-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent---src-pages-collaboration-file-js-8c46f1a5768cf7e080d3.js
2 lines (2 loc) · 881 KB
/
component---src-pages-collaboration-file-js-8c46f1a5768cf7e080d3.js
1
2
(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{"+80P":function(t,e,n){"use strict";function r(t){return Array.prototype.slice.call(arguments,1).forEach((function(e){e&&Object.keys(e).forEach((function(n){t[n]=e[n]}))})),t}function i(t){return Object.prototype.toString.call(t)}function o(t){return"[object Function]"===i(t)}function a(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}n("zGcK"),n("MIFh"),n("sc67"),n("sPse"),n("OeI1"),n("AqHK"),n("HQhv"),n("Ll4R"),n("klQ5"),n("U6Bt"),n("sC2a"),n("q8oJ"),n("C9fy"),n("rzGZ"),n("Dq+y"),n("8npG"),n("Ggvi"),n("JHok");var s={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};var u={"http:":{validate:function(t,e,n){var r=t.slice(e);return n.re.http||(n.re.http=new RegExp("^\\/\\/"+n.re.src_auth+n.re.src_host_port_strict+n.re.src_path,"i")),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(t,e,n){var r=t.slice(e);return n.re.no_http||(n.re.no_http=new RegExp("^"+n.re.src_auth+"(?:localhost|(?:(?:"+n.re.src_domain+")\\.)+"+n.re.src_domain_root+")"+n.re.src_port+n.re.src_host_terminator+n.re.src_path,"i")),n.re.no_http.test(r)?e>=3&&":"===t[e-3]?0:e>=3&&"/"===t[e-3]?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(t,e,n){var r=t.slice(e);return n.re.mailto||(n.re.mailto=new RegExp("^"+n.re.src_email_name+"@"+n.re.src_host_strict,"i")),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},c="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",h="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function l(t){var e=t.re=n("sRdV")(t.__opts__),r=t.__tlds__.slice();function s(t){return t.replace("%TLDS%",e.src_tlds)}t.onCompile(),t.__tlds_replaced__||r.push(c),r.push(e.src_xn),e.src_tlds=r.join("|"),e.email_fuzzy=RegExp(s(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(s(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(s(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(s(e.tpl_host_fuzzy_test),"i");var u=[];function h(t,e){throw new Error('(LinkifyIt) Invalid schema "'+t+'": '+e)}t.__compiled__={},Object.keys(t.__schemas__).forEach((function(e){var n=t.__schemas__[e];if(null!==n){var r={validate:null,link:null};if(t.__compiled__[e]=r,"[object Object]"===i(n))return!function(t){return"[object RegExp]"===i(t)}(n.validate)?o(n.validate)?r.validate=n.validate:h(e,n):r.validate=function(t){return function(e,n){var r=e.slice(n);return t.test(r)?r.match(t)[0].length:0}}(n.validate),void(o(n.normalize)?r.normalize=n.normalize:n.normalize?h(e,n):r.normalize=function(t,e){e.normalize(t)});!function(t){return"[object String]"===i(t)}(n)?h(e,n):u.push(e)}})),u.forEach((function(e){t.__compiled__[t.__schemas__[e]]&&(t.__compiled__[e].validate=t.__compiled__[t.__schemas__[e]].validate,t.__compiled__[e].normalize=t.__compiled__[t.__schemas__[e]].normalize)})),t.__compiled__[""]={validate:null,normalize:function(t,e){e.normalize(t)}};var l=Object.keys(t.__compiled__).filter((function(e){return e.length>0&&t.__compiled__[e]})).map(a).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+l+")","i"),t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+l+")","ig"),t.re.pretest=RegExp("("+t.re.schema_test.source+")|("+t.re.host_fuzzy_test.source+")|@","i"),function(t){t.__index__=-1,t.__text_cache__=""}(t)}function f(t,e){var n=t.__index__,r=t.__last_index__,i=t.__text_cache__.slice(n,r);this.schema=t.__schema__.toLowerCase(),this.index=n+e,this.lastIndex=r+e,this.raw=i,this.text=i,this.url=i}function p(t,e){var n=new f(t,e);return t.__compiled__[n.schema].normalize(n,t),n}function d(t,e){if(!(this instanceof d))return new d(t,e);var n;e||(n=t,Object.keys(n||{}).reduce((function(t,e){return t||s.hasOwnProperty(e)}),!1)&&(e=t,t={})),this.__opts__=r({},s,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=r({},u,t),this.__compiled__={},this.__tlds__=h,this.__tlds_replaced__=!1,this.re={},l(this)}d.prototype.add=function(t,e){return this.__schemas__[t]=e,l(this),this},d.prototype.set=function(t){return this.__opts__=r(this.__opts__,t),this},d.prototype.test=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return!1;var e,n,r,i,o,a,s,u;if(this.re.schema_test.test(t))for((s=this.re.schema_search).lastIndex=0;null!==(e=s.exec(t));)if(i=this.testSchemaAt(t,e[2],s.lastIndex)){this.__schema__=e[2],this.__index__=e.index+e[1].length,this.__last_index__=e.index+e[0].length+i;break}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(u=t.search(this.re.host_fuzzy_test))>=0&&(this.__index__<0||u<this.__index__)&&null!==(n=t.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))&&(o=n.index+n[1].length,(this.__index__<0||o<this.__index__)&&(this.__schema__="",this.__index__=o,this.__last_index__=n.index+n[0].length)),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&t.indexOf("@")>=0&&null!==(r=t.match(this.re.email_fuzzy))&&(o=r.index+r[1].length,a=r.index+r[0].length,(this.__index__<0||o<this.__index__||o===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=o,this.__last_index__=a)),this.__index__>=0},d.prototype.pretest=function(t){return this.re.pretest.test(t)},d.prototype.testSchemaAt=function(t,e,n){return this.__compiled__[e.toLowerCase()]?this.__compiled__[e.toLowerCase()].validate(t,n,this):0},d.prototype.match=function(t){var e=0,n=[];this.__index__>=0&&this.__text_cache__===t&&(n.push(p(this,e)),e=this.__last_index__);for(var r=e?t.slice(e):t;this.test(r);)n.push(p(this,e)),r=r.slice(this.__last_index__),e+=this.__last_index__;return n.length?n:null},d.prototype.tlds=function(t,e){return t=Array.isArray(t)?t:[t],e?(this.__tlds__=this.__tlds__.concat(t).sort().filter((function(t,e,n){return t!==n[e-1]})).reverse(),l(this),this):(this.__tlds__=t.slice(),this.__tlds_replaced__=!0,l(this),this)},d.prototype.normalize=function(t){t.schema||(t.url="http://"+t.url),"mailto:"!==t.schema||/^mailto:/i.test(t.url)||(t.url="mailto:"+t.url)},d.prototype.onCompile=function(){},t.exports=d},"+ar0":function(t,e,n){var r=n("P8UN");r(r.S+r.F*!n("QPJK"),"Object",{defineProperties:n("YmeT")})},"1/Ks":function(t,e,n){"use strict";n("EU/P")("trimLeft",(function(t){return function(){return t(this,1)}}),"trimStart")},"4w6A":function(t,e,n){var r,i;n("HXzo"),n("HQhv"),n("sc67"),n("sC2a"),n("n7j8"),r=this,i=function(t){var e=function t(e){return new t.lib.init(e)};function n(t,e){return!(!t||"string"!=typeof e||!(t.className&&t.className.trim().split(/\s+/gi).indexOf(e)>-1))}return e.lib=e.prototype={toastify:"1.6.1",constructor:e,init:function(t){return t||(t={}),this.options={},this.toastElement=null,this.options.text=t.text||"Hi there!",this.options.duration=t.duration||3e3,this.options.selector=t.selector,this.options.callback=t.callback||function(){},this.options.destination=t.destination,this.options.newWindow=t.newWindow||!1,this.options.close=t.close||!1,this.options.gravity="bottom"==t.gravity?"toastify-bottom":"toastify-top",this.options.positionLeft=t.positionLeft||!1,this.options.position=t.position||"",this.options.backgroundColor=t.backgroundColor,this.options.avatar=t.avatar||"",this.options.className=t.className||"",this.options.stopOnFocus=void 0===t.stopOnFocus||t.stopOnFocus,this},buildToast:function(){if(!this.options)throw"Toastify is not initialized";var t=document.createElement("div");if(t.className="toastify on "+this.options.className,this.options.position?t.className+=" toastify-"+this.options.position:!0===this.options.positionLeft?(t.className+=" toastify-left",console.warn("Property `positionLeft` will be depreciated in further versions. Please use `position` instead.")):t.className+=" toastify-right",t.className+=" "+this.options.gravity,this.options.backgroundColor&&(t.style.background=this.options.backgroundColor),t.innerHTML=this.options.text,""!==this.options.avatar){var e=document.createElement("img");e.src=this.options.avatar,e.className="toastify-avatar","left"==this.options.position||!0===this.options.positionLeft?t.appendChild(e):t.insertAdjacentElement("beforeend",e)}if(!0===this.options.close){var n=document.createElement("span");if(n.innerHTML="✖",n.className="toast-close",n.addEventListener("click",function(t){t.stopPropagation(),this.removeElement(t.target.parentElement),window.clearTimeout(t.target.parentElement.timeOutValue)}.bind(this)),this.options.stopOnFocus&&this.options.duration>0){var r=this;t.addEventListener("mouseover",(function(e){window.clearTimeout(t.timeOutValue)})),t.addEventListener("mouseleave",(function(){t.timeOutValue=window.setTimeout((function(){r.removeElement(t)}),r.options.duration)}))}var i=window.innerWidth>0?window.innerWidth:screen.width;("left"==this.options.position||!0===this.options.positionLeft)&&i>360?t.insertAdjacentElement("afterbegin",n):t.appendChild(n)}return void 0!==this.options.destination&&t.addEventListener("click",function(t){t.stopPropagation(),!0===this.options.newWindow?window.open(this.options.destination,"_blank"):window.location=this.options.destination}.bind(this)),t},showToast:function(){var t;if(this.toastElement=this.buildToast(),!(t=void 0===this.options.selector?document.body:document.getElementById(this.options.selector)))throw"Root element is not defined";return t.insertBefore(this.toastElement,t.firstChild),e.reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout(function(){this.removeElement(this.toastElement)}.bind(this),this.options.duration)),this},hideToast:function(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this.removeElement(this.toastElement)},removeElement:function(t){t.className=t.className.replace(" on",""),window.setTimeout(function(){t.parentNode.removeChild(t),this.options.callback.call(t),e.reposition()}.bind(this),400)}},e.reposition=function(){for(var t,e={top:15,bottom:15},r={top:15,bottom:15},i={top:15,bottom:15},o=document.getElementsByClassName("toastify"),a=0;a<o.length;a++){t=!0===n(o[a],"toastify-top")?"toastify-top":"toastify-bottom";var s=o[a].offsetHeight;t=t.substr(9,t.length-1),(window.innerWidth>0?window.innerWidth:screen.width)<=360?(o[a].style[t]=i[t]+"px",i[t]+=s+15):!0===n(o[a],"toastify-left")?(o[a].style[t]=e[t]+"px",e[t]+=s+15):(o[a].style[t]=r[t]+"px",r[t]+=s+15)}return this},e.lib.init.prototype=e.lib,e},t.exports?t.exports=i():r.Toastify=i()},"5x/H":function(t,e,n){"use strict";n("6Joi")},"6Joi":function(t,e,n){"use strict";(function(t){n("m210"),n("4DPX"),n("iuFa"),n("sPse"),n("pQ2P"),n("klQ5"),n("cxuS"),n("ToIb"),n("MIFh"),n("pncC"),n("m5Zt"),n("R0hF"),n("v9g0"),n("YbXK"),n("xJgp"),n("WevN"),n("TAD1"),n("Ll4R"),n("U6Bt"),n("rzGZ"),n("Dq+y"),n("zGcK"),n("1dPr"),n("n7j8"),n("6kNP"),n("sC2a"),n("HQhv"),n("OeI1"),n("JHok"),n("CtJk"),n("sc67"),n("wZFJ"),n("YBKJ"),n("q8oJ"),n("C9fy"),n("8npG"),n("pJf4"),n("AqHK"),n("R48M"),Object.defineProperty(e,"__esModule",{value:!0});var r,i,o=(r=n("wj3C"))&&"object"==typeof r&&"default"in r?r.default:r,a=n("mrSG"),s=n("q/0M"),u=n("zVF4"),c=n("S+S0"),h=n("x7I3"),l=o.SDK_VERSION,f=new s.Logger("@firebase/firestore");function p(){return f.logLevel===s.LogLevel.DEBUG?i.DEBUG:f.logLevel===s.LogLevel.SILENT?i.SILENT:i.ERROR}function d(t){switch(t){case i.DEBUG:f.logLevel=s.LogLevel.DEBUG;break;case i.ERROR:f.logLevel=s.LogLevel.ERROR;break;case i.SILENT:f.logLevel=s.LogLevel.SILENT;break;default:f.error("Firestore ("+l+"): Invalid value passed to `setLogLevel`")}}function m(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(f.logLevel<=s.LogLevel.DEBUG){var i=n.map(g);f.debug.apply(f,a.__spreadArrays(["Firestore ("+l+") ["+t+"]: "+e],i))}}function y(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(f.logLevel<=s.LogLevel.ERROR){var r=e.map(g);f.error.apply(f,a.__spreadArrays(["Firestore ("+l+"): "+t],r))}}function g(t){if("string"==typeof t)return t;var e=b.getPlatform();try{return e.formatJSON(t)}catch(n){return t}}function v(t){var e="FIRESTORE ("+l+") INTERNAL ASSERTION FAILED: "+t;throw y(e),new Error(e)}function _(t,e){t||v(e)}!function(t){t[t.DEBUG=0]="DEBUG",t[t.ERROR=1]="ERROR",t[t.SILENT=2]="SILENT"}(i||(i={}));var b=function(){function t(){}return t.setPlatform=function(e){t.platform&&v("Platform already defined"),t.platform=e},t.getPlatform=function(){return t.platform||v("Platform not set"),t.platform},t}();function w(){return b.getPlatform().emptyByteString}var E={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"},T=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 a.__extends(e,t),e}(Error);function C(t,e){function n(){var t="This constructor is private.";throw e&&(t+=" ",t+=e),new T(E.INVALID_ARGUMENT,t)}for(var r in n.prototype=t.prototype,t)t.hasOwnProperty(r)&&(n[r]=t[r]);return n}function S(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function I(t,e){return void 0!==t?t:e}function D(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 N(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function A(t){for(var e in _(null!=t&&"object"==typeof t,"isEmpty() expects object parameter."),t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function k(t,e){if(0!==e.length)throw new T(E.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+Y(e.length,"argument")+".")}function R(t,e,n){if(e.length!==n)throw new T(E.INVALID_ARGUMENT,"Function "+t+"() requires "+Y(n,"argument")+", but was called with "+Y(e.length,"argument")+".")}function O(t,e,n){if(e.length<n)throw new T(E.INVALID_ARGUMENT,"Function "+t+"() requires at least "+Y(n,"argument")+", but was called with "+Y(e.length,"argument")+".")}function x(t,e,n,r){if(e.length<n||e.length>r)throw new T(E.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+Y(e.length,"argument")+".")}function P(t,e,n,r){B(t,e,G(n)+" argument",r)}function M(t,e,n,r){void 0!==r&&P(t,e,n,r)}function L(t,e,n,r){B(t,e,n+" option",r)}function F(t,e,n,r){void 0!==r&&L(t,e,n,r)}function U(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){if(!(r instanceof Array))throw new T(E.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+z(r));for(var o=0;o<r.length;++o)if(!i(r[o]))throw new T(E.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be "+n+", but the value at index "+o+" was: "+z(r[o]))}(t,e,n,r,i)}function q(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){for(var o=[],a=0,s=i;a<s.length;a++){var u=s[a];if(u===r)return;o.push(z(u))}var c=z(r);throw new T(E.INVALID_ARGUMENT,"Invalid value "+c+" provided to function "+t+'() for option "'+n+'". Acceptable values: '+o.join(", "))}(t,0,n,r,i)}function V(t,e,n,r){if(!e.some((function(t){return t===r})))throw new T(E.INVALID_ARGUMENT,"Invalid value "+z(r)+" provided to function "+t+"() for its "+G(n)+" argument. Acceptable values: "+e.join(", "))}function B(t,e,n,r){if(!("object"===e?j(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=z(r);throw new T(E.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function j(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function z(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":v("Unknown wrong type: "+typeof t)}function W(t,e,n){if(void 0===n)throw new T(E.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+G(e)+" argument, but it was undefined.")}function Q(t,e,n){N(e,(function(e,r){if(n.indexOf(e)<0)throw new T(E.INVALID_ARGUMENT,"Unknown option '"+e+"' passed to function "+t+"(). Available options: "+n.join(", "))}))}function K(t,e,n,r){var i=z(r);return new T(E.INVALID_ARGUMENT,"Function "+t+"() requires its "+G(n)+" argument to be a "+e+", but it was: "+i)}function H(t,e,n){if(n<=0)throw new T(E.INVALID_ARGUMENT,'Function "'+t+'()" requires its '+G(e)+" argument to be a positive number, but it was: "+n+".")}function G(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}}function Y(t,e){return t+" "+e+(1===t?"":"s")}var X=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 _(20===e.length,"Invalid auto ID: "+e),e},t}();function J(t,e){return t<e?-1:t>e?1:0}function Z(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 $(t){return t+"\0"}function tt(){if("undefined"==typeof Uint8Array)throw new T(E.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function et(){if(!b.getPlatform().base64Available)throw new T(E.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var nt,rt=function(){function t(t){et(),this._binaryString=t}return t.fromBase64String=function(e){R("Blob.fromBase64String",arguments,1),P("Blob.fromBase64String","string",1,e),et();try{var n=b.getPlatform().atob(e);return new t(n)}catch(r){throw new T(E.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+r)}},t.fromUint8Array=function(e){if(R("Blob.fromUint8Array",arguments,1),tt(),!(e instanceof Uint8Array))throw K("Blob.fromUint8Array","Uint8Array",1,e);var n=Array.prototype.map.call(e,(function(t){return String.fromCharCode(t)})).join("");return new t(n)},t.prototype.toBase64=function(){return R("Blob.toBase64",arguments,0),et(),b.getPlatform().btoa(this._binaryString)},t.prototype.toUint8Array=function(){R("Blob.toUint8Array",arguments,0),tt();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 J(this._binaryString,t._binaryString)},t}(),it=C(rt,"Use Blob.fromUint8Array() or Blob.fromBase64String() instead."),ot=function(t,e,n,r,i){this.databaseId=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i},at="(default)",st=function(){function t(t,e){this.projectId=t,this.database=e||at}return Object.defineProperty(t.prototype,"isDefaultDatabase",{get:function(){return this.database===at},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 J(this.projectId,t.projectId)||J(this.database,t.database)},t}(),ut=function(){function t(t,e){var n=this;this.previousValue=t,e&&(e.sequenceNumberHandler=function(t){return n.setPreviousValue(t)},this.writeNewSequenceNumber=function(t){return e.writeSequenceNumber(t)})}return t.prototype.setPreviousValue=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},t.prototype.next=function(){var t=++this.previousValue;return this.writeNewSequenceNumber&&this.writeNewSequenceNumber(t),t},t.INVALID=-1,t}(),ct=function(){function t(t,e,n){void 0===e?e=0:e>t.length&&v("offset "+e+" out of range "+t.length),void 0===n?n=t.length-e:n>t.length-e&&v("length "+n+" out of range "+(t.length-e)),this.segments=t,this.offset=e,this.len=n}return 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)})):n.push(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,_(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 _(!this.isEmpty(),"Can't call popLast() on empty path"),this.construct(this.segments,this.offset,this.length-1)},t.prototype.firstSegment=function(){return _(!this.isEmpty(),"Can't call firstSegment() on empty path"),this.segments[this.offset]},t.prototype.lastSegment=function(){return this.get(this.length-1)},t.prototype.get=function(t){return _(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}(),ht=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a.__extends(e,t),e.prototype.construct=function(t,n,r){return new e(t,n,r)},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 T(E.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}(ct),lt=/^[_a-zA-Z][_a-zA-Z0-9]*$/,ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a.__extends(e,t),e.prototype.construct=function(t,n,r){return new e(t,n,r)},e.isValidIdentifier=function(t){return lt.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 T(E.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'");n.push(r),r=""},a=!1;i<t.length;){var s=t[i];if("\\"===s){if(i+1===t.length)throw new T(E.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var u=t[i+1];if("\\"!==u&&"."!==u&&"`"!==u)throw new T(E.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);r+=u,i+=2}else"`"===s?(a=!a,i++):"."!==s||a?(r+=s,i++):(o(),i++)}if(o(),a)throw new T(E.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)},e.EMPTY_PATH=new e([]),e}(ct),pt=function(){function t(e){this.path=e,_(t.isDocumentKey(e),"Invalid DocumentKey with an odd number of segments: "+e.toArray().join("/"))}return t.prototype.hasCollectionId=function(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t},t.prototype.isEqual=function(t){return null!==t&&0===ht.comparator(this.path,t.path)},t.prototype.toString=function(){return this.path.toString()},t.comparator=function(t,e){return ht.comparator(t.path,e.path)},t.isDocumentKey=function(t){return t.length%2==0},t.fromSegments=function(e){return new t(new ht(e.slice()))},t.fromPathString=function(e){return new t(ht.fromString(e))},t.EMPTY=new t(new ht([])),t}(),dt=function(){var t=this;this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))};!function(t){t.All="all",t.ListenStreamIdle="listen_stream_idle",t.ListenStreamConnectionBackoff="listen_stream_connection_backoff",t.WriteStreamIdle="write_stream_idle",t.WriteStreamConnectionBackoff="write_stream_connection_backoff",t.OnlineStateTimeout="online_state_timeout",t.ClientMetadataRefresh="client_metadata_refresh",t.LruGarbageCollection="lru_garbage_collection",t.RetryTransaction="retry_transaction"}(nt||(nt={}));var mt=function(){function t(t,e,n,r,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new dt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.catch=this.deferred.promise.catch.bind(this.deferred.promise),this.deferred.promise.catch((function(t){}))}return t.createAndSchedule=function(e,n,r,i,o){var a=new t(e,n,Date.now()+r,i,o);return a.start(r),a},t.prototype.start=function(t){var e=this;this.timerHandle=setTimeout((function(){return e.handleDelayElapsed()}),t)},t.prototype.skipDelay=function(){return this.handleDelayElapsed()},t.prototype.cancel=function(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new T(E.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},t.prototype.handleDelayElapsed=function(){var t=this;this.asyncQueue.enqueueAndForget((function(){return null!==t.timerHandle?(t.clearTimeout(),t.op().then((function(e){return t.deferred.resolve(e)}))):Promise.resolve()}))},t.prototype.clearTimeout=function(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)},t}(),yt=function(){function t(){this.tail=Promise.resolve(),this._isShuttingDown=!1,this.delayedOperations=[],this.failure=null,this.operationInProgress=!1,this.timerIdsToSkip=[]}return Object.defineProperty(t.prototype,"isShuttingDown",{get:function(){return this._isShuttingDown},enumerable:!0,configurable:!0}),t.prototype.enqueueAndForget=function(t){this.enqueue(t)},t.prototype.enqueueAndForgetEvenAfterShutdown=function(t){this.verifyNotFailed(),this.enqueueInternal(t)},t.prototype.enqueueEvenAfterShutdown=function(t){return this.verifyNotFailed(),this.enqueueInternal(t)},t.prototype.enqueueAndInitiateShutdown=function(t){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(e){switch(e.label){case 0:return this.verifyNotFailed(),this._isShuttingDown?[3,2]:(this._isShuttingDown=!0,[4,this.enqueueEvenAfterShutdown(t)]);case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.enqueue=function(t){return this.verifyNotFailed(),this._isShuttingDown?new Promise((function(t){})):this.enqueueInternal(t)},t.prototype.enqueueInternal=function(t){var e=this,n=this.tail.then((function(){return e.operationInProgress=!0,t().catch((function(t){e.failure=t,e.operationInProgress=!1;var n=t.stack||t.message||"";throw y("INTERNAL UNHANDLED ERROR: ",n),n.indexOf("Firestore Test Simulated Error")<0&&setTimeout((function(){throw t}),0),t})).then((function(t){return e.operationInProgress=!1,t}))}));return this.tail=n,n},t.prototype.enqueueAfterDelay=function(t,e,n){var r=this;this.verifyNotFailed(),_(e>=0,"Attempted to schedule an operation with a negative delay of "+e),this.timerIdsToSkip.indexOf(t)>-1&&(e=0);var i=mt.createAndSchedule(this,t,e,n,(function(t){return r.removeDelayedOperation(t)}));return this.delayedOperations.push(i),i},t.prototype.verifyNotFailed=function(){this.failure&&v("AsyncQueue is already failed: "+(this.failure.stack||this.failure.message))},t.prototype.verifyOperationInProgress=function(){_(this.operationInProgress,"verifyOpInProgress() called when no op in progress on this queue.")},t.prototype.drain=function(){return this.enqueueEvenAfterShutdown((function(){return Promise.resolve()}))},t.prototype.containsDelayedOperation=function(t){for(var e=0,n=this.delayedOperations;e<n.length;e++){if(n[e].timerId===t)return!0}return!1},t.prototype.runDelayedOperationsEarly=function(t){var e=this;return this.drain().then((function(){_(t===nt.All||e.containsDelayedOperation(t),"Attempted to drain to missing operation "+t),e.delayedOperations.sort((function(t,e){return t.targetTimeMs-e.targetTimeMs}));for(var n=0,r=e.delayedOperations;n<r.length;n++){var i=r[n];if(i.skipDelay(),t!==nt.All&&i.timerId===t)break}return e.drain()}))},t.prototype.skipDelaysForTimerId=function(t){this.timerIdsToSkip.push(t)},t.prototype.removeDelayedOperation=function(t){var e=this.delayedOperations.indexOf(t);_(e>=0,"Delayed operation not found."),this.delayedOperations.splice(e,1)},t}(),gt="",vt="",_t="",bt="";function wt(t){for(var e="",n=0;n<t.length;n++)e.length>0&&(e=Tt(e)),e=Et(t.get(n),e);return Tt(e)}function Et(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+=gt+_t;break;case gt:n+=gt+bt;break;default:n+=o}}return n}function Tt(t){return t+gt+vt}function Ct(t){var e=t.length;if(_(e>=2,"Invalid path "+t),2===e)return _(t.charAt(0)===gt&&t.charAt(1)===vt,"Non-empty path "+t+" had length 2"),ht.EMPTY_PATH;for(var n=e-2,r=[],i="",o=0;o<e;){var a=t.indexOf(gt,o);switch((a<0||a>n)&&v('Invalid encoded resource path: "'+t+'"'),t.charAt(a+1)){case vt:var s=t.substring(o,a),u=void 0;0===i.length?u=s:(u=i+=s,i=""),r.push(u);break;case _t:i+=t.substring(o,a),i+="\0";break;case bt:i+=t.substring(o,a+1);break;default:v('Invalid encoded resource path: "'+t+'"')}o=a+2}return new ht(r)}var St=function(){function t(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new T(E.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new T(E.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new T(E.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new T(E.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?J(this.nanoseconds,t.nanoseconds):J(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}(),It=function(){function t(t){this.timestamp=t}return t.fromMicroseconds=function(e){var n=Math.floor(e/1e6);return new t(new St(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 St(0,0)),t}(),Dt=function(){function t(t,e){this.comparator=t,this.root=e||At.EMPTY}return t.prototype.insert=function(e,n){return new t(this.comparator,this.root.insert(e,n,this.comparator).copy(null,null,At.BLACK,null,null))},t.prototype.remove=function(e){return new t(this.comparator,this.root.remove(e,this.comparator).copy(null,null,At.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.toString=function(){var t=[];return this.inorderTraversal((function(e,n){return t.push(e+":"+n),!1})),"{"+t.join(", ")+"}"},t.prototype.reverseTraversal=function(t){return this.root.reverseTraversal(t)},t.prototype.getIterator=function(){return new Nt(this.root,null,this.comparator,!1)},t.prototype.getIteratorFrom=function(t){return new Nt(this.root,t,this.comparator,!1)},t.prototype.getReverseIterator=function(){return new Nt(this.root,null,this.comparator,!0)},t.prototype.getReverseIteratorFrom=function(t){return new Nt(this.root,t,this.comparator,!0)},t}(),Nt=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(){_(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}(),At=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 v("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed())throw v("Right child of ("+this.key+","+this.value+") is red");var t=this.left.check();if(t!==this.right.check())throw v("Black depths differ");return t+(this.isRed()?0:1)},t.EMPTY=null,t.RED=!0,t.BLACK=!1,t}(),kt=function(){function t(){this.size=0}return Object.defineProperty(t.prototype,"key",{get:function(){throw v("LLRBEmptyNode has no key.")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){throw v("LLRBEmptyNode has no value.")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){throw v("LLRBEmptyNode has no color.")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){throw v("LLRBEmptyNode has no left child.")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){throw v("LLRBEmptyNode has no right child.")},enumerable:!0,configurable:!0}),t.prototype.copy=function(t,e,n,r,i){return this},t.prototype.insert=function(t,e,n){return new At(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}();At.EMPTY=new kt;var Rt=function(){function t(t){this.comparator=t,this.data=new Dt(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 Ot(this.data.getIterator())},t.prototype.getIteratorFrom=function(t){return new Ot(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}(),Ot=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}(),xt=new Dt(pt.comparator);function Pt(){return xt}function Mt(){return Pt()}var Lt=new Dt(pt.comparator);function Ft(){return Lt}var Ut=new Dt(pt.comparator);function qt(){return Ut}var Vt=new Rt(pt.comparator);function Bt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=Vt,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var jt=new Rt(J);function zt(){return jt}var Wt=function(){function t(t,e,n,r){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=r,_(r.length>0,"Cannot create an empty mutation batch")}return t.prototype.applyToRemoteDocument=function(t,e,n){e&&_(e.key.isEqual(t),"applyToRemoteDocument: key "+t+" should match maybeDoc key\n "+e.key);var r=n.mutationResults;_(r.length===this.mutations.length,"Mismatch between mutations length\n ("+this.mutations.length+") and mutation results length\n ("+r.length+").");for(var i=0;i<this.mutations.length;i++){var o=this.mutations[i];if(o.key.isEqual(t)){var a=r[i];e=o.applyToRemoteDocument(e,a)}}return e},t.prototype.applyToLocalView=function(t,e){e&&_(e.key.isEqual(t),"applyToLocalDocument: key "+t+" should match maybeDoc key\n "+e.key);for(var n=0,r=this.baseMutations;n<r.length;n++){(s=r[n]).key.isEqual(t)&&(e=s.applyToLocalView(e,e,this.localWriteTime))}for(var i=e,o=0,a=this.mutations;o<a.length;o++){var s;(s=a[o]).key.isEqual(t)&&(e=s.applyToLocalView(e,i,this.localWriteTime))}return e},t.prototype.applyToLocalDocumentSet=function(t){var e=this,n=t;return this.mutations.forEach((function(r){var i=e.applyToLocalView(r.key,t.get(r.key));i&&(n=n.insert(r.key,i))})),n},t.prototype.keys=function(){return this.mutations.reduce((function(t,e){return t.add(e.key)}),Bt())},t.prototype.isEqual=function(t){return this.batchId===t.batchId&&Z(this.mutations,t.mutations)&&Z(this.baseMutations,t.baseMutations)},t}(),Qt=function(){function t(t,e,n,r,i){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.streamToken=r,this.docVersions=i}return t.from=function(e,n,r,i){_(e.mutations.length===r.length,"Mutations sent "+e.mutations.length+" must equal results received "+r.length);for(var o=qt(),a=e.mutations,s=0;s<a.length;s++)o=o.insert(a[s].key,r[s].version);return new t(e,n,r,i,o)},t}(),Kt=function(){function t(t){var e=this;this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t((function(t){e.isDone=!0,e.result=t,e.nextCallback&&e.nextCallback(t)}),(function(t){e.isDone=!0,e.error=t,e.catchCallback&&e.catchCallback(t)}))}return t.prototype.catch=function(t){return this.next(void 0,t)},t.prototype.next=function(e,n){var r=this;return this.callbackAttached&&v("Called next() or catch() twice for PersistencePromise"),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(e,this.result):new t((function(t,i){r.nextCallback=function(n){r.wrapSuccess(e,n).next(t,i)},r.catchCallback=function(e){r.wrapFailure(n,e).next(t,i)}}))},t.prototype.toPromise=function(){var t=this;return new Promise((function(e,n){t.next(e,n)}))},t.prototype.wrapUserFunction=function(e){try{var n=e();return n instanceof t?n:t.resolve(n)}catch(r){return t.reject(r)}},t.prototype.wrapSuccess=function(e,n){return e?this.wrapUserFunction((function(){return e(n)})):t.resolve(n)},t.prototype.wrapFailure=function(e,n){return e?this.wrapUserFunction((function(){return e(n)})):t.reject(n)},t.resolve=function(e){return new t((function(t,n){t(e)}))},t.reject=function(e){return new t((function(t,n){n(e)}))},t.waitFor=function(e){return new t((function(t,n){var r=0,i=0,o=!1;e.forEach((function(e){++r,e.next((function(){++i,o&&i===r&&t()}),(function(t){return n(t)}))})),o=!0,i===r&&t()}))},t.or=function(e){for(var n=t.resolve(!1),r=function(e){n=n.next((function(n){return n?t.resolve(n):e()}))},i=0,o=e;i<o.length;i++){r(o[i])}return n},t.forEach=function(t,e){var n=this,r=[];return t.forEach((function(t,i){r.push(e.call(n,t,i))})),this.waitFor(r)},t}(),Ht="SimpleDb",Gt=function(){function e(t){this.db=t,12.2===e.getIOSVersion(u.getUA())&&y("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}return e.openOrCreate=function(t,n,r){return _(e.isAvailable(),"IndexedDB not supported in current environment."),m(Ht,"Opening database:",t),new Kt((function(i,o){var a=window.indexedDB.open(t,n);a.onsuccess=function(t){var n=t.target.result;i(new e(n))},a.onblocked=function(){o(new T(E.FAILED_PRECONDITION,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},a.onerror=function(t){var e=t.target.error;"VersionError"===e.name?o(new T(E.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):o(e)},a.onupgradeneeded=function(e){m(Ht,'Database "'+t+'" requires upgrade from version:',e.oldVersion);var n=e.target.result;r.createOrUpgrade(n,a.transaction,e.oldVersion,rn).next((function(){m(Ht,"Database upgrade to version "+rn+" complete")}))}})).toPromise()},e.delete=function(t){return m(Ht,"Removing database:",t),Zt(window.indexedDB.deleteDatabase(t)).toPromise()},e.isAvailable=function(){if("undefined"==typeof window||null==window.indexedDB)return!1;if(e.isMockPersistence())return!0;if(void 0===window.navigator)return!1;var t=u.getUA(),n=e.getIOSVersion(t),r=0<n&&n<10,i=e.getAndroidVersion(t),o=0<i&&i<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||r||o)},e.isMockPersistence=function(){var e;return void 0!==t&&"YES"===(null===(e={})||void 0===e?void 0:e.USE_MOCK_PERSISTENCE)},e.getStore=function(t,e){return t.store(e)},e.getIOSVersion=function(t){var e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)},e.getAndroidVersion=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},e.prototype.setVersionChangeListener=function(t){this.db.onversionchange=function(e){return t(e)}},e.prototype.runTransaction=function(t,e,n){return a.__awaiter(this,void 0,void 0,(function(){var r,i,o,s,u,c;return a.__generator(this,(function(h){switch(h.label){case 0:r=t.startsWith("readonly"),i=t.endsWith("idempotent"),o=0,s=function(){var t,s,c,h;return a.__generator(this,(function(a){switch(a.label){case 0:++o,t=Xt.open(u.db,r?"readonly":"readwrite",e),a.label=1;case 1:return a.trys.push([1,3,,4]),(s=n(t).catch((function(e){return t.abort(e),Kt.reject(e)})).toPromise()).catch((function(){})),[4,t.completionPromise];case 2:return a.sent(),[2,{value:s}];case 3:return c=a.sent(),h=i&&"FirebaseError"!==c.name&&o<3,m(Ht,"Transaction failed with error: %s. Retrying: %s.",c.message,h),h?[3,4]:[2,{value:Promise.reject(c)}];case 4:return[2]}}))},u=this,h.label=1;case 1:return[5,s()];case 2:return"object"==typeof(c=h.sent())?[2,c.value]:[3,1];case 3:return[2]}}))}))},e.prototype.close=function(){this.db.close()},e}(),Yt=function(){function t(t){this.dbCursor=t,this.shouldStop=!1,this.nextKey=null}return Object.defineProperty(t.prototype,"isDone",{get:function(){return this.shouldStop},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"skipToKey",{get:function(){return this.nextKey},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cursor",{set:function(t){this.dbCursor=t},enumerable:!0,configurable:!0}),t.prototype.done=function(){this.shouldStop=!0},t.prototype.skip=function(t){this.nextKey=t},t.prototype.delete=function(){return Zt(this.dbCursor.delete())},t}(),Xt=function(){function t(t){var e=this;this.transaction=t,this.aborted=!1,this.completionDeferred=new dt,this.transaction.oncomplete=function(){e.completionDeferred.resolve()},this.transaction.onabort=function(){t.error?e.completionDeferred.reject(t.error):e.completionDeferred.resolve()},this.transaction.onerror=function(t){var n=te(t.target.error);e.completionDeferred.reject(n)}}return t.open=function(e,n,r){return new t(e.transaction(r,n))},Object.defineProperty(t.prototype,"completionPromise",{get:function(){return this.completionDeferred.promise},enumerable:!0,configurable:!0}),t.prototype.abort=function(t){t&&this.completionDeferred.reject(t),this.aborted||(m(Ht,"Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},t.prototype.store=function(t){var e=this.transaction.objectStore(t);return _(!!e,"Object store not part of transaction: "+t),new Jt(e)},t}(),Jt=function(){function t(t){this.store=t}return t.prototype.put=function(t,e){var n;return void 0!==e?(m(Ht,"PUT",this.store.name,t,e),n=this.store.put(e,t)):(m(Ht,"PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),Zt(n)},t.prototype.add=function(t){return m(Ht,"ADD",this.store.name,t,t),Zt(this.store.add(t))},t.prototype.get=function(t){var e=this;return Zt(this.store.get(t)).next((function(n){return void 0===n&&(n=null),m(Ht,"GET",e.store.name,t,n),n}))},t.prototype.delete=function(t){return m(Ht,"DELETE",this.store.name,t),Zt(this.store.delete(t))},t.prototype.count=function(){return m(Ht,"COUNT",this.store.name),Zt(this.store.count())},t.prototype.loadAll=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.iterateCursor(n,(function(t,e){r.push(e)})).next((function(){return r}))},t.prototype.deleteAll=function(t,e){m(Ht,"DELETE ALL",this.store.name);var n=this.options(t,e);n.keysOnly=!1;var r=this.cursor(n);return this.iterateCursor(r,(function(t,e,n){return n.delete()}))},t.prototype.iterate=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.iterateCursor(r,e)},t.prototype.iterateSerial=function(t){var e=this.cursor({});return new Kt((function(n,r){e.onerror=function(t){var e=te(t.target.error);r(e)},e.onsuccess=function(e){var r=e.target.result;r?t(r.primaryKey,r.value).next((function(t){t?r.continue():n()})):n()}}))},t.prototype.iterateCursor=function(t,e){var n=[];return new Kt((function(r,i){t.onerror=function(t){i(t.target.error)},t.onsuccess=function(t){var i=t.target.result;if(i){var o=new Yt(i),a=e(i.primaryKey,i.value,o);if(a instanceof Kt){var s=a.catch((function(t){return o.done(),Kt.reject(t)}));n.push(s)}o.isDone?r():null===o.skipToKey?i.continue():i.continue(o.skipToKey)}else r()}})).next((function(){return Kt.waitFor(n)}))},t.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:(_(void 0===e,"3rd argument must not be defined if 2nd is a range."),e=t)),{index:n,range:e}},t.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.keysOnly?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},t}();function Zt(t){return new Kt((function(e,n){t.onsuccess=function(t){var n=t.target.result;e(n)},t.onerror=function(t){var e=te(t.target.error);n(e)}}))}var $t=!1;function te(t){var e=Gt.getIOSVersion(u.getUA());if(e>=12.2&&e<13){var n="An internal error was encountered in the Indexed Database server";if(t.message.indexOf(n)>=0){var r=new T("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '"+n+"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");return $t||($t=!0,setTimeout((function(){throw r}),0)),r}}return t}var ee=function(){function t(t,e,n,r){this.userId=t,this.serializer=e,this.indexManager=n,this.referenceDelegate=r,this.documentKeysByBatchId={}}return t.forUser=function(e,n,r,i){return _(""!==e.uid,"UserID must not be an empty string."),new t(e.isAuthenticated()?e.uid:"",n,r,i)},t.prototype.checkEmpty=function(t){var e=!0,n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return oe(t).iterate({index:cn.userMutationsIndex,range:n},(function(t,n,r){e=!1,r.done()})).next((function(){return e}))},t.prototype.acknowledgeBatch=function(t,e,n){return this.getMutationQueueMetadata(t).next((function(e){return e.lastStreamToken=ie(n),se(t).put(e)}))},t.prototype.getLastStreamToken=function(t){return this.getMutationQueueMetadata(t).next((function(t){return t.lastStreamToken}))},t.prototype.setLastStreamToken=function(t,e){return this.getMutationQueueMetadata(t).next((function(n){return n.lastStreamToken=ie(e),se(t).put(n)}))},t.prototype.addMutationBatch=function(t,e,n,r){var i=this,o=ae(t),a=oe(t);return a.add({}).next((function(s){_("number"==typeof s,"Auto-generated key is not a number");for(var u=new Wt(s,e,n,r),c=i.serializer.toDbMutationBatch(i.userId,u),h=[],l=new Rt((function(t,e){return J(t.canonicalString(),e.canonicalString())})),f=0,p=r;f<p.length;f++){var d=p[f],m=hn.key(i.userId,d.key.path,s);l=l.add(d.key.path.popLast()),h.push(a.put(c)),h.push(o.put(m,hn.PLACEHOLDER))}return l.forEach((function(e){h.push(i.indexManager.addToCollectionParentIndex(t,e))})),t.addOnCommittedListener((function(){i.documentKeysByBatchId[s]=u.keys()})),Kt.waitFor(h).next((function(){return u}))}))},t.prototype.lookupMutationBatch=function(t,e){var n=this;return oe(t).get(e).next((function(t){return t?(_(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),n.serializer.fromDbMutationBatch(t)):null}))},t.prototype.lookupMutationKeys=function(t,e){var n=this;return this.documentKeysByBatchId[e]?Kt.resolve(this.documentKeysByBatchId[e]):this.lookupMutationBatch(t,e).next((function(t){if(t){var r=t.keys();return n.documentKeysByBatchId[e]=r,r}return null}))},t.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=this,r=e+1,i=IDBKeyRange.lowerBound([this.userId,r]),o=null;return oe(t).iterate({index:cn.userMutationsIndex,range:i},(function(t,e,i){e.userId===n.userId&&(_(e.batchId>=r,"Should have found mutation after "+r),o=n.serializer.fromDbMutationBatch(e)),i.done()})).next((function(){return o}))},t.prototype.getHighestUnacknowledgedBatchId=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),n=-1;return oe(t).iterate({index:cn.userMutationsIndex,range:e,reverse:!0},(function(t,e,r){n=e.batchId,r.done()})).next((function(){return n}))},t.prototype.getAllMutationBatches=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return oe(t).loadAll(cn.userMutationsIndex,n).next((function(t){return t.map((function(t){return e.serializer.fromDbMutationBatch(t)}))}))},t.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,e){var n=this,r=hn.prefixForPath(this.userId,e.path),i=IDBKeyRange.lowerBound(r),o=[];return ae(t).iterate({range:i},(function(r,i,a){var s=r[0],u=r[1],c=r[2],h=Ct(u);if(s===n.userId&&e.path.isEqual(h))return oe(t).get(c).next((function(t){if(!t)throw v("Dangling document-mutation reference found: "+r+" which points to "+c);_(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+c),o.push(n.serializer.fromDbMutationBatch(t))}));a.done()})).next((function(){return o}))},t.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var n=this,r=new Rt(J),i=[];return e.forEach((function(e){var o=hn.prefixForPath(n.userId,e.path),a=IDBKeyRange.lowerBound(o),s=ae(t).iterate({range:a},(function(t,i,o){var a=t[0],s=t[1],u=t[2],c=Ct(s);a===n.userId&&e.path.isEqual(c)?r=r.add(u):o.done()}));i.push(s)})),Kt.waitFor(i).next((function(){return n.lookupMutationBatches(t,r)}))},t.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var n=this;_(!e.isDocumentQuery(),"Document queries shouldn't go down this path"),_(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var r=e.path,i=r.length+1,o=hn.prefixForPath(this.userId,r),a=IDBKeyRange.lowerBound(o),s=new Rt(J);return ae(t).iterate({range:a},(function(t,e,o){var a=t[0],u=t[1],c=t[2],h=Ct(u);a===n.userId&&r.isPrefixOf(h)?h.length===i&&(s=s.add(c)):o.done()})).next((function(){return n.lookupMutationBatches(t,s)}))},t.prototype.lookupMutationBatches=function(t,e){var n=this,r=[],i=[];return e.forEach((function(e){i.push(oe(t).get(e).next((function(t){if(null===t)throw v("Dangling document-mutation reference found, which points to "+e);_(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),r.push(n.serializer.fromDbMutationBatch(t))})))})),Kt.waitFor(i).next((function(){return r}))},t.prototype.removeMutationBatch=function(t,e){var n=this;return re(t.simpleDbTransaction,this.userId,e).next((function(r){return t.addOnCommittedListener((function(){n.removeCachedMutationKeys(e.batchId)})),Kt.forEach(r,(function(e){return n.referenceDelegate.removeMutationReference(t,e)}))}))},t.prototype.removeCachedMutationKeys=function(t){delete this.documentKeysByBatchId[t]},t.prototype.performConsistencyCheck=function(t){var e=this;return this.checkEmpty(t).next((function(n){if(!n)return Kt.resolve();var r=IDBKeyRange.lowerBound(hn.prefixForUser(e.userId)),i=[];return ae(t).iterate({range:r},(function(t,n,r){if(t[0]===e.userId){var o=Ct(t[1]);i.push(o)}else r.done()})).next((function(){_(0===i.length,"Document leak -- detected dangling mutation references when queue is empty. Dangling keys: "+i.map((function(t){return t.canonicalString()})))}))}))},t.prototype.containsKey=function(t,e){return ne(t,this.userId,e)},t.prototype.getMutationQueueMetadata=function(t){var e=this;return se(t).get(this.userId).next((function(t){return t||new un(e.userId,-1,"")}))},t}();function ne(t,e,n){var r=hn.prefixForPath(e,n.path),i=r[1],o=IDBKeyRange.lowerBound(r),a=!1;return ae(t).iterate({range:o,keysOnly:!0},(function(t,n,r){var o=t[0],s=t[1];t[2];o===e&&s===i&&(a=!0),r.done()})).next((function(){return a}))}function re(t,e,n){var r=t.store(cn.store),i=t.store(hn.store),o=[],a=IDBKeyRange.only(n.batchId),s=0,u=r.iterate({range:a},(function(t,e,n){return s++,n.delete()}));o.push(u.next((function(){_(1===s,"Dangling document-mutation reference found: Missing batch "+n.batchId)})));for(var c=[],h=0,l=n.mutations;h<l.length;h++){var f=l[h],p=hn.key(e,f.key.path,n.batchId);o.push(i.delete(p)),c.push(f.key)}return Kt.waitFor(o).next((function(){return c}))}function ie(t){return t instanceof Uint8Array?(_(Gt.isMockPersistence(),"Persisting non-string stream tokens is only supported with mock persistence."),t.toString()):t}function oe(t){return Bn.getStore(t,cn.store)}function ae(t){return Bn.getStore(t,hn.store)}function se(t){return Bn.getStore(t,un.store)}var ue,ce=1;!function(t){t[t.QueryCache=0]="QueryCache",t[t.SyncEngine=1]="SyncEngine"}(ue||(ue={}));var he=function(){function t(t,e){this.generatorId=t,_((t&ce)===t,"Generator ID "+t+" contains more than "+ce+" reserved bits"),this.seek(void 0!==e?e:this.generatorId)}return t.prototype.next=function(){var t=this.nextId;return this.nextId+=1<<ce,t},t.prototype.after=function(t){return this.seek(t+(1<<ce)),this.next()},t.prototype.seek=function(t){_((t&ce)===this.generatorId,"Cannot supply target ID from different generator ID"),this.nextId=t},t.forTargetCache=function(){return new t(ue.QueryCache,2)},t.forSyncEngine=function(){return new t(ue.SyncEngine)},t}(),le=function(){function t(t,e){this.referenceDelegate=t,this.serializer=e,this.targetIdGenerator=he.forTargetCache()}return t.prototype.allocateTargetId=function(t){var e=this;return this.retrieveMetadata(t).next((function(n){return n.highestTargetId=e.targetIdGenerator.after(n.highestTargetId),e.saveMetadata(t,n).next((function(){return n.highestTargetId}))}))},t.prototype.getLastRemoteSnapshotVersion=function(t){return this.retrieveMetadata(t).next((function(t){return It.fromTimestamp(new St(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))}))},t.prototype.getHighestSequenceNumber=function(t){return de(t.simpleDbTransaction)},t.prototype.setTargetsMetadata=function(t,e,n){var r=this;return this.retrieveMetadata(t).next((function(i){return i.highestListenSequenceNumber=e,n&&(i.lastRemoteSnapshotVersion=n.toTimestamp()),e>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=e),r.saveMetadata(t,i)}))},t.prototype.addTargetData=function(t,e){var n=this;return this.saveTargetData(t,e).next((function(){return n.retrieveMetadata(t).next((function(r){return r.targetCount+=1,n.updateMetadataFromTargetData(e,r),n.saveMetadata(t,r)}))}))},t.prototype.updateTargetData=function(t,e){return this.saveTargetData(t,e)},t.prototype.removeTargetData=function(t,e){var n=this;return this.removeMatchingKeysForTargetId(t,e.targetId).next((function(){return fe(t).delete(e.targetId)})).next((function(){return n.retrieveMetadata(t)})).next((function(e){return _(e.targetCount>0,"Removing from an empty target cache"),e.targetCount-=1,n.saveMetadata(t,e)}))},t.prototype.removeTargets=function(t,e,n){var r=this,i=0,o=[];return fe(t).iterate((function(a,s){var u=r.serializer.fromDbTarget(s);u.sequenceNumber<=e&&null===n.get(u.targetId)&&(i++,o.push(r.removeTargetData(t,u)))})).next((function(){return Kt.waitFor(o)})).next((function(){return i}))},t.prototype.forEachTarget=function(t,e){var n=this;return fe(t).iterate((function(t,r){var i=n.serializer.fromDbTarget(r);e(i)}))},t.prototype.retrieveMetadata=function(t){return pe(t.simpleDbTransaction)},t.prototype.saveMetadata=function(t,e){return(n=t,Bn.getStore(n,gn.store)).put(gn.key,e);var n},t.prototype.saveTargetData=function(t,e){return fe(t).put(this.serializer.toDbTarget(e))},t.prototype.updateMetadataFromTargetData=function(t,e){var n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},t.prototype.getTargetCount=function(t){return this.retrieveMetadata(t).next((function(t){return t.targetCount}))},t.prototype.getTargetData=function(t,e){var n=this,r=e.canonicalId(),i=IDBKeyRange.bound([r,Number.NEGATIVE_INFINITY],[r,Number.POSITIVE_INFINITY]),o=null;return fe(t).iterate({range:i,index:mn.queryTargetsIndexName},(function(t,r,i){var a=n.serializer.fromDbTarget(r);e.isEqual(a.target)&&(o=a,i.done())})).next((function(){return o}))},t.prototype.addMatchingKeys=function(t,e,n){var r=this,i=[],o=me(t);return e.forEach((function(e){var a=wt(e.path);i.push(o.put(new yn(n,a))),i.push(r.referenceDelegate.addReference(t,e))})),Kt.waitFor(i)},t.prototype.removeMatchingKeys=function(t,e,n){var r=this,i=me(t);return Kt.forEach(e,(function(e){var o=wt(e.path);return Kt.waitFor([i.delete([n,o]),r.referenceDelegate.removeReference(t,e)])}))},t.prototype.removeMatchingKeysForTargetId=function(t,e){var n=me(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},t.prototype.getMatchingKeysForTargetId=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=me(t),i=Bt();return r.iterate({range:n,keysOnly:!0},(function(t,e,n){var r=Ct(t[1]),o=new pt(r);i=i.add(o)})).next((function(){return i}))},t.prototype.containsKey=function(t,e){var n=wt(e.path),r=IDBKeyRange.bound([n],[$(n)],!1,!0),i=0;return me(t).iterate({index:yn.documentTargetsIndex,keysOnly:!0,range:r},(function(t,e,n){var r=t[0];t[1];0!==r&&(i++,n.done())})).next((function(){return i>0}))},t.prototype.getTargetDataForTarget=function(t,e){var n=this;return fe(t).get(e).next((function(t){return t?n.serializer.fromDbTarget(t):null}))},t}();function fe(t){return Bn.getStore(t,mn.store)}function pe(t){return Gt.getStore(t,gn.store).get(gn.key).next((function(t){return _(null!==t,"Missing metadata row."),t}))}function de(t){return pe(t).next((function(t){return t.highestListenSequenceNumber}))}function me(t){return Bn.getStore(t,yn.store)}var ye,ge=function(){function t(t){this.fields=t}return t.fromSet=function(e){return new t(e)},t.fromArray=function(e){var n=new Rt(ft.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}(),ve=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}(),_e=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"}(ye||(ye={}));var be,we,Ee=function(){function t(t,e){this.updateTime=t,this.exists=e,_(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 Qe&&t.version.isEqual(this.updateTime):void 0!==this.exists?this.exists===t instanceof Qe:(_(this.isNone,"Precondition should be empty"),!0)},t.prototype.isEqual=function(t){return e=this.updateTime,n=t.updateTime,(null!=e?!(!n||!e.isEqual(n)):e===n)&&this.exists===t.exists;var e,n},t.NONE=new t,t}(),Te=function(){function t(){}return t.prototype.verifyKeyMatches=function(t){null!=t&&_(t.key.isEqual(this.key),"Can only apply a mutation to a document with the same key")},t.getPostMutationVersion=function(t){return t instanceof Qe?t.version:It.MIN},t}(),Ce=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=ye.Set,i}return a.__extends(e,t),e.prototype.applyToRemoteDocument=function(t,e){this.verifyKeyMatches(t),_(null==e.transformResults,"Transform results received by SetMutation.");var n=e.version;return new Qe(this.key,n,{hasCommittedMutations:!0},this.value)},e.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=Te.getPostMutationVersion(t);return new Qe(this.key,r,{hasLocalMutations:!0},this.value)},e.prototype.extractBaseValue=function(t){return null},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}(Te),Se=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=ye.Patch,o}return a.__extends(e,t),e.prototype.applyToRemoteDocument=function(t,e){if(this.verifyKeyMatches(t),_(null==e.transformResults,"Transform results received by PatchMutation."),!this.precondition.isValidFor(t))return new He(this.key,e.version);var n=this.patchDocument(t);return new Qe(this.key,e.version,{hasCommittedMutations:!0},n)},e.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=Te.getPostMutationVersion(t),i=this.patchDocument(t);return new Qe(this.key,r,{hasLocalMutations:!0},i)},e.prototype.extractBaseValue=function(t){return null},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 Qe?t.data():je.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=null!==r?t.set(n,r):t.delete(n)}})),t},e}(Te),Ie=function(t){function e(e,n){var r=t.call(this)||this;return r.key=e,r.fieldTransforms=n,r.type=ye.Transform,r.precondition=Ee.exists(!0),r}return a.__extends(e,t),e.prototype.applyToRemoteDocument=function(t,e){if(this.verifyKeyMatches(t),_(null!=e.transformResults,"Transform results missing for TransformMutation."),!this.precondition.isValidFor(t))return new He(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 Qe(this.key,i,{hasCommittedMutations:!0},o)},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,t,e),o=this.transformObject(r.data(),i);return new Qe(this.key,r.version,{hasLocalMutations:!0},o)},e.prototype.extractBaseValue=function(t){for(var e=null,n=0,r=this.fieldTransforms;n<r.length;n++){var i=r[n],o=t instanceof Qe?t.field(i.field):void 0,a=i.transform.computeBaseValue(o||null);null!=a&&(e=null==e?je.EMPTY.set(i.field,a):e.set(i.field,a))}return e},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&Z(this.fieldTransforms,t.fieldTransforms)&&this.precondition.isEqual(t.precondition)},e.prototype.requireDocument=function(t){return _(t instanceof Qe,"Unknown MaybeDocument type "+t),_(t.key.isEqual(this.key),"Can only transform a document with the same key"),t},e.prototype.serverTransformResults=function(t,e){var n=[];_(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,a=null;t instanceof Qe&&(a=t.field(i.field)),n.push(o.applyToRemoteDocument(a,e[r]))}return n},e.prototype.localTransformResults=function(t,e,n){for(var r=[],i=0,o=this.fieldTransforms;i<o.length;i++){var a=o[i],s=a.transform,u=null;e instanceof Qe&&(u=e.field(a.field)),null===u&&n instanceof Qe&&(u=n.field(a.field)),r.push(s.applyToLocalView(u,t))}return r},e.prototype.transformObject=function(t,e){_(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}(Te),De=function(t){function e(e,n){var r=t.call(this)||this;return r.key=e,r.precondition=n,r.type=ye.Delete,r}return a.__extends(e,t),e.prototype.applyToRemoteDocument=function(t,e){return this.verifyKeyMatches(t),_(null==e.transformResults,"Transform results received by DeleteMutation."),new Ke(this.key,e.version,{hasCommittedMutations:!0})},e.prototype.applyToLocalView=function(t,e,n){return this.verifyKeyMatches(t),this.precondition.isValidFor(t)?(t&&_(t.key.isEqual(this.key),"Can only apply mutation to document with same key"),new Ke(this.key,It.forDeletedDoc())):t},e.prototype.extractBaseValue=function(t){return null},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.precondition.isEqual(t.precondition)},e}(Te);!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"}(be||(be={})),function(t){t[t.Default=0]="Default",t[t.Estimate=1]="Estimate",t[t.Previous=2]="Previous"}(we||(we={}));var Ne=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(we.Estimate,n);case"previous":return new t(we.Previous,n);case"none":case void 0:return new t(we.Default,n);default:return v("fromSnapshotOptions() called with invalid options.")}},t}(),Ae=function(){function t(){}return t.prototype.toString=function(){var t=this.value();return null===t?"null":t.toString()},t.prototype.defaultCompareTo=function(t){return _(this.typeOrder!==t.typeOrder,"Default compareTo should not be used for values of same type."),J(this.typeOrder,t.typeOrder)},t}(),ke=function(t){function e(){var e=t.call(this)||this;return e.typeOrder=be.NullValue,e.internalValue=null,e}return a.__extends(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}(Ae),Re=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=be.BooleanValue,n}return a.__extends(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?J(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}(Ae),Oe=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=be.NumberValue,n}return a.__extends(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}(Ae);function xe(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}var Pe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a.__extends(e,t),e.prototype.isEqual=function(t){return t instanceof e&&xe(this.internalValue,t.internalValue)},e}(Oe),Me=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a.__extends(e,t),e.prototype.isEqual=function(t){return t instanceof e&&xe(this.internalValue,t.internalValue)},e.NAN=new e(NaN),e.POSITIVE_INFINITY=new e(1/0),e.NEGATIVE_INFINITY=new e(-1/0),e}(Oe),Le=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=be.StringValue,n}return a.__extends(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?J(this.internalValue,t.internalValue):this.defaultCompareTo(t)},e}(Ae),Fe=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=be.TimestampValue,n}return a.__extends(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 Ue?-1:this.defaultCompareTo(t)},e}(Ae),Ue=function(t){function e(e,n){var r=t.call(this)||this;return r.localWriteTime=e,r.previousValue=n,r.typeOrder=be.TimestampValue,r}return a.__extends(e,t),e.prototype.value=function(t){return t&&t.serverTimestampBehavior===we.Estimate?new Fe(this.localWriteTime).value(t):t&&t.serverTimestampBehavior===we.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 Fe?1:this.defaultCompareTo(t)},e.prototype.toString=function(){return"<ServerTimestamp localTime="+this.localWriteTime.toString()+">"},e}(Ae),qe=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=be.BlobValue,n}return a.__extends(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}(Ae),Ve=function(t){function e(e,n){var r=t.call(this)||this;return r.databaseId=e,r.key=n,r.typeOrder=be.RefValue,r}return a.__extends(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:pt.comparator(this.key,t.key)}return this.defaultCompareTo(t)},e}(Ae),Be=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=be.GeoPointValue,n}return a.__extends(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}(Ae),je=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=be.ObjectValue,n}return a.__extends(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(),a=J(i.key,o.key)||i.value.compareTo(o.value);if(a)return a}return J(n.hasNext(),r.hasNext())}return this.defaultCompareTo(t)},e.prototype.set=function(t,n){if(_(!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(_(!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 null!==this.field(t)},e.prototype.field=function(t){_(!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):null})),n},e.prototype.fieldMask=function(){var t=new Rt(ft.comparator);return this.internalValue.forEach((function(n,r){var i=new ft([n]);if(r instanceof e){var o=r.fieldMask().fields;o.isEmpty()?t=t.add(i):o.forEach((function(e){t=t.add(i.child(e))}))}else t=t.add(i)})),ge.fromSet(t)},e.prototype.toString=function(){return this.internalValue.toString()},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 Dt(J)),e}(Ae),ze=function(t){function e(e){var n=t.call(this)||this;return n.internalValue=e,n.typeOrder=be.ArrayValue,n}return a.__extends(e,t),e.prototype.value=function(t){return this.internalValue.map((function(e){return e.value(t)}))},e.prototype.contains=function(t){for(var e=0,n=this.internalValue;e<n.length;e++){if(n[e].isEqual(t))return!0}return!1},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 J(this.internalValue.length,t.internalValue.length)}return this.defaultCompareTo(t)},e.prototype.toString=function(){return"["+this.internalValue.map((function(t){return t.toString()})).join(",")+"]"},e}(Ae),We=function(){function t(t,e){this.key=t,this.version=e}return t.compareByKey=function(t,e){return pt.comparator(t.key,e.key)},t}(),Qe=function(t){function e(e,n,r,i,o,a){var s=t.call(this,e,n)||this;return s.objectValue=i,s.proto=o,s.converter=a,_(void 0!==s.objectValue||void 0!==s.proto&&void 0!==s.converter,"If objectValue is not defined, proto and converter need to be set."),s.hasLocalMutations=!!r.hasLocalMutations,s.hasCommittedMutations=!!r.hasCommittedMutations,s}return a.__extends(e,t),e.prototype.field=function(t){if(this.objectValue)return this.objectValue.field(t);this.fieldValueCache||(this.fieldValueCache=new Map);var e=t.canonicalString(),n=this.fieldValueCache.get(e);if(void 0===n){var r=this.getProtoField(t);n=void 0===r?null:this.converter(r),this.fieldValueCache.set(e,n)}return n},e.prototype.data=function(){var t=this;if(!this.objectValue){var e=je.EMPTY;N(this.proto.fields||{},(function(n,r){e=e.set(new ft([n]),t.converter(r))})),this.objectValue=e,this.fieldValueCache=void 0}return this.objectValue},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.hasLocalMutations===t.hasLocalMutations&&this.hasCommittedMutations===t.hasCommittedMutations&&this.data().isEqual(t.data())},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.prototype.getProtoField=function(t){_(void 0!==this.proto,"Can only call getProtoField() when proto is defined");for(var e=this.proto.fields?this.proto.fields[t.firstSegment()]:void 0,n=1;n<t.length;++n){if(!e||!e.mapValue||!e.mapValue.fields)return;e=e.mapValue.fields[t.get(n)]}return e},e.compareByField=function(t,e,n){var r=e.field(t),i=n.field(t);return null!==r&&null!==i?r.compareTo(i):v("Trying to compare documents on fields that don't exist")},e}(We),Ke=function(t){function e(e,n,r){var i=t.call(this,e,n)||this;return i.hasCommittedMutations=!(!r||!r.hasCommittedMutations),i}return a.__extends(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}(We),He=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a.__extends(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}(We),Ge=function(){function t(t){this.mapKeyFn=t,this.inner={}}return t.prototype.get=function(t){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0!==n)for(var r=0,i=n;r<i.length;r++){var o=i[r],a=o[0],s=o[1];if(a.isEqual(t))return s}},t.prototype.has=function(t){return void 0!==this.get(t)},t.prototype.set=function(t,e){var n=this.mapKeyFn(t),r=this.inner[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(r[i][0].isEqual(t))return void(r[i]=[t,e]);r.push([t,e])}else this.inner[n]=[[t,e]]},t.prototype.delete=function(t){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(n[r][0].isEqual(t))return 1===n.length?delete this.inner[e]:n.splice(r,1),!0;return!1},t.prototype.forEach=function(t){N(this.inner,(function(e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r],a=o[0],s=o[1];t(a,s)}}))},t.prototype.isEmpty=function(){return A(this.inner)},t}(),Ye=function(){function t(){this.changes=new Ge((function(t){return t.toString()})),this.changesApplied=!1}return Object.defineProperty(t.prototype,"readTime",{get:function(){return _(void 0!==this._readTime,"Read time is not set. All removeEntry() calls must include a readTime if `trackRemovals` is used."),this._readTime},set:function(t){_(void 0===this._readTime||this._readTime.isEqual(t),"All changes in a RemoteDocumentChangeBuffer must have the same read time"),this._readTime=t},enumerable:!0,configurable:!0}),t.prototype.addEntry=function(t,e){this.assertNotApplied(),this.readTime=e,this.changes.set(t.key,t)},t.prototype.removeEntry=function(t,e){this.assertNotApplied(),e&&(this.readTime=e),this.changes.set(t,null)},t.prototype.getEntry=function(t,e){this.assertNotApplied();var n=this.changes.get(e);return void 0!==n?Kt.resolve(n):this.getFromCache(t,e)},t.prototype.getEntries=function(t,e){return this.getAllFromCache(t,e)},t.prototype.apply=function(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)},t.prototype.assertNotApplied=function(){_(!this.changesApplied,"Changes have already been applied.")},t}(),Xe=function(){function t(t,e){this.serializer=t,this.indexManager=e}return t.prototype.addEntry=function(t,e,n){return Ze(t).put($e(e),n)},t.prototype.removeEntry=function(t,e){var n=Ze(t),r=$e(e);return n.delete(r)},t.prototype.updateMetadata=function(t,e){var n=this;return this.getMetadata(t).next((function(r){return r.byteSize+=e,n.setMetadata(t,r)}))},t.prototype.getEntry=function(t,e){var n=this;return Ze(t).get($e(e)).next((function(t){return n.maybeDecodeDocument(t)}))},t.prototype.getSizedEntry=function(t,e){var n=this;return Ze(t).get($e(e)).next((function(t){var e=n.maybeDecodeDocument(t);return e?{maybeDocument:e,size:tn(t)}:null}))},t.prototype.getEntries=function(t,e){var n=this,r=Mt();return this.forEachDbEntry(t,e,(function(t,e){var i=n.maybeDecodeDocument(e);r=r.insert(t,i)})).next((function(){return r}))},t.prototype.getSizedEntries=function(t,e){var n=this,r=Mt(),i=new Dt(pt.comparator);return this.forEachDbEntry(t,e,(function(t,e){var o=n.maybeDecodeDocument(e);o?(r=r.insert(t,o),i=i.insert(t,tn(e))):(r=r.insert(t,null),i=i.insert(t,0))})).next((function(){return{maybeDocuments:r,sizeMap:i}}))},t.prototype.forEachDbEntry=function(t,e,n){if(e.isEmpty())return Kt.resolve();var r=IDBKeyRange.bound(e.first().path.toArray(),e.last().path.toArray()),i=e.getIterator(),o=i.getNext();return Ze(t).iterate({range:r},(function(t,e,r){for(var a=pt.fromSegments(t);o&&pt.comparator(o,a)<0;)n(o,null),o=i.getNext();o&&o.isEqual(a)&&(n(o,e),o=i.hasNext()?i.getNext():null),o?r.skip(o.path.toArray()):r.done()})).next((function(){for(;o;)n(o,null),o=i.hasNext()?i.getNext():null}))},t.prototype.getDocumentsMatchingQuery=function(t,e,n){var r=this;_(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var i=Ft(),o=e.path.length+1,a={};if(n.isEqual(It.MIN)){var s=e.path.toArray();a.range=IDBKeyRange.lowerBound(s)}else{var u=e.path.toArray(),c=this.serializer.toDbTimestampKey(n);a.range=IDBKeyRange.lowerBound([u,c],!0),a.index=pn.collectionReadTimeIndex}return Ze(t).iterate(a,(function(t,n,a){if(t.length===o){var s=r.serializer.fromDbRemoteDocument(n);e.path.isPrefixOf(s.key.path)?s instanceof Qe&&e.matches(s)&&(i=i.insert(s.key,s)):a.done()}})).next((function(){return i}))},t.prototype.getNewDocumentChanges=function(t,e){var n=this,r=Pt(),i=this.serializer.toDbTimestampKey(e),o=Ze(t),a=IDBKeyRange.lowerBound(i,!0);return o.iterate({index:pn.readTimeIndex,range:a},(function(t,e){var o=n.serializer.fromDbRemoteDocument(e);r=r.insert(o.key,o),i=e.readTime})).next((function(){return{changedDocs:r,readTime:n.serializer.fromDbTimestampKey(i)}}))},t.prototype.getLastDocumentChange=function(t){var e,n=this,r=Ze(t),i=It.MIN;return r.iterate({index:pn.readTimeIndex,reverse:!0},(function(t,r,o){e=n.serializer.fromDbRemoteDocument(r),r.readTime&&(i=n.serializer.fromDbTimestampKey(r.readTime)),o.done()})).next((function(){return{changedDoc:e,readTime:i}}))},t.prototype.newChangeBuffer=function(e){return new t.RemoteDocumentChangeBuffer(this,!!e&&e.trackRemovals)},t.prototype.getSize=function(t){return this.getMetadata(t).next((function(t){return t.byteSize}))},t.prototype.getMetadata=function(t){return Je(t).get(dn.key).next((function(t){return _(!!t,"Missing document cache metadata"),t}))},t.prototype.setMetadata=function(t,e){return Je(t).put(dn.key,e)},t.prototype.maybeDecodeDocument=function(t){if(t){var e=this.serializer.fromDbRemoteDocument(t);return e instanceof Ke&&e.version.isEqual(It.forDeletedDoc())?null:e}return null},t.RemoteDocumentChangeBuffer=function(t){function e(e,n){var r=t.call(this)||this;return r.documentCache=e,r.trackRemovals=n,r.documentSizes=new Ge((function(t){return t.toString()})),r}return a.__extends(e,t),e.prototype.applyChanges=function(t){var e=this,n=[],r=0,i=new Rt((function(t,e){return J(t.canonicalString(),e.canonicalString())}));return this.changes.forEach((function(o,a){var s=e.documentSizes.get(o);if(_(void 0!==s,"Cannot modify a document that wasn't read (for "+o+")"),a){_(!e.readTime.isEqual(It.MIN),"Cannot add a document with a read time of zero");var u=e.documentCache.serializer.toDbRemoteDocument(a,e.readTime);i=i.add(o.path.popLast());var c=tn(u);r+=c-s,n.push(e.documentCache.addEntry(t,o,u))}else if(r-=s,e.trackRemovals){var h=e.documentCache.serializer.toDbRemoteDocument(new Ke(o,It.forDeletedDoc()),e.readTime);n.push(e.documentCache.addEntry(t,o,h))}else n.push(e.documentCache.removeEntry(t,o))})),i.forEach((function(r){n.push(e.documentCache.indexManager.addToCollectionParentIndex(t,r))})),n.push(this.documentCache.updateMetadata(t,r)),Kt.waitFor(n)},e.prototype.getFromCache=function(t,e){var n=this;return this.documentCache.getSizedEntry(t,e).next((function(t){return null===t?(n.documentSizes.set(e,0),null):(n.documentSizes.set(e,t.size),t.maybeDocument)}))},e.prototype.getAllFromCache=function(t,e){var n=this;return this.documentCache.getSizedEntries(t,e).next((function(t){var e=t.maybeDocuments;return t.sizeMap.forEach((function(t,e){n.documentSizes.set(t,e)})),e}))},e}(Ye),t}();function Je(t){return Bn.getStore(t,dn.store)}function Ze(t){return Bn.getStore(t,pn.store)}function $e(t){return t.path.toArray()}function tn(t){var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw v("Unknown remote document type");e=t.noDocument}return JSON.stringify(e).length}var en=function(){function t(){this.collectionParentIndex=new nn}return t.prototype.addToCollectionParentIndex=function(t,e){return this.collectionParentIndex.add(e),Kt.resolve()},t.prototype.getCollectionParents=function(t,e){return Kt.resolve(this.collectionParentIndex.getEntries(e))},t}(),nn=function(){function t(){this.index={}}return t.prototype.add=function(t){_(t.length%2==1,"Expected a collection path.");var e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new Rt(ht.comparator),i=!r.has(n);return this.index[e]=r.add(n),i},t.prototype.has=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e];return r&&r.has(n)},t.prototype.getEntries=function(t){return(this.index[t]||new Rt(ht.comparator)).toArray()},t}(),rn=9,on=function(){function t(t){this.serializer=t}return t.prototype.createOrUpgrade=function(t,e,n,r){var i=this;_(n<r&&n>=0&&r<=rn,"Unexpected schema upgrade from v"+n+" to v{toVersion}.");var o=new Xt(e);n<1&&r>=1&&(function(t){t.createObjectStore(sn.store)}(t),function(t){t.createObjectStore(un.store,{keyPath:un.keyPath}),t.createObjectStore(cn.store,{keyPath:cn.keyPath,autoIncrement:!0}).createIndex(cn.userMutationsIndex,cn.userMutationsKeyPath,{unique:!0}),t.createObjectStore(hn.store)}(t),_n(t),function(t){t.createObjectStore(pn.store)}(t));var a=Kt.resolve();return n<3&&r>=3&&(0!==n&&(!function(t){t.deleteObjectStore(yn.store),t.deleteObjectStore(mn.store),t.deleteObjectStore(gn.store)}(t),_n(t)),a=a.next((function(){return function(t){var e=t.store(gn.store),n=new gn(0,0,It.MIN.toTimestamp(),0);return e.put(gn.key,n)}(o)}))),n<4&&r>=4&&(0!==n&&(a=a.next((function(){return function(t,e){return e.store(cn.store).loadAll().next((function(n){t.deleteObjectStore(cn.store),t.createObjectStore(cn.store,{keyPath:cn.keyPath,autoIncrement:!0}).createIndex(cn.userMutationsIndex,cn.userMutationsKeyPath,{unique:!0});var r=e.store(cn.store),i=n.map((function(t){return r.put(t)}));return Kt.waitFor(i)}))}(t,o)}))),a=a.next((function(){!function(t){t.createObjectStore(bn.store,{keyPath:bn.keyPath})}(t)}))),n<5&&r>=5&&(a=a.next((function(){return i.removeAcknowledgedMutations(o)}))),n<6&&r>=6&&(a=a.next((function(){return function(t){t.createObjectStore(dn.store)}(t),i.addDocumentGlobal(o)}))),n<7&&r>=7&&(a=a.next((function(){return i.ensureSequenceNumbers(o)}))),n<8&&r>=8&&(a=a.next((function(){return i.createCollectionParentIndex(t,o)}))),n<9&&r>=9&&(a=a.next((function(){!function(t){t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges")}(t),function(t){var e=t.objectStore(pn.store);e.createIndex(pn.readTimeIndex,pn.readTimeIndexPath,{unique:!1}),e.createIndex(pn.collectionReadTimeIndex,pn.collectionReadTimeIndexPath,{unique:!1})}(e)}))),a},t.prototype.addDocumentGlobal=function(t){var e=0;return t.store(pn.store).iterate((function(t,n){e+=tn(n)})).next((function(){var n=new dn(e);return t.store(dn.store).put(dn.key,n)}))},t.prototype.removeAcknowledgedMutations=function(t){var e=this,n=t.store(un.store),r=t.store(cn.store);return n.loadAll().next((function(n){return Kt.forEach(n,(function(n){var i=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return r.loadAll(cn.userMutationsIndex,i).next((function(r){return Kt.forEach(r,(function(r){_(r.userId===n.userId,"Cannot process batch "+r.batchId+" from unexpected user");var i=e.serializer.fromDbMutationBatch(r);return re(t,n.userId,i).next((function(){}))}))}))}))}))},t.prototype.ensureSequenceNumbers=function(t){var e=t.store(yn.store),n=t.store(pn.store);return de(t).next((function(t){var r=[];return n.iterate((function(n,i){var o=new ht(n),a=function(t){return[0,wt(t)]}(o);r.push(e.get(a).next((function(n){return n?Kt.resolve():function(n){return e.put(new yn(0,wt(n),t))}(o)})))})).next((function(){return Kt.waitFor(r)}))}))},t.prototype.createCollectionParentIndex=function(t,e){t.createObjectStore(vn.store,{keyPath:vn.keyPath});var n=e.store(vn.store),r=new nn,i=function(t){if(r.add(t)){var e=t.lastSegment(),i=t.popLast();return n.put({collectionId:e,parent:wt(i)})}};return e.store(pn.store).iterate({keysOnly:!0},(function(t,e){var n=new ht(t);return i(n.popLast())})).next((function(){return e.store(hn.store).iterate({keysOnly:!0},(function(t,e){t[0];var n=t[1],r=(t[2],Ct(n));return i(r.popLast())}))}))},t}();var an=function(t,e){this.seconds=t,this.nanoseconds=e},sn=function(){function t(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n}return t.store="owner",t.key="owner",t}();var un=function(){function t(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n}return t.store="mutationQueues",t.keyPath="userId",t}(),cn=function(){function t(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}return t.store="mutations",t.keyPath="batchId",t.userMutationsIndex="userMutationsIndex",t.userMutationsKeyPath=["userId","batchId"],t}();var hn=function(){function t(){}return t.prefixForUser=function(t){return[t]},t.prefixForPath=function(t,e){return[t,wt(e)]},t.key=function(t,e,n){return[t,wt(e),n]},t.store="documentMutations",t.PLACEHOLDER=new t,t}();var ln=function(t,e){this.path=t,this.readTime=e},fn=function(t,e){this.path=t,this.version=e},pn=function(){function t(t,e,n,r,i,o){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o}return t.store="remoteDocuments",t.readTimeIndex="readTimeIndex",t.readTimeIndexPath="readTime",t.collectionReadTimeIndex="collectionReadTimeIndex",t.collectionReadTimeIndexPath=["parentPath","readTime"],t}(),dn=function(){function t(t){this.byteSize=t}return t.store="remoteDocumentGlobal",t.key="remoteDocumentGlobalKey",t}();var mn=function(){function t(t,e,n,r,i,o,a){this.targetId=t,this.canonicalId=e,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=o,this.query=a}return t.store="targets",t.keyPath="targetId",t.queryTargetsIndexName="queryTargetsIndex",t.queryTargetsKeyPath=["canonicalId","targetId"],t}(),yn=function(){function t(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n,_(0===t==(void 0!==n),"A target-document row must either have targetId == 0 and a defined sequence number, or a non-zero targetId and no sequence number")}return t.store="targetDocuments",t.keyPath=["targetId","path"],t.documentTargetsIndex="documentTargetsIndex",t.documentTargetsKeyPath=["path","targetId"],t}(),gn=function(){function t(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r}return t.key="targetGlobalKey",t.store="targetGlobal",t}(),vn=function(){function t(t,e){this.collectionId=t,this.parent=e}return t.store="collectionParents",t.keyPath=["collectionId","parent"],t}();function _n(t){t.createObjectStore(yn.store,{keyPath:yn.keyPath}).createIndex(yn.documentTargetsIndex,yn.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(mn.store,{keyPath:mn.keyPath}).createIndex(mn.queryTargetsIndexName,mn.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(gn.store)}var bn=function(){function t(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r}return t.store="clientMetadata",t.keyPath="clientId",t}();var wn,En=[un.store,cn.store,hn.store,pn.store,mn.store,sn.store,gn.store,yn.store],Tn=a.__spreadArrays(En,[bn.store]),Cn=a.__spreadArrays(Tn,[dn.store]),Sn=a.__spreadArrays(Cn,[vn.store]),In=function(){function t(){this.collectionParentsCache=new nn}return t.prototype.addToCollectionParentIndex=function(t,e){var n=this;if(_(e.length%2==1,"Expected a collection path."),!this.collectionParentsCache.has(e)){var r=e.lastSegment(),i=e.popLast();t.addOnCommittedListener((function(){n.collectionParentsCache.add(e)}));var o={collectionId:r,parent:wt(i)};return Dn(t).put(o)}return Kt.resolve()},t.prototype.getCollectionParents=function(t,e){var n=[],r=IDBKeyRange.bound([e,""],[$(e),""],!1,!0);return Dn(t).loadAll(r).next((function(t){for(var r=0,i=t;r<i.length;r++){var o=i[r];if(o.collectionId!==e)break;n.push(Ct(o.parent))}return n}))},t}();function Dn(t){return Bn.getStore(t,vn.store)}!function(t){t[t.Listen=0]="Listen",t[t.ExistenceFilterMismatch=1]="ExistenceFilterMismatch",t[t.LimboResolution=2]="LimboResolution"}(wn||(wn={}));var Nn=function(){function t(t,e,n,r,i,o,a){void 0===i&&(i=It.MIN),void 0===o&&(o=It.MIN),void 0===a&&(a=w()),this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=a}return t.prototype.withSequenceNumber=function(e){return new t(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)},t.prototype.withResumeToken=function(e,n){return new t(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e)},t.prototype.withLastLimboFreeSnapshotVersion=function(e){return new t(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.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.lastLimboFreeSnapshotVersion.isEqual(t.lastLimboFreeSnapshotVersion)&&this.resumeToken===t.resumeToken&&this.target.isEqual(t.target)},t}(),An=function(){function t(t){this.remoteSerializer=t}return t.prototype.fromDbRemoteDocument=function(t){if(t.document)return this.remoteSerializer.fromDocument(t.document,!!t.hasCommittedMutations);if(t.noDocument){var e=pt.fromSegments(t.noDocument.path),n=this.fromDbTimestamp(t.noDocument.readTime);return new Ke(e,n,{hasCommittedMutations:!!t.hasCommittedMutations})}if(t.unknownDocument){e=pt.fromSegments(t.unknownDocument.path),n=this.fromDbTimestamp(t.unknownDocument.version);return new He(e,n)}return v("Unexpected DbRemoteDocument")},t.prototype.toDbRemoteDocument=function(t,e){var n=this.toDbTimestampKey(e),r=t.key.path.popLast().toArray();if(t instanceof Qe){var i=t.proto?t.proto:this.remoteSerializer.toDocument(t),o=t.hasCommittedMutations;return new pn(null,null,i,o,n,r)}if(t instanceof Ke){var a=t.key.path.toArray(),s=this.toDbTimestamp(t.version);o=t.hasCommittedMutations;return new pn(null,new ln(a,s),null,o,n,r)}if(t instanceof He){a=t.key.path.toArray();var u=this.toDbTimestamp(t.version);return new pn(new fn(a,u),null,null,!0,n,r)}return v("Unexpected MaybeDocument")},t.prototype.toDbTimestampKey=function(t){var e=t.toTimestamp();return[e.seconds,e.nanoseconds]},t.prototype.fromDbTimestampKey=function(t){var e=new St(t[0],t[1]);return It.fromTimestamp(e)},t.prototype.toDbTimestamp=function(t){var e=t.toTimestamp();return new an(e.seconds,e.nanoseconds)},t.prototype.fromDbTimestamp=function(t){var e=new St(t.seconds,t.nanoseconds);return It.fromTimestamp(e)},t.prototype.toDbMutationBatch=function(t,e){var n=this,r=e.baseMutations.map((function(t){return n.remoteSerializer.toMutation(t)})),i=e.mutations.map((function(t){return n.remoteSerializer.toMutation(t)}));return new cn(t,e.batchId,e.localWriteTime.toMillis(),r,i)},t.prototype.fromDbMutationBatch=function(t){var e=this,n=(t.baseMutations||[]).map((function(t){return e.remoteSerializer.fromMutation(t)})),r=t.mutations.map((function(t){return e.remoteSerializer.fromMutation(t)})),i=St.fromMillis(t.localWriteTimeMs);return new Wt(t.batchId,i,n,r)},t.prototype.toDbResourcePaths=function(t){var e=[];return t.forEach((function(t){e.push(wt(t.path))})),e},t.prototype.fromDbResourcePaths=function(t){for(var e=Bt(),n=0,r=t;n<r.length;n++){var i=r[n];e=e.add(new pt(Ct(i)))}return e},t.prototype.fromDbTarget=function(t){var e,n=this.fromDbTimestamp(t.readTime),r=void 0!==t.lastLimboFreeSnapshotVersion?this.fromDbTimestamp(t.lastLimboFreeSnapshotVersion):It.MIN,i=t.resumeToken;return e=void 0!==t.query.documents?this.remoteSerializer.fromDocumentsTarget(t.query):this.remoteSerializer.fromQueryTarget(t.query),new Nn(e,t.targetId,wn.Listen,t.lastListenSequenceNumber,n,r,i)},t.prototype.toDbTarget=function(t){_(wn.Listen===t.purpose,"Only queries with purpose "+wn.Listen+" may be stored, got "+t.purpose);var e,n,r=this.toDbTimestamp(t.snapshotVersion),i=this.toDbTimestamp(t.lastLimboFreeSnapshotVersion);return e=t.target.isDocumentQuery()?this.remoteSerializer.toDocumentsTarget(t.target):this.remoteSerializer.toQueryTarget(t.target),t.resumeToken instanceof Uint8Array?(_(Gt.isMockPersistence(),"Persisting non-string stream tokens is only supported with mock persistence ."),n=t.resumeToken.toString()):n=t.resumeToken,new mn(t.targetId,t.target.canonicalId(),r,n,t.sequenceNumber,i,e)},t}();function kn(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],a=J(n,i);return 0===a?J(r,o):a}var Rn=function(){function t(t){this.maxElements=t,this.buffer=new Rt(kn),this.previousIndex=0}return t.prototype.nextIndex=function(){return++this.previousIndex},t.prototype.addElement=function(t){var e=[t,this.nextIndex()];if(this.buffer.size<this.maxElements)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();kn(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(t.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!0,configurable:!0}),t}(),On={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},xn=function(){function t(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}return t.withCacheSize=function(e){return new t(e,t.DEFAULT_COLLECTION_PERCENTILE,t.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)},t.COLLECTION_DISABLED=-1,t.MINIMUM_CACHE_SIZE_BYTES=1048576,t.DEFAULT_CACHE_SIZE_BYTES=41943040,t.DEFAULT_COLLECTION_PERCENTILE=10,t.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,t.DEFAULT=new t(t.DEFAULT_CACHE_SIZE_BYTES,t.DEFAULT_COLLECTION_PERCENTILE,t.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),t.DISABLED=new t(t.COLLECTION_DISABLED,0,0),t}(),Pn=function(){function t(t,e,n){this.garbageCollector=t,this.asyncQueue=e,this.localStore=n,this.hasRun=!1,this.gcTask=null}return t.prototype.start=function(){_(null===this.gcTask,"Cannot start an already started LruScheduler"),this.garbageCollector.params.cacheSizeCollectionThreshold!==xn.COLLECTION_DISABLED&&this.scheduleGC()},t.prototype.stop=function(){this.gcTask&&(this.gcTask.cancel(),this.gcTask=null)},Object.defineProperty(t.prototype,"started",{get:function(){return null!==this.gcTask},enumerable:!0,configurable:!0}),t.prototype.scheduleGC=function(){var t=this;_(null===this.gcTask,"Cannot schedule GC while a task is pending");var e=this.hasRun?3e5:6e4;m("LruGarbageCollector","Garbage collection scheduled in "+e+"ms"),this.gcTask=this.asyncQueue.enqueueAfterDelay(nt.LruGarbageCollection,e,(function(){return t.gcTask=null,t.hasRun=!0,t.localStore.collectGarbage(t.garbageCollector).then((function(){return t.scheduleGC()})).catch(jn)}))},t}(),Mn=function(){function t(t,e){this.delegate=t,this.params=e}return t.prototype.calculateTargetCount=function(t,e){return this.delegate.getSequenceNumberCount(t).next((function(t){return Math.floor(e/100*t)}))},t.prototype.nthSequenceNumber=function(t,e){var n=this;if(0===e)return Kt.resolve(ut.INVALID);var r=new Rn(e);return this.delegate.forEachTarget(t,(function(t){return r.addElement(t.sequenceNumber)})).next((function(){return n.delegate.forEachOrphanedDocumentSequenceNumber(t,(function(t){return r.addElement(t)}))})).next((function(){return r.maxValue}))},t.prototype.removeTargets=function(t,e,n){return this.delegate.removeTargets(t,e,n)},t.prototype.removeOrphanedDocuments=function(t,e){return this.delegate.removeOrphanedDocuments(t,e)},t.prototype.collect=function(t,e){var n=this;return this.params.cacheSizeCollectionThreshold===xn.COLLECTION_DISABLED?(m("LruGarbageCollector","Garbage collection skipped; disabled"),Kt.resolve(On)):this.getCacheSize(t).next((function(r){return r<n.params.cacheSizeCollectionThreshold?(m("LruGarbageCollector","Garbage collection skipped; Cache size "+r+" is lower than threshold "+n.params.cacheSizeCollectionThreshold),On):n.runGarbageCollection(t,e)}))},t.prototype.getCacheSize=function(t){return this.delegate.getCacheSize(t)},t.prototype.runGarbageCollection=function(t,e){var n,r,o,a,s,u,c,h=this,l=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next((function(e){return e>h.params.maximumSequenceNumbersToCollect?(m("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+h.params.maximumSequenceNumbersToCollect+" from "+e),r=h.params.maximumSequenceNumbersToCollect):r=e,a=Date.now(),h.nthSequenceNumber(t,r)})).next((function(r){return n=r,s=Date.now(),h.removeTargets(t,n,e)})).next((function(e){return o=e,u=Date.now(),h.removeOrphanedDocuments(t,n)})).next((function(t){(c=Date.now(),p()<=i.DEBUG)&&m("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(a-l)+"ms\n\tDetermined least recently used "+r+" in "+(s-a)+"ms\n\tRemoved "+o+" targets in "+(u-s)+"ms\n\tRemoved "+t+" documents in "+(c-u)+"ms\nTotal Duration: "+(c-l)+"ms");return Kt.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:o,documentsRemoved:t})}))},t}(),Ln=function(){function t(){this.onCommittedListeners=[]}return t.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},t.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEach((function(t){return t()}))},t}(),Fn="IndexedDbPersistence",Un="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",qn="Another tab has exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs.",Vn=function(t){function e(e,n){var r=t.call(this)||this;return r.simpleDbTransaction=e,r.currentSequenceNumber=n,r}return a.__extends(e,t),e}(Ln),Bn=function(){function t(e,n,r,i,o,a,s,u){if(this.allowTabSynchronization=e,this.persistenceKey=n,this.clientId=r,this.queue=a,this.sequenceNumberSyncer=u,this._started=!1,this.isPrimary=!1,this.networkEnabled=!0,this.windowUnloadHandler=null,this.inForeground=!1,this.documentVisibilityHandler=null,this.clientMetadataRefresher=null,this.lastGarbageCollectionTime=Number.NEGATIVE_INFINITY,this.primaryStateListener=function(t){return Promise.resolve()},this.referenceDelegate=new Qn(this,o),this.dbName=n+t.MAIN_DATABASE,this.serializer=new An(s),this.document=i.document,this.targetCache=new le(this.referenceDelegate,this.serializer),this.indexManager=new In,this.remoteDocumentCache=new Xe(this.serializer,this.indexManager),!i.window||!i.window.localStorage)throw new T(E.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");this.window=i.window,this.webStorage=this.window.localStorage}return t.getStore=function(t,e){if(t instanceof Vn)return Gt.getStore(t.simpleDbTransaction,e);throw v("IndexedDbPersistence must use instances of IndexedDbTransaction")},t.createIndexedDbPersistence=function(e){return a.__awaiter(this,void 0,void 0,(function(){var n;return a.__generator(this,(function(r){switch(r.label){case 0:if(!t.isAvailable())throw new T(E.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");return[4,(n=new t(e.allowTabSynchronization,e.persistenceKey,e.clientId,e.platform,e.lruParams,e.queue,e.serializer,e.sequenceNumberSyncer)).start()];case 1:return r.sent(),[2,n]}}))}))},t.prototype.start=function(){var t=this;return _(!this.started,"IndexedDbPersistence double-started!"),_(null!==this.window,"Expected 'window' to be defined"),Gt.openOrCreate(this.dbName,rn,new on(this.serializer)).then((function(e){return t.simpleDb=e,t.updateClientMetadataAndTryBecomePrimary()})).then((function(){return t.attachVisibilityHandler(),t.attachWindowUnloadHook(),t.scheduleClientMetadataAndPrimaryLeaseRefreshes(),t.simpleDb.runTransaction("readonly-idempotent",[gn.store],(function(t){return de(t)}))})).then((function(e){t.listenSequence=new ut(e,t.sequenceNumberSyncer)})).then((function(){t._started=!0})).catch((function(e){return t.simpleDb&&t.simpleDb.close(),Promise.reject(e)}))},t.prototype.setPrimaryStateListener=function(t){var e=this;return this.primaryStateListener=function(n){return a.__awaiter(e,void 0,void 0,(function(){return a.__generator(this,(function(e){return this.started?[2,t(n)]:[2]}))}))},t(this.isPrimary)},t.prototype.setDatabaseDeletedListener=function(t){var e=this;this.simpleDb.setVersionChangeListener((function(n){return a.__awaiter(e,void 0,void 0,(function(){return a.__generator(this,(function(e){switch(e.label){case 0:return null!==n.newVersion?[3,2]:[4,t()];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))}))},t.prototype.setNetworkEnabled=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.queue.enqueueAndForget((function(){return a.__awaiter(e,void 0,void 0,(function(){return a.__generator(this,(function(t){switch(t.label){case 0:return this.started?[4,this.updateClientMetadataAndTryBecomePrimary()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))})))},t.prototype.updateClientMetadataAndTryBecomePrimary=function(){var t=this;return this.simpleDb.runTransaction("readwrite-idempotent",Sn,(function(e){return Wn(e).put(new bn(t.clientId,Date.now(),t.networkEnabled,t.inForeground)).next((function(){if(t.isPrimary)return t.verifyPrimaryLease(e).next((function(e){e||(t.isPrimary=!1,t.queue.enqueueAndForget((function(){return t.primaryStateListener(!1)})))}))})).next((function(){return t.canActAsPrimary(e)})).next((function(n){return t.isPrimary&&!n?t.releasePrimaryLeaseIfHeld(e).next((function(){return!1})):!!n&&t.acquireOrExtendPrimaryLease(e).next((function(){return!0}))}))})).catch((function(e){if(!t.allowTabSynchronization)throw e;return m(Fn,"Releasing owner lease after error during lease refresh",e),!1})).then((function(e){t.isPrimary!==e&&t.queue.enqueueAndForget((function(){return t.primaryStateListener(e)})),t.isPrimary=e}))},t.prototype.verifyPrimaryLease=function(t){var e=this;return zn(t).get(sn.key).next((function(t){return Kt.resolve(e.isLocalClient(t))}))},t.prototype.removeClientMetadata=function(t){return Wn(t).delete(this.clientId)},t.prototype.maybeGarbageCollectMultiClientState=function(){return a.__awaiter(this,void 0,void 0,(function(){var e=this;return a.__generator(this,(function(n){switch(n.label){case 0:return!this.isPrimary||this.isWithinAge(this.lastGarbageCollectionTime,18e5)?[3,2]:(this.lastGarbageCollectionTime=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary-idempotent",(function(n){var r=t.getStore(n,bn.store);return r.loadAll().next((function(t){var n=e.filterActiveClients(t,18e5),i=t.filter((function(t){return-1===n.indexOf(t)}));return Kt.forEach(i,(function(t){return r.delete(t.clientId)})).next((function(){return i}))}))}))]);case 1:n.sent().forEach((function(t){e.window.localStorage.removeItem(e.zombiedClientLocalStorageKey(t.clientId))})),n.label=2;case 2:return[2]}}))}))},t.prototype.scheduleClientMetadataAndPrimaryLeaseRefreshes=function(){var t=this;this.clientMetadataRefresher=this.queue.enqueueAfterDelay(nt.ClientMetadataRefresh,4e3,(function(){return t.updateClientMetadataAndTryBecomePrimary().then((function(){return t.maybeGarbageCollectMultiClientState()})).then((function(){return t.scheduleClientMetadataAndPrimaryLeaseRefreshes()}))}))},t.prototype.isLocalClient=function(t){return!!t&&t.ownerId===this.clientId},t.prototype.canActAsPrimary=function(t){var e=this;return zn(t).get(sn.key).next((function(n){if(null!==n&&e.isWithinAge(n.leaseTimestampMs,5e3)&&!e.isClientZombied(n.ownerId)){if(e.isLocalClient(n)&&e.networkEnabled)return!0;if(!e.isLocalClient(n)){if(!n.allowTabSynchronization)throw new T(E.FAILED_PRECONDITION,qn);return!1}}return!(!e.networkEnabled||!e.inForeground)||Wn(t).loadAll().next((function(t){return void 0===e.filterActiveClients(t,5e3).find((function(t){if(e.clientId!==t.clientId){var n=!e.networkEnabled&&t.networkEnabled,r=!e.inForeground&&t.inForeground,i=e.networkEnabled===t.networkEnabled;if(n||r&&i)return!0}return!1}))}))})).next((function(t){return e.isPrimary!==t&&m(Fn,"Client "+(t?"is":"is not")+" eligible for a primary lease."),t}))},t.prototype.shutdown=function(){return a.__awaiter(this,void 0,void 0,(function(){var t=this;return a.__generator(this,(function(e){switch(e.label){case 0:return this._started=!1,this.markClientZombied(),this.clientMetadataRefresher&&(this.clientMetadataRefresher.cancel(),this.clientMetadataRefresher=null),this.detachVisibilityHandler(),this.detachWindowUnloadHook(),[4,this.simpleDb.runTransaction("readwrite-idempotent",[sn.store,bn.store],(function(e){return t.releasePrimaryLeaseIfHeld(e).next((function(){return t.removeClientMetadata(e)}))}))];case 1:return e.sent(),this.simpleDb.close(),this.removeClientZombiedEntry(),[2]}}))}))},t.prototype.filterActiveClients=function(t,e){var n=this;return t.filter((function(t){return n.isWithinAge(t.updateTimeMs,e)&&!n.isClientZombied(t.clientId)}))},t.prototype.getActiveClients=function(){var t=this;return this.simpleDb.runTransaction("readonly-idempotent",[bn.store],(function(e){return Wn(e).loadAll().next((function(e){return t.filterActiveClients(e,18e5).map((function(t){return t.clientId}))}))}))},t.clearPersistence=function(e){return a.__awaiter(this,void 0,void 0,(function(){var n;return a.__generator(this,(function(r){switch(r.label){case 0:return t.isAvailable()?(n=e+t.MAIN_DATABASE,[4,Gt.delete(n)]):[2,Promise.resolve()];case 1:return r.sent(),[2]}}))}))},Object.defineProperty(t.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),t.prototype.getMutationQueue=function(t){return _(this.started,"Cannot initialize MutationQueue before persistence is started."),ee.forUser(t,this.serializer,this.indexManager,this.referenceDelegate)},t.prototype.getTargetCache=function(){return _(this.started,"Cannot initialize TargetCache before persistence is started."),this.targetCache},t.prototype.getRemoteDocumentCache=function(){return _(this.started,"Cannot initialize RemoteDocumentCache before persistence is started."),this.remoteDocumentCache},t.prototype.getIndexManager=function(){return _(this.started,"Cannot initialize IndexManager before persistence is started."),this.indexManager},t.prototype.runTransaction=function(t,e,n){var r=this;m(Fn,"Starting transaction:",t);var i,o=e.endsWith("idempotent"),a=e.startsWith("readonly")?o?"readonly-idempotent":"readonly":o?"readwrite-idempotent":"readwrite";return this.simpleDb.runTransaction(a,Sn,(function(o){return i=new Vn(o,r.listenSequence.next()),"readwrite-primary"===e||"readwrite-primary-idempotent"===e?r.verifyPrimaryLease(o).next((function(t){return!!t||r.canActAsPrimary(o)})).next((function(e){if(!e)throw y("Failed to obtain primary lease for action '"+t+"'."),r.isPrimary=!1,r.queue.enqueueAndForget((function(){return r.primaryStateListener(!1)})),new T(E.FAILED_PRECONDITION,Un);return n(i)})).next((function(t){return r.acquireOrExtendPrimaryLease(o).next((function(){return t}))})):r.verifyAllowTabSynchronization(o).next((function(){return n(i)}))})).then((function(t){return i.raiseOnCommittedEvent(),t}))},t.prototype.verifyAllowTabSynchronization=function(t){var e=this;return zn(t).get(sn.key).next((function(t){if(null!==t&&e.isWithinAge(t.leaseTimestampMs,5e3)&&!e.isClientZombied(t.ownerId)&&!e.isLocalClient(t)&&!t.allowTabSynchronization)throw new T(E.FAILED_PRECONDITION,qn)}))},t.prototype.acquireOrExtendPrimaryLease=function(t){var e=new sn(this.clientId,this.allowTabSynchronization,Date.now());return zn(t).put(sn.key,e)},t.isAvailable=function(){return Gt.isAvailable()},t.buildStoragePrefix=function(t){var e=t.databaseId.projectId;return t.databaseId.isDefaultDatabase||(e+="."+t.databaseId.database),"firestore/"+t.persistenceKey+"/"+e+"/"},t.prototype.releasePrimaryLeaseIfHeld=function(t){var e=this,n=zn(t);return n.get(sn.key).next((function(t){return e.isLocalClient(t)?(m(Fn,"Releasing primary lease."),n.delete(sn.key)):Kt.resolve()}))},t.prototype.isWithinAge=function(t,e){var n=Date.now();return!(t<n-e)&&(!(t>n)||(y("Detected an update time that is in the future: "+t+" > "+n),!1))},t.prototype.attachVisibilityHandler=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.documentVisibilityHandler=function(){t.queue.enqueueAndForget((function(){return t.inForeground="visible"===t.document.visibilityState,t.updateClientMetadataAndTryBecomePrimary()}))},this.document.addEventListener("visibilitychange",this.documentVisibilityHandler),this.inForeground="visible"===this.document.visibilityState)},t.prototype.detachVisibilityHandler=function(){this.documentVisibilityHandler&&(_(null!==this.document&&"function"==typeof this.document.addEventListener,"Expected 'document.addEventListener' to be a function"),this.document.removeEventListener("visibilitychange",this.documentVisibilityHandler),this.documentVisibilityHandler=null)},t.prototype.attachWindowUnloadHook=function(){var t=this;"function"==typeof this.window.addEventListener&&(this.windowUnloadHandler=function(){t.markClientZombied(),t.queue.enqueueAndForget((function(){return t.shutdown()}))},this.window.addEventListener("unload",this.windowUnloadHandler))},t.prototype.detachWindowUnloadHook=function(){this.windowUnloadHandler&&(_("function"==typeof this.window.removeEventListener,"Expected 'window.removeEventListener' to be a function"),this.window.removeEventListener("unload",this.windowUnloadHandler),this.windowUnloadHandler=null)},t.prototype.isClientZombied=function(t){try{var e=null!==this.webStorage.getItem(this.zombiedClientLocalStorageKey(t));return m(Fn,"Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(n){return y(Fn,"Failed to get zombied client id.",n),!1}},t.prototype.markClientZombied=function(){try{this.webStorage.setItem(this.zombiedClientLocalStorageKey(this.clientId),String(Date.now()))}catch(t){y("Failed to set zombie client id.",t)}},t.prototype.removeClientZombiedEntry=function(){try{this.webStorage.removeItem(this.zombiedClientLocalStorageKey(this.clientId))}catch(t){}},t.prototype.zombiedClientLocalStorageKey=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},t.MAIN_DATABASE="main",t}();function jn(t){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(e){if(!function(t){return t.code===E.FAILED_PRECONDITION&&t.message===Un}(t))throw t;return m(Fn,"Unexpectedly lost primary lease"),[2]}))}))}function zn(t){return t.store(sn.store)}function Wn(t){return t.store(bn.store)}var Qn=function(){function t(t,e){this.db=t,this.inMemoryPins=null,this.garbageCollector=new Mn(this,e)}return t.prototype.getSequenceNumberCount=function(t){var e=this.orphanedDocmentCount(t);return this.db.getTargetCache().getTargetCount(t).next((function(t){return e.next((function(e){return t+e}))}))},t.prototype.orphanedDocmentCount=function(t){var e=0;return this.forEachOrphanedDocumentSequenceNumber(t,(function(t){e++})).next((function(){return e}))},t.prototype.forEachTarget=function(t,e){return this.db.getTargetCache().forEachTarget(t,e)},t.prototype.forEachOrphanedDocumentSequenceNumber=function(t,e){return this.forEachOrphanedDocument(t,(function(t,n){return e(n)}))},t.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},t.prototype.addReference=function(t,e){return Kn(t,e)},t.prototype.removeReference=function(t,e){return Kn(t,e)},t.prototype.removeTargets=function(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)},t.prototype.removeMutationReference=function(t,e){return Kn(t,e)},t.prototype.isPinned=function(t,e){return this.inMemoryPins.containsKey(e)?Kt.resolve(!0):function(t,e){var n=!1;return se(t).iterateSerial((function(r){return ne(t,r,e).next((function(t){return t&&(n=!0),Kt.resolve(!t)}))})).next((function(){return n}))}(t,e)},t.prototype.removeOrphanedDocuments=function(t,e){var n=this,r=this.db.getRemoteDocumentCache().newChangeBuffer(),i=[],o=0;return this.forEachOrphanedDocument(t,(function(a,s){if(s<=e){var u=n.isPinned(t,a).next((function(e){if(!e)return o++,r.getEntry(t,a).next((function(){return r.removeEntry(a),me(t).delete([0,wt(a.path)])}))}));i.push(u)}})).next((function(){return Kt.waitFor(i)})).next((function(){return r.apply(t)})).next((function(){return o}))},t.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)},t.prototype.updateLimboDocument=function(t,e){return Kn(t,e)},t.prototype.forEachOrphanedDocument=function(t,e){var n,r=me(t),i=ut.INVALID;return r.iterate({index:yn.documentTargetsIndex},(function(t,r){var o=t[0],a=(t[1],r.path),s=r.sequenceNumber;0===o?(i!==ut.INVALID&&e(new pt(Ct(n)),i),i=s,n=a):i=ut.INVALID})).next((function(){i!==ut.INVALID&&e(new pt(Ct(n)),i)}))},t.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},t}();function Kn(t,e){return me(t).put(function(t,e){return new yn(0,wt(t.path),e)}(e,t.currentSequenceNumber))}var Hn=Number,Gn=Hn.MIN_SAFE_INTEGER||-(Math.pow(2,53)-1),Yn=Hn.MAX_SAFE_INTEGER||Math.pow(2,53)-1,Xn=Hn.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function Jn(t){return null==t}function Zn(t){return Xn(t)&&t<=Yn&&t>=Gn}var $n,tr=function(){function t(t,e,n,r,i,o,a){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===a&&(a=null),this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=a,this.memoizedCanonicalId=null}return t.prototype.canonicalId=function(){if(null===this.memoizedCanonicalId){var t=this.path.canonicalString();null!==this.collectionGroup&&(t+="|cg:"+this.collectionGroup),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+=","}Jn(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=this.path.canonicalString();return null!==this.collectionGroup&&(t+=" collectionGroup="+this.collectionGroup),this.filters.length>0&&(t+=", filters: ["+this.filters.join(", ")+"]"),Jn(this.limit)||(t+=", limit: "+this.limit),this.orderBy.length>0&&(t+=", orderBy: ["+this.orderBy.join(", ")+"]"),this.startAt&&(t+=", startAt: "+this.startAt.canonicalId()),this.endAt&&(t+=", endAt: "+this.endAt.canonicalId()),"Target("+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.collectionGroup===t.collectionGroup&&(!!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.isDocumentQuery=function(){return pt.isDocumentKey(this.path)&&null===this.collectionGroup&&0===this.filters.length},t}();!function(t){t.First="F",t.Last="L"}($n||($n={}));var er=function(){function t(t,e,n,r,i,o,a,s){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=$n.First),void 0===a&&(a=null),void 0===s&&(s=null),this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=o,this.startAt=a,this.endAt=s,this.memoizedOrderBy=null,this.memoizedTarget=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=[pr]:this.memoizedOrderBy=[new fr(t),pr];else{_(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 a=this.explicitOrderBy.length>0?this.explicitOrderBy[this.explicitOrderBy.length-1].dir:hr.ASCENDING;this.memoizedOrderBy.push(a===hr.ASCENDING?pr:dr)}}}return this.memoizedOrderBy},enumerable:!0,configurable:!0}),t.prototype.addFilter=function(e){_(null==this.getInequalityFilterField()||!(e instanceof ir)||!e.isInequality()||e.field.isEqual(this.getInequalityFilterField()),"Query must only have one inequality field."),_(!this.isDocumentQuery(),"No filtering allowed for document query");var n=this.filters.concat([e]);return new t(this.path,this.collectionGroup,this.explicitOrderBy.slice(),n,this.limit,this.limitType,this.startAt,this.endAt)},t.prototype.addOrderBy=function(e){_(!this.startAt&&!this.endAt,"Bounds must be set after orderBy");var n=this.explicitOrderBy.concat([e]);return new t(this.path,this.collectionGroup,n,this.filters.slice(),this.limit,this.limitType,this.startAt,this.endAt)},t.prototype.withLimitToFirst=function(e){return new t(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),e,$n.First,this.startAt,this.endAt)},t.prototype.withLimitToLast=function(e){return new t(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),e,$n.Last,this.startAt,this.endAt)},t.prototype.withStartAt=function(e){return new t(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.limitType,e,this.endAt)},t.prototype.withEndAt=function(e){return new t(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.limitType,this.startAt,e)},t.prototype.asCollectionQueryAtPath=function(e){return new t(e,null,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.limitType,this.startAt,this.endAt)},t.prototype.matchesAllDocuments=function(){return 0===this.filters.length&&null===this.limit&&null==this.startAt&&null==this.endAt&&(0===this.explicitOrderBy.length||1===this.explicitOrderBy.length&&this.explicitOrderBy[0].field.isKeyField())},t.prototype.canonicalId=function(){return this.toTarget().canonicalId()+"|lt:"+this.limitType},t.prototype.toString=function(){return"Query(target="+this.toTarget().toString()+"; limitType="+this.limitType+")"},t.prototype.isEqual=function(t){return this.toTarget().isEqual(t.toTarget())&&this.limitType===t.limitType},t.prototype.docComparator=function(t,e){for(var n=!1,r=0,i=this.orderBy;r<i.length;r++){var o=i[r],a=o.compare(t,e);if(0!==a)return a;n=n||o.field.isKeyField()}return _(n,"orderBy used that doesn't compare on key field"),0},t.prototype.matches=function(t){return this.matchesPathAndCollectionGroup(t)&&this.matchesOrderBy(t)&&this.matchesFilters(t)&&this.matchesBounds(t)},t.prototype.hasLimitToFirst=function(){return!Jn(this.limit)&&this.limitType===$n.First},t.prototype.hasLimitToLast=function(){return!Jn(this.limit)&&this.limitType===$n.Last},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 ir&&n.isInequality())return n.field}return null},t.prototype.findFilterOperator=function(t){for(var e=0,n=this.filters;e<n.length;e++){var r=n[e];if(r instanceof ir&&t.indexOf(r.op)>=0)return r.op}return null},t.prototype.isDocumentQuery=function(){return this.toTarget().isDocumentQuery()},t.prototype.isCollectionGroupQuery=function(){return null!==this.collectionGroup},t.prototype.toTarget=function(){if(!this.memoizedTarget)if(this.limitType===$n.First)this.memoizedTarget=new tr(this.path,this.collectionGroup,this.orderBy,this.filters,this.limit,this.startAt,this.endAt);else{for(var t=[],e=0,n=this.orderBy;e<n.length;e++){var r=n[e],i=r.dir===hr.DESCENDING?hr.ASCENDING:hr.DESCENDING;t.push(new fr(r.field,i))}var o=this.endAt?new lr(this.endAt.position,!this.endAt.before):null,a=this.startAt?new lr(this.startAt.position,!this.startAt.before):null;this.memoizedTarget=new tr(this.path,this.collectionGroup,t,this.filters,this.limit,o,a)}return this.memoizedTarget},t.prototype.matchesPathAndCollectionGroup=function(t){var e=t.key.path;return null!==this.collectionGroup?t.key.hasCollectionId(this.collectionGroup)&&this.path.isPrefixOf(e):pt.isDocumentKey(this.path)?this.path.isEqual(e):this.path.isImmediateParentOf(e)},t.prototype.matchesOrderBy=function(t){for(var e=0,n=this.explicitOrderBy;e<n.length;e++){var r=n[e];if(!r.field.isKeyField()&&null===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){_(t.position.length<=this.orderBy.length,"Bound is longer than orderBy")},t}(),nr=function(){},rr=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;case"in":return t.IN;case"array-contains-any":return t.ARRAY_CONTAINS_ANY;default:return v("Unknown FieldFilter operator: "+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.IN=new t("in"),t.ARRAY_CONTAINS_ANY=new t("array-contains-any"),t}(),ir=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 a.__extends(e,t),e.create=function(t,n,r){if(t.isKeyField())return n===rr.IN?(_(r instanceof ze,"Comparing on key with IN, but filter value not an ArrayValue"),_(r.internalValue.every((function(t){return t instanceof Ve})),"Comparing on key with IN, but an array value was not a RefValue"),new ar(t,r)):(_(r instanceof Ve,"Comparing on key, but filter value not a RefValue"),_(n!==rr.ARRAY_CONTAINS&&n!==rr.ARRAY_CONTAINS_ANY,"'"+n.toString()+"' queries don't make sense on document keys."),new or(t,n,r));if(r.isEqual(ke.INSTANCE)){if(n!==rr.EQUAL)throw new T(E.INVALID_ARGUMENT,"Invalid query. Null supports only equality comparisons.");return new e(t,n,r)}if(r.isEqual(Me.NAN)){if(n!==rr.EQUAL)throw new T(E.INVALID_ARGUMENT,"Invalid query. NaN supports only equality comparisons.");return new e(t,n,r)}return n===rr.ARRAY_CONTAINS?new sr(t,r):n===rr.IN?(_(r instanceof ze,"IN filter has invalid value: "+r.toString()),new ur(t,r)):n===rr.ARRAY_CONTAINS_ANY?(_(r instanceof ze,"ARRAY_CONTAINS_ANY filter has invalid value: "+r.toString()),new cr(t,r)):new e(t,n,r)},e.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&this.value.typeOrder===e.typeOrder&&this.matchesComparison(e.compareTo(this.value))},e.prototype.matchesComparison=function(t){switch(this.op){case rr.LESS_THAN:return t<0;case rr.LESS_THAN_OR_EQUAL:return t<=0;case rr.EQUAL:return 0===t;case rr.GREATER_THAN:return t>0;case rr.GREATER_THAN_OR_EQUAL:return t>=0;default:return v("Unknown FieldFilter operator: "+this.op)}},e.prototype.isInequality=function(){return[rr.LESS_THAN,rr.LESS_THAN_OR_EQUAL,rr.GREATER_THAN,rr.GREATER_THAN_OR_EQUAL].indexOf(this.op)>=0},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}(nr),or=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a.__extends(e,t),e.prototype.matches=function(t){var e=this.value,n=pt.comparator(t.key,e.key);return this.matchesComparison(n)},e}(ir),ar=function(t){function e(e,n){var r=t.call(this,e,rr.IN,n)||this;return r.value=n,r}return a.__extends(e,t),e.prototype.matches=function(t){return this.value.internalValue.some((function(e){return t.key.isEqual(e.key)}))},e}(ir),sr=function(t){function e(e,n){return t.call(this,e,rr.ARRAY_CONTAINS,n)||this}return a.__extends(e,t),e.prototype.matches=function(t){var e=t.field(this.field);return e instanceof ze&&e.contains(this.value)},e}(ir),ur=function(t){function e(e,n){var r=t.call(this,e,rr.IN,n)||this;return r.value=n,r}return a.__extends(e,t),e.prototype.matches=function(t){var e=this.value,n=t.field(this.field);return null!==n&&e.contains(n)},e}(ir),cr=function(t){function e(e,n){var r=t.call(this,e,rr.ARRAY_CONTAINS_ANY,n)||this;return r.value=n,r}return a.__extends(e,t),e.prototype.matches=function(t){var e=this,n=t.field(this.field);return n instanceof ze&&n.internalValue.some((function(t){return e.value.contains(t)}))},e}(ir),hr=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}(),lr=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){_(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())_(o instanceof Ve,"Bound has a non-key value where the key path is being used."),n=pt.comparator(o.key,e.key);else{var a=e.field(i.field);_(null!==a,"Field should exist since document matched the orderBy already."),n=o.compareTo(a)}if(i.dir===hr.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];if(!n.isEqual(r))return!1}return!0},t}(),fr=function(){function t(t,e){this.field=t,void 0===e&&(e=hr.ASCENDING),this.dir=e,this.isKeyOrderBy=t.isKeyField()}return t.prototype.compare=function(t,e){var n=this.isKeyOrderBy?Qe.compareByKey(t,e):Qe.compareByField(this.field,t,e);switch(this.dir){case hr.ASCENDING:return n;case hr.DESCENDING:return-1*n;default:return v("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}(),pr=new fr(ft.keyField(),hr.ASCENDING),dr=new fr(ft.keyField(),hr.DESCENDING),mr=function(){function t(){}return t.prototype.setLocalDocumentsView=function(t){this.localDocumentsView=t},t.prototype.getDocumentsMatchingQuery=function(t,e,n,r){var o=this;return _(void 0!==this.localDocumentsView,"setLocalDocumentsView() not called"),e.matchesAllDocuments()?this.executeFullCollectionScan(t,e):n.isEqual(It.MIN)?this.executeFullCollectionScan(t,e):this.localDocumentsView.getDocuments(t,r).next((function(a){var s=o.applyQuery(e,a);return(e.hasLimitToFirst()||e.hasLimitToLast())&&o.needsRefill(e.limitType,s,r,n)?o.executeFullCollectionScan(t,e):(p()<=i.DEBUG&&m("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),e.toString()),o.localDocumentsView.getDocumentsMatchingQuery(t,e,n).next((function(t){return s.forEach((function(e){t=t.insert(e.key,e)})),t})))}))},t.prototype.applyQuery=function(t,e){var n=new Rt((function(e,n){return t.docComparator(e,n)}));return e.forEach((function(e,r){r instanceof Qe&&t.matches(r)&&(n=n.add(r))})),n},t.prototype.needsRefill=function(t,e,n,r){if(n.size!==e.size)return!0;var i=t===$n.First?e.last():e.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)},t.prototype.executeFullCollectionScan=function(t,e){return p()<=i.DEBUG&&m("IndexFreeQueryEngine","Using full collection scan to execute query: %s",e.toString()),this.localDocumentsView.getDocumentsMatchingQuery(t,e,It.MIN)},t}(),yr=function(){function t(t,e,n){this.remoteDocumentCache=t,this.mutationQueue=e,this.indexManager=n}return t.prototype.getDocument=function(t,e){var n=this;return this.mutationQueue.getAllMutationBatchesAffectingDocumentKey(t,e).next((function(r){return n.getDocumentInternal(t,e,r)}))},t.prototype.getDocumentInternal=function(t,e,n){return this.remoteDocumentCache.getEntry(t,e).next((function(t){for(var r=0,i=n;r<i.length;r++){t=i[r].applyToLocalView(e,t)}return t}))},t.prototype.applyLocalMutationsToDocuments=function(t,e,n){var r=Mt();return e.forEach((function(t,e){for(var i=0,o=n;i<o.length;i++){e=o[i].applyToLocalView(t,e)}r=r.insert(t,e)})),r},t.prototype.getDocuments=function(t,e){var n=this;return this.remoteDocumentCache.getEntries(t,e).next((function(e){return n.getLocalViewOfDocuments(t,e)}))},t.prototype.getLocalViewOfDocuments=function(t,e){var n=this;return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,e).next((function(r){var i=n.applyLocalMutationsToDocuments(t,e,r),o=Pt();return i.forEach((function(t,e){e||(e=new Ke(t,It.forDeletedDoc())),o=o.insert(t,e)})),o}))},t.prototype.getDocumentsMatchingQuery=function(t,e,n){return e.isDocumentQuery()?this.getDocumentsMatchingDocumentQuery(t,e.path):e.isCollectionGroupQuery()?this.getDocumentsMatchingCollectionGroupQuery(t,e,n):this.getDocumentsMatchingCollectionQuery(t,e,n)},t.prototype.getDocumentsMatchingDocumentQuery=function(t,e){return this.getDocument(t,new pt(e)).next((function(t){var e=Ft();return t instanceof Qe&&(e=e.insert(t.key,t)),e}))},t.prototype.getDocumentsMatchingCollectionGroupQuery=function(t,e,n){var r=this;_(e.path.isEmpty(),"Currently we only support collection group queries at the root.");var i=e.collectionGroup,o=Ft();return this.indexManager.getCollectionParents(t,i).next((function(a){return Kt.forEach(a,(function(a){var s=e.asCollectionQueryAtPath(a.child(i));return r.getDocumentsMatchingCollectionQuery(t,s,n).next((function(t){t.forEach((function(t,e){o=o.insert(t,e)}))}))})).next((function(){return o}))}))},t.prototype.getDocumentsMatchingCollectionQuery=function(t,e,n){var r,i,o=this;return this.remoteDocumentCache.getDocumentsMatchingQuery(t,e,n).next((function(n){return r=n,o.mutationQueue.getAllMutationBatchesAffectingQuery(t,e)})).next((function(e){return i=e,o.addMissingBaseDocuments(t,i,r).next((function(t){r=t;for(var e=0,n=i;e<n.length;e++)for(var o=n[e],a=0,s=o.mutations;a<s.length;a++){var u=s[a],c=u.key,h=r.get(c),l=u.applyToLocalView(h,h,o.localWriteTime);r=l instanceof Qe?r.insert(c,l):r.remove(c)}}))})).next((function(){return r.forEach((function(t,n){e.matches(n)||(r=r.remove(t))})),r}))},t.prototype.addMissingBaseDocuments=function(t,e,n){for(var r=Bt(),i=0,o=e;i<o.length;i++)for(var a=0,s=o[i].mutations;a<s.length;a++){var u=s[a];u instanceof Se&&null===n.get(u.key)&&(r=r.add(u.key))}var c=n;return this.remoteDocumentCache.getEntries(t,r).next((function(t){return t.forEach((function(t,e){null!==e&&e instanceof Qe&&(c=c.insert(t,e))})),c}))},t}(),gr=function(){function t(){this.refsByKey=new Rt(vr.compareByKey),this.refsByTarget=new Rt(vr.compareByTargetId)}return t.prototype.isEmpty=function(){return this.refsByKey.isEmpty()},t.prototype.addReference=function(t,e){var n=new vr(t,e);this.refsByKey=this.refsByKey.add(n),this.refsByTarget=this.refsByTarget.add(n)},t.prototype.addReferences=function(t,e){var n=this;t.forEach((function(t){return n.addReference(t,e)}))},t.prototype.removeReference=function(t,e){this.removeRef(new vr(t,e))},t.prototype.removeReferences=function(t,e){var n=this;t.forEach((function(t){return n.removeReference(t,e)}))},t.prototype.removeReferencesForId=function(t){var e=this,n=pt.EMPTY,r=new vr(n,t),i=new vr(n,t+1),o=[];return this.refsByTarget.forEachInRange([r,i],(function(t){e.removeRef(t),o.push(t.key)})),o},t.prototype.removeAllReferences=function(){var t=this;this.refsByKey.forEach((function(e){return t.removeRef(e)}))},t.prototype.removeRef=function(t){this.refsByKey=this.refsByKey.delete(t),this.refsByTarget=this.refsByTarget.delete(t)},t.prototype.referencesForId=function(t){var e=pt.EMPTY,n=new vr(e,t),r=new vr(e,t+1),i=Bt();return this.refsByTarget.forEachInRange([n,r],(function(t){i=i.add(t.key)})),i},t.prototype.containsKey=function(t){var e=new vr(t,0),n=this.refsByKey.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)},t}(),vr=function(){function t(t,e){this.key=t,this.targetOrBatchId=e}return t.compareByKey=function(t,e){return pt.comparator(t.key,e.key)||J(t.targetOrBatchId,e.targetOrBatchId)},t.compareByTargetId=function(t,e){return J(t.targetOrBatchId,e.targetOrBatchId)||pt.comparator(t.key,e.key)},t}(),_r=function(){function t(t,e,n){this.persistence=t,this.queryEngine=e,this.localViewReferences=new gr,this.targetDataByTarget=new Dt(J),this.targetIdByTarget=new Ge((function(t){return t.canonicalId()})),this.lastDocumentChangeReadTime=It.MIN,_(t.started,"LocalStore was passed an unstarted persistence implementation"),this.persistence.referenceDelegate.setInMemoryPins(this.localViewReferences),this.mutationQueue=t.getMutationQueue(n),this.remoteDocuments=t.getRemoteDocumentCache(),this.targetCache=t.getTargetCache(),this.localDocuments=new yr(this.remoteDocuments,this.mutationQueue,this.persistence.getIndexManager()),this.queryEngine.setLocalDocumentsView(this.localDocuments)}return t.prototype.start=function(){return this.synchronizeLastDocumentChangeReadTime()},t.prototype.handleUserChange=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n,r,i=this;return a.__generator(this,(function(o){switch(o.label){case 0:return e=this.mutationQueue,n=this.localDocuments,[4,this.persistence.runTransaction("Handle user change","readonly-idempotent",(function(r){var o;return i.mutationQueue.getAllMutationBatches(r).next((function(a){return o=a,e=i.persistence.getMutationQueue(t),n=new yr(i.remoteDocuments,e,i.persistence.getIndexManager()),e.getAllMutationBatches(r)})).next((function(t){for(var e=[],i=[],a=Bt(),s=0,u=o;s<u.length;s++){var c=u[s];e.push(c.batchId);for(var h=0,l=c.mutations;h<l.length;h++){var f=l[h];a=a.add(f.key)}}for(var p=0,d=t;p<d.length;p++){c=d[p];i.push(c.batchId);for(var m=0,y=c.mutations;m<y.length;m++){f=y[m];a=a.add(f.key)}}return n.getDocuments(r,a).next((function(t){return{affectedDocuments:t,removedBatchIds:e,addedBatchIds:i}}))}))}))];case 1:return r=o.sent(),this.mutationQueue=e,this.localDocuments=n,this.queryEngine.setLocalDocumentsView(this.localDocuments),[2,r]}}))}))},t.prototype.localWrite=function(t){var e,n=this,r=St.now(),i=t.reduce((function(t,e){return t.add(e.key)}),Bt());return this.persistence.runTransaction("Locally write mutations","readwrite-idempotent",(function(o){return n.localDocuments.getDocuments(o,i).next((function(i){e=i;for(var a=[],s=0,u=t;s<u.length;s++){var c=u[s],h=c.extractBaseValue(e.get(c.key));null!=h&&a.push(new Se(c.key,h,h.fieldMask(),Ee.exists(!0)))}return n.mutationQueue.addMutationBatch(o,r,a,t)}))})).then((function(t){var n=t.applyToLocalDocumentSet(e);return{batchId:t.batchId,changes:n}}))},t.prototype.lookupMutationDocuments=function(t){var e=this;return this.persistence.runTransaction("Lookup mutation documents","readonly-idempotent",(function(n){return e.mutationQueue.lookupMutationKeys(n,t).next((function(t){return t?e.localDocuments.getDocuments(n,t):Kt.resolve(null)}))}))},t.prototype.acknowledgeBatch=function(t){var e=this;return this.persistence.runTransaction("Acknowledge batch","readwrite-primary-idempotent",(function(n){var r=t.batch.keys(),i=e.remoteDocuments.newChangeBuffer({trackRemovals:!0});return e.mutationQueue.acknowledgeBatch(n,t.batch,t.streamToken).next((function(){return e.applyWriteToRemoteDocuments(n,t,i)})).next((function(){return i.apply(n)})).next((function(){return e.mutationQueue.performConsistencyCheck(n)})).next((function(){return e.localDocuments.getDocuments(n,r)}))}))},t.prototype.rejectBatch=function(t){var e=this;return this.persistence.runTransaction("Reject batch","readwrite-primary-idempotent",(function(n){var r;return e.mutationQueue.lookupMutationBatch(n,t).next((function(t){return _(null!==t,"Attempt to reject nonexistent batch!"),r=t.keys(),e.mutationQueue.removeMutationBatch(n,t)})).next((function(){return e.mutationQueue.performConsistencyCheck(n)})).next((function(){return e.localDocuments.getDocuments(n,r)}))}))},t.prototype.getHighestUnacknowledgedBatchId=function(){var t=this;return this.persistence.runTransaction("Get highest unacknowledged batch id","readonly-idempotent",(function(e){return t.mutationQueue.getHighestUnacknowledgedBatchId(e)}))},t.prototype.getLastStreamToken=function(){var t=this;return this.persistence.runTransaction("Get last stream token","readonly-idempotent",(function(e){return t.mutationQueue.getLastStreamToken(e)}))},t.prototype.setLastStreamToken=function(t){var e=this;return this.persistence.runTransaction("Set last stream token","readwrite-primary-idempotent",(function(n){return e.mutationQueue.setLastStreamToken(n,t)}))},t.prototype.getLastRemoteSnapshotVersion=function(){var t=this;return this.persistence.runTransaction("Get last remote snapshot version","readonly-idempotent",(function(e){return t.targetCache.getLastRemoteSnapshotVersion(e)}))},t.prototype.applyRemoteEvent=function(e){var n=this,r=e.snapshotVersion,i=this.targetDataByTarget;return this.persistence.runTransaction("Apply remote event","readwrite-primary-idempotent",(function(o){var a=n.remoteDocuments.newChangeBuffer({trackRemovals:!0});i=n.targetDataByTarget;var s=[];D(e.targetChanges,(function(e,a){var u=i.get(e);if(u){s.push(n.targetCache.removeMatchingKeys(o,a.removedDocuments,e).next((function(){return n.targetCache.addMatchingKeys(o,a.addedDocuments,e)})));var c=a.resumeToken;if(c.length>0){var h=u.withResumeToken(c,r).withSequenceNumber(o.currentSequenceNumber);i=i.insert(e,h),t.shouldPersistTargetData(u,h,a)&&s.push(n.targetCache.updateTargetData(o,h))}}}));var u=Pt(),c=Bt();if(e.documentUpdates.forEach((function(t,e){c=c.add(t)})),s.push(a.getEntries(o,c).next((function(t){e.documentUpdates.forEach((function(i,c){var h=t.get(i);c instanceof Ke&&c.version.isEqual(It.MIN)?(a.removeEntry(i,r),u=u.insert(i,c)):null==h||c.version.compareTo(h.version)>0||0===c.version.compareTo(h.version)&&h.hasPendingWrites?(_(!It.MIN.isEqual(r),"Cannot add a document when the remote version is zero"),a.addEntry(c,r),u=u.insert(i,c)):m("LocalStore","Ignoring outdated watch update for ",i,". Current version:",h.version," Watch version:",c.version),e.resolvedLimboDocuments.has(i)&&s.push(n.persistence.referenceDelegate.updateLimboDocument(o,i))}))}))),!r.isEqual(It.MIN)){var h=n.targetCache.getLastRemoteSnapshotVersion(o).next((function(t){return _(r.compareTo(t)>=0,"Watch stream reverted to previous snapshot?? "+r+" < "+t),n.targetCache.setTargetsMetadata(o,o.currentSequenceNumber,r)}));s.push(h)}return Kt.waitFor(s).next((function(){return a.apply(o)})).next((function(){return n.localDocuments.getLocalViewOfDocuments(o,u)}))})).then((function(t){return n.targetDataByTarget=i,t}))},t.shouldPersistTargetData=function(t,e,n){return _(e.resumeToken.length>0,"Attempted to persist target data with no resume token"),0===t.resumeToken.length||(e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=this.RESUME_TOKEN_MAX_AGE_MICROS||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0)},t.prototype.notifyLocalViewChanges=function(t){for(var e=this,n=0,r=t;n<r.length;n++){var i=r[n],o=i.targetId;if(this.localViewReferences.addReferences(i.addedKeys,o),this.localViewReferences.removeReferences(i.removedKeys,o),!i.fromCache){var a=this.targetDataByTarget.get(o);_(null!==a,"Can't set limbo-free snapshot version for unknown target: "+o);var s=a.snapshotVersion,u=a.withLastLimboFreeSnapshotVersion(s);this.targetDataByTarget=this.targetDataByTarget.insert(o,u)}}return this.persistence.runTransaction("notifyLocalViewChanges","readwrite-idempotent",(function(n){return Kt.forEach(t,(function(t){return Kt.forEach(t.removedKeys,(function(t){return e.persistence.referenceDelegate.removeReference(n,t)}))}))}))},t.prototype.nextMutationBatch=function(t){var e=this;return this.persistence.runTransaction("Get next mutation batch","readonly-idempotent",(function(n){return void 0===t&&(t=-1),e.mutationQueue.getNextMutationBatchAfterBatchId(n,t)}))},t.prototype.readDocument=function(t){var e=this;return this.persistence.runTransaction("read document","readonly-idempotent",(function(n){return e.localDocuments.getDocument(n,t)}))},t.prototype.allocateTarget=function(t){var e=this;return this.persistence.runTransaction("Allocate target","readwrite-idempotent",(function(n){var r;return e.targetCache.getTargetData(n,t).next((function(i){return i?(r=i,Kt.resolve(r)):e.targetCache.allocateTargetId(n).next((function(i){return r=new Nn(t,i,wn.Listen,n.currentSequenceNumber),e.targetCache.addTargetData(n,r).next((function(){return r}))}))}))})).then((function(n){return null===e.targetDataByTarget.get(n.targetId)&&(e.targetDataByTarget=e.targetDataByTarget.insert(n.targetId,n),e.targetIdByTarget.set(t,n.targetId)),n}))},t.prototype.getTargetData=function(t,e){var n=this.targetIdByTarget.get(e);return void 0!==n?Kt.resolve(this.targetDataByTarget.get(n)):this.targetCache.getTargetData(t,e)},t.prototype.releaseTarget=function(t,e){var n=this,r=this.targetDataByTarget.get(t);_(null!==r,"Tried to release nonexistent target: "+t);var i=e?"readwrite-idempotent":"readwrite-primary-idempotent";return this.persistence.runTransaction("Release target",i,(function(i){var o=n.localViewReferences.removeReferencesForId(t);return e?Kt.resolve():Kt.forEach(o,(function(t){return n.persistence.referenceDelegate.removeReference(i,t)})).next((function(){n.persistence.referenceDelegate.removeTarget(i,r)}))})).then((function(){n.targetDataByTarget=n.targetDataByTarget.remove(t),n.targetIdByTarget.delete(r.target)}))},t.prototype.executeQuery=function(t,e){var n=this,r=It.MIN,i=Bt();return this.persistence.runTransaction("Execute query","readonly-idempotent",(function(o){return n.getTargetData(o,t.toTarget()).next((function(t){if(t)return r=t.lastLimboFreeSnapshotVersion,n.targetCache.getMatchingKeysForTargetId(o,t.targetId).next((function(t){i=t}))})).next((function(){return n.queryEngine.getDocumentsMatchingQuery(o,t,e?r:It.MIN,e?i:Bt())})).next((function(t){return{documents:t,remoteKeys:i}}))}))},t.prototype.remoteDocumentKeys=function(t){var e=this;return this.persistence.runTransaction("Remote document keys","readonly-idempotent",(function(n){return e.targetCache.getMatchingKeysForTargetId(n,t)}))},t.prototype.getActiveClients=function(){return this.persistence.getActiveClients()},t.prototype.removeCachedMutationBatchMetadata=function(t){this.mutationQueue.removeCachedMutationKeys(t)},t.prototype.setNetworkEnabled=function(t){this.persistence.setNetworkEnabled(t)},t.prototype.applyWriteToRemoteDocuments=function(t,e,n){var r=this,i=e.batch,o=i.keys(),a=Kt.resolve();return o.forEach((function(r){a=a.next((function(){return n.getEntry(t,r)})).next((function(t){var o=t,a=e.docVersions.get(r);_(null!==a,"ackVersions should contain every doc in the write."),(!o||o.version.compareTo(a)<0)&&((o=i.applyToRemoteDocument(r,o,e))?n.addEntry(o,e.commitVersion):_(!t,"Mutation batch "+i+" applied to document "+t+" resulted in null"))}))})),a.next((function(){return r.mutationQueue.removeMutationBatch(t,i)}))},t.prototype.collectGarbage=function(t){var e=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary-idempotent",(function(n){return t.collect(n,e.targetDataByTarget)}))},t.prototype.getTarget=function(t){var e=this,n=this.targetDataByTarget.get(t);return n?Promise.resolve(n.target):this.persistence.runTransaction("Get target data","readonly-idempotent",(function(n){return e.targetCache.getTargetDataForTarget(n,t).next((function(t){return t?t.target:null}))}))},t.prototype.getNewDocumentChanges=function(){var t=this;return this.persistence.runTransaction("Get new document changes","readonly-idempotent",(function(e){return t.remoteDocuments.getNewDocumentChanges(e,t.lastDocumentChangeReadTime)})).then((function(e){var n=e.changedDocs,r=e.readTime;return t.lastDocumentChangeReadTime=r,n}))},t.prototype.synchronizeLastDocumentChangeReadTime=function(){return a.__awaiter(this,void 0,void 0,(function(){var t,e=this;return a.__generator(this,(function(n){return this.remoteDocuments instanceof Xe?(t=this.remoteDocuments,[2,this.persistence.runTransaction("Synchronize last document change read time","readonly-idempotent",(function(e){return t.getLastDocumentChange(e)})).then((function(t){var n=t.readTime;e.lastDocumentChangeReadTime=n}))]):[2]}))}))},t.RESUME_TOKEN_MAX_AGE_MICROS=3e8,t}(),br=function(){function t(t,e){this.indexManager=t,this.referenceDelegate=e,this.mutationQueue=[],this.nextBatchId=1,this.lastStreamToken=w(),this.batchesByDocumentKey=new Rt(vr.compareByKey)}return t.prototype.checkEmpty=function(t){return Kt.resolve(0===this.mutationQueue.length)},t.prototype.acknowledgeBatch=function(t,e,n){var r=e.batchId,i=this.indexOfExistingBatchId(r,"acknowledged");_(0===i,"Can only acknowledge the first batch in the mutation queue");var o=this.mutationQueue[i];return _(r===o.batchId,"Queue ordering failure: expected batch "+r+", got batch "+o.batchId),this.lastStreamToken=n,Kt.resolve()},t.prototype.getLastStreamToken=function(t){return Kt.resolve(this.lastStreamToken)},t.prototype.setLastStreamToken=function(t,e){return this.lastStreamToken=e,Kt.resolve()},t.prototype.addMutationBatch=function(t,e,n,r){_(0!==r.length,"Mutation batches should not be empty");var i=this.nextBatchId;(this.nextBatchId++,this.mutationQueue.length>0)&&_(this.mutationQueue[this.mutationQueue.length-1].batchId<i,"Mutation batchIDs must be monotonically increasing order");var o=new Wt(i,e,n,r);this.mutationQueue.push(o);for(var a=0,s=r;a<s.length;a++){var u=s[a];this.batchesByDocumentKey=this.batchesByDocumentKey.add(new vr(u.key,i)),this.indexManager.addToCollectionParentIndex(t,u.key.path.popLast())}return Kt.resolve(o)},t.prototype.lookupMutationBatch=function(t,e){return Kt.resolve(this.findMutationBatch(e))},t.prototype.lookupMutationKeys=function(t,e){var n=this.findMutationBatch(e);return _(null!=n,"Failed to find local mutation batch."),Kt.resolve(n.keys())},t.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=e+1,r=this.indexOfBatchId(n),i=r<0?0:r;return Kt.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)},t.prototype.getHighestUnacknowledgedBatchId=function(){return Kt.resolve(0===this.mutationQueue.length?-1:this.nextBatchId-1)},t.prototype.getAllMutationBatches=function(t){return Kt.resolve(this.mutationQueue.slice())},t.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,e){var n=this,r=new vr(e,0),i=new vr(e,Number.POSITIVE_INFINITY),o=[];return this.batchesByDocumentKey.forEachInRange([r,i],(function(t){_(e.isEqual(t.key),"Should only iterate over a single key's batches");var r=n.findMutationBatch(t.targetOrBatchId);_(null!==r,"Batches in the index must exist in the main table"),o.push(r)})),Kt.resolve(o)},t.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var n=this,r=new Rt(J);return e.forEach((function(t){var e=new vr(t,0),i=new vr(t,Number.POSITIVE_INFINITY);n.batchesByDocumentKey.forEachInRange([e,i],(function(e){_(t.isEqual(e.key),"For each key, should only iterate over a single key's batches"),r=r.add(e.targetOrBatchId)}))})),Kt.resolve(this.findMutationBatches(r))},t.prototype.getAllMutationBatchesAffectingQuery=function(t,e){_(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var n=e.path,r=n.length+1,i=n;pt.isDocumentKey(i)||(i=i.child(""));var o=new vr(new pt(i),0),a=new Rt(J);return this.batchesByDocumentKey.forEachWhile((function(t){var e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===r&&(a=a.add(t.targetOrBatchId)),!0)}),o),Kt.resolve(this.findMutationBatches(a))},t.prototype.findMutationBatches=function(t){var e=this,n=[];return t.forEach((function(t){var r=e.findMutationBatch(t);null!==r&&n.push(r)})),n},t.prototype.removeMutationBatch=function(t,e){var n=this;_(0===this.indexOfExistingBatchId(e.batchId,"removed"),"Can only remove the first entry of the mutation queue"),this.mutationQueue.shift();var r=this.batchesByDocumentKey;return Kt.forEach(e.mutations,(function(i){var o=new vr(i.key,e.batchId);return r=r.delete(o),n.referenceDelegate.removeMutationReference(t,i.key)})).next((function(){n.batchesByDocumentKey=r}))},t.prototype.removeCachedMutationKeys=function(t){},t.prototype.containsKey=function(t,e){var n=new vr(e,0),r=this.batchesByDocumentKey.firstAfterOrEqual(n);return Kt.resolve(e.isEqual(r&&r.key))},t.prototype.performConsistencyCheck=function(t){return 0===this.mutationQueue.length&&_(this.batchesByDocumentKey.isEmpty(),"Document leak -- detected dangling mutation references when queue is empty."),Kt.resolve()},t.prototype.indexOfExistingBatchId=function(t,e){var n=this.indexOfBatchId(t);return _(n>=0&&n<this.mutationQueue.length,"Batches must exist to be "+e),n},t.prototype.indexOfBatchId=function(t){return 0===this.mutationQueue.length?0:t-this.mutationQueue[0].batchId},t.prototype.findMutationBatch=function(t){var e=this.indexOfBatchId(t);if(e<0||e>=this.mutationQueue.length)return null;var n=this.mutationQueue[e];return _(n.batchId===t,"If found batch must match"),n},t}();var wr,Er=function(){function t(t,e){this.indexManager=t,this.sizer=e,this.docs=new Dt(pt.comparator),this.size=0}return t.prototype.addEntry=function(t,e,n){_(!n.isEqual(It.MIN),"Cannot add a document with a read time of zero");var r=e.key,i=this.docs.get(r),o=i?i.size:0,a=this.sizer(e);return this.docs=this.docs.insert(r,{maybeDocument:e,size:a,readTime:n}),this.size+=a-o,this.indexManager.addToCollectionParentIndex(t,r.path.popLast())},t.prototype.removeEntry=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},t.prototype.getEntry=function(t,e){var n=this.docs.get(e);return Kt.resolve(n?n.maybeDocument:null)},t.prototype.getEntries=function(t,e){var n=this,r=Mt();return e.forEach((function(t){var e=n.docs.get(t);r=r.insert(t,e?e.maybeDocument:null)})),Kt.resolve(r)},t.prototype.getDocumentsMatchingQuery=function(t,e,n){_(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");for(var r=Ft(),i=new pt(e.path.child("")),o=this.docs.getIteratorFrom(i);o.hasNext();){var a=o.getNext(),s=a.key,u=a.value,c=u.maybeDocument,h=u.readTime;if(!e.path.isPrefixOf(s.path))break;h.compareTo(n)<=0||c instanceof Qe&&e.matches(c)&&(r=r.insert(c.key,c))}return Kt.resolve(r)},t.prototype.forEachDocumentKey=function(t,e){return Kt.forEach(this.docs,(function(t){return e(t)}))},t.prototype.getNewDocumentChanges=function(t,e){throw new Error("getNewDocumentChanges() is not supported with MemoryPersistence")},t.prototype.newChangeBuffer=function(e){return new t.RemoteDocumentChangeBuffer(this)},t.prototype.getSize=function(t){return Kt.resolve(this.size)},t.RemoteDocumentChangeBuffer=function(t){function e(e){var n=t.call(this)||this;return n.documentCache=e,n}return a.__extends(e,t),e.prototype.applyChanges=function(t){var e=this,n=[];return this.changes.forEach((function(r,i){i?n.push(e.documentCache.addEntry(t,i,e.readTime)):e.documentCache.removeEntry(r)})),Kt.waitFor(n)},e.prototype.getFromCache=function(t,e){return this.documentCache.getEntry(t,e)},e.prototype.getAllFromCache=function(t,e){return this.documentCache.getEntries(t,e)},e}(Ye),t}(),Tr=function(){function t(t){this.persistence=t,this.targets=new Ge((function(t){return t.canonicalId()})),this.lastRemoteSnapshotVersion=It.MIN,this.highestTargetId=0,this.highestSequenceNumber=0,this.references=new gr,this.targetCount=0,this.targetIdGenerator=he.forTargetCache()}return t.prototype.forEachTarget=function(t,e){return this.targets.forEach((function(t,n){return e(n)})),Kt.resolve()},t.prototype.getLastRemoteSnapshotVersion=function(t){return Kt.resolve(this.lastRemoteSnapshotVersion)},t.prototype.getHighestSequenceNumber=function(t){return Kt.resolve(this.highestSequenceNumber)},t.prototype.allocateTargetId=function(t){var e=this.targetIdGenerator.after(this.highestTargetId);return this.highestTargetId=e,Kt.resolve(e)},t.prototype.setTargetsMetadata=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.highestSequenceNumber&&(this.highestSequenceNumber=e),Kt.resolve()},t.prototype.saveTargetData=function(t){this.targets.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.highestTargetId=e),t.sequenceNumber>this.highestSequenceNumber&&(this.highestSequenceNumber=t.sequenceNumber)},t.prototype.addTargetData=function(t,e){return _(!this.targets.has(e.target),"Adding a target that already exists"),this.saveTargetData(e),this.targetCount+=1,Kt.resolve()},t.prototype.updateTargetData=function(t,e){return _(this.targets.has(e.target),"Updating a non-existent target"),this.saveTargetData(e),Kt.resolve()},t.prototype.removeTargetData=function(t,e){return _(this.targetCount>0,"Removing a target from an empty cache"),_(this.targets.has(e.target),"Removing a non-existent target from the cache"),this.targets.delete(e.target),this.references.removeReferencesForId(e.targetId),this.targetCount-=1,Kt.resolve()},t.prototype.removeTargets=function(t,e,n){var r=this,i=0,o=[];return this.targets.forEach((function(a,s){s.sequenceNumber<=e&&null===n.get(s.targetId)&&(r.targets.delete(a),o.push(r.removeMatchingKeysForTargetId(t,s.targetId)),i++)})),Kt.waitFor(o).next((function(){return i}))},t.prototype.getTargetCount=function(t){return Kt.resolve(this.targetCount)},t.prototype.getTargetData=function(t,e){var n=this.targets.get(e)||null;return Kt.resolve(n)},t.prototype.getTargetDataForTarget=function(t,e){return v("Not yet implemented.")},t.prototype.addMatchingKeys=function(t,e,n){this.references.addReferences(e,n);var r=this.persistence.referenceDelegate,i=[];return r&&e.forEach((function(e){i.push(r.addReference(t,e))})),Kt.waitFor(i)},t.prototype.removeMatchingKeys=function(t,e,n){this.references.removeReferences(e,n);var r=this.persistence.referenceDelegate,i=[];return r&&e.forEach((function(e){i.push(r.removeReference(t,e))})),Kt.waitFor(i)},t.prototype.removeMatchingKeysForTargetId=function(t,e){return this.references.removeReferencesForId(e),Kt.resolve()},t.prototype.getMatchingKeysForTargetId=function(t,e){var n=this.references.referencesForId(e);return Kt.resolve(n)},t.prototype.containsKey=function(t,e){return Kt.resolve(this.references.containsKey(e))},t}(),Cr=function(){function t(t,e){var n=this;this.clientId=t,this.mutationQueues={},this.listenSequence=new ut(0),this._started=!1,this._started=!0,this.referenceDelegate=e(this),this.targetCache=new Tr(this);this.indexManager=new en,this.remoteDocumentCache=new Er(this.indexManager,(function(t){return n.referenceDelegate.documentSize(t)}))}return t.createLruPersistence=function(e,n,r){return new t(e,(function(t){return new Dr(t,new An(n),r)}))},t.createEagerPersistence=function(e){return new t(e,(function(t){return new Ir(t)}))},t.prototype.shutdown=function(){return this._started=!1,Promise.resolve()},Object.defineProperty(t.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),t.prototype.getActiveClients=function(){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(t){return[2,[this.clientId]]}))}))},t.prototype.setPrimaryStateListener=function(t){return t(!0)},t.prototype.setDatabaseDeletedListener=function(){},t.prototype.setNetworkEnabled=function(t){},t.prototype.getIndexManager=function(){return this.indexManager},t.prototype.getMutationQueue=function(t){var e=this.mutationQueues[t.toKey()];return e||(e=new br(this.indexManager,this.referenceDelegate),this.mutationQueues[t.toKey()]=e),e},t.prototype.getTargetCache=function(){return this.targetCache},t.prototype.getRemoteDocumentCache=function(){return this.remoteDocumentCache},t.prototype.runTransaction=function(t,e,n){var r=this;m("MemoryPersistence","Starting transaction:",t);var i=new Sr(this.listenSequence.next());return this.referenceDelegate.onTransactionStarted(),n(i).next((function(t){return r.referenceDelegate.onTransactionCommitted(i).next((function(){return t}))})).toPromise().then((function(t){return i.raiseOnCommittedEvent(),t}))},t.prototype.mutationQueuesContainKey=function(t,e){return Kt.or((n=this.mutationQueues,r=[],N(n,(function(t,e){return r.push(e)})),r).map((function(n){return function(){return n.containsKey(t,e)}})));var n,r},t}(),Sr=function(t){function e(e){var n=t.call(this)||this;return n.currentSequenceNumber=e,n}return a.__extends(e,t),e}(Ln),Ir=function(){function t(t){this.persistence=t,this.inMemoryPins=null,this._orphanedDocuments=null}return Object.defineProperty(t.prototype,"orphanedDocuments",{get:function(){if(this._orphanedDocuments)return this._orphanedDocuments;throw v("orphanedDocuments is only valid during a transaction.")},enumerable:!0,configurable:!0}),t.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},t.prototype.addReference=function(t,e){return this.orphanedDocuments.delete(e),Kt.resolve()},t.prototype.removeReference=function(t,e){return this.orphanedDocuments.add(e),Kt.resolve()},t.prototype.removeMutationReference=function(t,e){return this.orphanedDocuments.add(e),Kt.resolve()},t.prototype.removeTarget=function(t,e){var n=this,r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(t,e.targetId).next((function(t){t.forEach((function(t){return n.orphanedDocuments.add(t)}))})).next((function(){return r.removeTargetData(t,e)}))},t.prototype.onTransactionStarted=function(){this._orphanedDocuments=new Set},t.prototype.onTransactionCommitted=function(t){var e=this,n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return Kt.forEach(this.orphanedDocuments,(function(r){return e.isReferenced(t,r).next((function(t){t||n.removeEntry(r)}))})).next((function(){return e._orphanedDocuments=null,n.apply(t)}))},t.prototype.updateLimboDocument=function(t,e){var n=this;return this.isReferenced(t,e).next((function(t){t?n.orphanedDocuments.delete(e):n.orphanedDocuments.add(e)}))},t.prototype.documentSize=function(t){return 0},t.prototype.isReferenced=function(t,e){var n=this;return Kt.or([function(){return n.persistence.getTargetCache().containsKey(t,e)},function(){return n.persistence.mutationQueuesContainKey(t,e)},function(){return Kt.resolve(n.inMemoryPins.containsKey(e))}])},t}(),Dr=function(){function t(t,e,n){this.persistence=t,this.serializer=e,this.inMemoryPins=null,this.orphanedSequenceNumbers=new Ge((function(t){return wt(t.path)})),this.garbageCollector=new Mn(this,n)}return t.prototype.onTransactionStarted=function(){},t.prototype.onTransactionCommitted=function(t){return Kt.resolve()},t.prototype.forEachTarget=function(t,e){return this.persistence.getTargetCache().forEachTarget(t,e)},t.prototype.getSequenceNumberCount=function(t){var e=this.orphanedDocumentCount(t);return this.persistence.getTargetCache().getTargetCount(t).next((function(t){return e.next((function(e){return t+e}))}))},t.prototype.orphanedDocumentCount=function(t){var e=0;return this.forEachOrphanedDocumentSequenceNumber(t,(function(t){e++})).next((function(){return e}))},t.prototype.forEachOrphanedDocumentSequenceNumber=function(t,e){var n=this;return Kt.forEach(this.orphanedSequenceNumbers,(function(r,i){return n.isPinned(t,r,i).next((function(t){return t?Kt.resolve():e(i)}))}))},t.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},t.prototype.removeTargets=function(t,e,n){return this.persistence.getTargetCache().removeTargets(t,e,n)},t.prototype.removeOrphanedDocuments=function(t,e){var n=this,r=0,i=this.persistence.getRemoteDocumentCache(),o=i.newChangeBuffer();return i.forEachDocumentKey(t,(function(i){return n.isPinned(t,i,e).next((function(t){t||(r++,o.removeEntry(i))}))})).next((function(){return o.apply(t)})).next((function(){return r}))},t.prototype.removeMutationReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Kt.resolve()},t.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(t,n)},t.prototype.addReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Kt.resolve()},t.prototype.removeReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Kt.resolve()},t.prototype.updateLimboDocument=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Kt.resolve()},t.prototype.documentSize=function(t){var e,n=this.serializer.toDbRemoteDocument(t,t.version);if(n.document)e=n.document;else if(n.unknownDocument)e=n.unknownDocument;else{if(!n.noDocument)throw v("Unknown remote document type");e=n.noDocument}return JSON.stringify(e).length},t.prototype.isPinned=function(t,e,n){var r=this;return Kt.or([function(){return r.persistence.mutationQueuesContainKey(t,e)},function(){return Kt.resolve(r.inMemoryPins.containsKey(e))},function(){return r.persistence.getTargetCache().containsKey(t,e)},function(){var t=r.orphanedSequenceNumbers.get(e);return Kt.resolve(void 0!==t&&t>n)}])},t.prototype.getCacheSize=function(t){return this.persistence.getRemoteDocumentCache().getSize(t)},t}(),Nr=1e3,Ar=1.5,kr=6e4,Rr=function(){function t(t,e,n,r,i){void 0===n&&(n=Nr),void 0===r&&(r=Ar),void 0===i&&(i=kr),this.queue=t,this.timerId=e,this.initialDelayMs=n,this.backoffFactor=r,this.maxDelayMs=i,this.currentBaseMs=0,this.timerPromise=null,this.lastAttemptTime=Date.now(),this.reset()}return t.prototype.reset=function(){this.currentBaseMs=0},t.prototype.resetToMax=function(){this.currentBaseMs=this.maxDelayMs},t.prototype.backoffAndRun=function(t){var e=this;this.cancel();var n=Math.floor(this.currentBaseMs+this.jitterDelayMs()),r=Math.max(0,Date.now()-this.lastAttemptTime),i=Math.max(0,n-r);this.currentBaseMs>0&&m("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.currentBaseMs+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.timerPromise=this.queue.enqueueAfterDelay(this.timerId,i,(function(){return e.lastAttemptTime=Date.now(),t()})),this.currentBaseMs*=this.backoffFactor,this.currentBaseMs<this.initialDelayMs&&(this.currentBaseMs=this.initialDelayMs),this.currentBaseMs>this.maxDelayMs&&(this.currentBaseMs=this.maxDelayMs)},t.prototype.cancel=function(){null!==this.timerPromise&&(this.timerPromise.cancel(),this.timerPromise=null)},t.prototype.jitterDelayMs=function(){return(Math.random()-.5)*this.currentBaseMs},t}();!function(t){t[t.Initial=0]="Initial",t[t.Starting=1]="Starting",t[t.Open=2]="Open",t[t.Error=3]="Error",t[t.Backoff=4]="Backoff"}(wr||(wr={}));var Or,xr,Pr=function(){function t(t,e,n,r,i,o){this.queue=t,this.idleTimerId=n,this.connection=r,this.credentialsProvider=i,this.listener=o,this.state=wr.Initial,this.closeCount=0,this.idleTimer=null,this.stream=null,this.backoff=new Rr(t,e)}return t.prototype.isStarted=function(){return this.state===wr.Starting||this.state===wr.Open||this.state===wr.Backoff},t.prototype.isOpen=function(){return this.state===wr.Open},t.prototype.start=function(){this.state!==wr.Error?(_(this.state===wr.Initial,"Already started"),this.auth()):this.performBackoff()},t.prototype.stop=function(){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(t){switch(t.label){case 0:return this.isStarted()?[4,this.close(wr.Initial)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.inhibitBackoff=function(){_(!this.isStarted(),"Can only inhibit backoff in a stopped state"),this.state=wr.Initial,this.backoff.reset()},t.prototype.markIdle=function(){var t=this;this.isOpen()&&null===this.idleTimer&&(this.idleTimer=this.queue.enqueueAfterDelay(this.idleTimerId,6e4,(function(){return t.handleIdleCloseTimer()})))},t.prototype.sendRequest=function(t){this.cancelIdleCheck(),this.stream.send(t)},t.prototype.handleIdleCloseTimer=function(){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(t){return this.isOpen()?[2,this.close(wr.Initial)]:[2]}))}))},t.prototype.cancelIdleCheck=function(){this.idleTimer&&(this.idleTimer.cancel(),this.idleTimer=null)},t.prototype.close=function(t,e){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(n){switch(n.label){case 0:return _(this.isStarted(),"Only started streams should be closed."),_(t===wr.Error||Jn(e),"Can't provide an error when not in an error state."),this.cancelIdleCheck(),this.backoff.cancel(),this.closeCount++,t!==wr.Error?this.backoff.reset():e&&e.code===E.RESOURCE_EXHAUSTED?(y(e.toString()),y("Using maximum backoff delay to prevent overloading the backend."),this.backoff.resetToMax()):e&&e.code===E.UNAUTHENTICATED&&this.credentialsProvider.invalidateToken(),null!==this.stream&&(this.tearDown(),this.stream.close(),this.stream=null),this.state=t,[4,this.listener.onClose(e)];case 1:return n.sent(),[2]}}))}))},t.prototype.tearDown=function(){},t.prototype.auth=function(){var t=this;_(this.state===wr.Initial,"Must be in initial state to auth"),this.state=wr.Starting;var e=this.getCloseGuardedDispatcher(this.closeCount),n=this.closeCount;this.credentialsProvider.getToken().then((function(e){t.closeCount===n&&t.startStream(e)}),(function(n){e((function(){var e=new T(E.UNKNOWN,"Fetching auth token failed: "+n.message);return t.handleStreamClose(e)}))}))},t.prototype.startStream=function(t){var e=this;_(this.state===wr.Starting,"Trying to start stream in a non-starting state");var n=this.getCloseGuardedDispatcher(this.closeCount);this.stream=this.startRpc(t),this.stream.onOpen((function(){n((function(){return _(e.state===wr.Starting,"Expected stream to be in state Starting, but was "+e.state),e.state=wr.Open,e.listener.onOpen()}))})),this.stream.onClose((function(t){n((function(){return e.handleStreamClose(t)}))})),this.stream.onMessage((function(t){n((function(){return e.onMessage(t)}))}))},t.prototype.performBackoff=function(){var t=this;_(this.state===wr.Error,"Should only perform backoff when in Error state"),this.state=wr.Backoff,this.backoff.backoffAndRun((function(){return a.__awaiter(t,void 0,void 0,(function(){return a.__generator(this,(function(t){return _(this.state===wr.Backoff,"Backoff elapsed but state is now: "+this.state),this.state=wr.Initial,this.start(),_(this.isStarted(),"PersistentStream should have started"),[2]}))}))}))},t.prototype.handleStreamClose=function(t){return _(this.isStarted(),"Can't handle server close on non-started stream"),m("PersistentStream","close with error: "+t),this.stream=null,this.close(wr.Error,t)},t.prototype.getCloseGuardedDispatcher=function(t){var e=this;return function(n){e.queue.enqueueAndForget((function(){return e.closeCount===t?n():(m("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())}))}},t}(),Mr=function(t){function e(e,n,r,i,o){var a=t.call(this,e,nt.ListenStreamConnectionBackoff,nt.ListenStreamIdle,n,r,o)||this;return a.serializer=i,a}return a.__extends(e,t),e.prototype.startRpc=function(t){return this.connection.openStream("Listen",t)},e.prototype.onMessage=function(t){this.backoff.reset();var e=this.serializer.fromWatchChange(t),n=this.serializer.versionFromListenResponse(t);return this.listener.onWatchChange(e,n)},e.prototype.watch=function(t){var e={};e.database=this.serializer.encodedDatabaseId,e.addTarget=this.serializer.toTarget(t);var n=this.serializer.toListenRequestLabels(t);n&&(e.labels=n),this.sendRequest(e)},e.prototype.unwatch=function(t){var e={};e.database=this.serializer.encodedDatabaseId,e.removeTarget=t,this.sendRequest(e)},e}(Pr),Lr=function(t){function e(e,n,r,i,o){var a=t.call(this,e,nt.WriteStreamConnectionBackoff,nt.WriteStreamIdle,n,r,o)||this;return a.serializer=i,a.handshakeComplete_=!1,a.lastStreamToken=w(),a}return a.__extends(e,t),Object.defineProperty(e.prototype,"handshakeComplete",{get:function(){return this.handshakeComplete_},enumerable:!0,configurable:!0}),e.prototype.start=function(){this.handshakeComplete_=!1,t.prototype.start.call(this)},e.prototype.tearDown=function(){this.handshakeComplete_&&this.writeMutations([])},e.prototype.startRpc=function(t){return this.connection.openStream("Write",t)},e.prototype.onMessage=function(t){if(_(!!t.streamToken,"Got a write response without a stream token"),this.lastStreamToken=t.streamToken,this.handshakeComplete_){this.backoff.reset();var e=this.serializer.fromWriteResults(t.writeResults,t.commitTime),n=this.serializer.fromVersion(t.commitTime);return this.listener.onMutationResult(n,e)}return _(!t.writeResults||0===t.writeResults.length,"Got mutation results for handshake"),this.handshakeComplete_=!0,this.listener.onHandshakeComplete()},e.prototype.writeHandshake=function(){_(this.isOpen(),"Writing handshake requires an opened stream"),_(!this.handshakeComplete_,"Handshake already completed");var t={};t.database=this.serializer.encodedDatabaseId,this.sendRequest(t)},e.prototype.writeMutations=function(t){var e=this;_(this.isOpen(),"Writing mutations requires an opened stream"),_(this.handshakeComplete_,"Handshake must be complete before writing mutations"),_(this.lastStreamToken.length>0,"Trying to write mutation without a token");var n={streamToken:this.lastStreamToken,writes:t.map((function(t){return e.serializer.toMutation(t)}))};this.sendRequest(n)},e}(Pr),Fr=function(){function t(t,e,n,r){this.queue=t,this.connection=e,this.credentials=n,this.serializer=r}return t.prototype.newPersistentWriteStream=function(t){return new Lr(this.queue,this.connection,this.credentials,this.serializer,t)},t.prototype.newPersistentWatchStream=function(t){return new Mr(this.queue,this.connection,this.credentials,this.serializer,t)},t.prototype.commit=function(t){var e=this,n={database:this.serializer.encodedDatabaseId,writes:t.map((function(t){return e.serializer.toMutation(t)}))};return this.invokeRPC("Commit",n).then((function(t){return e.serializer.fromWriteResults(t.writeResults,t.commitTime)}))},t.prototype.lookup=function(t){var e=this,n={database:this.serializer.encodedDatabaseId,documents:t.map((function(t){return e.serializer.toName(t)}))};return this.invokeStreamingRPC("BatchGetDocuments",n).then((function(n){var r=Pt();n.forEach((function(t){var n=e.serializer.fromMaybeDocument(t);r=r.insert(n.key,n)}));var i=[];return t.forEach((function(t){var e=r.get(t);_(!!e,"Missing entity in write response for "+t),i.push(e)})),i}))},t.prototype.invokeRPC=function(t,e){var n=this;return this.credentials.getToken().then((function(r){return n.connection.invokeRPC(t,e,r)})).catch((function(t){throw t.code===E.UNAUTHENTICATED&&n.credentials.invalidateToken(),t}))},t.prototype.invokeStreamingRPC=function(t,e){var n=this;return this.credentials.getToken().then((function(r){return n.connection.invokeStreamingRPC(t,e,r)})).catch((function(t){throw t.code===E.UNAUTHENTICATED&&n.credentials.invalidateToken(),t}))},t}(),Ur=function(){function t(t){this.datastore=t,this.readVersions=qt(),this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}return t.prototype.lookup=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n=this;return a.__generator(this,(function(r){switch(r.label){case 0:if(this.ensureCommitNotCalled(),this.mutations.length>0)throw new T(E.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,this.datastore.lookup(t)];case 1:return(e=r.sent()).forEach((function(t){t instanceof Ke||t instanceof Qe?n.recordVersion(t):v("Document in a transaction was a "+t.constructor.name)})),[2,e]}}))}))},t.prototype.set=function(t,e){this.write(e.toMutations(t,this.precondition(t))),this.writtenDocs.add(t)},t.prototype.update=function(t,e){try{this.write(e.toMutations(t,this.preconditionForUpdate(t)))}catch(n){this.lastWriteError=n}this.writtenDocs.add(t)},t.prototype.delete=function(t){this.write([new De(t,this.precondition(t))]),this.writtenDocs.add(t)},t.prototype.commit=function(){return a.__awaiter(this,void 0,void 0,(function(){var t;return a.__generator(this,(function(e){switch(e.label){case 0:if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;if(t=this.readVersions,this.mutations.forEach((function(e){t=t.remove(e.key)})),!t.isEmpty())throw new T(E.INVALID_ARGUMENT,"Every document read in a transaction must also be written.");return[4,this.datastore.commit(this.mutations)];case 1:return e.sent(),this.committed=!0,[2]}}))}))},t.prototype.recordVersion=function(t){var e;if(t instanceof Qe)e=t.version;else{if(!(t instanceof Ke))throw v("Document in a transaction was a "+t.constructor.name);e=It.forDeletedDoc()}var n=this.readVersions.get(t.key);if(null!==n){if(!e.isEqual(n))throw new T(E.ABORTED,"Document version changed between two reads.")}else this.readVersions=this.readVersions.insert(t.key,e)},t.prototype.precondition=function(t){var e=this.readVersions.get(t);return!this.writtenDocs.has(t)&&e?Ee.updateTime(e):Ee.NONE},t.prototype.preconditionForUpdate=function(t){var e=this.readVersions.get(t);if(!this.writtenDocs.has(t)&&e){if(e.isEqual(It.forDeletedDoc()))throw new T(E.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Ee.updateTime(e)}return Ee.exists(!0)},t.prototype.write=function(t){this.ensureCommitNotCalled(),this.mutations=this.mutations.concat(t)},t.prototype.ensureCommitNotCalled=function(){_(!this.committed,"A transaction object cannot be used after its update callback has been invoked.")},t}();!function(t){t[t.Unknown=0]="Unknown",t[t.Online=1]="Online",t[t.Offline=2]="Offline"}(Or||(Or={})),function(t){t[t.RemoteStore=0]="RemoteStore",t[t.SharedClientState=1]="SharedClientState"}(xr||(xr={}));var qr,Vr=function(){function t(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state=Or.Unknown,this.watchStreamFailures=0,this.onlineStateTimer=null,this.shouldWarnClientIsOffline=!0}return t.prototype.handleWatchStreamStart=function(){var t=this;0===this.watchStreamFailures&&(this.setAndBroadcast(Or.Unknown),_(null===this.onlineStateTimer,"onlineStateTimer shouldn't be started yet"),this.onlineStateTimer=this.asyncQueue.enqueueAfterDelay(nt.OnlineStateTimeout,1e4,(function(){return t.onlineStateTimer=null,_(t.state===Or.Unknown,"Timer should be canceled if we transitioned to a different state."),t.logClientOfflineWarningIfNecessary("Backend didn't respond within 10 seconds."),t.setAndBroadcast(Or.Offline),Promise.resolve()})))},t.prototype.handleWatchStreamFailure=function(t){this.state===Or.Online?(this.setAndBroadcast(Or.Unknown),_(0===this.watchStreamFailures,"watchStreamFailures must be 0"),_(null===this.onlineStateTimer,"onlineStateTimer must be null")):(this.watchStreamFailures++,this.watchStreamFailures>=1&&(this.clearOnlineStateTimer(),this.logClientOfflineWarningIfNecessary("Connection failed 1 times. Most recent error: "+t.toString()),this.setAndBroadcast(Or.Offline)))},t.prototype.set=function(t){this.clearOnlineStateTimer(),this.watchStreamFailures=0,t===Or.Online&&(this.shouldWarnClientIsOffline=!1),this.setAndBroadcast(t)},t.prototype.setAndBroadcast=function(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))},t.prototype.logClientOfflineWarningIfNecessary=function(t){var e="Could not reach Cloud Firestore backend. "+t+"\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.";this.shouldWarnClientIsOffline?(y(e),this.shouldWarnClientIsOffline=!1):m("OnlineStateTracker",e)},t.prototype.clearOnlineStateTimer=function(){null!==this.onlineStateTimer&&(this.onlineStateTimer.cancel(),this.onlineStateTimer=null)},t}();function Br(t){switch(t){case E.OK:return v("Treated status OK as error");case E.CANCELLED:case E.UNKNOWN:case E.DEADLINE_EXCEEDED:case E.RESOURCE_EXHAUSTED:case E.INTERNAL:case E.UNAVAILABLE:case E.UNAUTHENTICATED:return!1;case E.INVALID_ARGUMENT:case E.NOT_FOUND:case E.ALREADY_EXISTS:case E.PERMISSION_DENIED:case E.FAILED_PRECONDITION:case E.ABORTED:case E.OUT_OF_RANGE:case E.UNIMPLEMENTED:case E.DATA_LOSS:return!0;default:return v("Unknown status code: "+t)}}function jr(t){if(void 0===t)return y("GRPC error has no .code"),E.UNKNOWN;switch(t){case qr.OK:return E.OK;case qr.CANCELLED:return E.CANCELLED;case qr.UNKNOWN:return E.UNKNOWN;case qr.DEADLINE_EXCEEDED:return E.DEADLINE_EXCEEDED;case qr.RESOURCE_EXHAUSTED:return E.RESOURCE_EXHAUSTED;case qr.INTERNAL:return E.INTERNAL;case qr.UNAVAILABLE:return E.UNAVAILABLE;case qr.UNAUTHENTICATED:return E.UNAUTHENTICATED;case qr.INVALID_ARGUMENT:return E.INVALID_ARGUMENT;case qr.NOT_FOUND:return E.NOT_FOUND;case qr.ALREADY_EXISTS:return E.ALREADY_EXISTS;case qr.PERMISSION_DENIED:return E.PERMISSION_DENIED;case qr.FAILED_PRECONDITION:return E.FAILED_PRECONDITION;case qr.ABORTED:return E.ABORTED;case qr.OUT_OF_RANGE:return E.OUT_OF_RANGE;case qr.UNIMPLEMENTED:return E.UNIMPLEMENTED;case qr.DATA_LOSS:return E.DATA_LOSS;default:return v("Unknown status code: "+t)}}function zr(t){if(void 0===t)return qr.OK;switch(t){case E.OK:return qr.OK;case E.CANCELLED:return qr.CANCELLED;case E.UNKNOWN:return qr.UNKNOWN;case E.DEADLINE_EXCEEDED:return qr.DEADLINE_EXCEEDED;case E.RESOURCE_EXHAUSTED:return qr.RESOURCE_EXHAUSTED;case E.INTERNAL:return qr.INTERNAL;case E.UNAVAILABLE:return qr.UNAVAILABLE;case E.UNAUTHENTICATED:return qr.UNAUTHENTICATED;case E.INVALID_ARGUMENT:return qr.INVALID_ARGUMENT;case E.NOT_FOUND:return qr.NOT_FOUND;case E.ALREADY_EXISTS:return qr.ALREADY_EXISTS;case E.PERMISSION_DENIED:return qr.PERMISSION_DENIED;case E.FAILED_PRECONDITION:return qr.FAILED_PRECONDITION;case E.ABORTED:return qr.ABORTED;case E.OUT_OF_RANGE:return qr.OUT_OF_RANGE;case E.UNIMPLEMENTED:return qr.UNIMPLEMENTED;case E.DATA_LOSS:return qr.DATA_LOSS;default:return v("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"}(qr||(qr={}));var Wr,Qr,Kr=function(){function t(t){this.comparator=t?function(e,n){return t(e,n)||pt.comparator(e.key,n.key)}:function(t,e){return pt.comparator(t.key,e.key)},this.keyedMap=Ft(),this.sortedSet=new Dt(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"}(Wr||(Wr={})),function(t){t[t.Local=0]="Local",t[t.Synced=1]="Synced"}(Qr||(Qr={}));var Hr,Gr=function(){function t(){this.changeMap=new Dt(pt.comparator)}return t.prototype.track=function(t){var e=t.doc.key,n=this.changeMap.get(e);n?t.type!==Wr.Added&&n.type===Wr.Metadata?this.changeMap=this.changeMap.insert(e,t):t.type===Wr.Metadata&&n.type!==Wr.Removed?this.changeMap=this.changeMap.insert(e,{type:n.type,doc:t.doc}):t.type===Wr.Modified&&n.type===Wr.Modified?this.changeMap=this.changeMap.insert(e,{type:Wr.Modified,doc:t.doc}):t.type===Wr.Modified&&n.type===Wr.Added?this.changeMap=this.changeMap.insert(e,{type:Wr.Added,doc:t.doc}):t.type===Wr.Removed&&n.type===Wr.Added?this.changeMap=this.changeMap.remove(e):t.type===Wr.Removed&&n.type===Wr.Modified?this.changeMap=this.changeMap.insert(e,{type:Wr.Removed,doc:n.doc}):t.type===Wr.Added&&n.type===Wr.Removed?this.changeMap=this.changeMap.insert(e,{type:Wr.Modified,doc:t.doc}):v("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}(),Yr=function(){function t(t,e,n,r,i,o,a,s){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=a,this.excludesMetadataChanges=s}return t.fromInitialDocuments=function(e,n,r,i){var o=[];return n.forEach((function(t){o.push({type:Wr.Added,doc:t})})),new t(e,n,Kr.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}(),Xr=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]=Jr.createSynthesizedTargetChangeForCurrentChange(e,n),r);return new t(It.MIN,i,zt(),Pt(),Bt())},t}(),Jr=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(w(),n,Bt(),Bt(),Bt())},t}(),Zr=function(t,e,n,r){this.updatedTargetIds=t,this.removedTargetIds=e,this.key=n,this.newDoc=r},$r=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"}(Hr||(Hr={}));var ti=function(t,e,n,r){void 0===n&&(n=w()),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},ei=function(){function t(){this.pendingResponses=0,this.documentChanges=ii(),this._resumeToken=w(),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=Bt(),e=Bt(),n=Bt();return this.documentChanges.forEach((function(r,i){switch(i){case Wr.Added:t=t.add(r);break;case Wr.Modified:e=e.add(r);break;case Wr.Removed:n=n.add(r);break;default:v("Encountered invalid change type: "+i)}})),new Jr(this._resumeToken,this._current,t,e,n)},t.prototype.clearPendingChanges=function(){this._hasPendingChanges=!1,this.documentChanges=ii()},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}(),ni=function(){function t(t){this.metadataProvider=t,this.targetStates={},this.pendingDocumentUpdates=Pt(),this.pendingDocumentTargetMapping=ri(),this.pendingTargetResets=new Rt(J)}return t.prototype.handleDocumentChange=function(t){for(var e=0,n=t.updatedTargetIds;e<n.length;e++){var r=n[e];t.newDoc instanceof Qe?this.addDocumentToTarget(r,t.newDoc):t.newDoc instanceof Ke&&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 Hr.NoChange:e.isActiveTarget(n)&&r.updateResumeToken(t.resumeToken);break;case Hr.Added:r.recordTargetResponse(),r.isPending||r.clearPendingChanges(),r.updateResumeToken(t.resumeToken);break;case Hr.Removed:r.recordTargetResponse(),r.isPending||e.removeTarget(n),_(!t.cause,"WatchChangeAggregator does not handle errored targets");break;case Hr.Current:e.isActiveTarget(n)&&(r.markCurrent(),r.updateResumeToken(t.resumeToken));break;case Hr.Reset:e.isActiveTarget(n)&&(e.resetTarget(n),r.updateResumeToken(t.resumeToken));break;default:v("Unknown target watch change state: "+t.state)}}))},t.prototype.forEachTarget=function(t,e){t.targetIds.length>0?t.targetIds.forEach(e):D(this.targetStates,e)},t.prototype.handleExistenceFilter=function(t){var e=t.targetId,n=t.existenceFilter.count,r=this.targetDataForActiveTarget(e);if(r){var i=r.target;if(i.isDocumentQuery())if(0===n){var o=new pt(i.path);this.removeDocumentFromTarget(e,o,new Ke(o,It.forDeletedDoc()))}else _(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={};D(this.targetStates,(function(r,i){var o=e.targetDataForActiveTarget(r);if(o){if(i.current&&o.target.isDocumentQuery()){var a=new pt(o.target.path);null!==e.pendingDocumentUpdates.get(a)||e.targetContainsDocument(r,a)||e.removeDocumentFromTarget(r,a,new Ke(a,t))}i.hasPendingChanges&&(n[r]=i.toTargetChange(),i.clearPendingChanges())}}));var r=Bt();this.pendingDocumentTargetMapping.forEach((function(t,n){var i=!0;n.forEachWhile((function(t){var n=e.targetDataForActiveTarget(t);return!n||n.purpose===wn.LimboResolution||(i=!1,!1)})),i&&(r=r.add(t))}));var i=new Xr(t,n,this.pendingTargetResets,this.pendingDocumentUpdates,r);return this.pendingDocumentUpdates=Pt(),this.pendingDocumentTargetMapping=ri(),this.pendingTargetResets=new Rt(J),i},t.prototype.addDocumentToTarget=function(t,e){if(this.isActiveTarget(t)){var n=this.targetContainsDocument(t,e.key)?Wr.Modified:Wr.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,Wr.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 ei),this.targetStates[t]},t.prototype.ensureDocumentTargetMapping=function(t){var e=this.pendingDocumentTargetMapping.get(t);return e||(e=new Rt(J),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(t,e)),e},t.prototype.isActiveTarget=function(t){var e=null!==this.targetDataForActiveTarget(t);return e||m("WatchChangeAggregator","Detected inactive target",t),e},t.prototype.targetDataForActiveTarget=function(t){var e=this.targetStates[t];return e&&e.isPending?null:this.metadataProvider.getTargetDataForTarget(t)},t.prototype.resetTarget=function(t){var e=this;_(!this.targetStates[t].isPending,"Should only reset active targets"),this.targetStates[t]=new ei,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 ri(){return new Dt(pt.comparator)}function ii(){return new Dt(pt.comparator)}var oi="RemoteStore",ai=function(){function t(t,e,n,r,i){var o=this;this.localStore=t,this.datastore=e,this.writePipeline=[],this.listenTargets={},this.watchChangeAggregator=null,this.networkEnabled=!1,this.isPrimary=!1,this.connectivityMonitor=i,this.connectivityMonitor.addCallback((function(t){n.enqueueAndForget((function(){return a.__awaiter(o,void 0,void 0,(function(){return a.__generator(this,(function(t){switch(t.label){case 0:return this.canUseNetwork()?(m(oi,"Restarting streams for network reachability change."),[4,this.restartNetwork()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))}))})),this.onlineStateTracker=new Vr(n,r),this.watchStream=this.datastore.newPersistentWatchStream({onOpen:this.onWatchStreamOpen.bind(this),onClose:this.onWatchStreamClose.bind(this),onWatchChange:this.onWatchStreamChange.bind(this)}),this.writeStream=this.datastore.newPersistentWriteStream({onOpen:this.onWriteStreamOpen.bind(this),onClose:this.onWriteStreamClose.bind(this),onHandshakeComplete:this.onWriteHandshakeComplete.bind(this),onMutationResult:this.onMutationResult.bind(this)})}return t.prototype.start=function(){return this.enableNetwork()},t.prototype.enableNetwork=function(){return a.__awaiter(this,void 0,void 0,(function(){var t;return a.__generator(this,(function(e){switch(e.label){case 0:return this.networkEnabled=!0,this.canUseNetwork()?(t=this.writeStream,[4,this.localStore.getLastStreamToken()]):[3,3];case 1:return t.lastStreamToken=e.sent(),this.shouldStartWatchStream()?this.startWatchStream():this.onlineStateTracker.set(Or.Unknown),[4,this.fillWritePipeline()];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},t.prototype.disableNetwork=function(){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.onlineStateTracker.set(Or.Offline),[2]}}))}))},t.prototype.disableNetworkInternal=function(){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(t){switch(t.label){case 0:return[4,this.writeStream.stop()];case 1:return t.sent(),[4,this.watchStream.stop()];case 2:return t.sent(),this.writePipeline.length>0&&(m(oi,"Stopping write stream with "+this.writePipeline.length+" pending writes"),this.writePipeline=[]),this.cleanUpWatchStreamState(),[2]}}))}))},t.prototype.shutdown=function(){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(t){switch(t.label){case 0:return m(oi,"RemoteStore shutting down."),this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.connectivityMonitor.shutdown(),this.onlineStateTracker.set(Or.Unknown),[2]}}))}))},t.prototype.listen=function(t){S(this.listenTargets,t.targetId)||(this.listenTargets[t.targetId]=t,this.shouldStartWatchStream()?this.startWatchStream():this.watchStream.isOpen()&&this.sendWatchRequest(t))},t.prototype.unlisten=function(t){_(S(this.listenTargets,t),"unlisten called on target no currently watched: "+t),delete this.listenTargets[t],this.watchStream.isOpen()&&this.sendUnwatchRequest(t),A(this.listenTargets)&&(this.watchStream.isOpen()?this.watchStream.markIdle():this.canUseNetwork()&&this.onlineStateTracker.set(Or.Unknown))},t.prototype.getTargetDataForTarget=function(t){return this.listenTargets[t]||null},t.prototype.getRemoteKeysForTarget=function(t){return this.syncEngine.getRemoteKeysForTarget(t)},t.prototype.sendWatchRequest=function(t){this.watchChangeAggregator.recordPendingTargetRequest(t.targetId),this.watchStream.watch(t)},t.prototype.sendUnwatchRequest=function(t){this.watchChangeAggregator.recordPendingTargetRequest(t),this.watchStream.unwatch(t)},t.prototype.startWatchStream=function(){_(this.shouldStartWatchStream(),"startWatchStream() called when shouldStartWatchStream() is false."),this.watchChangeAggregator=new ni(this),this.watchStream.start(),this.onlineStateTracker.handleWatchStreamStart()},t.prototype.shouldStartWatchStream=function(){return this.canUseNetwork()&&!this.watchStream.isStarted()&&!A(this.listenTargets)},t.prototype.canUseNetwork=function(){return this.isPrimary&&this.networkEnabled},t.prototype.cleanUpWatchStreamState=function(){this.watchChangeAggregator=null},t.prototype.onWatchStreamOpen=function(){return a.__awaiter(this,void 0,void 0,(function(){var t=this;return a.__generator(this,(function(e){return D(this.listenTargets,(function(e,n){t.sendWatchRequest(n)})),[2]}))}))},t.prototype.onWatchStreamClose=function(t){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(e){return void 0===t&&_(!this.shouldStartWatchStream(),"Watch stream was stopped gracefully while still needed."),this.cleanUpWatchStreamState(),this.shouldStartWatchStream()?(this.onlineStateTracker.handleWatchStreamFailure(t),this.startWatchStream()):this.onlineStateTracker.set(Or.Unknown),[2]}))}))},t.prototype.onWatchStreamChange=function(t,e){return a.__awaiter(this,void 0,void 0,(function(){var n;return a.__generator(this,(function(r){switch(r.label){case 0:return this.onlineStateTracker.set(Or.Online),t instanceof ti&&t.state===Hr.Removed&&t.cause?[2,this.handleTargetError(t)]:(t instanceof Zr?this.watchChangeAggregator.handleDocumentChange(t):t instanceof $r?this.watchChangeAggregator.handleExistenceFilter(t):(_(t instanceof ti,"Expected watchChange to be an instance of WatchTargetChange"),this.watchChangeAggregator.handleTargetChange(t)),e.isEqual(It.MIN)?[3,3]:[4,this.localStore.getLastRemoteSnapshotVersion()]);case 1:return n=r.sent(),e.compareTo(n)>=0?[4,this.raiseWatchSnapshot(e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},t.prototype.raiseWatchSnapshot=function(t){var e=this;_(!t.isEqual(It.MIN),"Can't raise event for unknown SnapshotVersion");var n=this.watchChangeAggregator.createRemoteEvent(t);return D(n.targetChanges,(function(n,r){if(r.resumeToken.length>0){var i=e.listenTargets[n];i&&(e.listenTargets[n]=i.withResumeToken(r.resumeToken,t))}})),n.targetMismatches.forEach((function(t){var n=e.listenTargets[t];if(n){e.listenTargets[t]=n.withResumeToken(w(),n.snapshotVersion),e.sendUnwatchRequest(t);var r=new Nn(n.target,t,wn.ExistenceFilterMismatch,n.sequenceNumber);e.sendWatchRequest(r)}})),this.syncEngine.applyRemoteEvent(n)},t.prototype.handleTargetError=function(t){var e=this;_(!!t.cause,"Handling target error without a cause");var n=t.cause,r=Promise.resolve();return t.targetIds.forEach((function(t){r=r.then((function(){return a.__awaiter(e,void 0,void 0,(function(){return a.__generator(this,(function(e){return S(this.listenTargets,t)?(delete this.listenTargets[t],this.watchChangeAggregator.removeTarget(t),[2,this.syncEngine.rejectListen(t,n)]):[2]}))}))}))})),r},t.prototype.fillWritePipeline=function(){return a.__awaiter(this,void 0,void 0,(function(){var t,e;return a.__generator(this,(function(n){switch(n.label){case 0:return this.canAddToWritePipeline()?(t=this.writePipeline.length>0?this.writePipeline[this.writePipeline.length-1].batchId:-1,[4,this.localStore.nextMutationBatch(t)]):[3,4];case 1:return null!==(e=n.sent())?[3,2]:(0===this.writePipeline.length&&this.writeStream.markIdle(),[3,4]);case 2:return this.addToWritePipeline(e),[4,this.fillWritePipeline()];case 3:n.sent(),n.label=4;case 4:return this.shouldStartWriteStream()&&this.startWriteStream(),[2]}}))}))},t.prototype.canAddToWritePipeline=function(){return this.canUseNetwork()&&this.writePipeline.length<10},t.prototype.outstandingWrites=function(){return this.writePipeline.length},t.prototype.addToWritePipeline=function(t){_(this.canAddToWritePipeline(),"addToWritePipeline called when pipeline is full"),this.writePipeline.push(t),this.writeStream.isOpen()&&this.writeStream.handshakeComplete&&this.writeStream.writeMutations(t.mutations)},t.prototype.shouldStartWriteStream=function(){return this.canUseNetwork()&&!this.writeStream.isStarted()&&this.writePipeline.length>0},t.prototype.startWriteStream=function(){_(this.shouldStartWriteStream(),"startWriteStream() called when shouldStartWriteStream() is false."),this.writeStream.start()},t.prototype.onWriteStreamOpen=function(){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(t){return this.writeStream.writeHandshake(),[2]}))}))},t.prototype.onWriteHandshakeComplete=function(){var t=this;return this.localStore.setLastStreamToken(this.writeStream.lastStreamToken).then((function(){for(var e=0,n=t.writePipeline;e<n.length;e++){var r=n[e];t.writeStream.writeMutations(r.mutations)}})).catch(jn)},t.prototype.onMutationResult=function(t,e){var n=this;_(this.writePipeline.length>0,"Got result for empty write pipeline");var r=this.writePipeline.shift(),i=Qt.from(r,t,e,this.writeStream.lastStreamToken);return this.syncEngine.applySuccessfulWrite(i).then((function(){return n.fillWritePipeline()}))},t.prototype.onWriteStreamClose=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e=this;return a.__generator(this,(function(n){return void 0===t&&_(!this.shouldStartWriteStream(),"Write stream was stopped gracefully while still needed."),t&&this.writePipeline.length>0?(void 0,[2,(this.writeStream.handshakeComplete?this.handleWriteError(t):this.handleHandshakeError(t)).then((function(){e.shouldStartWriteStream()&&e.startWriteStream()}))]):[2]}))}))},t.prototype.handleHandshakeError=function(t){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(e){return Br(t.code)?(m(oi,"RemoteStore error before completed handshake; resetting stream token: ",this.writeStream.lastStreamToken),this.writeStream.lastStreamToken=w(),[2,this.localStore.setLastStreamToken(w()).catch(jn)]):[2]}))}))},t.prototype.handleWriteError=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n=this;return a.__generator(this,(function(r){return Br(i=t.code)&&i!==E.ABORTED?(e=this.writePipeline.shift(),this.writeStream.inhibitBackoff(),[2,this.syncEngine.rejectFailedWrite(e.batchId,t).then((function(){return n.fillWritePipeline()}))]):[2];var i}))}))},t.prototype.createTransaction=function(){return new Ur(this.datastore)},t.prototype.restartNetwork=function(){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.onlineStateTracker.set(Or.Unknown),[4,this.enableNetwork()];case 2:return t.sent(),[2]}}))}))},t.prototype.handleCredentialChange=function(){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(t){switch(t.label){case 0:return this.canUseNetwork()?(m(oi,"RemoteStore restarting streams for new credential"),[4,this.restartNetwork()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.applyPrimaryState=function(t){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(e){switch(e.label){case 0:return this.isPrimary=t,t&&this.networkEnabled?[4,this.enableNetwork()]:[3,2];case 1:return e.sent(),[3,4];case 2:return t?[3,4]:[4,this.disableNetworkInternal()];case 3:e.sent(),this.onlineStateTracker.set(Or.Unknown),e.label=4;case 4:return[2]}}))}))},t}(),si=function(){function t(t,e){if(R("GeoPoint",arguments,2),P("GeoPoint","number",1,t),P("GeoPoint","number",2,e),!isFinite(t)||t<-90||t>90)throw new T(E.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new T(E.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 J(this._lat,t._lat)||J(this._long,t._long)},t}(),ui=function(){function t(){}return t.prototype.applyToLocalView=function(t,e){return new Ue(e,t)},t.prototype.applyToRemoteDocument=function(t,e){return e},t.prototype.computeBaseValue=function(t){return null},t.prototype.isEqual=function(e){return e instanceof t},t.instance=new t,t}(),ci=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=fi(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 ze(e)},t.prototype.computeBaseValue=function(t){return null},t.prototype.isEqual=function(e){return e instanceof t&&Z(e.elements,this.elements)},t}(),hi=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=fi(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 ze(e)},t.prototype.computeBaseValue=function(t){return null},t.prototype.isEqual=function(e){return e instanceof t&&Z(e.elements,this.elements)},t}(),li=function(){function t(t){this.operand=t}return t.prototype.applyToLocalView=function(t,e){var n=this.computeBaseValue(t);if(n instanceof Pe&&this.operand instanceof Pe){var r=n.internalValue+this.operand.internalValue;return new Pe(r)}r=n.internalValue+this.operand.internalValue;return new Me(r)},t.prototype.applyToRemoteDocument=function(t,e){return _(null!==e,"Didn't receive transformResult for NUMERIC_ADD transform"),e},t.prototype.computeBaseValue=function(t){return t instanceof Oe?t:new Pe(0)},t.prototype.isEqual=function(e){return e instanceof t&&this.operand.isEqual(e.operand)},t}();function fi(t){return t instanceof ze?t.internalValue.slice():[]}var pi,di,mi=function(){function t(t){this.count=t}return t.prototype.isEqual=function(t){return t&&t.count===this.count},t}(),yi=((pi={})[hr.ASCENDING.name]="ASCENDING",pi[hr.DESCENDING.name]="DESCENDING",pi),gi=((di={})[rr.LESS_THAN.name]="LESS_THAN",di[rr.LESS_THAN_OR_EQUAL.name]="LESS_THAN_OR_EQUAL",di[rr.GREATER_THAN.name]="GREATER_THAN",di[rr.GREATER_THAN_OR_EQUAL.name]="GREATER_THAN_OR_EQUAL",di[rr.EQUAL.name]="EQUAL",di[rr.ARRAY_CONTAINS.name]="ARRAY_CONTAINS",di[rr.IN.name]="IN",di[rr.ARRAY_CONTAINS_ANY.name]="ARRAY_CONTAINS_ANY",di),vi=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function _i(t,e){_(!Jn(t),e+" is missing")}function bi(t){return"number"==typeof t?t:"string"==typeof t?Number(t):v("can't parse "+t)}var wi=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?E.UNKNOWN:jr(t.code);return new T(e,t.message||"")},t.prototype.toInt32Value=function(t){return this.options.useProto3Json||Jn(t)?t:{value:t}},t.prototype.fromInt32Value=function(t){var e;return Jn(e="object"==typeof t?t.value:t)?null:e},t.prototype.toTimestamp=function(t){return this.options.useProto3Json?new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+t.nanoseconds).slice(-9)+"Z":{seconds:""+t.seconds,nanos:t.nanoseconds}},t.prototype.fromTimestamp=function(t){if("string"==typeof t)return this.fromIso8601String(t);_(!!t,"Cannot deserialize null or undefined timestamp.");var e=bi(t.seconds||"0"),n=t.nanos||0;return new St(e,n)},t.prototype.fromIso8601String=function(t){var e=0,n=vi.exec(t);if(_(!!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 St(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?(_(this.options.useProto3Json,"Expected bytes to be passed in as Uint8Array, but got a string instead."),rt.fromBase64String(t)):(_(!this.options.useProto3Json,"Expected bytes to be passed in as Uint8Array, but got a string instead."),rt.fromUint8Array(t))},t.prototype.toVersion=function(t){return this.toTimestamp(t.toTimestamp())},t.prototype.fromVersion=function(t){return _(!!t,"Trying to deserialize version that isn't set"),It.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=ht.fromString(t);return _(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 _(e.get(1)===this.databaseId.projectId,"Tried to deserialize key from different project: "+e.get(1)+" vs "+this.databaseId.projectId),_(!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 pt(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?ht.EMPTY_PATH:this.extractLocalPathFromResourceName(e)},Object.defineProperty(t.prototype,"encodedDatabaseId",{get:function(){return new ht(["projects",this.databaseId.projectId,"databases",this.databaseId.database]).canonicalString()},enumerable:!0,configurable:!0}),t.prototype.fullyQualifiedPrefixPath=function(t){return new ht(["projects",t.projectId,"databases",t.database])},t.prototype.extractLocalPathFromResourceName=function(t){return _(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 ke)return{nullValue:"NULL_VALUE"};if(t instanceof Re)return{booleanValue:t.value()};if(t instanceof Pe)return{integerValue:""+t.value()};if(t instanceof Me){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 Le?{stringValue:t.value()}:t instanceof je?{mapValue:this.toMapValue(t)}:t instanceof ze?{arrayValue:this.toArrayValue(t)}:t instanceof Fe?{timestampValue:this.toTimestamp(t.internalValue)}:t instanceof Be?{geoPointValue:{latitude:t.value().latitude,longitude:t.value().longitude}}:t instanceof qe?{bytesValue:this.toBytes(t.value())}:t instanceof Ve?{referenceValue:this.toResourceName(t.databaseId,t.key.path)}:v("Unknown FieldValue "+JSON.stringify(t))},t.prototype.fromValue=function(t){var e=this;if("nullValue"in t)return ke.INSTANCE;if("booleanValue"in t)return Re.of(t.booleanValue);if("integerValue"in t)return new Pe(bi(t.integerValue));if("doubleValue"in t){if(this.options.useProto3Json){if("NaN"===t.doubleValue)return Me.NAN;if("Infinity"===t.doubleValue)return Me.POSITIVE_INFINITY;if("-Infinity"===t.doubleValue)return Me.NEGATIVE_INFINITY}return new Me(t.doubleValue)}if("stringValue"in t)return new Le(t.stringValue);if("mapValue"in t)return this.fromFields(t.mapValue.fields||{});if("arrayValue"in t){_i(t.arrayValue,"arrayValue");var n=t.arrayValue.values||[];return new ze(n.map((function(t){return e.fromValue(t)})))}if("timestampValue"in t)return _i(t.timestampValue,"timestampValue"),new Fe(this.fromTimestamp(t.timestampValue));if("geoPointValue"in t){_i(t.geoPointValue,"geoPointValue");var r=t.geoPointValue.latitude||0,i=t.geoPointValue.longitude||0;return new Be(new si(r,i))}if("bytesValue"in t){_i(t.bytesValue,"bytesValue");var o=this.fromBlob(t.bytesValue);return new qe(o)}if("referenceValue"in t){_i(t.referenceValue,"referenceValue");var a=this.fromResourceName(t.referenceValue),s=new st(a.get(1),a.get(3)),u=new pt(this.extractLocalPathFromResourceName(a));return new Ve(s,u)}return v("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 _(!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){var n=this,r=this.fromName(t.name),i=this.fromVersion(t.updateTime);return new Qe(r,i,{hasCommittedMutations:!!e},void 0,t,(function(t){return n.fromValue(t)}))},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=je.EMPTY;return N(n,(function(t,n){r=r.set(new ft([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){var e=this;_(!!t.found,"Tried to deserialize a found document from a missing document."),_i(t.found.name,"doc.found.name"),_i(t.found.updateTime,"doc.found.updateTime");var n=this.fromName(t.found.name),r=this.fromVersion(t.found.updateTime);return new Qe(n,r,{},void 0,t.found,(function(t){return e.fromValue(t)}))},t.prototype.fromMissing=function(t){_(!!t.missing,"Tried to deserialize a missing document from a found document."),_(!!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 Ke(e,n)},t.prototype.fromMaybeDocument=function(t){return"found"in t?this.fromFound(t):"missing"in t?this.fromMissing(t):v("invalid batch get response: "+JSON.stringify(t))},t.prototype.toWatchTargetChangeState=function(t){switch(t){case Hr.Added:return"ADD";case Hr.Current:return"CURRENT";case Hr.NoChange:return"NO_CHANGE";case Hr.Removed:return"REMOVE";case Hr.Reset:return"RESET";default:return v("Unknown WatchTargetChangeState: "+t)}},t.prototype.toTestWatchChange=function(t){if(t instanceof $r)return{filter:{count:t.existenceFilter.count,targetId:t.targetId}};if(t instanceof Zr){if(t.newDoc instanceof Qe){var e=t.newDoc;return{documentChange:{document:{name:this.toName(e.key),fields:this.toFields(e.data()),updateTime:this.toVersion(e.version)},targetIds:t.updatedTargetIds,removedTargetIds:t.removedTargetIds}}}if(t.newDoc instanceof Ke){e=t.newDoc;return{documentDelete:{document:this.toName(e.key),readTime:this.toVersion(e.version),removedTargetIds:t.removedTargetIds}}}if(null===t.newDoc)return{documentRemove:{document:this.toName(t.key),removedTargetIds:t.removedTargetIds}}}if(t instanceof ti){var n=void 0;return t.cause&&(n={code:zr(t.cause.code),message:t.cause.message}),{targetChange:{targetChangeType:this.toWatchTargetChangeState(t.state),targetIds:t.targetIds,resumeToken:this.unsafeCastProtoByteString(t.resumeToken),cause:n}}}return v("Unrecognized watch change: "+JSON.stringify(t))},t.prototype.fromWatchChange=function(t){var e,n=this;if("targetChange"in t){_i(t.targetChange,"targetChange");var r=this.fromWatchTargetChangeState(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],o=t.targetChange.resumeToken||this.emptyByteString(),a=t.targetChange.cause,s=a&&this.fromRpcStatus(a);e=new ti(r,i,o,s||null)}else if("documentChange"in t){_i(t.documentChange,"documentChange");var u=t.documentChange;_i(u.document,"documentChange.name"),_i(u.document.name,"documentChange.document.name"),_i(u.document.updateTime,"documentChange.document.updateTime");var c=this.fromName(u.document.name),h=this.fromVersion(u.document.updateTime),l=new Qe(c,h,{},void 0,u.document,(function(t){return n.fromValue(t)})),f=u.targetIds||[],p=u.removedTargetIds||[];e=new Zr(f,p,l.key,l)}else if("documentDelete"in t){_i(t.documentDelete,"documentDelete");var d=t.documentDelete;_i(d.document,"documentDelete.document");c=this.fromName(d.document),h=d.readTime?this.fromVersion(d.readTime):It.forDeletedDoc(),l=new Ke(c,h),p=d.removedTargetIds||[];e=new Zr([],p,l.key,l)}else if("documentRemove"in t){_i(t.documentRemove,"documentRemove");var m=t.documentRemove;_i(m.document,"documentRemove");c=this.fromName(m.document),p=m.removedTargetIds||[];e=new Zr([],p,c,null)}else{if(!("filter"in t))return v("Unknown change type "+JSON.stringify(t));_i(t.filter,"filter");var y=t.filter;_i(y.targetId,"filter.targetId");var g=y.count||0,_=new mi(g),b=y.targetId;e=new $r(b,_)}return e},t.prototype.fromWatchTargetChangeState=function(t){return"NO_CHANGE"===t?Hr.NoChange:"ADD"===t?Hr.Added:"REMOVE"===t?Hr.Removed:"CURRENT"===t?Hr.Current:"RESET"===t?Hr.Reset:v("Got unexpected TargetChange.state: "+t)},t.prototype.versionFromListenResponse=function(t){if(!("targetChange"in t))return It.MIN;var e=t.targetChange;return e.targetIds&&e.targetIds.length?It.MIN:e.readTime?this.fromVersion(e.readTime):It.MIN},t.prototype.toMutation=function(t){var e,n=this;if(t instanceof Ce)e={update:this.toMutationDocument(t.key,t.value)};else if(t instanceof De)e={delete:this.toName(t.key)};else if(t instanceof Se)e={update:this.toMutationDocument(t.key,t.data),updateMask:this.toDocumentMask(t.fieldMask)};else{if(!(t instanceof Ie))return v("Unknown mutation type "+t.type);e={transform:{document:this.toName(t.key),fieldTransforms:t.fieldTransforms.map((function(t){return n.toFieldTransform(t)}))}}}return t.precondition.isNone||(e.currentDocument=this.toPrecondition(t.precondition)),e},t.prototype.fromMutation=function(t){var e=this,n=t.currentDocument?this.fromPrecondition(t.currentDocument):Ee.NONE;if(t.update){_i(t.update.name,"name");var r=this.fromName(t.update.name),i=this.fromFields(t.update.fields||{});if(t.updateMask){var o=this.fromDocumentMask(t.updateMask);return new Se(r,i,o,n)}return new Ce(r,i,n)}if(t.delete){r=this.fromName(t.delete);return new De(r,n)}if(t.transform){r=this.fromName(t.transform.document);var a=t.transform.fieldTransforms.map((function(t){return e.fromFieldTransform(t)}));return _(!0===n.exists,'Transforms only support precondition "exists == true"'),new Ie(r,a)}return v("unknown mutation proto: "+JSON.stringify(t))},t.prototype.toPrecondition=function(t){return _(!t.isNone,"Can't serialize an empty precondition"),void 0!==t.updateTime?{updateTime:this.toVersion(t.updateTime)}:void 0!==t.exists?{exists:t.exists}:v("Unknown precondition")},t.prototype.fromPrecondition=function(t){return void 0!==t.updateTime?Ee.updateTime(this.fromVersion(t.updateTime)):void 0!==t.exists?Ee.exists(t.exists):Ee.NONE},t.prototype.fromWriteResult=function(t,e){var n=this,r=t.updateTime?this.fromVersion(t.updateTime):this.fromVersion(e);r.isEqual(It.MIN)&&(r=this.fromVersion(e));var i=null;return t.transformResults&&t.transformResults.length>0&&(i=t.transformResults.map((function(t){return n.fromValue(t)}))),new _e(r,i)},t.prototype.fromWriteResults=function(t,e){var n=this;return t&&t.length>0?(_(void 0!==e,"Received a write result without a commit time"),t.map((function(t){return n.fromWriteResult(t,e)}))):[]},t.prototype.toFieldTransform=function(t){var e=this,n=t.transform;if(n instanceof ui)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof ci)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements.map((function(t){return e.toValue(t)}))}};if(n instanceof hi)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements.map((function(t){return e.toValue(t)}))}};if(n instanceof li)return{fieldPath:t.field.canonicalString(),increment:this.toValue(n.operand)};throw v("Unknown transform: "+t.transform)},t.prototype.fromFieldTransform=function(t){var e=this,n=null;if("setToServerValue"in t)_("REQUEST_TIME"===t.setToServerValue,"Unknown server value transform proto: "+JSON.stringify(t)),n=ui.instance;else if("appendMissingElements"in t){var r=t.appendMissingElements.values||[];n=new ci(r.map((function(t){return e.fromValue(t)})))}else if("removeAllFromArray"in t){r=t.removeAllFromArray.values||[];n=new hi(r.map((function(t){return e.fromValue(t)})))}else if("increment"in t){var i=this.fromValue(t.increment);_(i instanceof Oe,"NUMERIC_ADD transform requires a NumberValue"),n=new li(i)}else v("Unknown transform proto: "+JSON.stringify(t));var o=ft.fromServerFormat(t.fieldPath);return new ve(o,n)},t.prototype.toDocumentsTarget=function(t){return{documents:[this.toQueryPath(t.path)]}},t.prototype.fromDocumentsTarget=function(t){var e=t.documents.length;_(1===e,"DocumentsTarget contained other than 1 document: "+e);var n=t.documents[0];return er.atPath(this.fromQueryPath(n)).toTarget()},t.prototype.toQueryTarget=function(t){var e={structuredQuery:{}},n=t.path;null!==t.collectionGroup?(_(n.length%2==0,"Collection Group queries should be within a document path or root."),e.parent=this.toQueryPath(n),e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(_(n.length%2!=0,"Document queries with filters are not supported."),e.parent=this.toQueryPath(n.popLast()),e.structuredQuery.from=[{collectionId:n.lastSegment()}]);var r=this.toFilter(t.filters);r&&(e.structuredQuery.where=r);var i=this.toOrder(t.orderBy);i&&(e.structuredQuery.orderBy=i);var o=this.toInt32Value(t.limit);return null!==o&&(e.structuredQuery.limit=o),t.startAt&&(e.structuredQuery.startAt=this.toCursor(t.startAt)),t.endAt&&(e.structuredQuery.endAt=this.toCursor(t.endAt)),e},t.prototype.fromQueryTarget=function(t){var e=this.fromQueryPath(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){_(1===r,"StructuredQuery.from with more than one collection is not supported.");var o=n.from[0];o.allDescendants?i=o.collectionId:e=e.child(o.collectionId)}var a=[];n.where&&(a=this.fromFilter(n.where));var s=[];n.orderBy&&(s=this.fromOrder(n.orderBy));var u=null;n.limit&&(u=this.fromInt32Value(n.limit));var c=null;n.startAt&&(c=this.fromCursor(n.startAt));var h=null;return n.endAt&&(h=this.fromCursor(n.endAt)),new er(e,i,s,a,u,$n.First,c,h).toTarget()},t.prototype.toListenRequestLabels=function(t){var e=this.toLabel(t.purpose);return null==e?null:{"goog-listen-tags":e}},t.prototype.toLabel=function(t){switch(t){case wn.Listen:return null;case wn.ExistenceFilterMismatch:return"existence-filter-mismatch";case wn.LimboResolution:return"limbo-document";default:return v("Unrecognized query purpose: "+t)}},t.prototype.toTarget=function(t){var e,n=t.target;return(e=n.isDocumentQuery()?{documents:this.toDocumentsTarget(n)}:{query:this.toQueryTarget(n)}).targetId=t.targetId,t.resumeToken.length>0&&(e.resumeToken=this.unsafeCastProtoByteString(t.resumeToken)),e},t.prototype.toFilter=function(t){var e=this;if(0!==t.length){var n=t.map((function(t){return t instanceof ir?e.toUnaryOrFieldFilter(t):v("Unrecognized filter: "+JSON.stringify(t))}));return 1===n.length?n[0]:{compositeFilter:{op:"AND",filters:n}}}},t.prototype.fromFilter=function(t){var e=this;return t?void 0!==t.unaryFilter?[this.fromUnaryFilter(t)]:void 0!==t.fieldFilter?[this.fromFieldFilter(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map((function(t){return e.fromFilter(t)})).reduce((function(t,e){return t.concat(e)})):v("Unknown filter: "+JSON.stringify(t)):[]},t.prototype.toOrder=function(t){var e=this;if(0!==t.length)return t.map((function(t){return e.toPropertyOrder(t)}))},t.prototype.fromOrder=function(t){var e=this;return t.map((function(t){return e.fromPropertyOrder(t)}))},t.prototype.toCursor=function(t){var e=this;return{before:t.before,values:t.position.map((function(t){return e.toValue(t)}))}},t.prototype.fromCursor=function(t){var e=this,n=!!t.before,r=t.values.map((function(t){return e.fromValue(t)}));return new lr(r,n)},t.prototype.toDirection=function(t){return yi[t.name]},t.prototype.fromDirection=function(t){switch(t){case"ASCENDING":return hr.ASCENDING;case"DESCENDING":return hr.DESCENDING;default:return}},t.prototype.toOperatorName=function(t){return gi[t.name]},t.prototype.fromOperatorName=function(t){switch(t){case"EQUAL":return rr.EQUAL;case"GREATER_THAN":return rr.GREATER_THAN;case"GREATER_THAN_OR_EQUAL":return rr.GREATER_THAN_OR_EQUAL;case"LESS_THAN":return rr.LESS_THAN;case"LESS_THAN_OR_EQUAL":return rr.LESS_THAN_OR_EQUAL;case"ARRAY_CONTAINS":return rr.ARRAY_CONTAINS;case"IN":return rr.IN;case"ARRAY_CONTAINS_ANY":return rr.ARRAY_CONTAINS_ANY;case"OPERATOR_UNSPECIFIED":return v("Unspecified operator");default:return v("Unknown operator")}},t.prototype.toFieldPathReference=function(t){return{fieldPath:t.canonicalString()}},t.prototype.fromFieldPathReference=function(t){return ft.fromServerFormat(t.fieldPath)},t.prototype.toPropertyOrder=function(t){return{field:this.toFieldPathReference(t.field),direction:this.toDirection(t.dir)}},t.prototype.fromPropertyOrder=function(t){return new fr(this.fromFieldPathReference(t.field),this.fromDirection(t.direction))},t.prototype.fromFieldFilter=function(t){return ir.create(this.fromFieldPathReference(t.fieldFilter.field),this.fromOperatorName(t.fieldFilter.op),this.fromValue(t.fieldFilter.value))},t.prototype.toUnaryOrFieldFilter=function(t){if(t.op===rr.EQUAL){if(t.value.isEqual(Me.NAN))return{unaryFilter:{field:this.toFieldPathReference(t.field),op:"IS_NAN"}};if(t.value.isEqual(ke.INSTANCE))return{unaryFilter:{field:this.toFieldPathReference(t.field),op:"IS_NULL"}}}return{fieldFilter:{field:this.toFieldPathReference(t.field),op:this.toOperatorName(t.op),value:this.toValue(t.value)}}},t.prototype.fromUnaryFilter=function(t){switch(t.unaryFilter.op){case"IS_NAN":var e=this.fromFieldPathReference(t.unaryFilter.field);return ir.create(e,rr.EQUAL,Me.NAN);case"IS_NULL":var n=this.fromFieldPathReference(t.unaryFilter.field);return ir.create(n,rr.EQUAL,ke.INSTANCE);case"OPERATOR_UNSPECIFIED":return v("Unspecified filter");default:return v("Unknown filter")}},t.prototype.toDocumentMask=function(t){var e=[];return t.fields.forEach((function(t){return e.push(t.canonicalString())})),{fieldPaths:e}},t.prototype.fromDocumentMask=function(t){var e=(t.fieldPaths||[]).map((function(t){return ft.fromServerFormat(t)}));return ge.fromArray(e)},t}(),Ei=function(){this.viewSnap=null,this.targetId=0,this.listeners=[]},Ti=function(){function t(t){this.syncEngine=t,this.queries=new Ge((function(t){return t.canonicalId()})),this.onlineState=Or.Unknown,this.snapshotsInSyncListeners=new Set,this.syncEngine.subscribe(this)}return t.prototype.listen=function(t){var e=t.query,n=!1,r=this.queries.get(e);(r||(n=!0,r=new Ei,this.queries.set(e,r)),r.listeners.push(t),_(!t.applyOnlineStateChange(this.onlineState),"applyOnlineStateChange() shouldn't raise an event for brand-new listeners."),r.viewSnap)&&(t.onViewSnapshot(r.viewSnap)&&this.raiseSnapshotsInSyncEvent());return n?this.syncEngine.listen(e).then((function(t){return r.targetId=t,t})):Promise.resolve(r.targetId)},t.prototype.unlisten=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n,r,i;return a.__generator(this,(function(o){return e=t.query,n=!1,(r=this.queries.get(e))&&(i=r.listeners.indexOf(t))>=0&&(r.listeners.splice(i,1),n=0===r.listeners.length),n?(this.queries.delete(e),[2,this.syncEngine.unlisten(e)]):[2]}))}))},t.prototype.onWatchChange=function(t){for(var e=!1,n=0,r=t;n<r.length;n++){var i=r[n],o=i.query,a=this.queries.get(o);if(a){for(var s=0,u=a.listeners;s<u.length;s++){u[s].onViewSnapshot(i)&&(e=!0)}a.viewSnap=i}}e&&this.raiseSnapshotsInSyncEvent()},t.prototype.onWatchError=function(t,e){var n=this.queries.get(t);if(n)for(var r=0,i=n.listeners;r<i.length;r++){i[r].onError(e)}this.queries.delete(t)},t.prototype.onOnlineStateChange=function(t){this.onlineState=t;var e=!1;this.queries.forEach((function(n,r){for(var i=0,o=r.listeners;i<o.length;i++){o[i].applyOnlineStateChange(t)&&(e=!0)}})),e&&this.raiseSnapshotsInSyncEvent()},t.prototype.addSnapshotsInSyncListener=function(t){this.snapshotsInSyncListeners.add(t),t.next()},t.prototype.removeSnapshotsInSyncListener=function(t){this.snapshotsInSyncListeners.delete(t)},t.prototype.raiseSnapshotsInSyncEvent=function(){this.snapshotsInSyncListeners.forEach((function(t){t.next()}))},t}(),Ci=function(){function t(t,e,n){this.query=t,this.queryObserver=e,this.raisedInitialEvent=!1,this.snap=null,this.onlineState=Or.Unknown,this.options=n||{}}return t.prototype.onViewSnapshot=function(t){if(_(t.docChanges.length>0||t.syncStateChanged,"We got a new snapshot with no changes?"),!this.options.includeMetadataChanges){for(var e=[],n=0,r=t.docChanges;n<r.length;n++){var i=r[n];i.type!==Wr.Metadata&&e.push(i)}t=new Yr(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0)}var o=!1;return this.raisedInitialEvent?this.shouldRaiseEvent(t)&&(this.queryObserver.next(t),o=!0):this.shouldRaiseInitialEvent(t,this.onlineState)&&(this.raiseInitialEvent(t),o=!0),this.snap=t,o},t.prototype.onError=function(t){this.queryObserver.error(t)},t.prototype.applyOnlineStateChange=function(t){this.onlineState=t;var e=!1;return this.snap&&!this.raisedInitialEvent&&this.shouldRaiseInitialEvent(this.snap,t)&&(this.raiseInitialEvent(this.snap),e=!0),e},t.prototype.shouldRaiseInitialEvent=function(t,e){if(_(!this.raisedInitialEvent,"Determining whether to raise first event but already had first event"),!t.fromCache)return!0;var n=e!==Or.Offline;return this.options.waitForSyncWhenOnline&&n?(_(t.fromCache,"Waiting for sync, but snapshot is not from cache"),!1):!t.docs.isEmpty()||e===Or.Offline},t.prototype.shouldRaiseEvent=function(t){if(t.docChanges.length>0)return!0;var e=this.snap&&this.snap.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges},t.prototype.raiseInitialEvent=function(t){_(!this.raisedInitialEvent,"Trying to raise initial events for second time"),t=Yr.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.raisedInitialEvent=!0,this.queryObserver.next(t)},t}(),Si=function(){function t(t,e,n,r){this.targetId=t,this.fromCache=e,this.addedKeys=n,this.removedKeys=r}return t.fromSnapshot=function(e,n){for(var r=Bt(),i=Bt(),o=0,a=n.docChanges;o<a.length;o++){var s=a[o];switch(s.type){case Wr.Added:r=r.add(s.doc.key);break;case Wr.Removed:i=i.add(s.doc.key)}}return new t(e,n.fromCache,r,i)},t}(),Ii=function(t){this.key=t},Di=function(t){this.key=t},Ni=function(){function t(t,e){this.query=t,this._syncedDocuments=e,this.syncState=null,this.current=!1,this.limboDocuments=Bt(),this.mutatedKeys=Bt(),this.documentSet=new Kr(t.docComparator.bind(t))}return Object.defineProperty(t.prototype,"syncedDocuments",{get:function(){return this._syncedDocuments},enumerable:!0,configurable:!0}),t.prototype.computeDocChanges=function(t,e){var n=this,r=e?e.changeSet:new Gr,i=e?e.documentSet:this.documentSet,o=e?e.mutatedKeys:this.mutatedKeys,a=i,s=!1,u=this.query.hasLimitToFirst()&&i.size===this.query.limit?i.last():null,c=this.query.hasLimitToLast()&&i.size===this.query.limit?i.first():null;if(t.inorderTraversal((function(t,e){var h=i.get(t),l=e instanceof Qe?e:null;l&&(_(t.isEqual(l.key),"Mismatching keys found in document changes: "+t+" != "+l.key),l=n.query.matches(l)?l:null);var f=!!h&&n.mutatedKeys.has(h.key),p=!!l&&(l.hasLocalMutations||n.mutatedKeys.has(l.key)&&l.hasCommittedMutations),d=!1;h&&l?h.data().isEqual(l.data())?f!==p&&(r.track({type:Wr.Metadata,doc:l}),d=!0):n.shouldWaitForSyncedDocument(h,l)||(r.track({type:Wr.Modified,doc:l}),d=!0,(u&&n.query.docComparator(l,u)>0||c&&n.query.docComparator(l,c)<0)&&(s=!0)):!h&&l?(r.track({type:Wr.Added,doc:l}),d=!0):h&&!l&&(r.track({type:Wr.Removed,doc:h}),d=!0,(u||c)&&(s=!0));d&&(l?(a=a.add(l),o=p?o.add(t):o.delete(t)):(a=a.delete(t),o=o.delete(t)))})),this.query.hasLimitToFirst()||this.query.hasLimitToLast())for(;a.size>this.query.limit;){var h=this.query.hasLimitToFirst()?a.last():a.first();a=a.delete(h.key),o=o.delete(h.key),r.track({type:Wr.Removed,doc:h})}return _(!s||!e,"View was refilled using docs that themselves needed refilling."),{documentSet:a,changeSet:r,needsRefill:s,mutatedKeys:o}},t.prototype.shouldWaitForSyncedDocument=function(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations},t.prototype.applyChanges=function(t,e,n){var r=this;_(!t.needsRefill,"Cannot apply changes that need a refill");var i=this.documentSet;this.documentSet=t.documentSet,this.mutatedKeys=t.mutatedKeys;var o=t.changeSet.getChanges();o.sort((function(t,e){return function(t,e){var n=function(t){switch(t){case Wr.Added:return 1;case Wr.Modified:case Wr.Metadata:return 2;case Wr.Removed:return 0;default:return v("Unknown ChangeType: "+t)}};return n(t)-n(e)}(t.type,e.type)||r.query.docComparator(t.doc,e.doc)})),this.applyTargetChange(n);var a=e?this.updateLimboDocuments():[],s=0===this.limboDocuments.size&&this.current?Qr.Synced:Qr.Local,u=s!==this.syncState;return this.syncState=s,0!==o.length||u?{snapshot:new Yr(this.query,t.documentSet,i,o,t.mutatedKeys,s===Qr.Local,u,!1),limboChanges:a}:{limboChanges:a}},t.prototype.applyOnlineStateChange=function(t){return this.current&&t===Or.Offline?(this.current=!1,this.applyChanges({documentSet:this.documentSet,changeSet:new Gr,mutatedKeys:this.mutatedKeys,needsRefill:!1},!1)):{limboChanges:[]}},t.prototype.shouldBeInLimbo=function(t){return!this._syncedDocuments.has(t)&&(!!this.documentSet.has(t)&&!this.documentSet.get(t).hasLocalMutations)},t.prototype.applyTargetChange=function(t){var e=this;t&&(t.addedDocuments.forEach((function(t){return e._syncedDocuments=e._syncedDocuments.add(t)})),t.modifiedDocuments.forEach((function(t){return _(e._syncedDocuments.has(t),"Modified document "+t+" not found in view.")})),t.removedDocuments.forEach((function(t){return e._syncedDocuments=e._syncedDocuments.delete(t)})),this.current=t.current)},t.prototype.updateLimboDocuments=function(){var t=this;if(!this.current)return[];var e=this.limboDocuments;this.limboDocuments=Bt(),this.documentSet.forEach((function(e){t.shouldBeInLimbo(e.key)&&(t.limboDocuments=t.limboDocuments.add(e.key))}));var n=[];return e.forEach((function(e){t.limboDocuments.has(e)||n.push(new Di(e))})),this.limboDocuments.forEach((function(t){e.has(t)||n.push(new Ii(t))})),n},t.prototype.synchronizeWithPersistedState=function(t){this._syncedDocuments=t.remoteKeys,this.limboDocuments=Bt();var e=this.computeDocChanges(t.documents);return this.applyChanges(e,!0)},t.prototype.computeInitialSnapshot=function(){return Yr.fromInitialDocuments(this.query,this.documentSet,this.mutatedKeys,this.syncState===Qr.Local)},t}();var Ai=5,ki=function(){function t(t,e,n,r){this.asyncQueue=t,this.remoteStore=e,this.updateFunction=n,this.deferred=r,this.retries=Ai,this.backoff=new Rr(this.asyncQueue,nt.RetryTransaction)}return t.prototype.run=function(){this.runWithBackOff()},t.prototype.runWithBackOff=function(){var t=this;this.backoff.backoffAndRun((function(){return a.__awaiter(t,void 0,void 0,(function(){var t,e,n=this;return a.__generator(this,(function(r){return t=this.remoteStore.createTransaction(),(e=this.tryRunUpdateFunction(t))&&e.then((function(e){n.asyncQueue.enqueueAndForget((function(){return t.commit().then((function(){n.deferred.resolve(e)})).catch((function(t){n.handleTransactionError(t)}))}))})).catch((function(t){n.handleTransactionError(t)})),[2]}))}))}))},t.prototype.tryRunUpdateFunction=function(t){try{var e=this.updateFunction(t);return!Jn(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(y){return this.deferred.reject(y),null}},t.prototype.handleTransactionError=function(t){var e=this;this.retries>0&&this.isRetryableTransactionError(t)?(this.retries-=1,this.asyncQueue.enqueueAndForget((function(){return e.runWithBackOff(),Promise.resolve()}))):this.deferred.reject(t)},t.prototype.isRetryableTransactionError=function(t){if("FirebaseError"===t.name){var e=t.code;return"aborted"===e||"failed-precondition"===e||!Br(e)}return!1},t}(),Ri=function(t,e,n){this.query=t,this.targetId=e,this.view=n},Oi=function(t){this.key=t,this.receivedDocument=!1},xi=function(){function t(t,e,n,r){this.localStore=t,this.remoteStore=e,this.sharedClientState=n,this.currentUser=r,this.syncEngineListener=null,this.queryViewsByQuery=new Ge((function(t){return t.canonicalId()})),this.queriesByTarget={},this.limboTargetsByKey=new Dt(pt.comparator),this.limboResolutionsByTarget={},this.limboDocumentRefs=new gr,this.mutationUserCallbacks={},this.pendingWritesCallbacks=new Map,this.limboTargetIdGenerator=he.forSyncEngine(),this.isPrimary=void 0,this.onlineState=Or.Unknown}return Object.defineProperty(t.prototype,"isPrimaryClient",{get:function(){return!0===this.isPrimary},enumerable:!0,configurable:!0}),t.prototype.subscribe=function(t){_(null!==t,"SyncEngine listener cannot be null"),_(null===this.syncEngineListener,"SyncEngine already has a subscriber."),this.syncEngineListener=t},t.prototype.listen=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n,r,i,o;return a.__generator(this,(function(a){switch(a.label){case 0:return this.assertSubscribed("listen()"),(r=this.queryViewsByQuery.get(t))?(e=r.targetId,this.sharedClientState.addLocalQueryTarget(e),n=r.view.computeInitialSnapshot(),[3,4]):[3,1];case 1:return[4,this.localStore.allocateTarget(t.toTarget())];case 2:return i=a.sent(),o=this.sharedClientState.addLocalQueryTarget(i.targetId),e=i.targetId,[4,this.initializeViewAndComputeSnapshot(t,e,"current"===o)];case 3:n=a.sent(),this.isPrimary&&this.remoteStore.listen(i),a.label=4;case 4:return this.syncEngineListener.onWatchChange([n]),[2,e]}}))}))},t.prototype.initializeViewAndComputeSnapshot=function(t,e,n){return a.__awaiter(this,void 0,void 0,(function(){var r,i,o,s,u,c;return a.__generator(this,(function(a){switch(a.label){case 0:return[4,this.localStore.executeQuery(t,!0)];case 1:return r=a.sent(),i=new Ni(t,r.remoteKeys),o=i.computeDocChanges(r.documents),s=Jr.createSynthesizedTargetChangeForCurrentChange(e,n&&this.onlineState!==Or.Offline),_(0===(u=i.applyChanges(o,!0===this.isPrimary,s)).limboChanges.length,"View returned limbo docs before target ack from the server."),_(!!u.snapshot,"applyChanges for new view should always return a snapshot"),c=new Ri(t,e,i),this.queryViewsByQuery.set(t,c),this.queriesByTarget[e]||(this.queriesByTarget[e]=[]),this.queriesByTarget[e].push(t),[2,u.snapshot]}}))}))},t.prototype.synchronizeViewAndComputeSnapshot=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n;return a.__generator(this,(function(r){switch(r.label){case 0:return[4,this.localStore.executeQuery(t.query,!0)];case 1:return e=r.sent(),n=t.view.synchronizeWithPersistedState(e),this.isPrimary&&this.updateTrackedLimbos(t.targetId,n.limboChanges),[2,n]}}))}))},t.prototype.unlisten=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n,r=this;return a.__generator(this,(function(i){switch(i.label){case 0:return this.assertSubscribed("unlisten()"),_(!!(e=this.queryViewsByQuery.get(t)),"Trying to unlisten on query not found:"+t),(n=this.queriesByTarget[e.targetId]).length>1?(this.queriesByTarget[e.targetId]=n.filter((function(e){return!e.isEqual(t)})),this.queryViewsByQuery.delete(t),[2]):this.isPrimary?(this.sharedClientState.removeLocalQueryTarget(e.targetId),this.sharedClientState.isActiveQueryTarget(e.targetId)?[3,2]:[4,this.localStore.releaseTarget(e.targetId,!1).then((function(){r.sharedClientState.clearQueryState(e.targetId),r.remoteStore.unlisten(e.targetId),r.removeAndCleanupTarget(e.targetId)})).catch(jn)]):[3,3];case 1:i.sent(),i.label=2;case 2:return[3,5];case 3:return this.removeAndCleanupTarget(e.targetId),[4,this.localStore.releaseTarget(e.targetId,!0)];case 4:i.sent(),i.label=5;case 5:return[2]}}))}))},t.prototype.write=function(t,e){return a.__awaiter(this,void 0,void 0,(function(){var n;return a.__generator(this,(function(r){switch(r.label){case 0:return this.assertSubscribed("write()"),[4,this.localStore.localWrite(t)];case 1:return n=r.sent(),this.sharedClientState.addPendingMutation(n.batchId),this.addMutationCallback(n.batchId,e),[4,this.emitNewSnapsAndNotifyLocalStore(n.changes)];case 2:return r.sent(),[4,this.remoteStore.fillWritePipeline()];case 3:return r.sent(),[2]}}))}))},t.prototype.runTransaction=function(t,e,n){new ki(t,this.remoteStore,e,n).run()},t.prototype.applyRemoteEvent=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n=this;return a.__generator(this,(function(r){switch(r.label){case 0:this.assertSubscribed("applyRemoteEvent()"),r.label=1;case 1:return r.trys.push([1,4,,6]),[4,this.localStore.applyRemoteEvent(t)];case 2:return e=r.sent(),N(t.targetChanges,(function(t,e){var r=n.limboResolutionsByTarget[Number(t)];r&&(_(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,"Limbo resolution for single document contains multiple changes."),e.addedDocuments.size>0?r.receivedDocument=!0:e.modifiedDocuments.size>0?_(r.receivedDocument,"Received change for limbo target document without add."):e.removedDocuments.size>0&&(_(r.receivedDocument,"Received remove for limbo target document without add."),r.receivedDocument=!1))})),[4,this.emitNewSnapsAndNotifyLocalStore(e,t)];case 3:return r.sent(),[3,6];case 4:return[4,jn(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}))}))},t.prototype.applyOnlineStateChange=function(t,e){if(this.isPrimary&&e===xr.RemoteStore||!this.isPrimary&&e===xr.SharedClientState){this.assertSubscribed("applyOnlineStateChange()");var n=[];this.queryViewsByQuery.forEach((function(e,r){var i=r.view.applyOnlineStateChange(t);_(0===i.limboChanges.length,"OnlineState should not affect limbo documents."),i.snapshot&&n.push(i.snapshot)})),this.syncEngineListener.onOnlineStateChange(t),this.syncEngineListener.onWatchChange(n),this.onlineState=t,this.isPrimary&&this.sharedClientState.setOnlineState(t)}},t.prototype.rejectListen=function(t,e){return a.__awaiter(this,void 0,void 0,(function(){var n,r,i,o,s,u=this;return a.__generator(this,(function(a){switch(a.label){case 0:return this.assertSubscribed("rejectListens()"),this.sharedClientState.updateQueryState(t,"rejected",e),n=this.limboResolutionsByTarget[t],(r=n&&n.key)?(this.limboTargetsByKey=this.limboTargetsByKey.remove(r),delete this.limboResolutionsByTarget[t],i=(i=new Dt(pt.comparator)).insert(r,new Ke(r,It.forDeletedDoc())),o=Bt().add(r),s=new Xr(It.MIN,{},new Rt(J),i,o),[2,this.applyRemoteEvent(s)]):[3,1];case 1:return[4,this.localStore.releaseTarget(t,!1).then((function(){return u.removeAndCleanupTarget(t,e)})).catch(jn)];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))},t.prototype.applyBatchState=function(t,e,n){return a.__awaiter(this,void 0,void 0,(function(){var r;return a.__generator(this,(function(i){switch(i.label){case 0:return this.assertSubscribed("applyBatchState()"),[4,this.localStore.lookupMutationDocuments(t)];case 1:return null===(r=i.sent())?(m("SyncEngine","Cannot apply mutation batch with id: "+t),[2]):"pending"!==e?[3,3]:[4,this.remoteStore.fillWritePipeline()];case 2:return i.sent(),[3,4];case 3:"acknowledged"===e||"rejected"===e?(this.processUserCallback(t,n||null),this.localStore.removeCachedMutationBatchMetadata(t)):v("Unknown batchState: "+e),i.label=4;case 4:return[4,this.emitNewSnapsAndNotifyLocalStore(r)];case 5:return i.sent(),[2]}}))}))},t.prototype.applySuccessfulWrite=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n;return a.__generator(this,(function(r){switch(r.label){case 0:this.assertSubscribed("applySuccessfulWrite()"),e=t.batch.batchId,this.processUserCallback(e,null),this.triggerPendingWritesCallbacks(e),r.label=1;case 1:return r.trys.push([1,4,,6]),[4,this.localStore.acknowledgeBatch(t)];case 2:return n=r.sent(),this.sharedClientState.updateMutationState(e,"acknowledged"),[4,this.emitNewSnapsAndNotifyLocalStore(n)];case 3:return r.sent(),[3,6];case 4:return[4,jn(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}))}))},t.prototype.rejectFailedWrite=function(t,e){return a.__awaiter(this,void 0,void 0,(function(){var n;return a.__generator(this,(function(r){switch(r.label){case 0:this.assertSubscribed("rejectFailedWrite()"),this.processUserCallback(t,e),this.triggerPendingWritesCallbacks(t),r.label=1;case 1:return r.trys.push([1,4,,6]),[4,this.localStore.rejectBatch(t)];case 2:return n=r.sent(),this.sharedClientState.updateMutationState(t,"rejected",e),[4,this.emitNewSnapsAndNotifyLocalStore(n)];case 3:return r.sent(),[3,6];case 4:return[4,jn(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}))}))},t.prototype.registerPendingWritesCallback=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n;return a.__generator(this,(function(r){switch(r.label){case 0:return this.remoteStore.canUseNetwork()||m("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),[4,this.localStore.getHighestUnacknowledgedBatchId()];case 1:return-1===(e=r.sent())?(t.resolve(),[2]):((n=this.pendingWritesCallbacks.get(e)||[]).push(t),this.pendingWritesCallbacks.set(e,n),[2])}}))}))},t.prototype.triggerPendingWritesCallbacks=function(t){(this.pendingWritesCallbacks.get(t)||[]).forEach((function(t){t.resolve()})),this.pendingWritesCallbacks.delete(t)},t.prototype.rejectOutstandingPendingWritesCallbacks=function(t){this.pendingWritesCallbacks.forEach((function(e){e.forEach((function(e){e.reject(new T(E.CANCELLED,t))}))})),this.pendingWritesCallbacks.clear()},t.prototype.addMutationCallback=function(t,e){var n=this.mutationUserCallbacks[this.currentUser.toKey()];n||(n=new Dt(J)),n=n.insert(t,e),this.mutationUserCallbacks[this.currentUser.toKey()]=n},t.prototype.processUserCallback=function(t,e){var n=this.mutationUserCallbacks[this.currentUser.toKey()];if(n){var r=n.get(t);r&&(_(t===n.minKey(),"Mutation callbacks processed out-of-order?"),e?r.reject(e):r.resolve(),n=n.remove(t)),this.mutationUserCallbacks[this.currentUser.toKey()]=n}},t.prototype.removeAndCleanupTarget=function(t,e){var n=this;void 0===e&&(e=null),this.sharedClientState.removeLocalQueryTarget(t),_(this.queriesByTarget[t]&&0!==this.queriesByTarget[t].length,"There are no queries mapped to target id "+t);for(var r=0,i=this.queriesByTarget[t];r<i.length;r++){var o=i[r];this.queryViewsByQuery.delete(o),e&&this.syncEngineListener.onWatchError(o,e)}if(delete this.queriesByTarget[t],this.isPrimary){var a=this.limboDocumentRefs.referencesForId(t);this.limboDocumentRefs.removeReferencesForId(t),a.forEach((function(t){n.limboDocumentRefs.containsKey(t)||n.removeLimboTarget(t)}))}},t.prototype.removeLimboTarget=function(t){var e=this.limboTargetsByKey.get(t);null!==e&&(this.remoteStore.unlisten(e),this.limboTargetsByKey=this.limboTargetsByKey.remove(t),delete this.limboResolutionsByTarget[e])},t.prototype.updateTrackedLimbos=function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n];if(i instanceof Ii)this.limboDocumentRefs.addReference(i.key,t),this.trackLimboChange(i);else if(i instanceof Di){m("SyncEngine","Document no longer in limbo: "+i.key),this.limboDocumentRefs.removeReference(i.key,t),this.limboDocumentRefs.containsKey(i.key)||this.removeLimboTarget(i.key)}else v("Unknown limbo change: "+JSON.stringify(i))}},t.prototype.trackLimboChange=function(t){var e=t.key;if(!this.limboTargetsByKey.get(e)){m("SyncEngine","New document in limbo: "+e);var n=this.limboTargetIdGenerator.next(),r=er.atPath(e.path);this.limboResolutionsByTarget[n]=new Oi(e),this.remoteStore.listen(new Nn(r.toTarget(),n,wn.LimboResolution,ut.INVALID)),this.limboTargetsByKey=this.limboTargetsByKey.insert(e,n)}},t.prototype.currentLimboDocs=function(){return this.limboTargetsByKey},t.prototype.emitNewSnapsAndNotifyLocalStore=function(t,e){return a.__awaiter(this,void 0,void 0,(function(){var n,r,i,o=this;return a.__generator(this,(function(a){switch(a.label){case 0:return n=[],r=[],i=[],this.queryViewsByQuery.forEach((function(a,s){i.push(Promise.resolve().then((function(){var e=s.view.computeDocChanges(t);return e.needsRefill?o.localStore.executeQuery(s.query,!1).then((function(t){var n=t.documents;return s.view.computeDocChanges(n,e)})):e})).then((function(t){var i=e&&e.targetChanges[s.targetId],a=s.view.applyChanges(t,!0===o.isPrimary,i);if(o.updateTrackedLimbos(s.targetId,a.limboChanges),a.snapshot){o.isPrimary&&o.sharedClientState.updateQueryState(s.targetId,a.snapshot.fromCache?"not-current":"current"),n.push(a.snapshot);var u=Si.fromSnapshot(s.targetId,a.snapshot);r.push(u)}})))})),[4,Promise.all(i)];case 1:return a.sent(),this.syncEngineListener.onWatchChange(n),[4,this.localStore.notifyLocalViewChanges(r)];case 2:return a.sent(),[2]}}))}))},t.prototype.assertSubscribed=function(t){_(null!==this.syncEngineListener,"Trying to call "+t+" before calling subscribe().")},t.prototype.handleCredentialChange=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n;return a.__generator(this,(function(r){switch(r.label){case 0:return e=!this.currentUser.isEqual(t),this.currentUser=t,e?(this.rejectOutstandingPendingWritesCallbacks("'waitForPendingWrites' promise is rejected due to a user change."),[4,this.localStore.handleUserChange(t)]):[3,3];case 1:return n=r.sent(),this.sharedClientState.handleUserChange(t,n.removedBatchIds,n.addedBatchIds),[4,this.emitNewSnapsAndNotifyLocalStore(n.affectedDocuments)];case 2:r.sent(),r.label=3;case 3:return[4,this.remoteStore.handleCredentialChange()];case 4:return r.sent(),[2]}}))}))},t.prototype.applyPrimaryState=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n,r,i,o,s,u,c=this;return a.__generator(this,(function(a){switch(a.label){case 0:return!0!==t||!0===this.isPrimary?[3,3]:(this.isPrimary=!0,[4,this.remoteStore.applyPrimaryState(!0)]);case 1:return a.sent(),e=this.sharedClientState.getAllActiveQueryTargets(),[4,this.synchronizeQueryViewsAndRaiseSnapshots(e.toArray())];case 2:for(n=a.sent(),r=0,i=n;r<i.length;r++)o=i[r],this.remoteStore.listen(o);return[3,7];case 3:return!1!==t||!1===this.isPrimary?[3,7]:(this.isPrimary=!1,s=[],u=Promise.resolve(),D(this.queriesByTarget,(function(t,e){c.sharedClientState.isLocalQueryTarget(t)?s.push(t):u=u.then((function(){return c.removeAndCleanupTarget(t),c.localStore.releaseTarget(t,!0)})),c.remoteStore.unlisten(t)})),[4,u]);case 4:return a.sent(),[4,this.synchronizeQueryViewsAndRaiseSnapshots(s)];case 5:return a.sent(),this.resetLimboDocuments(),[4,this.remoteStore.applyPrimaryState(!1)];case 6:a.sent(),a.label=7;case 7:return[2]}}))}))},t.prototype.resetLimboDocuments=function(){var t=this;D(this.limboResolutionsByTarget,(function(e){t.remoteStore.unlisten(e)})),this.limboDocumentRefs.removeAllReferences(),this.limboResolutionsByTarget=[],this.limboTargetsByKey=new Dt(pt.comparator)},t.prototype.synchronizeQueryViewsAndRaiseSnapshots=function(t){return a.__awaiter(this,void 0,void 0,(function(){var e,n,r,i,o,s,u,c,h,l,f,p,d;return a.__generator(this,(function(a){switch(a.label){case 0:e=[],n=[],r=0,i=t,a.label=1;case 1:return r<i.length?(o=i[r],s=void 0,(u=this.queriesByTarget[o])&&0!==u.length?[4,this.localStore.releaseTarget(o,!0)]:[3,8]):[3,14];case 2:return a.sent(),[4,this.localStore.allocateTarget(u[0].toTarget())];case 3:s=a.sent(),c=0,h=u,a.label=4;case 4:return c<h.length?(l=h[c],_(!!(f=this.queryViewsByQuery.get(l)),"No query view found for "+l),[4,this.synchronizeViewAndComputeSnapshot(f)]):[3,7];case 5:(p=a.sent()).snapshot&&n.push(p.snapshot),a.label=6;case 6:return c++,[3,4];case 7:return[3,12];case 8:return _(!0===this.isPrimary,"A secondary tab should never have an active target without an active query."),[4,this.localStore.getTarget(o)];case 9:return _(!!(d=a.sent()),"Target for id "+o+" not found"),[4,this.localStore.allocateTarget(d)];case 10:return s=a.sent(),[4,this.initializeViewAndComputeSnapshot(this.synthesizeTargetToQuery(d),o,!1)];case 11:a.sent(),a.label=12;case 12:e.push(s),a.label=13;case 13:return r++,[3,1];case 14:return this.syncEngineListener.onWatchChange(n),[2,e]}}))}))},t.prototype.synthesizeTargetToQuery=function(t){return new er(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,$n.First,t.startAt,t.endAt)},t.prototype.getActiveClients=function(){return this.localStore.getActiveClients()},t.prototype.applyTargetState=function(t,e,n){return a.__awaiter(this,void 0,void 0,(function(){var r,i;return a.__generator(this,(function(o){switch(o.label){case 0:if(this.isPrimary)return m("SyncEngine","Ignoring unexpected query state notification."),[2];if(!this.queriesByTarget[t])return[3,7];switch(e){case"current":case"not-current":return[3,1];case"rejected":return[3,4]}return[3,6];case 1:return[4,this.localStore.getNewDocumentChanges()];case 2:return r=o.sent(),i=Xr.createSynthesizedRemoteEventForCurrentChange(t,"current"===e),[4,this.emitNewSnapsAndNotifyLocalStore(r,i)];case 3:return o.sent(),[3,7];case 4:return[4,this.localStore.releaseTarget(t,!0)];case 5:return o.sent(),this.removeAndCleanupTarget(t,n),[3,7];case 6:v("Unexpected target state: "+e),o.label=7;case 7:return[2]}}))}))},t.prototype.applyActiveTargetsChange=function(t,e){return a.__awaiter(this,void 0,void 0,(function(){var n,r,i,o,s,u,c,h,l,f=this;return a.__generator(this,(function(p){switch(p.label){case 0:if(!this.isPrimary)return[2];n=0,r=t,p.label=1;case 1:return n<r.length?(l=r[n],_(!this.queriesByTarget[l],"Trying to add an already active target"),[4,this.localStore.getTarget(l)]):[3,6];case 2:return _(!!(i=p.sent()),"Query data for active target "+l+" not found"),[4,this.localStore.allocateTarget(i)];case 3:return o=p.sent(),[4,this.initializeViewAndComputeSnapshot(this.synthesizeTargetToQuery(i),o.targetId,!1)];case 4:p.sent(),this.remoteStore.listen(o),p.label=5;case 5:return n++,[3,1];case 6:s=function(t){return a.__generator(this,(function(e){switch(e.label){case 0:return u.queriesByTarget[t]?[4,u.localStore.releaseTarget(t,!1).then((function(){f.remoteStore.unlisten(t),f.removeAndCleanupTarget(t)})).catch(jn)]:[2,"continue"];case 1:return e.sent(),[2]}}))},u=this,c=0,h=e,p.label=7;case 7:return c<h.length?(l=h[c],[5,s(l)]):[3,10];case 8:p.sent(),p.label=9;case 9:return c++,[3,7];case 10:return[2]}}))}))},t.prototype.enableNetwork=function(){return this.localStore.setNetworkEnabled(!0),this.remoteStore.enableNetwork()},t.prototype.disableNetwork=function(){return this.localStore.setNetworkEnabled(!1),this.remoteStore.disableNetwork()},t.prototype.getRemoteKeysForTarget=function(t){var e=this.limboResolutionsByTarget[t];if(e&&e.receivedDocument)return Bt().add(e.key);var n=Bt(),r=this.queriesByTarget[t];if(!r)return n;for(var i=0,o=r;i<o.length;i++){var a=o[i],s=this.queryViewsByQuery.get(a);_(!!s,"No query view found for "+a),n=n.unionWith(s.view.syncedDocuments)}return n},t}(),Pi=function(){function t(t){this.uid=t}return t.prototype.isAuthenticated=function(){return null!=this.uid},t.prototype.toKey=function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"},t.prototype.isEqual=function(t){return t.uid===this.uid},t.UNAUTHENTICATED=new t(null),t.GOOGLE_CREDENTIALS=new t("google-credentials-uid"),t.FIRST_PARTY=new t("first-party-uid"),t}(),Mi="firestore_clients";function Li(t,e){return _(-1===e.indexOf("_"),"Client key cannot contain '_', but was '"+e+"'"),Mi+"_"+t+"_"+e}var Fi="firestore_mutations";function Ui(t,e,n){var r=Fi+"_"+t+"_"+n;return e.isAuthenticated()&&(r+="_"+e.uid),r}var qi="firestore_targets";function Vi(t,e){return qi+"_"+t+"_"+e}var Bi="firestore_online_state";var ji="firestore_sequence_number";var zi="SharedClientState",Wi=function(){function t(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r,_(void 0!==r==("rejected"===n),"MutationMetadata must contain an error iff state is 'rejected'")}return t.fromWebStorageEntry=function(e,n,r){var i=JSON.parse(r),o="object"==typeof i&&-1!==["pending","acknowledged","rejected"].indexOf(i.state)&&(void 0===i.error||"object"==typeof i.error),a=void 0;return o&&i.error&&(o="string"==typeof i.error.message&&"string"==typeof i.error.code)&&(a=new T(i.error.code,i.error.message)),o?new t(e,n,i.state,a):(y(zi,"Failed to parse mutation state for ID '"+n+"': "+r),null)},t.prototype.toWebStorageJSON=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},t}(),Qi=function(){function t(t,e,n){this.targetId=t,this.state=e,this.error=n,_(void 0!==n==("rejected"===e),"QueryTargetMetadata must contain an error iff state is 'rejected'")}return t.fromWebStorageEntry=function(e,n){var r=JSON.parse(n),i="object"==typeof r&&-1!==["not-current","current","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error),o=void 0;return i&&r.error&&(i="string"==typeof r.error.message&&"string"==typeof r.error.code)&&(o=new T(r.error.code,r.error.message)),i?new t(e,r.state,o):(y(zi,"Failed to parse target state for ID '"+e+"': "+n),null)},t.prototype.toWebStorageJSON=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},t}(),Ki=function(){function t(t,e){this.clientId=t,this.activeTargetIds=e}return t.fromWebStorageEntry=function(e,n){for(var r=JSON.parse(n),i="object"==typeof r&&r.activeTargetIds instanceof Array,o=zt(),a=0;i&&a<r.activeTargetIds.length;++a)i=Zn(r.activeTargetIds[a]),o=o.add(r.activeTargetIds[a]);return i?new t(e,o):(y(zi,"Failed to parse client data for instance '"+e+"': "+n),null)},t}(),Hi=function(){function t(t,e){this.clientId=t,this.onlineState=e}return t.fromWebStorageEntry=function(e){var n=JSON.parse(e);return"object"==typeof n&&n.onlineState in Or&&"string"==typeof n.clientId?new t(n.clientId,Or[n.onlineState]):(y(zi,"Failed to parse online state: "+e),null)},t}(),Gi=function(){function t(){this.activeTargetIds=zt()}return t.prototype.addQueryTarget=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},t.prototype.removeQueryTarget=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},t.prototype.toWebStorageJSON=function(){var t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)},t}(),Yi=function(){function t(e,n,r,i,o){if(this.queue=e,this.platform=n,this.persistenceKey=r,this.localClientId=i,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.activeClients={},this.storageListener=this.handleWebStorageEvent.bind(this),this.started=!1,this.earlyEvents=[],!t.isAvailable(this.platform))throw new T(E.UNIMPLEMENTED,"LocalStorage is not available on this platform.");var a=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.platform.window.localStorage,this.currentUser=o,this.localClientStorageKey=Li(this.persistenceKey,this.localClientId),this.sequenceNumberKey=function(t){return ji+"_"+t}(this.persistenceKey),this.activeClients[this.localClientId]=new Gi,this.clientStateKeyRe=new RegExp("^"+Mi+"_"+a+"_([^_]*)$"),this.mutationBatchKeyRe=new RegExp("^"+Fi+"_"+a+"_(\\d+)(?:_(.*))?$"),this.queryTargetKeyRe=new RegExp("^"+qi+"_"+a+"_(\\d+)$"),this.onlineStateKey=function(t){return Bi+"_"+t}(this.persistenceKey),this.platform.window.addEventListener("storage",this.storageListener)}return t.isAvailable=function(t){return!(!t.window||null==t.window.localStorage)},t.prototype.start=function(){return a.__awaiter(this,void 0,void 0,(function(){var t,e,n,r,i,o,s,u,c,h,l,f=this;return a.__generator(this,(function(a){switch(a.label){case 0:return _(!this.started,"WebStorageSharedClientState already started"),_(null!==this.syncEngine,"syncEngine property must be set before calling start()"),_(null!==this.onlineStateHandler,"onlineStateHandler property must be set before calling start()"),[4,this.syncEngine.getActiveClients()];case 1:for(t=a.sent(),e=0,n=t;e<n.length;e++)(r=n[e])!==this.localClientId&&(i=this.getItem(Li(this.persistenceKey,r)))&&(o=Ki.fromWebStorageEntry(r,i))&&(this.activeClients[o.clientId]=o);for(this.persistClientState(),(s=this.storage.getItem(this.onlineStateKey))&&(u=this.fromWebStorageOnlineState(s))&&this.handleOnlineStateEvent(u),c=0,h=this.earlyEvents;c<h.length;c++)l=h[c],this.handleWebStorageEvent(l);return this.earlyEvents=[],this.platform.window.addEventListener("unload",(function(){return f.shutdown()})),this.started=!0,[2]}}))}))},t.prototype.writeSequenceNumber=function(t){this.setItem(this.sequenceNumberKey,JSON.stringify(t))},t.prototype.getAllActiveQueryTargets=function(){var t=zt();return N(this.activeClients,(function(e,n){t=t.unionWith(n.activeTargetIds)})),t},t.prototype.isActiveQueryTarget=function(t){for(var e in this.activeClients)if(this.activeClients.hasOwnProperty(e)&&this.activeClients[e].activeTargetIds.has(t))return!0;return!1},t.prototype.addPendingMutation=function(t){this.persistMutationState(t,"pending")},t.prototype.updateMutationState=function(t,e,n){this.persistMutationState(t,e,n),this.removeMutationState(t)},t.prototype.addLocalQueryTarget=function(t){var e="not-current";if(this.isActiveQueryTarget(t)){var n=this.storage.getItem(Vi(this.persistenceKey,t));if(n){var r=Qi.fromWebStorageEntry(t,n);r&&(e=r.state)}}return this.localClientState.addQueryTarget(t),this.persistClientState(),e},t.prototype.removeLocalQueryTarget=function(t){this.localClientState.removeQueryTarget(t),this.persistClientState()},t.prototype.isLocalQueryTarget=function(t){return this.localClientState.activeTargetIds.has(t)},t.prototype.clearQueryState=function(t){this.removeItem(Vi(this.persistenceKey,t))},t.prototype.updateQueryState=function(t,e,n){this.persistQueryTargetState(t,e,n)},t.prototype.handleUserChange=function(t,e,n){var r=this;e.forEach((function(t){r.removeMutationState(t)})),this.currentUser=t,n.forEach((function(t){r.addPendingMutation(t)}))},t.prototype.setOnlineState=function(t){this.persistOnlineState(t)},t.prototype.shutdown=function(){this.started&&(this.platform.window.removeEventListener("storage",this.storageListener),this.removeItem(this.localClientStorageKey),this.started=!1)},t.prototype.getItem=function(t){var e=this.storage.getItem(t);return m(zi,"READ",t,e),e},t.prototype.setItem=function(t,e){m(zi,"SET",t,e),this.storage.setItem(t,e)},t.prototype.removeItem=function(t){m(zi,"REMOVE",t),this.storage.removeItem(t)},t.prototype.handleWebStorageEvent=function(t){var e=this;if(t.storageArea===this.storage){if(m(zi,"EVENT",t.key,t.newValue),t.key===this.localClientStorageKey)return void y("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.queue.enqueueAndForget((function(){return a.__awaiter(e,void 0,void 0,(function(){var e,n,r,i,o,s;return a.__generator(this,(function(a){if(!this.started)return this.earlyEvents.push(t),[2];if(null===t.key)return[2];if(this.clientStateKeyRe.test(t.key)){if(null==t.newValue)return n=this.fromWebStorageClientStateKey(t.key),[2,this.handleClientStateEvent(n,null)];if(e=this.fromWebStorageClientState(t.key,t.newValue))return[2,this.handleClientStateEvent(e.clientId,e)]}else if(this.mutationBatchKeyRe.test(t.key)){if(null!==t.newValue&&(r=this.fromWebStorageMutationMetadata(t.key,t.newValue)))return[2,this.handleMutationBatchEvent(r)]}else if(this.queryTargetKeyRe.test(t.key)){if(null!==t.newValue&&(i=this.fromWebStorageQueryTargetMetadata(t.key,t.newValue)))return[2,this.handleQueryTargetEvent(i)]}else if(t.key===this.onlineStateKey){if(null!==t.newValue&&(o=this.fromWebStorageOnlineState(t.newValue)))return[2,this.handleOnlineStateEvent(o)]}else t.key===this.sequenceNumberKey&&(_(!!this.sequenceNumberHandler,"Missing sequenceNumberHandler"),(s=function(t){var e=ut.INVALID;if(null!=t)try{var n=JSON.parse(t);_("number"==typeof n,"Found non-numeric sequence number"),e=n}catch(r){y(zi,"Failed to read sequence number from WebStorage",r)}return e}(t.newValue))!==ut.INVALID&&this.sequenceNumberHandler(s));return[2]}))}))}))}},Object.defineProperty(t.prototype,"localClientState",{get:function(){return this.activeClients[this.localClientId]},enumerable:!0,configurable:!0}),t.prototype.persistClientState=function(){this.setItem(this.localClientStorageKey,this.localClientState.toWebStorageJSON())},t.prototype.persistMutationState=function(t,e,n){var r=new Wi(this.currentUser,t,e,n),i=Ui(this.persistenceKey,this.currentUser,t);this.setItem(i,r.toWebStorageJSON())},t.prototype.removeMutationState=function(t){var e=Ui(this.persistenceKey,this.currentUser,t);this.removeItem(e)},t.prototype.persistOnlineState=function(t){var e={clientId:this.localClientId,onlineState:Or[t]};this.storage.setItem(this.onlineStateKey,JSON.stringify(e))},t.prototype.persistQueryTargetState=function(t,e,n){var r=Vi(this.persistenceKey,t),i=new Qi(t,e,n);this.setItem(r,i.toWebStorageJSON())},t.prototype.fromWebStorageClientStateKey=function(t){var e=this.clientStateKeyRe.exec(t);return e?e[1]:null},t.prototype.fromWebStorageClientState=function(t,e){var n=this.fromWebStorageClientStateKey(t);return _(null!==n,"Cannot parse client state key '"+t+"'"),Ki.fromWebStorageEntry(n,e)},t.prototype.fromWebStorageMutationMetadata=function(t,e){var n=this.mutationBatchKeyRe.exec(t);_(null!==n,"Cannot parse mutation batch key '"+t+"'");var r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return Wi.fromWebStorageEntry(new Pi(i),r,e)},t.prototype.fromWebStorageQueryTargetMetadata=function(t,e){var n=this.queryTargetKeyRe.exec(t);_(null!==n,"Cannot parse query target key '"+t+"'");var r=Number(n[1]);return Qi.fromWebStorageEntry(r,e)},t.prototype.fromWebStorageOnlineState=function(t){return Hi.fromWebStorageEntry(t)},t.prototype.handleMutationBatchEvent=function(t){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(e){return t.user.uid!==this.currentUser.uid?(m(zi,"Ignoring mutation for non-active user "+t.user.uid),[2]):[2,this.syncEngine.applyBatchState(t.batchId,t.state,t.error)]}))}))},t.prototype.handleQueryTargetEvent=function(t){return this.syncEngine.applyTargetState(t.targetId,t.state,t.error)},t.prototype.handleClientStateEvent=function(t,e){var n=this,r=this.getAllActiveQueryTargets();e?this.activeClients[t]=e:delete this.activeClients[t];var i=this.getAllActiveQueryTargets(),o=[],s=[];return i.forEach((function(t){return a.__awaiter(n,void 0,void 0,(function(){return a.__generator(this,(function(e){return r.has(t)||o.push(t),[2]}))}))})),r.forEach((function(t){return a.__awaiter(n,void 0,void 0,(function(){return a.__generator(this,(function(e){return i.has(t)||s.push(t),[2]}))}))})),this.syncEngine.applyActiveTargetsChange(o,s)},t.prototype.handleOnlineStateEvent=function(t){this.activeClients[t.clientId]&&this.onlineStateHandler(t.onlineState)},t}();var Xi=function(){function t(){this.localState=new Gi,this.queryState={},this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null}return t.prototype.addPendingMutation=function(t){},t.prototype.updateMutationState=function(t,e,n){},t.prototype.addLocalQueryTarget=function(t){return this.localState.addQueryTarget(t),this.queryState[t]||"not-current"},t.prototype.updateQueryState=function(t,e,n){this.queryState[t]=e},t.prototype.removeLocalQueryTarget=function(t){this.localState.removeQueryTarget(t)},t.prototype.isLocalQueryTarget=function(t){return this.localState.activeTargetIds.has(t)},t.prototype.clearQueryState=function(t){delete this.queryState[t]},t.prototype.getAllActiveQueryTargets=function(){return this.localState.activeTargetIds},t.prototype.isActiveQueryTarget=function(t){return this.localState.activeTargetIds.has(t)},t.prototype.start=function(){return this.localState=new Gi,Promise.resolve()},t.prototype.handleUserChange=function(t,e,n){},t.prototype.setOnlineState=function(t){},t.prototype.shutdown=function(){},t.prototype.writeSequenceNumber=function(t){},t}(),Ji=function(){function t(t,e){this.cacheSizeBytes=t,this.synchronizeTabs=e}return t.prototype.lruParams=function(){return xn.withCacheSize(this.cacheSizeBytes)},t}(),Zi=function(){},$i=function(){function t(t,e,n,r){this.platform=t,this.databaseInfo=e,this.credentials=n,this.asyncQueue=r,this.clientId=X.newId()}return t.prototype.start=function(t){var e=this;this.verifyNotTerminated();var n=new dt,r=new dt,i=!1;return this.credentials.setChangeListener((function(o){i?e.asyncQueue.enqueueAndForget((function(){return e.handleCredentialChange(o)})):(i=!0,e.initializePersistence(t,r,o).then((function(t){return e.initializeRest(o,t)})).then(n.resolve,n.reject))})),this.asyncQueue.enqueueAndForget((function(){return n.promise})),r.promise},t.prototype.enableNetwork=function(){var t=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue((function(){return t.syncEngine.enableNetwork()}))},t.prototype.initializePersistence=function(t,e,n){var r=this;return t instanceof Ji?this.startIndexedDbPersistence(n,t).then((function(t){return e.resolve(),t})).catch((function(t){if(e.reject(t),!r.canFallback(t))throw t;return console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+t),r.startMemoryPersistence()})):(e.resolve(),this.startMemoryPersistence())},t.prototype.canFallback=function(t){return t instanceof T?t.code===E.FAILED_PRECONDITION||t.code===E.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||(22===t.code||20===t.code||11===t.code)},t.prototype.verifyNotTerminated=function(){if(this.asyncQueue.isShuttingDown)throw new T(E.FAILED_PRECONDITION,"The client has already been terminated.")},t.prototype.startIndexedDbPersistence=function(t,e){var n=this,r=Bn.buildStoragePrefix(this.databaseInfo),i=new wi(this.databaseInfo.databaseId,{useProto3Json:!0});return Promise.resolve().then((function(){return a.__awaiter(n,void 0,void 0,(function(){var n,o;return a.__generator(this,(function(a){switch(a.label){case 0:if(e.synchronizeTabs&&!Yi.isAvailable(this.platform))throw new T(E.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");return n=e.lruParams(),this.sharedClientState=e.synchronizeTabs?new Yi(this.asyncQueue,this.platform,r,this.clientId,t):new Xi,[4,Bn.createIndexedDbPersistence({allowTabSynchronization:e.synchronizeTabs,persistenceKey:r,clientId:this.clientId,platform:this.platform,queue:this.asyncQueue,serializer:i,lruParams:n,sequenceNumberSyncer:this.sharedClientState})];case 1:return o=a.sent(),this.persistence=o,[2,o.referenceDelegate.garbageCollector]}}))}))}))},t.prototype.startMemoryPersistence=function(){return this.persistence=Cr.createEagerPersistence(this.clientId),this.sharedClientState=new Xi,Promise.resolve(null)},t.prototype.initializeRest=function(t,e){var n=this;return m("FirestoreClient","Initializing. user=",t.uid),this.platform.loadConnection(this.databaseInfo).then((function(r){return a.__awaiter(n,void 0,void 0,(function(){var n,i,o,s,u,c,h=this;return a.__generator(this,(function(l){switch(l.label){case 0:return n=new mr,this.localStore=new _r(this.persistence,n,t),[4,this.localStore.start()];case 1:return l.sent(),e&&(this.lruScheduler=new Pn(e,this.asyncQueue,this.localStore)),i=this.platform.newConnectivityMonitor(),o=this.platform.newSerializer(this.databaseInfo.databaseId),s=new Fr(this.asyncQueue,r,this.credentials,o),u=function(t){return h.syncEngine.applyOnlineStateChange(t,xr.RemoteStore)},c=function(t){return h.syncEngine.applyOnlineStateChange(t,xr.SharedClientState)},this.remoteStore=new ai(this.localStore,s,this.asyncQueue,u,i),this.syncEngine=new xi(this.localStore,this.remoteStore,this.sharedClientState,t),this.sharedClientState.onlineStateHandler=c,this.remoteStore.syncEngine=this.syncEngine,this.sharedClientState.syncEngine=this.syncEngine,this.eventMgr=new Ti(this.syncEngine),[4,this.sharedClientState.start()];case 2:return l.sent(),[4,this.remoteStore.start()];case 3:return l.sent(),[4,this.persistence.setPrimaryStateListener((function(t){return a.__awaiter(h,void 0,void 0,(function(){return a.__generator(this,(function(e){switch(e.label){case 0:return[4,this.syncEngine.applyPrimaryState(t)];case 1:return e.sent(),this.lruScheduler&&(t&&!this.lruScheduler.started?this.lruScheduler.start():t||this.lruScheduler.stop()),[2]}}))}))}))];case 4:return l.sent(),[4,this.persistence.setDatabaseDeletedListener((function(){return a.__awaiter(h,void 0,void 0,(function(){return a.__generator(this,(function(t){switch(t.label){case 0:return[4,this.terminate()];case 1:return t.sent(),[2]}}))}))}))];case 5:return l.sent(),[2]}}))}))}))},t.prototype.handleCredentialChange=function(t){return this.asyncQueue.verifyOperationInProgress(),m("FirestoreClient","Credential Changed. Current user: "+t.uid),this.syncEngine.handleCredentialChange(t)},t.prototype.disableNetwork=function(){var t=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue((function(){return t.syncEngine.disableNetwork()}))},t.prototype.terminate=function(){var t=this;return this.asyncQueue.enqueueAndInitiateShutdown((function(){return a.__awaiter(t,void 0,void 0,(function(){return a.__generator(this,(function(t){switch(t.label){case 0:return this.lruScheduler&&this.lruScheduler.stop(),[4,this.remoteStore.shutdown()];case 1:return t.sent(),[4,this.sharedClientState.shutdown()];case 2:return t.sent(),[4,this.persistence.shutdown()];case 3:return t.sent(),this.credentials.removeChangeListener(),[2]}}))}))}))},t.prototype.waitForPendingWrites=function(){var t=this;this.verifyNotTerminated();var e=new dt;return this.asyncQueue.enqueueAndForget((function(){return t.syncEngine.registerPendingWritesCallback(e)})),e.promise},t.prototype.listen=function(t,e,n){var r=this;this.verifyNotTerminated();var i=new Ci(t,e,n);return this.asyncQueue.enqueueAndForget((function(){return r.eventMgr.listen(i)})),i},t.prototype.unlisten=function(t){var e=this;this.clientTerminated||this.asyncQueue.enqueueAndForget((function(){return e.eventMgr.unlisten(t)}))},t.prototype.getDocumentFromLocalCache=function(t){var e=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue((function(){return e.localStore.readDocument(t)})).then((function(t){if(t instanceof Qe)return t;if(t instanceof Ke)return null;throw new T(E.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)")}))},t.prototype.getDocumentsFromLocalCache=function(t){var e=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue((function(){return a.__awaiter(e,void 0,void 0,(function(){var e,n,r;return a.__generator(this,(function(i){switch(i.label){case 0:return[4,this.localStore.executeQuery(t,!0)];case 1:return e=i.sent(),n=new Ni(t,e.remoteKeys),r=n.computeDocChanges(e.documents),[2,n.applyChanges(r,!1).snapshot]}}))}))}))},t.prototype.write=function(t){var e=this;this.verifyNotTerminated();var n=new dt;return this.asyncQueue.enqueueAndForget((function(){return e.syncEngine.write(t,n)})),n.promise},t.prototype.databaseId=function(){return this.databaseInfo.databaseId},t.prototype.addSnapshotsInSyncListener=function(t){var e=this;this.verifyNotTerminated(),this.asyncQueue.enqueueAndForget((function(){return e.eventMgr.addSnapshotsInSyncListener(t),Promise.resolve()}))},t.prototype.removeSnapshotsInSyncListener=function(t){this.clientTerminated||this.eventMgr.removeSnapshotsInSyncListener(t)},Object.defineProperty(t.prototype,"clientTerminated",{get:function(){return this.asyncQueue.isShuttingDown},enumerable:!0,configurable:!0}),t.prototype.transaction=function(t){var e=this;this.verifyNotTerminated();var n=new dt;return this.asyncQueue.enqueueAndForget((function(){return e.syncEngine.runTransaction(e.asyncQueue,t,n),Promise.resolve()})),n.promise},t}(),to=function(){function t(t){this.observer=t,this.muted=!1}return t.prototype.next=function(t){this.scheduleEvent(this.observer.next,t)},t.prototype.error=function(t){this.scheduleEvent(this.observer.error,t)},t.prototype.mute=function(){this.muted=!0},t.prototype.scheduleEvent=function(t,e){var n=this;this.muted||setTimeout((function(){n.muted||t(e)}),0)},t}(),eo=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];!function(t,e,n,r){if(!(e instanceof Array)||e.length<r)throw new T(E.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" argument to be an array with at least "+Y(r,"element")+".")}("FieldPath",t,"fieldNames",1);for(var n=0;n<t.length;++n)if(P("FieldPath","string",n,t[n]),0===t[n].length)throw new T(E.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ft(t)}return t.documentId=function(){return t._DOCUMENT_ID},t.prototype.isEqual=function(e){if(!(e instanceof t))throw K("isEqual","FieldPath",1,e);return this._internalPath.isEqual(e._internalPath)},t._DOCUMENT_ID=new t(ft.keyField().canonicalString()),t}(),no=new RegExp("[~\\*/\\[\\]]");var ro=function(t,e){this.user=e,this.type="OAuth",this.authHeaders={},this.authHeaders.Authorization="Bearer "+t},io=function(){function t(){this.changeListener=null}return t.prototype.getToken=function(){return Promise.resolve(null)},t.prototype.invalidateToken=function(){},t.prototype.setChangeListener=function(t){_(!this.changeListener,"Can only call setChangeListener() once."),this.changeListener=t,t(Pi.UNAUTHENTICATED)},t.prototype.removeChangeListener=function(){_(null!==this.changeListener,"removeChangeListener() when no listener registered"),this.changeListener=null},t}(),oo=function(){function t(t){var e=this;this.tokenListener=null,this.currentUser=Pi.UNAUTHENTICATED,this.receivedInitialUser=!1,this.tokenCounter=0,this.changeListener=null,this.forceRefresh=!1,this.tokenListener=function(){e.tokenCounter++,e.currentUser=e.getUser(),e.receivedInitialUser=!0,e.changeListener&&e.changeListener(e.currentUser)},this.tokenCounter=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.tokenListener):(this.tokenListener(null),t.get().then((function(t){e.auth=t,e.tokenListener&&e.auth.addAuthTokenListener(e.tokenListener)}),(function(){})))}return t.prototype.getToken=function(){var t=this;_(null!=this.tokenListener,"getToken cannot be called after listener removed.");var e=this.tokenCounter,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then((function(n){if(t.tokenCounter!==e)throw new T(E.ABORTED,"getToken aborted due to token change.");return n?(_("string"==typeof n.accessToken,"Invalid tokenData returned from getToken():"+n),new ro(n.accessToken,t.currentUser)):null})):Promise.resolve(null)},t.prototype.invalidateToken=function(){this.forceRefresh=!0},t.prototype.setChangeListener=function(t){_(!this.changeListener,"Can only call setChangeListener() once."),this.changeListener=t,this.receivedInitialUser&&t(this.currentUser)},t.prototype.removeChangeListener=function(){_(null!=this.tokenListener,"removeChangeListener() called twice"),_(null!==this.changeListener,"removeChangeListener() called when no listener registered"),this.auth&&this.auth.removeAuthTokenListener(this.tokenListener),this.tokenListener=null,this.changeListener=null},t.prototype.getUser=function(){var t=this.auth&&this.auth.getUid();return _(null===t||"string"==typeof t,"Received invalid UID: "+t),new Pi(t)},t}(),ao=function(){function t(t,e){this.gapi=t,this.sessionIndex=e,this.type="FirstParty",this.user=Pi.FIRST_PARTY}return Object.defineProperty(t.prototype,"authHeaders",{get:function(){var t={"X-Goog-AuthUser":this.sessionIndex},e=this.gapi.auth.getAuthHeaderValueForFirstParty([]);return e&&(t.Authorization=e),t},enumerable:!0,configurable:!0}),t}(),so=function(){function t(t,e){this.gapi=t,this.sessionIndex=e}return t.prototype.getToken=function(){return Promise.resolve(new ao(this.gapi,this.sessionIndex))},t.prototype.setChangeListener=function(t){t(Pi.FIRST_PARTY)},t.prototype.removeChangeListener=function(){},t.prototype.invalidateToken=function(){},t}();function uo(t){if(!t)return new io;switch(t.type){case"gapi":var e=t.client;return _(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty),"unexpected gapi interface"),new so(e,t.sessionIndex||"0");case"provider":return t.client;default:throw new T(E.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}function co(t){return function(t,e){if("object"!=typeof t||null===t)return!1;for(var n=t,r=0,i=e;r<i.length;r++){var o=i[r];if(o in n&&"function"==typeof n[o])return!0}return!1}(t,["next","error","complete"])}var ho,lo=function(){function t(t){this._methodName=t}return t.delete=function(){return k("FieldValue.delete",arguments),fo.instance},t.serverTimestamp=function(){return k("FieldValue.serverTimestamp",arguments),po.instance},t.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return O("FieldValue.arrayUnion",arguments,1),new mo(t)},t.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return O("FieldValue.arrayRemove",arguments,1),new yo(t)},t.increment=function(t){return P("FieldValue.increment","number",1,t),R("FieldValue.increment",arguments,1),new go(t)},t.prototype.isEqual=function(t){return this===t},t}(),fo=function(t){function e(){return t.call(this,"FieldValue.delete")||this}return a.__extends(e,t),e.instance=new e,e}(lo),po=function(t){function e(){return t.call(this,"FieldValue.serverTimestamp")||this}return a.__extends(e,t),e.instance=new e,e}(lo),mo=function(t){function e(e){var n=t.call(this,"FieldValue.arrayUnion")||this;return n._elements=e,n}return a.__extends(e,t),e}(lo),yo=function(t){function e(e){var n=t.call(this,"FieldValue.arrayRemove")||this;return n._elements=e,n}return a.__extends(e,t),e}(lo),go=function(t){function e(e){var n=t.call(this,"FieldValue.increment")||this;return n._operand=e,n}return a.__extends(e,t),e}(lo),vo=C(lo,"Use FieldValue.<field>() instead."),_o=/^__.*__$/,bo=function(){function t(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}return t.prototype.toMutations=function(t,e){var n=[];return null!==this.fieldMask?n.push(new Se(t,this.data,this.fieldMask,e)):n.push(new Ce(t,this.data,e)),this.fieldTransforms.length>0&&n.push(new Ie(t,this.fieldTransforms)),n},t}(),wo=function(){function t(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}return t.prototype.toMutations=function(t,e){var n=[new Se(t,this.data,this.fieldMask,e)];return this.fieldTransforms.length>0&&n.push(new Ie(t,this.fieldTransforms)),n},t}();function Eo(t){switch(t){case ho.Set:case ho.MergeSet:case ho.Update:return!0;case ho.Argument:case ho.ArrayArgument:return!1;default:throw v("Unexpected case for UserDataSource: "+t)}}!function(t){t[t.Set=0]="Set",t[t.Update=1]="Update",t[t.MergeSet=2]="MergeSet",t[t.Argument=3]="Argument",t[t.ArrayArgument=4]="ArrayArgument"}(ho||(ho={}));var To=function(){function t(t,e,n,r,i,o){this.dataSource=t,this.methodName=e,this.path=n,this.arrayElement=r,void 0===i&&this.validatePath(),this.arrayElement=void 0!==r&&r,this.fieldTransforms=i||[],this.fieldMask=o||[]}return t.prototype.childContextForField=function(e){var n=null==this.path?null:this.path.child(e),r=new t(this.dataSource,this.methodName,n,!1,this.fieldTransforms,this.fieldMask);return r.validatePathSegment(e),r},t.prototype.childContextForFieldPath=function(e){var n=null==this.path?null:this.path.child(e),r=new t(this.dataSource,this.methodName,n,!1,this.fieldTransforms,this.fieldMask);return r.validatePath(),r},t.prototype.childContextForArray=function(e){return new t(this.dataSource,this.methodName,null,!0,this.fieldTransforms,this.fieldMask)},t.prototype.createError=function(t){var e=null===this.path||this.path.isEmpty()?"":" (found in field "+this.path.toString()+")";return new T(E.INVALID_ARGUMENT,"Function "+this.methodName+"() called with invalid data. "+t+e)},t.prototype.contains=function(t){return void 0!==this.fieldMask.find((function(e){return t.isPrefixOf(e)}))||void 0!==this.fieldTransforms.find((function(e){return t.isPrefixOf(e.field)}))},t.prototype.validatePath=function(){if(null!==this.path)for(var t=0;t<this.path.length;t++)this.validatePathSegment(this.path.get(t))},t.prototype.validatePathSegment=function(t){if(0===t.length)throw this.createError("Document fields must not be empty");if(Eo(this.dataSource)&&_o.test(t))throw this.createError('Document fields cannot begin and end with "__"')},t}(),Co=function(t,e){this.databaseId=t,this.key=e},So=function(){function t(t){this.preConverter=t}return t.prototype.parseSetData=function(t,e){var n=new To(ho.Set,t,ft.EMPTY_PATH);Do("Data must be an object, but it was:",n,e);var r=this.parseData(e,n);return new bo(r,null,n.fieldTransforms)},t.prototype.parseMergeData=function(t,e,n){var r=new To(ho.MergeSet,t,ft.EMPTY_PATH);Do("Data must be an object, but it was:",r,e);var i,o,a=this.parseData(e,r);if(n){for(var s=new Rt(ft.comparator),u=0,c=n;u<c.length;u++){var h=c[u],l=void 0;if(h instanceof eo)l=h._internalPath;else{if("string"!=typeof h)throw v("Expected stringOrFieldPath to be a string or a FieldPath");l=Ao(t,h)}if(!r.contains(l))throw new T(E.INVALID_ARGUMENT,"Field '"+l+"' is specified in your field mask but missing from your input data.");s=s.add(l)}i=ge.fromSet(s),o=r.fieldTransforms.filter((function(t){return i.covers(t.field)}))}else i=ge.fromArray(r.fieldMask),o=r.fieldTransforms;return new bo(a,i,o)},t.prototype.parseUpdateData=function(t,e){var n=this,r=new To(ho.Update,t,ft.EMPTY_PATH);Do("Data must be an object, but it was:",r,e);var i=new Rt(ft.comparator),o=je.EMPTY;N(e,(function(e,a){var s=Ao(t,e),u=r.childContextForFieldPath(s);if((a=n.runPreConverter(a,u))instanceof fo)i=i.add(s);else{var c=n.parseData(a,u);null!=c&&(i=i.add(s),o=o.set(s,c))}}));var a=ge.fromSet(i);return new wo(o,a,r.fieldTransforms)},t.prototype.parseUpdateVarargs=function(t,e,n,r){var i=new To(ho.Update,t,ft.EMPTY_PATH),o=[No(t,e)],a=[n];if(r.length%2!=0)throw new T(E.INVALID_ARGUMENT,"Function "+t+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var s=0;s<r.length;s+=2)o.push(No(t,r[s])),a.push(r[s+1]);var u=new Rt(ft.comparator),c=je.EMPTY;for(s=0;s<o.length;++s){var h=o[s],l=i.childContextForFieldPath(h),f=this.runPreConverter(a[s],l);if(f instanceof fo)u=u.add(h);else{var p=this.parseData(f,l);null!=p&&(u=u.add(h),c=c.set(h,p))}}var d=ge.fromSet(u);return new wo(c,d,i.fieldTransforms)},t.prototype.parseQueryValue=function(t,e,n){void 0===n&&(n=!1);var r=new To(n?ho.ArrayArgument:ho.Argument,t,ft.EMPTY_PATH),i=this.parseData(e,r);return _(null!=i,"Parsed data should not be null."),_(0===r.fieldTransforms.length,"Field transforms should have been disallowed."),i},t.prototype.runPreConverter=function(t,e){try{return this.preConverter(t)}catch(r){var n=ko(r);throw e.createError(n)}},t.prototype.parseData=function(t,e){if(Io(t=this.runPreConverter(t,e)))return Do("Unsupported field value:",e,t),this.parseObject(t,e);if(t instanceof lo)return this.parseSentinelFieldValue(t,e),null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.arrayElement&&e.dataSource!==ho.ArrayArgument)throw e.createError("Nested arrays are not supported");return this.parseArray(t,e)}return this.parseScalarValue(t,e)},t.prototype.parseObject=function(t,e){var n=this,r=new Dt(J);return A(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):N(t,(function(t,i){var o=n.parseData(i,e.childContextForField(t));null!=o&&(r=r.insert(t,o))})),new je(r)},t.prototype.parseArray=function(t,e){for(var n=[],r=0,i=0,o=t;i<o.length;i++){var a=o[i],s=this.parseData(a,e.childContextForArray(r));null==s&&(s=ke.INSTANCE),n.push(s),r++}return new ze(n)},t.prototype.parseSentinelFieldValue=function(t,e){if(!Eo(e.dataSource))throw e.createError(t._methodName+"() can only be used with update() and set()");if(null===e.path)throw e.createError(t._methodName+"() is not currently supported inside arrays");if(t instanceof fo){if(e.dataSource!==ho.MergeSet)throw e.dataSource===ho.Update?(_(e.path.length>0,"FieldValue.delete() at the top level should have already been handled."),e.createError("FieldValue.delete() can only appear at the top level of your update data")):e.createError("FieldValue.delete() cannot be used with set() unless you pass {merge:true}");e.fieldMask.push(e.path)}else if(t instanceof po)e.fieldTransforms.push(new ve(e.path,ui.instance));else if(t instanceof mo){var n=this.parseArrayTransformElements(t._methodName,t._elements),r=new ci(n);e.fieldTransforms.push(new ve(e.path,r))}else if(t instanceof yo){n=this.parseArrayTransformElements(t._methodName,t._elements);var i=new hi(n);e.fieldTransforms.push(new ve(e.path,i))}else if(t instanceof go){var o=this.parseQueryValue("FieldValue.increment",t._operand),a=new li(o);e.fieldTransforms.push(new ve(e.path,a))}else v("Unknown FieldValue type: "+t)},t.prototype.parseScalarValue=function(t,e){if(null===t)return ke.INSTANCE;if("number"==typeof t)return Zn(t)?new Pe(t):new Me(t);if("boolean"==typeof t)return Re.of(t);if("string"==typeof t)return new Le(t);if(t instanceof Date)return new Fe(St.fromDate(t));if(t instanceof St)return new Fe(new St(t.seconds,1e3*Math.floor(t.nanoseconds/1e3)));if(t instanceof si)return new Be(t);if(t instanceof rt)return new qe(t);if(t instanceof Co)return new Ve(t.databaseId,t.key);throw e.createError("Unsupported field value: "+z(t))},t.prototype.parseArrayTransformElements=function(t,e){var n=this;return e.map((function(e,r){var i=new To(ho.Argument,t,ft.EMPTY_PATH);return n.parseData(e,i.childContextForArray(r))}))},t}();function Io(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof St||t instanceof si||t instanceof rt||t instanceof Co||t instanceof lo)}function Do(t,e,n){if(!Io(n)||!j(n)){var r=z(n);throw"an object"===r?e.createError(t+" a custom object"):e.createError(t+" "+r)}}function No(t,e){if(e instanceof eo)return e._internalPath;if("string"==typeof e)return Ao(t,e);throw new T(E.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. Field path arguments must be of type string or FieldPath.")}function Ao(t,e){try{return function(t){if(t.search(no)>=0)throw new T(E.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new(eo.bind.apply(eo,a.__spreadArrays([void 0],t.split("."))))}catch(e){throw new T(E.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'")}}(e)._internalPath}catch(r){var n=ko(r);throw new T(E.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. "+n)}}function ko(t){return t instanceof Error?t.message:t.toString()}var Ro="firestore.googleapis.com",Oo=!0,xo=!0,Po=!1,Mo=xn.COLLECTION_DISABLED,Lo=function(){function t(t){if(void 0===t.host){if(void 0!==t.ssl)throw new T(E.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=Ro,this.ssl=Oo}else L("settings","non-empty string","host",t.host),this.host=t.host,F("settings","boolean","ssl",t.ssl),this.ssl=I(t.ssl,Oo);if(Q("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling"]),F("settings","object","credentials",t.credentials),this.credentials=t.credentials,F("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),!0===t.timestampsInSnapshots?y("\n The timestampsInSnapshots setting now defaults to true and you no\n longer need to explicitly set it. In a future release, the setting\n will be removed entirely and so it is recommended that you remove it\n from your firestore.settings() call now."):!1===t.timestampsInSnapshots&&y("\n The timestampsInSnapshots setting will soon be removed. YOU MUST UPDATE\n YOUR CODE.\n\n To hide this warning, stop using the timestampsInSnapshots setting in your\n firestore.settings({ ... }) call.\n\n Once you remove the setting, Timestamps stored in Cloud Firestore will be\n read back as Firebase Timestamp objects instead of as system Date objects.\n So you will also need to update code expecting a Date to instead expect a\n Timestamp. For example:\n\n // Old:\n const date = snapshot.get('created_at');\n // New:\n const timestamp = snapshot.get('created_at'); const date =\n timestamp.toDate();\n\n Please audit all existing usages of Date when you enable the new\n behavior."),this.timestampsInSnapshots=I(t.timestampsInSnapshots,xo),F("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=xn.DEFAULT_CACHE_SIZE_BYTES;else{if(t.cacheSizeBytes!==Mo&&t.cacheSizeBytes<xn.MINIMUM_CACHE_SIZE_BYTES)throw new T(E.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+xn.MINIMUM_CACHE_SIZE_BYTES);this.cacheSizeBytes=t.cacheSizeBytes}F("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.forceLongPolling=void 0===t.experimentalForceLongPolling?Po:t.experimentalForceLongPolling}return t.prototype.isEqual=function(t){return this.host===t.host&&this.ssl===t.ssl&&this.timestampsInSnapshots===t.timestampsInSnapshots&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.forceLongPolling===t.forceLongPolling},t}(),Fo=function(){function t(e,n){var r=this;if(this._firebaseApp=null,this._queue=new yt,this.INTERNAL={delete:function(){return a.__awaiter(r,void 0,void 0,(function(){return a.__generator(this,(function(t){switch(t.label){case 0:return this.ensureClientConfigured(),[4,this._firestoreClient.terminate()];case 1:return t.sent(),[2]}}))}))}},"object"==typeof e.options){var i=e;this._firebaseApp=i,this._databaseId=t.databaseIdFromApp(i),this._persistenceKey=i.name,this._credentials=new oo(n)}else{var o=e;if(!o.projectId)throw new T(E.INVALID_ARGUMENT,"Must provide projectId");this._databaseId=new st(o.projectId,o.database),this._persistenceKey="[DEFAULT]",this._credentials=new io}this._settings=new Lo({}),this._dataConverter=this.createDataConverter(this._databaseId)}return t.prototype.settings=function(t){if(R("Firestore.settings",arguments,1),P("Firestore.settings","object",1,t),S(t,"persistence"))throw new T(E.INVALID_ARGUMENT,'"persistence" is now specified with a separate call to firestore.enablePersistence().');var e=new Lo(t);if(this._firestoreClient&&!this._settings.isEqual(e))throw new T(E.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only call settings() before calling any other methods on a Firestore object.");this._settings=e,void 0!==e.credentials&&(this._credentials=uo(e.credentials))},t.prototype.enableNetwork=function(){return this.ensureClientConfigured(),this._firestoreClient.enableNetwork()},t.prototype.disableNetwork=function(){return this.ensureClientConfigured(),this._firestoreClient.disableNetwork()},t.prototype.enablePersistence=function(t){if(this._firestoreClient)throw new T(E.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only call enablePersistence() before calling any other methods on a Firestore object.");var e=!1;return t&&(void 0!==t.experimentalTabSynchronization&&y("The 'experimentalTabSynchronization' setting has been renamed to 'synchronizeTabs'. In a future release, the setting will be removed and it is recommended that you update your firestore.enablePersistence() call to use 'synchronizeTabs'."),e=I(void 0!==t.synchronizeTabs?t.synchronizeTabs:t.experimentalTabSynchronization,!1)),this.configureClient(new Ji(this._settings.cacheSizeBytes,e))},t.prototype.clearPersistence=function(){var t=this,e=Bn.buildStoragePrefix(this.makeDatabaseInfo()),n=new dt;return this._queue.enqueueAndForgetEvenAfterShutdown((function(){return a.__awaiter(t,void 0,void 0,(function(){var t;return a.__generator(this,(function(r){switch(r.label){case 0:if(r.trys.push([0,2,,3]),void 0!==this._firestoreClient&&!this._firestoreClient.clientTerminated)throw new T(E.FAILED_PRECONDITION,"Persistence cannot be cleared after this Firestore instance is initialized.");return[4,Bn.clearPersistence(e)];case 1:return r.sent(),n.resolve(),[3,3];case 2:return t=r.sent(),n.reject(t),[3,3];case 3:return[2]}}))}))})),n.promise},t.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(t.prototype,"_isTerminated",{get:function(){return this.ensureClientConfigured(),this._firestoreClient.clientTerminated},enumerable:!0,configurable:!0}),t.prototype.waitForPendingWrites=function(){return this.ensureClientConfigured(),this._firestoreClient.waitForPendingWrites()},t.prototype.onSnapshotsInSync=function(t){if(this.ensureClientConfigured(),co(t))return this.onSnapshotsInSyncInternal(t);P("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.onSnapshotsInSyncInternal(e)},t.prototype.onSnapshotsInSyncInternal=function(t){var e=this,n=new to({next:function(){t.next&&t.next()},error:function(t){throw v("Uncaught Error in onSnapshotsInSync")}});return this._firestoreClient.addSnapshotsInSyncListener(n),function(){n.mute(),e._firestoreClient.removeSnapshotsInSyncListener(n)}},t.prototype.ensureClientConfigured=function(){return this._firestoreClient||this.configureClient(new Zi),this._firestoreClient},t.prototype.makeDatabaseInfo=function(){return new ot(this._databaseId,this._persistenceKey,this._settings.host,this._settings.ssl,this._settings.forceLongPolling)},t.prototype.configureClient=function(t){_(!!this._settings.host,"FirestoreSettings.host is not set"),_(!this._firestoreClient,"configureClient() called multiple times");var e=this.makeDatabaseInfo();return this._firestoreClient=new $i(b.getPlatform(),e,this._credentials,this._queue),this._firestoreClient.start(t)},t.prototype.createDataConverter=function(t){return new So((function(e){if(e instanceof Vo){var n=t,r=e.firestore._databaseId;if(!r.isEqual(n))throw new T(E.INVALID_ARGUMENT,"Document reference is for database "+r.projectId+"/"+r.database+" but should be for database "+n.projectId+"/"+n.database);return new Co(t,e._key)}return e}))},t.databaseIdFromApp=function(t){var e=t.options;if(!S(e,"projectId"))throw new T(E.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');var n=e.projectId;if(!n||"string"!=typeof n)throw new T(E.INVALID_ARGUMENT,"projectId must be a string in FirebaseApp.options");return new st(n)},Object.defineProperty(t.prototype,"app",{get:function(){if(!this._firebaseApp)throw new T(E.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._firebaseApp},enumerable:!0,configurable:!0}),t.prototype.collection=function(t){return R("Firestore.collection",arguments,1),P("Firestore.collection","non-empty string",1,t),this.ensureClientConfigured(),new Ko(ht.fromString(t),this)},t.prototype.doc=function(t){return R("Firestore.doc",arguments,1),P("Firestore.doc","non-empty string",1,t),this.ensureClientConfigured(),Vo.forPath(ht.fromString(t),this)},t.prototype.collectionGroup=function(t){if(R("Firestore.collectionGroup",arguments,1),P("Firestore.collectionGroup","non-empty string",1,t),t.indexOf("/")>=0)throw new T(E.INVALID_ARGUMENT,"Invalid collection ID '"+t+"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.");return this.ensureClientConfigured(),new Wo(new er(ht.EMPTY_PATH,t),this)},t.prototype.runTransaction=function(t){var e=this;return R("Firestore.runTransaction",arguments,1),P("Firestore.runTransaction","function",1,t),this.ensureClientConfigured().transaction((function(n){return t(new Uo(e,n))}))},t.prototype.batch=function(){return this.ensureClientConfigured(),new qo(this)},Object.defineProperty(t,"logLevel",{get:function(){switch(p()){case i.DEBUG:return"debug";case i.ERROR:return"error";case i.SILENT:return"silent";default:return v("Unknown log level: "+p())}},enumerable:!0,configurable:!0}),t.setLogLevel=function(t){switch(R("Firestore.setLogLevel",arguments,1),P("Firestore.setLogLevel","non-empty string",1,t),t){case"debug":d(i.DEBUG);break;case"error":d(i.ERROR);break;case"silent":d(i.SILENT);break;default:throw new T(E.INVALID_ARGUMENT,"Invalid log level: "+t)}},t.prototype._areTimestampsInSnapshotsEnabled=function(){return this._settings.timestampsInSnapshots},t}(),Uo=function(){function t(t,e){this._firestore=t,this._transaction=e}return t.prototype.get=function(t){var e=this;R("Transaction.get",arguments,1);var n=Xo("Transaction.get",t,this._firestore);return this._transaction.lookup([n._key]).then((function(t){if(!t||1!==t.length)return v("Mismatch in docs returned from document lookup.");var r=t[0];if(r instanceof Ke)return new jo(e._firestore,n._key,null,!1,!1,n._converter);if(r instanceof Qe)return new jo(e._firestore,n._key,r,!1,!1,n._converter);throw v("BatchGetDocumentsRequest returned unexpected document type: "+r.constructor.name)}))},t.prototype.set=function(t,e,n){x("Transaction.set",arguments,2,3);var r=Xo("Transaction.set",t,this._firestore);n=Ho("Transaction.set",n);var i=Zo(r._converter,e,"Transaction.set"),o=i[0],a=i[1],s=n.merge||n.mergeFields?this._firestore._dataConverter.parseMergeData(a,o,n.mergeFields):this._firestore._dataConverter.parseSetData(a,o);return this._transaction.set(r._key,s),this},t.prototype.update=function(t,e,n){for(var r,i,o=[],a=3;a<arguments.length;a++)o[a-3]=arguments[a];return"string"==typeof e||e instanceof eo?(O("Transaction.update",arguments,3),r=Xo("Transaction.update",t,this._firestore),i=this._firestore._dataConverter.parseUpdateVarargs("Transaction.update",e,n,o)):(R("Transaction.update",arguments,2),r=Xo("Transaction.update",t,this._firestore),i=this._firestore._dataConverter.parseUpdateData("Transaction.update",e)),this._transaction.update(r._key,i),this},t.prototype.delete=function(t){R("Transaction.delete",arguments,1);var e=Xo("Transaction.delete",t,this._firestore);return this._transaction.delete(e._key),this},t}(),qo=function(){function t(t){this._firestore=t,this._mutations=[],this._committed=!1}return t.prototype.set=function(t,e,n){x("WriteBatch.set",arguments,2,3),this.verifyNotCommitted();var r=Xo("WriteBatch.set",t,this._firestore);n=Ho("WriteBatch.set",n);var i=Zo(r._converter,e,"WriteBatch.set"),o=i[0],a=i[1],s=n.merge||n.mergeFields?this._firestore._dataConverter.parseMergeData(a,o,n.mergeFields):this._firestore._dataConverter.parseSetData(a,o);return this._mutations=this._mutations.concat(s.toMutations(r._key,Ee.NONE)),this},t.prototype.update=function(t,e,n){for(var r,i,o=[],a=3;a<arguments.length;a++)o[a-3]=arguments[a];return this.verifyNotCommitted(),"string"==typeof e||e instanceof eo?(O("WriteBatch.update",arguments,3),r=Xo("WriteBatch.update",t,this._firestore),i=this._firestore._dataConverter.parseUpdateVarargs("WriteBatch.update",e,n,o)):(R("WriteBatch.update",arguments,2),r=Xo("WriteBatch.update",t,this._firestore),i=this._firestore._dataConverter.parseUpdateData("WriteBatch.update",e)),this._mutations=this._mutations.concat(i.toMutations(r._key,Ee.exists(!0))),this},t.prototype.delete=function(t){R("WriteBatch.delete",arguments,1),this.verifyNotCommitted();var e=Xo("WriteBatch.delete",t,this._firestore);return this._mutations=this._mutations.concat(new De(e._key,Ee.NONE)),this},t.prototype.commit=function(){return a.__awaiter(this,void 0,void 0,(function(){return a.__generator(this,(function(t){return this.verifyNotCommitted(),this._committed=!0,this._mutations.length>0?[2,this._firestore.ensureClientConfigured().write(this._mutations)]:[2]}))}))},t.prototype.verifyNotCommitted=function(){if(this._committed)throw new T(E.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},t}(),Vo=function(){function t(t,e,n){this._key=t,this.firestore=e,this._converter=n,this._firestoreClient=this.firestore.ensureClientConfigured()}return t.forPath=function(e,n,r){if(e.length%2!=0)throw new T(E.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+e.canonicalString()+" has "+e.length);return new t(new pt(e),n,r)},Object.defineProperty(t.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return new Ko(this._key.path.popLast(),this.firestore,this._converter)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this._key.path.canonicalString()},enumerable:!0,configurable:!0}),t.prototype.collection=function(t){if(R("DocumentReference.collection",arguments,1),P("DocumentReference.collection","non-empty string",1,t),!t)throw new T(E.INVALID_ARGUMENT,"Must provide a non-empty collection name to collection()");var e=ht.fromString(t);return new Ko(this._key.path.child(e),this.firestore)},t.prototype.isEqual=function(e){if(!(e instanceof t))throw K("isEqual","DocumentReference",1,e);return this.firestore===e.firestore&&this._key.isEqual(e._key)&&this._converter===e._converter},t.prototype.set=function(t,e){x("DocumentReference.set",arguments,1,2),e=Ho("DocumentReference.set",e);var n=Zo(this._converter,t,"DocumentReference.set"),r=n[0],i=n[1],o=e.merge||e.mergeFields?this.firestore._dataConverter.parseMergeData(i,r,e.mergeFields):this.firestore._dataConverter.parseSetData(i,r);return this._firestoreClient.write(o.toMutations(this._key,Ee.NONE))},t.prototype.update=function(t,e){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return"string"==typeof t||t instanceof eo?(O("DocumentReference.update",arguments,2),n=this.firestore._dataConverter.parseUpdateVarargs("DocumentReference.update",t,e,r)):(R("DocumentReference.update",arguments,1),n=this.firestore._dataConverter.parseUpdateData("DocumentReference.update",t)),this._firestoreClient.write(n.toMutations(this._key,Ee.exists(!0)))},t.prototype.delete=function(){return R("DocumentReference.delete",arguments,0),this._firestoreClient.write([new De(this._key,Ee.NONE)])},t.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];x("DocumentReference.onSnapshot",arguments,1,4);var n,r={includeMetadataChanges:!1},i=0;"object"!=typeof t[i]||co(t[i])||(Q("DocumentReference.onSnapshot",r=t[i],["includeMetadataChanges"]),F("DocumentReference.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++);var o={includeMetadataChanges:r.includeMetadataChanges};return co(t[i])?n=t[i]:(P("DocumentReference.onSnapshot","function",i,t[i]),M("DocumentReference.onSnapshot","function",i+1,t[i+1]),M("DocumentReference.onSnapshot","function",i+2,t[i+2]),n={next:t[i],error:t[i+1],complete:t[i+2]}),this.onSnapshotInternal(o,n)},t.prototype.onSnapshotInternal=function(t,e){var n=this,r=function(t){console.error("Uncaught Error in onSnapshot:",t)};e.error&&(r=e.error.bind(e));var i=new to({next:function(t){if(e.next){_(t.docs.size<=1,"Too many documents returned on a document query");var r=t.docs.get(n._key);e.next(new jo(n.firestore,n._key,r,t.fromCache,t.hasPendingWrites,n._converter))}},error:r}),o=this._firestoreClient.listen(er.atPath(this._key.path),i,t);return function(){i.mute(),n._firestoreClient.unlisten(o)}},t.prototype.get=function(t){var e=this;return x("DocumentReference.get",arguments,0,1),Yo("DocumentReference.get",t),new Promise((function(n,r){t&&"cache"===t.source?e.firestore.ensureClientConfigured().getDocumentFromLocalCache(e._key).then((function(t){n(new jo(e.firestore,e._key,t,!0,t instanceof Qe&&t.hasLocalMutations,e._converter))}),r):e.getViaSnapshotListener(n,r,t)}))},t.prototype.getViaSnapshotListener=function(t,e,n){var r=this.onSnapshotInternal({includeMetadataChanges:!0,waitForSyncWhenOnline:!0},{next:function(i){r(),!i.exists&&i.metadata.fromCache?e(new T(E.UNAVAILABLE,"Failed to get document because the client is offline.")):i.exists&&i.metadata.fromCache&&n&&"server"===n.source?e(new T(E.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):t(i)},error:e})},t.prototype.withConverter=function(e){return new t(this._key,this.firestore,e)},t}(),Bo=function(){function t(t,e){this.hasPendingWrites=t,this.fromCache=e}return t.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},t}(),jo=function(){function t(t,e,n,r,i,o){this._firestore=t,this._key=e,this._document=n,this._fromCache=r,this._hasPendingWrites=i,this._converter=o}return t.prototype.data=function(t){if(x("DocumentSnapshot.data",arguments,0,1),t=Go("DocumentSnapshot.data",t),this._document){if(this._converter){var e=new zo(this._firestore,this._key,this._document,this._fromCache,this._hasPendingWrites);return this._converter.fromFirestore(e,t)}return this.toJSObject(this._document.data(),Ne.fromSnapshotOptions(t,this._firestore._areTimestampsInSnapshotsEnabled()))}},t.prototype.get=function(t,e){if(x("DocumentSnapshot.get",arguments,1,2),e=Go("DocumentSnapshot.get",e),this._document){var n=this._document.data().field(No("DocumentSnapshot.get",t));if(null!==n)return this.toJSValue(n,Ne.fromSnapshotOptions(e,this._firestore._areTimestampsInSnapshotsEnabled()))}},Object.defineProperty(t.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ref",{get:function(){return new Vo(this._key,this._firestore,this._converter)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"exists",{get:function(){return null!==this._document},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"metadata",{get:function(){return new Bo(this._hasPendingWrites,this._fromCache)},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(e){if(!(e instanceof t))throw K("isEqual","DocumentSnapshot",1,e);return this._firestore===e._firestore&&this._fromCache===e._fromCache&&this._key.isEqual(e._key)&&(null===this._document?null===e._document:this._document.isEqual(e._document))&&this._converter===e._converter},t.prototype.toJSObject=function(t,e){var n=this,r={};return t.forEach((function(t,i){r[t]=n.toJSValue(i,e)})),r},t.prototype.toJSValue=function(t,e){if(t instanceof je)return this.toJSObject(t,e);if(t instanceof ze)return this.toJSArray(t,e);if(t instanceof Ve){var n=t.value(e),r=this._firestore.ensureClientConfigured().databaseId();return t.databaseId.isEqual(r)||y("Document "+this._key.path+" contains a document reference within a different database ("+t.databaseId.projectId+"/"+t.databaseId.database+") which is not supported. It will be treated as a reference in the current database ("+r.projectId+"/"+r.database+") instead."),new Vo(n,this._firestore,this._converter)}return t.value(e)},t.prototype.toJSArray=function(t,e){var n=this;return t.internalValue.map((function(t){return n.toJSValue(t,e)}))},t}(),zo=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a.__extends(e,t),e.prototype.data=function(e){var n=t.prototype.data.call(this,e);return _(void 0!==n,"Document in a QueryDocumentSnapshot should exist"),n},e}(jo),Wo=function(){function t(t,e,n){this._query=t,this.firestore=e,this._converter=n}return t.prototype.where=function(e,n,r){R("Query.where",arguments,3),W("Query.where",3,r);var i,o=["<","<=","==",">=",">","array-contains","in","array-contains-any"];V("Query.where",o,2,n);var a=No("Query.where",e),s=rr.fromString(n);if(a.isKeyField()){if(s===rr.ARRAY_CONTAINS||s===rr.ARRAY_CONTAINS_ANY)throw new T(E.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+s.toString()+"' queries on FieldPath.documentId().");if(s===rr.IN){this.validateDisjunctiveFilterElements(r,s);for(var u=[],c=0,h=r;c<h.length;c++){var l=h[c];u.push(this.parseDocumentIdValue(l))}i=new ze(u)}else i=this.parseDocumentIdValue(r)}else s!==rr.IN&&s!==rr.ARRAY_CONTAINS_ANY||this.validateDisjunctiveFilterElements(r,s),i=this.firestore._dataConverter.parseQueryValue("Query.where",r,s===rr.IN);var f=ir.create(a,s,i);return this.validateNewFilter(f),new t(this._query.addFilter(f),this.firestore,this._converter)},t.prototype.orderBy=function(e,n){var r;if(x("Query.orderBy",arguments,1,2),M("Query.orderBy","non-empty string",2,n),void 0===n||"asc"===n)r=hr.ASCENDING;else{if("desc"!==n)throw new T(E.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+n+"', expected 'asc' or 'desc'.");r=hr.DESCENDING}if(null!==this._query.startAt)throw new T(E.INVALID_ARGUMENT,"Invalid query. You must not call Query.startAt() or Query.startAfter() before calling Query.orderBy().");if(null!==this._query.endAt)throw new T(E.INVALID_ARGUMENT,"Invalid query. You must not call Query.endAt() or Query.endBefore() before calling Query.orderBy().");var i=No("Query.orderBy",e),o=new fr(i,r);return this.validateNewOrderBy(o),new t(this._query.addOrderBy(o),this.firestore,this._converter)},t.prototype.limit=function(e){return R("Query.limit",arguments,1),P("Query.limit","number",1,e),H("Query.limit",1,e),new t(this._query.withLimitToFirst(e),this.firestore,this._converter)},t.prototype.limitToLast=function(e){return R("Query.limitToLast",arguments,1),P("Query.limitToLast","number",1,e),H("Query.limitToLast",1,e),new t(this._query.withLimitToLast(e),this.firestore,this._converter)},t.prototype.startAt=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];O("Query.startAt",arguments,1);var i=this.boundFromDocOrFields("Query.startAt",e,n,!0);return new t(this._query.withStartAt(i),this.firestore,this._converter)},t.prototype.startAfter=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];O("Query.startAfter",arguments,1);var i=this.boundFromDocOrFields("Query.startAfter",e,n,!1);return new t(this._query.withStartAt(i),this.firestore,this._converter)},t.prototype.endBefore=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];O("Query.endBefore",arguments,1);var i=this.boundFromDocOrFields("Query.endBefore",e,n,!0);return new t(this._query.withEndAt(i),this.firestore,this._converter)},t.prototype.endAt=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];O("Query.endAt",arguments,1);var i=this.boundFromDocOrFields("Query.endAt",e,n,!1);return new t(this._query.withEndAt(i),this.firestore,this._converter)},t.prototype.isEqual=function(e){if(!(e instanceof t))throw K("isEqual","Query",1,e);return this.firestore===e.firestore&&this._query.isEqual(e._query)},t.prototype.withConverter=function(e){return new t(this._query,this.firestore,e)},t.prototype.boundFromDocOrFields=function(t,e,n,r){if(W(t,1,e),e instanceof jo){if(n.length>0)throw new T(E.INVALID_ARGUMENT,"Too many arguments provided to "+t+"().");var i=e;if(!i.exists)throw new T(E.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+t+"().");return this.boundFromDocument(t,i._document,r)}var o=[e].concat(n);return this.boundFromFields(t,o,r)},t.prototype.boundFromDocument=function(t,e,n){for(var r=[],i=0,o=this._query.orderBy;i<o.length;i++){var a=o[i];if(a.field.isKeyField())r.push(new Ve(this.firestore._databaseId,e.key));else{var s=e.field(a.field);if(s instanceof Ue)throw new T(E.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+a.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===s){var u=a.field.canonicalString();throw new T(E.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+u+"' (used as the orderBy) does not exist.")}r.push(s)}}return new lr(r,n)},t.prototype.boundFromFields=function(t,e,n){var r=this._query.explicitOrderBy;if(e.length>r.length)throw new T(E.INVALID_ARGUMENT,"Too many arguments provided to "+t+"(). The number of arguments must be less than or equal to the number of Query.orderBy() clauses");for(var i=[],o=0;o<e.length;o++){var a=e[o];if(r[o].field.isKeyField()){if("string"!=typeof a)throw new T(E.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+t+"(), but got a "+typeof a);if(!this._query.isCollectionGroupQuery()&&-1!==a.indexOf("/"))throw new T(E.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to "+t+"() must be a plain document ID, but '"+a+"' contains a slash.");var s=this._query.path.child(ht.fromString(a));if(!pt.isDocumentKey(s))throw new T(E.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to "+t+"() must result in a valid document path, but '"+s+"' is not because it contains an odd number of segments.");var u=new pt(s);i.push(new Ve(this.firestore._databaseId,u))}else{var c=this.firestore._dataConverter.parseQueryValue(t,a);i.push(c)}}return new lr(i,n)},t.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];x("Query.onSnapshot",arguments,1,4);var n,r={},i=0;return"object"!=typeof t[i]||co(t[i])||(Q("Query.onSnapshot",r=t[i],["includeMetadataChanges"]),F("Query.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++),co(t[i])?n=t[i]:(P("Query.onSnapshot","function",i,t[i]),M("Query.onSnapshot","function",i+1,t[i+1]),M("Query.onSnapshot","function",i+2,t[i+2]),n={next:t[i],error:t[i+1],complete:t[i+2]}),this.validateHasExplicitOrderByForLimitToLast(this._query),this.onSnapshotInternal(r,n)},t.prototype.onSnapshotInternal=function(t,e){var n=this,r=function(t){console.error("Uncaught Error in onSnapshot:",t)};e.error&&(r=e.error.bind(e));var i=new to({next:function(t){e.next&&e.next(new Qo(n.firestore,n._query,t,n._converter))},error:r}),o=this.firestore.ensureClientConfigured(),a=o.listen(this._query,i,t);return function(){i.mute(),o.unlisten(a)}},t.prototype.validateHasExplicitOrderByForLimitToLast=function(t){if(t.hasLimitToLast()&&0===t.explicitOrderBy.length)throw new T(E.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")},t.prototype.get=function(t){var e=this;return x("Query.get",arguments,0,1),Yo("Query.get",t),this.validateHasExplicitOrderByForLimitToLast(this._query),new Promise((function(n,r){t&&"cache"===t.source?e.firestore.ensureClientConfigured().getDocumentsFromLocalCache(e._query).then((function(t){n(new Qo(e.firestore,e._query,t,e._converter))}),r):e.getViaSnapshotListener(n,r,t)}))},t.prototype.getViaSnapshotListener=function(t,e,n){var r=this.onSnapshotInternal({includeMetadataChanges:!0,waitForSyncWhenOnline:!0},{next:function(i){r(),i.metadata.fromCache&&n&&"server"===n.source?e(new T(E.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):t(i)},error:e})},t.prototype.parseDocumentIdValue=function(t){if("string"==typeof t){if(""===t)throw new T(E.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!this._query.isCollectionGroupQuery()&&-1!==t.indexOf("/"))throw new T(E.INVALID_ARGUMENT,"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '"+t+"' contains a '/' character.");var e=this._query.path.child(ht.fromString(t));if(!pt.isDocumentKey(e))throw new T(E.INVALID_ARGUMENT,"Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '"+e+"' is not because it has an odd number of segments ("+e.length+").");return new Ve(this.firestore._databaseId,new pt(e))}if(t instanceof Vo){var n=t;return new Ve(this.firestore._databaseId,n._key)}throw new T(E.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+z(t)+".")},t.prototype.validateDisjunctiveFilterElements=function(t,e){if(!Array.isArray(t)||0===t.length)throw new T(E.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(t.length>10)throw new T(E.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.");if(t.indexOf(null)>=0)throw new T(E.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'null' in the value array.");if(t.filter((function(t){return Number.isNaN(t)})).length>0)throw new T(E.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'NaN' in the value array.")},t.prototype.validateNewFilter=function(t){if(t instanceof ir){var e=[rr.ARRAY_CONTAINS,rr.ARRAY_CONTAINS_ANY],n=[rr.IN,rr.ARRAY_CONTAINS_ANY],r=e.indexOf(t.op)>=0,i=n.indexOf(t.op)>=0;if(t.isInequality()){var o=this._query.getInequalityFilterField();if(null!==o&&!o.isEqual(t.field))throw new T(E.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, >, or >=) must be on the same field. But you have inequality filters on '"+o.toString()+"' and '"+t.field.toString()+"'");var a=this._query.getFirstOrderByField();null!==a&&this.validateOrderByAndInequalityMatch(t.field,a)}else if(i||r){var s=null;if(i&&(s=this._query.findFilterOperator(n)),null===s&&r&&(s=this._query.findFilterOperator(e)),null!=s)throw s===t.op?new T(E.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new T(E.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+s.toString()+"' filters.")}}},t.prototype.validateNewOrderBy=function(t){if(null===this._query.getFirstOrderByField()){var e=this._query.getInequalityFilterField();null!==e&&this.validateOrderByAndInequalityMatch(e,t.field)}},t.prototype.validateOrderByAndInequalityMatch=function(t,e){if(!e.isEqual(t))throw new T(E.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, >, or >=) on field '"+t.toString()+"' and so you must also use '"+t.toString()+"' as your first Query.orderBy(), but your first Query.orderBy() is on field '"+e.toString()+"' instead.")},t}(),Qo=function(){function t(t,e,n,r){this._firestore=t,this._originalQuery=e,this._snapshot=n,this._converter=r,this._cachedChanges=null,this._cachedChangesIncludeMetadataChanges=null,this.metadata=new Bo(n.hasPendingWrites,n.fromCache)}return Object.defineProperty(t.prototype,"docs",{get:function(){var t=[];return this.forEach((function(e){return t.push(e)})),t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"empty",{get:function(){return this._snapshot.docs.isEmpty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!0,configurable:!0}),t.prototype.forEach=function(t,e){var n=this;x("QuerySnapshot.forEach",arguments,1,2),P("QuerySnapshot.forEach","function",1,t),this._snapshot.docs.forEach((function(r){t.call(e,n.convertToDocumentImpl(r))}))},Object.defineProperty(t.prototype,"query",{get:function(){return new Wo(this._originalQuery,this._firestore,this._converter)},enumerable:!0,configurable:!0}),t.prototype.docChanges=function(t){t&&(Q("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),F("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this._snapshot.excludesMetadataChanges)throw new T(E.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(t,e,n,r){if(n.oldDocs.isEmpty()){var i,o=0;return n.docChanges.map((function(e){var a=new zo(t,e.doc.key,e.doc,n.fromCache,n.mutatedKeys.has(e.doc.key),r);return _(e.type===Wr.Added,"Invalid event type for first snapshot"),_(!i||n.query.docComparator(i,e.doc)<0,"Got added events in wrong order"),i=e.doc,{type:"added",doc:a,oldIndex:-1,newIndex:o++}}))}var a=n.oldDocs;return n.docChanges.filter((function(t){return e||t.type!==Wr.Metadata})).map((function(e){var i=new zo(t,e.doc.key,e.doc,n.fromCache,n.mutatedKeys.has(e.doc.key),r),o=-1,s=-1;return e.type!==Wr.Added&&(_((o=a.indexOf(e.doc.key))>=0,"Index for document not found"),a=a.delete(e.doc.key)),e.type!==Wr.Removed&&(s=(a=a.add(e.doc)).indexOf(e.doc.key)),{type:Jo(e.type),doc:i,oldIndex:o,newIndex:s}}))}(this._firestore,e,this._snapshot,this._converter),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges},t.prototype.isEqual=function(e){if(!(e instanceof t))throw K("isEqual","QuerySnapshot",1,e);return this._firestore===e._firestore&&this._originalQuery.isEqual(e._originalQuery)&&this._snapshot.isEqual(e._snapshot)&&this._converter===e._converter},t.prototype.convertToDocumentImpl=function(t){return new zo(this._firestore,t.key,t,this.metadata.fromCache,this._snapshot.mutatedKeys.has(t.key),this._converter)},t}();a.__spreadArrays(["length","forEach","map"],"undefined"!=typeof Symbol?[Symbol.iterator]:[]).forEach((function(t){try{Object.defineProperty(Qo.prototype.docChanges,t,{get:function(){return function(){throw new T(E.INVALID_ARGUMENT,'QuerySnapshot.docChanges has been changed from a property into a method, so usages like "querySnapshot.docChanges" should become "querySnapshot.docChanges()"')}()}})}catch(e){}}));var Ko=function(t){function e(e,n,r){var i=t.call(this,er.atPath(e),n,r)||this;if(i._path=e,e.length%2!=1)throw new T(E.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+e.canonicalString()+" has "+e.length);return i}return a.__extends(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){var t=this._query.path.popLast();return t.isEmpty()?null:new Vo(new pt(t),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if(x("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=X.newId()),P("CollectionReference.doc","non-empty string",1,t),""===t)throw new T(E.INVALID_ARGUMENT,"Document path must be a non-empty string");var e=ht.fromString(t);return Vo.forPath(this._query.path.child(e),this.firestore,this._converter)},e.prototype.add=function(t){R("CollectionReference.add",arguments,1),P("CollectionReference.add","object",1,t);var e=this.doc();return e.set(t).then((function(){return e}))},e.prototype.withConverter=function(t){return new e(this._path,this.firestore,t)},e}(Wo);function Ho(t,e){if(void 0===e)return{merge:!1};if(Q(t,e,["merge","mergeFields"]),F(t,"boolean","merge",e.merge),U(t,"mergeFields","a string or a FieldPath",e.mergeFields,(function(t){return"string"==typeof t||t instanceof eo})),void 0!==e.mergeFields&&void 0!==e.merge)throw new T(E.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function Go(t,e){return void 0===e?{}:(Q(t,e,["serverTimestamps"]),q(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function Yo(t,e){M(t,"object",1,e),e&&(Q(t,e,["source"]),q(t,0,"source",e.source,["default","server","cache"]))}function Xo(t,e,n){if(e instanceof Vo){if(e.firestore!==n)throw new T(E.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw K(t,"DocumentReference",1,e)}function Jo(t){switch(t){case Wr.Added:return"added";case Wr.Modified:case Wr.Metadata:return"modified";case Wr.Removed:return"removed";default:return v("Unknown change type: "+t)}}function Zo(t,e,n){var r;return t?(r=t.toFirestore(e),n="toFirestore() in "+n):r=e,[r,n]}var $o=C(Fo,"Use firebase.firestore() instead."),ta=C(Uo,"Use firebase.firestore().runTransaction() instead."),ea=C(qo,"Use firebase.firestore().batch() instead."),na=C(Vo,"Use firebase.firestore().doc() instead."),ra=C(jo),ia=C(zo),oa=C(Wo),aa=C(Qo),sa=C(Ko,"Use firebase.firestore().collection() instead."),ua={Firestore:$o,GeoPoint:si,Timestamp:St,Blob:it,Transaction:ta,WriteBatch:ea,DocumentReference:na,DocumentSnapshot:ra,Query:oa,QueryDocumentSnapshot:ia,QuerySnapshot:aa,CollectionReference:sa,FieldPath:eo,FieldValue:vo,setLogLevel:Fo.setLogLevel,CACHE_SIZE_UNLIMITED:Mo};function ca(t){t.INTERNAL.registerComponent(new c.Component("firestore",(function(t){var e=t.getProvider("app").getImmediate();return new Fo(e,t.getProvider("auth-internal"))}),"PUBLIC").setServiceProps(function(t){_(t&&"object"==typeof t,"shallowCopy() expects object parameter.");var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}(ua)))}var ha=function(){function t(){}return t.prototype.addCallback=function(t){},t.prototype.shutdown=function(){},t}(),la=function(){function t(){var t=this;this.networkAvailableListener=function(){return t.onNetworkAvailable()},this.networkUnavailableListener=function(){return t.onNetworkUnavailable()},this.callbacks=[],this.configureNetworkMonitoring()}return t.prototype.addCallback=function(t){this.callbacks.push(t)},t.prototype.shutdown=function(){window.removeEventListener("online",this.networkAvailableListener),window.removeEventListener("offline",this.networkUnavailableListener)},t.prototype.configureNetworkMonitoring=function(){window.addEventListener("online",this.networkAvailableListener),window.addEventListener("offline",this.networkUnavailableListener)},t.prototype.onNetworkAvailable=function(){m("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.callbacks;t<e.length;t++){(0,e[t])(0)}},t.prototype.onNetworkUnavailable=function(){m("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.callbacks;t<e.length;t++){(0,e[t])(1)}},t.isAvailable=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},t}(),fa=function(){function t(t){this.sendFn=t.sendFn,this.closeFn=t.closeFn}return t.prototype.onOpen=function(t){_(!this.wrappedOnOpen,"Called onOpen on stream twice!"),this.wrappedOnOpen=t},t.prototype.onClose=function(t){_(!this.wrappedOnClose,"Called onClose on stream twice!"),this.wrappedOnClose=t},t.prototype.onMessage=function(t){_(!this.wrappedOnMessage,"Called onMessage on stream twice!"),this.wrappedOnMessage=t},t.prototype.close=function(){this.closeFn()},t.prototype.send=function(t){this.sendFn(t)},t.prototype.callOnOpen=function(){_(void 0!==this.wrappedOnOpen,"Cannot call onOpen because no callback was set"),this.wrappedOnOpen()},t.prototype.callOnClose=function(t){_(void 0!==this.wrappedOnClose,"Cannot call onClose because no callback was set"),this.wrappedOnClose(t)},t.prototype.callOnMessage=function(t){_(void 0!==this.wrappedOnMessage,"Cannot call onMessage because no callback was set"),this.wrappedOnMessage(t)},t}(),pa="Connection",da={BatchGetDocuments:"batchGet",Commit:"commit"},ma="gl-js/ fire/"+l,ya=function(){function t(t){this.databaseId=t.databaseId;var e=t.ssl?"https":"http";this.baseUrl=e+"://"+t.host,this.forceLongPolling=t.forceLongPolling}return t.prototype.modifyHeadersForRequest=function(t,e){if(e)for(var n in e.authHeaders)e.authHeaders.hasOwnProperty(n)&&(t[n]=e.authHeaders[n]);t["X-Goog-Api-Client"]=ma},t.prototype.invokeRPC=function(t,e,n){var r=this,i=this.makeUrl(t);return new Promise((function(o,s){var u=new h.XhrIo;u.listenOnce(h.EventType.COMPLETE,(function(){try{switch(u.getLastErrorCode()){case h.ErrorCode.NO_ERROR:var e=u.getResponseJson();m(pa,"XHR received:",JSON.stringify(e)),o(e);break;case h.ErrorCode.TIMEOUT:m(pa,'RPC "'+t+'" timed out'),s(new T(E.DEADLINE_EXCEEDED,"Request time out"));break;case h.ErrorCode.HTTP_ERROR:var n=u.getStatus();if(m(pa,'RPC "'+t+'" failed with status:',n,"response text:",u.getResponseText()),n>0){var r=u.getResponseJson().error;if(r&&r.status&&r.message){var i=(a=r.status,c=a.toLowerCase().replace("_","-"),Object.values(E).indexOf(c)>=0?c:E.UNKNOWN);s(new T(i,r.message))}else s(new T(E.UNKNOWN,"Server responded with status "+u.getStatus()))}else m(pa,'RPC "'+t+'" failed'),s(new T(E.UNAVAILABLE,"Connection failed."));break;default:v('RPC "'+t+'" failed with unanticipated webchannel error '+u.getLastErrorCode()+": "+u.getLastError()+", giving up.")}}finally{m(pa,'RPC "'+t+'" completed.')}var a,c}));var c=a.__assign({},e);delete c.database;var l=JSON.stringify(c);m(pa,"XHR sending: ",i+" "+l);var f={"Content-Type":"text/plain"};r.modifyHeadersForRequest(f,n),u.send(i,"POST",l,f,15)}))},t.prototype.invokeStreamingRPC=function(t,e,n){return this.invokeRPC(t,e,n)},t.prototype.openStream=function(t,e){var n=[this.baseUrl,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=h.createWebChannelTransport(),i={backgroundChannelTest:!0,httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling};this.modifyHeadersForRequest(i.initMessageHeaders,e),u.isReactNative()||(i.httpHeadersOverwriteParam="$httpHeaders");var o=n.join("");m(pa,"Creating WebChannel: "+o+" "+i);var a=r.createWebChannel(o,i),s=!1,c=!1,l=new fa({sendFn:function(t){c?m(pa,"Not sending because WebChannel is closed:",t):(s||(m(pa,"Opening WebChannel transport."),a.open(),s=!0),m(pa,"WebChannel sending:",t),a.send(t))},closeFn:function(){return a.close()}}),f=function(t,e){a.listen(t,(function(t){try{e(t)}catch(n){setTimeout((function(){throw n}),0)}}))};return f(h.WebChannel.EventType.OPEN,(function(){c||m(pa,"WebChannel transport opened.")})),f(h.WebChannel.EventType.CLOSE,(function(){c||(c=!0,m(pa,"WebChannel transport closed"),l.callOnClose())})),f(h.WebChannel.EventType.ERROR,(function(t){c||(c=!0,m(pa,"WebChannel transport errored:",t),l.callOnClose(new T(E.UNAVAILABLE,"The operation could not be completed")))})),f(h.WebChannel.EventType.MESSAGE,(function(t){var e;if(!c){var n=t.data[0];_(!!n,"Got a webchannel message without data.");var r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){m(pa,"WebChannel received error:",i);var o=i.status,s=function(t){var e=qr[t];if(void 0!==e)return jr(e)}(o),u=i.message;void 0===s&&(s=E.INTERNAL,u="Unknown error status: "+o+" with message "+i.message),c=!0,l.callOnClose(new T(s,u)),a.close()}else m(pa,"WebChannel received:",n),l.callOnMessage(n)}})),setTimeout((function(){l.callOnOpen()}),0),l},t.prototype.makeUrl=function(t){var e=da[t];return _(void 0!==e,"Unknown REST mapping for: "+t),this.baseUrl+"/v1/projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents:"+e},t}(),ga=function(){function t(){this.emptyByteString="",this.base64Available="undefined"!=typeof atob}return Object.defineProperty(t.prototype,"document",{get:function(){return"undefined"!=typeof document?document:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"window",{get:function(){return"undefined"!=typeof window?window:null},enumerable:!0,configurable:!0}),t.prototype.loadConnection=function(t){return Promise.resolve(new ya(t))},t.prototype.newConnectivityMonitor=function(){return la.isAvailable()?new la:new ha},t.prototype.newSerializer=function(t){return new wi(t,{useProto3Json:!0})},t.prototype.formatJSON=function(t){return JSON.stringify(t)},t.prototype.atob=function(t){return atob(t)},t.prototype.btoa=function(t){return btoa(t)},t}();b.setPlatform(new ga);var va="@firebase/firestore",_a="1.9.1";function ba(t){ca(t),t.registerVersion(va,_a)}ba(o),e.registerFirestore=ba}).call(this,n("8oxB"))},"6nXr":function(t,e,n){n("Sc3u")("Int32",4,(function(t){return function(e,n,r){return t(this,e,n,r)}}))},"6nsN":function(t,e,n){"use strict";n.r(e);n("t6oF")},"8oxB":function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(t){r=a}}();var u,c=[],h=!1,l=-1;function f(){h&&u&&(h=!1,u.length?c=u.concat(c):l=-1,c.length&&p())}function p(){if(!h){var t=s(f);h=!0;for(var e=c.length;e;){for(u=c,c=[];++l<e;)u&&u[l].run();l=-1,e=c.length}u=null,h=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function m(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new d(t,e)),1!==c.length||h||s(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},ARus:function(t,e,n){"use strict";n.d(e,"b",(function(){return p}));n("Ll4R");var r=n("q1tI"),i=n.n(r),o=(n("hmp0"),n("h3sT")),a=n("O6Fj"),s=n.n(a),u=n("zEh/"),c=n("if7W"),h=n("YtDf"),l=n.n(h);function f(){return navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)}function p(t,e){if(!e)return!1;var n=Math.round(e.currentTime-t.time);return n<=2&&n>=0}e.a=function(t){var e=t.pos,n=t.getPane,a=t.remove,h=t.annotation,d=t.onMove,m=t.comment,y=t.onSave,g=t.onChange,v=Object(r.useState)(!f()||!m),_=v[0],b=v[1],w=Object(r.useState)(!1),E=w[0],T=w[1];Object(r.useEffect)((function(){return document.addEventListener("dragover",(function(t){return t.preventDefault()}),!1)}),[]);var C=-1!==window.location.href.indexOf("/all"),S=-1*(Math.min(125,e.x-15)+Math.max(140-(n().offsetWidth-e.x),0))+"px",I=e.y>=n().offsetHeight/2?"-100%":0;return i.a.createElement("div",{style:{top:e.y,left:e.x},className:(m?"":"emptytext")+" annotation "+(E?"hasFocus":"")+" "+(h.time?p(h,n())?"visibletime":"hiddentime":"")},i.a.createElement((function(){return i.a.createElement("div",{draggable:!0,onDrag:function(t){t.nativeEvent.target.parentElement.style.top=t.nativeEvent.pageY-n().getBoundingClientRect().top+"px",t.nativeEvent.target.parentElement.style.left=t.nativeEvent.pageX-n().getBoundingClientRect().left+"px"},onDragEnd:function(t){return d({x:t.nativeEvent.pageX-n().getBoundingClientRect().left,y:t.nativeEvent.pageY-n().getBoundingClientRect().top})},className:"annoicon",onClick:function(){return b(!_)}})}),null),i.a.createElement("div",{style:{display:_?"block":"none",transform:"translate("+S+","+I+")"},className:"arrow_box"},!C&&i.a.createElement(s.a,{className:"marktextarea",required:!0,autoFocus:!m,onBlur:function(){m&&y(),setTimeout((function(){return T(!1)}),100)},value:m,onFocus:function(){return T(!0)},onChange:function(t){return g(t.target.value)},name:"comment",placeholder:c.a.annotator.type},m),C&&i.a.createElement("div",{className:"marktextarea"},i.a.createElement(l.a,null,m)),!m&&i.a.createElement((function(){return i.a.createElement("input",{accept:"image/x-png,image/gif,image/jpeg",onChange:function(t){Object(u.a)(t.target,(function(t){g(t),y(),b(!f())}),null,null)},type:"file"})}),null),h.time&&!!m&&i.a.createElement((function(){return i.a.createElement("a",{onClick:function(){return n().currentTime=h.time},className:"timestamp"},c.a.annotator.second," ",Math.floor(100*h.time)/100)}),null),i.a.createElement((function(){return i.a.createElement(o.a,{tagName:"button",onClick:function(t){y(),b(!f())}},"Speichern")}),null),!C&&i.a.createElement((function(){return i.a.createElement("img",{className:"binicon",onClick:function(t){a(t)},src:"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgaGVpZ2h0PSIxNnB4IiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2cHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48dGl0bGUvPjxkZWZzLz48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGlkPSJJY29ucyB3aXRoIG51bWJlcnMiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIj48ZyBmaWxsPSIjMDAwMDAwIiBpZD0iR3JvdXAiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0zMzYuMDAwMDAwLCAtMTkyLjAwMDAwMCkiPjxwYXRoIGQ9Ik0zNDcuOTk5OTU5LDE5NSBMMzUwLDE5NSBMMzUwLDE5NiBMMzQ5LDE5NiBMMzQ5LDIwNy4wMDE0OTggQzM0OSwyMDcuNTUyNTExIDM0OC41NTQyNjUsMjA4IDM0OC4wMDQ0MjMsMjA4IEwzMzguOTk1NTc3LDIwOCBDMzM4LjQ0NDgzNywyMDggMzM4LDIwNy41NTI5NTUgMzM4LDIwNy4wMDE0OTggTDMzOCwxOTYgTDMzNywxOTYgTDMzNywxOTUgTDMzOC45OTU1NzcsMTk1IEwzMzkuMDAwMDQyLDE5NSBMMzM5LDE5NC45OTA2MzEgTDMzOSwxOTMuMDA5MzY5IEMzMzksMTkyLjQ0MzM1MyAzMzkuNDQ2NjE2LDE5MiAzMzkuOTk3NTQ1LDE5MiBMMzQ3LjAwMjQ1NSwxOTIgQzM0Ny41NTM2ODksMTkyIDM0OCwxOTIuNDUxOTEgMzQ4LDE5My4wMDkzNjkgTDM0OCwxOTQuOTkwNjMxIFogTTM0MCwxOTQgTDM0MCwxOTUgTDM0NywxOTUgTDM0NywxOTQgQzM0NywxOTMuNDQ3NzE1IDM0Ni41NTIyODUsMTkzIDM0NiwxOTMgTDM0MSwxOTMgQzM0MC40NDc3MTUsMTkzIDM0MCwxOTMuNDQ3NzE1IDM0MCwxOTQgWiBNMzM5LDE5NiBMMzM5LDIwNyBMMzQ4LDIwNyBMMzQ4LDE5NiBaIE0zNDEsMTk3IEwzNDIsMTk3IEwzNDIsMjA2IEwzNDEsMjA2IFogTTM0MywxOTcgTDM0NCwxOTcgTDM0NCwyMDYgTDM0MywyMDYgWiBNMzQ1LDE5NyBMMzQ1LDIwNiBMMzQ2LDIwNiBMMzQ2LDE5NyBMMzQ1LDE5NyBaIE0zNDUsMTk3IiBpZD0iUmVjdGFuZ2xlIDE1OSIvPjwvZz48L2c+PC9zdmc+",alt:"remove comment icon"})}),null)))}},CNgt:function(t,e,n){"use strict";n("4DPX"),n("sc67"),n("E5k/"),n("pS08"),n("LagC");var r,i=this&&this.__extends||(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])},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),o=this&&this.__assign||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},a=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&(n[r[i]]=t[r[i]])}return n};e.__esModule=!0;var s=n("q1tI"),u=n("17x9"),c=n("GemG"),h=n("Rk8H"),l=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.state={lineHeight:null},e.textarea=e.props.innerRef||s.createRef(),e.onResize=function(t){e.props.onResize&&e.props.onResize(t)},e.updateLineHeight=function(){e.textarea.current&&e.setState({lineHeight:h(e.textarea.current)})},e.onChange=function(t){var n=e.props.onChange;e.currentValue=t.currentTarget.value,n&&n(t)},e}return i(e,t),e.prototype.componentDidMount=function(){var t=this,e=this.props,n=e.maxRows,r=e.async;"number"==typeof n&&this.updateLineHeight(),"number"==typeof n||r?setTimeout((function(){return t.textarea.current&&c(t.textarea.current)})):this.textarea.current&&c(this.textarea.current),this.textarea.current&&this.textarea.current.addEventListener("autosize:resized",this.onResize)},e.prototype.componentWillUnmount=function(){this.textarea.current&&(this.textarea.current.removeEventListener("autosize:resized",this.onResize),c.destroy(this.textarea.current))},e.prototype.render=function(){var t=this.props,e=(t.onResize,t.maxRows),n=(t.onChange,t.style),r=(t.innerRef,t.children),i=a(t,["onResize","maxRows","onChange","style","innerRef","children"]),u=this.state.lineHeight,c=e&&u?u*e:null;return s.createElement("textarea",o({},i,{onChange:this.onChange,style:c?o({},n,{maxHeight:c}):n,ref:this.textarea}),r)},e.prototype.componentDidUpdate=function(){this.textarea.current&&c.update(this.textarea.current)},e.defaultProps={rows:1,async:!1},e.propTypes={rows:u.number,maxRows:u.number,onResize:u.func,innerRef:u.object,async:u.bool},e}(s.Component);e.TextareaAutosize=s.forwardRef((function(t,e){return s.createElement(l,o({},t,{innerRef:e}))}))},CtJk:function(t,e,n){n("Sc3u")("Uint8",1,(function(t){return function(e,n,r){return t(this,e,n,r)}}))},DrhF:function(t,e,n){var r=n("BjK0"),i=n("N+BI").onFreeze;n("939a")("freeze",(function(t){return function(e){return t&&r(e)?t(i(e)):e}}))},GemG:function(t,e,n){var r,i,o;n("Ggvi"),n("n7j8"),n("JHok"),n("sc67"),n("rzGZ"),n("Dq+y"),n("8npG"),n("YbXK"),n("xJgp"),i=[t,e],void 0===(o="function"==typeof(r=function(t,e){"use strict";var n,r,i="function"==typeof Map?new Map:(n=[],r=[],{has:function(t){return n.indexOf(t)>-1},get:function(t){return r[n.indexOf(t)]},set:function(t,e){-1===n.indexOf(t)&&(n.push(t),r.push(e))},delete:function(t){var e=n.indexOf(t);e>-1&&(n.splice(e,1),r.splice(e,1))}}),o=function(t){return new Event(t,{bubbles:!0})};try{new Event("test")}catch(h){o=function(t){var e=document.createEvent("Event");return e.initEvent(t,!0,!1),e}}function a(t){if(t&&t.nodeName&&"TEXTAREA"===t.nodeName&&!i.has(t)){var e,n=null,r=null,a=null,s=function(){t.clientWidth!==r&&l()},u=function(e){window.removeEventListener("resize",s,!1),t.removeEventListener("input",l,!1),t.removeEventListener("keyup",l,!1),t.removeEventListener("autosize:destroy",u,!1),t.removeEventListener("autosize:update",l,!1),Object.keys(e).forEach((function(n){t.style[n]=e[n]})),i.delete(t)}.bind(t,{height:t.style.height,resize:t.style.resize,overflowY:t.style.overflowY,overflowX:t.style.overflowX,wordWrap:t.style.wordWrap});t.addEventListener("autosize:destroy",u,!1),"onpropertychange"in t&&"oninput"in t&&t.addEventListener("keyup",l,!1),window.addEventListener("resize",s,!1),t.addEventListener("input",l,!1),t.addEventListener("autosize:update",l,!1),t.style.overflowX="hidden",t.style.wordWrap="break-word",i.set(t,{destroy:u,update:l}),"vertical"===(e=window.getComputedStyle(t,null)).resize?t.style.resize="none":"both"===e.resize&&(t.style.resize="horizontal"),n="content-box"===e.boxSizing?-(parseFloat(e.paddingTop)+parseFloat(e.paddingBottom)):parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth),isNaN(n)&&(n=0),l()}function c(e){var n=t.style.width;t.style.width="0px",t.offsetWidth,t.style.width=n,t.style.overflowY=e}function h(){if(0!==t.scrollHeight){var e=function(t){for(var e=[];t&&t.parentNode&&t.parentNode instanceof Element;)t.parentNode.scrollTop&&e.push({node:t.parentNode,scrollTop:t.parentNode.scrollTop}),t=t.parentNode;return e}(t),i=document.documentElement&&document.documentElement.scrollTop;t.style.height="",t.style.height=t.scrollHeight+n+"px",r=t.clientWidth,e.forEach((function(t){t.node.scrollTop=t.scrollTop})),i&&(document.documentElement.scrollTop=i)}}function l(){h();var e=Math.round(parseFloat(t.style.height)),n=window.getComputedStyle(t,null),r="content-box"===n.boxSizing?Math.round(parseFloat(n.height)):t.offsetHeight;if(r<e?"hidden"===n.overflowY&&(c("scroll"),h(),r="content-box"===n.boxSizing?Math.round(parseFloat(window.getComputedStyle(t,null).height)):t.offsetHeight):"hidden"!==n.overflowY&&(c("hidden"),h(),r="content-box"===n.boxSizing?Math.round(parseFloat(window.getComputedStyle(t,null).height)):t.offsetHeight),a!==r){a=r;var i=o("autosize:resized");try{t.dispatchEvent(i)}catch(s){}}}}function s(t){var e=i.get(t);e&&e.destroy()}function u(t){var e=i.get(t);e&&e.update()}var c=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((c=function(t){return t}).destroy=function(t){return t},c.update=function(t){return t}):((c=function(t,e){return t&&Array.prototype.forEach.call(t.length?t:[t],(function(t){return a(t)})),t}).destroy=function(t){return t&&Array.prototype.forEach.call(t.length?t:[t],s),t},c.update=function(t){return t&&Array.prototype.forEach.call(t.length?t:[t],u),t}),e.default=c,t.exports=e.default})?r.apply(e,i):r)||(t.exports=o)},HQAx:function(t,e,n){"use strict";var r=n("P8UN"),i=n("ewoU"),o=n("DFzH"),a=n("kiRH"),s=n("nONw"),u=n("ytzU");r(r.P,"Array",{flatMap:function(t){var e,n,r=o(this);return s(t),e=a(r.length),n=u(r,0),i(n,r,r,e,0,1,t,arguments[1]),n}}),n("Dq1/")("flatMap")},I17o:function(t,e,n){"use strict";var r=n("P8UN"),i=n("pTxf"),o=n("CL53"),a=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(o);r(r.P+r.F*a,"String",{padEnd:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!1)}})},J6QO:function(t,e,n){"use strict";var r=n("96qb"),i=Date.prototype.getTime,o=Date.prototype.toISOString,a=function(t){return t>9?t:"0"+t};t.exports=r((function(){return"0385-07-25T07:06:39.999Z"!=o.call(new Date(-5e13-1))}))||!r((function(){o.call(new Date(NaN))}))?function(){if(!isFinite(i.call(this)))throw RangeError("Invalid time value");var t=this,e=t.getUTCFullYear(),n=t.getUTCMilliseconds(),r=e<0?"-":e>9999?"+":"";return r+("00000"+Math.abs(e)).slice(r?-6:-4)+"-"+a(t.getUTCMonth()+1)+"-"+a(t.getUTCDate())+"T"+a(t.getUTCHours())+":"+a(t.getUTCMinutes())+":"+a(t.getUTCSeconds())+"."+(n>99?n:"0"+a(n))+"Z"}:o},Jegl:function(t,e,n){for(var r,i=n("emib"),o=n("8wc8"),a=n("UEZ0"),s=a("typed_array"),u=a("view"),c=!(!i.ArrayBuffer||!i.DataView),h=c,l=0,f="Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array".split(",");l<9;)(r=i[f[l++]])?(o(r.prototype,s,!0),o(r.prototype,u,!0)):h=!1;t.exports={ABV:c,CONSTR:h,TYPED:s,VIEW:u}},KKAB:function(t,e,n){"use strict";var r=n("q1tI"),i=n.n(r),o=n("h3sT");n("if7W");e.a=function(t){var e=t.children,n=t.promise,a=Object(r.useState)(!1),s=a[0],u=a[1];return i.a.createElement(o.a,{onClick:function(){u(!0),n().then((function(t){return u(!1),t})).catch((function(t){u(!1)}))}},s?"Einen Moment Geduld":e)}},L5ms:function(t,e,n){"use strict";n("Ll4R"),n("R48M"),Object.defineProperty(e,"__esModule",{value:!0});var r=o(n("+80P")),i=o(n("wRvv"));function o(t){return t&&t.__esModule?t:{default:t}}var a=new r.default;a.tlds(i.default),e.default=function(t){return a.match(t)}},LvDl:function(t,e,n){(function(t,r){var i;n("nMRu"),n("1/Ks"),n("QzX/"),n("HXzo"),n("TAD1"),n("wZFJ"),n("ZiRl"),n("Rw9D"),n("U6Bt"),n("lizw"),n("I17o"),n("gu/5"),n("eoYm"),n("zTTH"),n("v9g0"),n("WevN"),n("HQAx"),n("OeI1"),n("n0hJ"),n("n7j8"),n("lFjb"),n("sPse"),n("MIFh"),n("sc67"),n("AqHK"),n("pJf4"),n("Ggvi"),n("4DPX"),n("1dPr"),n("pS08"),n("sC2a"),n("rzGZ"),n("Dq+y"),n("q8oJ"),n("C9fy"),n("8npG"),n("JHok"),n("zGcK"),n("Ll4R"),n("HQhv"),n("klQ5"),function(){var o,a=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",u="Expected a function",c="__lodash_hash_undefined__",h=500,l="__lodash_placeholder__",f=1,p=2,d=4,m=1,y=2,g=1,v=2,_=4,b=8,w=16,E=32,T=64,C=128,S=256,I=512,D=30,N="...",A=800,k=16,R=1,O=2,x=1/0,P=9007199254740991,M=17976931348623157e292,L=NaN,F=4294967295,U=F-1,q=F>>>1,V=[["ary",C],["bind",g],["bindKey",v],["curry",b],["curryRight",w],["flip",I],["partial",E],["partialRight",T],["rearg",S]],B="[object Arguments]",j="[object Array]",z="[object AsyncFunction]",W="[object Boolean]",Q="[object Date]",K="[object DOMException]",H="[object Error]",G="[object Function]",Y="[object GeneratorFunction]",X="[object Map]",J="[object Number]",Z="[object Null]",$="[object Object]",tt="[object Proxy]",et="[object RegExp]",nt="[object Set]",rt="[object String]",it="[object Symbol]",ot="[object Undefined]",at="[object WeakMap]",st="[object WeakSet]",ut="[object ArrayBuffer]",ct="[object DataView]",ht="[object Float32Array]",lt="[object Float64Array]",ft="[object Int8Array]",pt="[object Int16Array]",dt="[object Int32Array]",mt="[object Uint8Array]",yt="[object Uint8ClampedArray]",gt="[object Uint16Array]",vt="[object Uint32Array]",_t=/\b__p \+= '';/g,bt=/\b(__p \+=) '' \+/g,wt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Et=/&(?:amp|lt|gt|quot|#39);/g,Tt=/[&<>"']/g,Ct=RegExp(Et.source),St=RegExp(Tt.source),It=/<%-([\s\S]+?)%>/g,Dt=/<%([\s\S]+?)%>/g,Nt=/<%=([\s\S]+?)%>/g,At=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,kt=/^\w*$/,Rt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ot=/[\\^$.*+?()[\]{}|]/g,xt=RegExp(Ot.source),Pt=/^\s+|\s+$/g,Mt=/^\s+/,Lt=/\s+$/,Ft=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ut=/\{\n\/\* \[wrapped with (.+)\] \*/,qt=/,? & /,Vt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Bt=/\\(\\)?/g,jt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zt=/\w*$/,Wt=/^[-+]0x[0-9a-f]+$/i,Qt=/^0b[01]+$/i,Kt=/^\[object .+?Constructor\]$/,Ht=/^0o[0-7]+$/i,Gt=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xt=/($^)/,Jt=/['\n\r\u2028\u2029\\]/g,Zt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",$t="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",te="[\\ud800-\\udfff]",ee="["+$t+"]",ne="["+Zt+"]",re="\\d+",ie="[\\u2700-\\u27bf]",oe="[a-z\\xdf-\\xf6\\xf8-\\xff]",ae="[^\\ud800-\\udfff"+$t+re+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",ue="[^\\ud800-\\udfff]",ce="(?:\\ud83c[\\udde6-\\uddff]){2}",he="[\\ud800-\\udbff][\\udc00-\\udfff]",le="[A-Z\\xc0-\\xd6\\xd8-\\xde]",fe="(?:"+oe+"|"+ae+")",pe="(?:"+le+"|"+ae+")",de="(?:"+ne+"|"+se+")"+"?",me="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[ue,ce,he].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),ye="(?:"+[ie,ce,he].join("|")+")"+me,ge="(?:"+[ue+ne+"?",ne,ce,he,te].join("|")+")",ve=RegExp("['’]","g"),_e=RegExp(ne,"g"),be=RegExp(se+"(?="+se+")|"+ge+me,"g"),we=RegExp([le+"?"+oe+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[ee,le,"$"].join("|")+")",pe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[ee,le+fe,"$"].join("|")+")",le+"?"+fe+"+(?:['’](?:d|ll|m|re|s|t|ve))?",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",re,ye].join("|"),"g"),Ee=RegExp("[\\u200d\\ud800-\\udfff"+Zt+"\\ufe0e\\ufe0f]"),Te=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ce=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Se=-1,Ie={};Ie[ht]=Ie[lt]=Ie[ft]=Ie[pt]=Ie[dt]=Ie[mt]=Ie[yt]=Ie[gt]=Ie[vt]=!0,Ie[B]=Ie[j]=Ie[ut]=Ie[W]=Ie[ct]=Ie[Q]=Ie[H]=Ie[G]=Ie[X]=Ie[J]=Ie[$]=Ie[et]=Ie[nt]=Ie[rt]=Ie[at]=!1;var De={};De[B]=De[j]=De[ut]=De[ct]=De[W]=De[Q]=De[ht]=De[lt]=De[ft]=De[pt]=De[dt]=De[X]=De[J]=De[$]=De[et]=De[nt]=De[rt]=De[it]=De[mt]=De[yt]=De[gt]=De[vt]=!0,De[H]=De[G]=De[at]=!1;var Ne={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ae=parseFloat,ke=parseInt,Re="object"==typeof t&&t&&t.Object===Object&&t,Oe="object"==typeof self&&self&&self.Object===Object&&self,xe=Re||Oe||Function("return this")(),Pe=e&&!e.nodeType&&e,Me=Pe&&"object"==typeof r&&r&&!r.nodeType&&r,Le=Me&&Me.exports===Pe,Fe=Le&&Re.process,Ue=function(){try{var t=Me&&Me.require&&Me.require("util").types;return t||Fe&&Fe.binding&&Fe.binding("util")}catch(e){}}(),qe=Ue&&Ue.isArrayBuffer,Ve=Ue&&Ue.isDate,Be=Ue&&Ue.isMap,je=Ue&&Ue.isRegExp,ze=Ue&&Ue.isSet,We=Ue&&Ue.isTypedArray;function Qe(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function Ke(t,e,n,r){for(var i=-1,o=null==t?0:t.length;++i<o;){var a=t[i];e(r,a,n(a),t)}return r}function He(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}function Ge(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}function Ye(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(!e(t[n],n,t))return!1;return!0}function Xe(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var a=t[n];e(a,n,t)&&(o[i++]=a)}return o}function Je(t,e){return!!(null==t?0:t.length)&&un(t,e,0)>-1}function Ze(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}function $e(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}function tn(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}function en(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}function nn(t,e,n,r){var i=null==t?0:t.length;for(r&&i&&(n=t[--i]);i--;)n=e(n,t[i],i,t);return n}function rn(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}var on=fn("length");function an(t,e,n){var r;return n(t,(function(t,n,i){if(e(t,n,i))return r=n,!1})),r}function sn(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1}function un(t,e,n){return e==e?function(t,e,n){var r=n-1,i=t.length;for(;++r<i;)if(t[r]===e)return r;return-1}(t,e,n):sn(t,hn,n)}function cn(t,e,n,r){for(var i=n-1,o=t.length;++i<o;)if(r(t[i],e))return i;return-1}function hn(t){return t!=t}function ln(t,e){var n=null==t?0:t.length;return n?mn(t,e)/n:L}function fn(t){return function(e){return null==e?o:e[t]}}function pn(t){return function(e){return null==t?o:t[e]}}function dn(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}function mn(t,e){for(var n,r=-1,i=t.length;++r<i;){var a=e(t[r]);a!==o&&(n=n===o?a:n+a)}return n}function yn(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}function gn(t){return function(e){return t(e)}}function vn(t,e){return $e(e,(function(e){return t[e]}))}function _n(t,e){return t.has(e)}function bn(t,e){for(var n=-1,r=t.length;++n<r&&un(e,t[n],0)>-1;);return n}function wn(t,e){for(var n=t.length;n--&&un(e,t[n],0)>-1;);return n}var En=pn({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Tn=pn({"&":"&","<":"<",">":">",'"':""","'":"'"});function Cn(t){return"\\"+Ne[t]}function Sn(t){return Ee.test(t)}function In(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function Dn(t,e){return function(n){return t(e(n))}}function Nn(t,e){for(var n=-1,r=t.length,i=0,o=[];++n<r;){var a=t[n];a!==e&&a!==l||(t[n]=l,o[i++]=n)}return o}function An(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}function kn(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=[t,t]})),n}function Rn(t){return Sn(t)?function(t){var e=be.lastIndex=0;for(;be.test(t);)++e;return e}(t):on(t)}function On(t){return Sn(t)?function(t){return t.match(be)||[]}(t):function(t){return t.split("")}(t)}var xn=pn({"&":"&","<":"<",">":">",""":'"',"'":"'"});var Pn=function t(e){var n,r=(e=null==e?xe:Pn.defaults(xe.Object(),e,Pn.pick(xe,Ce))).Array,i=e.Date,Zt=e.Error,$t=e.Function,te=e.Math,ee=e.Object,ne=e.RegExp,re=e.String,ie=e.TypeError,oe=r.prototype,ae=$t.prototype,se=ee.prototype,ue=e["__core-js_shared__"],ce=ae.toString,he=se.hasOwnProperty,le=0,fe=(n=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",pe=se.toString,de=ce.call(ee),me=xe._,ye=ne("^"+ce.call(he).replace(Ot,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ge=Le?e.Buffer:o,be=e.Symbol,Ee=e.Uint8Array,Ne=ge?ge.allocUnsafe:o,Re=Dn(ee.getPrototypeOf,ee),Oe=ee.create,Pe=se.propertyIsEnumerable,Me=oe.splice,Fe=be?be.isConcatSpreadable:o,Ue=be?be.iterator:o,on=be?be.toStringTag:o,pn=function(){try{var t=qo(ee,"defineProperty");return t({},"",{}),t}catch(e){}}(),Mn=e.clearTimeout!==xe.clearTimeout&&e.clearTimeout,Ln=i&&i.now!==xe.Date.now&&i.now,Fn=e.setTimeout!==xe.setTimeout&&e.setTimeout,Un=te.ceil,qn=te.floor,Vn=ee.getOwnPropertySymbols,Bn=ge?ge.isBuffer:o,jn=e.isFinite,zn=oe.join,Wn=Dn(ee.keys,ee),Qn=te.max,Kn=te.min,Hn=i.now,Gn=e.parseInt,Yn=te.random,Xn=oe.reverse,Jn=qo(e,"DataView"),Zn=qo(e,"Map"),$n=qo(e,"Promise"),tr=qo(e,"Set"),er=qo(e,"WeakMap"),nr=qo(ee,"create"),rr=er&&new er,ir={},or=la(Jn),ar=la(Zn),sr=la($n),ur=la(tr),cr=la(er),hr=be?be.prototype:o,lr=hr?hr.valueOf:o,fr=hr?hr.toString:o;function pr(t){if(Ns(t)&&!gs(t)&&!(t instanceof gr)){if(t instanceof yr)return t;if(he.call(t,"__wrapped__"))return fa(t)}return new yr(t)}var dr=function(){function t(){}return function(e){if(!Ds(e))return{};if(Oe)return Oe(e);t.prototype=e;var n=new t;return t.prototype=o,n}}();function mr(){}function yr(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=o}function gr(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=F,this.__views__=[]}function vr(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function _r(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function br(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function wr(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new br;++e<n;)this.add(t[e])}function Er(t){var e=this.__data__=new _r(t);this.size=e.size}function Tr(t,e){var n=gs(t),r=!n&&ys(t),i=!n&&!r&&ws(t),o=!n&&!r&&!i&&Ls(t),a=n||r||i||o,s=a?yn(t.length,re):[],u=s.length;for(var c in t)!e&&!he.call(t,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Ko(c,u))||s.push(c);return s}function Cr(t){var e=t.length;return e?t[wi(0,e-1)]:o}function Sr(t,e){return ua(no(t),Pr(e,0,t.length))}function Ir(t){return ua(no(t))}function Dr(t,e,n){(n===o||ps(t[e],n))&&(n!==o||e in t)||Or(t,e,n)}function Nr(t,e,n){var r=t[e];he.call(t,e)&&ps(r,n)&&(n!==o||e in t)||Or(t,e,n)}function Ar(t,e){for(var n=t.length;n--;)if(ps(t[n][0],e))return n;return-1}function kr(t,e,n,r){return qr(t,(function(t,i,o){e(r,t,n(t),o)})),r}function Rr(t,e){return t&&ro(e,iu(e),t)}function Or(t,e,n){"__proto__"==e&&pn?pn(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function xr(t,e){for(var n=-1,i=e.length,a=r(i),s=null==t;++n<i;)a[n]=s?o:$s(t,e[n]);return a}function Pr(t,e,n){return t==t&&(n!==o&&(t=t<=n?t:n),e!==o&&(t=t>=e?t:e)),t}function Mr(t,e,n,r,i,a){var s,u=e&f,c=e&p,h=e&d;if(n&&(s=i?n(t,r,i,a):n(t)),s!==o)return s;if(!Ds(t))return t;var l=gs(t);if(l){if(s=function(t){var e=t.length,n=new t.constructor(e);e&&"string"==typeof t[0]&&he.call(t,"index")&&(n.index=t.index,n.input=t.input);return n}(t),!u)return no(t,s)}else{var m=jo(t),y=m==G||m==Y;if(ws(t))return Xi(t,u);if(m==$||m==B||y&&!i){if(s=c||y?{}:Wo(t),!u)return c?function(t,e){return ro(t,Bo(t),e)}(t,function(t,e){return t&&ro(e,ou(e),t)}(s,t)):function(t,e){return ro(t,Vo(t),e)}(t,Rr(s,t))}else{if(!De[m])return i?t:{};s=function(t,e,n){var r=t.constructor;switch(e){case ut:return Ji(t);case W:case Q:return new r(+t);case ct:return function(t,e){var n=e?Ji(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case ht:case lt:case ft:case pt:case dt:case mt:case yt:case gt:case vt:return Zi(t,n);case X:return new r;case J:case rt:return new r(t);case et:return function(t){var e=new t.constructor(t.source,zt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case nt:return new r;case it:return i=t,lr?ee(lr.call(i)):{}}var i}(t,m,u)}}a||(a=new Er);var g=a.get(t);if(g)return g;a.set(t,s),xs(t)?t.forEach((function(r){s.add(Mr(r,e,n,r,t,a))})):As(t)&&t.forEach((function(r,i){s.set(i,Mr(r,e,n,i,t,a))}));var v=l?o:(h?c?Oo:Ro:c?ou:iu)(t);return He(v||t,(function(r,i){v&&(r=t[i=r]),Nr(s,i,Mr(r,e,n,i,t,a))})),s}function Lr(t,e,n){var r=n.length;if(null==t)return!r;for(t=ee(t);r--;){var i=n[r],a=e[i],s=t[i];if(s===o&&!(i in t)||!a(s))return!1}return!0}function Fr(t,e,n){if("function"!=typeof t)throw new ie(u);return ia((function(){t.apply(o,n)}),e)}function Ur(t,e,n,r){var i=-1,o=Je,s=!0,u=t.length,c=[],h=e.length;if(!u)return c;n&&(e=$e(e,gn(n))),r?(o=Ze,s=!1):e.length>=a&&(o=_n,s=!1,e=new wr(e));t:for(;++i<u;){var l=t[i],f=null==n?l:n(l);if(l=r||0!==l?l:0,s&&f==f){for(var p=h;p--;)if(e[p]===f)continue t;c.push(l)}else o(e,f,r)||c.push(l)}return c}pr.templateSettings={escape:It,evaluate:Dt,interpolate:Nt,variable:"",imports:{_:pr}},pr.prototype=mr.prototype,pr.prototype.constructor=pr,yr.prototype=dr(mr.prototype),yr.prototype.constructor=yr,gr.prototype=dr(mr.prototype),gr.prototype.constructor=gr,vr.prototype.clear=function(){this.__data__=nr?nr(null):{},this.size=0},vr.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},vr.prototype.get=function(t){var e=this.__data__;if(nr){var n=e[t];return n===c?o:n}return he.call(e,t)?e[t]:o},vr.prototype.has=function(t){var e=this.__data__;return nr?e[t]!==o:he.call(e,t)},vr.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=nr&&e===o?c:e,this},_r.prototype.clear=function(){this.__data__=[],this.size=0},_r.prototype.delete=function(t){var e=this.__data__,n=Ar(e,t);return!(n<0)&&(n==e.length-1?e.pop():Me.call(e,n,1),--this.size,!0)},_r.prototype.get=function(t){var e=this.__data__,n=Ar(e,t);return n<0?o:e[n][1]},_r.prototype.has=function(t){return Ar(this.__data__,t)>-1},_r.prototype.set=function(t,e){var n=this.__data__,r=Ar(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},br.prototype.clear=function(){this.size=0,this.__data__={hash:new vr,map:new(Zn||_r),string:new vr}},br.prototype.delete=function(t){var e=Fo(this,t).delete(t);return this.size-=e?1:0,e},br.prototype.get=function(t){return Fo(this,t).get(t)},br.prototype.has=function(t){return Fo(this,t).has(t)},br.prototype.set=function(t,e){var n=Fo(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},wr.prototype.add=wr.prototype.push=function(t){return this.__data__.set(t,c),this},wr.prototype.has=function(t){return this.__data__.has(t)},Er.prototype.clear=function(){this.__data__=new _r,this.size=0},Er.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Er.prototype.get=function(t){return this.__data__.get(t)},Er.prototype.has=function(t){return this.__data__.has(t)},Er.prototype.set=function(t,e){var n=this.__data__;if(n instanceof _r){var r=n.__data__;if(!Zn||r.length<a-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new br(r)}return n.set(t,e),this.size=n.size,this};var qr=ao(Hr),Vr=ao(Gr,!0);function Br(t,e){var n=!0;return qr(t,(function(t,r,i){return n=!!e(t,r,i)})),n}function jr(t,e,n){for(var r=-1,i=t.length;++r<i;){var a=t[r],s=e(a);if(null!=s&&(u===o?s==s&&!Ms(s):n(s,u)))var u=s,c=a}return c}function zr(t,e){var n=[];return qr(t,(function(t,r,i){e(t,r,i)&&n.push(t)})),n}function Wr(t,e,n,r,i){var o=-1,a=t.length;for(n||(n=Qo),i||(i=[]);++o<a;){var s=t[o];e>0&&n(s)?e>1?Wr(s,e-1,n,r,i):tn(i,s):r||(i[i.length]=s)}return i}var Qr=so(),Kr=so(!0);function Hr(t,e){return t&&Qr(t,e,iu)}function Gr(t,e){return t&&Kr(t,e,iu)}function Yr(t,e){return Xe(e,(function(e){return Cs(t[e])}))}function Xr(t,e){for(var n=0,r=(e=Ki(e,t)).length;null!=t&&n<r;)t=t[ha(e[n++])];return n&&n==r?t:o}function Jr(t,e,n){var r=e(t);return gs(t)?r:tn(r,n(t))}function Zr(t){return null==t?t===o?ot:Z:on&&on in ee(t)?function(t){var e=he.call(t,on),n=t[on];try{t[on]=o;var r=!0}catch(a){}var i=pe.call(t);r&&(e?t[on]=n:delete t[on]);return i}(t):function(t){return pe.call(t)}(t)}function $r(t,e){return t>e}function ti(t,e){return null!=t&&he.call(t,e)}function ei(t,e){return null!=t&&e in ee(t)}function ni(t,e,n){for(var i=n?Ze:Je,a=t[0].length,s=t.length,u=s,c=r(s),h=1/0,l=[];u--;){var f=t[u];u&&e&&(f=$e(f,gn(e))),h=Kn(f.length,h),c[u]=!n&&(e||a>=120&&f.length>=120)?new wr(u&&f):o}f=t[0];var p=-1,d=c[0];t:for(;++p<a&&l.length<h;){var m=f[p],y=e?e(m):m;if(m=n||0!==m?m:0,!(d?_n(d,y):i(l,y,n))){for(u=s;--u;){var g=c[u];if(!(g?_n(g,y):i(t[u],y,n)))continue t}d&&d.push(y),l.push(m)}}return l}function ri(t,e,n){var r=null==(t=ea(t,e=Ki(e,t)))?t:t[ha(Ta(e))];return null==r?o:Qe(r,t,n)}function ii(t){return Ns(t)&&Zr(t)==B}function oi(t,e,n,r,i){return t===e||(null==t||null==e||!Ns(t)&&!Ns(e)?t!=t&&e!=e:function(t,e,n,r,i,a){var s=gs(t),u=gs(e),c=s?j:jo(t),h=u?j:jo(e),l=(c=c==B?$:c)==$,f=(h=h==B?$:h)==$,p=c==h;if(p&&ws(t)){if(!ws(e))return!1;s=!0,l=!1}if(p&&!l)return a||(a=new Er),s||Ls(t)?Ao(t,e,n,r,i,a):function(t,e,n,r,i,o,a){switch(n){case ct:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case ut:return!(t.byteLength!=e.byteLength||!o(new Ee(t),new Ee(e)));case W:case Q:case J:return ps(+t,+e);case H:return t.name==e.name&&t.message==e.message;case et:case rt:return t==e+"";case X:var s=In;case nt:var u=r&m;if(s||(s=An),t.size!=e.size&&!u)return!1;var c=a.get(t);if(c)return c==e;r|=y,a.set(t,e);var h=Ao(s(t),s(e),r,i,o,a);return a.delete(t),h;case it:if(lr)return lr.call(t)==lr.call(e)}return!1}(t,e,c,n,r,i,a);if(!(n&m)){var d=l&&he.call(t,"__wrapped__"),g=f&&he.call(e,"__wrapped__");if(d||g){var v=d?t.value():t,_=g?e.value():e;return a||(a=new Er),i(v,_,n,r,a)}}if(!p)return!1;return a||(a=new Er),function(t,e,n,r,i,a){var s=n&m,u=Ro(t),c=u.length,h=Ro(e).length;if(c!=h&&!s)return!1;var l=c;for(;l--;){var f=u[l];if(!(s?f in e:he.call(e,f)))return!1}var p=a.get(t);if(p&&a.get(e))return p==e;var d=!0;a.set(t,e),a.set(e,t);var y=s;for(;++l<c;){f=u[l];var g=t[f],v=e[f];if(r)var _=s?r(v,g,f,e,t,a):r(g,v,f,t,e,a);if(!(_===o?g===v||i(g,v,n,r,a):_)){d=!1;break}y||(y="constructor"==f)}if(d&&!y){var b=t.constructor,w=e.constructor;b!=w&&"constructor"in t&&"constructor"in e&&!("function"==typeof b&&b instanceof b&&"function"==typeof w&&w instanceof w)&&(d=!1)}return a.delete(t),a.delete(e),d}(t,e,n,r,i,a)}(t,e,n,r,oi,i))}function ai(t,e,n,r){var i=n.length,a=i,s=!r;if(null==t)return!a;for(t=ee(t);i--;){var u=n[i];if(s&&u[2]?u[1]!==t[u[0]]:!(u[0]in t))return!1}for(;++i<a;){var c=(u=n[i])[0],h=t[c],l=u[1];if(s&&u[2]){if(h===o&&!(c in t))return!1}else{var f=new Er;if(r)var p=r(h,l,c,t,e,f);if(!(p===o?oi(l,h,m|y,r,f):p))return!1}}return!0}function si(t){return!(!Ds(t)||(e=t,fe&&fe in e))&&(Cs(t)?ye:Kt).test(la(t));var e}function ui(t){return"function"==typeof t?t:null==t?ku:"object"==typeof t?gs(t)?di(t[0],t[1]):pi(t):qu(t)}function ci(t){if(!Jo(t))return Wn(t);var e=[];for(var n in ee(t))he.call(t,n)&&"constructor"!=n&&e.push(n);return e}function hi(t){if(!Ds(t))return function(t){var e=[];if(null!=t)for(var n in ee(t))e.push(n);return e}(t);var e=Jo(t),n=[];for(var r in t)("constructor"!=r||!e&&he.call(t,r))&&n.push(r);return n}function li(t,e){return t<e}function fi(t,e){var n=-1,i=_s(t)?r(t.length):[];return qr(t,(function(t,r,o){i[++n]=e(t,r,o)})),i}function pi(t){var e=Uo(t);return 1==e.length&&e[0][2]?$o(e[0][0],e[0][1]):function(n){return n===t||ai(n,t,e)}}function di(t,e){return Go(t)&&Zo(e)?$o(ha(t),e):function(n){var r=$s(n,t);return r===o&&r===e?tu(n,t):oi(e,r,m|y)}}function mi(t,e,n,r,i){t!==e&&Qr(e,(function(a,s){if(i||(i=new Er),Ds(a))!function(t,e,n,r,i,a,s){var u=na(t,n),c=na(e,n),h=s.get(c);if(h)return void Dr(t,n,h);var l=a?a(u,c,n+"",t,e,s):o,f=l===o;if(f){var p=gs(c),d=!p&&ws(c),m=!p&&!d&&Ls(c);l=c,p||d||m?gs(u)?l=u:bs(u)?l=no(u):d?(f=!1,l=Xi(c,!0)):m?(f=!1,l=Zi(c,!0)):l=[]:Rs(c)||ys(c)?(l=u,ys(u)?l=Ws(u):Ds(u)&&!Cs(u)||(l=Wo(c))):f=!1}f&&(s.set(c,l),i(l,c,r,a,s),s.delete(c));Dr(t,n,l)}(t,e,s,n,mi,r,i);else{var u=r?r(na(t,s),a,s+"",t,e,i):o;u===o&&(u=a),Dr(t,s,u)}}),ou)}function yi(t,e){var n=t.length;if(n)return Ko(e+=e<0?n:0,n)?t[e]:o}function gi(t,e,n){var r=-1;return e=$e(e.length?e:[ku],gn(Lo())),function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}(fi(t,(function(t,n,i){return{criteria:$e(e,(function(e){return e(t)})),index:++r,value:t}})),(function(t,e){return function(t,e,n){var r=-1,i=t.criteria,o=e.criteria,a=i.length,s=n.length;for(;++r<a;){var u=$i(i[r],o[r]);if(u){if(r>=s)return u;var c=n[r];return u*("desc"==c?-1:1)}}return t.index-e.index}(t,e,n)}))}function vi(t,e,n){for(var r=-1,i=e.length,o={};++r<i;){var a=e[r],s=Xr(t,a);n(s,a)&&Ii(o,Ki(a,t),s)}return o}function _i(t,e,n,r){var i=r?cn:un,o=-1,a=e.length,s=t;for(t===e&&(e=no(e)),n&&(s=$e(t,gn(n)));++o<a;)for(var u=0,c=e[o],h=n?n(c):c;(u=i(s,h,u,r))>-1;)s!==t&&Me.call(s,u,1),Me.call(t,u,1);return t}function bi(t,e){for(var n=t?e.length:0,r=n-1;n--;){var i=e[n];if(n==r||i!==o){var o=i;Ko(i)?Me.call(t,i,1):Ui(t,i)}}return t}function wi(t,e){return t+qn(Yn()*(e-t+1))}function Ei(t,e){var n="";if(!t||e<1||e>P)return n;do{e%2&&(n+=t),(e=qn(e/2))&&(t+=t)}while(e);return n}function Ti(t,e){return oa(ta(t,e,ku),t+"")}function Ci(t){return Cr(pu(t))}function Si(t,e){var n=pu(t);return ua(n,Pr(e,0,n.length))}function Ii(t,e,n,r){if(!Ds(t))return t;for(var i=-1,a=(e=Ki(e,t)).length,s=a-1,u=t;null!=u&&++i<a;){var c=ha(e[i]),h=n;if(i!=s){var l=u[c];(h=r?r(l,c,u):o)===o&&(h=Ds(l)?l:Ko(e[i+1])?[]:{})}Nr(u,c,h),u=u[c]}return t}var Di=rr?function(t,e){return rr.set(t,e),t}:ku,Ni=pn?function(t,e){return pn(t,"toString",{configurable:!0,enumerable:!1,value:Du(e),writable:!0})}:ku;function Ai(t){return ua(pu(t))}function ki(t,e,n){var i=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var a=r(o);++i<o;)a[i]=t[i+e];return a}function Ri(t,e){var n;return qr(t,(function(t,r,i){return!(n=e(t,r,i))})),!!n}function Oi(t,e,n){var r=0,i=null==t?r:t.length;if("number"==typeof e&&e==e&&i<=q){for(;r<i;){var o=r+i>>>1,a=t[o];null!==a&&!Ms(a)&&(n?a<=e:a<e)?r=o+1:i=o}return i}return xi(t,e,ku,n)}function xi(t,e,n,r){e=n(e);for(var i=0,a=null==t?0:t.length,s=e!=e,u=null===e,c=Ms(e),h=e===o;i<a;){var l=qn((i+a)/2),f=n(t[l]),p=f!==o,d=null===f,m=f==f,y=Ms(f);if(s)var g=r||m;else g=h?m&&(r||p):u?m&&p&&(r||!d):c?m&&p&&!d&&(r||!y):!d&&!y&&(r?f<=e:f<e);g?i=l+1:a=l}return Kn(a,U)}function Pi(t,e){for(var n=-1,r=t.length,i=0,o=[];++n<r;){var a=t[n],s=e?e(a):a;if(!n||!ps(s,u)){var u=s;o[i++]=0===a?0:a}}return o}function Mi(t){return"number"==typeof t?t:Ms(t)?L:+t}function Li(t){if("string"==typeof t)return t;if(gs(t))return $e(t,Li)+"";if(Ms(t))return fr?fr.call(t):"";var e=t+"";return"0"==e&&1/t==-x?"-0":e}function Fi(t,e,n){var r=-1,i=Je,o=t.length,s=!0,u=[],c=u;if(n)s=!1,i=Ze;else if(o>=a){var h=e?null:To(t);if(h)return An(h);s=!1,i=_n,c=new wr}else c=e?[]:u;t:for(;++r<o;){var l=t[r],f=e?e(l):l;if(l=n||0!==l?l:0,s&&f==f){for(var p=c.length;p--;)if(c[p]===f)continue t;e&&c.push(f),u.push(l)}else i(c,f,n)||(c!==u&&c.push(f),u.push(l))}return u}function Ui(t,e){return null==(t=ea(t,e=Ki(e,t)))||delete t[ha(Ta(e))]}function qi(t,e,n,r){return Ii(t,e,n(Xr(t,e)),r)}function Vi(t,e,n,r){for(var i=t.length,o=r?i:-1;(r?o--:++o<i)&&e(t[o],o,t););return n?ki(t,r?0:o,r?o+1:i):ki(t,r?o+1:0,r?i:o)}function Bi(t,e){var n=t;return n instanceof gr&&(n=n.value()),en(e,(function(t,e){return e.func.apply(e.thisArg,tn([t],e.args))}),n)}function ji(t,e,n){var i=t.length;if(i<2)return i?Fi(t[0]):[];for(var o=-1,a=r(i);++o<i;)for(var s=t[o],u=-1;++u<i;)u!=o&&(a[o]=Ur(a[o]||s,t[u],e,n));return Fi(Wr(a,1),e,n)}function zi(t,e,n){for(var r=-1,i=t.length,a=e.length,s={};++r<i;){var u=r<a?e[r]:o;n(s,t[r],u)}return s}function Wi(t){return bs(t)?t:[]}function Qi(t){return"function"==typeof t?t:ku}function Ki(t,e){return gs(t)?t:Go(t,e)?[t]:ca(Qs(t))}var Hi=Ti;function Gi(t,e,n){var r=t.length;return n=n===o?r:n,!e&&n>=r?t:ki(t,e,n)}var Yi=Mn||function(t){return xe.clearTimeout(t)};function Xi(t,e){if(e)return t.slice();var n=t.length,r=Ne?Ne(n):new t.constructor(n);return t.copy(r),r}function Ji(t){var e=new t.constructor(t.byteLength);return new Ee(e).set(new Ee(t)),e}function Zi(t,e){var n=e?Ji(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function $i(t,e){if(t!==e){var n=t!==o,r=null===t,i=t==t,a=Ms(t),s=e!==o,u=null===e,c=e==e,h=Ms(e);if(!u&&!h&&!a&&t>e||a&&s&&c&&!u&&!h||r&&s&&c||!n&&c||!i)return 1;if(!r&&!a&&!h&&t<e||h&&n&&i&&!r&&!a||u&&n&&i||!s&&i||!c)return-1}return 0}function to(t,e,n,i){for(var o=-1,a=t.length,s=n.length,u=-1,c=e.length,h=Qn(a-s,0),l=r(c+h),f=!i;++u<c;)l[u]=e[u];for(;++o<s;)(f||o<a)&&(l[n[o]]=t[o]);for(;h--;)l[u++]=t[o++];return l}function eo(t,e,n,i){for(var o=-1,a=t.length,s=-1,u=n.length,c=-1,h=e.length,l=Qn(a-u,0),f=r(l+h),p=!i;++o<l;)f[o]=t[o];for(var d=o;++c<h;)f[d+c]=e[c];for(;++s<u;)(p||o<a)&&(f[d+n[s]]=t[o++]);return f}function no(t,e){var n=-1,i=t.length;for(e||(e=r(i));++n<i;)e[n]=t[n];return e}function ro(t,e,n,r){var i=!n;n||(n={});for(var a=-1,s=e.length;++a<s;){var u=e[a],c=r?r(n[u],t[u],u,n,t):o;c===o&&(c=t[u]),i?Or(n,u,c):Nr(n,u,c)}return n}function io(t,e){return function(n,r){var i=gs(n)?Ke:kr,o=e?e():{};return i(n,t,Lo(r,2),o)}}function oo(t){return Ti((function(e,n){var r=-1,i=n.length,a=i>1?n[i-1]:o,s=i>2?n[2]:o;for(a=t.length>3&&"function"==typeof a?(i--,a):o,s&&Ho(n[0],n[1],s)&&(a=i<3?o:a,i=1),e=ee(e);++r<i;){var u=n[r];u&&t(e,u,r,a)}return e}))}function ao(t,e){return function(n,r){if(null==n)return n;if(!_s(n))return t(n,r);for(var i=n.length,o=e?i:-1,a=ee(n);(e?o--:++o<i)&&!1!==r(a[o],o,a););return n}}function so(t){return function(e,n,r){for(var i=-1,o=ee(e),a=r(e),s=a.length;s--;){var u=a[t?s:++i];if(!1===n(o[u],u,o))break}return e}}function uo(t){return function(e){var n=Sn(e=Qs(e))?On(e):o,r=n?n[0]:e.charAt(0),i=n?Gi(n,1).join(""):e.slice(1);return r[t]()+i}}function co(t){return function(e){return en(Cu(yu(e).replace(ve,"")),t,"")}}function ho(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var n=dr(t.prototype),r=t.apply(n,e);return Ds(r)?r:n}}function lo(t){return function(e,n,r){var i=ee(e);if(!_s(e)){var a=Lo(n,3);e=iu(e),n=function(t){return a(i[t],t,i)}}var s=t(e,n,r);return s>-1?i[a?e[s]:s]:o}}function fo(t){return ko((function(e){var n=e.length,r=n,i=yr.prototype.thru;for(t&&e.reverse();r--;){var a=e[r];if("function"!=typeof a)throw new ie(u);if(i&&!s&&"wrapper"==Po(a))var s=new yr([],!0)}for(r=s?r:n;++r<n;){var c=Po(a=e[r]),h="wrapper"==c?xo(a):o;s=h&&Yo(h[0])&&h[1]==(C|b|E|S)&&!h[4].length&&1==h[9]?s[Po(h[0])].apply(s,h[3]):1==a.length&&Yo(a)?s[c]():s.thru(a)}return function(){var t=arguments,r=t[0];if(s&&1==t.length&&gs(r))return s.plant(r).value();for(var i=0,o=n?e[i].apply(this,t):r;++i<n;)o=e[i].call(this,o);return o}}))}function po(t,e,n,i,a,s,u,c,h,l){var f=e&C,p=e&g,d=e&v,m=e&(b|w),y=e&I,_=d?o:ho(t);return function g(){for(var v=arguments.length,b=r(v),w=v;w--;)b[w]=arguments[w];if(m)var E=Mo(g),T=function(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}(b,E);if(i&&(b=to(b,i,a,m)),s&&(b=eo(b,s,u,m)),v-=T,m&&v<l){var C=Nn(b,E);return wo(t,e,po,g.placeholder,n,b,C,c,h,l-v)}var S=p?n:this,I=d?S[t]:t;return v=b.length,c?b=function(t,e){var n=t.length,r=Kn(e.length,n),i=no(t);for(;r--;){var a=e[r];t[r]=Ko(a,n)?i[a]:o}return t}(b,c):y&&v>1&&b.reverse(),f&&h<v&&(b.length=h),this&&this!==xe&&this instanceof g&&(I=_||ho(I)),I.apply(S,b)}}function mo(t,e){return function(n,r){return function(t,e,n,r){return Hr(t,(function(t,i,o){e(r,n(t),i,o)})),r}(n,t,e(r),{})}}function yo(t,e){return function(n,r){var i;if(n===o&&r===o)return e;if(n!==o&&(i=n),r!==o){if(i===o)return r;"string"==typeof n||"string"==typeof r?(n=Li(n),r=Li(r)):(n=Mi(n),r=Mi(r)),i=t(n,r)}return i}}function go(t){return ko((function(e){return e=$e(e,gn(Lo())),Ti((function(n){var r=this;return t(e,(function(t){return Qe(t,r,n)}))}))}))}function vo(t,e){var n=(e=e===o?" ":Li(e)).length;if(n<2)return n?Ei(e,t):e;var r=Ei(e,Un(t/Rn(e)));return Sn(e)?Gi(On(r),0,t).join(""):r.slice(0,t)}function _o(t){return function(e,n,i){return i&&"number"!=typeof i&&Ho(e,n,i)&&(n=i=o),e=Vs(e),n===o?(n=e,e=0):n=Vs(n),function(t,e,n,i){for(var o=-1,a=Qn(Un((e-t)/(n||1)),0),s=r(a);a--;)s[i?a:++o]=t,t+=n;return s}(e,n,i=i===o?e<n?1:-1:Vs(i),t)}}function bo(t){return function(e,n){return"string"==typeof e&&"string"==typeof n||(e=zs(e),n=zs(n)),t(e,n)}}function wo(t,e,n,r,i,a,s,u,c,h){var l=e&b;e|=l?E:T,(e&=~(l?T:E))&_||(e&=~(g|v));var f=[t,e,i,l?a:o,l?s:o,l?o:a,l?o:s,u,c,h],p=n.apply(o,f);return Yo(t)&&ra(p,f),p.placeholder=r,aa(p,t,e)}function Eo(t){var e=te[t];return function(t,n){if(t=zs(t),(n=null==n?0:Kn(Bs(n),292))&&jn(t)){var r=(Qs(t)+"e").split("e");return+((r=(Qs(e(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return e(t)}}var To=tr&&1/An(new tr([,-0]))[1]==x?function(t){return new tr(t)}:Mu;function Co(t){return function(e){var n=jo(e);return n==X?In(e):n==nt?kn(e):function(t,e){return $e(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function So(t,e,n,i,a,s,c,h){var f=e&v;if(!f&&"function"!=typeof t)throw new ie(u);var p=i?i.length:0;if(p||(e&=~(E|T),i=a=o),c=c===o?c:Qn(Bs(c),0),h=h===o?h:Bs(h),p-=a?a.length:0,e&T){var d=i,m=a;i=a=o}var y=f?o:xo(t),I=[t,e,n,i,a,d,m,s,c,h];if(y&&function(t,e){var n=t[1],r=e[1],i=n|r,o=i<(g|v|C),a=r==C&&n==b||r==C&&n==S&&t[7].length<=e[8]||r==(C|S)&&e[7].length<=e[8]&&n==b;if(!o&&!a)return t;r&g&&(t[2]=e[2],i|=n&g?0:_);var s=e[3];if(s){var u=t[3];t[3]=u?to(u,s,e[4]):s,t[4]=u?Nn(t[3],l):e[4]}(s=e[5])&&(u=t[5],t[5]=u?eo(u,s,e[6]):s,t[6]=u?Nn(t[5],l):e[6]);(s=e[7])&&(t[7]=s);r&C&&(t[8]=null==t[8]?e[8]:Kn(t[8],e[8]));null==t[9]&&(t[9]=e[9]);t[0]=e[0],t[1]=i}(I,y),t=I[0],e=I[1],n=I[2],i=I[3],a=I[4],!(h=I[9]=I[9]===o?f?0:t.length:Qn(I[9]-p,0))&&e&(b|w)&&(e&=~(b|w)),e&&e!=g)D=e==b||e==w?function(t,e,n){var i=ho(t);return function a(){for(var s=arguments.length,u=r(s),c=s,h=Mo(a);c--;)u[c]=arguments[c];var l=s<3&&u[0]!==h&&u[s-1]!==h?[]:Nn(u,h);return(s-=l.length)<n?wo(t,e,po,a.placeholder,o,u,l,o,o,n-s):Qe(this&&this!==xe&&this instanceof a?i:t,this,u)}}(t,e,h):e!=E&&e!=(g|E)||a.length?po.apply(o,I):function(t,e,n,i){var o=e&g,a=ho(t);return function e(){for(var s=-1,u=arguments.length,c=-1,h=i.length,l=r(h+u),f=this&&this!==xe&&this instanceof e?a:t;++c<h;)l[c]=i[c];for(;u--;)l[c++]=arguments[++s];return Qe(f,o?n:this,l)}}(t,e,n,i);else var D=function(t,e,n){var r=e&g,i=ho(t);return function e(){return(this&&this!==xe&&this instanceof e?i:t).apply(r?n:this,arguments)}}(t,e,n);return aa((y?Di:ra)(D,I),t,e)}function Io(t,e,n,r){return t===o||ps(t,se[n])&&!he.call(r,n)?e:t}function Do(t,e,n,r,i,a){return Ds(t)&&Ds(e)&&(a.set(e,t),mi(t,e,o,Do,a),a.delete(e)),t}function No(t){return Rs(t)?o:t}function Ao(t,e,n,r,i,a){var s=n&m,u=t.length,c=e.length;if(u!=c&&!(s&&c>u))return!1;var h=a.get(t);if(h&&a.get(e))return h==e;var l=-1,f=!0,p=n&y?new wr:o;for(a.set(t,e),a.set(e,t);++l<u;){var d=t[l],g=e[l];if(r)var v=s?r(g,d,l,e,t,a):r(d,g,l,t,e,a);if(v!==o){if(v)continue;f=!1;break}if(p){if(!rn(e,(function(t,e){if(!_n(p,e)&&(d===t||i(d,t,n,r,a)))return p.push(e)}))){f=!1;break}}else if(d!==g&&!i(d,g,n,r,a)){f=!1;break}}return a.delete(t),a.delete(e),f}function ko(t){return oa(ta(t,o,va),t+"")}function Ro(t){return Jr(t,iu,Vo)}function Oo(t){return Jr(t,ou,Bo)}var xo=rr?function(t){return rr.get(t)}:Mu;function Po(t){for(var e=t.name+"",n=ir[e],r=he.call(ir,e)?n.length:0;r--;){var i=n[r],o=i.func;if(null==o||o==t)return i.name}return e}function Mo(t){return(he.call(pr,"placeholder")?pr:t).placeholder}function Lo(){var t=pr.iteratee||Ru;return t=t===Ru?ui:t,arguments.length?t(arguments[0],arguments[1]):t}function Fo(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function Uo(t){for(var e=iu(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,Zo(i)]}return e}function qo(t,e){var n=function(t,e){return null==t?o:t[e]}(t,e);return si(n)?n:o}var Vo=Vn?function(t){return null==t?[]:(t=ee(t),Xe(Vn(t),(function(e){return Pe.call(t,e)})))}:ju,Bo=Vn?function(t){for(var e=[];t;)tn(e,Vo(t)),t=Re(t);return e}:ju,jo=Zr;function zo(t,e,n){for(var r=-1,i=(e=Ki(e,t)).length,o=!1;++r<i;){var a=ha(e[r]);if(!(o=null!=t&&n(t,a)))break;t=t[a]}return o||++r!=i?o:!!(i=null==t?0:t.length)&&Is(i)&&Ko(a,i)&&(gs(t)||ys(t))}function Wo(t){return"function"!=typeof t.constructor||Jo(t)?{}:dr(Re(t))}function Qo(t){return gs(t)||ys(t)||!!(Fe&&t&&t[Fe])}function Ko(t,e){var n=typeof t;return!!(e=null==e?P:e)&&("number"==n||"symbol"!=n&&Gt.test(t))&&t>-1&&t%1==0&&t<e}function Ho(t,e,n){if(!Ds(n))return!1;var r=typeof e;return!!("number"==r?_s(n)&&Ko(e,n.length):"string"==r&&e in n)&&ps(n[e],t)}function Go(t,e){if(gs(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!Ms(t))||(kt.test(t)||!At.test(t)||null!=e&&t in ee(e))}function Yo(t){var e=Po(t),n=pr[e];if("function"!=typeof n||!(e in gr.prototype))return!1;if(t===n)return!0;var r=xo(n);return!!r&&t===r[0]}(Jn&&jo(new Jn(new ArrayBuffer(1)))!=ct||Zn&&jo(new Zn)!=X||$n&&"[object Promise]"!=jo($n.resolve())||tr&&jo(new tr)!=nt||er&&jo(new er)!=at)&&(jo=function(t){var e=Zr(t),n=e==$?t.constructor:o,r=n?la(n):"";if(r)switch(r){case or:return ct;case ar:return X;case sr:return"[object Promise]";case ur:return nt;case cr:return at}return e});var Xo=ue?Cs:zu;function Jo(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||se)}function Zo(t){return t==t&&!Ds(t)}function $o(t,e){return function(n){return null!=n&&(n[t]===e&&(e!==o||t in ee(n)))}}function ta(t,e,n){return e=Qn(e===o?t.length-1:e,0),function(){for(var i=arguments,o=-1,a=Qn(i.length-e,0),s=r(a);++o<a;)s[o]=i[e+o];o=-1;for(var u=r(e+1);++o<e;)u[o]=i[o];return u[e]=n(s),Qe(t,this,u)}}function ea(t,e){return e.length<2?t:Xr(t,ki(e,0,-1))}function na(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var ra=sa(Di),ia=Fn||function(t,e){return xe.setTimeout(t,e)},oa=sa(Ni);function aa(t,e,n){var r=e+"";return oa(t,function(t,e){var n=e.length;if(!n)return t;var r=n-1;return e[r]=(n>1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(Ft,"{\n/* [wrapped with "+e+"] */\n")}(r,function(t,e){return He(V,(function(n){var r="_."+n[0];e&n[1]&&!Je(t,r)&&t.push(r)})),t.sort()}(function(t){var e=t.match(Ut);return e?e[1].split(qt):[]}(r),n)))}function sa(t){var e=0,n=0;return function(){var r=Hn(),i=k-(r-n);if(n=r,i>0){if(++e>=A)return arguments[0]}else e=0;return t.apply(o,arguments)}}function ua(t,e){var n=-1,r=t.length,i=r-1;for(e=e===o?r:e;++n<e;){var a=wi(n,i),s=t[a];t[a]=t[n],t[n]=s}return t.length=e,t}var ca=function(t){var e=ss(t,(function(t){return n.size===h&&n.clear(),t})),n=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Rt,(function(t,n,r,i){e.push(r?i.replace(Bt,"$1"):n||t)})),e}));function ha(t){if("string"==typeof t||Ms(t))return t;var e=t+"";return"0"==e&&1/t==-x?"-0":e}function la(t){if(null!=t){try{return ce.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function fa(t){if(t instanceof gr)return t.clone();var e=new yr(t.__wrapped__,t.__chain__);return e.__actions__=no(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var pa=Ti((function(t,e){return bs(t)?Ur(t,Wr(e,1,bs,!0)):[]})),da=Ti((function(t,e){var n=Ta(e);return bs(n)&&(n=o),bs(t)?Ur(t,Wr(e,1,bs,!0),Lo(n,2)):[]})),ma=Ti((function(t,e){var n=Ta(e);return bs(n)&&(n=o),bs(t)?Ur(t,Wr(e,1,bs,!0),o,n):[]}));function ya(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:Bs(n);return i<0&&(i=Qn(r+i,0)),sn(t,Lo(e,3),i)}function ga(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r-1;return n!==o&&(i=Bs(n),i=n<0?Qn(r+i,0):Kn(i,r-1)),sn(t,Lo(e,3),i,!0)}function va(t){return(null==t?0:t.length)?Wr(t,1):[]}function _a(t){return t&&t.length?t[0]:o}var ba=Ti((function(t){var e=$e(t,Wi);return e.length&&e[0]===t[0]?ni(e):[]})),wa=Ti((function(t){var e=Ta(t),n=$e(t,Wi);return e===Ta(n)?e=o:n.pop(),n.length&&n[0]===t[0]?ni(n,Lo(e,2)):[]})),Ea=Ti((function(t){var e=Ta(t),n=$e(t,Wi);return(e="function"==typeof e?e:o)&&n.pop(),n.length&&n[0]===t[0]?ni(n,o,e):[]}));function Ta(t){var e=null==t?0:t.length;return e?t[e-1]:o}var Ca=Ti(Sa);function Sa(t,e){return t&&t.length&&e&&e.length?_i(t,e):t}var Ia=ko((function(t,e){var n=null==t?0:t.length,r=xr(t,e);return bi(t,$e(e,(function(t){return Ko(t,n)?+t:t})).sort($i)),r}));function Da(t){return null==t?t:Xn.call(t)}var Na=Ti((function(t){return Fi(Wr(t,1,bs,!0))})),Aa=Ti((function(t){var e=Ta(t);return bs(e)&&(e=o),Fi(Wr(t,1,bs,!0),Lo(e,2))})),ka=Ti((function(t){var e=Ta(t);return e="function"==typeof e?e:o,Fi(Wr(t,1,bs,!0),o,e)}));function Ra(t){if(!t||!t.length)return[];var e=0;return t=Xe(t,(function(t){if(bs(t))return e=Qn(t.length,e),!0})),yn(e,(function(e){return $e(t,fn(e))}))}function Oa(t,e){if(!t||!t.length)return[];var n=Ra(t);return null==e?n:$e(n,(function(t){return Qe(e,o,t)}))}var xa=Ti((function(t,e){return bs(t)?Ur(t,e):[]})),Pa=Ti((function(t){return ji(Xe(t,bs))})),Ma=Ti((function(t){var e=Ta(t);return bs(e)&&(e=o),ji(Xe(t,bs),Lo(e,2))})),La=Ti((function(t){var e=Ta(t);return e="function"==typeof e?e:o,ji(Xe(t,bs),o,e)})),Fa=Ti(Ra);var Ua=Ti((function(t){var e=t.length,n=e>1?t[e-1]:o;return n="function"==typeof n?(t.pop(),n):o,Oa(t,n)}));function qa(t){var e=pr(t);return e.__chain__=!0,e}function Va(t,e){return e(t)}var Ba=ko((function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,i=function(e){return xr(e,t)};return!(e>1||this.__actions__.length)&&r instanceof gr&&Ko(n)?((r=r.slice(n,+n+(e?1:0))).__actions__.push({func:Va,args:[i],thisArg:o}),new yr(r,this.__chain__).thru((function(t){return e&&!t.length&&t.push(o),t}))):this.thru(i)}));var ja=io((function(t,e,n){he.call(t,n)?++t[n]:Or(t,n,1)}));var za=lo(ya),Wa=lo(ga);function Qa(t,e){return(gs(t)?He:qr)(t,Lo(e,3))}function Ka(t,e){return(gs(t)?Ge:Vr)(t,Lo(e,3))}var Ha=io((function(t,e,n){he.call(t,n)?t[n].push(e):Or(t,n,[e])}));var Ga=Ti((function(t,e,n){var i=-1,o="function"==typeof e,a=_s(t)?r(t.length):[];return qr(t,(function(t){a[++i]=o?Qe(e,t,n):ri(t,e,n)})),a})),Ya=io((function(t,e,n){Or(t,n,e)}));function Xa(t,e){return(gs(t)?$e:fi)(t,Lo(e,3))}var Ja=io((function(t,e,n){t[n?0:1].push(e)}),(function(){return[[],[]]}));var Za=Ti((function(t,e){if(null==t)return[];var n=e.length;return n>1&&Ho(t,e[0],e[1])?e=[]:n>2&&Ho(e[0],e[1],e[2])&&(e=[e[0]]),gi(t,Wr(e,1),[])})),$a=Ln||function(){return xe.Date.now()};function ts(t,e,n){return e=n?o:e,e=t&&null==e?t.length:e,So(t,C,o,o,o,o,e)}function es(t,e){var n;if("function"!=typeof e)throw new ie(u);return t=Bs(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=o),n}}var ns=Ti((function(t,e,n){var r=g;if(n.length){var i=Nn(n,Mo(ns));r|=E}return So(t,r,e,n,i)})),rs=Ti((function(t,e,n){var r=g|v;if(n.length){var i=Nn(n,Mo(rs));r|=E}return So(e,r,t,n,i)}));function is(t,e,n){var r,i,a,s,c,h,l=0,f=!1,p=!1,d=!0;if("function"!=typeof t)throw new ie(u);function m(e){var n=r,a=i;return r=i=o,l=e,s=t.apply(a,n)}function y(t){var n=t-h;return h===o||n>=e||n<0||p&&t-l>=a}function g(){var t=$a();if(y(t))return v(t);c=ia(g,function(t){var n=e-(t-h);return p?Kn(n,a-(t-l)):n}(t))}function v(t){return c=o,d&&r?m(t):(r=i=o,s)}function _(){var t=$a(),n=y(t);if(r=arguments,i=this,h=t,n){if(c===o)return function(t){return l=t,c=ia(g,e),f?m(t):s}(h);if(p)return Yi(c),c=ia(g,e),m(h)}return c===o&&(c=ia(g,e)),s}return e=zs(e)||0,Ds(n)&&(f=!!n.leading,a=(p="maxWait"in n)?Qn(zs(n.maxWait)||0,e):a,d="trailing"in n?!!n.trailing:d),_.cancel=function(){c!==o&&Yi(c),l=0,r=h=i=c=o},_.flush=function(){return c===o?s:v($a())},_}var os=Ti((function(t,e){return Fr(t,1,e)})),as=Ti((function(t,e,n){return Fr(t,zs(e)||0,n)}));function ss(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(u);var n=function n(){var r=arguments,i=e?e.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=t.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(ss.Cache||br),n}function us(t){if("function"!=typeof t)throw new ie(u);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ss.Cache=br;var cs=Hi((function(t,e){var n=(e=1==e.length&&gs(e[0])?$e(e[0],gn(Lo())):$e(Wr(e,1),gn(Lo()))).length;return Ti((function(r){for(var i=-1,o=Kn(r.length,n);++i<o;)r[i]=e[i].call(this,r[i]);return Qe(t,this,r)}))})),hs=Ti((function(t,e){var n=Nn(e,Mo(hs));return So(t,E,o,e,n)})),ls=Ti((function(t,e){var n=Nn(e,Mo(ls));return So(t,T,o,e,n)})),fs=ko((function(t,e){return So(t,S,o,o,o,e)}));function ps(t,e){return t===e||t!=t&&e!=e}var ds=bo($r),ms=bo((function(t,e){return t>=e})),ys=ii(function(){return arguments}())?ii:function(t){return Ns(t)&&he.call(t,"callee")&&!Pe.call(t,"callee")},gs=r.isArray,vs=qe?gn(qe):function(t){return Ns(t)&&Zr(t)==ut};function _s(t){return null!=t&&Is(t.length)&&!Cs(t)}function bs(t){return Ns(t)&&_s(t)}var ws=Bn||zu,Es=Ve?gn(Ve):function(t){return Ns(t)&&Zr(t)==Q};function Ts(t){if(!Ns(t))return!1;var e=Zr(t);return e==H||e==K||"string"==typeof t.message&&"string"==typeof t.name&&!Rs(t)}function Cs(t){if(!Ds(t))return!1;var e=Zr(t);return e==G||e==Y||e==z||e==tt}function Ss(t){return"number"==typeof t&&t==Bs(t)}function Is(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=P}function Ds(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ns(t){return null!=t&&"object"==typeof t}var As=Be?gn(Be):function(t){return Ns(t)&&jo(t)==X};function ks(t){return"number"==typeof t||Ns(t)&&Zr(t)==J}function Rs(t){if(!Ns(t)||Zr(t)!=$)return!1;var e=Re(t);if(null===e)return!0;var n=he.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&ce.call(n)==de}var Os=je?gn(je):function(t){return Ns(t)&&Zr(t)==et};var xs=ze?gn(ze):function(t){return Ns(t)&&jo(t)==nt};function Ps(t){return"string"==typeof t||!gs(t)&&Ns(t)&&Zr(t)==rt}function Ms(t){return"symbol"==typeof t||Ns(t)&&Zr(t)==it}var Ls=We?gn(We):function(t){return Ns(t)&&Is(t.length)&&!!Ie[Zr(t)]};var Fs=bo(li),Us=bo((function(t,e){return t<=e}));function qs(t){if(!t)return[];if(_s(t))return Ps(t)?On(t):no(t);if(Ue&&t[Ue])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[Ue]());var e=jo(t);return(e==X?In:e==nt?An:pu)(t)}function Vs(t){return t?(t=zs(t))===x||t===-x?(t<0?-1:1)*M:t==t?t:0:0===t?t:0}function Bs(t){var e=Vs(t),n=e%1;return e==e?n?e-n:e:0}function js(t){return t?Pr(Bs(t),0,F):0}function zs(t){if("number"==typeof t)return t;if(Ms(t))return L;if(Ds(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ds(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Pt,"");var n=Qt.test(t);return n||Ht.test(t)?ke(t.slice(2),n?2:8):Wt.test(t)?L:+t}function Ws(t){return ro(t,ou(t))}function Qs(t){return null==t?"":Li(t)}var Ks=oo((function(t,e){if(Jo(e)||_s(e))ro(e,iu(e),t);else for(var n in e)he.call(e,n)&&Nr(t,n,e[n])})),Hs=oo((function(t,e){ro(e,ou(e),t)})),Gs=oo((function(t,e,n,r){ro(e,ou(e),t,r)})),Ys=oo((function(t,e,n,r){ro(e,iu(e),t,r)})),Xs=ko(xr);var Js=Ti((function(t,e){t=ee(t);var n=-1,r=e.length,i=r>2?e[2]:o;for(i&&Ho(e[0],e[1],i)&&(r=1);++n<r;)for(var a=e[n],s=ou(a),u=-1,c=s.length;++u<c;){var h=s[u],l=t[h];(l===o||ps(l,se[h])&&!he.call(t,h))&&(t[h]=a[h])}return t})),Zs=Ti((function(t){return t.push(o,Do),Qe(su,o,t)}));function $s(t,e,n){var r=null==t?o:Xr(t,e);return r===o?n:r}function tu(t,e){return null!=t&&zo(t,e,ei)}var eu=mo((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=pe.call(e)),t[e]=n}),Du(ku)),nu=mo((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=pe.call(e)),he.call(t,e)?t[e].push(n):t[e]=[n]}),Lo),ru=Ti(ri);function iu(t){return _s(t)?Tr(t):ci(t)}function ou(t){return _s(t)?Tr(t,!0):hi(t)}var au=oo((function(t,e,n){mi(t,e,n)})),su=oo((function(t,e,n,r){mi(t,e,n,r)})),uu=ko((function(t,e){var n={};if(null==t)return n;var r=!1;e=$e(e,(function(e){return e=Ki(e,t),r||(r=e.length>1),e})),ro(t,Oo(t),n),r&&(n=Mr(n,f|p|d,No));for(var i=e.length;i--;)Ui(n,e[i]);return n}));var cu=ko((function(t,e){return null==t?{}:function(t,e){return vi(t,e,(function(e,n){return tu(t,n)}))}(t,e)}));function hu(t,e){if(null==t)return{};var n=$e(Oo(t),(function(t){return[t]}));return e=Lo(e),vi(t,n,(function(t,n){return e(t,n[0])}))}var lu=Co(iu),fu=Co(ou);function pu(t){return null==t?[]:vn(t,iu(t))}var du=co((function(t,e,n){return e=e.toLowerCase(),t+(n?mu(e):e)}));function mu(t){return Tu(Qs(t).toLowerCase())}function yu(t){return(t=Qs(t))&&t.replace(Yt,En).replace(_e,"")}var gu=co((function(t,e,n){return t+(n?"-":"")+e.toLowerCase()})),vu=co((function(t,e,n){return t+(n?" ":"")+e.toLowerCase()})),_u=uo("toLowerCase");var bu=co((function(t,e,n){return t+(n?"_":"")+e.toLowerCase()}));var wu=co((function(t,e,n){return t+(n?" ":"")+Tu(e)}));var Eu=co((function(t,e,n){return t+(n?" ":"")+e.toUpperCase()})),Tu=uo("toUpperCase");function Cu(t,e,n){return t=Qs(t),(e=n?o:e)===o?function(t){return Te.test(t)}(t)?function(t){return t.match(we)||[]}(t):function(t){return t.match(Vt)||[]}(t):t.match(e)||[]}var Su=Ti((function(t,e){try{return Qe(t,o,e)}catch(n){return Ts(n)?n:new Zt(n)}})),Iu=ko((function(t,e){return He(e,(function(e){e=ha(e),Or(t,e,ns(t[e],t))})),t}));function Du(t){return function(){return t}}var Nu=fo(),Au=fo(!0);function ku(t){return t}function Ru(t){return ui("function"==typeof t?t:Mr(t,f))}var Ou=Ti((function(t,e){return function(n){return ri(n,t,e)}})),xu=Ti((function(t,e){return function(n){return ri(t,n,e)}}));function Pu(t,e,n){var r=iu(e),i=Yr(e,r);null!=n||Ds(e)&&(i.length||!r.length)||(n=e,e=t,t=this,i=Yr(e,iu(e)));var o=!(Ds(n)&&"chain"in n&&!n.chain),a=Cs(t);return He(i,(function(n){var r=e[n];t[n]=r,a&&(t.prototype[n]=function(){var e=this.__chain__;if(o||e){var n=t(this.__wrapped__),i=n.__actions__=no(this.__actions__);return i.push({func:r,args:arguments,thisArg:t}),n.__chain__=e,n}return r.apply(t,tn([this.value()],arguments))})})),t}function Mu(){}var Lu=go($e),Fu=go(Ye),Uu=go(rn);function qu(t){return Go(t)?fn(ha(t)):function(t){return function(e){return Xr(e,t)}}(t)}var Vu=_o(),Bu=_o(!0);function ju(){return[]}function zu(){return!1}var Wu=yo((function(t,e){return t+e}),0),Qu=Eo("ceil"),Ku=yo((function(t,e){return t/e}),1),Hu=Eo("floor");var Gu,Yu=yo((function(t,e){return t*e}),1),Xu=Eo("round"),Ju=yo((function(t,e){return t-e}),0);return pr.after=function(t,e){if("function"!=typeof e)throw new ie(u);return t=Bs(t),function(){if(--t<1)return e.apply(this,arguments)}},pr.ary=ts,pr.assign=Ks,pr.assignIn=Hs,pr.assignInWith=Gs,pr.assignWith=Ys,pr.at=Xs,pr.before=es,pr.bind=ns,pr.bindAll=Iu,pr.bindKey=rs,pr.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return gs(t)?t:[t]},pr.chain=qa,pr.chunk=function(t,e,n){e=(n?Ho(t,e,n):e===o)?1:Qn(Bs(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var a=0,s=0,u=r(Un(i/e));a<i;)u[s++]=ki(t,a,a+=e);return u},pr.compact=function(t){for(var e=-1,n=null==t?0:t.length,r=0,i=[];++e<n;){var o=t[e];o&&(i[r++]=o)}return i},pr.concat=function(){var t=arguments.length;if(!t)return[];for(var e=r(t-1),n=arguments[0],i=t;i--;)e[i-1]=arguments[i];return tn(gs(n)?no(n):[n],Wr(e,1))},pr.cond=function(t){var e=null==t?0:t.length,n=Lo();return t=e?$e(t,(function(t){if("function"!=typeof t[1])throw new ie(u);return[n(t[0]),t[1]]})):[],Ti((function(n){for(var r=-1;++r<e;){var i=t[r];if(Qe(i[0],this,n))return Qe(i[1],this,n)}}))},pr.conforms=function(t){return function(t){var e=iu(t);return function(n){return Lr(n,t,e)}}(Mr(t,f))},pr.constant=Du,pr.countBy=ja,pr.create=function(t,e){var n=dr(t);return null==e?n:Rr(n,e)},pr.curry=function t(e,n,r){var i=So(e,b,o,o,o,o,o,n=r?o:n);return i.placeholder=t.placeholder,i},pr.curryRight=function t(e,n,r){var i=So(e,w,o,o,o,o,o,n=r?o:n);return i.placeholder=t.placeholder,i},pr.debounce=is,pr.defaults=Js,pr.defaultsDeep=Zs,pr.defer=os,pr.delay=as,pr.difference=pa,pr.differenceBy=da,pr.differenceWith=ma,pr.drop=function(t,e,n){var r=null==t?0:t.length;return r?ki(t,(e=n||e===o?1:Bs(e))<0?0:e,r):[]},pr.dropRight=function(t,e,n){var r=null==t?0:t.length;return r?ki(t,0,(e=r-(e=n||e===o?1:Bs(e)))<0?0:e):[]},pr.dropRightWhile=function(t,e){return t&&t.length?Vi(t,Lo(e,3),!0,!0):[]},pr.dropWhile=function(t,e){return t&&t.length?Vi(t,Lo(e,3),!0):[]},pr.fill=function(t,e,n,r){var i=null==t?0:t.length;return i?(n&&"number"!=typeof n&&Ho(t,e,n)&&(n=0,r=i),function(t,e,n,r){var i=t.length;for((n=Bs(n))<0&&(n=-n>i?0:i+n),(r=r===o||r>i?i:Bs(r))<0&&(r+=i),r=n>r?0:js(r);n<r;)t[n++]=e;return t}(t,e,n,r)):[]},pr.filter=function(t,e){return(gs(t)?Xe:zr)(t,Lo(e,3))},pr.flatMap=function(t,e){return Wr(Xa(t,e),1)},pr.flatMapDeep=function(t,e){return Wr(Xa(t,e),x)},pr.flatMapDepth=function(t,e,n){return n=n===o?1:Bs(n),Wr(Xa(t,e),n)},pr.flatten=va,pr.flattenDeep=function(t){return(null==t?0:t.length)?Wr(t,x):[]},pr.flattenDepth=function(t,e){return(null==t?0:t.length)?Wr(t,e=e===o?1:Bs(e)):[]},pr.flip=function(t){return So(t,I)},pr.flow=Nu,pr.flowRight=Au,pr.fromPairs=function(t){for(var e=-1,n=null==t?0:t.length,r={};++e<n;){var i=t[e];r[i[0]]=i[1]}return r},pr.functions=function(t){return null==t?[]:Yr(t,iu(t))},pr.functionsIn=function(t){return null==t?[]:Yr(t,ou(t))},pr.groupBy=Ha,pr.initial=function(t){return(null==t?0:t.length)?ki(t,0,-1):[]},pr.intersection=ba,pr.intersectionBy=wa,pr.intersectionWith=Ea,pr.invert=eu,pr.invertBy=nu,pr.invokeMap=Ga,pr.iteratee=Ru,pr.keyBy=Ya,pr.keys=iu,pr.keysIn=ou,pr.map=Xa,pr.mapKeys=function(t,e){var n={};return e=Lo(e,3),Hr(t,(function(t,r,i){Or(n,e(t,r,i),t)})),n},pr.mapValues=function(t,e){var n={};return e=Lo(e,3),Hr(t,(function(t,r,i){Or(n,r,e(t,r,i))})),n},pr.matches=function(t){return pi(Mr(t,f))},pr.matchesProperty=function(t,e){return di(t,Mr(e,f))},pr.memoize=ss,pr.merge=au,pr.mergeWith=su,pr.method=Ou,pr.methodOf=xu,pr.mixin=Pu,pr.negate=us,pr.nthArg=function(t){return t=Bs(t),Ti((function(e){return yi(e,t)}))},pr.omit=uu,pr.omitBy=function(t,e){return hu(t,us(Lo(e)))},pr.once=function(t){return es(2,t)},pr.orderBy=function(t,e,n,r){return null==t?[]:(gs(e)||(e=null==e?[]:[e]),gs(n=r?o:n)||(n=null==n?[]:[n]),gi(t,e,n))},pr.over=Lu,pr.overArgs=cs,pr.overEvery=Fu,pr.overSome=Uu,pr.partial=hs,pr.partialRight=ls,pr.partition=Ja,pr.pick=cu,pr.pickBy=hu,pr.property=qu,pr.propertyOf=function(t){return function(e){return null==t?o:Xr(t,e)}},pr.pull=Ca,pr.pullAll=Sa,pr.pullAllBy=function(t,e,n){return t&&t.length&&e&&e.length?_i(t,e,Lo(n,2)):t},pr.pullAllWith=function(t,e,n){return t&&t.length&&e&&e.length?_i(t,e,o,n):t},pr.pullAt=Ia,pr.range=Vu,pr.rangeRight=Bu,pr.rearg=fs,pr.reject=function(t,e){return(gs(t)?Xe:zr)(t,us(Lo(e,3)))},pr.remove=function(t,e){var n=[];if(!t||!t.length)return n;var r=-1,i=[],o=t.length;for(e=Lo(e,3);++r<o;){var a=t[r];e(a,r,t)&&(n.push(a),i.push(r))}return bi(t,i),n},pr.rest=function(t,e){if("function"!=typeof t)throw new ie(u);return Ti(t,e=e===o?e:Bs(e))},pr.reverse=Da,pr.sampleSize=function(t,e,n){return e=(n?Ho(t,e,n):e===o)?1:Bs(e),(gs(t)?Sr:Si)(t,e)},pr.set=function(t,e,n){return null==t?t:Ii(t,e,n)},pr.setWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:Ii(t,e,n,r)},pr.shuffle=function(t){return(gs(t)?Ir:Ai)(t)},pr.slice=function(t,e,n){var r=null==t?0:t.length;return r?(n&&"number"!=typeof n&&Ho(t,e,n)?(e=0,n=r):(e=null==e?0:Bs(e),n=n===o?r:Bs(n)),ki(t,e,n)):[]},pr.sortBy=Za,pr.sortedUniq=function(t){return t&&t.length?Pi(t):[]},pr.sortedUniqBy=function(t,e){return t&&t.length?Pi(t,Lo(e,2)):[]},pr.split=function(t,e,n){return n&&"number"!=typeof n&&Ho(t,e,n)&&(e=n=o),(n=n===o?F:n>>>0)?(t=Qs(t))&&("string"==typeof e||null!=e&&!Os(e))&&!(e=Li(e))&&Sn(t)?Gi(On(t),0,n):t.split(e,n):[]},pr.spread=function(t,e){if("function"!=typeof t)throw new ie(u);return e=null==e?0:Qn(Bs(e),0),Ti((function(n){var r=n[e],i=Gi(n,0,e);return r&&tn(i,r),Qe(t,this,i)}))},pr.tail=function(t){var e=null==t?0:t.length;return e?ki(t,1,e):[]},pr.take=function(t,e,n){return t&&t.length?ki(t,0,(e=n||e===o?1:Bs(e))<0?0:e):[]},pr.takeRight=function(t,e,n){var r=null==t?0:t.length;return r?ki(t,(e=r-(e=n||e===o?1:Bs(e)))<0?0:e,r):[]},pr.takeRightWhile=function(t,e){return t&&t.length?Vi(t,Lo(e,3),!1,!0):[]},pr.takeWhile=function(t,e){return t&&t.length?Vi(t,Lo(e,3)):[]},pr.tap=function(t,e){return e(t),t},pr.throttle=function(t,e,n){var r=!0,i=!0;if("function"!=typeof t)throw new ie(u);return Ds(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),is(t,e,{leading:r,maxWait:e,trailing:i})},pr.thru=Va,pr.toArray=qs,pr.toPairs=lu,pr.toPairsIn=fu,pr.toPath=function(t){return gs(t)?$e(t,ha):Ms(t)?[t]:no(ca(Qs(t)))},pr.toPlainObject=Ws,pr.transform=function(t,e,n){var r=gs(t),i=r||ws(t)||Ls(t);if(e=Lo(e,4),null==n){var o=t&&t.constructor;n=i?r?new o:[]:Ds(t)&&Cs(o)?dr(Re(t)):{}}return(i?He:Hr)(t,(function(t,r,i){return e(n,t,r,i)})),n},pr.unary=function(t){return ts(t,1)},pr.union=Na,pr.unionBy=Aa,pr.unionWith=ka,pr.uniq=function(t){return t&&t.length?Fi(t):[]},pr.uniqBy=function(t,e){return t&&t.length?Fi(t,Lo(e,2)):[]},pr.uniqWith=function(t,e){return e="function"==typeof e?e:o,t&&t.length?Fi(t,o,e):[]},pr.unset=function(t,e){return null==t||Ui(t,e)},pr.unzip=Ra,pr.unzipWith=Oa,pr.update=function(t,e,n){return null==t?t:qi(t,e,Qi(n))},pr.updateWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:qi(t,e,Qi(n),r)},pr.values=pu,pr.valuesIn=function(t){return null==t?[]:vn(t,ou(t))},pr.without=xa,pr.words=Cu,pr.wrap=function(t,e){return hs(Qi(e),t)},pr.xor=Pa,pr.xorBy=Ma,pr.xorWith=La,pr.zip=Fa,pr.zipObject=function(t,e){return zi(t||[],e||[],Nr)},pr.zipObjectDeep=function(t,e){return zi(t||[],e||[],Ii)},pr.zipWith=Ua,pr.entries=lu,pr.entriesIn=fu,pr.extend=Hs,pr.extendWith=Gs,Pu(pr,pr),pr.add=Wu,pr.attempt=Su,pr.camelCase=du,pr.capitalize=mu,pr.ceil=Qu,pr.clamp=function(t,e,n){return n===o&&(n=e,e=o),n!==o&&(n=(n=zs(n))==n?n:0),e!==o&&(e=(e=zs(e))==e?e:0),Pr(zs(t),e,n)},pr.clone=function(t){return Mr(t,d)},pr.cloneDeep=function(t){return Mr(t,f|d)},pr.cloneDeepWith=function(t,e){return Mr(t,f|d,e="function"==typeof e?e:o)},pr.cloneWith=function(t,e){return Mr(t,d,e="function"==typeof e?e:o)},pr.conformsTo=function(t,e){return null==e||Lr(t,e,iu(e))},pr.deburr=yu,pr.defaultTo=function(t,e){return null==t||t!=t?e:t},pr.divide=Ku,pr.endsWith=function(t,e,n){t=Qs(t),e=Li(e);var r=t.length,i=n=n===o?r:Pr(Bs(n),0,r);return(n-=e.length)>=0&&t.slice(n,i)==e},pr.eq=ps,pr.escape=function(t){return(t=Qs(t))&&St.test(t)?t.replace(Tt,Tn):t},pr.escapeRegExp=function(t){return(t=Qs(t))&&xt.test(t)?t.replace(Ot,"\\$&"):t},pr.every=function(t,e,n){var r=gs(t)?Ye:Br;return n&&Ho(t,e,n)&&(e=o),r(t,Lo(e,3))},pr.find=za,pr.findIndex=ya,pr.findKey=function(t,e){return an(t,Lo(e,3),Hr)},pr.findLast=Wa,pr.findLastIndex=ga,pr.findLastKey=function(t,e){return an(t,Lo(e,3),Gr)},pr.floor=Hu,pr.forEach=Qa,pr.forEachRight=Ka,pr.forIn=function(t,e){return null==t?t:Qr(t,Lo(e,3),ou)},pr.forInRight=function(t,e){return null==t?t:Kr(t,Lo(e,3),ou)},pr.forOwn=function(t,e){return t&&Hr(t,Lo(e,3))},pr.forOwnRight=function(t,e){return t&&Gr(t,Lo(e,3))},pr.get=$s,pr.gt=ds,pr.gte=ms,pr.has=function(t,e){return null!=t&&zo(t,e,ti)},pr.hasIn=tu,pr.head=_a,pr.identity=ku,pr.includes=function(t,e,n,r){t=_s(t)?t:pu(t),n=n&&!r?Bs(n):0;var i=t.length;return n<0&&(n=Qn(i+n,0)),Ps(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&un(t,e,n)>-1},pr.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:Bs(n);return i<0&&(i=Qn(r+i,0)),un(t,e,i)},pr.inRange=function(t,e,n){return e=Vs(e),n===o?(n=e,e=0):n=Vs(n),function(t,e,n){return t>=Kn(e,n)&&t<Qn(e,n)}(t=zs(t),e,n)},pr.invoke=ru,pr.isArguments=ys,pr.isArray=gs,pr.isArrayBuffer=vs,pr.isArrayLike=_s,pr.isArrayLikeObject=bs,pr.isBoolean=function(t){return!0===t||!1===t||Ns(t)&&Zr(t)==W},pr.isBuffer=ws,pr.isDate=Es,pr.isElement=function(t){return Ns(t)&&1===t.nodeType&&!Rs(t)},pr.isEmpty=function(t){if(null==t)return!0;if(_s(t)&&(gs(t)||"string"==typeof t||"function"==typeof t.splice||ws(t)||Ls(t)||ys(t)))return!t.length;var e=jo(t);if(e==X||e==nt)return!t.size;if(Jo(t))return!ci(t).length;for(var n in t)if(he.call(t,n))return!1;return!0},pr.isEqual=function(t,e){return oi(t,e)},pr.isEqualWith=function(t,e,n){var r=(n="function"==typeof n?n:o)?n(t,e):o;return r===o?oi(t,e,o,n):!!r},pr.isError=Ts,pr.isFinite=function(t){return"number"==typeof t&&jn(t)},pr.isFunction=Cs,pr.isInteger=Ss,pr.isLength=Is,pr.isMap=As,pr.isMatch=function(t,e){return t===e||ai(t,e,Uo(e))},pr.isMatchWith=function(t,e,n){return n="function"==typeof n?n:o,ai(t,e,Uo(e),n)},pr.isNaN=function(t){return ks(t)&&t!=+t},pr.isNative=function(t){if(Xo(t))throw new Zt(s);return si(t)},pr.isNil=function(t){return null==t},pr.isNull=function(t){return null===t},pr.isNumber=ks,pr.isObject=Ds,pr.isObjectLike=Ns,pr.isPlainObject=Rs,pr.isRegExp=Os,pr.isSafeInteger=function(t){return Ss(t)&&t>=-P&&t<=P},pr.isSet=xs,pr.isString=Ps,pr.isSymbol=Ms,pr.isTypedArray=Ls,pr.isUndefined=function(t){return t===o},pr.isWeakMap=function(t){return Ns(t)&&jo(t)==at},pr.isWeakSet=function(t){return Ns(t)&&Zr(t)==st},pr.join=function(t,e){return null==t?"":zn.call(t,e)},pr.kebabCase=gu,pr.last=Ta,pr.lastIndexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r;return n!==o&&(i=(i=Bs(n))<0?Qn(r+i,0):Kn(i,r-1)),e==e?function(t,e,n){for(var r=n+1;r--;)if(t[r]===e)return r;return r}(t,e,i):sn(t,hn,i,!0)},pr.lowerCase=vu,pr.lowerFirst=_u,pr.lt=Fs,pr.lte=Us,pr.max=function(t){return t&&t.length?jr(t,ku,$r):o},pr.maxBy=function(t,e){return t&&t.length?jr(t,Lo(e,2),$r):o},pr.mean=function(t){return ln(t,ku)},pr.meanBy=function(t,e){return ln(t,Lo(e,2))},pr.min=function(t){return t&&t.length?jr(t,ku,li):o},pr.minBy=function(t,e){return t&&t.length?jr(t,Lo(e,2),li):o},pr.stubArray=ju,pr.stubFalse=zu,pr.stubObject=function(){return{}},pr.stubString=function(){return""},pr.stubTrue=function(){return!0},pr.multiply=Yu,pr.nth=function(t,e){return t&&t.length?yi(t,Bs(e)):o},pr.noConflict=function(){return xe._===this&&(xe._=me),this},pr.noop=Mu,pr.now=$a,pr.pad=function(t,e,n){t=Qs(t);var r=(e=Bs(e))?Rn(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return vo(qn(i),n)+t+vo(Un(i),n)},pr.padEnd=function(t,e,n){t=Qs(t);var r=(e=Bs(e))?Rn(t):0;return e&&r<e?t+vo(e-r,n):t},pr.padStart=function(t,e,n){t=Qs(t);var r=(e=Bs(e))?Rn(t):0;return e&&r<e?vo(e-r,n)+t:t},pr.parseInt=function(t,e,n){return n||null==e?e=0:e&&(e=+e),Gn(Qs(t).replace(Mt,""),e||0)},pr.random=function(t,e,n){if(n&&"boolean"!=typeof n&&Ho(t,e,n)&&(e=n=o),n===o&&("boolean"==typeof e?(n=e,e=o):"boolean"==typeof t&&(n=t,t=o)),t===o&&e===o?(t=0,e=1):(t=Vs(t),e===o?(e=t,t=0):e=Vs(e)),t>e){var r=t;t=e,e=r}if(n||t%1||e%1){var i=Yn();return Kn(t+i*(e-t+Ae("1e-"+((i+"").length-1))),e)}return wi(t,e)},pr.reduce=function(t,e,n){var r=gs(t)?en:dn,i=arguments.length<3;return r(t,Lo(e,4),n,i,qr)},pr.reduceRight=function(t,e,n){var r=gs(t)?nn:dn,i=arguments.length<3;return r(t,Lo(e,4),n,i,Vr)},pr.repeat=function(t,e,n){return e=(n?Ho(t,e,n):e===o)?1:Bs(e),Ei(Qs(t),e)},pr.replace=function(){var t=arguments,e=Qs(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pr.result=function(t,e,n){var r=-1,i=(e=Ki(e,t)).length;for(i||(i=1,t=o);++r<i;){var a=null==t?o:t[ha(e[r])];a===o&&(r=i,a=n),t=Cs(a)?a.call(t):a}return t},pr.round=Xu,pr.runInContext=t,pr.sample=function(t){return(gs(t)?Cr:Ci)(t)},pr.size=function(t){if(null==t)return 0;if(_s(t))return Ps(t)?Rn(t):t.length;var e=jo(t);return e==X||e==nt?t.size:ci(t).length},pr.snakeCase=bu,pr.some=function(t,e,n){var r=gs(t)?rn:Ri;return n&&Ho(t,e,n)&&(e=o),r(t,Lo(e,3))},pr.sortedIndex=function(t,e){return Oi(t,e)},pr.sortedIndexBy=function(t,e,n){return xi(t,e,Lo(n,2))},pr.sortedIndexOf=function(t,e){var n=null==t?0:t.length;if(n){var r=Oi(t,e);if(r<n&&ps(t[r],e))return r}return-1},pr.sortedLastIndex=function(t,e){return Oi(t,e,!0)},pr.sortedLastIndexBy=function(t,e,n){return xi(t,e,Lo(n,2),!0)},pr.sortedLastIndexOf=function(t,e){if(null==t?0:t.length){var n=Oi(t,e,!0)-1;if(ps(t[n],e))return n}return-1},pr.startCase=wu,pr.startsWith=function(t,e,n){return t=Qs(t),n=null==n?0:Pr(Bs(n),0,t.length),e=Li(e),t.slice(n,n+e.length)==e},pr.subtract=Ju,pr.sum=function(t){return t&&t.length?mn(t,ku):0},pr.sumBy=function(t,e){return t&&t.length?mn(t,Lo(e,2)):0},pr.template=function(t,e,n){var r=pr.templateSettings;n&&Ho(t,e,n)&&(e=o),t=Qs(t),e=Gs({},e,r,Io);var i,a,s=Gs({},e.imports,r.imports,Io),u=iu(s),c=vn(s,u),h=0,l=e.interpolate||Xt,f="__p += '",p=ne((e.escape||Xt).source+"|"+l.source+"|"+(l===Nt?jt:Xt).source+"|"+(e.evaluate||Xt).source+"|$","g"),d="//# sourceURL="+(he.call(e,"sourceURL")?(e.sourceURL+"").replace(/[\r\n]/g," "):"lodash.templateSources["+ ++Se+"]")+"\n";t.replace(p,(function(e,n,r,o,s,u){return r||(r=o),f+=t.slice(h,u).replace(Jt,Cn),n&&(i=!0,f+="' +\n__e("+n+") +\n'"),s&&(a=!0,f+="';\n"+s+";\n__p += '"),r&&(f+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),h=u+e.length,e})),f+="';\n";var m=he.call(e,"variable")&&e.variable;m||(f="with (obj) {\n"+f+"\n}\n"),f=(a?f.replace(_t,""):f).replace(bt,"$1").replace(wt,"$1;"),f="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+f+"return __p\n}";var y=Su((function(){return $t(u,d+"return "+f).apply(o,c)}));if(y.source=f,Ts(y))throw y;return y},pr.times=function(t,e){if((t=Bs(t))<1||t>P)return[];var n=F,r=Kn(t,F);e=Lo(e),t-=F;for(var i=yn(r,e);++n<t;)e(n);return i},pr.toFinite=Vs,pr.toInteger=Bs,pr.toLength=js,pr.toLower=function(t){return Qs(t).toLowerCase()},pr.toNumber=zs,pr.toSafeInteger=function(t){return t?Pr(Bs(t),-P,P):0===t?t:0},pr.toString=Qs,pr.toUpper=function(t){return Qs(t).toUpperCase()},pr.trim=function(t,e,n){if((t=Qs(t))&&(n||e===o))return t.replace(Pt,"");if(!t||!(e=Li(e)))return t;var r=On(t),i=On(e);return Gi(r,bn(r,i),wn(r,i)+1).join("")},pr.trimEnd=function(t,e,n){if((t=Qs(t))&&(n||e===o))return t.replace(Lt,"");if(!t||!(e=Li(e)))return t;var r=On(t);return Gi(r,0,wn(r,On(e))+1).join("")},pr.trimStart=function(t,e,n){if((t=Qs(t))&&(n||e===o))return t.replace(Mt,"");if(!t||!(e=Li(e)))return t;var r=On(t);return Gi(r,bn(r,On(e))).join("")},pr.truncate=function(t,e){var n=D,r=N;if(Ds(e)){var i="separator"in e?e.separator:i;n="length"in e?Bs(e.length):n,r="omission"in e?Li(e.omission):r}var a=(t=Qs(t)).length;if(Sn(t)){var s=On(t);a=s.length}if(n>=a)return t;var u=n-Rn(r);if(u<1)return r;var c=s?Gi(s,0,u).join(""):t.slice(0,u);if(i===o)return c+r;if(s&&(u+=c.length-u),Os(i)){if(t.slice(u).search(i)){var h,l=c;for(i.global||(i=ne(i.source,Qs(zt.exec(i))+"g")),i.lastIndex=0;h=i.exec(l);)var f=h.index;c=c.slice(0,f===o?u:f)}}else if(t.indexOf(Li(i),u)!=u){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+r},pr.unescape=function(t){return(t=Qs(t))&&Ct.test(t)?t.replace(Et,xn):t},pr.uniqueId=function(t){var e=++le;return Qs(t)+e},pr.upperCase=Eu,pr.upperFirst=Tu,pr.each=Qa,pr.eachRight=Ka,pr.first=_a,Pu(pr,(Gu={},Hr(pr,(function(t,e){he.call(pr.prototype,e)||(Gu[e]=t)})),Gu),{chain:!1}),pr.VERSION="4.17.15",He(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){pr[t].placeholder=pr})),He(["drop","take"],(function(t,e){gr.prototype[t]=function(n){n=n===o?1:Qn(Bs(n),0);var r=this.__filtered__&&!e?new gr(this):this.clone();return r.__filtered__?r.__takeCount__=Kn(n,r.__takeCount__):r.__views__.push({size:Kn(n,F),type:t+(r.__dir__<0?"Right":"")}),r},gr.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),He(["filter","map","takeWhile"],(function(t,e){var n=e+1,r=n==R||3==n;gr.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Lo(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}})),He(["head","last"],(function(t,e){var n="take"+(e?"Right":"");gr.prototype[t]=function(){return this[n](1).value()[0]}})),He(["initial","tail"],(function(t,e){var n="drop"+(e?"":"Right");gr.prototype[t]=function(){return this.__filtered__?new gr(this):this[n](1)}})),gr.prototype.compact=function(){return this.filter(ku)},gr.prototype.find=function(t){return this.filter(t).head()},gr.prototype.findLast=function(t){return this.reverse().find(t)},gr.prototype.invokeMap=Ti((function(t,e){return"function"==typeof t?new gr(this):this.map((function(n){return ri(n,t,e)}))})),gr.prototype.reject=function(t){return this.filter(us(Lo(t)))},gr.prototype.slice=function(t,e){t=Bs(t);var n=this;return n.__filtered__&&(t>0||e<0)?new gr(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==o&&(n=(e=Bs(e))<0?n.dropRight(-e):n.take(e-t)),n)},gr.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},gr.prototype.toArray=function(){return this.take(F)},Hr(gr.prototype,(function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=pr[r?"take"+("last"==e?"Right":""):e],a=r||/^find/.test(e);i&&(pr.prototype[e]=function(){var e=this.__wrapped__,s=r?[1]:arguments,u=e instanceof gr,c=s[0],h=u||gs(e),l=function(t){var e=i.apply(pr,tn([t],s));return r&&f?e[0]:e};h&&n&&"function"==typeof c&&1!=c.length&&(u=h=!1);var f=this.__chain__,p=!!this.__actions__.length,d=a&&!f,m=u&&!p;if(!a&&h){e=m?e:new gr(this);var y=t.apply(e,s);return y.__actions__.push({func:Va,args:[l],thisArg:o}),new yr(y,f)}return d&&m?t.apply(this,s):(y=this.thru(l),d?r?y.value()[0]:y.value():y)})})),He(["pop","push","shift","sort","splice","unshift"],(function(t){var e=oe[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);pr.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var i=this.value();return e.apply(gs(i)?i:[],t)}return this[n]((function(n){return e.apply(gs(n)?n:[],t)}))}})),Hr(gr.prototype,(function(t,e){var n=pr[e];if(n){var r=n.name+"";he.call(ir,r)||(ir[r]=[]),ir[r].push({name:e,func:n})}})),ir[po(o,v).name]=[{name:"wrapper",func:o}],gr.prototype.clone=function(){var t=new gr(this.__wrapped__);return t.__actions__=no(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=no(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=no(this.__views__),t},gr.prototype.reverse=function(){if(this.__filtered__){var t=new gr(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},gr.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=gs(t),r=e<0,i=n?t.length:0,o=function(t,e,n){var r=-1,i=n.length;for(;++r<i;){var o=n[r],a=o.size;switch(o.type){case"drop":t+=a;break;case"dropRight":e-=a;break;case"take":e=Kn(e,t+a);break;case"takeRight":t=Qn(t,e-a)}}return{start:t,end:e}}(0,i,this.__views__),a=o.start,s=o.end,u=s-a,c=r?s:a-1,h=this.__iteratees__,l=h.length,f=0,p=Kn(u,this.__takeCount__);if(!n||!r&&i==u&&p==u)return Bi(t,this.__actions__);var d=[];t:for(;u--&&f<p;){for(var m=-1,y=t[c+=e];++m<l;){var g=h[m],v=g.iteratee,_=g.type,b=v(y);if(_==O)y=b;else if(!b){if(_==R)continue t;break t}}d[f++]=y}return d},pr.prototype.at=Ba,pr.prototype.chain=function(){return qa(this)},pr.prototype.commit=function(){return new yr(this.value(),this.__chain__)},pr.prototype.next=function(){this.__values__===o&&(this.__values__=qs(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?o:this.__values__[this.__index__++]}},pr.prototype.plant=function(t){for(var e,n=this;n instanceof mr;){var r=fa(n);r.__index__=0,r.__values__=o,e?i.__wrapped__=r:e=r;var i=r;n=n.__wrapped__}return i.__wrapped__=t,e},pr.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof gr){var e=t;return this.__actions__.length&&(e=new gr(this)),(e=e.reverse()).__actions__.push({func:Va,args:[Da],thisArg:o}),new yr(e,this.__chain__)}return this.thru(Da)},pr.prototype.toJSON=pr.prototype.valueOf=pr.prototype.value=function(){return Bi(this.__wrapped__,this.__actions__)},pr.prototype.first=pr.prototype.head,Ue&&(pr.prototype[Ue]=function(){return this}),pr}();xe._=Pn,(i=function(){return Pn}.call(e,n,e,r))===o||(r.exports=i)}.call(this)}).call(this,n("yLpj"),n("YuTi")(t))},"Ml7+":function(t,e,n){"use strict";n("t+fG")("sub",(function(t){return function(){return t(this,"sub","","")}}))},NSPt:function(t,e,n){"use strict";(function(r){n("DrhF"),n("U6Bt"),n("Ll4R"),n("ToIb"),n("6kNP"),n("zTTH"),n("OeI1"),n("cFtU"),n("v9g0"),n("YbXK"),n("xJgp"),n("rzGZ"),n("Dq+y"),n("Ggvi"),n("JHok"),n("+ar0"),n("AqHK"),n("pJf4"),n("nMRu"),n("sC2a"),n("HQhv"),n("sPse"),n("klQ5"),n("zGcK"),n("YBKJ"),n("sc67"),n("n7j8"),n("MIFh"),n("q8oJ"),n("C9fy"),n("8npG"),n("R48M"),Object.defineProperty(e,"__esModule",{value:!0});var i,o,a=(i=n("wj3C"))&&"object"==typeof i&&"default"in i?i.default:i,s=n("mrSG"),u=n("zVF4"),c=n("q/0M"),h=n("S+S0"),l=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),u.stringify(e))},t.prototype.get=function(t){var e=this.domStorage_.getItem(this.prefixedName_(t));return null==e?null:u.jsonEval(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}(),f=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 u.contains(this.cache_,t)?this.cache_[t]:null},t.prototype.remove=function(t){delete this.cache_[t]},t}(),p=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 l(e)}}catch(n){}return new f},d=p("localStorage"),m=p("sessionStorage"),y=new c.Logger("@firebase/database"),g=(o=1,function(){return o++}),v=function(t){var e=u.stringToByteArray(t),n=new u.Sha1;n.update(e);var r=n.digest();return u.base64.encodeByteArray(r)},_=function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];for(var r="",i=0;i<e.length;i++)Array.isArray(e[i])||e[i]&&"object"==typeof e[i]&&"number"==typeof e[i].length?r+=t.apply(null,e[i]):"object"==typeof e[i]?r+=u.stringify(e[i]):r+=e[i],r+=" ";return r},b=null,w=!0,E=function(t,e){u.assert(!e||!0===t||!1===t,"Can't turn on custom loggers persistently."),!0===t?(y.logLevel=c.LogLevel.VERBOSE,b=y.log.bind(y),e&&m.set("logging_enabled",!0)):"function"==typeof t?b=t:(b=null,m.remove("logging_enabled"))},T=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!0===w&&(w=!1,null===b&&!0===m.get("logging_enabled")&&E(!0)),b){var n=_.apply(null,t);b(n)}},C=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];T.apply(void 0,s.__spread([t],e))}},S=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE INTERNAL ERROR: "+_.apply(void 0,s.__spread(t));y.error(n)},I=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE FATAL ERROR: "+_.apply(void 0,s.__spread(t));throw y.error(n),new Error(n)},D=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE WARNING: "+_.apply(void 0,s.__spread(t));y.warn(n)},N=function(t){return"number"==typeof t&&(t!=t||t==Number.POSITIVE_INFINITY||t==Number.NEGATIVE_INFINITY)},A="[MIN_NAME]",k="[MAX_NAME]",R=function(t,e){if(t===e)return 0;if(t===A||e===k)return-1;if(e===A||t===k)return 1;var n=q(t),r=q(e);return null!==n?null!==r?n-r==0?t.length-e.length:n-r:-1:null!==r?1:t<e?-1:1},O=function(t,e){return t===e?0:t<e?-1:1},x=function(t,e){if(e&&t in e)return e[t];throw new Error("Missing required key ("+t+") in object: "+u.stringify(e))},P=function t(e){if("object"!=typeof e||null===e)return u.stringify(e);var n=[];for(var r in e)n.push(r);n.sort();for(var i="{",o=0;o<n.length;o++)0!==o&&(i+=","),i+=u.stringify(n[o]),i+=":",i+=t(e[n[o]]);return i+="}"},M=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};function L(t,e){for(var n in t)t.hasOwnProperty(n)&&e(n,t[n])}var F=function(t){u.assert(!N(t),"Invalid JSON number");var e,n,r,i,o,a,s;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)))),a=[],o=52;o;o-=1)a.push(r%2?1:0),r=Math.floor(r/2);for(o=11;o;o-=1)a.push(n%2?1:0),n=Math.floor(n/2);a.push(e?1:0),a.reverse(),s=a.join("");var c="";for(o=0;o<64;o+=8){var h=parseInt(s.substr(o,8),2).toString(16);1===h.length&&(h="0"+h),c+=h}return c.toLowerCase()},U=new RegExp("^-?(0*)\\d{1,10}$"),q=function(t){if(U.test(t)){var e=Number(t);if(e>=-2147483648&&e<=2147483647)return e}return null},V=function(t){try{t()}catch(e){setTimeout((function(){var t=e.stack||"";throw D("Exception was thrown by user callback.",t),e}),Math.floor(0))}},B=function(){return("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},j=function(t,e){var n=setTimeout(t,e);return"object"==typeof n&&n.unref&&n.unref(),n},z=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=R(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}(),W=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_+=u.stringLength(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_+=u.stringLength(t),this.checkValid_()},t.prototype.pop=function(){var t=this.parts_.pop();this.byteLength_-=u.stringLength(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}(),Q="long_polling",K=function(){function t(t,e,n,r,i,o){void 0===i&&(i=""),void 0===o&&(o=!1),this.secure=e,this.namespace=n,this.webSocketOnly=r,this.persistenceKey=i,this.includeNamespaceInQueryParams=o,this.host=t.toLowerCase(),this.domain=this.host.substr(this.host.indexOf(".")+1),this.internalHost=d.get("host:"+t)||this.host}return t.prototype.needsQueryParam=function(){return this.host!==this.internalHost||this.isCustomHost()||this.includeNamespaceInQueryParams},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()&&d.set("host:"+this.host,this.internalHost))},t.prototype.connectionURL=function(t,e){var n;if(u.assert("string"==typeof t,"typeof type must == string"),u.assert("object"==typeof e,"typeof params must == object"),"websocket"===t)n=(this.secure?"wss://":"ws://")+this.internalHost+"/.ws?";else{if(t!==Q)throw new Error("Unknown connection type: "+t);n=(this.secure?"https://":"http://")+this.internalHost+"/.lp?"}this.needsQueryParam()&&(e.ns=this.namespace);var r=[];return L(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 H,G,Y,X,J,Z=function(t){var e=$(t),n=e.namespace;"firebase"===e.domain&&I(e.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),n&&"undefined"!=n||"localhost"===e.domain||I("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:")&&D("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 K(e.host,e.secure,n,r,"",n!=e.subdomain),path:new z(e.pathString)}},$=function(t){var e="",n="",r="",i="",o="",a=!0,u="https",c=443;if("string"==typeof t){var h=t.indexOf("//");h>=0&&(u=t.substring(0,h-1),t=t.substring(h+2));var l=t.indexOf("/");-1===l&&(l=t.length);var f=t.indexOf("?");-1===f&&(f=t.length),e=t.substring(0,Math.min(l,f)),l<f&&(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(o){}e+="/"+i}return e}(t.substring(l,f)));var p=function(t){var e,n,r={};"?"===t.charAt(0)&&(t=t.substring(1));try{for(var i=s.__values(t.split("&")),o=i.next();!o.done;o=i.next()){var a=o.value;if(0!==a.length){var u=a.split("=");2===u.length?r[decodeURIComponent(u[0])]=decodeURIComponent(u[1]):D("Invalid query segment '"+a+"' in query '"+t+"'")}}}catch(c){e={error:c}}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,f)));(h=e.indexOf(":"))>=0?(a="https"===u||"wss"===u,c=parseInt(e.substring(h+1),10)):h=t.length;var d=e.split(".");3===d.length?(n=d[1],o=r=d[0].toLowerCase()):2===d.length?n=d[0]:"localhost"===d[0].slice(0,h).toLowerCase()&&(n="localhost"),"ns"in p&&(o=p.ns)}return{host:e,port:c,domain:n,subdomain:r,secure:a,scheme:u,pathString:i,namespace:o}},tt=/[\[\].#$\/\u0000-\u001F\u007F]/,et=/[\[\].#$\u0000-\u001F\u007F]/,nt=function(t){return"string"==typeof t&&0!==t.length&&!tt.test(t)},rt=function(t){return"string"==typeof t&&0!==t.length&&!et.test(t)},it=function(t){return null===t||"string"==typeof t||"number"==typeof t&&!N(t)||t&&"object"==typeof t&&u.contains(t,".sv")},ot=function(t,e,n,r,i){i&&void 0===n||at(u.errorPrefix(t,e,i),n,r)},at=function t(e,n,r){var i=r instanceof z?new W(r,e):r;if(void 0===n)throw new Error(e+"contains undefined "+i.toErrorString());if("function"==typeof n)throw new Error(e+"contains a function "+i.toErrorString()+" with contents = "+n.toString());if(N(n))throw new Error(e+"contains "+n.toString()+" "+i.toErrorString());if("string"==typeof n&&n.length>10485760/3&&u.stringLength(n)>10485760)throw new Error(e+"contains a string greater than 10485760 utf8 bytes "+i.toErrorString()+" ('"+n.substring(0,50)+"...')");if(n&&"object"==typeof n){var o=!1,a=!1;if(L(n,(function(n,r){if(".value"===n)o=!0;else if(".priority"!==n&&".sv"!==n&&(a=!0,!nt(n)))throw new Error(e+" contains an invalid key ("+n+") "+i.toErrorString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');i.push(n),t(e,r,i),i.pop()})),o&&a)throw new Error(e+' contains ".value" child '+i.toErrorString()+" in addition to actual children.")}},st=function(t,e,n,r,i){if(!i||void 0!==n){var o=u.errorPrefix(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 a=[];L(n,(function(t,e){var n=new z(t);if(at(o,e,r.child(n)),".priority"===n.getBack()&&!it(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).");a.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(!nt(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(z.comparePaths);var a=null;for(n=0;n<e.length;n++){if(r=e[n],null!==a&&a.contains(r))throw new Error(t+"contains a path "+a.toString()+" that is ancestor of another path "+r.toString());a=r}}(o,a)}},ut=function(t,e,n,r){if(!r||void 0!==n){if(N(n))throw new Error(u.errorPrefix(t,e,r)+"is "+n.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!it(n))throw new Error(u.errorPrefix(t,e,r)+"must be a valid Firebase priority (a string, finite number, server value, or null).")}},ct=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(u.errorPrefix(t,e,r)+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}},ht=function(t,e,n,r){if(!(r&&void 0===n||nt(n)))throw new Error(u.errorPrefix(t,e,r)+'was an invalid key = "'+n+'". Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')},lt=function(t,e,n,r){if(!(r&&void 0===n||rt(n)))throw new Error(u.errorPrefix(t,e,r)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},ft=function(t,e,n,r){n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),lt(t,e,n,r)},pt=function(t,e){if(".info"===e.getFront())throw new Error(t+" failed = Can't modify data under /.info/")},dt=function(t,e,n){var r=n.path.toString();if("string"!=typeof n.repoInfo.host||0===n.repoInfo.host.length||!nt(n.repoInfo.namespace)&&"localhost"!==n.repoInfo.host.split(":")[0]||0!==r.length&&!function(t){return t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),rt(t)}(r))throw new Error(u.errorPrefix(t,e,!1)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')},mt=function(t,e,n,r){if((!r||void 0!==n)&&"boolean"!=typeof n)throw new Error(u.errorPrefix(t,e,r)+"must be a boolean.")},yt=function(){function t(t,e){this.repo_=t,this.path_=e}return t.prototype.cancel=function(t){u.validateArgCount("OnDisconnect.cancel",0,1,arguments.length),u.validateCallback("OnDisconnect.cancel",1,t,!0);var e=new u.Deferred;return this.repo_.onDisconnectCancel(this.path_,e.wrapCallback(t)),e.promise},t.prototype.remove=function(t){u.validateArgCount("OnDisconnect.remove",0,1,arguments.length),pt("OnDisconnect.remove",this.path_),u.validateCallback("OnDisconnect.remove",1,t,!0);var e=new u.Deferred;return this.repo_.onDisconnectSet(this.path_,null,e.wrapCallback(t)),e.promise},t.prototype.set=function(t,e){u.validateArgCount("OnDisconnect.set",1,2,arguments.length),pt("OnDisconnect.set",this.path_),ot("OnDisconnect.set",1,t,this.path_,!1),u.validateCallback("OnDisconnect.set",2,e,!0);var n=new u.Deferred;return this.repo_.onDisconnectSet(this.path_,t,n.wrapCallback(e)),n.promise},t.prototype.setWithPriority=function(t,e,n){u.validateArgCount("OnDisconnect.setWithPriority",2,3,arguments.length),pt("OnDisconnect.setWithPriority",this.path_),ot("OnDisconnect.setWithPriority",1,t,this.path_,!1),ut("OnDisconnect.setWithPriority",2,e,!1),u.validateCallback("OnDisconnect.setWithPriority",3,n,!0);var r=new u.Deferred;return this.repo_.onDisconnectSetWithPriority(this.path_,t,e,r.wrapCallback(n)),r.promise},t.prototype.update=function(t,e){if(u.validateArgCount("OnDisconnect.update",1,2,arguments.length),pt("OnDisconnect.update",this.path_),Array.isArray(t)){for(var n={},r=0;r<t.length;++r)n[""+r]=t[r];t=n,D("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.")}st("OnDisconnect.update",1,t,this.path_,!1),u.validateCallback("OnDisconnect.update",2,e,!0);var i=new u.Deferred;return this.repo_.onDisconnectUpdate(this.path_,t,i.wrapCallback(e)),i.promise},t}(),gt=function(){function t(t,e){this.committed=t,this.snapshot=e}return t.prototype.toJSON=function(){return u.validateArgCount("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}},t}(),vt=(H="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",G=0,Y=[],function(t){var e,n=t===G;G=t;var r=new Array(8);for(e=7;e>=0;e--)r[e]=H.charAt(t%64),t=Math.floor(t/64);u.assert(0===t,"Cannot push at time == 0");var i=r.join("");if(n){for(e=11;e>=0&&63===Y[e];e--)Y[e]=0;Y[e]++}else for(e=0;e<12;e++)Y[e]=Math.floor(64*Math.random());for(e=0;e<12;e++)i+=H.charAt(Y[e]);return u.assert(20===i.length,"nextPushId: Length should be 20."),i}),_t=function(){function t(t,e){this.name=t,this.node=e}return t.Wrap=function(e,n){return new t(e,n)},t}(),bt=function(){function t(){}return t.prototype.getCompare=function(){return this.compare.bind(this)},t.prototype.indexedValueChanged=function(t,e){var n=new _t(A,t),r=new _t(A,e);return 0!==this.compare(n,r)},t.prototype.minPost=function(){return _t.MIN},t}(),wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s.__extends(e,t),Object.defineProperty(e,"__EMPTY_NODE",{get:function(){return X},set:function(t){X=t},enumerable:!0,configurable:!0}),e.prototype.compare=function(t,e){return R(t.name,e.name)},e.prototype.isDefinedOn=function(t){throw u.assertionError("KeyIndex.isDefinedOn not expected to be called.")},e.prototype.indexedValueChanged=function(t,e){return!1},e.prototype.minPost=function(){return _t.MIN},e.prototype.maxPost=function(){return new _t(k,X)},e.prototype.makePost=function(t,e){return u.assert("string"==typeof t,"KeyIndex indexValue must always be a string."),new _t(t,X)},e.prototype.toString=function(){return".key"},e}(bt),Et=new wt;var Tt,Ct,St,It=function(t){return"number"==typeof t?"number:"+F(t):"string:"+t},Dt=function(t){if(t.isLeafNode()){var e=t.val();u.assert("string"==typeof e||"number"==typeof e||"object"==typeof e&&u.contains(e,".sv"),"Priority must be a string or number.")}else u.assert(t===J||t.isEmpty(),"priority of unexpected type.");u.assert(t===J||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")},Nt=function(){function t(e,n){void 0===n&&(n=t.__childrenNodeConstructor.EMPTY_NODE),this.value_=e,this.priorityNode_=n,this.lazyHash_=null,u.assert(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),Dt(this.priorityNode_)}return Object.defineProperty(t,"__childrenNodeConstructor",{get:function(){return Tt},set:function(t){Tt=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:(u.assert(".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:"+It(this.priorityNode_.val())+":");var e=typeof this.value_;t+=e+":",t+="number"===e?F(this.value_):this.value_,this.lazyHash_=v(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:(u.assert(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 u.assert(i>=0,"Unknown leaf type: "+n),u.assert(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 At,kt,Rt=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s.__extends(e,t),e.prototype.compare=function(t,e){var n=t.node.getPriority(),r=e.node.getPriority(),i=n.compareTo(r);return 0===i?R(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 _t.MIN},e.prototype.maxPost=function(){return new _t(k,new Nt("[PRIORITY-POST]",St))},e.prototype.makePost=function(t,e){var n=Ct(t);return new _t(e,new Nt("[PRIORITY-POST]",n))},e.prototype.toString=function(){return".priority"},e}(bt)),Ot=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}(),xt=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:Mt.EMPTY_NODE,this.right=null!=o?o:Mt.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 Mt.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 Mt.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}(),Pt=function(){function t(){}return t.prototype.copy=function(t,e,n,r,i){return this},t.prototype.insert=function(t,e,n){return new xt(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}(),Mt=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,xt.BLACK,null,null))},t.prototype.remove=function(e){return new t(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,xt.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 Ot(this.root_,null,this.comparator_,!1,t)},t.prototype.getIteratorFrom=function(t,e){return new Ot(this.root_,t,this.comparator_,!1,e)},t.prototype.getReverseIteratorFrom=function(t,e){return new Ot(this.root_,t,this.comparator_,!0,e)},t.prototype.getReverseIterator=function(t){return new Ot(this.root_,null,this.comparator_,!0,t)},t.EMPTY_NODE=new Pt,t}(),Lt=Math.log(2),Ft=function(){function t(t){var e;this.count=(e=t+1,parseInt(Math.log(e)/Lt,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}(),Ut=function(t,e,n,r){t.sort(e);var i=function(e){for(var r=null,i=null,o=t.length,a=function(e,r){var i=o-e,a=o;o-=e;var u=function e(r,i){var o,a,s=i-r;if(0==s)return null;if(1==s)return o=t[r],a=n?n(o):o,new xt(a,o.node,xt.BLACK,null,null);var u=parseInt(s/2,10)+r,c=e(r,u),h=e(u+1,i);return o=t[u],a=n?n(o):o,new xt(a,o.node,xt.BLACK,c,h)}(i+1,a),c=t[i],h=n?n(c):c;s(new xt(h,c.node,r,null,u))},s=function(t){r?(r.left=t,r=t):(i=t,r=t)},u=0;u<e.count;++u){var c=e.nextBitIsOne(),h=Math.pow(2,e.count-(u+1));c?a(h,xt.BLACK):(a(h,xt.BLACK),a(h,xt.RED))}return i}(new Ft(t.length));return new Mt(r||e,i)},qt={},Vt=function(){function t(t,e){this.indexes_=t,this.indexSet_=e}return Object.defineProperty(t,"Default",{get:function(){return u.assert(qt&&Rt,"ChildrenNode.ts has not been loaded"),At=At||new t({".priority":qt},{".priority":Rt})},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var e=u.safeGet(this.indexes_,t);if(!e)throw new Error("No index defined for "+t);return e instanceof Mt?e:null},t.prototype.hasIndex=function(t){return u.contains(this.indexSet_,t.toString())},t.prototype.addIndex=function(e,n){u.assert(e!==Et,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var r,i=[],o=!1,a=n.getIterator(_t.Wrap),c=a.getNext();c;)o=o||e.isDefinedOn(c.node),i.push(c),c=a.getNext();r=o?Ut(i,e.getCompare()):qt;var h=e.toString(),l=s.__assign({},this.indexSet_);l[h]=e;var f=s.__assign({},this.indexes_);return f[h]=r,new t(f,l)},t.prototype.addToIndexes=function(e,n){var r=this;return new t(u.map(this.indexes_,(function(t,i){var o=u.safeGet(r.indexSet_,i);if(u.assert(o,"Missing index implementation for "+i),t===qt){if(o.isDefinedOn(e.node)){for(var a=[],s=n.getIterator(_t.Wrap),c=s.getNext();c;)c.name!=e.name&&a.push(c),c=s.getNext();return a.push(e),Ut(a,o.getCompare())}return qt}var h=n.get(e.name),l=t;return h&&(l=l.remove(new _t(e.name,h))),l.insert(e,e.node)})),this.indexSet_)},t.prototype.removeFromIndexes=function(e,n){return new t(u.map(this.indexes_,(function(t){if(t===qt)return t;var r=n.get(e.name);return r?t.remove(new _t(e.name,r)):t})),this.indexSet_)},t}();function Bt(t,e){return R(t.name,e.name)}function jt(t,e){return R(t,e)}var zt=function(){function t(t,e,n){this.children_=t,this.priorityNode_=e,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&Dt(this.priorityNode_),this.children_.isEmpty()&&u.assert(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}return Object.defineProperty(t,"EMPTY_NODE",{get:function(){return kt||(kt=new t(new Mt(jt),null,Vt.Default))},enumerable:!0,configurable:!0}),t.prototype.isLeafNode=function(){return!1},t.prototype.getPriority=function(){return this.priorityNode_||kt},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?kt: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(u.assert(n,"We should always be passing snapshot nodes"),".priority"===e)return this.updatePriority(n);var r,i=new _t(e,n),o=void 0,a=void 0;return n.isEmpty()?(o=this.children_.remove(e),a=this.indexMap_.removeFromIndexes(i,this.children_)):(o=this.children_.insert(e,n),a=this.indexMap_.addToIndexes(i,this.children_)),r=o.isEmpty()?kt:this.priorityNode_,new t(o,r,a)},t.prototype.updateChild=function(t,e){var n=t.getFront();if(null===n)return e;u.assert(".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(Rt,(function(a,s){n[a]=s.val(e),r++,o&&t.INTEGER_REGEXP_.test(a)?i=Math.max(i,Number(a)):o=!1})),!e&&o&&i<2*r){var a=[];for(var s in n)a[s]=n[s];return a}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:"+It(this.getPriority().val())+":"),this.forEachChild(Rt,(function(e,n){var r=n.hash();""!==r&&(t+=":"+e+":"+r)})),this.lazyHash_=""===t?"":v(t)}return this.lazyHash_},t.prototype.getPredecessorChildName=function(t,e,n){var r=this.resolveIndex_(n);if(r){var i=r.getPredecessorKey(new _t(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 _t(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 _t(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,_t.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,_t.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===Wt?-1:0},t.prototype.withIndex=function(e){if(e===Et||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===Et||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(Rt),r=e.getIterator(Rt),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===Et?null:this.indexMap_.get(t.toString())},t.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,t}(),Wt=new(function(t){function e(){return t.call(this,new Mt(jt),zt.EMPTY_NODE,Vt.Default)||this}return s.__extends(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 zt.EMPTY_NODE},e.prototype.isEmpty=function(){return!1},e}(zt));Object.defineProperties(_t,{MIN:{value:new _t(A,zt.EMPTY_NODE)},MAX:{value:new _t(k,Wt)}}),wt.__EMPTY_NODE=zt.EMPTY_NODE,Nt.__childrenNodeConstructor=zt,J=Wt,function(t){St=t}(Wt);var Qt=!0;function Kt(t,e){if(void 0===e&&(e=null),null===t)return zt.EMPTY_NODE;if("object"==typeof t&&".priority"in t&&(e=t[".priority"]),u.assert(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 Nt(t,Kt(e));if(t instanceof Array||!Qt){var n=zt.EMPTY_NODE;return L(t,(function(e,r){if(u.contains(t,e)&&"."!==e.substring(0,1)){var i=Kt(r);!i.isLeafNode()&&i.isEmpty()||(n=n.updateImmediateChild(e,i))}})),n.updatePriority(Kt(e))}var r=[],i=!1;if(L(t,(function(t,e){if("."!==t.substring(0,1)){var n=Kt(e);n.isEmpty()||(i=i||!n.getPriority().isEmpty(),r.push(new _t(t,n)))}})),0==r.length)return zt.EMPTY_NODE;var o=Ut(r,Bt,(function(t){return t.name}),jt);if(i){var a=Ut(r,Rt.getCompare());return new zt(o,Kt(e),new Vt({".priority":a},{".priority":Rt}))}return new zt(o,Kt(e),Vt.Default)}!function(t){Ct=t}(Kt);var Ht,Gt,Yt=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s.__extends(e,t),e.prototype.compare=function(t,e){var n=t.node.compareTo(e.node);return 0===n?R(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 _t.MIN},e.prototype.maxPost=function(){return _t.MAX},e.prototype.makePost=function(t,e){var n=Kt(t);return new _t(e,n)},e.prototype.toString=function(){return".value"},e}(bt)),Xt=function(t){function e(e){var n=t.call(this)||this;return n.indexPath_=e,u.assert(!e.isEmpty()&&".priority"!==e.getFront(),"Can't create PathIndex with empty path or .priority key"),n}return s.__extends(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?R(t.name,e.name):i},e.prototype.makePost=function(t,e){var n=Kt(t),r=zt.EMPTY_NODE.updateChild(this.indexPath_,n);return new _t(e,r)},e.prototype.maxPost=function(){var t=zt.EMPTY_NODE.updateChild(this.indexPath_,Wt);return new _t(k,t)},e.prototype.toString=function(){return this.indexPath_.slice().join("/")},e}(bt),Jt=function(){function t(t,e,n){this.node_=t,this.ref_=e,this.index_=n}return t.prototype.val=function(){return u.validateArgCount("DataSnapshot.val",0,0,arguments.length),this.node_.val()},t.prototype.exportVal=function(){return u.validateArgCount("DataSnapshot.exportVal",0,0,arguments.length),this.node_.val(!0)},t.prototype.toJSON=function(){return u.validateArgCount("DataSnapshot.toJSON",0,1,arguments.length),this.exportVal()},t.prototype.exists=function(){return u.validateArgCount("DataSnapshot.exists",0,0,arguments.length),!this.node_.isEmpty()},t.prototype.child=function(e){u.validateArgCount("DataSnapshot.child",0,1,arguments.length),e=String(e),lt("DataSnapshot.child",1,e,!1);var n=new z(e),r=this.ref_.child(n);return new t(this.node_.getChild(n),r,Rt)},t.prototype.hasChild=function(t){u.validateArgCount("DataSnapshot.hasChild",1,1,arguments.length),lt("DataSnapshot.hasChild",1,t,!1);var e=new z(t);return!this.node_.getChild(e).isEmpty()},t.prototype.getPriority=function(){return u.validateArgCount("DataSnapshot.getPriority",0,0,arguments.length),this.node_.getPriority().val()},t.prototype.forEach=function(e){var n=this;if(u.validateArgCount("DataSnapshot.forEach",1,1,arguments.length),u.validateCallback("DataSnapshot.forEach",1,e,!1),this.node_.isLeafNode())return!1;var r=this.node_;return!!r.forEachChild(this.index_,(function(r,i){return e(new t(i,n.ref_.child(r),Rt))}))},t.prototype.hasChildren=function(){return u.validateArgCount("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 u.validateArgCount("DataSnapshot.numChildren",0,0,arguments.length),this.node_.numChildren()},t.prototype.getRef=function(){return u.validateArgCount("DataSnapshot.ref",0,0,arguments.length),this.ref_},Object.defineProperty(t.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),t}(),Zt=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+":"+u.stringify(this.snapshot.exportVal())},t}(),$t=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}(),te=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 Zt("value",this,new Jt(t.snapshotNode,e.getRef(),n))},t.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){u.assert(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 $t(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}(),ee=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,u.contains(this.callbacks_,e)},t.prototype.createCancelEvent=function(t,e){return this.cancelCallback_?new $t(this,t,e):null},t.prototype.createEvent=function(t,e){u.assert(null!=t.childName,"Child events should have a childName.");var n=e.getRef().child(t.childName),r=e.getQueryParams().getIndex();return new Zt(t.type,this,new Jt(t.snapshotNode,n,r),t.prevName)},t.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){u.assert(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){var n=this;if(e instanceof t){if(!this.callbacks_||!e.callbacks_)return!0;if(this.context_===e.context_){var r=Object.keys(e.callbacks_),i=Object.keys(this.callbacks_),o=r.length;if(o===i.length){if(1===o){var a=r[0],s=i[0];return!(s!==a||e.callbacks_[a]&&this.callbacks_[s]&&e.callbacks_[a]!==this.callbacks_[s])}return i.every((function(t){return e.callbacks_[t]===n.callbacks_[t]}))}}}return!1},t.prototype.hasAnyCallback=function(){return null!==this.callbacks_},t}(),ne=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 u.assert(Ht,"Reference.ts has not been loaded"),Ht},set:function(t){Ht=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()===Et){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()!=A)throw new Error(r);if("string"!=typeof e)throw new Error(i)}if(t.hasEnd()){if(t.getIndexEndName()!=k)throw new Error(r);if("string"!=typeof n)throw new Error(i)}}else if(t.getIndex()===Rt){if(null!=e&&!it(e)||null!=n&&!it(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(u.assert(t.getIndex()instanceof Xt||t.getIndex()===Yt,"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 u.validateArgCount("Query.ref",0,0,arguments.length),new t.__referenceConstructor(this.repo,this.path)},t.prototype.on=function(e,n,r,i){u.validateArgCount("Query.on",2,4,arguments.length),ct("Query.on",1,e,!1),u.validateCallback("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 a={};a[e]=n,this.onChildEvent(a,o.cancel,o.context)}return n},t.prototype.onValueEvent=function(t,e,n){var r=new te(t,e||null,n||null);this.repo.addEventCallbackForQuery(this,r)},t.prototype.onChildEvent=function(t,e,n){var r=new ee(t,e,n);this.repo.addEventCallbackForQuery(this,r)},t.prototype.off=function(t,e,n){u.validateArgCount("Query.off",0,3,arguments.length),ct("Query.off",1,t,!0),u.validateCallback("Query.off",2,e,!0),u.validateContextObject("Query.off",3,n,!0);var r=null,i=null;if("value"===t){var o=e||null;r=new te(o,null,n||null)}else t&&(e&&((i={})[t]=e),r=new ee(i,null,n||null));this.repo.removeEventCallbackForQuery(this,r)},t.prototype.once=function(e,n,r,i){var o=this;u.validateArgCount("Query.once",1,4,arguments.length),ct("Query.once",1,e,!1),u.validateCallback("Query.once",2,n,!0);var a=t.getCancelAndContextArgs_("Query.once",r,i),s=!0,c=new u.Deferred;c.promise.catch((function(){}));var h=function t(r){s&&(s=!1,o.off(e,t),n&&n.bind(a.context)(r),c.resolve(r))};return this.on(e,h,(function(t){o.off(e,h),a.cancel&&a.cancel.bind(a.context)(t),c.reject(t)})),c.promise},t.prototype.limitToFirst=function(e){if(u.validateArgCount("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(u.validateArgCount("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(u.validateArgCount("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.');lt("Query.orderByChild",1,e,!1),this.validateNoPreviousOrderByCall_("Query.orderByChild");var n=new z(e);if(n.isEmpty())throw new Error("Query.orderByChild: cannot pass in empty path. Use Query.orderByValue() instead.");var r=new Xt(n),i=this.queryParams_.orderBy(r);return t.validateQueryEndpoints_(i),new t(this.repo,this.path,i,!0)},t.prototype.orderByKey=function(){u.validateArgCount("Query.orderByKey",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByKey");var e=this.queryParams_.orderBy(Et);return t.validateQueryEndpoints_(e),new t(this.repo,this.path,e,!0)},t.prototype.orderByPriority=function(){u.validateArgCount("Query.orderByPriority",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByPriority");var e=this.queryParams_.orderBy(Rt);return t.validateQueryEndpoints_(e),new t(this.repo,this.path,e,!0)},t.prototype.orderByValue=function(){u.validateArgCount("Query.orderByValue",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByValue");var e=this.queryParams_.orderBy(Yt);return t.validateQueryEndpoints_(e),new t(this.repo,this.path,e,!0)},t.prototype.startAt=function(e,n){void 0===e&&(e=null),u.validateArgCount("Query.startAt",0,2,arguments.length),ot("Query.startAt",1,e,this.path,!0),ht("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),u.validateArgCount("Query.endAt",0,2,arguments.length),ot("Query.endAt",1,e,this.path,!0),ht("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(u.validateArgCount("Query.equalTo",1,2,arguments.length),ot("Query.equalTo",1,t,this.path,!1),ht("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 u.validateArgCount("Query.toString",0,0,arguments.length),this.repo.toString()+this.path.toUrlEncodedString()},t.prototype.toJSON=function(){return u.validateArgCount("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=P(t);return"{}"===e?"default":e},t.prototype.isEqual=function(e){if(u.validateArgCount("Query.isEqual",1,1,arguments.length),!(e instanceof t)){var n="Query.isEqual failed: First argument must be an instance of firebase.database.Query.";throw new Error(n)}var r=this.repo===e.repo,i=this.path.equals(e.path),o=this.queryIdentifier()===e.queryIdentifier();return r&&i&&o},t.getCancelAndContextArgs_=function(t,e,n){var r={cancel:null,context:null};if(e&&n)r.cancel=e,u.validateCallback(t,3,r.cancel,!0),r.context=n,u.validateContextObject(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(u.errorPrefix(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}(),re=function(){function t(){this.value=null,this.children=new Map}return t.prototype.find=function(t){if(null!=this.value)return this.value.getChild(t);if(!t.isEmpty()&&this.children.size>0){var e=t.getFront();return t=t.popFront(),this.children.has(e)?this.children.get(e).find(t):null}return null},t.prototype.remember=function(e,n){if(e.isEmpty())this.value=n,this.children.clear();else if(null!==this.value)this.value=this.value.updateChild(e,n);else{var r=e.getFront();this.children.has(r)||this.children.set(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.clear(),!0;if(null!==this.value){if(this.value.isLeafNode())return!1;var e=this.value;this.value=null;var n=this;return e.forEachChild(Rt,(function(t,e){n.remember(new z(t),e)})),this.forget(t)}if(this.children.size>0){var r=t.getFront();if(t=t.popFront(),this.children.has(r))this.children.get(r).forget(t)&&this.children.delete(r);return 0===this.children.size}return!0},t.prototype.forEachTree=function(t,e){null!==this.value?e(t,this.value):this.forEachChild((function(n,r){var i=new z(t.toString()+"/"+n);r.forEachTree(i,e)}))},t.prototype.forEachChild=function(t){this.children.forEach((function(e,n){t(n,e)}))},t}(),ie=function(t,e,n){return t&&"object"==typeof t?(u.assert(".sv"in t,"Unexpected leaf node or priority contents"),"string"==typeof t[".sv"]?oe(t[".sv"],e,n):"object"==typeof t[".sv"]?ae(t[".sv"],e):void u.assert(!1,"Unexpected server value: "+JSON.stringify(t,null,2))):t},oe=function(t,e,n){switch(t){case"timestamp":return n.timestamp;default:u.assert(!1,"Unexpected server value: "+t)}},ae=function(t,e,n){t.hasOwnProperty("increment")||u.assert(!1,"Unexpected server value: "+JSON.stringify(t,null,2));var r=t.increment;if("number"!=typeof r&&u.assert(!1,"Unexpected increment value: "+r),!e.isLeafNode())return r;var i=e.getValue();return"number"!=typeof i?r:i+r},se=function t(e,n,r){var i,o=e.getPriority().val(),a=ie(o,n.getPriority(),r);if(e.isLeafNode()){var s=e,u=ie(s.getValue(),n,r);return u!==s.getValue()||a!==s.getPriority().val()?new Nt(u,Kt(a)):e}var c=e;return i=c,a!==c.getPriority().val()&&(i=i.updatePriority(new Nt(a))),c.forEachChild(Rt,(function(e,o){var a=t(o,n.getImmediateChild(e),r);a!==o&&(i=i.updateImmediateChild(e,a))})),i};!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"}(Gt||(Gt={}));var ue,ce,he=function(){function t(t,e,n,r){this.fromUser=t,this.fromServer=e,this.queryId=n,this.tagged=r,u.assert(!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}(),le=function(){function t(t,e,n){this.path=t,this.affectedTree=e,this.revert=n,this.type=Gt.ACK_USER_WRITE,this.source=he.User}return t.prototype.operationForChild=function(e){if(this.path.isEmpty()){if(null!=this.affectedTree.value)return u.assert(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var n=this.affectedTree.subtree(new z(e));return new t(z.Empty,n,this.revert)}return u.assert(this.path.getFront()===e,"operationForChild called for unrelated child."),new t(this.path.popFront(),this.affectedTree,this.revert)},t}(),fe=function(){return ue||(ue=new Mt(O)),ue},pe=function(){function t(t,e){void 0===e&&(e=fe()),this.value=t,this.children=e}return t.fromObject=function(e){var n=t.Empty;return L(e,(function(t,e){n=n.set(new z(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:z.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 z(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_(z.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,z.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,z.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_(z.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}(),de=function(){function t(t,e){this.source=t,this.path=e,this.type=Gt.LISTEN_COMPLETE}return t.prototype.operationForChild=function(e){return this.path.isEmpty()?new t(this.source,z.Empty):new t(this.source,this.path.popFront())},t}(),me=function(){function t(t,e,n){this.source=t,this.path=e,this.snap=n,this.type=Gt.OVERWRITE}return t.prototype.operationForChild=function(e){return this.path.isEmpty()?new t(this.source,z.Empty,this.snap.getImmediateChild(e)):new t(this.source,this.path.popFront(),this.snap)},t}(),ye=function(){function t(t,e,n){this.source=t,this.path=e,this.children=n,this.type=Gt.MERGE}return t.prototype.operationForChild=function(e){if(this.path.isEmpty()){var n=this.children.subtree(new z(e));return n.isEmpty()?null:n.value?new me(this.source,z.Empty,n.value):new t(this.source,z.Empty,n)}return u.assert(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}(),ge=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}(),ve=function(){function t(t,e){this.eventCache_=t,this.serverCache_=e}return t.prototype.updateEventSnap=function(e,n,r){return new t(new ge(e,n,r),this.serverCache_)},t.prototype.updateServerSnap=function(e,n,r){return new t(this.eventCache_,new ge(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 ge(zt.EMPTY_NODE,!1,!1),new ge(zt.EMPTY_NODE,!1,!1)),t}(),_e=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}(),be=function(){function t(t){this.index_=t}return t.prototype.updateChild=function(t,e,n,r,i,o){u.assert(t.isIndexed(this.index_),"A node must be indexed if only a child is updated");var a=t.getImmediateChild(e);return a.getChild(r).equals(n.getChild(r))&&a.isEmpty()==n.isEmpty()?t:(null!=o&&(n.isEmpty()?t.hasChild(e)?o.trackChildChange(_e.childRemovedChange(e,a)):u.assert(t.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(_e.childAddedChange(e,n)):o.trackChildChange(_e.childChangedChange(e,n,a))),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(Rt,(function(t,r){e.hasChild(t)||n.trackChildChange(_e.childRemovedChange(t,r))})),e.isLeafNode()||e.forEachChild(Rt,(function(e,r){if(t.hasChild(e)){var i=t.getImmediateChild(e);i.equals(r)||n.trackChildChange(_e.childChangedChange(e,r,i))}else n.trackChildChange(_e.childAddedChange(e,r))}))),e.withIndex(this.index_)},t.prototype.updatePriority=function(t,e){return t.isEmpty()?zt.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}(),we=function(){function t(){this.changeMap=new Map}return t.prototype.trackChildChange=function(t){var e=t.type,n=t.childName;u.assert(e==_e.CHILD_ADDED||e==_e.CHILD_CHANGED||e==_e.CHILD_REMOVED,"Only child changes supported for tracking"),u.assert(".priority"!==n,"Only non-priority child changes can be tracked.");var r=this.changeMap.get(n);if(r){var i=r.type;if(e==_e.CHILD_ADDED&&i==_e.CHILD_REMOVED)this.changeMap.set(n,_e.childChangedChange(n,t.snapshotNode,r.snapshotNode));else if(e==_e.CHILD_REMOVED&&i==_e.CHILD_ADDED)this.changeMap.delete(n);else if(e==_e.CHILD_REMOVED&&i==_e.CHILD_CHANGED)this.changeMap.set(n,_e.childRemovedChange(n,r.oldSnap));else if(e==_e.CHILD_CHANGED&&i==_e.CHILD_ADDED)this.changeMap.set(n,_e.childAddedChange(n,t.snapshotNode));else{if(e!=_e.CHILD_CHANGED||i!=_e.CHILD_CHANGED)throw u.assertionError("Illegal combination of changes: "+t+" occurred after "+r);this.changeMap.set(n,_e.childChangedChange(n,t.snapshotNode,r.oldSnap))}}else this.changeMap.set(n,t)},t.prototype.getChanges=function(){return Array.from(this.changeMap.values())},t}(),Ee=new(function(){function t(){}return t.prototype.getCompleteChild=function(t){return null},t.prototype.getChildAfterChild=function(t,e,n){return null},t}()),Te=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 ge(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}(),Ce=function(t,e){this.viewCache=t,this.changes=e},Se=function(){function t(t){this.filter_=t}return t.prototype.assertIndexed=function(t){u.assert(t.getEventCache().getNode().isIndexed(this.filter_.getIndex()),"Event snap not indexed"),u.assert(t.getServerCache().getNode().isIndexed(this.filter_.getIndex()),"Server snap not indexed")},t.prototype.applyOperation=function(e,n,r,i){var o,a,s=new we;if(n.type===Gt.OVERWRITE){var c=n;c.source.fromUser?o=this.applyUserOverwrite_(e,c.path,c.snap,r,i,s):(u.assert(c.source.fromServer,"Unknown source."),a=c.source.tagged||e.getServerCache().isFiltered()&&!c.path.isEmpty(),o=this.applyServerOverwrite_(e,c.path,c.snap,r,i,a,s))}else if(n.type===Gt.MERGE){var h=n;h.source.fromUser?o=this.applyUserMerge_(e,h.path,h.children,r,i,s):(u.assert(h.source.fromServer,"Unknown source."),a=h.source.tagged||e.getServerCache().isFiltered(),o=this.applyServerMerge_(e,h.path,h.children,r,i,a,s))}else if(n.type===Gt.ACK_USER_WRITE){var l=n;o=l.revert?this.revertUserWrite_(e,l.path,r,i,s):this.ackUserWrite_(e,l.path,l.affectedTree,r,i,s)}else{if(n.type!==Gt.LISTEN_COMPLETE)throw u.assertionError("Unknown operation type: "+n.type);o=this.listenComplete_(e,n.path,r,s)}var f=s.getChanges();return t.maybeAddValueEvent_(e,o,f),new Ce(o,f)},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(_e.valueChange(e.getCompleteEventSnap()))}},t.prototype.generateEventCacheAfterServerEvent_=function(t,e,n,r,i){var o=t.getEventCache();if(null!=n.shadowingWrite(e))return t;var a=void 0,s=void 0;if(e.isEmpty())if(u.assert(t.getServerCache().isFullyInitialized(),"If change path is empty, we must have complete server data"),t.getServerCache().isFiltered()){var c=t.getCompleteServerSnap(),h=c instanceof zt?c:zt.EMPTY_NODE,l=n.calcCompleteEventChildren(h);a=this.filter_.updateFullNode(t.getEventCache().getNode(),l,i)}else{var f=n.calcCompleteEventCache(t.getCompleteServerSnap());a=this.filter_.updateFullNode(t.getEventCache().getNode(),f,i)}else{var p=e.getFront();if(".priority"==p){u.assert(1==e.getLength(),"Can't have a priority with additional path components");var d=o.getNode();s=t.getServerCache().getNode();var m=n.calcEventCacheAfterServerOverwrite(e,d,s);a=null!=m?this.filter_.updatePriority(d,m):o.getNode()}else{var y=e.popFront(),g=void 0;if(o.isCompleteForChild(p)){s=t.getServerCache().getNode();var v=n.calcEventCacheAfterServerOverwrite(e,o.getNode(),s);g=null!=v?o.getNode().getImmediateChild(p).updateChild(y,v):o.getNode().getImmediateChild(p)}else g=n.calcCompleteChild(p,t.getServerCache());a=null!=g?this.filter_.updateChild(o.getNode(),p,g,y,r,i):o.getNode()}}return t.updateEventSnap(a,o.isFullyInitialized()||e.isEmpty(),this.filter_.filtersNodes())},t.prototype.applyServerOverwrite_=function(t,e,n,r,i,o,a){var s,u=t.getServerCache(),c=o?this.filter_:this.filter_.getIndexedFilter();if(e.isEmpty())s=c.updateFullNode(u.getNode(),n,null);else if(c.filtersNodes()&&!u.isFiltered()){var h=u.getNode().updateChild(e,n);s=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);s=".priority"==l?c.updatePriority(u.getNode(),p):c.updateChild(u.getNode(),l,p,f,Ee,null)}var d=t.updateServerSnap(s,u.isFullyInitialized()||e.isEmpty(),c.filtersNodes()),m=new Te(r,d,i);return this.generateEventCacheAfterServerEvent_(d,e,r,m,a)},t.prototype.applyUserOverwrite_=function(t,e,n,r,i,o){var a,s,u=t.getEventCache(),c=new Te(r,t,i);if(e.isEmpty())s=this.filter_.updateFullNode(t.getEventCache().getNode(),n,o),a=t.updateEventSnap(s,!0,this.filter_.filtersNodes());else{var h=e.getFront();if(".priority"===h)s=this.filter_.updatePriority(t.getEventCache().getNode(),n),a=t.updateEventSnap(s,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):zt.EMPTY_NODE}if(f.equals(p))a=t;else{var m=this.filter_.updateChild(u.getNode(),h,p,l,c,o);a=t.updateEventSnap(m,u.isFullyInitialized(),this.filter_.filtersNodes())}}}return a},t.cacheHasChild_=function(t,e){return t.getEventCache().isCompleteForChild(e)},t.prototype.applyUserMerge_=function(e,n,r,i,o,a){var s=this,u=e;return r.foreach((function(r,c){var h=n.child(r);t.cacheHasChild_(e,h.getFront())&&(u=s.applyUserOverwrite_(u,h,c,i,o,a))})),r.foreach((function(r,c){var h=n.child(r);t.cacheHasChild_(e,h.getFront())||(u=s.applyUserOverwrite_(u,h,c,i,o,a))})),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,a){var s=this;if(t.getServerCache().getNode().isEmpty()&&!t.getServerCache().isFullyInitialized())return t;var u,c=t;u=e.isEmpty()?n:pe.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=s.applyMerge_(u,n);c=s.applyServerOverwrite_(c,new z(e),l,r,i,o,a)}})),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=s.applyMerge_(l,n);c=s.applyServerOverwrite_(c,new z(e),f,r,i,o,a)}})),c},t.prototype.ackUserWrite_=function(t,e,n,r,i,o){if(null!=r.shadowingWrite(e))return t;var a=t.getServerCache().isFiltered(),s=t.getServerCache();if(null!=n.value){if(e.isEmpty()&&s.isFullyInitialized()||s.isCompleteForPath(e))return this.applyServerOverwrite_(t,e,s.getNode().getChild(e),r,i,a,o);if(e.isEmpty()){var u=pe.Empty;return s.getNode().forEachChild(Et,(function(t,e){u=u.set(new z(t),e)})),this.applyServerMerge_(t,e,u,r,i,a,o)}return t}var c=pe.Empty;return n.foreach((function(t,n){var r=e.child(t);s.isCompleteForPath(r)&&(c=c.set(t,s.getNode().getChild(r)))})),this.applyServerMerge_(t,e,c,r,i,a,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,Ee,r)},t.prototype.revertUserWrite_=function(t,e,n,r,i){var o;if(null!=n.shadowingWrite(e))return t;var a=new Te(n,t,r),s=t.getEventCache().getNode(),c=void 0;if(e.isEmpty()||".priority"===e.getFront()){var h=void 0;if(t.getServerCache().isFullyInitialized())h=n.calcCompleteEventCache(t.getCompleteServerSnap());else{var l=t.getServerCache().getNode();u.assert(l instanceof zt,"serverChildren would be complete if leaf node"),h=n.calcCompleteEventChildren(l)}h=h,c=this.filter_.updateFullNode(s,h,i)}else{var f=e.getFront(),p=n.calcCompleteChild(f,t.getServerCache());null==p&&t.getServerCache().isCompleteForChild(f)&&(p=s.getImmediateChild(f)),(c=null!=p?this.filter_.updateChild(s,f,p,e.popFront(),a,i):t.getEventCache().getNode().hasChild(f)?this.filter_.updateChild(s,f,zt.EMPTY_NODE,e.popFront(),a,i):s).isEmpty()&&t.getServerCache().isFullyInitialized()&&(o=n.calcCompleteEventCache(t.getCompleteServerSnap())).isLeafNode()&&(c=this.filter_.updateFullNode(c,o,i))}return o=t.getServerCache().isFullyInitialized()||null!=n.shadowingWrite(z.Empty),t.updateEventSnap(c,o,this.filter_.filtersNodes())},t}(),Ie=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===_e.CHILD_CHANGED&&r.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&&o.push(_e.childMovedChange(t.childName,t.snapshotNode))})),this.generateEventsForType_(i,_e.CHILD_REMOVED,t,n,e),this.generateEventsForType_(i,_e.CHILD_ADDED,t,n,e),this.generateEventsForType_(i,_e.CHILD_MOVED,o,n,e),this.generateEventsForType_(i,_e.CHILD_CHANGED,t,n,e),this.generateEventsForType_(i,_e.VALUE,t,n,e),i},t.prototype.generateEventsForType_=function(t,e,n,r,i){var o=this,a=n.filter((function(t){return t.type===e}));a.sort(this.compareChanges_.bind(this)),a.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 u.assertionError("Should only compare child_ events.");var n=new _t(t.childName,t.snapshotNode),r=new _t(e.childName,e.snapshotNode);return this.index_.compare(n,r)},t}(),De=function(){function t(t,e){this.query_=t,this.eventRegistrations_=[];var n=this.query_.getQueryParams(),r=new be(n.getIndex()),i=n.getNodeFilter();this.processor_=new Se(i);var o=e.getServerCache(),a=e.getEventCache(),s=r.updateFullNode(zt.EMPTY_NODE,o.getNode(),null),u=i.updateFullNode(zt.EMPTY_NODE,a.getNode(),null),c=new ge(s,o.isFullyInitialized(),r.filtersNodes()),h=new ge(u,a.isFullyInitialized(),i.filtersNodes());this.viewCache_=new ve(h,c),this.eventGenerator_=new Ie(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){u.assert(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 a=this.eventRegistrations_[o];if(a.matches(t)){if(t.hasAnyCallback()){i=i.concat(this.eventRegistrations_.slice(o+1));break}}else i.push(a)}this.eventRegistrations_=i}else this.eventRegistrations_=[];return n},t.prototype.applyOperation=function(t,e,n){t.type===Gt.MERGE&&null!==t.source.queryId&&(u.assert(this.viewCache_.getCompleteServerSnap(),"We should always have a full cache before handling merges"),u.assert(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),u.assert(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(Rt,(function(t,e){n.push(_e.childAddedChange(t,e))}));return e.isFullyInitialized()&&n.push(_e.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}(),Ne=function(){function t(){this.views=new Map}return Object.defineProperty(t,"__referenceConstructor",{get:function(){return u.assert(ce,"Reference.ts has not been loaded"),ce},set:function(t){u.assert(!ce,"__referenceConstructor has already been defined"),ce=t},enumerable:!0,configurable:!0}),t.prototype.isEmpty=function(){return 0===this.views.size},t.prototype.applyOperation=function(t,e,n){var r,i,o=t.source.queryId;if(null!==o){var a=this.views.get(o);return u.assert(null!=a,"SyncTree gave us an op for an invalid query."),a.applyOperation(t,e,n)}var c=[];try{for(var h=s.__values(this.views.values()),l=h.next();!l.done;l=h.next()){a=l.value;c=c.concat(a.applyOperation(t,e,n))}}catch(f){r={error:f}}finally{try{l&&!l.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}return c},t.prototype.addEventRegistration=function(t,e,n,r,i){var o=t.queryIdentifier(),a=this.views.get(o);if(!a){var s=n.calcCompleteEventCache(i?r:null),u=!1;s?u=!0:r instanceof zt?(s=n.calcCompleteEventChildren(r),u=!1):(s=zt.EMPTY_NODE,u=!1);var c=new ve(new ge(s,u,!1),new ge(r,i,!1));a=new De(t,c),this.views.set(o,a)}return a.addEventRegistration(e),a.getInitialEvents(e)},t.prototype.removeEventRegistration=function(e,n,r){var i,o,a=e.queryIdentifier(),u=[],c=[],h=this.hasCompleteView();if("default"===a)try{for(var l=s.__values(this.views.entries()),f=l.next();!f.done;f=l.next()){var p=s.__read(f.value,2),d=p[0],m=p[1];c=c.concat(m.removeEventRegistration(n,r)),m.isEmpty()&&(this.views.delete(d),m.getQuery().getQueryParams().loadsAllData()||u.push(m.getQuery()))}}catch(y){i={error:y}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(i)throw i.error}}else(m=this.views.get(a))&&(c=c.concat(m.removeEventRegistration(n,r)),m.isEmpty()&&(this.views.delete(a),m.getQuery().getQueryParams().loadsAllData()||u.push(m.getQuery())));return h&&!this.hasCompleteView()&&u.push(new t.__referenceConstructor(e.repo,e.path)),{removed:u,events:c}},t.prototype.getQueryViews=function(){var t,e,n=[];try{for(var r=s.__values(this.views.values()),i=r.next();!i.done;i=r.next()){var o=i.value;o.getQuery().getQueryParams().loadsAllData()||n.push(o)}}catch(a){t={error:a}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}return n},t.prototype.getCompleteServerCache=function(t){var e,n,r=null;try{for(var i=s.__values(this.views.values()),o=i.next();!o.done;o=i.next()){var a=o.value;r=r||a.getCompleteServerCache(t)}}catch(u){e={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r},t.prototype.viewForQuery=function(t){if(t.getQueryParams().loadsAllData())return this.getCompleteView();var e=t.queryIdentifier();return this.views.get(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;try{for(var n=s.__values(this.views.values()),r=n.next();!r.done;r=n.next()){var i=r.value;if(i.getQuery().getQueryParams().loadsAllData())return i}}catch(o){t={error:o}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return null},t}(),Ae=function(){function t(t){this.writeTree_=t}return t.prototype.addWrite=function(e,n){if(e.isEmpty())return new t(new pe(n));var r=this.writeTree_.findRootMostValueAndPath(e);if(null!=r){var i=r.path,o=r.value,a=z.relativePath(i,e);return o=o.updateChild(a,n),new t(this.writeTree_.set(i,o))}var s=new pe(n);return new t(this.writeTree_.setTree(e,s))},t.prototype.addWrites=function(t,e){var n=this;return L(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,pe.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(z.relativePath(e.path,t)):null},t.prototype.getCompleteChildren=function(){var t=[],e=this.writeTree_.value;return null!=e?e.isLeafNode()||e.forEachChild(Rt,(function(e,n){t.push(new _t(e,n))})):this.writeTree_.children.inorderTraversal((function(e,n){null!=n.value&&t.push(new _t(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 pe(n):this.writeTree_.subtree(e))},t.prototype.isEmpty=function(){return this.writeTree_.isEmpty()},t.prototype.apply=function(t){return function t(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?(u.assert(null!==o.value,"Priority writes must always be leaf nodes"),i=o.value):r=t(e.child(n),o,r)})),r.getChild(e).isEmpty()||null===i||(r=r.updateChild(e.child(".priority"),i)),r}(z.Empty,this.writeTree_,t)},t.Empty=new t(new pe(null)),t}();var ke=function(){function t(){this.visibleWrites_=Ae.Empty,this.allWrites_=[],this.lastWriteId_=-1}return t.prototype.childWrites=function(t){return new Re(t,this)},t.prototype.addOverwrite=function(t,e,n,r){u.assert(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){u.assert(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}));u.assert(n>=0,"removeWrite called with nonexistent writeId.");var r=this.allWrites_[n];this.allWrites_.splice(n,1);for(var i=r.visible,o=!1,a=this.allWrites_.length-1;i&&a>=0;){var s=this.allWrites_[a];s.visible&&(a>=n&&this.recordContainsPath_(s,r.path)?i=!1:r.path.contains(s.path)&&(o=!0)),a--}if(i){if(o)return this.resetTree_(),!0;r.snap?this.visibleWrites_=this.visibleWrites_.removeWrite(r.path):L(r.children,(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(z.Empty)){var a=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||zt.EMPTY_NODE;return a.apply(c)}return null}var s=this.visibleWrites_.getCompleteNode(e);if(null!=s)return s;var u=this.visibleWrites_.childCompoundWrite(e);if(u.isEmpty())return n;if(null!=n||u.hasCompleteWrite(z.Empty)){var c=n||zt.EMPTY_NODE;return u.apply(c)}return null},t.prototype.calcCompleteEventChildren=function(t,e){var n=zt.EMPTY_NODE,r=this.visibleWrites_.getCompleteNode(t);if(r)return r.isLeafNode()||r.forEachChild(Rt,(function(t,e){n=n.updateImmediateChild(t,e)})),n;if(e){var i=this.visibleWrites_.childCompoundWrite(t);return e.forEachChild(Rt,(function(t,e){var r=i.childCompoundWrite(new z(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){u.assert(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 a,s=this.visibleWrites_.childCompoundWrite(t),u=s.getCompleteNode(z.Empty);if(null!=u)a=u;else{if(null==e)return[];a=s.apply(e)}if((a=a.withIndex(o)).isEmpty()||a.isLeafNode())return[];for(var c=[],h=o.getCompare(),l=i?a.getReverseIteratorFrom(n,o):a.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){if(t.snap)return t.path.contains(e);for(var n in t.children)if(t.children.hasOwnProperty(n)&&t.path.child(n).contains(e))return!0;return!1},t.prototype.resetTree_=function(){this.visibleWrites_=t.layerTree_(this.allWrites_,t.DefaultFilter_,z.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=Ae.Empty,i=0;i<t.length;++i){var o=t[i];if(e(o)){var a=o.path,s=void 0;if(o.snap)n.contains(a)?(s=z.relativePath(n,a),r=r.addWrite(s,o.snap)):a.contains(n)&&(s=z.relativePath(a,n),r=r.addWrite(z.Empty,o.snap.getChild(s)));else{if(!o.children)throw u.assertionError("WriteRecord should have .snap or .children");if(n.contains(a))s=z.relativePath(n,a),r=r.addWrites(s,o.children);else if(a.contains(n))if((s=z.relativePath(a,n)).isEmpty())r=r.addWrites(z.Empty,o.children);else{var c=u.safeGet(o.children,s.getFront());if(c){var h=c.getChild(s.popFront());r=r.addWrite(z.Empty,h)}}}}}return r},t}(),Re=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}(),Oe=function(){function t(t){this.listenProvider_=t,this.syncPointTree_=pe.Empty,this.pendingWriteTree_=new ke,this.tagToQueryMap=new Map,this.queryToTagMap=new Map}return t.prototype.applyUserOverwrite=function(t,e,n,r){return this.pendingWriteTree_.addOverwrite(t,e,n,r),r?this.applyOperationToSyncPoints_(new me(he.User,t,e)):[]},t.prototype.applyUserMerge=function(t,e,n){this.pendingWriteTree_.addMerge(t,e,n);var r=pe.fromObject(e);return this.applyOperationToSyncPoints_(new ye(he.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=pe.Empty;return null!=n.snap?r=r.set(z.Empty,!0):L(n.children,(function(t,e){r=r.set(new z(t),e)})),this.applyOperationToSyncPoints_(new le(n.path,r,e))}return[]},t.prototype.applyServerOverwrite=function(t,e){return this.applyOperationToSyncPoints_(new me(he.Server,t,e))},t.prototype.applyServerMerge=function(t,e){var n=pe.fromObject(e);return this.applyOperationToSyncPoints_(new ye(he.Server,t,n))},t.prototype.applyListenComplete=function(t){return this.applyOperationToSyncPoints_(new de(he.Server,t))},t.prototype.applyTaggedQueryOverwrite=function(e,n,r){var i=this.queryKeyForTag_(r);if(null!=i){var o=t.parseQueryKey_(i),a=o.path,s=o.queryId,u=z.relativePath(a,e),c=new me(he.forServerTaggedQuery(s),u,n);return this.applyTaggedOperation_(a,c)}return[]},t.prototype.applyTaggedQueryMerge=function(e,n,r){var i=this.queryKeyForTag_(r);if(i){var o=t.parseQueryKey_(i),a=o.path,s=o.queryId,u=z.relativePath(a,e),c=pe.fromObject(n),h=new ye(he.forServerTaggedQuery(s),u,c);return this.applyTaggedOperation_(a,h)}return[]},t.prototype.applyTaggedListenComplete=function(e,n){var r=this.queryKeyForTag_(n);if(r){var i=t.parseQueryKey_(r),o=i.path,a=i.queryId,s=z.relativePath(o,e),u=new de(he.forServerTaggedQuery(a),s);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=z.relativePath(t,r);i=i||e.getCompleteServerCache(n),o=o||e.hasCompleteView()}));var a,s=this.syncPointTree_.get(r);(s?(o=o||s.hasCompleteView(),i=i||s.getCompleteServerCache(z.Empty)):(s=new Ne,this.syncPointTree_=this.syncPointTree_.set(r,s)),null!=i)?a=!0:(a=!1,i=zt.EMPTY_NODE,this.syncPointTree_.subtree(r).foreachChild((function(t,e){var n=e.getCompleteServerCache(z.Empty);n&&(i=i.updateImmediateChild(t,n))})));var c=s.viewExistsForQuery(e);if(!c&&!e.getQueryParams().loadsAllData()){var h=t.makeQueryKey_(e);u.assert(!this.queryToTagMap.has(h),"View does not exist, but we have a tag");var l=t.getNextQueryTag_();this.queryToTagMap.set(h,l),this.tagToQueryMap.set(l,h)}var f=this.pendingWriteTree_.childWrites(r),p=s.addEventRegistration(e,n,f,i,a);if(!c&&!o){var d=s.viewForQuery(e);p=p.concat(this.setupListener_(e,d))}return p},t.prototype.removeEventRegistration=function(e,n,r){var i=this,o=e.path,a=this.syncPointTree_.get(o),s=[];if(a&&("default"===e.queryIdentifier()||a.viewExistsForQuery(e))){var u=a.removeEventRegistration(e,n,r);a.isEmpty()&&(this.syncPointTree_=this.syncPointTree_.remove(o));var c=u.removed;s=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 m=p[d],y=m.getQuery(),g=this.createListenerForView_(m);this.listenProvider_.startListening(t.queryForListening_(y),this.tagForQuery_(y),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.get(t.makeQueryKey_(e));i.listenProvider_.stopListening(t.queryForListening_(e),n)}));this.removeTags_(c)}return s},t.prototype.calcCompleteEventCache=function(t,e){var n=this.pendingWriteTree_,r=this.syncPointTree_.findOnPath(t,(function(e,n){var r=z.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()),L(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.get(i);this.queryToTagMap.delete(i),this.tagToQueryMap.delete(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),a=this.listenProvider_.startListening(t.queryForListening_(e),i,o.hashFn,o.onComplete),s=this.syncPointTree_.subtree(r);if(i)u.assert(!s.value.hasCompleteView(),"If we're adding a query, it shouldn't be shadowed");else for(var c=s.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()})))),L(n,(function(t,e){r=r.concat(e)})),r})),h=0;h<c.length;++h){var l=c[h];this.listenProvider_.stopListening(t.queryForListening_(l),this.tagForQuery_(l))}return a},t.prototype.createListenerForView_=function(t){var e=this,n=t.getQuery(),r=this.tagForQuery_(n);return{hashFn:function(){return(t.getServerCache()||zt.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 u.assert(-1!==e&&e<t.length-1,"Bad queryKey."),{queryId:t.substr(e+1),path:new z(t.substr(0,e))}},t.prototype.queryKeyForTag_=function(t){return this.tagToQueryMap.get(t)},t.prototype.tagForQuery_=function(e){var n=t.makeQueryKey_(e);return this.queryToTagMap.get(n)},t.getNextQueryTag_=function(){return t.nextQueryTag_++},t.prototype.applyTaggedOperation_=function(t,e){var n=this.syncPointTree_.get(t);u.assert(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(z.Empty))},t.prototype.applyOperationHelper_=function(t,e,n,r){if(t.path.isEmpty())return this.applyOperationDescendantsHelper_(t,e,n,r);var i=e.get(z.Empty);null==n&&null!=i&&(n=i.getCompleteServerCache(z.Empty));var o=[],a=t.path.getFront(),s=t.operationForChild(a),u=e.children.get(a);if(u&&s){var c=n?n.getImmediateChild(a):null,h=r.child(a);o=o.concat(this.applyOperationHelper_(s,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(z.Empty);null==n&&null!=o&&(n=o.getCompleteServerCache(z.Empty));var a=[];return e.children.inorderTraversal((function(e,o){var s=n?n.getImmediateChild(e):null,u=r.child(e),c=t.operationForChild(e);c&&(a=a.concat(i.applyOperationDescendantsHelper_(c,o,s,u)))})),o&&(a=a.concat(o.applyOperation(t,r,n))),a},t.nextQueryTag_=1,t}(),xe=function(){function t(){this.rootNode_=zt.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}(),Pe=function(){function t(t,e){var n=this;this.app_=t,this.authProvider_=e,this.auth_=null,this.auth_=e.getImmediate({optional:!0}),this.auth_||e.get().then((function(t){return n.auth_=t}))}return t.prototype.getToken=function(t){return this.auth_?this.auth_.getToken(t).catch((function(t){return t&&"auth/token-not-initialized"===t.code?(T("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(t)})):Promise.resolve(null)},t.prototype.addTokenChangeListener=function(t){this.auth_?this.auth_.addAuthTokenListener(t):(setTimeout((function(){return t(null)}),0),this.authProvider_.get().then((function(e){return e.addAuthTokenListener(t)})))},t.prototype.removeTokenChangeListener=function(t){this.authProvider_.get().then((function(e){return e.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/.',D(t)},t}(),Me=function(){function t(){this.counters_={}}return t.prototype.incrementCounter=function(t,e){void 0===e&&(e=1),u.contains(this.counters_,t)||(this.counters_[t]=0),this.counters_[t]+=e},t.prototype.get=function(){return u.deepCopy(this.counters_)},t}(),Le=function(){function t(){}return t.getCollection=function(t){var e=t.toString();return this.collections_[e]||(this.collections_[e]=new Me),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}(),Fe=function(){function t(t){this.collection_=t,this.last_=null}return t.prototype.get=function(){var t=this.collection_.get(),e=s.__assign({},t);return this.last_&&L(this.last_,(function(t,n){e[t]=e[t]-n})),this.last_=t,e},t}(),Ue=1e4,qe=3e4,Ve=function(){function t(t,e){this.server_=e,this.statsToReport_={},this.statsListener_=new Fe(t);var n=Ue+(qe-Ue)*Math.random();j(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;L(e,(function(e,i){i>0&&u.contains(t.statsToReport_,e)&&(n[e]=i,r=!0)})),r&&this.server_.reportStats(n),j(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))},t}(),Be=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 je(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}(),je=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();b&&T("event: "+e.toString()),V(n)}}},t.prototype.getPath=function(){return this.path_},t}(),ze=function(){function t(t){this.allowedEvents_=t,this.listeners_={},u.assert(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=s.__spread(this.listeners_[t]),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){u.assert(this.allowedEvents_.find((function(e){return e===t})),"Unknown event: "+t)},t}(),We=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 s.__extends(e,t),e.getInstance=function(){return new e},e.prototype.getInitialEvent=function(t){return u.assert("visible"===t,"Unknown event type: "+t),[this.visible_]},e}(ze),Qe=function(t){function e(){var e=t.call(this,["online"])||this;return e.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||u.isMobileCordova()||(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 s.__extends(e,t),e.getInstance=function(){return new e},e.prototype.getInitialEvent=function(t){return u.assert("online"===t,"Unknown event type: "+t),[this.online_]},e.prototype.currentlyOnline=function(){return this.online_},e}(ze),Ke=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]&&V((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}(),He="pLPCommand",Ge="pRTLPCB",Ye=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_=C(t),this.stats_=Le.getCollection(e),this.urlFn=function(t){return e.connectionURL(Q,t)}}return t.prototype.open=function(t,e){var n=this;this.curSegmentNum=0,this.onDisconnect_=e,this.myPacketOrderer=new Ke(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(u.isNodeSdk()||"complete"===document.readyState)t();else{var e=!1,n=function n(){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 Xe((function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=s.__read(t,5),i=r[0],o=r[1],a=r[2];r[3],r[4];if(n.incrementIncomingBytes_(t),n.scriptTagHolder)if(n.connectTimeoutTimer_&&(clearTimeout(n.connectTimeoutTimer_),n.connectTimeoutTimer_=null),n.everConnected_=!0,"start"==i)n.id=o,n.password=a;else{if("close"!==i)throw new Error("Unrecognized command received: "+i);o?(n.scriptTagHolder.sendNewPolls=!1,n.myPacketOrderer.closeAfter(o,(function(){n.onClosed_()}))):n.onClosed_()}}),(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=s.__read(t,2),i=r[0],o=r[1];n.incrementIncomingBytes_(t),n.myPacketOrderer.handleResponse(i,o)}),(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),"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!u.isNodeSdk()&&(!!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))},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=u.stringify(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);for(var n=u.base64Encode(e),r=M(n,1840),i=0;i<r.length;i++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,r.length,r[i]),this.curSegmentNum++},t.prototype.addDisconnectPingFrame=function(t,e){if(!u.isNodeSdk()){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=u.stringify(t).length;this.bytesReceived+=e,this.stats_.incrementCounter("bytes_received",e)},t}(),Xe=function(){function t(e,n,r,i){if(this.onDisconnect=r,this.urlFn=i,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0,u.isNodeSdk())this.commandCB=e,this.onMessageCB=n;else{this.uniqueCallbackIdentifier=g(),window[He+this.uniqueCallbackIdentifier]=e,window[Ge+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 a="<html><body>"+o+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(a),this.myIFrame.doc.close()}catch(s){T("frame writing exception"),s.stack&&T(s.stack),T(s)}}}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||T("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 t=this;this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.innerHTML="",setTimeout((function(){null!==t.myIFrame&&(document.body.removeChild(t.myIFrame),t.myIFrame=null)}),Math.floor(0)));var e=this.onDisconnect;e&&(this.onDisconnect=null,e())},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.size<(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);var r=function(){n.outstandingRequests.delete(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;u.isNodeSdk()?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(){T("Long-poll script failed to load: "+t),n.sendNewPolls=!1,n.close()},n.myIFrame.doc.body.appendChild(r)}catch(i){}}),Math.floor(1))},t}(),Je="";var Ze=null;"undefined"!=typeof MozWebSocket?Ze=MozWebSocket:"undefined"!=typeof WebSocket&&(Ze=WebSocket);var $e=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_=C(this.connId),this.stats_=Le.getCollection(n),this.connURL=t.connectionURL_(n,r,i)}return t.connectionURL_=function(t,e,n){var r={v:"5"};return!u.isNodeSdk()&&"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,d.set("previous_websocket_failure",!0);try{if(u.isNodeSdk()){var i=u.CONSTANTS.NODE_ADMIN?"AdminNode":"Node",o={headers:{"User-Agent":"Firebase/5/"+Je+"/"+r.platform+"/"+i}},a={},s=0==this.connURL.indexOf("wss://")?a.HTTPS_PROXY||a.https_proxy:a.HTTP_PROXY||a.http_proxy;s&&(o.proxy={origin:s}),this.mySock=new Ze(this.connURL,[],o)}else this.mySock=new Ze(this.connURL)}catch(h){this.log_("Error instantiating WebSocket.");var c=h.message||h.data;return c&&this.log_(c),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!==Ze&&!t.forceDisallow_},t.previouslyFailed=function(){return d.isInMemoryStorage||!0===d.get("previous_websocket_failure")},t.prototype.markConnectionHealthy=function(){d.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=u.jsonEval(e);this.onMessage(n)}},t.prototype.handleNewFrameCount_=function(t){this.totalFrames=t,this.frames=[]},t.prototype.extractFrameCount_=function(t){if(u.assert(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=u.stringify(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);var n=M(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(e){this.log_("Exception thrown from WebSocket.send():",e.message||e.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}},t.responsesRequiredToBeHealthy=2,t.healthyTimeout=3e4,t}(),tn=function(){function t(t){this.initTransports_(t)}return Object.defineProperty(t,"ALL_TRANSPORTS",{get:function(){return[Ye,$e]},enumerable:!0,configurable:!0}),t.prototype.initTransports_=function(e){var n,r,i=$e&&$e.isAvailable(),o=i&&!$e.previouslyFailed();if(e.webSocketOnly&&(i||D("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),o=!0),o)this.transports_=[$e];else{var a=this.transports_=[];try{for(var u=s.__values(t.ALL_TRANSPORTS),c=u.next();!c.done;c=u.next()){var h=c.value;h&&h.isAvailable()&&a.push(h)}}catch(l){n={error:l}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}},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}(),en=function(){function t(t,e,n,r,i,o,a){this.id=t,this.repoInfo_=e,this.onMessage_=n,this.onReady_=r,this.onDisconnect_=i,this.onKill_=o,this.lastSessionId=a,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=C("c:"+this.id+":"),this.transportManager_=new tn(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_=j((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=x("t",t),n=x("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=x("t",t),n=x("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=x("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?S("Server Error: "+n):"o"===e?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):S("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&&D("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),j((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):j((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()&&(d.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}(),nn=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}(),rn=1e3,on=3e5,an=function(t){function e(n,r,i,o,a,s){var c=t.call(this)||this;if(c.repoInfo_=n,c.onDataUpdate_=r,c.onConnectStatus_=i,c.onServerInfoUpdate_=o,c.authTokenProvider_=a,c.authOverride_=s,c.id=e.nextPersistentConnectionId_++,c.log_=C("p:"+c.id+":"),c.interruptReasons_={},c.listens=new Map,c.outstandingPuts_=[],c.outstandingPutCount_=0,c.onDisconnectRequestQueue_=[],c.connected_=!1,c.reconnectDelay_=rn,c.maxReconnectDelay_=on,c.securityDebugCallback_=null,c.lastSessionId=null,c.establishConnectionTimer_=null,c.visible_=!1,c.requestCBHash_={},c.requestNumber_=0,c.realtime_=null,c.authToken_=null,c.forceTokenRefresh_=!1,c.invalidAuthTokenCount_=0,c.firstConnection_=!0,c.lastConnectionAttemptTime_=null,c.lastConnectionEstablishedTime_=null,s&&!u.isNodeSdk())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");return c.scheduleConnect_(0),We.getInstance().on("visible",c.onVisible_,c),-1===n.host.indexOf("fblocal")&&Qe.getInstance().on("online",c.onOnline_,c),c}return s.__extends(e,t),e.prototype.sendRequest=function(t,e,n){var r=++this.requestNumber_,i={r:r,a:t,b:e};this.log_(u.stringify(i)),u.assert(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.has(o)||this.listens.set(o,new Map),u.assert(t.getQueryParams().isDefault()||!t.getQueryParams().loadsAllData(),"listen() called for non-default but complete query"),u.assert(!this.listens.get(o).has(i),"listen() called twice for same path/queryId.");var a={onComplete:r,hashFn:e,query:t,tag:n};this.listens.get(o).set(i,a),this.connected_&&this.sendListen_(a)},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 a={p:i};t.tag&&(a.q=r.queryObject(),a.t=t.tag),a.h=t.hashFn(),this.sendRequest("q",a,(function(a){var s=a.d,u=a.s;e.warnOnListenWarnings_(s,r),(n.listens.get(i)&&n.listens.get(i).get(o))===t&&(n.log_("listen response",a),"ok"!==u&&n.removeListen_(i,o),t.onComplete&&t.onComplete(u,s))}))},e.warnOnListenWarnings_=function(t,e){if(t&&"object"==typeof t&&u.contains(t,"w")){var n=u.safeGet(t,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){var r='".indexOn": "'+e.getQueryParams().getIndex().toString()+'"',i=e.path.toString();D("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){(t&&40===t.length||u.isAdmin(t))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=3e4)},e.prototype.tryAuth=function(){var t=this;if(this.connected_&&this.authToken_){var e=this.authToken_,n=u.isValidFormat(e)?"auth":"gauth",r={cred:e};null===this.authOverride_?r.noauth=!0:"object"==typeof this.authOverride_&&(r.authvar=this.authOverride_),this.sendRequest(n,r,(function(n){var r=n.s,i=n.d||"error";t.authToken_===e&&("ok"===r?t.invalidAuthTokenCount_=0:t.onAuthRevoked_(r,i))}))}},e.prototype.unlisten=function(t,e){var n=t.path.toString(),r=t.queryIdentifier();this.log_("Unlisten called for "+n+" "+r),u.assert(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 a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):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: "+u.stringify(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):S("Unrecognized action received from server: "+u.stringify(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;u.assert(!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_=rn,this.realtime_||this.scheduleConnect_(0)),this.visible_=t},e.prototype.onOnline_=function(t){t?(this.log_("Browser went online."),this.reconnectDelay_=rn,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_=rn),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,a=this.lastSessionId,s=!1,c=null,h=function(){c?c.close():(s=!0,r())};this.realtime_={close:h,sendRequest:function(t){u.assert(c,"sendRequest call when we're not connected not allowed."),c.sendRequest(t)}};var l=this.forceTokenRefresh_;this.forceTokenRefresh_=!1,this.authTokenProvider_.getToken(l).then((function(e){s?T("getToken() completed but was canceled"):(T("getToken() completed. Creating connection."),o.authToken_=e&&e.accessToken,c=new en(i,o.repoInfo_,t,n,r,(function(t){D(t+" ("+o.repoInfo_.toString()+")"),o.interrupt("server_kill")}),a))})).then(null,(function(t){o.log_("Failed to get token: "+t),s||(u.CONSTANTS.NODE_ADMIN&&D(t),h())}))}},e.prototype.interrupt=function(t){T("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){T("Resuming connection for reason: "+t),delete this.interruptReasons_[t],u.isEmpty(this.interruptReasons_)&&(this.reconnectDelay_=rn,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 P(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 z(t).toString();if(this.listens.has(r)){var i=this.listens.get(r);n=i.get(e),i.delete(e),0===i.size&&this.listens.delete(r)}else n=void 0;return n},e.prototype.onAuthRevoked_=function(t,e){T("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,e,n,r;this.tryAuth();try{for(var i=s.__values(this.listens.values()),o=i.next();!o.done;o=i.next()){var a=o.value;try{for(var u=(n=void 0,s.__values(a.values())),c=u.next();!c.done;c=u.next()){var h=c.value;this.sendListen_(h)}}catch(p){n={error:p}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}}catch(d){t={error:d}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}for(var l=0;l<this.outstandingPuts_.length;l++)this.outstandingPuts_[l]&&this.sendPut_(l);for(;this.onDisconnectRequestQueue_.length;){var f=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(f.action,f.pathString,f.data,f.onComplete)}},e.prototype.sendConnectStats_=function(){var t={},e="js";u.CONSTANTS.NODE_ADMIN?e="admin_node":u.CONSTANTS.NODE_CLIENT&&(e="node"),t["sdk."+e+"."+Je.replace(/\./g,"-")]=1,u.isMobileCordova()?t["framework.cordova"]=1:u.isReactNative()&&(t["framework.reactnative"]=1),this.reportStats(t)},e.prototype.shouldReconnect_=function(){var t=Qe.getInstance().currentlyOnline();return u.isEmpty(this.interruptReasons_)&&t},e.nextPersistentConnectionId_=0,e.nextConnectionId_=0,e}(nn),sn=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_=C("p:rest:"),i.listens_={},i}return s.__extends(e,t),e.prototype.reportStats=function(t){throw new Error("Method not implemented.")},e.getListenId_=function(t,e){return void 0!==e?"tag$"+e:(u.assert(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,a=t.path.toString();this.log_("Listen called for "+a+" "+t.queryIdentifier());var s=e.getListenId_(t,r),c={};this.listens_[s]=c;var h=t.getQueryParams().toRestQueryStringParameters();this.restRequest_(a+".json",h,(function(t,e){var n=e;(404===t&&(n=null,t=null),null===t&&o.onDataUpdate_(a,n,!1,r),u.safeGet(o.listens_,s)===c)&&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 a=(r.repoInfo_.secure?"https://":"http://")+r.repoInfo_.host+t+"?ns="+r.repoInfo_.namespace+u.querystring(e);r.log_("Sending REST request for "+a);var s=new XMLHttpRequest;s.onreadystatechange=function(){if(n&&4===s.readyState){r.log_("REST Response for "+a+" received. status:",s.status,"response:",s.responseText);var t=null;if(s.status>=200&&s.status<300){try{t=u.jsonEval(s.responseText)}catch(e){D("Failed to parse JSON response for "+a+": "+s.responseText)}n(null,t)}else 401!==s.status&&404!==s.status&&D("Got unsuccessful REST response for "+a+" Status: "+s.status),n(s.status);n=null}},s.open("GET",a,!0),s.send()}))},e}(nn),un=function(){function t(t,e,n,r){var i=this;this.repoInfo_=t,this.app=n,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new Be,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=new re,this.persistentConnection_=null;var o=new Pe(n,r);if(this.stats_=Le.getCollection(t),e||B())this.server_=new sn(this.repoInfo_,this.onDataUpdate_.bind(this),o),setTimeout(this.onConnectStatus_.bind(this,!0),0);else{var a=n.options.databaseAuthVariableOverride;if(null!=a){if("object"!=typeof a)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{u.stringify(a)}catch(s){throw new Error("Invalid authOverride provided: "+s)}}this.persistentConnection_=new an(this.repoInfo_,this.onDataUpdate_.bind(this),this.onConnectStatus_.bind(this),this.onServerInfoUpdate_.bind(this),o,a),this.server_=this.persistentConnection_}o.addTokenChangeListener((function(t){i.server_.refreshAuthToken(t)})),this.statsReporter_=Le.getOrCreateReporter(t,(function(){return new Ve(i.stats_,i.server_)})),this.transactions_init_(),this.infoData_=new xe,this.infoSyncTree_=new Oe({startListening:function(t,e,n,r){var o=[],a=i.infoData_.getNode(t.path);return a.isEmpty()||(o=i.infoSyncTree_.applyServerOverwrite(t.path,a),setTimeout((function(){r("ok")}),0)),o},stopListening:function(){}}),this.updateInfo_("connected",!1),this.serverSyncTree_=new Oe({startListening:function(t,e,n,r){return i.server_.listen(t,n,e,(function(e,n){var o=r(e,n);i.eventQueue_.raiseEventsForChangedPath(t.path,o)})),[]},stopListening:function(t,e){i.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 z(".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 z(t);e=this.interceptServerDataCallback_?this.interceptServerDataCallback_(t,e):e;var o=[];if(r)if(n){var a=u.map(e,(function(t){return Kt(t)}));o=this.serverSyncTree_.applyTaggedQueryMerge(i,a,r)}else{var s=Kt(e);o=this.serverSyncTree_.applyTaggedQueryOverwrite(i,s,r)}else if(n){var c=u.map(e,(function(t){return Kt(t)}));o=this.serverSyncTree_.applyServerMerge(i,c)}else{var h=Kt(e);o=this.serverSyncTree_.applyServerOverwrite(i,h)}var l=i;o.length>0&&(l=this.rerunTransactions_(i)),this.eventQueue_.raiseEventsForChangedPath(l,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;L(t,(function(t,n){e.updateInfo_(t,n)}))},t.prototype.updateInfo_=function(t,e){var n=new z("/.info/"+t),r=Kt(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(),a=Kt(e,n),s=this.serverSyncTree_.calcCompleteEventCache(t),u=se(a,s,o),c=this.getNextWriteId_(),h=this.serverSyncTree_.applyUserOverwrite(t,u,c,!0);this.eventQueue_.queueEvents(h),this.server_.put(t.toString(),a.val(!0),(function(e,n){var o="ok"===e;o||D("set at "+t+" failed: "+e);var a=i.serverSyncTree_.ackUserWrite(c,!o);i.eventQueue_.raiseEventsForChangedPath(t,a),i.callOnCompleteCallback(r,e,n)}));var l=this.abortTransactions_(t);this.rerunTransactions_(l),this.eventQueue_.raiseEventsForChangedPath(l,[])},t.prototype.update=function(t,e,n){var r=this;this.log_("update",{path:t.toString(),value:e});var i=!0,o=this.generateServerValues(),a={};if(L(e,(function(e,n){i=!1;var s=Kt(n);a[e]=se(s,r.serverSyncTree_.calcCompleteEventCache(t),o)})),i)T("update() called with empty data. Don't do anything."),this.callOnCompleteCallback(n,"ok");else{var s=this.getNextWriteId_(),u=this.serverSyncTree_.applyUserMerge(t,a,s);this.eventQueue_.queueEvents(u),this.server_.merge(t.toString(),e,(function(e,i){var o="ok"===e;o||D("update at "+t+" failed: "+e);var a=r.serverSyncTree_.ackUserWrite(s,!o),u=a.length>0?r.rerunTransactions_(t):t;r.eventQueue_.raiseEventsForChangedPath(u,a),r.callOnCompleteCallback(n,e,i)})),L(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,n){var r=new re;return t.forEachTree(new z(""),(function(t,i){var o=e.calcCompleteEventCache(t);u.assert(null!=o,"Expected ChildrenNode.EMPTY_NODE for nulls"),r.remember(t,se(i,o,n))})),r}(this.onDisconnect_,this.serverSyncTree_,e),r=[];n.forEachTree(z.Empty,(function(e,n){r=r.concat(t.serverSyncTree_.applyServerOverwrite(e,n));var i=t.abortTransactions_(e);t.rerunTransactions_(i)})),this.onDisconnect_=new re,this.eventQueue_.raiseEventsForChangedPath(z.Empty,r)},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=Kt(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=Kt(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(u.isEmpty(e))return T("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&&L(e,(function(e,n){var i=Kt(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 Fe(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);L(e,(function(t,e){for(var r=t,i=t.length;i<n+2;i++)r+=" ";console.log(r+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+":"),T.apply(void 0,s.__spread([n],t))},t.prototype.callOnCompleteCallback=function(t,e,n){t&&V((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 vn(this))},enumerable:!0,configurable:!0}),t}(),cn=function(){function t(e){this.indexedFilter_=new be(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 _t(e,n))||(n=zt.EMPTY_NODE),this.indexedFilter_.updateChild(t,e,n,r,i,o)},t.prototype.updateFullNode=function(t,e,n){e.isLeafNode()&&(e=zt.EMPTY_NODE);var r=e.withIndex(this.index_);r=r.updatePriority(zt.EMPTY_NODE);var i=this;return e.forEachChild(Rt,(function(t,e){i.matches(new _t(t,e))||(r=r.updateImmediateChild(t,zt.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}(),hn=function(){function t(t){this.rangedFilter_=new cn(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 _t(e,n))||(n=zt.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=zt.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<e.numChildren()&&e.isIndexed(this.index_)){r=zt.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 a=i.getNext();if(!(this.reverse_?this.index_.compare(this.rangedFilter_.getStartPost(),a)<=0:this.index_.compare(a,this.rangedFilter_.getEndPost())<=0))break;r=r.updateImmediateChild(a.name,a.node),o++}}else{r=(r=e.withIndex(this.index_)).updatePriority(zt.EMPTY_NODE);var s=void 0,u=void 0,c=void 0;i=void 0;if(this.reverse_){i=r.getReverseIterator(this.index_),s=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_),s=this.rangedFilter_.getStartPost(),u=this.rangedFilter_.getEndPost(),c=this.index_.getCompare();o=0;for(var l=!1;i.hasNext();){a=i.getNext();!l&&c(s,a)<=0&&(l=!0),l&&o<this.limit_&&c(a,u)<=0?o++:r=r.updateImmediateChild(a.name,zt.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 a=this.index_.getCompare();o=function(t,e){return a(e,t)}}else o=this.index_.getCompare();var s=t;u.assert(s.numChildren()==this.limit_,"");var c=new _t(e,n),h=this.reverse_?s.getFirstChild(this.index_):s.getLastChild(this.index_),l=this.rangedFilter_.matches(c);if(s.hasChild(e)){for(var f=s.getImmediateChild(e),p=r.getChildAfterChild(this.index_,h,this.reverse_);null!=p&&(p.name==e||s.hasChild(p.name));)p=r.getChildAfterChild(this.index_,p,this.reverse_);var d=null==p?1:o(p,c);if(l&&!n.isEmpty()&&d>=0)return null!=i&&i.trackChildChange(_e.childChangedChange(e,n,f)),s.updateImmediateChild(e,n);null!=i&&i.trackChildChange(_e.childRemovedChange(e,f));var m=s.updateImmediateChild(e,zt.EMPTY_NODE);return null!=p&&this.rangedFilter_.matches(p)?(null!=i&&i.trackChildChange(_e.childAddedChange(p.name,p.node)),m.updateImmediateChild(p.name,p.node)):m}return n.isEmpty()?t:l&&o(h,c)>=0?(null!=i&&(i.trackChildChange(_e.childRemovedChange(h.name,h.node)),i.trackChildChange(_e.childAddedChange(e,n))),s.updateImmediateChild(e,n).updateImmediateChild(h.name,zt.EMPTY_NODE)):t},t}(),ln=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_=Rt}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 u.assert(this.startSet_,"Only valid if start has been set"),this.indexStartValue_},t.prototype.getIndexStartName=function(){return u.assert(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:A},t.prototype.hasEnd=function(){return this.endSet_},t.prototype.getIndexEndValue=function(){return u.assert(this.endSet_,"Only valid if end has been set"),this.indexEndValue_},t.prototype.getIndexEndName=function(){return u.assert(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:k},t.prototype.hasLimit=function(){return this.limitSet_},t.prototype.hasAnchoredLimit=function(){return this.limitSet_&&""!==this.viewFrom_},t.prototype.getLimit=function(){return u.assert(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_!==Rt&&(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_==Rt},t.prototype.getNodeFilter=function(){return this.loadsAllData()?new be(this.getIndex()):this.hasLimit()?new hn(this):new cn(this)},t.prototype.toRestQueryStringParameters=function(){var e,n=t.REST_QUERY_CONSTANTS_,r={};return this.isDefault()?r:(this.index_===Rt?e=n.PRIORITY_INDEX:this.index_===Yt?e=n.VALUE_INDEX:this.index_===Et?e=n.KEY_INDEX:(u.assert(this.index_ instanceof Xt,"Unrecognized index type!"),e=this.index_.toString()),r[n.ORDER_BY]=u.stringify(e),this.startSet_&&(r[n.START_AT]=u.stringify(this.indexStartValue_),this.startNameSet_&&(r[n.START_AT]+=","+u.stringify(this.indexStartName_))),this.endSet_&&(r[n.END_AT]=u.stringify(this.indexEndValue_),this.endNameSet_&&(r[n.END_AT]+=","+u.stringify(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}(),fn=function(t){function e(e,n){if(!(e instanceof un))throw new Error("new Reference() no longer supported - use app.database().");return t.call(this,e,n,ln.DEFAULT,!1)||this}return s.__extends(e,t),e.prototype.getKey=function(){return u.validateArgCount("Reference.key",0,0,arguments.length),this.path.isEmpty()?null:this.path.getBack()},e.prototype.child=function(t){return u.validateArgCount("Reference.child",1,1,arguments.length),"number"==typeof t?t=String(t):t instanceof z||(null===this.path.getFront()?ft("Reference.child",1,t,!1):lt("Reference.child",1,t,!1)),new e(this.repo,this.path.child(t))},e.prototype.getParent=function(){u.validateArgCount("Reference.parent",0,0,arguments.length);var t=this.path.parent();return null===t?null:new e(this.repo,t)},e.prototype.getRoot=function(){u.validateArgCount("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){u.validateArgCount("Reference.set",1,2,arguments.length),pt("Reference.set",this.path),ot("Reference.set",1,t,this.path,!1),u.validateCallback("Reference.set",2,e,!0);var n=new u.Deferred;return this.repo.setWithPriority(this.path,t,null,n.wrapCallback(e)),n.promise},e.prototype.update=function(t,e){if(u.validateArgCount("Reference.update",1,2,arguments.length),pt("Reference.update",this.path),Array.isArray(t)){for(var n={},r=0;r<t.length;++r)n[""+r]=t[r];t=n,D("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.")}st("Reference.update",1,t,this.path,!1),u.validateCallback("Reference.update",2,e,!0);var i=new u.Deferred;return this.repo.update(this.path,t,i.wrapCallback(e)),i.promise},e.prototype.setWithPriority=function(t,e,n){if(u.validateArgCount("Reference.setWithPriority",2,3,arguments.length),pt("Reference.setWithPriority",this.path),ot("Reference.setWithPriority",1,t,this.path,!1),ut("Reference.setWithPriority",2,e,!1),u.validateCallback("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 u.Deferred;return this.repo.setWithPriority(this.path,t,e,r.wrapCallback(n)),r.promise},e.prototype.remove=function(t){return u.validateArgCount("Reference.remove",0,1,arguments.length),pt("Reference.remove",this.path),u.validateCallback("Reference.remove",1,t,!0),this.set(null,t)},e.prototype.transaction=function(t,e,n){if(u.validateArgCount("Reference.transaction",1,3,arguments.length),pt("Reference.transaction",this.path),u.validateCallback("Reference.transaction",1,t,!1),u.validateCallback("Reference.transaction",2,e,!0),mt("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 u.Deferred;"function"==typeof e&&r.promise.catch((function(){}));var i=function(t,n,i){t?r.reject(t):r.resolve(new gt(n,i)),"function"==typeof e&&e(t,n,i)};return this.repo.startTransaction(this.path,t,i,n),r.promise},e.prototype.setPriority=function(t,e){u.validateArgCount("Reference.setPriority",1,2,arguments.length),pt("Reference.setPriority",this.path),ut("Reference.setPriority",1,t,!1),u.validateCallback("Reference.setPriority",2,e,!0);var n=new u.Deferred;return this.repo.setWithPriority(this.path.child(".priority"),t,null,n.wrapCallback(e)),n.promise},e.prototype.push=function(t,e){u.validateArgCount("Reference.push",0,2,arguments.length),pt("Reference.push",this.path),ot("Reference.push",1,t,this.path,!0),u.validateCallback("Reference.push",2,e,!0);var n,r=this.repo.serverTime(),i=vt(r),o=this.child(i),a=this.child(i);return n=null!=t?o.set(t,e).then((function(){return a})):Promise.resolve(a),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 pt("Reference.onDisconnect",this.path),new yt(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}(ne);ne.__referenceConstructor=fn,Ne.__referenceConstructor=fn;var pn,dn=function(){this.children={},this.childCount=0,this.value=null},mn=function(){function t(t,e,n){void 0===t&&(t=""),void 0===e&&(e=null),void 0===n&&(n=new dn),this.name_=t,this.parent_=e,this.node_=n}return t.prototype.subTree=function(e){for(var n,r=e instanceof z?e:new z(e),i=this;null!==(n=r.getFront());){i=new t(n,i,u.safeGet(i.node_.children,n)||new dn),r=r.popFront()}return i},t.prototype.getValue=function(){return this.node_.value},t.prototype.setValue=function(t){u.assert(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;L(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 z(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=u.contains(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"}(pn||(pn={})),un.MAX_TRANSACTION_RETRIES_=25,un.prototype.transactions_init_=function(){this.transactionQueueTree_=new mn},un.prototype.startTransaction=function(t,e,n,r){this.log_("transaction on "+t);var i=function(){},o=new fn(this,t);o.on("value",i);var a={path:t,update:e,onComplete:n,status:null,order:g(),applyLocally:r,retryCount:0,unwatcher:function(){o.off("value",i)},abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},s=this.getLatestState_(t);a.currentInputSnapshot=s;var c=a.update(s.val());if(void 0===c){if(a.unwatcher(),a.currentOutputSnapshotRaw=null,a.currentOutputSnapshotResolved=null,a.onComplete){var h=new Jt(a.currentInputSnapshot,new fn(this,a.path),Rt);a.onComplete(null,!1,h)}}else{at("transaction failed: Data returned ",c,a.path),a.status=pn.RUN;var l=this.transactionQueueTree_.subTree(t),f=l.getValue()||[];f.push(a),l.setValue(f);var p=void 0;if("object"==typeof c&&null!==c&&u.contains(c,".priority"))p=u.safeGet(c,".priority"),u.assert(it(p),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.");else p=(this.serverSyncTree_.calcCompleteEventCache(t)||zt.EMPTY_NODE).getPriority().val();p=p;var d=this.generateServerValues(),m=Kt(c,p),y=se(m,s,d);a.currentOutputSnapshotRaw=m,a.currentOutputSnapshotResolved=y,a.currentWriteId=this.getNextWriteId_();var v=this.serverSyncTree_.applyUserOverwrite(t,y,a.currentWriteId,a.applyLocally);this.eventQueue_.raiseEventsForChangedPath(t,v),this.sendReadyTransactions_()}},un.prototype.getLatestState_=function(t,e){return this.serverSyncTree_.calcCompleteEventCache(t,e)||zt.EMPTY_NODE},un.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);u.assert(n.length>0,"Sending zero length transaction queue"),n.every((function(t){return t.status===pn.RUN}))&&this.sendTransactionQueue_(t.path(),n)}else t.hasChildren()&&t.forEachChild((function(t){e.sendReadyTransactions_(t)}))},un.prototype.sendTransactionQueue_=function(t,e){for(var n=this,r=e.map((function(t){return t.currentWriteId})),i=this.getLatestState_(t,r),o=i,a=i.hash(),s=0;s<e.length;s++){var c=e[s];u.assert(c.status===pn.RUN,"tryToSendTransactionQueue_: items in queue should all be run."),c.status=pn.SENT,c.retryCount++;var h=z.relativePath(t,c.path);o=o.updateChild(h,c.currentOutputSnapshotRaw)}var l=o.val(!0),f=t;this.server_.put(f.toString(),l,(function(r){n.log_("transaction put response",{path:f.toString(),status:r});var i=[];if("ok"===r){for(var o=[],a=0;a<e.length;a++){if(e[a].status=pn.COMPLETED,i=i.concat(n.serverSyncTree_.ackUserWrite(e[a].currentWriteId)),e[a].onComplete){var s=e[a].currentOutputSnapshotResolved,u=new fn(n,e[a].path),c=new Jt(s,u,Rt);o.push(e[a].onComplete.bind(null,null,!0,c))}e[a].unwatcher()}n.pruneCompletedTransactionsBelowNode_(n.transactionQueueTree_.subTree(t)),n.sendReadyTransactions_(),n.eventQueue_.raiseEventsForChangedPath(t,i);for(a=0;a<o.length;a++)V(o[a])}else{if("datastale"===r)for(a=0;a<e.length;a++)e[a].status===pn.SENT_NEEDS_ABORT?e[a].status=pn.NEEDS_ABORT:e[a].status=pn.RUN;else{D("transaction at "+f.toString()+" failed: "+r);for(a=0;a<e.length;a++)e[a].status=pn.NEEDS_ABORT,e[a].abortReason=r}n.rerunTransactions_(t)}}),a)},un.prototype.rerunTransactions_=function(t){var e=this.getAncestorTransactionNode_(t),n=e.path(),r=this.buildTransactionQueue_(e);return this.rerunTransactionQueue_(r,n),n},un.prototype.rerunTransactionQueue_=function(t,e){if(0!==t.length){for(var n,r=[],i=[],o=t.filter((function(t){return t.status===pn.RUN})).map((function(t){return t.currentWriteId})),a=0;a<t.length;a++){var s=t[a],c=z.relativePath(e,s.path),h=!1,l=void 0;if(u.assert(null!==c,"rerunTransactionsUnderNode_: relativePath should not be null."),s.status===pn.NEEDS_ABORT)h=!0,l=s.abortReason,i=i.concat(this.serverSyncTree_.ackUserWrite(s.currentWriteId,!0));else if(s.status===pn.RUN)if(s.retryCount>=un.MAX_TRANSACTION_RETRIES_)h=!0,l="maxretry",i=i.concat(this.serverSyncTree_.ackUserWrite(s.currentWriteId,!0));else{var f=this.getLatestState_(s.path,o);s.currentInputSnapshot=f;var p=t[a].update(f.val());if(void 0!==p){at("transaction failed: Data returned ",p,s.path);var d=Kt(p);"object"==typeof p&&null!=p&&u.contains(p,".priority")||(d=d.updatePriority(f.getPriority()));var m=s.currentWriteId,y=this.generateServerValues(),g=se(d,f,y);s.currentOutputSnapshotRaw=d,s.currentOutputSnapshotResolved=g,s.currentWriteId=this.getNextWriteId_(),o.splice(o.indexOf(m),1),i=(i=i.concat(this.serverSyncTree_.applyUserOverwrite(s.path,g,s.currentWriteId,s.applyLocally))).concat(this.serverSyncTree_.ackUserWrite(m,!0))}else h=!0,l="nodata",i=i.concat(this.serverSyncTree_.ackUserWrite(s.currentWriteId,!0))}if(this.eventQueue_.raiseEventsForChangedPath(e,i),i=[],h&&(t[a].status=pn.COMPLETED,n=t[a].unwatcher,setTimeout(n,Math.floor(0)),t[a].onComplete))if("nodata"===l){var v=new fn(this,t[a].path),_=t[a].currentInputSnapshot,b=new Jt(_,v,Rt);r.push(t[a].onComplete.bind(null,null,!1,b))}else r.push(t[a].onComplete.bind(null,new Error(l),!1,null))}this.pruneCompletedTransactionsBelowNode_(this.transactionQueueTree_);for(a=0;a<r.length;a++)V(r[a]);this.sendReadyTransactions_()}},un.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},un.prototype.buildTransactionQueue_=function(t){var e=[];return this.aggregateTransactionQueuesForNode_(t,e),e.sort((function(t,e){return t.order-e.order})),e},un.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)}))},un.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!==pn.COMPLETED&&(n[r]=n[i],r++);n.length=r,t.setValue(n.length>0?n:null)}t.forEachChild((function(t){e.pruneCompletedTransactionsBelowNode_(t)}))},un.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},un.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===pn.SENT_NEEDS_ABORT);else if(e[o].status===pn.SENT)u.assert(i===o-1,"All SENT items should be at beginning of queue."),i=o,e[o].status=pn.SENT_NEEDS_ABORT,e[o].abortReason="set";else if(u.assert(e[o].status===pn.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++)V(n[o])}};var yn,gn=function(){function t(){this.repos_={},this.useRestClient_=!1}return t.getInstance=function(){return yn||(yn=new t),yn},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,n){var i=n||t.options.databaseURL;void 0===i&&I("Can't determine Firebase Database URL. Be sure to include databaseURL option when calling firebase.initializeApp().");var o=Z(i),a=o.repoInfo,s=void 0;return void 0!==r&&(s={}.FIREBASE_DATABASE_EMULATOR_HOST),s&&(i="http://"+s+"?ns="+a.namespace,a=(o=Z(i)).repoInfo),dt("Invalid Firebase Database URL",1,o),o.path.isEmpty()||I("Database URL must point to the root of a Firebase Database (not including a child path)."),this.createRepo(a,t,e).database},t.prototype.deleteRepo=function(t){var e=u.safeGet(this.repos_,t.app.name);e&&u.safeGet(e,t.repoInfo_.toURLString())===t||I("Database "+t.app.name+"("+t.repoInfo_+") has already been deleted."),t.interrupt(),delete e[t.repoInfo_.toURLString()]},t.prototype.createRepo=function(t,e,n){var r=u.safeGet(this.repos_,e.name);r||(r={},this.repos_[e.name]=r);var i=u.safeGet(r,t.toURLString());return i&&I("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),i=new un(t,this.useRestClient_,e,n),r[t.toURLString()]=i,i},t.prototype.forceRestClient=function(t){this.useRestClient_=t},t}(),vn=function(){function t(t){this.repo_=t,t instanceof un||I("Don't call new Database() directly - please use firebase.database()."),this.root_=new fn(t,z.Empty),this.INTERNAL=new _n(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"),u.validateArgCount("database.ref",0,1,arguments.length),t instanceof fn?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),u.validateArgCount(e,1,1,arguments.length);var n=Z(t);dt(e,1,n);var r=n.repoInfo;return r.host!==this.repo_.repoInfo_.host&&I(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_&&I("Cannot call "+t+" on a deleted database.")},t.prototype.goOffline=function(){u.validateArgCount("database.goOffline",0,0,arguments.length),this.checkDeleted_("goOffline"),this.repo_.interrupt()},t.prototype.goOnline=function(){u.validateArgCount("database.goOnline",0,0,arguments.length),this.checkDeleted_("goOnline"),this.repo_.resume()},t.ServerValue={TIMESTAMP:{".sv":"timestamp"},_increment:function(t){return{".sv":{increment:t}}}},t}(),_n=function(){function t(t){this.database=t}return t.prototype.delete=function(){return s.__awaiter(this,void 0,void 0,(function(){return s.__generator(this,(function(t){return this.database.checkDeleted_("delete"),gn.getInstance().deleteRepo(this.database.repo_),this.database.repo_=null,this.database.root_=null,this.database.INTERNAL=null,this.database=null,[2]}))}))},t}(),bn=Object.freeze({__proto__:null,forceLongPolling:function(){$e.forceDisallow(),Ye.forceAllow()},forceWebSockets:function(){Ye.forceDisallow()},isWebSocketsAvailable:function(){return $e.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)}}),wn=an;an.prototype.simpleListen=function(t,e){this.sendRequest("q",{p:t},e)},an.prototype.echo=function(t,e){this.sendRequest("echo",{d:t},e)};var En=en,Tn=K,Cn=Object.freeze({__proto__:null,DataConnection:wn,RealTimeConnection:En,hijackHash:function(t){var e=an.prototype.put;return an.prototype.put=function(n,r,i,o){void 0!==o&&(o=t()),e.call(this,n,r,i,o)},function(){an.prototype.put=e}},ConnectionTarget:Tn,queryIdentifier:function(t){return t.queryIdentifier()},forceRestClient:function(t){gn.getInstance().forceRestClient(t)}}),Sn="@firebase/database",In="0.5.17",Dn=vn.ServerValue;function Nn(e){!function(t){Je=t}(e.SDK_VERSION);var n=e.INTERNAL.registerComponent(new h.Component("database",(function(t,e){var n=t.getProvider("app").getImmediate(),r=t.getProvider("auth-internal");return gn.getInstance().databaseFromApp(n,r,e)}),"PUBLIC").setServiceProps({Reference:fn,Query:ne,Database:vn,DataSnapshot:Jt,enableLogging:E,INTERNAL:bn,ServerValue:Dn,TEST_ACCESS:Cn}).setMultipleInstances(!0));e.registerVersion(Sn,In),u.isNodeSdk()&&(t.exports=n)}Nn(a),e.DataSnapshot=Jt,e.Database=vn,e.OnDisconnect=yt,e.Query=ne,e.Reference=fn,e.ServerValue=Dn,e.enableLogging=E,e.registerDatabase=Nn}).call(this,n("8oxB"))},NrJJ:function(t,e,n){"use strict";n("R48M"),Object.defineProperty(e,"__esModule",{value:!0});var r=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(n("q1tI"));e.default=function(t,e,n){return r.createElement("a",{href:t,key:n},e)}},O6Fj:function(t,e,n){"use strict";e.__esModule=!0;var r=n("CNgt");e.default=r.TextareaAutosize},OR32:function(t,e,n){"use strict";n("R48M"),Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){return t}},"PZd/":function(t,e,n){var r=n("P8UN"),i=n("ys0W")(!0);r(r.S,"Object",{entries:function(t){return i(t)}})},"Q+Us":function(t,e,n){"use strict";n("R48M"),Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){return t}},"QzX/":function(t,e,n){"use strict";n("EU/P")("trimRight",(function(t){return function(){return t(this,2)}}),"trimEnd")},R0hF:function(t,e,n){var r=n("P8UN");r(r.S,"Number",{MIN_SAFE_INTEGER:-9007199254740991})},Ribc:function(t,e,n){"use strict";n("AqHK"),n("MIFh"),n("JHok"),n("LagC"),n("pS08"),n("R48M"),Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),i=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(n("q1tI")),o=c(n("NrJJ")),a=c(n("OR32")),s=c(n("L5ms")),u=c(n("Q+Us"));function c(t){return t&&t.__esModule?t:{default:t}}var h=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),r(e,[{key:"parseString",value:function(t){var e=this;if(""===t)return t;var n=this.props.matchDecorator(t);if(!n)return t;var r=[],i=0;return n.forEach((function(n,o){n.index>i&&r.push(t.substring(i,n.index));var a=e.props.hrefDecorator(n.url),s=e.props.textDecorator(n.text),u=e.props.componentDecorator(a,s,o);r.push(u),i=n.lastIndex})),t.length>i&&r.push(t.substring(i)),1===r.length?r[0]:r}},{key:"parse",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return"string"==typeof t?this.parseString(t):i.isValidElement(t)&&"a"!==t.type&&"button"!==t.type?i.cloneElement(t,{key:n},this.parse(t.props.children)):Array.isArray(t)?t.map((function(t,n){return e.parse(t,n)})):t}},{key:"render",value:function(){return i.createElement(i.Fragment,null,this.parse(this.props.children))}}]),e}(i.Component);h.defaultProps={componentDecorator:o.default,hrefDecorator:a.default,matchDecorator:s.default,textDecorator:u.default},e.default=h},Rk8H:function(t,e,n){n("sc67");var r=n("jTPX");t.exports=function(t){var e=r(t,"line-height"),n=parseFloat(e,10);if(e===n+""){var i=t.style.lineHeight;t.style.lineHeight=e+"em",e=r(t,"line-height"),n=parseFloat(e,10),i?t.style.lineHeight=i:delete t.style.lineHeight}if(-1!==e.indexOf("pt")?(n*=4,n/=3):-1!==e.indexOf("mm")?(n*=96,n/=25.4):-1!==e.indexOf("cm")?(n*=96,n/=2.54):-1!==e.indexOf("in")?n*=96:-1!==e.indexOf("pc")&&(n*=16),n=Math.round(n),"normal"===e){var o=t.nodeName,a=document.createElement(o);a.innerHTML=" ","TEXTAREA"===o.toUpperCase()&&a.setAttribute("rows","1");var s=r(t,"font-size");a.style.fontSize=s,a.style.padding="0px",a.style.border="0px";var u=document.body;u.appendChild(a),n=a.offsetHeight,u.removeChild(a)}return n}},Rw9D:function(t,e,n){"use strict";var r=n("P8UN"),i=n("/+AL");r(r.P+r.F*!n("h/qr")([].reduceRight,!0),"Array",{reduceRight:function(t){return i(this,t,arguments.length,arguments[1],!0)}})},"S+S0":function(t,e,n){"use strict";n("OeI1"),n("AqHK"),n("6kNP"),n("cFtU"),n("rzGZ"),n("Dq+y"),n("8npG"),n("YbXK"),n("xJgp"),n("pJf4"),n("R48M"),Object.defineProperty(e,"__esModule",{value:!0});var r=n("mrSG"),i=n("zVF4"),o=function(){function t(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY"}return t.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},t.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},t.prototype.setServiceProps=function(t){return this.serviceProps=t,this},t}(),a="[DEFAULT]",s=function(){function t(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map}return t.prototype.get=function(t){void 0===t&&(t=a);var e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){var n=new i.Deferred;this.instancesDeferred.set(e,n);try{var r=this.getOrInitializeService(e);r&&n.resolve(r)}catch(o){}}return this.instancesDeferred.get(e).promise},t.prototype.getImmediate=function(t){var e=r.__assign({identifier:a,optional:!1},t),n=e.identifier,i=e.optional,o=this.normalizeInstanceIdentifier(n);try{var s=this.getOrInitializeService(o);if(!s){if(i)return null;throw Error("Service "+this.name+" is not available")}return s}catch(u){if(i)return null;throw u}},t.prototype.getComponent=function(){return this.component},t.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(this.component=t,function(t){return"EAGER"===t.instantiationMode}(t))try{this.getOrInitializeService(a)}catch(f){}try{for(var i=r.__values(this.instancesDeferred.entries()),o=i.next();!o.done;o=i.next()){var s=r.__read(o.value,2),u=s[0],c=s[1],h=this.normalizeInstanceIdentifier(u);try{var l=this.getOrInitializeService(h);c.resolve(l)}catch(f){}}}catch(p){e={error:p}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},t.prototype.clearInstance=function(t){void 0===t&&(t=a),this.instancesDeferred.delete(t),this.instances.delete(t)},t.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){var t;return r.__generator(this,(function(e){switch(e.label){case 0:return t=Array.from(this.instances.values()),[4,Promise.all(t.filter((function(t){return"INTERNAL"in t})).map((function(t){return t.INTERNAL.delete()})))];case 1:return e.sent(),[2]}}))}))},t.prototype.isComponentSet=function(){return null!=this.component},t.prototype.getOrInitializeService=function(t){var e=this.instances.get(t);return!e&&this.component&&(e=this.component.instanceFactory(this.container,function(t){return t===a?void 0:t}(t)),this.instances.set(t,e)),e||null},t.prototype.normalizeInstanceIdentifier=function(t){return this.component?this.component.multipleInstances?t:a:t},t}();var u=function(){function t(t){this.name=t,this.providers=new Map}return t.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)},t.prototype.addOrOverwriteComponent=function(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)},t.prototype.getProvider=function(t){if(this.providers.has(t))return this.providers.get(t);var e=new s(t,this);return this.providers.set(t,e),e},t.prototype.getProviders=function(){return Array.from(this.providers.values())},t}();e.Component=o,e.ComponentContainer=u,e.Provider=s},Sc3u:function(t,e,n){"use strict";if(n("QPJK")){var r=n("939K"),i=n("emib"),o=n("96qb"),a=n("P8UN"),s=n("Jegl"),u=n("voZr"),c=n("ot9L"),h=n("xa9o"),l=n("pSXQ"),f=n("8wc8"),p=n("rj/q"),d=n("1Llc"),m=n("kiRH"),y=n("gx6d"),g=n("dTG6"),v=n("kxs/"),_=n("qDzq"),b=n("aHWV"),w=n("BjK0"),E=n("DFzH"),T=n("BuzY"),C=n("nsRs"),S=n("ltAs"),I=n("chL8").f,D=n("U9/z"),N=n("UEZ0"),A=n("sOol"),k=n("Wadk"),R=n("Ar2q"),O=n("Ioy3"),x=n("Dq+y"),P=n("m+kh"),M=n("vUMq"),L=n("to/b"),F=n("Y++M"),U=n("cRJv"),q=n("rjfK"),V=n("Drra"),B=q.f,j=V.f,z=i.RangeError,W=i.TypeError,Q=i.Uint8Array,K=Array.prototype,H=u.ArrayBuffer,G=u.DataView,Y=k(0),X=k(2),J=k(3),Z=k(4),$=k(5),tt=k(6),et=R(!0),nt=R(!1),rt=x.values,it=x.keys,ot=x.entries,at=K.lastIndexOf,st=K.reduce,ut=K.reduceRight,ct=K.join,ht=K.sort,lt=K.slice,ft=K.toString,pt=K.toLocaleString,dt=A("iterator"),mt=A("toStringTag"),yt=N("typed_constructor"),gt=N("def_constructor"),vt=s.CONSTR,_t=s.TYPED,bt=s.VIEW,wt=k(1,(function(t,e){return It(O(t,t[gt]),e)})),Et=o((function(){return 1===new Q(new Uint16Array([1]).buffer)[0]})),Tt=!!Q&&!!Q.prototype.set&&o((function(){new Q(1).set({})})),Ct=function(t,e){var n=d(t);if(n<0||n%e)throw z("Wrong offset!");return n},St=function(t){if(w(t)&&_t in t)return t;throw W(t+" is not a typed array!")},It=function(t,e){if(!(w(t)&&yt in t))throw W("It is not a typed array constructor!");return new t(e)},Dt=function(t,e){return Nt(O(t,t[gt]),e)},Nt=function(t,e){for(var n=0,r=e.length,i=It(t,r);r>n;)i[n]=e[n++];return i},At=function(t,e,n){B(t,e,{get:function(){return this._d[n]}})},kt=function(t){var e,n,r,i,o,a,s=E(t),u=arguments.length,h=u>1?arguments[1]:void 0,l=void 0!==h,f=D(s);if(null!=f&&!T(f)){for(a=f.call(s),r=[],e=0;!(o=a.next()).done;e++)r.push(o.value);s=r}for(l&&u>2&&(h=c(h,arguments[2],2)),e=0,n=m(s.length),i=It(this,n);n>e;e++)i[e]=l?h(s[e],e):s[e];return i},Rt=function(){for(var t=0,e=arguments.length,n=It(this,e);e>t;)n[t]=arguments[t++];return n},Ot=!!Q&&o((function(){pt.call(new Q(1))})),xt=function(){return pt.apply(Ot?lt.call(St(this)):St(this),arguments)},Pt={copyWithin:function(t,e){return U.call(St(this),t,e,arguments.length>2?arguments[2]:void 0)},every:function(t){return Z(St(this),t,arguments.length>1?arguments[1]:void 0)},fill:function(t){return F.apply(St(this),arguments)},filter:function(t){return Dt(this,X(St(this),t,arguments.length>1?arguments[1]:void 0))},find:function(t){return $(St(this),t,arguments.length>1?arguments[1]:void 0)},findIndex:function(t){return tt(St(this),t,arguments.length>1?arguments[1]:void 0)},forEach:function(t){Y(St(this),t,arguments.length>1?arguments[1]:void 0)},indexOf:function(t){return nt(St(this),t,arguments.length>1?arguments[1]:void 0)},includes:function(t){return et(St(this),t,arguments.length>1?arguments[1]:void 0)},join:function(t){return ct.apply(St(this),arguments)},lastIndexOf:function(t){return at.apply(St(this),arguments)},map:function(t){return wt(St(this),t,arguments.length>1?arguments[1]:void 0)},reduce:function(t){return st.apply(St(this),arguments)},reduceRight:function(t){return ut.apply(St(this),arguments)},reverse:function(){for(var t,e=St(this).length,n=Math.floor(e/2),r=0;r<n;)t=this[r],this[r++]=this[--e],this[e]=t;return this},some:function(t){return J(St(this),t,arguments.length>1?arguments[1]:void 0)},sort:function(t){return ht.call(St(this),t)},subarray:function(t,e){var n=St(this),r=n.length,i=g(t,r);return new(O(n,n[gt]))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,m((void 0===e?r:g(e,r))-i))}},Mt=function(t,e){return Dt(this,lt.call(St(this),t,e))},Lt=function(t){St(this);var e=Ct(arguments[1],1),n=this.length,r=E(t),i=m(r.length),o=0;if(i+e>n)throw z("Wrong length!");for(;o<i;)this[e+o]=r[o++]},Ft={entries:function(){return ot.call(St(this))},keys:function(){return it.call(St(this))},values:function(){return rt.call(St(this))}},Ut=function(t,e){return w(t)&&t[_t]&&"symbol"!=typeof e&&e in t&&String(+e)==String(e)},qt=function(t,e){return Ut(t,e=v(e,!0))?l(2,t[e]):j(t,e)},Vt=function(t,e,n){return!(Ut(t,e=v(e,!0))&&w(n)&&_(n,"value"))||_(n,"get")||_(n,"set")||n.configurable||_(n,"writable")&&!n.writable||_(n,"enumerable")&&!n.enumerable?B(t,e,n):(t[e]=n.value,t)};vt||(V.f=qt,q.f=Vt),a(a.S+a.F*!vt,"Object",{getOwnPropertyDescriptor:qt,defineProperty:Vt}),o((function(){ft.call({})}))&&(ft=pt=function(){return ct.call(this)});var Bt=p({},Pt);p(Bt,Ft),f(Bt,dt,Ft.values),p(Bt,{slice:Mt,set:Lt,constructor:function(){},toString:ft,toLocaleString:xt}),At(Bt,"buffer","b"),At(Bt,"byteOffset","o"),At(Bt,"byteLength","l"),At(Bt,"length","e"),B(Bt,mt,{get:function(){return this[_t]}}),t.exports=function(t,e,n,u){var c=t+((u=!!u)?"Clamped":"")+"Array",l="get"+t,p="set"+t,d=i[c],g=d||{},v=d&&S(d),_=!d||!s.ABV,E={},T=d&&d.prototype,D=function(t,n){B(t,n,{get:function(){return function(t,n){var r=t._d;return r.v[l](n*e+r.o,Et)}(this,n)},set:function(t){return function(t,n,r){var i=t._d;u&&(r=(r=Math.round(r))<0?0:r>255?255:255&r),i.v[p](n*e+i.o,r,Et)}(this,n,t)},enumerable:!0})};_?(d=n((function(t,n,r,i){h(t,d,c,"_d");var o,a,s,u,l=0,p=0;if(w(n)){if(!(n instanceof H||"ArrayBuffer"==(u=b(n))||"SharedArrayBuffer"==u))return _t in n?Nt(d,n):kt.call(d,n);o=n,p=Ct(r,e);var g=n.byteLength;if(void 0===i){if(g%e)throw z("Wrong length!");if((a=g-p)<0)throw z("Wrong length!")}else if((a=m(i)*e)+p>g)throw z("Wrong length!");s=a/e}else s=y(n),o=new H(a=s*e);for(f(t,"_d",{b:o,o:p,l:a,e:s,v:new G(o)});l<s;)D(t,l++)})),T=d.prototype=C(Bt),f(T,"constructor",d)):o((function(){d(1)}))&&o((function(){new d(-1)}))&&M((function(t){new d,new d(null),new d(1.5),new d(t)}),!0)||(d=n((function(t,n,r,i){var o;return h(t,d,c),w(n)?n instanceof H||"ArrayBuffer"==(o=b(n))||"SharedArrayBuffer"==o?void 0!==i?new g(n,Ct(r,e),i):void 0!==r?new g(n,Ct(r,e)):new g(n):_t in n?Nt(d,n):kt.call(d,n):new g(y(n))})),Y(v!==Function.prototype?I(g).concat(I(v)):I(g),(function(t){t in d||f(d,t,g[t])})),d.prototype=T,r||(T.constructor=d));var N=T[dt],A=!!N&&("values"==N.name||null==N.name),k=Ft.values;f(d,yt,!0),f(T,_t,c),f(T,bt,!0),f(T,gt,d),(u?new d(1)[mt]==c:mt in T)||B(T,mt,{get:function(){return c}}),E[c]=d,a(a.G+a.W+a.F*(d!=g),E),a(a.S,c,{BYTES_PER_ELEMENT:e}),a(a.S+a.F*o((function(){g.of.call(d,1)})),c,{from:kt,of:Rt}),"BYTES_PER_ELEMENT"in T||f(T,"BYTES_PER_ELEMENT",e),a(a.P,c,Pt),L(c),a(a.P+a.F*Tt,c,{set:Lt}),a(a.P+a.F*!A,c,Ft),r||T.toString==ft||(T.toString=ft),a(a.P+a.F*o((function(){new d(1).slice()})),c,{slice:Mt}),a(a.P+a.F*(o((function(){return[1,2].toLocaleString()!=new d([1,2]).toLocaleString()}))||!o((function(){T.toLocaleString.call([1,2])}))),c,{toLocaleString:xt}),P[c]=A?N:k,r||A||f(T,dt,k)}}else t.exports=function(){}},T8I8:function(t,e){t.exports=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/},Wcq6:function(t,e,n){"use strict";var r,i=(r=n("wj3C"))&&"object"==typeof r&&"default"in r?r.default:r;i.registerVersion("firebase","7.6.1","app"),t.exports=i},"Y++M":function(t,e,n){"use strict";var r=n("DFzH"),i=n("dTG6"),o=n("kiRH");t.exports=function(t){for(var e=r(this),n=o(e.length),a=arguments.length,s=i(a>1?arguments[1]:void 0,n),u=a>2?arguments[2]:void 0,c=void 0===u?n:i(u,n);c>s;)e[s++]=t;return e}},YtDf:function(t,e,n){"use strict";n("R48M"),Object.defineProperty(e,"__esModule",{value:!0});var r,i=n("Ribc"),o=(r=i)&&r.__esModule?r:{default:r};e.default=o.default},YuTi:function(t,e,n){n("R48M"),t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},ZiRl:function(t,e,n){var r=n("P8UN");r(r.P,"String",{repeat:n("gd4K")})},Zs65:function(t,e,n){"use strict";n.r(e);n("NSPt")},bdgK:function(t,e,n){"use strict";(function(t){n("eMsz"),n("AqHK"),n("pS08"),n("U6Bt"),n("Ggvi"),n("OeI1"),n("sc67"),n("1dPr"),n("n7j8"),n("JHok"),n("R48M"),n("wZFJ"),n("rzGZ"),n("Dq+y"),n("8npG"),n("YbXK"),n("xJgp");var r=function(){if("undefined"!=typeof Map)return Map;function t(t,e){var n=-1;return t.some((function(t,r){return t[0]===e&&(n=r,!0)})),n}return function(){function e(){this.__entries__=[]}return Object.defineProperty(e.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var n=t(this.__entries__,e),r=this.__entries__[n];return r&&r[1]},e.prototype.set=function(e,n){var r=t(this.__entries__,e);~r?this.__entries__[r][1]=n:this.__entries__.push([e,n])},e.prototype.delete=function(e){var n=this.__entries__,r=t(n,e);~r&&n.splice(r,1)},e.prototype.has=function(e){return!!~t(this.__entries__,e)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,e){void 0===e&&(e=null);for(var n=0,r=this.__entries__;n<r.length;n++){var i=r[n];t.call(e,i[1],i[0])}},e}()}(),i="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,o=void 0!==t&&t.Math===Math?t:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),a="function"==typeof requestAnimationFrame?requestAnimationFrame.bind(o):function(t){return setTimeout((function(){return t(Date.now())}),1e3/60)},s=2;var u=20,c=["top","right","bottom","left","width","height","size","weight"],h="undefined"!=typeof MutationObserver,l=function(){function t(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(t,e){var n=!1,r=!1,i=0;function o(){n&&(n=!1,t()),r&&c()}function u(){a(o)}function c(){var t=Date.now();if(n){if(t-i<s)return;r=!0}else n=!0,r=!1,setTimeout(u,e);i=t}return c}(this.refresh.bind(this),u)}return t.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},t.prototype.removeObserver=function(t){var e=this.observers_,n=e.indexOf(t);~n&&e.splice(n,1),!e.length&&this.connected_&&this.disconnect_()},t.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},t.prototype.updateObservers_=function(){var t=this.observers_.filter((function(t){return t.gatherActive(),t.hasActive()}));return t.forEach((function(t){return t.broadcastActive()})),t.length>0},t.prototype.connect_=function(){i&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),h?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){i&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,n=void 0===e?"":e;c.some((function(t){return!!~n.indexOf(t)}))&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),f=function(t,e){for(var n=0,r=Object.keys(e);n<r.length;n++){var i=r[n];Object.defineProperty(t,i,{value:e[i],enumerable:!1,writable:!1,configurable:!0})}return t},p=function(t){return t&&t.ownerDocument&&t.ownerDocument.defaultView||o},d=b(0,0,0,0);function m(t){return parseFloat(t)||0}function y(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return e.reduce((function(e,n){return e+m(t["border-"+n+"-width"])}),0)}function g(t){var e=t.clientWidth,n=t.clientHeight;if(!e&&!n)return d;var r=p(t).getComputedStyle(t),i=function(t){for(var e={},n=0,r=["top","right","bottom","left"];n<r.length;n++){var i=r[n],o=t["padding-"+i];e[i]=m(o)}return e}(r),o=i.left+i.right,a=i.top+i.bottom,s=m(r.width),u=m(r.height);if("border-box"===r.boxSizing&&(Math.round(s+o)!==e&&(s-=y(r,"left","right")+o),Math.round(u+a)!==n&&(u-=y(r,"top","bottom")+a)),!function(t){return t===p(t).document.documentElement}(t)){var c=Math.round(s+o)-e,h=Math.round(u+a)-n;1!==Math.abs(c)&&(s-=c),1!==Math.abs(h)&&(u-=h)}return b(i.left,i.top,s,u)}var v="undefined"!=typeof SVGGraphicsElement?function(t){return t instanceof p(t).SVGGraphicsElement}:function(t){return t instanceof p(t).SVGElement&&"function"==typeof t.getBBox};function _(t){return i?v(t)?function(t){var e=t.getBBox();return b(0,0,e.width,e.height)}(t):g(t):d}function b(t,e,n,r){return{x:t,y:e,width:n,height:r}}var w=function(){function t(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=b(0,0,0,0),this.target=t}return t.prototype.isActive=function(){var t=_(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},t.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},t}(),E=function(t,e){var n,r,i,o,a,s,u,c=(r=(n=e).x,i=n.y,o=n.width,a=n.height,s="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,u=Object.create(s.prototype),f(u,{x:r,y:i,width:o,height:a,top:i,right:r+o,bottom:a+i,left:r}),u);f(this,{target:t,contentRect:c})},T=function(){function t(t,e,n){if(this.activeObservations_=[],this.observations_=new r,"function"!=typeof t)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=e,this.callbackCtx_=n}return t.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof p(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)||(e.set(t,new w(t)),this.controller_.addObserver(this),this.controller_.refresh())}},t.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof p(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)&&(e.delete(t),e.size||this.controller_.removeObserver(this))}},t.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},t.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach((function(e){e.isActive()&&t.activeObservations_.push(e)}))},t.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,e=this.activeObservations_.map((function(t){return new E(t.target,t.broadcastRect())}));this.callback_.call(t,e,t),this.clearActive()}},t.prototype.clearActive=function(){this.activeObservations_.splice(0)},t.prototype.hasActive=function(){return this.activeObservations_.length>0},t}(),C="undefined"!=typeof WeakMap?new WeakMap:new r,S=function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=l.getInstance(),r=new T(e,n,this);C.set(this,r)};["observe","unobserve","disconnect"].forEach((function(t){S.prototype[t]=function(){var e;return(e=C.get(this))[t].apply(e,arguments)}}));var I=void 0!==o.ResizeObserver?o.ResizeObserver:S;e.a=I}).call(this,n("yLpj"))},cRJv:function(t,e,n){"use strict";var r=n("DFzH"),i=n("dTG6"),o=n("kiRH");t.exports=[].copyWithin||function(t,e){var n=r(this),a=o(n.length),s=i(t,a),u=i(e,a),c=arguments.length>2?arguments[2]:void 0,h=Math.min((void 0===c?a:i(c,a))-u,a-s),l=1;for(u<s&&s<u+h&&(l=-1,u+=h-1,s+=h-1);h-- >0;)u in n?n[s]=n[u]:delete n[s],s+=l,u+=l;return n}},cxuS:function(t,e,n){var r=n("P8UN"),i=n("ys0W")(!1);r(r.S,"Object",{values:function(t){return i(t)}})},ewoU:function(t,e,n){"use strict";var r=n("tuyV"),i=n("BjK0"),o=n("kiRH"),a=n("ot9L"),s=n("sOol")("isConcatSpreadable");t.exports=function t(e,n,u,c,h,l,f,p){for(var d,m,y=h,g=0,v=!!f&&a(f,p,3);g<c;){if(g in u){if(d=v?v(u[g],g,n):u[g],m=!1,i(d)&&(m=void 0!==(m=d[s])?!!m:r(d)),m&&l>0)y=t(e,n,d,o(d.length),y,l-1)-1;else{if(y>=9007199254740991)throw TypeError();e[y]=d}y++}g++}return y}},fFpS:function(t,e,n){"use strict";n.r(e);n("E5k/"),n("rzGZ"),n("Dq+y"),n("8npG"),n("HQAx"),n("zGcK"),n("sC2a"),n("YbXK"),n("cFtU"),n("HQhv"),n("sPse");var r=n("q1tI"),i=n.n(r),o=n("vRfx"),a=(n("UXi0"),n("zEh/")),s=n("if7W"),u=n("LvDl"),c=n("ARus"),h=n("h3sT"),l=n("KKAB"),f=function(t){var e=t.images,n=t.onAnnotationSelect,o=t.cur,f=(t.filter,t.folder,t.children),p=(t.onNewImage,t.onChange),d=t.current,m=(t.imageChildren,Object(r.useState)(!1)),y=(m[0],m[1],'https://phantomjscloud.com/api/browser/v2/ak-maw28-drn6m-zchk2-wx8yy-c5zgk/?request={url:"https://beta.videobakers.de/collaboration/all/?workspace='+o.public_id+'",renderType:"pdf",renderSettings:{pdfOptions:{ format: "A4",\nlandscape:true,\npreferCSSPageSize:true,\n }}}');return i.a.createElement("div",{className:"mygallery"},i.a.createElement("div",{className:"selection",id:"galleryselection"},e.length>=1&&i.a.createElement("div",{className:"filter"},"true"===localStorage.getItem("videobakersadmin")&&i.a.createElement(l.a,{promise:function(){return Object(a.a)({files:[y]},(function(t){return window.open(t.url,"_blank"),t}),"temp_download")}},"Kommentare herunterladen"),"true"===localStorage.getItem("videobakersadmin")&&i.a.createElement("select",{onChange:function(t){window.location="/collaboration/file/?workspace="+new URLSearchParams(window.location.search).get("workspace")+"&lang="+t.target.value},value:new URLSearchParams(window.location.search).get("lang")||"de"},i.a.createElement("option",{value:"de"},"Deutsch"),i.a.createElement("option",{value:"en"},"Englisch")),i.a.createElement(h.a,{onClick:function(){window.open(o.secure_url.replace("/upload/","/upload/fl_attachment/"),"_blank")}},"Datei Herunterladen")),e.map((function(t,e){var r=t.annotations.filter((function(t){return t.time>0}));Object(u.chain)(r).groupBy("time").mapValues((function(t){return Object(u.chain)(t).map("comment").flattenDeep()})).forEach((function(t){return console.log(t)}));return i.a.createElement("div",{key:t.public_id,id:t.public_id+"_as",className:"mygalleryimage"},i.a.createElement("img",{alt:"",key:e,className:d(t)?"selected":"",onClick:function(){return p(t)},src:t.src}),t.annotations.length>0&&i.a.createElement("p",{className:"badgeimage"},t.annotations.length),d(t)&&r.length>0&&i.a.createElement("div",{className:"comments"},r.map((function(t){return i.a.createElement("div",{key:t.comment,className:"onecomment "+(Object(c.b)(t,document.getElementsByTagName("video")[0])?"activecom":""),onClick:function(){n(t)}},s.a.annotator.second," ",Math.round(t.time),": ",t.comment)}))))}))),i.a.createElement("div",{className:"gallerydetail"},f))},p=n("0osF"),d=n("4w6A"),m=n.n(d);n("CARs"),n("pdi6");var y=n("Wcq6");n("6nsN"),n("5x/H");n.d(e,"firebaseConfig",(function(){return g})),n.d(e,"getFiles",(function(){return b}));var g={apiKey:"AIzaSyDcMPzTmFKGvIicPwY3D1gJ75eksjNbDQY",authDomain:"videobakers-53fbb.firebaseapp.com",databaseURL:"https://videobakers-53fbb.firebaseio.com",projectId:"videobakers-53fbb",storageBucket:"videobakers-53fbb.appspot.com",messagingSenderId:"872373535977",appId:"1:872373535977:web:e10a1f305054cf5d391c78",measurementId:"G-0GKSY6T98P"},v=function(t){var e,n;function r(){for(var e,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(e=t.call.apply(t,[this].concat(r))||this).state={images:[],current:{resource_type:"image",src:"https://media.giphy.com/media/3oEjI6SIIHBdRxXI40/giphy.gif",annotations:[]}},e}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n;var a=r.prototype;return a.componentDidMount=function(){var t=this;"undefined"!=typeof window&&(document.onkeydown=function(e){e=e||window.event;var n=t.state.images.indexOf(t.state.images.filter((function(e){return e.public_id===t.state.current.public_id}))[0]);"38"==e.keyCode?t.loadImage(0===n?t.state.images[t.state.images.length-1]:t.state.images[n-1]):"40"==e.keyCode&&t.loadImage(t.state.images[(n+1)%t.state.images.length])},y.initializeApp(g),b((function(e){t.setState({images:e,all_images:e});var n=e.filter((function(t){return t.public_id===new URLSearchParams(window.location.search).get("workspace")}));t.loadImage(n.length>=1?n[0]:e[0])})))},a.loadImage=function(t){this.setState({current:t,time:null})},a.render=function(){var t=this;return i.a.createElement(p.a,null,i.a.createElement(f,{filter:function(e){return t.setState({images:t.state.all_images.filter((function(t){return t.annotations.length>=(e?0:1)}))})},onAnnotationSelect:function(e){document.getElementById(t.state.current.public_id+"_img").currentTime=e.time,t.forceUpdate()},folder:"undefined"!=typeof window&&new URLSearchParams(window.location.search).get("workspace").split("/")[0],current:function(e){return!!t.state.current&&e.public_id===t.state.current.public_id},onChange:function(e){return t.loadImage(e)},cur:this.state.current,images:this.state.images},i.a.createElement(o.a,{setAnnotations:function(e){t.state.current.annotations=e,t.forceUpdate()},setTime:function(e){return t.setState({time:e})},time:this.state.time,save:function(e,n){t.state.current.annotations=t.state.current.annotations.filter((function(t){return!!t.comment})),t.state.current.annotations.forEach((function(t){return t.id=Math.random()})),t.state.current.update(t.state.current.annotations),t.forceUpdate()},id:this.state.current.public_id,image:this.state.current})))},r}(i.a.Component);e.default=v;function _(t){console.log(JSON.stringify({meta:t.annotations,public_id:t.public_id,resource_type:t.resource_type}));var e=n("Wcq6");n("6nsN"),n("Zs65"),e.database().ref("files/"+(new URLSearchParams(window.location.search).get("lang")||"de")+"/"+t.public_id).set({meta:JSON.parse(JSON.stringify(t.annotations))})}function b(t,e){var r=new URLSearchParams(window.location.search).get("workspace").split("_idx_")[0],i=n("Wcq6");n("6nsN"),n("Zs65"),i.database().ref("/files/"+(new URLSearchParams(window.location.search).get("lang")||"de")+"/"+r).once("value").then((function(n){fetch("/api/all?folder="+r).then((function(t){return t.json()})).then((function(r){if(r.resources.length<=0)m()({text:"There are currently no files in this workspace. It may take some time till all files are present after upload. Try again in 2 Minutes."}).showToast({duration:6e4});else{var i=Array.from(r.resources).map((function(t){return t.src=t.secure_url.replace(".mp4",".jpg"),t.annotations=n.val()&&n.val().meta?n.val().meta:[],t.annotations.forEach((function(t){return t.id=Math.random()})),t.annotations=t.annotations.sort((function(t,e){return t.time-e.time})),t.update=function(e){t.annotations=e,_(t)},t}));i=i.flatMap((function(t){return console.log(t.pages>=1),t.pages>=1?Array.from(Array(t.pages).keys()).map((function(e){var n=e+1;return Object.assign({},t,{public_id:t.public_id+"_idx_"+n,src:t.secure_url.replace("https://res.cloudinary.com/hvioxpubt/image/upload/","https://res.cloudinary.com/hvioxpubt/image/upload/pg_"+n+"/").replace(".pdf",".jpg"),annotations:t.annotations.filter((function(t){return t.page===n})),update:function(e){t.annotations=t.annotations.filter((function(t){return t.page!==n})).concat(e.map((function(t){return Object.assign({},t,{page:n})}))),console.log(t),_(t)}})})):[t]})),e&&(console.log(i),i=i.flatMap((function(t){return console.log("transofrming videos"),"video"===t.resource_type?t.annotations.map((function(e){var n="https://res.cloudinary.com/hvioxpubt/video/upload/so_"+e.time+",eo_"+e.time+"/"+t.public_id+".jpg";return{public_id:t.public_id+e.time+e.x+e.y,secure_url:n,src:n,resource_type:"image",annotations:[Object.assign({},e,{time:null})]}})):[t]}))),console.log(i),t(i)}}))}))}},fKCf:function(t,e){t.exports=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/},gBT9:function(t,e,n){var r=n("BjK0"),i=Math.floor;t.exports=function(t){return!r(t)&&isFinite(t)&&i(t)===t}},gd4K:function(t,e,n){"use strict";var r=n("1Llc"),i=n("ap2Z");t.exports=function(t){var e=String(i(this)),n="",o=r(t);if(o<0||o==1/0)throw RangeError("Count can't be negative");for(;o>0;(o>>>=1)&&(e+=e))1&o&&(n+=e);return n}},gx6d:function(t,e,n){var r=n("1Llc"),i=n("kiRH");t.exports=function(t){if(void 0===t)return 0;var e=r(t),n=i(e);if(e!==n)throw RangeError("Wrong length!");return n}},iuFa:function(t,e,n){var r=n("P8UN");r(r.S,"Number",{isNaN:function(t){return t!=t}})},jTPX:function(t,e,n){n("sC2a");t.exports=function(t,e,n){return((n=window.getComputedStyle)?n(t):t.currentStyle)[e.replace(/-(\w)/gi,(function(t,e){return e.toUpperCase()}))]}},lizw:function(t,e,n){"use strict";var r=n("P8UN"),i=n("pTxf"),o=n("CL53"),a=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(o);r(r.P+r.F*a,"String",{padStart:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!0)}})},m5Zt:function(t,e,n){var r=n("P8UN");r(r.S,"Number",{MAX_SAFE_INTEGER:9007199254740991})},mrSG:function(t,e,n){"use strict";n.r(e),n.d(e,"__extends",(function(){return i})),n.d(e,"__assign",(function(){return o})),n.d(e,"__rest",(function(){return a})),n.d(e,"__decorate",(function(){return s})),n.d(e,"__param",(function(){return u})),n.d(e,"__metadata",(function(){return c})),n.d(e,"__awaiter",(function(){return h})),n.d(e,"__generator",(function(){return l})),n.d(e,"__exportStar",(function(){return f})),n.d(e,"__values",(function(){return p})),n.d(e,"__read",(function(){return d})),n.d(e,"__spread",(function(){return m})),n.d(e,"__spreadArrays",(function(){return y})),n.d(e,"__await",(function(){return g})),n.d(e,"__asyncGenerator",(function(){return v})),n.d(e,"__asyncDelegator",(function(){return _})),n.d(e,"__asyncValues",(function(){return b})),n.d(e,"__makeTemplateObject",(function(){return w})),n.d(e,"__importStar",(function(){return E})),n.d(e,"__importDefault",(function(){return T}));n("rzGZ"),n("m210"),n("6kNP"),n("8npG"),n("R48M"),n("4DPX"),n("sc67"),n("E5k/"),n("pS08"),n("LagC");var 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 i(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return(o=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 a(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function s(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function u(t,e){return function(n,r){e(n,r,t)}}function c(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function h(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(e){o(e)}}function s(t){try{u(r.throw(t))}catch(e){o(e)}}function u(t){t.done?i(t.value):new n((function(e){e(t.value)})).then(a,s)}u((r=r.apply(t,e||[])).next())}))}function l(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(s){o=[6,s],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function f(t,e){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}function p(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function d(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(s){i={error:s}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function m(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(d(arguments[e]));return t}function y(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}function g(t){return this instanceof g?(this.v=t,this):new g(t)}function v(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(t,e||[]),o=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(t){i[t]&&(r[t]=function(e){return new Promise((function(n,r){o.push([t,e,n,r])>1||s(t,e)}))})}function s(t,e){try{(n=i[t](e)).value instanceof g?Promise.resolve(n.value.v).then(u,c):h(o[0][2],n)}catch(r){h(o[0][3],r)}var n}function u(t){s("next",t)}function c(t){s("throw",t)}function h(t,e){t(e),o.shift(),o.length&&s(o[0][0],o[0][1])}}function _(t){var e,n;return e={},r("next"),r("throw",(function(t){throw t})),r("return"),e[Symbol.iterator]=function(){return this},e;function r(r,i){e[r]=t[r]?function(e){return(n=!n)?{value:g(t[r](e)),done:"return"===r}:i?i(e):e}:i}}function b(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=p(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,i){(function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)})(r,i,(e=t[n](e)).done,e.value)}))}}}function w(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function E(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function T(t){return t&&t.__esModule?t:{default:t}}},n0hJ:function(t,e,n){var r=n("P8UN");r(r.P,"Array",{fill:n("Y++M")}),n("Dq1/")("fill")},p7ys:function(t,e){t.exports=/[\0-\x1F\x7F-\x9F]/},pQ2P:function(t,e,n){var r=n("P8UN"),i=n("J6QO");r(r.P+r.F*(Date.prototype.toISOString!==i),"Date",{toISOString:i})},pTxf:function(t,e,n){var r=n("kiRH"),i=n("gd4K"),o=n("ap2Z");t.exports=function(t,e,n,a){var s=String(o(t)),u=s.length,c=void 0===n?" ":String(n),h=r(e);if(h<=u||""==c)return s;var l=h-u,f=i.call(c,Math.ceil(l/c.length));return f.length>l&&(f=f.slice(0,l)),a?f+s:s+f}},pncC:function(t,e,n){var r=n("P8UN");r(r.S,"Number",{isInteger:n("gBT9")})},"q/0M":function(t,e,n){"use strict";n.r(e),n.d(e,"LogLevel",(function(){return i})),n.d(e,"Logger",(function(){return u})),n.d(e,"setLogLevel",(function(){return c}));n("JHok"),n("R48M"),n("pJf4"),n("pQ2P");function r(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}var i,o=[];!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"}(i||(i={}));var a=i.INFO,s=function(t,e){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];if(!(e<t.logLevel)){var a=(new Date).toISOString();switch(e){case i.DEBUG:case i.VERBOSE:console.log.apply(console,r(["["+a+"] "+t.name+":"],n));break;case i.INFO:console.info.apply(console,r(["["+a+"] "+t.name+":"],n));break;case i.WARN:console.warn.apply(console,r(["["+a+"] "+t.name+":"],n));break;case i.ERROR:console.error.apply(console,r(["["+a+"] "+t.name+":"],n));break;default:throw new Error("Attempted to log a message with an invalid logType (value: "+e+")")}}},u=function(){function t(t){this.name=t,this._logLevel=a,this._logHandler=s,o.push(this)}return Object.defineProperty(t.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in i))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,r([this,i.DEBUG],t))},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,r([this,i.VERBOSE],t))},t.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,r([this,i.INFO],t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,r([this,i.WARN],t))},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,r([this,i.ERROR],t))},t}();function c(t){o.forEach((function(e){e.logLevel=t}))}},sRdV:function(t,e,n){"use strict";t.exports=function(t){var e={};e.src_Any=n("y8fO").source,e.src_Cc=n("p7ys").source,e.src_Z=n("T8I8").source,e.src_P=n("fKCf").source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");return e.src_pseudo_letter="(?:(?![><|]|"+e.src_ZPCc+")"+e.src_Any+")",e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?",e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",e.src_host_terminator="(?=$|[><|]|"+e.src_ZPCc+")(?!-|_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|[><|]|[()[\\]{}.,\"'?!\\-]).|\\[(?:(?!"+e.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+e.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+e.src_ZCc+'|["]).)+\\"|\\\'(?:(?!'+e.src_ZCc+"|[']).)+\\'|\\'(?="+e.src_pseudo_letter+"|[-]).|\\.{2,4}[a-zA-Z0-9%/]|\\.(?!"+e.src_ZCc+"|[.]).|"+(t&&t["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+"\\,(?!"+e.src_ZCc+").|\\!(?!"+e.src_ZCc+"|[!]).|\\?(?!"+e.src_ZCc+"|[?]).)+|\\/)?",e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',e.src_xn="xn--[a-z0-9\\-]{1,59}",e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63})",e.src_domain="(?:"+e.src_xn+"|(?:"+e.src_pseudo_letter+")|(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+"))",e.src_host="(?:(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+"))",e.tpl_host_fuzzy="(?:"+e.src_ip4+"|(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%)))",e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))",e.src_host_strict=e.src_host+e.src_host_terminator,e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator,e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator,e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))",e.tpl_email_fuzzy='(^|[><|]|"|\\(|'+e.src_ZCc+")("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")",e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_fuzzy_strict+e.src_path+")",e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")",e}},t6oF:function(t,e,n){"use strict";(function(t){n("6kNP"),n("6nXr"),n("klQ5"),n("rzGZ"),n("Dq+y"),n("CtJk"),n("Ml7+"),n("nMRu"),n("zGcK"),n("lFjb"),n("Ll4R"),n("YBKJ"),n("DrhF"),n("HXzo"),n("sC2a"),n("wZFJ"),n("AqHK"),n("JHok"),n("pJf4"),n("1dPr"),n("sc67"),n("n7j8"),n("q8oJ"),n("C9fy"),n("8npG"),n("m210"),n("4DPX"),n("HQhv"),n("R48M"),n("+ar0");var e=n("wj3C"),r=n.n(e);(function(){var e,n="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,n){t!=Array.prototype&&t!=Object.prototype&&(t[e]=n.value)},i="undefined"!=typeof window&&window===this?this:void 0!==t&&null!=t?t:this;function o(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}function a(t){var e="undefined"!=typeof Symbol&&Symbol.iterator&&t[Symbol.iterator];return e?e.call(t):{next:o(t)}}!function(t,e){if(e){var r=i;t=t.split(".");for(var o=0;o<t.length-1;o++){var a=t[o];a in r||(r[a]={}),r=r[a]}(e=e(o=r[t=t[t.length-1]]))!=o&&null!=e&&n(r,t,{configurable:!0,writable:!0,value:e})}}("Promise",(function(t){function e(t){this.b=0,this.c=void 0,this.a=[];var e=this.f();try{t(e.resolve,e.reject)}catch(n){e.reject(n)}}function n(){this.a=null}function r(t){return t instanceof e?t:new e((function(e){e(t)}))}if(t)return t;n.prototype.b=function(t){if(null==this.a){this.a=[];var e=this;this.c((function(){e.g()}))}this.a.push(t)};var o=i.setTimeout;n.prototype.c=function(t){o(t,0)},n.prototype.g=function(){for(;this.a&&this.a.length;){var t=this.a;this.a=[];for(var e=0;e<t.length;++e){var n=t[e];t[e]=null;try{n()}catch(r){this.f(r)}}}this.a=null},n.prototype.f=function(t){this.c((function(){throw t}))},e.prototype.f=function(){function t(t){return function(r){n||(n=!0,t.call(e,r))}}var e=this,n=!1;return{resolve:t(this.m),reject:t(this.g)}},e.prototype.m=function(t){if(t===this)this.g(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof e)this.o(t);else{t:switch(typeof t){case"object":var n=null!=t;break t;case"function":n=!0;break t;default:n=!1}n?this.u(t):this.h(t)}},e.prototype.u=function(t){var e=void 0;try{e=t.then}catch(n){return void this.g(n)}"function"==typeof e?this.v(e,t):this.h(t)},e.prototype.g=function(t){this.i(2,t)},e.prototype.h=function(t){this.i(1,t)},e.prototype.i=function(t,e){if(0!=this.b)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.b);this.b=t,this.c=e,this.l()},e.prototype.l=function(){if(null!=this.a){for(var t=0;t<this.a.length;++t)s.b(this.a[t]);this.a=null}};var s=new n;return e.prototype.o=function(t){var e=this.f();t.La(e.resolve,e.reject)},e.prototype.v=function(t,e){var n=this.f();try{t.call(e,n.resolve,n.reject)}catch(r){n.reject(r)}},e.prototype.then=function(t,n){function r(t,e){return"function"==typeof t?function(e){try{i(t(e))}catch(n){o(n)}}:e}var i,o,a=new e((function(t,e){i=t,o=e}));return this.La(r(t,i),r(n,o)),a},e.prototype.catch=function(t){return this.then(void 0,t)},e.prototype.La=function(t,e){function n(){switch(r.b){case 1:t(r.c);break;case 2:e(r.c);break;default:throw Error("Unexpected state: "+r.b)}}var r=this;null==this.a?s.b(n):this.a.push(n)},e.resolve=r,e.reject=function(t){return new e((function(e,n){n(t)}))},e.race=function(t){return new e((function(e,n){for(var i=a(t),o=i.next();!o.done;o=i.next())r(o.value).La(e,n)}))},e.all=function(t){var n=a(t),i=n.next();return i.done?r([]):new e((function(t,e){function o(e){return function(n){a[e]=n,0==--s&&t(a)}}var a=[],s=0;do{a.push(void 0),s++,r(i.value).La(o(a.length-1),e),i=n.next()}while(!i.done)}))},e}));var s=s||{},u=this||self;function c(t){return"string"==typeof t}function h(t){return"boolean"==typeof t}var l=/^[\w+/_-]+[=]{0,2}$/,f=null;function p(){}function d(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 m(t){return null===t}function y(t){return"array"==d(t)}function g(t){var e=d(t);return"array"==e||"object"==e&&"number"==typeof t.length}function v(t){return"function"==d(t)}function _(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var b="closure_uid_"+(1e9*Math.random()>>>0),w=0;function E(t,e,n){return t.call.apply(t.bind,arguments)}function T(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 C(t,e,n){return(C=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?E:T).apply(null,arguments)}function S(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 I=Date.now||function(){return+new Date};function D(t,e){function n(){}n.prototype=e.prototype,t.qb=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.gd=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 N(t){if(!t)return!1;try{return!!t.$goog_Thenable}catch(e){return!1}}function A(t){if(Error.captureStackTrace)Error.captureStackTrace(this,A);else{var e=Error().stack;e&&(this.stack=e)}t&&(this.message=String(t))}function k(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");A.call(this,n+t[r])}function R(t,e){throw new k("Failure"+(t?": "+t:""),Array.prototype.slice.call(arguments,1))}function O(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function x(t,e){t.f(e),100>t.b&&(t.b++,e.next=t.a,t.a=e)}function P(){this.b=this.a=null}D(A,Error),A.prototype.name="CustomError",D(k,A),k.prototype.name="AssertionError",O.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 M=new O((function(){return new F}),(function(t){t.reset()}));function L(){var t=Wt,e=null;return t.a&&(e=t.a,t.a=t.a.next,t.a||(t.b=null),e.next=null),e}function F(){this.next=this.b=this.a=null}function U(t,e){t:{try{var n=t&&t.ownerDocument,r=n&&(n.defaultView||n.parentWindow);if((r=r||u).Element&&r.Location){var i=r;break t}}catch(a){}i=null}if(i&&void 0!==i[e]&&(!t||!(t instanceof i[e])&&(t instanceof i.Location||t instanceof i.Element))){if(_(t))try{var o=t.constructor.displayName||t.constructor.name||Object.prototype.toString.call(t)}catch(a){o="<object could not be stringified>"}else o=void 0===t?"undefined":null===t?"null":typeof t;R("Argument is not a %s (or a non-Element, non-Location mock); got: %s",e,o)}}P.prototype.add=function(t,e){var n=M.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},F.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null},F.prototype.reset=function(){this.next=this.b=this.a=null};var q=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(c(t))return c(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},V=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i=c(t)?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)};var B=Array.prototype.map?function(t,e){return Array.prototype.map.call(t,e,void 0)}:function(t,e){for(var n=t.length,r=Array(n),i=c(t)?t.split(""):t,o=0;o<n;o++)o in i&&(r[o]=e.call(void 0,i[o],o,t));return r},j=Array.prototype.some?function(t,e){return Array.prototype.some.call(t,e,void 0)}:function(t,e){for(var n=t.length,r=c(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 z(t,e){return 0<=q(t,e)}function W(t,e){var n;return(n=0<=(e=q(t,e)))&&Array.prototype.splice.call(t,e,1),n}function Q(t,e){!function(t,e){for(var n=c(t)?t.split(""):t,r=t.length-1;0<=r;--r)r in n&&e.call(void 0,n[r],r,t)}(t,(function(n,r){e.call(void 0,n,r,t)&&1==Array.prototype.splice.call(t,r,1).length&&0}))}function K(t){return Array.prototype.concat.apply([],arguments)}function H(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 G(t,e){for(var n in t)e.call(void 0,t[n],n,t)}function Y(t){for(var e in t)return!1;return!0}function X(t){var e,n={};for(e in t)n[e]=t[e];return n}var J="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Z(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<J.length;o++)n=J[o],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function $(t,e){this.a=t===nt&&e||"",this.b=et}function tt(t){return t instanceof $&&t.constructor===$&&t.b===et?t.a:(R("expected object of type Const, got '"+t+"'"),"type_error:Const")}$.prototype.qa=!0,$.prototype.pa=function(){return this.a},$.prototype.toString=function(){return"Const{"+this.a+"}"};var et={},nt={},rt=new $(nt,"");function it(){this.a="",this.b=ct}function ot(t){return t instanceof it&&t.constructor===it&&t.b===ct?t.a:(R("expected object of type TrustedResourceUrl, got '"+t+"' of type "+d(t)),"type_error:TrustedResourceUrl")}function at(t,e){var n=tt(t);if(!ut.test(n))throw Error("Invalid TrustedResourceUrl format: "+n);return ht(t=n.replace(st,(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 $?tt(t):encodeURIComponent(String(t))})))}it.prototype.qa=!0,it.prototype.pa=function(){return this.a.toString()},it.prototype.toString=function(){return"TrustedResourceUrl{"+this.a+"}"};var st=/%{(\w+)}/g,ut=/^((https:)?\/\/[0-9a-z.:[\]-]+\/|\/[^/\\]|[^:/\\%]+\/|[^:/\\%]*[?#]|about:blank#)/i,ct={};function ht(t){var e=new it;return e.a=t,e}var lt=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]},ft=/&/g,pt=/</g,dt=/>/g,mt=/"/g,yt=/'/g,gt=/\x00/g,vt=/[\x00&<>"']/;function _t(t,e){return-1!=t.indexOf(e)}function bt(t,e){return t<e?-1:t>e?1:0}function wt(){this.a="",this.b=It}function Et(t){return t instanceof wt&&t.constructor===wt&&t.b===It?t.a:(R("expected object of type SafeUrl, got '"+t+"' of type "+d(t)),"type_error:SafeUrl")}wt.prototype.qa=!0,wt.prototype.pa=function(){return this.a.toString()},wt.prototype.toString=function(){return"SafeUrl{"+this.a+"}"};var Tt=/^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i;function Ct(t){return t instanceof wt?t:(t="object"==typeof t&&t.qa?t.pa():String(t),Tt.test(t)||(t="about:invalid#zClosurez"),Dt(t))}var St,It={};function Dt(t){var e=new wt;return e.a=t,e}Dt("about:blank");t:{var Nt=u.navigator;if(Nt){var At=Nt.userAgent;if(At){St=At;break t}}St=""}function kt(t){return _t(St,t)}function Rt(){this.a="",this.b=xt}function Ot(t){return t instanceof Rt&&t.constructor===Rt&&t.b===xt?t.a:(R("expected object of type SafeHtml, got '"+t+"' of type "+d(t)),"type_error:SafeHtml")}Rt.prototype.qa=!0,Rt.prototype.pa=function(){return this.a.toString()},Rt.prototype.toString=function(){return"SafeHtml{"+this.a+"}"};var xt={};function Pt(t){var e=new Rt;return e.a=t,e}Pt("<!DOCTYPE html>");var Mt,Lt,Ft=Pt("");function Ut(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")}function qt(t){return vt.test(t)&&(-1!=t.indexOf("&")&&(t=t.replace(ft,"&")),-1!=t.indexOf("<")&&(t=t.replace(pt,"<")),-1!=t.indexOf(">")&&(t=t.replace(dt,">")),-1!=t.indexOf('"')&&(t=t.replace(mt,""")),-1!=t.indexOf("'")&&(t=t.replace(yt,"'")),-1!=t.indexOf("\0")&&(t=t.replace(gt,"�"))),t}function Vt(t){u.setTimeout((function(){throw t}),0)}function Bt(){var t=u.MessageChannel;if(void 0===t&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&!kt("Presto")&&(t=function(){var t=document.createElement("IFRAME");t.style.display="none",function(t){var e=ht(tt(rt));U(t,"HTMLIFrameElement"),t.src=ot(e).toString()}(t),document.documentElement.appendChild(t);var e=t.contentWindow;(t=e.document).open(),t.write(Ot(Ft)),t.close();var n="callImmediate"+Math.random(),r="file:"==e.location.protocol?"*":e.location.protocol+"//"+e.location.host;t=C((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&&!kt("Trident")&&!kt("MSIE")){var e=new t,n={},r=n;return e.port1.onmessage=function(){if(void 0!==n.next){var t=(n=n.next).yb;n.yb=null,t()}},function(t){r.next={yb: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){u.setTimeout(t,0)}}function jt(t,e){Lt||function(){if(u.Promise&&u.Promise.resolve){var t=u.Promise.resolve(void 0);Lt=function(){t.then(Qt)}}else Lt=function(){var t=Qt;!v(u.setImmediate)||u.Window&&u.Window.prototype&&!kt("Edge")&&u.Window.prototype.setImmediate==u.setImmediate?(Mt||(Mt=Bt()),Mt(t)):u.setImmediate(t)}}(),zt||(Lt(),zt=!0),Wt.add(t,e)}Pt("<br>");var zt=!1,Wt=new P;function Qt(){for(var t;t=L();){try{t.a.call(t.b)}catch(e){Vt(e)}x(M,t)}zt=!1}function Kt(t,e){if(this.a=Ht,this.i=void 0,this.f=this.b=this.c=null,this.g=this.h=!1,t!=p)try{var n=this;t.call(e,(function(t){oe(n,Gt,t)}),(function(t){if(!(t instanceof fe))try{if(t instanceof Error)throw t;throw Error("Promise rejected.")}catch(e){}oe(n,Yt,t)}))}catch(r){oe(this,Yt,r)}}var Ht=0,Gt=2,Yt=3;function Xt(){this.next=this.f=this.b=this.g=this.a=null,this.c=!1}Xt.prototype.reset=function(){this.f=this.b=this.g=this.a=null,this.c=!1};var Jt=new O((function(){return new Xt}),(function(t){t.reset()}));function Zt(t,e,n){var r=Jt.get();return r.g=t,r.b=e,r.f=n,r}function $t(t){if(t instanceof Kt)return t;var e=new Kt(p);return oe(e,Gt,t),e}function te(t){return new Kt((function(e,n){n(t)}))}function ee(t,e,n){ae(t,e,n,null)||jt(S(e,t))}function ne(t){return new Kt((function(e){var n=t.length,r=[];if(n)for(var i=function(t,i,o){n--,r[t]=i?{Gb:!0,value:o}:{Gb:!1,reason:o},0==n&&e(r)},o=0;o<t.length;o++)ee(t[o],S(i,o,!0),S(i,o,!1));else e(r)}))}function re(t,e){t.b||t.a!=Gt&&t.a!=Yt||se(t),t.f?t.f.next=e:t.b=e,t.f=e}function ie(t,e,n,r){var i=Zt(null,null,null);return i.a=new Kt((function(t,o){i.g=e?function(n){try{var i=e.call(r,n);t(i)}catch(a){o(a)}}:t,i.b=n?function(e){try{var i=n.call(r,e);void 0===i&&e instanceof fe?o(e):t(i)}catch(a){o(a)}}:o})),i.a.c=t,re(t,i),i.a}function oe(t,e,n){t.a==Ht&&(t===n&&(e=Yt,n=new TypeError("Promise cannot resolve to itself")),t.a=1,ae(n,t.Oc,t.Pc,t)||(t.i=n,t.a=e,t.c=null,se(t),e!=Yt||n instanceof fe||function(t,e){t.g=!0,jt((function(){t.g&&le.call(null,e)}))}(t,n)))}function ae(t,e,n,r){if(t instanceof Kt)return re(t,Zt(e||p,n||null,r)),!0;if(N(t))return t.then(e,n,r),!0;if(_(t))try{var i=t.then;if(v(i))return function(t,e,n,r,i){function o(t){a||(a=!0,r.call(i,t))}var a=!1;try{e.call(t,(function(t){a||(a=!0,n.call(i,t))}),o)}catch(s){o(s)}}(t,i,e,n,r),!0}catch(o){return n.call(r,o),!0}return!1}function se(t){t.h||(t.h=!0,jt(t.Zb,t))}function ue(t){var e=null;return t.b&&(e=t.b,t.b=e.next,e.next=null),t.b||(t.f=null),e}function ce(t,e,n,r){if(n==Yt&&e.b&&!e.c)for(;t&&t.g;t=t.c)t.g=!1;if(e.a)e.a.c=null,he(e,n,r);else try{e.c?e.g.call(e.f):he(e,n,r)}catch(i){le.call(null,i)}x(Jt,e)}function he(t,e,n){e==Gt?t.g.call(t.f,n):t.b&&t.b.call(t.f,n)}Kt.prototype.then=function(t,e,n){return ie(this,v(t)?t:null,v(e)?e:null,n)},Kt.prototype.$goog_Thenable=!0,(e=Kt.prototype).ka=function(t,e){return(t=Zt(t,t,e)).c=!0,re(this,t),this},e.s=function(t,e){return ie(this,null,t,e)},e.cancel=function(t){this.a==Ht&&jt((function(){!function t(e,n){if(e.a==Ht)if(e.c){var r=e.c;if(r.b){for(var i=0,o=null,a=null,s=r.b;s&&(s.c||(i++,s.a==e&&(o=s),!(o&&1<i)));s=s.next)o||(a=s);o&&(r.a==Ht&&1==i?t(r,n):(a?((i=a).next==r.f&&(r.f=i),i.next=i.next.next):ue(r),ce(r,o,Yt,n)))}e.c=null}else oe(e,Yt,n)}(this,new fe(t))}),this)},e.Oc=function(t){this.a=Ht,oe(this,Gt,t)},e.Pc=function(t){this.a=Ht,oe(this,Yt,t)},e.Zb=function(){for(var t;t=ue(this);)ce(this,t,this.a,this.i);this.h=!1};var le=Vt;function fe(t){A.call(this,t)}function pe(){0!=de&&(me[this[b]||(this[b]=++w)]=this),this.va=this.va,this.la=this.la}D(fe,A),fe.prototype.name="cancel";var de=0,me={};function ye(t){if(!t.va&&(t.va=!0,t.za(),0!=de)){var e=t[b]||(t[b]=++w);if(0!=de&&t.la&&0<t.la.length)throw Error(t+" did not empty its onDisposeCallbacks queue. This probably means it overrode dispose() or disposeInternal() without calling the superclass' method.");delete me[e]}}function ge(t){return ge[" "](t),t}pe.prototype.va=!1,pe.prototype.za=function(){if(this.la)for(;this.la.length;)this.la.shift()()},ge[" "]=p;var ve,_e,be=kt("Opera"),we=kt("Trident")||kt("MSIE"),Ee=kt("Edge"),Te=Ee||we,Ce=kt("Gecko")&&!(_t(St.toLowerCase(),"webkit")&&!kt("Edge"))&&!(kt("Trident")||kt("MSIE"))&&!kt("Edge"),Se=_t(St.toLowerCase(),"webkit")&&!kt("Edge");function Ie(){var t=u.document;return t?t.documentMode:void 0}t:{var De="",Ne=(_e=St,Ce?/rv:([^\);]+)(\)|;)/.exec(_e):Ee?/Edge\/([\d\.]+)/.exec(_e):we?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(_e):Se?/WebKit\/(\S+)/.exec(_e):be?/(?:Version)[ \/]?(\S+)/.exec(_e):void 0);if(Ne&&(De=Ne?Ne[1]:""),we){var Ae=Ie();if(null!=Ae&&Ae>parseFloat(De)){ve=String(Ae);break t}}ve=De}var ke,Re={};function Oe(t){return function(t,e){var n=Re;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(t,(function(){for(var e=0,n=lt(String(ve)).split("."),r=lt(String(t)).split("."),i=Math.max(n.length,r.length),o=0;0==e&&o<i;o++){var a=n[o]||"",s=r[o]||"";do{if(a=/(\d*)(\D*)(.*)/.exec(a)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],0==a[0].length&&0==s[0].length)break;e=bt(0==a[1].length?0:parseInt(a[1],10),0==s[1].length?0:parseInt(s[1],10))||bt(0==a[2].length,0==s[2].length)||bt(a[2],s[2]),a=a[3],s=s[3]}while(0==e)}return 0<=e}))}ke=u.document&&we?Ie():void 0;var xe=Object.freeze||function(t){return t},Pe=!we||9<=Number(ke),Me=we&&!Oe("9"),Le=function(){if(!u.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{u.addEventListener("test",p,e),u.removeEventListener("test",p,e)}catch(n){}return t}();function Fe(t,e){this.type=t,this.b=this.target=e,this.Mb=!0}function Ue(t,e){if(Fe.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,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.b=e,e=t.relatedTarget){if(Ce){t:{try{ge(e.nodeName);var i=!0;break t}catch(o){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,r?(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.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.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=c(t.pointerType)?t.pointerType:qe[t.pointerType]||"",this.a=t,t.defaultPrevented&&this.preventDefault()}}Fe.prototype.preventDefault=function(){this.Mb=!1},D(Ue,Fe);var qe=xe({2:"touch",3:"pen",4:"mouse"});Ue.prototype.preventDefault=function(){Ue.qb.preventDefault.call(this);var t=this.a;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,Me)try{(t.ctrlKey||112<=t.keyCode&&123>=t.keyCode)&&(t.keyCode=-1)}catch(e){}},Ue.prototype.f=function(){return this.a};var Ve="closure_listenable_"+(1e6*Math.random()|0),Be=0;function je(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.Pa=i,this.key=++Be,this.ta=this.Ka=!1}function ze(t){t.ta=!0,t.listener=null,t.proxy=null,t.src=null,t.Pa=null}function We(t){this.src=t,this.a={},this.b=0}function Qe(t,e){var n=e.type;n in t.a&&W(t.a[n],e)&&(ze(e),0==t.a[n].length&&(delete t.a[n],t.b--))}function Ke(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i];if(!o.ta&&o.listener==e&&o.capture==!!n&&o.Pa==r)return i}return-1}We.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var a=Ke(t,e,r,i);return-1<a?(e=t[a],n||(e.Ka=!1)):((e=new je(e,this.src,o,!!r,i)).Ka=n,t.push(e)),e};var He="closure_lm_"+(1e6*Math.random()|0),Ge={};function Ye(t,e,n,r,i){if(r&&r.once)Je(t,e,n,r,i);else if(y(e))for(var o=0;o<e.length;o++)Ye(t,e[o],n,r,i);else n=sn(n),t&&t[Ve]?cn(t,e,n,_(r)?!!r.capture:!!r,i):Xe(t,e,n,!1,r,i)}function Xe(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var a=_(i)?!!i.capture:!!i,s=on(t);if(s||(t[He]=s=new We(t)),!(n=s.add(e,n,r,a,o)).proxy){if(r=function(){var t=rn,e=Pe?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)Le||(i=a),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(tn(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}0}}function Je(t,e,n,r,i){if(y(e))for(var o=0;o<e.length;o++)Je(t,e[o],n,r,i);else n=sn(n),t&&t[Ve]?hn(t,e,n,_(r)?!!r.capture:!!r,i):Xe(t,e,n,!0,r,i)}function Ze(t,e,n,r,i){if(y(e))for(var o=0;o<e.length;o++)Ze(t,e[o],n,r,i);else r=_(r)?!!r.capture:!!r,n=sn(n),t&&t[Ve]?(t=t.u,(e=String(e).toString())in t.a&&(-1<(n=Ke(o=t.a[e],n,r,i))&&(ze(o[n]),Array.prototype.splice.call(o,n,1),0==o.length&&(delete t.a[e],t.b--)))):t&&(t=on(t))&&(e=t.a[e.toString()],t=-1,e&&(t=Ke(e,n,r,i)),(n=-1<t?e[t]:null)&&$e(n))}function $e(t){if("number"!=typeof t&&t&&!t.ta){var e=t.src;if(e&&e[Ve])Qe(e.u,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(tn(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=on(e))?(Qe(n,t),0==n.b&&(n.src=null,e[He]=null)):ze(t)}}}function tn(t){return t in Ge?Ge[t]:Ge[t]="on"+t}function en(t,e,n,r){var i=!0;if((t=on(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.ta&&(o=nn(o,r),i=i&&!1!==o)}return i}function nn(t,e){var n=t.listener,r=t.Pa||t.src;return t.Ka&&$e(t),n.call(r,e)}function rn(t,e){if(t.ta)return!0;if(!Pe){if(!e)t:{e=["window","event"];for(var n=u,r=0;r<e.length;r++)if(null==(n=n[e[r]])){e=null;break t}e=n}if(e=new Ue(r=e,this),n=!0,!(0>r.keyCode||null!=r.returnValue)){t:{var i=!1;if(0==r.keyCode)try{r.keyCode=-1;break t}catch(a){i=!0}(i||null==r.returnValue)&&(r.returnValue=!0)}for(r=[],i=e.b;i;i=i.parentNode)r.push(i);for(t=t.type,i=r.length-1;0<=i;i--){e.b=r[i];var o=en(r[i],t,!0,e);n=n&&o}for(i=0;i<r.length;i++)e.b=r[i],o=en(r[i],t,!1,e),n=n&&o}return n}return nn(t,new Ue(e,this))}function on(t){return(t=t[He])instanceof We?t:null}var an="__closure_events_fn_"+(1e9*Math.random()>>>0);function sn(t){return v(t)?t:(t[an]||(t[an]=function(e){return t.handleEvent(e)}),t[an])}function un(){pe.call(this),this.u=new We(this),this.Sb=this,this.Xa=null}function cn(t,e,n,r,i){t.u.add(String(e),n,!1,r,i)}function hn(t,e,n,r,i){t.u.add(String(e),n,!0,r,i)}function ln(t,e,n,r){if(!(e=t.u.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;o<e.length;++o){var a=e[o];if(a&&!a.ta&&a.capture==n){var s=a.listener,u=a.Pa||a.src;a.Ka&&Qe(t.u,a),i=!1!==s.call(u,r)&&i}}return i&&0!=r.Mb}function fn(t,e,n){if(v(t))n&&(t=C(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=C(t.handleEvent,t)}return 2147483647<Number(e)?-1:u.setTimeout(t,e||0)}function pn(t){var e=null;return new Kt((function(n,r){-1==(e=fn((function(){n(void 0)}),t))&&r(Error("Failed to schedule timer."))})).s((function(t){throw u.clearTimeout(e),t}))}function dn(t){if(t.U&&"function"==typeof t.U)return t.U();if(c(t))return t.split("");if(g(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}function mn(t){if(t.X&&"function"==typeof t.X)return t.X();if(!t.U||"function"!=typeof t.U){if(g(t)||c(t)){var e=[];t=t.length;for(var n=0;n<t;n++)e.push(n);return e}for(var r in e=[],n=0,t)e[n++]=r;return e}}function yn(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 yn)for(n=t.X(),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 gn(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];vn(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;)vn(i,r=t.a[e])||(t.a[n++]=r,i[r]=1),e++;t.a.length=n}}function vn(t,e){return Object.prototype.hasOwnProperty.call(t,e)}D(un,pe),un.prototype[Ve]=!0,un.prototype.addEventListener=function(t,e,n,r){Ye(this,t,e,n,r)},un.prototype.removeEventListener=function(t,e,n,r){Ze(this,t,e,n,r)},un.prototype.dispatchEvent=function(t){var e,n=this.Xa;if(n)for(e=[];n;n=n.Xa)e.push(n);n=this.Sb;var r=t.type||t;if(c(t))t=new Fe(t,n);else if(t instanceof Fe)t.target=t.target||n;else{var i=t;Z(t=new Fe(r,n),i)}if(i=!0,e)for(var o=e.length-1;0<=o;o--){var a=t.b=e[o];i=ln(a,r,!0,t)&&i}if(i=ln(a=t.b=n,r,!0,t)&&i,i=ln(a,r,!1,t)&&i,e)for(o=0;o<e.length;o++)i=ln(a=t.b=e[o],r,!1,t)&&i;return i},un.prototype.za=function(){if(un.qb.za.call(this),this.u){var t,e=this.u;for(t in e.a){for(var n=e.a[t],r=0;r<n.length;r++)ze(n[r]);delete e.a[t],e.b--}}this.Xa=null},(e=yn.prototype).U=function(){gn(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},e.X=function(){return gn(this),this.a.concat()},e.clear=function(){this.b={},this.c=this.a.length=0},e.get=function(t,e){return vn(this.b,t)?this.b[t]:e},e.set=function(t,e){vn(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},e.forEach=function(t,e){for(var n=this.X(),r=0;r<n.length;r++){var i=n[r],o=this.get(i);t.call(e,o,i,this)}};var _n=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function bn(t,e){var n;this.b=this.i=this.f="",this.l=null,this.g=this.c="",this.h=!1,t instanceof bn?(this.h=void 0!==e?e:t.h,wn(this,t.f),this.i=t.i,this.b=t.b,En(this,t.l),this.c=t.c,Tn(this,jn(t.a)),this.g=t.g):t&&(n=String(t).match(_n))?(this.h=!!e,wn(this,n[1]||"",!0),this.i=Nn(n[2]||""),this.b=Nn(n[3]||"",!0),En(this,n[4]),this.c=Nn(n[5]||"",!0),Tn(this,n[6]||"",!0),this.g=Nn(n[7]||"")):(this.h=!!e,this.a=new Ln(null,this.h))}function wn(t,e,n){t.f=n?Nn(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function En(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.l=e}else t.l=null}function Tn(t,e,n){e instanceof Ln?(t.a=e,function(t,e){e&&!t.f&&(Fn(t),t.c=null,t.a.forEach((function(t,e){var n=e.toLowerCase();e!=n&&(qn(this,e),Bn(this,n,t))}),t)),t.f=e}(t.a,t.h)):(n||(e=An(e,Pn)),t.a=new Ln(e,t.h))}function Cn(t,e,n){t.a.set(e,n)}function Sn(t,e){return t.a.get(e)}function In(t){return t instanceof bn?new bn(t):new bn(t,void 0)}function Dn(t,e){var n=new bn(null,void 0);return wn(n,"https"),t&&(n.b=t),e&&(n.c=e),n}function Nn(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function An(t,e,n){return c(t)?(t=encodeURI(t).replace(e,kn),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function kn(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}bn.prototype.toString=function(){var t=[],e=this.f;e&&t.push(An(e,Rn,!0),":");var n=this.b;return(n||"file"==e)&&(t.push("//"),(e=this.i)&&t.push(An(e,Rn,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.l)&&t.push(":",String(n))),(n=this.c)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(An(n,"/"==n.charAt(0)?xn:On,!0))),(n=this.a.toString())&&t.push("?",n),(n=this.g)&&t.push("#",An(n,Mn)),t.join("")},bn.prototype.resolve=function(t){var e=new bn(this),n=!!t.f;n?wn(e,t.f):n=!!t.i,n?e.i=t.i:n=!!t.b,n?e.b=t.b:n=null!=t.l;var r=t.c;if(n)En(e,t.l);else if(n=!!t.c){if("/"!=r.charAt(0))if(this.b&&!this.c)r="/"+r;else{var i=e.c.lastIndexOf("/");-1!=i&&(r=e.c.substr(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(_t(i,"./")||_t(i,"/.")){r=0==i.lastIndexOf("/",0),i=i.split("/");for(var o=[],a=0;a<i.length;){var s=i[a++];"."==s?r&&a==i.length&&o.push(""):".."==s?((1<o.length||1==o.length&&""!=o[0])&&o.pop(),r&&a==i.length&&o.push("")):(o.push(s),r=!0)}r=o.join("/")}else r=i}return n?e.c=r:n=""!==t.a.toString(),n?Tn(e,jn(t.a)):n=!!t.g,n&&(e.g=t.g),e};var Rn=/[#\/\?@]/g,On=/[#\?:]/g,xn=/[#\?]/g,Pn=/[#\?@]/g,Mn=/#/g;function Ln(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function Fn(t){t.a||(t.a=new yn,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 Un(t){var e=mn(t);if(void 0===e)throw Error("Keys are undefined");var n=new Ln(null,void 0);t=dn(t);for(var r=0;r<e.length;r++){var i=e[r],o=t[r];y(o)?Bn(n,i,o):n.add(i,o)}return n}function qn(t,e){Fn(t),e=zn(t,e),vn(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,vn((t=t.a).b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&gn(t)))}function Vn(t,e){return Fn(t),e=zn(t,e),vn(t.a.b,e)}function Bn(t,e,n){qn(t,e),0<n.length&&(t.c=null,t.a.set(zn(t,e),H(n)),t.b+=n.length)}function jn(t){var e=new Ln;return e.c=t.c,t.a&&(e.a=new yn(t.a),e.b=t.b),e}function zn(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}(e=Ln.prototype).add=function(t,e){Fn(this),this.c=null,t=zn(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},e.clear=function(){this.a=this.c=null,this.b=0},e.forEach=function(t,e){Fn(this),this.a.forEach((function(n,r){V(n,(function(n){t.call(e,n,r,this)}),this)}),this)},e.X=function(){Fn(this);for(var t=this.a.U(),e=this.a.X(),n=[],r=0;r<e.length;r++)for(var i=t[r],o=0;o<i.length;o++)n.push(e[r]);return n},e.U=function(t){Fn(this);var e=[];if(c(t))Vn(this,t)&&(e=K(e,this.a.get(zn(this,t))));else{t=this.a.U();for(var n=0;n<t.length;n++)e=K(e,t[n])}return e},e.set=function(t,e){return Fn(this),this.c=null,Vn(this,t=zn(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},e.get=function(t,e){return t&&0<(t=this.U(t)).length?String(t[0]):e},e.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var t=[],e=this.a.X(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.U(r);for(var o=0;o<r.length;o++){var a=i;""!==r[o]&&(a+="="+encodeURIComponent(String(r[o]))),t.push(a)}}return this.c=t.join("&")};var Wn=!we||9<=Number(ke);function Qn(t){var e=document;return c(t)?e.getElementById(t):t}function Kn(t,e){G(e,(function(e,n){e&&"object"==typeof e&&e.qa&&(e=e.pa()),"style"==n?t.style.cssText=e:"class"==n?t.className=e:"for"==n?t.htmlFor=e:Hn.hasOwnProperty(n)?t.setAttribute(Hn[n],e):0==n.lastIndexOf("aria-",0)||0==n.lastIndexOf("data-",0)?t.setAttribute(n,e):t[n]=e}))}var Hn={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 Gn(t,e,n){var r=arguments,i=document,o=String(r[0]),a=r[1];if(!Wn&&a&&(a.name||a.type)){if(o=["<",o],a.name&&o.push(' name="',qt(a.name),'"'),a.type){o.push(' type="',qt(a.type),'"');var s={};Z(s,a),delete s.type,a=s}o.push(">"),o=o.join("")}return o=i.createElement(o),a&&(c(a)?o.className=a:y(a)?o.className=a.join(" "):Kn(o,a)),2<r.length&&function(t,e,n){function r(n){n&&e.appendChild(c(n)?t.createTextNode(n):n)}for(var i=2;i<n.length;i++){var o=n[i];!g(o)||_(o)&&0<o.nodeType?r(o):V(Yn(o)?H(o):o,r)}}(i,o,r),o}function Yn(t){if(t&&"number"==typeof t.length){if(_(t))return"function"==typeof t.item||"string"==typeof t.item;if(v(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(y(n)){var i=n;n=i.length,r.push("[");for(var o="",a=0;a<n;a++)r.push(o),t(e,i[a],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(a=n[i])&&(r.push(o),tr(i,r),r.push(":"),t(e,a,r),o=","));return void r.push("}")}n=n.valueOf()}switch(typeof n){case"string":tr(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 Jn,t,e),e.join("")}function Jn(){}var Zn={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\u000b"},$n=/\uffff/.test("")?/[\\"\x00-\x1f\x7f-\uffff]/g:/[\\"\x00-\x1f\x7f-\xff]/g;function tr(t,e){e.push('"',t.replace($n,(function(t){var e=Zn[t];return e||(e="\\u"+(65536|t.charCodeAt(0)).toString(16).substr(1),Zn[t]=e),e})),'"')}function er(){var t=br();return we&&!!ke&&11==ke||/Edge\/\d+/.test(t)}function nr(){return u.window&&u.window.location.href||self&&self.location&&self.location.href||""}function rr(t,e){e=e||u.window;var n="about:blank";t&&(n=Et(Ct(t)).toString()),e.location.href=n}function ir(t){return!!((t=(t||br()).toLowerCase()).match(/android/)||t.match(/webos/)||t.match(/iphone|ipad|ipod/)||t.match(/blackberry/)||t.match(/windows phone/)||t.match(/iemobile/))}function or(t){t=t||u.window;try{t.close()}catch(e){}}function ar(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=br().toLowerCase(),r&&(e.target=r,_t(n,"crios/")&&(e.target="_blank")),gr(br())==mr&&(t=t||"http://localhost",e.scrollbars=!0),n=t||"",(t=e)||(t={}),r=window,e=n instanceof wt?n:Ct(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((kt("iPhone")&&!kt("iPod")&&!kt("iPad")||kt("iPad")||kt("iPod"))&&r.navigator&&r.navigator.standalone&&n&&"_self"!=n?(U(a=r.document.createElement("A"),"HTMLAnchorElement"),e instanceof wt||e instanceof wt||(e="object"==typeof e&&e.qa?e.pa():String(e),Tt.test(e)||(e="about:invalid#zClosurez"),e=Dt(e)),a.href=Et(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=Et(e).toString(),a&&(Te&&_t(t,";")&&(t="'"+t.replace(/'/g,"%27")+"'"),a.opener=null,t=Pt('<meta name="referrer" content="no-referrer"><meta http-equiv="refresh" content="0; url='+qt(t)+'">'),a.document.write(Ot(t)),a.document.close())):(a=r.open(Et(e).toString(),n,a))&&t.noopener&&(a.opener=null),a)try{a.focus()}catch(s){}return a}var sr=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,ur=/^[^@]+@[^@]+$/;function cr(){var t=null;return new Kt((function(e){"complete"==u.document.readyState?e():(t=function(){e()},Je(window,"load",t))})).s((function(e){throw Ze(window,"load",t),e}))}function hr(t){return t=t||br(),!("file:"!==Sr()&&"ionic:"!==Sr()||!t.toLowerCase().match(/iphone|ipad|ipod|android/))}function lr(){var t=u.window;try{return!(!t||t==t.top)}catch(e){return!1}}function fr(){return void 0!==u.WorkerGlobalScope&&"function"==typeof u.importScripts}function pr(){return r.a.INTERNAL.hasOwnProperty("reactNative")?"ReactNative":r.a.INTERNAL.hasOwnProperty("node")?"Node":fr()?"Worker":"Browser"}function dr(){var t=pr();return"ReactNative"===t||"Node"===t}var mr="Firefox",yr="Chrome";function gr(t){var e=t.toLowerCase();return _t(e,"opera/")||_t(e,"opr/")||_t(e,"opios/")?"Opera":_t(e,"iemobile")?"IEMobile":_t(e,"msie")||_t(e,"trident/")?"IE":_t(e,"edge/")?"Edge":_t(e,"firefox/")?mr:_t(e,"silk/")?"Silk":_t(e,"blackberry")?"Blackberry":_t(e,"webos")?"Webos":!_t(e,"safari/")||_t(e,"chrome/")||_t(e,"crios/")||_t(e,"android")?!_t(e,"chrome/")&&!_t(e,"crios/")||_t(e,"edge/")?_t(e,"android")?"Android":(t=t.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))&&2==t.length?t[1]:"Other":yr:"Safari"}var vr={Wc:"FirebaseCore-web",Yc:"FirebaseUI-web"};function _r(t,e){e=e||[];var n,r=[],i={};for(n in vr)i[vr[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=pr())?r=gr(i=br()):"Worker"===r&&(r=gr(i=br())+"-"+r),r+"/JsCore/"+t+"/"+e.join(",")}function br(){return u.navigator&&u.navigator.userAgent||""}function wr(t,e){t=t.split("."),e=e||u;for(var n=0;n<t.length&&"object"==typeof e&&null!=e;n++)e=e[t[n]];return n!=t.length&&(e=void 0),e}function Er(){try{var t=u.localStorage,e=kr();if(t)return t.setItem(e,"1"),t.removeItem(e),!er()||!!u.indexedDB}catch(n){return fr()&&!!u.indexedDB}return!1}function Tr(){return(Cr()||"chrome-extension:"===Sr()||hr())&&!dr()&&Er()&&!fr()}function Cr(){return"http:"===Sr()||"https:"===Sr()}function Sr(){return u.location&&u.location.protocol||null}function Ir(t){return!ir(t=t||br())&&gr(t)!=mr}function Dr(t){return void 0===t?null:Xn(t)}function Nr(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 Ar(t){if(null!==t)return JSON.parse(t)}function kr(t){return t||Math.floor(1e9*Math.random()).toString()}function Rr(t){return"Safari"!=gr(t=t||br())&&!t.toLowerCase().match(/iphone|ipad|ipod/)}function Or(){var t=u.___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 n=0;n<t.CP.length;n++)t.CP[n]=null}function xr(t,e){if(t>e)throw Error("Short delay should be less than long delay!");this.a=t,this.c=e,t=br(),e=pr(),this.b=ir(t)||"ReactNative"===e}function Pr(){var t=u.document;return!t||void 0===t.visibilityState||"visible"==t.visibilityState}function Mr(t){try{var e=new Date(parseInt(t,10));if(!isNaN(e.getTime())&&!/[^0-9]/.test(t))return e.toUTCString()}catch(n){}return null}function Lr(){return!(!wr("fireauth.oauthhelper",u)&&!wr("fireauth.iframe",u))}xr.prototype.get=function(){var t=u.navigator;return!t||"boolean"!=typeof t.onLine||!Cr()&&"chrome-extension:"!==Sr()&&void 0===t.connection||t.onLine?this.b?this.c:this.a:Math.min(5e3,this.a)};var Fr,Ur={};function qr(t){Ur[t]||(Ur[t]=!0,"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(t))}try{var Vr={};Object.defineProperty(Vr,"abcd",{configurable:!0,enumerable:!0,value:1}),Object.defineProperty(Vr,"abcd",{configurable:!0,enumerable:!0,value:2}),Fr=2==Vr.abcd}catch(_e){Fr=!1}function Br(t,e,n){Fr?Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:n}):t[e]=n}function jr(t,e){if(e)for(var n in e)e.hasOwnProperty(n)&&Br(t,n,e[n])}function zr(t){var e={};return jr(e,t),e}function Wr(t){var e=t;if("object"==typeof t&&null!=t)for(var n in e="length"in t?[]:{},t)Br(e,n,Wr(t[n]));return e}function Qr(t){var e={},n=t[Hr],r=t[Gr];if(!(t=t[Yr])||t!=Kr&&!n)throw Error("Invalid provider user info!");e[Jr]=r||null,e[Xr]=n||null,Br(this,$r,t),Br(this,Zr,Wr(e))}var Kr="EMAIL_SIGNIN",Hr="email",Gr="newEmail",Yr="requestType",Xr="email",Jr="fromEmail",Zr="data",$r="operation";function ti(t,e){this.code=ni+t,this.message=e||ri[t]||""}function ei(t){var e=t&&t.code;return e?new ti(e.substring(ni.length),t.message):null}D(ti,Error),ti.prototype.A=function(){return{code:this.code,message:this.message}},ti.prototype.toJSON=function(){return this.A()};var ni="auth/",ri={"admin-restricted-operation":"This operation is restricted to administrators only.","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-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-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","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.","invalid-tenant-id":"The Auth instance's tenant ID 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 request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","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.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",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.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","user-cancelled":"The 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 ii(t){var e=Sn(t=In(t),oi)||null,n=Sn(t,ai)||null,r=Sn(t,ci)||null;if(r=r&&li[r]||null,!e||!n||!r)throw new ti("argument-error",oi+", "+ai+"and "+ci+" are required in a valid action code URL.");jr(this,{apiKey:e,operation:r,code:n,continueUrl:Sn(t,si)||null,languageCode:Sn(t,ui)||null,tenantId:Sn(t,hi)||null})}var oi="apiKey",ai="oobCode",si="continueUrl",ui="languageCode",ci="mode",hi="tenantId",li={recoverEmail:"RECOVER_EMAIL",resetPassword:"PASSWORD_RESET",signIn:Kr,verifyEmail:"VERIFY_EMAIL"};function fi(t){try{return new ii(t)}catch(e){return null}}function pi(t){var e=t[vi];if(void 0===e)throw new ti("missing-continue-uri");if("string"!=typeof e||"string"==typeof e&&!e.length)throw new ti("invalid-continue-uri");this.h=e,this.b=this.a=null,this.g=!1;var n=t[di];if(n&&"object"==typeof n){e=n[wi];var r=n[_i];if(n=n[bi],"string"==typeof e&&e.length){if(this.a=e,void 0!==r&&"boolean"!=typeof r)throw new ti("argument-error",_i+" property must be a boolean when specified.");if(this.g=!!r,void 0!==n&&("string"!=typeof n||"string"==typeof n&&!n.length))throw new ti("argument-error",bi+" property must be a non empty string when specified.");this.b=n||null}else{if(void 0!==e)throw new ti("argument-error",wi+" property must be a non empty string when specified.");if(void 0!==r||void 0!==n)throw new ti("missing-android-pkg-name")}}else if(void 0!==n)throw new ti("argument-error",di+" property must be a non null object when specified.");if(this.f=null,(e=t[gi])&&"object"==typeof e){if("string"==typeof(e=e[Ei])&&e.length)this.f=e;else if(void 0!==e)throw new ti("argument-error",Ei+" property must be a non empty string when specified.")}else if(void 0!==e)throw new ti("argument-error",gi+" property must be a non null object when specified.");if(void 0!==(e=t[yi])&&"boolean"!=typeof e)throw new ti("argument-error",yi+" property must be a boolean when specified.");if(this.c=!!e,void 0!==(t=t[mi])&&("string"!=typeof t||"string"==typeof t&&!t.length))throw new ti("argument-error",mi+" property must be a non empty string when specified.");this.i=t||null}var di="android",mi="dynamicLinkDomain",yi="handleCodeInApp",gi="iOS",vi="url",_i="installApp",bi="minimumVersion",wi="packageName",Ei="bundleId";function Ti(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 Ci=null,Si=null;function Ii(t){var e="";return function(t,e){function n(e){for(;r<t.length;){var n=t.charAt(r++),i=Si[n];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return e}!function(){if(!Ci){Ci={},Si={};for(var t=0;65>t;t++)Ci[t]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(t),Si[Ci[t]]=t,62<=t&&(Si["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(t)]=t)}}();for(var r=0;;){var i=n(-1),o=n(0),a=n(64),s=n(64);if(64===s&&-1===i)break;e(i<<2|o>>4),64!=a&&(e(o<<4&240|a>>2),64!=s&&e(a<<6&192|s))}}(t,(function(t){e+=String.fromCharCode(t)})),e}function Di(t){this.f=t.sub,I(),this.a=t.provider_id||t.firebase&&t.firebase.sign_in_provider||null,this.c=t.firebase&&t.firebase.tenant||null,this.b=!!t.is_anonymous||"anonymous"==this.a}function Ni(t){return(t=Ai(t))&&t.sub&&t.iss&&t.aud&&t.exp?new Di(t):null}function Ai(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(Ii(t))}catch(r){}return null}Di.prototype.R=function(){return this.c},Di.prototype.g=function(){return this.b};var ki,Ri={bd:{cb:"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",ib:"https://securetoken.googleapis.com/v1/token",id:"p"},dd:{cb:"https://staging-www.sandbox.googleapis.com/identitytoolkit/v3/relyingparty/",ib:"https://staging-securetoken.sandbox.googleapis.com/v1/token",id:"s"},ed:{cb:"https://www-googleapis-test.sandbox.google.com/identitytoolkit/v3/relyingparty/",ib:"https://test-securetoken.sandbox.googleapis.com/v1/token",id:"t"}};function Oi(t){for(var e in Ri)if(Ri[e].id===t)return{firebaseEndpoint:(t=Ri[e]).cb,secureTokenEndpoint:t.ib};return null}ki=Oi("__EID__")?"__EID__":void 0;var xi="oauth_consumer_key oauth_nonce oauth_signature oauth_signature_method oauth_timestamp oauth_token oauth_version".split(" "),Pi=["client_id","response_type","scope","redirect_uri","state"],Mi={Xc:{Ea:"locale",sa:700,ra:600,Fa:"facebook.com",Qa:Pi},Zc:{Ea:null,sa:500,ra:750,Fa:"github.com",Qa:Pi},$c:{Ea:"hl",sa:515,ra:680,Fa:"google.com",Qa:Pi},fd:{Ea:"lang",sa:485,ra:705,Fa:"twitter.com",Qa:xi},Vc:{Ea:"locale",sa:600,ra:600,Fa:"apple.com",Qa:[]}};function Li(t){for(var e in Mi)if(Mi[e].Fa==t)return Mi[e];return null}function Fi(t){var e={};e["facebook.com"]=ji,e["google.com"]=Wi,e["github.com"]=zi,e["twitter.com"]=Qi;var n=t&&t[qi];try{if(n)return e[n]?new e[n](t):new Bi(t);if(void 0!==t[Ui])return new Vi(t)}catch(r){}return null}var Ui="idToken",qi="providerId";function Vi(t){var e=t[qi];if(!e&&t[Ui]){var n=Ni(t[Ui]);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),Br(this,"providerId",e),Br(this,"isNewUser",n)}function Bi(t){Vi.call(this,t),Br(this,"profile",Wr((t=Ar(t.rawUserInfo||"{}"))||{}))}function ji(t){if(Bi.call(this,t),"facebook.com"!=this.providerId)throw Error("Invalid provider ID!")}function zi(t){if(Bi.call(this,t),"github.com"!=this.providerId)throw Error("Invalid provider ID!");Br(this,"username",this.profile&&this.profile.login||null)}function Wi(t){if(Bi.call(this,t),"google.com"!=this.providerId)throw Error("Invalid provider ID!")}function Qi(t){if(Bi.call(this,t),"twitter.com"!=this.providerId)throw Error("Invalid provider ID!");Br(this,"username",t.screenName||null)}function Ki(t){var e=In(t),n=Sn(e,"link"),r=Sn(In(n),"link");return e=Sn(e,"deep_link_id"),Sn(In(e),"link")||e||r||n||t}function Hi(){}function Gi(t,e){return t.then((function(t){if(t[La]){var n=Ni(t[La]);if(!n||e!=n.f)throw new ti("user-mismatch");return t}throw new ti("user-mismatch")})).s((function(t){throw t&&t.code&&t.code==ni+"user-not-found"?new ti("user-mismatch"):t}))}function Yi(t,e){if(!e)throw new ti("internal-error","failed to construct a credential");this.a=e,Br(this,"providerId",t),Br(this,"signInMethod",t)}function Xi(t){return{pendingToken:t.a,requestUri:"http://localhost"}}function Ji(t){if(t&&t.providerId&&t.signInMethod&&0==t.providerId.indexOf("saml.")&&t.pendingToken)try{return new Yi(t.providerId,t.pendingToken)}catch(e){}return null}function Zi(t,e,n){if(this.a=null,e.idToken||e.accessToken)e.idToken&&Br(this,"idToken",e.idToken),e.accessToken&&Br(this,"accessToken",e.accessToken),e.nonce&&!e.pendingToken&&Br(this,"nonce",e.nonce),e.pendingToken&&(this.a=e.pendingToken);else{if(!e.oauthToken||!e.oauthTokenSecret)throw new ti("internal-error","failed to construct a credential");Br(this,"accessToken",e.oauthToken),Br(this,"secret",e.oauthTokenSecret)}Br(this,"providerId",t),Br(this,"signInMethod",n)}function $i(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:Un(e).toString(),requestUri:"http://localhost"},t.a&&(delete e.postBody,e.pendingToken=t.a),e}function to(t){if(t&&t.providerId&&t.signInMethod){var e={idToken:t.oauthIdToken,accessToken:t.oauthTokenSecret?null:t.oauthAccessToken,oauthTokenSecret:t.oauthTokenSecret,oauthToken:t.oauthTokenSecret&&t.oauthAccessToken,nonce:t.nonce,pendingToken:t.pendingToken};try{return new Zi(t.providerId,e,t.signInMethod)}catch(n){}}return null}function eo(t,e){this.Fc=e||[],jr(this,{providerId:t,isOAuthProvider:!0}),this.zb={},this.eb=(Li(t)||{}).Ea||null,this.bb=null}function no(t){if("string"!=typeof t||0!=t.indexOf("saml."))throw new ti("argument-error",'SAML provider IDs must be prefixed with "saml."');eo.call(this,t,[])}function ro(t){eo.call(this,t,Pi),this.a=[]}function io(){ro.call(this,"facebook.com")}function oo(t){if(!t)throw new ti("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return _(t)&&(e=t.accessToken),(new io).credential({accessToken:e})}function ao(){ro.call(this,"github.com")}function so(t){if(!t)throw new ti("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return _(t)&&(e=t.accessToken),(new ao).credential({accessToken:e})}function uo(){ro.call(this,"google.com"),this.ya("profile")}function co(t,e){var n=t;return _(t)&&(n=t.idToken,e=t.accessToken),(new uo).credential({idToken:n,accessToken:e})}function ho(){eo.call(this,"twitter.com",xi)}function lo(t,e){var n=t;if(_(n)||(n={oauthToken:t,oauthTokenSecret:e}),!n.oauthToken||!n.oauthTokenSecret)throw new ti("argument-error","credential failed: expected 2 arguments (the OAuth access token and secret).");return new Zi("twitter.com",n,"twitter.com")}function fo(t,e,n){this.a=t,this.c=e,Br(this,"providerId","password"),Br(this,"signInMethod",n===mo.EMAIL_LINK_SIGN_IN_METHOD?mo.EMAIL_LINK_SIGN_IN_METHOD:mo.EMAIL_PASSWORD_SIGN_IN_METHOD)}function po(t){return t&&t.email&&t.password?new fo(t.email,t.password,t.signInMethod):null}function mo(){jr(this,{providerId:"password",isOAuthProvider:!1})}function yo(t,e){if(!(e=go(e)))throw new ti("argument-error","Invalid email link!");return new fo(t,e.code,mo.EMAIL_LINK_SIGN_IN_METHOD)}function go(t){return(t=fi(t=Ki(t)))&&t.operation===Kr?t:null}function vo(t){if(!(t.Va&&t.Ua||t.Ha&&t.ba))throw new ti("internal-error");this.a=t,Br(this,"providerId","phone"),Br(this,"signInMethod","phone")}function _o(t){if(t&&"phone"===t.providerId&&(t.verificationId&&t.verificationCode||t.temporaryProof&&t.phoneNumber)){var e={};return V(["verificationId","verificationCode","temporaryProof","phoneNumber"],(function(n){t[n]&&(e[n]=t[n])})),new vo(e)}return null}function bo(t){return t.a.Ha&&t.a.ba?{temporaryProof:t.a.Ha,phoneNumber:t.a.ba}:{sessionInfo:t.a.Va,code:t.a.Ua}}function wo(t){try{this.a=t||r.a.auth()}catch(e){throw new ti("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().")}jr(this,{providerId:"phone",isOAuthProvider:!1})}function Eo(t,e){if(!t)throw new ti("missing-verification-id");if(!e)throw new ti("missing-verification-code");return new vo({Va:t,Ua:e})}function To(t){if(t.temporaryProof&&t.phoneNumber)return new vo({Ha:t.temporaryProof,ba: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,a=t&&t.pendingToken;try{switch(e){case"google.com":return co(o,n);case"facebook.com":return oo(n);case"github.com":return so(n);case"twitter.com":return lo(n,r);default:return n||r||o||a?a?0==e.indexOf("saml.")?new Yi(e,a):new Zi(e,{pendingToken:a,idToken:t.oauthIdToken,accessToken:t.oauthAccessToken},e):new ro(e).credential({idToken:o,accessToken:n,rawNonce:i}):null}}catch(s){return null}}function Co(t){if(!t.isOAuthProvider)throw new ti("invalid-oauth-provider")}function So(t,e,n,r,i,o,a){if(this.c=t,this.b=e||null,this.g=n||null,this.f=r||null,this.i=o||null,this.h=a||null,this.a=i||null,!this.g&&!this.a)throw new ti("invalid-auth-event");if(this.g&&this.a)throw new ti("invalid-auth-event");if(this.g&&!this.f)throw new ti("invalid-auth-event")}function Io(t){return(t=t||{}).type?new So(t.type,t.eventId,t.urlResponse,t.sessionId,t.error&&ei(t.error),t.postBody,t.tenantId):null}function Do(){this.b=null,this.a=[]}D(Bi,Vi),D(ji,Bi),D(zi,Bi),D(Wi,Bi),D(Qi,Bi),Yi.prototype.na=function(t){return ts(t,Xi(this))},Yi.prototype.b=function(t,e){var n=Xi(this);return n.idToken=e,es(t,n)},Yi.prototype.f=function(t,e){return Gi(ns(t,Xi(this)),e)},Yi.prototype.A=function(){return{providerId:this.providerId,signInMethod:this.signInMethod,pendingToken:this.a}},Zi.prototype.na=function(t){return ts(t,$i(this))},Zi.prototype.b=function(t,e){var n=$i(this);return n.idToken=e,es(t,n)},Zi.prototype.f=function(t,e){return Gi(ns(t,$i(this)),e)},Zi.prototype.A=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},eo.prototype.Ga=function(t){return this.zb=X(t),this},D(no,eo),D(ro,eo),ro.prototype.ya=function(t){return z(this.a,t)||this.a.push(t),this},ro.prototype.Hb=function(){return H(this.a)},ro.prototype.credential=function(t,e){var n;if(!(n=_(t)?{idToken:t.idToken||null,accessToken:t.accessToken||null,nonce:t.rawNonce||null}:{idToken:t||null,accessToken:e||null}).idToken&&!n.accessToken)throw new ti("argument-error","credential failed: must provide the ID token and/or the access token.");return new Zi(this.providerId,n,this.providerId)},D(io,ro),Br(io,"PROVIDER_ID","facebook.com"),Br(io,"FACEBOOK_SIGN_IN_METHOD","facebook.com"),D(ao,ro),Br(ao,"PROVIDER_ID","github.com"),Br(ao,"GITHUB_SIGN_IN_METHOD","github.com"),D(uo,ro),Br(uo,"PROVIDER_ID","google.com"),Br(uo,"GOOGLE_SIGN_IN_METHOD","google.com"),D(ho,eo),Br(ho,"PROVIDER_ID","twitter.com"),Br(ho,"TWITTER_SIGN_IN_METHOD","twitter.com"),fo.prototype.na=function(t){return this.signInMethod==mo.EMAIL_LINK_SIGN_IN_METHOD?Rs(t,hs,{email:this.a,oobCode:this.c}):Rs(t,Ds,{email:this.a,password:this.c})},fo.prototype.b=function(t,e){return this.signInMethod==mo.EMAIL_LINK_SIGN_IN_METHOD?Rs(t,ls,{idToken:e,email:this.a,oobCode:this.c}):Rs(t,ws,{idToken:e,email:this.a,password:this.c})},fo.prototype.f=function(t,e){return Gi(this.na(t),e)},fo.prototype.A=function(){return{email:this.a,password:this.c,signInMethod:this.signInMethod}},jr(mo,{PROVIDER_ID:"password"}),jr(mo,{EMAIL_LINK_SIGN_IN_METHOD:"emailLink"}),jr(mo,{EMAIL_PASSWORD_SIGN_IN_METHOD:"password"}),vo.prototype.na=function(t){return t.Wa(bo(this))},vo.prototype.b=function(t,e){var n=bo(this);return n.idToken=e,Rs(t,As,n)},vo.prototype.f=function(t,e){var n=bo(this);return n.operation="REAUTH",Gi(t=Rs(t,ks,n),e)},vo.prototype.A=function(){var t={providerId:"phone"};return this.a.Va&&(t.verificationId=this.a.Va),this.a.Ua&&(t.verificationCode=this.a.Ua),this.a.Ha&&(t.temporaryProof=this.a.Ha),this.a.ba&&(t.phoneNumber=this.a.ba),t},wo.prototype.Wa=function(t,e){var n=this.a.b;return $t(e.verify()).then((function(r){if(!c(r))throw new ti("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 Rs(t,_s,e)}(n,{phoneNumber:t,recaptchaToken:r}).then((function(t){return"function"==typeof e.reset&&e.reset(),t}),(function(t){throw"function"==typeof e.reset&&e.reset(),t}));default:throw new ti("argument-error",'Only firebase.auth.ApplicationVerifiers with type="recaptcha" are currently supported.')}}))},jr(wo,{PROVIDER_ID:"phone"}),jr(wo,{PHONE_SIGN_IN_METHOD:"phone"}),So.prototype.getUid=function(){var t=[];return t.push(this.c),this.b&&t.push(this.b),this.f&&t.push(this.f),this.h&&t.push(this.h),t.join("-")},So.prototype.R=function(){return this.h},So.prototype.A=function(){return{type:this.c,eventId:this.b,urlResponse:this.g,sessionId:this.f,postBody:this.i,tenantId:this.h,error:this.a&&this.a.A()}};var No,Ao=null;function ko(t){var e="unauthorized-domain",n=void 0,r=In(t);t=r.b,"chrome-extension"==(r=r.f)?n=Ut("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=Ut("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",ti.call(this,e,n)}function Ro(t,e,n){ti.call(this,t,n),(t=e||{}).Ab&&Br(this,"email",t.Ab),t.ba&&Br(this,"phoneNumber",t.ba),t.credential&&Br(this,"credential",t.credential),t.Qb&&Br(this,"tenantId",t.Qb)}function Oo(t){if(t.code){var e=t.code||"";0==e.indexOf(ni)&&(e=e.substring(ni.length));var n={credential:To(t),Qb:t.tenantId};if(t.email)n.Ab=t.email;else if(t.phoneNumber)n.ba=t.phoneNumber;else if(!n.credential)return new ti(e,t.message||void 0);return new Ro(e,n,t.message)}return null}function xo(){}function Po(t){return t.c||(t.c=t.b())}function Mo(){}function Lo(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(i){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed")}return t.f}function Fo(){}function Uo(){this.a=new XDomainRequest,this.readyState=0,this.onreadystatechange=null,this.responseType=this.responseText=this.response="",this.status=-1,this.statusText="",this.a.onload=C(this.fc,this),this.a.onerror=C(this.Ib,this),this.a.onprogress=C(this.gc,this),this.a.ontimeout=C(this.kc,this)}function qo(t,e){t.readyState=e,t.onreadystatechange&&t.onreadystatechange()}function Vo(t,e,n){this.reset(t,e,n,void 0,void 0)}D(ko,ti),D(Ro,ti),Ro.prototype.A=function(){var t={code:this.code,message:this.message};this.email&&(t.email=this.email),this.phoneNumber&&(t.phoneNumber=this.phoneNumber),this.tenantId&&(t.tenantId=this.tenantId);var e=this.credential&&this.credential.A();return e&&Z(t,e),t},Ro.prototype.toJSON=function(){return this.A()},xo.prototype.c=null,D(Mo,xo),Mo.prototype.a=function(){var t=Lo(this);return t?new ActiveXObject(t):new XMLHttpRequest},Mo.prototype.b=function(){var t={};return Lo(this)&&(t[0]=!0,t[1]=!0),t},No=new Mo,D(Fo,xo),Fo.prototype.a=function(){var t=new XMLHttpRequest;if("withCredentials"in t)return t;if("undefined"!=typeof XDomainRequest)return new Uo;throw Error("Unsupported browser")},Fo.prototype.b=function(){return{}},(e=Uo.prototype).open=function(t,e,n){if(null!=n&&!n)throw Error("Only async requests are supported.");this.a.open(t,e)},e.send=function(t){if(t){if("string"!=typeof t)throw Error("Only string data is supported");this.a.send(t)}else this.a.send()},e.abort=function(){this.a.abort()},e.setRequestHeader=function(){},e.getResponseHeader=function(t){return"content-type"==t.toLowerCase()?this.a.contentType:""},e.fc=function(){this.status=200,this.response=this.responseText=this.a.responseText,qo(this,4)},e.Ib=function(){this.status=500,this.response=this.responseText="",qo(this,4)},e.kc=function(){this.Ib()},e.gc=function(){this.status=200,qo(this,1)},e.getAllResponseHeaders=function(){return"content-type: "+this.a.contentType},Vo.prototype.a=null;function Bo(t){this.f=t,this.b=this.c=this.a=null}function jo(t,e){this.name=t,this.value=e}Vo.prototype.reset=function(t,e,n,r,i){"number"==typeof i||0,r||I(),delete this.a},jo.prototype.toString=function(){return this.name};var zo=new jo("SEVERE",1e3),Wo=new jo("WARNING",900),Qo=new jo("CONFIG",700),Ko=new jo("FINE",500);Bo.prototype.log=function(t,e,n){if(t.value>=function t(e){return e.c?e.c:e.a?t(e.a):(R("Root logger has no level set."),null)}(this).value)for(v(e)&&(e=e()),t=new Vo(t,String(e),this.f),n&&(t.a=n),n=this;n;)n=n.a};var Ho={},Go=null;function Yo(t){var e;if(Go||(Go=new Bo(""),Ho[""]=Go,Go.c=Qo),!(e=Ho[t])){e=new Bo(t);var n=t.lastIndexOf("."),r=t.substr(n+1);(n=Yo(t.substr(0,n))).b||(n.b={}),n.b[r]=e,e.a=n,Ho[t]=e}return e}function Xo(t,e){t&&t.log(Ko,e,void 0)}function Jo(t){this.f=t}function Zo(t){un.call(this),this.o=t,this.readyState=$o,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.i=new Headers,this.b=null,this.m="GET",this.g="",this.a=!1,this.h=Yo("goog.net.FetchXmlHttp"),this.l=this.c=this.f=null}D(Jo,xo),Jo.prototype.a=function(){return new Zo(this.f)},Jo.prototype.b=function(t){return function(){return t}}({}),D(Zo,un);var $o=0;function ta(t){t.c.read().then(t.ec.bind(t)).catch(t.Oa.bind(t))}function ea(t,e){e&&t.f&&(t.status=t.f.status,t.statusText=t.f.statusText),t.readyState=4,t.f=null,t.c=null,t.l=null,na(t)}function na(t){t.onreadystatechange&&t.onreadystatechange.call(t)}function ra(t){un.call(this),this.headers=new yn,this.B=t||null,this.c=!1,this.w=this.a=null,this.h=this.O=this.l="",this.f=this.J=this.i=this.I=!1,this.g=0,this.o=null,this.m=ia,this.v=this.P=!1}(e=Zo.prototype).open=function(t,e){if(this.readyState!=$o)throw this.abort(),Error("Error reopening a connection");this.m=t,this.g=e,this.readyState=1,na(this)},e.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.a=!0;var e={headers:this.i,method:this.m,credentials:void 0,cache:void 0};t&&(e.body=t),this.o.fetch(new Request(this.g,e)).then(this.jc.bind(this),this.Oa.bind(this))},e.abort=function(){this.response=this.responseText="",this.i=new Headers,this.status=0,this.c&&this.c.cancel("Request was aborted."),1<=this.readyState&&this.a&&4!=this.readyState&&(this.a=!1,ea(this,!1)),this.readyState=$o},e.jc=function(t){this.a&&(this.f=t,this.b||(this.b=t.headers,this.readyState=2,na(this)),this.a&&(this.readyState=3,na(this),this.a&&("arraybuffer"===this.responseType?t.arrayBuffer().then(this.hc.bind(this),this.Oa.bind(this)):void 0!==u.ReadableStream&&"body"in t?(this.response=this.responseText="",this.c=t.body.getReader(),this.l=new TextDecoder,ta(this)):t.text().then(this.ic.bind(this),this.Oa.bind(this)))))},e.ec=function(t){if(this.a){var e=this.l.decode(t.value?t.value:new Uint8Array(0),{stream:!t.done});e&&(this.response=this.responseText+=e),t.done?ea(this,!0):na(this),3==this.readyState&&ta(this)}},e.ic=function(t){this.a&&(this.response=this.responseText=t,ea(this,!0))},e.hc=function(t){this.a&&(this.response=t,ea(this,!0))},e.Oa=function(t){var e=this.h;e&&e.log(Wo,"Failed to fetch url "+this.g,t instanceof Error?t:Error(t)),this.a&&ea(this,!0)},e.setRequestHeader=function(t,e){this.i.append(t,e)},e.getResponseHeader=function(t){return this.b?this.b.get(t.toLowerCase())||"":((t=this.h)&&t.log(Wo,"Attempting to get response header but no headers have been received for url: "+this.g,void 0),"")},e.getAllResponseHeaders=function(){if(!this.b){var t=this.h;return t&&t.log(Wo,"Attempting to get all response headers but no headers have been received for url: "+this.g,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")},D(ra,un);var ia="";ra.prototype.b=Yo("goog.net.XhrIo");var oa=/^https?$/i,aa=["POST","PUT"];function sa(t,e,n,r,i){if(t.a)throw Error("[goog.net.XhrIo] Object is active with another request="+t.l+"; newUri="+e);n=n?n.toUpperCase():"GET",t.l=e,t.h="",t.O=n,t.I=!1,t.c=!0,t.a=t.B?t.B.a():No.a(),t.w=t.B?Po(t.B):Po(No),t.a.onreadystatechange=C(t.Lb,t);try{Xo(t.b,ya(t,"Opening Xhr")),t.J=!0,t.a.open(n,String(e),!0),t.J=!1}catch(a){return Xo(t.b,ya(t,"Error opening Xhr: "+a.message)),void ca(t,a)}e=r||"";var o=new yn(t.headers);i&&function(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(g(t)||c(t))V(t,e,void 0);else for(var n=mn(t),r=dn(t),i=r.length,o=0;o<i;o++)e.call(void 0,r[o],n&&n[o],t)}(i,(function(t,e){o.set(e,t)})),i=function(t){t:{for(var e=ua,n=t.length,r=c(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:c(t)?t.charAt(e):t[e]}(o.X()),r=u.FormData&&e instanceof u.FormData,!z(aa,n)||i||r||o.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),o.forEach((function(t,e){this.a.setRequestHeader(e,t)}),t),t.m&&(t.a.responseType=t.m),"withCredentials"in t.a&&t.a.withCredentials!==t.P&&(t.a.withCredentials=t.P);try{pa(t),0<t.g&&(t.v=function(t){return we&&Oe(9)&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(t.a),Xo(t.b,ya(t,"Will abort after "+t.g+"ms if incomplete, xhr2 "+t.v)),t.v?(t.a.timeout=t.g,t.a.ontimeout=C(t.Ia,t)):t.o=fn(t.Ia,t.g,t)),Xo(t.b,ya(t,"Sending request")),t.i=!0,t.a.send(e),t.i=!1}catch(a){Xo(t.b,ya(t,"Send error: "+a.message)),ca(t,a)}}function ua(t){return"content-type"==t.toLowerCase()}function ca(t,e){t.c=!1,t.a&&(t.f=!0,t.a.abort(),t.f=!1),t.h=e,ha(t),fa(t)}function ha(t){t.I||(t.I=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function la(t){if(t.c&&void 0!==s)if(t.w[1]&&4==da(t)&&2==ma(t))Xo(t.b,ya(t,"Local request error detected and ignored"));else if(t.i&&4==da(t))fn(t.Lb,0,t);else if(t.dispatchEvent("readystatechange"),4==da(t)){Xo(t.b,ya(t,"Request complete")),t.c=!1;try{var e,n=ma(t);t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(e=r)){var i;if(i=0===n){var o=String(t.l).match(_n)[1]||null;if(!o&&u.self&&u.self.location){var a=u.self.location.protocol;o=a.substr(0,a.length-1)}i=!oa.test(o?o.toLowerCase():"")}e=i}if(e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{try{var c=2<da(t)?t.a.statusText:""}catch(h){Xo(t.b,"Can not get status: "+h.message),c=""}t.h=c+" ["+ma(t)+"]",ha(t)}}finally{fa(t)}}}function fa(t,e){if(t.a){pa(t);var n=t.a,r=t.w[0]?p:null;t.a=null,t.w=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(i){(t=t.b)&&t.log(zo,"Problem encountered resetting onreadystatechange: "+i.message,void 0)}}}function pa(t){t.a&&t.v&&(t.a.ontimeout=null),t.o&&(u.clearTimeout(t.o),t.o=null)}function da(t){return t.a?t.a.readyState:0}function ma(t){try{return 2<da(t)?t.a.status:-1}catch(e){return-1}}function ya(t,e){return e+" ["+t.O+" "+t.l+" "+ma(t)+"]"}function ga(t){var e=Na;this.g=[],this.v=e,this.o=t||null,this.f=this.a=!1,this.c=void 0,this.u=this.w=this.i=!1,this.h=0,this.b=null,this.l=0}function va(t,e,n){t.a=!0,t.c=n,t.f=!e,Ea(t)}function _a(t){if(t.a){if(!t.u)throw new Ta(t);t.u=!1}}function ba(t,e,n,r){t.g.push([e,n,r]),t.a&&Ea(t)}function wa(t){return j(t.g,(function(t){return v(t[1])}))}function Ea(t){if(t.h&&t.a&&wa(t)){var e=t.h,n=Ia[e];n&&(u.clearTimeout(n.a),delete Ia[e]),t.h=0}t.b&&(t.b.l--,delete t.b),e=t.c;for(var r=n=!1;t.g.length&&!t.i;){var i=t.g.shift(),o=i[0],a=i[1];if(i=i[2],o=t.f?a:o)try{var s=o.call(i||t.o,e);void 0!==s&&(t.f=t.f&&(s==e||s instanceof Error),t.c=e=s),(N(e)||"function"==typeof u.Promise&&e instanceof u.Promise)&&(r=!0,t.i=!0)}catch(c){e=c,t.f=!0,wa(t)||(n=!0)}}t.c=e,r&&(s=C(t.m,t,!0),r=C(t.m,t,!1),e instanceof ga?(ba(e,s,r),e.w=!0):e.then(s,r)),n&&(e=new Sa(e),Ia[e.a]=e,t.h=e.a)}function Ta(){A.call(this)}function Ca(){A.call(this)}function Sa(t){this.a=u.setTimeout(C(this.c,this),0),this.b=t}(e=ra.prototype).Ia=function(){void 0!==s&&this.a&&(this.h="Timed out after "+this.g+"ms, aborting",Xo(this.b,ya(this,this.h)),this.dispatchEvent("timeout"),this.abort(8))},e.abort=function(){this.a&&this.c&&(Xo(this.b,ya(this,"Aborting")),this.c=!1,this.f=!0,this.a.abort(),this.f=!1,this.dispatchEvent("complete"),this.dispatchEvent("abort"),fa(this))},e.za=function(){this.a&&(this.c&&(this.c=!1,this.f=!0,this.a.abort(),this.f=!1),fa(this,!0)),ra.qb.za.call(this)},e.Lb=function(){this.va||(this.J||this.i||this.f?la(this):this.yc())},e.yc=function(){la(this)},e.getResponse=function(){try{if(!this.a)return null;if("response"in this.a)return this.a.response;switch(this.m){case ia: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(zo,"Response type "+this.m+" is not supported on this browser",void 0),null}catch(e){return Xo(this.b,"Can not get response: "+e.message),null}},ga.prototype.cancel=function(t){if(this.a)this.c instanceof ga&&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.o,this):this.u=!0,this.a||(t=new Ca(this),_a(this),va(this,!1,t))}},ga.prototype.m=function(t,e){this.i=!1,va(this,t,e)},ga.prototype.then=function(t,e,n){var r,i,o=new Kt((function(t,e){r=t,i=e}));return ba(this,r,(function(t){t instanceof Ca?o.cancel():i(t)})),o.then(t,e,n)},ga.prototype.$goog_Thenable=!0,D(Ta,A),Ta.prototype.message="Deferred has already fired",Ta.prototype.name="AlreadyCalledError",D(Ca,A),Ca.prototype.message="Deferred was canceled",Ca.prototype.name="CanceledError",Sa.prototype.c=function(){throw delete Ia[this.a],this.b};var Ia={};function Da(t){var e={},n=e.document||document,r=ot(t).toString(),i=document.createElement("SCRIPT"),o={Nb:i,Ia:void 0},a=new ga(o),s=null,c=null!=e.timeout?e.timeout:5e3;return 0<c&&(s=window.setTimeout((function(){Aa(i,!0);var t=new Oa(Ra,"Timeout reached for loading script "+r);_a(a),va(a,!1,t)}),c),o.Ia=s),i.onload=i.onreadystatechange=function(){i.readyState&&"loaded"!=i.readyState&&"complete"!=i.readyState||(Aa(i,e.hd||!1,s),_a(a),va(a,!0,null))},i.onerror=function(){Aa(i,!0,s);var t=new Oa(ka,"Error while loading script "+r);_a(a),va(a,!1,t)},Z(o=e.attributes||{},{type:"text/javascript",charset:"UTF-8"}),Kn(i,o),function(t,e){U(t,"HTMLScriptElement"),t.src=ot(e),null===f&&(f=(e=(e=u.document).querySelector&&e.querySelector("script[nonce]"))&&(e=e.nonce||e.getAttribute("nonce"))&&l.test(e)?e:""),(e=f)&&t.setAttribute("nonce",e)}(i,t),function(t){var e;return(e=(t||document).getElementsByTagName("HEAD"))&&0!=e.length?e[0]:t.documentElement}(n).appendChild(i),a}function Na(){if(this&&this.Nb){var t=this.Nb;t&&"SCRIPT"==t.tagName&&Aa(t,!0,this.Ia)}}function Aa(t,e,n){null!=n&&u.clearTimeout(n),t.onload=p,t.onerror=p,t.onreadystatechange=p,e&&window.setTimeout((function(){t&&t.parentNode&&t.parentNode.removeChild(t)}),0)}var ka=0,Ra=1;function Oa(t,e){var n="Jsloader error (code #"+t+")";e&&(n+=": "+e),A.call(this,n),this.code=t}function xa(t){this.f=t}function Pa(t,e,n){if(this.c=t,t=e||{},this.l=t.secureTokenEndpoint||"https://securetoken.googleapis.com/v1/token",this.u=t.secureTokenTimeout||Fa,this.g=X(t.secureTokenHeaders||Ua),this.h=t.firebaseEndpoint||"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",this.i=t.firebaseTimeout||qa,this.a=X(t.firebaseHeaders||Va),n&&(this.a["X-Client-Version"]=n,this.g["X-Client-Version"]=n),n="Node"==pr(),!(n=u.XMLHttpRequest||n&&r.a.INTERNAL.node&&r.a.INTERNAL.node.XMLHttpRequest)&&!fr())throw new ti("internal-error","The XMLHttpRequest compatibility library was not found.");this.f=void 0,fr()?this.f=new Jo(self):dr()?this.f=new xa(n):this.f=new Fo,this.b=null}D(Oa,A),D(xa,xo),xa.prototype.a=function(){return new this.f},xa.prototype.b=function(){return{}};var Ma,La="idToken",Fa=new xr(3e4,6e4),Ua={"Content-Type":"application/x-www-form-urlencoded"},qa=new xr(3e4,6e4),Va={"Content-Type":"application/json"};function Ba(t,e){e?t.a["X-Firebase-Locale"]=e:delete t.a["X-Firebase-Locale"]}function ja(t,e){e?(t.a["X-Client-Version"]=e,t.g["X-Client-Version"]=e):(delete t.a["X-Client-Version"],delete t.g["X-Client-Version"])}function za(t,e,n,r,i,o,a){(function(){var t=br();return!((t=gr(t)!=yr?null:(t=t.match(/\sChrome\/(\d+)/i))&&2==t.length?parseInt(t[1],10):null)&&30>t)&&(!we||!ke||9<ke)})()||fr()?t=C(t.o,t):(Ma||(Ma=new Kt((function(t,e){!function(t,e){if(((window.gapi||{}).client||{}).request)t();else{u[Qa]=function(){((window.gapi||{}).client||{}).request?t():e(Error("CORS_UNSUPPORTED"))},function(t,e){ba(t,null,e,void 0)}(Da(at(Wa,{onload:Qa})),(function(){e(Error("CORS_UNSUPPORTED"))}))}}(t,e)}))),t=C(t.m,t)),t(e,n,r,i,o,a)}Pa.prototype.R=function(){return this.b},Pa.prototype.o=function(t,e,n,r,i,o){if(fr()&&(void 0===u.fetch||void 0===u.Headers||void 0===u.Request))throw new ti("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 ra(this.f);if(o){a.g=Math.max(0,o);var s=setTimeout((function(){a.dispatchEvent("timeout")}),o)}cn(a,"complete",(function(){s&&clearTimeout(s);var t=null;try{t=JSON.parse(function(t){try{return t.a?t.a.responseText:""}catch(e){return Xo(t.b,"Can not get responseText: "+e.message),""}}(this))||null}catch(n){t=null}e&&e(t)})),hn(a,"ready",(function(){s&&clearTimeout(s),ye(this)})),hn(a,"timeout",(function(){s&&clearTimeout(s),ye(this),e&&e(null)})),sa(a,t,n,r,i)};var Wa=new $(nt,"https://apis.google.com/js/client.js?onload=%{onload}"),Qa="__fcb"+Math.floor(1e6*Math.random()).toString();function Ka(t){if(!c(t=t.email)||!ur.test(t))throw new ti("invalid-email")}function Ha(t){"email"in t&&Ka(t)}function Ga(t){if(!t[La])throw new ti("internal-error")}function Ya(t){if(t.phoneNumber||t.temporaryProof){if(!t.phoneNumber||!t.temporaryProof)throw new ti("internal-error")}else{if(!t.sessionInfo)throw new ti("missing-verification-id");if(!t.code)throw new ti("missing-verification-code")}}Pa.prototype.m=function(t,e,n,r,i){var o=this;Ma.then((function(){window.gapi.client.setApiKey(o.c);var a=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(a),e&&e(t)}})})).s((function(t){e&&e({error:{message:t&&t.message||"CORS_UNSUPPORTED"}})}))},Pa.prototype.ob=function(){return Rs(this,Es,{})},Pa.prototype.rb=function(t,e){return Rs(this,bs,{idToken:t,email:e})},Pa.prototype.sb=function(t,e){return Rs(this,ws,{idToken:t,password:e})};var Xa={displayName:"DISPLAY_NAME",photoUrl:"PHOTO_URL"};function Ja(t){if(!t.requestUri||!t.sessionId&&!t.postBody&&!t.pendingToken)throw new ti("internal-error")}function Za(t,e){return e.oauthIdToken&&e.providerId&&0==e.providerId.indexOf("oidc.")&&!e.pendingToken&&(t.sessionId?e.nonce=t.sessionId:t.postBody&&(Vn(t=new Ln(t.postBody),"nonce")&&(e.nonce=t.get("nonce")))),e}function $a(t){var e=null;if(t.needConfirmation?(t.code="account-exists-with-different-credential",e=Oo(t)):"FEDERATED_USER_ID_ALREADY_LINKED"==t.errorMessage?(t.code="credential-already-in-use",e=Oo(t)):"EMAIL_EXISTS"==t.errorMessage?(t.code="email-already-in-use",e=Oo(t)):t.errorMessage&&(e=Os(t.errorMessage)),e)throw e;if(!t[La])throw new ti("internal-error")}function ts(t,e){return e.returnIdpCredential=!0,Rs(t,Ts,e)}function es(t,e){return e.returnIdpCredential=!0,Rs(t,Ss,e)}function ns(t,e){return e.returnIdpCredential=!0,e.autoCreate=!1,Rs(t,Cs,e)}function rs(t){if(!t.oobCode)throw new ti("invalid-action-code")}(e=Pa.prototype).tb=function(t,e){var n={idToken:t},r=[];return G(Xa,(function(t,i){var o=e[i];null===o?r.push(t):i in e&&(n[i]=o)})),r.length&&(n.deleteAttribute=r),Rs(this,bs,n)},e.kb=function(t,e){return Z(t={requestType:"PASSWORD_RESET",email:t},e),Rs(this,ms,t)},e.lb=function(t,e){return Z(t={requestType:"EMAIL_SIGNIN",email:t},e),Rs(this,ps,t)},e.jb=function(t,e){return Z(t={requestType:"VERIFY_EMAIL",idToken:t},e),Rs(this,ds,t)},e.Wa=function(t){return Rs(this,Ns,t)},e.ab=function(t,e){return Rs(this,vs,{oobCode:t,newPassword:e})},e.Ma=function(t){return Rs(this,os,{oobCode:t})},e.Ya=function(t){return Rs(this,is,{oobCode:t})};var is={endpoint:"setAccountInfo",D:rs,fa:"email",F:!0},os={endpoint:"resetPassword",D:rs,K:function(t){var e=t.requestType;if(!e||!t.email&&"EMAIL_SIGNIN"!=e)throw new ti("internal-error")},F:!0},as={endpoint:"signupNewUser",D:function(t){if(Ka(t),!t.password)throw new ti("weak-password")},K:Ga,T:!0,F:!0},ss={endpoint:"createAuthUri",F:!0},us={endpoint:"deleteAccount",V:["idToken"]},cs={endpoint:"setAccountInfo",V:["idToken","deleteProvider"],D:function(t){if(!y(t.deleteProvider))throw new ti("internal-error")}},hs={endpoint:"emailLinkSignin",V:["email","oobCode"],D:Ka,K:Ga,T:!0,F:!0},ls={endpoint:"emailLinkSignin",V:["idToken","email","oobCode"],D:Ka,K:Ga,T:!0},fs={endpoint:"getAccountInfo"},ps={endpoint:"getOobConfirmationCode",V:["requestType"],D:function(t){if("EMAIL_SIGNIN"!=t.requestType)throw new ti("internal-error");Ka(t)},fa:"email",F:!0},ds={endpoint:"getOobConfirmationCode",V:["idToken","requestType"],D:function(t){if("VERIFY_EMAIL"!=t.requestType)throw new ti("internal-error")},fa:"email",F:!0},ms={endpoint:"getOobConfirmationCode",V:["requestType"],D:function(t){if("PASSWORD_RESET"!=t.requestType)throw new ti("internal-error");Ka(t)},fa:"email",F:!0},ys={wb:!0,endpoint:"getProjectConfig",Kb:"GET"},gs={wb:!0,endpoint:"getRecaptchaParam",Kb:"GET",K:function(t){if(!t.recaptchaSiteKey)throw new ti("internal-error")}},vs={endpoint:"resetPassword",D:rs,fa:"email",F:!0},_s={endpoint:"sendVerificationCode",V:["phoneNumber","recaptchaToken"],fa:"sessionInfo",F:!0},bs={endpoint:"setAccountInfo",V:["idToken"],D:Ha,T:!0},ws={endpoint:"setAccountInfo",V:["idToken"],D:function(t){if(Ha(t),!t.password)throw new ti("weak-password")},K:Ga,T:!0},Es={endpoint:"signupNewUser",K:Ga,T:!0,F:!0},Ts={endpoint:"verifyAssertion",D:Ja,Ra:Za,K:$a,T:!0,F:!0},Cs={endpoint:"verifyAssertion",D:Ja,Ra:Za,K:function(t){if(t.errorMessage&&"USER_NOT_FOUND"==t.errorMessage)throw new ti("user-not-found");if(t.errorMessage)throw Os(t.errorMessage);if(!t[La])throw new ti("internal-error")},T:!0,F:!0},Ss={endpoint:"verifyAssertion",D:function(t){if(Ja(t),!t.idToken)throw new ti("internal-error")},Ra:Za,K:$a,T:!0},Is={endpoint:"verifyCustomToken",D:function(t){if(!t.token)throw new ti("invalid-custom-token")},K:Ga,T:!0,F:!0},Ds={endpoint:"verifyPassword",D:function(t){if(Ka(t),!t.password)throw new ti("wrong-password")},K:Ga,T:!0,F:!0},Ns={endpoint:"verifyPhoneNumber",D:Ya,K:Ga,F:!0},As={endpoint:"verifyPhoneNumber",D:function(t){if(!t.idToken)throw new ti("internal-error");Ya(t)},K:function(t){if(t.temporaryProof)throw t.code="credential-already-in-use",Oo(t);Ga(t)}},ks={Yb:{USER_NOT_FOUND:"user-not-found"},endpoint:"verifyPhoneNumber",D:Ya,K:Ga,F:!0};function Rs(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(null==r||""===r)return!1}return!0}(n,e.V))return te(new ti("internal-error"));var r,i=e.Kb||"POST";return $t(n).then(e.D).then((function(){return e.T&&(n.returnSecureToken=!0),e.F&&t.b&&void 0===n.tenantId&&(n.tenantId=t.b),function(t,e,n,r,i,o){var a=In(t.h+e);Cn(a,"key",t.c),o&&Cn(a,"cb",I().toString());var s="GET"==n;if(s)for(var u in r)r.hasOwnProperty(u)&&Cn(a,u,r[u]);return new Kt((function(e,o){za(t,a.toString(),(function(t){t?t.error?o(xs(t,i||{})):e(t):o(new ti("network-request-failed"))}),n,s?void 0:Xn(Nr(r)),t.a,t.i.get())}))}(t,e.endpoint,i,n,e.Yb,e.wb||!1)})).then((function(t){return r=t,e.Ra?e.Ra(n,r):r})).then(e.K).then((function(){if(!e.fa)return r;if(!(e.fa in r))throw new ti("internal-error");return r[e.fa]}))}function Os(t){return xs({error:{errors:[{message:t}],code:400,message:t}})}function xs(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 ti(r[n]):null)return n;for(var i in n=t.error&&t.error.message||"",Z(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",UNSUPPORTED_TENANT_OPERATION:"unsupported-tenant-operation",INVALID_TENANT_ID:"invalid-tenant-id",TENANT_ID_MISMATCH:"tenant-id-mismatch",ADMIN_ONLY_OPERATION:"admin-restricted-operation"},e||{}),e=(e=n.match(/^[^\s]+\s*:\s*([\s\S]*)$/))&&1<e.length?e[1]:void 0,r)if(0===n.indexOf(i))return new ti(r[i],e);return!e&&t&&(e=Dr(t)),new ti("internal-error",e)}function Ps(t){this.b=t,this.a=null,this.gb=function(t){return(Us||(Us=new Kt((function(t,e){function n(){Or(),wr("gapi.load")("gapi.iframes",{callback:t,ontimeout:function(){Or(),e(Error("Network Error"))},timeout:Ls.get()})}if(wr("gapi.iframes.Iframe"))t();else if(wr("gapi.load"))n();else{var r="__iframefcb"+Math.floor(1e6*Math.random()).toString();u[r]=function(){wr("gapi.load")?n():e(Error("Network Error"))},$t(Da(r=at(Ms,{onload:r}))).s((function(){e(Error("Network Error"))}))}})).s((function(t){throw Us=null,t})))).then((function(){return new Kt((function(e,n){wr("gapi.iframes.getContext")().open({where:document.body,url:t.b,messageHandlersFilter:wr("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"))}),Fs.get());r.ping(i).then(i,(function(){n(Error("Network Error"))}))}))}))}))}(this)}var Ms=new $(nt,"https://apis.google.com/js/api.js?onload=%{onload}"),Ls=new xr(3e4,6e4),Fs=new xr(5e3,15e3),Us=null;function qs(t,e,n){this.i=t,this.g=e,this.h=n,this.f=null,this.a=Dn(this.i,"/__/auth/iframe"),Cn(this.a,"apiKey",this.g),Cn(this.a,"appName",this.h),this.b=null,this.c=[]}function Vs(t,e,n,r,i){this.o=t,this.m=e,this.c=n,this.u=r,this.i=this.g=this.l=null,this.a=i,this.h=this.f=null}function Bs(t){try{return r.a.app(t).auth().Ca()}catch(e){return[]}}function js(t,e,n,r,i){this.u=t,this.f=e,this.b=n,this.c=r||null,this.h=i||null,this.m=this.o=this.v=null,this.g=[],this.l=this.a=null}function zs(t){var e=nr();return function(t){return Rs(t,ys,{}).then((function(t){return t.authorizedDomains||[]}))}(t).then((function(t){t:{var n=In(e),r=n.f;n=n.b;for(var i=0;i<t.length;i++){var o=t[i],a=n,s=r;if(0==o.indexOf("chrome-extension://")?a=In(o).b==a&&"chrome-extension"==s:"http"!=s&&"https"!=s?a=!1:sr.test(o)?a=a==o:(o=o.split(".").join("\\."),a=new RegExp("^(.+\\."+o+"|"+o+")$","i").test(a)),a){t=!0;break t}}t=!1}if(!t)throw new ko(nr())}))}function Ws(t){return t.l?t.l:(t.l=cr().then((function(){if(!t.o){var e=t.c,n=t.h,r=Bs(t.b),i=new qs(t.u,t.f,t.b);i.f=e,i.b=n,i.c=H(r||[]),t.o=i.toString()}t.i=new Ps(t.o),function(t){if(!t.i)throw Error("IfcHandler must be initialized!");!function(t,e){t.gb.then((function(){t.a.register("authEvent",e,wr("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"))}))}(t.i,(function(e){var n={};if(e&&e.authEvent){var r=!1;for(e=Io(e.authEvent),n=0;n<t.g.length;n++)r=t.g[n](e)||r;return(n={}).status=r?"ACK":"ERROR",$t(n)}return n.status="ERROR",$t(n)}))}(t)})),t.l)}function Qs(t){return t.m||(t.v=t.c?_r(t.c,Bs(t.b)):null,t.m=new Pa(t.f,Oi(t.h),t.v)),t.m}function Ks(t,e,n,r,i,o,a,s,u,c,h){return(t=new Vs(t,e,n,r,i)).l=o,t.g=a,t.i=s,t.b=X(u||null),t.f=c,t.nb(h).toString()}function Hs(t){if(this.a=t||r.a.INTERNAL.reactNative&&r.a.INTERNAL.reactNative.AsyncStorage,!this.a)throw new ti("internal-error","The React Native compatibility library was not found.");this.type="asyncStorage"}function Gs(t){this.b=t,this.a={},this.f=C(this.c,this)}qs.prototype.toString=function(){return this.f?Cn(this.a,"v",this.f):qn(this.a.a,"v"),this.b?Cn(this.a,"eid",this.b):qn(this.a.a,"eid"),this.c.length?Cn(this.a,"fw",this.c.join(",")):qn(this.a.a,"fw"),this.a.toString()},Vs.prototype.nb=function(t){return this.h=t,this},Vs.prototype.toString=function(){var t=Dn(this.o,"/__/auth/handler");if(Cn(t,"apiKey",this.m),Cn(t,"appName",this.c),Cn(t,"authType",this.u),this.a.isOAuthProvider){var e=this.a;try{var n=r.a.app(this.c).auth().ha()}catch(u){n=null}for(var i in e.bb=n,Cn(t,"providerId",this.a.providerId),n=Nr((e=this.a).zb))n[i]=n[i].toString();i=e.Fc,n=X(n);for(var o=0;o<i.length;o++){var a=i[o];a in n&&delete n[a]}e.eb&&e.bb&&!n[e.eb]&&(n[e.eb]=e.bb),Y(n)||Cn(t,"customParameters",Dr(n))}if("function"==typeof this.a.Hb&&((e=this.a.Hb()).length&&Cn(t,"scopes",e.join(","))),this.l?Cn(t,"redirectUrl",this.l):qn(t.a,"redirectUrl"),this.g?Cn(t,"eventId",this.g):qn(t.a,"eventId"),this.i?Cn(t,"v",this.i):qn(t.a,"v"),this.b)for(var s in this.b)this.b.hasOwnProperty(s)&&!Sn(t,s)&&Cn(t,s,this.b[s]);return this.h?Cn(t,"tid",this.h):qn(t.a,"tid"),this.f?Cn(t,"eid",this.f):qn(t.a,"eid"),(s=Bs(this.c)).length&&Cn(t,"fw",s.join(",")),t.toString()},(e=js.prototype).Fb=function(t,e,n){var r=new ti("popup-closed-by-user"),i=new ti("web-storage-unsupported"),o=this,a=!1;return this.ia().then((function(){(function(t){var e={type:"webStorageSupport"};return Ws(t).then((function(){return function(t,e){return t.gb.then((function(){return new Kt((function(n){t.a.send(e.type,e,n,wr("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&&or(t),e(i),a=!0)}))})).s((function(){})).then((function(){if(!a)return function(t){return new Kt((function(e){return function n(){pn(2e3).then((function(){if(t&&!t.closed)return n();e()}))}()}))}(t)})).then((function(){if(!a)return pn(n).then((function(){e(r)}))}))},e.Ob=function(){var t=br();return!Ir(t)&&!Rr(t)},e.Jb=function(){return!1},e.Db=function(t,e,n,r,i,o,a,s){if(!t)return te(new ti("popup-blocked"));if(a&&!Ir())return this.ia().s((function(e){or(t),i(e)})),r(),$t();this.a||(this.a=zs(Qs(this)));var u=this;return this.a.then((function(){var e=u.ia().s((function(e){throw or(t),i(e),e}));return r(),e})).then((function(){(Co(n),a)||rr(Ks(u.u,u.f,u.b,e,n,null,o,u.c,void 0,u.h,s),t)})).s((function(t){throw"auth/network-request-failed"==t.code&&(u.a=null),t}))},e.Eb=function(t,e,n,r){this.a||(this.a=zs(Qs(this)));var i=this;return this.a.then((function(){Co(e),rr(Ks(i.u,i.f,i.b,t,e,nr(),n,i.c,void 0,i.h,r))})).s((function(t){throw"auth/network-request-failed"==t.code&&(i.a=null),t}))},e.ia=function(){var t=this;return Ws(this).then((function(){return t.i.gb})).s((function(){throw t.a=null,new ti("network-request-failed")}))},e.Rb=function(){return!0},e.Aa=function(t){this.g.push(t)},e.Na=function(t){Q(this.g,(function(e){return e==t}))},(e=Hs.prototype).get=function(t){return $t(this.a.getItem(t)).then((function(t){return t&&Ar(t)}))},e.set=function(t,e){return $t(this.a.setItem(t,Dr(e)))},e.S=function(t){return $t(this.a.removeItem(t))},e.$=function(){},e.ea=function(){};var Ys,Xs=[];function Js(t,e,n){Y(t.a)&&t.b.addEventListener("message",t.f),void 0===t.a[e]&&(t.a[e]=[]),t.a[e].push(n)}function Zs(t){this.a=t}function $s(t){this.c=t,this.b=!1,this.a=[]}function tu(t,e,n,r){var i,o,a,s,u=n||{},c=null;if(t.b)return te(Error("connection_unavailable"));var h=r?800:50,l="undefined"!=typeof MessageChannel?new MessageChannel:null;return new Kt((function(n,r){l?(i=Math.floor(Math.random()*Math.pow(10,20)).toString(),l.port1.start(),a=setTimeout((function(){r(Error("unsupported_event"))}),h),c={messageChannel:l,onMessage:o=function(t){t.data.eventId===i&&("ack"===t.data.status?(clearTimeout(a),s=setTimeout((function(){r(Error("timeout"))}),3e3)):"done"===t.data.status?(clearTimeout(s),void 0!==t.data.response?n(t.data.response):r(Error("unknown_error"))):(clearTimeout(a),clearTimeout(s),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 eu(t,c),e})).s((function(e){throw eu(t,c),e}))}function eu(t,e){if(e){var n=e.messageChannel,r=e.onMessage;n&&(n.port1.removeEventListener("message",r),n.port1.close()),Q(t.a,(function(t){return t==e}))}}function nu(){if(!ou())throw new ti("web-storage-unsupported");this.c={},this.a=[],this.b=0,this.u=u.indexedDB,this.type="indexedDB",this.g=this.l=this.f=this.i=null,this.o=!1,this.h=null;var t=this;fr()&&self?(this.l=function(){var t=fr()?self:null;if(V(Xs,(function(n){n.b==t&&(e=n)})),!e){var e=new Gs(t);Xs.push(e)}return e}(),Js(this.l,"keyChanged",(function(e,n){return hu(t).then((function(e){return 0<e.length&&V(t.a,(function(t){t(e)})),{keyProcessed:z(e,n.key)}}))})),Js(this.l,"ping",(function(){return $t(["keyChanged"])}))):function(){var t=u.navigator;return t&&t.serviceWorker?$t().then((function(){return t.serviceWorker.ready})).then((function(t){return t.active||null})).s((function(){return null})):$t(null)}().then((function(e){(t.h=e)&&(t.g=new $s(new Zs(e)),tu(t.g,"ping",null,!0).then((function(e){e[0].fulfilled&&z(e[0].value,"keyChanged")&&(t.o=!0)})).s((function(){})))}))}function ru(t){return new Kt((function(e,n){var r=t.u.open("firebaseLocalStorageDb",1);r.onerror=function(t){try{t.preventDefault()}catch(e){}n(Error(t.target.error))},r.onupgradeneeded=function(t){t=t.target.result;try{t.createObjectStore("firebaseLocalStorage",{keyPath:"fbase_key"})}catch(e){n(e)}},r.onsuccess=function(r){(r=r.target.result).objectStoreNames.contains("firebaseLocalStorage")?e(r):function(t){return new Kt((function(e,n){var r=t.u.deleteDatabase("firebaseLocalStorageDb");r.onsuccess=function(){e()},r.onerror=function(t){n(Error(t.target.error))}}))}(t).then((function(){return ru(t)})).then((function(t){e(t)})).s((function(t){n(t)}))}}))}function iu(t){return t.m||(t.m=ru(t)),t.m}function ou(){try{return!!u.indexedDB}catch(_e){return!1}}function au(t){return t.objectStore("firebaseLocalStorage")}function su(t,e){return t.transaction(["firebaseLocalStorage"],e?"readwrite":"readonly")}function uu(t){return new Kt((function(e,n){t.onsuccess=function(t){t&&t.target?e(t.target.result):e()},t.onerror=function(t){n(t.target.error)}}))}function cu(t,e){return t.g&&t.h&&function(){var t=u.navigator;return t&&t.serviceWorker&&t.serviceWorker.controller||null}()===t.h?tu(t.g,"keyChanged",{key:e},t.o).then((function(){})).s((function(){})):$t()}function hu(t){return iu(t).then((function(t){var e=au(su(t,!1));return e.getAll?uu(e.getAll()):new Kt((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 lu(t){t.i&&t.i.cancel("STOP_EVENT"),t.f&&(clearTimeout(t.f),t.f=null)}function fu(t){var e=this,n=null;this.a=[],this.type="indexedDB",this.c=t,this.b=$t().then((function(){if(ou()){var t=kr(),r="__sak"+t;return Ys||(Ys=new nu),(n=Ys).set(r,t).then((function(){return n.get(r)})).then((function(e){if(e!==t)throw Error("indexedDB not supported!");return n.S(r)})).then((function(){return n})).s((function(){return e.c}))}return e.c})).then((function(t){return e.type=t.type,t.$((function(t){V(e.a,(function(e){e(t)}))})),t}))}function pu(){this.a={},this.type="inMemory"}function du(){if(!function(){var t="Node"==pr();if(!(t=mu()||t&&r.a.INTERNAL.node&&r.a.INTERNAL.node.localStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(e){return!1}}()){if("Node"==pr())throw new ti("internal-error","The LocalStorage compatibility library was not found.");throw new ti("web-storage-unsupported")}this.a=mu()||r.a.INTERNAL.node.localStorage,this.type="localStorage"}function mu(){try{var t=u.localStorage,e=kr();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(n){return null}}function yu(){this.type="nullStorage"}function gu(){if(!function(){var t="Node"==pr();if(!(t=vu()||t&&r.a.INTERNAL.node&&r.a.INTERNAL.node.sessionStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(e){return!1}}()){if("Node"==pr())throw new ti("internal-error","The SessionStorage compatibility library was not found.");throw new ti("web-storage-unsupported")}this.a=vu()||r.a.INTERNAL.node.sessionStorage,this.type="sessionStorage"}function vu(){try{var t=u.sessionStorage,e=kr();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(n){return null}}function _u(){var t={};t.Browser=Eu,t.Node=Tu,t.ReactNative=Cu,t.Worker=Su,this.a=t[pr()]}Gs.prototype.c=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=[];V(r,(function(e){i.push($t().then((function(){return e(t.origin,t.data.data)})))})),ne(i).then((function(r){var i=[];V(r,(function(t){i.push({fulfilled:t.Gb,value:t.value,reason:t.reason?t.reason.message:void 0})})),V(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})}))}},Zs.prototype.postMessage=function(t,e){this.a.postMessage(t,e)},$s.prototype.close=function(){for(;0<this.a.length;)eu(this,this.a[0]);this.b=!0},(e=nu.prototype).set=function(t,e){var n,r=!1,i=this;return iu(this).then((function(e){return uu((e=au(su(n=e,!0))).get(t))})).then((function(o){var a=au(su(n,!0));return o?(o.value=e,uu(a.put(o))):(i.b++,r=!0,(o={}).fbase_key=t,o.value=e,uu(a.add(o)))})).then((function(){return i.c[t]=e,cu(i,t)})).ka((function(){r&&i.b--}))},e.get=function(t){return iu(this).then((function(e){return uu(au(su(e,!1)).get(t))})).then((function(t){return t&&t.value}))},e.S=function(t){var e=!1,n=this;return iu(this).then((function(r){return e=!0,n.b++,uu(au(su(r,!0)).delete(t))})).then((function(){return delete n.c[t],cu(n,t)})).ka((function(){e&&n.b--}))},e.$=function(t){0==this.a.length&&function(t){lu(t),function e(){t.f=setTimeout((function(){t.i=hu(t).then((function(e){0<e.length&&V(t.a,(function(t){t(e)}))})).then((function(){e()})).s((function(t){"STOP_EVENT"!=t.message&&e()}))}),800)}()}(this),this.a.push(t)},e.ea=function(t){Q(this.a,(function(e){return e==t})),0==this.a.length&&lu(this)},(e=fu.prototype).get=function(t){return this.b.then((function(e){return e.get(t)}))},e.set=function(t,e){return this.b.then((function(n){return n.set(t,e)}))},e.S=function(t){return this.b.then((function(e){return e.S(t)}))},e.$=function(t){this.a.push(t)},e.ea=function(t){Q(this.a,(function(e){return e==t}))},(e=pu.prototype).get=function(t){return $t(this.a[t])},e.set=function(t,e){return this.a[t]=e,$t()},e.S=function(t){return delete this.a[t],$t()},e.$=function(){},e.ea=function(){},(e=du.prototype).get=function(t){var e=this;return $t().then((function(){return Ar(e.a.getItem(t))}))},e.set=function(t,e){var n=this;return $t().then((function(){var r=Dr(e);null===r?n.S(t):n.a.setItem(t,r)}))},e.S=function(t){var e=this;return $t().then((function(){e.a.removeItem(t)}))},e.$=function(t){u.window&&Ye(u.window,"storage",t)},e.ea=function(t){u.window&&Ze(u.window,"storage",t)},(e=yu.prototype).get=function(){return $t(null)},e.set=function(){return $t()},e.S=function(){return $t()},e.$=function(){},e.ea=function(){},(e=gu.prototype).get=function(t){var e=this;return $t().then((function(){return Ar(e.a.getItem(t))}))},e.set=function(t,e){var n=this;return $t().then((function(){var r=Dr(e);null===r?n.S(t):n.a.setItem(t,r)}))},e.S=function(t){var e=this;return $t().then((function(){e.a.removeItem(t)}))},e.$=function(){},e.ea=function(){};var bu,wu,Eu={C:du,Ta:gu},Tu={C:du,Ta:gu},Cu={C:Hs,Ta:yu},Su={C:du,Ta:yu},Iu={ad:"local",NONE:"none",cd:"session"};function Du(){var t=!(Rr(br())||!lr()),e=Ir(),n=Er();this.m=t,this.h=e,this.l=n,this.a={},bu||(bu=new _u),t=bu;try{this.g=!er()&&Lr()||!u.indexedDB?new t.a.C:new fu(fr()?new pu:new t.a.C)}catch(r){this.g=new pu,this.h=!0}try{this.i=new t.a.Ta}catch(r){this.i=new pu}this.u=new pu,this.f=C(this.Pb,this),this.b={}}function Nu(){return wu||(wu=new Du),wu}function Au(t,e){switch(e){case"session":return t.i;case"none":return t.u;default:return t.g}}function ku(t,e){return"firebase:"+t.name+(e?":"+e:"")}function Ru(t,e,n){return n=ku(e,n),"local"==e.C&&(t.b[n]=null),Au(t,e.C).S(n)}function Ou(t){t.c&&(clearInterval(t.c),t.c=null)}function xu(t){this.a=t,this.b=Nu()}(e=Du.prototype).get=function(t,e){return Au(this,t.C).get(ku(t,e))},e.set=function(t,e,n){var r=ku(t,n),i=this,o=Au(this,t.C);return o.set(r,e).then((function(){return o.get(r)})).then((function(e){"local"==t.C&&(i.b[r]=e)}))},e.addListener=function(t,e,n){t=ku(t,e),this.l&&(this.b[t]=u.localStorage.getItem(t)),Y(this.a)&&(Au(this,"local").$(this.f),this.h||(er()||!Lr())&&u.indexedDB||!this.l||function(t){Ou(t),t.c=setInterval((function(){for(var e in t.a){var n=u.localStorage.getItem(e),r=t.b[e];n!=r&&(t.b[e]=n,n=new Ue({type:"storage",key:e,target:window,oldValue:r,newValue:n,a:!0}),t.Pb(n))}}),1e3)}(this)),this.a[t]||(this.a[t]=[]),this.a[t].push(n)},e.removeListener=function(t,e,n){t=ku(t,e),this.a[t]&&(Q(this.a[t],(function(t){return t==n})),0==this.a[t].length&&delete this.a[t]),Y(this.a)&&(Au(this,"local").ea(this.f),Ou(this))},e.Pb=function(t){if(t&&t.f){var e=t.a.key;if(null==e)for(var n in this.a){var r=this.b[n];void 0===r&&(r=null);var i=u.localStorage.getItem(n);i!==r&&(this.b[n]=i,this.$a(n))}else if(0==e.indexOf("firebase:")&&this.a[e]){if(void 0!==t.a.a?Au(this,"local").ea(this.f):Ou(this),this.m)if(n=u.localStorage.getItem(e),(r=t.a.newValue)!==n)null!==r?u.localStorage.setItem(e,r):u.localStorage.removeItem(e);else if(this.b[e]===r&&void 0===t.a.a)return;var o=this;n=function(){void 0===t.a.a&&o.b[e]===u.localStorage.getItem(e)||(o.b[e]=u.localStorage.getItem(e),o.$a(e))},we&&ke&&10==ke&&u.localStorage.getItem(e)!==t.a.newValue&&t.a.newValue!==t.a.oldValue?setTimeout(n,10):n()}}else V(t,C(this.$a,this))},e.$a=function(t){this.a[t]&&V(this.a[t],(function(t){t()}))};var Pu,Mu={name:"authEvent",C:"local"};function Lu(){this.a=Nu()}function Fu(t,e){this.b=Uu,this.f=u.Uint8Array?new Uint8Array(this.b):Array(this.b),this.g=this.c=0,this.a=[],this.i=t,this.h=e,this.l=u.Int32Array?new Int32Array(64):Array(64),void 0!==Pu||(Pu=u.Int32Array?new Int32Array(Qu):Qu),this.reset()}D(Fu,(function(){this.b=-1}));for(var Uu=64,qu=Uu-1,Vu=[],Bu=0;Bu<qu;Bu++)Vu[Bu]=0;var ju=K(128,Vu);function zu(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,a=(0|n[e-7])+((r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10)|0;n[e]=o+a|0}r=0|t.a[0],i=0|t.a[1];var s=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&s^i&s)|0;a=(o=o+((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))|0)+((a=(a=c&h^~c&l)+(0|Pu[e])|0)+(0|n[e])|0)|0,o=l,l=h,h=c,c=u+a|0,u=s,s=i,i=r,r=a+f|0}t.a[0]=t.a[0]+r|0,t.a[1]=t.a[1]+i|0,t.a[2]=t.a[2]+s|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 Wu(t,e,n){void 0===n&&(n=e.length);var r=0,i=t.c;if(c(e))for(;r<n;)t.f[i++]=e.charCodeAt(r++),i==t.b&&(zu(t),i=0);else{if(!g(e))throw Error("message must be string or array");for(;r<n;){var o=e[r++];if(!("number"==typeof o&&0<=o&&255>=o&&o==(0|o)))throw Error("message must be a byte array");t.f[i++]=o,i==t.b&&(zu(t),i=0)}}t.c=i,t.g+=n}Fu.prototype.reset=function(){this.g=this.c=0,this.a=u.Int32Array?new Int32Array(this.h):H(this.h)};var Qu=[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 Ku(){Fu.call(this,8,Hu)}D(Ku,Fu);var Hu=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function Gu(t,e,n,r,i){this.u=t,this.i=e,this.l=n,this.m=r||null,this.o=i||null,this.h=e+":"+n,this.v=new Lu,this.g=new xu(this.h),this.f=null,this.b=[],this.a=this.c=null}function Yu(t){return new ti("invalid-cordova-configuration",t)}function Xu(t){var e=new Ku;Wu(e,t),t=[];var n=8*e.g;56>e.c?Wu(e,ju,56-e.c):Wu(e,ju,e.b-(e.c-56));for(var r=63;56<=r;r--)e.f[r]=255&n,n/=256;for(zu(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 B(t,(function(t){return 1<(t=t.toString(16)).length?t:"0"+t})).join("")}(t)}function Ju(t,e){for(var n=0;n<t.b.length;n++)try{t.b[n](e)}catch(r){}}function Zu(t){return t.f||(t.f=t.ia().then((function(){return new Kt((function(e){t.Aa((function n(r){return e(r),t.Na(n),!1})),function(t){function e(e){r=!0,i&&i.cancel(),$u(t).then((function(r){var i=n;if(r&&e&&e.url){var o=null;-1!=(i=Ki(e.url)).indexOf("/__/auth/callback")&&(o=(o="object"==typeof(o=Ar(Sn(o=In(i),"firebaseError")||null))?ei(o):null)?new So(r.c,r.b,null,null,o,null,r.R()):new So(r.c,r.b,i,r.f,null,null,r.R())),i=o||n}Ju(t,i)}))}var n=new So("unknown",null,null,null,new ti("no-auth-event")),r=!1,i=pn(500).then((function(){return $u(t).then((function(){r||Ju(t,n)}))})),o=u.handleOpenURL;u.handleOpenURL=function(t){if(0==t.toLowerCase().indexOf(wr("BuildInfo.packageName",u).toLowerCase()+"://")&&e({url:t}),"function"==typeof o)try{o(t)}catch(n){console.error(n)}},Ao||(Ao=new Do),function(t){var e=Ao;e.a.push(t),e.b||(e.b=function(t){for(var n=0;n<e.a.length;n++)e.a[n](t)},"function"==typeof(t=wr("universalLinks.subscribe",u))&&t(null,e.b))}(e)}(t)}))}))),t.f}function $u(t){var e=null;return function(t){return t.b.get(Mu,t.a).then((function(t){return Io(t)}))}(t.g).then((function(n){return e=n,Ru((n=t.g).b,Mu,n.a)})).then((function(){return e}))}function tc(t){this.a=t,this.b=Nu()}(e=Gu.prototype).ia=function(){return this.Da?this.Da:this.Da=(hr(void 0)?cr().then((function(){return new Kt((function(t,e){var n=u.document,r=setTimeout((function(){e(Error("Cordova framework is not ready."))}),1e3);n.addEventListener("deviceready",(function(){clearTimeout(r),t()}),!1)}))})):te(Error("Cordova must run in an Android or iOS file scheme."))).then((function(){if("function"!=typeof wr("universalLinks.subscribe",u))throw Yu("cordova-universal-links-plugin-fix is not installed");if(void 0===wr("BuildInfo.packageName",u))throw Yu("cordova-plugin-buildinfo is not installed");if("function"!=typeof wr("cordova.plugins.browsertab.openUrl",u))throw Yu("cordova-plugin-browsertab is not installed");if("function"!=typeof wr("cordova.InAppBrowser.open",u))throw Yu("cordova-plugin-inappbrowser is not installed")}),(function(){throw new ti("cordova-not-ready")}))},e.Fb=function(t,e){return e(new ti("operation-not-supported-in-this-environment")),$t()},e.Db=function(){return te(new ti("operation-not-supported-in-this-environment"))},e.Rb=function(){return!1},e.Ob=function(){return!0},e.Jb=function(){return!0},e.Eb=function(t,e,n,r){if(this.c)return te(new ti("redirect-operation-pending"));var i=this,o=u.document,a=null,s=null,c=null,h=null;return this.c=$t().then((function(){return Co(e),Zu(i)})).then((function(){return function(t,e,n,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("")}(),a=new So(e,r,null,o,new ti("no-auth-event"),null,i),s=wr("BuildInfo.packageName",u);if("string"!=typeof s)throw new ti("invalid-cordova-configuration");var c=wr("BuildInfo.displayName",u),h={};if(br().toLowerCase().match(/iphone|ipad|ipod/))h.ibi=s;else{if(!br().toLowerCase().match(/android/))return te(new ti("operation-not-supported-in-this-environment"));h.apn=s}c&&(h.appDisplayName=c),o=Xu(o),h.sessionId=o;var l=Ks(t.u,t.i,t.l,e,n,null,r,t.m,h,t.o,i);return t.ia().then((function(){var e=t.h;return t.v.a.set(Mu,a.A(),e)})).then((function(){var e=wr("cordova.plugins.browsertab.isAvailable",u);if("function"!=typeof e)throw new ti("invalid-cordova-configuration");var n=null;e((function(e){if(e){if("function"!=typeof(n=wr("cordova.plugins.browsertab.openUrl",u)))throw new ti("invalid-cordova-configuration");n(l)}else{if("function"!=typeof(n=wr("cordova.InAppBrowser.open",u)))throw new ti("invalid-cordova-configuration");e=br(),t.a=n(l,e.match(/(iPad|iPhone|iPod).*OS 7_\d/i)||e.match(/(iPad|iPhone|iPod).*OS 8_\d/i)?"_blank":"_system","location=yes")}}))}))}(i,t,e,n,r)})).then((function(){return new Kt((function(t,e){s=function(){var e=wr("cordova.plugins.browsertab.close",u);return t(),"function"==typeof e&&e(),i.a&&"function"==typeof i.a.close&&(i.a.close(),i.a=null),!1},i.Aa(s),c=function(){a||(a=pn(2e3).then((function(){e(new ti("redirect-cancelled-by-user"))})))},h=function(){Pr()&&c()},o.addEventListener("resume",c,!1),br().toLowerCase().match(/android/)||o.addEventListener("visibilitychange",h,!1)})).s((function(t){return $u(i).then((function(){throw t}))}))})).ka((function(){c&&o.removeEventListener("resume",c,!1),h&&o.removeEventListener("visibilitychange",h,!1),a&&a.cancel(),s&&i.Na(s),i.c=null}))},e.Aa=function(t){this.b.push(t),Zu(this).s((function(e){"auth/invalid-cordova-configuration"===e.code&&(e=new So("unknown",null,null,null,new ti("no-auth-event")),t(e))}))},e.Na=function(t){Q(this.b,(function(e){return e==t}))};var ec={name:"pendingRedirect",C:"session"};function nc(t){return Ru(t.b,ec,t.a)}function rc(t,e,n){this.i={},this.v=0,this.B=t,this.u=e,this.m=n,this.h=[],this.f=!1,this.l=C(this.o,this),this.b=new gc,this.w=new Ec,this.g=new tc(this.u+":"+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.w,this.c.linkViaPopup=this.w,this.c.reauthViaPopup=this.w,this.a=ic(this.B,this.u,this.m,ki)}function ic(t,e,n,i){var o=r.a.SDK_VERSION||null;return hr()?new Gu(t,e,n,o,i):new js(t,e,n,o,i)}function oc(t){t.f||(t.f=!0,t.a.Aa(t.l));var e=t.a;return t.a.ia().s((function(n){throw t.a==e&&t.reset(),n}))}function ac(t){t.a.Ob()&&oc(t).s((function(e){var n=new So("unknown",null,null,null,new ti("operation-not-supported-in-this-environment"));fc(e)&&t.o(n)})),t.a.Jb()||vc(t.b)}function sc(t,e){z(t.h,e)||t.h.push(e),t.f||function(t){return t.b.get(ec,t.a).then((function(t){return"pending"==t}))}(t.g).then((function(e){e?nc(t.g).then((function(){oc(t).s((function(e){var n=new So("unknown",null,null,null,new ti("operation-not-supported-in-this-environment"));fc(e)&&t.o(n)}))})):ac(t)})).s((function(){ac(t)}))}function uc(t,e){Q(t.h,(function(t){return t==e}))}rc.prototype.reset=function(){this.f=!1,this.a.Na(this.l),this.a=ic(this.B,this.u,this.m),this.i={}},rc.prototype.o=function(t){if(!t)throw new ti("invalid-auth-event");if(6e5<=I()-this.v&&(this.i={},this.v=0),t&&t.getUid()&&this.i.hasOwnProperty(t.getUid()))return!1;for(var e=!1,n=0;n<this.h.length;n++){var r=this.h[n];if(r.xb(t.c,t.b)){(e=this.c[t.c])&&(e.h(t,r),t&&(t.f||t.b)&&(this.i[t.getUid()]=!0,this.v=I())),e=!0;break}}return vc(this.b),e};var cc=new xr(2e3,1e4),hc=new xr(3e4,6e4);function lc(t,e,n,r,i,o,a){return t.a.Db(e,n,r,(function(){t.f||(t.f=!0,t.a.Aa(t.l))}),(function(){t.reset()}),i,o,a)}function fc(t){return!(!t||"auth/cordova-not-ready"!=t.code)}function pc(t,e,n,r,i){var o;return function(t){return t.b.set(ec,"pending",t.a)}(t.g).then((function(){return t.a.Eb(e,n,r,i).s((function(e){if(fc(e))throw new ti("operation-not-supported-in-this-environment");return o=e,nc(t.g).then((function(){throw o}))})).then((function(){return t.a.Rb()?new Kt((function(){})):nc(t.g).then((function(){return t.oa()})).then((function(){})).s((function(){}))}))}))}function dc(t,e,n,r,i){return t.a.Fb(r,(function(t){e.ja(n,null,t,i)}),cc.get())}rc.prototype.oa=function(){return this.b.oa()};var mc={};function yc(t,e,n){var r=e+":"+n;return mc[r]||(mc[r]=new rc(t,e,n)),mc[r]}function gc(){this.b=null,this.f=[],this.c=[],this.a=null,this.i=this.g=!1}function vc(t){t.g||(t.g=!0,wc(t,!1,null,null))}function _c(t){t.g&&!t.i&&wc(t,!1,null,null)}function bc(t,e){if(t.b=function(){return $t(e)},t.f.length)for(var n=0;n<t.f.length;n++)t.f[n](e)}function wc(t,e,n,r){e?r?function(t,e){if(t.b=function(){return te(e)},t.c.length)for(var n=0;n<t.c.length;n++)t.c[n](e)}(t,r):bc(t,n):bc(t,{user:null}),t.f=[],t.c=[]}function Ec(){}function Tc(){this.vb=!1,Object.defineProperty(this,"appVerificationDisabled",{get:function(){return this.vb},set:function(t){this.vb=t},enumerable:!1})}function Cc(t,e){this.a=e,Br(this,"verificationId",t)}function Sc(t,e,n,r){return new wo(t).Wa(e,n).then((function(t){return new Cc(t,r)}))}function Ic(t){var e=Ai(t);if(!(e&&e.exp&&e.auth_time&&e.iat))throw new ti("internal-error","An internal error occurred. The token obtained by Firebase appears to be malformed. Please retry the operation.");jr(this,{token:t,expirationTime:Mr(1e3*e.exp),authTime:Mr(1e3*e.auth_time),issuedAtTime:Mr(1e3*e.iat),signInProvider:e.firebase&&e.firebase.sign_in_provider?e.firebase.sign_in_provider:null,claims:e})}function Dc(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 Nc(t){this.f=t,this.b=this.a=null,this.c=0}function Ac(t,e){var n=e[La],r=e.refreshToken;e=kc(e.expiresIn),t.b=n,t.c=e,t.a=r}function kc(t){return I()+1e3*parseInt(t,10)}function Rc(t,e){return function(t,e){return new Kt((function(n,r){"refresh_token"==e.grant_type&&e.refresh_token||"authorization_code"==e.grant_type&&e.code?za(t,t.l+"?key="+encodeURIComponent(t.c),(function(t){t?t.error?r(xs(t)):t.access_token&&t.refresh_token?n(t):r(new ti("internal-error")):r(new ti("network-request-failed"))}),"POST",Un(e).toString(),t.g,t.u.get()):r(new ti("internal-error"))}))}(t.f,e).then((function(e){return t.b=e.access_token,t.c=kc(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 Oc(t,e){this.a=t||null,this.b=e||null,jr(this,{lastSignInTime:Mr(e||null),creationTime:Mr(t||null)})}function xc(t,e,n,r,i,o){jr(this,{uid:t,displayName:r||null,photoURL:i||null,email:n||null,phoneNumber:o||null,providerId:e})}function Pc(t,e){for(var n in Fe.call(this,t),e)this[n]=e[n]}function Mc(t,e,n){this.I=[],this.l=t.apiKey,this.m=t.appName,this.o=t.authDomain||null,t=r.a.SDK_VERSION?_r(r.a.SDK_VERSION):null,this.a=new Pa(this.l,Oi(ki),t),this.b=new Nc(this.a),jc(this,e[La]),Ac(this.b,e),Br(this,"refreshToken",this.b.a),Qc(this,n||{}),un.call(this),this.J=!1,this.o&&Tr()&&(this.i=yc(this.o,this.l,this.m)),this.O=[],this.h=null,this.w=function(t){return new Dc((function(){return t.G(!0)}),(function(t){return!(!t||"auth/network-request-failed"!=t.code)}),(function(){var e=t.b.c-I()-3e5;return 0<e?e:0}))}(this),this.W=C(this.Ja,this);var i=this;this.ga=null,this.xa=function(t){i.ua(t.g)},this.Z=null,this.P=[],this.wa=function(t){Fc(i,t.c)},this.Y=null}function Lc(t,e){t.Z&&Ze(t.Z,"languageCodeChanged",t.xa),(t.Z=e)&&Ye(e,"languageCodeChanged",t.xa)}function Fc(t,e){t.P=e,ja(t.a,r.a.SDK_VERSION?_r(r.a.SDK_VERSION,t.P):null)}function Uc(t,e){t.Y&&Ze(t.Y,"frameworkChanged",t.wa),(t.Y=e)&&Ye(e,"frameworkChanged",t.wa)}function qc(t){try{return r.a.app(t.m).auth()}catch(e){throw new ti("internal-error","No firebase.auth.Auth instance is available for the Firebase App '"+t.m+"'!")}}function Vc(t){t.B||t.w.b||(t.w.start(),Ze(t,"tokenChanged",t.W),Ye(t,"tokenChanged",t.W))}function Bc(t){Ze(t,"tokenChanged",t.W),t.w.stop()}function jc(t,e){t.ma=e,Br(t,"_lat",e)}function zc(t){for(var e=[],n=0;n<t.O.length;n++)e.push(t.O[n](t));return ne(e).then((function(){return t}))}function Wc(t){t.i&&!t.J&&(t.J=!0,sc(t.i,t))}function Qc(t,e){jr(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,tenantId:e.tenantId||null,metadata:new Oc(e.createdAt,e.lastLoginAt),providerData:[]}),t.a.b=t.tenantId}function Kc(){}function Hc(t){return $t().then((function(){if(t.B)throw new ti("app-deleted")}))}function Gc(t){return B(t.providerData,(function(t){return t.providerId}))}function Yc(t,e){e&&(Xc(t,e.providerId),t.providerData.push(e))}function Xc(t,e){Q(t.providerData,(function(t){return t.providerId==e}))}function Jc(t,e,n){("uid"!=e||n)&&t.hasOwnProperty(e)&&Br(t,e,n)}function Zc(t,e){t!=e&&(jr(t,{uid:e.uid,displayName:e.displayName,photoURL:e.photoURL,email:e.email,emailVerified:e.emailVerified,phoneNumber:e.phoneNumber,isAnonymous:e.isAnonymous,tenantId:e.tenantId,providerData:[]}),e.metadata?Br(t,"metadata",function(t){return new Oc(t.a,t.b)}(e.metadata)):Br(t,"metadata",new Oc),V(e.providerData,(function(e){Yc(t,e)})),function(t,e){t.b=e.b,t.a=e.a,t.c=e.c}(t.b,e.b),Br(t,"refreshToken",t.b.a))}function $c(t){return t.G().then((function(e){var n=t.isAnonymous;return function(t,e){return Rs(t.a,fs,{idToken:e}).then(C(t.zc,t))}(t,e).then((function(){return n||Jc(t,"isAnonymous",!1),e}))}))}function th(t,e){e[La]&&t.ma!=e[La]&&(Ac(t.b,e),t.dispatchEvent(new Pc("tokenChanged")),jc(t,e[La]),Jc(t,"refreshToken",t.b.a))}function eh(t,e){return $c(t).then((function(){if(z(Gc(t),e))return zc(t).then((function(){throw new ti("provider-already-linked")}))}))}function nh(t,e,n){return zr({user:t,credential:To(e),additionalUserInfo:e=Fi(e),operationType:n})}function rh(t,e){return th(t,e),t.reload().then((function(){return t}))}function ih(t,e,n,i,o){if(!Tr())return te(new ti("operation-not-supported-in-this-environment"));if(t.h&&!o)return te(t.h);var a=Li(n.providerId),s=kr(t.uid+":::"),u=null;(!Ir()||lr())&&t.o&&n.isOAuthProvider&&(u=Ks(t.o,t.l,t.m,e,n,null,s,r.a.SDK_VERSION||null,null,null,t.tenantId));var c=ar(u,a&&a.sa,a&&a.ra);return i=i().then((function(){if(ah(t),!o)return t.G().then((function(){}))})).then((function(){return lc(t.i,c,e,n,s,!!u,t.tenantId)})).then((function(){return new Kt((function(n,r){t.ja(e,null,new ti("cancelled-popup-request"),t.g||null),t.f=n,t.v=r,t.g=s,t.c=dc(t.i,t,e,c,s)}))})).then((function(t){return c&&or(c),t?zr(t):null})).s((function(t){throw c&&or(c),t})),sh(t,i,o)}function oh(t,e,n,r,i){if(!Tr())return te(new ti("operation-not-supported-in-this-environment"));if(t.h&&!i)return te(t.h);var o=null,a=kr(t.uid+":::");return r=r().then((function(){if(ah(t),!i)return t.G().then((function(){}))})).then((function(){return t.ca=a,zc(t)})).then((function(e){return t.da&&(e=(e=t.da).b.set(hh,t.A(),e.a)),e})).then((function(){return pc(t.i,e,n,a,t.tenantId)})).s((function(e){if(o=e,t.da)return lh(t.da);throw o})).then((function(){if(o)throw o})),sh(t,r,i)}function ah(t){if(!t.i||!t.J){if(t.i&&!t.J)throw new ti("internal-error");throw new ti("auth-domain-config-required")}}function sh(t,e,n){var r=function(t,e,n){return t.h&&!n?(e.cancel(),te(t.h)):e.s((function(e){throw!e||"auth/user-disabled"!=e.code&&"auth/user-token-expired"!=e.code||(t.h||t.dispatchEvent(new Pc("userInvalidated")),t.h=e),e}))}(t,e,n);return t.I.push(r),r.ka((function(){W(t.I,r)})),r}function uh(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[La]=t.stsTokenManager.accessToken,n.refreshToken=t.stsTokenManager.refreshToken||null,n.expiresIn=(t.stsTokenManager.expirationTime-I())/1e3;var r=new Mc(e,n,t);return t.providerData&&V(t.providerData,(function(t){t&&Yc(r,zr(t))})),t.redirectEventId&&(r.ca=t.redirectEventId),r}function ch(t){this.a=t,this.b=Nu()}gc.prototype.reset=function(){this.b=null,this.a&&(this.a.cancel(),this.a=null)},gc.prototype.h=function(t,e){if(t){this.reset(),this.g=!0;var n=t.c,r=t.b,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?(wc(this,!0,null,t.a),$t()):e.Ba(n,r)?function(t,e,n){n=n.Ba(e.c,e.b);var r=e.g,i=e.f,o=e.i,a=e.R(),s=!!e.c.match(/Redirect$/);n(r,i,a,o).then((function(e){wc(t,s,e,null)})).s((function(e){wc(t,s,null,e)}))}(this,t,e):te(new ti("invalid-auth-event")):(wc(this,!1,null,null),$t())}else te(new ti("invalid-auth-event"))},gc.prototype.oa=function(){var t=this;return new Kt((function(e,n){t.b?t.b().then(e,n):(t.f.push(e),t.c.push(n),function(t){var e=new ti("timeout");t.a&&t.a.cancel(),t.a=pn(hc.get()).then((function(){t.b||(t.g=!0,wc(t,!0,null,e))}))}(t))}))},Ec.prototype.h=function(t,e){if(t){var n=t.c,r=t.b;t.a?(e.ja(t.c,null,t.a,t.b),$t()):e.Ba(n,r)?function(t,e){var n=t.b,r=t.c;e.Ba(r,n)(t.g,t.f,t.R(),t.i).then((function(t){e.ja(r,t,null,n)})).s((function(t){e.ja(r,null,t,n)}))}(t,e):te(new ti("invalid-auth-event"))}else te(new ti("invalid-auth-event"))},Cc.prototype.confirm=function(t){return t=Eo(this.verificationId,t),this.a(t)},Dc.prototype.start=function(){this.a=this.c,function t(e,n){e.stop(),e.b=pn(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,n)).then((function(){return function(){var t=u.document,e=null;return Pr()||!t?$t():new Kt((function(n){e=function(){Pr()&&(t.removeEventListener("visibilitychange",e,!1),n())},t.addEventListener("visibilitychange",e,!1)})).s((function(n){throw t.removeEventListener("visibilitychange",e,!1),n}))}()})).then((function(){return e.h()})).then((function(){t(e,!0)})).s((function(n){e.i(n)&&t(e,!1)}))}(this,!0)},Dc.prototype.stop=function(){this.b&&(this.b.cancel(),this.b=null)},Nc.prototype.A=function(){return{apiKey:this.f.c,refreshToken:this.a,accessToken:this.b,expirationTime:this.c}},Nc.prototype.getToken=function(t){return t=!!t,this.b&&!this.a?te(new ti("user-token-expired")):t||!this.b||I()>this.c-3e4?this.a?Rc(this,{grant_type:"refresh_token",refresh_token:this.a}):$t(null):$t({accessToken:this.b,expirationTime:this.c,refreshToken:this.a})},Oc.prototype.A=function(){return{lastLoginAt:this.b,createdAt:this.a}},D(Pc,Fe),D(Mc,un),Mc.prototype.ua=function(t){this.ga=t,Ba(this.a,t)},Mc.prototype.ha=function(){return this.ga},Mc.prototype.Ca=function(){return H(this.P)},Mc.prototype.Ja=function(){this.w.b&&(this.w.stop(),this.w.start())},Br(Mc.prototype,"providerId","firebase"),(e=Mc.prototype).reload=function(){var t=this;return sh(this,Hc(this).then((function(){return $c(t).then((function(){return zc(t)})).then(Kc)})))},e.dc=function(t){return this.G(t).then((function(t){return new Ic(t)}))},e.G=function(t){var e=this;return sh(this,Hc(this).then((function(){return e.b.getToken(t)})).then((function(t){if(!t)throw new ti("internal-error");return t.accessToken!=e.ma&&(jc(e,t.accessToken),e.dispatchEvent(new Pc("tokenChanged"))),Jc(e,"refreshToken",t.refreshToken),t.accessToken})))},e.zc=function(t){if(!(t=t.users)||!t.length)throw new ti("internal-error");Qc(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,tenantId:t.tenantId});for(var e=function(t){return(t=t.providerUserInfo)&&t.length?B(t,(function(t){return new xc(t.rawId,t.providerId,t.email,t.displayName,t.photoUrl,t.phoneNumber)})):[]}(t),n=0;n<e.length;n++)Yc(this,e[n]);Jc(this,"isAnonymous",!(this.email&&t.passwordHash||this.providerData&&this.providerData.length))},e.Ac=function(t){return qr("firebase.User.prototype.reauthenticateAndRetrieveDataWithCredential is deprecated. Please use firebase.User.prototype.reauthenticateWithCredential instead."),this.hb(t)},e.hb=function(t){var e=this,n=null;return sh(this,t.f(this.a,this.uid).then((function(t){return th(e,t),n=nh(e,t,"reauthenticate"),e.h=null,e.reload()})).then((function(){return n})),!0)},e.rc=function(t){return qr("firebase.User.prototype.linkAndRetrieveDataWithCredential is deprecated. Please use firebase.User.prototype.linkWithCredential instead."),this.fb(t)},e.fb=function(t){var e=this,n=null;return sh(this,eh(this,t.providerId).then((function(){return e.G()})).then((function(n){return t.b(e.a,n)})).then((function(t){return n=nh(e,t,"link"),rh(e,t)})).then((function(){return n})))},e.sc=function(t,e){var n=this;return sh(this,eh(this,"phone").then((function(){return Sc(qc(n),t,e,C(n.fb,n))})))},e.Bc=function(t,e){var n=this;return sh(this,$t().then((function(){return Sc(qc(n),t,e,C(n.hb,n))})),!0)},e.rb=function(t){var e=this;return sh(this,this.G().then((function(n){return e.a.rb(n,t)})).then((function(t){return th(e,t),e.reload()})))},e.Sc=function(t){var e=this;return sh(this,this.G().then((function(n){return t.b(e.a,n)})).then((function(t){return th(e,t),e.reload()})))},e.sb=function(t){var e=this;return sh(this,this.G().then((function(n){return e.a.sb(n,t)})).then((function(t){return th(e,t),e.reload()})))},e.tb=function(t){if(void 0===t.displayName&&void 0===t.photoURL)return Hc(this);var e=this;return sh(this,this.G().then((function(n){return e.a.tb(n,{displayName:t.displayName,photoUrl:t.photoURL})})).then((function(t){return th(e,t),Jc(e,"displayName",t.displayName||null),Jc(e,"photoURL",t.photoUrl||null),V(e.providerData,(function(t){"password"===t.providerId&&(Br(t,"displayName",e.displayName),Br(t,"photoURL",e.photoURL))})),zc(e)})).then(Kc))},e.Qc=function(t){var e=this;return sh(this,$c(this).then((function(n){return z(Gc(e),t)?function(t,e,n){return Rs(t,cs,{idToken:e,deleteProvider:n})}(e.a,n,[t]).then((function(t){var n={};return V(t.providerUserInfo||[],(function(t){n[t.providerId]=!0})),V(Gc(e),(function(t){n[t]||Xc(e,t)})),n[wo.PROVIDER_ID]||Br(e,"phoneNumber",null),zc(e)})):zc(e).then((function(){throw new ti("no-such-provider")}))})))},e.delete=function(){var t=this;return sh(this,this.G().then((function(e){return Rs(t.a,us,{idToken:e})})).then((function(){t.dispatchEvent(new Pc("userDeleted"))}))).then((function(){for(var e=0;e<t.I.length;e++)t.I[e].cancel("app-deleted");Lc(t,null),Uc(t,null),t.I=[],t.B=!0,Bc(t),Br(t,"refreshToken",null),t.i&&uc(t.i,t)}))},e.xb=function(t,e){return!!("linkViaPopup"==t&&(this.g||null)==e&&this.f||"reauthViaPopup"==t&&(this.g||null)==e&&this.f||"linkViaRedirect"==t&&(this.ca||null)==e||"reauthViaRedirect"==t&&(this.ca||null)==e)},e.ja=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)},e.Ba=function(t,e){return"linkViaPopup"==t&&e==(this.g||null)?C(this.Bb,this):"reauthViaPopup"==t&&e==(this.g||null)?C(this.Cb,this):"linkViaRedirect"==t&&(this.ca||null)==e?C(this.Bb,this):"reauthViaRedirect"==t&&(this.ca||null)==e?C(this.Cb,this):null},e.tc=function(t){var e=this;return ih(this,"linkViaPopup",t,(function(){return eh(e,t.providerId).then((function(){return zc(e)}))}),!1)},e.Cc=function(t){return ih(this,"reauthViaPopup",t,(function(){return $t()}),!0)},e.uc=function(t){var e=this;return oh(this,"linkViaRedirect",t,(function(){return eh(e,t.providerId)}),!1)},e.Dc=function(t){return oh(this,"reauthViaRedirect",t,(function(){return $t()}),!0)},e.Bb=function(t,e,n,r){var i=this;this.c&&(this.c.cancel(),this.c=null);var o=null;return sh(this,this.G().then((function(n){return es(i.a,{requestUri:t,postBody:r,sessionId:e,idToken:n})})).then((function(t){return o=nh(i,t,"link"),rh(i,t)})).then((function(){return o})))},e.Cb=function(t,e,n,r){var i=this;this.c&&(this.c.cancel(),this.c=null);var o=null;return sh(this,$t().then((function(){return Gi(ns(i.a,{requestUri:t,sessionId:e,postBody:r,tenantId:n}),i.uid)})).then((function(t){return o=nh(i,t,"reauthenticate"),th(i,t),i.h=null,i.reload()})).then((function(){return o})),!0)},e.jb=function(t){var e=this,n=null;return sh(this,this.G().then((function(e){return n=e,void 0===t||Y(t)?{}:Ti(new pi(t))})).then((function(t){return e.a.jb(n,t)})).then((function(t){if(e.email!=t)return e.reload()})).then((function(){})))},e.toJSON=function(){return this.A()},e.A=function(){var t={uid:this.uid,displayName:this.displayName,photoURL:this.photoURL,email:this.email,emailVerified:this.emailVerified,phoneNumber:this.phoneNumber,isAnonymous:this.isAnonymous,tenantId:this.tenantId,providerData:[],apiKey:this.l,appName:this.m,authDomain:this.o,stsTokenManager:this.b.A(),redirectEventId:this.ca||null};return this.metadata&&Z(t,this.metadata.A()),V(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 hh={name:"redirectUser",C:"session"};function lh(t){return Ru(t.b,hh,t.a)}function fh(t){this.a=t,this.b=Nu(),this.c=null,this.f=function(t){var e=mh("local"),n=mh("session"),r=mh("none");return function(t,e,n){var r=ku(e,n),i=Au(t,e.C);return t.get(e,n).then((function(o){var a=null;try{a=Ar(u.localStorage.getItem(r))}catch(s){}if(a&&!o)return u.localStorage.removeItem(r),t.set(e,a,n);a&&o&&"localStorage"!=i.type&&u.localStorage.removeItem(r)}))}(t.b,e,t.a).then((function(){return t.b.get(n,t.a)})).then((function(i){return i?n:t.b.get(r,t.a).then((function(n){return n?r:t.b.get(e,t.a).then((function(n){return n?e:t.b.get(dh,t.a).then((function(t){return t?mh(t):e}))}))}))})).then((function(e){return t.c=e,ph(t,e.C)})).s((function(){t.c||(t.c=e)}))}(this),this.b.addListener(mh("local"),this.a,C(this.g,this))}function ph(t,e){var n,r=[];for(n in Iu)Iu[n]!==e&&r.push(Ru(t.b,mh(Iu[n]),t.a));return r.push(Ru(t.b,dh,t.a)),function(t){return new Kt((function(e,n){var r=t.length,i=[];if(r)for(var o=function(t,n){r--,i[t]=n,0==r&&e(i)},a=function(t){n(t)},s=0;s<t.length;s++)ee(t[s],S(o,s),a);else e(i)}))}(r)}fh.prototype.g=function(){var t=this,e=mh("local");_h(this,(function(){return $t().then((function(){return t.c&&"local"!=t.c.C?t.b.get(e,t.a):null})).then((function(n){if(n)return ph(t,"local").then((function(){t.c=e}))}))}))};var dh={name:"persistence",C:"session"};function mh(t){return{name:"authUser",C:t}}function yh(t,e){return _h(t,(function(){return t.b.set(t.c,e.A(),t.a)}))}function gh(t){return _h(t,(function(){return Ru(t.b,t.c,t.a)}))}function vh(t,e){return _h(t,(function(){return t.b.get(t.c,t.a).then((function(t){return t&&e&&(t.authDomain=e),uh(t||{})}))}))}function _h(t,e){return t.f=t.f.then(e,e),t.f}function bh(t){if(this.l=!1,Br(this,"settings",new Tc),Br(this,"app",t),!Nh(this).options||!Nh(this).options.apiKey)throw new ti("invalid-api-key");t=r.a.SDK_VERSION?_r(r.a.SDK_VERSION):null,this.b=new Pa(Nh(this).options&&Nh(this).options.apiKey,Oi(ki),t),this.O=[],this.m=[],this.J=[],this.Ub=r.a.INTERNAL.createSubscribe(C(this.oc,this)),this.W=void 0,this.Vb=r.a.INTERNAL.createSubscribe(C(this.pc,this)),Ih(this,null),this.h=new fh(Nh(this).options.apiKey+":"+Nh(this).name),this.w=new ch(Nh(this).options.apiKey+":"+Nh(this).name),this.Y=Oh(this,function(t){var e=Nh(t).options.authDomain,n=function(t){var e=function(t,e){return t.b.get(hh,t.a).then((function(t){return t&&e&&(t.authDomain=e),uh(t||{})}))}(t.w,Nh(t).options.authDomain).then((function(e){return(t.B=e)&&(e.da=t.w),lh(t.w)}));return Oh(t,e)}(t).then((function(){return vh(t.h,e)})).then((function(e){return e?(e.da=t.w,t.B&&(t.B.ca||null)==(e.ca||null)?e:e.reload().then((function(){return yh(t.h,e).then((function(){return e}))})).s((function(n){return"auth/network-request-failed"==n.code?e:gh(t.h)}))):null})).then((function(e){Ih(t,e||null)}));return Oh(t,n)}(this)),this.i=Oh(this,function(t){return t.Y.then((function(){return Ch(t)})).s((function(){})).then((function(){if(!t.l)return t.ma()})).s((function(){})).then((function(){if(!t.l){t.ga=!0;var e=t.h;e.b.addListener(mh("local"),e.a,t.ma)}}))}(this)),this.ga=!1,this.ma=C(this.Nc,this),this.ub=C(this.aa,this),this.wa=C(this.bc,this),this.xa=C(this.mc,this),this.Ja=C(this.nc,this),this.a=null,function(t){var e=Nh(t).options.authDomain,n=Nh(t).options.apiKey;e&&Tr()&&(t.Tb=t.Y.then((function(){if(!t.l){if(t.a=yc(e,n,Nh(t).name),sc(t.a,t),Ah(t)&&Wc(Ah(t)),t.B){Wc(t.B);var r=t.B;r.ua(t.ha()),Lc(r,t),Fc(r=t.B,t.I),Uc(r,t),t.B=null}return t.a}})))}(this),this.INTERNAL={},this.INTERNAL.delete=C(this.delete,this),this.INTERNAL.logFramework=C(this.vc,this),this.o=0,un.call(this),function(t){Object.defineProperty(t,"lc",{get:function(){return this.ha()},set:function(t){this.ua(t)},enumerable:!1}),t.Z=null,Object.defineProperty(t,"ti",{get:function(){return this.R()},set:function(t){this.nb(t)},enumerable:!1}),t.P=null}(this),this.I=[]}function wh(t){Fe.call(this,"languageCodeChanged"),this.g=t}function Eh(t){Fe.call(this,"frameworkChanged"),this.c=t}function Th(t){return t.Tb||te(new ti("auth-domain-config-required"))}function Ch(t){if(!Tr())return te(new ti("operation-not-supported-in-this-environment"));var e=Th(t).then((function(){return t.a.oa()})).then((function(t){return t?zr(t):null}));return Oh(t,e)}function Sh(t,e){var n={};return n.apiKey=Nh(t).options.apiKey,n.authDomain=Nh(t).options.authDomain,n.appName=Nh(t).name,t.Y.then((function(){return function(t,e,n,r){var i=new Mc(t,e);return n&&(i.da=n),r&&Fc(i,r),i.reload().then((function(){return i}))}(n,e,t.w,t.Ca())})).then((function(e){return Ah(t)&&e.uid==Ah(t).uid?(Zc(Ah(t),e),t.aa(e)):(Ih(t,e),Wc(e),t.aa(e))})).then((function(){Rh(t)}))}function Ih(t,e){Ah(t)&&(function(t,e){Q(t.O,(function(t){return t==e}))}(Ah(t),t.ub),Ze(Ah(t),"tokenChanged",t.wa),Ze(Ah(t),"userDeleted",t.xa),Ze(Ah(t),"userInvalidated",t.Ja),Bc(Ah(t))),e&&(e.O.push(t.ub),Ye(e,"tokenChanged",t.wa),Ye(e,"userDeleted",t.xa),Ye(e,"userInvalidated",t.Ja),0<t.o&&Vc(e)),Br(t,"currentUser",e),e&&(e.ua(t.ha()),Lc(e,t),Fc(e,t.I),Uc(e,t))}function Dh(t,e){var n=null,r=null;return Oh(t,e.then((function(e){return n=To(e),r=Fi(e),Sh(t,e)})).then((function(){return zr({user:Ah(t),credential:n,additionalUserInfo:r,operationType:"signIn"})})))}function Nh(t){return t.app}function Ah(t){return t.currentUser}function kh(t){return Ah(t)&&Ah(t)._lat||null}function Rh(t){if(t.ga){for(var e=0;e<t.m.length;e++)t.m[e]&&t.m[e](kh(t));if(t.W!==t.getUid()&&t.J.length)for(t.W=t.getUid(),e=0;e<t.J.length;e++)t.J[e]&&t.J[e](kh(t))}}function Oh(t,e){return t.O.push(e),e.ka((function(){W(t.O,e)})),e}function xh(){}function Ph(){this.a={},this.b=1e12}fh.prototype.mb=function(t){var e=null,n=this;return function(t){var e=new ti("invalid-persistence-type"),n=new ti("unsupported-persistence-type");t:{for(r in Iu)if(Iu[r]==t){var r=!0;break t}r=!1}if(!r||"string"!=typeof t)throw e;switch(pr()){case"ReactNative":if("session"===t)throw n;break;case"Node":if("none"!==t)throw n;break;default:if(!Er()&&"none"!==t)throw n}}(t),_h(this,(function(){return t!=n.c.C?n.b.get(n.c,n.a).then((function(r){return e=r,ph(n,t)})).then((function(){if(n.c=mh(t),e)return n.b.set(n.c,e,n.a)})):$t()}))},D(bh,un),D(wh,Fe),D(Eh,Fe),(e=bh.prototype).mb=function(t){return Oh(this,t=this.h.mb(t))},e.ua=function(t){this.Z===t||this.l||(this.Z=t,Ba(this.b,this.Z),this.dispatchEvent(new wh(this.ha())))},e.ha=function(){return this.Z},e.Tc=function(){var t=u.navigator;this.ua(t&&(t.languages&&t.languages[0]||t.language||t.userLanguage)||null)},e.vc=function(t){this.I.push(t),ja(this.b,r.a.SDK_VERSION?_r(r.a.SDK_VERSION,this.I):null),this.dispatchEvent(new Eh(this.I))},e.Ca=function(){return H(this.I)},e.nb=function(t){this.P===t||this.l||(this.P=t,this.b.b=this.P)},e.R=function(){return this.P},e.toJSON=function(){return{apiKey:Nh(this).options.apiKey,authDomain:Nh(this).options.authDomain,appName:Nh(this).name,currentUser:Ah(this)&&Ah(this).A()}},e.xb=function(t,e){switch(t){case"unknown":case"signInViaRedirect":return!0;case"signInViaPopup":return this.g==e&&!!this.f;default:return!1}},e.ja=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)},e.Ba=function(t,e){return"signInViaRedirect"==t||"signInViaPopup"==t&&this.g==e&&this.f?C(this.ac,this):null},e.ac=function(t,e,n,r){var i=this;t={requestUri:t,postBody:r,sessionId:e,tenantId:n},this.c&&(this.c.cancel(),this.c=null);var o=null,a=null,s=ts(i.b,t).then((function(t){return o=To(t),a=Fi(t),t}));return Oh(this,t=i.Y.then((function(){return s})).then((function(t){return Sh(i,t)})).then((function(){return zr({user:Ah(i),credential:o,additionalUserInfo:a,operationType:"signIn"})})))},e.Lc=function(t){if(!Tr())return te(new ti("operation-not-supported-in-this-environment"));var e=this,n=Li(t.providerId),i=kr(),o=null;(!Ir()||lr())&&Nh(this).options.authDomain&&t.isOAuthProvider&&(o=Ks(Nh(this).options.authDomain,Nh(this).options.apiKey,Nh(this).name,"signInViaPopup",t,null,i,r.a.SDK_VERSION||null,null,null,this.R()));var a=ar(o,n&&n.sa,n&&n.ra);return Oh(this,n=Th(this).then((function(n){return lc(n,a,"signInViaPopup",t,i,!!o,e.R())})).then((function(){return new Kt((function(t,n){e.ja("signInViaPopup",null,new ti("cancelled-popup-request"),e.g),e.f=t,e.v=n,e.g=i,e.c=dc(e.a,e,"signInViaPopup",a,i)}))})).then((function(t){return a&&or(a),t?zr(t):null})).s((function(t){throw a&&or(a),t})))},e.Mc=function(t){if(!Tr())return te(new ti("operation-not-supported-in-this-environment"));var e=this;return Oh(this,Th(this).then((function(){return function(t){return _h(t,(function(){return t.b.set(dh,t.c.C,t.a)}))}(e.h)})).then((function(){return pc(e.a,"signInViaRedirect",t,void 0,e.R())})))},e.oa=function(){var t=this;return Ch(this).then((function(e){return t.a&&_c(t.a.b),e})).s((function(e){throw t.a&&_c(t.a.b),e}))},e.Rc=function(t){if(!t)return te(new ti("null-user"));if(this.P!=t.tenantId)return te(new ti("tenant-id-mismatch"));var e=this,n={};n.apiKey=Nh(this).options.apiKey,n.authDomain=Nh(this).options.authDomain,n.appName=Nh(this).name;var r=function(t,e,n,r){e=e||{apiKey:t.l,authDomain:t.o,appName:t.m};var i=t.b,o={};return o[La]=i.b,o.refreshToken=i.a,o.expiresIn=(i.c-I())/1e3,e=new Mc(e,o),n&&(e.da=n),r&&Fc(e,r),Zc(e,t),e}(t,n,e.w,e.Ca());return Oh(this,this.i.then((function(){if(Nh(e).options.apiKey!=t.l)return r.reload()})).then((function(){return Ah(e)&&t.uid==Ah(e).uid?(Zc(Ah(e),t),e.aa(t)):(Ih(e,r),Wc(r),e.aa(r))})).then((function(){Rh(e)})))},e.pb=function(){var t=this;return Oh(this,this.i.then((function(){return t.a&&_c(t.a.b),Ah(t)?(Ih(t,null),gh(t.h).then((function(){Rh(t)}))):$t()})))},e.Nc=function(){var t=this;return vh(this.h,Nh(this).options.authDomain).then((function(e){if(!t.l){var n;if(n=Ah(t)&&e){n=Ah(t).uid;var r=e.uid;n=null!=n&&""!==n&&null!=r&&""!==r&&n==r}if(n)return Zc(Ah(t),e),Ah(t).G();(Ah(t)||e)&&(Ih(t,e),e&&(Wc(e),e.da=t.w),t.a&&sc(t.a,t),Rh(t))}}))},e.aa=function(t){return yh(this.h,t)},e.bc=function(){Rh(this),this.aa(Ah(this))},e.mc=function(){this.pb()},e.nc=function(){this.pb()},e.oc=function(t){var e=this;this.addAuthTokenListener((function(){t.next(Ah(e))}))},e.pc=function(t){var e=this;!function(t,e){t.J.push(e),Oh(t,t.i.then((function(){!t.l&&z(t.J,e)&&t.W!==t.getUid()&&(t.W=t.getUid(),e(kh(t)))})))}(this,(function(){t.next(Ah(e))}))},e.xc=function(t,e,n){var r=this;return this.ga&&Promise.resolve().then((function(){v(t)?t(Ah(r)):v(t.next)&&t.next(Ah(r))})),this.Ub(t,e,n)},e.wc=function(t,e,n){var r=this;return this.ga&&Promise.resolve().then((function(){r.W=r.getUid(),v(t)?t(Ah(r)):v(t.next)&&t.next(Ah(r))})),this.Vb(t,e,n)},e.cc=function(t){var e=this;return Oh(this,this.i.then((function(){return Ah(e)?Ah(e).G(t).then((function(t){return{accessToken:t}})):null})))},e.Hc=function(t){var e=this;return this.i.then((function(){return Dh(e,Rs(e.b,Is,{token:t}))})).then((function(t){var n=t.user;return Jc(n,"isAnonymous",!1),e.aa(n),t}))},e.Ic=function(t,e){var n=this;return this.i.then((function(){return Dh(n,Rs(n.b,Ds,{email:t,password:e}))}))},e.Xb=function(t,e){var n=this;return this.i.then((function(){return Dh(n,Rs(n.b,as,{email:t,password:e}))}))},e.Sa=function(t){var e=this;return this.i.then((function(){return Dh(e,t.na(e.b))}))},e.Gc=function(t){return qr("firebase.auth.Auth.prototype.signInAndRetrieveDataWithCredential is deprecated. Please use firebase.auth.Auth.prototype.signInWithCredential instead."),this.Sa(t)},e.ob=function(){var t=this;return this.i.then((function(){var e=Ah(t);if(e&&e.isAnonymous){var n=zr({providerId:null,isNewUser:!1});return zr({user:e,credential:null,additionalUserInfo:n,operationType:"signIn"})}return Dh(t,t.b.ob()).then((function(e){var n=e.user;return Jc(n,"isAnonymous",!0),t.aa(n),e}))}))},e.getUid=function(){return Ah(this)&&Ah(this).uid||null},e.Wb=function(t){this.addAuthTokenListener(t),this.o++,0<this.o&&Ah(this)&&Vc(Ah(this))},e.Ec=function(t){var e=this;V(this.m,(function(n){n==t&&e.o--})),0>this.o&&(this.o=0),0==this.o&&Ah(this)&&Bc(Ah(this)),this.removeAuthTokenListener(t)},e.addAuthTokenListener=function(t){var e=this;this.m.push(t),Oh(this,this.i.then((function(){e.l||z(e.m,t)&&t(kh(e))})))},e.removeAuthTokenListener=function(t){Q(this.m,(function(e){return e==t}))},e.delete=function(){this.l=!0;for(var t=0;t<this.O.length;t++)this.O[t].cancel("app-deleted");return this.O=[],this.h&&(t=this.h).b.removeListener(mh("local"),t.a,this.ma),this.a&&(uc(this.a,this),_c(this.a.b)),Promise.resolve()},e.$b=function(t){return Oh(this,function(t,e){return Rs(t,ss,{identifier:e,continueUri:Cr()?nr():"http://localhost"}).then((function(t){return t.signinMethods||[]}))}(this.b,t))},e.qc=function(t){return!!go(t)},e.lb=function(t,e){var n=this;return Oh(this,$t().then((function(){var t=new pi(e);if(!t.c)throw new ti("argument-error",yi+" must be true when sending sign in link to email");return Ti(t)})).then((function(e){return n.b.lb(t,e)})).then((function(){})))},e.Uc=function(t){return this.Ma(t).then((function(t){return t.data.email}))},e.ab=function(t,e){return Oh(this,this.b.ab(t,e).then((function(){})))},e.Ma=function(t){return Oh(this,this.b.Ma(t).then((function(t){return new Qr(t)})))},e.Ya=function(t){return Oh(this,this.b.Ya(t).then((function(){})))},e.kb=function(t,e){var n=this;return Oh(this,$t().then((function(){return void 0===e||Y(e)?{}:Ti(new pi(e))})).then((function(e){return n.b.kb(t,e)})).then((function(){})))},e.Kc=function(t,e){return Oh(this,Sc(this,t,e,C(this.Sa,this)))},e.Jc=function(t,e){var n=this;return Oh(this,$t().then((function(){var r=e||nr(),i=yo(t,r);if(!(r=go(r)))throw new ti("argument-error","Invalid email link!");if(r.tenantId!==n.R())throw new ti("tenant-id-mismatch");return n.Sa(i)})))},xh.prototype.render=function(){},xh.prototype.reset=function(){},xh.prototype.getResponse=function(){},xh.prototype.execute=function(){};var Mh=null;function Lh(t,e){return(e=Fh(e))&&t.a[e]||null}function Fh(t){return(t=void 0===t?1e12:t)?t.toString():null}function Uh(t,e){this.g=!1,this.c=e,this.a=this.b=null,this.h="invisible"!==this.c.size,this.f=Qn(t);var n=this;this.i=function(){n.execute()},this.h?this.execute():Ye(this.f,"click",this.i)}function qh(t){if(t.g)throw Error("reCAPTCHA mock was already deleted!")}function Vh(){}Ph.prototype.render=function(t,e){return this.a[this.b.toString()]=new Uh(t,e),this.b++},Ph.prototype.reset=function(t){var e=Lh(this,t);t=Fh(t),e&&t&&(e.delete(),delete this.a[t])},Ph.prototype.getResponse=function(t){return(t=Lh(this,t))?t.getResponse():null},Ph.prototype.execute=function(t){(t=Lh(this,t))&&t.execute()},Uh.prototype.getResponse=function(){return qh(this),this.b},Uh.prototype.execute=function(){qh(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(r){}t.a=setTimeout((function(){if(t.a=null,t.b=null,n)try{n()}catch(r){}t.h&&t.execute()}),6e4)}),500))},Uh.prototype.delete=function(){qh(this),this.g=!0,clearTimeout(this.a),this.a=null,Ze(this.f,"click",this.i)},Vh.prototype.g=function(){return Mh||(Mh=new Ph),$t(Mh)},Vh.prototype.c=function(){};var Bh=null;function jh(){this.b=u.grecaptcha?1/0:0,this.f=null,this.a="__rcb"+Math.floor(1e6*Math.random()).toString()}var zh=new $(nt,"https://www.google.com/recaptcha/api.js?onload=%{onload}&render=explicit&hl=%{hl}"),Wh=new xr(3e4,6e4);jh.prototype.g=function(t){var e=this;return new Kt((function(n,r){var i=setTimeout((function(){r(new ti("network-request-failed"))}),Wh.get());!u.grecaptcha||t!==e.f&&!e.b?(u[e.a]=function(){if(u.grecaptcha){e.f=t;var o=u.grecaptcha.render;u.grecaptcha.render=function(t,n){return t=o(t,n),e.b++,t},clearTimeout(i),n(u.grecaptcha)}else clearTimeout(i),r(new ti("internal-error"));delete u[e.a]},$t(Da(at(zh,{onload:e.a,hl:t||""}))).s((function(){clearTimeout(i),r(new ti("internal-error","Unable to load external reCAPTCHA dependencies!"))}))):(clearTimeout(i),n(u.grecaptcha))}))},jh.prototype.c=function(){this.b--};var Qh=null;function Kh(t,e,n,r,i,o,a){if(Br(this,"type","recaptcha"),this.c=this.f=null,this.B=!1,this.u=e,this.g=null,a?(Bh||(Bh=new Vh),a=Bh):(Qh||(Qh=new jh),a=Qh),this.m=a,this.a=n||{theme:"light",type:"image"},this.h=[],this.a[Yh])throw new ti("argument-error","sitekey should not be provided for reCAPTCHA as one is automatically provisioned for the current project.");if(this.i="invisible"===this.a[Xh],!u.document)throw new ti("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment with DOM support.");if(!Qn(e)||!this.i&&Qn(e).hasChildNodes())throw new ti("argument-error","reCAPTCHA container is either not found or already contains inner elements!");this.o=new Pa(t,o||null,i||null),this.v=r||function(){return null};var s=this;this.l=[];var c=this.a[Hh];this.a[Hh]=function(t){if(Jh(s,t),"function"==typeof c)c(t);else if("string"==typeof c){var e=wr(c,u);"function"==typeof e&&e(t)}};var h=this.a[Gh];this.a[Gh]=function(){if(Jh(s,null),"function"==typeof h)h();else if("string"==typeof h){var t=wr(h,u);"function"==typeof t&&t()}}}var Hh="callback",Gh="expired-callback",Yh="sitekey",Xh="size";function Jh(t,e){for(var n=0;n<t.l.length;n++)try{t.l[n](e)}catch(r){}}function Zh(t,e){return t.h.push(e),e.ka((function(){W(t.h,e)})),e}function $h(t){if(t.B)throw new ti("internal-error","RecaptchaVerifier instance has been destroyed.")}function tl(t,e,n){var i=!1;try{this.b=n||r.a.app()}catch(s){throw new ti("argument-error","No firebase.app.App instance is currently initialized.")}if(!this.b.options||!this.b.options.apiKey)throw new ti("invalid-api-key");n=this.b.options.apiKey;var o=this,a=null;try{a=this.b.auth().Ca()}catch(s){}try{i=this.b.auth().settings.appVerificationDisabledForTesting}catch(s){}a=r.a.SDK_VERSION?_r(r.a.SDK_VERSION,a):null,Kh.call(this,n,t,e,(function(){try{var t=o.b.auth().ha()}catch(e){t=null}return t}),a,Oi(ki),i)}function el(t,e,n,r){t:{n=Array.prototype.slice.call(n);for(var i=0,o=!1,a=0;a<e.length;a++)if(e[a].optional)o=!0;else{if(o)throw new ti("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].N(n[i])&&!o){if(e=e[i],0>i||i>=nl.length)throw new ti("internal-error","Argument validator received an unsupported number of arguments.");n=nl[i],r=(r?"":n+" argument ")+(e.name?'"'+e.name+'" ':"")+"must be "+e.M+".";break t}r=null}}if(r)throw new ti("argument-error",t+" failed: "+r)}(e=Kh.prototype).Da=function(){var t=this;return this.f?this.f:this.f=Zh(this,$t().then((function(){if(Cr()&&!fr())return cr();throw new ti("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment.")})).then((function(){return t.m.g(t.v())})).then((function(e){return t.g=e,Rs(t.o,gs,{})})).then((function(e){t.a[Yh]=e.recaptchaSiteKey})).s((function(e){throw t.f=null,e})))},e.render=function(){$h(this);var t=this;return Zh(this,this.Da().then((function(){if(null===t.c){var e=t.u;if(!t.i){var n=Qn(e);e=Gn("DIV"),n.appendChild(e)}t.c=t.g.render(e,t.a)}return t.c})))},e.verify=function(){$h(this);var t=this;return Zh(this,this.render().then((function(e){return new Kt((function(n){var r=t.g.getResponse(e);if(r)n(r);else{t.l.push((function e(r){r&&(function(t,e){Q(t.l,(function(t){return t==e}))}(t,e),n(r))})),t.i&&t.g.execute(t.c)}}))})))},e.reset=function(){$h(this),null!==this.c&&this.g.reset(this.c)},e.clear=function(){$h(this),this.B=!0,this.m.c();for(var t=0;t<this.h.length;t++)this.h[t].cancel("RecaptchaVerifier instance has been destroyed.");if(!this.i){t=Qn(this.u);for(var e;e=t.firstChild;)t.removeChild(e)}},D(tl,Kh);var nl="First Second Third Fourth Fifth Sixth Seventh Eighth Ninth".split(" ");function rl(t,e){return{name:t||"",M:"a valid string",optional:!!e,N:c}}function il(t,e){return{name:t||"",M:"a boolean",optional:!!e,N:h}}function ol(t,e){return{name:t||"",M:"a valid object",optional:!!e,N:_}}function al(t,e){return{name:t||"",M:"a function",optional:!!e,N:v}}function sl(t,e){return{name:t||"",M:"null",optional:!!e,N:m}}function ul(t){return{name:t?t+"Credential":"credential",M:t?"a valid "+t+" credential":"a valid credential",optional:!1,N:function(e){if(!e)return!1;var n=!t||e.providerId===t;return!(!e.na||!n)}}}function cl(){return{name:"applicationVerifier",M:"an implementation of firebase.auth.ApplicationVerifier",optional:!1,N:function(t){return!!(t&&c(t.type)&&v(t.verify))}}}function hl(t,e,n,r){return{name:n||"",M:t.M+" or "+e.M,optional:!!r,N:function(n){return t.N(n)||e.N(n)}}}function ll(t,e){for(var n in e){var r=e[n].name;t[r]=dl(r,t[n],e[n].j)}}function fl(t,e){for(var n in e){var r=e[n].name;r!==n&&Object.defineProperty(t,r,{get:S((function(t){return this[t]}),n),set:S((function(t,e,n,r){el(t,[n],[r],!0),this[e]=r}),r,n,e[n].Za),enumerable:!0})}}function pl(t,e,n,r){t[e]=dl(e,n,r)}function dl(t,e,n){function r(){var t=Array.prototype.slice.call(arguments);return el(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}ll(bh.prototype,{Ya:{name:"applyActionCode",j:[rl("code")]},Ma:{name:"checkActionCode",j:[rl("code")]},ab:{name:"confirmPasswordReset",j:[rl("code"),rl("newPassword")]},Xb:{name:"createUserWithEmailAndPassword",j:[rl("email"),rl("password")]},$b:{name:"fetchSignInMethodsForEmail",j:[rl("email")]},oa:{name:"getRedirectResult",j:[]},qc:{name:"isSignInWithEmailLink",j:[rl("emailLink")]},wc:{name:"onAuthStateChanged",j:[hl(ol(),al(),"nextOrObserver"),al("opt_error",!0),al("opt_completed",!0)]},xc:{name:"onIdTokenChanged",j:[hl(ol(),al(),"nextOrObserver"),al("opt_error",!0),al("opt_completed",!0)]},kb:{name:"sendPasswordResetEmail",j:[rl("email"),hl(ol("opt_actionCodeSettings",!0),sl(null,!0),"opt_actionCodeSettings",!0)]},lb:{name:"sendSignInLinkToEmail",j:[rl("email"),ol("actionCodeSettings")]},mb:{name:"setPersistence",j:[rl("persistence")]},Gc:{name:"signInAndRetrieveDataWithCredential",j:[ul()]},ob:{name:"signInAnonymously",j:[]},Sa:{name:"signInWithCredential",j:[ul()]},Hc:{name:"signInWithCustomToken",j:[rl("token")]},Ic:{name:"signInWithEmailAndPassword",j:[rl("email"),rl("password")]},Jc:{name:"signInWithEmailLink",j:[rl("email"),rl("emailLink",!0)]},Kc:{name:"signInWithPhoneNumber",j:[rl("phoneNumber"),cl()]},Lc:{name:"signInWithPopup",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Mc:{name:"signInWithRedirect",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Rc:{name:"updateCurrentUser",j:[hl({name:"user",M:"an instance of Firebase User",optional:!1,N:function(t){return!!(t&&t instanceof Mc)}},sl(),"user")]},pb:{name:"signOut",j:[]},toJSON:{name:"toJSON",j:[rl(null,!0)]},Tc:{name:"useDeviceLanguage",j:[]},Uc:{name:"verifyPasswordResetCode",j:[rl("code")]}}),fl(bh.prototype,{lc:{name:"languageCode",Za:hl(rl(),sl(),"languageCode")},ti:{name:"tenantId",Za:hl(rl(),sl(),"tenantId")}}),bh.Persistence=Iu,bh.Persistence.LOCAL="local",bh.Persistence.SESSION="session",bh.Persistence.NONE="none",ll(Mc.prototype,{delete:{name:"delete",j:[]},dc:{name:"getIdTokenResult",j:[il("opt_forceRefresh",!0)]},G:{name:"getIdToken",j:[il("opt_forceRefresh",!0)]},rc:{name:"linkAndRetrieveDataWithCredential",j:[ul()]},fb:{name:"linkWithCredential",j:[ul()]},sc:{name:"linkWithPhoneNumber",j:[rl("phoneNumber"),cl()]},tc:{name:"linkWithPopup",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},uc:{name:"linkWithRedirect",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Ac:{name:"reauthenticateAndRetrieveDataWithCredential",j:[ul()]},hb:{name:"reauthenticateWithCredential",j:[ul()]},Bc:{name:"reauthenticateWithPhoneNumber",j:[rl("phoneNumber"),cl()]},Cc:{name:"reauthenticateWithPopup",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Dc:{name:"reauthenticateWithRedirect",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},reload:{name:"reload",j:[]},jb:{name:"sendEmailVerification",j:[hl(ol("opt_actionCodeSettings",!0),sl(null,!0),"opt_actionCodeSettings",!0)]},toJSON:{name:"toJSON",j:[rl(null,!0)]},Qc:{name:"unlink",j:[rl("provider")]},rb:{name:"updateEmail",j:[rl("email")]},sb:{name:"updatePassword",j:[rl("password")]},Sc:{name:"updatePhoneNumber",j:[ul("phone")]},tb:{name:"updateProfile",j:[ol("profile")]}}),ll(Ph.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),ll(xh.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),ll(Kt.prototype,{ka:{name:"finally"},s:{name:"catch"},then:{name:"then"}}),fl(Tc.prototype,{appVerificationDisabled:{name:"appVerificationDisabledForTesting",Za:il("appVerificationDisabledForTesting")}}),ll(Cc.prototype,{confirm:{name:"confirm",j:[rl("verificationCode")]}}),pl(Hi,"fromJSON",(function(t){t=c(t)?JSON.parse(t):t;for(var e,n=[to,po,_o,Ji],r=0;r<n.length;r++)if(e=n[r](t))return e;return null}),[hl(rl(),ol(),"json")]),pl(mo,"credential",(function(t,e){return new fo(t,e)}),[rl("email"),rl("password")]),ll(fo.prototype,{A:{name:"toJSON",j:[rl(null,!0)]}}),ll(io.prototype,{ya:{name:"addScope",j:[rl("scope")]},Ga:{name:"setCustomParameters",j:[ol("customOAuthParameters")]}}),pl(io,"credential",oo,[hl(rl(),ol(),"token")]),pl(mo,"credentialWithLink",yo,[rl("email"),rl("emailLink")]),ll(ao.prototype,{ya:{name:"addScope",j:[rl("scope")]},Ga:{name:"setCustomParameters",j:[ol("customOAuthParameters")]}}),pl(ao,"credential",so,[hl(rl(),ol(),"token")]),ll(uo.prototype,{ya:{name:"addScope",j:[rl("scope")]},Ga:{name:"setCustomParameters",j:[ol("customOAuthParameters")]}}),pl(uo,"credential",co,[hl(rl(),hl(ol(),sl()),"idToken"),hl(rl(),sl(),"accessToken",!0)]),ll(ho.prototype,{Ga:{name:"setCustomParameters",j:[ol("customOAuthParameters")]}}),pl(ho,"credential",lo,[hl(rl(),ol(),"token"),rl("secret",!0)]),ll(ro.prototype,{ya:{name:"addScope",j:[rl("scope")]},credential:{name:"credential",j:[hl(rl(),hl(ol(),sl()),"optionsOrIdToken"),hl(rl(),sl(),"accessToken",!0)]},Ga:{name:"setCustomParameters",j:[ol("customOAuthParameters")]}}),ll(Zi.prototype,{A:{name:"toJSON",j:[rl(null,!0)]}}),ll(Yi.prototype,{A:{name:"toJSON",j:[rl(null,!0)]}}),pl(wo,"credential",Eo,[rl("verificationId"),rl("verificationCode")]),ll(wo.prototype,{Wa:{name:"verifyPhoneNumber",j:[rl("phoneNumber"),cl()]}}),ll(vo.prototype,{A:{name:"toJSON",j:[rl(null,!0)]}}),ll(ti.prototype,{toJSON:{name:"toJSON",j:[rl(null,!0)]}}),ll(Ro.prototype,{toJSON:{name:"toJSON",j:[rl(null,!0)]}}),ll(ko.prototype,{toJSON:{name:"toJSON",j:[rl(null,!0)]}}),ll(tl.prototype,{clear:{name:"clear",j:[]},render:{name:"render",j:[]},verify:{name:"verify",j:[]}}),pl(ii,"parseLink",fi,[rl("link")]),function(){if(void 0===r.a||!r.a.INTERNAL||!r.a.INTERNAL.registerComponent)throw Error("Cannot find the firebase namespace; be sure to include firebase-app.js before this library.");var t={ActionCodeInfo:{Operation:{EMAIL_SIGNIN:Kr,PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",VERIFY_EMAIL:"VERIFY_EMAIL"}},Auth:bh,AuthCredential:Hi,Error:ti};pl(t,"EmailAuthProvider",mo,[]),pl(t,"FacebookAuthProvider",io,[]),pl(t,"GithubAuthProvider",ao,[]),pl(t,"GoogleAuthProvider",uo,[]),pl(t,"TwitterAuthProvider",ho,[]),pl(t,"OAuthProvider",ro,[rl("providerId")]),pl(t,"SAMLAuthProvider",no,[rl("providerId")]),pl(t,"PhoneAuthProvider",wo,[{name:"auth",M:"an instance of Firebase Auth",optional:!0,N:function(t){return!!(t&&t instanceof bh)}}]),pl(t,"RecaptchaVerifier",tl,[hl(rl(),{name:"",M:"an HTML element",optional:!1,N:function(t){return!!(t&&t instanceof Element)}},"recaptchaContainer"),ol("recaptchaParameters",!0),{name:"app",M:"an instance of Firebase App",optional:!0,N:function(t){return!!(t&&t instanceof r.a.app.App)}}]),pl(t,"ActionCodeURL",ii,[]),r.a.INTERNAL.registerComponent({name:"auth",instanceFactory:function(t){return new bh(t=t.getProvider("app").getImmediate())},multipleInstances:!1,serviceProps:t,instantiationMode:"LAZY",type:"PUBLIC"}),r.a.INTERNAL.registerComponent({name:"auth-internal",instanceFactory:function(t){return{getUid:C((t=t.getProvider("auth").getImmediate()).getUid,t),getToken:C(t.cc,t),addAuthTokenListener:C(t.Wb,t),removeAuthTokenListener:C(t.Ec,t)}},multipleInstances:!1,instantiationMode:"LAZY",type:"PRIVATE"}),r.a.registerVersion("@firebase/auth","0.13.3"),r.a.INTERNAL.extendNamespace({User:Mc})}()}).apply(void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})}).call(this,n("yLpj"))},vRfx:function(t,e,n){"use strict";var r=n("q1tI"),i=n.n(r),o=n("ARus"),a=(n("gEbY"),n("bdgK"));var s=function(t){var e,n;function r(){return t.apply(this,arguments)||this}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n;var s=r.prototype;return s.componentDidMount=function(){this.definePlaying(),this.addResizeListener(),this.forceUpdate()},s.componentWillReceiveProps=function(t,e){var n=this;this.setState({img:t.image}),setTimeout((function(){return n.forceUpdate()}),0)},s.getPane=function(){return"undefined"!=typeof document&&document.getElementById(this.props.id+"_img")},s.definePlaying=function(){Object.defineProperty(HTMLMediaElement.prototype,"playing",{configurable:!0,get:function(){return!!(this.currentTime>0&&!this.paused&&!this.ended&&this.readyState>2)}})},s.addResizeListener=function(){var t=this;new a.a((function(){t.forceUpdate()})).observe(this.getPane())},s.onPaneClick=function(t){this.getPane().currentTime>0&&(t.preventDefault(),this.getPane().pause()),0!==this.getPane().currentTime&&this.addAnnotation(this.newAnnotation(t.nativeEvent))},s.addAnnotation=function(t){this.props.setAnnotations(this.props.image.annotations.filter((function(t){return!!t.comment})).concat(t))},s.newAnnotation=function(t){return{x:t.offsetX/this.getXScale(),y:t.offsetY/this.getYScale(),time:this.getPane().currentTime,id:Math.random()}},s.getXScale=function(){return this.getScale("Width")},s.getYScale=function(){return this.getScale("Height")},s.getScale=function(t){var e=this.getPane();return e["offset"+t]/(e["natural"+t]||(0===e["video"+t]?1:e["video"+t]))},s.render=function(){var t=this;return[i.a.createElement("div",{style:this.props.style,className:"annocontainer",id:"annotationcontainer"},!!this.props.time&&i.a.createElement("div",{className:"videotimestamp"},this.props.time),"video"===this.props.image.resource_type?i.a.createElement("video",{crossOrigin:"anonymous",onTimeUpdate:function(){return t.props.setTime(t.getPane().currentTime)},alt:"curimg",id:this.props.id+"_img",controls:!0,onClick:function(e){return t.onPaneClick(e)},src:this.props.image.secure_url,poster:this.props.image.src}):i.a.createElement("img",{alt:this.props.id+"_img",id:this.props.id+"_img",onClick:function(e){return t.onPaneClick(e)},src:this.props.image.src}),this.getPane()&&this.props.image.annotations.map((function(e,n){return i.a.createElement(o.a,{key:e.id,getPane:function(){return t.getPane()},remove:function(){e.comment="",t.props.save()},onSave:function(){return t.props.save()},onMove:function(n){n.x=Math.max(n.x,15),n.y=Math.max(n.y,15),n.x=Math.min(n.x,t.getPane().offsetWidth-15),n.y=Math.min(n.y,t.getPane().offsetHeight-15),e.x=n.x/t.getXScale(t.getPane()),e.y=n.y/t.getYScale(t.getPane()),t.props.save()},onChange:function(n){e.comment=n,t.forceUpdate()},comment:e.comment,annotation:e,pos:{x:e.x*t.getXScale(),y:e.y*t.getYScale()}})})))]},r}(i.a.Component);e.a=s},voZr:function(t,e,n){"use strict";var r=n("emib"),i=n("QPJK"),o=n("939K"),a=n("Jegl"),s=n("8wc8"),u=n("rj/q"),c=n("96qb"),h=n("xa9o"),l=n("1Llc"),f=n("kiRH"),p=n("gx6d"),d=n("chL8").f,m=n("rjfK").f,y=n("Y++M"),g=n("dSuk"),v="prototype",_="Wrong index!",b=r.ArrayBuffer,w=r.DataView,E=r.Math,T=r.RangeError,C=r.Infinity,S=b,I=E.abs,D=E.pow,N=E.floor,A=E.log,k=E.LN2,R=i?"_b":"buffer",O=i?"_l":"byteLength",x=i?"_o":"byteOffset";function P(t,e,n){var r,i,o,a=new Array(n),s=8*n-e-1,u=(1<<s)-1,c=u>>1,h=23===e?D(2,-24)-D(2,-77):0,l=0,f=t<0||0===t&&1/t<0?1:0;for((t=I(t))!=t||t===C?(i=t!=t?1:0,r=u):(r=N(A(t)/k),t*(o=D(2,-r))<1&&(r--,o*=2),(t+=r+c>=1?h/o:h*D(2,1-c))*o>=2&&(r++,o/=2),r+c>=u?(i=0,r=u):r+c>=1?(i=(t*o-1)*D(2,e),r+=c):(i=t*D(2,c-1)*D(2,e),r=0));e>=8;a[l++]=255&i,i/=256,e-=8);for(r=r<<e|i,s+=e;s>0;a[l++]=255&r,r/=256,s-=8);return a[--l]|=128*f,a}function M(t,e,n){var r,i=8*n-e-1,o=(1<<i)-1,a=o>>1,s=i-7,u=n-1,c=t[u--],h=127&c;for(c>>=7;s>0;h=256*h+t[u],u--,s-=8);for(r=h&(1<<-s)-1,h>>=-s,s+=e;s>0;r=256*r+t[u],u--,s-=8);if(0===h)h=1-a;else{if(h===o)return r?NaN:c?-C:C;r+=D(2,e),h-=a}return(c?-1:1)*r*D(2,h-e)}function L(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]}function F(t){return[255&t]}function U(t){return[255&t,t>>8&255]}function q(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]}function V(t){return P(t,52,8)}function B(t){return P(t,23,4)}function j(t,e,n){m(t[v],e,{get:function(){return this[n]}})}function z(t,e,n,r){var i=p(+n);if(i+e>t[O])throw T(_);var o=t[R]._b,a=i+t[x],s=o.slice(a,a+e);return r?s:s.reverse()}function W(t,e,n,r,i,o){var a=p(+n);if(a+e>t[O])throw T(_);for(var s=t[R]._b,u=a+t[x],c=r(+i),h=0;h<e;h++)s[u+h]=c[o?h:e-h-1]}if(a.ABV){if(!c((function(){b(1)}))||!c((function(){new b(-1)}))||c((function(){return new b,new b(1.5),new b(NaN),"ArrayBuffer"!=b.name}))){for(var Q,K=(b=function(t){return h(this,b),new S(p(t))})[v]=S[v],H=d(S),G=0;H.length>G;)(Q=H[G++])in b||s(b,Q,S[Q]);o||(K.constructor=b)}var Y=new w(new b(2)),X=w[v].setInt8;Y.setInt8(0,2147483648),Y.setInt8(1,2147483649),!Y.getInt8(0)&&Y.getInt8(1)||u(w[v],{setInt8:function(t,e){X.call(this,t,e<<24>>24)},setUint8:function(t,e){X.call(this,t,e<<24>>24)}},!0)}else b=function(t){h(this,b,"ArrayBuffer");var e=p(t);this._b=y.call(new Array(e),0),this[O]=e},w=function(t,e,n){h(this,w,"DataView"),h(t,b,"DataView");var r=t[O],i=l(e);if(i<0||i>r)throw T("Wrong offset!");if(i+(n=void 0===n?r-i:f(n))>r)throw T("Wrong length!");this[R]=t,this[x]=i,this[O]=n},i&&(j(b,"byteLength","_l"),j(w,"buffer","_b"),j(w,"byteLength","_l"),j(w,"byteOffset","_o")),u(w[v],{getInt8:function(t){return z(this,1,t)[0]<<24>>24},getUint8:function(t){return z(this,1,t)[0]},getInt16:function(t){var e=z(this,2,t,arguments[1]);return(e[1]<<8|e[0])<<16>>16},getUint16:function(t){var e=z(this,2,t,arguments[1]);return e[1]<<8|e[0]},getInt32:function(t){return L(z(this,4,t,arguments[1]))},getUint32:function(t){return L(z(this,4,t,arguments[1]))>>>0},getFloat32:function(t){return M(z(this,4,t,arguments[1]),23,4)},getFloat64:function(t){return M(z(this,8,t,arguments[1]),52,8)},setInt8:function(t,e){W(this,1,t,F,e)},setUint8:function(t,e){W(this,1,t,F,e)},setInt16:function(t,e){W(this,2,t,U,e,arguments[2])},setUint16:function(t,e){W(this,2,t,U,e,arguments[2])},setInt32:function(t,e){W(this,4,t,q,e,arguments[2])},setUint32:function(t,e){W(this,4,t,q,e,arguments[2])},setFloat32:function(t,e){W(this,4,t,B,e,arguments[2])},setFloat64:function(t,e){W(this,8,t,V,e,arguments[2])}});g(b,"ArrayBuffer"),g(w,"DataView"),s(w[v],a.VIEW,!0),e.ArrayBuffer=b,e.DataView=w},wRvv:function(t,e){t.exports=["aaa","aarp","abarth","abb","abbott","abbvie","abc","able","abogado","abudhabi","ac","academy","accenture","accountant","accountants","aco","actor","ad","adac","ads","adult","ae","aeg","aero","aetna","af","afamilycompany","afl","africa","ag","agakhan","agency","ai","aig","aigo","airbus","airforce","airtel","akdn","al","alfaromeo","alibaba","alipay","allfinanz","allstate","ally","alsace","alstom","am","americanexpress","americanfamily","amex","amfam","amica","amsterdam","analytics","android","anquan","anz","ao","aol","apartments","app","apple","aq","aquarelle","ar","arab","aramco","archi","army","arpa","art","arte","as","asda","asia","associates","at","athleta","attorney","au","auction","audi","audible","audio","auspost","author","auto","autos","avianca","aw","aws","ax","axa","az","azure","ba","baby","baidu","banamex","bananarepublic","band","bank","bar","barcelona","barclaycard","barclays","barefoot","bargains","baseball","basketball","bauhaus","bayern","bb","bbc","bbt","bbva","bcg","bcn","bd","be","beats","beauty","beer","bentley","berlin","best","bestbuy","bet","bf","bg","bh","bharti","bi","bible","bid","bike","bing","bingo","bio","biz","bj","black","blackfriday","blockbuster","blog","bloomberg","blue","bm","bms","bmw","bn","bnpparibas","bo","boats","boehringer","bofa","bom","bond","boo","book","booking","bosch","bostik","boston","bot","boutique","box","br","bradesco","bridgestone","broadway","broker","brother","brussels","bs","bt","budapest","bugatti","build","builders","business","buy","buzz","bv","bw","by","bz","bzh","ca","cab","cafe","cal","call","calvinklein","cam","camera","camp","cancerresearch","canon","capetown","capital","capitalone","car","caravan","cards","care","career","careers","cars","casa","case","caseih","cash","casino","cat","catering","catholic","cba","cbn","cbre","cbs","cc","cd","ceb","center","ceo","cern","cf","cfa","cfd","cg","ch","chanel","channel","charity","chase","chat","cheap","chintai","christmas","chrome","church","ci","cipriani","circle","cisco","citadel","citi","citic","city","cityeats","ck","cl","claims","cleaning","click","clinic","clinique","clothing","cloud","club","clubmed","cm","cn","co","coach","codes","coffee","college","cologne","com","comcast","commbank","community","company","compare","computer","comsec","condos","construction","consulting","contact","contractors","cooking","cookingchannel","cool","coop","corsica","country","coupon","coupons","courses","cpa","cr","credit","creditcard","creditunion","cricket","crown","crs","cruise","cruises","csc","cu","cuisinella","cv","cw","cx","cy","cymru","cyou","cz","dabur","dad","dance","data","date","dating","datsun","day","dclk","dds","de","deal","dealer","deals","degree","delivery","dell","deloitte","delta","democrat","dental","dentist","desi","design","dev","dhl","diamonds","diet","digital","direct","directory","discount","discover","dish","diy","dj","dk","dm","dnp","do","docs","doctor","dog","domains","dot","download","drive","dtv","dubai","duck","dunlop","dupont","durban","dvag","dvr","dz","earth","eat","ec","eco","edeka","edu","education","ee","eg","email","emerck","energy","engineer","engineering","enterprises","epson","equipment","er","ericsson","erni","es","esq","estate","esurance","et","etisalat","eu","eurovision","eus","events","exchange","expert","exposed","express","extraspace","fage","fail","fairwinds","faith","family","fan","fans","farm","farmers","fashion","fast","fedex","feedback","ferrari","ferrero","fi","fiat","fidelity","fido","film","final","finance","financial","fire","firestone","firmdale","fish","fishing","fit","fitness","fj","fk","flickr","flights","flir","florist","flowers","fly","fm","fo","foo","food","foodnetwork","football","ford","forex","forsale","forum","foundation","fox","fr","free","fresenius","frl","frogans","frontdoor","frontier","ftr","fujitsu","fujixerox","fun","fund","furniture","futbol","fyi","ga","gal","gallery","gallo","gallup","game","games","gap","garden","gay","gb","gbiz","gd","gdn","ge","gea","gent","genting","george","gf","gg","ggee","gh","gi","gift","gifts","gives","giving","gl","glade","glass","gle","global","globo","gm","gmail","gmbh","gmo","gmx","gn","godaddy","gold","goldpoint","golf","goo","goodyear","goog","google","gop","got","gov","gp","gq","gr","grainger","graphics","gratis","green","gripe","grocery","group","gs","gt","gu","guardian","gucci","guge","guide","guitars","guru","gw","gy","hair","hamburg","hangout","haus","hbo","hdfc","hdfcbank","health","healthcare","help","helsinki","here","hermes","hgtv","hiphop","hisamitsu","hitachi","hiv","hk","hkt","hm","hn","hockey","holdings","holiday","homedepot","homegoods","homes","homesense","honda","horse","hospital","host","hosting","hot","hoteles","hotels","hotmail","house","how","hr","hsbc","ht","hu","hughes","hyatt","hyundai","ibm","icbc","ice","icu","id","ie","ieee","ifm","ikano","il","im","imamat","imdb","immo","immobilien","in","inc","industries","infiniti","info","ing","ink","institute","insurance","insure","int","intel","international","intuit","investments","io","ipiranga","iq","ir","irish","is","ismaili","ist","istanbul","it","itau","itv","iveco","jaguar","java","jcb","jcp","je","jeep","jetzt","jewelry","jio","jll","jm","jmp","jnj","jo","jobs","joburg","jot","joy","jp","jpmorgan","jprs","juegos","juniper","kaufen","kddi","ke","kerryhotels","kerrylogistics","kerryproperties","kfh","kg","kh","ki","kia","kim","kinder","kindle","kitchen","kiwi","km","kn","koeln","komatsu","kosher","kp","kpmg","kpn","kr","krd","kred","kuokgroup","kw","ky","kyoto","kz","la","lacaixa","lamborghini","lamer","lancaster","lancia","land","landrover","lanxess","lasalle","lat","latino","latrobe","law","lawyer","lb","lc","lds","lease","leclerc","lefrak","legal","lego","lexus","lgbt","li","liaison","lidl","life","lifeinsurance","lifestyle","lighting","like","lilly","limited","limo","lincoln","linde","link","lipsy","live","living","lixil","lk","llc","loan","loans","locker","locus","loft","lol","london","lotte","lotto","love","lpl","lplfinancial","lr","ls","lt","ltd","ltda","lu","lundbeck","lupin","luxe","luxury","lv","ly","ma","macys","madrid","maif","maison","makeup","man","management","mango","map","market","marketing","markets","marriott","marshalls","maserati","mattel","mba","mc","mckinsey","md","me","med","media","meet","melbourne","meme","memorial","men","menu","merckmsd","metlife","mg","mh","miami","microsoft","mil","mini","mint","mit","mitsubishi","mk","ml","mlb","mls","mm","mma","mn","mo","mobi","mobile","moda","moe","moi","mom","monash","money","monster","mormon","mortgage","moscow","moto","motorcycles","mov","movie","movistar","mp","mq","mr","ms","msd","mt","mtn","mtr","mu","museum","mutual","mv","mw","mx","my","mz","na","nab","nadex","nagoya","name","nationwide","natura","navy","nba","nc","ne","nec","net","netbank","netflix","network","neustar","new","newholland","news","next","nextdirect","nexus","nf","nfl","ng","ngo","nhk","ni","nico","nike","nikon","ninja","nissan","nissay","nl","no","nokia","northwesternmutual","norton","now","nowruz","nowtv","np","nr","nra","nrw","ntt","nu","nyc","nz","obi","observer","off","office","okinawa","olayan","olayangroup","oldnavy","ollo","om","omega","one","ong","onl","online","onyourside","ooo","open","oracle","orange","org","organic","origins","osaka","otsuka","ott","ovh","pa","page","panasonic","paris","pars","partners","parts","party","passagens","pay","pccw","pe","pet","pf","pfizer","pg","ph","pharmacy","phd","philips","phone","photo","photography","photos","physio","pics","pictet","pictures","pid","pin","ping","pink","pioneer","pizza","pk","pl","place","play","playstation","plumbing","plus","pm","pn","pnc","pohl","poker","politie","porn","post","pr","pramerica","praxi","press","prime","pro","prod","productions","prof","progressive","promo","properties","property","protection","pru","prudential","ps","pt","pub","pw","pwc","py","qa","qpon","quebec","quest","qvc","racing","radio","raid","re","read","realestate","realtor","realty","recipes","red","redstone","redumbrella","rehab","reise","reisen","reit","reliance","ren","rent","rentals","repair","report","republican","rest","restaurant","review","reviews","rexroth","rich","richardli","ricoh","rightathome","ril","rio","rip","rmit","ro","rocher","rocks","rodeo","rogers","room","rs","rsvp","ru","rugby","ruhr","run","rw","rwe","ryukyu","sa","saarland","safe","safety","sakura","sale","salon","samsclub","samsung","sandvik","sandvikcoromant","sanofi","sap","sarl","sas","save","saxo","sb","sbi","sbs","sc","sca","scb","schaeffler","schmidt","scholarships","school","schule","schwarz","science","scjohnson","scor","scot","sd","se","search","seat","secure","security","seek","select","sener","services","ses","seven","sew","sex","sexy","sfr","sg","sh","shangrila","sharp","shaw","shell","shia","shiksha","shoes","shop","shopping","shouji","show","showtime","shriram","si","silk","sina","singles","site","sj","sk","ski","skin","sky","skype","sl","sling","sm","smart","smile","sn","sncf","so","soccer","social","softbank","software","sohu","solar","solutions","song","sony","soy","space","sport","spot","spreadbetting","sr","srl","ss","st","stada","staples","star","statebank","statefarm","stc","stcgroup","stockholm","storage","store","stream","studio","study","style","su","sucks","supplies","supply","support","surf","surgery","suzuki","sv","swatch","swiftcover","swiss","sx","sy","sydney","symantec","systems","sz","tab","taipei","talk","taobao","target","tatamotors","tatar","tattoo","tax","taxi","tc","tci","td","tdk","team","tech","technology","tel","telefonica","temasek","tennis","teva","tf","tg","th","thd","theater","theatre","tiaa","tickets","tienda","tiffany","tips","tires","tirol","tj","tjmaxx","tjx","tk","tkmaxx","tl","tm","tmall","tn","to","today","tokyo","tools","top","toray","toshiba","total","tours","town","toyota","toys","tr","trade","trading","training","travel","travelchannel","travelers","travelersinsurance","trust","trv","tt","tube","tui","tunes","tushu","tv","tvs","tw","tz","ua","ubank","ubs","ug","uk","unicom","university","uno","uol","ups","us","uy","uz","va","vacations","vana","vanguard","vc","ve","vegas","ventures","verisign","versicherung","vet","vg","vi","viajes","video","vig","viking","villas","vin","vip","virgin","visa","vision","vistaprint","viva","vivo","vlaanderen","vn","vodka","volkswagen","volvo","vote","voting","voto","voyage","vu","vuelos","wales","walmart","walter","wang","wanggou","watch","watches","weather","weatherchannel","webcam","weber","website","wed","wedding","weibo","weir","wf","whoswho","wien","wiki","williamhill","win","windows","wine","winners","wme","wolterskluwer","woodside","work","works","world","wow","ws","wtc","wtf","xbox","xerox","xfinity","xihuan","xin","कॉम","セール","佛山","ಭಾರತ","慈善","集团","在线","한국","ଭାରତ","大众汽车","点看","คอม","ভাৰত","ভারত","八卦","موقع","বাংলা","公益","公司","香格里拉","网站","移动","我爱你","москва","қаз","католик","онлайн","сайт","联通","срб","бг","бел","קום","时尚","微博","淡马锡","ファッション","орг","नेट","ストア","삼성","சிங்கப்பூர்","商标","商店","商城","дети","мкд","ею","ポイント","新闻","工行","家電","كوم","中文网","中信","中国","中國","娱乐","谷歌","భారత్","ලංකා","電訊盈科","购物","クラウド","ભારત","通販","भारतम्","भारत","भारोत","网店","संगठन","餐厅","网络","ком","укр","香港","诺基亚","食品","飞利浦","台湾","台灣","手表","手机","мон","الجزائر","عمان","ارامكو","ایران","العليان","اتصالات","امارات","بازار","موريتانيا","پاکستان","الاردن","بارت","بھارت","المغرب","ابوظبي","السعودية","ڀارت","كاثوليك","سودان","همراه","عراق","مليسيا","澳門","닷컴","政府","شبكة","بيتك","عرب","გე","机构","组织机构","健康","ไทย","سورية","招聘","рус","рф","珠宝","تونس","大拿","みんな","グーグル","ευ","ελ","世界","書籍","ഭാരതം","ਭਾਰਤ","网址","닷넷","コム","天主教","游戏","vermögensberater","vermögensberatung","企业","信息","嘉里大酒店","嘉里","مصر","قطر","广东","இலங்கை","இந்தியா","հայ","新加坡","فلسطين","政务","xxx","xyz","yachts","yahoo","yamaxun","yandex","ye","yodobashi","yoga","yokohama","you","youtube","yt","yun","za","zappos","zara","zero","zip","zm","zone","zuerich","zw"]},wj3C:function(t,e,n){"use strict";n("sc67"),n("OeI1"),n("Ll4R"),n("n7j8"),n("Ggvi"),n("xJgp"),n("AqHK"),n("YbXK"),n("6kNP"),n("rzGZ"),n("Dq+y"),n("8npG"),n("pJf4"),n("R48M"),Object.defineProperty(e,"__esModule",{value:!0});var r,i,o=n("mrSG"),a=n("zVF4"),s=n("S+S0"),u=n("q/0M"),c=((r={})["no-app"]="No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()",r["bad-app-name"]="Illegal App name: '{$appName}",r["duplicate-app"]="Firebase App named '{$appName}' already exists",r["app-deleted"]="Firebase App named '{$appName}' already deleted",r["invalid-app-argument"]="firebase.{$appName}() takes either no argument or a Firebase App instance.",r),h=new a.ErrorFactory("app","Firebase",c),l="@firebase/app",f="0.5.0",p="[DEFAULT]",d=((i={})[l]="fire-core",i["@firebase/analytics"]="fire-analytics",i["@firebase/auth"]="fire-auth",i["@firebase/database"]="fire-rtdb",i["@firebase/functions"]="fire-fn",i["@firebase/installations"]="fire-iid",i["@firebase/messaging"]="fire-fcm",i["@firebase/performance"]="fire-perf",i["@firebase/remote-config"]="fire-rc",i["@firebase/storage"]="fire-gcs",i["@firebase/firestore"]="fire-fst",i["fire-js"]="fire-js",i["firebase-wrapper"]="fire-js-all",i),m=new u.Logger("@firebase/app"),y=function(){function t(t,e,n){var r,i,u=this;this.firebase_=n,this.isDeleted_=!1,this.name_=e.name,this.automaticDataCollectionEnabled_=e.automaticDataCollectionEnabled||!1,this.options_=a.deepCopy(t),this.container=new s.ComponentContainer(e.name),this._addComponent(new s.Component("app",(function(){return u}),"PUBLIC"));try{for(var c=o.__values(this.firebase_.INTERNAL.components.values()),h=c.next();!h.done;h=c.next()){var l=h.value;this._addComponent(l)}}catch(f){r={error:f}}finally{try{h&&!h.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}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(){return t.firebase_.INTERNAL.removeApp(t.name_),Promise.all(t.container.getProviders().map((function(t){return t.delete()})))})).then((function(){t.isDeleted_=!0}))},t.prototype._getService=function(t,e){return void 0===e&&(e=p),this.checkDestroyed_(),this.container.getProvider(t).getImmediate({identifier:e})},t.prototype._removeServiceInstance=function(t,e){void 0===e&&(e=p),this.container.getProvider(t).clearInstance(e)},t.prototype._addComponent=function(t){try{this.container.addComponent(t)}catch(e){m.debug("Component "+t.name+" failed to register with FirebaseApp "+this.name,e)}},t.prototype._addOrOverwriteComponent=function(t){this.container.addOrOverwriteComponent(t)},t.prototype.checkDestroyed_=function(){if(this.isDeleted_)throw h.create("app-deleted",{appName:this.name_})},t}();y.prototype.name&&y.prototype.options||y.prototype.delete||console.log("dc");var g="7.6.0";var v=function t(){var e=function(t){var e={},n=new Map,r={__esModule:!0,initializeApp:function(n,i){void 0===i&&(i={});if("object"!=typeof i||null===i){i={name:i}}var o=i;void 0===o.name&&(o.name=p);var s=o.name;if("string"!=typeof s||!s)throw h.create("bad-app-name",{appName:String(s)});if(a.contains(e,s))throw h.create("duplicate-app",{appName:s});var u=new t(n,o,r);return e[s]=u,u},app:i,registerVersion:function(t,e,n){var r,i=null!==(r=d[t])&&void 0!==r?r:t;n&&(i+="-"+n);var o=i.match(/\s|\//),a=e.match(/\s|\//);if(o||a){var c=['Unable to register library "'+i+'" with version "'+e+'":'];return o&&c.push('library name "'+i+'" contains illegal characters (whitespace or "/")'),o&&a&&c.push("and"),a&&c.push('version name "'+e+'" contains illegal characters (whitespace or "/")'),void m.warn(c.join(" "))}u(new s.Component(i+"-version",(function(){return{library:i,version:e}}),"VERSION"))},apps:null,SDK_VERSION:g,INTERNAL:{registerComponent:u,removeApp:function(t){delete e[t]},components:n,useAsService:function(t,e){if("serverAuth"===e)return null;return e}}};function i(t){if(t=t||p,!a.contains(e,t))throw h.create("no-app",{appName:t});return e[t]}function u(s){var u,c,l=s.name;if(n.has(l))return m.debug("There were multiple attempts to register component "+l+"."),"PUBLIC"===s.type?r[l]:null;if(n.set(l,s),"PUBLIC"===s.type){var f=function(t){if(void 0===t&&(t=i()),"function"!=typeof t[l])throw h.create("invalid-app-argument",{appName:l});return t[l]()};void 0!==s.serviceProps&&a.deepExtend(f,s.serviceProps),r[l]=f,t.prototype[l]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this._getService.bind(this,l);return n.apply(this,s.multipleInstances?t:[])}}try{for(var p=o.__values(Object.keys(e)),d=p.next();!d.done;d=p.next()){var y=d.value;e[y]._addComponent(s)}}catch(g){u={error:g}}finally{try{d&&!d.done&&(c=p.return)&&c.call(p)}finally{if(u)throw u.error}}return"PUBLIC"===s.type?r[l]:null}return r.default=r,Object.defineProperty(r,"apps",{get:function(){return Object.keys(e).map((function(t){return e[t]}))}}),i.App=t,r}(y);return e.INTERNAL=o.__assign(o.__assign({},e.INTERNAL),{createFirebaseNamespace:t,extendNamespace:function(t){a.deepExtend(e,t)},createSubscribe:a.createSubscribe,ErrorFactory:a.ErrorFactory,deepExtend:a.deepExtend}),e}(),_=function(){function t(t){this.container=t}return t.prototype.getPlatformInfoString=function(){return this.container.getProviders().map((function(t){if(function(t){var e,n=t.getComponent();return"VERSION"===(null===(e=n)||void 0===e?void 0:e.type)}(t)){var e=t.getImmediate();return e.library+"/"+e.version}return null})).filter((function(t){return t})).join(" ")},t}();if(a.isBrowser()&&void 0!==self.firebase){m.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n ");var b=self.firebase.SDK_VERSION;b&&b.indexOf("LITE")>=0&&m.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n ")}var w=v.initializeApp;v.initializeApp=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return a.isNode()&&m.warn('\n Warning: This is a browser-targeted Firebase bundle but it appears it is being\n run in a Node environment. If running in a Node environment, make sure you\n are using the bundle specified by the "main" field in package.json.\n \n If you are using Webpack, you can specify "main" as the first item in\n "resolve.mainFields":\n https://webpack.js.org/configuration/resolve/#resolvemainfields\n \n If using Rollup, use the rollup-plugin-node-resolve plugin and specify "main"\n as the first item in "mainFields", e.g. [\'main\', \'module\'].\n https://github.com/rollup/rollup-plugin-node-resolve\n '),w.apply(void 0,t)};var E=v;!function(t,e){t.INTERNAL.registerComponent(new s.Component("platform-logger",(function(t){return new _(t)}),"PRIVATE")),t.registerVersion(l,f,e),t.registerVersion("fire-js","")}(E),e.default=E,e.firebase=E},x7I3:function(t,e,n){"use strict";n.r(e),function(t){n.d(e,"ErrorCode",(function(){return cr})),n.d(e,"EventType",(function(){return hr})),n.d(e,"WebChannel",(function(){return lr})),n.d(e,"XhrIo",(function(){return fr})),n.d(e,"createWebChannelTransport",(function(){return ur}));n("lFjb"),n("Ll4R"),n("sC2a"),n("R48M"),n("YBKJ"),n("HXzo"),n("JHok"),n("1dPr"),n("sc67"),n("n7j8"),n("q8oJ"),n("C9fy"),n("8npG"),n("HQhv");var r,i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},o=o||{},a=i;function s(t){return"string"==typeof t}function u(t){return"number"==typeof t}function c(t,e){t=t.split("."),e=e||a;for(var n=0;n<t.length;n++)if(null==(e=e[t[n]]))return null;return e}function h(){}function l(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 f(t){return"array"==l(t)}function p(t){var e=l(t);return"array"==e||"object"==e&&"number"==typeof t.length}function d(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var m="closure_uid_"+(1e9*Math.random()>>>0),y=0;function g(t,e,n){return t.call.apply(t.bind,arguments)}function v(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 _(t,e,n){return(_=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?g:v).apply(null,arguments)}function b(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 w=Date.now||function(){return+new Date};function E(t,e){function n(){}n.prototype=e.prototype,t.N=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.xb=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(){this.j=this.j,this.i=this.i}T.prototype.j=!1,T.prototype.la=function(){if(!this.j&&(this.j=!0,this.G(),0))this[m]||(this[m]=++y)},T.prototype.G=function(){if(this.i)for(;this.i.length;)this.i.shift()()};var C=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(s(t))return s(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},S=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i=s(t)?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)};function I(t){return Array.prototype.concat.apply([],arguments)}function D(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 N(t){return/^[\s\xa0]*$/.test(t)}var A,k=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function R(t,e){return-1!=t.indexOf(e)}function O(t,e){return t<e?-1:t>e?1:0}t:{var x=a.navigator;if(x){var P=x.userAgent;if(P){A=P;break t}}A=""}function M(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function L(t){var e,n={};for(e in t)n[e]=t[e];return n}var F="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function U(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<F.length;o++)n=F[o],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function q(t){return q[" "](t),t}q[" "]=h;var V,B,j=R(A,"Opera"),z=R(A,"Trident")||R(A,"MSIE"),W=R(A,"Edge"),Q=W||z,K=R(A,"Gecko")&&!(R(A.toLowerCase(),"webkit")&&!R(A,"Edge"))&&!(R(A,"Trident")||R(A,"MSIE"))&&!R(A,"Edge"),H=R(A.toLowerCase(),"webkit")&&!R(A,"Edge");function G(){var t=a.document;return t?t.documentMode:void 0}t:{var Y="",X=(B=A,K?/rv:([^\);]+)(\)|;)/.exec(B):W?/Edge\/([\d\.]+)/.exec(B):z?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(B):H?/WebKit\/(\S+)/.exec(B):j?/(?:Version)[ \/]?(\S+)/.exec(B):void 0);if(X&&(Y=X?X[1]:""),z){var J=G();if(null!=J&&J>parseFloat(Y)){V=String(J);break t}}V=Y}var Z,$={};function tt(t){return function(t,e){var n=$;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(t,(function(){for(var e=0,n=k(String(V)).split("."),r=k(String(t)).split("."),i=Math.max(n.length,r.length),o=0;0==e&&o<i;o++){var a=n[o]||"",s=r[o]||"";do{if(a=/(\d*)(\D*)(.*)/.exec(a)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],0==a[0].length&&0==s[0].length)break;e=O(0==a[1].length?0:parseInt(a[1],10),0==s[1].length?0:parseInt(s[1],10))||O(0==a[2].length,0==s[2].length)||O(a[2],s[2]),a=a[3],s=s[3]}while(0==e)}return 0<=e}))}var et=a.document;Z=et&&z?G()||("CSS1Compat"==et.compatMode?parseInt(V,10):5):void 0;var nt=!z||9<=Number(Z),rt=z&&!tt("9"),it=function(){if(!a.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{a.addEventListener("test",h,e),a.removeEventListener("test",h,e)}catch(n){}return t}();function ot(t,e){this.type=t,this.a=this.target=e,this.Ia=!0}function at(t,e){if(ot.call(this,t?t.type:""),this.relatedTarget=this.a=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.pointerId=0,this.pointerType="",this.c=null,t){var n=this.type=t.type,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.a=e,e=t.relatedTarget){if(K){t:{try{q(e.nodeName);var i=!0;break t}catch(o){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,r?(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.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.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=s(t.pointerType)?t.pointerType:st[t.pointerType]||"",this.c=t,t.defaultPrevented&&this.b()}}ot.prototype.b=function(){this.Ia=!1},E(at,ot);var st={2:"touch",3:"pen",4:"mouse"};at.prototype.b=function(){at.N.b.call(this);var t=this.c;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,rt)try{(t.ctrlKey||112<=t.keyCode&&123>=t.keyCode)&&(t.keyCode=-1)}catch(e){}};var ut="closure_listenable_"+(1e6*Math.random()|0),ct=0;function ht(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.da=i,this.key=++ct,this.X=this.Z=!1}function lt(t){t.X=!0,t.listener=null,t.proxy=null,t.src=null,t.da=null}function ft(t){this.src=t,this.a={},this.b=0}function pt(t,e){var n=e.type;if(n in t.a){var r,i=t.a[n],o=C(i,e);(r=0<=o)&&Array.prototype.splice.call(i,o,1),r&&(lt(e),0==t.a[n].length&&(delete t.a[n],t.b--))}}function dt(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i];if(!o.X&&o.listener==e&&o.capture==!!n&&o.da==r)return i}return-1}ft.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var a=dt(t,e,r,i);return-1<a?(e=t[a],n||(e.Z=!1)):((e=new ht(e,this.src,o,!!r,i)).Z=n,t.push(e)),e};var mt="closure_lm_"+(1e6*Math.random()|0),yt={};function gt(t,e,n,r,i){if(r&&r.once)return function t(e,n,r,i,o){if(f(n)){for(var a=0;a<n.length;a++)t(e,n[a],r,i,o);return null}return r=St(r),e&&e[ut]?e.Aa(n,r,d(i)?!!i.capture:!!i,o):vt(e,n,r,!0,i,o)}(t,e,n,r,i);if(f(e)){for(var o=0;o<e.length;o++)gt(t,e[o],n,r,i);return null}return n=St(n),t&&t[ut]?t.za(e,n,d(r)?!!r.capture:!!r,i):vt(t,e,n,!1,r,i)}function vt(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var a=d(i)?!!i.capture:!!i;if(a&&!nt)return null;var s=Tt(t);if(s||(t[mt]=s=new ft(t)),(n=s.add(e,n,r,a,o)).proxy)return n;if(r=function(){var t=Et,e=nt?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)it||(i=a),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(bt(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function _t(t){if(!u(t)&&t&&!t.X){var e=t.src;if(e&&e[ut])pt(e.c,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(bt(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=Tt(e))?(pt(n,t),0==n.b&&(n.src=null,e[mt]=null)):lt(t)}}}function bt(t){return t in yt?yt[t]:yt[t]="on"+t}function wt(t,e){var n=t.listener,r=t.da||t.src;return t.Z&&_t(t),n.call(r,e)}function Et(t,e){return!!t.X||(nt?wt(t,new at(e,this)):wt(t,e=new at(e||c("window.event"),this)))}function Tt(t){return(t=t[mt])instanceof ft?t:null}var Ct="__closure_events_fn_"+(1e9*Math.random()>>>0);function St(t){return"function"==l(t)?t:(t[Ct]||(t[Ct]=function(e){return t.handleEvent(e)}),t[Ct])}function It(){T.call(this),this.c=new ft(this),this.J=this,this.B=null}function Dt(t,e,n,r){if(!(e=t.c.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;o<e.length;++o){var a=e[o];if(a&&!a.X&&a.capture==n){var s=a.listener,u=a.da||a.src;a.Z&&pt(t.c,a),i=!1!==s.call(u,r)&&i}}return i&&0!=r.Ia}E(It,T),It.prototype[ut]=!0,(r=It.prototype).addEventListener=function(t,e,n,r){gt(this,t,e,n,r)},r.removeEventListener=function(t,e,n,r){!function t(e,n,r,i,o){if(f(n))for(var a=0;a<n.length;a++)t(e,n[a],r,i,o);else i=d(i)?!!i.capture:!!i,r=St(r),e&&e[ut]?(e=e.c,(n=String(n).toString())in e.a&&(-1<(r=dt(a=e.a[n],r,i,o))&&(lt(a[r]),Array.prototype.splice.call(a,r,1),0==a.length&&(delete e.a[n],e.b--)))):e&&(e=Tt(e))&&(n=e.a[n.toString()],e=-1,n&&(e=dt(n,r,i,o)),(r=-1<e?n[e]:null)&&_t(r))}(this,t,e,n,r)},r.dispatchEvent=function(t){var e,n=this.B;if(n)for(e=[];n;n=n.B)e.push(n);n=this.J;var r=t.type||t;if(s(t))t=new ot(t,n);else if(t instanceof ot)t.target=t.target||n;else{var i=t;U(t=new ot(r,n),i)}if(i=!0,e)for(var o=e.length-1;0<=o;o--){var a=t.a=e[o];i=Dt(a,r,!0,t)&&i}if(i=Dt(a=t.a=n,r,!0,t)&&i,i=Dt(a,r,!1,t)&&i,e)for(o=0;o<e.length;o++)i=Dt(a=t.a=e[o],r,!1,t)&&i;return i},r.G=function(){if(It.N.G.call(this),this.c){var t,e=this.c;for(t in e.a){for(var n=e.a[t],r=0;r<n.length;r++)lt(n[r]);delete e.a[t],e.b--}}this.B=null},r.za=function(t,e,n,r){return this.c.add(String(t),e,!1,n,r)},r.Aa=function(t,e,n,r){return this.c.add(String(t),e,!0,n,r)};var Nt=a.JSON.stringify;function At(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function kt(){this.b=this.a=null}At.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 Rt,Ot=new At((function(){return new Pt}),(function(t){t.reset()}));function xt(){var t=Ut,e=null;return t.a&&(e=t.a,t.a=t.a.next,t.a||(t.b=null),e.next=null),e}function Pt(){this.next=this.b=this.a=null}function Mt(t){a.setTimeout((function(){throw t}),0)}function Lt(t,e){Rt||function(){var t=a.Promise.resolve(void 0);Rt=function(){t.then(qt)}}(),Ft||(Rt(),Ft=!0),Ut.add(t,e)}kt.prototype.add=function(t,e){var n=Ot.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},Pt.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null},Pt.prototype.reset=function(){this.next=this.b=this.a=null};var Ft=!1,Ut=new kt;function qt(){for(var t;t=xt();){try{t.a.call(t.b)}catch(n){Mt(n)}var e=Ot;e.f(t),100>e.b&&(e.b++,t.next=e.a,e.a=t)}Ft=!1}function Vt(t,e){It.call(this),this.b=t||1,this.a=e||a,this.f=_(this.fb,this),this.g=w()}function Bt(t){t.ba=!1,t.L&&(t.a.clearTimeout(t.L),t.L=null)}function jt(t,e,n){if("function"==l(t))n&&(t=_(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=_(t.handleEvent,t)}return 2147483647<Number(e)?-1:a.setTimeout(t,e||0)}function zt(t,e,n){T.call(this),this.f=null!=n?_(t,n):t,this.c=e,this.b=_(this.$a,this),this.a=[]}function Wt(t){t.U=jt(t.b,t.c),t.f.apply(null,t.a)}function Qt(t){T.call(this),this.b=t,this.a={}}E(Vt,It),(r=Vt.prototype).ba=!1,r.L=null,r.fb=function(){if(this.ba){var t=w()-this.g;0<t&&t<.8*this.b?this.L=this.a.setTimeout(this.f,this.b-t):(this.L&&(this.a.clearTimeout(this.L),this.L=null),this.dispatchEvent("tick"),this.ba&&(Bt(this),this.start()))}},r.start=function(){this.ba=!0,this.L||(this.L=this.a.setTimeout(this.f,this.b),this.g=w())},r.G=function(){Vt.N.G.call(this),Bt(this),delete this.a},E(zt,T),(r=zt.prototype).ea=!1,r.U=null,r.Ta=function(t){this.a=arguments,this.U?this.ea=!0:Wt(this)},r.G=function(){zt.N.G.call(this),this.U&&(a.clearTimeout(this.U),this.U=null,this.ea=!1,this.a=[])},r.$a=function(){this.U=null,this.ea&&(this.ea=!1,Wt(this))},E(Qt,T);var Kt=[];function Ht(t,e,n,r){f(n)||(n&&(Kt[0]=n.toString()),n=Kt);for(var i=0;i<n.length;i++){var o=gt(e,n[i],r||t.handleEvent,!1,t.b||t);if(!o)break;t.a[o.key]=o}}function Gt(t){M(t.a,(function(t,e){this.a.hasOwnProperty(e)&&_t(t)}),t),t.a={}}function Yt(){}Qt.prototype.G=function(){Qt.N.G.call(this),Gt(this)},Qt.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Xt=new It;function Jt(t){ot.call(this,"serverreachability",t)}function Zt(t){Xt.dispatchEvent(new Jt(Xt,t))}function $t(t){ot.call(this,"statevent",t)}function te(t){Xt.dispatchEvent(new $t(Xt,t))}function ee(t){ot.call(this,"timingevent",t)}function ne(t,e){if("function"!=l(t))throw Error("Fn must not be null and must be a function");return a.setTimeout((function(){t()}),e)}E(Jt,ot),E($t,ot),E(ee,ot);var re={NO_ERROR:0,gb:1,nb:2,mb:3,jb:4,lb:5,ob:6,La:7,TIMEOUT:8,rb:9},ie={ib:"complete",vb:"success",Ma:"error",La:"abort",tb:"ready",ub:"readystatechange",TIMEOUT:"timeout",pb:"incrementaldata",sb:"progress",kb:"downloadprogress",wb:"uploadprogress"};function oe(){}function ae(t){var e;return(e=t.a)||(e=t.a={}),e}function se(){}oe.prototype.a=null;var ue,ce={OPEN:"a",hb:"b",Ma:"c",qb:"d"};function he(){ot.call(this,"d")}function le(){ot.call(this,"c")}function fe(){}function pe(t,e,n){this.g=t,this.W=e,this.V=n||1,this.I=new Qt(this),this.O=de,t=Q?125:void 0,this.P=new Vt(t),this.h=null,this.b=!1,this.l=this.D=this.f=this.F=this.v=this.R=this.i=null,this.j=[],this.a=null,this.A=0,this.c=this.w=null,this.o=-1,this.m=!1,this.J=0,this.B=null,this.s=this.S=this.H=!1}E(he,ot),E(le,ot),E(fe,oe),ue=new fe;var de=45e3,me={},ye={};function ge(t,e,n){t.F=1,t.f=je(Me(e)),t.l=n,t.H=!0,_e(t,null)}function ve(t,e,n,r){t.F=1,t.f=je(Me(e)),t.l=null,t.H=n,_e(t,r)}function _e(t,e){t.v=w(),Ee(t),t.D=Me(t.f),Be(t.D,"t",t.V),t.A=0,t.a=t.g.$(t.g.Y()?e:null),0<t.J&&(t.B=new zt(_(t.Ja,t,t.a),t.J)),Ht(t.I,t.a,"readystatechange",t.cb),e=t.h?L(t.h):{},t.l?(t.w||(t.w="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.a.ca(t.D,t.w,t.l,e)):(t.w="GET",t.a.ca(t.D,t.w,null,e)),Zt(1)}function be(t,e,n){for(var r=!0;!t.m&&t.A<n.length;){var i=we(t,n);if(i==ye){4==e&&(t.c=4,te(14),r=!1);break}if(i==me){t.c=4,te(15),r=!1;break}De(t,i)}4==e&&0==n.length&&(t.c=1,te(16),r=!1),t.b=t.b&&r,r||(Ie(t),Se(t))}function we(t,e){var n=t.A,r=e.indexOf("\n",n);return-1==r?ye:(n=Number(e.substring(n,r)),isNaN(n)?me:(r+=1)+n>e.length?ye:(e=e.substr(r,n),t.A=r+n,e))}function Ee(t){t.R=w()+t.O,Te(t,t.O)}function Te(t,e){if(null!=t.i)throw Error("WatchDog timer not null");t.i=ne(_(t.ab,t),e)}function Ce(t){t.i&&(a.clearTimeout(t.i),t.i=null)}function Se(t){t.g.Ca()||t.m||t.g.na(t)}function Ie(t){Ce(t);var e=t.B;e&&"function"==typeof e.la&&e.la(),t.B=null,Bt(t.P),Gt(t.I),t.a&&(e=t.a,t.a=null,e.abort(),e.la())}function De(t,e){try{t.g.Fa(t,e),Zt(4)}catch(n){}}function Ne(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(p(t)||s(t))S(t,e,void 0);else{if(t.K&&"function"==typeof t.K)var n=t.K();else if(t.C&&"function"==typeof t.C)n=void 0;else if(p(t)||s(t)){n=[];for(var r=t.length,i=0;i<r;i++)n.push(i)}else for(i in n=[],r=0,t)n[r++]=i;i=(r=function(t){if(t.C&&"function"==typeof t.C)return t.C();if(s(t))return t.split("");if(p(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t)).length;for(var o=0;o<i;o++)e.call(void 0,r[o],n&&n[o],t)}}function Ae(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 Ae)for(n=t.K(),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 ke(t,e){Oe(t.b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&Re(t))}function Re(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];Oe(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;)Oe(i,r=t.a[e])||(t.a[n++]=r,i[r]=1),e++;t.a.length=n}}function Oe(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(r=pe.prototype).setTimeout=function(t){this.O=t},r.cb=function(t){t=t.target;var e=this.B;e&&3==Mn(t)?e.Ta():this.Ja(t)},r.Ja=function(t){try{if(t==this.a)t:{var e=Mn(this.a),n=this.a.ya(),r=this.a.T();if(!(3>e||3==e&&!Q&&!this.a.aa())){this.m||4!=e||7==n||Zt(8==n||0>=r?3:2),Ce(this);var i=this.a.T();this.o=i;var o=this.a.aa();if(this.b=200==i){if(this.S&&!this.s){e:{if(this.a){var a=Ln(this.a,"X-HTTP-Initial-Response");if(a&&!N(a)){var s=a;break e}}s=null}if(!s){this.b=!1,this.c=3,te(12),Ie(this),Se(this);break t}this.s=!0,De(this,s)}this.H?(be(this,e,o),Q&&this.b&&3==e&&(Ht(this.I,this.P,"tick",this.bb),this.P.start())):De(this,o),4==e&&Ie(this),this.b&&!this.m&&(4==e?this.g.na(this):(this.b=!1,Ee(this)))}else 400==i&&0<o.indexOf("Unknown SID")?(this.c=3,te(12)):(this.c=0,te(13)),Ie(this),Se(this)}}}catch(u){}},r.bb=function(){if(this.a){var t=Mn(this.a),e=this.a.aa();this.A<e.length&&(Ce(this),be(this,t,e),this.b&&4!=t&&Ee(this))}},r.cancel=function(){this.m=!0,Ie(this)},r.ab=function(){this.i=null;var t=w();0<=t-this.R?(2!=this.F&&(Zt(3),te(17)),Ie(this),this.c=2,Se(this)):Te(this,this.R-t)},(r=Ae.prototype).C=function(){Re(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},r.K=function(){return Re(this),this.a.concat()},r.get=function(t,e){return Oe(this.b,t)?this.b[t]:e},r.set=function(t,e){Oe(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},r.forEach=function(t,e){for(var n=this.K(),r=0;r<n.length;r++){var i=n[r],o=this.get(i);t.call(e,o,i,this)}};var xe=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Pe(t,e){var n;this.b=this.j=this.f="",this.i=null,this.g=this.a="",this.h=!1,t instanceof Pe?(this.h=void 0!==e?e:t.h,Le(this,t.f),this.j=t.j,Fe(this,t.b),Ue(this,t.i),this.a=t.a,qe(this,nn(t.c)),this.g=t.g):t&&(n=String(t).match(xe))?(this.h=!!e,Le(this,n[1]||"",!0),this.j=ze(n[2]||""),Fe(this,n[3]||"",!0),Ue(this,n[4]),this.a=ze(n[5]||"",!0),qe(this,n[6]||"",!0),this.g=ze(n[7]||"")):(this.h=!!e,this.c=new Je(null,this.h))}function Me(t){return new Pe(t)}function Le(t,e,n){t.f=n?ze(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function Fe(t,e,n){t.b=n?ze(e,!0):e}function Ue(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 qe(t,e,n){e instanceof Je?(t.c=e,function(t,e){e&&!t.f&&(Ze(t),t.c=null,t.a.forEach((function(t,e){var n=e.toLowerCase();e!=n&&($e(this,e),en(this,n,t))}),t)),t.f=e}(t.c,t.h)):(n||(e=We(e,Ye)),t.c=new Je(e,t.h))}function Ve(t,e,n){t.c.set(e,n)}function Be(t,e,n){f(n)||(n=[String(n)]),en(t.c,e,n)}function je(t){return Ve(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^w()).toString(36)),t}function ze(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function We(t,e,n){return s(t)?(t=encodeURI(t).replace(e,Qe),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function Qe(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}Pe.prototype.toString=function(){var t=[],e=this.f;e&&t.push(We(e,Ke,!0),":");var n=this.b;return(n||"file"==e)&&(t.push("//"),(e=this.j)&&t.push(We(e,Ke,!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.a)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(We(n,"/"==n.charAt(0)?Ge:He,!0))),(n=this.c.toString())&&t.push("?",n),(n=this.g)&&t.push("#",We(n,Xe)),t.join("")},Pe.prototype.resolve=function(t){var e=Me(this),n=!!t.f;n?Le(e,t.f):n=!!t.j,n?e.j=t.j:n=!!t.b,n?Fe(e,t.b):n=null!=t.i;var r=t.a;if(n)Ue(e,t.i);else if(n=!!t.a){if("/"!=r.charAt(0))if(this.b&&!this.a)r="/"+r;else{var i=e.a.lastIndexOf("/");-1!=i&&(r=e.a.substr(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(R(i,"./")||R(i,"/.")){r=0==i.lastIndexOf("/",0),i=i.split("/");for(var o=[],a=0;a<i.length;){var s=i[a++];"."==s?r&&a==i.length&&o.push(""):".."==s?((1<o.length||1==o.length&&""!=o[0])&&o.pop(),r&&a==i.length&&o.push("")):(o.push(s),r=!0)}r=o.join("/")}else r=i}return n?e.a=r:n=""!==t.c.toString(),n?qe(e,nn(t.c)):n=!!t.g,n&&(e.g=t.g),e};var Ke=/[#\/\?@]/g,He=/[#\?:]/g,Ge=/[#\?]/g,Ye=/[#\?@]/g,Xe=/#/g;function Je(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function Ze(t){t.a||(t.a=new Ae,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 $e(t,e){Ze(t),e=rn(t,e),Oe(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,ke(t.a,e))}function tn(t,e){return Ze(t),e=rn(t,e),Oe(t.a.b,e)}function en(t,e,n){$e(t,e),0<n.length&&(t.c=null,t.a.set(rn(t,e),D(n)),t.b+=n.length)}function nn(t){var e=new Je;return e.c=t.c,t.a&&(e.a=new Ae(t.a),e.b=t.b),e}function rn(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}function on(t){this.a=t,this.b=this.h=null,this.g=!1,this.i=null,this.c=-1,this.l=this.f=null}function an(t){var e=t.a.F.a;if(null!=e)te(4),e?(te(10),Gn(t.a,t,!1)):(te(11),Gn(t.a,t,!0));else{t.b=new pe(t,void 0,void 0),t.b.h=t.h,e=$n(e=t.a,e.Y()?t.f:null,t.i),te(4),Be(e,"TYPE","xmlhttp");var n=t.a.j,r=t.a.I;n&&r&&Ve(e,n,r),ve(t.b,e,!1,t.f)}}function sn(){this.a=this.b=null}function un(){this.a=new Ae}function cn(t){var e=typeof t;return"object"==e&&t||"function"==e?"o"+(t[m]||(t[m]=++y)):e.charAt(0)+t}function hn(t,e){this.b=t,this.a=e}function ln(t){this.g=t||fn,a.PerformanceNavigationTiming?t=0<(t=a.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):t=!!(a.ka&&a.ka.Da&&a.ka.Da()&&a.ka.Da().yb),this.f=t?this.g:1,this.a=null,1<this.f&&(this.a=new un),this.b=null,this.c=[]}(r=Je.prototype).add=function(t,e){Ze(this),this.c=null,t=rn(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},r.forEach=function(t,e){Ze(this),this.a.forEach((function(n,r){S(n,(function(n){t.call(e,n,r,this)}),this)}),this)},r.K=function(){Ze(this);for(var t=this.a.C(),e=this.a.K(),n=[],r=0;r<e.length;r++)for(var i=t[r],o=0;o<i.length;o++)n.push(e[r]);return n},r.C=function(t){Ze(this);var e=[];if(s(t))tn(this,t)&&(e=I(e,this.a.get(rn(this,t))));else{t=this.a.C();for(var n=0;n<t.length;n++)e=I(e,t[n])}return e},r.set=function(t,e){return Ze(this),this.c=null,tn(this,t=rn(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},r.get=function(t,e){return t&&0<(t=this.C(t)).length?String(t[0]):e},r.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var t=[],e=this.a.K(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.C(r);for(var o=0;o<r.length;o++){var a=i;""!==r[o]&&(a+="="+encodeURIComponent(String(r[o]))),t.push(a)}}return this.c=t.join("&")},E((function(){}),(function(){})),(r=on.prototype).M=null,r.$=function(t){return this.a.$(t)},r.abort=function(){this.b&&(this.b.cancel(),this.b=null),this.c=-1},r.Ca=function(){return!1},r.Fa=function(t,e){if(this.c=t.o,0==this.M){if(!this.a.o&&(t=t.a)){var n=Ln(t,"X-Client-Wire-Protocol");this.l=n||null,this.a.j&&(t=Ln(t,"X-HTTP-Session-Id"))&&(this.a.I=t)}if(e){try{var r=this.a.ja.a.parse(e)}catch(i){return(e=this.a).m=this.c,void Jn(e,2)}this.f=r[0]}else(e=this.a).m=this.c,Jn(e,2)}else 1==this.M&&(this.g?te(6):"11111"==e?(te(5),this.g=!0,(!z||10<=Number(Z))&&(this.c=200,this.b.cancel(),te(11),Gn(this.a,this,!0))):(te(7),this.g=!1))},r.na=function(){if(this.c=this.b.o,this.b.b)0==this.M?(this.M=1,an(this)):1==this.M&&(this.g?(te(11),Gn(this.a,this,!0)):(te(10),Gn(this.a,this,!1)));else{0==this.M?te(8):1==this.M&&te(9);var t=this.a;t.m=this.c,Jn(t,2)}},r.Y=function(){return this.a.Y()},r.ma=function(){return this.a.ma()},un.prototype.add=function(t){this.a.set(cn(t),t)},un.prototype.C=function(){return this.a.C()};var fn=10;function pn(t,e){!t.a&&(R(e,"spdy")||R(e,"quic")||R(e,"h2"))&&(t.f=t.g,t.a=new un,t.b&&(gn(t,t.b),t.b=null))}function dn(t){return!!t.b||!!t.a&&t.a.a.c>=t.f}function mn(t){return t.b?1:t.a?t.a.a.c:0}function yn(t,e){return t.b?t=t.b==e:t.a?(e=cn(e),t=Oe(t.a.a.b,e)):t=!1,t}function gn(t,e){t.a?t.a.add(e):t.b=e}function vn(t,e){var n;t.b&&t.b==e?t.b=null:((n=t.a)&&(n=cn(e),n=Oe(t.a.a.b,n)),n&&ke(t.a.a,cn(e)))}function _n(t){if(null!=t.b)return t.c.concat(t.b.j);if(null!=t.a&&0!=t.a.a.c){var e=t.c;return S(t.a.C(),(function(t){e=e.concat(t.j)})),e}return D(t.c)}function bn(){}function wn(){this.a=new bn}function En(t,e,n){var r=n||"";try{Ne(t,(function(t,n){var i=t;d(t)&&(i=Nt(t)),e.push(r+n+"="+encodeURIComponent(i))}))}catch(i){throw e.push(r+"type="+encodeURIComponent("_badmap")),i}}function Tn(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(o){}}ln.prototype.cancel=function(){this.c=_n(this),this.b?(this.b.cancel(),this.b=null):this.a&&0!=this.a.a.c&&(S(this.a.C(),(function(t){t.cancel()})),function(t){t.b={},t.a.length=0,t.c=0}(this.a.a))},bn.prototype.stringify=function(t){return a.JSON.stringify(t,void 0)},bn.prototype.parse=function(t){return a.JSON.parse(t,void 0)};var Cn=a.JSON.parse;function Sn(t){It.call(this),this.headers=new Ae,this.H=t||null,this.b=!1,this.s=this.a=null,this.A="",this.h=0,this.f="",this.g=this.w=this.l=this.v=!1,this.o=0,this.m=null,this.I=In,this.D=this.F=!1}E(Sn,It);var In="",Dn=/^https?$/i,Nn=["POST","PUT"];function An(t){return"content-type"==t.toLowerCase()}function kn(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,Rn(t),xn(t)}function Rn(t){t.v||(t.v=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function On(t){if(t.b&&void 0!==o&&(!t.s[1]||4!=Mn(t)||2!=t.T()))if(t.l&&4==Mn(t))jt(t.Ea,0,t);else if(t.dispatchEvent("readystatechange"),4==Mn(t)){t.b=!1;try{var e,n=t.T();t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(e=r)){var i;if(i=0===n){var s=String(t.A).match(xe)[1]||null;if(!s&&a.self&&a.self.location){var u=a.self.location.protocol;s=u.substr(0,u.length-1)}i=!Dn.test(s?s.toLowerCase():"")}e=i}if(e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{t.h=6;try{var c=2<Mn(t)?t.a.statusText:""}catch(h){c=""}t.f=c+" ["+t.T()+"]",Rn(t)}}finally{xn(t)}}}function xn(t,e){if(t.a){Pn(t);var n=t.a,r=t.s[0]?h:null;t.a=null,t.s=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(i){}}}function Pn(t){t.a&&t.D&&(t.a.ontimeout=null),t.m&&(a.clearTimeout(t.m),t.m=null)}function Mn(t){return t.a?t.a.readyState:0}function Ln(t,e){return t.a?t.a.getResponseHeader(e):null}function Fn(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 M(t,(function(t,n){e+=n,e+=":",e+=t,e+="\r\n"})),e}(n),s(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 Ve(t,e,n),t}function Un(t){this.f=[],this.F=new sn,this.ga=this.pa=this.B=this.ha=this.a=this.I=this.j=this.V=this.g=this.J=this.i=null,this.Qa=this.P=0,this.Oa=!!c("internalChannelParams.failFast",t),this.ia=this.w=this.s=this.l=this.h=this.c=null,this.oa=!0,this.m=this.ra=this.O=-1,this.S=this.v=this.A=0,this.Na=c("internalChannelParams.baseRetryDelayMs",t)||5e3,this.Ra=c("internalChannelParams.retryDelaySeedMs",t)||1e4,this.Pa=c("internalChannelParams.forwardChannelMaxRetries",t)||2,this.qa=c("internalChannelParams.forwardChannelRequestTimeoutMs",t)||2e4,this.Ka=t&&t.zb||void 0,this.D=void 0,this.R=t&&t.supportsCrossDomainXhr||!1,this.H="",this.b=new ln(t&&t.concurrentRequestLimit),this.ja=new wn,this.o=!t||void 0===t.backgroundChannelTest||t.backgroundChannelTest,(this.W=t&&t.fastHandshake||!1)&&!this.o&&(this.o=!0),t&&t.forceLongPolling&&(this.oa=!1),this.fa=void 0}function qn(t){if(Vn(t),3==t.u){var e=t.P++,n=Me(t.B);Ve(n,"SID",t.H),Ve(n,"RID",e),Ve(n,"TYPE","terminate"),Wn(t,n),(e=new pe(t,e,void 0)).F=2,e.f=je(Me(n)),n=!1,a.navigator&&a.navigator.sendBeacon&&(n=a.navigator.sendBeacon(e.f.toString(),"")),!n&&a.Image&&((new Image).src=e.f,n=!0),n||(e.a=e.g.$(null),e.a.ca(e.f)),e.v=w(),Ee(e)}Zn(t)}function Vn(t){t.w&&(t.w.abort(),t.w=null),t.a&&(t.a.cancel(),t.a=null),t.l&&(a.clearTimeout(t.l),t.l=null),Yn(t),t.b.cancel(),t.h&&(u(t.h)&&a.clearTimeout(t.h),t.h=null)}function Bn(t,e){t.f.push(new hn(t.Qa++,e)),3==t.u&&jn(t)}function jn(t){dn(t.b)||t.h||(t.h=!0,Lt(t.Ha,t),t.A=0)}function zn(t,e){var n;n=e?e.W:t.P++;var r=Me(t.B);Ve(r,"SID",t.H),Ve(r,"RID",n),Ve(r,"AID",t.O),Wn(t,r),t.g&&t.i&&Fn(r,t.g,t.i),n=new pe(t,n,t.A+1),null===t.g&&(n.h=t.i),e&&(t.f=e.j.concat(t.f)),e=Qn(t,n,1e3),n.setTimeout(Math.round(.5*t.qa)+Math.round(.5*t.qa*Math.random())),gn(t.b,n),ge(n,r,e)}function Wn(t,e){t.c&&Ne({},(function(t,n){Ve(e,n,t)}))}function Qn(t,e,n){n=Math.min(t.f.length,n);var r=t.c?_(t.c.Sa,t.c,t):null;t:for(var i=t.f,o=-1;;){var a=["count="+n];-1==o?0<n?(o=i[0].b,a.push("ofs="+o)):o=0:a.push("ofs="+o);for(var s=!0,u=0;u<n;u++){var c=i[u].b,h=i[u].a;if(0>(c-=o))o=Math.max(0,i[u].b-100),s=!1;else try{En(h,a,"req"+c+"_")}catch(l){r&&r(h)}}if(s){r=a.join("&");break t}}return t=t.f.splice(0,n),e.j=t,r}function Kn(t){t.a||t.l||(t.S=1,Lt(t.Ga,t),t.v=0)}function Hn(t){return!(t.a||t.l||3<=t.v)&&(t.S++,t.l=ne(_(t.Ga,t),Xn(t,t.v)),t.v++,!0)}function Gn(t,e,n){var r=e.l;r&&pn(t.b,r),t.ia=t.oa&&n,t.m=e.c,t.B=$n(t,null,t.ha),jn(t)}function Yn(t){null!=t.s&&(a.clearTimeout(t.s),t.s=null)}function Xn(t,e){var n=t.Na+Math.floor(Math.random()*t.Ra);return t.ma()||(n*=2),n*e}function Jn(t,e){if(2==e){var n=null;t.c&&(n=null);var r=_(t.eb,t);n||(n=new Pe("//www.google.com/images/cleardot.gif"),a.location&&"http"==a.location.protocol||Le(n,"https"),je(n)),function(t,e){var n=new Yt;if(a.Image){var r=new Image;r.onload=b(Tn,n,r,"TestLoadImage: loaded",!0,e),r.onerror=b(Tn,n,r,"TestLoadImage: error",!1,e),r.onabort=b(Tn,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=b(Tn,n,r,"TestLoadImage: timeout",!1,e),a.setTimeout((function(){r.ontimeout&&r.ontimeout()}),1e4),r.src=t}else e(!1)}(n.toString(),r)}else te(2);t.u=0,t.c&&t.c.ta(e),Zn(t),Vn(t)}function Zn(t){t.u=0,t.m=-1,t.c&&(0==_n(t.b).length&&0==t.f.length||(t.b.c.length=0,D(t.f),t.f.length=0),t.c.sa())}function $n(t,e,n){var r=function(t){return t instanceof Pe?Me(t):new Pe(t,void 0)}(n);if(""!=r.b)e&&Fe(r,e+"."+r.b),Ue(r,r.i);else{var i,o=a.location;i=e?e+"."+o.hostname:o.hostname,r=function(t,e,n,r){var i=new Pe(null,void 0);return t&&Le(i,t),e&&Fe(i,e),n&&Ue(i,n),r&&(i.a=r),i}(o.protocol,i,+o.port,n)}return t.V&&M(t.V,(function(t,e){Ve(r,e,t)})),e=t.j,n=t.I,e&&n&&Ve(r,e,n),Ve(r,"VER",t.wa),Wn(t,r),r}function tr(){}function er(){if(z&&!(10<=Number(Z)))throw Error("Environmental error: no available transport.")}function nr(t,e){It.call(this),this.a=new Un(e),this.g=t,this.m=e&&e.testUrl?e.testUrl:function(t){for(var e=arguments[0],n=1;n<arguments.length;n++){var r,i=arguments[n];if(0==i.lastIndexOf("/",0))e=i;else(r=""==e)||(r=0<=(r=e.length-1)&&e.indexOf("/",r)==r),e+=r?i:"/"+i}return e}(this.g,"test"),this.b=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.a.i=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.xa&&(t?t["X-WebChannel-Client-Profile"]=e.xa:t={"X-WebChannel-Client-Profile":e.xa}),this.a.J=t,(t=e&&e.httpHeadersOverwriteParam)&&!N(t)&&(this.a.g=t),this.l=e&&e.supportsCrossDomainXhr||!1,this.h=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!N(e)&&(this.a.j=e,null!==(t=this.b)&&e in t&&(e in(t=this.b)&&delete t[e])),this.f=new or(this)}function rr(t){he.call(this);var e=t.__sm__;if(e){t:{for(var n in e){t=n;break t}t=void 0}(this.c=t)?(t=this.c,this.data=null!==e&&t in e?e[t]:void 0):this.data=e}else this.data=t}function ir(){le.call(this),this.status=1}function or(t){this.a=t}(r=Sn.prototype).ca=function(t,e,n,r){if(this.a)throw Error("[goog.net.XhrIo] Object is active with another request="+this.A+"; newUri="+t);e=e?e.toUpperCase():"GET",this.A=t,this.f="",this.h=0,this.v=!1,this.b=!0,this.a=new XMLHttpRequest,this.s=this.H?ae(this.H):ae(ue),this.a.onreadystatechange=_(this.Ea,this);try{this.w=!0,this.a.open(e,String(t),!0),this.w=!1}catch(o){return void kn(this,o)}t=n||"";var i=new Ae(this.headers);r&&Ne(r,(function(t,e){i.set(e,t)})),r=function(t){t:{for(var e=An,n=t.length,r=s(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:s(t)?t.charAt(e):t[e]}(i.K()),n=a.FormData&&t instanceof a.FormData,!(0<=C(Nn,e))||r||n||i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach((function(t,e){this.a.setRequestHeader(e,t)}),this),this.I&&(this.a.responseType=this.I),"withCredentials"in this.a&&this.a.withCredentials!==this.F&&(this.a.withCredentials=this.F);try{Pn(this),0<this.o&&((this.D=function(t){return z&&tt(9)&&u(t.timeout)&&void 0!==t.ontimeout}(this.a))?(this.a.timeout=this.o,this.a.ontimeout=_(this.Ba,this)):this.m=jt(this.Ba,this.o,this)),this.l=!0,this.a.send(t),this.l=!1}catch(o){kn(this,o)}},r.Ba=function(){void 0!==o&&this.a&&(this.f="Timed out after "+this.o+"ms, aborting",this.h=8,this.dispatchEvent("timeout"),this.abort(8))},r.abort=function(t){this.a&&this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1,this.h=t||7,this.dispatchEvent("complete"),this.dispatchEvent("abort"),xn(this))},r.G=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),xn(this,!0)),Sn.N.G.call(this)},r.Ea=function(){this.j||(this.w||this.l||this.g?On(this):this.Za())},r.Za=function(){On(this)},r.T=function(){try{return 2<Mn(this)?this.a.status:-1}catch(B){return-1}},r.aa=function(){try{return this.a?this.a.responseText:""}catch(B){return""}},r.Ua=function(t){if(this.a){var e=this.a.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Cn(e)}},r.ya=function(){return this.h},r.Xa=function(){return s(this.f)?this.f:String(this.f)},(r=Un.prototype).wa=8,r.u=1,r.Ca=function(){return 0==this.u},r.Ha=function(t){if(this.h)if(this.h=null,1==this.u){if(!t){this.P=Math.floor(1e5*Math.random());var e,n=new pe(this,t=this.P++,void 0),r=this.i;if(this.J&&(r?U(r=L(r),this.J):r=this.J),null===this.g&&(n.h=r),this.W)t:{for(var i=e=0;i<this.f.length;i++){var o=this.f[i];if(void 0===(o="__data__"in o.a&&s(o=o.a.__data__)?o.length:void 0))break;if(4096<(e+=o)){e=i;break t}if(4096===e||i===this.f.length-1){e=i+1;break t}}e=1e3}else e=1e3;e=Qn(this,n,e),Ve(i=Me(this.B),"RID",t),Ve(i,"CVER",22),this.o&&this.j&&Ve(i,"X-HTTP-Session-Id",this.j),Wn(this,i),this.g&&r&&Fn(i,this.g,r),gn(this.b,n),this.W?(Ve(i,"$req",e),Ve(i,"SID","null"),n.S=!0,ge(n,i,null)):ge(n,i,e),this.u=2}}else 3==this.u&&(t?zn(this,t):0==this.f.length||dn(this.b)||zn(this))},r.Ga=function(){this.l=null,this.a=new pe(this,"rpc",this.S),null===this.g&&(this.a.h=this.i),this.a.J=0;var t=Me(this.pa);Ve(t,"RID","rpc"),Ve(t,"SID",this.H),Ve(t,"CI",this.ia?"0":"1"),Ve(t,"AID",this.O),Wn(this,t),Ve(t,"TYPE","xmlhttp"),this.g&&this.i&&Fn(t,this.g,this.i),this.D&&this.a.setTimeout(this.D),ve(this.a,t,!0,this.ga)},r.Fa=function(t,e){if(0!=this.u&&(this.a==t||yn(this.b,t)))if(this.m=t.o,!t.s&&yn(this.b,t)&&3==this.u){try{var n=this.ja.a.parse(e)}catch(o){n=null}if(f(n)&&3==n.length){if(0==(e=n)[0]){t:if(!this.l){if(this.a){if(!(this.a.v+3e3<t.v))break t;Yn(this),this.a.cancel(),this.a=null}Hn(this),te(18)}}else this.ra=e[1],0<this.ra-this.O&&37500>e[2]&&this.ia&&0==this.v&&!this.s&&(this.s=ne(_(this.Ya,this),6e3));if(1>=mn(this.b)&&this.fa){try{this.fa()}catch(o){}this.fa=void 0}}else Jn(this,11)}else if((t.s||this.a==t)&&Yn(this),!N(e))for(e=n=this.ja.a.parse(e),n=0;n<e.length;n++){var r=e[n];if(this.O=r[0],r=r[1],2==this.u)if("c"==r[0]){this.H=r[1],this.ga=r[2];var i=r[3];null!=i&&(this.wa=i),null!=(r=r[5])&&u(r)&&0<r&&(this.D=1.5*r),this.o&&(r=t.a)&&((i=Ln(r,"X-Client-Wire-Protocol"))&&pn(this.b,i),this.j&&(r=Ln(r,"X-HTTP-Session-Id")))&&(this.I=r,Ve(this.B,this.j,r)),this.u=3,this.c&&this.c.va(),r=t,this.pa=$n(this,this.Y()?this.ga:null,this.ha),r.s?(vn(this.b,r),(i=this.D)&&r.setTimeout(i),r.i&&(Ce(r),Ee(r)),this.a=r):Kn(this),0<this.f.length&&jn(this)}else"stop"!=r[0]&&"close"!=r[0]||Jn(this,7);else 3==this.u&&("stop"==r[0]||"close"==r[0]?"stop"==r[0]?Jn(this,7):qn(this):"noop"!=r[0]&&this.c&&this.c.ua(r),this.v=0)}},r.Ya=function(){null!=this.s&&(this.s=null,this.a.cancel(),this.a=null,Hn(this),te(19))},r.na=function(t){var e=null;if(this.a==t){Yn(this),this.a=null;var n=2}else{if(!yn(this.b,t))return;e=t.j,vn(this.b,t),n=1}if(this.m=t.o,0!=this.u)if(t.b)1==n?(e=w()-t.v,Xt.dispatchEvent(new ee(Xt,t.l?t.l.length:0,e,this.A)),jn(this)):Kn(this);else{var r=t.c;if(3==r||0==r&&0<this.m||!(1==n&&function(t,e){return!(mn(t.b)>=t.b.f-(t.h?1:0))&&(t.h?(t.f=e.j.concat(t.f),!0):!(1==t.u||2==t.u||t.A>=(t.Oa?0:t.Pa))&&(t.h=ne(_(t.Ha,t,e),Xn(t,t.A)),t.A++,!0))}(this,t)||2==n&&Hn(this)))switch(e&&0<e.length&&(t=this.b,t.c=t.c.concat(e)),r){case 1:Jn(this,5);break;case 4:Jn(this,10);break;case 3:Jn(this,6);break;default:Jn(this,2)}}},r.eb=function(t){te(t?2:1)},r.$=function(t){if(t&&!this.R)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new Sn(this.Ka)).F=this.R,t},r.ma=function(){return!!this.c&&!0},r.Y=function(){return this.R},(r=tr.prototype).va=function(){},r.ua=function(){},r.ta=function(){},r.sa=function(){},r.Sa=function(){},er.prototype.a=function(t,e){return new nr(t,e)},E(nr,It),(r=nr.prototype).addEventListener=function(t,e,n,r){nr.N.addEventListener.call(this,t,e,n,r)},r.removeEventListener=function(t,e,n,r){nr.N.removeEventListener.call(this,t,e,n,r)},r.Va=function(){this.a.c=this.f,this.l&&(this.a.R=!0);var t=this.a,e=this.m,n=this.g,r=this.b||void 0;te(0),t.ha=n,t.V=r||{},t.o&&(t.F.b=[],t.F.a=!1),t.w=new on(t),null===t.g&&(t.w.h=t.i),n=e,t.g&&t.i&&(n=Fn(e,t.g,t.i)),(t=t.w).i=n,e=$n(t.a,null,t.i),te(3),null!=(n=t.a.F.b)?(t.f=n[0],t.M=1,an(t)):(Be(e,"MODE","init"),!t.a.o&&t.a.j&&Be(e,"X-HTTP-Session-Id",t.a.j),t.b=new pe(t,void 0,void 0),t.b.h=t.h,ve(t.b,e,!1,null),t.M=0)},r.close=function(){qn(this.a)},r.Wa=function(t){if(s(t)){var e={};e.__data__=t,Bn(this.a,e)}else this.h?((e={}).__data__=Nt(t),Bn(this.a,e)):Bn(this.a,t)},r.G=function(){this.a.c=null,delete this.f,qn(this.a),delete this.a,nr.N.G.call(this)},E(rr,he),E(ir,le),E(or,tr),or.prototype.va=function(){this.a.dispatchEvent("a")},or.prototype.ua=function(t){this.a.dispatchEvent(new rr(t))},or.prototype.ta=function(t){this.a.dispatchEvent(new ir(t))},or.prototype.sa=function(){this.a.dispatchEvent("b")};var ar=b((function(t,e){function n(){}n.prototype=t.prototype;var r=new n;return t.apply(r,Array.prototype.slice.call(arguments,1)),r}),er);er.prototype.createWebChannel=er.prototype.a,nr.prototype.send=nr.prototype.Wa,nr.prototype.open=nr.prototype.Va,nr.prototype.close=nr.prototype.close,re.NO_ERROR=0,re.TIMEOUT=8,re.HTTP_ERROR=6,ie.COMPLETE="complete",se.EventType=ce,ce.OPEN="a",ce.CLOSE="b",ce.ERROR="c",ce.MESSAGE="d",It.prototype.listen=It.prototype.za,Sn.prototype.listenOnce=Sn.prototype.Aa,Sn.prototype.getLastError=Sn.prototype.Xa,Sn.prototype.getLastErrorCode=Sn.prototype.ya,Sn.prototype.getStatus=Sn.prototype.T,Sn.prototype.getResponseJson=Sn.prototype.Ua,Sn.prototype.getResponseText=Sn.prototype.aa,Sn.prototype.send=Sn.prototype.ca;var sr={createWebChannelTransport:ar,ErrorCode:re,EventType:ie,WebChannel:se,XhrIo:Sn},ur=sr.createWebChannelTransport,cr=sr.ErrorCode,hr=sr.EventType,lr=sr.WebChannel,fr=sr.XhrIo;e.default=sr}.call(this,n("yLpj"))},y8fO:function(t,e){t.exports=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/},ys0W:function(t,e,n){var r=n("QPJK"),i=n("2mBY"),o=n("5SQf"),a=n("BnbX").f;t.exports=function(t){return function(e){for(var n,s=o(e),u=i(s),c=u.length,h=0,l=[];c>h;)n=u[h++],r&&!a.call(s,n)||l.push(t?[n,s[n]]:s[n]);return l}}},"zEh/":function(t,e,n){"use strict";n.d(e,"a",(function(){return r}));n("6kNP"),n("8npG");function r(t,e,n,r,i){return new Promise((function(o,a){console.log(r);var s=new XMLHttpRequest,u=new FormData;u.append("file",t.files[0]),s.open("POST","https://api.cloudinary.com/v1_1/hvioxpubt/upload?upload_preset=ml_default",!0),s.setRequestHeader("X-Requested-With","XMLHttpRequest"),s.upload.onprogress=function(t){var e=Math.ceil(t.loaded/t.total*100);i&&i(e)},s.onreadystatechange=function(t){if(4===s.readyState&&200===s.status){var n=JSON.parse(s.responseText);e(n),o()}},u.append("tags","browser_upload"),n&&u.append("folder",n),r&&u.append("public_id",r),s.send(u),s.onerror=a}))}},zTTH:function(t,e,n){"use strict";var r=n("P8UN"),i=n("Wadk")(6),o="findIndex",a=!0;o in[]&&Array(1)[o]((function(){a=!1})),r(r.P+r.F*a,"Array",{findIndex:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),n("Dq1/")(o)},zVF4:function(t,e,n){"use strict";(function(t){n("AqHK"),n("n7j8"),n("PZd/"),n("JHok"),n("HQhv"),n("sC2a"),n("rzGZ"),n("Dq+y"),n("Ggvi"),n("LagC"),n("pJf4"),n("q8oJ"),n("C9fy"),n("6kNP"),n("8npG"),n("MIFh"),n("R48M"),Object.defineProperty(e,"__esModule",{value:!0});var r=n("mrSG"),i={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},o=function(t,e){if(!t)throw a(e)},a=function(t){return new Error("Firebase Database ("+i.SDK_VERSION+") INTERNAL ASSERT FAILED: "+t)},s=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},u={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],a=i+1<t.length,s=a?t[i+1]:0,u=i+2<t.length,c=u?t[i+2]:0,h=o>>2,l=(3&o)<<4|s>>4,f=(15&s)<<2|c>>6,p=63&c;u||(p=64,a||(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(s(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 a=((7&i)<<18|(63&(o=t[n++]))<<12|(63&(s=t[n++]))<<6|63&t[n++])-65536;e[r++]=String.fromCharCode(55296+(a>>10)),e[r++]=String.fromCharCode(56320+(1023&a))}else{o=t[n++];var s=t[n++];e[r++]=String.fromCharCode((15&i)<<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++)],a=i<t.length?n[t.charAt(i)]:0,s=++i<t.length?n[t.charAt(i)]:64,u=++i<t.length?n[t.charAt(i)]:64;if(++i,null==o||null==a||null==s||null==u)throw Error();var c=o<<2|a>>4;if(r.push(c),64!==s){var h=a<<4&240|s>>2;if(r.push(h),64!==u){var l=s<<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)}}},c=function(t){try{return u.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function h(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]=h(t[n],e[n]));return t}var l=function(){function t(){var t=this;this.reject=function(){},this.resolve=function(){},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}();function f(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}var p="FirebaseError",d=function(t){function e(n,r){var i=t.call(this,r)||this;return i.code=n,i.name=p,Object.setPrototypeOf(i,e.prototype),Error.captureStackTrace&&Error.captureStackTrace(i,m.prototype.create),i}return r.__extends(e,t),e}(Error),m=function(){function t(t,e,n){this.service=t,this.serviceName=e,this.errors=n}return t.prototype.create=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=e[0]||{},i=this.service+"/"+t,o=this.errors[t],a=o?y(o,r):"Error",s=this.serviceName+": "+a+" ("+i+").",u=new d(i,s),c=0,h=Object.keys(r);c<h.length;c++){var l=h[c];"_"!==l.slice(-1)&&(l in u&&console.warn('Overwriting FirebaseError base field "'+l+'" can cause unexpected behavior.'),u[l]=r[l])}return u},t}();function y(t,e){return t.replace(g,(function(t,n){var r=e[n];return null!=r?r.toString():"<"+n+"?>"}))}var g=/\{\$([^}]+)}/g;function v(t){return JSON.parse(t)}var _=function(t){var e={},n={},r={},i="";try{var o=t.split(".");e=v(c(o[0])||""),n=v(c(o[1])||""),i=o[2],r=n.d||{},delete n.d}catch(a){}return{header:e,claims:n,data:r,signature:i}};var b=function(){function t(){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()}return t.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},t.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,a,s=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),a=1518500249):(o=u^c^h,a=1859775393):r<60?(o=u&c|h&(u|c),a=2400959708):(o=u^c^h,a=3395469782);i=(s<<5|s>>>27)+o+l+a+n[r]&4294967295;l=h,h=c,c=4294967295&(u<<30|u>>>2),u=s,s=i}this.chain_[0]=this.chain_[0]+s&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},t.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}},t.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},t}();var w=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=E),void 0===r.error&&(r.error=E),void 0===r.complete&&(r.complete=E);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(r){"undefined"!=typeof console&&console.error&&console.error(r)}}))},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 E(){}function T(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 "}e.CONSTANTS=i,e.Deferred=l,e.ErrorFactory=m,e.FirebaseError=d,e.Sha1=b,e.assert=o,e.assertionError=a,e.async=function(t,e){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];Promise.resolve(!0).then((function(){t.apply(void 0,n)})).catch((function(t){e&&e(t)}))}},e.base64=u,e.base64Decode=c,e.base64Encode=function(t){var e=s(t);return u.encodeByteArray(e,!0)},e.contains=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.createSubscribe=function(t,e){var n=new w(t,e);return n.subscribe.bind(n)},e.decode=_,e.deepCopy=function(t){return h(void 0,t)},e.deepExtend=h,e.errorPrefix=T,e.getUA=f,e.isAdmin=function(t){var e=_(t).claims;return"object"==typeof e&&!0===e.admin},e.isBrowser=function(){return"object"==typeof self&&self.self===self},e.isEmpty=function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0},e.isMobileCordova=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(f())},e.isNode=function(){try{return"[object process]"===Object.prototype.toString.call(t.process)}catch(e){return!1}},e.isNodeSdk=function(){return!0===i.NODE_CLIENT||!0===i.NODE_ADMIN},e.isReactNative=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},e.isValidFormat=function(t){var e=_(t).claims;return!!e&&"object"==typeof e&&e.hasOwnProperty("iat")},e.isValidTimestamp=function(t){var e=_(t).claims,n=Math.floor((new Date).getTime()/1e3),r=0,i=0;return"object"==typeof e&&(e.hasOwnProperty("nbf")?r=e.nbf:e.hasOwnProperty("iat")&&(r=e.iat),i=e.hasOwnProperty("exp")?e.exp:r+86400),!!n&&!!r&&!!i&&n>=r&&n<=i},e.issuedAtTime=function(t){var e=_(t).claims;return"object"==typeof e&&e.hasOwnProperty("iat")?e.iat:null},e.jsonEval=v,e.map=function(t,e,n){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=e.call(n,t[i],i,t));return r},e.querystring=function(t){for(var e=[],n=function(t,n){Array.isArray(n)?n.forEach((function(n){e.push(encodeURIComponent(t)+"="+encodeURIComponent(n))})):e.push(encodeURIComponent(t)+"="+encodeURIComponent(n))},r=0,i=Object.entries(t);r<i.length;r++){var o=i[r];n(o[0],o[1])}return e.length?"&"+e.join("&"):""},e.querystringDecode=function(t){var e={};return t.replace(/^\?/,"").split("&").forEach((function(t){if(t){var n=t.split("=");e[n[0]]=n[1]}})),e},e.safeGet=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0},e.stringLength=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},e.stringToByteArray=function(t){for(var e=[],n=0,r=0;r<t.length;r++){var i=t.charCodeAt(r);if(i>=55296&&i<=56319){var a=i-55296;r++,o(r<t.length,"Surrogate pair missing trail surrogate."),i=65536+(a<<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},e.stringify=function(t){return JSON.stringify(t)},e.validateArgCount=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+".")},e.validateCallback=function(t,e,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(T(t,e,r)+"must be a valid function.")},e.validateContextObject=function(t,e,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(T(t,e,r)+"must be a valid context object.")},e.validateNamespace=function(t,e,n,r){if((!r||n)&&"string"!=typeof n)throw new Error(T(t,e,r)+"must be a valid firebase namespace.")}}).call(this,n("yLpj"))}}]);
//# sourceMappingURL=component---src-pages-collaboration-file-js-8c46f1a5768cf7e080d3.js.map