Socialify

Folder ..

Viewing firebase581.js
0 lines (1 loc) • 785.6 KB

1
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.firebase=e()}(this,function(){"use strict";!function(t){if(!t.fetch){var e={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(e.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],r=function(t){return t&&DataView.prototype.isPrototypeOf(t)},i=ArrayBuffer.isView||function(t){return t&&n.indexOf(Object.prototype.toString.call(t))>-1};h.prototype.append=function(t,e){t=a(t),e=u(e);var n=this.map[t];this.map[t]=n?n+","+e:e},h.prototype.delete=function(t){delete this.map[a(t)]},h.prototype.get=function(t){return t=a(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(a(t))},h.prototype.set=function(t,e){this.map[a(t)]=u(e)},h.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},h.prototype.keys=function(){var t=[];return this.forEach(function(e,n){t.push(n)}),c(t)},h.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),c(t)},h.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),c(t)},e.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},y.call(m.prototype),y.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:0,statusText:""});return t.type="error",t};var s=[301,302,303,307,308];v.redirect=function(t,e){if(-1===s.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})},t.Headers=h,t.Request=m,t.Response=v,t.fetch=function(t,n){return new Promise(function(r,i){var o=new m(t,n),s=new XMLHttpRequest;s.onload=function(){var t,e,n={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var n=t.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();e.append(r,i)}}),e)};n.url="responseURL"in s?s.responseURL:n.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;r(new v(i,n))},s.onerror=function(){i(new TypeError("Network request failed"))},s.ontimeout=function(){i(new TypeError("Network request failed"))},s.open(o.method,o.url,!0),"include"===o.credentials?s.withCredentials=!0:"omit"===o.credentials&&(s.withCredentials=!1),"responseType"in s&&e.blob&&(s.responseType="blob"),o.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send(void 0===o._bodyInit?null:o._bodyInit)})},t.fetch.polyfill=!0}function a(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function u(t){return"string"!=typeof t&&(t=String(t)),t}function c(t){var n={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e.iterable&&(n[Symbol.iterator]=function(){return n}),n}function h(t){this.map={},t instanceof h?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise(function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}})}function p(t){var e=new FileReader,n=f(e);return e.readAsArrayBuffer(t),n}function d(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(e.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(e.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(e.arrayBuffer&&e.blob&&r(t))this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!e.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!i(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=d(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(p)}),this.text=function(){var t,e,n,r=l(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,n=f(e),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(g)}),this.json=function(){return this.text().then(JSON.parse)},this}function m(t,e){var n,r,i=(e=e||{}).body;if(t instanceof m){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new h(e.headers)),this.method=(n=e.method||this.method||"GET",r=n.toUpperCase(),o.indexOf(r)>-1?r:n),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}}),e}function v(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}}("undefined"!=typeof self?self:void 0);var t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=setTimeout;function r(){}function i(t){if(!(this instanceof i))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],c(t,this)}function o(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,i._immediateFn(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var r;try{r=n(t._value)}catch(t){return void a(e.promise,t)}s(e.promise,r)}else(1===t._state?s:a)(e.promise,t._value)})):t._deferreds.push(e)}function s(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof i)return t._state=3,t._value=e,void u(t);if("function"==typeof n)return void c((r=n,o=e,function(){r.apply(o,arguments)}),t)}t._state=1,t._value=e,u(t)}catch(e){a(t,e)}var r,o}function a(t,e){t._state=2,t._value=e,u(t)}function u(t){2===t._state&&0===t._deferreds.length&&i._immediateFn(function(){t._handled||i._unhandledRejectionFn(t._value)});for(var e=0,n=t._deferreds.length;e<n;e++)o(t,t._deferreds[e]);t._deferreds=null}function c(t,e){var n=!1;try{t(function(t){n||(n=!0,s(e,t))},function(t){n||(n=!0,a(e,t))})}catch(t){if(n)return;n=!0,a(e,t)}}i.prototype.catch=function(t){return this.then(null,t)},i.prototype.then=function(t,e){var n=new this.constructor(r);return o(this,new function(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}(t,e,n)),n},i.prototype.finally=function(t){var e=this.constructor;return this.then(function(n){return e.resolve(t()).then(function(){return n})},function(n){return e.resolve(t()).then(function(){return e.reject(n)})})},i.all=function(t){return new i(function(e,n){if(!t||void 0===t.length)throw new TypeError("Promise.all accepts an array");var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);var i=r.length;function o(t,s){try{if(s&&("object"==typeof s||"function"==typeof s)){var a=s.then;if("function"==typeof a)return void a.call(s,function(e){o(t,e)},n)}r[t]=s,0==--i&&e(r)}catch(t){n(t)}}for(var s=0;s<r.length;s++)o(s,r[s])})},i.resolve=function(t){return t&&"object"==typeof t&&t.constructor===i?t:new i(function(e){e(t)})},i.reject=function(t){return new i(function(e,n){n(t)})},i.race=function(t){return new i(function(e,n){for(var r=0,i=t.length;r<i;r++)t[r].then(e,n)})},i._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){n(t,0)},i._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};var h=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t)return t;throw new Error("unable to locate global object")}();h.Promise||(h.Promise=i);var l=e(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),f=e(function(t){var e=t.exports={version:"2.5.5"};"number"==typeof __e&&(__e=e)}),p=(f.version,function(t){return"object"==typeof t?null!==t:"function"==typeof t}),d=function(t){if(!p(t))throw TypeError(t+" is not an object!");return t},y=function(t){try{return!!t()}catch(t){return!0}},m=!y(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),g=l.document,v=p(g)&&p(g.createElement),b=function(t){return v?g.createElement(t):{}},_=!m&&!y(function(){return 7!=Object.defineProperty(b("div"),"a",{get:function(){return 7}}).a}),w=function(t,e){if(!p(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!p(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!p(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!p(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},E=Object.defineProperty,T={f:m?Object.defineProperty:function(t,e,n){if(d(t),e=w(e,!0),d(n),_)try{return E(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},S=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},I=m?function(t,e,n){return T.f(t,e,S(1,n))}:function(t,e,n){return t[e]=n,t},C={}.hasOwnProperty,N=function(t,e){return C.call(t,e)},D=0,A=Math.random(),R=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++D+A).toString(36))},k=e(function(t){var e=R("src"),n=Function.toString,r=(""+n).split("toString");f.inspectSource=function(t){return n.call(t)},(t.exports=function(t,n,i,o){var s="function"==typeof i;s&&(N(i,"name")||I(i,"name",n)),t[n]!==i&&(s&&(N(i,e)||I(i,e,t[n]?""+t[n]:r.join(String(n)))),t===l?t[n]=i:o?t[n]?t[n]=i:I(t,n,i):(delete t[n],I(t,n,i)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[e]||n.call(this)})}),O=function(t,e,n){if(function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!")}(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}},P=function(t,e,n){var r,i,o,s,a=t&P.F,u=t&P.G,c=t&P.S,h=t&P.P,p=t&P.B,d=u?l:c?l[e]||(l[e]={}):(l[e]||{}).prototype,y=u?f:f[e]||(f[e]={}),m=y.prototype||(y.prototype={});for(r in u&&(n=e),n)o=((i=!a&&d&&void 0!==d[r])?d:n)[r],s=p&&i?O(o,l):h&&"function"==typeof o?O(Function.call,o):o,d&&k(d,r,o,t&P.U),y[r]!=o&&I(y,r,s),h&&m[r]!=o&&(m[r]=o)};l.core=f,P.F=1,P.G=2,P.S=4,P.P=8,P.B=16,P.W=32,P.U=64,P.R=128;var L=P,M={}.toString,x=function(t){return M.call(t).slice(8,-1)},F=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==x(t)?t.split(""):Object(t)},U=function(t){if(void 0==t)throw TypeError("Can't call method on  "+t);return t},q=function(t){return Object(U(t))},B=Math.ceil,V=Math.floor,W=function(t){return isNaN(t=+t)?0:(t>0?V:B)(t)},j=Math.min,K=function(t){return t>0?j(W(t),9007199254740991):0},Q=Array.isArray||function(t){return"Array"==x(t)},H=l["__core-js_shared__"]||(l["__core-js_shared__"]={}),G=function(t){return H[t]||(H[t]={})},z=e(function(t){var e=G("wks"),n=l.Symbol,r="function"==typeof n;(t.exports=function(t){return e[t]||(e[t]=r&&n[t]||(r?n:R)("Symbol."+t))}).store=e}),Y=z("species"),X=function(t,e){return new(function(t){var e;return Q(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!Q(e.prototype)||(e=void 0),p(e)&&null===(e=e[Y])&&(e=void 0)),void 0===e?Array:e}(t))(e)},J=function(t,e){var n=1==t,r=2==t,i=3==t,o=4==t,s=6==t,a=5==t||s,u=e||X;return function(e,c,h){for(var l,f,p=q(e),d=F(p),y=O(c,h,3),m=K(d.length),g=0,v=n?u(e,m):r?u(e,0):void 0;m>g;g++)if((a||g in d)&&(f=y(l=d[g],g,p),t))if(n)v[g]=f;else if(f)switch(t){case 3:return!0;case 5:return l;case 6:return g;case 2:v.push(l)}else if(o)return!1;return s?-1:i||o?o:v}},$=z("unscopables"),Z=Array.prototype;void 0==Z[$]&&I(Z,$,{});var tt=function(t){Z[$][t]=!0},et=J(5),nt=!0;"find"in[]&&Array(1).find(function(){nt=!1}),L(L.P+L.F*nt,"Array",{find:function(t){return et(this,t,arguments.length>1?arguments[1]:void 0)}}),tt("find");f.Array.find;var rt=J(6),it=!0;"findIndex"in[]&&Array(1).findIndex(function(){it=!1}),L(L.P+L.F*it,"Array",{findIndex:function(t){return rt(this,t,arguments.length>1?arguments[1]:void 0)}}),tt("findIndex");f.Array.findIndex;var ot,st=function(t){return F(U(t))},at=Math.max,ut=Math.min,ct=G("keys"),ht=function(t){return ct[t]||(ct[t]=R(t))},lt=(ot=!1,function(t,e,n){var r,i=st(t),o=K(i.length),s=function(t,e){return(t=W(t))<0?at(t+e,0):ut(t,e)}(n,o);if(ot&&e!=e){for(;o>s;)if((r=i[s++])!=r)return!0}else for(;o>s;s++)if((ot||s in i)&&i[s]===e)return ot||s||0;return!ot&&-1}),ft=ht("IE_PROTO"),pt=function(t,e){var n,r=st(t),i=0,o=[];for(n in r)n!=ft&&N(r,n)&&o.push(n);for(;e.length>i;)N(r,n=e[i++])&&(~lt(o,n)||o.push(n));return o},dt="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),yt=Object.keys||function(t){return pt(t,dt)},mt={f:Object.getOwnPropertySymbols},gt={f:{}.propertyIsEnumerable},vt=Object.assign,bt=!vt||y(function(){var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach(function(t){e[t]=t}),7!=vt({},t)[n]||Object.keys(vt({},e)).join("")!=r})?function(t,e){for(var n=q(t),r=arguments.length,i=1,o=mt.f,s=gt.f;r>i;)for(var a,u=F(arguments[i++]),c=o?yt(u).concat(o(u)):yt(u),h=c.length,l=0;h>l;)s.call(u,a=c[l++])&&(n[a]=u[a]);return n}:vt;L(L.S+L.F,"Object",{assign:bt});f.Object.assign;var _t=z("match"),wt=function(t,e,n){if(p(r=e)&&(void 0!==(i=r[_t])?i:"RegExp"==x(r)))throw TypeError("String#"+n+" doesn't accept regex!");var r,i;return String(U(t))},Et=z("match"),Tt="".startsWith;L(L.P+L.F*function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[Et]=!1,!"/./"[t](e)}catch(t){}}return!0}("startsWith"),"String",{startsWith:function(t){var e=wt(this,t,"startsWith"),n=K(Math.min(arguments.length>1?arguments[1]:void 0,e.length)),r=String(t);return Tt?Tt.call(e,r,n):e.slice(n,n+r.length)===r}});f.String.startsWith;L(L.P,"String",{repeat:function(t){var e=String(U(this)),n="",r=W(t);if(r<0||r==1/0)throw RangeError("Count can't be negative");for(;r>0;(r>>>=1)&&(e+=e))1&r&&(n+=e);return n}});f.String.repeat;var St=e(function(t){var e=R("meta"),n=T.f,r=0,i=Object.isExtensible||function(){return!0},o=!y(function(){return i(Object.preventExtensions({}))}),s=function(t){n(t,e,{value:{i:"O"+ ++r,w:{}}})},a=t.exports={KEY:e,NEED:!1,fastKey:function(t,n){if(!p(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!N(t,e)){if(!i(t))return"F";if(!n)return"E";s(t)}return t[e].i},getWeak:function(t,n){if(!N(t,e)){if(!i(t))return!0;if(!n)return!1;s(t)}return t[e].w},onFreeze:function(t){return o&&a.NEED&&i(t)&&!N(t,e)&&s(t),t}}}),It=(St.KEY,St.NEED,St.fastKey,St.getWeak,St.onFreeze,T.f),Ct=z("toStringTag"),Nt=function(t,e,n){t&&!N(t=n?t:t.prototype,Ct)&&It(t,Ct,{configurable:!0,value:e})},Dt={f:z},At=T.f,Rt=function(t){var e=f.Symbol||(f.Symbol=l.Symbol||{});"_"==t.charAt(0)||t in e||At(e,t,{value:Dt.f(t)})},kt=m?Object.defineProperties:function(t,e){d(t);for(var n,r=yt(e),i=r.length,o=0;i>o;)T.f(t,n=r[o++],e[n]);return t},Ot=l.document,Pt=Ot&&Ot.documentElement,Lt=ht("IE_PROTO"),Mt=function(){},xt=function(){var t,e=b("iframe"),n=dt.length;for(e.style.display="none",Pt.appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),xt=t.F;n--;)delete xt.prototype[dt[n]];return xt()},Ft=Object.create||function(t,e){var n;return null!==t?(Mt.prototype=d(t),n=new Mt,Mt.prototype=null,n[Lt]=t):n=xt(),void 0===e?n:kt(n,e)},Ut=dt.concat("length","prototype"),qt={f:Object.getOwnPropertyNames||function(t){return pt(t,Ut)}},Bt=qt.f,Vt={}.toString,Wt="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],jt={f:function(t){return Wt&&"[object Window]"==Vt.call(t)?function(t){try{return Bt(t)}catch(t){return Wt.slice()}}(t):Bt(st(t))}},Kt=Object.getOwnPropertyDescriptor,Qt={f:m?Kt:function(t,e){if(t=st(t),e=w(e,!0),_)try{return Kt(t,e)}catch(t){}if(N(t,e))return S(!gt.f.call(t,e),t[e])}},Ht=St.KEY,Gt=Qt.f,zt=T.f,Yt=jt.f,Xt=l.Symbol,Jt=l.JSON,$t=Jt&&Jt.stringify,Zt=z("_hidden"),te=z("toPrimitive"),ee={}.propertyIsEnumerable,ne=G("symbol-registry"),re=G("symbols"),ie=G("op-symbols"),oe=Object.prototype,se="function"==typeof Xt,ae=l.QObject,ue=!ae||!ae.prototype||!ae.prototype.findChild,ce=m&&y(function(){return 7!=Ft(zt({},"a",{get:function(){return zt(this,"a",{value:7}).a}})).a})?function(t,e,n){var r=Gt(oe,e);r&&delete oe[e],zt(t,e,n),r&&t!==oe&&zt(oe,e,r)}:zt,he=function(t){var e=re[t]=Ft(Xt.prototype);return e._k=t,e},le=se&&"symbol"==typeof Xt.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof Xt},fe=function(t,e,n){return t===oe&&fe(ie,e,n),d(t),e=w(e,!0),d(n),N(re,e)?(n.enumerable?(N(t,Zt)&&t[Zt][e]&&(t[Zt][e]=!1),n=Ft(n,{enumerable:S(0,!1)})):(N(t,Zt)||zt(t,Zt,S(1,{})),t[Zt][e]=!0),ce(t,e,n)):zt(t,e,n)},pe=function(t,e){d(t);for(var n,r=function(t){var e=yt(t),n=mt.f;if(n)for(var r,i=n(t),o=gt.f,s=0;i.length>s;)o.call(t,r=i[s++])&&e.push(r);return e}(e=st(e)),i=0,o=r.length;o>i;)fe(t,n=r[i++],e[n]);return t},de=function(t){var e=ee.call(this,t=w(t,!0));return!(this===oe&&N(re,t)&&!N(ie,t))&&(!(e||!N(this,t)||!N(re,t)||N(this,Zt)&&this[Zt][t])||e)},ye=function(t,e){if(t=st(t),e=w(e,!0),t!==oe||!N(re,e)||N(ie,e)){var n=Gt(t,e);return!n||!N(re,e)||N(t,Zt)&&t[Zt][e]||(n.enumerable=!0),n}},me=function(t){for(var e,n=Yt(st(t)),r=[],i=0;n.length>i;)N(re,e=n[i++])||e==Zt||e==Ht||r.push(e);return r},ge=function(t){for(var e,n=t===oe,r=Yt(n?ie:st(t)),i=[],o=0;r.length>o;)!N(re,e=r[o++])||n&&!N(oe,e)||i.push(re[e]);return i};se||(k((Xt=function(){if(this instanceof Xt)throw TypeError("Symbol is not a constructor!");var t=R(arguments.length>0?arguments[0]:void 0),e=function(n){this===oe&&e.call(ie,n),N(this,Zt)&&N(this[Zt],t)&&(this[Zt][t]=!1),ce(this,t,S(1,n))};return m&&ue&&ce(oe,t,{configurable:!0,set:e}),he(t)}).prototype,"toString",function(){return this._k}),Qt.f=ye,T.f=fe,qt.f=jt.f=me,gt.f=de,mt.f=ge,m&&k(oe,"propertyIsEnumerable",de,!0),Dt.f=function(t){return he(z(t))}),L(L.G+L.W+L.F*!se,{Symbol:Xt});for(var ve="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),be=0;ve.length>be;)z(ve[be++]);for(var _e=yt(z.store),we=0;_e.length>we;)Rt(_e[we++]);L(L.S+L.F*!se,"Symbol",{for:function(t){return N(ne,t+="")?ne[t]:ne[t]=Xt(t)},keyFor:function(t){if(!le(t))throw TypeError(t+" is not a symbol!");for(var e in ne)if(ne[e]===t)return e},useSetter:function(){ue=!0},useSimple:function(){ue=!1}}),L(L.S+L.F*!se,"Object",{create:function(t,e){return void 0===e?Ft(t):pe(Ft(t),e)},defineProperty:fe,defineProperties:pe,getOwnPropertyDescriptor:ye,getOwnPropertyNames:me,getOwnPropertySymbols:ge}),Jt&&L(L.S+L.F*(!se||y(function(){var t=Xt();return"[null]"!=$t([t])||"{}"!=$t({a:t})||"{}"!=$t(Object(t))})),"JSON",{stringify:function(t){for(var e,n,r=[t],i=1;arguments.length>i;)r.push(arguments[i++]);if(n=e=r[1],(p(e)||void 0!==t)&&!le(t))return Q(e)||(e=function(t,e){if("function"==typeof n&&(e=n.call(this,t,e)),!le(e))return e}),r[1]=e,$t.apply(Jt,r)}}),Xt.prototype[te]||I(Xt.prototype,te,Xt.prototype.valueOf),Nt(Xt,"Symbol"),Nt(Math,"Math",!0),Nt(l.JSON,"JSON",!0);var Ee=z("toStringTag"),Te="Arguments"==x(function(){return arguments}()),Se={};Se[z("toStringTag")]="z",Se+""!="[object z]"&&k(Object.prototype,"toString",function(){return"[object "+(void 0===(t=this)?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),Ee))?n:Te?x(e):"Object"==(r=x(e))&&"function"==typeof e.callee?"Arguments":r)+"]";var t,e,n,r},!0),Rt("asyncIterator"),Rt("observable");f.Symbol;var Ie={},Ce={};I(Ce,z("iterator"),function(){return this});var Ne,De=function(t,e,n){t.prototype=Ft(Ce,{next:S(1,n)}),Nt(t,e+" Iterator")},Ae=ht("IE_PROTO"),Re=Object.prototype,ke=Object.getPrototypeOf||function(t){return t=q(t),N(t,Ae)?t[Ae]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?Re:null},Oe=z("iterator"),Pe=!([].keys&&"next"in[].keys()),Le=function(){return this},Me=function(t,e,n,r,i,o,s){De(n,e,r);var a,u,c,h=function(t){if(!Pe&&t in d)return d[t];switch(t){case"keys":case"values":return function(){return new n(this,t)}}return function(){return new n(this,t)}},l=e+" Iterator",f="values"==i,p=!1,d=t.prototype,y=d[Oe]||d["@@iterator"]||i&&d[i],m=y||h(i),g=i?f?h("entries"):m:void 0,v="Array"==e&&d.entries||y;if(v&&(c=ke(v.call(new t)))!==Object.prototype&&c.next&&(Nt(c,l,!0),"function"!=typeof c[Oe]&&I(c,Oe,Le)),f&&y&&"values"!==y.name&&(p=!0,m=function(){return y.call(this)}),(Pe||p||!d[Oe])&&I(d,Oe,m),Ie[e]=m,Ie[l]=Le,i)if(a={values:f?m:h("values"),keys:o?m:h("keys"),entries:g},s)for(u in a)u in d||k(d,u,a[u]);else L(L.P+L.F*(Pe||p),e,a);return a},xe=(Ne=!0,function(t,e){var n,r,i=String(U(t)),o=W(e),s=i.length;return o<0||o>=s?Ne?"":void 0:(n=i.charCodeAt(o))<55296||n>56319||o+1===s||(r=i.charCodeAt(o+1))<56320||r>57343?Ne?i.charAt(o):n:Ne?i.slice(o,o+2):r-56320+(n-55296<<10)+65536});Me(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,n=this._i;return n>=e.length?{value:void 0,done:!0}:(t=xe(e,n),this._i+=t.length,{value:t,done:!1})});var Fe=function(t,e){return{value:e,done:!!t}},Ue=Me(Array,"Array",function(t,e){this._t=st(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,n=this._i++;return!t||n>=t.length?(this._t=void 0,Fe(1)):Fe(0,"keys"==e?n:"values"==e?t[n]:[n,t[n]])},"values");Ie.Arguments=Ie.Array,tt("keys"),tt("values"),tt("entries");for(var qe=z("iterator"),Be=z("toStringTag"),Ve=Ie.Array,We={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},je=yt(We),Ke=0;Ke<je.length;Ke++){var Qe,He=je[Ke],Ge=We[He],ze=l[He],Ye=ze&&ze.prototype;if(Ye&&(Ye[qe]||I(Ye,qe,Ve),Ye[Be]||I(Ye,Be,He),Ie[He]=Ve,Ge))for(Qe in Ue)Ye[Qe]||k(Ye,Qe,Ue[Qe],!0)}Dt.f("iterator");var Xe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};function Je(t,e){function n(){this.constructor=t}Xe(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var $e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t};function Ze(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):new n(function(e){e(t.value)}).then(s,a)}u((r=r.apply(t,e||[])).next())})}function tn(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var en=!1,nn=!1,rn="${JSCORE_VERSION}",on=function(t,e){if(!t)throw sn(e)},sn=function(t){return new Error("Firebase Database ("+rn+") INTERNAL ASSERT FAILED: "+t)},an=function(t){for(var e=[],n=0,r=0;r<t.length;r++){var i=t.charCodeAt(r);i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=63&i|128):55296==(64512&i)&&r+1<t.length&&56320==(64512&t.charCodeAt(r+1))?(i=65536+((1023&i)<<10)+(1023&t.charCodeAt(++r)),e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=63&i|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=63&i|128)}return e},un={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray:function(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[],i=0;i<t.length;i+=3){var o=t[i],s=i+1<t.length,a=s?t[i+1]:0,u=i+2<t.length,c=u?t[i+2]:0,h=o>>2,l=(3&o)<<4|a>>4,f=(15&a)<<2|c>>6,p=63&c;u||(p=64,s||(f=64)),r.push(n[h],n[l],n[f],n[p])}return r.join("")},encodeString:function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(an(t),e)},decodeString:function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){for(var e=[],n=0,r=0;n<t.length;){var i=t[n++];if(i<128)e[r++]=String.fromCharCode(i);else if(i>191&&i<224){var o=t[n++];e[r++]=String.fromCharCode((31&i)<<6|63&o)}else if(i>239&&i<365){var s=((7&i)<<18|(63&(o=t[n++]))<<12|(63&(a=t[n++]))<<6|63&t[n++])-65536;e[r++]=String.fromCharCode(55296+(s>>10)),e[r++]=String.fromCharCode(56320+(1023&s))}else{o=t[n++];var a=t[n++];e[r++]=String.fromCharCode((15&i)<<12|(63&o)<<6|63&a)}}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray:function(t,e){this.init_();for(var n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[],i=0;i<t.length;){var o=n[t.charAt(i++)],s=i<t.length?n[t.charAt(i)]:0,a=++i<t.length?n[t.charAt(i)]:64,u=++i<t.length?n[t.charAt(i)]:64;if(++i,null==o||null==s||null==a||null==u)throw Error();var c=o<<2|s>>4;if(r.push(c),64!=a){var h=s<<4&240|a>>2;if(r.push(h),64!=u){var l=a<<6&192|u;r.push(l)}}}return r},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},cn=function(t){try{return un.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};function hn(t){return ln(void 0,t)}function ln(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n in e)e.hasOwnProperty(n)&&(t[n]=ln(t[n],e[n]));return t}function fn(t,e,n){t[e]=n}var pn=function(){function t(){var t=this;this.promise=new Promise(function(e,n){t.resolve=e,t.reject=n})}return t.prototype.wrapCallback=function(t){var e=this;return function(n,r){n?e.reject(n):e.resolve(r),"function"==typeof t&&(e.promise.catch(function(){}),1===t.length?t(n):t(n,r))}},t}(),dn=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test("undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:"")},yn=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},mn=function(){return!0===en||!0===nn},gn="FirebaseError",vn=Error.captureStackTrace,bn=function(){return function(t,e){if(this.code=t,this.message=e,vn)vn(this,_n.prototype.create);else try{throw Error.apply(this,arguments)}catch(t){this.name=gn,Object.defineProperty(this,"stack",{get:function(){return t.stack}})}}}();bn.prototype=Object.create(Error.prototype),bn.prototype.constructor=bn,bn.prototype.name=gn;var _n=function(){function t(t,e,n){this.service=t,this.serviceName=e,this.errors=n,this.pattern=/\{\$([^}]+)}/g}return t.prototype.create=function(t,e){void 0===e&&(e={});var n,r=this.errors[t],i=this.service+"/"+t;n=void 0===r?"Error":r.replace(this.pattern,function(t,n){var r=e[n];return void 0!==r?r.toString():"<"+n+"?>"}),n=this.serviceName+": "+n+" ("+i+").";var o=new bn(i,n);for(var s in e)e.hasOwnProperty(s)&&"_"!==s.slice(-1)&&(o[s]=e[s]);return o},t}();function wn(t){return JSON.parse(t)}function En(t){return JSON.stringify(t)}var Tn=function(t){var e={},n={},r={},i="";try{var o=t.split(".");e=wn(cn(o[0])||""),n=wn(cn(o[1])||""),i=o[2],r=n.d||{},delete n.d}catch(t){}return{header:e,claims:n,data:r,signature:i}},Sn=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},In=function(t,e){if(Object.prototype.hasOwnProperty.call(t,e))return t[e]},Cn=function(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])},Nn=function(t){return e={},Cn(t,function(t,n){e[t]=n}),e;var e},Dn=function(t){for(var e in t)return!1;return!0},An=function(t){var e=0;for(var n in t)e++;return e},Rn=function(t,e,n){var r={};for(var i in t)r[i]=e.call(n,t[i],i,t);return r},kn=function(t,e,n){for(var r in t)if(e.call(n,t[r],r,t))return r},On=function(t){for(var e in t)return e},Pn=function(t){function e(){var e=t.call(this)||this;e.chain_=[],e.buf_=[],e.W_=[],e.pad_=[],e.inbuf_=0,e.total_=0,e.blockSize=64,e.pad_[0]=128;for(var n=1;n<e.blockSize;++n)e.pad_[n]=0;return e.reset(),e}return Je(e,t),e.prototype.reset=function(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0},e.prototype.compress_=function(t,e){e||(e=0);var n=this.W_;if("string"==typeof t)for(var r=0;r<16;r++)n[r]=t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|t.charCodeAt(e+3),e+=4;else for(r=0;r<16;r++)n[r]=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3],e+=4;for(r=16;r<80;r++){var i=n[r-3]^n[r-8]^n[r-14]^n[r-16];n[r]=4294967295&(i<<1|i>>>31)}var o,s,a=this.chain_[0],u=this.chain_[1],c=this.chain_[2],h=this.chain_[3],l=this.chain_[4];for(r=0;r<80;r++){r<40?r<20?(o=h^u&(c^h),s=1518500249):(o=u^c^h,s=1859775393):r<60?(o=u&c|h&(u|c),s=2400959708):(o=u^c^h,s=3395469782);i=(a<<5|a>>>27)+o+l+s+n[r]&4294967295;l=h,h=c,c=4294967295&(u<<30|u>>>2),u=a,a=i}this.chain_[0]=this.chain_[0]+a&4294967295,this.chain_[1]=this.chain_[1]+u&4294967295,this.chain_[2]=this.chain_[2]+c&4294967295,this.chain_[3]=this.chain_[3]+h&4294967295,this.chain_[4]=this.chain_[4]+l&4294967295},e.prototype.update=function(t,e){if(null!=t){void 0===e&&(e=t.length);for(var n=e-this.blockSize,r=0,i=this.buf_,o=this.inbuf_;r<e;){if(0==o)for(;r<=n;)this.compress_(t,r),r+=this.blockSize;if("string"==typeof t){for(;r<e;)if(i[o]=t.charCodeAt(r),++r,++o==this.blockSize){this.compress_(i),o=0;break}}else for(;r<e;)if(i[o]=t[r],++r,++o==this.blockSize){this.compress_(i),o=0;break}}this.inbuf_=o,this.total_+=e}},e.prototype.digest=function(){var t=[],e=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(var n=this.blockSize-1;n>=56;n--)this.buf_[n]=255&e,e/=256;this.compress_(this.buf_);var r=0;for(n=0;n<5;n++)for(var i=24;i>=0;i-=8)t[r]=this.chain_[n]>>i&255,++r;return t},e}(function(){return function(){this.blockSize=-1}}());function Ln(t,e){var n=new Mn(t,e);return n.subscribe.bind(n)}var Mn=function(){function t(t,e){var n=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then(function(){t(n)}).catch(function(t){n.error(t)})}return t.prototype.next=function(t){this.forEachObserver(function(e){e.next(t)})},t.prototype.error=function(t){this.forEachObserver(function(e){e.error(t)}),this.close(t)},t.prototype.complete=function(){this.forEachObserver(function(t){t.complete()}),this.close()},t.prototype.subscribe=function(t,e,n){var r,i=this;if(void 0===t&&void 0===e&&void 0===n)throw new Error("Missing Observer.");void 0===(r=function(t,e){if("object"!=typeof t||null===t)return!1;for(var n=0,r=e;n<r.length;n++){var i=r[n];if(i in t&&"function"==typeof t[i])return!0}return!1}(t,["next","error","complete"])?t:{next:t,error:e,complete:n}).next&&(r.next=xn),void 0===r.error&&(r.error=xn),void 0===r.complete&&(r.complete=xn);var o=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(function(){try{i.finalError?r.error(i.finalError):r.complete()}catch(t){}}),this.observers.push(r),o},t.prototype.unsubscribeOne=function(t){void 0!==this.observers&&void 0!==this.observers[t]&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))},t.prototype.forEachObserver=function(t){if(!this.finalized)for(var e=0;e<this.observers.length;e++)this.sendOne(e,t)},t.prototype.sendOne=function(t,e){var n=this;this.task.then(function(){if(void 0!==n.observers&&void 0!==n.observers[t])try{e(n.observers[t])}catch(t){"undefined"!=typeof console&&console.error&&console.error(t)}})},t.prototype.close=function(t){var e=this;this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then(function(){e.observers=void 0,e.onNoObservers=void 0}))},t}();function xn(){}var Fn=function(t,e,n,r){var i;if(r<e?i="at least "+e:r>n&&(i=0===n?"none":"no more than "+n),i)throw new Error(t+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+i+".")};function Un(t,e,n){var r="";switch(e){case 1:r=n?"first":"First";break;case 2:r=n?"second":"Second";break;case 3:r=n?"third":"Third";break;case 4:r=n?"fourth":"Fourth";break;default:throw new Error("errorPrefix called with argumentNumber > 4.  Need to update it?")}var i=t+" failed: ";return i+=r+" argument "}function qn(t,e,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(Un(t,e,r)+"must be a valid function.")}function Bn(t,e,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(Un(t,e,r)+"must be a valid context object.")}var Vn=function(t){for(var e=0,n=0;n<t.length;n++){var r=t.charCodeAt(n);r<128?e++:r<2048?e+=2:r>=55296&&r<=56319?(e+=4,n++):e+=3}return e},Wn=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},jn="[DEFAULT]",Kn=[],Qn=function(){function t(t,e,n){this.firebase_=n,this.isDeleted_=!1,this.services_={},this.name_=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled||!1,this.options_=hn(t),this.INTERNAL={getUid:function(){return null},getToken:function(){return Promise.resolve(null)},addAuthTokenListener:function(t){Kn.push(t),setTimeout(function(){return t(null)},0)},removeAuthTokenListener:function(t){Kn=Kn.filter(function(e){return e!==t})}}}return Object.defineProperty(t.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this._automaticDataCollectionEnabled},set:function(t){this.checkDestroyed_(),this._automaticDataCollectionEnabled=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),t.prototype.delete=function(){var t=this;return new Promise(function(e){t.checkDestroyed_(),e()}).then(function(){t.firebase_.INTERNAL.removeApp(t.name_);var e=[];return Object.keys(t.services_).forEach(function(n){Object.keys(t.services_[n]).forEach(function(r){e.push(t.services_[n][r])})}),Promise.all(e.map(function(t){return t.INTERNAL.delete()}))}).then(function(){t.isDeleted_=!0,t.services_={}})},t.prototype._getService=function(t,e){if(void 0===e&&(e=jn),this.checkDestroyed_(),this.services_[t]||(this.services_[t]={}),!this.services_[t][e]){var n=e!==jn?e:void 0,r=this.firebase_.INTERNAL.factories[t](this,this.extendApp.bind(this),n);this.services_[t][e]=r}return this.services_[t][e]},t.prototype.extendApp=function(t){var e=this;ln(this,t),t.INTERNAL&&t.INTERNAL.addAuthTokenListener&&(Kn.forEach(function(t){e.INTERNAL.addAuthTokenListener(t)}),Kn=[])},t.prototype.checkDestroyed_=function(){this.isDeleted_&&Hn("app-deleted",{name:this.name_})},t}();function Hn(t,e){throw zn.create(t,e)}Qn.prototype.name&&Qn.prototype.options||Qn.prototype.delete||console.log("dc");var Gn,zn=new _n("app","Firebase",{"no-app":"No Firebase App '{$name}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$name}","duplicate-app":"Firebase App named '{$name}' already exists","app-deleted":"Firebase App named '{$name}' already deleted","duplicate-service":"Firebase service named '{$name}' already registered","sa-not-supported":"Initializing the Firebase SDK with a service account is only allowed in a Node.js environment. On client devices, you should instead initialize the SDK with an api key and auth domain","invalid-app-argument":"firebase.{$name}() takes either no argument or a Firebase App instance."}),Yn=function t(){var e={},n={},r={},i={__esModule:!0,initializeApp:function(t,n){if(void 0===n&&(n={}),"object"!=typeof n||null===n){var r=n;n={name:r}}var o=n;void 0===o.name&&(o.name=jn);var s=o.name;"string"==typeof s&&s||Hn("bad-app-name",{name:s+""}),Wn(e,s)&&Hn("duplicate-app",{name:s});var u=new Qn(t,o,i);return e[s]=u,a(u,"create"),u},app:o,apps:null,Promise:Promise,SDK_VERSION:"5.8.1",INTERNAL:{registerService:function(t,e,a,u,c){n[t]&&Hn("duplicate-service",{name:t}),n[t]=e,u&&(r[t]=u,s().forEach(function(t){u("create",t)}));var h=function(e){return void 0===e&&(e=o()),"function"!=typeof e[t]&&Hn("invalid-app-argument",{name:t}),e[t]()};return void 0!==a&&ln(h,a),i[t]=h,Qn.prototype[t]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return this._getService.bind(this,t).apply(this,c?e:[])},h},createFirebaseNamespace:t,extendNamespace:function(t){ln(i,t)},createSubscribe:Ln,ErrorFactory:_n,removeApp:function(t){a(e[t],"delete"),delete e[t]},factories:n,useAsService:u,Promise:Promise,deepExtend:ln}};function o(t){return Wn(e,t=t||jn)||Hn("no-app",{name:t}),e[t]}function s(){return Object.keys(e).map(function(t){return e[t]})}function a(t,e){Object.keys(n).forEach(function(n){var i=u(t,n);null!==i&&r[i]&&r[i](e,t)})}function u(t,e){if("serverAuth"===e)return null;var n=e;return t.options,n}return fn(i,"default",i),Object.defineProperty(i,"apps",{get:s}),fn(o,"App",Qn),i}();(function(){var t,e=e||{},n=this;function r(t){return"string"==typeof t}function i(t){return"boolean"==typeof t}function o(){}function s(t){var e=typeof t;if("object"==e){if(!t)return"null";if(t instanceof Array)return"array";if(t instanceof Object)return e;var n=Object.prototype.toString.call(t);if("[object Window]"==n)return"object";if("[object Array]"==n||"number"==typeof t.length&&void 0!==t.splice&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("splice"))return"array";if("[object Function]"==n||void 0!==t.call&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("call"))return"function"}else if("function"==e&&void 0===t.call)return"object";return e}function a(t){return null===t}function u(t){return"array"==s(t)}function c(t){var e=s(t);return"array"==e||"object"==e&&"number"==typeof t.length}function h(t){return"function"==s(t)}function l(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var f="closure_uid_"+(1e9*Math.random()>>>0),p=0;function d(t,e,n){return t.call.apply(t.bind,arguments)}function y(t,e,n){if(!t)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function m(t,e,n){return(m=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?d:y).apply(null,arguments)}function g(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}var v=Date.now||function(){return+new Date};function b(t,e){function n(){}n.prototype=e.prototype,t.ob=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.ed=function(t,n,r){for(var i=Array(arguments.length-2),o=2;o<arguments.length;o++)i[o-2]=arguments[o];return e.prototype[n].apply(t,i)}}function _(t){t.prototype.then=t.prototype.then,t.prototype.$goog_Thenable=!0}function w(t){if(!t)return!1;try{return!!t.$goog_Thenable}catch(t){return!1}}function E(t){if(Error.captureStackTrace)Error.captureStackTrace(this,E);else{var e=Error().stack;e&&(this.stack=e)}t&&(this.message=String(t))}function T(t,e){for(var n="",r=(t=t.split("%s")).length-1,i=0;i<r;i++)n+=t[i]+(i<e.length?e[i]:"%s");E.call(this,n+t[r])}function S(t,e){throw new T("Failure"+(t?": "+t:""),Array.prototype.slice.call(arguments,1))}function I(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function C(t,e){t.f(e),100>t.b&&(t.b++,e.next=t.a,t.a=e)}function N(){this.b=this.a=null}b(E,Error),E.prototype.name="CustomError",b(T,E),T.prototype.name="AssertionError",I.prototype.get=function(){if(0<this.b){this.b--;var t=this.a;this.a=t.next,t.next=null}else t=this.c();return t};var D=new I(function(){return new R},function(t){t.reset()});function A(){var t=ft,e=null;return t.a&&(e=t.a,t.a=t.a.next,t.a||(t.b=null),e.next=null),e}function R(){this.next=this.b=this.a=null}N.prototype.add=function(t,e){var n=D.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},R.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null},R.prototype.reset=function(){this.next=this.b=this.a=null};var k=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(r(t))return r(e)&&1==e.length?t.indexOf(e,0):-1;for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},O=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var i=t.length,o=r(t)?t.split(""):t,s=0;s<i;s++)s in o&&e.call(n,o[s],s,t)};var P=Array.prototype.map?function(t,e){return Array.prototype.map.call(t,e,void 0)}:function(t,e){for(var n=t.length,i=Array(n),o=r(t)?t.split(""):t,s=0;s<n;s++)s in o&&(i[s]=e.call(void 0,o[s],s,t));return i},L=Array.prototype.some?function(t,e){return Array.prototype.some.call(t,e,void 0)}:function(t,e){for(var n=t.length,i=r(t)?t.split(""):t,o=0;o<n;o++)if(o in i&&e.call(void 0,i[o],o,t))return!0;return!1};function M(t,e){return 0<=k(t,e)}function x(t,e){var n;return(n=0<=(e=k(t,e)))&&Array.prototype.splice.call(t,e,1),n}function F(t,e){!function(t,e){var n=t.length,i=r(t)?t.split(""):t;for(--n;0<=n;--n)n in i&&e.call(void 0,i[n],n,t)}(t,function(n,r){e.call(void 0,n,r,t)&&1==Array.prototype.splice.call(t,r,1).length&&0})}function U(t){return Array.prototype.concat.apply([],arguments)}function q(t){var e=t.length;if(0<e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}return[]}function B(t,e){for(var n=t.split("%s"),r="",i=Array.prototype.slice.call(arguments,1);i.length&&1<n.length;)r+=n.shift()+i.shift();return r+n.join("%s")}var V=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function W(t){return X.test(t)?(-1!=t.indexOf("&")&&(t=t.replace(K,"&amp;")),-1!=t.indexOf("<")&&(t=t.replace(Q,"&lt;")),-1!=t.indexOf(">")&&(t=t.replace(H,"&gt;")),-1!=t.indexOf('"')&&(t=t.replace(G,"&quot;")),-1!=t.indexOf("'")&&(t=t.replace(z,"&#39;")),-1!=t.indexOf("\0")&&(t=t.replace(Y,"&#0;")),t):t}var j,K=/&/g,Q=/</g,H=/>/g,G=/"/g,z=/'/g,Y=/\x00/g,X=/[\x00&<>"']/;function J(t,e){return-1!=t.indexOf(e)}function $(t,e){return t<e?-1:t>e?1:0}t:{var Z=n.navigator;if(Z){var tt=Z.userAgent;if(tt){j=tt;break t}}j=""}function et(t){return J(j,t)}function nt(t,e){for(var n in t)e.call(void 0,t[n],n,t)}function rt(t){for(var e in t)return!1;return!0}function it(t){var e,n={};for(e in t)n[e]=t[e];return n}var ot,st,at="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function ut(t,e){for(var n,r,i=1;i<arguments.length;i++){for(n in r=arguments[i])t[n]=r[n];for(var o=0;o<at.length;o++)n=at[o],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function ct(t){n.setTimeout(function(){throw t},0)}function ht(t,e){st||function(){if(n.Promise&&n.Promise.resolve){var t=n.Promise.resolve(void 0);st=function(){t.then(pt)}}else st=function(){var t=pt;!h(n.setImmediate)||n.Window&&n.Window.prototype&&!et("Edge")&&n.Window.prototype.setImmediate==n.setImmediate?(ot||(ot=function(){var t=n.MessageChannel;if(void 0===t&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&!et("Presto")&&(t=function(){var t=document.createElement("IFRAME");t.style.display="none",t.src="",document.documentElement.appendChild(t);var e=t.contentWindow;(t=e.document).open(),t.write(""),t.close();var n="callImmediate"+Math.random(),r="file:"==e.location.protocol?"*":e.location.protocol+"//"+e.location.host;t=m(function(t){"*"!=r&&t.origin!=r||t.data!=n||this.port1.onmessage()},this),e.addEventListener("message",t,!1),this.port1={},this.port2={postMessage:function(){e.postMessage(n,r)}}}),void 0!==t&&!et("Trident")&&!et("MSIE")){var e=new t,r={},i=r;return e.port1.onmessage=function(){if(void 0!==r.next){var t=(r=r.next).wb;r.wb=null,t()}},function(t){i.next={wb:t},i=i.next,e.port2.postMessage(0)}}return"undefined"!=typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?function(t){var e=document.createElement("SCRIPT");e.onreadystatechange=function(){e.onreadystatechange=null,e.parentNode.removeChild(e),e=null,t(),t=null},document.documentElement.appendChild(e)}:function(t){n.setTimeout(t,0)}}()),ot(t)):n.setImmediate(t)}}(),lt||(st(),lt=!0),ft.add(t,e)}var lt=!1,ft=new N;function pt(){for(var t;t=A();){try{t.a.call(t.b)}catch(t){ct(t)}C(D,t)}lt=!1}function dt(t,e){if(this.a=yt,this.i=void 0,this.f=this.b=this.c=null,this.g=this.h=!1,t!=o)try{var n=this;t.call(e,function(t){Nt(n,mt,t)},function(t){if(!(t instanceof Lt))try{if(t instanceof Error)throw t;throw Error("Promise rejected.")}catch(t){}Nt(n,gt,t)})}catch(t){Nt(this,gt,t)}}var yt=0,mt=2,gt=3;function vt(){this.next=this.f=this.b=this.g=this.a=null,this.c=!1}vt.prototype.reset=function(){this.f=this.b=this.g=this.a=null,this.c=!1};var bt=new I(function(){return new vt},function(t){t.reset()});function _t(t,e,n){var r=bt.get();return r.g=t,r.b=e,r.f=n,r}function wt(t){if(t instanceof dt)return t;var e=new dt(o);return Nt(e,mt,t),e}function Et(t){return new dt(function(e,n){n(t)})}function Tt(t,e,n){Dt(t,e,n,null)||ht(g(e,t))}function St(t){return new dt(function(e){var n=t.length,r=[];if(n)for(var i=function(t,i,o){n--,r[t]=i?{Db:!0,value:o}:{Db:!1,reason:o},0==n&&e(r)},o=0;o<t.length;o++)Tt(t[o],g(i,o,!0),g(i,o,!1));else e(r)})}function It(t,e){t.b||t.a!=mt&&t.a!=gt||At(t),t.f?t.f.next=e:t.b=e,t.f=e}function Ct(t,e,n,r){var i=_t(null,null,null);return i.a=new dt(function(t,o){i.g=e?function(n){try{var i=e.call(r,n);t(i)}catch(t){o(t)}}:t,i.b=n?function(e){try{var i=n.call(r,e);void 0===i&&e instanceof Lt?o(e):t(i)}catch(t){o(t)}}:o}),i.a.c=t,It(t,i),i.a}function Nt(t,e,n){t.a==yt&&(t===n&&(e=gt,n=new TypeError("Promise cannot resolve to itself")),t.a=1,Dt(n,t.Nc,t.Oc,t)||(t.i=n,t.a=e,t.c=null,At(t),e!=gt||n instanceof Lt||function(t,e){t.g=!0,ht(function(){t.g&&Pt.call(null,e)})}(t,n)))}function Dt(t,e,n,r){if(t instanceof dt)return It(t,_t(e||o,n||null,r)),!0;if(w(t))return t.then(e,n,r),!0;if(l(t))try{var i=t.then;if(h(i))return function(t,e,n,r,i){function o(t){s||(s=!0,r.call(i,t))}var s=!1;try{e.call(t,function(t){s||(s=!0,n.call(i,t))},o)}catch(t){o(t)}}(t,i,e,n,r),!0}catch(t){return n.call(r,t),!0}return!1}function At(t){t.h||(t.h=!0,ht(t.Yb,t))}function Rt(t){var e=null;return t.b&&(e=t.b,t.b=e.next,e.next=null),t.b||(t.f=null),e}function kt(t,e,n,r){if(n==gt&&e.b&&!e.c)for(;t&&t.g;t=t.c)t.g=!1;if(e.a)e.a.c=null,Ot(e,n,r);else try{e.c?e.g.call(e.f):Ot(e,n,r)}catch(t){Pt.call(null,t)}C(bt,e)}function Ot(t,e,n){e==mt?t.g.call(t.f,n):t.b&&t.b.call(t.f,n)}dt.prototype.then=function(t,e,n){return Ct(this,h(t)?t:null,h(e)?e:null,n)},_(dt),(t=dt.prototype).ia=function(t,e){return(t=_t(t,t,e)).c=!0,It(this,t),this},t.s=function(t,e){return Ct(this,null,t,e)},t.cancel=function(t){this.a==yt&&ht(function(){!function t(e,n){if(e.a==yt)if(e.c){var r=e.c;if(r.b){for(var i=0,o=null,s=null,a=r.b;a&&(a.c||(i++,a.a==e&&(o=a),!(o&&1<i)));a=a.next)o||(s=a);o&&(r.a==yt&&1==i?t(r,n):(s?((i=s).next==r.f&&(r.f=i),i.next=i.next.next):Rt(r),kt(r,o,gt,n)))}e.c=null}else Nt(e,gt,n)}(this,new Lt(t))},this)},t.Nc=function(t){this.a=yt,Nt(this,mt,t)},t.Oc=function(t){this.a=yt,Nt(this,gt,t)},t.Yb=function(){for(var t;t=Rt(this);)kt(this,t,this.a,this.i);this.h=!1};var Pt=ct;function Lt(t){E.call(this,t)}function Mt(){0!=xt&&(Ft[this[f]||(this[f]=++p)]=this),this.qa=this.qa,this.ja=this.ja}b(Lt,E),Lt.prototype.name="cancel";var xt=0,Ft={};function Ut(t){if(!t.qa&&(t.qa=!0,t.va(),0!=xt)){var e=t[f]||(t[f]=++p);if(0!=xt&&t.ja&&0<t.ja.length)throw Error(t+" did not empty its onDisposeCallbacks queue. This probably means it overrode dispose() or disposeInternal() without calling the superclass' method.");delete Ft[e]}}function qt(t){return qt[" "](t),t}Mt.prototype.qa=!1,Mt.prototype.va=function(){if(this.ja)for(;this.ja.length;)this.ja.shift()()},qt[" "]=o;var Bt,Vt,Wt=et("Opera"),jt=et("Trident")||et("MSIE"),Kt=et("Edge"),Qt=Kt||jt,Ht=et("Gecko")&&!(J(j.toLowerCase(),"webkit")&&!et("Edge"))&&!(et("Trident")||et("MSIE"))&&!et("Edge"),Gt=J(j.toLowerCase(),"webkit")&&!et("Edge");function zt(){var t=n.document;return t?t.documentMode:void 0}t:{var Yt="",Xt=(Vt=j,Ht?/rv:([^\);]+)(\)|;)/.exec(Vt):Kt?/Edge\/([\d\.]+)/.exec(Vt):jt?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(Vt):Gt?/WebKit\/(\S+)/.exec(Vt):Wt?/(?:Version)[ \/]?(\S+)/.exec(Vt):void 0);if(Xt&&(Yt=Xt?Xt[1]:""),jt){var Jt=zt();if(null!=Jt&&Jt>parseFloat(Yt)){Bt=String(Jt);break t}}Bt=Yt}var $t,Zt={};function te(t){return function(t,e){var n=Zt;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(t,function(){for(var e=0,n=V(String(Bt)).split("."),r=V(String(t)).split("."),i=Math.max(n.length,r.length),o=0;0==e&&o<i;o++){var s=n[o]||"",a=r[o]||"";do{if(s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],a=/(\d*)(\D*)(.*)/.exec(a)||["","","",""],0==s[0].length&&0==a[0].length)break;e=$(0==s[1].length?0:parseInt(s[1],10),0==a[1].length?0:parseInt(a[1],10))||$(0==s[2].length,0==a[2].length)||$(s[2],a[2]),s=s[3],a=a[3]}while(0==e)}return 0<=e})}var ee=n.document;$t=ee&&jt?zt()||("CSS1Compat"==ee.compatMode?parseInt(Bt,10):5):void 0;var ne=Object.freeze||function(t){return t},re=!jt||9<=Number($t),ie=jt&&!te("9"),oe=function(){if(!n.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});return n.addEventListener("test",o,e),n.removeEventListener("test",o,e),t}();function se(t,e){this.type=t,this.b=this.target=e,this.Kb=!0}function ae(t,e){if(se.call(this,t?t.type:""),this.relatedTarget=this.b=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.a=null,t){var n=this.type=t.type,i=t.changedTouches?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.b=e,e=t.relatedTarget){if(Ht){t:{try{qt(e.nodeName);var o=!0;break t}catch(t){}o=!1}o||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,null===i?(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0):(this.clientX=void 0!==i.clientX?i.clientX:i.pageX,this.clientY=void 0!==i.clientY?i.clientY:i.pageY,this.screenX=i.screenX||0,this.screenY=i.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType=r(t.pointerType)?t.pointerType:ue[t.pointerType]||"",this.a=t,t.defaultPrevented&&this.preventDefault()}}se.prototype.preventDefault=function(){this.Kb=!1},b(ae,se);var ue=ne({2:"touch",3:"pen",4:"mouse"});ae.prototype.preventDefault=function(){ae.ob.preventDefault.call(this);var t=this.a;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,ie)try{(t.ctrlKey||112<=t.keyCode&&123>=t.keyCode)&&(t.keyCode=-1)}catch(t){}},ae.prototype.f=function(){return this.a};var ce="closure_listenable_"+(1e6*Math.random()|0),he=0;function le(t){t.oa=!0,t.listener=null,t.proxy=null,t.src=null,t.La=null}function fe(t){this.src=t,this.a={},this.b=0}function pe(t,e){var n=e.type;n in t.a&&x(t.a[n],e)&&(le(e),0==t.a[n].length&&(delete t.a[n],t.b--))}function de(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i];if(!o.oa&&o.listener==e&&o.capture==!!n&&o.La==r)return i}return-1}fe.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var s=de(t,e,r,i);return-1<s?(e=t[s],n||(e.Ia=!1)):((e=new function(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.La=i,this.key=++he,this.oa=this.Ia=!1}(e,this.src,o,!!r,i)).Ia=n,t.push(e)),e};var ye="closure_lm_"+(1e6*Math.random()|0),me={};function ge(t,e,n,r,i){if(r&&r.once)be(t,e,n,r,i);else if(u(e))for(var o=0;o<e.length;o++)ge(t,e[o],n,r,i);else n=De(n),t&&t[ce]?Re(t,e,n,l(r)?!!r.capture:!!r,i):ve(t,e,n,!1,r,i)}function ve(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var s=l(i)?!!i.capture:!!i,a=Ce(t);if(a||(t[ye]=a=new fe(t)),!(n=a.add(e,n,r,s,o)).proxy)if(r=function(){var t=Ie,e=re?function(n){return t.call(e.src,e.listener,n)}:function(n){if(!(n=t.call(e.src,e.listener,n)))return n};return e}(),n.proxy=r,r.src=t,r.listener=n,t.addEventListener)oe||(i=s),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(Ee(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}}function be(t,e,n,r,i){if(u(e))for(var o=0;o<e.length;o++)be(t,e[o],n,r,i);else n=De(n),t&&t[ce]?ke(t,e,n,l(r)?!!r.capture:!!r,i):ve(t,e,n,!0,r,i)}function _e(t,e,n,r,i){if(u(e))for(var o=0;o<e.length;o++)_e(t,e[o],n,r,i);else r=l(r)?!!r.capture:!!r,n=De(n),t&&t[ce]?(t=t.l,(e=String(e).toString())in t.a&&(-1<(n=de(o=t.a[e],n,r,i))&&(le(o[n]),Array.prototype.splice.call(o,n,1),0==o.length&&(delete t.a[e],t.b--)))):t&&(t=Ce(t))&&(e=t.a[e.toString()],t=-1,e&&(t=de(e,n,r,i)),(n=-1<t?e[t]:null)&&we(n))}function we(t){if("number"!=typeof t&&t&&!t.oa){var e=t.src;if(e&&e[ce])pe(e.l,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(Ee(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=Ce(e))?(pe(n,t),0==n.b&&(n.src=null,e[ye]=null)):le(t)}}}function Ee(t){return t in me?me[t]:me[t]="on"+t}function Te(t,e,n,r){var i=!0;if((t=Ce(t))&&(e=t.a[e.toString()]))for(e=e.concat(),t=0;t<e.length;t++){var o=e[t];o&&o.capture==n&&!o.oa&&(o=Se(o,r),i=i&&!1!==o)}return i}function Se(t,e){var n=t.listener,r=t.La||t.src;return t.Ia&&we(t),n.call(r,e)}function Ie(t,e){if(t.oa)return!0;if(!re){if(!e)t:{e=["window","event"];for(var r=n,i=0;i<e.length;i++)if(null==(r=r[e[i]])){e=null;break t}e=r}if(e=new ae(i=e,this),r=!0,!(0>i.keyCode||void 0!=i.returnValue)){t:{var o=!1;if(0==i.keyCode)try{i.keyCode=-1;break t}catch(t){o=!0}(o||void 0==i.returnValue)&&(i.returnValue=!0)}for(i=[],o=e.b;o;o=o.parentNode)i.push(o);for(t=t.type,o=i.length-1;0<=o;o--){e.b=i[o];var s=Te(i[o],t,!0,e);r=r&&s}for(o=0;o<i.length;o++)e.b=i[o],s=Te(i[o],t,!1,e),r=r&&s}return r}return Se(t,new ae(e,this))}function Ce(t){return(t=t[ye])instanceof fe?t:null}var Ne="__closure_events_fn_"+(1e9*Math.random()>>>0);function De(t){return h(t)?t:(t[Ne]||(t[Ne]=function(e){return t.handleEvent(e)}),t[Ne])}function Ae(){Mt.call(this),this.l=new fe(this),this.Rb=this,this.Va=null}function Re(t,e,n,r,i){t.l.add(String(e),n,!1,r,i)}function ke(t,e,n,r,i){t.l.add(String(e),n,!0,r,i)}function Oe(t,e,n,r){if(!(e=t.l.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;o<e.length;++o){var s=e[o];if(s&&!s.oa&&s.capture==n){var a=s.listener,u=s.La||s.src;s.Ia&&pe(t.l,s),i=!1!==a.call(u,r)&&i}}return i&&0!=r.Kb}function Pe(t,e,r){if(h(t))r&&(t=m(t,r));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=m(t.handleEvent,t)}return 2147483647<Number(e)?-1:n.setTimeout(t,e||0)}function Le(t){var e=null;return new dt(function(n,r){-1==(e=Pe(function(){n(void 0)},t))&&r(Error("Failed to schedule timer."))}).s(function(t){throw n.clearTimeout(e),t})}function Me(t){if(t.S&&"function"==typeof t.S)return t.S();if(r(t))return t.split("");if(c(t)){for(var e=[],n=t.length,i=0;i<n;i++)e.push(t[i]);return e}for(i in e=[],n=0,t)e[n++]=t[i];return e}function xe(t){if(t.U&&"function"==typeof t.U)return t.U();if(!t.S||"function"!=typeof t.S){if(c(t)||r(t)){var e=[];t=t.length;for(var n=0;n<t;n++)e.push(n);return e}for(var i in e=[],n=0,t)e[n++]=i;return e}}function Fe(t,e){this.b={},this.a=[],this.c=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(t)if(t instanceof Fe)for(n=t.U(),r=0;r<n.length;r++)this.set(n[r],t.get(n[r]));else for(r in t)this.set(r,t[r])}function Ue(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];qe(t.b,r)&&(t.a[n++]=r),e++}t.a.length=n}if(t.c!=t.a.length){var i={};for(n=e=0;e<t.a.length;)qe(i,r=t.a[e])||(t.a[n++]=r,i[r]=1),e++;t.a.length=n}}function qe(t,e){return Object.prototype.hasOwnProperty.call(t,e)}b(Ae,Mt),Ae.prototype[ce]=!0,Ae.prototype.addEventListener=function(t,e,n,r){ge(this,t,e,n,r)},Ae.prototype.removeEventListener=function(t,e,n,r){_e(this,t,e,n,r)},Ae.prototype.dispatchEvent=function(t){var e,n=this.Va;if(n)for(e=[];n;n=n.Va)e.push(n);n=this.Rb;var i=t.type||t;if(r(t))t=new se(t,n);else if(t instanceof se)t.target=t.target||n;else{var o=t;ut(t=new se(i,n),o)}if(o=!0,e)for(var s=e.length-1;0<=s;s--){var a=t.b=e[s];o=Oe(a,i,!0,t)&&o}if(o=Oe(a=t.b=n,i,!0,t)&&o,o=Oe(a,i,!1,t)&&o,e)for(s=0;s<e.length;s++)o=Oe(a=t.b=e[s],i,!1,t)&&o;return o},Ae.prototype.va=function(){if(Ae.ob.va.call(this),this.l){var t,e=this.l;for(t in e.a){for(var n=e.a[t],r=0;r<n.length;r++)le(n[r]);delete e.a[t],e.b--}}this.Va=null},(t=Fe.prototype).S=function(){Ue(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},t.U=function(){return Ue(this),this.a.concat()},t.clear=function(){this.b={},this.c=this.a.length=0},t.get=function(t,e){return qe(this.b,t)?this.b[t]:e},t.set=function(t,e){qe(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},t.forEach=function(t,e){for(var n=this.U(),r=0;r<n.length;r++){var i=n[r],o=this.get(i);t.call(e,o,i,this)}};var Be=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Ve(t,e){if(this.b=this.l=this.c="",this.i=null,this.h=this.g="",this.f=!1,t instanceof Ve){this.f=void 0!==e?e:t.f,We(this,t.c),this.l=t.l,this.b=t.b,je(this,t.i),this.g=t.g,e=t.a;var n=new rn;n.c=e.c,e.a&&(n.a=new Fe(e.a),n.b=e.b),Ke(this,n),this.h=t.h}else t&&(n=String(t).match(Be))?(this.f=!!e,We(this,n[1]||"",!0),this.l=Ye(n[2]||""),this.b=Ye(n[3]||"",!0),je(this,n[4]),this.g=Ye(n[5]||"",!0),Ke(this,n[6]||"",!0),this.h=Ye(n[7]||"")):(this.f=!!e,this.a=new rn(null,this.f))}function We(t,e,n){t.c=n?Ye(e,!0):e,t.c&&(t.c=t.c.replace(/:$/,""))}function je(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.i=e}else t.i=null}function Ke(t,e,n){e instanceof rn?(t.a=e,function(t,e){e&&!t.f&&(on(t),t.c=null,t.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(an(this,e),cn(this,n,t))},t)),t.f=e}(t.a,t.f)):(n||(e=Xe(e,en)),t.a=new rn(e,t.f))}function Qe(t,e,n){t.a.set(e,n)}function He(t,e){return t.a.get(e)}function Ge(t){return t instanceof Ve?new Ve(t):new Ve(t,void 0)}function ze(t,e){var n=new Ve(null,void 0);return We(n,"https"),t&&(n.b=t),e&&(n.g=e),n}function Ye(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Xe(t,e,n){return r(t)?(t=encodeURI(t).replace(e,Je),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function Je(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}Ve.prototype.toString=function(){var t=[],e=this.c;e&&t.push(Xe(e,$e,!0),":");var n=this.b;return(n||"file"==e)&&(t.push("//"),(e=this.l)&&t.push(Xe(e,$e,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.i)&&t.push(":",String(n))),(n=this.g)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(Xe(n,"/"==n.charAt(0)?tn:Ze,!0))),(n=this.a.toString())&&t.push("?",n),(n=this.h)&&t.push("#",Xe(n,nn)),t.join("")};var $e=/[#\/\?@]/g,Ze=/[#\?:]/g,tn=/[#\?]/g,en=/[#\?@]/g,nn=/#/g;function rn(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function on(t){t.a||(t.a=new Fe,t.b=0,t.c&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var o=t[n].substring(0,r);i=t[n].substring(r+1)}else o=t[n];e(o,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(t.c,function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)}))}function sn(t){var e=xe(t);if(void 0===e)throw Error("Keys are undefined");var n=new rn(null,void 0);t=Me(t);for(var r=0;r<e.length;r++){var i=e[r],o=t[r];u(o)?cn(n,i,o):n.add(i,o)}return n}function an(t,e){on(t),e=hn(t,e),qe(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,qe((t=t.a).b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&Ue(t)))}function un(t,e){return on(t),e=hn(t,e),qe(t.a.b,e)}function cn(t,e,n){an(t,e),0<n.length&&(t.c=null,t.a.set(hn(t,e),q(n)),t.b+=n.length)}function hn(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}(t=rn.prototype).add=function(t,e){on(this),this.c=null,t=hn(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},t.clear=function(){this.a=this.c=null,this.b=0},t.forEach=function(t,e){on(this),this.a.forEach(function(n,r){O(n,function(n){t.call(e,n,r,this)},this)},this)},t.U=function(){on(this);for(var t=this.a.S(),e=this.a.U(),n=[],r=0;r<e.length;r++)for(var i=t[r],o=0;o<i.length;o++)n.push(e[r]);return n},t.S=function(t){on(this);var e=[];if(r(t))un(this,t)&&(e=U(e,this.a.get(hn(this,t))));else{t=this.a.S();for(var n=0;n<t.length;n++)e=U(e,t[n])}return e},t.set=function(t,e){return on(this),this.c=null,un(this,t=hn(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},t.get=function(t,e){return 0<(t=t?this.S(t):[]).length?String(t[0]):e},t.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var t=[],e=this.a.U(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.S(r);for(var o=0;o<r.length;o++){var s=i;""!==r[o]&&(s+="="+encodeURIComponent(String(r[o]))),t.push(s)}}return this.c=t.join("&")};var ln=!jt||9<=Number($t);function fn(){this.a="",this.b=dn}function pn(t){return t instanceof fn&&t.constructor===fn&&t.b===dn?t.a:(S("expected object of type Const, got '"+t+"'"),"type_error:Const")}fn.prototype.na=!0,fn.prototype.ma=function(){return this.a},fn.prototype.toString=function(){return"Const{"+this.a+"}"};var dn={};function yn(t){var e=new fn;return e.a=t,e}function mn(){this.a="",this.b=wn}function gn(t){return t instanceof mn&&t.constructor===mn&&t.b===wn?t.a:(S("expected object of type TrustedResourceUrl, got '"+t+"' of type "+s(t)),"type_error:TrustedResourceUrl")}function vn(t,e){var n=pn(t);if(!_n.test(n))throw Error("Invalid TrustedResourceUrl format: "+n);return function(t){var e=new mn;return e.a=t,e}(t=n.replace(bn,function(t,r){if(!Object.prototype.hasOwnProperty.call(e,r))throw Error('Found marker, "'+r+'", in format string, "'+n+'", but no valid label mapping found in args: '+JSON.stringify(e));return(t=e[r])instanceof fn?pn(t):encodeURIComponent(String(t))}))}yn(""),mn.prototype.na=!0,mn.prototype.ma=function(){return this.a},mn.prototype.toString=function(){return"TrustedResourceUrl{"+this.a+"}"};var bn=/%{(\w+)}/g,_n=/^(?:https:)?\/\/[0-9a-z.:[\]-]+\/|^\/[^\/\\]|^about:blank#/i,wn={};function En(){this.a="",this.b=Cn}function Tn(t){return t instanceof En&&t.constructor===En&&t.b===Cn?t.a:(S("expected object of type SafeUrl, got '"+t+"' of type "+s(t)),"type_error:SafeUrl")}En.prototype.na=!0,En.prototype.ma=function(){return this.a},En.prototype.toString=function(){return"SafeUrl{"+this.a+"}"};var Sn=/^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i;function In(t){return t instanceof En?t:(t=t.na?t.ma():String(t),Sn.test(t)||(t="about:invalid#zClosurez"),Nn(t))}var Cn={};function Nn(t){var e=new En;return e.a=t,e}function Dn(){this.a="",this.b=An}Nn("about:blank"),Dn.prototype.na=!0,Dn.prototype.ma=function(){return this.a},Dn.prototype.toString=function(){return"SafeHtml{"+this.a+"}"};var An={};function Rn(t){var e=new Dn;return e.a=t,e}function kn(t){var e=document;return r(t)?e.getElementById(t):t}function On(t,e){nt(e,function(e,n){e&&e.na&&(e=e.ma()),"style"==n?t.style.cssText=e:"class"==n?t.className=e:"for"==n?t.htmlFor=e:Pn.hasOwnProperty(n)?t.setAttribute(Pn[n],e):0==n.lastIndexOf("aria-",0)||0==n.lastIndexOf("data-",0)?t.setAttribute(n,e):t[n]=e})}Rn("<!DOCTYPE html>"),Rn(""),Rn("<br>");var Pn={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",nonce:"nonce",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"};function Ln(t,e,n){var i=arguments,o=document,s=String(i[0]),a=i[1];if(!ln&&a&&(a.name||a.type)){if(s=["<",s],a.name&&s.push(' name="',W(a.name),'"'),a.type){s.push(' type="',W(a.type),'"');var h={};ut(h,a),delete h.type,a=h}s.push(">"),s=s.join("")}return s=o.createElement(s),a&&(r(a)?s.className=a:u(a)?s.className=a.join(" "):On(s,a)),2<i.length&&function(t,e,n){function i(n){n&&e.appendChild(r(n)?t.createTextNode(n):n)}for(var o=2;o<n.length;o++){var s=n[o];!c(s)||l(s)&&0<s.nodeType?i(s):O(Mn(s)?q(s):s,i)}}(o,s,i),s}function Mn(t){if(t&&"number"==typeof t.length){if(l(t))return"function"==typeof t.item||"string"==typeof t.item;if(h(t))return"function"==typeof t.item}return!1}function xn(t){var e=[];return function t(e,n,r){if(null==n)r.push("null");else{if("object"==typeof n){if(u(n)){var i=n;n=i.length,r.push("[");for(var o="",s=0;s<n;s++)r.push(o),t(e,i[s],r),o=",";return void r.push("]")}if(!(n instanceof String||n instanceof Number||n instanceof Boolean)){for(i in r.push("{"),o="",n)Object.prototype.hasOwnProperty.call(n,i)&&("function"!=typeof(s=n[i])&&(r.push(o),qn(i,r),r.push(":"),t(e,s,r),o=","));return void r.push("}")}n=n.valueOf()}switch(typeof n){case"string":qn(n,r);break;case"number":r.push(isFinite(n)&&!isNaN(n)?String(n):"null");break;case"boolean":r.push(String(n));break;case"function":r.push("null");break;default:throw Error("Unknown type: "+typeof n)}}}(new function(){},t,e),e.join("")}var Fn={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\u000b"},Un=/\uffff/.test("￿")?/[\\"\x00-\x1f\x7f-\uffff]/g:/[\\"\x00-\x1f\x7f-\xff]/g;function qn(t,e){e.push('"',t.replace(Un,function(t){var e=Fn[t];return e||(e="\\u"+(65536|t.charCodeAt(0)).toString(16).substr(1),Fn[t]=e),e}),'"')}function Bn(){var t=sr();return jt&&!!$t&&11==$t||/Edge\/\d+/.test(t)}function Vn(){return n.window&&n.window.location.href||self&&self.location&&self.location.href||""}function Wn(t,e){e=e||n.window;var r="about:blank";t&&(r=Tn(In(t))),e.location.href=r}function jn(t){return!!((t=(t||sr()).toLowerCase()).match(/android/)||t.match(/webos/)||t.match(/iphone|ipad|ipod/)||t.match(/blackberry/)||t.match(/windows phone/)||t.match(/iemobile/))}function Kn(t){t=t||n.window;try{t.close()}catch(t){}}function Qn(t,e,n){var r=Math.floor(1e9*Math.random()).toString();e=e||500,n=n||600;var i=(window.screen.availHeight-n)/2,o=(window.screen.availWidth-e)/2;for(a in e={width:e,height:n,top:0<i?i:0,left:0<o?o:0,location:!0,resizable:!0,statusbar:!0,toolbar:!1},n=sr().toLowerCase(),r&&(e.target=r,J(n,"crios/")&&(e.target="_blank")),rr(sr())==er&&(t=t||"http://localhost",e.scrollbars=!0),n=t||"",(t=e)||(t={}),r=window,e=n instanceof En?n:In(void 0!==n.href?n.href:String(n)),n=t.target||n.target,i=[],t)switch(a){case"width":case"height":case"top":case"left":i.push(a+"="+t[a]);break;case"target":case"noopener":case"noreferrer":break;default:i.push(a+"="+(t[a]?1:0))}var a=i.join(",");if((et("iPhone")&&!et("iPod")&&!et("iPad")||et("iPad")||et("iPod"))&&r.navigator&&r.navigator.standalone&&n&&"_self"!=n?(a=r.document.createElement("A"),e instanceof En||e instanceof En||(e=e.na?e.ma():String(e),Sn.test(e)||(e="about:invalid#zClosurez"),e=Nn(e)),a.href=Tn(e),a.setAttribute("target",n),t.noreferrer&&a.setAttribute("rel","noreferrer"),(t=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,r,1),a.dispatchEvent(t),a={}):t.noreferrer?(a=r.open("",n,a),t=Tn(e),a&&(Qt&&J(t,";")&&(t="'"+t.replace(/'/g,"%27")+"'"),a.opener=null,yn("b/12014412, meta tag with sanitized URL"),t=Rn(t='<meta name="referrer" content="no-referrer"><meta http-equiv="refresh" content="0; url='+W(t)+'">'),a.document.write(function(t){return t instanceof Dn&&t.constructor===Dn&&t.b===An?t.a:(S("expected object of type SafeHtml, got '"+t+"' of type "+s(t)),"type_error:SafeHtml")}(t)),a.document.close())):(a=r.open(Tn(e),n,a))&&t.noopener&&(a.opener=null),a)try{a.focus()}catch(t){}return a}var Hn=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Gn=/^[^@]+@[^@]+$/;function zn(){var t=null;return new dt(function(e){"complete"==n.document.readyState?e():(t=function(){e()},be(window,"load",t))}).s(function(e){throw _e(window,"load",t),e})}function Xn(t){return t=t||sr(),!("file:"!==lr()||!t.toLowerCase().match(/iphone|ipad|ipod|android/))}function Jn(){var t=n.window;try{return!(!t||t==t.top)}catch(t){return!1}}function $n(){return"object"!=typeof n.window&&"function"==typeof n.importScripts}function Zn(){return Yn.INTERNAL.hasOwnProperty("reactNative")?"ReactNative":Yn.INTERNAL.hasOwnProperty("node")?"Node":$n()?"Worker":"Browser"}function tr(){var t=Zn();return"ReactNative"===t||"Node"===t}var er="Firefox",nr="Chrome";function rr(t){var e=t.toLowerCase();return J(e,"opera/")||J(e,"opr/")||J(e,"opios/")?"Opera":J(e,"iemobile")?"IEMobile":J(e,"msie")||J(e,"trident/")?"IE":J(e,"edge/")?"Edge":J(e,"firefox/")?er:J(e,"silk/")?"Silk":J(e,"blackberry")?"Blackberry":J(e,"webos")?"Webos":!J(e,"safari/")||J(e,"chrome/")||J(e,"crios/")||J(e,"android")?!J(e,"chrome/")&&!J(e,"crios/")||J(e,"edge/")?J(e,"android")?"Android":(t=t.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))&&2==t.length?t[1]:"Other":nr:"Safari"}var ir={Uc:"FirebaseCore-web",Wc:"FirebaseUI-web"};function or(t,e){e=e||[];var n,r=[],i={};for(n in ir)i[ir[n]]=!0;for(n=0;n<e.length;n++)void 0!==i[e[n]]&&(delete i[e[n]],r.push(e[n]));return r.sort(),(e=r).length||(e=["FirebaseCore-web"]),"Browser"===(r=Zn())?r=rr(i=sr()):"Worker"===r&&(r=rr(i=sr())+"-"+r),r+"/JsCore/"+t+"/"+e.join(",")}function sr(){return n.navigator&&n.navigator.userAgent||""}function ar(t,e){t=t.split("."),e=e||n;for(var r=0;r<t.length&&"object"==typeof e&&null!=e;r++)e=e[t[r]];return r!=t.length&&(e=void 0),e}function ur(){try{var t=n.localStorage,e=mr();if(t)return t.setItem(e,"1"),t.removeItem(e),!Bn()||!!n.indexedDB}catch(t){return $n()&&!!n.indexedDB}return!1}function cr(){return(hr()||"chrome-extension:"===lr()||Xn())&&!tr()&&ur()&&!$n()}function hr(){return"http:"===lr()||"https:"===lr()}function lr(){return n.location&&n.location.protocol||null}function fr(t){return!jn(t=t||sr())&&rr(t)!=er}function pr(t){return void 0===t?null:xn(t)}function dr(t){var e,n={};for(e in t)t.hasOwnProperty(e)&&null!==t[e]&&void 0!==t[e]&&(n[e]=t[e]);return n}function yr(t){if(null!==t)return JSON.parse(t)}function mr(t){return t||Math.floor(1e9*Math.random()).toString()}function gr(t){return"Safari"!=rr(t=t||sr())&&!t.toLowerCase().match(/iphone|ipad|ipod/)}function vr(){var t=n.___jsl;if(t&&t.H)for(var e in t.H)if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=t.H[e].L.concat(),t.CP)for(var r=0;r<t.CP.length;r++)t.CP[r]=null}function br(t,e){if(t>e)throw Error("Short delay should be less than long delay!");this.a=t,this.c=e,t=sr(),e=Zn(),this.b=jn(t)||"ReactNative"===e}function _r(){var t=n.document;return!t||void 0===t.visibilityState||"visible"==t.visibilityState}function wr(t){try{var e=new Date(parseInt(t,10));if(!isNaN(e.getTime())&&!/[^0-9]/.test(t))return e.toUTCString()}catch(t){}return null}function Er(){return!(!ar("fireauth.oauthhelper",n)&&!ar("fireauth.iframe",n))}br.prototype.get=function(){var t=n.navigator;return!t||"boolean"!=typeof t.onLine||!hr()&&"chrome-extension:"!==lr()&&void 0===t.connection||t.onLine?this.b?this.c:this.a:Math.min(5e3,this.a)};var Tr,Sr={};function Ir(t){Sr[t]||(Sr[t]=!0,"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(t))}try{var Cr={};Object.defineProperty(Cr,"abcd",{configurable:!0,enumerable:!0,value:1}),Object.defineProperty(Cr,"abcd",{configurable:!0,enumerable:!0,value:2}),Tr=2==Cr.abcd}catch(Vt){Tr=!1}function Nr(t,e,n){Tr?Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:n}):t[e]=n}function Dr(t,e){if(e)for(var n in e)e.hasOwnProperty(n)&&Nr(t,n,e[n])}function Ar(t){var e={};return Dr(e,t),e}function Rr(t){var e=t;if("object"==typeof t&&null!=t)for(var n in e="length"in t?[]:{},t)Nr(e,n,Rr(t[n]));return e}var kr="EMAIL_SIGNIN",Or="email",Pr="newEmail",Lr="requestType",Mr="email",xr="fromEmail",Fr="data",Ur="operation";function qr(t,e){this.code=Vr+t,this.message=e||Wr[t]||""}function Br(t){var e=t&&t.code;return e?new qr(e.substring(Vr.length),t.message):null}b(qr,Error),qr.prototype.C=function(){return{code:this.code,message:this.message}},qr.prototype.toJSON=function(){return this.C()};var Vr="auth/",Wr={"argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-already-in-use":"The email address is already in use by another account.","expired-action-code":"The action code has expired. ","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal error has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registed for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal error has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is malformed or has expired.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal error has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The OIDC ID token requires a valid unhashed nonce.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network error (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal error has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted.  Please whitelist the domain in the Firebase console.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","user-cancelled":"User did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled."};function jr(t){var e=t[zr];if(void 0===e)throw new qr("missing-continue-uri");if("string"!=typeof e||"string"==typeof e&&!e.length)throw new qr("invalid-continue-uri");this.h=e,this.b=this.a=null,this.g=!1;var n=t[Kr];if(n&&"object"==typeof n){e=n[Jr];var r=n[Yr];if(n=n[Xr],"string"==typeof e&&e.length){if(this.a=e,void 0!==r&&"boolean"!=typeof r)throw new qr("argument-error",Yr+" property must be a boolean when specified.");if(this.g=!!r,void 0!==n&&("string"!=typeof n||"string"==typeof n&&!n.length))throw new qr("argument-error",Xr+" property must be a non empty string when specified.");this.b=n||null}else{if(void 0!==e)throw new qr("argument-error",Jr+" property must be a non empty string when specified.");if(void 0!==r||void 0!==n)throw new qr("missing-android-pkg-name")}}else if(void 0!==n)throw new qr("argument-error",Kr+" property must be a non null object when specified.");if(this.f=null,(e=t[Gr])&&"object"==typeof e){if("string"==typeof(e=e[$r])&&e.length)this.f=e;else if(void 0!==e)throw new qr("argument-error",$r+" property must be a non empty string when specified.")}else if(void 0!==e)throw new qr("argument-error",Gr+" property must be a non null object when specified.");if(void 0!==(e=t[Hr])&&"boolean"!=typeof e)throw new qr("argument-error",Hr+" property must be a boolean when specified.");if(this.c=!!e,void 0!==(t=t[Qr])&&("string"!=typeof t||"string"==typeof t&&!t.length))throw new qr("argument-error",Qr+" property must be a non empty string when specified.");this.i=t||null}var Kr="android",Qr="dynamicLinkDomain",Hr="handleCodeInApp",Gr="iOS",zr="url",Yr="installApp",Xr="minimumVersion",Jr="packageName",$r="bundleId";function Zr(t){var e={};for(var n in e.continueUrl=t.h,e.canHandleCodeInApp=t.c,(e.androidPackageName=t.a)&&(e.androidMinimumVersion=t.b,e.androidInstallApp=t.g),e.iOSBundleId=t.f,e.dynamicLinkDomain=t.i,e)null===e[n]&&delete e[n];return e}var ti=null,ei=null;function ni(t){var e="";return function(t,e){function n(e){for(;r<t.length;){var n=t.charAt(r++),i=ei[n];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return e}!function(){if(!ti){ti={},ei={};for(var t=0;65>t;t++)ti[t]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(t),ei[ti[t]]=t,62<=t&&(ei["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(t)]=t)}}();for(var r=0;;){var i=n(-1),o=n(0),s=n(64),a=n(64);if(64===a&&-1===i)break;e(i<<2|o>>4),64!=s&&(e(o<<4&240|s>>2),64!=a&&e(s<<6&192|a))}}(t,function(t){e+=String.fromCharCode(t)}),e}function ri(t){this.c=t.sub,this.a=t.provider_id||t.firebase&&t.firebase.sign_in_provider||null,this.b=!!t.is_anonymous||"anonymous"==this.a}function ii(t){return(t=oi(t))&&t.sub&&t.iss&&t.aud&&t.exp?new ri(t):null}function oi(t){if(!t)return null;if(3!=(t=t.split(".")).length)return null;for(var e=(4-(t=t[1]).length%4)%4,n=0;n<e;n++)t+=".";try{return JSON.parse(ni(t))}catch(t){}return null}ri.prototype.f=function(){return this.b};var si,ai={$c:{ab:"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",ib:"https://securetoken.googleapis.com/v1/token",id:"p"},bd:{ab:"https://staging-www.sandbox.googleapis.com/identitytoolkit/v3/relyingparty/",ib:"https://staging-securetoken.sandbox.googleapis.com/v1/token",id:"s"},cd:{ab:"https://www-googleapis-test.sandbox.google.com/identitytoolkit/v3/relyingparty/",ib:"https://test-securetoken.sandbox.googleapis.com/v1/token",id:"t"}};function ui(t){for(var e in ai)if(ai[e].id===t)return{firebaseEndpoint:(t=ai[e]).ab,secureTokenEndpoint:t.ib};return null}si=ui("__EID__")?"__EID__":void 0;var ci="oauth_consumer_key oauth_nonce oauth_signature oauth_signature_method oauth_timestamp oauth_token oauth_version".split(" "),hi=["client_id","response_type","scope","redirect_uri","state"],li={Vc:{Ma:"locale",Ba:500,Aa:600,Na:"facebook.com",hb:hi},Xc:{Ma:null,Ba:500,Aa:620,Na:"github.com",hb:hi},Yc:{Ma:"hl",Ba:515,Aa:680,Na:"google.com",hb:hi},dd:{Ma:"lang",Ba:485,Aa:705,Na:"twitter.com",hb:ci}};function fi(t){for(var e in li)if(li[e].Na==t)return li[e];return null}function pi(t){var e={};e["facebook.com"]=vi,e["google.com"]=_i,e["github.com"]=bi,e["twitter.com"]=wi;var n=t&&t[yi];try{if(n)return e[n]?new e[n](t):new gi(t);if(void 0!==t[di])return new mi(t)}catch(t){}return null}var di="idToken",yi="providerId";function mi(t){var e=t[yi];if(!e&&t[di]){var n=ii(t[di]);n&&n.a&&(e=n.a)}if(!e)throw Error("Invalid additional user info!");"anonymous"!=e&&"custom"!=e||(e=null),n=!1,void 0!==t.isNewUser?n=!!t.isNewUser:"identitytoolkit#SignupNewUserResponse"===t.kind&&(n=!0),Nr(this,"providerId",e),Nr(this,"isNewUser",n)}function gi(t){mi.call(this,t),Nr(this,"profile",Rr((t=yr(t.rawUserInfo||"{}"))||{}))}function vi(t){if(gi.call(this,t),"facebook.com"!=this.providerId)throw Error("Invalid provider ID!")}function bi(t){if(gi.call(this,t),"github.com"!=this.providerId)throw Error("Invalid provider ID!");Nr(this,"username",this.profile&&this.profile.login||null)}function _i(t){if(gi.call(this,t),"google.com"!=this.providerId)throw Error("Invalid provider ID!")}function wi(t){if(gi.call(this,t),"twitter.com"!=this.providerId)throw Error("Invalid provider ID!");Nr(this,"username",t.screenName||null)}function Ei(t){var e=Ge(t),n=He(e,"link"),r=He(Ge(n),"link");return He(Ge(e=He(e,"deep_link_id")),"link")||e||r||n||t}function Ti(t,e){return t.then(function(t){if(t[os]){var n=ii(t[os]);if(!n||e!=n.c)throw new qr("user-mismatch");return t}throw new qr("user-mismatch")}).s(function(t){throw t&&t.code&&t.code==Vr+"user-not-found"?new qr("user-mismatch"):t})}function Si(t,e){if(!e)throw new qr("internal-error","failed to construct a credential");this.a=e,Nr(this,"providerId",t),Nr(this,"signInMethod",t)}function Ii(t){return{pendingToken:t.a,requestUri:"http://localhost"}}function Ci(t,e,n){if(this.a=null,e.idToken||e.accessToken)e.idToken&&Nr(this,"idToken",e.idToken),e.accessToken&&Nr(this,"accessToken",e.accessToken),e.nonce&&!e.pendingToken&&Nr(this,"nonce",e.nonce),e.pendingToken&&(this.a=e.pendingToken);else{if(!e.oauthToken||!e.oauthTokenSecret)throw new qr("internal-error","failed to construct a credential");Nr(this,"accessToken",e.oauthToken),Nr(this,"secret",e.oauthTokenSecret)}Nr(this,"providerId",t),Nr(this,"signInMethod",n)}function Ni(t){var e={};return t.idToken&&(e.id_token=t.idToken),t.accessToken&&(e.access_token=t.accessToken),t.secret&&(e.oauth_token_secret=t.secret),e.providerId=t.providerId,t.nonce&&!t.a&&(e.nonce=t.nonce),e={postBody:sn(e).toString(),requestUri:"http://localhost"},t.a&&(delete e.postBody,e.pendingToken=t.a),e}function Di(t,e){this.Dc=e||[],Dr(this,{providerId:t,isOAuthProvider:!0}),this.yb={},this.cb=(fi(t)||{}).Ma||null,this.$a=null}function Ai(t){if("string"!=typeof t||0!=t.indexOf("saml."))throw new qr("argument-error",'SAML provider IDs must be prefixed with "saml."');Di.call(this,t,[])}function Ri(t){Di.call(this,t,hi),this.a=[]}function ki(){Ri.call(this,"facebook.com")}function Oi(t){if(!t)throw new qr("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return l(t)&&(e=t.accessToken),(new ki).credential(null,e)}function Pi(){Ri.call(this,"github.com")}function Li(t){if(!t)throw new qr("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return l(t)&&(e=t.accessToken),(new Pi).credential(null,e)}function Mi(){Ri.call(this,"google.com"),this.ua("profile")}function xi(t,e){var n=t;return l(t)&&(n=t.idToken,e=t.accessToken),(new Mi).credential(n,e)}function Fi(){Di.call(this,"twitter.com",ci)}function Ui(t,e){var n=t;if(l(n)||(n={oauthToken:t,oauthTokenSecret:e}),!n.oauthToken||!n.oauthTokenSecret)throw new qr("argument-error","credential failed: expected 2 arguments (the OAuth access token and secret).");return new Ci("twitter.com",n,"twitter.com")}function qi(t,e,n){this.a=t,this.c=e,Nr(this,"providerId","password"),Nr(this,"signInMethod",n===Bi.EMAIL_LINK_SIGN_IN_METHOD?Bi.EMAIL_LINK_SIGN_IN_METHOD:Bi.EMAIL_PASSWORD_SIGN_IN_METHOD)}function Bi(){Dr(this,{providerId:"password",isOAuthProvider:!1})}function Vi(t,e){if(!(e=Wi(e)))throw new qr("argument-error","Invalid email link!");return new qi(t,e,Bi.EMAIL_LINK_SIGN_IN_METHOD)}function Wi(t){var e=He((t=new function(t){this.a=Ge(t)}(t=Ei(t))).a,"oobCode")||null;return"signIn"===(He(t.a,"mode")||null)&&e?e:null}function ji(t){if(!(t.Ta&&t.Sa||t.Fa&&t.$))throw new qr("internal-error");this.a=t,Nr(this,"providerId","phone"),Nr(this,"signInMethod","phone")}function Ki(t){return t.a.Fa&&t.a.$?{temporaryProof:t.a.Fa,phoneNumber:t.a.$}:{sessionInfo:t.a.Ta,code:t.a.Sa}}function Qi(t){try{this.a=t||Yn.auth()}catch(t){throw new qr("argument-error","Either an instance of firebase.auth.Auth must be passed as an argument to the firebase.auth.PhoneAuthProvider constructor, or the default firebase App instance must be initialized via firebase.initializeApp().")}Dr(this,{providerId:"phone",isOAuthProvider:!1})}function Hi(t,e){if(!t)throw new qr("missing-verification-id");if(!e)throw new qr("missing-verification-code");return new ji({Ta:t,Sa:e})}function Gi(t){if(t.temporaryProof&&t.phoneNumber)return new ji({Fa:t.temporaryProof,$:t.phoneNumber});var e=t&&t.providerId;if(!e||"password"===e)return null;var n=t&&t.oauthAccessToken,r=t&&t.oauthTokenSecret,i=t&&t.nonce,o=t&&t.oauthIdToken,s=t&&t.pendingToken;try{switch(e){case"google.com":return xi(o,n);case"facebook.com":return Oi(n);case"github.com":return Li(n);case"twitter.com":return Ui(n,r);default:return n||r||o||s?s?0==e.indexOf("saml.")?new Si(e,s):new Ci(e,{pendingToken:s,idToken:t.oauthIdToken,accessToken:t.oauthAccessToken},e):new Ri(e).credential(o,n,i):null}}catch(t){return null}}function zi(t){if(!t.isOAuthProvider)throw new qr("invalid-oauth-provider")}function Yi(t,e,n,r,i,o){if(this.b=t,this.c=e||null,this.f=n||null,this.g=r||null,this.h=o||null,this.a=i||null,!this.f&&!this.a)throw new qr("invalid-auth-event");if(this.f&&this.a)throw new qr("invalid-auth-event");if(this.f&&!this.g)throw new qr("invalid-auth-event")}function Xi(t){return(t=t||{}).type?new Yi(t.type,t.eventId,t.urlResponse,t.sessionId,t.error&&Br(t.error),t.postBody):null}function Ji(){this.b=null,this.a=[]}b(gi,mi),b(vi,gi),b(bi,gi),b(_i,gi),b(wi,gi),Si.prototype.la=function(t){return Ts(t,Ii(this))},Si.prototype.b=function(t,e){var n=Ii(this);return n.idToken=e,Ss(t,n)},Si.prototype.f=function(t,e){return Ti(Is(t,Ii(this)),e)},Si.prototype.C=function(){return{providerId:this.providerId,signInMethod:this.signInMethod,pendingToken:this.a}},Ci.prototype.la=function(t){return Ts(t,Ni(this))},Ci.prototype.b=function(t,e){var n=Ni(this);return n.idToken=e,Ss(t,n)},Ci.prototype.f=function(t,e){return Ti(Is(t,Ni(this)),e)},Ci.prototype.C=function(){var t={providerId:this.providerId,signInMethod:this.signInMethod};return this.idToken&&(t.oauthIdToken=this.idToken),this.accessToken&&(t.oauthAccessToken=this.accessToken),this.secret&&(t.oauthTokenSecret=this.secret),this.nonce&&(t.nonce=this.nonce),this.a&&(t.pendingToken=this.a),t},Di.prototype.Da=function(t){return this.yb=it(t),this},b(Ai,Di),b(Ri,Di),Ri.prototype.ua=function(t){return M(this.a,t)||this.a.push(t),this},Ri.prototype.Eb=function(){return q(this.a)},Ri.prototype.credential=function(t,e,n){if(!t&&!e)throw new qr("argument-error","credential failed: must provide the ID token and/or the access token.");return new Ci(this.providerId,{idToken:t||null,accessToken:e||null,nonce:n||null},this.providerId)},b(ki,Ri),Nr(ki,"PROVIDER_ID","facebook.com"),Nr(ki,"FACEBOOK_SIGN_IN_METHOD","facebook.com"),b(Pi,Ri),Nr(Pi,"PROVIDER_ID","github.com"),Nr(Pi,"GITHUB_SIGN_IN_METHOD","github.com"),b(Mi,Ri),Nr(Mi,"PROVIDER_ID","google.com"),Nr(Mi,"GOOGLE_SIGN_IN_METHOD","google.com"),b(Fi,Di),Nr(Fi,"PROVIDER_ID","twitter.com"),Nr(Fi,"TWITTER_SIGN_IN_METHOD","twitter.com"),qi.prototype.la=function(t){return this.signInMethod==Bi.EMAIL_LINK_SIGN_IN_METHOD?ta(t,Ps,{email:this.a,oobCode:this.c}):ta(t,Xs,{email:this.a,password:this.c})},qi.prototype.b=function(t,e){return this.signInMethod==Bi.EMAIL_LINK_SIGN_IN_METHOD?ta(t,Ls,{idToken:e,email:this.a,oobCode:this.c}):ta(t,Ks,{idToken:e,email:this.a,password:this.c})},qi.prototype.f=function(t,e){return Ti(this.la(t),e)},qi.prototype.C=function(){return{email:this.a,password:this.c,signInMethod:this.signInMethod}},Dr(Bi,{PROVIDER_ID:"password"}),Dr(Bi,{EMAIL_LINK_SIGN_IN_METHOD:"emailLink"}),Dr(Bi,{EMAIL_PASSWORD_SIGN_IN_METHOD:"password"}),ji.prototype.la=function(t){return t.Ua(Ki(this))},ji.prototype.b=function(t,e){var n=Ki(this);return n.idToken=e,ta(t,$s,n)},ji.prototype.f=function(t,e){var n=Ki(this);return n.operation="REAUTH",Ti(t=ta(t,Zs,n),e)},ji.prototype.C=function(){var t={providerId:"phone"};return this.a.Ta&&(t.verificationId=this.a.Ta),this.a.Sa&&(t.verificationCode=this.a.Sa),this.a.Fa&&(t.temporaryProof=this.a.Fa),this.a.$&&(t.phoneNumber=this.a.$),t},Qi.prototype.Ua=function(t,e){var n=this.a.b;return wt(e.verify()).then(function(i){if(!r(i))throw new qr("argument-error","An implementation of firebase.auth.ApplicationVerifier.prototype.verify() must return a firebase.Promise that resolves with a string.");switch(e.type){case"recaptcha":return function(t,e){return ta(t,Ws,e)}(n,{phoneNumber:t,recaptchaToken:i}).then(function(t){return"function"==typeof e.reset&&e.reset(),t},function(t){throw"function"==typeof e.reset&&e.reset(),t});default:throw new qr("argument-error",'Only firebase.auth.ApplicationVerifiers with type="recaptcha" are currently supported.')}})},Dr(Qi,{PROVIDER_ID:"phone"}),Dr(Qi,{PHONE_SIGN_IN_METHOD:"phone"}),Yi.prototype.C=function(){return{type:this.b,eventId:this.c,urlResponse:this.f,sessionId:this.g,postBody:this.h,error:this.a&&this.a.C()}};var $i,Zi=null;function to(t){var e="unauthorized-domain",n=void 0,r=Ge(t);t=r.b,"chrome-extension"==(r=r.c)?n=B("This chrome extension ID (chrome-extension://%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",t):"http"==r||"https"==r?n=B("This domain (%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",t):e="operation-not-supported-in-this-environment",qr.call(this,e,n)}function eo(t,e,n){qr.call(this,t,n),(t=e||{}).zb&&Nr(this,"email",t.zb),t.$&&Nr(this,"phoneNumber",t.$),t.credential&&Nr(this,"credential",t.credential)}function no(t){if(t.code){var e=t.code||"";0==e.indexOf(Vr)&&(e=e.substring(Vr.length));var n={credential:Gi(t)};if(t.email)n.zb=t.email;else if(t.phoneNumber)n.$=t.phoneNumber;else if(!n.credential)return new qr(e,t.message||void 0);return new eo(e,n,t.message)}return null}function ro(){}function io(t){return t.c||(t.c=t.b())}function oo(){}function so(t){if(!t.f&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(var e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],n=0;n<e.length;n++){var r=e[n];try{return new ActiveXObject(r),t.f=r}catch(t){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed")}return t.f}function ao(){}function uo(){this.a=new XDomainRequest,this.readyState=0,this.onreadystatechange=null,this.responseText="",this.status=-1,this.statusText="",this.a.onload=m(this.ec,this),this.a.onerror=m(this.Fb,this),this.a.onprogress=m(this.fc,this),this.a.ontimeout=m(this.ic,this)}function co(t,e){t.readyState=e,t.onreadystatechange&&t.onreadystatechange()}function ho(t,e,n){this.reset(t,e,n,void 0,void 0)}function lo(t){this.f=t,this.b=this.c=this.a=null}function fo(t,e){this.name=t,this.value=e}Ji.prototype.subscribe=function(t){var e=this;this.a.push(t),this.b||(this.b=function(t){for(var n=0;n<e.a.length;n++)e.a[n](t)},"function"==typeof(t=ar("universalLinks.subscribe",n))&&t(null,this.b))},Ji.prototype.unsubscribe=function(t){F(this.a,function(e){return e==t})},b(to,qr),b(eo,qr),eo.prototype.C=function(){var t={code:this.code,message:this.message};this.email&&(t.email=this.email),this.phoneNumber&&(t.phoneNumber=this.phoneNumber);var e=this.credential&&this.credential.C();return e&&ut(t,e),t},eo.prototype.toJSON=function(){return this.C()},ro.prototype.c=null,b(oo,ro),oo.prototype.a=function(){var t=so(this);return t?new ActiveXObject(t):new XMLHttpRequest},oo.prototype.b=function(){var t={};return so(this)&&(t[0]=!0,t[1]=!0),t},$i=new oo,b(ao,ro),ao.prototype.a=function(){var t=new XMLHttpRequest;if("withCredentials"in t)return t;if("undefined"!=typeof XDomainRequest)return new uo;throw Error("Unsupported browser")},ao.prototype.b=function(){return{}},(t=uo.prototype).open=function(t,e,n){if(null!=n&&!n)throw Error("Only async requests are supported.");this.a.open(t,e)},t.send=function(t){if(t){if("string"!=typeof t)throw Error("Only string data is supported");this.a.send(t)}else this.a.send()},t.abort=function(){this.a.abort()},t.setRequestHeader=function(){},t.getResponseHeader=function(t){return"content-type"==t.toLowerCase()?this.a.contentType:""},t.ec=function(){this.status=200,this.responseText=this.a.responseText,co(this,4)},t.Fb=function(){this.status=500,this.responseText="",co(this,4)},t.ic=function(){this.Fb()},t.fc=function(){this.status=200,co(this,1)},t.getAllResponseHeaders=function(){return"content-type: "+this.a.contentType},ho.prototype.a=null,ho.prototype.reset=function(t,e,n,r,i){delete this.a},fo.prototype.toString=function(){return this.name};var po=new fo("SEVERE",1e3),yo=new fo("WARNING",900),mo=new fo("CONFIG",700),go=new fo("FINE",500);lo.prototype.log=function(t,e,n){if(t.value>=function t(e){return e.c?e.c:e.a?t(e.a):(S("Root logger has no level set."),null)}(this).value)for(h(e)&&(e=e()),t=new ho(t,String(e),this.f),n&&(t.a=n),n=this;n;)n=n.a};var vo={},bo=null;function _o(t){var e;if(bo||(bo=new lo(""),vo[""]=bo,bo.c=mo),!(e=vo[t])){e=new lo(t);var n=t.lastIndexOf("."),r=t.substr(n+1);(n=_o(t.substr(0,n))).b||(n.b={}),n.b[r]=e,e.a=n,vo[t]=e}return e}function wo(t,e){t&&t.log(go,e,void 0)}function Eo(t){this.f=t}function To(t){Ae.call(this),this.i=t,this.readyState=So,this.status=0,this.responseText=this.statusText="",this.onreadystatechange=null,this.g=new Headers,this.b=null,this.h="GET",this.c="",this.a=!1,this.f=_o("goog.net.FetchXmlHttp")}b(Eo,ro),Eo.prototype.a=function(){return new To(this.f)},Eo.prototype.b=function(t){return function(){return t}}({}),b(To,Ae);var So=0;function Io(t){t.onreadystatechange&&t.onreadystatechange.call(t)}function Co(t){Ae.call(this),this.headers=new Fe,this.D=t||null,this.c=!1,this.w=this.a=null,this.h=this.N=this.m="",this.f=this.I=this.i=this.G=!1,this.g=0,this.u=null,this.o=No,this.v=this.O=!1}(t=To.prototype).open=function(t,e){if(this.readyState!=So)throw this.abort(),Error("Error reopening a connection");this.h=t,this.c=e,this.readyState=1,Io(this)},t.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.a=!0;var e={headers:this.g,method:this.h,credentials:void 0,cache:void 0};t&&(e.body=t),this.i.fetch(new Request(this.c,e)).then(this.hc.bind(this),this.Gb.bind(this))},t.abort=function(){this.responseText="",this.g=new Headers,this.status=0,1<=this.readyState&&this.a&&4!=this.readyState&&(this.readyState=4,this.a=!1,Io(this)),this.readyState=So},t.hc=function(t){this.a&&(this.b||(this.b=t.headers,this.readyState=2,Io(this)),this.a&&(this.readyState=3,Io(this),this.a&&t.text().then(this.gc.bind(this,t),this.Gb.bind(this))))},t.gc=function(t,e){this.a&&(this.status=t.status,this.statusText=t.statusText,this.responseText=e,this.readyState=4,Io(this))},t.Gb=function(t){var e=this.f;e&&e.log(yo,"Failed to fetch url "+this.c,t instanceof Error?t:Error(t)),this.a&&(this.readyState=4,Io(this))},t.setRequestHeader=function(t,e){this.g.append(t,e)},t.getResponseHeader=function(t){return this.b?this.b.get(t.toLowerCase())||"":((t=this.f)&&t.log(yo,"Attempting to get response header but no headers have been received for url: "+this.c,void 0),"")},t.getAllResponseHeaders=function(){if(!this.b){var t=this.f;return t&&t.log(yo,"Attempting to get all response headers but no headers have been received for url: "+this.c,void 0),""}t=[];for(var e=this.b.entries(),n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},b(Co,Ae);var No="";Co.prototype.b=_o("goog.net.XhrIo");var Do=/^https?$/i,Ao=["POST","PUT"];function Ro(t,e,i,o,s){if(t.a)throw Error("[goog.net.XhrIo] Object is active with another request="+t.m+"; newUri="+e);i=i?i.toUpperCase():"GET",t.m=e,t.h="",t.N=i,t.G=!1,t.c=!0,t.a=t.D?t.D.a():$i.a(),t.w=t.D?io(t.D):io($i),t.a.onreadystatechange=m(t.Jb,t);try{wo(t.b,qo(t,"Opening Xhr")),t.I=!0,t.a.open(i,String(e),!0),t.I=!1}catch(e){return wo(t.b,qo(t,"Error opening Xhr: "+e.message)),void Oo(t,e)}e=o||"";var a=new Fe(t.headers);s&&function(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(c(t)||r(t))O(t,e,void 0);else for(var n=xe(t),i=Me(t),o=i.length,s=0;s<o;s++)e.call(void 0,i[s],n&&n[s],t)}(s,function(t,e){a.set(e,t)}),s=function(t){t:{for(var e=ko,n=t.length,i=r(t)?t.split(""):t,o=0;o<n;o++)if(o in i&&e.call(void 0,i[o],o,t)){e=o;break t}e=-1}return 0>e?null:r(t)?t.charAt(e):t[e]}(a.U()),o=n.FormData&&e instanceof n.FormData,!M(Ao,i)||s||o||a.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),a.forEach(function(t,e){this.a.setRequestHeader(e,t)},t),t.o&&(t.a.responseType=t.o),"withCredentials"in t.a&&t.a.withCredentials!==t.O&&(t.a.withCredentials=t.O);try{xo(t),0<t.g&&(t.v=function(t){return jt&&te(9)&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(t.a),wo(t.b,qo(t,"Will abort after "+t.g+"ms if incomplete, xhr2 "+t.v)),t.v?(t.a.timeout=t.g,t.a.ontimeout=m(t.Ga,t)):t.u=Pe(t.Ga,t.g,t)),wo(t.b,qo(t,"Sending request")),t.i=!0,t.a.send(e),t.i=!1}catch(e){wo(t.b,qo(t,"Send error: "+e.message)),Oo(t,e)}}function ko(t){return"content-type"==t.toLowerCase()}function Oo(t,e){t.c=!1,t.a&&(t.f=!0,t.a.abort(),t.f=!1),t.h=e,Po(t),Mo(t)}function Po(t){t.G||(t.G=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function Lo(t){if(t.c&&void 0!==e)if(t.w[1]&&4==Fo(t)&&2==Uo(t))wo(t.b,qo(t,"Local request error detected and ignored"));else if(t.i&&4==Fo(t))Pe(t.Jb,0,t);else if(t.dispatchEvent("readystatechange"),4==Fo(t)){wo(t.b,qo(t,"Request complete")),t.c=!1;try{var r,i=Uo(t);t:switch(i){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var o=!0;break t;default:o=!1}if(!(r=o)){var s;if(s=0===i){var a=String(t.m).match(Be)[1]||null;if(!a&&n.self&&n.self.location){var u=n.self.location.protocol;a=u.substr(0,u.length-1)}s=!Do.test(a?a.toLowerCase():"")}r=s}if(r)t.dispatchEvent("complete"),t.dispatchEvent("success");else{try{var c=2<Fo(t)?t.a.statusText:""}catch(e){wo(t.b,"Can not get status: "+e.message),c=""}t.h=c+" ["+Uo(t)+"]",Po(t)}}finally{Mo(t)}}}function Mo(t,e){if(t.a){xo(t);var n=t.a,r=t.w[0]?o:null;t.a=null,t.w=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(e){(t=t.b)&&t.log(po,"Problem encountered resetting onreadystatechange: "+e.message,void 0)}}}function xo(t){t.a&&t.v&&(t.a.ontimeout=null),t.u&&(n.clearTimeout(t.u),t.u=null)}function Fo(t){return t.a?t.a.readyState:0}function Uo(t){try{return 2<Fo(t)?t.a.status:-1}catch(t){return-1}}function qo(t,e){return e+" ["+t.N+" "+t.m+" "+Uo(t)+"]"}function Bo(t,e){this.g=[],this.v=t,this.u=e||null,this.f=this.a=!1,this.c=void 0,this.m=this.w=this.i=!1,this.h=0,this.b=null,this.l=0}function Vo(t,e,n){t.a=!0,t.c=n,t.f=!e,Qo(t)}function Wo(t){if(t.a){if(!t.m)throw new Ho(t);t.m=!1}}function jo(t,e,n,r){t.g.push([e,n,r]),t.a&&Qo(t)}function Ko(t){return L(t.g,function(t){return h(t[1])})}function Qo(t){if(t.h&&t.a&&Ko(t)){var e=t.h,r=Yo[e];r&&(n.clearTimeout(r.a),delete Yo[e]),t.h=0}t.b&&(t.b.l--,delete t.b),e=t.c;for(var i=r=!1;t.g.length&&!t.i;){var o=t.g.shift(),s=o[0],a=o[1];if(o=o[2],s=t.f?a:s)try{var u=s.call(o||t.u,e);void 0!==u&&(t.f=t.f&&(u==e||u instanceof Error),t.c=e=u),(w(e)||"function"==typeof n.Promise&&e instanceof n.Promise)&&(i=!0,t.i=!0)}catch(n){e=n,t.f=!0,Ko(t)||(r=!0)}}t.c=e,i&&(u=m(t.o,t,!0),i=m(t.o,t,!1),e instanceof Bo?(jo(e,u,i),e.w=!0):e.then(u,i)),r&&(e=new zo(e),Yo[e.a]=e,t.h=e.a)}function Ho(){E.call(this)}function Go(){E.call(this)}function zo(t){this.a=n.setTimeout(m(this.c,this),0),this.b=t}(t=Co.prototype).Ga=function(){void 0!==e&&this.a&&(this.h="Timed out after "+this.g+"ms, aborting",wo(this.b,qo(this,this.h)),this.dispatchEvent("timeout"),this.abort(8))},t.abort=function(){this.a&&this.c&&(wo(this.b,qo(this,"Aborting")),this.c=!1,this.f=!0,this.a.abort(),this.f=!1,this.dispatchEvent("complete"),this.dispatchEvent("abort"),Mo(this))},t.va=function(){this.a&&(this.c&&(this.c=!1,this.f=!0,this.a.abort(),this.f=!1),Mo(this,!0)),Co.ob.va.call(this)},t.Jb=function(){this.qa||(this.I||this.i||this.f?Lo(this):this.wc())},t.wc=function(){Lo(this)},t.getResponse=function(){try{if(!this.a)return null;if("response"in this.a)return this.a.response;switch(this.o){case No:case"text":return this.a.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in this.a)return this.a.mozResponseArrayBuffer}var t=this.b;return t&&t.log(po,"Response type "+this.o+" is not supported on this browser",void 0),null}catch(t){return wo(this.b,"Can not get response: "+t.message),null}},Bo.prototype.cancel=function(t){if(this.a)this.c instanceof Bo&&this.c.cancel();else{if(this.b){var e=this.b;delete this.b,t?e.cancel(t):(e.l--,0>=e.l&&e.cancel())}this.v?this.v.call(this.u,this):this.m=!0,this.a||(t=new Go(this),Wo(this),Vo(this,!1,t))}},Bo.prototype.o=function(t,e){this.i=!1,Vo(this,t,e)},Bo.prototype.D=function(){Wo(this),Vo(this,!0,null)},Bo.prototype.then=function(t,e,n){var r,i,o=new dt(function(t,e){r=t,i=e});return jo(this,r,function(t){t instanceof Go?o.cancel():i(t)}),o.then(t,e,n)},_(Bo),b(Ho,E),Ho.prototype.message="Deferred has already fired",Ho.prototype.name="AlreadyCalledError",b(Go,E),Go.prototype.message="Deferred was canceled",Go.prototype.name="CanceledError",zo.prototype.c=function(){throw delete Yo[this.a],this.b};var Yo={};function Xo(t){var e={},n=e.document||document,r=gn(t),i=document.createElement("SCRIPT"),o={Lb:i,Ga:void 0},s=new Bo(Jo,o),a=null,u=null!=e.timeout?e.timeout:5e3;return 0<u&&(a=window.setTimeout(function(){$o(i,!0);var t=new es(ts,"Timeout reached for loading script "+r);Wo(s),Vo(s,!1,t)},u),o.Ga=a),i.onload=i.onreadystatechange=function(){i.readyState&&"loaded"!=i.readyState&&"complete"!=i.readyState||($o(i,e.fd||!1,a),s.D())},i.onerror=function(){$o(i,!0,a);var t=new es(Zo,"Error while loading script "+r);Wo(s),Vo(s,!1,t)},ut(o=e.attributes||{},{type:"text/javascript",charset:"UTF-8"}),On(i,o),i.src=gn(t),function(t){var e;return(e=(t||document).getElementsByTagName("HEAD"))&&0!=e.length?e[0]:t.documentElement}(n).appendChild(i),s}function Jo(){if(this&&this.Lb){var t=this.Lb;t&&"SCRIPT"==t.tagName&&$o(t,!0,this.Ga)}}function $o(t,e,r){null!=r&&n.clearTimeout(r),t.onload=o,t.onerror=o,t.onreadystatechange=o,e&&window.setTimeout(function(){t&&t.parentNode&&t.parentNode.removeChild(t)},0)}var Zo=0,ts=1;function es(t,e){var n="Jsloader error (code #"+t+")";e&&(n+=": "+e),E.call(this,n),this.code=t}function ns(t){this.f=t}function rs(t,e,r){if(this.b=t,t=e||{},this.i=t.secureTokenEndpoint||"https://securetoken.googleapis.com/v1/token",this.l=t.secureTokenTimeout||ss,this.f=it(t.secureTokenHeaders||as),this.g=t.firebaseEndpoint||"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",this.h=t.firebaseTimeout||us,this.a=it(t.firebaseHeaders||cs),r&&(this.a["X-Client-Version"]=r,this.f["X-Client-Version"]=r),r="Node"==Zn(),!(r=n.XMLHttpRequest||r&&Yn.INTERNAL.node&&Yn.INTERNAL.node.XMLHttpRequest)&&!$n())throw new qr("internal-error","The XMLHttpRequest compatibility library was not found.");this.c=void 0,$n()?this.c=new Eo(self):tr()?this.c=new ns(r):this.c=new ao}b(es,E),b(ns,ro),ns.prototype.a=function(){return new this.f},ns.prototype.b=function(){return{}};var is,os="idToken",ss=new br(3e4,6e4),as={"Content-Type":"application/x-www-form-urlencoded"},us=new br(3e4,6e4),cs={"Content-Type":"application/json"};function hs(t,e){e?t.a["X-Firebase-Locale"]=e:delete t.a["X-Firebase-Locale"]}function ls(t,e){e?(t.a["X-Client-Version"]=e,t.f["X-Client-Version"]=e):(delete t.a["X-Client-Version"],delete t.f["X-Client-Version"])}function fs(t,e,r,i,o,s,a){(function(){var t=sr();return!((t=rr(t)!=nr?null:(t=t.match(/\sChrome\/(\d+)/i))&&2==t.length?parseInt(t[1],10):null)&&30>t||jt&&$t&&!(9<$t))})()||$n()?t=m(t.o,t):(is||(is=new dt(function(t,e){!function(t,e){if(((window.gapi||{}).client||{}).request)t();else{n[ds]=function(){((window.gapi||{}).client||{}).request?t():e(Error("CORS_UNSUPPORTED"))};var r=vn(ps,{onload:ds});!function(t,e){jo(t,null,e,void 0)}(Xo(r),function(){e(Error("CORS_UNSUPPORTED"))})}}(t,e)})),t=m(t.m,t)),t(e,r,i,o,s,a)}rs.prototype.o=function(t,e,r,i,o,s){if($n()&&(void 0===n.fetch||void 0===n.Headers||void 0===n.Request))throw new qr("operation-not-supported-in-this-environment","fetch, Headers and Request native APIs or equivalent Polyfills must be available to support HTTP requests from a Worker environment.");var a=new Co(this.c);if(s){a.g=Math.max(0,s);var u=setTimeout(function(){a.dispatchEvent("timeout")},s)}Re(a,"complete",function(){u&&clearTimeout(u);var t=null;try{t=JSON.parse(function(t){try{return t.a?t.a.responseText:""}catch(e){return wo(t.b,"Can not get responseText: "+e.message),""}}(this))||null}catch(e){t=null}e&&e(t)}),ke(a,"ready",function(){u&&clearTimeout(u),Ut(this)}),ke(a,"timeout",function(){u&&clearTimeout(u),Ut(this),e&&e(null)}),Ro(a,t,r,i,o)};var ps=yn("https://apis.google.com/js/client.js?onload=%{onload}"),ds="__fcb"+Math.floor(1e6*Math.random()).toString();function ys(t){if(!r(t=t.email)||!Gn.test(t))throw new qr("invalid-email")}function ms(t){"email"in t&&ys(t)}function gs(t){if(!t[os])throw new qr("internal-error")}function vs(t){if(t.phoneNumber||t.temporaryProof){if(!t.phoneNumber||!t.temporaryProof)throw new qr("internal-error")}else{if(!t.sessionInfo)throw new qr("missing-verification-id");if(!t.code)throw new qr("missing-verification-code")}}rs.prototype.m=function(t,e,n,r,i){var o=this;is.then(function(){window.gapi.client.setApiKey(o.b);var s=window.gapi.auth.getToken();window.gapi.auth.setToken(null),window.gapi.client.request({path:t,method:n,body:r,headers:i,authType:"none",callback:function(t){window.gapi.auth.setToken(s),e&&e(t)}})}).s(function(t){e&&e({error:{message:t&&t.message||"CORS_UNSUPPORTED"}})})},rs.prototype.Qa=function(){return ta(this,Qs,{})},rs.prototype.pb=function(t,e){return ta(this,js,{idToken:t,email:e})},rs.prototype.qb=function(t,e){return ta(this,Ks,{idToken:t,password:e})};var bs={displayName:"DISPLAY_NAME",photoUrl:"PHOTO_URL"};function _s(t){if(!t.requestUri||!t.sessionId&&!t.postBody&&!t.pendingToken)throw new qr("internal-error")}function ws(t,e){return e.oauthIdToken&&e.providerId&&0==e.providerId.indexOf("oidc.")&&!e.pendingToken&&(t.sessionId?e.nonce=t.sessionId:t.postBody&&(un(t=new rn(t.postBody),"nonce")&&(e.nonce=t.get("nonce")))),e}function Es(t){var e=null;if(t.needConfirmation?(t.code="account-exists-with-different-credential",e=no(t)):"FEDERATED_USER_ID_ALREADY_LINKED"==t.errorMessage?(t.code="credential-already-in-use",e=no(t)):"EMAIL_EXISTS"==t.errorMessage?(t.code="email-already-in-use",e=no(t)):t.errorMessage&&(e=ea(t.errorMessage)),e)throw e;if(!t[os])throw new qr("internal-error")}function Ts(t,e){return e.returnIdpCredential=!0,ta(t,Hs,e)}function Ss(t,e){return e.returnIdpCredential=!0,ta(t,zs,e)}function Is(t,e){return e.returnIdpCredential=!0,e.autoCreate=!1,ta(t,Gs,e)}function Cs(t){if(!t.oobCode)throw new qr("invalid-action-code")}(t=rs.prototype).rb=function(t,e){var n={idToken:t},r=[];return nt(bs,function(t,i){var o=e[i];null===o?r.push(t):i in e&&(n[i]=o)}),r.length&&(n.deleteAttribute=r),ta(this,js,n)},t.kb=function(t,e){return ut(t={requestType:"PASSWORD_RESET",email:t},e),ta(this,Us,t)},t.lb=function(t,e){return ut(t={requestType:"EMAIL_SIGNIN",email:t},e),ta(this,xs,t)},t.jb=function(t,e){return ut(t={requestType:"VERIFY_EMAIL",idToken:t},e),ta(this,Fs,t)},t.Ua=function(t){return ta(this,Js,t)},t.Za=function(t,e){return ta(this,Vs,{oobCode:t,newPassword:e})},t.Ja=function(t){return ta(this,Ds,{oobCode:t})},t.Wa=function(t){return ta(this,Ns,{oobCode:t})};var Ns={endpoint:"setAccountInfo",B:Cs,da:"email"},Ds={endpoint:"resetPassword",B:Cs,J:function(t){var e=t.requestType;if(!e||!t.email&&"EMAIL_SIGNIN"!=e)throw new qr("internal-error")}},As={endpoint:"signupNewUser",B:function(t){if(ys(t),!t.password)throw new qr("weak-password")},J:gs,R:!0},Rs={endpoint:"createAuthUri"},ks={endpoint:"deleteAccount",T:["idToken"]},Os={endpoint:"setAccountInfo",T:["idToken","deleteProvider"],B:function(t){if(!u(t.deleteProvider))throw new qr("internal-error")}},Ps={endpoint:"emailLinkSignin",T:["email","oobCode"],B:ys,J:gs,R:!0},Ls={endpoint:"emailLinkSignin",T:["idToken","email","oobCode"],B:ys,J:gs,R:!0},Ms={endpoint:"getAccountInfo"},xs={endpoint:"getOobConfirmationCode",T:["requestType"],B:function(t){if("EMAIL_SIGNIN"!=t.requestType)throw new qr("internal-error");ys(t)},da:"email"},Fs={endpoint:"getOobConfirmationCode",T:["idToken","requestType"],B:function(t){if("VERIFY_EMAIL"!=t.requestType)throw new qr("internal-error")},da:"email"},Us={endpoint:"getOobConfirmationCode",T:["requestType"],B:function(t){if("PASSWORD_RESET"!=t.requestType)throw new qr("internal-error");ys(t)},da:"email"},qs={ub:!0,endpoint:"getProjectConfig",Ib:"GET"},Bs={ub:!0,endpoint:"getRecaptchaParam",Ib:"GET",J:function(t){if(!t.recaptchaSiteKey)throw new qr("internal-error")}},Vs={endpoint:"resetPassword",B:Cs,da:"email"},Ws={endpoint:"sendVerificationCode",T:["phoneNumber","recaptchaToken"],da:"sessionInfo"},js={endpoint:"setAccountInfo",T:["idToken"],B:ms,R:!0},Ks={endpoint:"setAccountInfo",T:["idToken"],B:function(t){if(ms(t),!t.password)throw new qr("weak-password")},J:gs,R:!0},Qs={endpoint:"signupNewUser",J:gs,R:!0},Hs={endpoint:"verifyAssertion",B:_s,Oa:ws,J:Es,R:!0},Gs={endpoint:"verifyAssertion",B:_s,Oa:ws,J:function(t){if(t.errorMessage&&"USER_NOT_FOUND"==t.errorMessage)throw new qr("user-not-found");if(t.errorMessage)throw ea(t.errorMessage);if(!t[os])throw new qr("internal-error")},R:!0},zs={endpoint:"verifyAssertion",B:function(t){if(_s(t),!t.idToken)throw new qr("internal-error")},Oa:ws,J:Es,R:!0},Ys={endpoint:"verifyCustomToken",B:function(t){if(!t.token)throw new qr("invalid-custom-token")},J:gs,R:!0},Xs={endpoint:"verifyPassword",B:function(t){if(ys(t),!t.password)throw new qr("wrong-password")},J:gs,R:!0},Js={endpoint:"verifyPhoneNumber",B:vs,J:gs},$s={endpoint:"verifyPhoneNumber",B:function(t){if(!t.idToken)throw new qr("internal-error");vs(t)},J:function(t){if(t.temporaryProof)throw t.code="credential-already-in-use",no(t);gs(t)}},Zs={Xb:{USER_NOT_FOUND:"user-not-found"},endpoint:"verifyPhoneNumber",B:vs,J:gs};function ta(t,e,n){if(!function(t,e){if(!e||!e.length)return!0;if(!t)return!1;for(var n=0;n<e.length;n++){var r=t[e[n]];if(void 0===r||null===r||""===r)return!1}return!0}(n,e.T))return Et(new qr("internal-error"));var r,i=e.Ib||"POST";return wt(n).then(e.B).then(function(){return e.R&&(n.returnSecureToken=!0),function(t,e,n,r,i,o){var s=Ge(t.g+e);Qe(s,"key",t.b),o&&Qe(s,"cb",v().toString());var a="GET"==n;if(a)for(var u in r)r.hasOwnProperty(u)&&Qe(s,u,r[u]);return new dt(function(e,o){fs(t,s.toString(),function(t){t?t.error?o(na(t,i||{})):e(t):o(new qr("network-request-failed"))},n,a?void 0:xn(dr(r)),t.a,t.h.get())})}(t,e.endpoint,i,n,e.Xb,e.ub||!1)}).then(function(t){return r=t,e.Oa?e.Oa(n,r):r}).then(e.J).then(function(){if(!e.da)return r;if(!(e.da in r))throw new qr("internal-error");return r[e.da]})}function ea(t){return na({error:{errors:[{message:t}],code:400,message:t}})}function na(t,e){var n=(t.error&&t.error.errors&&t.error.errors[0]||{}).reason||"",r={keyInvalid:"invalid-api-key",ipRefererBlocked:"app-not-authorized"};if(n=r[n]?new qr(r[n]):null)return n;for(var i in n=t.error&&t.error.message||"",ut(r={INVALID_CUSTOM_TOKEN:"invalid-custom-token",CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_EMAIL:"invalid-email",INVALID_PASSWORD:"wrong-password",USER_DISABLED:"user-disabled",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_OR_INVALID_NONCE:"missing-or-invalid-nonce",INVALID_MESSAGE_PAYLOAD:"invalid-message-payload",INVALID_RECIPIENT_EMAIL:"invalid-recipient-email",INVALID_SENDER:"invalid-sender",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",INVALID_PROVIDER_ID:"invalid-provider-id",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",CORS_UNSUPPORTED:"cors-unsupported",DYNAMIC_LINK_NOT_ACTIVATED:"dynamic-link-not-activated",INVALID_APP_ID:"invalid-app-id",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",WEAK_PASSWORD:"weak-password",OPERATION_NOT_ALLOWED:"operation-not-allowed",USER_CANCELLED:"user-cancelled",CAPTCHA_CHECK_FAILED:"captcha-check-failed",INVALID_APP_CREDENTIAL:"invalid-app-credential",INVALID_CODE:"invalid-verification-code",INVALID_PHONE_NUMBER:"invalid-phone-number",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_APP_CREDENTIAL:"missing-app-credential",MISSING_CODE:"missing-verification-code",MISSING_PHONE_NUMBER:"missing-phone-number",MISSING_SESSION_INFO:"missing-verification-id",QUOTA_EXCEEDED:"quota-exceeded",SESSION_EXPIRED:"code-expired",REJECTED_CREDENTIAL:"rejected-credential",INVALID_CONTINUE_URI:"invalid-continue-uri",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",MISSING_IOS_BUNDLE_ID:"missing-ios-bundle-id",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_DYNAMIC_LINK_DOMAIN:"invalid-dynamic-link-domain",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",INVALID_CERT_HASH:"invalid-cert-hash"},e||{}),e=(e=n.match(/^[^\s]+\s*:\s*(.*)$/))&&1<e.length?e[1]:void 0,r)if(0===n.indexOf(i))return new qr(r[i],e);return!e&&t&&(e=pr(t)),new qr("internal-error",e)}function ra(t){this.b=t,this.a=null,this.fb=function(t){return(aa||(aa=new dt(function(t,e){function r(){vr(),ar("gapi.load")("gapi.iframes",{callback:t,ontimeout:function(){vr(),e(Error("Network Error"))},timeout:oa.get()})}if(ar("gapi.iframes.Iframe"))t();else if(ar("gapi.load"))r();else{var i="__iframefcb"+Math.floor(1e6*Math.random()).toString();n[i]=function(){ar("gapi.load")?r():e(Error("Network Error"))},wt(Xo(i=vn(ia,{onload:i}))).s(function(){e(Error("Network Error"))})}}).s(function(t){throw aa=null,t}))).then(function(){return new dt(function(e,n){ar("gapi.iframes.getContext")().open({where:document.body,url:t.b,messageHandlersFilter:ar("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"),attributes:{style:{position:"absolute",top:"-100px",width:"1px",height:"1px"}},dontclear:!0},function(r){function i(){clearTimeout(o),e()}t.a=r,t.a.restyle({setHideOnLeave:!1});var o=setTimeout(function(){n(Error("Network Error"))},sa.get());r.ping(i).then(i,function(){n(Error("Network Error"))})})})})}(this)}var ia=yn("https://apis.google.com/js/api.js?onload=%{onload}"),oa=new br(3e4,6e4),sa=new br(5e3,15e3),aa=null;function ua(t,e,n){this.i=t,this.g=e,this.h=n,this.f=null,this.a=ze(this.i,"/__/auth/iframe"),Qe(this.a,"apiKey",this.g),Qe(this.a,"appName",this.h),this.b=null,this.c=[]}function ca(t,e,n,r,i){this.o=t,this.m=e,this.c=n,this.l=r,this.h=this.g=this.i=null,this.a=i,this.f=null}function ha(t){try{return Yn.app(t).auth().ya()}catch(t){return[]}}function la(t,e,n,r,i){this.m=t,this.f=e,this.b=n,this.c=r||null,this.h=i||null,this.o=this.u=this.v=null,this.g=[],this.l=this.a=null}function fa(t){var e=Vn();return function(t){return ta(t,qs,{}).then(function(t){return t.authorizedDomains||[]})}(t).then(function(t){t:{var n=Ge(e),r=n.c;n=n.b;for(var i=0;i<t.length;i++){var o=t[i],s=n,a=r;if(0==o.indexOf("chrome-extension://")?s=Ge(o).b==s&&"chrome-extension"==a:"http"!=a&&"https"!=a?s=!1:Hn.test(o)?s=s==o:(o=o.split(".").join("\\."),s=new RegExp("^(.+\\."+o+"|"+o+")$","i").test(s)),s){t=!0;break t}}t=!1}if(!t)throw new to(Vn())})}function pa(t){return t.l?t.l:(t.l=zn().then(function(){if(!t.u){var e=t.c,n=t.h,r=ha(t.b),i=new ua(t.m,t.f,t.b);i.f=e,i.b=n,i.c=q(r||[]),t.u=i.toString()}t.i=new ra(t.u),function(t){if(!t.i)throw Error("IfcHandler must be initialized!");!function(t,e){t.fb.then(function(){t.a.register("authEvent",e,ar("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"))})}(t.i,function(e){var n={};if(e&&e.authEvent){var r=!1;for(e=Xi(e.authEvent),n=0;n<t.g.length;n++)r=t.g[n](e)||r;return(n={}).status=r?"ACK":"ERROR",wt(n)}return n.status="ERROR",wt(n)})}(t)}),t.l)}function da(t){return t.o||(t.v=t.c?or(t.c,ha(t.b)):null,t.o=new rs(t.f,ui(t.h),t.v)),t.o}function ya(t,e,n,r,i,o,s,a,u,c){return(t=new ca(t,e,n,r,i)).i=o,t.g=s,t.h=a,t.b=it(u||null),t.f=c,t.toString()}function ma(t){if(this.a=t||Yn.INTERNAL.reactNative&&Yn.INTERNAL.reactNative.AsyncStorage,!this.a)throw new qr("internal-error","The React Native compatibility library was not found.");this.type="asyncStorage"}function ga(t){this.b=t,this.a={},this.c=m(this.f,this)}ua.prototype.toString=function(){return this.f?Qe(this.a,"v",this.f):an(this.a.a,"v"),this.b?Qe(this.a,"eid",this.b):an(this.a.a,"eid"),this.c.length?Qe(this.a,"fw",this.c.join(",")):an(this.a.a,"fw"),this.a.toString()},ca.prototype.toString=function(){var t=ze(this.o,"/__/auth/handler");if(Qe(t,"apiKey",this.m),Qe(t,"appName",this.c),Qe(t,"authType",this.l),this.a.isOAuthProvider){var e=this.a;try{var n=Yn.app(this.c).auth().ea()}catch(t){n=null}for(var r in e.$a=n,Qe(t,"providerId",this.a.providerId),n=dr((e=this.a).yb))n[r]=n[r].toString();r=e.Dc,n=it(n);for(var i=0;i<r.length;i++){var o=r[i];o in n&&delete n[o]}e.cb&&e.$a&&!n[e.cb]&&(n[e.cb]=e.$a),rt(n)||Qe(t,"customParameters",pr(n))}if("function"==typeof this.a.Eb&&((e=this.a.Eb()).length&&Qe(t,"scopes",e.join(","))),this.i?Qe(t,"redirectUrl",this.i):an(t.a,"redirectUrl"),this.g?Qe(t,"eventId",this.g):an(t.a,"eventId"),this.h?Qe(t,"v",this.h):an(t.a,"v"),this.b)for(var s in this.b)this.b.hasOwnProperty(s)&&!He(t,s)&&Qe(t,s,this.b[s]);return this.f?Qe(t,"eid",this.f):an(t.a,"eid"),(s=ha(this.c)).length&&Qe(t,"fw",s.join(",")),t.toString()},(t=la.prototype).Ea=function(t,e,n){var r=new qr("popup-closed-by-user"),i=new qr("web-storage-unsupported"),o=this,s=!1;return this.ga().then(function(){(function(t){var e={type:"webStorageSupport"};return pa(t).then(function(){return function(t,e){return t.fb.then(function(){return new dt(function(n){t.a.send(e.type,e,n,ar("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"))})})}(t.i,e)}).then(function(t){if(t&&t.length&&void 0!==t[0].webStorageSupport)return t[0].webStorageSupport;throw Error()})})(o).then(function(n){n||(t&&Kn(t),e(i),s=!0)})}).s(function(){}).then(function(){if(!s)return function(t){return new dt(function(e){return function n(){Le(2e3).then(function(){if(t&&!t.closed)return n();e()})}()})}(t)}).then(function(){if(!s)return Le(n).then(function(){e(r)})})},t.Mb=function(){var t=sr();return!fr(t)&&!gr(t)},t.Hb=function(){return!1},t.Cb=function(t,e,n,r,i,o,s){if(!t)return Et(new qr("popup-blocked"));if(s&&!fr())return this.ga().s(function(e){Kn(t),i(e)}),r(),wt();this.a||(this.a=fa(da(this)));var a=this;return this.a.then(function(){var e=a.ga().s(function(e){throw Kn(t),i(e),e});return r(),e}).then(function(){(zi(n),s)||Wn(ya(a.m,a.f,a.b,e,n,null,o,a.c,void 0,a.h),t)}).s(function(t){throw"auth/network-request-failed"==t.code&&(a.a=null),t})},t.Ca=function(t,e,n){this.a||(this.a=fa(da(this)));var r=this;return this.a.then(function(){zi(e),Wn(ya(r.m,r.f,r.b,t,e,Vn(),n,r.c,void 0,r.h))}).s(function(t){throw"auth/network-request-failed"==t.code&&(r.a=null),t})},t.ga=function(){var t=this;return pa(this).then(function(){return t.i.fb}).s(function(){throw t.a=null,new qr("network-request-failed")})},t.Qb=function(){return!0},t.wa=function(t){this.g.push(t)},t.Ka=function(t){F(this.g,function(e){return e==t})},(t=ma.prototype).get=function(t){return wt(this.a.getItem(t)).then(function(t){return t&&yr(t)})},t.set=function(t,e){return wt(this.a.setItem(t,pr(e)))},t.P=function(t){return wt(this.a.removeItem(t))},t.Y=function(){},t.ca=function(){};var va,ba=[];function _a(t){this.a=t}function wa(t){this.c=t,this.b=!1,this.a=[]}function Ea(t,e,n,r){var i,o,s,a,u=n||{},c=null;if(t.b)return Et(Error("connection_unavailable"));var h=r?800:50,l="undefined"!=typeof MessageChannel?new MessageChannel:null;return new dt(function(n,r){l?(i=Math.floor(Math.random()*Math.pow(10,20)).toString(),l.port1.start(),s=setTimeout(function(){r(Error("unsupported_event"))},h),c={messageChannel:l,onMessage:o=function(t){t.data.eventId===i&&("ack"===t.data.status?(clearTimeout(s),a=setTimeout(function(){r(Error("timeout"))},3e3)):"done"===t.data.status?(clearTimeout(a),void 0!==t.data.response?n(t.data.response):r(Error("unknown_error"))):(clearTimeout(s),clearTimeout(a),r(Error("invalid_response"))))}},t.a.push(c),l.port1.addEventListener("message",o),t.c.postMessage({eventType:e,eventId:i,data:u},[l.port2])):r(Error("connection_unavailable"))}).then(function(e){return Ta(t,c),e}).s(function(e){throw Ta(t,c),e})}function Ta(t,e){if(e){var n=e.messageChannel,r=e.onMessage;n&&(n.port1.removeEventListener("message",r),n.port1.close()),F(t.a,function(t){return t==e})}}function Sa(){if(!Na())throw new qr("web-storage-unsupported");this.c={},this.a=[],this.b=0,this.m=n.indexedDB,this.type="indexedDB",this.g=this.l=this.f=this.i=null,this.u=!1,this.h=null;var t=this;$n()&&self?(this.l=function(){var t=$n()?self:null;if(O(ba,function(n){n.b==t&&(e=n)}),!e){var e=new ga(t);ba.push(e)}return e}(),this.l.subscribe("keyChanged",function(e,n){return Oa(t).then(function(e){return 0<e.length&&O(t.a,function(t){t(e)}),{keyProcessed:M(e,n.key)}})}),this.l.subscribe("ping",function(){return wt(["keyChanged"])})):function(){var t=n.navigator;return t&&t.serviceWorker?wt().then(function(){return t.serviceWorker.ready}).then(function(t){return t.active||null}).s(function(){return null}):wt(null)}().then(function(e){(t.h=e)&&(t.g=new wa(new _a(e)),Ea(t.g,"ping",null,!0).then(function(e){e[0].fulfilled&&M(e[0].value,"keyChanged")&&(t.u=!0)}).s(function(){}))})}function Ia(t){return new dt(function(e,n){var r=t.m.open("firebaseLocalStorageDb",1);r.onerror=function(t){try{t.preventDefault()}catch(t){}n(Error(t.target.error))},r.onupgradeneeded=function(t){t=t.target.result;try{t.createObjectStore("firebaseLocalStorage",{keyPath:"fbase_key"})}catch(t){n(t)}},r.onsuccess=function(r){(r=r.target.result).objectStoreNames.contains("firebaseLocalStorage")?e(r):function(t){return new dt(function(e,n){var r=t.m.deleteDatabase("firebaseLocalStorageDb");r.onsuccess=function(){e()},r.onerror=function(t){n(Error(t.target.error))}})}(t).then(function(){return Ia(t)}).then(function(t){e(t)}).s(function(t){n(t)})}})}function Ca(t){return t.o||(t.o=Ia(t)),t.o}function Na(){try{return!!n.indexedDB}catch(t){return!1}}function Da(t){return t.objectStore("firebaseLocalStorage")}function Aa(t,e){return t.transaction(["firebaseLocalStorage"],e?"readwrite":"readonly")}function Ra(t){return new dt(function(e,n){t.onsuccess=function(t){t&&t.target?e(t.target.result):e()},t.onerror=function(t){n(t.target.error)}})}function ka(t,e){return t.g&&t.h&&function(){var t=n.navigator;return t&&t.serviceWorker&&t.serviceWorker.controller||null}()===t.h?Ea(t.g,"keyChanged",{key:e},t.u).then(function(){}).s(function(){}):wt()}function Oa(t){return Ca(t).then(function(t){var e=Da(Aa(t,!1));return e.getAll?Ra(e.getAll()):new dt(function(t,n){var r=[],i=e.openCursor();i.onsuccess=function(e){(e=e.target.result)?(r.push(e.value),e.continue()):t(r)},i.onerror=function(t){n(t.target.error)}})}).then(function(e){var n={},r=[];if(0==t.b){for(r=0;r<e.length;r++)n[e[r].fbase_key]=e[r].value;r=function t(e,n){var r,i=[];for(r in e)r in n?typeof e[r]!=typeof n[r]?i.push(r):"object"==typeof e[r]&&null!=e[r]&&null!=n[r]?0<t(e[r],n[r]).length&&i.push(r):e[r]!==n[r]&&i.push(r):i.push(r);for(r in n)r in e||i.push(r);return i}(t.c,n),t.c=n}return r})}function Pa(t){t.i&&t.i.cancel("STOP_EVENT"),t.f&&(clearTimeout(t.f),t.f=null)}function La(t){var e=this,n=null;this.a=[],this.type="indexedDB",this.c=t,this.b=wt().then(function(){if(Na()){var t=mr(),r="__sak"+t;return va||(va=new Sa),(n=va).set(r,t).then(function(){return n.get(r)}).then(function(e){if(e!==t)throw Error("indexedDB not supported!");return n.P(r)}).then(function(){return n}).s(function(){return e.c})}return e.c}).then(function(t){return e.type=t.type,t.Y(function(t){O(e.a,function(e){e(t)})}),t})}function Ma(){this.a={},this.type="inMemory"}function xa(){if(!function(){var t="Node"==Zn();if(!(t=Fa()||t&&Yn.INTERNAL.node&&Yn.INTERNAL.node.localStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(t){return!1}}()){if("Node"==Zn())throw new qr("internal-error","The LocalStorage compatibility library was not found.");throw new qr("web-storage-unsupported")}this.a=Fa()||Yn.INTERNAL.node.localStorage,this.type="localStorage"}function Fa(){try{var t=n.localStorage,e=mr();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(t){return null}}function Ua(){this.type="nullStorage"}function qa(){if(!function(){var t="Node"==Zn();if(!(t=Ba()||t&&Yn.INTERNAL.node&&Yn.INTERNAL.node.sessionStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(t){return!1}}()){if("Node"==Zn())throw new qr("internal-error","The SessionStorage compatibility library was not found.");throw new qr("web-storage-unsupported")}this.a=Ba()||Yn.INTERNAL.node.sessionStorage,this.type="sessionStorage"}function Ba(){try{var t=n.sessionStorage,e=mr();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(t){return null}}ga.prototype.f=function(t){var e=t.data.eventType,n=t.data.eventId,r=this.a[e];if(r&&0<r.length){t.ports[0].postMessage({status:"ack",eventId:n,eventType:e,response:null});var i=[];O(r,function(e){i.push(wt().then(function(){return e(t.origin,t.data.data)}))}),St(i).then(function(r){var i=[];O(r,function(t){i.push({fulfilled:t.Db,value:t.value,reason:t.reason?t.reason.message:void 0})}),O(i,function(t){for(var e in t)void 0===t[e]&&delete t[e]}),t.ports[0].postMessage({status:"done",eventId:n,eventType:e,response:i})})}},ga.prototype.subscribe=function(t,e){rt(this.a)&&this.b.addEventListener("message",this.c),void 0===this.a[t]&&(this.a[t]=[]),this.a[t].push(e)},ga.prototype.unsubscribe=function(t,e){void 0!==this.a[t]&&e?(F(this.a[t],function(t){return t==e}),0==this.a[t].length&&delete this.a[t]):e||delete this.a[t],rt(this.a)&&this.b.removeEventListener("message",this.c)},_a.prototype.postMessage=function(t,e){this.a.postMessage(t,e)},wa.prototype.close=function(){for(;0<this.a.length;)Ta(this,this.a[0]);this.b=!0},(t=Sa.prototype).set=function(t,e){var n,r=!1,i=this;return Ca(this).then(function(e){return Ra((e=Da(Aa(n=e,!0))).get(t))}).then(function(o){var s=Da(Aa(n,!0));return o?(o.value=e,Ra(s.put(o))):(i.b++,r=!0,(o={}).fbase_key=t,o.value=e,Ra(s.add(o)))}).then(function(){return i.c[t]=e,ka(i,t)}).ia(function(){r&&i.b--})},t.get=function(t){return Ca(this).then(function(e){return Ra(Da(Aa(e,!1)).get(t))}).then(function(t){return t&&t.value})},t.P=function(t){var e=!1,n=this;return Ca(this).then(function(r){return e=!0,n.b++,Ra(Da(Aa(r,!0)).delete(t))}).then(function(){return delete n.c[t],ka(n,t)}).ia(function(){e&&n.b--})},t.Y=function(t){0==this.a.length&&function(t){Pa(t),function e(){t.f=setTimeout(function(){t.i=Oa(t).then(function(e){0<e.length&&O(t.a,function(t){t(e)})}).then(function(){e()}).s(function(t){"STOP_EVENT"!=t.message&&e()})},800)}()}(this),this.a.push(t)},t.ca=function(t){F(this.a,function(e){return e==t}),0==this.a.length&&Pa(this)},(t=La.prototype).get=function(t){return this.b.then(function(e){return e.get(t)})},t.set=function(t,e){return this.b.then(function(n){return n.set(t,e)})},t.P=function(t){return this.b.then(function(e){return e.P(t)})},t.Y=function(t){this.a.push(t)},t.ca=function(t){F(this.a,function(e){return e==t})},(t=Ma.prototype).get=function(t){return wt(this.a[t])},t.set=function(t,e){return this.a[t]=e,wt()},t.P=function(t){return delete this.a[t],wt()},t.Y=function(){},t.ca=function(){},(t=xa.prototype).get=function(t){var e=this;return wt().then(function(){return yr(e.a.getItem(t))})},t.set=function(t,e){var n=this;return wt().then(function(){var r=pr(e);null===r?n.P(t):n.a.setItem(t,r)})},t.P=function(t){var e=this;return wt().then(function(){e.a.removeItem(t)})},t.Y=function(t){n.window&&ge(n.window,"storage",t)},t.ca=function(t){n.window&&_e(n.window,"storage",t)},(t=Ua.prototype).get=function(){return wt(null)},t.set=function(){return wt()},t.P=function(){return wt()},t.Y=function(){},t.ca=function(){},(t=qa.prototype).get=function(t){var e=this;return wt().then(function(){return yr(e.a.getItem(t))})},t.set=function(t,e){var n=this;return wt().then(function(){var r=pr(e);null===r?n.P(t):n.a.setItem(t,r)})},t.P=function(t){var e=this;return wt().then(function(){e.a.removeItem(t)})},t.Y=function(){},t.ca=function(){};var Va,Wa,ja={A:xa,Ra:qa},Ka={A:xa,Ra:qa},Qa={A:ma,Ra:Ua},Ha={A:xa,Ra:Ua},Ga={Zc:"local",NONE:"none",ad:"session"};function za(){var t=!(gr(sr())||!Jn()),e=fr(),r=ur();this.o=t,this.h=e,this.l=r,this.a={},Va||(Va=new function(){var t={};t.Browser=ja,t.Node=Ka,t.ReactNative=Qa,t.Worker=Ha,this.a=t[Zn()]}),t=Va;try{this.g=!Bn()&&Er()||!n.indexedDB?new t.a.A:new La($n()?new Ma:new t.a.A)}catch(t){this.g=new Ma,this.h=!0}try{this.i=new t.a.Ra}catch(t){this.i=new Ma}this.m=new Ma,this.f=m(this.Pb,this),this.b={}}function Ya(){return Wa||(Wa=new za),Wa}function Xa(t,e){switch(e){case"session":return t.i;case"none":return t.m;default:return t.g}}function Ja(t,e){return"firebase:"+t.name+(e?":"+e:"")}function $a(t,e,n){return n=Ja(e,n),"local"==e.A&&(t.b[n]=null),Xa(t,e.A).P(n)}function Za(t){t.c&&(clearInterval(t.c),t.c=null)}(t=za.prototype).get=function(t,e){return Xa(this,t.A).get(Ja(t,e))},t.set=function(t,e,n){var r=Ja(t,n),i=this,o=Xa(this,t.A);return o.set(r,e).then(function(){return o.get(r)}).then(function(e){"local"==t.A&&(i.b[r]=e)})},t.addListener=function(t,e,r){t=Ja(t,e),this.l&&(this.b[t]=n.localStorage.getItem(t)),rt(this.a)&&(Xa(this,"local").Y(this.f),this.h||(Bn()||!Er())&&n.indexedDB||!this.l||function(t){Za(t),t.c=setInterval(function(){for(var e in t.a){var r=n.localStorage.getItem(e),i=t.b[e];r!=i&&(t.b[e]=r,r=new ae({type:"storage",key:e,target:window,oldValue:i,newValue:r,a:!0}),t.Pb(r))}},1e3)}(this)),this.a[t]||(this.a[t]=[]),this.a[t].push(r)},t.removeListener=function(t,e,n){t=Ja(t,e),this.a[t]&&(F(this.a[t],function(t){return t==n}),0==this.a[t].length&&delete this.a[t]),rt(this.a)&&(Xa(this,"local").ca(this.f),Za(this))},t.Pb=function(t){if(t&&t.f){var e=t.a.key;if(null==e)for(var r in this.a){var i=this.b[r];void 0===i&&(i=null);var o=n.localStorage.getItem(r);o!==i&&(this.b[r]=o,this.Xa(r))}else if(0==e.indexOf("firebase:")&&this.a[e]){if(void 0!==t.a.a?Xa(this,"local").ca(this.f):Za(this),this.o)if(r=n.localStorage.getItem(e),(i=t.a.newValue)!==r)null!==i?n.localStorage.setItem(e,i):n.localStorage.removeItem(e);else if(this.b[e]===i&&void 0===t.a.a)return;var s=this;r=function(){void 0===t.a.a&&s.b[e]===n.localStorage.getItem(e)||(s.b[e]=n.localStorage.getItem(e),s.Xa(e))},jt&&$t&&10==$t&&n.localStorage.getItem(e)!==t.a.newValue&&t.a.newValue!==t.a.oldValue?setTimeout(r,10):r()}}else O(t,m(this.Xa,this))},t.Xa=function(t){this.a[t]&&O(this.a[t],function(t){t()})};var tu,eu={name:"authEvent",A:"local"};function nu(t,e){this.b=ru,this.f=n.Uint8Array?new Uint8Array(this.b):Array(this.b),this.g=this.c=0,this.a=[],this.i=t,this.h=e,this.l=n.Int32Array?new Int32Array(64):Array(64),void 0!==tu||(tu=n.Int32Array?new Int32Array(hu):hu),this.reset()}b(nu,function(){this.b=-1});for(var ru=64,iu=ru-1,ou=[],su=0;su<iu;su++)ou[su]=0;var au=U(128,ou);function uu(t){for(var e=t.f,n=t.l,r=0,i=0;i<e.length;)n[r++]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3],i=4*r;for(e=16;64>e;e++){i=0|n[e-15],r=0|n[e-2];var o=(0|n[e-16])+((i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3)|0,s=(0|n[e-7])+((r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10)|0;n[e]=o+s|0}r=0|t.a[0],i=0|t.a[1];var a=0|t.a[2],u=0|t.a[3],c=0|t.a[4],h=0|t.a[5],l=0|t.a[6];for(o=0|t.a[7],e=0;64>e;e++){var f=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&i^r&a^i&a)|0;s=(o=o+((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))|0)+((s=(s=c&h^~c&l)+(0|tu[e])|0)+(0|n[e])|0)|0,o=l,l=h,h=c,c=u+s|0,u=a,a=i,i=r,r=s+f|0}t.a[0]=t.a[0]+r|0,t.a[1]=t.a[1]+i|0,t.a[2]=t.a[2]+a|0,t.a[3]=t.a[3]+u|0,t.a[4]=t.a[4]+c|0,t.a[5]=t.a[5]+h|0,t.a[6]=t.a[6]+l|0,t.a[7]=t.a[7]+o|0}function cu(t,e,n){void 0===n&&(n=e.length);var i=0,o=t.c;if(r(e))for(;i<n;)t.f[o++]=e.charCodeAt(i++),o==t.b&&(uu(t),o=0);else{if(!c(e))throw Error("message must be string or array");for(;i<n;){var s=e[i++];if(!("number"==typeof s&&0<=s&&255>=s&&s==(0|s)))throw Error("message must be a byte array");t.f[o++]=s,o==t.b&&(uu(t),o=0)}}t.c=o,t.g+=n}nu.prototype.reset=function(){this.g=this.c=0,this.a=n.Int32Array?new Int32Array(this.h):q(this.h)};var hu=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function lu(){nu.call(this,8,fu)}b(lu,nu);var fu=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function pu(t,e,n,r,i){this.m=t,this.i=e,this.l=n,this.o=r||null,this.u=i||null,this.h=e+":"+n,this.v=new function(){this.a=Ya()},this.g=new function(t){this.a=t,this.b=Ya()}(this.h),this.f=null,this.b=[],this.a=this.c=null}function du(t){return new qr("invalid-cordova-configuration",t)}function yu(t){var e=new lu;cu(e,t),t=[];var n=8*e.g;56>e.c?cu(e,au,56-e.c):cu(e,au,e.b-(e.c-56));for(var r=63;56<=r;r--)e.f[r]=255&n,n/=256;for(uu(e),r=n=0;r<e.i;r++)for(var i=24;0<=i;i-=8)t[n++]=e.a[r]>>i&255;return function(t){return P(t,function(t){return 1<(t=t.toString(16)).length?t:"0"+t}).join("")}(t)}function mu(t,e){for(var n=0;n<t.b.length;n++)try{t.b[n](e)}catch(t){}}function gu(t){return t.f||(t.f=t.ga().then(function(){return new dt(function(e){t.wa(function n(r){return e(r),t.Ka(n),!1}),function(t){function e(e){i=!0,o&&o.cancel(),vu(t).then(function(n){var i=r;if(n&&e&&e.url){var o=null;-1!=(i=Ei(e.url)).indexOf("/__/auth/callback")&&(o=(o="object"==typeof(o=yr(He(o=Ge(i),"firebaseError")||null))?Br(o):null)?new Yi(n.b,n.c,null,null,o):new Yi(n.b,n.c,i,n.g)),i=o||r}mu(t,i)})}var r=new Yi("unknown",null,null,null,new qr("no-auth-event")),i=!1,o=Le(500).then(function(){return vu(t).then(function(){i||mu(t,r)})}),s=n.handleOpenURL;n.handleOpenURL=function(t){if(0==t.toLowerCase().indexOf(ar("BuildInfo.packageName",n).toLowerCase()+"://")&&e({url:t}),"function"==typeof s)try{s(t)}catch(t){console.error(t)}},Zi||(Zi=new Ji),Zi.subscribe(e)}(t)})})),t.f}function vu(t){var e=null;return function(t){return t.b.get(eu,t.a).then(function(t){return Xi(t)})}(t.g).then(function(n){return e=n,$a((n=t.g).b,eu,n.a)}).then(function(){return e})}(t=pu.prototype).ga=function(){return this.za?this.za:this.za=(Xn(void 0)?zn().then(function(){return new dt(function(t,e){var r=n.document,i=setTimeout(function(){e(Error("Cordova framework is not ready."))},1e3);r.addEventListener("deviceready",function(){clearTimeout(i),t()},!1)})}):Et(Error("Cordova must run in an Android or iOS file scheme."))).then(function(){if("function"!=typeof ar("universalLinks.subscribe",n))throw du("cordova-universal-links-plugin-fix is not installed");if(void 0===ar("BuildInfo.packageName",n))throw du("cordova-plugin-buildinfo is not installed");if("function"!=typeof ar("cordova.plugins.browsertab.openUrl",n))throw du("cordova-plugin-browsertab is not installed");if("function"!=typeof ar("cordova.InAppBrowser.open",n))throw du("cordova-plugin-inappbrowser is not installed")},function(){throw new qr("cordova-not-ready")})},t.Ea=function(t,e){return e(new qr("operation-not-supported-in-this-environment")),wt()},t.Cb=function(){return Et(new qr("operation-not-supported-in-this-environment"))},t.Qb=function(){return!1},t.Mb=function(){return!0},t.Hb=function(){return!0},t.Ca=function(t,e,r){if(this.c)return Et(new qr("redirect-operation-pending"));var i=this,o=n.document,s=null,a=null,u=null,c=null;return this.c=wt().then(function(){return zi(e),gu(i)}).then(function(){return function(t,e,r,i){var o=function(){for(var t=20,e=[];0<t;)e.push("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(62*Math.random()))),t--;return e.join("")}(),s=new Yi(e,i,null,o,new qr("no-auth-event")),a=ar("BuildInfo.packageName",n);if("string"!=typeof a)throw new qr("invalid-cordova-configuration");var u=ar("BuildInfo.displayName",n),c={};if(sr().toLowerCase().match(/iphone|ipad|ipod/))c.ibi=a;else{if(!sr().toLowerCase().match(/android/))return Et(new qr("operation-not-supported-in-this-environment"));c.apn=a}u&&(c.appDisplayName=u),o=yu(o),c.sessionId=o;var h=ya(t.m,t.i,t.l,e,r,null,i,t.o,c,t.u);return t.ga().then(function(){var e=t.h;return t.v.a.set(eu,s.C(),e)}).then(function(){var e=ar("cordova.plugins.browsertab.isAvailable",n);if("function"!=typeof e)throw new qr("invalid-cordova-configuration");var r=null;e(function(e){if(e){if("function"!=typeof(r=ar("cordova.plugins.browsertab.openUrl",n)))throw new qr("invalid-cordova-configuration");r(h)}else{if("function"!=typeof(r=ar("cordova.InAppBrowser.open",n)))throw new qr("invalid-cordova-configuration");e=!(!(e=sr()).match(/(iPad|iPhone|iPod).*OS 7_\d/i)&&!e.match(/(iPad|iPhone|iPod).*OS 8_\d/i)),t.a=r(h,e?"_blank":"_system","location=yes")}})})}(i,t,e,r)}).then(function(){return new dt(function(t,e){a=function(){var e=ar("cordova.plugins.browsertab.close",n);return t(),"function"==typeof e&&e(),i.a&&"function"==typeof i.a.close&&(i.a.close(),i.a=null),!1},i.wa(a),u=function(){s||(s=Le(2e3).then(function(){e(new qr("redirect-cancelled-by-user"))}))},c=function(){_r()&&u()},o.addEventListener("resume",u,!1),sr().toLowerCase().match(/android/)||o.addEventListener("visibilitychange",c,!1)}).s(function(t){return vu(i).then(function(){throw t})})}).ia(function(){u&&o.removeEventListener("resume",u,!1),c&&o.removeEventListener("visibilitychange",c,!1),s&&s.cancel(),a&&i.Ka(a),i.c=null})},t.wa=function(t){this.b.push(t),gu(this).s(function(e){"auth/invalid-cordova-configuration"===e.code&&(e=new Yi("unknown",null,null,null,new qr("no-auth-event")),t(e))})},t.Ka=function(t){F(this.b,function(e){return e==t})};var bu={name:"pendingRedirect",A:"session"};function _u(t){return $a(t.b,bu,t.a)}function wu(t,e,n){this.u=t,this.l=e,this.m=n,this.h=[],this.f=!1,this.i=m(this.bb,this),this.b=new ku,this.o=new Mu,this.g=new function(t){this.a=t,this.b=Ya()}(this.l+":"+this.m),this.c={},this.c.unknown=this.b,this.c.signInViaRedirect=this.b,this.c.linkViaRedirect=this.b,this.c.reauthViaRedirect=this.b,this.c.signInViaPopup=this.o,this.c.linkViaPopup=this.o,this.c.reauthViaPopup=this.o,this.a=Eu(this.u,this.l,this.m,si)}function Eu(t,e,n,r){var i=Yn.SDK_VERSION||null;return Xn()?new pu(t,e,n,i,r):new la(t,e,n,i,r)}function Tu(t){t.f||(t.f=!0,t.a.wa(t.i));var e=t.a;return t.a.ga().s(function(n){throw t.a==e&&t.reset(),n})}function Su(t){t.a.Mb()&&Tu(t).s(function(e){var n=new Yi("unknown",null,null,null,new qr("operation-not-supported-in-this-environment"));Du(e)&&t.bb(n)}),t.a.Hb()||Ou(t.b)}(t=wu.prototype).reset=function(){this.f=!1,this.a.Ka(this.i),this.a=Eu(this.u,this.l,this.m)},t.Ya=function(){this.b.Ya()},t.subscribe=function(t){if(M(this.h,t)||this.h.push(t),!this.f){var e=this;(function(t){return t.b.get(bu,t.a).then(function(t){return"pending"==t})})(this.g).then(function(t){t?_u(e.g).then(function(){Tu(e).s(function(t){var n=new Yi("unknown",null,null,null,new qr("operation-not-supported-in-this-environment"));Du(t)&&e.bb(n)})}):Su(e)}).s(function(){Su(e)})}},t.unsubscribe=function(t){F(this.h,function(e){return e==t})},t.bb=function(t){if(!t)throw new qr("invalid-auth-event");for(var e=!1,n=0;n<this.h.length;n++){var r=this.h[n];if(r.vb(t.b,t.c)){(e=this.c[t.b])&&e.h(t,r),e=!0;break}}return Ou(this.b),e};var Iu=new br(2e3,1e4),Cu=new br(3e4,6e4);function Nu(t,e,n,r,i,o){return t.a.Cb(e,n,r,function(){t.f||(t.f=!0,t.a.wa(t.i))},function(){t.reset()},i,o)}function Du(t){return!(!t||"auth/cordova-not-ready"!=t.code)}wu.prototype.fa=function(){return this.b.fa()},wu.prototype.Ca=function(t,e,n){var r,i=this;return function(t){return t.b.set(bu,"pending",t.a)}(this.g).then(function(){return i.a.Ca(t,e,n).s(function(t){if(Du(t))throw new qr("operation-not-supported-in-this-environment");return r=t,_u(i.g).then(function(){throw r})}).then(function(){return i.a.Qb()?new dt(function(){}):_u(i.g).then(function(){return i.fa()}).then(function(){}).s(function(){})})})},wu.prototype.Ea=function(t,e,n,r){return this.a.Ea(n,function(n){t.ha(e,null,n,r)},Iu.get())};var Au={};function Ru(t,e,n){var r=e+":"+n;return Au[r]||(Au[r]=new wu(t,e,n)),Au[r]}function ku(){this.b=null,this.f=[],this.c=[],this.a=null,this.i=this.g=!1}function Ou(t){t.g||(t.g=!0,Lu(t,!1,null,null))}function Pu(t,e){if(t.b=function(){return wt(e)},t.f.length)for(var n=0;n<t.f.length;n++)t.f[n](e)}function Lu(t,e,n,r){e?r?function(t,e){if(t.b=function(){return Et(e)},t.c.length)for(var n=0;n<t.c.length;n++)t.c[n](e)}(t,r):Pu(t,n):Pu(t,{user:null}),t.f=[],t.c=[]}function Mu(){}function xu(){this.sb=!1,Object.defineProperty(this,"appVerificationDisabled",{get:function(){return this.sb},set:function(t){this.sb=t},enumerable:!1})}function Fu(t,e){this.a=e,Nr(this,"verificationId",t)}function Uu(t,e,n,r){return new Qi(t).Ua(e,n).then(function(t){return new Fu(t,r)})}function qu(t,e,n){if(this.h=t,this.i=e,this.g=n,this.c=3e4,this.f=96e4,this.b=null,this.a=this.c,this.f<this.c)throw Error("Proactive refresh lower bound greater than upper bound!")}function Bu(t){this.f=t,this.b=this.a=null,this.c=0}function Vu(t,e){var n=e[os],r=e.refreshToken;e=Wu(e.expiresIn),t.b=n,t.c=e,t.a=r}function Wu(t){return v()+1e3*parseInt(t,10)}function ju(t,e){return function(t,e){return new dt(function(n,r){"refresh_token"==e.grant_type&&e.refresh_token||"authorization_code"==e.grant_type&&e.code?fs(t,t.i+"?key="+encodeURIComponent(t.b),function(t){t?t.error?r(na(t)):t.access_token&&t.refresh_token?n(t):r(new qr("internal-error")):r(new qr("network-request-failed"))},"POST",sn(e).toString(),t.f,t.l.get()):r(new qr("internal-error"))})}(t.f,e).then(function(e){return t.b=e.access_token,t.c=Wu(e.expires_in),t.a=e.refresh_token,{accessToken:t.b,expirationTime:t.c,refreshToken:t.a}}).s(function(e){throw"auth/user-token-expired"==e.code&&(t.a=null),e})}function Ku(t,e){this.a=t||null,this.b=e||null,Dr(this,{lastSignInTime:wr(e||null),creationTime:wr(t||null)})}function Qu(t,e){for(var n in se.call(this,t),e)this[n]=e[n]}function Hu(t,e,n){this.G=[],this.m=t.apiKey,this.o=t.appName,this.u=t.authDomain||null,t=Yn.SDK_VERSION?or(Yn.SDK_VERSION):null,this.b=new rs(this.m,ui(si),t),this.h=new Bu(this.b),Zu(this,e[os]),Vu(this.h,e),Nr(this,"refreshToken",this.h.a),nc(this,n||{}),Ae.call(this),this.I=!1,this.u&&cr()&&(this.a=Ru(this.u,this.m,this.o)),this.N=[],this.i=null,this.w=function(t){return new qu(function(){return t.F(!0)},function(t){return!(!t||"auth/network-request-failed"!=t.code)},function(){var e=t.h.c-v()-3e5;return 0<e?e:0})}(this),this.V=m(this.Ha,this);var r=this;this.ka=null,this.ta=function(t){r.pa(t.g)},this.X=null,this.O=[],this.sa=function(t){zu(r,t.c)},this.W=null}function Gu(t,e){t.X&&_e(t.X,"languageCodeChanged",t.ta),(t.X=e)&&ge(e,"languageCodeChanged",t.ta)}function zu(t,e){t.O=e,ls(t.b,Yn.SDK_VERSION?or(Yn.SDK_VERSION,t.O):null)}function Yu(t,e){t.W&&_e(t.W,"frameworkChanged",t.sa),(t.W=e)&&ge(e,"frameworkChanged",t.sa)}function Xu(t){try{return Yn.app(t.o).auth()}catch(e){throw new qr("internal-error","No firebase.auth.Auth instance is available for the Firebase App '"+t.o+"'!")}}function Ju(t){t.D||t.w.b||(t.w.start(),_e(t,"tokenChanged",t.V),ge(t,"tokenChanged",t.V))}function $u(t){_e(t,"tokenChanged",t.V),t.w.stop()}function Zu(t,e){t.ra=e,Nr(t,"_lat",e)}function tc(t){for(var e=[],n=0;n<t.N.length;n++)e.push(t.N[n](t));return St(e).then(function(){return t})}function ec(t){t.a&&!t.I&&(t.I=!0,t.a.subscribe(t))}function nc(t,e){Dr(t,{uid:e.uid,displayName:e.displayName||null,photoURL:e.photoURL||null,email:e.email||null,emailVerified:e.emailVerified||!1,phoneNumber:e.phoneNumber||null,isAnonymous:e.isAnonymous||!1,metadata:new Ku(e.createdAt,e.lastLoginAt),providerData:[]})}function rc(){}function ic(t){return wt().then(function(){if(t.D)throw new qr("app-deleted")})}function oc(t){return P(t.providerData,function(t){return t.providerId})}function sc(t,e){e&&(ac(t,e.providerId),t.providerData.push(e))}function ac(t,e){F(t.providerData,function(t){return t.providerId==e})}function uc(t,e,n){("uid"!=e||n)&&t.hasOwnProperty(e)&&Nr(t,e,n)}function cc(t,e){t!=e&&(Dr(t,{uid:e.uid,displayName:e.displayName,photoURL:e.photoURL,email:e.email,emailVerified:e.emailVerified,phoneNumber:e.phoneNumber,isAnonymous:e.isAnonymous,providerData:[]}),e.metadata?Nr(t,"metadata",function(t){return new Ku(t.a,t.b)}(e.metadata)):Nr(t,"metadata",new Ku),O(e.providerData,function(e){sc(t,e)}),function(t,e){t.b=e.b,t.a=e.a,t.c=e.c}(t.h,e.h),Nr(t,"refreshToken",t.h.a))}function hc(t){return t.F().then(function(e){var n=t.isAnonymous;return function(t,e){return ta(t.b,Ms,{idToken:e}).then(m(t.xc,t))}(t,e).then(function(){return n||uc(t,"isAnonymous",!1),e})})}function lc(t,e){e[os]&&t.ra!=e[os]&&(Vu(t.h,e),t.dispatchEvent(new Qu("tokenChanged")),Zu(t,e[os]),uc(t,"refreshToken",t.h.a))}function fc(t,e){return hc(t).then(function(){if(M(oc(t),e))return tc(t).then(function(){throw new qr("provider-already-linked")})})}function pc(t,e,n){return Ar({user:t,credential:Gi(e),additionalUserInfo:e=pi(e),operationType:n})}function dc(t,e){return lc(t,e),t.reload().then(function(){return t})}function yc(t,e,n,r,i){if(!cr())return Et(new qr("operation-not-supported-in-this-environment"));if(t.i&&!i)return Et(t.i);var o=fi(n.providerId),s=mr(t.uid+":::"),a=null;(!fr()||Jn())&&t.u&&n.isOAuthProvider&&(a=ya(t.u,t.m,t.o,e,n,null,s,Yn.SDK_VERSION||null));var u=Qn(a,o&&o.Ba,o&&o.Aa);return r=r().then(function(){if(gc(t),!i)return t.F().then(function(){})}).then(function(){return Nu(t.a,u,e,n,s,!!a)}).then(function(){return new dt(function(n,r){t.ha(e,null,new qr("cancelled-popup-request"),t.g||null),t.f=n,t.v=r,t.g=s,t.c=t.a.Ea(t,e,u,s)})}).then(function(t){return u&&Kn(u),t?Ar(t):null}).s(function(t){throw u&&Kn(u),t}),vc(t,r,i)}function mc(t,e,n,r,i){if(!cr())return Et(new qr("operation-not-supported-in-this-environment"));if(t.i&&!i)return Et(t.i);var o=null,s=mr(t.uid+":::");return r=r().then(function(){if(gc(t),!i)return t.F().then(function(){})}).then(function(){return t.aa=s,tc(t)}).then(function(e){return t.ba&&(e=(e=t.ba).b.set(_c,t.C(),e.a)),e}).then(function(){return t.a.Ca(e,n,s)}).s(function(e){if(o=e,t.ba)return wc(t.ba);throw o}).then(function(){if(o)throw o}),vc(t,r,i)}function gc(t){if(!t.a||!t.I){if(t.a&&!t.I)throw new qr("internal-error");throw new qr("auth-domain-config-required")}}function vc(t,e,n){var r=function(t,e,n){return t.i&&!n?(e.cancel(),Et(t.i)):e.s(function(e){throw!e||"auth/user-disabled"!=e.code&&"auth/user-token-expired"!=e.code||(t.i||t.dispatchEvent(new Qu("userInvalidated")),t.i=e),e})}(t,e,n);return t.G.push(r),r.ia(function(){x(t.G,r)}),r}function bc(t){if(!t.apiKey)return null;var e={apiKey:t.apiKey,authDomain:t.authDomain,appName:t.appName},n={};if(!(t.stsTokenManager&&t.stsTokenManager.accessToken&&t.stsTokenManager.expirationTime))return null;n[os]=t.stsTokenManager.accessToken,n.refreshToken=t.stsTokenManager.refreshToken||null,n.expiresIn=(t.stsTokenManager.expirationTime-v())/1e3;var r=new Hu(e,n,t);return t.providerData&&O(t.providerData,function(t){t&&sc(r,Ar(t))}),t.redirectEventId&&(r.aa=t.redirectEventId),r}ku.prototype.reset=function(){this.b=null,this.a&&(this.a.cancel(),this.a=null)},ku.prototype.h=function(t,e){if(t){this.reset(),this.g=!0;var n=t.b,r=t.c,i=t.a&&"auth/web-storage-unsupported"==t.a.code,o=t.a&&"auth/operation-not-supported-in-this-environment"==t.a.code;this.i=!(!i&&!o),"unknown"!=n||i||o?t.a?(Lu(this,!0,null,t.a),wt()):e.xa(n,r)?function(t,e,n){n=n.xa(e.b,e.c);var r=e.f,i=e.g,o=e.h,s=!!e.b.match(/Redirect$/);n(r,i,o).then(function(e){Lu(t,s,e,null)}).s(function(e){Lu(t,s,null,e)})}(this,t,e):Et(new qr("invalid-auth-event")):(Lu(this,!1,null,null),wt())}else Et(new qr("invalid-auth-event"))},ku.prototype.Ya=function(){this.g&&!this.i&&Lu(this,!1,null,null)},ku.prototype.fa=function(){var t=this;return new dt(function(e,n){t.b?t.b().then(e,n):(t.f.push(e),t.c.push(n),function(t){var e=new qr("timeout");t.a&&t.a.cancel(),t.a=Le(Cu.get()).then(function(){t.b||(t.g=!0,Lu(t,!0,null,e))})}(t))})},Mu.prototype.h=function(t,e){if(t){var n=t.b,r=t.c;t.a?(e.ha(t.b,null,t.a,t.c),wt()):e.xa(n,r)?function(t,e){var n=t.c,r=t.b;e.xa(r,n)(t.f,t.g,t.h).then(function(t){e.ha(r,t,null,n)}).s(function(t){e.ha(r,null,t,n)})}(t,e):Et(new qr("invalid-auth-event"))}else Et(new qr("invalid-auth-event"))},Fu.prototype.confirm=function(t){return t=Hi(this.verificationId,t),this.a(t)},qu.prototype.start=function(){this.a=this.c,function t(e,r){e.stop();e.b=Le(function(t,e){return e?(t.a=t.c,t.g()):(e=t.a,t.a*=2,t.a>t.f&&(t.a=t.f),e)}(e,r)).then(function(){return t=n.document,e=null,_r()||!t?wt():new dt(function(n){e=function(){_r()&&(t.removeEventListener("visibilitychange",e,!1),n())},t.addEventListener("visibilitychange",e,!1)}).s(function(n){throw t.removeEventListener("visibilitychange",e,!1),n});var t,e}).then(function(){return e.h()}).then(function(){t(e,!0)}).s(function(n){e.i(n)&&t(e,!1)})}(this,!0)},qu.prototype.stop=function(){this.b&&(this.b.cancel(),this.b=null)},Bu.prototype.C=function(){return{apiKey:this.f.b,refreshToken:this.a,accessToken:this.b,expirationTime:this.c}},Bu.prototype.getToken=function(t){return t=!!t,this.b&&!this.a?Et(new qr("user-token-expired")):t||!this.b||v()>this.c-3e4?this.a?ju(this,{grant_type:"refresh_token",refresh_token:this.a}):wt(null):wt({accessToken:this.b,expirationTime:this.c,refreshToken:this.a})},Ku.prototype.C=function(){return{lastLoginAt:this.b,createdAt:this.a}},b(Qu,se),b(Hu,Ae),Hu.prototype.pa=function(t){this.ka=t,hs(this.b,t)},Hu.prototype.ea=function(){return this.ka},Hu.prototype.ya=function(){return q(this.O)},Hu.prototype.Ha=function(){this.w.b&&(this.w.stop(),this.w.start())},Nr(Hu.prototype,"providerId","firebase"),(t=Hu.prototype).reload=function(){var t=this;return vc(this,ic(this).then(function(){return hc(t).then(function(){return tc(t)}).then(rc)}))},t.dc=function(t){return this.F(t).then(function(t){return new function(t){var e=oi(t);if(!(e&&e.exp&&e.auth_time&&e.iat))throw new qr("internal-error","An internal error occurred. The token obtained by Firebase appears to be malformed. Please retry the operation.");Dr(this,{token:t,expirationTime:wr(1e3*e.exp),authTime:wr(1e3*e.auth_time),issuedAtTime:wr(1e3*e.iat),signInProvider:e.firebase&&e.firebase.sign_in_provider?e.firebase.sign_in_provider:null,claims:e})}(t)})},t.F=function(t){var e=this;return vc(this,ic(this).then(function(){return e.h.getToken(t)}).then(function(t){if(!t)throw new qr("internal-error");return t.accessToken!=e.ra&&(Zu(e,t.accessToken),e.dispatchEvent(new Qu("tokenChanged"))),uc(e,"refreshToken",t.refreshToken),t.accessToken}))},t.xc=function(t){if(!(t=t.users)||!t.length)throw new qr("internal-error");nc(this,{uid:(t=t[0]).localId,displayName:t.displayName,photoURL:t.photoUrl,email:t.email,emailVerified:!!t.emailVerified,phoneNumber:t.phoneNumber,lastLoginAt:t.lastLoginAt,createdAt:t.createdAt});for(var e=function(t){return(t=t.providerUserInfo)&&t.length?P(t,function(t){return new function(t,e,n,r,i,o){Dr(this,{uid:t,displayName:r||null,photoURL:i||null,email:n||null,phoneNumber:o||null,providerId:e})}(t.rawId,t.providerId,t.email,t.displayName,t.photoUrl,t.phoneNumber)}):[]}(t),n=0;n<e.length;n++)sc(this,e[n]);uc(this,"isAnonymous",!(this.email&&t.passwordHash||this.providerData&&this.providerData.length))},t.gb=function(t){var e=this,n=null;return vc(this,t.f(this.b,this.uid).then(function(t){return lc(e,t),n=pc(e,t,"reauthenticate"),e.i=null,e.reload()}).then(function(){return n}),!0)},t.yc=function(t){return Ir("firebase.User.prototype.reauthenticateWithCredential is deprecated. Please use firebase.User.prototype.reauthenticateAndRetrieveDataWithCredential instead."),this.gb(t).then(function(){})},t.eb=function(t){var e=this,n=null;return vc(this,fc(this,t.providerId).then(function(){return e.F()}).then(function(n){return t.b(e.b,n)}).then(function(t){return n=pc(e,t,"link"),dc(e,t)}).then(function(){return n}))},t.pc=function(t){return Ir("firebase.User.prototype.linkWithCredential is deprecated. Please use firebase.User.prototype.linkAndRetrieveDataWithCredential instead."),this.eb(t).then(function(t){return t.user})},t.qc=function(t,e){var n=this;return vc(this,fc(this,"phone").then(function(){return Uu(Xu(n),t,e,m(n.eb,n))}))},t.zc=function(t,e){var n=this;return vc(this,wt().then(function(){return Uu(Xu(n),t,e,m(n.gb,n))}),!0)},t.pb=function(t){var e=this;return vc(this,this.F().then(function(n){return e.b.pb(n,t)}).then(function(t){return lc(e,t),e.reload()}))},t.Rc=function(t){var e=this;return vc(this,this.F().then(function(n){return t.b(e.b,n)}).then(function(t){return lc(e,t),e.reload()}))},t.qb=function(t){var e=this;return vc(this,this.F().then(function(n){return e.b.qb(n,t)}).then(function(t){return lc(e,t),e.reload()}))},t.rb=function(t){if(void 0===t.displayName&&void 0===t.photoURL)return ic(this);var e=this;return vc(this,this.F().then(function(n){return e.b.rb(n,{displayName:t.displayName,photoUrl:t.photoURL})}).then(function(t){return lc(e,t),uc(e,"displayName",t.displayName||null),uc(e,"photoURL",t.photoUrl||null),O(e.providerData,function(t){"password"===t.providerId&&(Nr(t,"displayName",e.displayName),Nr(t,"photoURL",e.photoURL))}),tc(e)}).then(rc))},t.Pc=function(t){var e=this;return vc(this,hc(this).then(function(n){return M(oc(e),t)?function(t,e,n){return ta(t,Os,{idToken:e,deleteProvider:n})}(e.b,n,[t]).then(function(t){var n={};return O(t.providerUserInfo||[],function(t){n[t.providerId]=!0}),O(oc(e),function(t){n[t]||ac(e,t)}),n[Qi.PROVIDER_ID]||Nr(e,"phoneNumber",null),tc(e)}):tc(e).then(function(){throw new qr("no-such-provider")})}))},t.delete=function(){var t=this;return vc(this,this.F().then(function(e){return ta(t.b,ks,{idToken:e})}).then(function(){t.dispatchEvent(new Qu("userDeleted"))})).then(function(){for(var e=0;e<t.G.length;e++)t.G[e].cancel("app-deleted");Gu(t,null),Yu(t,null),t.G=[],t.D=!0,$u(t),Nr(t,"refreshToken",null),t.a&&t.a.unsubscribe(t)})},t.vb=function(t,e){return!!("linkViaPopup"==t&&(this.g||null)==e&&this.f||"reauthViaPopup"==t&&(this.g||null)==e&&this.f||"linkViaRedirect"==t&&(this.aa||null)==e||"reauthViaRedirect"==t&&(this.aa||null)==e)},t.ha=function(t,e,n,r){"linkViaPopup"!=t&&"reauthViaPopup"!=t||r!=(this.g||null)||(n&&this.v?this.v(n):e&&!n&&this.f&&this.f(e),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.v)},t.xa=function(t,e){return"linkViaPopup"==t&&e==(this.g||null)?m(this.Ab,this):"reauthViaPopup"==t&&e==(this.g||null)?m(this.Bb,this):"linkViaRedirect"==t&&(this.aa||null)==e?m(this.Ab,this):"reauthViaRedirect"==t&&(this.aa||null)==e?m(this.Bb,this):null},t.rc=function(t){var e=this;return yc(this,"linkViaPopup",t,function(){return fc(e,t.providerId).then(function(){return tc(e)})},!1)},t.Ac=function(t){return yc(this,"reauthViaPopup",t,function(){return wt()},!0)},t.sc=function(t){var e=this;return mc(this,"linkViaRedirect",t,function(){return fc(e,t.providerId)},!1)},t.Bc=function(t){return mc(this,"reauthViaRedirect",t,function(){return wt()},!0)},t.Ab=function(t,e,n){var r=this;this.c&&(this.c.cancel(),this.c=null);var i=null;return vc(this,this.F().then(function(i){return Ss(r.b,{requestUri:t,postBody:n,sessionId:e,idToken:i})}).then(function(t){return i=pc(r,t,"link"),dc(r,t)}).then(function(){return i}))},t.Bb=function(t,e,n){var r=this;this.c&&(this.c.cancel(),this.c=null);var i=null;return vc(this,wt().then(function(){return Ti(Is(r.b,{requestUri:t,sessionId:e,postBody:n}),r.uid)}).then(function(t){return i=pc(r,t,"reauthenticate"),lc(r,t),r.i=null,r.reload()}).then(function(){return i}),!0)},t.jb=function(t){var e=this,n=null;return vc(this,this.F().then(function(e){return n=e,void 0===t||rt(t)?{}:Zr(new jr(t))}).then(function(t){return e.b.jb(n,t)}).then(function(t){if(e.email!=t)return e.reload()}).then(function(){}))},t.toJSON=function(){return this.C()},t.C=function(){var t={uid:this.uid,displayName:this.displayName,photoURL:this.photoURL,email:this.email,emailVerified:this.emailVerified,phoneNumber:this.phoneNumber,isAnonymous:this.isAnonymous,providerData:[],apiKey:this.m,appName:this.o,authDomain:this.u,stsTokenManager:this.h.C(),redirectEventId:this.aa||null};return this.metadata&&ut(t,this.metadata.C()),O(this.providerData,function(e){t.providerData.push(function(t){var e,n={};for(e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n}(e))}),t};var _c={name:"redirectUser",A:"session"};function wc(t){return $a(t.b,_c,t.a)}function Ec(t){this.a=t,this.b=Ya(),this.c=null,this.f=function(t){var e=Ic("local"),r=Ic("session"),i=Ic("none");return function(t,e,r){var i=Ja(e,r),o=Xa(t,e.A);return t.get(e,r).then(function(s){var a=null;try{a=yr(n.localStorage.getItem(i))}catch(t){}if(a&&!s)return n.localStorage.removeItem(i),t.set(e,a,r);a&&s&&"localStorage"!=o.type&&n.localStorage.removeItem(i)})}(t.b,e,t.a).then(function(){return t.b.get(r,t.a)}).then(function(n){return n?r:t.b.get(i,t.a).then(function(n){return n?i:t.b.get(e,t.a).then(function(n){return n?e:t.b.get(Sc,t.a).then(function(t){return t?Ic(t):e})})})}).then(function(e){return t.c=e,Tc(t,e.A)}).s(function(){t.c||(t.c=e)})}(this),this.b.addListener(Ic("local"),this.a,m(this.g,this))}function Tc(t,e){var n,r=[];for(n in Ga)Ga[n]!==e&&r.push($a(t.b,Ic(Ga[n]),t.a));return r.push($a(t.b,Sc,t.a)),function(t){return new dt(function(e,n){var r=t.length,i=[];if(r)for(var o=function(t,n){r--,i[t]=n,0==r&&e(i)},s=function(t){n(t)},a=0;a<t.length;a++)Tt(t[a],g(o,a),s);else e(i)})}(r)}Ec.prototype.g=function(){var t=this,e=Ic("local");Ac(this,function(){return wt().then(function(){return t.c&&"local"!=t.c.A?t.b.get(e,t.a):null}).then(function(n){if(n)return Tc(t,"local").then(function(){t.c=e})})})};var Sc={name:"persistence",A:"session"};function Ic(t){return{name:"authUser",A:t}}function Cc(t,e){return Ac(t,function(){return t.b.set(t.c,e.C(),t.a)})}function Nc(t){return Ac(t,function(){return $a(t.b,t.c,t.a)})}function Dc(t,e){return Ac(t,function(){return t.b.get(t.c,t.a).then(function(t){return t&&e&&(t.authDomain=e),bc(t||{})})})}function Ac(t,e){return t.f=t.f.then(e,e),t.f}function Rc(t){if(this.m=!1,Nr(this,"settings",new xu),Nr(this,"app",t),!Fc(this).options||!Fc(this).options.apiKey)throw new qr("invalid-api-key");t=Yn.SDK_VERSION?or(Yn.SDK_VERSION):null,this.b=new rs(Fc(this).options&&Fc(this).options.apiKey,ui(si),t),this.N=[],this.o=[],this.I=[],this.Tb=Yn.INTERNAL.createSubscribe(m(this.mc,this)),this.O=void 0,this.Ub=Yn.INTERNAL.createSubscribe(m(this.nc,this)),Mc(this,null),this.h=new Ec(Fc(this).options.apiKey+":"+Fc(this).name),this.w=new function(t){this.a=t,this.b=Ya()}(Fc(this).options.apiKey+":"+Fc(this).name),this.V=Vc(this,function(t){var e=Fc(t).options.authDomain,n=function(t){var e=function(t,e){return t.b.get(_c,t.a).then(function(t){return t&&e&&(t.authDomain=e),bc(t||{})})}(t.w,Fc(t).options.authDomain).then(function(e){return(t.D=e)&&(e.ba=t.w),wc(t.w)});return Vc(t,e)}(t).then(function(){return Dc(t.h,e)}).then(function(e){return e?(e.ba=t.w,t.D&&(t.D.aa||null)==(e.aa||null)?e:e.reload().then(function(){return Cc(t.h,e).then(function(){return e})}).s(function(n){return"auth/network-request-failed"==n.code?e:Nc(t.h)})):null}).then(function(e){Mc(t,e||null)});return Vc(t,n)}(this)),this.i=Vc(this,function(t){return t.V.then(function(){return t.fa()}).s(function(){}).then(function(){if(!t.m)return t.ka()}).s(function(){}).then(function(){if(!t.m){t.X=!0;var e=t.h;e.b.addListener(Ic("local"),e.a,t.ka)}})}(this)),this.X=!1,this.ka=m(this.Mc,this),this.Ha=m(this.Z,this),this.ra=m(this.bc,this),this.sa=m(this.jc,this),this.ta=m(this.kc,this),function(t){var e=Fc(t).options.authDomain,n=Fc(t).options.apiKey;e&&cr()&&(t.Sb=t.V.then(function(){if(!t.m){if(t.a=Ru(e,n,Fc(t).name),t.a.subscribe(t),Uc(t)&&ec(Uc(t)),t.D){ec(t.D);var r=t.D;r.pa(t.ea()),Gu(r,t),zu(r=t.D,t.G),Yu(r,t),t.D=null}return t.a}}))}(this),this.INTERNAL={},this.INTERNAL.delete=m(this.delete,this),this.INTERNAL.logFramework=m(this.tc,this),this.u=0,Ae.call(this),function(t){Object.defineProperty(t,"lc",{get:function(){return this.ea()},set:function(t){this.pa(t)},enumerable:!1}),t.W=null}(this),this.G=[]}function kc(t){se.call(this,"languageCodeChanged"),this.g=t}function Oc(t){se.call(this,"frameworkChanged"),this.c=t}function Pc(t){return t.Sb||Et(new qr("auth-domain-config-required"))}function Lc(t,e){var n={};return n.apiKey=Fc(t).options.apiKey,n.authDomain=Fc(t).options.authDomain,n.appName=Fc(t).name,t.V.then(function(){return function(t,e,n,r){var i=new Hu(t,e);return n&&(i.ba=n),r&&zu(i,r),i.reload().then(function(){return i})}(n,e,t.w,t.ya())}).then(function(e){return Uc(t)&&e.uid==Uc(t).uid?(cc(Uc(t),e),t.Z(e)):(Mc(t,e),ec(e),t.Z(e))}).then(function(){Bc(t)})}function Mc(t,e){Uc(t)&&(function(t,e){F(t.N,function(t){return t==e})}(Uc(t),t.Ha),_e(Uc(t),"tokenChanged",t.ra),_e(Uc(t),"userDeleted",t.sa),_e(Uc(t),"userInvalidated",t.ta),$u(Uc(t))),e&&(e.N.push(t.Ha),ge(e,"tokenChanged",t.ra),ge(e,"userDeleted",t.sa),ge(e,"userInvalidated",t.ta),0<t.u&&Ju(e)),Nr(t,"currentUser",e),e&&(e.pa(t.ea()),Gu(e,t),zu(e,t.G),Yu(e,t))}function xc(t,e){var n=null,r=null;return Vc(t,e.then(function(e){return n=Gi(e),r=pi(e),Lc(t,e)}).then(function(){return Ar({user:Uc(t),credential:n,additionalUserInfo:r,operationType:"signIn"})}))}function Fc(t){return t.app}function Uc(t){return t.currentUser}function qc(t){return Uc(t)&&Uc(t)._lat||null}function Bc(t){if(t.X){for(var e=0;e<t.o.length;e++)t.o[e]&&t.o[e](qc(t));if(t.O!==t.getUid()&&t.I.length)for(t.O=t.getUid(),e=0;e<t.I.length;e++)t.I[e]&&t.I[e](qc(t))}}function Vc(t,e){return t.N.push(e),e.ia(function(){x(t.N,e)}),e}function Wc(){}function jc(){this.a={},this.b=1e12}Ec.prototype.mb=function(t){var e=null,n=this;return function(t){var e=new qr("invalid-persistence-type"),n=new qr("unsupported-persistence-type");t:{for(r in Ga)if(Ga[r]==t){var r=!0;break t}r=!1}if(!r||"string"!=typeof t)throw e;switch(Zn()){case"ReactNative":if("session"===t)throw n;break;case"Node":if("none"!==t)throw n;break;default:if(!ur()&&"none"!==t)throw n}}(t),Ac(this,function(){return t!=n.c.A?n.b.get(n.c,n.a).then(function(r){return e=r,Tc(n,t)}).then(function(){if(n.c=Ic(t),e)return n.b.set(n.c,e,n.a)}):wt()})},b(Rc,Ae),b(kc,se),b(Oc,se),(t=Rc.prototype).mb=function(t){return Vc(this,t=this.h.mb(t))},t.pa=function(t){this.W===t||this.m||(this.W=t,hs(this.b,this.W),this.dispatchEvent(new kc(this.ea())))},t.ea=function(){return this.W},t.Sc=function(){var t=n.navigator;this.pa(t&&(t.languages&&t.languages[0]||t.language||t.userLanguage)||null)},t.tc=function(t){this.G.push(t),ls(this.b,Yn.SDK_VERSION?or(Yn.SDK_VERSION,this.G):null),this.dispatchEvent(new Oc(this.G))},t.ya=function(){return q(this.G)},t.toJSON=function(){return{apiKey:Fc(this).options.apiKey,authDomain:Fc(this).options.authDomain,appName:Fc(this).name,currentUser:Uc(this)&&Uc(this).C()}},t.vb=function(t,e){switch(t){case"unknown":case"signInViaRedirect":return!0;case"signInViaPopup":return this.g==e&&!!this.f;default:return!1}},t.ha=function(t,e,n,r){"signInViaPopup"==t&&this.g==r&&(n&&this.v?this.v(n):e&&!n&&this.f&&this.f(e),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.v)},t.xa=function(t,e){return"signInViaRedirect"==t||"signInViaPopup"==t&&this.g==e&&this.f?m(this.ac,this):null},t.ac=function(t,e,n){var r=this;t={requestUri:t,postBody:n,sessionId:e},this.c&&(this.c.cancel(),this.c=null);var i=null,o=null,s=Ts(r.b,t).then(function(t){return i=Gi(t),o=pi(t),t});return Vc(this,t=r.V.then(function(){return s}).then(function(t){return Lc(r,t)}).then(function(){return Ar({user:Uc(r),credential:i,additionalUserInfo:o,operationType:"signIn"})}))},t.Kc=function(t){if(!cr())return Et(new qr("operation-not-supported-in-this-environment"));var e=this,n=fi(t.providerId),r=mr(),i=null;(!fr()||Jn())&&Fc(this).options.authDomain&&t.isOAuthProvider&&(i=ya(Fc(this).options.authDomain,Fc(this).options.apiKey,Fc(this).name,"signInViaPopup",t,null,r,Yn.SDK_VERSION||null));var o=Qn(i,n&&n.Ba,n&&n.Aa);return Vc(this,n=Pc(this).then(function(e){return Nu(e,o,"signInViaPopup",t,r,!!i)}).then(function(){return new dt(function(t,n){e.ha("signInViaPopup",null,new qr("cancelled-popup-request"),e.g),e.f=t,e.v=n,e.g=r,e.c=e.a.Ea(e,"signInViaPopup",o,r)})}).then(function(t){return o&&Kn(o),t?Ar(t):null}).s(function(t){throw o&&Kn(o),t}))},t.Lc=function(t){if(!cr())return Et(new qr("operation-not-supported-in-this-environment"));var e=this;return Vc(this,Pc(this).then(function(){return Ac(t=e.h,function(){return t.b.set(Sc,t.c.A,t.a)});var t}).then(function(){return e.a.Ca("signInViaRedirect",t)}))},t.fa=function(){if(!cr())return Et(new qr("operation-not-supported-in-this-environment"));var t=this;return Vc(this,Pc(this).then(function(){return t.a.fa()}).then(function(t){return t?Ar(t):null}))},t.Qc=function(t){if(!t)return Et(new qr("null-user"));var e=this,n={};n.apiKey=Fc(this).options.apiKey,n.authDomain=Fc(this).options.authDomain,n.appName=Fc(this).name;var r=function(t,e,n,r){e=e||{apiKey:t.m,authDomain:t.u,appName:t.o};var i=t.h,o={};return o[os]=i.b,o.refreshToken=i.a,o.expiresIn=(i.c-v())/1e3,e=new Hu(e,o),n&&(e.ba=n),r&&zu(e,r),cc(e,t),e}(t,n,e.w,e.ya());return Vc(this,this.i.then(function(){if(Fc(e).options.apiKey!=t.m)return r.reload()}).then(function(){return Uc(e)&&t.uid==Uc(e).uid?(cc(Uc(e),t),e.Z(t)):(Mc(e,r),ec(r),e.Z(r))}).then(function(){Bc(e)}))},t.nb=function(){var t=this;return Vc(this,this.i.then(function(){return Uc(t)?(Mc(t,null),Nc(t.h).then(function(){Bc(t)})):wt()}))},t.Mc=function(){var t=this;return Dc(this.h,Fc(this).options.authDomain).then(function(e){if(!t.m){var n;if(n=Uc(t)&&e){n=Uc(t).uid;var r=e.uid;n=void 0!==n&&null!==n&&""!==n&&void 0!==r&&null!==r&&""!==r&&n==r}if(n)return cc(Uc(t),e),Uc(t).F();(Uc(t)||e)&&(Mc(t,e),e&&(ec(e),e.ba=t.w),t.a&&t.a.subscribe(t),Bc(t))}})},t.Z=function(t){return Cc(this.h,t)},t.bc=function(){Bc(this),this.Z(Uc(this))},t.jc=function(){this.nb()},t.kc=function(){this.nb()},t.mc=function(t){var e=this;this.addAuthTokenListener(function(){t.next(Uc(e))})},t.nc=function(t){var e=this;!function(t,e){t.I.push(e),Vc(t,t.i.then(function(){!t.m&&M(t.I,e)&&t.O!==t.getUid()&&(t.O=t.getUid(),e(qc(t)))}))}(this,function(){t.next(Uc(e))})},t.vc=function(t,e,n){var r=this;return this.X&&Yn.Promise.resolve().then(function(){h(t)?t(Uc(r)):h(t.next)&&t.next(Uc(r))}),this.Tb(t,e,n)},t.uc=function(t,e,n){var r=this;return this.X&&Yn.Promise.resolve().then(function(){r.O=r.getUid(),h(t)?t(Uc(r)):h(t.next)&&t.next(Uc(r))}),this.Ub(t,e,n)},t.cc=function(t){var e=this;return Vc(this,this.i.then(function(){return Uc(e)?Uc(e).F(t).then(function(t){return{accessToken:t}}):null}))},t.Nb=function(t){var e=this;return this.i.then(function(){return xc(e,ta(e.b,Ys,{token:t}))}).then(function(t){var n=t.user;return uc(n,"isAnonymous",!1),e.Z(n),t})},t.Ec=function(t){return Ir("firebase.auth.Auth.prototype.signInAndRetrieveDataWithCustomToken is deprecated. Please use firebase.auth.Auth.prototype.signInWithCustomToken instead."),this.Nb(t)},t.Fc=function(t,e){return Ir("firebase.auth.Auth.prototype.signInAndRetrieveDataWithEmailAndPassword is deprecated. Please use firebase.auth.Auth.prototype.signInWithEmailAndPassword instead."),this.Ob(t,e)},t.Ob=function(t,e){var n=this;return this.i.then(function(){return xc(n,ta(n.b,Xs,{email:t,password:e}))})},t.xb=function(t,e){var n=this;return this.i.then(function(){return xc(n,ta(n.b,As,{email:t,password:e}))})},t.Wb=function(t,e){return Ir("firebase.auth.Auth.prototype.createUserAndRetrieveDataWithEmailAndPassword is deprecated. Please use firebase.auth.Auth.prototype.createUserWithEmailAndPassword instead."),this.xb(t,e)},t.Hc=function(t){return Ir("firebase.auth.Auth.prototype.signInWithCredential is deprecated. Please use firebase.auth.Auth.prototype.signInAndRetrieveDataWithCredential instead."),this.Pa(t).then(function(t){return t.user})},t.Pa=function(t){var e=this;return this.i.then(function(){return xc(e,t.la(e.b))})},t.Qa=function(){var t=this;return this.i.then(function(){var e=Uc(t);return e&&e.isAnonymous?Ar({user:e,credential:null,additionalUserInfo:Ar({providerId:null,isNewUser:!1}),operationType:"signIn"}):xc(t,t.b.Qa()).then(function(e){var n=e.user;return uc(n,"isAnonymous",!0),t.Z(n),e})})},t.Gc=function(){return Ir("firebase.auth.Auth.prototype.signInAnonymouslyAndRetrieveData is deprecated. Please use firebase.auth.Auth.prototype.signInAnonymously instead."),this.Qa()},t.getUid=function(){return Uc(this)&&Uc(this).uid||null},t.Vb=function(t){this.addAuthTokenListener(t),this.u++,0<this.u&&Uc(this)&&Ju(Uc(this))},t.Cc=function(t){var e=this;O(this.o,function(n){n==t&&e.u--}),0>this.u&&(this.u=0),0==this.u&&Uc(this)&&$u(Uc(this)),this.removeAuthTokenListener(t)},t.addAuthTokenListener=function(t){var e=this;this.o.push(t),Vc(this,this.i.then(function(){e.m||M(e.o,t)&&t(qc(e))}))},t.removeAuthTokenListener=function(t){F(this.o,function(e){return e==t})},t.delete=function(){this.m=!0;for(var t=0;t<this.N.length;t++)this.N[t].cancel("app-deleted");return this.N=[],this.h&&(t=this.h).b.removeListener(Ic("local"),t.a,this.ka),this.a&&(this.a.unsubscribe(this),this.a.Ya()),Yn.Promise.resolve()},t.Zb=function(t){return Ir("firebase.auth.Auth.prototype.fetchProvidersForEmail is deprecated. Please use firebase.auth.Auth.prototype.fetchSignInMethodsForEmail instead."),Vc(this,function(t,e){return ta(t,Rs,{identifier:e,continueUri:hr()?Vn():"http://localhost"}).then(function(t){return t.allProviders||[]})}(this.b,t))},t.$b=function(t){return Vc(this,function(t,e){return ta(t,Rs,{identifier:e,continueUri:hr()?Vn():"http://localhost"}).then(function(t){return t.signinMethods||[]})}(this.b,t))},t.oc=function(t){return!!Wi(t)},t.lb=function(t,e){var n=this;return Vc(this,wt().then(function(){var t=new jr(e);if(!t.c)throw new qr("argument-error",Hr+" must be true when sending sign in link to email");return Zr(t)}).then(function(e){return n.b.lb(t,e)}).then(function(){}))},t.Tc=function(t){return this.Ja(t).then(function(t){return t.data.email})},t.Za=function(t,e){return Vc(this,this.b.Za(t,e).then(function(){}))},t.Ja=function(t){return Vc(this,this.b.Ja(t).then(function(t){return new function(t){var e={},n=t[Or],r=t[Pr];if(!(t=t[Lr])||t!=kr&&!n)throw Error("Invalid provider user info!");e[xr]=r||null,e[Mr]=n||null,Nr(this,Ur,t),Nr(this,Fr,Rr(e))}(t)}))},t.Wa=function(t){return Vc(this,this.b.Wa(t).then(function(){}))},t.kb=function(t,e){var n=this;return Vc(this,wt().then(function(){return void 0===e||rt(e)?{}:Zr(new jr(e))}).then(function(e){return n.b.kb(t,e)}).then(function(){}))},t.Jc=function(t,e){return Vc(this,Uu(this,t,e,m(this.Pa,this)))},t.Ic=function(t,e){var n=this;return Vc(this,wt().then(function(){var r=Vi(t,e||Vn());return n.Pa(r)}))},Wc.prototype.render=function(){},Wc.prototype.reset=function(){},Wc.prototype.getResponse=function(){},Wc.prototype.execute=function(){};var Kc=null;function Qc(t,e){return(e=Hc(e))&&t.a[e]||null}function Hc(t){return(t=void 0===t?1e12:t)?t.toString():null}function Gc(t,e){this.g=!1,this.c=e,this.a=this.b=null,this.h="invisible"!==this.c.size,this.f=kn(t);var n=this;this.i=function(){n.execute()},this.h?this.execute():ge(this.f,"click",this.i)}function zc(t){if(t.g)throw Error("reCAPTCHA mock was already deleted!")}function Yc(){}jc.prototype.render=function(t,e){return this.a[this.b.toString()]=new Gc(t,e),this.b++},jc.prototype.reset=function(t){var e=Qc(this,t);t=Hc(t),e&&t&&(e.delete(),delete this.a[t])},jc.prototype.getResponse=function(t){return(t=Qc(this,t))?t.getResponse():null},jc.prototype.execute=function(t){(t=Qc(this,t))&&t.execute()},Gc.prototype.getResponse=function(){return zc(this),this.b},Gc.prototype.execute=function(){zc(this);var t=this;this.a||(this.a=setTimeout(function(){t.b=function(){for(var t=50,e=[];0<t;)e.push("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(62*Math.random()))),t--;return e.join("")}();var e=t.c.callback,n=t.c["expired-callback"];if(e)try{e(t.b)}catch(t){}t.a=setTimeout(function(){if(t.a=null,t.b=null,n)try{n()}catch(t){}t.h&&t.execute()},6e4)},500))},Gc.prototype.delete=function(){zc(this),this.g=!0,clearTimeout(this.a),this.a=null,_e(this.f,"click",this.i)},Yc.prototype.g=function(){return Kc||(Kc=new jc),wt(Kc)},Yc.prototype.c=function(){};var Xc=null;function Jc(){this.b=n.grecaptcha?1/0:0,this.f=null,this.a="__rcb"+Math.floor(1e6*Math.random()).toString()}var $c=yn("https://www.google.com/recaptcha/api.js?onload=%{onload}&render=explicit&hl=%{hl}"),Zc=new br(3e4,6e4);Jc.prototype.g=function(t){var e=this;return new dt(function(r,i){var o=setTimeout(function(){i(new qr("network-request-failed"))},Zc.get());!n.grecaptcha||t!==e.f&&!e.b?(n[e.a]=function(){if(n.grecaptcha){e.f=t;var s=n.grecaptcha.render;n.grecaptcha.render=function(t,n){return t=s(t,n),e.b++,t},clearTimeout(o),r(n.grecaptcha)}else clearTimeout(o),i(new qr("internal-error"));delete n[e.a]},wt(Xo(vn($c,{onload:e.a,hl:t||""}))).s(function(){clearTimeout(o),i(new qr("internal-error","Unable to load external reCAPTCHA dependencies!"))})):(clearTimeout(o),r(n.grecaptcha))})},Jc.prototype.c=function(){this.b--};var th=null;function eh(t,e,r,i,o,s,a){if(Nr(this,"type","recaptcha"),this.c=this.f=null,this.D=!1,this.m=e,this.g=null,a?(Xc||(Xc=new Yc),a=Xc):(th||(th=new Jc),a=th),this.o=a,this.a=r||{theme:"light",type:"image"},this.h=[],this.a[ih])throw new qr("argument-error","sitekey should not be provided for reCAPTCHA as one is automatically provisioned for the current project.");if(this.i="invisible"===this.a[oh],!n.document)throw new qr("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment with DOM support.");if(!kn(e)||!this.i&&kn(e).hasChildNodes())throw new qr("argument-error","reCAPTCHA container is either not found or already contains inner elements!");this.u=new rs(t,s||null,o||null),this.v=i||function(){return null};var u=this;this.l=[];var c=this.a[nh];this.a[nh]=function(t){if(sh(u,t),"function"==typeof c)c(t);else if("string"==typeof c){var e=ar(c,n);"function"==typeof e&&e(t)}};var h=this.a[rh];this.a[rh]=function(){if(sh(u,null),"function"==typeof h)h();else if("string"==typeof h){var t=ar(h,n);"function"==typeof t&&t()}}}var nh="callback",rh="expired-callback",ih="sitekey",oh="size";function sh(t,e){for(var n=0;n<t.l.length;n++)try{t.l[n](e)}catch(t){}}function ah(t,e){return t.h.push(e),e.ia(function(){x(t.h,e)}),e}function uh(t){if(t.D)throw new qr("internal-error","RecaptchaVerifier instance has been destroyed.")}function ch(t,e,n){var r=!1;try{this.b=n||Yn.app()}catch(t){throw new qr("argument-error","No firebase.app.App instance is currently initialized.")}if(!this.b.options||!this.b.options.apiKey)throw new qr("invalid-api-key");n=this.b.options.apiKey;var i=this,o=null;try{o=this.b.auth().ya()}catch(t){}try{r=this.b.auth().settings.appVerificationDisabledForTesting}catch(t){}o=Yn.SDK_VERSION?or(Yn.SDK_VERSION,o):null,eh.call(this,n,t,e,function(){try{var t=i.b.auth().ea()}catch(e){t=null}return t},o,ui(si),r)}function hh(t,e,n,r){t:{n=Array.prototype.slice.call(n);for(var i=0,o=!1,s=0;s<e.length;s++)if(e[s].optional)o=!0;else{if(o)throw new qr("internal-error","Argument validator encountered a required argument after an optional argument.");i++}if(o=e.length,n.length<i||o<n.length)r="Expected "+(i==o?1==i?"1 argument":i+" arguments":i+"-"+o+" arguments")+" but got "+n.length+".";else{for(i=0;i<n.length;i++)if(o=e[i].optional&&void 0===n[i],!e[i].M(n[i])&&!o){if(e=e[i],0>i||i>=lh.length)throw new qr("internal-error","Argument validator received an unsupported number of arguments.");n=lh[i],r=(r?"":n+" argument ")+(e.name?'"'+e.name+'" ':"")+"must be "+e.K+".";break t}r=null}}if(r)throw new qr("argument-error",t+" failed: "+r)}(t=eh.prototype).za=function(){var t=this;return this.f?this.f:this.f=ah(this,wt().then(function(){if(hr()&&!$n())return zn();throw new qr("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment.")}).then(function(){return t.o.g(t.v())}).then(function(e){return t.g=e,ta(t.u,Bs,{})}).then(function(e){t.a[ih]=e.recaptchaSiteKey}).s(function(e){throw t.f=null,e}))},t.render=function(){uh(this);var t=this;return ah(this,this.za().then(function(){if(null===t.c){var e=t.m;if(!t.i){var n=kn(e);e=Ln("DIV"),n.appendChild(e)}t.c=t.g.render(e,t.a)}return t.c}))},t.verify=function(){uh(this);var t=this;return ah(this,this.render().then(function(e){return new dt(function(n){var r=t.g.getResponse(e);if(r)n(r);else{var i=function(e){e&&(function(t,e){F(t.l,function(t){return t==e})}(t,i),n(e))};t.l.push(i),t.i&&t.g.execute(t.c)}})}))},t.reset=function(){uh(this),null!==this.c&&this.g.reset(this.c)},t.clear=function(){uh(this),this.D=!0,this.o.c();for(var t=0;t<this.h.length;t++)this.h[t].cancel("RecaptchaVerifier instance has been destroyed.");if(!this.i){t=kn(this.m);for(var e;e=t.firstChild;)t.removeChild(e)}},b(ch,eh);var lh="First Second Third Fourth Fifth Sixth Seventh Eighth Ninth".split(" ");function fh(t,e){return{name:t||"",K:"a valid string",optional:!!e,M:r}}function ph(t,e){return{name:t||"",K:"a boolean",optional:!!e,M:i}}function dh(t,e){return{name:t||"",K:"a valid object",optional:!!e,M:l}}function yh(t,e){return{name:t||"",K:"a function",optional:!!e,M:h}}function mh(t,e){return{name:t||"",K:"null",optional:!!e,M:a}}function gh(t){return{name:t?t+"Credential":"credential",K:t?"a valid "+t+" credential":"a valid credential",optional:!1,M:function(e){if(!e)return!1;var n=!t||e.providerId===t;return!(!e.la||!n)}}}function vh(){return{name:"applicationVerifier",K:"an implementation of firebase.auth.ApplicationVerifier",optional:!1,M:function(t){return!!(t&&r(t.type)&&h(t.verify))}}}function bh(t,e,n,r){return{name:n||"",K:t.K+" or "+e.K,optional:!!r,M:function(n){return t.M(n)||e.M(n)}}}function _h(t,e){for(var n in e){var r=e[n].name;t[r]=Th(r,t[n],e[n].j)}}function wh(t,e){for(var n in e){var r=e[n].name;r!==n&&Object.defineProperty(t,r,{get:g(function(t){return this[t]},n),set:g(function(t,e,n,r){hh(t,[n],[r],!0),this[e]=r},r,n,e[n].tb),enumerable:!0})}}function Eh(t,e,n,r){t[e]=Th(e,n,r)}function Th(t,e,n){function r(){var t=Array.prototype.slice.call(arguments);return hh(o,n,t),e.apply(this,t)}if(!n)return e;var i,o=function(t){return(t=t.split("."))[t.length-1]}(t);for(i in e)r[i]=e[i];for(i in e.prototype)r.prototype[i]=e.prototype[i];return r}_h(Rc.prototype,{Wa:{name:"applyActionCode",j:[fh("code")]},Ja:{name:"checkActionCode",j:[fh("code")]},Za:{name:"confirmPasswordReset",j:[fh("code"),fh("newPassword")]},xb:{name:"createUserWithEmailAndPassword",j:[fh("email"),fh("password")]},Wb:{name:"createUserAndRetrieveDataWithEmailAndPassword",j:[fh("email"),fh("password")]},Zb:{name:"fetchProvidersForEmail",j:[fh("email")]},$b:{name:"fetchSignInMethodsForEmail",j:[fh("email")]},fa:{name:"getRedirectResult",j:[]},oc:{name:"isSignInWithEmailLink",j:[fh("emailLink")]},uc:{name:"onAuthStateChanged",j:[bh(dh(),yh(),"nextOrObserver"),yh("opt_error",!0),yh("opt_completed",!0)]},vc:{name:"onIdTokenChanged",j:[bh(dh(),yh(),"nextOrObserver"),yh("opt_error",!0),yh("opt_completed",!0)]},kb:{name:"sendPasswordResetEmail",j:[fh("email"),bh(dh("opt_actionCodeSettings",!0),mh(null,!0),"opt_actionCodeSettings",!0)]},lb:{name:"sendSignInLinkToEmail",j:[fh("email"),dh("actionCodeSettings")]},mb:{name:"setPersistence",j:[fh("persistence")]},Pa:{name:"signInAndRetrieveDataWithCredential",j:[gh()]},Qa:{name:"signInAnonymously",j:[]},Gc:{name:"signInAnonymouslyAndRetrieveData",j:[]},Hc:{name:"signInWithCredential",j:[gh()]},Nb:{name:"signInWithCustomToken",j:[fh("token")]},Ec:{name:"signInAndRetrieveDataWithCustomToken",j:[fh("token")]},Ob:{name:"signInWithEmailAndPassword",j:[fh("email"),fh("password")]},Ic:{name:"signInWithEmailLink",j:[fh("email"),fh("emailLink",!0)]},Fc:{name:"signInAndRetrieveDataWithEmailAndPassword",j:[fh("email"),fh("password")]},Jc:{name:"signInWithPhoneNumber",j:[fh("phoneNumber"),vh()]},Kc:{name:"signInWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Lc:{name:"signInWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Qc:{name:"updateCurrentUser",j:[bh({name:"user",K:"an instance of Firebase User",optional:!1,M:function(t){return!!(t&&t instanceof Hu)}},mh(),"user")]},nb:{name:"signOut",j:[]},toJSON:{name:"toJSON",j:[fh(null,!0)]},Sc:{name:"useDeviceLanguage",j:[]},Tc:{name:"verifyPasswordResetCode",j:[fh("code")]}}),wh(Rc.prototype,{lc:{name:"languageCode",tb:bh(fh(),mh(),"languageCode")}}),Rc.Persistence=Ga,Rc.Persistence.LOCAL="local",Rc.Persistence.SESSION="session",Rc.Persistence.NONE="none",_h(Hu.prototype,{delete:{name:"delete",j:[]},dc:{name:"getIdTokenResult",j:[ph("opt_forceRefresh",!0)]},F:{name:"getIdToken",j:[ph("opt_forceRefresh",!0)]},eb:{name:"linkAndRetrieveDataWithCredential",j:[gh()]},pc:{name:"linkWithCredential",j:[gh()]},qc:{name:"linkWithPhoneNumber",j:[fh("phoneNumber"),vh()]},rc:{name:"linkWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},sc:{name:"linkWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},gb:{name:"reauthenticateAndRetrieveDataWithCredential",j:[gh()]},yc:{name:"reauthenticateWithCredential",j:[gh()]},zc:{name:"reauthenticateWithPhoneNumber",j:[fh("phoneNumber"),vh()]},Ac:{name:"reauthenticateWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Bc:{name:"reauthenticateWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},reload:{name:"reload",j:[]},jb:{name:"sendEmailVerification",j:[bh(dh("opt_actionCodeSettings",!0),mh(null,!0),"opt_actionCodeSettings",!0)]},toJSON:{name:"toJSON",j:[fh(null,!0)]},Pc:{name:"unlink",j:[fh("provider")]},pb:{name:"updateEmail",j:[fh("email")]},qb:{name:"updatePassword",j:[fh("password")]},Rc:{name:"updatePhoneNumber",j:[gh("phone")]},rb:{name:"updateProfile",j:[dh("profile")]}}),_h(jc.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),_h(Wc.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),_h(dt.prototype,{ia:{name:"finally"},s:{name:"catch"},then:{name:"then"}}),wh(xu.prototype,{appVerificationDisabled:{name:"appVerificationDisabledForTesting",tb:ph("appVerificationDisabledForTesting")}}),_h(Fu.prototype,{confirm:{name:"confirm",j:[fh("verificationCode")]}}),Eh(Bi,"credential",function(t,e){return new qi(t,e)},[fh("email"),fh("password")]),_h(ki.prototype,{ua:{name:"addScope",j:[fh("scope")]},Da:{name:"setCustomParameters",j:[dh("customOAuthParameters")]}}),Eh(ki,"credential",Oi,[bh(fh(),dh(),"token")]),Eh(Bi,"credentialWithLink",Vi,[fh("email"),fh("emailLink")]),_h(Pi.prototype,{ua:{name:"addScope",j:[fh("scope")]},Da:{name:"setCustomParameters",j:[dh("customOAuthParameters")]}}),Eh(Pi,"credential",Li,[bh(fh(),dh(),"token")]),_h(Mi.prototype,{ua:{name:"addScope",j:[fh("scope")]},Da:{name:"setCustomParameters",j:[dh("customOAuthParameters")]}}),Eh(Mi,"credential",xi,[bh(fh(),bh(dh(),mh()),"idToken"),bh(fh(),mh(),"accessToken",!0)]),_h(Fi.prototype,{Da:{name:"setCustomParameters",j:[dh("customOAuthParameters")]}}),Eh(Fi,"credential",Ui,[bh(fh(),dh(),"token"),fh("secret",!0)]),_h(Ri.prototype,{ua:{name:"addScope",j:[fh("scope")]},credential:{name:"credential",j:[bh(fh(),mh(),"idToken",!0),bh(fh(),mh(),"accessToken",!0),bh(fh(),mh(),"nonce",!0)]},Da:{name:"setCustomParameters",j:[dh("customOAuthParameters")]}}),Eh(Qi,"credential",Hi,[fh("verificationId"),fh("verificationCode")]),_h(Qi.prototype,{Ua:{name:"verifyPhoneNumber",j:[fh("phoneNumber"),vh()]}}),_h(qr.prototype,{toJSON:{name:"toJSON",j:[fh(null,!0)]}}),_h(eo.prototype,{toJSON:{name:"toJSON",j:[fh(null,!0)]}}),_h(to.prototype,{toJSON:{name:"toJSON",j:[fh(null,!0)]}}),_h(ch.prototype,{clear:{name:"clear",j:[]},render:{name:"render",j:[]},verify:{name:"verify",j:[]}}),function(){if(void 0===Yn||!Yn.INTERNAL||!Yn.INTERNAL.registerService)throw Error("Cannot find the firebase namespace; be sure to include firebase-app.js before this library.");var t={Auth:Rc,Error:qr};Eh(t,"EmailAuthProvider",Bi,[]),Eh(t,"FacebookAuthProvider",ki,[]),Eh(t,"GithubAuthProvider",Pi,[]),Eh(t,"GoogleAuthProvider",Mi,[]),Eh(t,"TwitterAuthProvider",Fi,[]),Eh(t,"OAuthProvider",Ri,[fh("providerId")]),Eh(t,"SAMLAuthProvider",Ai,[fh("providerId")]),Eh(t,"PhoneAuthProvider",Qi,[{name:"auth",K:"an instance of Firebase Auth",optional:!0,M:function(t){return!!(t&&t instanceof Rc)}}]),Eh(t,"RecaptchaVerifier",ch,[bh(fh(),{name:"",K:"an HTML element",optional:!1,M:function(t){return!!(t&&t instanceof Element)}},"recaptchaContainer"),dh("recaptchaParameters",!0),{name:"app",K:"an instance of Firebase App",optional:!0,M:function(t){return!!(t&&t instanceof Yn.app.App)}}]),Yn.INTERNAL.registerService("auth",function(t,e){return e({INTERNAL:{getUid:m((t=new Rc(t)).getUid,t),getToken:m(t.cc,t),addAuthTokenListener:m(t.Vb,t),removeAuthTokenListener:m(t.Cc,t)}}),t},t,function(t,e){if("create"===t)try{e.auth()}catch(t){}}),Yn.INTERNAL.extendNamespace({User:Hu})}()}).apply("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(Gn||(Gn={}));var Xn=Gn.INFO,Jn=function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(!(e<t.logLevel)){var i=(new Date).toISOString();switch(e){case Gn.DEBUG:case Gn.VERBOSE:console.log.apply(console,["["+i+"]  "+t.name+":"].concat(n));break;case Gn.INFO:console.info.apply(console,["["+i+"]  "+t.name+":"].concat(n));break;case Gn.WARN:console.warn.apply(console,["["+i+"]  "+t.name+":"].concat(n));break;case Gn.ERROR:console.error.apply(console,["["+i+"]  "+t.name+":"].concat(n));break;default:throw new Error("Attempted to log a message with an invalid logType (value: "+e+")")}}},$n=function(){function t(t){this.name=t,this._logLevel=Xn,this._logHandler=Jn}return Object.defineProperty(t.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in Gn))throw new TypeError("Invalid value assigned to `logLevel`");this._logLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"logHandler",{get:function(){return this._logHandler},set:function(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t},enumerable:!0,configurable:!0}),t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,[this,Gn.DEBUG].concat(t))},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,[this,Gn.VERBOSE].concat(t))},t.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,[this,Gn.INFO].concat(t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,[this,Gn.WARN].concat(t))},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,[this,Gn.ERROR].concat(t))},t}(),Zn=function(){function t(t){this.domStorage_=t,this.prefix_="firebase:"}return t.prototype.set=function(t,e){null==e?this.domStorage_.removeItem(this.prefixedName_(t)):this.domStorage_.setItem(this.prefixedName_(t),En(e))},t.prototype.get=function(t){var e=this.domStorage_.getItem(this.prefixedName_(t));return null==e?null:wn(e)},t.prototype.remove=function(t){this.domStorage_.removeItem(this.prefixedName_(t))},t.prototype.prefixedName_=function(t){return this.prefix_+t},t.prototype.toString=function(){return this.domStorage_.toString()},t}(),tr=function(){function t(){this.cache_={},this.isInMemoryStorage=!0}return t.prototype.set=function(t,e){null==e?delete this.cache_[t]:this.cache_[t]=e},t.prototype.get=function(t){return Sn(this.cache_,t)?this.cache_[t]:null},t.prototype.remove=function(t){delete this.cache_[t]},t}(),er=function(t){try{if("undefined"!=typeof window&&void 0!==window[t]){var e=window[t];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new Zn(e)}}catch(t){}return new tr},nr=er("localStorage"),rr=er("sessionStorage"),ir=new $n("@firebase/database"),or=function(){var t=1;return function(){return t++}}(),sr=function(t){var e=function(t){for(var e=[],n=0,r=0;r<t.length;r++){var i=t.charCodeAt(r);if(i>=55296&&i<=56319){var o=i-55296;on(++r<t.length,"Surrogate pair missing trail surrogate."),i=65536+(o<<10)+(t.charCodeAt(r)-56320)}i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=63&i|128):i<65536?(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=63&i|128):(e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=63&i|128)}return e}(t),n=new Pn;n.update(e);var r=n.digest();return un.encodeByteArray(r)},ar=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n="",r=0;r<t.length;r++)Array.isArray(t[r])||t[r]&&"object"==typeof t[r]&&"number"==typeof t[r].length?n+=ar.apply(null,t[r]):"object"==typeof t[r]?n+=En(t[r]):n+=t[r],n+=" ";return n},ur=null,cr=!0,hr=function(t,e){on(!e||!0===t||!1===t,"Can't turn on custom loggers persistently."),!0===t?(ir.logLevel=Gn.VERBOSE,ur=ir.log.bind(ir),e&&rr.set("logging_enabled",!0)):"function"==typeof t?ur=t:(ur=null,rr.remove("logging_enabled"))},lr=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!0===cr&&(cr=!1,null===ur&&!0===rr.get("logging_enabled")&&hr(!0)),ur){var n=ar.apply(null,t);ur(n)}},fr=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];lr.apply(void 0,[t].concat(e))}},pr=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE INTERNAL ERROR: "+ar.apply(void 0,t);ir.error(n)},dr=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE FATAL ERROR: "+ar.apply(void 0,t);throw ir.error(n),new Error(n)},yr=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE WARNING: "+ar.apply(void 0,t);ir.warn(n)},mr=function(t){return"number"==typeof t&&(t!=t||t==Number.POSITIVE_INFINITY||t==Number.NEGATIVE_INFINITY)},gr="[MIN_NAME]",vr="[MAX_NAME]",br=function(t,e){if(t===e)return 0;if(t===gr||e===vr)return-1;if(e===gr||t===vr)return 1;var n=Nr(t),r=Nr(e);return null!==n?null!==r?n-r==0?t.length-e.length:n-r:-1:null!==r?1:t<e?-1:1},_r=function(t,e){return t===e?0:t<e?-1:1},wr=function(t,e){if(e&&t in e)return e[t];throw new Error("Missing required key ("+t+") in object: "+En(e))},Er=function(t){if("object"!=typeof t||null===t)return En(t);var e=[];for(var n in t)e.push(n);e.sort();for(var r="{",i=0;i<e.length;i++)0!==i&&(r+=","),r+=En(e[i]),r+=":",r+=Er(t[e[i]]);return r+="}"},Tr=function(t,e){var n=t.length;if(n<=e)return[t];for(var r=[],i=0;i<n;i+=e)i+e>n?r.push(t.substring(i,n)):r.push(t.substring(i,i+e));return r},Sr=function(t,e){if(Array.isArray(t))for(var n=0;n<t.length;++n)e(n,t[n]);else Cn(t,function(t,n){return e(n,t)})},Ir=function(t){on(!mr(t),"Invalid JSON number");var e,n,r,i,o,s,a;for(0===t?(n=0,r=0,e=1/t==-1/0?1:0):(e=t<0,(t=Math.abs(t))>=Math.pow(2,-1022)?(n=(i=Math.min(Math.floor(Math.log(t)/Math.LN2),1023))+1023,r=Math.round(t*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,r=Math.round(t/Math.pow(2,-1074)))),s=[],o=52;o;o-=1)s.push(r%2?1:0),r=Math.floor(r/2);for(o=11;o;o-=1)s.push(n%2?1:0),n=Math.floor(n/2);s.push(e?1:0),s.reverse(),a=s.join("");var u="";for(o=0;o<64;o+=8){var c=parseInt(a.substr(o,8),2).toString(16);1===c.length&&(c="0"+c),u+=c}return u.toLowerCase()},Cr=new RegExp("^-?\\d{1,10}$"),Nr=function(t){if(Cr.test(t)){var e=Number(t);if(e>=-2147483648&&e<=2147483647)return e}return null},Dr=function(t){try{t()}catch(t){setTimeout(function(){var e=t.stack||"";throw yr("Exception was thrown by user callback.",e),t},Math.floor(0))}},Ar=function(){return("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},Rr=function(t,e){var n=setTimeout(t,e);return"object"==typeof n&&n.unref&&n.unref(),n},kr=function(){function t(t,e){if(void 0===e){this.pieces_=t.split("/");for(var n=0,r=0;r<this.pieces_.length;r++)this.pieces_[r].length>0&&(this.pieces_[n]=this.pieces_[r],n++);this.pieces_.length=n,this.pieceNum_=0}else this.pieces_=t,this.pieceNum_=e}return Object.defineProperty(t,"Empty",{get:function(){return new t("")},enumerable:!0,configurable:!0}),t.prototype.getFront=function(){return this.pieceNum_>=this.pieces_.length?null:this.pieces_[this.pieceNum_]},t.prototype.getLength=function(){return this.pieces_.length-this.pieceNum_},t.prototype.popFront=function(){var e=this.pieceNum_;return e<this.pieces_.length&&e++,new t(this.pieces_,e)},t.prototype.getBack=function(){return this.pieceNum_<this.pieces_.length?this.pieces_[this.pieces_.length-1]:null},t.prototype.toString=function(){for(var t="",e=this.pieceNum_;e<this.pieces_.length;e++)""!==this.pieces_[e]&&(t+="/"+this.pieces_[e]);return t||"/"},t.prototype.toUrlEncodedString=function(){for(var t="",e=this.pieceNum_;e<this.pieces_.length;e++)""!==this.pieces_[e]&&(t+="/"+encodeURIComponent(String(this.pieces_[e])));return t||"/"},t.prototype.slice=function(t){return void 0===t&&(t=0),this.pieces_.slice(this.pieceNum_+t)},t.prototype.parent=function(){if(this.pieceNum_>=this.pieces_.length)return null;for(var e=[],n=this.pieceNum_;n<this.pieces_.length-1;n++)e.push(this.pieces_[n]);return new t(e,0)},t.prototype.child=function(e){for(var n=[],r=this.pieceNum_;r<this.pieces_.length;r++)n.push(this.pieces_[r]);if(e instanceof t)for(r=e.pieceNum_;r<e.pieces_.length;r++)n.push(e.pieces_[r]);else{var i=e.split("/");for(r=0;r<i.length;r++)i[r].length>0&&n.push(i[r])}return new t(n,0)},t.prototype.isEmpty=function(){return this.pieceNum_>=this.pieces_.length},t.relativePath=function(e,n){var r=e.getFront(),i=n.getFront();if(null===r)return n;if(r===i)return t.relativePath(e.popFront(),n.popFront());throw new Error("INTERNAL ERROR: innerPath ("+n+") is not within outerPath ("+e+")")},t.comparePaths=function(t,e){for(var n=t.slice(),r=e.slice(),i=0;i<n.length&&i<r.length;i++){var o=br(n[i],r[i]);if(0!==o)return o}return n.length===r.length?0:n.length<r.length?-1:1},t.prototype.equals=function(t){if(this.getLength()!==t.getLength())return!1;for(var e=this.pieceNum_,n=t.pieceNum_;e<=this.pieces_.length;e++,n++)if(this.pieces_[e]!==t.pieces_[n])return!1;return!0},t.prototype.contains=function(t){var e=this.pieceNum_,n=t.pieceNum_;if(this.getLength()>t.getLength())return!1;for(;e<this.pieces_.length;){if(this.pieces_[e]!==t.pieces_[n])return!1;++e,++n}return!0},t}(),Or=function(){function t(t,e){this.errorPrefix_=e,this.parts_=t.slice(),this.byteLength_=Math.max(1,this.parts_.length);for(var n=0;n<this.parts_.length;n++)this.byteLength_+=Vn(this.parts_[n]);this.checkValid_()}return Object.defineProperty(t,"MAX_PATH_DEPTH",{get:function(){return 32},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MAX_PATH_LENGTH_BYTES",{get:function(){return 768},enumerable:!0,configurable:!0}),t.prototype.push=function(t){this.parts_.length>0&&(this.byteLength_+=1),this.parts_.push(t),this.byteLength_+=Vn(t),this.checkValid_()},t.prototype.pop=function(){var t=this.parts_.pop();this.byteLength_-=Vn(t),this.parts_.length>0&&(this.byteLength_-=1)},t.prototype.checkValid_=function(){if(this.byteLength_>t.MAX_PATH_LENGTH_BYTES)throw new Error(this.errorPrefix_+"has a key path longer than "+t.MAX_PATH_LENGTH_BYTES+" bytes ("+this.byteLength_+").");if(this.parts_.length>t.MAX_PATH_DEPTH)throw new Error(this.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+t.MAX_PATH_DEPTH+") or object contains a cycle "+this.toErrorString())},t.prototype.toErrorString=function(){return 0==this.parts_.length?"":"in property '"+this.parts_.join(".")+"'"},t}(),Pr="long_polling",Lr=function(){function t(t,e,n,r,i){void 0===i&&(i=""),this.secure=e,this.namespace=n,this.webSocketOnly=r,this.persistenceKey=i,this.host=t.toLowerCase(),this.domain=this.host.substr(this.host.indexOf(".")+1),this.internalHost=nr.get("host:"+t)||this.host}return t.prototype.needsQueryParam=function(){return this.host!==this.internalHost||this.isCustomHost()},t.prototype.isCacheableHost=function(){return"s-"===this.internalHost.substr(0,2)},t.prototype.isDemoHost=function(){return"firebaseio-demo.com"===this.domain},t.prototype.isCustomHost=function(){return"firebaseio.com"!==this.domain&&"firebaseio-demo.com"!==this.domain},t.prototype.updateHost=function(t){t!==this.internalHost&&(this.internalHost=t,this.isCacheableHost()&&nr.set("host:"+this.host,this.internalHost))},t.prototype.connectionURL=function(t,e){var n;if(on("string"==typeof t,"typeof type must == string"),on("object"==typeof e,"typeof params must == object"),"websocket"===t)n=(this.secure?"wss://":"ws://")+this.internalHost+"/.ws?";else{if(t!==Pr)throw new Error("Unknown connection type: "+t);n=(this.secure?"https://":"http://")+this.internalHost+"/.lp?"}this.needsQueryParam()&&(e.ns=this.namespace);var r=[];return Cn(e,function(t,e){r.push(t+"="+e)}),n+r.join("&")},t.prototype.toString=function(){var t=this.toURLString();return this.persistenceKey&&(t+="<"+this.persistenceKey+">"),t},t.prototype.toURLString=function(){return(this.secure?"https://":"http://")+this.host},t}();var Mr,xr,Fr,Ur,qr,Br=function(t){var e=Vr(t),n=e.subdomain;"firebase"===e.domain&&dr(e.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),n&&"undefined"!=n||"localhost"===e.domain||dr("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),e.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&yr("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");var r="ws"===e.scheme||"wss"===e.scheme;return{repoInfo:new Lr(e.host,e.secure,n,r),path:new kr(e.pathString)}},Vr=function(t){var e="",n="",r="",i="",o=!0,s="https",a=443;if("string"==typeof t){var u=t.indexOf("//");u>=0&&(s=t.substring(0,u-1),t=t.substring(u+2));var c=t.indexOf("/");-1===c&&(c=t.length);var h=t.indexOf("?");-1===h&&(h=t.length),e=t.substring(0,Math.min(c,h)),c<h&&(i=function(t){for(var e="",n=t.split("/"),r=0;r<n.length;r++)if(n[r].length>0){var i=n[r];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch(t){}e+="/"+i}return e}(t.substring(c,h)));var l=function(t){var e={};"?"===t.charAt(0)&&(t=t.substring(1));for(var n=0,r=t.split("&");n<r.length;n++){var i=r[n];if(0!==i.length){var o=i.split("=");2===o.length?e[decodeURIComponent(o[0])]=decodeURIComponent(o[1]):yr("Invalid query segment '"+i+"' in query '"+t+"'")}}return e}(t.substring(Math.min(t.length,h)));(u=e.indexOf(":"))>=0?(o="https"===s||"wss"===s,a=parseInt(e.substring(u+1),10)):u=t.length;var f=e.split(".");3===f.length?(n=f[1],r=f[0].toLowerCase()):2===f.length?n=f[0]:"localhost"===f[0].slice(0,u).toLowerCase()&&(n="localhost"),""===r&&"ns"in l&&(r=l.ns)}return{host:e,port:a,domain:n,subdomain:r,secure:o,scheme:s,pathString:i}},Wr=/[\[\].#$\/\u0000-\u001F\u007F]/,jr=/[\[\].#$\u0000-\u001F\u007F]/,Kr=function(t){return"string"==typeof t&&0!==t.length&&!Wr.test(t)},Qr=function(t){return"string"==typeof t&&0!==t.length&&!jr.test(t)},Hr=function(t){return null===t||"string"==typeof t||"number"==typeof t&&!mr(t)||t&&"object"==typeof t&&Sn(t,".sv")},Gr=function(t,e,n,r,i){i&&void 0===n||zr(Un(t,e,i),n,r)},zr=function(t,e,n){var r=n instanceof kr?new Or(n,t):n;if(void 0===e)throw new Error(t+"contains undefined "+r.toErrorString());if("function"==typeof e)throw new Error(t+"contains a function "+r.toErrorString()+" with contents = "+e.toString());if(mr(e))throw new Error(t+"contains "+e.toString()+" "+r.toErrorString());if("string"==typeof e&&e.length>10485760/3&&Vn(e)>10485760)throw new Error(t+"contains a string greater than 10485760 utf8 bytes "+r.toErrorString()+" ('"+e.substring(0,50)+"...')");if(e&&"object"==typeof e){var i=!1,o=!1;if(Cn(e,function(e,n){if(".value"===e)i=!0;else if(".priority"!==e&&".sv"!==e&&(o=!0,!Kr(e)))throw new Error(t+" contains an invalid key ("+e+") "+r.toErrorString()+'.  Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');r.push(e),zr(t,n,r),r.pop()}),i&&o)throw new Error(t+' contains ".value" child '+r.toErrorString()+" in addition to actual children.")}},Yr=function(t,e,n,r,i){if(!i||void 0!==n){var o=Un(t,e,i);if(!n||"object"!=typeof n||Array.isArray(n))throw new Error(o+" must be an object containing the children to replace.");var s=[];Cn(n,function(t,e){var n=new kr(t);if(zr(o,e,r.child(n)),".priority"===n.getBack()&&!Hr(e))throw new Error(o+"contains an invalid value for '"+n.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");s.push(n)}),function(t,e){var n,r;for(n=0;n<e.length;n++)for(var i=(r=e[n]).slice(),o=0;o<i.length;o++)if(".priority"===i[o]&&o===i.length-1);else if(!Kr(i[o]))throw new Error(t+"contains an invalid key ("+i[o]+") in path "+r.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');e.sort(kr.comparePaths);var s=null;for(n=0;n<e.length;n++){if(r=e[n],null!==s&&s.contains(r))throw new Error(t+"contains a path "+s.toString()+" that is ancestor of another path "+r.toString());s=r}}(o,s)}},Xr=function(t,e,n,r){if(!r||void 0!==n){if(mr(n))throw new Error(Un(t,e,r)+"is "+n.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!Hr(n))throw new Error(Un(t,e,r)+"must be a valid Firebase priority (a string, finite number, server value, or null).")}},Jr=function(t,e,n,r){if(!r||void 0!==n)switch(n){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:throw new Error(Un(t,e,r)+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}},$r=function(t,e,n,r){if(!(r&&void 0===n||Kr(n)))throw new Error(Un(t,e,r)+'was an invalid key = "'+n+'".  Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')},Zr=function(t,e,n,r){if(!(r&&void 0===n||Qr(n)))throw new Error(Un(t,e,r)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},ti=function(t,e){if(".info"===e.getFront())throw new Error(t+" failed = Can't modify data under /.info/")},ei=function(t,e,n){var r=n.path.toString();if("string"!=typeof n.repoInfo.host||0===n.repoInfo.host.length||!Kr(n.repoInfo.namespace)&&"localhost"!==n.repoInfo.host.split(":")[0]||0!==r.length&&!function(t){return t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),Qr(t)}(r))throw new Error(Un(t,e,!1)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')},ni=function(){function t(t,e){this.repo_=t,this.path_=e}return t.prototype.cancel=function(t){Fn("OnDisconnect.cancel",0,1,arguments.length),qn("OnDisconnect.cancel",1,t,!0);var e=new pn;return this.repo_.onDisconnectCancel(this.path_,e.wrapCallback(t)),e.promise},t.prototype.remove=function(t){Fn("OnDisconnect.remove",0,1,arguments.length),ti("OnDisconnect.remove",this.path_),qn("OnDisconnect.remove",1,t,!0);var e=new pn;return this.repo_.onDisconnectSet(this.path_,null,e.wrapCallback(t)),e.promise},t.prototype.set=function(t,e){Fn("OnDisconnect.set",1,2,arguments.length),ti("OnDisconnect.set",this.path_),Gr("OnDisconnect.set",1,t,this.path_,!1),qn("OnDisconnect.set",2,e,!0);var n=new pn;return this.repo_.onDisconnectSet(this.path_,t,n.wrapCallback(e)),n.promise},t.prototype.setWithPriority=function(t,e,n){Fn("OnDisconnect.setWithPriority",2,3,arguments.length),ti("OnDisconnect.setWithPriority",this.path_),Gr("OnDisconnect.setWithPriority",1,t,this.path_,!1),Xr("OnDisconnect.setWithPriority",2,e,!1),qn("OnDisconnect.setWithPriority",3,n,!0);var r=new pn;return this.repo_.onDisconnectSetWithPriority(this.path_,t,e,r.wrapCallback(n)),r.promise},t.prototype.update=function(t,e){if(Fn("OnDisconnect.update",1,2,arguments.length),ti("OnDisconnect.update",this.path_),Array.isArray(t)){for(var n={},r=0;r<t.length;++r)n[""+r]=t[r];t=n,yr("Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}Yr("OnDisconnect.update",1,t,this.path_,!1),qn("OnDisconnect.update",2,e,!0);var i=new pn;return this.repo_.onDisconnectUpdate(this.path_,t,i.wrapCallback(e)),i.promise},t}(),ri=function(){function t(t,e){this.committed=t,this.snapshot=e}return t.prototype.toJSON=function(){return Fn("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}},t}(),ii=(Mr="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",xr=0,Fr=[],function(t){var e,n=t===xr;xr=t;var r=new Array(8);for(e=7;e>=0;e--)r[e]=Mr.charAt(t%64),t=Math.floor(t/64);on(0===t,"Cannot push at time == 0");var i=r.join("");if(n){for(e=11;e>=0&&63===Fr[e];e--)Fr[e]=0;Fr[e]++}else for(e=0;e<12;e++)Fr[e]=Math.floor(64*Math.random());for(e=0;e<12;e++)i+=Mr.charAt(Fr[e]);return on(20===i.length,"nextPushId: Length should be 20."),i}),oi=function(){function t(t,e){this.name=t,this.node=e}return t.Wrap=function(e,n){return new t(e,n)},t}(),si=function(){function t(){}return t.prototype.getCompare=function(){return this.compare.bind(this)},t.prototype.indexedValueChanged=function(t,e){var n=new oi(gr,t),r=new oi(gr,e);return 0!==this.compare(n,r)},t.prototype.minPost=function(){return oi.MIN},t}(),ai=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Je(e,t),Object.defineProperty(e,"__EMPTY_NODE",{get:function(){return Ur},set:function(t){Ur=t},enumerable:!0,configurable:!0}),e.prototype.compare=function(t,e){return br(t.name,e.name)},e.prototype.isDefinedOn=function(t){throw sn("KeyIndex.isDefinedOn not expected to be called.")},e.prototype.indexedValueChanged=function(t,e){return!1},e.prototype.minPost=function(){return oi.MIN},e.prototype.maxPost=function(){return new oi(vr,Ur)},e.prototype.makePost=function(t,e){return on("string"==typeof t,"KeyIndex indexValue must always be a string."),new oi(t,Ur)},e.prototype.toString=function(){return".key"},e}(si),ui=new ai;var ci,hi,li,fi=function(t){return"number"==typeof t?"number:"+Ir(t):"string:"+t},pi=function(t){if(t.isLeafNode()){var e=t.val();on("string"==typeof e||"number"==typeof e||"object"==typeof e&&Sn(e,".sv"),"Priority must be a string or number.")}else on(t===qr||t.isEmpty(),"priority of unexpected type.");on(t===qr||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")},di=function(){function t(e,n){void 0===n&&(n=t.__childrenNodeConstructor.EMPTY_NODE),this.value_=e,this.priorityNode_=n,this.lazyHash_=null,on(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),pi(this.priorityNode_)}return Object.defineProperty(t,"__childrenNodeConstructor",{get:function(){return ci},set:function(t){ci=t},enumerable:!0,configurable:!0}),t.prototype.isLeafNode=function(){return!0},t.prototype.getPriority=function(){return this.priorityNode_},t.prototype.updatePriority=function(e){return new t(this.value_,e)},t.prototype.getImmediateChild=function(e){return".priority"===e?this.priorityNode_:t.__childrenNodeConstructor.EMPTY_NODE},t.prototype.getChild=function(e){return e.isEmpty()?this:".priority"===e.getFront()?this.priorityNode_:t.__childrenNodeConstructor.EMPTY_NODE},t.prototype.hasChild=function(){return!1},t.prototype.getPredecessorChildName=function(t,e){return null},t.prototype.updateImmediateChild=function(e,n){return".priority"===e?this.updatePriority(n):n.isEmpty()&&".priority"!==e?this:t.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,n).updatePriority(this.priorityNode_)},t.prototype.updateChild=function(e,n){var r=e.getFront();return null===r?n:n.isEmpty()&&".priority"!==r?this:(on(".priority"!==r||1===e.getLength(),".priority must be the last token in a path"),this.updateImmediateChild(r,t.__childrenNodeConstructor.EMPTY_NODE.updateChild(e.popFront(),n)))},t.prototype.isEmpty=function(){return!1},t.prototype.numChildren=function(){return 0},t.prototype.forEachChild=function(t,e){return!1},t.prototype.val=function(t){return t&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()},t.prototype.hash=function(){if(null===this.lazyHash_){var t="";this.priorityNode_.isEmpty()||(t+="priority:"+fi(this.priorityNode_.val())+":");var e=typeof this.value_;t+=e+":",t+="number"===e?Ir(this.value_):this.value_,this.lazyHash_=sr(t)}return this.lazyHash_},t.prototype.getValue=function(){return this.value_},t.prototype.compareTo=function(e){return e===t.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof t.__childrenNodeConstructor?-1:(on(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))},t.prototype.compareToLeafNode_=function(e){var n=typeof e.value_,r=typeof this.value_,i=t.VALUE_TYPE_ORDER.indexOf(n),o=t.VALUE_TYPE_ORDER.indexOf(r);return on(i>=0,"Unknown leaf type: "+n),on(o>=0,"Unknown leaf type: "+r),i===o?"object"===r?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:o-i},t.prototype.withIndex=function(){return this},t.prototype.isIndexed=function(){return!0},t.prototype.equals=function(t){if(t===this)return!0;if(t.isLeafNode()){var e=t;return this.value_===e.value_&&this.priorityNode_.equals(e.priorityNode_)}return!1},t.VALUE_TYPE_ORDER=["object","boolean","number","string"],t}();var yi,mi,gi=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Je(e,t),e.prototype.compare=function(t,e){var n=t.node.getPriority(),r=e.node.getPriority(),i=n.compareTo(r);return 0===i?br(t.name,e.name):i},e.prototype.isDefinedOn=function(t){return!t.getPriority().isEmpty()},e.prototype.indexedValueChanged=function(t,e){return!t.getPriority().equals(e.getPriority())},e.prototype.minPost=function(){return oi.MIN},e.prototype.maxPost=function(){return new oi(vr,new di("[PRIORITY-POST]",li))},e.prototype.makePost=function(t,e){var n=hi(t);return new oi(e,new di("[PRIORITY-POST]",n))},e.prototype.toString=function(){return".priority"},e}(si)),vi=function(){function t(t,e,n,r,i){void 0===i&&(i=null),this.isReverse_=r,this.resultGenerator_=i,this.nodeStack_=[];for(var o=1;!t.isEmpty();)if(t=t,o=e?n(t.key,e):1,r&&(o*=-1),o<0)t=this.isReverse_?t.left:t.right;else{if(0===o){this.nodeStack_.push(t);break}this.nodeStack_.push(t),t=this.isReverse_?t.right:t.left}}return t.prototype.getNext=function(){if(0===this.nodeStack_.length)return null;var t,e=this.nodeStack_.pop();if(t=this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value},this.isReverse_)for(e=e.left;!e.isEmpty();)this.nodeStack_.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack_.push(e),e=e.left;return t},t.prototype.hasNext=function(){return this.nodeStack_.length>0},t.prototype.peek=function(){if(0===this.nodeStack_.length)return null;var t=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value}},t}(),bi=function(){function t(e,n,r,i,o){this.key=e,this.value=n,this.color=null!=r?r:t.RED,this.left=null!=i?i:wi.EMPTY_NODE,this.right=null!=o?o:wi.EMPTY_NODE}return t.prototype.copy=function(e,n,r,i,o){return new t(null!=e?e:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},t.prototype.count=function(){return this.left.count()+1+this.right.count()},t.prototype.isEmpty=function(){return!1},t.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},t.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},t.prototype.min_=function(){return this.left.isEmpty()?this:this.left.min_()},t.prototype.minKey=function(){return this.min_().key},t.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},t.prototype.insert=function(t,e,n){var r,i;return(i=(r=n(t,(i=this).key))<0?i.copy(null,null,null,i.left.insert(t,e,n),null):0===r?i.copy(null,e,null,null,null):i.copy(null,null,null,null,i.right.insert(t,e,n))).fixUp_()},t.prototype.removeMin_=function(){if(this.left.isEmpty())return wi.EMPTY_NODE;var t=this;return t.left.isRed_()||t.left.left.isRed_()||(t=t.moveRedLeft_()),(t=t.copy(null,null,null,t.left.removeMin_(),null)).fixUp_()},t.prototype.remove=function(t,e){var n,r;if(e(t,(n=this).key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(t,e),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===e(t,n.key)){if(n.right.isEmpty())return wi.EMPTY_NODE;r=n.right.min_(),n=n.copy(r.key,r.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(t,e))}return n.fixUp_()},t.prototype.isRed_=function(){return this.color},t.prototype.fixUp_=function(){var t=this;return t.right.isRed_()&&!t.left.isRed_()&&(t=t.rotateLeft_()),t.left.isRed_()&&t.left.left.isRed_()&&(t=t.rotateRight_()),t.left.isRed_()&&t.right.isRed_()&&(t=t.colorFlip_()),t},t.prototype.moveRedLeft_=function(){var t=this.colorFlip_();return t.right.left.isRed_()&&(t=(t=(t=t.copy(null,null,null,null,t.right.rotateRight_())).rotateLeft_()).colorFlip_()),t},t.prototype.moveRedRight_=function(){var t=this.colorFlip_();return t.left.left.isRed_()&&(t=(t=t.rotateRight_()).colorFlip_()),t},t.prototype.rotateLeft_=function(){var e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)},t.prototype.rotateRight_=function(){var e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)},t.prototype.colorFlip_=function(){var t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)},t.prototype.checkMaxDepth_=function(){var t=this.check_();return Math.pow(2,t)<=this.count()+1},t.prototype.check_=function(){var t;if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");if((t=this.left.check_())!==this.right.check_())throw new Error("Black depths differ");return t+(this.isRed_()?0:1)},t.RED=!0,t.BLACK=!1,t}(),_i=function(){function t(){}return t.prototype.copy=function(t,e,n,r,i){return this},t.prototype.insert=function(t,e,n){return new bi(t,e,null)},t.prototype.remove=function(t,e){return this},t.prototype.count=function(){return 0},t.prototype.isEmpty=function(){return!0},t.prototype.inorderTraversal=function(t){return!1},t.prototype.reverseTraversal=function(t){return!1},t.prototype.minKey=function(){return null},t.prototype.maxKey=function(){return null},t.prototype.check_=function(){return 0},t.prototype.isRed_=function(){return!1},t}(),wi=function(){function t(e,n){void 0===n&&(n=t.EMPTY_NODE),this.comparator_=e,this.root_=n}return t.prototype.insert=function(e,n){return new t(this.comparator_,this.root_.insert(e,n,this.comparator_).copy(null,null,bi.BLACK,null,null))},t.prototype.remove=function(e){return new t(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,bi.BLACK,null,null))},t.prototype.get=function(t){for(var e,n=this.root_;!n.isEmpty();){if(0===(e=this.comparator_(t,n.key)))return n.value;e<0?n=n.left:e>0&&(n=n.right)}return null},t.prototype.getPredecessorKey=function(t){for(var e,n=this.root_,r=null;!n.isEmpty();){if(0===(e=this.comparator_(t,n.key))){if(n.left.isEmpty())return r?r.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}e<0?n=n.left:e>0&&(r=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key.  What gives?")},t.prototype.isEmpty=function(){return this.root_.isEmpty()},t.prototype.count=function(){return this.root_.count()},t.prototype.minKey=function(){return this.root_.minKey()},t.prototype.maxKey=function(){return this.root_.maxKey()},t.prototype.inorderTraversal=function(t){return this.root_.inorderTraversal(t)},t.prototype.reverseTraversal=function(t){return this.root_.reverseTraversal(t)},t.prototype.getIterator=function(t){return new vi(this.root_,null,this.comparator_,!1,t)},t.prototype.getIteratorFrom=function(t,e){return new vi(this.root_,t,this.comparator_,!1,e)},t.prototype.getReverseIteratorFrom=function(t,e){return new vi(this.root_,t,this.comparator_,!0,e)},t.prototype.getReverseIterator=function(t){return new vi(this.root_,null,this.comparator_,!0,t)},t.EMPTY_NODE=new _i,t}(),Ei=Math.log(2),Ti=function(){function t(t){var e;this.count=(e=t+1,parseInt(Math.log(e)/Ei,10)),this.current_=this.count-1;var n,r=(n=this.count,parseInt(Array(n+1).join("1"),2));this.bits_=t+1&r}return t.prototype.nextBitIsOne=function(){var t=!(this.bits_&1<<this.current_);return this.current_--,t},t}(),Si=function(t,e,n,r){t.sort(e);var i=function(e,r){var o,s,a=r-e;if(0==a)return null;if(1==a)return o=t[e],s=n?n(o):o,new bi(s,o.node,bi.BLACK,null,null);var u=parseInt(a/2,10)+e,c=i(e,u),h=i(u+1,r);return o=t[u],s=n?n(o):o,new bi(s,o.node,bi.BLACK,c,h)},o=function(e){for(var r=null,o=null,s=t.length,a=function(e,r){var o=s-e,a=s;s-=e;var c=i(o+1,a),h=t[o],l=n?n(h):h;u(new bi(l,h.node,r,null,c))},u=function(t){r?(r.left=t,r=t):(o=t,r=t)},c=0;c<e.count;++c){var h=e.nextBitIsOne(),l=Math.pow(2,e.count-(c+1));h?a(l,bi.BLACK):(a(l,bi.BLACK),a(l,bi.RED))}return o}(new Ti(t.length));return new wi(r||e,o)},Ii={},Ci=function(){function t(t,e){this.indexes_=t,this.indexSet_=e}return Object.defineProperty(t,"Default",{get:function(){return on(Ii&&gi,"ChildrenNode.ts has not been loaded"),yi=yi||new t({".priority":Ii},{".priority":gi})},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var e=In(this.indexes_,t);if(!e)throw new Error("No index defined for "+t);return e===Ii?null:e},t.prototype.hasIndex=function(t){return Sn(this.indexSet_,t.toString())},t.prototype.addIndex=function(e,n){on(e!==ui,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var r,i=[],o=!1,s=n.getIterator(oi.Wrap),a=s.getNext();a;)o=o||e.isDefinedOn(a.node),i.push(a),a=s.getNext();r=o?Si(i,e.getCompare()):Ii;var u=e.toString(),c=Nn(this.indexSet_);c[u]=e;var h=Nn(this.indexes_);return h[u]=r,new t(h,c)},t.prototype.addToIndexes=function(e,n){var r=this;return new t(Rn(this.indexes_,function(t,i){var o=In(r.indexSet_,i);if(on(o,"Missing index implementation for "+i),t===Ii){if(o.isDefinedOn(e.node)){for(var s=[],a=n.getIterator(oi.Wrap),u=a.getNext();u;)u.name!=e.name&&s.push(u),u=a.getNext();return s.push(e),Si(s,o.getCompare())}return Ii}var c=n.get(e.name),h=t;return c&&(h=h.remove(new oi(e.name,c))),h.insert(e,e.node)}),this.indexSet_)},t.prototype.removeFromIndexes=function(e,n){return new t(Rn(this.indexes_,function(t){if(t===Ii)return t;var r=n.get(e.name);return r?t.remove(new oi(e.name,r)):t}),this.indexSet_)},t}();function Ni(t,e){return br(t.name,e.name)}function Di(t,e){return br(t,e)}var Ai=function(){function t(t,e,n){this.children_=t,this.priorityNode_=e,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&pi(this.priorityNode_),this.children_.isEmpty()&&on(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}return Object.defineProperty(t,"EMPTY_NODE",{get:function(){return mi||(mi=new t(new wi(Di),null,Ci.Default))},enumerable:!0,configurable:!0}),t.prototype.isLeafNode=function(){return!1},t.prototype.getPriority=function(){return this.priorityNode_||mi},t.prototype.updatePriority=function(e){return this.children_.isEmpty()?this:new t(this.children_,e,this.indexMap_)},t.prototype.getImmediateChild=function(t){if(".priority"===t)return this.getPriority();var e=this.children_.get(t);return null===e?mi:e},t.prototype.getChild=function(t){var e=t.getFront();return null===e?this:this.getImmediateChild(e).getChild(t.popFront())},t.prototype.hasChild=function(t){return null!==this.children_.get(t)},t.prototype.updateImmediateChild=function(e,n){if(on(n,"We should always be passing snapshot nodes"),".priority"===e)return this.updatePriority(n);var r=new oi(e,n),i=void 0,o=void 0;return n.isEmpty()?(i=this.children_.remove(e),o=this.indexMap_.removeFromIndexes(r,this.children_)):(i=this.children_.insert(e,n),o=this.indexMap_.addToIndexes(r,this.children_)),new t(i,i.isEmpty()?mi:this.priorityNode_,o)},t.prototype.updateChild=function(t,e){var n=t.getFront();if(null===n)return e;on(".priority"!==t.getFront()||1===t.getLength(),".priority must be the last token in a path");var r=this.getImmediateChild(n).updateChild(t.popFront(),e);return this.updateImmediateChild(n,r)},t.prototype.isEmpty=function(){return this.children_.isEmpty()},t.prototype.numChildren=function(){return this.children_.count()},t.prototype.val=function(e){if(this.isEmpty())return null;var n={},r=0,i=0,o=!0;if(this.forEachChild(gi,function(s,a){n[s]=a.val(e),r++,o&&t.INTEGER_REGEXP_.test(s)?i=Math.max(i,Number(s)):o=!1}),!e&&o&&i<2*r){var s=[];for(var a in n)s[a]=n[a];return s}return e&&!this.getPriority().isEmpty()&&(n[".priority"]=this.getPriority().val()),n},t.prototype.hash=function(){if(null===this.lazyHash_){var t="";this.getPriority().isEmpty()||(t+="priority:"+fi(this.getPriority().val())+":"),this.forEachChild(gi,function(e,n){var r=n.hash();""!==r&&(t+=":"+e+":"+r)}),this.lazyHash_=""===t?"":sr(t)}return this.lazyHash_},t.prototype.getPredecessorChildName=function(t,e,n){var r=this.resolveIndex_(n);if(r){var i=r.getPredecessorKey(new oi(t,e));return i?i.name:null}return this.children_.getPredecessorKey(t)},t.prototype.getFirstChildName=function(t){var e=this.resolveIndex_(t);if(e){var n=e.minKey();return n&&n.name}return this.children_.minKey()},t.prototype.getFirstChild=function(t){var e=this.getFirstChildName(t);return e?new oi(e,this.children_.get(e)):null},t.prototype.getLastChildName=function(t){var e=this.resolveIndex_(t);if(e){var n=e.maxKey();return n&&n.name}return this.children_.maxKey()},t.prototype.getLastChild=function(t){var e=this.getLastChildName(t);return e?new oi(e,this.children_.get(e)):null},t.prototype.forEachChild=function(t,e){var n=this.resolveIndex_(t);return n?n.inorderTraversal(function(t){return e(t.name,t.node)}):this.children_.inorderTraversal(e)},t.prototype.getIterator=function(t){return this.getIteratorFrom(t.minPost(),t)},t.prototype.getIteratorFrom=function(t,e){var n=this.resolveIndex_(e);if(n)return n.getIteratorFrom(t,function(t){return t});for(var r=this.children_.getIteratorFrom(t.name,oi.Wrap),i=r.peek();null!=i&&e.compare(i,t)<0;)r.getNext(),i=r.peek();return r},t.prototype.getReverseIterator=function(t){return this.getReverseIteratorFrom(t.maxPost(),t)},t.prototype.getReverseIteratorFrom=function(t,e){var n=this.resolveIndex_(e);if(n)return n.getReverseIteratorFrom(t,function(t){return t});for(var r=this.children_.getReverseIteratorFrom(t.name,oi.Wrap),i=r.peek();null!=i&&e.compare(i,t)>0;)r.getNext(),i=r.peek();return r},t.prototype.compareTo=function(t){return this.isEmpty()?t.isEmpty()?0:-1:t.isLeafNode()||t.isEmpty()?1:t===Ri?-1:0},t.prototype.withIndex=function(e){if(e===ui||this.indexMap_.hasIndex(e))return this;var n=this.indexMap_.addIndex(e,this.children_);return new t(this.children_,this.priorityNode_,n)},t.prototype.isIndexed=function(t){return t===ui||this.indexMap_.hasIndex(t)},t.prototype.equals=function(t){if(t===this)return!0;if(t.isLeafNode())return!1;var e=t;if(this.getPriority().equals(e.getPriority())){if(this.children_.count()===e.children_.count()){for(var n=this.getIterator(gi),r=e.getIterator(gi),i=n.getNext(),o=r.getNext();i&&o;){if(i.name!==o.name||!i.node.equals(o.node))return!1;i=n.getNext(),o=r.getNext()}return null===i&&null===o}return!1}return!1},t.prototype.resolveIndex_=function(t){return t===ui?null:this.indexMap_.get(t.toString())},t.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,t}(),Ri=new(function(t){function e(){return t.call(this,new wi(Di),Ai.EMPTY_NODE,Ci.Default)||this}return Je(e,t),e.prototype.compareTo=function(t){return t===this?0:1},e.prototype.equals=function(t){return t===this},e.prototype.getPriority=function(){return this},e.prototype.getImmediateChild=function(t){return Ai.EMPTY_NODE},e.prototype.isEmpty=function(){return!1},e}(Ai));Object.defineProperties(oi,{MIN:{value:new oi(gr,Ai.EMPTY_NODE)},MAX:{value:new oi(vr,Ri)}}),ai.__EMPTY_NODE=Ai.EMPTY_NODE,di.__childrenNodeConstructor=Ai,qr=Ri,function(t){li=t}(Ri);var ki=!0;function Oi(t,e){if(void 0===e&&(e=null),null===t)return Ai.EMPTY_NODE;if("object"==typeof t&&".priority"in t&&(e=t[".priority"]),on(null===e||"string"==typeof e||"number"==typeof e||"object"==typeof e&&".sv"in e,"Invalid priority type found: "+typeof e),"object"==typeof t&&".value"in t&&null!==t[".value"]&&(t=t[".value"]),"object"!=typeof t||".sv"in t)return new di(t,Oi(e));if(t instanceof Array||!ki){var n=Ai.EMPTY_NODE,r=t;return Cn(r,function(t,e){if(Sn(r,t)&&"."!==t.substring(0,1)){var i=Oi(e);!i.isLeafNode()&&i.isEmpty()||(n=n.updateImmediateChild(t,i))}}),n.updatePriority(Oi(e))}var i=[],o=!1,s=t;if(Cn(s,function(t,e){if("string"!=typeof t||"."!==t.substring(0,1)){var n=Oi(s[t]);n.isEmpty()||(o=o||!n.getPriority().isEmpty(),i.push(new oi(t,n)))}}),0==i.length)return Ai.EMPTY_NODE;var a=Si(i,Ni,function(t){return t.name},Di);if(o){var u=Si(i,gi.getCompare());return new Ai(a,Oi(e),new Ci({".priority":u},{".priority":gi}))}return new Ai(a,Oi(e),Ci.Default)}!function(t){hi=t}(Oi);var Pi,Li,Mi=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Je(e,t),e.prototype.compare=function(t,e){var n=t.node.compareTo(e.node);return 0===n?br(t.name,e.name):n},e.prototype.isDefinedOn=function(t){return!0},e.prototype.indexedValueChanged=function(t,e){return!t.equals(e)},e.prototype.minPost=function(){return oi.MIN},e.prototype.maxPost=function(){return oi.MAX},e.prototype.makePost=function(t,e){var n=Oi(t);return new oi(e,n)},e.prototype.toString=function(){return".value"},e}(si)),xi=function(t){function e(e){var n=t.call(this)||this;return n.indexPath_=e,on(!e.isEmpty()&&".priority"!==e.getFront(),"Can't create PathIndex with empty path or .priority key"),n}return Je(e,t),e.prototype.extractChild=function(t){return t.getChild(this.indexPath_)},e.prototype.isDefinedOn=function(t){return!t.getChild(this.indexPath_).isEmpty()},e.prototype.compare=function(t,e){var n=this.extractChild(t.node),r=this.extractChild(e.node),i=n.compareTo(r);return 0===i?br(t.name,e.name):i},e.prototype.makePost=function(t,e){var n=Oi(t),r=Ai.EMPTY_NODE.updateChild(this.indexPath_,n);return new oi(e,r)},e.prototype.maxPost=function(){var t=Ai.EMPTY_NODE.updateChild(this.indexPath_,Ri);return new oi(vr,t)},e.prototype.toString=function(){return this.indexPath_.slice().join("/")},e}(si),Fi=function(){function t(t,e,n){this.node_=t,this.ref_=e,this.index_=n}return t.prototype.val=function(){return Fn("DataSnapshot.val",0,0,arguments.length),this.node_.val()},t.prototype.exportVal=function(){return Fn("DataSnapshot.exportVal",0,0,arguments.length),this.node_.val(!0)},t.prototype.toJSON=function(){return Fn("DataSnapshot.toJSON",0,1,arguments.length),this.exportVal()},t.prototype.exists=function(){return Fn("DataSnapshot.exists",0,0,arguments.length),!this.node_.isEmpty()},t.prototype.child=function(e){Fn("DataSnapshot.child",0,1,arguments.length),e=String(e),Zr("DataSnapshot.child",1,e,!1);var n=new kr(e),r=this.ref_.child(n);return new t(this.node_.getChild(n),r,gi)},t.prototype.hasChild=function(t){Fn("DataSnapshot.hasChild",1,1,arguments.length),Zr("DataSnapshot.hasChild",1,t,!1);var e=new kr(t);return!this.node_.getChild(e).isEmpty()},t.prototype.getPriority=function(){return Fn("DataSnapshot.getPriority",0,0,arguments.length),this.node_.getPriority().val()},t.prototype.forEach=function(e){var n=this;return Fn("DataSnapshot.forEach",1,1,arguments.length),qn("DataSnapshot.forEach",1,e,!1),!this.node_.isLeafNode()&&!!this.node_.forEachChild(this.index_,function(r,i){return e(new t(i,n.ref_.child(r),gi))})},t.prototype.hasChildren=function(){return Fn("DataSnapshot.hasChildren",0,0,arguments.length),!this.node_.isLeafNode()&&!this.node_.isEmpty()},Object.defineProperty(t.prototype,"key",{get:function(){return this.ref_.getKey()},enumerable:!0,configurable:!0}),t.prototype.numChildren=function(){return Fn("DataSnapshot.numChildren",0,0,arguments.length),this.node_.numChildren()},t.prototype.getRef=function(){return Fn("DataSnapshot.ref",0,0,arguments.length),this.ref_},Object.defineProperty(t.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),t}(),Ui=function(){function t(t,e,n,r){this.eventType=t,this.eventRegistration=e,this.snapshot=n,this.prevName=r}return t.prototype.getPath=function(){var t=this.snapshot.getRef();return"value"===this.eventType?t.path:t.getParent().path},t.prototype.getEventType=function(){return this.eventType},t.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},t.prototype.toString=function(){return this.getPath().toString()+":"+this.eventType+":"+En(this.snapshot.exportVal())},t}(),qi=function(){function t(t,e,n){this.eventRegistration=t,this.error=e,this.path=n}return t.prototype.getPath=function(){return this.path},t.prototype.getEventType=function(){return"cancel"},t.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},t.prototype.toString=function(){return this.path.toString()+":cancel"},t}(),Bi=function(){function t(t,e,n){this.callback_=t,this.cancelCallback_=e,this.context_=n}return t.prototype.respondsTo=function(t){return"value"===t},t.prototype.createEvent=function(t,e){var n=e.getQueryParams().getIndex();return new Ui("value",this,new Fi(t.snapshotNode,e.getRef(),n))},t.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){on(this.cancelCallback_,"Raising a cancel event on a listener with no cancel callback");var n=this.cancelCallback_;return function(){n.call(e,t.error)}}var r=this.callback_;return function(){r.call(e,t.snapshot)}},t.prototype.createCancelEvent=function(t,e){return this.cancelCallback_?new qi(this,t,e):null},t.prototype.matches=function(e){return e instanceof t&&(!e.callback_||!this.callback_||e.callback_===this.callback_&&e.context_===this.context_)},t.prototype.hasAnyCallback=function(){return null!==this.callback_},t}(),Vi=function(){function t(t,e,n){this.callbacks_=t,this.cancelCallback_=e,this.context_=n}return t.prototype.respondsTo=function(t){var e="children_added"===t?"child_added":t;return e="children_removed"===e?"child_removed":e,Sn(this.callbacks_,e)},t.prototype.createCancelEvent=function(t,e){return this.cancelCallback_?new qi(this,t,e):null},t.prototype.createEvent=function(t,e){on(null!=t.childName,"Child events should have a childName.");var n=e.getRef().child(t.childName),r=e.getQueryParams().getIndex();return new Ui(t.type,this,new Fi(t.snapshotNode,n,r),t.prevName)},t.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){on(this.cancelCallback_,"Raising a cancel event on a listener with no cancel callback");var n=this.cancelCallback_;return function(){n.call(e,t.error)}}var r=this.callbacks_[t.eventType];return function(){r.call(e,t.snapshot,t.prevName)}},t.prototype.matches=function(e){if(e instanceof t){if(!this.callbacks_||!e.callbacks_)return!0;if(this.context_===e.context_){var n=An(e.callbacks_);if(n===An(this.callbacks_)){if(1===n){var r=On(e.callbacks_),i=On(this.callbacks_);return!(i!==r||e.callbacks_[r]&&this.callbacks_[i]&&e.callbacks_[r]!==this.callbacks_[i])}return function(t,e){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&!e(n,t[n]))return!1;return!0}(this.callbacks_,function(t,n){return e.callbacks_[t]===n})}}}return!1},t.prototype.hasAnyCallback=function(){return null!==this.callbacks_},t}(),Wi=function(){function t(t,e,n,r){this.repo=t,this.path=e,this.queryParams_=n,this.orderByCalled_=r}return Object.defineProperty(t,"__referenceConstructor",{get:function(){return on(Pi,"Reference.ts has not been loaded"),Pi},set:function(t){Pi=t},enumerable:!0,configurable:!0}),t.validateQueryEndpoints_=function(t){var e=null,n=null;if(t.hasStart()&&(e=t.getIndexStartValue()),t.hasEnd()&&(n=t.getIndexEndValue()),t.getIndex()===ui){var r="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",i="Query: When ordering by key, the argument passed to startAt(), endAt(),or equalTo() must be a string.";if(t.hasStart()){if(t.getIndexStartName()!=gr)throw new Error(r);if("string"!=typeof e)throw new Error(i)}if(t.hasEnd()){if(t.getIndexEndName()!=vr)throw new Error(r);if("string"!=typeof n)throw new Error(i)}}else if(t.getIndex()===gi){if(null!=e&&!Hr(e)||null!=n&&!Hr(n))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), endAt(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if(on(t.getIndex()instanceof xi||t.getIndex()===Mi,"unknown index type."),null!=e&&"object"==typeof e||null!=n&&"object"==typeof n)throw new Error("Query: First argument passed to startAt(), endAt(), or equalTo() cannot be an object.")},t.validateLimit_=function(t){if(t.hasStart()&&t.hasEnd()&&t.hasLimit()&&!t.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), endAt(), and limit(). Use limitToFirst() or limitToLast() instead.")},t.prototype.validateNoPreviousOrderByCall_=function(t){if(!0===this.orderByCalled_)throw new Error(t+": You can't combine multiple orderBy calls.")},t.prototype.getQueryParams=function(){return this.queryParams_},t.prototype.getRef=function(){return Fn("Query.ref",0,0,arguments.length),new t.__referenceConstructor(this.repo,this.path)},t.prototype.on=function(e,n,r,i){Fn("Query.on",2,4,arguments.length),Jr("Query.on",1,e,!1),qn("Query.on",2,n,!1);var o=t.getCancelAndContextArgs_("Query.on",r,i);if("value"===e)this.onValueEvent(n,o.cancel,o.context);else{var s={};s[e]=n,this.onChildEvent(s,o.cancel,o.context)}return n},t.prototype.onValueEvent=function(t,e,n){var r=new Bi(t,e||null,n||null);this.repo.addEventCallbackForQuery(this,r)},t.prototype.onChildEvent=function(t,e,n){var r=new Vi(t,e,n);this.repo.addEventCallbackForQuery(this,r)},t.prototype.off=function(t,e,n){Fn("Query.off",0,3,arguments.length),Jr("Query.off",1,t,!0),qn("Query.off",2,e,!0),Bn("Query.off",3,n,!0);var r=null,i=null;"value"===t?r=new Bi(e||null,null,n||null):t&&(e&&((i={})[t]=e),r=new Vi(i,null,n||null));this.repo.removeEventCallbackForQuery(this,r)},t.prototype.once=function(e,n,r,i){var o=this;Fn("Query.once",1,4,arguments.length),Jr("Query.once",1,e,!1),qn("Query.once",2,n,!0);var s=t.getCancelAndContextArgs_("Query.once",r,i),a=!0,u=new pn;u.promise.catch(function(){});var c=function(t){a&&(a=!1,o.off(e,c),n&&n.bind(s.context)(t),u.resolve(t))};return this.on(e,c,function(t){o.off(e,c),s.cancel&&s.cancel.bind(s.context)(t),u.reject(t)}),u.promise},t.prototype.limitToFirst=function(e){if(Fn("Query.limitToFirst",1,1,arguments.length),"number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("Query.limitToFirst: First argument must be a positive integer.");if(this.queryParams_.hasLimit())throw new Error("Query.limitToFirst: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new t(this.repo,this.path,this.queryParams_.limitToFirst(e),this.orderByCalled_)},t.prototype.limitToLast=function(e){if(Fn("Query.limitToLast",1,1,arguments.length),"number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("Query.limitToLast: First argument must be a positive integer.");if(this.queryParams_.hasLimit())throw new Error("Query.limitToLast: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new t(this.repo,this.path,this.queryParams_.limitToLast(e),this.orderByCalled_)},t.prototype.orderByChild=function(e){if(Fn("Query.orderByChild",1,1,arguments.length),"$key"===e)throw new Error('Query.orderByChild: "$key" is invalid.  Use Query.orderByKey() instead.');if("$priority"===e)throw new Error('Query.orderByChild: "$priority" is invalid.  Use Query.orderByPriority() instead.');if("$value"===e)throw new Error('Query.orderByChild: "$value" is invalid.  Use Query.orderByValue() instead.');Zr("Query.orderByChild",1,e,!1),this.validateNoPreviousOrderByCall_("Query.orderByChild");var n=new kr(e);if(n.isEmpty())throw new Error("Query.orderByChild: cannot pass in empty path.  Use Query.orderByValue() instead.");var r=new xi(n),i=this.queryParams_.orderBy(r);return t.validateQueryEndpoints_(i),new t(this.repo,this.path,i,!0)},t.prototype.orderByKey=function(){Fn("Query.orderByKey",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByKey");var e=this.queryParams_.orderBy(ui);return t.validateQueryEndpoints_(e),new t(this.repo,this.path,e,!0)},t.prototype.orderByPriority=function(){Fn("Query.orderByPriority",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByPriority");var e=this.queryParams_.orderBy(gi);return t.validateQueryEndpoints_(e),new t(this.repo,this.path,e,!0)},t.prototype.orderByValue=function(){Fn("Query.orderByValue",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByValue");var e=this.queryParams_.orderBy(Mi);return t.validateQueryEndpoints_(e),new t(this.repo,this.path,e,!0)},t.prototype.startAt=function(e,n){void 0===e&&(e=null),Fn("Query.startAt",0,2,arguments.length),Gr("Query.startAt",1,e,this.path,!0),$r("Query.startAt",2,n,!0);var r=this.queryParams_.startAt(e,n);if(t.validateLimit_(r),t.validateQueryEndpoints_(r),this.queryParams_.hasStart())throw new Error("Query.startAt: Starting point was already set (by another call to startAt or equalTo).");return void 0===e&&(e=null,n=null),new t(this.repo,this.path,r,this.orderByCalled_)},t.prototype.endAt=function(e,n){void 0===e&&(e=null),Fn("Query.endAt",0,2,arguments.length),Gr("Query.endAt",1,e,this.path,!0),$r("Query.endAt",2,n,!0);var r=this.queryParams_.endAt(e,n);if(t.validateLimit_(r),t.validateQueryEndpoints_(r),this.queryParams_.hasEnd())throw new Error("Query.endAt: Ending point was already set (by another call to endAt or equalTo).");return new t(this.repo,this.path,r,this.orderByCalled_)},t.prototype.equalTo=function(t,e){if(Fn("Query.equalTo",1,2,arguments.length),Gr("Query.equalTo",1,t,this.path,!1),$r("Query.equalTo",2,e,!0),this.queryParams_.hasStart())throw new Error("Query.equalTo: Starting point was already set (by another call to startAt or equalTo).");if(this.queryParams_.hasEnd())throw new Error("Query.equalTo: Ending point was already set (by another call to endAt or equalTo).");return this.startAt(t,e).endAt(t,e)},t.prototype.toString=function(){return Fn("Query.toString",0,0,arguments.length),this.repo.toString()+this.path.toUrlEncodedString()},t.prototype.toJSON=function(){return Fn("Query.toJSON",0,1,arguments.length),this.toString()},t.prototype.queryObject=function(){return this.queryParams_.getQueryObject()},t.prototype.queryIdentifier=function(){var t=this.queryObject(),e=Er(t);return"{}"===e?"default":e},t.prototype.isEqual=function(e){if(Fn("Query.isEqual",1,1,arguments.length),!(e instanceof t)){throw new Error("Query.isEqual failed: First argument must be an instance of firebase.database.Query.")}var n=this.repo===e.repo,r=this.path.equals(e.path),i=this.queryIdentifier()===e.queryIdentifier();return n&&r&&i},t.getCancelAndContextArgs_=function(t,e,n){var r={cancel:null,context:null};if(e&&n)r.cancel=e,qn(t,3,r.cancel,!0),r.context=n,Bn(t,4,r.context,!0);else if(e)if("object"==typeof e&&null!==e)r.context=e;else{if("function"!=typeof e)throw new Error(Un(t,3,!0)+" must either be a cancel callback or a context object.");r.cancel=e}return r},Object.defineProperty(t.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),t}(),ji=function(){function t(){this.set={}}return t.prototype.add=function(t,e){this.set[t]=null===e||e},t.prototype.contains=function(t){return Sn(this.set,t)},t.prototype.get=function(t){return this.contains(t)?this.set[t]:void 0},t.prototype.remove=function(t){delete this.set[t]},t.prototype.clear=function(){this.set={}},t.prototype.isEmpty=function(){return Dn(this.set)},t.prototype.count=function(){return An(this.set)},t.prototype.each=function(t){Cn(this.set,function(e,n){return t(e,n)})},t.prototype.keys=function(){var t=[];return Cn(this.set,function(e){t.push(e)}),t},t}(),Ki=function(){function t(){this.value_=null,this.children_=null}return t.prototype.find=function(t){if(null!=this.value_)return this.value_.getChild(t);if(t.isEmpty()||null==this.children_)return null;var e=t.getFront();return t=t.popFront(),this.children_.contains(e)?this.children_.get(e).find(t):null},t.prototype.remember=function(e,n){if(e.isEmpty())this.value_=n,this.children_=null;else if(null!==this.value_)this.value_=this.value_.updateChild(e,n);else{null==this.children_&&(this.children_=new ji);var r=e.getFront();this.children_.contains(r)||this.children_.add(r,new t);var i=this.children_.get(r);e=e.popFront(),i.remember(e,n)}},t.prototype.forget=function(t){if(t.isEmpty())return this.value_=null,this.children_=null,!0;if(null!==this.value_){if(this.value_.isLeafNode())return!1;var e=this.value_;this.value_=null;var n=this;return e.forEachChild(gi,function(t,e){n.remember(new kr(t),e)}),this.forget(t)}if(null!==this.children_){var r=t.getFront();if(t=t.popFront(),this.children_.contains(r))this.children_.get(r).forget(t)&&this.children_.remove(r);return!!this.children_.isEmpty()&&(this.children_=null,!0)}return!0},t.prototype.forEachTree=function(t,e){null!==this.value_?e(t,this.value_):this.forEachChild(function(n,r){var i=new kr(t.toString()+"/"+n);r.forEachTree(i,e)})},t.prototype.forEachChild=function(t){null!==this.children_&&this.children_.each(function(e,n){t(e,n)})},t}(),Qi=function(t,e){return t&&"object"==typeof t?(on(".sv"in t,"Unexpected leaf node or priority contents"),e[t[".sv"]]):t},Hi=function(t,e){var n,r=t.getPriority().val(),i=Qi(r,e);if(t.isLeafNode()){var o=t,s=Qi(o.getValue(),e);return s!==o.getValue()||i!==o.getPriority().val()?new di(s,Oi(i)):t}var a=t;return n=a,i!==a.getPriority().val()&&(n=n.updatePriority(new di(i))),a.forEachChild(gi,function(t,r){var i=Hi(r,e);i!==r&&(n=n.updateImmediateChild(t,i))}),n};!function(t){t[t.OVERWRITE=0]="OVERWRITE",t[t.MERGE=1]="MERGE",t[t.ACK_USER_WRITE=2]="ACK_USER_WRITE",t[t.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(Li||(Li={}));var Gi,zi,Yi=function(){function t(t,e,n,r){this.fromUser=t,this.fromServer=e,this.queryId=n,this.tagged=r,on(!r||e,"Tagged queries must be from server.")}return t.User=new t(!0,!1,null,!1),t.Server=new t(!1,!0,null,!1),t.forServerTaggedQuery=function(e){return new t(!1,!0,e,!0)},t}(),Xi=function(){function t(t,e,n){this.path=t,this.affectedTree=e,this.revert=n,this.type=Li.ACK_USER_WRITE,this.source=Yi.User}return t.prototype.operationForChild=function(e){if(this.path.isEmpty()){if(null!=this.affectedTree.value)return on(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var n=this.affectedTree.subtree(new kr(e));return new t(kr.Empty,n,this.revert)}return on(this.path.getFront()===e,"operationForChild called for unrelated child."),new t(this.path.popFront(),this.affectedTree,this.revert)},t}(),Ji=function(){return Gi||(Gi=new wi(_r)),Gi},$i=function(){function t(t,e){void 0===e&&(e=Ji()),this.value=t,this.children=e}return t.fromObject=function(e){var n=t.Empty;return Cn(e,function(t,e){n=n.set(new kr(t),e)}),n},t.prototype.isEmpty=function(){return null===this.value&&this.children.isEmpty()},t.prototype.findRootMostMatchingPathAndValue=function(t,e){if(null!=this.value&&e(this.value))return{path:kr.Empty,value:this.value};if(t.isEmpty())return null;var n=t.getFront(),r=this.children.get(n);if(null!==r){var i=r.findRootMostMatchingPathAndValue(t.popFront(),e);return null!=i?{path:new kr(n).child(i.path),value:i.value}:null}return null},t.prototype.findRootMostValueAndPath=function(t){return this.findRootMostMatchingPathAndValue(t,function(){return!0})},t.prototype.subtree=function(e){if(e.isEmpty())return this;var n=e.getFront(),r=this.children.get(n);return null!==r?r.subtree(e.popFront()):t.Empty},t.prototype.set=function(e,n){if(e.isEmpty())return new t(n,this.children);var r=e.getFront(),i=(this.children.get(r)||t.Empty).set(e.popFront(),n),o=this.children.insert(r,i);return new t(this.value,o)},t.prototype.remove=function(e){if(e.isEmpty())return this.children.isEmpty()?t.Empty:new t(null,this.children);var n=e.getFront(),r=this.children.get(n);if(r){var i=r.remove(e.popFront()),o=void 0;return o=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),null===this.value&&o.isEmpty()?t.Empty:new t(this.value,o)}return this},t.prototype.get=function(t){if(t.isEmpty())return this.value;var e=t.getFront(),n=this.children.get(e);return n?n.get(t.popFront()):null},t.prototype.setTree=function(e,n){if(e.isEmpty())return n;var r=e.getFront(),i=(this.children.get(r)||t.Empty).setTree(e.popFront(),n),o=void 0;return o=i.isEmpty()?this.children.remove(r):this.children.insert(r,i),new t(this.value,o)},t.prototype.fold=function(t){return this.fold_(kr.Empty,t)},t.prototype.fold_=function(t,e){var n={};return this.children.inorderTraversal(function(r,i){n[r]=i.fold_(t.child(r),e)}),e(t,this.value,n)},t.prototype.findOnPath=function(t,e){return this.findOnPath_(t,kr.Empty,e)},t.prototype.findOnPath_=function(t,e,n){var r=!!this.value&&n(e,this.value);if(r)return r;if(t.isEmpty())return null;var i=t.getFront(),o=this.children.get(i);return o?o.findOnPath_(t.popFront(),e.child(i),n):null},t.prototype.foreachOnPath=function(t,e){return this.foreachOnPath_(t,kr.Empty,e)},t.prototype.foreachOnPath_=function(e,n,r){if(e.isEmpty())return this;this.value&&r(n,this.value);var i=e.getFront(),o=this.children.get(i);return o?o.foreachOnPath_(e.popFront(),n.child(i),r):t.Empty},t.prototype.foreach=function(t){this.foreach_(kr.Empty,t)},t.prototype.foreach_=function(t,e){this.children.inorderTraversal(function(n,r){r.foreach_(t.child(n),e)}),this.value&&e(t,this.value)},t.prototype.foreachChild=function(t){this.children.inorderTraversal(function(e,n){n.value&&t(e,n.value)})},t.Empty=new t(null),t}(),Zi=function(){function t(t,e){this.source=t,this.path=e,this.type=Li.LISTEN_COMPLETE}return t.prototype.operationForChild=function(e){return this.path.isEmpty()?new t(this.source,kr.Empty):new t(this.source,this.path.popFront())},t}(),to=function(){function t(t,e,n){this.source=t,this.path=e,this.snap=n,this.type=Li.OVERWRITE}return t.prototype.operationForChild=function(e){return this.path.isEmpty()?new t(this.source,kr.Empty,this.snap.getImmediateChild(e)):new t(this.source,this.path.popFront(),this.snap)},t}(),eo=function(){function t(t,e,n){this.source=t,this.path=e,this.children=n,this.type=Li.MERGE}return t.prototype.operationForChild=function(e){if(this.path.isEmpty()){var n=this.children.subtree(new kr(e));return n.isEmpty()?null:n.value?new to(this.source,kr.Empty,n.value):new t(this.source,kr.Empty,n)}return on(this.path.getFront()===e,"Can't get a merge for a child not on the path of the operation"),new t(this.source,this.path.popFront(),this.children)},t.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"},t}(),no=function(){function t(t,e,n){this.node_=t,this.fullyInitialized_=e,this.filtered_=n}return t.prototype.isFullyInitialized=function(){return this.fullyInitialized_},t.prototype.isFiltered=function(){return this.filtered_},t.prototype.isCompleteForPath=function(t){if(t.isEmpty())return this.isFullyInitialized()&&!this.filtered_;var e=t.getFront();return this.isCompleteForChild(e)},t.prototype.isCompleteForChild=function(t){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(t)},t.prototype.getNode=function(){return this.node_},t}(),ro=function(){function t(t,e){this.eventCache_=t,this.serverCache_=e}return t.prototype.updateEventSnap=function(e,n,r){return new t(new no(e,n,r),this.serverCache_)},t.prototype.updateServerSnap=function(e,n,r){return new t(this.eventCache_,new no(e,n,r))},t.prototype.getEventCache=function(){return this.eventCache_},t.prototype.getCompleteEventSnap=function(){return this.eventCache_.isFullyInitialized()?this.eventCache_.getNode():null},t.prototype.getServerCache=function(){return this.serverCache_},t.prototype.getCompleteServerSnap=function(){return this.serverCache_.isFullyInitialized()?this.serverCache_.getNode():null},t.Empty=new t(new no(Ai.EMPTY_NODE,!1,!1),new no(Ai.EMPTY_NODE,!1,!1)),t}(),io=function(){function t(t,e,n,r,i){this.type=t,this.snapshotNode=e,this.childName=n,this.oldSnap=r,this.prevName=i}return t.valueChange=function(e){return new t(t.VALUE,e)},t.childAddedChange=function(e,n){return new t(t.CHILD_ADDED,n,e)},t.childRemovedChange=function(e,n){return new t(t.CHILD_REMOVED,n,e)},t.childChangedChange=function(e,n,r){return new t(t.CHILD_CHANGED,n,e,r)},t.childMovedChange=function(e,n){return new t(t.CHILD_MOVED,n,e)},t.CHILD_ADDED="child_added",t.CHILD_REMOVED="child_removed",t.CHILD_CHANGED="child_changed",t.CHILD_MOVED="child_moved",t.VALUE="value",t}(),oo=function(){function t(t){this.index_=t}return t.prototype.updateChild=function(t,e,n,r,i,o){on(t.isIndexed(this.index_),"A node must be indexed if only a child is updated");var s=t.getImmediateChild(e);return s.getChild(r).equals(n.getChild(r))&&s.isEmpty()==n.isEmpty()?t:(null!=o&&(n.isEmpty()?t.hasChild(e)?o.trackChildChange(io.childRemovedChange(e,s)):on(t.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):s.isEmpty()?o.trackChildChange(io.childAddedChange(e,n)):o.trackChildChange(io.childChangedChange(e,n,s))),t.isLeafNode()&&n.isEmpty()?t:t.updateImmediateChild(e,n).withIndex(this.index_))},t.prototype.updateFullNode=function(t,e,n){return null!=n&&(t.isLeafNode()||t.forEachChild(gi,function(t,r){e.hasChild(t)||n.trackChildChange(io.childRemovedChange(t,r))}),e.isLeafNode()||e.forEachChild(gi,function(e,r){if(t.hasChild(e)){var i=t.getImmediateChild(e);i.equals(r)||n.trackChildChange(io.childChangedChange(e,r,i))}else n.trackChildChange(io.childAddedChange(e,r))})),e.withIndex(this.index_)},t.prototype.updatePriority=function(t,e){return t.isEmpty()?Ai.EMPTY_NODE:t.updatePriority(e)},t.prototype.filtersNodes=function(){return!1},t.prototype.getIndexedFilter=function(){return this},t.prototype.getIndex=function(){return this.index_},t}(),so=function(){function t(){this.changeMap_={}}return t.prototype.trackChildChange=function(t){var e=t.type,n=t.childName;on(e==io.CHILD_ADDED||e==io.CHILD_CHANGED||e==io.CHILD_REMOVED,"Only child changes supported for tracking"),on(".priority"!==n,"Only non-priority child changes can be tracked.");var r=In(this.changeMap_,n);if(r){var i=r.type;if(e==io.CHILD_ADDED&&i==io.CHILD_REMOVED)this.changeMap_[n]=io.childChangedChange(n,t.snapshotNode,r.snapshotNode);else if(e==io.CHILD_REMOVED&&i==io.CHILD_ADDED)delete this.changeMap_[n];else if(e==io.CHILD_REMOVED&&i==io.CHILD_CHANGED)this.changeMap_[n]=io.childRemovedChange(n,r.oldSnap);else if(e==io.CHILD_CHANGED&&i==io.CHILD_ADDED)this.changeMap_[n]=io.childAddedChange(n,t.snapshotNode);else{if(e!=io.CHILD_CHANGED||i!=io.CHILD_CHANGED)throw sn("Illegal combination of changes: "+t+" occurred after "+r);this.changeMap_[n]=io.childChangedChange(n,t.snapshotNode,r.oldSnap)}}else this.changeMap_[n]=t},t.prototype.getChanges=function(){return function(t){var e=[],n=0;for(var r in t)e[n++]=t[r];return e}(this.changeMap_)},t}(),ao=new(function(){function t(){}return t.prototype.getCompleteChild=function(t){return null},t.prototype.getChildAfterChild=function(t,e,n){return null},t}()),uo=function(){function t(t,e,n){void 0===n&&(n=null),this.writes_=t,this.viewCache_=e,this.optCompleteServerCache_=n}return t.prototype.getCompleteChild=function(t){var e=this.viewCache_.getEventCache();if(e.isCompleteForChild(t))return e.getNode().getImmediateChild(t);var n=null!=this.optCompleteServerCache_?new no(this.optCompleteServerCache_,!0,!1):this.viewCache_.getServerCache();return this.writes_.calcCompleteChild(t,n)},t.prototype.getChildAfterChild=function(t,e,n){var r=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:this.viewCache_.getCompleteServerSnap(),i=this.writes_.calcIndexedSlice(r,e,1,n,t);return 0===i.length?null:i[0]},t}(),co=function(){return function(t,e){this.viewCache=t,this.changes=e}}(),ho=function(){function t(t){this.filter_=t}return t.prototype.assertIndexed=function(t){on(t.getEventCache().getNode().isIndexed(this.filter_.getIndex()),"Event snap not indexed"),on(t.getServerCache().getNode().isIndexed(this.filter_.getIndex()),"Server snap not indexed")},t.prototype.applyOperation=function(e,n,r,i){var o,s,a=new so;if(n.type===Li.OVERWRITE){var u=n;u.source.fromUser?o=this.applyUserOverwrite_(e,u.path,u.snap,r,i,a):(on(u.source.fromServer,"Unknown source."),s=u.source.tagged||e.getServerCache().isFiltered()&&!u.path.isEmpty(),o=this.applyServerOverwrite_(e,u.path,u.snap,r,i,s,a))}else if(n.type===Li.MERGE){var c=n;c.source.fromUser?o=this.applyUserMerge_(e,c.path,c.children,r,i,a):(on(c.source.fromServer,"Unknown source."),s=c.source.tagged||e.getServerCache().isFiltered(),o=this.applyServerMerge_(e,c.path,c.children,r,i,s,a))}else if(n.type===Li.ACK_USER_WRITE){var h=n;o=h.revert?this.revertUserWrite_(e,h.path,r,i,a):this.ackUserWrite_(e,h.path,h.affectedTree,r,i,a)}else{if(n.type!==Li.LISTEN_COMPLETE)throw sn("Unknown operation type: "+n.type);o=this.listenComplete_(e,n.path,r,a)}var l=a.getChanges();return t.maybeAddValueEvent_(e,o,l),new co(o,l)},t.maybeAddValueEvent_=function(t,e,n){var r=e.getEventCache();if(r.isFullyInitialized()){var i=r.getNode().isLeafNode()||r.getNode().isEmpty(),o=t.getCompleteEventSnap();(n.length>0||!t.getEventCache().isFullyInitialized()||i&&!r.getNode().equals(o)||!r.getNode().getPriority().equals(o.getPriority()))&&n.push(io.valueChange(e.getCompleteEventSnap()))}},t.prototype.generateEventCacheAfterServerEvent_=function(t,e,n,r,i){var o=t.getEventCache();if(null!=n.shadowingWrite(e))return t;var s=void 0,a=void 0;if(e.isEmpty())if(on(t.getServerCache().isFullyInitialized(),"If change path is empty, we must have complete server data"),t.getServerCache().isFiltered()){var u=t.getCompleteServerSnap(),c=u instanceof Ai?u:Ai.EMPTY_NODE,h=n.calcCompleteEventChildren(c);s=this.filter_.updateFullNode(t.getEventCache().getNode(),h,i)}else{var l=n.calcCompleteEventCache(t.getCompleteServerSnap());s=this.filter_.updateFullNode(t.getEventCache().getNode(),l,i)}else{var f=e.getFront();if(".priority"==f){on(1==e.getLength(),"Can't have a priority with additional path components");var p=o.getNode();a=t.getServerCache().getNode();var d=n.calcEventCacheAfterServerOverwrite(e,p,a);s=null!=d?this.filter_.updatePriority(p,d):o.getNode()}else{var y=e.popFront(),m=void 0;if(o.isCompleteForChild(f)){a=t.getServerCache().getNode();var g=n.calcEventCacheAfterServerOverwrite(e,o.getNode(),a);m=null!=g?o.getNode().getImmediateChild(f).updateChild(y,g):o.getNode().getImmediateChild(f)}else m=n.calcCompleteChild(f,t.getServerCache());s=null!=m?this.filter_.updateChild(o.getNode(),f,m,y,r,i):o.getNode()}}return t.updateEventSnap(s,o.isFullyInitialized()||e.isEmpty(),this.filter_.filtersNodes())},t.prototype.applyServerOverwrite_=function(t,e,n,r,i,o,s){var a,u=t.getServerCache(),c=o?this.filter_:this.filter_.getIndexedFilter();if(e.isEmpty())a=c.updateFullNode(u.getNode(),n,null);else if(c.filtersNodes()&&!u.isFiltered()){var h=u.getNode().updateChild(e,n);a=c.updateFullNode(u.getNode(),h,null)}else{var l=e.getFront();if(!u.isCompleteForPath(e)&&e.getLength()>1)return t;var f=e.popFront(),p=u.getNode().getImmediateChild(l).updateChild(f,n);a=".priority"==l?c.updatePriority(u.getNode(),p):c.updateChild(u.getNode(),l,p,f,ao,null)}var d=t.updateServerSnap(a,u.isFullyInitialized()||e.isEmpty(),c.filtersNodes()),y=new uo(r,d,i);return this.generateEventCacheAfterServerEvent_(d,e,r,y,s)},t.prototype.applyUserOverwrite_=function(t,e,n,r,i,o){var s,a,u=t.getEventCache(),c=new uo(r,t,i);if(e.isEmpty())a=this.filter_.updateFullNode(t.getEventCache().getNode(),n,o),s=t.updateEventSnap(a,!0,this.filter_.filtersNodes());else{var h=e.getFront();if(".priority"===h)a=this.filter_.updatePriority(t.getEventCache().getNode(),n),s=t.updateEventSnap(a,u.isFullyInitialized(),u.isFiltered());else{var l=e.popFront(),f=u.getNode().getImmediateChild(h),p=void 0;if(l.isEmpty())p=n;else{var d=c.getCompleteChild(h);p=null!=d?".priority"===l.getBack()&&d.getChild(l.parent()).isEmpty()?d:d.updateChild(l,n):Ai.EMPTY_NODE}if(f.equals(p))s=t;else{var y=this.filter_.updateChild(u.getNode(),h,p,l,c,o);s=t.updateEventSnap(y,u.isFullyInitialized(),this.filter_.filtersNodes())}}}return s},t.cacheHasChild_=function(t,e){return t.getEventCache().isCompleteForChild(e)},t.prototype.applyUserMerge_=function(e,n,r,i,o,s){var a=this,u=e;return r.foreach(function(r,c){var h=n.child(r);t.cacheHasChild_(e,h.getFront())&&(u=a.applyUserOverwrite_(u,h,c,i,o,s))}),r.foreach(function(r,c){var h=n.child(r);t.cacheHasChild_(e,h.getFront())||(u=a.applyUserOverwrite_(u,h,c,i,o,s))}),u},t.prototype.applyMerge_=function(t,e){return e.foreach(function(e,n){t=t.updateChild(e,n)}),t},t.prototype.applyServerMerge_=function(t,e,n,r,i,o,s){var a=this;if(t.getServerCache().getNode().isEmpty()&&!t.getServerCache().isFullyInitialized())return t;var u,c=t;u=e.isEmpty()?n:$i.Empty.setTree(e,n);var h=t.getServerCache().getNode();return u.children.inorderTraversal(function(e,n){if(h.hasChild(e)){var u=t.getServerCache().getNode().getImmediateChild(e),l=a.applyMerge_(u,n);c=a.applyServerOverwrite_(c,new kr(e),l,r,i,o,s)}}),u.children.inorderTraversal(function(e,n){var u=!t.getServerCache().isCompleteForChild(e)&&null==n.value;if(!h.hasChild(e)&&!u){var l=t.getServerCache().getNode().getImmediateChild(e),f=a.applyMerge_(l,n);c=a.applyServerOverwrite_(c,new kr(e),f,r,i,o,s)}}),c},t.prototype.ackUserWrite_=function(t,e,n,r,i,o){if(null!=r.shadowingWrite(e))return t;var s=t.getServerCache().isFiltered(),a=t.getServerCache();if(null!=n.value){if(e.isEmpty()&&a.isFullyInitialized()||a.isCompleteForPath(e))return this.applyServerOverwrite_(t,e,a.getNode().getChild(e),r,i,s,o);if(e.isEmpty()){var u=$i.Empty;return a.getNode().forEachChild(ui,function(t,e){u=u.set(new kr(t),e)}),this.applyServerMerge_(t,e,u,r,i,s,o)}return t}var c=$i.Empty;return n.foreach(function(t,n){var r=e.child(t);a.isCompleteForPath(r)&&(c=c.set(t,a.getNode().getChild(r)))}),this.applyServerMerge_(t,e,c,r,i,s,o)},t.prototype.listenComplete_=function(t,e,n,r){var i=t.getServerCache(),o=t.updateServerSnap(i.getNode(),i.isFullyInitialized()||e.isEmpty(),i.isFiltered());return this.generateEventCacheAfterServerEvent_(o,e,n,ao,r)},t.prototype.revertUserWrite_=function(t,e,n,r,i){var o;if(null!=n.shadowingWrite(e))return t;var s=new uo(n,t,r),a=t.getEventCache().getNode(),u=void 0;if(e.isEmpty()||".priority"===e.getFront()){var c=void 0;if(t.getServerCache().isFullyInitialized())c=n.calcCompleteEventCache(t.getCompleteServerSnap());else{var h=t.getServerCache().getNode();on(h instanceof Ai,"serverChildren would be complete if leaf node"),c=n.calcCompleteEventChildren(h)}c=c,u=this.filter_.updateFullNode(a,c,i)}else{var l=e.getFront(),f=n.calcCompleteChild(l,t.getServerCache());null==f&&t.getServerCache().isCompleteForChild(l)&&(f=a.getImmediateChild(l)),(u=null!=f?this.filter_.updateChild(a,l,f,e.popFront(),s,i):t.getEventCache().getNode().hasChild(l)?this.filter_.updateChild(a,l,Ai.EMPTY_NODE,e.popFront(),s,i):a).isEmpty()&&t.getServerCache().isFullyInitialized()&&(o=n.calcCompleteEventCache(t.getCompleteServerSnap())).isLeafNode()&&(u=this.filter_.updateFullNode(u,o,i))}return o=t.getServerCache().isFullyInitialized()||null!=n.shadowingWrite(kr.Empty),t.updateEventSnap(u,o,this.filter_.filtersNodes())},t}(),lo=function(){function t(t){this.query_=t,this.index_=this.query_.getQueryParams().getIndex()}return t.prototype.generateEventsForChanges=function(t,e,n){var r=this,i=[],o=[];return t.forEach(function(t){t.type===io.CHILD_CHANGED&&r.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&&o.push(io.childMovedChange(t.childName,t.snapshotNode))}),this.generateEventsForType_(i,io.CHILD_REMOVED,t,n,e),this.generateEventsForType_(i,io.CHILD_ADDED,t,n,e),this.generateEventsForType_(i,io.CHILD_MOVED,o,n,e),this.generateEventsForType_(i,io.CHILD_CHANGED,t,n,e),this.generateEventsForType_(i,io.VALUE,t,n,e),i},t.prototype.generateEventsForType_=function(t,e,n,r,i){var o=this,s=n.filter(function(t){return t.type===e});s.sort(this.compareChanges_.bind(this)),s.forEach(function(e){var n=o.materializeSingleChange_(e,i);r.forEach(function(r){r.respondsTo(e.type)&&t.push(r.createEvent(n,o.query_))})})},t.prototype.materializeSingleChange_=function(t,e){return"value"===t.type||"child_removed"===t.type?t:(t.prevName=e.getPredecessorChildName(t.childName,t.snapshotNode,this.index_),t)},t.prototype.compareChanges_=function(t,e){if(null==t.childName||null==e.childName)throw sn("Should only compare child_ events.");var n=new oi(t.childName,t.snapshotNode),r=new oi(e.childName,e.snapshotNode);return this.index_.compare(n,r)},t}(),fo=function(){function t(t,e){this.query_=t,this.eventRegistrations_=[];var n=this.query_.getQueryParams(),r=new oo(n.getIndex()),i=n.getNodeFilter();this.processor_=new ho(i);var o=e.getServerCache(),s=e.getEventCache(),a=r.updateFullNode(Ai.EMPTY_NODE,o.getNode(),null),u=i.updateFullNode(Ai.EMPTY_NODE,s.getNode(),null),c=new no(a,o.isFullyInitialized(),r.filtersNodes()),h=new no(u,s.isFullyInitialized(),i.filtersNodes());this.viewCache_=new ro(h,c),this.eventGenerator_=new lo(this.query_)}return t.prototype.getQuery=function(){return this.query_},t.prototype.getServerCache=function(){return this.viewCache_.getServerCache().getNode()},t.prototype.getCompleteServerCache=function(t){var e=this.viewCache_.getCompleteServerSnap();return e&&(this.query_.getQueryParams().loadsAllData()||!t.isEmpty()&&!e.getImmediateChild(t.getFront()).isEmpty())?e.getChild(t):null},t.prototype.isEmpty=function(){return 0===this.eventRegistrations_.length},t.prototype.addEventRegistration=function(t){this.eventRegistrations_.push(t)},t.prototype.removeEventRegistration=function(t,e){var n=[];if(e){on(null==t,"A cancel should cancel all event registrations.");var r=this.query_.path;this.eventRegistrations_.forEach(function(t){e=e;var i=t.createCancelEvent(e,r);i&&n.push(i)})}if(t){for(var i=[],o=0;o<this.eventRegistrations_.length;++o){var s=this.eventRegistrations_[o];if(s.matches(t)){if(t.hasAnyCallback()){i=i.concat(this.eventRegistrations_.slice(o+1));break}}else i.push(s)}this.eventRegistrations_=i}else this.eventRegistrations_=[];return n},t.prototype.applyOperation=function(t,e,n){t.type===Li.MERGE&&null!==t.source.queryId&&(on(this.viewCache_.getCompleteServerSnap(),"We should always have a full cache before handling merges"),on(this.viewCache_.getCompleteEventSnap(),"Missing event cache, even though we have a server cache"));var r=this.viewCache_,i=this.processor_.applyOperation(r,t,e,n);return this.processor_.assertIndexed(i.viewCache),on(i.viewCache.getServerCache().isFullyInitialized()||!r.getServerCache().isFullyInitialized(),"Once a server snap is complete, it should never go back"),this.viewCache_=i.viewCache,this.generateEventsForChanges_(i.changes,i.viewCache.getEventCache().getNode(),null)},t.prototype.getInitialEvents=function(t){var e=this.viewCache_.getEventCache(),n=[];e.getNode().isLeafNode()||e.getNode().forEachChild(gi,function(t,e){n.push(io.childAddedChange(t,e))});return e.isFullyInitialized()&&n.push(io.valueChange(e.getNode())),this.generateEventsForChanges_(n,e.getNode(),t)},t.prototype.generateEventsForChanges_=function(t,e,n){var r=n?[n]:this.eventRegistrations_;return this.eventGenerator_.generateEventsForChanges(t,e,r)},t}(),po=function(){function t(){this.views_={}}return Object.defineProperty(t,"__referenceConstructor",{get:function(){return on(zi,"Reference.ts has not been loaded"),zi},set:function(t){on(!zi,"__referenceConstructor has already been defined"),zi=t},enumerable:!0,configurable:!0}),t.prototype.isEmpty=function(){return Dn(this.views_)},t.prototype.applyOperation=function(t,e,n){var r=t.source.queryId;if(null!==r){var i=In(this.views_,r);return on(null!=i,"SyncTree gave us an op for an invalid query."),i.applyOperation(t,e,n)}var o=[];return Cn(this.views_,function(r,i){o=o.concat(i.applyOperation(t,e,n))}),o},t.prototype.addEventRegistration=function(t,e,n,r,i){var o=t.queryIdentifier(),s=In(this.views_,o);if(!s){var a=n.calcCompleteEventCache(i?r:null),u=!1;a?u=!0:r instanceof Ai?(a=n.calcCompleteEventChildren(r),u=!1):(a=Ai.EMPTY_NODE,u=!1);var c=new ro(new no(a,u,!1),new no(r,i,!1));s=new fo(t,c),this.views_[o]=s}return s.addEventRegistration(e),s.getInitialEvents(e)},t.prototype.removeEventRegistration=function(e,n,r){var i=e.queryIdentifier(),o=[],s=[],a=this.hasCompleteView();if("default"===i){var u=this;Cn(this.views_,function(t,e){s=s.concat(e.removeEventRegistration(n,r)),e.isEmpty()&&(delete u.views_[t],e.getQuery().getQueryParams().loadsAllData()||o.push(e.getQuery()))})}else{var c=In(this.views_,i);c&&(s=s.concat(c.removeEventRegistration(n,r)),c.isEmpty()&&(delete this.views_[i],c.getQuery().getQueryParams().loadsAllData()||o.push(c.getQuery())))}return a&&!this.hasCompleteView()&&o.push(new t.__referenceConstructor(e.repo,e.path)),{removed:o,events:s}},t.prototype.getQueryViews=function(){var t=this;return Object.keys(this.views_).map(function(e){return t.views_[e]}).filter(function(t){return!t.getQuery().getQueryParams().loadsAllData()})},t.prototype.getCompleteServerCache=function(t){var e=null;return Cn(this.views_,function(n,r){e=e||r.getCompleteServerCache(t)}),e},t.prototype.viewForQuery=function(t){if(t.getQueryParams().loadsAllData())return this.getCompleteView();var e=t.queryIdentifier();return In(this.views_,e)},t.prototype.viewExistsForQuery=function(t){return null!=this.viewForQuery(t)},t.prototype.hasCompleteView=function(){return null!=this.getCompleteView()},t.prototype.getCompleteView=function(){var t,e,n;return(t=this.views_,(n=kn(t,function(t){return t.getQuery().getQueryParams().loadsAllData()},e))&&t[n])||null},t}(),yo=function(){function t(t){this.writeTree_=t}return t.prototype.addWrite=function(e,n){if(e.isEmpty())return new t(new $i(n));var r=this.writeTree_.findRootMostValueAndPath(e);if(null!=r){var i=r.path,o=r.value,s=kr.relativePath(i,e);return o=o.updateChild(s,n),new t(this.writeTree_.set(i,o))}var a=new $i(n);return new t(this.writeTree_.setTree(e,a))},t.prototype.addWrites=function(t,e){var n=this;return Cn(e,function(e,r){n=n.addWrite(t.child(e),r)}),n},t.prototype.removeWrite=function(e){return e.isEmpty()?t.Empty:new t(this.writeTree_.setTree(e,$i.Empty))},t.prototype.hasCompleteWrite=function(t){return null!=this.getCompleteNode(t)},t.prototype.getCompleteNode=function(t){var e=this.writeTree_.findRootMostValueAndPath(t);return null!=e?this.writeTree_.get(e.path).getChild(kr.relativePath(e.path,t)):null},t.prototype.getCompleteChildren=function(){var t=[],e=this.writeTree_.value;return null!=e?e.isLeafNode()||e.forEachChild(gi,function(e,n){t.push(new oi(e,n))}):this.writeTree_.children.inorderTraversal(function(e,n){null!=n.value&&t.push(new oi(e,n.value))}),t},t.prototype.childCompoundWrite=function(e){if(e.isEmpty())return this;var n=this.getCompleteNode(e);return new t(null!=n?new $i(n):this.writeTree_.subtree(e))},t.prototype.isEmpty=function(){return this.writeTree_.isEmpty()},t.prototype.apply=function(e){return t.applySubtreeWrite_(kr.Empty,this.writeTree_,e)},t.Empty=new t(new $i(null)),t.applySubtreeWrite_=function(e,n,r){if(null!=n.value)return r.updateChild(e,n.value);var i=null;return n.children.inorderTraversal(function(n,o){".priority"===n?(on(null!==o.value,"Priority writes must always be leaf nodes"),i=o.value):r=t.applySubtreeWrite_(e.child(n),o,r)}),r.getChild(e).isEmpty()||null===i||(r=r.updateChild(e.child(".priority"),i)),r},t}(),mo=function(){function t(){this.visibleWrites_=yo.Empty,this.allWrites_=[],this.lastWriteId_=-1}return t.prototype.childWrites=function(t){return new go(t,this)},t.prototype.addOverwrite=function(t,e,n,r){on(n>this.lastWriteId_,"Stacking an older write on top of newer ones"),void 0===r&&(r=!0),this.allWrites_.push({path:t,snap:e,writeId:n,visible:r}),r&&(this.visibleWrites_=this.visibleWrites_.addWrite(t,e)),this.lastWriteId_=n},t.prototype.addMerge=function(t,e,n){on(n>this.lastWriteId_,"Stacking an older merge on top of newer ones"),this.allWrites_.push({path:t,children:e,writeId:n,visible:!0}),this.visibleWrites_=this.visibleWrites_.addWrites(t,e),this.lastWriteId_=n},t.prototype.getWrite=function(t){for(var e=0;e<this.allWrites_.length;e++){var n=this.allWrites_[e];if(n.writeId===t)return n}return null},t.prototype.removeWrite=function(t){var e=this,n=this.allWrites_.findIndex(function(e){return e.writeId===t});on(n>=0,"removeWrite called with nonexistent writeId.");var r=this.allWrites_[n];this.allWrites_.splice(n,1);for(var i=r.visible,o=!1,s=this.allWrites_.length-1;i&&s>=0;){var a=this.allWrites_[s];a.visible&&(s>=n&&this.recordContainsPath_(a,r.path)?i=!1:r.path.contains(a.path)&&(o=!0)),s--}if(i){if(o)return this.resetTree_(),!0;if(r.snap)this.visibleWrites_=this.visibleWrites_.removeWrite(r.path);else{var u=r.children;Cn(u,function(t){e.visibleWrites_=e.visibleWrites_.removeWrite(r.path.child(t))})}return!0}return!1},t.prototype.getCompleteWriteData=function(t){return this.visibleWrites_.getCompleteNode(t)},t.prototype.calcCompleteEventCache=function(e,n,r,i){if(r||i){var o=this.visibleWrites_.childCompoundWrite(e);if(!i&&o.isEmpty())return n;if(i||null!=n||o.hasCompleteWrite(kr.Empty)){var s=t.layerTree_(this.allWrites_,function(t){return(t.visible||i)&&(!r||!~r.indexOf(t.writeId))&&(t.path.contains(e)||e.contains(t.path))},e);c=n||Ai.EMPTY_NODE;return s.apply(c)}return null}var a=this.visibleWrites_.getCompleteNode(e);if(null!=a)return a;var u=this.visibleWrites_.childCompoundWrite(e);if(u.isEmpty())return n;if(null!=n||u.hasCompleteWrite(kr.Empty)){var c=n||Ai.EMPTY_NODE;return u.apply(c)}return null},t.prototype.calcCompleteEventChildren=function(t,e){var n=Ai.EMPTY_NODE,r=this.visibleWrites_.getCompleteNode(t);if(r)return r.isLeafNode()||r.forEachChild(gi,function(t,e){n=n.updateImmediateChild(t,e)}),n;if(e){var i=this.visibleWrites_.childCompoundWrite(t);return e.forEachChild(gi,function(t,e){var r=i.childCompoundWrite(new kr(t)).apply(e);n=n.updateImmediateChild(t,r)}),i.getCompleteChildren().forEach(function(t){n=n.updateImmediateChild(t.name,t.node)}),n}return this.visibleWrites_.childCompoundWrite(t).getCompleteChildren().forEach(function(t){n=n.updateImmediateChild(t.name,t.node)}),n},t.prototype.calcEventCacheAfterServerOverwrite=function(t,e,n,r){on(n||r,"Either existingEventSnap or existingServerSnap must exist");var i=t.child(e);if(this.visibleWrites_.hasCompleteWrite(i))return null;var o=this.visibleWrites_.childCompoundWrite(i);return o.isEmpty()?r.getChild(e):o.apply(r.getChild(e))},t.prototype.calcCompleteChild=function(t,e,n){var r=t.child(e),i=this.visibleWrites_.getCompleteNode(r);return null!=i?i:n.isCompleteForChild(e)?this.visibleWrites_.childCompoundWrite(r).apply(n.getNode().getImmediateChild(e)):null},t.prototype.shadowingWrite=function(t){return this.visibleWrites_.getCompleteNode(t)},t.prototype.calcIndexedSlice=function(t,e,n,r,i,o){var s,a=this.visibleWrites_.childCompoundWrite(t),u=a.getCompleteNode(kr.Empty);if(null!=u)s=u;else{if(null==e)return[];s=a.apply(e)}if((s=s.withIndex(o)).isEmpty()||s.isLeafNode())return[];for(var c=[],h=o.getCompare(),l=i?s.getReverseIteratorFrom(n,o):s.getIteratorFrom(n,o),f=l.getNext();f&&c.length<r;)0!==h(f,n)&&c.push(f),f=l.getNext();return c},t.prototype.recordContainsPath_=function(t,e){return t.snap?t.path.contains(e):!!kn(t.children,function(n,r){return t.path.child(r).contains(e)})},t.prototype.resetTree_=function(){this.visibleWrites_=t.layerTree_(this.allWrites_,t.DefaultFilter_,kr.Empty),this.allWrites_.length>0?this.lastWriteId_=this.allWrites_[this.allWrites_.length-1].writeId:this.lastWriteId_=-1},t.DefaultFilter_=function(t){return t.visible},t.layerTree_=function(t,e,n){for(var r=yo.Empty,i=0;i<t.length;++i){var o=t[i];if(e(o)){var s=o.path,a=void 0;if(o.snap)n.contains(s)?(a=kr.relativePath(n,s),r=r.addWrite(a,o.snap)):s.contains(n)&&(a=kr.relativePath(s,n),r=r.addWrite(kr.Empty,o.snap.getChild(a)));else{if(!o.children)throw sn("WriteRecord should have .snap or .children");if(n.contains(s))a=kr.relativePath(n,s),r=r.addWrites(a,o.children);else if(s.contains(n))if((a=kr.relativePath(s,n)).isEmpty())r=r.addWrites(kr.Empty,o.children);else{var u=In(o.children,a.getFront());if(u){var c=u.getChild(a.popFront());r=r.addWrite(kr.Empty,c)}}}}}return r},t}(),go=function(){function t(t,e){this.treePath_=t,this.writeTree_=e}return t.prototype.calcCompleteEventCache=function(t,e,n){return this.writeTree_.calcCompleteEventCache(this.treePath_,t,e,n)},t.prototype.calcCompleteEventChildren=function(t){return this.writeTree_.calcCompleteEventChildren(this.treePath_,t)},t.prototype.calcEventCacheAfterServerOverwrite=function(t,e,n){return this.writeTree_.calcEventCacheAfterServerOverwrite(this.treePath_,t,e,n)},t.prototype.shadowingWrite=function(t){return this.writeTree_.shadowingWrite(this.treePath_.child(t))},t.prototype.calcIndexedSlice=function(t,e,n,r,i){return this.writeTree_.calcIndexedSlice(this.treePath_,t,e,n,r,i)},t.prototype.calcCompleteChild=function(t,e){return this.writeTree_.calcCompleteChild(this.treePath_,t,e)},t.prototype.child=function(e){return new t(this.treePath_.child(e),this.writeTree_)},t}(),vo=function(){function t(t){this.listenProvider_=t,this.syncPointTree_=$i.Empty,this.pendingWriteTree_=new mo,this.tagToQueryMap_={},this.queryToTagMap_={}}return t.prototype.applyUserOverwrite=function(t,e,n,r){return this.pendingWriteTree_.addOverwrite(t,e,n,r),r?this.applyOperationToSyncPoints_(new to(Yi.User,t,e)):[]},t.prototype.applyUserMerge=function(t,e,n){this.pendingWriteTree_.addMerge(t,e,n);var r=$i.fromObject(e);return this.applyOperationToSyncPoints_(new eo(Yi.User,t,r))},t.prototype.ackUserWrite=function(t,e){void 0===e&&(e=!1);var n=this.pendingWriteTree_.getWrite(t);if(this.pendingWriteTree_.removeWrite(t)){var r=$i.Empty;return null!=n.snap?r=r.set(kr.Empty,!0):Cn(n.children,function(t,e){r=r.set(new kr(t),e)}),this.applyOperationToSyncPoints_(new Xi(n.path,r,e))}return[]},t.prototype.applyServerOverwrite=function(t,e){return this.applyOperationToSyncPoints_(new to(Yi.Server,t,e))},t.prototype.applyServerMerge=function(t,e){var n=$i.fromObject(e);return this.applyOperationToSyncPoints_(new eo(Yi.Server,t,n))},t.prototype.applyListenComplete=function(t){return this.applyOperationToSyncPoints_(new Zi(Yi.Server,t))},t.prototype.applyTaggedQueryOverwrite=function(e,n,r){var i=this.queryKeyForTag_(r);if(null!=i){var o=t.parseQueryKey_(i),s=o.path,a=o.queryId,u=kr.relativePath(s,e),c=new to(Yi.forServerTaggedQuery(a),u,n);return this.applyTaggedOperation_(s,c)}return[]},t.prototype.applyTaggedQueryMerge=function(e,n,r){var i=this.queryKeyForTag_(r);if(i){var o=t.parseQueryKey_(i),s=o.path,a=o.queryId,u=kr.relativePath(s,e),c=$i.fromObject(n),h=new eo(Yi.forServerTaggedQuery(a),u,c);return this.applyTaggedOperation_(s,h)}return[]},t.prototype.applyTaggedListenComplete=function(e,n){var r=this.queryKeyForTag_(n);if(r){var i=t.parseQueryKey_(r),o=i.path,s=i.queryId,a=kr.relativePath(o,e),u=new Zi(Yi.forServerTaggedQuery(s),a);return this.applyTaggedOperation_(o,u)}return[]},t.prototype.addEventRegistration=function(e,n){var r=e.path,i=null,o=!1;this.syncPointTree_.foreachOnPath(r,function(t,e){var n=kr.relativePath(t,r);i=i||e.getCompleteServerCache(n),o=o||e.hasCompleteView()});var s,a=this.syncPointTree_.get(r);(a?(o=o||a.hasCompleteView(),i=i||a.getCompleteServerCache(kr.Empty)):(a=new po,this.syncPointTree_=this.syncPointTree_.set(r,a)),null!=i)?s=!0:(s=!1,i=Ai.EMPTY_NODE,this.syncPointTree_.subtree(r).foreachChild(function(t,e){var n=e.getCompleteServerCache(kr.Empty);n&&(i=i.updateImmediateChild(t,n))}));var u=a.viewExistsForQuery(e);if(!u&&!e.getQueryParams().loadsAllData()){var c=t.makeQueryKey_(e);on(!(c in this.queryToTagMap_),"View does not exist, but we have a tag");var h=t.getNextQueryTag_();this.queryToTagMap_[c]=h,this.tagToQueryMap_["_"+h]=c}var l=this.pendingWriteTree_.childWrites(r),f=a.addEventRegistration(e,n,l,i,s);if(!u&&!o){var p=a.viewForQuery(e);f=f.concat(this.setupListener_(e,p))}return f},t.prototype.removeEventRegistration=function(e,n,r){var i=this,o=e.path,s=this.syncPointTree_.get(o),a=[];if(s&&("default"===e.queryIdentifier()||s.viewExistsForQuery(e))){var u=s.removeEventRegistration(e,n,r);s.isEmpty()&&(this.syncPointTree_=this.syncPointTree_.remove(o));var c=u.removed;a=u.events;var h=-1!==c.findIndex(function(t){return t.getQueryParams().loadsAllData()}),l=this.syncPointTree_.findOnPath(o,function(t,e){return e.hasCompleteView()});if(h&&!l){var f=this.syncPointTree_.subtree(o);if(!f.isEmpty())for(var p=this.collectDistinctViewsForSubTree_(f),d=0;d<p.length;++d){var y=p[d],m=y.getQuery(),g=this.createListenerForView_(y);this.listenProvider_.startListening(t.queryForListening_(m),this.tagForQuery_(m),g.hashFn,g.onComplete)}}if(!l&&c.length>0&&!r)if(h){this.listenProvider_.stopListening(t.queryForListening_(e),null)}else c.forEach(function(e){var n=i.queryToTagMap_[t.makeQueryKey_(e)];i.listenProvider_.stopListening(t.queryForListening_(e),n)});this.removeTags_(c)}return a},t.prototype.calcCompleteEventCache=function(t,e){var n=this.pendingWriteTree_,r=this.syncPointTree_.findOnPath(t,function(e,n){var r=kr.relativePath(e,t),i=n.getCompleteServerCache(r);if(i)return i});return n.calcCompleteEventCache(t,r,e,!0)},t.prototype.collectDistinctViewsForSubTree_=function(t){return t.fold(function(t,e,n){if(e&&e.hasCompleteView())return[e.getCompleteView()];var r=[];return e&&(r=e.getQueryViews()),Cn(n,function(t,e){r=r.concat(e)}),r})},t.prototype.removeTags_=function(e){for(var n=0;n<e.length;++n){var r=e[n];if(!r.getQueryParams().loadsAllData()){var i=t.makeQueryKey_(r),o=this.queryToTagMap_[i];delete this.queryToTagMap_[i],delete this.tagToQueryMap_["_"+o]}}},t.queryForListening_=function(t){return t.getQueryParams().loadsAllData()&&!t.getQueryParams().isDefault()?t.getRef():t},t.prototype.setupListener_=function(e,n){var r=e.path,i=this.tagForQuery_(e),o=this.createListenerForView_(n),s=this.listenProvider_.startListening(t.queryForListening_(e),i,o.hashFn,o.onComplete),a=this.syncPointTree_.subtree(r);if(i)on(!a.value.hasCompleteView(),"If we're adding a query, it shouldn't be shadowed");else for(var u=a.fold(function(t,e,n){if(!t.isEmpty()&&e&&e.hasCompleteView())return[e.getCompleteView().getQuery()];var r=[];return e&&(r=r.concat(e.getQueryViews().map(function(t){return t.getQuery()}))),Cn(n,function(t,e){r=r.concat(e)}),r}),c=0;c<u.length;++c){var h=u[c];this.listenProvider_.stopListening(t.queryForListening_(h),this.tagForQuery_(h))}return s},t.prototype.createListenerForView_=function(t){var e=this,n=t.getQuery(),r=this.tagForQuery_(n);return{hashFn:function(){return(t.getServerCache()||Ai.EMPTY_NODE).hash()},onComplete:function(t){if("ok"===t)return r?e.applyTaggedListenComplete(n.path,r):e.applyListenComplete(n.path);var i=function(t,e){var n="Unknown Error";"too_big"===t?n="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"==t?n="Client doesn't have permission to access the desired data.":"unavailable"==t&&(n="The service is unavailable");var r=new Error(t+" at "+e.path.toString()+": "+n);return r.code=t.toUpperCase(),r}(t,n);return e.removeEventRegistration(n,null,i)}}},t.makeQueryKey_=function(t){return t.path.toString()+"$"+t.queryIdentifier()},t.parseQueryKey_=function(t){var e=t.indexOf("$");return on(-1!==e&&e<t.length-1,"Bad queryKey."),{queryId:t.substr(e+1),path:new kr(t.substr(0,e))}},t.prototype.queryKeyForTag_=function(t){return this.tagToQueryMap_["_"+t]},t.prototype.tagForQuery_=function(e){var n=t.makeQueryKey_(e);return In(this.queryToTagMap_,n)},t.getNextQueryTag_=function(){return t.nextQueryTag_++},t.prototype.applyTaggedOperation_=function(t,e){var n=this.syncPointTree_.get(t);on(n,"Missing sync point for query tag that we're tracking");var r=this.pendingWriteTree_.childWrites(t);return n.applyOperation(e,r,null)},t.prototype.applyOperationToSyncPoints_=function(t){return this.applyOperationHelper_(t,this.syncPointTree_,null,this.pendingWriteTree_.childWrites(kr.Empty))},t.prototype.applyOperationHelper_=function(t,e,n,r){if(t.path.isEmpty())return this.applyOperationDescendantsHelper_(t,e,n,r);var i=e.get(kr.Empty);null==n&&null!=i&&(n=i.getCompleteServerCache(kr.Empty));var o=[],s=t.path.getFront(),a=t.operationForChild(s),u=e.children.get(s);if(u&&a){var c=n?n.getImmediateChild(s):null,h=r.child(s);o=o.concat(this.applyOperationHelper_(a,u,c,h))}return i&&(o=o.concat(i.applyOperation(t,r,n))),o},t.prototype.applyOperationDescendantsHelper_=function(t,e,n,r){var i=this,o=e.get(kr.Empty);null==n&&null!=o&&(n=o.getCompleteServerCache(kr.Empty));var s=[];return e.children.inorderTraversal(function(e,o){var a=n?n.getImmediateChild(e):null,u=r.child(e),c=t.operationForChild(e);c&&(s=s.concat(i.applyOperationDescendantsHelper_(c,o,a,u)))}),o&&(s=s.concat(o.applyOperation(t,r,n))),s},t.nextQueryTag_=1,t}(),bo=function(){function t(){this.rootNode_=Ai.EMPTY_NODE}return t.prototype.getNode=function(t){return this.rootNode_.getChild(t)},t.prototype.updateSnapshot=function(t,e){this.rootNode_=this.rootNode_.updateChild(t,e)},t}(),_o=function(){function t(t){this.app_=t}return t.prototype.getToken=function(t){return this.app_.INTERNAL.getToken(t).then(null,function(t){return t&&"auth/token-not-initialized"===t.code?(lr("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(t)})},t.prototype.addTokenChangeListener=function(t){this.app_.INTERNAL.addAuthTokenListener(t)},t.prototype.removeTokenChangeListener=function(t){this.app_.INTERNAL.removeAuthTokenListener(t)},t.prototype.notifyForInvalidToken=function(){var t='Provided authentication credentials for the app named "'+this.app_.name+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.app_.options?t+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.app_.options?t+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':t+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',yr(t)},t}(),wo=function(){function t(){this.counters_={}}return t.prototype.incrementCounter=function(t,e){void 0===e&&(e=1),Sn(this.counters_,t)||(this.counters_[t]=0),this.counters_[t]+=e},t.prototype.get=function(){return hn(this.counters_)},t}(),Eo=function(){function t(){}return t.getCollection=function(t){var e=t.toString();return this.collections_[e]||(this.collections_[e]=new wo),this.collections_[e]},t.getOrCreateReporter=function(t,e){var n=t.toString();return this.reporters_[n]||(this.reporters_[n]=e()),this.reporters_[n]},t.collections_={},t.reporters_={},t}(),To=function(){function t(t){this.collection_=t,this.last_=null}return t.prototype.get=function(){var t=this.collection_.get(),e=Nn(t);return this.last_&&Cn(this.last_,function(t,n){e[t]=e[t]-n}),this.last_=t,e},t}(),So=1e4,Io=3e4,Co=function(){function t(t,e){this.server_=e,this.statsToReport_={},this.statsListener_=new To(t);var n=So+(Io-So)*Math.random();Rr(this.reportStats_.bind(this),Math.floor(n))}return t.prototype.includeStat=function(t){this.statsToReport_[t]=!0},t.prototype.reportStats_=function(){var t=this,e=this.statsListener_.get(),n={},r=!1;Cn(e,function(e,i){i>0&&Sn(t.statsToReport_,e)&&(n[e]=i,r=!0)}),r&&this.server_.reportStats(n),Rr(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))},t}(),No=function(){function t(){this.eventLists_=[],this.recursionDepth_=0}return t.prototype.queueEvents=function(t){for(var e=null,n=0;n<t.length;n++){var r=t[n],i=r.getPath();null===e||i.equals(e.getPath())||(this.eventLists_.push(e),e=null),null===e&&(e=new Do(i)),e.add(r)}e&&this.eventLists_.push(e)},t.prototype.raiseEventsAtPath=function(t,e){this.queueEvents(e),this.raiseQueuedEventsMatchingPredicate_(function(e){return e.equals(t)})},t.prototype.raiseEventsForChangedPath=function(t,e){this.queueEvents(e),this.raiseQueuedEventsMatchingPredicate_(function(e){return e.contains(t)||t.contains(e)})},t.prototype.raiseQueuedEventsMatchingPredicate_=function(t){this.recursionDepth_++;for(var e=!0,n=0;n<this.eventLists_.length;n++){var r=this.eventLists_[n];if(r)t(r.getPath())?(this.eventLists_[n].raise(),this.eventLists_[n]=null):e=!1}e&&(this.eventLists_=[]),this.recursionDepth_--},t}(),Do=function(){function t(t){this.path_=t,this.events_=[]}return t.prototype.add=function(t){this.events_.push(t)},t.prototype.raise=function(){for(var t=0;t<this.events_.length;t++){var e=this.events_[t];if(null!==e){this.events_[t]=null;var n=e.getEventRunner();ur&&lr("event: "+e.toString()),Dr(n)}}},t.prototype.getPath=function(){return this.path_},t}(),Ao=function(){function t(t){this.allowedEvents_=t,this.listeners_={},on(Array.isArray(t)&&t.length>0,"Requires a non-empty array")}return t.prototype.trigger=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(Array.isArray(this.listeners_[t]))for(var r=this.listeners_[t].slice(),i=0;i<r.length;i++)r[i].callback.apply(r[i].context,e)},t.prototype.on=function(t,e,n){this.validateEventType_(t),this.listeners_[t]=this.listeners_[t]||[],this.listeners_[t].push({callback:e,context:n});var r=this.getInitialEvent(t);r&&e.apply(n,r)},t.prototype.off=function(t,e,n){this.validateEventType_(t);for(var r=this.listeners_[t]||[],i=0;i<r.length;i++)if(r[i].callback===e&&(!n||n===r[i].context))return void r.splice(i,1)},t.prototype.validateEventType_=function(t){on(this.allowedEvents_.find(function(e){return e===t}),"Unknown event: "+t)},t}(),Ro=function(t){function e(){var e,n,r=t.call(this,["visible"])||this;return"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(n="visibilitychange",e="hidden"):void 0!==document.mozHidden?(n="mozvisibilitychange",e="mozHidden"):void 0!==document.msHidden?(n="msvisibilitychange",e="msHidden"):void 0!==document.webkitHidden&&(n="webkitvisibilitychange",e="webkitHidden")),r.visible_=!0,n&&document.addEventListener(n,function(){var t=!document[e];t!==r.visible_&&(r.visible_=t,r.trigger("visible",t))},!1),r}return Je(e,t),e.getInstance=function(){return new e},e.prototype.getInitialEvent=function(t){return on("visible"===t,"Unknown event type: "+t),[this.visible_]},e}(Ao),ko=function(t){function e(){var e=t.call(this,["online"])||this;return e.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||dn()||(window.addEventListener("online",function(){e.online_||(e.online_=!0,e.trigger("online",!0))},!1),window.addEventListener("offline",function(){e.online_&&(e.online_=!1,e.trigger("online",!1))},!1)),e}return Je(e,t),e.getInstance=function(){return new e},e.prototype.getInitialEvent=function(t){return on("online"===t,"Unknown event type: "+t),[this.online_]},e.prototype.currentlyOnline=function(){return this.online_},e}(Ao),Oo=function(){function t(t){this.onMessage_=t,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}return t.prototype.closeAfter=function(t,e){this.closeAfterResponse=t,this.onClose=e,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)},t.prototype.handleResponse=function(t,e){var n=this;this.pendingResponses[t]=e;for(var r=function(){var t=i.pendingResponses[i.currentResponseNum];delete i.pendingResponses[i.currentResponseNum];for(var e=function(e){t[e]&&Dr(function(){n.onMessage_(t[e])})},r=0;r<t.length;++r)e(r);if(i.currentResponseNum===i.closeAfterResponse)return i.onClose&&(i.onClose(),i.onClose=null),"break";i.currentResponseNum++},i=this;this.pendingResponses[this.currentResponseNum];){if("break"===r())break}},t}(),Po="pLPCommand",Lo="pRTLPCB",Mo=function(){function t(t,e,n,r){this.connId=t,this.repoInfo=e,this.transportSessionId=n,this.lastSessionId=r,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=fr(t),this.stats_=Eo.getCollection(e),this.urlFn=function(t){return e.connectionURL(Pr,t)}}return t.prototype.open=function(t,e){var n=this;this.curSegmentNum=0,this.onDisconnect_=e,this.myPacketOrderer=new Oo(t),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(function(){n.log_("Timed out trying to connect."),n.onClosed_(),n.connectTimeoutTimer_=null},Math.floor(3e4)),function(t){if(mn()||"complete"===document.readyState)t();else{var e=!1,n=function(){document.body?e||(e=!0,t()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&n()}),window.attachEvent("onload",n))}}(function(){if(!n.isClosed_){n.scriptTagHolder=new xo(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t[0],i=t[1],o=t[2];if(n.incrementIncomingBytes_(t),n.scriptTagHolder)if(n.connectTimeoutTimer_&&(clearTimeout(n.connectTimeoutTimer_),n.connectTimeoutTimer_=null),n.everConnected_=!0,"start"==r)n.id=i,n.password=o;else{if("close"!==r)throw new Error("Unrecognized command received: "+r);i?(n.scriptTagHolder.sendNewPolls=!1,n.myPacketOrderer.closeAfter(i,function(){n.onClosed_()})):n.onClosed_()}},function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t[0],i=t[1];n.incrementIncomingBytes_(t),n.myPacketOrderer.handleResponse(r,i)},function(){n.onClosed_()},n.urlFn);var t={start:"t"};t.ser=Math.floor(1e8*Math.random()),n.scriptTagHolder.uniqueCallbackIdentifier&&(t.cb=n.scriptTagHolder.uniqueCallbackIdentifier),t.v="5",n.transportSessionId&&(t.s=n.transportSessionId),n.lastSessionId&&(t.ls=n.lastSessionId),!mn()&&"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf("firebaseio.com")&&(t.r="f");var e=n.urlFn(t);n.log_("Connecting via long-poll to "+e),n.scriptTagHolder.addTag(e,function(){})}})},t.prototype.start=function(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)},t.forceAllow=function(){t.forceAllow_=!0},t.forceDisallow=function(){t.forceDisallow_=!0},t.isAvailable=function(){return t.forceAllow_||!t.forceDisallow_&&"undefined"!=typeof document&&null!=document.createElement&&!("object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))&&!("object"==typeof Windows&&"object"==typeof Windows.UI)&&!mn()},t.prototype.markConnectionHealthy=function(){},t.prototype.shutdown_=function(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)},t.prototype.onClosed_=function(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))},t.prototype.close=function(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())},t.prototype.send=function(t){var e=En(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);for(var n,r=(n=an(e),un.encodeByteArray(n,!0)),i=Tr(r,1840),o=0;o<i.length;o++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[o]),this.curSegmentNum++},t.prototype.addDisconnectPingFrame=function(t,e){if(!mn()){this.myDisconnFrame=document.createElement("iframe");var n={dframe:"t"};n.id=t,n.pw=e,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}},t.prototype.incrementIncomingBytes_=function(t){var e=En(t).length;this.bytesReceived+=e,this.stats_.incrementCounter("bytes_received",e)},t}(),xo=function(){function t(e,n,r,i){if(this.onDisconnect=r,this.urlFn=i,this.outstandingRequests=new ji,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0,mn())this.commandCB=e,this.onMessageCB=n;else{this.uniqueCallbackIdentifier=or(),window[Po+this.uniqueCallbackIdentifier]=e,window[Lo+this.uniqueCallbackIdentifier]=n,this.myIFrame=t.createIFrame_();var o="";if(this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,"javascript:".length))o='<script>document.domain="'+document.domain+'";<\/script>';var s="<html><body>"+o+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(s),this.myIFrame.doc.close()}catch(t){lr("frame writing exception"),t.stack&&lr(t.stack),lr(t)}}}return t.createIFrame_=function(){var t=document.createElement("iframe");if(t.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(t);try{t.contentWindow.document||lr("No IE domain setting required")}catch(n){var e=document.domain;t.src="javascript:void((function(){document.open();document.domain='"+e+"';document.close();})())"}return t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document),t},t.prototype.close=function(){var e=this;if(this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.innerHTML="",setTimeout(function(){null!==e.myIFrame&&(document.body.removeChild(e.myIFrame),e.myIFrame=null)},Math.floor(0))),mn()&&this.myID){var n={disconn:"t"};n.id=this.myID,n.pw=this.myPW;var r=this.urlFn(n);t.nodeRestRequest(r)}var i=this.onDisconnect;i&&(this.onDisconnect=null,i())},t.prototype.startLongPoll=function(t,e){for(this.myID=t,this.myPW=e,this.alive=!0;this.newRequest_(););},t.prototype.newRequest_=function(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.count()<(this.pendingSegs.length>0?2:1)){this.currentSerial++;var t={};t.id=this.myID,t.pw=this.myPW,t.ser=this.currentSerial;for(var e=this.urlFn(t),n="",r=0;this.pendingSegs.length>0;){if(!(this.pendingSegs[0].d.length+30+n.length<=1870))break;var i=this.pendingSegs.shift();n=n+"&seg"+r+"="+i.seg+"&ts"+r+"="+i.ts+"&d"+r+"="+i.d,r++}return e+=n,this.addLongPollTag_(e,this.currentSerial),!0}return!1},t.prototype.enqueueSegment=function(t,e,n){this.pendingSegs.push({seg:t,ts:e,d:n}),this.alive&&this.newRequest_()},t.prototype.addLongPollTag_=function(t,e){var n=this;this.outstandingRequests.add(e,1);var r=function(){n.outstandingRequests.remove(e),n.newRequest_()},i=setTimeout(r,Math.floor(25e3));this.addTag(t,function(){clearTimeout(i),r()})},t.prototype.addTag=function(t,e){var n=this;mn()?this.doNodeLongPoll(t,e):setTimeout(function(){try{if(!n.sendNewPolls)return;var r=n.myIFrame.doc.createElement("script");r.type="text/javascript",r.async=!0,r.src=t,r.onload=r.onreadystatechange=function(){var t=r.readyState;t&&"loaded"!==t&&"complete"!==t||(r.onload=r.onreadystatechange=null,r.parentNode&&r.parentNode.removeChild(r),e())},r.onerror=function(){lr("Long-poll script failed to load: "+t),n.sendNewPolls=!1,n.close()},n.myIFrame.doc.body.appendChild(r)}catch(t){}},Math.floor(1))},t}(),Fo=null;"undefined"!=typeof MozWebSocket?Fo=MozWebSocket:"undefined"!=typeof WebSocket&&(Fo=WebSocket);var Uo=function(){function t(e,n,r,i){this.connId=e,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=fr(this.connId),this.stats_=Eo.getCollection(n),this.connURL=t.connectionURL_(n,r,i)}return t.connectionURL_=function(t,e,n){var r={v:"5"};return!mn()&&"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf("firebaseio.com")&&(r.r="f"),e&&(r.s=e),n&&(r.ls=n),t.connectionURL("websocket",r)},t.prototype.open=function(t,e){var n=this;this.onDisconnect=e,this.onMessage=t,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,nr.set("previous_websocket_failure",!0);try{if(mn()){var r=nn?"AdminNode":"Node",i={headers:{"User-Agent":"Firebase/5/"+Yn.SDK_VERSION+"/"+process.platform+"/"+r}},o=process.env,s=0==this.connURL.indexOf("wss://")?o.HTTPS_PROXY||o.https_proxy:o.HTTP_PROXY||o.http_proxy;s&&(i.proxy={origin:s}),this.mySock=new Fo(this.connURL,[],i)}else this.mySock=new Fo(this.connURL)}catch(t){this.log_("Error instantiating WebSocket.");var a=t.message||t.data;return a&&this.log_(a),void this.onClosed_()}this.mySock.onopen=function(){n.log_("Websocket connected."),n.everConnected_=!0},this.mySock.onclose=function(){n.log_("Websocket connection was disconnected."),n.mySock=null,n.onClosed_()},this.mySock.onmessage=function(t){n.handleIncomingFrame(t)},this.mySock.onerror=function(t){n.log_("WebSocket error.  Closing connection.");var e=t.message||t.data;e&&n.log_(e),n.onClosed_()}},t.prototype.start=function(){},t.forceDisallow=function(){t.forceDisallow_=!0},t.isAvailable=function(){var e=!1;if("undefined"!=typeof navigator&&navigator.userAgent){var n=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/);n&&n.length>1&&parseFloat(n[1])<4.4&&(e=!0)}return!e&&null!==Fo&&!t.forceDisallow_},t.previouslyFailed=function(){return nr.isInMemoryStorage||!0===nr.get("previous_websocket_failure")},t.prototype.markConnectionHealthy=function(){nr.remove("previous_websocket_failure")},t.prototype.appendFrame_=function(t){if(this.frames.push(t),this.frames.length==this.totalFrames){var e=this.frames.join("");this.frames=null;var n=wn(e);this.onMessage(n)}},t.prototype.handleNewFrameCount_=function(t){this.totalFrames=t,this.frames=[]},t.prototype.extractFrameCount_=function(t){if(on(null===this.frames,"We already have a frame buffer"),t.length<=6){var e=Number(t);if(!isNaN(e))return this.handleNewFrameCount_(e),null}return this.handleNewFrameCount_(1),t},t.prototype.handleIncomingFrame=function(t){if(null!==this.mySock){var e=t.data;if(this.bytesReceived+=e.length,this.stats_.incrementCounter("bytes_received",e.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(e);else{var n=this.extractFrameCount_(e);null!==n&&this.appendFrame_(n)}}},t.prototype.send=function(t){this.resetKeepAlive();var e=En(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);var n=Tr(e,16384);n.length>1&&this.sendString_(String(n.length));for(var r=0;r<n.length;r++)this.sendString_(n[r])},t.prototype.shutdown_=function(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)},t.prototype.onClosed_=function(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))},t.prototype.close=function(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())},t.prototype.resetKeepAlive=function(){var t=this;clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(function(){t.mySock&&t.sendString_("0"),t.resetKeepAlive()},Math.floor(45e3))},t.prototype.sendString_=function(t){try{this.mySock.send(t)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}},t.responsesRequiredToBeHealthy=2,t.healthyTimeout=3e4,t}(),qo=function(){function t(t){this.initTransports_(t)}return Object.defineProperty(t,"ALL_TRANSPORTS",{get:function(){return[Mo,Uo]},enumerable:!0,configurable:!0}),t.prototype.initTransports_=function(e){var n=Uo&&Uo.isAvailable(),r=n&&!Uo.previouslyFailed();if(e.webSocketOnly&&(n||yr("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),r=!0),r)this.transports_=[Uo];else{var i=this.transports_=[];Sr(t.ALL_TRANSPORTS,function(t,e){e&&e.isAvailable()&&i.push(e)})}},t.prototype.initialTransport=function(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")},t.prototype.upgradeTransport=function(){return this.transports_.length>1?this.transports_[1]:null},t}(),Bo=function(){function t(t,e,n,r,i,o,s){this.id=t,this.repoInfo_=e,this.onMessage_=n,this.onReady_=r,this.onDisconnect_=i,this.onKill_=o,this.lastSessionId=s,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=fr("c:"+this.id+":"),this.transportManager_=new qo(e),this.log_("Connection created"),this.start_()}return t.prototype.start_=function(){var t=this,e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,void 0,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;var n=this.connReceiver_(this.conn_),r=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(function(){t.conn_&&t.conn_.open(n,r)},Math.floor(0));var i=e.healthyTimeout||0;i>0&&(this.healthyTimeout_=Rr(function(){t.healthyTimeout_=null,t.isHealthy_||(t.conn_&&t.conn_.bytesReceived>102400?(t.log_("Connection exceeded healthy timeout but has received "+t.conn_.bytesReceived+" bytes.  Marking connection healthy."),t.isHealthy_=!0,t.conn_.markConnectionHealthy()):t.conn_&&t.conn_.bytesSent>10240?t.log_("Connection exceeded healthy timeout but has sent "+t.conn_.bytesSent+" bytes.  Leaving connection alive."):(t.log_("Closing unhealthy connection after timeout."),t.close()))},Math.floor(i)))},t.prototype.nextTransportId_=function(){return"c:"+this.id+":"+this.connectionCount++},t.prototype.disconnReceiver_=function(t){var e=this;return function(n){t===e.conn_?e.onConnectionLost_(n):t===e.secondaryConn_?(e.log_("Secondary connection lost."),e.onSecondaryConnectionLost_()):e.log_("closing an old connection")}},t.prototype.connReceiver_=function(t){var e=this;return function(n){2!=e.state_&&(t===e.rx_?e.onPrimaryMessageReceived_(n):t===e.secondaryConn_?e.onSecondaryMessageReceived_(n):e.log_("message on old connection"))}},t.prototype.sendRequest=function(t){var e={t:"d",d:t};this.sendData_(e)},t.prototype.tryCleanupConnection=function(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)},t.prototype.onSecondaryControl_=function(t){if("t"in t){var e=t.t;"a"===e?this.upgradeIfSecondaryHealthy_():"r"===e?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===e&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}},t.prototype.onSecondaryMessageReceived_=function(t){var e=wr("t",t),n=wr("d",t);if("c"==e)this.onSecondaryControl_(n);else{if("d"!=e)throw new Error("Unknown protocol layer: "+e);this.pendingDataMessages.push(n)}},t.prototype.upgradeIfSecondaryHealthy_=function(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))},t.prototype.proceedWithUpgrade_=function(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()},t.prototype.onPrimaryMessageReceived_=function(t){var e=wr("t",t),n=wr("d",t);"c"==e?this.onControl_(n):"d"==e&&this.onDataMessage_(n)},t.prototype.onDataMessage_=function(t){this.onPrimaryResponse_(),this.onMessage_(t)},t.prototype.onPrimaryResponse_=function(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))},t.prototype.onControl_=function(t){var e=wr("t",t);if("d"in t){var n=t.d;if("h"===e)this.onHandshake_(n);else if("n"===e){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(var r=0;r<this.pendingDataMessages.length;++r)this.onDataMessage_(this.pendingDataMessages[r]);this.pendingDataMessages=[],this.tryCleanupConnection()}else"s"===e?this.onConnectionShutdown_(n):"r"===e?this.onReset_(n):"e"===e?pr("Server Error: "+n):"o"===e?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):pr("Unknown control packet command: "+e)}},t.prototype.onHandshake_=function(t){var e=t.ts,n=t.v,r=t.h;this.sessionId=t.s,this.repoInfo_.updateHost(r),0==this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,e),"5"!==n&&yr("Protocol version mismatch detected"),this.tryStartUpgrade_())},t.prototype.tryStartUpgrade_=function(){var t=this.transportManager_.upgradeTransport();t&&this.startUpgrade_(t)},t.prototype.startUpgrade_=function(t){var e=this;this.secondaryConn_=new t(this.nextTransportId_(),this.repoInfo_,this.sessionId),this.secondaryResponsesRequired_=t.responsesRequiredToBeHealthy||0;var n=this.connReceiver_(this.secondaryConn_),r=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(n,r),Rr(function(){e.secondaryConn_&&(e.log_("Timed out trying to upgrade."),e.secondaryConn_.close())},Math.floor(6e4))},t.prototype.onReset_=function(t){this.log_("Reset packet received.  New host: "+t),this.repoInfo_.updateHost(t),1===this.state_?this.close():(this.closeConnections_(),this.start_())},t.prototype.onConnectionEstablished_=function(t,e){var n=this;this.log_("Realtime connection established."),this.conn_=t,this.state_=1,this.onReady_&&(this.onReady_(e,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Rr(function(){n.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))},t.prototype.sendPingOnPrimaryIfNecessary_=function(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))},t.prototype.onSecondaryConnectionLost_=function(){var t=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==t&&this.rx_!==t||this.close()},t.prototype.onConnectionLost_=function(t){this.conn_=null,t||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(nr.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()},t.prototype.onConnectionShutdown_=function(t){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(t),this.onKill_=null),this.onDisconnect_=null,this.close()},t.prototype.sendData_=function(t){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(t)},t.prototype.close=function(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))},t.prototype.closeConnections_=function(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)},t}(),Vo=function(){function t(){}return t.prototype.put=function(t,e,n,r){},t.prototype.merge=function(t,e,n,r){},t.prototype.refreshAuthToken=function(t){},t.prototype.onDisconnectPut=function(t,e,n){},t.prototype.onDisconnectMerge=function(t,e,n){},t.prototype.onDisconnectCancel=function(t,e){},t.prototype.reportStats=function(t){},t}(),Wo=1e3,jo=3e5,Ko=function(t){function e(n,r,i,o,s,a){var u=t.call(this)||this;if(u.repoInfo_=n,u.onDataUpdate_=r,u.onConnectStatus_=i,u.onServerInfoUpdate_=o,u.authTokenProvider_=s,u.authOverride_=a,u.id=e.nextPersistentConnectionId_++,u.log_=fr("p:"+u.id+":"),u.interruptReasons_={},u.listens_={},u.outstandingPuts_=[],u.outstandingPutCount_=0,u.onDisconnectRequestQueue_=[],u.connected_=!1,u.reconnectDelay_=Wo,u.maxReconnectDelay_=jo,u.securityDebugCallback_=null,u.lastSessionId=null,u.establishConnectionTimer_=null,u.visible_=!1,u.requestCBHash_={},u.requestNumber_=0,u.realtime_=null,u.authToken_=null,u.forceTokenRefresh_=!1,u.invalidAuthTokenCount_=0,u.firstConnection_=!0,u.lastConnectionAttemptTime_=null,u.lastConnectionEstablishedTime_=null,a&&!mn())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");return u.scheduleConnect_(0),Ro.getInstance().on("visible",u.onVisible_,u),-1===n.host.indexOf("fblocal")&&ko.getInstance().on("online",u.onOnline_,u),u}return Je(e,t),e.prototype.sendRequest=function(t,e,n){var r=++this.requestNumber_,i={r:r,a:t,b:e};this.log_(En(i)),on(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),n&&(this.requestCBHash_[r]=n)},e.prototype.listen=function(t,e,n,r){var i=t.queryIdentifier(),o=t.path.toString();this.log_("Listen called for "+o+" "+i),this.listens_[o]=this.listens_[o]||{},on(t.getQueryParams().isDefault()||!t.getQueryParams().loadsAllData(),"listen() called for non-default but complete query"),on(!this.listens_[o][i],"listen() called twice for same path/queryId.");var s={onComplete:r,hashFn:e,query:t,tag:n};this.listens_[o][i]=s,this.connected_&&this.sendListen_(s)},e.prototype.sendListen_=function(t){var n=this,r=t.query,i=r.path.toString(),o=r.queryIdentifier();this.log_("Listen on "+i+" for "+o);var s={p:i};t.tag&&(s.q=r.queryObject(),s.t=t.tag),s.h=t.hashFn(),this.sendRequest("q",s,function(s){var a=s.d,u=s.s;e.warnOnListenWarnings_(a,r),(n.listens_[i]&&n.listens_[i][o])===t&&(n.log_("listen response",s),"ok"!==u&&n.removeListen_(i,o),t.onComplete&&t.onComplete(u,a))})},e.warnOnListenWarnings_=function(t,e){if(t&&"object"==typeof t&&Sn(t,"w")){var n=In(t,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){var r='".indexOn": "'+e.getQueryParams().getIndex().toString()+'"',i=e.path.toString();yr("Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding "+r+" at "+i+" to your security rules for better performance.")}}},e.prototype.refreshAuthToken=function(t){this.authToken_=t,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},function(){}),this.reduceReconnectDelayIfAdminCredential_(t)},e.prototype.reduceReconnectDelayIfAdminCredential_=function(t){var e;(t&&40===t.length||"object"==typeof(e=Tn(t).claims)&&!0===e.admin)&&(this.log_("Admin auth credential detected.  Reducing max reconnect time."),this.maxReconnectDelay_=3e4)},e.prototype.tryAuth=function(){var t,e=this;if(this.connected_&&this.authToken_){var n=this.authToken_,r=(t=Tn(n).claims)&&"object"==typeof t&&t.hasOwnProperty("iat")?"auth":"gauth",i={cred:n};null===this.authOverride_?i.noauth=!0:"object"==typeof this.authOverride_&&(i.authvar=this.authOverride_),this.sendRequest(r,i,function(t){var r=t.s,i=t.d||"error";e.authToken_===n&&("ok"===r?e.invalidAuthTokenCount_=0:e.onAuthRevoked_(r,i))})}},e.prototype.unlisten=function(t,e){var n=t.path.toString(),r=t.queryIdentifier();this.log_("Unlisten called for "+n+" "+r),on(t.getQueryParams().isDefault()||!t.getQueryParams().loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(n,r)&&this.connected_&&this.sendUnlisten_(n,r,t.queryObject(),e)},e.prototype.sendUnlisten_=function(t,e,n,r){this.log_("Unlisten on "+t+" for "+e);var i={p:t};r&&(i.q=n,i.t=r),this.sendRequest("n",i)},e.prototype.onDisconnectPut=function(t,e,n){this.connected_?this.sendOnDisconnect_("o",t,e,n):this.onDisconnectRequestQueue_.push({pathString:t,action:"o",data:e,onComplete:n})},e.prototype.onDisconnectMerge=function(t,e,n){this.connected_?this.sendOnDisconnect_("om",t,e,n):this.onDisconnectRequestQueue_.push({pathString:t,action:"om",data:e,onComplete:n})},e.prototype.onDisconnectCancel=function(t,e){this.connected_?this.sendOnDisconnect_("oc",t,null,e):this.onDisconnectRequestQueue_.push({pathString:t,action:"oc",data:null,onComplete:e})},e.prototype.sendOnDisconnect_=function(t,e,n,r){var i={p:e,d:n};this.log_("onDisconnect "+t,i),this.sendRequest(t,i,function(t){r&&setTimeout(function(){r(t.s,t.d)},Math.floor(0))})},e.prototype.put=function(t,e,n,r){this.putInternal("p",t,e,n,r)},e.prototype.merge=function(t,e,n,r){this.putInternal("m",t,e,n,r)},e.prototype.putInternal=function(t,e,n,r,i){var o={p:e,d:n};void 0!==i&&(o.h=i),this.outstandingPuts_.push({action:t,request:o,onComplete:r}),this.outstandingPutCount_++;var s=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(s):this.log_("Buffering put: "+e)},e.prototype.sendPut_=function(t){var e=this,n=this.outstandingPuts_[t].action,r=this.outstandingPuts_[t].request,i=this.outstandingPuts_[t].onComplete;this.outstandingPuts_[t].queued=this.connected_,this.sendRequest(n,r,function(r){e.log_(n+" response",r),delete e.outstandingPuts_[t],e.outstandingPutCount_--,0===e.outstandingPutCount_&&(e.outstandingPuts_=[]),i&&i(r.s,r.d)})},e.prototype.reportStats=function(t){var e=this;if(this.connected_){var n={c:t};this.log_("reportStats",n),this.sendRequest("s",n,function(t){if("ok"!==t.s){var n=t.d;e.log_("reportStats","Error sending stats: "+n)}})}},e.prototype.onDataMessage_=function(t){if("r"in t){this.log_("from server: "+En(t));var e=t.r,n=this.requestCBHash_[e];n&&(delete this.requestCBHash_[e],n(t.b))}else{if("error"in t)throw"A server-side error has occurred: "+t.error;"a"in t&&this.onDataPush_(t.a,t.b)}},e.prototype.onDataPush_=function(t,e){this.log_("handleServerMessage",t,e),"d"===t?this.onDataUpdate_(e.p,e.d,!1,e.t):"m"===t?this.onDataUpdate_(e.p,e.d,!0,e.t):"c"===t?this.onListenRevoked_(e.p,e.q):"ac"===t?this.onAuthRevoked_(e.s,e.d):"sd"===t?this.onSecurityDebugPacket_(e):pr("Unrecognized action received from server: "+En(t)+"\nAre you using the latest client?")},e.prototype.onReady_=function(t,e){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(t),this.lastSessionId=e,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)},e.prototype.scheduleConnect_=function(t){var e=this;on(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(function(){e.establishConnectionTimer_=null,e.establishConnection_()},Math.floor(t))},e.prototype.onVisible_=function(t){t&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible.  Reducing delay."),this.reconnectDelay_=Wo,this.realtime_||this.scheduleConnect_(0)),this.visible_=t},e.prototype.onOnline_=function(t){t?(this.log_("Browser went online."),this.reconnectDelay_=Wo,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline.  Killing connection."),this.realtime_&&this.realtime_.close())},e.prototype.onRealtimeDisconnect_=function(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){if(this.visible_){if(this.lastConnectionEstablishedTime_){(new Date).getTime()-this.lastConnectionEstablishedTime_>3e4&&(this.reconnectDelay_=Wo),this.lastConnectionEstablishedTime_=null}}else this.log_("Window isn't visible.  Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime();var t=(new Date).getTime()-this.lastConnectionAttemptTime_,e=Math.max(0,this.reconnectDelay_-t);e=Math.random()*e,this.log_("Trying to reconnect in "+e+"ms"),this.scheduleConnect_(e),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)},e.prototype.establishConnection_=function(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;var t=this.onDataMessage_.bind(this),n=this.onReady_.bind(this),r=this.onRealtimeDisconnect_.bind(this),i=this.id+":"+e.nextConnectionId_++,o=this,s=this.lastSessionId,a=!1,u=null,c=function(){u?u.close():(a=!0,r())};this.realtime_={close:c,sendRequest:function(t){on(u,"sendRequest call when we're not connected not allowed."),u.sendRequest(t)}};var h=this.forceTokenRefresh_;this.forceTokenRefresh_=!1,this.authTokenProvider_.getToken(h).then(function(e){a?lr("getToken() completed but was canceled"):(lr("getToken() completed. Creating connection."),o.authToken_=e&&e.accessToken,u=new Bo(i,o.repoInfo_,t,n,r,function(t){yr(t+" ("+o.repoInfo_.toString()+")"),o.interrupt("server_kill")},s))}).then(null,function(t){o.log_("Failed to get token: "+t),a||(nn&&yr(t),c())})}},e.prototype.interrupt=function(t){lr("Interrupting connection for reason: "+t),this.interruptReasons_[t]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())},e.prototype.resume=function(t){lr("Resuming connection for reason: "+t),delete this.interruptReasons_[t],Dn(this.interruptReasons_)&&(this.reconnectDelay_=Wo,this.realtime_||this.scheduleConnect_(0))},e.prototype.handleTimestamp_=function(t){var e=t-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:e})},e.prototype.cancelSentTransactions_=function(){for(var t=0;t<this.outstandingPuts_.length;t++){var e=this.outstandingPuts_[t];e&&"h"in e.request&&e.queued&&(e.onComplete&&e.onComplete("disconnect"),delete this.outstandingPuts_[t],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])},e.prototype.onListenRevoked_=function(t,e){var n;n=e?e.map(function(t){return Er(t)}).join("$"):"default";var r=this.removeListen_(t,n);r&&r.onComplete&&r.onComplete("permission_denied")},e.prototype.removeListen_=function(t,e){var n,r=new kr(t).toString();return void 0!==this.listens_[r]?(n=this.listens_[r][e],delete this.listens_[r][e],0===An(this.listens_[r])&&delete this.listens_[r]):n=void 0,n},e.prototype.onAuthRevoked_=function(t,e){lr("Auth token revoked: "+t+"/"+e),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==t&&"permission_denied"!==t||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=3&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))},e.prototype.onSecurityDebugPacket_=function(t){this.securityDebugCallback_?this.securityDebugCallback_(t):"msg"in t&&console.log("FIREBASE: "+t.msg.replace("\n","\nFIREBASE: "))},e.prototype.restoreState_=function(){var t=this;this.tryAuth(),Cn(this.listens_,function(e,n){Cn(n,function(e,n){t.sendListen_(n)})});for(var e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){var n=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(n.action,n.pathString,n.data,n.onComplete)}},e.prototype.sendConnectStats_=function(){var t={},e="js";nn?e="admin_node":en&&(e="node"),t["sdk."+e+"."+Yn.SDK_VERSION.replace(/\./g,"-")]=1,dn()?t["framework.cordova"]=1:yn()&&(t["framework.reactnative"]=1),this.reportStats(t)},e.prototype.shouldReconnect_=function(){var t=ko.getInstance().currentlyOnline();return Dn(this.interruptReasons_)&&t},e.nextPersistentConnectionId_=0,e.nextConnectionId_=0,e}(Vo),Qo=function(t){function e(e,n,r){var i=t.call(this)||this;return i.repoInfo_=e,i.onDataUpdate_=n,i.authTokenProvider_=r,i.log_=fr("p:rest:"),i.listens_={},i}return Je(e,t),e.prototype.reportStats=function(t){throw new Error("Method not implemented.")},e.getListenId_=function(t,e){return void 0!==e?"tag$"+e:(on(t.getQueryParams().isDefault(),"should have a tag if it's not a default query."),t.path.toString())},e.prototype.listen=function(t,n,r,i){var o=this,s=t.path.toString();this.log_("Listen called for "+s+" "+t.queryIdentifier());var a=e.getListenId_(t,r),u={};this.listens_[a]=u;var c=t.getQueryParams().toRestQueryStringParameters();this.restRequest_(s+".json",c,function(t,e){var n=e;(404===t&&(n=null,t=null),null===t&&o.onDataUpdate_(s,n,!1,r),In(o.listens_,a)===u)&&i(t?401==t?"permission_denied":"rest_error:"+t:"ok",null)})},e.prototype.unlisten=function(t,n){var r=e.getListenId_(t,n);delete this.listens_[r]},e.prototype.refreshAuthToken=function(t){},e.prototype.restRequest_=function(t,e,n){var r=this;void 0===e&&(e={}),e.format="export",this.authTokenProvider_.getToken(!1).then(function(i){var o=i&&i.accessToken;o&&(e.auth=o);var s,a=(r.repoInfo_.secure?"https://":"http://")+r.repoInfo_.host+t+"?ns="+r.repoInfo_.namespace+(s=[],Cn(e,function(t,e){Array.isArray(e)?e.forEach(function(e){s.push(encodeURIComponent(t)+"="+encodeURIComponent(e))}):s.push(encodeURIComponent(t)+"="+encodeURIComponent(e))}),s.length?"&"+s.join("&"):"");r.log_("Sending REST request for "+a);var u=new XMLHttpRequest;u.onreadystatechange=function(){if(n&&4===u.readyState){r.log_("REST Response for "+a+" received. status:",u.status,"response:",u.responseText);var t=null;if(u.status>=200&&u.status<300){try{t=wn(u.responseText)}catch(t){yr("Failed to parse JSON response for "+a+": "+u.responseText)}n(null,t)}else 401!==u.status&&404!==u.status&&yr("Got unsuccessful REST response for "+a+" Status: "+u.status),n(u.status);n=null}},u.open("GET",a,!0),u.send()})},e}(Vo),Ho=function(){function t(t,e,n){var r=this;this.repoInfo_=t,this.app=n,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new No,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=new Ki,this.persistentConnection_=null;var i=new _o(n);if(this.stats_=Eo.getCollection(t),e||Ar())this.server_=new Qo(this.repoInfo_,this.onDataUpdate_.bind(this),i),setTimeout(this.onConnectStatus_.bind(this,!0),0);else{var o=n.options.databaseAuthVariableOverride;if(void 0!==o&&null!==o){if("object"!=typeof o)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{En(o)}catch(t){throw new Error("Invalid authOverride provided: "+t)}}this.persistentConnection_=new Ko(this.repoInfo_,this.onDataUpdate_.bind(this),this.onConnectStatus_.bind(this),this.onServerInfoUpdate_.bind(this),i,o),this.server_=this.persistentConnection_}i.addTokenChangeListener(function(t){r.server_.refreshAuthToken(t)}),this.statsReporter_=Eo.getOrCreateReporter(t,function(){return new Co(r.stats_,r.server_)}),this.transactions_init_(),this.infoData_=new bo,this.infoSyncTree_=new vo({startListening:function(t,e,n,i){var o=[],s=r.infoData_.getNode(t.path);return s.isEmpty()||(o=r.infoSyncTree_.applyServerOverwrite(t.path,s),setTimeout(function(){i("ok")},0)),o},stopListening:function(){}}),this.updateInfo_("connected",!1),this.serverSyncTree_=new vo({startListening:function(t,e,n,i){return r.server_.listen(t,n,e,function(e,n){var o=i(e,n);r.eventQueue_.raiseEventsForChangedPath(t.path,o)}),[]},stopListening:function(t,e){r.server_.unlisten(t,e)}})}return t.prototype.toString=function(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host},t.prototype.name=function(){return this.repoInfo_.namespace},t.prototype.serverTime=function(){var t=this.infoData_.getNode(new kr(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t},t.prototype.generateServerValues=function(){return(t=(t={timestamp:this.serverTime()})||{}).timestamp=t.timestamp||(new Date).getTime(),t;var t},t.prototype.onDataUpdate_=function(t,e,n,r){this.dataUpdateCount++;var i=new kr(t);e=this.interceptServerDataCallback_?this.interceptServerDataCallback_(t,e):e;var o=[];if(r)if(n){var s=Rn(e,function(t){return Oi(t)});o=this.serverSyncTree_.applyTaggedQueryMerge(i,s,r)}else{var a=Oi(e);o=this.serverSyncTree_.applyTaggedQueryOverwrite(i,a,r)}else if(n){var u=Rn(e,function(t){return Oi(t)});o=this.serverSyncTree_.applyServerMerge(i,u)}else{var c=Oi(e);o=this.serverSyncTree_.applyServerOverwrite(i,c)}var h=i;o.length>0&&(h=this.rerunTransactions_(i)),this.eventQueue_.raiseEventsForChangedPath(h,o)},t.prototype.interceptServerData_=function(t){this.interceptServerDataCallback_=t},t.prototype.onConnectStatus_=function(t){this.updateInfo_("connected",t),!1===t&&this.runOnDisconnectEvents_()},t.prototype.onServerInfoUpdate_=function(t){var e=this;Sr(t,function(t,n){e.updateInfo_(n,t)})},t.prototype.updateInfo_=function(t,e){var n=new kr("/.info/"+t),r=Oi(e);this.infoData_.updateSnapshot(n,r);var i=this.infoSyncTree_.applyServerOverwrite(n,r);this.eventQueue_.raiseEventsForChangedPath(n,i)},t.prototype.getNextWriteId_=function(){return this.nextWriteId_++},t.prototype.setWithPriority=function(t,e,n,r){var i=this;this.log_("set",{path:t.toString(),value:e,priority:n});var o=this.generateServerValues(),s=Oi(e,n),a=Hi(s,o),u=this.getNextWriteId_(),c=this.serverSyncTree_.applyUserOverwrite(t,a,u,!0);this.eventQueue_.queueEvents(c),this.server_.put(t.toString(),s.val(!0),function(e,n){var o="ok"===e;o||yr("set at "+t+" failed: "+e);var s=i.serverSyncTree_.ackUserWrite(u,!o);i.eventQueue_.raiseEventsForChangedPath(t,s),i.callOnCompleteCallback(r,e,n)});var h=this.abortTransactions_(t);this.rerunTransactions_(h),this.eventQueue_.raiseEventsForChangedPath(h,[])},t.prototype.update=function(t,e,n){var r=this;this.log_("update",{path:t.toString(),value:e});var i=!0,o=this.generateServerValues(),s={};if(Cn(e,function(t,e){i=!1;var n=Oi(e);s[t]=Hi(n,o)}),i)lr("update() called with empty data.  Don't do anything."),this.callOnCompleteCallback(n,"ok");else{var a=this.getNextWriteId_(),u=this.serverSyncTree_.applyUserMerge(t,s,a);this.eventQueue_.queueEvents(u),this.server_.merge(t.toString(),e,function(e,i){var o="ok"===e;o||yr("update at "+t+" failed: "+e);var s=r.serverSyncTree_.ackUserWrite(a,!o),u=s.length>0?r.rerunTransactions_(t):t;r.eventQueue_.raiseEventsForChangedPath(u,s),r.callOnCompleteCallback(n,e,i)}),Cn(e,function(e){var n=r.abortTransactions_(t.child(e));r.rerunTransactions_(n)}),this.eventQueue_.raiseEventsForChangedPath(t,[])}},t.prototype.runOnDisconnectEvents_=function(){var t=this;this.log_("onDisconnectEvents");var e=this.generateServerValues(),n=[];(function(t,e){var n=new Ki;return t.forEachTree(new kr(""),function(t,r){n.remember(t,Hi(r,e))}),n})(this.onDisconnect_,e).forEachTree(kr.Empty,function(e,r){n=n.concat(t.serverSyncTree_.applyServerOverwrite(e,r));var i=t.abortTransactions_(e);t.rerunTransactions_(i)}),this.onDisconnect_=new Ki,this.eventQueue_.raiseEventsForChangedPath(kr.Empty,n)},t.prototype.onDisconnectCancel=function(t,e){var n=this;this.server_.onDisconnectCancel(t.toString(),function(r,i){"ok"===r&&n.onDisconnect_.forget(t),n.callOnCompleteCallback(e,r,i)})},t.prototype.onDisconnectSet=function(t,e,n){var r=this,i=Oi(e);this.server_.onDisconnectPut(t.toString(),i.val(!0),function(e,o){"ok"===e&&r.onDisconnect_.remember(t,i),r.callOnCompleteCallback(n,e,o)})},t.prototype.onDisconnectSetWithPriority=function(t,e,n,r){var i=this,o=Oi(e,n);this.server_.onDisconnectPut(t.toString(),o.val(!0),function(e,n){"ok"===e&&i.onDisconnect_.remember(t,o),i.callOnCompleteCallback(r,e,n)})},t.prototype.onDisconnectUpdate=function(t,e,n){var r=this;if(Dn(e))return lr("onDisconnect().update() called with empty data.  Don't do anything."),void this.callOnCompleteCallback(n,"ok");this.server_.onDisconnectMerge(t.toString(),e,function(i,o){"ok"===i&&Cn(e,function(e,n){var i=Oi(n);r.onDisconnect_.remember(t.child(e),i)}),r.callOnCompleteCallback(n,i,o)})},t.prototype.addEventCallbackForQuery=function(t,e){var n;n=".info"===t.path.getFront()?this.infoSyncTree_.addEventRegistration(t,e):this.serverSyncTree_.addEventRegistration(t,e),this.eventQueue_.raiseEventsAtPath(t.path,n)},t.prototype.removeEventCallbackForQuery=function(t,e){var n;n=".info"===t.path.getFront()?this.infoSyncTree_.removeEventRegistration(t,e):this.serverSyncTree_.removeEventRegistration(t,e),this.eventQueue_.raiseEventsAtPath(t.path,n)},t.prototype.interrupt=function(){this.persistentConnection_&&this.persistentConnection_.interrupt("repo_interrupt")},t.prototype.resume=function(){this.persistentConnection_&&this.persistentConnection_.resume("repo_interrupt")},t.prototype.stats=function(t){if(void 0===t&&(t=!1),"undefined"!=typeof console){var e;t?(this.statsListener_||(this.statsListener_=new To(this.stats_)),e=this.statsListener_.get()):e=this.stats_.get();var n=Object.keys(e).reduce(function(t,e){return Math.max(e.length,t)},0);Cn(e,function(t,e){for(var r=t.length;r<n+2;r++)t+=" ";console.log(t+e)})}},t.prototype.statsIncrementCounter=function(t){this.stats_.incrementCounter(t),this.statsReporter_.includeStat(t)},t.prototype.log_=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="";this.persistentConnection_&&(n=this.persistentConnection_.id+":"),lr.apply(void 0,[n].concat(t))},t.prototype.callOnCompleteCallback=function(t,e,n){t&&Dr(function(){if("ok"==e)t(null);else{var r=(e||"error").toUpperCase(),i=r;n&&(i+=": "+n);var o=new Error(i);o.code=r,t(o)}})},Object.defineProperty(t.prototype,"database",{get:function(){return this.__database||(this.__database=new ns(this))},enumerable:!0,configurable:!0}),t}(),Go=function(){function t(e){this.indexedFilter_=new oo(e.getIndex()),this.index_=e.getIndex(),this.startPost_=t.getStartPost_(e),this.endPost_=t.getEndPost_(e)}return t.prototype.getStartPost=function(){return this.startPost_},t.prototype.getEndPost=function(){return this.endPost_},t.prototype.matches=function(t){return this.index_.compare(this.getStartPost(),t)<=0&&this.index_.compare(t,this.getEndPost())<=0},t.prototype.updateChild=function(t,e,n,r,i,o){return this.matches(new oi(e,n))||(n=Ai.EMPTY_NODE),this.indexedFilter_.updateChild(t,e,n,r,i,o)},t.prototype.updateFullNode=function(t,e,n){e.isLeafNode()&&(e=Ai.EMPTY_NODE);var r=e.withIndex(this.index_);r=r.updatePriority(Ai.EMPTY_NODE);var i=this;return e.forEachChild(gi,function(t,e){i.matches(new oi(t,e))||(r=r.updateImmediateChild(t,Ai.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(t,r,n)},t.prototype.updatePriority=function(t,e){return t},t.prototype.filtersNodes=function(){return!0},t.prototype.getIndexedFilter=function(){return this.indexedFilter_},t.prototype.getIndex=function(){return this.index_},t.getStartPost_=function(t){if(t.hasStart()){var e=t.getIndexStartName();return t.getIndex().makePost(t.getIndexStartValue(),e)}return t.getIndex().minPost()},t.getEndPost_=function(t){if(t.hasEnd()){var e=t.getIndexEndName();return t.getIndex().makePost(t.getIndexEndValue(),e)}return t.getIndex().maxPost()},t}(),zo=function(){function t(t){this.rangedFilter_=new Go(t),this.index_=t.getIndex(),this.limit_=t.getLimit(),this.reverse_=!t.isViewFromLeft()}return t.prototype.updateChild=function(t,e,n,r,i,o){return this.rangedFilter_.matches(new oi(e,n))||(n=Ai.EMPTY_NODE),t.getImmediateChild(e).equals(n)?t:t.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(t,e,n,r,i,o):this.fullLimitUpdateChild_(t,e,n,i,o)},t.prototype.updateFullNode=function(t,e,n){var r;if(e.isLeafNode()||e.isEmpty())r=Ai.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<e.numChildren()&&e.isIndexed(this.index_)){r=Ai.EMPTY_NODE.withIndex(this.index_);var i=void 0;i=this.reverse_?e.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):e.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);for(var o=0;i.hasNext()&&o<this.limit_;){var s=i.getNext();if(!(this.reverse_?this.index_.compare(this.rangedFilter_.getStartPost(),s)<=0:this.index_.compare(s,this.rangedFilter_.getEndPost())<=0))break;r=r.updateImmediateChild(s.name,s.node),o++}}else{r=(r=e.withIndex(this.index_)).updatePriority(Ai.EMPTY_NODE);var a=void 0,u=void 0,c=void 0;i=void 0;if(this.reverse_){i=r.getReverseIterator(this.index_),a=this.rangedFilter_.getEndPost(),u=this.rangedFilter_.getStartPost();var h=this.index_.getCompare();c=function(t,e){return h(e,t)}}else i=r.getIterator(this.index_),a=this.rangedFilter_.getStartPost(),u=this.rangedFilter_.getEndPost(),c=this.index_.getCompare();o=0;for(var l=!1;i.hasNext();){s=i.getNext();!l&&c(a,s)<=0&&(l=!0),l&&o<this.limit_&&c(s,u)<=0?o++:r=r.updateImmediateChild(s.name,Ai.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(t,r,n)},t.prototype.updatePriority=function(t,e){return t},t.prototype.filtersNodes=function(){return!0},t.prototype.getIndexedFilter=function(){return this.rangedFilter_.getIndexedFilter()},t.prototype.getIndex=function(){return this.index_},t.prototype.fullLimitUpdateChild_=function(t,e,n,r,i){var o;if(this.reverse_){var s=this.index_.getCompare();o=function(t,e){return s(e,t)}}else o=this.index_.getCompare();var a=t;on(a.numChildren()==this.limit_,"");var u=new oi(e,n),c=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),h=this.rangedFilter_.matches(u);if(a.hasChild(e)){for(var l=a.getImmediateChild(e),f=r.getChildAfterChild(this.index_,c,this.reverse_);null!=f&&(f.name==e||a.hasChild(f.name));)f=r.getChildAfterChild(this.index_,f,this.reverse_);var p=null==f?1:o(f,u);if(h&&!n.isEmpty()&&p>=0)return null!=i&&i.trackChildChange(io.childChangedChange(e,n,l)),a.updateImmediateChild(e,n);null!=i&&i.trackChildChange(io.childRemovedChange(e,l));var d=a.updateImmediateChild(e,Ai.EMPTY_NODE);return null!=f&&this.rangedFilter_.matches(f)?(null!=i&&i.trackChildChange(io.childAddedChange(f.name,f.node)),d.updateImmediateChild(f.name,f.node)):d}return n.isEmpty()?t:h&&o(c,u)>=0?(null!=i&&(i.trackChildChange(io.childRemovedChange(c.name,c.node)),i.trackChildChange(io.childAddedChange(e,n))),a.updateImmediateChild(e,n).updateImmediateChild(c.name,Ai.EMPTY_NODE)):t},t}(),Yo=function(){function t(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=gi}return t.prototype.hasStart=function(){return this.startSet_},t.prototype.isViewFromLeft=function(){return""===this.viewFrom_?this.startSet_:this.viewFrom_===t.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT},t.prototype.getIndexStartValue=function(){return on(this.startSet_,"Only valid if start has been set"),this.indexStartValue_},t.prototype.getIndexStartName=function(){return on(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:gr},t.prototype.hasEnd=function(){return this.endSet_},t.prototype.getIndexEndValue=function(){return on(this.endSet_,"Only valid if end has been set"),this.indexEndValue_},t.prototype.getIndexEndName=function(){return on(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:vr},t.prototype.hasLimit=function(){return this.limitSet_},t.prototype.hasAnchoredLimit=function(){return this.limitSet_&&""!==this.viewFrom_},t.prototype.getLimit=function(){return on(this.limitSet_,"Only valid if limit has been set"),this.limit_},t.prototype.getIndex=function(){return this.index_},t.prototype.copy_=function(){var e=new t;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e},t.prototype.limit=function(t){var e=this.copy_();return e.limitSet_=!0,e.limit_=t,e.viewFrom_="",e},t.prototype.limitToFirst=function(e){var n=this.copy_();return n.limitSet_=!0,n.limit_=e,n.viewFrom_=t.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT,n},t.prototype.limitToLast=function(e){var n=this.copy_();return n.limitSet_=!0,n.limit_=e,n.viewFrom_=t.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_RIGHT,n},t.prototype.startAt=function(t,e){var n=this.copy_();return n.startSet_=!0,void 0===t&&(t=null),n.indexStartValue_=t,null!=e?(n.startNameSet_=!0,n.indexStartName_=e):(n.startNameSet_=!1,n.indexStartName_=""),n},t.prototype.endAt=function(t,e){var n=this.copy_();return n.endSet_=!0,void 0===t&&(t=null),n.indexEndValue_=t,void 0!==e?(n.endNameSet_=!0,n.indexEndName_=e):(n.endNameSet_=!1,n.indexEndName_=""),n},t.prototype.orderBy=function(t){var e=this.copy_();return e.index_=t,e},t.prototype.getQueryObject=function(){var e=t.WIRE_PROTOCOL_CONSTANTS_,n={};if(this.startSet_&&(n[e.INDEX_START_VALUE]=this.indexStartValue_,this.startNameSet_&&(n[e.INDEX_START_NAME]=this.indexStartName_)),this.endSet_&&(n[e.INDEX_END_VALUE]=this.indexEndValue_,this.endNameSet_&&(n[e.INDEX_END_NAME]=this.indexEndName_)),this.limitSet_){n[e.LIMIT]=this.limit_;var r=this.viewFrom_;""===r&&(r=this.isViewFromLeft()?e.VIEW_FROM_LEFT:e.VIEW_FROM_RIGHT),n[e.VIEW_FROM]=r}return this.index_!==gi&&(n[e.INDEX]=this.index_.toString()),n},t.prototype.loadsAllData=function(){return!(this.startSet_||this.endSet_||this.limitSet_)},t.prototype.isDefault=function(){return this.loadsAllData()&&this.index_==gi},t.prototype.getNodeFilter=function(){return this.loadsAllData()?new oo(this.getIndex()):this.hasLimit()?new zo(this):new Go(this)},t.prototype.toRestQueryStringParameters=function(){var e,n=t.REST_QUERY_CONSTANTS_,r={};return this.isDefault()?r:(this.index_===gi?e=n.PRIORITY_INDEX:this.index_===Mi?e=n.VALUE_INDEX:this.index_===ui?e=n.KEY_INDEX:(on(this.index_ instanceof xi,"Unrecognized index type!"),e=this.index_.toString()),r[n.ORDER_BY]=En(e),this.startSet_&&(r[n.START_AT]=En(this.indexStartValue_),this.startNameSet_&&(r[n.START_AT]+=","+En(this.indexStartName_))),this.endSet_&&(r[n.END_AT]=En(this.indexEndValue_),this.endNameSet_&&(r[n.END_AT]+=","+En(this.indexEndName_))),this.limitSet_&&(this.isViewFromLeft()?r[n.LIMIT_TO_FIRST]=this.limit_:r[n.LIMIT_TO_LAST]=this.limit_),r)},t.WIRE_PROTOCOL_CONSTANTS_={INDEX_START_VALUE:"sp",INDEX_START_NAME:"sn",INDEX_END_VALUE:"ep",INDEX_END_NAME:"en",LIMIT:"l",VIEW_FROM:"vf",VIEW_FROM_LEFT:"l",VIEW_FROM_RIGHT:"r",INDEX:"i"},t.REST_QUERY_CONSTANTS_={ORDER_BY:"orderBy",PRIORITY_INDEX:"$priority",VALUE_INDEX:"$value",KEY_INDEX:"$key",START_AT:"startAt",END_AT:"endAt",LIMIT_TO_FIRST:"limitToFirst",LIMIT_TO_LAST:"limitToLast"},t.DEFAULT=new t,t}(),Xo=function(t){function e(e,n){if(!(e instanceof Ho))throw new Error("new Reference() no longer supported - use app.database().");return t.call(this,e,n,Yo.DEFAULT,!1)||this}return Je(e,t),e.prototype.getKey=function(){return Fn("Reference.key",0,0,arguments.length),this.path.isEmpty()?null:this.path.getBack()},e.prototype.child=function(t){return Fn("Reference.child",1,1,arguments.length),"number"==typeof t?t=String(t):t instanceof kr||(null===this.path.getFront()?function(t,e,n,r){n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),Zr(t,e,n,r)}("Reference.child",1,t,!1):Zr("Reference.child",1,t,!1)),new e(this.repo,this.path.child(t))},e.prototype.getParent=function(){Fn("Reference.parent",0,0,arguments.length);var t=this.path.parent();return null===t?null:new e(this.repo,t)},e.prototype.getRoot=function(){Fn("Reference.root",0,0,arguments.length);for(var t=this;null!==t.getParent();)t=t.getParent();return t},e.prototype.databaseProp=function(){return this.repo.database},e.prototype.set=function(t,e){Fn("Reference.set",1,2,arguments.length),ti("Reference.set",this.path),Gr("Reference.set",1,t,this.path,!1),qn("Reference.set",2,e,!0);var n=new pn;return this.repo.setWithPriority(this.path,t,null,n.wrapCallback(e)),n.promise},e.prototype.update=function(t,e){if(Fn("Reference.update",1,2,arguments.length),ti("Reference.update",this.path),Array.isArray(t)){for(var n={},r=0;r<t.length;++r)n[""+r]=t[r];t=n,yr("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}Yr("Reference.update",1,t,this.path,!1),qn("Reference.update",2,e,!0);var i=new pn;return this.repo.update(this.path,t,i.wrapCallback(e)),i.promise},e.prototype.setWithPriority=function(t,e,n){if(Fn("Reference.setWithPriority",2,3,arguments.length),ti("Reference.setWithPriority",this.path),Gr("Reference.setWithPriority",1,t,this.path,!1),Xr("Reference.setWithPriority",2,e,!1),qn("Reference.setWithPriority",3,n,!0),".length"===this.getKey()||".keys"===this.getKey())throw"Reference.setWithPriority failed: "+this.getKey()+" is a read-only object.";var r=new pn;return this.repo.setWithPriority(this.path,t,e,r.wrapCallback(n)),r.promise},e.prototype.remove=function(t){return Fn("Reference.remove",0,1,arguments.length),ti("Reference.remove",this.path),qn("Reference.remove",1,t,!0),this.set(null,t)},e.prototype.transaction=function(t,e,n){if(Fn("Reference.transaction",1,3,arguments.length),ti("Reference.transaction",this.path),qn("Reference.transaction",1,t,!1),qn("Reference.transaction",2,e,!0),function(t,e,n,r){if((!r||void 0!==n)&&"boolean"!=typeof n)throw new Error(Un(t,e,r)+"must be a boolean.")}("Reference.transaction",3,n,!0),".length"===this.getKey()||".keys"===this.getKey())throw"Reference.transaction failed: "+this.getKey()+" is a read-only object.";void 0===n&&(n=!0);var r=new pn;"function"==typeof e&&r.promise.catch(function(){});return this.repo.startTransaction(this.path,t,function(t,n,i){t?r.reject(t):r.resolve(new ri(n,i)),"function"==typeof e&&e(t,n,i)},n),r.promise},e.prototype.setPriority=function(t,e){Fn("Reference.setPriority",1,2,arguments.length),ti("Reference.setPriority",this.path),Xr("Reference.setPriority",1,t,!1),qn("Reference.setPriority",2,e,!0);var n=new pn;return this.repo.setWithPriority(this.path.child(".priority"),t,null,n.wrapCallback(e)),n.promise},e.prototype.push=function(t,e){Fn("Reference.push",0,2,arguments.length),ti("Reference.push",this.path),Gr("Reference.push",1,t,this.path,!0),qn("Reference.push",2,e,!0);var n,r=this.repo.serverTime(),i=ii(r),o=this.child(i),s=this.child(i);return n=null!=t?o.set(t,e).then(function(){return s}):Promise.resolve(s),o.then=n.then.bind(n),o.catch=n.then.bind(n,void 0),"function"==typeof e&&n.catch(function(){}),o},e.prototype.onDisconnect=function(){return ti("Reference.onDisconnect",this.path),new ni(this.repo,this.path)},Object.defineProperty(e.prototype,"database",{get:function(){return this.databaseProp()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"key",{get:function(){return this.getKey()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.getParent()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"root",{get:function(){return this.getRoot()},enumerable:!0,configurable:!0}),e}(Wi);Wi.__referenceConstructor=Xo,po.__referenceConstructor=Xo;var Jo,$o=function(){return function(){this.children={},this.childCount=0,this.value=null}}(),Zo=function(){function t(t,e,n){void 0===t&&(t=""),void 0===e&&(e=null),void 0===n&&(n=new $o),this.name_=t,this.parent_=e,this.node_=n}return t.prototype.subTree=function(e){for(var n,r=e instanceof kr?e:new kr(e),i=this;null!==(n=r.getFront());){i=new t(n,i,In(i.node_.children,n)||new $o),r=r.popFront()}return i},t.prototype.getValue=function(){return this.node_.value},t.prototype.setValue=function(t){on(void 0!==t,"Cannot set value to undefined"),this.node_.value=t,this.updateParents_()},t.prototype.clear=function(){this.node_.value=null,this.node_.children={},this.node_.childCount=0,this.updateParents_()},t.prototype.hasChildren=function(){return this.node_.childCount>0},t.prototype.isEmpty=function(){return null===this.getValue()&&!this.hasChildren()},t.prototype.forEachChild=function(e){var n=this;Cn(this.node_.children,function(r,i){e(new t(r,n,i))})},t.prototype.forEachDescendant=function(t,e,n){e&&!n&&t(this),this.forEachChild(function(e){e.forEachDescendant(t,!0,n)}),e&&n&&t(this)},t.prototype.forEachAncestor=function(t,e){for(var n=e?this:this.parent();null!==n;){if(t(n))return!0;n=n.parent()}return!1},t.prototype.forEachImmediateDescendantWithValue=function(t){this.forEachChild(function(e){null!==e.getValue()?t(e):e.forEachImmediateDescendantWithValue(t)})},t.prototype.path=function(){return new kr(null===this.parent_?this.name_:this.parent_.path()+"/"+this.name_)},t.prototype.name=function(){return this.name_},t.prototype.parent=function(){return this.parent_},t.prototype.updateParents_=function(){null!==this.parent_&&this.parent_.updateChild_(this.name_,this)},t.prototype.updateChild_=function(t,e){var n=e.isEmpty(),r=Sn(this.node_.children,t);n&&r?(delete this.node_.children[t],this.node_.childCount--,this.updateParents_()):n||r||(this.node_.children[t]=e.node_,this.node_.childCount++,this.updateParents_())},t}();!function(t){t[t.RUN=0]="RUN",t[t.SENT=1]="SENT",t[t.COMPLETED=2]="COMPLETED",t[t.SENT_NEEDS_ABORT=3]="SENT_NEEDS_ABORT",t[t.NEEDS_ABORT=4]="NEEDS_ABORT"}(Jo||(Jo={})),Ho.MAX_TRANSACTION_RETRIES_=25,Ho.prototype.transactions_init_=function(){this.transactionQueueTree_=new Zo},Ho.prototype.startTransaction=function(t,e,n,r){this.log_("transaction on "+t);var i=function(){},o=new Xo(this,t);o.on("value",i);var s={path:t,update:e,onComplete:n,status:null,order:or(),applyLocally:r,retryCount:0,unwatcher:function(){o.off("value",i)},abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},a=this.getLatestState_(t);s.currentInputSnapshot=a;var u=s.update(a.val());if(void 0===u){if(s.unwatcher(),s.currentOutputSnapshotRaw=null,s.currentOutputSnapshotResolved=null,s.onComplete){var c=new Fi(s.currentInputSnapshot,new Xo(this,s.path),gi);s.onComplete(null,!1,c)}}else{zr("transaction failed: Data returned ",u,s.path),s.status=Jo.RUN;var h=this.transactionQueueTree_.subTree(t),l=h.getValue()||[];l.push(s),h.setValue(l);var f=void 0;if("object"==typeof u&&null!==u&&Sn(u,".priority"))f=In(u,".priority"),on(Hr(f),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.");else f=(this.serverSyncTree_.calcCompleteEventCache(t)||Ai.EMPTY_NODE).getPriority().val();f=f;var p=this.generateServerValues(),d=Oi(u,f),y=Hi(d,p);s.currentOutputSnapshotRaw=d,s.currentOutputSnapshotResolved=y,s.currentWriteId=this.getNextWriteId_();var m=this.serverSyncTree_.applyUserOverwrite(t,y,s.currentWriteId,s.applyLocally);this.eventQueue_.raiseEventsForChangedPath(t,m),this.sendReadyTransactions_()}},Ho.prototype.getLatestState_=function(t,e){return this.serverSyncTree_.calcCompleteEventCache(t,e)||Ai.EMPTY_NODE},Ho.prototype.sendReadyTransactions_=function(t){var e=this;if(void 0===t&&(t=this.transactionQueueTree_),t||this.pruneCompletedTransactionsBelowNode_(t),null!==t.getValue()){var n=this.buildTransactionQueue_(t);on(n.length>0,"Sending zero length transaction queue"),n.every(function(t){return t.status===Jo.RUN})&&this.sendTransactionQueue_(t.path(),n)}else t.hasChildren()&&t.forEachChild(function(t){e.sendReadyTransactions_(t)})},Ho.prototype.sendTransactionQueue_=function(t,e){for(var n=this,r=e.map(function(t){return t.currentWriteId}),i=this.getLatestState_(t,r),o=i,s=i.hash(),a=0;a<e.length;a++){var u=e[a];on(u.status===Jo.RUN,"tryToSendTransactionQueue_: items in queue should all be run."),u.status=Jo.SENT,u.retryCount++;var c=kr.relativePath(t,u.path);o=o.updateChild(c,u.currentOutputSnapshotRaw)}var h=o.val(!0),l=t;this.server_.put(l.toString(),h,function(r){n.log_("transaction put response",{path:l.toString(),status:r});var i=[];if("ok"===r){for(var o=[],s=0;s<e.length;s++){if(e[s].status=Jo.COMPLETED,i=i.concat(n.serverSyncTree_.ackUserWrite(e[s].currentWriteId)),e[s].onComplete){var a=e[s].currentOutputSnapshotResolved,u=new Xo(n,e[s].path),c=new Fi(a,u,gi);o.push(e[s].onComplete.bind(null,null,!0,c))}e[s].unwatcher()}n.pruneCompletedTransactionsBelowNode_(n.transactionQueueTree_.subTree(t)),n.sendReadyTransactions_(),n.eventQueue_.raiseEventsForChangedPath(t,i);for(s=0;s<o.length;s++)Dr(o[s])}else{if("datastale"===r)for(s=0;s<e.length;s++)e[s].status===Jo.SENT_NEEDS_ABORT?e[s].status=Jo.NEEDS_ABORT:e[s].status=Jo.RUN;else{yr("transaction at "+l.toString()+" failed: "+r);for(s=0;s<e.length;s++)e[s].status=Jo.NEEDS_ABORT,e[s].abortReason=r}n.rerunTransactions_(t)}},s)},Ho.prototype.rerunTransactions_=function(t){var e=this.getAncestorTransactionNode_(t),n=e.path(),r=this.buildTransactionQueue_(e);return this.rerunTransactionQueue_(r,n),n},Ho.prototype.rerunTransactionQueue_=function(t,e){if(0!==t.length){for(var n,r=[],i=[],o=t.filter(function(t){return t.status===Jo.RUN}).map(function(t){return t.currentWriteId}),s=0;s<t.length;s++){var a=t[s],u=kr.relativePath(e,a.path),c=!1,h=void 0;if(on(null!==u,"rerunTransactionsUnderNode_: relativePath should not be null."),a.status===Jo.NEEDS_ABORT)c=!0,h=a.abortReason,i=i.concat(this.serverSyncTree_.ackUserWrite(a.currentWriteId,!0));else if(a.status===Jo.RUN)if(a.retryCount>=Ho.MAX_TRANSACTION_RETRIES_)c=!0,h="maxretry",i=i.concat(this.serverSyncTree_.ackUserWrite(a.currentWriteId,!0));else{var l=this.getLatestState_(a.path,o);a.currentInputSnapshot=l;var f=t[s].update(l.val());if(void 0!==f){zr("transaction failed: Data returned ",f,a.path);var p=Oi(f);"object"==typeof f&&null!=f&&Sn(f,".priority")||(p=p.updatePriority(l.getPriority()));var d=a.currentWriteId,y=this.generateServerValues(),m=Hi(p,y);a.currentOutputSnapshotRaw=p,a.currentOutputSnapshotResolved=m,a.currentWriteId=this.getNextWriteId_(),o.splice(o.indexOf(d),1),i=(i=i.concat(this.serverSyncTree_.applyUserOverwrite(a.path,m,a.currentWriteId,a.applyLocally))).concat(this.serverSyncTree_.ackUserWrite(d,!0))}else c=!0,h="nodata",i=i.concat(this.serverSyncTree_.ackUserWrite(a.currentWriteId,!0))}if(this.eventQueue_.raiseEventsForChangedPath(e,i),i=[],c&&(t[s].status=Jo.COMPLETED,n=t[s].unwatcher,setTimeout(n,Math.floor(0)),t[s].onComplete))if("nodata"===h){var g=new Xo(this,t[s].path),v=t[s].currentInputSnapshot,b=new Fi(v,g,gi);r.push(t[s].onComplete.bind(null,null,!1,b))}else r.push(t[s].onComplete.bind(null,new Error(h),!1,null))}this.pruneCompletedTransactionsBelowNode_(this.transactionQueueTree_);for(s=0;s<r.length;s++)Dr(r[s]);this.sendReadyTransactions_()}},Ho.prototype.getAncestorTransactionNode_=function(t){for(var e,n=this.transactionQueueTree_;null!==(e=t.getFront())&&null===n.getValue();)n=n.subTree(e),t=t.popFront();return n},Ho.prototype.buildTransactionQueue_=function(t){var e=[];return this.aggregateTransactionQueuesForNode_(t,e),e.sort(function(t,e){return t.order-e.order}),e},Ho.prototype.aggregateTransactionQueuesForNode_=function(t,e){var n=this,r=t.getValue();if(null!==r)for(var i=0;i<r.length;i++)e.push(r[i]);t.forEachChild(function(t){n.aggregateTransactionQueuesForNode_(t,e)})},Ho.prototype.pruneCompletedTransactionsBelowNode_=function(t){var e=this,n=t.getValue();if(n){for(var r=0,i=0;i<n.length;i++)n[i].status!==Jo.COMPLETED&&(n[r]=n[i],r++);n.length=r,t.setValue(n.length>0?n:null)}t.forEachChild(function(t){e.pruneCompletedTransactionsBelowNode_(t)})},Ho.prototype.abortTransactions_=function(t){var e=this,n=this.getAncestorTransactionNode_(t).path(),r=this.transactionQueueTree_.subTree(t);return r.forEachAncestor(function(t){e.abortTransactionsOnNode_(t)}),this.abortTransactionsOnNode_(r),r.forEachDescendant(function(t){e.abortTransactionsOnNode_(t)}),n},Ho.prototype.abortTransactionsOnNode_=function(t){var e=t.getValue();if(null!==e){for(var n=[],r=[],i=-1,o=0;o<e.length;o++)if(e[o].status===Jo.SENT_NEEDS_ABORT);else if(e[o].status===Jo.SENT)on(i===o-1,"All SENT items should be at beginning of queue."),i=o,e[o].status=Jo.SENT_NEEDS_ABORT,e[o].abortReason="set";else if(on(e[o].status===Jo.RUN,"Unexpected transaction status in abort"),e[o].unwatcher(),r=r.concat(this.serverSyncTree_.ackUserWrite(e[o].currentWriteId,!0)),e[o].onComplete){n.push(e[o].onComplete.bind(null,new Error("set"),!1,null))}-1===i?t.setValue(null):e.length=i+1,this.eventQueue_.raiseEventsForChangedPath(t.path(),r);for(o=0;o<n.length;o++)Dr(n[o])}};var ts,es=function(){function t(){this.repos_={},this.useRestClient_=!1}return t.getInstance=function(){return ts||(ts=new t),ts},t.prototype.interrupt=function(){for(var t in this.repos_)for(var e in this.repos_[t])this.repos_[t][e].interrupt()},t.prototype.resume=function(){for(var t in this.repos_)for(var e in this.repos_[t])this.repos_[t][e].resume()},t.prototype.databaseFromApp=function(t,e){var n=e||t.options.databaseURL;void 0===n&&dr("Can't determine Firebase Database URL.  Be sure to include databaseURL option when calling firebase.initializeApp().");var r=Br(n),i=r.repoInfo;return ei("Invalid Firebase Database URL",1,r),r.path.isEmpty()||dr("Database URL must point to the root of a Firebase Database (not including a child path)."),this.createRepo(i,t).database},t.prototype.deleteRepo=function(t){var e=In(this.repos_,t.app.name);e&&In(e,t.repoInfo_.toURLString())===t||dr("Database "+t.app.name+"("+t.repoInfo_+") has already been deleted."),t.interrupt(),delete e[t.repoInfo_.toURLString()]},t.prototype.createRepo=function(t,e){var n=In(this.repos_,e.name);n||(n={},this.repos_[e.name]=n);var r=In(n,t.toURLString());return r&&dr("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),r=new Ho(t,this.useRestClient_,e),n[t.toURLString()]=r,r},t.prototype.forceRestClient=function(t){this.useRestClient_=t},t}(),ns=function(){function t(t){this.repo_=t,t instanceof Ho||dr("Don't call new Database() directly - please use firebase.database()."),this.root_=new Xo(t,kr.Empty),this.INTERNAL=new rs(this)}return Object.defineProperty(t.prototype,"app",{get:function(){return this.repo_.app},enumerable:!0,configurable:!0}),t.prototype.ref=function(t){return this.checkDeleted_("ref"),Fn("database.ref",0,1,arguments.length),t instanceof Xo?this.refFromURL(t.toString()):void 0!==t?this.root_.child(t):this.root_},t.prototype.refFromURL=function(t){var e="database.refFromURL";this.checkDeleted_(e),Fn(e,1,1,arguments.length);var n=Br(t);ei(e,1,n);var r=n.repoInfo;return r.host!==this.repo_.repoInfo_.host&&dr(e+": Host name does not match the current database: (found "+r.host+" but expected "+this.repo_.repoInfo_.host+")"),this.ref(n.path.toString())},t.prototype.checkDeleted_=function(t){null===this.repo_&&dr("Cannot call "+t+" on a deleted database.")},t.prototype.goOffline=function(){Fn("database.goOffline",0,0,arguments.length),this.checkDeleted_("goOffline"),this.repo_.interrupt()},t.prototype.goOnline=function(){Fn("database.goOnline",0,0,arguments.length),this.checkDeleted_("goOnline"),this.repo_.resume()},t.ServerValue={TIMESTAMP:{".sv":"timestamp"}},t}(),rs=function(){function t(t){this.database=t}return t.prototype.delete=function(){return Ze(this,void 0,void 0,function(){return tn(this,function(t){return this.database.checkDeleted_("delete"),es.getInstance().deleteRepo(this.database.repo_),this.database.repo_=null,this.database.root_=null,this.database.INTERNAL=null,this.database=null,[2]})})},t}(),is=Object.freeze({forceLongPolling:function(){Uo.forceDisallow(),Mo.forceAllow()},forceWebSockets:function(){Mo.forceDisallow()},isWebSocketsAvailable:function(){return Uo.isAvailable()},setSecurityDebugCallback:function(t,e){t.repo.persistentConnection_.securityDebugCallback_=e},stats:function(t,e){t.repo.stats(e)},statsIncrementCounter:function(t,e){t.repo.statsIncrementCounter(e)},dataUpdateCount:function(t){return t.repo.dataUpdateCount},interceptServerData:function(t,e){return t.repo.interceptServerData_(e)}}),os=Ko;Ko.prototype.simpleListen=function(t,e){this.sendRequest("q",{p:t},e)},Ko.prototype.echo=function(t,e){this.sendRequest("echo",{d:t},e)};var ss,as=Bo,us=Lr,cs=Object.freeze({DataConnection:os,RealTimeConnection:as,hijackHash:function(t){var e=Ko.prototype.put;return Ko.prototype.put=function(n,r,i,o){void 0!==o&&(o=t()),e.call(this,n,r,i,o)},function(){Ko.prototype.put=e}},ConnectionTarget:us,queryIdentifier:function(t){return t.queryIdentifier()},listens:function(t){return t.repo.persistentConnection_.listens_},forceRestClient:function(t){es.getInstance().forceRestClient(t)}}),hs=ns.ServerValue;ss=Yn.INTERNAL.registerService("database",function(t,e,n){return es.getInstance().databaseFromApp(t,n)},{Reference:Xo,Query:Wi,Database:ns,enableLogging:hr,INTERNAL:is,ServerValue:hs,TEST_ACCESS:cs},null,!0),mn()&&(module.exports=ss);var ls,fs="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},ps=ps||{},ds=fs;function ys(t){return"string"==typeof t}function ms(t,e){t=t.split("."),e=e||ds;for(var n=0;n<t.length;n++)if(null==(e=e[t[n]]))return null;return e}function gs(){}function vs(t){var e=typeof t;if("object"==e){if(!t)return"null";if(t instanceof Array)return"array";if(t instanceof Object)return e;var n=Object.prototype.toString.call(t);if("[object Window]"==n)return"object";if("[object Array]"==n||"number"==typeof t.length&&void 0!==t.splice&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("splice"))return"array";if("[object Function]"==n||void 0!==t.call&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("call"))return"function"}else if("function"==e&&void 0===t.call)return"object";return e}function bs(t){return"array"==vs(t)}function _s(t){var e=vs(t);return"array"==e||"object"==e&&"number"==typeof t.length}function ws(t){return"function"==vs(t)}function Es(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var Ts="closure_uid_"+(1e9*Math.random()>>>0),Ss=0;function Is(t,e,n){return t.call.apply(t.bind,arguments)}function Cs(t,e,n){if(!t)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function Ns(t,e,n){return(Ns=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?Is:Cs).apply(null,arguments)}function Ds(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}var As=Date.now||function(){return+new Date};function Rs(t,e){function n(){}n.prototype=e.prototype,t.L=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.mh=function(t,n,r){for(var i=Array(arguments.length-2),o=2;o<arguments.length;o++)i[o-2]=arguments[o];return e.prototype[n].apply(t,i)}}function ks(t){if(Error.captureStackTrace)Error.captureStackTrace(this,ks);else{var e=Error().stack;e&&(this.stack=e)}t&&(this.message=String(t))}function Os(t,e){for(var n="",r=(t=t.split("%s")).length-1,i=0;i<r;i++)n+=t[i]+(i<e.length?e[i]:"%s");ks.call(this,n+t[r])}function Ps(){0!=Ls&&(Ms[this[Ts]||(this[Ts]=++Ss)]=this),this.Ka=this.Ka,this.Qa=this.Qa}Rs(ks,Error),ks.prototype.name="CustomError",Rs(Os,ks),Os.prototype.name="AssertionError";var Ls=0,Ms={};Ps.prototype.Ka=!1,Ps.prototype.bb=function(){if(!this.Ka&&(this.Ka=!0,this.F(),0!=Ls)){var t=this[Ts]||(this[Ts]=++Ss);if(0!=Ls&&this.Qa&&0<this.Qa.length)throw Error(this+" did not empty its onDisposeCallbacks queue. This probably means it overrode dispose() or disposeInternal() without calling the superclass' method.");delete Ms[t]}},Ps.prototype.F=function(){if(this.Qa)for(;this.Qa.length;)this.Qa.shift()()};var xs=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(ys(t))return ys(e)&&1==e.length?t.indexOf(e,0):-1;for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},Fs=Array.prototype.lastIndexOf?function(t,e){return Array.prototype.lastIndexOf.call(t,e,t.length-1)}:function(t,e){var n=t.length-1;if(0>n&&(n=Math.max(0,t.length+n)),ys(t))return ys(e)&&1==e.length?t.lastIndexOf(e,n):-1;for(;0<=n;n--)if(n in t&&t[n]===e)return n;return-1},Us=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i=ys(t)?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)},qs=Array.prototype.some?function(t,e){return Array.prototype.some.call(t,e,void 0)}:function(t,e){for(var n=t.length,r=ys(t)?t.split(""):t,i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t))return!0;return!1};function Bs(t){if(!bs(t))for(var e=t.length-1;0<=e;e--)delete t[e];t.length=0}function Vs(t,e){var n;return(n=0<=(e=xs(t,e)))&&Array.prototype.splice.call(t,e,1),n}function Ws(t){return Array.prototype.concat.apply([],arguments)}function js(t){var e=t.length;if(0<e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}return[]}function Ks(t){return/^[\s\xa0]*$/.test(t)}var Qs,Hs=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function Gs(t,e){return t<e?-1:t>e?1:0}t:{var zs=ds.navigator;if(zs){var Ys=zs.userAgent;if(Ys){Qs=Ys;break t}}Qs=""}function Xs(t){return-1!=Qs.indexOf(t)}function Js(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function $s(t){var e,n=[],r=0;for(e in t)n[r++]=t[e];return n}function Zs(t){var e,n=[],r=0;for(e in t)n[r++]=e;return n}function ta(t){var e,n={};for(e in t)n[e]=t[e];return n}var ea="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function na(t,e){for(var n,r,i=1;i<arguments.length;i++){for(n in r=arguments[i])t[n]=r[n];for(var o=0;o<ea.length;o++)n=ea[o],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function ra(t){return ra[" "](t),t}ra[" "]=gs;var ia,oa,sa=Xs("Opera"),aa=Xs("Trident")||Xs("MSIE"),ua=Xs("Edge"),ca=ua||aa,ha=Xs("Gecko")&&!(-1!=Qs.toLowerCase().indexOf("webkit")&&!Xs("Edge"))&&!(Xs("Trident")||Xs("MSIE"))&&!Xs("Edge"),la=-1!=Qs.toLowerCase().indexOf("webkit")&&!Xs("Edge");function fa(){var t=ds.document;return t?t.documentMode:void 0}t:{var pa="",da=(oa=Qs,ha?/rv:([^\);]+)(\)|;)/.exec(oa):ua?/Edge\/([\d\.]+)/.exec(oa):aa?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(oa):la?/WebKit\/(\S+)/.exec(oa):sa?/(?:Version)[ \/]?(\S+)/.exec(oa):void 0);if(da&&(pa=da?da[1]:""),aa){var ya=fa();if(null!=ya&&ya>parseFloat(pa)){ia=String(ya);break t}}ia=pa}var ma,ga={};function va(t){return function(t,e){var n=ga;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(t,function(){for(var e=0,n=Hs(String(ia)).split("."),r=Hs(String(t)).split("."),i=Math.max(n.length,r.length),o=0;0==e&&o<i;o++){var s=n[o]||"",a=r[o]||"";do{if(s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],a=/(\d*)(\D*)(.*)/.exec(a)||["","","",""],0==s[0].length&&0==a[0].length)break;e=Gs(0==s[1].length?0:parseInt(s[1],10),0==a[1].length?0:parseInt(a[1],10))||Gs(0==s[2].length,0==a[2].length)||Gs(s[2],a[2]),s=s[3],a=a[3]}while(0==e)}return 0<=e})}var ba=ds.document;ma=ba&&aa?fa()||("CSS1Compat"==ba.compatMode?parseInt(ia,10):5):void 0;var _a=Object.freeze||function(t){return t},wa=!aa||9<=Number(ma),Ea=aa&&!va("9"),Ta=function(){if(!ds.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{ds.addEventListener("test",gs,e),ds.removeEventListener("test",gs,e)}catch(t){}return t}();function Sa(t,e){this.type=t,this.currentTarget=this.target=e,this.defaultPrevented=this.Ea=!1,this.Be=!0}function Ia(t,e){Sa.call(this,t?t.type:""),this.relatedTarget=this.currentTarget=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=this.offsetY=this.offsetX=0,this.key="",this.charCode=this.keyCode=0,this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.fb=null,t&&this.Kf(t,e)}Sa.prototype.stopPropagation=function(){this.Ea=!0},Sa.prototype.preventDefault=function(){this.defaultPrevented=!0,this.Be=!1},Rs(Ia,Sa);var Ca=_a({2:"touch",3:"pen",4:"mouse"});Ia.prototype.Kf=function(t,e){var n=this.type=t.type,r=t.changedTouches?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.currentTarget=e,e=t.relatedTarget){if(ha){t:{try{ra(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,null===r?(this.offsetX=la||void 0!==t.offsetX?t.offsetX:t.layerX,this.offsetY=la||void 0!==t.offsetY?t.offsetY:t.layerY,this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0):(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0),this.button=t.button,this.keyCode=t.keyCode||0,this.key=t.key||"",this.charCode=t.charCode||("keypress"==n?t.keyCode:0),this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType=ys(t.pointerType)?t.pointerType:Ca[t.pointerType]||"",this.state=t.state,this.fb=t,t.defaultPrevented&&this.preventDefault()},Ia.prototype.stopPropagation=function(){Ia.L.stopPropagation.call(this),this.fb.stopPropagation?this.fb.stopPropagation():this.fb.cancelBubble=!0},Ia.prototype.preventDefault=function(){Ia.L.preventDefault.call(this);var t=this.fb;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,Ea)try{(t.ctrlKey||112<=t.keyCode&&123>=t.keyCode)&&(t.keyCode=-1)}catch(t){}};var Na="closure_listenable_"+(1e6*Math.random()|0);function Da(t){return!(!t||!t[Na])}var Aa=0;function Ra(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.Ob=i,this.key=++Aa,this.Sa=this.Eb=!1}function ka(t){this.src=t,this.J={},this.xb=0}function Oa(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i];if(!o.Sa&&o.listener==e&&o.capture==!!n&&o.Ob==r)return i}return-1}Ra.prototype.Vb=function(){this.Sa=!0,this.Ob=this.src=this.proxy=this.listener=null},(ls=ka.prototype).add=function(t,e,n,r,i){var o=t.toString();(t=this.J[o])||(t=this.J[o]=[],this.xb++);var s=Oa(t,e,r,i);return-1<s?(e=t[s],n||(e.Eb=!1)):((e=new Ra(e,this.src,o,!!r,i)).Eb=n,t.push(e)),e},ls.remove=function(t,e,n,r){if(!((t=t.toString())in this.J))return!1;var i=this.J[t];return-1<(e=Oa(i,e,n,r))&&(i[e].Vb(),Array.prototype.splice.call(i,e,1),0==i.length&&(delete this.J[t],this.xb--),!0)},ls.ye=function(t){var e=t.type;e in this.J&&Vs(this.J[e],t)&&(t.Vb(),0==this.J[e].length&&(delete this.J[e],this.xb--))},ls.pb=function(t){var e;for(e in t=t&&t.toString(),this.J)if(!t||e==t){for(var n=this.J[e],r=0;r<n.length;r++)n[r].Vb();delete this.J[e],this.xb--}},ls.jb=function(t,e,n,r){var i=-1;return(t=this.J[t.toString()])&&(i=Oa(t,e,n,r)),-1<i?t[i]:null};var Pa="closure_lm_"+(1e6*Math.random()|0),La={};function Ma(t,e,n,r,i){if(r&&r.once)return Fa(t,e,n,r,i);if(bs(e)){for(var o=0;o<e.length;o++)Ma(t,e[o],n,r,i);return null}return n=Qa(n),Da(t)?t.nb(e,n,Es(r)?!!r.capture:!!r,i):xa(t,e,n,!1,r,i)}function xa(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var s=Es(i)?!!i.capture:!!i,a=ja(t);if(a||(t[Pa]=a=new ka(t)),(n=a.add(e,n,r,s,o)).proxy)return n;if(r=function(){var t=Wa,e=wa?function(n){return t.call(e.src,e.listener,n)}:function(n){if(!(n=t.call(e.src,e.listener,n)))return n};return e}(),n.proxy=r,r.src=t,r.listener=n,t.addEventListener)Ta||(i=s),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(qa(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function Fa(t,e,n,r,i){if(bs(e)){for(var o=0;o<e.length;o++)Fa(t,e[o],n,r,i);return null}return n=Qa(n),Da(t)?t.Oc(e,n,Es(r)?!!r.capture:!!r,i):xa(t,e,n,!0,r,i)}function Ua(t){if("number"!=typeof t&&t&&!t.Sa){var e=t.src;if(Da(e))e.Le(t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(qa(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=ja(e))?(n.ye(t),0==n.xb&&(n.src=null,e[Pa]=null)):t.Vb()}}}function qa(t){return t in La?La[t]:La[t]="on"+t}function Ba(t,e,n,r){var i=!0;if((t=ja(t))&&(e=t.J[e.toString()]))for(e=e.concat(),t=0;t<e.length;t++){var o=e[t];o&&o.capture==n&&!o.Sa&&(o=Va(o,r),i=i&&!1!==o)}return i}function Va(t,e){var n=t.listener,r=t.Ob||t.src;return t.Eb&&Ua(t),n.call(r,e)}function Wa(t,e){if(t.Sa)return!0;if(!wa){var n=e||ms("window.event");e=new Ia(n,this);var r=!0;if(!(0>n.keyCode||void 0!=n.returnValue)){t:{var i=!1;if(0==n.keyCode)try{n.keyCode=-1;break t}catch(t){i=!0}(i||void 0==n.returnValue)&&(n.returnValue=!0)}for(n=[],i=e.currentTarget;i;i=i.parentNode)n.push(i);for(t=t.type,i=n.length-1;!e.Ea&&0<=i;i--){e.currentTarget=n[i];var o=Ba(n[i],t,!0,e);r=r&&o}for(i=0;!e.Ea&&i<n.length;i++)e.currentTarget=n[i],o=Ba(n[i],t,!1,e),r=r&&o}return r}return Va(t,new Ia(e,this))}function ja(t){return(t=t[Pa])instanceof ka?t:null}var Ka="__closure_events_fn_"+(1e9*Math.random()>>>0);function Qa(t){return ws(t)?t:(t[Ka]||(t[Ka]=function(e){return t.handleEvent(e)}),t[Ka])}function Ha(){Ps.call(this),this.ka=new ka(this),this.Pe=this,this.Uc=null}Rs(Ha,Ps),Ha.prototype[Na]=!0,(ls=Ha.prototype).addEventListener=function(t,e,n,r){Ma(this,t,e,n,r)},ls.removeEventListener=function(t,e,n,r){!function t(e,n,r,i,o){if(bs(n))for(var s=0;s<n.length;s++)t(e,n[s],r,i,o);else i=Es(i)?!!i.capture:!!i,r=Qa(r),Da(e)?e.ed(n,r,i,o):e&&(e=ja(e))&&(n=e.jb(n,r,i,o))&&Ua(n)}(this,t,e,n,r)},ls.dispatchEvent=function(t){var e,n=this.Uc;if(n)for(e=[];n;n=n.Uc)e.push(n);n=this.Pe;var r=t.type||t;if(ys(t))t=new Sa(t,n);else if(t instanceof Sa)t.target=t.target||n;else{var i=t;na(t=new Sa(r,n),i)}if(i=!0,e)for(var o=e.length-1;!t.Ea&&0<=o;o--){var s=t.currentTarget=e[o];i=s.Lb(r,!0,t)&&i}if(t.Ea||(i=(s=t.currentTarget=n).Lb(r,!0,t)&&i,t.Ea||(i=s.Lb(r,!1,t)&&i)),e)for(o=0;!t.Ea&&o<e.length;o++)i=(s=t.currentTarget=e[o]).Lb(r,!1,t)&&i;return i},ls.F=function(){Ha.L.F.call(this),this.pg(),this.Uc=null},ls.nb=function(t,e,n,r){return this.ka.add(String(t),e,!1,n,r)},ls.Oc=function(t,e,n,r){return this.ka.add(String(t),e,!0,n,r)},ls.ed=function(t,e,n,r){this.ka.remove(String(t),e,n,r)},ls.Le=function(t){this.ka.ye(t)},ls.pg=function(){this.ka&&this.ka.pb(void 0)},ls.Lb=function(t,e,n){if(!(t=this.ka.J[String(t)]))return!0;t=t.concat();for(var r=!0,i=0;i<t.length;++i){var o=t[i];if(o&&!o.Sa&&o.capture==e){var s=o.listener,a=o.Ob||o.src;o.Eb&&this.Le(o),r=!1!==s.call(a,n)&&r}}return r&&0!=n.Be},ls.jb=function(t,e,n,r){return this.ka.jb(String(t),e,n,r)};var Ga=ds.JSON.stringify;function za(t,e){this.Sf=100,this.ef=t,this.ug=e,this.Zb=0,this.Pb=null}function Ya(){this.lc=this.Va=null}za.prototype.get=function(){if(0<this.Zb){this.Zb--;var t=this.Pb;this.Pb=t.next,t.next=null}else t=this.ef();return t},za.prototype.put=function(t){this.ug(t),this.Zb<this.Sf&&(this.Zb++,t.next=this.Pb,this.Pb=t)};var Xa,Ja,$a=new za(function(){return new Za},function(t){t.reset()});function Za(){this.next=this.scope=this.Gc=null}function tu(t){ds.setTimeout(function(){throw t},0)}function eu(){if(ds.Promise&&ds.Promise.resolve){var t=ds.Promise.resolve(void 0);Ja=function(){t.then(iu)}}else Ja=function(){var t=iu;!ws(ds.setImmediate)||ds.Window&&ds.Window.prototype&&!Xs("Edge")&&ds.Window.prototype.setImmediate==ds.setImmediate?(Xa||(Xa=function(){var t=ds.MessageChannel;if(void 0===t&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&!Xs("Presto")&&(t=function(){var t=document.createElement("IFRAME");t.style.display="none",t.src="",document.documentElement.appendChild(t);var e=t.contentWindow;(t=e.document).open(),t.write(""),t.close();var n="callImmediate"+Math.random(),r="file:"==e.location.protocol?"*":e.location.protocol+"//"+e.location.host;t=Ns(function(t){"*"!=r&&t.origin!=r||t.data!=n||this.port1.onmessage()},this),e.addEventListener("message",t,!1),this.port1={},this.port2={postMessage:function(){e.postMessage(n,r)}}}),void 0!==t&&!Xs("Trident")&&!Xs("MSIE")){var e=new t,n={},r=n;return e.port1.onmessage=function(){if(void 0!==n.next){var t=(n=n.next).rd;n.rd=null,t()}},function(t){r.next={rd:t},r=r.next,e.port2.postMessage(0)}}return"undefined"!=typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?function(t){var e=document.createElement("SCRIPT");e.onreadystatechange=function(){e.onreadystatechange=null,e.parentNode.removeChild(e),e=null,t(),t=null},document.documentElement.appendChild(e)}:function(t){ds.setTimeout(t,0)}}()),Xa(t)):ds.setImmediate(t)}}Ya.prototype.add=function(t,e){var n=this.Af();n.set(t,e),this.lc?this.lc.next=n:this.Va=n,this.lc=n},Ya.prototype.remove=function(){var t=null;return this.Va&&(t=this.Va,this.Va=this.Va.next,this.Va||(this.lc=null),t.next=null),t},Ya.prototype.wg=function(t){$a.put(t)},Ya.prototype.Af=function(){return $a.get()},Za.prototype.set=function(t,e){this.Gc=t,this.scope=e,this.next=null},Za.prototype.reset=function(){this.next=this.scope=this.Gc=null};var nu=!1,ru=new Ya;function iu(){for(var t;t=ru.remove();){try{t.Gc.call(t.scope)}catch(t){tu(t)}ru.wg(t)}nu=!1}function ou(t,e){Ha.call(this),this.Na=t||1,this.wb=e||ds,this.nd=Ns(this.Rg,this),this.ie=As()}function su(t,e,n){if(ws(t))n&&(t=Ns(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=Ns(t.handleEvent,t)}return 2147483647<Number(e)?-1:ds.setTimeout(t,e||0)}function au(t,e,n){Ps.call(this),this.Uf=null!=n?Ns(t,n):t,this.Na=e,this.Xe=Ns(this.fg,this),this.qc=[]}function uu(t){Ps.call(this),this.i=t,this.o={}}Rs(ou,Ha),(ls=ou.prototype).enabled=!1,ls.B=null,ls.setInterval=function(t){this.Na=t,this.B&&this.enabled?(this.stop(),this.start()):this.B&&this.stop()},ls.Rg=function(){if(this.enabled){var t=As()-this.ie;0<t&&t<.8*this.Na?this.B=this.wb.setTimeout(this.nd,this.Na-t):(this.B&&(this.wb.clearTimeout(this.B),this.B=null),this.ff(),this.enabled&&(this.stop(),this.start()))}},ls.ff=function(){this.dispatchEvent("tick")},ls.start=function(){this.enabled=!0,this.B||(this.B=this.wb.setTimeout(this.nd,this.Na),this.ie=As())},ls.stop=function(){this.enabled=!1,this.B&&(this.wb.clearTimeout(this.B),this.B=null)},ls.F=function(){ou.L.F.call(this),this.stop(),delete this.wb},Rs(au,Ps),(ls=au.prototype).Ta=!1,ls.ob=0,ls.B=null,ls.mf=function(t){this.qc=arguments,this.B||this.ob?this.Ta=!0:this.Cc()},ls.stop=function(){this.B&&(ds.clearTimeout(this.B),this.B=null,this.Ta=!1,this.qc=[])},ls.pause=function(){this.ob++},ls.resume=function(){this.ob--,this.ob||!this.Ta||this.B||(this.Ta=!1,this.Cc())},ls.F=function(){au.L.F.call(this),this.stop()},ls.fg=function(){this.B=null,this.Ta&&!this.ob&&(this.Ta=!1,this.Cc())},ls.Cc=function(){this.B=su(this.Xe,this.Na),this.Uf.apply(null,this.qc)},Rs(uu,Ps);var cu=[];function hu(t,e,n){this.reset(t,e,n,void 0,void 0)}function lu(t){this.pe=t,this.Zd=this.uc=this.mb=this.$b=null}function fu(t,e){this.name=t,this.value=e}(ls=uu.prototype).nb=function(t,e,n,r){return this.Tf(t,e,n,r)},ls.Tf=function(t,e,n,r){bs(e)||(e&&(cu[0]=e.toString()),e=cu);for(var i=0;i<e.length;i++){var o=Ma(t,e[i],n||this.handleEvent,r||!1,this.i||this);if(!o)break;this.o[o.key]=o}return this},ls.Oc=function(t,e,n,r){return this.je(t,e,n,r)},ls.je=function(t,e,n,r,i){if(bs(e))for(var o=0;o<e.length;o++)this.je(t,e[o],n,r,i);else{if(!(t=Fa(t,e,n||this.handleEvent,r,i||this.i||this)))return this;this.o[t.key]=t}return this},ls.ed=function(t,e,n,r,i){if(bs(e))for(var o=0;o<e.length;o++)this.ed(t,e[o],n,r,i);else n=n||this.handleEvent,r=Es(r)?!!r.capture:!!r,i=i||this.i||this,n=Qa(n),r=!!r,(e=Da(t)?t.jb(e,n,r,i):t&&(t=ja(t))?t.jb(e,n,r,i):null)&&(Ua(e),delete this.o[e.key])},ls.pb=function(){Js(this.o,function(t,e){this.o.hasOwnProperty(e)&&Ua(t)},this),this.o={}},ls.F=function(){uu.L.F.call(this),this.pb()},ls.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},hu.prototype.Md=null,hu.prototype.reset=function(t,e,n,r,i){this.mb=t,delete this.Md},hu.prototype.Bg=function(t){this.Md=t},hu.prototype.Ge=function(t){this.mb=t},fu.prototype.toString=function(){return this.name};var pu=new fu("SEVERE",1e3),du=new fu("WARNING",900),yu=new fu("INFO",800),mu=new fu("CONFIG",700),gu=new fu("FINE",500);(ls=lu.prototype).getName=function(){return this.pe},ls.getParent=function(){return this.$b},ls.pf=function(){return this.uc||(this.uc={}),this.uc},ls.Ge=function(t){this.mb=t},ls.Qd=function(){return this.mb?this.mb:this.$b?this.$b.Qd():(function(t,e){throw new Os("Failure"+(t?": "+t:""),Array.prototype.slice.call(arguments,1))}("Root logger has no level set."),null)},ls.Pf=function(t){return t.value>=this.Qd().value},ls.log=function(t,e,n){this.Pf(t)&&(ws(e)&&(e=e()),this.gf(this.uf(t,e,n)))},ls.uf=function(t,e,n){return t=new hu(t,String(e),this.pe),n&&t.Bg(n),t},ls.ca=function(t,e){this.log(pu,t,e)},ls.T=function(t,e){this.log(du,t,e)},ls.info=function(t,e){this.log(yu,t,e)},ls.lf=function(t){this.log(gu,t,void 0)},ls.gf=function(t){for(var e=this;e;)e.We(t),e=e.getParent()},ls.We=function(t){if(this.Zd)for(var e,n=0;e=this.Zd[n];n++)e(t)},ls.Fg=function(t){this.$b=t},ls.Qe=function(t,e){this.pf()[t]=e};var vu={},bu=null;function _u(t){var e;if(bu||(bu=new lu(""),vu[""]=bu,bu.Ge(mu)),!(e=vu[t])){e=new lu(t);var n=t.lastIndexOf("."),r=t.substr(n+1);(n=_u(t.substr(0,n))).Qe(r,e),e.Fg(n),vu[t]=e}return e}function wu(t,e){t&&t.info(e,void 0)}function Eu(t,e){t&&t.lf(e)}function Tu(){this.s=_u("goog.labs.net.webChannel.WebChannelDebug"),this.Wc=!0}(ls=Tu.prototype).Id=function(){this.Wc=!1},ls.Tg=function(t,e,n,r,i){var o=this;this.info(function(){return"XMLHTTP REQ ("+n+") [attempt "+r+"]: "+t+"\n"+e+"\n"+o.Xf(i)})},ls.Ug=function(t,e,n,r,i,o){this.info(function(){return"XMLHTTP RESP ("+n+") [ attempt "+r+"]: "+t+"\n"+e+"\n"+i+" "+o})},ls.Wa=function(t,e,n){var r=this;this.info(function(){return"XMLHTTP TEXT ("+t+"): "+r.ng(e)+(n?" "+n:"")})},ls.Sg=function(t){this.info(function(){return"TIMEOUT: "+t})},ls.debug=function(t){Eu(this.s,t)},ls.cb=function(t,e){var n=this.s;n&&n.ca(e||"Exception",t)},ls.info=function(t){wu(this.s,t)},ls.T=function(t){var e=this.s;e&&e.T(t,void 0)},ls.ca=function(t){var e=this.s;e&&e.ca(t,void 0)},ls.ng=function(t){if(!this.Wc)return t;if(!t)return null;try{var e=JSON.parse(t);if(e)for(var n=0;n<e.length;n++)bs(e[n])&&this.Wf(e[n]);return Ga(e)}catch(e){return this.debug("Exception parsing expected JS array - probably was not JS"),t}},ls.Wf=function(t){if(!(2>t.length||(t=t[1],!bs(t)||1>t.length))){var e=t[0];if("noop"!=e&&"stop"!=e&&"close"!=e)for(e=1;e<t.length;e++)t[e]=""}},ls.Xf=function(t){if(!this.Wc)return t;if(!t)return null;var e="";t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].split("=");if(1<r.length){var i=r[0];r=r[1];var o=i.split("_");e=2<=o.length&&"type"==o[1]?e+(i+"=")+r+"&":e+(i+"=redacted&")}}return e};var Su=new Ha;function Iu(t){Sa.call(this,"serverreachability",t)}function Cu(t){Su.dispatchEvent(new Iu(Su,t))}function Nu(t,e){Sa.call(this,"statevent",t),this.stat=e}function Du(t){Su.dispatchEvent(new Nu(Su,t))}function Au(t,e,n){Sa.call(this,"timingevent",t),this.size=e,this.rtt=n}function Ru(t,e){if(!ws(t))throw Error("Fn must not be null and must be a function");return ds.setTimeout(function(){t()},e)}Rs(Iu,Sa),Rs(Nu,Sa),Rs(Au,Sa);var ku={NO_ERROR:0,Vg:1,bh:2,ah:3,Yg:4,$g:5,dh:6,Ne:7,TIMEOUT:8,gh:9},Ou={Xg:"complete",kh:"success",Oe:"error",Ne:"abort",ih:"ready",jh:"readystatechange",TIMEOUT:"timeout",eh:"incrementaldata",hh:"progress",Zg:"downloadprogress",lh:"uploadprogress"};function Pu(){}function Lu(){}Pu.prototype.pd=null,Pu.prototype.Vd=function(){return this.pd||(this.pd=this.Mf())};var Mu,xu={OPEN:"a",Wg:"b",Oe:"c",fh:"d"};function Fu(){Sa.call(this,"d")}function Uu(){Sa.call(this,"c")}function qu(){}function Bu(t,e,n,r,i){this.b=t,this.a=e,this.ra=n,this.R=r,this.Xc=i||1,this.Fc=new uu(this),this.Ua=Vu,t=ca?125:void 0,this.Vc=new ou(t),this.A=null,this.S=!1,this.Da=this.pa=this.ua=this.ic=this.qb=this.hd=this.Ga=null,this.ba=[],this.h=null,this.Bb=0,this.I=this.Fa=null,this.w=-1,this.Za=!1,this.Ra=0,this.ac=null,this.lb=this.Ed=this.yc=!1}Rs(Fu,Sa),Rs(Uu,Sa),Rs(qu,Pu),qu.prototype.Dd=function(){var t=this.Wd();return t?new ActiveXObject(t):new XMLHttpRequest},qu.prototype.Mf=function(){var t={};return this.Wd()&&(t[0]=!0,t[1]=!0),t},qu.prototype.Wd=function(){if(!this.be&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(var t=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],e=0;e<t.length;e++){var n=t[e];try{return new ActiveXObject(n),this.be=n}catch(t){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed")}return this.be},Mu=new qu;var Vu=45e3;var Wu={},ju={};function Ku(t){if(t.H&&"function"==typeof t.H)return t.H();if(ys(t))return t.split("");if(_s(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}return $s(t)}function Qu(t,e,n){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,n);else if(_s(t)||ys(t))Us(t,e,n);else{if(t.W&&"function"==typeof t.W)var r=t.W();else if(t.H&&"function"==typeof t.H)r=void 0;else if(_s(t)||ys(t)){r=[];for(var i=t.length,o=0;o<i;o++)r.push(o)}else r=Zs(t);o=(i=Ku(t)).length;for(var s=0;s<o;s++)e.call(n,i[s],r&&r[s],t)}}function Hu(t,e){this.D={},this.o=[],this.j=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else t&&this.addAll(t)}function Gu(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(ls=Bu.prototype).ga=function(t){this.A=t},ls.setTimeout=function(t){this.Ua=t},ls.He=function(t){this.Ra=t},ls.Gg=function(t){this.ba=t},ls.la=function(){return this.ba},ls.kd=function(t,e){this.ic=1,this.ua=t.clone().Ub(),this.Da=e,this.yc=!0,this.Ce(null)},ls.jd=function(t,e,n){this.ic=1,this.ua=t.clone().Ub(),this.Da=null,this.yc=e,this.Ce(n)},ls.Ce=function(t){this.qb=As(),this.eb(),this.pa=this.ua.clone(),this.pa.dc("t",this.Xc),this.Bb=0,this.h=this.b.Jb(this.b.fc()?t:null),0<this.Ra&&(this.ac=new au(Ns(this.Me,this,this.h),this.Ra)),this.Fc.nb(this.h,"readystatechange",this.mg),t=this.A?ta(this.A):{},this.Da?(this.Fa||(this.Fa="POST"),t["Content-Type"]="application/x-www-form-urlencoded",this.h.send(this.pa,this.Fa,this.Da,t)):(this.Fa="GET",this.h.send(this.pa,this.Fa,null,t)),Cu(1),this.a.Tg(this.Fa,this.pa,this.R,this.Xc,this.Da)},ls.mg=function(t){t=t.target;var e=this.ac;e&&3==t.ma()?(this.a.debug("Throttling readystatechange."),e.mf()):this.Me(t)},ls.Me=function(t){try{t==this.h?this.hg():this.a.T("Called back with an unexpected xmlhttp")}catch(t){if(this.a.debug("Failed call to OnXmlHttpReadyStateChanged_"),this.h&&this.h.ya()){var e=this;this.a.cb(t,function(){return"ResponseText: "+e.h.ya()})}else this.a.cb(t,"No response text")}},ls.hg=function(){var t=this.h.ma(),e=this.h.Ud(),n=this.h.za();if(!(3>t||3==t&&!ca&&!this.h.ya())){this.Za||4!=t||7==e||Cu(8==e||0>=n?3:2),this.Fb();var r=this.h.za();if(this.w=r,!(e=this.h.ya())){var i=this;this.a.debug(function(){return"No response text for uri "+i.pa+" status "+r})}if(this.S=200==r,this.a.Ug(this.Fa,this.pa,this.R,this.Xc,t,r),this.S){if(this.Ig()){if(!(n=this.sf()))return this.S=!1,this.I=3,Du(12),this.a.T("XMLHTTP Missing X_HTTP_INITIAL_RESPONSE ("+this.R+")"),this.Ia(),void this.Kb();this.a.Wa(this.R,n,"Initial handshake response via X-HTTP-Initial-Response"),this.lb=!0,this.Yc(n)}this.yc?(this.Fd(t,e),ca&&this.S&&3==t&&this.Ng()):(this.a.Wa(this.R,e,null),this.Yc(e)),4==t&&this.Ia(),this.S&&!this.Za&&(4==t?this.b.Tc(this):(this.S=!1,this.eb()))}else 400==r&&0<e.indexOf("Unknown SID")?(this.I=3,Du(12),this.a.T("XMLHTTP Unknown SID ("+this.R+")")):(this.I=0,Du(13),this.a.T("XMLHTTP Bad status "+r+" ("+this.R+")")),this.Ia(),this.Kb()}},ls.Ig=function(){return this.Ed&&!this.lb},ls.sf=function(){if(this.h){var t=this.h.kb("X-HTTP-Initial-Response");if(t&&!Ks(t))return t}return null},ls.Ag=function(){this.Ed=!0},ls.Fd=function(t,e){for(var n=!0;!this.Za&&this.Bb<e.length;){var r=this.vf(e);if(r==ju){4==t&&(this.I=4,Du(14),n=!1),this.a.Wa(this.R,null,"[Incomplete Response]");break}if(r==Wu){this.I=4,Du(15),this.a.Wa(this.R,e,"[Invalid Chunk]"),n=!1;break}this.a.Wa(this.R,r,null),this.Yc(r)}4==t&&0==e.length&&(this.I=1,Du(16),n=!1),this.S=this.S&&n,n||(this.a.Wa(this.R,e,"[Invalid Chunked Response]"),this.Ia(),this.Kb())},ls.kg=function(){if(this.h){var t=this.h.ma(),e=this.h.ya();this.Bb<e.length&&(this.Fb(),this.Fd(t,e),this.S&&4!=t&&this.eb())}},ls.Ng=function(){this.Fc.nb(this.Vc,"tick",this.kg),this.Vc.start()},ls.vf=function(t){var e=this.Bb,n=t.indexOf("\n",e);return-1==n?ju:(e=Number(t.substring(e,n)),isNaN(e)?Wu:(n+=1)+e>t.length?ju:(t=t.substr(n,e),this.Bb=n+e,t))},ls.yg=function(t){this.ic=2,this.ua=t.clone().Ub(),t=!1,ds.navigator&&ds.navigator.sendBeacon&&(t=ds.navigator.sendBeacon(this.ua.toString(),"")),!t&&ds.Image&&((new Image).src=this.ua,t=!0),t||(this.h=this.b.Jb(null),this.h.send(this.ua)),this.qb=As(),this.eb()},ls.cancel=function(){this.Za=!0,this.Ia()},ls.tg=function(t){t&&this.setTimeout(t),this.Ga&&(this.Fb(),this.eb())},ls.eb=function(){this.hd=As()+this.Ua,this.Ke(this.Ua)},ls.Ke=function(t){if(null!=this.Ga)throw Error("WatchDog timer not null");this.Ga=Ru(Ns(this.gg,this),t)},ls.Fb=function(){this.Ga&&(ds.clearTimeout(this.Ga),this.Ga=null)},ls.gg=function(){this.Ga=null;var t=As();0<=t-this.hd?this.Df():(this.a.T("WatchDog timer called too early"),this.Ke(this.hd-t))},ls.Df=function(){this.S&&this.a.ca("Received watchdog timeout even though request loaded successfully"),this.a.Sg(this.pa),2!=this.ic&&(Cu(3),Du(17)),this.Ia(),this.I=2,this.Kb()},ls.Kb=function(){this.b.de()||this.Za||this.b.Tc(this)},ls.Ia=function(){this.Fb();var t=this.ac;t&&"function"==typeof t.bb&&t.bb(),this.ac=null,this.Vc.stop(),this.Fc.pb(),this.h&&(t=this.h,this.h=null,t.abort(),t.bb())},ls.Hc=function(){return this.I},ls.Yc=function(t){try{this.b.ue(this,t),Cu(4)}catch(t){this.a.cb(t,"Error in httprequest callback")}},(ls=Hu.prototype).C=function(){return this.j},ls.H=function(){this.wc();for(var t=[],e=0;e<this.o.length;e++)t.push(this.D[this.o[e]]);return t},ls.W=function(){return this.wc(),this.o.concat()},ls.va=function(t){return Gu(this.D,t)},ls.X=function(){return 0==this.j},ls.clear=function(){this.D={},this.j=this.o.length=0},ls.remove=function(t){return!!Gu(this.D,t)&&(delete this.D[t],this.j--,this.o.length>2*this.j&&this.wc(),!0)},ls.wc=function(){if(this.j!=this.o.length){for(var t=0,e=0;t<this.o.length;){var n=this.o[t];Gu(this.D,n)&&(this.o[e++]=n),t++}this.o.length=e}if(this.j!=this.o.length){var r={};for(e=t=0;t<this.o.length;)Gu(r,n=this.o[t])||(this.o[e++]=n,r[n]=1),t++;this.o.length=e}},ls.get=function(t,e){return Gu(this.D,t)?this.D[t]:e},ls.set=function(t,e){Gu(this.D,t)||(this.j++,this.o.push(t)),this.D[t]=e},ls.addAll=function(t){if(t instanceof Hu)for(var e=t.W(),n=0;n<e.length;n++)this.set(e[n],t.get(e[n]));else for(e in t)this.set(e,t[e])},ls.forEach=function(t,e){for(var n=this.W(),r=0;r<n.length;r++){var i=n[r],o=this.get(i);t.call(e,o,i,this)}},ls.clone=function(){return new Hu(this)};var zu=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Yu(t,e){var n;this.xa=this.zb=this.qa="",this.Ca=null,this.ib=this.K="",this.O=this.Qf=!1,t instanceof Yu?(this.O=void 0!==e?e:t.O,this.tb(t.qa),this.cd(t.zb),this.rb(t.xa),this.sb(t.Ca),this.ec(t.K),this.bd(t.P.clone()),this.$c(t.ib)):t&&(n=String(t).match(zu))?(this.O=!!e,this.tb(n[1]||"",!0),this.cd(n[2]||"",!0),this.rb(n[3]||"",!0),this.sb(n[4]),this.ec(n[5]||"",!0),this.bd(n[6]||"",!0),this.$c(n[7]||"",!0)):(this.O=!!e,this.P=new ic(null,this.O))}function Xu(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Ju(t,e,n){return ys(t)?(t=encodeURI(t).replace(e,$u),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function $u(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}(ls=Yu.prototype).toString=function(){var t=[],e=this.qa;e&&t.push(Ju(e,Zu,!0),":");var n=this.xa;return(n||"file"==e)&&(t.push("//"),(e=this.zb)&&t.push(Ju(e,Zu,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.Ca)&&t.push(":",String(n))),(n=this.K)&&(this.Ic()&&"/"!=n.charAt(0)&&t.push("/"),t.push(Ju(n,"/"==n.charAt(0)?ec:tc,!0))),(n=this.Rd())&&t.push("?",n),(n=this.ib)&&t.push("#",Ju(n,rc)),t.join("")},ls.resolve=function(t){var e=this.clone(),n=t.Hf();n?e.tb(t.qa):n=t.If(),n?e.cd(t.zb):n=t.Ic(),n?e.rb(t.xa):n=t.Ff();var r=t.K;if(n)e.sb(t.Ca);else if(n=t.ae()){if("/"!=r.charAt(0))if(this.Ic()&&!this.ae())r="/"+r;else{var i=e.K.lastIndexOf("/");-1!=i&&(r=e.K.substr(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(-1!=i.indexOf("./")||-1!=i.indexOf("/.")){r=0==i.lastIndexOf("/",0),i=i.split("/");for(var o=[],s=0;s<i.length;){var a=i[s++];"."==a?r&&s==i.length&&o.push(""):".."==a?((1<o.length||1==o.length&&""!=o[0])&&o.pop(),r&&s==i.length&&o.push("")):(o.push(a),r=!0)}r=o.join("/")}else r=i}return n?e.ec(r):n=t.Gf(),n?e.bd(t.P.clone()):n=t.Ef(),n&&e.$c(t.ib),e},ls.clone=function(){return new Yu(this)},ls.tb=function(t,e){this.U(),(this.qa=e?Xu(t,!0):t)&&(this.qa=this.qa.replace(/:$/,""))},ls.Hf=function(){return!!this.qa},ls.cd=function(t,e){this.U(),this.zb=e?Xu(t):t},ls.If=function(){return!!this.zb},ls.rb=function(t,e){this.U(),this.xa=e?Xu(t,!0):t},ls.Ic=function(){return!!this.xa},ls.sb=function(t){if(this.U(),t){if(t=Number(t),isNaN(t)||0>t)throw Error("Bad port number "+t);this.Ca=t}else this.Ca=null},ls.Ff=function(){return null!=this.Ca},ls.ec=function(t,e){this.U(),this.K=e?Xu(t,!0):t},ls.ae=function(){return!!this.K},ls.Gf=function(){return""!==this.P.toString()},ls.bd=function(t,e){this.U(),t instanceof ic?(this.P=t,this.P.ad(this.O)):(e||(t=Ju(t,nc)),this.P=new ic(t,this.O))},ls.Rd=function(){return this.P.toString()},ls.getQuery=function(){return this.Rd()},ls.l=function(t,e){this.U(),this.P.set(t,e)},ls.dc=function(t,e){this.U(),bs(e)||(e=[String(e)]),this.P.Ie(t,e)},ls.$c=function(t,e){this.U(),this.ib=e?Xu(t):t},ls.Ef=function(){return!!this.ib},ls.Ub=function(){return this.U(),this.l("zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^As()).toString(36)),this},ls.removeParameter=function(t){return this.U(),this.P.remove(t),this},ls.U=function(){if(this.Qf)throw Error("Tried to modify a read-only Uri")},ls.ad=function(t){this.O=t,this.P&&this.P.ad(t)};var Zu=/[#\/\?@]/g,tc=/[#\?:]/g,ec=/[#\?]/g,nc=/[#\?@]/g,rc=/#/g;function ic(t,e){this.j=this.m=null,this.ja=t||null,this.O=!!e}function oc(t,e){this.b=t,this.a=e,this.f=this.A=null,this.bc=!1,this.K=null,this.w=-1,this.Ad=this.na=null}function sc(t){this.D=new Hu,t&&this.addAll(t)}function ac(t){var e=typeof t;return"object"==e&&t||"function"==e?"o"+(t[Ts]||(t[Ts]=++Ss)):e.substr(0,1)+t}function uc(t){this.me=t||cc,ds.PerformanceNavigationTiming?t=0<(t=ds.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):t=!!(ds.vc&&ds.vc.ke&&ds.vc.ke()&&ds.vc.ke().nh),this.Xb=t?this.me:1,this.v=null,1<this.Xb&&(this.v=new sc),this.f=null,this.ba=[]}(ls=ic.prototype).$=function(){if(!this.m&&(this.m=new Hu,this.j=0,this.ja)){var t=this;!function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var o=t[n].substring(0,r);i=t[n].substring(r+1)}else o=t[n];e(o,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(this.ja,function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)})}},ls.C=function(){return this.$(),this.j},ls.add=function(t,e){this.$(),this.Oa(),t=this.Ma(t);var n=this.m.get(t);return n||this.m.set(t,n=[]),n.push(e),this.j+=1,this},ls.remove=function(t){return this.$(),t=this.Ma(t),!!this.m.va(t)&&(this.Oa(),this.j-=this.m.get(t).length,this.m.remove(t))},ls.clear=function(){this.Oa(),this.m=null,this.j=0},ls.X=function(){return this.$(),0==this.j},ls.va=function(t){return this.$(),t=this.Ma(t),this.m.va(t)},ls.forEach=function(t,e){this.$(),this.m.forEach(function(n,r){Us(n,function(n){t.call(e,n,r,this)},this)},this)},ls.W=function(){this.$();for(var t=this.m.H(),e=this.m.W(),n=[],r=0;r<e.length;r++)for(var i=t[r],o=0;o<i.length;o++)n.push(e[r]);return n},ls.H=function(t){this.$();var e=[];if(ys(t))this.va(t)&&(e=Ws(e,this.m.get(this.Ma(t))));else{t=this.m.H();for(var n=0;n<t.length;n++)e=Ws(e,t[n])}return e},ls.set=function(t,e){return this.$(),this.Oa(),t=this.Ma(t),this.va(t)&&(this.j-=this.m.get(t).length),this.m.set(t,[e]),this.j+=1,this},ls.get=function(t,e){return t&&0<(t=this.H(t)).length?String(t[0]):e},ls.Ie=function(t,e){this.remove(t),0<e.length&&(this.Oa(),this.m.set(this.Ma(t),js(e)),this.j+=e.length)},ls.toString=function(){if(this.ja)return this.ja;if(!this.m)return"";for(var t=[],e=this.m.W(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.H(r);for(var o=0;o<r.length;o++){var s=i;""!==r[o]&&(s+="="+encodeURIComponent(String(r[o]))),t.push(s)}}return this.ja=t.join("&")},ls.Oa=function(){this.ja=null},ls.clone=function(){var t=new ic;return t.ja=this.ja,this.m&&(t.m=this.m.clone(),t.j=this.j),t},ls.Ma=function(t){return t=String(t),this.O&&(t=t.toLowerCase()),t},ls.ad=function(t){t&&!this.O&&(this.$(),this.Oa(),this.m.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(this.remove(e),this.Ie(n,t))},this)),this.O=t},ls.extend=function(t){for(var e=0;e<arguments.length;e++)Qu(arguments[e],function(t,e){this.add(e,t)},this)},Rs(function(){},function(){}),(ls=oc.prototype).g=null,ls.ga=function(t){this.A=t},ls.connect=function(t){this.K=t,t=this.b.Sd(this.K),Du(3);var e=this.b.Ib.$d;null!=e?(this.na=this.b.$a(e[0]),this.g=1,this.xd()):(t.dc("MODE","init"),!this.b.ta&&this.b.aa&&t.dc("X-HTTP-Session-Id",this.b.aa),this.f=new Bu(this,this.a,void 0,void 0,void 0),this.f.ga(this.A),this.f.jd(t,!1,null),this.g=0)},ls.xd=function(){this.a.debug("TestConnection: starting stage 2");var t=this.b.Ib.od;if(null!=t)this.a.debug(function(){return"Buffered"}),Du(4),t?(Du(10),this.b.ub(this,!1)):(Du(11),this.b.ub(this,!0));else{this.f=new Bu(this,this.a,void 0,void 0,void 0),this.f.ga(this.A);var e=this.b.Pd(this.na,this.K);Du(4),e.dc("TYPE","xmlhttp");var n=this.b.aa,r=this.b.Kc;n&&r&&e.l(n,r),this.f.jd(e,!1,this.na)}},ls.Jb=function(t){return this.b.Jb(t)},ls.abort=function(){this.f&&(this.f.cancel(),this.f=null),this.w=-1},ls.de=function(){return!1},ls.ue=function(t,e){if(this.w=t.w,0==this.g)if(this.a.debug("TestConnection: Got data for stage 1"),this.pc(t),e){try{var n=this.b.kc.zc(e)}catch(t){return this.a.cb(t),void this.b.dd(this)}this.na=this.b.$a(n[0])}else this.a.debug("TestConnection: Null responseText"),this.b.dd(this);else 1==this.g&&(this.bc?Du(6):"11111"==e?(Du(5),this.bc=!0,this.Ze()&&(this.w=200,this.f.cancel(),this.a.debug("Test connection succeeded; using streaming connection"),Du(11),this.b.ub(this,!0))):(Du(7),this.bc=!1))},ls.Tc=function(){this.w=this.f.w,this.f.S?0==this.g?(this.g=1,this.a.debug("TestConnection: request complete for initial check"),this.xd()):1==this.g&&(this.a.debug("TestConnection: request complete for stage 2"),this.bc?(this.a.debug("Test connection succeeded; using streaming connection"),Du(11),this.b.ub(this,!0)):(this.a.debug("Test connection failed; not using streaming"),Du(10),this.b.ub(this,!1))):(this.a.debug("TestConnection: request failed, in state "+this.g),0==this.g?Du(8):1==this.g&&Du(9),this.b.dd(this))},ls.pc=function(t){if(!this.b.ta&&(t=t.h)){var e=t.kb("X-Client-Wire-Protocol");this.Ad=e||null,this.b.aa&&((t=t.kb("X-HTTP-Session-Id"))?this.b.Fe(t):this.a.T("Missing X_HTTP_SESSION_ID in the handshake response"))}},ls.fc=function(){return this.b.fc()},ls.Ba=function(){return this.b.Ba()},ls.Ze=function(){return!aa||10<=Number(ma)},(ls=sc.prototype).C=function(){return this.D.C()},ls.add=function(t){this.D.set(ac(t),t)},ls.addAll=function(t){for(var e=(t=Ku(t)).length,n=0;n<e;n++)this.add(t[n])},ls.pb=function(t){for(var e=(t=Ku(t)).length,n=0;n<e;n++)this.remove(t[n])},ls.remove=function(t){return this.D.remove(ac(t))},ls.clear=function(){this.D.clear()},ls.X=function(){return this.D.X()},ls.contains=function(t){return this.D.va(ac(t))},ls.H=function(){return this.D.H()},ls.clone=function(){return new sc(this)};var cc=10;function hc(){this.xg=this.rg=void 0}function lc(){this.jg=new hc}function fc(t,e,n,r,i){try{t.debug(n),e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(e){t.cb(e)}}(ls=uc.prototype).ld=function(t){this.v||-1==t.indexOf("spdy")&&-1==t.indexOf("quic")&&-1==t.indexOf("h2")||(this.Xb=this.me,this.v=new sc,this.f&&(this.oc(this.f),this.f=null))},ls.ee=function(){return!!this.f||!!this.v&&this.v.C()>=this.Xb},ls.xf=function(){return this.f?1:this.v?this.v.C():0},ls.Jc=function(t){return this.f?this.f==t:!!this.v&&this.v.contains(t)},ls.oc=function(t){this.v?this.v.add(t):this.f=t},ls.ze=function(t){this.f&&this.f==t?this.f=null:this.v&&this.v.contains(t)&&this.v.remove(t)},ls.cancel=function(){this.ba=this.la(),this.f?(this.f.cancel(),this.f=null):this.v&&!this.v.X()&&(Us(this.v.H(),function(t){t.cancel()}),this.v.clear())},ls.la=function(){if(null!=this.f)return this.ba.concat(this.f.la());if(null!=this.v&&!this.v.X()){var t=this.ba;return Us(this.v.H(),function(e){t=t.concat(e.la())}),t}return js(this.ba)},ls.Re=function(t){this.ba=this.ba.concat(t)},ls.$e=function(){this.ba.length=0},hc.prototype.stringify=function(t){return ds.JSON.stringify(t,this.rg)},hc.prototype.parse=function(t){return ds.JSON.parse(t,this.xg)},lc.prototype.hf=function(t,e,n){var r=n||"";try{Qu(t,function(t,n){var i=t;Es(t)&&(i=Ga(t)),e.push(r+n+"="+encodeURIComponent(i))})}catch(t){throw e.push(r+"type="+encodeURIComponent("_badmap")),t}},lc.prototype.jf=function(t,e,n){for(var r=-1;;){var i=["count="+e];-1==r?0<e?(r=t[0].Pc,i.push("ofs="+r)):r=0:i.push("ofs="+r);for(var o=!0,s=0;s<e;s++){var a=t[s].Pc,u=t[s].map;if(0>(a-=r))r=Math.max(0,t[s].Pc-100),o=!1;else try{this.hf(u,i,"req"+a+"_")}catch(t){n&&n(u)}}if(o)return i.join("&")}},lc.prototype.zc=function(t){return this.jg.parse(t)};var pc=ds.JSON.parse;function dc(t){Ha.call(this),this.headers=new Hu,this.Xa=t||null,this.ha=!1,this.mc=this.c=null,this.ge=this.Tb="",this.Pa=0,this.I="",this.Aa=this.Lc=this.Qb=this.Ec=!1,this.vb=0,this.hc=null,this.Ae=yc,this.jc=this.lg=this.Ab=!1}Rs(dc,Ha);var yc="";dc.prototype.s=_u("goog.net.XhrIo");var mc=/^https?$/i,gc=["POST","PUT"];function vc(t){return"content-type"==t.toLowerCase()}function bc(t,e){return{type:e,lengthComputable:t.lengthComputable,loaded:t.loaded,total:t.total}}function _c(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}if(r)return t;if(n=function(t){var e="";return Js(t,function(t,n){e+=n,e+=":",e+=t,e+="\r\n"}),e}(n),ys(t)){if(e=encodeURIComponent(String(e)),e+=n=null!=n?"="+encodeURIComponent(String(n)):""){if(0>(n=t.indexOf("#"))&&(n=t.length),0>(r=t.indexOf("?"))||r>n){r=n;var i=""}else i=t.substring(r+1,n);n=(t=[t.substr(0,r),i,t.substr(n)])[1],t[1]=e?n?n+"&"+e:e:n,t=t[0]+(t[1]?"?"+t[1]:"")+t[2]}return t}return t.l(e,n),t}function wc(t){this.Bd=22,this.De=0,this.M=[],this.a=new Tu,this.Ib=new function(){this.od=this.$d=null},this.na=this.md=this.hb=this.K=this.u=this.Kc=this.aa=this.gb=this.N=this.Rb=this.A=null,this.Te=!0,this.ag=this.Yb=0,this.kf=!!ms("internalChannelParams.failFast",t),this.fd=this.Ja=this.wa=this.ia=this.ea=this.i=null,this.Se=!0,this.w=this.he=this.Sb=-1,this.rc=this.Ha=this.La=0,this.Ve=ms("internalChannelParams.baseRetryDelayMs",t)||5e3,this.vg=ms("internalChannelParams.retryDelaySeedMs",t)||1e4,this.nf=ms("internalChannelParams.forwardChannelMaxRetries",t)||2,this.Od=ms("internalChannelParams.forwardChannelRequestTimeoutMs",t)||2e4,this.Xa=t&&t.oh||void 0,this.Db=void 0,this.Ra=0,this.gc=t&&t.supportsCrossDomainXhr||!1,this.ra="",this.G=new uc(t&&t.concurrentRequestLimit),this.kc=new lc,this.ta=!t||void 0===t.backgroundChannelTest||t.backgroundChannelTest,(this.Nd=t&&t.fastHandshake||!1)&&!this.ta&&(this.a.T("Force backgroundChannelTest when fastHandshake is enabled."),this.ta=!0),t&&t.Id&&this.a.Id()}function Ec(){}function Tc(){if(aa&&!(10<=Number(ma)))throw Error("Environmental error: no available transport.")}function Sc(t,e){Ha.call(this),this.b=new wc(e),this.yb=t,this.Qg=e&&e.testUrl?e.testUrl:function(t){for(var e=arguments[0],n=1;n<arguments.length;n++){var r,i=arguments[n];0==i.lastIndexOf("/",0)?e=i:((r=""==e)||(r=0<=(r=e.length-1)&&e.indexOf("/",r)==r),e=r?e+i:e+"/"+i)}return e}(this.yb,"test"),this.s=_u("goog.labs.net.webChannel.WebChannelBaseTransport"),this.Rc=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.b.ga(t),t=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(t?t["X-WebChannel-Content-Type"]=e.messageContentType:t={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.zd&&(t?t["X-WebChannel-Client-Profile"]=e.zd:t={"X-WebChannel-Client-Profile":e.zd}),this.b.Eg(t),(t=e&&e.httpHeadersOverwriteParam)&&!Ks(t)&&this.b.Cg(t),this.Og=e&&e.supportsCrossDomainXhr||!1,this.zg=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!Ks(e)&&(this.b.Dg(e),null!==(t=this.Rc)&&e in t&&(e in(t=this.Rc)&&delete t[e],(t=this.s)&&t.T("Ignore httpSessionIdParam also specified with messageUrlParams: "+e,void 0))),this.vd=new Nc(this)}function Ic(t){Fu.call(this);var e=t.__sm__;if(e){t:{for(var n in e){t=n;break t}t=void 0}(this.ne=t)&&(t=this.ne,e=null!==e&&t in e?e[t]:void 0),this.data=e}else this.data=t}function Cc(t){Uu.call(this),this.status=1,this.errorCode=t}function Nc(t){this.b=t}(ls=dc.prototype).Je=function(t){this.Ab=t},ls.send=function(t,e,n,r){if(this.c)throw Error("[goog.net.XhrIo] Object is active with another request="+this.Tb+"; newUri="+t);e=e?e.toUpperCase():"GET",this.Tb=t,this.I="",this.Pa=0,this.ge=e,this.Ec=!1,this.ha=!0,this.c=this.df(),this.mc=this.Xa?this.Xa.Vd():Mu.Vd(),this.c.onreadystatechange=Ns(this.te,this),this.lg&&"onprogress"in this.c&&(this.c.onprogress=Ns(function(t){this.re(t,!0)},this),this.c.upload&&(this.c.upload.onprogress=Ns(this.re,this)));try{Eu(this.s,this.da("Opening Xhr")),this.Lc=!0,this.c.open(e,String(t),!0),this.Lc=!1}catch(t){return Eu(this.s,this.da("Error opening Xhr: "+t.message)),void this.Ld(t)}t=n||"";var i=this.headers.clone();r&&Qu(r,function(t,e){i.set(e,t)}),r=function(t){t:{for(var e=vc,n=t.length,r=ys(t)?t.split(""):t,i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t)){e=i;break t}e=-1}return 0>e?null:ys(t)?t.charAt(e):t[e]}(i.W()),n=ds.FormData&&t instanceof ds.FormData,!(0<=xs(gc,e))||r||n||i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach(function(t,e){this.c.setRequestHeader(e,t)},this),this.Ae&&(this.c.responseType=this.Ae),"withCredentials"in this.c&&this.c.withCredentials!==this.Ab&&(this.c.withCredentials=this.Ab);try{this.yd(),0<this.vb&&(this.jc=function(t){return aa&&va(9)&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(this.c),Eu(this.s,this.da("Will abort after "+this.vb+"ms if incomplete, xhr2 "+this.jc)),this.jc?(this.c.timeout=this.vb,this.c.ontimeout=Ns(this.Ua,this)):this.hc=su(this.Ua,this.vb,this)),Eu(this.s,this.da("Sending request")),this.Qb=!0,this.c.send(t),this.Qb=!1}catch(t){Eu(this.s,this.da("Send error: "+t.message)),this.Ld(t)}},ls.df=function(){return this.Xa?this.Xa.Dd():Mu.Dd()},ls.Ua=function(){void 0!==ps&&this.c&&(this.I="Timed out after "+this.vb+"ms, aborting",this.Pa=8,Eu(this.s,this.da(this.I)),this.dispatchEvent("timeout"),this.abort(8))},ls.Ld=function(t){this.ha=!1,this.c&&(this.Aa=!0,this.c.abort(),this.Aa=!1),this.I=t,this.Pa=5,this.Jd(),this.Gb()},ls.Jd=function(){this.Ec||(this.Ec=!0,this.dispatchEvent("complete"),this.dispatchEvent("error"))},ls.abort=function(t){this.c&&this.ha&&(Eu(this.s,this.da("Aborting")),this.ha=!1,this.Aa=!0,this.c.abort(),this.Aa=!1,this.Pa=t||7,this.dispatchEvent("complete"),this.dispatchEvent("abort"),this.Gb())},ls.F=function(){this.c&&(this.ha&&(this.ha=!1,this.Aa=!0,this.c.abort(),this.Aa=!1),this.Gb(!0)),dc.L.F.call(this)},ls.te=function(){this.Ka||(this.Lc||this.Qb||this.Aa?this.se():this.eg())},ls.eg=function(){this.se()},ls.se=function(){if(this.ha&&void 0!==ps)if(this.mc[1]&&4==this.ma()&&2==this.za())Eu(this.s,this.da("Local request error detected and ignored"));else if(this.Qb&&4==this.ma())su(this.te,0,this);else if(this.dispatchEvent("readystatechange"),this.Mc()){Eu(this.s,this.da("Request complete")),this.ha=!1;try{this.Rf()?(this.dispatchEvent("complete"),this.dispatchEvent("success")):(this.Pa=6,this.I=this.Yd()+" ["+this.za()+"]",this.Jd())}finally{this.Gb()}}},ls.re=function(t,e){this.dispatchEvent(bc(t,"progress")),this.dispatchEvent(bc(t,e?"downloadprogress":"uploadprogress"))},ls.Gb=function(t){if(this.c){this.yd();var e=this.c,n=this.mc[0]?gs:null;this.mc=this.c=null,t||this.dispatchEvent("ready");try{e.onreadystatechange=n}catch(e){(t=this.s)&&t.ca("Problem encountered resetting onreadystatechange: "+e.message,void 0)}}},ls.yd=function(){this.c&&this.jc&&(this.c.ontimeout=null),this.hc&&(ds.clearTimeout(this.hc),this.hc=null)},ls.Ba=function(){return!!this.c},ls.Mc=function(){return 4==this.ma()},ls.Rf=function(){var t=this.za();t:switch(t){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var e=!0;break t;default:e=!1}return e||0===t&&!this.Of()},ls.Of=function(){var t=String(this.Tb).match(zu)[1]||null;return!t&&ds.self&&ds.self.location&&(t=(t=ds.self.location.protocol).substr(0,t.length-1)),mc.test(t?t.toLowerCase():"")},ls.ma=function(){return this.c?this.c.readyState:0},ls.za=function(){try{return 2<this.ma()?this.c.status:-1}catch(t){return-1}},ls.Yd=function(){try{return 2<this.ma()?this.c.statusText:""}catch(t){return Eu(this.s,"Can not get status: "+t.message),""}},ls.ya=function(){try{return this.c?this.c.responseText:""}catch(t){return Eu(this.s,"Can not get responseText: "+t.message),""}},ls.yf=function(t){if(this.c){var e=this.c.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),pc(e)}},ls.getResponseHeader=function(t){if(this.c&&this.Mc())return null===(t=this.c.getResponseHeader(t))?void 0:t},ls.getAllResponseHeaders=function(){return this.c&&this.Mc()&&this.c.getAllResponseHeaders()||""},ls.kb=function(t){return this.c?this.c.getResponseHeader(t):null},ls.Ud=function(){return this.Pa},ls.Hc=function(){return ys(this.I)?this.I:String(this.I)},ls.da=function(t){return t+" ["+this.ge+" "+this.Tb+" "+this.za()+"]"},(ls=wc.prototype).tc=8,ls.g=1,ls.connect=function(t,e,n,r,i){this.a.debug("connect()"),Du(0),this.K=e,this.gb=n||{},r&&void 0!==i&&(this.gb.OSID=r,this.gb.OAID=i),this.ta&&(this.a.debug("connect() bypassed channel-test."),this.Ib.$d=[],this.Ib.od=!1),this.bf(t)},ls.disconnect=function(){if(this.a.debug("disconnect()"),this.qd(),3==this.g){var t=this.Yb++,e=this.hb.clone();e.l("SID",this.ra),e.l("RID",t),e.l("TYPE","terminate"),this.Ya(e),new Bu(this,this.a,this.ra,t,void 0).yg(e)}this.qe()},ls.bf=function(t){this.a.debug("connectTest_()"),this.Ja=new oc(this,this.a),null===this.N&&this.Ja.ga(this.A);var e=t;this.N&&this.A&&(e=_c(t,this.N,this.A)),this.Ja.connect(e)},ls.af=function(){this.a.debug("connectChannel_()"),this.hb=this.Sd(this.K),this.Dc()},ls.qd=function(){this.Ja&&(this.Ja.abort(),this.Ja=null),this.u&&(this.u.cancel(),this.u=null),this.ia&&(ds.clearTimeout(this.ia),this.ia=null),this.Hb(),this.G.cancel(),this.ea&&(ds.clearTimeout(this.ea),this.ea=null)},ls.ga=function(t){this.A=t},ls.Eg=function(t){this.Rb=t},ls.Cg=function(t){this.N=t},ls.Dg=function(t){this.aa=t},ls.Fe=function(t){this.Kc=t},ls.He=function(t){this.Ra=t},ls.Hg=function(){this.gc=!0},ls.Ee=function(t){this.i=t},ls.Nf=function(){return!this.fd},ls.Zc=function(t){1e3==this.M.length&&this.a.ca(function(){return"Already have 1000 queued maps upon queueing "+Ga(t)}),this.M.push(new function(t,e){this.Pc=t,this.map=e,this.context=null}(this.ag++,t)),3==this.g&&this.Dc()},ls.qf=function(){return this.kf?0:this.nf},ls.de=function(){return 0==this.g},ls.getState=function(){return this.g},ls.Dc=function(){this.G.ee()||this.ea||(this.ea=Ru(Ns(this.we,this),0),this.La=0)},ls.Yf=function(t){return this.G.xf()>=this.G.Xb-(this.ea?1:0)?(this.a.ca("Unexpected retry request is scheduled."),!1):this.ea?(this.a.debug("Use the retry request that is already scheduled."),this.M=t.la().concat(this.M),!0):!(1==this.g||2==this.g||this.La>=this.qf())&&(this.a.debug("Going to retry POST"),this.ea=Ru(Ns(this.we,this,t),this.Xd(this.La)),this.La++,!0)},ls.we=function(t){this.ea=null,this.Mg(t)},ls.Mg=function(t){this.a.debug("startForwardChannel_"),1==this.g?t?this.a.ca("Not supposed to retry the open"):(this.ig(),this.g=2):3==this.g&&(t?this.le(t):0==this.M.length?this.a.debug("startForwardChannel_ returned: nothing to send"):this.G.ee()?this.a.ca("startForwardChannel_ returned: connection already in progress"):(this.le(),this.a.debug("startForwardChannel_ finished, sent request")))},ls.ig=function(){this.a.debug("open_()"),this.Yb=Math.floor(1e5*Math.random());var t=this.Yb++,e=new Bu(this,this.a,"",t,void 0),n=this.A;this.Rb&&(n?na(n=ta(n),this.Rb):n=this.Rb),null===this.N&&e.ga(n);var r=this.Hd(e),i=this.hb.clone();i.l("RID",t),0<this.Bd&&i.l("CVER",this.Bd),this.ta&&this.aa&&i.l("X-HTTP-Session-Id",this.aa),this.Ya(i),this.N&&n&&_c(i,this.N,n),this.G.oc(e),this.Nd?(i.l("$req",r),i.l("SID","null"),e.Ag(),e.kd(i,null)):e.kd(i,r)},ls.le=function(t){var e=t?t.R:this.Yb++,n=this.hb.clone();n.l("SID",this.ra),n.l("RID",e),n.l("AID",this.Sb),this.Ya(n),this.N&&this.A&&_c(n,this.N,this.A),e=new Bu(this,this.a,this.ra,e,this.La+1),null===this.N&&e.ga(this.A),t&&this.sg(t),t=this.Hd(e),e.setTimeout(Math.round(.5*this.Od)+Math.round(.5*this.Od*Math.random())),this.G.oc(e),e.kd(n,t)},ls.Ya=function(t){this.i&&Qu({},function(e,n){t.l(n,e)})},ls.Hd=function(t){var e=Math.min(this.M.length,1e3),n=this.i?Ns(this.i.Ue,this.i,this):null;return n=this.kc.jf(this.M,e,n),t.Gg(this.M.splice(0,e)),n},ls.sg=function(t){this.M=t.la().concat(this.M)},ls.Kd=function(){if(!this.u&&!this.ia){this.rc=1;var t=this.ve;Ja||eu(),nu||(Ja(),nu=!0),ru.add(t,this),this.Ha=0}},ls.Qc=function(){return this.u||this.ia?(this.a.ca("Request already in progress"),!1):!(3<=this.Ha)&&(this.a.debug("Going to retry GET"),this.rc++,this.ia=Ru(Ns(this.ve,this),this.Xd(this.Ha)),this.Ha++,!0)},ls.ve=function(){this.ia=null,this.Kg()},ls.Kg=function(){this.a.debug("Creating new HttpRequest"),this.u=new Bu(this,this.a,this.ra,"rpc",this.rc),null===this.N&&this.u.ga(this.A),this.u.He(this.Ra);var t=this.md.clone();t.l("RID","rpc"),t.l("SID",this.ra),t.l("CI",this.fd?"0":"1"),t.l("AID",this.Sb),this.Ya(t),t.l("TYPE","xmlhttp"),this.N&&this.A&&_c(t,this.N,this.A),this.Db&&this.u.setTimeout(this.Db),this.u.jd(t,!0,this.na),this.a.debug("New Request created")},ls.ub=function(t,e){this.a.debug("Test Connection Finished");var n=t.Ad;n&&this.G.ld(n),this.fd=this.Se&&e,this.w=t.w,this.af()},ls.dd=function(t){this.a.debug("Test Connection Failed"),this.w=t.w,this.sa(2)},ls.ue=function(t,e){if(0!=this.g&&(this.u==t||this.G.Jc(t)))if(this.w=t.w,!t.lb&&this.G.Jc(t)&&3==this.g){try{var n=this.kc.zc(e)}catch(t){n=null}bs(n)&&3==n.length?this.Cf(n,t):(this.a.debug("Bad POST response data returned"),this.sa(11))}else(t.lb||this.u==t)&&this.Hb(),Ks(e)||(n=this.kc.zc(e),this.dg(n,t))},ls.Cf=function(t,e){0==t[0]?this.Bf(e):(this.he=t[1],0<(e=this.he-this.Sb)&&(t=t[2],this.a.debug(t+" bytes (in "+e+" arrays) are outstanding on the BackChannel"),this.Jg(t)&&!this.wa&&(this.wa=Ru(Ns(this.bg,this),6e3))))},ls.Bf=function(t){if(this.a.debug("Server claims our backchannel is missing."),this.ia)this.a.debug("But we are currently starting the request.");else{if(this.u){if(!(this.u.qb+3e3<t.qb))return;this.Hb(),this.u.cancel(),this.u=null}else this.a.T("We do not have a BackChannel established");this.Qc(),Du(18)}},ls.Jg=function(t){return 37500>t&&!this.Nf()&&0==this.Ha},ls.$a=function(t){return this.Te?this.i?this.i.$a(t):t:null},ls.bg=function(){null!=this.wa&&(this.wa=null,this.u.cancel(),this.u=null,this.Qc(),Du(19))},ls.Hb=function(){null!=this.wa&&(ds.clearTimeout(this.wa),this.wa=null)},ls.Tc=function(t){this.a.debug("Request complete");var e=null;if(this.u==t){this.Hb(),this.u=null;var n=2}else{if(!this.G.Jc(t))return;e=t.la(),this.G.ze(t),n=1}if(this.w=t.w,0!=this.g)if(t.S)1==n?(function(t,e,n){Su.dispatchEvent(new Au(Su,t,e,n))}(t.Da?t.Da.length:0,As()-t.qb,this.La),this.Dc()):this.Kd();else{var r=t.Hc();if(3==r||0==r&&0<this.w)this.a.debug("Not retrying due to error type");else{var i=this;if(this.a.debug(function(){return"Maybe retrying, last error: "+function(t,e){switch(t){case 0:return"Non-200 return code ("+e+")";case 1:return"XMLHTTP failure (no data)";case 2:return"HttpConnection timeout";default:return"Unknown error"}}(r,i.w)}),1==n&&this.Yf(t)||2==n&&this.Qc())return;this.a.debug("Exceeded max number of retries")}switch(e&&0<e.length&&this.G.Re(e),this.a.debug("Error: HTTP request failed"),r){case 1:this.sa(5);break;case 4:this.sa(10);break;case 3:this.sa(6);break;default:this.sa(2)}}},ls.Xd=function(t){var e=this.Ve+Math.floor(Math.random()*this.vg);return this.Ba()||(this.a.debug("Inactive channel"),e*=2),e*t},ls.pc=function(t){if(this.ta&&(t=t.h)){var e=t.kb("X-Client-Wire-Protocol");e&&this.G.ld(e),this.aa&&((t=t.kb("X-HTTP-Session-Id"))?(this.Fe(t),this.hb.l(this.aa,t)):this.a.T("Missing X_HTTP_SESSION_ID in the handshake response"))}},ls.dg=function(t,e){for(var n=this.i&&this.i.sc?[]:null,r=0;r<t.length;r++){var i=t[r];if(this.Sb=i[0],i=i[1],2==this.g)if("c"==i[0]){this.ra=i[1],this.na=this.$a(i[2]);var o=i[3];null!=o&&(this.tc=o,this.a.info("VER="+this.tc)),null!=(o=i[4])&&(this.De=o,this.a.info("SVER="+this.De)),null!=(i=i[5])&&"number"==typeof i&&0<i&&(this.Db=i*=1.5,this.a.info("backChannelRequestTimeoutMs_="+i)),this.pc(e),this.g=3,this.i&&this.i.wd(),this.Lg(e)}else"stop"!=i[0]&&"close"!=i[0]||this.sa(7);else 3==this.g&&("stop"==i[0]||"close"==i[0]?(n&&0!=n.length&&(this.i.sc(this,n),n.length=0),"stop"==i[0]?this.sa(7):this.disconnect()):"noop"!=i[0]&&(n?n.push(i):this.i&&this.i.ud(i)),this.Ha=0)}n&&0!=n.length&&this.i.sc(this,n)},ls.Lg=function(t){this.md=this.Pd(this.na,this.K),t.lb?(this.a.debug("Upgrade the handshake request to a backchannel."),this.G.ze(t),t.tg(this.Db),this.u=t):this.Kd()},ls.sa=function(t){if(this.a.info("Error code "+t),2==t){var e=null;this.i&&(e=null);var n=Ns(this.Pg,this);e||(e=new Yu("//www.google.com/images/cleardot.gif"),ds.location&&"http"==ds.location.protocol||e.tb("https"),e.Ub()),function(t,e){var n=new Tu;n.debug("TestLoadImage: loading "+t);var r=new Image;r.onload=Ds(fc,n,r,"TestLoadImage: loaded",!0,e),r.onerror=Ds(fc,n,r,"TestLoadImage: error",!1,e),r.onabort=Ds(fc,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=Ds(fc,n,r,"TestLoadImage: timeout",!1,e),ds.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=t}(e.toString(),n)}else Du(2);this.cg(t)},ls.Pg=function(t){t?(this.a.info("Successfully pinged google.com"),Du(2)):(this.a.info("Failed to ping google.com"),Du(1))},ls.cg=function(t){this.a.debug("HttpChannel: error - "+t),this.g=0,this.i&&this.i.td(t),this.qe(),this.qd()},ls.qe=function(){if(this.g=0,this.w=-1,this.i){var t=this.G.la();if(0!=t.length||0!=this.M.length){var e=this;this.a.debug(function(){return"Number of undelivered maps, pending: "+t.length+", outgoing: "+e.M.length}),this.G.$e(),js(this.M),this.M.length=0}this.i.sd()}},ls.Sd=function(t){return t=this.Cd(null,t),this.a.debug("GetForwardChannelUri: "+t),t},ls.Pd=function(t,e){return t=this.Cd(this.fc()?t:null,e),this.a.debug("GetBackChannelUri: "+t),t},ls.Cd=function(t,e){var n=function(t){return t instanceof Yu?t.clone():new Yu(t,void 0)}(e);if(""!=n.xa)t&&n.rb(t+"."+n.xa),n.sb(n.Ca);else{var r=ds.location;n=function(t,e,n,r){var i=new Yu(null,void 0);return t&&i.tb(t),e&&i.rb(e),n&&i.sb(n),r&&i.ec(r),i}(r.protocol,t?t+"."+r.hostname:r.hostname,+r.port,e)}return this.gb&&Js(this.gb,function(t,e){n.l(e,t)}),t=this.aa,e=this.Kc,t&&e&&n.l(t,e),n.l("VER",this.tc),this.Ya(n),n},ls.Jb=function(t){if(t&&!this.gc)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new dc(this.Xa)).Je(this.gc),t},ls.Ba=function(){return!!this.i&&this.i.Ba()},ls.fc=function(){return this.gc},(ls=Ec.prototype).sc=null,ls.wd=function(){},ls.ud=function(){},ls.td=function(){},ls.sd=function(){},ls.Ba=function(){return!0},ls.Ue=function(){},ls.$a=function(t){return t},Tc.prototype.cf=function(t,e){return new Sc(t,e)},Rs(Sc,Ha),(ls=Sc.prototype).addEventListener=function(t,e,n,r){Sc.L.addEventListener.call(this,t,e,n,r)},ls.removeEventListener=function(t,e,n,r){Sc.L.removeEventListener.call(this,t,e,n,r)},ls.open=function(){this.b.Ee(this.vd),this.Og&&this.b.Hg(),this.b.connect(this.Qg,this.yb,this.Rc||void 0)},ls.close=function(){this.b.disconnect()},ls.send=function(t){if(ys(t)){var e={};e.__data__=t,this.b.Zc(e)}else this.zg?((e={}).__data__=Ga(t),this.b.Zc(e)):this.b.Zc(t)},ls.F=function(){this.b.Ee(null),delete this.vd,this.b.disconnect(),delete this.b,Sc.L.F.call(this)},Rs(Ic,Fu),Rs(Cc,Uu),Rs(Nc,Ec),Nc.prototype.wd=function(){wu(this.b.s,"WebChannel opened on "+this.b.yb),this.b.dispatchEvent("a")},Nc.prototype.ud=function(t){this.b.dispatchEvent(new Ic(t))},Nc.prototype.td=function(t){wu(this.b.s,"WebChannel aborted on "+this.b.yb+" due to channel error: "+t),this.b.dispatchEvent(new Cc(t))},Nc.prototype.sd=function(){wu(this.b.s,"WebChannel closed on "+this.b.yb),this.b.dispatchEvent("b")};var Dc=Ds(function(t,e){function n(){}n.prototype=t.prototype;var r=new n;return t.apply(r,Array.prototype.slice.call(arguments,1)),r},Tc);function Ac(){this.V=[],this.Z=[]}function Rc(t,e){if(Ps.call(this),this.oe=t||0,this.Wb=e||10,this.oe>this.Wb)throw Error(kc);this.fa=new Ac,this.oa=new sc,this.Ac=0,this.Nc=null,this.Cb()}(ls=Ac.prototype).Vf=function(){0==this.V.length&&(this.V=this.Z,this.V.reverse(),this.Z=[])},ls.enqueue=function(t){this.Z.push(t)},ls.ab=function(){return this.Vf(),this.V.pop()},ls.C=function(){return this.V.length+this.Z.length},ls.X=function(){return 0==this.V.length&&0==this.Z.length},ls.clear=function(){this.V=[],this.Z=[]},ls.contains=function(t){return 0<=xs(this.V,t)||0<=xs(this.Z,t)},ls.remove=function(t){var e=this.V,n=Fs(e,t);return 0<=n?(Array.prototype.splice.call(e,n,1),e=!0):e=!1,e||Vs(this.Z,t)},ls.H=function(){for(var t=[],e=this.V.length-1;0<=e;--e)t.push(this.V[e]);var n=this.Z.length;for(e=0;e<n;++e)t.push(this.Z[e]);return t},Rs(Rc,Ps);var kc="[goog.structs.Pool] Min can not be greater than max";function Oc(t,e){this.fe=t,this.gd=e}function Pc(t){this.Y=[],t&&this.Lf(t)}function Lc(){Pc.call(this)}function Mc(t,e){this.Gd=void 0,this.cc=new Lc,Rc.call(this,t,e)}function xc(t,e,n,r){this.Jf=t,this.Ab=!!r,Mc.call(this,e,n)}(ls=Rc.prototype).Mb=function(){var t=As();if(!(null!=this.Nc&&t-this.Nc<this.Ac)){var e=this.qg();return e&&(this.Nc=t,this.oa.add(e)),e}},ls.og=function(t){return!!this.oa.remove(t)&&(this.nc(t),!0)},ls.qg=function(){for(var t;0<this.Td()&&(t=this.fa.ab(),!this.Sc(t));)this.Cb();return!t&&this.C()<this.Wb&&(t=this.xc()),t},ls.nc=function(t){this.oa.remove(t),this.Sc(t)&&this.C()<this.Wb?this.fa.enqueue(t):this.Bc(t)},ls.Cb=function(){for(var t=this.fa;this.C()<this.oe;)t.enqueue(this.xc());for(;this.C()>this.Wb&&0<this.Td();)this.Bc(t.ab())},ls.xc=function(){return{}},ls.Bc=function(t){if("function"==typeof t.bb)t.bb();else for(var e in t)t[e]=null},ls.Sc=function(t){return"function"!=typeof t.Ye||t.Ye()},ls.contains=function(t){return this.fa.contains(t)||this.oa.contains(t)},ls.C=function(){return this.fa.C()+this.oa.C()},ls.rf=function(){return this.oa.C()},ls.Td=function(){return this.fa.C()},ls.X=function(){return this.fa.X()&&this.oa.X()},ls.F=function(){if(Rc.L.F.call(this),0<this.rf())throw Error("[goog.structs.Pool] Objects not released");delete this.oa;for(var t=this.fa;!t.X();)this.Bc(t.ab());delete this.fa},Oc.prototype.getKey=function(){return this.fe},Oc.prototype.clone=function(){return new Oc(this.fe,this.gd)},(ls=Pc.prototype).ce=function(t,e){var n=this.Y;n.push(new Oc(t,e)),this.$f(n.length-1)},ls.Lf=function(t){if(t instanceof Pc){var e=t.W();if(t=t.H(),0>=this.C()){for(var n=this.Y,r=0;r<e.length;r++)n.push(new Oc(e[r],t[r]));return}}else e=Zs(t),t=$s(t);for(r=0;r<e.length;r++)this.ce(e[r],t[r])},ls.remove=function(){var t=this.Y,e=t.length,n=t[0];if(!(0>=e))return 1==e?Bs(t):(t[0]=t.pop(),this.Zf()),n.gd},ls.Zf=function(){for(var t=0,e=this.Y,n=e.length,r=e[t];t<n>>1;){var i=this.tf(t),o=this.zf(t);if(e[i=o<n&&e[o].getKey()<e[i].getKey()?o:i].getKey()>r.getKey())break;e[t]=e[i],t=i}e[t]=r},ls.$f=function(t){for(var e=this.Y,n=e[t];0<t;){var r=this.wf(t);if(!(e[r].getKey()>n.getKey()))break;e[t]=e[r],t=r}e[t]=n},ls.tf=function(t){return 2*t+1},ls.zf=function(t){return 2*t+2},ls.wf=function(t){return t-1>>1},ls.H=function(){for(var t=this.Y,e=[],n=t.length,r=0;r<n;r++)e.push(t[r].gd);return e},ls.W=function(){for(var t=this.Y,e=[],n=t.length,r=0;r<n;r++)e.push(t[r].getKey());return e},ls.va=function(t){return qs(this.Y,function(e){return e.getKey()==t})},ls.clone=function(){return new Pc(this)},ls.C=function(){return this.Y.length},ls.X=function(){return 0==this.Y.length},ls.clear=function(){Bs(this.Y)},Rs(Lc,Pc),Lc.prototype.enqueue=function(t,e){this.ce(t,e)},Lc.prototype.ab=function(){return this.remove()},Rs(Mc,Rc),(ls=Mc.prototype).Mb=function(t,e){if(!t)return(t=Mc.L.Mb.call(this))&&this.Ac&&(this.Gd=ds.setTimeout(Ns(this.Nb,this),this.Ac)),t;this.cc.enqueue(void 0!==e?e:100,t),this.Nb()},ls.Nb=function(){for(var t=this.cc;0<t.C();){var e=this.Mb();if(!e)break;t.ab().apply(this,[e])}},ls.nc=function(t){Mc.L.nc.call(this,t),this.Nb()},ls.Cb=function(){Mc.L.Cb.call(this),this.Nb()},ls.F=function(){Mc.L.F.call(this),ds.clearTimeout(this.Gd),this.cc.clear(),this.cc=null},Rs(xc,Mc),xc.prototype.xc=function(){var t=new dc,e=this.Jf;return e&&e.forEach(function(e,n){t.headers.set(n,e)}),this.Ab&&t.Je(!0),t},xc.prototype.Sc=function(t){return!t.Ka&&!t.Ba()},Tc.prototype.createWebChannel=Tc.prototype.cf,Sc.prototype.send=Sc.prototype.send,Sc.prototype.open=Sc.prototype.open,Sc.prototype.close=Sc.prototype.close,ku.NO_ERROR=0,ku.TIMEOUT=8,ku.HTTP_ERROR=6,Ou.COMPLETE="complete",Lu.EventType=xu,xu.OPEN="a",xu.CLOSE="b",xu.ERROR="c",xu.MESSAGE="d",Ha.prototype.listen=Ha.prototype.nb,xc.prototype.getObject=xc.prototype.Mb,xc.prototype.releaseObject=xc.prototype.og,dc.prototype.listenOnce=dc.prototype.Oc,dc.prototype.getLastError=dc.prototype.Hc,dc.prototype.getLastErrorCode=dc.prototype.Ud,dc.prototype.getStatus=dc.prototype.za,dc.prototype.getStatusText=dc.prototype.Yd,dc.prototype.getResponseJson=dc.prototype.yf,dc.prototype.getResponseText=dc.prototype.ya,dc.prototype.getResponseText=dc.prototype.ya,dc.prototype.send=dc.prototype.send;var Fc,Uc,qc={createWebChannelTransport:Dc,ErrorCode:ku,EventType:Ou,WebChannel:Lu,XhrIoPool:xc},Bc=qc.createWebChannelTransport,Vc=qc.ErrorCode,Wc=qc.EventType,jc=qc.WebChannel,Kc=qc.XhrIoPool,Qc=Yn.SDK_VERSION,Hc=new $n("@firebase/firestore");function Gc(){return Hc.logLevel===Gn.DEBUG?Fc.DEBUG:Hc.logLevel===Gn.SILENT?Fc.SILENT:Fc.ERROR}function zc(t){switch(t){case Fc.DEBUG:Hc.logLevel=Gn.DEBUG;break;case Fc.ERROR:Hc.logLevel=Gn.ERROR;break;case Fc.SILENT:Hc.logLevel=Gn.SILENT;break;default:Hc.error("Firestore ("+Qc+"): Invalid value passed to `setLogLevel`")}}function Yc(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(Hc.logLevel<=Gn.DEBUG){var i=n.map(Jc);Hc.debug.apply(Hc,["Firestore ("+Qc+") ["+t+"]: "+e].concat(i))}}function Xc(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(Hc.logLevel<=Gn.ERROR){var r=e.map(Jc);Hc.error.apply(Hc,["Firestore ("+Qc+"): "+t].concat(r))}}function Jc(t){if("string"==typeof t)return t;var e=th.getPlatform();try{return e.formatJSON(t)}catch(e){return t}}function $c(t){var e="FIRESTORE ("+Qc+") INTERNAL ASSERTION FAILED: "+t;throw Xc(e),new Error(e)}function Zc(t,e){t||$c(e)}(Uc=Fc||(Fc={}))[Uc.DEBUG=0]="DEBUG",Uc[Uc.ERROR=1]="ERROR",Uc[Uc.SILENT=2]="SILENT";var th=function(){function t(){}return t.setPlatform=function(e){t.platform&&$c("Platform already defined"),t.platform=e},t.getPlatform=function(){return t.platform||$c("Platform not set"),t.platform},t}();function eh(){return th.getPlatform().emptyByteString}var nh={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},rh=function(t){function e(e,n){var r=t.call(this,n)||this;return r.code=e,r.message=n,r.name="FirebaseError",r.toString=function(){return r.name+": [code="+r.code+"]: "+r.message},r}return Je(e,t),e}(Error);function ih(t,e){function n(){var t="This constructor is private.";throw e&&(t+=" ",t+=e),new rh(nh.INVALID_ARGUMENT,t)}for(var r in n.prototype=t.prototype,t)t.hasOwnProperty(r)&&(n[r]=t[r]);return n}function oh(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function sh(t,e){return void 0!==t?t:e}function ah(t,e){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=Number(n);isNaN(r)||e(r,t[n])}}function uh(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function ch(t){for(var e in Zc(null!=t&&"object"==typeof t,"isEmpty() expects object parameter."),t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function hh(t,e,n){if(e.length!==n)throw new rh(nh.INVALID_ARGUMENT,"Function "+t+"() requires "+Ch(n,"argument")+", but was called with "+Ch(e.length,"argument")+".")}function lh(t,e,n){if(e.length<n)throw new rh(nh.INVALID_ARGUMENT,"Function "+t+"() requires at least "+Ch(n,"argument")+", but was called with "+Ch(e.length,"argument")+".")}function fh(t,e,n,r){if(e.length<n||e.length>r)throw new rh(nh.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+Ch(e.length,"argument")+".")}function ph(t,e,n,r){bh(t,e,Ih(n)+" argument",r)}function dh(t,e,n,r){void 0!==r&&ph(t,e,n,r)}function yh(t,e,n,r){bh(t,e,n+" option",r)}function mh(t,e,n,r){void 0!==r&&yh(t,e,n,r)}function gh(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){if(!(r instanceof Array))throw new rh(nh.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+wh(r));for(var o=0;o<r.length;++o)if(!i(r[o]))throw new rh(nh.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be "+n+", but the value at index "+o+" was: "+wh(r[o]))}(t,e,n,r,i)}function vh(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){for(var o=[],s=0,a=i;s<a.length;s++){var u=a[s];if(u===r)return;o.push(wh(u))}var c=wh(r);throw new rh(nh.INVALID_ARGUMENT,"Invalid value "+c+" provided to function "+t+'() for option "'+n+'". Acceptable values: '+o.join(", "))}(t,0,n,r,i)}function bh(t,e,n,r){if(!("object"===e?_h(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=wh(r);throw new rh(nh.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function _h(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function wh(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=t.substring(0,20)+"..."),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";var e=function(t){if(t.constructor){var e=/function\s+([^\s(]+)\s*\(/.exec(t.constructor.toString());if(e&&e.length>1)return e[1]}return null}(t);return e?"a custom "+e+" object":"an object"}return"function"==typeof t?"a function":$c("Unknown wrong type: "+typeof t)}function Eh(t,e,n){if(void 0===n)throw new rh(nh.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+Ih(e)+" argument, but it was undefined.")}function Th(t,e,n){uh(e,function(e,r){if(n.indexOf(e)<0)throw new rh(nh.INVALID_ARGUMENT,"Unknown option '"+e+"' passed to function "+t+"(). Available options: "+n.join(", "))})}function Sh(t,e,n,r){var i=wh(r);return new rh(nh.INVALID_ARGUMENT,"Function "+t+"() requires its "+Ih(n)+" argument to be a "+e+", but it was: "+i)}function Ih(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}}function Ch(t,e){return t+" "+e+(1===t?"":"s")}var Nh=function(){function t(){}return t.newId=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="",n=0;n<20;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return Zc(20===e.length,"Invalid auto ID: "+e),e},t}();function Dh(t,e){return t<e?-1:t>e?1:0}function Ah(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].isEqual(e[n]))return!1;return!0}function Rh(){if("undefined"==typeof Uint8Array)throw new rh(nh.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function kh(){if(!th.getPlatform().base64Available)throw new rh(nh.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var Oh,Ph,Lh=function(){function t(t){kh(),this._binaryString=t}return t.fromBase64String=function(e){hh("Blob.fromBase64String",arguments,1),ph("Blob.fromBase64String","string",1,e),kh();try{return new t(th.getPlatform().atob(e))}catch(t){throw new rh(nh.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+t)}},t.fromUint8Array=function(e){if(hh("Blob.fromUint8Array",arguments,1),Rh(),!(e instanceof Uint8Array))throw Sh("Blob.fromUint8Array","Uint8Array",1,e);return new t(Array.prototype.map.call(e,function(t){return String.fromCharCode(t)}).join(""))},t.prototype.toBase64=function(){return hh("Blob.toBase64",arguments,0),kh(),th.getPlatform().btoa(this._binaryString)},t.prototype.toUint8Array=function(){hh("Blob.toUint8Array",arguments,0),Rh();for(var t=new Uint8Array(this._binaryString.length),e=0;e<this._binaryString.length;e++)t[e]=this._binaryString.charCodeAt(e);return t},t.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},t.prototype.isEqual=function(t){return this._binaryString===t._binaryString},t.prototype._compareTo=function(t){return Dh(this._binaryString,t._binaryString)},t}(),Mh=ih(Lh,"Use Blob.fromUint8Array() or Blob.fromBase64String() instead."),xh=function(){function t(t,e){if(hh("GeoPoint",arguments,2),ph("GeoPoint","number",1,t),ph("GeoPoint","number",2,e),!isFinite(t)||t<-90||t>90)throw new rh(nh.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new rh(nh.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}return Object.defineProperty(t.prototype,"latitude",{get:function(){return this._lat},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"longitude",{get:function(){return this._long},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(t){return this._lat===t._lat&&this._long===t._long},t.prototype._compareTo=function(t){return Dh(this._lat,t._lat)||Dh(this._long,t._long)},t}(),Fh=function(){function t(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new rh(nh.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new rh(nh.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new rh(nh.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new rh(nh.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}return t.now=function(){return t.fromMillis(Date.now())},t.fromDate=function(e){return t.fromMillis(e.getTime())},t.fromMillis=function(e){var n=Math.floor(e/1e3);return new t(n,1e6*(e-1e3*n))},t.prototype.toDate=function(){return new Date(this.toMillis())},t.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},t.prototype._compareTo=function(t){return this.seconds===t.seconds?Dh(this.nanoseconds,t.nanoseconds):Dh(this.seconds,t.seconds)},t.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},t.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},t}(),Uh=function(){return function(t,e,n,r){this.databaseId=t,this.persistenceKey=e,this.host=n,this.ssl=r}}(),qh="(default)",Bh=function(){function t(t,e){this.projectId=t,this.database=e||qh}return Object.defineProperty(t.prototype,"isDefaultDatabase",{get:function(){return this.database===qh},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(e){return e instanceof t&&e.projectId===this.projectId&&e.database===this.database},t.prototype.compareTo=function(t){return Dh(this.projectId,t.projectId)||Dh(this.database,t.database)},t}(),Vh=function(){function t(t,e,n){this.init(t,e,n)}return t.prototype.init=function(t,e,n){void 0===e?e=0:e>t.length&&$c("offset "+e+" out of range "+t.length),void 0===n?n=t.length-e:n>t.length-e&&$c("length "+n+" out of range "+(t.length-e)),this.segments=t,this.offset=e,this.len=n},t.prototype.construct=function(t,e,n){var r=Object.create(Object.getPrototypeOf(this));return r.init(t,e,n),r},Object.defineProperty(t.prototype,"length",{get:function(){return this.len},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(e){return 0===t.comparator(this,e)},t.prototype.child=function(e){var n=this.segments.slice(this.offset,this.limit());return e instanceof t?e.forEach(function(t){n.push(t)}):"string"==typeof e?n.push(e):$c("Unknown parameter type for Path.child(): "+e),this.construct(n)},t.prototype.limit=function(){return this.offset+this.length},t.prototype.popFirst=function(t){return t=void 0===t?1:t,Zc(this.length>=t,"Can't call popFirst() with less segments"),this.construct(this.segments,this.offset+t,this.length-t)},t.prototype.popLast=function(){return Zc(!this.isEmpty(),"Can't call popLast() on empty path"),this.construct(this.segments,this.offset,this.length-1)},t.prototype.firstSegment=function(){return Zc(!this.isEmpty(),"Can't call firstSegment() on empty path"),this.segments[this.offset]},t.prototype.lastSegment=function(){return Zc(!this.isEmpty(),"Can't call lastSegment() on empty path"),this.segments[this.limit()-1]},t.prototype.get=function(t){return Zc(t<this.length,"Index out of range"),this.segments[this.offset+t]},t.prototype.isEmpty=function(){return 0===this.length},t.prototype.isPrefixOf=function(t){if(t.length<this.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},t.prototype.isImmediateParentOf=function(t){if(this.length+1!==t.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},t.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},t.prototype.toArray=function(){return this.segments.slice(this.offset,this.limit())},t.comparator=function(t,e){for(var n=Math.min(t.length,e.length),r=0;r<n;r++){var i=t.get(r),o=e.get(r);if(i<o)return-1;if(i>o)return 1}return t.length<e.length?-1:t.length>e.length?1:0},t}(),Wh=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Je(e,t),e.prototype.canonicalString=function(){return this.toArray().join("/")},e.prototype.toString=function(){return this.canonicalString()},e.fromString=function(t){if(t.indexOf("//")>=0)throw new rh(nh.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new e(t.split("/").filter(function(t){return t.length>0}))},e.EMPTY_PATH=new e([]),e}(Vh),jh=/^[_a-zA-Z][_a-zA-Z0-9]*$/,Kh=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Je(e,t),e.isValidIdentifier=function(t){return jh.test(t)},e.prototype.canonicalString=function(){return this.toArray().map(function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),e.isValidIdentifier(t)||(t="`"+t+"`"),t}).join(".")},e.prototype.toString=function(){return this.canonicalString()},e.prototype.isKeyField=function(){return 1===this.length&&"__name__"===this.get(0)},e.keyField=function(){return new e(["__name__"])},e.fromServerFormat=function(t){for(var n=[],r="",i=0,o=function(){if(0===r.length)throw new rh(nh.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'");n.push(r),r=""},s=!1;i<t.length;){var a=t[i];if("\\"===a){if(i+1===t.length)throw new rh(nh.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var u=t[i+1];if("\\"!==u&&"."!==u&&"`"!==u)throw new rh(nh.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);r+=u,i+=2}else"`"===a?(s=!s,i++):"."!==a||s?(r+=a,i++):(o(),i++)}if(o(),s)throw new rh(nh.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)},e.EMPTY_PATH=new e([]),e}(Vh),Qh=function(){function t(e){this.path=e,Zc(t.isDocumentKey(e),"Invalid DocumentKey with an odd number of segments: "+e.toArray().join("/"))}return t.prototype.isEqual=function(t){return null!==t&&0===Wh.comparator(this.path,t.path)},t.prototype.toString=function(){return this.path.toString()},t.comparator=function(t,e){return Wh.comparator(t.path,e.path)},t.isDocumentKey=function(t){return t.length%2==0},t.fromSegments=function(e){return new t(new Wh(e.slice()))},t.fromPathString=function(e){return new t(Wh.fromString(e))},t.EMPTY=new t(new Wh([])),t}(),Hh=function(){function t(t,e){this.key=t,this.version=e}return t.compareByKey=function(t,e){return Qh.comparator(t.key,e.key)},t}(),Gh=function(t){function e(e,n,r,i,o){var s=t.call(this,e,n)||this;return s.data=r,s.proto=o,s.hasLocalMutations=!!i.hasLocalMutations,s.hasCommittedMutations=!!i.hasCommittedMutations,s}return Je(e,t),e.prototype.field=function(t){return this.data.field(t)},e.prototype.fieldValue=function(t){var e=this.field(t);return e?e.value():void 0},e.prototype.value=function(){return this.data.value()},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.data.isEqual(t.data)&&this.hasLocalMutations===t.hasLocalMutations&&this.hasCommittedMutations===t.hasCommittedMutations},e.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.data.toString()+", {hasLocalMutations: "+this.hasLocalMutations+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return this.hasLocalMutations||this.hasCommittedMutations},enumerable:!0,configurable:!0}),e.compareByField=function(t,e,n){var r=e.field(t),i=n.field(t);return void 0!==r&&void 0!==i?r.compareTo(i):$c("Trying to compare documents on fields that don't exist")},e}(Hh),zh=function(t){function e(e,n,r){var i=t.call(this,e,n)||this;return i.hasCommittedMutations=!(!r||!r.hasCommittedMutations),i}return Je(e,t),e.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!0,configurable:!0}),e.prototype.isEqual=function(t){return t instanceof e&&t.hasCommittedMutations===this.hasCommittedMutations&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},e}(Hh),Yh=function(t){function e(e,n){return t.call(this,e,n)||this}return Je(e,t),e.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return!0},enumerable:!0,configurable:!0}),e.prototype.isEqual=function(t){return t instanceof e&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},e}(Hh),Xh=function(){function t(t,e){this.comparator=t,this.root=e||$h.EMPTY}return t.prototype.insert=function(e,n){return new t(this.comparator,this.root.insert(e,n,this.comparator).copy(null,null,$h.BLACK,null,null))},t.prototype.remove=function(e){return new t(this.comparator,this.root.remove(e,this.comparator).copy(null,null,$h.BLACK,null,null))},t.prototype.get=function(t){for(var e=this.root;!e.isEmpty();){var n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null},t.prototype.indexOf=function(t){for(var e=0,n=this.root;!n.isEmpty();){var r=this.comparator(t,n.key);if(0===r)return e+n.left.size;r<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1},t.prototype.isEmpty=function(){return this.root.isEmpty()},Object.defineProperty(t.prototype,"size",{get:function(){return this.root.size},enumerable:!0,configurable:!0}),t.prototype.minKey=function(){return this.root.minKey()},t.prototype.maxKey=function(){return this.root.maxKey()},t.prototype.inorderTraversal=function(t){return this.root.inorderTraversal(t)},t.prototype.forEach=function(t){this.inorderTraversal(function(e,n){return t(e,n),!1})},t.prototype.reverseTraversal=function(t){return this.root.reverseTraversal(t)},t.prototype.getIterator=function(){return new Jh(this.root,null,this.comparator,!1)},t.prototype.getIteratorFrom=function(t){return new Jh(this.root,t,this.comparator,!1)},t.prototype.getReverseIterator=function(){return new Jh(this.root,null,this.comparator,!0)},t.prototype.getReverseIteratorFrom=function(t){return new Jh(this.root,t,this.comparator,!0)},t}(),Jh=function(){function t(t,e,n,r){this.isReverse=r,this.nodeStack=[];for(var i=1;!t.isEmpty();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.isReverse?t.left:t.right;else{if(0===i){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}return t.prototype.getNext=function(){Zc(this.nodeStack.length>0,"getNext() called on iterator when hasNext() is false.");var t=this.nodeStack.pop(),e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e},t.prototype.hasNext=function(){return this.nodeStack.length>0},t.prototype.peek=function(){if(0===this.nodeStack.length)return null;var t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}},t}(),$h=function(){function t(e,n,r,i,o){this.key=e,this.value=n,this.color=null!=r?r:t.RED,this.left=null!=i?i:t.EMPTY,this.right=null!=o?o:t.EMPTY,this.size=this.left.size+1+this.right.size}return t.prototype.copy=function(e,n,r,i,o){return new t(null!=e?e:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},t.prototype.isEmpty=function(){return!1},t.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},t.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},t.prototype.min=function(){return this.left.isEmpty()?this:this.left.min()},t.prototype.minKey=function(){return this.min().key},t.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},t.prototype.insert=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n))).fixUp()},t.prototype.removeMin=function(){if(this.left.isEmpty())return t.EMPTY;var e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),(e=e.copy(null,null,null,e.left.removeMin(),null)).fixUp()},t.prototype.remove=function(e,n){var r,i=this;if(n(e,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(e,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),0===n(e,i.key)){if(i.right.isEmpty())return t.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(e,n))}return i.fixUp()},t.prototype.isRed=function(){return this.color},t.prototype.fixUp=function(){var t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t},t.prototype.moveRedLeft=function(){var t=this.colorFlip();return t.right.left.isRed()&&(t=(t=(t=t.copy(null,null,null,null,t.right.rotateRight())).rotateLeft()).colorFlip()),t},t.prototype.moveRedRight=function(){var t=this.colorFlip();return t.left.left.isRed()&&(t=(t=t.rotateRight()).colorFlip()),t},t.prototype.rotateLeft=function(){var e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)},t.prototype.rotateRight=function(){var e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)},t.prototype.colorFlip=function(){var t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)},t.prototype.checkMaxDepth=function(){var t=this.check();return Math.pow(2,t)<=this.size+1},t.prototype.check=function(){if(this.isRed()&&this.left.isRed())throw $c("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed())throw $c("Right child of ("+this.key+","+this.value+") is red");var t=this.left.check();if(t!==this.right.check())throw $c("Black depths differ");return t+(this.isRed()?0:1)},t.EMPTY=null,t.RED=!0,t.BLACK=!1,t}(),Zh=function(){function t(){this.size=0}return t.prototype.copy=function(t,e,n,r,i){return this},t.prototype.insert=function(t,e,n){return new $h(t,e)},t.prototype.remove=function(t,e){return this},t.prototype.isEmpty=function(){return!0},t.prototype.inorderTraversal=function(t){return!1},t.prototype.reverseTraversal=function(t){return!1},t.prototype.minKey=function(){return null},t.prototype.maxKey=function(){return null},t.prototype.isRed=function(){return!1},t.prototype.checkMaxDepth=function(){return!0},t.prototype.check=function(){return 0},t}();$h.EMPTY=new Zh,function(t){t[t.NullValue=0]="NullValue",t[t.BooleanValue=1]="BooleanValue",t[t.NumberValue=2]="NumberValue",t[t.TimestampValue=3]="TimestampValue",t[t.StringValue=4]="StringValue",t[t.BlobValue=5]="BlobValue",t[t.RefValue=6]="RefValue",t[t.GeoPointValue=7]="GeoPointValue",t[t.ArrayValue=8]="ArrayValue",t[t.ObjectValue=9]="ObjectValue"}(Oh||(Oh={})),function(t){t[t.Default=0]="Default",t[t.Estimate=1]="Estimate",t[t.Previous=2]="Previous"}(Ph||(Ph={}));var tl=function(){function t(t,e){this.serverTimestampBehavior=t,this.timestampsInSnapshots=e}return t.fromSnapshotOptions=function(e,n){switch(e.serverTimestamps){case"estimate":return new t(Ph.Estimate,n);case"previous":return new t(Ph.Previous,n);case"none":case void 0:return new t(Ph.Default,n);default:return $c("fromSnapshotOptions() called with invalid options.")}},t}(),el=function(){function t(){}return t.prototype.toString=function(){var t=this.value();return null===t?"null":t.toString()},t.prototype.defaultCompareTo=function(t){return Zc(this.typeOrder!==t.typeOrder,"Default compareTo should not be used for values of same type."),Dh(this.typeOrder,t.typeOrder)},t}(),nl=function(t){function e(){var e=t.call(this)||this;return e.typeOrder=Oh.NullValue,e.internalValue=null,e}return Je(e,t),e.prototype.value=function(t){return null},e.prototype.isEqual=function(t){return t instanceof e},e.prototype.compareTo=function(t){return t instanceof e?0:this.defaultCompareTo(t)},e.INSTANCE=new e,e}(el),rl=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=Oh.BooleanValue,n}return Je(e,t),e.prototype.value=function(t){return this.internalValue},e.prototype.isEqual=function(t){return t instanceof e&&this.internalValue===t.internalValue},e.prototype.compareTo=function(t){return t instanceof e?Dh(this,t):this.defaultCompareTo(t)},e.of=function(t){return t?e.TRUE:e.FALSE},e.TRUE=new e(!0),e.FALSE=new e(!1),e}(el),il=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=Oh.NumberValue,n}return Je(e,t),e.prototype.value=function(t){return this.internalValue},e.prototype.compareTo=function(t){return t instanceof e?(n=this.internalValue,r=t.internalValue,n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1):this.defaultCompareTo(t);var n,r},e}(el);function ol(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}var sl=function(t){function e(e){return t.call(this,e)||this}return Je(e,t),e.prototype.isEqual=function(t){return t instanceof e&&ol(this.internalValue,t.internalValue)},e}(il),al=function(t){function e(e){var n=t.call(this,e)||this;return n.internalValue=e,n}return Je(e,t),e.prototype.isEqual=function(t){return t instanceof e&&ol(this.internalValue,t.internalValue)},e.NAN=new e(NaN),e.POSITIVE_INFINITY=new e(1/0),e.NEGATIVE_INFINITY=new e(-1/0),e}(il),ul=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=Oh.StringValue,n}return Je(e,t),e.prototype.value=function(t){return this.internalValue},e.prototype.isEqual=function(t){return t instanceof e&&this.internalValue===t.internalValue},e.prototype.compareTo=function(t){return t instanceof e?Dh(this.internalValue,t.internalValue):this.defaultCompareTo(t)},e}(el),cl=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=Oh.TimestampValue,n}return Je(e,t),e.prototype.value=function(t){return!t||t.timestampsInSnapshots?this.internalValue:this.internalValue.toDate()},e.prototype.isEqual=function(t){return t instanceof e&&this.internalValue.isEqual(t.internalValue)},e.prototype.compareTo=function(t){return t instanceof e?this.internalValue._compareTo(t.internalValue):t instanceof hl?-1:this.defaultCompareTo(t)},e}(el),hl=function(t){function e(e,n){var r=t.call(this)||this;return r.localWriteTime=e,r.previousValue=n,r.typeOrder=Oh.TimestampValue,r}return Je(e,t),e.prototype.value=function(t){return t&&t.serverTimestampBehavior===Ph.Estimate?new cl(this.localWriteTime).value(t):t&&t.serverTimestampBehavior===Ph.Previous&&this.previousValue?this.previousValue.value(t):null},e.prototype.isEqual=function(t){return t instanceof e&&this.localWriteTime.isEqual(t.localWriteTime)},e.prototype.compareTo=function(t){return t instanceof e?this.localWriteTime._compareTo(t.localWriteTime):t instanceof cl?1:this.defaultCompareTo(t)},e.prototype.toString=function(){return"<ServerTimestamp localTime="+this.localWriteTime.toString()+">"},e}(el),ll=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=Oh.BlobValue,n}return Je(e,t),e.prototype.value=function(t){return this.internalValue},e.prototype.isEqual=function(t){return t instanceof e&&this.internalValue.isEqual(t.internalValue)},e.prototype.compareTo=function(t){return t instanceof e?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},e}(el),fl=function(t){function e(e,n){var r=t.call(this)||this;return r.databaseId=e,r.key=n,r.typeOrder=Oh.RefValue,r}return Je(e,t),e.prototype.value=function(t){return this.key},e.prototype.isEqual=function(t){return t instanceof e&&(this.key.isEqual(t.key)&&this.databaseId.isEqual(t.databaseId))},e.prototype.compareTo=function(t){if(t instanceof e){var n=this.databaseId.compareTo(t.databaseId);return 0!==n?n:Qh.comparator(this.key,t.key)}return this.defaultCompareTo(t)},e}(el),pl=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=Oh.GeoPointValue,n}return Je(e,t),e.prototype.value=function(t){return this.internalValue},e.prototype.isEqual=function(t){return t instanceof e&&this.internalValue.isEqual(t.internalValue)},e.prototype.compareTo=function(t){return t instanceof e?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},e}(el),dl=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=Oh.ObjectValue,n}return Je(e,t),e.prototype.value=function(t){var e={};return this.internalValue.inorderTraversal(function(n,r){e[n]=r.value(t)}),e},e.prototype.forEach=function(t){this.internalValue.inorderTraversal(t)},e.prototype.isEqual=function(t){if(t instanceof e){for(var n=this.internalValue.getIterator(),r=t.internalValue.getIterator();n.hasNext()&&r.hasNext();){var i=n.getNext(),o=r.getNext();if(i.key!==o.key||!i.value.isEqual(o.value))return!1}return!n.hasNext()&&!r.hasNext()}return!1},e.prototype.compareTo=function(t){if(t instanceof e){for(var n=this.internalValue.getIterator(),r=t.internalValue.getIterator();n.hasNext()&&r.hasNext();){var i=n.getNext(),o=r.getNext(),s=Dh(i.key,o.key)||i.value.compareTo(o.value);if(s)return s}return Dh(n.hasNext(),r.hasNext())}return this.defaultCompareTo(t)},e.prototype.set=function(t,n){if(Zc(!t.isEmpty(),"Cannot set field for empty path on ObjectValue"),1===t.length)return this.setChild(t.firstSegment(),n);var r=this.child(t.firstSegment());r instanceof e||(r=e.EMPTY);var i=r.set(t.popFirst(),n);return this.setChild(t.firstSegment(),i)},e.prototype.delete=function(t){if(Zc(!t.isEmpty(),"Cannot delete field for empty path on ObjectValue"),1===t.length)return new e(this.internalValue.remove(t.firstSegment()));var n=this.child(t.firstSegment());if(n instanceof e){var r=n.delete(t.popFirst());return new e(this.internalValue.insert(t.firstSegment(),r))}return this},e.prototype.contains=function(t){return void 0!==this.field(t)},e.prototype.field=function(t){Zc(!t.isEmpty(),"Can't get field of empty path");var n=this;return t.forEach(function(t){n=n instanceof e&&n.internalValue.get(t)||void 0}),n},e.prototype.toString=function(){return JSON.stringify(this.value())},e.prototype.child=function(t){return this.internalValue.get(t)||void 0},e.prototype.setChild=function(t,n){return new e(this.internalValue.insert(t,n))},e.EMPTY=new e(new Xh(Dh)),e}(el),yl=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=Oh.ArrayValue,n}return Je(e,t),e.prototype.value=function(t){return this.internalValue.map(function(e){return e.value(t)})},e.prototype.forEach=function(t){this.internalValue.forEach(t)},e.prototype.isEqual=function(t){if(t instanceof e){if(this.internalValue.length!==t.internalValue.length)return!1;for(var n=0;n<this.internalValue.length;n++)if(!this.internalValue[n].isEqual(t.internalValue[n]))return!1;return!0}return!1},e.prototype.compareTo=function(t){if(t instanceof e){for(var n=Math.min(this.internalValue.length,t.internalValue.length),r=0;r<n;r++){var i=this.internalValue[r].compareTo(t.internalValue[r]);if(i)return i}return Dh(this.internalValue.length,t.internalValue.length)}return this.defaultCompareTo(t)},e.prototype.toString=function(){return JSON.stringify(this.value())},e}(el),ml=Number,gl=ml.MIN_SAFE_INTEGER||-(Math.pow(2,53)-1),vl=ml.MAX_SAFE_INTEGER||Math.pow(2,53)-1,bl=ml.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function _l(t){return null===t||void 0===t}function wl(t){return bl(t)&&t<=vl&&t>=gl}var El,Tl=function(){function t(t,e,n,r,i,o){void 0===e&&(e=[]),void 0===n&&(n=[]),void 0===r&&(r=null),void 0===i&&(i=null),void 0===o&&(o=null),this.path=t,this.explicitOrderBy=e,this.filters=n,this.limit=r,this.startAt=i,this.endAt=o,this.memoizedCanonicalId=null,this.memoizedOrderBy=null,this.startAt&&this.assertValidBound(this.startAt),this.endAt&&this.assertValidBound(this.endAt)}return t.atPath=function(e){return new t(e)},Object.defineProperty(t.prototype,"orderBy",{get:function(){if(null===this.memoizedOrderBy){var t=this.getInequalityFilterField(),e=this.getFirstOrderByField();if(null!==t&&null===e)t.isKeyField()?this.memoizedOrderBy=[Ol]:this.memoizedOrderBy=[new kl(t),Ol];else{Zc(null===t||null!==e&&t.isEqual(e),"First orderBy should match inequality field."),this.memoizedOrderBy=[];for(var n=!1,r=0,i=this.explicitOrderBy;r<i.length;r++){var o=i[r];this.memoizedOrderBy.push(o),o.field.isKeyField()&&(n=!0)}if(!n){var s=this.explicitOrderBy.length>0?this.explicitOrderBy[this.explicitOrderBy.length-1].dir:Al.ASCENDING;this.memoizedOrderBy.push(s===Al.ASCENDING?Ol:Pl)}}}return this.memoizedOrderBy},enumerable:!0,configurable:!0}),t.prototype.addFilter=function(e){Zc(null==this.getInequalityFilterField()||!(e instanceof Cl)||!e.isInequality()||e.field.isEqual(this.getInequalityFilterField()),"Query must only have one inequality field."),Zc(!Qh.isDocumentKey(this.path),"No filtering allowed for document query");var n=this.filters.concat([e]);return new t(this.path,this.explicitOrderBy.slice(),n,this.limit,this.startAt,this.endAt)},t.prototype.addOrderBy=function(e){Zc(!Qh.isDocumentKey(this.path),"No ordering allowed for document query"),Zc(!this.startAt&&!this.endAt,"Bounds must be set after orderBy");var n=this.explicitOrderBy.concat([e]);return new t(this.path,n,this.filters.slice(),this.limit,this.startAt,this.endAt)},t.prototype.withLimit=function(e){return new t(this.path,this.explicitOrderBy.slice(),this.filters.slice(),e,this.startAt,this.endAt)},t.prototype.withStartAt=function(e){return new t(this.path,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,e,this.endAt)},t.prototype.withEndAt=function(e){return new t(this.path,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.startAt,e)},t.prototype.canonicalId=function(){if(null===this.memoizedCanonicalId){var t=this.path.canonicalString();t+="|f:";for(var e=0,n=this.filters;e<n.length;e++){t+=n[e].canonicalId(),t+=","}t+="|ob:";for(var r=0,i=this.orderBy;r<i.length;r++){t+=i[r].canonicalId(),t+=","}_l(this.limit)||(t+="|l:",t+=this.limit),this.startAt&&(t+="|lb:",t+=this.startAt.canonicalId()),this.endAt&&(t+="|ub:",t+=this.endAt.canonicalId()),this.memoizedCanonicalId=t}return this.memoizedCanonicalId},t.prototype.toString=function(){var t="Query("+this.path.canonicalString();return this.filters.length>0&&(t+=", filters: ["+this.filters.join(", ")+"]"),_l(this.limit)||(t+=", limit: "+this.limit),this.explicitOrderBy.length>0&&(t+=", orderBy: ["+this.explicitOrderBy.join(", ")+"]"),this.startAt&&(t+=", startAt: "+this.startAt.canonicalId()),this.endAt&&(t+=", endAt: "+this.endAt.canonicalId()),t+")"},t.prototype.isEqual=function(t){if(this.limit!==t.limit)return!1;if(this.orderBy.length!==t.orderBy.length)return!1;for(var e=0;e<this.orderBy.length;e++)if(!this.orderBy[e].isEqual(t.orderBy[e]))return!1;if(this.filters.length!==t.filters.length)return!1;for(e=0;e<this.filters.length;e++)if(!this.filters[e].isEqual(t.filters[e]))return!1;return!!this.path.isEqual(t.path)&&(!(null!==this.startAt?!this.startAt.isEqual(t.startAt):null!==t.startAt)&&(null!==this.endAt?this.endAt.isEqual(t.endAt):null===t.endAt))},t.prototype.docComparator=function(t,e){for(var n=!1,r=0,i=this.orderBy;r<i.length;r++){var o=i[r],s=o.compare(t,e);if(0!==s)return s;n=n||o.field.isKeyField()}return Zc(n,"orderBy used that doesn't compare on key field"),0},t.prototype.matches=function(t){return this.matchesAncestor(t)&&this.matchesOrderBy(t)&&this.matchesFilters(t)&&this.matchesBounds(t)},t.prototype.hasLimit=function(){return!_l(this.limit)},t.prototype.getFirstOrderByField=function(){return this.explicitOrderBy.length>0?this.explicitOrderBy[0].field:null},t.prototype.getInequalityFilterField=function(){for(var t=0,e=this.filters;t<e.length;t++){var n=e[t];if(n instanceof Cl&&n.isInequality())return n.field}return null},t.prototype.hasArrayContainsFilter=function(){return void 0!==this.filters.find(function(t){return t instanceof Cl&&t.op===Il.ARRAY_CONTAINS})},t.prototype.isDocumentQuery=function(){return Qh.isDocumentKey(this.path)&&0===this.filters.length},t.prototype.matchesAncestor=function(t){var e=t.key.path;return Qh.isDocumentKey(this.path)?this.path.isEqual(e):this.path.isPrefixOf(e)&&this.path.length===e.length-1},t.prototype.matchesOrderBy=function(t){for(var e=0,n=this.explicitOrderBy;e<n.length;e++){var r=n[e];if(!r.field.isKeyField()&&void 0===t.field(r.field))return!1}return!0},t.prototype.matchesFilters=function(t){for(var e=0,n=this.filters;e<n.length;e++){if(!n[e].matches(t))return!1}return!0},t.prototype.matchesBounds=function(t){return!(this.startAt&&!this.startAt.sortsBeforeDocument(this.orderBy,t))&&(!this.endAt||!this.endAt.sortsBeforeDocument(this.orderBy,t))},t.prototype.assertValidBound=function(t){Zc(t.position.length<=this.orderBy.length,"Bound is longer than orderBy")},t}(),Sl=function(){function t(){}return t.create=function(t,e,n){if(n.isEqual(nl.INSTANCE)){if(e!==Il.EQUAL)throw new rh(nh.INVALID_ARGUMENT,"Invalid query. You can only perform equals comparisons on null.");return new Nl(t)}if(n.isEqual(al.NAN)){if(e!==Il.EQUAL)throw new rh(nh.INVALID_ARGUMENT,"Invalid query. You can only perform equals comparisons on NaN.");return new Dl(t)}return new Cl(t,e,n)},t}(),Il=function(){function t(t){this.name=t}return t.fromString=function(e){switch(e){case"<":return t.LESS_THAN;case"<=":return t.LESS_THAN_OR_EQUAL;case"==":return t.EQUAL;case">=":return t.GREATER_THAN_OR_EQUAL;case">":return t.GREATER_THAN;case"array-contains":return t.ARRAY_CONTAINS;default:return $c("Unknown relation: "+e)}},t.prototype.toString=function(){return this.name},t.prototype.isEqual=function(t){return this.name===t.name},t.LESS_THAN=new t("<"),t.LESS_THAN_OR_EQUAL=new t("<="),t.EQUAL=new t("=="),t.GREATER_THAN=new t(">"),t.GREATER_THAN_OR_EQUAL=new t(">="),t.ARRAY_CONTAINS=new t("array-contains"),t}(),Cl=function(t){function e(e,n,r){var i=t.call(this)||this;return i.field=e,i.op=n,i.value=r,i}return Je(e,t),e.prototype.matches=function(t){if(this.field.isKeyField()){Zc(this.value instanceof fl,"Comparing on key, but filter value not a RefValue"),Zc(this.op!==Il.ARRAY_CONTAINS,"array-contains queries don't make sense on document keys.");var e=this.value,n=Qh.comparator(t.key,e.key);return this.matchesComparison(n)}var r=t.field(this.field);return void 0!==r&&this.matchesValue(r)},e.prototype.matchesValue=function(t){var e=this;return this.op===Il.ARRAY_CONTAINS?t instanceof yl&&void 0!==t.internalValue.find(function(t){return t.isEqual(e.value)}):this.value.typeOrder===t.typeOrder&&this.matchesComparison(t.compareTo(this.value))},e.prototype.matchesComparison=function(t){switch(this.op){case Il.LESS_THAN:return t<0;case Il.LESS_THAN_OR_EQUAL:return t<=0;case Il.EQUAL:return 0===t;case Il.GREATER_THAN:return t>0;case Il.GREATER_THAN_OR_EQUAL:return t>=0;default:return $c("Unknown relation op"+this.op)}},e.prototype.isInequality=function(){return this.op!==Il.EQUAL&&this.op!==Il.ARRAY_CONTAINS},e.prototype.canonicalId=function(){return this.field.canonicalString()+this.op.toString()+this.value.toString()},e.prototype.isEqual=function(t){return t instanceof e&&(this.op.isEqual(t.op)&&this.field.isEqual(t.field)&&this.value.isEqual(t.value))},e.prototype.toString=function(){return this.field.canonicalString()+" "+this.op+" "+this.value.value()},e}(Sl),Nl=function(t){function e(e){var n=t.call(this)||this;return n.field=e,n}return Je(e,t),e.prototype.matches=function(t){var e=t.field(this.field);return void 0!==e&&null===e.value()},e.prototype.canonicalId=function(){return this.field.canonicalString()+" IS null"},e.prototype.toString=function(){return this.field.canonicalString()+" IS null"},e.prototype.isEqual=function(t){return t instanceof e&&this.field.isEqual(t.field)},e}(Sl),Dl=function(t){function e(e){var n=t.call(this)||this;return n.field=e,n}return Je(e,t),e.prototype.matches=function(t){var e=t.field(this.field),n=e&&e.value();return"number"==typeof n&&isNaN(n)},e.prototype.canonicalId=function(){return this.field.canonicalString()+" IS NaN"},e.prototype.toString=function(){return this.field.canonicalString()+" IS NaN"},e.prototype.isEqual=function(t){return t instanceof e&&this.field.isEqual(t.field)},e}(Sl),Al=function(){function t(t){this.name=t}return t.prototype.toString=function(){return this.name},t.ASCENDING=new t("asc"),t.DESCENDING=new t("desc"),t}(),Rl=function(){function t(t,e){this.position=t,this.before=e}return t.prototype.canonicalId=function(){for(var t=this.before?"b:":"a:",e=0,n=this.position;e<n.length;e++){t+=n[e].toString()}return t},t.prototype.sortsBeforeDocument=function(t,e){Zc(this.position.length<=t.length,"Bound has more components than query's orderBy");for(var n=0,r=0;r<this.position.length;r++){var i=t[r],o=this.position[r];if(i.field.isKeyField())Zc(o instanceof fl,"Bound has a non-key value where the key path is being used."),n=Qh.comparator(o.key,e.key);else{var s=e.field(i.field);Zc(void 0!==s,"Field should exist since document matched the orderBy already."),n=o.compareTo(s)}if(i.dir===Al.DESCENDING&&(n*=-1),0!==n)break}return this.before?n<=0:n<0},t.prototype.isEqual=function(t){if(null===t)return!1;if(this.before!==t.before||this.position.length!==t.position.length)return!1;for(var e=0;e<this.position.length;e++){var n=this.position[e],r=t.position[e];return n.isEqual(r)}return!0},t}(),kl=function(){function t(t,e){this.field=t,void 0===e&&(e=Al.ASCENDING),this.dir=e,this.isKeyOrderBy=t.isKeyField()}return t.prototype.compare=function(t,e){var n=this.isKeyOrderBy?Gh.compareByKey(t,e):Gh.compareByField(this.field,t,e);switch(this.dir){case Al.ASCENDING:return n;case Al.DESCENDING:return-1*n;default:return $c("Unknown direction: "+this.dir)}},t.prototype.canonicalId=function(){return this.field.canonicalString()+this.dir.toString()},t.prototype.toString=function(){return this.field.canonicalString()+" ("+this.dir+")"},t.prototype.isEqual=function(t){return this.dir===t.dir&&this.field.isEqual(t.field)},t}(),Ol=new kl(Kh.keyField(),Al.ASCENDING),Pl=new kl(Kh.keyField(),Al.DESCENDING),Ll=function(){function t(t){this.timestamp=t}return t.fromMicroseconds=function(e){var n=Math.floor(e/1e6);return new t(new Fh(n,e%1e6*1e3))},t.fromTimestamp=function(e){return new t(e)},t.forDeletedDoc=function(){return t.MIN},t.prototype.compareTo=function(t){return this.timestamp._compareTo(t.timestamp)},t.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},t.prototype.toMicroseconds=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},t.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},t.prototype.toTimestamp=function(){return this.timestamp},t.MIN=new t(new Fh(0,0)),t}();!function(t){t[t.Listen=0]="Listen",t[t.ExistenceFilterMismatch=1]="ExistenceFilterMismatch",t[t.LimboResolution=2]="LimboResolution"}(El||(El={}));var Ml,xl=function(){function t(t,e,n,r,i,o){void 0===i&&(i=Ll.MIN),void 0===o&&(o=eh()),this.query=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.resumeToken=o}return t.prototype.copy=function(e){return new t(this.query,this.targetId,this.purpose,void 0===e.sequenceNumber?this.sequenceNumber:e.sequenceNumber,void 0===e.snapshotVersion?this.snapshotVersion:e.snapshotVersion,void 0===e.resumeToken?this.resumeToken:e.resumeToken)},t.prototype.isEqual=function(t){return this.targetId===t.targetId&&this.purpose===t.purpose&&this.sequenceNumber===t.sequenceNumber&&this.snapshotVersion.isEqual(t.snapshotVersion)&&this.resumeToken===t.resumeToken&&this.query.isEqual(t.query)},t}(),Fl=function(){function t(t){this.comparator=t,this.data=new Xh(this.comparator)}return t.fromMapKeys=function(e){var n=new t(e.comparator);return e.forEach(function(t){n=n.add(t)}),n},t.prototype.has=function(t){return null!==this.data.get(t)},t.prototype.first=function(){return this.data.minKey()},t.prototype.last=function(){return this.data.maxKey()},Object.defineProperty(t.prototype,"size",{get:function(){return this.data.size},enumerable:!0,configurable:!0}),t.prototype.indexOf=function(t){return this.data.indexOf(t)},t.prototype.forEach=function(t){this.data.inorderTraversal(function(e,n){return t(e),!1})},t.prototype.forEachInRange=function(t,e){for(var n=this.data.getIteratorFrom(t[0]);n.hasNext();){var r=n.getNext();if(this.comparator(r.key,t[1])>=0)return;e(r.key)}},t.prototype.forEachWhile=function(t,e){var n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();){if(!t(n.getNext().key))return}},t.prototype.firstAfterOrEqual=function(t){var e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null},t.prototype.getIterator=function(){return new Ul(this.data.getIterator())},t.prototype.getIteratorFrom=function(t){return new Ul(this.data.getIteratorFrom(t))},t.prototype.add=function(t){return this.copy(this.data.remove(t).insert(t,!0))},t.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},t.prototype.isEmpty=function(){return this.data.isEmpty()},t.prototype.unionWith=function(t){var e=this;return t.forEach(function(t){e=e.add(t)}),e},t.prototype.isEqual=function(e){if(!(e instanceof t))return!1;if(this.size!==e.size)return!1;for(var n=this.data.getIterator(),r=e.data.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(0!==this.comparator(i,o))return!1}return!0},t.prototype.toArray=function(){var t=[];return this.forEach(function(e){t.push(e)}),t},t.prototype.toString=function(){var t=[];return this.forEach(function(e){return t.push(e)}),"SortedSet("+t.toString()+")"},t.prototype.copy=function(e){var n=new t(this.comparator);return n.data=e,n},t}(),Ul=function(){function t(t){this.iter=t}return t.prototype.getNext=function(){return this.iter.getNext().key},t.prototype.hasNext=function(){return this.iter.hasNext()},t}(),ql=function(){function t(t){this.fields=t}return t.fromSet=function(e){return new t(e)},t.fromArray=function(e){var n=new Fl(Kh.comparator);return e.forEach(function(t){return n=n.add(t)}),new t(n)},t.prototype.covers=function(t){var e=!1;return this.fields.forEach(function(n){n.isPrefixOf(t)&&(e=!0)}),e},t.prototype.isEqual=function(t){return this.fields.isEqual(t.fields)},t}(),Bl=function(){function t(t,e){this.field=t,this.transform=e}return t.prototype.isEqual=function(t){return this.field.isEqual(t.field)&&this.transform.isEqual(t.transform)},t}(),Vl=function(){return function(t,e){this.version=t,this.transformResults=e}}();!function(t){t[t.Set=0]="Set",t[t.Patch=1]="Patch",t[t.Transform=2]="Transform",t[t.Delete=3]="Delete"}(Ml||(Ml={}));var Wl=function(){function t(t,e){this.updateTime=t,this.exists=e,Zc(void 0===t||void 0===e,'Precondition can specify "exists" or "updateTime" but not both')}return t.exists=function(e){return new t(void 0,e)},t.updateTime=function(e){return new t(e)},Object.defineProperty(t.prototype,"isNone",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!0,configurable:!0}),t.prototype.isValidFor=function(t){return void 0!==this.updateTime?t instanceof Gh&&t.version.isEqual(this.updateTime):void 0!==this.exists?this.exists===t instanceof Gh:(Zc(this.isNone,"Precondition should be empty"),!0)},t.prototype.isEqual=function(t){return e=this.updateTime,n=t.updateTime,(null!==e&&void 0!==e?!(!n||!e.isEqual(n)):e===n)&&this.exists===t.exists;var e,n},t.NONE=new t,t}(),jl=function(){function t(){}return t.prototype.verifyKeyMatches=function(t){null!=t&&Zc(t.key.isEqual(this.key),"Can only apply a mutation to a document with the same key")},t.getPostMutationVersion=function(t){return t instanceof Gh?t.version:Ll.MIN},t}(),Kl=function(t){function e(e,n,r){var i=t.call(this)||this;return i.key=e,i.value=n,i.precondition=r,i.type=Ml.Set,i}return Je(e,t),e.prototype.applyToRemoteDocument=function(t,e){this.verifyKeyMatches(t),Zc(null==e.transformResults,"Transform results received by SetMutation.");var n=e.version;return new Gh(this.key,n,this.value,{hasCommittedMutations:!0})},e.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=jl.getPostMutationVersion(t);return new Gh(this.key,r,this.value,{hasLocalMutations:!0})},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.value.isEqual(t.value)&&this.precondition.isEqual(t.precondition)},e}(jl),Ql=function(t){function e(e,n,r,i){var o=t.call(this)||this;return o.key=e,o.data=n,o.fieldMask=r,o.precondition=i,o.type=Ml.Patch,o}return Je(e,t),e.prototype.applyToRemoteDocument=function(t,e){if(this.verifyKeyMatches(t),Zc(null==e.transformResults,"Transform results received by PatchMutation."),!this.precondition.isValidFor(t))return new Yh(this.key,e.version);var n=this.patchDocument(t);return new Gh(this.key,e.version,n,{hasCommittedMutations:!0})},e.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=jl.getPostMutationVersion(t),i=this.patchDocument(t);return new Gh(this.key,r,i,{hasLocalMutations:!0})},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.fieldMask.isEqual(t.fieldMask)&&this.precondition.isEqual(t.precondition)},e.prototype.patchDocument=function(t){var e;return e=t instanceof Gh?t.data:dl.EMPTY,this.patchObject(e)},e.prototype.patchObject=function(t){var e=this;return this.fieldMask.fields.forEach(function(n){if(!n.isEmpty()){var r=e.data.field(n);t=void 0!==r?t.set(n,r):t.delete(n)}}),t},e}(jl),Hl=function(t){function e(e,n){var r=t.call(this)||this;return r.key=e,r.fieldTransforms=n,r.type=Ml.Transform,r.precondition=Wl.exists(!0),r}return Je(e,t),e.prototype.applyToRemoteDocument=function(t,e){if(this.verifyKeyMatches(t),Zc(null!=e.transformResults,"Transform results missing for TransformMutation."),!this.precondition.isValidFor(t))return new Yh(this.key,e.version);var n=this.requireDocument(t),r=this.serverTransformResults(t,e.transformResults),i=e.version,o=this.transformObject(n.data,r);return new Gh(this.key,i,o,{hasCommittedMutations:!0})},e.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=this.requireDocument(t),i=this.localTransformResults(n,e),o=this.transformObject(r.data,i);return new Gh(this.key,r.version,o,{hasLocalMutations:!0})},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&Ah(this.fieldTransforms,t.fieldTransforms)&&this.precondition.isEqual(t.precondition)},e.prototype.requireDocument=function(t){Zc(t instanceof Gh,"Unknown MaybeDocument type "+t);var e=t;return Zc(e.key.isEqual(this.key),"Can only transform a document with the same key"),e},e.prototype.serverTransformResults=function(t,e){var n=[];Zc(this.fieldTransforms.length===e.length,"server transform result count ("+e.length+") should match field transform count ("+this.fieldTransforms.length+")");for(var r=0;r<e.length;r++){var i=this.fieldTransforms[r],o=i.transform,s=null;t instanceof Gh&&(s=t.field(i.field)||null),n.push(o.applyToRemoteDocument(s,e[r]))}return n},e.prototype.localTransformResults=function(t,e){for(var n=[],r=0,i=this.fieldTransforms;r<i.length;r++){var o=i[r],s=o.transform,a=null;e instanceof Gh&&(a=e.field(o.field)||null),n.push(s.applyToLocalView(a,t))}return n},e.prototype.transformObject=function(t,e){Zc(e.length===this.fieldTransforms.length,"TransformResults length mismatch.");for(var n=0;n<this.fieldTransforms.length;n++){var r=this.fieldTransforms[n].field;t=t.set(r,e[n])}return t},e}(jl),Gl=function(t){function e(e,n){var r=t.call(this)||this;return r.key=e,r.precondition=n,r.type=Ml.Delete,r}return Je(e,t),e.prototype.applyToRemoteDocument=function(t,e){return this.verifyKeyMatches(t),Zc(null==e.transformResults,"Transform results received by DeleteMutation."),new zh(this.key,e.version,{hasCommittedMutations:!0})},e.prototype.applyToLocalView=function(t,e,n){return this.verifyKeyMatches(t),this.precondition.isValidFor(t)?(t&&Zc(t.key.isEqual(this.key),"Can only apply mutation to document with same key"),new zh(this.key,Ll.forDeletedDoc())):t},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.precondition.isEqual(t.precondition)},e}(jl),zl=function(){function t(){}return t.prototype.applyToLocalView=function(t,e){return new hl(e,t)},t.prototype.applyToRemoteDocument=function(t,e){return e},t.prototype.isEqual=function(e){return e instanceof t},t.instance=new t,t}(),Yl=function(){function t(t){this.elements=t}return t.prototype.applyToLocalView=function(t,e){return this.apply(t)},t.prototype.applyToRemoteDocument=function(t,e){return this.apply(t)},t.prototype.apply=function(t){for(var e=Jl(t),n=function(t){e.find(function(e){return e.isEqual(t)})||e.push(t)},r=0,i=this.elements;r<i.length;r++){n(i[r])}return new yl(e)},t.prototype.isEqual=function(e){return e instanceof t&&Ah(e.elements,this.elements)},t}(),Xl=function(){function t(t){this.elements=t}return t.prototype.applyToLocalView=function(t,e){return this.apply(t)},t.prototype.applyToRemoteDocument=function(t,e){return this.apply(t)},t.prototype.apply=function(t){for(var e=Jl(t),n=function(t){e=e.filter(function(e){return!e.isEqual(t)})},r=0,i=this.elements;r<i.length;r++){n(i[r])}return new yl(e)},t.prototype.isEqual=function(e){return e instanceof t&&Ah(e.elements,this.elements)},t}();function Jl(t){return t instanceof yl?t.internalValue.slice():[]}var $l,Zl=function(){function t(t){this.count=t}return t.prototype.isEqual=function(t){return t&&t.count===this.count},t}();function tf(t){switch(t){case nh.OK:return $c("Treated status OK as error");case nh.CANCELLED:case nh.UNKNOWN:case nh.DEADLINE_EXCEEDED:case nh.RESOURCE_EXHAUSTED:case nh.INTERNAL:case nh.UNAVAILABLE:case nh.UNAUTHENTICATED:return!1;case nh.INVALID_ARGUMENT:case nh.NOT_FOUND:case nh.ALREADY_EXISTS:case nh.PERMISSION_DENIED:case nh.FAILED_PRECONDITION:case nh.ABORTED:case nh.OUT_OF_RANGE:case nh.UNIMPLEMENTED:case nh.DATA_LOSS:return!0;default:return $c("Unknown status code: "+t)}}function ef(t){if(void 0===t)return Xc("GRPC error has no .code"),nh.UNKNOWN;switch(t){case $l.OK:return nh.OK;case $l.CANCELLED:return nh.CANCELLED;case $l.UNKNOWN:return nh.UNKNOWN;case $l.DEADLINE_EXCEEDED:return nh.DEADLINE_EXCEEDED;case $l.RESOURCE_EXHAUSTED:return nh.RESOURCE_EXHAUSTED;case $l.INTERNAL:return nh.INTERNAL;case $l.UNAVAILABLE:return nh.UNAVAILABLE;case $l.UNAUTHENTICATED:return nh.UNAUTHENTICATED;case $l.INVALID_ARGUMENT:return nh.INVALID_ARGUMENT;case $l.NOT_FOUND:return nh.NOT_FOUND;case $l.ALREADY_EXISTS:return nh.ALREADY_EXISTS;case $l.PERMISSION_DENIED:return nh.PERMISSION_DENIED;case $l.FAILED_PRECONDITION:return nh.FAILED_PRECONDITION;case $l.ABORTED:return nh.ABORTED;case $l.OUT_OF_RANGE:return nh.OUT_OF_RANGE;case $l.UNIMPLEMENTED:return nh.UNIMPLEMENTED;case $l.DATA_LOSS:return nh.DATA_LOSS;default:return $c("Unknown status code: "+t)}}!function(t){t[t.OK=0]="OK",t[t.CANCELLED=1]="CANCELLED",t[t.UNKNOWN=2]="UNKNOWN",t[t.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",t[t.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",t[t.NOT_FOUND=5]="NOT_FOUND",t[t.ALREADY_EXISTS=6]="ALREADY_EXISTS",t[t.PERMISSION_DENIED=7]="PERMISSION_DENIED",t[t.UNAUTHENTICATED=16]="UNAUTHENTICATED",t[t.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",t[t.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",t[t.ABORTED=10]="ABORTED",t[t.OUT_OF_RANGE=11]="OUT_OF_RANGE",t[t.UNIMPLEMENTED=12]="UNIMPLEMENTED",t[t.INTERNAL=13]="INTERNAL",t[t.UNAVAILABLE=14]="UNAVAILABLE",t[t.DATA_LOSS=15]="DATA_LOSS"}($l||($l={}));var nf=new Xh(Qh.comparator);function rf(){return nf}function of(){return rf()}var sf=new Xh(Qh.comparator);function af(){return sf}var uf=new Xh(Qh.comparator);function cf(){return uf}var hf=new Fl(Qh.comparator);function lf(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=hf,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var ff=new Fl(Dh);function pf(){return ff}var df,yf,mf=function(){function t(t){this.comparator=t?function(e,n){return t(e,n)||Qh.comparator(e.key,n.key)}:function(t,e){return Qh.comparator(t.key,e.key)},this.keyedMap=af(),this.sortedSet=new Xh(this.comparator)}return t.emptySet=function(e){return new t(e.comparator)},t.prototype.has=function(t){return null!=this.keyedMap.get(t)},t.prototype.get=function(t){return this.keyedMap.get(t)},t.prototype.first=function(){return this.sortedSet.minKey()},t.prototype.last=function(){return this.sortedSet.maxKey()},t.prototype.isEmpty=function(){return this.sortedSet.isEmpty()},t.prototype.indexOf=function(t){var e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1},Object.defineProperty(t.prototype,"size",{get:function(){return this.sortedSet.size},enumerable:!0,configurable:!0}),t.prototype.forEach=function(t){this.sortedSet.inorderTraversal(function(e,n){return t(e),!1})},t.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))},t.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this},t.prototype.isEqual=function(e){if(!(e instanceof t))return!1;if(this.size!==e.size)return!1;for(var n=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(!i.isEqual(o))return!1}return!0},t.prototype.toString=function(){var t=[];return this.forEach(function(e){t.push(e.toString())}),0===t.length?"DocumentSet ()":"DocumentSet (\n  "+t.join("  \n")+"\n)"},t.prototype.copy=function(e,n){var r=new t;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=n,r},t}();!function(t){t[t.Added=0]="Added",t[t.Removed=1]="Removed",t[t.Modified=2]="Modified",t[t.Metadata=3]="Metadata"}(df||(df={})),function(t){t[t.Local=0]="Local",t[t.Synced=1]="Synced"}(yf||(yf={}));var gf,vf=function(){function t(){this.changeMap=new Xh(Qh.comparator)}return t.prototype.track=function(t){var e=t.doc.key,n=this.changeMap.get(e);n?t.type!==df.Added&&n.type===df.Metadata?this.changeMap=this.changeMap.insert(e,t):t.type===df.Metadata&&n.type!==df.Removed?this.changeMap=this.changeMap.insert(e,{type:n.type,doc:t.doc}):t.type===df.Modified&&n.type===df.Modified?this.changeMap=this.changeMap.insert(e,{type:df.Modified,doc:t.doc}):t.type===df.Modified&&n.type===df.Added?this.changeMap=this.changeMap.insert(e,{type:df.Added,doc:t.doc}):t.type===df.Removed&&n.type===df.Added?this.changeMap=this.changeMap.remove(e):t.type===df.Removed&&n.type===df.Modified?this.changeMap=this.changeMap.insert(e,{type:df.Removed,doc:n.doc}):t.type===df.Added&&n.type===df.Removed?this.changeMap=this.changeMap.insert(e,{type:df.Modified,doc:t.doc}):$c("unsupported combination of changes: "+JSON.stringify(t)+" after "+JSON.stringify(n)):this.changeMap=this.changeMap.insert(e,t)},t.prototype.getChanges=function(){var t=[];return this.changeMap.inorderTraversal(function(e,n){t.push(n)}),t},t}(),bf=function(){function t(t,e,n,r,i,o,s,a){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=s,this.excludesMetadataChanges=a}return t.fromInitialDocuments=function(e,n,r,i){var o=[];return n.forEach(function(t){o.push({type:df.Added,doc:t})}),new t(e,n,mf.emptySet(n),o,r,i,!0,!1)},Object.defineProperty(t.prototype,"hasPendingWrites",{get:function(){return!this.mutatedKeys.isEmpty()},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&this.query.isEqual(t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;var e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(e[r].type!==n[r].type||!e[r].doc.isEqual(n[r].doc))return!1;return!0},t}(),_f=function(){function t(t,e,n,r,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}return t.createSynthesizedRemoteEventForCurrentChange=function(e,n){var r,i=((r={})[e]=wf.createSynthesizedTargetChangeForCurrentChange(e,n),r);return new t(Ll.MIN,i,pf(),rf(),lf())},t}(),wf=function(){function t(t,e,n,r,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}return t.createSynthesizedTargetChangeForCurrentChange=function(e,n){return new t(eh(),n,lf(),lf(),lf())},t}(),Ef=function(){return function(t,e,n,r){this.updatedTargetIds=t,this.removedTargetIds=e,this.key=n,this.newDoc=r}}(),Tf=function(){return function(t,e){this.targetId=t,this.existenceFilter=e}}();!function(t){t[t.NoChange=0]="NoChange",t[t.Added=1]="Added",t[t.Removed=2]="Removed",t[t.Current=3]="Current",t[t.Reset=4]="Reset"}(gf||(gf={}));var Sf=function(){return function(t,e,n,r){void 0===n&&(n=eh()),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r}}(),If=function(){function t(){this.pendingResponses=0,this.documentChanges=Df(),this._resumeToken=eh(),this._current=!1,this._hasPendingChanges=!0}return Object.defineProperty(t.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"resumeToken",{get:function(){return this._resumeToken},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isPending",{get:function(){return 0!==this.pendingResponses},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPendingChanges",{get:function(){return this._hasPendingChanges},enumerable:!0,configurable:!0}),t.prototype.updateResumeToken=function(t){t.length>0&&(this._hasPendingChanges=!0,this._resumeToken=t)},t.prototype.toTargetChange=function(){var t=lf(),e=lf(),n=lf();return this.documentChanges.forEach(function(r,i){switch(i){case df.Added:t=t.add(r);break;case df.Modified:e=e.add(r);break;case df.Removed:n=n.add(r);break;default:$c("Encountered invalid change type: "+i)}}),new wf(this._resumeToken,this._current,t,e,n)},t.prototype.clearPendingChanges=function(){this._hasPendingChanges=!1,this.documentChanges=Df()},t.prototype.addDocumentChange=function(t,e){this._hasPendingChanges=!0,this.documentChanges=this.documentChanges.insert(t,e)},t.prototype.removeDocumentChange=function(t){this._hasPendingChanges=!0,this.documentChanges=this.documentChanges.remove(t)},t.prototype.recordPendingTargetRequest=function(){this.pendingResponses+=1},t.prototype.recordTargetResponse=function(){this.pendingResponses-=1},t.prototype.markCurrent=function(){this._hasPendingChanges=!0,this._current=!0},t}(),Cf=function(){function t(t){this.metadataProvider=t,this.targetStates={},this.pendingDocumentUpdates=rf(),this.pendingDocumentTargetMapping=Nf(),this.pendingTargetResets=new Fl(Dh)}return t.prototype.handleDocumentChange=function(t){for(var e=0,n=t.updatedTargetIds;e<n.length;e++){var r=n[e];t.newDoc instanceof Gh?this.addDocumentToTarget(r,t.newDoc):t.newDoc instanceof zh&&this.removeDocumentFromTarget(r,t.key,t.newDoc)}for(var i=0,o=t.removedTargetIds;i<o.length;i++){r=o[i];this.removeDocumentFromTarget(r,t.key,t.newDoc)}},t.prototype.handleTargetChange=function(t){var e=this;this.forEachTarget(t,function(n){var r=e.ensureTargetState(n);switch(t.state){case gf.NoChange:e.isActiveTarget(n)&&r.updateResumeToken(t.resumeToken);break;case gf.Added:r.recordTargetResponse(),r.isPending||r.clearPendingChanges(),r.updateResumeToken(t.resumeToken);break;case gf.Removed:r.recordTargetResponse(),r.isPending||e.removeTarget(n),Zc(!t.cause,"WatchChangeAggregator does not handle errored targets");break;case gf.Current:e.isActiveTarget(n)&&(r.markCurrent(),r.updateResumeToken(t.resumeToken));break;case gf.Reset:e.isActiveTarget(n)&&(e.resetTarget(n),r.updateResumeToken(t.resumeToken));break;default:$c("Unknown target watch change state: "+t.state)}})},t.prototype.forEachTarget=function(t,e){t.targetIds.length>0?t.targetIds.forEach(e):ah(this.targetStates,e)},t.prototype.handleExistenceFilter=function(t){var e=t.targetId,n=t.existenceFilter.count,r=this.queryDataForActiveTarget(e);if(r){var i=r.query;if(i.isDocumentQuery())if(0===n){var o=new Qh(i.path);this.removeDocumentFromTarget(e,o,new zh(o,Ll.forDeletedDoc()))}else Zc(1===n,"Single document existence filter with count: "+n);else this.getCurrentDocumentCountForTarget(e)!==n&&(this.resetTarget(e),this.pendingTargetResets=this.pendingTargetResets.add(e))}},t.prototype.createRemoteEvent=function(t){var e=this,n={};ah(this.targetStates,function(r,i){var o=e.queryDataForActiveTarget(r);if(o){if(i.current&&o.query.isDocumentQuery()){var s=new Qh(o.query.path);null!==e.pendingDocumentUpdates.get(s)||e.targetContainsDocument(r,s)||e.removeDocumentFromTarget(r,s,new zh(s,t))}i.hasPendingChanges&&(n[r]=i.toTargetChange(),i.clearPendingChanges())}});var r=lf();this.pendingDocumentTargetMapping.forEach(function(t,n){var i=!0;n.forEachWhile(function(t){var n=e.queryDataForActiveTarget(t);return!n||n.purpose===El.LimboResolution||(i=!1,!1)}),i&&(r=r.add(t))});var i=new _f(t,n,this.pendingTargetResets,this.pendingDocumentUpdates,r);return this.pendingDocumentUpdates=rf(),this.pendingDocumentTargetMapping=Nf(),this.pendingTargetResets=new Fl(Dh),i},t.prototype.addDocumentToTarget=function(t,e){if(this.isActiveTarget(t)){var n=this.targetContainsDocument(t,e.key)?df.Modified:df.Added;this.ensureTargetState(t).addDocumentChange(e.key,n),this.pendingDocumentUpdates=this.pendingDocumentUpdates.insert(e.key,e),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(e.key,this.ensureDocumentTargetMapping(e.key).add(t))}},t.prototype.removeDocumentFromTarget=function(t,e,n){if(this.isActiveTarget(t)){var r=this.ensureTargetState(t);this.targetContainsDocument(t,e)?r.addDocumentChange(e,df.Removed):r.removeDocumentChange(e),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(e,this.ensureDocumentTargetMapping(e).delete(t)),n&&(this.pendingDocumentUpdates=this.pendingDocumentUpdates.insert(e,n))}},t.prototype.removeTarget=function(t){delete this.targetStates[t]},t.prototype.getCurrentDocumentCountForTarget=function(t){var e=this.ensureTargetState(t).toTargetChange();return this.metadataProvider.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size},t.prototype.recordPendingTargetRequest=function(t){this.ensureTargetState(t).recordPendingTargetRequest()},t.prototype.ensureTargetState=function(t){return this.targetStates[t]||(this.targetStates[t]=new If),this.targetStates[t]},t.prototype.ensureDocumentTargetMapping=function(t){var e=this.pendingDocumentTargetMapping.get(t);return e||(e=new Fl(Dh),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(t,e)),e},t.prototype.isActiveTarget=function(t){return null!==this.queryDataForActiveTarget(t)},t.prototype.queryDataForActiveTarget=function(t){var e=this.targetStates[t];return e&&e.isPending?null:this.metadataProvider.getQueryDataForTarget(t)},t.prototype.resetTarget=function(t){var e=this;Zc(!this.targetStates[t].isPending,"Should only reset active targets"),this.targetStates[t]=new If,this.metadataProvider.getRemoteKeysForTarget(t).forEach(function(n){e.removeDocumentFromTarget(t,n,null)})},t.prototype.targetContainsDocument=function(t,e){return this.metadataProvider.getRemoteKeysForTarget(t).has(e)},t}();function Nf(){return new Xh(Qh.comparator)}function Df(){return new Xh(Qh.comparator)}var Af,Rf,kf=((Af={})[Al.ASCENDING.name]="ASCENDING",Af[Al.DESCENDING.name]="DESCENDING",Af),Of=((Rf={})[Il.LESS_THAN.name]="LESS_THAN",Rf[Il.LESS_THAN_OR_EQUAL.name]="LESS_THAN_OR_EQUAL",Rf[Il.GREATER_THAN.name]="GREATER_THAN",Rf[Il.GREATER_THAN_OR_EQUAL.name]="GREATER_THAN_OR_EQUAL",Rf[Il.EQUAL.name]="EQUAL",Rf[Il.ARRAY_CONTAINS.name]="ARRAY_CONTAINS",Rf),Pf=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Lf(t,e){Zc(!_l(t),e+" is missing")}function Mf(t){return"number"==typeof t?t:"string"==typeof t?Number(t):$c("can't parse "+t)}var xf=function(){function t(t,e){this.databaseId=t,this.options=e}return t.prototype.emptyByteString=function(){return this.options.useProto3Json?"":new Uint8Array(0)},t.prototype.unsafeCastProtoByteString=function(t){return t},t.prototype.fromRpcStatus=function(t){var e=void 0===t.code?nh.UNKNOWN:ef(t.code);return new rh(e,t.message||"")},t.prototype.toInt32Value=function(t){return _l(t)?void 0:{value:t}},t.prototype.fromInt32Value=function(t){var e;return _l(e="object"==typeof t?t.value:t)?null:e},t.prototype.toTimestamp=function(t){return{seconds:t.seconds,nanos:t.nanoseconds}},t.prototype.fromTimestamp=function(t){if("string"==typeof t)return this.fromIso8601String(t);Zc(!!t,"Cannot deserialize null or undefined timestamp.");var e=Mf(t.seconds||"0"),n=t.nanos||0;return new Fh(e,n)},t.prototype.fromIso8601String=function(t){var e=0,n=Pf.exec(t);if(Zc(!!n,"invalid timestamp: "+t),n[1]){var r=n[1];r=(r+"000000000").substr(0,9),e=Number(r)}var i=new Date(t),o=Math.floor(i.getTime()/1e3);return new Fh(o,e)},t.prototype.toBytes=function(t){return this.options.useProto3Json?t.toBase64():this.unsafeCastProtoByteString(t.toUint8Array())},t.prototype.fromBlob=function(t){return"string"==typeof t?(Zc(this.options.useProto3Json,"Expected bytes to be passed in as Uint8Array, but got a string instead."),Lh.fromBase64String(t)):(Zc(!this.options.useProto3Json,"Expected bytes to be passed in as string, but got something else instead."),Lh.fromUint8Array(t))},t.prototype.toVersion=function(t){return this.toTimestamp(t.toTimestamp())},t.prototype.fromVersion=function(t){return Zc(!!t,"Trying to deserialize version that isn't set"),Ll.fromTimestamp(this.fromTimestamp(t))},t.prototype.toResourceName=function(t,e){return this.fullyQualifiedPrefixPath(t).child("documents").child(e).canonicalString()},t.prototype.fromResourceName=function(t){var e=Wh.fromString(t);return Zc(this.isValidResourceName(e),"Tried to deserialize invalid key "+e.toString()),e},t.prototype.toName=function(t){return this.toResourceName(this.databaseId,t.path)},t.prototype.fromName=function(t){var e=this.fromResourceName(t);return Zc(e.get(1)===this.databaseId.projectId,"Tried to deserialize key from different project: "+e.get(1)+" vs "+this.databaseId.projectId),Zc(!e.get(3)&&!this.databaseId.database||e.get(3)===this.databaseId.database,"Tried to deserialize key from different database: "+e.get(3)+" vs "+this.databaseId.database),new Qh(this.extractLocalPathFromResourceName(e))},t.prototype.toQueryPath=function(t){return this.toResourceName(this.databaseId,t)},t.prototype.fromQueryPath=function(t){var e=this.fromResourceName(t);return 4===e.length?Wh.EMPTY_PATH:this.extractLocalPathFromResourceName(e)},Object.defineProperty(t.prototype,"encodedDatabaseId",{get:function(){return new Wh(["projects",this.databaseId.projectId,"databases",this.databaseId.database]).canonicalString()},enumerable:!0,configurable:!0}),t.prototype.fullyQualifiedPrefixPath=function(t){return new Wh(["projects",t.projectId,"databases",t.database])},t.prototype.extractLocalPathFromResourceName=function(t){return Zc(t.length>4&&"documents"===t.get(4),"tried to deserialize invalid key "+t.toString()),t.popFirst(5)},t.prototype.isValidResourceName=function(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)},t.prototype.toValue=function(t){if(t instanceof nl)return{nullValue:"NULL_VALUE"};if(t instanceof rl)return{booleanValue:t.value()};if(t instanceof sl)return{integerValue:""+t.value()};if(t instanceof al){var e=t.value();if(this.options.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:t.value()}}return t instanceof ul?{stringValue:t.value()}:t instanceof dl?{mapValue:this.toMapValue(t)}:t instanceof yl?{arrayValue:this.toArrayValue(t)}:t instanceof cl?{timestampValue:this.toTimestamp(t.internalValue)}:t instanceof pl?{geoPointValue:{latitude:t.value().latitude,longitude:t.value().longitude}}:t instanceof ll?{bytesValue:this.toBytes(t.value())}:t instanceof fl?{referenceValue:this.toResourceName(t.databaseId,t.key.path)}:$c("Unknown FieldValue "+JSON.stringify(t))},t.prototype.fromValue=function(t){var e=this,n=t.value_type;if(Ff(t,n,"nullValue"))return nl.INSTANCE;if(Ff(t,n,"booleanValue"))return rl.of(t.booleanValue);if(Ff(t,n,"integerValue"))return new sl(Mf(t.integerValue));if(Ff(t,n,"doubleValue")){if(this.options.useProto3Json){if("NaN"===t.doubleValue)return al.NAN;if("Infinity"===t.doubleValue)return al.POSITIVE_INFINITY;if("-Infinity"===t.doubleValue)return al.NEGATIVE_INFINITY}return new al(t.doubleValue)}if(Ff(t,n,"stringValue"))return new ul(t.stringValue);if(Ff(t,n,"mapValue"))return this.fromFields(t.mapValue.fields||{});if(Ff(t,n,"arrayValue")){Lf(t.arrayValue,"arrayValue");var r=t.arrayValue.values||[];return new yl(r.map(function(t){return e.fromValue(t)}))}if(Ff(t,n,"timestampValue"))return Lf(t.timestampValue,"timestampValue"),new cl(this.fromTimestamp(t.timestampValue));if(Ff(t,n,"geoPointValue")){Lf(t.geoPointValue,"geoPointValue");var i=t.geoPointValue.latitude||0,o=t.geoPointValue.longitude||0;return new pl(new xh(i,o))}if(Ff(t,n,"bytesValue")){Lf(t.bytesValue,"bytesValue");var s=this.fromBlob(t.bytesValue);return new ll(s)}if(Ff(t,n,"referenceValue")){Lf(t.referenceValue,"referenceValue");var a=this.fromResourceName(t.referenceValue),u=new Bh(a.get(1),a.get(3)),c=new Qh(this.extractLocalPathFromResourceName(a));return new fl(u,c)}return $c("Unknown Value proto "+JSON.stringify(t))},t.prototype.toMutationDocument=function(t,e){return{name:this.toName(t),fields:this.toFields(e)}},t.prototype.toDocument=function(t){return Zc(!t.hasLocalMutations,"Can't serialize documents with mutations."),{name:this.toName(t.key),fields:this.toFields(t.data),updateTime:this.toTimestamp(t.version.toTimestamp())}},t.prototype.fromDocument=function(t,e){return new Gh(this.fromName(t.name),this.fromVersion(t.updateTime),this.fromFields(t.fields||{}),{hasCommittedMutations:!!e})},t.prototype.toFields=function(t){var e=this,n={};return t.forEach(function(t,r){n[t]=e.toValue(r)}),n},t.prototype.fromFields=function(t){var e=this,n=t,r=dl.EMPTY;return uh(n,function(t,n){r=r.set(new Kh([t]),e.fromValue(n))}),r},t.prototype.toMapValue=function(t){return{fields:this.toFields(t)}},t.prototype.toArrayValue=function(t){var e=this,n=[];return t.forEach(function(t){n.push(e.toValue(t))}),{values:n}},t.prototype.fromFound=function(t){Zc(!!t.found,"Tried to deserialize a found document from a missing document."),Lf(t.found.name,"doc.found.name"),Lf(t.found.updateTime,"doc.found.updateTime");var e=this.fromName(t.found.name),n=this.fromVersion(t.found.updateTime),r=this.fromFields(t.found.fields||{});return new Gh(e,n,r,{},t.found)},t.prototype.fromMissing=function(t){Zc(!!t.missing,"Tried to deserialize a missing document from a found document."),Zc(!!t.readTime,"Tried to deserialize a missing document without a read time.");var e=this.fromName(t.missing),n=this.fromVersion(t.readTime);return new zh(e,n)},t.prototype.fromMaybeDocument=function(t){var e=t.result;return Ff(t,e,"found")?this.fromFound(t):Ff(t,e,"missing")?this.fromMissing(t):$c("invalid batch get response: "+JSON.stringify(t))},t.prototype.toWatchTargetChangeState=function(t){switch(t){case gf.Added:return"ADD";case gf.Current:return"CURRENT";case gf.NoChange:return"NO_CHANGE";case gf.Removed:return"REMOVE"