firebase
Version:
Firebase JavaScript library for web and Node.js
1 lines • 190 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).firebase)}(this,function(eo){"use strict";try{(function(){function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e=t(eo),r=function(t,e){return(r=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])})(t,e)};function n(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var l=function(){return(l=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}).apply(this,arguments)};function i(t,s,a,h){return new(a=a||Promise)(function(n,e){function r(t){try{o(h.next(t))}catch(t){e(t)}}function i(t){try{o(h.throw(t))}catch(t){e(t)}}function o(t){var e;t.done?n(t.value):((e=t.value)instanceof a?e:new a(function(t){t(e)})).then(r,i)}o((h=h.apply(t,s||[])).next())})}function o(n,r){var i,o,s,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,o=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){a.label=e[1];break}if(6===e[0]&&a.label<s[1]){a.label=s[1],s=e;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(e);break}s[2]&&a.ops.pop(),a.trys.pop();continue}e=r.call(n,a)}catch(t){e=[6,t],o=0}finally{i=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function f(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function y(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function s(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(y(arguments[e]));return t}function a(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:(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>>12|224,e[n++]=i>>6&63|128),e[n++]=63&i|128)}return e}function h(t){try{return p.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null}var u={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},_=function(t,e){if(!t)throw c(e)},c=function(t){return new Error("Firebase Database ("+u.SDK_VERSION+") INTERNAL ASSERT FAILED: "+t)},p={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,h=i+2<t.length,l=h?t[i+2]:0,u=o>>2,o=(3&o)<<4|a>>4,a=(15&a)<<2|l>>6,l=63&l;h||(l=64,s||(a=64)),r.push(n[u],n[o],n[a],n[l])}return r.join("")},encodeString:function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(a(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,o,s,a=t[n++];a<128?e[r++]=String.fromCharCode(a):191<a&&a<224?(o=t[n++],e[r++]=String.fromCharCode((31&a)<<6|63&o)):239<a&&a<365?(i=((7&a)<<18|(63&(o=t[n++]))<<12|(63&(s=t[n++]))<<6|63&t[n++])-65536,e[r++]=String.fromCharCode(55296+(i>>10)),e[r++]=String.fromCharCode(56320+(1023&i))):(o=t[n++],s=t[n++],e[r++]=String.fromCharCode((15&a)<<12|(63&o)<<6|63&s))}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,h=++i<t.length?n[t.charAt(i)]:64;if(++i,null==o||null==s||null==a||null==h)throw Error();o=o<<2|s>>4;r.push(o),64!==a&&(s=s<<4&240|a>>2,r.push(s),64!==h&&(h=a<<6&192|h,r.push(h)))}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)>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};function d(t){return function t(e,n){if(!(n instanceof Object))return n;switch(n.constructor){case Date:var r=n;return new Date(r.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return n}for(var i in n)n.hasOwnProperty(i)&&(e[i]=t(e[i],n[i]));return e}(void 0,t)}var g=(v.prototype.wrapCallback=function(n){var r=this;return function(t,e){t?r.reject(t):r.resolve(e),"function"==typeof n&&(r.promise.catch(function(){}),1===n.length?n(t):n(t,e))}},v);function v(){var n=this;this.reject=function(){},this.resolve=function(){},this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})}function m(){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:"")}function C(){return!0===u.NODE_ADMIN}var E,w="FirebaseError",b=(n(S,E=Error),S);function S(t,e){e=E.call(this,e)||this;return e.code=t,e.name=w,Object.setPrototypeOf(e,S.prototype),Error.captureStackTrace&&Error.captureStackTrace(e,T.prototype.create),e}var T=(I.prototype.create=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r,i=e[0]||{},o=this.service+"/"+t,t=this.errors[t],t=t?(r=i,t.replace(N,function(t,e){var n=r[e];return null!=n?String(n):"<"+e+"?>"})):"Error",t=this.serviceName+": "+t+" ("+o+").",s=new b(o,t),a=0,h=Object.keys(i);a<h.length;a++){var l=h[a];"_"!==l.slice(-1)&&(l in s&&console.warn('Overwriting FirebaseError base field "'+l+'" can cause unexpected behavior.'),s[l]=i[l])}return s},I);function I(t,e,n){this.service=t,this.serviceName=e,this.errors=n}var N=/\{\$([^}]+)}/g;function R(t){return JSON.parse(t)}function P(t){return JSON.stringify(t)}function D(t){var e={},n={},r={},i="";try{var o=t.split("."),e=R(h(o[0])||""),n=R(h(o[1])||""),i=o[2],r=n.d||{};delete n.d}catch(t){}return{header:e,claims:n,data:r,signature:i}}function O(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function x(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function A(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function k(t,e,n){var r,i={};for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=e.call(n,t[r],r,t));return i}var F=(L.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},L.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)}for(var o,s,a=this.chain_[0],h=this.chain_[1],l=this.chain_[2],u=this.chain_[3],c=this.chain_[4],r=0;r<80;r++){s=r<40?r<20?(o=u^h&(l^u),1518500249):(o=h^l^u,1859775393):r<60?(o=h&l|u&(h|l),2400959708):(o=h^l^u,3395469782);i=(a<<5|a>>>27)+o+c+s+n[r]&4294967295,c=u,u=l,l=4294967295&(h<<30|h>>>2),h=a,a=i}this.chain_[0]=this.chain_[0]+a&4294967295,this.chain_[1]=this.chain_[1]+h&4294967295,this.chain_[2]=this.chain_[2]+l&4294967295,this.chain_[3]=this.chain_[3]+u&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295},L.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}},L.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;56<=n;n--)this.buf_[n]=255&e,e/=256;this.compress_(this.buf_);for(var r=0,n=0;n<5;n++)for(var i=24;0<=i;i-=8)t[r]=this.chain_[n]>>i&255,++r;return t},L);function L(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(var t=1;t<this.blockSize;++t)this.pad_[t]=0;this.reset()}function M(t,e,n,r){var i;if(r<e?i="at least "+e:n<r&&(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 W(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?")}t+=" failed: ";return t+=r+" argument "}function Q(t,e,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(W(t,e,r)+"must be a valid function.")}function q(t,e,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(W(t,e,r)+"must be a valid context object.")}function U(t){for(var e=0,n=0;n<t.length;n++){var r=t.charCodeAt(n);r<128?e++:r<2048?e+=2:55296<=r&&r<=56319?(e+=4,n++):e+=3}return e}var V;function H(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var r=Array(t),i=0,e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}(gt=V=V||{})[gt.DEBUG=0]="DEBUG",gt[gt.VERBOSE=1]="VERBOSE",gt[gt.INFO=2]="INFO",gt[gt.WARN=3]="WARN",gt[gt.ERROR=4]="ERROR",gt[gt.SILENT=5]="SILENT";function j(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(),o=K[e];if(!o)throw new Error("Attempted to log a message with an invalid logType (value: "+e+")");console[o].apply(console,H(["["+i+"] "+t.name+":"],n))}}var B={debug:V.DEBUG,verbose:V.VERBOSE,info:V.INFO,warn:V.WARN,error:V.ERROR,silent:V.SILENT},z=V.INFO,K=((Ce={})[V.DEBUG]="log",Ce[V.VERBOSE]="log",Ce[V.INFO]="info",Ce[V.WARN]="warn",Ce[V.ERROR]="error",Ce),Y=(Object.defineProperty(G.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in V))throw new TypeError('Invalid value "'+t+'" assigned to `logLevel`');this._logLevel=t},enumerable:!1,configurable:!0}),G.prototype.setLogLevel=function(t){this._logLevel="string"==typeof t?B[t]:t},Object.defineProperty(G.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:!1,configurable:!0}),Object.defineProperty(G.prototype,"userLogHandler",{get:function(){return this._userLogHandler},set:function(t){this._userLogHandler=t},enumerable:!1,configurable:!0}),G.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,H([this,V.DEBUG],t)),this._logHandler.apply(this,H([this,V.DEBUG],t))},G.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,H([this,V.VERBOSE],t)),this._logHandler.apply(this,H([this,V.VERBOSE],t))},G.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,H([this,V.INFO],t)),this._logHandler.apply(this,H([this,V.INFO],t))},G.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,H([this,V.WARN],t)),this._logHandler.apply(this,H([this,V.WARN],t))},G.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,H([this,V.ERROR],t)),this._logHandler.apply(this,H([this,V.ERROR],t))},G);function G(t){this.name=t,this._logLevel=z,this._logHandler=j,this._userLogHandler=null}var X=($.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},$.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},$.prototype.setServiceProps=function(t){return this.serviceProps=t,this},$);function $(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY"}var J="[DEFAULT]",Z=(tt.prototype.get=function(t){void 0===t&&(t=J);var e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){var n=new g;this.instancesDeferred.set(e,n);try{var r=this.getOrInitializeService(e);r&&n.resolve(r)}catch(t){}}return this.instancesDeferred.get(e).promise},tt.prototype.getImmediate=function(t){var e=l({identifier:J,optional:!1},t),t=e.identifier,n=e.optional,r=this.normalizeInstanceIdentifier(t);try{var i=this.getOrInitializeService(r);if(i)return i;if(n)return null;throw Error("Service "+this.name+" is not available")}catch(t){if(n)return null;throw t}},tt.prototype.getComponent=function(){return this.component},tt.prototype.setComponent=function(t){var e,n;if(t.name!==this.name)throw Error("Mismatching Component "+t.name+" for Provider "+this.name+".");if(this.component)throw Error("Component for "+this.name+" has already been provided");if("EAGER"===(this.component=t).instantiationMode)try{this.getOrInitializeService(J)}catch(t){}try{for(var r=f(this.instancesDeferred.entries()),i=r.next();!i.done;i=r.next()){var o=y(i.value,2),s=o[0],a=o[1],h=this.normalizeInstanceIdentifier(s);try{var l=this.getOrInitializeService(h);a.resolve(l)}catch(t){}}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},tt.prototype.clearInstance=function(t){void 0===t&&(t=J),this.instancesDeferred.delete(t),this.instances.delete(t)},tt.prototype.delete=function(){return i(this,void 0,void 0,function(){var e;return o(this,function(t){switch(t.label){case 0:return e=Array.from(this.instances.values()),[4,Promise.all(s(e.filter(function(t){return"INTERNAL"in t}).map(function(t){return t.INTERNAL.delete()}),e.filter(function(t){return"_delete"in t}).map(function(t){return t._delete()})))];case 1:return t.sent(),[2]}})})},tt.prototype.isComponentSet=function(){return null!=this.component},tt.prototype.getOrInitializeService=function(t){var e,n=this.instances.get(t);return!n&&this.component&&(n=this.component.instanceFactory(this.container,(e=t)===J?void 0:e),this.instances.set(t,n)),n||null},tt.prototype.normalizeInstanceIdentifier=function(t){return!this.component||this.component.multipleInstances?t:J},tt);function tt(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map}var et=(nt.prototype.addComponent=function(t){var e=this.getProvider(t.name);if(e.isComponentSet())throw new Error("Component "+t.name+" has already been registered with "+this.name);e.setComponent(t)},nt.prototype.addOrOverwriteComponent=function(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)},nt.prototype.getProvider=function(t){if(this.providers.has(t))return this.providers.get(t);var e=new Z(t,this);return this.providers.set(t,e),e},nt.prototype.getProviders=function(){return Array.from(this.providers.values())},nt);function nt(t){this.name=t,this.providers=new Map}var rt=(it.prototype.set=function(t,e){null==e?this.domStorage_.removeItem(this.prefixedName_(t)):this.domStorage_.setItem(this.prefixedName_(t),P(e))},it.prototype.get=function(t){t=this.domStorage_.getItem(this.prefixedName_(t));return null==t?null:R(t)},it.prototype.remove=function(t){this.domStorage_.removeItem(this.prefixedName_(t))},it.prototype.prefixedName_=function(t){return this.prefix_+t},it.prototype.toString=function(){return this.domStorage_.toString()},it);function it(t){this.domStorage_=t,this.prefix_="firebase:"}var ot=(st.prototype.set=function(t,e){null==e?delete this.cache_[t]:this.cache_[t]=e},st.prototype.get=function(t){return O(this.cache_,t)?this.cache_[t]:null},st.prototype.remove=function(t){delete this.cache_[t]},st);function st(){this.cache_={},this.isInMemoryStorage=!0}function at(t){var e=function(t){for(var e=[],n=0,r=0;r<t.length;r++){var i,o=t.charCodeAt(r);55296<=o&&o<=56319&&(i=o-55296,_(++r<t.length,"Surrogate pair missing trail surrogate."),o=65536+(i<<10)+(t.charCodeAt(r)-56320)),o<128?e[n++]=o:(o<2048?e[n++]=o>>6|192:(o<65536?e[n++]=o>>12|224:(e[n++]=o>>18|240,e[n++]=o>>12&63|128),e[n++]=o>>6&63|128),e[n++]=63&o|128)}return e}(t);return(t=new F).update(e),t=t.digest(),p.encodeByteArray(t)}function ht(t,e){_(!e||!0===t||!1===t,"Can't turn on custom loggers persistently."),!0===t?(Ct.logLevel=V.VERBOSE,bt=Ct.log.bind(Ct),e&&mt.set("logging_enabled",!0)):"function"==typeof t?bt=t:(bt=null,mt.remove("logging_enabled"))}function lt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE INTERNAL ERROR: "+wt.apply(void 0,s(t));Ct.error(n)}function ut(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE FATAL ERROR: "+wt.apply(void 0,s(t));throw Ct.error(n),new Error(n)}function ct(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE WARNING: "+wt.apply(void 0,s(t));Ct.warn(n)}function pt(t){return"number"==typeof t&&(t!=t||t===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY)}function dt(t,e){return t===e?0:t<e?-1:1}function ft(t,e){if(e&&t in e)return e[t];throw new Error("Missing required key ("+t+") in object: "+P(e))}function yt(t,e){var n=t.length;if(n<=e)return[t];for(var r=[],i=0;i<n;i+=e)n<i+e?r.push(t.substring(i,n)):r.push(t.substring(i,i+e));return r}var _t,gt=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 rt(e)}}catch(t){}return new ot},vt=gt("localStorage"),mt=gt("sessionStorage"),Ct=new Y("@firebase/database"),Et=(_t=1,function(){return _t++}),wt=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n="",r=0;r<t.length;r++){var i=t[r];Array.isArray(i)||i&&"object"==typeof i&&"number"==typeof i.length?n+=wt.apply(null,i):n+="object"==typeof i?P(i):i,n+=" "}return n},bt=null,St=!0,Tt=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];!0===St&&(St=!1,null===bt&&!0===mt.get("logging_enabled")&&ht(!0)),bt&&(t=wt.apply(null,e),bt(t))},It=function(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Tt.apply(void 0,s([n],t))}},Nt="[MIN_NAME]",Rt="[MAX_NAME]",Pt=function(t,e){if(t===e)return 0;if(t===Nt||e===Rt)return-1;if(e===Nt||t===Rt)return 1;var n=Lt(t),r=Lt(e);return null!==n?null!==r?n-r==0?t.length-e.length:n-r:-1:null===r&&t<e?-1:1},Dt=function(t){if("object"!=typeof t||null===t)return P(t);var e,n=[];for(e in t)n.push(e);n.sort();for(var r="{",i=0;i<n.length;i++)0!==i&&(r+=","),r+=P(n[i]),r+=":",r+=Dt(t[n[i]]);return r+="}"};function Ot(t,e){for(var n in t)t.hasOwnProperty(n)&&e(n,t[n])}function xt(t){var e,n,r,i;_(!pt(t),"Invalid JSON number"),0===t?e=1/t==-1/(r=n=0)?1:0:(e=t<0,r=(t=Math.abs(t))>=Math.pow(2,-1022)?(n=(i=Math.min(Math.floor(Math.log(t)/Math.LN2),1023))+1023,Math.round(t*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,Math.round(t/Math.pow(2,-1074))));for(var o=[],s=52;s;--s)o.push(r%2?1:0),r=Math.floor(r/2);for(s=11;s;--s)o.push(n%2?1:0),n=Math.floor(n/2);o.push(e?1:0),o.reverse();var a=o.join(""),h="";for(s=0;s<64;s+=8){var l=parseInt(a.substr(s,8),2).toString(16);1===l.length&&(l="0"+l),h+=l}return h.toLowerCase()}function At(t){try{t()}catch(e){setTimeout(function(){var t=e.stack||"";throw ct("Exception was thrown by user callback.",t),e},Math.floor(0))}}function kt(t,e){return"object"==typeof(e=setTimeout(t,e))&&e.unref&&e.unref(),e}var Ft=new RegExp("^-?(0*)\\d{1,10}$"),Lt=function(t){if(Ft.test(t)){t=Number(t);if(-2147483648<=t&&t<=2147483647)return t}return null},Mt=(Object.defineProperty(Wt,"Empty",{get:function(){return new Wt("")},enumerable:!1,configurable:!0}),Wt.prototype.getFront=function(){return this.pieceNum_>=this.pieces_.length?null:this.pieces_[this.pieceNum_]},Wt.prototype.getLength=function(){return this.pieces_.length-this.pieceNum_},Wt.prototype.popFront=function(){var t=this.pieceNum_;return t<this.pieces_.length&&t++,new Wt(this.pieces_,t)},Wt.prototype.getBack=function(){return this.pieceNum_<this.pieces_.length?this.pieces_[this.pieces_.length-1]:null},Wt.prototype.toString=function(){for(var t="",e=this.pieceNum_;e<this.pieces_.length;e++)""!==this.pieces_[e]&&(t+="/"+this.pieces_[e]);return t||"/"},Wt.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||"/"},Wt.prototype.slice=function(t){return void 0===t&&(t=0),this.pieces_.slice(this.pieceNum_+t)},Wt.prototype.parent=function(){if(this.pieceNum_>=this.pieces_.length)return null;for(var t=[],e=this.pieceNum_;e<this.pieces_.length-1;e++)t.push(this.pieces_[e]);return new Wt(t,0)},Wt.prototype.child=function(t){for(var e=[],n=this.pieceNum_;n<this.pieces_.length;n++)e.push(this.pieces_[n]);if(t instanceof Wt)for(n=t.pieceNum_;n<t.pieces_.length;n++)e.push(t.pieces_[n]);else for(var r=t.split("/"),n=0;n<r.length;n++)0<r[n].length&&e.push(r[n]);return new Wt(e,0)},Wt.prototype.isEmpty=function(){return this.pieceNum_>=this.pieces_.length},Wt.relativePath=function(t,e){var n=t.getFront(),r=e.getFront();if(null===n)return e;if(n===r)return Wt.relativePath(t.popFront(),e.popFront());throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")},Wt.comparePaths=function(t,e){for(var n=t.slice(),r=e.slice(),i=0;i<n.length&&i<r.length;i++){var o=Pt(n[i],r[i]);if(0!==o)return o}return n.length===r.length?0:n.length<r.length?-1:1},Wt.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},Wt.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},Wt);function Wt(t,e){if(void 0===e){this.pieces_=t.split("/");for(var n=0,r=0;r<this.pieces_.length;r++)0<this.pieces_[r].length&&(this.pieces_[n]=this.pieces_[r],n++);this.pieces_.length=n,this.pieceNum_=0}else this.pieces_=t,this.pieceNum_=e}var Qt=(Object.defineProperty(qt,"MAX_PATH_DEPTH",{get:function(){return 32},enumerable:!1,configurable:!0}),Object.defineProperty(qt,"MAX_PATH_LENGTH_BYTES",{get:function(){return 768},enumerable:!1,configurable:!0}),qt.prototype.push=function(t){0<this.parts_.length&&(this.byteLength_+=1),this.parts_.push(t),this.byteLength_+=U(t),this.checkValid_()},qt.prototype.pop=function(){var t=this.parts_.pop();this.byteLength_-=U(t),0<this.parts_.length&&--this.byteLength_},qt.prototype.checkValid_=function(){if(this.byteLength_>qt.MAX_PATH_LENGTH_BYTES)throw new Error(this.errorPrefix_+"has a key path longer than "+qt.MAX_PATH_LENGTH_BYTES+" bytes ("+this.byteLength_+").");if(this.parts_.length>qt.MAX_PATH_DEPTH)throw new Error(this.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+qt.MAX_PATH_DEPTH+") or object contains a cycle "+this.toErrorString())},qt.prototype.toErrorString=function(){return 0===this.parts_.length?"":"in property '"+this.parts_.join(".")+"'"},qt);function qt(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_+=U(this.parts_[n]);this.checkValid_()}var Ut="firebaseio.com",Vt="websocket",Ht="long_polling",jt=(Bt.prototype.needsQueryParam=function(){return this.host!==this.internalHost||this.isCustomHost()||this.includeNamespaceInQueryParams},Bt.prototype.isCacheableHost=function(){return"s-"===this.internalHost.substr(0,2)},Bt.prototype.isDemoHost=function(){return"firebaseio-demo.com"===this.domain},Bt.prototype.isCustomHost=function(){return"firebaseio.com"!==this.domain&&"firebaseio-demo.com"!==this.domain},Bt.prototype.updateHost=function(t){t!==this.internalHost&&(this.internalHost=t,this.isCacheableHost()&&vt.set("host:"+this.host,this.internalHost))},Bt.prototype.connectionURL=function(t,e){var n;if(_("string"==typeof t,"typeof type must == string"),_("object"==typeof e,"typeof params must == object"),t===Vt)n=(this.secure?"wss://":"ws://")+this.internalHost+"/.ws?";else{if(t!==Ht)throw new Error("Unknown connection type: "+t);n=(this.secure?"https://":"http://")+this.internalHost+"/.lp?"}this.needsQueryParam()&&(e.ns=this.namespace);var r=[];return Ot(e,function(t,e){r.push(t+"="+e)}),n+r.join("&")},Bt.prototype.toString=function(){var t=this.toURLString();return this.persistenceKey&&(t+="<"+this.persistenceKey+">"),t},Bt.prototype.toURLString=function(){return(this.secure?"https://":"http://")+this.host},Bt);function Bt(t,e,n,r,i,o,s){void 0===i&&(i=!1),void 0===o&&(o=""),void 0===s&&(s=!1),this.secure=e,this.namespace=n,this.webSocketOnly=r,this.nodeAdmin=i,this.persistenceKey=o,this.includeNamespaceInQueryParams=s,this.host=t.toLowerCase(),this.domain=this.host.substr(this.host.indexOf(".")+1),this.internalHost=vt.get("host:"+t)||this.host}function zt(t,e){var n=ie(t),r=n.namespace;return"firebase.com"===n.domain&&ut(n.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),r&&"undefined"!==r||"localhost"===n.domain||ut("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),n.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&ct("Insecure Firebase access from a secure page. Please use https in calls to new Firebase()."),t="ws"===n.scheme||"wss"===n.scheme,{repoInfo:new jt(n.host,n.secure,r,e,t,"",r!==n.subdomain),path:new Mt(n.pathString)}}function Kt(t){return"string"==typeof t&&0!==t.length&&!oe.test(t)}function Yt(t){return"string"==typeof t&&0!==t.length&&!se.test(t)}function Gt(t){return null===t||"string"==typeof t||"number"==typeof t&&!pt(t)||t&&"object"==typeof t&&O(t,".sv")}function Xt(t,e,n,r,i){i&&void 0===n||he(W(t,e,i),n,r)}function $t(t,e,n,r,i){if(!i||void 0!==n){var o=W(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=[];Ot(n,function(t,e){t=new Mt(t);if(he(o,e,r.child(t)),".priority"===t.getBack()&&!Gt(e))throw new Error(o+"contains an invalid value for '"+t.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");s.push(t)}),function(t,e){for(var n,r=0;r<e.length;r++)for(var i=(n=e[r]).slice(),o=0;o<i.length;o++)if((".priority"!==i[o]||o!==i.length-1)&&!Kt(i[o]))throw new Error(t+"contains an invalid key ("+i[o]+") in path "+n.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');e.sort(Mt.comparePaths);var s=null;for(r=0;r<e.length;r++){if(n=e[r],null!==s&&s.contains(n))throw new Error(t+"contains a path "+s.toString()+" that is ancestor of another path "+n.toString());s=n}}(o,s)}}function Jt(t,e,n,r){if(!r||void 0!==n){if(pt(n))throw new Error(W(t,e,r)+"is "+n.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!Gt(n))throw new Error(W(t,e,r)+"must be a valid Firebase priority (a string, finite number, server value, or null).")}}function Zt(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(W(t,e,r)+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}function te(t,e,n,r){if(!(r&&void 0===n||Kt(n)))throw new Error(W(t,e,r)+'was an invalid key = "'+n+'". Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')}function ee(t,e,n,r){if(!(r&&void 0===n||Yt(n)))throw new Error(W(t,e,r)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')}function ne(t,e){if(".info"===e.getFront())throw new Error(t+" failed = Can't modify data under /.info/")}function re(t,e,n){var r=n.path.toString();if("string"!=typeof n.repoInfo.host||0===n.repoInfo.host.length||!Kt(n.repoInfo.namespace)&&"localhost"!==n.repoInfo.host.split(":")[0]||0!==r.length&&(r=(r=r)&&r.replace(/^\/*\.info(\/|$)/,"/"),!Yt(r)))throw new Error(W(t,e,!1)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')}var ie=function(t){var e,n,r,i="",o="",s="",a="",h="",l=!0,u="https",c=443;return"string"==typeof t&&(0<=(r=t.indexOf("//"))&&(u=t.substring(0,r-1),t=t.substring(r+2)),-1===(e=t.indexOf("/"))&&(e=t.length),-1===(n=t.indexOf("?"))&&(n=t.length),i=t.substring(0,Math.min(e,n)),e<n&&(a=function(t){for(var e="",n=t.split("/"),r=0;r<n.length;r++)if(0<n[r].length){var i=n[r];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch(t){}e+="/"+i}return e}(t.substring(e,n))),n=function(t){var e,n,r={};"?"===t.charAt(0)&&(t=t.substring(1));try{for(var i=f(t.split("&")),o=i.next();!o.done;o=i.next()){var s,a=o.value;0!==a.length&&(2===(s=a.split("=")).length?r[decodeURIComponent(s[0])]=decodeURIComponent(s[1]):ct("Invalid query segment '"+a+"' in query '"+t+"'"))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r}(t.substring(Math.min(t.length,n))),0<=(r=i.indexOf(":"))?(l="https"===u||"wss"===u,c=parseInt(i.substring(r+1),10)):r=i.length,"localhost"===(r=i.slice(0,r)).toLowerCase()?o="localhost":r.split(".").length<=2?o=r:(r=i.indexOf("."),s=i.substring(0,r).toLowerCase(),o=i.substring(r+1),h=s),"ns"in n&&(h=n.ns)),{host:i,port:c,domain:o,subdomain:s,secure:l,scheme:u,pathString:a,namespace:h}},oe=/[\[\].#$\/\u0000-\u001F\u007F]/,se=/[\[\].#$\u0000-\u001F\u007F]/,ae=10485760,he=function(n,t,e){var r=e instanceof Mt?new Qt(e,n):e;if(void 0===t)throw new Error(n+"contains undefined "+r.toErrorString());if("function"==typeof t)throw new Error(n+"contains a function "+r.toErrorString()+" with contents = "+t.toString());if(pt(t))throw new Error(n+"contains "+t.toString()+" "+r.toErrorString());if("string"==typeof t&&t.length>ae/3&&U(t)>ae)throw new Error(n+"contains a string greater than "+ae+" utf8 bytes "+r.toErrorString()+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){var i=!1,o=!1;if(Ot(t,function(t,e){if(".value"===t)i=!0;else if(".priority"!==t&&".sv"!==t&&(o=!0,!Kt(t)))throw new Error(n+" contains an invalid key ("+t+") "+r.toErrorString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');r.push(t),he(n,e,r),r.pop()}),i&&o)throw new Error(n+' contains ".value" child '+r.toErrorString()+" in addition to actual children.")}},le=(ue.prototype.cancel=function(t){M("OnDisconnect.cancel",0,1,arguments.length),Q("OnDisconnect.cancel",1,t,!0);var e=new g;return this.repo_.onDisconnectCancel(this.path_,e.wrapCallback(t)),e.promise},ue.prototype.remove=function(t){M("OnDisconnect.remove",0,1,arguments.length),ne("OnDisconnect.remove",this.path_),Q("OnDisconnect.remove",1,t,!0);var e=new g;return this.repo_.onDisconnectSet(this.path_,null,e.wrapCallback(t)),e.promise},ue.prototype.set=function(t,e){M("OnDisconnect.set",1,2,arguments.length),ne("OnDisconnect.set",this.path_),Xt("OnDisconnect.set",1,t,this.path_,!1),Q("OnDisconnect.set",2,e,!0);var n=new g;return this.repo_.onDisconnectSet(this.path_,t,n.wrapCallback(e)),n.promise},ue.prototype.setWithPriority=function(t,e,n){M("OnDisconnect.setWithPriority",2,3,arguments.length),ne("OnDisconnect.setWithPriority",this.path_),Xt("OnDisconnect.setWithPriority",1,t,this.path_,!1),Jt("OnDisconnect.setWithPriority",2,e,!1),Q("OnDisconnect.setWithPriority",3,n,!0);var r=new g;return this.repo_.onDisconnectSetWithPriority(this.path_,t,e,r.wrapCallback(n)),r.promise},ue.prototype.update=function(t,e){if(M("OnDisconnect.update",1,2,arguments.length),ne("OnDisconnect.update",this.path_),Array.isArray(t)){for(var n={},r=0;r<t.length;++r)n[""+r]=t[r];t=n,ct("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.")}$t("OnDisconnect.update",1,t,this.path_,!1),Q("OnDisconnect.update",2,e,!0);var i=new g;return this.repo_.onDisconnectUpdate(this.path_,t,i.wrapCallback(e)),i.promise},ue);function ue(t,e){this.repo_=t,this.path_=e}var ce=(pe.prototype.toJSON=function(){return M("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}},pe);function pe(t,e){this.committed=t,this.snapshot=e}var de,fe,ye,_e=(de="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",fe=0,ye=[],function(t){var e=t===fe;fe=t;for(var n=new Array(8),r=7;0<=r;r--)n[r]=de.charAt(t%64),t=Math.floor(t/64);_(0===t,"Cannot push at time == 0");var i=n.join("");if(e){for(r=11;0<=r&&63===ye[r];r--)ye[r]=0;ye[r]++}else for(r=0;r<12;r++)ye[r]=Math.floor(64*Math.random());for(r=0;r<12;r++)i+=de.charAt(ye[r]);return _(20===i.length,"nextPushId: Length should be 20."),i}),ge=(ve.Wrap=function(t,e){return new ve(t,e)},ve);function ve(t,e){this.name=t,this.node=e}var me,Ce=(Ee.prototype.getCompare=function(){return this.compare.bind(this)},Ee.prototype.indexedValueChanged=function(t,e){t=new ge(Nt,t),e=new ge(Nt,e);return 0!==this.compare(t,e)},Ee.prototype.minPost=function(){return ge.MIN},Ee);function Ee(){}var we,gt=(n(be,we=Ce),Object.defineProperty(be,"__EMPTY_NODE",{get:function(){return me},set:function(t){me=t},enumerable:!1,configurable:!0}),be.prototype.compare=function(t,e){return Pt(t.name,e.name)},be.prototype.isDefinedOn=function(t){throw c("KeyIndex.isDefinedOn not expected to be called.")},be.prototype.indexedValueChanged=function(t,e){return!1},be.prototype.minPost=function(){return ge.MIN},be.prototype.maxPost=function(){return new ge(Rt,me)},be.prototype.makePost=function(t,e){return _("string"==typeof t,"KeyIndex indexValue must always be a string."),new ge(t,me)},be.prototype.toString=function(){return".key"},be);function be(){return null!==we&&we.apply(this,arguments)||this}var Se,Te=new gt;function Ie(t){return"number"==typeof t?"number:"+xt(t):"string:"+t}var Ne,Re,Pe,De,Oe=function(t){var e;t.isLeafNode()?(e=t.val(),_("string"==typeof e||"number"==typeof e||"object"==typeof e&&O(e,".sv"),"Priority must be a string or number.")):_(t===Se||t.isEmpty(),"priority of unexpected type."),_(t===Se||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")},xe=(Object.defineProperty(Ae,"__childrenNodeConstructor",{get:function(){return Ne},set:function(t){Ne=t},enumerable:!1,configurable:!0}),Ae.prototype.isLeafNode=function(){return!0},Ae.prototype.getPriority=function(){return this.priorityNode_},Ae.prototype.updatePriority=function(t){return new Ae(this.value_,t)},Ae.prototype.getImmediateChild=function(t){return".priority"===t?this.priorityNode_:Ae.__childrenNodeConstructor.EMPTY_NODE},Ae.prototype.getChild=function(t){return t.isEmpty()?this:".priority"===t.getFront()?this.priorityNode_:Ae.__childrenNodeConstructor.EMPTY_NODE},Ae.prototype.hasChild=function(){return!1},Ae.prototype.getPredecessorChildName=function(t,e){return null},Ae.prototype.updateImmediateChild=function(t,e){return".priority"===t?this.updatePriority(e):e.isEmpty()&&".priority"!==t?this:Ae.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(t,e).updatePriority(this.priorityNode_)},Ae.prototype.updateChild=function(t,e){var n=t.getFront();return null===n?e:e.isEmpty()&&".priority"!==n?this:(_(".priority"!==n||1===t.getLength(),".priority must be the last token in a path"),this.updateImmediateChild(n,Ae.__childrenNodeConstructor.EMPTY_NODE.updateChild(t.popFront(),e)))},Ae.prototype.isEmpty=function(){return!1},Ae.prototype.numChildren=function(){return 0},Ae.prototype.forEachChild=function(t,e){return!1},Ae.prototype.val=function(t){return t&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()},Ae.prototype.hash=function(){var t,e;return null===this.lazyHash_&&(t="",this.priorityNode_.isEmpty()||(t+="priority:"+Ie(this.priorityNode_.val())+":"),t+=(e=typeof this.value_)+":",t+="number"==e?xt(this.value_):this.value_,this.lazyHash_=at(t)),this.lazyHash_},Ae.prototype.getValue=function(){return this.value_},Ae.prototype.compareTo=function(t){return t===Ae.__childrenNodeConstructor.EMPTY_NODE?1:t instanceof Ae.__childrenNodeConstructor?-1:(_(t.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(t))},Ae.prototype.compareToLeafNode_=function(t){var e=typeof t.value_,n=typeof this.value_,r=Ae.VALUE_TYPE_ORDER.indexOf(e),i=Ae.VALUE_TYPE_ORDER.indexOf(n);return _(0<=r,"Unknown leaf type: "+e),_(0<=i,"Unknown leaf type: "+n),r===i?"object"==n?0:this.value_<t.value_?-1:this.value_===t.value_?0:1:i-r},Ae.prototype.withIndex=function(){return this},Ae.prototype.isIndexed=function(){return!0},Ae.prototype.equals=function(t){return t===this||!!t.isLeafNode()&&(this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_))},Ae.VALUE_TYPE_ORDER=["object","boolean","number","string"],Ae);function Ae(t,e){void 0===e&&(e=Ae.__childrenNodeConstructor.EMPTY_NODE),this.value_=t,this.priorityNode_=e,this.lazyHash_=null,_(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),Oe(this.priorityNode_)}function ke(){return null!==De&&De.apply(this,arguments)||this}var Fe=new(n(ke,De=Ce),ke.prototype.compare=function(t,e){var n=t.node.getPriority(),r=e.node.getPriority(),r=n.compareTo(r);return 0===r?Pt(t.name,e.name):r},ke.prototype.isDefinedOn=function(t){return!t.getPriority().isEmpty()},ke.prototype.indexedValueChanged=function(t,e){return!t.getPriority().equals(e.getPriority())},ke.prototype.minPost=function(){return ge.MIN},ke.prototype.maxPost=function(){return new ge(Rt,new xe("[PRIORITY-POST]",Pe))},ke.prototype.makePost=function(t,e){t=Re(t);return new ge(e,new xe("[PRIORITY-POST]",t))},ke.prototype.toString=function(){return".priority"},ke),Le=(Me.prototype.getNext=function(){if(0===this.nodeStack_.length)return null;var t=this.nodeStack_.pop(),e=this.resultGenerator_?this.resultGenerator_(t.key,t.value):{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},Me.prototype.hasNext=function(){return 0<this.nodeStack_.length},Me.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}},Me);function Me(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(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}}var We=(Qe.prototype.copy=function(t,e,n,r,i){return new Qe(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)},Qe.prototype.count=function(){return this.left.count()+1+this.right.count()},Qe.prototype.isEmpty=function(){return!1},Qe.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||!!t(this.key,this.value)||this.right.inorderTraversal(t)},Qe.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},Qe.prototype.min_=function(){return this.left.isEmpty()?this:this.left.min_()},Qe.prototype.minKey=function(){return this.min_().key},Qe.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},Qe.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_()},Qe.prototype.removeMin_=function(){if(this.left.isEmpty())return Ue.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_()},Qe.prototype.remove=function(t,e){var n,r=this;if(e(t,r.key)<0)r.left.isEmpty()||r.left.isRed_()||r.left.left.isRed_()||(r=r.moveRedLeft_()),r=r.copy(null,null,null,r.left.remove(t,e),null);else{if(r.left.isRed_()&&(r=r.rotateRight_()),r.right.isEmpty()||r.right.isRed_()||r.right.left.isRed_()||(r=r.moveRedRight_()),0===e(t,r.key)){if(r.right.isEmpty())return Ue.EMPTY_NODE;n=r.right.min_(),r=r.copy(n.key,n.value,null,null,r.right.removeMin_())}r=r.copy(null,null,null,null,r.right.remove(t,e))}return r.fixUp_()},Qe.prototype.isRed_=function(){return this.color},Qe.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},Qe.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},Qe.prototype.moveRedRight_=function(){var t=this.colorFlip_();return t.left.left.isRed_()&&(t=(t=t.rotateRight_()).colorFlip_()),t},Qe.prototype.rotateLeft_=function(){var t=this.copy(null,null,Qe.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},Qe.prototype.rotateRight_=function(){var t=this.copy(null,null,Qe.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},Qe.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)},Qe.prototype.checkMaxDepth_=function(){var t=this.check_();return Math.pow(2,t)<=this.count()+1},Qe.prototype.check_=function(){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");var t=this.left.check_();if(t!==this.right.check_())throw new Error("Black depths differ");return t+(this.isRed_()?0:1)},Qe.RED=!0,Qe.BLACK=!1,Qe);function Qe(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:Qe.RED,this.left=null!=r?r:Ue.EMPTY_NODE,this.right=null!=i?i:Ue.EMPTY_NODE}qe.prototype.copy=function(t,e,n,r,i){return this},qe.prototype.insert=function(t,e,n){return new We(t,e,null)},qe.prototype.remove=function(t,e){return this},qe.prototype.count=function(){return 0},qe.prototype.isEmpty=function(){return!0},qe.prototype.inorderTraversal=function(t){return!1},qe.prototype.reverseTraversal=function(t){return!1},qe.prototype.minKey=function(){return null},qe.prototype.maxKey=function(){return null},qe.prototype.check_=function(){return 0},qe.prototype.isRed_=function(){return!1},Y=qe;function qe(){}var Ue=(Ve.prototype.insert=function(t,e){return new Ve(this.comparator_,this.root_.insert(t,e,this.comparator_).copy(null,null,We.BLACK,null,null))},Ve.prototype.remove=function(t){return new Ve(this.comparator_,this.root_.remove(t,this.comparator_).copy(null,null,We.BLACK,null,null))},Ve.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:0<e&&(n=n.right)}return null},Ve.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:0<e&&(n=(r=n).right)}throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")},Ve.prototype.isEmpty=function(){return this.root_.isEmpty()},Ve.prototype.count=function(){return this.root_.count()},Ve.prototype.minKey=function(){return this.root_.minKey()},Ve.prototype.maxKey=function(){return this.root_.maxKey()},Ve.prototype.inorderTraversal=function(t){return this.root_.inorderTraversal(t)},Ve.prototype.reverseTraversal=function(t){return this.root_.reverseTraversal(t)},Ve.prototype.getIterator=function(t){return new Le(this.root_,null,this.comparator_,!1,t)},Ve.prototype.getIteratorFrom=function(t,e){return new Le(this.root_,t,this.comparator_,!1,e)},Ve.prototype.getReverseIteratorFrom=function(t,e){return new Le(this.root_,t,this.comparator_,!0,e)},Ve.prototype.getReverseIterator=function(t){return new Le(this.root_,null,this.comparator_,!0,t)},Ve.EMPTY_NODE=new Y,Ve);function Ve(t,e){void 0===e&&(e=Ve.EMPTY_NODE),this.comparator_=t,this.root_=e}var He=Math.log(2),je=(Be.prototype.nextBitIsOne=function(){var t=!(this.bits_&1<<this.current_);return this.current_--,t},Be);function Be(t){var e;this.count=(e=t+1,parseInt(Math.log(e)/He,10)),this.current_=this.count-1;var n,r=(n=this.count,parseInt(Array(n+1).join("1"),2));this.bits_=t+1&r}var ze,Ke,Ye=function(l,t,u,e){l.sort(t);var c=function(t,e){var n=e-t;if(0==n)return null;if(1==n)return r=l[t],i=u?u(r):r,new We(i,r.node,We.BLACK,null,null);var n=parseInt(n/2,10)+t,t=c(t,n),e=c(n+1,e),r=l[n],i=u?u(r):r;return new We(i,r.node,We.BLACK,t,e)},n=function(t){for(var e=null,n=null,i=l.length,r=function(t,e){var n=i-t,r=i;i-=t;t=c(1+n,r),r=l[n],n=u?u(r):r;o(new We(n,r.node,e,null,t))},o=function(t){e=e?e.left=t:n=t},s=0;s<t.count;++s){var a=t.nextBitIsOne(),h=Math.pow(2,t.count-(s+1));a?r(h,We.BLACK):(r(h,We.BLACK),r(h,We.RED))}return n}(new je(l.length));return new Ue(e||t,n)},Ge={},Xe=(Object.defineProperty($e,"Default",{get:function(){return _(Fe,"ChildrenNode.ts has not been loaded"),ze=ze||new $e({".priority":Ge},{".priority":Fe})},enumerable:!1,configurable:!0}),$e.prototype.get=function(t){var e=x(this.indexes_,t);if(!e)throw new Error("No index defined for "+t);return e instanceof Ue?e:null},$e.prototype.hasIndex=function(t){return O(this.indexSet_,t.toString())},$e.prototype.addIndex=function(t,e){_(t!==Te,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var n,r=[],i=!1,o=e.getIterator(ge.Wrap),s=o.getNext();s;)i=i||t.isDefinedOn(s.node),r.push(s),s=o.getNext();n=i?Ye(r,t.getCompare()):Ge;var a=t.toString(),h=l({},this.indexSet_);h[a]=t;e=l({},this.indexes_);return e[a]=n,new $e(e,h)},$e.prototype.addToIndexes=function(s,a){var h=this;return new $e(k(this.indexes_,function(t,e){var n=x(h.indexSet_,e);if(_(n,"Missing index implementation for "+e),t===Ge){if(n.isDefinedOn(s.node)){for(var r=[],i=a.getIterator(ge.Wrap),o=i.getNext();o;)o.name!==s.name&&r.push(o),o=i.getNext();return r.push(s),Ye(r,n.getCompare())}return Ge}n=a.get(s.name);return n&&(t=t.remove(new ge(s.name,n))),t.insert(s,s.node)}),this.indexSet_)},$e.prototype.removeFromIndexes=function(n,r){return new $e(k(this.indexes_,function(t){if(t===Ge)return t;var e=r.get(n.name);return e?t.remove(new ge(n.name,e)):t}),this.indexSet_)},$e);function $e(t,e){this.indexes_=t,this.indexSet_=e}function Je(t,e){return Pt(t.name,e.name)}function Ze(t,e){return Pt(t,e)}var tn,en=(Object.defineProperty(nn,"EMPTY_NODE",{get:function(){return Ke=Ke||new nn(new Ue(Ze),null,Xe.Default)},enumerable:!1,configurable:!0}),nn.prototype.isLeafNode=function(){return!1},nn.prototype.getPriority=function(){return this.priorityNode_||Ke},nn.prototype.updatePriority=function(t){return this.children_.isEmpty()?this:new nn(this.children_,t,this.indexMap_)},nn.prototype.getImmediateChild=function(t){if(".priority"===t)return this.getPriority();t=this.children_.get(t);return null===t?Ke:t},nn.prototype.getChild=function(t){var e=t.getFront();return null===e?this:this.getImmediateChild(e).getChild(t.popFront())},nn.prototype.hasChild=function(t){return null!==this.children_.get(t)},nn.prototype.updateImmediateChild=function(t,e){if(_(e,"We should always be passing snapshot nodes"),".priority"===t)return this.updatePriority(e);var n=new ge(t,e),r=void 0,i=void 0,i=e.isEmpty()?(r=this.children_.remove(t),this.indexMap_.removeFromIndexes(n,this.chil