}\n */\nconst matchAll = (regExp, str) => {\n let matches;\n const arr = [];\n\n while ((matches = regExp.exec(str)) !== null) {\n arr.push(matches);\n }\n\n return arr;\n}\n\n/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */\nconst isHTMLForm = kindOfTest('HTMLFormElement');\n\nconst toCamelCase = str => {\n return str.toLowerCase().replace(/[-_\\s]([a-z\\d])(\\w*)/g,\n function replacer(m, p1, p2) {\n return p1.toUpperCase() + p2;\n }\n );\n};\n\n/* Creating a function that will check if an object has a property. */\nconst hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);\n\n/**\n * Determine if a value is a RegExp object\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a RegExp object, otherwise false\n */\nconst isRegExp = kindOfTest('RegExp');\n\nconst reduceDescriptors = (obj, reducer) => {\n const descriptors = Object.getOwnPropertyDescriptors(obj);\n const reducedDescriptors = {};\n\n forEach(descriptors, (descriptor, name) => {\n let ret;\n if ((ret = reducer(descriptor, name, obj)) !== false) {\n reducedDescriptors[name] = ret || descriptor;\n }\n });\n\n Object.defineProperties(obj, reducedDescriptors);\n}\n\n/**\n * Makes all methods read-only\n * @param {Object} obj\n */\n\nconst freezeMethods = (obj) => {\n reduceDescriptors(obj, (descriptor, name) => {\n // skip restricted props in strict mode\n if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {\n return false;\n }\n\n const value = obj[name];\n\n if (!isFunction(value)) return;\n\n descriptor.enumerable = false;\n\n if ('writable' in descriptor) {\n descriptor.writable = false;\n return;\n }\n\n if (!descriptor.set) {\n descriptor.set = () => {\n throw Error('Can not rewrite read-only method \\'' + name + '\\'');\n };\n }\n });\n}\n\nconst toObjectSet = (arrayOrString, delimiter) => {\n const obj = {};\n\n const define = (arr) => {\n arr.forEach(value => {\n obj[value] = true;\n });\n }\n\n isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));\n\n return obj;\n}\n\nconst noop = () => {}\n\nconst toFiniteNumber = (value, defaultValue) => {\n value = +value;\n return Number.isFinite(value) ? value : defaultValue;\n}\n\nconst ALPHA = 'abcdefghijklmnopqrstuvwxyz'\n\nconst DIGIT = '0123456789';\n\nconst ALPHABET = {\n DIGIT,\n ALPHA,\n ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT\n}\n\nconst generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {\n let str = '';\n const {length} = alphabet;\n while (size--) {\n str += alphabet[Math.random() * length|0]\n }\n\n return str;\n}\n\n/**\n * If the thing is a FormData object, return true, otherwise return false.\n *\n * @param {unknown} thing - The thing to check.\n *\n * @returns {boolean}\n */\nfunction isSpecCompliantForm(thing) {\n return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);\n}\n\nconst toJSONObject = (obj) => {\n const stack = new Array(10);\n\n const visit = (source, i) => {\n\n if (isObject(source)) {\n if (stack.indexOf(source) >= 0) {\n return;\n }\n\n if(!('toJSON' in source)) {\n stack[i] = source;\n const target = isArray(source) ? [] : {};\n\n forEach(source, (value, key) => {\n const reducedValue = visit(value, i + 1);\n !isUndefined(reducedValue) && (target[key] = reducedValue);\n });\n\n stack[i] = undefined;\n\n return target;\n }\n }\n\n return source;\n }\n\n return visit(obj, 0);\n}\n\nconst isAsyncFn = kindOfTest('AsyncFunction');\n\nconst isThenable = (thing) =>\n thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);\n\nexport default {\n isArray,\n isArrayBuffer,\n isBuffer,\n isFormData,\n isArrayBufferView,\n isString,\n isNumber,\n isBoolean,\n isObject,\n isPlainObject,\n isUndefined,\n isDate,\n isFile,\n isBlob,\n isRegExp,\n isFunction,\n isStream,\n isURLSearchParams,\n isTypedArray,\n isFileList,\n forEach,\n merge,\n extend,\n trim,\n stripBOM,\n inherits,\n toFlatObject,\n kindOf,\n kindOfTest,\n endsWith,\n toArray,\n forEachEntry,\n matchAll,\n isHTMLForm,\n hasOwnProperty,\n hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection\n reduceDescriptors,\n freezeMethods,\n toObjectSet,\n toCamelCase,\n noop,\n toFiniteNumber,\n findKey,\n global: _global,\n isContextDefined,\n ALPHABET,\n generateString,\n isSpecCompliantForm,\n toJSONObject,\n isAsyncFn,\n isThenable\n};\n","'use strict';\nvar NATIVE_BIND = require('../internals/function-bind-native');\n\nvar call = Function.prototype.call;\n\nmodule.exports = NATIVE_BIND ? call.bind(call) : function () {\n return call.apply(call, arguments);\n};\n","'use strict';\nvar uncurryThis = require('../internals/function-uncurry-this');\n\nvar toString = uncurryThis({}.toString);\nvar stringSlice = uncurryThis(''.slice);\n\nmodule.exports = function (it) {\n return stringSlice(toString(it), 8, -1);\n};\n","'use strict';\nvar IS_PURE = require('../internals/is-pure');\nvar globalThis = require('../internals/global');\nvar defineGlobalProperty = require('../internals/define-global-property');\n\nvar SHARED = '__core-js_shared__';\nvar store = module.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {});\n\n(store.versions || (store.versions = [])).push({\n version: '3.37.0',\n mode: IS_PURE ? 'pure' : 'global',\n copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',\n license: 'https://github.com/zloirock/core-js/blob/v3.37.0/LICENSE',\n source: 'https://github.com/zloirock/core-js'\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar call = require('../internals/function-call');\nvar IS_PURE = require('../internals/is-pure');\nvar FunctionName = require('../internals/function-name');\nvar isCallable = require('../internals/is-callable');\nvar createIteratorConstructor = require('../internals/iterator-create-constructor');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar defineBuiltIn = require('../internals/define-built-in');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar Iterators = require('../internals/iterators');\nvar IteratorsCore = require('../internals/iterators-core');\n\nvar PROPER_FUNCTION_NAME = FunctionName.PROPER;\nvar CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;\nvar IteratorPrototype = IteratorsCore.IteratorPrototype;\nvar BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;\nvar ITERATOR = wellKnownSymbol('iterator');\nvar KEYS = 'keys';\nvar VALUES = 'values';\nvar ENTRIES = 'entries';\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {\n createIteratorConstructor(IteratorConstructor, NAME, next);\n\n var getIterationMethod = function (KIND) {\n if (KIND === DEFAULT && defaultIterator) return defaultIterator;\n if (!BUGGY_SAFARI_ITERATORS && KIND && KIND in IterablePrototype) return IterablePrototype[KIND];\n\n switch (KIND) {\n case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };\n case VALUES: return function values() { return new IteratorConstructor(this, KIND); };\n case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };\n }\n\n return function () { return new IteratorConstructor(this); };\n };\n\n var TO_STRING_TAG = NAME + ' Iterator';\n var INCORRECT_VALUES_NAME = false;\n var IterablePrototype = Iterable.prototype;\n var nativeIterator = IterablePrototype[ITERATOR]\n || IterablePrototype['@@iterator']\n || DEFAULT && IterablePrototype[DEFAULT];\n var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);\n var anyNativeIterator = NAME === 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;\n var CurrentIteratorPrototype, methods, KEY;\n\n // fix native\n if (anyNativeIterator) {\n CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));\n if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {\n if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {\n if (setPrototypeOf) {\n setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);\n } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {\n defineBuiltIn(CurrentIteratorPrototype, ITERATOR, returnThis);\n }\n }\n // Set @@toStringTag to native iterators\n setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);\n if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;\n }\n }\n\n // fix Array.prototype.{ values, @@iterator }.name in V8 / FF\n if (PROPER_FUNCTION_NAME && DEFAULT === VALUES && nativeIterator && nativeIterator.name !== VALUES) {\n if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) {\n createNonEnumerableProperty(IterablePrototype, 'name', VALUES);\n } else {\n INCORRECT_VALUES_NAME = true;\n defaultIterator = function values() { return call(nativeIterator, this); };\n }\n }\n\n // export additional methods\n if (DEFAULT) {\n methods = {\n values: getIterationMethod(VALUES),\n keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),\n entries: getIterationMethod(ENTRIES)\n };\n if (FORCED) for (KEY in methods) {\n if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {\n defineBuiltIn(IterablePrototype, KEY, methods[KEY]);\n }\n } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);\n }\n\n // define iterator\n if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {\n defineBuiltIn(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });\n }\n Iterators[NAME] = defaultIterator;\n\n return methods;\n};\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nfunction __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\n\nvar commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};\n\nvar g, goog = goog || {}, k = commonjsGlobal || self;\r\nfunction aa() { }\r\nfunction ba(a) { var b = typeof a; return \"object\" != b ? b : a ? Array.isArray(a) ? \"array\" : b : \"null\"; }\r\nfunction ca(a) { var b = ba(a); return \"array\" == b || \"object\" == b && \"number\" == typeof a.length; }\r\nfunction n(a) { var b = typeof a; return \"object\" == b && null != a || \"function\" == b; }\r\nfunction da(a) { return Object.prototype.hasOwnProperty.call(a, ea) && a[ea] || (a[ea] = ++fa); }\r\nvar ea = \"closure_uid_\" + (1E9 * Math.random() >>> 0), fa = 0;\r\nfunction ha(a, b, c) { return a.call.apply(a.bind, arguments); }\r\nfunction ja(a, b, c) { if (!a)\r\n throw Error(); if (2 < arguments.length) {\r\n var d = Array.prototype.slice.call(arguments, 2);\r\n return function () { var e = Array.prototype.slice.call(arguments); Array.prototype.unshift.apply(e, d); return a.apply(b, e); };\r\n} return function () { return a.apply(b, arguments); }; }\r\nfunction p(a, b, c) { Function.prototype.bind && -1 != Function.prototype.bind.toString().indexOf(\"native code\") ? p = ha : p = ja; return p.apply(null, arguments); }\r\nfunction ka(a, b) { var c = Array.prototype.slice.call(arguments, 1); return function () { var d = c.slice(); d.push.apply(d, arguments); return a.apply(this, d); }; }\r\nvar q = Date.now;\r\nfunction r(a, b) { function c() { } c.prototype = b.prototype; a.S = b.prototype; a.prototype = new c; a.prototype.constructor = a; }\r\nfunction u() { this.j = this.j; this.i = this.i; }\r\nvar la = 0;\r\nu.prototype.j = !1;\r\nu.prototype.ja = function () { if (!this.j && (this.j = !0, this.G(), 0 != la)) {\r\n var a = da(this);\r\n} };\r\nu.prototype.G = function () { if (this.i)\r\n for (; this.i.length;)\r\n this.i.shift()(); };\r\nvar na = Array.prototype.indexOf ? function (a, b) { return Array.prototype.indexOf.call(a, b, void 0); } : function (a, b) { if (\"string\" === typeof a)\r\n return \"string\" !== typeof b || 1 != b.length ? -1 : a.indexOf(b, 0); for (var c = 0; c < a.length; c++)\r\n if (c in a && a[c] === b)\r\n return c; return -1; }, oa = Array.prototype.forEach ? function (a, b, c) { Array.prototype.forEach.call(a, b, c); } : function (a, b, c) { for (var d = a.length, e = \"string\" === typeof a ? a.split(\"\") : a, f = 0; f < d; f++)\r\n f in e && b.call(c, e[f], f, a); };\r\nfunction pa(a) { a: {\r\n var b = qa;\r\n for (var c = a.length, d = \"string\" === typeof a ? a.split(\"\") : a, e = 0; e < c; e++)\r\n if (e in d && b.call(void 0, d[e], e, a)) {\r\n b = e;\r\n break a;\r\n }\r\n b = -1;\r\n} return 0 > b ? null : \"string\" === typeof a ? a.charAt(b) : a[b]; }\r\nfunction ra(a) { return Array.prototype.concat.apply([], arguments); }\r\nfunction sa(a) { var b = a.length; if (0 < b) {\r\n for (var c = Array(b), d = 0; d < b; d++)\r\n c[d] = a[d];\r\n return c;\r\n} return []; }\r\nfunction ta(a) { return /^[\\s\\xa0]*$/.test(a); }\r\nvar ua = String.prototype.trim ? function (a) { return a.trim(); } : function (a) { return /^[\\s\\xa0]*([\\s\\S]*?)[\\s\\xa0]*$/.exec(a)[1]; };\r\nfunction v(a, b) { return -1 != a.indexOf(b); }\r\nfunction xa(a, b) { return a < b ? -1 : a > b ? 1 : 0; }\r\nvar w;\r\na: {\r\n var ya = k.navigator;\r\n if (ya) {\r\n var za = ya.userAgent;\r\n if (za) {\r\n w = za;\r\n break a;\r\n }\r\n }\r\n w = \"\";\r\n}\r\nfunction Aa(a, b, c) { for (var d in a)\r\n b.call(c, a[d], d, a); }\r\nfunction Ba(a) { var b = {}; for (var c in a)\r\n b[c] = a[c]; return b; }\r\nvar Ca = \"constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf\".split(\" \");\r\nfunction Da(a, b) { var c, d; for (var e = 1; e < arguments.length; e++) {\r\n d = arguments[e];\r\n for (c in d)\r\n a[c] = d[c];\r\n for (var f = 0; f < Ca.length; f++)\r\n c = Ca[f], Object.prototype.hasOwnProperty.call(d, c) && (a[c] = d[c]);\r\n} }\r\nfunction Ea(a) { Ea[\" \"](a); return a; }\r\nEa[\" \"] = aa;\r\nfunction Fa(a, b) { var c = Ga; return Object.prototype.hasOwnProperty.call(c, a) ? c[a] : c[a] = b(a); }\r\nvar Ha = v(w, \"Opera\"), x = v(w, \"Trident\") || v(w, \"MSIE\"), Ia = v(w, \"Edge\"), Ja = Ia || x, Ka = v(w, \"Gecko\") && !(v(w.toLowerCase(), \"webkit\") && !v(w, \"Edge\")) && !(v(w, \"Trident\") || v(w, \"MSIE\")) && !v(w, \"Edge\"), La = v(w.toLowerCase(), \"webkit\") && !v(w, \"Edge\");\r\nfunction Ma() { var a = k.document; return a ? a.documentMode : void 0; }\r\nvar Na;\r\na: {\r\n var Oa = \"\", Pa = function () { var a = w; if (Ka)\r\n return /rv:([^\\);]+)(\\)|;)/.exec(a); if (Ia)\r\n return /Edge\\/([\\d\\.]+)/.exec(a); if (x)\r\n return /\\b(?:MSIE|rv)[: ]([^\\);]+)(\\)|;)/.exec(a); if (La)\r\n return /WebKit\\/(\\S+)/.exec(a); if (Ha)\r\n return /(?:Version)[ \\/]?(\\S+)/.exec(a); }();\r\n Pa && (Oa = Pa ? Pa[1] : \"\");\r\n if (x) {\r\n var Qa = Ma();\r\n if (null != Qa && Qa > parseFloat(Oa)) {\r\n Na = String(Qa);\r\n break a;\r\n }\r\n }\r\n Na = Oa;\r\n}\r\nvar Ga = {};\r\nfunction Ra(a) { return Fa(a, function () { {\r\n var b = 0;\r\n var e = ua(String(Na)).split(\".\"), f = ua(String(a)).split(\".\"), h = Math.max(e.length, f.length);\r\n for (var m = 0; 0 == b && m < h; m++) {\r\n var c = e[m] || \"\", d = f[m] || \"\";\r\n do {\r\n c = /(\\d*)(\\D*)(.*)/.exec(c) || [\"\", \"\", \"\", \"\"];\r\n d = /(\\d*)(\\D*)(.*)/.exec(d) || [\"\", \"\", \"\", \"\"];\r\n if (0 == c[0].length && 0 == d[0].length)\r\n break;\r\n b = xa(0 == c[1].length ? 0 : parseInt(c[1], 10), 0 == d[1].length ? 0 : parseInt(d[1], 10)) || xa(0 == c[2].length, 0 == d[2].length) || xa(c[2], d[2]);\r\n c = c[3];\r\n d = d[3];\r\n } while (0 == b);\r\n }\r\n} return 0 <= b; }); }\r\nvar Sa;\r\nif (k.document && x) {\r\n var Ta = Ma();\r\n Sa = Ta ? Ta : parseInt(Na, 10) || void 0;\r\n}\r\nelse\r\n Sa = void 0;\r\nvar Ua = Sa;\r\nvar Va = !x || 9 <= Number(Ua), Wa = x && !Ra(\"9\"), Xa = function () { if (!k.addEventListener || !Object.defineProperty)\r\n return !1; var a = !1, b = Object.defineProperty({}, \"passive\", { get: function () { a = !0; } }); try {\r\n k.addEventListener(\"test\", aa, b), k.removeEventListener(\"test\", aa, b);\r\n}\r\ncatch (c) { } return a; }();\r\nfunction y(a, b) { this.type = a; this.a = this.target = b; this.defaultPrevented = !1; }\r\ny.prototype.b = function () { this.defaultPrevented = !0; };\r\nfunction A(a, b) {\r\n y.call(this, a ? a.type : \"\");\r\n this.relatedTarget = this.a = this.target = null;\r\n this.button = this.screenY = this.screenX = this.clientY = this.clientX = 0;\r\n this.key = \"\";\r\n this.metaKey = this.shiftKey = this.altKey = this.ctrlKey = !1;\r\n this.pointerId = 0;\r\n this.pointerType = \"\";\r\n this.c = null;\r\n if (a) {\r\n var c = this.type = a.type, d = a.changedTouches && a.changedTouches.length ? a.changedTouches[0] : null;\r\n this.target = a.target || a.srcElement;\r\n this.a = b;\r\n if (b = a.relatedTarget) {\r\n if (Ka) {\r\n a: {\r\n try {\r\n Ea(b.nodeName);\r\n var e = !0;\r\n break a;\r\n }\r\n catch (f) { }\r\n e = !1;\r\n }\r\n e || (b = null);\r\n }\r\n }\r\n else\r\n \"mouseover\" ==\r\n c ? b = a.fromElement : \"mouseout\" == c && (b = a.toElement);\r\n this.relatedTarget = b;\r\n d ? (this.clientX = void 0 !== d.clientX ? d.clientX : d.pageX, this.clientY = void 0 !== d.clientY ? d.clientY : d.pageY, this.screenX = d.screenX || 0, this.screenY = d.screenY || 0) : (this.clientX = void 0 !== a.clientX ? a.clientX : a.pageX, this.clientY = void 0 !== a.clientY ? a.clientY : a.pageY, this.screenX = a.screenX || 0, this.screenY = a.screenY || 0);\r\n this.button = a.button;\r\n this.key = a.key || \"\";\r\n this.ctrlKey = a.ctrlKey;\r\n this.altKey = a.altKey;\r\n this.shiftKey = a.shiftKey;\r\n this.metaKey =\r\n a.metaKey;\r\n this.pointerId = a.pointerId || 0;\r\n this.pointerType = \"string\" === typeof a.pointerType ? a.pointerType : Ya[a.pointerType] || \"\";\r\n this.c = a;\r\n a.defaultPrevented && this.b();\r\n }\r\n}\r\nr(A, y);\r\nvar Ya = { 2: \"touch\", 3: \"pen\", 4: \"mouse\" };\r\nA.prototype.b = function () { A.S.b.call(this); var a = this.c; if (a.preventDefault)\r\n a.preventDefault();\r\nelse if (a.returnValue = !1, Wa)\r\n try {\r\n if (a.ctrlKey || 112 <= a.keyCode && 123 >= a.keyCode)\r\n a.keyCode = -1;\r\n }\r\n catch (b) { } };\r\nvar C = \"closure_listenable_\" + (1E6 * Math.random() | 0), Za = 0;\r\nfunction $a(a, b, c, d, e) { this.listener = a; this.proxy = null; this.src = b; this.type = c; this.capture = !!d; this.ca = e; this.key = ++Za; this.Y = this.Z = !1; }\r\nfunction ab(a) { a.Y = !0; a.listener = null; a.proxy = null; a.src = null; a.ca = null; }\r\nfunction bb(a) { this.src = a; this.a = {}; this.b = 0; }\r\nbb.prototype.add = function (a, b, c, d, e) { var f = a.toString(); a = this.a[f]; a || (a = this.a[f] = [], this.b++); var h = cb(a, b, d, e); -1 < h ? (b = a[h], c || (b.Z = !1)) : (b = new $a(b, this.src, f, !!d, e), b.Z = c, a.push(b)); return b; };\r\nfunction db(a, b) { var c = b.type; if (c in a.a) {\r\n var d = a.a[c], e = na(d, b), f;\r\n (f = 0 <= e) && Array.prototype.splice.call(d, e, 1);\r\n f && (ab(b), 0 == a.a[c].length && (delete a.a[c], a.b--));\r\n} }\r\nfunction cb(a, b, c, d) { for (var e = 0; e < a.length; ++e) {\r\n var f = a[e];\r\n if (!f.Y && f.listener == b && f.capture == !!c && f.ca == d)\r\n return e;\r\n} return -1; }\r\nvar eb = \"closure_lm_\" + (1E6 * Math.random() | 0), fb = {};\r\nfunction hb(a, b, c, d, e) { if (d && d.once)\r\n return ib(a, b, c, d, e); if (Array.isArray(b)) {\r\n for (var f = 0; f < b.length; f++)\r\n hb(a, b[f], c, d, e);\r\n return null;\r\n} c = jb(c); return a && a[C] ? a.va(b, c, n(d) ? !!d.capture : !!d, e) : kb(a, b, c, !1, d, e); }\r\nfunction kb(a, b, c, d, e, f) {\r\n if (!b)\r\n throw Error(\"Invalid event type\");\r\n var h = n(e) ? !!e.capture : !!e;\r\n if (h && !Va)\r\n return null;\r\n var m = lb(a);\r\n m || (a[eb] = m = new bb(a));\r\n c = m.add(b, c, d, h, f);\r\n if (c.proxy)\r\n return c;\r\n d = mb();\r\n c.proxy = d;\r\n d.src = a;\r\n d.listener = c;\r\n if (a.addEventListener)\r\n Xa || (e = h), void 0 === e && (e = !1), a.addEventListener(b.toString(), d, e);\r\n else if (a.attachEvent)\r\n a.attachEvent(nb(b.toString()), d);\r\n else if (a.addListener && a.removeListener)\r\n a.addListener(d);\r\n else\r\n throw Error(\"addEventListener and attachEvent are unavailable.\");\r\n return c;\r\n}\r\nfunction mb() { var a = ob, b = Va ? function (c) { return a.call(b.src, b.listener, c); } : function (c) { c = a.call(b.src, b.listener, c); if (!c)\r\n return c; }; return b; }\r\nfunction ib(a, b, c, d, e) { if (Array.isArray(b)) {\r\n for (var f = 0; f < b.length; f++)\r\n ib(a, b[f], c, d, e);\r\n return null;\r\n} c = jb(c); return a && a[C] ? a.wa(b, c, n(d) ? !!d.capture : !!d, e) : kb(a, b, c, !0, d, e); }\r\nfunction pb(a, b, c, d, e) { if (Array.isArray(b))\r\n for (var f = 0; f < b.length; f++)\r\n pb(a, b[f], c, d, e);\r\nelse\r\n (d = n(d) ? !!d.capture : !!d, c = jb(c), a && a[C]) ? (a = a.c, b = String(b).toString(), b in a.a && (f = a.a[b], c = cb(f, c, d, e), -1 < c && (ab(f[c]), Array.prototype.splice.call(f, c, 1), 0 == f.length && (delete a.a[b], a.b--)))) : a && (a = lb(a)) && (b = a.a[b.toString()], a = -1, b && (a = cb(b, c, d, e)), (c = -1 < a ? b[a] : null) && rb(c)); }\r\nfunction rb(a) { if (\"number\" !== typeof a && a && !a.Y) {\r\n var b = a.src;\r\n if (b && b[C])\r\n db(b.c, a);\r\n else {\r\n var c = a.type, d = a.proxy;\r\n b.removeEventListener ? b.removeEventListener(c, d, a.capture) : b.detachEvent ? b.detachEvent(nb(c), d) : b.addListener && b.removeListener && b.removeListener(d);\r\n (c = lb(b)) ? (db(c, a), 0 == c.b && (c.src = null, b[eb] = null)) : ab(a);\r\n }\r\n} }\r\nfunction nb(a) { return a in fb ? fb[a] : fb[a] = \"on\" + a; }\r\nfunction sb(a, b) { var c = a.listener, d = a.ca || a.src; a.Z && rb(a); return c.call(d, b); }\r\nfunction ob(a, b) { if (a.Y)\r\n return !0; if (!Va) {\r\n if (!b)\r\n a: {\r\n b = [\"window\", \"event\"];\r\n for (var c = k, d = 0; d < b.length; d++)\r\n if (c = c[b[d]], null == c) {\r\n b = null;\r\n break a;\r\n }\r\n b = c;\r\n }\r\n b = new A(b, this);\r\n return sb(a, b);\r\n} return sb(a, new A(b, this)); }\r\nfunction lb(a) { a = a[eb]; return a instanceof bb ? a : null; }\r\nvar tb = \"__closure_events_fn_\" + (1E9 * Math.random() >>> 0);\r\nfunction jb(a) { if (\"function\" == ba(a))\r\n return a; a[tb] || (a[tb] = function (b) { return a.handleEvent(b); }); return a[tb]; }\r\nfunction D() { u.call(this); this.c = new bb(this); this.J = this; this.C = null; }\r\nr(D, u);\r\nD.prototype[C] = !0;\r\ng = D.prototype;\r\ng.addEventListener = function (a, b, c, d) { hb(this, a, b, c, d); };\r\ng.removeEventListener = function (a, b, c, d) { pb(this, a, b, c, d); };\r\ng.dispatchEvent = function (a) { var b, c = this.C; if (c)\r\n for (b = []; c; c = c.C)\r\n b.push(c); c = this.J; var d = a.type || a; if (\"string\" === typeof a)\r\n a = new y(a, c);\r\nelse if (a instanceof y)\r\n a.target = a.target || c;\r\nelse {\r\n var e = a;\r\n a = new y(d, c);\r\n Da(a, e);\r\n} e = !0; if (b)\r\n for (var f = b.length - 1; 0 <= f; f--) {\r\n var h = a.a = b[f];\r\n e = ub(h, d, !0, a) && e;\r\n } h = a.a = c; e = ub(h, d, !0, a) && e; e = ub(h, d, !1, a) && e; if (b)\r\n for (f = 0; f < b.length; f++)\r\n h = a.a = b[f], e = ub(h, d, !1, a) && e; return e; };\r\ng.G = function () { D.S.G.call(this); if (this.c) {\r\n var a = this.c, c;\r\n for (c in a.a) {\r\n for (var d = a.a[c], e = 0; e < d.length; e++)\r\n ab(d[e]);\r\n delete a.a[c];\r\n a.b--;\r\n }\r\n} this.C = null; };\r\ng.va = function (a, b, c, d) { return this.c.add(String(a), b, !1, c, d); };\r\ng.wa = function (a, b, c, d) { return this.c.add(String(a), b, !0, c, d); };\r\nfunction ub(a, b, c, d) { b = a.c.a[String(b)]; if (!b)\r\n return !0; b = b.concat(); for (var e = !0, f = 0; f < b.length; ++f) {\r\n var h = b[f];\r\n if (h && !h.Y && h.capture == c) {\r\n var m = h.listener, l = h.ca || h.src;\r\n h.Z && db(a.c, h);\r\n e = !1 !== m.call(l, d) && e;\r\n }\r\n} return e && !d.defaultPrevented; }\r\nvar vb = k.JSON.stringify;\r\nfunction wb() { this.b = this.a = null; }\r\nvar yb = new /** @class */ (function () {\r\n function class_1(a, b, c) {\r\n this.f = c;\r\n this.c = a;\r\n this.g = b;\r\n this.b = 0;\r\n this.a = null;\r\n }\r\n class_1.prototype.get = function () { var a; 0 < this.b ? (this.b--, a = this.a, this.a = a.next, a.next = null) : a = this.c(); return a; };\r\n return class_1;\r\n}())(function () { return new xb; }, function (a) { a.reset(); }, 100);\r\nwb.prototype.add = function (a, b) { var c = yb.get(); c.set(a, b); this.b ? this.b.next = c : this.a = c; this.b = c; };\r\nfunction zb() { var a = Ab, b = null; a.a && (b = a.a, a.a = a.a.next, a.a || (a.b = null), b.next = null); return b; }\r\nfunction xb() { this.next = this.b = this.a = null; }\r\nxb.prototype.set = function (a, b) { this.a = a; this.b = b; this.next = null; };\r\nxb.prototype.reset = function () { this.next = this.b = this.a = null; };\r\nfunction Bb(a) { k.setTimeout(function () { throw a; }, 0); }\r\nfunction Cb(a, b) { Db || Eb(); Fb || (Db(), Fb = !0); Ab.add(a, b); }\r\nvar Db;\r\nfunction Eb() { var a = k.Promise.resolve(void 0); Db = function () { a.then(Gb); }; }\r\nvar Fb = !1, Ab = new wb;\r\nfunction Gb() { for (var a; a = zb();) {\r\n try {\r\n a.a.call(a.b);\r\n }\r\n catch (c) {\r\n Bb(c);\r\n }\r\n var b = yb;\r\n b.g(a);\r\n b.b < b.f && (b.b++, a.next = b.a, b.a = a);\r\n} Fb = !1; }\r\nfunction Hb(a, b) { D.call(this); this.b = a || 1; this.a = b || k; this.f = p(this.Ya, this); this.g = q(); }\r\nr(Hb, D);\r\ng = Hb.prototype;\r\ng.aa = !1;\r\ng.M = null;\r\ng.Ya = function () { if (this.aa) {\r\n var a = q() - this.g;\r\n 0 < a && a < .8 * this.b ? this.M = this.a.setTimeout(this.f, this.b - a) : (this.M && (this.a.clearTimeout(this.M), this.M = null), this.dispatchEvent(\"tick\"), this.aa && (Ib(this), this.start()));\r\n} };\r\ng.start = function () { this.aa = !0; this.M || (this.M = this.a.setTimeout(this.f, this.b), this.g = q()); };\r\nfunction Ib(a) { a.aa = !1; a.M && (a.a.clearTimeout(a.M), a.M = null); }\r\ng.G = function () { Hb.S.G.call(this); Ib(this); delete this.a; };\r\nfunction Jb(a, b, c) { if (\"function\" == ba(a))\r\n c && (a = p(a, c));\r\nelse if (a && \"function\" == typeof a.handleEvent)\r\n a = p(a.handleEvent, a);\r\nelse\r\n throw Error(\"Invalid listener argument\"); return 2147483647 < Number(b) ? -1 : k.setTimeout(a, b || 0); }\r\nfunction Kb(a) { a.a = Jb(function () { a.a = null; a.c && (a.c = !1, Kb(a)); }, a.h); var b = a.b; a.b = null; a.g.apply(null, b); }\r\nvar Lb = /** @class */ (function (_super) {\r\n __extends(Lb, _super);\r\n function Lb(a, b, c) {\r\n var _this = _super.call(this) || this;\r\n _this.g = null != c ? a.bind(c) : a;\r\n _this.h = b;\r\n _this.b = null;\r\n _this.c = !1;\r\n _this.a = null;\r\n return _this;\r\n }\r\n Lb.prototype.f = function (a) { this.b = arguments; this.a ? this.c = !0 : Kb(this); };\r\n Lb.prototype.G = function () { _super.prototype.G.call(this); this.a && (k.clearTimeout(this.a), this.a = null, this.c = !1, this.b = null); };\r\n return Lb;\r\n}(u));\r\nfunction E(a) { u.call(this); this.b = a; this.a = {}; }\r\nr(E, u);\r\nvar Mb = [];\r\nfunction Nb(a, b, c, d) { Array.isArray(c) || (c && (Mb[0] = c.toString()), c = Mb); for (var e = 0; e < c.length; e++) {\r\n var f = hb(b, c[e], d || a.handleEvent, !1, a.b || a);\r\n if (!f)\r\n break;\r\n a.a[f.key] = f;\r\n} }\r\nfunction Ob(a) { Aa(a.a, function (b, c) { this.a.hasOwnProperty(c) && rb(b); }, a); a.a = {}; }\r\nE.prototype.G = function () { E.S.G.call(this); Ob(this); };\r\nE.prototype.handleEvent = function () { throw Error(\"EventHandler.handleEvent not implemented\"); };\r\nfunction Pb() { this.a = !0; }\r\nfunction Qb(a, b, c, d, e, f) { a.info(function () { if (a.a)\r\n if (f) {\r\n var h = \"\";\r\n for (var m = f.split(\"&\"), l = 0; l < m.length; l++) {\r\n var t = m[l].split(\"=\");\r\n if (1 < t.length) {\r\n var B = t[0];\r\n t = t[1];\r\n var z = B.split(\"_\");\r\n h = 2 <= z.length && \"type\" == z[1] ? h + (B + \"=\" + t + \"&\") : h + (B + \"=redacted&\");\r\n }\r\n }\r\n }\r\n else\r\n h = null;\r\nelse\r\n h = f; return \"XMLHTTP REQ (\" + d + \") [attempt \" + e + \"]: \" + b + \"\\n\" + c + \"\\n\" + h; }); }\r\nfunction Rb(a, b, c, d, e, f, h) { a.info(function () { return \"XMLHTTP RESP (\" + d + \") [ attempt \" + e + \"]: \" + b + \"\\n\" + c + \"\\n\" + f + \" \" + h; }); }\r\nfunction F(a, b, c, d) { a.info(function () { return \"XMLHTTP TEXT (\" + b + \"): \" + Sb(a, c) + (d ? \" \" + d : \"\"); }); }\r\nfunction Tb(a, b) { a.info(function () { return \"TIMEOUT: \" + b; }); }\r\nPb.prototype.info = function () { };\r\nfunction Sb(a, b) { if (!a.a)\r\n return b; if (!b)\r\n return null; try {\r\n var c = JSON.parse(b);\r\n if (c)\r\n for (a = 0; a < c.length; a++)\r\n if (Array.isArray(c[a])) {\r\n var d = c[a];\r\n if (!(2 > d.length)) {\r\n var e = d[1];\r\n if (Array.isArray(e) && !(1 > e.length)) {\r\n var f = e[0];\r\n if (\"noop\" != f && \"stop\" != f && \"close\" != f)\r\n for (var h = 1; h < e.length; h++)\r\n e[h] = \"\";\r\n }\r\n }\r\n }\r\n return vb(c);\r\n}\r\ncatch (m) {\r\n return b;\r\n} }\r\nvar Ub = null;\r\nfunction Vb() { return Ub = Ub || new D; }\r\nfunction Wb(a) { y.call(this, \"serverreachability\", a); }\r\nr(Wb, y);\r\nfunction G(a) { var b = Vb(); b.dispatchEvent(new Wb(b, a)); }\r\nfunction Xb(a) { y.call(this, \"statevent\", a); }\r\nr(Xb, y);\r\nfunction H(a) { var b = Vb(); b.dispatchEvent(new Xb(b, a)); }\r\nfunction Yb(a) { y.call(this, \"timingevent\", a); }\r\nr(Yb, y);\r\nfunction I(a, b) { if (\"function\" != ba(a))\r\n throw Error(\"Fn must not be null and must be a function\"); return k.setTimeout(function () { a(); }, b); }\r\nvar Zb = { NO_ERROR: 0, Za: 1, gb: 2, fb: 3, bb: 4, eb: 5, hb: 6, Da: 7, TIMEOUT: 8, kb: 9 };\r\nvar $b = { ab: \"complete\", ob: \"success\", Ea: \"error\", Da: \"abort\", mb: \"ready\", nb: \"readystatechange\", TIMEOUT: \"timeout\", ib: \"incrementaldata\", lb: \"progress\", cb: \"downloadprogress\", pb: \"uploadprogress\" };\r\nfunction ac() { }\r\nac.prototype.a = null;\r\nfunction bc(a) { var b; (b = a.a) || (b = a.a = {}); return b; }\r\nfunction cc() { }\r\nvar J = { OPEN: \"a\", $a: \"b\", Ea: \"c\", jb: \"d\" };\r\nfunction dc() { y.call(this, \"d\"); }\r\nr(dc, y);\r\nfunction ec() { y.call(this, \"c\"); }\r\nr(ec, y);\r\nvar fc;\r\nfunction gc() { }\r\nr(gc, ac);\r\nfc = new gc;\r\nfunction K(a, b, c, d) { this.g = a; this.c = b; this.f = c; this.T = d || 1; this.J = new E(this); this.P = hc; a = Ja ? 125 : void 0; this.R = new Hb(a); this.B = null; this.b = !1; this.j = this.l = this.i = this.H = this.u = this.U = this.o = null; this.s = []; this.a = null; this.D = 0; this.h = this.m = null; this.N = -1; this.A = !1; this.O = 0; this.F = null; this.W = this.C = this.V = this.I = !1; }\r\nvar hc = 45E3, ic = {}, jc = {};\r\ng = K.prototype;\r\ng.setTimeout = function (a) { this.P = a; };\r\nfunction kc(a, b, c) { a.H = 1; a.i = lc(L(b)); a.j = c; a.I = !0; mc(a, null); }\r\nfunction mc(a, b) { a.u = q(); M(a); a.l = L(a.i); var c = a.l, d = a.T; Array.isArray(d) || (d = [String(d)]); nc(c.b, \"t\", d); a.D = 0; a.a = oc(a.g, a.g.C ? b : null); 0 < a.O && (a.F = new Lb(p(a.Ca, a, a.a), a.O)); Nb(a.J, a.a, \"readystatechange\", a.Wa); b = a.B ? Ba(a.B) : {}; a.j ? (a.m || (a.m = \"POST\"), b[\"Content-Type\"] = \"application/x-www-form-urlencoded\", a.a.ba(a.l, a.m, a.j, b)) : (a.m = \"GET\", a.a.ba(a.l, a.m, null, b)); G(1); Qb(a.c, a.m, a.l, a.f, a.T, a.j); }\r\ng.Wa = function (a) { a = a.target; var b = this.F; b && 3 == N(a) ? b.f() : this.Ca(a); };\r\ng.Ca = function (a) {\r\n try {\r\n if (a == this.a)\r\n a: {\r\n var b = N(this.a), c = this.a.ua(), d = this.a.X();\r\n if (!(3 > b || 3 == b && !Ja && !this.a.$())) {\r\n this.A || 4 != b || 7 == c || (8 == c || 0 >= d ? G(3) : G(2));\r\n pc(this);\r\n var e = this.a.X();\r\n this.N = e;\r\n var f = this.a.$();\r\n this.b = 200 == e;\r\n Rb(this.c, this.m, this.l, this.f, this.T, b, e);\r\n if (this.b) {\r\n if (this.V && !this.C) {\r\n b: {\r\n if (this.a) {\r\n var h, m = this.a;\r\n if ((h = m.a ? m.a.getResponseHeader(\"X-HTTP-Initial-Response\") : null) && !ta(h)) {\r\n var l = h;\r\n break b;\r\n }\r\n }\r\n l = null;\r\n }\r\n if (l)\r\n F(this.c, this.f, l, \"Initial handshake response via X-HTTP-Initial-Response\"),\r\n this.C = !0, qc(this, l);\r\n else {\r\n this.b = !1;\r\n this.h = 3;\r\n H(12);\r\n O(this);\r\n rc(this);\r\n break a;\r\n }\r\n }\r\n this.I ? (tc(this, b, f), Ja && this.b && 3 == b && (Nb(this.J, this.R, \"tick\", this.Va), this.R.start())) : (F(this.c, this.f, f, null), qc(this, f));\r\n 4 == b && O(this);\r\n this.b && !this.A && (4 == b ? uc(this.g, this) : (this.b = !1, M(this)));\r\n }\r\n else\r\n 400 == e && 0 < f.indexOf(\"Unknown SID\") ? (this.h = 3, H(12)) : (this.h = 0, H(13)), O(this), rc(this);\r\n }\r\n }\r\n }\r\n catch (t) { }\r\n finally { }\r\n};\r\nfunction tc(a, b, c) { for (var d = !0; !a.A && a.D < c.length;) {\r\n var e = vc(a, c);\r\n if (e == jc) {\r\n 4 == b && (a.h = 4, H(14), d = !1);\r\n F(a.c, a.f, null, \"[Incomplete Response]\");\r\n break;\r\n }\r\n else if (e == ic) {\r\n a.h = 4;\r\n H(15);\r\n F(a.c, a.f, c, \"[Invalid Chunk]\");\r\n d = !1;\r\n break;\r\n }\r\n else\r\n F(a.c, a.f, e, null), qc(a, e);\r\n} 4 == b && 0 == c.length && (a.h = 1, H(16), d = !1); a.b = a.b && d; d ? 0 < c.length && !a.W && (a.W = !0, b = a.g, b.a == a && b.V && !b.F && (b.c.info(\"Great, no buffering proxy detected. Bytes received: \" + c.length), xc(b), b.F = !0)) : (F(a.c, a.f, c, \"[Invalid Chunked Response]\"), O(a), rc(a)); }\r\ng.Va = function () { if (this.a) {\r\n var a = N(this.a), b = this.a.$();\r\n this.D < b.length && (pc(this), tc(this, a, b), this.b && 4 != a && M(this));\r\n} };\r\nfunction vc(a, b) { var c = a.D, d = b.indexOf(\"\\n\", c); if (-1 == d)\r\n return jc; c = Number(b.substring(c, d)); if (isNaN(c))\r\n return ic; d += 1; if (d + c > b.length)\r\n return jc; b = b.substr(d, c); a.D = d + c; return b; }\r\ng.cancel = function () { this.A = !0; O(this); };\r\nfunction M(a) { a.U = q() + a.P; yc(a, a.P); }\r\nfunction yc(a, b) { if (null != a.o)\r\n throw Error(\"WatchDog timer not null\"); a.o = I(p(a.Ua, a), b); }\r\nfunction pc(a) { a.o && (k.clearTimeout(a.o), a.o = null); }\r\ng.Ua = function () { this.o = null; var a = q(); 0 <= a - this.U ? (Tb(this.c, this.l), 2 != this.H && (G(3), H(17)), O(this), this.h = 2, rc(this)) : yc(this, this.U - a); };\r\nfunction rc(a) { 0 == a.g.v || a.A || uc(a.g, a); }\r\nfunction O(a) { pc(a); var b = a.F; b && \"function\" == typeof b.ja && b.ja(); a.F = null; Ib(a.R); Ob(a.J); a.a && (b = a.a, a.a = null, b.abort(), b.ja()); }\r\nfunction qc(a, b) {\r\n try {\r\n var c = a.g;\r\n if (0 != c.v && (c.a == a || zc(c.b, a)))\r\n if (c.I = a.N, !a.C && zc(c.b, a) && 3 == c.v) {\r\n try {\r\n var d = c.ka.a.parse(b);\r\n }\r\n catch (sc) {\r\n d = null;\r\n }\r\n if (Array.isArray(d) && 3 == d.length) {\r\n var e = d;\r\n if (0 == e[0])\r\n a: {\r\n if (!c.j) {\r\n if (c.a)\r\n if (c.a.u + 3E3 < a.u)\r\n Ac(c), Bc(c);\r\n else\r\n break a;\r\n Cc(c);\r\n H(18);\r\n }\r\n }\r\n else\r\n c.oa = e[1], 0 < c.oa - c.P && 37500 > e[2] && c.H && 0 == c.o && !c.m && (c.m = I(p(c.Ra, c), 6E3));\r\n if (1 >= Dc(c.b) && c.ea) {\r\n try {\r\n c.ea();\r\n }\r\n catch (sc) { }\r\n c.ea = void 0;\r\n }\r\n }\r\n else\r\n P(c, 11);\r\n }\r\n else if ((a.C || c.a == a) && Ac(c), !ta(b))\r\n for (b = d = c.ka.a.parse(b), d = 0; d < b.length; d++)\r\n if (e =\r\n b[d], c.P = e[0], e = e[1], 2 == c.v)\r\n if (\"c\" == e[0]) {\r\n c.J = e[1];\r\n c.ga = e[2];\r\n var f = e[3];\r\n null != f && (c.ha = f, c.c.info(\"VER=\" + c.ha));\r\n var h = e[4];\r\n null != h && (c.pa = h, c.c.info(\"SVER=\" + c.pa));\r\n var m = e[5];\r\n if (null != m && \"number\" === typeof m && 0 < m) {\r\n var l = 1.5 * m;\r\n c.D = l;\r\n c.c.info(\"backChannelRequestTimeoutMs_=\" + l);\r\n }\r\n l = c;\r\n var t = a.a;\r\n if (t) {\r\n var B = t.a ? t.a.getResponseHeader(\"X-Client-Wire-Protocol\") : null;\r\n if (B) {\r\n var z = l.b;\r\n !z.a && (v(B, \"spdy\") || v(B, \"quic\") || v(B, \"h2\")) && (z.f = z.g, z.a = new Set, z.b && (Ec(z, z.b), z.b = null));\r\n }\r\n if (l.A) {\r\n var qb = t.a ? t.a.getResponseHeader(\"X-HTTP-Session-Id\") :\r\n null;\r\n qb && (l.na = qb, Q(l.B, l.A, qb));\r\n }\r\n }\r\n c.v = 3;\r\n c.f && c.f.ta();\r\n c.V && (c.N = q() - a.u, c.c.info(\"Handshake RTT: \" + c.N + \"ms\"));\r\n l = c;\r\n var va = a;\r\n l.la = Fc(l, l.C ? l.ga : null, l.fa);\r\n if (va.C) {\r\n Gc(l.b, va);\r\n var wa = va, wc = l.D;\r\n wc && wa.setTimeout(wc);\r\n wa.o && (pc(wa), M(wa));\r\n l.a = va;\r\n }\r\n else\r\n Hc(l);\r\n 0 < c.g.length && Ic(c);\r\n }\r\n else\r\n \"stop\" != e[0] && \"close\" != e[0] || P(c, 7);\r\n else\r\n 3 == c.v && (\"stop\" == e[0] || \"close\" == e[0] ? \"stop\" == e[0] ? P(c, 7) : Jc(c) : \"noop\" != e[0] && c.f && c.f.sa(e), c.o = 0);\r\n G(4);\r\n }\r\n catch (sc) { }\r\n}\r\nfunction Kc(a) { if (a.K && \"function\" == typeof a.K)\r\n return a.K(); if (\"string\" === typeof a)\r\n return a.split(\"\"); if (ca(a)) {\r\n for (var b = [], c = a.length, d = 0; d < c; d++)\r\n b.push(a[d]);\r\n return b;\r\n} b = []; c = 0; for (d in a)\r\n b[c++] = a[d]; return a = b; }\r\nfunction Lc(a, b) { if (a.forEach && \"function\" == typeof a.forEach)\r\n a.forEach(b, void 0);\r\nelse if (ca(a) || \"string\" === typeof a)\r\n oa(a, b, void 0);\r\nelse {\r\n if (a.L && \"function\" == typeof a.L)\r\n var c = a.L();\r\n else if (a.K && \"function\" == typeof a.K)\r\n c = void 0;\r\n else if (ca(a) || \"string\" === typeof a) {\r\n c = [];\r\n for (var d = a.length, e = 0; e < d; e++)\r\n c.push(e);\r\n }\r\n else\r\n for (e in c = [], d = 0, a)\r\n c[d++] = e;\r\n d = Kc(a);\r\n e = d.length;\r\n for (var f = 0; f < e; f++)\r\n b.call(void 0, d[f], c && c[f], a);\r\n} }\r\nfunction R(a, b) { this.b = {}; this.a = []; this.c = 0; var c = arguments.length; if (1 < c) {\r\n if (c % 2)\r\n throw Error(\"Uneven number of arguments\");\r\n for (var d = 0; d < c; d += 2)\r\n this.set(arguments[d], arguments[d + 1]);\r\n}\r\nelse if (a)\r\n if (a instanceof R)\r\n for (c = a.L(), d = 0; d < c.length; d++)\r\n this.set(c[d], a.get(c[d]));\r\n else\r\n for (d in a)\r\n this.set(d, a[d]); }\r\ng = R.prototype;\r\ng.K = function () { Mc(this); for (var a = [], b = 0; b < this.a.length; b++)\r\n a.push(this.b[this.a[b]]); return a; };\r\ng.L = function () { Mc(this); return this.a.concat(); };\r\nfunction Mc(a) { if (a.c != a.a.length) {\r\n for (var b = 0, c = 0; b < a.a.length;) {\r\n var d = a.a[b];\r\n S(a.b, d) && (a.a[c++] = d);\r\n b++;\r\n }\r\n a.a.length = c;\r\n} if (a.c != a.a.length) {\r\n var e = {};\r\n for (c = b = 0; b < a.a.length;)\r\n d = a.a[b], S(e, d) || (a.a[c++] = d, e[d] = 1), b++;\r\n a.a.length = c;\r\n} }\r\ng.get = function (a, b) { return S(this.b, a) ? this.b[a] : b; };\r\ng.set = function (a, b) { S(this.b, a) || (this.c++, this.a.push(a)); this.b[a] = b; };\r\ng.forEach = function (a, b) { for (var c = this.L(), d = 0; d < c.length; d++) {\r\n var e = c[d], f = this.get(e);\r\n a.call(b, f, e, this);\r\n} };\r\nfunction S(a, b) { return Object.prototype.hasOwnProperty.call(a, b); }\r\nvar Nc = /^(?:([^:/?#.]+):)?(?:\\/\\/(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$/;\r\nfunction Oc(a, b) { if (a) {\r\n a = a.split(\"&\");\r\n for (var c = 0; c < a.length; c++) {\r\n var d = a[c].indexOf(\"=\"), e = null;\r\n if (0 <= d) {\r\n var f = a[c].substring(0, d);\r\n e = a[c].substring(d + 1);\r\n }\r\n else\r\n f = a[c];\r\n b(f, e ? decodeURIComponent(e.replace(/\\+/g, \" \")) : \"\");\r\n }\r\n} }\r\nfunction T(a, b) { this.c = this.j = this.f = \"\"; this.h = null; this.i = this.g = \"\"; this.a = !1; if (a instanceof T) {\r\n this.a = void 0 !== b ? b : a.a;\r\n Pc(this, a.f);\r\n this.j = a.j;\r\n Qc(this, a.c);\r\n Rc(this, a.h);\r\n this.g = a.g;\r\n b = a.b;\r\n var c = new U;\r\n c.c = b.c;\r\n b.a && (c.a = new R(b.a), c.b = b.b);\r\n Sc(this, c);\r\n this.i = a.i;\r\n}\r\nelse\r\n a && (c = String(a).match(Nc)) ? (this.a = !!b, Pc(this, c[1] || \"\", !0), this.j = Tc(c[2] || \"\"), Qc(this, c[3] || \"\", !0), Rc(this, c[4]), this.g = Tc(c[5] || \"\", !0), Sc(this, c[6] || \"\", !0), this.i = Tc(c[7] || \"\")) : (this.a = !!b, this.b = new U(null, this.a)); }\r\nT.prototype.toString = function () { var a = [], b = this.f; b && a.push(Uc(b, Vc, !0), \":\"); var c = this.c; if (c || \"file\" == b)\r\n a.push(\"//\"), (b = this.j) && a.push(Uc(b, Vc, !0), \"@\"), a.push(encodeURIComponent(String(c)).replace(/%25([0-9a-fA-F]{2})/g, \"%$1\")), c = this.h, null != c && a.push(\":\", String(c)); if (c = this.g)\r\n this.c && \"/\" != c.charAt(0) && a.push(\"/\"), a.push(Uc(c, \"/\" == c.charAt(0) ? Wc : Xc, !0)); (c = this.b.toString()) && a.push(\"?\", c); (c = this.i) && a.push(\"#\", Uc(c, Yc)); return a.join(\"\"); };\r\nfunction L(a) { return new T(a); }\r\nfunction Pc(a, b, c) { a.f = c ? Tc(b, !0) : b; a.f && (a.f = a.f.replace(/:$/, \"\")); }\r\nfunction Qc(a, b, c) { a.c = c ? Tc(b, !0) : b; }\r\nfunction Rc(a, b) { if (b) {\r\n b = Number(b);\r\n if (isNaN(b) || 0 > b)\r\n throw Error(\"Bad port number \" + b);\r\n a.h = b;\r\n}\r\nelse\r\n a.h = null; }\r\nfunction Sc(a, b, c) { b instanceof U ? (a.b = b, Zc(a.b, a.a)) : (c || (b = Uc(b, $c)), a.b = new U(b, a.a)); }\r\nfunction Q(a, b, c) { a.b.set(b, c); }\r\nfunction lc(a) { Q(a, \"zx\", Math.floor(2147483648 * Math.random()).toString(36) + Math.abs(Math.floor(2147483648 * Math.random()) ^ q()).toString(36)); return a; }\r\nfunction ad(a) { return a instanceof T ? L(a) : new T(a, void 0); }\r\nfunction bd(a, b, c, d) { var e = new T(null, void 0); a && Pc(e, a); b && Qc(e, b); c && Rc(e, c); d && (e.g = d); return e; }\r\nfunction Tc(a, b) { return a ? b ? decodeURI(a.replace(/%25/g, \"%2525\")) : decodeURIComponent(a) : \"\"; }\r\nfunction Uc(a, b, c) { return \"string\" === typeof a ? (a = encodeURI(a).replace(b, cd), c && (a = a.replace(/%25([0-9a-fA-F]{2})/g, \"%$1\")), a) : null; }\r\nfunction cd(a) { a = a.charCodeAt(0); return \"%\" + (a >> 4 & 15).toString(16) + (a & 15).toString(16); }\r\nvar Vc = /[#\\/\\?@]/g, Xc = /[#\\?:]/g, Wc = /[#\\?]/g, $c = /[#\\?@]/g, Yc = /#/g;\r\nfunction U(a, b) { this.b = this.a = null; this.c = a || null; this.f = !!b; }\r\nfunction V(a) { a.a || (a.a = new R, a.b = 0, a.c && Oc(a.c, function (b, c) { a.add(decodeURIComponent(b.replace(/\\+/g, \" \")), c); })); }\r\ng = U.prototype;\r\ng.add = function (a, b) { V(this); this.c = null; a = W(this, a); var c = this.a.get(a); c || this.a.set(a, c = []); c.push(b); this.b += 1; return this; };\r\nfunction dd(a, b) { V(a); b = W(a, b); S(a.a.b, b) && (a.c = null, a.b -= a.a.get(b).length, a = a.a, S(a.b, b) && (delete a.b[b], a.c--, a.a.length > 2 * a.c && Mc(a))); }\r\nfunction ed(a, b) { V(a); b = W(a, b); return S(a.a.b, b); }\r\ng.forEach = function (a, b) { V(this); this.a.forEach(function (c, d) { oa(c, function (e) { a.call(b, e, d, this); }, this); }, this); };\r\ng.L = function () { V(this); for (var a = this.a.K(), b = this.a.L(), c = [], d = 0; d < b.length; d++)\r\n for (var e = a[d], f = 0; f < e.length; f++)\r\n c.push(b[d]); return c; };\r\ng.K = function (a) { V(this); var b = []; if (\"string\" === typeof a)\r\n ed(this, a) && (b = ra(b, this.a.get(W(this, a))));\r\nelse {\r\n a = this.a.K();\r\n for (var c = 0; c < a.length; c++)\r\n b = ra(b, a[c]);\r\n} return b; };\r\ng.set = function (a, b) { V(this); this.c = null; a = W(this, a); ed(this, a) && (this.b -= this.a.get(a).length); this.a.set(a, [b]); this.b += 1; return this; };\r\ng.get = function (a, b) { if (!a)\r\n return b; a = this.K(a); return 0 < a.length ? String(a[0]) : b; };\r\nfunction nc(a, b, c) { dd(a, b); 0 < c.length && (a.c = null, a.a.set(W(a, b), sa(c)), a.b += c.length); }\r\ng.toString = function () { if (this.c)\r\n return this.c; if (!this.a)\r\n return \"\"; for (var a = [], b = this.a.L(), c = 0; c < b.length; c++) {\r\n var d = b[c], e = encodeURIComponent(String(d));\r\n d = this.K(d);\r\n for (var f = 0; f < d.length; f++) {\r\n var h = e;\r\n \"\" !== d[f] && (h += \"=\" + encodeURIComponent(String(d[f])));\r\n a.push(h);\r\n }\r\n} return this.c = a.join(\"&\"); };\r\nfunction W(a, b) { b = String(b); a.f && (b = b.toLowerCase()); return b; }\r\nfunction Zc(a, b) { b && !a.f && (V(a), a.c = null, a.a.forEach(function (c, d) { var e = d.toLowerCase(); d != e && (dd(this, d), nc(this, e, c)); }, a)); a.f = b; }\r\nfunction fd(a, b) { this.b = a; this.a = b; }\r\nfunction gd(a) { this.g = a || hd; k.PerformanceNavigationTiming ? (a = k.performance.getEntriesByType(\"navigation\"), a = 0 < a.length && (\"hq\" == a[0].nextHopProtocol || \"h2\" == a[0].nextHopProtocol)) : a = !!(k.ia && k.ia.ya && k.ia.ya() && k.ia.ya().qb); this.f = a ? this.g : 1; this.a = null; 1 < this.f && (this.a = new Set); this.b = null; this.c = []; }\r\nvar hd = 10;\r\nfunction id(a) { return a.b ? !0 : a.a ? a.a.size >= a.f : !1; }\r\nfunction Dc(a) { return a.b ? 1 : a.a ? a.a.size : 0; }\r\nfunction zc(a, b) { return a.b ? a.b == b : a.a ? a.a.has(b) : !1; }\r\nfunction Ec(a, b) { a.a ? a.a.add(b) : a.b = b; }\r\nfunction Gc(a, b) { a.b && a.b == b ? a.b = null : a.a && a.a.has(b) && a.a.delete(b); }\r\ngd.prototype.cancel = function () {\r\n var e_1, _a;\r\n this.c = jd(this);\r\n if (this.b)\r\n this.b.cancel(), this.b = null;\r\n else if (this.a && 0 !== this.a.size) {\r\n try {\r\n for (var _b = __values(this.a.values()), _c = _b.next(); !_c.done; _c = _b.next()) {\r\n var a = _c.value;\r\n a.cancel();\r\n }\r\n }\r\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\r\n finally {\r\n try {\r\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\r\n }\r\n finally { if (e_1) throw e_1.error; }\r\n }\r\n this.a.clear();\r\n }\r\n};\r\nfunction jd(a) {\r\n var e_2, _a;\r\n if (null != a.b)\r\n return a.c.concat(a.b.s);\r\n if (null != a.a && 0 !== a.a.size) {\r\n var b = a.c;\r\n try {\r\n for (var _b = __values(a.a.values()), _c = _b.next(); !_c.done; _c = _b.next()) {\r\n var c = _c.value;\r\n b = b.concat(c.s);\r\n }\r\n }\r\n catch (e_2_1) { e_2 = { error: e_2_1 }; }\r\n finally {\r\n try {\r\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\r\n }\r\n finally { if (e_2) throw e_2.error; }\r\n }\r\n return b;\r\n }\r\n return sa(a.c);\r\n}\r\nfunction kd() { }\r\nkd.prototype.stringify = function (a) { return k.JSON.stringify(a, void 0); };\r\nkd.prototype.parse = function (a) { return k.JSON.parse(a, void 0); };\r\nfunction ld() { this.a = new kd; }\r\nfunction md(a, b, c) { var d = c || \"\"; try {\r\n Lc(a, function (e, f) { var h = e; n(e) && (h = vb(e)); b.push(d + f + \"=\" + encodeURIComponent(h)); });\r\n}\r\ncatch (e) {\r\n throw b.push(d + \"type=\" + encodeURIComponent(\"_badmap\")), e;\r\n} }\r\nfunction nd(a, b) { var c = new Pb; if (k.Image) {\r\n var d = new Image;\r\n d.onload = ka(od, c, d, \"TestLoadImage: loaded\", !0, b);\r\n d.onerror = ka(od, c, d, \"TestLoadImage: error\", !1, b);\r\n d.onabort = ka(od, c, d, \"TestLoadImage: abort\", !1, b);\r\n d.ontimeout = ka(od, c, d, \"TestLoadImage: timeout\", !1, b);\r\n k.setTimeout(function () { if (d.ontimeout)\r\n d.ontimeout(); }, 1E4);\r\n d.src = a;\r\n}\r\nelse\r\n b(!1); }\r\nfunction od(a, b, c, d, e) { try {\r\n b.onload = null, b.onerror = null, b.onabort = null, b.ontimeout = null, e(d);\r\n}\r\ncatch (f) { } }\r\nvar pd = k.JSON.parse;\r\nfunction X(a) { D.call(this); this.headers = new R; this.H = a || null; this.b = !1; this.s = this.a = null; this.B = \"\"; this.h = 0; this.f = \"\"; this.g = this.A = this.l = this.u = !1; this.o = 0; this.m = null; this.I = qd; this.D = this.F = !1; }\r\nr(X, D);\r\nvar qd = \"\", rd = /^https?$/i, sd = [\"POST\", \"PUT\"];\r\ng = X.prototype;\r\ng.ba = function (a, b, c, d) {\r\n if (this.a)\r\n throw Error(\"[goog.net.XhrIo] Object is active with another request=\" + this.B + \"; newUri=\" + a);\r\n b = b ? b.toUpperCase() : \"GET\";\r\n this.B = a;\r\n this.f = \"\";\r\n this.h = 0;\r\n this.u = !1;\r\n this.b = !0;\r\n this.a = new XMLHttpRequest;\r\n this.s = this.H ? bc(this.H) : bc(fc);\r\n this.a.onreadystatechange = p(this.za, this);\r\n try {\r\n this.A = !0, this.a.open(b, String(a), !0), this.A = !1;\r\n }\r\n catch (f) {\r\n td(this, f);\r\n return;\r\n }\r\n a = c || \"\";\r\n var e = new R(this.headers);\r\n d && Lc(d, function (f, h) { e.set(h, f); });\r\n d = pa(e.L());\r\n c = k.FormData && a instanceof k.FormData;\r\n !(0 <=\r\n na(sd, b)) || d || c || e.set(\"Content-Type\", \"application/x-www-form-urlencoded;charset=utf-8\");\r\n e.forEach(function (f, h) { this.a.setRequestHeader(h, f); }, this);\r\n this.I && (this.a.responseType = this.I);\r\n \"withCredentials\" in this.a && this.a.withCredentials !== this.F && (this.a.withCredentials = this.F);\r\n try {\r\n ud(this), 0 < this.o && ((this.D = vd(this.a)) ? (this.a.timeout = this.o, this.a.ontimeout = p(this.xa, this)) : this.m = Jb(this.xa, this.o, this)), this.l = !0, this.a.send(a), this.l = !1;\r\n }\r\n catch (f) {\r\n td(this, f);\r\n }\r\n};\r\nfunction vd(a) { return x && Ra(9) && \"number\" === typeof a.timeout && void 0 !== a.ontimeout; }\r\nfunction qa(a) { return \"content-type\" == a.toLowerCase(); }\r\ng.xa = function () { \"undefined\" != typeof goog && this.a && (this.f = \"Timed out after \" + this.o + \"ms, aborting\", this.h = 8, this.dispatchEvent(\"timeout\"), this.abort(8)); };\r\nfunction td(a, b) { a.b = !1; a.a && (a.g = !0, a.a.abort(), a.g = !1); a.f = b; a.h = 5; wd(a); xd(a); }\r\nfunction wd(a) { a.u || (a.u = !0, a.dispatchEvent(\"complete\"), a.dispatchEvent(\"error\")); }\r\ng.abort = function (a) { this.a && this.b && (this.b = !1, this.g = !0, this.a.abort(), this.g = !1, this.h = a || 7, this.dispatchEvent(\"complete\"), this.dispatchEvent(\"abort\"), xd(this)); };\r\ng.G = function () { this.a && (this.b && (this.b = !1, this.g = !0, this.a.abort(), this.g = !1), xd(this, !0)); X.S.G.call(this); };\r\ng.za = function () { this.j || (this.A || this.l || this.g ? yd(this) : this.Ta()); };\r\ng.Ta = function () { yd(this); };\r\nfunction yd(a) {\r\n if (a.b && \"undefined\" != typeof goog && (!a.s[1] || 4 != N(a) || 2 != a.X()))\r\n if (a.l && 4 == N(a))\r\n Jb(a.za, 0, a);\r\n else if (a.dispatchEvent(\"readystatechange\"), 4 == N(a)) {\r\n a.b = !1;\r\n try {\r\n var b = a.X();\r\n a: switch (b) {\r\n case 200:\r\n case 201:\r\n case 202:\r\n case 204:\r\n case 206:\r\n case 304:\r\n case 1223:\r\n var c = !0;\r\n break a;\r\n default: c = !1;\r\n }\r\n var d;\r\n if (!(d = c)) {\r\n var e;\r\n if (e = 0 === b) {\r\n var f = String(a.B).match(Nc)[1] || null;\r\n if (!f && k.self && k.self.location) {\r\n var h = k.self.location.protocol;\r\n f = h.substr(0, h.length - 1);\r\n }\r\n e = !rd.test(f ? f.toLowerCase() : \"\");\r\n }\r\n d = e;\r\n }\r\n if (d)\r\n a.dispatchEvent(\"complete\"),\r\n a.dispatchEvent(\"success\");\r\n else {\r\n a.h = 6;\r\n try {\r\n var m = 2 < N(a) ? a.a.statusText : \"\";\r\n }\r\n catch (l) {\r\n m = \"\";\r\n }\r\n a.f = m + \" [\" + a.X() + \"]\";\r\n wd(a);\r\n }\r\n }\r\n finally {\r\n xd(a);\r\n }\r\n }\r\n}\r\nfunction xd(a, b) { if (a.a) {\r\n ud(a);\r\n var c = a.a, d = a.s[0] ? aa : null;\r\n a.a = null;\r\n a.s = null;\r\n b || a.dispatchEvent(\"ready\");\r\n try {\r\n c.onreadystatechange = d;\r\n }\r\n catch (e) { }\r\n} }\r\nfunction ud(a) { a.a && a.D && (a.a.ontimeout = null); a.m && (k.clearTimeout(a.m), a.m = null); }\r\nfunction N(a) { return a.a ? a.a.readyState : 0; }\r\ng.X = function () { try {\r\n return 2 < N(this) ? this.a.status : -1;\r\n}\r\ncatch (a) {\r\n return -1;\r\n} };\r\ng.$ = function () { try {\r\n return this.a ? this.a.responseText : \"\";\r\n}\r\ncatch (a) {\r\n return \"\";\r\n} };\r\ng.Na = function (a) { if (this.a) {\r\n var b = this.a.responseText;\r\n a && 0 == b.indexOf(a) && (b = b.substring(a.length));\r\n return pd(b);\r\n} };\r\ng.ua = function () { return this.h; };\r\ng.Qa = function () { return \"string\" === typeof this.f ? this.f : String(this.f); };\r\nfunction zd(a) { var b = \"\"; Aa(a, function (c, d) { b += d; b += \":\"; b += c; b += \"\\r\\n\"; }); return b; }\r\nfunction Ad(a, b, c) { a: {\r\n for (d in c) {\r\n var d = !1;\r\n break a;\r\n }\r\n d = !0;\r\n} d || (c = zd(c), \"string\" === typeof a ? (null != c && encodeURIComponent(String(c))) : Q(a, b, c)); }\r\nfunction Bd(a, b, c) { return c && c.internalChannelParams ? c.internalChannelParams[a] || b : b; }\r\nfunction Cd(a) {\r\n this.pa = 0;\r\n this.g = [];\r\n this.c = new Pb;\r\n this.ga = this.la = this.B = this.fa = this.a = this.na = this.A = this.W = this.i = this.O = this.l = null;\r\n this.La = this.R = 0;\r\n this.Ia = Bd(\"failFast\", !1, a);\r\n this.H = this.m = this.j = this.h = this.f = null;\r\n this.T = !0;\r\n this.I = this.oa = this.P = -1;\r\n this.U = this.o = this.u = 0;\r\n this.Fa = Bd(\"baseRetryDelayMs\", 5E3, a);\r\n this.Ma = Bd(\"retryDelaySeedMs\", 1E4, a);\r\n this.Ja = Bd(\"forwardChannelMaxRetries\", 2, a);\r\n this.ma = Bd(\"forwardChannelRequestTimeoutMs\", 2E4, a);\r\n this.Ka = a && a.g || void 0;\r\n this.D = void 0;\r\n this.C = a && a.supportsCrossDomainXhr ||\r\n !1;\r\n this.J = \"\";\r\n this.b = new gd(a && a.concurrentRequestLimit);\r\n this.ka = new ld;\r\n this.da = a && a.fastHandshake || !1;\r\n this.Ga = a && a.b || !1;\r\n a && a.f && (this.c.a = !1);\r\n a && a.forceLongPolling && (this.T = !1);\r\n this.V = !this.da && this.T && a && a.c || !1;\r\n this.ea = void 0;\r\n this.N = 0;\r\n this.F = !1;\r\n this.s = null;\r\n}\r\ng = Cd.prototype;\r\ng.ha = 8;\r\ng.v = 1;\r\nfunction Jc(a) { Dd(a); if (3 == a.v) {\r\n var b = a.R++, c = L(a.B);\r\n Q(c, \"SID\", a.J);\r\n Q(c, \"RID\", b);\r\n Q(c, \"TYPE\", \"terminate\");\r\n Ed(a, c);\r\n b = new K(a, a.c, b, void 0);\r\n b.H = 2;\r\n b.i = lc(L(c));\r\n c = !1;\r\n k.navigator && k.navigator.sendBeacon && (c = k.navigator.sendBeacon(b.i.toString(), \"\"));\r\n !c && k.Image && ((new Image).src = b.i, c = !0);\r\n c || (b.a = oc(b.g, null), b.a.ba(b.i));\r\n b.u = q();\r\n M(b);\r\n} Fd(a); }\r\nfunction Bc(a) { a.a && (xc(a), a.a.cancel(), a.a = null); }\r\nfunction Dd(a) { Bc(a); a.j && (k.clearTimeout(a.j), a.j = null); Ac(a); a.b.cancel(); a.h && (\"number\" === typeof a.h && k.clearTimeout(a.h), a.h = null); }\r\nfunction Gd(a, b) { a.g.push(new fd(a.La++, b)); 3 == a.v && Ic(a); }\r\nfunction Ic(a) { id(a.b) || a.h || (a.h = !0, Cb(a.Ba, a), a.u = 0); }\r\nfunction Hd(a, b) { if (Dc(a.b) >= a.b.f - (a.h ? 1 : 0))\r\n return !1; if (a.h)\r\n return a.g = b.s.concat(a.g), !0; if (1 == a.v || 2 == a.v || a.u >= (a.Ia ? 0 : a.Ja))\r\n return !1; a.h = I(p(a.Ba, a, b), Id(a, a.u)); a.u++; return !0; }\r\ng.Ba = function (a) {\r\n if (this.h)\r\n if (this.h = null, 1 == this.v) {\r\n if (!a) {\r\n this.R = Math.floor(1E5 * Math.random());\r\n a = this.R++;\r\n var b = new K(this, this.c, a, void 0), c = this.l;\r\n this.O && (c ? (c = Ba(c), Da(c, this.O)) : c = this.O);\r\n null === this.i && (b.B = c);\r\n var d;\r\n if (this.da)\r\n a: {\r\n for (var e = d = 0; e < this.g.length; e++) {\r\n b: {\r\n var f = this.g[e];\r\n if (\"__data__\" in f.a && (f = f.a.__data__, \"string\" === typeof f)) {\r\n f = f.length;\r\n break b;\r\n }\r\n f = void 0;\r\n }\r\n if (void 0 === f)\r\n break;\r\n d += f;\r\n if (4096 < d) {\r\n d = e;\r\n break a;\r\n }\r\n if (4096 === d || e === this.g.length - 1) {\r\n d = e + 1;\r\n break a;\r\n }\r\n }\r\n d = 1E3;\r\n }\r\n else\r\n d = 1E3;\r\n d = Jd(this, b, d);\r\n e = L(this.B);\r\n Q(e, \"RID\", a);\r\n Q(e, \"CVER\", 22);\r\n this.A && Q(e, \"X-HTTP-Session-Id\", this.A);\r\n Ed(this, e);\r\n this.i && c && Ad(e, this.i, c);\r\n Ec(this.b, b);\r\n this.Ga && Q(e, \"TYPE\", \"init\");\r\n this.da ? (Q(e, \"$req\", d), Q(e, \"SID\", \"null\"), b.V = !0, kc(b, e, null)) : kc(b, e, d);\r\n this.v = 2;\r\n }\r\n }\r\n else\r\n 3 == this.v && (a ? Kd(this, a) : 0 == this.g.length || id(this.b) || Kd(this));\r\n};\r\nfunction Kd(a, b) { var c; b ? c = b.f : c = a.R++; var d = L(a.B); Q(d, \"SID\", a.J); Q(d, \"RID\", c); Q(d, \"AID\", a.P); Ed(a, d); a.i && a.l && Ad(d, a.i, a.l); c = new K(a, a.c, c, a.u + 1); null === a.i && (c.B = a.l); b && (a.g = b.s.concat(a.g)); b = Jd(a, c, 1E3); c.setTimeout(Math.round(.5 * a.ma) + Math.round(.5 * a.ma * Math.random())); Ec(a.b, c); kc(c, d, b); }\r\nfunction Ed(a, b) { a.f && Lc({}, function (c, d) { Q(b, d, c); }); }\r\nfunction Jd(a, b, c) { c = Math.min(a.g.length, c); var d = a.f ? p(a.f.Ha, a.f, a) : null; a: for (var e = a.g, f = -1;;) {\r\n var h = [\"count=\" + c];\r\n -1 == f ? 0 < c ? (f = e[0].b, h.push(\"ofs=\" + f)) : f = 0 : h.push(\"ofs=\" + f);\r\n for (var m = !0, l = 0; l < c; l++) {\r\n var t = e[l].b, B = e[l].a;\r\n t -= f;\r\n if (0 > t)\r\n f = Math.max(0, e[l].b - 100), m = !1;\r\n else\r\n try {\r\n md(B, h, \"req\" + t + \"_\");\r\n }\r\n catch (z) {\r\n d && d(B);\r\n }\r\n }\r\n if (m) {\r\n d = h.join(\"&\");\r\n break a;\r\n }\r\n} a = a.g.splice(0, c); b.s = a; return d; }\r\nfunction Hc(a) { a.a || a.j || (a.U = 1, Cb(a.Aa, a), a.o = 0); }\r\nfunction Cc(a) { if (a.a || a.j || 3 <= a.o)\r\n return !1; a.U++; a.j = I(p(a.Aa, a), Id(a, a.o)); a.o++; return !0; }\r\ng.Aa = function () { this.j = null; Ld(this); if (this.V && !(this.F || null == this.a || 0 >= this.N)) {\r\n var a = 2 * this.N;\r\n this.c.info(\"BP detection timer enabled: \" + a);\r\n this.s = I(p(this.Sa, this), a);\r\n} };\r\ng.Sa = function () { this.s && (this.s = null, this.c.info(\"BP detection timeout reached.\"), this.c.info(\"Buffering proxy detected and switch to long-polling!\"), this.H = !1, this.F = !0, Bc(this), Ld(this)); };\r\nfunction xc(a) { null != a.s && (k.clearTimeout(a.s), a.s = null); }\r\nfunction Ld(a) { a.a = new K(a, a.c, \"rpc\", a.U); null === a.i && (a.a.B = a.l); a.a.O = 0; var b = L(a.la); Q(b, \"RID\", \"rpc\"); Q(b, \"SID\", a.J); Q(b, \"CI\", a.H ? \"0\" : \"1\"); Q(b, \"AID\", a.P); Ed(a, b); Q(b, \"TYPE\", \"xmlhttp\"); a.i && a.l && Ad(b, a.i, a.l); a.D && a.a.setTimeout(a.D); var c = a.a; a = a.ga; c.H = 1; c.i = lc(L(b)); c.j = null; c.I = !0; mc(c, a); }\r\ng.Ra = function () { null != this.m && (this.m = null, Bc(this), Cc(this), H(19)); };\r\nfunction Ac(a) { null != a.m && (k.clearTimeout(a.m), a.m = null); }\r\nfunction uc(a, b) { var c = null; if (a.a == b) {\r\n Ac(a);\r\n xc(a);\r\n a.a = null;\r\n var d = 2;\r\n}\r\nelse if (zc(a.b, b))\r\n c = b.s, Gc(a.b, b), d = 1;\r\nelse\r\n return; a.I = b.N; if (0 != a.v)\r\n if (b.b)\r\n if (1 == d) {\r\n c = b.j ? b.j.length : 0;\r\n b = q() - b.u;\r\n var e = a.u;\r\n d = Vb();\r\n d.dispatchEvent(new Yb(d, c, b, e));\r\n Ic(a);\r\n }\r\n else\r\n Hc(a);\r\n else if (e = b.h, 3 == e || 0 == e && 0 < a.I || !(1 == d && Hd(a, b) || 2 == d && Cc(a)))\r\n switch (c && 0 < c.length && (b = a.b, b.c = b.c.concat(c)), e) {\r\n case 1:\r\n P(a, 5);\r\n break;\r\n case 4:\r\n P(a, 10);\r\n break;\r\n case 3:\r\n P(a, 6);\r\n break;\r\n default: P(a, 2);\r\n } }\r\nfunction Id(a, b) { var c = a.Fa + Math.floor(Math.random() * a.Ma); a.f || (c *= 2); return c * b; }\r\nfunction P(a, b) { a.c.info(\"Error code \" + b); if (2 == b) {\r\n var c = null;\r\n a.f && (c = null);\r\n var d = p(a.Xa, a);\r\n c || (c = new T(\"//www.google.com/images/cleardot.gif\"), k.location && \"http\" == k.location.protocol || Pc(c, \"https\"), lc(c));\r\n nd(c.toString(), d);\r\n}\r\nelse\r\n H(2); a.v = 0; a.f && a.f.ra(b); Fd(a); Dd(a); }\r\ng.Xa = function (a) { a ? (this.c.info(\"Successfully pinged google.com\"), H(2)) : (this.c.info(\"Failed to ping google.com\"), H(1)); };\r\nfunction Fd(a) { a.v = 0; a.I = -1; if (a.f) {\r\n if (0 != jd(a.b).length || 0 != a.g.length)\r\n a.b.c.length = 0, sa(a.g), a.g.length = 0;\r\n a.f.qa();\r\n} }\r\nfunction Fc(a, b, c) { var d = ad(c); if (\"\" != d.c)\r\n b && Qc(d, b + \".\" + d.c), Rc(d, d.h);\r\nelse {\r\n var e = k.location;\r\n d = bd(e.protocol, b ? b + \".\" + e.hostname : e.hostname, +e.port, c);\r\n} a.W && Aa(a.W, function (f, h) { Q(d, h, f); }); b = a.A; c = a.na; b && c && Q(d, b, c); Q(d, \"VER\", a.ha); Ed(a, d); return d; }\r\nfunction oc(a, b) { if (b && !a.C)\r\n throw Error(\"Can't create secondary domain capable XhrIo object.\"); b = new X(a.Ka); b.F = a.C; return b; }\r\nfunction Md() { }\r\ng = Md.prototype;\r\ng.ta = function () { };\r\ng.sa = function () { };\r\ng.ra = function () { };\r\ng.qa = function () { };\r\ng.Ha = function () { };\r\nfunction Nd() { if (x && !(10 <= Number(Ua)))\r\n throw Error(\"Environmental error: no available transport.\"); }\r\nNd.prototype.a = function (a, b) { return new Y(a, b); };\r\nfunction Y(a, b) {\r\n D.call(this);\r\n this.a = new Cd(b);\r\n this.l = a;\r\n this.b = b && b.messageUrlParams || null;\r\n a = b && b.messageHeaders || null;\r\n b && b.clientProtocolHeaderRequired && (a ? a[\"X-Client-Protocol\"] = \"webchannel\" : a = { \"X-Client-Protocol\": \"webchannel\" });\r\n this.a.l = a;\r\n a = b && b.initMessageHeaders || null;\r\n b && b.messageContentType && (a ? a[\"X-WebChannel-Content-Type\"] = b.messageContentType : a = { \"X-WebChannel-Content-Type\": b.messageContentType });\r\n b && b.a && (a ? a[\"X-WebChannel-Client-Profile\"] = b.a : a = { \"X-WebChannel-Client-Profile\": b.a });\r\n this.a.O =\r\n a;\r\n (a = b && b.httpHeadersOverwriteParam) && !ta(a) && (this.a.i = a);\r\n this.h = b && b.supportsCrossDomainXhr || !1;\r\n this.g = b && b.sendRawJson || !1;\r\n (b = b && b.httpSessionIdParam) && !ta(b) && (this.a.A = b, a = this.b, null !== a && b in a && (a = this.b, b in a && delete a[b]));\r\n this.f = new Z(this);\r\n}\r\nr(Y, D);\r\ng = Y.prototype;\r\ng.addEventListener = function (a, b, c, d) { Y.S.addEventListener.call(this, a, b, c, d); };\r\ng.removeEventListener = function (a, b, c, d) { Y.S.removeEventListener.call(this, a, b, c, d); };\r\ng.Oa = function () { this.a.f = this.f; this.h && (this.a.C = !0); var a = this.a, b = this.l, c = this.b || void 0; H(0); a.fa = b; a.W = c || {}; a.H = a.T; a.B = Fc(a, null, a.fa); Ic(a); };\r\ng.close = function () { Jc(this.a); };\r\ng.Pa = function (a) { if (\"string\" === typeof a) {\r\n var b = {};\r\n b.__data__ = a;\r\n Gd(this.a, b);\r\n}\r\nelse\r\n this.g ? (b = {}, b.__data__ = vb(a), Gd(this.a, b)) : Gd(this.a, a); };\r\ng.G = function () { this.a.f = null; delete this.f; Jc(this.a); delete this.a; Y.S.G.call(this); };\r\nfunction Od(a) { dc.call(this); var b = a.__sm__; if (b) {\r\n a: {\r\n for (var c in b) {\r\n a = c;\r\n break a;\r\n }\r\n a = void 0;\r\n }\r\n (this.c = a) ? (a = this.c, this.data = null !== b && a in b ? b[a] : void 0) : this.data = b;\r\n}\r\nelse\r\n this.data = a; }\r\nr(Od, dc);\r\nfunction Pd() { ec.call(this); this.status = 1; }\r\nr(Pd, ec);\r\nfunction Z(a) { this.a = a; }\r\nr(Z, Md);\r\nZ.prototype.ta = function () { this.a.dispatchEvent(\"a\"); };\r\nZ.prototype.sa = function (a) { this.a.dispatchEvent(new Od(a)); };\r\nZ.prototype.ra = function (a) { this.a.dispatchEvent(new Pd(a)); };\r\nZ.prototype.qa = function () { this.a.dispatchEvent(\"b\"); }; /*\r\n\n Copyright 2017 Google LLC\r\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\r\n you may not use this file except in compliance with the License.\r\n You may obtain a copy of the License at\r\n\n http://www.apache.org/licenses/LICENSE-2.0\r\n\n Unless required by applicable law or agreed to in writing, software\r\n distributed under the License is distributed on an \"AS IS\" BASIS,\r\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n See the License for the specific language governing permissions and\r\n limitations under the License.\r\n*/\r\nNd.prototype.createWebChannel = Nd.prototype.a;\r\nY.prototype.send = Y.prototype.Pa;\r\nY.prototype.open = Y.prototype.Oa;\r\nY.prototype.close = Y.prototype.close;\r\nZb.NO_ERROR = 0;\r\nZb.TIMEOUT = 8;\r\nZb.HTTP_ERROR = 6;\r\n$b.COMPLETE = \"complete\";\r\ncc.EventType = J;\r\nJ.OPEN = \"a\";\r\nJ.CLOSE = \"b\";\r\nJ.ERROR = \"c\";\r\nJ.MESSAGE = \"d\";\r\nD.prototype.listen = D.prototype.va;\r\nX.prototype.listenOnce = X.prototype.wa;\r\nX.prototype.getLastError = X.prototype.Qa;\r\nX.prototype.getLastErrorCode = X.prototype.ua;\r\nX.prototype.getStatus = X.prototype.X;\r\nX.prototype.getResponseJson = X.prototype.Na;\r\nX.prototype.getResponseText = X.prototype.$;\r\nX.prototype.send = X.prototype.ba;\r\nvar createWebChannelTransport = function () { return new Nd; };\r\nvar ErrorCode = Zb;\r\nvar EventType = $b;\r\nvar WebChannel = cc;\r\nvar XhrIo = X;\r\n\r\nvar esm = {\r\n createWebChannelTransport: createWebChannelTransport,\r\n ErrorCode: ErrorCode,\r\n EventType: EventType,\r\n WebChannel: WebChannel,\r\n XhrIo: XhrIo\r\n};\n\nexport default esm;\nexport { ErrorCode, EventType, WebChannel, XhrIo, createWebChannelTransport };\n//# sourceMappingURL=index.esm.js.map\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","\"use strict\";\nexports.__esModule = true;\nexports.isExists = void 0;\nfunction isExists(value) {\n return value !== undefined && value !== null;\n}\nexports.isExists = isExists;\n","'use strict';\nvar uncurryThis = require('../internals/function-uncurry-this');\nvar hasOwn = require('../internals/has-own-property');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar indexOf = require('../internals/array-includes').indexOf;\nvar hiddenKeys = require('../internals/hidden-keys');\n\nvar push = uncurryThis([].push);\n\nmodule.exports = function (object, names) {\n var O = toIndexedObject(object);\n var i = 0;\n var result = [];\n var key;\n for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);\n // Don't enum bug & hidden keys\n while (names.length > i) if (hasOwn(O, key = names[i++])) {\n ~indexOf(result, key) || push(result, key);\n }\n return result;\n};\n","'use strict';\nvar isCallable = require('../internals/is-callable');\nvar definePropertyModule = require('../internals/object-define-property');\nvar makeBuiltIn = require('../internals/make-built-in');\nvar defineGlobalProperty = require('../internals/define-global-property');\n\nmodule.exports = function (O, key, value, options) {\n if (!options) options = {};\n var simple = options.enumerable;\n var name = options.name !== undefined ? options.name : key;\n if (isCallable(value)) makeBuiltIn(value, name, options);\n if (options.global) {\n if (simple) O[key] = value;\n else defineGlobalProperty(key, value);\n } else {\n try {\n if (!options.unsafe) delete O[key];\n else if (O[key]) simple = true;\n } catch (error) { /* empty */ }\n if (simple) O[key] = value;\n else definePropertyModule.f(O, key, {\n value: value,\n enumerable: false,\n configurable: !options.nonConfigurable,\n writable: !options.nonWritable\n });\n } return O;\n};\n","'use strict';\nvar global = require('../internals/global');\nvar isObject = require('../internals/is-object');\n\nvar document = global.document;\n// typeof document.createElement is 'object' in old IE\nvar EXISTS = isObject(document) && isObject(document.createElement);\n\nmodule.exports = function (it) {\n return EXISTS ? document.createElement(it) : {};\n};\n","'use strict';\nvar $ = require('../internals/export');\nvar assign = require('../internals/object-assign');\n\n// `Object.assign` method\n// https://tc39.es/ecma262/#sec-object.assign\n// eslint-disable-next-line es/no-object-assign -- required for testing\n$({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {\n assign: assign\n});\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar tslib = require('tslib');\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * @fileoverview Firebase constants. Some of these (@defines) can be overridden at compile-time.\r\n */\r\nvar CONSTANTS = {\r\n /**\r\n * @define {boolean} Whether this is the client Node.js SDK.\r\n */\r\n NODE_CLIENT: false,\r\n /**\r\n * @define {boolean} Whether this is the Admin Node.js SDK.\r\n */\r\n NODE_ADMIN: false,\r\n /**\r\n * Firebase SDK Version\r\n */\r\n SDK_VERSION: '${JSCORE_VERSION}'\r\n};\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Throws an error if the provided assertion is falsy\r\n */\r\nvar assert = function (assertion, message) {\r\n if (!assertion) {\r\n throw assertionError(message);\r\n }\r\n};\r\n/**\r\n * Returns an Error object suitable for throwing.\r\n */\r\nvar assertionError = function (message) {\r\n return new Error('Firebase Database (' +\r\n CONSTANTS.SDK_VERSION +\r\n ') INTERNAL ASSERT FAILED: ' +\r\n message);\r\n};\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar stringToByteArray = function (str) {\r\n // TODO(user): Use native implementations if/when available\r\n var out = [];\r\n var p = 0;\r\n for (var i = 0; i < str.length; i++) {\r\n var c = str.charCodeAt(i);\r\n if (c < 128) {\r\n out[p++] = c;\r\n }\r\n else if (c < 2048) {\r\n out[p++] = (c >> 6) | 192;\r\n out[p++] = (c & 63) | 128;\r\n }\r\n else if ((c & 0xfc00) === 0xd800 &&\r\n i + 1 < str.length &&\r\n (str.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {\r\n // Surrogate Pair\r\n c = 0x10000 + ((c & 0x03ff) << 10) + (str.charCodeAt(++i) & 0x03ff);\r\n out[p++] = (c >> 18) | 240;\r\n out[p++] = ((c >> 12) & 63) | 128;\r\n out[p++] = ((c >> 6) & 63) | 128;\r\n out[p++] = (c & 63) | 128;\r\n }\r\n else {\r\n out[p++] = (c >> 12) | 224;\r\n out[p++] = ((c >> 6) & 63) | 128;\r\n out[p++] = (c & 63) | 128;\r\n }\r\n }\r\n return out;\r\n};\r\n/**\r\n * Turns an array of numbers into the string given by the concatenation of the\r\n * characters to which the numbers correspond.\r\n * @param bytes Array of numbers representing characters.\r\n * @return Stringification of the array.\r\n */\r\nvar byteArrayToString = function (bytes) {\r\n // TODO(user): Use native implementations if/when available\r\n var out = [];\r\n var pos = 0, c = 0;\r\n while (pos < bytes.length) {\r\n var c1 = bytes[pos++];\r\n if (c1 < 128) {\r\n out[c++] = String.fromCharCode(c1);\r\n }\r\n else if (c1 > 191 && c1 < 224) {\r\n var c2 = bytes[pos++];\r\n out[c++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));\r\n }\r\n else if (c1 > 239 && c1 < 365) {\r\n // Surrogate Pair\r\n var c2 = bytes[pos++];\r\n var c3 = bytes[pos++];\r\n var c4 = bytes[pos++];\r\n var u = (((c1 & 7) << 18) | ((c2 & 63) << 12) | ((c3 & 63) << 6) | (c4 & 63)) -\r\n 0x10000;\r\n out[c++] = String.fromCharCode(0xd800 + (u >> 10));\r\n out[c++] = String.fromCharCode(0xdc00 + (u & 1023));\r\n }\r\n else {\r\n var c2 = bytes[pos++];\r\n var c3 = bytes[pos++];\r\n out[c++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));\r\n }\r\n }\r\n return out.join('');\r\n};\r\n// We define it as an object literal instead of a class because a class compiled down to es5 can't\r\n// be treeshaked. https://github.com/rollup/rollup/issues/1691\r\n// Static lookup maps, lazily populated by init_()\r\nvar base64 = {\r\n /**\r\n * Maps bytes to characters.\r\n */\r\n byteToCharMap_: null,\r\n /**\r\n * Maps characters to bytes.\r\n */\r\n charToByteMap_: null,\r\n /**\r\n * Maps bytes to websafe characters.\r\n * @private\r\n */\r\n byteToCharMapWebSafe_: null,\r\n /**\r\n * Maps websafe characters to bytes.\r\n * @private\r\n */\r\n charToByteMapWebSafe_: null,\r\n /**\r\n * Our default alphabet, shared between\r\n * ENCODED_VALS and ENCODED_VALS_WEBSAFE\r\n */\r\n ENCODED_VALS_BASE: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789',\r\n /**\r\n * Our default alphabet. Value 64 (=) is special; it means \"nothing.\"\r\n */\r\n get ENCODED_VALS() {\r\n return this.ENCODED_VALS_BASE + '+/=';\r\n },\r\n /**\r\n * Our websafe alphabet.\r\n */\r\n get ENCODED_VALS_WEBSAFE() {\r\n return this.ENCODED_VALS_BASE + '-_.';\r\n },\r\n /**\r\n * Whether this browser supports the atob and btoa functions. This extension\r\n * started at Mozilla but is now implemented by many browsers. We use the\r\n * ASSUME_* variables to avoid pulling in the full useragent detection library\r\n * but still allowing the standard per-browser compilations.\r\n *\r\n */\r\n HAS_NATIVE_SUPPORT: typeof atob === 'function',\r\n /**\r\n * Base64-encode an array of bytes.\r\n *\r\n * @param input An array of bytes (numbers with\r\n * value in [0, 255]) to encode.\r\n * @param webSafe Boolean indicating we should use the\r\n * alternative alphabet.\r\n * @return The base64 encoded string.\r\n */\r\n encodeByteArray: function (input, webSafe) {\r\n if (!Array.isArray(input)) {\r\n throw Error('encodeByteArray takes an array as a parameter');\r\n }\r\n this.init_();\r\n var byteToCharMap = webSafe\r\n ? this.byteToCharMapWebSafe_\r\n : this.byteToCharMap_;\r\n var output = [];\r\n for (var i = 0; i < input.length; i += 3) {\r\n var byte1 = input[i];\r\n var haveByte2 = i + 1 < input.length;\r\n var byte2 = haveByte2 ? input[i + 1] : 0;\r\n var haveByte3 = i + 2 < input.length;\r\n var byte3 = haveByte3 ? input[i + 2] : 0;\r\n var outByte1 = byte1 >> 2;\r\n var outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4);\r\n var outByte3 = ((byte2 & 0x0f) << 2) | (byte3 >> 6);\r\n var outByte4 = byte3 & 0x3f;\r\n if (!haveByte3) {\r\n outByte4 = 64;\r\n if (!haveByte2) {\r\n outByte3 = 64;\r\n }\r\n }\r\n output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]);\r\n }\r\n return output.join('');\r\n },\r\n /**\r\n * Base64-encode a string.\r\n *\r\n * @param input A string to encode.\r\n * @param webSafe If true, we should use the\r\n * alternative alphabet.\r\n * @return The base64 encoded string.\r\n */\r\n encodeString: function (input, webSafe) {\r\n // Shortcut for Mozilla browsers that implement\r\n // a native base64 encoder in the form of \"btoa/atob\"\r\n if (this.HAS_NATIVE_SUPPORT && !webSafe) {\r\n return btoa(input);\r\n }\r\n return this.encodeByteArray(stringToByteArray(input), webSafe);\r\n },\r\n /**\r\n * Base64-decode a string.\r\n *\r\n * @param input to decode.\r\n * @param webSafe True if we should use the\r\n * alternative alphabet.\r\n * @return string representing the decoded value.\r\n */\r\n decodeString: function (input, webSafe) {\r\n // Shortcut for Mozilla browsers that implement\r\n // a native base64 encoder in the form of \"btoa/atob\"\r\n if (this.HAS_NATIVE_SUPPORT && !webSafe) {\r\n return atob(input);\r\n }\r\n return byteArrayToString(this.decodeStringToByteArray(input, webSafe));\r\n },\r\n /**\r\n * Base64-decode a string.\r\n *\r\n * In base-64 decoding, groups of four characters are converted into three\r\n * bytes. If the encoder did not apply padding, the input length may not\r\n * be a multiple of 4.\r\n *\r\n * In this case, the last group will have fewer than 4 characters, and\r\n * padding will be inferred. If the group has one or two characters, it decodes\r\n * to one byte. If the group has three characters, it decodes to two bytes.\r\n *\r\n * @param input Input to decode.\r\n * @param webSafe True if we should use the web-safe alphabet.\r\n * @return bytes representing the decoded value.\r\n */\r\n decodeStringToByteArray: function (input, webSafe) {\r\n this.init_();\r\n var charToByteMap = webSafe\r\n ? this.charToByteMapWebSafe_\r\n : this.charToByteMap_;\r\n var output = [];\r\n for (var i = 0; i < input.length;) {\r\n var byte1 = charToByteMap[input.charAt(i++)];\r\n var haveByte2 = i < input.length;\r\n var byte2 = haveByte2 ? charToByteMap[input.charAt(i)] : 0;\r\n ++i;\r\n var haveByte3 = i < input.length;\r\n var byte3 = haveByte3 ? charToByteMap[input.charAt(i)] : 64;\r\n ++i;\r\n var haveByte4 = i < input.length;\r\n var byte4 = haveByte4 ? charToByteMap[input.charAt(i)] : 64;\r\n ++i;\r\n if (byte1 == null || byte2 == null || byte3 == null || byte4 == null) {\r\n throw Error();\r\n }\r\n var outByte1 = (byte1 << 2) | (byte2 >> 4);\r\n output.push(outByte1);\r\n if (byte3 !== 64) {\r\n var outByte2 = ((byte2 << 4) & 0xf0) | (byte3 >> 2);\r\n output.push(outByte2);\r\n if (byte4 !== 64) {\r\n var outByte3 = ((byte3 << 6) & 0xc0) | byte4;\r\n output.push(outByte3);\r\n }\r\n }\r\n }\r\n return output;\r\n },\r\n /**\r\n * Lazy static initialization function. Called before\r\n * accessing any of the static map variables.\r\n * @private\r\n */\r\n init_: function () {\r\n if (!this.byteToCharMap_) {\r\n this.byteToCharMap_ = {};\r\n this.charToByteMap_ = {};\r\n this.byteToCharMapWebSafe_ = {};\r\n this.charToByteMapWebSafe_ = {};\r\n // We want quick mappings back and forth, so we precompute two maps.\r\n for (var i = 0; i < this.ENCODED_VALS.length; i++) {\r\n this.byteToCharMap_[i] = this.ENCODED_VALS.charAt(i);\r\n this.charToByteMap_[this.byteToCharMap_[i]] = i;\r\n this.byteToCharMapWebSafe_[i] = this.ENCODED_VALS_WEBSAFE.charAt(i);\r\n this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[i]] = i;\r\n // Be forgiving when decoding and correctly decode both encodings.\r\n if (i >= this.ENCODED_VALS_BASE.length) {\r\n this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(i)] = i;\r\n this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(i)] = i;\r\n }\r\n }\r\n }\r\n }\r\n};\r\n/**\r\n * URL-safe base64 encoding\r\n */\r\nvar base64Encode = function (str) {\r\n var utf8Bytes = stringToByteArray(str);\r\n return base64.encodeByteArray(utf8Bytes, true);\r\n};\r\n/**\r\n * URL-safe base64 decoding\r\n *\r\n * NOTE: DO NOT use the global atob() function - it does NOT support the\r\n * base64Url variant encoding.\r\n *\r\n * @param str To be decoded\r\n * @return Decoded result, if possible\r\n */\r\nvar base64Decode = function (str) {\r\n try {\r\n return base64.decodeString(str, true);\r\n }\r\n catch (e) {\r\n console.error('base64Decode failed: ', e);\r\n }\r\n return null;\r\n};\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Do a deep-copy of basic JavaScript Objects or Arrays.\r\n */\r\nfunction deepCopy(value) {\r\n return deepExtend(undefined, value);\r\n}\r\n/**\r\n * Copy properties from source to target (recursively allows extension\r\n * of Objects and Arrays). Scalar values in the target are over-written.\r\n * If target is undefined, an object of the appropriate type will be created\r\n * (and returned).\r\n *\r\n * We recursively copy all child properties of plain Objects in the source- so\r\n * that namespace- like dictionaries are merged.\r\n *\r\n * Note that the target can be a function, in which case the properties in\r\n * the source Object are copied onto it as static properties of the Function.\r\n */\r\nfunction deepExtend(target, source) {\r\n if (!(source instanceof Object)) {\r\n return source;\r\n }\r\n switch (source.constructor) {\r\n case Date:\r\n // Treat Dates like scalars; if the target date object had any child\r\n // properties - they will be lost!\r\n var dateValue = source;\r\n return new Date(dateValue.getTime());\r\n case Object:\r\n if (target === undefined) {\r\n target = {};\r\n }\r\n break;\r\n case Array:\r\n // Always copy the array source and overwrite the target.\r\n target = [];\r\n break;\r\n default:\r\n // Not a plain Object - treat it as a scalar.\r\n return source;\r\n }\r\n for (var prop in source) {\r\n if (!source.hasOwnProperty(prop)) {\r\n continue;\r\n }\r\n target[prop] = deepExtend(target[prop], source[prop]);\r\n }\r\n return target;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar Deferred = /** @class */ (function () {\r\n function Deferred() {\r\n var _this = this;\r\n this.reject = function () { };\r\n this.resolve = function () { };\r\n this.promise = new Promise(function (resolve, reject) {\r\n _this.resolve = resolve;\r\n _this.reject = reject;\r\n });\r\n }\r\n /**\r\n * Our API internals are not promiseified and cannot because our callback APIs have subtle expectations around\r\n * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback\r\n * and returns a node-style callback which will resolve or reject the Deferred's promise.\r\n */\r\n Deferred.prototype.wrapCallback = function (callback) {\r\n var _this = this;\r\n return function (error, value) {\r\n if (error) {\r\n _this.reject(error);\r\n }\r\n else {\r\n _this.resolve(value);\r\n }\r\n if (typeof callback === 'function') {\r\n // Attaching noop handler just in case developer wasn't expecting\r\n // promises\r\n _this.promise.catch(function () { });\r\n // Some of our callbacks don't expect a value and our own tests\r\n // assert that the parameter length is 1\r\n if (callback.length === 1) {\r\n callback(error);\r\n }\r\n else {\r\n callback(error, value);\r\n }\r\n }\r\n };\r\n };\r\n return Deferred;\r\n}());\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Returns navigator.userAgent string or '' if it's not defined.\r\n * @return user agent string\r\n */\r\nfunction getUA() {\r\n if (typeof navigator !== 'undefined' &&\r\n typeof navigator['userAgent'] === 'string') {\r\n return navigator['userAgent'];\r\n }\r\n else {\r\n return '';\r\n }\r\n}\r\n/**\r\n * Detect Cordova / PhoneGap / Ionic frameworks on a mobile device.\r\n *\r\n * Deliberately does not rely on checking `file://` URLs (as this fails PhoneGap\r\n * in the Ripple emulator) nor Cordova `onDeviceReady`, which would normally\r\n * wait for a callback.\r\n */\r\nfunction isMobileCordova() {\r\n return (typeof window !== 'undefined' &&\r\n // @ts-ignore Setting up an broadly applicable index signature for Window\r\n // just to deal with this case would probably be a bad idea.\r\n !!(window['cordova'] || window['phonegap'] || window['PhoneGap']) &&\r\n /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(getUA()));\r\n}\r\n/**\r\n * Detect Node.js.\r\n *\r\n * @return true if Node.js environment is detected.\r\n */\r\n// Node detection logic from: https://github.com/iliakan/detect-node/\r\nfunction isNode() {\r\n try {\r\n return (Object.prototype.toString.call(global.process) === '[object process]');\r\n }\r\n catch (e) {\r\n return false;\r\n }\r\n}\r\n/**\r\n * Detect Browser Environment\r\n */\r\nfunction isBrowser() {\r\n return typeof self === 'object' && self.self === self;\r\n}\r\nfunction isBrowserExtension() {\r\n var runtime = typeof chrome === 'object'\r\n ? chrome.runtime\r\n : typeof browser === 'object'\r\n ? browser.runtime\r\n : undefined;\r\n return typeof runtime === 'object' && runtime.id !== undefined;\r\n}\r\n/**\r\n * Detect React Native.\r\n *\r\n * @return true if ReactNative environment is detected.\r\n */\r\nfunction isReactNative() {\r\n return (typeof navigator === 'object' && navigator['product'] === 'ReactNative');\r\n}\r\n/** Detects Electron apps. */\r\nfunction isElectron() {\r\n return getUA().indexOf('Electron/') >= 0;\r\n}\r\n/** Detects Internet Explorer. */\r\nfunction isIE() {\r\n var ua = getUA();\r\n return ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0;\r\n}\r\n/** Detects Universal Windows Platform apps. */\r\nfunction isUWP() {\r\n return getUA().indexOf('MSAppHost/') >= 0;\r\n}\r\n/**\r\n * Detect whether the current SDK build is the Node version.\r\n *\r\n * @return true if it's the Node SDK build.\r\n */\r\nfunction isNodeSdk() {\r\n return CONSTANTS.NODE_CLIENT === true || CONSTANTS.NODE_ADMIN === true;\r\n}\r\n/** Returns true if we are running in Safari. */\r\nfunction isSafari() {\r\n return (!isNode() &&\r\n navigator.userAgent.includes('Safari') &&\r\n !navigator.userAgent.includes('Chrome'));\r\n}\r\n/**\r\n * This method checks if indexedDB is supported by current browser/service worker context\r\n * @return true if indexedDB is supported by current browser/service worker context\r\n */\r\nfunction isIndexedDBAvailable() {\r\n return 'indexedDB' in self && indexedDB != null;\r\n}\r\n/**\r\n * This method validates browser context for indexedDB by opening a dummy indexedDB database and reject\r\n * if errors occur during the database open operation.\r\n */\r\nfunction validateIndexedDBOpenable() {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n var preExist_1 = true;\r\n var DB_CHECK_NAME_1 = 'validate-browser-context-for-indexeddb-analytics-module';\r\n var request_1 = window.indexedDB.open(DB_CHECK_NAME_1);\r\n request_1.onsuccess = function () {\r\n request_1.result.close();\r\n // delete database only when it doesn't pre-exist\r\n if (!preExist_1) {\r\n window.indexedDB.deleteDatabase(DB_CHECK_NAME_1);\r\n }\r\n resolve(true);\r\n };\r\n request_1.onupgradeneeded = function () {\r\n preExist_1 = false;\r\n };\r\n request_1.onerror = function () {\r\n var _a;\r\n reject(((_a = request_1.error) === null || _a === void 0 ? void 0 : _a.message) || '');\r\n };\r\n }\r\n catch (error) {\r\n reject(error);\r\n }\r\n });\r\n}\r\n/**\r\n *\r\n * This method checks whether cookie is enabled within current browser\r\n * @return true if cookie is enabled within current browser\r\n */\r\nfunction areCookiesEnabled() {\r\n if (!navigator || !navigator.cookieEnabled) {\r\n return false;\r\n }\r\n return true;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar ERROR_NAME = 'FirebaseError';\r\n// Based on code from:\r\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types\r\nvar FirebaseError = /** @class */ (function (_super) {\r\n tslib.__extends(FirebaseError, _super);\r\n function FirebaseError(code, message) {\r\n var _this = _super.call(this, message) || this;\r\n _this.code = code;\r\n _this.name = ERROR_NAME;\r\n // Fix For ES5\r\n // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\r\n Object.setPrototypeOf(_this, FirebaseError.prototype);\r\n // Maintains proper stack trace for where our error was thrown.\r\n // Only available on V8.\r\n if (Error.captureStackTrace) {\r\n Error.captureStackTrace(_this, ErrorFactory.prototype.create);\r\n }\r\n return _this;\r\n }\r\n return FirebaseError;\r\n}(Error));\r\nvar ErrorFactory = /** @class */ (function () {\r\n function ErrorFactory(service, serviceName, errors) {\r\n this.service = service;\r\n this.serviceName = serviceName;\r\n this.errors = errors;\r\n }\r\n ErrorFactory.prototype.create = function (code) {\r\n var data = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n data[_i - 1] = arguments[_i];\r\n }\r\n var customData = data[0] || {};\r\n var fullCode = this.service + \"/\" + code;\r\n var template = this.errors[code];\r\n var message = template ? replaceTemplate(template, customData) : 'Error';\r\n // Service Name: Error message (service/code).\r\n var fullMessage = this.serviceName + \": \" + message + \" (\" + fullCode + \").\";\r\n var error = new FirebaseError(fullCode, fullMessage);\r\n // Keys with an underscore at the end of their name are not included in\r\n // error.data for some reason.\r\n // TODO: Replace with Object.entries when lib is updated to es2017.\r\n for (var _a = 0, _b = Object.keys(customData); _a < _b.length; _a++) {\r\n var key = _b[_a];\r\n if (key.slice(-1) !== '_') {\r\n if (key in error) {\r\n console.warn(\"Overwriting FirebaseError base field \\\"\" + key + \"\\\" can cause unexpected behavior.\");\r\n }\r\n error[key] = customData[key];\r\n }\r\n }\r\n return error;\r\n };\r\n return ErrorFactory;\r\n}());\r\nfunction replaceTemplate(template, data) {\r\n return template.replace(PATTERN, function (_, key) {\r\n var value = data[key];\r\n return value != null ? String(value) : \"<\" + key + \"?>\";\r\n });\r\n}\r\nvar PATTERN = /\\{\\$([^}]+)}/g;\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Evaluates a JSON string into a javascript object.\r\n *\r\n * @param {string} str A string containing JSON.\r\n * @return {*} The javascript object representing the specified JSON.\r\n */\r\nfunction jsonEval(str) {\r\n return JSON.parse(str);\r\n}\r\n/**\r\n * Returns JSON representing a javascript object.\r\n * @param {*} data Javascript object to be stringified.\r\n * @return {string} The JSON contents of the object.\r\n */\r\nfunction stringify(data) {\r\n return JSON.stringify(data);\r\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Decodes a Firebase auth. token into constituent parts.\r\n *\r\n * Notes:\r\n * - May return with invalid / incomplete claims if there's no native base64 decoding support.\r\n * - Doesn't check if the token is actually valid.\r\n */\r\nvar decode = function (token) {\r\n var header = {}, claims = {}, data = {}, signature = '';\r\n try {\r\n var parts = token.split('.');\r\n header = jsonEval(base64Decode(parts[0]) || '');\r\n claims = jsonEval(base64Decode(parts[1]) || '');\r\n signature = parts[2];\r\n data = claims['d'] || {};\r\n delete claims['d'];\r\n }\r\n catch (e) { }\r\n return {\r\n header: header,\r\n claims: claims,\r\n data: data,\r\n signature: signature\r\n };\r\n};\r\n/**\r\n * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the\r\n * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.\r\n *\r\n * Notes:\r\n * - May return a false negative if there's no native base64 decoding support.\r\n * - Doesn't check if the token is actually valid.\r\n */\r\nvar isValidTimestamp = function (token) {\r\n var claims = decode(token).claims;\r\n var now = Math.floor(new Date().getTime() / 1000);\r\n var validSince = 0, validUntil = 0;\r\n if (typeof claims === 'object') {\r\n if (claims.hasOwnProperty('nbf')) {\r\n validSince = claims['nbf'];\r\n }\r\n else if (claims.hasOwnProperty('iat')) {\r\n validSince = claims['iat'];\r\n }\r\n if (claims.hasOwnProperty('exp')) {\r\n validUntil = claims['exp'];\r\n }\r\n else {\r\n // token will expire after 24h by default\r\n validUntil = validSince + 86400;\r\n }\r\n }\r\n return (!!now &&\r\n !!validSince &&\r\n !!validUntil &&\r\n now >= validSince &&\r\n now <= validUntil);\r\n};\r\n/**\r\n * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.\r\n *\r\n * Notes:\r\n * - May return null if there's no native base64 decoding support.\r\n * - Doesn't check if the token is actually valid.\r\n */\r\nvar issuedAtTime = function (token) {\r\n var claims = decode(token).claims;\r\n if (typeof claims === 'object' && claims.hasOwnProperty('iat')) {\r\n return claims['iat'];\r\n }\r\n return null;\r\n};\r\n/**\r\n * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.\r\n *\r\n * Notes:\r\n * - May return a false negative if there's no native base64 decoding support.\r\n * - Doesn't check if the token is actually valid.\r\n */\r\nvar isValidFormat = function (token) {\r\n var decoded = decode(token), claims = decoded.claims;\r\n return !!claims && typeof claims === 'object' && claims.hasOwnProperty('iat');\r\n};\r\n/**\r\n * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion.\r\n *\r\n * Notes:\r\n * - May return a false negative if there's no native base64 decoding support.\r\n * - Doesn't check if the token is actually valid.\r\n */\r\nvar isAdmin = function (token) {\r\n var claims = decode(token).claims;\r\n return typeof claims === 'object' && claims['admin'] === true;\r\n};\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction contains(obj, key) {\r\n return Object.prototype.hasOwnProperty.call(obj, key);\r\n}\r\nfunction safeGet(obj, key) {\r\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\r\n return obj[key];\r\n }\r\n else {\r\n return undefined;\r\n }\r\n}\r\nfunction isEmpty(obj) {\r\n for (var key in obj) {\r\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n}\r\nfunction map(obj, fn, contextObj) {\r\n var res = {};\r\n for (var key in obj) {\r\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\r\n res[key] = fn.call(contextObj, obj[key], key, obj);\r\n }\r\n }\r\n return res;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Returns a querystring-formatted string (e.g. &arg=val&arg2=val2) from a\r\n * params object (e.g. {arg: 'val', arg2: 'val2'})\r\n * Note: You must prepend it with ? when adding it to a URL.\r\n */\r\nfunction querystring(querystringParams) {\r\n var params = [];\r\n var _loop_1 = function (key, value) {\r\n if (Array.isArray(value)) {\r\n value.forEach(function (arrayVal) {\r\n params.push(encodeURIComponent(key) + '=' + encodeURIComponent(arrayVal));\r\n });\r\n }\r\n else {\r\n params.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));\r\n }\r\n };\r\n for (var _i = 0, _a = Object.entries(querystringParams); _i < _a.length; _i++) {\r\n var _b = _a[_i], key = _b[0], value = _b[1];\r\n _loop_1(key, value);\r\n }\r\n return params.length ? '&' + params.join('&') : '';\r\n}\r\n/**\r\n * Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object\r\n * (e.g. {arg: 'val', arg2: 'val2'})\r\n */\r\nfunction querystringDecode(querystring) {\r\n var obj = {};\r\n var tokens = querystring.replace(/^\\?/, '').split('&');\r\n tokens.forEach(function (token) {\r\n if (token) {\r\n var key = token.split('=');\r\n obj[key[0]] = key[1];\r\n }\r\n });\r\n return obj;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * @fileoverview SHA-1 cryptographic hash.\r\n * Variable names follow the notation in FIPS PUB 180-3:\r\n * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf.\r\n *\r\n * Usage:\r\n * var sha1 = new sha1();\r\n * sha1.update(bytes);\r\n * var hash = sha1.digest();\r\n *\r\n * Performance:\r\n * Chrome 23: ~400 Mbit/s\r\n * Firefox 16: ~250 Mbit/s\r\n *\r\n */\r\n/**\r\n * SHA-1 cryptographic hash constructor.\r\n *\r\n * The properties declared here are discussed in the above algorithm document.\r\n * @constructor\r\n * @final\r\n * @struct\r\n */\r\nvar Sha1 = /** @class */ (function () {\r\n function Sha1() {\r\n /**\r\n * Holds the previous values of accumulated variables a-e in the compress_\r\n * function.\r\n * @private\r\n */\r\n this.chain_ = [];\r\n /**\r\n * A buffer holding the partially computed hash result.\r\n * @private\r\n */\r\n this.buf_ = [];\r\n /**\r\n * An array of 80 bytes, each a part of the message to be hashed. Referred to\r\n * as the message schedule in the docs.\r\n * @private\r\n */\r\n this.W_ = [];\r\n /**\r\n * Contains data needed to pad messages less than 64 bytes.\r\n * @private\r\n */\r\n this.pad_ = [];\r\n /**\r\n * @private {number}\r\n */\r\n this.inbuf_ = 0;\r\n /**\r\n * @private {number}\r\n */\r\n this.total_ = 0;\r\n this.blockSize = 512 / 8;\r\n this.pad_[0] = 128;\r\n for (var i = 1; i < this.blockSize; ++i) {\r\n this.pad_[i] = 0;\r\n }\r\n this.reset();\r\n }\r\n Sha1.prototype.reset = function () {\r\n this.chain_[0] = 0x67452301;\r\n this.chain_[1] = 0xefcdab89;\r\n this.chain_[2] = 0x98badcfe;\r\n this.chain_[3] = 0x10325476;\r\n this.chain_[4] = 0xc3d2e1f0;\r\n this.inbuf_ = 0;\r\n this.total_ = 0;\r\n };\r\n /**\r\n * Internal compress helper function.\r\n * @param buf Block to compress.\r\n * @param offset Offset of the block in the buffer.\r\n * @private\r\n */\r\n Sha1.prototype.compress_ = function (buf, offset) {\r\n if (!offset) {\r\n offset = 0;\r\n }\r\n var W = this.W_;\r\n // get 16 big endian words\r\n if (typeof buf === 'string') {\r\n for (var i = 0; i < 16; i++) {\r\n // TODO(user): [bug 8140122] Recent versions of Safari for Mac OS and iOS\r\n // have a bug that turns the post-increment ++ operator into pre-increment\r\n // during JIT compilation. We have code that depends heavily on SHA-1 for\r\n // correctness and which is affected by this bug, so I've removed all uses\r\n // of post-increment ++ in which the result value is used. We can revert\r\n // this change once the Safari bug\r\n // (https://bugs.webkit.org/show_bug.cgi?id=109036) has been fixed and\r\n // most clients have been updated.\r\n W[i] =\r\n (buf.charCodeAt(offset) << 24) |\r\n (buf.charCodeAt(offset + 1) << 16) |\r\n (buf.charCodeAt(offset + 2) << 8) |\r\n buf.charCodeAt(offset + 3);\r\n offset += 4;\r\n }\r\n }\r\n else {\r\n for (var i = 0; i < 16; i++) {\r\n W[i] =\r\n (buf[offset] << 24) |\r\n (buf[offset + 1] << 16) |\r\n (buf[offset + 2] << 8) |\r\n buf[offset + 3];\r\n offset += 4;\r\n }\r\n }\r\n // expand to 80 words\r\n for (var i = 16; i < 80; i++) {\r\n var t = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];\r\n W[i] = ((t << 1) | (t >>> 31)) & 0xffffffff;\r\n }\r\n var a = this.chain_[0];\r\n var b = this.chain_[1];\r\n var c = this.chain_[2];\r\n var d = this.chain_[3];\r\n var e = this.chain_[4];\r\n var f, k;\r\n // TODO(user): Try to unroll this loop to speed up the computation.\r\n for (var i = 0; i < 80; i++) {\r\n if (i < 40) {\r\n if (i < 20) {\r\n f = d ^ (b & (c ^ d));\r\n k = 0x5a827999;\r\n }\r\n else {\r\n f = b ^ c ^ d;\r\n k = 0x6ed9eba1;\r\n }\r\n }\r\n else {\r\n if (i < 60) {\r\n f = (b & c) | (d & (b | c));\r\n k = 0x8f1bbcdc;\r\n }\r\n else {\r\n f = b ^ c ^ d;\r\n k = 0xca62c1d6;\r\n }\r\n }\r\n var t = (((a << 5) | (a >>> 27)) + f + e + k + W[i]) & 0xffffffff;\r\n e = d;\r\n d = c;\r\n c = ((b << 30) | (b >>> 2)) & 0xffffffff;\r\n b = a;\r\n a = t;\r\n }\r\n this.chain_[0] = (this.chain_[0] + a) & 0xffffffff;\r\n this.chain_[1] = (this.chain_[1] + b) & 0xffffffff;\r\n this.chain_[2] = (this.chain_[2] + c) & 0xffffffff;\r\n this.chain_[3] = (this.chain_[3] + d) & 0xffffffff;\r\n this.chain_[4] = (this.chain_[4] + e) & 0xffffffff;\r\n };\r\n Sha1.prototype.update = function (bytes, length) {\r\n // TODO(johnlenz): tighten the function signature and remove this check\r\n if (bytes == null) {\r\n return;\r\n }\r\n if (length === undefined) {\r\n length = bytes.length;\r\n }\r\n var lengthMinusBlock = length - this.blockSize;\r\n var n = 0;\r\n // Using local instead of member variables gives ~5% speedup on Firefox 16.\r\n var buf = this.buf_;\r\n var inbuf = this.inbuf_;\r\n // The outer while loop should execute at most twice.\r\n while (n < length) {\r\n // When we have no data in the block to top up, we can directly process the\r\n // input buffer (assuming it contains sufficient data). This gives ~25%\r\n // speedup on Chrome 23 and ~15% speedup on Firefox 16, but requires that\r\n // the data is provided in large chunks (or in multiples of 64 bytes).\r\n if (inbuf === 0) {\r\n while (n <= lengthMinusBlock) {\r\n this.compress_(bytes, n);\r\n n += this.blockSize;\r\n }\r\n }\r\n if (typeof bytes === 'string') {\r\n while (n < length) {\r\n buf[inbuf] = bytes.charCodeAt(n);\r\n ++inbuf;\r\n ++n;\r\n if (inbuf === this.blockSize) {\r\n this.compress_(buf);\r\n inbuf = 0;\r\n // Jump to the outer loop so we use the full-block optimization.\r\n break;\r\n }\r\n }\r\n }\r\n else {\r\n while (n < length) {\r\n buf[inbuf] = bytes[n];\r\n ++inbuf;\r\n ++n;\r\n if (inbuf === this.blockSize) {\r\n this.compress_(buf);\r\n inbuf = 0;\r\n // Jump to the outer loop so we use the full-block optimization.\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n this.inbuf_ = inbuf;\r\n this.total_ += length;\r\n };\r\n /** @override */\r\n Sha1.prototype.digest = function () {\r\n var digest = [];\r\n var totalBits = this.total_ * 8;\r\n // Add pad 0x80 0x00*.\r\n if (this.inbuf_ < 56) {\r\n this.update(this.pad_, 56 - this.inbuf_);\r\n }\r\n else {\r\n this.update(this.pad_, this.blockSize - (this.inbuf_ - 56));\r\n }\r\n // Add # bits.\r\n for (var i = this.blockSize - 1; i >= 56; i--) {\r\n this.buf_[i] = totalBits & 255;\r\n totalBits /= 256; // Don't use bit-shifting here!\r\n }\r\n this.compress_(this.buf_);\r\n var n = 0;\r\n for (var i = 0; i < 5; i++) {\r\n for (var j = 24; j >= 0; j -= 8) {\r\n digest[n] = (this.chain_[i] >> j) & 255;\r\n ++n;\r\n }\r\n }\r\n return digest;\r\n };\r\n return Sha1;\r\n}());\n\n/**\r\n * Helper to make a Subscribe function (just like Promise helps make a\r\n * Thenable).\r\n *\r\n * @param executor Function which can make calls to a single Observer\r\n * as a proxy.\r\n * @param onNoObservers Callback when count of Observers goes to zero.\r\n */\r\nfunction createSubscribe(executor, onNoObservers) {\r\n var proxy = new ObserverProxy(executor, onNoObservers);\r\n return proxy.subscribe.bind(proxy);\r\n}\r\n/**\r\n * Implement fan-out for any number of Observers attached via a subscribe\r\n * function.\r\n */\r\nvar ObserverProxy = /** @class */ (function () {\r\n /**\r\n * @param executor Function which can make calls to a single Observer\r\n * as a proxy.\r\n * @param onNoObservers Callback when count of Observers goes to zero.\r\n */\r\n function ObserverProxy(executor, onNoObservers) {\r\n var _this = this;\r\n this.observers = [];\r\n this.unsubscribes = [];\r\n this.observerCount = 0;\r\n // Micro-task scheduling by calling task.then().\r\n this.task = Promise.resolve();\r\n this.finalized = false;\r\n this.onNoObservers = onNoObservers;\r\n // Call the executor asynchronously so subscribers that are called\r\n // synchronously after the creation of the subscribe function\r\n // can still receive the very first value generated in the executor.\r\n this.task\r\n .then(function () {\r\n executor(_this);\r\n })\r\n .catch(function (e) {\r\n _this.error(e);\r\n });\r\n }\r\n ObserverProxy.prototype.next = function (value) {\r\n this.forEachObserver(function (observer) {\r\n observer.next(value);\r\n });\r\n };\r\n ObserverProxy.prototype.error = function (error) {\r\n this.forEachObserver(function (observer) {\r\n observer.error(error);\r\n });\r\n this.close(error);\r\n };\r\n ObserverProxy.prototype.complete = function () {\r\n this.forEachObserver(function (observer) {\r\n observer.complete();\r\n });\r\n this.close();\r\n };\r\n /**\r\n * Subscribe function that can be used to add an Observer to the fan-out list.\r\n *\r\n * - We require that no event is sent to a subscriber sychronously to their\r\n * call to subscribe().\r\n */\r\n ObserverProxy.prototype.subscribe = function (nextOrObserver, error, complete) {\r\n var _this = this;\r\n var observer;\r\n if (nextOrObserver === undefined &&\r\n error === undefined &&\r\n complete === undefined) {\r\n throw new Error('Missing Observer.');\r\n }\r\n // Assemble an Observer object when passed as callback functions.\r\n if (implementsAnyMethods(nextOrObserver, [\r\n 'next',\r\n 'error',\r\n 'complete'\r\n ])) {\r\n observer = nextOrObserver;\r\n }\r\n else {\r\n observer = {\r\n next: nextOrObserver,\r\n error: error,\r\n complete: complete\r\n };\r\n }\r\n if (observer.next === undefined) {\r\n observer.next = noop;\r\n }\r\n if (observer.error === undefined) {\r\n observer.error = noop;\r\n }\r\n if (observer.complete === undefined) {\r\n observer.complete = noop;\r\n }\r\n var unsub = this.unsubscribeOne.bind(this, this.observers.length);\r\n // Attempt to subscribe to a terminated Observable - we\r\n // just respond to the Observer with the final error or complete\r\n // event.\r\n if (this.finalized) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.task.then(function () {\r\n try {\r\n if (_this.finalError) {\r\n observer.error(_this.finalError);\r\n }\r\n else {\r\n observer.complete();\r\n }\r\n }\r\n catch (e) {\r\n // nothing\r\n }\r\n return;\r\n });\r\n }\r\n this.observers.push(observer);\r\n return unsub;\r\n };\r\n // Unsubscribe is synchronous - we guarantee that no events are sent to\r\n // any unsubscribed Observer.\r\n ObserverProxy.prototype.unsubscribeOne = function (i) {\r\n if (this.observers === undefined || this.observers[i] === undefined) {\r\n return;\r\n }\r\n delete this.observers[i];\r\n this.observerCount -= 1;\r\n if (this.observerCount === 0 && this.onNoObservers !== undefined) {\r\n this.onNoObservers(this);\r\n }\r\n };\r\n ObserverProxy.prototype.forEachObserver = function (fn) {\r\n if (this.finalized) {\r\n // Already closed by previous event....just eat the additional values.\r\n return;\r\n }\r\n // Since sendOne calls asynchronously - there is no chance that\r\n // this.observers will become undefined.\r\n for (var i = 0; i < this.observers.length; i++) {\r\n this.sendOne(i, fn);\r\n }\r\n };\r\n // Call the Observer via one of it's callback function. We are careful to\r\n // confirm that the observe has not been unsubscribed since this asynchronous\r\n // function had been queued.\r\n ObserverProxy.prototype.sendOne = function (i, fn) {\r\n var _this = this;\r\n // Execute the callback asynchronously\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.task.then(function () {\r\n if (_this.observers !== undefined && _this.observers[i] !== undefined) {\r\n try {\r\n fn(_this.observers[i]);\r\n }\r\n catch (e) {\r\n // Ignore exceptions raised in Observers or missing methods of an\r\n // Observer.\r\n // Log error to console. b/31404806\r\n if (typeof console !== 'undefined' && console.error) {\r\n console.error(e);\r\n }\r\n }\r\n }\r\n });\r\n };\r\n ObserverProxy.prototype.close = function (err) {\r\n var _this = this;\r\n if (this.finalized) {\r\n return;\r\n }\r\n this.finalized = true;\r\n if (err !== undefined) {\r\n this.finalError = err;\r\n }\r\n // Proxy is no longer needed - garbage collect references\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.task.then(function () {\r\n _this.observers = undefined;\r\n _this.onNoObservers = undefined;\r\n });\r\n };\r\n return ObserverProxy;\r\n}());\r\n/** Turn synchronous function into one called asynchronously. */\r\n// eslint-disable-next-line @typescript-eslint/ban-types\r\nfunction async(fn, onError) {\r\n return function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n Promise.resolve(true)\r\n .then(function () {\r\n fn.apply(void 0, args);\r\n })\r\n .catch(function (error) {\r\n if (onError) {\r\n onError(error);\r\n }\r\n });\r\n };\r\n}\r\n/**\r\n * Return true if the object passed in implements any of the named methods.\r\n */\r\nfunction implementsAnyMethods(obj, methods) {\r\n if (typeof obj !== 'object' || obj === null) {\r\n return false;\r\n }\r\n for (var _i = 0, methods_1 = methods; _i < methods_1.length; _i++) {\r\n var method = methods_1[_i];\r\n if (method in obj && typeof obj[method] === 'function') {\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\nfunction noop() {\r\n // do nothing\r\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Check to make sure the appropriate number of arguments are provided for a public function.\r\n * Throws an error if it fails.\r\n *\r\n * @param fnName The function name\r\n * @param minCount The minimum number of arguments to allow for the function call\r\n * @param maxCount The maximum number of argument to allow for the function call\r\n * @param argCount The actual number of arguments provided.\r\n */\r\nvar validateArgCount = function (fnName, minCount, maxCount, argCount) {\r\n var argError;\r\n if (argCount < minCount) {\r\n argError = 'at least ' + minCount;\r\n }\r\n else if (argCount > maxCount) {\r\n argError = maxCount === 0 ? 'none' : 'no more than ' + maxCount;\r\n }\r\n if (argError) {\r\n var error = fnName +\r\n ' failed: Was called with ' +\r\n argCount +\r\n (argCount === 1 ? ' argument.' : ' arguments.') +\r\n ' Expects ' +\r\n argError +\r\n '.';\r\n throw new Error(error);\r\n }\r\n};\r\n/**\r\n * Generates a string to prefix an error message about failed argument validation\r\n *\r\n * @param fnName The function name\r\n * @param argumentNumber The index of the argument\r\n * @param optional Whether or not the argument is optional\r\n * @return The prefix to add to the error thrown for validation.\r\n */\r\nfunction errorPrefix(fnName, argumentNumber, optional) {\r\n var argName = '';\r\n switch (argumentNumber) {\r\n case 1:\r\n argName = optional ? 'first' : 'First';\r\n break;\r\n case 2:\r\n argName = optional ? 'second' : 'Second';\r\n break;\r\n case 3:\r\n argName = optional ? 'third' : 'Third';\r\n break;\r\n case 4:\r\n argName = optional ? 'fourth' : 'Fourth';\r\n break;\r\n default:\r\n throw new Error('errorPrefix called with argumentNumber > 4. Need to update it?');\r\n }\r\n var error = fnName + ' failed: ';\r\n error += argName + ' argument ';\r\n return error;\r\n}\r\n/**\r\n * @param fnName\r\n * @param argumentNumber\r\n * @param namespace\r\n * @param optional\r\n */\r\nfunction validateNamespace(fnName, argumentNumber, namespace, optional) {\r\n if (optional && !namespace) {\r\n return;\r\n }\r\n if (typeof namespace !== 'string') {\r\n //TODO: I should do more validation here. We only allow certain chars in namespaces.\r\n throw new Error(errorPrefix(fnName, argumentNumber, optional) +\r\n 'must be a valid firebase namespace.');\r\n }\r\n}\r\nfunction validateCallback(fnName, argumentNumber, \r\n// eslint-disable-next-line @typescript-eslint/ban-types\r\ncallback, optional) {\r\n if (optional && !callback) {\r\n return;\r\n }\r\n if (typeof callback !== 'function') {\r\n throw new Error(errorPrefix(fnName, argumentNumber, optional) +\r\n 'must be a valid function.');\r\n }\r\n}\r\nfunction validateContextObject(fnName, argumentNumber, context, optional) {\r\n if (optional && !context) {\r\n return;\r\n }\r\n if (typeof context !== 'object' || context === null) {\r\n throw new Error(errorPrefix(fnName, argumentNumber, optional) +\r\n 'must be a valid context object.');\r\n }\r\n}\n\n/**\r\n * @license\r\n * Copyright 2017 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n// Code originally came from goog.crypt.stringToUtf8ByteArray, but for some reason they\r\n// automatically replaced '\\r\\n' with '\\n', and they didn't handle surrogate pairs,\r\n// so it's been modified.\r\n// Note that not all Unicode characters appear as single characters in JavaScript strings.\r\n// fromCharCode returns the UTF-16 encoding of a character - so some Unicode characters\r\n// use 2 characters in Javascript. All 4-byte UTF-8 characters begin with a first\r\n// character in the range 0xD800 - 0xDBFF (the first character of a so-called surrogate\r\n// pair).\r\n// See http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3\r\n/**\r\n * @param {string} str\r\n * @return {Array}\r\n */\r\nvar stringToByteArray$1 = function (str) {\r\n var out = [];\r\n var p = 0;\r\n for (var i = 0; i < str.length; i++) {\r\n var c = str.charCodeAt(i);\r\n // Is this the lead surrogate in a surrogate pair?\r\n if (c >= 0xd800 && c <= 0xdbff) {\r\n var high = c - 0xd800; // the high 10 bits.\r\n i++;\r\n assert(i < str.length, 'Surrogate pair missing trail surrogate.');\r\n var low = str.charCodeAt(i) - 0xdc00; // the low 10 bits.\r\n c = 0x10000 + (high << 10) + low;\r\n }\r\n if (c < 128) {\r\n out[p++] = c;\r\n }\r\n else if (c < 2048) {\r\n out[p++] = (c >> 6) | 192;\r\n out[p++] = (c & 63) | 128;\r\n }\r\n else if (c < 65536) {\r\n out[p++] = (c >> 12) | 224;\r\n out[p++] = ((c >> 6) & 63) | 128;\r\n out[p++] = (c & 63) | 128;\r\n }\r\n else {\r\n out[p++] = (c >> 18) | 240;\r\n out[p++] = ((c >> 12) & 63) | 128;\r\n out[p++] = ((c >> 6) & 63) | 128;\r\n out[p++] = (c & 63) | 128;\r\n }\r\n }\r\n return out;\r\n};\r\n/**\r\n * Calculate length without actually converting; useful for doing cheaper validation.\r\n * @param {string} str\r\n * @return {number}\r\n */\r\nvar stringLength = function (str) {\r\n var p = 0;\r\n for (var i = 0; i < str.length; i++) {\r\n var c = str.charCodeAt(i);\r\n if (c < 128) {\r\n p++;\r\n }\r\n else if (c < 2048) {\r\n p += 2;\r\n }\r\n else if (c >= 0xd800 && c <= 0xdbff) {\r\n // Lead surrogate of a surrogate pair. The pair together will take 4 bytes to represent.\r\n p += 4;\r\n i++; // skip trail surrogate.\r\n }\r\n else {\r\n p += 3;\r\n }\r\n }\r\n return p;\r\n};\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * The amount of milliseconds to exponentially increase.\r\n */\r\nvar DEFAULT_INTERVAL_MILLIS = 1000;\r\n/**\r\n * The factor to backoff by.\r\n * Should be a number greater than 1.\r\n */\r\nvar DEFAULT_BACKOFF_FACTOR = 2;\r\n/**\r\n * The maximum milliseconds to increase to.\r\n *\r\n * Visible for testing\r\n */\r\nvar MAX_VALUE_MILLIS = 4 * 60 * 60 * 1000; // Four hours, like iOS and Android.\r\n/**\r\n * The percentage of backoff time to randomize by.\r\n * See\r\n * http://go/safe-client-behavior#step-1-determine-the-appropriate-retry-interval-to-handle-spike-traffic\r\n * for context.\r\n *\r\n *
Visible for testing\r\n */\r\nvar RANDOM_FACTOR = 0.5;\r\n/**\r\n * Based on the backoff method from\r\n * https://github.com/google/closure-library/blob/master/closure/goog/math/exponentialbackoff.js.\r\n * Extracted here so we don't need to pass metadata and a stateful ExponentialBackoff object around.\r\n */\r\nfunction calculateBackoffMillis(backoffCount, intervalMillis, backoffFactor) {\r\n if (intervalMillis === void 0) { intervalMillis = DEFAULT_INTERVAL_MILLIS; }\r\n if (backoffFactor === void 0) { backoffFactor = DEFAULT_BACKOFF_FACTOR; }\r\n // Calculates an exponentially increasing value.\r\n // Deviation: calculates value from count and a constant interval, so we only need to save value\r\n // and count to restore state.\r\n var currBaseValue = intervalMillis * Math.pow(backoffFactor, backoffCount);\r\n // A random \"fuzz\" to avoid waves of retries.\r\n // Deviation: randomFactor is required.\r\n var randomWait = Math.round(\r\n // A fraction of the backoff value to add/subtract.\r\n // Deviation: changes multiplication order to improve readability.\r\n RANDOM_FACTOR *\r\n currBaseValue *\r\n // A random float (rounded to int by Math.round above) in the range [-1, 1]. Determines\r\n // if we add or subtract.\r\n (Math.random() - 0.5) *\r\n 2);\r\n // Limits backoff to max to avoid effectively permanent backoff.\r\n return Math.min(MAX_VALUE_MILLIS, currBaseValue + randomWait);\r\n}\n\nexports.CONSTANTS = CONSTANTS;\nexports.Deferred = Deferred;\nexports.ErrorFactory = ErrorFactory;\nexports.FirebaseError = FirebaseError;\nexports.MAX_VALUE_MILLIS = MAX_VALUE_MILLIS;\nexports.RANDOM_FACTOR = RANDOM_FACTOR;\nexports.Sha1 = Sha1;\nexports.areCookiesEnabled = areCookiesEnabled;\nexports.assert = assert;\nexports.assertionError = assertionError;\nexports.async = async;\nexports.base64 = base64;\nexports.base64Decode = base64Decode;\nexports.base64Encode = base64Encode;\nexports.calculateBackoffMillis = calculateBackoffMillis;\nexports.contains = contains;\nexports.createSubscribe = createSubscribe;\nexports.decode = decode;\nexports.deepCopy = deepCopy;\nexports.deepExtend = deepExtend;\nexports.errorPrefix = errorPrefix;\nexports.getUA = getUA;\nexports.isAdmin = isAdmin;\nexports.isBrowser = isBrowser;\nexports.isBrowserExtension = isBrowserExtension;\nexports.isElectron = isElectron;\nexports.isEmpty = isEmpty;\nexports.isIE = isIE;\nexports.isIndexedDBAvailable = isIndexedDBAvailable;\nexports.isMobileCordova = isMobileCordova;\nexports.isNode = isNode;\nexports.isNodeSdk = isNodeSdk;\nexports.isReactNative = isReactNative;\nexports.isSafari = isSafari;\nexports.isUWP = isUWP;\nexports.isValidFormat = isValidFormat;\nexports.isValidTimestamp = isValidTimestamp;\nexports.issuedAtTime = issuedAtTime;\nexports.jsonEval = jsonEval;\nexports.map = map;\nexports.querystring = querystring;\nexports.querystringDecode = querystringDecode;\nexports.safeGet = safeGet;\nexports.stringLength = stringLength;\nexports.stringToByteArray = stringToByteArray$1;\nexports.stringify = stringify;\nexports.validateArgCount = validateArgCount;\nexports.validateCallback = validateCallback;\nexports.validateContextObject = validateContextObject;\nexports.validateIndexedDBOpenable = validateIndexedDBOpenable;\nexports.validateNamespace = validateNamespace;\n//# sourceMappingURL=index.cjs.js.map\n","'use strict';\nvar global = require('../internals/global');\nvar isCallable = require('../internals/is-callable');\n\nvar WeakMap = global.WeakMap;\n\nmodule.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n/*\nMixin for objects that are mounted by Google Maps\nJavascript API.\n\nThese are objects that are sensitive to element resize\noperations so it exposes a property which accepts a bus\n\n*/\n\nexports.default = {\n props: ['resizeBus'],\n\n data: function data() {\n return {\n _actualResizeBus: null\n };\n },\n created: function created() {\n if (typeof this.resizeBus === 'undefined') {\n this.$data._actualResizeBus = this.$gmapDefaultResizeBus;\n } else {\n this.$data._actualResizeBus = this.resizeBus;\n }\n },\n\n\n methods: {\n _resizeCallback: function _resizeCallback() {\n this.resize();\n },\n _delayedResizeCallback: function _delayedResizeCallback() {\n var _this = this;\n\n this.$nextTick(function () {\n return _this._resizeCallback();\n });\n }\n },\n\n watch: {\n resizeBus: function resizeBus(newVal) {\n // eslint-disable-line no-unused-vars\n this.$data._actualResizeBus = newVal;\n },\n '$data._actualResizeBus': function $data_actualResizeBus(newVal, oldVal) {\n if (oldVal) {\n oldVal.$off('resize', this._delayedResizeCallback);\n }\n if (newVal) {\n newVal.$on('resize', this._delayedResizeCallback);\n }\n }\n },\n\n destroyed: function destroyed() {\n if (this.$data._actualResizeBus) {\n this.$data._actualResizeBus.$off('resize', this._delayedResizeCallback);\n }\n }\n};","var Symbol = require('./_Symbol'),\n arrayMap = require('./_arrayMap'),\n isArray = require('./isArray'),\n isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isArray(value)) {\n // Recursively convert values (susceptible to call stack limits).\n return arrayMap(value, baseToString) + '';\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nmodule.exports = baseToString;\n","'use strict';\n\nimport toFormData from './toFormData.js';\n\n/**\n * It encodes a string by replacing all characters that are not in the unreserved set with\n * their percent-encoded equivalents\n *\n * @param {string} str - The string to encode.\n *\n * @returns {string} The encoded string.\n */\nfunction encode(str) {\n const charMap = {\n '!': '%21',\n \"'\": '%27',\n '(': '%28',\n ')': '%29',\n '~': '%7E',\n '%20': '+',\n '%00': '\\x00'\n };\n return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {\n return charMap[match];\n });\n}\n\n/**\n * It takes a params object and converts it to a FormData object\n *\n * @param {Object} params - The parameters to be converted to a FormData object.\n * @param {Object} options - The options object passed to the Axios constructor.\n *\n * @returns {void}\n */\nfunction AxiosURLSearchParams(params, options) {\n this._pairs = [];\n\n params && toFormData(params, this, options);\n}\n\nconst prototype = AxiosURLSearchParams.prototype;\n\nprototype.append = function append(name, value) {\n this._pairs.push([name, value]);\n};\n\nprototype.toString = function toString(encoder) {\n const _encode = encoder ? function(value) {\n return encoder.call(this, value, encode);\n } : encode;\n\n return this._pairs.map(function each(pair) {\n return _encode(pair[0]) + '=' + _encode(pair[1]);\n }, '').join('&');\n};\n\nexport default AxiosURLSearchParams;\n","'use strict';\n\nimport utils from '../utils.js';\nimport AxiosURLSearchParams from '../helpers/AxiosURLSearchParams.js';\n\n/**\n * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their\n * URI encoded counterparts\n *\n * @param {string} val The value to be encoded.\n *\n * @returns {string} The encoded value.\n */\nfunction encode(val) {\n return encodeURIComponent(val).\n replace(/%3A/gi, ':').\n replace(/%24/g, '$').\n replace(/%2C/gi, ',').\n replace(/%20/g, '+').\n replace(/%5B/gi, '[').\n replace(/%5D/gi, ']');\n}\n\n/**\n * Build a URL by appending params to the end\n *\n * @param {string} url The base of the url (e.g., http://www.google.com)\n * @param {object} [params] The params to be appended\n * @param {?object} options\n *\n * @returns {string} The formatted url\n */\nexport default function buildURL(url, params, options) {\n /*eslint no-param-reassign:0*/\n if (!params) {\n return url;\n }\n \n const _encode = options && options.encode || encode;\n\n const serializeFn = options && options.serialize;\n\n let serializedParams;\n\n if (serializeFn) {\n serializedParams = serializeFn(params, options);\n } else {\n serializedParams = utils.isURLSearchParams(params) ?\n params.toString() :\n new AxiosURLSearchParams(params, options).toString(_encode);\n }\n\n if (serializedParams) {\n const hashmarkIndex = url.indexOf(\"#\");\n\n if (hashmarkIndex !== -1) {\n url = url.slice(0, hashmarkIndex);\n }\n url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n }\n\n return url;\n}\n","'use strict';\n\nimport utils from './../utils.js';\n\nclass InterceptorManager {\n constructor() {\n this.handlers = [];\n }\n\n /**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\n use(fulfilled, rejected, options) {\n this.handlers.push({\n fulfilled,\n rejected,\n synchronous: options ? options.synchronous : false,\n runWhen: options ? options.runWhen : null\n });\n return this.handlers.length - 1;\n }\n\n /**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n *\n * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise\n */\n eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n }\n\n /**\n * Clear all interceptors from the stack\n *\n * @returns {void}\n */\n clear() {\n if (this.handlers) {\n this.handlers = [];\n }\n }\n\n /**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n *\n * @returns {void}\n */\n forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n }\n}\n\nexport default InterceptorManager;\n","'use strict';\n\nexport default {\n silentJSONParsing: true,\n forcedJSONParsing: true,\n clarifyTimeoutError: false\n};\n","'use strict';\n\nimport AxiosURLSearchParams from '../../../helpers/AxiosURLSearchParams.js';\nexport default typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;\n","'use strict';\n\nexport default typeof FormData !== 'undefined' ? FormData : null;\n","'use strict'\n\nexport default typeof Blob !== 'undefined' ? Blob : null\n","import URLSearchParams from './classes/URLSearchParams.js'\nimport FormData from './classes/FormData.js'\nimport Blob from './classes/Blob.js'\n\nexport default {\n isBrowser: true,\n classes: {\n URLSearchParams,\n FormData,\n Blob\n },\n protocols: ['http', 'https', 'file', 'blob', 'url', 'data']\n};\n","const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * navigator.product -> 'ReactNative'\n * nativescript\n * navigator.product -> 'NativeScript' or 'NS'\n *\n * @returns {boolean}\n */\nconst hasStandardBrowserEnv = (\n (product) => {\n return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0\n })(typeof navigator !== 'undefined' && navigator.product);\n\n/**\n * Determine if we're running in a standard browser webWorker environment\n *\n * Although the `isStandardBrowserEnv` method indicates that\n * `allows axios to run in a web worker`, the WebWorker will still be\n * filtered out due to its judgment standard\n * `typeof window !== 'undefined' && typeof document !== 'undefined'`.\n * This leads to a problem when axios post `FormData` in webWorker\n */\nconst hasStandardBrowserWebWorkerEnv = (() => {\n return (\n typeof WorkerGlobalScope !== 'undefined' &&\n // eslint-disable-next-line no-undef\n self instanceof WorkerGlobalScope &&\n typeof self.importScripts === 'function'\n );\n})();\n\nexport {\n hasBrowserEnv,\n hasStandardBrowserWebWorkerEnv,\n hasStandardBrowserEnv\n}\n","import platform from './node/index.js';\nimport * as utils from './common/utils.js';\n\nexport default {\n ...utils,\n ...platform\n}\n","'use strict';\n\nimport utils from '../utils.js';\nimport toFormData from './toFormData.js';\nimport platform from '../platform/index.js';\n\nexport default function toURLEncodedForm(data, options) {\n return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({\n visitor: function(value, key, path, helpers) {\n if (platform.isNode && utils.isBuffer(value)) {\n this.append(key, value.toString('base64'));\n return false;\n }\n\n return helpers.defaultVisitor.apply(this, arguments);\n }\n }, options));\n}\n","'use strict';\n\nimport utils from '../utils.js';\n\n/**\n * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']\n *\n * @param {string} name - The name of the property to get.\n *\n * @returns An array of strings.\n */\nfunction parsePropPath(name) {\n // foo[x][y][z]\n // foo.x.y.z\n // foo-x-y-z\n // foo x y z\n return utils.matchAll(/\\w+|\\[(\\w*)]/g, name).map(match => {\n return match[0] === '[]' ? '' : match[1] || match[0];\n });\n}\n\n/**\n * Convert an array to an object.\n *\n * @param {Array} arr - The array to convert to an object.\n *\n * @returns An object with the same keys and values as the array.\n */\nfunction arrayToObject(arr) {\n const obj = {};\n const keys = Object.keys(arr);\n let i;\n const len = keys.length;\n let key;\n for (i = 0; i < len; i++) {\n key = keys[i];\n obj[key] = arr[key];\n }\n return obj;\n}\n\n/**\n * It takes a FormData object and returns a JavaScript object\n *\n * @param {string} formData The FormData object to convert to JSON.\n *\n * @returns {Object | null} The converted object.\n */\nfunction formDataToJSON(formData) {\n function buildPath(path, value, target, index) {\n let name = path[index++];\n\n if (name === '__proto__') return true;\n\n const isNumericKey = Number.isFinite(+name);\n const isLast = index >= path.length;\n name = !name && utils.isArray(target) ? target.length : name;\n\n if (isLast) {\n if (utils.hasOwnProp(target, name)) {\n target[name] = [target[name], value];\n } else {\n target[name] = value;\n }\n\n return !isNumericKey;\n }\n\n if (!target[name] || !utils.isObject(target[name])) {\n target[name] = [];\n }\n\n const result = buildPath(path, value, target[name], index);\n\n if (result && utils.isArray(target[name])) {\n target[name] = arrayToObject(target[name]);\n }\n\n return !isNumericKey;\n }\n\n if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {\n const obj = {};\n\n utils.forEachEntry(formData, (name, value) => {\n buildPath(parsePropPath(name), value, obj, 0);\n });\n\n return obj;\n }\n\n return null;\n}\n\nexport default formDataToJSON;\n","'use strict';\n\nimport utils from '../utils.js';\nimport AxiosError from '../core/AxiosError.js';\nimport transitionalDefaults from './transitional.js';\nimport toFormData from '../helpers/toFormData.js';\nimport toURLEncodedForm from '../helpers/toURLEncodedForm.js';\nimport platform from '../platform/index.js';\nimport formDataToJSON from '../helpers/formDataToJSON.js';\n\n/**\n * It takes a string, tries to parse it, and if it fails, it returns the stringified version\n * of the input\n *\n * @param {any} rawValue - The value to be stringified.\n * @param {Function} parser - A function that parses a string into a JavaScript object.\n * @param {Function} encoder - A function that takes a value and returns a string.\n *\n * @returns {string} A stringified version of the rawValue.\n */\nfunction stringifySafely(rawValue, parser, encoder) {\n if (utils.isString(rawValue)) {\n try {\n (parser || JSON.parse)(rawValue);\n return utils.trim(rawValue);\n } catch (e) {\n if (e.name !== 'SyntaxError') {\n throw e;\n }\n }\n }\n\n return (encoder || JSON.stringify)(rawValue);\n}\n\nconst defaults = {\n\n transitional: transitionalDefaults,\n\n adapter: ['xhr', 'http'],\n\n transformRequest: [function transformRequest(data, headers) {\n const contentType = headers.getContentType() || '';\n const hasJSONContentType = contentType.indexOf('application/json') > -1;\n const isObjectPayload = utils.isObject(data);\n\n if (isObjectPayload && utils.isHTMLForm(data)) {\n data = new FormData(data);\n }\n\n const isFormData = utils.isFormData(data);\n\n if (isFormData) {\n return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;\n }\n\n if (utils.isArrayBuffer(data) ||\n utils.isBuffer(data) ||\n utils.isStream(data) ||\n utils.isFile(data) ||\n utils.isBlob(data)\n ) {\n return data;\n }\n if (utils.isArrayBufferView(data)) {\n return data.buffer;\n }\n if (utils.isURLSearchParams(data)) {\n headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);\n return data.toString();\n }\n\n let isFileList;\n\n if (isObjectPayload) {\n if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {\n return toURLEncodedForm(data, this.formSerializer).toString();\n }\n\n if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {\n const _FormData = this.env && this.env.FormData;\n\n return toFormData(\n isFileList ? {'files[]': data} : data,\n _FormData && new _FormData(),\n this.formSerializer\n );\n }\n }\n\n if (isObjectPayload || hasJSONContentType ) {\n headers.setContentType('application/json', false);\n return stringifySafely(data);\n }\n\n return data;\n }],\n\n transformResponse: [function transformResponse(data) {\n const transitional = this.transitional || defaults.transitional;\n const forcedJSONParsing = transitional && transitional.forcedJSONParsing;\n const JSONRequested = this.responseType === 'json';\n\n if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {\n const silentJSONParsing = transitional && transitional.silentJSONParsing;\n const strictJSONParsing = !silentJSONParsing && JSONRequested;\n\n try {\n return JSON.parse(data);\n } catch (e) {\n if (strictJSONParsing) {\n if (e.name === 'SyntaxError') {\n throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);\n }\n throw e;\n }\n }\n }\n\n return data;\n }],\n\n /**\n * A timeout in milliseconds to abort a request. If set to 0 (default) a\n * timeout is not created.\n */\n timeout: 0,\n\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN',\n\n maxContentLength: -1,\n maxBodyLength: -1,\n\n env: {\n FormData: platform.classes.FormData,\n Blob: platform.classes.Blob\n },\n\n validateStatus: function validateStatus(status) {\n return status >= 200 && status < 300;\n },\n\n headers: {\n common: {\n 'Accept': 'application/json, text/plain, */*',\n 'Content-Type': undefined\n }\n }\n};\n\nutils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {\n defaults.headers[method] = {};\n});\n\nexport default defaults;\n","'use strict';\n\nimport utils from './../utils.js';\n\n// RawAxiosHeaders whose duplicates are ignored by node\n// c.f. https://nodejs.org/api/http.html#http_message_headers\nconst ignoreDuplicateOf = utils.toObjectSet([\n 'age', 'authorization', 'content-length', 'content-type', 'etag',\n 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',\n 'last-modified', 'location', 'max-forwards', 'proxy-authorization',\n 'referer', 'retry-after', 'user-agent'\n]);\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} rawHeaders Headers needing to be parsed\n *\n * @returns {Object} Headers parsed into an object\n */\nexport default rawHeaders => {\n const parsed = {};\n let key;\n let val;\n let i;\n\n rawHeaders && rawHeaders.split('\\n').forEach(function parser(line) {\n i = line.indexOf(':');\n key = line.substring(0, i).trim().toLowerCase();\n val = line.substring(i + 1).trim();\n\n if (!key || (parsed[key] && ignoreDuplicateOf[key])) {\n return;\n }\n\n if (key === 'set-cookie') {\n if (parsed[key]) {\n parsed[key].push(val);\n } else {\n parsed[key] = [val];\n }\n } else {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n });\n\n return parsed;\n};\n","'use strict';\n\nimport utils from '../utils.js';\nimport parseHeaders from '../helpers/parseHeaders.js';\n\nconst $internals = Symbol('internals');\n\nfunction normalizeHeader(header) {\n return header && String(header).trim().toLowerCase();\n}\n\nfunction normalizeValue(value) {\n if (value === false || value == null) {\n return value;\n }\n\n return utils.isArray(value) ? value.map(normalizeValue) : String(value);\n}\n\nfunction parseTokens(str) {\n const tokens = Object.create(null);\n const tokensRE = /([^\\s,;=]+)\\s*(?:=\\s*([^,;]+))?/g;\n let match;\n\n while ((match = tokensRE.exec(str))) {\n tokens[match[1]] = match[2];\n }\n\n return tokens;\n}\n\nconst isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());\n\nfunction matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {\n if (utils.isFunction(filter)) {\n return filter.call(this, value, header);\n }\n\n if (isHeaderNameFilter) {\n value = header;\n }\n\n if (!utils.isString(value)) return;\n\n if (utils.isString(filter)) {\n return value.indexOf(filter) !== -1;\n }\n\n if (utils.isRegExp(filter)) {\n return filter.test(value);\n }\n}\n\nfunction formatHeader(header) {\n return header.trim()\n .toLowerCase().replace(/([a-z\\d])(\\w*)/g, (w, char, str) => {\n return char.toUpperCase() + str;\n });\n}\n\nfunction buildAccessors(obj, header) {\n const accessorName = utils.toCamelCase(' ' + header);\n\n ['get', 'set', 'has'].forEach(methodName => {\n Object.defineProperty(obj, methodName + accessorName, {\n value: function(arg1, arg2, arg3) {\n return this[methodName].call(this, header, arg1, arg2, arg3);\n },\n configurable: true\n });\n });\n}\n\nclass AxiosHeaders {\n constructor(headers) {\n headers && this.set(headers);\n }\n\n set(header, valueOrRewrite, rewrite) {\n const self = this;\n\n function setHeader(_value, _header, _rewrite) {\n const lHeader = normalizeHeader(_header);\n\n if (!lHeader) {\n throw new Error('header name must be a non-empty string');\n }\n\n const key = utils.findKey(self, lHeader);\n\n if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {\n self[key || _header] = normalizeValue(_value);\n }\n }\n\n const setHeaders = (headers, _rewrite) =>\n utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));\n\n if (utils.isPlainObject(header) || header instanceof this.constructor) {\n setHeaders(header, valueOrRewrite)\n } else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {\n setHeaders(parseHeaders(header), valueOrRewrite);\n } else {\n header != null && setHeader(valueOrRewrite, header, rewrite);\n }\n\n return this;\n }\n\n get(header, parser) {\n header = normalizeHeader(header);\n\n if (header) {\n const key = utils.findKey(this, header);\n\n if (key) {\n const value = this[key];\n\n if (!parser) {\n return value;\n }\n\n if (parser === true) {\n return parseTokens(value);\n }\n\n if (utils.isFunction(parser)) {\n return parser.call(this, value, key);\n }\n\n if (utils.isRegExp(parser)) {\n return parser.exec(value);\n }\n\n throw new TypeError('parser must be boolean|regexp|function');\n }\n }\n }\n\n has(header, matcher) {\n header = normalizeHeader(header);\n\n if (header) {\n const key = utils.findKey(this, header);\n\n return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));\n }\n\n return false;\n }\n\n delete(header, matcher) {\n const self = this;\n let deleted = false;\n\n function deleteHeader(_header) {\n _header = normalizeHeader(_header);\n\n if (_header) {\n const key = utils.findKey(self, _header);\n\n if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {\n delete self[key];\n\n deleted = true;\n }\n }\n }\n\n if (utils.isArray(header)) {\n header.forEach(deleteHeader);\n } else {\n deleteHeader(header);\n }\n\n return deleted;\n }\n\n clear(matcher) {\n const keys = Object.keys(this);\n let i = keys.length;\n let deleted = false;\n\n while (i--) {\n const key = keys[i];\n if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {\n delete this[key];\n deleted = true;\n }\n }\n\n return deleted;\n }\n\n normalize(format) {\n const self = this;\n const headers = {};\n\n utils.forEach(this, (value, header) => {\n const key = utils.findKey(headers, header);\n\n if (key) {\n self[key] = normalizeValue(value);\n delete self[header];\n return;\n }\n\n const normalized = format ? formatHeader(header) : String(header).trim();\n\n if (normalized !== header) {\n delete self[header];\n }\n\n self[normalized] = normalizeValue(value);\n\n headers[normalized] = true;\n });\n\n return this;\n }\n\n concat(...targets) {\n return this.constructor.concat(this, ...targets);\n }\n\n toJSON(asStrings) {\n const obj = Object.create(null);\n\n utils.forEach(this, (value, header) => {\n value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);\n });\n\n return obj;\n }\n\n [Symbol.iterator]() {\n return Object.entries(this.toJSON())[Symbol.iterator]();\n }\n\n toString() {\n return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\\n');\n }\n\n get [Symbol.toStringTag]() {\n return 'AxiosHeaders';\n }\n\n static from(thing) {\n return thing instanceof this ? thing : new this(thing);\n }\n\n static concat(first, ...targets) {\n const computed = new this(first);\n\n targets.forEach((target) => computed.set(target));\n\n return computed;\n }\n\n static accessor(header) {\n const internals = this[$internals] = (this[$internals] = {\n accessors: {}\n });\n\n const accessors = internals.accessors;\n const prototype = this.prototype;\n\n function defineAccessor(_header) {\n const lHeader = normalizeHeader(_header);\n\n if (!accessors[lHeader]) {\n buildAccessors(prototype, _header);\n accessors[lHeader] = true;\n }\n }\n\n utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);\n\n return this;\n }\n}\n\nAxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);\n\n// reserved names hotfix\nutils.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {\n let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`\n return {\n get: () => value,\n set(headerValue) {\n this[mapped] = headerValue;\n }\n }\n});\n\nutils.freezeMethods(AxiosHeaders);\n\nexport default AxiosHeaders;\n","'use strict';\n\nimport utils from './../utils.js';\nimport defaults from '../defaults/index.js';\nimport AxiosHeaders from '../core/AxiosHeaders.js';\n\n/**\n * Transform the data for a request or a response\n *\n * @param {Array|Function} fns A single function or Array of functions\n * @param {?Object} response The response object\n *\n * @returns {*} The resulting transformed data\n */\nexport default function transformData(fns, response) {\n const config = this || defaults;\n const context = response || config;\n const headers = AxiosHeaders.from(context.headers);\n let data = context.data;\n\n utils.forEach(fns, function transform(fn) {\n data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);\n });\n\n headers.normalize();\n\n return data;\n}\n","'use strict';\n\nexport default function isCancel(value) {\n return !!(value && value.__CANCEL__);\n}\n","'use strict';\n\nimport AxiosError from '../core/AxiosError.js';\nimport utils from '../utils.js';\n\n/**\n * A `CanceledError` is an object that is thrown when an operation is canceled.\n *\n * @param {string=} message The message.\n * @param {Object=} config The config.\n * @param {Object=} request The request.\n *\n * @returns {CanceledError} The created error.\n */\nfunction CanceledError(message, config, request) {\n // eslint-disable-next-line no-eq-null,eqeqeq\n AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);\n this.name = 'CanceledError';\n}\n\nutils.inherits(CanceledError, AxiosError, {\n __CANCEL__: true\n});\n\nexport default CanceledError;\n","'use strict';\n\nimport AxiosError from './AxiosError.js';\n\n/**\n * Resolve or reject a Promise based on response status.\n *\n * @param {Function} resolve A function that resolves the promise.\n * @param {Function} reject A function that rejects the promise.\n * @param {object} response The response.\n *\n * @returns {object} The response.\n */\nexport default function settle(resolve, reject, response) {\n const validateStatus = response.config.validateStatus;\n if (!response.status || !validateStatus || validateStatus(response.status)) {\n resolve(response);\n } else {\n reject(new AxiosError(\n 'Request failed with status code ' + response.status,\n [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],\n response.config,\n response.request,\n response\n ));\n }\n}\n","import utils from './../utils.js';\nimport platform from '../platform/index.js';\n\nexport default platform.hasStandardBrowserEnv ?\n\n // Standard browser envs support document.cookie\n {\n write(name, value, expires, path, domain, secure) {\n const cookie = [name + '=' + encodeURIComponent(value)];\n\n utils.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());\n\n utils.isString(path) && cookie.push('path=' + path);\n\n utils.isString(domain) && cookie.push('domain=' + domain);\n\n secure === true && cookie.push('secure');\n\n document.cookie = cookie.join('; ');\n },\n\n read(name) {\n const match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n return (match ? decodeURIComponent(match[3]) : null);\n },\n\n remove(name) {\n this.write(name, '', Date.now() - 86400000);\n }\n }\n\n :\n\n // Non-standard browser env (web workers, react-native) lack needed support.\n {\n write() {},\n read() {\n return null;\n },\n remove() {}\n };\n\n","'use strict';\n\n/**\n * Determines whether the specified URL is absolute\n *\n * @param {string} url The URL to test\n *\n * @returns {boolean} True if the specified URL is absolute, otherwise false\n */\nexport default function isAbsoluteURL(url) {\n // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n // by any combination of letters, digits, plus, period, or hyphen.\n return /^([a-z][a-z\\d+\\-.]*:)?\\/\\//i.test(url);\n}\n","'use strict';\n\n/**\n * Creates a new URL by combining the specified URLs\n *\n * @param {string} baseURL The base URL\n * @param {string} relativeURL The relative URL\n *\n * @returns {string} The combined URL\n */\nexport default function combineURLs(baseURL, relativeURL) {\n return relativeURL\n ? baseURL.replace(/\\/?\\/$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n : baseURL;\n}\n","'use strict';\n\nimport isAbsoluteURL from '../helpers/isAbsoluteURL.js';\nimport combineURLs from '../helpers/combineURLs.js';\n\n/**\n * Creates a new URL by combining the baseURL with the requestedURL,\n * only when the requestedURL is not already an absolute URL.\n * If the requestURL is absolute, this function returns the requestedURL untouched.\n *\n * @param {string} baseURL The base URL\n * @param {string} requestedURL Absolute or relative URL to combine\n *\n * @returns {string} The combined full path\n */\nexport default function buildFullPath(baseURL, requestedURL) {\n if (baseURL && !isAbsoluteURL(requestedURL)) {\n return combineURLs(baseURL, requestedURL);\n }\n return requestedURL;\n}\n","'use strict';\n\nimport utils from './../utils.js';\nimport platform from '../platform/index.js';\n\nexport default platform.hasStandardBrowserEnv ?\n\n// Standard browser envs have full support of the APIs needed to test\n// whether the request URL is of the same origin as current location.\n (function standardBrowserEnv() {\n const msie = /(msie|trident)/i.test(navigator.userAgent);\n const urlParsingNode = document.createElement('a');\n let originURL;\n\n /**\n * Parse a URL to discover its components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n function resolveURL(url) {\n let href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href);\n\n // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n urlParsingNode.pathname :\n '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n return function isURLSameOrigin(requestURL) {\n const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n return (parsed.protocol === originURL.protocol &&\n parsed.host === originURL.host);\n };\n })() :\n\n // Non standard browser envs (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n })();\n","'use strict';\n\nexport default function parseProtocol(url) {\n const match = /^([-+\\w]{1,25})(:?\\/\\/|:)/.exec(url);\n return match && match[1] || '';\n}\n","'use strict';\n\n/**\n * Calculate data maxRate\n * @param {Number} [samplesCount= 10]\n * @param {Number} [min= 1000]\n * @returns {Function}\n */\nfunction speedometer(samplesCount, min) {\n samplesCount = samplesCount || 10;\n const bytes = new Array(samplesCount);\n const timestamps = new Array(samplesCount);\n let head = 0;\n let tail = 0;\n let firstSampleTS;\n\n min = min !== undefined ? min : 1000;\n\n return function push(chunkLength) {\n const now = Date.now();\n\n const startedAt = timestamps[tail];\n\n if (!firstSampleTS) {\n firstSampleTS = now;\n }\n\n bytes[head] = chunkLength;\n timestamps[head] = now;\n\n let i = tail;\n let bytesCount = 0;\n\n while (i !== head) {\n bytesCount += bytes[i++];\n i = i % samplesCount;\n }\n\n head = (head + 1) % samplesCount;\n\n if (head === tail) {\n tail = (tail + 1) % samplesCount;\n }\n\n if (now - firstSampleTS < min) {\n return;\n }\n\n const passed = startedAt && now - startedAt;\n\n return passed ? Math.round(bytesCount * 1000 / passed) : undefined;\n };\n}\n\nexport default speedometer;\n","'use strict';\n\nimport utils from './../utils.js';\nimport settle from './../core/settle.js';\nimport cookies from './../helpers/cookies.js';\nimport buildURL from './../helpers/buildURL.js';\nimport buildFullPath from '../core/buildFullPath.js';\nimport isURLSameOrigin from './../helpers/isURLSameOrigin.js';\nimport transitionalDefaults from '../defaults/transitional.js';\nimport AxiosError from '../core/AxiosError.js';\nimport CanceledError from '../cancel/CanceledError.js';\nimport parseProtocol from '../helpers/parseProtocol.js';\nimport platform from '../platform/index.js';\nimport AxiosHeaders from '../core/AxiosHeaders.js';\nimport speedometer from '../helpers/speedometer.js';\n\nfunction progressEventReducer(listener, isDownloadStream) {\n let bytesNotified = 0;\n const _speedometer = speedometer(50, 250);\n\n return e => {\n const loaded = e.loaded;\n const total = e.lengthComputable ? e.total : undefined;\n const progressBytes = loaded - bytesNotified;\n const rate = _speedometer(progressBytes);\n const inRange = loaded <= total;\n\n bytesNotified = loaded;\n\n const data = {\n loaded,\n total,\n progress: total ? (loaded / total) : undefined,\n bytes: progressBytes,\n rate: rate ? rate : undefined,\n estimated: rate && total && inRange ? (total - loaded) / rate : undefined,\n event: e\n };\n\n data[isDownloadStream ? 'download' : 'upload'] = true;\n\n listener(data);\n };\n}\n\nconst isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';\n\nexport default isXHRAdapterSupported && function (config) {\n return new Promise(function dispatchXhrRequest(resolve, reject) {\n let requestData = config.data;\n const requestHeaders = AxiosHeaders.from(config.headers).normalize();\n let {responseType, withXSRFToken} = config;\n let onCanceled;\n function done() {\n if (config.cancelToken) {\n config.cancelToken.unsubscribe(onCanceled);\n }\n\n if (config.signal) {\n config.signal.removeEventListener('abort', onCanceled);\n }\n }\n\n let contentType;\n\n if (utils.isFormData(requestData)) {\n if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {\n requestHeaders.setContentType(false); // Let the browser set it\n } else if ((contentType = requestHeaders.getContentType()) !== false) {\n // fix semicolon duplication issue for ReactNative FormData implementation\n const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];\n requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));\n }\n }\n\n let request = new XMLHttpRequest();\n\n // HTTP basic authentication\n if (config.auth) {\n const username = config.auth.username || '';\n const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';\n requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));\n }\n\n const fullPath = buildFullPath(config.baseURL, config.url);\n\n request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);\n\n // Set the request timeout in MS\n request.timeout = config.timeout;\n\n function onloadend() {\n if (!request) {\n return;\n }\n // Prepare the response\n const responseHeaders = AxiosHeaders.from(\n 'getAllResponseHeaders' in request && request.getAllResponseHeaders()\n );\n const responseData = !responseType || responseType === 'text' || responseType === 'json' ?\n request.responseText : request.response;\n const response = {\n data: responseData,\n status: request.status,\n statusText: request.statusText,\n headers: responseHeaders,\n config,\n request\n };\n\n settle(function _resolve(value) {\n resolve(value);\n done();\n }, function _reject(err) {\n reject(err);\n done();\n }, response);\n\n // Clean up request\n request = null;\n }\n\n if ('onloadend' in request) {\n // Use onloadend if available\n request.onloadend = onloadend;\n } else {\n // Listen for ready state to emulate onloadend\n request.onreadystatechange = function handleLoad() {\n if (!request || request.readyState !== 4) {\n return;\n }\n\n // The request errored out and we didn't get a response, this will be\n // handled by onerror instead\n // With one exception: request that using file: protocol, most browsers\n // will return status as 0 even though it's a successful request\n if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n return;\n }\n // readystate handler is calling before onerror or ontimeout handlers,\n // so we should call onloadend on the next 'tick'\n setTimeout(onloadend);\n };\n }\n\n // Handle browser request cancellation (as opposed to a manual cancellation)\n request.onabort = function handleAbort() {\n if (!request) {\n return;\n }\n\n reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));\n\n // Clean up request\n request = null;\n };\n\n // Handle low level network errors\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));\n\n // Clean up request\n request = null;\n };\n\n // Handle timeout\n request.ontimeout = function handleTimeout() {\n let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';\n const transitional = config.transitional || transitionalDefaults;\n if (config.timeoutErrorMessage) {\n timeoutErrorMessage = config.timeoutErrorMessage;\n }\n reject(new AxiosError(\n timeoutErrorMessage,\n transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,\n config,\n request));\n\n // Clean up request\n request = null;\n };\n\n // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n if(platform.hasStandardBrowserEnv) {\n withXSRFToken && utils.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));\n\n if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {\n // Add xsrf header\n const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);\n\n if (xsrfValue) {\n requestHeaders.set(config.xsrfHeaderName, xsrfValue);\n }\n }\n }\n\n // Remove Content-Type if data is undefined\n requestData === undefined && requestHeaders.setContentType(null);\n\n // Add headers to the request\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {\n request.setRequestHeader(key, val);\n });\n }\n\n // Add withCredentials to request if needed\n if (!utils.isUndefined(config.withCredentials)) {\n request.withCredentials = !!config.withCredentials;\n }\n\n // Add responseType to request if needed\n if (responseType && responseType !== 'json') {\n request.responseType = config.responseType;\n }\n\n // Handle progress if needed\n if (typeof config.onDownloadProgress === 'function') {\n request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));\n }\n\n // Not all browsers support upload events\n if (typeof config.onUploadProgress === 'function' && request.upload) {\n request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));\n }\n\n if (config.cancelToken || config.signal) {\n // Handle cancellation\n // eslint-disable-next-line func-names\n onCanceled = cancel => {\n if (!request) {\n return;\n }\n reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);\n request.abort();\n request = null;\n };\n\n config.cancelToken && config.cancelToken.subscribe(onCanceled);\n if (config.signal) {\n config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);\n }\n }\n\n const protocol = parseProtocol(fullPath);\n\n if (protocol && platform.protocols.indexOf(protocol) === -1) {\n reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));\n return;\n }\n\n\n // Send the request\n request.send(requestData || null);\n });\n}\n","import utils from '../utils.js';\nimport httpAdapter from './http.js';\nimport xhrAdapter from './xhr.js';\nimport AxiosError from \"../core/AxiosError.js\";\n\nconst knownAdapters = {\n http: httpAdapter,\n xhr: xhrAdapter\n}\n\nutils.forEach(knownAdapters, (fn, value) => {\n if (fn) {\n try {\n Object.defineProperty(fn, 'name', {value});\n } catch (e) {\n // eslint-disable-next-line no-empty\n }\n Object.defineProperty(fn, 'adapterName', {value});\n }\n});\n\nconst renderReason = (reason) => `- ${reason}`;\n\nconst isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === false;\n\nexport default {\n getAdapter: (adapters) => {\n adapters = utils.isArray(adapters) ? adapters : [adapters];\n\n const {length} = adapters;\n let nameOrAdapter;\n let adapter;\n\n const rejectedReasons = {};\n\n for (let i = 0; i < length; i++) {\n nameOrAdapter = adapters[i];\n let id;\n\n adapter = nameOrAdapter;\n\n if (!isResolvedHandle(nameOrAdapter)) {\n adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];\n\n if (adapter === undefined) {\n throw new AxiosError(`Unknown adapter '${id}'`);\n }\n }\n\n if (adapter) {\n break;\n }\n\n rejectedReasons[id || '#' + i] = adapter;\n }\n\n if (!adapter) {\n\n const reasons = Object.entries(rejectedReasons)\n .map(([id, state]) => `adapter ${id} ` +\n (state === false ? 'is not supported by the environment' : 'is not available in the build')\n );\n\n let s = length ?\n (reasons.length > 1 ? 'since :\\n' + reasons.map(renderReason).join('\\n') : ' ' + renderReason(reasons[0])) :\n 'as no adapter specified';\n\n throw new AxiosError(\n `There is no suitable adapter to dispatch the request ` + s,\n 'ERR_NOT_SUPPORT'\n );\n }\n\n return adapter;\n },\n adapters: knownAdapters\n}\n","'use strict';\n\nimport transformData from './transformData.js';\nimport isCancel from '../cancel/isCancel.js';\nimport defaults from '../defaults/index.js';\nimport CanceledError from '../cancel/CanceledError.js';\nimport AxiosHeaders from '../core/AxiosHeaders.js';\nimport adapters from \"../adapters/adapters.js\";\n\n/**\n * Throws a `CanceledError` if cancellation has been requested.\n *\n * @param {Object} config The config that is to be used for the request\n *\n * @returns {void}\n */\nfunction throwIfCancellationRequested(config) {\n if (config.cancelToken) {\n config.cancelToken.throwIfRequested();\n }\n\n if (config.signal && config.signal.aborted) {\n throw new CanceledError(null, config);\n }\n}\n\n/**\n * Dispatch a request to the server using the configured adapter.\n *\n * @param {object} config The config that is to be used for the request\n *\n * @returns {Promise} The Promise to be fulfilled\n */\nexport default function dispatchRequest(config) {\n throwIfCancellationRequested(config);\n\n config.headers = AxiosHeaders.from(config.headers);\n\n // Transform request data\n config.data = transformData.call(\n config,\n config.transformRequest\n );\n\n if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {\n config.headers.setContentType('application/x-www-form-urlencoded', false);\n }\n\n const adapter = adapters.getAdapter(config.adapter || defaults.adapter);\n\n return adapter(config).then(function onAdapterResolution(response) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n response.data = transformData.call(\n config,\n config.transformResponse,\n response\n );\n\n response.headers = AxiosHeaders.from(response.headers);\n\n return response;\n }, function onAdapterRejection(reason) {\n if (!isCancel(reason)) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n if (reason && reason.response) {\n reason.response.data = transformData.call(\n config,\n config.transformResponse,\n reason.response\n );\n reason.response.headers = AxiosHeaders.from(reason.response.headers);\n }\n }\n\n return Promise.reject(reason);\n });\n}\n","'use strict';\n\nimport utils from '../utils.js';\nimport AxiosHeaders from \"./AxiosHeaders.js\";\n\nconst headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;\n\n/**\n * Config-specific merge-function which creates a new config-object\n * by merging two configuration objects together.\n *\n * @param {Object} config1\n * @param {Object} config2\n *\n * @returns {Object} New object resulting from merging config2 to config1\n */\nexport default function mergeConfig(config1, config2) {\n // eslint-disable-next-line no-param-reassign\n config2 = config2 || {};\n const config = {};\n\n function getMergedValue(target, source, caseless) {\n if (utils.isPlainObject(target) && utils.isPlainObject(source)) {\n return utils.merge.call({caseless}, target, source);\n } else if (utils.isPlainObject(source)) {\n return utils.merge({}, source);\n } else if (utils.isArray(source)) {\n return source.slice();\n }\n return source;\n }\n\n // eslint-disable-next-line consistent-return\n function mergeDeepProperties(a, b, caseless) {\n if (!utils.isUndefined(b)) {\n return getMergedValue(a, b, caseless);\n } else if (!utils.isUndefined(a)) {\n return getMergedValue(undefined, a, caseless);\n }\n }\n\n // eslint-disable-next-line consistent-return\n function valueFromConfig2(a, b) {\n if (!utils.isUndefined(b)) {\n return getMergedValue(undefined, b);\n }\n }\n\n // eslint-disable-next-line consistent-return\n function defaultToConfig2(a, b) {\n if (!utils.isUndefined(b)) {\n return getMergedValue(undefined, b);\n } else if (!utils.isUndefined(a)) {\n return getMergedValue(undefined, a);\n }\n }\n\n // eslint-disable-next-line consistent-return\n function mergeDirectKeys(a, b, prop) {\n if (prop in config2) {\n return getMergedValue(a, b);\n } else if (prop in config1) {\n return getMergedValue(undefined, a);\n }\n }\n\n const mergeMap = {\n url: valueFromConfig2,\n method: valueFromConfig2,\n data: valueFromConfig2,\n baseURL: defaultToConfig2,\n transformRequest: defaultToConfig2,\n transformResponse: defaultToConfig2,\n paramsSerializer: defaultToConfig2,\n timeout: defaultToConfig2,\n timeoutMessage: defaultToConfig2,\n withCredentials: defaultToConfig2,\n withXSRFToken: defaultToConfig2,\n adapter: defaultToConfig2,\n responseType: defaultToConfig2,\n xsrfCookieName: defaultToConfig2,\n xsrfHeaderName: defaultToConfig2,\n onUploadProgress: defaultToConfig2,\n onDownloadProgress: defaultToConfig2,\n decompress: defaultToConfig2,\n maxContentLength: defaultToConfig2,\n maxBodyLength: defaultToConfig2,\n beforeRedirect: defaultToConfig2,\n transport: defaultToConfig2,\n httpAgent: defaultToConfig2,\n httpsAgent: defaultToConfig2,\n cancelToken: defaultToConfig2,\n socketPath: defaultToConfig2,\n responseEncoding: defaultToConfig2,\n validateStatus: mergeDirectKeys,\n headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)\n };\n\n utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {\n const merge = mergeMap[prop] || mergeDeepProperties;\n const configValue = merge(config1[prop], config2[prop], prop);\n (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);\n });\n\n return config;\n}\n","export const VERSION = \"1.6.8\";","'use strict';\n\nimport {VERSION} from '../env/data.js';\nimport AxiosError from '../core/AxiosError.js';\n\nconst validators = {};\n\n// eslint-disable-next-line func-names\n['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {\n validators[type] = function validator(thing) {\n return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;\n };\n});\n\nconst deprecatedWarnings = {};\n\n/**\n * Transitional option validator\n *\n * @param {function|boolean?} validator - set to false if the transitional option has been removed\n * @param {string?} version - deprecated version / removed since version\n * @param {string?} message - some message with additional info\n *\n * @returns {function}\n */\nvalidators.transitional = function transitional(validator, version, message) {\n function formatMessage(opt, desc) {\n return '[Axios v' + VERSION + '] Transitional option \\'' + opt + '\\'' + desc + (message ? '. ' + message : '');\n }\n\n // eslint-disable-next-line func-names\n return (value, opt, opts) => {\n if (validator === false) {\n throw new AxiosError(\n formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),\n AxiosError.ERR_DEPRECATED\n );\n }\n\n if (version && !deprecatedWarnings[opt]) {\n deprecatedWarnings[opt] = true;\n // eslint-disable-next-line no-console\n console.warn(\n formatMessage(\n opt,\n ' has been deprecated since v' + version + ' and will be removed in the near future'\n )\n );\n }\n\n return validator ? validator(value, opt, opts) : true;\n };\n};\n\n/**\n * Assert object's properties type\n *\n * @param {object} options\n * @param {object} schema\n * @param {boolean?} allowUnknown\n *\n * @returns {object}\n */\n\nfunction assertOptions(options, schema, allowUnknown) {\n if (typeof options !== 'object') {\n throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);\n }\n const keys = Object.keys(options);\n let i = keys.length;\n while (i-- > 0) {\n const opt = keys[i];\n const validator = schema[opt];\n if (validator) {\n const value = options[opt];\n const result = value === undefined || validator(value, opt, options);\n if (result !== true) {\n throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);\n }\n continue;\n }\n if (allowUnknown !== true) {\n throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);\n }\n }\n}\n\nexport default {\n assertOptions,\n validators\n};\n","'use strict';\n\nimport utils from './../utils.js';\nimport buildURL from '../helpers/buildURL.js';\nimport InterceptorManager from './InterceptorManager.js';\nimport dispatchRequest from './dispatchRequest.js';\nimport mergeConfig from './mergeConfig.js';\nimport buildFullPath from './buildFullPath.js';\nimport validator from '../helpers/validator.js';\nimport AxiosHeaders from './AxiosHeaders.js';\n\nconst validators = validator.validators;\n\n/**\n * Create a new instance of Axios\n *\n * @param {Object} instanceConfig The default config for the instance\n *\n * @return {Axios} A new instance of Axios\n */\nclass Axios {\n constructor(instanceConfig) {\n this.defaults = instanceConfig;\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n }\n\n /**\n * Dispatch a request\n *\n * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)\n * @param {?Object} config\n *\n * @returns {Promise} The Promise to be fulfilled\n */\n async request(configOrUrl, config) {\n try {\n return await this._request(configOrUrl, config);\n } catch (err) {\n if (err instanceof Error) {\n let dummy;\n\n Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());\n\n // slice off the Error: ... line\n const stack = dummy.stack ? dummy.stack.replace(/^.+\\n/, '') : '';\n\n if (!err.stack) {\n err.stack = stack;\n // match without the 2 top stack lines\n } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\\n.+\\n/, ''))) {\n err.stack += '\\n' + stack\n }\n }\n\n throw err;\n }\n }\n\n _request(configOrUrl, config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof configOrUrl === 'string') {\n config = config || {};\n config.url = configOrUrl;\n } else {\n config = configOrUrl || {};\n }\n\n config = mergeConfig(this.defaults, config);\n\n const {transitional, paramsSerializer, headers} = config;\n\n if (transitional !== undefined) {\n validator.assertOptions(transitional, {\n silentJSONParsing: validators.transitional(validators.boolean),\n forcedJSONParsing: validators.transitional(validators.boolean),\n clarifyTimeoutError: validators.transitional(validators.boolean)\n }, false);\n }\n\n if (paramsSerializer != null) {\n if (utils.isFunction(paramsSerializer)) {\n config.paramsSerializer = {\n serialize: paramsSerializer\n }\n } else {\n validator.assertOptions(paramsSerializer, {\n encode: validators.function,\n serialize: validators.function\n }, true);\n }\n }\n\n // Set config.method\n config.method = (config.method || this.defaults.method || 'get').toLowerCase();\n\n // Flatten headers\n let contextHeaders = headers && utils.merge(\n headers.common,\n headers[config.method]\n );\n\n headers && utils.forEach(\n ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n (method) => {\n delete headers[method];\n }\n );\n\n config.headers = AxiosHeaders.concat(contextHeaders, headers);\n\n // filter out skipped interceptors\n const requestInterceptorChain = [];\n let synchronousRequestInterceptors = true;\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {\n return;\n }\n\n synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;\n\n requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n\n const responseInterceptorChain = [];\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n let promise;\n let i = 0;\n let len;\n\n if (!synchronousRequestInterceptors) {\n const chain = [dispatchRequest.bind(this), undefined];\n chain.unshift.apply(chain, requestInterceptorChain);\n chain.push.apply(chain, responseInterceptorChain);\n len = chain.length;\n\n promise = Promise.resolve(config);\n\n while (i < len) {\n promise = promise.then(chain[i++], chain[i++]);\n }\n\n return promise;\n }\n\n len = requestInterceptorChain.length;\n\n let newConfig = config;\n\n i = 0;\n\n while (i < len) {\n const onFulfilled = requestInterceptorChain[i++];\n const onRejected = requestInterceptorChain[i++];\n try {\n newConfig = onFulfilled(newConfig);\n } catch (error) {\n onRejected.call(this, error);\n break;\n }\n }\n\n try {\n promise = dispatchRequest.call(this, newConfig);\n } catch (error) {\n return Promise.reject(error);\n }\n\n i = 0;\n len = responseInterceptorChain.length;\n\n while (i < len) {\n promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);\n }\n\n return promise;\n }\n\n getUri(config) {\n config = mergeConfig(this.defaults, config);\n const fullPath = buildFullPath(config.baseURL, config.url);\n return buildURL(fullPath, config.params, config.paramsSerializer);\n }\n}\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, config) {\n return this.request(mergeConfig(config || {}, {\n method,\n url,\n data: (config || {}).data\n }));\n };\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n\n function generateHTTPMethod(isForm) {\n return function httpMethod(url, data, config) {\n return this.request(mergeConfig(config || {}, {\n method,\n headers: isForm ? {\n 'Content-Type': 'multipart/form-data'\n } : {},\n url,\n data\n }));\n };\n }\n\n Axios.prototype[method] = generateHTTPMethod();\n\n Axios.prototype[method + 'Form'] = generateHTTPMethod(true);\n});\n\nexport default Axios;\n","'use strict';\n\nimport CanceledError from './CanceledError.js';\n\n/**\n * A `CancelToken` is an object that can be used to request cancellation of an operation.\n *\n * @param {Function} executor The executor function.\n *\n * @returns {CancelToken}\n */\nclass CancelToken {\n constructor(executor) {\n if (typeof executor !== 'function') {\n throw new TypeError('executor must be a function.');\n }\n\n let resolvePromise;\n\n this.promise = new Promise(function promiseExecutor(resolve) {\n resolvePromise = resolve;\n });\n\n const token = this;\n\n // eslint-disable-next-line func-names\n this.promise.then(cancel => {\n if (!token._listeners) return;\n\n let i = token._listeners.length;\n\n while (i-- > 0) {\n token._listeners[i](cancel);\n }\n token._listeners = null;\n });\n\n // eslint-disable-next-line func-names\n this.promise.then = onfulfilled => {\n let _resolve;\n // eslint-disable-next-line func-names\n const promise = new Promise(resolve => {\n token.subscribe(resolve);\n _resolve = resolve;\n }).then(onfulfilled);\n\n promise.cancel = function reject() {\n token.unsubscribe(_resolve);\n };\n\n return promise;\n };\n\n executor(function cancel(message, config, request) {\n if (token.reason) {\n // Cancellation has already been requested\n return;\n }\n\n token.reason = new CanceledError(message, config, request);\n resolvePromise(token.reason);\n });\n }\n\n /**\n * Throws a `CanceledError` if cancellation has been requested.\n */\n throwIfRequested() {\n if (this.reason) {\n throw this.reason;\n }\n }\n\n /**\n * Subscribe to the cancel signal\n */\n\n subscribe(listener) {\n if (this.reason) {\n listener(this.reason);\n return;\n }\n\n if (this._listeners) {\n this._listeners.push(listener);\n } else {\n this._listeners = [listener];\n }\n }\n\n /**\n * Unsubscribe from the cancel signal\n */\n\n unsubscribe(listener) {\n if (!this._listeners) {\n return;\n }\n const index = this._listeners.indexOf(listener);\n if (index !== -1) {\n this._listeners.splice(index, 1);\n }\n }\n\n /**\n * Returns an object that contains a new `CancelToken` and a function that, when called,\n * cancels the `CancelToken`.\n */\n static source() {\n let cancel;\n const token = new CancelToken(function executor(c) {\n cancel = c;\n });\n return {\n token,\n cancel\n };\n }\n}\n\nexport default CancelToken;\n","'use strict';\n\n/**\n * Syntactic sugar for invoking a function and expanding an array for arguments.\n *\n * Common use case would be to use `Function.prototype.apply`.\n *\n * ```js\n * function f(x, y, z) {}\n * var args = [1, 2, 3];\n * f.apply(null, args);\n * ```\n *\n * With `spread` this example can be re-written.\n *\n * ```js\n * spread(function(x, y, z) {})([1, 2, 3]);\n * ```\n *\n * @param {Function} callback\n *\n * @returns {Function}\n */\nexport default function spread(callback) {\n return function wrap(arr) {\n return callback.apply(null, arr);\n };\n}\n","'use strict';\n\nimport utils from './../utils.js';\n\n/**\n * Determines whether the payload is an error thrown by Axios\n *\n * @param {*} payload The value to test\n *\n * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false\n */\nexport default function isAxiosError(payload) {\n return utils.isObject(payload) && (payload.isAxiosError === true);\n}\n","const HttpStatusCode = {\n Continue: 100,\n SwitchingProtocols: 101,\n Processing: 102,\n EarlyHints: 103,\n Ok: 200,\n Created: 201,\n Accepted: 202,\n NonAuthoritativeInformation: 203,\n NoContent: 204,\n ResetContent: 205,\n PartialContent: 206,\n MultiStatus: 207,\n AlreadyReported: 208,\n ImUsed: 226,\n MultipleChoices: 300,\n MovedPermanently: 301,\n Found: 302,\n SeeOther: 303,\n NotModified: 304,\n UseProxy: 305,\n Unused: 306,\n TemporaryRedirect: 307,\n PermanentRedirect: 308,\n BadRequest: 400,\n Unauthorized: 401,\n PaymentRequired: 402,\n Forbidden: 403,\n NotFound: 404,\n MethodNotAllowed: 405,\n NotAcceptable: 406,\n ProxyAuthenticationRequired: 407,\n RequestTimeout: 408,\n Conflict: 409,\n Gone: 410,\n LengthRequired: 411,\n PreconditionFailed: 412,\n PayloadTooLarge: 413,\n UriTooLong: 414,\n UnsupportedMediaType: 415,\n RangeNotSatisfiable: 416,\n ExpectationFailed: 417,\n ImATeapot: 418,\n MisdirectedRequest: 421,\n UnprocessableEntity: 422,\n Locked: 423,\n FailedDependency: 424,\n TooEarly: 425,\n UpgradeRequired: 426,\n PreconditionRequired: 428,\n TooManyRequests: 429,\n RequestHeaderFieldsTooLarge: 431,\n UnavailableForLegalReasons: 451,\n InternalServerError: 500,\n NotImplemented: 501,\n BadGateway: 502,\n ServiceUnavailable: 503,\n GatewayTimeout: 504,\n HttpVersionNotSupported: 505,\n VariantAlsoNegotiates: 506,\n InsufficientStorage: 507,\n LoopDetected: 508,\n NotExtended: 510,\n NetworkAuthenticationRequired: 511,\n};\n\nObject.entries(HttpStatusCode).forEach(([key, value]) => {\n HttpStatusCode[value] = key;\n});\n\nexport default HttpStatusCode;\n","'use strict';\n\nimport utils from './utils.js';\nimport bind from './helpers/bind.js';\nimport Axios from './core/Axios.js';\nimport mergeConfig from './core/mergeConfig.js';\nimport defaults from './defaults/index.js';\nimport formDataToJSON from './helpers/formDataToJSON.js';\nimport CanceledError from './cancel/CanceledError.js';\nimport CancelToken from './cancel/CancelToken.js';\nimport isCancel from './cancel/isCancel.js';\nimport {VERSION} from './env/data.js';\nimport toFormData from './helpers/toFormData.js';\nimport AxiosError from './core/AxiosError.js';\nimport spread from './helpers/spread.js';\nimport isAxiosError from './helpers/isAxiosError.js';\nimport AxiosHeaders from \"./core/AxiosHeaders.js\";\nimport adapters from './adapters/adapters.js';\nimport HttpStatusCode from './helpers/HttpStatusCode.js';\n\n/**\n * Create an instance of Axios\n *\n * @param {Object} defaultConfig The default config for the instance\n *\n * @returns {Axios} A new instance of Axios\n */\nfunction createInstance(defaultConfig) {\n const context = new Axios(defaultConfig);\n const instance = bind(Axios.prototype.request, context);\n\n // Copy axios.prototype to instance\n utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});\n\n // Copy context to instance\n utils.extend(instance, context, null, {allOwnKeys: true});\n\n // Factory for creating new instances\n instance.create = function create(instanceConfig) {\n return createInstance(mergeConfig(defaultConfig, instanceConfig));\n };\n\n return instance;\n}\n\n// Create the default instance to be exported\nconst axios = createInstance(defaults);\n\n// Expose Axios class to allow class inheritance\naxios.Axios = Axios;\n\n// Expose Cancel & CancelToken\naxios.CanceledError = CanceledError;\naxios.CancelToken = CancelToken;\naxios.isCancel = isCancel;\naxios.VERSION = VERSION;\naxios.toFormData = toFormData;\n\n// Expose AxiosError class\naxios.AxiosError = AxiosError;\n\n// alias for CanceledError for backward compatibility\naxios.Cancel = axios.CanceledError;\n\n// Expose all/spread\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\n\naxios.spread = spread;\n\n// Expose isAxiosError\naxios.isAxiosError = isAxiosError;\n\n// Expose mergeConfig\naxios.mergeConfig = mergeConfig;\n\naxios.AxiosHeaders = AxiosHeaders;\n\naxios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);\n\naxios.getAdapter = adapters.getAdapter;\n\naxios.HttpStatusCode = HttpStatusCode;\n\naxios.default = axios;\n\n// this module should only have a default export\nexport default axios\n","'use strict';\nmodule.exports = {};\n","'use strict';\nmodule.exports = function (exec) {\n try {\n return !!exec();\n } catch (error) {\n return true;\n }\n};\n","'use strict';\nvar global = require('../internals/global');\nvar isCallable = require('../internals/is-callable');\n\nvar aFunction = function (argument) {\n return isCallable(argument) ? argument : undefined;\n};\n\nmodule.exports = function (namespace, method) {\n return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method];\n};\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nvar _bindEvents = require('../utils/bindEvents.js');\n\nvar _bindEvents2 = _interopRequireDefault(_bindEvents);\n\nvar _bindProps = require('../utils/bindProps.js');\n\nvar _mountableMixin = require('../utils/mountableMixin.js');\n\nvar _mountableMixin2 = _interopRequireDefault(_mountableMixin);\n\nvar _TwoWayBindingWrapper = require('../utils/TwoWayBindingWrapper.js');\n\nvar _TwoWayBindingWrapper2 = _interopRequireDefault(_TwoWayBindingWrapper);\n\nvar _WatchPrimitiveProperties = require('../utils/WatchPrimitiveProperties.js');\n\nvar _WatchPrimitiveProperties2 = _interopRequireDefault(_WatchPrimitiveProperties);\n\nvar _mapElementFactory = require('./mapElementFactory.js');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar props = {\n center: {\n required: true,\n twoWay: true,\n type: Object,\n noBind: true\n },\n zoom: {\n required: false,\n twoWay: true,\n type: Number,\n noBind: true\n },\n heading: {\n type: Number,\n twoWay: true\n },\n mapTypeId: {\n twoWay: true,\n type: String\n },\n tilt: {\n twoWay: true,\n type: Number\n },\n options: {\n type: Object,\n default: function _default() {\n return {};\n }\n }\n};\n\nvar events = ['bounds_changed', 'click', 'dblclick', 'drag', 'dragend', 'dragstart', 'idle', 'mousemove', 'mouseout', 'mouseover', 'resize', 'rightclick', 'tilesloaded'];\n\n// Plain Google Maps methods exposed here for convenience\nvar linkedMethods = ['panBy', 'panTo', 'panToBounds', 'fitBounds'].reduce(function (all, methodName) {\n all[methodName] = function () {\n if (this.$mapObject) {\n this.$mapObject[methodName].apply(this.$mapObject, arguments);\n }\n };\n return all;\n}, {});\n\n// Other convenience methods exposed by Vue Google Maps\nvar customMethods = {\n resize: function resize() {\n if (this.$mapObject) {\n google.maps.event.trigger(this.$mapObject, 'resize');\n }\n },\n resizePreserveCenter: function resizePreserveCenter() {\n if (!this.$mapObject) {\n return;\n }\n\n var oldCenter = this.$mapObject.getCenter();\n google.maps.event.trigger(this.$mapObject, 'resize');\n this.$mapObject.setCenter(oldCenter);\n },\n\n\n /// Override mountableMixin::_resizeCallback\n /// because resizePreserveCenter is usually the\n /// expected behaviour\n _resizeCallback: function _resizeCallback() {\n this.resizePreserveCenter();\n }\n};\n\nexports.default = {\n mixins: [_mountableMixin2.default],\n props: (0, _mapElementFactory.mappedPropsToVueProps)(props),\n\n provide: function provide() {\n var _this = this;\n\n this.$mapPromise = new Promise(function (resolve, reject) {\n _this.$mapPromiseDeferred = { resolve: resolve, reject: reject };\n });\n return {\n '$mapPromise': this.$mapPromise\n };\n },\n\n\n computed: {\n finalLat: function finalLat() {\n return this.center && typeof this.center.lat === 'function' ? this.center.lat() : this.center.lat;\n },\n finalLng: function finalLng() {\n return this.center && typeof this.center.lng === 'function' ? this.center.lng() : this.center.lng;\n },\n finalLatLng: function finalLatLng() {\n return { lat: this.finalLat, lng: this.finalLng };\n }\n },\n\n watch: {\n zoom: function zoom(_zoom) {\n if (this.$mapObject) {\n this.$mapObject.setZoom(_zoom);\n }\n }\n },\n\n mounted: function mounted() {\n var _this2 = this;\n\n return this.$gmapApiPromiseLazy().then(function () {\n // getting the DOM element where to create the map\n var element = _this2.$refs['vue-map'];\n\n // creating the map\n var options = _extends({}, _this2.options, (0, _bindProps.getPropsValues)(_this2, props));\n delete options.options;\n _this2.$mapObject = new google.maps.Map(element, options);\n\n // binding properties (two and one way)\n (0, _bindProps.bindProps)(_this2, _this2.$mapObject, props);\n // binding events\n (0, _bindEvents2.default)(_this2, _this2.$mapObject, events);\n\n // manually trigger center and zoom\n (0, _TwoWayBindingWrapper2.default)(function (increment, decrement, shouldUpdate) {\n _this2.$mapObject.addListener('center_changed', function () {\n if (shouldUpdate()) {\n _this2.$emit('center_changed', _this2.$mapObject.getCenter());\n }\n decrement();\n });\n\n (0, _WatchPrimitiveProperties2.default)(_this2, ['finalLat', 'finalLng'], function updateCenter() {\n increment();\n _this2.$mapObject.setCenter(_this2.finalLatLng);\n });\n });\n _this2.$mapObject.addListener('zoom_changed', function () {\n _this2.$emit('zoom_changed', _this2.$mapObject.getZoom());\n });\n _this2.$mapObject.addListener('bounds_changed', function () {\n _this2.$emit('bounds_changed', _this2.$mapObject.getBounds());\n });\n\n _this2.$mapPromiseDeferred.resolve(_this2.$mapObject);\n\n return _this2.$mapObject;\n }).catch(function (error) {\n throw error;\n });\n },\n\n methods: _extends({}, customMethods, linkedMethods)\n};","/** Used to compose unicode character classes. */\nvar rsAstralRange = '\\\\ud800-\\\\udfff',\n rsComboMarksRange = '\\\\u0300-\\\\u036f',\n reComboHalfMarksRange = '\\\\ufe20-\\\\ufe2f',\n rsComboSymbolsRange = '\\\\u20d0-\\\\u20ff',\n rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,\n rsVarRange = '\\\\ufe0e\\\\ufe0f';\n\n/** Used to compose unicode capture groups. */\nvar rsAstral = '[' + rsAstralRange + ']',\n rsCombo = '[' + rsComboRange + ']',\n rsFitz = '\\\\ud83c[\\\\udffb-\\\\udfff]',\n rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',\n rsNonAstral = '[^' + rsAstralRange + ']',\n rsRegional = '(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}',\n rsSurrPair = '[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]',\n rsZWJ = '\\\\u200d';\n\n/** Used to compose unicode regexes. */\nvar reOptMod = rsModifier + '?',\n rsOptVar = '[' + rsVarRange + ']?',\n rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',\n rsSeq = rsOptVar + reOptMod + rsOptJoin,\n rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';\n\n/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */\nvar reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');\n\n/**\n * Converts a Unicode `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\nfunction unicodeToArray(string) {\n return string.match(reUnicode) || [];\n}\n\nmodule.exports = unicodeToArray;\n","export * from \"-!../../../mini-css-extract-plugin/dist/loader.js??ref--7-oneOf-1-0!../../../css-loader/dist/cjs.js??ref--7-oneOf-1-1!../../../vue-loader/lib/loaders/stylePostLoader.js!../../../postcss-loader/src/index.js??ref--7-oneOf-1-2!../../../cache-loader/dist/cjs.js??ref--1-0!../../../vue-loader/lib/index.js??vue-loader-options!./streetViewPanorama.vue?vue&type=style&index=0&id=50f7f8d6&prod&lang=css\"","var castSlice = require('./_castSlice'),\n hasUnicode = require('./_hasUnicode'),\n stringToArray = require('./_stringToArray'),\n toString = require('./toString');\n\n/**\n * Creates a function like `_.lowerFirst`.\n *\n * @private\n * @param {string} methodName The name of the `String` case method to use.\n * @returns {Function} Returns the new case function.\n */\nfunction createCaseFirst(methodName) {\n return function(string) {\n string = toString(string);\n\n var strSymbols = hasUnicode(string)\n ? stringToArray(string)\n : undefined;\n\n var chr = strSymbols\n ? strSymbols[0]\n : string.charAt(0);\n\n var trailing = strSymbols\n ? castSlice(strSymbols, 1).join('')\n : string.slice(1);\n\n return chr[methodName]() + trailing;\n };\n}\n\nmodule.exports = createCaseFirst;\n","'use strict';\nvar $propertyIsEnumerable = {}.propertyIsEnumerable;\n// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\n\n// Nashorn ~ JDK8 bug\nvar NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);\n\n// `Object.prototype.propertyIsEnumerable` method implementation\n// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable\nexports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {\n var descriptor = getOwnPropertyDescriptor(this, V);\n return !!descriptor && descriptor.enumerable;\n} : $propertyIsEnumerable;\n","'use strict';\n/* eslint-disable no-proto -- safe */\nvar uncurryThisAccessor = require('../internals/function-uncurry-this-accessor');\nvar isObject = require('../internals/is-object');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\nvar aPossiblePrototype = require('../internals/a-possible-prototype');\n\n// `Object.setPrototypeOf` method\n// https://tc39.es/ecma262/#sec-object.setprototypeof\n// Works with __proto__ only. Old v8 can't work with null proto objects.\n// eslint-disable-next-line es/no-object-setprototypeof -- safe\nmodule.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {\n var CORRECT_SETTER = false;\n var test = {};\n var setter;\n try {\n setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');\n setter(test, []);\n CORRECT_SETTER = test instanceof Array;\n } catch (error) { /* empty */ }\n return function setPrototypeOf(O, proto) {\n requireObjectCoercible(O);\n aPossiblePrototype(proto);\n if (!isObject(O)) return O;\n if (CORRECT_SETTER) setter(O, proto);\n else O.__proto__ = proto;\n return O;\n };\n}() : undefined);\n","'use strict';\nvar TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');\nvar defineBuiltIn = require('../internals/define-built-in');\nvar toString = require('../internals/object-to-string');\n\n// `Object.prototype.toString` method\n// https://tc39.es/ecma262/#sec-object.prototype.tostring\nif (!TO_STRING_TAG_SUPPORT) {\n defineBuiltIn(Object.prototype, 'toString', toString, { unsafe: true });\n}\n","'use strict';\nvar defineProperty = require('../internals/object-define-property').f;\nvar hasOwn = require('../internals/has-own-property');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\n\nmodule.exports = function (target, TAG, STATIC) {\n if (target && !STATIC) target = target.prototype;\n if (target && !hasOwn(target, TO_STRING_TAG)) {\n defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });\n }\n};\n","\"use strict\";\nexports.__esModule = true;\nvar utils_1 = require(\"./utils\");\nfunction default_1(value, replacement) {\n if (!utils_1.isExists(value)) {\n return '';\n }\n return value.replace(new RegExp(value, 'g'), replacement);\n}\nexports[\"default\"] = default_1;\n","\"use strict\";\nexports.__esModule = true;\nvar utils_1 = require(\"./utils\");\nfunction default_1(value) {\n if (!utils_1.isExists(value)) {\n return '';\n }\n return value.charAt(0).toUpperCase() + value.slice(1);\n}\nexports[\"default\"] = default_1;\n","'use strict';\nvar aCallable = require('../internals/a-callable');\nvar toObject = require('../internals/to-object');\nvar IndexedObject = require('../internals/indexed-object');\nvar lengthOfArrayLike = require('../internals/length-of-array-like');\n\nvar $TypeError = TypeError;\n\nvar REDUCE_EMPTY = 'Reduce of empty array with no initial value';\n\n// `Array.prototype.{ reduce, reduceRight }` methods implementation\nvar createMethod = function (IS_RIGHT) {\n return function (that, callbackfn, argumentsLength, memo) {\n var O = toObject(that);\n var self = IndexedObject(O);\n var length = lengthOfArrayLike(O);\n aCallable(callbackfn);\n if (length === 0 && argumentsLength < 2) throw new $TypeError(REDUCE_EMPTY);\n var index = IS_RIGHT ? length - 1 : 0;\n var i = IS_RIGHT ? -1 : 1;\n if (argumentsLength < 2) while (true) {\n if (index in self) {\n memo = self[index];\n index += i;\n break;\n }\n index += i;\n if (IS_RIGHT ? index < 0 : length <= index) {\n throw new $TypeError(REDUCE_EMPTY);\n }\n }\n for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {\n memo = callbackfn(memo, self[index], index, O);\n }\n return memo;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.reduce` method\n // https://tc39.es/ecma262/#sec-array.prototype.reduce\n left: createMethod(false),\n // `Array.prototype.reduceRight` method\n // https://tc39.es/ecma262/#sec-array.prototype.reduceright\n right: createMethod(true)\n};\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _mapElementFactory = require('./mapElementFactory.js');\n\nvar _mapElementFactory2 = _interopRequireDefault(_mapElementFactory);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar props = {\n bounds: {\n type: Object,\n twoWay: true\n },\n draggable: {\n type: Boolean,\n default: false\n },\n editable: {\n type: Boolean,\n default: false\n },\n options: {\n type: Object,\n twoWay: false\n }\n};\n\nvar events = ['click', 'dblclick', 'drag', 'dragend', 'dragstart', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];\n\nexports.default = (0, _mapElementFactory2.default)({\n mappedProps: props,\n name: 'rectangle',\n ctr: function ctr() {\n return google.maps.Rectangle;\n },\n events: events\n});","'use strict';\n// TODO: Remove from `core-js@4` since it's moved to entry points\nrequire('../modules/es.regexp.exec');\nvar call = require('../internals/function-call');\nvar defineBuiltIn = require('../internals/define-built-in');\nvar regexpExec = require('../internals/regexp-exec');\nvar fails = require('../internals/fails');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\n\nvar SPECIES = wellKnownSymbol('species');\nvar RegExpPrototype = RegExp.prototype;\n\nmodule.exports = function (KEY, exec, FORCED, SHAM) {\n var SYMBOL = wellKnownSymbol(KEY);\n\n var DELEGATES_TO_SYMBOL = !fails(function () {\n // String methods call symbol-named RegExp methods\n var O = {};\n O[SYMBOL] = function () { return 7; };\n return ''[KEY](O) !== 7;\n });\n\n var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {\n // Symbol-named RegExp methods call .exec\n var execCalled = false;\n var re = /a/;\n\n if (KEY === 'split') {\n // We can't use real regex here since it causes deoptimization\n // and serious performance degradation in V8\n // https://github.com/zloirock/core-js/issues/306\n re = {};\n // RegExp[@@split] doesn't call the regex's exec method, but first creates\n // a new one. We need to return the patched regex when creating the new one.\n re.constructor = {};\n re.constructor[SPECIES] = function () { return re; };\n re.flags = '';\n re[SYMBOL] = /./[SYMBOL];\n }\n\n re.exec = function () {\n execCalled = true;\n return null;\n };\n\n re[SYMBOL]('');\n return !execCalled;\n });\n\n if (\n !DELEGATES_TO_SYMBOL ||\n !DELEGATES_TO_EXEC ||\n FORCED\n ) {\n var nativeRegExpMethod = /./[SYMBOL];\n var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {\n var $exec = regexp.exec;\n if ($exec === regexpExec || $exec === RegExpPrototype.exec) {\n if (DELEGATES_TO_SYMBOL && !forceStringMethod) {\n // The native String method already delegates to @@method (this\n // polyfilled function), leasing to infinite recursion.\n // We avoid it by directly calling the native @@method method.\n return { done: true, value: call(nativeRegExpMethod, regexp, str, arg2) };\n }\n return { done: true, value: call(nativeMethod, str, regexp, arg2) };\n }\n return { done: false };\n });\n\n defineBuiltIn(String.prototype, KEY, methods[0]);\n defineBuiltIn(RegExpPrototype, SYMBOL, methods[1]);\n }\n\n if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);\n};\n","'use strict';\n// FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it\nvar fails = require('../internals/fails');\n\nmodule.exports = fails(function () {\n if (typeof ArrayBuffer == 'function') {\n var buffer = new ArrayBuffer(8);\n // eslint-disable-next-line es/no-object-isextensible, es/no-object-defineproperty -- safe\n if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', { value: 8 });\n }\n});\n","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"VueDraggable\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"VueDraggable\"] = factory();\n\telse\n\t\troot[\"VueDraggable\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// define __esModule on exports\n/******/ \t__webpack_require__.r = function(exports) {\n/******/ \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n/******/ \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t}\n/******/ \t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t};\n/******/\n/******/ \t// create a fake namespace object\n/******/ \t// mode & 1: value is a module id, require it\n/******/ \t// mode & 2: merge all properties of value into the ns\n/******/ \t// mode & 4: return value when already ns object\n/******/ \t// mode & 8|1: behave like require\n/******/ \t__webpack_require__.t = function(value, mode) {\n/******/ \t\tif(mode & 1) value = __webpack_require__(value);\n/******/ \t\tif(mode & 8) return value;\n/******/ \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n/******/ \t\tvar ns = Object.create(null);\n/******/ \t\t__webpack_require__.r(ns);\n/******/ \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n/******/ \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n/******/ \t\treturn ns;\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = \"./src/index.js\");\n/******/ })\n/************************************************************************/\n/******/ ({\n\n/***/ \"./src/components/vue-draggable-group.component.js\":\n/*!*********************************************************!*\\\n !*** ./src/components/vue-draggable-group.component.js ***!\n \\*********************************************************/\n/*! exports provided: VueDraggableGroup */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"VueDraggableGroup\", function() { return VueDraggableGroup; });\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nvar CUSTOM_EVENTS = ['added', 'removed', 'reordered'];\nvar VueDraggableGroup = {\n name: 'VueDraggableGroup',\n props: {\n groups: {\n required: true,\n type: Array\n },\n value: {\n required: true,\n type: Array\n },\n itemsKey: {\n type: String,\n \"default\": 'items'\n }\n },\n render: function render() {\n return this.$scopedSlots[\"default\"]({});\n },\n methods: {\n added: function added(event) {\n var _this = this,\n _this$value;\n\n var newItems = this.groups.map(function (group) {\n return group[_this.itemsKey];\n }).reduce(function (prev, curr) {\n return [].concat(_toConsumableArray(prev), _toConsumableArray(curr));\n }, []).filter(function (item) {\n return event.detail.ids.map(Number).indexOf(item.id) >= 0;\n });\n\n (_this$value = this.value).splice.apply(_this$value, [event.detail.index, 0].concat(_toConsumableArray(newItems)));\n\n this.$emit('change', this.groups);\n },\n removed: function removed(event) {\n var newArray = this.value.filter(function (item) {\n return event.detail.ids.map(Number).indexOf(item.id) < 0;\n });\n this.$emit('input', newArray);\n },\n reordered: function reordered(event, group) {\n var reorderedItems = this.value.filter(function (item) {\n return event.detail.ids.map(Number).indexOf(item.id) >= 0;\n });\n var notReorderedItems = this.value.filter(function (item) {\n return event.detail.ids.map(Number).indexOf(item.id) < 0;\n });\n notReorderedItems.splice.apply(notReorderedItems, [event.detail.index, 0].concat(_toConsumableArray(reorderedItems)));\n this.$emit('input', notReorderedItems);\n this.$emit('change', this.groups);\n },\n addListeners: function addListeners() {\n var _this2 = this;\n\n CUSTOM_EVENTS.forEach(function (event) {\n return _this2.$el.addEventListener(event, _this2[event]);\n });\n },\n removeListeners: function removeListeners() {\n var _this3 = this;\n\n CUSTOM_EVENTS.forEach(function (event) {\n return _this3.$el.removeEventListener(event, _this3[event]);\n });\n }\n },\n mounted: function mounted() {\n this.addListeners();\n },\n beforeDestroy: function beforeDestroy() {\n this.removeListeners();\n }\n};\n\n/***/ }),\n\n/***/ \"./src/core/helpers/dom.helper.js\":\n/*!****************************************!*\\\n !*** ./src/core/helpers/dom.helper.js ***!\n \\****************************************/\n/*! exports provided: getDroptargets, getDraggables, updateInitialAttributes, setInitialAtributes, removeOldDropzoneAreaElements, getContainer, addDropeffects, clearDropeffects, hasModifier */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getDroptargets\", function() { return getDroptargets; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getDraggables\", function() { return getDraggables; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"updateInitialAttributes\", function() { return updateInitialAttributes; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"setInitialAtributes\", function() { return setInitialAtributes; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"removeOldDropzoneAreaElements\", function() { return removeOldDropzoneAreaElements; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getContainer\", function() { return getContainer; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"addDropeffects\", function() { return addDropeffects; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"clearDropeffects\", function() { return clearDropeffects; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"hasModifier\", function() { return hasModifier; });\nvar getDroptargets = function getDroptargets(el, dropzoneSelector) {\n return el.querySelectorAll(dropzoneSelector);\n};\nvar getDraggables = function getDraggables(el, draggableSelector) {\n return el.querySelectorAll(draggableSelector);\n};\nvar updateInitialAttributes = function updateInitialAttributes(el) {\n this.targets = getDroptargets(el, this.defaultOptions.dropzoneSelector);\n this.items = getDraggables(el, this.defaultOptions.draggableSelector);\n\n for (var i = 0; i < this.targets.length; i++) {\n this.targets[i].setAttribute('aria-dropeffect', 'none');\n }\n\n for (var _i = 0; _i < this.items.length; _i++) {\n this.items[_i].setAttribute('draggable', 'true');\n\n if (this.items[_i].getAttribute('aria-grabbed') !== 'true') {\n this.items[_i].setAttribute('aria-grabbed', 'false');\n }\n\n this.items[_i].setAttribute('tabindex', '0');\n }\n};\nvar setInitialAtributes = function setInitialAtributes(el) {\n this.targets = getDroptargets(el, this.defaultOptions.dropzoneSelector);\n this.items = getDraggables(el, this.defaultOptions.draggableSelector);\n\n for (var i = 0; i < this.targets.length; i++) {\n this.targets[i].setAttribute('aria-dropeffect', 'none');\n }\n\n for (var _i2 = 0; _i2 < this.items.length; _i2++) {\n this.items[_i2].setAttribute('draggable', 'true');\n\n this.items[_i2].setAttribute('aria-grabbed', 'false');\n\n this.items[_i2].setAttribute('tabindex', '0');\n }\n};\nvar removeOldDropzoneAreaElements = function removeOldDropzoneAreaElements() {\n var oldItemDropzoneElements = document.querySelectorAll('.item-dropzone-area');\n\n for (var i = 0; i < oldItemDropzoneElements.length; i++) {\n oldItemDropzoneElements[i].remove();\n }\n};\nvar getContainer = function getContainer(element) {\n var containerElement = element;\n\n do {\n if (containerElement && containerElement.nodeType === 1 && containerElement.getAttribute('aria-dropeffect')) {\n return containerElement;\n }\n } while (containerElement = containerElement ? containerElement.parentNode : null);\n\n return null;\n};\nvar addDropeffects = function addDropeffects(items, selections, targets) {\n // apply aria-dropeffect and tabindex to all targets apart from the owner\n for (var len = targets.length, i = 0; i < len; i++) {\n if (targets[i] !== selections.owner && targets[i].getAttribute('aria-dropeffect') === 'none') {\n targets[i].setAttribute('aria-dropeffect', 'move');\n targets[i].setAttribute('tabindex', '0');\n }\n } // remove aria-grabbed and tabindex from all items inside those containers\n\n\n for (var _len = items.length, _i3 = 0; _i3 < _len; _i3++) {\n if (items[_i3].parentNode !== selections.owner && items[_i3].getAttribute('aria-grabbed')) {\n items[_i3].removeAttribute('aria-grabbed');\n\n items[_i3].removeAttribute('tabindex');\n }\n }\n};\nvar clearDropeffects = function clearDropeffects(items, selections, targets) {\n // if we dont't have any selected items just skip\n if (!selections.items.length) {\n return;\n } // reset aria-dropeffect and remove tabindex from all targets\n\n\n for (var i = 0; i < targets.length; i++) {\n if (targets[i].getAttribute('aria-dropeffect') !== 'none') {\n targets[i].setAttribute('aria-dropeffect', 'none');\n targets[i].removeAttribute('tabindex');\n }\n } // restore aria-grabbed and tabindex to all selectable items\n // without changing the grabbed value of any existing selected items\n\n\n for (var _i4 = 0; _i4 < items.length; _i4++) {\n if (!items[_i4].getAttribute('aria-grabbed')) {\n items[_i4].setAttribute('aria-grabbed', 'false');\n\n items[_i4].setAttribute('tabindex', '0');\n } else if (items[_i4].getAttribute('aria-grabbed') === 'true') {\n items[_i4].setAttribute('tabindex', '0');\n }\n }\n};\nvar hasModifier = function hasModifier(e) {\n return e.ctrlKey || e.metaKey || e.shiftKey;\n};\n\n/***/ }),\n\n/***/ \"./src/core/helpers/events.helper.js\":\n/*!*******************************************!*\\\n !*** ./src/core/helpers/events.helper.js ***!\n \\*******************************************/\n/*! exports provided: dispatchCustomEvent, dispatchReorderEvents */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"dispatchCustomEvent\", function() { return dispatchCustomEvent; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"dispatchReorderEvents\", function() { return dispatchReorderEvents; });\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar createCustomEvent = function createCustomEvent(name, data) {\n return new CustomEvent(name, {\n detail: data\n });\n};\n\nvar dispatchCustomEvent = function dispatchCustomEvent(name, data, element) {\n var customEvent = createCustomEvent(name, data);\n element.dispatchEvent(customEvent);\n};\nvar dispatchReorderEvents = function dispatchReorderEvents(e) {\n var oldItems = this.selections.droptarget.querySelectorAll(this.defaultOptions.draggableSelector);\n var index = this.nextItemElement ? Array.prototype.indexOf.call(oldItems, this.nextItemElement) : oldItems.length;\n\n var eventData = _objectSpread({\n ids: this.selections.items.map(function (item) {\n return item.dataset.id;\n }),\n index: index,\n nativeEvent: e\n }, this.selections);\n\n if (this.selections.droptarget === this.selections.owner) {\n dispatchCustomEvent('reordered', eventData, this.selections.droptarget);\n return;\n }\n\n dispatchCustomEvent('added', eventData, this.selections.droptarget);\n dispatchCustomEvent('removed', eventData, this.selections.owner);\n};\n\n/***/ }),\n\n/***/ \"./src/core/helpers/index.js\":\n/*!***********************************!*\\\n !*** ./src/core/helpers/index.js ***!\n \\***********************************/\n/*! exports provided: getDroptargets, getDraggables, updateInitialAttributes, setInitialAtributes, removeOldDropzoneAreaElements, getContainer, addDropeffects, clearDropeffects, hasModifier, addSelection, removeSelection, clearSelections, stopDragAndDrop, dispatchCustomEvent, dispatchReorderEvents */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _dom_helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dom.helper */ \"./src/core/helpers/dom.helper.js\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"getDroptargets\", function() { return _dom_helper__WEBPACK_IMPORTED_MODULE_0__[\"getDroptargets\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"getDraggables\", function() { return _dom_helper__WEBPACK_IMPORTED_MODULE_0__[\"getDraggables\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"updateInitialAttributes\", function() { return _dom_helper__WEBPACK_IMPORTED_MODULE_0__[\"updateInitialAttributes\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"setInitialAtributes\", function() { return _dom_helper__WEBPACK_IMPORTED_MODULE_0__[\"setInitialAtributes\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"removeOldDropzoneAreaElements\", function() { return _dom_helper__WEBPACK_IMPORTED_MODULE_0__[\"removeOldDropzoneAreaElements\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"getContainer\", function() { return _dom_helper__WEBPACK_IMPORTED_MODULE_0__[\"getContainer\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"addDropeffects\", function() { return _dom_helper__WEBPACK_IMPORTED_MODULE_0__[\"addDropeffects\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"clearDropeffects\", function() { return _dom_helper__WEBPACK_IMPORTED_MODULE_0__[\"clearDropeffects\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"hasModifier\", function() { return _dom_helper__WEBPACK_IMPORTED_MODULE_0__[\"hasModifier\"]; });\n\n/* harmony import */ var _state_helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./state.helper */ \"./src/core/helpers/state.helper.js\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"addSelection\", function() { return _state_helper__WEBPACK_IMPORTED_MODULE_1__[\"addSelection\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"removeSelection\", function() { return _state_helper__WEBPACK_IMPORTED_MODULE_1__[\"removeSelection\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"clearSelections\", function() { return _state_helper__WEBPACK_IMPORTED_MODULE_1__[\"clearSelections\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"stopDragAndDrop\", function() { return _state_helper__WEBPACK_IMPORTED_MODULE_1__[\"stopDragAndDrop\"]; });\n\n/* harmony import */ var _events_helper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./events.helper */ \"./src/core/helpers/events.helper.js\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"dispatchCustomEvent\", function() { return _events_helper__WEBPACK_IMPORTED_MODULE_2__[\"dispatchCustomEvent\"]; });\n\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"dispatchReorderEvents\", function() { return _events_helper__WEBPACK_IMPORTED_MODULE_2__[\"dispatchReorderEvents\"]; });\n\n\n\n\n\n/***/ }),\n\n/***/ \"./src/core/helpers/state.helper.js\":\n/*!******************************************!*\\\n !*** ./src/core/helpers/state.helper.js ***!\n \\******************************************/\n/*! exports provided: addSelection, removeSelection, clearSelections, stopDragAndDrop */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"addSelection\", function() { return addSelection; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"removeSelection\", function() { return removeSelection; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"clearSelections\", function() { return clearSelections; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"stopDragAndDrop\", function() { return stopDragAndDrop; });\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nvar addSelection = function addSelection(item) {\n // if the owner reference is still null, set it to this item's parent\n // so that further selection is only allowed within the same container\n if (!this.selections.owner) {\n this.selections.owner = item.parentNode;\n } // or if that's already happened then compare it with this item's parent\n // and if they're not the same container, return to prevent selection\n\n\n if (!this.defaultOptions.multipleDropzonesItemsDraggingEnabled && this.selections.owner !== item.parentNode) {\n return;\n } // set this item's grabbed state\n\n\n item.setAttribute('aria-grabbed', 'true'); // add it to the items array\n\n this.selections.items = this.selections.items.indexOf(item) >= 0 ? this.selections.items : [].concat(_toConsumableArray(this.selections.items), [item]);\n};\nvar removeSelection = function removeSelection(item) {\n // reset this item's grabbed state\n item.setAttribute('aria-grabbed', 'false'); // then find and remove this item from the existing items array\n\n for (var i = 0; i < this.selections.items.length; i++) {\n if (this.selections.items[i] === item) {\n this.selections.items.splice(i, 1);\n break;\n }\n }\n};\nvar clearSelections = function clearSelections() {\n // if we have any selected items\n if (this.selections.items.length) {\n // reset the owner reference\n this.selections.owner = null; // reset the grabbed state on every selected item\n\n for (var i = 0; i < this.selections.items.length; i++) {\n this.selections.items[i].setAttribute('aria-grabbed', 'false');\n } // then reset the items array\n\n\n this.selections.items = [];\n }\n};\nvar stopDragAndDrop = function stopDragAndDrop() {\n // throw exception and catch this to stop further d&d\n throw new Error('Requested D&D stop...');\n};\n\n/***/ }),\n\n/***/ \"./src/core/index.js\":\n/*!***************************!*\\\n !*** ./src/core/index.js ***!\n \\***************************/\n/*! exports provided: VueDraggable */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"VueDraggable\", function() { return VueDraggable; });\n/* harmony import */ var _listeners__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./listeners */ \"./src/core/listeners/index.js\");\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./helpers */ \"./src/core/helpers/index.js\");\n/* harmony import */ var _options__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./options */ \"./src/core/options.js\");\n/* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./state */ \"./src/core/state.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\nvar VueDraggable =\n/*#__PURE__*/\nfunction () {\n function VueDraggable(el, componentInstance, options) {\n _classCallCheck(this, VueDraggable);\n\n Object.assign(this, Object(_state__WEBPACK_IMPORTED_MODULE_3__[\"getState\"])(), {\n defaultOptions: Object(_options__WEBPACK_IMPORTED_MODULE_2__[\"getOptions\"])(componentInstance, options)\n }, {\n el: el\n });\n this.registerListeners(el);\n this.initiate(el);\n }\n\n _createClass(VueDraggable, [{\n key: \"registerListeners\",\n value: function registerListeners(el) {\n _listeners__WEBPACK_IMPORTED_MODULE_0__[\"attachListeners\"].bind(this)(el);\n }\n }, {\n key: \"initiate\",\n value: function initiate(el) {\n _helpers__WEBPACK_IMPORTED_MODULE_1__[\"setInitialAtributes\"].bind(this)(el);\n }\n }, {\n key: \"update\",\n value: function update(el) {\n _helpers__WEBPACK_IMPORTED_MODULE_1__[\"updateInitialAttributes\"].bind(this)(el);\n }\n }]);\n\n return VueDraggable;\n}();\n;\n\n/***/ }),\n\n/***/ \"./src/core/listeners/handlers/dragend.handler.js\":\n/*!********************************************************!*\\\n !*** ./src/core/listeners/handlers/dragend.handler.js ***!\n \\********************************************************/\n/*! exports provided: dragendHandler */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"dragendHandler\", function() { return dragendHandler; });\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../helpers */ \"./src/core/helpers/index.js\");\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n\n\nvar reorderDomElements = function reorderDomElements(droptarget, items, nextItemElement) {\n for (var i = 0; i < items.length; i++) {\n if (nextItemElement) {\n droptarget.insertBefore(items[i], nextItemElement);\n continue;\n }\n\n droptarget.appendChild(items[i]);\n }\n};\n\nvar dragendHandler = function dragendHandler(e) {\n if (typeof this.defaultOptions.onDragend === 'function') {\n try {\n this.defaultOptions.onDragend(_objectSpread({\n nativeEvent: e,\n stop: _helpers__WEBPACK_IMPORTED_MODULE_0__[\"stopDragAndDrop\"]\n }, this.selections));\n } catch (error) {\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"removeOldDropzoneAreaElements\"])();\n return;\n }\n } // if we have a valid drop target reference\n // (which implies that we have some selected items)\n\n\n if (this.selections.droptarget) {\n if (this.defaultOptions.reactivityEnabled) {\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"dispatchReorderEvents\"].bind(this)(e);\n } else {\n // make dom manipulation only if reactivity is disabled\n reorderDomElements(this.selections.droptarget, this.selections.items, this.nextItemElement);\n }\n\n if (typeof this.defaultOptions.onDrop === 'function') {\n this.defaultOptions.onDrop(_objectSpread({\n nativeEvent: e,\n stop: function stop() {\n throw new Error(\"Stop method is available only for callbacks\\n 'onDragstart' and 'onDragend'. For more info look at\\n https://github.com/Vivify-Ideas/vue-draggable/blob/master/README.md\\n \");\n }\n }, this.selections));\n } // prevent default to allow the action\n\n\n e.preventDefault();\n } // if we have any selected items\n\n\n if (this.selections.items.length) {\n // clear dropeffect from the target containers\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearDropeffects\"])(this.items, this.selections, this.targets); // if we have a valid drop target reference\n\n if (this.selections.droptarget) {\n // reset the selections array\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearSelections\"].bind(this)(); // reset the target's dragover class\n\n this.selections.droptarget.className = this.selections.droptarget.className.replace(/ dragover/g, ''); // reset the target reference\n\n this.selections.droptarget = null;\n }\n } // dropzone area elements\n\n\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"removeOldDropzoneAreaElements\"])();\n};\n\n/***/ }),\n\n/***/ \"./src/core/listeners/handlers/dragenter.handler.js\":\n/*!**********************************************************!*\\\n !*** ./src/core/listeners/handlers/dragenter.handler.js ***!\n \\**********************************************************/\n/*! exports provided: dragenterHandler */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"dragenterHandler\", function() { return dragenterHandler; });\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar dragenterHandler = function dragenterHandler(e) {\n this.related = e.target;\n\n if (typeof this.defaultOptions.onDragenter === 'function') {\n try {\n this.defaultOptions.onDragenter(_objectSpread({\n nativeEvent: e,\n stop: function stop() {\n throw new Error(\"Stop method is available only for callbacks\\n 'onDragstart' and 'onDragend'. For more info look at\\n https://github.com/Vivify-Ideas/vue-draggable/blob/master/README.md\\n \");\n }\n }, this.selections));\n } catch (error) {\n e.preventDefault();\n return;\n }\n }\n};\n\n/***/ }),\n\n/***/ \"./src/core/listeners/handlers/dragleave.handler.js\":\n/*!**********************************************************!*\\\n !*** ./src/core/listeners/handlers/dragleave.handler.js ***!\n \\**********************************************************/\n/*! exports provided: dragleaveHandler */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"dragleaveHandler\", function() { return dragleaveHandler; });\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../helpers */ \"./src/core/helpers/index.js\");\n\nvar dragleaveHandler = function dragleaveHandler() {\n // get a drop target reference from the relatedTarget\n var droptarget = Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"getContainer\"])(this.related); // if the drop target is different from the last stored reference\n // (or we have one of those references but not the other one)\n\n if (droptarget !== this.selections.droptarget) {\n // if we have a saved reference, clear its existing dragover class\n if (this.selections.droptarget) {\n this.selections.droptarget.className = this.selections.droptarget.className.replace(/ dragover/g, '');\n } // apply the dragover class to the new drop target reference\n\n\n if (droptarget) {\n droptarget.className += ' dragover';\n } // then save that reference for next time\n\n\n this.selections.droptarget = droptarget;\n }\n};\n\n/***/ }),\n\n/***/ \"./src/core/listeners/handlers/dragover.handler.js\":\n/*!*********************************************************!*\\\n !*** ./src/core/listeners/handlers/dragover.handler.js ***!\n \\*********************************************************/\n/*! exports provided: dragoverHandler */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"dragoverHandler\", function() { return dragoverHandler; });\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../helpers */ \"./src/core/helpers/index.js\");\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n\nvar state = {\n previousTarget: null,\n dragoverCalls: 0\n};\n\nvar displayDropzones = function displayDropzones(e) {\n if (state.dragoverCalls % 100 !== 0 && (e.target === state.previousTarget || !e.target || e.target.className === 'item-dropzone-area')) return;\n state.dragoverCalls++;\n state.previousTarget = e.target;\n this.nextItemElement = e.target.closest(this.defaultOptions.draggableSelector);\n this.selections.droptarget = e.target.closest(this.defaultOptions.dropzoneSelector);\n var itemDropzoneElement = document.createElement('div');\n itemDropzoneElement.className = 'item-dropzone-area';\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"removeOldDropzoneAreaElements\"])();\n\n if (this.selections.droptarget && this.nextItemElement) {\n this.selections.droptarget.insertBefore(itemDropzoneElement, state.previousTarget.closest(this.defaultOptions.draggableSelector));\n }\n\n if (this.selections.droptarget && !this.nextItemElement) {\n this.selections.droptarget.appendChild(itemDropzoneElement);\n }\n};\n\nvar dragoverHandler = function dragoverHandler(e) {\n // if we have any selected items,\n // allow them to be dragged\n if (this.selections.items.length) {\n e.preventDefault();\n }\n\n if (!this.defaultOptions.showDropzoneAreas) {\n return;\n }\n\n displayDropzones.bind(this)(e);\n\n if (typeof this.defaultOptions.onDragover === 'function') {\n try {\n this.defaultOptions.onDragover(_objectSpread({\n nativeEvent: e,\n stop: function stop() {\n throw new Error(\"Stop method is available only for callbacks\\n 'onDragstart' and 'onDragend'. For more info look at\\n https://github.com/Vivify-Ideas/vue-draggable/blob/master/README.md\\n \");\n }\n }, this.selections));\n } catch (error) {\n e.preventDefault();\n return;\n }\n }\n};\n\n/***/ }),\n\n/***/ \"./src/core/listeners/handlers/dragstart.handler.js\":\n/*!**********************************************************!*\\\n !*** ./src/core/listeners/handlers/dragstart.handler.js ***!\n \\**********************************************************/\n/*! exports provided: dragstartHandler */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"dragstartHandler\", function() { return dragstartHandler; });\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../helpers */ \"./src/core/helpers/index.js\");\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n\nvar dragstartHandler = function dragstartHandler(e) {\n var elem = e.target.closest(this.defaultOptions.draggableSelector); // if the element's parent is not the owner, then block this event\n\n if (!this.defaultOptions.multipleDropzonesItemsDraggingEnabled && elem && this.selections.owner !== elem.parentNode) {\n e.preventDefault();\n return;\n }\n\n if (typeof this.defaultOptions.onDragstart === 'function') {\n try {\n this.defaultOptions.onDragstart(_objectSpread({\n nativeEvent: e,\n stop: _helpers__WEBPACK_IMPORTED_MODULE_0__[\"stopDragAndDrop\"]\n }, this.selections));\n } catch (error) {\n e.preventDefault();\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"removeOldDropzoneAreaElements\"])();\n return;\n }\n } // [else] if the multiple selection modifier is pressed\n // and the item's grabbed state is currently false\n\n\n if (Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"hasModifier\"])(e) && elem.getAttribute('aria-grabbed') === 'false') {\n // add this additional selection\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"addSelection\"].bind(this)(elem);\n } // we don't need the transfer data, but we have to define something\n // otherwise the drop action won't work at all in firefox\n // most browsers support the proper mime-type syntax, eg. \"text/plain\"\n // but we have to use this incorrect syntax for the benefit of IE10+\n\n\n e.dataTransfer.setData('text', ''); // apply dropeffect to the target containers\n\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"addDropeffects\"])(this.items, this.selections, this.targets);\n};\n\n/***/ }),\n\n/***/ \"./src/core/listeners/handlers/index.js\":\n/*!**********************************************!*\\\n !*** ./src/core/listeners/handlers/index.js ***!\n \\**********************************************/\n/*! exports provided: mousedownHandler, mouseupHandler, dragoverHandler, dragstartHandler, dragenterHandler, dragleaveHandler, dragendHandler, keydownHandler */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _mousedown_handler__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mousedown.handler */ \"./src/core/listeners/handlers/mousedown.handler.js\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"mousedownHandler\", function() { return _mousedown_handler__WEBPACK_IMPORTED_MODULE_0__[\"mousedownHandler\"]; });\n\n/* harmony import */ var _mouseup_handler__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mouseup.handler */ \"./src/core/listeners/handlers/mouseup.handler.js\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"mouseupHandler\", function() { return _mouseup_handler__WEBPACK_IMPORTED_MODULE_1__[\"mouseupHandler\"]; });\n\n/* harmony import */ var _dragover_handler__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dragover.handler */ \"./src/core/listeners/handlers/dragover.handler.js\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"dragoverHandler\", function() { return _dragover_handler__WEBPACK_IMPORTED_MODULE_2__[\"dragoverHandler\"]; });\n\n/* harmony import */ var _dragstart_handler__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dragstart.handler */ \"./src/core/listeners/handlers/dragstart.handler.js\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"dragstartHandler\", function() { return _dragstart_handler__WEBPACK_IMPORTED_MODULE_3__[\"dragstartHandler\"]; });\n\n/* harmony import */ var _dragenter_handler__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./dragenter.handler */ \"./src/core/listeners/handlers/dragenter.handler.js\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"dragenterHandler\", function() { return _dragenter_handler__WEBPACK_IMPORTED_MODULE_4__[\"dragenterHandler\"]; });\n\n/* harmony import */ var _dragleave_handler__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./dragleave.handler */ \"./src/core/listeners/handlers/dragleave.handler.js\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"dragleaveHandler\", function() { return _dragleave_handler__WEBPACK_IMPORTED_MODULE_5__[\"dragleaveHandler\"]; });\n\n/* harmony import */ var _dragend_handler__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dragend.handler */ \"./src/core/listeners/handlers/dragend.handler.js\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"dragendHandler\", function() { return _dragend_handler__WEBPACK_IMPORTED_MODULE_6__[\"dragendHandler\"]; });\n\n/* harmony import */ var _keydown_handler__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./keydown.handler */ \"./src/core/listeners/handlers/keydown.handler.js\");\n/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, \"keydownHandler\", function() { return _keydown_handler__WEBPACK_IMPORTED_MODULE_7__[\"keydownHandler\"]; });\n\n\n\n\n\n\n\n\n\n\n/***/ }),\n\n/***/ \"./src/core/listeners/handlers/keydown.handler.js\":\n/*!********************************************************!*\\\n !*** ./src/core/listeners/handlers/keydown.handler.js ***!\n \\********************************************************/\n/*! exports provided: keydownHandler */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"keydownHandler\", function() { return keydownHandler; });\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../helpers */ \"./src/core/helpers/index.js\");\n\n\nvar isItemAroundSelectionArea = function isItemAroundSelectionArea(item, lastItem) {\n return item.parentNode === lastItem.parentNode;\n};\n\nvar keydownHandler = function keydownHandler(e) {\n // if the element is a grabbable item\n if (e.target.getAttribute('aria-grabbed')) {\n // Space is the selection or unselection keystroke\n if (e.keyCode === 32) {\n // if the multiple selection modifier is pressed\n if (Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"hasModifier\"])(e)) {\n // if the item's grabbed state is currently true\n if (e.target.getAttribute('aria-grabbed') === 'true') {\n // if this is the only selected item, clear dropeffect\n // from the target containers, which we must do first\n // in case subsequent unselection sets owner to null\n if (this.selections.items.length === 1) {\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearDropeffects\"])(this.items, this.selections, this.targets);\n } // unselect this item\n\n\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"removeSelection\"].bind(this)(e.target); // if we have any selections\n // apply dropeffect to the target containers,\n // in case earlier selections were made by mouse\n\n if (this.selections.items.length) {\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"addDropeffects\"])(this.items, this.selections, this.targets);\n } // if that was the only selected item\n // then reset the owner container reference\n\n\n if (!this.selections.items.length) {\n this.selections.owner = null;\n }\n } else {\n // else [if its grabbed state is currently false]\n // add this additional selection\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"addSelection\"].bind(this)(e.target); // apply dropeffect to the target containers\n\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"addDropeffects\"])(this.items, this.selections, this.targets);\n }\n } else if (e.target.getAttribute('aria-grabbed') === 'false') {\n // else [if the multiple selection modifier is not pressed]\n // and the item's grabbed state is currently false\n // clear dropeffect from the target containers\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearDropeffects\"])(this.items, this.selections, this.targets); // clear all existing selections\n\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearSelections\"].bind(this)(); // add this new selection\n\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"addSelection\"].bind(this)(e.target); // apply dropeffect to the target containers\n\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"addDropeffects\"])(this.items, this.selections, this.targets);\n } else {\n // else [if modifier is not pressed and grabbed is already true]\n // apply dropeffect to the target containers\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"addDropeffects\"])(this.items, this.selections, this.targets);\n } // then prevent default to avoid any conflict with native actions\n\n\n e.preventDefault();\n } // (CMD or Ctrl) + A - select all the items around the selected one\n\n\n if (e.keyCode === 65 && (e.ctrlKey || e.metaKey)) {\n var lastItem = this.selections.items.slice(-1).pop();\n\n if (this.items && this.items.length > 0) {\n for (var i = 0; i < this.items.length; i++) {\n var item = this.items[i];\n var shouldSelectItem = isItemAroundSelectionArea(item, lastItem);\n shouldSelectItem && _helpers__WEBPACK_IMPORTED_MODULE_0__[\"addSelection\"].bind(this)(item);\n }\n }\n\n e.preventDefault(); // prevent entire page selection.\n } // Modifier + M is the end-of-selection keystroke\n\n\n if (e.keyCode === 77 && Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"hasModifier\"])(e)) {\n // if we have any selected items\n if (this.selections.items.length) {\n // apply dropeffect to the target containers\n // in case earlier selections were made by mouse\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"addDropeffects\"])(this.items, this.selections, this.targets); // if the owner container is the last one, focus the first one\n\n if (this.selections.owner === this.targets[this.targets.length - 1]) {\n this.targets[0].focus();\n } else {\n // else [if it's not the last one], find and focus the next one\n for (var _i = 0; _i < this.targets.length; _i++) {\n if (this.selections.owner === this.targets[_i]) {\n this.targets[_i + 1].focus();\n\n break;\n }\n }\n }\n } // then prevent default to avoid any conflict with native actions\n\n\n e.preventDefault();\n }\n } // Escape is the abort keystroke (for any target element)\n\n\n if (e.keyCode === 27) {\n // if we have any selected items\n if (this.selections.items.length) {\n // clear dropeffect from the target containers\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearDropeffects\"])(this.items, this.selections, this.targets); // then set focus back on the last item that was selected, which is\n // necessary because we've removed tabindex from the current focus\n\n this.selections.items[this.selections.items.length - 1].focus(); // clear all existing selections\n\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearSelections\"].bind(this)(); // but don't prevent default so that native actions can still occur\n }\n } // if the element is a drop target container\n\n\n if (e.target.getAttribute('aria-dropeffect')) {\n // Enter or Modifier + M is the drop keystroke\n if (e.keyCode === 13 || e.keyCode === 77 && Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"hasModifier\"])(e)) {\n // append the selected items to the end of the target container\n if (this.defaultOptions.reactivityEnabled) {\n this.selections.droptarget = e.target;\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"dispatchReorderEvents\"].bind(this)(e);\n } else {\n for (var _i2 = 0; _i2 < this.selections.items.length; _i2++) {\n e.target.appendChild(this.selections.items[_i2]);\n }\n } // clear dropeffect from the target containers\n\n\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearDropeffects\"])(this.items, this.selections, this.targets); // then set focus back on the last item that was selected, which is\n // necessary because we've removed tabindex from the current focus\n\n this.selections.items[this.selections.items.length - 1].focus(); // reset the selections array\n\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearSelections\"].bind(this)(); // prevent default to to avoid any conflict with native actions\n\n e.preventDefault();\n }\n }\n};\n\n/***/ }),\n\n/***/ \"./src/core/listeners/handlers/mousedown.handler.js\":\n/*!**********************************************************!*\\\n !*** ./src/core/listeners/handlers/mousedown.handler.js ***!\n \\**********************************************************/\n/*! exports provided: mousedownHandler */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"mousedownHandler\", function() { return mousedownHandler; });\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../helpers */ \"./src/core/helpers/index.js\");\n\nvar mousedownHandler = function mousedownHandler(e) {\n if (this.defaultOptions.handlerSelector) {\n var handler = e.target.closest(this.defaultOptions.handlerSelector);\n\n if (!handler) {\n return;\n }\n }\n\n var elem = e.target.closest(this.defaultOptions.draggableSelector); // if the element is a draggable item\n\n if (elem && elem.getAttribute('draggable')) {\n // clear dropeffect from the target containers\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearDropeffects\"])(this.items, this.selections, this.targets); // if the multiple selection modifier is not pressed\n // and the item's grabbed state is currently false\n\n if (!Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"hasModifier\"])(e) && elem.getAttribute('aria-grabbed') === 'false') {\n // clear all existing selections\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearSelections\"].bind(this)(); // then add this new selection\n\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"addSelection\"].bind(this)(elem);\n }\n } else if (!Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"hasModifier\"])(e)) {\n // else [if the element is anything else]\n // and the selection modifier is not pressed\n // clear dropeffect from the target containers\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearDropeffects\"])(this.items, this.selections, this.targets); // clear all existing selections\n\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearSelections\"].bind(this)();\n } else {\n // else [if the element is anything else and the modifier is pressed]\n // clear dropeffect from the target containers\n Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearDropeffects\"])(this.items, this.selections, this.targets);\n }\n};\n\n/***/ }),\n\n/***/ \"./src/core/listeners/handlers/mouseup.handler.js\":\n/*!********************************************************!*\\\n !*** ./src/core/listeners/handlers/mouseup.handler.js ***!\n \\********************************************************/\n/*! exports provided: mouseupHandler */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"mouseupHandler\", function() { return mouseupHandler; });\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../helpers */ \"./src/core/helpers/index.js\");\n\n\nvar isItemInSelectionArea = function isItemInSelectionArea(item, element, lastItem) {\n return item.parentNode === element.parentNode && (element.offsetTop > lastItem.offsetTop && item.offsetTop <= element.offsetTop && item.offsetTop >= lastItem.offsetTop || item.offsetTop >= element.offsetTop && item.offsetTop <= lastItem.offsetTop);\n};\n\nvar mouseupHandler = function mouseupHandler(e) {\n var elem = e.target.closest(this.defaultOptions.draggableSelector); // if the element is a draggable item\n\n if (elem && elem.getAttribute('draggable')) {\n // if shift key is pressed select multiple items\n if (Object(_helpers__WEBPACK_IMPORTED_MODULE_0__[\"hasModifier\"])(e)) {\n if (this.selections.items.length && e.shiftKey) {\n // last selected item\n var lastItem = this.selections.items.slice(-1).pop();\n\n if (this.items && this.items.length > 0) {\n for (var i = 0; i < this.items.length; i++) {\n var item = this.items[i];\n var shouldSelectItem = isItemInSelectionArea(item, elem, lastItem);\n shouldSelectItem && _helpers__WEBPACK_IMPORTED_MODULE_0__[\"addSelection\"].bind(this)(item);\n } // if the item's grabbed state is currently true\n\n }\n } else if (elem.getAttribute('aria-grabbed') === 'true') {\n // unselect this item\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"removeSelection\"].bind(this)(elem); // if that was the only selected item\n // then reset the owner container reference\n\n if (!this.selections.items.length) {\n this.selections.owner = null;\n }\n } else {\n // else [if the item's grabbed state is false]\n // add this additional selection\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"addSelection\"].bind(this)(elem);\n }\n } else {\n // if no modifier, clear all selections and add current item.\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"clearSelections\"].bind(this)();\n _helpers__WEBPACK_IMPORTED_MODULE_0__[\"addSelection\"].bind(this)(elem);\n }\n }\n};\n\n/***/ }),\n\n/***/ \"./src/core/listeners/index.js\":\n/*!*************************************!*\\\n !*** ./src/core/listeners/index.js ***!\n \\*************************************/\n/*! exports provided: attachListeners */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"attachListeners\", function() { return attachListeners; });\n/* harmony import */ var _handlers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./handlers */ \"./src/core/listeners/handlers/index.js\");\n\nvar attachListeners = function attachListeners(el) {\n // mousedown event to clear previous selections\n el.addEventListener('mousedown', _handlers__WEBPACK_IMPORTED_MODULE_0__[\"mousedownHandler\"].bind(this), false); // mouseup event to implement multiple selection\n\n el.addEventListener('mouseup', _handlers__WEBPACK_IMPORTED_MODULE_0__[\"mouseupHandler\"].bind(this), false); // dragstart event to initiate mouse dragging\n\n el.addEventListener('dragstart', _handlers__WEBPACK_IMPORTED_MODULE_0__[\"dragstartHandler\"].bind(this), false); // keydown event to implement selection and abort\n\n el.addEventListener('keydown', _handlers__WEBPACK_IMPORTED_MODULE_0__[\"keydownHandler\"].bind(this), false); // dragenter event to set related variable\n\n el.addEventListener('dragenter', _handlers__WEBPACK_IMPORTED_MODULE_0__[\"dragenterHandler\"].bind(this), false); // dragleave event to maintain target highlighting using that variable\n\n el.addEventListener('dragleave', _handlers__WEBPACK_IMPORTED_MODULE_0__[\"dragleaveHandler\"].bind(this), false); // dragover event to allow the drag by preventing its default\n\n el.addEventListener('dragover', _handlers__WEBPACK_IMPORTED_MODULE_0__[\"dragoverHandler\"].bind(this), false); // dragend event to implement items being validly dropped into targets,\n // or invalidly dropped elsewhere, and to clean-up the interface either way\n\n el.addEventListener('dragend', _handlers__WEBPACK_IMPORTED_MODULE_0__[\"dragendHandler\"].bind(this), false);\n};\n\n/***/ }),\n\n/***/ \"./src/core/options.js\":\n/*!*****************************!*\\\n !*** ./src/core/options.js ***!\n \\*****************************/\n/*! exports provided: getOptions */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getOptions\", function() { return getOptions; });\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar getOptions = function getOptions(componentInstance, options) {\n return _objectSpread({\n dropzoneSelector: 'ul',\n draggableSelector: 'li',\n handlerSelector: null,\n reactivityEnabled: true,\n multipleDropzonesItemsDraggingEnabled: false,\n showDropzoneAreas: true\n }, options, {\n onDragstart: (options.onDragstart || function () {}).bind(componentInstance),\n onDragenter: (options.onDragenter || function () {}).bind(componentInstance),\n onDragover: (options.onDragover || function () {}).bind(componentInstance),\n onDragend: (options.onDragend || function () {}).bind(componentInstance),\n onDrop: (options.onDrop || function () {}).bind(componentInstance)\n });\n};\n\n/***/ }),\n\n/***/ \"./src/core/state.js\":\n/*!***************************!*\\\n !*** ./src/core/state.js ***!\n \\***************************/\n/*! exports provided: getState */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getState\", function() { return getState; });\nvar getState = function getState() {\n return {\n targets: null,\n items: null,\n nextItemElement: null,\n // related variable is needed to maintain a reference to the\n // dragleave's relatedTarget, since it doesn't have e.relatedTarget\n related: null,\n selections: {\n items: [],\n owner: null,\n droptarget: null\n }\n };\n};\n\n/***/ }),\n\n/***/ \"./src/index.js\":\n/*!**********************!*\\\n !*** ./src/index.js ***!\n \\**********************/\n/*! exports provided: VueDraggableDirective, default */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"VueDraggableDirective\", function() { return VueDraggableDirective; });\n/* harmony import */ var _core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./core */ \"./src/core/index.js\");\n/* harmony import */ var _components_vue_draggable_group_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/vue-draggable-group.component */ \"./src/components/vue-draggable-group.component.js\");\n\n\nvar instances = [];\nvar VueDraggableDirective = {\n bind: function bind(el, options, vnode) {\n var instance = new _core__WEBPACK_IMPORTED_MODULE_0__[\"VueDraggable\"](el, vnode.context, options.value);\n instances.push(instance);\n },\n componentUpdated: function componentUpdated(el) {\n setTimeout(function () {\n instances.forEach(function (instance) {\n if (instance.el !== el) return;\n instance.update(el);\n });\n });\n },\n unbind: function unbind(el) {\n instances = instances.filter(function (instance) {\n return instance.el !== el;\n });\n }\n};\n\n_core__WEBPACK_IMPORTED_MODULE_0__[\"VueDraggable\"].install = function (Vue) {\n Vue.directive('drag-and-drop', VueDraggableDirective);\n Vue.component('vue-draggable-group', _components_vue_draggable_group_component__WEBPACK_IMPORTED_MODULE_1__[\"VueDraggableGroup\"]);\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (_core__WEBPACK_IMPORTED_MODULE_0__[\"VueDraggable\"]);\n\n/***/ })\n\n/******/ });\n});\n//# sourceMappingURL=vue-draggable.js.map","'use strict';\nvar getBuiltIn = require('../internals/get-built-in');\nvar isCallable = require('../internals/is-callable');\nvar isPrototypeOf = require('../internals/object-is-prototype-of');\nvar USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');\n\nvar $Object = Object;\n\nmodule.exports = USE_SYMBOL_AS_UID ? function (it) {\n return typeof it == 'symbol';\n} : function (it) {\n var $Symbol = getBuiltIn('Symbol');\n return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));\n};\n","'use strict';\n/* eslint-disable no-unused-vars -- required for functions `.length` */\nvar $ = require('../internals/export');\nvar global = require('../internals/global');\nvar apply = require('../internals/function-apply');\nvar wrapErrorConstructorWithCause = require('../internals/wrap-error-constructor-with-cause');\n\nvar WEB_ASSEMBLY = 'WebAssembly';\nvar WebAssembly = global[WEB_ASSEMBLY];\n\n// eslint-disable-next-line es/no-error-cause -- feature detection\nvar FORCED = new Error('e', { cause: 7 }).cause !== 7;\n\nvar exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) {\n var O = {};\n O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED);\n $({ global: true, constructor: true, arity: 1, forced: FORCED }, O);\n};\n\nvar exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) {\n if (WebAssembly && WebAssembly[ERROR_NAME]) {\n var O = {};\n O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED);\n $({ target: WEB_ASSEMBLY, stat: true, constructor: true, arity: 1, forced: FORCED }, O);\n }\n};\n\n// https://tc39.es/ecma262/#sec-nativeerror\nexportGlobalErrorCauseWrapper('Error', function (init) {\n return function Error(message) { return apply(init, this, arguments); };\n});\nexportGlobalErrorCauseWrapper('EvalError', function (init) {\n return function EvalError(message) { return apply(init, this, arguments); };\n});\nexportGlobalErrorCauseWrapper('RangeError', function (init) {\n return function RangeError(message) { return apply(init, this, arguments); };\n});\nexportGlobalErrorCauseWrapper('ReferenceError', function (init) {\n return function ReferenceError(message) { return apply(init, this, arguments); };\n});\nexportGlobalErrorCauseWrapper('SyntaxError', function (init) {\n return function SyntaxError(message) { return apply(init, this, arguments); };\n});\nexportGlobalErrorCauseWrapper('TypeError', function (init) {\n return function TypeError(message) { return apply(init, this, arguments); };\n});\nexportGlobalErrorCauseWrapper('URIError', function (init) {\n return function URIError(message) { return apply(init, this, arguments); };\n});\nexportWebAssemblyErrorCauseWrapper('CompileError', function (init) {\n return function CompileError(message) { return apply(init, this, arguments); };\n});\nexportWebAssemblyErrorCauseWrapper('LinkError', function (init) {\n return function LinkError(message) { return apply(init, this, arguments); };\n});\nexportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) {\n return function RuntimeError(message) { return apply(init, this, arguments); };\n});\n","'use strict';\nvar check = function (it) {\n return it && it.Math === Math && it;\n};\n\n// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\nmodule.exports =\n // eslint-disable-next-line es/no-global-this -- safe\n check(typeof globalThis == 'object' && globalThis) ||\n check(typeof window == 'object' && window) ||\n // eslint-disable-next-line no-restricted-globals -- safe\n check(typeof self == 'object' && self) ||\n check(typeof global == 'object' && global) ||\n check(typeof this == 'object' && this) ||\n // eslint-disable-next-line no-new-func -- fallback\n (function () { return this; })() || Function('return this')();\n","'use strict';\nvar aCallable = require('../internals/a-callable');\nvar isNullOrUndefined = require('../internals/is-null-or-undefined');\n\n// `GetMethod` abstract operation\n// https://tc39.es/ecma262/#sec-getmethod\nmodule.exports = function (V, P) {\n var func = V[P];\n return isNullOrUndefined(func) ? undefined : aCallable(func);\n};\n","'use strict';\nvar IteratorPrototype = require('../internals/iterators-core').IteratorPrototype;\nvar create = require('../internals/object-create');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar Iterators = require('../internals/iterators');\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {\n var TO_STRING_TAG = NAME + ' Iterator';\n IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });\n setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);\n Iterators[TO_STRING_TAG] = returnThis;\n return IteratorConstructor;\n};\n","'use strict';\nvar global = require('../internals/global');\nvar DOMIterables = require('../internals/dom-iterables');\nvar DOMTokenListPrototype = require('../internals/dom-token-list-prototype');\nvar ArrayIteratorMethods = require('../modules/es.array.iterator');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar ArrayValues = ArrayIteratorMethods.values;\n\nvar handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {\n if (CollectionPrototype) {\n // some Chrome versions have non-configurable methods on DOMTokenList\n if (CollectionPrototype[ITERATOR] !== ArrayValues) try {\n createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);\n } catch (error) {\n CollectionPrototype[ITERATOR] = ArrayValues;\n }\n setToStringTag(CollectionPrototype, COLLECTION_NAME, true);\n if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) {\n // some Chrome versions have non-configurable methods on DOMTokenList\n if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try {\n createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);\n } catch (error) {\n CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];\n }\n }\n }\n};\n\nfor (var COLLECTION_NAME in DOMIterables) {\n handlePrototype(global[COLLECTION_NAME] && global[COLLECTION_NAME].prototype, COLLECTION_NAME);\n}\n\nhandlePrototype(DOMTokenListPrototype, 'DOMTokenList');\n","/**\n * The base implementation of `_.propertyOf` without support for deep paths.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Function} Returns the new accessor function.\n */\nfunction basePropertyOf(object) {\n return function(key) {\n return object == null ? undefined : object[key];\n };\n}\n\nmodule.exports = basePropertyOf;\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","'use strict';\nvar internalObjectKeys = require('../internals/object-keys-internal');\nvar enumBugKeys = require('../internals/enum-bug-keys');\n\n// `Object.keys` method\n// https://tc39.es/ecma262/#sec-object.keys\n// eslint-disable-next-line es/no-object-keys -- safe\nmodule.exports = Object.keys || function keys(O) {\n return internalObjectKeys(O, enumBugKeys);\n};\n","// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,\n// backported and transplited with Babel, with backwards-compat fixes\n\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length - 1; i >= 0; i--) {\n var last = parts[i];\n if (last === '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\n var resolvedPath = '',\n resolvedAbsolute = false;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0) ? arguments[i] : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string') {\n throw new TypeError('Arguments to path.resolve must be strings');\n } else if (!path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\n var isAbsolute = exports.isAbsolute(path),\n trailingSlash = substr(path, -1) === '/';\n\n // Normalize the path\n path = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n\n return (isAbsolute ? '/' : '') + path;\n};\n\n// posix version\nexports.isAbsolute = function(path) {\n return path.charAt(0) === '/';\n};\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n if (typeof p !== 'string') {\n throw new TypeError('Arguments to path.join must be strings');\n }\n return p;\n }).join('/'));\n};\n\n\n// path.relative(from, to)\n// posix version\nexports.relative = function(from, to) {\n from = exports.resolve(from).substr(1);\n to = exports.resolve(to).substr(1);\n\n function trim(arr) {\n var start = 0;\n for (; start < arr.length; start++) {\n if (arr[start] !== '') break;\n }\n\n var end = arr.length - 1;\n for (; end >= 0; end--) {\n if (arr[end] !== '') break;\n }\n\n if (start > end) return [];\n return arr.slice(start, end - start + 1);\n }\n\n var fromParts = trim(from.split('/'));\n var toParts = trim(to.split('/'));\n\n var length = Math.min(fromParts.length, toParts.length);\n var samePartsLength = length;\n for (var i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i;\n break;\n }\n }\n\n var outputParts = [];\n for (var i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..');\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\n\n return outputParts.join('/');\n};\n\nexports.sep = '/';\nexports.delimiter = ':';\n\nexports.dirname = function (path) {\n if (typeof path !== 'string') path = path + '';\n if (path.length === 0) return '.';\n var code = path.charCodeAt(0);\n var hasRoot = code === 47 /*/*/;\n var end = -1;\n var matchedSlash = true;\n for (var i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n\n if (end === -1) return hasRoot ? '/' : '.';\n if (hasRoot && end === 1) {\n // return '//';\n // Backwards-compat fix:\n return '/';\n }\n return path.slice(0, end);\n};\n\nfunction basename(path) {\n if (typeof path !== 'string') path = path + '';\n\n var start = 0;\n var end = -1;\n var matchedSlash = true;\n var i;\n\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n\n if (end === -1) return '';\n return path.slice(start, end);\n}\n\n// Uses a mixed approach for backwards-compatibility, as ext behavior changed\n// in new Node.js versions, so only basename() above is backported here\nexports.basename = function (path, ext) {\n var f = basename(path);\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\nexports.extname = function (path) {\n if (typeof path !== 'string') path = path + '';\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n for (var i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return '';\n }\n return path.slice(startDot, end);\n};\n\nfunction filter (xs, f) {\n if (xs.filter) return xs.filter(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (f(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// String.prototype.substr - negative index don't work in IE8\nvar substr = 'ab'.substr(-1) === 'b'\n ? function (str, start, len) { return str.substr(start, len) }\n : function (str, start, len) {\n if (start < 0) start = str.length + start;\n return str.substr(start, len);\n }\n;\n","'use strict';\nvar hasOwn = require('../internals/has-own-property');\nvar isCallable = require('../internals/is-callable');\nvar toObject = require('../internals/to-object');\nvar sharedKey = require('../internals/shared-key');\nvar CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');\n\nvar IE_PROTO = sharedKey('IE_PROTO');\nvar $Object = Object;\nvar ObjectPrototype = $Object.prototype;\n\n// `Object.getPrototypeOf` method\n// https://tc39.es/ecma262/#sec-object.getprototypeof\n// eslint-disable-next-line es/no-object-getprototypeof -- safe\nmodule.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {\n var object = toObject(O);\n if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];\n var constructor = object.constructor;\n if (isCallable(constructor) && object instanceof constructor) {\n return constructor.prototype;\n } return object instanceof $Object ? ObjectPrototype : null;\n};\n","'use strict';\nvar fails = require('../internals/fails');\n\nmodule.exports = !fails(function () {\n function F() { /* empty */ }\n F.prototype.constructor = null;\n // eslint-disable-next-line es/no-object-getprototypeof -- required for testing\n return Object.getPrototypeOf(new F()) !== F.prototype;\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar $parseInt = require('../internals/number-parse-int');\n\n// `parseInt` method\n// https://tc39.es/ecma262/#sec-parseint-string-radix\n$({ global: true, forced: parseInt !== $parseInt }, {\n parseInt: $parseInt\n});\n","'use strict';\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar addToUnscopables = require('../internals/add-to-unscopables');\nvar Iterators = require('../internals/iterators');\nvar InternalStateModule = require('../internals/internal-state');\nvar defineProperty = require('../internals/object-define-property').f;\nvar defineIterator = require('../internals/iterator-define');\nvar createIterResultObject = require('../internals/create-iter-result-object');\nvar IS_PURE = require('../internals/is-pure');\nvar DESCRIPTORS = require('../internals/descriptors');\n\nvar ARRAY_ITERATOR = 'Array Iterator';\nvar setInternalState = InternalStateModule.set;\nvar getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);\n\n// `Array.prototype.entries` method\n// https://tc39.es/ecma262/#sec-array.prototype.entries\n// `Array.prototype.keys` method\n// https://tc39.es/ecma262/#sec-array.prototype.keys\n// `Array.prototype.values` method\n// https://tc39.es/ecma262/#sec-array.prototype.values\n// `Array.prototype[@@iterator]` method\n// https://tc39.es/ecma262/#sec-array.prototype-@@iterator\n// `CreateArrayIterator` internal method\n// https://tc39.es/ecma262/#sec-createarrayiterator\nmodule.exports = defineIterator(Array, 'Array', function (iterated, kind) {\n setInternalState(this, {\n type: ARRAY_ITERATOR,\n target: toIndexedObject(iterated), // target\n index: 0, // next index\n kind: kind // kind\n });\n// `%ArrayIteratorPrototype%.next` method\n// https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next\n}, function () {\n var state = getInternalState(this);\n var target = state.target;\n var index = state.index++;\n if (!target || index >= target.length) {\n state.target = undefined;\n return createIterResultObject(undefined, true);\n }\n switch (state.kind) {\n case 'keys': return createIterResultObject(index, false);\n case 'values': return createIterResultObject(target[index], false);\n } return createIterResultObject([index, target[index]], false);\n}, 'values');\n\n// argumentsList[@@iterator] is %ArrayProto_values%\n// https://tc39.es/ecma262/#sec-createunmappedargumentsobject\n// https://tc39.es/ecma262/#sec-createmappedargumentsobject\nvar values = Iterators.Arguments = Iterators.Array;\n\n// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables\naddToUnscopables('keys');\naddToUnscopables('values');\naddToUnscopables('entries');\n\n// V8 ~ Chrome 45- bug\nif (!IS_PURE && DESCRIPTORS && values.name !== 'values') try {\n defineProperty(values, 'name', { value: 'values' });\n} catch (error) { /* empty */ }\n","'use strict';\nvar NATIVE_BIND = require('../internals/function-bind-native');\n\nvar FunctionPrototype = Function.prototype;\nvar call = FunctionPrototype.call;\nvar uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);\n\nmodule.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {\n return function () {\n return call.apply(fn, arguments);\n };\n};\n","'use strict';\nvar toString = require('../internals/to-string');\n\nmodule.exports = function (argument, $default) {\n return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);\n};\n","var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n","'use strict';\n\nimport utils from '../utils.js';\nimport AxiosError from '../core/AxiosError.js';\n// temporary hotfix to avoid circular references until AxiosURLSearchParams is refactored\nimport PlatformFormData from '../platform/node/classes/FormData.js';\n\n/**\n * Determines if the given thing is a array or js object.\n *\n * @param {string} thing - The object or array to be visited.\n *\n * @returns {boolean}\n */\nfunction isVisitable(thing) {\n return utils.isPlainObject(thing) || utils.isArray(thing);\n}\n\n/**\n * It removes the brackets from the end of a string\n *\n * @param {string} key - The key of the parameter.\n *\n * @returns {string} the key without the brackets.\n */\nfunction removeBrackets(key) {\n return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;\n}\n\n/**\n * It takes a path, a key, and a boolean, and returns a string\n *\n * @param {string} path - The path to the current key.\n * @param {string} key - The key of the current object being iterated over.\n * @param {string} dots - If true, the key will be rendered with dots instead of brackets.\n *\n * @returns {string} The path to the current key.\n */\nfunction renderKey(path, key, dots) {\n if (!path) return key;\n return path.concat(key).map(function each(token, i) {\n // eslint-disable-next-line no-param-reassign\n token = removeBrackets(token);\n return !dots && i ? '[' + token + ']' : token;\n }).join(dots ? '.' : '');\n}\n\n/**\n * If the array is an array and none of its elements are visitable, then it's a flat array.\n *\n * @param {Array} arr - The array to check\n *\n * @returns {boolean}\n */\nfunction isFlatArray(arr) {\n return utils.isArray(arr) && !arr.some(isVisitable);\n}\n\nconst predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {\n return /^is[A-Z]/.test(prop);\n});\n\n/**\n * Convert a data object to FormData\n *\n * @param {Object} obj\n * @param {?Object} [formData]\n * @param {?Object} [options]\n * @param {Function} [options.visitor]\n * @param {Boolean} [options.metaTokens = true]\n * @param {Boolean} [options.dots = false]\n * @param {?Boolean} [options.indexes = false]\n *\n * @returns {Object}\n **/\n\n/**\n * It converts an object into a FormData object\n *\n * @param {Object} obj - The object to convert to form data.\n * @param {string} formData - The FormData object to append to.\n * @param {Object} options\n *\n * @returns\n */\nfunction toFormData(obj, formData, options) {\n if (!utils.isObject(obj)) {\n throw new TypeError('target must be an object');\n }\n\n // eslint-disable-next-line no-param-reassign\n formData = formData || new (PlatformFormData || FormData)();\n\n // eslint-disable-next-line no-param-reassign\n options = utils.toFlatObject(options, {\n metaTokens: true,\n dots: false,\n indexes: false\n }, false, function defined(option, source) {\n // eslint-disable-next-line no-eq-null,eqeqeq\n return !utils.isUndefined(source[option]);\n });\n\n const metaTokens = options.metaTokens;\n // eslint-disable-next-line no-use-before-define\n const visitor = options.visitor || defaultVisitor;\n const dots = options.dots;\n const indexes = options.indexes;\n const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;\n const useBlob = _Blob && utils.isSpecCompliantForm(formData);\n\n if (!utils.isFunction(visitor)) {\n throw new TypeError('visitor must be a function');\n }\n\n function convertValue(value) {\n if (value === null) return '';\n\n if (utils.isDate(value)) {\n return value.toISOString();\n }\n\n if (!useBlob && utils.isBlob(value)) {\n throw new AxiosError('Blob is not supported. Use a Buffer instead.');\n }\n\n if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {\n return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);\n }\n\n return value;\n }\n\n /**\n * Default visitor.\n *\n * @param {*} value\n * @param {String|Number} key\n * @param {Array} path\n * @this {FormData}\n *\n * @returns {boolean} return true to visit the each prop of the value recursively\n */\n function defaultVisitor(value, key, path) {\n let arr = value;\n\n if (value && !path && typeof value === 'object') {\n if (utils.endsWith(key, '{}')) {\n // eslint-disable-next-line no-param-reassign\n key = metaTokens ? key : key.slice(0, -2);\n // eslint-disable-next-line no-param-reassign\n value = JSON.stringify(value);\n } else if (\n (utils.isArray(value) && isFlatArray(value)) ||\n ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))\n )) {\n // eslint-disable-next-line no-param-reassign\n key = removeBrackets(key);\n\n arr.forEach(function each(el, index) {\n !(utils.isUndefined(el) || el === null) && formData.append(\n // eslint-disable-next-line no-nested-ternary\n indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),\n convertValue(el)\n );\n });\n return false;\n }\n }\n\n if (isVisitable(value)) {\n return true;\n }\n\n formData.append(renderKey(path, key, dots), convertValue(value));\n\n return false;\n }\n\n const stack = [];\n\n const exposedHelpers = Object.assign(predicates, {\n defaultVisitor,\n convertValue,\n isVisitable\n });\n\n function build(value, path) {\n if (utils.isUndefined(value)) return;\n\n if (stack.indexOf(value) !== -1) {\n throw Error('Circular reference detected in ' + path.join('.'));\n }\n\n stack.push(value);\n\n utils.forEach(value, function each(el, key) {\n const result = !(utils.isUndefined(el) || el === null) && visitor.call(\n formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers\n );\n\n if (result === true) {\n build(el, path ? path.concat(key) : [key]);\n }\n });\n\n stack.pop();\n }\n\n if (!utils.isObject(obj)) {\n throw new TypeError('data must be an object');\n }\n\n build(obj);\n\n return formData;\n}\n\nexport default toFormData;\n","'use strict';\nvar getBuiltIn = require('../internals/get-built-in');\nvar hasOwn = require('../internals/has-own-property');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar isPrototypeOf = require('../internals/object-is-prototype-of');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar copyConstructorProperties = require('../internals/copy-constructor-properties');\nvar proxyAccessor = require('../internals/proxy-accessor');\nvar inheritIfRequired = require('../internals/inherit-if-required');\nvar normalizeStringArgument = require('../internals/normalize-string-argument');\nvar installErrorCause = require('../internals/install-error-cause');\nvar installErrorStack = require('../internals/error-stack-install');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar IS_PURE = require('../internals/is-pure');\n\nmodule.exports = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) {\n var STACK_TRACE_LIMIT = 'stackTraceLimit';\n var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1;\n var path = FULL_NAME.split('.');\n var ERROR_NAME = path[path.length - 1];\n var OriginalError = getBuiltIn.apply(null, path);\n\n if (!OriginalError) return;\n\n var OriginalErrorPrototype = OriginalError.prototype;\n\n // V8 9.3- bug https://bugs.chromium.org/p/v8/issues/detail?id=12006\n if (!IS_PURE && hasOwn(OriginalErrorPrototype, 'cause')) delete OriginalErrorPrototype.cause;\n\n if (!FORCED) return OriginalError;\n\n var BaseError = getBuiltIn('Error');\n\n var WrappedError = wrapper(function (a, b) {\n var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined);\n var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError();\n if (message !== undefined) createNonEnumerableProperty(result, 'message', message);\n installErrorStack(result, WrappedError, result.stack, 2);\n if (this && isPrototypeOf(OriginalErrorPrototype, this)) inheritIfRequired(result, this, WrappedError);\n if (arguments.length > OPTIONS_POSITION) installErrorCause(result, arguments[OPTIONS_POSITION]);\n return result;\n });\n\n WrappedError.prototype = OriginalErrorPrototype;\n\n if (ERROR_NAME !== 'Error') {\n if (setPrototypeOf) setPrototypeOf(WrappedError, BaseError);\n else copyConstructorProperties(WrappedError, BaseError, { name: true });\n } else if (DESCRIPTORS && STACK_TRACE_LIMIT in OriginalError) {\n proxyAccessor(WrappedError, OriginalError, STACK_TRACE_LIMIT);\n proxyAccessor(WrappedError, OriginalError, 'prepareStackTrace');\n }\n\n copyConstructorProperties(WrappedError, OriginalError);\n\n if (!IS_PURE) try {\n // Safari 13- bug: WebAssembly errors does not have a proper `.name`\n if (OriginalErrorPrototype.name !== ERROR_NAME) {\n createNonEnumerableProperty(OriginalErrorPrototype, 'name', ERROR_NAME);\n }\n OriginalErrorPrototype.constructor = WrappedError;\n } catch (error) { /* empty */ }\n\n return WrappedError;\n};\n","import '@firebase/firestore';\n//# sourceMappingURL=index.esm.js.map\n","'use strict';\nvar hasOwn = require('../internals/has-own-property');\nvar ownKeys = require('../internals/own-keys');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar definePropertyModule = require('../internals/object-define-property');\n\nmodule.exports = function (target, source, exceptions) {\n var keys = ownKeys(source);\n var defineProperty = definePropertyModule.f;\n var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {\n defineProperty(target, key, getOwnPropertyDescriptor(source, key));\n }\n }\n};\n","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: !0\n});\n\nvar t = require(\"tslib\"), e = require(\"@firebase/app\"), n = require(\"@firebase/logger\"), r = require(\"@firebase/util\"), i = require(\"@firebase/webchannel-wrapper\"), o = require(\"@firebase/component\");\n\nfunction s(t) {\n return t && \"object\" == typeof t && \"default\" in t ? t : {\n default: t\n };\n}\n\nvar u = s(e), a = {\n // Causes are copied from:\n // https://github.com/grpc/grpc/blob/bceec94ea4fc5f0085d81235d8e1c06798dc341a/include/grpc%2B%2B/impl/codegen/status_code_enum.h\n /** Not an error; returned on success. */\n OK: \"ok\",\n /** The operation was cancelled (typically by the caller). */\n CANCELLED: \"cancelled\",\n /** Unknown error or an error from a different error domain. */\n UNKNOWN: \"unknown\",\n /**\n * Client specified an invalid argument. Note that this differs from\n * FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are\n * problematic regardless of the state of the system (e.g., a malformed file\n * name).\n */\n INVALID_ARGUMENT: \"invalid-argument\",\n /**\n * Deadline expired before operation could complete. For operations that\n * change the state of the system, this error may be returned even if the\n * operation has completed successfully. For example, a successful response\n * from a server could have been delayed long enough for the deadline to\n * expire.\n */\n DEADLINE_EXCEEDED: \"deadline-exceeded\",\n /** Some requested entity (e.g., file or directory) was not found. */\n NOT_FOUND: \"not-found\",\n /**\n * Some entity that we attempted to create (e.g., file or directory) already\n * exists.\n */\n ALREADY_EXISTS: \"already-exists\",\n /**\n * The caller does not have permission to execute the specified operation.\n * PERMISSION_DENIED must not be used for rejections caused by exhausting\n * some resource (use RESOURCE_EXHAUSTED instead for those errors).\n * PERMISSION_DENIED must not be used if the caller can not be identified\n * (use UNAUTHENTICATED instead for those errors).\n */\n PERMISSION_DENIED: \"permission-denied\",\n /**\n * The request does not have valid authentication credentials for the\n * operation.\n */\n UNAUTHENTICATED: \"unauthenticated\",\n /**\n * Some resource has been exhausted, perhaps a per-user quota, or perhaps the\n * entire file system is out of space.\n */\n RESOURCE_EXHAUSTED: \"resource-exhausted\",\n /**\n * Operation was rejected because the system is not in a state required for\n * the operation's execution. For example, directory to be deleted may be\n * non-empty, an rmdir operation is applied to a non-directory, etc.\n *\n * A litmus test that may help a service implementor in deciding\n * between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE:\n * (a) Use UNAVAILABLE if the client can retry just the failing call.\n * (b) Use ABORTED if the client should retry at a higher-level\n * (e.g., restarting a read-modify-write sequence).\n * (c) Use FAILED_PRECONDITION if the client should not retry until\n * the system state has been explicitly fixed. E.g., if an \"rmdir\"\n * fails because the directory is non-empty, FAILED_PRECONDITION\n * should be returned since the client should not retry unless\n * they have first fixed up the directory by deleting files from it.\n * (d) Use FAILED_PRECONDITION if the client performs conditional\n * REST Get/Update/Delete on a resource and the resource on the\n * server does not match the condition. E.g., conflicting\n * read-modify-write on the same resource.\n */\n FAILED_PRECONDITION: \"failed-precondition\",\n /**\n * The operation was aborted, typically due to a concurrency issue like\n * sequencer check failures, transaction aborts, etc.\n *\n * See litmus test above for deciding between FAILED_PRECONDITION, ABORTED,\n * and UNAVAILABLE.\n */\n ABORTED: \"aborted\",\n /**\n * Operation was attempted past the valid range. E.g., seeking or reading\n * past end of file.\n *\n * Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed\n * if the system state changes. For example, a 32-bit file system will\n * generate INVALID_ARGUMENT if asked to read at an offset that is not in the\n * range [0,2^32-1], but it will generate OUT_OF_RANGE if asked to read from\n * an offset past the current file size.\n *\n * There is a fair bit of overlap between FAILED_PRECONDITION and\n * OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific error)\n * when it applies so that callers who are iterating through a space can\n * easily look for an OUT_OF_RANGE error to detect when they are done.\n */\n OUT_OF_RANGE: \"out-of-range\",\n /** Operation is not implemented or not supported/enabled in this service. */\n UNIMPLEMENTED: \"unimplemented\",\n /**\n * Internal errors. Means some invariants expected by underlying System has\n * been broken. If you see one of these errors, Something is very broken.\n */\n INTERNAL: \"internal\",\n /**\n * The service is currently unavailable. This is a most likely a transient\n * condition and may be corrected by retrying with a backoff.\n *\n * See litmus test above for deciding between FAILED_PRECONDITION, ABORTED,\n * and UNAVAILABLE.\n */\n UNAVAILABLE: \"unavailable\",\n /** Unrecoverable data loss or corruption. */\n DATA_LOSS: \"data-loss\"\n}, c = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this, n) || this).code = t, r.message = n, r.name = \"FirebaseError\", \n // HACK: We write a toString property directly because Error is not a real\n // class and so inheritance does not work correctly. We could alternatively\n // do the same \"back-door inheritance\" trick that FirebaseError does.\n r.toString = function() {\n return r.name + \": [code=\" + r.code + \"]: \" + r.message;\n }, r;\n }\n return t.__extends(n, e), n;\n}(Error), h = new n.Logger(\"@firebase/firestore\");\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** Converts a Base64 encoded string to a binary string. */\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// Helper methods are needed because variables can't be exported as read/write\nfunction f() {\n return h.logLevel;\n}\n\n/**\n * Sets the verbosity of Cloud Firestore logs (debug, error, or silent).\n *\n * @param logLevel\n * The verbosity you set for activity and error logging. Can be any of\n * the following values:\n *\n * \n * - `debug` for the most verbose logging level, primarily for\n * debugging.
\n * - `error` to log errors only.
\n * `silent` to turn off logging.
\n *
\n */ function l(e) {\n for (var r = [], i = 1; i < arguments.length; i++) r[i - 1] = arguments[i];\n if (h.logLevel <= n.LogLevel.DEBUG) {\n var o = r.map(v);\n h.debug.apply(h, t.__spreadArrays([ \"Firestore (7.24.0): \" + e ], o));\n }\n}\n\nfunction p(e) {\n for (var r = [], i = 1; i < arguments.length; i++) r[i - 1] = arguments[i];\n if (h.logLevel <= n.LogLevel.ERROR) {\n var o = r.map(v);\n h.error.apply(h, t.__spreadArrays([ \"Firestore (7.24.0): \" + e ], o));\n }\n}\n\nfunction d(e) {\n for (var r = [], i = 1; i < arguments.length; i++) r[i - 1] = arguments[i];\n if (h.logLevel <= n.LogLevel.WARN) {\n var o = r.map(v);\n h.warn.apply(h, t.__spreadArrays([ \"Firestore (7.24.0): \" + e ], o));\n }\n}\n\n/**\n * Converts an additional log parameter to a string representation.\n */ function v(t) {\n if (\"string\" == typeof t) return t;\n try {\n return e = t, JSON.stringify(e);\n } catch (e) {\n // Converting to JSON failed, just log the object directly\n return t;\n }\n /**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /** Formats an object as a JSON string, suitable for logging. */ var e;\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Unconditionally fails, throwing an Error with the given message.\n * Messages are stripped in production builds.\n *\n * Returns `never` and can be used in expressions:\n * @example\n * let futureVar = fail('not implemented yet');\n */ function y(t) {\n void 0 === t && (t = \"Unexpected state\");\n // Log the failure in addition to throw an exception, just in case the\n // exception is swallowed.\n var e = \"FIRESTORE (7.24.0) INTERNAL ASSERTION FAILED: \" + t;\n // NOTE: We don't use FirestoreError here because these are internal failures\n // that cannot be handled by the user. (Also it would create a circular\n // dependency between the error and assert modules which doesn't work.)\n throw p(e), new Error(e)\n /**\n * Fails if the given assertion condition is false, throwing an Error with the\n * given message if it did.\n *\n * Messages are stripped in production builds.\n */;\n}\n\nfunction g(t, e) {\n t || y();\n}\n\n/**\n * Casts `obj` to `T`. In non-production builds, verifies that `obj` is an\n * instance of `T` before casting.\n */ function m(t, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ne) {\n return t;\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */ function w(t) {\n var e = 0;\n for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;\n return e;\n}\n\nfunction _(t, e) {\n for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);\n}\n\nfunction b(t) {\n for (var e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;\n return !0;\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Path represents an ordered sequence of string segments.\n */ var I = /** @class */ function() {\n function t(t, e, n) {\n void 0 === e ? e = 0 : e > t.length && y(), void 0 === n ? n = t.length - e : n > t.length - e && y(), \n this.segments = t, this.offset = e, this.t = n;\n }\n return Object.defineProperty(t.prototype, \"length\", {\n get: function() {\n return this.t;\n },\n enumerable: !1,\n configurable: !0\n }), t.prototype.isEqual = function(e) {\n return 0 === t.i(this, e);\n }, t.prototype.child = function(e) {\n var n = this.segments.slice(this.offset, this.limit());\n return e instanceof t ? e.forEach((function(t) {\n n.push(t);\n })) : n.push(e), this.o(n);\n }, \n /** The index of one past the last segment of the path. */ t.prototype.limit = function() {\n return this.offset + this.length;\n }, t.prototype.u = function(t) {\n return t = void 0 === t ? 1 : t, this.o(this.segments, this.offset + t, this.length - t);\n }, t.prototype.h = function() {\n return this.o(this.segments, this.offset, this.length - 1);\n }, t.prototype.l = function() {\n return this.segments[this.offset];\n }, t.prototype._ = function() {\n return this.get(this.length - 1);\n }, t.prototype.get = function(t) {\n return this.segments[this.offset + t];\n }, t.prototype.m = function() {\n return 0 === this.length;\n }, t.prototype.T = function(t) {\n if (t.length < this.length) return !1;\n for (var e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;\n return !0;\n }, t.prototype.I = function(t) {\n if (this.length + 1 !== t.length) return !1;\n for (var e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;\n return !0;\n }, t.prototype.forEach = function(t) {\n for (var e = this.offset, n = this.limit(); e < n; e++) t(this.segments[e]);\n }, t.prototype.A = function() {\n return this.segments.slice(this.offset, this.limit());\n }, t.i = function(t, e) {\n for (var n = Math.min(t.length, e.length), r = 0; r < n; r++) {\n var i = t.get(r), o = e.get(r);\n if (i < o) return -1;\n if (i > o) return 1;\n }\n return t.length < e.length ? -1 : t.length > e.length ? 1 : 0;\n }, t;\n}(), E = /** @class */ function(e) {\n function n() {\n return null !== e && e.apply(this, arguments) || this;\n }\n return t.__extends(n, e), n.prototype.o = function(t, e, r) {\n return new n(t, e, r);\n }, n.prototype.R = function() {\n // NOTE: The client is ignorant of any path segments containing escape\n // sequences (e.g. __id123__) and just passes them through raw (they exist\n // for legacy reasons and should not be used frequently).\n return this.A().join(\"/\");\n }, n.prototype.toString = function() {\n return this.R();\n }, \n /**\n * Creates a resource path from the given slash-delimited string. If multiple\n * arguments are provided, all components are combined. Leading and trailing\n * slashes from all components are ignored.\n */\n n.g = function() {\n for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];\n // NOTE: The client is ignorant of any path segments containing escape\n // sequences (e.g. __id123__) and just passes them through raw (they exist\n // for legacy reasons and should not be used frequently).\n for (var r = [], i = 0, o = t; i < o.length; i++) {\n var s = o[i];\n if (s.indexOf(\"//\") >= 0) throw new c(a.INVALID_ARGUMENT, \"Invalid segment (\" + s + \"). Paths must not contain // in them.\");\n // Strip leading and traling slashed.\n r.push.apply(r, s.split(\"/\").filter((function(t) {\n return t.length > 0;\n })));\n }\n return new n(r);\n }, n.P = function() {\n return new n([]);\n }, n;\n}(I), T = /^[_a-zA-Z][_a-zA-Z0-9]*$/, N = /** @class */ function(e) {\n function n() {\n return null !== e && e.apply(this, arguments) || this;\n }\n return t.__extends(n, e), n.prototype.o = function(t, e, r) {\n return new n(t, e, r);\n }, \n /**\n * Returns true if the string could be used as a segment in a field path\n * without escaping.\n */\n n.V = function(t) {\n return T.test(t);\n }, n.prototype.R = function() {\n return this.A().map((function(t) {\n return t = t.replace(\"\\\\\", \"\\\\\\\\\").replace(\"`\", \"\\\\`\"), n.V(t) || (t = \"`\" + t + \"`\"), \n t;\n })).join(\".\");\n }, n.prototype.toString = function() {\n return this.R();\n }, \n /**\n * Returns true if this field references the key of a document.\n */\n n.prototype.p = function() {\n return 1 === this.length && \"__name__\" === this.get(0);\n }, \n /**\n * The field designating the key of a document.\n */\n n.v = function() {\n return new n([ \"__name__\" ]);\n }, \n /**\n * Parses a field string from the given server-formatted string.\n *\n * - Splitting the empty string is not allowed (for now at least).\n * - Empty segments within the string (e.g. if there are two consecutive\n * separators) are not allowed.\n *\n * TODO(b/37244157): we should make this more strict. Right now, it allows\n * non-identifier path components, even if they aren't escaped.\n */\n n.S = function(t) {\n for (var e = [], r = \"\", i = 0, o = function() {\n if (0 === r.length) throw new c(a.INVALID_ARGUMENT, \"Invalid field path (\" + t + \"). Paths must not be empty, begin with '.', end with '.', or contain '..'\");\n e.push(r), r = \"\";\n }, s = !1; i < t.length; ) {\n var u = t[i];\n if (\"\\\\\" === u) {\n if (i + 1 === t.length) throw new c(a.INVALID_ARGUMENT, \"Path has trailing escape character: \" + t);\n var h = t[i + 1];\n if (\"\\\\\" !== h && \".\" !== h && \"`\" !== h) throw new c(a.INVALID_ARGUMENT, \"Path has invalid escape sequence: \" + t);\n r += h, i += 2;\n } else \"`\" === u ? (s = !s, i++) : \".\" !== u || s ? (r += u, i++) : (o(), i++);\n }\n if (o(), s) throw new c(a.INVALID_ARGUMENT, \"Unterminated ` in path: \" + t);\n return new n(e);\n }, n.P = function() {\n return new n([]);\n }, n;\n}(I), A = /** @class */ function() {\n function t(t) {\n this.path = t;\n }\n return t.D = function(e) {\n return new t(E.g(e));\n }, t.C = function(e) {\n return new t(E.g(e).u(5));\n }, \n /** Returns true if the document is in the specified collectionId. */ t.prototype.N = function(t) {\n return this.path.length >= 2 && this.path.get(this.path.length - 2) === t;\n }, t.prototype.isEqual = function(t) {\n return null !== t && 0 === E.i(this.path, t.path);\n }, t.prototype.toString = function() {\n return this.path.toString();\n }, t.i = function(t, e) {\n return E.i(t.path, e.path);\n }, t.F = function(t) {\n return t.length % 2 == 0;\n }, \n /**\n * Creates and returns a new document key with the given segments.\n *\n * @param segments The segments of the path to the document\n * @return A new instance of DocumentKey\n */\n t.$ = function(e) {\n return new t(new E(e.slice()));\n }, t;\n}();\n\n/**\n * A slash-separated path for navigating resources (documents and collections)\n * within Firestore.\n */\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Validates that no arguments were passed in the invocation of functionName.\n *\n * Forward the magic \"arguments\" variable as second parameter on which the\n * parameter validation is performed:\n * validateNoArgs('myFunction', arguments);\n */\nfunction S(t, e) {\n if (0 !== e.length) throw new c(a.INVALID_ARGUMENT, \"Function \" + t + \"() does not support arguments, but was called with \" + W(e.length, \"argument\") + \".\");\n}\n\n/**\n * Validates the invocation of functionName has the exact number of arguments.\n *\n * Forward the magic \"arguments\" variable as second parameter on which the\n * parameter validation is performed:\n * validateExactNumberOfArgs('myFunction', arguments, 2);\n */ function D(t, e, n) {\n if (e.length !== n) throw new c(a.INVALID_ARGUMENT, \"Function \" + t + \"() requires \" + W(n, \"argument\") + \", but was called with \" + W(e.length, \"argument\") + \".\");\n}\n\n/**\n * Validates the invocation of functionName has at least the provided number of\n * arguments (but can have many more).\n *\n * Forward the magic \"arguments\" variable as second parameter on which the\n * parameter validation is performed:\n * validateAtLeastNumberOfArgs('myFunction', arguments, 2);\n */ function x(t, e, n) {\n if (e.length < n) throw new c(a.INVALID_ARGUMENT, \"Function \" + t + \"() requires at least \" + W(n, \"argument\") + \", but was called with \" + W(e.length, \"argument\") + \".\");\n}\n\n/**\n * Validates the invocation of functionName has number of arguments between\n * the values provided.\n *\n * Forward the magic \"arguments\" variable as second parameter on which the\n * parameter validation is performed:\n * validateBetweenNumberOfArgs('myFunction', arguments, 2, 3);\n */ function L(t, e, n, r) {\n if (e.length < n || e.length > r) throw new c(a.INVALID_ARGUMENT, \"Function \" + t + \"() requires between \" + n + \" and \" + r + \" arguments, but was called with \" + W(e.length, \"argument\") + \".\");\n}\n\n/**\n * Validates the provided argument is an array and has as least the expected\n * number of elements.\n */\n/**\n * Validates the provided positional argument has the native JavaScript type\n * using typeof checks.\n */ function k(t, e, n, r) {\n C(t, e, B(n) + \" argument\", r);\n}\n\n/**\n * Validates the provided argument has the native JavaScript type using\n * typeof checks or is undefined.\n */ function R(t, e, n, r) {\n void 0 !== r && k(t, e, n, r);\n}\n\n/**\n * Validates the provided named option has the native JavaScript type using\n * typeof checks.\n */ function O(t, e, n, r) {\n C(t, e, n + \" option\", r);\n}\n\n/**\n * Validates the provided named option has the native JavaScript type using\n * typeof checks or is undefined.\n */ function P(t, e, n, r) {\n void 0 !== r && O(t, e, n, r);\n}\n\n/**\n * Validates that two boolean options are not set at the same time.\n */\n/**\n * Validates that the provided named option equals one of the expected values.\n */\n/**\n * Validates that the provided named option equals one of the expected values or\n * is undefined.\n */\nfunction V(t, e, n, r, i) {\n void 0 !== r && function(t, e, n, r, i) {\n for (var o = [], s = 0, u = i; s < u.length; s++) {\n var h = u[s];\n if (h === r) return;\n o.push(M(h));\n }\n var f = M(r);\n throw new c(a.INVALID_ARGUMENT, \"Invalid value \" + f + \" provided to function \" + t + '() for option \"' + n + '\". Acceptable values: ' + o.join(\", \"));\n }(t, 0, n, r, i);\n}\n\n/**\n * Validates that the provided argument is a valid enum.\n *\n * @param functionName Function making the validation call.\n * @param enums Array containing all possible values for the enum.\n * @param position Position of the argument in `functionName`.\n * @param argument Argument to validate.\n * @return The value as T if the argument can be converted.\n */ function U(t, e, n, r) {\n if (!e.some((function(t) {\n return t === r;\n }))) throw new c(a.INVALID_ARGUMENT, \"Invalid value \" + M(r) + \" provided to function \" + t + \"() for its \" + B(n) + \" argument. Acceptable values: \" + e.join(\", \"));\n return r;\n}\n\n/** Helper to validate the type of a provided input. */ function C(t, e, n, r) {\n if (!(\"object\" === e ? F(r) : \"non-empty string\" === e ? \"string\" == typeof r && \"\" !== r : typeof r === e)) {\n var i = M(r);\n throw new c(a.INVALID_ARGUMENT, \"Function \" + t + \"() requires its \" + n + \" to be of type \" + e + \", but it was: \" + i);\n }\n}\n\n/**\n * Returns true if it's a non-null object without a custom prototype\n * (i.e. excludes Array, Date, etc.).\n */ function F(t) {\n return \"object\" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));\n}\n\n/** Returns a string describing the type / value of the provided input. */ function M(t) {\n if (void 0 === t) return \"undefined\";\n if (null === t) return \"null\";\n if (\"string\" == typeof t) return t.length > 20 && (t = t.substring(0, 20) + \"...\"), \n JSON.stringify(t);\n if (\"number\" == typeof t || \"boolean\" == typeof t) return \"\" + t;\n if (\"object\" == typeof t) {\n if (t instanceof Array) return \"an array\";\n var e = \n /** Hacky method to try to get the constructor name for an object. */\n function(t) {\n if (t.constructor) {\n var e = /function\\s+([^\\s(]+)\\s*\\(/.exec(t.constructor.toString());\n if (e && e.length > 1) return e[1];\n }\n return null;\n }(t);\n return e ? \"a custom \" + e + \" object\" : \"an object\";\n }\n return \"function\" == typeof t ? \"a function\" : y();\n}\n\nfunction q(t, e, n) {\n if (void 0 === n) throw new c(a.INVALID_ARGUMENT, \"Function \" + t + \"() requires a valid \" + B(e) + \" argument, but it was undefined.\");\n}\n\n/**\n * Validates the provided positional argument is an object, and its keys and\n * values match the expected keys and types provided in optionTypes.\n */ function j(t, e, n) {\n _(e, (function(e, r) {\n if (n.indexOf(e) < 0) throw new c(a.INVALID_ARGUMENT, \"Unknown option '\" + e + \"' passed to function \" + t + \"(). Available options: \" + n.join(\", \"));\n }));\n}\n\n/**\n * Helper method to throw an error that the provided argument did not pass\n * an instanceof check.\n */ function G(t, e, n, r) {\n var i = M(r);\n return new c(a.INVALID_ARGUMENT, \"Function \" + t + \"() requires its \" + B(n) + \" argument to be a \" + e + \", but it was: \" + i);\n}\n\nfunction z(t, e, n) {\n if (n <= 0) throw new c(a.INVALID_ARGUMENT, \"Function \" + t + \"() requires its \" + B(e) + \" argument to be a positive number, but it was: \" + n + \".\");\n}\n\n/** Converts a number to its english word representation */ function B(t) {\n switch (t) {\n case 1:\n return \"first\";\n\n case 2:\n return \"second\";\n\n case 3:\n return \"third\";\n\n default:\n return t + \"th\";\n }\n}\n\n/**\n * Formats the given word as plural conditionally given the preceding number.\n */ function W(t, e) {\n return t + \" \" + e + (1 === t ? \"\" : \"s\");\n}\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Generates `nBytes` of random bytes.\n *\n * If `nBytes < 0` , an error will be thrown.\n */ function K(t) {\n // Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.\n var e = \n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n \"undefined\" != typeof self && (self.crypto || self.msCrypto), n = new Uint8Array(t);\n if (e && \"function\" == typeof e.getRandomValues) e.getRandomValues(n); else \n // Falls back to Math.random\n for (var r = 0; r < t; r++) n[r] = Math.floor(256 * Math.random());\n return n;\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */ var Q = /** @class */ function() {\n function t() {}\n return t.k = function() {\n for (\n // Alphanumeric characters\n var t = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\", e = Math.floor(256 / t.length) * t.length, n = \"\"\n // The largest byte value that is a multiple of `char.length`.\n ; n.length < 20; ) for (var r = K(40), i = 0; i < r.length; ++i) \n // Only accept values that are [0, maxMultiple), this ensures they can\n // be evenly mapped to indices of `chars` via a modulo operation.\n n.length < 20 && r[i] < e && (n += t.charAt(r[i] % t.length));\n return n;\n }, t;\n}();\n\nfunction H(t, e) {\n return t < e ? -1 : t > e ? 1 : 0;\n}\n\n/** Helper to compare arrays using isEqual(). */ function Y(t, e, n) {\n return t.length === e.length && t.every((function(t, r) {\n return n(t, e[r]);\n }));\n}\n\n/**\n * Returns the immediate lexicographically-following string. This is useful to\n * construct an inclusive range for indexeddb iterators.\n */ function $(t) {\n // Return the input string, with an additional NUL byte appended.\n return t + \"\\0\";\n}\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Immutable class that represents a \"proto\" byte string.\n *\n * Proto byte strings can either be Base64-encoded strings or Uint8Arrays when\n * sent on the wire. This class abstracts away this differentiation by holding\n * the proto byte string in a common class that must be converted into a string\n * before being sent as a proto.\n */ var X = /** @class */ function() {\n function t(t) {\n this.M = t;\n }\n return t.fromBase64String = function(e) {\n return new t(atob(e));\n }, t.fromUint8Array = function(e) {\n return new t(\n /**\n * Helper function to convert an Uint8array to a binary string.\n */\n function(t) {\n for (var e = \"\", n = 0; n < t.length; ++n) e += String.fromCharCode(t[n]);\n return e;\n }(e));\n }, t.prototype.toBase64 = function() {\n return t = this.M, btoa(t);\n /** Converts a binary string to a Base64 encoded string. */ var t;\n /** True if and only if the Base64 conversion functions are available. */ }, \n t.prototype.toUint8Array = function() {\n return function(t) {\n for (var e = new Uint8Array(t.length), n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);\n return e;\n }(this.M);\n }, t.prototype.O = function() {\n return 2 * this.M.length;\n }, t.prototype.L = function(t) {\n return H(this.M, t.M);\n }, t.prototype.isEqual = function(t) {\n return this.M === t.M;\n }, t;\n}();\n\nX.B = new X(\"\");\n\nvar J = /** @class */ function() {\n function t(t) {\n this.q = t;\n }\n /**\n * Creates a new `Bytes` object from the given Base64 string, converting it to\n * bytes.\n *\n * @param base64 The Base64 string used to create the `Bytes` object.\n */ return t.fromBase64String = function(e) {\n try {\n return new t(X.fromBase64String(e));\n } catch (e) {\n throw new c(a.INVALID_ARGUMENT, \"Failed to construct Bytes from Base64 string: \" + e);\n }\n }, \n /**\n * Creates a new `Bytes` object from the given Uint8Array.\n *\n * @param array The Uint8Array used to create the `Bytes` object.\n */\n t.fromUint8Array = function(e) {\n return new t(X.fromUint8Array(e));\n }, \n /**\n * Returns the underlying bytes as a Base64-encoded string.\n *\n * @return The Base64-encoded string created from the `Bytes` object.\n */\n t.prototype.toBase64 = function() {\n return this.q.toBase64();\n }, \n /**\n * Returns the underlying bytes in a new `Uint8Array`.\n *\n * @return The Uint8Array created from the `Bytes` object.\n */\n t.prototype.toUint8Array = function() {\n return this.q.toUint8Array();\n }, \n /**\n * Returns a string representation of the `Bytes` object.\n *\n * @return A string representation of the `Bytes` object.\n */\n t.prototype.toString = function() {\n return \"Bytes(base64: \" + this.toBase64() + \")\";\n }, \n /**\n * Returns true if this `Bytes` object is equal to the provided one.\n *\n * @param other The `Bytes` object to compare against.\n * @return true if this `Bytes` object is equal to the provided one.\n */\n t.prototype.isEqual = function(t) {\n return this.q.isEqual(t.q);\n }, t;\n}();\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** Helper function to assert Uint8Array is available at runtime. */ function Z() {\n if (\"undefined\" == typeof Uint8Array) throw new c(a.UNIMPLEMENTED, \"Uint8Arrays are not available in this environment.\");\n}\n\n/** Helper function to assert Base64 functions are available at runtime. */ function tt() {\n if (\"undefined\" == typeof atob) throw new c(a.UNIMPLEMENTED, \"Blobs are unavailable in Firestore in this environment.\");\n}\n\n/**\n * Immutable class holding a blob (binary data).\n *\n * This class is directly exposed in the public API. It extends the Bytes class\n * of the firestore-exp API to support `instanceof Bytes` checks during user\n * data conversion.\n *\n * Note that while you can't hide the constructor in JavaScript code, we are\n * using the hack above to make sure no-one outside this module can call it.\n */ var et = /** @class */ function(e) {\n function n() {\n return null !== e && e.apply(this, arguments) || this;\n }\n return t.__extends(n, e), n.fromBase64String = function(t) {\n D(\"Blob.fromBase64String\", arguments, 1), k(\"Blob.fromBase64String\", \"string\", 1, t), \n tt();\n try {\n return new n(X.fromBase64String(t));\n } catch (t) {\n throw new c(a.INVALID_ARGUMENT, \"Failed to construct Blob from Base64 string: \" + t);\n }\n }, n.fromUint8Array = function(t) {\n if (D(\"Blob.fromUint8Array\", arguments, 1), Z(), !(t instanceof Uint8Array)) throw G(\"Blob.fromUint8Array\", \"Uint8Array\", 1, t);\n return new n(X.fromUint8Array(t));\n }, n.prototype.toBase64 = function() {\n return D(\"Blob.toBase64\", arguments, 0), tt(), e.prototype.toBase64.call(this);\n }, n.prototype.toUint8Array = function() {\n return D(\"Blob.toUint8Array\", arguments, 0), Z(), e.prototype.toUint8Array.call(this);\n }, n.prototype.toString = function() {\n return \"Blob(base64: \" + this.toBase64() + \")\";\n }, n;\n}(J), nt = \n/**\n * Constructs a DatabaseInfo using the provided host, databaseId and\n * persistenceKey.\n *\n * @param databaseId The database to use.\n * @param persistenceKey A unique identifier for this Firestore's local\n * storage (used in conjunction with the databaseId).\n * @param host The Firestore backend host to connect to.\n * @param ssl Whether to use SSL when connecting.\n * @param forceLongPolling Whether to use the forceLongPolling option\n * when using WebChannel as the network transport.\n * @param autoDetectLongPolling Whether to use the detectBufferingProxy\n * option when using WebChannel as the network transport.\n */\nfunction(t, e, n, r, i, o) {\n this.U = t, this.persistenceKey = e, this.host = n, this.ssl = r, this.forceLongPolling = i, \n this.W = o;\n}, rt = /** @class */ function() {\n function t(t, e) {\n this.projectId = t, this.database = e || \"(default)\";\n }\n return Object.defineProperty(t.prototype, \"j\", {\n get: function() {\n return \"(default)\" === this.database;\n },\n enumerable: !1,\n configurable: !0\n }), t.prototype.isEqual = function(e) {\n return e instanceof t && e.projectId === this.projectId && e.database === this.database;\n }, t.prototype.L = function(t) {\n return H(this.projectId, t.projectId) || H(this.database, t.database);\n }, t;\n}(), it = /** @class */ function() {\n function t(t, e) {\n this.K = t, this.G = e, \n /**\n * The inner map for a key -> value pair. Due to the possibility of\n * collisions we keep a list of entries that we do a linear search through\n * to find an actual match. Note that collisions should be rare, so we still\n * expect near constant time lookups in practice.\n */\n this.H = {}\n /** Get a value for this key, or undefined if it does not exist. */;\n }\n return t.prototype.get = function(t) {\n var e = this.K(t), n = this.H[e];\n if (void 0 !== n) for (var r = 0, i = n; r < i.length; r++) {\n var o = i[r], s = o[0], u = o[1];\n if (this.G(s, t)) return u;\n }\n }, t.prototype.has = function(t) {\n return void 0 !== this.get(t);\n }, \n /** Put this key and value in the map. */ t.prototype.set = function(t, e) {\n var n = this.K(t), r = this.H[n];\n if (void 0 !== r) {\n for (var i = 0; i < r.length; i++) if (this.G(r[i][0], t)) return void (r[i] = [ t, e ]);\n r.push([ t, e ]);\n } else this.H[n] = [ [ t, e ] ];\n }, \n /**\n * Remove this key from the map. Returns a boolean if anything was deleted.\n */\n t.prototype.delete = function(t) {\n var e = this.K(t), n = this.H[e];\n if (void 0 === n) return !1;\n for (var r = 0; r < n.length; r++) if (this.G(n[r][0], t)) return 1 === n.length ? delete this.H[e] : n.splice(r, 1), \n !0;\n return !1;\n }, t.prototype.forEach = function(t) {\n _(this.H, (function(e, n) {\n for (var r = 0, i = n; r < i.length; r++) {\n var o = i[r], s = o[0], u = o[1];\n t(s, u);\n }\n }));\n }, t.prototype.m = function() {\n return b(this.H);\n }, t;\n}(), ot = /** @class */ function() {\n /**\n * Creates a new timestamp.\n *\n * @param seconds The number of seconds of UTC time since Unix epoch\n * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n * 9999-12-31T23:59:59Z inclusive.\n * @param nanoseconds The non-negative fractions of a second at nanosecond\n * resolution. Negative second values with fractions must still have\n * non-negative nanoseconds values that count forward in time. Must be\n * from 0 to 999,999,999 inclusive.\n */\n function t(t, e) {\n if (this.seconds = t, this.nanoseconds = e, e < 0) throw new c(a.INVALID_ARGUMENT, \"Timestamp nanoseconds out of range: \" + e);\n if (e >= 1e9) throw new c(a.INVALID_ARGUMENT, \"Timestamp nanoseconds out of range: \" + e);\n if (t < -62135596800) throw new c(a.INVALID_ARGUMENT, \"Timestamp seconds out of range: \" + t);\n // This will break in the year 10,000.\n if (t >= 253402300800) throw new c(a.INVALID_ARGUMENT, \"Timestamp seconds out of range: \" + t);\n }\n /**\n * Creates a new timestamp with the current date, with millisecond precision.\n *\n * @return a new timestamp representing the current date.\n */ return t.now = function() {\n return t.fromMillis(Date.now());\n }, \n /**\n * Creates a new timestamp from the given date.\n *\n * @param date The date to initialize the `Timestamp` from.\n * @return A new `Timestamp` representing the same point in time as the given\n * date.\n */\n t.fromDate = function(e) {\n return t.fromMillis(e.getTime());\n }, \n /**\n * Creates a new timestamp from the given number of milliseconds.\n *\n * @param milliseconds Number of milliseconds since Unix epoch\n * 1970-01-01T00:00:00Z.\n * @return A new `Timestamp` representing the same point in time as the given\n * number of milliseconds.\n */\n t.fromMillis = function(e) {\n var n = Math.floor(e / 1e3);\n return new t(n, 1e6 * (e - 1e3 * n));\n }, \n /**\n * Converts a `Timestamp` to a JavaScript `Date` object. This conversion causes\n * a loss of precision since `Date` objects only support millisecond precision.\n *\n * @return JavaScript `Date` object representing the same point in time as\n * this `Timestamp`, with millisecond precision.\n */\n t.prototype.toDate = function() {\n return new Date(this.toMillis());\n }, \n /**\n * Converts a `Timestamp` to a numeric timestamp (in milliseconds since\n * epoch). This operation causes a loss of precision.\n *\n * @return The point in time corresponding to this timestamp, represented as\n * the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.\n */\n t.prototype.toMillis = function() {\n return 1e3 * this.seconds + this.nanoseconds / 1e6;\n }, t.prototype.Y = function(t) {\n return this.seconds === t.seconds ? H(this.nanoseconds, t.nanoseconds) : H(this.seconds, t.seconds);\n }, \n /**\n * Returns true if this `Timestamp` is equal to the provided one.\n *\n * @param other The `Timestamp` to compare against.\n * @return true if this `Timestamp` is equal to the provided one.\n */\n t.prototype.isEqual = function(t) {\n return t.seconds === this.seconds && t.nanoseconds === this.nanoseconds;\n }, t.prototype.toString = function() {\n return \"Timestamp(seconds=\" + this.seconds + \", nanoseconds=\" + this.nanoseconds + \")\";\n }, t.prototype.toJSON = function() {\n return {\n seconds: this.seconds,\n nanoseconds: this.nanoseconds\n };\n }, \n /**\n * Converts this object to a primitive string, which allows Timestamp objects to be compared\n * using the `>`, `<=`, `>=` and `>` operators.\n */\n t.prototype.valueOf = function() {\n // This method returns a string of the form . where is\n // translated to have a non-negative value and both and are left-padded\n // with zeroes to be a consistent length. Strings with this format then have a lexiographical\n // ordering that matches the expected ordering. The translation is done to avoid\n // having a leading negative sign (i.e. a leading '-' character) in its string representation,\n // which would affect its lexiographical ordering.\n var t = this.seconds - -62135596800;\n // Note: Up to 12 decimal digits are required to represent all valid 'seconds' values.\n return String(t).padStart(12, \"0\") + \".\" + String(this.nanoseconds).padStart(9, \"0\");\n }, t;\n}(), st = /** @class */ function() {\n function t(t) {\n this.timestamp = t;\n }\n return t.J = function(e) {\n return new t(e);\n }, t.min = function() {\n return new t(new ot(0, 0));\n }, t.prototype.L = function(t) {\n return this.timestamp.Y(t.timestamp);\n }, t.prototype.isEqual = function(t) {\n return this.timestamp.isEqual(t.timestamp);\n }, \n /** Returns a number representation of the version for use in spec tests. */ t.prototype.X = function() {\n // Convert to microseconds.\n return 1e6 * this.timestamp.seconds + this.timestamp.nanoseconds / 1e3;\n }, t.prototype.toString = function() {\n return \"SnapshotVersion(\" + this.timestamp.toString() + \")\";\n }, t.prototype.Z = function() {\n return this.timestamp;\n }, t;\n}();\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Returns whether a variable is either undefined or null.\n */\nfunction ut(t) {\n return null == t;\n}\n\n/** Returns whether the value represents -0. */ function at(t) {\n // Detect if the value is -0.0. Based on polyfill from\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n return 0 === t && 1 / t == -1 / 0;\n}\n\n/**\n * Returns whether a value is an integer and in the safe integer range\n * @param value The value to test for being an integer and in the safe range\n */ function ct(t) {\n return \"number\" == typeof t && Number.isInteger(t) && !at(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;\n}\n\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// Visible for testing\nvar ht = function(t, e, n, r, i, o, s) {\n void 0 === e && (e = null), void 0 === n && (n = []), void 0 === r && (r = []), \n void 0 === i && (i = null), void 0 === o && (o = null), void 0 === s && (s = null), \n this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = i, \n this.startAt = o, this.endAt = s, this.tt = null;\n};\n\n/**\n * Initializes a Target with a path and optional additional query constraints.\n * Path must currently be empty if this is a collection group query.\n *\n * NOTE: you should always construct `Target` from `Query.toTarget` instead of\n * using this factory method, because `Query` provides an implicit `orderBy`\n * property.\n */ function ft(t, e, n, r, i, o, s) {\n return void 0 === e && (e = null), void 0 === n && (n = []), void 0 === r && (r = []), \n void 0 === i && (i = null), void 0 === o && (o = null), void 0 === s && (s = null), \n new ht(t, e, n, r, i, o, s);\n}\n\nfunction lt(t) {\n var e = m(t);\n if (null === e.tt) {\n var n = e.path.R();\n null !== e.collectionGroup && (n += \"|cg:\" + e.collectionGroup), n += \"|f:\", n += e.filters.map((function(t) {\n return function(t) {\n // TODO(b/29183165): Technically, this won't be unique if two values have\n // the same description, such as the int 3 and the string \"3\". So we should\n // add the types in here somehow, too.\n return t.field.R() + t.op.toString() + re(t.value);\n }(t);\n })).join(\",\"), n += \"|ob:\", n += e.orderBy.map((function(t) {\n return (e = t).field.R() + e.dir;\n var e;\n })).join(\",\"), ut(e.limit) || (n += \"|l:\", n += e.limit), e.startAt && (n += \"|lb:\", \n n += ar(e.startAt)), e.endAt && (n += \"|ub:\", n += ar(e.endAt)), e.tt = n;\n }\n return e.tt;\n}\n\nfunction pt(t, e) {\n if (t.limit !== e.limit) return !1;\n if (t.orderBy.length !== e.orderBy.length) return !1;\n for (var n = 0; n < t.orderBy.length; n++) if (!pr(t.orderBy[n], e.orderBy[n])) return !1;\n if (t.filters.length !== e.filters.length) return !1;\n for (var r = 0; r < t.filters.length; r++) if (i = t.filters[r], o = e.filters[r], \n i.op !== o.op || !i.field.isEqual(o.field) || !Zt(i.value, o.value)) return !1;\n var i, o;\n return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!hr(t.startAt, e.startAt) && hr(t.endAt, e.endAt);\n}\n\nfunction dt(t) {\n return A.F(t.path) && null === t.collectionGroup && 0 === t.filters.length;\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * An immutable set of metadata that the local store tracks for each target.\n */ var vt, yt, gt = /** @class */ function() {\n function t(\n /** The target being listened to. */\n t, \n /**\n * The target ID to which the target corresponds; Assigned by the\n * LocalStore for user listens and by the SyncEngine for limbo watches.\n */\n e, \n /** The purpose of the target. */\n n, \n /**\n * The sequence number of the last transaction during which this target data\n * was modified.\n */\n r, \n /** The latest snapshot version seen for this target. */\n i\n /**\n * The maximum snapshot version at which the associated view\n * contained no limbo documents.\n */ , o\n /**\n * An opaque, server-assigned token that allows watching a target to be\n * resumed after disconnecting without retransmitting all the data that\n * matches the target. The resume token essentially identifies a point in\n * time from which the server should resume sending results.\n */ , s) {\n void 0 === i && (i = st.min()), void 0 === o && (o = st.min()), void 0 === s && (s = X.B), \n this.target = t, this.targetId = e, this.et = n, this.sequenceNumber = r, this.nt = i, \n this.lastLimboFreeSnapshotVersion = o, this.resumeToken = s;\n }\n /** Creates a new target data instance with an updated sequence number. */ return t.prototype.st = function(e) {\n return new t(this.target, this.targetId, this.et, e, this.nt, this.lastLimboFreeSnapshotVersion, this.resumeToken);\n }, \n /**\n * Creates a new target data instance with an updated resume token and\n * snapshot version.\n */\n t.prototype.it = function(e, n) {\n return new t(this.target, this.targetId, this.et, this.sequenceNumber, n, this.lastLimboFreeSnapshotVersion, e);\n }, \n /**\n * Creates a new target data instance with an updated last limbo free\n * snapshot version number.\n */\n t.prototype.rt = function(e) {\n return new t(this.target, this.targetId, this.et, this.sequenceNumber, this.nt, e, this.resumeToken);\n }, t;\n}(), mt = \n// TODO(b/33078163): just use simplest form of existence filter for now\nfunction(t) {\n this.count = t;\n};\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Determines whether an error code represents a permanent error when received\n * in response to a non-write operation.\n *\n * See isPermanentWriteError for classifying write errors.\n */\nfunction wt(t) {\n switch (t) {\n case a.OK:\n return y();\n\n case a.CANCELLED:\n case a.UNKNOWN:\n case a.DEADLINE_EXCEEDED:\n case a.RESOURCE_EXHAUSTED:\n case a.INTERNAL:\n case a.UNAVAILABLE:\n // Unauthenticated means something went wrong with our token and we need\n // to retry with new credentials which will happen automatically.\n case a.UNAUTHENTICATED:\n return !1;\n\n case a.INVALID_ARGUMENT:\n case a.NOT_FOUND:\n case a.ALREADY_EXISTS:\n case a.PERMISSION_DENIED:\n case a.FAILED_PRECONDITION:\n // Aborted might be retried in some scenarios, but that is dependant on\n // the context and should handled individually by the calling code.\n // See https://cloud.google.com/apis/design/errors.\n case a.ABORTED:\n case a.OUT_OF_RANGE:\n case a.UNIMPLEMENTED:\n case a.DATA_LOSS:\n return !0;\n\n default:\n return y();\n }\n}\n\n/**\n * Determines whether an error code represents a permanent error when received\n * in response to a write operation.\n *\n * Write operations must be handled specially because as of b/119437764, ABORTED\n * errors on the write stream should be retried too (even though ABORTED errors\n * are not generally retryable).\n *\n * Note that during the initial handshake on the write stream an ABORTED error\n * signals that we should discard our stream token (i.e. it is permanent). This\n * means a handshake error should be classified with isPermanentError, above.\n */\n/**\n * Maps an error Code from GRPC status code number, like 0, 1, or 14. These\n * are not the same as HTTP status codes.\n *\n * @returns The Code equivalent to the given GRPC status code. Fails if there\n * is no match.\n */ function _t(t) {\n if (void 0 === t) \n // This shouldn't normally happen, but in certain error cases (like trying\n // to send invalid proto messages) we may get an error with no GRPC code.\n return p(\"GRPC error has no .code\"), a.UNKNOWN;\n switch (t) {\n case vt.OK:\n return a.OK;\n\n case vt.CANCELLED:\n return a.CANCELLED;\n\n case vt.UNKNOWN:\n return a.UNKNOWN;\n\n case vt.DEADLINE_EXCEEDED:\n return a.DEADLINE_EXCEEDED;\n\n case vt.RESOURCE_EXHAUSTED:\n return a.RESOURCE_EXHAUSTED;\n\n case vt.INTERNAL:\n return a.INTERNAL;\n\n case vt.UNAVAILABLE:\n return a.UNAVAILABLE;\n\n case vt.UNAUTHENTICATED:\n return a.UNAUTHENTICATED;\n\n case vt.INVALID_ARGUMENT:\n return a.INVALID_ARGUMENT;\n\n case vt.NOT_FOUND:\n return a.NOT_FOUND;\n\n case vt.ALREADY_EXISTS:\n return a.ALREADY_EXISTS;\n\n case vt.PERMISSION_DENIED:\n return a.PERMISSION_DENIED;\n\n case vt.FAILED_PRECONDITION:\n return a.FAILED_PRECONDITION;\n\n case vt.ABORTED:\n return a.ABORTED;\n\n case vt.OUT_OF_RANGE:\n return a.OUT_OF_RANGE;\n\n case vt.UNIMPLEMENTED:\n return a.UNIMPLEMENTED;\n\n case vt.DATA_LOSS:\n return a.DATA_LOSS;\n\n default:\n return y();\n }\n}\n\n/**\n * Converts an HTTP response's error status to the equivalent error code.\n *\n * @param status An HTTP error response status (\"FAILED_PRECONDITION\",\n * \"UNKNOWN\", etc.)\n * @returns The equivalent Code. Non-matching responses are mapped to\n * Code.UNKNOWN.\n */ (yt = vt || (vt = {}))[yt.OK = 0] = \"OK\", yt[yt.CANCELLED = 1] = \"CANCELLED\", \nyt[yt.UNKNOWN = 2] = \"UNKNOWN\", yt[yt.INVALID_ARGUMENT = 3] = \"INVALID_ARGUMENT\", \nyt[yt.DEADLINE_EXCEEDED = 4] = \"DEADLINE_EXCEEDED\", yt[yt.NOT_FOUND = 5] = \"NOT_FOUND\", \nyt[yt.ALREADY_EXISTS = 6] = \"ALREADY_EXISTS\", yt[yt.PERMISSION_DENIED = 7] = \"PERMISSION_DENIED\", \nyt[yt.UNAUTHENTICATED = 16] = \"UNAUTHENTICATED\", yt[yt.RESOURCE_EXHAUSTED = 8] = \"RESOURCE_EXHAUSTED\", \nyt[yt.FAILED_PRECONDITION = 9] = \"FAILED_PRECONDITION\", yt[yt.ABORTED = 10] = \"ABORTED\", \nyt[yt.OUT_OF_RANGE = 11] = \"OUT_OF_RANGE\", yt[yt.UNIMPLEMENTED = 12] = \"UNIMPLEMENTED\", \nyt[yt.INTERNAL = 13] = \"INTERNAL\", yt[yt.UNAVAILABLE = 14] = \"UNAVAILABLE\", yt[yt.DATA_LOSS = 15] = \"DATA_LOSS\";\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// An immutable sorted map implementation, based on a Left-leaning Red-Black\n// tree.\nvar bt = /** @class */ function() {\n function t(t, e) {\n this.i = t, this.root = e || Et.EMPTY;\n }\n // Returns a copy of the map, with the specified key/value added or replaced.\n return t.prototype.ot = function(e, n) {\n return new t(this.i, this.root.ot(e, n, this.i).copy(null, null, Et.at, null, null));\n }, \n // Returns a copy of the map, with the specified key removed.\n t.prototype.remove = function(e) {\n return new t(this.i, this.root.remove(e, this.i).copy(null, null, Et.at, null, null));\n }, \n // Returns the value of the node with the given key, or null.\n t.prototype.get = function(t) {\n for (var e = this.root; !e.m(); ) {\n var n = this.i(t, e.key);\n if (0 === n) return e.value;\n n < 0 ? e = e.left : n > 0 && (e = e.right);\n }\n return null;\n }, \n // Returns the index of the element in this sorted map, or -1 if it doesn't\n // exist.\n t.prototype.indexOf = function(t) {\n for (\n // Number of nodes that were pruned when descending right\n var e = 0, n = this.root; !n.m(); ) {\n var r = this.i(t, n.key);\n if (0 === r) return e + n.left.size;\n r < 0 ? n = n.left : (\n // Count all nodes left of the node plus the node itself\n e += n.left.size + 1, n = n.right);\n }\n // Node not found\n return -1;\n }, t.prototype.m = function() {\n return this.root.m();\n }, Object.defineProperty(t.prototype, \"size\", {\n // Returns the total number of nodes in the map.\n get: function() {\n return this.root.size;\n },\n enumerable: !1,\n configurable: !0\n }), \n // Returns the minimum key in the map.\n t.prototype.ct = function() {\n return this.root.ct();\n }, \n // Returns the maximum key in the map.\n t.prototype.ut = function() {\n return this.root.ut();\n }, \n // Traverses the map in key order and calls the specified action function\n // for each key/value pair. If action returns true, traversal is aborted.\n // Returns the first truthy value returned by action, or the last falsey\n // value returned by action.\n t.prototype.ht = function(t) {\n return this.root.ht(t);\n }, t.prototype.forEach = function(t) {\n this.ht((function(e, n) {\n return t(e, n), !1;\n }));\n }, t.prototype.toString = function() {\n var t = [];\n return this.ht((function(e, n) {\n return t.push(e + \":\" + n), !1;\n })), \"{\" + t.join(\", \") + \"}\";\n }, \n // Traverses the map in reverse key order and calls the specified action\n // function for each key/value pair. If action returns true, traversal is\n // aborted.\n // Returns the first truthy value returned by action, or the last falsey\n // value returned by action.\n t.prototype.lt = function(t) {\n return this.root.lt(t);\n }, \n // Returns an iterator over the SortedMap.\n t.prototype._t = function() {\n return new It(this.root, null, this.i, !1);\n }, t.prototype.ft = function(t) {\n return new It(this.root, t, this.i, !1);\n }, t.prototype.dt = function() {\n return new It(this.root, null, this.i, !0);\n }, t.prototype.wt = function(t) {\n return new It(this.root, t, this.i, !0);\n }, t;\n}(), It = /** @class */ function() {\n function t(t, e, n, r) {\n this.Tt = r, this.Et = [];\n for (var i = 1; !t.m(); ) if (i = e ? n(t.key, e) : 1, \n // flip the comparison if we're going in reverse\n r && (i *= -1), i < 0) \n // This node is less than our start key. ignore it\n t = this.Tt ? t.left : t.right; else {\n if (0 === i) {\n // This node is exactly equal to our start key. Push it on the stack,\n // but stop iterating;\n this.Et.push(t);\n break;\n }\n // This node is greater than our start key, add it to the stack and move\n // to the next one\n this.Et.push(t), t = this.Tt ? t.right : t.left;\n }\n }\n return t.prototype.It = function() {\n var t = this.Et.pop(), e = {\n key: t.key,\n value: t.value\n };\n if (this.Tt) for (t = t.left; !t.m(); ) this.Et.push(t), t = t.right; else for (t = t.right; !t.m(); ) this.Et.push(t), \n t = t.left;\n return e;\n }, t.prototype.At = function() {\n return this.Et.length > 0;\n }, t.prototype.Rt = function() {\n if (0 === this.Et.length) return null;\n var t = this.Et[this.Et.length - 1];\n return {\n key: t.key,\n value: t.value\n };\n }, t;\n}(), Et = /** @class */ function() {\n function t(e, n, r, i, o) {\n this.key = e, this.value = n, this.color = null != r ? r : t.RED, this.left = null != i ? i : t.EMPTY, \n this.right = null != o ? o : t.EMPTY, this.size = this.left.size + 1 + this.right.size;\n }\n // Returns a copy of the current node, optionally replacing pieces of it.\n return t.prototype.copy = function(e, n, r, i, o) {\n 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);\n }, t.prototype.m = function() {\n return !1;\n }, \n // Traverses the tree in key order and calls the specified action function\n // for each node. If action returns true, traversal is aborted.\n // Returns the first truthy value returned by action, or the last falsey\n // value returned by action.\n t.prototype.ht = function(t) {\n return this.left.ht(t) || t(this.key, this.value) || this.right.ht(t);\n }, \n // Traverses the tree in reverse key order and calls the specified action\n // function for each node. If action returns true, traversal is aborted.\n // Returns the first truthy value returned by action, or the last falsey\n // value returned by action.\n t.prototype.lt = function(t) {\n return this.right.lt(t) || t(this.key, this.value) || this.left.lt(t);\n }, \n // Returns the minimum node in the tree.\n t.prototype.min = function() {\n return this.left.m() ? this : this.left.min();\n }, \n // Returns the maximum key in the tree.\n t.prototype.ct = function() {\n return this.min().key;\n }, \n // Returns the maximum key in the tree.\n t.prototype.ut = function() {\n return this.right.m() ? this.key : this.right.ut();\n }, \n // Returns new tree, with the key/value added.\n t.prototype.ot = function(t, e, n) {\n var r = this, i = n(t, r.key);\n return (r = i < 0 ? r.copy(null, null, null, r.left.ot(t, e, n), null) : 0 === i ? r.copy(null, e, null, null, null) : r.copy(null, null, null, null, r.right.ot(t, e, n))).gt();\n }, t.prototype.Pt = function() {\n if (this.left.m()) return t.EMPTY;\n var e = this;\n return e.left.yt() || e.left.left.yt() || (e = e.Vt()), (e = e.copy(null, null, null, e.left.Pt(), null)).gt();\n }, \n // Returns new tree, with the specified item removed.\n t.prototype.remove = function(e, n) {\n var r, i = this;\n if (n(e, i.key) < 0) i.left.m() || i.left.yt() || i.left.left.yt() || (i = i.Vt()), \n i = i.copy(null, null, null, i.left.remove(e, n), null); else {\n if (i.left.yt() && (i = i.bt()), i.right.m() || i.right.yt() || i.right.left.yt() || (i = i.vt()), \n 0 === n(e, i.key)) {\n if (i.right.m()) return t.EMPTY;\n r = i.right.min(), i = i.copy(r.key, r.value, null, null, i.right.Pt());\n }\n i = i.copy(null, null, null, null, i.right.remove(e, n));\n }\n return i.gt();\n }, t.prototype.yt = function() {\n return this.color;\n }, \n // Returns new tree after performing any needed rotations.\n t.prototype.gt = function() {\n var t = this;\n return t.right.yt() && !t.left.yt() && (t = t.St()), t.left.yt() && t.left.left.yt() && (t = t.bt()), \n t.left.yt() && t.right.yt() && (t = t.Dt()), t;\n }, t.prototype.Vt = function() {\n var t = this.Dt();\n return t.right.left.yt() && (t = (t = (t = t.copy(null, null, null, null, t.right.bt())).St()).Dt()), \n t;\n }, t.prototype.vt = function() {\n var t = this.Dt();\n return t.left.left.yt() && (t = (t = t.bt()).Dt()), t;\n }, t.prototype.St = function() {\n var e = this.copy(null, null, t.RED, null, this.right.left);\n return this.right.copy(null, null, this.color, e, null);\n }, t.prototype.bt = function() {\n var e = this.copy(null, null, t.RED, this.left.right, null);\n return this.left.copy(null, null, this.color, null, e);\n }, t.prototype.Dt = function() {\n var t = this.left.copy(null, null, !this.left.color, null, null), e = this.right.copy(null, null, !this.right.color, null, null);\n return this.copy(null, null, !this.color, t, e);\n }, \n // For testing.\n t.prototype.Ct = function() {\n var t = this.Nt();\n return Math.pow(2, t) <= this.size + 1;\n }, \n // In a balanced RB tree, the black-depth (number of black nodes) from root to\n // leaves is equal on both sides. This function verifies that or asserts.\n t.prototype.Nt = function() {\n if (this.yt() && this.left.yt()) throw y();\n if (this.right.yt()) throw y();\n var t = this.left.Nt();\n if (t !== this.right.Nt()) throw y();\n return t + (this.yt() ? 0 : 1);\n }, t;\n}();\n\n// end SortedMap\n// An iterator over an LLRBNode.\n// end LLRBNode\n// Empty node is shared between all LLRB trees.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nEt.EMPTY = null, Et.RED = !0, Et.at = !1, \n// end LLRBEmptyNode\nEt.EMPTY = new (/** @class */ function() {\n function t() {\n this.size = 0;\n }\n return Object.defineProperty(t.prototype, \"key\", {\n get: function() {\n throw y();\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"value\", {\n get: function() {\n throw y();\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"color\", {\n get: function() {\n throw y();\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"left\", {\n get: function() {\n throw y();\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"right\", {\n get: function() {\n throw y();\n },\n enumerable: !1,\n configurable: !0\n }), \n // Returns a copy of the current node.\n t.prototype.copy = function(t, e, n, r, i) {\n return this;\n }, \n // Returns a copy of the tree, with the specified key/value added.\n t.prototype.ot = function(t, e, n) {\n return new Et(t, e);\n }, \n // Returns a copy of the tree, with the specified key removed.\n t.prototype.remove = function(t, e) {\n return this;\n }, t.prototype.m = function() {\n return !0;\n }, t.prototype.ht = function(t) {\n return !1;\n }, t.prototype.lt = function(t) {\n return !1;\n }, t.prototype.ct = function() {\n return null;\n }, t.prototype.ut = function() {\n return null;\n }, t.prototype.yt = function() {\n return !1;\n }, \n // For testing.\n t.prototype.Ct = function() {\n return !0;\n }, t.prototype.Nt = function() {\n return 0;\n }, t;\n}());\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * SortedSet is an immutable (copy-on-write) collection that holds elements\n * in order specified by the provided comparator.\n *\n * NOTE: if provided comparator returns 0 for two elements, we consider them to\n * be equal!\n */\nvar Tt = /** @class */ function() {\n function t(t) {\n this.i = t, this.data = new bt(this.i);\n }\n return t.prototype.has = function(t) {\n return null !== this.data.get(t);\n }, t.prototype.first = function() {\n return this.data.ct();\n }, t.prototype.last = function() {\n return this.data.ut();\n }, Object.defineProperty(t.prototype, \"size\", {\n get: function() {\n return this.data.size;\n },\n enumerable: !1,\n configurable: !0\n }), t.prototype.indexOf = function(t) {\n return this.data.indexOf(t);\n }, \n /** Iterates elements in order defined by \"comparator\" */ t.prototype.forEach = function(t) {\n this.data.ht((function(e, n) {\n return t(e), !1;\n }));\n }, \n /** Iterates over `elem`s such that: range[0] <= elem < range[1]. */ t.prototype.Ft = function(t, e) {\n for (var n = this.data.ft(t[0]); n.At(); ) {\n var r = n.It();\n if (this.i(r.key, t[1]) >= 0) return;\n e(r.key);\n }\n }, \n /**\n * Iterates over `elem`s such that: start <= elem until false is returned.\n */\n t.prototype.xt = function(t, e) {\n var n;\n for (n = void 0 !== e ? this.data.ft(e) : this.data._t(); n.At(); ) if (!t(n.It().key)) return;\n }, \n /** Finds the least element greater than or equal to `elem`. */ t.prototype.$t = function(t) {\n var e = this.data.ft(t);\n return e.At() ? e.It().key : null;\n }, t.prototype._t = function() {\n return new Nt(this.data._t());\n }, t.prototype.ft = function(t) {\n return new Nt(this.data.ft(t));\n }, \n /** Inserts or updates an element */ t.prototype.add = function(t) {\n return this.copy(this.data.remove(t).ot(t, !0));\n }, \n /** Deletes an element */ t.prototype.delete = function(t) {\n return this.has(t) ? this.copy(this.data.remove(t)) : this;\n }, t.prototype.m = function() {\n return this.data.m();\n }, t.prototype.kt = function(t) {\n var e = this;\n // Make sure `result` always refers to the larger one of the two sets.\n return e.size < t.size && (e = t, t = this), t.forEach((function(t) {\n e = e.add(t);\n })), e;\n }, t.prototype.isEqual = function(e) {\n if (!(e instanceof t)) return !1;\n if (this.size !== e.size) return !1;\n for (var n = this.data._t(), r = e.data._t(); n.At(); ) {\n var i = n.It().key, o = r.It().key;\n if (0 !== this.i(i, o)) return !1;\n }\n return !0;\n }, t.prototype.A = function() {\n var t = [];\n return this.forEach((function(e) {\n t.push(e);\n })), t;\n }, t.prototype.toString = function() {\n var t = [];\n return this.forEach((function(e) {\n return t.push(e);\n })), \"SortedSet(\" + t.toString() + \")\";\n }, t.prototype.copy = function(e) {\n var n = new t(this.i);\n return n.data = e, n;\n }, t;\n}(), Nt = /** @class */ function() {\n function t(t) {\n this.Mt = t;\n }\n return t.prototype.It = function() {\n return this.Mt.It().key;\n }, t.prototype.At = function() {\n return this.Mt.At();\n }, t;\n}(), At = new bt(A.i);\n\nfunction St() {\n return At;\n}\n\nfunction Dt() {\n return St();\n}\n\nvar xt = new bt(A.i);\n\nfunction Lt() {\n return xt;\n}\n\nvar kt = new bt(A.i), Rt = new Tt(A.i);\n\nfunction Ot() {\n for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];\n for (var n = Rt, r = 0, i = t; r < i.length; r++) {\n var o = i[r];\n n = n.add(o);\n }\n return n;\n}\n\nvar Pt = new Tt(H);\n\nfunction Vt() {\n return Pt;\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * DocumentSet is an immutable (copy-on-write) collection that holds documents\n * in order specified by the provided comparator. We always add a document key\n * comparator on top of what is provided to guarantee document equality based on\n * the key.\n */ var Ut = /** @class */ function() {\n /** The default ordering is by key if the comparator is omitted */\n function t(t) {\n // We are adding document key comparator to the end as it's the only\n // guaranteed unique property of a document.\n this.i = t ? function(e, n) {\n return t(e, n) || A.i(e.key, n.key);\n } : function(t, e) {\n return A.i(t.key, e.key);\n }, this.Ot = Lt(), this.Lt = new bt(this.i)\n /**\n * Returns an empty copy of the existing DocumentSet, using the same\n * comparator.\n */;\n }\n return t.Bt = function(e) {\n return new t(e.i);\n }, t.prototype.has = function(t) {\n return null != this.Ot.get(t);\n }, t.prototype.get = function(t) {\n return this.Ot.get(t);\n }, t.prototype.first = function() {\n return this.Lt.ct();\n }, t.prototype.last = function() {\n return this.Lt.ut();\n }, t.prototype.m = function() {\n return this.Lt.m();\n }, \n /**\n * Returns the index of the provided key in the document set, or -1 if the\n * document key is not present in the set;\n */\n t.prototype.indexOf = function(t) {\n var e = this.Ot.get(t);\n return e ? this.Lt.indexOf(e) : -1;\n }, Object.defineProperty(t.prototype, \"size\", {\n get: function() {\n return this.Lt.size;\n },\n enumerable: !1,\n configurable: !0\n }), \n /** Iterates documents in order defined by \"comparator\" */ t.prototype.forEach = function(t) {\n this.Lt.ht((function(e, n) {\n return t(e), !1;\n }));\n }, \n /** Inserts or updates a document with the same key */ t.prototype.add = function(t) {\n // First remove the element if we have it.\n var e = this.delete(t.key);\n return e.copy(e.Ot.ot(t.key, t), e.Lt.ot(t, null));\n }, \n /** Deletes a document with a given key */ t.prototype.delete = function(t) {\n var e = this.get(t);\n return e ? this.copy(this.Ot.remove(t), this.Lt.remove(e)) : this;\n }, t.prototype.isEqual = function(e) {\n if (!(e instanceof t)) return !1;\n if (this.size !== e.size) return !1;\n for (var n = this.Lt._t(), r = e.Lt._t(); n.At(); ) {\n var i = n.It().key, o = r.It().key;\n if (!i.isEqual(o)) return !1;\n }\n return !0;\n }, t.prototype.toString = function() {\n var t = [];\n return this.forEach((function(e) {\n t.push(e.toString());\n })), 0 === t.length ? \"DocumentSet ()\" : \"DocumentSet (\\n \" + t.join(\" \\n\") + \"\\n)\";\n }, t.prototype.copy = function(e, n) {\n var r = new t;\n return r.i = this.i, r.Ot = e, r.Lt = n, r;\n }, t;\n}(), Ct = /** @class */ function() {\n function t() {\n this.qt = new bt(A.i);\n }\n return t.prototype.track = function(t) {\n var e = t.doc.key, n = this.qt.get(e);\n n ? \n // Merge the new change with the existing change.\n 0 /* Added */ !== t.type && 3 /* Metadata */ === n.type ? this.qt = this.qt.ot(e, t) : 3 /* Metadata */ === t.type && 1 /* Removed */ !== n.type ? this.qt = this.qt.ot(e, {\n type: n.type,\n doc: t.doc\n }) : 2 /* Modified */ === t.type && 2 /* Modified */ === n.type ? this.qt = this.qt.ot(e, {\n type: 2 /* Modified */ ,\n doc: t.doc\n }) : 2 /* Modified */ === t.type && 0 /* Added */ === n.type ? this.qt = this.qt.ot(e, {\n type: 0 /* Added */ ,\n doc: t.doc\n }) : 1 /* Removed */ === t.type && 0 /* Added */ === n.type ? this.qt = this.qt.remove(e) : 1 /* Removed */ === t.type && 2 /* Modified */ === n.type ? this.qt = this.qt.ot(e, {\n type: 1 /* Removed */ ,\n doc: n.doc\n }) : 0 /* Added */ === t.type && 1 /* Removed */ === n.type ? this.qt = this.qt.ot(e, {\n type: 2 /* Modified */ ,\n doc: t.doc\n }) : \n // This includes these cases, which don't make sense:\n // Added->Added\n // Removed->Removed\n // Modified->Added\n // Removed->Modified\n // Metadata->Added\n // Removed->Metadata\n y() : this.qt = this.qt.ot(e, t);\n }, t.prototype.Ut = function() {\n var t = [];\n return this.qt.ht((function(e, n) {\n t.push(n);\n })), t;\n }, t;\n}(), Ft = /** @class */ function() {\n function t(t, e, n, r, i, o, s, u) {\n this.query = t, this.docs = e, this.Qt = n, this.docChanges = r, this.Wt = i, this.fromCache = o, \n this.jt = s, this.Kt = u\n /** Returns a view snapshot as if all documents in the snapshot were added. */;\n }\n return t.Gt = function(e, n, r, i) {\n var o = [];\n return n.forEach((function(t) {\n o.push({\n type: 0 /* Added */ ,\n doc: t\n });\n })), new t(e, n, Ut.Bt(n), o, r, i, \n /* syncStateChanged= */ !0, \n /* excludesMetadataChanges= */ !1);\n }, Object.defineProperty(t.prototype, \"hasPendingWrites\", {\n get: function() {\n return !this.Wt.m();\n },\n enumerable: !1,\n configurable: !0\n }), t.prototype.isEqual = function(t) {\n if (!(this.fromCache === t.fromCache && this.jt === t.jt && this.Wt.isEqual(t.Wt) && Qn(this.query, t.query) && this.docs.isEqual(t.docs) && this.Qt.isEqual(t.Qt))) return !1;\n var e = this.docChanges, n = t.docChanges;\n if (e.length !== n.length) return !1;\n for (var r = 0; r < e.length; r++) if (e[r].type !== n[r].type || !e[r].doc.isEqual(n[r].doc)) return !1;\n return !0;\n }, t;\n}(), Mt = /** @class */ function() {\n function t(\n /**\n * The snapshot version this event brings us up to, or MIN if not set.\n */\n t, \n /**\n * A map from target to changes to the target. See TargetChange.\n */\n e, \n /**\n * A set of targets that is known to be inconsistent. Listens for these\n * targets should be re-established without resume tokens.\n */\n n, \n /**\n * A set of which documents have changed or been deleted, along with the\n * doc's new values (if not deleted).\n */\n r, \n /**\n * A set of which document updates are due only to limbo resolution targets.\n */\n i) {\n this.nt = t, this.zt = e, this.Ht = n, this.Yt = r, this.Jt = i;\n }\n /**\n * HACK: Views require RemoteEvents in order to determine whether the view is\n * CURRENT, but secondary tabs don't receive remote events. So this method is\n * used to create a synthesized RemoteEvent that can be used to apply a\n * CURRENT status change to a View, for queries executed in a different tab.\n */\n // PORTING NOTE: Multi-tab only\n return t.Xt = function(e, n) {\n var r = new Map;\n return r.set(e, qt.Zt(e, n)), new t(st.min(), r, Vt(), St(), Ot());\n }, t;\n}(), qt = /** @class */ function() {\n function t(\n /**\n * An opaque, server-assigned token that allows watching a query to be resumed\n * after disconnecting without retransmitting all the data that matches the\n * query. The resume token essentially identifies a point in time from which\n * the server should resume sending results.\n */\n t, \n /**\n * The \"current\" (synced) status of this target. Note that \"current\"\n * has special meaning in the RPC protocol that implies that a target is\n * both up-to-date and consistent with the rest of the watch stream.\n */\n e, \n /**\n * The set of documents that were newly assigned to this target as part of\n * this remote event.\n */\n n, \n /**\n * The set of documents that were already assigned to this target but received\n * an update during this remote event.\n */\n r, \n /**\n * The set of documents that were removed from this target as part of this\n * remote event.\n */\n i) {\n this.resumeToken = t, this.te = e, this.ee = n, this.ne = r, this.se = i\n /**\n * This method is used to create a synthesized TargetChanges that can be used to\n * apply a CURRENT status change to a View (for queries executed in a different\n * tab) or for new queries (to raise snapshots with correct CURRENT status).\n */;\n }\n return t.Zt = function(e, n) {\n return new t(X.B, n, Ot(), Ot(), Ot());\n }, t;\n}(), jt = function(\n/** The new document applies to all of these targets. */\nt, \n/** The new document is removed from all of these targets. */\ne, \n/** The key of the document for this change. */\nn, \n/**\n * The new document or NoDocument if it was deleted. Is null if the\n * document went out of view without the server sending a new document.\n */\nr) {\n this.ie = t, this.removedTargetIds = e, this.key = n, this.re = r;\n}, Gt = function(t, e) {\n this.targetId = t, this.oe = e;\n}, zt = function(\n/** What kind of change occurred to the watch target. */\nt, \n/** The target IDs that were added/removed/set. */\ne, \n/**\n * An opaque, server-assigned token that allows watching a target to be\n * resumed after disconnecting without retransmitting all the data that\n * matches the target. The resume token essentially identifies a point in\n * time from which the server should resume sending results.\n */\nn\n/** An RPC error indicating why the watch failed. */ , r) {\n void 0 === n && (n = X.B), void 0 === r && (r = null), this.state = t, this.targetIds = e, \n this.resumeToken = n, this.cause = r;\n}, Bt = /** @class */ function() {\n function t() {\n /**\n * The number of pending responses (adds or removes) that we are waiting on.\n * We only consider targets active that have no pending responses.\n */\n this.ae = 0, \n /**\n * Keeps track of the document changes since the last raised snapshot.\n *\n * These changes are continuously updated as we receive document updates and\n * always reflect the current set of changes against the last issued snapshot.\n */\n this.ce = Qt(), \n /** See public getters for explanations of these fields. */\n this.ue = X.B, this.he = !1, \n /**\n * Whether this target state should be included in the next snapshot. We\n * initialize to true so that newly-added targets are included in the next\n * RemoteEvent.\n */\n this.le = !0;\n }\n return Object.defineProperty(t.prototype, \"te\", {\n /**\n * Whether this target has been marked 'current'.\n *\n * 'Current' has special meaning in the RPC protocol: It implies that the\n * Watch backend has sent us all changes up to the point at which the target\n * was added and that the target is consistent with the rest of the watch\n * stream.\n */\n get: function() {\n return this.he;\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"resumeToken\", {\n /** The last resume token sent to us for this target. */ get: function() {\n return this.ue;\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"_e\", {\n /** Whether this target has pending target adds or target removes. */ get: function() {\n return 0 !== this.ae;\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"fe\", {\n /** Whether we have modified any state that should trigger a snapshot. */ get: function() {\n return this.le;\n },\n enumerable: !1,\n configurable: !0\n }), \n /**\n * Applies the resume token to the TargetChange, but only when it has a new\n * value. Empty resumeTokens are discarded.\n */\n t.prototype.de = function(t) {\n t.O() > 0 && (this.le = !0, this.ue = t);\n }, \n /**\n * Creates a target change from the current set of changes.\n *\n * To reset the document changes after raising this snapshot, call\n * `clearPendingChanges()`.\n */\n t.prototype.we = function() {\n var t = Ot(), e = Ot(), n = Ot();\n return this.ce.forEach((function(r, i) {\n switch (i) {\n case 0 /* Added */ :\n t = t.add(r);\n break;\n\n case 2 /* Modified */ :\n e = e.add(r);\n break;\n\n case 1 /* Removed */ :\n n = n.add(r);\n break;\n\n default:\n y();\n }\n })), new qt(this.ue, this.he, t, e, n);\n }, \n /**\n * Resets the document changes and sets `hasPendingChanges` to false.\n */\n t.prototype.me = function() {\n this.le = !1, this.ce = Qt();\n }, t.prototype.Te = function(t, e) {\n this.le = !0, this.ce = this.ce.ot(t, e);\n }, t.prototype.Ee = function(t) {\n this.le = !0, this.ce = this.ce.remove(t);\n }, t.prototype.Ie = function() {\n this.ae += 1;\n }, t.prototype.Ae = function() {\n this.ae -= 1;\n }, t.prototype.Re = function() {\n this.le = !0, this.he = !0;\n }, t;\n}(), Wt = /** @class */ function() {\n function t(t) {\n this.ge = t, \n /** The internal state of all tracked targets. */\n this.Pe = new Map, \n /** Keeps track of the documents to update since the last raised snapshot. */\n this.ye = St(), \n /** A mapping of document keys to their set of target IDs. */\n this.Ve = Kt(), \n /**\n * A list of targets with existence filter mismatches. These targets are\n * known to be inconsistent and their listens needs to be re-established by\n * RemoteStore.\n */\n this.pe = new Tt(H)\n /**\n * Processes and adds the DocumentWatchChange to the current set of changes.\n */;\n }\n return t.prototype.be = function(t) {\n for (var e = 0, n = t.ie; e < n.length; e++) {\n var r = n[e];\n t.re instanceof kn ? this.ve(r, t.re) : t.re instanceof Rn && this.Se(r, t.key, t.re);\n }\n for (var i = 0, o = t.removedTargetIds; i < o.length; i++) {\n var s = o[i];\n this.Se(s, t.key, t.re);\n }\n }, \n /** Processes and adds the WatchTargetChange to the current set of changes. */ t.prototype.De = function(t) {\n var e = this;\n this.Ce(t, (function(n) {\n var r = e.Ne(n);\n switch (t.state) {\n case 0 /* NoChange */ :\n e.Fe(n) && r.de(t.resumeToken);\n break;\n\n case 1 /* Added */ :\n // We need to decrement the number of pending acks needed from watch\n // for this targetId.\n r.Ae(), r._e || \n // We have a freshly added target, so we need to reset any state\n // that we had previously. This can happen e.g. when remove and add\n // back a target for existence filter mismatches.\n r.me(), r.de(t.resumeToken);\n break;\n\n case 2 /* Removed */ :\n // We need to keep track of removed targets to we can post-filter and\n // remove any target changes.\n // We need to decrement the number of pending acks needed from watch\n // for this targetId.\n r.Ae(), r._e || e.removeTarget(n);\n break;\n\n case 3 /* Current */ :\n e.Fe(n) && (r.Re(), r.de(t.resumeToken));\n break;\n\n case 4 /* Reset */ :\n e.Fe(n) && (\n // Reset the target and synthesizes removes for all existing\n // documents. The backend will re-add any documents that still\n // match the target before it sends the next global snapshot.\n e.xe(n), r.de(t.resumeToken));\n break;\n\n default:\n y();\n }\n }));\n }, \n /**\n * Iterates over all targetIds that the watch change applies to: either the\n * targetIds explicitly listed in the change or the targetIds of all currently\n * active targets.\n */\n t.prototype.Ce = function(t, e) {\n var n = this;\n t.targetIds.length > 0 ? t.targetIds.forEach(e) : this.Pe.forEach((function(t, r) {\n n.Fe(r) && e(r);\n }));\n }, \n /**\n * Handles existence filters and synthesizes deletes for filter mismatches.\n * Targets that are invalidated by filter mismatches are added to\n * `pendingTargetResets`.\n */\n t.prototype.$e = function(t) {\n var e = t.targetId, n = t.oe.count, r = this.ke(e);\n if (r) {\n var i = r.target;\n if (dt(i)) if (0 === n) {\n // The existence filter told us the document does not exist. We deduce\n // that this document does not exist and apply a deleted document to\n // our updates. Without applying this deleted document there might be\n // another query that will raise this document as part of a snapshot\n // until it is resolved, essentially exposing inconsistency between\n // queries.\n var o = new A(i.path);\n this.Se(e, o, new Rn(o, st.min()));\n } else g(1 === n); else this.Me(e) !== n && (\n // Existence filter mismatch: We reset the mapping and raise a new\n // snapshot with `isFromCache:true`.\n this.xe(e), this.pe = this.pe.add(e));\n }\n }, \n /**\n * Converts the currently accumulated state into a remote event at the\n * provided snapshot version. Resets the accumulated changes before returning.\n */\n t.prototype.Oe = function(t) {\n var e = this, n = new Map;\n this.Pe.forEach((function(r, i) {\n var o = e.ke(i);\n if (o) {\n if (r.te && dt(o.target)) {\n // Document queries for document that don't exist can produce an empty\n // result set. To update our local cache, we synthesize a document\n // delete if we have not previously received the document. This\n // resolves the limbo state of the document, removing it from\n // limboDocumentRefs.\n // TODO(dimond): Ideally we would have an explicit lookup target\n // instead resulting in an explicit delete message and we could\n // remove this special logic.\n var s = new A(o.target.path);\n null !== e.ye.get(s) || e.Le(i, s) || e.Se(i, s, new Rn(s, t));\n }\n r.fe && (n.set(i, r.we()), r.me());\n }\n }));\n var r = Ot();\n // We extract the set of limbo-only document updates as the GC logic\n // special-cases documents that do not appear in the target cache.\n // TODO(gsoltis): Expand on this comment once GC is available in the JS\n // client.\n this.Ve.forEach((function(t, n) {\n var i = !0;\n n.xt((function(t) {\n var n = e.ke(t);\n return !n || 2 /* LimboResolution */ === n.et || (i = !1, !1);\n })), i && (r = r.add(t));\n }));\n var i = new Mt(t, n, this.pe, this.ye, r);\n return this.ye = St(), this.Ve = Kt(), this.pe = new Tt(H), i;\n }, \n /**\n * Adds the provided document to the internal list of document updates and\n * its document key to the given target's mapping.\n */\n // Visible for testing.\n t.prototype.ve = function(t, e) {\n if (this.Fe(t)) {\n var n = this.Le(t, e.key) ? 2 /* Modified */ : 0 /* Added */;\n this.Ne(t).Te(e.key, n), this.ye = this.ye.ot(e.key, e), this.Ve = this.Ve.ot(e.key, this.Be(e.key).add(t));\n }\n }, \n /**\n * Removes the provided document from the target mapping. If the\n * document no longer matches the target, but the document's state is still\n * known (e.g. we know that the document was deleted or we received the change\n * that caused the filter mismatch), the new document can be provided\n * to update the remote document cache.\n */\n // Visible for testing.\n t.prototype.Se = function(t, e, n) {\n if (this.Fe(t)) {\n var r = this.Ne(t);\n this.Le(t, e) ? r.Te(e, 1 /* Removed */) : \n // The document may have entered and left the target before we raised a\n // snapshot, so we can just ignore the change.\n r.Ee(e), this.Ve = this.Ve.ot(e, this.Be(e).delete(t)), n && (this.ye = this.ye.ot(e, n));\n }\n }, t.prototype.removeTarget = function(t) {\n this.Pe.delete(t);\n }, \n /**\n * Returns the current count of documents in the target. This includes both\n * the number of documents that the LocalStore considers to be part of the\n * target as well as any accumulated changes.\n */\n t.prototype.Me = function(t) {\n var e = this.Ne(t).we();\n return this.ge.qe(t).size + e.ee.size - e.se.size;\n }, \n /**\n * Increment the number of acks needed from watch before we can consider the\n * server to be 'in-sync' with the client's active targets.\n */\n t.prototype.Ie = function(t) {\n this.Ne(t).Ie();\n }, t.prototype.Ne = function(t) {\n var e = this.Pe.get(t);\n return e || (e = new Bt, this.Pe.set(t, e)), e;\n }, t.prototype.Be = function(t) {\n var e = this.Ve.get(t);\n return e || (e = new Tt(H), this.Ve = this.Ve.ot(t, e)), e;\n }, \n /**\n * Verifies that the user is still interested in this target (by calling\n * `getTargetDataForTarget()`) and that we are not waiting for pending ADDs\n * from watch.\n */\n t.prototype.Fe = function(t) {\n var e = null !== this.ke(t);\n return e || l(\"WatchChangeAggregator\", \"Detected inactive target\", t), e;\n }, \n /**\n * Returns the TargetData for an active target (i.e. a target that the user\n * is still interested in that has no outstanding target change requests).\n */\n t.prototype.ke = function(t) {\n var e = this.Pe.get(t);\n return e && e._e ? null : this.ge.Ue(t);\n }, \n /**\n * Resets the state of a Watch target to its initial state (e.g. sets\n * 'current' to false, clears the resume token and removes its target mapping\n * from all documents).\n */\n t.prototype.xe = function(t) {\n var e = this;\n this.Pe.set(t, new Bt), this.ge.qe(t).forEach((function(n) {\n e.Se(t, n, /*updatedDocument=*/ null);\n }));\n }, \n /**\n * Returns whether the LocalStore considers the document to be part of the\n * specified target.\n */\n t.prototype.Le = function(t, e) {\n return this.ge.qe(t).has(e);\n }, t;\n}();\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * DocumentChangeSet keeps track of a set of changes to docs in a query, merging\n * duplicate events for the same doc.\n */ function Kt() {\n return new bt(A.i);\n}\n\nfunction Qt() {\n return new bt(A.i);\n}\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Represents a locally-applied ServerTimestamp.\n *\n * Server Timestamps are backed by MapValues that contain an internal field\n * `__type__` with a value of `server_timestamp`. The previous value and local\n * write time are stored in its `__previous_value__` and `__local_write_time__`\n * fields respectively.\n *\n * Notes:\n * - ServerTimestampValue instances are created as the result of applying a\n * TransformMutation (see TransformMutation.applyTo()). They can only exist in\n * the local view of a document. Therefore they do not need to be parsed or\n * serialized.\n * - When evaluated locally (e.g. for snapshot.data()), they by default\n * evaluate to `null`. This behavior can be configured by passing custom\n * FieldValueOptions to value().\n * - With respect to other ServerTimestampValues, they sort by their\n * localWriteTime.\n */ function Ht(t) {\n var e, n;\n return \"server_timestamp\" === (null === (n = ((null === (e = null == t ? void 0 : t.mapValue) || void 0 === e ? void 0 : e.fields) || {}).__type__) || void 0 === n ? void 0 : n.stringValue);\n}\n\n/**\n * Creates a new ServerTimestamp proto value (using the internal format).\n */\n/**\n * Returns the value of the field before this ServerTimestamp was set.\n *\n * Preserving the previous values allows the user to display the last resoled\n * value until the backend responds with the timestamp.\n */ function Yt(t) {\n var e = t.mapValue.fields.__previous_value__;\n return Ht(e) ? Yt(e) : e;\n}\n\n/**\n * Returns the local time at which this timestamp was first set.\n */ function $t(t) {\n var e = oe(t.mapValue.fields.__local_write_time__.timestampValue);\n return new ot(e.seconds, e.nanos);\n}\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// A RegExp matching ISO 8601 UTC timestamps with optional fraction.\nvar Xt = new RegExp(/^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(?:\\.(\\d+))?Z$/);\n\n/** Extracts the backend's type order for the provided value. */ function Jt(t) {\n return \"nullValue\" in t ? 0 /* NullValue */ : \"booleanValue\" in t ? 1 /* BooleanValue */ : \"integerValue\" in t || \"doubleValue\" in t ? 2 /* NumberValue */ : \"timestampValue\" in t ? 3 /* TimestampValue */ : \"stringValue\" in t ? 5 /* StringValue */ : \"bytesValue\" in t ? 6 /* BlobValue */ : \"referenceValue\" in t ? 7 /* RefValue */ : \"geoPointValue\" in t ? 8 /* GeoPointValue */ : \"arrayValue\" in t ? 9 /* ArrayValue */ : \"mapValue\" in t ? Ht(t) ? 4 /* ServerTimestampValue */ : 10 /* ObjectValue */ : y();\n}\n\n/** Tests `left` and `right` for equality based on the backend semantics. */ function Zt(t, e) {\n var n = Jt(t);\n if (n !== Jt(e)) return !1;\n switch (n) {\n case 0 /* NullValue */ :\n return !0;\n\n case 1 /* BooleanValue */ :\n return t.booleanValue === e.booleanValue;\n\n case 4 /* ServerTimestampValue */ :\n return $t(t).isEqual($t(e));\n\n case 3 /* TimestampValue */ :\n return function(t, e) {\n if (\"string\" == typeof t.timestampValue && \"string\" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length) \n // Use string equality for ISO 8601 timestamps\n return t.timestampValue === e.timestampValue;\n var n = oe(t.timestampValue), r = oe(e.timestampValue);\n return n.seconds === r.seconds && n.nanos === r.nanos;\n }(t, e);\n\n case 5 /* StringValue */ :\n return t.stringValue === e.stringValue;\n\n case 6 /* BlobValue */ :\n return function(t, e) {\n return ue(t.bytesValue).isEqual(ue(e.bytesValue));\n }(t, e);\n\n case 7 /* RefValue */ :\n return t.referenceValue === e.referenceValue;\n\n case 8 /* GeoPointValue */ :\n return function(t, e) {\n return se(t.geoPointValue.latitude) === se(e.geoPointValue.latitude) && se(t.geoPointValue.longitude) === se(e.geoPointValue.longitude);\n }(t, e);\n\n case 2 /* NumberValue */ :\n return function(t, e) {\n if (\"integerValue\" in t && \"integerValue\" in e) return se(t.integerValue) === se(e.integerValue);\n if (\"doubleValue\" in t && \"doubleValue\" in e) {\n var n = se(t.doubleValue), r = se(e.doubleValue);\n return n === r ? at(n) === at(r) : isNaN(n) && isNaN(r);\n }\n return !1;\n }(t, e);\n\n case 9 /* ArrayValue */ :\n return Y(t.arrayValue.values || [], e.arrayValue.values || [], Zt);\n\n case 10 /* ObjectValue */ :\n return function(t, e) {\n var n = t.mapValue.fields || {}, r = e.mapValue.fields || {};\n if (w(n) !== w(r)) return !1;\n for (var i in n) if (n.hasOwnProperty(i) && (void 0 === r[i] || !Zt(n[i], r[i]))) return !1;\n return !0;\n }(t, e);\n\n default:\n return y();\n }\n}\n\nfunction te(t, e) {\n return void 0 !== (t.values || []).find((function(t) {\n return Zt(t, e);\n }));\n}\n\nfunction ee(t, e) {\n var n = Jt(t), r = Jt(e);\n if (n !== r) return H(n, r);\n switch (n) {\n case 0 /* NullValue */ :\n return 0;\n\n case 1 /* BooleanValue */ :\n return H(t.booleanValue, e.booleanValue);\n\n case 2 /* NumberValue */ :\n return function(t, e) {\n var n = se(t.integerValue || t.doubleValue), r = se(e.integerValue || e.doubleValue);\n return n < r ? -1 : n > r ? 1 : n === r ? 0 : \n // one or both are NaN.\n isNaN(n) ? isNaN(r) ? 0 : -1 : 1;\n }(t, e);\n\n case 3 /* TimestampValue */ :\n return ne(t.timestampValue, e.timestampValue);\n\n case 4 /* ServerTimestampValue */ :\n return ne($t(t), $t(e));\n\n case 5 /* StringValue */ :\n return H(t.stringValue, e.stringValue);\n\n case 6 /* BlobValue */ :\n return function(t, e) {\n var n = ue(t), r = ue(e);\n return n.L(r);\n }(t.bytesValue, e.bytesValue);\n\n case 7 /* RefValue */ :\n return function(t, e) {\n for (var n = t.split(\"/\"), r = e.split(\"/\"), i = 0; i < n.length && i < r.length; i++) {\n var o = H(n[i], r[i]);\n if (0 !== o) return o;\n }\n return H(n.length, r.length);\n }(t.referenceValue, e.referenceValue);\n\n case 8 /* GeoPointValue */ :\n return function(t, e) {\n var n = H(se(t.latitude), se(e.latitude));\n return 0 !== n ? n : H(se(t.longitude), se(e.longitude));\n }(t.geoPointValue, e.geoPointValue);\n\n case 9 /* ArrayValue */ :\n return function(t, e) {\n for (var n = t.values || [], r = e.values || [], i = 0; i < n.length && i < r.length; ++i) {\n var o = ee(n[i], r[i]);\n if (o) return o;\n }\n return H(n.length, r.length);\n }(t.arrayValue, e.arrayValue);\n\n case 10 /* ObjectValue */ :\n return function(t, e) {\n var n = t.fields || {}, r = Object.keys(n), i = e.fields || {}, o = Object.keys(i);\n // Even though MapValues are likely sorted correctly based on their insertion\n // order (e.g. when received from the backend), local modifications can bring\n // elements out of order. We need to re-sort the elements to ensure that\n // canonical IDs are independent of insertion order.\n r.sort(), o.sort();\n for (var s = 0; s < r.length && s < o.length; ++s) {\n var u = H(r[s], o[s]);\n if (0 !== u) return u;\n var a = ee(n[r[s]], i[o[s]]);\n if (0 !== a) return a;\n }\n return H(r.length, o.length);\n }(t.mapValue, e.mapValue);\n\n default:\n throw y();\n }\n}\n\nfunction ne(t, e) {\n if (\"string\" == typeof t && \"string\" == typeof e && t.length === e.length) return H(t, e);\n var n = oe(t), r = oe(e), i = H(n.seconds, r.seconds);\n return 0 !== i ? i : H(n.nanos, r.nanos);\n}\n\nfunction re(t) {\n return ie(t);\n}\n\nfunction ie(t) {\n return \"nullValue\" in t ? \"null\" : \"booleanValue\" in t ? \"\" + t.booleanValue : \"integerValue\" in t ? \"\" + t.integerValue : \"doubleValue\" in t ? \"\" + t.doubleValue : \"timestampValue\" in t ? function(t) {\n var e = oe(t);\n return \"time(\" + e.seconds + \",\" + e.nanos + \")\";\n }(t.timestampValue) : \"stringValue\" in t ? t.stringValue : \"bytesValue\" in t ? ue(t.bytesValue).toBase64() : \"referenceValue\" in t ? (n = t.referenceValue, \n A.C(n).toString()) : \"geoPointValue\" in t ? \"geo(\" + (e = t.geoPointValue).latitude + \",\" + e.longitude + \")\" : \"arrayValue\" in t ? function(t) {\n for (var e = \"[\", n = !0, r = 0, i = t.values || []; r < i.length; r++) {\n n ? n = !1 : e += \",\", e += ie(i[r]);\n }\n return e + \"]\";\n }(t.arrayValue) : \"mapValue\" in t ? function(t) {\n for (\n // Iteration order in JavaScript is not guaranteed. To ensure that we generate\n // matching canonical IDs for identical maps, we need to sort the keys.\n var e = \"{\", n = !0, r = 0, i = Object.keys(t.fields || {}).sort(); r < i.length; r++) {\n var o = i[r];\n n ? n = !1 : e += \",\", e += o + \":\" + ie(t.fields[o]);\n }\n return e + \"}\";\n }(t.mapValue) : y();\n var e, n;\n}\n\nfunction oe(t) {\n // The json interface (for the browser) will return an iso timestamp string,\n // while the proto js library (for node) will return a\n // google.protobuf.Timestamp instance.\n if (g(!!t), \"string\" == typeof t) {\n // The date string can have higher precision (nanos) than the Date class\n // (millis), so we do some custom parsing here.\n // Parse the nanos right out of the string.\n var e = 0, n = Xt.exec(t);\n if (g(!!n), n[1]) {\n // Pad the fraction out to 9 digits (nanos).\n var r = n[1];\n r = (r + \"000000000\").substr(0, 9), e = Number(r);\n }\n // Parse the date to get the seconds.\n var i = new Date(t);\n return {\n seconds: Math.floor(i.getTime() / 1e3),\n nanos: e\n };\n }\n return {\n seconds: se(t.seconds),\n nanos: se(t.nanos)\n };\n}\n\n/**\n * Converts the possible Proto types for numbers into a JavaScript number.\n * Returns 0 if the value is not numeric.\n */ function se(t) {\n // TODO(bjornick): Handle int64 greater than 53 bits.\n return \"number\" == typeof t ? t : \"string\" == typeof t ? Number(t) : 0;\n}\n\n/** Converts the possible Proto types for Blobs into a ByteString. */ function ue(t) {\n return \"string\" == typeof t ? X.fromBase64String(t) : X.fromUint8Array(t);\n}\n\n/** Returns a reference value for the provided database and key. */ function ae(t, e) {\n return {\n referenceValue: \"projects/\" + t.projectId + \"/databases/\" + t.database + \"/documents/\" + e.path.R()\n };\n}\n\n/** Returns true if `value` is an IntegerValue . */ function ce(t) {\n return !!t && \"integerValue\" in t;\n}\n\n/** Returns true if `value` is a DoubleValue. */\n/** Returns true if `value` is an ArrayValue. */ function he(t) {\n return !!t && \"arrayValue\" in t;\n}\n\n/** Returns true if `value` is a NullValue. */ function fe(t) {\n return !!t && \"nullValue\" in t;\n}\n\n/** Returns true if `value` is NaN. */ function le(t) {\n return !!t && \"doubleValue\" in t && isNaN(Number(t.doubleValue));\n}\n\n/** Returns true if `value` is a MapValue. */ function pe(t) {\n return !!t && \"mapValue\" in t;\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */ var de = {\n asc: \"ASCENDING\",\n desc: \"DESCENDING\"\n}, ve = {\n \"<\": \"LESS_THAN\",\n \"<=\": \"LESS_THAN_OR_EQUAL\",\n \">\": \"GREATER_THAN\",\n \">=\": \"GREATER_THAN_OR_EQUAL\",\n \"==\": \"EQUAL\",\n \"!=\": \"NOT_EQUAL\",\n \"array-contains\": \"ARRAY_CONTAINS\",\n in: \"IN\",\n \"not-in\": \"NOT_IN\",\n \"array-contains-any\": \"ARRAY_CONTAINS_ANY\"\n}, ye = function(t, e) {\n this.U = t, this.Qe = e;\n};\n\n/**\n * This class generates JsonObject values for the Datastore API suitable for\n * sending to either GRPC stub methods or via the JSON/HTTP REST API.\n *\n * The serializer supports both Protobuf.js and Proto3 JSON formats. By\n * setting `useProto3Json` to true, the serializer will use the Proto3 JSON\n * format.\n *\n * For a description of the Proto3 JSON format check\n * https://developers.google.com/protocol-buffers/docs/proto3#json\n *\n * TODO(klimt): We can remove the databaseId argument if we keep the full\n * resource name in documents.\n */\n/**\n * Returns an IntegerValue for `value`.\n */\nfunction ge(t) {\n return {\n integerValue: \"\" + t\n };\n}\n\n/**\n * Returns an DoubleValue for `value` that is encoded based the serializer's\n * `useProto3Json` setting.\n */ function me(t, e) {\n if (t.Qe) {\n if (isNaN(e)) return {\n doubleValue: \"NaN\"\n };\n if (e === 1 / 0) return {\n doubleValue: \"Infinity\"\n };\n if (e === -1 / 0) return {\n doubleValue: \"-Infinity\"\n };\n }\n return {\n doubleValue: at(e) ? \"-0\" : e\n };\n}\n\n/**\n * Returns a value for a number that's appropriate to put into a proto.\n * The return value is an IntegerValue if it can safely represent the value,\n * otherwise a DoubleValue is returned.\n */ function we(t, e) {\n return ct(e) ? ge(e) : me(t, e);\n}\n\n/**\n * Returns a value for a Date that's appropriate to put into a proto.\n */ function _e(t, e) {\n return t.Qe ? new Date(1e3 * e.seconds).toISOString().replace(/\\.\\d*/, \"\").replace(\"Z\", \"\") + \".\" + (\"000000000\" + e.nanoseconds).slice(-9) + \"Z\" : {\n seconds: \"\" + e.seconds,\n nanos: e.nanoseconds\n };\n}\n\n/**\n * Returns a value for bytes that's appropriate to put in a proto.\n *\n * Visible for testing.\n */ function be(t, e) {\n return t.Qe ? e.toBase64() : e.toUint8Array();\n}\n\n/**\n * Returns a ByteString based on the proto string value.\n */ function Ie(t, e) {\n return _e(t, e.Z());\n}\n\nfunction Ee(t) {\n return g(!!t), st.J(function(t) {\n var e = oe(t);\n return new ot(e.seconds, e.nanos);\n }(t));\n}\n\nfunction Te(t, e) {\n return function(t) {\n return new E([ \"projects\", t.projectId, \"databases\", t.database ]);\n }(t).child(\"documents\").child(e).R();\n}\n\nfunction Ne(t) {\n var e = E.g(t);\n return g(He(e)), e;\n}\n\nfunction Ae(t, e) {\n return Te(t.U, e.path);\n}\n\nfunction Se(t, e) {\n var n = Ne(e);\n return g(n.get(1) === t.U.projectId), g(!n.get(3) && !t.U.database || n.get(3) === t.U.database), \n new A(ke(n));\n}\n\nfunction De(t, e) {\n return Te(t.U, e);\n}\n\nfunction xe(t) {\n var e = Ne(t);\n // In v1beta1 queries for collections at the root did not have a trailing\n // \"/documents\". In v1 all resource paths contain \"/documents\". Preserve the\n // ability to read the v1beta1 form for compatibility with queries persisted\n // in the local target cache.\n return 4 === e.length ? E.P() : ke(e);\n}\n\nfunction Le(t) {\n return new E([ \"projects\", t.U.projectId, \"databases\", t.U.database ]).R();\n}\n\nfunction ke(t) {\n return g(t.length > 4 && \"documents\" === t.get(4)), t.u(5)\n /** Creates a Document proto from key and fields (but no create/update time) */;\n}\n\nfunction Re(t, e, n) {\n return {\n name: Ae(t, e),\n fields: n.proto.mapValue.fields\n };\n}\n\nfunction Oe(t, e) {\n var n;\n if (e instanceof wn) n = {\n update: Re(t, e.key, e.value)\n }; else if (e instanceof Nn) n = {\n delete: Ae(t, e.key)\n }; else if (e instanceof _n) n = {\n update: Re(t, e.key, e.data),\n updateMask: Qe(e.We)\n }; else if (e instanceof In) n = {\n transform: {\n document: Ae(t, e.key),\n fieldTransforms: e.fieldTransforms.map((function(t) {\n return function(t, e) {\n var n = e.transform;\n if (n instanceof Ze) return {\n fieldPath: e.field.R(),\n setToServerValue: \"REQUEST_TIME\"\n };\n if (n instanceof tn) return {\n fieldPath: e.field.R(),\n appendMissingElements: {\n values: n.elements\n }\n };\n if (n instanceof nn) return {\n fieldPath: e.field.R(),\n removeAllFromArray: {\n values: n.elements\n }\n };\n if (n instanceof on) return {\n fieldPath: e.field.R(),\n increment: n.je\n };\n throw y();\n }(0, t);\n }))\n }\n }; else {\n if (!(e instanceof An)) return y();\n n = {\n verify: Ae(t, e.key)\n };\n }\n return e.Ge.Ke || (n.currentDocument = function(t, e) {\n return void 0 !== e.updateTime ? {\n updateTime: Ie(t, e.updateTime)\n } : void 0 !== e.exists ? {\n exists: e.exists\n } : y();\n }(t, e.Ge)), n;\n}\n\nfunction Pe(t, e) {\n var n = e.currentDocument ? function(t) {\n return void 0 !== t.updateTime ? fn.updateTime(Ee(t.updateTime)) : void 0 !== t.exists ? fn.exists(t.exists) : fn.ze();\n }(e.currentDocument) : fn.ze();\n if (e.update) {\n e.update.name;\n var r = Se(t, e.update.name), i = new Sn({\n mapValue: {\n fields: e.update.fields\n }\n });\n if (e.updateMask) {\n var o = function(t) {\n var e = t.fieldPaths || [];\n return new an(e.map((function(t) {\n return N.S(t);\n })));\n }(e.updateMask);\n return new _n(r, i, o, n);\n }\n return new wn(r, i, n);\n }\n if (e.delete) {\n var s = Se(t, e.delete);\n return new Nn(s, n);\n }\n if (e.transform) {\n var u = Se(t, e.transform.document), a = e.transform.fieldTransforms.map((function(e) {\n return function(t, e) {\n var n = null;\n if (\"setToServerValue\" in e) g(\"REQUEST_TIME\" === e.setToServerValue), n = new Ze; else if (\"appendMissingElements\" in e) {\n var r = e.appendMissingElements.values || [];\n n = new tn(r);\n } else if (\"removeAllFromArray\" in e) {\n var i = e.removeAllFromArray.values || [];\n n = new nn(i);\n } else \"increment\" in e ? n = new on(t, e.increment) : y();\n var o = N.S(e.fieldPath);\n return new cn(o, n);\n }(t, e);\n }));\n return g(!0 === n.exists), new In(u, a);\n }\n if (e.verify) {\n var c = Se(t, e.verify);\n return new An(c, n);\n }\n return y();\n}\n\nfunction Ve(t, e) {\n return {\n documents: [ De(t, e.path) ]\n };\n}\n\nfunction Ue(t, e) {\n // Dissect the path into parent, collectionId, and optional key filter.\n var n = {\n structuredQuery: {}\n }, r = e.path;\n null !== e.collectionGroup ? (n.parent = De(t, r), n.structuredQuery.from = [ {\n collectionId: e.collectionGroup,\n allDescendants: !0\n } ]) : (n.parent = De(t, r.h()), n.structuredQuery.from = [ {\n collectionId: r._()\n } ]);\n var i = function(t) {\n if (0 !== t.length) {\n var e = t.map((function(t) {\n // visible for testing\n return function(t) {\n if (\"==\" /* EQUAL */ === t.op) {\n if (le(t.value)) return {\n unaryFilter: {\n field: ze(t.field),\n op: \"IS_NAN\"\n }\n };\n if (fe(t.value)) return {\n unaryFilter: {\n field: ze(t.field),\n op: \"IS_NULL\"\n }\n };\n } else if (\"!=\" /* NOT_EQUAL */ === t.op) {\n if (le(t.value)) return {\n unaryFilter: {\n field: ze(t.field),\n op: \"IS_NOT_NAN\"\n }\n };\n if (fe(t.value)) return {\n unaryFilter: {\n field: ze(t.field),\n op: \"IS_NOT_NULL\"\n }\n };\n }\n return {\n fieldFilter: {\n field: ze(t.field),\n op: Ge(t.op),\n value: t.value\n }\n };\n }(t);\n }));\n return 1 === e.length ? e[0] : {\n compositeFilter: {\n op: \"AND\",\n filters: e\n }\n };\n }\n }(e.filters);\n i && (n.structuredQuery.where = i);\n var o = function(t) {\n if (0 !== t.length) return t.map((function(t) {\n // visible for testing\n return function(t) {\n return {\n field: ze(t.field),\n direction: je(t.dir)\n };\n }(t);\n }));\n }(e.orderBy);\n o && (n.structuredQuery.orderBy = o);\n var s = function(t, e) {\n return t.Qe || ut(e) ? e : {\n value: e\n };\n }(t, e.limit);\n return null !== s && (n.structuredQuery.limit = s), e.startAt && (n.structuredQuery.startAt = Me(e.startAt)), \n e.endAt && (n.structuredQuery.endAt = Me(e.endAt)), n;\n}\n\nfunction Ce(t) {\n var e = xe(t.parent), n = t.structuredQuery, r = n.from ? n.from.length : 0, i = null;\n if (r > 0) {\n g(1 === r);\n var o = n.from[0];\n o.allDescendants ? i = o.collectionId : e = e.child(o.collectionId);\n }\n var s = [];\n n.where && (s = Fe(n.where));\n var u = [];\n n.orderBy && (u = n.orderBy.map((function(t) {\n return function(t) {\n return new fr(Be(t.field), \n // visible for testing\n function(t) {\n switch (t) {\n case \"ASCENDING\":\n return \"asc\" /* ASCENDING */;\n\n case \"DESCENDING\":\n return \"desc\" /* DESCENDING */;\n\n default:\n return;\n }\n }(t.direction));\n }(t);\n })));\n var a = null;\n n.limit && (a = function(t) {\n var e;\n return ut(e = \"object\" == typeof t ? t.value : t) ? null : e;\n }(n.limit));\n var c = null;\n n.startAt && (c = qe(n.startAt));\n var h = null;\n return n.endAt && (h = qe(n.endAt)), zn(Vn(e, i, u, s, a, \"F\" /* First */ , c, h));\n}\n\nfunction Fe(t) {\n return t ? void 0 !== t.unaryFilter ? [ Ke(t) ] : void 0 !== t.fieldFilter ? [ We(t) ] : void 0 !== t.compositeFilter ? t.compositeFilter.filters.map((function(t) {\n return Fe(t);\n })).reduce((function(t, e) {\n return t.concat(e);\n })) : y() : [];\n}\n\nfunction Me(t) {\n return {\n before: t.before,\n values: t.position\n };\n}\n\nfunction qe(t) {\n var e = !!t.before, n = t.values || [];\n return new ur(n, e);\n}\n\n// visible for testing\nfunction je(t) {\n return de[t];\n}\n\nfunction Ge(t) {\n return ve[t];\n}\n\nfunction ze(t) {\n return {\n fieldPath: t.R()\n };\n}\n\nfunction Be(t) {\n return N.S(t.fieldPath);\n}\n\nfunction We(t) {\n return Jn.create(Be(t.fieldFilter.field), function(t) {\n switch (t) {\n case \"EQUAL\":\n return \"==\" /* EQUAL */;\n\n case \"NOT_EQUAL\":\n return \"!=\" /* NOT_EQUAL */;\n\n case \"GREATER_THAN\":\n return \">\" /* GREATER_THAN */;\n\n case \"GREATER_THAN_OR_EQUAL\":\n return \">=\" /* GREATER_THAN_OR_EQUAL */;\n\n case \"LESS_THAN\":\n return \"<\" /* LESS_THAN */;\n\n case \"LESS_THAN_OR_EQUAL\":\n return \"<=\" /* LESS_THAN_OR_EQUAL */;\n\n case \"ARRAY_CONTAINS\":\n return \"array-contains\" /* ARRAY_CONTAINS */;\n\n case \"IN\":\n return \"in\" /* IN */;\n\n case \"NOT_IN\":\n return \"not-in\" /* NOT_IN */;\n\n case \"ARRAY_CONTAINS_ANY\":\n return \"array-contains-any\" /* ARRAY_CONTAINS_ANY */;\n\n case \"OPERATOR_UNSPECIFIED\":\n default:\n return y();\n }\n }(t.fieldFilter.op), t.fieldFilter.value);\n}\n\nfunction Ke(t) {\n switch (t.unaryFilter.op) {\n case \"IS_NAN\":\n var e = Be(t.unaryFilter.field);\n return Jn.create(e, \"==\" /* EQUAL */ , {\n doubleValue: NaN\n });\n\n case \"IS_NULL\":\n var n = Be(t.unaryFilter.field);\n return Jn.create(n, \"==\" /* EQUAL */ , {\n nullValue: \"NULL_VALUE\"\n });\n\n case \"IS_NOT_NAN\":\n var r = Be(t.unaryFilter.field);\n return Jn.create(r, \"!=\" /* NOT_EQUAL */ , {\n doubleValue: NaN\n });\n\n case \"IS_NOT_NULL\":\n var i = Be(t.unaryFilter.field);\n return Jn.create(i, \"!=\" /* NOT_EQUAL */ , {\n nullValue: \"NULL_VALUE\"\n });\n\n case \"OPERATOR_UNSPECIFIED\":\n default:\n return y();\n }\n}\n\nfunction Qe(t) {\n var e = [];\n return t.fields.forEach((function(t) {\n return e.push(t.R());\n })), {\n fieldPaths: e\n };\n}\n\nfunction He(t) {\n // Resource names have at least 4 components (project ID, database ID)\n return t.length >= 4 && \"projects\" === t.get(0) && \"databases\" === t.get(2);\n}\n\n/**\n * @license\n * Copyright 2018 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** Represents a transform within a TransformMutation. */ var Ye = function() {\n // Make sure that the structural type of `TransformOperation` is unique.\n // See https://github.com/microsoft/TypeScript/issues/5451\n this.He = void 0;\n};\n\n/**\n * Computes the local transform result against the provided `previousValue`,\n * optionally using the provided localWriteTime.\n */ function $e(t, e, n) {\n return t instanceof Ze ? function(t, e) {\n var n = {\n fields: {\n __type__: {\n stringValue: \"server_timestamp\"\n },\n __local_write_time__: {\n timestampValue: {\n seconds: t.seconds,\n nanos: t.nanoseconds\n }\n }\n }\n };\n return e && (n.fields.__previous_value__ = e), {\n mapValue: n\n };\n }(n, e) : t instanceof tn ? en(t, e) : t instanceof nn ? rn(t, e) : function(t, e) {\n // PORTING NOTE: Since JavaScript's integer arithmetic is limited to 53 bit\n // precision and resolves overflows by reducing precision, we do not\n // manually cap overflows at 2^63.\n var n = Je(t, e), r = sn(n) + sn(t.je);\n return ce(n) && ce(t.je) ? ge(r) : me(t.serializer, r);\n }(t, e);\n}\n\n/**\n * Computes a final transform result after the transform has been acknowledged\n * by the server, potentially using the server-provided transformResult.\n */ function Xe(t, e, n) {\n // The server just sends null as the transform result for array operations,\n // so we have to calculate a result the same as we do for local\n // applications.\n return t instanceof tn ? en(t, e) : t instanceof nn ? rn(t, e) : n;\n}\n\n/**\n * If this transform operation is not idempotent, returns the base value to\n * persist for this transform. If a base value is returned, the transform\n * operation is always applied to this base value, even if document has\n * already been updated.\n *\n * Base values provide consistent behavior for non-idempotent transforms and\n * allow us to return the same latency-compensated value even if the backend\n * has already applied the transform operation. The base value is null for\n * idempotent transforms, as they can be re-played even if the backend has\n * already applied them.\n *\n * @return a base value to store along with the mutation, or null for\n * idempotent transforms.\n */ function Je(t, e) {\n return t instanceof on ? ce(n = e) || function(t) {\n return !!t && \"doubleValue\" in t;\n }(n) ? e : {\n integerValue: 0\n } : null;\n var n;\n}\n\n/** Transforms a value into a server-generated timestamp. */ var Ze = /** @class */ function(e) {\n function n() {\n return null !== e && e.apply(this, arguments) || this;\n }\n return t.__extends(n, e), n;\n}(Ye), tn = /** @class */ function(e) {\n function n(t) {\n var n = this;\n return (n = e.call(this) || this).elements = t, n;\n }\n return t.__extends(n, e), n;\n}(Ye);\n\n/** Transforms an array value via a union operation. */ function en(t, e) {\n for (var n = un(e), r = function(t) {\n n.some((function(e) {\n return Zt(e, t);\n })) || n.push(t);\n }, i = 0, o = t.elements; i < o.length; i++) {\n r(o[i]);\n }\n return {\n arrayValue: {\n values: n\n }\n };\n}\n\n/** Transforms an array value via a remove operation. */ var nn = /** @class */ function(e) {\n function n(t) {\n var n = this;\n return (n = e.call(this) || this).elements = t, n;\n }\n return t.__extends(n, e), n;\n}(Ye);\n\nfunction rn(t, e) {\n for (var n = un(e), r = function(t) {\n n = n.filter((function(e) {\n return !Zt(e, t);\n }));\n }, i = 0, o = t.elements; i < o.length; i++) {\n r(o[i]);\n }\n return {\n arrayValue: {\n values: n\n }\n };\n}\n\n/**\n * Implements the backend semantics for locally computed NUMERIC_ADD (increment)\n * transforms. Converts all field values to integers or doubles, but unlike the\n * backend does not cap integer values at 2^63. Instead, JavaScript number\n * arithmetic is used and precision loss can occur for values greater than 2^53.\n */ var on = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this) || this).serializer = t, r.je = n, r;\n }\n return t.__extends(n, e), n;\n}(Ye);\n\nfunction sn(t) {\n return se(t.integerValue || t.doubleValue);\n}\n\nfunction un(t) {\n return he(t) && t.arrayValue.values ? t.arrayValue.values.slice() : [];\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Provides a set of fields that can be used to partially patch a document.\n * FieldMask is used in conjunction with ObjectValue.\n * Examples:\n * foo - Overwrites foo entirely with the provided value. If foo is not\n * present in the companion ObjectValue, the field is deleted.\n * foo.bar - Overwrites only the field bar of the object foo.\n * If foo is not an object, foo is replaced with an object\n * containing foo\n */ var an = /** @class */ function() {\n function t(t) {\n this.fields = t, \n // TODO(dimond): validation of FieldMask\n // Sort the field mask to support `FieldMask.isEqual()` and assert below.\n t.sort(N.i)\n /**\n * Verifies that `fieldPath` is included by at least one field in this field\n * mask.\n *\n * This is an O(n) operation, where `n` is the size of the field mask.\n */;\n }\n return t.prototype.Ye = function(t) {\n for (var e = 0, n = this.fields; e < n.length; e++) {\n if (n[e].T(t)) return !0;\n }\n return !1;\n }, t.prototype.isEqual = function(t) {\n return Y(this.fields, t.fields, (function(t, e) {\n return t.isEqual(e);\n }));\n }, t;\n}(), cn = function(t, e) {\n this.field = t, this.transform = e;\n};\n\n/** A field path and the TransformOperation to perform upon it. */\n/** The result of successfully applying a mutation to the backend. */ var hn = function(\n/**\n * The version at which the mutation was committed:\n *\n * - For most operations, this is the updateTime in the WriteResult.\n * - For deletes, the commitTime of the WriteResponse (because deletes are\n * not stored and have no updateTime).\n *\n * Note that these versions can be different: No-op writes will not change\n * the updateTime even though the commitTime advances.\n */\nt, \n/**\n * The resulting fields returned from the backend after a\n * TransformMutation has been committed. Contains one FieldValue for each\n * FieldTransform that was in the mutation.\n *\n * Will be null if the mutation was not a TransformMutation.\n */\ne) {\n this.version = t, this.transformResults = e;\n}, fn = /** @class */ function() {\n function t(t, e) {\n this.updateTime = t, this.exists = e\n /** Creates a new empty Precondition. */;\n }\n return t.ze = function() {\n return new t;\n }, \n /** Creates a new Precondition with an exists flag. */ t.exists = function(e) {\n return new t(void 0, e);\n }, \n /** Creates a new Precondition based on a version a document exists at. */ t.updateTime = function(e) {\n return new t(e);\n }, Object.defineProperty(t.prototype, \"Ke\", {\n /** Returns whether this Precondition is empty. */ get: function() {\n return void 0 === this.updateTime && void 0 === this.exists;\n },\n enumerable: !1,\n configurable: !0\n }), t.prototype.isEqual = function(t) {\n return this.exists === t.exists && (this.updateTime ? !!t.updateTime && this.updateTime.isEqual(t.updateTime) : !t.updateTime);\n }, t;\n}();\n\n/**\n * Encodes a precondition for a mutation. This follows the model that the\n * backend accepts with the special case of an explicit \"empty\" precondition\n * (meaning no precondition).\n */\n/**\n * Returns true if the preconditions is valid for the given document\n * (or null if no document is available).\n */\nfunction ln(t, e) {\n return void 0 !== t.updateTime ? e instanceof kn && e.version.isEqual(t.updateTime) : void 0 === t.exists || t.exists === e instanceof kn;\n}\n\n/**\n * A mutation describes a self-contained change to a document. Mutations can\n * create, replace, delete, and update subsets of documents.\n *\n * Mutations not only act on the value of the document but also its version.\n *\n * For local mutations (mutations that haven't been committed yet), we preserve\n * the existing version for Set, Patch, and Transform mutations. For Delete\n * mutations, we reset the version to 0.\n *\n * Here's the expected transition table.\n *\n * MUTATION APPLIED TO RESULTS IN\n *\n * SetMutation Document(v3) Document(v3)\n * SetMutation NoDocument(v3) Document(v0)\n * SetMutation null Document(v0)\n * PatchMutation Document(v3) Document(v3)\n * PatchMutation NoDocument(v3) NoDocument(v3)\n * PatchMutation null null\n * TransformMutation Document(v3) Document(v3)\n * TransformMutation NoDocument(v3) NoDocument(v3)\n * TransformMutation null null\n * DeleteMutation Document(v3) NoDocument(v0)\n * DeleteMutation NoDocument(v3) NoDocument(v0)\n * DeleteMutation null NoDocument(v0)\n *\n * For acknowledged mutations, we use the updateTime of the WriteResponse as\n * the resulting version for Set, Patch, and Transform mutations. As deletes\n * have no explicit update time, we use the commitTime of the WriteResponse for\n * Delete mutations.\n *\n * If a mutation is acknowledged by the backend but fails the precondition check\n * locally, we return an `UnknownDocument` and rely on Watch to send us the\n * updated version.\n *\n * Note that TransformMutations don't create Documents (in the case of being\n * applied to a NoDocument), even though they would on the backend. This is\n * because the client always combines the TransformMutation with a SetMutation\n * or PatchMutation and we only want to apply the transform if the prior\n * mutation resulted in a Document (always true for a SetMutation, but not\n * necessarily for a PatchMutation).\n *\n * ## Subclassing Notes\n *\n * Subclasses of Mutation need to implement applyToRemoteDocument() and\n * applyToLocalView() to implement the actual behavior of applying the mutation\n * to some source document.\n */ var pn = function() {};\n\n/**\n * Applies this mutation to the given MaybeDocument or null for the purposes\n * of computing a new remote document. If the input document doesn't match the\n * expected state (e.g. it is null or outdated), an `UnknownDocument` can be\n * returned.\n *\n * @param mutation The mutation to apply.\n * @param maybeDoc The document to mutate. The input document can be null if\n * the client has no knowledge of the pre-mutation state of the document.\n * @param mutationResult The result of applying the mutation from the backend.\n * @return The mutated document. The returned document may be an\n * UnknownDocument if the mutation could not be applied to the locally\n * cached base document.\n */ function dn(t, e, n) {\n return t instanceof wn ? function(t, e, n) {\n // Unlike applySetMutationToLocalView, if we're applying a mutation to a\n // remote document the server has accepted the mutation so the precondition\n // must have held.\n return new kn(t.key, n.version, t.value, {\n hasCommittedMutations: !0\n });\n }(t, 0, n) : t instanceof _n ? function(t, e, n) {\n if (!ln(t.Ge, e)) \n // Since the mutation was not rejected, we know that the precondition\n // matched on the backend. We therefore must not have the expected version\n // of the document in our cache and return an UnknownDocument with the\n // known updateTime.\n return new On(t.key, n.version);\n var r = bn(t, e);\n return new kn(t.key, n.version, r, {\n hasCommittedMutations: !0\n });\n }(t, e, n) : t instanceof In ? function(t, e, n) {\n if (g(null != n.transformResults), !ln(t.Ge, e)) \n // Since the mutation was not rejected, we know that the precondition\n // matched on the backend. We therefore must not have the expected version\n // of the document in our cache and return an UnknownDocument with the\n // known updateTime.\n return new On(t.key, n.version);\n var r = En(t, e), i = \n /**\n * Creates a list of \"transform results\" (a transform result is a field value\n * representing the result of applying a transform) for use after a\n * TransformMutation has been acknowledged by the server.\n *\n * @param fieldTransforms The field transforms to apply the result to.\n * @param baseDoc The document prior to applying this mutation batch.\n * @param serverTransformResults The transform results received by the server.\n * @return The transform results list.\n */\n function(t, e, n) {\n var r = [];\n g(t.length === n.length);\n for (var i = 0; i < n.length; i++) {\n var o = t[i], s = o.transform, u = null;\n e instanceof kn && (u = e.field(o.field)), r.push(Xe(s, u, n[i]));\n }\n return r;\n }(t.fieldTransforms, e, n.transformResults), o = n.version, s = Tn(t, r.data(), i);\n return new kn(t.key, o, s, {\n hasCommittedMutations: !0\n });\n }(t, e, n) : function(t, e, n) {\n // Unlike applyToLocalView, if we're applying a mutation to a remote\n // document the server has accepted the mutation so the precondition must\n // have held.\n return new Rn(t.key, n.version, {\n hasCommittedMutations: !0\n });\n }(t, 0, n);\n}\n\n/**\n * Applies this mutation to the given MaybeDocument or null for the purposes\n * of computing the new local view of a document. Both the input and returned\n * documents can be null.\n *\n * @param mutation The mutation to apply.\n * @param maybeDoc The document to mutate. The input document can be null if\n * the client has no knowledge of the pre-mutation state of the document.\n * @param baseDoc The state of the document prior to this mutation batch. The\n * input document can be null if the client has no knowledge of the\n * pre-mutation state of the document.\n * @param localWriteTime A timestamp indicating the local write time of the\n * batch this mutation is a part of.\n * @return The mutated document. The returned document may be null, but only\n * if maybeDoc was null and the mutation would not create a new document.\n */ function vn(t, e, n, r) {\n return t instanceof wn ? function(t, e) {\n if (!ln(t.Ge, e)) return e;\n var n = mn(e);\n return new kn(t.key, n, t.value, {\n Je: !0\n });\n }(t, e) : t instanceof _n ? function(t, e) {\n if (!ln(t.Ge, e)) return e;\n var n = mn(e), r = bn(t, e);\n return new kn(t.key, n, r, {\n Je: !0\n });\n }(t, e) : t instanceof In ? function(t, e, n, r) {\n if (!ln(t.Ge, e)) return e;\n var i = En(t, e), o = function(t, e, n, r) {\n for (var i = [], o = 0, s = t; o < s.length; o++) {\n var u = s[o], a = u.transform, c = null;\n n instanceof kn && (c = n.field(u.field)), null === c && r instanceof kn && (\n // If the current document does not contain a value for the mutated\n // field, use the value that existed before applying this mutation\n // batch. This solves an edge case where a PatchMutation clears the\n // values in a nested map before the TransformMutation is applied.\n c = r.field(u.field)), i.push($e(a, c, e));\n }\n return i;\n }(t.fieldTransforms, n, e, r), s = Tn(t, i.data(), o);\n return new kn(t.key, i.version, s, {\n Je: !0\n });\n }(t, e, r, n) : function(t, e) {\n return ln(t.Ge, e) ? new Rn(t.key, st.min()) : e;\n }(t, e);\n}\n\n/**\n * If this mutation is not idempotent, returns the base value to persist with\n * this mutation. If a base value is returned, the mutation is always applied\n * to this base value, even if document has already been updated.\n *\n * The base value is a sparse object that consists of only the document\n * fields for which this mutation contains a non-idempotent transformation\n * (e.g. a numeric increment). The provided value guarantees consistent\n * behavior for non-idempotent transforms and allow us to return the same\n * latency-compensated value even if the backend has already applied the\n * mutation. The base value is null for idempotent mutations, as they can be\n * re-played even if the backend has already applied them.\n *\n * @return a base value to store along with the mutation, or null for\n * idempotent mutations.\n */ function yn(t, e) {\n return t instanceof In ? function(t, e) {\n for (var n = null, r = 0, i = t.fieldTransforms; r < i.length; r++) {\n var o = i[r], s = e instanceof kn ? e.field(o.field) : void 0, u = Je(o.transform, s || null);\n null != u && (n = null == n ? (new Dn).set(o.field, u) : n.set(o.field, u));\n }\n return n ? n.Xe() : null;\n }(t, e) : null;\n}\n\nfunction gn(t, e) {\n return t.type === e.type && !!t.key.isEqual(e.key) && !!t.Ge.isEqual(e.Ge) && (0 /* Set */ === t.type ? t.value.isEqual(e.value) : 1 /* Patch */ === t.type ? t.data.isEqual(e.data) && t.We.isEqual(e.We) : 2 /* Transform */ !== t.type || Y(t.fieldTransforms, t.fieldTransforms, (function(t, e) {\n return function(t, e) {\n return t.field.isEqual(e.field) && function(t, e) {\n return t instanceof tn && e instanceof tn || t instanceof nn && e instanceof nn ? Y(t.elements, e.elements, Zt) : t instanceof on && e instanceof on ? Zt(t.je, e.je) : t instanceof Ze && e instanceof Ze;\n }(t.transform, e.transform);\n }(t, e);\n })));\n}\n\n/**\n * Returns the version from the given document for use as the result of a\n * mutation. Mutations are defined to return the version of the base document\n * only if it is an existing document. Deleted and unknown documents have a\n * post-mutation version of SnapshotVersion.min().\n */ function mn(t) {\n return t instanceof kn ? t.version : st.min();\n}\n\n/**\n * A mutation that creates or replaces the document at the given key with the\n * object value contents.\n */ var wn = /** @class */ function(e) {\n function n(t, n, r) {\n var i = this;\n return (i = e.call(this) || this).key = t, i.value = n, i.Ge = r, i.type = 0 /* Set */ , \n i;\n }\n return t.__extends(n, e), n;\n}(pn), _n = /** @class */ function(e) {\n function n(t, n, r, i) {\n var o = this;\n return (o = e.call(this) || this).key = t, o.data = n, o.We = r, o.Ge = i, o.type = 1 /* Patch */ , \n o;\n }\n return t.__extends(n, e), n;\n}(pn);\n\nfunction bn(t, e) {\n return function(t, e) {\n var n = new Dn(e);\n return t.We.fields.forEach((function(e) {\n if (!e.m()) {\n var r = t.data.field(e);\n null !== r ? n.set(e, r) : n.delete(e);\n }\n })), n.Xe();\n }(t, e instanceof kn ? e.data() : Sn.empty());\n}\n\nvar In = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this) || this).key = t, r.fieldTransforms = n, r.type = 2 /* Transform */ , \n // NOTE: We set a precondition of exists: true as a safety-check, since we\n // always combine TransformMutations with a SetMutation or PatchMutation which\n // (if successful) should end up with an existing document.\n r.Ge = fn.exists(!0), r;\n }\n return t.__extends(n, e), n;\n}(pn);\n\nfunction En(t, e) {\n return e;\n}\n\nfunction Tn(t, e, n) {\n for (var r = new Dn(e), i = 0; i < t.fieldTransforms.length; i++) {\n var o = t.fieldTransforms[i];\n r.set(o.field, n[i]);\n }\n return r.Xe();\n}\n\n/** A mutation that deletes the document at the given key. */ var Nn = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this) || this).key = t, r.Ge = n, r.type = 3 /* Delete */ , r;\n }\n return t.__extends(n, e), n;\n}(pn), An = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this) || this).key = t, r.Ge = n, r.type = 4 /* Verify */ , r;\n }\n return t.__extends(n, e), n;\n}(pn), Sn = /** @class */ function() {\n function t(t) {\n this.proto = t;\n }\n return t.empty = function() {\n return new t({\n mapValue: {}\n });\n }, \n /**\n * Returns the value at the given path or null.\n *\n * @param path the path to search\n * @return The value at the path or if there it doesn't exist.\n */\n t.prototype.field = function(t) {\n if (t.m()) return this.proto;\n for (var e = this.proto, n = 0; n < t.length - 1; ++n) {\n if (!e.mapValue.fields) return null;\n if (!pe(e = e.mapValue.fields[t.get(n)])) return null;\n }\n return (e = (e.mapValue.fields || {})[t._()]) || null;\n }, t.prototype.isEqual = function(t) {\n return Zt(this.proto, t.proto);\n }, t;\n}(), Dn = /** @class */ function() {\n /**\n * @param baseObject The object to mutate.\n */\n function t(t) {\n void 0 === t && (t = Sn.empty()), this.Ze = t, \n /** A map that contains the accumulated changes in this builder. */\n this.tn = new Map;\n }\n /**\n * Sets the field to the provided value.\n *\n * @param path The field path to set.\n * @param value The value to set.\n * @return The current Builder instance.\n */ return t.prototype.set = function(t, e) {\n return this.en(t, e), this;\n }, \n /**\n * Removes the field at the specified path. If there is no field at the\n * specified path, nothing is changed.\n *\n * @param path The field path to remove.\n * @return The current Builder instance.\n */\n t.prototype.delete = function(t) {\n return this.en(t, null), this;\n }, \n /**\n * Adds `value` to the overlay map at `path`. Creates nested map entries if\n * needed.\n */\n t.prototype.en = function(t, e) {\n for (var n = this.tn, r = 0; r < t.length - 1; ++r) {\n var i = t.get(r), o = n.get(i);\n o instanceof Map ? \n // Re-use a previously created map\n n = o : o && 10 /* ObjectValue */ === Jt(o) ? (\n // Convert the existing Protobuf MapValue into a map\n o = new Map(Object.entries(o.mapValue.fields || {})), n.set(i, o), n = o) : (\n // Create an empty map to represent the current nesting level\n o = new Map, n.set(i, o), n = o);\n }\n n.set(t._(), e);\n }, \n /** Returns an ObjectValue with all mutations applied. */ t.prototype.Xe = function() {\n var t = this.nn(N.P(), this.tn);\n return null != t ? new Sn(t) : this.Ze;\n }, \n /**\n * Applies any overlays from `currentOverlays` that exist at `currentPath`\n * and returns the merged data at `currentPath` (or null if there were no\n * changes).\n *\n * @param currentPath The path at the current nesting level. Can be set to\n * FieldValue.emptyPath() to represent the root.\n * @param currentOverlays The overlays at the current nesting level in the\n * same format as `overlayMap`.\n * @return The merged data at `currentPath` or null if no modifications\n * were applied.\n */\n t.prototype.nn = function(t, e) {\n var n = this, r = !1, i = this.Ze.field(t), o = pe(i) ? // If there is already data at the current path, base our\n Object.assign({}, i.mapValue.fields) : {};\n return e.forEach((function(e, i) {\n if (e instanceof Map) {\n var s = n.nn(t.child(i), e);\n null != s && (o[i] = s, r = !0);\n } else null !== e ? (o[i] = e, r = !0) : o.hasOwnProperty(i) && (delete o[i], r = !0);\n })), r ? {\n mapValue: {\n fields: o\n }\n } : null;\n }, t;\n}();\n\n/**\n * Returns a FieldMask built from all fields in a MapValue.\n */\nfunction xn(t) {\n var e = [];\n return _(t.fields || {}, (function(t, n) {\n var r = new N([ t ]);\n if (pe(n)) {\n var i = xn(n.mapValue).fields;\n if (0 === i.length) \n // Preserve the empty map by adding it to the FieldMask.\n e.push(r); else \n // For nested and non-empty ObjectValues, add the FieldPath of the\n // leaf nodes.\n for (var o = 0, s = i; o < s.length; o++) {\n var u = s[o];\n e.push(r.child(u));\n }\n } else \n // For nested and non-empty ObjectValues, add the FieldPath of the leaf\n // nodes.\n e.push(r);\n })), new an(e)\n /**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * The result of a lookup for a given path may be an existing document or a\n * marker that this document does not exist at a given version.\n */;\n}\n\nvar Ln = function(t, e) {\n this.key = t, this.version = e;\n}, kn = /** @class */ function(e) {\n function n(t, n, r, i) {\n var o = this;\n return (o = e.call(this, t, n) || this).sn = r, o.Je = !!i.Je, o.hasCommittedMutations = !!i.hasCommittedMutations, \n o;\n }\n return t.__extends(n, e), n.prototype.field = function(t) {\n return this.sn.field(t);\n }, n.prototype.data = function() {\n return this.sn;\n }, n.prototype.rn = function() {\n return this.sn.proto;\n }, n.prototype.isEqual = function(t) {\n return t instanceof n && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.Je === t.Je && this.hasCommittedMutations === t.hasCommittedMutations && this.sn.isEqual(t.sn);\n }, n.prototype.toString = function() {\n return \"Document(\" + this.key + \", \" + this.version + \", \" + this.sn.toString() + \", {hasLocalMutations: \" + this.Je + \"}), {hasCommittedMutations: \" + this.hasCommittedMutations + \"})\";\n }, Object.defineProperty(n.prototype, \"hasPendingWrites\", {\n get: function() {\n return this.Je || this.hasCommittedMutations;\n },\n enumerable: !1,\n configurable: !0\n }), n;\n}(Ln), Rn = /** @class */ function(e) {\n function n(t, n, r) {\n var i = this;\n return (i = e.call(this, t, n) || this).hasCommittedMutations = !(!r || !r.hasCommittedMutations), \n i;\n }\n return t.__extends(n, e), n.prototype.toString = function() {\n return \"NoDocument(\" + this.key + \", \" + this.version + \")\";\n }, Object.defineProperty(n.prototype, \"hasPendingWrites\", {\n get: function() {\n return this.hasCommittedMutations;\n },\n enumerable: !1,\n configurable: !0\n }), n.prototype.isEqual = function(t) {\n return t instanceof n && t.hasCommittedMutations === this.hasCommittedMutations && t.version.isEqual(this.version) && t.key.isEqual(this.key);\n }, n;\n}(Ln), On = /** @class */ function(e) {\n function n() {\n return null !== e && e.apply(this, arguments) || this;\n }\n return t.__extends(n, e), n.prototype.toString = function() {\n return \"UnknownDocument(\" + this.key + \", \" + this.version + \")\";\n }, Object.defineProperty(n.prototype, \"hasPendingWrites\", {\n get: function() {\n return !0;\n },\n enumerable: !1,\n configurable: !0\n }), n.prototype.isEqual = function(t) {\n return t instanceof n && t.version.isEqual(this.version) && t.key.isEqual(this.key);\n }, n;\n}(Ln), Pn = \n/**\n * Initializes a Query with a path and optional additional query constraints.\n * Path must currently be empty if this is a collection group query.\n */\nfunction(t, e, n, r, i, o /* First */ , s, u) {\n void 0 === e && (e = null), void 0 === n && (n = []), void 0 === r && (r = []), \n void 0 === i && (i = null), void 0 === o && (o = \"F\"), void 0 === s && (s = null), \n void 0 === u && (u = null), this.path = t, this.collectionGroup = e, this.on = n, \n this.filters = r, this.limit = i, this.an = o, this.startAt = s, this.endAt = u, \n this.cn = null, \n // The corresponding `Target` of this `Query` instance.\n this.un = null, this.startAt, this.endAt;\n};\n\n/**\n * Represents a document in Firestore with a key, version, data and whether the\n * data has local mutations applied to it.\n */\n/** Creates a new Query instance with the options provided. */ function Vn(t, e, n, r, i, o, s, u) {\n return new Pn(t, e, n, r, i, o, s, u);\n}\n\n/** Creates a new Query for a query that matches all documents at `path` */ function Un(t) {\n return new Pn(t);\n}\n\n/**\n * Helper to convert a collection group query into a collection query at a\n * specific path. This is used when executing collection group queries, since\n * we have to split the query into a set of collection queries at multiple\n * paths.\n */ function Cn(t) {\n return !ut(t.limit) && \"F\" /* First */ === t.an;\n}\n\nfunction Fn(t) {\n return !ut(t.limit) && \"L\" /* Last */ === t.an;\n}\n\nfunction Mn(t) {\n return t.on.length > 0 ? t.on[0].field : null;\n}\n\nfunction qn(t) {\n for (var e = 0, n = t.filters; e < n.length; e++) {\n var r = n[e];\n if (r.hn()) return r.field;\n }\n return null;\n}\n\n/**\n * Checks if any of the provided Operators are included in the query and\n * returns the first one that is, or null if none are.\n */\n/**\n * Returns whether the query matches a collection group rather than a specific\n * collection.\n */ function jn(t) {\n return null !== t.collectionGroup;\n}\n\n/**\n * Returns the implicit order by constraint that is used to execute the Query,\n * which can be different from the order by constraints the user provided (e.g.\n * the SDK and backend always orders by `__name__`).\n */ function Gn(t) {\n var e = m(t);\n if (null === e.cn) {\n e.cn = [];\n var n = qn(e), r = Mn(e);\n if (null !== n && null === r) \n // In order to implicitly add key ordering, we must also add the\n // inequality filter field for it to be a valid query.\n // Note that the default inequality field and key ordering is ascending.\n n.p() || e.cn.push(new fr(n)), e.cn.push(new fr(N.v(), \"asc\" /* ASCENDING */)); else {\n for (var i = !1, o = 0, s = e.on; o < s.length; o++) {\n var u = s[o];\n e.cn.push(u), u.field.p() && (i = !0);\n }\n if (!i) {\n // The order of the implicit key ordering always matches the last\n // explicit order by\n var a = e.on.length > 0 ? e.on[e.on.length - 1].dir : \"asc\" /* ASCENDING */;\n e.cn.push(new fr(N.v(), a));\n }\n }\n }\n return e.cn;\n}\n\n/**\n * Converts this `Query` instance to it's corresponding `Target` representation.\n */ function zn(t) {\n var e = m(t);\n if (!e.un) if (\"F\" /* First */ === e.an) e.un = ft(e.path, e.collectionGroup, Gn(e), e.filters, e.limit, e.startAt, e.endAt); else {\n for (\n // Flip the orderBy directions since we want the last results\n var n = [], r = 0, i = Gn(e); r < i.length; r++) {\n var o = i[r], s = \"desc\" /* DESCENDING */ === o.dir ? \"asc\" /* ASCENDING */ : \"desc\" /* DESCENDING */;\n n.push(new fr(o.field, s));\n }\n // We need to swap the cursors to match the now-flipped query ordering.\n var u = e.endAt ? new ur(e.endAt.position, !e.endAt.before) : null, a = e.startAt ? new ur(e.startAt.position, !e.startAt.before) : null;\n // Now return as a LimitType.First query.\n e.un = ft(e.path, e.collectionGroup, n, e.filters, e.limit, u, a);\n }\n return e.un;\n}\n\nfunction Bn(t, e, n) {\n return new Pn(t.path, t.collectionGroup, t.on.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);\n}\n\nfunction Wn(t, e) {\n return new Pn(t.path, t.collectionGroup, t.on.slice(), t.filters.slice(), t.limit, t.an, e, t.endAt);\n}\n\nfunction Kn(t, e) {\n return new Pn(t.path, t.collectionGroup, t.on.slice(), t.filters.slice(), t.limit, t.an, t.startAt, e);\n}\n\nfunction Qn(t, e) {\n return pt(zn(t), zn(e)) && t.an === e.an;\n}\n\n// TODO(b/29183165): This is used to get a unique string from a query to, for\n// example, use as a dictionary key, but the implementation is subject to\n// collisions. Make it collision-free.\nfunction Hn(t) {\n return lt(zn(t)) + \"|lt:\" + t.an;\n}\n\nfunction Yn(t) {\n return \"Query(target=\" + function(t) {\n var e = t.path.R();\n return null !== t.collectionGroup && (e += \" collectionGroup=\" + t.collectionGroup), \n t.filters.length > 0 && (e += \", filters: [\" + t.filters.map((function(t) {\n return (e = t).field.R() + \" \" + e.op + \" \" + re(e.value);\n /** Returns a debug description for `filter`. */ var e;\n /** Filter that matches on key fields (i.e. '__name__'). */ })).join(\", \") + \"]\"), \n ut(t.limit) || (e += \", limit: \" + t.limit), t.orderBy.length > 0 && (e += \", orderBy: [\" + t.orderBy.map((function(t) {\n return (e = t).field.R() + \" (\" + e.dir + \")\";\n var e;\n })).join(\", \") + \"]\"), t.startAt && (e += \", startAt: \" + ar(t.startAt)), t.endAt && (e += \", endAt: \" + ar(t.endAt)), \n \"Target(\" + e + \")\";\n }(zn(t)) + \"; limitType=\" + t.an + \")\";\n}\n\n/** Returns whether `doc` matches the constraints of `query`. */ function $n(t, e) {\n return function(t, e) {\n var n = e.key.path;\n return null !== t.collectionGroup ? e.key.N(t.collectionGroup) && t.path.T(n) : A.F(t.path) ? t.path.isEqual(n) : t.path.I(n);\n }(t, e) && function(t, e) {\n for (var n = 0, r = t.on; n < r.length; n++) {\n var i = r[n];\n // order by key always matches\n if (!i.field.p() && null === e.field(i.field)) return !1;\n }\n return !0;\n }(t, e) && function(t, e) {\n for (var n = 0, r = t.filters; n < r.length; n++) {\n if (!r[n].matches(e)) return !1;\n }\n return !0;\n }(t, e) && function(t, e) {\n return !(t.startAt && !cr(t.startAt, Gn(t), e)) && (!t.endAt || !cr(t.endAt, Gn(t), e));\n }(t, e);\n}\n\nfunction Xn(t) {\n return function(e, n) {\n for (var r = !1, i = 0, o = Gn(t); i < o.length; i++) {\n var s = o[i], u = lr(s, e, n);\n if (0 !== u) return u;\n r = r || s.field.p();\n }\n return 0;\n };\n}\n\nvar Jn = /** @class */ function(e) {\n function n(t, n, r) {\n var i = this;\n return (i = e.call(this) || this).field = t, i.op = n, i.value = r, i;\n }\n /**\n * Creates a filter based on the provided arguments.\n */ return t.__extends(n, e), n.create = function(t, e, r) {\n if (t.p()) return \"in\" /* IN */ === e || \"not-in\" /* NOT_IN */ === e ? this.ln(t, e, r) : new Zn(t, e, r);\n if (fe(r)) {\n if (\"==\" /* EQUAL */ !== e && \"!=\" /* NOT_EQUAL */ !== e) throw new c(a.INVALID_ARGUMENT, \"Invalid query. Null only supports '==' and '!=' comparisons.\");\n return new n(t, e, r);\n }\n if (le(r)) {\n if (\"==\" /* EQUAL */ !== e && \"!=\" /* NOT_EQUAL */ !== e) throw new c(a.INVALID_ARGUMENT, \"Invalid query. NaN only supports '==' and '!=' comparisons.\");\n return new n(t, e, r);\n }\n return \"array-contains\" /* ARRAY_CONTAINS */ === e ? new rr(t, r) : \"in\" /* IN */ === e ? new ir(t, r) : \"not-in\" /* NOT_IN */ === e ? new or(t, r) : \"array-contains-any\" /* ARRAY_CONTAINS_ANY */ === e ? new sr(t, r) : new n(t, e, r);\n }, n.ln = function(t, e, n) {\n return \"in\" /* IN */ === e ? new tr(t, n) : new er(t, n);\n }, n.prototype.matches = function(t) {\n var e = t.field(this.field);\n // Types do not have to match in NOT_EQUAL filters.\n return \"!=\" /* NOT_EQUAL */ === this.op ? null !== e && this._n(ee(e, this.value)) : null !== e && Jt(this.value) === Jt(e) && this._n(ee(e, this.value));\n // Only compare types with matching backend order (such as double and int).\n }, n.prototype._n = function(t) {\n switch (this.op) {\n case \"<\" /* LESS_THAN */ :\n return t < 0;\n\n case \"<=\" /* LESS_THAN_OR_EQUAL */ :\n return t <= 0;\n\n case \"==\" /* EQUAL */ :\n return 0 === t;\n\n case \"!=\" /* NOT_EQUAL */ :\n return 0 !== t;\n\n case \">\" /* GREATER_THAN */ :\n return t > 0;\n\n case \">=\" /* GREATER_THAN_OR_EQUAL */ :\n return t >= 0;\n\n default:\n return y();\n }\n }, n.prototype.hn = function() {\n return [ \"<\" /* LESS_THAN */ , \"<=\" /* LESS_THAN_OR_EQUAL */ , \">\" /* GREATER_THAN */ , \">=\" /* GREATER_THAN_OR_EQUAL */ , \"!=\" /* NOT_EQUAL */ , \"not-in\" /* NOT_IN */ ].indexOf(this.op) >= 0;\n }, n;\n}((function() {}));\n\nvar Zn = /** @class */ function(e) {\n function n(t, n, r) {\n var i = this;\n return (i = e.call(this, t, n, r) || this).key = A.C(r.referenceValue), i;\n }\n return t.__extends(n, e), n.prototype.matches = function(t) {\n var e = A.i(t.key, this.key);\n return this._n(e);\n }, n;\n}(Jn), tr = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this, t, \"in\" /* IN */ , n) || this).keys = nr(\"in\" /* IN */ , n), \n r;\n }\n return t.__extends(n, e), n.prototype.matches = function(t) {\n return this.keys.some((function(e) {\n return e.isEqual(t.key);\n }));\n }, n;\n}(Jn), er = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this, t, \"not-in\" /* NOT_IN */ , n) || this).keys = nr(\"not-in\" /* NOT_IN */ , n), \n r;\n }\n return t.__extends(n, e), n.prototype.matches = function(t) {\n return !this.keys.some((function(e) {\n return e.isEqual(t.key);\n }));\n }, n;\n}(Jn);\n\n/** Filter that matches on key fields within an array. */ function nr(t, e) {\n var n;\n return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((function(t) {\n return A.C(t.referenceValue);\n }));\n}\n\n/** A Filter that implements the array-contains operator. */ var rr = /** @class */ function(e) {\n function n(t, n) {\n return e.call(this, t, \"array-contains\" /* ARRAY_CONTAINS */ , n) || this;\n }\n return t.__extends(n, e), n.prototype.matches = function(t) {\n var e = t.field(this.field);\n return he(e) && te(e.arrayValue, this.value);\n }, n;\n}(Jn), ir = /** @class */ function(e) {\n function n(t, n) {\n return e.call(this, t, \"in\" /* IN */ , n) || this;\n }\n return t.__extends(n, e), n.prototype.matches = function(t) {\n var e = t.field(this.field);\n return null !== e && te(this.value.arrayValue, e);\n }, n;\n}(Jn), or = /** @class */ function(e) {\n function n(t, n) {\n return e.call(this, t, \"not-in\" /* NOT_IN */ , n) || this;\n }\n return t.__extends(n, e), n.prototype.matches = function(t) {\n if (te(this.value.arrayValue, {\n nullValue: \"NULL_VALUE\"\n })) return !1;\n var e = t.field(this.field);\n return null !== e && !te(this.value.arrayValue, e);\n }, n;\n}(Jn), sr = /** @class */ function(e) {\n function n(t, n) {\n return e.call(this, t, \"array-contains-any\" /* ARRAY_CONTAINS_ANY */ , n) || this;\n }\n return t.__extends(n, e), n.prototype.matches = function(t) {\n var e = this, n = t.field(this.field);\n return !(!he(n) || !n.arrayValue.values) && n.arrayValue.values.some((function(t) {\n return te(e.value.arrayValue, t);\n }));\n }, n;\n}(Jn), ur = function(t, e) {\n this.position = t, this.before = e;\n};\n\n/** A Filter that implements the IN operator. */ function ar(t) {\n // TODO(b/29183165): Make this collision robust.\n return (t.before ? \"b\" : \"a\") + \":\" + t.position.map((function(t) {\n return re(t);\n })).join(\",\");\n}\n\n/**\n * Returns true if a document sorts before a bound using the provided sort\n * order.\n */ function cr(t, e, n) {\n for (var r = 0, i = 0; i < t.position.length; i++) {\n var o = e[i], s = t.position[i];\n if (r = o.field.p() ? A.i(A.C(s.referenceValue), n.key) : ee(s, n.field(o.field)), \n \"desc\" /* DESCENDING */ === o.dir && (r *= -1), 0 !== r) break;\n }\n return t.before ? r <= 0 : r < 0;\n}\n\nfunction hr(t, e) {\n if (null === t) return null === e;\n if (null === e) return !1;\n if (t.before !== e.before || t.position.length !== e.position.length) return !1;\n for (var n = 0; n < t.position.length; n++) if (!Zt(t.position[n], e.position[n])) return !1;\n return !0;\n}\n\n/**\n * An ordering on a field, in some Direction. Direction defaults to ASCENDING.\n */ var fr = function(t, e /* ASCENDING */) {\n void 0 === e && (e = \"asc\"), this.field = t, this.dir = e;\n};\n\nfunction lr(t, e, n) {\n var r = t.field.p() ? A.i(e.key, n.key) : function(t, e, n) {\n var r = e.field(t), i = n.field(t);\n return null !== r && null !== i ? ee(r, i) : y();\n }(t.field, e, n);\n switch (t.dir) {\n case \"asc\" /* ASCENDING */ :\n return r;\n\n case \"desc\" /* DESCENDING */ :\n return -1 * r;\n\n default:\n return y();\n }\n}\n\nfunction pr(t, e) {\n return t.dir === e.dir && t.field.isEqual(e.field);\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */ var dr = function() {\n var t = this;\n this.promise = new Promise((function(e, n) {\n t.resolve = e, t.reject = n;\n }));\n}, vr = /** @class */ function() {\n function t(\n /**\n * The AsyncQueue to run backoff operations on.\n */\n t, \n /**\n * The ID to use when scheduling backoff operations on the AsyncQueue.\n */\n e, \n /**\n * The initial delay (used as the base delay on the first retry attempt).\n * Note that jitter will still be applied, so the actual delay could be as\n * little as 0.5*initialDelayMs.\n */\n n\n /**\n * The multiplier to use to determine the extended base delay after each\n * attempt.\n */ , r\n /**\n * The maximum base delay after which no further backoff is performed.\n * Note that jitter will still be applied, so the actual delay could be as\n * much as 1.5*maxDelayMs.\n */ , i) {\n void 0 === n && (n = 1e3), void 0 === r && (r = 1.5), void 0 === i && (i = 6e4), \n this.fn = t, this.dn = e, this.wn = n, this.mn = r, this.Tn = i, this.En = 0, this.In = null, \n /** The last backoff attempt, as epoch milliseconds. */\n this.An = Date.now(), this.reset();\n }\n /**\n * Resets the backoff delay.\n *\n * The very next backoffAndWait() will have no delay. If it is called again\n * (i.e. due to an error), initialDelayMs (plus jitter) will be used, and\n * subsequent ones will increase according to the backoffFactor.\n */ return t.prototype.reset = function() {\n this.En = 0;\n }, \n /**\n * Resets the backoff delay to the maximum delay (e.g. for use after a\n * RESOURCE_EXHAUSTED error).\n */\n t.prototype.Rn = function() {\n this.En = this.Tn;\n }, \n /**\n * Returns a promise that resolves after currentDelayMs, and increases the\n * delay for any subsequent attempts. If there was a pending backoff operation\n * already, it will be canceled.\n */\n t.prototype.gn = function(t) {\n var e = this;\n // Cancel any pending backoff operation.\n this.cancel();\n // First schedule using the current base (which may be 0 and should be\n // honored as such).\n var n = Math.floor(this.En + this.Pn()), r = Math.max(0, Date.now() - this.An), i = Math.max(0, n - r);\n // Guard against lastAttemptTime being in the future due to a clock change.\n i > 0 && l(\"ExponentialBackoff\", \"Backing off for \" + i + \" ms (base delay: \" + this.En + \" ms, delay with jitter: \" + n + \" ms, last attempt: \" + r + \" ms ago)\"), \n this.In = this.fn.yn(this.dn, i, (function() {\n return e.An = Date.now(), t();\n })), \n // Apply backoff factor to determine next delay and ensure it is within\n // bounds.\n this.En *= this.mn, this.En < this.wn && (this.En = this.wn), this.En > this.Tn && (this.En = this.Tn);\n }, t.prototype.Vn = function() {\n null !== this.In && (this.In.pn(), this.In = null);\n }, t.prototype.cancel = function() {\n null !== this.In && (this.In.cancel(), this.In = null);\n }, \n /** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */ t.prototype.Pn = function() {\n return (Math.random() - .5) * this.En;\n }, t;\n}(), yr = /** @class */ function() {\n function t(t) {\n var e = this;\n // NOTE: next/catchCallback will always point to our own wrapper functions,\n // not the user's raw next() or catch() callbacks.\n this.bn = null, this.vn = null, \n // When the operation resolves, we'll set result or error and mark isDone.\n this.result = void 0, this.error = void 0, this.Sn = !1, \n // Set to true when .then() or .catch() are called and prevents additional\n // chaining.\n this.Dn = !1, t((function(t) {\n e.Sn = !0, e.result = t, e.bn && \n // value should be defined unless T is Void, but we can't express\n // that in the type system.\n e.bn(t);\n }), (function(t) {\n e.Sn = !0, e.error = t, e.vn && e.vn(t);\n }));\n }\n return t.prototype.catch = function(t) {\n return this.next(void 0, t);\n }, t.prototype.next = function(e, n) {\n var r = this;\n return this.Dn && y(), this.Dn = !0, this.Sn ? this.error ? this.Cn(n, this.error) : this.Nn(e, this.result) : new t((function(t, i) {\n r.bn = function(n) {\n r.Nn(e, n).next(t, i);\n }, r.vn = function(e) {\n r.Cn(n, e).next(t, i);\n };\n }));\n }, t.prototype.Fn = function() {\n var t = this;\n return new Promise((function(e, n) {\n t.next(e, n);\n }));\n }, t.prototype.xn = function(e) {\n try {\n var n = e();\n return n instanceof t ? n : t.resolve(n);\n } catch (e) {\n return t.reject(e);\n }\n }, t.prototype.Nn = function(e, n) {\n return e ? this.xn((function() {\n return e(n);\n })) : t.resolve(n);\n }, t.prototype.Cn = function(e, n) {\n return e ? this.xn((function() {\n return e(n);\n })) : t.reject(n);\n }, t.resolve = function(e) {\n return new t((function(t, n) {\n t(e);\n }));\n }, t.reject = function(e) {\n return new t((function(t, n) {\n n(e);\n }));\n }, t.$n = function(\n // Accept all Promise types in waitFor().\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n e) {\n return new t((function(t, n) {\n var r = 0, i = 0, o = !1;\n e.forEach((function(e) {\n ++r, e.next((function() {\n ++i, o && i === r && t();\n }), (function(t) {\n return n(t);\n }));\n })), o = !0, i === r && t();\n }));\n }, \n /**\n * Given an array of predicate functions that asynchronously evaluate to a\n * boolean, implements a short-circuiting `or` between the results. Predicates\n * will be evaluated until one of them returns `true`, then stop. The final\n * result will be whether any of them returned `true`.\n */\n t.kn = function(e) {\n for (var n = t.resolve(!1), r = function(e) {\n n = n.next((function(n) {\n return n ? t.resolve(n) : e();\n }));\n }, i = 0, o = e; i < o.length; i++) {\n r(o[i]);\n }\n return n;\n }, t.forEach = function(t, e) {\n var n = this, r = [];\n return t.forEach((function(t, i) {\n r.push(e.call(n, t, i));\n })), this.$n(r);\n }, t;\n}(), gr = /** @class */ function() {\n /*\n * Creates a new SimpleDb wrapper for IndexedDb database `name`.\n *\n * Note that `version` must not be a downgrade. IndexedDB does not support\n * downgrading the schema version. We currently do not support any way to do\n * versioning outside of IndexedDB's versioning mechanism, as only\n * version-upgrade transactions are allowed to do things like create\n * objectstores.\n */\n function e(t, n, i) {\n this.name = t, this.version = n, this.Mn = i, \n // NOTE: According to https://bugs.webkit.org/show_bug.cgi?id=197050, the\n // bug we're checking for should exist in iOS >= 12.2 and < 13, but for\n // whatever reason it's much harder to hit after 12.2 so we only proactively\n // log on 12.2.\n 12.2 === e.On(r.getUA()) && p(\"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.\");\n }\n /** Deletes the specified database. */ return e.delete = function(t) {\n return l(\"SimpleDb\", \"Removing database:\", t), Er(window.indexedDB.deleteDatabase(t)).Fn();\n }, \n /** Returns true if IndexedDB is available in the current environment. */ e.Ln = function() {\n if (\"undefined\" == typeof indexedDB) return !1;\n if (e.Bn()) return !0;\n // We extensively use indexed array values and compound keys,\n // which IE and Edge do not support. However, they still have indexedDB\n // defined on the window, so we need to check for them here and make sure\n // to return that persistence is not enabled for those browsers.\n // For tracking support of this feature, see here:\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/status/indexeddbarraysandmultientrysupport/\n // Check the UA string to find out the browser.\n var t = r.getUA(), n = e.On(t), i = 0 < n && n < 10, o = e.qn(t), s = 0 < o && o < 4.5;\n // IE 10\n // ua = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)';\n // IE 11\n // ua = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';\n // Edge\n // ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML,\n // like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0';\n // iOS Safari: Disable for users running iOS version < 10.\n return !(t.indexOf(\"MSIE \") > 0 || t.indexOf(\"Trident/\") > 0 || t.indexOf(\"Edge/\") > 0 || i || s);\n }, \n /**\n * Returns true if the backing IndexedDB store is the Node IndexedDBShim\n * (see https://github.com/axemclion/IndexedDBShim).\n */\n e.Bn = function() {\n var t;\n return \"undefined\" != typeof process && \"YES\" === (null === (t = process.env) || void 0 === t ? void 0 : t.Un);\n }, \n /** Helper to get a typed SimpleDbStore from a transaction. */ e.Qn = function(t, e) {\n return t.store(e);\n }, \n // visible for testing\n /** Parse User Agent to determine iOS version. Returns -1 if not found. */\n e.On = function(t) {\n var e = t.match(/i(?:phone|pad|pod) os ([\\d_]+)/i), n = e ? e[1].split(\"_\").slice(0, 2).join(\".\") : \"-1\";\n return Number(n);\n }, \n // visible for testing\n /** Parse User Agent to determine Android version. Returns -1 if not found. */\n e.qn = function(t) {\n var e = t.match(/Android ([\\d.]+)/i), n = e ? e[1].split(\".\").slice(0, 2).join(\".\") : \"-1\";\n return Number(n);\n }, \n /**\n * Opens the specified database, creating or upgrading it if necessary.\n */\n e.prototype.Wn = function(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n, r = this;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return this.db ? [ 3 /*break*/ , 2 ] : (l(\"SimpleDb\", \"Opening database:\", this.name), \n n = this, [ 4 /*yield*/ , new Promise((function(t, n) {\n // TODO(mikelehen): Investigate browser compatibility.\n // https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB\n // suggests IE9 and older WebKit browsers handle upgrade\n // differently. They expect setVersion, as described here:\n // https://developer.mozilla.org/en-US/docs/Web/API/IDBVersionChangeRequest/setVersion\n var i = indexedDB.open(r.name, r.version);\n i.onsuccess = function(e) {\n var n = e.target.result;\n t(n);\n }, i.onblocked = function() {\n n(new wr(e, \"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed.\"));\n }, i.onerror = function(t) {\n var r = t.target.error;\n \"VersionError\" === r.name ? n(new c(a.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.\")) : n(new wr(e, r));\n }, i.onupgradeneeded = function(t) {\n l(\"SimpleDb\", 'Database \"' + r.name + '\" requires upgrade from version:', t.oldVersion);\n var e = t.target.result;\n r.Mn.createOrUpgrade(e, i.transaction, t.oldVersion, r.version).next((function() {\n l(\"SimpleDb\", \"Database upgrade to version \" + r.version + \" complete\");\n }));\n };\n })) ]);\n\n case 1:\n n.db = t.sent(), t.label = 2;\n\n case 2:\n return [ 2 /*return*/ , (this.jn && (this.db.onversionchange = function(t) {\n return r.jn(t);\n }), this.db) ];\n }\n }));\n }));\n }, e.prototype.Kn = function(t) {\n this.jn = t, this.db && (this.db.onversionchange = function(e) {\n return t(e);\n });\n }, e.prototype.runTransaction = function(e, n, r, i) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var o, s, u, a, c;\n return t.__generator(this, (function(h) {\n switch (h.label) {\n case 0:\n o = \"readonly\" === n, s = 0, u = function() {\n var n, u, c, h, f;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n ++s, t.label = 1;\n\n case 1:\n return t.trys.push([ 1, 4, , 5 ]), [ 4 /*yield*/ , a.Wn(e) ];\n\n case 2:\n // Wait for the transaction to complete (i.e. IndexedDb's onsuccess event to\n // fire), but still return the original transactionFnResult back to the\n // caller.\n return a.db = t.sent(), n = br.open(a.db, e, o ? \"readonly\" : \"readwrite\", r), u = i(n).catch((function(t) {\n // Abort the transaction if there was an error.\n return n.abort(t), yr.reject(t);\n })).Fn(), c = {}, u.catch((function() {})), [ 4 /*yield*/ , n.Gn ];\n\n case 3:\n return [ 2 /*return*/ , (c.value = (\n // Wait for the transaction to complete (i.e. IndexedDb's onsuccess event to\n // fire), but still return the original transactionFnResult back to the\n // caller.\n t.sent(), u), c) ];\n\n case 4:\n return h = t.sent(), f = \"FirebaseError\" !== h.name && s < 3, l(\"SimpleDb\", \"Transaction failed with error:\", h.message, \"Retrying:\", f), \n a.close(), f ? [ 3 /*break*/ , 5 ] : [ 2 /*return*/ , {\n value: Promise.reject(h)\n } ];\n\n case 5:\n return [ 2 /*return*/ ];\n }\n }));\n }, a = this, h.label = 1;\n\n case 1:\n return [ 5 /*yield**/ , u() ];\n\n case 2:\n if (\"object\" == typeof (c = h.sent())) return [ 2 /*return*/ , c.value ];\n h.label = 3;\n\n case 3:\n return [ 3 /*break*/ , 1 ];\n\n case 4:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }, e.prototype.close = function() {\n this.db && this.db.close(), this.db = void 0;\n }, e;\n}(), mr = /** @class */ function() {\n function t(t) {\n this.zn = t, this.Hn = !1, this.Yn = null;\n }\n return Object.defineProperty(t.prototype, \"Sn\", {\n get: function() {\n return this.Hn;\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"Jn\", {\n get: function() {\n return this.Yn;\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"cursor\", {\n set: function(t) {\n this.zn = t;\n },\n enumerable: !1,\n configurable: !0\n }), \n /**\n * This function can be called to stop iteration at any point.\n */\n t.prototype.done = function() {\n this.Hn = !0;\n }, \n /**\n * This function can be called to skip to that next key, which could be\n * an index or a primary key.\n */\n t.prototype.Xn = function(t) {\n this.Yn = t;\n }, \n /**\n * Delete the current cursor value from the object store.\n *\n * NOTE: You CANNOT do this with a keysOnly query.\n */\n t.prototype.delete = function() {\n return Er(this.zn.delete());\n }, t;\n}(), wr = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this, a.UNAVAILABLE, \"IndexedDB transaction '\" + t + \"' failed: \" + n) || this).name = \"IndexedDbTransactionError\", \n r;\n }\n return t.__extends(n, e), n;\n}(c);\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * A helper for running delayed tasks following an exponential backoff curve\n * between attempts.\n *\n * Each delay is made up of a \"base\" delay which follows the exponential\n * backoff curve, and a +/- 50% \"jitter\" that is calculated and added to the\n * base delay. This prevents clients from accidentally synchronizing their\n * delays causing spikes of load to the backend.\n */\n/** Verifies whether `e` is an IndexedDbTransactionError. */ function _r(t) {\n // Use name equality, as instanceof checks on errors don't work with errors\n // that wrap other errors.\n return \"IndexedDbTransactionError\" === t.name;\n}\n\n/**\n * Wraps an IDBTransaction and exposes a store() method to get a handle to a\n * specific object store.\n */ var br = /** @class */ function() {\n function t(t, e) {\n var n = this;\n this.action = t, this.transaction = e, this.aborted = !1, \n /**\n * A promise that resolves with the result of the IndexedDb transaction.\n */\n this.Zn = new dr, this.transaction.oncomplete = function() {\n n.Zn.resolve();\n }, this.transaction.onabort = function() {\n e.error ? n.Zn.reject(new wr(t, e.error)) : n.Zn.resolve();\n }, this.transaction.onerror = function(e) {\n var r = Nr(e.target.error);\n n.Zn.reject(new wr(t, r));\n };\n }\n return t.open = function(e, n, r, i) {\n try {\n return new t(n, e.transaction(i, r));\n } catch (e) {\n throw new wr(n, e);\n }\n }, Object.defineProperty(t.prototype, \"Gn\", {\n get: function() {\n return this.Zn.promise;\n },\n enumerable: !1,\n configurable: !0\n }), t.prototype.abort = function(t) {\n t && this.Zn.reject(t), this.aborted || (l(\"SimpleDb\", \"Aborting transaction:\", t ? t.message : \"Client-initiated abort\"), \n this.aborted = !0, this.transaction.abort());\n }, \n /**\n * Returns a SimpleDbStore for the specified store. All\n * operations performed on the SimpleDbStore happen within the context of this\n * transaction and it cannot be used anymore once the transaction is\n * completed.\n *\n * Note that we can't actually enforce that the KeyType and ValueType are\n * correct, but they allow type safety through the rest of the consuming code.\n */\n t.prototype.store = function(t) {\n var e = this.transaction.objectStore(t);\n return new Ir(e);\n }, t;\n}(), Ir = /** @class */ function() {\n function t(t) {\n this.store = t;\n }\n return t.prototype.put = function(t, e) {\n var n;\n return void 0 !== e ? (l(\"SimpleDb\", \"PUT\", this.store.name, t, e), n = this.store.put(e, t)) : (l(\"SimpleDb\", \"PUT\", this.store.name, \"\", t), \n n = this.store.put(t)), Er(n);\n }, \n /**\n * Adds a new value into an Object Store and returns the new key. Similar to\n * IndexedDb's `add()`, this method will fail on primary key collisions.\n *\n * @param value The object to write.\n * @return The key of the value to add.\n */\n t.prototype.add = function(t) {\n return l(\"SimpleDb\", \"ADD\", this.store.name, t, t), Er(this.store.add(t));\n }, \n /**\n * Gets the object with the specified key from the specified store, or null\n * if no object exists with the specified key.\n *\n * @key The key of the object to get.\n * @return The object with the specified key or null if no object exists.\n */\n t.prototype.get = function(t) {\n var e = this;\n // We're doing an unsafe cast to ValueType.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Er(this.store.get(t)).next((function(n) {\n // Normalize nonexistence to null.\n return void 0 === n && (n = null), l(\"SimpleDb\", \"GET\", e.store.name, t, n), n;\n }));\n }, t.prototype.delete = function(t) {\n return l(\"SimpleDb\", \"DELETE\", this.store.name, t), Er(this.store.delete(t));\n }, \n /**\n * If we ever need more of the count variants, we can add overloads. For now,\n * all we need is to count everything in a store.\n *\n * Returns the number of rows in the store.\n */\n t.prototype.count = function() {\n return l(\"SimpleDb\", \"COUNT\", this.store.name), Er(this.store.count());\n }, t.prototype.ts = function(t, e) {\n var n = this.cursor(this.options(t, e)), r = [];\n return this.es(n, (function(t, e) {\n r.push(e);\n })).next((function() {\n return r;\n }));\n }, t.prototype.ns = function(t, e) {\n l(\"SimpleDb\", \"DELETE ALL\", this.store.name);\n var n = this.options(t, e);\n n.ss = !1;\n var r = this.cursor(n);\n return this.es(r, (function(t, e, n) {\n return n.delete();\n }));\n }, t.prototype.rs = function(t, e) {\n var n;\n e ? n = t : (n = {}, e = t);\n var r = this.cursor(n);\n return this.es(r, e);\n }, \n /**\n * Iterates over a store, but waits for the given callback to complete for\n * each entry before iterating the next entry. This allows the callback to do\n * asynchronous work to determine if this iteration should continue.\n *\n * The provided callback should return `true` to continue iteration, and\n * `false` otherwise.\n */\n t.prototype.os = function(t) {\n var e = this.cursor({});\n return new yr((function(n, r) {\n e.onerror = function(t) {\n var e = Nr(t.target.error);\n r(e);\n }, e.onsuccess = function(e) {\n var r = e.target.result;\n r ? t(r.primaryKey, r.value).next((function(t) {\n t ? r.continue() : n();\n })) : n();\n };\n }));\n }, t.prototype.es = function(t, e) {\n var n = [];\n return new yr((function(r, i) {\n t.onerror = function(t) {\n i(t.target.error);\n }, t.onsuccess = function(t) {\n var i = t.target.result;\n if (i) {\n var o = new mr(i), s = e(i.primaryKey, i.value, o);\n if (s instanceof yr) {\n var u = s.catch((function(t) {\n return o.done(), yr.reject(t);\n }));\n n.push(u);\n }\n o.Sn ? r() : null === o.Jn ? i.continue() : i.continue(o.Jn);\n } else r();\n };\n })).next((function() {\n return yr.$n(n);\n }));\n }, t.prototype.options = function(t, e) {\n var n = void 0;\n return void 0 !== t && (\"string\" == typeof t ? n = t : e = t), {\n index: n,\n range: e\n };\n }, t.prototype.cursor = function(t) {\n var e = \"next\";\n if (t.reverse && (e = \"prev\"), t.index) {\n var n = this.store.index(t.index);\n return t.ss ? n.openKeyCursor(t.range, e) : n.openCursor(t.range, e);\n }\n return this.store.openCursor(t.range, e);\n }, t;\n}();\n\n/**\n * A wrapper around an IDBObjectStore providing an API that:\n *\n * 1) Has generic KeyType / ValueType parameters to provide strongly-typed\n * methods for acting against the object store.\n * 2) Deals with IndexedDB's onsuccess / onerror event callbacks, making every\n * method return a PersistencePromise instead.\n * 3) Provides a higher-level API to avoid needing to do excessive wrapping of\n * intermediate IndexedDB types (IDBCursorWithValue, etc.)\n */\n/**\n * Wraps an IDBRequest in a PersistencePromise, using the onsuccess / onerror\n * handlers to resolve / reject the PersistencePromise as appropriate.\n */\nfunction Er(t) {\n return new yr((function(e, n) {\n t.onsuccess = function(t) {\n var n = t.target.result;\n e(n);\n }, t.onerror = function(t) {\n var e = Nr(t.target.error);\n n(e);\n };\n }));\n}\n\n// Guard so we only report the error once.\nvar Tr = !1;\n\nfunction Nr(t) {\n var e = gr.On(r.getUA());\n if (e >= 12.2 && e < 13) {\n var n = \"An internal error was encountered in the Indexed Database server\";\n if (t.message.indexOf(n) >= 0) {\n // Wrap error in a more descriptive one.\n var i = new c(\"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.\");\n return Tr || (Tr = !0, \n // Throw a global exception outside of this promise chain, for the user to\n // potentially catch.\n setTimeout((function() {\n throw i;\n }), 0)), i;\n }\n }\n return t;\n}\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** The Platform's 'window' implementation or null if not available. */ function Ar() {\n // `window` is not always available, e.g. in ReactNative and WebWorkers.\n // eslint-disable-next-line no-restricted-globals\n return \"undefined\" != typeof window ? window : null;\n}\n\n/** The Platform's 'document' implementation or null if not available. */ function Sr() {\n // `document` is not always available, e.g. in ReactNative and WebWorkers.\n // eslint-disable-next-line no-restricted-globals\n return \"undefined\" != typeof document ? document : null;\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Represents an operation scheduled to be run in the future on an AsyncQueue.\n *\n * It is created via DelayedOperation.createAndSchedule().\n *\n * Supports cancellation (via cancel()) and early execution (via skipDelay()).\n *\n * Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type\n * in newer versions of TypeScript defines `finally`, which is not available in\n * IE.\n */ var Dr = /** @class */ function() {\n function t(t, e, n, r, i) {\n this.cs = t, this.dn = e, this.us = n, this.op = r, this.hs = i, this.ls = new dr, \n this.then = this.ls.promise.then.bind(this.ls.promise), \n // It's normal for the deferred promise to be canceled (due to cancellation)\n // and so we attach a dummy catch callback to avoid\n // 'UnhandledPromiseRejectionWarning' log spam.\n this.ls.promise.catch((function(t) {}))\n /**\n * Creates and returns a DelayedOperation that has been scheduled to be\n * executed on the provided asyncQueue after the provided delayMs.\n *\n * @param asyncQueue The queue to schedule the operation on.\n * @param id A Timer ID identifying the type of operation this is.\n * @param delayMs The delay (ms) before the operation should be scheduled.\n * @param op The operation to run.\n * @param removalCallback A callback to be called synchronously once the\n * operation is executed or canceled, notifying the AsyncQueue to remove it\n * from its delayedOperations list.\n * PORTING NOTE: This exists to prevent making removeDelayedOperation() and\n * the DelayedOperation class public.\n */;\n }\n return t._s = function(e, n, r, i, o) {\n var s = new t(e, n, Date.now() + r, i, o);\n return s.start(r), s;\n }, \n /**\n * Starts the timer. This is called immediately after construction by\n * createAndSchedule().\n */\n t.prototype.start = function(t) {\n var e = this;\n this.fs = setTimeout((function() {\n return e.ds();\n }), t);\n }, \n /**\n * Queues the operation to run immediately (if it hasn't already been run or\n * canceled).\n */\n t.prototype.pn = function() {\n return this.ds();\n }, \n /**\n * Cancels the operation if it hasn't already been executed or canceled. The\n * promise will be rejected.\n *\n * As long as the operation has not yet been run, calling cancel() provides a\n * guarantee that the operation will not be run.\n */\n t.prototype.cancel = function(t) {\n null !== this.fs && (this.clearTimeout(), this.ls.reject(new c(a.CANCELLED, \"Operation cancelled\" + (t ? \": \" + t : \"\"))));\n }, t.prototype.ds = function() {\n var t = this;\n this.cs.ws((function() {\n return null !== t.fs ? (t.clearTimeout(), t.op().then((function(e) {\n return t.ls.resolve(e);\n }))) : Promise.resolve();\n }));\n }, t.prototype.clearTimeout = function() {\n null !== this.fs && (this.hs(this), clearTimeout(this.fs), this.fs = null);\n }, t;\n}(), xr = /** @class */ function() {\n function e() {\n var t = this;\n // The last promise in the queue.\n this.Ts = Promise.resolve(), \n // A list of retryable operations. Retryable operations are run in order and\n // retried with backoff.\n this.Es = [], \n // Is this AsyncQueue being shut down? Once it is set to true, it will not\n // be changed again.\n this.Is = !1, \n // Operations scheduled to be queued in the future. Operations are\n // automatically removed after they are run or canceled.\n this.As = [], \n // visible for testing\n this.Rs = null, \n // Flag set while there's an outstanding AsyncQueue operation, used for\n // assertion sanity-checks.\n this.gs = !1, \n // List of TimerIds to fast-forward delays for.\n this.Ps = [], \n // Backoff timer used to schedule retries for retryable operations\n this.ys = new vr(this, \"async_queue_retry\" /* AsyncQueueRetry */), \n // Visibility handler that triggers an immediate retry of all retryable\n // operations. Meant to speed up recovery when we regain file system access\n // after page comes into foreground.\n this.Vs = function() {\n var e = Sr();\n e && l(\"AsyncQueue\", \"Visibility state changed to \", e.visibilityState), t.ys.Vn();\n };\n var e = Sr();\n e && \"function\" == typeof e.addEventListener && e.addEventListener(\"visibilitychange\", this.Vs);\n }\n return Object.defineProperty(e.prototype, \"ps\", {\n // Is this AsyncQueue being shut down? If true, this instance will not enqueue\n // any new operations, Promises from enqueue requests will not resolve.\n get: function() {\n return this.Is;\n },\n enumerable: !1,\n configurable: !0\n }), \n /**\n * Adds a new operation to the queue without waiting for it to complete (i.e.\n * we ignore the Promise result).\n */\n e.prototype.ws = function(t) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.enqueue(t);\n }, \n /**\n * Regardless if the queue has initialized shutdown, adds a new operation to the\n * queue without waiting for it to complete (i.e. we ignore the Promise result).\n */\n e.prototype.bs = function(t) {\n this.vs(), \n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.Ss(t);\n }, \n /**\n * Initialize the shutdown of this queue. Once this method is called, the\n * only possible way to request running an operation is through\n * `enqueueEvenWhileRestricted()`.\n */\n e.prototype.Ds = function() {\n if (!this.Is) {\n this.Is = !0;\n var t = Sr();\n t && \"function\" == typeof t.removeEventListener && t.removeEventListener(\"visibilitychange\", this.Vs);\n }\n }, \n /**\n * Adds a new operation to the queue. Returns a promise that will be resolved\n * when the promise returned by the new operation is (with its value).\n */\n e.prototype.enqueue = function(t) {\n return this.vs(), this.Is ? new Promise((function(t) {})) : this.Ss(t);\n }, \n /**\n * Enqueue a retryable operation.\n *\n * A retryable operation is rescheduled with backoff if it fails with a\n * IndexedDbTransactionError (the error type used by SimpleDb). All\n * retryable operations are executed in order and only run if all prior\n * operations were retried successfully.\n */\n e.prototype.Cs = function(t) {\n var e = this;\n this.ws((function() {\n return e.Es.push(t), e.Ns();\n }));\n }, \n /**\n * Runs the next operation from the retryable queue. If the operation fails,\n * reschedules with backoff.\n */\n e.prototype.Ns = function() {\n return t.__awaiter(this, void 0, void 0, (function() {\n var e, n = this;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n if (0 === this.Es.length) return [ 3 /*break*/ , 5 ];\n t.label = 1;\n\n case 1:\n return t.trys.push([ 1, 3, , 4 ]), [ 4 /*yield*/ , this.Es[0]() ];\n\n case 2:\n return t.sent(), this.Es.shift(), this.ys.reset(), [ 3 /*break*/ , 4 ];\n\n case 3:\n if (!_r(e = t.sent())) throw e;\n // Failure will be handled by AsyncQueue\n return l(\"AsyncQueue\", \"Operation failed with retryable error: \" + e), \n [ 3 /*break*/ , 4 ];\n\n case 4:\n this.Es.length > 0 && \n // If there are additional operations, we re-schedule `retryNextOp()`.\n // This is necessary to run retryable operations that failed during\n // their initial attempt since we don't know whether they are already\n // enqueued. If, for example, `op1`, `op2`, `op3` are enqueued and `op1`\n // needs to be re-run, we will run `op1`, `op1`, `op2` using the\n // already enqueued calls to `retryNextOp()`. `op3()` will then run in the\n // call scheduled here.\n // Since `backoffAndRun()` cancels an existing backoff and schedules a\n // new backoff on every call, there is only ever a single additional\n // operation in the queue.\n this.ys.gn((function() {\n return n.Ns();\n })), t.label = 5;\n\n case 5:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }, e.prototype.Ss = function(t) {\n var e = this, n = this.Ts.then((function() {\n return e.gs = !0, t().catch((function(t) {\n // Re-throw the error so that this.tail becomes a rejected Promise and\n // all further attempts to chain (via .then) will just short-circuit\n // and return the rejected Promise.\n throw e.Rs = t, e.gs = !1, p(\"INTERNAL UNHANDLED ERROR: \", \n /**\n * Chrome includes Error.message in Error.stack. Other browsers do not.\n * This returns expected output of message + stack when available.\n * @param error Error or FirestoreError\n */\n function(t) {\n var e = t.message || \"\";\n return t.stack && (e = t.stack.includes(t.message) ? t.stack : t.message + \"\\n\" + t.stack), \n e;\n }(t)), t;\n })).then((function(t) {\n return e.gs = !1, t;\n }));\n }));\n return this.Ts = n, n;\n }, \n /**\n * Schedules an operation to be queued on the AsyncQueue once the specified\n * `delayMs` has elapsed. The returned DelayedOperation can be used to cancel\n * or fast-forward the operation prior to its running.\n */\n e.prototype.yn = function(t, e, n) {\n var r = this;\n this.vs(), \n // Fast-forward delays for timerIds that have been overriden.\n this.Ps.indexOf(t) > -1 && (e = 0);\n var i = Dr._s(this, t, e, n, (function(t) {\n return r.Fs(t);\n }));\n return this.As.push(i), i;\n }, e.prototype.vs = function() {\n this.Rs && y();\n }, \n /**\n * Verifies there's an operation currently in-progress on the AsyncQueue.\n * Unfortunately we can't verify that the running code is in the promise chain\n * of that operation, so this isn't a foolproof check, but it should be enough\n * to catch some bugs.\n */\n e.prototype.xs = function() {}, \n /**\n * Waits until all currently queued tasks are finished executing. Delayed\n * operations are not run.\n */\n e.prototype.$s = function() {\n return t.__awaiter(this, void 0, void 0, (function() {\n var e;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return [ 4 /*yield*/ , e = this.Ts ];\n\n case 1:\n t.sent(), t.label = 2;\n\n case 2:\n if (e !== this.Ts) return [ 3 /*break*/ , 0 ];\n t.label = 3;\n\n case 3:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }, \n /**\n * For Tests: Determine if a delayed operation with a particular TimerId\n * exists.\n */\n e.prototype.ks = function(t) {\n for (var e = 0, n = this.As; e < n.length; e++) {\n if (n[e].dn === t) return !0;\n }\n return !1;\n }, \n /**\n * For Tests: Runs some or all delayed operations early.\n *\n * @param lastTimerId Delayed operations up to and including this TimerId will\n * be drained. Pass TimerId.All to run all delayed operations.\n * @returns a Promise that resolves once all operations have been run.\n */\n e.prototype.Ms = function(t) {\n var e = this;\n // Note that draining may generate more delayed ops, so we do that first.\n return this.$s().then((function() {\n // Run ops in the same order they'd run if they ran naturally.\n e.As.sort((function(t, e) {\n return t.us - e.us;\n }));\n for (var n = 0, r = e.As; n < r.length; n++) {\n var i = r[n];\n if (i.pn(), \"all\" /* All */ !== t && i.dn === t) break;\n }\n return e.$s();\n }));\n }, \n /**\n * For Tests: Skip all subsequent delays for a timer id.\n */\n e.prototype.Os = function(t) {\n this.Ps.push(t);\n }, \n /** Called once a DelayedOperation is run or canceled. */ e.prototype.Fs = function(t) {\n // NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.\n var e = this.As.indexOf(t);\n this.As.splice(e, 1);\n }, e;\n}();\n\n/**\n * Returns a FirestoreError that can be surfaced to the user if the provided\n * error is an IndexedDbTransactionError. Re-throws the error otherwise.\n */\nfunction Lr(t, e) {\n if (p(\"AsyncQueue\", e + \": \" + t), _r(t)) return new c(a.UNAVAILABLE, e + \": \" + t);\n throw t;\n}\n\nvar kr = function() {\n this.Ls = void 0, this.listeners = [];\n}, Rr = function() {\n this.Bs = new it((function(t) {\n return Hn(t);\n }), Qn), this.onlineState = \"Unknown\" /* Unknown */ , this.qs = new Set;\n};\n\nfunction Or(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o, s, u, a, c;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n if (r = m(e), i = n.query, o = !1, (s = r.Bs.get(i)) || (o = !0, s = new kr), !o) return [ 3 /*break*/ , 4 ];\n t.label = 1;\n\n case 1:\n return t.trys.push([ 1, 3, , 4 ]), u = s, [ 4 /*yield*/ , r.Us(i) ];\n\n case 2:\n return u.Ls = t.sent(), [ 3 /*break*/ , 4 ];\n\n case 3:\n return a = t.sent(), c = Lr(a, \"Initialization of query '\" + Yn(n.query) + \"' failed\"), \n [ 2 /*return*/ , void n.onError(c) ];\n\n case 4:\n return r.Bs.set(i, s), s.listeners.push(n), \n // Run global snapshot listeners if a consistent snapshot has been emitted.\n n.Qs(r.onlineState), s.Ls && n.Ws(s.Ls) && Cr(r), [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\nfunction Pr(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o, s, u;\n return t.__generator(this, (function(t) {\n return r = m(e), i = n.query, o = !1, (s = r.Bs.get(i)) && (u = s.listeners.indexOf(n)) >= 0 && (s.listeners.splice(u, 1), \n o = 0 === s.listeners.length), o ? [ 2 /*return*/ , (r.Bs.delete(i), r.js(i)) ] : [ 2 /*return*/ ];\n }));\n }));\n}\n\nfunction Vr(t, e) {\n for (var n = m(t), r = !1, i = 0, o = e; i < o.length; i++) {\n var s = o[i], u = s.query, a = n.Bs.get(u);\n if (a) {\n for (var c = 0, h = a.listeners; c < h.length; c++) {\n h[c].Ws(s) && (r = !0);\n }\n a.Ls = s;\n }\n }\n r && Cr(n);\n}\n\nfunction Ur(t, e, n) {\n var r = m(t), i = r.Bs.get(e);\n if (i) for (var o = 0, s = i.listeners; o < s.length; o++) {\n s[o].onError(n);\n }\n // Remove all listeners. NOTE: We don't need to call syncEngine.unlisten()\n // after an error.\n r.Bs.delete(e);\n}\n\n// Call all global snapshot listeners that have been set.\nfunction Cr(t) {\n t.qs.forEach((function(t) {\n t.next();\n }));\n}\n\n/**\n * QueryListener takes a series of internal view snapshots and determines\n * when to raise the event.\n *\n * It uses an Observer to dispatch events.\n */ var Fr = /** @class */ function() {\n function t(t, e, n) {\n this.query = t, this.Ks = e, \n /**\n * Initial snapshots (e.g. from cache) may not be propagated to the wrapped\n * observer. This flag is set to true once we've actually raised an event.\n */\n this.Gs = !1, this.zs = null, this.onlineState = \"Unknown\" /* Unknown */ , this.options = n || {}\n /**\n * Applies the new ViewSnapshot to this listener, raising a user-facing event\n * if applicable (depending on what changed, whether the user has opted into\n * metadata-only changes, etc.). Returns true if a user-facing event was\n * indeed raised.\n */;\n }\n return t.prototype.Ws = function(t) {\n if (!this.options.includeMetadataChanges) {\n for (\n // Remove the metadata only changes.\n var e = [], n = 0, r = t.docChanges; n < r.length; n++) {\n var i = r[n];\n 3 /* Metadata */ !== i.type && e.push(i);\n }\n t = new Ft(t.query, t.docs, t.Qt, e, t.Wt, t.fromCache, t.jt, \n /* excludesMetadataChanges= */ !0);\n }\n var o = !1;\n return this.Gs ? this.Hs(t) && (this.Ks.next(t), o = !0) : this.Ys(t, this.onlineState) && (this.Js(t), \n o = !0), this.zs = t, o;\n }, t.prototype.onError = function(t) {\n this.Ks.error(t);\n }, \n /** Returns whether a snapshot was raised. */ t.prototype.Qs = function(t) {\n this.onlineState = t;\n var e = !1;\n return this.zs && !this.Gs && this.Ys(this.zs, t) && (this.Js(this.zs), e = !0), \n e;\n }, t.prototype.Ys = function(t, e) {\n // Always raise the first event when we're synced\n if (!t.fromCache) return !0;\n // NOTE: We consider OnlineState.Unknown as online (it should become Offline\n // or Online if we wait long enough).\n var n = \"Offline\" /* Offline */ !== e;\n // Don't raise the event if we're online, aren't synced yet (checked\n // above) and are waiting for a sync.\n return !(this.options.Xs && n || t.docs.m() && \"Offline\" /* Offline */ !== e);\n // Raise data from cache if we have any documents or we are offline\n }, t.prototype.Hs = function(t) {\n // We don't need to handle includeDocumentMetadataChanges here because\n // the Metadata only changes have already been stripped out if needed.\n // At this point the only changes we will see are the ones we should\n // propagate.\n if (t.docChanges.length > 0) return !0;\n var e = this.zs && this.zs.hasPendingWrites !== t.hasPendingWrites;\n return !(!t.jt && !e) && !0 === this.options.includeMetadataChanges;\n // Generally we should have hit one of the cases above, but it's possible\n // to get here if there were only metadata docChanges and they got\n // stripped out.\n }, t.prototype.Js = function(t) {\n t = Ft.Gt(t.query, t.docs, t.Wt, t.fromCache), this.Gs = !0, this.Ks.next(t);\n }, t;\n}(), Mr = /** @class */ function() {\n function t(t) {\n this.uid = t;\n }\n return t.prototype.Zs = function() {\n return null != this.uid;\n }, \n /**\n * Returns a key representing this user, suitable for inclusion in a\n * dictionary.\n */\n t.prototype.ti = function() {\n return this.Zs() ? \"uid:\" + this.uid : \"anonymous-user\";\n }, t.prototype.isEqual = function(t) {\n return t.uid === this.uid;\n }, t;\n}();\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Simple wrapper around a nullable UID. Mostly exists to make code more\n * readable.\n */\n/** A user with a null UID. */ Mr.UNAUTHENTICATED = new Mr(null), \n// TODO(mikelehen): Look into getting a proper uid-equivalent for\n// non-FirebaseAuth providers.\nMr.ei = new Mr(\"google-credentials-uid\"), Mr.ni = new Mr(\"first-party-uid\");\n\n/**\n * @license\n * Copyright 2018 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * `ListenSequence` is a monotonic sequence. It is initialized with a minimum value to\n * exceed. All subsequent calls to next will return increasing values. If provided with a\n * `SequenceNumberSyncer`, it will additionally bump its next value when told of a new value, as\n * well as write out sequence numbers that it produces via `next()`.\n */\nvar qr = /** @class */ function() {\n function t(t, e) {\n var n = this;\n this.previousValue = t, e && (e.si = function(t) {\n return n.ii(t);\n }, this.ri = function(t) {\n return e.oi(t);\n });\n }\n return t.prototype.ii = function(t) {\n return this.previousValue = Math.max(t, this.previousValue), this.previousValue;\n }, t.prototype.next = function() {\n var t = ++this.previousValue;\n return this.ri && this.ri(t), t;\n }, t;\n}();\n\n/** Assembles the key for a client state in WebStorage */\nfunction jr(t, e) {\n return \"firestore_clients_\" + t + \"_\" + e;\n}\n\n// The format of the WebStorage key that stores the mutation state is:\n// firestore_mutations__\n// (for unauthenticated users)\n// or: firestore_mutations___\n// 'user_uid' is last to avoid needing to escape '_' characters that it might\n// contain.\n/** Assembles the key for a mutation batch in WebStorage */ function Gr(t, e, n) {\n var r = \"firestore_mutations_\" + t + \"_\" + n;\n return e.Zs() && (r += \"_\" + e.uid), r;\n}\n\n// The format of the WebStorage key that stores a query target's metadata is:\n// firestore_targets__\n/** Assembles the key for a query state in WebStorage */ function zr(t, e) {\n return \"firestore_targets_\" + t + \"_\" + e;\n}\n\n// The WebStorage prefix that stores the primary tab's online state. The\n// format of the key is:\n// firestore_online_state_\n/**\n * Holds the state of a mutation batch, including its user ID, batch ID and\n * whether the batch is 'pending', 'acknowledged' or 'rejected'.\n */\n// Visible for testing\nqr.ai = -1;\n\nvar Br = /** @class */ function() {\n function t(t, e, n, r) {\n this.user = t, this.batchId = e, this.state = n, this.error = r\n /**\n * Parses a MutationMetadata from its JSON representation in WebStorage.\n * Logs a warning and returns null if the format of the data is not valid.\n */;\n }\n return t.ci = function(e, n, r) {\n var i = JSON.parse(r), o = \"object\" == typeof i && -1 !== [ \"pending\", \"acknowledged\", \"rejected\" ].indexOf(i.state) && (void 0 === i.error || \"object\" == typeof i.error), s = void 0;\n return o && i.error && ((o = \"string\" == typeof i.error.message && \"string\" == typeof i.error.code) && (s = new c(i.error.code, i.error.message))), \n o ? new t(e, n, i.state, s) : (p(\"SharedClientState\", \"Failed to parse mutation state for ID '\" + n + \"': \" + r), \n null);\n }, t.prototype.ui = function() {\n var t = {\n state: this.state,\n updateTimeMs: Date.now()\n };\n return this.error && (t.error = {\n code: this.error.code,\n message: this.error.message\n }), JSON.stringify(t);\n }, t;\n}(), Wr = /** @class */ function() {\n function t(t, e, n) {\n this.targetId = t, this.state = e, this.error = n\n /**\n * Parses a QueryTargetMetadata from its JSON representation in WebStorage.\n * Logs a warning and returns null if the format of the data is not valid.\n */;\n }\n return t.ci = function(e, n) {\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;\n return i && r.error && ((i = \"string\" == typeof r.error.message && \"string\" == typeof r.error.code) && (o = new c(r.error.code, r.error.message))), \n i ? new t(e, r.state, o) : (p(\"SharedClientState\", \"Failed to parse target state for ID '\" + e + \"': \" + n), \n null);\n }, t.prototype.ui = function() {\n var t = {\n state: this.state,\n updateTimeMs: Date.now()\n };\n return this.error && (t.error = {\n code: this.error.code,\n message: this.error.message\n }), JSON.stringify(t);\n }, t;\n}(), Kr = /** @class */ function() {\n function t(t, e) {\n this.clientId = t, this.activeTargetIds = e\n /**\n * Parses a RemoteClientState from the JSON representation in WebStorage.\n * Logs a warning and returns null if the format of the data is not valid.\n */;\n }\n return t.ci = function(e, n) {\n for (var r = JSON.parse(n), i = \"object\" == typeof r && r.activeTargetIds instanceof Array, o = Vt(), s = 0; i && s < r.activeTargetIds.length; ++s) i = ct(r.activeTargetIds[s]), \n o = o.add(r.activeTargetIds[s]);\n return i ? new t(e, o) : (p(\"SharedClientState\", \"Failed to parse client data for instance '\" + e + \"': \" + n), \n null);\n }, t;\n}(), Qr = /** @class */ function() {\n function t(t, e) {\n this.clientId = t, this.onlineState = e\n /**\n * Parses a SharedOnlineState from its JSON representation in WebStorage.\n * Logs a warning and returns null if the format of the data is not valid.\n */;\n }\n return t.ci = function(e) {\n var n = JSON.parse(e);\n return \"object\" == typeof n && -1 !== [ \"Unknown\", \"Online\", \"Offline\" ].indexOf(n.onlineState) && \"string\" == typeof n.clientId ? new t(n.clientId, n.onlineState) : (p(\"SharedClientState\", \"Failed to parse online state: \" + e), \n null);\n }, t;\n}(), Hr = /** @class */ function() {\n function t() {\n this.activeTargetIds = Vt();\n }\n return t.prototype.hi = function(t) {\n this.activeTargetIds = this.activeTargetIds.add(t);\n }, t.prototype.li = function(t) {\n this.activeTargetIds = this.activeTargetIds.delete(t);\n }, \n /**\n * Converts this entry into a JSON-encoded format we can use for WebStorage.\n * Does not encode `clientId` as it is part of the key in WebStorage.\n */\n t.prototype.ui = function() {\n var t = {\n activeTargetIds: this.activeTargetIds.A(),\n updateTimeMs: Date.now()\n };\n return JSON.stringify(t);\n }, t;\n}(), Yr = /** @class */ function() {\n function e(t, e, n, r, i) {\n this.window = t, this.fn = e, this.persistenceKey = n, this._i = r, this.fi = null, \n this.di = null, this.si = null, this.wi = this.mi.bind(this), this.Ti = new bt(H), \n this.Ei = !1, \n /**\n * Captures WebStorage events that occur before `start()` is called. These\n * events are replayed once `WebStorageSharedClientState` is started.\n */\n this.Ii = [];\n // Escape the special characters mentioned here:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\n var o = n.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n this.storage = this.window.localStorage, this.currentUser = i, this.Ai = jr(this.persistenceKey, this._i), \n this.Ri = \n /** Assembles the key for the current sequence number. */\n function(t) {\n return \"firestore_sequence_number_\" + t;\n }(this.persistenceKey), this.Ti = this.Ti.ot(this._i, new Hr), this.gi = new RegExp(\"^firestore_clients_\" + o + \"_([^_]*)$\"), \n this.Pi = new RegExp(\"^firestore_mutations_\" + o + \"_(\\\\d+)(?:_(.*))?$\"), this.yi = new RegExp(\"^firestore_targets_\" + o + \"_(\\\\d+)$\"), \n this.Vi = \n /** Assembles the key for the online state of the primary tab. */\n function(t) {\n return \"firestore_online_state_\" + t;\n }(this.persistenceKey), \n // Rather than adding the storage observer during start(), we add the\n // storage observer during initialization. This ensures that we collect\n // events before other components populate their initial state (during their\n // respective start() calls). Otherwise, we might for example miss a\n // mutation that is added after LocalStore's start() processed the existing\n // mutations but before we observe WebStorage events.\n this.window.addEventListener(\"storage\", this.wi);\n }\n /** Returns 'true' if WebStorage is available in the current environment. */ return e.Ln = function(t) {\n return !(!t || !t.localStorage);\n }, e.prototype.start = function() {\n return t.__awaiter(this, void 0, void 0, (function() {\n var e, n, r, i, o, s, u, a, c, h, f, l = this;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return [ 4 /*yield*/ , this.fi.pi() ];\n\n case 1:\n for (e = t.sent(), n = 0, r = e; n < r.length; n++) (i = r[n]) !== this._i && (o = this.getItem(jr(this.persistenceKey, i))) && (s = Kr.ci(i, o)) && (this.Ti = this.Ti.ot(s.clientId, s));\n for (this.bi(), (u = this.storage.getItem(this.Vi)) && (a = this.vi(u)) && this.Si(a), \n c = 0, h = this.Ii; c < h.length; c++) f = h[c], this.mi(f);\n return this.Ii = [], \n // Register a window unload hook to remove the client metadata entry from\n // WebStorage even if `shutdown()` was not called.\n this.window.addEventListener(\"unload\", (function() {\n return l.Di();\n })), this.Ei = !0, [ 2 /*return*/ ];\n }\n }));\n }));\n }, e.prototype.oi = function(t) {\n this.setItem(this.Ri, JSON.stringify(t));\n }, e.prototype.Ci = function() {\n return this.Ni(this.Ti);\n }, e.prototype.Fi = function(t) {\n var e = !1;\n return this.Ti.forEach((function(n, r) {\n r.activeTargetIds.has(t) && (e = !0);\n })), e;\n }, e.prototype.xi = function(t) {\n this.$i(t, \"pending\");\n }, e.prototype.ki = function(t, e, n) {\n this.$i(t, e, n), \n // Once a final mutation result is observed by other clients, they no longer\n // access the mutation's metadata entry. Since WebStorage replays events\n // in order, it is safe to delete the entry right after updating it.\n this.Mi(t);\n }, e.prototype.Oi = function(t) {\n var e = \"not-current\";\n // Lookup an existing query state if the target ID was already registered\n // by another tab\n if (this.Fi(t)) {\n var n = this.storage.getItem(zr(this.persistenceKey, t));\n if (n) {\n var r = Wr.ci(t, n);\n r && (e = r.state);\n }\n }\n return this.Li.hi(t), this.bi(), e;\n }, e.prototype.Bi = function(t) {\n this.Li.li(t), this.bi();\n }, e.prototype.qi = function(t) {\n return this.Li.activeTargetIds.has(t);\n }, e.prototype.Ui = function(t) {\n this.removeItem(zr(this.persistenceKey, t));\n }, e.prototype.Qi = function(t, e, n) {\n this.Wi(t, e, n);\n }, e.prototype.ji = function(t, e, n) {\n var r = this;\n e.forEach((function(t) {\n r.Mi(t);\n })), this.currentUser = t, n.forEach((function(t) {\n r.xi(t);\n }));\n }, e.prototype.Ki = function(t) {\n this.Gi(t);\n }, e.prototype.Di = function() {\n this.Ei && (this.window.removeEventListener(\"storage\", this.wi), this.removeItem(this.Ai), \n this.Ei = !1);\n }, e.prototype.getItem = function(t) {\n var e = this.storage.getItem(t);\n return l(\"SharedClientState\", \"READ\", t, e), e;\n }, e.prototype.setItem = function(t, e) {\n l(\"SharedClientState\", \"SET\", t, e), this.storage.setItem(t, e);\n }, e.prototype.removeItem = function(t) {\n l(\"SharedClientState\", \"REMOVE\", t), this.storage.removeItem(t);\n }, e.prototype.mi = function(e) {\n var n = this, r = e;\n // Note: The function is typed to take Event to be interface-compatible with\n // `Window.addEventListener`.\n if (r.storageArea === this.storage) {\n if (l(\"SharedClientState\", \"EVENT\", r.key, r.newValue), r.key === this.Ai) return void p(\"Received WebStorage notification for local change. Another client might have garbage-collected our state\");\n this.fn.Cs((function() {\n return t.__awaiter(n, void 0, void 0, (function() {\n var e, n, i, o, s, u;\n return t.__generator(this, (function(t) {\n if (this.Ei) {\n if (null !== r.key) if (this.gi.test(r.key)) {\n if (null == r.newValue) return e = this.zi(r.key), [ 2 /*return*/ , this.Hi(e, null) ];\n if (n = this.Yi(r.key, r.newValue)) return [ 2 /*return*/ , this.Hi(n.clientId, n) ];\n } else if (this.Pi.test(r.key)) {\n if (null !== r.newValue && (i = this.Ji(r.key, r.newValue))) return [ 2 /*return*/ , this.Xi(i) ];\n } else if (this.yi.test(r.key)) {\n if (null !== r.newValue && (o = this.Zi(r.key, r.newValue))) return [ 2 /*return*/ , this.tr(o) ];\n } else if (r.key === this.Vi) {\n if (null !== r.newValue && (s = this.vi(r.newValue))) return [ 2 /*return*/ , this.Si(s) ];\n } else r.key === this.Ri && (u = function(t) {\n var e = qr.ai;\n if (null != t) try {\n var n = JSON.parse(t);\n g(\"number\" == typeof n), e = n;\n } catch (t) {\n p(\"SharedClientState\", \"Failed to read sequence number from WebStorage\", t);\n }\n return e;\n }(r.newValue)) !== qr.ai && this.si(u);\n } else this.Ii.push(r);\n return [ 2 /*return*/ ];\n }));\n }));\n }));\n }\n }, Object.defineProperty(e.prototype, \"Li\", {\n get: function() {\n return this.Ti.get(this._i);\n },\n enumerable: !1,\n configurable: !0\n }), e.prototype.bi = function() {\n this.setItem(this.Ai, this.Li.ui());\n }, e.prototype.$i = function(t, e, n) {\n var r = new Br(this.currentUser, t, e, n), i = Gr(this.persistenceKey, this.currentUser, t);\n this.setItem(i, r.ui());\n }, e.prototype.Mi = function(t) {\n var e = Gr(this.persistenceKey, this.currentUser, t);\n this.removeItem(e);\n }, e.prototype.Gi = function(t) {\n var e = {\n clientId: this._i,\n onlineState: t\n };\n this.storage.setItem(this.Vi, JSON.stringify(e));\n }, e.prototype.Wi = function(t, e, n) {\n var r = zr(this.persistenceKey, t), i = new Wr(t, e, n);\n this.setItem(r, i.ui());\n }, \n /**\n * Parses a client state key in WebStorage. Returns null if the key does not\n * match the expected key format.\n */\n e.prototype.zi = function(t) {\n var e = this.gi.exec(t);\n return e ? e[1] : null;\n }, \n /**\n * Parses a client state in WebStorage. Returns 'null' if the value could not\n * be parsed.\n */\n e.prototype.Yi = function(t, e) {\n var n = this.zi(t);\n return Kr.ci(n, e);\n }, \n /**\n * Parses a mutation batch state in WebStorage. Returns 'null' if the value\n * could not be parsed.\n */\n e.prototype.Ji = function(t, e) {\n var n = this.Pi.exec(t), r = Number(n[1]), i = void 0 !== n[2] ? n[2] : null;\n return Br.ci(new Mr(i), r, e);\n }, \n /**\n * Parses a query target state from WebStorage. Returns 'null' if the value\n * could not be parsed.\n */\n e.prototype.Zi = function(t, e) {\n var n = this.yi.exec(t), r = Number(n[1]);\n return Wr.ci(r, e);\n }, \n /**\n * Parses an online state from WebStorage. Returns 'null' if the value\n * could not be parsed.\n */\n e.prototype.vi = function(t) {\n return Qr.ci(t);\n }, e.prototype.Xi = function(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n return e.user.uid === this.currentUser.uid ? [ 2 /*return*/ , this.fi.er(e.batchId, e.state, e.error) ] : (l(\"SharedClientState\", \"Ignoring mutation for non-active user \" + e.user.uid), \n [ 2 /*return*/ ]);\n }));\n }));\n }, e.prototype.tr = function(t) {\n return this.fi.nr(t.targetId, t.state, t.error);\n }, e.prototype.Hi = function(t, e) {\n var n = this, r = e ? this.Ti.ot(t, e) : this.Ti.remove(t), i = this.Ni(this.Ti), o = this.Ni(r), s = [], u = [];\n return o.forEach((function(t) {\n i.has(t) || s.push(t);\n })), i.forEach((function(t) {\n o.has(t) || u.push(t);\n })), this.fi.sr(s, u).then((function() {\n n.Ti = r;\n }));\n }, e.prototype.Si = function(t) {\n // We check whether the client that wrote this online state is still active\n // by comparing its client ID to the list of clients kept active in\n // IndexedDb. If a client does not update their IndexedDb client state\n // within 5 seconds, it is considered inactive and we don't emit an online\n // state event.\n this.Ti.get(t.clientId) && this.di(t.onlineState);\n }, e.prototype.Ni = function(t) {\n var e = Vt();\n return t.forEach((function(t, n) {\n e = e.kt(n.activeTargetIds);\n })), e;\n }, e;\n}(), $r = /** @class */ function() {\n function t() {\n this.ir = new Hr, this.rr = {}, this.di = null, this.si = null;\n }\n return t.prototype.xi = function(t) {\n // No op.\n }, t.prototype.ki = function(t, e, n) {\n // No op.\n }, t.prototype.Oi = function(t) {\n return this.ir.hi(t), this.rr[t] || \"not-current\";\n }, t.prototype.Qi = function(t, e, n) {\n this.rr[t] = e;\n }, t.prototype.Bi = function(t) {\n this.ir.li(t);\n }, t.prototype.qi = function(t) {\n return this.ir.activeTargetIds.has(t);\n }, t.prototype.Ui = function(t) {\n delete this.rr[t];\n }, t.prototype.Ci = function() {\n return this.ir.activeTargetIds;\n }, t.prototype.Fi = function(t) {\n return this.ir.activeTargetIds.has(t);\n }, t.prototype.start = function() {\n return this.ir = new Hr, Promise.resolve();\n }, t.prototype.ji = function(t, e, n) {\n // No op.\n }, t.prototype.Ki = function(t) {\n // No op.\n }, t.prototype.Di = function() {}, t.prototype.oi = function(t) {}, t;\n}(), Xr = /** @class */ function() {\n /**\n * @param batchId The unique ID of this mutation batch.\n * @param localWriteTime The original write time of this mutation.\n * @param baseMutations Mutations that are used to populate the base\n * values when this mutation is applied locally. This can be used to locally\n * overwrite values that are persisted in the remote document cache. Base\n * mutations are never sent to the backend.\n * @param mutations The user-provided mutations in this mutation batch.\n * User-provided mutations are applied both locally and remotely on the\n * backend.\n */\n function t(t, e, n, r) {\n this.batchId = t, this.ar = e, this.baseMutations = n, this.mutations = r\n /**\n * Applies all the mutations in this MutationBatch to the specified document\n * to create a new remote document\n *\n * @param docKey The key of the document to apply mutations to.\n * @param maybeDoc The document to apply mutations to.\n * @param batchResult The result of applying the MutationBatch to the\n * backend.\n */;\n }\n return t.prototype.cr = function(t, e, n) {\n for (var r = n.ur, i = 0; i < this.mutations.length; i++) {\n var o = this.mutations[i];\n o.key.isEqual(t) && (e = dn(o, e, r[i]));\n }\n return e;\n }, \n /**\n * Computes the local view of a document given all the mutations in this\n * batch.\n *\n * @param docKey The key of the document to apply mutations to.\n * @param maybeDoc The document to apply mutations to.\n */\n t.prototype.hr = function(t, e) {\n // First, apply the base state. This allows us to apply non-idempotent\n // transform against a consistent set of values.\n for (var n = 0, r = this.baseMutations; n < r.length; n++) {\n var i = r[n];\n i.key.isEqual(t) && (e = vn(i, e, e, this.ar));\n }\n // Second, apply all user-provided mutations.\n for (var o = e, s = 0, u = this.mutations; s < u.length; s++) {\n var a = u[s];\n a.key.isEqual(t) && (e = vn(a, e, o, this.ar));\n }\n return e;\n }, \n /**\n * Computes the local view for all provided documents given the mutations in\n * this batch.\n */\n t.prototype.lr = function(t) {\n var e = this, n = t;\n // TODO(mrschmidt): This implementation is O(n^2). If we apply the mutations\n // directly (as done in `applyToLocalView()`), we can reduce the complexity\n // to O(n).\n return this.mutations.forEach((function(r) {\n var i = e.hr(r.key, t.get(r.key));\n i && (n = n.ot(r.key, i));\n })), n;\n }, t.prototype.keys = function() {\n return this.mutations.reduce((function(t, e) {\n return t.add(e.key);\n }), Ot());\n }, t.prototype.isEqual = function(t) {\n return this.batchId === t.batchId && Y(this.mutations, t.mutations, (function(t, e) {\n return gn(t, e);\n })) && Y(this.baseMutations, t.baseMutations, (function(t, e) {\n return gn(t, e);\n }));\n }, t;\n}(), Jr = /** @class */ function() {\n function t(t, e, n, \n /**\n * A pre-computed mapping from each mutated document to the resulting\n * version.\n */\n r) {\n this.batch = t, this._r = e, this.ur = n, this.dr = r\n /**\n * Creates a new MutationBatchResult for the given batch and results. There\n * must be one result for each mutation in the batch. This static factory\n * caches a document=>version mapping (docVersions).\n */;\n }\n return t.from = function(e, n, r) {\n g(e.mutations.length === r.length);\n for (var i = kt, o = e.mutations, s = 0; s < o.length; s++) i = i.ot(o[s].key, r[s].version);\n return new t(e, n, r, i);\n }, t;\n}(), Zr = /** @class */ function() {\n function t() {\n // A mapping of document key to the new cache entry that should be written (or null if any\n // existing cache entry should be removed).\n this.wr = new it((function(t) {\n return t.toString();\n }), (function(t, e) {\n return t.isEqual(e);\n })), this.mr = !1;\n }\n return Object.defineProperty(t.prototype, \"readTime\", {\n get: function() {\n return this.Tr;\n },\n set: function(t) {\n this.Tr = t;\n },\n enumerable: !1,\n configurable: !0\n }), \n /**\n * Buffers a `RemoteDocumentCache.addEntry()` call.\n *\n * You can only modify documents that have already been retrieved via\n * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).\n */\n t.prototype.Er = function(t, e) {\n this.Ir(), this.readTime = e, this.wr.set(t.key, t);\n }, \n /**\n * Buffers a `RemoteDocumentCache.removeEntry()` call.\n *\n * You can only remove documents that have already been retrieved via\n * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).\n */\n t.prototype.Ar = function(t, e) {\n this.Ir(), e && (this.readTime = e), this.wr.set(t, null);\n }, \n /**\n * Looks up an entry in the cache. The buffered changes will first be checked,\n * and if no buffered change applies, this will forward to\n * `RemoteDocumentCache.getEntry()`.\n *\n * @param transaction The transaction in which to perform any persistence\n * operations.\n * @param documentKey The key of the entry to look up.\n * @return The cached Document or NoDocument entry, or null if we have nothing\n * cached.\n */\n t.prototype.Rr = function(t, e) {\n this.Ir();\n var n = this.wr.get(e);\n return void 0 !== n ? yr.resolve(n) : this.gr(t, e);\n }, \n /**\n * Looks up several entries in the cache, forwarding to\n * `RemoteDocumentCache.getEntry()`.\n *\n * @param transaction The transaction in which to perform any persistence\n * operations.\n * @param documentKeys The keys of the entries to look up.\n * @return A map of cached `Document`s or `NoDocument`s, indexed by key. If an\n * entry cannot be found, the corresponding key will be mapped to a null\n * value.\n */\n t.prototype.getEntries = function(t, e) {\n return this.Pr(t, e);\n }, \n /**\n * Applies buffered changes to the underlying RemoteDocumentCache, using\n * the provided transaction.\n */\n t.prototype.apply = function(t) {\n return this.Ir(), this.mr = !0, this.yr(t);\n }, \n /** Helper to assert this.changes is not null */ t.prototype.Ir = function() {}, \n t;\n}(), ti = \"The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.\", ei = /** @class */ function() {\n function t() {\n this.Vr = [];\n }\n return t.prototype.pr = function(t) {\n this.Vr.push(t);\n }, t.prototype.br = function() {\n this.Vr.forEach((function(t) {\n return t();\n }));\n }, t;\n}(), ni = /** @class */ function() {\n function t(t, e, n) {\n this.vr = t, this.Sr = e, this.Dr = n\n /**\n * Get the local view of the document identified by `key`.\n *\n * @return Local view of the document or null if we don't have any cached\n * state for it.\n */;\n }\n return t.prototype.Cr = function(t, e) {\n var n = this;\n return this.Sr.Nr(t, e).next((function(r) {\n return n.Fr(t, e, r);\n }));\n }, \n /** Internal version of `getDocument` that allows reusing batches. */ t.prototype.Fr = function(t, e, n) {\n return this.vr.Rr(t, e).next((function(t) {\n for (var r = 0, i = n; r < i.length; r++) {\n t = i[r].hr(e, t);\n }\n return t;\n }));\n }, \n // Returns the view of the given `docs` as they would appear after applying\n // all mutations in the given `batches`.\n t.prototype.$r = function(t, e, n) {\n var r = Dt();\n return e.forEach((function(t, e) {\n for (var i = 0, o = n; i < o.length; i++) {\n e = o[i].hr(t, e);\n }\n r = r.ot(t, e);\n })), r;\n }, \n /**\n * Gets the local view of the documents identified by `keys`.\n *\n * If we don't have cached state for a document in `keys`, a NoDocument will\n * be stored for that key in the resulting set.\n */\n t.prototype.kr = function(t, e) {\n var n = this;\n return this.vr.getEntries(t, e).next((function(e) {\n return n.Mr(t, e);\n }));\n }, \n /**\n * Similar to `getDocuments`, but creates the local view from the given\n * `baseDocs` without retrieving documents from the local store.\n */\n t.prototype.Mr = function(t, e) {\n var n = this;\n return this.Sr.Or(t, e).next((function(r) {\n var i = n.$r(t, e, r), o = St();\n return i.forEach((function(t, e) {\n // TODO(http://b/32275378): Don't conflate missing / deleted.\n e || (e = new Rn(t, st.min())), o = o.ot(t, e);\n })), o;\n }));\n }, \n /**\n * Performs a query against the local view of all documents.\n *\n * @param transaction The persistence transaction.\n * @param query The query to match documents against.\n * @param sinceReadTime If not set to SnapshotVersion.min(), return only\n * documents that have been read since this snapshot version (exclusive).\n */\n t.prototype.Lr = function(t, e, n) {\n /**\n * Returns whether the query matches a single document by path (rather than a\n * collection).\n */\n return function(t) {\n return A.F(t.path) && null === t.collectionGroup && 0 === t.filters.length;\n }(e) ? this.Br(t, e.path) : jn(e) ? this.qr(t, e, n) : this.Ur(t, e, n);\n }, t.prototype.Br = function(t, e) {\n // Just do a simple document lookup.\n return this.Cr(t, new A(e)).next((function(t) {\n var e = Lt();\n return t instanceof kn && (e = e.ot(t.key, t)), e;\n }));\n }, t.prototype.qr = function(t, e, n) {\n var r = this, i = e.collectionGroup, o = Lt();\n return this.Dr.Qr(t, i).next((function(s) {\n return yr.forEach(s, (function(s) {\n var u = function(t, e) {\n return new Pn(e, \n /*collectionGroup=*/ null, t.on.slice(), t.filters.slice(), t.limit, t.an, t.startAt, t.endAt);\n }(e, s.child(i));\n return r.Ur(t, u, n).next((function(t) {\n t.forEach((function(t, e) {\n o = o.ot(t, e);\n }));\n }));\n })).next((function() {\n return o;\n }));\n }));\n }, t.prototype.Ur = function(t, e, n) {\n var r, i, o = this;\n // Query the remote documents and overlay mutations.\n return this.vr.Lr(t, e, n).next((function(n) {\n return r = n, o.Sr.Wr(t, e);\n })).next((function(e) {\n return i = e, o.jr(t, i, r).next((function(t) {\n r = t;\n for (var e = 0, n = i; e < n.length; e++) for (var o = n[e], s = 0, u = o.mutations; s < u.length; s++) {\n var a = u[s], c = a.key, h = r.get(c), f = vn(a, h, h, o.ar);\n r = f instanceof kn ? r.ot(c, f) : r.remove(c);\n }\n }));\n })).next((function() {\n // Finally, filter out any documents that don't actually match\n // the query.\n return r.forEach((function(t, n) {\n $n(e, n) || (r = r.remove(t));\n })), r;\n }));\n }, t.prototype.jr = function(t, e, n) {\n for (var r = Ot(), i = 0, o = e; i < o.length; i++) for (var s = 0, u = o[i].mutations; s < u.length; s++) {\n var a = u[s];\n a instanceof _n && null === n.get(a.key) && (r = r.add(a.key));\n }\n var c = n;\n return this.vr.getEntries(t, r).next((function(t) {\n return t.forEach((function(t, e) {\n null !== e && e instanceof kn && (c = c.ot(t, e));\n })), c;\n }));\n }, t;\n}(), ri = /** @class */ function() {\n function t(t, e, n, r) {\n this.targetId = t, this.fromCache = e, this.Kr = n, this.Gr = r;\n }\n return t.zr = function(e, n) {\n for (var r = Ot(), i = Ot(), o = 0, s = n.docChanges; o < s.length; o++) {\n var u = s[o];\n switch (u.type) {\n case 0 /* Added */ :\n r = r.add(u.doc.key);\n break;\n\n case 1 /* Removed */ :\n i = i.add(u.doc.key);\n // do nothing\n }\n }\n return new t(e, n.fromCache, r, i);\n }, t;\n}();\n\n/**\n * Holds the state of a query target, including its target ID and whether the\n * target is 'not-current', 'current' or 'rejected'.\n */\n// Visible for testing\n/**\n * @license\n * Copyright 2018 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nfunction ii(t, e) {\n var n = t[0], r = t[1], i = e[0], o = e[1], s = H(n, i);\n return 0 === s ? H(r, o) : s;\n}\n\n/**\n * Used to calculate the nth sequence number. Keeps a rolling buffer of the\n * lowest n values passed to `addElement`, and finally reports the largest of\n * them in `maxValue`.\n */ var oi = /** @class */ function() {\n function t(t) {\n this.Hr = t, this.buffer = new Tt(ii), this.Yr = 0;\n }\n return t.prototype.Jr = function() {\n return ++this.Yr;\n }, t.prototype.Xr = function(t) {\n var e = [ t, this.Jr() ];\n if (this.buffer.size < this.Hr) this.buffer = this.buffer.add(e); else {\n var n = this.buffer.last();\n ii(e, n) < 0 && (this.buffer = this.buffer.delete(n).add(e));\n }\n }, Object.defineProperty(t.prototype, \"maxValue\", {\n get: function() {\n // Guaranteed to be non-empty. If we decide we are not collecting any\n // sequence numbers, nthSequenceNumber below short-circuits. If we have\n // decided that we are collecting n sequence numbers, it's because n is some\n // percentage of the existing sequence numbers. That means we should never\n // be in a situation where we are collecting sequence numbers but don't\n // actually have any.\n return this.buffer.last()[0];\n },\n enumerable: !1,\n configurable: !0\n }), t;\n}(), si = {\n Zr: !1,\n eo: 0,\n no: 0,\n so: 0\n}, ui = /** @class */ function() {\n function t(\n // When we attempt to collect, we will only do so if the cache size is greater than this\n // threshold. Passing `COLLECTION_DISABLED` here will cause collection to always be skipped.\n t, \n // The percentage of sequence numbers that we will attempt to collect\n e, \n // A cap on the total number of sequence numbers that will be collected. This prevents\n // us from collecting a huge number of sequence numbers if the cache has grown very large.\n n) {\n this.io = t, this.ro = e, this.oo = n;\n }\n return t.ao = function(e) {\n return new t(e, t.co, t.uo);\n }, t;\n}();\n\nui.ho = -1, ui.lo = 1048576, ui._o = 41943040, ui.co = 10, ui.uo = 1e3, ui.fo = new ui(ui._o, ui.co, ui.uo), \nui.do = new ui(ui.ho, 0, 0);\n\n/**\n * This class is responsible for the scheduling of LRU garbage collection. It handles checking\n * whether or not GC is enabled, as well as which delay to use before the next run.\n */\nvar ai = /** @class */ function() {\n function e(t, e) {\n this.wo = t, this.cs = e, this.mo = !1, this.To = null;\n }\n return e.prototype.start = function(t) {\n this.wo.params.io !== ui.ho && this.Eo(t);\n }, e.prototype.stop = function() {\n this.To && (this.To.cancel(), this.To = null);\n }, Object.defineProperty(e.prototype, \"Ei\", {\n get: function() {\n return null !== this.To;\n },\n enumerable: !1,\n configurable: !0\n }), e.prototype.Eo = function(e) {\n var n = this, r = this.mo ? 3e5 : 6e4;\n l(\"LruGarbageCollector\", \"Garbage collection scheduled in \" + r + \"ms\"), this.To = this.cs.yn(\"lru_garbage_collection\" /* LruGarbageCollection */ , r, (function() {\n return t.__awaiter(n, void 0, void 0, (function() {\n var n;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n this.To = null, this.mo = !0, t.label = 1;\n\n case 1:\n return t.trys.push([ 1, 3, , 7 ]), [ 4 /*yield*/ , e.Io(this.wo) ];\n\n case 2:\n return t.sent(), [ 3 /*break*/ , 7 ];\n\n case 3:\n return _r(n = t.sent()) ? (l(\"LruGarbageCollector\", \"Ignoring IndexedDB error during garbage collection: \", n), \n [ 3 /*break*/ , 6 ]) : [ 3 /*break*/ , 4 ];\n\n case 4:\n return [ 4 /*yield*/ , Do(n) ];\n\n case 5:\n t.sent(), t.label = 6;\n\n case 6:\n return [ 3 /*break*/ , 7 ];\n\n case 7:\n return [ 4 /*yield*/ , this.Eo(e) ];\n\n case 8:\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n }));\n }, e;\n}(), ci = /** @class */ function() {\n function t(t, e) {\n this.Ao = t, this.params = e\n /** Given a percentile of target to collect, returns the number of targets to collect. */;\n }\n return t.prototype.Ro = function(t, e) {\n return this.Ao.Po(t).next((function(t) {\n return Math.floor(e / 100 * t);\n }));\n }, \n /** Returns the nth sequence number, counting in order from the smallest. */ t.prototype.yo = function(t, e) {\n var n = this;\n if (0 === e) return yr.resolve(qr.ai);\n var r = new oi(e);\n return this.Ao.Ce(t, (function(t) {\n return r.Xr(t.sequenceNumber);\n })).next((function() {\n return n.Ao.Vo(t, (function(t) {\n return r.Xr(t);\n }));\n })).next((function() {\n return r.maxValue;\n }));\n }, \n /**\n * Removes targets with a sequence number equal to or less than the given upper bound, and removes\n * document associations with those targets.\n */\n t.prototype.po = function(t, e, n) {\n return this.Ao.po(t, e, n);\n }, \n /**\n * Removes documents that have a sequence number equal to or less than the upper bound and are not\n * otherwise pinned.\n */\n t.prototype.bo = function(t, e) {\n return this.Ao.bo(t, e);\n }, t.prototype.vo = function(t, e) {\n var n = this;\n return this.params.io === ui.ho ? (l(\"LruGarbageCollector\", \"Garbage collection skipped; disabled\"), \n yr.resolve(si)) : this.So(t).next((function(r) {\n return r < n.params.io ? (l(\"LruGarbageCollector\", \"Garbage collection skipped; Cache size \" + r + \" is lower than threshold \" + n.params.io), \n si) : n.Do(t, e);\n }));\n }, t.prototype.So = function(t) {\n return this.Ao.So(t);\n }, t.prototype.Do = function(t, e) {\n var r, i, o, s, u, a, c, h = this, p = Date.now();\n return this.Ro(t, this.params.ro).next((function(e) {\n // Cap at the configured max\n return e > h.params.oo ? (l(\"LruGarbageCollector\", \"Capping sequence numbers to collect down to the maximum of \" + h.params.oo + \" from \" + e), \n i = h.params.oo) : i = e, s = Date.now(), h.yo(t, i);\n })).next((function(n) {\n return r = n, u = Date.now(), h.po(t, r, e);\n })).next((function(e) {\n return o = e, a = Date.now(), h.bo(t, r);\n })).next((function(t) {\n return c = Date.now(), f() <= n.LogLevel.DEBUG && l(\"LruGarbageCollector\", \"LRU Garbage Collection\\n\\tCounted targets in \" + (s - p) + \"ms\\n\\tDetermined least recently used \" + i + \" in \" + (u - s) + \"ms\\n\\tRemoved \" + o + \" targets in \" + (a - u) + \"ms\\n\\tRemoved \" + t + \" documents in \" + (c - a) + \"ms\\nTotal Duration: \" + (c - p) + \"ms\"), \n yr.resolve({\n Zr: !0,\n eo: i,\n no: o,\n so: t\n });\n }));\n }, t;\n}();\n\n/** Implements the steps for LRU garbage collection. */\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Encodes a resource path into a IndexedDb-compatible string form.\n */\nfunction hi(t) {\n for (var e = \"\", n = 0; n < t.length; n++) e.length > 0 && (e = li(e)), e = fi(t.get(n), e);\n return li(e);\n}\n\n/** Encodes a single segment of a resource path into the given result */ function fi(t, e) {\n for (var n = e, r = t.length, i = 0; i < r; i++) {\n var o = t.charAt(i);\n switch (o) {\n case \"\\0\":\n n += \"\u0001\u0010\";\n break;\n\n case \"\u0001\":\n n += \"\u0001\u0011\";\n break;\n\n default:\n n += o;\n }\n }\n return n;\n}\n\n/** Encodes a path separator into the given result */ function li(t) {\n return t + \"\u0001\u0001\";\n}\n\n/**\n * Decodes the given IndexedDb-compatible string form of a resource path into\n * a ResourcePath instance. Note that this method is not suitable for use with\n * decoding resource names from the server; those are One Platform format\n * strings.\n */ function pi(t) {\n // Event the empty path must encode as a path of at least length 2. A path\n // with exactly 2 must be the empty path.\n var e = t.length;\n if (g(e >= 2), 2 === e) return g(\"\u0001\" === t.charAt(0) && \"\u0001\" === t.charAt(1)), E.P();\n // Escape characters cannot exist past the second-to-last position in the\n // source value.\n for (var n = e - 2, r = [], i = \"\", o = 0; o < e; ) {\n // The last two characters of a valid encoded path must be a separator, so\n // there must be an end to this segment.\n var s = t.indexOf(\"\u0001\", o);\n switch ((s < 0 || s > n) && y(), t.charAt(s + 1)) {\n case \"\u0001\":\n var u = t.substring(o, s), a = void 0;\n 0 === i.length ? \n // Avoid copying for the common case of a segment that excludes \\0\n // and \\001\n a = u : (a = i += u, i = \"\"), r.push(a);\n break;\n\n case \"\u0010\":\n i += t.substring(o, s), i += \"\\0\";\n break;\n\n case \"\u0011\":\n // The escape character can be used in the output to encode itself.\n i += t.substring(o, s + 1);\n break;\n\n default:\n y();\n }\n o = s + 2;\n }\n return new E(r);\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** Serializer for values stored in the LocalStore. */ var di = function(t) {\n this.Co = t;\n};\n\n/** Decodes a remote document from storage locally to a Document. */ function vi(t, e) {\n if (e.document) return function(t, e, n) {\n var r = Se(t, e.name), i = Ee(e.updateTime), o = new Sn({\n mapValue: {\n fields: e.fields\n }\n });\n return new kn(r, i, o, {\n hasCommittedMutations: !!n\n });\n }(t.Co, e.document, !!e.hasCommittedMutations);\n if (e.noDocument) {\n var n = A.$(e.noDocument.path), r = _i(e.noDocument.readTime);\n return new Rn(n, r, {\n hasCommittedMutations: !!e.hasCommittedMutations\n });\n }\n if (e.unknownDocument) {\n var i = A.$(e.unknownDocument.path), o = _i(e.unknownDocument.version);\n return new On(i, o);\n }\n return y();\n}\n\n/** Encodes a document for storage locally. */ function yi(t, e, n) {\n var r = gi(n), i = e.key.path.h().A();\n if (e instanceof kn) {\n var o = function(t, e) {\n return {\n name: Ae(t, e.key),\n fields: e.rn().mapValue.fields,\n updateTime: _e(t, e.version.Z())\n };\n }(t.Co, e), s = e.hasCommittedMutations;\n return new Ki(\n /* unknownDocument= */ null, \n /* noDocument= */ null, o, s, r, i);\n }\n if (e instanceof Rn) {\n var u = e.key.path.A(), a = wi(e.version), c = e.hasCommittedMutations;\n return new Ki(\n /* unknownDocument= */ null, new Bi(u, a), \n /* document= */ null, c, r, i);\n }\n if (e instanceof On) {\n var h = e.key.path.A(), f = wi(e.version);\n return new Ki(new Wi(h, f), \n /* noDocument= */ null, \n /* document= */ null, \n /* hasCommittedMutations= */ !0, r, i);\n }\n return y();\n}\n\nfunction gi(t) {\n var e = t.Z();\n return [ e.seconds, e.nanoseconds ];\n}\n\nfunction mi(t) {\n var e = new ot(t[0], t[1]);\n return st.J(e);\n}\n\nfunction wi(t) {\n var e = t.Z();\n return new Mi(e.seconds, e.nanoseconds);\n}\n\nfunction _i(t) {\n var e = new ot(t.seconds, t.nanoseconds);\n return st.J(e);\n}\n\n/** Encodes a batch of mutations into a DbMutationBatch for local storage. */\n/** Decodes a DbMutationBatch into a MutationBatch */ function bi(t, e) {\n var n = (e.baseMutations || []).map((function(e) {\n return Pe(t.Co, e);\n })), r = e.mutations.map((function(e) {\n return Pe(t.Co, e);\n })), i = ot.fromMillis(e.localWriteTimeMs);\n return new Xr(e.batchId, i, n, r);\n}\n\n/** Decodes a DbTarget into TargetData */ function Ii(t) {\n var e, n, r = _i(t.readTime), i = void 0 !== t.lastLimboFreeSnapshotVersion ? _i(t.lastLimboFreeSnapshotVersion) : st.min();\n return void 0 !== t.query.documents ? (g(1 === (n = t.query).documents.length), \n e = zn(Un(xe(n.documents[0])))) : e = Ce(t.query), new gt(e, t.targetId, 0 /* Listen */ , t.lastListenSequenceNumber, r, i, X.fromBase64String(t.resumeToken))\n /** Encodes TargetData into a DbTarget for storage locally. */;\n}\n\nfunction Ei(t, e) {\n var n, r = wi(e.nt), i = wi(e.lastLimboFreeSnapshotVersion);\n n = dt(e.target) ? Ve(t.Co, e.target) : Ue(t.Co, e.target);\n // We can't store the resumeToken as a ByteString in IndexedDb, so we\n // convert it to a base64 string for storage.\n var o = e.resumeToken.toBase64();\n // lastListenSequenceNumber is always 0 until we do real GC.\n return new Hi(e.targetId, lt(e.target), r, o, e.sequenceNumber, i, n);\n}\n\n/**\n * A helper function for figuring out what kind of query has been stored.\n */\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** A mutation queue for a specific user, backed by IndexedDB. */ var Ti = /** @class */ function() {\n function t(\n /**\n * The normalized userId (e.g. null UID => \"\" userId) used to store /\n * retrieve mutations.\n */\n t, e, n, r) {\n this.userId = t, this.serializer = e, this.Dr = n, this.No = r, \n /**\n * Caches the document keys for pending mutation batches. If the mutation\n * has been removed from IndexedDb, the cached value may continue to\n * be used to retrieve the batch's document keys. To remove a cached value\n * locally, `removeCachedMutationKeys()` should be invoked either directly\n * or through `removeMutationBatches()`.\n *\n * With multi-tab, when the primary client acknowledges or rejects a mutation,\n * this cache is used by secondary clients to invalidate the local\n * view of the documents that were previously affected by the mutation.\n */\n // PORTING NOTE: Multi-tab only.\n this.Fo = {}\n /**\n * Creates a new mutation queue for the given user.\n * @param user The user for which to create a mutation queue.\n * @param serializer The serializer to use when persisting to IndexedDb.\n */;\n }\n return t.xo = function(e, n, r, i) {\n // TODO(mcg): Figure out what constraints there are on userIDs\n // In particular, are there any reserved characters? are empty ids allowed?\n // For the moment store these together in the same mutations table assuming\n // that empty userIDs aren't allowed.\n return g(\"\" !== e.uid), new t(e.Zs() ? e.uid : \"\", n, r, i);\n }, t.prototype.$o = function(t) {\n var e = !0, n = IDBKeyRange.bound([ this.userId, Number.NEGATIVE_INFINITY ], [ this.userId, Number.POSITIVE_INFINITY ]);\n return Si(t).rs({\n index: Gi.userMutationsIndex,\n range: n\n }, (function(t, n, r) {\n e = !1, r.done();\n })).next((function() {\n return e;\n }));\n }, t.prototype.ko = function(t, e, n, r) {\n var i = this, o = Di(t), s = Si(t);\n // The IndexedDb implementation in Chrome (and Firefox) does not handle\n // compound indices that include auto-generated keys correctly. To ensure\n // that the index entry is added correctly in all browsers, we perform two\n // writes: The first write is used to retrieve the next auto-generated Batch\n // ID, and the second write populates the index and stores the actual\n // mutation batch.\n // See: https://bugs.chromium.org/p/chromium/issues/detail?id=701972\n // We write an empty object to obtain key\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return s.add({}).next((function(u) {\n g(\"number\" == typeof u);\n for (var a = new Xr(u, e, n, r), c = function(t, e, n) {\n var r = n.baseMutations.map((function(e) {\n return Oe(t.Co, e);\n })), i = n.mutations.map((function(e) {\n return Oe(t.Co, e);\n }));\n return new Gi(e, n.batchId, n.ar.toMillis(), r, i);\n }(i.serializer, i.userId, a), h = [], f = new Tt((function(t, e) {\n return H(t.R(), e.R());\n })), l = 0, p = r; l < p.length; l++) {\n var d = p[l], v = zi.key(i.userId, d.key.path, u);\n f = f.add(d.key.path.h()), h.push(s.put(c)), h.push(o.put(v, zi.PLACEHOLDER));\n }\n return f.forEach((function(e) {\n h.push(i.Dr.Mo(t, e));\n })), t.pr((function() {\n i.Fo[u] = a.keys();\n })), yr.$n(h).next((function() {\n return a;\n }));\n }));\n }, t.prototype.Oo = function(t, e) {\n var n = this;\n return Si(t).get(e).next((function(t) {\n return t ? (g(t.userId === n.userId), bi(n.serializer, t)) : null;\n }));\n }, \n /**\n * Returns the document keys for the mutation batch with the given batchId.\n * For primary clients, this method returns `null` after\n * `removeMutationBatches()` has been called. Secondary clients return a\n * cached result until `removeCachedMutationKeys()` is invoked.\n */\n // PORTING NOTE: Multi-tab only.\n t.prototype.Lo = function(t, e) {\n var n = this;\n return this.Fo[e] ? yr.resolve(this.Fo[e]) : this.Oo(t, e).next((function(t) {\n if (t) {\n var r = t.keys();\n return n.Fo[e] = r, r;\n }\n return null;\n }));\n }, t.prototype.Bo = function(t, e) {\n var n = this, r = e + 1, i = IDBKeyRange.lowerBound([ this.userId, r ]), o = null;\n return Si(t).rs({\n index: Gi.userMutationsIndex,\n range: i\n }, (function(t, e, i) {\n e.userId === n.userId && (g(e.batchId >= r), o = bi(n.serializer, e)), i.done();\n })).next((function() {\n return o;\n }));\n }, t.prototype.qo = function(t) {\n var e = IDBKeyRange.upperBound([ this.userId, Number.POSITIVE_INFINITY ]), n = -1;\n return Si(t).rs({\n index: Gi.userMutationsIndex,\n range: e,\n reverse: !0\n }, (function(t, e, r) {\n n = e.batchId, r.done();\n })).next((function() {\n return n;\n }));\n }, t.prototype.Uo = function(t) {\n var e = this, n = IDBKeyRange.bound([ this.userId, -1 ], [ this.userId, Number.POSITIVE_INFINITY ]);\n return Si(t).ts(Gi.userMutationsIndex, n).next((function(t) {\n return t.map((function(t) {\n return bi(e.serializer, t);\n }));\n }));\n }, t.prototype.Nr = function(t, e) {\n var n = this, r = zi.prefixForPath(this.userId, e.path), i = IDBKeyRange.lowerBound(r), o = [];\n // Scan the document-mutation index starting with a prefix starting with\n // the given documentKey.\n return Di(t).rs({\n range: i\n }, (function(r, i, s) {\n var u = r[0], a = r[1], c = r[2], h = pi(a);\n // Only consider rows matching exactly the specific key of\n // interest. Note that because we order by path first, and we\n // order terminators before path separators, we'll encounter all\n // the index rows for documentKey contiguously. In particular, all\n // the rows for documentKey will occur before any rows for\n // documents nested in a subcollection beneath documentKey so we\n // can stop as soon as we hit any such row.\n if (u === n.userId && e.path.isEqual(h)) \n // Look up the mutation batch in the store.\n return Si(t).get(c).next((function(t) {\n if (!t) throw y();\n g(t.userId === n.userId), o.push(bi(n.serializer, t));\n }));\n s.done();\n })).next((function() {\n return o;\n }));\n }, t.prototype.Or = function(t, e) {\n var n = this, r = new Tt(H), i = [];\n return e.forEach((function(e) {\n var o = zi.prefixForPath(n.userId, e.path), s = IDBKeyRange.lowerBound(o), u = Di(t).rs({\n range: s\n }, (function(t, i, o) {\n var s = t[0], u = t[1], a = t[2], c = pi(u);\n // Only consider rows matching exactly the specific key of\n // interest. Note that because we order by path first, and we\n // order terminators before path separators, we'll encounter all\n // the index rows for documentKey contiguously. In particular, all\n // the rows for documentKey will occur before any rows for\n // documents nested in a subcollection beneath documentKey so we\n // can stop as soon as we hit any such row.\n s === n.userId && e.path.isEqual(c) ? r = r.add(a) : o.done();\n }));\n i.push(u);\n })), yr.$n(i).next((function() {\n return n.Qo(t, r);\n }));\n }, t.prototype.Wr = function(t, e) {\n var n = this, r = e.path, i = r.length + 1, o = zi.prefixForPath(this.userId, r), s = IDBKeyRange.lowerBound(o), u = new Tt(H);\n return Di(t).rs({\n range: s\n }, (function(t, e, o) {\n var s = t[0], a = t[1], c = t[2], h = pi(a);\n s === n.userId && r.T(h) ? \n // Rows with document keys more than one segment longer than the\n // query path can't be matches. For example, a query on 'rooms'\n // can't match the document /rooms/abc/messages/xyx.\n // TODO(mcg): we'll need a different scanner when we implement\n // ancestor queries.\n h.length === i && (u = u.add(c)) : o.done();\n })).next((function() {\n return n.Qo(t, u);\n }));\n }, t.prototype.Qo = function(t, e) {\n var n = this, r = [], i = [];\n // TODO(rockwood): Implement this using iterate.\n return e.forEach((function(e) {\n i.push(Si(t).get(e).next((function(t) {\n if (null === t) throw y();\n g(t.userId === n.userId), r.push(bi(n.serializer, t));\n })));\n })), yr.$n(i).next((function() {\n return r;\n }));\n }, t.prototype.Wo = function(t, e) {\n var n = this;\n return Ai(t.jo, this.userId, e).next((function(r) {\n return t.pr((function() {\n n.Ko(e.batchId);\n })), yr.forEach(r, (function(e) {\n return n.No.Go(t, e);\n }));\n }));\n }, \n /**\n * Clears the cached keys for a mutation batch. This method should be\n * called by secondary clients after they process mutation updates.\n *\n * Note that this method does not have to be called from primary clients as\n * the corresponding cache entries are cleared when an acknowledged or\n * rejected batch is removed from the mutation queue.\n */\n // PORTING NOTE: Multi-tab only\n t.prototype.Ko = function(t) {\n delete this.Fo[t];\n }, t.prototype.zo = function(t) {\n var e = this;\n return this.$o(t).next((function(n) {\n if (!n) return yr.resolve();\n // Verify that there are no entries in the documentMutations index if\n // the queue is empty.\n var r = IDBKeyRange.lowerBound(zi.prefixForUser(e.userId)), i = [];\n return Di(t).rs({\n range: r\n }, (function(t, n, r) {\n if (t[0] === e.userId) {\n var o = pi(t[1]);\n i.push(o);\n } else r.done();\n })).next((function() {\n g(0 === i.length);\n }));\n }));\n }, t.prototype.Ho = function(t, e) {\n return Ni(t, this.userId, e);\n }, \n // PORTING NOTE: Multi-tab only (state is held in memory in other clients).\n /** Returns the mutation queue's metadata from IndexedDb. */\n t.prototype.Yo = function(t) {\n var e = this;\n return xi(t).get(this.userId).next((function(t) {\n return t || new ji(e.userId, -1, \n /*lastStreamToken=*/ \"\");\n }));\n }, t;\n}();\n\n/**\n * @return true if the mutation queue for the given user contains a pending\n * mutation for the given key.\n */ function Ni(t, e, n) {\n var r = zi.prefixForPath(e, n.path), i = r[1], o = IDBKeyRange.lowerBound(r), s = !1;\n return Di(t).rs({\n range: o,\n ss: !0\n }, (function(t, n, r) {\n var o = t[0], u = t[1];\n t[2];\n o === e && u === i && (s = !0), r.done();\n })).next((function() {\n return s;\n }));\n}\n\n/** Returns true if any mutation queue contains the given document. */\n/**\n * Delete a mutation batch and the associated document mutations.\n * @return A PersistencePromise of the document mutations that were removed.\n */ function Ai(t, e, n) {\n var r = t.store(Gi.store), i = t.store(zi.store), o = [], s = IDBKeyRange.only(n.batchId), u = 0, a = r.rs({\n range: s\n }, (function(t, e, n) {\n return u++, n.delete();\n }));\n o.push(a.next((function() {\n g(1 === u);\n })));\n for (var c = [], h = 0, f = n.mutations; h < f.length; h++) {\n var l = f[h], p = zi.key(e, l.key.path, n.batchId);\n o.push(i.delete(p)), c.push(l.key);\n }\n return yr.$n(o).next((function() {\n return c;\n }));\n}\n\n/**\n * Helper to get a typed SimpleDbStore for the mutations object store.\n */ function Si(t) {\n return ho.Qn(t, Gi.store);\n}\n\n/**\n * Helper to get a typed SimpleDbStore for the mutationQueues object store.\n */ function Di(t) {\n return ho.Qn(t, zi.store);\n}\n\n/**\n * Helper to get a typed SimpleDbStore for the mutationQueues object store.\n */ function xi(t) {\n return ho.Qn(t, ji.store);\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * The RemoteDocumentCache for IndexedDb. To construct, invoke\n * `newIndexedDbRemoteDocumentCache()`.\n */ var Li = /** @class */ function() {\n /**\n * @param serializer The document serializer.\n * @param indexManager The query indexes that need to be maintained.\n */\n function t(t, e) {\n this.serializer = t, this.Dr = e\n /**\n * Adds the supplied entries to the cache.\n *\n * All calls of `addEntry` are required to go through the RemoteDocumentChangeBuffer\n * returned by `newChangeBuffer()` to ensure proper accounting of metadata.\n */;\n }\n return t.prototype.Er = function(t, e, n) {\n return Oi(t).put(Pi(e), n);\n }, \n /**\n * Removes a document from the cache.\n *\n * All calls of `removeEntry` are required to go through the RemoteDocumentChangeBuffer\n * returned by `newChangeBuffer()` to ensure proper accounting of metadata.\n */\n t.prototype.Ar = function(t, e) {\n var n = Oi(t), r = Pi(e);\n return n.delete(r);\n }, \n /**\n * Updates the current cache size.\n *\n * Callers to `addEntry()` and `removeEntry()` *must* call this afterwards to update the\n * cache's metadata.\n */\n t.prototype.updateMetadata = function(t, e) {\n var n = this;\n return this.getMetadata(t).next((function(r) {\n return r.byteSize += e, n.Jo(t, r);\n }));\n }, t.prototype.Rr = function(t, e) {\n var n = this;\n return Oi(t).get(Pi(e)).next((function(t) {\n return n.Xo(t);\n }));\n }, \n /**\n * Looks up an entry in the cache.\n *\n * @param documentKey The key of the entry to look up.\n * @return The cached MaybeDocument entry and its size, or null if we have nothing cached.\n */\n t.prototype.Zo = function(t, e) {\n var n = this;\n return Oi(t).get(Pi(e)).next((function(t) {\n var e = n.Xo(t);\n return e ? {\n ta: e,\n size: Vi(t)\n } : null;\n }));\n }, t.prototype.getEntries = function(t, e) {\n var n = this, r = Dt();\n return this.ea(t, e, (function(t, e) {\n var i = n.Xo(e);\n r = r.ot(t, i);\n })).next((function() {\n return r;\n }));\n }, \n /**\n * Looks up several entries in the cache.\n *\n * @param documentKeys The set of keys entries to look up.\n * @return A map of MaybeDocuments indexed by key (if a document cannot be\n * found, the key will be mapped to null) and a map of sizes indexed by\n * key (zero if the key cannot be found).\n */\n t.prototype.na = function(t, e) {\n var n = this, r = Dt(), i = new bt(A.i);\n return this.ea(t, e, (function(t, e) {\n var o = n.Xo(e);\n o ? (r = r.ot(t, o), i = i.ot(t, Vi(e))) : (r = r.ot(t, null), i = i.ot(t, 0));\n })).next((function() {\n return {\n sa: r,\n ia: i\n };\n }));\n }, t.prototype.ea = function(t, e, n) {\n if (e.m()) return yr.resolve();\n var r = IDBKeyRange.bound(e.first().path.A(), e.last().path.A()), i = e._t(), o = i.It();\n return Oi(t).rs({\n range: r\n }, (function(t, e, r) {\n // Go through keys not found in cache.\n for (var s = A.$(t); o && A.i(o, s) < 0; ) n(o, null), o = i.It();\n o && o.isEqual(s) && (\n // Key found in cache.\n n(o, e), o = i.At() ? i.It() : null), \n // Skip to the next key (if there is one).\n o ? r.Xn(o.path.A()) : r.done();\n })).next((function() {\n // The rest of the keys are not in the cache. One case where `iterate`\n // above won't go through them is when the cache is empty.\n for (;o; ) n(o, null), o = i.At() ? i.It() : null;\n }));\n }, t.prototype.Lr = function(t, e, n) {\n var r = this, i = Lt(), o = e.path.length + 1, s = {};\n if (n.isEqual(st.min())) {\n // Documents are ordered by key, so we can use a prefix scan to narrow\n // down the documents we need to match the query against.\n var u = e.path.A();\n s.range = IDBKeyRange.lowerBound(u);\n } else {\n // Execute an index-free query and filter by read time. This is safe\n // since all document changes to queries that have a\n // lastLimboFreeSnapshotVersion (`sinceReadTime`) have a read time set.\n var a = e.path.A(), c = gi(n);\n s.range = IDBKeyRange.lowerBound([ a, c ], \n /* open= */ !0), s.index = Ki.collectionReadTimeIndex;\n }\n return Oi(t).rs(s, (function(t, n, s) {\n // The query is actually returning any path that starts with the query\n // path prefix which may include documents in subcollections. For\n // example, a query on 'rooms' will return rooms/abc/messages/xyx but we\n // shouldn't match it. Fix this by discarding rows with document keys\n // more than one segment longer than the query path.\n if (t.length === o) {\n var u = vi(r.serializer, n);\n e.path.T(u.key.path) ? u instanceof kn && $n(e, u) && (i = i.ot(u.key, u)) : s.done();\n }\n })).next((function() {\n return i;\n }));\n }, t.prototype.ra = function(t) {\n return new ki(this, !!t && t.oa);\n }, t.prototype.aa = function(t) {\n return this.getMetadata(t).next((function(t) {\n return t.byteSize;\n }));\n }, t.prototype.getMetadata = function(t) {\n return Ri(t).get(Qi.key).next((function(t) {\n return g(!!t), t;\n }));\n }, t.prototype.Jo = function(t, e) {\n return Ri(t).put(Qi.key, e);\n }, \n /**\n * Decodes `remoteDoc` and returns the document (or null, if the document\n * corresponds to the format used for sentinel deletes).\n */\n t.prototype.Xo = function(t) {\n if (t) {\n var e = vi(this.serializer, t);\n return e instanceof Rn && e.version.isEqual(st.min()) ? null : e;\n }\n return null;\n }, t;\n}(), ki = /** @class */ function(e) {\n /**\n * @param documentCache The IndexedDbRemoteDocumentCache to apply the changes to.\n * @param trackRemovals Whether to create sentinel deletes that can be tracked by\n * `getNewDocumentChanges()`.\n */\n function n(t, n) {\n var r = this;\n return (r = e.call(this) || this).ca = t, r.oa = n, \n // A map of document sizes prior to applying the changes in this buffer.\n r.ua = new it((function(t) {\n return t.toString();\n }), (function(t, e) {\n return t.isEqual(e);\n })), r;\n }\n return t.__extends(n, e), n.prototype.yr = function(t) {\n var e = this, n = [], r = 0, i = new Tt((function(t, e) {\n return H(t.R(), e.R());\n }));\n return this.wr.forEach((function(o, s) {\n var u = e.ua.get(o);\n if (s) {\n var a = yi(e.ca.serializer, s, e.readTime);\n i = i.add(o.path.h());\n var c = Vi(a);\n r += c - u, n.push(e.ca.Er(t, o, a));\n } else if (r -= u, e.oa) {\n // In order to track removals, we store a \"sentinel delete\" in the\n // RemoteDocumentCache. This entry is represented by a NoDocument\n // with a version of 0 and ignored by `maybeDecodeDocument()` but\n // preserved in `getNewDocumentChanges()`.\n var h = yi(e.ca.serializer, new Rn(o, st.min()), e.readTime);\n n.push(e.ca.Er(t, o, h));\n } else n.push(e.ca.Ar(t, o));\n })), i.forEach((function(r) {\n n.push(e.ca.Dr.Mo(t, r));\n })), n.push(this.ca.updateMetadata(t, r)), yr.$n(n);\n }, n.prototype.gr = function(t, e) {\n var n = this;\n // Record the size of everything we load from the cache so we can compute a delta later.\n return this.ca.Zo(t, e).next((function(t) {\n return null === t ? (n.ua.set(e, 0), null) : (n.ua.set(e, t.size), t.ta);\n }));\n }, n.prototype.Pr = function(t, e) {\n var n = this;\n // Record the size of everything we load from the cache so we can compute\n // a delta later.\n return this.ca.na(t, e).next((function(t) {\n var e = t.sa;\n // Note: `getAllFromCache` returns two maps instead of a single map from\n // keys to `DocumentSizeEntry`s. This is to allow returning the\n // `NullableMaybeDocumentMap` directly, without a conversion.\n return t.ia.forEach((function(t, e) {\n n.ua.set(t, e);\n })), e;\n }));\n }, n;\n}(Zr);\n\n/**\n * Creates a new IndexedDbRemoteDocumentCache.\n *\n * @param serializer The document serializer.\n * @param indexManager The query indexes that need to be maintained.\n */\n/**\n * Handles the details of adding and updating documents in the IndexedDbRemoteDocumentCache.\n *\n * Unlike the MemoryRemoteDocumentChangeBuffer, the IndexedDb implementation computes the size\n * delta for all submitted changes. This avoids having to re-read all documents from IndexedDb\n * when we apply the changes.\n */ function Ri(t) {\n return ho.Qn(t, Qi.store);\n}\n\n/**\n * Helper to get a typed SimpleDbStore for the remoteDocuments object store.\n */ function Oi(t) {\n return ho.Qn(t, Ki.store);\n}\n\nfunction Pi(t) {\n return t.path.A();\n}\n\n/**\n * Retrusn an approximate size for the given document.\n */ function Vi(t) {\n var e;\n if (t.document) e = t.document; else if (t.unknownDocument) e = t.unknownDocument; else {\n if (!t.noDocument) throw y();\n e = t.noDocument;\n }\n return JSON.stringify(e).length;\n}\n\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * An in-memory implementation of IndexManager.\n */ var Ui = /** @class */ function() {\n function t() {\n this.ha = new Ci;\n }\n return t.prototype.Mo = function(t, e) {\n return this.ha.add(e), yr.resolve();\n }, t.prototype.Qr = function(t, e) {\n return yr.resolve(this.ha.getEntries(e));\n }, t;\n}(), Ci = /** @class */ function() {\n function t() {\n this.index = {};\n }\n // Returns false if the entry already existed.\n return t.prototype.add = function(t) {\n var e = t._(), n = t.h(), r = this.index[e] || new Tt(E.i), i = !r.has(n);\n return this.index[e] = r.add(n), i;\n }, t.prototype.has = function(t) {\n var e = t._(), n = t.h(), r = this.index[e];\n return r && r.has(n);\n }, t.prototype.getEntries = function(t) {\n return (this.index[t] || new Tt(E.i)).A();\n }, t;\n}(), Fi = /** @class */ function() {\n function t(t) {\n this.serializer = t;\n }\n /**\n * Performs database creation and schema upgrades.\n *\n * Note that in production, this method is only ever used to upgrade the schema\n * to SCHEMA_VERSION. Different values of toVersion are only used for testing\n * and local feature development.\n */ return t.prototype.createOrUpgrade = function(t, e, n, r) {\n var i = this;\n g(n < r && n >= 0 && r <= 10);\n var o = new br(\"createOrUpgrade\", e);\n n < 1 && r >= 1 && (function(t) {\n t.createObjectStore(qi.store);\n }(t), function(t) {\n t.createObjectStore(ji.store, {\n keyPath: ji.keyPath\n }), t.createObjectStore(Gi.store, {\n keyPath: Gi.keyPath,\n autoIncrement: !0\n }).createIndex(Gi.userMutationsIndex, Gi.userMutationsKeyPath, {\n unique: !0\n }), t.createObjectStore(zi.store);\n }(t), Ji(t), function(t) {\n t.createObjectStore(Ki.store);\n }(t));\n // Migration 2 to populate the targetGlobal object no longer needed since\n // migration 3 unconditionally clears it.\n var s = yr.resolve();\n return n < 3 && r >= 3 && (\n // Brand new clients don't need to drop and recreate--only clients that\n // potentially have corrupt data.\n 0 !== n && (function(t) {\n t.deleteObjectStore(Yi.store), t.deleteObjectStore(Hi.store), t.deleteObjectStore($i.store);\n }(t), Ji(t)), s = s.next((function() {\n /**\n * Creates the target global singleton row.\n *\n * @param {IDBTransaction} txn The version upgrade transaction for indexeddb\n */\n return function(t) {\n var e = t.store($i.store), n = new $i(\n /*highestTargetId=*/ 0, \n /*lastListenSequenceNumber=*/ 0, st.min().Z(), \n /*targetCount=*/ 0);\n return e.put($i.key, n);\n }(o);\n }))), n < 4 && r >= 4 && (0 !== n && (\n // Schema version 3 uses auto-generated keys to generate globally unique\n // mutation batch IDs (this was previously ensured internally by the\n // client). To migrate to the new schema, we have to read all mutations\n // and write them back out. We preserve the existing batch IDs to guarantee\n // consistency with other object stores. Any further mutation batch IDs will\n // be auto-generated.\n s = s.next((function() {\n return function(t, e) {\n return e.store(Gi.store).ts().next((function(n) {\n t.deleteObjectStore(Gi.store), t.createObjectStore(Gi.store, {\n keyPath: Gi.keyPath,\n autoIncrement: !0\n }).createIndex(Gi.userMutationsIndex, Gi.userMutationsKeyPath, {\n unique: !0\n });\n var r = e.store(Gi.store), i = n.map((function(t) {\n return r.put(t);\n }));\n return yr.$n(i);\n }));\n }(t, o);\n }))), s = s.next((function() {\n !function(t) {\n t.createObjectStore(Zi.store, {\n keyPath: Zi.keyPath\n });\n }(t);\n }))), n < 5 && r >= 5 && (s = s.next((function() {\n return i.removeAcknowledgedMutations(o);\n }))), n < 6 && r >= 6 && (s = s.next((function() {\n return function(t) {\n t.createObjectStore(Qi.store);\n }(t), i.addDocumentGlobal(o);\n }))), n < 7 && r >= 7 && (s = s.next((function() {\n return i.ensureSequenceNumbers(o);\n }))), n < 8 && r >= 8 && (s = s.next((function() {\n return i.createCollectionParentIndex(t, o);\n }))), n < 9 && r >= 9 && (s = s.next((function() {\n // Multi-Tab used to manage its own changelog, but this has been moved\n // to the DbRemoteDocument object store itself. Since the previous change\n // log only contained transient data, we can drop its object store.\n !function(t) {\n t.objectStoreNames.contains(\"remoteDocumentChanges\") && t.deleteObjectStore(\"remoteDocumentChanges\");\n }(t), function(t) {\n var e = t.objectStore(Ki.store);\n e.createIndex(Ki.readTimeIndex, Ki.readTimeIndexPath, {\n unique: !1\n }), e.createIndex(Ki.collectionReadTimeIndex, Ki.collectionReadTimeIndexPath, {\n unique: !1\n });\n }(e);\n }))), n < 10 && r >= 10 && (s = s.next((function() {\n return i.rewriteCanonicalIds(o);\n }))), s;\n }, t.prototype.addDocumentGlobal = function(t) {\n var e = 0;\n return t.store(Ki.store).rs((function(t, n) {\n e += Vi(n);\n })).next((function() {\n var n = new Qi(e);\n return t.store(Qi.store).put(Qi.key, n);\n }));\n }, t.prototype.removeAcknowledgedMutations = function(t) {\n var e = this, n = t.store(ji.store), r = t.store(Gi.store);\n return n.ts().next((function(n) {\n return yr.forEach(n, (function(n) {\n var i = IDBKeyRange.bound([ n.userId, -1 ], [ n.userId, n.lastAcknowledgedBatchId ]);\n return r.ts(Gi.userMutationsIndex, i).next((function(r) {\n return yr.forEach(r, (function(r) {\n g(r.userId === n.userId);\n var i = bi(e.serializer, r);\n return Ai(t, n.userId, i).next((function() {}));\n }));\n }));\n }));\n }));\n }, \n /**\n * Ensures that every document in the remote document cache has a corresponding sentinel row\n * with a sequence number. Missing rows are given the most recently used sequence number.\n */\n t.prototype.ensureSequenceNumbers = function(t) {\n var e = t.store(Yi.store), n = t.store(Ki.store);\n return t.store($i.store).get($i.key).next((function(t) {\n var r = [];\n return n.rs((function(n, i) {\n var o = new E(n), s = function(t) {\n return [ 0, hi(t) ];\n }(o);\n r.push(e.get(s).next((function(n) {\n return n ? yr.resolve() : function(n) {\n return e.put(new Yi(0, hi(n), t.highestListenSequenceNumber));\n }(o);\n })));\n })).next((function() {\n return yr.$n(r);\n }));\n }));\n }, t.prototype.createCollectionParentIndex = function(t, e) {\n // Create the index.\n t.createObjectStore(Xi.store, {\n keyPath: Xi.keyPath\n });\n var n = e.store(Xi.store), r = new Ci, i = function(t) {\n if (r.add(t)) {\n var e = t._(), i = t.h();\n return n.put({\n collectionId: e,\n parent: hi(i)\n });\n }\n };\n // Helper to add an index entry iff we haven't already written it.\n // Index existing remote documents.\n return e.store(Ki.store).rs({\n ss: !0\n }, (function(t, e) {\n var n = new E(t);\n return i(n.h());\n })).next((function() {\n return e.store(zi.store).rs({\n ss: !0\n }, (function(t, e) {\n t[0];\n var n = t[1], r = (t[2], pi(n));\n return i(r.h());\n }));\n }));\n }, t.prototype.rewriteCanonicalIds = function(t) {\n var e = this, n = t.store(Hi.store);\n return n.rs((function(t, r) {\n var i = Ii(r), o = Ei(e.serializer, i);\n return n.put(o);\n }));\n }, t;\n}(), Mi = function(t, e) {\n this.seconds = t, this.nanoseconds = e;\n}, qi = function(t, \n/** Whether to allow shared access from multiple tabs. */\ne, n) {\n this.ownerId = t, this.allowTabSynchronization = e, this.leaseTimestampMs = n;\n};\n\n/**\n * Internal implementation of the collection-parent index exposed by MemoryIndexManager.\n * Also used for in-memory caching by IndexedDbIndexManager and initial index population\n * in indexeddb_schema.ts\n */\n/**\n * Name of the IndexedDb object store.\n *\n * Note that the name 'owner' is chosen to ensure backwards compatibility with\n * older clients that only supported single locked access to the persistence\n * layer.\n */\nqi.store = \"owner\", \n/**\n * The key string used for the single object that exists in the\n * DbPrimaryClient store.\n */\nqi.key = \"owner\";\n\nvar ji = function(\n/**\n * The normalized user ID to which this queue belongs.\n */\nt, \n/**\n * An identifier for the highest numbered batch that has been acknowledged\n * by the server. All MutationBatches in this queue with batchIds less\n * than or equal to this value are considered to have been acknowledged by\n * the server.\n *\n * NOTE: this is deprecated and no longer used by the code.\n */\ne, \n/**\n * A stream token that was previously sent by the server.\n *\n * See StreamingWriteRequest in datastore.proto for more details about\n * usage.\n *\n * After sending this token, earlier tokens may not be used anymore so\n * only a single stream token is retained.\n *\n * NOTE: this is deprecated and no longer used by the code.\n */\nn) {\n this.userId = t, this.lastAcknowledgedBatchId = e, this.lastStreamToken = n;\n};\n\n/** Name of the IndexedDb object store. */ ji.store = \"mutationQueues\", \n/** Keys are automatically assigned via the userId property. */\nji.keyPath = \"userId\";\n\n/**\n * An object to be stored in the 'mutations' store in IndexedDb.\n *\n * Represents a batch of user-level mutations intended to be sent to the server\n * in a single write. Each user-level batch gets a separate DbMutationBatch\n * with a new batchId.\n */\nvar Gi = function(\n/**\n * The normalized user ID to which this batch belongs.\n */\nt, \n/**\n * An identifier for this batch, allocated using an auto-generated key.\n */\ne, \n/**\n * The local write time of the batch, stored as milliseconds since the\n * epoch.\n */\nn, \n/**\n * A list of \"mutations\" that represent a partial base state from when this\n * write batch was initially created. During local application of the write\n * batch, these baseMutations are applied prior to the real writes in order\n * to override certain document fields from the remote document cache. This\n * is necessary in the case of non-idempotent writes (e.g. `increment()`\n * transforms) to make sure that the local view of the modified documents\n * doesn't flicker if the remote document cache receives the result of the\n * non-idempotent write before the write is removed from the queue.\n *\n * These mutations are never sent to the backend.\n */\nr, \n/**\n * A list of mutations to apply. All mutations will be applied atomically.\n *\n * Mutations are serialized via toMutation().\n */\ni) {\n this.userId = t, this.batchId = e, this.localWriteTimeMs = n, this.baseMutations = r, \n this.mutations = i;\n};\n\n/** Name of the IndexedDb object store. */ Gi.store = \"mutations\", \n/** Keys are automatically assigned via the userId, batchId properties. */\nGi.keyPath = \"batchId\", \n/** The index name for lookup of mutations by user. */\nGi.userMutationsIndex = \"userMutationsIndex\", \n/** The user mutations index is keyed by [userId, batchId] pairs. */\nGi.userMutationsKeyPath = [ \"userId\", \"batchId\" ];\n\nvar zi = /** @class */ function() {\n function t() {}\n /**\n * Creates a [userId] key for use in the DbDocumentMutations index to iterate\n * over all of a user's document mutations.\n */ return t.prefixForUser = function(t) {\n return [ t ];\n }, \n /**\n * Creates a [userId, encodedPath] key for use in the DbDocumentMutations\n * index to iterate over all at document mutations for a given path or lower.\n */\n t.prefixForPath = function(t, e) {\n return [ t, hi(e) ];\n }, \n /**\n * Creates a full index key of [userId, encodedPath, batchId] for inserting\n * and deleting into the DbDocumentMutations index.\n */\n t.key = function(t, e, n) {\n return [ t, hi(e), n ];\n }, t;\n}();\n\nzi.store = \"documentMutations\", \n/**\n * Because we store all the useful information for this store in the key,\n * there is no useful information to store as the value. The raw (unencoded)\n * path cannot be stored because IndexedDb doesn't store prototype\n * information.\n */\nzi.PLACEHOLDER = new zi;\n\nvar Bi = function(t, e) {\n this.path = t, this.readTime = e;\n}, Wi = function(t, e) {\n this.path = t, this.version = e;\n}, Ki = \n// TODO: We are currently storing full document keys almost three times\n// (once as part of the primary key, once - partly - as `parentPath` and once\n// inside the encoded documents). During our next migration, we should\n// rewrite the primary key as parentPath + document ID which would allow us\n// to drop one value.\nfunction(\n/**\n * Set to an instance of DbUnknownDocument if the data for a document is\n * not known, but it is known that a document exists at the specified\n * version (e.g. it had a successful update applied to it)\n */\nt, \n/**\n * Set to an instance of a DbNoDocument if it is known that no document\n * exists.\n */\ne, \n/**\n * Set to an instance of a Document if there's a cached version of the\n * document.\n */\nn, \n/**\n * Documents that were written to the remote document store based on\n * a write acknowledgment are marked with `hasCommittedMutations`. These\n * documents are potentially inconsistent with the backend's copy and use\n * the write's commit version as their document version.\n */\nr, \n/**\n * When the document was read from the backend. Undefined for data written\n * prior to schema version 9.\n */\ni, \n/**\n * The path of the collection this document is part of. Undefined for data\n * written prior to schema version 9.\n */\no) {\n this.unknownDocument = t, this.noDocument = e, this.document = n, this.hasCommittedMutations = r, \n this.readTime = i, this.parentPath = o;\n};\n\n/**\n * Represents a document that is known to exist but whose data is unknown.\n * Stored in IndexedDb as part of a DbRemoteDocument object.\n */ Ki.store = \"remoteDocuments\", \n/**\n * An index that provides access to all entries sorted by read time (which\n * corresponds to the last modification time of each row).\n *\n * This index is used to provide a changelog for Multi-Tab.\n */\nKi.readTimeIndex = \"readTimeIndex\", Ki.readTimeIndexPath = \"readTime\", \n/**\n * An index that provides access to documents in a collection sorted by read\n * time.\n *\n * This index is used to allow the RemoteDocumentCache to fetch newly changed\n * documents in a collection.\n */\nKi.collectionReadTimeIndex = \"collectionReadTimeIndex\", Ki.collectionReadTimeIndexPath = [ \"parentPath\", \"readTime\" ];\n\n/**\n * Contains a single entry that has metadata about the remote document cache.\n */\nvar Qi = \n/**\n * @param byteSize Approximately the total size in bytes of all the documents in the document\n * cache.\n */\nfunction(t) {\n this.byteSize = t;\n};\n\nQi.store = \"remoteDocumentGlobal\", Qi.key = \"remoteDocumentGlobalKey\";\n\nvar Hi = function(\n/**\n * An auto-generated sequential numeric identifier for the query.\n *\n * Queries are stored using their canonicalId as the key, but these\n * canonicalIds can be quite long so we additionally assign a unique\n * queryId which can be used by referenced data structures (e.g.\n * indexes) to minimize the on-disk cost.\n */\nt, \n/**\n * The canonical string representing this query. This is not unique.\n */\ne, \n/**\n * The last readTime received from the Watch Service for this query.\n *\n * This is the same value as TargetChange.read_time in the protos.\n */\nn, \n/**\n * An opaque, server-assigned token that allows watching a query to be\n * resumed after disconnecting without retransmitting all the data\n * that matches the query. The resume token essentially identifies a\n * point in time from which the server should resume sending results.\n *\n * This is related to the snapshotVersion in that the resumeToken\n * effectively also encodes that value, but the resumeToken is opaque\n * and sometimes encodes additional information.\n *\n * A consequence of this is that the resumeToken should be used when\n * asking the server to reason about where this client is in the watch\n * stream, but the client should use the snapshotVersion for its own\n * purposes.\n *\n * This is the same value as TargetChange.resume_token in the protos.\n */\nr, \n/**\n * A sequence number representing the last time this query was\n * listened to, used for garbage collection purposes.\n *\n * Conventionally this would be a timestamp value, but device-local\n * clocks are unreliable and they must be able to create new listens\n * even while disconnected. Instead this should be a monotonically\n * increasing number that's incremented on each listen call.\n *\n * This is different from the queryId since the queryId is an\n * immutable identifier assigned to the Query on first use while\n * lastListenSequenceNumber is updated every time the query is\n * listened to.\n */\ni, \n/**\n * Denotes the maximum snapshot version at which the associated query view\n * contained no limbo documents. Undefined for data written prior to\n * schema version 9.\n */\no, \n/**\n * The query for this target.\n *\n * Because canonical ids are not unique we must store the actual query. We\n * use the proto to have an object we can persist without having to\n * duplicate translation logic to and from a `Query` object.\n */\ns) {\n this.targetId = t, this.canonicalId = e, this.readTime = n, this.resumeToken = r, \n this.lastListenSequenceNumber = i, this.lastLimboFreeSnapshotVersion = o, this.query = s;\n};\n\nHi.store = \"targets\", \n/** Keys are automatically assigned via the targetId property. */\nHi.keyPath = \"targetId\", \n/** The name of the queryTargets index. */\nHi.queryTargetsIndexName = \"queryTargetsIndex\", \n/**\n * The index of all canonicalIds to the targets that they match. This is not\n * a unique mapping because canonicalId does not promise a unique name for all\n * possible queries, so we append the targetId to make the mapping unique.\n */\nHi.queryTargetsKeyPath = [ \"canonicalId\", \"targetId\" ];\n\n/**\n * An object representing an association between a target and a document, or a\n * sentinel row marking the last sequence number at which a document was used.\n * Each document cached must have a corresponding sentinel row before lru\n * garbage collection is enabled.\n *\n * The target associations and sentinel rows are co-located so that orphaned\n * documents and their sequence numbers can be identified efficiently via a scan\n * of this store.\n */\nvar Yi = function(\n/**\n * The targetId identifying a target or 0 for a sentinel row.\n */\nt, \n/**\n * The path to the document, as encoded in the key.\n */\ne, \n/**\n * If this is a sentinel row, this should be the sequence number of the last\n * time the document specified by `path` was used. Otherwise, it should be\n * `undefined`.\n */\nn) {\n this.targetId = t, this.path = e, this.sequenceNumber = n;\n};\n\n/** Name of the IndexedDb object store. */ Yi.store = \"targetDocuments\", \n/** Keys are automatically assigned via the targetId, path properties. */\nYi.keyPath = [ \"targetId\", \"path\" ], \n/** The index name for the reverse index. */\nYi.documentTargetsIndex = \"documentTargetsIndex\", \n/** We also need to create the reverse index for these properties. */\nYi.documentTargetsKeyPath = [ \"path\", \"targetId\" ];\n\n/**\n * A record of global state tracked across all Targets, tracked separately\n * to avoid the need for extra indexes.\n *\n * This should be kept in-sync with the proto used in the iOS client.\n */\nvar $i = function(\n/**\n * The highest numbered target id across all targets.\n *\n * See DbTarget.targetId.\n */\nt, \n/**\n * The highest numbered lastListenSequenceNumber across all targets.\n *\n * See DbTarget.lastListenSequenceNumber.\n */\ne, \n/**\n * A global snapshot version representing the last consistent snapshot we\n * received from the backend. This is monotonically increasing and any\n * snapshots received from the backend prior to this version (e.g. for\n * targets resumed with a resumeToken) should be suppressed (buffered)\n * until the backend has caught up to this snapshot version again. This\n * prevents our cache from ever going backwards in time.\n */\nn, \n/**\n * The number of targets persisted.\n */\nr) {\n this.highestTargetId = t, this.highestListenSequenceNumber = e, this.lastRemoteSnapshotVersion = n, \n this.targetCount = r;\n};\n\n/**\n * The key string used for the single object that exists in the\n * DbTargetGlobal store.\n */ $i.key = \"targetGlobalKey\", $i.store = \"targetGlobal\";\n\n/**\n * An object representing an association between a Collection id (e.g. 'messages')\n * to a parent path (e.g. '/chats/123') that contains it as a (sub)collection.\n * This is used to efficiently find all collections to query when performing\n * a Collection Group query.\n */\nvar Xi = function(\n/**\n * The collectionId (e.g. 'messages')\n */\nt, \n/**\n * The path to the parent (either a document location or an empty path for\n * a root-level collection).\n */\ne) {\n this.collectionId = t, this.parent = e;\n};\n\n/** Name of the IndexedDb object store. */ function Ji(t) {\n t.createObjectStore(Yi.store, {\n keyPath: Yi.keyPath\n }).createIndex(Yi.documentTargetsIndex, Yi.documentTargetsKeyPath, {\n unique: !0\n }), \n // NOTE: This is unique only because the TargetId is the suffix.\n t.createObjectStore(Hi.store, {\n keyPath: Hi.keyPath\n }).createIndex(Hi.queryTargetsIndexName, Hi.queryTargetsKeyPath, {\n unique: !0\n }), t.createObjectStore($i.store);\n}\n\nXi.store = \"collectionParents\", \n/** Keys are automatically assigned via the collectionId, parent properties. */\nXi.keyPath = [ \"collectionId\", \"parent\" ];\n\nvar Zi = function(\n// Note: Previous schema versions included a field\n// \"lastProcessedDocumentChangeId\". Don't use anymore.\n/** The auto-generated client id assigned at client startup. */\nt, \n/** The last time this state was updated. */\ne, \n/** Whether the client's network connection is enabled. */\nn, \n/** Whether this client is running in a foreground tab. */\nr) {\n this.clientId = t, this.updateTimeMs = e, this.networkEnabled = n, this.inForeground = r;\n};\n\n/** Name of the IndexedDb object store. */ Zi.store = \"clientMetadata\", \n/** Keys are automatically assigned via the clientId properties. */\nZi.keyPath = \"clientId\";\n\nvar to = t.__spreadArrays(t.__spreadArrays(t.__spreadArrays([ ji.store, Gi.store, zi.store, Ki.store, Hi.store, qi.store, $i.store, Yi.store ], [ Zi.store ]), [ Qi.store ]), [ Xi.store ]), eo = /** @class */ function() {\n function t() {\n /**\n * An in-memory copy of the index entries we've already written since the SDK\n * launched. Used to avoid re-writing the same entry repeatedly.\n *\n * This is *NOT* a complete cache of what's in persistence and so can never be used to\n * satisfy reads.\n */\n this.la = new Ci;\n }\n /**\n * Adds a new entry to the collection parent index.\n *\n * Repeated calls for the same collectionPath should be avoided within a\n * transaction as IndexedDbIndexManager only caches writes once a transaction\n * has been committed.\n */ return t.prototype.Mo = function(t, e) {\n var n = this;\n if (!this.la.has(e)) {\n var r = e._(), i = e.h();\n t.pr((function() {\n // Add the collection to the in memory cache only if the transaction was\n // successfully committed.\n n.la.add(e);\n }));\n var o = {\n collectionId: r,\n parent: hi(i)\n };\n return no(t).put(o);\n }\n return yr.resolve();\n }, t.prototype.Qr = function(t, e) {\n var n = [], r = IDBKeyRange.bound([ e, \"\" ], [ $(e), \"\" ], \n /*lowerOpen=*/ !1, \n /*upperOpen=*/ !0);\n return no(t).ts(r).next((function(t) {\n for (var r = 0, i = t; r < i.length; r++) {\n var o = i[r];\n // This collectionId guard shouldn't be necessary (and isn't as long\n // as we're running in a real browser), but there's a bug in\n // indexeddbshim that breaks our range in our tests running in node:\n // https://github.com/axemclion/IndexedDBShim/issues/334\n if (o.collectionId !== e) break;\n n.push(pi(o.parent));\n }\n return n;\n }));\n }, t;\n}();\n\n// V2 is no longer usable (see comment at top of file)\n// Visible for testing\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * A persisted implementation of IndexManager.\n */\n/**\n * Helper to get a typed SimpleDbStore for the collectionParents\n * document store.\n */\nfunction no(t) {\n return ho.Qn(t, Xi.store);\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** Offset to ensure non-overlapping target ids. */\n/**\n * Generates monotonically increasing target IDs for sending targets to the\n * watch stream.\n *\n * The client constructs two generators, one for the target cache, and one for\n * for the sync engine (to generate limbo documents targets). These\n * generators produce non-overlapping IDs (by using even and odd IDs\n * respectively).\n *\n * By separating the target ID space, the query cache can generate target IDs\n * that persist across client restarts, while sync engine can independently\n * generate in-memory target IDs that are transient and can be reused after a\n * restart.\n */ var ro = /** @class */ function() {\n function t(t) {\n this._a = t;\n }\n return t.prototype.next = function() {\n return this._a += 2, this._a;\n }, t.fa = function() {\n // The target cache generator must return '2' in its first call to `next()`\n // as there is no differentiation in the protocol layer between an unset\n // number and the number '0'. If we were to sent a target with target ID\n // '0', the backend would consider it unset and replace it with its own ID.\n return new t(0);\n }, t.da = function() {\n // Sync engine assigns target IDs for limbo document detection.\n return new t(-1);\n }, t;\n}(), io = /** @class */ function() {\n function t(t, e) {\n this.No = t, this.serializer = e;\n }\n // PORTING NOTE: We don't cache global metadata for the target cache, since\n // some of it (in particular `highestTargetId`) can be modified by secondary\n // tabs. We could perhaps be more granular (and e.g. still cache\n // `lastRemoteSnapshotVersion` in memory) but for simplicity we currently go\n // to IndexedDb whenever we need to read metadata. We can revisit if it turns\n // out to have a meaningful performance impact.\n return t.prototype.wa = function(t) {\n var e = this;\n return this.ma(t).next((function(n) {\n var r = new ro(n.highestTargetId);\n return n.highestTargetId = r.next(), e.Ta(t, n).next((function() {\n return n.highestTargetId;\n }));\n }));\n }, t.prototype.Ea = function(t) {\n return this.ma(t).next((function(t) {\n return st.J(new ot(t.lastRemoteSnapshotVersion.seconds, t.lastRemoteSnapshotVersion.nanoseconds));\n }));\n }, t.prototype.Ia = function(t) {\n return this.ma(t).next((function(t) {\n return t.highestListenSequenceNumber;\n }));\n }, t.prototype.Aa = function(t, e, n) {\n var r = this;\n return this.ma(t).next((function(i) {\n return i.highestListenSequenceNumber = e, n && (i.lastRemoteSnapshotVersion = n.Z()), \n e > i.highestListenSequenceNumber && (i.highestListenSequenceNumber = e), r.Ta(t, i);\n }));\n }, t.prototype.Ra = function(t, e) {\n var n = this;\n return this.ga(t, e).next((function() {\n return n.ma(t).next((function(r) {\n return r.targetCount += 1, n.Pa(e, r), n.Ta(t, r);\n }));\n }));\n }, t.prototype.ya = function(t, e) {\n return this.ga(t, e);\n }, t.prototype.Va = function(t, e) {\n var n = this;\n return this.pa(t, e.targetId).next((function() {\n return oo(t).delete(e.targetId);\n })).next((function() {\n return n.ma(t);\n })).next((function(e) {\n return g(e.targetCount > 0), e.targetCount -= 1, n.Ta(t, e);\n }));\n }, \n /**\n * Drops any targets with sequence number less than or equal to the upper bound, excepting those\n * present in `activeTargetIds`. Document associations for the removed targets are also removed.\n * Returns the number of targets removed.\n */\n t.prototype.po = function(t, e, n) {\n var r = this, i = 0, o = [];\n return oo(t).rs((function(s, u) {\n var a = Ii(u);\n a.sequenceNumber <= e && null === n.get(a.targetId) && (i++, o.push(r.Va(t, a)));\n })).next((function() {\n return yr.$n(o);\n })).next((function() {\n return i;\n }));\n }, \n /**\n * Call provided function with each `TargetData` that we have cached.\n */\n t.prototype.Ce = function(t, e) {\n return oo(t).rs((function(t, n) {\n var r = Ii(n);\n e(r);\n }));\n }, t.prototype.ma = function(t) {\n return so(t).get($i.key).next((function(t) {\n return g(null !== t), t;\n }));\n }, t.prototype.Ta = function(t, e) {\n return so(t).put($i.key, e);\n }, t.prototype.ga = function(t, e) {\n return oo(t).put(Ei(this.serializer, e));\n }, \n /**\n * In-place updates the provided metadata to account for values in the given\n * TargetData. Saving is done separately. Returns true if there were any\n * changes to the metadata.\n */\n t.prototype.Pa = function(t, e) {\n var n = !1;\n return t.targetId > e.highestTargetId && (e.highestTargetId = t.targetId, n = !0), \n t.sequenceNumber > e.highestListenSequenceNumber && (e.highestListenSequenceNumber = t.sequenceNumber, \n n = !0), n;\n }, t.prototype.ba = function(t) {\n return this.ma(t).next((function(t) {\n return t.targetCount;\n }));\n }, t.prototype.va = function(t, e) {\n // Iterating by the canonicalId may yield more than one result because\n // canonicalId values are not required to be unique per target. This query\n // depends on the queryTargets index to be efficient.\n var n = lt(e), r = IDBKeyRange.bound([ n, Number.NEGATIVE_INFINITY ], [ n, Number.POSITIVE_INFINITY ]), i = null;\n return oo(t).rs({\n range: r,\n index: Hi.queryTargetsIndexName\n }, (function(t, n, r) {\n var o = Ii(n);\n // After finding a potential match, check that the target is\n // actually equal to the requested target.\n pt(e, o.target) && (i = o, r.done());\n })).next((function() {\n return i;\n }));\n }, t.prototype.Sa = function(t, e, n) {\n var r = this, i = [], o = uo(t);\n // PORTING NOTE: The reverse index (documentsTargets) is maintained by\n // IndexedDb.\n return e.forEach((function(e) {\n var s = hi(e.path);\n i.push(o.put(new Yi(n, s))), i.push(r.No.Da(t, n, e));\n })), yr.$n(i);\n }, t.prototype.Ca = function(t, e, n) {\n var r = this, i = uo(t);\n // PORTING NOTE: The reverse index (documentsTargets) is maintained by\n // IndexedDb.\n return yr.forEach(e, (function(e) {\n var o = hi(e.path);\n return yr.$n([ i.delete([ n, o ]), r.No.Na(t, n, e) ]);\n }));\n }, t.prototype.pa = function(t, e) {\n var n = uo(t), r = IDBKeyRange.bound([ e ], [ e + 1 ], \n /*lowerOpen=*/ !1, \n /*upperOpen=*/ !0);\n return n.delete(r);\n }, t.prototype.Fa = function(t, e) {\n var n = IDBKeyRange.bound([ e ], [ e + 1 ], \n /*lowerOpen=*/ !1, \n /*upperOpen=*/ !0), r = uo(t), i = Ot();\n return r.rs({\n range: n,\n ss: !0\n }, (function(t, e, n) {\n var r = pi(t[1]), o = new A(r);\n i = i.add(o);\n })).next((function() {\n return i;\n }));\n }, t.prototype.Ho = function(t, e) {\n var n = hi(e.path), r = IDBKeyRange.bound([ n ], [ $(n) ], \n /*lowerOpen=*/ !1, \n /*upperOpen=*/ !0), i = 0;\n return uo(t).rs({\n index: Yi.documentTargetsIndex,\n ss: !0,\n range: r\n }, (function(t, e, n) {\n var r = t[0];\n // Having a sentinel row for a document does not count as containing that document;\n // For the target cache, containing the document means the document is part of some\n // target.\n t[1];\n 0 !== r && (i++, n.done());\n })).next((function() {\n return i > 0;\n }));\n }, \n /**\n * Looks up a TargetData entry by target ID.\n *\n * @param targetId The target ID of the TargetData entry to look up.\n * @return The cached TargetData entry, or null if the cache has no entry for\n * the target.\n */\n // PORTING NOTE: Multi-tab only.\n t.prototype.Ue = function(t, e) {\n return oo(t).get(e).next((function(t) {\n return t ? Ii(t) : null;\n }));\n }, t;\n}();\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Helper to get a typed SimpleDbStore for the queries object store.\n */\nfunction oo(t) {\n return ho.Qn(t, Hi.store);\n}\n\n/**\n * Helper to get a typed SimpleDbStore for the target globals object store.\n */ function so(t) {\n return ho.Qn(t, $i.store);\n}\n\n/**\n * Helper to get a typed SimpleDbStore for the document target object store.\n */ function uo(t) {\n return ho.Qn(t, Yi.store);\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */ var ao = \"Failed to obtain exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.\", co = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this) || this).jo = t, r.xa = n, r;\n }\n return t.__extends(n, e), n;\n}(ei), ho = /** @class */ function() {\n function e(\n /**\n * Whether to synchronize the in-memory state of multiple tabs and share\n * access to local persistence.\n */\n t, n, r, i, o, s, u, h, f, \n /**\n * If set to true, forcefully obtains database access. Existing tabs will\n * no longer be able to access IndexedDB.\n */\n l) {\n if (this.allowTabSynchronization = t, this.persistenceKey = n, this.clientId = r, \n this.fn = o, this.window = s, this.document = u, this.$a = f, this.ka = l, this.Ma = null, \n this.Oa = !1, this.isPrimary = !1, this.networkEnabled = !0, \n /** Our window.unload handler, if registered. */\n this.La = null, this.inForeground = !1, \n /** Our 'visibilitychange' listener if registered. */\n this.Ba = null, \n /** The client metadata refresh task. */\n this.qa = null, \n /** The last time we garbage collected the client metadata object store. */\n this.Ua = Number.NEGATIVE_INFINITY, \n /** A listener to notify on primary state changes. */\n this.Qa = function(t) {\n return Promise.resolve();\n }, !e.Ln()) throw new c(a.UNIMPLEMENTED, \"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.\");\n this.No = new po(this, i), this.Wa = n + \"main\", this.serializer = new di(h), this.ja = new gr(this.Wa, 10, new Fi(this.serializer)), \n this.Ka = new io(this.No, this.serializer), this.Dr = new eo, this.vr = function(t, e) {\n return new Li(t, e);\n }(this.serializer, this.Dr), this.window && this.window.localStorage ? this.Ga = this.window.localStorage : (this.Ga = null, \n !1 === l && p(\"IndexedDbPersistence\", \"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page.\"));\n }\n return e.Qn = function(t, e) {\n if (t instanceof co) return gr.Qn(t.jo, e);\n throw y();\n }, \n /**\n * Attempt to start IndexedDb persistence.\n *\n * @return {Promise} Whether persistence was enabled.\n */\n e.prototype.start = function() {\n var t = this;\n // NOTE: This is expected to fail sometimes (in the case of another tab\n // already having the persistence lock), so it's the first thing we should\n // do.\n return this.za().then((function() {\n if (!t.isPrimary && !t.allowTabSynchronization) \n // Fail `start()` if `synchronizeTabs` is disabled and we cannot\n // obtain the primary lease.\n throw new c(a.FAILED_PRECONDITION, ao);\n return t.Ha(), t.Ya(), t.Ja(), t.runTransaction(\"getHighestListenSequenceNumber\", \"readonly\", (function(e) {\n return t.Ka.Ia(e);\n }));\n })).then((function(e) {\n t.Ma = new qr(e, t.$a);\n })).then((function() {\n t.Oa = !0;\n })).catch((function(e) {\n return t.ja && t.ja.close(), Promise.reject(e);\n }));\n }, \n /**\n * Registers a listener that gets called when the primary state of the\n * instance changes. Upon registering, this listener is invoked immediately\n * with the current primary state.\n *\n * PORTING NOTE: This is only used for Web multi-tab.\n */\n e.prototype.Xa = function(e) {\n var n = this;\n return this.Qa = function(r) {\n return t.__awaiter(n, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n return this.Ei ? [ 2 /*return*/ , e(r) ] : [ 2 /*return*/ ];\n }));\n }));\n }, e(this.isPrimary);\n }, \n /**\n * Registers a listener that gets called when the database receives a\n * version change event indicating that it has deleted.\n *\n * PORTING NOTE: This is only used for Web multi-tab.\n */\n e.prototype.Za = function(e) {\n var n = this;\n this.ja.Kn((function(r) {\n return t.__awaiter(n, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return null === r.newVersion ? [ 4 /*yield*/ , e() ] : [ 3 /*break*/ , 2 ];\n\n case 1:\n t.sent(), t.label = 2;\n\n case 2:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }));\n }, \n /**\n * Adjusts the current network state in the client's metadata, potentially\n * affecting the primary lease.\n *\n * PORTING NOTE: This is only used for Web multi-tab.\n */\n e.prototype.tc = function(e) {\n var n = this;\n this.networkEnabled !== e && (this.networkEnabled = e, \n // Schedule a primary lease refresh for immediate execution. The eventual\n // lease update will be propagated via `primaryStateListener`.\n this.fn.ws((function() {\n return t.__awaiter(n, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return this.Ei ? [ 4 /*yield*/ , this.za() ] : [ 3 /*break*/ , 2 ];\n\n case 1:\n t.sent(), t.label = 2;\n\n case 2:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n })));\n }, \n /**\n * Updates the client metadata in IndexedDb and attempts to either obtain or\n * extend the primary lease for the local client. Asynchronously notifies the\n * primary state listener if the client either newly obtained or released its\n * primary lease.\n */\n e.prototype.za = function() {\n var t = this;\n return this.runTransaction(\"updateClientMetadataAndTryBecomePrimary\", \"readwrite\", (function(e) {\n return lo(e).put(new Zi(t.clientId, Date.now(), t.networkEnabled, t.inForeground)).next((function() {\n if (t.isPrimary) return t.ec(e).next((function(e) {\n e || (t.isPrimary = !1, t.fn.Cs((function() {\n return t.Qa(!1);\n })));\n }));\n })).next((function() {\n return t.nc(e);\n })).next((function(n) {\n return t.isPrimary && !n ? t.sc(e).next((function() {\n return !1;\n })) : !!n && t.ic(e).next((function() {\n return !0;\n }));\n }));\n })).catch((function(e) {\n if (_r(e)) \n // Proceed with the existing state. Any subsequent access to\n // IndexedDB will verify the lease.\n return l(\"IndexedDbPersistence\", \"Failed to extend owner lease: \", e), t.isPrimary;\n if (!t.allowTabSynchronization) throw e;\n return l(\"IndexedDbPersistence\", \"Releasing owner lease after error during lease refresh\", e), \n /* isPrimary= */ !1;\n })).then((function(e) {\n t.isPrimary !== e && t.fn.Cs((function() {\n return t.Qa(e);\n })), t.isPrimary = e;\n }));\n }, e.prototype.ec = function(t) {\n var e = this;\n return fo(t).get(qi.key).next((function(t) {\n return yr.resolve(e.rc(t));\n }));\n }, e.prototype.oc = function(t) {\n return lo(t).delete(this.clientId);\n }, \n /**\n * If the garbage collection threshold has passed, prunes the\n * RemoteDocumentChanges and the ClientMetadata store based on the last update\n * time of all clients.\n */\n e.prototype.ac = function() {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n, r, i, o, s = this;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return !this.isPrimary || this.cc(this.Ua, 18e5) ? [ 3 /*break*/ , 2 ] : (this.Ua = Date.now(), \n [ 4 /*yield*/ , this.runTransaction(\"maybeGarbageCollectMultiClientState\", \"readwrite-primary\", (function(t) {\n var n = e.Qn(t, Zi.store);\n return n.ts().next((function(t) {\n var e = s.uc(t, 18e5), r = t.filter((function(t) {\n return -1 === e.indexOf(t);\n }));\n // Delete metadata for clients that are no longer considered active.\n return yr.forEach(r, (function(t) {\n return n.delete(t.clientId);\n })).next((function() {\n return r;\n }));\n }));\n })).catch((function() {\n return [];\n })) ]);\n\n case 1:\n // Delete potential leftover entries that may continue to mark the\n // inactive clients as zombied in LocalStorage.\n // Ideally we'd delete the IndexedDb and LocalStorage zombie entries for\n // the client atomically, but we can't. So we opt to delete the IndexedDb\n // entries first to avoid potentially reviving a zombied client.\n if (n = t.sent(), this.Ga) for (r = 0, i = n; r < i.length; r++) o = i[r], this.Ga.removeItem(this.hc(o.clientId));\n t.label = 2;\n\n case 2:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }, \n /**\n * Schedules a recurring timer to update the client metadata and to either\n * extend or acquire the primary lease if the client is eligible.\n */\n e.prototype.Ja = function() {\n var t = this;\n this.qa = this.fn.yn(\"client_metadata_refresh\" /* ClientMetadataRefresh */ , 4e3, (function() {\n return t.za().then((function() {\n return t.ac();\n })).then((function() {\n return t.Ja();\n }));\n }));\n }, \n /** Checks whether `client` is the local client. */ e.prototype.rc = function(t) {\n return !!t && t.ownerId === this.clientId;\n }, \n /**\n * Evaluate the state of all active clients and determine whether the local\n * client is or can act as the holder of the primary lease. Returns whether\n * the client is eligible for the lease, but does not actually acquire it.\n * May return 'false' even if there is no active leaseholder and another\n * (foreground) client should become leaseholder instead.\n */\n e.prototype.nc = function(t) {\n var e = this;\n return this.ka ? yr.resolve(!0) : fo(t).get(qi.key).next((function(n) {\n // A client is eligible for the primary lease if:\n // - its network is enabled and the client's tab is in the foreground.\n // - its network is enabled and no other client's tab is in the\n // foreground.\n // - every clients network is disabled and the client's tab is in the\n // foreground.\n // - every clients network is disabled and no other client's tab is in\n // the foreground.\n // - the `forceOwningTab` setting was passed in.\n if (null !== n && e.cc(n.leaseTimestampMs, 5e3) && !e.lc(n.ownerId)) {\n if (e.rc(n) && e.networkEnabled) return !0;\n if (!e.rc(n)) {\n if (!n.allowTabSynchronization) \n // Fail the `canActAsPrimary` check if the current leaseholder has\n // not opted into multi-tab synchronization. If this happens at\n // client startup, we reject the Promise returned by\n // `enablePersistence()` and the user can continue to use Firestore\n // with in-memory persistence.\n // If this fails during a lease refresh, we will instead block the\n // AsyncQueue from executing further operations. Note that this is\n // acceptable since mixing & matching different `synchronizeTabs`\n // settings is not supported.\n // TODO(b/114226234): Remove this check when `synchronizeTabs` can\n // no longer be turned off.\n throw new c(a.FAILED_PRECONDITION, ao);\n return !1;\n }\n }\n return !(!e.networkEnabled || !e.inForeground) || lo(t).ts().next((function(t) {\n return void 0 === e.uc(t, 5e3).find((function(t) {\n if (e.clientId !== t.clientId) {\n var n = !e.networkEnabled && t.networkEnabled, r = !e.inForeground && t.inForeground, i = e.networkEnabled === t.networkEnabled;\n if (n || r && i) return !0;\n }\n return !1;\n }));\n }));\n })).next((function(t) {\n return e.isPrimary !== t && l(\"IndexedDbPersistence\", \"Client \" + (t ? \"is\" : \"is not\") + \" eligible for a primary lease.\"), \n t;\n }));\n }, e.prototype.Di = function() {\n return t.__awaiter(this, void 0, void 0, (function() {\n var e = this;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n // Use `SimpleDb.runTransaction` directly to avoid failing if another tab\n // has obtained the primary lease.\n // The shutdown() operations are idempotent and can be called even when\n // start() aborted (e.g. because it couldn't acquire the persistence lease).\n return this.Oa = !1, this._c(), this.qa && (this.qa.cancel(), this.qa = null), this.fc(), \n this.dc(), [ 4 /*yield*/ , this.ja.runTransaction(\"shutdown\", \"readwrite\", [ qi.store, Zi.store ], (function(t) {\n var n = new co(t, qr.ai);\n return e.sc(n).next((function() {\n return e.oc(n);\n }));\n })) ];\n\n case 1:\n // The shutdown() operations are idempotent and can be called even when\n // start() aborted (e.g. because it couldn't acquire the persistence lease).\n // Use `SimpleDb.runTransaction` directly to avoid failing if another tab\n // has obtained the primary lease.\n return t.sent(), this.ja.close(), \n // Remove the entry marking the client as zombied from LocalStorage since\n // we successfully deleted its metadata from IndexedDb.\n this.wc(), [ 2 /*return*/ ];\n }\n }));\n }));\n }, \n /**\n * Returns clients that are not zombied and have an updateTime within the\n * provided threshold.\n */\n e.prototype.uc = function(t, e) {\n var n = this;\n return t.filter((function(t) {\n return n.cc(t.updateTimeMs, e) && !n.lc(t.clientId);\n }));\n }, \n /**\n * Returns the IDs of the clients that are currently active. If multi-tab\n * is not supported, returns an array that only contains the local client's\n * ID.\n *\n * PORTING NOTE: This is only used for Web multi-tab.\n */\n e.prototype.pi = function() {\n var t = this;\n return this.runTransaction(\"getActiveClients\", \"readonly\", (function(e) {\n return lo(e).ts().next((function(e) {\n return t.uc(e, 18e5).map((function(t) {\n return t.clientId;\n }));\n }));\n }));\n }, Object.defineProperty(e.prototype, \"Ei\", {\n get: function() {\n return this.Oa;\n },\n enumerable: !1,\n configurable: !0\n }), e.prototype.mc = function(t) {\n return Ti.xo(t, this.serializer, this.Dr, this.No);\n }, e.prototype.Tc = function() {\n return this.Ka;\n }, e.prototype.Ec = function() {\n return this.vr;\n }, e.prototype.Ic = function() {\n return this.Dr;\n }, e.prototype.runTransaction = function(t, e, n) {\n var r = this;\n l(\"IndexedDbPersistence\", \"Starting transaction:\", t);\n var i, o = \"readonly\" === e ? \"readonly\" : \"readwrite\";\n // Do all transactions as readwrite against all object stores, since we\n // are the only reader/writer.\n return this.ja.runTransaction(t, o, to, (function(o) {\n return i = new co(o, r.Ma ? r.Ma.next() : qr.ai), \"readwrite-primary\" === e ? r.ec(i).next((function(t) {\n return !!t || r.nc(i);\n })).next((function(e) {\n if (!e) throw p(\"Failed to obtain primary lease for action '\" + t + \"'.\"), r.isPrimary = !1, \n r.fn.Cs((function() {\n return r.Qa(!1);\n })), new c(a.FAILED_PRECONDITION, ti);\n return n(i);\n })).next((function(t) {\n return r.ic(i).next((function() {\n return t;\n }));\n })) : r.Ac(i).next((function() {\n return n(i);\n }));\n })).then((function(t) {\n return i.br(), t;\n }));\n }, \n /**\n * Verifies that the current tab is the primary leaseholder or alternatively\n * that the leaseholder has opted into multi-tab synchronization.\n */\n // TODO(b/114226234): Remove this check when `synchronizeTabs` can no longer\n // be turned off.\n e.prototype.Ac = function(t) {\n var e = this;\n return fo(t).get(qi.key).next((function(t) {\n if (null !== t && e.cc(t.leaseTimestampMs, 5e3) && !e.lc(t.ownerId) && !e.rc(t) && !(e.ka || e.allowTabSynchronization && t.allowTabSynchronization)) throw new c(a.FAILED_PRECONDITION, ao);\n }));\n }, \n /**\n * Obtains or extends the new primary lease for the local client. This\n * method does not verify that the client is eligible for this lease.\n */\n e.prototype.ic = function(t) {\n var e = new qi(this.clientId, this.allowTabSynchronization, Date.now());\n return fo(t).put(qi.key, e);\n }, e.Ln = function() {\n return gr.Ln();\n }, \n /** Checks the primary lease and removes it if we are the current primary. */ e.prototype.sc = function(t) {\n var e = this, n = fo(t);\n return n.get(qi.key).next((function(t) {\n return e.rc(t) ? (l(\"IndexedDbPersistence\", \"Releasing primary lease.\"), n.delete(qi.key)) : yr.resolve();\n }));\n }, \n /** Verifies that `updateTimeMs` is within `maxAgeMs`. */ e.prototype.cc = function(t, e) {\n var n = Date.now();\n return !(t < n - e || t > n && (p(\"Detected an update time that is in the future: \" + t + \" > \" + n), \n 1));\n }, e.prototype.Ha = function() {\n var t = this;\n null !== this.document && \"function\" == typeof this.document.addEventListener && (this.Ba = function() {\n t.fn.ws((function() {\n return t.inForeground = \"visible\" === t.document.visibilityState, t.za();\n }));\n }, this.document.addEventListener(\"visibilitychange\", this.Ba), this.inForeground = \"visible\" === this.document.visibilityState);\n }, e.prototype.fc = function() {\n this.Ba && (this.document.removeEventListener(\"visibilitychange\", this.Ba), this.Ba = null);\n }, \n /**\n * Attaches a window.unload handler that will synchronously write our\n * clientId to a \"zombie client id\" location in LocalStorage. This can be used\n * by tabs trying to acquire the primary lease to determine that the lease\n * is no longer valid even if the timestamp is recent. This is particularly\n * important for the refresh case (so the tab correctly re-acquires the\n * primary lease). LocalStorage is used for this rather than IndexedDb because\n * it is a synchronous API and so can be used reliably from an unload\n * handler.\n */\n e.prototype.Ya = function() {\n var t, e = this;\n \"function\" == typeof (null === (t = this.window) || void 0 === t ? void 0 : t.addEventListener) && (this.La = function() {\n // Note: In theory, this should be scheduled on the AsyncQueue since it\n // accesses internal state. We execute this code directly during shutdown\n // to make sure it gets a chance to run.\n e._c(), e.fn.ws((function() {\n return e.Di();\n }));\n }, this.window.addEventListener(\"unload\", this.La));\n }, e.prototype.dc = function() {\n this.La && (this.window.removeEventListener(\"unload\", this.La), this.La = null);\n }, \n /**\n * Returns whether a client is \"zombied\" based on its LocalStorage entry.\n * Clients become zombied when their tab closes without running all of the\n * cleanup logic in `shutdown()`.\n */\n e.prototype.lc = function(t) {\n var e;\n try {\n var n = null !== (null === (e = this.Ga) || void 0 === e ? void 0 : e.getItem(this.hc(t)));\n return l(\"IndexedDbPersistence\", \"Client '\" + t + \"' \" + (n ? \"is\" : \"is not\") + \" zombied in LocalStorage\"), \n n;\n } catch (t) {\n // Gracefully handle if LocalStorage isn't working.\n return p(\"IndexedDbPersistence\", \"Failed to get zombied client id.\", t), !1;\n }\n }, \n /**\n * Record client as zombied (a client that had its tab closed). Zombied\n * clients are ignored during primary tab selection.\n */\n e.prototype._c = function() {\n if (this.Ga) try {\n this.Ga.setItem(this.hc(this.clientId), String(Date.now()));\n } catch (t) {\n // Gracefully handle if LocalStorage isn't available / working.\n p(\"Failed to set zombie client id.\", t);\n }\n }, \n /** Removes the zombied client entry if it exists. */ e.prototype.wc = function() {\n if (this.Ga) try {\n this.Ga.removeItem(this.hc(this.clientId));\n } catch (t) {\n // Ignore\n }\n }, e.prototype.hc = function(t) {\n return \"firestore_zombie_\" + this.persistenceKey + \"_\" + t;\n }, e;\n}();\n\n/**\n * Oldest acceptable age in milliseconds for client metadata before the client\n * is considered inactive and its associated data is garbage collected.\n */\n/**\n * Helper to get a typed SimpleDbStore for the primary client object store.\n */\nfunction fo(t) {\n return ho.Qn(t, qi.store);\n}\n\n/**\n * Helper to get a typed SimpleDbStore for the client metadata object store.\n */ function lo(t) {\n return ho.Qn(t, Zi.store);\n}\n\n/** Provides LRU functionality for IndexedDB persistence. */ var po = /** @class */ function() {\n function t(t, e) {\n this.db = t, this.wo = new ci(this, e);\n }\n return t.prototype.Po = function(t) {\n var e = this.Rc(t);\n return this.db.Tc().ba(t).next((function(t) {\n return e.next((function(e) {\n return t + e;\n }));\n }));\n }, t.prototype.Rc = function(t) {\n var e = 0;\n return this.Vo(t, (function(t) {\n e++;\n })).next((function() {\n return e;\n }));\n }, t.prototype.Ce = function(t, e) {\n return this.db.Tc().Ce(t, e);\n }, t.prototype.Vo = function(t, e) {\n return this.gc(t, (function(t, n) {\n return e(n);\n }));\n }, t.prototype.Da = function(t, e, n) {\n return vo(t, n);\n }, t.prototype.Na = function(t, e, n) {\n return vo(t, n);\n }, t.prototype.po = function(t, e, n) {\n return this.db.Tc().po(t, e, n);\n }, t.prototype.Go = function(t, e) {\n return vo(t, e);\n }, \n /**\n * Returns true if anything would prevent this document from being garbage\n * collected, given that the document in question is not present in any\n * targets and has a sequence number less than or equal to the upper bound for\n * the collection run.\n */\n t.prototype.Pc = function(t, e) {\n return function(t, e) {\n var n = !1;\n return xi(t).os((function(r) {\n return Ni(t, r, e).next((function(t) {\n return t && (n = !0), yr.resolve(!t);\n }));\n })).next((function() {\n return n;\n }));\n }(t, e);\n }, t.prototype.bo = function(t, e) {\n var n = this, r = this.db.Ec().ra(), i = [], o = 0;\n return this.gc(t, (function(s, u) {\n if (u <= e) {\n var a = n.Pc(t, s).next((function(e) {\n if (!e) \n // Our size accounting requires us to read all documents before\n // removing them.\n return o++, r.Rr(t, s).next((function() {\n return r.Ar(s), uo(t).delete([ 0, hi(s.path) ]);\n }));\n }));\n i.push(a);\n }\n })).next((function() {\n return yr.$n(i);\n })).next((function() {\n return r.apply(t);\n })).next((function() {\n return o;\n }));\n }, t.prototype.removeTarget = function(t, e) {\n var n = e.st(t.xa);\n return this.db.Tc().ya(t, n);\n }, t.prototype.yc = function(t, e) {\n return vo(t, e);\n }, \n /**\n * Call provided function for each document in the cache that is 'orphaned'. Orphaned\n * means not a part of any target, so the only entry in the target-document index for\n * that document will be the sentinel row (targetId 0), which will also have the sequence\n * number for the last time the document was accessed.\n */\n t.prototype.gc = function(t, e) {\n var n, r = uo(t), i = qr.ai;\n return r.rs({\n index: Yi.documentTargetsIndex\n }, (function(t, r) {\n var o = t[0], s = (t[1], r.path), u = r.sequenceNumber;\n 0 === o ? (\n // if nextToReport is valid, report it, this is a new key so the\n // last one must not be a member of any targets.\n i !== qr.ai && e(new A(pi(n)), i), \n // set nextToReport to be this sequence number. It's the next one we\n // might report, if we don't find any targets for this document.\n // Note that the sequence number must be defined when the targetId\n // is 0.\n i = u, n = s) : \n // set nextToReport to be invalid, we know we don't need to report\n // this one since we found a target for it.\n i = qr.ai;\n })).next((function() {\n // Since we report sequence numbers after getting to the next key, we\n // need to check if the last key we iterated over was an orphaned\n // document and report it.\n i !== qr.ai && e(new A(pi(n)), i);\n }));\n }, t.prototype.So = function(t) {\n return this.db.Ec().aa(t);\n }, t;\n}();\n\nfunction vo(t, e) {\n return uo(t).put(\n /**\n * @return A value suitable for writing a sentinel row in the target-document\n * store.\n */\n function(t, e) {\n return new Yi(0, hi(t.path), e);\n }(e, t.xa));\n}\n\n/**\n * Generates a string used as a prefix when storing data in IndexedDB and\n * LocalStorage.\n */ function yo(t, e) {\n // Use two different prefix formats:\n // * firestore / persistenceKey / projectID . databaseID / ...\n // * firestore / persistenceKey / projectID / ...\n // projectIDs are DNS-compatible names and cannot contain dots\n // so there's no danger of collisions.\n var n = t.projectId;\n return t.j || (n += \".\" + t.database), \"firestore/\" + e + \"/\" + n + \"/\"\n /**\n * Implements `LocalStore` interface.\n *\n * Note: some field defined in this class might have public access level, but\n * the class is not exported so they are only accessible from this module.\n * This is useful to implement optional features (like bundles) in free\n * functions, such that they are tree-shakeable.\n */;\n}\n\nvar go = /** @class */ function() {\n function t(\n /** Manages our in-memory or durable persistence. */\n t, e, n) {\n this.persistence = t, this.Vc = e, \n /**\n * Maps a targetID to data about its target.\n *\n * PORTING NOTE: We are using an immutable data structure on Web to make re-runs\n * of `applyRemoteEvent()` idempotent.\n */\n this.bc = new bt(H), \n /** Maps a target to its targetID. */\n // TODO(wuandy): Evaluate if TargetId can be part of Target.\n this.vc = new it((function(t) {\n return lt(t);\n }), pt), \n /**\n * The read time of the last entry processed by `getNewDocumentChanges()`.\n *\n * PORTING NOTE: This is only used for multi-tab synchronization.\n */\n this.Sc = st.min(), this.Sr = t.mc(n), this.Dc = t.Ec(), this.Ka = t.Tc(), this.Cc = new ni(this.Dc, this.Sr, this.persistence.Ic()), \n this.Vc.Nc(this.Cc);\n }\n return t.prototype.Io = function(t) {\n var e = this;\n return this.persistence.runTransaction(\"Collect garbage\", \"readwrite-primary\", (function(n) {\n return t.vo(n, e.bc);\n }));\n }, t;\n}();\n\n/**\n * Acknowledges the given batch.\n *\n * On the happy path when a batch is acknowledged, the local store will\n *\n * + remove the batch from the mutation queue;\n * + apply the changes to the remote document cache;\n * + recalculate the latency compensated view implied by those changes (there\n * may be mutations in the queue that affect the documents but haven't been\n * acknowledged yet); and\n * + give the changed documents back the sync engine\n *\n * @returns The resulting (modified) documents.\n */ function mo(t, e) {\n var n = m(t);\n return n.persistence.runTransaction(\"Acknowledge batch\", \"readwrite-primary\", (function(t) {\n var r = e.batch.keys(), i = n.Dc.ra({\n oa: !0\n });\n return function(t, e, n, r) {\n var i = n.batch, o = i.keys(), s = yr.resolve();\n return o.forEach((function(t) {\n s = s.next((function() {\n return r.Rr(e, t);\n })).next((function(e) {\n var o = e, s = n.dr.get(t);\n g(null !== s), (!o || o.version.L(s) < 0) && ((o = i.cr(t, o, n)) && \n // We use the commitVersion as the readTime rather than the\n // document's updateTime since the updateTime is not advanced\n // for updates that do not modify the underlying document.\n r.Er(o, n._r));\n }));\n })), s.next((function() {\n return t.Sr.Wo(e, i);\n }));\n }(n, t, e, i).next((function() {\n return i.apply(t);\n })).next((function() {\n return n.Sr.zo(t);\n })).next((function() {\n return n.Cc.kr(t, r);\n }));\n }));\n}\n\n/**\n * Removes mutations from the MutationQueue for the specified batch;\n * LocalDocuments will be recalculated.\n *\n * @returns The resulting modified documents.\n */\n/**\n * Returns the last consistent snapshot processed (used by the RemoteStore to\n * determine whether to buffer incoming snapshots from the backend).\n */ function wo(t) {\n var e = m(t);\n return e.persistence.runTransaction(\"Get last remote snapshot version\", \"readonly\", (function(t) {\n return e.Ka.Ea(t);\n }));\n}\n\n/**\n * Updates the \"ground-state\" (remote) documents. We assume that the remote\n * event reflects any write batches that have been acknowledged or rejected\n * (i.e. we do not re-apply local mutations to updates from this event).\n *\n * LocalDocuments are re-calculated if there are remaining mutations in the\n * queue.\n */ function _o(t, e) {\n var n = m(t), r = e.nt, i = n.bc;\n return n.persistence.runTransaction(\"Apply remote event\", \"readwrite-primary\", (function(t) {\n var o = n.Dc.ra({\n oa: !0\n });\n // Reset newTargetDataByTargetMap in case this transaction gets re-run.\n i = n.bc;\n var s = [];\n e.zt.forEach((function(e, o) {\n var u = i.get(o);\n if (u) {\n // Only update the remote keys if the target is still active. This\n // ensures that we can persist the updated target data along with\n // the updated assignment.\n s.push(n.Ka.Ca(t, e.se, o).next((function() {\n return n.Ka.Sa(t, e.ee, o);\n })));\n var a = e.resumeToken;\n // Update the resume token if the change includes one.\n if (a.O() > 0) {\n var c = u.it(a, r).st(t.xa);\n i = i.ot(o, c), \n // Update the target data if there are target changes (or if\n // sufficient time has passed since the last update).\n /**\n * Returns true if the newTargetData should be persisted during an update of\n * an active target. TargetData should always be persisted when a target is\n * being released and should not call this function.\n *\n * While the target is active, TargetData updates can be omitted when nothing\n * about the target has changed except metadata like the resume token or\n * snapshot version. Occasionally it's worth the extra write to prevent these\n * values from getting too stale after a crash, but this doesn't have to be\n * too frequent.\n */\n function(t, e, n) {\n // Always persist target data if we don't already have a resume token.\n return g(e.resumeToken.O() > 0), 0 === t.resumeToken.O() || (\n // Don't allow resume token changes to be buffered indefinitely. This\n // allows us to be reasonably up-to-date after a crash and avoids needing\n // to loop over all active queries on shutdown. Especially in the browser\n // we may not get time to do anything interesting while the current tab is\n // closing.\n e.nt.X() - t.nt.X() >= 3e8 || n.ee.size + n.ne.size + n.se.size > 0);\n }(u, c, e) && s.push(n.Ka.ya(t, c));\n }\n }\n }));\n var u = St(), a = Ot();\n // HACK: The only reason we allow a null snapshot version is so that we\n // can synthesize remote events when we get permission denied errors while\n // trying to resolve the state of a locally cached document that is in\n // limbo.\n if (e.Yt.forEach((function(t, e) {\n a = a.add(t);\n })), \n // Each loop iteration only affects its \"own\" doc, so it's safe to get all the remote\n // documents in advance in a single call.\n s.push(o.getEntries(t, a).next((function(i) {\n e.Yt.forEach((function(a, c) {\n var h = i.get(a);\n // Note: The order of the steps below is important, since we want\n // to ensure that rejected limbo resolutions (which fabricate\n // NoDocuments with SnapshotVersion.min()) never add documents to\n // cache.\n c instanceof Rn && c.version.isEqual(st.min()) ? (\n // NoDocuments with SnapshotVersion.min() are used in manufactured\n // events. We remove these documents from cache since we lost\n // access.\n o.Ar(a, r), u = u.ot(a, c)) : null == h || c.version.L(h.version) > 0 || 0 === c.version.L(h.version) && h.hasPendingWrites ? (o.Er(c, r), \n u = u.ot(a, c)) : l(\"LocalStore\", \"Ignoring outdated watch update for \", a, \". Current version:\", h.version, \" Watch version:\", c.version), \n e.Jt.has(a) && s.push(n.persistence.No.yc(t, a));\n }));\n }))), !r.isEqual(st.min())) {\n var c = n.Ka.Ea(t).next((function(e) {\n return n.Ka.Aa(t, t.xa, r);\n }));\n s.push(c);\n }\n return yr.$n(s).next((function() {\n return o.apply(t);\n })).next((function() {\n return n.Cc.Mr(t, u);\n }));\n })).then((function(t) {\n return n.bc = i, t;\n }));\n}\n\n/**\n * Gets the mutation batch after the passed in batchId in the mutation queue\n * or null if empty.\n * @param afterBatchId If provided, the batch to search after.\n * @returns The next mutation or null if there wasn't one.\n */ function bo(t, e) {\n var n = m(t);\n return n.persistence.runTransaction(\"Get next mutation batch\", \"readonly\", (function(t) {\n return void 0 === e && (e = -1), n.Sr.Bo(t, e);\n }));\n}\n\n/**\n * Reads the current value of a Document with a given key or null if not\n * found - used for testing.\n */\n/**\n * Assigns the given target an internal ID so that its results can be pinned so\n * they don't get GC'd. A target must be allocated in the local store before\n * the store can be used to manage its view.\n *\n * Allocating an already allocated `Target` will return the existing `TargetData`\n * for that `Target`.\n */ function Io(t, e) {\n var n = m(t);\n return n.persistence.runTransaction(\"Allocate target\", \"readwrite\", (function(t) {\n var r;\n return n.Ka.va(t, e).next((function(i) {\n return i ? (\n // This target has been listened to previously, so reuse the\n // previous targetID.\n // TODO(mcg): freshen last accessed date?\n r = i, yr.resolve(r)) : n.Ka.wa(t).next((function(i) {\n return r = new gt(e, i, 0 /* Listen */ , t.xa), n.Ka.Ra(t, r).next((function() {\n return r;\n }));\n }));\n }));\n })).then((function(t) {\n // If Multi-Tab is enabled, the existing target data may be newer than\n // the in-memory data\n var r = n.bc.get(t.targetId);\n return (null === r || t.nt.L(r.nt) > 0) && (n.bc = n.bc.ot(t.targetId, t), n.vc.set(e, t.targetId)), \n t;\n }));\n}\n\n/**\n * Returns the TargetData as seen by the LocalStore, including updates that may\n * have not yet been persisted to the TargetCache.\n */\n// Visible for testing.\n/**\n * Unpins all the documents associated with the given target. If\n * `keepPersistedTargetData` is set to false and Eager GC enabled, the method\n * directly removes the associated target data from the target cache.\n *\n * Releasing a non-existing `Target` is a no-op.\n */\n// PORTING NOTE: `keepPersistedTargetData` is multi-tab only.\nfunction Eo(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var i, o, s, u;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n i = m(e), o = i.bc.get(n), s = r ? \"readwrite\" : \"readwrite-primary\", t.label = 1;\n\n case 1:\n return t.trys.push([ 1, 4, , 5 ]), r ? [ 3 /*break*/ , 3 ] : [ 4 /*yield*/ , i.persistence.runTransaction(\"Release target\", s, (function(t) {\n return i.persistence.No.removeTarget(t, o);\n })) ];\n\n case 2:\n t.sent(), t.label = 3;\n\n case 3:\n return [ 3 /*break*/ , 5 ];\n\n case 4:\n if (!_r(u = t.sent())) throw u;\n // All `releaseTarget` does is record the final metadata state for the\n // target, but we've been recording this periodically during target\n // activity. If we lose this write this could cause a very slight\n // difference in the order of target deletion during GC, but we\n // don't define exact LRU semantics so this is acceptable.\n return l(\"LocalStore\", \"Failed to update sequence numbers for target \" + n + \": \" + u), \n [ 3 /*break*/ , 5 ];\n\n case 5:\n return i.bc = i.bc.remove(n), i.vc.delete(o.target), [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/**\n * Runs the specified query against the local store and returns the results,\n * potentially taking advantage of query data from previous executions (such\n * as the set of remote keys).\n *\n * @param usePreviousResults Whether results from previous executions can\n * be used to optimize this query execution.\n */ function To(t, e, n) {\n var r = m(t), i = st.min(), o = Ot();\n return r.persistence.runTransaction(\"Execute query\", \"readonly\", (function(t) {\n return function(t, e, n) {\n var r = m(t), i = r.vc.get(n);\n return void 0 !== i ? yr.resolve(r.bc.get(i)) : r.Ka.va(e, n);\n }(r, t, zn(e)).next((function(e) {\n if (e) return i = e.lastLimboFreeSnapshotVersion, r.Ka.Fa(t, e.targetId).next((function(t) {\n o = t;\n }));\n })).next((function() {\n return r.Vc.Lr(t, e, n ? i : st.min(), n ? o : Ot());\n })).next((function(t) {\n return {\n documents: t,\n Fc: o\n };\n }));\n }));\n}\n\n// PORTING NOTE: Multi-Tab only.\nfunction No(t, e) {\n var n = m(t), r = m(n.Ka), i = n.bc.get(e);\n return i ? Promise.resolve(i.target) : n.persistence.runTransaction(\"Get target data\", \"readonly\", (function(t) {\n return r.Ue(t, e).next((function(t) {\n return t ? t.target : null;\n }));\n }));\n}\n\n/**\n * Returns the set of documents that have been updated since the last call.\n * If this is the first call, returns the set of changes since client\n * initialization. Further invocations will return document that have changed\n * since the prior call.\n */\n// PORTING NOTE: Multi-Tab only.\nfunction Ao(t) {\n var e = m(t);\n return e.persistence.runTransaction(\"Get new document changes\", \"readonly\", (function(t) {\n return function(t, e, n) {\n var r = m(t), i = St(), o = gi(n), s = Oi(e), u = IDBKeyRange.lowerBound(o, !0);\n return s.rs({\n index: Ki.readTimeIndex,\n range: u\n }, (function(t, e) {\n // Unlike `getEntry()` and others, `getNewDocumentChanges()` parses\n // the documents directly since we want to keep sentinel deletes.\n var n = vi(r.serializer, e);\n i = i.ot(n.key, n), o = e.readTime;\n })).next((function() {\n return {\n xc: i,\n readTime: mi(o)\n };\n }));\n }(e.Dc, t, e.Sc);\n })).then((function(t) {\n var n = t.xc, r = t.readTime;\n return e.Sc = r, n;\n }));\n}\n\n/**\n * Reads the newest document change from persistence and moves the internal\n * synchronization marker forward so that calls to `getNewDocumentChanges()`\n * only return changes that happened after client initialization.\n */\n// PORTING NOTE: Multi-Tab only.\nfunction So(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n;\n return t.__generator(this, (function(t) {\n return [ 2 /*return*/ , (n = m(e)).persistence.runTransaction(\"Synchronize last document change read time\", \"readonly\", (function(t) {\n return function(t) {\n var e = Oi(t), n = st.min();\n // If there are no existing entries, we return SnapshotVersion.min().\n return e.rs({\n index: Ki.readTimeIndex,\n reverse: !0\n }, (function(t, e, r) {\n e.readTime && (n = mi(e.readTime)), r.done();\n })).next((function() {\n return n;\n }));\n }(t);\n })).then((function(t) {\n n.Sc = t;\n })) ];\n }));\n }));\n}\n\n/**\n * Verifies the error thrown by a LocalStore operation. If a LocalStore\n * operation fails because the primary lease has been taken by another client,\n * we ignore the error (the persistence layer will immediately call\n * `applyPrimaryLease` to propagate the primary state change). All other errors\n * are re-thrown.\n *\n * @param err An error returned by a LocalStore operation.\n * @return A Promise that resolves after we recovered, or the original error.\n */ function Do(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n if (e.code !== a.FAILED_PRECONDITION || e.message !== ti) throw e;\n return l(\"LocalStore\", \"Unexpectedly lost primary lease\"), [ 2 /*return*/ ];\n }));\n }));\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * A collection of references to a document from some kind of numbered entity\n * (either a target ID or batch ID). As references are added to or removed from\n * the set corresponding events are emitted to a registered garbage collector.\n *\n * Each reference is represented by a DocumentReference object. Each of them\n * contains enough information to uniquely identify the reference. They are all\n * stored primarily in a set sorted by key. A document is considered garbage if\n * there's no references in that set (this can be efficiently checked thanks to\n * sorting by key).\n *\n * ReferenceSet also keeps a secondary set that contains references sorted by\n * IDs. This one is used to efficiently implement removal of all references by\n * some target ID.\n */ var xo = /** @class */ function() {\n function t() {\n // A set of outstanding references to a document sorted by key.\n this.$c = new Tt(Lo.kc), \n // A set of outstanding references to a document sorted by target id.\n this.Mc = new Tt(Lo.Oc)\n /** Returns true if the reference set contains no references. */;\n }\n return t.prototype.m = function() {\n return this.$c.m();\n }, \n /** Adds a reference to the given document key for the given ID. */ t.prototype.Da = function(t, e) {\n var n = new Lo(t, e);\n this.$c = this.$c.add(n), this.Mc = this.Mc.add(n);\n }, \n /** Add references to the given document keys for the given ID. */ t.prototype.Lc = function(t, e) {\n var n = this;\n t.forEach((function(t) {\n return n.Da(t, e);\n }));\n }, \n /**\n * Removes a reference to the given document key for the given\n * ID.\n */\n t.prototype.Na = function(t, e) {\n this.Bc(new Lo(t, e));\n }, t.prototype.qc = function(t, e) {\n var n = this;\n t.forEach((function(t) {\n return n.Na(t, e);\n }));\n }, \n /**\n * Clears all references with a given ID. Calls removeRef() for each key\n * removed.\n */\n t.prototype.Uc = function(t) {\n var e = this, n = new A(new E([])), r = new Lo(n, t), i = new Lo(n, t + 1), o = [];\n return this.Mc.Ft([ r, i ], (function(t) {\n e.Bc(t), o.push(t.key);\n })), o;\n }, t.prototype.Qc = function() {\n var t = this;\n this.$c.forEach((function(e) {\n return t.Bc(e);\n }));\n }, t.prototype.Bc = function(t) {\n this.$c = this.$c.delete(t), this.Mc = this.Mc.delete(t);\n }, t.prototype.Wc = function(t) {\n var e = new A(new E([])), n = new Lo(e, t), r = new Lo(e, t + 1), i = Ot();\n return this.Mc.Ft([ n, r ], (function(t) {\n i = i.add(t.key);\n })), i;\n }, t.prototype.Ho = function(t) {\n var e = new Lo(t, 0), n = this.$c.$t(e);\n return null !== n && t.isEqual(n.key);\n }, t;\n}(), Lo = /** @class */ function() {\n function t(t, e) {\n this.key = t, this.jc = e\n /** Compare by key then by ID */;\n }\n return t.kc = function(t, e) {\n return A.i(t.key, e.key) || H(t.jc, e.jc);\n }, \n /** Compare by ID then by key */ t.Oc = function(t, e) {\n return H(t.jc, e.jc) || A.i(t.key, e.key);\n }, t;\n}(), ko = function(t, e) {\n this.user = e, this.type = \"OAuth\", this.Kc = {}, \n // Set the headers using Object Literal notation to avoid minification\n this.Kc.Authorization = \"Bearer \" + t;\n}, Ro = /** @class */ function() {\n function t() {\n /**\n * Stores the listener registered with setChangeListener()\n * This isn't actually necessary since the UID never changes, but we use this\n * to verify the listen contract is adhered to in tests.\n */\n this.Gc = null;\n }\n return t.prototype.getToken = function() {\n return Promise.resolve(null);\n }, t.prototype.zc = function() {}, t.prototype.Hc = function(t) {\n this.Gc = t, \n // Fire with initial user.\n t(Mr.UNAUTHENTICATED);\n }, t.prototype.Yc = function() {\n this.Gc = null;\n }, t;\n}(), Oo = /** @class */ function() {\n function t(t) {\n var e = this;\n /**\n * The auth token listener registered with FirebaseApp, retained here so we\n * can unregister it.\n */ this.Jc = null, \n /** Tracks the current User. */\n this.currentUser = Mr.UNAUTHENTICATED, this.Xc = !1, \n /**\n * Counter used to detect if the token changed while a getToken request was\n * outstanding.\n */\n this.Zc = 0, \n /** The listener registered with setChangeListener(). */\n this.Gc = null, this.forceRefresh = !1, this.Jc = function() {\n e.Zc++, e.currentUser = e.tu(), e.Xc = !0, e.Gc && e.Gc(e.currentUser);\n }, this.Zc = 0, this.auth = t.getImmediate({\n optional: !0\n }), this.auth ? this.auth.addAuthTokenListener(this.Jc) : (\n // if auth is not available, invoke tokenListener once with null token\n this.Jc(null), t.get().then((function(t) {\n e.auth = t, e.Jc && \n // tokenListener can be removed by removeChangeListener()\n e.auth.addAuthTokenListener(e.Jc);\n }), (function() {})));\n }\n return t.prototype.getToken = function() {\n var t = this, e = this.Zc, n = this.forceRefresh;\n // Take note of the current value of the tokenCounter so that this method\n // can fail (with an ABORTED error) if there is a token change while the\n // request is outstanding.\n return this.forceRefresh = !1, this.auth ? this.auth.getToken(n).then((function(n) {\n // Cancel the request since the token changed while the request was\n // outstanding so the response is potentially for a previous user (which\n // user, we can't be sure).\n return t.Zc !== e ? (l(\"FirebaseCredentialsProvider\", \"getToken aborted due to token change.\"), \n t.getToken()) : n ? (g(\"string\" == typeof n.accessToken), new ko(n.accessToken, t.currentUser)) : null;\n })) : Promise.resolve(null);\n }, t.prototype.zc = function() {\n this.forceRefresh = !0;\n }, t.prototype.Hc = function(t) {\n this.Gc = t, \n // Fire the initial event\n this.Xc && t(this.currentUser);\n }, t.prototype.Yc = function() {\n this.auth && this.auth.removeAuthTokenListener(this.Jc), this.Jc = null, this.Gc = null;\n }, \n // Auth.getUid() can return null even with a user logged in. It is because\n // getUid() is synchronous, but the auth code populating Uid is asynchronous.\n // This method should only be called in the AuthTokenListener callback\n // to guarantee to get the actual user.\n t.prototype.tu = function() {\n var t = this.auth && this.auth.getUid();\n return g(null === t || \"string\" == typeof t), new Mr(t);\n }, t;\n}(), Po = /** @class */ function() {\n function t(t, e) {\n this.eu = t, this.nu = e, this.type = \"FirstParty\", this.user = Mr.ni;\n }\n return Object.defineProperty(t.prototype, \"Kc\", {\n get: function() {\n var t = {\n \"X-Goog-AuthUser\": this.nu\n }, e = this.eu.auth.getAuthHeaderValueForFirstParty([]);\n // Use array notation to prevent minification\n return e && (t.Authorization = e), t;\n },\n enumerable: !1,\n configurable: !0\n }), t;\n}(), Vo = /** @class */ function() {\n function t(t, e) {\n this.eu = t, this.nu = e;\n }\n return t.prototype.getToken = function() {\n return Promise.resolve(new Po(this.eu, this.nu));\n }, t.prototype.Hc = function(t) {\n // Fire with initial uid.\n t(Mr.ni);\n }, t.prototype.Yc = function() {}, t.prototype.zc = function() {}, t;\n}(), Uo = /** @class */ function() {\n function e(t, e, n, r, i, o) {\n this.fn = t, this.su = n, this.iu = r, this.ru = i, this.listener = o, this.state = 0 /* Initial */ , \n /**\n * A close count that's incremented every time the stream is closed; used by\n * getCloseGuardedDispatcher() to invalidate callbacks that happen after\n * close.\n */\n this.ou = 0, this.au = null, this.stream = null, this.ys = new vr(t, e)\n /**\n * Returns true if start() has been called and no error has occurred. True\n * indicates the stream is open or in the process of opening (which\n * encompasses respecting backoff, getting auth tokens, and starting the\n * actual RPC). Use isOpen() to determine if the stream is open and ready for\n * outbound requests.\n */;\n }\n return e.prototype.cu = function() {\n return 1 /* Starting */ === this.state || 2 /* Open */ === this.state || 4 /* Backoff */ === this.state;\n }, \n /**\n * Returns true if the underlying RPC is open (the onOpen() listener has been\n * called) and the stream is ready for outbound requests.\n */\n e.prototype.uu = function() {\n return 2 /* Open */ === this.state;\n }, \n /**\n * Starts the RPC. Only allowed if isStarted() returns false. The stream is\n * not immediately ready for use: onOpen() will be invoked when the RPC is\n * ready for outbound requests, at which point isOpen() will return true.\n *\n * When start returns, isStarted() will return true.\n */\n e.prototype.start = function() {\n 3 /* Error */ !== this.state ? this.auth() : this.hu();\n }, \n /**\n * Stops the RPC. This call is idempotent and allowed regardless of the\n * current isStarted() state.\n *\n * When stop returns, isStarted() and isOpen() will both return false.\n */\n e.prototype.stop = function() {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return this.cu() ? [ 4 /*yield*/ , this.close(0 /* Initial */) ] : [ 3 /*break*/ , 2 ];\n\n case 1:\n t.sent(), t.label = 2;\n\n case 2:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }, \n /**\n * After an error the stream will usually back off on the next attempt to\n * start it. If the error warrants an immediate restart of the stream, the\n * sender can use this to indicate that the receiver should not back off.\n *\n * Each error will call the onClose() listener. That function can decide to\n * inhibit backoff if required.\n */\n e.prototype.lu = function() {\n this.state = 0 /* Initial */ , this.ys.reset();\n }, \n /**\n * Marks this stream as idle. If no further actions are performed on the\n * stream for one minute, the stream will automatically close itself and\n * notify the stream's onClose() handler with Status.OK. The stream will then\n * be in a !isStarted() state, requiring the caller to start the stream again\n * before further use.\n *\n * Only streams that are in state 'Open' can be marked idle, as all other\n * states imply pending network operations.\n */\n e.prototype._u = function() {\n var t = this;\n // Starts the idle time if we are in state 'Open' and are not yet already\n // running a timer (in which case the previous idle timeout still applies).\n this.uu() && null === this.au && (this.au = this.fn.yn(this.su, 6e4, (function() {\n return t.fu();\n })));\n }, \n /** Sends a message to the underlying stream. */ e.prototype.du = function(t) {\n this.wu(), this.stream.send(t);\n }, \n /** Called by the idle timer when the stream should close due to inactivity. */ e.prototype.fu = function() {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n return this.uu() ? [ 2 /*return*/ , this.close(0 /* Initial */) ] : [ 2 /*return*/ ];\n }));\n }));\n }, \n /** Marks the stream as active again. */ e.prototype.wu = function() {\n this.au && (this.au.cancel(), this.au = null);\n }, \n /**\n * Closes the stream and cleans up as necessary:\n *\n * * closes the underlying GRPC stream;\n * * calls the onClose handler with the given 'error';\n * * sets internal stream state to 'finalState';\n * * adjusts the backoff timer based on the error\n *\n * A new stream can be opened by calling start().\n *\n * @param finalState the intended state of the stream after closing.\n * @param error the error the connection was closed with.\n */\n e.prototype.close = function(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n // Notify the listener that the stream closed.\n // Cancel any outstanding timers (they're guaranteed not to execute).\n return this.wu(), this.ys.cancel(), \n // Invalidates any stream-related callbacks (e.g. from auth or the\n // underlying stream), guaranteeing they won't execute.\n this.ou++, 3 /* Error */ !== e ? \n // If this is an intentional close ensure we don't delay our next connection attempt.\n this.ys.reset() : n && n.code === a.RESOURCE_EXHAUSTED ? (\n // Log the error. (Probably either 'quota exceeded' or 'max queue length reached'.)\n p(n.toString()), p(\"Using maximum backoff delay to prevent overloading the backend.\"), \n this.ys.Rn()) : n && n.code === a.UNAUTHENTICATED && \n // \"unauthenticated\" error means the token was rejected. Try force refreshing it in case it\n // just expired.\n this.ru.zc(), \n // Clean up the underlying stream because we are no longer interested in events.\n null !== this.stream && (this.mu(), this.stream.close(), this.stream = null), \n // This state must be assigned before calling onClose() to allow the callback to\n // inhibit backoff or otherwise manipulate the state in its non-started state.\n this.state = e, [ 4 /*yield*/ , this.listener.Tu(n) ];\n\n case 1:\n // Cancel any outstanding timers (they're guaranteed not to execute).\n // Notify the listener that the stream closed.\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n }, \n /**\n * Can be overridden to perform additional cleanup before the stream is closed.\n * Calling super.tearDown() is not required.\n */\n e.prototype.mu = function() {}, e.prototype.auth = function() {\n var t = this;\n this.state = 1 /* Starting */;\n var e = this.Eu(this.ou), n = this.ou;\n // TODO(mikelehen): Just use dispatchIfNotClosed, but see TODO below.\n this.ru.getToken().then((function(e) {\n // Stream can be stopped while waiting for authentication.\n // TODO(mikelehen): We really should just use dispatchIfNotClosed\n // and let this dispatch onto the queue, but that opened a spec test can\n // of worms that I don't want to deal with in this PR.\n t.ou === n && \n // Normally we'd have to schedule the callback on the AsyncQueue.\n // However, the following calls are safe to be called outside the\n // AsyncQueue since they don't chain asynchronous calls\n t.Iu(e);\n }), (function(n) {\n e((function() {\n var e = new c(a.UNKNOWN, \"Fetching auth token failed: \" + n.message);\n return t.Au(e);\n }));\n }));\n }, e.prototype.Iu = function(t) {\n var e = this, n = this.Eu(this.ou);\n this.stream = this.Ru(t), this.stream.gu((function() {\n n((function() {\n return e.state = 2 /* Open */ , e.listener.gu();\n }));\n })), this.stream.Tu((function(t) {\n n((function() {\n return e.Au(t);\n }));\n })), this.stream.onMessage((function(t) {\n n((function() {\n return e.onMessage(t);\n }));\n }));\n }, e.prototype.hu = function() {\n var e = this;\n this.state = 4 /* Backoff */ , this.ys.gn((function() {\n return t.__awaiter(e, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n return this.state = 0 /* Initial */ , this.start(), [ 2 /*return*/ ];\n }));\n }));\n }));\n }, \n // Visible for tests\n e.prototype.Au = function(t) {\n // In theory the stream could close cleanly, however, in our current model\n // we never expect this to happen because if we stop a stream ourselves,\n // this callback will never be called. To prevent cases where we retry\n // without a backoff accidentally, we set the stream to error in all cases.\n return l(\"PersistentStream\", \"close with error: \" + t), this.stream = null, this.close(3 /* Error */ , t);\n }, \n /**\n * Returns a \"dispatcher\" function that dispatches operations onto the\n * AsyncQueue but only runs them if closeCount remains unchanged. This allows\n * us to turn auth / stream callbacks into no-ops if the stream is closed /\n * re-opened, etc.\n */\n e.prototype.Eu = function(t) {\n var e = this;\n return function(n) {\n e.fn.ws((function() {\n return e.ou === t ? n() : (l(\"PersistentStream\", \"stream callback skipped by getCloseGuardedDispatcher.\"), \n Promise.resolve());\n }));\n };\n }, e;\n}(), Co = /** @class */ function(e) {\n function n(t, n, r, i, o) {\n var s = this;\n return (s = e.call(this, t, \"listen_stream_connection_backoff\" /* ListenStreamConnectionBackoff */ , \"listen_stream_idle\" /* ListenStreamIdle */ , n, r, o) || this).serializer = i, \n s;\n }\n return t.__extends(n, e), n.prototype.Ru = function(t) {\n return this.iu.Pu(\"Listen\", t);\n }, n.prototype.onMessage = function(t) {\n // A successful response means the stream is healthy\n this.ys.reset();\n var e = function(t, e) {\n var n;\n if (\"targetChange\" in e) {\n e.targetChange;\n // proto3 default value is unset in JSON (undefined), so use 'NO_CHANGE'\n // if unset\n var r = function(t) {\n return \"NO_CHANGE\" === t ? 0 /* NoChange */ : \"ADD\" === t ? 1 /* Added */ : \"REMOVE\" === t ? 2 /* Removed */ : \"CURRENT\" === t ? 3 /* Current */ : \"RESET\" === t ? 4 /* Reset */ : y();\n }(e.targetChange.targetChangeType || \"NO_CHANGE\"), i = e.targetChange.targetIds || [], o = function(t, e) {\n return t.Qe ? (g(void 0 === e || \"string\" == typeof e), X.fromBase64String(e || \"\")) : (g(void 0 === e || e instanceof Uint8Array), \n X.fromUint8Array(e || new Uint8Array));\n }(t, e.targetChange.resumeToken), s = e.targetChange.cause, u = s && function(t) {\n var e = void 0 === t.code ? a.UNKNOWN : _t(t.code);\n return new c(e, t.message || \"\");\n }(s);\n n = new zt(r, i, o, u || null);\n } else if (\"documentChange\" in e) {\n e.documentChange;\n var h = e.documentChange;\n h.document, h.document.name, h.document.updateTime;\n var f = Se(t, h.document.name), l = Ee(h.document.updateTime), p = new Sn({\n mapValue: {\n fields: h.document.fields\n }\n }), d = new kn(f, l, p, {}), v = h.targetIds || [], m = h.removedTargetIds || [];\n n = new jt(v, m, d.key, d);\n } else if (\"documentDelete\" in e) {\n e.documentDelete;\n var w = e.documentDelete;\n w.document;\n var _ = Se(t, w.document), b = w.readTime ? Ee(w.readTime) : st.min(), I = new Rn(_, b), E = w.removedTargetIds || [];\n n = new jt([], E, I.key, I);\n } else if (\"documentRemove\" in e) {\n e.documentRemove;\n var T = e.documentRemove;\n T.document;\n var N = Se(t, T.document), A = T.removedTargetIds || [];\n n = new jt([], A, N, null);\n } else {\n if (!(\"filter\" in e)) return y();\n e.filter;\n var S = e.filter;\n S.targetId;\n var D = S.count || 0, x = new mt(D), L = S.targetId;\n n = new Gt(L, x);\n }\n return n;\n }(this.serializer, t), n = function(t) {\n // We have only reached a consistent snapshot for the entire stream if there\n // is a read_time set and it applies to all targets (i.e. the list of\n // targets is empty). The backend is guaranteed to send such responses.\n if (!(\"targetChange\" in t)) return st.min();\n var e = t.targetChange;\n return e.targetIds && e.targetIds.length ? st.min() : e.readTime ? Ee(e.readTime) : st.min();\n }(t);\n return this.listener.yu(e, n);\n }, \n /**\n * Registers interest in the results of the given target. If the target\n * includes a resumeToken it will be included in the request. Results that\n * affect the target will be streamed back as WatchChange messages that\n * reference the targetId.\n */\n n.prototype.Vu = function(t) {\n var e = {};\n e.database = Le(this.serializer), e.addTarget = function(t, e) {\n var n, r = e.target;\n return (n = dt(r) ? {\n documents: Ve(t, r)\n } : {\n query: Ue(t, r)\n }).targetId = e.targetId, e.resumeToken.O() > 0 && (n.resumeToken = be(t, e.resumeToken)), \n n;\n }(this.serializer, t);\n var n = function(t, e) {\n var n = function(t, e) {\n switch (e) {\n case 0 /* Listen */ :\n return null;\n\n case 1 /* ExistenceFilterMismatch */ :\n return \"existence-filter-mismatch\";\n\n case 2 /* LimboResolution */ :\n return \"limbo-document\";\n\n default:\n return y();\n }\n }(0, e.et);\n return null == n ? null : {\n \"goog-listen-tags\": n\n };\n }(this.serializer, t);\n n && (e.labels = n), this.du(e);\n }, \n /**\n * Unregisters interest in the results of the target associated with the\n * given targetId.\n */\n n.prototype.pu = function(t) {\n var e = {};\n e.database = Le(this.serializer), e.removeTarget = t, this.du(e);\n }, n;\n}(Uo), Fo = /** @class */ function(e) {\n function n(t, n, r, i, o) {\n var s = this;\n return (s = e.call(this, t, \"write_stream_connection_backoff\" /* WriteStreamConnectionBackoff */ , \"write_stream_idle\" /* WriteStreamIdle */ , n, r, o) || this).serializer = i, \n s.bu = !1, s;\n }\n return t.__extends(n, e), Object.defineProperty(n.prototype, \"vu\", {\n /**\n * Tracks whether or not a handshake has been successfully exchanged and\n * the stream is ready to accept mutations.\n */\n get: function() {\n return this.bu;\n },\n enumerable: !1,\n configurable: !0\n }), \n // Override of PersistentStream.start\n n.prototype.start = function() {\n this.bu = !1, this.lastStreamToken = void 0, e.prototype.start.call(this);\n }, n.prototype.mu = function() {\n this.bu && this.Su([]);\n }, n.prototype.Ru = function(t) {\n return this.iu.Pu(\"Write\", t);\n }, n.prototype.onMessage = function(t) {\n if (\n // Always capture the last stream token.\n g(!!t.streamToken), this.lastStreamToken = t.streamToken, this.bu) {\n // A successful first write response means the stream is healthy,\n // Note, that we could consider a successful handshake healthy, however,\n // the write itself might be causing an error we want to back off from.\n this.ys.reset();\n var e = function(t, e) {\n return t && t.length > 0 ? (g(void 0 !== e), t.map((function(t) {\n return function(t, e) {\n // NOTE: Deletes don't have an updateTime.\n var n = t.updateTime ? Ee(t.updateTime) : Ee(e);\n n.isEqual(st.min()) && (\n // The Firestore Emulator currently returns an update time of 0 for\n // deletes of non-existing documents (rather than null). This breaks the\n // test \"get deleted doc while offline with source=cache\" as NoDocuments\n // with version 0 are filtered by IndexedDb's RemoteDocumentCache.\n // TODO(#2149): Remove this when Emulator is fixed\n n = Ee(e));\n var r = null;\n return t.transformResults && t.transformResults.length > 0 && (r = t.transformResults), \n new hn(n, r);\n }(t, e);\n }))) : [];\n }(t.writeResults, t.commitTime), n = Ee(t.commitTime);\n return this.listener.Du(n, e);\n }\n // The first response is always the handshake response\n return g(!t.writeResults || 0 === t.writeResults.length), this.bu = !0, \n this.listener.Cu();\n }, \n /**\n * Sends an initial streamToken to the server, performing the handshake\n * required to make the StreamingWrite RPC work. Subsequent\n * calls should wait until onHandshakeComplete was called.\n */\n n.prototype.Nu = function() {\n // TODO(dimond): Support stream resumption. We intentionally do not set the\n // stream token on the handshake, ignoring any stream token we might have.\n var t = {};\n t.database = Le(this.serializer), this.du(t);\n }, \n /** Sends a group of mutations to the Firestore backend to apply. */ n.prototype.Su = function(t) {\n var e = this, n = {\n streamToken: this.lastStreamToken,\n writes: t.map((function(t) {\n return Oe(e.serializer, t);\n }))\n };\n this.du(n);\n }, n;\n}(Uo), Mo = /** @class */ function(e) {\n function n(t, n, r) {\n var i = this;\n return (i = e.call(this) || this).credentials = t, i.iu = n, i.serializer = r, i.Fu = !1, \n i;\n }\n return t.__extends(n, e), n.prototype.xu = function() {\n if (this.Fu) throw new c(a.FAILED_PRECONDITION, \"The client has already been terminated.\");\n }, \n /** Gets an auth token and invokes the provided RPC. */ n.prototype.$u = function(t, e, n) {\n var r = this;\n return this.xu(), this.credentials.getToken().then((function(i) {\n return r.iu.$u(t, e, n, i);\n })).catch((function(t) {\n throw t.code === a.UNAUTHENTICATED && r.credentials.zc(), t;\n }));\n }, \n /** Gets an auth token and invokes the provided RPC with streamed results. */ n.prototype.ku = function(t, e, n) {\n var r = this;\n return this.xu(), this.credentials.getToken().then((function(i) {\n return r.iu.ku(t, e, n, i);\n })).catch((function(t) {\n throw t.code === a.UNAUTHENTICATED && r.credentials.zc(), t;\n }));\n }, n.prototype.terminate = function() {\n this.Fu = !1;\n }, n;\n}((function() {})), qo = /** @class */ function() {\n function t(t, e) {\n this.cs = t, this.di = e, \n /** The current OnlineState. */\n this.state = \"Unknown\" /* Unknown */ , \n /**\n * A count of consecutive failures to open the stream. If it reaches the\n * maximum defined by MAX_WATCH_STREAM_FAILURES, we'll set the OnlineState to\n * Offline.\n */\n this.Mu = 0, \n /**\n * A timer that elapses after ONLINE_STATE_TIMEOUT_MS, at which point we\n * transition from OnlineState.Unknown to OnlineState.Offline without waiting\n * for the stream to actually fail (MAX_WATCH_STREAM_FAILURES times).\n */\n this.Ou = null, \n /**\n * Whether the client should log a warning message if it fails to connect to\n * the backend (initially true, cleared after a successful stream, or if we've\n * logged the message already).\n */\n this.Lu = !0\n /**\n * Called by RemoteStore when a watch stream is started (including on each\n * backoff attempt).\n *\n * If this is the first attempt, it sets the OnlineState to Unknown and starts\n * the onlineStateTimer.\n */;\n }\n return t.prototype.Bu = function() {\n var t = this;\n 0 === this.Mu && (this.qu(\"Unknown\" /* Unknown */), this.Ou = this.cs.yn(\"online_state_timeout\" /* OnlineStateTimeout */ , 1e4, (function() {\n return t.Ou = null, t.Uu(\"Backend didn't respond within 10 seconds.\"), t.qu(\"Offline\" /* Offline */), \n Promise.resolve();\n })));\n }, \n /**\n * Updates our OnlineState as appropriate after the watch stream reports a\n * failure. The first failure moves us to the 'Unknown' state. We then may\n * allow multiple failures (based on MAX_WATCH_STREAM_FAILURES) before we\n * actually transition to the 'Offline' state.\n */\n t.prototype.Qu = function(t) {\n \"Online\" /* Online */ === this.state ? this.qu(\"Unknown\" /* Unknown */) : (this.Mu++, \n this.Mu >= 1 && (this.Wu(), this.Uu(\"Connection failed 1 times. Most recent error: \" + t.toString()), \n this.qu(\"Offline\" /* Offline */)));\n }, \n /**\n * Explicitly sets the OnlineState to the specified state.\n *\n * Note that this resets our timers / failure counters, etc. used by our\n * Offline heuristics, so must not be used in place of\n * handleWatchStreamStart() and handleWatchStreamFailure().\n */\n t.prototype.set = function(t) {\n this.Wu(), this.Mu = 0, \"Online\" /* Online */ === t && (\n // We've connected to watch at least once. Don't warn the developer\n // about being offline going forward.\n this.Lu = !1), this.qu(t);\n }, t.prototype.qu = function(t) {\n t !== this.state && (this.state = t, this.di(t));\n }, t.prototype.Uu = function(t) {\n 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.\";\n this.Lu ? (p(e), this.Lu = !1) : l(\"OnlineStateTracker\", e);\n }, t.prototype.Wu = function() {\n null !== this.Ou && (this.Ou.cancel(), this.Ou = null);\n }, t;\n}(), jo = function(\n/**\n * The local store, used to fill the write pipeline with outbound mutations.\n */\ne, \n/** The client-side proxy for interacting with the backend. */\nn, r, i, o) {\n var s = this;\n this.ju = e, this.Ku = n, this.cs = r, this.Gu = {}, \n /**\n * A list of up to MAX_PENDING_WRITES writes that we have fetched from the\n * LocalStore via fillWritePipeline() and have or will send to the write\n * stream.\n *\n * Whenever writePipeline.length > 0 the RemoteStore will attempt to start or\n * restart the write stream. When the stream is established the writes in the\n * pipeline will be sent in order.\n *\n * Writes remain in writePipeline until they are acknowledged by the backend\n * and thus will automatically be re-sent if the stream is interrupted /\n * restarted before they're acknowledged.\n *\n * Write responses from the backend are linked to their originating request\n * purely based on order, and so we can just shift() writes from the front of\n * the writePipeline as we receive responses.\n */\n this.zu = [], \n /**\n * A mapping of watched targets that the client cares about tracking and the\n * user has explicitly called a 'listen' for this target.\n *\n * These targets may or may not have been sent to or acknowledged by the\n * server. On re-establishing the listen stream, these targets should be sent\n * to the server. The targets removed with unlistens are removed eagerly\n * without waiting for confirmation from the listen stream.\n */\n this.Hu = new Map, \n /**\n * A set of reasons for why the RemoteStore may be offline. If empty, the\n * RemoteStore may start its network connections.\n */\n this.Yu = new Set, \n /**\n * Event handlers that get called when the network is disabled or enabled.\n *\n * PORTING NOTE: These functions are used on the Web client to create the\n * underlying streams (to support tree-shakeable streams). On Android and iOS,\n * the streams are created during construction of RemoteStore.\n */\n this.Ju = [], this.Xu = o, this.Xu.Zu((function(e) {\n r.ws((function() {\n return t.__awaiter(s, void 0, void 0, (function() {\n return t.__generator(this, (function(e) {\n switch (e.label) {\n case 0:\n return Xo(this) ? (l(\"RemoteStore\", \"Restarting streams for network reachability change.\"), \n [ 4 /*yield*/ , function(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return (n = m(e)).Yu.add(4 /* ConnectivityChange */), [ 4 /*yield*/ , zo(n) ];\n\n case 1:\n return t.sent(), n.th.set(\"Unknown\" /* Unknown */), n.Yu.delete(4 /* ConnectivityChange */), \n [ 4 /*yield*/ , Go(n) ];\n\n case 2:\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n }(this) ]) : [ 3 /*break*/ , 2 ];\n\n case 1:\n e.sent(), e.label = 2;\n\n case 2:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }));\n })), this.th = new qo(r, i);\n};\n\nfunction Go(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n, r;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n if (!Xo(e)) return [ 3 /*break*/ , 4 ];\n n = 0, r = e.Ju, t.label = 1;\n\n case 1:\n return n < r.length ? [ 4 /*yield*/ , (0, r[n])(/* enabled= */ !0) ] : [ 3 /*break*/ , 4 ];\n\n case 2:\n t.sent(), t.label = 3;\n\n case 3:\n return n++, [ 3 /*break*/ , 1 ];\n\n case 4:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/**\n * Temporarily disables the network. The network can be re-enabled using\n * enableNetwork().\n */ function zo(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n, r;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n n = 0, r = e.Ju, t.label = 1;\n\n case 1:\n return n < r.length ? [ 4 /*yield*/ , (0, r[n])(/* enabled= */ !1) ] : [ 3 /*break*/ , 4 ];\n\n case 2:\n t.sent(), t.label = 3;\n\n case 3:\n return n++, [ 3 /*break*/ , 1 ];\n\n case 4:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\nfunction Bo(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return n = m(e), l(\"RemoteStore\", \"RemoteStore shutting down.\"), n.Yu.add(5 /* Shutdown */), \n [ 4 /*yield*/ , zo(n) ];\n\n case 1:\n return t.sent(), n.Xu.Di(), \n // Set the OnlineState to Unknown (rather than Offline) to avoid potentially\n // triggering spurious listener events with cached data, etc.\n n.th.set(\"Unknown\" /* Unknown */), [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/**\n * Starts new listen for the given target. Uses resume token if provided. It\n * is a no-op if the target of given `TargetData` is already being listened to.\n */ function Wo(t, e) {\n var n = m(t);\n n.Hu.has(e.targetId) || (\n // Mark this as something the client is currently listening for.\n n.Hu.set(e.targetId, e), $o(n) ? \n // The listen will be sent in onWatchStreamOpen\n Yo(n) : ls(n).uu() && Qo(n, e));\n}\n\n/**\n * Removes the listen from server. It is a no-op if the given target id is\n * not being listened to.\n */ function Ko(t, e) {\n var n = m(t), r = ls(n);\n n.Hu.delete(e), r.uu() && Ho(n, e), 0 === n.Hu.size && (r.uu() ? r._u() : Xo(n) && \n // Revert to OnlineState.Unknown if the watch stream is not open and we\n // have no listeners, since without any listens to send we cannot\n // confirm if the stream is healthy and upgrade to OnlineState.Online.\n n.th.set(\"Unknown\" /* Unknown */));\n}\n\n/**\n * We need to increment the the expected number of pending responses we're due\n * from watch so we wait for the ack to process any messages from this target.\n */ function Qo(t, e) {\n t.eh.Ie(e.targetId), ls(t).Vu(e)\n /**\n * We need to increment the expected number of pending responses we're due\n * from watch so we wait for the removal on the server before we process any\n * messages from this target.\n */;\n}\n\nfunction Ho(t, e) {\n t.eh.Ie(e), ls(t).pu(e);\n}\n\nfunction Yo(t) {\n t.eh = new Wt({\n qe: function(e) {\n return t.Gu.qe(e);\n },\n Ue: function(e) {\n return t.Hu.get(e) || null;\n }\n }), ls(t).start(), t.th.Bu()\n /**\n * Returns whether the watch stream should be started because it's necessary\n * and has not yet been started.\n */;\n}\n\nfunction $o(t) {\n return Xo(t) && !ls(t).cu() && t.Hu.size > 0;\n}\n\nfunction Xo(t) {\n return 0 === m(t).Yu.size;\n}\n\nfunction Jo(t) {\n t.eh = void 0;\n}\n\nfunction Zo(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n return e.Hu.forEach((function(t, n) {\n Qo(e, t);\n })), [ 2 /*return*/ ];\n }));\n }));\n}\n\nfunction ts(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n return Jo(e), \n // If we still need the watch stream, retry the connection.\n $o(e) ? (e.th.Qu(n), Yo(e)) : \n // No need to restart watch stream because there are no active targets.\n // The online state is set to unknown because there is no active attempt\n // at establishing a connection\n e.th.set(\"Unknown\" /* Unknown */), [ 2 /*return*/ ];\n }));\n }));\n}\n\nfunction es(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var i, o, s;\n return t.__generator(this, (function(u) {\n switch (u.label) {\n case 0:\n if (e.th.set(\"Online\" /* Online */), !(n instanceof zt && 2 /* Removed */ === n.state && n.cause)) \n // Mark the client as online since we got a message from the server\n return [ 3 /*break*/ , 6 ];\n u.label = 1;\n\n case 1:\n return u.trys.push([ 1, 3, , 5 ]), [ 4 /*yield*/ , \n /** Handles an error on a target */\n function(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o, s;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n r = n.cause, i = 0, o = n.targetIds, t.label = 1;\n\n case 1:\n return i < o.length ? (s = o[i], e.Hu.has(s) ? [ 4 /*yield*/ , e.Gu.nh(s, r) ] : [ 3 /*break*/ , 3 ]) : [ 3 /*break*/ , 5 ];\n\n case 2:\n t.sent(), e.Hu.delete(s), e.eh.removeTarget(s), t.label = 3;\n\n case 3:\n t.label = 4;\n\n case 4:\n return i++, [ 3 /*break*/ , 1 ];\n\n case 5:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }(e, n) ];\n\n case 2:\n return u.sent(), [ 3 /*break*/ , 5 ];\n\n case 3:\n return i = u.sent(), l(\"RemoteStore\", \"Failed to remove targets %s: %s \", n.targetIds.join(\",\"), i), \n [ 4 /*yield*/ , ns(e, i) ];\n\n case 4:\n return u.sent(), [ 3 /*break*/ , 5 ];\n\n case 5:\n return [ 3 /*break*/ , 13 ];\n\n case 6:\n if (n instanceof jt ? e.eh.be(n) : n instanceof Gt ? e.eh.$e(n) : e.eh.De(n), r.isEqual(st.min())) return [ 3 /*break*/ , 13 ];\n u.label = 7;\n\n case 7:\n return u.trys.push([ 7, 11, , 13 ]), [ 4 /*yield*/ , wo(e.ju) ];\n\n case 8:\n return o = u.sent(), r.L(o) >= 0 ? [ 4 /*yield*/ , \n /**\n * Takes a batch of changes from the Datastore, repackages them as a\n * RemoteEvent, and passes that on to the listener, which is typically the\n * SyncEngine.\n */\n function(t, e) {\n var n = t.eh.Oe(e);\n // Update in-memory resume tokens. LocalStore will update the\n // persistent view of these when applying the completed RemoteEvent.\n return n.zt.forEach((function(n, r) {\n if (n.resumeToken.O() > 0) {\n var i = t.Hu.get(r);\n // A watched target might have been removed already.\n i && t.Hu.set(r, i.it(n.resumeToken, e));\n }\n })), \n // Re-establish listens for the targets that have been invalidated by\n // existence filter mismatches.\n n.Ht.forEach((function(e) {\n var n = t.Hu.get(e);\n if (n) {\n // Clear the resume token for the target, since we're in a known mismatch\n // state.\n t.Hu.set(e, n.it(X.B, n.nt)), \n // Cause a hard reset by unwatching and rewatching immediately, but\n // deliberately don't send a resume token so that we get a full update.\n Ho(t, e);\n // Mark the target we send as being on behalf of an existence filter\n // mismatch, but don't actually retain that in listenTargets. This ensures\n // that we flag the first re-listen this way without impacting future\n // listens of this target (that might happen e.g. on reconnect).\n var r = new gt(n.target, e, 1 /* ExistenceFilterMismatch */ , n.sequenceNumber);\n Qo(t, r);\n }\n })), t.Gu.sh(n);\n }(e, r) ] : [ 3 /*break*/ , 10 ];\n\n // We have received a target change with a global snapshot if the snapshot\n // version is not equal to SnapshotVersion.min().\n case 9:\n // We have received a target change with a global snapshot if the snapshot\n // version is not equal to SnapshotVersion.min().\n u.sent(), u.label = 10;\n\n case 10:\n return [ 3 /*break*/ , 13 ];\n\n case 11:\n return l(\"RemoteStore\", \"Failed to raise snapshot:\", s = u.sent()), [ 4 /*yield*/ , ns(e, s) ];\n\n case 12:\n return u.sent(), [ 3 /*break*/ , 13 ];\n\n case 13:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/**\n * Recovery logic for IndexedDB errors that takes the network offline until\n * `op` succeeds. Retries are scheduled with backoff using\n * `enqueueRetryable()`. If `op()` is not provided, IndexedDB access is\n * validated via a generic operation.\n *\n * The returned Promise is resolved once the network is disabled and before\n * any retry attempt.\n */ function ns(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var i = this;\n return t.__generator(this, (function(o) {\n switch (o.label) {\n case 0:\n if (!_r(n)) throw n;\n // Disable network and raise offline snapshots\n return e.Yu.add(1 /* IndexedDbFailed */), [ 4 /*yield*/ , zo(e) ];\n\n case 1:\n // Disable network and raise offline snapshots\n return o.sent(), e.th.set(\"Offline\" /* Offline */), r || (\n // Use a simple read operation to determine if IndexedDB recovered.\n // Ideally, we would expose a health check directly on SimpleDb, but\n // RemoteStore only has access to persistence through LocalStore.\n r = function() {\n return wo(e.ju);\n }), \n // Probe IndexedDB periodically and re-enable network\n e.cs.Cs((function() {\n return t.__awaiter(i, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return l(\"RemoteStore\", \"Retrying IndexedDB access\"), [ 4 /*yield*/ , r() ];\n\n case 1:\n return t.sent(), e.Yu.delete(1 /* IndexedDbFailed */), [ 4 /*yield*/ , Go(e) ];\n\n case 2:\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n })), [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/**\n * Executes `op`. If `op` fails, takes the network offline until `op`\n * succeeds. Returns after the first attempt.\n */ function rs(t, e) {\n return e().catch((function(n) {\n return ns(t, n, e);\n }));\n}\n\nfunction is(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n, r, i, o, s;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n n = m(e), r = ps(n), i = n.zu.length > 0 ? n.zu[n.zu.length - 1].batchId : -1, t.label = 1;\n\n case 1:\n if (!\n /**\n * Returns true if we can add to the write pipeline (i.e. the network is\n * enabled and the write pipeline is not full).\n */\n function(t) {\n return Xo(t) && t.zu.length < 10;\n }\n /**\n * Queues additional writes to be sent to the write stream, sending them\n * immediately if the write stream is established.\n */ (n)) return [ 3 /*break*/ , 7 ];\n t.label = 2;\n\n case 2:\n return t.trys.push([ 2, 4, , 6 ]), [ 4 /*yield*/ , bo(n.ju, i) ];\n\n case 3:\n return null === (o = t.sent()) ? (0 === n.zu.length && r._u(), [ 3 /*break*/ , 7 ]) : (i = o.batchId, \n function(t, e) {\n t.zu.push(e);\n var n = ps(t);\n n.uu() && n.vu && n.Su(e.mutations);\n }(n, o), [ 3 /*break*/ , 6 ]);\n\n case 4:\n return s = t.sent(), [ 4 /*yield*/ , ns(n, s) ];\n\n case 5:\n return t.sent(), [ 3 /*break*/ , 6 ];\n\n case 6:\n return [ 3 /*break*/ , 1 ];\n\n case 7:\n return os(n) && ss(n), [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\nfunction os(t) {\n return Xo(t) && !ps(t).cu() && t.zu.length > 0;\n}\n\nfunction ss(t) {\n ps(t).start();\n}\n\nfunction us(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n return ps(e).Nu(), [ 2 /*return*/ ];\n }));\n }));\n}\n\nfunction as(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n, r, i, o;\n return t.__generator(this, (function(t) {\n // Send the write pipeline now that the stream is established.\n for (n = ps(e), r = 0, i = e.zu; r < i.length; r++) o = i[r], n.Su(o.mutations);\n return [ 2 /*return*/ ];\n }));\n }));\n}\n\nfunction cs(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var i, o;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return i = e.zu.shift(), o = Jr.from(i, n, r), [ 4 /*yield*/ , rs(e, (function() {\n return e.Gu.ih(o);\n })) ];\n\n case 1:\n // It's possible that with the completion of this mutation another\n // slot has freed up.\n return t.sent(), [ 4 /*yield*/ , is(e) ];\n\n case 2:\n // It's possible that with the completion of this mutation another\n // slot has freed up.\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\nfunction hs(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(r) {\n switch (r.label) {\n case 0:\n return n && ps(e).vu ? [ 4 /*yield*/ , function(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return wt(i = n.code) && i !== a.ABORTED ? (r = e.zu.shift(), \n // In this case it's also unlikely that the server itself is melting\n // down -- this was just a bad request so inhibit backoff on the next\n // restart.\n ps(e).lu(), [ 4 /*yield*/ , rs(e, (function() {\n return e.Gu.rh(r.batchId, n);\n })) ]) : [ 3 /*break*/ , 3 ];\n\n case 1:\n // It's possible that with the completion of this mutation\n // another slot has freed up.\n return t.sent(), [ 4 /*yield*/ , is(e) ];\n\n case 2:\n // In this case it's also unlikely that the server itself is melting\n // down -- this was just a bad request so inhibit backoff on the next\n // restart.\n // It's possible that with the completion of this mutation\n // another slot has freed up.\n t.sent(), t.label = 3;\n\n case 3:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }(e, n) ] : [ 3 /*break*/ , 2 ];\n\n // This error affects the actual write.\n case 1:\n // This error affects the actual write.\n r.sent(), r.label = 2;\n\n case 2:\n // If the write stream closed after the write handshake completes, a write\n // operation failed and we fail the pending operation.\n // The write stream might have been started by refilling the write\n // pipeline for failed writes\n return os(e) && ss(e), [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/**\n * Toggles the network state when the client gains or loses its primary lease.\n */ function fs(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return r = m(e), n ? (r.Yu.delete(2 /* IsSecondary */), [ 4 /*yield*/ , Go(r) ]) : [ 3 /*break*/ , 2 ];\n\n case 1:\n return t.sent(), [ 3 /*break*/ , 5 ];\n\n case 2:\n return (i = n) ? [ 3 /*break*/ , 4 ] : (r.Yu.add(2 /* IsSecondary */), [ 4 /*yield*/ , zo(r) ]);\n\n case 3:\n t.sent(), i = r.th.set(\"Unknown\" /* Unknown */), t.label = 4;\n\n case 4:\n i, t.label = 5;\n\n case 5:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/**\n * If not yet initialized, registers the WatchStream and its network state\n * callback with `remoteStoreImpl`. Returns the existing stream if one is\n * already available.\n *\n * PORTING NOTE: On iOS and Android, the WatchStream gets registered on startup.\n * This is not done on Web to allow it to be tree-shaken.\n */ function ls(e) {\n var n = this;\n return e.oh || (\n // Create stream (but note that it is not started yet).\n e.oh = function(t, e, n) {\n var r = m(t);\n return r.xu(), new Co(e, r.iu, r.credentials, r.serializer, n);\n }(e.Ku, e.cs, {\n gu: Zo.bind(null, e),\n Tu: ts.bind(null, e),\n yu: es.bind(null, e)\n }), e.Ju.push((function(r) {\n return t.__awaiter(n, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return r ? (e.oh.lu(), $o(e) ? Yo(e) : e.th.set(\"Unknown\" /* Unknown */), [ 3 /*break*/ , 3 ]) : [ 3 /*break*/ , 1 ];\n\n case 1:\n return [ 4 /*yield*/ , e.oh.stop() ];\n\n case 2:\n t.sent(), Jo(e), t.label = 3;\n\n case 3:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }))), e.oh\n /**\n * If not yet initialized, registers the WriteStream and its network state\n * callback with `remoteStoreImpl`. Returns the existing stream if one is\n * already available.\n *\n * PORTING NOTE: On iOS and Android, the WriteStream gets registered on startup.\n * This is not done on Web to allow it to be tree-shaken.\n */;\n}\n\nfunction ps(e) {\n var n = this;\n return e.ah || (\n // Create stream (but note that it is not started yet).\n e.ah = function(t, e, n) {\n var r = m(t);\n return r.xu(), new Fo(e, r.iu, r.credentials, r.serializer, n);\n }(e.Ku, e.cs, {\n gu: us.bind(null, e),\n Tu: hs.bind(null, e),\n Cu: as.bind(null, e),\n Du: cs.bind(null, e)\n }), e.Ju.push((function(r) {\n return t.__awaiter(n, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return r ? (e.ah.lu(), [ 4 /*yield*/ , is(e) ]) : [ 3 /*break*/ , 2 ];\n\n case 1:\n // This will start the write stream if necessary.\n return t.sent(), [ 3 /*break*/ , 4 ];\n\n case 2:\n return [ 4 /*yield*/ , e.ah.stop() ];\n\n case 3:\n t.sent(), e.zu.length > 0 && (l(\"RemoteStore\", \"Stopping write stream with \" + e.zu.length + \" pending writes\"), \n e.zu = []), t.label = 4;\n\n case 4:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }))), e.ah\n /**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */;\n}\n\nvar ds = function(t) {\n this.key = t;\n}, vs = function(t) {\n this.key = t;\n}, ys = /** @class */ function() {\n function t(t, \n /** Documents included in the remote target */\n e) {\n this.query = t, this.uh = e, this.hh = null, \n /**\n * A flag whether the view is current with the backend. A view is considered\n * current after it has seen the current flag from the backend and did not\n * lose consistency within the watch stream (e.g. because of an existence\n * filter mismatch).\n */\n this.te = !1, \n /** Documents in the view but not in the remote target */\n this.lh = Ot(), \n /** Document Keys that have local changes */\n this.Wt = Ot(), this._h = Xn(t), this.fh = new Ut(this._h);\n }\n return Object.defineProperty(t.prototype, \"dh\", {\n /**\n * The set of remote documents that the server has told us belongs to the target associated with\n * this view.\n */\n get: function() {\n return this.uh;\n },\n enumerable: !1,\n configurable: !0\n }), \n /**\n * Iterates over a set of doc changes, applies the query limit, and computes\n * what the new results should be, what the changes were, and whether we may\n * need to go back to the local cache for more results. Does not make any\n * changes to the view.\n * @param docChanges The doc changes to apply to this view.\n * @param previousChanges If this is being called with a refill, then start\n * with this set of docs and changes instead of the current view.\n * @return a new set of docs, changes, and refill flag.\n */\n t.prototype.wh = function(t, e) {\n var n = this, r = e ? e.mh : new Ct, i = e ? e.fh : this.fh, o = e ? e.Wt : this.Wt, s = i, u = !1, a = Cn(this.query) && i.size === this.query.limit ? i.last() : null, c = Fn(this.query) && i.size === this.query.limit ? i.first() : null;\n // Drop documents out to meet limit/limitToLast requirement.\n if (t.ht((function(t, e) {\n var h = i.get(t), f = e instanceof kn ? e : null;\n f && (f = $n(n.query, f) ? f : null);\n var l = !!h && n.Wt.has(h.key), p = !!f && (f.Je || \n // We only consider committed mutations for documents that were\n // mutated during the lifetime of the view.\n n.Wt.has(f.key) && f.hasCommittedMutations), d = !1;\n // Calculate change\n h && f ? h.data().isEqual(f.data()) ? l !== p && (r.track({\n type: 3 /* Metadata */ ,\n doc: f\n }), d = !0) : n.Th(h, f) || (r.track({\n type: 2 /* Modified */ ,\n doc: f\n }), d = !0, (a && n._h(f, a) > 0 || c && n._h(f, c) < 0) && (\n // This doc moved from inside the limit to outside the limit.\n // That means there may be some other doc in the local cache\n // that should be included instead.\n u = !0)) : !h && f ? (r.track({\n type: 0 /* Added */ ,\n doc: f\n }), d = !0) : h && !f && (r.track({\n type: 1 /* Removed */ ,\n doc: h\n }), d = !0, (a || c) && (\n // A doc was removed from a full limit query. We'll need to\n // requery from the local cache to see if we know about some other\n // doc that should be in the results.\n u = !0)), d && (f ? (s = s.add(f), o = p ? o.add(t) : o.delete(t)) : (s = s.delete(t), \n o = o.delete(t)));\n })), Cn(this.query) || Fn(this.query)) for (;s.size > this.query.limit; ) {\n var h = Cn(this.query) ? s.last() : s.first();\n s = s.delete(h.key), o = o.delete(h.key), r.track({\n type: 1 /* Removed */ ,\n doc: h\n });\n }\n return {\n fh: s,\n mh: r,\n Eh: u,\n Wt: o\n };\n }, t.prototype.Th = function(t, e) {\n // We suppress the initial change event for documents that were modified as\n // part of a write acknowledgment (e.g. when the value of a server transform\n // is applied) as Watch will send us the same document again.\n // By suppressing the event, we only raise two user visible events (one with\n // `hasPendingWrites` and the final state of the document) instead of three\n // (one with `hasPendingWrites`, the modified document with\n // `hasPendingWrites` and the final state of the document).\n return t.Je && e.hasCommittedMutations && !e.Je;\n }, \n /**\n * Updates the view with the given ViewDocumentChanges and optionally updates\n * limbo docs and sync state from the provided target change.\n * @param docChanges The set of changes to make to the view's docs.\n * @param updateLimboDocuments Whether to update limbo documents based on this\n * change.\n * @param targetChange A target change to apply for computing limbo docs and\n * sync state.\n * @return A new ViewChange with the given docs, changes, and sync state.\n */\n // PORTING NOTE: The iOS/Android clients always compute limbo document changes.\n t.prototype.yr = function(t, e, n) {\n var r = this, i = this.fh;\n this.fh = t.fh, this.Wt = t.Wt;\n // Sort changes based on type and query comparator\n var o = t.mh.Ut();\n o.sort((function(t, e) {\n return function(t, e) {\n var n = function(t) {\n switch (t) {\n case 0 /* Added */ :\n return 1;\n\n case 2 /* Modified */ :\n case 3 /* Metadata */ :\n // A metadata change is converted to a modified change at the public\n // api layer. Since we sort by document key and then change type,\n // metadata and modified changes must be sorted equivalently.\n return 2;\n\n case 1 /* Removed */ :\n return 0;\n\n default:\n return y();\n }\n };\n return n(t) - n(e);\n }(t.type, e.type) || r._h(t.doc, e.doc);\n })), this.Ih(n);\n var s = e ? this.Ah() : [], u = 0 === this.lh.size && this.te ? 1 /* Synced */ : 0 /* Local */ , a = u !== this.hh;\n return this.hh = u, 0 !== o.length || a ? {\n snapshot: new Ft(this.query, t.fh, i, o, t.Wt, 0 /* Local */ === u, a, \n /* excludesMetadataChanges= */ !1),\n Rh: s\n } : {\n Rh: s\n };\n // no changes\n }, \n /**\n * Applies an OnlineState change to the view, potentially generating a\n * ViewChange if the view's syncState changes as a result.\n */\n t.prototype.Qs = function(t) {\n return this.te && \"Offline\" /* Offline */ === t ? (\n // If we're offline, set `current` to false and then call applyChanges()\n // to refresh our syncState and generate a ViewChange as appropriate. We\n // are guaranteed to get a new TargetChange that sets `current` back to\n // true once the client is back online.\n this.te = !1, this.yr({\n fh: this.fh,\n mh: new Ct,\n Wt: this.Wt,\n Eh: !1\n }, \n /* updateLimboDocuments= */ !1)) : {\n Rh: []\n };\n }, \n /**\n * Returns whether the doc for the given key should be in limbo.\n */\n t.prototype.gh = function(t) {\n // If the remote end says it's part of this query, it's not in limbo.\n return !this.uh.has(t) && \n // The local store doesn't think it's a result, so it shouldn't be in limbo.\n !!this.fh.has(t) && !this.fh.get(t).Je;\n }, \n /**\n * Updates syncedDocuments, current, and limbo docs based on the given change.\n * Returns the list of changes to which docs are in limbo.\n */\n t.prototype.Ih = function(t) {\n var e = this;\n t && (t.ee.forEach((function(t) {\n return e.uh = e.uh.add(t);\n })), t.ne.forEach((function(t) {})), t.se.forEach((function(t) {\n return e.uh = e.uh.delete(t);\n })), this.te = t.te);\n }, t.prototype.Ah = function() {\n var t = this;\n // We can only determine limbo documents when we're in-sync with the server.\n if (!this.te) return [];\n // TODO(klimt): Do this incrementally so that it's not quadratic when\n // updating many documents.\n var e = this.lh;\n this.lh = Ot(), this.fh.forEach((function(e) {\n t.gh(e.key) && (t.lh = t.lh.add(e.key));\n }));\n // Diff the new limbo docs with the old limbo docs.\n var n = [];\n return e.forEach((function(e) {\n t.lh.has(e) || n.push(new vs(e));\n })), this.lh.forEach((function(t) {\n e.has(t) || n.push(new ds(t));\n })), n;\n }, \n /**\n * Update the in-memory state of the current view with the state read from\n * persistence.\n *\n * We update the query view whenever a client's primary status changes:\n * - When a client transitions from primary to secondary, it can miss\n * LocalStorage updates and its query views may temporarily not be\n * synchronized with the state on disk.\n * - For secondary to primary transitions, the client needs to update the list\n * of `syncedDocuments` since secondary clients update their query views\n * based purely on synthesized RemoteEvents.\n *\n * @param queryResult.documents - The documents that match the query according\n * to the LocalStore.\n * @param queryResult.remoteKeys - The keys of the documents that match the\n * query according to the backend.\n *\n * @return The ViewChange that resulted from this synchronization.\n */\n // PORTING NOTE: Multi-tab only.\n t.prototype.Ph = function(t) {\n this.uh = t.Fc, this.lh = Ot();\n var e = this.wh(t.documents);\n return this.yr(e, /*updateLimboDocuments=*/ !0);\n }, \n /**\n * Returns a view snapshot as if this query was just listened to. Contains\n * a document add for every existing document and the `fromCache` and\n * `hasPendingWrites` status of the already established view.\n */\n // PORTING NOTE: Multi-tab only.\n t.prototype.yh = function() {\n return Ft.Gt(this.query, this.fh, this.Wt, 0 /* Local */ === this.hh);\n }, t;\n}(), gs = function(\n/**\n * The query itself.\n */\nt, \n/**\n * The target number created by the client that is used in the watch\n * stream to identify this query.\n */\ne, \n/**\n * The view is responsible for computing the final merged truth of what\n * docs are in the query. It gets notified of local and remote changes,\n * and applies the query filters and limits to determine the most correct\n * possible results.\n */\nn) {\n this.query = t, this.targetId = e, this.view = n;\n}, ms = function(t) {\n this.key = t, \n /**\n * Set to true once we've received a document. This is used in\n * getRemoteKeysForTarget() and ultimately used by WatchChangeAggregator to\n * decide whether it needs to manufacture a delete event for the target once\n * the target is CURRENT.\n */\n this.Vh = !1;\n}, ws = /** @class */ function() {\n function t(t, e, n, \n // PORTING NOTE: Manages state synchronization in multi-tab environments.\n r, i, o) {\n this.ju = t, this.ph = e, this.bh = n, this.Sh = r, this.currentUser = i, this.Dh = o, \n this.Ch = {}, this.Nh = new it((function(t) {\n return Hn(t);\n }), Qn), this.Fh = new Map, \n /**\n * The keys of documents that are in limbo for which we haven't yet started a\n * limbo resolution query.\n */\n this.xh = [], \n /**\n * Keeps track of the target ID for each document that is in limbo with an\n * active target.\n */\n this.$h = new bt(A.i), \n /**\n * Keeps track of the information about an active limbo resolution for each\n * active target ID that was started for the purpose of limbo resolution.\n */\n this.kh = new Map, this.Mh = new xo, \n /** Stores user completion handlers, indexed by User and BatchId. */\n this.Oh = {}, \n /** Stores user callbacks waiting for all pending writes to be acknowledged. */\n this.Lh = new Map, this.Bh = ro.da(), this.onlineState = \"Unknown\" /* Unknown */ , \n // The primary state is set to `true` or `false` immediately after Firestore\n // startup. In the interim, a client should only be considered primary if\n // `isPrimary` is true.\n this.qh = void 0;\n }\n return Object.defineProperty(t.prototype, \"Uh\", {\n get: function() {\n return !0 === this.qh;\n },\n enumerable: !1,\n configurable: !0\n }), t;\n}();\n\n/**\n * Initiates the new listen, resolves promise when listen enqueued to the\n * server. All the subsequent view snapshots or errors are sent to the\n * subscribed handlers. Returns the initial snapshot.\n */\nfunction _s(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o, s, u, a;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return r = Ks(e), (s = r.Nh.get(n)) ? (\n // PORTING NOTE: With Multi-Tab Web, it is possible that a query view\n // already exists when EventManager calls us for the first time. This\n // happens when the primary tab is already listening to this query on\n // behalf of another tab and the user of the primary also starts listening\n // to the query. EventManager will not have an assigned target ID in this\n // case and calls `listen` to obtain this ID.\n i = s.targetId, r.Sh.Oi(i), o = s.view.yh(), [ 3 /*break*/ , 4 ]) : [ 3 /*break*/ , 1 ];\n\n case 1:\n return [ 4 /*yield*/ , Io(r.ju, zn(n)) ];\n\n case 2:\n return u = t.sent(), a = r.Sh.Oi(u.targetId), i = u.targetId, [ 4 /*yield*/ , bs(r, n, i, \"current\" === a) ];\n\n case 3:\n o = t.sent(), r.Uh && Wo(r.ph, u), t.label = 4;\n\n case 4:\n return [ 2 /*return*/ , o ];\n }\n }));\n }));\n}\n\n/**\n * Registers a view for a previously unknown query and computes its initial\n * snapshot.\n */ function bs(e, n, r, i) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var o, s, u, a, c, h;\n return t.__generator(this, (function(f) {\n switch (f.label) {\n case 0:\n // PORTING NOTE: On Web only, we inject the code that registers new Limbo\n // targets based on view changes. This allows us to only depend on Limbo\n // changes when user code includes queries.\n return e.Qh = function(n, r, i) {\n return function(e, n, r, i) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var o, s, u;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return o = n.view.wh(r), o.Eh ? [ 4 /*yield*/ , To(e.ju, n.query, \n /* usePreviousResults= */ !1).then((function(t) {\n var e = t.documents;\n return n.view.wh(e, o);\n })) ] : [ 3 /*break*/ , 2 ];\n\n case 1:\n // The query has a limit and some docs were removed, so we need\n // to re-run the query against the local store to make sure we\n // didn't lose any good docs that had been past the limit.\n o = t.sent(), t.label = 2;\n\n case 2:\n return s = i && i.zt.get(n.targetId), u = n.view.yr(o, \n /* updateLimboDocuments= */ e.Uh, s), [ 2 /*return*/ , (Rs(e, n.targetId, u.Rh), \n u.snapshot) ];\n }\n }));\n }));\n }(e, n, r, i);\n }, [ 4 /*yield*/ , To(e.ju, n, \n /* usePreviousResults= */ !0) ];\n\n case 1:\n return o = f.sent(), s = new ys(n, o.Fc), u = s.wh(o.documents), a = qt.Zt(r, i && \"Offline\" /* Offline */ !== e.onlineState), \n c = s.yr(u, \n /* updateLimboDocuments= */ e.Uh, a), Rs(e, r, c.Rh), h = new gs(n, r, s), [ 2 /*return*/ , (e.Nh.set(n, h), \n e.Fh.has(r) ? e.Fh.get(r).push(n) : e.Fh.set(r, [ n ]), c.snapshot) ];\n }\n }));\n }));\n}\n\n/** Stops listening to the query. */ function Is(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return r = m(e), i = r.Nh.get(n), (o = r.Fh.get(i.targetId)).length > 1 ? [ 2 /*return*/ , (r.Fh.set(i.targetId, o.filter((function(t) {\n return !Qn(t, n);\n }))), void r.Nh.delete(n)) ] : r.Uh ? (\n // We need to remove the local query target first to allow us to verify\n // whether any other client is still interested in this target.\n r.Sh.Bi(i.targetId), r.Sh.Fi(i.targetId) ? [ 3 /*break*/ , 2 ] : [ 4 /*yield*/ , Eo(r.ju, i.targetId, \n /*keepPersistedTargetData=*/ !1).then((function() {\n r.Sh.Ui(i.targetId), Ko(r.ph, i.targetId), Ls(r, i.targetId);\n })).catch(Do) ]) : [ 3 /*break*/ , 3 ];\n\n case 1:\n t.sent(), t.label = 2;\n\n case 2:\n return [ 3 /*break*/ , 5 ];\n\n case 3:\n return Ls(r, i.targetId), [ 4 /*yield*/ , Eo(r.ju, i.targetId, \n /*keepPersistedTargetData=*/ !0) ];\n\n case 4:\n t.sent(), t.label = 5;\n\n case 5:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/**\n * Initiates the write of local mutation batch which involves adding the\n * writes to the mutation queue, notifying the remote store about new\n * mutations and raising events for any changes this write caused.\n *\n * The promise returned by this call is resolved when the above steps\n * have completed, *not* when the write was acked by the backend. The\n * userCallback is resolved once the write was acked/rejected by the\n * backend (or failed locally for any other reason).\n */\n/**\n * Applies one remote event to the sync engine, notifying any views of the\n * changes, and releasing any pending mutation batches that would become\n * visible because of the snapshot version the remote event contains.\n */\nfunction Es(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n r = m(e), t.label = 1;\n\n case 1:\n return t.trys.push([ 1, 4, , 6 ]), [ 4 /*yield*/ , _o(r.ju, n) ];\n\n case 2:\n return i = t.sent(), \n // Update `receivedDocument` as appropriate for any limbo targets.\n n.zt.forEach((function(t, e) {\n var n = r.kh.get(e);\n n && (\n // Since this is a limbo resolution lookup, it's for a single document\n // and it could be added, modified, or removed, but not a combination.\n g(t.ee.size + t.ne.size + t.se.size <= 1), t.ee.size > 0 ? n.Vh = !0 : t.ne.size > 0 ? g(n.Vh) : t.se.size > 0 && (g(n.Vh), \n n.Vh = !1));\n })), [ 4 /*yield*/ , Vs(r, i, n) ];\n\n case 3:\n // Update `receivedDocument` as appropriate for any limbo targets.\n return t.sent(), [ 3 /*break*/ , 6 ];\n\n case 4:\n return [ 4 /*yield*/ , Do(t.sent()) ];\n\n case 5:\n return t.sent(), [ 3 /*break*/ , 6 ];\n\n case 6:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/**\n * Applies an OnlineState change to the sync engine and notifies any views of\n * the change.\n */ function Ts(t, e, n) {\n var r = m(t);\n // If we are the secondary client, we explicitly ignore the remote store's\n // online state (the local client may go offline, even though the primary\n // tab remains online) and only apply the primary tab's online state from\n // SharedClientState.\n if (r.Uh && 0 /* RemoteStore */ === n || !r.Uh && 1 /* SharedClientState */ === n) {\n var i = [];\n r.Nh.forEach((function(t, n) {\n var r = n.view.Qs(e);\n r.snapshot && i.push(r.snapshot);\n })), function(t, e) {\n var n = m(t);\n n.onlineState = e;\n var r = !1;\n n.Bs.forEach((function(t, n) {\n for (var i = 0, o = n.listeners; i < o.length; i++) {\n // Run global snapshot listeners if a consistent snapshot has been emitted.\n o[i].Qs(e) && (r = !0);\n }\n })), r && Cr(n);\n }(r.bh, e), i.length && r.Ch.yu(i), r.onlineState = e, r.Uh && r.Sh.Ki(e);\n }\n}\n\n/**\n * Rejects the listen for the given targetID. This can be triggered by the\n * backend for any active target.\n *\n * @param syncEngine The sync engine implementation.\n * @param targetId The targetID corresponds to one previously initiated by the\n * user as part of TargetData passed to listen() on RemoteStore.\n * @param err A description of the condition that has forced the rejection.\n * Nearly always this will be an indication that the user is no longer\n * authorized to see the data matching the target.\n */ function Ns(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var i, o, s, u, a, c;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n // PORTING NOTE: Multi-tab only.\n return (i = m(e)).Sh.Qi(n, \"rejected\", r), o = i.kh.get(n), (s = o && o.key) ? (u = (u = new bt(A.i)).ot(s, new Rn(s, st.min())), \n a = Ot().add(s), c = new Mt(st.min(), \n /* targetChanges= */ new Map, \n /* targetMismatches= */ new Tt(H), u, a), [ 4 /*yield*/ , Es(i, c) ]) : [ 3 /*break*/ , 2 ];\n\n case 1:\n return t.sent(), \n // Since this query failed, we won't want to manually unlisten to it.\n // We only remove it from bookkeeping after we successfully applied the\n // RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to\n // this query when the RemoteStore restarts the Watch stream, which should\n // re-trigger the target failure.\n i.$h = i.$h.remove(s), i.kh.delete(n), Ps(i), [ 3 /*break*/ , 4 ];\n\n case 2:\n return [ 4 /*yield*/ , Eo(i.ju, n, \n /* keepPersistedTargetData */ !1).then((function() {\n return Ls(i, n, r);\n })).catch(Do) ];\n\n case 3:\n t.sent(), t.label = 4;\n\n case 4:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\nfunction As(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n r = m(e), i = n.batch.batchId, t.label = 1;\n\n case 1:\n return t.trys.push([ 1, 4, , 6 ]), [ 4 /*yield*/ , mo(r.ju, n) ];\n\n case 2:\n return o = t.sent(), \n // The local store may or may not be able to apply the write result and\n // raise events immediately (depending on whether the watcher is caught\n // up), so we raise user callbacks first so that they consistently happen\n // before listen events.\n xs(r, i, /*error=*/ null), Ds(r, i), r.Sh.ki(i, \"acknowledged\"), [ 4 /*yield*/ , Vs(r, o) ];\n\n case 3:\n // The local store may or may not be able to apply the write result and\n // raise events immediately (depending on whether the watcher is caught\n // up), so we raise user callbacks first so that they consistently happen\n // before listen events.\n return t.sent(), [ 3 /*break*/ , 6 ];\n\n case 4:\n return [ 4 /*yield*/ , Do(t.sent()) ];\n\n case 5:\n return t.sent(), [ 3 /*break*/ , 6 ];\n\n case 6:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\nfunction Ss(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var i, o;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n i = m(e), t.label = 1;\n\n case 1:\n return t.trys.push([ 1, 4, , 6 ]), [ 4 /*yield*/ , function(t, e) {\n var n = m(t);\n return n.persistence.runTransaction(\"Reject batch\", \"readwrite-primary\", (function(t) {\n var r;\n return n.Sr.Oo(t, e).next((function(e) {\n return g(null !== e), r = e.keys(), n.Sr.Wo(t, e);\n })).next((function() {\n return n.Sr.zo(t);\n })).next((function() {\n return n.Cc.kr(t, r);\n }));\n }));\n }(i.ju, n) ];\n\n case 2:\n return o = t.sent(), \n // The local store may or may not be able to apply the write result and\n // raise events immediately (depending on whether the watcher is caught up),\n // so we raise user callbacks first so that they consistently happen before\n // listen events.\n xs(i, n, r), Ds(i, n), i.Sh.ki(n, \"rejected\", r), [ 4 /*yield*/ , Vs(i, o) ];\n\n case 3:\n // The local store may or may not be able to apply the write result and\n // raise events immediately (depending on whether the watcher is caught up),\n // so we raise user callbacks first so that they consistently happen before\n // listen events.\n return t.sent(), [ 3 /*break*/ , 6 ];\n\n case 4:\n return [ 4 /*yield*/ , Do(t.sent()) ];\n\n case 5:\n return t.sent(), [ 3 /*break*/ , 6 ];\n\n case 6:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/**\n * Registers a user callback that resolves when all pending mutations at the moment of calling\n * are acknowledged .\n */\n/**\n * Triggers the callbacks that are waiting for this batch id to get acknowledged by server,\n * if there are any.\n */\nfunction Ds(t, e) {\n (t.Lh.get(e) || []).forEach((function(t) {\n t.resolve();\n })), t.Lh.delete(e)\n /** Reject all outstanding callbacks waiting for pending writes to complete. */;\n}\n\nfunction xs(t, e, n) {\n var r = m(t), i = r.Oh[r.currentUser.ti()];\n // NOTE: Mutations restored from persistence won't have callbacks, so it's\n // okay for there to be no callback for this ID.\n if (i) {\n var o = i.get(e);\n o && (n ? o.reject(n) : o.resolve(), i = i.remove(e)), r.Oh[r.currentUser.ti()] = i;\n }\n}\n\nfunction Ls(t, e, n) {\n void 0 === n && (n = null), t.Sh.Bi(e);\n for (var r = 0, i = t.Fh.get(e); r < i.length; r++) {\n var o = i[r];\n t.Nh.delete(o), n && t.Ch.Wh(o, n);\n }\n t.Fh.delete(e), t.Uh && t.Mh.Uc(e).forEach((function(e) {\n t.Mh.Ho(e) || \n // We removed the last reference for this key\n ks(t, e);\n }));\n}\n\nfunction ks(t, e) {\n // It's possible that the target already got removed because the query failed. In that case,\n // the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.\n var n = t.$h.get(e);\n null !== n && (Ko(t.ph, n), t.$h = t.$h.remove(e), t.kh.delete(n), Ps(t));\n}\n\nfunction Rs(t, e, n) {\n for (var r = 0, i = n; r < i.length; r++) {\n var o = i[r];\n o instanceof ds ? (t.Mh.Da(o.key, e), Os(t, o)) : o instanceof vs ? (l(\"SyncEngine\", \"Document no longer in limbo: \" + o.key), \n t.Mh.Na(o.key, e), t.Mh.Ho(o.key) || \n // We removed the last reference for this key\n ks(t, o.key)) : y();\n }\n}\n\nfunction Os(t, e) {\n var n = e.key;\n t.$h.get(n) || (l(\"SyncEngine\", \"New document in limbo: \" + n), t.xh.push(n), Ps(t));\n}\n\n/**\n * Starts listens for documents in limbo that are enqueued for resolution,\n * subject to a maximum number of concurrent resolutions.\n *\n * Without bounding the number of concurrent resolutions, the server can fail\n * with \"resource exhausted\" errors which can lead to pathological client\n * behavior as seen in https://github.com/firebase/firebase-js-sdk/issues/2683.\n */ function Ps(t) {\n for (;t.xh.length > 0 && t.$h.size < t.Dh; ) {\n var e = t.xh.shift(), n = t.Bh.next();\n t.kh.set(n, new ms(e)), t.$h = t.$h.ot(e, n), Wo(t.ph, new gt(zn(Un(e.path)), n, 2 /* LimboResolution */ , qr.ai));\n }\n}\n\nfunction Vs(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var i, o, s, u;\n return t.__generator(this, (function(a) {\n switch (a.label) {\n case 0:\n return i = m(e), o = [], s = [], u = [], i.Nh.m() ? [ 3 /*break*/ , 3 ] : (i.Nh.forEach((function(t, e) {\n u.push(i.Qh(e, n, r).then((function(t) {\n if (t) {\n i.Uh && i.Sh.Qi(e.targetId, t.fromCache ? \"not-current\" : \"current\"), o.push(t);\n var n = ri.zr(e.targetId, t);\n s.push(n);\n }\n })));\n })), [ 4 /*yield*/ , Promise.all(u) ]);\n\n case 1:\n return a.sent(), i.Ch.yu(o), [ 4 /*yield*/ , function(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o, s, u, a, c, h, f;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n r = m(e), t.label = 1;\n\n case 1:\n return t.trys.push([ 1, 3, , 4 ]), [ 4 /*yield*/ , r.persistence.runTransaction(\"notifyLocalViewChanges\", \"readwrite\", (function(t) {\n return yr.forEach(n, (function(e) {\n return yr.forEach(e.Kr, (function(n) {\n return r.persistence.No.Da(t, e.targetId, n);\n })).next((function() {\n return yr.forEach(e.Gr, (function(n) {\n return r.persistence.No.Na(t, e.targetId, n);\n }));\n }));\n }));\n })) ];\n\n case 2:\n return t.sent(), [ 3 /*break*/ , 4 ];\n\n case 3:\n if (!_r(i = t.sent())) throw i;\n // If `notifyLocalViewChanges` fails, we did not advance the sequence\n // number for the documents that were included in this transaction.\n // This might trigger them to be deleted earlier than they otherwise\n // would have, but it should not invalidate the integrity of the data.\n return l(\"LocalStore\", \"Failed to update sequence numbers: \" + i), \n [ 3 /*break*/ , 4 ];\n\n case 4:\n for (o = 0, s = n; o < s.length; o++) u = s[o], a = u.targetId, u.fromCache || (c = r.bc.get(a), \n h = c.nt, f = c.rt(h), \n // Advance the last limbo free snapshot version\n r.bc = r.bc.ot(a, f));\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }(i.ju, s) ];\n\n case 2:\n a.sent(), a.label = 3;\n\n case 3:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\nfunction Us(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i;\n return t.__generator(this, (function(o) {\n switch (o.label) {\n case 0:\n return (r = m(e)).currentUser.isEqual(n) ? [ 3 /*break*/ , 3 ] : (l(\"SyncEngine\", \"User change. New user:\", n.ti()), \n [ 4 /*yield*/ , \n /**\n * Tells the LocalStore that the currently authenticated user has changed.\n *\n * In response the local store switches the mutation queue to the new user and\n * returns any resulting document changes.\n */\n // PORTING NOTE: Android and iOS only return the documents affected by the\n // change.\n function(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o, s;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return r = m(e), i = r.Sr, o = r.Cc, [ 4 /*yield*/ , r.persistence.runTransaction(\"Handle user change\", \"readonly\", (function(t) {\n // Swap out the mutation queue, grabbing the pending mutation batches\n // before and after.\n var e;\n return r.Sr.Uo(t).next((function(s) {\n return e = s, i = r.persistence.mc(n), \n // Recreate our LocalDocumentsView using the new\n // MutationQueue.\n o = new ni(r.Dc, i, r.persistence.Ic()), i.Uo(t);\n })).next((function(n) {\n for (var r = [], i = [], s = Ot(), u = 0, a = e\n // Union the old/new changed keys.\n ; u < a.length; u++) {\n var c = a[u];\n r.push(c.batchId);\n for (var h = 0, f = c.mutations; h < f.length; h++) {\n var l = f[h];\n s = s.add(l.key);\n }\n }\n for (var p = 0, d = n; p < d.length; p++) {\n var v = d[p];\n i.push(v.batchId);\n for (var y = 0, g = v.mutations; y < g.length; y++) {\n var m = g[y];\n s = s.add(m.key);\n }\n }\n // Return the set of all (potentially) changed documents and the list\n // of mutation batch IDs that were affected by change.\n return o.kr(t, s).next((function(t) {\n return {\n jh: t,\n Kh: r,\n Gh: i\n };\n }));\n }));\n })) ];\n\n case 1:\n return s = t.sent(), [ 2 /*return*/ , (r.Sr = i, r.Cc = o, r.Vc.Nc(r.Cc), s) ];\n }\n }));\n }));\n }(r.ju, n) ]);\n\n case 1:\n return i = o.sent(), r.currentUser = n, \n // Fails tasks waiting for pending writes requested by previous user.\n function(t, e) {\n t.Lh.forEach((function(t) {\n t.forEach((function(t) {\n t.reject(new c(a.CANCELLED, \"'waitForPendingWrites' promise is rejected due to a user change.\"));\n }));\n })), t.Lh.clear();\n }(r), \n // TODO(b/114226417): Consider calling this only in the primary tab.\n r.Sh.ji(n, i.Kh, i.Gh), [ 4 /*yield*/ , Vs(r, i.jh) ];\n\n case 2:\n o.sent(), o.label = 3;\n\n case 3:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\nfunction Cs(t, e) {\n var n = m(t), r = n.kh.get(e);\n if (r && r.Vh) return Ot().add(r.key);\n var i = Ot(), o = n.Fh.get(e);\n if (!o) return i;\n for (var s = 0, u = o; s < u.length; s++) {\n var a = u[s], c = n.Nh.get(a);\n i = i.kt(c.view.dh);\n }\n return i;\n}\n\n/**\n * Reconcile the list of synced documents in an existing view with those\n * from persistence.\n */ function Fs(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return [ 4 /*yield*/ , To((r = m(e)).ju, n.query, \n /* usePreviousResults= */ !0) ];\n\n case 1:\n return i = t.sent(), o = n.view.Ph(i), [ 2 /*return*/ , (r.Uh && Rs(r, n.targetId, o.Rh), \n o) ];\n }\n }));\n }));\n}\n\n/** Applies a mutation state to an existing batch. */\n// PORTING NOTE: Multi-Tab only.\nfunction Ms(e, n, r, i) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var o, s;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return [ 4 /*yield*/ , function(t, e) {\n var n = m(t), r = m(n.Sr);\n return n.persistence.runTransaction(\"Lookup mutation documents\", \"readonly\", (function(t) {\n return r.Lo(t, e).next((function(e) {\n return e ? n.Cc.kr(t, e) : yr.resolve(null);\n }));\n }));\n }((o = m(e)).ju, n) ];\n\n case 1:\n return null === (s = t.sent()) ? [ 3 /*break*/ , 6 ] : \"pending\" !== r ? [ 3 /*break*/ , 3 ] : [ 4 /*yield*/ , is(o.ph) ];\n\n case 2:\n // If we are the primary client, we need to send this write to the\n // backend. Secondary clients will ignore these writes since their remote\n // connection is disabled.\n return t.sent(), [ 3 /*break*/ , 4 ];\n\n case 3:\n \"acknowledged\" === r || \"rejected\" === r ? (\n // NOTE: Both these methods are no-ops for batches that originated from\n // other clients.\n xs(o, n, i || null), Ds(o, n), function(t, e) {\n m(m(t).Sr).Ko(e);\n }(o.ju, n)) : y(), t.label = 4;\n\n case 4:\n return [ 4 /*yield*/ , Vs(o, s) ];\n\n case 5:\n return t.sent(), [ 3 /*break*/ , 7 ];\n\n case 6:\n // A throttled tab may not have seen the mutation before it was completed\n // and removed from the mutation queue, in which case we won't have cached\n // the affected documents. In this case we can safely ignore the update\n // since that means we didn't apply the mutation locally at all (if we\n // had, we would have cached the affected documents), and so we will just\n // see any resulting document changes via normal remote document updates\n // as applicable.\n l(\"SyncEngine\", \"Cannot apply mutation batch with id: \" + n), t.label = 7;\n\n case 7:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/** Applies a query target change from a different tab. */\n// PORTING NOTE: Multi-Tab only.\nfunction qs(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o, s, u, a, c, h;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return Ks(r = m(e)), Qs(r), !0 !== n || !0 === r.qh ? [ 3 /*break*/ , 3 ] : (i = r.Sh.Ci(), \n [ 4 /*yield*/ , js(r, i.A()) ]);\n\n case 1:\n return o = t.sent(), r.qh = !0, [ 4 /*yield*/ , fs(r.ph, !0) ];\n\n case 2:\n for (t.sent(), s = 0, u = o; s < u.length; s++) a = u[s], Wo(r.ph, a);\n return [ 3 /*break*/ , 7 ];\n\n case 3:\n return !1 !== n || !1 === r.qh ? [ 3 /*break*/ , 7 ] : (c = [], h = Promise.resolve(), \n r.Fh.forEach((function(t, e) {\n r.Sh.qi(e) ? c.push(e) : h = h.then((function() {\n return Ls(r, e), Eo(r.ju, e, \n /*keepPersistedTargetData=*/ !0);\n })), Ko(r.ph, e);\n })), [ 4 /*yield*/ , h ]);\n\n case 4:\n return t.sent(), [ 4 /*yield*/ , js(r, c) ];\n\n case 5:\n return t.sent(), \n // PORTING NOTE: Multi-Tab only.\n function(t) {\n var e = m(t);\n e.kh.forEach((function(t, n) {\n Ko(e.ph, n);\n })), e.Mh.Qc(), e.kh = new Map, e.$h = new bt(A.i);\n }(r), r.qh = !1, [ 4 /*yield*/ , fs(r.ph, !1) ];\n\n case 6:\n t.sent(), t.label = 7;\n\n case 7:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\nfunction js(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o, s, u, a, c, h, f, l, p, d, v, y;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n r = m(e), i = [], o = [], s = 0, u = n, t.label = 1;\n\n case 1:\n return s < u.length ? (a = u[s], c = void 0, (h = r.Fh.get(a)) && 0 !== h.length ? [ 4 /*yield*/ , Io(r.ju, zn(h[0])) ] : [ 3 /*break*/ , 7 ]) : [ 3 /*break*/ , 13 ];\n\n case 2:\n // For queries that have a local View, we fetch their current state\n // from LocalStore (as the resume token and the snapshot version\n // might have changed) and reconcile their views with the persisted\n // state (the list of syncedDocuments may have gotten out of sync).\n c = t.sent(), f = 0, l = h, t.label = 3;\n\n case 3:\n return f < l.length ? (p = l[f], d = r.Nh.get(p), [ 4 /*yield*/ , Fs(r, d) ]) : [ 3 /*break*/ , 6 ];\n\n case 4:\n (v = t.sent()).snapshot && o.push(v.snapshot), t.label = 5;\n\n case 5:\n return f++, [ 3 /*break*/ , 3 ];\n\n case 6:\n return [ 3 /*break*/ , 11 ];\n\n case 7:\n return [ 4 /*yield*/ , No(r.ju, a) ];\n\n case 8:\n return y = t.sent(), [ 4 /*yield*/ , Io(r.ju, y) ];\n\n case 9:\n return c = t.sent(), [ 4 /*yield*/ , bs(r, Gs(y), a, \n /*current=*/ !1) ];\n\n case 10:\n t.sent(), t.label = 11;\n\n case 11:\n i.push(c), t.label = 12;\n\n case 12:\n return s++, [ 3 /*break*/ , 1 ];\n\n case 13:\n return [ 2 /*return*/ , (r.Ch.yu(o), i) ];\n }\n }));\n }));\n}\n\n/**\n * Creates a `Query` object from the specified `Target`. There is no way to\n * obtain the original `Query`, so we synthesize a `Query` from the `Target`\n * object.\n *\n * The synthesized result might be different from the original `Query`, but\n * since the synthesized `Query` should return the same results as the\n * original one (only the presentation of results might differ), the potential\n * difference will not cause issues.\n */\n// PORTING NOTE: Multi-Tab only.\nfunction Gs(t) {\n return Vn(t.path, t.collectionGroup, t.orderBy, t.filters, t.limit, \"F\" /* First */ , t.startAt, t.endAt);\n}\n\n/** Returns the IDs of the clients that are currently active. */\n// PORTING NOTE: Multi-Tab only.\nfunction zs(t) {\n var e = m(t);\n return m(m(e.ju).persistence).pi();\n}\n\n/** Applies a query target change from a different tab. */\n// PORTING NOTE: Multi-Tab only.\nfunction Bs(e, n, r, i) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var o, s, u;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return (o = m(e)).qh ? (\n // If we receive a target state notification via WebStorage, we are\n // either already secondary or another tab has taken the primary lease.\n l(\"SyncEngine\", \"Ignoring unexpected query state notification.\"), [ 3 /*break*/ , 8 ]) : [ 3 /*break*/ , 1 ];\n\n case 1:\n if (!o.Fh.has(n)) return [ 3 /*break*/ , 8 ];\n switch (r) {\n case \"current\":\n case \"not-current\":\n return [ 3 /*break*/ , 2 ];\n\n case \"rejected\":\n return [ 3 /*break*/ , 5 ];\n }\n return [ 3 /*break*/ , 7 ];\n\n case 2:\n return [ 4 /*yield*/ , Ao(o.ju) ];\n\n case 3:\n return s = t.sent(), u = Mt.Xt(n, \"current\" === r), [ 4 /*yield*/ , Vs(o, s, u) ];\n\n case 4:\n return t.sent(), [ 3 /*break*/ , 8 ];\n\n case 5:\n return [ 4 /*yield*/ , Eo(o.ju, n, \n /* keepPersistedTargetData */ !0) ];\n\n case 6:\n return t.sent(), Ls(o, n, i), [ 3 /*break*/ , 8 ];\n\n case 7:\n y(), t.label = 8;\n\n case 8:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\n/** Adds or removes Watch targets for queries from different tabs. */ function Ws(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var i, o, s, u, a, c, h, f, p, d;\n return t.__generator(this, (function(v) {\n switch (v.label) {\n case 0:\n if (!(i = Ks(e)).qh) return [ 3 /*break*/ , 10 ];\n o = 0, s = n, v.label = 1;\n\n case 1:\n return o < s.length ? (u = s[o], i.Fh.has(u) ? (\n // A target might have been added in a previous attempt\n l(\"SyncEngine\", \"Adding an already active target \" + u), [ 3 /*break*/ , 5 ]) : [ 4 /*yield*/ , No(i.ju, u) ]) : [ 3 /*break*/ , 6 ];\n\n case 2:\n return a = v.sent(), [ 4 /*yield*/ , Io(i.ju, a) ];\n\n case 3:\n return c = v.sent(), [ 4 /*yield*/ , bs(i, Gs(a), c.targetId, \n /*current=*/ !1) ];\n\n case 4:\n v.sent(), Wo(i.ph, c), v.label = 5;\n\n case 5:\n return o++, [ 3 /*break*/ , 1 ];\n\n case 6:\n h = function(e) {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return i.Fh.has(e) ? [ 4 /*yield*/ , Eo(i.ju, e, \n /* keepPersistedTargetData */ !1).then((function() {\n Ko(i.ph, e), Ls(i, e);\n })).catch(Do) ] : [ 3 /*break*/ , 2 ];\n\n // Release queries that are still active.\n case 1:\n // Release queries that are still active.\n t.sent(), t.label = 2;\n\n case 2:\n return [ 2 /*return*/ ];\n }\n }));\n }, f = 0, p = r, v.label = 7;\n\n case 7:\n return f < p.length ? (d = p[f], [ 5 /*yield**/ , h(d) ]) : [ 3 /*break*/ , 10 ];\n\n case 8:\n v.sent(), v.label = 9;\n\n case 9:\n return f++, [ 3 /*break*/ , 7 ];\n\n case 10:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}\n\nfunction Ks(t) {\n var e = m(t);\n return e.ph.Gu.sh = Es.bind(null, e), e.ph.Gu.qe = Cs.bind(null, e), e.ph.Gu.nh = Ns.bind(null, e), \n e.Ch.yu = Vr.bind(null, e.bh), e.Ch.Wh = Ur.bind(null, e.bh), e;\n}\n\nfunction Qs(t) {\n var e = m(t);\n return e.ph.Gu.ih = As.bind(null, e), e.ph.Gu.rh = Ss.bind(null, e), e;\n}\n\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// TOOD(b/140938512): Drop SimpleQueryEngine and rename IndexFreeQueryEngine.\n/**\n * A query engine that takes advantage of the target document mapping in the\n * QueryCache. The IndexFreeQueryEngine optimizes query execution by only\n * reading the documents that previously matched a query plus any documents that were\n * edited after the query was last listened to.\n *\n * There are some cases where Index-Free queries are not guaranteed to produce\n * the same results as full collection scans. In these cases, the\n * IndexFreeQueryEngine falls back to full query processing. These cases are:\n *\n * - Limit queries where a document that matched the query previously no longer\n * matches the query.\n *\n * - Limit queries where a document edit may cause the document to sort below\n * another document that is in the local cache.\n *\n * - Queries that have never been CURRENT or free of Limbo documents.\n */ var Hs = /** @class */ function() {\n function t() {}\n return t.prototype.Nc = function(t) {\n this.zh = t;\n }, t.prototype.Lr = function(t, e, r, i) {\n var o = this;\n // Queries that match all documents don't benefit from using\n // IndexFreeQueries. It is more efficient to scan all documents in a\n // collection, rather than to perform individual lookups.\n return function(t) {\n return 0 === t.filters.length && null === t.limit && null == t.startAt && null == t.endAt && (0 === t.on.length || 1 === t.on.length && t.on[0].field.p());\n }(e) || r.isEqual(st.min()) ? this.Hh(t, e) : this.zh.kr(t, i).next((function(s) {\n var u = o.Yh(e, s);\n return (Cn(e) || Fn(e)) && o.Eh(e.an, u, i, r) ? o.Hh(t, e) : (f() <= n.LogLevel.DEBUG && l(\"IndexFreeQueryEngine\", \"Re-using previous result from %s to execute query: %s\", r.toString(), Yn(e)), \n o.zh.Lr(t, e, r).next((function(t) {\n // We merge `previousResults` into `updateResults`, since\n // `updateResults` is already a DocumentMap. If a document is\n // contained in both lists, then its contents are the same.\n return u.forEach((function(e) {\n t = t.ot(e.key, e);\n })), t;\n })));\n }));\n // Queries that have never seen a snapshot without limbo free documents\n // should also be run as a full collection scan.\n }, \n /** Applies the query filter and sorting to the provided documents. */ t.prototype.Yh = function(t, e) {\n // Sort the documents and re-apply the query filter since previously\n // matching documents do not necessarily still match the query.\n var n = new Tt(Xn(t));\n return e.forEach((function(e, r) {\n r instanceof kn && $n(t, r) && (n = n.add(r));\n })), n;\n }, \n /**\n * Determines if a limit query needs to be refilled from cache, making it\n * ineligible for index-free execution.\n *\n * @param sortedPreviousResults The documents that matched the query when it\n * was last synchronized, sorted by the query's comparator.\n * @param remoteKeys The document keys that matched the query at the last\n * snapshot.\n * @param limboFreeSnapshotVersion The version of the snapshot when the query\n * was last synchronized.\n */\n t.prototype.Eh = function(t, e, n, r) {\n // The query needs to be refilled if a previously matching document no\n // longer matches.\n if (n.size !== e.size) return !0;\n // Limit queries are not eligible for index-free query execution if there is\n // a potential that an older document from cache now sorts before a document\n // that was previously part of the limit. This, however, can only happen if\n // the document at the edge of the limit goes out of limit.\n // If a document that is not the limit boundary sorts differently,\n // the boundary of the limit itself did not change and documents from cache\n // will continue to be \"rejected\" by this boundary. Therefore, we can ignore\n // any modifications that don't affect the last document.\n var i = \"F\" /* First */ === t ? e.last() : e.first();\n return !!i && (i.hasPendingWrites || i.version.L(r) > 0);\n }, t.prototype.Hh = function(t, e) {\n return f() <= n.LogLevel.DEBUG && l(\"IndexFreeQueryEngine\", \"Using full collection scan to execute query:\", Yn(e)), \n this.zh.Lr(t, e, st.min());\n }, t;\n}(), Ys = /** @class */ function() {\n function t(t, e) {\n this.Dr = t, this.No = e, \n /**\n * The set of all mutations that have been sent but not yet been applied to\n * the backend.\n */\n this.Sr = [], \n /** Next value to use when assigning sequential IDs to each mutation batch. */\n this.Jh = 1, \n /** An ordered mapping between documents and the mutations batch IDs. */\n this.Xh = new Tt(Lo.kc);\n }\n return t.prototype.$o = function(t) {\n return yr.resolve(0 === this.Sr.length);\n }, t.prototype.ko = function(t, e, n, r) {\n var i = this.Jh;\n this.Jh++, this.Sr.length > 0 && this.Sr[this.Sr.length - 1];\n var o = new Xr(i, e, n, r);\n this.Sr.push(o);\n // Track references by document key and index collection parents.\n for (var s = 0, u = r; s < u.length; s++) {\n var a = u[s];\n this.Xh = this.Xh.add(new Lo(a.key, i)), this.Dr.Mo(t, a.key.path.h());\n }\n return yr.resolve(o);\n }, t.prototype.Oo = function(t, e) {\n return yr.resolve(this.Zh(e));\n }, t.prototype.Bo = function(t, e) {\n var n = e + 1, r = this.tl(n), i = r < 0 ? 0 : r;\n // The requested batchId may still be out of range so normalize it to the\n // start of the queue.\n return yr.resolve(this.Sr.length > i ? this.Sr[i] : null);\n }, t.prototype.qo = function() {\n return yr.resolve(0 === this.Sr.length ? -1 : this.Jh - 1);\n }, t.prototype.Uo = function(t) {\n return yr.resolve(this.Sr.slice());\n }, t.prototype.Nr = function(t, e) {\n var n = this, r = new Lo(e, 0), i = new Lo(e, Number.POSITIVE_INFINITY), o = [];\n return this.Xh.Ft([ r, i ], (function(t) {\n var e = n.Zh(t.jc);\n o.push(e);\n })), yr.resolve(o);\n }, t.prototype.Or = function(t, e) {\n var n = this, r = new Tt(H);\n return e.forEach((function(t) {\n var e = new Lo(t, 0), i = new Lo(t, Number.POSITIVE_INFINITY);\n n.Xh.Ft([ e, i ], (function(t) {\n r = r.add(t.jc);\n }));\n })), yr.resolve(this.el(r));\n }, t.prototype.Wr = function(t, e) {\n // Use the query path as a prefix for testing if a document matches the\n // query.\n var n = e.path, r = n.length + 1, i = n;\n // Construct a document reference for actually scanning the index. Unlike\n // the prefix the document key in this reference must have an even number of\n // segments. The empty segment can be used a suffix of the query path\n // because it precedes all other segments in an ordered traversal.\n A.F(i) || (i = i.child(\"\"));\n var o = new Lo(new A(i), 0), s = new Tt(H);\n // Find unique batchIDs referenced by all documents potentially matching the\n // query.\n return this.Xh.xt((function(t) {\n var e = t.key.path;\n return !!n.T(e) && (\n // Rows with document keys more than one segment longer than the query\n // path can't be matches. For example, a query on 'rooms' can't match\n // the document /rooms/abc/messages/xyx.\n // TODO(mcg): we'll need a different scanner when we implement\n // ancestor queries.\n e.length === r && (s = s.add(t.jc)), !0);\n }), o), yr.resolve(this.el(s));\n }, t.prototype.el = function(t) {\n var e = this, n = [];\n // Construct an array of matching batches, sorted by batchID to ensure that\n // multiple mutations affecting the same document key are applied in order.\n return t.forEach((function(t) {\n var r = e.Zh(t);\n null !== r && n.push(r);\n })), n;\n }, t.prototype.Wo = function(t, e) {\n var n = this;\n g(0 === this.nl(e.batchId, \"removed\")), this.Sr.shift();\n var r = this.Xh;\n return yr.forEach(e.mutations, (function(i) {\n var o = new Lo(i.key, e.batchId);\n return r = r.delete(o), n.No.Go(t, i.key);\n })).next((function() {\n n.Xh = r;\n }));\n }, t.prototype.Ko = function(t) {\n // No-op since the memory mutation queue does not maintain a separate cache.\n }, t.prototype.Ho = function(t, e) {\n var n = new Lo(e, 0), r = this.Xh.$t(n);\n return yr.resolve(e.isEqual(r && r.key));\n }, t.prototype.zo = function(t) {\n return this.Sr.length, yr.resolve();\n }, \n /**\n * Finds the index of the given batchId in the mutation queue and asserts that\n * the resulting index is within the bounds of the queue.\n *\n * @param batchId The batchId to search for\n * @param action A description of what the caller is doing, phrased in passive\n * form (e.g. \"acknowledged\" in a routine that acknowledges batches).\n */\n t.prototype.nl = function(t, e) {\n return this.tl(t);\n }, \n /**\n * Finds the index of the given batchId in the mutation queue. This operation\n * is O(1).\n *\n * @return The computed index of the batch with the given batchId, based on\n * the state of the queue. Note this index can be negative if the requested\n * batchId has already been remvoed from the queue or past the end of the\n * queue if the batchId is larger than the last added batch.\n */\n t.prototype.tl = function(t) {\n return 0 === this.Sr.length ? 0 : t - this.Sr[0].batchId;\n // Examine the front of the queue to figure out the difference between the\n // batchId and indexes in the array. Note that since the queue is ordered\n // by batchId, if the first batch has a larger batchId then the requested\n // batchId doesn't exist in the queue.\n }, \n /**\n * A version of lookupMutationBatch that doesn't return a promise, this makes\n * other functions that uses this code easier to read and more efficent.\n */\n t.prototype.Zh = function(t) {\n var e = this.tl(t);\n return e < 0 || e >= this.Sr.length ? null : this.Sr[e];\n }, t;\n}(), $s = /** @class */ function() {\n /**\n * @param sizer Used to assess the size of a document. For eager GC, this is expected to just\n * return 0 to avoid unnecessarily doing the work of calculating the size.\n */\n function t(t, e) {\n this.Dr = t, this.sl = e, \n /** Underlying cache of documents and their read times. */\n this.docs = new bt(A.i), \n /** Size of all cached documents. */\n this.size = 0\n /**\n * Adds the supplied entry to the cache and updates the cache size as appropriate.\n *\n * All calls of `addEntry` are required to go through the RemoteDocumentChangeBuffer\n * returned by `newChangeBuffer()`.\n */;\n }\n return t.prototype.Er = function(t, e, n) {\n var r = e.key, i = this.docs.get(r), o = i ? i.size : 0, s = this.sl(e);\n return this.docs = this.docs.ot(r, {\n ta: e,\n size: s,\n readTime: n\n }), this.size += s - o, this.Dr.Mo(t, r.path.h());\n }, \n /**\n * Removes the specified entry from the cache and updates the cache size as appropriate.\n *\n * All calls of `removeEntry` are required to go through the RemoteDocumentChangeBuffer\n * returned by `newChangeBuffer()`.\n */\n t.prototype.Ar = function(t) {\n var e = this.docs.get(t);\n e && (this.docs = this.docs.remove(t), this.size -= e.size);\n }, t.prototype.Rr = function(t, e) {\n var n = this.docs.get(e);\n return yr.resolve(n ? n.ta : null);\n }, t.prototype.getEntries = function(t, e) {\n var n = this, r = Dt();\n return e.forEach((function(t) {\n var e = n.docs.get(t);\n r = r.ot(t, e ? e.ta : null);\n })), yr.resolve(r);\n }, t.prototype.Lr = function(t, e, n) {\n for (var r = Lt(), i = new A(e.path.child(\"\")), o = this.docs.ft(i)\n // Documents are ordered by key, so we can use a prefix scan to narrow down\n // the documents we need to match the query against.\n ; o.At(); ) {\n var s = o.It(), u = s.key, a = s.value, c = a.ta, h = a.readTime;\n if (!e.path.T(u.path)) break;\n h.L(n) <= 0 || c instanceof kn && $n(e, c) && (r = r.ot(c.key, c));\n }\n return yr.resolve(r);\n }, t.prototype.il = function(t, e) {\n return yr.forEach(this.docs, (function(t) {\n return e(t);\n }));\n }, t.prototype.ra = function(t) {\n // `trackRemovals` is ignores since the MemoryRemoteDocumentCache keeps\n // a separate changelog and does not need special handling for removals.\n return new Xs(this);\n }, t.prototype.aa = function(t) {\n return yr.resolve(this.size);\n }, t;\n}(), Xs = /** @class */ function(e) {\n function n(t) {\n var n = this;\n return (n = e.call(this) || this).ca = t, n;\n }\n return t.__extends(n, e), n.prototype.yr = function(t) {\n var e = this, n = [];\n return this.wr.forEach((function(r, i) {\n i ? n.push(e.ca.Er(t, i, e.readTime)) : e.ca.Ar(r);\n })), yr.$n(n);\n }, n.prototype.gr = function(t, e) {\n return this.ca.Rr(t, e);\n }, n.prototype.Pr = function(t, e) {\n return this.ca.getEntries(t, e);\n }, n;\n}(Zr), Js = /** @class */ function() {\n function t(t) {\n this.persistence = t, \n /**\n * Maps a target to the data about that target\n */\n this.rl = new it((function(t) {\n return lt(t);\n }), pt), \n /** The last received snapshot version. */\n this.lastRemoteSnapshotVersion = st.min(), \n /** The highest numbered target ID encountered. */\n this.highestTargetId = 0, \n /** The highest sequence number encountered. */\n this.ol = 0, \n /**\n * A ordered bidirectional mapping between documents and the remote target\n * IDs.\n */\n this.al = new xo, this.targetCount = 0, this.cl = ro.fa();\n }\n return t.prototype.Ce = function(t, e) {\n return this.rl.forEach((function(t, n) {\n return e(n);\n })), yr.resolve();\n }, t.prototype.Ea = function(t) {\n return yr.resolve(this.lastRemoteSnapshotVersion);\n }, t.prototype.Ia = function(t) {\n return yr.resolve(this.ol);\n }, t.prototype.wa = function(t) {\n return this.highestTargetId = this.cl.next(), yr.resolve(this.highestTargetId);\n }, t.prototype.Aa = function(t, e, n) {\n return n && (this.lastRemoteSnapshotVersion = n), e > this.ol && (this.ol = e), \n yr.resolve();\n }, t.prototype.ga = function(t) {\n this.rl.set(t.target, t);\n var e = t.targetId;\n e > this.highestTargetId && (this.cl = new ro(e), this.highestTargetId = e), t.sequenceNumber > this.ol && (this.ol = t.sequenceNumber);\n }, t.prototype.Ra = function(t, e) {\n return this.ga(e), this.targetCount += 1, yr.resolve();\n }, t.prototype.ya = function(t, e) {\n return this.ga(e), yr.resolve();\n }, t.prototype.Va = function(t, e) {\n return this.rl.delete(e.target), this.al.Uc(e.targetId), this.targetCount -= 1, \n yr.resolve();\n }, t.prototype.po = function(t, e, n) {\n var r = this, i = 0, o = [];\n return this.rl.forEach((function(s, u) {\n u.sequenceNumber <= e && null === n.get(u.targetId) && (r.rl.delete(s), o.push(r.pa(t, u.targetId)), \n i++);\n })), yr.$n(o).next((function() {\n return i;\n }));\n }, t.prototype.ba = function(t) {\n return yr.resolve(this.targetCount);\n }, t.prototype.va = function(t, e) {\n var n = this.rl.get(e) || null;\n return yr.resolve(n);\n }, t.prototype.Sa = function(t, e, n) {\n return this.al.Lc(e, n), yr.resolve();\n }, t.prototype.Ca = function(t, e, n) {\n this.al.qc(e, n);\n var r = this.persistence.No, i = [];\n return r && e.forEach((function(e) {\n i.push(r.Go(t, e));\n })), yr.$n(i);\n }, t.prototype.pa = function(t, e) {\n return this.al.Uc(e), yr.resolve();\n }, t.prototype.Fa = function(t, e) {\n var n = this.al.Wc(e);\n return yr.resolve(n);\n }, t.prototype.Ho = function(t, e) {\n return yr.resolve(this.al.Ho(e));\n }, t;\n}(), Zs = /** @class */ function() {\n /**\n * The constructor accepts a factory for creating a reference delegate. This\n * allows both the delegate and this instance to have strong references to\n * each other without having nullable fields that would then need to be\n * checked or asserted on every access.\n */\n function t(t) {\n var e = this;\n this.ul = {}, this.Ma = new qr(0), this.Oa = !1, this.Oa = !0, this.No = t(this), \n this.Ka = new Js(this), this.Dr = new Ui, this.vr = function(t, n) {\n return new $s(t, (function(t) {\n return e.No.hl(t);\n }));\n }(this.Dr);\n }\n return t.prototype.start = function() {\n return Promise.resolve();\n }, t.prototype.Di = function() {\n // No durable state to ensure is closed on shutdown.\n return this.Oa = !1, Promise.resolve();\n }, Object.defineProperty(t.prototype, \"Ei\", {\n get: function() {\n return this.Oa;\n },\n enumerable: !1,\n configurable: !0\n }), t.prototype.Za = function() {\n // No op.\n }, t.prototype.tc = function() {\n // No op.\n }, t.prototype.Ic = function() {\n return this.Dr;\n }, t.prototype.mc = function(t) {\n var e = this.ul[t.ti()];\n return e || (e = new Ys(this.Dr, this.No), this.ul[t.ti()] = e), e;\n }, t.prototype.Tc = function() {\n return this.Ka;\n }, t.prototype.Ec = function() {\n return this.vr;\n }, t.prototype.runTransaction = function(t, e, n) {\n var r = this;\n l(\"MemoryPersistence\", \"Starting transaction:\", t);\n var i = new tu(this.Ma.next());\n return this.No.ll(), n(i).next((function(t) {\n return r.No._l(i).next((function() {\n return t;\n }));\n })).Fn().then((function(t) {\n return i.br(), t;\n }));\n }, t.prototype.fl = function(t, e) {\n return yr.kn(Object.values(this.ul).map((function(n) {\n return function() {\n return n.Ho(t, e);\n };\n })));\n }, t;\n}(), tu = /** @class */ function(e) {\n function n(t) {\n var n = this;\n return (n = e.call(this) || this).xa = t, n;\n }\n return t.__extends(n, e), n;\n}(ei), eu = /** @class */ function() {\n function t(t) {\n this.persistence = t, \n /** Tracks all documents that are active in Query views. */\n this.dl = new xo, \n /** The list of documents that are potentially GCed after each transaction. */\n this.wl = null;\n }\n return t.ml = function(e) {\n return new t(e);\n }, Object.defineProperty(t.prototype, \"Tl\", {\n get: function() {\n if (this.wl) return this.wl;\n throw y();\n },\n enumerable: !1,\n configurable: !0\n }), t.prototype.Da = function(t, e, n) {\n return this.dl.Da(n, e), this.Tl.delete(n.toString()), yr.resolve();\n }, t.prototype.Na = function(t, e, n) {\n return this.dl.Na(n, e), this.Tl.add(n.toString()), yr.resolve();\n }, t.prototype.Go = function(t, e) {\n return this.Tl.add(e.toString()), yr.resolve();\n }, t.prototype.removeTarget = function(t, e) {\n var n = this;\n this.dl.Uc(e.targetId).forEach((function(t) {\n return n.Tl.add(t.toString());\n }));\n var r = this.persistence.Tc();\n return r.Fa(t, e.targetId).next((function(t) {\n t.forEach((function(t) {\n return n.Tl.add(t.toString());\n }));\n })).next((function() {\n return r.Va(t, e);\n }));\n }, t.prototype.ll = function() {\n this.wl = new Set;\n }, t.prototype._l = function(t) {\n var e = this, n = this.persistence.Ec().ra();\n // Remove newly orphaned documents.\n return yr.forEach(this.Tl, (function(r) {\n var i = A.D(r);\n return e.El(t, i).next((function(t) {\n t || n.Ar(i);\n }));\n })).next((function() {\n return e.wl = null, n.apply(t);\n }));\n }, t.prototype.yc = function(t, e) {\n var n = this;\n return this.El(t, e).next((function(t) {\n t ? n.Tl.delete(e.toString()) : n.Tl.add(e.toString());\n }));\n }, t.prototype.hl = function(t) {\n // For eager GC, we don't care about the document size, there are no size thresholds.\n return 0;\n }, t.prototype.El = function(t, e) {\n var n = this;\n return yr.kn([ function() {\n return yr.resolve(n.dl.Ho(e));\n }, function() {\n return n.persistence.Tc().Ho(t, e);\n }, function() {\n return n.persistence.fl(t, e);\n } ]);\n }, t;\n}(), nu = /** @class */ function() {\n function t(t) {\n this.Il = t.Il, this.Al = t.Al;\n }\n return t.prototype.gu = function(t) {\n this.Rl = t;\n }, t.prototype.Tu = function(t) {\n this.gl = t;\n }, t.prototype.onMessage = function(t) {\n this.Pl = t;\n }, t.prototype.close = function() {\n this.Al();\n }, t.prototype.send = function(t) {\n this.Il(t);\n }, t.prototype.yl = function() {\n this.Rl();\n }, t.prototype.Vl = function(t) {\n this.gl(t);\n }, t.prototype.pl = function(t) {\n this.Pl(t);\n }, t;\n}(), ru = {\n BatchGetDocuments: \"batchGet\",\n Commit: \"commit\",\n RunQuery: \"runQuery\"\n}, iu = /** @class */ function(e) {\n function n(t) {\n var n = this;\n return (n = e.call(this, t) || this).forceLongPolling = t.forceLongPolling, n.W = t.W, \n n;\n }\n /**\n * Base class for all Rest-based connections to the backend (WebChannel and\n * HTTP).\n */\n return t.__extends(n, e), n.prototype.Nl = function(t, e, n, r) {\n return new Promise((function(o, s) {\n var u = new i.XhrIo;\n u.listenOnce(i.EventType.COMPLETE, (function() {\n try {\n switch (u.getLastErrorCode()) {\n case i.ErrorCode.NO_ERROR:\n var e = u.getResponseJson();\n l(\"Connection\", \"XHR received:\", JSON.stringify(e)), o(e);\n break;\n\n case i.ErrorCode.TIMEOUT:\n l(\"Connection\", 'RPC \"' + t + '\" timed out'), s(new c(a.DEADLINE_EXCEEDED, \"Request time out\"));\n break;\n\n case i.ErrorCode.HTTP_ERROR:\n var n = u.getStatus();\n if (l(\"Connection\", 'RPC \"' + t + '\" failed with status:', n, \"response text:\", u.getResponseText()), \n n > 0) {\n var r = u.getResponseJson().error;\n if (r && r.status && r.message) {\n var h = function(t) {\n var e = t.toLowerCase().replace(\"_\", \"-\");\n return Object.values(a).indexOf(e) >= 0 ? e : a.UNKNOWN;\n }(r.status);\n s(new c(h, r.message));\n } else s(new c(a.UNKNOWN, \"Server responded with status \" + u.getStatus()));\n } else \n // If we received an HTTP_ERROR but there's no status code,\n // it's most probably a connection issue\n s(new c(a.UNAVAILABLE, \"Connection failed.\"));\n break;\n\n default:\n y();\n }\n } finally {\n l(\"Connection\", 'RPC \"' + t + '\" completed.');\n }\n }));\n var h = JSON.stringify(r);\n u.send(e, \"POST\", h, n, 15);\n }));\n }, n.prototype.Pu = function(t, e) {\n var n = [ this.vl, \"/\", \"google.firestore.v1.Firestore\", \"/\", t, \"/channel\" ], o = i.createWebChannelTransport(), s = {\n // Required for backend stickiness, routing behavior is based on this\n // parameter.\n httpSessionIdParam: \"gsessionid\",\n initMessageHeaders: {},\n messageUrlParams: {\n // This param is used to improve routing and project isolation by the\n // backend and must be included in every request.\n database: \"projects/\" + this.U.projectId + \"/databases/\" + this.U.database\n },\n sendRawJson: !0,\n supportsCrossDomainXhr: !0,\n internalChannelParams: {\n // Override the default timeout (randomized between 10-20 seconds) since\n // a large write batch on a slow internet connection may take a long\n // time to send to the backend. Rather than have WebChannel impose a\n // tight timeout which could lead to infinite timeouts and retries, we\n // set it very large (5-10 minutes) and rely on the browser's builtin\n // timeouts to kick in if the request isn't working.\n forwardChannelRequestTimeoutMs: 6e5\n },\n forceLongPolling: this.forceLongPolling,\n detectBufferingProxy: this.W\n };\n this.Cl(s.initMessageHeaders, e), \n // Sending the custom headers we just added to request.initMessageHeaders\n // (Authorization, etc.) will trigger the browser to make a CORS preflight\n // request because the XHR will no longer meet the criteria for a \"simple\"\n // CORS request:\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests\n // Therefore to avoid the CORS preflight request (an extra network\n // roundtrip), we use the httpHeadersOverwriteParam option to specify that\n // the headers should instead be encoded into a special \"$httpHeaders\" query\n // parameter, which is recognized by the webchannel backend. This is\n // formally defined here:\n // https://github.com/google/closure-library/blob/b0e1815b13fb92a46d7c9b3c30de5d6a396a3245/closure/goog/net/rpc/httpcors.js#L32\n // TODO(b/145624756): There is a backend bug where $httpHeaders isn't respected if the request\n // doesn't have an Origin header. So we have to exclude a few browser environments that are\n // known to (sometimes) not include an Origin. See\n // https://github.com/firebase/firebase-js-sdk/issues/1491.\n r.isMobileCordova() || r.isReactNative() || r.isElectron() || r.isIE() || r.isUWP() || r.isBrowserExtension() || (s.httpHeadersOverwriteParam = \"$httpHeaders\");\n var u = n.join(\"\");\n l(\"Connection\", \"Creating WebChannel: \" + u, s);\n var h = o.createWebChannel(u, s), f = !1, p = !1, v = new nu({\n Il: function(t) {\n p ? l(\"Connection\", \"Not sending because WebChannel is closed:\", t) : (f || (l(\"Connection\", \"Opening WebChannel transport.\"), \n h.open(), f = !0), l(\"Connection\", \"WebChannel sending:\", t), h.send(t));\n },\n Al: function() {\n return h.close();\n }\n }), y = function(t, e) {\n // TODO(dimond): closure typing seems broken because WebChannel does\n // not implement goog.events.Listenable\n h.listen(t, (function(t) {\n try {\n e(t);\n } catch (t) {\n setTimeout((function() {\n throw t;\n }), 0);\n }\n }));\n };\n // WebChannel supports sending the first message with the handshake - saving\n // a network round trip. However, it will have to call send in the same\n // JS event loop as open. In order to enforce this, we delay actually\n // opening the WebChannel until send is called. Whether we have called\n // open is tracked with this variable.\n // Closure events are guarded and exceptions are swallowed, so catch any\n // exception and rethrow using a setTimeout so they become visible again.\n // Note that eventually this function could go away if we are confident\n // enough the code is exception free.\n return y(i.WebChannel.EventType.OPEN, (function() {\n p || l(\"Connection\", \"WebChannel transport opened.\");\n })), y(i.WebChannel.EventType.CLOSE, (function() {\n p || (p = !0, l(\"Connection\", \"WebChannel transport closed\"), v.Vl());\n })), y(i.WebChannel.EventType.ERROR, (function(t) {\n p || (p = !0, d(\"Connection\", \"WebChannel transport errored:\", t), v.Vl(new c(a.UNAVAILABLE, \"The operation could not be completed\")));\n })), y(i.WebChannel.EventType.MESSAGE, (function(t) {\n var e;\n if (!p) {\n var n = t.data[0];\n g(!!n);\n // TODO(b/35143891): There is a bug in One Platform that caused errors\n // (and only errors) to be wrapped in an extra array. To be forward\n // compatible with the bug we need to check either condition. The latter\n // can be removed once the fix has been rolled out.\n // Use any because msgData.error is not typed.\n var r = n, i = r.error || (null === (e = r[0]) || void 0 === e ? void 0 : e.error);\n if (i) {\n l(\"Connection\", \"WebChannel received error:\", i);\n // error.status will be a string like 'OK' or 'NOT_FOUND'.\n var o = i.status, s = function(t) {\n // lookup by string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n var e = vt[t];\n if (void 0 !== e) return _t(e);\n }(o), u = i.message;\n void 0 === s && (s = a.INTERNAL, u = \"Unknown error status: \" + o + \" with message \" + i.message), \n // Mark closed so no further events are propagated\n p = !0, v.Vl(new c(s, u)), h.close();\n } else l(\"Connection\", \"WebChannel received:\", n), v.pl(n);\n }\n })), setTimeout((function() {\n // Technically we could/should wait for the WebChannel opened event,\n // but because we want to send the first message with the WebChannel\n // handshake we pretend the channel opened here (asynchronously), and\n // then delay the actual open until the first message is sent.\n v.yl();\n }), 0), v;\n }, n;\n}(/** @class */ function() {\n function t(t) {\n this.bl = t, this.U = t.U;\n var e = t.ssl ? \"https\" : \"http\";\n this.vl = e + \"://\" + t.host, this.Sl = \"projects/\" + this.U.projectId + \"/databases/\" + this.U.database + \"/documents\";\n }\n return t.prototype.$u = function(t, e, n, r) {\n var i = this.Dl(t, e);\n l(\"RestConnection\", \"Sending: \", i, n);\n var o = {};\n return this.Cl(o, r), this.Nl(t, i, o, n).then((function(t) {\n return l(\"RestConnection\", \"Received: \", t), t;\n }), (function(e) {\n throw d(\"RestConnection\", t + \" failed with error: \", e, \"url: \", i, \"request:\", n), \n e;\n }));\n }, t.prototype.ku = function(t, e, n, r) {\n // The REST API automatically aggregates all of the streamed results, so we\n // can just use the normal invoke() method.\n return this.$u(t, e, n, r);\n }, \n /**\n * Modifies the headers for a request, adding any authorization token if\n * present and any additional headers for the request.\n */\n t.prototype.Cl = function(t, e) {\n if (t[\"X-Goog-Api-Client\"] = \"gl-js/ fire/7.24.0\", \n // Content-Type: text/plain will avoid preflight requests which might\n // mess with CORS and redirects by proxies. If we add custom headers\n // we will need to change this code to potentially use the $httpOverwrite\n // parameter supported by ESF to avoid triggering preflight requests.\n t[\"Content-Type\"] = \"text/plain\", e) for (var n in e.Kc) e.Kc.hasOwnProperty(n) && (t[n] = e.Kc[n]);\n }, t.prototype.Dl = function(t, e) {\n var n = ru[t];\n return this.vl + \"/v1/\" + e + \":\" + n;\n }, t;\n}()), ou = /** @class */ function() {\n function t() {\n var t = this;\n this.Fl = function() {\n return t.xl();\n }, this.$l = function() {\n return t.kl();\n }, this.Ml = [], this.Ol();\n }\n return t.prototype.Zu = function(t) {\n this.Ml.push(t);\n }, t.prototype.Di = function() {\n window.removeEventListener(\"online\", this.Fl), window.removeEventListener(\"offline\", this.$l);\n }, t.prototype.Ol = function() {\n window.addEventListener(\"online\", this.Fl), window.addEventListener(\"offline\", this.$l);\n }, t.prototype.xl = function() {\n l(\"ConnectivityMonitor\", \"Network connectivity changed: AVAILABLE\");\n for (var t = 0, e = this.Ml; t < e.length; t++) {\n (0, e[t])(0 /* AVAILABLE */);\n }\n }, t.prototype.kl = function() {\n l(\"ConnectivityMonitor\", \"Network connectivity changed: UNAVAILABLE\");\n for (var t = 0, e = this.Ml; t < e.length; t++) {\n (0, e[t])(1 /* UNAVAILABLE */);\n }\n }, \n // TODO(chenbrian): Consider passing in window either into this component or\n // here for testing via FakeWindow.\n /** Checks that all used attributes of window are available. */\n t.Ln = function() {\n return \"undefined\" != typeof window && void 0 !== window.addEventListener && void 0 !== window.removeEventListener;\n }, t;\n}(), su = /** @class */ function() {\n function t() {}\n return t.prototype.Zu = function(t) {\n // No-op.\n }, t.prototype.Di = function() {\n // No-op.\n }, t;\n}();\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/** Initializes the WebChannelConnection for the browser. */\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nfunction uu(t) {\n return new ye(t, /* useProto3Json= */ !0);\n}\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */ var au = \"You are using the memory-only build of Firestore. Persistence support is only available via the @firebase/firestore bundle or the firebase-firestore.js build.\", cu = /** @class */ function() {\n function e() {}\n return e.prototype.initialize = function(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return this.Sh = this.Ll(e), this.persistence = this.Bl(e), [ 4 /*yield*/ , this.persistence.start() ];\n\n case 1:\n return t.sent(), this.ql = this.Ul(e), this.ju = this.Ql(e), [ 2 /*return*/ ];\n }\n }));\n }));\n }, e.prototype.Ul = function(t) {\n return null;\n }, e.prototype.Ql = function(t) {\n /** Manages our in-memory or durable persistence. */\n return e = this.persistence, n = new Hs, r = t.Wl, new go(e, n, r);\n var e, n, r;\n }, e.prototype.Bl = function(t) {\n if (t.persistenceSettings.jl) throw new c(a.FAILED_PRECONDITION, au);\n return new Zs(eu.ml);\n }, e.prototype.Ll = function(t) {\n return new $r;\n }, e.prototype.terminate = function() {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return this.ql && this.ql.stop(), [ 4 /*yield*/ , this.Sh.Di() ];\n\n case 1:\n return t.sent(), [ 4 /*yield*/ , this.persistence.Di() ];\n\n case 2:\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n }, e.prototype.clearPersistence = function(t, e) {\n throw new c(a.FAILED_PRECONDITION, au);\n }, e;\n}(), hu = /** @class */ function(e) {\n function n() {\n return null !== e && e.apply(this, arguments) || this;\n }\n return t.__extends(n, e), n.prototype.initialize = function(n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i = this;\n return t.__generator(this, (function(o) {\n switch (o.label) {\n case 0:\n return [ 4 /*yield*/ , e.prototype.initialize.call(this, n) ];\n\n case 1:\n return o.sent(), r = this.Kl.fi, this.Sh instanceof Yr ? (this.Sh.fi = {\n er: Ms.bind(null, r),\n nr: Bs.bind(null, r),\n sr: Ws.bind(null, r),\n pi: zs.bind(null, r)\n }, [ 4 /*yield*/ , this.Sh.start() ]) : [ 3 /*break*/ , 3 ];\n\n case 2:\n o.sent(), o.label = 3;\n\n case 3:\n // NOTE: This will immediately call the listener, so we make sure to\n // set it after localStore / remoteStore are started.\n return [ 4 /*yield*/ , this.persistence.Xa((function(e) {\n return t.__awaiter(i, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return [ 4 /*yield*/ , qs(this.Kl.fi, e) ];\n\n case 1:\n return t.sent(), this.ql && (e && !this.ql.Ei ? this.ql.start(this.ju) : e || this.ql.stop()), \n [ 2 /*return*/ ];\n }\n }));\n }));\n })) ];\n\n case 4:\n // NOTE: This will immediately call the listener, so we make sure to\n // set it after localStore / remoteStore are started.\n return o.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n }, n.prototype.Ll = function(t) {\n if (t.persistenceSettings.jl && t.persistenceSettings.synchronizeTabs) {\n var e = Ar();\n if (!Yr.Ln(e)) throw new c(a.UNIMPLEMENTED, \"IndexedDB persistence is only available on platforms that support LocalStorage.\");\n var n = yo(t.bl.U, t.bl.persistenceKey);\n return new Yr(e, t.cs, n, t.clientId, t.Wl);\n }\n return new $r;\n }, n;\n}(/** @class */ function(e) {\n function n(t) {\n var n = this;\n return (n = e.call(this) || this).Kl = t, n;\n }\n return t.__extends(n, e), n.prototype.initialize = function(n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return [ 4 /*yield*/ , e.prototype.initialize.call(this, n) ];\n\n case 1:\n return t.sent(), [ 4 /*yield*/ , So(this.ju) ];\n\n case 2:\n return t.sent(), [ 4 /*yield*/ , this.Kl.initialize(this, n) ];\n\n case 3:\n // Enqueue writes from a previous session\n return t.sent(), [ 4 /*yield*/ , Qs(this.Kl.fi) ];\n\n case 4:\n // Enqueue writes from a previous session\n return t.sent(), [ 4 /*yield*/ , is(this.Kl.ph) ];\n\n case 5:\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n }, n.prototype.Ul = function(t) {\n var e = this.persistence.No.wo;\n return new ai(e, t.cs);\n }, n.prototype.Bl = function(t) {\n var e = yo(t.bl.U, t.bl.persistenceKey), n = uu(t.bl.U);\n return new ho(t.persistenceSettings.synchronizeTabs, e, t.clientId, ui.ao(t.persistenceSettings.cacheSizeBytes), t.cs, Ar(), Sr(), n, this.Sh, t.persistenceSettings.ka);\n }, n.prototype.Ll = function(t) {\n return new $r;\n }, n.prototype.clearPersistence = function(e, n) {\n return function(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return gr.Ln() ? (n = e + \"main\", [ 4 /*yield*/ , gr.delete(n) ]) : [ 2 /*return*/ , Promise.resolve() ];\n\n case 1:\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n }(yo(e, n));\n }, n;\n}(cu)), fu = /** @class */ function() {\n function e() {}\n return e.prototype.initialize = function(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r = this;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return this.ju ? [ 3 /*break*/ , 2 ] : (this.ju = e.ju, this.Sh = e.Sh, this.Ku = this.Gl(n), \n this.ph = this.zl(n), this.bh = this.Hl(n), this.fi = this.Yl(n), this.Sh.di = function(t) {\n return Ts(r.fi, t, 1 /* SharedClientState */);\n }, this.ph.Gu.Jl = Us.bind(null, this.fi), [ 4 /*yield*/ , fs(this.ph, this.fi.Uh) ]);\n\n case 1:\n t.sent(), t.label = 2;\n\n case 2:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }, e.prototype.Hl = function(t) {\n return new Rr;\n }, e.prototype.Gl = function(t) {\n var e, n = uu(t.bl.U), r = (e = t.bl, new iu(e));\n /** Return the Platform-specific connectivity monitor. */ return function(t, e, n) {\n return new Mo(t, e, n);\n }(t.credentials, r, n);\n }, e.prototype.zl = function(t) {\n var e, n, r, i, o, s = this;\n return e = this.ju, n = this.Ku, r = t.cs, i = function(t) {\n return Ts(s.fi, t, 0 /* RemoteStore */);\n }, o = ou.Ln() ? new ou : new su, new jo(e, n, r, i, o);\n }, e.prototype.Yl = function(t) {\n return function(t, e, n, \n // PORTING NOTE: Manages state synchronization in multi-tab environments.\n r, i, o, s) {\n var u = new ws(t, e, n, r, i, o);\n return s && (u.qh = !0), u;\n }(this.ju, this.ph, this.bh, this.Sh, t.Wl, t.Dh, !t.persistenceSettings.jl || !t.persistenceSettings.synchronizeTabs);\n }, e.prototype.terminate = function() {\n return Bo(this.ph);\n }, e;\n}(), lu = /** @class */ function() {\n function t(t) {\n this.observer = t, \n /**\n * When set to true, will not raise future events. Necessary to deal with\n * async detachment of listener.\n */\n this.muted = !1;\n }\n return t.prototype.next = function(t) {\n this.observer.next && this.Xl(this.observer.next, t);\n }, t.prototype.error = function(t) {\n this.observer.error ? this.Xl(this.observer.error, t) : console.error(\"Uncaught Error in snapshot listener:\", t);\n }, t.prototype.Zl = function() {\n this.muted = !0;\n }, t.prototype.Xl = function(t, e) {\n var n = this;\n this.muted || setTimeout((function() {\n n.muted || t(e);\n }), 0);\n }, t;\n}(), pu = function(t) {\n !function(t, e, n, r) {\n if (!(e instanceof Array) || e.length < 1) throw new c(a.INVALID_ARGUMENT, \"Function FieldPath() requires its fieldNames argument to be an array with at least \" + W(1, \"element\") + \".\");\n }(0, t);\n for (var e = 0; e < t.length; ++e) if (k(\"FieldPath\", \"string\", e, t[e]), 0 === t[e].length) throw new c(a.INVALID_ARGUMENT, \"Invalid field name at argument $(i + 1). Field names must not be empty.\");\n this.t_ = new N(t);\n}, du = /** @class */ function(e) {\n /**\n * Creates a FieldPath from the provided field names. If more than one field\n * name is provided, the path will point to a nested field in a document.\n *\n * @param fieldNames A list of field names.\n */\n function n() {\n for (var t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];\n return e.call(this, t) || this;\n }\n return t.__extends(n, e), n.documentId = function() {\n /**\n * Internal Note: The backend doesn't technically support querying by\n * document ID. Instead it queries by the entire document name (full path\n * included), but in the cases we currently support documentId(), the net\n * effect is the same.\n */\n return new n(N.v().R());\n }, n.prototype.isEqual = function(t) {\n if (!(t instanceof n)) throw G(\"isEqual\", \"FieldPath\", 1, t);\n return this.t_.isEqual(t.t_);\n }, n;\n}(pu), vu = new RegExp(\"[~\\\\*/\\\\[\\\\]]\"), yu = \n/**\n * @param _methodName The public API endpoint that returns this class.\n */\nfunction(t) {\n this.e_ = t;\n}, gu = /** @class */ function(e) {\n function n() {\n return null !== e && e.apply(this, arguments) || this;\n }\n return t.__extends(n, e), n.prototype.n_ = function(t) {\n if (2 /* MergeSet */ !== t.s_) throw 1 /* Update */ === t.s_ ? t.i_(this.e_ + \"() can only appear at the top level of your update data\") : t.i_(this.e_ + \"() cannot be used with set() unless you pass {merge:true}\");\n // No transform to add for a delete, but we need to add it to our\n // fieldMask so it gets deleted.\n return t.We.push(t.path), null;\n }, n.prototype.isEqual = function(t) {\n return t instanceof n;\n }, n;\n}(yu);\n\n/**\n * Provides all components needed for Firestore with in-memory persistence.\n * Uses EagerGC garbage collection.\n */\n/**\n * Creates a child context for parsing SerializableFieldValues.\n *\n * This is different than calling `ParseContext.contextWith` because it keeps\n * the fieldTransforms and fieldMask separate.\n *\n * The created context has its `dataSource` set to `UserDataSource.Argument`.\n * Although these values are used with writes, any elements in these FieldValues\n * are not considered writes since they cannot contain any FieldValue sentinels,\n * etc.\n *\n * @param fieldValue The sentinel FieldValue for which to create a child\n * context.\n * @param context The parent context.\n * @param arrayElement Whether or not the FieldValue has an array.\n */\nfunction mu(t, e, n) {\n return new Lu({\n s_: 3 /* Argument */ ,\n r_: e.settings.r_,\n methodName: t.e_,\n o_: n\n }, e.U, e.serializer, e.ignoreUndefinedProperties);\n}\n\nvar wu = /** @class */ function(e) {\n function n() {\n return null !== e && e.apply(this, arguments) || this;\n }\n return t.__extends(n, e), n.prototype.n_ = function(t) {\n return new cn(t.path, new Ze);\n }, n.prototype.isEqual = function(t) {\n return t instanceof n;\n }, n;\n}(yu), _u = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this, t) || this).a_ = n, r;\n }\n return t.__extends(n, e), n.prototype.n_ = function(t) {\n var e = mu(this, t, \n /*array=*/ !0), n = this.a_.map((function(t) {\n return Uu(t, e);\n })), r = new tn(n);\n return new cn(t.path, r);\n }, n.prototype.isEqual = function(t) {\n // TODO(mrschmidt): Implement isEquals\n return this === t;\n }, n;\n}(yu), bu = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this, t) || this).a_ = n, r;\n }\n return t.__extends(n, e), n.prototype.n_ = function(t) {\n var e = mu(this, t, \n /*array=*/ !0), n = this.a_.map((function(t) {\n return Uu(t, e);\n })), r = new nn(n);\n return new cn(t.path, r);\n }, n.prototype.isEqual = function(t) {\n // TODO(mrschmidt): Implement isEquals\n return this === t;\n }, n;\n}(yu), Iu = /** @class */ function(e) {\n function n(t, n) {\n var r = this;\n return (r = e.call(this, t) || this).c_ = n, r;\n }\n return t.__extends(n, e), n.prototype.n_ = function(t) {\n var e = new on(t.serializer, we(t.serializer, this.c_));\n return new cn(t.path, e);\n }, n.prototype.isEqual = function(t) {\n // TODO(mrschmidt): Implement isEquals\n return this === t;\n }, n;\n}(yu), Eu = /** @class */ function() {\n /**\n * Creates a new immutable `GeoPoint` object with the provided latitude and\n * longitude values.\n * @param latitude The latitude as number between -90 and 90.\n * @param longitude The longitude as number between -180 and 180.\n */\n function t(t, e) {\n if (D(\"GeoPoint\", arguments, 2), k(\"GeoPoint\", \"number\", 1, t), k(\"GeoPoint\", \"number\", 2, e), \n !isFinite(t) || t < -90 || t > 90) throw new c(a.INVALID_ARGUMENT, \"Latitude must be a number between -90 and 90, but was: \" + t);\n if (!isFinite(e) || e < -180 || e > 180) throw new c(a.INVALID_ARGUMENT, \"Longitude must be a number between -180 and 180, but was: \" + e);\n this.u_ = t, this.h_ = e;\n }\n return Object.defineProperty(t.prototype, \"latitude\", {\n /**\n * The latitude of this `GeoPoint` instance.\n */\n get: function() {\n return this.u_;\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"longitude\", {\n /**\n * The longitude of this `GeoPoint` instance.\n */\n get: function() {\n return this.h_;\n },\n enumerable: !1,\n configurable: !0\n }), \n /**\n * Returns true if this `GeoPoint` is equal to the provided one.\n *\n * @param other The `GeoPoint` to compare against.\n * @return true if this `GeoPoint` is equal to the provided one.\n */\n t.prototype.isEqual = function(t) {\n return this.u_ === t.u_ && this.h_ === t.h_;\n }, t.prototype.toJSON = function() {\n return {\n latitude: this.u_,\n longitude: this.h_\n };\n }, \n /**\n * Actually private to JS consumers of our API, so this function is prefixed\n * with an underscore.\n */\n t.prototype.Y = function(t) {\n return H(this.u_, t.u_) || H(this.h_, t.h_);\n }, t;\n}(), Tu = function(t) {\n this.l_ = t;\n}, Nu = /^__.*__$/, Au = function(t, e, n) {\n this.__ = t, this.f_ = e, this.d_ = n;\n}, Su = /** @class */ function() {\n function t(t, e, n) {\n this.data = t, this.We = e, this.fieldTransforms = n;\n }\n return t.prototype.w_ = function(t, e) {\n var n = [];\n return null !== this.We ? n.push(new _n(t, this.data, this.We, e)) : n.push(new wn(t, this.data, e)), \n this.fieldTransforms.length > 0 && n.push(new In(t, this.fieldTransforms)), n;\n }, t;\n}(), Du = /** @class */ function() {\n function t(t, e, n) {\n this.data = t, this.We = e, this.fieldTransforms = n;\n }\n return t.prototype.w_ = function(t, e) {\n var n = [ new _n(t, this.data, this.We, e) ];\n return this.fieldTransforms.length > 0 && n.push(new In(t, this.fieldTransforms)), \n n;\n }, t;\n}();\n\nfunction xu(t) {\n switch (t) {\n case 0 /* Set */ :\n // fall through\n case 2 /* MergeSet */ :\n // fall through\n case 1 /* Update */ :\n return !0;\n\n case 3 /* Argument */ :\n case 4 /* ArrayArgument */ :\n return !1;\n\n default:\n throw y();\n }\n}\n\n/** A \"context\" object passed around while parsing user data. */ var Lu = /** @class */ function() {\n /**\n * Initializes a ParseContext with the given source and path.\n *\n * @param settings The settings for the parser.\n * @param databaseId The database ID of the Firestore instance.\n * @param serializer The serializer to use to generate the Value proto.\n * @param ignoreUndefinedProperties Whether to ignore undefined properties\n * rather than throw.\n * @param fieldTransforms A mutable list of field transforms encountered while\n * parsing the data.\n * @param fieldMask A mutable list of field paths encountered while parsing\n * the data.\n *\n * TODO(b/34871131): We don't support array paths right now, so path can be\n * null to indicate the context represents any location within an array (in\n * which case certain features will not work and errors will be somewhat\n * compromised).\n */\n function t(t, e, n, r, i, o) {\n this.settings = t, this.U = e, this.serializer = n, this.ignoreUndefinedProperties = r, \n // Minor hack: If fieldTransforms is undefined, we assume this is an\n // external call and we need to validate the entire path.\n void 0 === i && this.m_(), this.fieldTransforms = i || [], this.We = o || [];\n }\n return Object.defineProperty(t.prototype, \"path\", {\n get: function() {\n return this.settings.path;\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"s_\", {\n get: function() {\n return this.settings.s_;\n },\n enumerable: !1,\n configurable: !0\n }), \n /** Returns a new context with the specified settings overwritten. */ t.prototype.T_ = function(e) {\n return new t(Object.assign(Object.assign({}, this.settings), e), this.U, this.serializer, this.ignoreUndefinedProperties, this.fieldTransforms, this.We);\n }, t.prototype.E_ = function(t) {\n var e, n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.T_({\n path: n,\n o_: !1\n });\n return r.I_(t), r;\n }, t.prototype.A_ = function(t) {\n var e, n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.T_({\n path: n,\n o_: !1\n });\n return r.m_(), r;\n }, t.prototype.R_ = function(t) {\n // TODO(b/34871131): We don't support array paths right now; so make path\n // undefined.\n return this.T_({\n path: void 0,\n o_: !0\n });\n }, t.prototype.i_ = function(t) {\n return Gu(t, this.settings.methodName, this.settings.g_ || !1, this.path, this.settings.r_);\n }, \n /** Returns 'true' if 'fieldPath' was traversed when creating this context. */ t.prototype.contains = function(t) {\n return void 0 !== this.We.find((function(e) {\n return t.T(e);\n })) || void 0 !== this.fieldTransforms.find((function(e) {\n return t.T(e.field);\n }));\n }, t.prototype.m_ = function() {\n // TODO(b/34871131): Remove null check once we have proper paths for fields\n // within arrays.\n if (this.path) for (var t = 0; t < this.path.length; t++) this.I_(this.path.get(t));\n }, t.prototype.I_ = function(t) {\n if (0 === t.length) throw this.i_(\"Document fields must not be empty\");\n if (xu(this.s_) && Nu.test(t)) throw this.i_('Document fields cannot begin and end with \"__\"');\n }, t;\n}(), ku = /** @class */ function() {\n function t(t, e, n) {\n this.U = t, this.ignoreUndefinedProperties = e, this.serializer = n || uu(t)\n /** Creates a new top-level parse context. */;\n }\n return t.prototype.P_ = function(t, e, n, r) {\n return void 0 === r && (r = !1), new Lu({\n s_: t,\n methodName: e,\n r_: n,\n path: N.P(),\n o_: !1,\n g_: r\n }, this.U, this.serializer, this.ignoreUndefinedProperties);\n }, t;\n}();\n\n/**\n * Helper for parsing raw user input (provided via the API) into internal model\n * classes.\n */\n/** Parse document data from a set() call. */ function Ru(t, e, n, r, i, o) {\n void 0 === o && (o = {});\n var s = t.P_(o.merge || o.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, i);\n Mu(\"Data must be an object, but it was:\", s, r);\n var u, h, f = Cu(r, s);\n if (o.merge) u = new an(s.We), h = s.fieldTransforms; else if (o.mergeFields) {\n for (var l = [], p = 0, d = o.mergeFields; p < d.length; p++) {\n var v = d[p], g = void 0;\n if (v instanceof pu) g = v.t_; else {\n if (\"string\" != typeof v) throw y();\n g = ju(e, v, n);\n }\n if (!s.contains(g)) throw new c(a.INVALID_ARGUMENT, \"Field '\" + g + \"' is specified in your field mask but missing from your input data.\");\n zu(l, g) || l.push(g);\n }\n u = new an(l), h = s.fieldTransforms.filter((function(t) {\n return u.Ye(t.field);\n }));\n } else u = null, h = s.fieldTransforms;\n return new Su(new Sn(f), u, h);\n}\n\n/** Parse update data from an update() call. */ function Ou(t, e, n, r) {\n var i = t.P_(1 /* Update */ , e, n);\n Mu(\"Data must be an object, but it was:\", i, r);\n var o = [], s = new Dn;\n _(r, (function(t, r) {\n var u = ju(e, t, n), a = i.A_(u);\n if (r instanceof gu || r instanceof Tu && r.l_ instanceof gu) \n // Add it to the field mask, but don't add anything to updateData.\n o.push(u); else {\n var c = Uu(r, a);\n null != c && (o.push(u), s.set(u, c));\n }\n }));\n var u = new an(o);\n return new Du(s.Xe(), u, i.fieldTransforms);\n}\n\n/** Parse update data from a list of field/value arguments. */ function Pu(t, e, n, r, i, o) {\n var s = t.P_(1 /* Update */ , e, n), u = [ qu(e, r, n) ], h = [ i ];\n if (o.length % 2 != 0) throw new c(a.INVALID_ARGUMENT, \"Function \" + e + \"() needs to be called with an even number of arguments that alternate between field names and values.\");\n for (var f = 0; f < o.length; f += 2) u.push(qu(e, o[f])), h.push(o[f + 1]);\n // We iterate in reverse order to pick the last value for a field if the\n // user specified the field multiple times.\n for (var l = [], p = new Dn, d = u.length - 1; d >= 0; --d) if (!zu(l, u[d])) {\n var v = u[d], y = h[d], g = s.A_(v);\n if (y instanceof gu || y instanceof Tu && y.l_ instanceof gu) \n // Add it to the field mask, but don't add anything to updateData.\n l.push(v); else {\n var m = Uu(y, g);\n null != m && (l.push(v), p.set(v, m));\n }\n }\n var w = new an(l);\n return new Du(p.Xe(), w, s.fieldTransforms);\n}\n\n/**\n * Parse a \"query value\" (e.g. value in a where filter or a value in a cursor\n * bound).\n *\n * @param allowArrays Whether the query value is an array that may directly\n * contain additional arrays (e.g. the operand of an `in` query).\n */ function Vu(t, e, n, r) {\n return void 0 === r && (r = !1), Uu(n, t.P_(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));\n}\n\n/**\n * Parses user data to Protobuf Values.\n *\n * @param input Data to be parsed.\n * @param context A context object representing the current path being parsed,\n * the source of the data being parsed, etc.\n * @return The parsed value, or null if the value was a FieldValue sentinel\n * that should not be included in the resulting parsed data.\n */ function Uu(t, e) {\n if (\n // Unwrap the API type from the Compat SDK. This will return the API type\n // from firestore-exp.\n t instanceof Tu && (t = t.l_), Fu(t)) return Mu(\"Unsupported field value:\", e, t), \n Cu(t, e);\n if (t instanceof yu) \n // FieldValues usually parse into transforms (except FieldValue.delete())\n // in which case we do not want to include this field in our parsed data\n // (as doing so will overwrite the field directly prior to the transform\n // trying to transform it). So we don't add this location to\n // context.fieldMask and we return null as our parsing result.\n /**\n * \"Parses\" the provided FieldValueImpl, adding any necessary transforms to\n * context.fieldTransforms.\n */\n return function(t, e) {\n // Sentinels are only supported with writes, and not within arrays.\n if (!xu(e.s_)) throw e.i_(t.e_ + \"() can only be used with update() and set()\");\n if (!e.path) throw e.i_(t.e_ + \"() is not currently supported inside arrays\");\n var n = t.n_(e);\n n && e.fieldTransforms.push(n);\n }(t, e), null;\n if (\n // If context.path is null we are inside an array and we don't support\n // field mask paths more granular than the top-level array.\n e.path && e.We.push(e.path), t instanceof Array) {\n // TODO(b/34871131): Include the path containing the array in the error\n // message.\n // In the case of IN queries, the parsed data is an array (representing\n // the set of values to be included for the IN query) that may directly\n // contain additional arrays (each representing an individual field\n // value), so we disable this validation.\n if (e.settings.o_ && 4 /* ArrayArgument */ !== e.s_) throw e.i_(\"Nested arrays are not supported\");\n return function(t, e) {\n for (var n = [], r = 0, i = 0, o = t; i < o.length; i++) {\n var s = Uu(o[i], e.R_(r));\n null == s && (\n // Just include nulls in the array for fields being replaced with a\n // sentinel.\n s = {\n nullValue: \"NULL_VALUE\"\n }), n.push(s), r++;\n }\n return {\n arrayValue: {\n values: n\n }\n };\n }(t, e);\n }\n return function(t, e) {\n if (null === t) return {\n nullValue: \"NULL_VALUE\"\n };\n if (\"number\" == typeof t) return we(e.serializer, t);\n if (\"boolean\" == typeof t) return {\n booleanValue: t\n };\n if (\"string\" == typeof t) return {\n stringValue: t\n };\n if (t instanceof Date) {\n var n = ot.fromDate(t);\n return {\n timestampValue: _e(e.serializer, n)\n };\n }\n if (t instanceof ot) {\n // Firestore backend truncates precision down to microseconds. To ensure\n // offline mode works the same with regards to truncation, perform the\n // truncation immediately without waiting for the backend to do that.\n var r = new ot(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));\n return {\n timestampValue: _e(e.serializer, r)\n };\n }\n if (t instanceof Eu) return {\n geoPointValue: {\n latitude: t.latitude,\n longitude: t.longitude\n }\n };\n if (t instanceof J) return {\n bytesValue: be(e.serializer, t.q)\n };\n if (t instanceof Au) {\n var i = e.U, o = t.__;\n if (!o.isEqual(i)) throw e.i_(\"Document reference is for database \" + o.projectId + \"/\" + o.database + \" but should be for database \" + i.projectId + \"/\" + i.database);\n return {\n referenceValue: Te(t.__ || e.U, t.f_.path)\n };\n }\n if (void 0 === t && e.ignoreUndefinedProperties) return null;\n throw e.i_(\"Unsupported field value: \" + M(t));\n }(t, e);\n}\n\nfunction Cu(t, e) {\n var n = {};\n return b(t) ? \n // If we encounter an empty object, we explicitly add it to the update\n // mask to ensure that the server creates a map entry.\n e.path && e.path.length > 0 && e.We.push(e.path) : _(t, (function(t, r) {\n var i = Uu(r, e.E_(t));\n null != i && (n[t] = i);\n })), {\n mapValue: {\n fields: n\n }\n };\n}\n\nfunction Fu(t) {\n return !(\"object\" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof ot || t instanceof Eu || t instanceof J || t instanceof Au || t instanceof yu);\n}\n\nfunction Mu(t, e, n) {\n if (!Fu(n) || !F(n)) {\n var r = M(n);\n throw \"an object\" === r ? e.i_(t + \" a custom object\") : e.i_(t + \" \" + r);\n }\n}\n\n/**\n * Helper that calls fromDotSeparatedString() but wraps any error thrown.\n */ function qu(t, e, n) {\n if (e instanceof pu) return e.t_;\n if (\"string\" == typeof e) return ju(t, e);\n throw Gu(\"Field path arguments must be of type string or FieldPath.\", t, \n /* hasConverter= */ !1, \n /* path= */ void 0, n);\n}\n\n/**\n * Wraps fromDotSeparatedString with an error message about the method that\n * was thrown.\n * @param methodName The publicly visible method name\n * @param path The dot-separated string form of a field path which will be split\n * on dots.\n * @param targetDoc The document against which the field path will be evaluated.\n */ function ju(e, n, r) {\n try {\n return function(e) {\n if (e.search(vu) >= 0) throw new c(a.INVALID_ARGUMENT, \"Invalid field path (\" + e + \"). Paths must not contain '~', '*', '/', '[', or ']'\");\n try {\n return new (du.bind.apply(du, t.__spreadArrays([ void 0 ], e.split(\".\"))));\n } catch (t) {\n throw new c(a.INVALID_ARGUMENT, \"Invalid field path (\" + e + \"). Paths must not be empty, begin with '.', end with '.', or contain '..'\");\n }\n }(n).t_;\n } catch (n) {\n throw Gu((i = n) instanceof Error ? i.message : i.toString(), e, \n /* hasConverter= */ !1, \n /* path= */ void 0, r);\n }\n /**\n * Extracts the message from a caught exception, which should be an Error object\n * though JS doesn't guarantee that.\n */ var i;\n /** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */}\n\nfunction Gu(t, e, n, r, i) {\n var o = r && !r.m(), s = void 0 !== i, u = \"Function \" + e + \"() called with invalid data\";\n n && (u += \" (via `toFirestore()`)\");\n var h = \"\";\n return (o || s) && (h += \" (found\", o && (h += \" in field \" + r), s && (h += \" in document \" + i), \n h += \")\"), new c(a.INVALID_ARGUMENT, (u += \". \") + t + h);\n}\n\nfunction zu(t, e) {\n return t.some((function(t) {\n return t.isEqual(e);\n }));\n}\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Internal transaction object responsible for accumulating the mutations to\n * perform and the base versions for any documents read.\n */ var Bu = /** @class */ function() {\n function e(t) {\n this.Ku = t, \n // The version of each document that was read during this transaction.\n this.y_ = new Map, this.mutations = [], this.V_ = !1, \n /**\n * A deferred usage error that occurred previously in this transaction that\n * will cause the transaction to fail once it actually commits.\n */\n this.p_ = null, \n /**\n * Set of documents that have been written in the transaction.\n *\n * When there's more than one write to the same key in a transaction, any\n * writes after the first are handled differently.\n */\n this.b_ = new Set;\n }\n return e.prototype.v_ = function(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n, r = this;\n return t.__generator(this, (function(i) {\n switch (i.label) {\n case 0:\n if (this.S_(), this.mutations.length > 0) throw new c(a.INVALID_ARGUMENT, \"Firestore transactions require all reads to be executed before all writes.\");\n return [ 4 /*yield*/ , function(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o, s, u, a;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return r = m(e), i = Le(r.serializer) + \"/documents\", o = {\n documents: n.map((function(t) {\n return Ae(r.serializer, t);\n }))\n }, [ 4 /*yield*/ , r.ku(\"BatchGetDocuments\", i, o) ];\n\n case 1:\n return s = t.sent(), u = new Map, s.forEach((function(t) {\n var e = function(t, e) {\n return \"found\" in e ? function(t, e) {\n g(!!e.found), e.found.name, e.found.updateTime;\n var n = Se(t, e.found.name), r = Ee(e.found.updateTime), i = new Sn({\n mapValue: {\n fields: e.found.fields\n }\n });\n return new kn(n, r, i, {});\n }(t, e) : \"missing\" in e ? function(t, e) {\n g(!!e.missing), g(!!e.readTime);\n var n = Se(t, e.missing), r = Ee(e.readTime);\n return new Rn(n, r);\n }(t, e) : y();\n }(r.serializer, t);\n u.set(e.key.toString(), e);\n })), a = [], [ 2 /*return*/ , (n.forEach((function(t) {\n var e = u.get(t.toString());\n g(!!e), a.push(e);\n })), a) ];\n }\n }));\n }));\n }(this.Ku, e) ];\n\n case 1:\n return [ 2 /*return*/ , ((n = i.sent()).forEach((function(t) {\n t instanceof Rn || t instanceof kn ? r.D_(t) : y();\n })), n) ];\n }\n }));\n }));\n }, e.prototype.set = function(t, e) {\n this.write(e.w_(t, this.Ge(t))), this.b_.add(t.toString());\n }, e.prototype.update = function(t, e) {\n try {\n this.write(e.w_(t, this.C_(t)));\n } catch (t) {\n this.p_ = t;\n }\n this.b_.add(t.toString());\n }, e.prototype.delete = function(t) {\n this.write([ new Nn(t, this.Ge(t)) ]), this.b_.add(t.toString());\n }, e.prototype.commit = function() {\n return t.__awaiter(this, void 0, void 0, (function() {\n var e, n = this;\n return t.__generator(this, (function(r) {\n switch (r.label) {\n case 0:\n if (this.S_(), this.p_) throw this.p_;\n return e = this.y_, \n // For each mutation, note that the doc was written.\n this.mutations.forEach((function(t) {\n e.delete(t.key.toString());\n })), \n // For each document that was read but not written to, we want to perform\n // a `verify` operation.\n e.forEach((function(t, e) {\n var r = A.D(e);\n n.mutations.push(new An(r, n.Ge(r)));\n })), [ 4 /*yield*/ , function(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return r = m(e), i = Le(r.serializer) + \"/documents\", o = {\n writes: n.map((function(t) {\n return Oe(r.serializer, t);\n }))\n }, [ 4 /*yield*/ , r.$u(\"Commit\", i, o) ];\n\n case 1:\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n }(this.Ku, this.mutations) ];\n\n case 1:\n // For each mutation, note that the doc was written.\n return r.sent(), this.V_ = !0, [ 2 /*return*/ ];\n }\n }));\n }));\n }, e.prototype.D_ = function(t) {\n var e;\n if (t instanceof kn) e = t.version; else {\n if (!(t instanceof Rn)) throw y();\n // For deleted docs, we must use baseVersion 0 when we overwrite them.\n e = st.min();\n }\n var n = this.y_.get(t.key.toString());\n if (n) {\n if (!e.isEqual(n)) \n // This transaction will fail no matter what.\n throw new c(a.ABORTED, \"Document version changed between two reads.\");\n } else this.y_.set(t.key.toString(), e);\n }, \n /**\n * Returns the version of this document when it was read in this transaction,\n * as a precondition, or no precondition if it was not read.\n */\n e.prototype.Ge = function(t) {\n var e = this.y_.get(t.toString());\n return !this.b_.has(t.toString()) && e ? fn.updateTime(e) : fn.ze();\n }, \n /**\n * Returns the precondition for a document if the operation is an update.\n */\n e.prototype.C_ = function(t) {\n var e = this.y_.get(t.toString());\n // The first time a document is written, we want to take into account the\n // read time and existence\n if (!this.b_.has(t.toString()) && e) {\n if (e.isEqual(st.min())) \n // The document doesn't exist, so fail the transaction.\n // This has to be validated locally because you can't send a\n // precondition that a document does not exist without changing the\n // semantics of the backend write to be an insert. This is the reverse\n // of what we want, since we want to assert that the document doesn't\n // exist but then send the update and have it fail. Since we can't\n // express that to the backend, we have to validate locally.\n // Note: this can change once we can send separate verify writes in the\n // transaction.\n throw new c(a.INVALID_ARGUMENT, \"Can't update a document that doesn't exist.\");\n // Document exists, base precondition on document update time.\n return fn.updateTime(e);\n }\n // Document was not read, so we just use the preconditions for a blind\n // update.\n return fn.exists(!0);\n }, e.prototype.write = function(t) {\n this.S_(), this.mutations = this.mutations.concat(t);\n }, e.prototype.S_ = function() {}, e;\n}(), Wu = /** @class */ function() {\n function e(t, e, n, r) {\n this.cs = t, this.Ku = e, this.updateFunction = n, this.ls = r, this.N_ = 5, this.ys = new vr(this.cs, \"transaction_retry\" /* TransactionRetry */)\n /** Runs the transaction and sets the result on deferred. */;\n }\n return e.prototype.run = function() {\n this.F_();\n }, e.prototype.F_ = function() {\n var e = this;\n this.ys.gn((function() {\n return t.__awaiter(e, void 0, void 0, (function() {\n var e, n, r = this;\n return t.__generator(this, (function(t) {\n return e = new Bu(this.Ku), (n = this.x_(e)) && n.then((function(t) {\n r.cs.ws((function() {\n return e.commit().then((function() {\n r.ls.resolve(t);\n })).catch((function(t) {\n r.k_(t);\n }));\n }));\n })).catch((function(t) {\n r.k_(t);\n })), [ 2 /*return*/ ];\n }));\n }));\n }));\n }, e.prototype.x_ = function(t) {\n try {\n var e = this.updateFunction(t);\n return !ut(e) && e.catch && e.then ? e : (this.ls.reject(Error(\"Transaction callback must return a Promise\")), \n null);\n } catch (t) {\n // Do not retry errors thrown by user provided updateFunction.\n return this.ls.reject(t), null;\n }\n }, e.prototype.k_ = function(t) {\n var e = this;\n this.N_ > 0 && this.M_(t) ? (this.N_ -= 1, this.cs.ws((function() {\n return e.F_(), Promise.resolve();\n }))) : this.ls.reject(t);\n }, e.prototype.M_ = function(t) {\n if (\"FirebaseError\" === t.name) {\n // In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and\n // non-matching document versions with ABORTED. These errors should be retried.\n var e = t.code;\n return \"aborted\" === e || \"failed-precondition\" === e || !wt(e);\n }\n return !1;\n }, e;\n}(), Ku = /** @class */ function() {\n function e(t, \n /**\n * Asynchronous queue responsible for all of our internal processing. When\n * we get incoming work from the user (via public API) or the network\n * (incoming GRPC messages), we should always schedule onto this queue.\n * This ensures all of our work is properly serialized (e.g. we don't\n * start processing a new operation while the previous one is waiting for\n * an async I/O to complete).\n */\n e) {\n this.credentials = t, this.cs = e, this.clientId = Q.k(), \n // We defer our initialization until we get the current user from\n // setChangeListener(). We block the async queue until we got the initial\n // user and the initialization is completed. This will prevent any scheduled\n // work from happening before initialization is completed.\n // If initializationDone resolved then the FirestoreClient is in a usable\n // state.\n this.O_ = new dr\n /**\n * Starts up the FirestoreClient, returning only whether or not enabling\n * persistence succeeded.\n *\n * The intent here is to \"do the right thing\" as far as users are concerned.\n * Namely, in cases where offline persistence is requested and possible,\n * enable it, but otherwise fall back to persistence disabled. For the most\n * part we expect this to succeed one way or the other so we don't expect our\n * users to actually wait on the firestore.enablePersistence Promise since\n * they generally won't care.\n *\n * Of course some users actually do care about whether or not persistence\n * was successfully enabled, so the Promise returned from this method\n * indicates this outcome.\n *\n * This presents a problem though: even before enablePersistence resolves or\n * rejects, users may have made calls to e.g. firestore.collection() which\n * means that the FirestoreClient in there will be available and will be\n * enqueuing actions on the async queue.\n *\n * Meanwhile any failure of an operation on the async queue causes it to\n * panic and reject any further work, on the premise that unhandled errors\n * are fatal.\n *\n * Consequently the fallback is handled internally here in start, and if the\n * fallback succeeds we signal success to the async queue even though the\n * start() itself signals failure.\n *\n * @param databaseInfo The connection information for the current instance.\n * @param offlineComponentProvider Provider that returns all components\n * required for memory-only or IndexedDB persistence.\n * @param onlineComponentProvider Provider that returns all components\n * required for online support.\n * @param persistenceSettings Settings object to configure offline\n * persistence.\n * @returns A deferred result indicating the user-visible result of enabling\n * offline persistence. This method will reject this if IndexedDB fails to\n * start for any reason. If usePersistence is false this is\n * unconditionally resolved.\n */;\n }\n return e.prototype.start = function(e, n, r, i) {\n var o = this;\n this.L_(), this.bl = e;\n // If usePersistence is true, certain classes of errors while starting are\n // recoverable but only by falling back to persistence disabled.\n // If there's an error in the first case but not in recovery we cannot\n // reject the promise blocking the async queue because this will cause the\n // async queue to panic.\n var s = new dr, u = !1;\n // Return only the result of enabling persistence. Note that this does not\n // need to await the completion of initializationDone because the result of\n // this method should not reflect any other kind of failure to start.\n return this.credentials.Hc((function(e) {\n if (!u) return u = !0, l(\"FirestoreClient\", \"Initializing. user=\", e.uid), o.B_(n, r, i, e, s).then(o.O_.resolve, o.O_.reject);\n o.cs.Cs((function() {\n return function(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return (r = m(e)).cs.xs(), l(\"RemoteStore\", \"RemoteStore received new credentials\"), \n i = Xo(r), \n // Tear down and re-create our network streams. This will ensure we get a\n // fresh auth token for the new user and re-fill the write pipeline with\n // new mutations from the LocalStore (since mutations are per-user).\n r.Yu.add(3 /* CredentialChange */), [ 4 /*yield*/ , zo(r) ];\n\n case 1:\n return t.sent(), i && \n // Don't set the network status to Unknown if we are offline.\n r.th.set(\"Unknown\" /* Unknown */), [ 4 /*yield*/ , r.Gu.Jl(n) ];\n\n case 2:\n return t.sent(), r.Yu.delete(3 /* CredentialChange */), [ 4 /*yield*/ , Go(r) ];\n\n case 3:\n // Tear down and re-create our network streams. This will ensure we get a\n // fresh auth token for the new user and re-fill the write pipeline with\n // new mutations from the LocalStore (since mutations are per-user).\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n }(o.ph, e);\n }));\n })), \n // Block the async queue until initialization is done\n this.cs.ws((function() {\n return o.O_.promise;\n })), s.promise;\n }, \n /** Enables the network connection and requeues all pending operations. */ e.prototype.enableNetwork = function() {\n var t = this;\n return this.L_(), this.cs.enqueue((function() {\n return t.persistence.tc(!0), function(t) {\n var e = m(t);\n return e.Yu.delete(0 /* UserDisabled */), Go(e);\n }(t.ph);\n }));\n }, \n /**\n * Initializes persistent storage, attempting to use IndexedDB if\n * usePersistence is true or memory-only if false.\n *\n * If IndexedDB fails because it's already open in another tab or because the\n * platform can't possibly support our implementation then this method rejects\n * the persistenceResult and falls back on memory-only persistence.\n *\n * @param offlineComponentProvider Provider that returns all components\n * required for memory-only or IndexedDB persistence.\n * @param onlineComponentProvider Provider that returns all components\n * required for online support.\n * @param persistenceSettings Settings object to configure offline persistence\n * @param user The initial user\n * @param persistenceResult A deferred result indicating the user-visible\n * result of enabling offline persistence. This method will reject this if\n * IndexedDB fails to start for any reason. If usePersistence is false\n * this is unconditionally resolved.\n * @returns a Promise indicating whether or not initialization should\n * continue, i.e. that one of the persistence implementations actually\n * succeeded.\n */\n e.prototype.B_ = function(e, n, r, i, o) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var s, u, a = this;\n return t.__generator(this, (function(c) {\n switch (c.label) {\n case 0:\n return c.trys.push([ 0, 3, , 4 ]), s = {\n cs: this.cs,\n bl: this.bl,\n clientId: this.clientId,\n credentials: this.credentials,\n Wl: i,\n Dh: 100,\n persistenceSettings: r\n }, [ 4 /*yield*/ , e.initialize(s) ];\n\n case 1:\n return c.sent(), [ 4 /*yield*/ , n.initialize(e, s) ];\n\n case 2:\n return c.sent(), this.persistence = e.persistence, this.Sh = e.Sh, this.ju = e.ju, \n this.ql = e.ql, this.Ku = n.Ku, this.ph = n.ph, this.fi = n.fi, this.q_ = n.bh, \n this.q_.Us = _s.bind(null, this.fi), this.q_.js = Is.bind(null, this.fi), \n // When a user calls clearPersistence() in one client, all other clients\n // need to be terminated to allow the delete to succeed.\n this.persistence.Za((function() {\n return t.__awaiter(a, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return [ 4 /*yield*/ , this.terminate() ];\n\n case 1:\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n })), o.resolve(), [ 3 /*break*/ , 4 ];\n\n case 3:\n // An unknown failure on the first stage shuts everything down.\n if (u = c.sent(), \n // Regardless of whether or not the retry succeeds, from an user\n // perspective, offline persistence has failed.\n o.reject(u), !this.U_(u)) throw u;\n return [ 2 /*return*/ , (console.warn(\"Error enabling offline persistence. Falling back to persistence disabled: \" + u), \n this.B_(new cu, new fu, {\n jl: !1\n }, i, o)) ];\n\n case 4:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }, \n /**\n * Decides whether the provided error allows us to gracefully disable\n * persistence (as opposed to crashing the client).\n */\n e.prototype.U_ = function(t) {\n return \"FirebaseError\" === t.name ? t.code === a.FAILED_PRECONDITION || t.code === a.UNIMPLEMENTED : !(\"undefined\" != typeof DOMException && t instanceof DOMException) || \n // When the browser is out of quota we could get either quota exceeded\n // or an aborted error depending on whether the error happened during\n // schema migration.\n 22 === t.code || 20 === t.code || \n // Firefox Private Browsing mode disables IndexedDb and returns\n // INVALID_STATE for any usage.\n 11 === t.code;\n }, \n /**\n * Checks that the client has not been terminated. Ensures that other methods on\n * this class cannot be called after the client is terminated.\n */\n e.prototype.L_ = function() {\n if (this.cs.ps) throw new c(a.FAILED_PRECONDITION, \"The client has already been terminated.\");\n }, \n /** Disables the network connection. Pending operations will not complete. */ e.prototype.disableNetwork = function() {\n var e = this;\n return this.L_(), this.cs.enqueue((function() {\n return e.persistence.tc(!1), function(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return (n = m(e)).Yu.add(0 /* UserDisabled */), [ 4 /*yield*/ , zo(n) ];\n\n case 1:\n return t.sent(), \n // Set the OnlineState to Offline so get()s return from cache, etc.\n n.th.set(\"Offline\" /* Offline */), [ 2 /*return*/ ];\n }\n }));\n }));\n }(e.ph);\n }));\n }, e.prototype.terminate = function() {\n var e = this;\n this.cs.Ds();\n var n = new dr;\n return this.cs.bs((function() {\n return t.__awaiter(e, void 0, void 0, (function() {\n var e, r;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return t.trys.push([ 0, 4, , 5 ]), \n // PORTING NOTE: LocalStore does not need an explicit shutdown on web.\n this.ql && this.ql.stop(), [ 4 /*yield*/ , Bo(this.ph) ];\n\n case 1:\n return t.sent(), [ 4 /*yield*/ , this.Sh.Di() ];\n\n case 2:\n return t.sent(), [ 4 /*yield*/ , this.persistence.Di() ];\n\n case 3:\n // PORTING NOTE: LocalStore does not need an explicit shutdown on web.\n return t.sent(), \n // `removeChangeListener` must be called after shutting down the\n // RemoteStore as it will prevent the RemoteStore from retrieving\n // auth tokens.\n this.credentials.Yc(), n.resolve(), [ 3 /*break*/ , 5 ];\n\n case 4:\n return e = t.sent(), r = Lr(e, \"Failed to shutdown persistence\"), n.reject(r), [ 3 /*break*/ , 5 ];\n\n case 5:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n })), n.promise;\n }, \n /**\n * Returns a Promise that resolves when all writes that were pending at the time this\n * method was called received server acknowledgement. An acknowledgement can be either acceptance\n * or rejection.\n */\n e.prototype.waitForPendingWrites = function() {\n var e = this;\n this.L_();\n var n = new dr;\n return this.cs.ws((function() {\n return function(e, n) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var r, i, o, s, u;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n Xo((r = m(e)).ph) || l(\"SyncEngine\", \"The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.\"), \n t.label = 1;\n\n case 1:\n return t.trys.push([ 1, 3, , 4 ]), [ 4 /*yield*/ , function(t) {\n var e = m(t);\n return e.persistence.runTransaction(\"Get highest unacknowledged batch id\", \"readonly\", (function(t) {\n return e.Sr.qo(t);\n }));\n }(r.ju) ];\n\n case 2:\n return -1 === (i = t.sent()) ? [ 2 /*return*/ , void n.resolve() ] : ((o = r.Lh.get(i) || []).push(n), \n r.Lh.set(i, o), [ 3 /*break*/ , 4 ]);\n\n case 3:\n return s = t.sent(), u = Lr(s, \"Initialization of waitForPendingWrites() operation failed\"), \n n.reject(u), [ 3 /*break*/ , 4 ];\n\n case 4:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }(e.fi, n);\n })), n.promise;\n }, e.prototype.listen = function(t, e, n) {\n var r = this;\n this.L_();\n var i = new lu(n), o = new Fr(t, i, e);\n return this.cs.ws((function() {\n return Or(r.q_, o);\n })), function() {\n i.Zl(), r.cs.ws((function() {\n return Pr(r.q_, o);\n }));\n };\n }, e.prototype.Q_ = function(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n, r = this;\n return t.__generator(this, (function(i) {\n switch (i.label) {\n case 0:\n return this.L_(), [ 4 /*yield*/ , this.O_.promise ];\n\n case 1:\n return i.sent(), n = new dr, [ 2 /*return*/ , (this.cs.ws((function() {\n return function(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var i, o, s;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return t.trys.push([ 0, 2, , 3 ]), [ 4 /*yield*/ , function(t, e) {\n var n = m(t);\n return n.persistence.runTransaction(\"read document\", \"readonly\", (function(t) {\n return n.Cc.Cr(t, e);\n }));\n }(e, n) ];\n\n case 1:\n return (i = t.sent()) instanceof kn ? r.resolve(i) : i instanceof Rn ? r.resolve(null) : r.reject(new c(a.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.)\")), \n [ 3 /*break*/ , 3 ];\n\n case 2:\n return o = t.sent(), s = Lr(o, \"Failed to get document '\" + n + \" from cache\"), \n r.reject(s), [ 3 /*break*/ , 3 ];\n\n case 3:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }(r.ju, e, n);\n })), n.promise) ];\n }\n }));\n }));\n }, e.prototype.W_ = function(e, n) {\n return void 0 === n && (n = {}), t.__awaiter(this, void 0, void 0, (function() {\n var r, i = this;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return this.L_(), [ 4 /*yield*/ , this.O_.promise ];\n\n case 1:\n return t.sent(), r = new dr, [ 2 /*return*/ , (this.cs.ws((function() {\n return function(t, e, n, r, i) {\n var o = new lu({\n next: function(o) {\n // Remove query first before passing event to user to avoid\n // user actions affecting the now stale query.\n e.ws((function() {\n return Pr(t, s);\n }));\n var u = o.docs.has(n);\n !u && o.fromCache ? \n // TODO(dimond): If we're online and the document doesn't\n // exist then we resolve with a doc.exists set to false. If\n // we're offline however, we reject the Promise in this\n // case. Two options: 1) Cache the negative response from\n // the server so we can deliver that even when you're\n // offline 2) Actually reject the Promise in the online case\n // if the document doesn't exist.\n i.reject(new c(a.UNAVAILABLE, \"Failed to get document because the client is offline.\")) : u && o.fromCache && r && \"server\" === r.source ? i.reject(new c(a.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.)')) : i.resolve(o);\n },\n error: function(t) {\n return i.reject(t);\n }\n }), s = new Fr(Un(n.path), o, {\n includeMetadataChanges: !0,\n Xs: !0\n });\n return Or(t, s);\n }(i.q_, i.cs, e, n, r);\n })), r.promise) ];\n }\n }));\n }));\n }, e.prototype.j_ = function(e) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var n, r = this;\n return t.__generator(this, (function(i) {\n switch (i.label) {\n case 0:\n return this.L_(), [ 4 /*yield*/ , this.O_.promise ];\n\n case 1:\n return i.sent(), n = new dr, [ 2 /*return*/ , (this.cs.ws((function() {\n return function(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var i, o, s, u, a, c;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return t.trys.push([ 0, 2, , 3 ]), [ 4 /*yield*/ , To(e, n, \n /* usePreviousResults= */ !0) ];\n\n case 1:\n return i = t.sent(), o = new ys(n, i.Fc), s = o.wh(i.documents), u = o.yr(s, \n /* updateLimboDocuments= */ !1), r.resolve(u.snapshot), [ 3 /*break*/ , 3 ];\n\n case 2:\n return a = t.sent(), c = Lr(a, \"Failed to execute query '\" + n + \" against cache\"), \n r.reject(c), [ 3 /*break*/ , 3 ];\n\n case 3:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }(r.ju, e, n);\n })), n.promise) ];\n }\n }));\n }));\n }, e.prototype.K_ = function(e, n) {\n return void 0 === n && (n = {}), t.__awaiter(this, void 0, void 0, (function() {\n var r, i = this;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return this.L_(), [ 4 /*yield*/ , this.O_.promise ];\n\n case 1:\n return t.sent(), r = new dr, [ 2 /*return*/ , (this.cs.ws((function() {\n return function(t, e, n, r, i) {\n var o = new lu({\n next: function(n) {\n // Remove query first before passing event to user to avoid\n // user actions affecting the now stale query.\n e.ws((function() {\n return Pr(t, s);\n })), n.fromCache && \"server\" === r.source ? i.reject(new c(a.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.)')) : i.resolve(n);\n },\n error: function(t) {\n return i.reject(t);\n }\n }), s = new Fr(n, o, {\n includeMetadataChanges: !0,\n Xs: !0\n });\n return Or(t, s);\n }(i.q_, i.cs, e, n, r);\n })), r.promise) ];\n }\n }));\n }));\n }, e.prototype.write = function(e) {\n var n = this;\n this.L_();\n var r = new dr;\n return this.cs.ws((function() {\n return function(e, n, r) {\n return t.__awaiter(this, void 0, void 0, (function() {\n var i, o, s, u;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n i = Qs(e), t.label = 1;\n\n case 1:\n return t.trys.push([ 1, 5, , 6 ]), [ 4 /*yield*/ , \n /* Accepts locally generated Mutations and commit them to storage. */\n function(t, e) {\n var n, r = m(t), i = ot.now(), o = e.reduce((function(t, e) {\n return t.add(e.key);\n }), Ot());\n return r.persistence.runTransaction(\"Locally write mutations\", \"readwrite\", (function(t) {\n return r.Cc.kr(t, o).next((function(o) {\n n = o;\n for (\n // For non-idempotent mutations (such as `FieldValue.increment()`),\n // we record the base state in a separate patch mutation. This is\n // later used to guarantee consistent values and prevents flicker\n // even if the backend sends us an update that already includes our\n // transform.\n var s = [], u = 0, a = e; u < a.length; u++) {\n var c = a[u], h = yn(c, n.get(c.key));\n null != h && \n // NOTE: The base state should only be applied if there's some\n // existing document to override, so use a Precondition of\n // exists=true\n s.push(new _n(c.key, h, xn(h.proto.mapValue), fn.exists(!0)));\n }\n return r.Sr.ko(t, i, s, e);\n }));\n })).then((function(t) {\n var e = t.lr(n);\n return {\n batchId: t.batchId,\n wr: e\n };\n }));\n }(i.ju, n) ];\n\n case 2:\n return o = t.sent(), i.Sh.xi(o.batchId), function(t, e, n) {\n var r = t.Oh[t.currentUser.ti()];\n r || (r = new bt(H)), r = r.ot(e, n), t.Oh[t.currentUser.ti()] = r;\n }(i, o.batchId, r), [ 4 /*yield*/ , Vs(i, o.wr) ];\n\n case 3:\n return t.sent(), [ 4 /*yield*/ , is(i.ph) ];\n\n case 4:\n return t.sent(), [ 3 /*break*/ , 6 ];\n\n case 5:\n return s = t.sent(), u = Lr(s, \"Failed to persist write\"), r.reject(u), [ 3 /*break*/ , 6 ];\n\n case 6:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n }(n.fi, e, r);\n })), r.promise;\n }, e.prototype.U = function() {\n return this.bl.U;\n }, e.prototype.G_ = function(e) {\n var n = this;\n this.L_();\n var r = new lu(e);\n return this.cs.ws((function() {\n return t.__awaiter(n, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n return [ 2 /*return*/ , function(t, e) {\n m(t).qs.add(e), \n // Immediately fire an initial event, indicating all existing listeners\n // are in-sync.\n e.next();\n }(this.q_, r) ];\n }));\n }));\n })), function() {\n r.Zl(), n.cs.ws((function() {\n return t.__awaiter(n, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n return [ 2 /*return*/ , function(t, e) {\n m(t).qs.delete(e);\n }(this.q_, r) ];\n }));\n }));\n }));\n };\n }, Object.defineProperty(e.prototype, \"z_\", {\n get: function() {\n // Technically, the asyncQueue is still running, but only accepting operations\n // related to termination or supposed to be run after termination. It is effectively\n // terminated to the eyes of users.\n return this.cs.ps;\n },\n enumerable: !1,\n configurable: !0\n }), \n /**\n * Takes an updateFunction in which a set of reads and writes can be performed\n * atomically. In the updateFunction, the client can read and write values\n * using the supplied transaction object. After the updateFunction, all\n * changes will be committed. If a retryable error occurs (ex: some other\n * client has changed any of the data referenced), then the updateFunction\n * will be called again after a backoff. If the updateFunction still fails\n * after all retries, then the transaction will be rejected.\n *\n * The transaction object passed to the updateFunction contains methods for\n * accessing documents and collections. Unlike other datastore access, data\n * accessed with the transaction will not reflect local changes that have not\n * been committed. For this reason, it is required that all reads are\n * performed before any writes. Transactions must be performed while online.\n */\n e.prototype.transaction = function(t) {\n var e = this;\n this.L_();\n var n = new dr;\n return this.cs.ws((function() {\n return new Wu(e.cs, e.Ku, t, n).run(), Promise.resolve();\n })), n.promise;\n }, e;\n}();\n\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * TransactionRunner encapsulates the logic needed to run and retry transactions\n * with backoff.\n */ function Qu(t) {\n /**\n * Returns true if obj is an object and contains at least one of the specified\n * methods.\n */\n return function(t, e) {\n if (\"object\" != typeof t || null === t) return !1;\n for (var n = t, r = 0, i = [ \"next\", \"error\", \"complete\" ]; r < i.length; r++) {\n var o = i[r];\n if (o in n && \"function\" == typeof n[o]) return !0;\n }\n return !1;\n }(t);\n}\n\nvar Hu = /** @class */ function() {\n function t(t, e, n, r, i) {\n this.U = t, this.timestampsInSnapshots = e, this.H_ = n, this.Y_ = r, this.J_ = i;\n }\n return t.prototype.X_ = function(t) {\n switch (Jt(t)) {\n case 0 /* NullValue */ :\n return null;\n\n case 1 /* BooleanValue */ :\n return t.booleanValue;\n\n case 2 /* NumberValue */ :\n return se(t.integerValue || t.doubleValue);\n\n case 3 /* TimestampValue */ :\n return this.Z_(t.timestampValue);\n\n case 4 /* ServerTimestampValue */ :\n return this.tf(t);\n\n case 5 /* StringValue */ :\n return t.stringValue;\n\n case 6 /* BlobValue */ :\n return this.J_(ue(t.bytesValue));\n\n case 7 /* RefValue */ :\n return this.ef(t.referenceValue);\n\n case 8 /* GeoPointValue */ :\n return this.nf(t.geoPointValue);\n\n case 9 /* ArrayValue */ :\n return this.sf(t.arrayValue);\n\n case 10 /* ObjectValue */ :\n return this.if(t.mapValue);\n\n default:\n throw y();\n }\n }, t.prototype.if = function(t) {\n var e = this, n = {};\n return _(t.fields || {}, (function(t, r) {\n n[t] = e.X_(r);\n })), n;\n }, t.prototype.nf = function(t) {\n return new Eu(se(t.latitude), se(t.longitude));\n }, t.prototype.sf = function(t) {\n var e = this;\n return (t.values || []).map((function(t) {\n return e.X_(t);\n }));\n }, t.prototype.tf = function(t) {\n switch (this.H_) {\n case \"previous\":\n var e = Yt(t);\n return null == e ? null : this.X_(e);\n\n case \"estimate\":\n return this.Z_($t(t));\n\n default:\n return null;\n }\n }, t.prototype.Z_ = function(t) {\n var e = oe(t), n = new ot(e.seconds, e.nanos);\n return this.timestampsInSnapshots ? n : n.toDate();\n }, t.prototype.ef = function(t) {\n var e = E.g(t);\n g(He(e));\n var n = new rt(e.get(1), e.get(3)), r = new A(e.u(5));\n return n.isEqual(this.U) || \n // TODO(b/64130202): Somehow support foreign references.\n p(\"Document \" + r + \" contains a document reference within a different database (\" + n.projectId + \"/\" + n.database + \") which is not supported. It will be treated as a reference in the current database (\" + this.U.projectId + \"/\" + this.U.database + \") instead.\"), \n this.Y_(r);\n }, t;\n}(), Yu = ui.ho, $u = /** @class */ function() {\n function t(t) {\n var e, n, r, i, o;\n if (void 0 === t.host) {\n if (void 0 !== t.ssl) throw new c(a.INVALID_ARGUMENT, \"Can't provide ssl option if host option is not set\");\n this.host = \"firestore.googleapis.com\", this.ssl = !0;\n } else O(\"settings\", \"non-empty string\", \"host\", t.host), this.host = t.host, P(\"settings\", \"boolean\", \"ssl\", t.ssl), \n this.ssl = null === (e = t.ssl) || void 0 === e || e;\n if (j(\"settings\", t, [ \"host\", \"ssl\", \"credentials\", \"timestampsInSnapshots\", \"cacheSizeBytes\", \"experimentalForceLongPolling\", \"experimentalAutoDetectLongPolling\", \"ignoreUndefinedProperties\" ]), \n P(\"settings\", \"object\", \"credentials\", t.credentials), this.credentials = t.credentials, \n P(\"settings\", \"boolean\", \"timestampsInSnapshots\", t.timestampsInSnapshots), P(\"settings\", \"boolean\", \"ignoreUndefinedProperties\", t.ignoreUndefinedProperties), \n // Nobody should set timestampsInSnapshots anymore, but the error depends on\n // whether they set it to true or false...\n !0 === t.timestampsInSnapshots ? p(\"The setting 'timestampsInSnapshots: true' is no longer required and should be removed.\") : !1 === t.timestampsInSnapshots && p(\"Support for 'timestampsInSnapshots: false' will be removed soon. You must update your code to handle Timestamp objects.\"), \n this.timestampsInSnapshots = null === (n = t.timestampsInSnapshots) || void 0 === n || n, \n this.ignoreUndefinedProperties = null !== (r = t.ignoreUndefinedProperties) && void 0 !== r && r, \n P(\"settings\", \"number\", \"cacheSizeBytes\", t.cacheSizeBytes), void 0 === t.cacheSizeBytes) this.cacheSizeBytes = ui._o; else {\n if (t.cacheSizeBytes !== Yu && t.cacheSizeBytes < ui.lo) throw new c(a.INVALID_ARGUMENT, \"cacheSizeBytes must be at least \" + ui.lo);\n this.cacheSizeBytes = t.cacheSizeBytes;\n }\n P(\"settings\", \"boolean\", \"experimentalForceLongPolling\", t.experimentalForceLongPolling), \n this.experimentalForceLongPolling = null !== (i = t.experimentalForceLongPolling) && void 0 !== i && i, \n P(\"settings\", \"boolean\", \"experimentalAutoDetectLongPolling\", t.experimentalAutoDetectLongPolling), \n this.experimentalAutoDetectLongPolling = null !== (o = t.experimentalAutoDetectLongPolling) && void 0 !== o && o, \n function(t, e, n, r) {\n if (!0 === e && !0 === r) throw new c(a.INVALID_ARGUMENT, \"experimentalForceLongPolling and experimentalAutoDetectLongPolling cannot be used together.\");\n }(0, t.experimentalForceLongPolling, 0, t.experimentalAutoDetectLongPolling);\n }\n return t.prototype.isEqual = function(t) {\n return this.host === t.host && this.ssl === t.ssl && this.timestampsInSnapshots === t.timestampsInSnapshots && this.credentials === t.credentials && this.cacheSizeBytes === t.cacheSizeBytes && this.experimentalForceLongPolling === t.experimentalForceLongPolling && this.experimentalAutoDetectLongPolling === t.experimentalAutoDetectLongPolling && this.ignoreUndefinedProperties === t.ignoreUndefinedProperties;\n }, t;\n}(), Xu = /** @class */ function() {\n // Note: We are using `MemoryComponentProvider` as a default\n // ComponentProvider to ensure backwards compatibility with the format\n // expected by the console build.\n function e(n, r, i, o) {\n var s = this;\n if (void 0 === i && (i = new cu), void 0 === o && (o = new fu), this.rf = i, this.af = o, \n this.cf = null, \n // Public for use in tests.\n // TODO(mikelehen): Use modularized initialization instead.\n this.uf = new xr, this.INTERNAL = {\n delete: function() {\n return t.__awaiter(s, void 0, void 0, (function() {\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n // The client must be initalized to ensure that all subsequent API usage\n // throws an exception.\n return this.hf(), [ 4 /*yield*/ , this.lf.terminate() ];\n\n case 1:\n // The client must be initalized to ensure that all subsequent API usage\n // throws an exception.\n return t.sent(), [ 2 /*return*/ ];\n }\n }));\n }));\n }\n }, \"object\" == typeof n.options) {\n // This is very likely a Firebase app object\n // TODO(b/34177605): Can we somehow use instanceof?\n var u = n;\n this.cf = u, this.__ = e._f(u), this.ff = u.name, this.df = new Oo(r);\n } else {\n var h = n;\n if (!h.projectId) throw new c(a.INVALID_ARGUMENT, \"Must provide projectId\");\n this.__ = new rt(h.projectId, h.database), \n // Use a default persistenceKey that lines up with FirebaseApp.\n this.ff = \"[DEFAULT]\", this.df = new Ro;\n }\n this.wf = new $u({});\n }\n return Object.defineProperty(e.prototype, \"mf\", {\n get: function() {\n return this.Tf || (\n // Lazy initialize UserDataReader once the settings are frozen\n this.Tf = new ku(this.__, this.wf.ignoreUndefinedProperties)), this.Tf;\n },\n enumerable: !1,\n configurable: !0\n }), e.prototype.settings = function(t) {\n D(\"Firestore.settings\", arguments, 1), k(\"Firestore.settings\", \"object\", 1, t), \n t.merge && \n // Remove the property from the settings once the merge is completed\n delete (t = Object.assign(Object.assign({}, this.wf), t)).merge;\n var e = new $u(t);\n if (this.lf && !this.wf.isEqual(e)) throw new c(a.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.\");\n this.wf = e, void 0 !== e.credentials && (this.df = function(t) {\n if (!t) return new Ro;\n switch (t.type) {\n case \"gapi\":\n var e = t.client;\n // Make sure this really is a Gapi client.\n return g(!(\"object\" != typeof e || null === e || !e.auth || !e.auth.getAuthHeaderValueForFirstParty)), \n new Vo(e, t.sessionIndex || \"0\");\n\n case \"provider\":\n return t.client;\n\n default:\n throw new c(a.INVALID_ARGUMENT, \"makeCredentialsProvider failed due to invalid credential type\");\n }\n }(e.credentials));\n }, e.prototype.enableNetwork = function() {\n return this.hf(), this.lf.enableNetwork();\n }, e.prototype.disableNetwork = function() {\n return this.hf(), this.lf.disableNetwork();\n }, e.prototype.enablePersistence = function(t) {\n var e, n;\n if (this.lf) throw new c(a.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.\");\n var r = !1, i = !1;\n if (t && (void 0 !== t.experimentalTabSynchronization && p(\"The 'experimentalTabSynchronization' setting will be removed. Use 'synchronizeTabs' instead.\"), \n r = null !== (n = null !== (e = t.synchronizeTabs) && void 0 !== e ? e : t.experimentalTabSynchronization) && void 0 !== n && n, \n i = !!t.experimentalForceOwningTab && t.experimentalForceOwningTab, r && i)) throw new c(a.INVALID_ARGUMENT, \"The 'experimentalForceOwningTab' setting cannot be used with 'synchronizeTabs'.\");\n return this.Ef(this.rf, this.af, {\n jl: !0,\n cacheSizeBytes: this.wf.cacheSizeBytes,\n synchronizeTabs: r,\n ka: i\n });\n }, e.prototype.clearPersistence = function() {\n return t.__awaiter(this, void 0, void 0, (function() {\n var e, n = this;\n return t.__generator(this, (function(r) {\n if (void 0 !== this.lf && !this.lf.z_) throw new c(a.FAILED_PRECONDITION, \"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.\");\n return e = new dr, [ 2 /*return*/ , (this.uf.bs((function() {\n return t.__awaiter(n, void 0, void 0, (function() {\n var n;\n return t.__generator(this, (function(t) {\n switch (t.label) {\n case 0:\n return t.trys.push([ 0, 2, , 3 ]), [ 4 /*yield*/ , this.rf.clearPersistence(this.__, this.ff) ];\n\n case 1:\n return t.sent(), e.resolve(), [ 3 /*break*/ , 3 ];\n\n case 2:\n return n = t.sent(), e.reject(n), [ 3 /*break*/ , 3 ];\n\n case 3:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n })), e.promise) ];\n }));\n }));\n }, e.prototype.terminate = function() {\n return this.app._removeServiceInstance(\"firestore\"), this.INTERNAL.delete();\n }, Object.defineProperty(e.prototype, \"If\", {\n get: function() {\n return this.hf(), this.lf.z_;\n },\n enumerable: !1,\n configurable: !0\n }), e.prototype.waitForPendingWrites = function() {\n return this.hf(), this.lf.waitForPendingWrites();\n }, e.prototype.onSnapshotsInSync = function(t) {\n if (this.hf(), Qu(t)) return this.lf.G_(t);\n k(\"Firestore.onSnapshotsInSync\", \"function\", 1, t);\n var e = {\n next: t\n };\n return this.lf.G_(e);\n }, e.prototype.hf = function() {\n return this.lf || \n // Kick off starting the client but don't actually wait for it.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.Ef(new cu, new fu, {\n jl: !1\n }), this.lf;\n }, e.prototype.Af = function() {\n return new nt(this.__, this.ff, this.wf.host, this.wf.ssl, this.wf.experimentalForceLongPolling, this.wf.experimentalAutoDetectLongPolling);\n }, e.prototype.Ef = function(t, e, n) {\n var r = this.Af();\n return this.lf = new Ku(this.df, this.uf), this.lf.start(r, t, e, n);\n }, e._f = function(t) {\n if (e = t.options, \"projectId\", !Object.prototype.hasOwnProperty.call(e, \"projectId\")) throw new c(a.INVALID_ARGUMENT, '\"projectId\" not provided in firebase.initializeApp.');\n var e, n = t.options.projectId;\n if (!n || \"string\" != typeof n) throw new c(a.INVALID_ARGUMENT, \"projectId must be a string in FirebaseApp.options\");\n return new rt(n);\n }, Object.defineProperty(e.prototype, \"app\", {\n get: function() {\n if (!this.cf) throw new c(a.FAILED_PRECONDITION, \"Firestore was not initialized using the Firebase SDK. 'app' is not available\");\n return this.cf;\n },\n enumerable: !1,\n configurable: !0\n }), e.prototype.collection = function(t) {\n return D(\"Firestore.collection\", arguments, 1), k(\"Firestore.collection\", \"non-empty string\", 1, t), \n this.hf(), new la(E.g(t), this, \n /* converter= */ null);\n }, e.prototype.doc = function(t) {\n return D(\"Firestore.doc\", arguments, 1), k(\"Firestore.doc\", \"non-empty string\", 1, t), \n this.hf(), ta.Rf(E.g(t), this, \n /* converter= */ null);\n }, e.prototype.collectionGroup = function(t) {\n if (D(\"Firestore.collectionGroup\", arguments, 1), k(\"Firestore.collectionGroup\", \"non-empty string\", 1, t), \n t.indexOf(\"/\") >= 0) throw new c(a.INVALID_ARGUMENT, \"Invalid collection ID '\" + t + \"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.\");\n return this.hf(), new ha(\n /**\n * Creates a new Query for a collection group query that matches all documents\n * within the provided collection group.\n */\n function(t) {\n return new Pn(E.P(), t);\n }(t), this, \n /* converter= */ null);\n }, e.prototype.runTransaction = function(t) {\n var e = this;\n return D(\"Firestore.runTransaction\", arguments, 1), k(\"Firestore.runTransaction\", \"function\", 1, t), \n this.hf().transaction((function(n) {\n return t(new Ju(e, n));\n }));\n }, e.prototype.batch = function() {\n return this.hf(), new Zu(this);\n }, Object.defineProperty(e, \"logLevel\", {\n get: function() {\n switch (f()) {\n case n.LogLevel.DEBUG:\n return \"debug\";\n\n case n.LogLevel.ERROR:\n return \"error\";\n\n case n.LogLevel.SILENT:\n return \"silent\";\n\n case n.LogLevel.WARN:\n return \"warn\";\n\n case n.LogLevel.INFO:\n return \"info\";\n\n case n.LogLevel.VERBOSE:\n return \"verbose\";\n\n default:\n // The default log level is error\n return \"error\";\n }\n },\n enumerable: !1,\n configurable: !0\n }), e.setLogLevel = function(t) {\n var e;\n D(\"Firestore.setLogLevel\", arguments, 1), U(\"setLogLevel\", [ \"debug\", \"error\", \"silent\", \"warn\", \"info\", \"verbose\" ], 1, t), \n e = t, h.setLogLevel(e);\n }, \n // Note: this is not a property because the minifier can't work correctly with\n // the way TypeScript compiler outputs properties.\n e.prototype.gf = function() {\n return this.wf.timestampsInSnapshots;\n }, \n // Visible for testing.\n e.prototype.Pf = function() {\n return this.wf;\n }, e;\n}(), Ju = /** @class */ function() {\n function t(t, e) {\n this.yf = t, this.Vf = e;\n }\n return t.prototype.get = function(t) {\n var e = this;\n D(\"Transaction.get\", arguments, 1);\n var n = ya(\"Transaction.get\", t, this.yf);\n return this.Vf.v_([ n.f_ ]).then((function(t) {\n if (!t || 1 !== t.length) return y();\n var r = t[0];\n if (r instanceof Rn) return new na(e.yf, n.f_, null, \n /* fromCache= */ !1, \n /* hasPendingWrites= */ !1, n.d_);\n if (r instanceof kn) return new na(e.yf, n.f_, r, \n /* fromCache= */ !1, \n /* hasPendingWrites= */ !1, n.d_);\n throw y();\n }));\n }, t.prototype.set = function(t, e, n) {\n L(\"Transaction.set\", arguments, 2, 3);\n var r = ya(\"Transaction.set\", t, this.yf);\n n = pa(\"Transaction.set\", n);\n var i = ma(r.d_, e, n), o = Ru(this.yf.mf, \"Transaction.set\", r.f_, i, null !== r.d_, n);\n return this.Vf.set(r.f_, o), this;\n }, t.prototype.update = function(t, e, n) {\n for (var r, i, o = [], s = 3; s < arguments.length; s++) o[s - 3] = arguments[s];\n return \"string\" == typeof e || e instanceof du ? (x(\"Transaction.update\", arguments, 3), \n r = ya(\"Transaction.update\", t, this.yf), i = Pu(this.yf.mf, \"Transaction.update\", r.f_, e, n, o)) : (D(\"Transaction.update\", arguments, 2), \n r = ya(\"Transaction.update\", t, this.yf), i = Ou(this.yf.mf, \"Transaction.update\", r.f_, e)), \n this.Vf.update(r.f_, i), this;\n }, t.prototype.delete = function(t) {\n D(\"Transaction.delete\", arguments, 1);\n var e = ya(\"Transaction.delete\", t, this.yf);\n return this.Vf.delete(e.f_), this;\n }, t;\n}(), Zu = /** @class */ function() {\n function t(t) {\n this.yf = t, this.pf = [], this.bf = !1;\n }\n return t.prototype.set = function(t, e, n) {\n L(\"WriteBatch.set\", arguments, 2, 3), this.vf();\n var r = ya(\"WriteBatch.set\", t, this.yf);\n n = pa(\"WriteBatch.set\", n);\n var i = ma(r.d_, e, n), o = Ru(this.yf.mf, \"WriteBatch.set\", r.f_, i, null !== r.d_, n);\n return this.pf = this.pf.concat(o.w_(r.f_, fn.ze())), this;\n }, t.prototype.update = function(t, e, n) {\n for (var r, i, o = [], s = 3; s < arguments.length; s++) o[s - 3] = arguments[s];\n return this.vf(), \"string\" == typeof e || e instanceof du ? (x(\"WriteBatch.update\", arguments, 3), \n r = ya(\"WriteBatch.update\", t, this.yf), i = Pu(this.yf.mf, \"WriteBatch.update\", r.f_, e, n, o)) : (D(\"WriteBatch.update\", arguments, 2), \n r = ya(\"WriteBatch.update\", t, this.yf), i = Ou(this.yf.mf, \"WriteBatch.update\", r.f_, e)), \n this.pf = this.pf.concat(i.w_(r.f_, fn.exists(!0))), this;\n }, t.prototype.delete = function(t) {\n D(\"WriteBatch.delete\", arguments, 1), this.vf();\n var e = ya(\"WriteBatch.delete\", t, this.yf);\n return this.pf = this.pf.concat(new Nn(e.f_, fn.ze())), this;\n }, t.prototype.commit = function() {\n return this.vf(), this.bf = !0, this.pf.length > 0 ? this.yf.hf().write(this.pf) : Promise.resolve();\n }, t.prototype.vf = function() {\n if (this.bf) throw new c(a.FAILED_PRECONDITION, \"A write batch can no longer be used after commit() has been called.\");\n }, t;\n}(), ta = /** @class */ function(e) {\n function n(t, n, r) {\n var i = this;\n return (i = e.call(this, n.__, t, r) || this).f_ = t, i.firestore = n, i.d_ = r, \n i.lf = i.firestore.hf(), i;\n }\n return t.__extends(n, e), n.Rf = function(t, e, r) {\n if (t.length % 2 != 0) throw new c(a.INVALID_ARGUMENT, \"Invalid document reference. Document references must have an even number of segments, but \" + t.R() + \" has \" + t.length);\n return new n(new A(t), e, r);\n }, Object.defineProperty(n.prototype, \"id\", {\n get: function() {\n return this.f_.path._();\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(n.prototype, \"parent\", {\n get: function() {\n return new la(this.f_.path.h(), this.firestore, this.d_);\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(n.prototype, \"path\", {\n get: function() {\n return this.f_.path.R();\n },\n enumerable: !1,\n configurable: !0\n }), n.prototype.collection = function(t) {\n if (D(\"DocumentReference.collection\", arguments, 1), k(\"DocumentReference.collection\", \"non-empty string\", 1, t), \n !t) throw new c(a.INVALID_ARGUMENT, \"Must provide a non-empty collection name to collection()\");\n var e = E.g(t);\n return new la(this.f_.path.child(e), this.firestore, \n /* converter= */ null);\n }, n.prototype.isEqual = function(t) {\n if (!(t instanceof n)) throw G(\"isEqual\", \"DocumentReference\", 1, t);\n return this.firestore === t.firestore && this.f_.isEqual(t.f_) && this.d_ === t.d_;\n }, n.prototype.set = function(t, e) {\n L(\"DocumentReference.set\", arguments, 1, 2), e = pa(\"DocumentReference.set\", e);\n var n = ma(this.d_, t, e), r = Ru(this.firestore.mf, \"DocumentReference.set\", this.f_, n, null !== this.d_, e);\n return this.lf.write(r.w_(this.f_, fn.ze()));\n }, n.prototype.update = function(t, e) {\n for (var n, r = [], i = 2; i < arguments.length; i++) r[i - 2] = arguments[i];\n return \"string\" == typeof t || t instanceof du ? (x(\"DocumentReference.update\", arguments, 2), \n n = Pu(this.firestore.mf, \"DocumentReference.update\", this.f_, t, e, r)) : (D(\"DocumentReference.update\", arguments, 1), \n n = Ou(this.firestore.mf, \"DocumentReference.update\", this.f_, t)), this.lf.write(n.w_(this.f_, fn.exists(!0)));\n }, n.prototype.delete = function() {\n return D(\"DocumentReference.delete\", arguments, 0), this.lf.write([ new Nn(this.f_, fn.ze()) ]);\n }, n.prototype.onSnapshot = function() {\n for (var t, e, n, r = this, i = [], o = 0; o < arguments.length; o++) i[o] = arguments[o];\n L(\"DocumentReference.onSnapshot\", arguments, 1, 4);\n var s = {\n includeMetadataChanges: !1\n }, u = 0;\n \"object\" != typeof i[u] || Qu(i[u]) || (j(\"DocumentReference.onSnapshot\", s = i[u], [ \"includeMetadataChanges\" ]), \n P(\"DocumentReference.onSnapshot\", \"boolean\", \"includeMetadataChanges\", s.includeMetadataChanges), \n u++);\n var a = {\n includeMetadataChanges: s.includeMetadataChanges\n };\n if (Qu(i[u])) {\n var c = i[u];\n i[u] = null === (t = c.next) || void 0 === t ? void 0 : t.bind(c), i[u + 1] = null === (e = c.error) || void 0 === e ? void 0 : e.bind(c), \n i[u + 2] = null === (n = c.complete) || void 0 === n ? void 0 : n.bind(c);\n } else k(\"DocumentReference.onSnapshot\", \"function\", u, i[u]), R(\"DocumentReference.onSnapshot\", \"function\", u + 1, i[u + 1]), \n R(\"DocumentReference.onSnapshot\", \"function\", u + 2, i[u + 2]);\n var h = {\n next: function(t) {\n i[u] && i[u](r.Sf(t));\n },\n error: i[u + 1],\n complete: i[u + 2]\n };\n return this.lf.listen(Un(this.f_.path), a, h);\n }, n.prototype.get = function(t) {\n var e = this;\n L(\"DocumentReference.get\", arguments, 0, 1), va(\"DocumentReference.get\", t);\n var n = this.firestore.hf();\n return t && \"cache\" === t.source ? n.Q_(this.f_).then((function(t) {\n return new na(e.firestore, e.f_, t, \n /*fromCache=*/ !0, t instanceof kn && t.Je, e.d_);\n })) : n.W_(this.f_, t).then((function(t) {\n return e.Sf(t);\n }));\n }, n.prototype.withConverter = function(t) {\n return new n(this.f_, this.firestore, t);\n }, \n /**\n * Converts a ViewSnapshot that contains the current document to a\n * DocumentSnapshot.\n */\n n.prototype.Sf = function(t) {\n var e = t.docs.get(this.f_);\n return new na(this.firestore, this.f_, e, t.fromCache, t.hasPendingWrites, this.d_);\n }, n;\n}(Au), ea = /** @class */ function() {\n function t(t, e) {\n this.hasPendingWrites = t, this.fromCache = e\n /**\n * Returns true if this `SnapshotMetadata` is equal to the provided one.\n *\n * @param other The `SnapshotMetadata` to compare against.\n * @return true if this `SnapshotMetadata` is equal to the provided one.\n */;\n }\n return t.prototype.isEqual = function(t) {\n return this.hasPendingWrites === t.hasPendingWrites && this.fromCache === t.fromCache;\n }, t;\n}(), na = /** @class */ function() {\n function t(t, e, n, r, i, o) {\n this.yf = t, this.f_ = e, this.Df = n, this.Cf = r, this.Nf = i, this.d_ = o;\n }\n return t.prototype.data = function(t) {\n var e = this;\n if (L(\"DocumentSnapshot.data\", arguments, 0, 1), t = da(\"DocumentSnapshot.data\", t), \n this.Df) {\n // We only want to use the converter and create a new DocumentSnapshot\n // if a converter has been provided.\n if (this.d_) {\n var n = new ra(this.yf, this.f_, this.Df, this.Cf, this.Nf, \n /* converter= */ null);\n return this.d_.fromFirestore(n, t);\n }\n return new Hu(this.yf.__, this.yf.gf(), t.serverTimestamps || \"none\", (function(t) {\n return new ta(t, e.yf, /* converter= */ null);\n }), (function(t) {\n return new et(t);\n })).X_(this.Df.rn());\n }\n }, t.prototype.get = function(t, e) {\n var n = this;\n if (L(\"DocumentSnapshot.get\", arguments, 1, 2), e = da(\"DocumentSnapshot.get\", e), \n this.Df) {\n var r = this.Df.data().field(qu(\"DocumentSnapshot.get\", t, this.f_));\n if (null !== r) return new Hu(this.yf.__, this.yf.gf(), e.serverTimestamps || \"none\", (function(t) {\n return new ta(t, n.yf, n.d_);\n }), (function(t) {\n return new et(t);\n })).X_(r);\n }\n }, Object.defineProperty(t.prototype, \"id\", {\n get: function() {\n return this.f_.path._();\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"ref\", {\n get: function() {\n return new ta(this.f_, this.yf, this.d_);\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"exists\", {\n get: function() {\n return null !== this.Df;\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"metadata\", {\n get: function() {\n return new ea(this.Nf, this.Cf);\n },\n enumerable: !1,\n configurable: !0\n }), t.prototype.isEqual = function(e) {\n if (!(e instanceof t)) throw G(\"isEqual\", \"DocumentSnapshot\", 1, e);\n return this.yf === e.yf && this.Cf === e.Cf && this.f_.isEqual(e.f_) && (null === this.Df ? null === e.Df : this.Df.isEqual(e.Df)) && this.d_ === e.d_;\n }, t;\n}(), ra = /** @class */ function(e) {\n function n() {\n return null !== e && e.apply(this, arguments) || this;\n }\n return t.__extends(n, e), n.prototype.data = function(t) {\n return e.prototype.data.call(this, t);\n }, n;\n}(na);\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// settings() defaults:\nfunction ia(t, e, n, r, i, o, s) {\n var u;\n if (i.p()) {\n if (\"array-contains\" /* ARRAY_CONTAINS */ === o || \"array-contains-any\" /* ARRAY_CONTAINS_ANY */ === o) throw new c(a.INVALID_ARGUMENT, \"Invalid Query. You can't perform '\" + o + \"' queries on FieldPath.documentId().\");\n if (\"in\" /* IN */ === o || \"not-in\" /* NOT_IN */ === o) {\n ua(s, o);\n for (var h = [], f = 0, l = s; f < l.length; f++) {\n var p = l[f];\n h.push(sa(r, t, p));\n }\n u = {\n arrayValue: {\n values: h\n }\n };\n } else u = sa(r, t, s);\n } else \"in\" /* IN */ !== o && \"not-in\" /* NOT_IN */ !== o && \"array-contains-any\" /* ARRAY_CONTAINS_ANY */ !== o || ua(s, o), \n u = Vu(n, e, s, \n /* allowArrays= */ \"in\" /* IN */ === o || \"not-in\" /* NOT_IN */ === o);\n var d = Jn.create(i, o, u);\n return function(t, e) {\n if (e.hn()) {\n var n = qn(t);\n if (null !== n && !n.isEqual(e.field)) throw new c(a.INVALID_ARGUMENT, \"Invalid query. All where filters with an inequality (<, <=, >, or >=) must be on the same field. But you have inequality filters on '\" + n.toString() + \"' and '\" + e.field.toString() + \"'\");\n var r = Mn(t);\n null !== r && aa(t, e.field, r);\n }\n var i = function(t, e) {\n for (var n = 0, r = t.filters; n < r.length; n++) {\n var i = r[n];\n if (e.indexOf(i.op) >= 0) return i.op;\n }\n return null;\n }(t, \n /**\n * Given an operator, returns the set of operators that cannot be used with it.\n *\n * Operators in a query must adhere to the following set of rules:\n * 1. Only one array operator is allowed.\n * 2. Only one disjunctive operator is allowed.\n * 3. NOT_EQUAL cannot be used with another NOT_EQUAL operator.\n * 4. NOT_IN cannot be used with array, disjunctive, or NOT_EQUAL operators.\n *\n * Array operators: ARRAY_CONTAINS, ARRAY_CONTAINS_ANY\n * Disjunctive operators: IN, ARRAY_CONTAINS_ANY, NOT_IN\n */\n function(t) {\n switch (t) {\n case \"!=\" /* NOT_EQUAL */ :\n return [ \"!=\" /* NOT_EQUAL */ , \"not-in\" /* NOT_IN */ ];\n\n case \"array-contains\" /* ARRAY_CONTAINS */ :\n return [ \"array-contains\" /* ARRAY_CONTAINS */ , \"array-contains-any\" /* ARRAY_CONTAINS_ANY */ , \"not-in\" /* NOT_IN */ ];\n\n case \"in\" /* IN */ :\n return [ \"array-contains-any\" /* ARRAY_CONTAINS_ANY */ , \"in\" /* IN */ , \"not-in\" /* NOT_IN */ ];\n\n case \"array-contains-any\" /* ARRAY_CONTAINS_ANY */ :\n return [ \"array-contains\" /* ARRAY_CONTAINS */ , \"array-contains-any\" /* ARRAY_CONTAINS_ANY */ , \"in\" /* IN */ , \"not-in\" /* NOT_IN */ ];\n\n case \"not-in\" /* NOT_IN */ :\n return [ \"array-contains\" /* ARRAY_CONTAINS */ , \"array-contains-any\" /* ARRAY_CONTAINS_ANY */ , \"in\" /* IN */ , \"not-in\" /* NOT_IN */ , \"!=\" /* NOT_EQUAL */ ];\n\n default:\n return [];\n }\n }(e.op));\n if (null !== i) \n // Special case when it's a duplicate op to give a slightly clearer error message.\n throw i === e.op ? new c(a.INVALID_ARGUMENT, \"Invalid query. You cannot use more than one '\" + e.op.toString() + \"' filter.\") : new c(a.INVALID_ARGUMENT, \"Invalid query. You cannot use '\" + e.op.toString() + \"' filters with '\" + i.toString() + \"' filters.\");\n }(t, d), d;\n}\n\nfunction oa(t, e, n) {\n if (null !== t.startAt) throw new c(a.INVALID_ARGUMENT, \"Invalid query. You must not call startAt() or startAfter() before calling orderBy().\");\n if (null !== t.endAt) throw new c(a.INVALID_ARGUMENT, \"Invalid query. You must not call endAt() or endBefore() before calling orderBy().\");\n var r = new fr(e, n);\n return function(t, e) {\n if (null === Mn(t)) {\n // This is the first order by. It must match any inequality.\n var n = qn(t);\n null !== n && aa(t, n, e.field);\n }\n }(t, r), r\n /**\n * Create a Bound from a query and a document.\n *\n * Note that the Bound will always include the key of the document\n * and so only the provided document will compare equal to the returned\n * position.\n *\n * Will throw if the document does not contain all fields of the order by\n * of the query or if any of the fields in the order by are an uncommitted\n * server timestamp.\n */\n /**\n * Parses the given documentIdValue into a ReferenceValue, throwing\n * appropriate errors if the value is anything other than a DocumentReference\n * or String, or if the string is malformed.\n */;\n}\n\nfunction sa(t, e, n) {\n if (\"string\" == typeof n) {\n if (\"\" === n) throw new c(a.INVALID_ARGUMENT, \"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.\");\n if (!jn(e) && -1 !== n.indexOf(\"/\")) throw new c(a.INVALID_ARGUMENT, \"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '\" + n + \"' contains a '/' character.\");\n var r = e.path.child(E.g(n));\n if (!A.F(r)) throw new c(a.INVALID_ARGUMENT, \"Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '\" + r + \"' is not because it has an odd number of segments (\" + r.length + \").\");\n return ae(t, new A(r));\n }\n if (n instanceof Au) return ae(t, n.f_);\n throw new c(a.INVALID_ARGUMENT, \"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: \" + M(n) + \".\");\n}\n\n/**\n * Validates that the value passed into a disjunctive filter satisfies all\n * array requirements.\n */ function ua(t, e) {\n if (!Array.isArray(t) || 0 === t.length) throw new c(a.INVALID_ARGUMENT, \"Invalid Query. A non-empty array is required for '\" + e.toString() + \"' filters.\");\n if (t.length > 10) throw new c(a.INVALID_ARGUMENT, \"Invalid Query. '\" + e.toString() + \"' filters support a maximum of 10 elements in the value array.\");\n if (\"in\" /* IN */ === e || \"array-contains-any\" /* ARRAY_CONTAINS_ANY */ === e) {\n if (t.indexOf(null) >= 0) throw new c(a.INVALID_ARGUMENT, \"Invalid Query. '\" + e.toString() + \"' filters cannot contain 'null' in the value array.\");\n if (t.filter((function(t) {\n return Number.isNaN(t);\n })).length > 0) throw new c(a.INVALID_ARGUMENT, \"Invalid Query. '\" + e.toString() + \"' filters cannot contain 'NaN' in the value array.\");\n }\n}\n\nfunction aa(t, e, n) {\n if (!n.isEqual(e)) throw new c(a.INVALID_ARGUMENT, \"Invalid query. You have a where filter with an inequality (<, <=, >, or >=) on field '\" + e.toString() + \"' and so you must also use '\" + e.toString() + \"' as your first orderBy(), but your first orderBy() is on field '\" + n.toString() + \"' instead.\");\n}\n\nfunction ca(t) {\n if (Fn(t) && 0 === t.on.length) throw new c(a.UNIMPLEMENTED, \"limitToLast() queries require specifying at least one orderBy() clause\");\n}\n\nvar ha = /** @class */ function() {\n function e(t, e, n) {\n this.Ff = t, this.firestore = e, this.d_ = n;\n }\n return e.prototype.where = function(t, n, r) {\n D(\"Query.where\", arguments, 3), q(\"Query.where\", 3, r);\n // Enumerated from the WhereFilterOp type in index.d.ts.\n var i = U(\"Query.where\", [ \"<\" /* LESS_THAN */ , \"<=\" /* LESS_THAN_OR_EQUAL */ , \"==\" /* EQUAL */ , \"!=\" /* NOT_EQUAL */ , \">=\" /* GREATER_THAN_OR_EQUAL */ , \">\" /* GREATER_THAN */ , \"array-contains\" /* ARRAY_CONTAINS */ , \"in\" /* IN */ , \"array-contains-any\" /* ARRAY_CONTAINS_ANY */ , \"not-in\" /* NOT_IN */ ], 2, n), o = qu(\"Query.where\", t), s = ia(this.Ff, \"Query.where\", this.firestore.mf, this.firestore.__, o, i, r);\n return new e(function(t, e) {\n var n = t.filters.concat([ e ]);\n return new Pn(t.path, t.collectionGroup, t.on.slice(), n, t.limit, t.an, t.startAt, t.endAt);\n }(this.Ff, s), this.firestore, this.d_);\n }, e.prototype.orderBy = function(t, n) {\n var r;\n if (L(\"Query.orderBy\", arguments, 1, 2), R(\"Query.orderBy\", \"non-empty string\", 2, n), \n void 0 === n || \"asc\" === n) r = \"asc\" /* ASCENDING */; else {\n if (\"desc\" !== n) throw new c(a.INVALID_ARGUMENT, \"Function Query.orderBy() has unknown direction '\" + n + \"', expected 'asc' or 'desc'.\");\n r = \"desc\" /* DESCENDING */;\n }\n var i = qu(\"Query.orderBy\", t), o = oa(this.Ff, i, r);\n return new e(function(t, e) {\n // TODO(dimond): validate that orderBy does not list the same key twice.\n var n = t.on.concat([ e ]);\n return new Pn(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.an, t.startAt, t.endAt);\n }(this.Ff, o), this.firestore, this.d_);\n }, e.prototype.limit = function(t) {\n return D(\"Query.limit\", arguments, 1), k(\"Query.limit\", \"number\", 1, t), z(\"Query.limit\", 1, t), \n new e(Bn(this.Ff, t, \"F\" /* First */), this.firestore, this.d_);\n }, e.prototype.limitToLast = function(t) {\n return D(\"Query.limitToLast\", arguments, 1), k(\"Query.limitToLast\", \"number\", 1, t), \n z(\"Query.limitToLast\", 1, t), new e(Bn(this.Ff, t, \"L\" /* Last */), this.firestore, this.d_);\n }, e.prototype.startAt = function(t) {\n for (var n = [], r = 1; r < arguments.length; r++) n[r - 1] = arguments[r];\n x(\"Query.startAt\", arguments, 1);\n var i = this.xf(\"Query.startAt\", t, n, \n /*before=*/ !0);\n return new e(Wn(this.Ff, i), this.firestore, this.d_);\n }, e.prototype.startAfter = function(t) {\n for (var n = [], r = 1; r < arguments.length; r++) n[r - 1] = arguments[r];\n x(\"Query.startAfter\", arguments, 1);\n var i = this.xf(\"Query.startAfter\", t, n, \n /*before=*/ !1);\n return new e(Wn(this.Ff, i), this.firestore, this.d_);\n }, e.prototype.endBefore = function(t) {\n for (var n = [], r = 1; r < arguments.length; r++) n[r - 1] = arguments[r];\n x(\"Query.endBefore\", arguments, 1);\n var i = this.xf(\"Query.endBefore\", t, n, \n /*before=*/ !0);\n return new e(Kn(this.Ff, i), this.firestore, this.d_);\n }, e.prototype.endAt = function(t) {\n for (var n = [], r = 1; r < arguments.length; r++) n[r - 1] = arguments[r];\n x(\"Query.endAt\", arguments, 1);\n var i = this.xf(\"Query.endAt\", t, n, \n /*before=*/ !1);\n return new e(Kn(this.Ff, i), this.firestore, this.d_);\n }, e.prototype.isEqual = function(t) {\n if (!(t instanceof e)) throw G(\"isEqual\", \"Query\", 1, t);\n return this.firestore === t.firestore && Qn(this.Ff, t.Ff) && this.d_ === t.d_;\n }, e.prototype.withConverter = function(t) {\n return new e(this.Ff, this.firestore, t);\n }, \n /** Helper function to create a bound from a document or fields */ e.prototype.xf = function(e, n, r, i) {\n if (q(e, 1, n), n instanceof na) return D(e, t.__spreadArrays([ n ], r), 1), function(t, e, n, r, i) {\n if (!r) throw new c(a.NOT_FOUND, \"Can't use a DocumentSnapshot that doesn't exist for \" + n + \"().\");\n // Because people expect to continue/end a query at the exact document\n // provided, we need to use the implicit sort order rather than the explicit\n // sort order, because it's guaranteed to contain the document key. That way\n // the position becomes unambiguous and the query continues/ends exactly at\n // the provided document. Without the key (by using the explicit sort\n // orders), multiple documents could match the position, yielding duplicate\n // results.\n for (var o = [], s = 0, u = Gn(t); s < u.length; s++) {\n var h = u[s];\n if (h.field.p()) o.push(ae(e, r.key)); else {\n var f = r.field(h.field);\n if (Ht(f)) throw new c(a.INVALID_ARGUMENT, 'Invalid query. You are trying to start or end a query using a document for which the field \"' + h.field + '\" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');\n if (null === f) {\n var l = h.field.R();\n throw new c(a.INVALID_ARGUMENT, \"Invalid query. You are trying to start or end a query using a document for which the field '\" + l + \"' (used as the orderBy) does not exist.\");\n }\n o.push(f);\n }\n }\n return new ur(o, i);\n }(this.Ff, this.firestore.__, e, n.Df, i);\n var o = [ n ].concat(r);\n return function(t, e, n, r, i, o) {\n // Use explicit order by's because it has to match the query the user made\n var s = t.on;\n if (i.length > s.length) throw new c(a.INVALID_ARGUMENT, \"Too many arguments provided to \" + r + \"(). The number of arguments must be less than or equal to the number of orderBy() clauses\");\n for (var u = [], h = 0; h < i.length; h++) {\n var f = i[h];\n if (s[h].field.p()) {\n if (\"string\" != typeof f) throw new c(a.INVALID_ARGUMENT, \"Invalid query. Expected a string for document ID in \" + r + \"(), but got a \" + typeof f);\n if (!jn(t) && -1 !== f.indexOf(\"/\")) throw new c(a.INVALID_ARGUMENT, \"Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to \" + r + \"() must be a plain document ID, but '\" + f + \"' contains a slash.\");\n var l = t.path.child(E.g(f));\n if (!A.F(l)) throw new c(a.INVALID_ARGUMENT, \"Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to \" + r + \"() must result in a valid document path, but '\" + l + \"' is not because it contains an odd number of segments.\");\n var p = new A(l);\n u.push(ae(e, p));\n } else {\n var d = Vu(n, r, f);\n u.push(d);\n }\n }\n return new ur(u, o);\n }(this.Ff, this.firestore.__, this.firestore.mf, e, o, i);\n }, e.prototype.onSnapshot = function() {\n for (var t, e, n, r = this, i = [], o = 0; o < arguments.length; o++) i[o] = arguments[o];\n L(\"Query.onSnapshot\", arguments, 1, 4);\n var s = {}, u = 0;\n if (\"object\" != typeof i[u] || Qu(i[u]) || (j(\"Query.onSnapshot\", s = i[u], [ \"includeMetadataChanges\" ]), \n P(\"Query.onSnapshot\", \"boolean\", \"includeMetadataChanges\", s.includeMetadataChanges), \n u++), Qu(i[u])) {\n var a = i[u];\n i[u] = null === (t = a.next) || void 0 === t ? void 0 : t.bind(a), i[u + 1] = null === (e = a.error) || void 0 === e ? void 0 : e.bind(a), \n i[u + 2] = null === (n = a.complete) || void 0 === n ? void 0 : n.bind(a);\n } else k(\"Query.onSnapshot\", \"function\", u, i[u]), R(\"Query.onSnapshot\", \"function\", u + 1, i[u + 1]), \n R(\"Query.onSnapshot\", \"function\", u + 2, i[u + 2]);\n var c = {\n next: function(t) {\n i[u] && i[u](new fa(r.firestore, r.Ff, t, r.d_));\n },\n error: i[u + 1],\n complete: i[u + 2]\n };\n return ca(this.Ff), this.firestore.hf().listen(this.Ff, s, c);\n }, e.prototype.get = function(t) {\n var e = this;\n L(\"Query.get\", arguments, 0, 1), va(\"Query.get\", t), ca(this.Ff);\n var n = this.firestore.hf();\n return (t && \"cache\" === t.source ? n.j_(this.Ff) : n.K_(this.Ff, t)).then((function(t) {\n return new fa(e.firestore, e.Ff, t, e.d_);\n }));\n }, e;\n}(), fa = /** @class */ function() {\n function t(t, e, n, r) {\n this.yf = t, this.$f = e, this.kf = n, this.d_ = r, this.Mf = null, this.Of = null, \n this.metadata = new ea(n.hasPendingWrites, n.fromCache);\n }\n return Object.defineProperty(t.prototype, \"docs\", {\n get: function() {\n var t = [];\n return this.forEach((function(e) {\n return t.push(e);\n })), t;\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"empty\", {\n get: function() {\n return this.kf.docs.m();\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(t.prototype, \"size\", {\n get: function() {\n return this.kf.docs.size;\n },\n enumerable: !1,\n configurable: !0\n }), t.prototype.forEach = function(t, e) {\n var n = this;\n L(\"QuerySnapshot.forEach\", arguments, 1, 2), k(\"QuerySnapshot.forEach\", \"function\", 1, t), \n this.kf.docs.forEach((function(r) {\n t.call(e, n.Lf(r, n.metadata.fromCache, n.kf.Wt.has(r.key)));\n }));\n }, Object.defineProperty(t.prototype, \"query\", {\n get: function() {\n return new ha(this.$f, this.yf, this.d_);\n },\n enumerable: !1,\n configurable: !0\n }), t.prototype.docChanges = function(t) {\n t && (j(\"QuerySnapshot.docChanges\", t, [ \"includeMetadataChanges\" ]), P(\"QuerySnapshot.docChanges\", \"boolean\", \"includeMetadataChanges\", t.includeMetadataChanges));\n var e = !(!t || !t.includeMetadataChanges);\n if (e && this.kf.Kt) throw new c(a.INVALID_ARGUMENT, \"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().\");\n return this.Mf && this.Of === e || (this.Mf = \n /**\n * Calculates the array of DocumentChanges for a given ViewSnapshot.\n *\n * Exported for testing.\n *\n * @param snapshot The ViewSnapshot that represents the expected state.\n * @param includeMetadataChanges Whether to include metadata changes.\n * @param converter A factory function that returns a QueryDocumentSnapshot.\n * @return An object that matches the DocumentChange API.\n */\n function(t, e, n) {\n if (t.Qt.m()) {\n // Special case the first snapshot because index calculation is easy and\n // fast\n var r = 0;\n return t.docChanges.map((function(e) {\n var i = n(e.doc, t.fromCache, t.Wt.has(e.doc.key));\n return e.doc, {\n type: \"added\",\n doc: i,\n oldIndex: -1,\n newIndex: r++\n };\n }));\n }\n // A DocumentSet that is updated incrementally as changes are applied to use\n // to lookup the index of a document.\n var i = t.Qt;\n return t.docChanges.filter((function(t) {\n return e || 3 /* Metadata */ !== t.type;\n })).map((function(e) {\n var r = n(e.doc, t.fromCache, t.Wt.has(e.doc.key)), o = -1, s = -1;\n return 0 /* Added */ !== e.type && (o = i.indexOf(e.doc.key), i = i.delete(e.doc.key)), \n 1 /* Removed */ !== e.type && (s = (i = i.add(e.doc)).indexOf(e.doc.key)), {\n type: ga(e.type),\n doc: r,\n oldIndex: o,\n newIndex: s\n };\n }));\n }(this.kf, e, this.Lf.bind(this)), this.Of = e), this.Mf;\n }, \n /** Check the equality. The call can be very expensive. */ t.prototype.isEqual = function(e) {\n if (!(e instanceof t)) throw G(\"isEqual\", \"QuerySnapshot\", 1, e);\n return this.yf === e.yf && Qn(this.$f, e.$f) && this.kf.isEqual(e.kf) && this.d_ === e.d_;\n }, t.prototype.Lf = function(t, e, n) {\n return new ra(this.yf, t.key, t, e, n, this.d_);\n }, t;\n}(), la = /** @class */ function(e) {\n function n(t, n, r) {\n var i = this;\n if ((i = e.call(this, Un(t), n, r) || this).Bf = t, t.length % 2 != 1) throw new c(a.INVALID_ARGUMENT, \"Invalid collection reference. Collection references must have an odd number of segments, but \" + t.R() + \" has \" + t.length);\n return i;\n }\n return t.__extends(n, e), Object.defineProperty(n.prototype, \"id\", {\n get: function() {\n return this.Ff.path._();\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(n.prototype, \"parent\", {\n get: function() {\n var t = this.Ff.path.h();\n return t.m() ? null : new ta(new A(t), this.firestore, \n /* converter= */ null);\n },\n enumerable: !1,\n configurable: !0\n }), Object.defineProperty(n.prototype, \"path\", {\n get: function() {\n return this.Ff.path.R();\n },\n enumerable: !1,\n configurable: !0\n }), n.prototype.doc = function(t) {\n L(\"CollectionReference.doc\", arguments, 0, 1), \n // We allow omission of 'pathString' but explicitly prohibit passing in both\n // 'undefined' and 'null'.\n 0 === arguments.length && (t = Q.k()), k(\"CollectionReference.doc\", \"non-empty string\", 1, t);\n var e = E.g(t);\n return ta.Rf(this.Ff.path.child(e), this.firestore, this.d_);\n }, n.prototype.add = function(t) {\n D(\"CollectionReference.add\", arguments, 1);\n var e = this.d_ ? this.d_.toFirestore(t) : t;\n k(\"CollectionReference.add\", \"object\", 1, e);\n var n = this.doc();\n // Call set() with the converted value directly to avoid calling toFirestore() a second time.\n return new ta(n.f_, this.firestore, null).set(e).then((function() {\n return n;\n }));\n }, n.prototype.withConverter = function(t) {\n return new n(this.Bf, this.firestore, t);\n }, n;\n}(ha);\n\nfunction pa(t, e) {\n if (void 0 === e) return {\n merge: !1\n };\n if (j(t, e, [ \"merge\", \"mergeFields\" ]), P(t, \"boolean\", \"merge\", e.merge), function(t, e, n, r, i) {\n void 0 !== r && function(t, e, n, r, i) {\n if (!(r instanceof Array)) throw new c(a.INVALID_ARGUMENT, \"Function \" + t + \"() requires its \" + e + \" option to be an array, but it was: \" + M(r));\n for (var o = 0; o < r.length; ++o) if (!i(r[o])) throw new c(a.INVALID_ARGUMENT, \"Function \" + t + \"() requires all \" + e + \" elements to be \" + n + \", but the value at index \" + o + \" was: \" + M(r[o]));\n }(t, e, n, r, i);\n }(t, \"mergeFields\", \"a string or a FieldPath\", e.mergeFields, (function(t) {\n return \"string\" == typeof t || t instanceof du;\n })), void 0 !== e.mergeFields && void 0 !== e.merge) throw new c(a.INVALID_ARGUMENT, \"Invalid options passed to function \" + t + '(): You cannot specify both \"merge\" and \"mergeFields\".');\n return e;\n}\n\nfunction da(t, e) {\n return void 0 === e ? {} : (j(t, e, [ \"serverTimestamps\" ]), V(t, 0, \"serverTimestamps\", e.serverTimestamps, [ \"estimate\", \"previous\", \"none\" ]), \n e);\n}\n\nfunction va(t, e) {\n R(t, \"object\", 1, e), e && (j(t, e, [ \"source\" ]), V(t, 0, \"source\", e.source, [ \"default\", \"server\", \"cache\" ]));\n}\n\nfunction ya(t, e, n) {\n if (e instanceof Au) {\n if (e.firestore !== n) throw new c(a.INVALID_ARGUMENT, \"Provided document reference is from a different Firestore instance.\");\n return e;\n }\n throw G(t, \"DocumentReference\", 1, e);\n}\n\nfunction ga(t) {\n switch (t) {\n case 0 /* Added */ :\n return \"added\";\n\n case 2 /* Modified */ :\n case 3 /* Metadata */ :\n return \"modified\";\n\n case 1 /* Removed */ :\n return \"removed\";\n\n default:\n return y();\n }\n}\n\n/**\n * Converts custom model object of type T into DocumentData by applying the\n * converter if it exists.\n *\n * This function is used when converting user objects to DocumentData\n * because we want to provide the user with a more specific error message if\n * their set() or fails due to invalid data originating from a toFirestore()\n * call.\n */ function ma(t, e, n) {\n // Cast to `any` in order to satisfy the union type constraint on\n // toFirestore().\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return t ? n && (n.merge || n.mergeFields) ? t.toFirestore(e, n) : t.toFirestore(e) : e;\n}\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */ var wa = /** @class */ function(e) {\n function n() {\n return null !== e && e.apply(this, arguments) || this;\n }\n return t.__extends(n, e), n.serverTimestamp = function() {\n S(\"FieldValue.serverTimestamp\", arguments);\n var t = new wu(\"serverTimestamp\");\n return t.e_ = \"FieldValue.serverTimestamp\", new n(t);\n }, n.delete = function() {\n S(\"FieldValue.delete\", arguments);\n var t = new gu(\"deleteField\");\n return t.e_ = \"FieldValue.delete\", new n(t);\n }, n.arrayUnion = function() {\n for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];\n x(\"FieldValue.arrayUnion\", arguments, 1);\n var r = \n /**\n * Returns a special value that can be used with {@link setDoc()} or {@link\n * updateDoc()} that tells the server to union the given elements with any array\n * value that already exists on the server. Each specified element that doesn't\n * already exist in the array will be added to the end. If the field being\n * modified is not already an array it will be overwritten with an array\n * containing exactly the specified elements.\n *\n * @param elements The elements to union into the array.\n * @return The `FieldValue` sentinel for use in a call to `setDoc()` or\n * `updateDoc()`.\n */\n function() {\n for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];\n // NOTE: We don't actually parse the data until it's used in set() or\n // update() since we'd need the Firestore instance to do this.\n return x(\"arrayUnion()\", arguments, 1), new _u(\"arrayUnion\", t);\n }.apply(void 0, t);\n return r.e_ = \"FieldValue.arrayUnion\", new n(r);\n }, n.arrayRemove = function() {\n for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];\n x(\"FieldValue.arrayRemove\", arguments, 1);\n var r = function() {\n for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];\n // NOTE: We don't actually parse the data until it's used in set() or\n // update() since we'd need the Firestore instance to do this.\n return x(\"arrayRemove()\", arguments, 1), new bu(\"arrayRemove\", t);\n }.apply(void 0, t);\n return r.e_ = \"FieldValue.arrayRemove\", new n(r);\n }, n.increment = function(t) {\n k(\"FieldValue.increment\", \"number\", 1, t), D(\"FieldValue.increment\", arguments, 1);\n var e = function(t) {\n return new Iu(\"increment\", t);\n }(t);\n return e.e_ = \"FieldValue.increment\", new n(e);\n }, n.prototype.isEqual = function(t) {\n return this.l_.isEqual(t.l_);\n }, n;\n}(Tu), _a = {\n Firestore: Xu,\n GeoPoint: Eu,\n Timestamp: ot,\n Blob: et,\n Transaction: Ju,\n WriteBatch: Zu,\n DocumentReference: ta,\n DocumentSnapshot: na,\n Query: ha,\n QueryDocumentSnapshot: ra,\n QuerySnapshot: fa,\n CollectionReference: la,\n FieldPath: du,\n FieldValue: wa,\n setLogLevel: Xu.setLogLevel,\n CACHE_SIZE_UNLIMITED: Yu\n};\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Configures Firestore as part of the Firebase SDK by calling registerService.\n *\n * @param firebase The FirebaseNamespace to register Firestore with\n * @param firestoreFactory A factory function that returns a new Firestore\n * instance.\n */\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Registers the main Firestore build with the components framework.\n * Persistence can be enabled via `firebase.firestore().enablePersistence()`.\n */\nfunction ba(t) {\n !function(t, e) {\n t.INTERNAL.registerComponent(new o.Component(\"firestore\", (function(t) {\n return function(t, e) {\n var n = new fu, r = new hu(n);\n return new Xu(t, e, r, n);\n }(t.getProvider(\"app\").getImmediate(), t.getProvider(\"auth-internal\"));\n }), \"PUBLIC\" /* PUBLIC */).setServiceProps(Object.assign({}, _a)));\n }(t), t.registerVersion(\"@firebase/firestore\", \"1.18.0\");\n}\n\nba(u.default), exports.__PRIVATE_registerFirestore = ba;\n//# sourceMappingURL=index.cjs.js.map\n","'use strict';\nvar classof = require('../internals/classof-raw');\n\n// `IsArray` abstract operation\n// https://tc39.es/ecma262/#sec-isarray\n// eslint-disable-next-line es/no-array-isarray -- safe\nmodule.exports = Array.isArray || function isArray(argument) {\n return classof(argument) === 'Array';\n};\n","'use strict';\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar Iterators = require('../internals/iterators');\n\nvar ITERATOR = wellKnownSymbol('iterator');\nvar ArrayPrototype = Array.prototype;\n\n// check on default Array iterator\nmodule.exports = function (it) {\n return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);\n};\n","var toString = require('./toString'),\n upperFirst = require('./upperFirst');\n\n/**\n * Converts the first character of `string` to upper case and the remaining\n * to lower case.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to capitalize.\n * @returns {string} Returns the capitalized string.\n * @example\n *\n * _.capitalize('FRED');\n * // => 'Fred'\n */\nfunction capitalize(string) {\n return upperFirst(toString(string).toLowerCase());\n}\n\nmodule.exports = capitalize;\n","var asciiWords = require('./_asciiWords'),\n hasUnicodeWord = require('./_hasUnicodeWord'),\n toString = require('./toString'),\n unicodeWords = require('./_unicodeWords');\n\n/**\n * Splits `string` into an array of its words.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to inspect.\n * @param {RegExp|string} [pattern] The pattern to match words.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the words of `string`.\n * @example\n *\n * _.words('fred, barney, & pebbles');\n * // => ['fred', 'barney', 'pebbles']\n *\n * _.words('fred, barney, & pebbles', /[^, ]+/g);\n * // => ['fred', 'barney', '&', 'pebbles']\n */\nfunction words(string, pattern, guard) {\n string = toString(string);\n pattern = guard ? undefined : pattern;\n\n if (pattern === undefined) {\n return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);\n }\n return string.match(pattern) || [];\n}\n\nmodule.exports = words;\n","import '@firebase/auth';\n//# sourceMappingURL=index.esm.js.map\n","'use strict';\nvar makeBuiltIn = require('../internals/make-built-in');\nvar defineProperty = require('../internals/object-define-property');\n\nmodule.exports = function (target, name, descriptor) {\n if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true });\n if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true });\n return defineProperty.f(target, name, descriptor);\n};\n","/**!\n * @fileOverview Kickass library to create and place poppers near their reference elements.\n * @version 1.16.1\n * @license\n * Copyright (c) 2016 Federico Zivolo and contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nvar isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';\n\nvar timeoutDuration = function () {\n var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];\n for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {\n if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {\n return 1;\n }\n }\n return 0;\n}();\n\nfunction microtaskDebounce(fn) {\n var called = false;\n return function () {\n if (called) {\n return;\n }\n called = true;\n window.Promise.resolve().then(function () {\n called = false;\n fn();\n });\n };\n}\n\nfunction taskDebounce(fn) {\n var scheduled = false;\n return function () {\n if (!scheduled) {\n scheduled = true;\n setTimeout(function () {\n scheduled = false;\n fn();\n }, timeoutDuration);\n }\n };\n}\n\nvar supportsMicroTasks = isBrowser && window.Promise;\n\n/**\n* Create a debounced version of a method, that's asynchronously deferred\n* but called in the minimum time possible.\n*\n* @method\n* @memberof Popper.Utils\n* @argument {Function} fn\n* @returns {Function}\n*/\nvar debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;\n\n/**\n * Check if the given variable is a function\n * @method\n * @memberof Popper.Utils\n * @argument {Any} functionToCheck - variable to check\n * @returns {Boolean} answer to: is a function?\n */\nfunction isFunction(functionToCheck) {\n var getType = {};\n return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';\n}\n\n/**\n * Get CSS computed property of the given element\n * @method\n * @memberof Popper.Utils\n * @argument {Eement} element\n * @argument {String} property\n */\nfunction getStyleComputedProperty(element, property) {\n if (element.nodeType !== 1) {\n return [];\n }\n // NOTE: 1 DOM access here\n var window = element.ownerDocument.defaultView;\n var css = window.getComputedStyle(element, null);\n return property ? css[property] : css;\n}\n\n/**\n * Returns the parentNode or the host of the element\n * @method\n * @memberof Popper.Utils\n * @argument {Element} element\n * @returns {Element} parent\n */\nfunction getParentNode(element) {\n if (element.nodeName === 'HTML') {\n return element;\n }\n return element.parentNode || element.host;\n}\n\n/**\n * Returns the scrolling parent of the given element\n * @method\n * @memberof Popper.Utils\n * @argument {Element} element\n * @returns {Element} scroll parent\n */\nfunction getScrollParent(element) {\n // Return body, `getScroll` will take care to get the correct `scrollTop` from it\n if (!element) {\n return document.body;\n }\n\n switch (element.nodeName) {\n case 'HTML':\n case 'BODY':\n return element.ownerDocument.body;\n case '#document':\n return element.body;\n }\n\n // Firefox want us to check `-x` and `-y` variations as well\n\n var _getStyleComputedProp = getStyleComputedProperty(element),\n overflow = _getStyleComputedProp.overflow,\n overflowX = _getStyleComputedProp.overflowX,\n overflowY = _getStyleComputedProp.overflowY;\n\n if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {\n return element;\n }\n\n return getScrollParent(getParentNode(element));\n}\n\n/**\n * Returns the reference node of the reference object, or the reference object itself.\n * @method\n * @memberof Popper.Utils\n * @param {Element|Object} reference - the reference element (the popper will be relative to this)\n * @returns {Element} parent\n */\nfunction getReferenceNode(reference) {\n return reference && reference.referenceNode ? reference.referenceNode : reference;\n}\n\nvar isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);\nvar isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);\n\n/**\n * Determines if the browser is Internet Explorer\n * @method\n * @memberof Popper.Utils\n * @param {Number} version to check\n * @returns {Boolean} isIE\n */\nfunction isIE(version) {\n if (version === 11) {\n return isIE11;\n }\n if (version === 10) {\n return isIE10;\n }\n return isIE11 || isIE10;\n}\n\n/**\n * Returns the offset parent of the given element\n * @method\n * @memberof Popper.Utils\n * @argument {Element} element\n * @returns {Element} offset parent\n */\nfunction getOffsetParent(element) {\n if (!element) {\n return document.documentElement;\n }\n\n var noOffsetParent = isIE(10) ? document.body : null;\n\n // NOTE: 1 DOM access here\n var offsetParent = element.offsetParent || null;\n // Skip hidden elements which don't have an offsetParent\n while (offsetParent === noOffsetParent && element.nextElementSibling) {\n offsetParent = (element = element.nextElementSibling).offsetParent;\n }\n\n var nodeName = offsetParent && offsetParent.nodeName;\n\n if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {\n return element ? element.ownerDocument.documentElement : document.documentElement;\n }\n\n // .offsetParent will return the closest TH, TD or TABLE in case\n // no offsetParent is present, I hate this job...\n if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {\n return getOffsetParent(offsetParent);\n }\n\n return offsetParent;\n}\n\nfunction isOffsetContainer(element) {\n var nodeName = element.nodeName;\n\n if (nodeName === 'BODY') {\n return false;\n }\n return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;\n}\n\n/**\n * Finds the root node (document, shadowDOM root) of the given element\n * @method\n * @memberof Popper.Utils\n * @argument {Element} node\n * @returns {Element} root node\n */\nfunction getRoot(node) {\n if (node.parentNode !== null) {\n return getRoot(node.parentNode);\n }\n\n return node;\n}\n\n/**\n * Finds the offset parent common to the two provided nodes\n * @method\n * @memberof Popper.Utils\n * @argument {Element} element1\n * @argument {Element} element2\n * @returns {Element} common offset parent\n */\nfunction findCommonOffsetParent(element1, element2) {\n // This check is needed to avoid errors in case one of the elements isn't defined for any reason\n if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {\n return document.documentElement;\n }\n\n // Here we make sure to give as \"start\" the element that comes first in the DOM\n var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;\n var start = order ? element1 : element2;\n var end = order ? element2 : element1;\n\n // Get common ancestor container\n var range = document.createRange();\n range.setStart(start, 0);\n range.setEnd(end, 0);\n var commonAncestorContainer = range.commonAncestorContainer;\n\n // Both nodes are inside #document\n\n if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {\n if (isOffsetContainer(commonAncestorContainer)) {\n return commonAncestorContainer;\n }\n\n return getOffsetParent(commonAncestorContainer);\n }\n\n // one of the nodes is inside shadowDOM, find which one\n var element1root = getRoot(element1);\n if (element1root.host) {\n return findCommonOffsetParent(element1root.host, element2);\n } else {\n return findCommonOffsetParent(element1, getRoot(element2).host);\n }\n}\n\n/**\n * Gets the scroll value of the given element in the given side (top and left)\n * @method\n * @memberof Popper.Utils\n * @argument {Element} element\n * @argument {String} side `top` or `left`\n * @returns {number} amount of scrolled pixels\n */\nfunction getScroll(element) {\n var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';\n\n var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';\n var nodeName = element.nodeName;\n\n if (nodeName === 'BODY' || nodeName === 'HTML') {\n var html = element.ownerDocument.documentElement;\n var scrollingElement = element.ownerDocument.scrollingElement || html;\n return scrollingElement[upperSide];\n }\n\n return element[upperSide];\n}\n\n/*\n * Sum or subtract the element scroll values (left and top) from a given rect object\n * @method\n * @memberof Popper.Utils\n * @param {Object} rect - Rect object you want to change\n * @param {HTMLElement} element - The element from the function reads the scroll values\n * @param {Boolean} subtract - set to true if you want to subtract the scroll values\n * @return {Object} rect - The modifier rect object\n */\nfunction includeScroll(rect, element) {\n var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n\n var scrollTop = getScroll(element, 'top');\n var scrollLeft = getScroll(element, 'left');\n var modifier = subtract ? -1 : 1;\n rect.top += scrollTop * modifier;\n rect.bottom += scrollTop * modifier;\n rect.left += scrollLeft * modifier;\n rect.right += scrollLeft * modifier;\n return rect;\n}\n\n/*\n * Helper to detect borders of a given element\n * @method\n * @memberof Popper.Utils\n * @param {CSSStyleDeclaration} styles\n * Result of `getStyleComputedProperty` on the given element\n * @param {String} axis - `x` or `y`\n * @return {number} borders - The borders size of the given axis\n */\n\nfunction getBordersSize(styles, axis) {\n var sideA = axis === 'x' ? 'Left' : 'Top';\n var sideB = sideA === 'Left' ? 'Right' : 'Bottom';\n\n return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);\n}\n\nfunction getSize(axis, body, html, computedStyle) {\n return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);\n}\n\nfunction getWindowSizes(document) {\n var body = document.body;\n var html = document.documentElement;\n var computedStyle = isIE(10) && getComputedStyle(html);\n\n return {\n height: getSize('Height', body, html, computedStyle),\n width: getSize('Width', body, html, computedStyle)\n };\n}\n\nvar classCallCheck = function (instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n};\n\nvar createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n\n return function (Constructor, protoProps, staticProps) {\n if (protoProps) defineProperties(Constructor.prototype, protoProps);\n if (staticProps) defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\n\n\n\n\n\nvar defineProperty = function (obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n};\n\nvar _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n};\n\n/**\n * Given element offsets, generate an output similar to getBoundingClientRect\n * @method\n * @memberof Popper.Utils\n * @argument {Object} offsets\n * @returns {Object} ClientRect like output\n */\nfunction getClientRect(offsets) {\n return _extends({}, offsets, {\n right: offsets.left + offsets.width,\n bottom: offsets.top + offsets.height\n });\n}\n\n/**\n * Get bounding client rect of given element\n * @method\n * @memberof Popper.Utils\n * @param {HTMLElement} element\n * @return {Object} client rect\n */\nfunction getBoundingClientRect(element) {\n var rect = {};\n\n // IE10 10 FIX: Please, don't ask, the element isn't\n // considered in DOM in some circumstances...\n // This isn't reproducible in IE10 compatibility mode of IE11\n try {\n if (isIE(10)) {\n rect = element.getBoundingClientRect();\n var scrollTop = getScroll(element, 'top');\n var scrollLeft = getScroll(element, 'left');\n rect.top += scrollTop;\n rect.left += scrollLeft;\n rect.bottom += scrollTop;\n rect.right += scrollLeft;\n } else {\n rect = element.getBoundingClientRect();\n }\n } catch (e) {}\n\n var result = {\n left: rect.left,\n top: rect.top,\n width: rect.right - rect.left,\n height: rect.bottom - rect.top\n };\n\n // subtract scrollbar size from sizes\n var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};\n var width = sizes.width || element.clientWidth || result.width;\n var height = sizes.height || element.clientHeight || result.height;\n\n var horizScrollbar = element.offsetWidth - width;\n var vertScrollbar = element.offsetHeight - height;\n\n // if an hypothetical scrollbar is detected, we must be sure it's not a `border`\n // we make this check conditional for performance reasons\n if (horizScrollbar || vertScrollbar) {\n var styles = getStyleComputedProperty(element);\n horizScrollbar -= getBordersSize(styles, 'x');\n vertScrollbar -= getBordersSize(styles, 'y');\n\n result.width -= horizScrollbar;\n result.height -= vertScrollbar;\n }\n\n return getClientRect(result);\n}\n\nfunction getOffsetRectRelativeToArbitraryNode(children, parent) {\n var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n\n var isIE10 = isIE(10);\n var isHTML = parent.nodeName === 'HTML';\n var childrenRect = getBoundingClientRect(children);\n var parentRect = getBoundingClientRect(parent);\n var scrollParent = getScrollParent(children);\n\n var styles = getStyleComputedProperty(parent);\n var borderTopWidth = parseFloat(styles.borderTopWidth);\n var borderLeftWidth = parseFloat(styles.borderLeftWidth);\n\n // In cases where the parent is fixed, we must ignore negative scroll in offset calc\n if (fixedPosition && isHTML) {\n parentRect.top = Math.max(parentRect.top, 0);\n parentRect.left = Math.max(parentRect.left, 0);\n }\n var offsets = getClientRect({\n top: childrenRect.top - parentRect.top - borderTopWidth,\n left: childrenRect.left - parentRect.left - borderLeftWidth,\n width: childrenRect.width,\n height: childrenRect.height\n });\n offsets.marginTop = 0;\n offsets.marginLeft = 0;\n\n // Subtract margins of documentElement in case it's being used as parent\n // we do this only on HTML because it's the only element that behaves\n // differently when margins are applied to it. The margins are included in\n // the box of the documentElement, in the other cases not.\n if (!isIE10 && isHTML) {\n var marginTop = parseFloat(styles.marginTop);\n var marginLeft = parseFloat(styles.marginLeft);\n\n offsets.top -= borderTopWidth - marginTop;\n offsets.bottom -= borderTopWidth - marginTop;\n offsets.left -= borderLeftWidth - marginLeft;\n offsets.right -= borderLeftWidth - marginLeft;\n\n // Attach marginTop and marginLeft because in some circumstances we may need them\n offsets.marginTop = marginTop;\n offsets.marginLeft = marginLeft;\n }\n\n if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {\n offsets = includeScroll(offsets, parent);\n }\n\n return offsets;\n}\n\nfunction getViewportOffsetRectRelativeToArtbitraryNode(element) {\n var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\n var html = element.ownerDocument.documentElement;\n var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);\n var width = Math.max(html.clientWidth, window.innerWidth || 0);\n var height = Math.max(html.clientHeight, window.innerHeight || 0);\n\n var scrollTop = !excludeScroll ? getScroll(html) : 0;\n var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;\n\n var offset = {\n top: scrollTop - relativeOffset.top + relativeOffset.marginTop,\n left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,\n width: width,\n height: height\n };\n\n return getClientRect(offset);\n}\n\n/**\n * Check if the given element is fixed or is inside a fixed parent\n * @method\n * @memberof Popper.Utils\n * @argument {Element} element\n * @argument {Element} customContainer\n * @returns {Boolean} answer to \"isFixed?\"\n */\nfunction isFixed(element) {\n var nodeName = element.nodeName;\n if (nodeName === 'BODY' || nodeName === 'HTML') {\n return false;\n }\n if (getStyleComputedProperty(element, 'position') === 'fixed') {\n return true;\n }\n var parentNode = getParentNode(element);\n if (!parentNode) {\n return false;\n }\n return isFixed(parentNode);\n}\n\n/**\n * Finds the first parent of an element that has a transformed property defined\n * @method\n * @memberof Popper.Utils\n * @argument {Element} element\n * @returns {Element} first transformed parent or documentElement\n */\n\nfunction getFixedPositionOffsetParent(element) {\n // This check is needed to avoid errors in case one of the elements isn't defined for any reason\n if (!element || !element.parentElement || isIE()) {\n return document.documentElement;\n }\n var el = element.parentElement;\n while (el && getStyleComputedProperty(el, 'transform') === 'none') {\n el = el.parentElement;\n }\n return el || document.documentElement;\n}\n\n/**\n * Computed the boundaries limits and return them\n * @method\n * @memberof Popper.Utils\n * @param {HTMLElement} popper\n * @param {HTMLElement} reference\n * @param {number} padding\n * @param {HTMLElement} boundariesElement - Element used to define the boundaries\n * @param {Boolean} fixedPosition - Is in fixed position mode\n * @returns {Object} Coordinates of the boundaries\n */\nfunction getBoundaries(popper, reference, padding, boundariesElement) {\n var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n\n // NOTE: 1 DOM access here\n\n var boundaries = { top: 0, left: 0 };\n var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));\n\n // Handle viewport case\n if (boundariesElement === 'viewport') {\n boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);\n } else {\n // Handle other cases based on DOM element used as boundaries\n var boundariesNode = void 0;\n if (boundariesElement === 'scrollParent') {\n boundariesNode = getScrollParent(getParentNode(reference));\n if (boundariesNode.nodeName === 'BODY') {\n boundariesNode = popper.ownerDocument.documentElement;\n }\n } else if (boundariesElement === 'window') {\n boundariesNode = popper.ownerDocument.documentElement;\n } else {\n boundariesNode = boundariesElement;\n }\n\n var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);\n\n // In case of HTML, we need a different computation\n if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {\n var _getWindowSizes = getWindowSizes(popper.ownerDocument),\n height = _getWindowSizes.height,\n width = _getWindowSizes.width;\n\n boundaries.top += offsets.top - offsets.marginTop;\n boundaries.bottom = height + offsets.top;\n boundaries.left += offsets.left - offsets.marginLeft;\n boundaries.right = width + offsets.left;\n } else {\n // for all the other DOM elements, this one is good\n boundaries = offsets;\n }\n }\n\n // Add paddings\n padding = padding || 0;\n var isPaddingNumber = typeof padding === 'number';\n boundaries.left += isPaddingNumber ? padding : padding.left || 0;\n boundaries.top += isPaddingNumber ? padding : padding.top || 0;\n boundaries.right -= isPaddingNumber ? padding : padding.right || 0;\n boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;\n\n return boundaries;\n}\n\nfunction getArea(_ref) {\n var width = _ref.width,\n height = _ref.height;\n\n return width * height;\n}\n\n/**\n * Utility used to transform the `auto` placement to the placement with more\n * available space.\n * @method\n * @memberof Popper.Utils\n * @argument {Object} data - The data object generated by update method\n * @argument {Object} options - Modifiers configuration and options\n * @returns {Object} The data object, properly modified\n */\nfunction computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {\n var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;\n\n if (placement.indexOf('auto') === -1) {\n return placement;\n }\n\n var boundaries = getBoundaries(popper, reference, padding, boundariesElement);\n\n var rects = {\n top: {\n width: boundaries.width,\n height: refRect.top - boundaries.top\n },\n right: {\n width: boundaries.right - refRect.right,\n height: boundaries.height\n },\n bottom: {\n width: boundaries.width,\n height: boundaries.bottom - refRect.bottom\n },\n left: {\n width: refRect.left - boundaries.left,\n height: boundaries.height\n }\n };\n\n var sortedAreas = Object.keys(rects).map(function (key) {\n return _extends({\n key: key\n }, rects[key], {\n area: getArea(rects[key])\n });\n }).sort(function (a, b) {\n return b.area - a.area;\n });\n\n var filteredAreas = sortedAreas.filter(function (_ref2) {\n var width = _ref2.width,\n height = _ref2.height;\n return width >= popper.clientWidth && height >= popper.clientHeight;\n });\n\n var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;\n\n var variation = placement.split('-')[1];\n\n return computedPlacement + (variation ? '-' + variation : '');\n}\n\n/**\n * Get offsets to the reference element\n * @method\n * @memberof Popper.Utils\n * @param {Object} state\n * @param {Element} popper - the popper element\n * @param {Element} reference - the reference element (the popper will be relative to this)\n * @param {Element} fixedPosition - is in fixed position mode\n * @returns {Object} An object containing the offsets which will be applied to the popper\n */\nfunction getReferenceOffsets(state, popper, reference) {\n var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;\n\n var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));\n return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);\n}\n\n/**\n * Get the outer sizes of the given element (offset size + margins)\n * @method\n * @memberof Popper.Utils\n * @argument {Element} element\n * @returns {Object} object containing width and height properties\n */\nfunction getOuterSizes(element) {\n var window = element.ownerDocument.defaultView;\n var styles = window.getComputedStyle(element);\n var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);\n var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);\n var result = {\n width: element.offsetWidth + y,\n height: element.offsetHeight + x\n };\n return result;\n}\n\n/**\n * Get the opposite placement of the given one\n * @method\n * @memberof Popper.Utils\n * @argument {String} placement\n * @returns {String} flipped placement\n */\nfunction getOppositePlacement(placement) {\n var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };\n return placement.replace(/left|right|bottom|top/g, function (matched) {\n return hash[matched];\n });\n}\n\n/**\n * Get offsets to the popper\n * @method\n * @memberof Popper.Utils\n * @param {Object} position - CSS position the Popper will get applied\n * @param {HTMLElement} popper - the popper element\n * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)\n * @param {String} placement - one of the valid placement options\n * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper\n */\nfunction getPopperOffsets(popper, referenceOffsets, placement) {\n placement = placement.split('-')[0];\n\n // Get popper node sizes\n var popperRect = getOuterSizes(popper);\n\n // Add position, width and height to our offsets object\n var popperOffsets = {\n width: popperRect.width,\n height: popperRect.height\n };\n\n // depending by the popper placement we have to compute its offsets slightly differently\n var isHoriz = ['right', 'left'].indexOf(placement) !== -1;\n var mainSide = isHoriz ? 'top' : 'left';\n var secondarySide = isHoriz ? 'left' : 'top';\n var measurement = isHoriz ? 'height' : 'width';\n var secondaryMeasurement = !isHoriz ? 'height' : 'width';\n\n popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;\n if (placement === secondarySide) {\n popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];\n } else {\n popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];\n }\n\n return popperOffsets;\n}\n\n/**\n * Mimics the `find` method of Array\n * @method\n * @memberof Popper.Utils\n * @argument {Array} arr\n * @argument prop\n * @argument value\n * @returns index or -1\n */\nfunction find(arr, check) {\n // use native find if supported\n if (Array.prototype.find) {\n return arr.find(check);\n }\n\n // use `filter` to obtain the same behavior of `find`\n return arr.filter(check)[0];\n}\n\n/**\n * Return the index of the matching object\n * @method\n * @memberof Popper.Utils\n * @argument {Array} arr\n * @argument prop\n * @argument value\n * @returns index or -1\n */\nfunction findIndex(arr, prop, value) {\n // use native findIndex if supported\n if (Array.prototype.findIndex) {\n return arr.findIndex(function (cur) {\n return cur[prop] === value;\n });\n }\n\n // use `find` + `indexOf` if `findIndex` isn't supported\n var match = find(arr, function (obj) {\n return obj[prop] === value;\n });\n return arr.indexOf(match);\n}\n\n/**\n * Loop trough the list of modifiers and run them in order,\n * each of them will then edit the data object.\n * @method\n * @memberof Popper.Utils\n * @param {dataObject} data\n * @param {Array} modifiers\n * @param {String} ends - Optional modifier name used as stopper\n * @returns {dataObject}\n */\nfunction runModifiers(modifiers, data, ends) {\n var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));\n\n modifiersToRun.forEach(function (modifier) {\n if (modifier['function']) {\n // eslint-disable-line dot-notation\n console.warn('`modifier.function` is deprecated, use `modifier.fn`!');\n }\n var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation\n if (modifier.enabled && isFunction(fn)) {\n // Add properties to offsets to make them a complete clientRect object\n // we do this before each modifier to make sure the previous one doesn't\n // mess with these values\n data.offsets.popper = getClientRect(data.offsets.popper);\n data.offsets.reference = getClientRect(data.offsets.reference);\n\n data = fn(data, modifier);\n }\n });\n\n return data;\n}\n\n/**\n * Updates the position of the popper, computing the new offsets and applying\n * the new style.
\n * Prefer `scheduleUpdate` over `update` because of performance reasons.\n * @method\n * @memberof Popper\n */\nfunction update() {\n // if popper is destroyed, don't perform any further update\n if (this.state.isDestroyed) {\n return;\n }\n\n var data = {\n instance: this,\n styles: {},\n arrowStyles: {},\n attributes: {},\n flipped: false,\n offsets: {}\n };\n\n // compute reference element offsets\n data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);\n\n // compute auto placement, store placement inside the data object,\n // modifiers will be able to edit `placement` if needed\n // and refer to originalPlacement to know the original value\n data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);\n\n // store the computed placement inside `originalPlacement`\n data.originalPlacement = data.placement;\n\n data.positionFixed = this.options.positionFixed;\n\n // compute the popper offsets\n data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);\n\n data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';\n\n // run the modifiers\n data = runModifiers(this.modifiers, data);\n\n // the first `update` will call `onCreate` callback\n // the other ones will call `onUpdate` callback\n if (!this.state.isCreated) {\n this.state.isCreated = true;\n this.options.onCreate(data);\n } else {\n this.options.onUpdate(data);\n }\n}\n\n/**\n * Helper used to know if the given modifier is enabled.\n * @method\n * @memberof Popper.Utils\n * @returns {Boolean}\n */\nfunction isModifierEnabled(modifiers, modifierName) {\n return modifiers.some(function (_ref) {\n var name = _ref.name,\n enabled = _ref.enabled;\n return enabled && name === modifierName;\n });\n}\n\n/**\n * Get the prefixed supported property name\n * @method\n * @memberof Popper.Utils\n * @argument {String} property (camelCase)\n * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)\n */\nfunction getSupportedPropertyName(property) {\n var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];\n var upperProp = property.charAt(0).toUpperCase() + property.slice(1);\n\n for (var i = 0; i < prefixes.length; i++) {\n var prefix = prefixes[i];\n var toCheck = prefix ? '' + prefix + upperProp : property;\n if (typeof document.body.style[toCheck] !== 'undefined') {\n return toCheck;\n }\n }\n return null;\n}\n\n/**\n * Destroys the popper.\n * @method\n * @memberof Popper\n */\nfunction destroy() {\n this.state.isDestroyed = true;\n\n // touch DOM only if `applyStyle` modifier is enabled\n if (isModifierEnabled(this.modifiers, 'applyStyle')) {\n this.popper.removeAttribute('x-placement');\n this.popper.style.position = '';\n this.popper.style.top = '';\n this.popper.style.left = '';\n this.popper.style.right = '';\n this.popper.style.bottom = '';\n this.popper.style.willChange = '';\n this.popper.style[getSupportedPropertyName('transform')] = '';\n }\n\n this.disableEventListeners();\n\n // remove the popper if user explicitly asked for the deletion on destroy\n // do not use `remove` because IE11 doesn't support it\n if (this.options.removeOnDestroy) {\n this.popper.parentNode.removeChild(this.popper);\n }\n return this;\n}\n\n/**\n * Get the window associated with the element\n * @argument {Element} element\n * @returns {Window}\n */\nfunction getWindow(element) {\n var ownerDocument = element.ownerDocument;\n return ownerDocument ? ownerDocument.defaultView : window;\n}\n\nfunction attachToScrollParents(scrollParent, event, callback, scrollParents) {\n var isBody = scrollParent.nodeName === 'BODY';\n var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;\n target.addEventListener(event, callback, { passive: true });\n\n if (!isBody) {\n attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);\n }\n scrollParents.push(target);\n}\n\n/**\n * Setup needed event listeners used to update the popper position\n * @method\n * @memberof Popper.Utils\n * @private\n */\nfunction setupEventListeners(reference, options, state, updateBound) {\n // Resize event listener on window\n state.updateBound = updateBound;\n getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });\n\n // Scroll event listener on scroll parents\n var scrollElement = getScrollParent(reference);\n attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);\n state.scrollElement = scrollElement;\n state.eventsEnabled = true;\n\n return state;\n}\n\n/**\n * It will add resize/scroll events and start recalculating\n * position of the popper element when they are triggered.\n * @method\n * @memberof Popper\n */\nfunction enableEventListeners() {\n if (!this.state.eventsEnabled) {\n this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);\n }\n}\n\n/**\n * Remove event listeners used to update the popper position\n * @method\n * @memberof Popper.Utils\n * @private\n */\nfunction removeEventListeners(reference, state) {\n // Remove resize event listener on window\n getWindow(reference).removeEventListener('resize', state.updateBound);\n\n // Remove scroll event listener on scroll parents\n state.scrollParents.forEach(function (target) {\n target.removeEventListener('scroll', state.updateBound);\n });\n\n // Reset state\n state.updateBound = null;\n state.scrollParents = [];\n state.scrollElement = null;\n state.eventsEnabled = false;\n return state;\n}\n\n/**\n * It will remove resize/scroll events and won't recalculate popper position\n * when they are triggered. It also won't trigger `onUpdate` callback anymore,\n * unless you call `update` method manually.\n * @method\n * @memberof Popper\n */\nfunction disableEventListeners() {\n if (this.state.eventsEnabled) {\n cancelAnimationFrame(this.scheduleUpdate);\n this.state = removeEventListeners(this.reference, this.state);\n }\n}\n\n/**\n * Tells if a given input is a number\n * @method\n * @memberof Popper.Utils\n * @param {*} input to check\n * @return {Boolean}\n */\nfunction isNumeric(n) {\n return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);\n}\n\n/**\n * Set the style to the given popper\n * @method\n * @memberof Popper.Utils\n * @argument {Element} element - Element to apply the style to\n * @argument {Object} styles\n * Object with a list of properties and values which will be applied to the element\n */\nfunction setStyles(element, styles) {\n Object.keys(styles).forEach(function (prop) {\n var unit = '';\n // add unit if the value is numeric and is one of the following\n if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {\n unit = 'px';\n }\n element.style[prop] = styles[prop] + unit;\n });\n}\n\n/**\n * Set the attributes to the given popper\n * @method\n * @memberof Popper.Utils\n * @argument {Element} element - Element to apply the attributes to\n * @argument {Object} styles\n * Object with a list of properties and values which will be applied to the element\n */\nfunction setAttributes(element, attributes) {\n Object.keys(attributes).forEach(function (prop) {\n var value = attributes[prop];\n if (value !== false) {\n element.setAttribute(prop, attributes[prop]);\n } else {\n element.removeAttribute(prop);\n }\n });\n}\n\n/**\n * @function\n * @memberof Modifiers\n * @argument {Object} data - The data object generated by `update` method\n * @argument {Object} data.styles - List of style properties - values to apply to popper element\n * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element\n * @argument {Object} options - Modifiers configuration and options\n * @returns {Object} The same data object\n */\nfunction applyStyle(data) {\n // any property present in `data.styles` will be applied to the popper,\n // in this way we can make the 3rd party modifiers add custom styles to it\n // Be aware, modifiers could override the properties defined in the previous\n // lines of this modifier!\n setStyles(data.instance.popper, data.styles);\n\n // any property present in `data.attributes` will be applied to the popper,\n // they will be set as HTML attributes of the element\n setAttributes(data.instance.popper, data.attributes);\n\n // if arrowElement is defined and arrowStyles has some properties\n if (data.arrowElement && Object.keys(data.arrowStyles).length) {\n setStyles(data.arrowElement, data.arrowStyles);\n }\n\n return data;\n}\n\n/**\n * Set the x-placement attribute before everything else because it could be used\n * to add margins to the popper margins needs to be calculated to get the\n * correct popper offsets.\n * @method\n * @memberof Popper.modifiers\n * @param {HTMLElement} reference - The reference element used to position the popper\n * @param {HTMLElement} popper - The HTML element used as popper\n * @param {Object} options - Popper.js options\n */\nfunction applyStyleOnLoad(reference, popper, options, modifierOptions, state) {\n // compute reference element offsets\n var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);\n\n // compute auto placement, store placement inside the data object,\n // modifiers will be able to edit `placement` if needed\n // and refer to originalPlacement to know the original value\n var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);\n\n popper.setAttribute('x-placement', placement);\n\n // Apply `position` to popper before anything else because\n // without the position applied we can't guarantee correct computations\n setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });\n\n return options;\n}\n\n/**\n * @function\n * @memberof Popper.Utils\n * @argument {Object} data - The data object generated by `update` method\n * @argument {Boolean} shouldRound - If the offsets should be rounded at all\n * @returns {Object} The popper's position offsets rounded\n *\n * The tale of pixel-perfect positioning. It's still not 100% perfect, but as\n * good as it can be within reason.\n * Discussion here: https://github.com/FezVrasta/popper.js/pull/715\n *\n * Low DPI screens cause a popper to be blurry if not using full pixels (Safari\n * as well on High DPI screens).\n *\n * Firefox prefers no rounding for positioning and does not have blurriness on\n * high DPI screens.\n *\n * Only horizontal placement and left/right values need to be considered.\n */\nfunction getRoundedOffsets(data, shouldRound) {\n var _data$offsets = data.offsets,\n popper = _data$offsets.popper,\n reference = _data$offsets.reference;\n var round = Math.round,\n floor = Math.floor;\n\n var noRound = function noRound(v) {\n return v;\n };\n\n var referenceWidth = round(reference.width);\n var popperWidth = round(popper.width);\n\n var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;\n var isVariation = data.placement.indexOf('-') !== -1;\n var sameWidthParity = referenceWidth % 2 === popperWidth % 2;\n var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;\n\n var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;\n var verticalToInteger = !shouldRound ? noRound : round;\n\n return {\n left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),\n top: verticalToInteger(popper.top),\n bottom: verticalToInteger(popper.bottom),\n right: horizontalToInteger(popper.right)\n };\n}\n\nvar isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);\n\n/**\n * @function\n * @memberof Modifiers\n * @argument {Object} data - The data object generated by `update` method\n * @argument {Object} options - Modifiers configuration and options\n * @returns {Object} The data object, properly modified\n */\nfunction computeStyle(data, options) {\n var x = options.x,\n y = options.y;\n var popper = data.offsets.popper;\n\n // Remove this legacy support in Popper.js v2\n\n var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {\n return modifier.name === 'applyStyle';\n }).gpuAcceleration;\n if (legacyGpuAccelerationOption !== undefined) {\n console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');\n }\n var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;\n\n var offsetParent = getOffsetParent(data.instance.popper);\n var offsetParentRect = getBoundingClientRect(offsetParent);\n\n // Styles\n var styles = {\n position: popper.position\n };\n\n var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);\n\n var sideA = x === 'bottom' ? 'top' : 'bottom';\n var sideB = y === 'right' ? 'left' : 'right';\n\n // if gpuAcceleration is set to `true` and transform is supported,\n // we use `translate3d` to apply the position to the popper we\n // automatically use the supported prefixed version if needed\n var prefixedProperty = getSupportedPropertyName('transform');\n\n // now, let's make a step back and look at this code closely (wtf?)\n // If the content of the popper grows once it's been positioned, it\n // may happen that the popper gets misplaced because of the new content\n // overflowing its reference element\n // To avoid this problem, we provide two options (x and y), which allow\n // the consumer to define the offset origin.\n // If we position a popper on top of a reference element, we can set\n // `x` to `top` to make the popper grow towards its top instead of\n // its bottom.\n var left = void 0,\n top = void 0;\n if (sideA === 'bottom') {\n // when offsetParent is the positioning is relative to the bottom of the screen (excluding the scrollbar)\n // and not the bottom of the html element\n if (offsetParent.nodeName === 'HTML') {\n top = -offsetParent.clientHeight + offsets.bottom;\n } else {\n top = -offsetParentRect.height + offsets.bottom;\n }\n } else {\n top = offsets.top;\n }\n if (sideB === 'right') {\n if (offsetParent.nodeName === 'HTML') {\n left = -offsetParent.clientWidth + offsets.right;\n } else {\n left = -offsetParentRect.width + offsets.right;\n }\n } else {\n left = offsets.left;\n }\n if (gpuAcceleration && prefixedProperty) {\n styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';\n styles[sideA] = 0;\n styles[sideB] = 0;\n styles.willChange = 'transform';\n } else {\n // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties\n var invertTop = sideA === 'bottom' ? -1 : 1;\n var invertLeft = sideB === 'right' ? -1 : 1;\n styles[sideA] = top * invertTop;\n styles[sideB] = left * invertLeft;\n styles.willChange = sideA + ', ' + sideB;\n }\n\n // Attributes\n var attributes = {\n 'x-placement': data.placement\n };\n\n // Update `data` attributes, styles and arrowStyles\n data.attributes = _extends({}, attributes, data.attributes);\n data.styles = _extends({}, styles, data.styles);\n data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);\n\n return data;\n}\n\n/**\n * Helper used to know if the given modifier depends from another one.
\n * It checks if the needed modifier is listed and enabled.\n * @method\n * @memberof Popper.Utils\n * @param {Array} modifiers - list of modifiers\n * @param {String} requestingName - name of requesting modifier\n * @param {String} requestedName - name of requested modifier\n * @returns {Boolean}\n */\nfunction isModifierRequired(modifiers, requestingName, requestedName) {\n var requesting = find(modifiers, function (_ref) {\n var name = _ref.name;\n return name === requestingName;\n });\n\n var isRequired = !!requesting && modifiers.some(function (modifier) {\n return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;\n });\n\n if (!isRequired) {\n var _requesting = '`' + requestingName + '`';\n var requested = '`' + requestedName + '`';\n console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');\n }\n return isRequired;\n}\n\n/**\n * @function\n * @memberof Modifiers\n * @argument {Object} data - The data object generated by update method\n * @argument {Object} options - Modifiers configuration and options\n * @returns {Object} The data object, properly modified\n */\nfunction arrow(data, options) {\n var _data$offsets$arrow;\n\n // arrow depends on keepTogether in order to work\n if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {\n return data;\n }\n\n var arrowElement = options.element;\n\n // if arrowElement is a string, suppose it's a CSS selector\n if (typeof arrowElement === 'string') {\n arrowElement = data.instance.popper.querySelector(arrowElement);\n\n // if arrowElement is not found, don't run the modifier\n if (!arrowElement) {\n return data;\n }\n } else {\n // if the arrowElement isn't a query selector we must check that the\n // provided DOM node is child of its popper node\n if (!data.instance.popper.contains(arrowElement)) {\n console.warn('WARNING: `arrow.element` must be child of its popper element!');\n return data;\n }\n }\n\n var placement = data.placement.split('-')[0];\n var _data$offsets = data.offsets,\n popper = _data$offsets.popper,\n reference = _data$offsets.reference;\n\n var isVertical = ['left', 'right'].indexOf(placement) !== -1;\n\n var len = isVertical ? 'height' : 'width';\n var sideCapitalized = isVertical ? 'Top' : 'Left';\n var side = sideCapitalized.toLowerCase();\n var altSide = isVertical ? 'left' : 'top';\n var opSide = isVertical ? 'bottom' : 'right';\n var arrowElementSize = getOuterSizes(arrowElement)[len];\n\n //\n // extends keepTogether behavior making sure the popper and its\n // reference have enough pixels in conjunction\n //\n\n // top/left side\n if (reference[opSide] - arrowElementSize < popper[side]) {\n data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);\n }\n // bottom/right side\n if (reference[side] + arrowElementSize > popper[opSide]) {\n data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];\n }\n data.offsets.popper = getClientRect(data.offsets.popper);\n\n // compute center of the popper\n var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;\n\n // Compute the sideValue using the updated popper offsets\n // take popper margin in account because we don't have this info available\n var css = getStyleComputedProperty(data.instance.popper);\n var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);\n var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);\n var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;\n\n // prevent arrowElement from being placed not contiguously to its popper\n sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);\n\n data.arrowElement = arrowElement;\n data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);\n\n return data;\n}\n\n/**\n * Get the opposite placement variation of the given one\n * @method\n * @memberof Popper.Utils\n * @argument {String} placement variation\n * @returns {String} flipped placement variation\n */\nfunction getOppositeVariation(variation) {\n if (variation === 'end') {\n return 'start';\n } else if (variation === 'start') {\n return 'end';\n }\n return variation;\n}\n\n/**\n * List of accepted placements to use as values of the `placement` option.
\n * Valid placements are:\n * - `auto`\n * - `top`\n * - `right`\n * - `bottom`\n * - `left`\n *\n * Each placement can have a variation from this list:\n * - `-start`\n * - `-end`\n *\n * Variations are interpreted easily if you think of them as the left to right\n * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`\n * is right.
\n * Vertically (`left` and `right`), `start` is top and `end` is bottom.\n *\n * Some valid examples are:\n * - `top-end` (on top of reference, right aligned)\n * - `right-start` (on right of reference, top aligned)\n * - `bottom` (on bottom, centered)\n * - `auto-end` (on the side with more space available, alignment depends by placement)\n *\n * @static\n * @type {Array}\n * @enum {String}\n * @readonly\n * @method placements\n * @memberof Popper\n */\nvar placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];\n\n// Get rid of `auto` `auto-start` and `auto-end`\nvar validPlacements = placements.slice(3);\n\n/**\n * Given an initial placement, returns all the subsequent placements\n * clockwise (or counter-clockwise).\n *\n * @method\n * @memberof Popper.Utils\n * @argument {String} placement - A valid placement (it accepts variations)\n * @argument {Boolean} counter - Set to true to walk the placements counterclockwise\n * @returns {Array} placements including their variations\n */\nfunction clockwise(placement) {\n var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\n var index = validPlacements.indexOf(placement);\n var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));\n return counter ? arr.reverse() : arr;\n}\n\nvar BEHAVIORS = {\n FLIP: 'flip',\n CLOCKWISE: 'clockwise',\n COUNTERCLOCKWISE: 'counterclockwise'\n};\n\n/**\n * @function\n * @memberof Modifiers\n * @argument {Object} data - The data object generated by update method\n * @argument {Object} options - Modifiers configuration and options\n * @returns {Object} The data object, properly modified\n */\nfunction flip(data, options) {\n // if `inner` modifier is enabled, we can't use the `flip` modifier\n if (isModifierEnabled(data.instance.modifiers, 'inner')) {\n return data;\n }\n\n if (data.flipped && data.placement === data.originalPlacement) {\n // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides\n return data;\n }\n\n var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);\n\n var placement = data.placement.split('-')[0];\n var placementOpposite = getOppositePlacement(placement);\n var variation = data.placement.split('-')[1] || '';\n\n var flipOrder = [];\n\n switch (options.behavior) {\n case BEHAVIORS.FLIP:\n flipOrder = [placement, placementOpposite];\n break;\n case BEHAVIORS.CLOCKWISE:\n flipOrder = clockwise(placement);\n break;\n case BEHAVIORS.COUNTERCLOCKWISE:\n flipOrder = clockwise(placement, true);\n break;\n default:\n flipOrder = options.behavior;\n }\n\n flipOrder.forEach(function (step, index) {\n if (placement !== step || flipOrder.length === index + 1) {\n return data;\n }\n\n placement = data.placement.split('-')[0];\n placementOpposite = getOppositePlacement(placement);\n\n var popperOffsets = data.offsets.popper;\n var refOffsets = data.offsets.reference;\n\n // using floor because the reference offsets may contain decimals we are not going to consider here\n var floor = Math.floor;\n var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);\n\n var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);\n var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);\n var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);\n var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);\n\n var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;\n\n // flip the variation if required\n var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;\n\n // flips variation if reference element overflows boundaries\n var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);\n\n // flips variation if popper content overflows boundaries\n var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);\n\n var flippedVariation = flippedVariationByRef || flippedVariationByContent;\n\n if (overlapsRef || overflowsBoundaries || flippedVariation) {\n // this boolean to detect any flip loop\n data.flipped = true;\n\n if (overlapsRef || overflowsBoundaries) {\n placement = flipOrder[index + 1];\n }\n\n if (flippedVariation) {\n variation = getOppositeVariation(variation);\n }\n\n data.placement = placement + (variation ? '-' + variation : '');\n\n // this object contains `position`, we want to preserve it along with\n // any additional property we may add in the future\n data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));\n\n data = runModifiers(data.instance.modifiers, data, 'flip');\n }\n });\n return data;\n}\n\n/**\n * @function\n * @memberof Modifiers\n * @argument {Object} data - The data object generated by update method\n * @argument {Object} options - Modifiers configuration and options\n * @returns {Object} The data object, properly modified\n */\nfunction keepTogether(data) {\n var _data$offsets = data.offsets,\n popper = _data$offsets.popper,\n reference = _data$offsets.reference;\n\n var placement = data.placement.split('-')[0];\n var floor = Math.floor;\n var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;\n var side = isVertical ? 'right' : 'bottom';\n var opSide = isVertical ? 'left' : 'top';\n var measurement = isVertical ? 'width' : 'height';\n\n if (popper[side] < floor(reference[opSide])) {\n data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];\n }\n if (popper[opSide] > floor(reference[side])) {\n data.offsets.popper[opSide] = floor(reference[side]);\n }\n\n return data;\n}\n\n/**\n * Converts a string containing value + unit into a px value number\n * @function\n * @memberof {modifiers~offset}\n * @private\n * @argument {String} str - Value + unit string\n * @argument {String} measurement - `height` or `width`\n * @argument {Object} popperOffsets\n * @argument {Object} referenceOffsets\n * @returns {Number|String}\n * Value in pixels, or original string if no values were extracted\n */\nfunction toValue(str, measurement, popperOffsets, referenceOffsets) {\n // separate value from unit\n var split = str.match(/((?:\\-|\\+)?\\d*\\.?\\d*)(.*)/);\n var value = +split[1];\n var unit = split[2];\n\n // If it's not a number it's an operator, I guess\n if (!value) {\n return str;\n }\n\n if (unit.indexOf('%') === 0) {\n var element = void 0;\n switch (unit) {\n case '%p':\n element = popperOffsets;\n break;\n case '%':\n case '%r':\n default:\n element = referenceOffsets;\n }\n\n var rect = getClientRect(element);\n return rect[measurement] / 100 * value;\n } else if (unit === 'vh' || unit === 'vw') {\n // if is a vh or vw, we calculate the size based on the viewport\n var size = void 0;\n if (unit === 'vh') {\n size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n } else {\n size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n }\n return size / 100 * value;\n } else {\n // if is an explicit pixel unit, we get rid of the unit and keep the value\n // if is an implicit unit, it's px, and we return just the value\n return value;\n }\n}\n\n/**\n * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.\n * @function\n * @memberof {modifiers~offset}\n * @private\n * @argument {String} offset\n * @argument {Object} popperOffsets\n * @argument {Object} referenceOffsets\n * @argument {String} basePlacement\n * @returns {Array} a two cells array with x and y offsets in numbers\n */\nfunction parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {\n var offsets = [0, 0];\n\n // Use height if placement is left or right and index is 0 otherwise use width\n // in this way the first offset will use an axis and the second one\n // will use the other one\n var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;\n\n // Split the offset string to obtain a list of values and operands\n // The regex addresses values with the plus or minus sign in front (+10, -20, etc)\n var fragments = offset.split(/(\\+|\\-)/).map(function (frag) {\n return frag.trim();\n });\n\n // Detect if the offset string contains a pair of values or a single one\n // they could be separated by comma or space\n var divider = fragments.indexOf(find(fragments, function (frag) {\n return frag.search(/,|\\s/) !== -1;\n }));\n\n if (fragments[divider] && fragments[divider].indexOf(',') === -1) {\n console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');\n }\n\n // If divider is found, we divide the list of values and operands to divide\n // them by ofset X and Y.\n var splitRegex = /\\s*,\\s*|\\s+/;\n var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];\n\n // Convert the values with units to absolute pixels to allow our computations\n ops = ops.map(function (op, index) {\n // Most of the units rely on the orientation of the popper\n var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';\n var mergeWithPrevious = false;\n return op\n // This aggregates any `+` or `-` sign that aren't considered operators\n // e.g.: 10 + +5 => [10, +, +5]\n .reduce(function (a, b) {\n if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {\n a[a.length - 1] = b;\n mergeWithPrevious = true;\n return a;\n } else if (mergeWithPrevious) {\n a[a.length - 1] += b;\n mergeWithPrevious = false;\n return a;\n } else {\n return a.concat(b);\n }\n }, [])\n // Here we convert the string values into number values (in px)\n .map(function (str) {\n return toValue(str, measurement, popperOffsets, referenceOffsets);\n });\n });\n\n // Loop trough the offsets arrays and execute the operations\n ops.forEach(function (op, index) {\n op.forEach(function (frag, index2) {\n if (isNumeric(frag)) {\n offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);\n }\n });\n });\n return offsets;\n}\n\n/**\n * @function\n * @memberof Modifiers\n * @argument {Object} data - The data object generated by update method\n * @argument {Object} options - Modifiers configuration and options\n * @argument {Number|String} options.offset=0\n * The offset value as described in the modifier description\n * @returns {Object} The data object, properly modified\n */\nfunction offset(data, _ref) {\n var offset = _ref.offset;\n var placement = data.placement,\n _data$offsets = data.offsets,\n popper = _data$offsets.popper,\n reference = _data$offsets.reference;\n\n var basePlacement = placement.split('-')[0];\n\n var offsets = void 0;\n if (isNumeric(+offset)) {\n offsets = [+offset, 0];\n } else {\n offsets = parseOffset(offset, popper, reference, basePlacement);\n }\n\n if (basePlacement === 'left') {\n popper.top += offsets[0];\n popper.left -= offsets[1];\n } else if (basePlacement === 'right') {\n popper.top += offsets[0];\n popper.left += offsets[1];\n } else if (basePlacement === 'top') {\n popper.left += offsets[0];\n popper.top -= offsets[1];\n } else if (basePlacement === 'bottom') {\n popper.left += offsets[0];\n popper.top += offsets[1];\n }\n\n data.popper = popper;\n return data;\n}\n\n/**\n * @function\n * @memberof Modifiers\n * @argument {Object} data - The data object generated by `update` method\n * @argument {Object} options - Modifiers configuration and options\n * @returns {Object} The data object, properly modified\n */\nfunction preventOverflow(data, options) {\n var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);\n\n // If offsetParent is the reference element, we really want to\n // go one step up and use the next offsetParent as reference to\n // avoid to make this modifier completely useless and look like broken\n if (data.instance.reference === boundariesElement) {\n boundariesElement = getOffsetParent(boundariesElement);\n }\n\n // NOTE: DOM access here\n // resets the popper's position so that the document size can be calculated excluding\n // the size of the popper element itself\n var transformProp = getSupportedPropertyName('transform');\n var popperStyles = data.instance.popper.style; // assignment to help minification\n var top = popperStyles.top,\n left = popperStyles.left,\n transform = popperStyles[transformProp];\n\n popperStyles.top = '';\n popperStyles.left = '';\n popperStyles[transformProp] = '';\n\n var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);\n\n // NOTE: DOM access here\n // restores the original style properties after the offsets have been computed\n popperStyles.top = top;\n popperStyles.left = left;\n popperStyles[transformProp] = transform;\n\n options.boundaries = boundaries;\n\n var order = options.priority;\n var popper = data.offsets.popper;\n\n var check = {\n primary: function primary(placement) {\n var value = popper[placement];\n if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {\n value = Math.max(popper[placement], boundaries[placement]);\n }\n return defineProperty({}, placement, value);\n },\n secondary: function secondary(placement) {\n var mainSide = placement === 'right' ? 'left' : 'top';\n var value = popper[mainSide];\n if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {\n value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));\n }\n return defineProperty({}, mainSide, value);\n }\n };\n\n order.forEach(function (placement) {\n var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';\n popper = _extends({}, popper, check[side](placement));\n });\n\n data.offsets.popper = popper;\n\n return data;\n}\n\n/**\n * @function\n * @memberof Modifiers\n * @argument {Object} data - The data object generated by `update` method\n * @argument {Object} options - Modifiers configuration and options\n * @returns {Object} The data object, properly modified\n */\nfunction shift(data) {\n var placement = data.placement;\n var basePlacement = placement.split('-')[0];\n var shiftvariation = placement.split('-')[1];\n\n // if shift shiftvariation is specified, run the modifier\n if (shiftvariation) {\n var _data$offsets = data.offsets,\n reference = _data$offsets.reference,\n popper = _data$offsets.popper;\n\n var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;\n var side = isVertical ? 'left' : 'top';\n var measurement = isVertical ? 'width' : 'height';\n\n var shiftOffsets = {\n start: defineProperty({}, side, reference[side]),\n end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])\n };\n\n data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);\n }\n\n return data;\n}\n\n/**\n * @function\n * @memberof Modifiers\n * @argument {Object} data - The data object generated by update method\n * @argument {Object} options - Modifiers configuration and options\n * @returns {Object} The data object, properly modified\n */\nfunction hide(data) {\n if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {\n return data;\n }\n\n var refRect = data.offsets.reference;\n var bound = find(data.instance.modifiers, function (modifier) {\n return modifier.name === 'preventOverflow';\n }).boundaries;\n\n if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {\n // Avoid unnecessary DOM access if visibility hasn't changed\n if (data.hide === true) {\n return data;\n }\n\n data.hide = true;\n data.attributes['x-out-of-boundaries'] = '';\n } else {\n // Avoid unnecessary DOM access if visibility hasn't changed\n if (data.hide === false) {\n return data;\n }\n\n data.hide = false;\n data.attributes['x-out-of-boundaries'] = false;\n }\n\n return data;\n}\n\n/**\n * @function\n * @memberof Modifiers\n * @argument {Object} data - The data object generated by `update` method\n * @argument {Object} options - Modifiers configuration and options\n * @returns {Object} The data object, properly modified\n */\nfunction inner(data) {\n var placement = data.placement;\n var basePlacement = placement.split('-')[0];\n var _data$offsets = data.offsets,\n popper = _data$offsets.popper,\n reference = _data$offsets.reference;\n\n var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;\n\n var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;\n\n popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);\n\n data.placement = getOppositePlacement(placement);\n data.offsets.popper = getClientRect(popper);\n\n return data;\n}\n\n/**\n * Modifier function, each modifier can have a function of this type assigned\n * to its `fn` property.
\n * These functions will be called on each update, this means that you must\n * make sure they are performant enough to avoid performance bottlenecks.\n *\n * @function ModifierFn\n * @argument {dataObject} data - The data object generated by `update` method\n * @argument {Object} options - Modifiers configuration and options\n * @returns {dataObject} The data object, properly modified\n */\n\n/**\n * Modifiers are plugins used to alter the behavior of your poppers.
\n * Popper.js uses a set of 9 modifiers to provide all the basic functionalities\n * needed by the library.\n *\n * Usually you don't want to override the `order`, `fn` and `onLoad` props.\n * All the other properties are configurations that could be tweaked.\n * @namespace modifiers\n */\nvar modifiers = {\n /**\n * Modifier used to shift the popper on the start or end of its reference\n * element.
\n * It will read the variation of the `placement` property.
\n * It can be one either `-end` or `-start`.\n * @memberof modifiers\n * @inner\n */\n shift: {\n /** @prop {number} order=100 - Index used to define the order of execution */\n order: 100,\n /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n enabled: true,\n /** @prop {ModifierFn} */\n fn: shift\n },\n\n /**\n * The `offset` modifier can shift your popper on both its axis.\n *\n * It accepts the following units:\n * - `px` or unit-less, interpreted as pixels\n * - `%` or `%r`, percentage relative to the length of the reference element\n * - `%p`, percentage relative to the length of the popper element\n * - `vw`, CSS viewport width unit\n * - `vh`, CSS viewport height unit\n *\n * For length is intended the main axis relative to the placement of the popper.
\n * This means that if the placement is `top` or `bottom`, the length will be the\n * `width`. In case of `left` or `right`, it will be the `height`.\n *\n * You can provide a single value (as `Number` or `String`), or a pair of values\n * as `String` divided by a comma or one (or more) white spaces.
\n * The latter is a deprecated method because it leads to confusion and will be\n * removed in v2.
\n * Additionally, it accepts additions and subtractions between different units.\n * Note that multiplications and divisions aren't supported.\n *\n * Valid examples are:\n * ```\n * 10\n * '10%'\n * '10, 10'\n * '10%, 10'\n * '10 + 10%'\n * '10 - 5vh + 3%'\n * '-10px + 5vh, 5px - 6%'\n * ```\n * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap\n * > with their reference element, unfortunately, you will have to disable the `flip` modifier.\n * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).\n *\n * @memberof modifiers\n * @inner\n */\n offset: {\n /** @prop {number} order=200 - Index used to define the order of execution */\n order: 200,\n /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n enabled: true,\n /** @prop {ModifierFn} */\n fn: offset,\n /** @prop {Number|String} offset=0\n * The offset value as described in the modifier description\n */\n offset: 0\n },\n\n /**\n * Modifier used to prevent the popper from being positioned outside the boundary.\n *\n * A scenario exists where the reference itself is not within the boundaries.
\n * We can say it has \"escaped the boundaries\" — or just \"escaped\".
\n * In this case we need to decide whether the popper should either:\n *\n * - detach from the reference and remain \"trapped\" in the boundaries, or\n * - if it should ignore the boundary and \"escape with its reference\"\n *\n * When `escapeWithReference` is set to`true` and reference is completely\n * outside its boundaries, the popper will overflow (or completely leave)\n * the boundaries in order to remain attached to the edge of the reference.\n *\n * @memberof modifiers\n * @inner\n */\n preventOverflow: {\n /** @prop {number} order=300 - Index used to define the order of execution */\n order: 300,\n /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n enabled: true,\n /** @prop {ModifierFn} */\n fn: preventOverflow,\n /**\n * @prop {Array} [priority=['left','right','top','bottom']]\n * Popper will try to prevent overflow following these priorities by default,\n * then, it could overflow on the left and on top of the `boundariesElement`\n */\n priority: ['left', 'right', 'top', 'bottom'],\n /**\n * @prop {number} padding=5\n * Amount of pixel used to define a minimum distance between the boundaries\n * and the popper. This makes sure the popper always has a little padding\n * between the edges of its container\n */\n padding: 5,\n /**\n * @prop {String|HTMLElement} boundariesElement='scrollParent'\n * Boundaries used by the modifier. Can be `scrollParent`, `window`,\n * `viewport` or any DOM element.\n */\n boundariesElement: 'scrollParent'\n },\n\n /**\n * Modifier used to make sure the reference and its popper stay near each other\n * without leaving any gap between the two. Especially useful when the arrow is\n * enabled and you want to ensure that it points to its reference element.\n * It cares only about the first axis. You can still have poppers with margin\n * between the popper and its reference element.\n * @memberof modifiers\n * @inner\n */\n keepTogether: {\n /** @prop {number} order=400 - Index used to define the order of execution */\n order: 400,\n /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n enabled: true,\n /** @prop {ModifierFn} */\n fn: keepTogether\n },\n\n /**\n * This modifier is used to move the `arrowElement` of the popper to make\n * sure it is positioned between the reference element and its popper element.\n * It will read the outer size of the `arrowElement` node to detect how many\n * pixels of conjunction are needed.\n *\n * It has no effect if no `arrowElement` is provided.\n * @memberof modifiers\n * @inner\n */\n arrow: {\n /** @prop {number} order=500 - Index used to define the order of execution */\n order: 500,\n /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n enabled: true,\n /** @prop {ModifierFn} */\n fn: arrow,\n /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */\n element: '[x-arrow]'\n },\n\n /**\n * Modifier used to flip the popper's placement when it starts to overlap its\n * reference element.\n *\n * Requires the `preventOverflow` modifier before it in order to work.\n *\n * **NOTE:** this modifier will interrupt the current update cycle and will\n * restart it if it detects the need to flip the placement.\n * @memberof modifiers\n * @inner\n */\n flip: {\n /** @prop {number} order=600 - Index used to define the order of execution */\n order: 600,\n /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n enabled: true,\n /** @prop {ModifierFn} */\n fn: flip,\n /**\n * @prop {String|Array} behavior='flip'\n * The behavior used to change the popper's placement. It can be one of\n * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid\n * placements (with optional variations)\n */\n behavior: 'flip',\n /**\n * @prop {number} padding=5\n * The popper will flip if it hits the edges of the `boundariesElement`\n */\n padding: 5,\n /**\n * @prop {String|HTMLElement} boundariesElement='viewport'\n * The element which will define the boundaries of the popper position.\n * The popper will never be placed outside of the defined boundaries\n * (except if `keepTogether` is enabled)\n */\n boundariesElement: 'viewport',\n /**\n * @prop {Boolean} flipVariations=false\n * The popper will switch placement variation between `-start` and `-end` when\n * the reference element overlaps its boundaries.\n *\n * The original placement should have a set variation.\n */\n flipVariations: false,\n /**\n * @prop {Boolean} flipVariationsByContent=false\n * The popper will switch placement variation between `-start` and `-end` when\n * the popper element overlaps its reference boundaries.\n *\n * The original placement should have a set variation.\n */\n flipVariationsByContent: false\n },\n\n /**\n * Modifier used to make the popper flow toward the inner of the reference element.\n * By default, when this modifier is disabled, the popper will be placed outside\n * the reference element.\n * @memberof modifiers\n * @inner\n */\n inner: {\n /** @prop {number} order=700 - Index used to define the order of execution */\n order: 700,\n /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */\n enabled: false,\n /** @prop {ModifierFn} */\n fn: inner\n },\n\n /**\n * Modifier used to hide the popper when its reference element is outside of the\n * popper boundaries. It will set a `x-out-of-boundaries` attribute which can\n * be used to hide with a CSS selector the popper when its reference is\n * out of boundaries.\n *\n * Requires the `preventOverflow` modifier before it in order to work.\n * @memberof modifiers\n * @inner\n */\n hide: {\n /** @prop {number} order=800 - Index used to define the order of execution */\n order: 800,\n /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n enabled: true,\n /** @prop {ModifierFn} */\n fn: hide\n },\n\n /**\n * Computes the style that will be applied to the popper element to gets\n * properly positioned.\n *\n * Note that this modifier will not touch the DOM, it just prepares the styles\n * so that `applyStyle` modifier can apply it. This separation is useful\n * in case you need to replace `applyStyle` with a custom implementation.\n *\n * This modifier has `850` as `order` value to maintain backward compatibility\n * with previous versions of Popper.js. Expect the modifiers ordering method\n * to change in future major versions of the library.\n *\n * @memberof modifiers\n * @inner\n */\n computeStyle: {\n /** @prop {number} order=850 - Index used to define the order of execution */\n order: 850,\n /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n enabled: true,\n /** @prop {ModifierFn} */\n fn: computeStyle,\n /**\n * @prop {Boolean} gpuAcceleration=true\n * If true, it uses the CSS 3D transformation to position the popper.\n * Otherwise, it will use the `top` and `left` properties\n */\n gpuAcceleration: true,\n /**\n * @prop {string} [x='bottom']\n * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.\n * Change this if your popper should grow in a direction different from `bottom`\n */\n x: 'bottom',\n /**\n * @prop {string} [x='left']\n * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.\n * Change this if your popper should grow in a direction different from `right`\n */\n y: 'right'\n },\n\n /**\n * Applies the computed styles to the popper element.\n *\n * All the DOM manipulations are limited to this modifier. This is useful in case\n * you want to integrate Popper.js inside a framework or view library and you\n * want to delegate all the DOM manipulations to it.\n *\n * Note that if you disable this modifier, you must make sure the popper element\n * has its position set to `absolute` before Popper.js can do its work!\n *\n * Just disable this modifier and define your own to achieve the desired effect.\n *\n * @memberof modifiers\n * @inner\n */\n applyStyle: {\n /** @prop {number} order=900 - Index used to define the order of execution */\n order: 900,\n /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n enabled: true,\n /** @prop {ModifierFn} */\n fn: applyStyle,\n /** @prop {Function} */\n onLoad: applyStyleOnLoad,\n /**\n * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier\n * @prop {Boolean} gpuAcceleration=true\n * If true, it uses the CSS 3D transformation to position the popper.\n * Otherwise, it will use the `top` and `left` properties\n */\n gpuAcceleration: undefined\n }\n};\n\n/**\n * The `dataObject` is an object containing all the information used by Popper.js.\n * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.\n * @name dataObject\n * @property {Object} data.instance The Popper.js instance\n * @property {String} data.placement Placement applied to popper\n * @property {String} data.originalPlacement Placement originally defined on init\n * @property {Boolean} data.flipped True if popper has been flipped by flip modifier\n * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper\n * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier\n * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)\n * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)\n * @property {Object} data.boundaries Offsets of the popper boundaries\n * @property {Object} data.offsets The measurements of popper, reference and arrow elements\n * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values\n * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values\n * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0\n */\n\n/**\n * Default options provided to Popper.js constructor.
\n * These can be overridden using the `options` argument of Popper.js.
\n * To override an option, simply pass an object with the same\n * structure of the `options` object, as the 3rd argument. For example:\n * ```\n * new Popper(ref, pop, {\n * modifiers: {\n * preventOverflow: { enabled: false }\n * }\n * })\n * ```\n * @type {Object}\n * @static\n * @memberof Popper\n */\nvar Defaults = {\n /**\n * Popper's placement.\n * @prop {Popper.placements} placement='bottom'\n */\n placement: 'bottom',\n\n /**\n * Set this to true if you want popper to position it self in 'fixed' mode\n * @prop {Boolean} positionFixed=false\n */\n positionFixed: false,\n\n /**\n * Whether events (resize, scroll) are initially enabled.\n * @prop {Boolean} eventsEnabled=true\n */\n eventsEnabled: true,\n\n /**\n * Set to true if you want to automatically remove the popper when\n * you call the `destroy` method.\n * @prop {Boolean} removeOnDestroy=false\n */\n removeOnDestroy: false,\n\n /**\n * Callback called when the popper is created.
\n * By default, it is set to no-op.
\n * Access Popper.js instance with `data.instance`.\n * @prop {onCreate}\n */\n onCreate: function onCreate() {},\n\n /**\n * Callback called when the popper is updated. This callback is not called\n * on the initialization/creation of the popper, but only on subsequent\n * updates.
\n * By default, it is set to no-op.
\n * Access Popper.js instance with `data.instance`.\n * @prop {onUpdate}\n */\n onUpdate: function onUpdate() {},\n\n /**\n * List of modifiers used to modify the offsets before they are applied to the popper.\n * They provide most of the functionalities of Popper.js.\n * @prop {modifiers}\n */\n modifiers: modifiers\n};\n\n/**\n * @callback onCreate\n * @param {dataObject} data\n */\n\n/**\n * @callback onUpdate\n * @param {dataObject} data\n */\n\n// Utils\n// Methods\nvar Popper = function () {\n /**\n * Creates a new Popper.js instance.\n * @class Popper\n * @param {Element|referenceObject} reference - The reference element used to position the popper\n * @param {Element} popper - The HTML / XML element used as the popper\n * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)\n * @return {Object} instance - The generated Popper.js instance\n */\n function Popper(reference, popper) {\n var _this = this;\n\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n classCallCheck(this, Popper);\n\n this.scheduleUpdate = function () {\n return requestAnimationFrame(_this.update);\n };\n\n // make update() debounced, so that it only runs at most once-per-tick\n this.update = debounce(this.update.bind(this));\n\n // with {} we create a new object with the options inside it\n this.options = _extends({}, Popper.Defaults, options);\n\n // init state\n this.state = {\n isDestroyed: false,\n isCreated: false,\n scrollParents: []\n };\n\n // get reference and popper elements (allow jQuery wrappers)\n this.reference = reference && reference.jquery ? reference[0] : reference;\n this.popper = popper && popper.jquery ? popper[0] : popper;\n\n // Deep merge modifiers options\n this.options.modifiers = {};\n Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {\n _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});\n });\n\n // Refactoring modifiers' list (Object => Array)\n this.modifiers = Object.keys(this.options.modifiers).map(function (name) {\n return _extends({\n name: name\n }, _this.options.modifiers[name]);\n })\n // sort the modifiers by order\n .sort(function (a, b) {\n return a.order - b.order;\n });\n\n // modifiers have the ability to execute arbitrary code when Popper.js get inited\n // such code is executed in the same order of its modifier\n // they could add new properties to their options configuration\n // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!\n this.modifiers.forEach(function (modifierOptions) {\n if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {\n modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);\n }\n });\n\n // fire the first update to position the popper in the right place\n this.update();\n\n var eventsEnabled = this.options.eventsEnabled;\n if (eventsEnabled) {\n // setup event listeners, they will take care of update the position in specific situations\n this.enableEventListeners();\n }\n\n this.state.eventsEnabled = eventsEnabled;\n }\n\n // We can't use class properties because they don't get listed in the\n // class prototype and break stuff like Sinon stubs\n\n\n createClass(Popper, [{\n key: 'update',\n value: function update$$1() {\n return update.call(this);\n }\n }, {\n key: 'destroy',\n value: function destroy$$1() {\n return destroy.call(this);\n }\n }, {\n key: 'enableEventListeners',\n value: function enableEventListeners$$1() {\n return enableEventListeners.call(this);\n }\n }, {\n key: 'disableEventListeners',\n value: function disableEventListeners$$1() {\n return disableEventListeners.call(this);\n }\n\n /**\n * Schedules an update. It will run on the next UI update available.\n * @method scheduleUpdate\n * @memberof Popper\n */\n\n\n /**\n * Collection of utilities useful when writing custom modifiers.\n * Starting from version 1.7, this method is available only if you\n * include `popper-utils.js` before `popper.js`.\n *\n * **DEPRECATION**: This way to access PopperUtils is deprecated\n * and will be removed in v2! Use the PopperUtils module directly instead.\n * Due to the high instability of the methods contained in Utils, we can't\n * guarantee them to follow semver. Use them at your own risk!\n * @static\n * @private\n * @type {Object}\n * @deprecated since version 1.8\n * @member Utils\n * @memberof Popper\n */\n\n }]);\n return Popper;\n}();\n\n/**\n * The `referenceObject` is an object that provides an interface compatible with Popper.js\n * and lets you use it as replacement of a real DOM node.
\n * You can use this method to position a popper relatively to a set of coordinates\n * in case you don't have a DOM node to use as reference.\n *\n * ```\n * new Popper(referenceObject, popperNode);\n * ```\n *\n * NB: This feature isn't supported in Internet Explorer 10.\n * @name referenceObject\n * @property {Function} data.getBoundingClientRect\n * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.\n * @property {number} data.clientWidth\n * An ES6 getter that will return the width of the virtual reference element.\n * @property {number} data.clientHeight\n * An ES6 getter that will return the height of the virtual reference element.\n */\n\n\nPopper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;\nPopper.placements = placements;\nPopper.Defaults = Defaults;\n\nexport default Popper;\n//# sourceMappingURL=popper.js.map\n","'use strict';\nvar $ = require('../internals/export');\nvar uncurryThis = require('../internals/function-uncurry-this');\nvar hiddenKeys = require('../internals/hidden-keys');\nvar isObject = require('../internals/is-object');\nvar hasOwn = require('../internals/has-own-property');\nvar defineProperty = require('../internals/object-define-property').f;\nvar getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');\nvar getOwnPropertyNamesExternalModule = require('../internals/object-get-own-property-names-external');\nvar isExtensible = require('../internals/object-is-extensible');\nvar uid = require('../internals/uid');\nvar FREEZING = require('../internals/freezing');\n\nvar REQUIRED = false;\nvar METADATA = uid('meta');\nvar id = 0;\n\nvar setMetadata = function (it) {\n defineProperty(it, METADATA, { value: {\n objectID: 'O' + id++, // object ID\n weakData: {} // weak collections IDs\n } });\n};\n\nvar fastKey = function (it, create) {\n // return a primitive with prefix\n if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;\n if (!hasOwn(it, METADATA)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return 'F';\n // not necessary to add metadata\n if (!create) return 'E';\n // add missing metadata\n setMetadata(it);\n // return object ID\n } return it[METADATA].objectID;\n};\n\nvar getWeakData = function (it, create) {\n if (!hasOwn(it, METADATA)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return true;\n // not necessary to add metadata\n if (!create) return false;\n // add missing metadata\n setMetadata(it);\n // return the store of weak collections IDs\n } return it[METADATA].weakData;\n};\n\n// add metadata on freeze-family methods calling\nvar onFreeze = function (it) {\n if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it);\n return it;\n};\n\nvar enable = function () {\n meta.enable = function () { /* empty */ };\n REQUIRED = true;\n var getOwnPropertyNames = getOwnPropertyNamesModule.f;\n var splice = uncurryThis([].splice);\n var test = {};\n test[METADATA] = 1;\n\n // prevent exposing of metadata key\n if (getOwnPropertyNames(test).length) {\n getOwnPropertyNamesModule.f = function (it) {\n var result = getOwnPropertyNames(it);\n for (var i = 0, length = result.length; i < length; i++) {\n if (result[i] === METADATA) {\n splice(result, i, 1);\n break;\n }\n } return result;\n };\n\n $({ target: 'Object', stat: true, forced: true }, {\n getOwnPropertyNames: getOwnPropertyNamesExternalModule.f\n });\n }\n};\n\nvar meta = module.exports = {\n enable: enable,\n fastKey: fastKey,\n getWeakData: getWeakData,\n onFreeze: onFreeze\n};\n\nhiddenKeys[METADATA] = true;\n","'use strict';\nvar uncurryThis = require('../internals/function-uncurry-this');\n\nmodule.exports = uncurryThis([].slice);\n","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\n// This piece of code was orignally written by sindresorhus and can be seen here\n// https://github.com/sindresorhus/lazy-value/blob/master/index.js\n\nexports.default = function (fn) {\n var called = false;\n var ret = void 0;\n\n return function () {\n if (!called) {\n called = true;\n ret = fn();\n }\n\n return ret;\n };\n};","/** Used to compose unicode character classes. */\nvar rsAstralRange = '\\\\ud800-\\\\udfff',\n rsComboMarksRange = '\\\\u0300-\\\\u036f',\n reComboHalfMarksRange = '\\\\ufe20-\\\\ufe2f',\n rsComboSymbolsRange = '\\\\u20d0-\\\\u20ff',\n rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,\n rsDingbatRange = '\\\\u2700-\\\\u27bf',\n rsLowerRange = 'a-z\\\\xdf-\\\\xf6\\\\xf8-\\\\xff',\n rsMathOpRange = '\\\\xac\\\\xb1\\\\xd7\\\\xf7',\n rsNonCharRange = '\\\\x00-\\\\x2f\\\\x3a-\\\\x40\\\\x5b-\\\\x60\\\\x7b-\\\\xbf',\n rsPunctuationRange = '\\\\u2000-\\\\u206f',\n rsSpaceRange = ' \\\\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',\n rsUpperRange = 'A-Z\\\\xc0-\\\\xd6\\\\xd8-\\\\xde',\n rsVarRange = '\\\\ufe0e\\\\ufe0f',\n rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;\n\n/** Used to compose unicode capture groups. */\nvar rsApos = \"['\\u2019]\",\n rsBreak = '[' + rsBreakRange + ']',\n rsCombo = '[' + rsComboRange + ']',\n rsDigits = '\\\\d+',\n rsDingbat = '[' + rsDingbatRange + ']',\n rsLower = '[' + rsLowerRange + ']',\n rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',\n rsFitz = '\\\\ud83c[\\\\udffb-\\\\udfff]',\n rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',\n rsNonAstral = '[^' + rsAstralRange + ']',\n rsRegional = '(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}',\n rsSurrPair = '[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]',\n rsUpper = '[' + rsUpperRange + ']',\n rsZWJ = '\\\\u200d';\n\n/** Used to compose unicode regexes. */\nvar rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',\n rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',\n rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',\n rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',\n reOptMod = rsModifier + '?',\n rsOptVar = '[' + rsVarRange + ']?',\n rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',\n rsOrdLower = '\\\\d*(?:1st|2nd|3rd|(?![123])\\\\dth)(?=\\\\b|[A-Z_])',\n rsOrdUpper = '\\\\d*(?:1ST|2ND|3RD|(?![123])\\\\dTH)(?=\\\\b|[a-z_])',\n rsSeq = rsOptVar + reOptMod + rsOptJoin,\n rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;\n\n/** Used to match complex or compound words. */\nvar reUnicodeWord = RegExp([\n rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',\n rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',\n rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,\n rsUpper + '+' + rsOptContrUpper,\n rsOrdUpper,\n rsOrdLower,\n rsDigits,\n rsEmoji\n].join('|'), 'g');\n\n/**\n * Splits a Unicode `string` into an array of its words.\n *\n * @private\n * @param {string} The string to inspect.\n * @returns {Array} Returns the words of `string`.\n */\nfunction unicodeWords(string) {\n return string.match(reUnicodeWord) || [];\n}\n\nmodule.exports = unicodeWords;\n","'use strict';\nvar TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');\nvar isCallable = require('../internals/is-callable');\nvar classofRaw = require('../internals/classof-raw');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\nvar $Object = Object;\n\n// ES3 wrong here\nvar CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';\n\n// fallback for IE11 Script Access Denied error\nvar tryGet = function (it, key) {\n try {\n return it[key];\n } catch (error) { /* empty */ }\n};\n\n// getting tag from ES6+ `Object.prototype.toString`\nmodule.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {\n var O, tag, result;\n return it === undefined ? 'Undefined' : it === null ? 'Null'\n // @@toStringTag case\n : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag\n // builtinTag case\n : CORRECT_ARGUMENTS ? classofRaw(O)\n // ES3 arguments fallback\n : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;\n};\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _mapElementFactory = require('./mapElementFactory.js');\n\nvar _mapElementFactory2 = _interopRequireDefault(_mapElementFactory);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar props = {\n draggable: {\n type: Boolean\n },\n editable: {\n type: Boolean\n },\n options: {\n type: Object\n },\n path: {\n type: Array,\n twoWay: true,\n noBind: true\n },\n paths: {\n type: Array,\n twoWay: true,\n noBind: true\n }\n};\n\nvar events = ['click', 'dblclick', 'drag', 'dragend', 'dragstart', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];\n\nexports.default = (0, _mapElementFactory2.default)({\n props: {\n deepWatch: {\n type: Boolean,\n default: false\n }\n },\n events: events,\n mappedProps: props,\n name: 'polygon',\n ctr: function ctr() {\n return google.maps.Polygon;\n },\n\n beforeCreate: function beforeCreate(options) {\n if (!options.path) delete options.path;\n if (!options.paths) delete options.paths;\n },\n afterCreate: function afterCreate(inst) {\n var _this = this;\n\n var clearEvents = function () {};\n\n // Watch paths, on our own, because we do not want to set either when it is\n // empty\n this.$watch('paths', function (paths) {\n if (paths) {\n clearEvents();\n\n inst.setPaths(paths);\n\n var updatePaths = function () {\n _this.$emit('paths_changed', inst.getPaths());\n };\n var eventListeners = [];\n\n var mvcArray = inst.getPaths();\n for (var i = 0; i < mvcArray.getLength(); i++) {\n var mvcPath = mvcArray.getAt(i);\n eventListeners.push([mvcPath, mvcPath.addListener('insert_at', updatePaths)]);\n eventListeners.push([mvcPath, mvcPath.addListener('remove_at', updatePaths)]);\n eventListeners.push([mvcPath, mvcPath.addListener('set_at', updatePaths)]);\n }\n eventListeners.push([mvcArray, mvcArray.addListener('insert_at', updatePaths)]);\n eventListeners.push([mvcArray, mvcArray.addListener('remove_at', updatePaths)]);\n eventListeners.push([mvcArray, mvcArray.addListener('set_at', updatePaths)]);\n\n clearEvents = function () {\n eventListeners.map(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 2),\n obj = _ref2[0],\n listenerHandle = _ref2[1];\n\n return (// eslint-disable-line no-unused-vars\n google.maps.event.removeListener(listenerHandle)\n );\n });\n };\n }\n }, {\n deep: this.deepWatch,\n immediate: true\n });\n\n this.$watch('path', function (path) {\n if (path) {\n clearEvents();\n\n inst.setPaths(path);\n\n var mvcPath = inst.getPath();\n var eventListeners = [];\n\n var updatePaths = function () {\n _this.$emit('path_changed', inst.getPath());\n };\n\n eventListeners.push([mvcPath, mvcPath.addListener('insert_at', updatePaths)]);\n eventListeners.push([mvcPath, mvcPath.addListener('remove_at', updatePaths)]);\n eventListeners.push([mvcPath, mvcPath.addListener('set_at', updatePaths)]);\n\n clearEvents = function () {\n eventListeners.map(function (_ref3) {\n var _ref4 = _slicedToArray(_ref3, 2),\n obj = _ref4[0],\n listenerHandle = _ref4[1];\n\n return (// eslint-disable-line no-unused-vars\n google.maps.event.removeListener(listenerHandle)\n );\n });\n };\n }\n }, {\n deep: this.deepWatch,\n immediate: true\n });\n }\n});","'use strict';\nvar shared = require('../internals/shared');\nvar uid = require('../internals/uid');\n\nvar keys = shared('keys');\n\nmodule.exports = function (key) {\n return keys[key] || (keys[key] = uid(key));\n};\n","/**\n * lodash (Custom Build) \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as the `TypeError` message for \"Functions\" methods. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max,\n nativeMin = Math.min;\n\n/**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\nvar now = function() {\n return root.Date.now();\n};\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n result = wait - timeSinceLastCall;\n\n return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||\n (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nmodule.exports = debounce;\n","var render = function render(){var _vm=this,_c=_vm._self._c,_setup=_vm._self._setupProxy;return _c('div',{staticClass:\"vue-street-view-pano-container\"},[_c('div',{ref:\"vue-street-view-pano\",staticClass:\"vue-street-view-pano\"}),_vm._t(\"default\")],2)\n}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","