text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).firebase)}(this,function(om){"use strict";try{!function(){function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e=t(om),r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function y(t,s,a,u){return new(a=a||Promise)(function(n,e){function r(t){try{o(u.next(t))}catch(t){e(t)}}function i(t){try{o(u.throw(t))}catch(t){e(t)}}function o(t){var e;t.done?n(t.value):((e=t.value)instanceof a?e:new a(function(t){t(e)})).then(r,i)}o((u=u.apply(t,s||[])).next())})}function g(n,r){var i,o,s,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=0,(e=s?[2&e[0],s.value]:e)[0]){case 0:case 1:s=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,o=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){a.label=e[1];break}if(6===e[0]&&a.label<s[1]){a.label=s[1],s=e;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(e);break}s[2]&&a.ops.pop(),a.trys.pop();continue}e=r.call(n,a)}catch(t){e=[6,t],o=0}finally{i=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function s(t,e){for(var n=0,r=e.length,i=t.length;n<r;n++,i++)t[i]=e[n];return t}function h(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}var i,o="FirebaseError",a=(n(u,i=Error),u);function u(t,e,n){e=i.call(this,e)||this;return e.code=t,e.customData=n,e.name=o,Object.setPrototypeOf(e,u.prototype),Error.captureStackTrace&&Error.captureStackTrace(e,c.prototype.create),e}var c=(l.prototype.create=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r,i=e[0]||{},o=this.service+"/"+t,t=this.errors[t],t=t?(r=i,t.replace(d,function(t,e){var n=r[e];return null!=n?String(n):"<"+e+"?>"})):"Error",t=this.serviceName+": "+t+" ("+o+").";return new a(o,t,i)},l);function l(t,e,n){this.service=t,this.serviceName=e,this.errors=n}var f,d=/\{\$([^}]+)}/g;function m(t){return t&&t._delegate?t._delegate:t}(Ee=f=f||{})[Ee.DEBUG=0]="DEBUG",Ee[Ee.VERBOSE=1]="VERBOSE",Ee[Ee.INFO=2]="INFO",Ee[Ee.WARN=3]="WARN",Ee[Ee.ERROR=4]="ERROR",Ee[Ee.SILENT=5]="SILENT";function p(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(!(e<t.logLevel)){var i=(new Date).toISOString(),o=w[e];if(!o)throw new Error("Attempted to log a message with an invalid logType (value: "+e+")");console[o].apply(console,s(["["+i+"]  "+t.name+":"],n))}}var v={debug:f.DEBUG,verbose:f.VERBOSE,info:f.INFO,warn:f.WARN,error:f.ERROR,silent:f.SILENT},b=f.INFO,w=((Te={})[f.DEBUG]="log",Te[f.VERBOSE]="log",Te[f.INFO]="info",Te[f.WARN]="warn",Te[f.ERROR]="error",Te),I=(Object.defineProperty(E.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in f))throw new TypeError('Invalid value "'+t+'" assigned to `logLevel`');this._logLevel=t},enumerable:!1,configurable:!0}),E.prototype.setLogLevel=function(t){this._logLevel="string"==typeof t?v[t]:t},Object.defineProperty(E.prototype,"logHandler",{get:function(){return this._logHandler},set:function(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"userLogHandler",{get:function(){return this._userLogHandler},set:function(t){this._userLogHandler=t},enumerable:!1,configurable:!0}),E.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,s([this,f.DEBUG],t)),this._logHandler.apply(this,s([this,f.DEBUG],t))},E.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,s([this,f.VERBOSE],t)),this._logHandler.apply(this,s([this,f.VERBOSE],t))},E.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,s([this,f.INFO],t)),this._logHandler.apply(this,s([this,f.INFO],t))},E.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,s([this,f.WARN],t)),this._logHandler.apply(this,s([this,f.WARN],t))},E.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,s([this,f.ERROR],t)),this._logHandler.apply(this,s([this,f.ERROR],t))},E);function E(t){this.name=t,this._logLevel=b,this._logHandler=p,this._userLogHandler=null}var T=function(t,e){return(T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function _(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&r>=t.length?void 0:t)&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var S,N="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},D={},A=N||self;function k(){}function C(t){var e=typeof t;return"array"==(e="object"!=e?e:t?Array.isArray(t)?"array":e:"null")||"object"==e&&"number"==typeof t.length}function R(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var x="closure_uid_"+(1e9*Math.random()>>>0),O=0;function L(t,e,n){return t.call.apply(t.bind,arguments)}function P(e,n,t){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var t=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(t,r),e.apply(n,t)}}return function(){return e.apply(n,arguments)}}function M(t,e,n){return(M=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?L:P).apply(null,arguments)}function F(e){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function V(){return Date.now()}function U(t,o){function e(){}e.prototype=o.prototype,t.X=o.prototype,t.prototype=new e,(t.prototype.constructor=t).Kb=function(t,e,n){for(var r=Array(arguments.length-2),i=2;i<arguments.length;i++)r[i-2]=arguments[i];return o.prototype[e].apply(t,r)}}function q(){this.j=this.j,this.i=this.i}q.prototype.j=!1,q.prototype.ja=function(){var t;!this.j&&(this.j=!0,this.G(),0)&&(t=this,Object.prototype.hasOwnProperty.call(t,x)&&t[x]||(t[x]=++O))},q.prototype.G=function(){if(this.i)for(;this.i.length;)this.i.shift()()};var B=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if("string"==typeof t)return"string"!=typeof e||1!=e.length?-1:t.indexOf(e,0);for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},j=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i="string"==typeof t?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)};function K(){return Array.prototype.concat.apply([],arguments)}function G(t){var e=t.length;if(0<e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}return[]}function Q(t){return/^[\s\xa0]*$/.test(t)}var z,H=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function W(t,e){return-1!=t.indexOf(e)}function Y(t,e){return t<e?-1:e<t?1:0}t:{var X=A.navigator;if(X){X=X.userAgent;if(X){z=X;break t}}z=""}function J(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function $(t){var e,n={};for(e in t)n[e]=t[e];return n}var Z="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function tt(t){for(var e,n,r=1;r<arguments.length;r++){for(e in n=arguments[r])t[e]=n[e];for(var i=0;i<Z.length;i++)e=Z[i],Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}}function et(t){return et[" "](t),t}et[" "]=k;var nt,rt=W(z,"Opera"),it=W(z,"Trident")||W(z,"MSIE"),ot=W(z,"Edge"),st=ot||it,at=W(z,"Gecko")&&!(W(z.toLowerCase(),"webkit")&&!W(z,"Edge"))&&!(W(z,"Trident")||W(z,"MSIE"))&&!W(z,"Edge"),ut=W(z.toLowerCase(),"webkit")&&!W(z,"Edge");function ct(){var t=A.document;return t?t.documentMode:void 0}t:{var ht="",lt=(lt=z,at?/rv:([^\);]+)(\)|;)/.exec(lt):ot?/Edge\/([\d\.]+)/.exec(lt):it?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(lt):ut?/WebKit\/(\S+)/.exec(lt):rt?/(?:Version)[ \/]?(\S+)/.exec(lt):void 0);if(lt&&(ht=lt?lt[1]:""),it){lt=ct();if(null!=lt&&lt>parseFloat(ht)){nt=String(lt);break t}}nt=ht}var ft={};function dt(a){return t=a,e=function(){for(var t=0,e=H(String(nt)).split("."),n=H(String(a)).split("."),r=Math.max(e.length,n.length),i=0;0==t&&i<r;i++)for(var o=e[i]||"",s=n[i]||"";o=/(\d*)(\D*)(.*)/.exec(o)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],(0!=o[0].length||0!=s[0].length)&&(t=Y(0==o[1].length?0:parseInt(o[1],10),0==s[1].length?0:parseInt(s[1],10))||Y(0==o[2].length,0==s[2].length)||Y(o[2],s[2]),o=o[3],s=s[3],0==t););return 0<=t},n=ft,Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t);var t,e,n}var pt=A.document&&it&&(ct()||parseInt(nt,10))||void 0,yt=!it||9<=Number(pt),gt=it&&!dt("9"),mt=function(){if(!A.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{A.addEventListener("test",k,e),A.removeEventListener("test",k,e)}catch(t){}return t}();function vt(t,e){this.type=t,this.a=this.target=e,this.defaultPrevented=!1}function bt(t,e){if(vt.call(this,t?t.type:""),this.relatedTarget=this.a=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.pointerId=0,this.pointerType="",this.c=null,t){var n=this.type=t.type,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.a=e,e=t.relatedTarget){if(at){t:{try{et(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:wt[t.pointerType]||"",(this.c=t).defaultPrevented&&this.b()}}vt.prototype.b=function(){this.defaultPrevented=!0},U(bt,vt);var wt={2:"touch",3:"pen",4:"mouse"};bt.prototype.b=function(){bt.X.b.call(this);var t=this.c;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,gt)try{(t.ctrlKey||112<=t.keyCode&&t.keyCode<=123)&&(t.keyCode=-1)}catch(t){}};var It="closure_listenable_"+(1e6*Math.random()|0),Et=0;function Tt(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.ca=i,this.key=++Et,this.Y=this.Z=!1}function _t(t){t.Y=!0,t.listener=null,t.proxy=null,t.src=null,t.ca=null}function St(t){this.src=t,this.a={},this.b=0}function Nt(t,e){var n,r,i,o=e.type;o in t.a&&(n=t.a[o],(i=0<=(r=B(n,e)))&&Array.prototype.splice.call(n,r,1),i&&(_t(e),0==t.a[o].length&&(delete t.a[o],t.b--)))}function Dt(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i];if(!o.Y&&o.listener==e&&o.capture==!!n&&o.ca==r)return i}return-1}St.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var s=Dt(t,e,r,i);return-1<s?(e=t[s],n||(e.Z=!1)):((e=new Tt(e,this.src,o,!!r,i)).Z=n,t.push(e)),e};var At="closure_lm_"+(1e6*Math.random()|0),kt={};function Ct(t,e,n,r,i){if(r&&r.once)return function t(e,n,r,i,o){if(Array.isArray(n)){for(var s=0;s<n.length;s++)t(e,n[s],r,i,o);return null}r=Vt(r);return e&&e[It]?e.wa(n,r,R(i)?!!i.capture:!!i,o):Rt(e,n,r,!0,i,o)}(t,e,n,r,i);if(Array.isArray(e)){for(var o=0;o<e.length;o++)Ct(t,e[o],n,r,i);return null}return n=Vt(n),t&&t[It]?t.va(e,n,R(r)?!!r.capture:!!r,i):Rt(t,e,n,!1,r,i)}function Rt(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var s=R(i)?!!i.capture:!!i;if(s&&!yt)return null;var a,u,c=Mt(t);if(c||(t[At]=c=new St(t)),(n=c.add(e,n,r,s,o)).proxy)return n;if(a=Pt,r=u=yt?function(t){return a.call(u.src,u.listener,t)}:function(t){if(!(t=a.call(u.src,u.listener,t)))return t},(n.proxy=r).src=t,r.listener=n,t.addEventListener)void 0===(i=!mt?s:i)&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(Ot(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function xt(t){var e,n,r;"number"!=typeof t&&t&&!t.Y&&((e=t.src)&&e[It]?Nt(e.c,t):(n=t.type,r=t.proxy,e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(Ot(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=Mt(e))?(Nt(n,t),0==n.b&&(n.src=null,e[At]=null)):_t(t)))}function Ot(t){return t in kt?kt[t]:kt[t]="on"+t}function Lt(t,e){var n=t.listener,r=t.ca||t.src;return t.Z&&xt(t),n.call(r,e)}function Pt(t,e){if(t.Y)return!0;if(yt)return Lt(t,new bt(e,this));if(!e)t:{e=["window","event"];for(var n=A,r=0;r<e.length;r++)if(null==(n=n[e[r]])){e=null;break t}e=n}return Lt(t,e=new bt(e,this))}function Mt(t){return(t=t[At])instanceof St?t:null}var Ft="__closure_events_fn_"+(1e9*Math.random()>>>0);function Vt(e){return"function"==typeof e?e:(e[Ft]||(e[Ft]=function(t){return e.handleEvent(t)}),e[Ft])}function Ut(){q.call(this),this.c=new St(this),(this.J=this).C=null}function qt(t,e){var n,r=t.C;if(r)for(n=[];r;r=r.C)n.push(r);if(t=t.J,r=e.type||e,"string"==typeof e?e=new vt(e,t):e instanceof vt?e.target=e.target||t:(s=e,tt(e=new vt(r,t),s)),s=!0,n)for(var i=n.length-1;0<=i;i--)var o=e.a=n[i],s=Bt(o,r,!0,e)&&s;if(s=Bt(o=e.a=t,r,!0,e)&&s,s=Bt(o,r,!1,e)&&s,n)for(i=0;i<n.length;i++)s=Bt(o=e.a=n[i],r,!1,e)&&s}function Bt(t,e,n,r){if(!(e=t.c.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;o<e.length;++o){var s,a,u=e[o];u&&!u.Y&&u.capture==n&&(s=u.listener,a=u.ca||u.src,u.Z&&Nt(t.c,u),i=!1!==s.call(a,r)&&i)}return i&&!r.defaultPrevented}U(Ut,q),Ut.prototype[It]=!0,(S=Ut.prototype).addEventListener=function(t,e,n,r){Ct(this,t,e,n,r)},S.removeEventListener=function(t,e,n,r){!function t(e,n,r,i,o){if(Array.isArray(n))for(var s=0;s<n.length;s++)t(e,n[s],r,i,o);else i=R(i)?!!i.capture:!!i,r=Vt(r),e&&e[It]?(e=e.c,(n=String(n).toString())in e.a&&-1<(r=Dt(s=e.a[n],r,i,o))&&(_t(s[r]),Array.prototype.splice.call(s,r,1),0==s.length&&(delete e.a[n],e.b--))):(e=e&&Mt(e))&&(n=e.a[n.toString()],(r=(e=-1)<(e=n?Dt(n,r,i,o):e)?n[e]:null)&&xt(r))}(this,t,e,n,r)},S.G=function(){if(Ut.X.G.call(this),this.c){var t,e=this.c;for(t in e.a){for(var n=e.a[t],r=0;r<n.length;r++)_t(n[r]);delete e.a[t],e.b--}}this.C=null},S.va=function(t,e,n,r){return this.c.add(String(t),e,!1,n,r)},S.wa=function(t,e,n,r){return this.c.add(String(t),e,!0,n,r)};var jt=A.JSON.stringify;function Kt(){this.b=this.a=null}var Gt,Qt=(zt.prototype.get=function(){var t;return 0<this.b?(this.b--,t=this.a,this.a=t.next,t.next=null):t=this.c(),t},new zt(function(){return new Ht},function(t){t.reset()}));function zt(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function Ht(){this.next=this.b=this.a=null}function Wt(t,e){var n;Gt||(n=A.Promise.resolve(void 0),Gt=function(){n.then(Jt)}),Yt||(Gt(),Yt=!0),Xt.add(t,e)}Kt.prototype.add=function(t,e){var n=Qt.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},Ht.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null};var Yt=!(Ht.prototype.reset=function(){this.next=this.b=this.a=null}),Xt=new Kt;function Jt(){for(var t,e;n=e=void 0,n=null,(e=Xt).a&&(n=e.a,e.a=e.a.next,e.a||(e.b=null),n.next=null),t=n;){try{t.a.call(t.b)}catch(t){!function(t){A.setTimeout(function(){throw t},0)}(t)}var n=Qt;n.f(t),n.b<100&&(n.b++,t.next=n.a,n.a=t)}Yt=!1}function $t(t,e){Ut.call(this),this.b=t||1,this.a=e||A,this.f=M(this.Za,this),this.g=V()}function Zt(t){t.aa=!1,t.M&&(t.a.clearTimeout(t.M),t.M=null)}function te(t,e,n){if("function"==typeof t)n&&(t=M(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=M(t.handleEvent,t)}return 2147483647<Number(e)?-1:A.setTimeout(t,e||0)}U($t,Ut),(S=$t.prototype).aa=!1,S.M=null,S.Za=function(){var t;this.aa&&(0<(t=V()-this.g)&&t<.8*this.b?this.M=this.a.setTimeout(this.f,this.b-t):(this.M&&(this.a.clearTimeout(this.M),this.M=null),qt(this,"tick"),this.aa&&(Zt(this),this.start())))},S.start=function(){this.aa=!0,this.M||(this.M=this.a.setTimeout(this.f,this.b),this.g=V())},S.G=function(){$t.X.G.call(this),Zt(this),delete this.a};var ee,ne,re,ie=(T(ne=se,re=ee=q),ne.prototype=null===re?Object.create(re):(oe.prototype=re.prototype,new oe),se.prototype.f=function(t){this.b=arguments,this.a?this.c=!0:function t(e){e.a=te(function(){e.a=null,e.c&&(e.c=!1,t(e))},e.h);var n=e.b;e.b=null,e.g.apply(null,n)}(this)},se.prototype.G=function(){ee.prototype.G.call(this),this.a&&(A.clearTimeout(this.a),this.a=null,this.c=!1,this.b=null)},se);function oe(){this.constructor=ne}function se(t,e){var n=ee.call(this)||this;return n.g=t,n.h=e,n.b=null,n.c=!1,n.a=null,n}function ae(t){q.call(this),this.b=t,this.a={}}U(ae,q);var ue=[];function ce(t,e,n,r){Array.isArray(n)||(n&&(ue[0]=n.toString()),n=ue);for(var i=0;i<n.length;i++){var o=Ct(e,n[i],r||t.handleEvent,!1,t.b||t);if(!o)break;t.a[o.key]=o}}function he(t){J(t.a,function(t,e){this.a.hasOwnProperty(e)&&xt(t)},t),t.a={}}function le(){this.a=!0}function fe(t,e,n,r){t.info(function(){return"XMLHTTP TEXT ("+e+"): "+function(t,e){if(!t.a)return e;if(!e)return null;try{var n=JSON.parse(e);if(n)for(t=0;t<n.length;t++)if(Array.isArray(n[t])){var r=n[t];if(!(r.length<2)){var i=r[1];if(Array.isArray(i)&&!(i.length<1)){r=i[0];if("noop"!=r&&"stop"!=r&&"close"!=r)for(var o=1;o<i.length;o++)i[o]=""}}}return jt(n)}catch(t){return e}}(t,n)+(r?" "+r:"")})}ae.prototype.G=function(){ae.X.G.call(this),he(this)},ae.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},le.prototype.info=function(){};var de={},pe=null;function ye(){return pe=pe||new Ut}function ge(t){vt.call(this,de.Fa,t)}function me(t){var e=ye();qt(e,new ge(e))}function ve(t,e){vt.call(this,de.STAT_EVENT,t),this.stat=e}function be(t){var e=ye();qt(e,new ve(e,t))}function we(t){vt.call(this,de.Ga,t)}function Ie(t,e){if("function"!=typeof t)throw Error("Fn must not be null and must be a function");return A.setTimeout(function(){t()},e)}de.Fa="serverreachability",U(ge,vt),de.STAT_EVENT="statevent",U(ve,vt),de.Ga="timingevent",U(we,vt);var Ee={NO_ERROR:0,$a:1,nb:2,mb:3,hb:4,lb:5,ob:6,Da:7,TIMEOUT:8,rb:9},Te={fb:"complete",Bb:"success",Ea:"error",Da:"abort",tb:"ready",ub:"readystatechange",TIMEOUT:"timeout",pb:"incrementaldata",sb:"progress",ib:"downloadprogress",Jb:"uploadprogress"};function _e(){}function Se(t){var e;return e=!(e=t.a)?t.a={}:e}function Ne(){}_e.prototype.a=null;N={OPEN:"a",eb:"b",Ea:"c",qb:"d"};function De(){vt.call(this,"d")}function Ae(){vt.call(this,"c")}function ke(){}function Ce(t,e,n,r){this.g=t,this.c=e,this.f=n,this.S=r||1,this.J=new ae(this),this.P=xe,t=st?125:void 0,this.R=new $t(t),this.B=null,this.b=!1,this.j=this.l=this.i=this.H=this.u=this.T=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.V=this.C=this.U=this.I=!1}U(De,vt),U(Ae,vt),U(ke,_e);var Re=new ke,xe=45e3,Oe={},Le={};function Pe(t,e,n){t.H=1,t.i=nn(Xe(e)),t.j=n,t.I=!0,Me(t,null)}function Me(t,e){t.u=V(),Ve(t),t.l=Xe(t.i);var s,a,u,c,h,l,n=t.l,r=t.S;Array.isArray(r)||(r=[String(r)]),gn(n.b,"t",r),t.D=0,t.a=cr(t.g,t.g.C?e:null),0<t.O&&(t.F=new ie(M(t.Ca,t,t.a),t.O)),ce(t.J,t.a,"readystatechange",t.Xa),e=t.B?$(t.B):{},t.j?(t.m||(t.m="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.a.ba(t.l,t.m,t.j,e)):(t.m="GET",t.a.ba(t.l,t.m,null,e)),me(1),s=t.c,a=t.m,u=t.l,c=t.f,h=t.S,l=t.j,s.info(function(){if(s.a)if(l)for(var t="",e=l.split("&"),n=0;n<e.length;n++){var r,i,o=e[n].split("=");1<o.length&&(r=o[0],o=o[1],t=2<=(i=r.split("_")).length&&"type"==i[1]?t+(r+"=")+o+"&":t+(r+"=redacted&"))}else t=null;else t=l;return"XMLHTTP REQ ("+c+") [attempt "+h+"]: "+a+"\n"+u+"\n"+t})}function Fe(t,e,n){for(var r,i,o,s=!0;!t.A&&t.D<n.length;){var a=(a=n,o=i=void 0,i=(r=t).D,-1==(o=a.indexOf("\n",i))?Le:(i=Number(a.substring(i,o)),isNaN(i)?Oe:(o+=1)+i>a.length?Le:(a=a.substr(o,i),r.D=o+i,a)));if(a==Le){4==e&&(t.h=4,be(14),s=!1),fe(t.c,t.f,null,"[Incomplete Response]");break}if(a==Oe){t.h=4,be(15),fe(t.c,t.f,n,"[Invalid Chunk]"),s=!1;break}fe(t.c,t.f,a,null),Ke(t,a)}4==e&&0==n.length&&(t.h=1,be(16),s=!1),t.b=t.b&&s,s?0<n.length&&!t.V&&(t.V=!0,(e=t.g).a==t&&e.U&&!e.F&&(e.c.info("Great, no buffering proxy detected. Bytes received: "+n.length),er(e),e.F=!0,be(11))):(fe(t.c,t.f,n,"[Invalid Chunked Response]"),je(t),Be(t))}function Ve(t){t.T=V()+t.P,Ue(t,t.P)}function Ue(t,e){if(null!=t.o)throw Error("WatchDog timer not null");t.o=Ie(M(t.Va,t),e)}function qe(t){t.o&&(A.clearTimeout(t.o),t.o=null)}function Be(t){0==t.g.v||t.A||ir(t.g,t)}function je(t){qe(t);var e=t.F;e&&"function"==typeof e.ja&&e.ja(),t.F=null,Zt(t.R),he(t.J),t.a&&(e=t.a,t.a=null,e.abort(),e.ja())}function Ke(t,e){try{var n,r,i,o,s,a=t.g;if(0!=a.v&&(a.a==t||Tn(a.b,t)))if(a.I=t.N,!t.C&&Tn(a.b,t)&&3==a.v){try{var u=a.ka.a.parse(e)}catch(t){u=null}if(Array.isArray(u)&&3==u.length){var c=u;if(0==c[0]){t:if(!a.j){if(a.a){if(!(a.a.u+3e3<t.u))break t;rr(a),zn(a)}tr(a),be(18)}}else a.oa=c[1],0<a.oa-a.P&&c[2]<37500&&a.H&&0==a.o&&!a.m&&(a.m=Ie(M(a.Sa,a),6e3));if(En(a.b)<=1&&a.ea){try{a.ea()}catch(t){}a.ea=void 0}}else sr(a,11)}else if(!t.C&&a.a!=t||rr(a),!Q(e))for(e=u=a.ka.a.parse(e),u=0;u<e.length;u++)c=e[u],a.P=c[0],c=c[1],2==a.v?"c"==c[0]?(a.J=c[1],a.ga=c[2],null!=(r=c[3])&&(a.ha=r,a.c.info("VER="+a.ha)),null!=(o=c[4])&&(a.pa=o,a.c.info("SVER="+a.pa)),null!=(r=c[5])&&"number"==typeof r&&0<r&&(n=1.5*r,a.D=n,a.c.info("backChannelRequestTimeoutMs_="+n)),n=a,(o=t.a)&&(!(r=o.a?o.a.getResponseHeader("X-Client-Wire-Protocol"):null)||!(i=n.b).a&&(W(r,"spdy")||W(r,"quic")||W(r,"h2"))&&(i.f=i.g,i.a=new Set,i.b&&(_n(i,i.b),i.b=null)),!n.A||(s=o.a?o.a.getResponseHeader("X-HTTP-Session-Id"):null)&&(n.na=s,en(n.B,n.A,s))),a.v=3,a.f&&a.f.ta(),a.U&&(a.N=V()-t.u,a.c.info("Handshake RTT: "+a.N+"ms")),i=t,(n=a).la=ur(n,n.C?n.ga:null,n.fa),i.C?(Sn(n.b,i),o=i,(s=n.D)&&o.setTimeout(s),o.o&&(qe(o),Ve(o)),n.a=i):Zn(n),0<a.g.length&&Yn(a)):"stop"!=c[0]&&"close"!=c[0]||sr(a,7):3==a.v&&("stop"==c[0]||"close"==c[0]?"stop"==c[0]?sr(a,7):Qn(a):"noop"!=c[0]&&a.f&&a.f.sa(c),a.o=0);me(4)}catch(t){}}function Ge(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(C(t)||"string"==typeof t)j(t,e,void 0);else{if(t.L&&"function"==typeof t.L)var n=t.L();else if(t.K&&"function"==typeof t.K)n=void 0;else if(C(t)||"string"==typeof t)for(var n=[],r=t.length,i=0;i<r;i++)n.push(i);else for(i in n=[],r=0,t)n[r++]=i;for(var i=(r=function(t){if(t.K&&"function"==typeof t.K)return t.K();if("string"==typeof t)return t.split("");if(C(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t)).length,o=0;o<i;o++)e.call(void 0,r[o],n&&n[o],t)}}function Qe(t,e){this.b={},this.a=[],this.c=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(t)if(t instanceof Qe)for(n=t.L(),r=0;r<n.length;r++)this.set(n[r],t.get(n[r]));else for(r in t)this.set(r,t[r])}function ze(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];He(t.b,r)&&(t.a[n++]=r),e++}t.a.length=n}if(t.c!=t.a.length){for(var i={},n=e=0;e<t.a.length;)He(i,r=t.a[e])||(i[t.a[n++]=r]=1),e++;t.a.length=n}}function He(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(S=Ce.prototype).setTimeout=function(t){this.P=t},S.Xa=function(t){t=t.target;var e=this.F;e&&3==Bn(t)?e.f():this.Ca(t)},S.Ca=function(t){try{if(t==this.a)t:{var e=Bn(this.a),n=this.a.ua(),r=this.a.W();if(!(e<3||3==e&&!st&&!this.a.$())){this.A||4!=e||7==n||me(8==n||r<=0?3:2),qe(this);var i=this.a.W();this.N=i;var o=this.a.$();if(this.b=200==i,r=this.c,u=this.m,c=this.l,h=this.f,l=this.S,f=e,d=i,r.info(function(){return"XMLHTTP RESP ("+h+") [ attempt "+l+"]: "+u+"\n"+c+"\n"+f+" "+d}),this.b){if(this.U&&!this.C){e:{if(this.a){var s=this.a;if((s=s.a?s.a.getResponseHeader("X-HTTP-Initial-Response"):null)&&!Q(s)){var a=s;break e}}a=null}if(!a){this.b=!1,this.h=3,be(12),je(this),Be(this);break t}fe(this.c,this.f,a,"Initial handshake response via X-HTTP-Initial-Response"),this.C=!0,Ke(this,a)}this.I?(Fe(this,e,o),st&&this.b&&3==e&&(ce(this.J,this.R,"tick",this.Wa),this.R.start())):(fe(this.c,this.f,o,null),Ke(this,o)),4==e&&je(this),this.b&&!this.A&&(4==e?ir(this.g,this):(this.b=!1,Ve(this)))}else 400==i&&0<o.indexOf("Unknown SID")?(this.h=3,be(12)):(this.h=0,be(13)),je(this),Be(this)}}}catch(t){}var u,c,h,l,f,d},S.Wa=function(){var t,e;this.a&&(t=Bn(this.a),e=this.a.$(),this.D<e.length&&(qe(this),Fe(this,t,e),this.b&&4!=t&&Ve(this)))},S.cancel=function(){this.A=!0,je(this)},S.Va=function(){this.o=null;var t,e,n=V();0<=n-this.T?(t=this.c,e=this.l,t.info(function(){return"TIMEOUT: "+e}),2!=this.H&&(me(3),be(17)),je(this),this.h=2,Be(this)):Ue(this,this.T-n)},(S=Qe.prototype).K=function(){ze(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},S.L=function(){return ze(this),this.a.concat()},S.get=function(t,e){return He(this.b,t)?this.b[t]:e},S.set=function(t,e){He(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},S.forEach=function(t,e){for(var n=this.L(),r=0;r<n.length;r++){var i=n[r],o=this.get(i);t.call(e,o,i,this)}};var We=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Ye(t,e){var n;this.c=this.j=this.f="",this.h=null,this.i=this.g="",this.a=!1,t instanceof Ye?(this.a=void 0!==e?e:t.a,Je(this,t.f),this.j=t.j,$e(this,t.c),Ze(this,t.h),this.g=t.g,e=t.b,(n=new fn).c=e.c,e.a&&(n.a=new Qe(e.a),n.b=e.b),tn(this,n),this.i=t.i):t&&(n=String(t).match(We))?(this.a=!!e,Je(this,n[1]||"",!0),this.j=rn(n[2]||""),$e(this,n[3]||"",!0),Ze(this,n[4]),this.g=rn(n[5]||"",!0),tn(this,n[6]||"",!0),this.i=rn(n[7]||"")):(this.a=!!e,this.b=new fn(null,this.a))}function Xe(t){return new Ye(t)}function Je(t,e,n){t.f=n?rn(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function $e(t,e,n){t.c=n?rn(e,!0):e}function Ze(t,e){if(e){if(e=Number(e),isNaN(e)||e<0)throw Error("Bad port number "+e);t.h=e}else t.h=null}function tn(t,e,n){var r,i;e instanceof fn?(t.b=e,r=t.b,(i=t.a)&&!r.f&&(dn(r),r.c=null,r.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(pn(this,e),gn(this,n,t))},r)),r.f=i):(n||(e=on(e,hn)),t.b=new fn(e,t.a))}function en(t,e,n){t.b.set(e,n)}function nn(t){return en(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^V()).toString(36)),t}function rn(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function on(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,sn),t=n?t.replace(/%25([0-9a-fA-F]{2})/g,"%$1"):t):null}function sn(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}Ye.prototype.toString=function(){var t=[],e=this.f;e&&t.push(on(e,an,!0),":");var n=this.c;return!n&&"file"!=e||(t.push("//"),(e=this.j)&&t.push(on(e,an,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.h)&&t.push(":",String(n))),(n=this.g)&&(this.c&&"/"!=n.charAt(0)&&t.push("/"),t.push(on(n,"/"==n.charAt(0)?cn:un,!0))),(n=this.b.toString())&&t.push("?",n),(n=this.i)&&t.push("#",on(n,ln)),t.join("")};var an=/[#\/\?@]/g,un=/[#\?:]/g,cn=/[#\?]/g,hn=/[#\?@]/g,ln=/#/g;function fn(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function dn(n){n.a||(n.a=new Qe,n.b=0,n.c&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r,i=t[n].indexOf("="),o=null;0<=i?(r=t[n].substring(0,i),o=t[n].substring(i+1)):r=t[n],e(r,o?decodeURIComponent(o.replace(/\+/g," ")):"")}}}(n.c,function(t,e){n.add(decodeURIComponent(t.replace(/\+/g," ")),e)}))}function pn(t,e){dn(t),e=mn(t,e),He(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,He((t=t.a).b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&ze(t)))}function yn(t,e){return dn(t),e=mn(t,e),He(t.a.b,e)}function gn(t,e,n){pn(t,e),0<n.length&&(t.c=null,t.a.set(mn(t,e),G(n)),t.b+=n.length)}function mn(t,e){return e=String(e),e=t.f?e.toLowerCase():e}(S=fn.prototype).add=function(t,e){dn(this),this.c=null,t=mn(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},S.forEach=function(n,r){dn(this),this.a.forEach(function(t,e){j(t,function(t){n.call(r,t,e,this)},this)},this)},S.L=function(){dn(this);for(var t=this.a.K(),e=this.a.L(),n=[],r=0;r<e.length;r++)for(var i=t[r],o=0;o<i.length;o++)n.push(e[r]);return n},S.K=function(t){dn(this);var e=[];if("string"==typeof t)yn(this,t)&&(e=K(e,this.a.get(mn(this,t))));else{t=this.a.K();for(var n=0;n<t.length;n++)e=K(e,t[n])}return e},S.set=function(t,e){return dn(this),this.c=null,yn(this,t=mn(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},S.get=function(t,e){return t&&0<(t=this.K(t)).length?String(t[0]):e},S.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var t=[],e=this.a.L(),n=0;n<e.length;n++)for(var r=e[n],i=encodeURIComponent(String(r)),r=this.K(r),o=0;o<r.length;o++){var s=i;""!==r[o]&&(s+="="+encodeURIComponent(String(r[o]))),t.push(s)}return this.c=t.join("&")};var vn=function(t,e){this.b=t,this.a=e};function bn(t){this.g=t||wn,t=A.PerformanceNavigationTiming?0<(t=A.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(A.ia&&A.ia.ya&&A.ia.ya()&&A.ia.ya().Lb),this.f=t?this.g:1,this.a=null,1<this.f&&(this.a=new Set),this.b=null,this.c=[]}var wn=10;function In(t){return t.b||t.a&&t.a.size>=t.f}function En(t){return t.b?1:t.a?t.a.size:0}function Tn(t,e){return t.b?t.b==e:t.a&&t.a.has(e)}function _n(t,e){t.a?t.a.add(e):t.b=e}function Sn(t,e){t.b&&t.b==e?t.b=null:t.a&&t.a.has(e)&&t.a.delete(e)}function Nn(t){var e,n;if(null!=t.b)return t.c.concat(t.b.s);if(null==t.a||0===t.a.size)return G(t.c);var r=t.c;try{for(var i=_(t.a.values()),o=i.next();!o.done;o=i.next())var s=o.value,r=r.concat(s.s)}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r}function Dn(){}function An(){this.a=new Dn}function kn(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}bn.prototype.cancel=function(){var e,t;if(this.c=Nn(this),this.b)this.b.cancel(),this.b=null;else if(this.a&&0!==this.a.size){try{for(var n=_(this.a.values()),r=n.next();!r.done;r=n.next())r.value.cancel()}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.a.clear()}},Dn.prototype.stringify=function(t){return A.JSON.stringify(t,void 0)},Dn.prototype.parse=function(t){return A.JSON.parse(t,void 0)};var Cn=A.JSON.parse;function Rn(t){Ut.call(this),this.headers=new Qe,this.H=t||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=xn,this.D=this.F=!1}U(Rn,Ut);var xn="",On=/^https?$/i,Ln=["POST","PUT"];function Pn(t){return"content-type"==t.toLowerCase()}function Mn(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,Fn(t),Un(t)}function Fn(t){t.u||(t.u=!0,qt(t,"complete"),qt(t,"error"))}function Vn(t){if(t.b&&void 0!==D&&(!t.s[1]||4!=Bn(t)||2!=t.W()))if(t.l&&4==Bn(t))te(t.za,0,t);else if(qt(t,"readystatechange"),4==Bn(t)){t.b=!1;try{var e,n,r,i,o=t.W();t:switch(o){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var s=!0;break t;default:s=!1}(e=s)||((n=0===o)&&(!(i=String(t.B).match(We)[1]||null)&&A.self&&A.self.location&&(i=(r=A.self.location.protocol).substr(0,r.length-1)),n=!On.test(i?i.toLowerCase():"")),e=n);if(e)qt(t,"complete"),qt(t,"success");else{t.h=6;try{var a=2<Bn(t)?t.a.statusText:""}catch(o){a=""}t.f=a+" ["+t.W()+"]",Fn(t)}}finally{Un(t)}}}function Un(t,e){if(t.a){qn(t);var n=t.a,r=t.s[0]?k:null;t.a=null,t.s=null,e||qt(t,"ready");try{n.onreadystatechange=r}catch(t){}}}function qn(t){t.a&&t.D&&(t.a.ontimeout=null),t.m&&(A.clearTimeout(t.m),t.m=null)}function Bn(t){return t.a?t.a.readyState:0}function jn(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}var i;r||(i="",J(n,function(t,e){i+=e,i+=":",i+=t,i+="\r\n"}),n=i,"string"==typeof t?null!=n&&encodeURIComponent(String(n)):en(t,e,n))}function Kn(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function Gn(t){this.pa=0,this.g=[],this.c=new le,this.ga=this.la=this.B=this.fa=this.a=this.na=this.A=this.V=this.i=this.O=this.l=null,this.Oa=this.R=0,this.La=Kn("failFast",!1,t),this.H=this.m=this.j=this.h=this.f=null,this.S=!0,this.I=this.oa=this.P=-1,this.T=this.o=this.u=0,this.Ha=Kn("baseRetryDelayMs",5e3,t),this.Ra=Kn("retryDelaySeedMs",1e4,t),this.Ma=Kn("forwardChannelMaxRetries",2,t),this.ma=Kn("forwardChannelRequestTimeoutMs",2e4,t),this.Na=t&&t.g||void 0,this.D=void 0,this.C=t&&t.supportsCrossDomainXhr||!1,this.J="",this.b=new bn(t&&t.concurrentRequestLimit),this.ka=new An,this.da=t&&t.fastHandshake||!1,this.Ia=t&&t.b||!1,t&&t.f&&(this.c.a=!1),t&&t.forceLongPolling&&(this.S=!1),this.U=!this.da&&this.S&&t&&t.detectBufferingProxy||!1,this.ea=void 0,this.N=0,this.F=!1,this.s=null,(this.Ka=t&&t.c||!1)&&this.c.info("Opt-in to enable Chrome Origin Trials.")}function Qn(t){var e,n;Hn(t),3==t.v&&(e=t.R++,en(n=Xe(t.B),"SID",t.J),en(n,"RID",e),en(n,"TYPE","terminate"),Jn(t,n),(e=new Ce(t,t.c,e,void 0)).H=2,e.i=nn(Xe(n)),n=!1,!(n=A.navigator&&A.navigator.sendBeacon?A.navigator.sendBeacon(e.i.toString(),""):n)&&A.Image&&((new Image).src=e.i,n=!0),n||(e.a=cr(e.g,null),e.a.ba(e.i)),e.u=V(),Ve(e)),ar(t)}function zn(t){t.a&&(er(t),t.a.cancel(),t.a=null)}function Hn(t){zn(t),t.j&&(A.clearTimeout(t.j),t.j=null),rr(t),t.b.cancel(),t.h&&("number"==typeof t.h&&A.clearTimeout(t.h),t.h=null)}function Wn(t,e){t.g.push(new vn(t.Oa++,e)),3==t.v&&Yn(t)}function Yn(t){In(t.b)||t.h||(t.h=!0,Wt(t.Ba,t),t.u=0)}function Xn(t,e){var n=e?e.f:t.R++,r=Xe(t.B);en(r,"SID",t.J),en(r,"RID",n),en(r,"AID",t.P),Jn(t,r),t.i&&t.l&&jn(r,t.i,t.l),n=new Ce(t,t.c,n,t.u+1),null===t.i&&(n.B=t.l),e&&(t.g=e.s.concat(t.g)),e=$n(t,n,1e3),n.setTimeout(Math.round(.5*t.ma)+Math.round(.5*t.ma*Math.random())),_n(t.b,n),Pe(n,r,e)}function Jn(t,n){t.f&&Ge({},function(t,e){en(n,e,t)})}function $n(t,e,n){n=Math.min(t.g.length,n);var r=t.f?M(t.f.Ja,t.f,t):null;t:for(var i=t.g,o=-1;;){var s=["count="+n];-1==o?0<n?(o=i[0].b,s.push("ofs="+o)):o=0:s.push("ofs="+o);for(var a=!0,u=0;u<n;u++){var c=i[u].b,h=i[u].a;if((c-=o)<0)o=Math.max(0,i[u].b-100),a=!1;else try{!function(t,r,e){var i=e||"";try{Ge(t,function(t,e){var n=t;R(t)&&(n=jt(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}(h,s,"req"+c+"_")}catch(t){r&&r(h)}}if(a){r=s.join("&");break t}}return t=t.g.splice(0,n),e.s=t,r}function Zn(t){t.a||t.j||(t.T=1,Wt(t.Aa,t),t.o=0)}function tr(t){return!(t.a||t.j||3<=t.o)&&(t.T++,t.j=Ie(M(t.Aa,t),or(t,t.o)),t.o++,1)}function er(t){null!=t.s&&(A.clearTimeout(t.s),t.s=null)}function nr(t){t.a=new Ce(t,t.c,"rpc",t.T),null===t.i&&(t.a.B=t.l),t.a.O=0;var e=Xe(t.la);en(e,"RID","rpc"),en(e,"SID",t.J),en(e,"CI",t.H?"0":"1"),en(e,"AID",t.P),Jn(t,e),en(e,"TYPE","xmlhttp"),t.i&&t.l&&jn(e,t.i,t.l),t.D&&t.a.setTimeout(t.D);var n=t.a;t=t.ga,n.H=1,n.i=nn(Xe(e)),n.j=null,n.I=!0,Me(n,t)}function rr(t){null!=t.m&&(A.clearTimeout(t.m),t.m=null)}function ir(t,e){var n,r,i,o=null;if(t.a==e){rr(t),er(t),t.a=null;var s=2}else{if(!Tn(t.b,e))return;o=e.s,Sn(t.b,e),s=1}if(t.I=e.N,0!=t.v)if(e.b)1==s?(o=e.j?e.j.length:0,e=V()-e.u,n=t.u,qt(s=ye(),new we(s)),Yn(t)):Zn(t);else if(3==(n=e.h)||0==n&&0<t.I||(1!=s||(i=e,En((r=t).b)>=r.b.f-(r.h?1:0)||(r.h?(r.g=i.s.concat(r.g),0):1==r.v||2==r.v||r.u>=(r.La?0:r.Ma)||(r.h=Ie(M(r.Ba,r,i),or(r,r.u)),r.u++,0))))&&(2!=s||!tr(t)))switch(o&&0<o.length&&(e=t.b,e.c=e.c.concat(o)),n){case 1:sr(t,5);break;case 4:sr(t,10);break;case 3:sr(t,6);break;default:sr(t,2)}}function or(t,e){var n=t.Ha+Math.floor(Math.random()*t.Ra);return t.f||(n*=2),n*e}function sr(t,e){var n,r,i,o;t.c.info("Error code "+e),2==e?(r=null,t.f&&(r=null),o=M(t.Ya,t),r||(r=new Ye("//www.google.com/images/cleardot.gif"),A.location&&"http"==A.location.protocol||Je(r,"https"),nn(r)),n=r.toString(),r=o,o=new le,A.Image?((i=new Image).onload=F(kn,o,i,"TestLoadImage: loaded",!0,r),i.onerror=F(kn,o,i,"TestLoadImage: error",!1,r),i.onabort=F(kn,o,i,"TestLoadImage: abort",!1,r),i.ontimeout=F(kn,o,i,"TestLoadImage: timeout",!1,r),A.setTimeout(function(){i.ontimeout&&i.ontimeout()},1e4),i.src=n):r(!1)):be(2),t.v=0,t.f&&t.f.ra(e),ar(t),Hn(t)}function ar(t){t.v=0,t.I=-1,t.f&&(0==Nn(t.b).length&&0==t.g.length||(t.b.c.length=0,G(t.g),t.g.length=0),t.f.qa())}function ur(t,e,n){var r,i,o,s,a,u=(s=n)instanceof Ye?Xe(s):new Ye(s,void 0);return""!=u.c?(e&&$e(u,e+"."+u.c),Ze(u,u.h)):(a=A.location,r=a.protocol,i=e?e+"."+a.hostname:a.hostname,o=+a.port,s=n,a=new Ye(null,void 0),r&&Je(a,r),i&&$e(a,i),o&&Ze(a,o),s&&(a.g=s),u=a),t.V&&J(t.V,function(t,e){en(u,e,t)}),e=t.A,n=t.na,e&&n&&en(u,e,n),en(u,"VER",t.ha),Jn(t,u),u}function cr(t,e){if(e&&!t.C)throw Error("Can't create secondary domain capable XhrIo object.");return(e=new Rn(t.Na)).F=t.C,e}function hr(){}function lr(){if(it&&!(10<=Number(pt)))throw Error("Environmental error: no available transport.")}function fr(t,e){Ut.call(this),this.a=new Gn(e),this.o=t,this.b=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.a.l=t,t=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(t?t["X-WebChannel-Content-Type"]=e.messageContentType:t={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.a&&(t?t["X-WebChannel-Client-Profile"]=e.a:t={"X-WebChannel-Client-Profile":e.a}),this.a.O=t,(t=e&&e.httpHeadersOverwriteParam)&&!Q(t)&&(this.a.i=t),this.m=e&&e.supportsCrossDomainXhr||!1,this.l=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!Q(e)&&(this.a.A=e,null!==(t=this.b)&&e in t&&(e in(t=this.b)&&delete t[e])),this.f=new yr(this)}function dr(t){De.call(this);var e=t.__sm__;if(e){t:{for(var n in e){t=n;break t}t=void 0}(this.c=t)?(t=this.c,this.data=null!==e&&t in e?e[t]:void 0):this.data=e}else this.data=t}function pr(){Ae.call(this),this.status=1}function yr(t){this.a=t}(S=Rn.prototype).ba=function(t,e,n,r){if(this.a)throw Error("[goog.net.XhrIo] Object is active with another request="+this.B+"; newUri="+t);e=e?e.toUpperCase():"GET",this.B=t,this.f="",this.h=0,this.u=!1,this.b=!0,this.a=new XMLHttpRequest,this.s=this.H?Se(this.H):Se(Re),this.a.onreadystatechange=M(this.za,this);try{this.A=!0,this.a.open(e,String(t),!0),this.A=!1}catch(t){return void Mn(this,t)}t=n||"";var i,o=new Qe(this.headers);r&&Ge(r,function(t,e){o.set(e,t)}),r=function(t){t:{for(var e=Pn,n=t.length,r="string"==typeof t?t.split(""):t,i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t)){e=i;break t}e=-1}return e<0?null:"string"==typeof t?t.charAt(e):t[e]}(o.L()),n=A.FormData&&t instanceof A.FormData,0<=B(Ln,e)&&!r&&!n&&o.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),o.forEach(function(t,e){this.a.setRequestHeader(e,t)},this),this.I&&(this.a.responseType=this.I),"withCredentials"in this.a&&this.a.withCredentials!==this.F&&(this.a.withCredentials=this.F);try{qn(this),0<this.o&&((this.D=(i=this.a,it&&dt(9)&&"number"==typeof i.timeout&&void 0!==i.ontimeout))?(this.a.timeout=this.o,this.a.ontimeout=M(this.xa,this)):this.m=te(this.xa,this.o,this)),this.l=!0,this.a.send(t),this.l=!1}catch(t){Mn(this,t)}},S.xa=function(){void 0!==D&&this.a&&(this.f="Timed out after "+this.o+"ms, aborting",this.h=8,qt(this,"timeout"),this.abort(8))},S.abort=function(t){this.a&&this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1,this.h=t||7,qt(this,"complete"),qt(this,"abort"),Un(this))},S.G=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),Un(this,!0)),Rn.X.G.call(this)},S.za=function(){this.j||(this.A||this.l||this.g?Vn(this):this.Ua())},S.Ua=function(){Vn(this)},S.W=function(){try{return 2<Bn(this)?this.a.status:-1}catch(t){return-1}},S.$=function(){try{return this.a?this.a.responseText:""}catch(t){return""}},S.Pa=function(t){if(this.a){var e=this.a.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Cn(e)}},S.ua=function(){return this.h},S.Qa=function(){return"string"==typeof this.f?this.f:String(this.f)},(S=Gn.prototype).ha=8,S.v=1,S.Ba=function(t){if(this.h)if(this.h=null,1==this.v){if(!t){this.R=Math.floor(1e5*Math.random()),t=this.R++;var e,n=new Ce(this,this.c,t,void 0),r=this.l;if(this.O&&(r?tt(r=$(r),this.O):r=this.O),null===this.i&&(n.B=r),this.da)t:{for(var i=e=0;i<this.g.length;i++){var o=this.g[i];if("__data__"in o.a&&"string"==typeof(o=o.a.__data__)?o=o.length:o=void 0,void 0===o)break;if(4096<(e+=o)){e=i;break t}if(4096===e||i===this.g.length-1){e=i+1;break t}}e=1e3}else e=1e3;e=$n(this,n,e),en(i=Xe(this.B),"RID",t),en(i,"CVER",22),this.A&&en(i,"X-HTTP-Session-Id",this.A),Jn(this,i),this.i&&r&&jn(i,this.i,r),_n(this.b,n),this.Ia&&en(i,"TYPE","init"),this.da?(en(i,"$req",e),en(i,"SID","null"),n.U=!0,Pe(n,i,null)):Pe(n,i,e),this.v=2}}else 3==this.v&&(t?Xn(this,t):0==this.g.length||In(this.b)||Xn(this))},S.Aa=function(){var t;this.j=null,nr(this),this.U&&!(this.F||null==this.a||this.N<=0)&&(t=2*this.N,this.c.info("BP detection timer enabled: "+t),this.s=Ie(M(this.Ta,this),t))},S.Ta=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,be(10),zn(this),nr(this))},S.Sa=function(){null!=this.m&&(this.m=null,zn(this),tr(this),be(19))},S.Ya=function(t){t?(this.c.info("Successfully pinged google.com"),be(2)):(this.c.info("Failed to ping google.com"),be(1))},(S=hr.prototype).ta=function(){},S.sa=function(){},S.ra=function(){},S.qa=function(){},S.Ja=function(){},lr.prototype.a=function(t,e){return new fr(t,e)},U(fr,Ut),fr.prototype.g=function(){this.a.f=this.f,this.m&&(this.a.C=!0);var t=this.a,e=this.o,n=this.b||void 0;be(0),t.fa=e,t.V=n||{},t.H=t.S,t.B=ur(t,null,t.fa),Yn(t)},fr.prototype.close=function(){Qn(this.a)},fr.prototype.h=function(t){var e;"string"==typeof t?((e={}).__data__=t,Wn(this.a,e)):this.l?((e={}).__data__=jt(t),Wn(this.a,e)):Wn(this.a,t)},fr.prototype.G=function(){this.a.f=null,delete this.f,Qn(this.a),delete this.a,fr.X.G.call(this)},U(dr,De),U(pr,Ae),U(yr,hr),yr.prototype.ta=function(){qt(this.a,"a")},yr.prototype.sa=function(t){qt(this.a,new dr(t))},yr.prototype.ra=function(t){qt(this.a,new pr)},yr.prototype.qa=function(){qt(this.a,"b")},lr.prototype.createWebChannel=lr.prototype.a,fr.prototype.send=fr.prototype.h,fr.prototype.open=fr.prototype.g,Ee.NO_ERROR=0,Ee.TIMEOUT=8,Ee.HTTP_ERROR=6,Te.COMPLETE="complete",(Ne.EventType=N).OPEN="a",N.CLOSE="b",N.ERROR="c",N.MESSAGE="d",Ut.prototype.listen=Ut.prototype.va,Rn.prototype.listenOnce=Rn.prototype.wa,Rn.prototype.getLastError=Rn.prototype.Qa,Rn.prototype.getLastErrorCode=Rn.prototype.ua,Rn.prototype.getStatus=Rn.prototype.W,Rn.prototype.getResponseJson=Rn.prototype.Pa,Rn.prototype.getResponseText=Rn.prototype.$,Rn.prototype.send=Rn.prototype.ba;var gr=ye,mr=Ee,vr=Te,br=de,wr=10,Ir=11,Er=Ne,Tr=Rn,_r=(Sr.prototype.t=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},Sr.prototype.next=function(){var t=++this.previousValue;return this.i&&this.i(t),t},Sr);function Sr(t,e){var n=this;this.previousValue=t,e&&(e.sequenceNumberHandler=function(t){return n.t(t)},this.i=function(t){return e.writeSequenceNumber(t)})}_r.o=-1;var Nr,Dr={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},Ar=(n(Cr,Nr=Error),Cr),kr=new I("@firebase/firestore");function Cr(t,e){var n=this;return(n=Nr.call(this,e)||this).code=t,n.message=e,n.name="FirebaseError",n.toString=function(){return n.name+": [code="+n.code+"]: "+n.message},n}function Rr(){return kr.logLevel}function xr(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];kr.logLevel<=f.DEBUG&&(e=n.map(Pr),kr.debug.apply(kr,s(["Firestore (8.4.2): "+t],e)))}function Or(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];kr.logLevel<=f.ERROR&&(e=n.map(Pr),kr.error.apply(kr,s(["Firestore (8.4.2): "+t],e)))}function Lr(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];kr.logLevel<=f.WARN&&(e=n.map(Pr),kr.warn.apply(kr,s(["Firestore (8.4.2): "+t],e)))}function Pr(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return e}}function Mr(t){t="FIRESTORE (8.4.2) INTERNAL ASSERTION FAILED: "+(t=void 0===t?"Unexpected state":t);throw Or(t),new Error(t)}function Fr(t){t||Mr()}var Vr=(Ur.u=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length,n="";n.length<20;)for(var r=function(t){var e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(var r=0;r<t;r++)n[r]=Math.floor(256*Math.random());return n}(40),i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%t.length));return n},Ur);function Ur(){}function qr(t,e){return t<e?-1:e<t?1:0}function Br(t,n,r){return t.length===n.length&&t.every(function(t,e){return r(t,n[e])})}function jr(t){return t+"\0"}var Kr=(zr.now=function(){return zr.fromMillis(Date.now())},zr.fromDate=function(t){return zr.fromMillis(t.getTime())},zr.fromMillis=function(t){var e=Math.floor(t/1e3);return new zr(e,Math.floor(1e6*(t-1e3*e)))},zr.prototype.toDate=function(){return new Date(this.toMillis())},zr.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},zr.prototype._compareTo=function(t){return this.seconds===t.seconds?qr(this.nanoseconds,t.nanoseconds):qr(this.seconds,t.seconds)},zr.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},zr.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},zr.prototype.toJSON=function(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}},zr.prototype.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")},zr),Gr=(Qr.fromTimestamp=function(t){return new Qr(t)},Qr.min=function(){return new Qr(new Kr(0,0))},Qr.prototype.compareTo=function(t){return this.timestamp._compareTo(t.timestamp)},Qr.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},Qr.prototype.toMicroseconds=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},Qr.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},Qr.prototype.toTimestamp=function(){return this.timestamp},Qr);function Qr(t){this.timestamp=t}function zr(t,e){if(this.seconds=t,(this.nanoseconds=e)<0)throw new Ar(Dr.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(1e9<=e)throw new Ar(Dr.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new Ar(Dr.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(253402300800<=t)throw new Ar(Dr.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}function Hr(t){var e,n=0;for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&n++;return n}function Wr(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function Yr(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}var Xr,Jr,Te=(Object.defineProperty(ai.prototype,"length",{get:function(){return this.len},enumerable:!1,configurable:!0}),ai.prototype.isEqual=function(t){return 0===ai.comparator(this,t)},ai.prototype.child=function(t){var e=this.segments.slice(this.offset,this.limit());return t instanceof ai?t.forEach(function(t){e.push(t)}):e.push(t),this.construct(e)},ai.prototype.limit=function(){return this.offset+this.length},ai.prototype.popFirst=function(t){return t=void 0===t?1:t,this.construct(this.segments,this.offset+t,this.length-t)},ai.prototype.popLast=function(){return this.construct(this.segments,this.offset,this.length-1)},ai.prototype.firstSegment=function(){return this.segments[this.offset]},ai.prototype.lastSegment=function(){return this.get(this.length-1)},ai.prototype.get=function(t){return this.segments[this.offset+t]},ai.prototype.isEmpty=function(){return 0===this.length},ai.prototype.isPrefixOf=function(t){if(t.length<this.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},ai.prototype.isImmediateParentOf=function(t){if(this.length+1!==t.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},ai.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},ai.prototype.toArray=function(){return this.segments.slice(this.offset,this.limit())},ai.comparator=function(t,e){for(var n=Math.min(t.length,e.length),r=0;r<n;r++){var i=t.get(r),o=e.get(r);if(i<o)return-1;if(o<i)return 1}return t.length<e.length?-1:t.length>e.length?1:0},ai),$r=(n(si,Jr=Te),si.prototype.construct=function(t,e,n){return new si(t,e,n)},si.prototype.canonicalString=function(){return this.toArray().join("/")},si.prototype.toString=function(){return this.canonicalString()},si.fromString=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=[],r=0,i=t;r<i.length;r++){var o=i[r];if(0<=o.indexOf("//"))throw new Ar(Dr.INVALID_ARGUMENT,"Invalid segment ("+o+"). Paths must not contain // in them.");n.push.apply(n,o.split("/").filter(function(t){return 0<t.length}))}return new si(n)},si.emptyPath=function(){return new si([])},si),Zr=/^[_a-zA-Z][_a-zA-Z0-9]*$/,ti=(n(oi,Xr=Te),oi.prototype.construct=function(t,e,n){return new oi(t,e,n)},oi.isValidIdentifier=function(t){return Zr.test(t)},oi.prototype.canonicalString=function(){return this.toArray().map(function(t){return t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),t=!oi.isValidIdentifier(t)?"`"+t+"`":t}).join(".")},oi.prototype.toString=function(){return this.canonicalString()},oi.prototype.isKeyField=function(){return 1===this.length&&"__name__"===this.get(0)},oi.keyField=function(){return new oi(["__name__"])},oi.fromServerFormat=function(t){for(var e=[],n="",r=0,i=function(){if(0===n.length)throw new Ar(Dr.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'");e.push(n),n=""},o=!1;r<t.length;){var s=t[r];if("\\"===s){if(r+1===t.length)throw new Ar(Dr.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var a=t[r+1];if("\\"!==a&&"."!==a&&"`"!==a)throw new Ar(Dr.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=a,r+=2}else"`"===s?o=!o:"."!==s||o?n+=s:i(),r++}if(i(),o)throw new Ar(Dr.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new oi(e)},oi.emptyPath=function(){return new oi([])},oi),ei=(ii.prototype.covers=function(t){for(var e=0,n=this.fields;e<n.length;e++)if(n[e].isPrefixOf(t))return!0;return!1},ii.prototype.isEqual=function(t){return Br(this.fields,t.fields,function(t,e){return t.isEqual(e)})},ii),ni=(ri.fromBase64String=function(t){return new ri(atob(t))},ri.fromUint8Array=function(t){return new ri(function(t){for(var e="",n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(t))},ri.prototype.toBase64=function(){return t=this.binaryString,btoa(t);var t},ri.prototype.toUint8Array=function(){return function(t){for(var e=new Uint8Array(t.length),n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.binaryString)},ri.prototype.approximateByteSize=function(){return 2*this.binaryString.length},ri.prototype.compareTo=function(t){return qr(this.binaryString,t.binaryString)},ri.prototype.isEqual=function(t){return this.binaryString===t.binaryString},ri);function ri(t){this.binaryString=t}function ii(t){(this.fields=t).sort(ti.comparator)}function oi(){return null!==Xr&&Xr.apply(this,arguments)||this}function si(){return null!==Jr&&Jr.apply(this,arguments)||this}function ai(t,e,n){void 0===e?e=0:e>t.length&&Mr(),void 0===n?n=t.length-e:n>t.length-e&&Mr(),this.segments=t,this.offset=e,this.len=n}ni.EMPTY_BYTE_STRING=new ni("");var ui=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ci(t){if(Fr(!!t),"string"!=typeof t)return{seconds:hi(t.seconds),nanos:hi(t.nanos)};var e=0,n=ui.exec(t);Fr(!!n),n[1]&&(n=((n=n[1])+"000000000").substr(0,9),e=Number(n));t=new Date(t);return{seconds:Math.floor(t.getTime()/1e3),nanos:e}}function hi(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function li(t){return"string"==typeof t?ni.fromBase64String(t):ni.fromUint8Array(t)}function fi(t){return"server_timestamp"===(null===(t=((null===(t=null==t?void 0:t.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===t?void 0:t.stringValue)}function di(t){t=ci(t.mapValue.fields.__local_write_time__.timestampValue);return new Kr(t.seconds,t.nanos)}function pi(t){return null==t}function yi(t){return 0===t&&1/t==-1/0}function gi(t){return"number"==typeof t&&Number.isInteger(t)&&!yi(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}var mi=(vi.fromPath=function(t){return new vi($r.fromString(t))},vi.fromName=function(t){return new vi($r.fromString(t).popFirst(5))},vi.prototype.hasCollectionId=function(t){return 2<=this.path.length&&this.path.get(this.path.length-2)===t},vi.prototype.isEqual=function(t){return null!==t&&0===$r.comparator(this.path,t.path)},vi.prototype.toString=function(){return this.path.toString()},vi.comparator=function(t,e){return $r.comparator(t.path,e.path)},vi.isDocumentKey=function(t){return t.length%2==0},vi.fromSegments=function(t){return new vi(new $r(t.slice()))},vi);function vi(t){this.path=t}function bi(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?fi(t)?4:10:Mr()}function wi(r,i){var t,e,n=bi(r);if(n!==bi(i))return!1;switch(n){case 0:return!0;case 1:return r.booleanValue===i.booleanValue;case 4:return di(r).isEqual(di(i));case 3:return function(t){if("string"==typeof r.timestampValue&&"string"==typeof t.timestampValue&&r.timestampValue.length===t.timestampValue.length)return r.timestampValue===t.timestampValue;var e=ci(r.timestampValue),t=ci(t.timestampValue);return e.seconds===t.seconds&&e.nanos===t.nanos}(i);case 5:return r.stringValue===i.stringValue;case 6:return e=i,li(r.bytesValue).isEqual(li(e.bytesValue));case 7:return r.referenceValue===i.referenceValue;case 8:return t=i,hi((e=r).geoPointValue.latitude)===hi(t.geoPointValue.latitude)&&hi(e.geoPointValue.longitude)===hi(t.geoPointValue.longitude);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return hi(t.integerValue)===hi(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){t=hi(t.doubleValue),e=hi(e.doubleValue);return t===e?yi(t)===yi(e):isNaN(t)&&isNaN(e)}return!1}(r,i);case 9:return Br(r.arrayValue.values||[],i.arrayValue.values||[],wi);case 10:return function(){var t,e=r.mapValue.fields||{},n=i.mapValue.fields||{};if(Hr(e)!==Hr(n))return!1;for(t in e)if(e.hasOwnProperty(t)&&(void 0===n[t]||!wi(e[t],n[t])))return!1;return!0}();default:return Mr()}}function Ii(t,e){return void 0!==(t.values||[]).find(function(t){return wi(t,e)})}function Ei(t,e){var n,r,i,o=bi(t),s=bi(e);if(o!==s)return qr(o,s);switch(o){case 0:return 0;case 1:return qr(t.booleanValue,e.booleanValue);case 2:return r=e,i=hi(t.integerValue||t.doubleValue),r=hi(r.integerValue||r.doubleValue),i<r?-1:r<i?1:i===r?0:isNaN(i)?isNaN(r)?0:-1:1;case 3:return Ti(t.timestampValue,e.timestampValue);case 4:return Ti(di(t),di(e));case 5:return qr(t.stringValue,e.stringValue);case 6:return function(t,e){t=li(t),e=li(e);return t.compareTo(e)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){for(var n=t.split("/"),r=e.split("/"),i=0;i<n.length&&i<r.length;i++){var o=qr(n[i],r[i]);if(0!==o)return o}return qr(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return n=t.geoPointValue,i=e.geoPointValue,0!==(r=qr(hi(n.latitude),hi(i.latitude)))?r:qr(hi(n.longitude),hi(i.longitude));case 9:return function(t,e){for(var n=t.values||[],r=e.values||[],i=0;i<n.length&&i<r.length;++i){var o=Ei(n[i],r[i]);if(o)return o}return qr(n.length,r.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){var n=t.fields||{},r=Object.keys(n),i=e.fields||{},o=Object.keys(i);r.sort(),o.sort();for(var s=0;s<r.length&&s<o.length;++s){var a=qr(r[s],o[s]);if(0!==a)return a;a=Ei(n[r[s]],i[o[s]]);if(0!==a)return a}return qr(r.length,o.length)}(t.mapValue,e.mapValue);default:throw Mr()}}function Ti(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return qr(t,e);var n=ci(t),t=ci(e),e=qr(n.seconds,t.seconds);return 0!==e?e:qr(n.nanos,t.nanos)}function _i(t){return function s(t){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){var t=ci(t);return"time("+t.seconds+","+t.nanos+")"}(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?li(t.bytesValue).toBase64():"referenceValue"in t?(e=t.referenceValue,mi.fromName(e).toString()):"geoPointValue"in t?"geo("+(e=t.geoPointValue).latitude+","+e.longitude+")":"arrayValue"in t?function(t){for(var e="[",n=!0,r=0,i=t.values||[];r<i.length;r++)n?n=!1:e+=",",e+=s(i[r]);return e+"]"}(t.arrayValue):"mapValue"in t?function(t){for(var e="{",n=!0,r=0,i=Object.keys(t.fields||{}).sort();r<i.length;r++){var o=i[r];n?n=!1:e+=",",e+=o+":"+s(t.fields[o])}return e+"}"}(t.mapValue):Mr();var e}(t)}function Si(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.canonicalString()}}function Ni(t){return t&&"integerValue"in t}function Di(t){return!!t&&"arrayValue"in t}function Ai(t){return t&&"nullValue"in t}function ki(t){return t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function Ci(t){return t&&"mapValue"in t}var Ri=(xi.empty=function(){return new xi({mapValue:{}})},xi.prototype.field=function(t){return xi.extractNestedValue(this.buildProto(),t)},xi.prototype.toProto=function(){return this.field(ti.emptyPath())},xi.prototype.set=function(t,e){this.setOverlay(t,e)},xi.prototype.setAll=function(t){var n=this;t.forEach(function(t,e){t?n.set(e,t):n.delete(e)})},xi.prototype.delete=function(t){this.setOverlay(t,null)},xi.prototype.isEqual=function(t){return wi(this.buildProto(),t.buildProto())},xi.prototype.setOverlay=function(t,e){for(var n=this.overlayMap,r=0;r<t.length-1;++r)var i=t.get(r),o=n.get(i),n=(o instanceof Map||(o=o&&10===bi(o)?new Map(Object.entries(o.mapValue.fields||{})):new Map,n.set(i,o)),o);n.set(t.lastSegment(),e)},xi.prototype.applyOverlay=function(r,t){var i=this,o=!1,e=xi.extractNestedValue(this.partialValue,r),s=Ci(e)?Object.assign({},e.mapValue.fields):{};return t.forEach(function(t,e){var n;t instanceof Map?null!=(n=i.applyOverlay(r.child(e),t))&&(s[e]=n,o=!0):null!==t?(s[e]=t,o=!0):s.hasOwnProperty(e)&&(delete s[e],o=!0)}),o?{mapValue:{fields:s}}:null},xi.prototype.buildProto=function(){var t=this.applyOverlay(ti.emptyPath(),this.overlayMap);return null!=t&&(this.partialValue=t,this.overlayMap.clear()),this.partialValue},xi.extractNestedValue=function(t,e){if(e.isEmpty())return t;for(var n=t,r=0;r<e.length-1;++r){if(!n.mapValue.fields)return null;if(!Ci(n=n.mapValue.fields[e.get(r)]))return null}return(n=(n.mapValue.fields||{})[e.lastSegment()])||null},xi.prototype.clone=function(){return new xi(this.buildProto())},xi);function xi(t){this.overlayMap=new Map,this.partialValue=t}var Oi=(Pi.newInvalidDocument=function(t){return new Pi(t,0,Gr.min(),Ri.empty(),0)},Pi.newFoundDocument=function(t,e,n){return new Pi(t,1,e,n,0)},Pi.newNoDocument=function(t,e){return new Pi(t,2,e,Ri.empty(),0)},Pi.newUnknownDocument=function(t,e){return new Pi(t,3,e,Ri.empty(),2)},Pi.prototype.convertToFoundDocument=function(t,e){return this.version=t,this.documentType=1,this.data=e,this.documentState=0,this},Pi.prototype.convertToNoDocument=function(t){return this.version=t,this.documentType=2,this.data=Ri.empty(),this.documentState=0,this},Pi.prototype.convertToUnknownDocument=function(t){return this.version=t,this.documentType=3,this.data=Ri.empty(),this.documentState=2,this},Pi.prototype.setHasCommittedMutations=function(){return this.documentState=2,this},Pi.prototype.setHasLocalMutations=function(){return this.documentState=1,this},Object.defineProperty(Pi.prototype,"hasLocalMutations",{get:function(){return 1===this.documentState},enumerable:!1,configurable:!0}),Object.defineProperty(Pi.prototype,"hasCommittedMutations",{get:function(){return 2===this.documentState},enumerable:!1,configurable:!0}),Object.defineProperty(Pi.prototype,"hasPendingWrites",{get:function(){return this.hasLocalMutations||this.hasCommittedMutations},enumerable:!1,configurable:!0}),Pi.prototype.isValidDocument=function(){return 0!==this.documentType},Pi.prototype.isFoundDocument=function(){return 1===this.documentType},Pi.prototype.isNoDocument=function(){return 2===this.documentType},Pi.prototype.isUnknownDocument=function(){return 3===this.documentType},Pi.prototype.isEqual=function(t){return t instanceof Pi&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)},Pi.prototype.clone=function(){return new Pi(this.key,this.documentType,this.version,this.data.clone(),this.documentState)},Pi.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+JSON.stringify(this.data.toProto())+", {documentType: "+this.documentType+"}), {documentState: "+this.documentState+"})"},Pi),Li=function(t,e,n,r,i,o,s){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=s,this.h=null};function Pi(t,e,n,r,i){this.key=t,this.documentType=e,this.version=n,this.data=r,this.documentState=i}function Mi(t,e,n,r,i,o,s){return new Li(t,e=void 0===e?null:e,n=void 0===n?[]:n,r=void 0===r?[]:r,i=void 0===i?null:i,o=void 0===o?null:o,s=void 0===s?null:s)}function Fi(t){var e=t;return null===e.h&&(t=e.path.canonicalString(),null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(function(t){return(t=t).field.canonicalString()+t.op.toString()+_i(t.value)}).join(","),t+="|ob:",t+=e.orderBy.map(function(t){return(t=t).field.canonicalString()+t.dir}).join(","),pi(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=fo(e.startAt)),e.endAt&&(t+="|ub:",t+=fo(e.endAt)),e.h=t),e.h}function Vi(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(var n,r,i=0;i<t.orderBy.length;i++)if(n=t.orderBy[i],r=e.orderBy[i],n.dir!==r.dir||!n.field.isEqual(r.field))return!1;if(t.filters.length!==e.filters.length)return!1;for(var o,s,a=0;a<t.filters.length;a++)if(o=t.filters[a],s=e.filters[a],o.op!==s.op||!o.field.isEqual(s.field)||!wi(o.value,s.value))return!1;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!go(t.startAt,e.startAt)&&go(t.endAt,e.endAt)}function Ui(t){return mi.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}var qi,Bi=(n(ji,qi=function(){}),ji.create=function(t,e,n){return t.isKeyField()?"in"===e||"not-in"===e?this.l(t,e,n):new zi(t,e,n):"array-contains"===e?new ro(t,n):"in"===e?new io(t,n):"not-in"===e?new oo(t,n):"array-contains-any"===e?new so(t,n):new ji(t,e,n)},ji.l=function(t,e,n){return new("in"===e?Hi:Wi)(t,n)},ji.prototype.matches=function(t){t=t.data.field(this.field);return"!="===this.op?null!==t&&this.m(Ei(t,this.value)):null!==t&&bi(this.value)===bi(t)&&this.m(Ei(t,this.value))},ji.prototype.m=function(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return 0<t;case">=":return 0<=t;default:return Mr()}},ji.prototype.g=function(){return 0<=["<","<=",">",">=","!=","not-in"].indexOf(this.op)},ji);function ji(t,e,n){var r=this;return(r=qi.call(this)||this).field=t,r.op=e,r.value=n,r}var Ki,Gi,Qi,zi=(n(Ji,Qi=Bi),Ji.prototype.matches=function(t){t=mi.comparator(t.key,this.key);return this.m(t)},Ji),Hi=(n(Xi,Gi=Bi),Xi.prototype.matches=function(e){return this.keys.some(function(t){return t.isEqual(e.key)})},Xi),Wi=(n(Yi,Ki=Bi),Yi.prototype.matches=function(e){return!this.keys.some(function(t){return t.isEqual(e.key)})},Yi);function Yi(t,e){var n=this;return(n=Ki.call(this,t,"not-in",e)||this).keys=$i(0,e),n}function Xi(t,e){var n=this;return(n=Gi.call(this,t,"in",e)||this).keys=$i(0,e),n}function Ji(t,e,n){var r=this;return(r=Qi.call(this,t,e,n)||this).key=mi.fromName(n.referenceValue),r}function $i(t,e){return((null===(e=e.arrayValue)||void 0===e?void 0:e.values)||[]).map(function(t){return mi.fromName(t.referenceValue)})}var Zi,to,eo,no,ro=(n(lo,no=Bi),lo.prototype.matches=function(t){t=t.data.field(this.field);return Di(t)&&Ii(t.arrayValue,this.value)},lo),io=(n(ho,eo=Bi),ho.prototype.matches=function(t){t=t.data.field(this.field);return null!==t&&Ii(this.value.arrayValue,t)},ho),oo=(n(co,to=Bi),co.prototype.matches=function(t){if(Ii(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;t=t.data.field(this.field);return null!==t&&!Ii(this.value.arrayValue,t)},co),so=(n(uo,Zi=Bi),uo.prototype.matches=function(t){var e=this,t=t.data.field(this.field);return!(!Di(t)||!t.arrayValue.values)&&t.arrayValue.values.some(function(t){return Ii(e.value.arrayValue,t)})},uo),ao=function(t,e){this.position=t,this.before=e};function uo(t,e){return Zi.call(this,t,"array-contains-any",e)||this}function co(t,e){return to.call(this,t,"not-in",e)||this}function ho(t,e){return eo.call(this,t,"in",e)||this}function lo(t,e){return no.call(this,t,"array-contains",e)||this}function fo(t){return(t.before?"b":"a")+":"+t.position.map(_i).join(",")}var po=function(t,e){void 0===e&&(e="asc"),this.field=t,this.dir=e};function yo(t,e,n){for(var r=0,i=0;i<t.position.length;i++){var o=e[i],s=t.position[i],r=o.field.isKeyField()?mi.comparator(mi.fromName(s.referenceValue),n.key):Ei(s,n.data.field(o.field));if("desc"===o.dir&&(r*=-1),0!==r)break}return t.before?r<=0:r<0}function go(t,e){if(null===t)return null===e;if(null===e)return!1;if(t.before!==e.before||t.position.length!==e.position.length)return!1;for(var n=0;n<t.position.length;n++)if(!wi(t.position[n],e.position[n]))return!1;return!0}var mo=function(t,e,n,r,i,o,s,a){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o="F"),void 0===s&&(s=null),void 0===a&&(a=null),this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=o,this.startAt=s,this.endAt=a,this.p=null,this.T=null,this.startAt,this.endAt};function vo(t,e,n,r,i,o,s,a){return new mo(t,e,n,r,i,o,s,a)}function bo(t){return new mo(t)}function wo(t){return!pi(t.limit)&&"F"===t.limitType}function Io(t){return!pi(t.limit)&&"L"===t.limitType}function Eo(t){return 0<t.explicitOrderBy.length?t.explicitOrderBy[0].field:null}function To(t){for(var e=0,n=t.filters;e<n.length;e++){var r=n[e];if(r.g())return r.field}return null}function _o(t){return null!==t.collectionGroup}function So(t){var e=t;if(null===e.p){e.p=[];var n=To(e),t=Eo(e);if(null!==n&&null===t)n.isKeyField()||e.p.push(new po(n)),e.p.push(new po(ti.keyField(),"asc"));else{for(var r=!1,i=0,o=e.explicitOrderBy;i<o.length;i++){var s=o[i];e.p.push(s),s.field.isKeyField()&&(r=!0)}r||(n=0<e.explicitOrderBy.length?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc",e.p.push(new po(ti.keyField(),n)))}}return e.p}function No(t){var e=t;if(!e.T)if("F"===e.limitType)e.T=Mi(e.path,e.collectionGroup,So(e),e.filters,e.limit,e.startAt,e.endAt);else{for(var n=[],r=0,i=So(e);r<i.length;r++){var o=i[r],s="desc"===o.dir?"asc":"desc";n.push(new po(o.field,s))}var a=e.endAt?new ao(e.endAt.position,!e.endAt.before):null,t=e.startAt?new ao(e.startAt.position,!e.startAt.before):null;e.T=Mi(e.path,e.collectionGroup,n,e.filters,e.limit,a,t)}return e.T}function Do(t,e,n){return new mo(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Ao(t,e){return Vi(No(t),No(e))&&t.limitType===e.limitType}function ko(t){return Fi(No(t))+"|lt:"+t.limitType}function Co(t){return"Query(target="+(e=No(t),n=e.path.canonicalString(),null!==e.collectionGroup&&(n+=" collectionGroup="+e.collectionGroup),0<e.filters.length&&(n+=", filters: ["+e.filters.map(function(t){return(t=t).field.canonicalString()+" "+t.op+" "+_i(t.value)}).join(", ")+"]"),pi(e.limit)||(n+=", limit: "+e.limit),0<e.orderBy.length&&(n+=", orderBy: ["+e.orderBy.map(function(t){return(t=t).field.canonicalString()+" ("+t.dir+")"}).join(", ")+"]"),e.startAt&&(n+=", startAt: "+fo(e.startAt)),e.endAt&&(n+=", endAt: "+fo(e.endAt)),"Target("+n+")")+"; limitType="+t.limitType+")";var e,n}function Ro(i,t){return t.isFoundDocument()&&(e=i,n=t.key.path,null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n):mi.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n))&&function(t){for(var e=0,n=i.explicitOrderBy;e<n.length;e++){var r=n[e];if(!r.field.isKeyField()&&null===t.data.field(r.field))return}return 1}(t)&&function(t){for(var e=0,n=i.filters;e<n.length;e++)if(!n[e].matches(t))return;return 1}(t)&&(n=t,(!(t=i).startAt||yo(t.startAt,So(t),n))&&(!t.endAt||!yo(t.endAt,So(t),n)));var e,n}function xo(a){return function(t,e){for(var n=!1,r=0,i=So(a);r<i.length;r++){var o=i[r],s=function(t,r,e){var n=t.field.isKeyField()?mi.comparator(r.key,e.key):function(t,e){var n=r.data.field(t),t=e.data.field(t);return null!==n&&null!==t?Ei(n,t):Mr()}(t.field,e);switch(t.dir){case"asc":return n;case"desc":return-1*n;default:return Mr()}}(o,t,e);if(0!==s)return s;n=n||o.field.isKeyField()}return 0}}function Oo(t,e){if(t.I){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:yi(e)?"-0":e}}function Lo(t){return{integerValue:""+t}}function Po(t,e){return gi(e)?Lo(e):Oo(t,e)}I=function(){this._=void 0};function Mo(t,e){return t instanceof Yo?Ni(t=e)||t&&"doubleValue"in t?e:{integerValue:0}:null}var Fo,Vo,Uo=(n(jo,Vo=I),jo),qo=(n(Bo,Fo=I),Bo);function Bo(t){var e=this;return(e=Fo.call(this)||this).elements=t,e}function jo(){return null!==Vo&&Vo.apply(this,arguments)||this}function Ko(t,e){for(var n=$o(e),r=0,i=t.elements;r<i.length;r++)!function(e){n.some(function(t){return wi(t,e)})||n.push(e)}(i[r]);return{arrayValue:{values:n}}}var Go,Qo=(n(zo,Go=I),zo);function zo(t){var e=this;return(e=Go.call(this)||this).elements=t,e}function Ho(t,e){for(var n=$o(e),r=0,i=t.elements;r<i.length;r++)!function(e){n=n.filter(function(t){return!wi(t,e)})}(i[r]);return{arrayValue:{values:n}}}var Wo,Yo=(n(Xo,Wo=I),Xo);function Xo(t,e){var n=this;return(n=Wo.call(this)||this).R=t,n.A=e,n}function Jo(t){return hi(t.integerValue||t.doubleValue)}function $o(t){return Di(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}function Zo(t,e){this.version=t,this.transformResults=e}var ts=function(t,e){this.field=t,this.transform=e},es=(ns.none=function(){return new ns},ns.exists=function(t){return new ns(void 0,t)},ns.updateTime=function(t){return new ns(t)},Object.defineProperty(ns.prototype,"isNone",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!1,configurable:!0}),ns.prototype.isEqual=function(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)},ns);function ns(t,e){this.updateTime=t,this.exists=e}function rs(t,e){return void 0!==t.updateTime?e.isFoundDocument()&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e.isFoundDocument()}Te=function(){};function is(t,e,n){var r,i,o,s;t instanceof cs?(i=e,o=n,rs((r=t).precondition,i)&&(s=r.value.clone(),o=ys(r.fieldTransforms,o,i),s.setAll(o),i.convertToFoundDocument(ss(i),s).setHasLocalMutations())):t instanceof hs?(o=e,i=n,rs((s=t).precondition,o)&&(n=ys(s.fieldTransforms,i,o),(i=o.data).setAll(ds(s)),i.setAll(n),o.convertToFoundDocument(ss(o),i).setHasLocalMutations())):(e=e,rs(t.precondition,e)&&e.convertToNoDocument(Gr.min()))}function os(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&(n=t.fieldTransforms,r=e.fieldTransforms,!!(void 0===n&&void 0===r||n&&r&&Br(n,r,function(t,e){return e=e,(t=t).field.isEqual(e.field)&&(t=t.transform,e=e.transform,t instanceof qo&&e instanceof qo||t instanceof Qo&&e instanceof Qo?Br(t.elements,e.elements,wi):t instanceof Yo&&e instanceof Yo?wi(t.A,e.A):t instanceof Uo&&e instanceof Uo)})))&&(0===t.type?t.value.isEqual(e.value):1!==t.type||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask));var n,r}function ss(t){return t.isFoundDocument()?t.version:Gr.min()}var as,us,cs=(n(fs,us=Te),fs),hs=(n(ls,as=Te),ls);function ls(t,e,n,r,i){void 0===i&&(i=[]);var o=this;return(o=as.call(this)||this).key=t,o.data=e,o.fieldMask=n,o.precondition=r,o.fieldTransforms=i,o.type=1,o}function fs(t,e,n,r){void 0===r&&(r=[]);var i=this;return(i=us.call(this)||this).key=t,i.value=e,i.precondition=n,i.fieldTransforms=r,i.type=0,i}function ds(n){var r=new Map;return n.fieldMask.fields.forEach(function(t){var e;t.isEmpty()||(e=n.data.field(t),r.set(t,e))}),r}function ps(t,e,n){var r=new Map;Fr(t.length===n.length);for(var i=0;i<n.length;i++){var o=t[i],s=o.transform,a=e.data.field(o.field);r.set(o.field,(o=s,s=a,a=n[i],o instanceof qo?Ko(o,s):o instanceof Qo?Ho(o,s):a))}return r}function ys(t,e,n){for(var r,i=new Map,o=0,s=t;o<s.length;o++){var a=s[o],u=a.transform,c=n.data.field(a.field);i.set(a.field,(r=c,a=e,c=void 0,(u=u)instanceof Uo?(c={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:a.seconds,nanos:a.nanoseconds}}}},r&&(c.fields.__previous_value__=r),{mapValue:c}):u instanceof qo?Ko(u,r):u instanceof Qo?Ho(u,r):(u=Mo(c=u,r),r=Jo(u)+Jo(c.A),Ni(u)&&Ni(c.A)?Lo(r):Oo(c.R,r))))}return i}function gs(t){this.count=t}var ms,vs,bs,ws=(n(Ts,bs=Te),Ts),Is=(n(Es,vs=Te),Es);function Es(t,e){var n=this;return(n=vs.call(this)||this).key=t,n.precondition=e,n.type=3,n.fieldTransforms=[],n}function Ts(t,e){var n=this;return(n=bs.call(this)||this).key=t,n.precondition=e,n.type=2,n.fieldTransforms=[],n}function _s(t){switch(t){case Dr.OK:return Mr(),0;case Dr.CANCELLED:case Dr.UNKNOWN:case Dr.DEADLINE_EXCEEDED:case Dr.RESOURCE_EXHAUSTED:case Dr.INTERNAL:case Dr.UNAVAILABLE:case Dr.UNAUTHENTICATED:return;case Dr.INVALID_ARGUMENT:case Dr.NOT_FOUND:case Dr.ALREADY_EXISTS:case Dr.PERMISSION_DENIED:case Dr.FAILED_PRECONDITION:case Dr.ABORTED:case Dr.OUT_OF_RANGE:case Dr.UNIMPLEMENTED:case Dr.DATA_LOSS:return 1;default:return Mr(),0}}function Ss(t){if(void 0===t)return Or("GRPC error has no .code"),Dr.UNKNOWN;switch(t){case ms.OK:return Dr.OK;case ms.CANCELLED:return Dr.CANCELLED;case ms.UNKNOWN:return Dr.UNKNOWN;case ms.DEADLINE_EXCEEDED:return Dr.DEADLINE_EXCEEDED;case ms.RESOURCE_EXHAUSTED:return Dr.RESOURCE_EXHAUSTED;case ms.INTERNAL:return Dr.INTERNAL;case ms.UNAVAILABLE:return Dr.UNAVAILABLE;case ms.UNAUTHENTICATED:return Dr.UNAUTHENTICATED;case ms.INVALID_ARGUMENT:return Dr.INVALID_ARGUMENT;case ms.NOT_FOUND:return Dr.NOT_FOUND;case ms.ALREADY_EXISTS:return Dr.ALREADY_EXISTS;case ms.PERMISSION_DENIED:return Dr.PERMISSION_DENIED;case ms.FAILED_PRECONDITION:return Dr.FAILED_PRECONDITION;case ms.ABORTED:return Dr.ABORTED;case ms.OUT_OF_RANGE:return Dr.OUT_OF_RANGE;case ms.UNIMPLEMENTED:return Dr.UNIMPLEMENTED;case ms.DATA_LOSS:return Dr.DATA_LOSS;default:return Mr()}}(I=ms=ms||{})[I.OK=0]="OK",I[I.CANCELLED=1]="CANCELLED",I[I.UNKNOWN=2]="UNKNOWN",I[I.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",I[I.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",I[I.NOT_FOUND=5]="NOT_FOUND",I[I.ALREADY_EXISTS=6]="ALREADY_EXISTS",I[I.PERMISSION_DENIED=7]="PERMISSION_DENIED",I[I.UNAUTHENTICATED=16]="UNAUTHENTICATED",I[I.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",I[I.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",I[I.ABORTED=10]="ABORTED",I[I.OUT_OF_RANGE=11]="OUT_OF_RANGE",I[I.UNIMPLEMENTED=12]="UNIMPLEMENTED",I[I.INTERNAL=13]="INTERNAL",I[I.UNAVAILABLE=14]="UNAVAILABLE",I[I.DATA_LOSS=15]="DATA_LOSS";var Ns=(Rs.prototype.insert=function(t,e){return new Rs(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,As.BLACK,null,null))},Rs.prototype.remove=function(t){return new Rs(this.comparator,this.root.remove(t,this.comparator).copy(null,null,As.BLACK,null,null))},Rs.prototype.get=function(t){for(var e=this.root;!e.isEmpty();){var n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:0<n&&(e=e.right)}return null},Rs.prototype.indexOf=function(t){for(var e=0,n=this.root;!n.isEmpty();){var r=this.comparator(t,n.key);if(0===r)return e+n.left.size;n=r<0?n.left:(e+=n.left.size+1,n.right)}return-1},Rs.prototype.isEmpty=function(){return this.root.isEmpty()},Object.defineProperty(Rs.prototype,"size",{get:function(){return this.root.size},enumerable:!1,configurable:!0}),Rs.prototype.minKey=function(){return this.root.minKey()},Rs.prototype.maxKey=function(){return this.root.maxKey()},Rs.prototype.inorderTraversal=function(t){return this.root.inorderTraversal(t)},Rs.prototype.forEach=function(n){this.inorderTraversal(function(t,e){return n(t,e),!1})},Rs.prototype.toString=function(){var n=[];return this.inorderTraversal(function(t,e){return n.push(t+":"+e),!1}),"{"+n.join(", ")+"}"},Rs.prototype.reverseTraversal=function(t){return this.root.reverseTraversal(t)},Rs.prototype.getIterator=function(){return new Ds(this.root,null,this.comparator,!1)},Rs.prototype.getIteratorFrom=function(t){return new Ds(this.root,t,this.comparator,!1)},Rs.prototype.getReverseIterator=function(){return new Ds(this.root,null,this.comparator,!0)},Rs.prototype.getReverseIteratorFrom=function(t){return new Ds(this.root,t,this.comparator,!0)},Rs),Ds=(Cs.prototype.getNext=function(){var t=this.nodeStack.pop(),e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e},Cs.prototype.hasNext=function(){return 0<this.nodeStack.length},Cs.prototype.peek=function(){if(0===this.nodeStack.length)return null;var t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}},Cs),As=(ks.prototype.copy=function(t,e,n,r,i){return new ks(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)},ks.prototype.isEmpty=function(){return!1},ks.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},ks.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},ks.prototype.min=function(){return this.left.isEmpty()?this:this.left.min()},ks.prototype.minKey=function(){return this.min().key},ks.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},ks.prototype.insert=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n))).fixUp()},ks.prototype.removeMin=function(){if(this.left.isEmpty())return ks.EMPTY;var t=this;return(t=(t=!t.left.isRed()&&!t.left.left.isRed()?t.moveRedLeft():t).copy(null,null,null,t.left.removeMin(),null)).fixUp()},ks.prototype.remove=function(t,e){var n,r=this;if(e(t,r.key)<0)r=(r=!(r.left.isEmpty()||r.left.isRed()||r.left.left.isRed())?r.moveRedLeft():r).copy(null,null,null,r.left.remove(t,e),null);else{if(0===e(t,(r=!((r=r.left.isRed()?r.rotateRight():r).right.isEmpty()||r.right.isRed()||r.right.left.isRed())?r.moveRedRight():r).key)){if(r.right.isEmpty())return ks.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(t,e))}return r.fixUp()},ks.prototype.isRed=function(){return this.color},ks.prototype.fixUp=function(){var t=this;return t=(t=(t=t.right.isRed()&&!t.left.isRed()?t.rotateLeft():t).left.isRed()&&t.left.left.isRed()?t.rotateRight():t).left.isRed()&&t.right.isRed()?t.colorFlip():t},ks.prototype.moveRedLeft=function(){var t=this.colorFlip();return t=t.right.left.isRed()?(t=(t=t.copy(null,null,null,null,t.right.rotateRight())).rotateLeft()).colorFlip():t},ks.prototype.moveRedRight=function(){var t=this.colorFlip();return t=t.left.left.isRed()?(t=t.rotateRight()).colorFlip():t},ks.prototype.rotateLeft=function(){var t=this.copy(null,null,ks.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},ks.prototype.rotateRight=function(){var t=this.copy(null,null,ks.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},ks.prototype.colorFlip=function(){var t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)},ks.prototype.checkMaxDepth=function(){var t=this.check();return Math.pow(2,t)<=this.size+1},ks.prototype.check=function(){if(this.isRed()&&this.left.isRed())throw Mr();if(this.right.isRed())throw Mr();var t=this.left.check();if(t!==this.right.check())throw Mr();return t+(this.isRed()?0:1)},ks);function ks(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:ks.RED,this.left=null!=r?r:ks.EMPTY,this.right=null!=i?i:ks.EMPTY,this.size=this.left.size+1+this.right.size}function Cs(t,e,n,r){this.isReverse=r,this.nodeStack=[];for(var i=1;!t.isEmpty();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.isReverse?t.left:t.right;else{if(0===i){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}function Rs(t,e){this.comparator=t,this.root=e||As.EMPTY}function xs(){this.size=0}As.EMPTY=null,As.RED=!0,As.BLACK=!1,As.EMPTY=(Object.defineProperty(xs.prototype,"key",{get:function(){throw Mr()},enumerable:!1,configurable:!0}),Object.defineProperty(xs.prototype,"value",{get:function(){throw Mr()},enumerable:!1,configurable:!0}),Object.defineProperty(xs.prototype,"color",{get:function(){throw Mr()},enumerable:!1,configurable:!0}),Object.defineProperty(xs.prototype,"left",{get:function(){throw Mr()},enumerable:!1,configurable:!0}),Object.defineProperty(xs.prototype,"right",{get:function(){throw Mr()},enumerable:!1,configurable:!0}),xs.prototype.copy=function(t,e,n,r,i){return this},xs.prototype.insert=function(t,e,n){return new As(t,e)},xs.prototype.remove=function(t,e){return this},xs.prototype.isEmpty=function(){return!0},xs.prototype.inorderTraversal=function(t){return!1},xs.prototype.reverseTraversal=function(t){return!1},xs.prototype.minKey=function(){return null},xs.prototype.maxKey=function(){return null},xs.prototype.isRed=function(){return!1},xs.prototype.checkMaxDepth=function(){return!0},xs.prototype.check=function(){return 0},new xs);var Os=(Fs.prototype.has=function(t){return null!==this.data.get(t)},Fs.prototype.first=function(){return this.data.minKey()},Fs.prototype.last=function(){return this.data.maxKey()},Object.defineProperty(Fs.prototype,"size",{get:function(){return this.data.size},enumerable:!1,configurable:!0}),Fs.prototype.indexOf=function(t){return this.data.indexOf(t)},Fs.prototype.forEach=function(n){this.data.inorderTraversal(function(t,e){return n(t),!1})},Fs.prototype.forEachInRange=function(t,e){for(var n=this.data.getIteratorFrom(t[0]);n.hasNext();){var r=n.getNext();if(0<=this.comparator(r.key,t[1]))return;e(r.key)}},Fs.prototype.forEachWhile=function(t,e){for(var n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return},Fs.prototype.firstAfterOrEqual=function(t){t=this.data.getIteratorFrom(t);return t.hasNext()?t.getNext().key:null},Fs.prototype.getIterator=function(){return new Ls(this.data.getIterator())},Fs.prototype.getIteratorFrom=function(t){return new Ls(this.data.getIteratorFrom(t))},Fs.prototype.add=function(t){return this.copy(this.data.remove(t).insert(t,!0))},Fs.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},Fs.prototype.isEmpty=function(){return this.data.isEmpty()},Fs.prototype.unionWith=function(t){var e=this;return e.size<t.size&&(e=t,t=this),t.forEach(function(t){e=e.add(t)}),e},Fs.prototype.isEqual=function(t){if(!(t instanceof Fs))return!1;if(this.size!==t.size)return!1;for(var e=this.data.getIterator(),n=t.data.getIterator();e.hasNext();){var r=e.getNext().key,i=n.getNext().key;if(0!==this.comparator(r,i))return!1}return!0},Fs.prototype.toArray=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},Fs.prototype.toString=function(){var e=[];return this.forEach(function(t){return e.push(t)}),"SortedSet("+e.toString()+")"},Fs.prototype.copy=function(t){var e=new Fs(this.comparator);return e.data=t,e},Fs),Ls=(Ms.prototype.getNext=function(){return this.iter.getNext().key},Ms.prototype.hasNext=function(){return this.iter.hasNext()},Ms),Ps=new Ns(mi.comparator);function Ms(t){this.iter=t}function Fs(t){this.comparator=t,this.data=new Ns(this.comparator)}var Vs=new Ns(mi.comparator);var Us=new Ns(mi.comparator);var qs=new Os(mi.comparator);function Bs(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=qs,r=0,i=t;r<i.length;r++)var o=i[r],n=n.add(o);return n}var js=new Os(qr);var Ks=(Zs.createSynthesizedRemoteEventForCurrentChange=function(t,e){var n=new Map;return n.set(t,Gs.createSynthesizedTargetChangeForCurrentChange(t,e)),new Zs(Gr.min(),n,js,Ps,Bs())},Zs),Gs=($s.createSynthesizedTargetChangeForCurrentChange=function(t,e){return new $s(ni.EMPTY_BYTE_STRING,e,Bs(),Bs(),Bs())},$s),Qs=function(t,e,n,r){this.v=t,this.removedTargetIds=e,this.key=n,this.P=r},zs=function(t,e){this.targetId=t,this.V=e},Hs=function(t,e,n,r){void 0===n&&(n=ni.EMPTY_BYTE_STRING),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},Ws=(Object.defineProperty(Js.prototype,"current",{get:function(){return this.N},enumerable:!1,configurable:!0}),Object.defineProperty(Js.prototype,"resumeToken",{get:function(){return this.C},enumerable:!1,configurable:!0}),Object.defineProperty(Js.prototype,"k",{get:function(){return 0!==this.S},enumerable:!1,configurable:!0}),Object.defineProperty(Js.prototype,"O",{get:function(){return this.F},enumerable:!1,configurable:!0}),Js.prototype.$=function(t){0<t.approximateByteSize()&&(this.F=!0,this.C=t)},Js.prototype.M=function(){var n=Bs(),r=Bs(),i=Bs();return this.D.forEach(function(t,e){switch(e){case 0:n=n.add(t);break;case 2:r=r.add(t);break;case 1:i=i.add(t);break;default:Mr()}}),new Gs(this.C,this.N,n,r,i)},Js.prototype.L=function(){this.F=!1,this.D=ea()},Js.prototype.B=function(t,e){this.F=!0,this.D=this.D.insert(t,e)},Js.prototype.q=function(t){this.F=!0,this.D=this.D.remove(t)},Js.prototype.U=function(){this.S+=1},Js.prototype.K=function(){--this.S},Js.prototype.j=function(){this.F=!0,this.N=!0},Js),Ys=(Xs.prototype.X=function(t){for(var e=0,n=t.v;e<n.length;e++){var r=n[e];t.P&&t.P.isFoundDocument()?this.Z(r,t.P):this.tt(r,t.key,t.P)}for(var i=0,o=t.removedTargetIds;i<o.length;i++)r=o[i],this.tt(r,t.key,t.P)},Xs.prototype.et=function(n){var r=this;this.forEachTarget(n,function(t){var e=r.nt(t);switch(n.state){case 0:r.st(t)&&e.$(n.resumeToken);break;case 1:e.K(),e.k||e.L(),e.$(n.resumeToken);break;case 2:e.K(),e.k||r.removeTarget(t);break;case 3:r.st(t)&&(e.j(),e.$(n.resumeToken));break;case 4:r.st(t)&&(r.it(t),e.$(n.resumeToken));break;default:Mr()}})},Xs.prototype.forEachTarget=function(t,n){var r=this;0<t.targetIds.length?t.targetIds.forEach(n):this.G.forEach(function(t,e){r.st(e)&&n(e)})},Xs.prototype.rt=function(t){var e=t.targetId,n=t.V.count,t=this.ot(e);t&&(Ui(t=t.target)?0===n?(t=new mi(t.path),this.tt(e,t,Oi.newNoDocument(t,Gr.min()))):Fr(1===n):this.ct(e)!==n&&(this.it(e),this.Y=this.Y.add(e)))},Xs.prototype.ut=function(r){var i=this,o=new Map;this.G.forEach(function(t,e){var n=i.ot(e);n&&(t.current&&Ui(n.target)&&(n=new mi(n.target.path),null!==i.H.get(n)||i.at(e,n)||i.tt(e,n,Oi.newNoDocument(n,r))),t.O&&(o.set(e,t.M()),t.L()))});var s=Bs();this.J.forEach(function(t,e){var n=!0;e.forEachWhile(function(t){t=i.ot(t);return!t||2===t.purpose||(n=!1)}),n&&(s=s.add(t))});var t=new Ks(r,o,this.Y,this.H,s);return this.H=Ps,this.J=ta(),this.Y=new Os(qr),t},Xs.prototype.Z=function(t,e){var n;this.st(t)&&(n=this.at(t,e.key)?2:0,this.nt(t).B(e.key,n),this.H=this.H.insert(e.key,e),this.J=this.J.insert(e.key,this.ht(e.key).add(t)))},Xs.prototype.tt=function(t,e,n){var r;this.st(t)&&(r=this.nt(t),this.at(t,e)?r.B(e,1):r.q(e),this.J=this.J.insert(e,this.ht(e).delete(t)),n&&(this.H=this.H.insert(e,n)))},Xs.prototype.removeTarget=function(t){this.G.delete(t)},Xs.prototype.ct=function(t){var e=this.nt(t).M();return this.W.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size},Xs.prototype.U=function(t){this.nt(t).U()},Xs.prototype.nt=function(t){var e=this.G.get(t);return e||(e=new Ws,this.G.set(t,e)),e},Xs.prototype.ht=function(t){var e=this.J.get(t);return e||(e=new Os(qr),this.J=this.J.insert(t,e)),e},Xs.prototype.st=function(t){var e=null!==this.ot(t);return e||xr("WatchChangeAggregator","Detected inactive target",t),e},Xs.prototype.ot=function(t){var e=this.G.get(t);return e&&e.k?null:this.W.lt(t)},Xs.prototype.it=function(e){var n=this;this.G.set(e,new Ws),this.W.getRemoteKeysForTarget(e).forEach(function(t){n.tt(e,t,null)})},Xs.prototype.at=function(t,e){return this.W.getRemoteKeysForTarget(t).has(e)},Xs);function Xs(t){this.W=t,this.G=new Map,this.H=Ps,this.J=ta(),this.Y=new Os(qr)}function Js(){this.S=0,this.D=ea(),this.C=ni.EMPTY_BYTE_STRING,this.N=!1,this.F=!0}function $s(t,e,n,r,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}function Zs(t,e,n,r,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}function ta(){return new Ns(mi.comparator)}function ea(){return new Ns(mi.comparator)}var na={asc:"ASCENDING",desc:"DESCENDING"},ra={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},ia=function(t,e){this.databaseId=t,this.I=e};function oa(t,e){return t.I?new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+e.nanoseconds).slice(-9)+"Z":{seconds:""+e.seconds,nanos:e.nanoseconds}}function sa(t,e){return t.I?e.toBase64():e.toUint8Array()}function aa(t){return Fr(!!t),Gr.fromTimestamp((t=ci(t),new Kr(t.seconds,t.nanos)))}function ua(t,e){return new $r(["projects",t.projectId,"databases",t.database]).child("documents").child(e).canonicalString()}function ca(t){t=$r.fromString(t);return Fr(ka(t)),t}function ha(t,e){return ua(t.databaseId,e.path)}function la(t,e){e=ca(e);if(e.get(1)!==t.databaseId.projectId)throw new Ar(Dr.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+e.get(1)+" vs "+t.databaseId.projectId);if(e.get(3)!==t.databaseId.database)throw new Ar(Dr.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+e.get(3)+" vs "+t.databaseId.database);return new mi(ya(e))}function fa(t,e){return ua(t.databaseId,e)}function da(t){t=ca(t);return 4===t.length?$r.emptyPath():ya(t)}function pa(t){return new $r(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function ya(t){return Fr(4<t.length&&"documents"===t.get(4)),t.popFirst(5)}function ga(t,e,n){return{name:ha(t,e),fields:n.toProto().mapValue.fields}}function ma(t,e,n){var r=la(t,e.name),t=aa(e.updateTime),e=new Ri({mapValue:{fields:e.fields}}),e=Oi.newFoundDocument(r,t,e);return n&&e.setHasCommittedMutations(),n?e.setHasCommittedMutations():e}function va(t,e){var n,r,i;if(e instanceof cs)n={update:ga(t,e.key,e.value)};else if(e instanceof ws)n={delete:ha(t,e.key)};else if(e instanceof hs)n={update:ga(t,e.key,e.data),updateMask:(i=e.fieldMask,r=[],i.fields.forEach(function(t){return r.push(t.canonicalString())}),{fieldPaths:r})};else{if(!(e instanceof Is))return Mr();n={verify:ha(t,e.key)}}return 0<e.fieldTransforms.length&&(n.updateTransforms=e.fieldTransforms.map(function(t){var e=t.transform;if(e instanceof Uo)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(e instanceof qo)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:e.elements}};if(e instanceof Qo)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:e.elements}};if(e instanceof Yo)return{fieldPath:t.field.canonicalString(),increment:e.A};throw Mr()})),e.precondition.isNone||(n.currentDocument=void 0!==(i=e.precondition).updateTime?{updateTime:(e=t,t=i.updateTime,oa(e,t.toTimestamp()))}:void 0!==i.exists?{exists:i.exists}:Mr()),n}function ba(e,t){var n=t.currentDocument?void 0!==(s=t.currentDocument).updateTime?es.updateTime(aa(s.updateTime)):void 0!==s.exists?es.exists(s.exists):es.none():es.none(),r=t.updateTransforms?t.updateTransforms.map(function(t){return function(t,e){var n,r=null;"setToServerValue"in e?(Fr("REQUEST_TIME"===e.setToServerValue),r=new Uo):"appendMissingElements"in e?(n=e.appendMissingElements.values||[],r=new qo(n)):"removeAllFromArray"in e?(n=e.removeAllFromArray.values||[],r=new Qo(n)):"increment"in e?r=new Yo(t,e.increment):Mr();e=ti.fromServerFormat(e.fieldPath);return new ts(e,r)}(e,t)}):[];if(t.update){t.update.name;var i=la(e,t.update.name),o=new Ri({mapValue:{fields:t.update.fields}});if(t.updateMask){var s=(s=t.updateMask.fieldPaths||[],new ei(s.map(function(t){return ti.fromServerFormat(t)})));return new hs(i,o,s,n,r)}return new cs(i,o,n,r)}if(t.delete){r=la(e,t.delete);return new ws(r,n)}if(t.verify){t=la(e,t.verify);return new Is(t,n)}return Mr()}function wa(t,e){return{documents:[fa(t,e.path)]}}function Ia(t,e){var n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=fa(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=fa(t,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);r=function(t){if(0!==t.length){t=t.map(function(t){if("=="===t.op){if(ki(t.value))return{unaryFilter:{field:Sa(t.field),op:"IS_NAN"}};if(Ai(t.value))return{unaryFilter:{field:Sa(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(ki(t.value))return{unaryFilter:{field:Sa(t.field),op:"IS_NOT_NAN"}};if(Ai(t.value))return{unaryFilter:{field:Sa(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Sa(t.field),op:(e=t.op,ra[e]),value:t.value}};var e});return 1===t.length?t[0]:{compositeFilter:{op:"AND",filters:t}}}}(e.filters);r&&(n.structuredQuery.where=r);r=function(t){if(0!==t.length)return t.map(function(t){return{field:Sa((t=t).field),direction:(t=t.dir,na[t])}})}(e.orderBy);r&&(n.structuredQuery.orderBy=r);r=e.limit,r=t.I||pi(r)?r:{value:r};return null!==r&&(n.structuredQuery.limit=r),e.startAt&&(n.structuredQuery.startAt=Ta(e.startAt)),e.endAt&&(n.structuredQuery.endAt=Ta(e.endAt)),n}function Ea(t){var e=da(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;0<r&&(Fr(1===r),(a=n.from[0]).allDescendants?i=a.collectionId:e=e.child(a.collectionId));var o=[];n.where&&(o=function e(t){return t?void 0!==t.unaryFilter?[Aa(t)]:void 0!==t.fieldFilter?[Da(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map(function(t){return e(t)}).reduce(function(t,e){return t.concat(e)}):Mr():[]}(n.where));var s=[],t=null,r=null,a=null;return vo(e,i,s=n.orderBy?n.orderBy.map(function(t){return new po(Na((e=t).field),function(){switch(e.direction){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}());var e}):s,o,t=n.limit?pi(o="object"==typeof(o=n.limit)?o.value:o)?null:o:t,"F",r=n.startAt?_a(n.startAt):r,a=n.endAt?_a(n.endAt):a)}function Ta(t){return{before:t.before,values:t.position}}function _a(t){var e=!!t.before,t=t.values||[];return new ao(t,e)}function Sa(t){return{fieldPath:t.canonicalString()}}function Na(t){return ti.fromServerFormat(t.fieldPath)}function Da(t){return Bi.create(Na(t.fieldFilter.field),function(){switch(t.fieldFilter.op){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":default:return Mr()}}(),t.fieldFilter.value)}function Aa(t){switch(t.unaryFilter.op){case"IS_NAN":var e=Na(t.unaryFilter.field);return Bi.create(e,"==",{doubleValue:NaN});case"IS_NULL":e=Na(t.unaryFilter.field);return Bi.create(e,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var n=Na(t.unaryFilter.field);return Bi.create(n,"!=",{doubleValue:NaN});case"IS_NOT_NULL":n=Na(t.unaryFilter.field);return Bi.create(n,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":default:return Mr()}}function ka(t){return 4<=t.length&&"projects"===t.get(0)&&"databases"===t.get(2)}function Ca(t){for(var e="",n=0;n<t.length;n++)0<e.length&&(e=Ra(e)),e=function(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+="\x01\x10";break;case"\x01":n+="\x01\x11";break;default:n+=o}}return n}(t.get(n),e);return Ra(e)}function Ra(t){return t+"\x01\x01"}function xa(t){var e=t.length;if(Fr(2<=e),2===e)return Fr("\x01"===t.charAt(0)&&"\x01"===t.charAt(1)),$r.emptyPath();for(var n=e-2,r=[],i="",o=0;o<e;){var s=t.indexOf("\x01",o);switch((s<0||n<s)&&Mr(),t.charAt(s+1)){case"\x01":var a=t.substring(o,s),u=void 0;0===i.length?u=a:(u=i+=a,i=""),r.push(u);break;case"\x10":i+=t.substring(o,s),i+="\0";break;case"\x11":i+=t.substring(o,s+1);break;default:Mr()}o=s+2}return new $r(r)}function Oa(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n}var La=function(t,e){this.seconds=t,this.nanoseconds=e};Oa.store="owner",Oa.key="owner";function Pa(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n}Pa.store="mutationQueues",Pa.keyPath="userId";function Ma(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}Ma.store="mutations",Ma.keyPath="batchId",Ma.userMutationsIndex="userMutationsIndex",Ma.userMutationsKeyPath=["userId","batchId"];var Fa=(Va.prefixForUser=function(t){return[t]},Va.prefixForPath=function(t,e){return[t,Ca(e)]},Va.key=function(t,e,n){return[t,Ca(e),n]},Va);function Va(){}Fa.store="documentMutations",Fa.PLACEHOLDER=new Fa;function Ua(t,e){this.path=t,this.readTime=e}function qa(t,e){this.path=t,this.version=e}var Ba=function(t,e,n,r,i,o){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o};Ba.store="remoteDocuments",Ba.readTimeIndex="readTimeIndex",Ba.readTimeIndexPath="readTime",Ba.collectionReadTimeIndex="collectionReadTimeIndex",Ba.collectionReadTimeIndexPath=["parentPath","readTime"];function ja(t){this.byteSize=t}ja.store="remoteDocumentGlobal",ja.key="remoteDocumentGlobalKey";function Ka(t,e,n,r,i,o,s){this.targetId=t,this.canonicalId=e,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=o,this.query=s}Ka.store="targets",Ka.keyPath="targetId",Ka.queryTargetsIndexName="queryTargetsIndex",Ka.queryTargetsKeyPath=["canonicalId","targetId"];var Ga=function(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n};Ga.store="targetDocuments",Ga.keyPath=["targetId","path"],Ga.documentTargetsIndex="documentTargetsIndex",Ga.documentTargetsKeyPath=["path","targetId"];function Qa(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r}Qa.key="targetGlobalKey",Qa.store="targetGlobal";function za(t,e){this.collectionId=t,this.parent=e}za.store="collectionParents",za.keyPath=["collectionId","parent"];function Ha(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r}Ha.store="clientMetadata",Ha.keyPath="clientId";function Wa(t,e,n){this.bundleId=t,this.createTime=e,this.version=n}Wa.store="bundles",Wa.keyPath="bundleId";function Ya(t,e,n){this.name=t,this.readTime=e,this.bundledQuery=n}Ya.store="namedQueries",Ya.keyPath="name";var Xa,Ja=s(s([],s(s([],s(s([],s(s([],[Pa.store,Ma.store,Fa.store,Ba.store,Ka.store,Oa.store,Qa.store,Ga.store]),[Ha.store])),[ja.store])),[za.store])),[Wa.store,Ya.store]),$a="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",Te=(hu.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},hu.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEach(function(t){return t()})},hu),Za=function(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})},tu=(cu.prototype.catch=function(t){return this.next(void 0,t)},cu.prototype.next=function(r,i){var o=this;return this.callbackAttached&&Mr(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(i,this.error):this.wrapSuccess(r,this.result):new cu(function(e,n){o.nextCallback=function(t){o.wrapSuccess(r,t).next(e,n)},o.catchCallback=function(t){o.wrapFailure(i,t).next(e,n)}})},cu.prototype.toPromise=function(){var n=this;return new Promise(function(t,e){n.next(t,e)})},cu.prototype.wrapUserFunction=function(t){try{var e=t();return e instanceof cu?e:cu.resolve(e)}catch(t){return cu.reject(t)}},cu.prototype.wrapSuccess=function(t,e){return t?this.wrapUserFunction(function(){return t(e)}):cu.resolve(e)},cu.prototype.wrapFailure=function(t,e){return t?this.wrapUserFunction(function(){return t(e)}):cu.reject(e)},cu.resolve=function(n){return new cu(function(t,e){t(n)})},cu.reject=function(n){return new cu(function(t,e){e(n)})},cu.waitFor=function(t){return new cu(function(e,n){var r=0,i=0,o=!1;t.forEach(function(t){++r,t.next(function(){++i,o&&i===r&&e()},function(t){return n(t)})}),o=!0,i===r&&e()})},cu.or=function(t){for(var n=cu.resolve(!1),e=0,r=t;e<r.length;e++)!function(e){n=n.next(function(t){return t?cu.resolve(t):e()})}(r[e]);return n},cu.forEach=function(t,n){var r=this,i=[];return t.forEach(function(t,e){i.push(n.call(r,t,e))}),this.waitFor(i)},cu),eu=(uu.open=function(t,e,n,r){try{return new uu(e,t.transaction(r,n))}catch(t){throw new iu(e,t)}},Object.defineProperty(uu.prototype,"dt",{get:function(){return this.ft.promise},enumerable:!1,configurable:!0}),uu.prototype.abort=function(t){t&&this.ft.reject(t),this.aborted||(xr("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},uu.prototype.store=function(t){t=this.transaction.objectStore(t);return new fu(t)},uu),nu=(au.delete=function(t){return xr("SimpleDb","Removing database:",t),pu(window.indexedDB.deleteDatabase(t)).toPromise()},au.yt=function(){if("undefined"==typeof indexedDB)return!1;if(au.gt())return!0;var t=h(),e=au._t(t),n=0<e&&e<10,e=au.Et(t),e=0<e&&e<4.5;return!(0<t.indexOf("MSIE ")||0<t.indexOf("Trident/")||0<t.indexOf("Edge/")||n||e)},au.gt=function(){var t;return"undefined"!=typeof process&&"YES"===(null===(t=process.env)||void 0===t?void 0:t.Tt)},au.It=function(t,e){return t.store(e)},au._t=function(t){t=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),t=t?t[1].split("_").slice(0,2).join("."):"-1";return Number(t)},au.Et=function(t){t=t.match(/Android ([\d.]+)/i),t=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(t)},au.prototype.At=function(o){return y(this,void 0,void 0,function(){var e,i=this;return g(this,function(t){switch(t.label){case 0:return this.db?[3,2]:(xr("SimpleDb","Opening database:",this.name),e=this,[4,new Promise(function(e,n){var r=indexedDB.open(i.name,i.version);r.onsuccess=function(t){t=t.target.result;e(t)},r.onblocked=function(){n(new iu(o,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},r.onerror=function(t){t=t.target.error;"VersionError"===t.name?n(new Ar(Dr.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 iu(o,t))},r.onupgradeneeded=function(t){xr("SimpleDb",'Database "'+i.name+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;i.wt.Rt(e,r.transaction,t.oldVersion,i.version).next(function(){xr("SimpleDb","Database upgrade to version "+i.version+" complete")})}})]);case 1:e.db=t.sent(),t.label=2;case 2:return[2,(this.bt&&(this.db.onversionchange=function(t){return i.bt(t)}),this.db)]}})})},au.prototype.vt=function(e){this.bt=e,this.db&&(this.db.onversionchange=function(t){return e(t)})},au.prototype.runTransaction=function(a,n,u,c){return y(this,void 0,void 0,function(){var i,o,s,e;return g(this,function(t){switch(t.label){case 0:i="readonly"===n,o=0,e=function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:++o,t.label=1;case 1:return t.trys.push([1,4,,5]),[4,s.At(a)];case 2:return s.db=t.sent(),e=eu.open(s.db,a,i?"readonly":"readwrite",u),n=c(e).catch(function(t){return e.abort(t),tu.reject(t)}).toPromise(),r={},n.catch(function(){}),[4,e.dt];case 3:return[2,(r.value=(t.sent(),n),r)];case 4:return n=t.sent(),r="FirebaseError"!==n.name&&o<3,xr("SimpleDb","Transaction failed with error:",n.message,"Retrying:",r),s.close(),r?[3,5]:[2,{value:Promise.reject(n)}];case 5:return[2]}})},s=this,t.label=1;case 1:return[5,e()];case 2:if("object"==typeof(e=t.sent()))return[2,e.value];t.label=3;case 3:return[3,1];case 4:return[2]}})})},au.prototype.close=function(){this.db&&this.db.close(),this.db=void 0},au),ru=(Object.defineProperty(su.prototype,"isDone",{get:function(){return this.Vt},enumerable:!1,configurable:!0}),Object.defineProperty(su.prototype,"Dt",{get:function(){return this.St},enumerable:!1,configurable:!0}),Object.defineProperty(su.prototype,"cursor",{set:function(t){this.Pt=t},enumerable:!1,configurable:!0}),su.prototype.done=function(){this.Vt=!0},su.prototype.Ct=function(t){this.St=t},su.prototype.delete=function(){return pu(this.Pt.delete())},su),iu=(n(ou,Xa=Ar),ou);function ou(t,e){var n=this;return(n=Xa.call(this,Dr.UNAVAILABLE,"IndexedDB transaction '"+t+"' failed: "+e)||this).name="IndexedDbTransactionError",n}function su(t){this.Pt=t,this.Vt=!1,this.St=null}function au(t,e,n){this.name=t,this.version=e,this.wt=n,12.2===au._t(h())&&Or("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.")}function uu(e,t){var n=this;this.action=e,this.transaction=t,this.aborted=!1,this.ft=new Za,this.transaction.oncomplete=function(){n.ft.resolve()},this.transaction.onabort=function(){t.error?n.ft.reject(new iu(e,t.error)):n.ft.resolve()},this.transaction.onerror=function(t){t=gu(t.target.error);n.ft.reject(new iu(e,t))}}function cu(t){var e=this;this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(function(t){e.isDone=!0,e.result=t,e.nextCallback&&e.nextCallback(t)},function(t){e.isDone=!0,e.error=t,e.catchCallback&&e.catchCallback(t)})}function hu(){this.onCommittedListeners=[]}function lu(t){return"IndexedDbTransactionError"===t.name}var fu=(du.prototype.put=function(t,e){t=void 0!==e?(xr("SimpleDb","PUT",this.store.name,t,e),this.store.put(e,t)):(xr("SimpleDb","PUT",this.store.name,"<auto-key>",t),this.store.put(t));return pu(t)},du.prototype.add=function(t){return xr("SimpleDb","ADD",this.store.name,t,t),pu(this.store.add(t))},du.prototype.get=function(e){var n=this;return pu(this.store.get(e)).next(function(t){return void 0===t&&(t=null),xr("SimpleDb","GET",n.store.name,e,t),t})},du.prototype.delete=function(t){return xr("SimpleDb","DELETE",this.store.name,t),pu(this.store.delete(t))},du.prototype.count=function(){return xr("SimpleDb","COUNT",this.store.name),pu(this.store.count())},du.prototype.Nt=function(t,e){var e=this.cursor(this.options(t,e)),n=[];return this.xt(e,function(t,e){n.push(e)}).next(function(){return n})},du.prototype.Ft=function(t,e){xr("SimpleDb","DELETE ALL",this.store.name);e=this.options(t,e);e.kt=!1;e=this.cursor(e);return this.xt(e,function(t,e,n){return n.delete()})},du.prototype.Ot=function(t,e){e?n=t:(n={},e=t);var n=this.cursor(n);return this.xt(n,e)},du.prototype.$t=function(r){var t=this.cursor({});return new tu(function(n,e){t.onerror=function(t){t=gu(t.target.error);e(t)},t.onsuccess=function(t){var e=t.target.result;e?r(e.primaryKey,e.value).next(function(t){t?e.continue():n()}):n()}})},du.prototype.xt=function(t,i){var o=[];return new tu(function(r,e){t.onerror=function(t){e(t.target.error)},t.onsuccess=function(t){var e,n=t.target.result;n?(e=new ru(n),(t=i(n.primaryKey,n.value,e))instanceof tu&&(t=t.catch(function(t){return e.done(),tu.reject(t)}),o.push(t)),e.isDone?r():null===e.Dt?n.continue():n.continue(e.Dt)):r()}}).next(function(){return tu.waitFor(o)})},du.prototype.options=function(t,e){var n;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}},du.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.kt?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},du);function du(t){this.store=t}function pu(t){return new tu(function(e,n){t.onsuccess=function(t){t=t.target.result;e(t)},t.onerror=function(t){t=gu(t.target.error);n(t)}})}var yu=!1;function gu(t){var e=nu._t(h());if(12.2<=e&&e<13){e="An internal error was encountered in the Indexed Database server";if(0<=t.message.indexOf(e)){var n=new Ar("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '"+e+"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");return yu||(yu=!0,setTimeout(function(){throw n},0)),n}}return t}var mu,vu=(n(bu,mu=Te),bu);function bu(t,e){var n=this;return(n=mu.call(this)||this).Mt=t,n.currentSequenceNumber=e,n}function wu(t,e){return nu.It(t.Mt,e)}var Iu=(Du.prototype.applyToRemoteDocument=function(t,e){for(var n,r,i,o,s,a,u=e.mutationResults,c=0;c<this.mutations.length;c++){var h=this.mutations[c];h.key.isEqual(t.key)&&(n=h,r=t,i=u[c],h=a=s=o=void 0,n instanceof cs?(s=r,a=i,h=(o=n).value.clone(),o=ps(o.fieldTransforms,s,a.transformResults),h.setAll(o),s.convertToFoundDocument(a.version,h).setHasCommittedMutations()):n instanceof hs?(o=r,s=i,rs((a=n).precondition,o)?(h=ps(a.fieldTransforms,o,s.transformResults),(n=o.data).setAll(ds(a)),n.setAll(h),o.convertToFoundDocument(s.version,n).setHasCommittedMutations()):o.convertToUnknownDocument(s.version)):r.convertToNoDocument(i.version).setHasCommittedMutations())}},Du.prototype.applyToLocalView=function(t){for(var e=0,n=this.baseMutations;e<n.length;e++)(r=n[e]).key.isEqual(t.key)&&is(r,t,this.localWriteTime);for(var r,i=0,o=this.mutations;i<o.length;i++)(r=o[i]).key.isEqual(t.key)&&is(r,t,this.localWriteTime)},Du.prototype.applyToLocalDocumentSet=function(n){var r=this;this.mutations.forEach(function(t){var e=n.get(t.key),t=e;r.applyToLocalView(t),e.isValidDocument()||t.convertToNoDocument(Gr.min())})},Du.prototype.keys=function(){return this.mutations.reduce(function(t,e){return t.add(e.key)},Bs())},Du.prototype.isEqual=function(t){return this.batchId===t.batchId&&Br(this.mutations,t.mutations,os)&&Br(this.baseMutations,t.baseMutations,os)},Du),Eu=(Nu.from=function(t,e,n){Fr(t.mutations.length===n.length);for(var r=Us,i=t.mutations,o=0;o<i.length;o++)r=r.insert(i[o].key,n[o].version);return new Nu(t,e,n,r)},Nu),Tu=(Su.prototype.withSequenceNumber=function(t){return new Su(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)},Su.prototype.withResumeToken=function(t,e){return new Su(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)},Su.prototype.withLastLimboFreeSnapshotVersion=function(t){return new Su(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken)},Su),_u=function(t){this.Lt=t};function Su(t,e,n,r,i,o,s){void 0===i&&(i=Gr.min()),void 0===o&&(o=Gr.min()),void 0===s&&(s=ni.EMPTY_BYTE_STRING),this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s}function Nu(t,e,n,r){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=r}function Du(t,e,n,r){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=r}function Au(t,e){if(e.document)return ma(t.Lt,e.document,!!e.hasCommittedMutations);if(e.noDocument){var n=mi.fromSegments(e.noDocument.path),r=Ou(e.noDocument.readTime),n=Oi.newNoDocument(n,r);return e.hasCommittedMutations?n.setHasCommittedMutations():n}if(e.unknownDocument){n=mi.fromSegments(e.unknownDocument.path),r=Ou(e.unknownDocument.version);return Oi.newUnknownDocument(n,r)}return Mr()}function ku(t,e,n){var r=Cu(n),n=e.key.path.popLast().toArray();if(e.isFoundDocument()){var i={name:ha(o=t.Lt,(s=e).key),fields:s.data.toProto().mapValue.fields,updateTime:oa(o,s.version.toTimestamp())},o=e.hasCommittedMutations;return new Ba(null,null,i,o,r,n)}if(e.isNoDocument()){var s=e.key.path.toArray(),i=xu(e.version),o=e.hasCommittedMutations;return new Ba(null,new Ua(s,i),null,o,r,n)}if(e.isUnknownDocument()){o=e.key.path.toArray(),e=xu(e.version);return new Ba(new qa(o,e),null,null,!0,r,n)}return Mr()}function Cu(t){t=t.toTimestamp();return[t.seconds,t.nanoseconds]}function Ru(t){t=new Kr(t[0],t[1]);return Gr.fromTimestamp(t)}function xu(t){t=t.toTimestamp();return new La(t.seconds,t.nanoseconds)}function Ou(t){t=new Kr(t.seconds,t.nanoseconds);return Gr.fromTimestamp(t)}function Lu(e,t){for(var n=(t.baseMutations||[]).map(function(t){return ba(e.Lt,t)}),r=0;r<t.mutations.length-1;++r){var i,o=t.mutations[r];r+1<t.mutations.length&&void 0!==t.mutations[r+1].transform&&(i=t.mutations[r+1],o.updateTransforms=i.transform.fieldTransforms,t.mutations.splice(r+1,1),++r)}var s=t.mutations.map(function(t){return ba(e.Lt,t)}),a=Kr.fromMillis(t.localWriteTimeMs);return new Iu(t.batchId,a,n,s)}function Pu(t){var e=Ou(t.readTime),n=void 0!==t.lastLimboFreeSnapshotVersion?Ou(t.lastLimboFreeSnapshotVersion):Gr.min(),r=void 0!==t.query.documents?(Fr(1===(r=t.query).documents.length),No(bo(da(r.documents[0])))):No(Ea(t.query));return new Tu(r,t.targetId,0,t.lastListenSequenceNumber,e,n,ni.fromBase64String(t.resumeToken))}function Mu(t,e){var n=xu(e.snapshotVersion),r=xu(e.lastLimboFreeSnapshotVersion),i=(Ui(e.target)?wa:Ia)(t.Lt,e.target),t=e.resumeToken.toBase64();return new Ka(e.targetId,Fi(e.target),n,t,e.sequenceNumber,r,i)}function Fu(t){var e=Ea({parent:t.parent,structuredQuery:t.structuredQuery});return"LAST"===t.limitType?Do(e,e.limit,"L"):e}var Vu=(Uu.prototype.getBundleMetadata=function(t,e){return qu(t).get(e).next(function(t){if(t)return{id:(t=t).bundleId,createTime:Ou(t.createTime),version:t.version}})},Uu.prototype.saveBundleMetadata=function(t,e){return qu(t).put({bundleId:(e=e).id,createTime:xu(aa(e.createTime)),version:e.version})},Uu.prototype.getNamedQuery=function(t,e){return Bu(t).get(e).next(function(t){if(t)return{name:(t=t).name,query:Fu(t.bundledQuery),readTime:Ou(t.readTime)}})},Uu.prototype.saveNamedQuery=function(t,e){return Bu(t).put({name:(e=e).name,readTime:xu(aa(e.readTime)),bundledQuery:e.bundledQuery})},Uu);function Uu(){}function qu(t){return wu(t,Wa.store)}function Bu(t){return wu(t,Ya.store)}var ju=(Hu.prototype.addToCollectionParentIndex=function(t,e){return this.Bt.add(e),tu.resolve()},Hu.prototype.getCollectionParents=function(t,e){return tu.resolve(this.Bt.getEntries(e))},Hu),Ku=(zu.prototype.add=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new Os($r.comparator),t=!r.has(n);return this.index[e]=r.add(n),t},zu.prototype.has=function(t){var e=t.lastSegment(),t=t.popLast(),e=this.index[e];return e&&e.has(t)},zu.prototype.getEntries=function(t){return(this.index[t]||new Os($r.comparator)).toArray()},zu),Gu=(Qu.prototype.addToCollectionParentIndex=function(t,e){var n=this;if(this.qt.has(e))return tu.resolve();var r=e.lastSegment(),i=e.popLast();t.addOnCommittedListener(function(){n.qt.add(e)});i={collectionId:r,parent:Ca(i)};return Wu(t).put(i)},Qu.prototype.getCollectionParents=function(t,i){var o=[],e=IDBKeyRange.bound([i,""],[jr(i),""],!1,!0);return Wu(t).Nt(e).next(function(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];if(r.collectionId!==i)break;o.push(xa(r.parent))}return o})},Qu);function Qu(){this.qt=new Ku}function zu(){this.index={}}function Hu(){this.Bt=new Ku}function Wu(t){return wu(t,za.store)}var Yu={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},Xu=(Ju.withCacheSize=function(t){return new Ju(t,Ju.DEFAULT_COLLECTION_PERCENTILE,Ju.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)},Ju);function Ju(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}function $u(t,e,n){var r=t.store(Ma.store),i=t.store(Fa.store),o=[],t=IDBKeyRange.only(n.batchId),s=0,t=r.Ot({range:t},function(t,e,n){return s++,n.delete()});o.push(t.next(function(){Fr(1===s)}));for(var a=[],u=0,c=n.mutations;u<c.length;u++){var h=c[u],l=Fa.key(e,h.key.path,n.batchId);o.push(i.delete(l)),a.push(h.key)}return tu.waitFor(o).next(function(){return a})}function Zu(t){if(!t)return 0;var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw Mr();e=t.noDocument}return JSON.stringify(e).length}Xu.DEFAULT_COLLECTION_PERCENTILE=10,Xu.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Xu.DEFAULT=new Xu(41943040,Xu.DEFAULT_COLLECTION_PERCENTILE,Xu.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Xu.DISABLED=new Xu(-1,0,0);var tc=(ec.Kt=function(t,e,n,r){return Fr(""!==t.uid),new ec(t.isAuthenticated()?t.uid:"",e,n,r)},ec.prototype.checkEmpty=function(t){var r=!0,e=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return rc(t).Ot({index:Ma.userMutationsIndex,range:e},function(t,e,n){r=!1,n.done()}).next(function(){return r})},ec.prototype.addMutationBatch=function(p,y,g,m){var v=this,b=ic(p),w=rc(p);return w.add({}).next(function(t){Fr("number"==typeof t);for(var e,n,r,i,o,s=new Iu(t,y,g,m),a=(e=v.R,n=v.userId,i=(r=s).baseMutations.map(function(t){return va(e.Lt,t)}),o=r.mutations.map(function(t){return va(e.Lt,t)}),new Ma(n,r.batchId,r.localWriteTime.toMillis(),i,o)),u=[],c=new Os(function(t,e){return qr(t.canonicalString(),e.canonicalString())}),h=0,l=m;h<l.length;h++){var f=l[h],d=Fa.key(v.userId,f.key.path,t),c=c.add(f.key.path.popLast());u.push(w.put(a)),u.push(b.put(d,Fa.PLACEHOLDER))}return c.forEach(function(t){u.push(v.Ut.addToCollectionParentIndex(p,t))}),p.addOnCommittedListener(function(){v.Qt[t]=s.keys()}),tu.waitFor(u).next(function(){return s})})},ec.prototype.lookupMutationBatch=function(t,e){var n=this;return rc(t).get(e).next(function(t){return t?(Fr(t.userId===n.userId),Lu(n.R,t)):null})},ec.prototype.jt=function(t,e){var n=this;return this.Qt[e]?tu.resolve(this.Qt[e]):this.lookupMutationBatch(t,e).next(function(t){if(t){t=t.keys();return n.Qt[e]=t}return null})},ec.prototype.getNextMutationBatchAfterBatchId=function(t,e){var r=this,i=e+1,e=IDBKeyRange.lowerBound([this.userId,i]),o=null;return rc(t).Ot({index:Ma.userMutationsIndex,range:e},function(t,e,n){e.userId===r.userId&&(Fr(e.batchId>=i),o=Lu(r.R,e)),n.done()}).next(function(){return o})},ec.prototype.getHighestUnacknowledgedBatchId=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return rc(t).Ot({index:Ma.userMutationsIndex,range:e,reverse:!0},function(t,e,n){r=e.batchId,n.done()}).next(function(){return r})},ec.prototype.getAllMutationBatches=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return rc(t).Nt(Ma.userMutationsIndex,n).next(function(t){return t.map(function(t){return Lu(e.R,t)})})},ec.prototype.getAllMutationBatchesAffectingDocumentKey=function(o,s){var a=this,t=Fa.prefixForPath(this.userId,s.path),t=IDBKeyRange.lowerBound(t),u=[];return ic(o).Ot({range:t},function(t,e,n){var r=t[0],i=t[1],t=t[2],i=xa(i);if(r===a.userId&&s.path.isEqual(i))return rc(o).get(t).next(function(t){if(!t)throw Mr();Fr(t.userId===a.userId),u.push(Lu(a.R,t))});n.done()}).next(function(){return u})},ec.prototype.getAllMutationBatchesAffectingDocumentKeys=function(e,t){var s=this,a=new Os(qr),n=[];return t.forEach(function(o){var t=Fa.prefixForPath(s.userId,o.path),t=IDBKeyRange.lowerBound(t),t=ic(e).Ot({range:t},function(t,e,n){var r=t[0],i=t[1],t=t[2],i=xa(i);r===s.userId&&o.path.isEqual(i)?a=a.add(t):n.done()});n.push(t)}),tu.waitFor(n).next(function(){return s.Wt(e,a)})},ec.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var o=this,s=e.path,a=s.length+1,e=Fa.prefixForPath(this.userId,s),e=IDBKeyRange.lowerBound(e),u=new Os(qr);return ic(t).Ot({range:e},function(t,e,n){var r=t[0],i=t[1],t=t[2],i=xa(i);r===o.userId&&s.isPrefixOf(i)?i.length===a&&(u=u.add(t)):n.done()}).next(function(){return o.Wt(t,u)})},ec.prototype.Wt=function(e,t){var n=this,r=[],i=[];return t.forEach(function(t){i.push(rc(e).get(t).next(function(t){if(null===t)throw Mr();Fr(t.userId===n.userId),r.push(Lu(n.R,t))}))}),tu.waitFor(i).next(function(){return r})},ec.prototype.removeMutationBatch=function(e,n){var r=this;return $u(e.Mt,this.userId,n).next(function(t){return e.addOnCommittedListener(function(){r.Gt(n.batchId)}),tu.forEach(t,function(t){return r.referenceDelegate.markPotentiallyOrphaned(e,t)})})},ec.prototype.Gt=function(t){delete this.Qt[t]},ec.prototype.performConsistencyCheck=function(e){var i=this;return this.checkEmpty(e).next(function(t){if(!t)return tu.resolve();var t=IDBKeyRange.lowerBound(Fa.prefixForUser(i.userId)),r=[];return ic(e).Ot({range:t},function(t,e,n){t[0]===i.userId?(t=xa(t[1]),r.push(t)):n.done()}).next(function(){Fr(0===r.length)})})},ec.prototype.containsKey=function(t,e){return nc(t,this.userId,e)},ec.prototype.zt=function(t){var e=this;return oc(t).get(this.userId).next(function(t){return t||new Pa(e.userId,-1,"")})},ec);function ec(t,e,n,r){this.userId=t,this.R=e,this.Ut=n,this.referenceDelegate=r,this.Qt={}}function nc(t,o,e){var e=Fa.prefixForPath(o,e.path),s=e[1],e=IDBKeyRange.lowerBound(e),a=!1;return ic(t).Ot({range:e,kt:!0},function(t,e,n){var r=t[0],i=t[1];t[2],r===o&&i===s&&(a=!0),n.done()}).next(function(){return a})}function rc(t){return wu(t,Ma.store)}function ic(t){return wu(t,Fa.store)}function oc(t){return wu(t,Pa.store)}var sc=(cc.prototype.next=function(){return this.Ht+=2,this.Ht},cc.Jt=function(){return new cc(0)},cc.Yt=function(){return new cc(-1)},cc),ac=(uc.prototype.allocateTargetId=function(n){var r=this;return this.Xt(n).next(function(t){var e=new sc(t.highestTargetId);return t.highestTargetId=e.next(),r.Zt(n,t).next(function(){return t.highestTargetId})})},uc.prototype.getLastRemoteSnapshotVersion=function(t){return this.Xt(t).next(function(t){return Gr.fromTimestamp(new Kr(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))})},uc.prototype.getHighestSequenceNumber=function(t){return this.Xt(t).next(function(t){return t.highestListenSequenceNumber})},uc.prototype.setTargetsMetadata=function(e,n,r){var i=this;return this.Xt(e).next(function(t){return t.highestListenSequenceNumber=n,r&&(t.lastRemoteSnapshotVersion=r.toTimestamp()),n>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=n),i.Zt(e,t)})},uc.prototype.addTargetData=function(e,n){var r=this;return this.te(e,n).next(function(){return r.Xt(e).next(function(t){return t.targetCount+=1,r.ee(n,t),r.Zt(e,t)})})},uc.prototype.updateTargetData=function(t,e){return this.te(t,e)},uc.prototype.removeTargetData=function(e,t){var n=this;return this.removeMatchingKeysForTargetId(e,t.targetId).next(function(){return hc(e).delete(t.targetId)}).next(function(){return n.Xt(e)}).next(function(t){return Fr(0<t.targetCount),--t.targetCount,n.Zt(e,t)})},uc.prototype.removeTargets=function(n,r,i){var o=this,s=0,a=[];return hc(n).Ot(function(t,e){e=Pu(e);e.sequenceNumber<=r&&null===i.get(e.targetId)&&(s++,a.push(o.removeTargetData(n,e)))}).next(function(){return tu.waitFor(a)}).next(function(){return s})},uc.prototype.forEachTarget=function(t,n){return hc(t).Ot(function(t,e){e=Pu(e);n(e)})},uc.prototype.Xt=function(t){return lc(t).get(Qa.key).next(function(t){return Fr(null!==t),t})},uc.prototype.Zt=function(t,e){return lc(t).put(Qa.key,e)},uc.prototype.te=function(t,e){return hc(t).put(Mu(this.R,e))},uc.prototype.ee=function(t,e){var n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},uc.prototype.getTargetCount=function(t){return this.Xt(t).next(function(t){return t.targetCount})},uc.prototype.getTargetData=function(t,r){var e=Fi(r),e=IDBKeyRange.bound([e,Number.NEGATIVE_INFINITY],[e,Number.POSITIVE_INFINITY]),i=null;return hc(t).Ot({range:e,index:Ka.queryTargetsIndexName},function(t,e,n){e=Pu(e);Vi(r,e.target)&&(i=e,n.done())}).next(function(){return i})},uc.prototype.addMatchingKeys=function(n,t,r){var i=this,o=[],s=fc(n);return t.forEach(function(t){var e=Ca(t.path);o.push(s.put(new Ga(r,e))),o.push(i.referenceDelegate.addReference(n,r,t))}),tu.waitFor(o)},uc.prototype.removeMatchingKeys=function(n,t,r){var i=this,o=fc(n);return tu.forEach(t,function(t){var e=Ca(t.path);return tu.waitFor([o.delete([r,e]),i.referenceDelegate.removeReference(n,r,t)])})},uc.prototype.removeMatchingKeysForTargetId=function(t,e){t=fc(t),e=IDBKeyRange.bound([e],[e+1],!1,!0);return t.delete(e)},uc.prototype.getMatchingKeysForTargetId=function(t,e){var e=IDBKeyRange.bound([e],[e+1],!1,!0),t=fc(t),r=Bs();return t.Ot({range:e,kt:!0},function(t,e,n){t=xa(t[1]),t=new mi(t);r=r.add(t)}).next(function(){return r})},uc.prototype.containsKey=function(t,e){var e=Ca(e.path),e=IDBKeyRange.bound([e],[jr(e)],!1,!0),i=0;return fc(t).Ot({index:Ga.documentTargetsIndex,kt:!0,range:e},function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())}).next(function(){return 0<i})},uc.prototype.lt=function(t,e){return hc(t).get(e).next(function(t){return t?Pu(t):null})},uc);function uc(t,e){this.referenceDelegate=t,this.R=e}function cc(t){this.Ht=t}function hc(t){return wu(t,Ka.store)}function lc(t){return wu(t,Qa.store)}function fc(t){return wu(t,Ga.store)}function dc(e){return y(this,void 0,void 0,function(){return g(this,function(t){if(e.code!==Dr.FAILED_PRECONDITION||e.message!==$a)throw e;return xr("LocalStore","Unexpectedly lost primary lease"),[2]})})}function pc(t,e){var n=t[0],r=t[1],t=e[0],e=e[1],t=qr(n,t);return 0===t?qr(r,e):t}var yc=(Ec.prototype.ie=function(){return++this.se},Ec.prototype.re=function(t){var e=[t,this.ie()];this.buffer.size<this.ne?this.buffer=this.buffer.add(e):pc(e,t=this.buffer.last())<0&&(this.buffer=this.buffer.delete(t).add(e))},Object.defineProperty(Ec.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!1,configurable:!0}),Ec),gc=(Ic.prototype.start=function(t){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.ue(t)},Ic.prototype.stop=function(){this.ce&&(this.ce.cancel(),this.ce=null)},Object.defineProperty(Ic.prototype,"started",{get:function(){return null!==this.ce},enumerable:!1,configurable:!0}),Ic.prototype.ue=function(n){var t=this,e=this.oe?3e5:6e4;xr("LruGarbageCollector","Garbage collection scheduled in "+e+"ms"),this.ce=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,function(){return y(t,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:this.ce=null,this.oe=!0,t.label=1;case 1:return t.trys.push([1,3,,7]),[4,n.collectGarbage(this.garbageCollector)];case 2:return t.sent(),[3,7];case 3:return lu(e=t.sent())?(xr("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e),[3,6]):[3,4];case 4:return[4,dc(e)];case 5:t.sent(),t.label=6;case 6:return[3,7];case 7:return[4,this.ue(n)];case 8:return t.sent(),[2]}})})})},Ic),mc=(wc.prototype.calculateTargetCount=function(t,e){return this.ae.he(t).next(function(t){return Math.floor(e/100*t)})},wc.prototype.nthSequenceNumber=function(t,e){var n=this;if(0===e)return tu.resolve(_r.o);var r=new yc(e);return this.ae.forEachTarget(t,function(t){return r.re(t.sequenceNumber)}).next(function(){return n.ae.le(t,function(t){return r.re(t)})}).next(function(){return r.maxValue})},wc.prototype.removeTargets=function(t,e,n){return this.ae.removeTargets(t,e,n)},wc.prototype.removeOrphanedDocuments=function(t,e){return this.ae.removeOrphanedDocuments(t,e)},wc.prototype.collect=function(e,n){var r=this;return-1===this.params.cacheSizeCollectionThreshold?(xr("LruGarbageCollector","Garbage collection skipped; disabled"),tu.resolve(Yu)):this.getCacheSize(e).next(function(t){return t<r.params.cacheSizeCollectionThreshold?(xr("LruGarbageCollector","Garbage collection skipped; Cache size "+t+" is lower than threshold "+r.params.cacheSizeCollectionThreshold),Yu):r.fe(e,n)})},wc.prototype.getCacheSize=function(t){return this.ae.getCacheSize(t)},wc.prototype.fe=function(e,n){var r,i,o,s,a,u,c,h=this,l=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(function(t){return i=t>h.params.maximumSequenceNumbersToCollect?(xr("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+h.params.maximumSequenceNumbersToCollect+" from "+t),h.params.maximumSequenceNumbersToCollect):t,s=Date.now(),h.nthSequenceNumber(e,i)}).next(function(t){return r=t,a=Date.now(),h.removeTargets(e,r,n)}).next(function(t){return o=t,u=Date.now(),h.removeOrphanedDocuments(e,r)}).next(function(t){return c=Date.now(),Rr()<=f.DEBUG&&xr("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(s-l)+"ms\n\tDetermined least recently used "+i+" in "+(a-s)+"ms\n\tRemoved "+o+" targets in "+(u-a)+"ms\n\tRemoved "+t+" documents in "+(c-u)+"ms\nTotal Duration: "+(c-l)+"ms"),tu.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:o,documentsRemoved:t})})},wc),vc=(bc.prototype.he=function(t){var n=this.de(t);return this.db.getTargetCache().getTargetCount(t).next(function(e){return n.next(function(t){return e+t})})},bc.prototype.de=function(t){var e=0;return this.le(t,function(t){e++}).next(function(){return e})},bc.prototype.forEachTarget=function(t,e){return this.db.getTargetCache().forEachTarget(t,e)},bc.prototype.le=function(t,n){return this.we(t,function(t,e){return n(e)})},bc.prototype.addReference=function(t,e,n){return Tc(t,n)},bc.prototype.removeReference=function(t,e,n){return Tc(t,n)},bc.prototype.removeTargets=function(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)},bc.prototype.markPotentiallyOrphaned=Tc,bc.prototype._e=function(t,e){return r=e,i=!1,oc(n=t).$t(function(t){return nc(n,t,r).next(function(t){return t&&(i=!0),tu.resolve(!t)})}).next(function(){return i});var n,r,i},bc.prototype.removeOrphanedDocuments=function(n,r){var i=this,o=this.db.getRemoteDocumentCache().newChangeBuffer(),s=[],a=0;return this.we(n,function(e,t){t<=r&&(t=i._e(n,e).next(function(t){if(!t)return a++,o.getEntry(n,e).next(function(){return o.removeEntry(e),fc(n).delete([0,Ca(e.path)])})}),s.push(t))}).next(function(){return tu.waitFor(s)}).next(function(){return o.apply(n)}).next(function(){return a})},bc.prototype.removeTarget=function(t,e){e=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,e)},bc.prototype.updateLimboDocument=Tc,bc.prototype.we=function(t,r){var i,t=fc(t),o=_r.o;return t.Ot({index:Ga.documentTargetsIndex},function(t,e){var n=t[0],t=(t[1],e.path),e=e.sequenceNumber;0===n?(o!==_r.o&&r(new mi(xa(i)),o),o=e,i=t):o=_r.o}).next(function(){o!==_r.o&&r(new mi(xa(i)),o)})},bc.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},bc);function bc(t,e){this.db=t,this.garbageCollector=new mc(this,e)}function wc(t,e){this.ae=t,this.params=e}function Ic(t,e){this.garbageCollector=t,this.asyncQueue=e,this.oe=!1,this.ce=null}function Ec(t){this.ne=t,this.buffer=new Os(pc),this.se=0}function Tc(t,e){return fc(t).put((t=t.currentSequenceNumber,new Ga(0,Ca(e.path),t)))}var _c,Sc=(Rc.prototype.get=function(t){var e=this.mapKeyFn(t),e=this.inner[e];if(void 0!==e)for(var n=0,r=e;n<r.length;n++){var i=r[n],o=i[0],i=i[1];if(this.equalsFn(o,t))return i}},Rc.prototype.has=function(t){return void 0!==this.get(t)},Rc.prototype.set=function(t,e){var n=this.mapKeyFn(t),r=this.inner[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(this.equalsFn(r[i][0],t))return void(r[i]=[t,e]);r.push([t,e])}else this.inner[n]=[[t,e]]},Rc.prototype.delete=function(t){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(this.equalsFn(n[r][0],t))return 1===n.length?delete this.inner[e]:n.splice(r,1),!0;return!1},Rc.prototype.forEach=function(s){Wr(this.inner,function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n],o=i[0],i=i[1];s(o,i)}})},Rc.prototype.isEmpty=function(){return Yr(this.inner)},Rc),I=(Cc.prototype.getReadTime=function(t){t=this.changes.get(t);return t?t.readTime:Gr.min()},Cc.prototype.addEntry=function(t,e){this.assertNotApplied(),this.changes.set(t.key,{document:t,readTime:e})},Cc.prototype.removeEntry=function(t,e){void 0===e&&(e=null),this.assertNotApplied(),this.changes.set(t,{document:Oi.newInvalidDocument(t),readTime:e})},Cc.prototype.getEntry=function(t,e){this.assertNotApplied();var n=this.changes.get(e);return void 0!==n?tu.resolve(n.document):this.getFromCache(t,e)},Cc.prototype.getEntries=function(t,e){return this.getAllFromCache(t,e)},Cc.prototype.apply=function(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)},Cc.prototype.assertNotApplied=function(){},Cc),Nc=(kc.prototype.addEntry=function(t,e,n){return Oc(t).put(Lc(e),n)},kc.prototype.removeEntry=function(t,e){t=Oc(t),e=Lc(e);return t.delete(e)},kc.prototype.updateMetadata=function(e,n){var r=this;return this.getMetadata(e).next(function(t){return t.byteSize+=n,r.me(e,t)})},kc.prototype.getEntry=function(t,e){var n=this;return Oc(t).get(Lc(e)).next(function(t){return n.ye(e,t)})},kc.prototype.ge=function(t,e){var n=this;return Oc(t).get(Lc(e)).next(function(t){return{document:n.ye(e,t),size:Zu(t)}})},kc.prototype.getEntries=function(t,e){var n=this,r=Ps;return this.pe(t,e,function(t,e){e=n.ye(t,e);r=r.insert(t,e)}).next(function(){return r})},kc.prototype.Ee=function(t,e){var r=this,i=Ps,o=new Ns(mi.comparator);return this.pe(t,e,function(t,e){var n=r.ye(t,e);i=i.insert(t,n),o=o.insert(t,Zu(e))}).next(function(){return{documents:i,Te:o}})},kc.prototype.pe=function(t,e,i){if(e.isEmpty())return tu.resolve();var n=IDBKeyRange.bound(e.first().path.toArray(),e.last().path.toArray()),o=e.getIterator(),s=o.getNext();return Oc(t).Ot({range:n},function(t,e,n){for(var r=mi.fromSegments(t);s&&mi.comparator(s,r)<0;)i(s,null),s=o.getNext();s&&s.isEqual(r)&&(i(s,e),s=o.hasNext()?o.getNext():null),s?n.Ct(s.path.toArray()):n.done()}).next(function(){for(;s;)i(s,null),s=o.hasNext()?o.getNext():null})},kc.prototype.getDocumentsMatchingQuery=function(t,r,e){var n,i=this,o=Ps,s=r.path.length+1,a={};return e.isEqual(Gr.min())?(n=r.path.toArray(),a.range=IDBKeyRange.lowerBound(n)):(n=r.path.toArray(),e=Cu(e),a.range=IDBKeyRange.lowerBound([n,e],!0),a.index=Ba.collectionReadTimeIndex),Oc(t).Ot(a,function(t,e,n){t.length===s&&(e=Au(i.R,e),r.path.isPrefixOf(e.key.path)?Ro(r,e)&&(o=o.insert(e.key,e)):n.done())}).next(function(){return o})},kc.prototype.newChangeBuffer=function(t){return new Dc(this,!!t&&t.trackRemovals)},kc.prototype.getSize=function(t){return this.getMetadata(t).next(function(t){return t.byteSize})},kc.prototype.getMetadata=function(t){return xc(t).get(ja.key).next(function(t){return Fr(!!t),t})},kc.prototype.me=function(t,e){return xc(t).put(ja.key,e)},kc.prototype.ye=function(t,e){if(e){e=Au(this.R,e);if(!e.isNoDocument()||!e.version.isEqual(Gr.min()))return e}return Oi.newInvalidDocument(t)},kc),Dc=(n(Ac,_c=I),Ac.prototype.applyChanges=function(i){var o=this,s=[],a=0,u=new Os(function(t,e){return qr(t.canonicalString(),e.canonicalString())});return this.changes.forEach(function(t,e){var n,r=o.Ae.get(t);e.document.isValidDocument()?(n=ku(o.Ie.R,e.document,o.getReadTime(t)),u=u.add(t.path.popLast()),e=Zu(n),a+=e-r,s.push(o.Ie.addEntry(i,t,n))):(a-=r,o.trackRemovals?(r=ku(o.Ie.R,Oi.newNoDocument(t,Gr.min()),o.getReadTime(t)),s.push(o.Ie.addEntry(i,t,r))):s.push(o.Ie.removeEntry(i,t)))}),u.forEach(function(t){s.push(o.Ie.Ut.addToCollectionParentIndex(i,t))}),s.push(this.Ie.updateMetadata(i,a)),tu.waitFor(s)},Ac.prototype.getFromCache=function(t,e){var n=this;return this.Ie.ge(t,e).next(function(t){return n.Ae.set(e,t.size),t.document})},Ac.prototype.getAllFromCache=function(t,e){var n=this;return this.Ie.Ee(t,e).next(function(t){var e=t.documents;return t.Te.forEach(function(t,e){n.Ae.set(t,e)}),e})},Ac);function Ac(t,e){var n=this;return(n=_c.call(this)||this).Ie=t,n.trackRemovals=e,n.Ae=new Sc(function(t){return t.toString()},function(t,e){return t.isEqual(e)}),n}function kc(t,e){this.R=t,this.Ut=e}function Cc(){this.changes=new Sc(function(t){return t.toString()},function(t,e){return t.isEqual(e)}),this.changesApplied=!1}function Rc(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={}}function xc(t){return wu(t,ja.store)}function Oc(t){return wu(t,Ba.store)}function Lc(t){return t.path.toArray()}var Pc=(Mc.prototype.Rt=function(e,n,t,r){var i=this;Fr(t<r&&0<=t&&r<=11);var o=new eu("createOrUpgrade",n);t<1&&1<=r&&(e.createObjectStore(Oa.store),(s=e).createObjectStore(Pa.store,{keyPath:Pa.keyPath}),s.createObjectStore(Ma.store,{keyPath:Ma.keyPath,autoIncrement:!0}).createIndex(Ma.userMutationsIndex,Ma.userMutationsKeyPath,{unique:!0}),s.createObjectStore(Fa.store),Fc(e),e.createObjectStore(Ba.store));var s,a=tu.resolve();return t<3&&3<=r&&(0!==t&&((s=e).deleteObjectStore(Ga.store),s.deleteObjectStore(Ka.store),s.deleteObjectStore(Qa.store),Fc(e)),a=a.next(function(){return t=o.store(Qa.store),e=new Qa(0,0,Gr.min().toTimestamp(),0),t.put(Qa.key,e);var t,e})),t<4&&4<=r&&(a=(a=0!==t?a.next(function(){return n=e,(r=o).store(Ma.store).Nt().next(function(t){n.deleteObjectStore(Ma.store),n.createObjectStore(Ma.store,{keyPath:Ma.keyPath,autoIncrement:!0}).createIndex(Ma.userMutationsIndex,Ma.userMutationsKeyPath,{unique:!0});var e=r.store(Ma.store),t=t.map(function(t){return e.put(t)});return tu.waitFor(t)});var n,r}):a).next(function(){e.createObjectStore(Ha.store,{keyPath:Ha.keyPath})})),t<5&&5<=r&&(a=a.next(function(){return i.Re(o)})),t<6&&6<=r&&(a=a.next(function(){return e.createObjectStore(ja.store),i.be(o)})),t<7&&7<=r&&(a=a.next(function(){return i.ve(o)})),t<8&&8<=r&&(a=a.next(function(){return i.Pe(e,o)})),t<9&&9<=r&&(a=a.next(function(){var t;(t=e).objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges"),(t=n.objectStore(Ba.store)).createIndex(Ba.readTimeIndex,Ba.readTimeIndexPath,{unique:!1}),t.createIndex(Ba.collectionReadTimeIndex,Ba.collectionReadTimeIndexPath,{unique:!1})})),t<10&&10<=r&&(a=a.next(function(){return i.Ve(o)})),a=t<11&&11<=r?a.next(function(){e.createObjectStore(Wa.store,{keyPath:Wa.keyPath}),e.createObjectStore(Ya.store,{keyPath:Ya.keyPath})}):a},Mc.prototype.be=function(e){var n=0;return e.store(Ba.store).Ot(function(t,e){n+=Zu(e)}).next(function(){var t=new ja(n);return e.store(ja.store).put(ja.key,t)})},Mc.prototype.Re=function(n){var r=this,t=n.store(Pa.store),i=n.store(Ma.store);return t.Nt().next(function(t){return tu.forEach(t,function(e){var t=IDBKeyRange.bound([e.userId,-1],[e.userId,e.lastAcknowledgedBatchId]);return i.Nt(Ma.userMutationsIndex,t).next(function(t){return tu.forEach(t,function(t){Fr(t.userId===e.userId);t=Lu(r.R,t);return $u(n,e.userId,t).next(function(){})})})})})},Mc.prototype.ve=function(t){var o=t.store(Ga.store),e=t.store(Ba.store);return t.store(Qa.store).get(Qa.key).next(function(r){var i=[];return e.Ot(function(t,e){var n=new $r(t),t=[0,Ca(n)];i.push(o.get(t).next(function(t){return t?tu.resolve():o.put(new Ga(0,Ca(n),r.highestListenSequenceNumber))}))}).next(function(){return tu.waitFor(i)})})},Mc.prototype.Pe=function(t,e){t.createObjectStore(za.store,{keyPath:za.keyPath});function r(t){if(i.add(t)){var e=t.lastSegment(),t=t.popLast();return n.put({collectionId:e,parent:Ca(t)})}}var n=e.store(za.store),i=new Ku;return e.store(Ba.store).Ot({kt:!0},function(t,e){t=new $r(t);return r(t.popLast())}).next(function(){return e.store(Fa.store).Ot({kt:!0},function(t,e){t[0];var n=t[1],n=(t[2],xa(n));return r(n.popLast())})})},Mc.prototype.Ve=function(t){var n=this,r=t.store(Ka.store);return r.Ot(function(t,e){e=Pu(e),e=Mu(n.R,e);return r.put(e)})},Mc);function Mc(t){this.R=t}function Fc(t){t.createObjectStore(Ga.store,{keyPath:Ga.keyPath}).createIndex(Ga.documentTargetsIndex,Ga.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(Ka.store,{keyPath:Ka.keyPath}).createIndex(Ka.queryTargetsIndexName,Ka.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(Qa.store)}var Vc="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",Uc=(qc.prototype.start=function(){var e=this;return this.je().then(function(){if(!e.isPrimary&&!e.allowTabSynchronization)throw new Ar(Dr.FAILED_PRECONDITION,Vc);return e.We(),e.Ge(),e.ze(),e.runTransaction("getHighestListenSequenceNumber","readonly",function(t){return e.qe.getHighestSequenceNumber(t)})}).then(function(t){e.Ne=new _r(t,e.De)}).then(function(){e.xe=!0}).catch(function(t){return e.Be&&e.Be.close(),Promise.reject(t)})},qc.prototype.He=function(n){var t=this;return this.Me=function(e){return y(t,void 0,void 0,function(){return g(this,function(t){return this.started?[2,n(e)]:[2]})})},n(this.isPrimary)},qc.prototype.setDatabaseDeletedListener=function(n){var t=this;this.Be.vt(function(e){return y(t,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return null===e.newVersion?[4,n()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})})},qc.prototype.setNetworkEnabled=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.Se.enqueueAndForget(function(){return y(e,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return this.started?[4,this.je()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})}))},qc.prototype.je=function(){var n=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",function(e){return jc(e).put(new Ha(n.clientId,Date.now(),n.networkEnabled,n.inForeground)).next(function(){if(n.isPrimary)return n.Je(e).next(function(t){t||(n.isPrimary=!1,n.Se.enqueueRetryable(function(){return n.Me(!1)}))})}).next(function(){return n.Ye(e)}).next(function(t){return n.isPrimary&&!t?n.Xe(e).next(function(){return!1}):!!t&&n.Ze(e).next(function(){return!0})})}).catch(function(t){if(lu(t))return xr("IndexedDbPersistence","Failed to extend owner lease: ",t),n.isPrimary;if(!n.allowTabSynchronization)throw t;return xr("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1}).then(function(t){n.isPrimary!==t&&n.Se.enqueueRetryable(function(){return n.Me(t)}),n.isPrimary=t})},qc.prototype.Je=function(t){var e=this;return Bc(t).get(Oa.key).next(function(t){return tu.resolve(e.tn(t))})},qc.prototype.en=function(t){return jc(t).delete(this.clientId)},qc.prototype.nn=function(){return y(this,void 0,void 0,function(){var e,n,r,i,o=this;return g(this,function(t){switch(t.label){case 0:return!this.isPrimary||this.sn(this.$e,18e5)?[3,2]:(this.$e=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",function(t){var r=wu(t,Ha.store);return r.Nt().next(function(t){var e=o.rn(t,18e5),n=t.filter(function(t){return-1===e.indexOf(t)});return tu.forEach(n,function(t){return r.delete(t.clientId)}).next(function(){return n})})}).catch(function(){return[]})]);case 1:if(e=t.sent(),this.Ke)for(n=0,r=e;n<r.length;n++)i=r[n],this.Ke.removeItem(this.on(i.clientId));t.label=2;case 2:return[2]}})})},qc.prototype.ze=function(){var t=this;this.Oe=this.Se.enqueueAfterDelay("client_metadata_refresh",4e3,function(){return t.je().then(function(){return t.nn()}).then(function(){return t.ze()})})},qc.prototype.tn=function(t){return!!t&&t.ownerId===this.clientId},qc.prototype.Ye=function(e){var r=this;return this.Ce?tu.resolve(!0):Bc(e).get(Oa.key).next(function(t){if(null!==t&&r.sn(t.leaseTimestampMs,5e3)&&!r.cn(t.ownerId)){if(r.tn(t)&&r.networkEnabled)return!0;if(!r.tn(t)){if(!t.allowTabSynchronization)throw new Ar(Dr.FAILED_PRECONDITION,Vc);return!1}}return!(!r.networkEnabled||!r.inForeground)||jc(e).Nt().next(function(t){return void 0===r.rn(t,5e3).find(function(t){if(r.clientId!==t.clientId){var e=!r.networkEnabled&&t.networkEnabled,n=!r.inForeground&&t.inForeground,t=r.networkEnabled===t.networkEnabled;if(e||n&&t)return!0}return!1})})}).next(function(t){return r.isPrimary!==t&&xr("IndexedDbPersistence","Client "+(t?"is":"is not")+" eligible for a primary lease."),t})},qc.prototype.shutdown=function(){return y(this,void 0,void 0,function(){var n=this;return g(this,function(t){switch(t.label){case 0:return this.xe=!1,this.un(),this.Oe&&(this.Oe.cancel(),this.Oe=null),this.an(),this.hn(),[4,this.Be.runTransaction("shutdown","readwrite",[Oa.store,Ha.store],function(t){var e=new vu(t,_r.o);return n.Xe(e).next(function(){return n.en(e)})})];case 1:return t.sent(),this.Be.close(),this.ln(),[2]}})})},qc.prototype.rn=function(t,e){var n=this;return t.filter(function(t){return n.sn(t.updateTimeMs,e)&&!n.cn(t.clientId)})},qc.prototype.fn=function(){var e=this;return this.runTransaction("getActiveClients","readonly",function(t){return jc(t).Nt().next(function(t){return e.rn(t,18e5).map(function(t){return t.clientId})})})},Object.defineProperty(qc.prototype,"started",{get:function(){return this.xe},enumerable:!1,configurable:!0}),qc.prototype.getMutationQueue=function(t){return tc.Kt(t,this.R,this.Ut,this.referenceDelegate)},qc.prototype.getTargetCache=function(){return this.qe},qc.prototype.getRemoteDocumentCache=function(){return this.Ue},qc.prototype.getIndexManager=function(){return this.Ut},qc.prototype.getBundleCache=function(){return this.Qe},qc.prototype.runTransaction=function(e,n,r){var i=this;xr("IndexedDbPersistence","Starting transaction:",e);var o,t="readonly"===n?"readonly":"readwrite";return this.Be.runTransaction(e,t,Ja,function(t){return o=new vu(t,i.Ne?i.Ne.next():_r.o),"readwrite-primary"===n?i.Je(o).next(function(t){return!!t||i.Ye(o)}).next(function(t){if(!t)throw Or("Failed to obtain primary lease for action '"+e+"'."),i.isPrimary=!1,i.Se.enqueueRetryable(function(){return i.Me(!1)}),new Ar(Dr.FAILED_PRECONDITION,$a);return r(o)}).next(function(t){return i.Ze(o).next(function(){return t})}):i.dn(o).next(function(){return r(o)})}).then(function(t){return o.raiseOnCommittedEvent(),t})},qc.prototype.dn=function(t){var e=this;return Bc(t).get(Oa.key).next(function(t){if(null!==t&&e.sn(t.leaseTimestampMs,5e3)&&!e.cn(t.ownerId)&&!e.tn(t)&&!(e.Ce||e.allowTabSynchronization&&t.allowTabSynchronization))throw new Ar(Dr.FAILED_PRECONDITION,Vc)})},qc.prototype.Ze=function(t){var e=new Oa(this.clientId,this.allowTabSynchronization,Date.now());return Bc(t).put(Oa.key,e)},qc.yt=function(){return nu.yt()},qc.prototype.Xe=function(t){var e=this,n=Bc(t);return n.get(Oa.key).next(function(t){return e.tn(t)?(xr("IndexedDbPersistence","Releasing primary lease."),n.delete(Oa.key)):tu.resolve()})},qc.prototype.sn=function(t,e){var n=Date.now();return!(t<n-e||n<t&&(Or("Detected an update time that is in the future: "+t+" > "+n),1))},qc.prototype.We=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.ke=function(){t.Se.enqueueAndForget(function(){return t.inForeground="visible"===t.document.visibilityState,t.je()})},this.document.addEventListener("visibilitychange",this.ke),this.inForeground="visible"===this.document.visibilityState)},qc.prototype.an=function(){this.ke&&(this.document.removeEventListener("visibilitychange",this.ke),this.ke=null)},qc.prototype.Ge=function(){var t,e=this;"function"==typeof(null===(t=this.window)||void 0===t?void 0:t.addEventListener)&&(this.Fe=function(){e.un(),e.Se.enqueueAndForget(function(){return e.shutdown()})},this.window.addEventListener("unload",this.Fe))},qc.prototype.hn=function(){this.Fe&&(this.window.removeEventListener("unload",this.Fe),this.Fe=null)},qc.prototype.cn=function(t){try{var e=null!==(null===(e=this.Ke)||void 0===e?void 0:e.getItem(this.on(t)));return xr("IndexedDbPersistence","Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(t){return Or("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},qc.prototype.un=function(){if(this.Ke)try{this.Ke.setItem(this.on(this.clientId),String(Date.now()))}catch(t){Or("Failed to set zombie client id.",t)}},qc.prototype.ln=function(){if(this.Ke)try{this.Ke.removeItem(this.on(this.clientId))}catch(t){}},qc.prototype.on=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},qc);function qc(t,e,n,r,i,o,s,a,u,c){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.Se=i,this.window=o,this.document=s,this.De=u,this.Ce=c,this.Ne=null,this.xe=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Fe=null,this.inForeground=!1,this.ke=null,this.Oe=null,this.$e=Number.NEGATIVE_INFINITY,this.Me=function(t){return Promise.resolve()},!qc.yt())throw new Ar(Dr.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new vc(this,r),this.Le=e+"main",this.R=new _u(a),this.Be=new nu(this.Le,11,new Pc(this.R)),this.qe=new ac(this.referenceDelegate,this.R),this.Ut=new Gu,this.Ue=(e=this.R,a=this.Ut,new Nc(e,a)),this.Qe=new Vu,this.window&&this.window.localStorage?this.Ke=this.window.localStorage:(this.Ke=null,!1===c&&Or("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}function Bc(t){return wu(t,Oa.store)}function jc(t){return wu(t,Ha.store)}function Kc(t,e){var n=t.projectId;return t.isDefaultDatabase||(n+="."+t.database),"firestore/"+e+"/"+n+"/"}function Gc(t,e){this.progress=t,this.wn=e}var Qc=($c.prototype.mn=function(e,n){var r=this;return this._n.getAllMutationBatchesAffectingDocumentKey(e,n).next(function(t){return r.yn(e,n,t)})},$c.prototype.yn=function(t,e,r){return this.Ue.getEntry(t,e).next(function(t){for(var e=0,n=r;e<n.length;e++)n[e].applyToLocalView(t);return t})},$c.prototype.gn=function(t,i){t.forEach(function(t,e){for(var n=0,r=i;n<r.length;n++)r[n].applyToLocalView(e)})},$c.prototype.pn=function(e,t){var n=this;return this.Ue.getEntries(e,t).next(function(t){return n.En(e,t).next(function(){return t})})},$c.prototype.En=function(t,e){var n=this;return this._n.getAllMutationBatchesAffectingDocumentKeys(t,e).next(function(t){return n.gn(e,t)})},$c.prototype.getDocumentsMatchingQuery=function(t,e,n){return r=e,mi.isDocumentKey(r.path)&&null===r.collectionGroup&&0===r.filters.length?this.Tn(t,e.path):_o(e)?this.In(t,e,n):this.An(t,e,n);var r},$c.prototype.Tn=function(t,e){return this.mn(t,new mi(e)).next(function(t){var e=Vs;return e=t.isFoundDocument()?e.insert(t.key,t):e})},$c.prototype.In=function(n,r,i){var o=this,s=r.collectionGroup,a=Vs;return this.Ut.getCollectionParents(n,s).next(function(t){return tu.forEach(t,function(t){var e,e=(e=r,t=t.child(s),new mo(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt));return o.An(n,e,i).next(function(t){t.forEach(function(t,e){a=a.insert(t,e)})})}).next(function(){return a})})},$c.prototype.An=function(e,n,t){var c,h,r=this;return this.Ue.getDocumentsMatchingQuery(e,n,t).next(function(t){return c=t,r._n.getAllMutationBatchesAffectingQuery(e,n)}).next(function(t){return h=t,r.Rn(e,h,c).next(function(t){c=t;for(var e=0,n=h;e<n.length;e++)for(var r=n[e],i=0,o=r.mutations;i<o.length;i++){var s=o[i],a=s.key,u=c.get(a);null==u&&(u=Oi.newInvalidDocument(a),c=c.insert(a,u)),is(s,u,r.localWriteTime),u.isFoundDocument()||(c=c.remove(a))}})}).next(function(){return c.forEach(function(t,e){Ro(n,e)||(c=c.remove(t))}),c})},$c.prototype.Rn=function(t,e,n){for(var r=Bs(),i=0,o=e;i<o.length;i++)for(var s=0,a=o[i].mutations;s<a.length;s++){var u=a[s];u instanceof hs&&null===n.get(u.key)&&(r=r.add(u.key))}var c=n;return this.Ue.getEntries(t,r).next(function(t){return t.forEach(function(t,e){e.isFoundDocument()&&(c=c.insert(t,e))}),c})},$c),zc=(Jc.Pn=function(t,e){for(var n=Bs(),r=Bs(),i=0,o=e.docChanges;i<o.length;i++){var s=o[i];switch(s.type){case 0:n=n.add(s.doc.key);break;case 1:r=r.add(s.doc.key)}}return new Jc(t,e.fromCache,n,r)},Jc),Hc=(Xc.prototype.Vn=function(t){this.Sn=t},Xc.prototype.getDocumentsMatchingQuery=function(e,r,i,o){var s=this;return 0===r.filters.length&&null===r.limit&&null==r.startAt&&null==r.endAt&&(0===r.explicitOrderBy.length||1===r.explicitOrderBy.length&&r.explicitOrderBy[0].field.isKeyField())||i.isEqual(Gr.min())?this.Dn(e,r):this.Sn.pn(e,o).next(function(t){var n=s.Cn(r,t);return(wo(r)||Io(r))&&s.Nn(r.limitType,n,o,i)?s.Dn(e,r):(Rr()<=f.DEBUG&&xr("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),Co(r)),s.Sn.getDocumentsMatchingQuery(e,r,i).next(function(e){return n.forEach(function(t){e=e.insert(t.key,t)}),e}))})},Xc.prototype.Cn=function(n,t){var r=new Os(xo(n));return t.forEach(function(t,e){Ro(n,e)&&(r=r.add(e))}),r},Xc.prototype.Nn=function(t,e,n,r){if(n.size!==e.size)return!0;e="F"===t?e.last():e.first();return!!e&&(e.hasPendingWrites||0<e.version.compareTo(r))},Xc.prototype.Dn=function(t,e){return Rr()<=f.DEBUG&&xr("QueryEngine","Using full collection scan to execute query:",Co(e)),this.Sn.getDocumentsMatchingQuery(t,e,Gr.min())},Xc),Wc=(Yc.prototype.collectGarbage=function(e){var n=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",function(t){return e.collect(t,n.Fn)})},Yc);function Yc(t,e,n,r){this.persistence=t,this.xn=e,this.R=r,this.Fn=new Ns(qr),this.kn=new Sc(Fi,Vi),this.On=Gr.min(),this._n=t.getMutationQueue(n),this.$n=t.getRemoteDocumentCache(),this.qe=t.getTargetCache(),this.Mn=new Qc(this.$n,this._n,this.persistence.getIndexManager()),this.Qe=t.getBundleCache(),this.xn.Vn(this.Mn)}function Xc(){}function Jc(t,e,n,r){this.targetId=t,this.fromCache=e,this.bn=n,this.vn=r}function $c(t,e,n){this.Ue=t,this._n=e,this.Ut=n}function Zc(t,e,n,r){return new Wc(t,e,n,r)}function th(i,o){return y(this,void 0,void 0,function(){var e,n,v,r;return g(this,function(t){switch(t.label){case 0:return n=(e=i)._n,v=e.Mn,[4,e.persistence.runTransaction("Handle user change","readonly",function(g){var m;return e._n.getAllMutationBatches(g).next(function(t){return m=t,n=e.persistence.getMutationQueue(o),v=new Qc(e.$n,n,e.persistence.getIndexManager()),n.getAllMutationBatches(g)}).next(function(t){for(var e=[],n=[],r=Bs(),i=0,o=m;i<o.length;i++){var s=o[i];e.push(s.batchId);for(var a=0,u=s.mutations;a<u.length;a++)var c=u[a],r=r.add(c.key)}for(var h=0,l=t;h<l.length;h++){var f=l[h];n.push(f.batchId);for(var d=0,p=f.mutations;d<p.length;d++){var y=p[d];r=r.add(y.key)}}return v.pn(g,r).next(function(t){return{Ln:t,removedBatchIds:e,addedBatchIds:n}})})})];case 1:return r=t.sent(),[2,(e._n=n,e.Mn=v,e.xn.Vn(e.Mn),r)]}})})}function eh(t,h){var l=t;return l.persistence.runTransaction("Acknowledge batch","readwrite-primary",function(t){var e,r,i,o,s,n,a,u=h.batch.keys(),c=l.$n.newChangeBuffer({trackRemovals:!0});return e=l,r=t,o=c,s=(i=h).batch,n=s.keys(),a=tu.resolve(),n.forEach(function(n){a=a.next(function(){return o.getEntry(r,n)}).next(function(t){var e=i.docVersions.get(n);Fr(null!==e),t.version.compareTo(e)<0&&(s.applyToRemoteDocument(t,i),t.isValidDocument()&&o.addEntry(t,i.commitVersion))})}),a.next(function(){return e._n.removeMutationBatch(r,s)}).next(function(){return c.apply(t)}).next(function(){return l._n.performConsistencyCheck(t)}).next(function(){return l.Mn.pn(t,u)})})}function nh(t){var e=t;return e.persistence.runTransaction("Get last remote snapshot version","readonly",function(t){return e.qe.getLastRemoteSnapshotVersion(t)})}function rh(t,r){var u=t,c=r.snapshotVersion,h=u.Fn;return u.persistence.runTransaction("Apply remote event","readwrite-primary",function(s){var t=u.$n.newChangeBuffer({trackRemovals:!0});h=u.Fn;var a=[];r.targetChanges.forEach(function(t,e){var n,r,i,o=h.get(e);o&&(a.push(u.qe.removeMatchingKeys(s,t.removedDocuments,e).next(function(){return u.qe.addMatchingKeys(s,t.addedDocuments,e)})),0<(i=t.resumeToken).approximateByteSize()&&(n=o.withResumeToken(i,c).withSequenceNumber(s.currentSequenceNumber),h=h.insert(e,n),r=o,i=t,Fr(0<(o=n).resumeToken.approximateByteSize()),(0===r.resumeToken.approximateByteSize()||3e8<=o.snapshotVersion.toMicroseconds()-r.snapshotVersion.toMicroseconds()||0<i.addedDocuments.size+i.modifiedDocuments.size+i.removedDocuments.size)&&a.push(u.qe.updateTargetData(s,n))))});var e,n=Ps;return r.documentUpdates.forEach(function(t,e){r.resolvedLimboDocuments.has(t)&&a.push(u.persistence.referenceDelegate.updateLimboDocument(s,t))}),a.push(ih(s,t,r.documentUpdates,c,void 0).next(function(t){n=t})),c.isEqual(Gr.min())||(e=u.qe.getLastRemoteSnapshotVersion(s).next(function(t){return u.qe.setTargetsMetadata(s,s.currentSequenceNumber,c)}),a.push(e)),tu.waitFor(a).next(function(){return t.apply(s)}).next(function(){return u.Mn.En(s,n)}).next(function(){return n})}).then(function(t){return u.Fn=h,t})}function ih(t,s,e,a,u){var n=Bs();return e.forEach(function(t){return n=n.add(t)}),s.getEntries(t,n).next(function(i){var o=Ps;return e.forEach(function(t,e){var n=i.get(t),r=(null==u?void 0:u.get(t))||a;e.isNoDocument()&&e.version.isEqual(Gr.min())?(s.removeEntry(t,r),o=o.insert(t,e)):!n.isValidDocument()||0<e.version.compareTo(n.version)||0===e.version.compareTo(n.version)&&n.hasPendingWrites?(s.addEntry(e,r),o=o.insert(t,e)):xr("LocalStore","Ignoring outdated watch update for ",t,". Current version:",n.version," Watch version:",e.version)}),o})}function oh(t,r){var i=t;return i.persistence.runTransaction("Allocate target","readwrite",function(e){var n;return i.qe.getTargetData(e,r).next(function(t){return t?(n=t,tu.resolve(n)):i.qe.allocateTargetId(e).next(function(t){return n=new Tu(r,t,0,e.currentSequenceNumber),i.qe.addTargetData(e,n).next(function(){return n})})})}).then(function(t){var e=i.Fn.get(t.targetId);return(null===e||0<t.snapshotVersion.compareTo(e.snapshotVersion))&&(i.Fn=i.Fn.insert(t.targetId,t),i.kn.set(r,t.targetId)),t})}function sh(i,o,s){return y(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:n=(e=i).Fn.get(o),r=s?"readwrite":"readwrite-primary",t.label=1;case 1:return t.trys.push([1,4,,5]),s?[3,3]:[4,e.persistence.runTransaction("Release target",r,function(t){return e.persistence.referenceDelegate.removeTarget(t,n)})];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:if(!lu(r=t.sent()))throw r;return xr("LocalStore","Failed to update sequence numbers for target "+o+": "+r),[3,5];case 5:return e.Fn=e.Fn.remove(o),e.kn.delete(n.target),[2]}})})}function ah(t,o,s){var a=t,u=Gr.min(),c=Bs();return a.persistence.runTransaction("Execute query","readonly",function(e){return t=a,n=e,r=No(o),(void 0!==(t=(i=t).kn.get(r))?tu.resolve(i.Fn.get(t)):i.qe.getTargetData(n,r)).next(function(t){if(t)return u=t.lastLimboFreeSnapshotVersion,a.qe.getMatchingKeysForTargetId(e,t.targetId).next(function(t){c=t})}).next(function(){return a.xn.getDocumentsMatchingQuery(e,o,s?u:Gr.min(),s?c:Bs())}).next(function(t){return{documents:t,Bn:c}});var t,n,r,i})}function uh(t,e){var n=t,r=n.qe,t=n.Fn.get(e);return t?Promise.resolve(t.target):n.persistence.runTransaction("Get target data","readonly",function(t){return r.lt(t,e).next(function(t){return t?t.target:null})})}function ch(t){var s=t;return s.persistence.runTransaction("Get new document changes","readonly",function(t){return e=s.$n,n=t,t=s.On,r=e,i=Ps,o=Cu(t),t=Oc(n),n=IDBKeyRange.lowerBound(o,!0),t.Ot({index:Ba.readTimeIndex,range:n},function(t,e){var n=Au(r.R,e);i=i.insert(n.key,n),o=e.readTime}).next(function(){return{wn:i,readTime:Ru(o)}});var e,n,r,i,o}).then(function(t){var e=t.wn,t=t.readTime;return s.On=t,e})}function hh(n){return y(this,void 0,void 0,function(){var e;return g(this,function(t){return[2,(e=n).persistence.runTransaction("Synchronize last document change read time","readonly",function(t){return t=Oc(t),r=Gr.min(),t.Ot({index:Ba.readTimeIndex,reverse:!0},function(t,e,n){e.readTime&&(r=Ru(e.readTime)),n.done()}).next(function(){return r});var r}).then(function(t){e.On=t})]})})}var lh,fh,dh=(Lh.prototype.getBundleMetadata=function(t,e){return tu.resolve(this.Kn.get(e))},Lh.prototype.saveBundleMetadata=function(t,e){return this.Kn.set(e.id,{id:e.id,version:e.version,createTime:aa(e.createTime)}),tu.resolve()},Lh.prototype.getNamedQuery=function(t,e){return tu.resolve(this.jn.get(e))},Lh.prototype.saveNamedQuery=function(t,e){return this.jn.set(e.name,{name:(e=e).name,query:Fu(e.bundledQuery),readTime:aa(e.readTime)}),tu.resolve()},Lh),ph=(Oh.prototype.isEmpty=function(){return this.Wn.isEmpty()},Oh.prototype.addReference=function(t,e){e=new yh(t,e);this.Wn=this.Wn.add(e),this.zn=this.zn.add(e)},Oh.prototype.Jn=function(t,e){var n=this;t.forEach(function(t){return n.addReference(t,e)})},Oh.prototype.removeReference=function(t,e){this.Yn(new yh(t,e))},Oh.prototype.Xn=function(t,e){var n=this;t.forEach(function(t){return n.removeReference(t,e)})},Oh.prototype.Zn=function(t){var e=this,n=new mi(new $r([])),r=new yh(n,t),t=new yh(n,t+1),i=[];return this.zn.forEachInRange([r,t],function(t){e.Yn(t),i.push(t.key)}),i},Oh.prototype.ts=function(){var e=this;this.Wn.forEach(function(t){return e.Yn(t)})},Oh.prototype.Yn=function(t){this.Wn=this.Wn.delete(t),this.zn=this.zn.delete(t)},Oh.prototype.es=function(t){var e=new mi(new $r([])),n=new yh(e,t),t=new yh(e,t+1),r=Bs();return this.zn.forEachInRange([n,t],function(t){r=r.add(t.key)}),r},Oh.prototype.containsKey=function(t){var e=new yh(t,0),e=this.Wn.firstAfterOrEqual(e);return null!==e&&t.isEqual(e.key)},Oh),yh=(xh.Gn=function(t,e){return mi.comparator(t.key,e.key)||qr(t.ns,e.ns)},xh.Hn=function(t,e){return qr(t.ns,e.ns)||mi.comparator(t.key,e.key)},xh),gh=(Rh.prototype.checkEmpty=function(t){return tu.resolve(0===this._n.length)},Rh.prototype.addMutationBatch=function(t,e,n,r){var i=this.ss;this.ss++,0<this._n.length&&this._n[this._n.length-1];n=new Iu(i,e,n,r);this._n.push(n);for(var o=0,s=r;o<s.length;o++){var a=s[o];this.rs=this.rs.add(new yh(a.key,i)),this.Ut.addToCollectionParentIndex(t,a.key.path.popLast())}return tu.resolve(n)},Rh.prototype.lookupMutationBatch=function(t,e){return tu.resolve(this.os(e))},Rh.prototype.getNextMutationBatchAfterBatchId=function(t,e){e+=1,e=this.cs(e),e=e<0?0:e;return tu.resolve(this._n.length>e?this._n[e]:null)},Rh.prototype.getHighestUnacknowledgedBatchId=function(){return tu.resolve(0===this._n.length?-1:this.ss-1)},Rh.prototype.getAllMutationBatches=function(t){return tu.resolve(this._n.slice())},Rh.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,e){var n=this,r=new yh(e,0),e=new yh(e,Number.POSITIVE_INFINITY),i=[];return this.rs.forEachInRange([r,e],function(t){t=n.os(t.ns);i.push(t)}),tu.resolve(i)},Rh.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var n=this,r=new Os(qr);return e.forEach(function(t){var e=new yh(t,0),t=new yh(t,Number.POSITIVE_INFINITY);n.rs.forEachInRange([e,t],function(t){r=r.add(t.ns)})}),tu.resolve(this.us(r))},Rh.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var n=e.path,r=n.length+1,e=n;mi.isDocumentKey(e)||(e=e.child(""));var e=new yh(new mi(e),0),i=new Os(qr);return this.rs.forEachWhile(function(t){var e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===r&&(i=i.add(t.ns)),!0)},e),tu.resolve(this.us(i))},Rh.prototype.us=function(t){var e=this,n=[];return t.forEach(function(t){t=e.os(t);null!==t&&n.push(t)}),n},Rh.prototype.removeMutationBatch=function(n,r){var i=this;Fr(0===this.hs(r.batchId,"removed")),this._n.shift();var o=this.rs;return tu.forEach(r.mutations,function(t){var e=new yh(t.key,r.batchId);return o=o.delete(e),i.referenceDelegate.markPotentiallyOrphaned(n,t.key)}).next(function(){i.rs=o})},Rh.prototype.Gt=function(t){},Rh.prototype.containsKey=function(t,e){var n=new yh(e,0),n=this.rs.firstAfterOrEqual(n);return tu.resolve(e.isEqual(n&&n.key))},Rh.prototype.performConsistencyCheck=function(t){return this._n.length,tu.resolve()},Rh.prototype.hs=function(t,e){return this.cs(t)},Rh.prototype.cs=function(t){return 0===this._n.length?0:t-this._n[0].batchId},Rh.prototype.os=function(t){t=this.cs(t);return t<0||t>=this._n.length?null:this._n[t]},Rh),mh=(Ch.prototype.addEntry=function(t,e,n){var r=e.key,i=this.docs.get(r),o=i?i.size:0,i=this.ls(e);return this.docs=this.docs.insert(r,{document:e.clone(),size:i,readTime:n}),this.size+=i-o,this.Ut.addToCollectionParentIndex(t,r.path.popLast())},Ch.prototype.removeEntry=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},Ch.prototype.getEntry=function(t,e){var n=this.docs.get(e);return tu.resolve(n?n.document.clone():Oi.newInvalidDocument(e))},Ch.prototype.getEntries=function(t,e){var n=this,r=Ps;return e.forEach(function(t){var e=n.docs.get(t);r=r.insert(t,e?e.document.clone():Oi.newInvalidDocument(t))}),tu.resolve(r)},Ch.prototype.getDocumentsMatchingQuery=function(t,e,n){for(var r=Ps,i=new mi(e.path.child("")),o=this.docs.getIteratorFrom(i);o.hasNext();){var s=o.getNext(),a=s.key,u=s.value,s=u.document,u=u.readTime;if(!e.path.isPrefixOf(a.path))break;u.compareTo(n)<=0||Ro(e,s)&&(r=r.insert(s.key,s.clone()))}return tu.resolve(r)},Ch.prototype.fs=function(t,e){return tu.forEach(this.docs,function(t){return e(t)})},Ch.prototype.newChangeBuffer=function(t){return new vh(this)},Ch.prototype.getSize=function(t){return tu.resolve(this.size)},Ch),vh=(n(kh,fh=I),kh.prototype.applyChanges=function(n){var r=this,i=[];return this.changes.forEach(function(t,e){e.document.isValidDocument()?i.push(r.Ie.addEntry(n,e.document,r.getReadTime(t))):r.Ie.removeEntry(t)}),tu.waitFor(i)},kh.prototype.getFromCache=function(t,e){return this.Ie.getEntry(t,e)},kh.prototype.getAllFromCache=function(t,e){return this.Ie.getEntries(t,e)},kh),bh=(Ah.prototype.forEachTarget=function(t,n){return this.ds.forEach(function(t,e){return n(e)}),tu.resolve()},Ah.prototype.getLastRemoteSnapshotVersion=function(t){return tu.resolve(this.lastRemoteSnapshotVersion)},Ah.prototype.getHighestSequenceNumber=function(t){return tu.resolve(this.ws)},Ah.prototype.allocateTargetId=function(t){return this.highestTargetId=this.ys.next(),tu.resolve(this.highestTargetId)},Ah.prototype.setTargetsMetadata=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.ws&&(this.ws=e),tu.resolve()},Ah.prototype.te=function(t){this.ds.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.ys=new sc(e),this.highestTargetId=e),t.sequenceNumber>this.ws&&(this.ws=t.sequenceNumber)},Ah.prototype.addTargetData=function(t,e){return this.te(e),this.targetCount+=1,tu.resolve()},Ah.prototype.updateTargetData=function(t,e){return this.te(e),tu.resolve()},Ah.prototype.removeTargetData=function(t,e){return this.ds.delete(e.target),this._s.Zn(e.targetId),--this.targetCount,tu.resolve()},Ah.prototype.removeTargets=function(n,r,i){var o=this,s=0,a=[];return this.ds.forEach(function(t,e){e.sequenceNumber<=r&&null===i.get(e.targetId)&&(o.ds.delete(t),a.push(o.removeMatchingKeysForTargetId(n,e.targetId)),s++)}),tu.waitFor(a).next(function(){return s})},Ah.prototype.getTargetCount=function(t){return tu.resolve(this.targetCount)},Ah.prototype.getTargetData=function(t,e){e=this.ds.get(e)||null;return tu.resolve(e)},Ah.prototype.addMatchingKeys=function(t,e,n){return this._s.Jn(e,n),tu.resolve()},Ah.prototype.removeMatchingKeys=function(e,t,n){this._s.Xn(t,n);var r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(function(t){i.push(r.markPotentiallyOrphaned(e,t))}),tu.waitFor(i)},Ah.prototype.removeMatchingKeysForTargetId=function(t,e){return this._s.Zn(e),tu.resolve()},Ah.prototype.getMatchingKeysForTargetId=function(t,e){e=this._s.es(e);return tu.resolve(e)},Ah.prototype.containsKey=function(t,e){return tu.resolve(this._s.containsKey(e))},Ah),wh=(Dh.prototype.start=function(){return Promise.resolve()},Dh.prototype.shutdown=function(){return this.xe=!1,Promise.resolve()},Object.defineProperty(Dh.prototype,"started",{get:function(){return this.xe},enumerable:!1,configurable:!0}),Dh.prototype.setDatabaseDeletedListener=function(){},Dh.prototype.setNetworkEnabled=function(){},Dh.prototype.getIndexManager=function(){return this.Ut},Dh.prototype.getMutationQueue=function(t){var e=this.gs[t.toKey()];return e||(e=new gh(this.Ut,this.referenceDelegate),this.gs[t.toKey()]=e),e},Dh.prototype.getTargetCache=function(){return this.qe},Dh.prototype.getRemoteDocumentCache=function(){return this.Ue},Dh.prototype.getBundleCache=function(){return this.Qe},Dh.prototype.runTransaction=function(t,e,n){var r=this;xr("MemoryPersistence","Starting transaction:",t);var i=new Ih(this.Ne.next());return this.referenceDelegate.Es(),n(i).next(function(t){return r.referenceDelegate.Ts(i).next(function(){return t})}).toPromise().then(function(t){return i.raiseOnCommittedEvent(),t})},Dh.prototype.Is=function(e,n){return tu.or(Object.values(this.gs).map(function(t){return function(){return t.containsKey(e,n)}}))},Dh),Ih=(n(Nh,lh=Te),Nh),Eh=(Sh.bs=function(t){return new Sh(t)},Object.defineProperty(Sh.prototype,"vs",{get:function(){if(this.Rs)return this.Rs;throw Mr()},enumerable:!1,configurable:!0}),Sh.prototype.addReference=function(t,e,n){return this.As.addReference(n,e),this.vs.delete(n.toString()),tu.resolve()},Sh.prototype.removeReference=function(t,e,n){return this.As.removeReference(n,e),this.vs.add(n.toString()),tu.resolve()},Sh.prototype.markPotentiallyOrphaned=function(t,e){return this.vs.add(e.toString()),tu.resolve()},Sh.prototype.removeTarget=function(t,e){var n=this;this.As.Zn(e.targetId).forEach(function(t){return n.vs.add(t.toString())});var r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(t,e.targetId).next(function(t){t.forEach(function(t){return n.vs.add(t.toString())})}).next(function(){return r.removeTargetData(t,e)})},Sh.prototype.Es=function(){this.Rs=new Set},Sh.prototype.Ts=function(n){var r=this,i=this.persistence.getRemoteDocumentCache().newChangeBuffer();return tu.forEach(this.vs,function(t){var e=mi.fromPath(t);return r.Ps(n,e).next(function(t){t||i.removeEntry(e)})}).next(function(){return r.Rs=null,i.apply(n)})},Sh.prototype.updateLimboDocument=function(t,e){var n=this;return this.Ps(t,e).next(function(t){t?n.vs.delete(e.toString()):n.vs.add(e.toString())})},Sh.prototype.ps=function(t){return 0},Sh.prototype.Ps=function(t,e){var n=this;return tu.or([function(){return tu.resolve(n.As.containsKey(e))},function(){return n.persistence.getTargetCache().containsKey(t,e)},function(){return n.persistence.Is(t,e)}])},Sh),Th=(_h.prototype.isAuthenticated=function(){return null!=this.uid},_h.prototype.toKey=function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"},_h.prototype.isEqual=function(t){return t.uid===this.uid},_h);function _h(t){this.uid=t}function Sh(t){this.persistence=t,this.As=new ph,this.Rs=null}function Nh(t){var e=this;return(e=lh.call(this)||this).currentSequenceNumber=t,e}function Dh(t,e){var n=this;this.gs={},this.Ne=new _r(0),this.xe=!1,this.xe=!0,this.referenceDelegate=t(this),this.qe=new bh(this),this.Ut=new ju,this.Ue=(t=this.Ut,new mh(t,function(t){return n.referenceDelegate.ps(t)})),this.R=new _u(e),this.Qe=new dh(this.R)}function Ah(t){this.persistence=t,this.ds=new Sc(Fi,Vi),this.lastRemoteSnapshotVersion=Gr.min(),this.highestTargetId=0,this.ws=0,this._s=new ph,this.targetCount=0,this.ys=sc.Jt()}function kh(t){var e=this;return(e=fh.call(this)||this).Ie=t,e}function Ch(t,e){this.Ut=t,this.ls=e,this.docs=new Ns(mi.comparator),this.size=0}function Rh(t,e){this.Ut=t,this.referenceDelegate=e,this._n=[],this.ss=1,this.rs=new Os(yh.Gn)}function xh(t,e){this.key=t,this.ns=e}function Oh(){this.Wn=new Os(yh.Gn),this.zn=new Os(yh.Hn)}function Lh(t){this.R=t,this.Kn=new Map,this.jn=new Map}function Ph(t,e){return"firestore_clients_"+t+"_"+e}function Mh(t,e,n){n="firestore_mutations_"+t+"_"+n;return e.isAuthenticated()&&(n+="_"+e.uid),n}function Fh(t,e){return"firestore_targets_"+t+"_"+e}Th.UNAUTHENTICATED=new Th(null),Th.GOOGLE_CREDENTIALS=new Th("google-credentials-uid"),Th.FIRST_PARTY=new Th("first-party-uid");var Vh,Uh=(ul.Vs=function(t,e,n){var r,i=JSON.parse(n),o="object"==typeof i&&-1!==["pending","acknowledged","rejected"].indexOf(i.state)&&(void 0===i.error||"object"==typeof i.error);return o&&i.error&&(o="string"==typeof i.error.message&&"string"==typeof i.error.code)&&(r=new Ar(i.error.code,i.error.message)),o?new ul(t,e,i.state,r):(Or("SharedClientState","Failed to parse mutation state for ID '"+e+"': "+n),null)},ul.prototype.Ss=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},ul),qh=(al.Vs=function(t,e){var n,r=JSON.parse(e),i="object"==typeof r&&-1!==["not-current","current","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error);return i&&r.error&&(i="string"==typeof r.error.message&&"string"==typeof r.error.code)&&(n=new Ar(r.error.code,r.error.message)),i?new al(t,r.state,n):(Or("SharedClientState","Failed to parse target state for ID '"+t+"': "+e),null)},al.prototype.Ss=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},al),Bh=(sl.Vs=function(t,e){for(var n=JSON.parse(e),r="object"==typeof n&&n.activeTargetIds instanceof Array,i=js,o=0;r&&o<n.activeTargetIds.length;++o)r=gi(n.activeTargetIds[o]),i=i.add(n.activeTargetIds[o]);return r?new sl(t,i):(Or("SharedClientState","Failed to parse client data for instance '"+t+"': "+e),null)},sl),jh=(ol.Vs=function(t){var e=JSON.parse(t);return"object"==typeof e&&-1!==["Unknown","Online","Offline"].indexOf(e.onlineState)&&"string"==typeof e.clientId?new ol(e.clientId,e.onlineState):(Or("SharedClientState","Failed to parse online state: "+t),null)},ol),Kh=(il.prototype.Ds=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},il.prototype.Cs=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},il.prototype.Ss=function(){var t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)},il),Gh=(rl.yt=function(t){return!(!t||!t.localStorage)},rl.prototype.start=function(){return y(this,void 0,void 0,function(){var e,n,r,i,o,s,a,u,c,h,l=this;return g(this,function(t){switch(t.label){case 0:return[4,this.syncEngine.fn()];case 1:for(s=t.sent(),e=0,n=s;e<n.length;e++)(r=n[e])!==this.Ns&&(i=this.getItem(Ph(this.persistenceKey,r)))&&(o=Bh.Vs(r,i))&&(this.ks=this.ks.insert(o.clientId,o));for(this.Ks(),(s=this.storage.getItem(this.Us))&&(a=this.js(s))&&this.Ws(a),u=0,c=this.Os;u<c.length;u++)h=c[u],this.Fs(h);return this.Os=[],this.window.addEventListener("unload",function(){return l.shutdown()}),this.started=!0,[2]}})})},rl.prototype.writeSequenceNumber=function(t){this.setItem(this.Ms,JSON.stringify(t))},rl.prototype.getAllActiveQueryTargets=function(){return this.Gs(this.ks)},rl.prototype.isActiveQueryTarget=function(n){var r=!1;return this.ks.forEach(function(t,e){e.activeTargetIds.has(n)&&(r=!0)}),r},rl.prototype.addPendingMutation=function(t){this.zs(t,"pending")},rl.prototype.updateMutationState=function(t,e,n){this.zs(t,e,n),this.Hs(t)},rl.prototype.addLocalQueryTarget=function(t){var e,n="not-current";return this.isActiveQueryTarget(t)&&(!(e=this.storage.getItem(Fh(this.persistenceKey,t)))||(e=qh.Vs(t,e))&&(n=e.state)),this.Js.Ds(t),this.Ks(),n},rl.prototype.removeLocalQueryTarget=function(t){this.Js.Cs(t),this.Ks()},rl.prototype.isLocalQueryTarget=function(t){return this.Js.activeTargetIds.has(t)},rl.prototype.clearQueryState=function(t){this.removeItem(Fh(this.persistenceKey,t))},rl.prototype.updateQueryState=function(t,e,n){this.Ys(t,e,n)},rl.prototype.handleUserChange=function(t,e,n){var r=this;e.forEach(function(t){r.Hs(t)}),this.currentUser=t,n.forEach(function(t){r.addPendingMutation(t)})},rl.prototype.setOnlineState=function(t){this.Xs(t)},rl.prototype.notifyBundleLoaded=function(){this.Zs()},rl.prototype.shutdown=function(){this.started&&(this.window.removeEventListener("storage",this.xs),this.removeItem(this.$s),this.started=!1)},rl.prototype.getItem=function(t){var e=this.storage.getItem(t);return xr("SharedClientState","READ",t,e),e},rl.prototype.setItem=function(t,e){xr("SharedClientState","SET",t,e),this.storage.setItem(t,e)},rl.prototype.removeItem=function(t){xr("SharedClientState","REMOVE",t),this.storage.removeItem(t)},rl.prototype.Fs=function(t){var e=this,o=t;o.storageArea===this.storage&&(xr("SharedClientState","EVENT",o.key,o.newValue),o.key!==this.$s?this.Se.enqueueRetryable(function(){return y(e,void 0,void 0,function(){var e,n,r,i;return g(this,function(t){if(this.started){if(null!==o.key)if(this.Ls.test(o.key)){if(null==o.newValue)return e=this.ti(o.key),[2,this.ei(e,null)];if(e=this.ni(o.key,o.newValue))return[2,this.ei(e.clientId,e)]}else if(this.Bs.test(o.key)){if(null!==o.newValue&&(n=this.si(o.key,o.newValue)))return[2,this.ii(n)]}else if(this.qs.test(o.key)){if(null!==o.newValue&&(r=this.ri(o.key,o.newValue)))return[2,this.oi(r)]}else if(o.key===this.Us){if(null!==o.newValue&&(i=this.js(o.newValue)))return[2,this.Ws(i)]}else if(o.key===this.Ms)(i=function(t){var e=_r.o;if(null!=t)try{var n=JSON.parse(t);Fr("number"==typeof n),e=n}catch(t){Or("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(o.newValue))!==_r.o&&this.sequenceNumberHandler(i);else if(o.key===this.Qs)return[2,this.syncEngine.ci()]}else this.Os.push(o);return[2]})})}):Or("Received WebStorage notification for local change. Another client might have garbage-collected our state"))},Object.defineProperty(rl.prototype,"Js",{get:function(){return this.ks.get(this.Ns)},enumerable:!1,configurable:!0}),rl.prototype.Ks=function(){this.setItem(this.$s,this.Js.Ss())},rl.prototype.zs=function(t,e,n){n=new Uh(this.currentUser,t,e,n),t=Mh(this.persistenceKey,this.currentUser,t);this.setItem(t,n.Ss())},rl.prototype.Hs=function(t){t=Mh(this.persistenceKey,this.currentUser,t);this.removeItem(t)},rl.prototype.Xs=function(t){t={clientId:this.Ns,onlineState:t};this.storage.setItem(this.Us,JSON.stringify(t))},rl.prototype.Ys=function(t,e,n){var r=Fh(this.persistenceKey,t),n=new qh(t,e,n);this.setItem(r,n.Ss())},rl.prototype.Zs=function(){this.setItem(this.Qs,"value-not-used")},rl.prototype.ti=function(t){t=this.Ls.exec(t);return t?t[1]:null},rl.prototype.ni=function(t,e){t=this.ti(t);return Bh.Vs(t,e)},rl.prototype.si=function(t,e){var n=this.Bs.exec(t),t=Number(n[1]),n=void 0!==n[2]?n[2]:null;return Uh.Vs(new Th(n),t,e)},rl.prototype.ri=function(t,e){t=this.qs.exec(t),t=Number(t[1]);return qh.Vs(t,e)},rl.prototype.js=function(t){return jh.Vs(t)},rl.prototype.ii=function(e){return y(this,void 0,void 0,function(){return g(this,function(t){return e.user.uid===this.currentUser.uid?[2,this.syncEngine.ui(e.batchId,e.state,e.error)]:(xr("SharedClientState","Ignoring mutation for non-active user "+e.user.uid),[2])})})},rl.prototype.oi=function(t){return this.syncEngine.ai(t.targetId,t.state,t.error)},rl.prototype.ei=function(t,e){var n=this,r=e?this.ks.insert(t,e):this.ks.remove(t),i=this.Gs(this.ks),o=this.Gs(r),s=[],a=[];return o.forEach(function(t){i.has(t)||s.push(t)}),i.forEach(function(t){o.has(t)||a.push(t)}),this.syncEngine.hi(s,a).then(function(){n.ks=r})},rl.prototype.Ws=function(t){this.ks.get(t.clientId)&&this.onlineStateHandler(t.onlineState)},rl.prototype.Gs=function(t){var n=js;return t.forEach(function(t,e){n=n.unionWith(e.activeTargetIds)}),n},rl),Qh=(nl.prototype.addPendingMutation=function(t){},nl.prototype.updateMutationState=function(t,e,n){},nl.prototype.addLocalQueryTarget=function(t){return this.li.Ds(t),this.fi[t]||"not-current"},nl.prototype.updateQueryState=function(t,e,n){this.fi[t]=e},nl.prototype.removeLocalQueryTarget=function(t){this.li.Cs(t)},nl.prototype.isLocalQueryTarget=function(t){return this.li.activeTargetIds.has(t)},nl.prototype.clearQueryState=function(t){delete this.fi[t]},nl.prototype.getAllActiveQueryTargets=function(){return this.li.activeTargetIds},nl.prototype.isActiveQueryTarget=function(t){return this.li.activeTargetIds.has(t)},nl.prototype.start=function(){return this.li=new Kh,Promise.resolve()},nl.prototype.handleUserChange=function(t,e,n){},nl.prototype.setOnlineState=function(t){},nl.prototype.shutdown=function(){},nl.prototype.writeSequenceNumber=function(t){},nl.prototype.notifyBundleLoaded=function(){},nl),zh=(el.prototype.di=function(t){},el.prototype.shutdown=function(){},el),Hh=(tl.prototype.di=function(t){this.gi.push(t)},tl.prototype.shutdown=function(){window.removeEventListener("online",this.wi),window.removeEventListener("offline",this.mi)},tl.prototype.pi=function(){window.addEventListener("online",this.wi),window.addEventListener("offline",this.mi)},tl.prototype._i=function(){xr("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.gi;t<e.length;t++)(0,e[t])(0)},tl.prototype.yi=function(){xr("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.gi;t<e.length;t++)(0,e[t])(1)},tl.yt=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},tl),Wh={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"},Yh=(Zh.prototype.Ii=function(t){this.Ai=t},Zh.prototype.Ri=function(t){this.bi=t},Zh.prototype.onMessage=function(t){this.vi=t},Zh.prototype.close=function(){this.Ti()},Zh.prototype.send=function(t){this.Ei(t)},Zh.prototype.Pi=function(){this.Ai()},Zh.prototype.Vi=function(t){this.bi(t)},Zh.prototype.Si=function(t){this.vi(t)},Zh),Xh=($h.prototype.Ni=function(e,t,n,r){var i=this.xi(e,t);xr("RestConnection","Sending: ",i,n);t={};return this.Fi(t,r),this.ki(e,i,t,n).then(function(t){return xr("RestConnection","Received: ",t),t},function(t){throw Lr("RestConnection",e+" failed with error: ",t,"url: ",i,"request:",n),t})},$h.prototype.Oi=function(t,e,n,r){return this.Ni(t,e,n,r)},$h.prototype.Fi=function(t,e){if(t["X-Goog-Api-Client"]="gl-js/ fire/8.4.2",t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e)for(var n in e.authHeaders)e.authHeaders.hasOwnProperty(n)&&(t[n]=e.authHeaders[n])},$h.prototype.xi=function(t,e){t=Wh[t];return this.Di+"/v1/"+e+":"+t},n(Jh,Vh=$h),Jh.prototype.ki=function(o,e,s,a){return new Promise(function(n,r){var i=new Tr;i.listenOnce(vr.COMPLETE,function(){try{switch(i.getLastErrorCode()){case mr.NO_ERROR:var t=i.getResponseJson();xr("Connection","XHR received:",JSON.stringify(t)),n(t);break;case mr.TIMEOUT:xr("Connection",'RPC "'+o+'" timed out'),r(new Ar(Dr.DEADLINE_EXCEEDED,"Request time out"));break;case mr.HTTP_ERROR:var e=i.getStatus();xr("Connection",'RPC "'+o+'" failed with status:',e,"response text:",i.getResponseText()),0<e?(t=i.getResponseJson().error)&&t.status&&t.message?(e=t.status.toLowerCase().replace(/_/g,"-"),e=0<=Object.values(Dr).indexOf(e)?e:Dr.UNKNOWN,r(new Ar(e,t.message))):r(new Ar(Dr.UNKNOWN,"Server responded with status "+i.getStatus())):r(new Ar(Dr.UNAVAILABLE,"Connection failed."));break;default:Mr()}}finally{xr("Connection",'RPC "'+o+'" completed.')}});var t=JSON.stringify(a);i.send(e,"POST",t,s,15)})},Jh.prototype.$i=function(t,e){var n,r=[this.Di,"/","google.firestore.v1.Firestore","/",t,"/channel"],i=new lr,o=gr(),t={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.Fi(t.initMessageHeaders,e),"undefined"!=typeof window&&(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(h())||"object"==typeof navigator&&"ReactNative"===navigator.product||0<=h().indexOf("Electron/")||(0<=(n=h()).indexOf("MSIE ")||0<=n.indexOf("Trident/"))||0<=h().indexOf("MSAppHost/")||"object"==typeof(n="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0)&&void 0!==n.id||(t.httpHeadersOverwriteParam="$httpHeaders");r=r.join("");xr("Connection","Creating WebChannel: "+r,t);var s=i.createWebChannel(r,t),a=!1,u=!1,c=new Yh({Ei:function(t){u?xr("Connection","Not sending because WebChannel is closed:",t):(a||(xr("Connection","Opening WebChannel transport."),s.open(),a=!0),xr("Connection","WebChannel sending:",t),s.send(t))},Ti:function(){return s.close()}}),t=function(t,e,n){t.listen(e,function(t){try{n(t)}catch(t){setTimeout(function(){throw t},0)}})};return t(s,Er.EventType.OPEN,function(){u||xr("Connection","WebChannel transport opened.")}),t(s,Er.EventType.CLOSE,function(){u||(u=!0,xr("Connection","WebChannel transport closed"),c.Vi())}),t(s,Er.EventType.ERROR,function(t){u||(u=!0,Lr("Connection","WebChannel transport errored:",t),c.Vi(new Ar(Dr.UNAVAILABLE,"The operation could not be completed")))}),t(s,Er.EventType.MESSAGE,function(t){var e,n,r,i;u||(Fr(!!(e=t.data[0])),(n=e.error||(null===(i=e[0])||void 0===i?void 0:i.error))?(xr("Connection","WebChannel received error:",n),r=n.status,t=function(){var t=ms[r];if(void 0!==t)return Ss(t)}(),i=n.message,void 0===t&&(t=Dr.INTERNAL,i="Unknown error status: "+r+" with message "+n.message),u=!0,c.Vi(new Ar(t,i)),s.close()):(xr("Connection","WebChannel received:",e),c.Si(e)))}),t(o,br.STAT_EVENT,function(t){t.stat===wr?xr("Connection","Detected buffering proxy"):t.stat===Ir&&xr("Connection","Detected no buffering proxy")}),setTimeout(function(){c.Pi()},0),c},Jh);function Jh(t){var e=this;return(e=Vh.call(this,t)||this).forceLongPolling=t.forceLongPolling,e.autoDetectLongPolling=t.autoDetectLongPolling,e}function $h(t){this.databaseInfo=t,this.databaseId=t.databaseId;var e=t.ssl?"https":"http";this.Di=e+"://"+t.host,this.Ci="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}function Zh(t){this.Ei=t.Ei,this.Ti=t.Ti}function tl(){var t=this;this.wi=function(){return t._i()},this.mi=function(){return t.yi()},this.gi=[],this.pi()}function el(){}function nl(){this.li=new Kh,this.fi={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}function rl(t,e,n,r,i){this.window=t,this.Se=e,this.persistenceKey=n,this.Ns=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.xs=this.Fs.bind(this),this.ks=new Ns(qr),this.started=!1,this.Os=[];n=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.$s=Ph(this.persistenceKey,this.Ns),this.Ms="firestore_sequence_number_"+this.persistenceKey,this.ks=this.ks.insert(this.Ns,new Kh),this.Ls=new RegExp("^firestore_clients_"+n+"_([^_]*)$"),this.Bs=new RegExp("^firestore_mutations_"+n+"_(\\d+)(?:_(.*))?$"),this.qs=new RegExp("^firestore_targets_"+n+"_(\\d+)$"),this.Us="firestore_online_state_"+this.persistenceKey,this.Qs="firestore_bundle_loaded_"+this.persistenceKey,this.window.addEventListener("storage",this.xs)}function il(){this.activeTargetIds=js}function ol(t,e){this.clientId=t,this.onlineState=e}function sl(t,e){this.clientId=t,this.activeTargetIds=e}function al(t,e,n){this.targetId=t,this.state=e,this.error=n}function ul(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}function cl(){return"undefined"!=typeof window?window:null}function hl(){return"undefined"!=typeof document?document:null}function ll(t){return new ia(t,!0)}function fl(t,e,n,r,i){var o=this;this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.kr=[],this.Or=new Map,this.$r=new Set,this.Mr=[],this.Lr=i,this.Lr.di(function(t){n.enqueueAndForget(function(){return y(o,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return Pl(this)?(xr("RemoteStore","Restarting streams for network reachability change."),[4,function(n){return y(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return(e=n).$r.add(4),[4,Al(e)];case 1:return t.sent(),e.Br.set("Unknown"),e.$r.delete(4),[4,Dl(e)];case 2:return t.sent(),[2]}})})}(this)]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})})}),this.Br=new wl(n,r)}var dl,pl,yl,gl=(Nl.prototype.reset=function(){this.qi=0},Nl.prototype.Ki=function(){this.qi=this.Bi},Nl.prototype.ji=function(t){var e=this;this.cancel();var n=Math.floor(this.qi+this.Wi()),r=Math.max(0,Date.now()-this.Qi),i=Math.max(0,n-r);0<i&&xr("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.qi+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.Ui=this.Se.enqueueAfterDelay(this.timerId,i,function(){return e.Qi=Date.now(),t()}),this.qi*=this.Li,this.qi<this.Mi&&(this.qi=this.Mi),this.qi>this.Bi&&(this.qi=this.Bi)},Nl.prototype.Gi=function(){null!==this.Ui&&(this.Ui.skipDelay(),this.Ui=null)},Nl.prototype.cancel=function(){null!==this.Ui&&(this.Ui.cancel(),this.Ui=null)},Nl.prototype.Wi=function(){return(Math.random()-.5)*this.qi},Nl),I=(Sl.prototype.tr=function(){return 1===this.state||2===this.state||4===this.state},Sl.prototype.er=function(){return 2===this.state},Sl.prototype.start=function(){3!==this.state?this.auth():this.nr()},Sl.prototype.stop=function(){return y(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return this.tr()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},Sl.prototype.sr=function(){this.state=0,this.Zi.reset()},Sl.prototype.ir=function(){var t=this;this.er()&&null===this.Xi&&(this.Xi=this.Se.enqueueAfterDelay(this.zi,6e4,function(){return t.rr()}))},Sl.prototype.cr=function(t){this.ur(),this.stream.send(t)},Sl.prototype.rr=function(){return y(this,void 0,void 0,function(){return g(this,function(t){return this.er()?[2,this.close(0)]:[2]})})},Sl.prototype.ur=function(){this.Xi&&(this.Xi.cancel(),this.Xi=null)},Sl.prototype.close=function(e,n){return y(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return this.ur(),this.Zi.cancel(),this.Yi++,3!==e?this.Zi.reset():n&&n.code===Dr.RESOURCE_EXHAUSTED?(Or(n.toString()),Or("Using maximum backoff delay to prevent overloading the backend."),this.Zi.Ki()):n&&n.code===Dr.UNAUTHENTICATED&&this.Ji.invalidateToken(),null!==this.stream&&(this.ar(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.Ri(n)];case 1:return t.sent(),[2]}})})},Sl.prototype.ar=function(){},Sl.prototype.auth=function(){var n=this;this.state=1;var t=this.hr(this.Yi),e=this.Yi;this.Ji.getToken().then(function(t){n.Yi===e&&n.lr(t)},function(e){t(function(){var t=new Ar(Dr.UNKNOWN,"Fetching auth token failed: "+e.message);return n.dr(t)})})},Sl.prototype.lr=function(t){var e=this,n=this.hr(this.Yi);this.stream=this.wr(t),this.stream.Ii(function(){n(function(){return e.state=2,e.listener.Ii()})}),this.stream.Ri(function(t){n(function(){return e.dr(t)})}),this.stream.onMessage(function(t){n(function(){return e.onMessage(t)})})},Sl.prototype.nr=function(){var t=this;this.state=4,this.Zi.ji(function(){return y(t,void 0,void 0,function(){return g(this,function(t){return this.state=0,this.start(),[2]})})})},Sl.prototype.dr=function(t){return xr("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},Sl.prototype.hr=function(e){var n=this;return function(t){n.Se.enqueueAndForget(function(){return n.Yi===e?t():(xr("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},Sl),ml=(n(_l,yl=I),_l.prototype.wr=function(t){return this.Hi.$i("Listen",t)},_l.prototype.onMessage=function(t){this.Zi.reset();var e=function(t,e){if("targetChange"in e){e.targetChange;var n="NO_CHANGE"===(o=e.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===o?1:"REMOVE"===o?2:"CURRENT"===o?3:"RESET"===o?4:Mr(),r=e.targetChange.targetIds||[],i=(s=e.targetChange.resumeToken,t.I?(Fr(void 0===s||"string"==typeof s),ni.fromBase64String(s||"")):(Fr(void 0===s||s instanceof Uint8Array),ni.fromUint8Array(s||new Uint8Array))),o=(a=e.targetChange.cause)&&(u=void 0===(c=a).code?Dr.UNKNOWN:Ss(c.code),new Ar(u,c.message||"")),s=new Hs(n,r,i,o||null)}else if("documentChange"in e){e.documentChange,(n=e.documentChange).document,n.document.name,n.document.updateTime;var r=la(t,n.document.name),i=aa(n.document.updateTime),a=new Ri({mapValue:{fields:n.document.fields}}),u=(o=Oi.newFoundDocument(r,i,a),n.targetIds||[]),c=n.removedTargetIds||[];s=new Qs(u,c,o.key,o)}else if("documentDelete"in e)e.documentDelete,(n=e.documentDelete).document,r=la(t,n.document),i=n.readTime?aa(n.readTime):Gr.min(),a=Oi.newNoDocument(r,i),o=n.removedTargetIds||[],s=new Qs([],o,a.key,a);else if("documentRemove"in e)e.documentRemove,(n=e.documentRemove).document,r=la(t,n.document),i=n.removedTargetIds||[],s=new Qs([],i,r,null);else{if(!("filter"in e))return Mr();e.filter;e=e.filter;e.targetId,n=e.count||0,r=new gs(n),i=e.targetId,s=new zs(i,r)}return s}(this.R,t),t=function(t){if(!("targetChange"in t))return Gr.min();t=t.targetChange;return(!t.targetIds||!t.targetIds.length)&&t.readTime?aa(t.readTime):Gr.min()}(t);return this.listener._r(e,t)},_l.prototype.mr=function(t){var e,n,r,i={};i.database=pa(this.R),i.addTarget=(e=this.R,(r=Ui(r=(n=t).target)?{documents:wa(e,r)}:{query:Ia(e,r)}).targetId=n.targetId,0<n.resumeToken.approximateByteSize()?r.resumeToken=sa(e,n.resumeToken):0<n.snapshotVersion.compareTo(Gr.min())&&(r.readTime=oa(e,n.snapshotVersion.toTimestamp())),r);var o,t=(this.R,o=t,null==(t=function(){switch(o.purpose){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return Mr()}}())?null:{"goog-listen-tags":t});t&&(i.labels=t),this.cr(i)},_l.prototype.yr=function(t){var e={};e.database=pa(this.R),e.removeTarget=t,this.cr(e)},_l),vl=(n(Tl,pl=I),Object.defineProperty(Tl.prototype,"pr",{get:function(){return this.gr},enumerable:!1,configurable:!0}),Tl.prototype.start=function(){this.gr=!1,this.lastStreamToken=void 0,pl.prototype.start.call(this)},Tl.prototype.ar=function(){this.gr&&this.Er([])},Tl.prototype.wr=function(t){return this.Hi.$i("Write",t)},Tl.prototype.onMessage=function(t){if(Fr(!!t.streamToken),this.lastStreamToken=t.streamToken,this.gr){this.Zi.reset();var e=(n=t.writeResults,r=t.commitTime,n&&0<n.length?(Fr(void 0!==r),n.map(function(t){return n=r,(t=(e=t).updateTime?aa(e.updateTime):aa(n)).isEqual(Gr.min())&&(t=aa(n)),new Zo(t,e.transformResults||[]);var e,n})):[]),n=aa(t.commitTime);return this.listener.Tr(n,e)}var n,r;return Fr(!t.writeResults||0===t.writeResults.length),this.gr=!0,this.listener.Ir()},Tl.prototype.Ar=function(){var t={};t.database=pa(this.R),this.cr(t)},Tl.prototype.Er=function(t){var e=this,t={streamToken:this.lastStreamToken,writes:t.map(function(t){return va(e.R,t)})};this.cr(t)},Tl),bl=(n(El,dl=function(){}),El.prototype.br=function(){if(this.Rr)throw new Ar(Dr.FAILED_PRECONDITION,"The client has already been terminated.")},El.prototype.Ni=function(e,n,r){var i=this;return this.br(),this.credentials.getToken().then(function(t){return i.Hi.Ni(e,n,r,t)}).catch(function(t){throw"FirebaseError"===t.name?(t.code===Dr.UNAUTHENTICATED&&i.credentials.invalidateToken(),t):new Ar(Dr.UNKNOWN,t.toString())})},El.prototype.Oi=function(e,n,r){var i=this;return this.br(),this.credentials.getToken().then(function(t){return i.Hi.Oi(e,n,r,t)}).catch(function(t){throw"FirebaseError"===t.name?(t.code===Dr.UNAUTHENTICATED&&i.credentials.invalidateToken(),t):new Ar(Dr.UNKNOWN,t.toString())})},El.prototype.terminate=function(){this.Rr=!0},El),wl=(Il.prototype.Sr=function(){var t=this;0===this.vr&&(this.Dr("Unknown"),this.Pr=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,function(){return t.Pr=null,t.Cr("Backend didn't respond within 10 seconds."),t.Dr("Offline"),Promise.resolve()}))},Il.prototype.Nr=function(t){"Online"===this.state?this.Dr("Unknown"):(this.vr++,1<=this.vr&&(this.Fr(),this.Cr("Connection failed 1 times. Most recent error: "+t.toString()),this.Dr("Offline")))},Il.prototype.set=function(t){this.Fr(),this.vr=0,"Online"===t&&(this.Vr=!1),this.Dr(t)},Il.prototype.Dr=function(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))},Il.prototype.Cr=function(t){t="Could not reach Cloud Firestore backend. "+t+"\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.";this.Vr?(Or(t),this.Vr=!1):xr("OnlineStateTracker",t)},Il.prototype.Fr=function(){null!==this.Pr&&(this.Pr.cancel(),this.Pr=null)},Il);function Il(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.vr=0,this.Pr=null,this.Vr=!0}function El(t,e,n){var r=this;return(r=dl.call(this)||this).credentials=t,r.Hi=e,r.R=n,r.Rr=!1,r}function Tl(t,e,n,r,i){var o=this;return(o=pl.call(this,t,"write_stream_connection_backoff","write_stream_idle",e,n,i)||this).R=r,o.gr=!1,o}function _l(t,e,n,r,i){var o=this;return(o=yl.call(this,t,"listen_stream_connection_backoff","listen_stream_idle",e,n,i)||this).R=r,o}function Sl(t,e,n,r,i,o){this.Se=t,this.zi=n,this.Hi=r,this.Ji=i,this.listener=o,this.state=0,this.Yi=0,this.Xi=null,this.stream=null,this.Zi=new gl(t,e)}function Nl(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.Se=t,this.timerId=e,this.Mi=n,this.Li=r,this.Bi=i,this.qi=0,this.Ui=null,this.Qi=Date.now(),this.reset()}function Dl(r){return y(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:if(!Pl(r))return[3,4];e=0,n=r.Mr,t.label=1;case 1:return e<n.length?[4,(0,n[e])(!0)]:[3,4];case 2:t.sent(),t.label=3;case 3:return e++,[3,1];case 4:return[2]}})})}function Al(r){return y(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:e=0,n=r.Mr,t.label=1;case 1:return e<n.length?[4,(0,n[e])(!1)]:[3,4];case 2:t.sent(),t.label=3;case 3:return e++,[3,1];case 4:return[2]}})})}function kl(t,e){t.Or.has(e.targetId)||(t.Or.set(e.targetId,e),Ll(t)?Ol(t):Gl(t).er()&&Rl(t,e))}function Cl(t,e){var n=t,t=Gl(n);n.Or.delete(e),t.er()&&xl(n,e),0===n.Or.size&&(t.er()?t.ir():Pl(n)&&n.Br.set("Unknown"))}function Rl(t,e){t.qr.U(e.targetId),Gl(t).mr(e)}function xl(t,e){t.qr.U(e),Gl(t).yr(e)}function Ol(e){e.qr=new Ys({getRemoteKeysForTarget:function(t){return e.remoteSyncer.getRemoteKeysForTarget(t)},lt:function(t){return e.Or.get(t)||null}}),Gl(e).start(),e.Br.Sr()}function Ll(t){return Pl(t)&&!Gl(t).tr()&&0<t.Or.size}function Pl(t){return 0===t.$r.size}function Ml(t){t.qr=void 0}function Fl(s,a,u){return y(this,void 0,void 0,function(){var n,o;return g(this,function(t){switch(t.label){case 0:if(s.Br.set("Online"),!(a instanceof Hs&&2===a.state&&a.cause))return[3,6];t.label=1;case 1:return t.trys.push([1,3,,5]),[4,function(o,s){return y(this,void 0,void 0,function(){var e,n,r,i;return g(this,function(t){switch(t.label){case 0:e=s.cause,n=0,r=s.targetIds,t.label=1;case 1:return n<r.length?(i=r[n],o.Or.has(i)?[4,o.remoteSyncer.rejectListen(i,e)]:[3,3]):[3,5];case 2:t.sent(),o.Or.delete(i),o.qr.removeTarget(i),t.label=3;case 3:t.label=4;case 4:return n++,[3,1];case 5:return[2]}})})}(s,a)];case 2:return t.sent(),[3,5];case 3:return n=t.sent(),xr("RemoteStore","Failed to remove targets %s: %s ",a.targetIds.join(","),n),[4,Vl(s,n)];case 4:return t.sent(),[3,5];case 5:return[3,13];case 6:if(a instanceof Qs?s.qr.X(a):a instanceof zs?s.qr.rt(a):s.qr.et(a),u.isEqual(Gr.min()))return[3,13];t.label=7;case 7:return t.trys.push([7,11,,13]),[4,nh(s.localStore)];case 8:return o=t.sent(),0<=u.compareTo(o)?[4,(i=u,(e=(r=s).qr.ut(i)).targetChanges.forEach(function(t,e){var n;0<t.resumeToken.approximateByteSize()&&((n=r.Or.get(e))&&r.Or.set(e,n.withResumeToken(t.resumeToken,i)))}),e.targetMismatches.forEach(function(t){var e=r.Or.get(t);e&&(r.Or.set(t,e.withResumeToken(ni.EMPTY_BYTE_STRING,e.snapshotVersion)),xl(r,t),e=new Tu(e.target,t,1,e.sequenceNumber),Rl(r,e))}),r.remoteSyncer.applyRemoteEvent(e))]:[3,10];case 9:t.sent(),t.label=10;case 10:return[3,13];case 11:return xr("RemoteStore","Failed to raise snapshot:",o=t.sent()),[4,Vl(s,o)];case 12:return t.sent(),[3,13];case 13:return[2]}var r,i,e})})}function Vl(n,r,i){return y(this,void 0,void 0,function(){var e=this;return g(this,function(t){switch(t.label){case 0:if(!lu(r))throw r;return n.$r.add(1),[4,Al(n)];case 1:return t.sent(),n.Br.set("Offline"),i=i||function(){return nh(n.localStore)},n.asyncQueue.enqueueRetryable(function(){return y(e,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return xr("RemoteStore","Retrying IndexedDB access"),[4,i()];case 1:return t.sent(),n.$r.delete(1),[4,Dl(n)];case 2:return t.sent(),[2]}})})}),[2]}})})}function Ul(e,n){return n().catch(function(t){return Vl(e,t,n)})}function ql(u){return y(this,void 0,void 0,function(){var i,o,s,a;return g(this,function(t){switch(t.label){case 0:o=Ql(i=u),s=0<i.kr.length?i.kr[i.kr.length-1].batchId:-1,t.label=1;case 1:if(!(Pl(i)&&i.kr.length<10))return[3,7];t.label=2;case 2:return t.trys.push([2,4,,6]),[4,(e=i.localStore,n=s,(r=e).persistence.runTransaction("Get next mutation batch","readonly",function(t){return void 0===n&&(n=-1),r._n.getNextMutationBatchAfterBatchId(t,n)}))];case 3:return null===(a=t.sent())?(0===i.kr.length&&o.ir(),[3,7]):(s=a.batchId,function(t,e){t.kr.push(e);t=Ql(t);t.er()&&t.pr&&t.Er(e.mutations)}(i,a),[3,6]);case 4:return a=t.sent(),[4,Vl(i,a)];case 5:return t.sent(),[3,6];case 6:return[3,1];case 7:return Bl(i)&&jl(i),[2]}var e,n,r})})}function Bl(t){return Pl(t)&&!Ql(t).tr()&&0<t.kr.length}function jl(t){Ql(t).start()}function Kl(n,r){return y(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=n,r?(e.$r.delete(2),[4,Dl(e)]):[3,2];case 1:return t.sent(),[3,5];case 2:return r?[3,4]:(e.$r.add(2),[4,Al(e)]);case 3:t.sent(),e.Br.set("Unknown"),t.label=4;case 4:t.label=5;case 5:return[2]}})})}function Gl(n){var t,e,r,i=this;return n.Ur||(n.Ur=(t=n.datastore,e=n.asyncQueue,r={Ii:function(n){return y(this,void 0,void 0,function(){return g(this,function(t){return n.Or.forEach(function(t,e){Rl(n,t)}),[2]})})}.bind(null,n),Ri:function(e,n){return y(this,void 0,void 0,function(){return g(this,function(t){return Ml(e),Ll(e)?(e.Br.Nr(n),Ol(e)):e.Br.set("Unknown"),[2]})})}.bind(null,n),_r:Fl.bind(null,n)},t.br(),new ml(e,t.Hi,t.credentials,t.R,r)),n.Mr.push(function(e){return y(i,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return e?(n.Ur.sr(),Ll(n)?Ol(n):n.Br.set("Unknown"),[3,3]):[3,1];case 1:return[4,n.Ur.stop()];case 2:t.sent(),Ml(n),t.label=3;case 3:return[2]}})})})),n.Ur}function Ql(n){var t,e,r,i=this;return n.Qr||(n.Qr=(t=n.datastore,e=n.asyncQueue,r={Ii:function(e){return y(this,void 0,void 0,function(){return g(this,function(t){return Ql(e).Ar(),[2]})})}.bind(null,n),Ri:function(e,n){return y(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return n&&Ql(e).pr?[4,function(r,i){return y(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return _s(n=i.code)&&n!==Dr.ABORTED?(e=r.kr.shift(),Ql(r).sr(),[4,Ul(r,function(){return r.remoteSyncer.rejectFailedWrite(e.batchId,i)})]):[3,3];case 1:return t.sent(),[4,ql(r)];case 2:t.sent(),t.label=3;case 3:return[2]}})})}(e,n)]:[3,2];case 1:t.sent(),t.label=2;case 2:return Bl(e)&&jl(e),[2]}})})}.bind(null,n),Ir:function(o){return y(this,void 0,void 0,function(){var e,n,r,i;return g(this,function(t){for(e=Ql(o),n=0,r=o.kr;n<r.length;n++)i=r[n],e.Er(i.mutations);return[2]})})}.bind(null,n),Tr:function(r,i,o){return y(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return e=r.kr.shift(),n=Eu.from(e,i,o),[4,Ul(r,function(){return r.remoteSyncer.applySuccessfulWrite(n)})];case 1:return t.sent(),[4,ql(r)];case 2:return t.sent(),[2]}})})}.bind(null,n)},t.br(),new vl(e,t.Hi,t.credentials,t.R,r)),n.Mr.push(function(e){return y(i,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return e?(n.Qr.sr(),[4,ql(n)]):[3,2];case 1:return t.sent(),[3,4];case 2:return[4,n.Qr.stop()];case 3:t.sent(),0<n.kr.length&&(xr("RemoteStore","Stopping write stream with "+n.kr.length+" pending writes"),n.kr=[]),t.label=4;case 4:return[2]}})})})),n.Qr}var zl=(Hl.createAndSchedule=function(t,e,n,r,i){i=new Hl(t,e,Date.now()+n,r,i);return i.start(n),i},Hl.prototype.start=function(t){var e=this;this.timerHandle=setTimeout(function(){return e.handleDelayElapsed()},t)},Hl.prototype.skipDelay=function(){return this.handleDelayElapsed()},Hl.prototype.cancel=function(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new Ar(Dr.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},Hl.prototype.handleDelayElapsed=function(){var e=this;this.asyncQueue.enqueueAndForget(function(){return null!==e.timerHandle?(e.clearTimeout(),e.op().then(function(t){return e.deferred.resolve(t)})):Promise.resolve()})},Hl.prototype.clearTimeout=function(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)},Hl);function Hl(t,e,n,r,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new Za,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(function(t){})}function Wl(t,e){if(Or("AsyncQueue",e+": "+t),lu(t))return new Ar(Dr.UNAVAILABLE,e+": "+t);throw t}function Yl(){this.queries=new Sc(ko,Ao),this.onlineState="Unknown",this.Gr=new Set}var Xl=(nf.emptySet=function(t){return new nf(t.comparator)},nf.prototype.has=function(t){return null!=this.keyedMap.get(t)},nf.prototype.get=function(t){return this.keyedMap.get(t)},nf.prototype.first=function(){return this.sortedSet.minKey()},nf.prototype.last=function(){return this.sortedSet.maxKey()},nf.prototype.isEmpty=function(){return this.sortedSet.isEmpty()},nf.prototype.indexOf=function(t){t=this.keyedMap.get(t);return t?this.sortedSet.indexOf(t):-1},Object.defineProperty(nf.prototype,"size",{get:function(){return this.sortedSet.size},enumerable:!1,configurable:!0}),nf.prototype.forEach=function(n){this.sortedSet.inorderTraversal(function(t,e){return n(t),!1})},nf.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))},nf.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this},nf.prototype.isEqual=function(t){if(!(t instanceof nf))return!1;if(this.size!==t.size)return!1;for(var e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();e.hasNext();){var r=e.getNext().key,i=n.getNext().key;if(!r.isEqual(i))return!1}return!0},nf.prototype.toString=function(){var e=[];return this.forEach(function(t){e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n  "+e.join("  \n")+"\n)"},nf.prototype.copy=function(t,e){var n=new nf;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n},nf),Jl=(ef.prototype.track=function(t){var e=t.doc.key,n=this.Kr.get(e);!n||0!==t.type&&3===n.type?this.Kr=this.Kr.insert(e,t):3===t.type&&1!==n.type?this.Kr=this.Kr.insert(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.Kr=this.Kr.insert(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.Kr=this.Kr.insert(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.Kr=this.Kr.remove(e):1===t.type&&2===n.type?this.Kr=this.Kr.insert(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.Kr=this.Kr.insert(e,{type:2,doc:t.doc}):Mr()},ef.prototype.jr=function(){var n=[];return this.Kr.inorderTraversal(function(t,e){n.push(e)}),n},ef),$l=(tf.fromInitialDocuments=function(t,e,n,r){var i=[];return e.forEach(function(t){i.push({type:0,doc:t})}),new tf(t,e,Xl.emptySet(e),i,n,r,!0,!1)},Object.defineProperty(tf.prototype,"hasPendingWrites",{get:function(){return!this.mutatedKeys.isEmpty()},enumerable:!1,configurable:!0}),tf.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&Ao(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;var e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(e[r].type!==n[r].type||!e[r].doc.isEqual(n[r].doc))return!1;return!0},tf),Zl=function(){this.Wr=void 0,this.listeners=[]};function tf(t,e,n,r,i,o,s,a){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=s,this.excludesMetadataChanges=a}function ef(){this.Kr=new Ns(mi.comparator)}function nf(n){this.comparator=n?function(t,e){return n(t,e)||mi.comparator(t.key,e.key)}:function(t,e){return mi.comparator(t.key,e.key)},this.keyedMap=Vs,this.sortedSet=new Ns(this.comparator)}function rf(s,a){return y(this,void 0,void 0,function(){var e,n,r,i,o;return g(this,function(t){switch(t.label){case 0:if(e=s,n=a.query,r=!1,(i=e.queries.get(n))||(r=!0,i=new Zl),!r)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),o=i,[4,e.onListen(n)];case 2:return o.Wr=t.sent(),[3,4];case 3:return o=t.sent(),o=Wl(o,"Initialization of query '"+Co(a.query)+"' failed"),[2,void a.onError(o)];case 4:return e.queries.set(n,i),i.listeners.push(a),a.zr(e.onlineState),i.Wr&&a.Hr(i.Wr)&&sf(e),[2]}})})}function of(s,a){return y(this,void 0,void 0,function(){var e,n,r,i,o;return g(this,function(t){return e=s,n=a.query,r=!1,(i=e.queries.get(n))&&0<=(o=i.listeners.indexOf(a))&&(i.listeners.splice(o,1),r=0===i.listeners.length),r?[2,(e.queries.delete(n),e.onUnlisten(n))]:[2]})})}function sf(t){t.Gr.forEach(function(t){t.next()})}var af=(pf.prototype.Hr=function(t){if(!this.options.includeMetadataChanges){for(var e=[],n=0,r=t.docChanges;n<r.length;n++){var i=r[n];3!==i.type&&e.push(i)}t=new $l(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0)}var o=!1;return this.Yr?this.Zr(t)&&(this.Jr.next(t),o=!0):this.eo(t,this.onlineState)&&(this.no(t),o=!0),this.Xr=t,o},pf.prototype.onError=function(t){this.Jr.error(t)},pf.prototype.zr=function(t){this.onlineState=t;var e=!1;return this.Xr&&!this.Yr&&this.eo(this.Xr,t)&&(this.no(this.Xr),e=!0),e},pf.prototype.eo=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.so&&n||t.docs.isEmpty()&&"Offline"!==e)},pf.prototype.Zr=function(t){if(0<t.docChanges.length)return!0;var e=this.Xr&&this.Xr.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges},pf.prototype.no=function(t){t=$l.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.Yr=!0,this.Jr.next(t)},pf),uf=(df.prototype.io=function(){return"metadata"in this.payload},df),cf=(ff.prototype.qn=function(t){return la(this.R,t)},ff.prototype.Un=function(t){return t.metadata.exists?ma(this.R,t.document,!1):Oi.newNoDocument(this.qn(t.metadata.name),this.Qn(t.metadata.readTime))},ff.prototype.Qn=aa,ff),hf=(lf.prototype.oo=function(t){this.progress.bytesLoaded+=t.byteLength;var e=this.progress.documentsLoaded;return t.payload.namedQuery?this.queries.push(t.payload.namedQuery):t.payload.documentMetadata?(this.documents.push({metadata:t.payload.documentMetadata}),t.payload.documentMetadata.exists||++e):t.payload.document&&(this.documents[this.documents.length-1].document=t.payload.document,++e),e!==this.progress.documentsLoaded?(this.progress.documentsLoaded=e,Object.assign({},this.progress)):null},lf.prototype.co=function(t){for(var e=new Map,n=new cf(this.R),r=0,i=t;r<i.length;r++){var o=i[r];if(o.metadata.queries)for(var s=n.qn(o.metadata.name),a=0,u=o.metadata.queries;a<u.length;a++){var c=u[a],h=(e.get(c)||Bs()).add(s);e.set(c,h)}}return e},lf.prototype.complete=function(){return y(this,void 0,void 0,function(){var e,n,r,i;return g(this,function(t){switch(t.label){case 0:return[4,function(l,f,d,p){return y(this,void 0,void 0,function(){var n,r,i,o,e,s,a,u,c,h;return g(this,function(t){switch(t.label){case 0:for(n=l,r=Bs(),i=Ps,o=Us,e=0,s=d;e<s.length;e++)a=s[e],u=f.qn(a.metadata.name),a.document&&(r=r.add(u)),i=i.insert(u,f.Un(a)),o=o.insert(u,f.Qn(a.metadata.readTime));return c=n.$n.newChangeBuffer({trackRemovals:!0}),[4,oh(n,No(bo($r.fromString("__bundle__/docs/"+p))))];case 1:return h=t.sent(),[2,n.persistence.runTransaction("Apply bundle documents","readwrite",function(e){return ih(e,c,i,Gr.min(),o).next(function(t){return c.apply(e),t}).next(function(t){return n.qe.removeMatchingKeysForTargetId(e,h.targetId).next(function(){return n.qe.addMatchingKeys(e,r,h.targetId)}).next(function(){return n.Mn.En(e,t)}).next(function(){return t})})})]}})})}(this.localStore,new cf(this.R),this.documents,this.ro.id)];case 1:e=t.sent(),n=this.co(this.documents),r=0,i=this.queries,t.label=2;case 2:return r<i.length?(i=i[r],[4,function(e,i,o){return void 0===o&&(o=Bs()),y(this,void 0,void 0,function(){var n,r;return g(this,function(t){switch(t.label){case 0:return[4,oh(e,No(Fu(i.bundledQuery)))];case 1:return n=t.sent(),[2,(r=e).persistence.runTransaction("Save named query","readwrite",function(t){var e=aa(i.readTime);if(0<=n.snapshotVersion.compareTo(e))return r.Qe.saveNamedQuery(t,i);e=n.withResumeToken(ni.EMPTY_BYTE_STRING,e);return r.Fn=r.Fn.insert(e.targetId,e),r.qe.updateTargetData(t,e).next(function(){return r.qe.removeMatchingKeysForTargetId(t,n.targetId)}).next(function(){return r.qe.addMatchingKeys(t,o,n.targetId)}).next(function(){return r.Qe.saveNamedQuery(t,i)})})]}})})}(this.localStore,i,n.get(i.name))]):[3,5];case 3:t.sent(),t.label=4;case 4:return r++,[3,2];case 5:return[2,(this.progress.taskState="Success",new Gc(Object.assign({},this.progress),e))]}})})},lf);function lf(t,e,n){this.ro=t,this.localStore=e,this.R=n,this.queries=[],this.documents=[],this.progress=yf(t)}function ff(t){this.R=t}function df(t,e){this.payload=t,this.byteLength=e}function pf(t,e,n){this.query=t,this.Jr=e,this.Yr=!1,this.Xr=null,this.onlineState="Unknown",this.options=n||{}}function yf(t){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}var gf=function(t){this.key=t},mf=function(t){this.key=t},vf=(Object.defineProperty(Tf.prototype,"wo",{get:function(){return this.uo},enumerable:!1,configurable:!0}),Tf.prototype._o=function(t,e){var s=this,a=e?e.mo:new Jl,u=(e||this).fo,c=(e||this).mutatedKeys,h=u,l=!1,f=wo(this.query)&&u.size===this.query.limit?u.last():null,d=Io(this.query)&&u.size===this.query.limit?u.first():null;if(t.inorderTraversal(function(t,e){var n=u.get(t),r=Ro(s.query,e)?e:null,i=!!n&&s.mutatedKeys.has(n.key),o=!!r&&(r.hasLocalMutations||s.mutatedKeys.has(r.key)&&r.hasCommittedMutations),e=!1;n&&r?n.data.isEqual(r.data)?i!==o&&(a.track({type:3,doc:r}),e=!0):s.yo(n,r)||(a.track({type:2,doc:r}),e=!0,(f&&0<s.lo(r,f)||d&&s.lo(r,d)<0)&&(l=!0)):!n&&r?(a.track({type:0,doc:r}),e=!0):n&&!r&&(a.track({type:1,doc:n}),e=!0,(f||d)&&(l=!0)),e&&(c=r?(h=h.add(r),o?c.add(t):c.delete(t)):(h=h.delete(t),c.delete(t)))}),wo(this.query)||Io(this.query))for(;h.size>this.query.limit;){var n=wo(this.query)?h.last():h.first(),h=h.delete(n.key),c=c.delete(n.key);a.track({type:1,doc:n})}return{fo:h,mo:a,Nn:l,mutatedKeys:c}},Tf.prototype.yo=function(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations},Tf.prototype.applyChanges=function(t,e,n){var o=this,r=this.fo;this.fo=t.fo,this.mutatedKeys=t.mutatedKeys;var i=t.mo.jr();i.sort(function(t,e){return r=t.type,i=e.type,n(r)-n(i)||o.lo(t.doc,e.doc);function n(t){switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Mr()}}var r,i}),this.po(n);var s=e?this.Eo():[],n=0===this.ho.size&&this.current?1:0,e=n!==this.ao;return this.ao=n,0!==i.length||e?{snapshot:new $l(this.query,t.fo,r,i,t.mutatedKeys,0==n,e,!1),To:s}:{To:s}},Tf.prototype.zr=function(t){return this.current&&"Offline"===t?(this.current=!1,this.applyChanges({fo:this.fo,mo:new Jl,mutatedKeys:this.mutatedKeys,Nn:!1},!1)):{To:[]}},Tf.prototype.Io=function(t){return!this.uo.has(t)&&!!this.fo.has(t)&&!this.fo.get(t).hasLocalMutations},Tf.prototype.po=function(t){var e=this;t&&(t.addedDocuments.forEach(function(t){return e.uo=e.uo.add(t)}),t.modifiedDocuments.forEach(function(t){}),t.removedDocuments.forEach(function(t){return e.uo=e.uo.delete(t)}),this.current=t.current)},Tf.prototype.Eo=function(){var e=this;if(!this.current)return[];var n=this.ho;this.ho=Bs(),this.fo.forEach(function(t){e.Io(t.key)&&(e.ho=e.ho.add(t.key))});var r=[];return n.forEach(function(t){e.ho.has(t)||r.push(new mf(t))}),this.ho.forEach(function(t){n.has(t)||r.push(new gf(t))}),r},Tf.prototype.Ao=function(t){this.uo=t.Bn,this.ho=Bs();t=this._o(t.documents);return this.applyChanges(t,!0)},Tf.prototype.Ro=function(){return $l.fromInitialDocuments(this.query,this.fo,this.mutatedKeys,0===this.ao)},Tf),bf=function(t,e,n){this.query=t,this.targetId=e,this.view=n},wf=function(t){this.key=t,this.bo=!1},If=(Object.defineProperty(Ef.prototype,"isPrimaryClient",{get:function(){return!0===this.Oo},enumerable:!1,configurable:!0}),Ef);function Ef(t,e,n,r,i,o){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=o,this.vo={},this.Po=new Sc(ko,Ao),this.Vo=new Map,this.So=new Set,this.Do=new Ns(mi.comparator),this.Co=new Map,this.No=new ph,this.xo={},this.Fo=new Map,this.ko=sc.Yt(),this.onlineState="Unknown",this.Oo=void 0}function Tf(t,e){this.query=t,this.uo=e,this.ao=null,this.current=!1,this.ho=Bs(),this.mutatedKeys=Bs(),this.lo=xo(t),this.fo=new Xl(this.lo)}function _f(i,o,s,a){return y(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:return i.$o=function(t,e,n){return function(r,i,o,s){return y(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return(e=i.view._o(o)).Nn?[4,ah(r.localStore,i.query,!1).then(function(t){t=t.documents;return i.view._o(t,e)})]:[3,2];case 1:e=t.sent(),t.label=2;case 2:return n=s&&s.targetChanges.get(i.targetId),n=i.view.applyChanges(e,r.isPrimaryClient,n),[2,(Lf(r,i.targetId,n.To),n.snapshot)]}})})}(i,t,e,n)},[4,ah(i.localStore,o,!0)];case 1:return n=t.sent(),r=new vf(o,n.Bn),e=r._o(n.documents),n=Gs.createSynthesizedTargetChangeForCurrentChange(s,a&&"Offline"!==i.onlineState),n=r.applyChanges(e,i.isPrimaryClient,n),Lf(i,s,n.To),r=new bf(o,s,r),[2,(i.Po.set(o,r),i.Vo.has(s)?i.Vo.get(s).push(o):i.Vo.set(s,[o]),n.snapshot)]}})})}function Sf(f,d,p){return y(this,void 0,void 0,function(){var s,l;return g(this,function(t){switch(t.label){case 0:l=Kf(f),t.label=1;case 1:return t.trys.push([1,5,,6]),[4,(i=l.localStore,a=d,c=i,h=Kr.now(),o=a.reduce(function(t,e){return t.add(e.key)},Bs()),c.persistence.runTransaction("Locally write mutations","readwrite",function(s){return c.Mn.pn(s,o).next(function(t){u=t;for(var e=[],n=0,r=a;n<r.length;n++){var i=r[n],o=function(t,e){for(var n=null,r=0,i=t.fieldTransforms;r<i.length;r++){var o=i[r],s=e.data.field(o.field),s=Mo(o.transform,s||null);null!=s&&(n=null==n?Ri.empty():n).set(o.field,s)}return n||null}(i,u.get(i.key));null!=o&&e.push(new hs(i.key,o,function s(t){var a=[];return Wr(t.fields||{},function(t,e){var n=new ti([t]);if(Ci(e))if(0===(e=s(e.mapValue).fields).length)a.push(n);else for(var r=0,i=e;r<i.length;r++){var o=i[r];a.push(n.child(o))}else a.push(n)}),new ei(a)}(o.toProto().mapValue),es.exists(!0)))}return c._n.addMutationBatch(s,h,e,a)})}).then(function(t){return t.applyToLocalDocumentSet(u),{batchId:t.batchId,changes:u}}))];case 2:return s=t.sent(),l.sharedClientState.addPendingMutation(s.batchId),e=l,n=s.batchId,r=p,i=(i=(i=e.xo[e.currentUser.toKey()])||new Ns(qr)).insert(n,r),e.xo[e.currentUser.toKey()]=i,[4,Mf(l,s.changes)];case 3:return t.sent(),[4,ql(l.remoteStore)];case 4:return t.sent(),[3,6];case 5:return l=t.sent(),l=Wl(l,"Failed to persist write"),p.reject(l),[3,6];case 6:return[2]}var e,n,r,i,a,u,c,h,o})})}function Nf(r,i){return y(this,void 0,void 0,function(){var n,e;return g(this,function(t){switch(t.label){case 0:n=r,t.label=1;case 1:return t.trys.push([1,4,,6]),[4,rh(n.localStore,i)];case 2:return e=t.sent(),i.targetChanges.forEach(function(t,e){e=n.Co.get(e);e&&(Fr(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1),0<t.addedDocuments.size?e.bo=!0:0<t.modifiedDocuments.size?Fr(e.bo):0<t.removedDocuments.size&&(Fr(e.bo),e.bo=!1))}),[4,Mf(n,e,i)];case 3:return t.sent(),[3,6];case 4:return[4,dc(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})}function Df(t,n,e){var r,t=t;(t.isPrimaryClient&&0===e||!t.isPrimaryClient&&1===e)&&(r=[],t.Po.forEach(function(t,e){e=e.view.zr(n);e.snapshot&&r.push(e.snapshot)}),function(t,i){t.onlineState=i;var o=!1;t.queries.forEach(function(t,e){for(var n=0,r=e.listeners;n<r.length;n++)r[n].zr(i)&&(o=!0)}),o&&sf(t)}(t.eventManager,n),r.length&&t.vo._r(r),t.onlineState=n,t.isPrimaryClient&&t.sharedClientState.setOnlineState(n))}function Af(s,a,u){return y(this,void 0,void 0,function(){var n,o;return g(this,function(t){switch(t.label){case 0:n=s,t.label=1;case 1:return t.trys.push([1,4,,6]),[4,(e=n.localStore,r=a,(i=e).persistence.runTransaction("Reject batch","readwrite-primary",function(e){var n;return i._n.lookupMutationBatch(e,r).next(function(t){return Fr(null!==t),n=t.keys(),i._n.removeMutationBatch(e,t)}).next(function(){return i._n.performConsistencyCheck(e)}).next(function(){return i.Mn.pn(e,n)})}))];case 2:return o=t.sent(),Rf(n,a,u),Cf(n,a),n.sharedClientState.updateMutationState(a,"rejected",u),[4,Mf(n,o)];case 3:return t.sent(),[3,6];case 4:return[4,dc(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}var e,r,i})})}function kf(o,s){return y(this,void 0,void 0,function(){var n,r,i;return g(this,function(t){switch(t.label){case 0:Pl((n=o).remoteStore)||xr("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,(e=n.localStore).persistence.runTransaction("Get highest unacknowledged batch id","readonly",function(t){return e._n.getHighestUnacknowledgedBatchId(t)})];case 2:return-1===(r=t.sent())?[2,void s.resolve()]:((i=n.Fo.get(r)||[]).push(s),n.Fo.set(r,i),[3,4]);case 3:return i=t.sent(),i=Wl(i,"Initialization of waitForPendingWrites() operation failed"),s.reject(i),[3,4];case 4:return[2]}var e})})}function Cf(t,e){(t.Fo.get(e)||[]).forEach(function(t){t.resolve()}),t.Fo.delete(e)}function Rf(t,e,n){var r=t,i=r.xo[r.currentUser.toKey()];i&&((t=i.get(e))&&(n?t.reject(n):t.resolve(),i=i.remove(e)),r.xo[r.currentUser.toKey()]=i)}function xf(e,t,n){void 0===n&&(n=null),e.sharedClientState.removeLocalQueryTarget(t);for(var r=0,i=e.Vo.get(t);r<i.length;r++){var o=i[r];e.Po.delete(o),n&&e.vo.Mo(o,n)}e.Vo.delete(t),e.isPrimaryClient&&e.No.Zn(t).forEach(function(t){e.No.containsKey(t)||Of(e,t)})}function Of(t,e){t.So.delete(e.path.canonicalString());var n=t.Do.get(e);null!==n&&(Cl(t.remoteStore,n),t.Do=t.Do.remove(e),t.Co.delete(n),Pf(t))}function Lf(t,e,n){for(var r,i,o,s=0,a=n;s<a.length;s++){var u=a[s];u instanceof gf?(t.No.addReference(u.key,e),r=t,o=void 0,i=(o=(i=u).key).path.canonicalString(),r.Do.get(o)||r.So.has(i)||(xr("SyncEngine","New document in limbo: "+o),r.So.add(i),Pf(r))):u instanceof mf?(xr("SyncEngine","Document no longer in limbo: "+u.key),t.No.removeReference(u.key,e),t.No.containsKey(u.key)||Of(t,u.key)):Mr()}}function Pf(t){for(;0<t.So.size&&t.Do.size<t.maxConcurrentLimboResolutions;){var e=t.So.values().next().value;t.So.delete(e);var n=new mi($r.fromString(e)),e=t.ko.next();t.Co.set(e,new wf(n)),t.Do=t.Do.insert(n,e),kl(t.remoteStore,new Tu(No(bo(n.path)),e,2,_r.o))}}function Mf(e,s,a){return y(this,void 0,void 0,function(){var n,r,i,o;return g(this,function(t){switch(t.label){case 0:return r=[],i=[],o=[],(n=e).Po.isEmpty()?[3,3]:(n.Po.forEach(function(t,e){o.push(n.$o(e,s,a).then(function(t){t&&(n.isPrimaryClient&&n.sharedClientState.updateQueryState(e.targetId,t.fromCache?"not-current":"current"),r.push(t),t=zc.Pn(e.targetId,t),i.push(t))}))}),[4,Promise.all(o)]);case 1:return t.sent(),n.vo._r(r),[4,function(u,c){return y(this,void 0,void 0,function(){var r,e,n,i,o,s,a;return g(this,function(t){switch(t.label){case 0:r=u,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r.persistence.runTransaction("notifyLocalViewChanges","readwrite",function(n){return tu.forEach(c,function(e){return tu.forEach(e.bn,function(t){return r.persistence.referenceDelegate.addReference(n,e.targetId,t)}).next(function(){return tu.forEach(e.vn,function(t){return r.persistence.referenceDelegate.removeReference(n,e.targetId,t)})})})})];case 2:return t.sent(),[3,4];case 3:if(!lu(e=t.sent()))throw e;return xr("LocalStore","Failed to update sequence numbers: "+e),[3,4];case 4:for(n=0,i=c;n<i.length;n++)a=i[n],o=a.targetId,a.fromCache||(s=r.Fn.get(o),a=s.snapshotVersion,a=s.withLastLimboFreeSnapshotVersion(a),r.Fn=r.Fn.insert(o,a));return[2]}})})}(n.localStore,i)];case 2:t.sent(),t.label=3;case 3:return[2]}})})}function Ff(i,o){return y(this,void 0,void 0,function(){var n,r;return g(this,function(t){switch(t.label){case 0:return(n=i).currentUser.isEqual(o)?[3,3]:(xr("SyncEngine","User change. New user:",o.toKey()),[4,th(n.localStore,o)]);case 1:return r=t.sent(),n.currentUser=o,(e=n).Fo.forEach(function(t){t.forEach(function(t){t.reject(new Ar(Dr.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.Fo.clear(),n.sharedClientState.handleUserChange(o,r.removedBatchIds,r.addedBatchIds),[4,Mf(n,r.Ln)];case 2:t.sent(),t.label=3;case 3:return[2]}var e})})}function Vf(a,u,c,h){return y(this,void 0,void 0,function(){var o,s;return g(this,function(t){switch(t.label){case 0:return[4,(e=(o=a).localStore,n=u,i=(r=e)._n,r.persistence.runTransaction("Lookup mutation documents","readonly",function(e){return i.jt(e,n).next(function(t){return t?r.Mn.pn(e,t):tu.resolve(null)})}))];case 1:return null===(s=t.sent())?[3,6]:"pending"!==c?[3,3]:[4,ql(o.remoteStore)];case 2:return t.sent(),[3,4];case 3:"acknowledged"===c||"rejected"===c?(Rf(o,u,h||null),Cf(o,u),o.localStore._n.Gt(u)):Mr(),t.label=4;case 4:return[4,Mf(o,s)];case 5:return t.sent(),[3,7];case 6:xr("SyncEngine","Cannot apply mutation batch with id: "+u),t.label=7;case 7:return[2]}var e,n,r,i})})}function Uf(h,l){return y(this,void 0,void 0,function(){var r,e,i,o,s,a,u,c;return g(this,function(t){switch(t.label){case 0:return jf(r=h),Kf(r),!0!==l||!0===r.Oo?[3,3]:(e=r.sharedClientState.getAllActiveQueryTargets(),[4,qf(r,e.toArray())]);case 1:return i=t.sent(),r.Oo=!0,[4,Kl(r.remoteStore,!0)];case 2:for(t.sent(),o=0,s=i;o<s.length;o++)a=s[o],kl(r.remoteStore,a);return[3,7];case 3:return!1!==l||!1===r.Oo?[3,7]:(u=[],c=Promise.resolve(),r.Vo.forEach(function(t,e){r.sharedClientState.isLocalQueryTarget(e)?u.push(e):c=c.then(function(){return xf(r,e),sh(r.localStore,e,!0)}),Cl(r.remoteStore,e)}),[4,c]);case 4:return t.sent(),[4,qf(r,u)];case 5:return t.sent(),(n=r).Co.forEach(function(t,e){Cl(n.remoteStore,e)}),n.No.ts(),n.Co=new Map,n.Do=new Ns(mi.comparator),r.Oo=!1,[4,Kl(r.remoteStore,!1)];case 6:t.sent(),t.label=7;case 7:return[2]}var n})})}function qf(d,p){return y(this,void 0,void 0,function(){var e,n,r,i,o,s,a,u,c,h,l,f;return g(this,function(t){switch(t.label){case 0:e=d,n=[],r=[],i=0,o=p,t.label=1;case 1:return i<o.length?(s=o[i],a=void 0,(u=e.Vo.get(s))&&0!==u.length?[4,oh(e.localStore,No(u[0]))]:[3,7]):[3,13];case 2:a=t.sent(),c=0,h=u,t.label=3;case 3:return c<h.length?(l=h[c],l=e.Po.get(l),[4,function(r,i){return y(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return[4,ah((e=r).localStore,i.query,!0)];case 1:return n=t.sent(),n=i.view.Ao(n),[2,(e.isPrimaryClient&&Lf(e,i.targetId,n.To),n)]}})})}(e,l)]):[3,6];case 4:(l=t.sent()).snapshot&&r.push(l.snapshot),t.label=5;case 5:return c++,[3,3];case 6:return[3,11];case 7:return[4,uh(e.localStore,s)];case 8:return f=t.sent(),[4,oh(e.localStore,f)];case 9:return a=t.sent(),[4,_f(e,Bf(f),s,!1)];case 10:t.sent(),t.label=11;case 11:n.push(a),t.label=12;case 12:return i++,[3,1];case 13:return[2,(e.vo._r(r),n)]}})})}function Bf(t){return vo(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)}function jf(t){return t.remoteStore.remoteSyncer.applyRemoteEvent=Nf.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=function(t,e){var n=t;if((t=n.Co.get(e))&&t.bo)return Bs().add(t.key);var r=Bs();if(!(e=n.Vo.get(e)))return r;for(var i=0,o=e;i<o.length;i++)var s=o[i],s=n.Po.get(s),r=r.unionWith(s.view.wo);return r}.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=function(o,s,a){return y(this,void 0,void 0,function(){var e,n,r,i;return g(this,function(t){switch(t.label){case 0:return(e=o).sharedClientState.updateQueryState(s,"rejected",a),i=e.Co.get(s),(n=i&&i.key)?(r=(r=new Ns(mi.comparator)).insert(n,Oi.newNoDocument(n,Gr.min())),i=Bs().add(n),i=new Ks(Gr.min(),new Map,new Os(qr),r,i),[4,Nf(e,i)]):[3,2];case 1:return t.sent(),e.Do=e.Do.remove(n),e.Co.delete(s),Pf(e),[3,4];case 2:return[4,sh(e.localStore,s,!1).then(function(){return xf(e,s,a)}).catch(dc)];case 3:t.sent(),t.label=4;case 4:return[2]}})})}.bind(null,t),t.vo._r=function(t,e){for(var n=t,r=!1,i=0,o=e;i<o.length;i++){var s=o[i],a=s.query,a=n.queries.get(a);if(a){for(var u=0,c=a.listeners;u<c.length;u++)c[u].Hr(s)&&(r=!0);a.Wr=s}}r&&sf(n)}.bind(null,t.eventManager),t.vo.Mo=function(t,e,n){var r=t;if(t=r.queries.get(e))for(var i=0,o=t.listeners;i<o.length;i++)o[i].onError(n);r.queries.delete(e)}.bind(null,t.eventManager),t}function Kf(t){return t.remoteStore.remoteSyncer.applySuccessfulWrite=function(i,o){return y(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:e=i,n=o.batch.batchId,t.label=1;case 1:return t.trys.push([1,4,,6]),[4,eh(e.localStore,o)];case 2:return r=t.sent(),Rf(e,n,null),Cf(e,n),e.sharedClientState.updateMutationState(n,"acknowledged"),[4,Mf(e,r)];case 3:return t.sent(),[3,6];case 4:return[4,dc(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})}.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Af.bind(null,t),t}function Gf(t,e,n){var r=t;!function(f,d,p){return y(this,void 0,void 0,function(){var a,u,c,h,l;return g(this,function(t){switch(t.label){case 0:return t.trys.push([0,14,,15]),[4,d.getMetadata()];case 1:return a=t.sent(),[4,(r=f.localStore,o=r,s=aa((i=a).createTime),o.persistence.runTransaction("hasNewerBundle","readonly",function(t){return o.Qe.getBundleMetadata(t,i.id)}).then(function(t){return!!t&&0<=t.createTime.compareTo(s)}))];case 2:return t.sent()?[4,d.close()]:[3,4];case 3:return[2,(t.sent(),void p._completeWith({taskState:"Success",documentsLoaded:a.totalDocuments,bytesLoaded:a.totalBytes,totalDocuments:a.totalDocuments,totalBytes:a.totalBytes}))];case 4:return p._updateProgress(yf(a)),u=new hf(a,f.localStore,d.R),[4,d.Lo()];case 5:c=t.sent(),t.label=6;case 6:return c?[4,u.oo(c)]:[3,10];case 7:return(h=t.sent())&&p._updateProgress(h),[4,d.Lo()];case 8:c=t.sent(),t.label=9;case 9:return[3,6];case 10:return[4,u.complete()];case 11:return l=t.sent(),[4,Mf(f,l.wn,void 0)];case 12:return t.sent(),[4,(r=f.localStore,e=a,(n=r).persistence.runTransaction("Save bundle","readwrite",function(t){return n.Qe.saveBundleMetadata(t,e)}))];case 13:return t.sent(),p._completeWith(l.progress),[3,15];case 14:return Lr("SyncEngine","Loading bundle failed with "+(l=t.sent())),p._failWith(l),[3,15];case 15:return[2]}var e,n,r,i,o,s})})}(r,e,n).then(function(){r.sharedClientState.notifyBundleLoaded()})}var Qf,zf,Hf=(td.prototype.initialize=function(e){return y(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return this.R=ll(e.databaseInfo.databaseId),this.sharedClientState=this.Bo(e),this.persistence=this.qo(e),[4,this.persistence.start()];case 1:return t.sent(),this.gcScheduler=this.Uo(e),this.localStore=this.Qo(e),[2]}})})},td.prototype.Uo=function(t){return null},td.prototype.Qo=function(t){return Zc(this.persistence,new Hc,t.initialUser,this.R)},td.prototype.qo=function(t){return new wh(Eh.bs,this.R)},td.prototype.Bo=function(t){return new Qh},td.prototype.terminate=function(){return y(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return this.gcScheduler&&this.gcScheduler.stop(),[4,this.sharedClientState.shutdown()];case 1:return t.sent(),[4,this.persistence.shutdown()];case 2:return t.sent(),[2]}})})},td),Wf=(n(Zf,zf=Hf),Zf.prototype.initialize=function(e){return y(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,zf.prototype.initialize.call(this,e)];case 1:return t.sent(),[4,hh(this.localStore)];case 2:return t.sent(),[4,this.Ko.initialize(this,e)];case 3:return t.sent(),[4,Kf(this.Ko.syncEngine)];case 4:return t.sent(),[4,ql(this.Ko.remoteStore)];case 5:return t.sent(),[2]}})})},Zf.prototype.Qo=function(t){return Zc(this.persistence,new Hc,t.initialUser,this.R)},Zf.prototype.Uo=function(t){var e=this.persistence.referenceDelegate.garbageCollector;return new gc(e,t.asyncQueue)},Zf.prototype.qo=function(t){var e=Kc(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?Xu.withCacheSize(this.cacheSizeBytes):Xu.DEFAULT;return new Uc(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,cl(),hl(),this.R,this.sharedClientState,!!this.forceOwnership)},Zf.prototype.Bo=function(t){return new Qh},Zf),Yf=(n($f,Qf=Wf),$f.prototype.initialize=function(r){return y(this,void 0,void 0,function(){var e,n=this;return g(this,function(t){switch(t.label){case 0:return[4,Qf.prototype.initialize.call(this,r)];case 1:return t.sent(),e=this.Ko.syncEngine,this.sharedClientState instanceof Gh?(this.sharedClientState.syncEngine={ui:Vf.bind(null,e),ai:function(i,o,s,a){return y(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:return(e=i).Oo?(xr("SyncEngine","Ignoring unexpected query state notification."),[3,8]):[3,1];case 1:if(!e.Vo.has(o))return[3,8];switch(s){case"current":case"not-current":return[3,2];case"rejected":return[3,5]}return[3,7];case 2:return[4,ch(e.localStore)];case 3:return n=t.sent(),r=Ks.createSynthesizedRemoteEventForCurrentChange(o,"current"===s),[4,Mf(e,n,r)];case 4:return t.sent(),[3,8];case 5:return[4,sh(e.localStore,o,!0)];case 6:return t.sent(),xf(e,o,a),[3,8];case 7:Mr(),t.label=8;case 8:return[2]}})})}.bind(null,e),hi:function(c,h,l){return y(this,void 0,void 0,function(){var n,e,r,i,o,s,a,u;return g(this,function(t){switch(t.label){case 0:if(!(n=jf(c)).Oo)return[3,10];e=0,r=h,t.label=1;case 1:return e<r.length?(r=r[e],n.Vo.has(r)?(xr("SyncEngine","Adding an already active target "+r),[3,5]):[4,uh(n.localStore,r)]):[3,6];case 2:return i=t.sent(),[4,oh(n.localStore,i)];case 3:return o=t.sent(),[4,_f(n,Bf(i),o.targetId,!1)];case 4:t.sent(),kl(n.remoteStore,o),t.label=5;case 5:return e++,[3,1];case 6:s=function(e){return g(this,function(t){switch(t.label){case 0:return n.Vo.has(e)?[4,sh(n.localStore,e,!1).then(function(){Cl(n.remoteStore,e),xf(n,e)}).catch(dc)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})},a=0,u=l,t.label=7;case 7:return a<u.length?(u=u[a],[5,s(u)]):[3,10];case 8:t.sent(),t.label=9;case 9:return a++,[3,7];case 10:return[2]}})})}.bind(null,e),fn:function(t){return t.localStore.persistence.fn()}.bind(null,e),ci:function(n){return y(this,void 0,void 0,function(){var e;return g(this,function(t){return[2,ch((e=n).localStore).then(function(t){return Mf(e,t)})]})})}.bind(null,e)},[4,this.sharedClientState.start()]):[3,3];case 2:t.sent(),t.label=3;case 3:return[4,this.persistence.He(function(e){return y(n,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,Uf(this.Ko.syncEngine,e)];case 1:return t.sent(),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):e||this.gcScheduler.stop()),[2]}})})})];case 4:return t.sent(),[2]}})})},$f.prototype.Bo=function(t){var e=cl();if(!Gh.yt(e))throw new Ar(Dr.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=Kc(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new Gh(e,t.asyncQueue,n,t.clientId,t.initialUser)},$f),Xf=(Jf.prototype.initialize=function(n,r){return y(this,void 0,void 0,function(){var e=this;return g(this,function(t){switch(t.label){case 0:return this.localStore?[3,2]:(this.localStore=n.localStore,this.sharedClientState=n.sharedClientState,this.datastore=this.createDatastore(r),this.remoteStore=this.createRemoteStore(r),this.eventManager=this.createEventManager(r),this.syncEngine=this.createSyncEngine(r,!n.synchronizeTabs),this.sharedClientState.onlineStateHandler=function(t){return Df(e.syncEngine,t,1)},this.remoteStore.remoteSyncer.handleCredentialChange=Ff.bind(null,this.syncEngine),[4,Kl(this.remoteStore,this.syncEngine.isPrimaryClient)]);case 1:t.sent(),t.label=2;case 2:return[2]}})})},Jf.prototype.createEventManager=function(t){return new Yl},Jf.prototype.createDatastore=function(t){var e=ll(t.databaseInfo.databaseId),n=(n=t.databaseInfo,new Xh(n));return t=t.credentials,new bl(t,n,e)},Jf.prototype.createRemoteStore=function(t){var e=this,n=this.localStore,r=this.datastore,i=t.asyncQueue,o=function(t){return Df(e.syncEngine,t,0)},t=new(Hh.yt()?Hh:zh);return new fl(n,r,i,o,t)},Jf.prototype.createSyncEngine=function(t,e){return function(t,e,n,r,i,o,s){o=new If(t,e,n,r,i,o);return s&&(o.Oo=!0),o}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)},Jf.prototype.terminate=function(){return function(n){return y(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=n,xr("RemoteStore","RemoteStore shutting down."),e.$r.add(5),[4,Al(e)];case 1:return t.sent(),e.Lr.shutdown(),e.Br.set("Unknown"),[2]}})})}(this.remoteStore)},Jf);function Jf(){}function $f(t,e){var n=this;return(n=Qf.call(this,t,e,!1)||this).Ko=t,n.cacheSizeBytes=e,n.synchronizeTabs=!0,n}function Zf(t,e,n){var r=this;return(r=zf.call(this)||this).Ko=t,r.cacheSizeBytes=e,r.forceOwnership=n,r.synchronizeTabs=!1,r}function td(){this.synchronizeTabs=!1}function ed(n,r){void 0===r&&(r=10240);var i=0;return{read:function(){return y(this,void 0,void 0,function(){var e;return g(this,function(t){return i<n.byteLength?(e={value:n.slice(i,i+r),done:!1},[2,(i+=r,e)]):[2,{done:!0}]})})},cancel:function(){return y(this,void 0,void 0,function(){return g(this,function(t){return[2]})})},releaseLock:function(){},closed:Promise.reject("unimplemented")}}var nd=(ld.prototype.next=function(t){this.observer.next&&this.jo(this.observer.next,t)},ld.prototype.error=function(t){this.observer.error?this.jo(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)},ld.prototype.Wo=function(){this.muted=!0},ld.prototype.jo=function(t,e){var n=this;this.muted||setTimeout(function(){n.muted||t(e)},0)},ld),rd=(hd.prototype.close=function(){return this.Go.cancel()},hd.prototype.getMetadata=function(){return y(this,void 0,void 0,function(){return g(this,function(t){return[2,this.metadata.promise]})})},hd.prototype.Lo=function(){return y(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,this.getMetadata()];case 1:return[2,(t.sent(),this.Ho())]}})})},hd.prototype.Ho=function(){return y(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:return[4,this.Jo()];case 1:return null===(e=t.sent())?[2,null]:(r=this.zo.decode(e),n=Number(r),isNaN(n)&&this.Yo("length string ("+r+") is not valid number"),[4,this.Xo(n)]);case 2:return r=t.sent(),[2,new uf(JSON.parse(r),e.length+n)]}})})},hd.prototype.Zo=function(){return this.buffer.findIndex(function(t){return t==="{".charCodeAt(0)})},hd.prototype.Jo=function(){return y(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return this.Zo()<0?[4,this.tc()]:[3,3];case 1:if(t.sent())return[3,3];t.label=2;case 2:return[3,0];case 3:return 0===this.buffer.length?[2,null]:((e=this.Zo())<0&&this.Yo("Reached the end of bundle when a length string is expected."),n=this.buffer.slice(0,e),[2,(this.buffer=this.buffer.slice(e),n)])}})})},hd.prototype.Xo=function(n){return y(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return this.buffer.length<n?[4,this.tc()]:[3,3];case 1:t.sent()&&this.Yo("Reached the end of bundle when more is expected."),t.label=2;case 2:return[3,0];case 3:return e=this.zo.decode(this.buffer.slice(0,n)),[2,(this.buffer=this.buffer.slice(n),e)]}})})},hd.prototype.Yo=function(t){throw this.Go.cancel(),new Error("Invalid bundle format: "+t)},hd.prototype.tc=function(){return y(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return[4,this.Go.read()];case 1:return(e=t.sent()).done||((n=new Uint8Array(this.buffer.length+e.value.length)).set(this.buffer),n.set(e.value,this.buffer.length),this.buffer=n),[2,e.done]}})})},hd),id=(cd.prototype.lookup=function(r){return y(this,void 0,void 0,function(){var e,n=this;return g(this,function(t){switch(t.label){case 0:if(this.ensureCommitNotCalled(),0<this.mutations.length)throw new Ar(Dr.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,function(s,a){return y(this,void 0,void 0,function(){var n,e,r,i,o;return g(this,function(t){switch(t.label){case 0:return e=pa((n=s).R)+"/documents",r={documents:a.map(function(t){return ha(n.R,t)})},[4,n.Oi("BatchGetDocuments",e,r)];case 1:return r=t.sent(),i=new Map,r.forEach(function(t){var e,t=(e=n.R,"found"in(t=t)?function(t,e){Fr(!!e.found),e.found.name,e.found.updateTime;var n=la(t,e.found.name),t=aa(e.found.updateTime),e=new Ri({mapValue:{fields:e.found.fields}});return Oi.newFoundDocument(n,t,e)}(e,t):"missing"in t?function(t,e){Fr(!!e.missing),Fr(!!e.readTime);t=la(t,e.missing),e=aa(e.readTime);return Oi.newNoDocument(t,e)}(e,t):Mr());i.set(t.key.toString(),t)}),o=[],[2,(a.forEach(function(t){t=i.get(t.toString());Fr(!!t),o.push(t)}),o)]}})})}(this.datastore,r)];case 1:return[2,((e=t.sent()).forEach(function(t){return n.recordVersion(t)}),e)]}})})},cd.prototype.set=function(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())},cd.prototype.update=function(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t.toString())},cd.prototype.delete=function(t){this.write(new ws(t,this.precondition(t))),this.writtenDocs.add(t.toString())},cd.prototype.commit=function(){return y(this,void 0,void 0,function(){var e,n=this;return g(this,function(t){switch(t.label){case 0:if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;return e=this.readVersions,this.mutations.forEach(function(t){e.delete(t.key.toString())}),e.forEach(function(t,e){e=mi.fromPath(e);n.mutations.push(new Is(e,n.precondition(e)))}),[4,function(i,o){return y(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:return n=pa((e=i).R)+"/documents",r={writes:o.map(function(t){return va(e.R,t)})},[4,e.Ni("Commit",n,r)];case 1:return t.sent(),[2]}})})}(this.datastore,this.mutations)];case 1:return t.sent(),this.committed=!0,[2]}})})},cd.prototype.recordVersion=function(t){var e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw Mr();e=Gr.min()}var n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new Ar(Dr.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)},cd.prototype.precondition=function(t){var e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?es.updateTime(e):es.none()},cd.prototype.preconditionForUpdate=function(t){var e=this.readVersions.get(t.toString());if(this.writtenDocs.has(t.toString())||!e)return es.exists(!0);if(e.isEqual(Gr.min()))throw new Ar(Dr.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return es.updateTime(e)},cd.prototype.write=function(t){this.ensureCommitNotCalled(),this.mutations.push(t)},cd.prototype.ensureCommitNotCalled=function(){},cd),od=(ud.prototype.run=function(){this.nc()},ud.prototype.nc=function(){var t=this;this.Zi.ji(function(){return y(t,void 0,void 0,function(){var e,n,r=this;return g(this,function(t){return e=new id(this.datastore),(n=this.sc(e))&&n.then(function(t){r.asyncQueue.enqueueAndForget(function(){return e.commit().then(function(){r.deferred.resolve(t)}).catch(function(t){r.ic(t)})})}).catch(function(t){r.ic(t)}),[2]})})})},ud.prototype.sc=function(t){try{var e=this.updateFunction(t);return!pi(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}},ud.prototype.ic=function(t){var e=this;0<this.ec&&this.rc(t)?(--this.ec,this.asyncQueue.enqueueAndForget(function(){return e.nc(),Promise.resolve()})):this.deferred.reject(t)},ud.prototype.rc=function(t){if("FirebaseError"!==t.name)return!1;t=t.code;return"aborted"===t||"failed-precondition"===t||!_s(t)},ud),sd=(ad.prototype.getConfiguration=function(){return y(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,this.receivedInitialUser.promise];case 1:return[2,(t.sent(),{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,credentials:this.credentials,initialUser:this.user,maxConcurrentLimboResolutions:100})]}})})},ad.prototype.setCredentialChangeListener=function(t){var e=this;this.credentialListener=t,this.receivedInitialUser.promise.then(function(){return e.credentialListener(e.user)})},ad.prototype.verifyNotTerminated=function(){if(this.asyncQueue.isShuttingDown)throw new Ar(Dr.FAILED_PRECONDITION,"The client has already been terminated.")},ad.prototype.terminate=function(){var t=this;this.asyncQueue.enterRestrictedMode();var n=new Za;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(function(){return y(t,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return t.trys.push([0,5,,6]),this.onlineComponents?[4,this.onlineComponents.terminate()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.offlineComponents?[4,this.offlineComponents.terminate()]:[3,4];case 3:t.sent(),t.label=4;case 4:return this.credentials.removeChangeListener(),n.resolve(),[3,6];case 5:return e=t.sent(),e=Wl(e,"Failed to shutdown persistence"),n.reject(e),[3,6];case 6:return[2]}})})}),n.promise},ad);function ad(t,e,n){var r=this;this.credentials=t,this.asyncQueue=e,this.databaseInfo=n,this.user=Th.UNAUTHENTICATED,this.clientId=Vr.u(),this.credentialListener=function(){},this.receivedInitialUser=new Za,this.credentials.setChangeListener(function(t){xr("FirestoreClient","Received user=",t.uid),r.user=t,r.credentialListener(t),r.receivedInitialUser.resolve()})}function ud(t,e,n,r){this.asyncQueue=t,this.datastore=e,this.updateFunction=n,this.deferred=r,this.ec=5,this.Zi=new gl(this.asyncQueue,"transaction_retry")}function cd(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}function hd(t,e){var n=this;this.Go=t,this.R=e,this.metadata=new Za,this.buffer=new Uint8Array,this.zo=new TextDecoder("utf-8"),this.Ho().then(function(t){t&&t.io()?n.metadata.resolve(t.payload.metadata):n.metadata.reject(new Error("The first element of the bundle is not a metadata, it is\n             "+JSON.stringify(null==t?void 0:t.payload)))},function(t){return n.metadata.reject(t)})}function ld(t){this.observer=t,this.muted=!1}function fd(i,o){return y(this,void 0,void 0,function(){var e,n,r=this;return g(this,function(t){switch(t.label){case 0:return i.asyncQueue.verifyOperationInProgress(),xr("FirestoreClient","Initializing OfflineComponentProvider"),[4,i.getConfiguration()];case 1:return e=t.sent(),[4,o.initialize(e)];case 2:return t.sent(),n=e.initialUser,i.setCredentialChangeListener(function(e){n.isEqual(e)||(n=e,i.asyncQueue.enqueueRetryable(function(){return y(r,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,th(o.localStore,e)];case 1:return t.sent(),[2]}})})}))}),o.persistence.setDatabaseDeletedListener(function(){return i.terminate()}),i.offlineComponents=o,[2]}})})}function dd(r,i){return y(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return r.asyncQueue.verifyOperationInProgress(),[4,pd(r)];case 1:return e=t.sent(),xr("FirestoreClient","Initializing OnlineComponentProvider"),[4,r.getConfiguration()];case 2:return n=t.sent(),[4,i.initialize(e,n)];case 3:return t.sent(),r.setCredentialChangeListener(function(t){return r.asyncQueue.enqueueRetryable(function(){return function(r,i){return y(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return(e=r).asyncQueue.verifyOperationInProgress(),xr("RemoteStore","RemoteStore received new credentials"),n=Pl(e),e.$r.add(3),[4,Al(e)];case 1:return t.sent(),n&&e.Br.set("Unknown"),[4,e.remoteSyncer.handleCredentialChange(i)];case 2:return t.sent(),e.$r.delete(3),[4,Dl(e)];case 3:return t.sent(),[2]}})})}(i.remoteStore,t)})}),r.onlineComponents=i,[2]}})})}function pd(e){return y(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return e.offlineComponents?[3,2]:(xr("FirestoreClient","Using default OfflineComponentProvider"),[4,fd(e,new Hf)]);case 1:t.sent(),t.label=2;case 2:return[2,e.offlineComponents]}})})}function yd(e){return y(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return e.onlineComponents?[3,2]:(xr("FirestoreClient","Using default OnlineComponentProvider"),[4,dd(e,new Xf)]);case 1:t.sent(),t.label=2;case 2:return[2,e.onlineComponents]}})})}function gd(t){return pd(t).then(function(t){return t.persistence})}function md(t){return pd(t).then(function(t){return t.localStore})}function vd(t){return yd(t).then(function(t){return t.remoteStore})}function bd(t){return yd(t).then(function(t){return t.syncEngine})}function wd(r){return y(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return[4,yd(r)];case 1:return e=t.sent(),[2,((n=e.eventManager).onListen=function(s,a){return y(this,void 0,void 0,function(){var e,n,r,i,o;return g(this,function(t){switch(t.label){case 0:return e=jf(s),(o=e.Po.get(a))?(n=o.targetId,e.sharedClientState.addLocalQueryTarget(n),r=o.view.Ro(),[3,4]):[3,1];case 1:return[4,oh(e.localStore,No(a))];case 2:return i=t.sent(),o=e.sharedClientState.addLocalQueryTarget(i.targetId),n=i.targetId,[4,_f(e,a,n,"current"===o)];case 3:r=t.sent(),e.isPrimaryClient&&kl(e.remoteStore,i),t.label=4;case 4:return[2,r]}})})}.bind(null,e.syncEngine),n.onUnlisten=function(i,o){return y(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:return n=(e=i).Po.get(o),1<(r=e.Vo.get(n.targetId)).length?[2,(e.Vo.set(n.targetId,r.filter(function(t){return!Ao(t,o)})),void e.Po.delete(o))]:e.isPrimaryClient?(e.sharedClientState.removeLocalQueryTarget(n.targetId),e.sharedClientState.isActiveQueryTarget(n.targetId)?[3,2]:[4,sh(e.localStore,n.targetId,!1).then(function(){e.sharedClientState.clearQueryState(n.targetId),Cl(e.remoteStore,n.targetId),xf(e,n.targetId)}).catch(dc)]):[3,3];case 1:t.sent(),t.label=2;case 2:return[3,5];case 3:return xf(e,n.targetId),[4,sh(e.localStore,n.targetId,!0)];case 4:t.sent(),t.label=5;case 5:return[2]}})})}.bind(null,e.syncEngine),n)]}})})}function Id(n,r,i){var t=this;void 0===i&&(i={});var o=new Za;return n.asyncQueue.enqueueAndForget(function(){return y(t,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=function(n,r,i,o,s){var t=new nd({next:function(t){r.enqueueAndForget(function(){return of(n,a)});var e=t.docs.has(i);!e&&t.fromCache?s.reject(new Ar(Dr.UNAVAILABLE,"Failed to get document because the client is offline.")):e&&t.fromCache&&o&&"server"===o.source?s.reject(new Ar(Dr.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.)')):s.resolve(t)},error:function(t){return s.reject(t)}}),a=new af(bo(i.path),t,{includeMetadataChanges:!0,so:!0});return rf(n,a)},[4,wd(n)];case 1:return[2,e.apply(void 0,[t.sent(),n.asyncQueue,r,i,o])]}})})}),o.promise}function Ed(n,r,i){var t=this;void 0===i&&(i={});var o=new Za;return n.asyncQueue.enqueueAndForget(function(){return y(t,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=function(e,n,t,r,i){var o=new nd({next:function(t){n.enqueueAndForget(function(){return of(e,s)}),t.fromCache&&"server"===r.source?i.reject(new Ar(Dr.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(t)},error:function(t){return i.reject(t)}}),s=new af(t,o,{includeMetadataChanges:!0,so:!0});return rf(e,s)},[4,wd(n)];case 1:return[2,e.apply(void 0,[t.sent(),n.asyncQueue,r,i,o])]}})})}),o.promise}function Td(t,e){this.user=e,this.type="OAuth",this.authHeaders={},this.authHeaders.Authorization="Bearer "+t}var _d=function(t,e,n,r,i,o,s){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=o,this.autoDetectLongPolling=s},Sd=(Object.defineProperty(Pd.prototype,"isDefaultDatabase",{get:function(){return"(default)"===this.database},enumerable:!1,configurable:!0}),Pd.prototype.isEqual=function(t){return t instanceof Pd&&t.projectId===this.projectId&&t.database===this.database},Pd),Nd=new Map,Dd=(Ld.prototype.getToken=function(){return Promise.resolve(null)},Ld.prototype.invalidateToken=function(){},Ld.prototype.setChangeListener=function(t){(this.changeListener=t)(Th.UNAUTHENTICATED)},Ld.prototype.removeChangeListener=function(){this.changeListener=null},Ld),Ad=(Od.prototype.getToken=function(){var e=this,n=this.cc,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(function(t){return e.cc!==n?(xr("FirebaseCredentialsProvider","getToken aborted due to token change."),e.getToken()):t?(Fr("string"==typeof t.accessToken),new Td(t.accessToken,e.currentUser)):null}):Promise.resolve(null)},Od.prototype.invalidateToken=function(){this.forceRefresh=!0},Od.prototype.setChangeListener=function(t){this.changeListener=t,this.receivedInitialUser&&t(this.currentUser)},Od.prototype.removeChangeListener=function(){this.auth&&this.auth.removeAuthTokenListener(this.oc),this.oc=null,this.changeListener=null},Od.prototype.uc=function(){var t=this.auth&&this.auth.getUid();return Fr(null===t||"string"==typeof t),new Th(t)},Od),kd=(Object.defineProperty(xd.prototype,"authHeaders",{get:function(){var t={"X-Goog-AuthUser":this.hc},e=this.ac.auth.getAuthHeaderValueForFirstParty([]);return e&&(t.Authorization=e),this.lc&&(t["X-Goog-Iam-Authorization-Token"]=this.lc),t},enumerable:!1,configurable:!0}),xd),Cd=(Rd.prototype.getToken=function(){return Promise.resolve(new kd(this.ac,this.hc,this.lc))},Rd.prototype.setChangeListener=function(t){t(Th.FIRST_PARTY)},Rd.prototype.removeChangeListener=function(){},Rd.prototype.invalidateToken=function(){},Rd);function Rd(t,e,n){this.ac=t,this.hc=e,this.lc=n}function xd(t,e,n){this.ac=t,this.hc=e,this.lc=n,this.type="FirstParty",this.user=Th.FIRST_PARTY}function Od(t){var e=this;this.oc=null,this.currentUser=Th.UNAUTHENTICATED,this.receivedInitialUser=!1,this.cc=0,this.changeListener=null,this.forceRefresh=!1,this.oc=function(){e.cc++,e.currentUser=e.uc(),e.receivedInitialUser=!0,e.changeListener&&e.changeListener(e.currentUser)},this.cc=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.oc):(this.oc(null),t.get().then(function(t){e.auth=t,e.oc&&e.auth.addAuthTokenListener(e.oc)},function(){}))}function Ld(){this.changeListener=null}function Pd(t,e){this.projectId=t,this.database=e||"(default)"}function Md(t,e,n){if(!n)throw new Ar(Dr.INVALID_ARGUMENT,"Function "+t+"() cannot be called with an empty "+e+".")}function Fd(t,e){if(void 0===e)return{merge:!1};if(void 0!==e.mergeFields&&void 0!==e.merge)throw new Ar(Dr.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function Vd(t,e,n,r){if(!0===e&&!0===r)throw new Ar(Dr.INVALID_ARGUMENT,t+" and "+n+" cannot be used together.")}function Ud(t){if(!mi.isDocumentKey(t))throw new Ar(Dr.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t+" has "+t.length+".")}function qd(t){if(mi.isDocumentKey(t))throw new Ar(Dr.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t+" has "+t.length+".")}function Bd(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return 20<e.length&&(e=e.substring(0,20)+"..."),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"!=typeof e)return"function"==typeof e?"a function":Mr();if(e instanceof Array)return"an array";var t=function(){if(e.constructor){var t=/function\s+([^\s(]+)\s*\(/.exec(e.constructor.toString());if(t&&1<t.length)return t[1]}return null}();return t?"a custom "+t+" object":"an object"}function jd(t,e){if((t="_delegate"in t?t._delegate:t)instanceof e)return t;if(e.name===t.constructor.name)throw new Ar(Dr.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");t=Bd(t);throw new Ar(Dr.INVALID_ARGUMENT,"Expected type '"+e.name+"', but it was: "+t)}function Kd(t,e){if(e<=0)throw new Ar(Dr.INVALID_ARGUMENT,"Function "+t+"() requires a positive number, but it was: "+e+".")}var Gd,Qd=(tp.prototype.isEqual=function(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties},tp),zd=(Object.defineProperty(Zd.prototype,"app",{get:function(){if(!this._app)throw new Ar(Dr.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app},enumerable:!1,configurable:!0}),Object.defineProperty(Zd.prototype,"_initialized",{get:function(){return this._settingsFrozen},enumerable:!1,configurable:!0}),Object.defineProperty(Zd.prototype,"_terminated",{get:function(){return void 0!==this._terminateTask},enumerable:!1,configurable:!0}),Zd.prototype._setSettings=function(t){if(this._settingsFrozen)throw new Ar(Dr.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new Qd(t),void 0!==t.credentials&&(this._credentials=function(t){if(!t)return new Dd;switch(t.type){case"gapi":var e=t.client;return Fr(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new Cd(e,t.sessionIndex||"0",t.iamToken||null);case"provider":return t.client;default:throw new Ar(Dr.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(t.credentials))},Zd.prototype._getSettings=function(){return this._settings},Zd.prototype._freezeSettings=function(){return this._settingsFrozen=!0,this._settings},Zd.prototype._delete=function(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask},Zd.prototype.toJSON=function(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}},Zd.prototype._terminate=function(){return(t=Nd.get(this))&&(xr("ComponentProvider","Removing Datastore"),Nd.delete(this),t.terminate()),Promise.resolve();var t},Zd),Hd=(Object.defineProperty($d.prototype,"_path",{get:function(){return this._key.path},enumerable:!1,configurable:!0}),Object.defineProperty($d.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty($d.prototype,"path",{get:function(){return this._key.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty($d.prototype,"parent",{get:function(){return new Yd(this.firestore,this._converter,this._key.path.popLast())},enumerable:!1,configurable:!0}),$d.prototype.withConverter=function(t){return new $d(this.firestore,t,this._key)},$d),Wd=(Jd.prototype.withConverter=function(t){return new Jd(this.firestore,t,this._query)},Jd),Yd=(n(Xd,Gd=Wd),Object.defineProperty(Xd.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(Xd.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty(Xd.prototype,"parent",{get:function(){var t=this._path.popLast();return t.isEmpty()?null:new Hd(this.firestore,null,new mi(t))},enumerable:!1,configurable:!0}),Xd.prototype.withConverter=function(t){return new Xd(this.firestore,t,this._path)},Xd);function Xd(t,e,n){var r=this;return(r=Gd.call(this,t,e,bo(n))||this)._path=n,r.type="collection",r}function Jd(t,e,n){this._converter=e,this._query=n,this.type="query",this.firestore=t}function $d(t,e,n){this._converter=e,this._key=n,this.type="document",this.firestore=t}function Zd(t,e){this._persistenceKey="(lite)",this._settings=new Qd({}),this._settingsFrozen=!1,t instanceof Sd?(this._databaseId=t,this._credentials=new Dd):(this._app=t,this._databaseId=function(t){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new Ar(Dr.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Sd(t.options.projectId)}(t),this._credentials=new Ad(e))}function tp(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new Ar(Dr.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=null===(e=t.ssl)||void 0===e||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new Ar(Dr.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,Vd("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}function ep(t,e){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];if(t=m(t),Md("collection","path",e),t instanceof zd)return qd(n=$r.fromString.apply($r,s([e],r))),new Yd(t,null,n);if(!(t instanceof Hd||t instanceof Yd))throw new Ar(Dr.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return qd(n=$r.fromString.apply($r,s([t.path],r)).child($r.fromString(e))),new Yd(t.firestore,null,n)}function np(t,e){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];if(t=m(t),Md("doc","path",e=1===arguments.length?Vr.u():e),t instanceof zd)return Ud(n=$r.fromString.apply($r,s([e],r))),new Hd(t,null,new mi(n));if(!(t instanceof Hd||t instanceof Yd))throw new Ar(Dr.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return Ud(n=t._path.child($r.fromString.apply($r,s([e],r)))),new Hd(t.firestore,t instanceof Yd?t._converter:null,new mi(n))}function rp(t,e){return t=m(t),e=m(e),(t instanceof Hd||t instanceof Yd)&&(e instanceof Hd||e instanceof Yd)&&t.firestore===e.firestore&&t.path===e.path&&t._converter===e._converter}function ip(t,e){return t=m(t),e=m(e),t instanceof Wd&&e instanceof Wd&&t.firestore===e.firestore&&Ao(t._query,e._query)&&t._converter===e._converter}var op=(Object.defineProperty(sp.prototype,"isShuttingDown",{get:function(){return this.wc},enumerable:!1,configurable:!0}),sp.prototype.enqueueAndForget=function(t){this.enqueue(t)},sp.prototype.enqueueAndForgetEvenWhileRestricted=function(t){this.Tc(),this.Ic(t)},sp.prototype.enterRestrictedMode=function(){var t;this.wc||(this.wc=!0,(t=hl())&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Ec))},sp.prototype.enqueue=function(t){return this.Tc(),this.wc?new Promise(function(t){}):this.Ic(t)},sp.prototype.enqueueRetryable=function(t){var e=this;this.enqueueAndForget(function(){return e.dc.push(t),e.Ac()})},sp.prototype.Ac=function(){return y(this,void 0,void 0,function(){var e,n=this;return g(this,function(t){switch(t.label){case 0:if(0===this.dc.length)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.dc[0]()];case 2:return t.sent(),this.dc.shift(),this.Zi.reset(),[3,4];case 3:if(!lu(e=t.sent()))throw e;return xr("AsyncQueue","Operation failed with retryable error: "+e),[3,4];case 4:0<this.dc.length&&this.Zi.ji(function(){return n.Ac()}),t.label=5;case 5:return[2]}})})},sp.prototype.Ic=function(t){var r=this,e=this.fc.then(function(){return r.yc=!0,t().catch(function(t){throw r.mc=t,r.yc=!1,Or("INTERNAL UNHANDLED ERROR: ",(n=(e=t).message||"",n=e.stack?e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack:n)),t;var e,n}).then(function(t){return r.yc=!1,t})});return this.fc=e},sp.prototype.enqueueAfterDelay=function(t,e,n){var r=this;this.Tc(),-1<this.gc.indexOf(t)&&(e=0);n=zl.createAndSchedule(this,t,e,n,function(t){return r.Rc(t)});return this._c.push(n),n},sp.prototype.Tc=function(){this.mc&&Mr()},sp.prototype.verifyOperationInProgress=function(){},sp.prototype.bc=function(){return y(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,e=this.fc];case 1:t.sent(),t.label=2;case 2:if(e!==this.fc)return[3,0];t.label=3;case 3:return[2]}})})},sp.prototype.vc=function(t){for(var e=0,n=this._c;e<n.length;e++)if(n[e].timerId===t)return!0;return!1},sp.prototype.Pc=function(r){var i=this;return this.bc().then(function(){i._c.sort(function(t,e){return t.targetTimeMs-e.targetTimeMs});for(var t=0,e=i._c;t<e.length;t++){var n=e[t];if(n.skipDelay(),"all"!==r&&n.timerId===r)break}return i.bc()})},sp.prototype.Vc=function(t){this.gc.push(t)},sp.prototype.Rc=function(t){t=this._c.indexOf(t);this._c.splice(t,1)},sp);function sp(){var e=this;this.fc=Promise.resolve(),this.dc=[],this.wc=!1,this._c=[],this.mc=null,this.yc=!1,this.gc=[],this.Zi=new gl(this,"async_queue_retry"),this.Ec=function(){var t=hl();t&&xr("AsyncQueue","Visibility state changed to "+t.visibilityState),e.Zi.Gi()};var t=hl();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.Ec)}function ap(i){return function(){if("object"==typeof i&&null!==i)for(var t=i,e=0,n=["next","error","complete"];e<n.length;e++){var r=n[e];if(r in t&&"function"==typeof t[r])return 1}}()}var up,cp=(fp.prototype.onProgress=function(t,e,n){this._progressObserver={next:t,error:e,complete:n}},fp.prototype.catch=function(t){return this._taskCompletionResolver.promise.catch(t)},fp.prototype.then=function(t,e){return this._taskCompletionResolver.promise.then(t,e)},fp.prototype._completeWith=function(t){this._updateProgress(t),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(t)},fp.prototype._failWith=function(t){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(t),this._taskCompletionResolver.reject(t)},fp.prototype._updateProgress=function(t){this._lastProgress=t,this._progressObserver.next&&this._progressObserver.next(t)},fp),hp=(n(lp,up=zd),lp.prototype._terminate=function(){return this._firestoreClient||pp(this),this._firestoreClient.terminate()},lp);function lp(t,e){var n=this;return(n=up.call(this,t,e)||this)._queue=new op,n._persistenceKey="name"in t?t.name:"[DEFAULT]",n}function fp(){this._progressObserver={},this._taskCompletionResolver=new Za,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}function dp(t){return t._firestoreClient||pp(t),t._firestoreClient.verifyNotTerminated(),t._firestoreClient}function pp(t){var e,n,r,i=t._freezeSettings(),i=(e=t._databaseId,n=(null===(r=t._app)||void 0===r?void 0:r.options.appId)||"",r=t._persistenceKey,new _d(e,n,r,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling));t._firestoreClient=new sd(t._credentials,t._queue,i)}function yp(r,i,o){var t=this,s=new Za;return r.asyncQueue.enqueue(function(){return y(t,void 0,void 0,function(){var n;return g(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),[4,fd(r,o)];case 1:return t.sent(),[4,dd(r,i)];case 2:return t.sent(),s.resolve(),[3,4];case 3:if(!("FirebaseError"===(e=n=t.sent()).name?e.code===Dr.FAILED_PRECONDITION||e.code===Dr.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&e instanceof DOMException)||22===e.code||20===e.code||11===e.code))throw n;return console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+n),s.reject(n),[3,4];case 4:return[2]}var e})})}).then(function(){return s.promise})}function gp(t){if(t._initialized||t._terminated)throw new Ar(Dr.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}var mp=(Ap.prototype.isEqual=function(t){return this._internalPath.isEqual(t._internalPath)},Ap),vp=(Dp.fromBase64String=function(t){try{return new Dp(ni.fromBase64String(t))}catch(t){throw new Ar(Dr.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}},Dp.fromUint8Array=function(t){return new Dp(ni.fromUint8Array(t))},Dp.prototype.toBase64=function(){return this._byteString.toBase64()},Dp.prototype.toUint8Array=function(){return this._byteString.toUint8Array()},Dp.prototype.toString=function(){return"Bytes(base64: "+this.toBase64()+")"},Dp.prototype.isEqual=function(t){return this._byteString.isEqual(t._byteString)},Dp),bp=function(t){this._methodName=t},wp=(Object.defineProperty(Np.prototype,"latitude",{get:function(){return this._lat},enumerable:!1,configurable:!0}),Object.defineProperty(Np.prototype,"longitude",{get:function(){return this._long},enumerable:!1,configurable:!0}),Np.prototype.isEqual=function(t){return this._lat===t._lat&&this._long===t._long},Np.prototype.toJSON=function(){return{latitude:this._lat,longitude:this._long}},Np.prototype._compareTo=function(t){return qr(this._lat,t._lat)||qr(this._long,t._long)},Np),Ip=/^__.*__$/,Ep=(Sp.prototype.toMutation=function(t,e){return null!==this.fieldMask?new hs(t,this.data,this.fieldMask,e,this.fieldTransforms):new cs(t,this.data,e,this.fieldTransforms)},Sp),Tp=(_p.prototype.toMutation=function(t,e){return new hs(t,this.data,this.fieldMask,e,this.fieldTransforms)},_p);function _p(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}function Sp(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}function Np(t,e){if(!isFinite(t)||t<-90||90<t)throw new Ar(Dr.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||180<e)throw new Ar(Dr.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}function Dp(t){this._byteString=t}function Ap(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0;n<t.length;++n)if(0===t[n].length)throw new Ar(Dr.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ti(t)}function kp(t){switch(t){case 0:case 2:case 1:return 1;case 3:case 4:return;default:throw Mr()}}var Cp=(Object.defineProperty(Op.prototype,"path",{get:function(){return this.settings.path},enumerable:!1,configurable:!0}),Object.defineProperty(Op.prototype,"Dc",{get:function(){return this.settings.Dc},enumerable:!1,configurable:!0}),Op.prototype.Cc=function(t){return new Op(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.R,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)},Op.prototype.Nc=function(t){var e=null===(e=this.path)||void 0===e?void 0:e.child(t),e=this.Cc({path:e,xc:!1});return e.Fc(t),e},Op.prototype.kc=function(t){var e,t=null===(e=this.path)||void 0===e?void 0:e.child(t),t=this.Cc({path:t,xc:!1});return t.Sc(),t},Op.prototype.Oc=function(t){return this.Cc({path:void 0,xc:!0})},Op.prototype.$c=function(t){return uy(t,this.settings.methodName,this.settings.Mc||!1,this.path,this.settings.Lc)},Op.prototype.contains=function(e){return void 0!==this.fieldMask.find(function(t){return e.isPrefixOf(t)})||void 0!==this.fieldTransforms.find(function(t){return e.isPrefixOf(t.field)})},Op.prototype.Sc=function(){if(this.path)for(var t=0;t<this.path.length;t++)this.Fc(this.path.get(t))},Op.prototype.Fc=function(t){if(0===t.length)throw this.$c("Document fields must not be empty");if(kp(this.Dc)&&Ip.test(t))throw this.$c('Document fields cannot begin and end with "__"')},Op),Rp=(xp.prototype.Bc=function(t,e,n,r){return void 0===r&&(r=!1),new Cp({Dc:t,methodName:e,Lc:n,path:ti.emptyPath(),xc:!1,Mc:r},this.databaseId,this.R,this.ignoreUndefinedProperties)},xp);function xp(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.R=n||ll(t)}function Op(t,e,n,r,i,o){this.settings=t,this.databaseId=e,this.R=n,this.ignoreUndefinedProperties=r,void 0===i&&this.Sc(),this.fieldTransforms=i||[],this.fieldMask=o||[]}function Lp(t){var e=t._freezeSettings(),n=ll(t._databaseId);return new Rp(t._databaseId,!!e.ignoreUndefinedProperties,n)}function Pp(t,e,n,r,i,o){void 0===o&&(o={});var s=t.Bc(o.merge||o.mergeFields?2:0,e,n,i);iy("Data must be an object, but it was:",s,r);var a,u,r=ny(r,s);if(o.merge)a=new ei(s.fieldMask),u=s.fieldTransforms;else if(o.mergeFields){for(var c=[],h=0,l=o.mergeFields;h<l.length;h++){var f=oy(e,l[h],n);if(!s.contains(f))throw new Ar(Dr.INVALID_ARGUMENT,"Field '"+f+"' is specified in your field mask but missing from your input data.");cy(c,f)||c.push(f)}a=new ei(c),u=s.fieldTransforms.filter(function(t){return a.covers(t.field)})}else a=null,u=s.fieldTransforms;return new Ep(new Ri(r),a,u)}var Mp,Fp=(n(Vp,Mp=bp),Vp.prototype._toFieldTransform=function(t){if(2!==t.Dc)throw 1===t.Dc?t.$c(this._methodName+"() can only appear at the top level of your update data"):t.$c(this._methodName+"() cannot be used with set() unless you pass {merge:true}");return t.fieldMask.push(t.path),null},Vp.prototype.isEqual=function(t){return t instanceof Vp},Vp);function Vp(){return null!==Mp&&Mp.apply(this,arguments)||this}function Up(t,e,n){return new Cp({Dc:3,Lc:e.settings.Lc,methodName:t._methodName,xc:n},e.databaseId,e.R,e.ignoreUndefinedProperties)}var qp,Bp,jp,Kp,Gp=(n(Jp,Kp=bp),Jp.prototype._toFieldTransform=function(t){return new ts(t.path,new Uo)},Jp.prototype.isEqual=function(t){return t instanceof Jp},Jp),Qp=(n(Xp,jp=bp),Xp.prototype._toFieldTransform=function(t){var e=Up(this,t,!0),n=this.qc.map(function(t){return ey(t,e)}),n=new qo(n);return new ts(t.path,n)},Xp.prototype.isEqual=function(t){return this===t},Xp),zp=(n(Yp,Bp=bp),Yp.prototype._toFieldTransform=function(t){var e=Up(this,t,!0),n=this.qc.map(function(t){return ey(t,e)}),n=new Qo(n);return new ts(t.path,n)},Yp.prototype.isEqual=function(t){return this===t},Yp),Hp=(n(Wp,qp=bp),Wp.prototype._toFieldTransform=function(t){var e=new Yo(t.R,Po(t.R,this.Uc));return new ts(t.path,e)},Wp.prototype.isEqual=function(t){return this===t},Wp);function Wp(t,e){var n=this;return(n=qp.call(this,t)||this).Uc=e,n}function Yp(t,e){var n=this;return(n=Bp.call(this,t)||this).qc=e,n}function Xp(t,e){var n=this;return(n=jp.call(this,t)||this).qc=e,n}function Jp(){return null!==Kp&&Kp.apply(this,arguments)||this}function $p(t,r,i,e){var o=t.Bc(1,r,i);iy("Data must be an object, but it was:",o,e);var s=[],a=Ri.empty();Wr(e,function(t,e){var n=ay(r,t,i);e=m(e);t=o.kc(n);e instanceof Fp?s.push(n):null!=(t=ey(e,t))&&(s.push(n),a.set(n,t))});e=new ei(s);return new Tp(a,e,o.fieldTransforms)}function Zp(t,e,n,r,i,o){var s=t.Bc(1,e,n),a=[oy(e,r,n)],u=[i];if(o.length%2!=0)throw new Ar(Dr.INVALID_ARGUMENT,"Function "+e+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var c=0;c<o.length;c+=2)a.push(oy(e,o[c])),u.push(o[c+1]);for(var h,l,f,d=[],p=Ri.empty(),y=a.length-1;0<=y;--y)cy(d,a[y])||(h=a[y],l=m(l=u[y]),f=s.kc(h),l instanceof Fp?d.push(h):null!=(f=ey(l,f))&&(d.push(h),p.set(h,f)));i=new ei(d);return new Tp(p,i,s.fieldTransforms)}function ty(t,e,n,r){return void 0===r&&(r=!1),ey(n,t.Bc(r?4:3,e))}function ey(s,t){if(ry(s=m(s)))return iy("Unsupported field value:",t,s),ny(s,t);if(s instanceof bp)return function(t,e){if(!kp(e.Dc))throw e.$c(t._methodName+"() can only be used with update() and set()");if(!e.path)throw e.$c(t._methodName+"() is not currently supported inside arrays");t=t._toFieldTransform(e);t&&e.fieldTransforms.push(t)}(s,t),null;if(void 0===s&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),s instanceof Array){if(t.settings.xc&&4!==t.Dc)throw t.$c("Nested arrays are not supported");return function(t){for(var e=[],n=0,r=0,i=s;r<i.length;r++){var o=ey(i[r],t.Oc(n));null==o&&(o={nullValue:"NULL_VALUE"}),e.push(o),n++}return{arrayValue:{values:e}}}(t)}return function(t,e){if(null===(t=m(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t)return Po(e.R,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var n=Kr.fromDate(t);return{timestampValue:oa(e.R,n)}}if(t instanceof Kr)return n=new Kr(t.seconds,1e3*Math.floor(t.nanoseconds/1e3)),{timestampValue:oa(e.R,n)};if(t instanceof wp)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof vp)return{bytesValue:sa(e.R,t._byteString)};if(t instanceof Hd){var n=e.databaseId,r=t.firestore._databaseId;if(!r.isEqual(n))throw e.$c("Document reference is for database "+r.projectId+"/"+r.database+" but should be for database "+n.projectId+"/"+n.database);return{referenceValue:ua(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.$c("Unsupported field value: "+Bd(t))}(s,t)}function ny(t,n){var r={};return Yr(t)?n.path&&0<n.path.length&&n.fieldMask.push(n.path):Wr(t,function(t,e){e=ey(e,n.Nc(t));null!=e&&(r[t]=e)}),{mapValue:{fields:r}}}function ry(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Kr||t instanceof wp||t instanceof vp||t instanceof Hd||t instanceof bp)}function iy(t,e,n){if(!ry(n)||("object"!=typeof(r=n)||null===r||Object.getPrototypeOf(r)!==Object.prototype&&null!==Object.getPrototypeOf(r))){n=Bd(n);throw"an object"===n?e.$c(t+" a custom object"):e.$c(t+" "+n)}var r}function oy(t,e,n){if((e=m(e))instanceof mp)return e._internalPath;if("string"==typeof e)return ay(t,e);throw uy("Field path arguments must be of type string or FieldPath.",t,!1,void 0,n)}var sy=new RegExp("[~\\*/\\[\\]]");function ay(e,n,r){if(0<=n.search(sy))throw uy("Invalid field path ("+n+"). Paths must not contain '~', '*', '/', '[', or ']'",e,!1,void 0,r);try{return(new(mp.bind.apply(mp,s([void 0],n.split(".")))))._internalPath}catch(t){throw uy("Invalid field path ("+n+"). Paths must not be empty, begin with '.', end with '.', or contain '..'",e,!1,void 0,r)}}function uy(t,e,n,r,i){var o=r&&!r.isEmpty(),s=void 0!==i,e="Function "+e+"() called with invalid data";n&&(e+=" (via `toFirestore()`)");n="";return(o||s)&&(n+=" (found",o&&(n+=" in field "+r),s&&(n+=" in document "+i),n+=")"),new Ar(Dr.INVALID_ARGUMENT,(e+=". ")+t+n)}function cy(t,e){return t.some(function(t){return t.isEqual(e)})}var hy,ly=(Object.defineProperty(py.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(py.prototype,"ref",{get:function(){return new Hd(this._firestore,this._converter,this._key)},enumerable:!1,configurable:!0}),py.prototype.exists=function(){return null!==this._document},py.prototype.data=function(){if(this._document){if(this._converter){var t=new fy(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.toProto())}},py.prototype.get=function(t){if(this._document){t=this._document.data.field(yy("DocumentSnapshot.get",t));if(null!==t)return this._userDataWriter.convertValue(t)}},py),fy=(n(dy,hy=ly),dy.prototype.data=function(){return hy.prototype.data.call(this)},dy);function dy(){return null!==hy&&hy.apply(this,arguments)||this}function py(t,e,n,r,i){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=r,this._converter=i}function yy(t,e){return"string"==typeof e?ay(t,e):(e instanceof mp?e:e._delegate)._internalPath}var gy,my,vy=(Sy.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},Sy),by=(n(_y,my=ly),_y.prototype.exists=function(){return my.prototype.exists.call(this)},_y.prototype.data=function(t){if(void 0===t&&(t={}),this._document){if(this._converter){var e=new wy(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.toProto(),t.serverTimestamps)}},_y.prototype.get=function(t,e){if(void 0===e&&(e={}),this._document){t=this._document.data.field(yy("DocumentSnapshot.get",t));if(null!==t)return this._userDataWriter.convertValue(t,e.serverTimestamps)}},_y),wy=(n(Ty,gy=by),Ty.prototype.data=function(t){return void 0===t&&(t={}),gy.prototype.data.call(this,t)},Ty),Iy=(Object.defineProperty(Ey.prototype,"docs",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!1,configurable:!0}),Object.defineProperty(Ey.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!1,configurable:!0}),Object.defineProperty(Ey.prototype,"empty",{get:function(){return 0===this.size},enumerable:!1,configurable:!0}),Ey.prototype.forEach=function(e,n){var r=this;this._snapshot.docs.forEach(function(t){e.call(n,new wy(r._firestore,r._userDataWriter,t.key,t,new vy(r._snapshot.mutatedKeys.has(t.key),r._snapshot.fromCache),r.query._converter))})},Ey.prototype.docChanges=function(t){t=!!(t=void 0===t?{}:t).includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new Ar(Dr.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(i,e){if(i._snapshot.oldDocs.isEmpty()){var n=0;return i._snapshot.docChanges.map(function(t){var e=new wy(i._firestore,i._userDataWriter,t.doc.key,t.doc,new vy(i._snapshot.mutatedKeys.has(t.doc.key),i._snapshot.fromCache),i.query._converter);return t.doc,{type:"added",doc:e,oldIndex:-1,newIndex:n++}})}var o=i._snapshot.oldDocs;return i._snapshot.docChanges.filter(function(t){return e||3!==t.type}).map(function(t){var e=new wy(i._firestore,i._userDataWriter,t.doc.key,t.doc,new vy(i._snapshot.mutatedKeys.has(t.doc.key),i._snapshot.fromCache),i.query._converter),n=-1,r=-1;return 0!==t.type&&(n=o.indexOf(t.doc.key),o=o.delete(t.doc.key)),1!==t.type&&(r=(o=o.add(t.doc)).indexOf(t.doc.key)),{type:function(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Mr()}}(t.type),doc:e,oldIndex:n,newIndex:r}})}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges},Ey);function Ey(t,e,n,r){this._firestore=t,this._userDataWriter=e,this._snapshot=r,this.metadata=new vy(r.hasPendingWrites,r.fromCache),this.query=n}function Ty(){return null!==gy&&gy.apply(this,arguments)||this}function _y(t,e,n,r,i,o){var s=this;return(s=my.call(this,t,e,n,r,o)||this)._firestore=t,s._firestoreImpl=t,s.metadata=i,s}function Sy(t,e){this.hasPendingWrites=t,this.fromCache=e}function Ny(t,e){return t instanceof by&&e instanceof by?t._firestore===e._firestore&&t._key.isEqual(e._key)&&(null===t._document?null===e._document:t._document.isEqual(e._document))&&t._converter===e._converter:t instanceof Iy&&e instanceof Iy&&t._firestore===e._firestore&&ip(t.query,e.query)&&t.metadata.isEqual(e.metadata)&&t._snapshot.isEqual(e._snapshot)}function Dy(t){if(Io(t)&&0===t.explicitOrderBy.length)throw new Ar(Dr.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}Te=function(){};function Ay(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0,i=e;r<i.length;r++)t=i[r]._apply(t);return t}var ky,Cy,Ry,xy,Oy,Ly=(n(Ky,Oy=Te),Ky.prototype._apply=function(t){var e=Lp(t.firestore),e=function(t,e,n,r,i,o){if(r.isKeyField()){if("array-contains"===i||"array-contains-any"===i)throw new Ar(Dr.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+i+"' queries on FieldPath.documentId().");if("in"===i||"not-in"===i){zy(o,i);for(var s=[],a=0,u=o;a<u.length;a++){var c=u[a];s.push(Qy(n,t,c))}h={arrayValue:{values:s}}}else h=Qy(n,t,o)}else"in"!==i&&"not-in"!==i&&"array-contains-any"!==i||zy(o,i),h=ty(e,"where",o,"in"===i||"not-in"===i);var h=Bi.create(r,i,h);return function(t,e){if(e.g()){var n=To(t);if(null!==n&&!n.isEqual(e.field))throw new Ar(Dr.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '"+n.toString()+"' and '"+e.field.toString()+"'");n=Eo(t);null!==n&&Hy(0,e.field,n)}t=function(t,e){for(var n=0,r=t.filters;n<r.length;n++){var i=r[n];if(0<=e.indexOf(i.op))return i.op}return null}(t,function(){switch(e.op){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}());if(null!==t)throw t===e.op?new Ar(Dr.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+e.op.toString()+"' filter."):new Ar(Dr.INVALID_ARGUMENT,"Invalid query. You cannot use '"+e.op.toString()+"' filters with '"+t.toString()+"' filters.")}(t,h),h}(t._query,e,t.firestore._databaseId,this.Qc,this.Kc,this.jc);return new Wd(t.firestore,t._converter,(t=t._query,e=t.filters.concat([e]),new mo(t.path,t.collectionGroup,t.explicitOrderBy.slice(),e,t.limit,t.limitType,t.startAt,t.endAt)))},Ky),Py=(n(jy,xy=Te),jy.prototype._apply=function(t){var e=function(t,e,n){if(null!==t.startAt)throw new Ar(Dr.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new Ar(Dr.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r=new po(e,n);return e=r,null!==Eo(n=t)||null!==(t=To(n))&&Hy(0,t,e.field),r}(t._query,this.Qc,this.Wc);return new Wd(t.firestore,t._converter,(t=t._query,e=t.explicitOrderBy.concat([e]),new mo(t.path,t.collectionGroup,e,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)))},jy),My=(n(By,Ry=Te),By.prototype._apply=function(t){return new Wd(t.firestore,t._converter,Do(t._query,this.Gc,this.zc))},By),Fy=(n(qy,Cy=Te),qy.prototype._apply=function(t){var e=Gy(t,this.type,this.Hc,this.Jc);return new Wd(t.firestore,t._converter,(t=t._query,e=e,new mo(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)))},qy),Vy=(n(Uy,ky=Te),Uy.prototype._apply=function(t){var e=Gy(t,this.type,this.Hc,this.Jc);return new Wd(t.firestore,t._converter,(t=t._query,e=e,new mo(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)))},Uy);function Uy(t,e,n){var r=this;return(r=ky.call(this)||this).type=t,r.Hc=e,r.Jc=n,r}function qy(t,e,n){var r=this;return(r=Cy.call(this)||this).type=t,r.Hc=e,r.Jc=n,r}function By(t,e,n){var r=this;return(r=Ry.call(this)||this).type=t,r.Gc=e,r.zc=n,r}function jy(t,e){var n=this;return(n=xy.call(this)||this).Qc=t,n.Wc=e,n.type="orderBy",n}function Ky(t,e,n){var r=this;return(r=Oy.call(this)||this).Qc=t,r.Kc=e,r.jc=n,r.type="where",r}function Gy(t,c,e,n){if(e[0]=m(e[0]),e[0]instanceof ly)return function(t,e,n,r){if(!n)throw new Ar(Dr.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+c+"().");for(var i=[],o=0,s=So(t);o<s.length;o++){var a=s[o];if(a.field.isKeyField())i.push(Si(e,n.key));else{var u=n.data.field(a.field);if(fi(u))throw new Ar(Dr.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+a.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===u){a=a.field.canonicalString();throw new Ar(Dr.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+a+"' (used as the orderBy) does not exist.")}i.push(u)}}return new ao(i,r)}(t._query,t.firestore._databaseId,e[0]._document,n);var r=Lp(t.firestore);return function(t,e,n,r,i,o){var s=t.explicitOrderBy;if(i.length>s.length)throw new Ar(Dr.INVALID_ARGUMENT,"Too many arguments provided to "+r+"(). The number of arguments must be less than or equal to the number of orderBy() clauses");for(var a=[],u=0;u<i.length;u++){var c=i[u];if(s[u].field.isKeyField()){if("string"!=typeof c)throw new Ar(Dr.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+r+"(), but got a "+typeof c);if(!_o(t)&&-1!==c.indexOf("/"))throw new Ar(Dr.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 '"+c+"' contains a slash.");var h=t.path.child($r.fromString(c));if(!mi.isDocumentKey(h))throw new Ar(Dr.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 '"+h+"' is not because it contains an odd number of segments.");h=new mi(h);a.push(Si(e,h))}else{c=ty(n,r,c);a.push(c)}}return new ao(a,o)}(t._query,t.firestore._databaseId,r,c,e,n)}function Qy(t,e,n){if("string"==typeof(n=m(n))){if(""===n)throw new Ar(Dr.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!_o(e)&&-1!==n.indexOf("/"))throw new Ar(Dr.INVALID_ARGUMENT,"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '"+n+"' contains a '/' character.");e=e.path.child($r.fromString(n));if(!mi.isDocumentKey(e))throw new Ar(Dr.INVALID_ARGUMENT,"Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '"+e+"' is not because it has an odd number of segments ("+e.length+").");return Si(t,new mi(e))}if(n instanceof Hd)return Si(t,n._key);throw new Ar(Dr.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+Bd(n)+".")}function zy(t,e){if(!Array.isArray(t)||0===t.length)throw new Ar(Dr.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(10<t.length)throw new Ar(Dr.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.")}function Hy(t,e,n){if(!n.isEqual(e))throw new Ar(Dr.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '"+e.toString()+"' and so you must also use '"+e.toString()+"' as your first argument to orderBy(), but your first orderBy() is on field '"+n.toString()+"' instead.")}Wy.prototype.convertValue=function(t,e){switch(void 0===e&&(e="none"),bi(t)){case 0:return null;case 1:return t.booleanValue;case 2:return hi(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(li(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw Mr()}},Wy.prototype.convertObject=function(t,n){var r=this,i={};return Wr(t.fields||{},function(t,e){i[t]=r.convertValue(e,n)}),i},Wy.prototype.convertGeoPoint=function(t){return new wp(hi(t.latitude),hi(t.longitude))},Wy.prototype.convertArray=function(t,e){var n=this;return(t.values||[]).map(function(t){return n.convertValue(t,e)})},Wy.prototype.convertServerTimestamp=function(t,e){switch(e){case"previous":var n=function t(e){e=e.mapValue.fields.__previous_value__;return fi(e)?t(e):e}(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(di(t));default:return null}},Wy.prototype.convertTimestamp=function(t){t=ci(t);return new Kr(t.seconds,t.nanos)},Wy.prototype.convertDocumentKey=function(t,e){var n=$r.fromString(t);Fr(ka(n));t=new Sd(n.get(1),n.get(3)),n=new mi(n.popFirst(5));return t.isEqual(e)||Or("Document "+n+" contains a document reference within a different database ("+t.projectId+"/"+t.database+") which is not supported. It will be treated as a reference in the current database ("+e.projectId+"/"+e.database+") instead."),n},I=Wy;function Wy(){}function Yy(t,e,n){return t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e}var Xy,Jy=(n(tg,Xy=I),tg.prototype.convertBytes=function(t){return new vp(t)},tg.prototype.convertReference=function(t){t=this.convertDocumentKey(t,this.firestore._databaseId);return new Hd(this.firestore,null,t)},tg),$y=(Zy.prototype.set=function(t,e,n){this._verifyNotCommitted();t=eg(t,this._firestore),e=Yy(t._converter,e,n),n=Pp(this._dataReader,"WriteBatch.set",t._key,e,null!==t._converter,n);return this._mutations.push(n.toMutation(t._key,es.none())),this},Zy.prototype.update=function(t,e,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];this._verifyNotCommitted();t=eg(t,this._firestore),e="string"==typeof(e=m(e))||e instanceof mp?Zp(this._dataReader,"WriteBatch.update",t._key,e,n,r):$p(this._dataReader,"WriteBatch.update",t._key,e);return this._mutations.push(e.toMutation(t._key,es.exists(!0))),this},Zy.prototype.delete=function(t){this._verifyNotCommitted();t=eg(t,this._firestore);return this._mutations=this._mutations.concat(new ws(t._key,es.none())),this},Zy.prototype.commit=function(){return this._verifyNotCommitted(),this._committed=!0,0<this._mutations.length?this._commitHandler(this._mutations):Promise.resolve()},Zy.prototype._verifyNotCommitted=function(){if(this._committed)throw new Ar(Dr.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},Zy);function Zy(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=Lp(t)}function tg(t){var e=this;return(e=Xy.call(this)||this).firestore=t,e}function eg(t,e){if((t=m(t)).firestore!==e)throw new Ar(Dr.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return t}var ng,rg=(n(ig,ng=I),ig.prototype.convertBytes=function(t){return new vp(t)},ig.prototype.convertReference=function(t){t=this.convertDocumentKey(t,this.firestore._databaseId);return new Hd(this.firestore,null,t)},ig);function ig(t){var e=this;return(e=ng.call(this)||this).firestore=t,e}function og(t,e,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];t=jd(t,Hd);var o=jd(t.firestore,hp),s=Lp(o);return ag(o,[("string"==typeof(e=m(e))||e instanceof mp?Zp(s,"updateDoc",t._key,e,n,r):$p(s,"updateDoc",t._key,e)).toMutation(t._key,es.exists(!0))])}function sg(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];e=m(e);var r={includeMetadataChanges:!1},i=0;"object"!=typeof n[i]||ap(n[i])||(r=n[i],i++);var o,s,a,u,c,h,l={includeMetadataChanges:r.includeMetadataChanges};return ap(n[i])&&(o=n[i],n[i]=null===(r=o.next)||void 0===r?void 0:r.bind(o),n[i+1]=null===(r=o.error)||void 0===r?void 0:r.bind(o),n[i+2]=null===(r=o.complete)||void 0===r?void 0:r.bind(o)),e instanceof Hd?(a=jd(e.firestore,hp),u=bo(e._key.path),h={next:function(t){n[i]&&n[i](ug(a,e,t))},error:n[i+1],complete:n[i+2]}):(s=jd(e,Wd),a=jd(s.firestore,hp),u=s._query,c=new rg(a),h={next:function(t){n[i]&&n[i](new Iy(a,c,s,t))},error:n[i+1],complete:n[i+2]},Dy(e._query)),function(n,t,e){var r=this,i=new nd(h),o=new af(t,i,e);return n.asyncQueue.enqueueAndForget(function(){return y(r,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=rf,[4,wd(n)];case 1:return[2,e.apply(void 0,[t.sent(),o])]}})})}),function(){i.Wo(),n.asyncQueue.enqueueAndForget(function(){return y(r,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=of,[4,wd(n)];case 1:return[2,e.apply(void 0,[t.sent(),o])]}})})})}}(dp(a),u,l)}function ag(t,e){return function(n,r){var t=this,i=new Za;return n.asyncQueue.enqueueAndForget(function(){return y(t,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=Sf,[4,bd(n)];case 1:return[2,e.apply(void 0,[t.sent(),r,i])]}})})}),i.promise}(dp(t),e)}function ug(t,e,n){var r=n.docs.get(e._key),i=new rg(t);return new by(t,i,e._key,r,new vy(n.hasPendingWrites,n.fromCache),e._converter)}var cg,hg=(fg.prototype.get=function(t){var e=this,n=eg(t,this._firestore),r=new Jy(this._firestore);return this._transaction.lookup([n._key]).then(function(t){if(!t||1!==t.length)return Mr();t=t[0];if(t.isFoundDocument())return new ly(e._firestore,r,t.key,t,n._converter);if(t.isNoDocument())return new ly(e._firestore,r,n._key,null,n._converter);throw Mr()})},fg.prototype.set=function(t,e,n){t=eg(t,this._firestore),e=Yy(t._converter,e,n),n=Pp(this._dataReader,"Transaction.set",t._key,e,null!==t._converter,n);return this._transaction.set(t._key,n),this},fg.prototype.update=function(t,e,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];t=eg(t,this._firestore),e="string"==typeof(e=m(e))||e instanceof mp?Zp(this._dataReader,"Transaction.update",t._key,e,n,r):$p(this._dataReader,"Transaction.update",t._key,e);return this._transaction.update(t._key,e),this},fg.prototype.delete=function(t){t=eg(t,this._firestore);return this._transaction.delete(t._key),this},n(lg,cg=fg),lg.prototype.get=function(t){var e=this,n=eg(t,this._firestore),r=new rg(this._firestore);return cg.prototype.get.call(this,t).then(function(t){return new by(e._firestore,r,n._key,t._document,new vy(!1,!1),n._converter)})},lg);function lg(t,e){var n=this;return(n=cg.call(this,t,e)||this)._firestore=t,n}function fg(t,e){this._firestore=t,this._transaction=e,this._dataReader=Lp(t)}function dg(){if("undefined"==typeof Uint8Array)throw new Ar(Dr.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function pg(){if("undefined"==typeof atob)throw new Ar(Dr.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var yg,gg=(Tg.fromBase64String=function(t){return pg(),new Tg(vp.fromBase64String(t))},Tg.fromUint8Array=function(t){return dg(),new Tg(vp.fromUint8Array(t))},Tg.prototype.toBase64=function(){return pg(),this._delegate.toBase64()},Tg.prototype.toUint8Array=function(){return dg(),this._delegate.toUint8Array()},Tg.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},Tg.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},Tg),mg=(Eg.prototype.enableIndexedDbPersistence=function(t,e){return function(t,e){gp(t=jd(t,hp));var n=dp(t),r=t._freezeSettings(),t=new Xf;return yp(n,t,new Wf(t,r.cacheSizeBytes,null==e?void 0:e.forceOwnership))}(t._delegate,{forceOwnership:e})},Eg.prototype.enableMultiTabIndexedDbPersistence=function(t){return function(t){gp(t=jd(t,hp));var e=dp(t),n=t._freezeSettings(),t=new Xf;return yp(e,t,new Yf(t,n.cacheSizeBytes))}(t._delegate)},Eg.prototype.clearIndexedDbPersistence=function(t){return function(n){var t=this;if(n._initialized&&!n._terminated)throw new Ar(Dr.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");var r=new Za;return n._queue.enqueueAndForgetEvenWhileRestricted(function(){return y(t,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,function(n){return y(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return nu.yt()?(e=n+"main",[4,nu.delete(e)]):[2,Promise.resolve()];case 1:return t.sent(),[2]}})})}(Kc(n._databaseId,n._persistenceKey))];case 1:return t.sent(),r.resolve(),[3,3];case 2:return e=t.sent(),r.reject(e),[3,3];case 3:return[2]}})})}),r.promise}(t._delegate)},Eg),vg=(Object.defineProperty(Ig.prototype,"_databaseId",{get:function(){return this._delegate._databaseId},enumerable:!1,configurable:!0}),Ig.prototype.settings=function(t){t.merge&&delete(t=Object.assign(Object.assign({},this._delegate._getSettings()),t)).merge,this._delegate._setSettings(t)},Ig.prototype.useEmulator=function(t,e){var n,r;n=this._delegate,r=t,t=e,"firestore.googleapis.com"!==(e=(n=jd(n,zd))._getSettings()).host&&e.host!==r&&Lr("Host has been set in both settings() and useEmulator(), emulator host will be used"),n._setSettings(Object.assign(Object.assign({},e),{host:r+":"+t,ssl:!1}))},Ig.prototype.enableNetwork=function(){return function(i){var t=this;return i.asyncQueue.enqueue(function(){return y(t,void 0,void 0,function(){var n,r;return g(this,function(t){switch(t.label){case 0:return[4,gd(i)];case 1:return n=t.sent(),[4,vd(i)];case 2:return r=t.sent(),[2,(n.setNetworkEnabled(!0),(e=r).$r.delete(0),Dl(e))]}var e})})})}(dp(jd(this._delegate,hp)))},Ig.prototype.disableNetwork=function(){return function(r){var t=this;return r.asyncQueue.enqueue(function(){return y(t,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return[4,gd(r)];case 1:return e=t.sent(),[4,vd(r)];case 2:return n=t.sent(),[2,(e.setNetworkEnabled(!1),function(n){return y(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return(e=n).$r.add(0),[4,Al(e)];case 1:return t.sent(),e.Br.set("Offline"),[2]}})})}(n))]}})})})}(dp(jd(this._delegate,hp)))},Ig.prototype.enablePersistence=function(t){var e=!1,n=!1;return t&&Vd("synchronizeTabs",e=!!t.synchronizeTabs,"experimentalForceOwningTab",n=!!t.experimentalForceOwningTab),e?this.Yc.enableMultiTabIndexedDbPersistence(this):this.Yc.enableIndexedDbPersistence(this,n)},Ig.prototype.clearPersistence=function(){return this.Yc.clearIndexedDbPersistence(this)},Ig.prototype.terminate=function(){return this.Xc&&(this.Xc._removeServiceInstance("firestore"),this.Xc._removeServiceInstance("firestore-exp")),this._delegate._delete()},Ig.prototype.waitForPendingWrites=function(){return function(n){var t=this,r=new Za;return n.asyncQueue.enqueueAndForget(function(){return y(t,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=kf,[4,bd(n)];case 1:return[2,e.apply(void 0,[t.sent(),r])]}})})}),r.promise}(dp(jd(this._delegate,hp)))},Ig.prototype.onSnapshotsInSync=function(t){return e=this._delegate,t=t,function(n,t){var e=this,r=new nd(t);return n.asyncQueue.enqueueAndForget(function(){return y(e,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=function(t,e){t.Gr.add(e),e.next()},[4,wd(n)];case 1:return[2,e.apply(void 0,[t.sent(),r])]}})})}),function(){r.Wo(),n.asyncQueue.enqueueAndForget(function(){return y(e,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=function(t,e){t.Gr.delete(e)},[4,wd(n)];case 1:return[2,e.apply(void 0,[t.sent(),r])]}})})})}}(dp(jd(e,hp)),ap(t)?t:{next:t});var e},Object.defineProperty(Ig.prototype,"app",{get:function(){if(!this.Xc)throw new Ar(Dr.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.Xc},enumerable:!1,configurable:!0}),Ig.prototype.collection=function(t){try{return new jg(this,ep(this._delegate,t))}catch(t){throw xg(t,"collection()","Firestore.collection()")}},Ig.prototype.doc=function(t){try{return new Cg(this,np(this._delegate,t))}catch(t){throw xg(t,"doc()","Firestore.doc()")}},Ig.prototype.collectionGroup=function(t){try{return new Ug(this,function(t,e){if(t=jd(t,zd),Md("collectionGroup","collection id",e),0<=e.indexOf("/"))throw new Ar(Dr.INVALID_ARGUMENT,"Invalid collection ID '"+e+"' passed to function collectionGroup(). Collection IDs must not contain '/'.");return new Wd(t,null,(e=e,new mo($r.emptyPath(),e)))}(this._delegate,t))}catch(t){throw xg(t,"collectionGroup()","Firestore.collectionGroup()")}},Ig.prototype.runTransaction=function(e){var n,r=this;return function(n,r){var t=this,i=new Za;return n.asyncQueue.enqueueAndForget(function(){return y(t,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,yd(n).then(function(t){return t.datastore})];case 1:return e=t.sent(),new od(n.asyncQueue,e,r,i).run(),[2]}})})}),i.promise}(dp(n=this._delegate),function(t){return t=new hg(n,t),e(new _g(r,t))})},Ig.prototype.batch=function(){var e=this;return dp(this._delegate),new Sg(new $y(this._delegate,function(t){return ag(e._delegate,t)}))},Ig.prototype.loadBundle=function(t){throw new Ar(Dr.FAILED_PRECONDITION,'"loadBundle()" does not exist, have you imported "firebase/firestore/bundle"?')},Ig.prototype.namedQuery=function(t){throw new Ar(Dr.FAILED_PRECONDITION,'"namedQuery()" does not exist, have you imported "firebase/firestore/bundle"?')},Ig),bg=(n(wg,yg=I),wg.prototype.convertBytes=function(t){return new gg(new vp(t))},wg.prototype.convertReference=function(t){t=this.convertDocumentKey(t,this.firestore._databaseId);return Cg.Zc(t,this.firestore,null)},wg);function wg(t){var e=this;return(e=yg.call(this)||this).firestore=t,e}function Ig(t,e,n){var r=this;this._delegate=e,this.Yc=n,this.INTERNAL={delete:function(){return r.terminate()}},t instanceof Sd||(this.Xc=t)}function Eg(){}function Tg(t){this._delegate=t}var _g=(kg.prototype.get=function(t){var e=this,n=Yg(t);return this._delegate.get(n).then(function(t){return new Fg(e._firestore,new by(e._firestore._delegate,e._userDataWriter,t._key,t._document,t.metadata,n._converter))})},kg.prototype.set=function(t,e,n){t=Yg(t);return n?(Fd("Transaction.set",n),this._delegate.set(t,e,n)):this._delegate.set(t,e),this},kg.prototype.update=function(t,e,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];var o=Yg(t);return 2===arguments.length?this._delegate.update(o,e):(t=this._delegate).update.apply(t,s([o,e,n],r)),this},kg.prototype.delete=function(t){t=Yg(t);return this._delegate.delete(t),this},kg),Sg=(Ag.prototype.set=function(t,e,n){t=Yg(t);return n?(Fd("WriteBatch.set",n),this._delegate.set(t,e,n)):this._delegate.set(t,e),this},Ag.prototype.update=function(t,e,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];var o=Yg(t);return 2===arguments.length?this._delegate.update(o,e):(t=this._delegate).update.apply(t,s([o,e,n],r)),this},Ag.prototype.delete=function(t){t=Yg(t);return this._delegate.delete(t),this},Ag.prototype.commit=function(){return this._delegate.commit()},Ag),Ng=(Dg.prototype.fromFirestore=function(t,e){t=new wy(this._firestore._delegate,this._userDataWriter,t._key,t._document,t.metadata,null);return this._delegate.fromFirestore(new Vg(this._firestore,t),null!=e?e:{})},Dg.prototype.toFirestore=function(t,e){return e?this._delegate.toFirestore(t,e):this._delegate.toFirestore(t)},Dg.tu=function(t,e){var n=Dg.eu,r=n.get(t);r||(r=new WeakMap,n.set(t,r));n=r.get(e);return n||(n=new Dg(t,new bg(t),e),r.set(e,n)),n},Dg);function Dg(t,e,n){this._firestore=t,this._userDataWriter=e,this._delegate=n}function Ag(t){this._delegate=t}function kg(t,e){this._firestore=t,this._delegate=e,this._userDataWriter=new bg(t)}Ng.eu=new WeakMap;var Cg=(Rg.nu=function(t,e,n){if(t.length%2!=0)throw new Ar(Dr.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.canonicalString()+" has "+t.length);return new Rg(e,new Hd(e._delegate,n,new mi(t)))},Rg.Zc=function(t,e,n){return new Rg(e,new Hd(e._delegate,n,t))},Object.defineProperty(Rg.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(Rg.prototype,"parent",{get:function(){return new jg(this.firestore,this._delegate.parent)},enumerable:!1,configurable:!0}),Object.defineProperty(Rg.prototype,"path",{get:function(){return this._delegate.path},enumerable:!1,configurable:!0}),Rg.prototype.collection=function(t){try{return new jg(this.firestore,ep(this._delegate,t))}catch(t){throw xg(t,"collection()","DocumentReference.collection()")}},Rg.prototype.isEqual=function(t){return(t=m(t))instanceof Hd&&rp(this._delegate,t)},Rg.prototype.set=function(t,e){e=Fd("DocumentReference.set",e);try{return function(t,e,n){t=jd(t,Hd);var r=jd(t.firestore,hp),e=Yy(t._converter,e,n);return ag(r,[Pp(Lp(r),"setDoc",t._key,e,null!==t._converter,n).toMutation(t._key,es.none())])}(this._delegate,t,e)}catch(t){throw xg(t,"setDoc()","DocumentReference.set()")}},Rg.prototype.update=function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];try{return 1===arguments.length?og(this._delegate,t):og.apply(void 0,s([this._delegate,t,e],n))}catch(t){throw xg(t,"updateDoc()","DocumentReference.update()")}},Rg.prototype.delete=function(){return ag(jd((t=this._delegate).firestore,hp),[new ws(t._key,es.none())]);var t},Rg.prototype.onSnapshot=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Og(t),i=Lg(t,function(t){return new Fg(e.firestore,new by(e.firestore._delegate,e._userDataWriter,t._key,t._document,t.metadata,e._delegate._converter))});return sg(this._delegate,r,i)},Rg.prototype.get=function(t){var e=this;return("cache"===(null==t?void 0:t.source)?function(e){e=jd(e,Hd);var n=jd(e.firestore,hp),t=dp(n),r=new rg(n);return function(n,r){var t=this,i=new Za;return n.asyncQueue.enqueueAndForget(function(){return y(t,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=function(o,s,a){return y(this,void 0,void 0,function(){var r,i;return g(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,(e=s,(n=o).persistence.runTransaction("read document","readonly",function(t){return n.Mn.mn(t,e)}))];case 1:return(i=t.sent()).isFoundDocument()?a.resolve(i):i.isNoDocument()?a.resolve(null):a.reject(new Ar(Dr.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.)")),[3,3];case 2:return r=t.sent(),i=Wl(r,"Failed to get document '"+s+" from cache"),a.reject(i),[3,3];case 3:return[2]}var e,n})})},[4,md(n)];case 1:return[2,e.apply(void 0,[t.sent(),r,i])]}})})}),i.promise}(t,e._key).then(function(t){return new by(n,r,e._key,t,new vy(null!==t&&t.hasLocalMutations,!0),e._converter)})}:"server"===(null==t?void 0:t.source)?function(e){e=jd(e,Hd);var n=jd(e.firestore,hp);return Id(dp(n),e._key,{source:"server"}).then(function(t){return ug(n,e,t)})}:function(e){e=jd(e,Hd);var n=jd(e.firestore,hp);return Id(dp(n),e._key).then(function(t){return ug(n,e,t)})})(this._delegate).then(function(t){return new Fg(e.firestore,new by(e.firestore._delegate,e._userDataWriter,t._key,t._document,t.metadata,e._delegate._converter))})},Rg.prototype.withConverter=function(t){return new Rg(this.firestore,t?this._delegate.withConverter(Ng.tu(this.firestore,t)):this._delegate.withConverter(null))},Rg);function Rg(t,e){this.firestore=t,this._delegate=e,this._userDataWriter=new bg(t)}function xg(t,e,n){return t.message=t.message.replace(e,n),t}function Og(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];if("object"==typeof r&&!ap(r))return r}return{}}function Lg(t,e){var n;return{next:function(t){n.next&&n.next(e(t))},error:null===(t=(n=ap(t[0])?t[0]:ap(t[1])?t[1]:"function"==typeof t[0]?{next:t[0],error:t[1],complete:t[2]}:{next:t[1],error:t[2],complete:t[3]}).error)||void 0===t?void 0:t.bind(n),complete:null===(t=n.complete)||void 0===t?void 0:t.bind(n)}}var Pg,Mg,Fg=(Object.defineProperty(Wg.prototype,"ref",{get:function(){return new Cg(this._firestore,this._delegate.ref)},enumerable:!1,configurable:!0}),Object.defineProperty(Wg.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(Wg.prototype,"metadata",{get:function(){return this._delegate.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(Wg.prototype,"exists",{get:function(){return this._delegate.exists()},enumerable:!1,configurable:!0}),Wg.prototype.data=function(t){return this._delegate.data(t)},Wg.prototype.get=function(t,e){return this._delegate.get(t,e)},Wg.prototype.isEqual=function(t){return Ny(this._delegate,t._delegate)},Wg),Vg=(n(Hg,Mg=Fg),Hg.prototype.data=function(t){return this._delegate.data(t)},Hg),Ug=(zg.prototype.where=function(t,e,n){try{return new zg(this.firestore,Ay(this._delegate,(r=n,i=e,o=yy("where",t),new Ly(o,i,r))))}catch(t){throw xg(t,/(orderBy|where)\(\)/,"Query.$1()")}var r,i,o},zg.prototype.orderBy=function(t,e){try{return new zg(this.firestore,Ay(this._delegate,(n=void 0===e?"asc":e,r=yy("orderBy",t),new Py(r,n))))}catch(t){throw xg(t,/(orderBy|where)\(\)/,"Query.$1()")}var n,r},zg.prototype.limit=function(t){try{return new zg(this.firestore,Ay(this._delegate,(Kd("limit",e=t),new My("limit",e,"F"))))}catch(t){throw xg(t,"limit()","Query.limit()")}var e},zg.prototype.limitToLast=function(t){try{return new zg(this.firestore,Ay(this._delegate,(Kd("limitToLast",e=t),new My("limitToLast",e,"L"))))}catch(t){throw xg(t,"limitToLast()","Query.limitToLast()")}var e},zg.prototype.startAt=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return new zg(this.firestore,Ay(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Fy("startAt",t,!0)}.apply(void 0,t)))}catch(t){throw xg(t,"startAt()","Query.startAt()")}},zg.prototype.startAfter=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return new zg(this.firestore,Ay(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Fy("startAfter",t,!1)}.apply(void 0,t)))}catch(t){throw xg(t,"startAfter()","Query.startAfter()")}},zg.prototype.endBefore=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return new zg(this.firestore,Ay(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Vy("endBefore",t,!0)}.apply(void 0,t)))}catch(t){throw xg(t,"endBefore()","Query.endBefore()")}},zg.prototype.endAt=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return new zg(this.firestore,Ay(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Vy("endAt",t,!1)}.apply(void 0,t)))}catch(t){throw xg(t,"endAt()","Query.endAt()")}},zg.prototype.isEqual=function(t){return ip(this._delegate,t._delegate)},zg.prototype.get=function(t){var e=this;return("cache"===(null==t?void 0:t.source)?function(e){e=jd(e,Wd);var n=jd(e.firestore,hp),t=dp(n),r=new rg(n);return function(n,r){var t=this,i=new Za;return n.asyncQueue.enqueueAndForget(function(){return y(t,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=function(i,o,s){return y(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,ah(i,o,!0)];case 1:return r=t.sent(),e=new vf(o,r.Bn),n=e._o(r.documents),n=e.applyChanges(n,!1),s.resolve(n.snapshot),[3,3];case 2:return n=t.sent(),r=Wl(n,"Failed to execute query '"+o+" against cache"),s.reject(r),[3,3];case 3:return[2]}})})},[4,md(n)];case 1:return[2,e.apply(void 0,[t.sent(),r,i])]}})})}),i.promise}(t,e._query).then(function(t){return new Iy(n,r,e,t)})}:"server"===(null==t?void 0:t.source)?function(e){e=jd(e,Wd);var n=jd(e.firestore,hp),t=dp(n),r=new rg(n);return Ed(t,e._query,{source:"server"}).then(function(t){return new Iy(n,r,e,t)})}:function(e){e=jd(e,Wd);var n=jd(e.firestore,hp),t=dp(n),r=new rg(n);return Dy(e._query),Ed(t,e._query).then(function(t){return new Iy(n,r,e,t)})})(this._delegate).then(function(t){return new Bg(e.firestore,new Iy(e.firestore._delegate,e._userDataWriter,e._delegate,t._snapshot))})},zg.prototype.onSnapshot=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Og(t),i=Lg(t,function(t){return new Bg(e.firestore,new Iy(e.firestore._delegate,e._userDataWriter,e._delegate,t._snapshot))});return sg(this._delegate,r,i)},zg.prototype.withConverter=function(t){return new zg(this.firestore,t?this._delegate.withConverter(Ng.tu(this.firestore,t)):this._delegate.withConverter(null))},zg),qg=(Object.defineProperty(Qg.prototype,"type",{get:function(){return this._delegate.type},enumerable:!1,configurable:!0}),Object.defineProperty(Qg.prototype,"doc",{get:function(){return new Vg(this._firestore,this._delegate.doc)},enumerable:!1,configurable:!0}),Object.defineProperty(Qg.prototype,"oldIndex",{get:function(){return this._delegate.oldIndex},enumerable:!1,configurable:!0}),Object.defineProperty(Qg.prototype,"newIndex",{get:function(){return this._delegate.newIndex},enumerable:!1,configurable:!0}),Qg),Bg=(Object.defineProperty(Gg.prototype,"query",{get:function(){return new Ug(this._firestore,this._delegate.query)},enumerable:!1,configurable:!0}),Object.defineProperty(Gg.prototype,"metadata",{get:function(){return this._delegate.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(Gg.prototype,"size",{get:function(){return this._delegate.size},enumerable:!1,configurable:!0}),Object.defineProperty(Gg.prototype,"empty",{get:function(){return this._delegate.empty},enumerable:!1,configurable:!0}),Object.defineProperty(Gg.prototype,"docs",{get:function(){var e=this;return this._delegate.docs.map(function(t){return new Vg(e._firestore,t)})},enumerable:!1,configurable:!0}),Gg.prototype.docChanges=function(t){var e=this;return this._delegate.docChanges(t).map(function(t){return new qg(e._firestore,t)})},Gg.prototype.forEach=function(e,n){var r=this;this._delegate.forEach(function(t){e.call(n,new Vg(r._firestore,t))})},Gg.prototype.isEqual=function(t){return Ny(this._delegate,t._delegate)},Gg),jg=(n(Kg,Pg=Ug),Object.defineProperty(Kg.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(Kg.prototype,"path",{get:function(){return this._delegate.path},enumerable:!1,configurable:!0}),Object.defineProperty(Kg.prototype,"parent",{get:function(){var t=this._delegate.parent;return t?new Cg(this.firestore,t):null},enumerable:!1,configurable:!0}),Kg.prototype.doc=function(t){try{return new Cg(this.firestore,void 0===t?np(this._delegate):np(this._delegate,t))}catch(t){throw xg(t,"doc()","CollectionReference.doc()")}},Kg.prototype.add=function(t){var e,n,r,i=this;return e=this._delegate,n=t,t=jd(e.firestore,hp),r=np(e),n=Yy(e._converter,n),ag(t,[Pp(Lp(e.firestore),"addDoc",r._key,n,null!==e._converter,{}).toMutation(r._key,es.exists(!1))]).then(function(){return r}).then(function(t){return new Cg(i.firestore,t)})},Kg.prototype.isEqual=function(t){return rp(this._delegate,t._delegate)},Kg.prototype.withConverter=function(t){return new Kg(this.firestore,t?this._delegate.withConverter(Ng.tu(this.firestore,t)):this._delegate.withConverter(null))},Kg);function Kg(t,e){var n=this;return(n=Pg.call(this,t,e)||this).firestore=t,n._delegate=e,n}function Gg(t,e){this._firestore=t,this._delegate=e}function Qg(t,e){this._firestore=t,this._delegate=e}function zg(t,e){this.firestore=t,this._delegate=e,this._userDataWriter=new bg(t)}function Hg(){return null!==Mg&&Mg.apply(this,arguments)||this}function Wg(t,e){this._firestore=t,this._delegate=e}function Yg(t){return jd(t,Hd)}Jg.documentId=function(){return new Jg(ti.keyField().canonicalString())},Jg.prototype.isEqual=function(t){return(t=m(t))instanceof mp&&this._delegate._internalPath.isEqual(t._internalPath)},Te=Jg,Xg.serverTimestamp=function(){var t=new Gp("serverTimestamp");return t._methodName="FieldValue.serverTimestamp",new Xg(t)},Xg.delete=function(){var t=new Fp("deleteField");return t._methodName="FieldValue.delete",new Xg(t)},Xg.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Qp("arrayUnion",t)}.apply(void 0,t);return n._methodName="FieldValue.arrayUnion",new Xg(n)},Xg.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new zp("arrayRemove",t)}.apply(void 0,t);return n._methodName="FieldValue.arrayRemove",new Xg(n)},Xg.increment=function(t){t=new Hp("increment",t);return t._methodName="FieldValue.increment",new Xg(t)},Xg.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},I=Xg;function Xg(t){this._delegate=t}function Jg(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._delegate=new(mp.bind.apply(mp,s([void 0],t)))}function $g(t){return e=this._delegate,s=t,n=dp(e=jd(e,hp)),t=new cp,function(n,t,r){var e,i=this,o=(e=s,t=ll(t),e=function(t){if(t instanceof Uint8Array)return ed(t,void 0);if(t instanceof ArrayBuffer)return ed(new Uint8Array(t),void 0);if(t instanceof ReadableStream)return t.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}("string"==typeof e?(new TextEncoder).encode(e):e),new rd(e,t));n.asyncQueue.enqueueAndForget(function(){return y(i,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=Gf,[4,bd(n)];case 1:return e.apply(void 0,[t.sent(),o,r]),[2]}})})})}(n,e._databaseId,t),t;var e,s,n}function Zg(t){var e=this,n=this._delegate,t=t;return function(n,r){var t=this;return n.asyncQueue.enqueue(function(){return y(t,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return e=function(t,e){var n=t;return n.persistence.runTransaction("Get named query","readonly",function(t){return n.Qe.getNamedQuery(t,e)})},[4,md(n)];case 1:return[2,e.apply(void 0,[t.sent(),r])]}})})})}(dp(n=jd(n,hp)),t).then(function(t){return t?new Wd(n,null,t.query):null}).then(function(t){return t?new Ug(e,t):null})}var tm=(em.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},em.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},em.prototype.setServiceProps=function(t){return this.serviceProps=t,this},em.prototype.setInstanceCreatedCallback=function(t){return this.onInstanceCreated=t,this},em);function em(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}var nm,rm,im={Firestore:vg,GeoPoint:wp,Timestamp:Kr,Blob:gg,Transaction:_g,WriteBatch:Sg,DocumentReference:Cg,DocumentSnapshot:Fg,Query:Ug,QueryDocumentSnapshot:Vg,QuerySnapshot:Bg,CollectionReference:jg,FieldPath:Te,FieldValue:I,setLogLevel:function(t){kr.setLogLevel(t)},CACHE_SIZE_UNLIMITED:-1};(nm=e.default).INTERNAL.registerComponent(new tm("firestore",function(t){var e=t.getProvider("app").getImmediate();return e=e,t=t.getProvider("auth-internal"),new vg(e,new hp(e,t),new mg)},"PUBLIC").setServiceProps(Object.assign({},im))),nm.registerVersion("@firebase/firestore","2.2.5"),(rm=vg).prototype.loadBundle=$g,rm.prototype.namedQuery=Zg}.apply(this,arguments)}catch(t){throw console.error(t),new Error("Cannot instantiate firebase-firestore.js - be sure to load firebase-app.js first.")}});
  //# sourceMappingURL=firebase-firestore.js.map
  