-
Notifications
You must be signed in to change notification settings - Fork 0
/
firebase-node.js
132 lines (132 loc) · 64.9 KB
/
firebase-node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
function f(a){throw a;}var i=void 0,k=!0,l=null,o=!1;function aa(a){return function(){return this[a]}}function p(a){return function(){return a}}var r,ba=this;function ca(a,b){var c=a.split("."),d=ba;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)!c.length&&s(b)?d[e]=b:d=d[e]?d[e]:d[e]={}}function da(){}
function ea(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 s(a){return a!==i}function fa(a){var b=ea(a);return"array"==b||"object"==b&&"number"==typeof a.length}function t(a){return"string"==typeof a}function ga(a){return"number"==typeof a}function ha(a){var b=typeof a;return"object"==b&&a!=l||"function"==b}Math.floor(2147483648*Math.random()).toString(36);function ia(a,b,c){return a.call.apply(a.bind,arguments)}
function ja(a,b,c){a||f(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 v(a,b,c){v=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ia:ja;return v.apply(l,arguments)}function ka(a,b){function c(){}c.prototype=b.prototype;a.Pd=b.prototype;a.prototype=new c};function la(a){a=String(a);if(/^\s*$/.test(a)?0:/^[\],:{}\s\u2028\u2029]*$/.test(a.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r\u2028\u2029\x00-\x08\x10-\x1f\x80-\x9f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,"")))try{return eval("("+a+")")}catch(b){}f(Error("Invalid JSON string: "+a))}function ma(){this.ec=i}
function na(a,b,c){switch(typeof b){case "string":oa(b,c);break;case "number":c.push(isFinite(b)&&!isNaN(b)?b:"null");break;case "boolean":c.push(b);break;case "undefined":c.push("null");break;case "object":if(b==l){c.push("null");break}if("array"==ea(b)){var d=b.length;c.push("[");for(var e="",g=0;g<d;g++)c.push(e),e=b[g],na(a,a.ec?a.ec.call(b,String(g),e):e,c),e=",";c.push("]");break}c.push("{");d="";for(g in b)Object.prototype.hasOwnProperty.call(b,g)&&(e=b[g],"function"!=typeof e&&(c.push(d),
oa(g,c),c.push(":"),na(a,a.ec?a.ec.call(b,g,e):e,c),d=","));c.push("}");break;case "function":break;default:f(Error("Unknown type: "+typeof b))}}var pa={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\u000b"},qa=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;
function oa(a,b){b.push('"',a.replace(qa,function(a){if(a in pa)return pa[a];var b=a.charCodeAt(0),e="\\u";16>b?e+="000":256>b?e+="00":4096>b&&(e+="0");return pa[a]=e+b.toString(16)}),'"')};function ra(a){return"undefined"!==typeof JSON&&s(JSON.parse)?JSON.parse(a):la(a)}function y(a){if("undefined"!==typeof JSON&&s(JSON.stringify))a=JSON.stringify(a);else{var b=[];na(new ma,a,b);a=b.join("")}return a};function sa(a){for(var b=[],c=0,d=0;d<a.length;d++){var e=a.charCodeAt(d);55296<=e&&56319>=e&&(e-=55296,d++,z(d<a.length,"Surrogate pair missing trail surrogate."),e=65536+(e<<10)+(a.charCodeAt(d)-56320));128>e?b[c++]=e:(2048>e?b[c++]=e>>6|192:(65536>e?b[c++]=e>>12|224:(b[c++]=e>>18|240,b[c++]=e>>12&63|128),b[c++]=e>>6&63|128),b[c++]=e&63|128)}return b};function A(a,b,c,d){var e;d<b?e="at least "+b:d>c&&(e=0===c?"none":"no more than "+c);e&&f(Error(a+" failed: Was called with "+d+(1===d?" argument.":" arguments.")+" Expects "+e+"."))}function B(a,b,c){var d="";switch(b){case 1:d=c?"first":"First";break;case 2:d=c?"second":"Second";break;case 3:d=c?"third":"Third";break;case 4:d=c?"fourth":"Fourth";break;default:ta.assert(o,"errorPrefix_ called with argumentNumber > 4. Need to update it?")}return a+" failed: "+(d+" argument ")}
function C(a,b,c,d){(!d||s(c))&&"function"!=ea(c)&&f(Error(B(a,b,d)+"must be a valid function."))}function ua(a,b,c){s(c)&&(!ha(c)||c===l)&&f(Error(B(a,b,k)+"must be a valid context object."))};function D(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function va(a,b){if(Object.prototype.hasOwnProperty.call(a,b))return a[b]};var wa={},ta={},xa=/[\[\].#$\/]/,ya=/[\[\].#$]/;function za(a){return t(a)&&0!==a.length&&!xa.test(a)}function Aa(a,b,c){(!c||s(b))&&Ba(B(a,1,c),b)}
function Ba(a,b,c,d){c||(c=0);d||(d=[]);s(b)||f(Error(a+"contains undefined"+Ca(d)));"function"==ea(b)&&f(Error(a+"contains a function"+Ca(d)));Da(b)&&f(Error(a+"contains "+b.toString()+Ca(d)));1E3<c&&f(new TypeError(a+"contains a cyclic object value ("+d.slice(0,100).join(".")+"...)"));t(b)&&(b.length>10485760/3&&10485760<wa.Qd.Od(b).length)&&f(Error(a+"contains a string greater than 10485760 utf8 bytes"+Ca(d)+" ('"+b.substring(0,50)+"...')"));if(ha(b))for(var e in b)D(b,e)&&(".priority"!==e&&(".value"!==
e&&!za(e))&&f(Error(a+"contains an invalid key ("+e+")"+Ca(d)+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"')),d.push(e),Ba(a,b[e],c+1,d),d.pop())}function Ca(a){return 0==a.length?"":" in property "+a.join(".")}function Ea(a,b){ha(b)||f(Error(B(a,1,o)+" must be an object containing the children to replace."));Aa(a,b,o)}function Fa(a,b,c,d){(!d||s(c))&&(c!==l&&!ga(c)&&!t(c))&&f(Error(B(a,b,d)+"must be a valid firebase priority (null or a string.)"))}
function Ga(a,b,c){if(!c||s(b))switch(b){case "value":case "child_added":case "child_removed":case "child_changed":case "child_moved":break;default:f(Error(B(a,1,c)+'must be a valid event type: "value", "child_added", "child_removed", "child_changed", or "child_moved".'))}}function Ha(a,b){s(b)&&!za(b)&&f(Error(B(a,2,k)+'must be a valid firebase key (non-empty string, not containing ".", "#", "$", "/", "[", or "]").'))}
function Ia(a,b){(!t(b)||0===b.length||ya.test(b))&&f(Error(B(a,1,o)+'must be a non-empty string and can\'t contain ".", "#", "$", "[", or "]".'))}function E(a,b){".info"===F(b)&&f(Error(a+" failed: Can't modify data under /.info/"))};function G(a,b,c,d,e,g,h){this.u=a;this.path=b;this.xa=c;this.fa=d;this.qa=e;this.va=g;this.Ta=h;s(this.fa)&&(s(this.va)&&s(this.xa))&&f("Query: Can't combine startAt(), endAt(), and limit().")}G.prototype.sc=function(a,b){A("Query.on",2,4,arguments.length);Ga("Query.on",a,o);C("Query.on",2,b,o);var c=Ja("Query.on",arguments[2],arguments[3]);this.u.Hb(this,a,b,c.cancel,c.$);return b};G.prototype.on=G.prototype.sc;
G.prototype.Qb=function(a,b,c){A("Query.off",0,3,arguments.length);Ga("Query.off",a,k);C("Query.off",2,b,k);ua("Query.off",3,c);this.u.dc(this,a,b,c)};G.prototype.off=G.prototype.Qb;G.prototype.yd=function(a,b){function c(h){g&&(g=o,e.Qb(a,c),b.call(d.$,h))}A("Query.once",2,4,arguments.length);Ga("Query.once",a,o);C("Query.once",2,b,o);var d=Ja("Query.once",arguments[2],arguments[3]),e=this,g=k;this.sc(a,c,function(){e.Qb(a,c);d.cancel&&d.cancel.call(d.$)})};G.prototype.once=G.prototype.yd;
G.prototype.vd=function(a){A("Query.limit",1,1,arguments.length);(!ga(a)||Math.floor(a)!==a||0>=a)&&f("Query.limit: First argument must be a positive integer.");return new G(this.u,this.path,a,this.fa,this.qa,this.va,this.Ta)};G.prototype.limit=G.prototype.vd;G.prototype.Id=function(a,b){A("Query.startAt",0,2,arguments.length);Fa("Query.startAt",1,a,k);Ha("Query.startAt",b);s(a)||(b=a=l);return new G(this.u,this.path,this.xa,a,b,this.va,this.Ta)};G.prototype.startAt=G.prototype.Id;
G.prototype.qd=function(a,b){A("Query.endAt",0,2,arguments.length);Fa("Query.endAt",1,a,k);Ha("Query.endAt",b);return new G(this.u,this.path,this.xa,this.fa,this.qa,a,b)};G.prototype.endAt=G.prototype.qd;function Ka(a){var b={};s(a.fa)&&(b.sp=a.fa);s(a.qa)&&(b.sn=a.qa);s(a.va)&&(b.ep=a.va);s(a.Ta)&&(b.en=a.Ta);s(a.xa)&&(b.l=a.xa);s(a.fa)&&(s(a.qa)&&a.fa===l&&a.qa===l)&&(b.vf="l");return b}G.prototype.La=function(){var a=La(Ka(this));return"{}"===a?"default":a};
function Ja(a,b,c){var d={};b&&c?(d.cancel=b,C(a,3,d.cancel,k),d.$=c,ua(a,4,d.$)):b&&("object"===typeof b&&b!==l?d.$=b:"function"===typeof b?d.cancel=b:f(Error(B(a,3,k)+"must either be a cancel callback or a context object.")));return d};function I(a){if(a instanceof I)return a;if(1==arguments.length){this.m=a.split("/");for(var b=0,c=0;c<this.m.length;c++)0<this.m[c].length&&(this.m[b]=this.m[c],b++);this.m.length=b;this.da=0}else this.m=arguments[0],this.da=arguments[1]}function F(a){return a.da>=a.m.length?l:a.m[a.da]}function Ma(a){var b=a.da;b<a.m.length&&b++;return new I(a.m,b)}function Na(a){return a.da<a.m.length?a.m[a.m.length-1]:l}r=I.prototype;
r.toString=function(){for(var a="",b=this.da;b<this.m.length;b++)""!==this.m[b]&&(a+="/"+this.m[b]);return a||"/"};r.parent=function(){if(this.da>=this.m.length)return l;for(var a=[],b=this.da;b<this.m.length-1;b++)a.push(this.m[b]);return new I(a,0)};r.D=function(a){for(var b=[],c=this.da;c<this.m.length;c++)b.push(this.m[c]);if(a instanceof I)for(c=a.da;c<a.m.length;c++)b.push(a.m[c]);else{a=a.split("/");for(c=0;c<a.length;c++)0<a[c].length&&b.push(a[c])}return new I(b,0)};
r.f=function(){return this.da>=this.m.length};function Oa(a,b){var c=F(a);if(c===l)return b;if(c===F(b))return Oa(Ma(a),Ma(b));f("INTERNAL ERROR: innerPath ("+b+") is not within outerPath ("+a+")")}r.contains=function(a){var b=0;if(this.m.length>a.m.length)return o;for(;b<this.m.length;){if(this.m[b]!==a.m[b])return o;++b}return k};function Ra(){this.children={};this.Jb=0;this.value=l}function Sa(a,b,c){this.ya=a?a:"";this.ub=b?b:l;this.o=c?c:new Ra}function J(a,b){for(var c=b instanceof I?b:new I(b),d=a,e;(e=F(c))!==l;)d=new Sa(e,d,va(d.o.children,e)||new Ra),c=Ma(c);return d}r=Sa.prototype;r.j=function(){return this.o.value};function M(a,b){z("undefined"!==typeof b);a.o.value=b;Ta(a)}r.clear=function(){this.o.value=l;this.o.children={};this.o.Jb=0;Ta(this)};r.Mb=function(){return 0<this.o.Jb};
r.f=function(){return this.j()===l&&!this.Mb()};r.B=function(a){for(var b in this.o.children)a(new Sa(b,this,this.o.children[b]))};function Ua(a,b,c,d){c&&!d&&b(a);a.B(function(a){Ua(a,b,k,d)});c&&d&&b(a)}function Va(a,b,c){for(a=c?a:a.parent();a!==l;){if(b(a))return k;a=a.parent()}return o}r.path=function(){return new I(this.ub===l?this.ya:this.ub.path()+"/"+this.ya)};r.name=aa("ya");r.parent=aa("ub");
function Ta(a){if(a.ub!==l){var b=a.ub,c=a.ya,d=a.f(),e=D(b.o.children,c);d&&e?(delete b.o.children[c],b.o.Jb--,Ta(b)):!d&&!e&&(b.o.children[c]=a.o,b.o.Jb++,Ta(b))}};function Wa(a,b){this.Qa=a?a:Xa;this.ea=b?b:Ya}function Xa(a,b){return a<b?-1:a>b?1:0}r=Wa.prototype;r.na=function(a,b){return new Wa(this.Qa,this.ea.na(a,b,this.Qa).copy(l,l,o,l,l))};r.remove=function(a){return new Wa(this.Qa,this.ea.remove(a,this.Qa).copy(l,l,o,l,l))};r.get=function(a){for(var b,c=this.ea;!c.f();){b=this.Qa(a,c.key);if(0===b)return c.value;0>b?c=c.left:0<b&&(c=c.right)}return l};
function Za(a,b){for(var c,d=a.ea,e=l;!d.f();){c=a.Qa(b,d.key);if(0===c){if(d.left.f())return e?e.key:l;for(d=d.left;!d.right.f();)d=d.right;return d.key}0>c?d=d.left:0<c&&(e=d,d=d.right)}f(Error("Attempted to find predecessor key for a nonexistent key. What gives?"))}r.f=function(){return this.ea.f()};r.count=function(){return this.ea.count()};r.pb=function(){return this.ea.pb()};r.Wa=function(){return this.ea.Wa()};r.wa=function(a){return this.ea.wa(a)};r.Ma=function(a){return this.ea.Ma(a)};
r.Ua=function(a){return new $a(this.ea,a)};function $a(a,b){this.$c=b;for(this.Ob=[];!a.f();)this.Ob.push(a),a=a.left}function ab(a){if(0===a.Ob.length)return l;var b=a.Ob.pop(),c;c=a.$c?a.$c(b.key,b.value):{key:b.key,value:b.value};for(b=b.right;!b.f();)a.Ob.push(b),b=b.left;return c}function bb(a,b,c,d,e){this.key=a;this.value=b;this.color=c!=l?c:k;this.left=d!=l?d:Ya;this.right=e!=l?e:Ya}r=bb.prototype;
r.copy=function(a,b,c,d,e){return new bb(a!=l?a:this.key,b!=l?b:this.value,c!=l?c:this.color,d!=l?d:this.left,e!=l?e:this.right)};r.count=function(){return this.left.count()+1+this.right.count()};r.f=p(o);r.wa=function(a){return this.left.wa(a)||a(this.key,this.value)||this.right.wa(a)};r.Ma=function(a){return this.right.Ma(a)||a(this.key,this.value)||this.left.Ma(a)};function cb(a){return a.left.f()?a:cb(a.left)}r.pb=function(){return cb(this).key};
r.Wa=function(){return this.right.f()?this.key:this.right.Wa()};r.na=function(a,b,c){var d,e;e=this;d=c(a,e.key);e=0>d?e.copy(l,l,l,e.left.na(a,b,c),l):0===d?e.copy(l,b,l,l,l):e.copy(l,l,l,l,e.right.na(a,b,c));return db(e)};function eb(a){if(a.left.f())return Ya;!a.left.I()&&!a.left.left.I()&&(a=gb(a));a=a.copy(l,l,l,eb(a.left),l);return db(a)}
r.remove=function(a,b){var c,d;c=this;if(0>b(a,c.key))!c.left.f()&&(!c.left.I()&&!c.left.left.I())&&(c=gb(c)),c=c.copy(l,l,l,c.left.remove(a,b),l);else{c.left.I()&&(c=hb(c));!c.right.f()&&(!c.right.I()&&!c.right.left.I())&&(c=ib(c),c.left.left.I()&&(c=hb(c),c=ib(c)));if(0===b(a,c.key)){if(c.right.f())return Ya;d=cb(c.right);c=c.copy(d.key,d.value,l,l,eb(c.right))}c=c.copy(l,l,l,l,c.right.remove(a,b))}return db(c)};r.I=aa("color");
function db(a){a.right.I()&&!a.left.I()&&(a=jb(a));a.left.I()&&a.left.left.I()&&(a=hb(a));a.left.I()&&a.right.I()&&(a=ib(a));return a}function gb(a){a=ib(a);a.right.left.I()&&(a=a.copy(l,l,l,l,hb(a.right)),a=jb(a),a=ib(a));return a}function jb(a){var b;b=a.copy(l,l,k,l,a.right.left);return a.right.copy(l,l,a.color,b,l)}function hb(a){var b;b=a.copy(l,l,k,a.left.right,l);return a.left.copy(l,l,a.color,l,b)}
function ib(a){var b,c;b=a.left.copy(l,l,!a.left.color,l,l);c=a.right.copy(l,l,!a.right.color,l,l);return a.copy(l,l,!a.color,b,c)}function kb(){}r=kb.prototype;r.copy=function(){return this};r.na=function(a,b){return new bb(a,b,i,i,i)};r.remove=function(){return this};r.get=p(l);r.count=p(0);r.f=p(k);r.wa=p(o);r.Ma=p(o);r.pb=p(l);r.Wa=p(l);r.I=p(o);var Ya=new kb;var lb=Array.prototype,mb=lb.forEach?function(a,b,c){lb.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=t(a)?a.split(""):a,g=0;g<d;g++)g in e&&b.call(c,e[g],g,a)},nb=lb.map?function(a,b,c){return lb.map.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=Array(d),g=t(a)?a.split(""):a,h=0;h<d;h++)h in g&&(e[h]=b.call(c,g[h],h,a));return e};function ob(){};function pb(){this.z=[];this.lc=[];this.md=[];this.Wb=[];this.Wb[0]=128;for(var a=1;64>a;++a)this.Wb[a]=0;this.reset()}ka(pb,ob);pb.prototype.reset=function(){this.z[0]=1732584193;this.z[1]=4023233417;this.z[2]=2562383102;this.z[3]=271733878;this.z[4]=3285377520;this.Ec=this.lb=0};
function qb(a,b){var c;c||(c=0);for(var d=a.md,e=c;e<c+64;e+=4)d[e/4]=b[e]<<24|b[e+1]<<16|b[e+2]<<8|b[e+3];for(e=16;80>e;e++){var g=d[e-3]^d[e-8]^d[e-14]^d[e-16];d[e]=(g<<1|g>>>31)&4294967295}c=a.z[0];for(var h=a.z[1],j=a.z[2],m=a.z[3],n=a.z[4],q,e=0;80>e;e++)40>e?20>e?(g=m^h&(j^m),q=1518500249):(g=h^j^m,q=1859775393):60>e?(g=h&j|m&(h|j),q=2400959708):(g=h^j^m,q=3395469782),g=(c<<5|c>>>27)+g+n+q+d[e]&4294967295,n=m,m=j,j=(h<<30|h>>>2)&4294967295,h=c,c=g;a.z[0]=a.z[0]+c&4294967295;a.z[1]=a.z[1]+h&
4294967295;a.z[2]=a.z[2]+j&4294967295;a.z[3]=a.z[3]+m&4294967295;a.z[4]=a.z[4]+n&4294967295}pb.prototype.update=function(a,b){s(b)||(b=a.length);var c=this.lc,d=this.lb,e=0;if(t(a))for(;e<b;)c[d++]=a.charCodeAt(e++),64==d&&(qb(this,c),d=0);else for(;e<b;)c[d++]=a[e++],64==d&&(qb(this,c),d=0);this.lb=d;this.Ec+=b};function rb(){this.Pa={};this.length=0}rb.prototype.setItem=function(a,b){D(this.Pa,a)||(this.length+=1);this.Pa[a]=b};rb.prototype.getItem=function(a){return D(this.Pa,a)?this.Pa[a]:l};rb.prototype.removeItem=function(a){D(this.Pa,a)&&(this.length-=1,delete this.Pa[a])};var N=l;if("undefined"!==typeof sessionStorage)try{sessionStorage.setItem("firebase-sentinel","cache"),sessionStorage.removeItem("firebase-sentinel"),N=sessionStorage}catch(sb){N=new rb}else N=new rb;function tb(a,b,c,d){this.host=a;this.Cb=b;this.Xa=c;this.P=d||N.getItem(a)||this.host}function ub(a,b){b!==a.P&&(a.P=b,"s-"===a.P.substr(0,2)&&N.setItem(a.host,a.P))}tb.prototype.toString=function(){return(this.Cb?"https://":"http://")+this.host};var vb,wb,xb,yb;function zb(){return ba.navigator?ba.navigator.userAgent:l}yb=xb=wb=vb=o;var Ab;if(Ab=zb()){var Bb=ba.navigator;vb=0==Ab.indexOf("Opera");wb=!vb&&-1!=Ab.indexOf("MSIE");xb=!vb&&-1!=Ab.indexOf("WebKit");yb=!vb&&!xb&&"Gecko"==Bb.product}var Cb=wb,Db=yb,Eb=xb;var Fb;if(vb&&ba.opera){var Gb=ba.opera.version;"function"==typeof Gb&&Gb()}else Db?Fb=/rv\:([^\);]+)(\)|;)/:Cb?Fb=/MSIE\s+([^\);]+)(\)|;)/:Eb&&(Fb=/WebKit\/(\S+)/),Fb&&Fb.exec(zb());var Hb=l,Ib=l;
function Jb(a,b){fa(a)||f(Error("encodeByteArray takes an array as a parameter"));if(!Hb){Hb={};Ib={};for(var c=0;65>c;c++)Hb[c]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(c),Ib[c]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(c)}for(var c=b?Ib:Hb,d=[],e=0;e<a.length;e+=3){var g=a[e],h=e+1<a.length,j=h?a[e+1]:0,m=e+2<a.length,n=m?a[e+2]:0,q=g>>2,g=(g&3)<<4|j>>4,j=(j&15)<<2|n>>6,n=n&63;m||(n=64,h||(j=64));d.push(c[q],c[g],c[j],c[n])}return d.join("")}
;var Kb,Lb=1;Kb=function(){return Lb++};function z(a,b){a||f(Error("Firebase INTERNAL ASSERT FAILED:"+b))}function Mb(a){a=sa(a);return Jb(a,k)}function Nb(a){var b=sa(a),a=new pb;a.update(b);var b=[],c=8*a.Ec;56>a.lb?a.update(a.Wb,56-a.lb):a.update(a.Wb,64-(a.lb-56));for(var d=63;56<=d;d--)a.lc[d]=c&255,c/=256;qb(a,a.lc);for(d=c=0;5>d;d++)for(var e=24;0<=e;e-=8)b[c++]=a.z[d]>>e&255;return Jb(b)}
function Ob(){for(var a="",b=0;b<arguments.length;b++)a=fa(arguments[b])?a+Ob.apply(l,arguments[b]):"object"===typeof arguments[b]?a+y(arguments[b]):a+arguments[b],a+=" ";return a}var Pb=l,Qb=k;function Rb(){Qb===k&&(Qb=o,Pb===l&&"true"===N.getItem("logging_enabled")&&Sb(k));if(Pb){var a=Ob.apply(l,arguments);Pb(a)}}function Tb(a){return function(){Rb(a,arguments)}}
function Ub(){if("undefined"!==typeof console){var a="FIREBASE INTERNAL ERROR: "+Ob.apply(l,arguments);"undefined"!==typeof console.error?console.error(a):console.log(a)}}function Wb(){var a=Ob.apply(l,arguments);f(Error("FIREBASE FATAL ERROR: "+a))}function Xb(){if("undefined"!==typeof console){var a="FIREBASE WARNING: "+Ob.apply(l,arguments);"undefined"!==typeof console.warn?console.warn(a):console.log(a)}}
function Da(a){return ga(a)&&(a!=a||a==Number.POSITIVE_INFINITY||a==Number.NEGATIVE_INFINITY)}function Yb(a,b){return a!==b?a===l?-1:b===l?1:typeof a!==typeof b?"number"===typeof a?-1:1:a>b?1:-1:0}function Zb(a,b){if(b&&a in b)return b[a];f(Error("Missing required key ("+a+") in object: "+y(b)))}var $b=0;function La(a){if("object"!==typeof a||a===l)return y(a);var b=[],c;for(c in a)b.push(c);b.sort();c="{";for(var d=0;d<b.length;d++)0!==d&&(c+=","),c+=y(b[d]),c+=":",c+=La(a[b[d]]);return c+"}"}
function ac(a,b){if(a.length<=b)return[a];for(var c=[],d=0;d<a.length;d+=b)d+b>a?c.push(a.substring(d,a.length)):c.push(a.substring(d,d+b));return c}
function bc(a){z(!Da(a));var b,c,d,e;0===a?(d=c=0,b=-Infinity===1/a?1:0):(b=0>a,a=Math.abs(a),a>=Math.pow(2,-1022)?(d=Math.min(Math.floor(Math.log(a)/Math.LN2),1023),c=d+1023,d=Math.round(a*Math.pow(2,52-d)-Math.pow(2,52))):(c=0,d=Math.round(a/Math.pow(2,-1074))));e=[];for(a=52;a;a-=1)e.push(d%2?1:0),d=Math.floor(d/2);for(a=11;a;a-=1)e.push(c%2?1:0),c=Math.floor(c/2);e.push(b?1:0);e.reverse();b=e.join("");c="";for(a=0;64>a;a+=8)d=parseInt(b.substr(a,8),2).toString(16),1===d.length&&(d="0"+d),c+=d;
return c.toLowerCase()};function cc(a,b){this.ta=a;z(this.ta!==l,"LeafNode shouldn't be created with null value.");this.Ya="undefined"!==typeof b?b:l}r=cc.prototype;r.L=p(k);r.k=aa("Ya");r.jc=function(a){return new cc(this.ta,a)};r.O=function(){return O};r.G=function(a){return F(a)===l?this:O};r.V=p(l);r.F=function(a,b){return(new P(new Wa,this.Ya)).F(a,b)};r.bb=function(a,b){var c=F(a);return c===l?b:this.F(c,O.bb(Ma(a),b))};r.f=p(o);r.Pb=p(0);
r.R=function(a){return a&&this.k()!==l?{".value":this.j(),".priority":this.k()}:this.j()};r.hash=function(){var a="";this.k()!==l&&(a+="priority:"+dc(this.k())+":");var b=typeof this.ta,a=a+(b+":"),a="number"===b?a+bc(this.ta):a+this.ta;return Nb(a)};r.j=aa("ta");r.toString=function(){return"string"===typeof this.ta?'"'+this.ta+'"':this.ta};function P(a,b){this.T=a||new Wa;this.Ya="undefined"!==typeof b?b:l}r=P.prototype;r.L=p(o);r.k=aa("Ya");r.jc=function(a){return new P(this.T,a)};r.F=function(a,b){var c=this.T.remove(a);b&&b.f()&&(b=l);b!==l&&(c=c.na(a,b));return b&&b.k()!==l?new ec(c,l,this.Ya):new P(c,this.Ya)};r.bb=function(a,b){var c=F(a);if(c===l)return b;var d=this.O(c).bb(Ma(a),b);return this.F(c,d)};r.f=function(){return this.T.f()};r.Pb=function(){return this.T.count()};var fc=/^\d+$/;r=P.prototype;
r.R=function(a){if(this.f())return l;var b={},c=0,d=0,e=k;this.B(function(g,h){b[g]=h.R(a);c++;e&&fc.test(g)?d=Math.max(d,Number(g)):e=o});if(!a&&e&&d<2*c){var g=[],h;for(h in b)g[h]=b[h];return g}a&&this.k()!==l&&(b[".priority"]=this.k());return b};r.hash=function(){var a="";this.k()!==l&&(a+="priority:"+dc(this.k())+":");this.B(function(b,c){var d=c.hash();""!==d&&(a+=":"+b+":"+d)});return""===a?"":Nb(a)};r.O=function(a){a=this.T.get(a);return a===l?O:a};
r.G=function(a){var b=F(a);return b===l?this:this.O(b).G(Ma(a))};r.V=function(a){return Za(this.T,a)};r.Nc=function(){return this.T.pb()};r.Oc=function(){return this.T.Wa()};r.B=function(a){return this.T.wa(a)};r.nc=function(a){return this.T.Ma(a)};r.Ua=function(){return this.T.Ua()};r.toString=function(){var a="{",b=k;this.B(function(c,d){b?b=o:a+=", ";a+='"'+c+'" : '+d.toString()});return a+="}"};var O=new P(new Wa);function ec(a,b,c){P.call(this,a,c);b===l&&(b=new Wa(gc),a.wa(function(a,c){b=b.na({name:a,Aa:c.k()},c)}));this.pa=b}ka(ec,P);r=ec.prototype;r.F=function(a,b){var c=this.O(a),d=this.T,e=this.pa;c!==l&&(d=d.remove(a),e=e.remove({name:a,Aa:c.k()}));b&&b.f()&&(b=l);b!==l&&(d=d.na(a,b),e=e.na({name:a,Aa:b.k()},b));return new ec(d,e,this.k())};r.V=function(a,b){var c=Za(this.pa,{name:a,Aa:b.k()});return c?c.name:l};r.B=function(a){return this.pa.wa(function(b,c){return a(b.name,c)})};
r.nc=function(a){return this.pa.Ma(function(b,c){return a(b.name,c)})};r.Ua=function(){return this.pa.Ua(function(a,b){return{key:a.name,value:b}})};r.Nc=function(){return this.pa.f()?l:this.pa.pb().name};r.Oc=function(){return this.pa.f()?l:this.pa.Wa().name};function Q(a,b){if("object"!==typeof a)return new cc(a,b);if(a===l)return O;var c=l;".priority"in a?c=a[".priority"]:"undefined"!==typeof b&&(c=b);z(c===l||"string"===typeof c||"number"===typeof c);if(".value"in a&&a[".value"]!==l)return new cc(a[".value"],c);var c=new P(new Wa,c),d;for(d in a)if(D(a,d)&&"."!==d.substring(0,1)){var e=Q(a[d]);if(e.L()||!e.f())c=c.F(d,e)}return c}function gc(a,b){return Yb(a.Aa,b.Aa)||(a.name!==b.name?a.name<b.name?-1:1:0)}
function dc(a){return"number"===typeof a?"number:"+bc(a):"string:"+a};function R(a,b){this.o=a;this.cc=b}R.prototype.R=function(){A("Firebase.DataSnapshot.val",0,0,arguments.length);return this.o.R()};R.prototype.val=R.prototype.R;R.prototype.rd=function(){A("Firebase.DataSnapshot.exportVal",0,0,arguments.length);return this.o.R(k)};R.prototype.exportVal=R.prototype.rd;R.prototype.D=function(a){A("Firebase.DataSnapshot.child",0,1,arguments.length);ga(a)&&(a=String(a));Ia("Firebase.DataSnapshot.child",a);var b=new I(a),c=this.cc.D(b);return new R(this.o.G(b),c)};
R.prototype.child=R.prototype.D;R.prototype.oc=function(a){A("Firebase.DataSnapshot.hasChild",1,1,arguments.length);Ia("Firebase.DataSnapshot.hasChild",a);var b=new I(a);return!this.o.G(b).f()};R.prototype.hasChild=R.prototype.oc;R.prototype.k=function(){A("Firebase.DataSnapshot.getPriority",0,0,arguments.length);return this.o.k()};R.prototype.getPriority=R.prototype.k;
R.prototype.forEach=function(a){A("Firebase.DataSnapshot.forEach",1,1,arguments.length);C("Firebase.DataSnapshot.forEach",1,a,o);if(this.o.L())return o;var b=this;return this.o.B(function(c,d){return a(new R(d,b.cc.D(c)))})};R.prototype.forEach=R.prototype.forEach;R.prototype.Mb=function(){A("Firebase.DataSnapshot.hasChildren",0,0,arguments.length);return this.o.L()?o:!this.o.f()};R.prototype.hasChildren=R.prototype.Mb;
R.prototype.name=function(){A("Firebase.DataSnapshot.name",0,0,arguments.length);return this.cc.name()};R.prototype.name=R.prototype.name;R.prototype.Pb=function(){A("Firebase.DataSnapshot.numChildren",0,0,arguments.length);return this.o.Pb()};R.prototype.numChildren=R.prototype.Pb;R.prototype.Bd=function(){A("Firebase.DataSnapshot.ref",0,0,arguments.length);return this.cc};R.prototype.ref=R.prototype.Bd;function hc(a){this.wc=a;this.Yb=[];this.Sa=0;this.mc=-1;this.Ka=l}function ic(a,b,c){for(a.Yb[b]=c;a.Yb[a.Sa];){b=a.Yb[a.Sa];delete a.Yb[a.Sa];for(c=0;c<b.length;++c)b[c]&&a.wc(b[c]);if(a.Sa===a.mc){a.Ka&&(clearTimeout(a.Ka),a.Ka(),a.Ka=l);break}a.Sa++}};function S(a,b){for(var c in a)b.call(i,a[c],c,a)}function jc(a){var b={},c;for(c in a)b[c]=a[c];return b};function kc(){this.gb={}}function lc(a,b,c){s(c)||(c=1);D(a.gb,b)||(a.gb[b]=0);a.gb[b]+=c}kc.prototype.get=function(){return jc(this.gb)};function mc(a){this.nd=a;this.Nb=l}mc.prototype.get=function(){var a=this.nd.get(),b=jc(a);if(this.Nb)for(var c in this.Nb)b[c]-=this.Nb[c];this.Nb=a;return b};function nc(a,b){this.ed={};this.fc=new mc(a);this.n=b;setTimeout(v(this.Yc,this),10+6E4*Math.random())}nc.prototype.Yc=function(){var a=this.fc.get(),b={},c=o,d;for(d in a)0<a[d]&&D(this.ed,d)&&(b[d]=a[d],c=k);c&&(a=this.n,a.U&&(b={c:b},a.e("reportStats",b),a.Ca("s",b)));setTimeout(v(this.Yc,this),6E5*Math.random())};var oc={},pc={};function qc(a){a=a.toString();oc[a]||(oc[a]=new kc);return oc[a]};var rc=require("http");function sc(a,b,c){this.Kb=a;this.e=Tb(a);this.C=b;this.Y=qc(b);this.Oa=c;this.aa=this.Ia=o;this.ba=new tc;this.buffer={};this.ca=[];this.Ad=function(a){b.host!==b.P&&(a.ns=b.Xa);var c=[],g;for(g in a)a.hasOwnProperty(g)&&c.push(g+"="+a[g]);return"/.hp?"+c.join("&")}}sc.isAvailable=p(o);r=sc.prototype;
r.open=function(a,b){this.hb=0;this.X=b;this.zd=new hc(a);var c=this;this.K=setTimeout(function(){c.e("Timed out trying to connect.");c.close();c.K=l},3E4);var d=Math.floor(1E8*Math.random()),e={start:"t"};e.ser=d;e.v="5";this.Oa&&(e.s=this.Oa);this.e("Connecting via httppoll to "+this.C.P);uc(this,d,e)};r.start=function(){this.eb=k;for(this.ib=Math.floor(1E8*Math.random());this.za(););};
r.send=function(a){for(var a=y(a),a=Mb(a),a=ac(a,1048576),b=0;b<a.length;++b)this.ca.push({zc:this.hb,Gc:a.length,jb:a[b]}),this.eb&&this.za(),this.hb++};r.close=function(){if(!this.aa){this.e("Httppoll is being closed");if(this.eb&&this.id&&this.vb){this.e("doing a disconnect");var a={};a.id=this.id;a.pw=this.vb;a.disconn="t";uc(this,0,a)}this.Ea()}};
r.za=function(){if(this.eb&&this.ba.count()<(0<this.ca.length?2:1)){var a=this.ib++,b={};b.id=this.id;b.pw=this.vb;b.ser=a;for(var c=[];0<this.ca.length;)if(1048608>=this.ca[0].jb.length){var d=this.ca.shift();c.push(d.zc+":"+d.Gc+":"+d.jb)}else break;var e=this,d=setTimeout(function(){e.ba.remove(a);e.za()},25E3);this.ba.add(a,d);uc(this,a,b,c.join("\n"));return k}return o};r.ha=function(){this.aa||(this.e("Httppoll is closing itself"),this.Ea(),this.X&&(this.X(this.Ia),this.X=l))};
r.Ea=function(){this.aa=k;this.eb=o;this.K&&(clearTimeout(this.K),this.K=l);S(this.ba.set,function(a){clearTimeout(a)});this.ba.clear()};
function uc(a,b,c,d){var d=d||"",c=a.Ad(c),e=a.C.P,g=e.split(":"),h=a.C.Cb?443:80;1<g.length&&(e=g[0],h=parseInt(g[1]));c=rc.request({method:"POST",host:e,port:h,path:c},function(c){if(a.K){clearTimeout(a.K);a.K=l}var d=a.ba.get(b);d&&clearTimeout(d);a.ba.remove(b);a.za();if(c.statusCode!=200){a.e("error code received: "+c.statusCode);a.ha()}else{if("x-firebase-poll-id"in c.headers&&"x-firebase-poll-pw"in c.headers){a.id=c.headers["x-firebase-poll-id"];a.vb=c.headers["x-firebase-poll-pw"]}if("x-firebase-poll-close"in
c.headers){a.e("recvd close");a.eb=o}c.on("data",function(b){b=b.toString();a.buffer[c]=c in a.buffer?a.buffer[c]+b:b});c.on("end",function(){if(c in a.buffer){var b=a.buffer[c];delete a.buffer[c];var b=ra(b),d=parseInt(Zb("x-firebase-response",c.headers));ic(a.zd,d,b)}})}});c.on("error",function(b){a.e("An error occurred: "+b.message);a.ha()});c.end(d)};var vc=l,vc=require("faye-websocket").Client;function wc(a,b,c){this.Kb=a;this.e=Tb(this.Kb);this.frames=this.nb=l;this.Dc=0;this.Y=qc(b);this.Ra=(b.Cb?"wss://":"ws://")+b.P+"/.ws?v=5";b.host!==b.P&&(this.Ra=this.Ra+"&ns="+b.Xa);c&&(this.Ra=this.Ra+"&s="+c)}var xc;
wc.prototype.open=function(a,b){this.ia=b;this.Ub=a;this.e("websocket connecting to "+this.Ra);this.W=new vc(this.Ra);this.Ia=o;var c=this;this.W.onopen=function(){c.e("Websocket connected.");c.Ia=k};this.W.onclose=function(){c.e("Websocket connection was disconnected.");c.W=l;c.ha()};this.W.onmessage=function(a){if(c.W!==l)if(a=a.data,lc(c.Y,"bytes_received",a.length),yc(c),c.frames!==l)zc(c,a);else{a:{z(c.frames===l,"We already have a frame buffer");if(4>=a.length){var b=Number(a);if(!isNaN(b)){c.Dc=
b;c.frames=[];a=l;break a}}c.Dc=1;c.frames=[]}a!==l&&zc(c,a)}};this.W.onerror=function(){c.e("WebSocket error. Closing connection.");c.ha()}};wc.prototype.start=function(){};wc.isAvailable=function(){return!("undefined"!==typeof navigator&&"Opera"===navigator.appName)&&vc!==l&&!xc};function zc(a,b){a.frames.push(b);if(a.frames.length==a.Dc){var c=a.frames.join("");a.frames=l;c=ra(c);a.Ub(c)}}
wc.prototype.send=function(a){yc(this);a=y(a);lc(this.Y,"bytes_sent",a.length);a=ac(a,16384);1<a.length&&this.W.send(String(a.length));for(var b=0;b<a.length;b++)this.W.send(a[b])};wc.prototype.Ea=function(){this.aa=k;this.nb&&(clearTimeout(this.nb),this.nb=l);this.W&&(this.W.close(),this.W=l)};wc.prototype.ha=function(){this.aa||(this.e("WebSocket is closing itself"),this.Ea(),this.ia&&(this.ia(this.Ia),this.ia=l))};wc.prototype.close=function(){this.aa||(this.e("WebSocket is being closed"),this.Ea())};
function yc(a){clearTimeout(a.nb);a.nb=setInterval(function(){a.W.send("0");yc(a)},45E3)};function tc(){this.set={}}r=tc.prototype;r.add=function(a,b){this.set[a]=b!==l?b:k};r.contains=function(a){return D(this.set,a)};r.get=function(a){return this.set[a]};r.remove=function(a){delete this.set[a]};r.clear=function(){this.set={}};r.f=function(){var a;a:{for(a in this.set){a=o;break a}a=k}return a};r.count=function(){var a=0,b;for(b in this.set)a++;return a};r.keys=function(){var a=[],b;for(b in this.set)D(this.set,b)&&a.push(b);return a};function Ac(a,b,c){this.Kb=a;this.e=Tb(a);this.Nd=b;this.Y=qc(b);this.Oa=c;this.Ia=o;this.Gb=function(a){b.host!==b.P&&(a.ns=b.Xa);var c=[],g;for(g in a)a.hasOwnProperty(g)&&c.push(g+"="+a[g]);return(b.Cb?"https://":"http://")+b.P+"/.lp?"+c.join("&")}}var Bc;
Ac.prototype.open=function(a,b){this.hb=0;this.X=b;this.Uc=new hc(a);this.aa=o;var c=this;this.K=setTimeout(function(){c.e("Timed out trying to connect.");c.ha();c.K=l},3E4);if(!c.aa){c.ja=new Cc(function(a,b,d,j,m){lc(c.Y,"bytes_received",y(arguments).length);if(c.ja)if(c.K&&(clearTimeout(c.K),c.K=l),c.Ia=k,"start"==a)c.id=b,c.vb=d;else if("close"===a)if(b){c.ja.cd=o;var n=c.Uc;n.mc=b;n.Ka=function(){c.ha()};n.mc<n.Sa&&(n.Ka(),n.Ka=l)}else c.ha();else f(Error("Unrecognized command received: "+a))},
function(a,b){lc(c.Y,"bytes_received",y(arguments).length);ic(c.Uc,a,b)},function(){c.ha()},c.Gb);var d={start:"t"};d.ser=Math.floor(1E8*Math.random());c.ja.Kd&&(d.cb=c.ja.Kd);d.v="5";c.Oa&&(d.s=c.Oa);d=c.Gb(d);c.e("Connecting via long-poll to "+d);Dc(c.ja,d,function(){})}};Ac.prototype.start=function(){var a=this.ja,b=this.vb;a.qc=this.id;a.Tc=b;for(a.kc=k;a.za(););};Ac.isAvailable=function(){return Bc||o};
Ac.prototype.Ea=function(){this.aa=k;this.ja&&(this.ja.close(),this.ja=l);this.Sc&&(document.body.removeChild(this.Sc),this.Sc=l);this.K&&(clearTimeout(this.K),this.K=l)};Ac.prototype.ha=function(){this.aa||(this.e("Longpoll is closing itself"),this.Ea(),this.X&&(this.X(this.Ia),this.X=l))};Ac.prototype.close=function(){this.aa||(this.e("Longpoll is being closed."),this.Ea())};
Ac.prototype.send=function(a){a=y(a);lc(this.Y,"bytes_sent",a.length);for(var a=Mb(a),a=ac(a,1840),b=0;b<a.length;b++){var c=this.ja;c.ca.push({zc:this.hb,Gc:a.length,jb:a[b]});c.kc&&c.za();this.hb++}};function Cc(a,b,c,d){this.Gb=d;this.ia=c;this.ba=new tc;this.ca=[];this.ib=Math.floor(1E8*Math.random());this.cd=k;this.od=a;this.xd=b}
Cc.prototype.close=function(){this.kc=o;this.rc&&(this.rc.Ld.body.innerHTML="",document.body.removeChild(this.rc),this.rc=l);if(this.qc){var a={disconn:"t"};a.id=this.qc;a.pw=this.Tc;a=this.Gb(a);Ec(a)}if(a=this.ia)this.ia=l,a()};
Cc.prototype.za=function(){if(this.kc&&this.cd&&this.ba.count()<(0<this.ca.length?2:1)){this.ib++;var a={};a.id=this.qc;a.pw=this.Tc;a.ser=this.ib;for(var a=this.Gb(a),b="",c=0;0<this.ca.length;)if(1870>=this.ca[0].jb.length+30+b.length){var d=this.ca.shift(),b=b+"&seg"+c+"="+d.zc+"&ts"+c+"="+d.Gc+"&d"+c+"="+d.jb;c++}else break;var a=a+b,e=this.ib,g=this;g.ba.add(e);var h=function(){g.ba.remove(e);g.za()},j=setTimeout(h,25E3);Dc(this,a,function(){clearTimeout(j);h()});return k}return o};
function Ec(a,b){Fc||(Fc=require("request"));Fc(a,function(a,d,e){a&&f("Rest request for "+url+" failed.");b&&b(e)})}var Fc;function Dc(a,b,c){Ec({url:b,Md:k},function(b){Gc(a,b);c()})}function Gc(a,b){eval("var document = function(pLPCommand, pRTLPCB) {"+b+"}");document(a.od,a.xd)};function Hc(){function a(a,c){c&&c.isAvailable()&&b.push(c)}var b=[],c=Ic;if("array"==ea(c))for(var d=0;d<c.length;++d)a(0,c[d]);else S(c,a);this.hc=b}var Ic=[Ac,sc,wc];function Jc(a,b,c,d,e,g){this.id=a;this.e=Tb("c:"+this.id+":");this.wc=c;this.sb=d;this.X=e;this.vc=g;this.C=b;this.Xb=[];this.Ic=0;this.Fc=new Hc;this.ra=0;this.e("Connection created");Kc(this)}function Kc(a){var b;var c=a.Fc;0<c.hc.length?b=c.hc[0]:f(Error("No transports available"));a.H=new b("c:"+a.id+":"+a.Ic++,a.C);var d=Lc(a,a.H),e=Mc(a,a.H);a.Eb=a.H;a.Bb=a.H;a.w=l;setTimeout(function(){a.H&&a.H.open(d,e)},0)}
function Mc(a,b){return function(c){b===a.H?(a.H=l,!c&&0===a.ra?(a.e("Realtime connection failed."),"s-"===a.C.P.substr(0,2)&&(N.removeItem(a.C.Xa),a.C.P=a.C.host)):1===a.ra&&a.e("Realtime connection lost."),a.close()):b===a.w?(c=a.w,a.w=l,(a.Eb===c||a.Bb===c)&&a.close()):a.e("closing an old connection")}}
function Lc(a,b){return function(c){if(2!=a.ra)if(b===a.Bb){var d=Zb("t",c),c=Zb("d",c);if("c"==d){if(d=Zb("t",c),"d"in c)if(c=c.d,"h"===d){var d=c.ts,e=c.v,g=c.h;a.Oa=c.s;ub(a.C,g);if(0==a.ra&&(a.H.start(),c=a.H,a.e("Realtime connection established."),a.H=c,a.ra=1,a.sb&&(a.sb(d),a.sb=l),"5"!==e&&Xb("Protocol version mismatch detected"),c=1<a.Fc.hc.length?a.Fc.hc[1]:l))a.w=new c("c:"+a.id+":"+a.Ic++,a.C,a.Oa),a.w.open(Lc(a,a.w),Mc(a,a.w))}else if("n"===d){a.e("recvd end transmission on primary");
a.Bb=a.w;for(c=0;c<a.Xb.length;++c)a.Sb(a.Xb[c]);a.Xb=[];Nc(a)}else"s"===d?(a.e("Connection shutdown command received. Shutting down..."),a.vc&&(a.vc(c),a.vc=l),a.X=l,a.close()):"r"===d?(a.e("Reset packet received. New host: "+c),ub(a.C,c),1===a.ra?a.close():(Oc(a),Kc(a))):Ub("Unknown control packet command: "+d)}else"d"==d&&a.Sb(c)}else b===a.w?(d=Zb("t",c),c=Zb("d",c),"c"==d?"t"in c&&(c=c.t,"a"===c?(a.w.start(),a.e("sending client ack on secondary"),a.w.send({t:"c",d:{t:"a",d:{}}}),a.e("Ending transmission on primary"),
a.H.send({t:"c",d:{t:"n",d:{}}}),a.Eb=a.w,Nc(a)):"r"===c&&(a.e("Got a reset on secondary, closing it"),a.w.close(),(a.Eb===a.w||a.Bb===a.w)&&a.close())):"d"==d?a.Xb.push(c):f(Error("Unknown protocol layer: "+d))):a.e("message on old connection")}}Jc.prototype.Ac=function(a){a={t:"d",d:a};1!==this.ra&&f("Connection is not connected");this.Eb.send(a)};function Nc(a){a.Eb===a.w&&a.Bb===a.w&&(a.e("cleaning up and promoting a connection: "+a.w.Kb),a.H=a.w,a.w=l)}Jc.prototype.Sb=function(a){this.wc(a)};
Jc.prototype.close=function(){2!==this.ra&&(this.e("Closing realtime connection."),this.ra=2,Oc(this),this.X&&(this.X(),this.X=l))};function Oc(a){a.e("Shutting down all connections");a.H&&(a.H.close(),a.H=l);a.w&&(a.w.close(),a.w=l)};function Pc(a,b,c,d){this.id=Qc++;this.e=Tb("p:"+this.id+":");this.Db=k;this.ga={};this.Q=[];this.tb=0;this.rb=[];this.U=o;this.bc=1E3;this.Tb=b||da;this.Rb=c||da;this.qb=d||da;this.C=a;this.yc=l;this.Zb=[];this.Ba={};this.Ed=0;this.ob=this.Rc=l;setTimeout(v(this.Jc,this),0)}var Qc=0,Rc=0;r=Pc.prototype;
r.Ca=function(a,b,c,d){var e=++this.Ed,a={r:e,a:a,b:b};this.e(y(a));this.U?this.yb.Ac(a):this.Zb.push(a);var g=this,a=setTimeout(function(){var a=g.Ba[e];a&&(delete g.Ba[e],a.ma&&a.ma.Vb&&a.ma.Vb())},45E3);this.Ba[e]={ma:{Ub:c,Vb:d},fd:a}};function Sc(a,b,c,d,e){a.e("Listen on "+b+" for "+c);var g={p:b},d=nb(d,function(a){return Ka(a)});"{}"!==c&&(g.q=d);a.Ca("l",g,function(d){a.e("listen response",d);d=d.s;"ok"!==d&&Tc(a,b,c);e&&e(d)},function(){a.e("timed out on listen...")})}
r.fb=function(a,b,c){this.Ga={pd:a,Lc:o,ka:b,Ib:c};this.e("Authenticating using credential: "+this.Ga);Uc(this)};r.Fb=function(){delete this.Ga;this.qb(o);this.U&&this.Ca("unauth",{},function(){},function(){})};function Uc(a){var b=a.Ga;a.U&&b&&a.Ca("auth",{cred:b.pd},function(c){var d=c.s,c=c.d||"error";"ok"!==d&&a.Ga===b&&delete a.Ga;b.Lc?"ok"!==d&&b.Ib&&b.Ib(d,c):(b.Lc=k,b.ka&&b.ka(d,c));a.qb("ok"===d)},function(){a.e("timed out on auth...")})}
r.hd=function(a,b,c){a=a.toString();if(Tc(this,a,b)&&this.U){this.e("Unlisten on "+a+" for "+b);var d=this,a={p:a},c=nb(c,function(a){return Ka(a)});"{}"!==b&&(a.q=c);this.Ca("u",a,l,function(){d.e("timed out on unlisten...")})}};function Vc(a,b,c,d){a.U?Wc(a,"o",b,c,d):a.rb.push({xc:b,action:"o",data:c,A:d})}r.uc=function(a,b){this.U?Wc(this,"oc",a,l,b):this.rb.push({xc:a,action:"oc",data:l,A:b})};
function Wc(a,b,c,d,e){c={p:c,d:d};a.e("onDisconnect "+b,c);a.Ca(b,c,function(a){e&&setTimeout(function(){e(a.s)},0)},function(){a.e("timed out on onDisconnect...")})}r.put=function(a,b,c,d){Xc(this,"p",a,b,c,d)};function Xc(a,b,c,d,e,g){c={p:c,d:d};s(g)&&(c.h=g);a.Q.push({action:b,Zc:c,A:e});a.tb++;b=a.Q.length-1;a.U&&Yc(a,b)}
function Yc(a,b){var c=a.Q[b].action,d=a.Q[b].A;a.Ca(c,a.Q[b].Zc,function(e){a.e(c+" response",e);delete a.Q[b];a.tb--;0===a.tb&&(a.Q=[]);d&&d(e.s)},function(){a.e("timed out on put...")})}
r.Sb=function(a){if("r"in a){this.e("from server: "+y(a));var b=a.r,c=this.Ba[b];c&&(delete this.Ba[b],clearTimeout(c.fd),c.ma&&c.ma.Ub&&c.ma.Ub(a.b))}else"error"in a&&f("A server-side error has occurred: "+a.error),"a"in a&&(b=a.a,a=a.b,this.e("handleServerMessage",b,a),"d"===b?this.Tb(a.p,a.d):"m"===b?this.Tb(a.p,a.d,k):"c"===b?(b=a.p,a=(a=a.q)?nb(a,function(a){return La(a)}).join("$"):"{}",(a=Tc(this,b,a))&&a.A&&a.A("permission_denied")):"ac"===b?(b=a.s,a=a.d,c=this.Ga,delete this.Ga,c&&c.Ib&&
c.Ib(b,a),this.qb(o)):"sd"===b?this.yc?this.yc(a):"msg"in a&&"undefined"!==typeof console&&console.log("FIREBASE: "+a.msg.replace("\n","\nFIREBASE: ")):Ub("Unrecognized action received from server: "+y(b)+"\nAre you using the latest client?"))};
r.sb=function(a){this.e("connection ready");this.U=k;this.ob=(new Date).getTime();$b=a-(new Date).getTime();for(a=0;a<this.Zb.length;a++)this.yb.Ac(this.Zb[a]);this.Zb=[];Uc(this);for(a=0;a<this.Q.length;a++)this.Q[a]&&Yc(this,a);for(var b in this.ga)for(var c in this.ga[b])a=this.ga[b][c],Sc(this,b,c,a.Za,a.A);for(;this.rb.length;)b=this.rb.shift(),Wc(this,b.action,b.xc,b.data,b.A);this.Rb(k)};
r.Wc=function(){this.U=o;this.e("data client disconnected");var a=v(function(){this.Jc()},this);if(this.Db){this.ob&&(3E4<(new Date).getTime()-this.ob&&(this.bc=1E3),this.ob=l);var b=Math.max(0,this.bc-((new Date).getTime()-this.Rc)),b=Math.random()*b;this.e("Trying to reconnect in "+b+"ms");setTimeout(a,b);this.bc=Math.min(3E5,1.5*this.bc)}else{for(var c=0;c<this.Q.length;c++){var d=this.Q[c];d&&"h"in d.Zc&&(d.A&&d.A("disconnect"),delete this.Q[c],this.tb--)}0===this.tb&&(this.Q=[]);for(b in this.Ba)c=
this.Ba[b],delete this.Ba[b],c!==l&&(c.ma&&c.ma.Vb&&c.ma.Vb(),clearTimeout(c.fd));this.ad=function(){setTimeout(a,0)}}this.Rb(o)};r.Jc=function(){if(this.Db){this.e("Making a connection attempt");this.Rc=(new Date).getTime();this.ob=l;var a=v(this.Sb,this),b=v(this.sb,this),c=v(this.Wc,this),d=this.id+":"+Rc++,e=this;this.yb=new Jc(d,this.C,a,b,c,function(a){e.Db=o;f(Error(a))})}};r.Va=function(){this.Db=o;this.yb?this.yb.close():this.Wc()};r.Ab=function(){this.Db=k;this.ad();this.ad=i};
function Tc(a,b,c){b=(new I(b)).toString();c||(c="{}");var d=a.ga[b][c];delete a.ga[b][c];return d};function Zc(){this.Na=O}function T(a,b){return a.Na.G(b)}function U(a,b,c){a.Na=a.Na.bb(b,c)}Zc.prototype.toString=function(){return this.Na.toString()};function $c(){this.Da=new Zc;this.M=new Zc;this.Fa=new Zc;this.wb=new Sa}function ad(a,b){for(var c=T(a.Da,b),d=T(a.M,b),e=J(a.wb,b),g=o,h=e;h!==l;){if(h.j()!==l){g=k;break}h=h.parent()}if(g)return o;c=bd(c,d,e);return c!==d?(U(a.M,b,c),k):o}function bd(a,b,c){if(c.f())return a;if(c.j()!==l)return b;a=a||O;c.B(function(d){var d=d.name(),e=a.O(d),g=b.O(d),h=J(c,d),e=bd(e,g,h);a=a.F(d,e)});return a}
$c.prototype.set=function(a,b){var c=this,d=[];mb(b,function(a){var b=a.path,a=a.Ja,h=Kb();M(J(c.wb,b),h);U(c.M,b,a);d.push({path:b,Fd:h})});return d};function cd(a,b){mb(b,function(b){var d=b.Fd,b=J(a.wb,b.path),e=b.j();z(e!==l,"pendingPut should not be null.");e===d&&M(b,l)})};function dd(){this.Ha=[]}function ed(a,b){if(0!==b.length){a.Ha.push.apply(a.Ha,b);for(var c=0;c<a.Ha.length;c++)if(a.Ha[c]){var d=a.Ha[c];a.Ha[c]=l;var e=d.ka;e(d.dd,d.xb)}a.Ha=[]}};function V(a,b,c,d){this.type=a;this.oa=b;this.Z=c;this.xb=d};function fd(a){this.J=a;this.la=[];this.Kc=new dd}function gd(a,b,c,d,e){a.la.push({type:b,ka:c,cancel:d,$:e});var d=[],g=hd(a.g);a.mb&&g.push(new V("value",a.g));for(var h=0;h<g.length;h++)if(g[h].type===b){var j=new W(a.J.u,a.J.path);g[h].Z&&(j=j.D(g[h].Z));d.push({ka:e?v(c,e):c,dd:new R(g[h].oa,j),xb:g[h].xb})}ed(a.Kc,d)}fd.prototype.$b=function(a,b){b=this.ac(a,b);b!=l&&id(this,b)};
function id(a,b){for(var c=[],d=0;d<b.length;d++){var e=b[d],g=e.type,h=new W(a.J.u,a.J.path);b[d].Z&&(h=h.D(b[d].Z));h=new R(b[d].oa,h);"value"===e.type&&!h.Mb()?g+="("+h.R()+")":"value"!==e.type&&(g+=" "+h.name());Rb(a.J.u.n.id+": event:"+a.J.path+":"+a.J.La()+":"+g);for(g=0;g<a.la.length;g++){var j=a.la[g];b[d].type===j.type&&c.push({ka:j.$?v(j.ka,j.$):j.ka,dd:h,xb:e.xb})}}ed(a.Kc,c)}
function hd(a){var b=[];if(!a.L()){var c=l;a.B(function(a,e){b.push(new V("child_added",e,a,c));c=a})}return b}function ld(a){a.mb||(a.mb=k,id(a,[new V("value",a.g)]))};function md(a,b){fd.call(this,a);this.g=b}ka(md,fd);md.prototype.ac=function(a,b){this.g=a;this.mb&&b!=l&&b.push(new V("value",this.g));return b};md.prototype.kb=function(){return{}};function nd(a,b){this.Lb=a;this.tc=b}
function od(a,b,c,d,e){var g=a.G(c),h=b.G(c),d=new nd(d,e),e=pd(d,c,g,h),j=o;if(!g.f()&&!h.f()&&g.k()!==h.k())var j=a.G(c.parent()),m=b.G(c.parent()),n=Na(c),j=j.V(n,g)!=m.V(n,h);if(e||j){g=c;c=e;for(h=j;g.parent()!==l;){var q=a.G(g),e=b.G(g),j=g.parent();if(!d.Lb||J(d.Lb,j).j())m=b.G(j),n=[],g=Na(g),q.f()?(q=m.V(g,e),n.push(new V("child_added",e,g,q))):e.f()?n.push(new V("child_removed",q,g)):(q=m.V(g,e),h&&n.push(new V("child_moved",e,g,q)),c&&n.push(new V("child_changed",e,g,q))),d.tc(j,m,n);h&&
(h=o,c=k);g=j}}}function pd(a,b,c,d){var e,g=[];c===d?e=o:c.L()&&d.L()?e=c.j()!==d.j():c.L()?(qd(a,b,O,d,g),e=k):d.L()?(qd(a,b,c,O,g),e=k):e=qd(a,b,c,d,g);e?a.tc(b,d,g):c.k()!==d.k()&&a.tc(b,d,l);return e}
function qd(a,b,c,d,e){var g=o,h=!a.Lb||!J(a.Lb,b).f(),j=[],m=[],n=[],q=[],x={},u={},w,L,K,H;w=c.Ua();K=ab(w);L=d.Ua();for(H=ab(L);K!==l||H!==l;){c=K===l?1:H===l?-1:K.key===H.key?0:gc({name:K.key,Aa:K.value.k()},{name:H.key,Aa:H.value.k()});if(0>c)g=va(x,K.key),s(g)?(n.push({Mc:K,gd:j[g]}),j[g]=l):(u[K.key]=m.length,m.push(K)),g=k,K=ab(w);else{if(0<c)g=va(u,H.key),s(g)?(n.push({Mc:m[g],gd:H}),m[g]=l):(x[H.key]=j.length,j.push(H)),g=k;else{c=b.D(H.key);if(c=pd(a,c,K.value,H.value))q.push(H),g=k;K=
ab(w)}H=ab(L)}if(!h&&g)return k}for(h=0;h<m.length;h++)if(x=m[h])c=b.D(x.key),pd(a,c,x.value,O),e.push(new V("child_removed",x.value,x.key));for(h=0;h<j.length;h++)if(x=j[h])c=b.D(x.key),m=d.V(x.key,x.value),pd(a,c,O,x.value),e.push(new V("child_added",x.value,x.key,m));for(h=0;h<n.length;h++)x=n[h].Mc,j=n[h].gd,c=b.D(j.key),m=d.V(j.key,j.value),e.push(new V("child_moved",j.value,j.key,m)),(c=pd(a,c,x.value,j.value))&&q.push(j);for(h=0;h<q.length;h++)a=q[h],m=d.V(a.key,a.value),e.push(new V("child_changed",
a.value,a.key,m));return g};function rd(){this.N=this.sa=l;this.set={}}ka(rd,tc);r=rd.prototype;r.setActive=function(a){this.sa=a};function sd(a){return a.contains("default")}function td(a){return a.sa!=l&&sd(a)}r.defaultView=function(){return sd(this)?this.get("default"):l};r.path=aa("N");r.toString=function(){return nb(this.keys(),function(a){return"default"===a?"{}":a}).join("$")};r.Za=function(){var a=[];S(this.set,function(b){a.push(b.J)});return a};function ud(a,b){fd.call(this,a);this.g=O;this.ac(b,hd(b))}ka(ud,fd);
ud.prototype.ac=function(a,b){if(b===l)return b;var c=[],d=this.J;s(d.fa)&&(s(d.qa)&&d.qa!=l?c.push(function(a,b){var c=Yb(b,d.fa);return 0<c||0===c&&a>=d.qa}):c.push(function(a,b){return 0<=Yb(b,d.fa)}));s(d.va)&&(s(d.Ta)?c.push(function(a,b){var c=Yb(b,d.va);return 0>c||0===c&&a<=d.Ta}):c.push(function(a,b){return 0>=Yb(b,d.va)}));var e=l,g=l;if(s(this.J.xa))if(s(this.J.fa)){if(e=vd(a,c,this.J.xa,o)){var h=a.O(e).k();c.push(function(a,b){var c=Yb(b,h);return 0>c||0===c&&a<=e})}}else if(g=vd(a,c,
this.J.xa,k)){var j=a.O(g).k();c.push(function(a,b){var c=Yb(b,j);return 0<c||0===c&&a>=g})}for(var m=[],n=[],q=[],x=[],u=0;u<b.length;u++){var w=b[u].Z,L=b[u].oa;switch(b[u].type){case "child_added":wd(c,w,L)&&(this.g=this.g.F(w,L),n.push(b[u]));break;case "child_removed":this.g.O(w).f()||(this.g=this.g.F(w,l),m.push(b[u]));break;case "child_changed":!this.g.O(w).f()&&wd(c,w,L)&&(this.g=this.g.F(w,L),x.push(b[u]));break;case "child_moved":var K=!this.g.O(w).f(),H=wd(c,w,L);K?H?(this.g=this.g.F(w,
L),q.push(b[u])):(m.push(new V("child_removed",this.g.O(w),w)),this.g=this.g.F(w,l)):H&&(this.g=this.g.F(w,L),n.push(b[u]))}}var jd=e||g;if(jd){var kd=(u=g!==l)?this.g.Nc():this.g.Oc(),Vb=o,Pa=o,Qa=this;(u?a.nc:a.B).call(a,function(a,b){!Pa&&kd===l&&(Pa=k);if(Pa&&Vb)return k;Vb?(m.push(new V("child_removed",Qa.g.O(a),a)),Qa.g=Qa.g.F(a,l)):Pa&&(n.push(new V("child_added",b,a)),Qa.g=Qa.g.F(a,b));kd===a&&(Pa=k);a===jd&&(Vb=k)})}for(u=0;u<n.length;u++)c=n[u],w=this.g.V(c.Z,c.oa),m.push(new V("child_added",
c.oa,c.Z,w));for(u=0;u<q.length;u++)c=q[u],w=this.g.V(c.Z,c.oa),m.push(new V("child_moved",c.oa,c.Z,w));for(u=0;u<x.length;u++)c=x[u],w=this.g.V(c.Z,c.oa),m.push(new V("child_changed",c.oa,c.Z,w));this.mb&&0<m.length&&m.push(new V("value",this.g));return m};function vd(a,b,c,d){if(a.L())return l;var e=l;(d?a.nc:a.B).call(a,function(a,d){if(wd(b,a,d)&&(e=a,c--,0===c))return k});return e}function wd(a,b,c){for(var d=0;d<a.length;d++)if(!a[d](b,c.k()))return o;return k}
ud.prototype.oc=function(a){return this.g.O(a)!==O};ud.prototype.kb=function(a,b,c){var d={};this.g.L()||this.g.B(function(a){d[a]=k});var e=this.g,c=T(c,new I("")),g=new Sa;M(J(g,this.J.path),k);var h=O.bb(a,b),j=[];od(c,h,a,g,function(a,b,c){c!==l&&(j=j.concat(c))});this.ac(b,j);this.g.L()||this.g.B(function(a){d[a]=k});this.g=e;return d};function xd(a,b){this.n=a;this.i=b;this.Vc=b.Na;this.ua=new Sa}
xd.prototype.Hb=function(a,b,c,d,e){var g=a.path,h=J(this.ua,g),j=h.j();j===l?(j=new rd,M(h,j)):z(!j.f(),"We shouldn't be storing empty QueryMaps");var m=a.La();if(j.contains(m))gd(j.get(m),b,c,d,e);else{var n=this.i.Na.G(g),a="default"===a.La()?new md(a,n):new ud(a,n);if(td(j)||yd(h))j.add(m,a),j.N||(j.N=a.J.path);else{var q,x;j.f()||(q=j.toString(),x=j.Za());j.add(m,a);j.N||(j.N=a.J.path);j.setActive(zd(this,j));q&&x&&this.n.hd(j.path(),q,x)}td(j)&&Ua(h,function(a){if(a=a.j()){a.sa&&a.sa();a.sa=
l}});gd(a,b,c,d,e);(b=(b=Va(J(this.ua,g),function(a){var b;if(b=a.j())if(b=a.j().defaultView())b=a.j().defaultView().mb;if(b)return k},k))||this.n===l)&&ld(a)}};function Ad(a,b,c,d,e){for(var g=a.get(b),h=o,j=g.la.length-1;0<=j;j--){var m=g.la[j];if((!c||m.type===c)&&(!d||m.ka===d)&&(!e||m.$===e))if(g.la.splice(j,1),h=k,c&&d)break}(c=h&&!(0<g.la.length))&&a.remove(b);return c}xd.prototype.dc=function(a,b,c,d){var e=J(this.ua,a.path).j();return e===l?l:Bd(this,e,a,b,c,d)};
function Bd(a,b,c,d,e,g){var h=b.path(),h=J(a.ua,h),c=c?c.La():l,j=[];c&&"default"!==c?Ad(b,c,d,e,g)&&j.push(c):mb(b.keys(),function(a){Ad(b,a,d,e,g)&&j.push(a)});b.f()&&M(h,l);c=yd(h);if(0<j.length&&!c){for(var m=h,n=h.parent(),c=o;!c&&n;){var q=n.j();if(q){z(!td(q));var x=m.name(),u=o;S(q.set,function(a){u=a.oc(x)||u});u&&(c=k)}m=n;n=n.parent()}m=l;if(!td(b)){n=b.sa;b.sa=l;var w=[],L=function(b){var c=b.j();c&&sd(c)?(w.push(c.path()),c.sa==l&&c.setActive(zd(a,c))):(c&&c.sa==l&&c.setActive(zd(a,
c)),b.B(L))};L(h);m=w;n&&n()}return c?l:m}return l}function Cd(a,b,c){Ua(J(a.ua,b),function(a){(a=a.j())&&S(a.set,function(a){ld(a)})},c,k)}function Dd(a,b,c){function d(a){for(var b=0;b<c.length;++b)if(c[b].contains(a))return k;return o}var e=a.Vc,g=a.i.Na;a.Vc=g;od(e,g,b,a.ua,function(c,e,g){if(b.contains(c)){var n=d(c);n&&Cd(a,c,o);a.$b(c,e,g);n&&Cd(a,c,k)}else a.$b(c,e,g)});d(b)&&Cd(a,b,k)}xd.prototype.$b=function(a,b,c){a=J(this.ua,a).j();a!==l&&S(a.set,function(a){a.$b(b,c)})};
function yd(a){return Va(a,function(a){return a.j()&&td(a.j())})}
function zd(a,b){if(a.n){var c=b.keys(),d=a.n,e=function(d){"ok"!==d?(Xb("on() or once() for "+b.path().toString()+" failed: "+d),b&&S(b.set,function(a){for(var b=0;b<a.la.length;b++){var c=a.la[b];c.cancel&&(c.$?v(c.cancel,c.$):c.cancel)()}}),Bd(a,b)):mb(c,function(a){(a=b.get(a))&&ld(a)})},g=b.toString(),h=b.path().toString();d.ga[h]=d.ga[h]||{};z(!d.ga[h][g],"listen() called twice for same path/queryId.");d.ga[h][g]={Za:b.Za(),A:e};d.U&&Sc(d,h,g,b.Za(),e);return v(a.n.hd,a.n,b.path(),b.toString(),
b.Za())}return da}xd.prototype.kb=function(a,b,c,d){var e={};S(b.set,function(b){b=b.kb(a,c,d);S(b,function(a,b){e[b]=a?k:va(e,b)||o})});c.L()||c.B(function(a){D(e,a)||(e[a]=o)});return e};
function Ed(a,b,c,d,e,g){var h=b.path();if(g!==l){var j=[];d.L()||d.B(function(a,b){j.push({path:h.D(a),Ja:b});delete g[a]});S(g,function(a,b){j.push({path:h.D(b),Ja:O})});return j}var b=a.kb(h,b,d,e),m=O,n=[];S(b,function(b,g){var h=new I(g);b?m=m.F(g,d.G(h)):n=n.concat(Fd(a,d.G(h),J(c,h),e))});return[{path:h,Ja:m}].concat(n)}
function Gd(a,b,c,d,e){for(var g=J(a.ua,b),h=g.parent(),j=o;!j&&h!==l;){var m=h.j();m!==l&&(sd(m)?j=k:(m=a.kb(b,m,c,d),g=g.name(),va(m,g)&&(j=k)));g=h;h=h.parent()}if(j)return[{path:b,Ja:c}];h=J(a.ua,b);j=h.j();return j!==l?sd(j)?[{path:b,Ja:c}]:Ed(a,j,h,c,d,e):Fd(a,c,h,d)}function Fd(a,b,c,d){var e=c.j();if(e!==l)return sd(e)?[{path:c.path(),Ja:b}]:Ed(a,e,c,b,d,l);if(b.L())return[];var g=[];b.B(function(b,e){var m=new I(b);g=g.concat(Fd(a,e,J(c,m),d))});return g};function Hd(a){this.C=a;this.Y=qc(a);this.n=new Pc(this.C,v(this.Tb,this),v(this.Rb,this),v(this.qb,this));var b=v(function(){return new nc(this.Y,this.n)},this),a=a.toString();pc[a]||(pc[a]=b());this.Jd=pc[a];this.gc=new Sa;this.i=new $c;this.S=new xd(this.n,this.i.Fa);this.Pc=new Zc;this.pc=new xd(l,this.Pc);Id(this,"connected",o);Id(this,"authenticated",o)}r=Hd.prototype;r.toString=function(){return(this.C.Cb?"https://":"http://")+this.C.host};r.name=function(){return this.C.Xa};
r.Tb=function(a,b,c){var d=[],e=l;if(9<=a.length&&a.lastIndexOf(".priority")===a.length-9)a=new I(a.substring(0,a.length-9)),c=T(this.i.Da,a).jc(b),d.push(a);else if(c){var e=b,a=new I(a),c=T(this.i.Da,a),g;for(g in b){var h=Q(b[g]),c=c.F(g,h);d.push(a.D(g))}}else a=new I(a),c=Q(b),d.push(a);b=Gd(this.S,a,c,this.i.M,e);e=o;for(g=0;g<b.length;++g){var c=b[g],h=this.i,j=c.path;U(h.Da,j,c.Ja);e=ad(h,j)||e}e&&(a=Jd(this,a),Kd(this,a),a=a.path());Dd(this.S,a,d)};r.Rb=function(a){Id(this,"connected",a)};
r.qb=function(a){Id(this,"authenticated",a)};function Id(a,b,c){b=new I("/.info/"+b);U(a.Pc,b,Q(c));Dd(a.pc,b,[b])}r.fb=function(a,b,c){this.n.fb(a,function(a,c){X(b,a,c)},function(a,b){Xb("auth() was canceled: "+b);if(c){var g=Error(b);g.code=a.toUpperCase();c(g)}})};r.Fb=function(){this.n.Fb()};
r.ab=function(a,b,c,d){this.e("set",{path:a.toString(),value:b});var b=Q(b,c),c=Gd(this.S,a,b,this.i.M,l),e=this.i.set(a,c),g=this;this.n.put(a.toString(),b.R(k),function(b){var c="ok"===b;cd(g.i,e);c||(Xb("set at "+a+" failed: "+b),ad(g.i,a),c=Jd(g,a),Kd(g,c),Dd(g.S,c.path(),[]));X(d,b)});b=Jd(this,a);Ld(this,a);Kd(this,b);Dd(this.S,b.path(),[a])};
r.update=function(a,b,c){this.e("update",{path:a.toString(),value:b});var d=T(this.i.Fa,a),e=k,g=[],h;for(h in b){var e=o,j=Q(b[h]),d=d.F(h,j);g.push(a.D(h))}if(e)Rb("update() called with empty data. Don't do anything."),X(c,"ok");else{var d=Gd(this.S,a,d,this.i.M,b),m=this.i.set(a,d),n=this;Xc(this.n,"m",a.toString(),b,function(b){z("ok"===b||"permission_denied"===b,"merge at "+a+" failed.");cd(n.i,m);X(c,b)},i);b=Jd(this,a);Ld(this,a);Kd(this,b);Dd(this.S,b.path(),g)}};
r.Bc=function(a,b,c){this.e("setPriority",{path:a.toString(),Aa:b});var d=T(this.i.M,a).jc(b),d=Gd(this.S,a,d,this.i.M,l),e=this.i.set(a,d),g=this;this.n.put(a.toString()+"/.priority",b,function(a){cd(g.i,e);X(c,a)});a=Jd(this,a);Kd(this,a);Dd(this.S,a.path(),[])};r.uc=function(a,b){this.n.uc(a.toString(),function(a){X(b,a)})};function Md(a,b,c,d){c=Q(c);Vc(a.n,b.toString(),c.R(k),function(a){X(d,a)})}function Nd(a){lc(a.Y,"deprecated_on_disconnect");a.Jd.ed.deprecated_on_disconnect=k}
r.Hb=function(a,b,c,d,e){".info"===F(a.path)?this.pc.Hb(a,b,c,d,e):this.S.Hb(a,b,c,d,e)};r.dc=function(a,b,c,d){if(".info"===F(a.path))this.pc.dc(a,b,c,d);else if(b=this.S.dc(a,b,c,d),b!==l){for(var c=this.i,a=a.path,d=[],e=0;e<b.length;++e)d[e]=T(c.Da,b[e]);U(c.Da,a,O);for(e=0;e<b.length;++e)U(c.Da,b[e],d[e])}};r.Va=function(){this.n.Va()};r.Ab=function(){this.n.Ab()};
r.Cc=function(a){if("undefined"!==typeof console){a?(this.fc||(this.fc=new mc(this.Y)),a=this.fc.get()):a=this.Y.get();var b=a,c=[],d=0,e;for(e in b)c[d++]=e;var g=function(a,b){return Math.max(b.length,a)};if(c.reduce)e=c.reduce(g,0);else{var h=0;mb(c,function(a){h=g.call(i,h,a)});e=h}for(var j in a){b=a[j];for(c=j.length;c<e+2;c++)j+=" ";console.log(j+b)}}};r.e=function(){Rb("r:"+this.n.id+":",arguments)};function Od(a,b){var c=new W(a,b);return new R(T(a.i.Fa,b),c)}
function X(a,b,c){if(a)if("ok"==b)a(l,c);else{var d=b=(b||"error").toUpperCase();c&&(d+=": "+c);c=Error(d);c.code=b;a(c)}};function Ld(a,b){var c=J(a.gc,b);Va(c,function(b){Pd(a,b)});Pd(a,c);Ua(c,function(b){Pd(a,b)})}function Pd(a,b){var c=b.j();if(c!==l){for(var d=-1,e=[],g=0;g<c.length;g++)if(2===c[g].status)z(d===g-1,"All SENT items should be at beginning of queue."),d=g,c[g].status=4,c[g].Hc="set";else if(c[g].ic(),c[g].A){var h=Od(a,b.path());e.push(v(c[g].A,l,Error("set"),o,h))}-1===d?M(b,l):c.length=d+1;for(g=0;g<e.length;g++)e[g]()}}
function Qd(a,b){var c=b||a.gc;b||Rd(a,c);if(!c.f())if(c.j()!==l){var d=Sd(a,c);if(0!==d.length){var e=c.path();if(2!==d[0].status&&4!==d[0].status){for(var g=0;g<d.length;g++)z(1===d[g].status,"tryToSendTransactionForNode_: items in queue should all be run."),d[g].status=2,d[g].bd++;var h=T(a.i.M,e).hash();U(a.i.M,e,T(a.i.Fa,e));var j=T(a.i.M,e).R(k),m=Kb();M(J(a.i.wb,e),m);a.n.put(e.toString(),j,function(b){a.e("transaction put response",{path:e.toString(),status:b});var h=J(a.i.wb,e),j=h.j();z(j!==
l,"tryToSendTransactionsForNode_: pendingPut should not be null.");j===m&&(M(h,l),U(a.i.M,e,T(a.i.Da,e)));if("ok"===b){b=[];for(g=0;g<d.length;g++)d[g].status=3,d[g].A&&(h=Od(a,d[g].path),b.push(v(d[g].A,l,l,k,h))),d[g].ic();Rd(a,c);Qd(a);for(g=0;g<b.length;g++)b[g]()}else{if("datastale"===b)for(g=0;g<d.length;g++)d[g].status=4===d[g].status?5:1;else{Xb("transaction at "+e+" failed: "+b);for(g=0;g<d.length;g++)d[g].status=5,d[g].Hc=b}b=Jd(a,e);Kd(a,b);Dd(a.S,b.path(),[e])}},h)}}}else c.B(function(b){Qd(a,
b)})}
function Kd(a,b){var c=b.path();U(a.i.Fa,c,T(a.i.M,c));var d=Sd(a,b);if(0!==d.length){for(var e=T(a.i.Fa,c),g=[],h=0;h<d.length;h++){var j=Oa(c,d[h].path),m=o,n;z(j!==l,"rerunTransactionsUnderNode_: relativePath should not be null.");if(5===d[h].status)m=k,n=d[h].Hc;else if(1===d[h].status)if(25<=d[h].bd)m=k,n="maxretry";else{var q=d[h].update(e.G(j).R());s(q)?(Ba("transaction failed: Data returned ",q),e=e.bb(j,Q(q))):(m=k,n="nodata")}m&&(d[h].ic(),d[h].status=3,d[h].A&&(m=new W(a,d[h].path),j=new R(e.G(j),
m),"nodata"===n?g.push(v(d[h].A,l,l,o,j)):g.push(v(d[h].A,l,Error(n),o,j))))}d=T(a.i.M,c).k();U(a.i.Fa,c,e.jc(d));Qd(a);for(h=0;h<g.length;h++)g[h]()}}function Jd(a,b){for(var c,d=a.gc;(c=F(b))!==l&&d.j()===l;)d=J(d,c),b=Ma(b);return d}function Sd(a,b){var c=[];Td(a,b,c);c.sort(function(a,b){return a.Xc-b.Xc});return c}function Td(a,b,c){var d=b.j();if(d!==l)for(var e=0;e<d.length;e++)c.push(d[e]);b.B(function(b){Td(a,b,c)})}
function Rd(a,b){var c=b.j();if(c){for(var d=0,e=0;e<c.length;e++)3!==c[e].status&&(c[d]=c[e],d++);c.length=d;M(b,0<c.length?c:l)}b.B(function(b){Rd(a,b)})};function Y(){this.$a={}}Y.td=function(){return Y.Qc?Y.Qc:Y.Qc=new Y};Y.prototype.Va=function(){for(var a in this.$a)this.$a[a].Va()};Y.prototype.interrupt=Y.prototype.Va;Y.prototype.Ab=function(){for(var a in this.$a)this.$a[a].Ab()};Y.prototype.resume=Y.prototype.Ab;var Z={ud:function(a){var b=P.prototype.hash;P.prototype.hash=a;return function(){P.prototype.hash=b}}};Z.hijackHash=Z.ud;Z.La=function(a){return a.La()};Z.queryIdentifier=Z.La;Z.wd=function(a){return a.u.n.ga};Z.listens=Z.wd;Z.Cd=function(a){return a.u.n.yb};Z.refConnection=Z.Cd;Z.kd=Pc;Z.DataConnection=Z.kd;Pc.prototype.sendRequest=Pc.prototype.Ca;Pc.prototype.interrupt=Pc.prototype.Va;Z.ld=Jc;Z.RealTimeConnection=Z.ld;Jc.prototype.sendRequest=Jc.prototype.Ac;Jc.prototype.close=Jc.prototype.close;
Z.jd=tb;Z.ConnectionTarget=Z.jd;Z.sd=function(){Bc=xc=k};Z.forceLongPolling=Z.sd;Z.Hd=function(a,b){a.u.n.yc=b};Z.setSecurityDebugCallback=Z.Hd;Z.Cc=function(a,b){a.u.Cc(b)};Z.stats=Z.Cc;function $(a,b,c){this.zb=a;this.N=b;this.ya=c}ca("fb.api.onDisconnect",$);$.prototype.cancel=function(a){A("Firebase.onDisconnect().cancel",0,1,arguments.length);C("Firebase.onDisconnect().cancel",1,a,k);this.zb.uc(this.N,a)};$.prototype.cancel=$.prototype.cancel;$.prototype.remove=function(a){A("Firebase.onDisconnect().remove",0,1,arguments.length);E("Firebase.onDisconnect().remove",this.N);C("Firebase.onDisconnect().remove",1,a,k);Md(this.zb,this.N,l,a)};$.prototype.remove=$.prototype.remove;
$.prototype.set=function(a,b){A("Firebase.onDisconnect().set",1,2,arguments.length);E("Firebase.onDisconnect().set",this.N);Aa("Firebase.onDisconnect().set",a,o);C("Firebase.onDisconnect().set",2,b,k);Md(this.zb,this.N,a,b)};$.prototype.set=$.prototype.set;
$.prototype.ab=function(a,b,c){A("Firebase.onDisconnect().setWithPriority",2,3,arguments.length);E("Firebase.onDisconnect().setWithPriority",this.N);Aa("Firebase.onDisconnect().setWithPriority",a,o);Fa("Firebase.onDisconnect().setWithPriority",2,b,o);C("Firebase.onDisconnect().setWithPriority",3,c,k);(".length"===this.ya||".keys"===this.ya)&&f("Firebase.onDisconnect().setWithPriority failed: "+this.ya+" is a read-only object.");var d=this.zb,e=this.N,g=Q(a,b);Vc(d.n,e.toString(),g.R(k),function(a){X(c,
a)})};$.prototype.setWithPriority=$.prototype.ab;$.prototype.update=function(a,b){A("Firebase.onDisconnect().update",1,2,arguments.length);E("Firebase.onDisconnect().update",this.N);Ea("Firebase.onDisconnect().update",a);C("Firebase.onDisconnect().update",2,b,k);var c=this.zb,d=this.N,e=k,g;for(g in a)e=o;e?(Rb("onDisconnect().update() called with empty data. Don't do anything."),X(b,k)):(c=c.n,d=d.toString(),e=function(a){X(b,a)},c.U?Wc(c,"om",d,a,e):c.rb.push({xc:d,action:"om",data:a,A:e}))};
$.prototype.update=$.prototype.update;var Ud,Vd=0,Wd=[];Ud=function(){var a=(new Date).getTime()+$b,b=a===Vd;Vd=a;for(var c=Array(8),d=7;0<=d;d--)c[d]="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(a%64),a=Math.floor(a/64);z(0===a);a=c.join("");if(b){for(d=11;0<=d&&63===Wd[d];d--)Wd[d]=0;Wd[d]++}else for(d=0;12>d;d++)Wd[d]=Math.floor(64*Math.random());for(d=0;12>d;d++)a+="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(Wd[d]);z(20===a.length,"NextPushId: Length should be 20.");return a};function W(){var a,b,c;if(arguments[0]instanceof Hd)c=arguments[0],a=arguments[1];else{A("new Firebase",1,2,arguments.length);var d=arguments[0];b=a="";var e=k,g="";if(t(d)){var h=d.indexOf("//");if(0<=h)var j=d.substring(0,h-1),d=d.substring(h+2);h=d.indexOf("/");-1===h&&(h=d.length);a=d.substring(0,h);var d=d.substring(h+1),m=a.split(".");if(3==m.length){h=m[2].indexOf(":");e=0<=h?"https"===j:k;if("firebase"===m[1])Wb(a+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead");
else{b=m[0];g="";d=("/"+d).split("/");for(j=0;j<d.length;j++)if(0<d[j].length){h=d[j];try{h=decodeURIComponent(h.replace(/\+/g," "))}catch(n){}g+="/"+h}}b=b.toLowerCase()}else b=l}e||"undefined"!==typeof window&&(window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:"))&&Xb("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");a=new tb(a,e,b);b=new I(g);e=b.toString();if(!(d=!t(a.host)))if(!(d=0===a.host.length))if(!(d=!za(a.Xa)))if(d=
0!==e.length)e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),d=!(t(e)&&0!==e.length&&!ya.test(e));d&&f(Error(B("new Firebase",1,o)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".'));arguments[1]?arguments[1]instanceof Y?c=arguments[1]:f(Error("Expected a valid Firebase.Context for second argument to new Firebase()")):c=Y.td();e=a.toString();d=va(c.$a,e);d||(d=new Hd(a),c.$a[e]=d);c=d;a=b}G.call(this,c,a)}ka(W,G);ca("Firebase",W);module.exports=W;
W.prototype.name=function(){A("Firebase.name",0,0,arguments.length);return this.path.f()?l:Na(this.path)};W.prototype.name=W.prototype.name;W.prototype.D=function(a){A("Firebase.child",1,1,arguments.length);if(ga(a))a=String(a);else if(!(a instanceof I))if(F(this.path)===l){var b=a;b&&(b=b.replace(/^\/*\.info(\/|$)/,"/"));Ia("Firebase.child",b)}else Ia("Firebase.child",a);return new W(this.u,this.path.D(a))};W.prototype.child=W.prototype.D;
W.prototype.parent=function(){A("Firebase.parent",0,0,arguments.length);var a=this.path.parent();return a===l?l:new W(this.u,a)};W.prototype.parent=W.prototype.parent;W.prototype.toString=function(){A("Firebase.toString",0,0,arguments.length);var a;if(this.parent()===l)a=this.u.toString();else{a=this.parent().toString()+"/";var b=this.name();a+=encodeURIComponent(String(b))}return a};W.prototype.toString=W.prototype.toString;
W.prototype.set=function(a,b){A("Firebase.set",1,2,arguments.length);E("Firebase.set",this.path);Aa("Firebase.set",a,o);C("Firebase.set",2,b,k);return this.u.ab(this.path,a,l,b)};W.prototype.set=W.prototype.set;W.prototype.update=function(a,b){A("Firebase.update",1,2,arguments.length);E("Firebase.update",this.path);Ea("Firebase.update",a);C("Firebase.update",2,b,k);return this.u.update(this.path,a,b)};W.prototype.update=W.prototype.update;
W.prototype.ab=function(a,b,c){A("Firebase.setWithPriority",2,3,arguments.length);E("Firebase.setWithPriority",this.path);Aa("Firebase.setWithPriority",a,o);Fa("Firebase.setWithPriority",2,b,o);C("Firebase.setWithPriority",3,c,k);(".length"===this.name()||".keys"===this.name())&&f("Firebase.setWithPriority failed: "+this.name()+" is a read-only object.");return this.u.ab(this.path,a,b,c)};W.prototype.setWithPriority=W.prototype.ab;
W.prototype.remove=function(a){A("Firebase.remove",0,1,arguments.length);E("Firebase.remove",this.path);C("Firebase.remove",1,a,k);this.set(l,a)};W.prototype.remove=W.prototype.remove;
W.prototype.transaction=function(a,b){function c(){}A("Firebase.transaction",1,2,arguments.length);E("Firebase.transaction",this.path);C("Firebase.transaction",1,a,o);C("Firebase.transaction",2,b,k);(".length"===this.name()||".keys"===this.name())&&f("Firebase.transaction failed: "+this.name()+" is a read-only object.");var d=this.u,e=this.path;d.e("transaction on "+e);var g=new W(d,e);g.sc("value",c);var h={path:e,update:a,A:b,Xc:Kb(),bd:0,ic:function(){g.Qb("value",c)}},j=d.i.Fa,m=h.update(T(j,
e).R());if(s(m)){Ba("transaction failed: Data returned ",m);var n=T(d.i.M,e).k();U(j,e,Q(m,n));Dd(d.S,e,[e]);h.status=1;e=J(d.gc,e);j=e.j()||[];j.push(h);M(e,j);Qd(d)}else h.ic(),h.A&&(d=Od(d,e),h.A(l,o,d))};W.prototype.transaction=W.prototype.transaction;W.prototype.Bc=function(a,b){A("Firebase.setPriority",1,2,arguments.length);E("Firebase.setPriority",this.path);Fa("Firebase.setPriority",1,a,o);C("Firebase.setPriority",2,b,k);this.u.Bc(this.path,a,b)};W.prototype.setPriority=W.prototype.Bc;
W.prototype.push=function(a,b){A("Firebase.push",0,2,arguments.length);E("Firebase.push",this.path);Aa("Firebase.push",a,k);C("Firebase.push",2,b,k);var c=Ud(),c=this.D(c);"undefined"!==typeof a&&a!==l&&c.set(a,b);return c};W.prototype.push=W.prototype.push;W.prototype.ia=function(){return new $(this.u,this.path,this.name())};W.prototype.onDisconnect=W.prototype.ia;
W.prototype.Dd=function(){Xb("FirebaseRef.removeOnDisconnect() being deprecated. Please use FirebaseRef.onDisconnect().remove() instead.");this.ia().remove();Nd(this.u)};W.prototype.removeOnDisconnect=W.prototype.Dd;W.prototype.Gd=function(a){Xb("FirebaseRef.setOnDisconnect(value) being deprecated. Please use FirebaseRef.onDisconnect().set(value) instead.");this.ia().set(a);Nd(this.u)};W.prototype.setOnDisconnect=W.prototype.Gd;
W.prototype.fb=function(a,b,c){A("Firebase.auth",1,3,arguments.length);t(a)||f(Error(B("Firebase.auth",1,o)+"must be a valid credential (a string)."));C("Firebase.auth",2,b,k);C("Firebase.auth",3,b,k);this.u.fb(a,b,c)};W.prototype.auth=W.prototype.fb;W.prototype.Fb=function(){this.u.Fb()};W.prototype.unauth=W.prototype.Fb;
function Sb(a,b){z(!b||a===k||a===o,"Can't turn on custom loggers persistently.");a===k?("undefined"!==typeof console&&("function"===typeof console.log?Pb=v(console.log,console):"object"===typeof console.log&&(Pb=function(a){console.log(a)})),b&&N.setItem("logging_enabled","true")):a?Pb=a:(Pb=l,N.removeItem("logging_enabled"))}W.enableLogging=Sb;W.INTERNAL=Z;W.Context=Y;