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(sp){"use strict";try{(function(){function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e,a,n,r=t(sp),i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function o(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function w(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 b(n,r){var i,o,s,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,o=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){a.label=e[1];break}if(6===e[0]&&a.label<s[1]){a.label=s[1],s=e;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(e);break}s[2]&&a.ops.pop(),a.trys.pop();continue}e=r.call(n,a)}catch(t){e=[6,t],o=0}finally{i=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function s(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var r=Array(t),i=0,e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}function u(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var r=Array(t),i=0,e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}(n=a=a||{})[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT";function h(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=f[e];if(!o)throw new Error("Attempted to log a message with an invalid logType (value: "+e+")");console[o].apply(console,u(["["+i+"]  "+t.name+":"],n))}}var c={debug:a.DEBUG,verbose:a.VERBOSE,info:a.INFO,warn:a.WARN,error:a.ERROR,silent:a.SILENT},l=a.INFO,f=((e={})[a.DEBUG]="log",e[a.VERBOSE]="log",e[a.INFO]="info",e[a.WARN]="warn",e[a.ERROR]="error",e),p=(Object.defineProperty(d.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in a))throw new TypeError('Invalid value "'+t+'" assigned to `logLevel`');this._logLevel=t},enumerable:!1,configurable:!0}),d.prototype.setLogLevel=function(t){this._logLevel="string"==typeof t?c[t]:t},Object.defineProperty(d.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(d.prototype,"userLogHandler",{get:function(){return this._userLogHandler},set:function(t){this._userLogHandler=t},enumerable:!1,configurable:!0}),d.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,u([this,a.DEBUG],t)),this._logHandler.apply(this,u([this,a.DEBUG],t))},d.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,u([this,a.VERBOSE],t)),this._logHandler.apply(this,u([this,a.VERBOSE],t))},d.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,u([this,a.INFO],t)),this._logHandler.apply(this,u([this,a.INFO],t))},d.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,u([this,a.WARN],t)),this._logHandler.apply(this,u([this,a.WARN],t))},d.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,u([this,a.ERROR],t)),this._logHandler.apply(this,u([this,a.ERROR],t))},d);function d(t){this.name=t,this._logLevel=l,this._logHandler=h,this._userLogHandler=null}function v(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}var y,g="FirebaseError",m=(o(E,y=Error),E);function E(t,e){var n=y.call(this,e)||this;return n.code=t,n.name=g,Object.setPrototypeOf(n,E.prototype),Error.captureStackTrace&&Error.captureStackTrace(n,I.prototype.create),n}var I=(T.prototype.create=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r,i=e[0]||{},o=this.service+"/"+t,s=this.errors[t],a=s?(r=i,s.replace(A,function(t,e){var n=r[e];return null!=n?String(n):"<"+e+"?>"})):"Error",u=this.serviceName+": "+a+" ("+o+").",h=new m(o,u),c=0,l=Object.keys(i);c<l.length;c++){var f=l[c];"_"!==f.slice(-1)&&(f in h&&console.warn('Overwriting FirebaseError base field "'+f+'" can cause unexpected behavior.'),h[f]=i[f])}return h},T);function T(t,e,n){this.service=t,this.serviceName=e,this.errors=n}var A=/\{\$([^}]+)}/g,N=function(t,e){return(N=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 R(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var S,D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},L={},O=D||self;function P(){}function k(t){var e=typeof t;return"object"!=e?e:t?Array.isArray(t)?"array":e:"null"}function V(t){var e=k(t);return"array"==e||"object"==e&&"number"==typeof t.length}function _(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var U="closure_uid_"+(1e9*Math.random()>>>0),C=0;function j(t,e,n){return t.call.apply(t.bind,arguments)}function M(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 x(t,e,n){return(x=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?j:M).apply(null,arguments)}function B(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}var F=Date.now;function q(t,e){function n(){}n.prototype=e.prototype,t.S=e.prototype,t.prototype=new n,t.prototype.constructor=t}function G(){this.j=this.j,this.i=this.i}G.prototype.j=!1,G.prototype.ja=function(){var t;!this.j&&(this.j=!0,this.G(),0)&&(t=this,Object.prototype.hasOwnProperty.call(t,U)&&t[U]||(t[U]=++C))},G.prototype.G=function(){if(this.i)for(;this.i.length;)this.i.shift()()};var z=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},W=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 Q(t){return Array.prototype.concat.apply([],arguments)}function H(t){var e=t.length;if(0<e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}return[]}function X(t){return/^[\s\xa0]*$/.test(t)}var Y,K=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function J(t,e){return-1!=t.indexOf(e)}function Z(t,e){return t<e?-1:e<t?1:0}t:{var $=O.navigator;if($){var tt=$.userAgent;if(tt){Y=tt;break t}}Y=""}function et(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function nt(t){var e,n={};for(e in t)n[e]=t[e];return n}var rt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function it(t,e){for(var n,r,i=1;i<arguments.length;i++){for(n in r=arguments[i])t[n]=r[n];for(var o=0;o<rt.length;o++)n=rt[o],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function ot(t){return ot[" "](t),t}ot[" "]=P;var st,at,ut=J(Y,"Opera"),ht=J(Y,"Trident")||J(Y,"MSIE"),ct=J(Y,"Edge"),lt=ct||ht,ft=J(Y,"Gecko")&&!(J(Y.toLowerCase(),"webkit")&&!J(Y,"Edge"))&&!(J(Y,"Trident")||J(Y,"MSIE"))&&!J(Y,"Edge"),pt=J(Y.toLowerCase(),"webkit")&&!J(Y,"Edge");function dt(){var t=O.document;return t?t.documentMode:void 0}t:{var vt="",yt=(at=Y,ft?/rv:([^\);]+)(\)|;)/.exec(at):ct?/Edge\/([\d\.]+)/.exec(at):ht?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(at):pt?/WebKit\/(\S+)/.exec(at):ut?/(?:Version)[ \/]?(\S+)/.exec(at):void 0);if(yt&&(vt=yt?yt[1]:""),ht){var gt=dt();if(null!=gt&&gt>parseFloat(vt)){st=String(gt);break t}}st=vt}var mt={};function wt(a){return t=a,e=function(){for(var t=0,e=K(String(st)).split("."),n=K(String(a)).split("."),r=Math.max(e.length,n.length),i=0;0==t&&i<r;i++){var o=e[i]||"",s=n[i]||"";do{if(o=/(\d*)(\D*)(.*)/.exec(o)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],0==o[0].length&&0==s[0].length)break;t=Z(0==o[1].length?0:parseInt(o[1],10),0==s[1].length?0:parseInt(s[1],10))||Z(0==o[2].length,0==s[2].length)||Z(o[2],s[2]),o=o[3],s=s[3]}while(0==t)}return 0<=t},n=mt,Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t);var t,e,n}var bt=O.document&&ht?dt()||(parseInt(st,10)||void 0):void 0,Et=!ht||9<=Number(bt),It=ht&&!wt("9"),Tt=function(){if(!O.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{O.addEventListener("test",P,e),O.removeEventListener("test",P,e)}catch(t){}return t}();function At(t,e){this.type=t,this.a=this.target=e,this.defaultPrevented=!1}function Nt(t,e){if(At.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(ft){t:{try{ot(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:Rt[t.pointerType]||"",(this.c=t).defaultPrevented&&this.b()}}At.prototype.b=function(){this.defaultPrevented=!0},q(Nt,At);var Rt={2:"touch",3:"pen",4:"mouse"};Nt.prototype.b=function(){Nt.S.b.call(this);var t=this.c;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,It)try{(t.ctrlKey||112<=t.keyCode&&t.keyCode<=123)&&(t.keyCode=-1)}catch(t){}};var St="closure_listenable_"+(1e6*Math.random()|0),Dt=0;function Lt(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=++Dt,this.Y=this.Z=!1}function Ot(t){t.Y=!0,t.listener=null,t.proxy=null,t.src=null,t.ca=null}function Pt(t){this.src=t,this.a={},this.b=0}function kt(t,e){var n,r,i,o=e.type;o in t.a&&(n=t.a[o],(i=0<=(r=z(n,e)))&&Array.prototype.splice.call(n,r,1),i&&(Ot(e),0==t.a[o].length&&(delete t.a[o],t.b--)))}function Vt(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}Pt.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var s=Vt(t,e,r,i);return-1<s?(e=t[s],n||(e.Z=!1)):((e=new Lt(e,this.src,o,!!r,i)).Z=n,t.push(e)),e};var _t="closure_lm_"+(1e6*Math.random()|0),Ut={};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=zt(r);return e&&e[St]?e.wa(n,r,_(i)?!!i.capture:!!i,o):jt(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=zt(n),t&&t[St]?t.va(e,n,_(r)?!!r.capture:!!r,i):jt(t,e,n,!1,r,i)}function jt(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var s=_(i)?!!i.capture:!!i;if(s&&!Et)return null;var a,u,h=qt(t);if(h||(t[_t]=h=new Pt(t)),(n=h.add(e,n,r,s,o)).proxy)return n;if(a=Ft,r=u=Et?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)Tt||(i=s),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(xt(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function Mt(t){var e,n,r;"number"!=typeof t&&t&&!t.Y&&((e=t.src)&&e[St]?kt(e.c,t):(n=t.type,r=t.proxy,e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(xt(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=qt(e))?(kt(n,t),0==n.b&&(n.src=null,e[_t]=null)):Ot(t)))}function xt(t){return t in Ut?Ut[t]:Ut[t]="on"+t}function Bt(t,e){var n=t.listener,r=t.ca||t.src;return t.Z&&Mt(t),n.call(r,e)}function Ft(t,e){if(t.Y)return!0;if(Et)return Bt(t,new Nt(e,this));if(!e)t:{e=["window","event"];for(var n=O,r=0;r<e.length;r++)if(null==(n=n[e[r]])){e=null;break t}e=n}return Bt(t,e=new Nt(e,this))}function qt(t){return(t=t[_t])instanceof Pt?t:null}var Gt="__closure_events_fn_"+(1e9*Math.random()>>>0);function zt(e){return"function"==k(e)?e:(e[Gt]||(e[Gt]=function(t){return e.handleEvent(t)}),e[Gt])}function Wt(){G.call(this),this.c=new Pt(this),(this.J=this).C=null}function Qt(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&&kt(t.c,u),i=!1!==s.call(a,r)&&i)}return i&&!r.defaultPrevented}q(Wt,G),Wt.prototype[St]=!0,(S=Wt.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=_(i)?!!i.capture:!!i,r=zt(r),e&&e[St]?(e=e.c,(n=String(n).toString())in e.a&&-1<(r=Vt(s=e.a[n],r,i,o))&&(Ot(s[r]),Array.prototype.splice.call(s,r,1),0==s.length&&(delete e.a[n],e.b--))):(e=e&&qt(e))&&(n=e.a[n.toString()],e=-1,n&&(e=Vt(n,r,i,o)),(r=-1<e?n[e]:null)&&Mt(r))}(this,t,e,n,r)},S.dispatchEvent=function(t){var e,n=this.C;if(n)for(e=[];n;n=n.C)e.push(n);n=this.J;var r=t.type||t;if("string"==typeof t?t=new At(t,n):t instanceof At?t.target=t.target||n:(s=t,it(t=new At(r,n),s)),s=!0,e)for(var i=e.length-1;0<=i;i--)var o=t.a=e[i],s=Qt(o,r,!0,t)&&s;if(s=Qt(o=t.a=n,r,!0,t)&&s,s=Qt(o,r,!1,t)&&s,e)for(i=0;i<e.length;i++)s=Qt(o=t.a=e[i],r,!1,t)&&s;return s},S.G=function(){if(Wt.S.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++)Ot(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 Ht=O.JSON.stringify;function Xt(){this.b=this.a=null}var Yt,Kt=(Jt.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 Jt(function(){return new Zt},function(t){t.reset()},100));function Jt(t,e,n){this.f=n,this.c=t,this.g=e,this.b=0,this.a=null}function Zt(){this.next=this.b=this.a=null}function $t(t,e){var n;Yt||(n=O.Promise.resolve(void 0),Yt=function(){n.then(ne)}),te||(Yt(),te=!0),ee.add(t,e)}Xt.prototype.add=function(t,e){var n=Kt.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},Zt.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null};var te=!(Zt.prototype.reset=function(){this.next=this.b=this.a=null}),ee=new Xt;function ne(){for(var t,e,n;n=e=void 0,n=null,(e=ee).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){O.setTimeout(function(){throw t},0)}(t)}var r=Kt;r.g(t),r.b<r.f&&(r.b++,t.next=r.a,r.a=t)}te=!1}function re(t,e){Wt.call(this),this.b=t||1,this.a=e||O,this.f=x(this.Ya,this),this.g=F()}function ie(t){t.aa=!1,t.M&&(t.a.clearTimeout(t.M),t.M=null)}function oe(t,e,n){if("function"==k(t))n&&(t=x(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=x(t.handleEvent,t)}return 2147483647<Number(e)?-1:O.setTimeout(t,e||0)}q(re,Wt),(S=re.prototype).aa=!1,S.M=null,S.Ya=function(){var t;this.aa&&(0<(t=F()-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),this.dispatchEvent("tick"),this.aa&&(ie(this),this.start())))},S.start=function(){this.aa=!0,this.M||(this.M=this.a.setTimeout(this.f,this.b),this.g=F())},S.G=function(){re.S.G.call(this),ie(this),delete this.a};var se,ae,ue,he=(N(ae=le,ue=se=G),ae.prototype=null===ue?Object.create(ue):(ce.prototype=ue.prototype,new ce),le.prototype.f=function(t){this.b=arguments,this.a?this.c=!0:function t(e){e.a=oe(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)},le.prototype.G=function(){se.prototype.G.call(this),this.a&&(O.clearTimeout(this.a),this.a=null,this.c=!1,this.b=null)},le);function ce(){this.constructor=ae}function le(t,e,n){var r=se.call(this)||this;return r.g=null!=n?t.bind(n):t,r.h=e,r.b=null,r.c=!1,r.a=null,r}function fe(t){G.call(this),this.b=t,this.a={}}q(fe,G);var pe=[];function de(t,e,n,r){Array.isArray(n)||(n&&(pe[0]=n.toString()),n=pe);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 ve(t){et(t.a,function(t,e){this.a.hasOwnProperty(e)&&Mt(t)},t),t.a={}}function ye(){this.a=!0}function ge(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)){var o=i[0];if("noop"!=o&&"stop"!=o&&"close"!=o)for(var s=1;s<i.length;s++)i[s]=""}}}return Ht(n)}catch(t){return e}}(t,n)+(r?" "+r:"")})}fe.prototype.G=function(){fe.S.G.call(this),ve(this)},fe.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},ye.prototype.info=function(){};var me=null;function we(){return me=me||new Wt}function be(t){At.call(this,"serverreachability",t)}function Ee(t){var e=we();e.dispatchEvent(new be(e))}function Ie(t){At.call(this,"statevent",t)}function Te(t){var e=we();e.dispatchEvent(new Ie(e))}function Ae(t){At.call(this,"timingevent",t)}function Ne(t,e){if("function"!=k(t))throw Error("Fn must not be null and must be a function");return O.setTimeout(function(){t()},e)}q(be,At),q(Ie,At),q(Ae,At);var Re={NO_ERROR:0,Za:1,gb:2,fb:3,bb:4,eb:5,hb:6,Da:7,TIMEOUT:8,kb:9},Se={ab:"complete",ob:"success",Ea:"error",Da:"abort",mb:"ready",nb:"readystatechange",TIMEOUT:"timeout",ib:"incrementaldata",lb:"progress",cb:"downloadprogress",pb:"uploadprogress"};function De(){}function Le(t){var e;return(e=t.a)||(e=t.a={}),e}function Oe(){}De.prototype.a=null;var Pe,ke={OPEN:"a",$a:"b",Ea:"c",jb:"d"};function Ve(){At.call(this,"d")}function _e(){At.call(this,"c")}function Ue(){}function Ce(t,e,n,r){this.g=t,this.c=e,this.f=n,this.T=r||1,this.J=new fe(this),this.P=je,t=lt?125:void 0,this.R=new re(t),this.B=null,this.b=!1,this.j=this.l=this.i=this.H=this.u=this.U=this.o=null,this.s=[],this.a=null,this.D=0,this.h=this.m=null,this.N=-1,this.A=!1,this.O=0,this.F=null,this.W=this.C=this.V=this.I=!1}q(Ve,At),q(_e,At),q(Ue,De),Pe=new Ue;var je=45e3,Me={},xe={};function Be(t,e,n){t.H=1,t.i=un(en(e)),t.j=n,t.I=!0,Fe(t,null)}function Fe(t,e){t.u=F(),Ge(t),t.l=en(t.i);var s,a,u,h,c,l,n=t.l,r=t.T;Array.isArray(r)||(r=[String(r)]),En(n.b,"t",r),t.D=0,t.a=dr(t.g,t.g.C?e:null),0<t.O&&(t.F=new he(x(t.Ca,t,t.a),t.O)),de(t.J,t.a,"readystatechange",t.Wa),e=t.B?nt(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)),Ee(1),s=t.c,a=t.m,u=t.l,h=t.f,c=t.T,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 ("+h+") [attempt "+c+"]: "+a+"\n"+u+"\n"+t})}function qe(t,e,n){for(var r,i,o,s,a=!0;!t.A&&t.D<n.length;){var u=(i=n,s=o=void 0,o=(r=t).D,-1==(s=i.indexOf("\n",o))?xe:(o=Number(i.substring(o,s)),isNaN(o)?Me:(s+=1)+o>i.length?xe:(i=i.substr(s,o),r.D=s+o,i)));if(u==xe){4==e&&(t.h=4,Te(14),a=!1),ge(t.c,t.f,null,"[Incomplete Response]");break}if(u==Me){t.h=4,Te(15),ge(t.c,t.f,n,"[Invalid Chunk]"),a=!1;break}ge(t.c,t.f,u,null),Xe(t,u)}4==e&&0==n.length&&(t.h=1,Te(16),a=!1),t.b=t.b&&a,a?0<n.length&&!t.W&&(t.W=!0,(e=t.g).a==t&&e.V&&!e.F&&(e.c.info("Great, no buffering proxy detected. Bytes received: "+n.length),sr(e),e.F=!0)):(ge(t.c,t.f,n,"[Invalid Chunked Response]"),He(t),Qe(t))}function Ge(t){t.U=F()+t.P,ze(t,t.P)}function ze(t,e){if(null!=t.o)throw Error("WatchDog timer not null");t.o=Ne(x(t.Ua,t),e)}function We(t){t.o&&(O.clearTimeout(t.o),t.o=null)}function Qe(t){0==t.g.v||t.A||hr(t.g,t)}function He(t){We(t);var e=t.F;e&&"function"==typeof e.ja&&e.ja(),t.F=null,ie(t.R),ve(t.J),t.a&&(e=t.a,t.a=null,e.abort(),e.ja())}function Xe(t,e){try{var n,r,i,o,s,a,u,h,c,l,f,p=t.g;if(0!=p.v&&(p.a==t||Dn(p.b,t)))if(p.I=t.N,!t.C&&Dn(p.b,t)&&3==p.v){try{var d=p.ka.a.parse(e)}catch(t){d=null}if(Array.isArray(d)&&3==d.length){var v=d;if(0==v[0]){t:if(!p.j){if(p.a){if(!(p.a.u+3e3<t.u))break t;ur(p),Jn(p)}or(p),Te(18)}}else p.oa=v[1],0<p.oa-p.P&&v[2]<37500&&p.H&&0==p.o&&!p.m&&(p.m=Ne(x(p.Ra,p),6e3));if(Sn(p.b)<=1&&p.ea){try{p.ea()}catch(t){}p.ea=void 0}}else lr(p,11)}else if(!t.C&&p.a!=t||ur(p),!X(e))for(e=d=p.ka.a.parse(e),d=0;d<e.length;d++){v=e[d],p.P=v[0],v=v[1],2==p.v?"c"==v[0]?(p.J=v[1],p.ga=v[2],null!=(n=v[3])&&(p.ha=n,p.c.info("VER="+p.ha)),null!=(r=v[4])&&(p.pa=r,p.c.info("SVER="+p.pa)),null!=(i=v[5])&&"number"==typeof i&&0<i&&(o=1.5*i,p.D=o,p.c.info("backChannelRequestTimeoutMs_="+o)),o=p,(s=t.a)&&(!(a=s.a?s.a.getResponseHeader("X-Client-Wire-Protocol"):null)||!(u=o.b).a&&(J(a,"spdy")||J(a,"quic")||J(a,"h2"))&&(u.f=u.g,u.a=new Set,u.b&&(Ln(u,u.b),u.b=null)),!o.A||(h=s.a?s.a.getResponseHeader("X-HTTP-Session-Id"):null)&&(o.na=h,an(o.B,o.A,h))),p.v=3,p.f&&p.f.ta(),p.V&&(p.N=F()-t.u,p.c.info("Handshake RTT: "+p.N+"ms")),c=t,(o=p).la=pr(o,o.C?o.ga:null,o.fa),c.C?(On(o.b,c),l=c,(f=o.D)&&l.setTimeout(f),l.o&&(We(l),Ge(l)),o.a=c):ir(o),0<p.g.length&&tr(p)):"stop"!=v[0]&&"close"!=v[0]||lr(p,7):3==p.v&&("stop"==v[0]||"close"==v[0]?"stop"==v[0]?lr(p,7):Kn(p):"noop"!=v[0]&&p.f&&p.f.sa(v),p.o=0)}Ee(4)}catch(t){}}function Ye(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(V(t)||"string"==typeof t)W(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(V(t)||"string"==typeof t){n=[];for(var r=t.length,i=0;i<r;i++)n.push(i)}else for(i in n=[],r=0,t)n[r++]=i;i=(r=function(t){if(t.K&&"function"==typeof t.K)return t.K();if("string"==typeof t)return t.split("");if(V(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t)).length;for(var o=0;o<i;o++)e.call(void 0,r[o],n&&n[o],t)}}function Ke(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 Ke)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 Je(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];Ze(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;)Ze(i,r=t.a[e])||(i[t.a[n++]=r]=1),e++;t.a.length=n}}function Ze(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(S=Ce.prototype).setTimeout=function(t){this.P=t},S.Wa=function(t){t=t.target;var e=this.F;e&&3==Qn(t)?e.f():this.Ca(t)},S.Ca=function(t){try{if(t==this.a)t:{var e=Qn(this.a),n=this.a.ua(),r=this.a.X();if(!(e<3||3==e&&!lt&&!this.a.$())){this.A||4!=e||7==n||Ee(8==n||r<=0?3:2),We(this);var i=this.a.X();this.N=i;var o=this.a.$();if(this.b=200==i,h=this.c,c=this.m,l=this.l,f=this.f,p=this.T,d=e,v=i,h.info(function(){return"XMLHTTP RESP ("+f+") [ attempt "+p+"]: "+c+"\n"+l+"\n"+d+" "+v}),this.b){if(this.V&&!this.C){e:{if(this.a){var s,a=this.a;if((s=a.a?a.a.getResponseHeader("X-HTTP-Initial-Response"):null)&&!X(s)){var u=s;break e}}u=null}if(!u){this.b=!1,this.h=3,Te(12),He(this),Qe(this);break t}ge(this.c,this.f,u,"Initial handshake response via X-HTTP-Initial-Response"),this.C=!0,Xe(this,u)}this.I?(qe(this,e,o),lt&&this.b&&3==e&&(de(this.J,this.R,"tick",this.Va),this.R.start())):(ge(this.c,this.f,o,null),Xe(this,o)),4==e&&He(this),this.b&&!this.A&&(4==e?hr(this.g,this):(this.b=!1,Ge(this)))}else 400==i&&0<o.indexOf("Unknown SID")?(this.h=3,Te(12)):(this.h=0,Te(13)),He(this),Qe(this)}}}catch(t){}var h,c,l,f,p,d,v},S.Va=function(){var t,e;this.a&&(t=Qn(this.a),e=this.a.$(),this.D<e.length&&(We(this),qe(this,t,e),this.b&&4!=t&&Ge(this)))},S.cancel=function(){this.A=!0,He(this)},S.Ua=function(){this.o=null;var t,e,n=F();0<=n-this.U?(t=this.c,e=this.l,t.info(function(){return"TIMEOUT: "+e}),2!=this.H&&(Ee(3),Te(17)),He(this),this.h=2,Qe(this)):ze(this,this.U-n)},(S=Ke.prototype).K=function(){Je(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},S.L=function(){return Je(this),this.a.concat()},S.get=function(t,e){return Ze(this.b,t)?this.b[t]:e},S.set=function(t,e){Ze(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 $e=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function tn(t,e){var n;this.c=this.j=this.f="",this.h=null,this.i=this.g="",this.a=!1,t instanceof tn?(this.a=void 0!==e?e:t.a,nn(this,t.f),this.j=t.j,rn(this,t.c),on(this,t.h),this.g=t.g,e=t.b,(n=new gn).c=e.c,e.a&&(n.a=new Ke(e.a),n.b=e.b),sn(this,n),this.i=t.i):t&&(n=String(t).match($e))?(this.a=!!e,nn(this,n[1]||"",!0),this.j=hn(n[2]||""),rn(this,n[3]||"",!0),on(this,n[4]),this.g=hn(n[5]||"",!0),sn(this,n[6]||"",!0),this.i=hn(n[7]||"")):(this.a=!!e,this.b=new gn(null,this.a))}function en(t){return new tn(t)}function nn(t,e,n){t.f=n?hn(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function rn(t,e,n){t.c=n?hn(e,!0):e}function on(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 sn(t,e,n){var r,i;e instanceof gn?(t.b=e,r=t.b,(i=t.a)&&!r.f&&(mn(r),r.c=null,r.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(wn(this,e),En(this,n,t))},r)),r.f=i):(n||(e=cn(e,vn)),t.b=new gn(e,t.a))}function an(t,e,n){t.b.set(e,n)}function un(t){return an(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^F()).toString(36)),t}function hn(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function cn(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,ln),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function ln(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}tn.prototype.toString=function(){var t=[],e=this.f;e&&t.push(cn(e,fn,!0),":");var n=this.c;return!n&&"file"!=e||(t.push("//"),(e=this.j)&&t.push(cn(e,fn,!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(cn(n,"/"==n.charAt(0)?dn:pn,!0))),(n=this.b.toString())&&t.push("?",n),(n=this.i)&&t.push("#",cn(n,yn)),t.join("")};var fn=/[#\/\?@]/g,pn=/[#\?:]/g,dn=/[#\?]/g,vn=/[#\?@]/g,yn=/#/g;function gn(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function mn(n){n.a||(n.a=new Ke,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 wn(t,e){mn(t),e=In(t,e),Ze(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,Ze((t=t.a).b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&Je(t)))}function bn(t,e){return mn(t),e=In(t,e),Ze(t.a.b,e)}function En(t,e,n){wn(t,e),0<n.length&&(t.c=null,t.a.set(In(t,e),H(n)),t.b+=n.length)}function In(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}function Tn(t,e){this.b=t,this.a=e}function An(t){this.g=t||Nn,t=O.PerformanceNavigationTiming?0<(t=O.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(O.ia&&O.ia.ya&&O.ia.ya()&&O.ia.ya().qb),this.f=t?this.g:1,this.a=null,1<this.f&&(this.a=new Set),this.b=null,this.c=[]}(S=gn.prototype).add=function(t,e){mn(this),this.c=null,t=In(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){mn(this),this.a.forEach(function(t,e){W(t,function(t){n.call(r,t,e,this)},this)},this)},S.L=function(){mn(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){mn(this);var e=[];if("string"==typeof t)bn(this,t)&&(e=Q(e,this.a.get(In(this,t))));else{t=this.a.K();for(var n=0;n<t.length;n++)e=Q(e,t[n])}return e},S.set=function(t,e){return mn(this),this.c=null,bn(this,t=In(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 Nn=10;function Rn(t){return t.b||t.a&&t.a.size>=t.f}function Sn(t){return t.b?1:t.a?t.a.size:0}function Dn(t,e){return t.b?t.b==e:t.a&&t.a.has(e)}function Ln(t,e){t.a?t.a.add(e):t.b=e}function On(t,e){t.b&&t.b==e?t.b=null:t.a&&t.a.has(e)&&t.a.delete(e)}function Pn(t){var e,n;if(null!=t.b)return t.c.concat(t.b.s);if(null==t.a||0===t.a.size)return H(t.c);var r=t.c;try{for(var i=R(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 kn(){}function Vn(){this.a=new kn}function _n(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}An.prototype.cancel=function(){var e,t;if(this.c=Pn(this),this.b)this.b.cancel(),this.b=null;else if(this.a&&0!==this.a.size){try{for(var n=R(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()}},kn.prototype.stringify=function(t){return O.JSON.stringify(t,void 0)},kn.prototype.parse=function(t){return O.JSON.parse(t,void 0)};var Un=O.JSON.parse;function Cn(t){Wt.call(this),this.headers=new Ke,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=jn,this.D=this.F=!1}q(Cn,Wt);var jn="",Mn=/^https?$/i,xn=["POST","PUT"];function Bn(t){return"content-type"==t.toLowerCase()}function Fn(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,qn(t),zn(t)}function qn(t){t.u||(t.u=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function Gn(t){if(t.b&&void 0!==L&&(!t.s[1]||4!=Qn(t)||2!=t.X()))if(t.l&&4==Qn(t))oe(t.za,0,t);else if(t.dispatchEvent("readystatechange"),4==Qn(t)){t.b=!1;try{var e,n,r,i,o=t.X();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}if((e=s)||((n=0===o)&&(!(i=String(t.B).match($e)[1]||null)&&O.self&&O.self.location&&(i=(r=O.self.location.protocol).substr(0,r.length-1)),n=!Mn.test(i?i.toLowerCase():"")),e=n),e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{t.h=6;try{var a=2<Qn(t)?t.a.statusText:""}catch(t){a=""}t.f=a+" ["+t.X()+"]",qn(t)}}finally{zn(t)}}}function zn(t,e){if(t.a){Wn(t);var n=t.a,r=t.s[0]?P:null;t.a=null,t.s=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(t){}}}function Wn(t){t.a&&t.D&&(t.a.ontimeout=null),t.m&&(O.clearTimeout(t.m),t.m=null)}function Qn(t){return t.a?t.a.readyState:0}function Hn(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}var i;r||(i="",et(n,function(t,e){i+=e,i+=":",i+=t,i+="\r\n"}),n=i,"string"==typeof t?null!=n&&encodeURIComponent(String(n)):an(t,e,n))}function Xn(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function Yn(t){this.pa=0,this.g=[],this.c=new ye,this.ga=this.la=this.B=this.fa=this.a=this.na=this.A=this.W=this.i=this.O=this.l=null,this.La=this.R=0,this.Ia=Xn("failFast",!1,t),this.H=this.m=this.j=this.h=this.f=null,this.T=!0,this.I=this.oa=this.P=-1,this.U=this.o=this.u=0,this.Fa=Xn("baseRetryDelayMs",5e3,t),this.Ma=Xn("retryDelaySeedMs",1e4,t),this.Ja=Xn("forwardChannelMaxRetries",2,t),this.ma=Xn("forwardChannelRequestTimeoutMs",2e4,t),this.Ka=t&&t.g||void 0,this.D=void 0,this.C=t&&t.supportsCrossDomainXhr||!1,this.J="",this.b=new An(t&&t.concurrentRequestLimit),this.ka=new Vn,this.da=t&&t.fastHandshake||!1,this.Ga=t&&t.b||!1,t&&t.f&&(this.c.a=!1),t&&t.forceLongPolling&&(this.T=!1),this.V=!this.da&&this.T&&t&&t.c||!1,this.ea=void 0,this.N=0,this.F=!1,this.s=null}function Kn(t){var e,n;Zn(t),3==t.v&&(e=t.R++,an(n=en(t.B),"SID",t.J),an(n,"RID",e),an(n,"TYPE","terminate"),nr(t,n),(e=new Ce(t,t.c,e,void 0)).H=2,e.i=un(en(n)),n=!1,O.navigator&&O.navigator.sendBeacon&&(n=O.navigator.sendBeacon(e.i.toString(),"")),!n&&O.Image&&((new Image).src=e.i,n=!0),n||(e.a=dr(e.g,null),e.a.ba(e.i)),e.u=F(),Ge(e)),fr(t)}function Jn(t){t.a&&(sr(t),t.a.cancel(),t.a=null)}function Zn(t){Jn(t),t.j&&(O.clearTimeout(t.j),t.j=null),ur(t),t.b.cancel(),t.h&&("number"==typeof t.h&&O.clearTimeout(t.h),t.h=null)}function $n(t,e){t.g.push(new Tn(t.La++,e)),3==t.v&&tr(t)}function tr(t){Rn(t.b)||t.h||(t.h=!0,$t(t.Ba,t),t.u=0)}function er(t,e){var n=e?e.f:t.R++,r=en(t.B);an(r,"SID",t.J),an(r,"RID",n),an(r,"AID",t.P),nr(t,r),t.i&&t.l&&Hn(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=rr(t,n,1e3),n.setTimeout(Math.round(.5*t.ma)+Math.round(.5*t.ma*Math.random())),Ln(t.b,n),Be(n,r,e)}function nr(t,n){t.f&&Ye({},function(t,e){an(n,e,t)})}function rr(t,e,n){n=Math.min(t.g.length,n);var r=t.f?x(t.f.Ha,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 h=i[u].b,c=i[u].a;if((h-=o)<0)o=Math.max(0,i[u].b-100),a=!1;else try{!function(t,r,e){var i=e||"";try{Ye(t,function(t,e){var n=t;_(t)&&(n=Ht(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}(c,s,"req"+h+"_")}catch(t){r&&r(c)}}if(a){r=s.join("&");break t}}return t=t.g.splice(0,n),e.s=t,r}function ir(t){t.a||t.j||(t.U=1,$t(t.Aa,t),t.o=0)}function or(t){return!(t.a||t.j||3<=t.o)&&(t.U++,t.j=Ne(x(t.Aa,t),cr(t,t.o)),t.o++,1)}function sr(t){null!=t.s&&(O.clearTimeout(t.s),t.s=null)}function ar(t){t.a=new Ce(t,t.c,"rpc",t.U),null===t.i&&(t.a.B=t.l),t.a.O=0;var e=en(t.la);an(e,"RID","rpc"),an(e,"SID",t.J),an(e,"CI",t.H?"0":"1"),an(e,"AID",t.P),nr(t,e),an(e,"TYPE","xmlhttp"),t.i&&t.l&&Hn(e,t.i,t.l),t.D&&t.a.setTimeout(t.D);var n=t.a;t=t.ga,n.H=1,n.i=un(en(e)),n.j=null,n.I=!0,Fe(n,t)}function ur(t){null!=t.m&&(O.clearTimeout(t.m),t.m=null)}function hr(t,e){var n,r=null;if(t.a==e){ur(t),sr(t),t.a=null;var i=2}else{if(!Dn(t.b,e))return;r=e.s,On(t.b,e),i=1}if(t.I=e.N,0!=t.v)if(e.b){1==i?(r=e.j?e.j.length:0,e=F()-e.u,n=t.u,(i=we()).dispatchEvent(new Ae(i)),tr(t)):ir(t)}else if(3==(n=e.h)||0==n&&0<t.I||!(1==i&&function(t,e){if(!(Sn(t.b)>=t.b.f-(t.h?1:0))){if(t.h)return t.g=e.s.concat(t.g),1;if(!(1==t.v||2==t.v||t.u>=(t.Ia?0:t.Ja)))return t.h=Ne(x(t.Ba,t,e),cr(t,t.u)),t.u++,1}}(t,e)||2==i&&or(t)))switch(r&&0<r.length&&(e=t.b,e.c=e.c.concat(r)),n){case 1:lr(t,5);break;case 4:lr(t,10);break;case 3:lr(t,6);break;default:lr(t,2)}}function cr(t,e){var n=t.Fa+Math.floor(Math.random()*t.Ma);return t.f||(n*=2),n*e}function lr(t,e){var n,r,i,o,s,a;t.c.info("Error code "+e),2==e?(n=null,t.f&&(n=null),r=x(t.Xa,t),n||(n=new tn("//www.google.com/images/cleardot.gif"),O.location&&"http"==O.location.protocol||nn(n,"https"),un(n)),i=n.toString(),o=r,a=new ye,O.Image?((s=new Image).onload=B(_n,a,s,"TestLoadImage: loaded",!0,o),s.onerror=B(_n,a,s,"TestLoadImage: error",!1,o),s.onabort=B(_n,a,s,"TestLoadImage: abort",!1,o),s.ontimeout=B(_n,a,s,"TestLoadImage: timeout",!1,o),O.setTimeout(function(){s.ontimeout&&s.ontimeout()},1e4),s.src=i):o(!1)):Te(2),t.v=0,t.f&&t.f.ra(e),fr(t),Zn(t)}function fr(t){t.v=0,t.I=-1,t.f&&(0==Pn(t.b).length&&0==t.g.length||(t.b.c.length=0,H(t.g),t.g.length=0),t.f.qa())}function pr(t,e,n){var r,i,o,s,a,u,h,c=(r=n)instanceof tn?en(r):new tn(r,void 0);return""!=c.c?(e&&rn(c,e+"."+c.c),on(c,c.h)):(i=O.location,o=i.protocol,s=e?e+"."+i.hostname:i.hostname,a=+i.port,u=n,h=new tn(null,void 0),o&&nn(h,o),s&&rn(h,s),a&&on(h,a),u&&(h.g=u),c=h),t.W&&et(t.W,function(t,e){an(c,e,t)}),e=t.A,n=t.na,e&&n&&an(c,e,n),an(c,"VER",t.ha),nr(t,c),c}function dr(t,e){if(e&&!t.C)throw Error("Can't create secondary domain capable XhrIo object.");return(e=new Cn(t.Ka)).F=t.C,e}function vr(){}function yr(){if(ht&&!(10<=Number(bt)))throw Error("Environmental error: no available transport.")}function gr(t,e){Wt.call(this),this.a=new Yn(e),this.l=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)&&!X(t)&&(this.a.i=t),this.h=e&&e.supportsCrossDomainXhr||!1,this.g=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!X(e)&&(this.a.A=e,null!==(t=this.b)&&e in t&&(e in(t=this.b)&&delete t[e])),this.f=new br(this)}function mr(t){Ve.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 wr(){_e.call(this),this.status=1}function br(t){this.a=t}(S=Cn.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?Le(this.H):Le(Pe),this.a.onreadystatechange=x(this.za,this);try{this.A=!0,this.a.open(e,String(t),!0),this.A=!1}catch(t){return void Fn(this,t)}t=n||"";var i,o=new Ke(this.headers);r&&Ye(r,function(t,e){o.set(e,t)}),r=function(t){t:{for(var e=Bn,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=O.FormData&&t instanceof O.FormData,0<=z(xn,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{Wn(this),0<this.o&&((this.D=(i=this.a,ht&&wt(9)&&"number"==typeof i.timeout&&void 0!==i.ontimeout))?(this.a.timeout=this.o,this.a.ontimeout=x(this.xa,this)):this.m=oe(this.xa,this.o,this)),this.l=!0,this.a.send(t),this.l=!1}catch(t){Fn(this,t)}},S.xa=function(){void 0!==L&&this.a&&(this.f="Timed out after "+this.o+"ms, aborting",this.h=8,this.dispatchEvent("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,this.dispatchEvent("complete"),this.dispatchEvent("abort"),zn(this))},S.G=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),zn(this,!0)),Cn.S.G.call(this)},S.za=function(){this.j||(this.A||this.l||this.g?Gn(this):this.Ta())},S.Ta=function(){Gn(this)},S.X=function(){try{return 2<Qn(this)?this.a.status:-1}catch(t){return-1}},S.$=function(){try{return this.a?this.a.responseText:""}catch(t){return""}},S.Na=function(t){if(this.a){var e=this.a.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Un(e)}},S.ua=function(){return this.h},S.Qa=function(){return"string"==typeof this.f?this.f:String(this.f)},(S=Yn.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?it(r=nt(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=rr(this,n,e),an(i=en(this.B),"RID",t),an(i,"CVER",22),this.A&&an(i,"X-HTTP-Session-Id",this.A),nr(this,i),this.i&&r&&Hn(i,this.i,r),Ln(this.b,n),this.Ga&&an(i,"TYPE","init"),this.da?(an(i,"$req",e),an(i,"SID","null"),n.V=!0,Be(n,i,null)):Be(n,i,e),this.v=2}}else 3==this.v&&(t?er(this,t):0==this.g.length||Rn(this.b)||er(this))},S.Aa=function(){var t;this.j=null,ar(this),this.V&&!(this.F||null==this.a||this.N<=0)&&(t=2*this.N,this.c.info("BP detection timer enabled: "+t),this.s=Ne(x(this.Sa,this),t))},S.Sa=function(){this.s&&(this.s=null,this.c.info("BP detection timeout reached."),this.c.info("Buffering proxy detected and switch to long-polling!"),this.H=!1,this.F=!0,Jn(this),ar(this))},S.Ra=function(){null!=this.m&&(this.m=null,Jn(this),or(this),Te(19))},S.Xa=function(t){t?(this.c.info("Successfully pinged google.com"),Te(2)):(this.c.info("Failed to ping google.com"),Te(1))},(S=vr.prototype).ta=function(){},S.sa=function(){},S.ra=function(){},S.qa=function(){},S.Ha=function(){},yr.prototype.a=function(t,e){return new gr(t,e)},q(gr,Wt),(S=gr.prototype).addEventListener=function(t,e,n,r){gr.S.addEventListener.call(this,t,e,n,r)},S.removeEventListener=function(t,e,n,r){gr.S.removeEventListener.call(this,t,e,n,r)},S.Oa=function(){this.a.f=this.f,this.h&&(this.a.C=!0);var t=this.a,e=this.l,n=this.b||void 0;Te(0),t.fa=e,t.W=n||{},t.H=t.T,t.B=pr(t,null,t.fa),tr(t)},S.close=function(){Kn(this.a)},S.Pa=function(t){var e;"string"==typeof t?((e={}).__data__=t,$n(this.a,e)):this.g?((e={}).__data__=Ht(t),$n(this.a,e)):$n(this.a,t)},S.G=function(){this.a.f=null,delete this.f,Kn(this.a),delete this.a,gr.S.G.call(this)},q(mr,Ve),q(wr,_e),q(br,vr),br.prototype.ta=function(){this.a.dispatchEvent("a")},br.prototype.sa=function(t){this.a.dispatchEvent(new mr(t))},br.prototype.ra=function(t){this.a.dispatchEvent(new wr)},br.prototype.qa=function(){this.a.dispatchEvent("b")},yr.prototype.createWebChannel=yr.prototype.a,gr.prototype.send=gr.prototype.Pa,gr.prototype.open=gr.prototype.Oa,Re.NO_ERROR=0,Re.TIMEOUT=8,Re.HTTP_ERROR=6,Se.COMPLETE="complete",(Oe.EventType=ke).OPEN="a",ke.CLOSE="b",ke.ERROR="c",ke.MESSAGE="d",Wt.prototype.listen=Wt.prototype.va,Cn.prototype.listenOnce=Cn.prototype.wa,Cn.prototype.getLastError=Cn.prototype.Qa,Cn.prototype.getLastErrorCode=Cn.prototype.ua,Cn.prototype.getStatus=Cn.prototype.X,Cn.prototype.getResponseJson=Cn.prototype.Na,Cn.prototype.getResponseText=Cn.prototype.$,Cn.prototype.send=Cn.prototype.ba;var Er={createWebChannelTransport:function(){return new yr},ErrorCode:Re,EventType:Se,WebChannel:Oe,XhrIo:Cn},Ir=Er.createWebChannelTransport,Tr=Er.ErrorCode,Ar=Er.EventType,Nr=Er.WebChannel,Rr=Er.XhrIo,Sr=(Dr.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},Dr.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},Dr.prototype.setServiceProps=function(t){return this.serviceProps=t,this},Dr);function Dr(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY"}var Lr,Or={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"},Pr=(o(Vr,Lr=Error),Vr),kr=new p("@firebase/firestore");function Vr(t,e){var n=this;return(n=Lr.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 _r(){return kr.logLevel}function Ur(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];kr.logLevel<=a.DEBUG&&(e=n.map(Mr),kr.debug.apply(kr,s(["Firestore (7.22.0): "+t],e)))}function Cr(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];kr.logLevel<=a.ERROR&&(e=n.map(Mr),kr.error.apply(kr,s(["Firestore (7.22.0): "+t],e)))}function jr(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];kr.logLevel<=a.WARN&&(e=n.map(Mr),kr.warn.apply(kr,s(["Firestore (7.22.0): "+t],e)))}function Mr(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return e}}function xr(t){void 0===t&&(t="Unexpected state");var e="FIRESTORE (7.22.0) INTERNAL ASSERTION FAILED: "+t;throw Cr(e),new Error(e)}function Br(t){t||xr()}function Fr(t){var e,n=0;for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&n++;return n}function qr(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function Gr(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}var zr,Wr,Qr=(Object.defineProperty(ti.prototype,"length",{get:function(){return this.t},enumerable:!1,configurable:!0}),ti.prototype.isEqual=function(t){return 0===ti.i(this,t)},ti.prototype.child=function(t){var e=this.segments.slice(this.offset,this.limit());return t instanceof ti?t.forEach(function(t){e.push(t)}):e.push(t),this.o(e)},ti.prototype.limit=function(){return this.offset+this.length},ti.prototype.u=function(t){return t=void 0===t?1:t,this.o(this.segments,this.offset+t,this.length-t)},ti.prototype.h=function(){return this.o(this.segments,this.offset,this.length-1)},ti.prototype.l=function(){return this.segments[this.offset]},ti.prototype._=function(){return this.get(this.length-1)},ti.prototype.get=function(t){return this.segments[this.offset+t]},ti.prototype.m=function(){return 0===this.length},ti.prototype.T=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},ti.prototype.I=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},ti.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},ti.prototype.A=function(){return this.segments.slice(this.offset,this.limit())},ti.i=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},ti),Hr=(o($r,Wr=Qr),$r.prototype.o=function(t,e,n){return new $r(t,e,n)},$r.prototype.R=function(){return this.A().join("/")},$r.prototype.toString=function(){return this.R()},$r.P=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 Pr(Or.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 $r(n)},$r.p=function(){return new $r([])},$r),Xr=/^[_a-zA-Z][_a-zA-Z0-9]*$/,Yr=(o(Zr,zr=Qr),Zr.prototype.o=function(t,e,n){return new Zr(t,e,n)},Zr.g=function(t){return Xr.test(t)},Zr.prototype.R=function(){return this.A().map(function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),Zr.g(t)||(t="`"+t+"`"),t}).join(".")},Zr.prototype.toString=function(){return this.R()},Zr.prototype.V=function(){return 1===this.length&&"__name__"===this.get(0)},Zr.v=function(){return new Zr(["__name__"])},Zr.S=function(t){for(var e=[],n="",r=0,i=function(){if(0===n.length)throw new Pr(Or.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 Pr(Or.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var a=t[r+1];if("\\"!==a&&"."!==a&&"`"!==a)throw new Pr(Or.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 Pr(Or.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new Zr(e)},Zr.p=function(){return new Zr([])},Zr),Kr=(Jr.C=function(t){return new Jr(Hr.P(t))},Jr.D=function(t){return new Jr(Hr.P(t).u(5))},Jr.prototype.F=function(t){return 2<=this.path.length&&this.path.get(this.path.length-2)===t},Jr.prototype.isEqual=function(t){return null!==t&&0===Hr.i(this.path,t.path)},Jr.prototype.toString=function(){return this.path.toString()},Jr.i=function(t,e){return Hr.i(t.path,e.path)},Jr.N=function(t){return t.length%2==0},Jr.$=function(t){return new Jr(new Hr(t.slice()))},Jr);function Jr(t){this.path=t}function Zr(){return null!==zr&&zr.apply(this,arguments)||this}function $r(){return null!==Wr&&Wr.apply(this,arguments)||this}function ti(t,e,n){void 0===e?e=0:e>t.length&&xr(),void 0===n?n=t.length-e:n>t.length-e&&xr(),this.segments=t,this.offset=e,this.t=n}function ei(t,e){if(0!==e.length)throw new Pr(Or.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+wi(e.length,"argument")+".")}function ni(t,e,n){if(e.length!==n)throw new Pr(Or.INVALID_ARGUMENT,"Function "+t+"() requires "+wi(n,"argument")+", but was called with "+wi(e.length,"argument")+".")}function ri(t,e,n){if(e.length<n)throw new Pr(Or.INVALID_ARGUMENT,"Function "+t+"() requires at least "+wi(n,"argument")+", but was called with "+wi(e.length,"argument")+".")}function ii(t,e,n,r){if(e.length<n||e.length>r)throw new Pr(Or.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+wi(e.length,"argument")+".")}function oi(t,e,n,r){li(t,e,mi(n)+" argument",r)}function si(t,e,n,r){void 0!==r&&oi(t,e,n,r)}function ai(t,e,n,r){li(t,e,n+" option",r)}function ui(t,e,n,r){void 0!==r&&ai(t,e,n,r)}function hi(t,e,n,r,u){void 0!==r&&function(t,e,n){for(var r=[],i=0,o=u;i<o.length;i++){var s=o[i];if(s===n)return;r.push(pi(s))}var a=pi(n);throw new Pr(Or.INVALID_ARGUMENT,"Invalid value "+a+" provided to function "+t+'() for option "'+e+'". Acceptable values: '+r.join(", "))}(t,n,r)}function ci(t,e,n,r){if(!e.some(function(t){return t===r}))throw new Pr(Or.INVALID_ARGUMENT,"Invalid value "+pi(r)+" provided to function "+t+"() for its "+mi(n)+" argument. Acceptable values: "+e.join(", "));return r}function li(t,e,n,r){if(!("object"===e?fi(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=pi(r);throw new Pr(Or.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function fi(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function pi(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":xr();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 di(t,e,n){if(void 0===n)throw new Pr(Or.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+mi(e)+" argument, but it was undefined.")}function vi(n,t,r){qr(t,function(t,e){if(r.indexOf(t)<0)throw new Pr(Or.INVALID_ARGUMENT,"Unknown option '"+t+"' passed to function "+n+"(). Available options: "+r.join(", "))})}function yi(t,e,n,r){var i=pi(r);return new Pr(Or.INVALID_ARGUMENT,"Function "+t+"() requires its "+mi(n)+" argument to be a "+e+", but it was: "+i)}function gi(t,e,n){if(n<=0)throw new Pr(Or.INVALID_ARGUMENT,"Function "+t+"() requires its "+mi(e)+" argument to be a positive number, but it was: "+n+".")}function mi(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}}function wi(t,e){return t+" "+e+(1===t?"":"s")}var bi=(Ei.k=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},Ei);function Ei(){}function Ii(t,e){return t<e?-1:e<t?1:0}function Ti(t,n,r){return t.length===n.length&&t.every(function(t,e){return r(t,n[e])})}var Ai=(Ni.fromBase64String=function(t){return new Ni(atob(t))},Ni.fromUint8Array=function(t){return new Ni(function(t){for(var e="",n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(t))},Ni.prototype.toBase64=function(){return t=this.O,btoa(t);var t},Ni.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.O)},Ni.prototype.M=function(){return 2*this.O.length},Ni.prototype.L=function(t){return Ii(this.O,t.O)},Ni.prototype.isEqual=function(t){return this.O===t.O},Ni);function Ni(t){this.O=t}Ai.q=new Ai("");var Ri=(Si.fromBase64String=function(t){try{return new Si(Ai.fromBase64String(t))}catch(t){throw new Pr(Or.INVALID_ARGUMENT,"Failed to construct Bytes from Base64 string: "+t)}},Si.fromUint8Array=function(t){return new Si(Ai.fromUint8Array(t))},Si.prototype.toBase64=function(){return this.U.toBase64()},Si.prototype.toUint8Array=function(){return this.U.toUint8Array()},Si.prototype.toString=function(){return"Bytes(base64: "+this.toBase64()+")"},Si.prototype.isEqual=function(t){return this.U.isEqual(t.U)},Si);function Si(t){this.U=t}function Di(){if("undefined"==typeof Uint8Array)throw new Pr(Or.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function Li(){if("undefined"==typeof atob)throw new Pr(Or.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}function Oi(t,e,n,r,i){this.B=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i}var Pi,ki=(o(Fi,Pi=Ri),Fi.fromBase64String=function(t){ni("Blob.fromBase64String",arguments,1),oi("Blob.fromBase64String","string",1,t),Li();try{return new Fi(Ai.fromBase64String(t))}catch(t){throw new Pr(Or.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+t)}},Fi.fromUint8Array=function(t){if(ni("Blob.fromUint8Array",arguments,1),Di(),!(t instanceof Uint8Array))throw yi("Blob.fromUint8Array","Uint8Array",1,t);return new Fi(Ai.fromUint8Array(t))},Fi.prototype.toBase64=function(){return ni("Blob.toBase64",arguments,0),Li(),Pi.prototype.toBase64.call(this)},Fi.prototype.toUint8Array=function(){return ni("Blob.toUint8Array",arguments,0),Di(),Pi.prototype.toUint8Array.call(this)},Fi.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},Fi),Vi=(Object.defineProperty(Bi.prototype,"j",{get:function(){return"(default)"===this.database},enumerable:!1,configurable:!0}),Bi.prototype.isEqual=function(t){return t instanceof Bi&&t.projectId===this.projectId&&t.database===this.database},Bi.prototype.L=function(t){return Ii(this.projectId,t.projectId)||Ii(this.database,t.database)},Bi),_i=(xi.prototype.get=function(t){var e=this.W(t),n=this.K[e];if(void 0!==n)for(var r=0,i=n;r<i.length;r++){var o=i[r],s=o[0],a=o[1];if(this.G(s,t))return a}},xi.prototype.has=function(t){return void 0!==this.get(t)},xi.prototype.set=function(t,e){var n=this.W(t),r=this.K[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(this.G(r[i][0],t))return void(r[i]=[t,e]);r.push([t,e])}else this.K[n]=[[t,e]]},xi.prototype.delete=function(t){var e=this.W(t),n=this.K[e];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(this.G(n[r][0],t))return 1===n.length?delete this.K[e]:n.splice(r,1),!0;return!1},xi.prototype.forEach=function(a){qr(this.K,function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n],o=i[0],s=i[1];a(o,s)}})},xi.prototype.m=function(){return Gr(this.K)},xi),Ui=(Mi.now=function(){return Mi.fromMillis(Date.now())},Mi.fromDate=function(t){return Mi.fromMillis(t.getTime())},Mi.fromMillis=function(t){var e=Math.floor(t/1e3);return new Mi(e,1e6*(t-1e3*e))},Mi.prototype.toDate=function(){return new Date(this.toMillis())},Mi.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},Mi.prototype.H=function(t){return this.seconds===t.seconds?Ii(this.nanoseconds,t.nanoseconds):Ii(this.seconds,t.seconds)},Mi.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},Mi.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},Mi.prototype.toJSON=function(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}},Mi.prototype.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")},Mi),Ci=(ji.Y=function(t){return new ji(t)},ji.min=function(){return new ji(new Ui(0,0))},ji.prototype.L=function(t){return this.timestamp.H(t.timestamp)},ji.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},ji.prototype.J=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},ji.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},ji.prototype.X=function(){return this.timestamp},ji);function ji(t){this.timestamp=t}function Mi(t,e){if(this.seconds=t,(this.nanoseconds=e)<0)throw new Pr(Or.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(1e9<=e)throw new Pr(Or.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new Pr(Or.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(253402300800<=t)throw new Pr(Or.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}function xi(t,e){this.W=t,this.G=e,this.K={}}function Bi(t,e){this.projectId=t,this.database=e||"(default)"}function Fi(){return null!==Pi&&Pi.apply(this,arguments)||this}function qi(t){return null==t}function Gi(t){return 0===t&&1/t==-1/0}var zi=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.Z=null};function Wi(t,e,n,r,i,o,s){return 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),new zi(t,e,n,r,i,o,s)}function Qi(t){var e,n=t;return null===n.Z&&(e=n.path.R(),null!==n.collectionGroup&&(e+="|cg:"+n.collectionGroup),e+="|f:",e+=n.filters.map(function(t){return(e=t).field.R()+e.op.toString()+Ho(e.value);var e}).join(","),e+="|ob:",e+=n.orderBy.map(function(t){return(e=t).field.R()+e.dir;var e}).join(","),qi(n.limit)||(e+="|l:",e+=n.limit),n.startAt&&(e+="|lb:",e+=wu(n.startAt)),n.endAt&&(e+="|ub:",e+=wu(n.endAt)),n.Z=e),n.Z}function Hi(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)||!Go(o.value,s.value))return!1;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!Eu(t.startAt,e.startAt)&&Eu(t.endAt,e.endAt)}function Xi(t){return Kr.N(t.path)&&null===t.collectionGroup&&0===t.filters.length}function Yi(t){this.count=t}var Ki,Ji,Zi=($i.prototype.nt=function(t){return new $i(this.target,this.targetId,this.tt,t,this.et,this.lastLimboFreeSnapshotVersion,this.resumeToken)},$i.prototype.st=function(t,e){return new $i(this.target,this.targetId,this.tt,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)},$i.prototype.it=function(t){return new $i(this.target,this.targetId,this.tt,this.sequenceNumber,this.et,t,this.resumeToken)},$i);function $i(t,e,n,r,i,o,s){void 0===i&&(i=Ci.min()),void 0===o&&(o=Ci.min()),void 0===s&&(s=Ai.q),this.target=t,this.targetId=e,this.tt=n,this.sequenceNumber=r,this.et=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s}function to(t){switch(t){case Or.OK:return xr(),0;case Or.CANCELLED:case Or.UNKNOWN:case Or.DEADLINE_EXCEEDED:case Or.RESOURCE_EXHAUSTED:case Or.INTERNAL:case Or.UNAVAILABLE:case Or.UNAUTHENTICATED:return;case Or.INVALID_ARGUMENT:case Or.NOT_FOUND:case Or.ALREADY_EXISTS:case Or.PERMISSION_DENIED:case Or.FAILED_PRECONDITION:case Or.ABORTED:case Or.OUT_OF_RANGE:case Or.UNIMPLEMENTED:case Or.DATA_LOSS:return 1;default:return xr(),0}}function eo(t){if(void 0===t)return Cr("GRPC error has no .code"),Or.UNKNOWN;switch(t){case Ki.OK:return Or.OK;case Ki.CANCELLED:return Or.CANCELLED;case Ki.UNKNOWN:return Or.UNKNOWN;case Ki.DEADLINE_EXCEEDED:return Or.DEADLINE_EXCEEDED;case Ki.RESOURCE_EXHAUSTED:return Or.RESOURCE_EXHAUSTED;case Ki.INTERNAL:return Or.INTERNAL;case Ki.UNAVAILABLE:return Or.UNAVAILABLE;case Ki.UNAUTHENTICATED:return Or.UNAUTHENTICATED;case Ki.INVALID_ARGUMENT:return Or.INVALID_ARGUMENT;case Ki.NOT_FOUND:return Or.NOT_FOUND;case Ki.ALREADY_EXISTS:return Or.ALREADY_EXISTS;case Ki.PERMISSION_DENIED:return Or.PERMISSION_DENIED;case Ki.FAILED_PRECONDITION:return Or.FAILED_PRECONDITION;case Ki.ABORTED:return Or.ABORTED;case Ki.OUT_OF_RANGE:return Or.OUT_OF_RANGE;case Ki.UNIMPLEMENTED:return Or.UNIMPLEMENTED;case Ki.DATA_LOSS:return Or.DATA_LOSS;default:return xr()}}(Ji=Ki=Ki||{})[Ji.OK=0]="OK",Ji[Ji.CANCELLED=1]="CANCELLED",Ji[Ji.UNKNOWN=2]="UNKNOWN",Ji[Ji.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Ji[Ji.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Ji[Ji.NOT_FOUND=5]="NOT_FOUND",Ji[Ji.ALREADY_EXISTS=6]="ALREADY_EXISTS",Ji[Ji.PERMISSION_DENIED=7]="PERMISSION_DENIED",Ji[Ji.UNAUTHENTICATED=16]="UNAUTHENTICATED",Ji[Ji.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Ji[Ji.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Ji[Ji.ABORTED=10]="ABORTED",Ji[Ji.OUT_OF_RANGE=11]="OUT_OF_RANGE",Ji[Ji.UNIMPLEMENTED=12]="UNIMPLEMENTED",Ji[Ji.INTERNAL=13]="INTERNAL",Ji[Ji.UNAVAILABLE=14]="UNAVAILABLE",Ji[Ji.DATA_LOSS=15]="DATA_LOSS";var no=(ao.prototype.rt=function(t,e){return new ao(this.i,this.root.rt(t,e,this.i).copy(null,null,io.ot,null,null))},ao.prototype.remove=function(t){return new ao(this.i,this.root.remove(t,this.i).copy(null,null,io.ot,null,null))},ao.prototype.get=function(t){for(var e=this.root;!e.m();){var n=this.i(t,e.key);if(0===n)return e.value;n<0?e=e.left:0<n&&(e=e.right)}return null},ao.prototype.indexOf=function(t){for(var e=0,n=this.root;!n.m();){var r=this.i(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},ao.prototype.m=function(){return this.root.m()},Object.defineProperty(ao.prototype,"size",{get:function(){return this.root.size},enumerable:!1,configurable:!0}),ao.prototype.ut=function(){return this.root.ut()},ao.prototype.ct=function(){return this.root.ct()},ao.prototype.at=function(t){return this.root.at(t)},ao.prototype.forEach=function(n){this.at(function(t,e){return n(t,e),!1})},ao.prototype.toString=function(){var n=[];return this.at(function(t,e){return n.push(t+":"+e),!1}),"{"+n.join(", ")+"}"},ao.prototype.ht=function(t){return this.root.ht(t)},ao.prototype.lt=function(){return new ro(this.root,null,this.i,!1)},ao.prototype._t=function(t){return new ro(this.root,t,this.i,!1)},ao.prototype.ft=function(){return new ro(this.root,null,this.i,!0)},ao.prototype.dt=function(t){return new ro(this.root,t,this.i,!0)},ao),ro=(so.prototype.Et=function(){var t=this.Tt.pop(),e={key:t.key,value:t.value};if(this.wt)for(t=t.left;!t.m();)this.Tt.push(t),t=t.right;else for(t=t.right;!t.m();)this.Tt.push(t),t=t.left;return e},so.prototype.It=function(){return 0<this.Tt.length},so.prototype.At=function(){if(0===this.Tt.length)return null;var t=this.Tt[this.Tt.length-1];return{key:t.key,value:t.value}},so),io=(oo.prototype.copy=function(t,e,n,r,i){return new oo(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)},oo.prototype.m=function(){return!1},oo.prototype.at=function(t){return this.left.at(t)||t(this.key,this.value)||this.right.at(t)},oo.prototype.ht=function(t){return this.right.ht(t)||t(this.key,this.value)||this.left.ht(t)},oo.prototype.min=function(){return this.left.m()?this:this.left.min()},oo.prototype.ut=function(){return this.min().key},oo.prototype.ct=function(){return this.right.m()?this.key:this.right.ct()},oo.prototype.rt=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.copy(null,null,null,r.left.rt(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.rt(t,e,n))).Rt()},oo.prototype.yt=function(){if(this.left.m())return oo.EMPTY;var t=this;return t.left.Pt()||t.left.left.Pt()||(t=t.gt()),(t=t.copy(null,null,null,t.left.yt(),null)).Rt()},oo.prototype.remove=function(t,e){var n,r=this;if(e(t,r.key)<0)r.left.m()||r.left.Pt()||r.left.left.Pt()||(r=r.gt()),r=r.copy(null,null,null,r.left.remove(t,e),null);else{if(r.left.Pt()&&(r=r.Vt()),r.right.m()||r.right.Pt()||r.right.left.Pt()||(r=r.vt()),0===e(t,r.key)){if(r.right.m())return oo.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.yt())}r=r.copy(null,null,null,null,r.right.remove(t,e))}return r.Rt()},oo.prototype.Pt=function(){return this.color},oo.prototype.Rt=function(){var t=this;return t.right.Pt()&&!t.left.Pt()&&(t=t.bt()),t.left.Pt()&&t.left.left.Pt()&&(t=t.Vt()),t.left.Pt()&&t.right.Pt()&&(t=t.St()),t},oo.prototype.gt=function(){var t=this.St();return t.right.left.Pt()&&(t=(t=(t=t.copy(null,null,null,null,t.right.Vt())).bt()).St()),t},oo.prototype.vt=function(){var t=this.St();return t.left.left.Pt()&&(t=(t=t.Vt()).St()),t},oo.prototype.bt=function(){var t=this.copy(null,null,oo.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},oo.prototype.Vt=function(){var t=this.copy(null,null,oo.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},oo.prototype.St=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)},oo.prototype.Ct=function(){var t=this.Dt();return Math.pow(2,t)<=this.size+1},oo.prototype.Dt=function(){if(this.Pt()&&this.left.Pt())throw xr();if(this.right.Pt())throw xr();var t=this.left.Dt();if(t!==this.right.Dt())throw xr();return t+(this.Pt()?0:1)},oo);function oo(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:oo.RED,this.left=null!=r?r:oo.EMPTY,this.right=null!=i?i:oo.EMPTY,this.size=this.left.size+1+this.right.size}function so(t,e,n,r){this.wt=r,this.Tt=[];for(var i=1;!t.m();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.wt?t.left:t.right;else{if(0===i){this.Tt.push(t);break}this.Tt.push(t),t=this.wt?t.right:t.left}}function ao(t,e){this.i=t,this.root=e||io.EMPTY}function uo(){this.size=0}io.EMPTY=null,io.RED=!0,io.ot=!1,io.EMPTY=(Object.defineProperty(uo.prototype,"key",{get:function(){throw xr()},enumerable:!1,configurable:!0}),Object.defineProperty(uo.prototype,"value",{get:function(){throw xr()},enumerable:!1,configurable:!0}),Object.defineProperty(uo.prototype,"color",{get:function(){throw xr()},enumerable:!1,configurable:!0}),Object.defineProperty(uo.prototype,"left",{get:function(){throw xr()},enumerable:!1,configurable:!0}),Object.defineProperty(uo.prototype,"right",{get:function(){throw xr()},enumerable:!1,configurable:!0}),uo.prototype.copy=function(t,e,n,r,i){return this},uo.prototype.rt=function(t,e,n){return new io(t,e)},uo.prototype.remove=function(t,e){return this},uo.prototype.m=function(){return!0},uo.prototype.at=function(t){return!1},uo.prototype.ht=function(t){return!1},uo.prototype.ut=function(){return null},uo.prototype.ct=function(){return null},uo.prototype.Pt=function(){return!1},uo.prototype.Ct=function(){return!0},uo.prototype.Dt=function(){return 0},new uo);var ho=(po.prototype.has=function(t){return null!==this.data.get(t)},po.prototype.first=function(){return this.data.ut()},po.prototype.last=function(){return this.data.ct()},Object.defineProperty(po.prototype,"size",{get:function(){return this.data.size},enumerable:!1,configurable:!0}),po.prototype.indexOf=function(t){return this.data.indexOf(t)},po.prototype.forEach=function(n){this.data.at(function(t,e){return n(t),!1})},po.prototype.Ft=function(t,e){for(var n=this.data._t(t[0]);n.It();){var r=n.Et();if(0<=this.i(r.key,t[1]))return;e(r.key)}},po.prototype.Nt=function(t,e){for(var n=void 0!==e?this.data._t(e):this.data.lt();n.It();)if(!t(n.Et().key))return},po.prototype.$t=function(t){var e=this.data._t(t);return e.It()?e.Et().key:null},po.prototype.lt=function(){return new co(this.data.lt())},po.prototype._t=function(t){return new co(this.data._t(t))},po.prototype.add=function(t){return this.copy(this.data.remove(t).rt(t,!0))},po.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},po.prototype.m=function(){return this.data.m()},po.prototype.kt=function(t){var e=this;return e.size<t.size&&(e=t,t=this),t.forEach(function(t){e=e.add(t)}),e},po.prototype.isEqual=function(t){if(!(t instanceof po))return!1;if(this.size!==t.size)return!1;for(var e=this.data.lt(),n=t.data.lt();e.It();){var r=e.Et().key,i=n.Et().key;if(0!==this.i(r,i))return!1}return!0},po.prototype.A=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},po.prototype.toString=function(){var e=[];return this.forEach(function(t){return e.push(t)}),"SortedSet("+e.toString()+")"},po.prototype.copy=function(t){var e=new po(this.i);return e.data=t,e},po),co=(fo.prototype.Et=function(){return this.xt.Et().key},fo.prototype.It=function(){return this.xt.It()},fo),lo=new no(Kr.i);function fo(t){this.xt=t}function po(t){this.i=t,this.data=new no(this.i)}var vo=new no(Kr.i);var yo=new no(Kr.i),go=new ho(Kr.i);function mo(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=go,r=0,i=t;r<i.length;r++)var o=i[r],n=n.add(o);return n}var wo=new ho(Ii);var bo=(Co.Lt=function(t){return new Co(t.i)},Co.prototype.has=function(t){return null!=this.Ot.get(t)},Co.prototype.get=function(t){return this.Ot.get(t)},Co.prototype.first=function(){return this.Mt.ut()},Co.prototype.last=function(){return this.Mt.ct()},Co.prototype.m=function(){return this.Mt.m()},Co.prototype.indexOf=function(t){var e=this.Ot.get(t);return e?this.Mt.indexOf(e):-1},Object.defineProperty(Co.prototype,"size",{get:function(){return this.Mt.size},enumerable:!1,configurable:!0}),Co.prototype.forEach=function(n){this.Mt.at(function(t,e){return n(t),!1})},Co.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.Ot.rt(t.key,t),e.Mt.rt(t,null))},Co.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.Ot.remove(t),this.Mt.remove(e)):this},Co.prototype.isEqual=function(t){if(!(t instanceof Co))return!1;if(this.size!==t.size)return!1;for(var e=this.Mt.lt(),n=t.Mt.lt();e.It();){var r=e.Et().key,i=n.Et().key;if(!r.isEqual(i))return!1}return!0},Co.prototype.toString=function(){var e=[];return this.forEach(function(t){e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n  "+e.join("  \n")+"\n)"},Co.prototype.copy=function(t,e){var n=new Co;return n.i=this.i,n.Ot=t,n.Mt=e,n},Co),Eo=(Uo.prototype.track=function(t){var e=t.doc.key,n=this.qt.get(e);!n||0!==t.type&&3===n.type?this.qt=this.qt.rt(e,t):3===t.type&&1!==n.type?this.qt=this.qt.rt(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.qt=this.qt.rt(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.qt=this.qt.rt(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.qt=this.qt.remove(e):1===t.type&&2===n.type?this.qt=this.qt.rt(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.qt=this.qt.rt(e,{type:2,doc:t.doc}):xr()},Uo.prototype.Ut=function(){var n=[];return this.qt.at(function(t,e){n.push(e)}),n},Uo),Io=(_o.Gt=function(t,e,n,r){var i=[];return e.forEach(function(t){i.push({type:0,doc:t})}),new _o(t,e,bo.Lt(e),i,n,r,!0,!1)},Object.defineProperty(_o.prototype,"hasPendingWrites",{get:function(){return!this.Qt.m()},enumerable:!1,configurable:!0}),_o.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.jt===t.jt&&this.Qt.isEqual(t.Qt)&&qa(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.Bt.isEqual(t.Bt)))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},_o),To=(Vo.Jt=function(t,e){var n=new Map;return n.set(t,Ao.Xt(t,e)),new Vo(Ci.min(),n,wo,lo,mo())},Vo),Ao=(ko.Xt=function(t,e){return new ko(Ai.q,e,mo(),mo(),mo())},ko),No=function(t,e,n,r){this.se=t,this.removedTargetIds=e,this.key=n,this.ie=r},Ro=function(t,e){this.targetId=t,this.re=e},So=function(t,e,n,r){void 0===n&&(n=Ai.q),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},Do=(Object.defineProperty(Po.prototype,"Zt",{get:function(){return this.ae},enumerable:!1,configurable:!0}),Object.defineProperty(Po.prototype,"resumeToken",{get:function(){return this.ce},enumerable:!1,configurable:!0}),Object.defineProperty(Po.prototype,"le",{get:function(){return 0!==this.oe},enumerable:!1,configurable:!0}),Object.defineProperty(Po.prototype,"_e",{get:function(){return this.he},enumerable:!1,configurable:!0}),Po.prototype.fe=function(t){0<t.M()&&(this.he=!0,this.ce=t)},Po.prototype.de=function(){var n=mo(),r=mo(),i=mo();return this.ue.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:xr()}}),new Ao(this.ce,this.ae,n,r,i)},Po.prototype.we=function(){this.he=!1,this.ue=Mo()},Po.prototype.me=function(t,e){this.he=!0,this.ue=this.ue.rt(t,e)},Po.prototype.Te=function(t){this.he=!0,this.ue=this.ue.remove(t)},Po.prototype.Ee=function(){this.oe+=1},Po.prototype.Ie=function(){--this.oe},Po.prototype.Ae=function(){this.he=!0,this.ae=!0},Po),Lo=(Oo.prototype.Ve=function(t){for(var e=0,n=t.se;e<n.length;e++){var r=n[e];t.ie instanceof Aa?this.ve(r,t.ie):t.ie instanceof Na&&this.be(r,t.key,t.ie)}for(var i=0,o=t.removedTargetIds;i<o.length;i++){var s=o[i];this.be(s,t.key,t.ie)}},Oo.prototype.Se=function(n){var r=this;this.Ce(n,function(t){var e=r.De(t);switch(n.state){case 0:r.Fe(t)&&e.fe(n.resumeToken);break;case 1:e.Ie(),e.le||e.we(),e.fe(n.resumeToken);break;case 2:e.Ie(),e.le||r.removeTarget(t);break;case 3:r.Fe(t)&&(e.Ae(),e.fe(n.resumeToken));break;case 4:r.Fe(t)&&(r.Ne(t),e.fe(n.resumeToken));break;default:xr()}})},Oo.prototype.Ce=function(t,n){var r=this;0<t.targetIds.length?t.targetIds.forEach(n):this.ye.forEach(function(t,e){r.Fe(e)&&n(e)})},Oo.prototype.$e=function(t){var e,n,r=t.targetId,i=t.re.count,o=this.ke(r);o&&(Xi(e=o.target)?0===i?(n=new Kr(e.path),this.be(r,n,new Na(n,Ci.min()))):Br(1===i):this.xe(r)!==i&&(this.Ne(r),this.ge=this.ge.add(r)))},Oo.prototype.Oe=function(i){var o=this,s=new Map;this.ye.forEach(function(t,e){var n,r=o.ke(e);r&&(t.Zt&&Xi(r.target)&&(n=new Kr(r.target.path),null!==o.Pe.get(n)||o.Me(e,n)||o.be(e,n,new Na(n,i))),t._e&&(s.set(e,t.de()),t.we()))});var r=mo();this.pe.forEach(function(t,e){var n=!0;e.Nt(function(t){var e=o.ke(t);return!e||2===e.tt||(n=!1)}),n&&(r=r.add(t))});var t=new To(i,s,this.ge,this.Pe,r);return this.Pe=lo,this.pe=jo(),this.ge=new ho(Ii),t},Oo.prototype.ve=function(t,e){var n;this.Fe(t)&&(n=this.Me(t,e.key)?2:0,this.De(t).me(e.key,n),this.Pe=this.Pe.rt(e.key,e),this.pe=this.pe.rt(e.key,this.Le(e.key).add(t)))},Oo.prototype.be=function(t,e,n){var r;this.Fe(t)&&(r=this.De(t),this.Me(t,e)?r.me(e,1):r.Te(e),this.pe=this.pe.rt(e,this.Le(e).delete(t)),n&&(this.Pe=this.Pe.rt(e,n)))},Oo.prototype.removeTarget=function(t){this.ye.delete(t)},Oo.prototype.xe=function(t){var e=this.De(t).de();return this.Re.qe(t).size+e.te.size-e.ne.size},Oo.prototype.Ee=function(t){this.De(t).Ee()},Oo.prototype.De=function(t){var e=this.ye.get(t);return e||(e=new Do,this.ye.set(t,e)),e},Oo.prototype.Le=function(t){var e=this.pe.get(t);return e||(e=new ho(Ii),this.pe=this.pe.rt(t,e)),e},Oo.prototype.Fe=function(t){var e=null!==this.ke(t);return e||Ur("WatchChangeAggregator","Detected inactive target",t),e},Oo.prototype.ke=function(t){var e=this.ye.get(t);return e&&e.le?null:this.Re.Ue(t)},Oo.prototype.Ne=function(e){var n=this;this.ye.set(e,new Do),this.Re.qe(e).forEach(function(t){n.be(e,t,null)})},Oo.prototype.Me=function(t,e){return this.Re.qe(t).has(e)},Oo);function Oo(t){this.Re=t,this.ye=new Map,this.Pe=lo,this.pe=jo(),this.ge=new ho(Ii)}function Po(){this.oe=0,this.ue=Mo(),this.ce=Ai.q,this.ae=!1,this.he=!0}function ko(t,e,n,r,i){this.resumeToken=t,this.Zt=e,this.te=n,this.ee=r,this.ne=i}function Vo(t,e,n,r,i){this.et=t,this.zt=e,this.Kt=n,this.Ht=r,this.Yt=i}function _o(t,e,n,r,i,o,s,a){this.query=t,this.docs=e,this.Bt=n,this.docChanges=r,this.Qt=i,this.fromCache=o,this.jt=s,this.Wt=a}function Uo(){this.qt=new no(Kr.i)}function Co(n){this.i=n?function(t,e){return n(t,e)||Kr.i(t.key,e.key)}:function(t,e){return Kr.i(t.key,e.key)},this.Ot=vo,this.Mt=new no(this.i)}function jo(){return new no(Kr.i)}function Mo(){return new no(Kr.i)}function xo(t){var e,n;return"server_timestamp"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function Bo(t){var e=Xo(t.mapValue.fields.__local_write_time__.timestampValue);return new Ui(e.seconds,e.nanos)}var Fo=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function qo(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?xo(t)?4:10:xr()}function Go(r,i){var t,e,n,o=qo(r);if(o!==qo(i))return!1;switch(o){case 0:return!0;case 1:return r.booleanValue===i.booleanValue;case 4:return Bo(r).isEqual(Bo(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=Xo(r.timestampValue),n=Xo(t.timestampValue);return e.seconds===n.seconds&&e.nanos===n.nanos}(i);case 5:return r.stringValue===i.stringValue;case 6:return n=i,Ko(r.bytesValue).isEqual(Ko(n.bytesValue));case 7:return r.referenceValue===i.referenceValue;case 8:return e=i,Yo((t=r).geoPointValue.latitude)===Yo(e.geoPointValue.latitude)&&Yo(t.geoPointValue.longitude)===Yo(e.geoPointValue.longitude);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return Yo(t.integerValue)===Yo(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){var n=Yo(t.doubleValue),r=Yo(e.doubleValue);return n===r?Gi(n)===Gi(r):isNaN(n)&&isNaN(r)}return!1}(r,i);case 9:return Ti(r.arrayValue.values||[],i.arrayValue.values||[],Go);case 10:return function(){var t,e=r.mapValue.fields||{},n=i.mapValue.fields||{};if(Fr(e)!==Fr(n))return!1;for(t in e)if(e.hasOwnProperty(t)&&(void 0===n[t]||!Go(e[t],n[t])))return!1;return!0}();default:return xr()}}function zo(t,e){return void 0!==(t.values||[]).find(function(t){return Go(t,e)})}function Wo(t,e){var n,r,i,o,s,a,u,h,c,l,f=qo(t),p=qo(e);if(f!==p)return Ii(f,p);switch(f){case 0:return 0;case 1:return Ii(t.booleanValue,e.booleanValue);case 2:return h=e,c=Yo(t.integerValue||t.doubleValue),l=Yo(h.integerValue||h.doubleValue),c<l?-1:l<c?1:c===l?0:isNaN(c)?isNaN(l)?0:-1:1;case 3:return Qo(t.timestampValue,e.timestampValue);case 4:return Qo(Bo(t),Bo(e));case 5:return Ii(t.stringValue,e.stringValue);case 6:return o=t.bytesValue,s=e.bytesValue,a=Ko(o),u=Ko(s),a.L(u);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=Ii(n[i],r[i]);if(0!==o)return o}return Ii(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return n=t.geoPointValue,r=e.geoPointValue,0!==(i=Ii(Yo(n.latitude),Yo(r.latitude)))?i:Ii(Yo(n.longitude),Yo(r.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=Wo(n[i],r[i]);if(o)return o}return Ii(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=Ii(r[s],o[s]);if(0!==a)return a;var u=Wo(n[r[s]],i[o[s]]);if(0!==u)return u}return Ii(r.length,o.length)}(t.mapValue,e.mapValue);default:throw xr()}}function Qo(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return Ii(t,e);var n=Xo(t),r=Xo(e),i=Ii(n.seconds,r.seconds);return 0!==i?i:Ii(n.nanos,r.nanos)}function Ho(t){return function s(i){return"nullValue"in i?"null":"booleanValue"in i?""+i.booleanValue:"integerValue"in i?""+i.integerValue:"doubleValue"in i?""+i.doubleValue:"timestampValue"in i?"time("+(t=Xo(i.timestampValue)).seconds+","+t.nanos+")":"stringValue"in i?i.stringValue:"bytesValue"in i?Ko(i.bytesValue).toBase64():"referenceValue"in i?(n=i.referenceValue,Kr.D(n).toString()):"geoPointValue"in i?"geo("+(e=i.geoPointValue).latitude+","+e.longitude+")":"arrayValue"in i?function(){for(var t="[",e=!0,n=0,r=i.arrayValue.values||[];n<r.length;n++){e?e=!1:t+=",",t+=s(r[n])}return t+"]"}():"mapValue"in i?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+"}"}(i.mapValue):xr();var t,e,n}(t)}function Xo(t){if(Br(!!t),"string"!=typeof t)return{seconds:Yo(t.seconds),nanos:Yo(t.nanos)};var e,n=0,r=Fo.exec(t);Br(!!r),r[1]&&(e=((e=r[1])+"000000000").substr(0,9),n=Number(e));var i=new Date(t);return{seconds:Math.floor(i.getTime()/1e3),nanos:n}}function Yo(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function Ko(t){return"string"==typeof t?Ai.fromBase64String(t):Ai.fromUint8Array(t)}function Jo(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.R()}}function Zo(t){return t&&"integerValue"in t}function $o(t){return!!t&&"arrayValue"in t}function ts(t){return t&&"nullValue"in t}function es(t){return t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function ns(t){return t&&"mapValue"in t}var rs={asc:"ASCENDING",desc:"DESCENDING"},is={"<":"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"},os=function(t,e){this.B=t,this.Be=e};function ss(t){return{integerValue:""+t}}function as(t,e){if(t.Be){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Gi(e)?"-0":e}}function us(t,e){return"number"==typeof(n=e)&&Number.isInteger(n)&&!Gi(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER?ss(e):as(t,e);var n}function hs(t,e){return t.Be?new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+e.nanoseconds).slice(-9)+"Z":{seconds:""+e.seconds,nanos:e.nanoseconds}}function cs(t,e){return t.Be?e.toBase64():e.toUint8Array()}function ls(t){return Br(!!t),Ci.Y((e=Xo(t),new Ui(e.seconds,e.nanos)));var e}function fs(t,e){return new Hr(["projects",t.projectId,"databases",t.database]).child("documents").child(e).R()}function ps(t,e){return fs(t.B,e.path)}function ds(t,e){var n,r,i=(Br(Is(r=Hr.P(e))),r);return Br(i.get(1)===t.B.projectId),Br(!i.get(3)&&!t.B.database||i.get(3)===t.B.database),new Kr((Br(4<(n=i).length&&"documents"===n.get(4)),n.u(5)))}function vs(t,e){return fs(t.B,e)}function ys(t){return new Hr(["projects",t.B.projectId,"databases",t.B.database]).R()}function gs(t,e,n){return{name:ps(t,e),fields:n.proto.mapValue.fields}}function ms(t,e){var n,r,i,o,s,a;if(e instanceof ea)n={update:gs(t,e.key,e.value)};else if(e instanceof fa)n={delete:ps(t,e.key)};else if(e instanceof na)n={update:gs(t,e.key,e.data),updateMask:(r=e.Qe,i=[],r.fields.forEach(function(t){return i.push(t.R())}),{fieldPaths:i})};else if(e instanceof aa)n={transform:{document:ps(t,e.key),fieldTransforms:e.fieldTransforms.map(function(t){var e=t.transform;if(e instanceof Ss)return{fieldPath:t.field.R(),setToServerValue:"REQUEST_TIME"};if(e instanceof Ds)return{fieldPath:t.field.R(),appendMissingElements:{values:e.elements}};if(e instanceof Vs)return{fieldPath:t.field.R(),removeAllFromArray:{values:e.elements}};if(e instanceof js)return{fieldPath:t.field.R(),increment:e.je};throw xr()})}};else{if(!(e instanceof pa))return xr();n={verify:ps(t,e.key)}}return e.Ge.We||(n.currentDocument=void 0!==(o=e.Ge).updateTime?{updateTime:(s=t,a=o.updateTime,hs(s,a.X()))}:void 0!==o.exists?{exists:o.exists}:xr()),n}function ws(t,e){var n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=vs(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=vs(t,r.h()),n.structuredQuery.from=[{collectionId:r._()}]);var i=function(t){if(0!==t.length){var e=t.map(function(t){if("=="===t.op){if(es(t.value))return{unaryFilter:{field:Es(t.field),op:"IS_NAN"}};if(ts(t.value))return{unaryFilter:{field:Es(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(es(t.value))return{unaryFilter:{field:Es(t.field),op:"IS_NOT_NAN"}};if(ts(t.value))return{unaryFilter:{field:Es(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Es(t.field),op:(e=t.op,is[e]),value:t.value}};var e});return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}}(e.filters);i&&(n.structuredQuery.where=i);var o=function(t){if(0!==t.length)return t.map(function(t){return{field:Es((e=t).field),direction:(n=e.dir,rs[n])};var e,n})}(e.orderBy);o&&(n.structuredQuery.orderBy=o);var s,a=(s=e.limit,t.Be||qi(s)?s:{value:s});return null!==a&&(n.structuredQuery.limit=a),e.startAt&&(n.structuredQuery.startAt=bs(e.startAt)),e.endAt&&(n.structuredQuery.endAt=bs(e.endAt)),n}function bs(t){return{before:t.before,values:t.position}}function Es(t){return{fieldPath:t.R()}}function Is(t){return 4<=t.length&&"projects"===t.get(0)&&"databases"===t.get(2)}function Ts(){this.ze=void 0}function As(t,e){return t instanceof js?Zo(n=e)||n&&"doubleValue"in n?e:{integerValue:0}:null;var n}var Ns,Rs,Ss=(o(Os,Rs=Ts),Os),Ds=(o(Ls,Ns=Ts),Ls);function Ls(t){var e=this;return(e=Ns.call(this)||this).elements=t,e}function Os(){return null!==Rs&&Rs.apply(this,arguments)||this}function Ps(t,e){for(var n=Bs(e),r=0,i=t.elements;r<i.length;r++)!function(e){n.some(function(t){return Go(t,e)})||n.push(e)}(i[r]);return{arrayValue:{values:n}}}var ks,Vs=(o(_s,ks=Ts),_s);function _s(t){var e=this;return(e=ks.call(this)||this).elements=t,e}function Us(t,e){for(var n=Bs(e),r=0,i=t.elements;r<i.length;r++)!function(e){n=n.filter(function(t){return!Go(t,e)})}(i[r]);return{arrayValue:{values:n}}}var Cs,js=(o(Ms,Cs=Ts),Ms);function Ms(t,e){var n=this;return(n=Cs.call(this)||this).serializer=t,n.je=e,n}function xs(t){return Yo(t.integerValue||t.doubleValue)}function Bs(t){return $o(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}function Fs(t,e){this.field=t,this.transform=e}var qs=(Gs.prototype.Ke=function(t){for(var e=0,n=this.fields;e<n.length;e++)if(n[e].T(t))return!0;return!1},Gs.prototype.isEqual=function(t){return Ti(this.fields,t.fields,function(t,e){return t.isEqual(e)})},Gs);function Gs(t){(this.fields=t).sort(Yr.i)}function zs(t,e){this.version=t,this.transformResults=e}var Ws=(Qs.He=function(){return new Qs},Qs.exists=function(t){return new Qs(void 0,t)},Qs.updateTime=function(t){return new Qs(t)},Object.defineProperty(Qs.prototype,"We",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!1,configurable:!0}),Qs.prototype.isEqual=function(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)},Qs);function Qs(t,e){this.updateTime=t,this.exists=e}function Hs(t,e){return void 0!==t.updateTime?e instanceof Aa&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e instanceof Aa}function Xs(){}function Ys(t,e,n){return t instanceof ea?new Aa(t.key,n.version,t.value,{hasCommittedMutations:!0}):t instanceof na?function(t,e,n){if(!Hs(t.Ge,e))return new Ra(t.key,n.version);var r=oa(t,e);return new Aa(t.key,n.version,r,{hasCommittedMutations:!0})}(t,e,n):t instanceof aa?function(t,e,n){if(Br(null!=n.transformResults),!Hs(t.Ge,e))return new Ra(t.key,n.version);var r=e,i=function(t,e,n){var r=[];Br(t.length===n.length);for(var i,o,s,a=0;a<n.length;a++){var u=t[a],h=u.transform,c=null;e instanceof Aa&&(c=e.field(u.field)),r.push((i=h,o=c,s=n[a],i instanceof Ds?Ps(i,o):i instanceof Vs?Us(i,o):s))}return r}(t.fieldTransforms,e,n.transformResults),o=n.version,s=ha(t,r.data(),i);return new Aa(t.key,o,s,{hasCommittedMutations:!0})}(t,e,n):new Na(t.key,n.version,{hasCommittedMutations:!0})}function Ks(t,e,n,r){return t instanceof ea?function(t,e){if(!Hs(t.Ge,e))return e;var n=Zs(e);return new Aa(t.key,n,t.value,{Ye:!0})}(t,e):t instanceof na?function(t,e){if(!Hs(t.Ge,e))return e;var n=Zs(e),r=oa(t,e);return new Aa(t.key,n,r,{Ye:!0})}(t,e):t instanceof aa?function(t,e,n,r){if(!Hs(t.Ge,e))return e;var i=e,o=function(t,e,n,r){for(var i,o,s,a,u,h,c,l=[],f=0,p=t;f<p.length;f++){var d=p[f],v=d.transform,y=null;n instanceof Aa&&(y=n.field(d.field)),null===y&&r instanceof Aa&&(y=r.field(d.field)),l.push((o=y,s=e,c=h=u=a=void 0,(i=v)instanceof Ss?(c={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}},o&&(c.fields.__previous_value__=o),{mapValue:c}):i instanceof Ds?Ps(i,o):i instanceof Vs?Us(i,o):(u=As(a=i,o),h=xs(u)+xs(a.je),Zo(u)&&Zo(a.je)?ss(h):as(a.serializer,h))))}return l}(t.fieldTransforms,n,e,r),s=ha(t,i.data(),o);return new Aa(t.key,i.version,s,{Ye:!0})}(t,e,r,n):(o=e,Hs((i=t).Ge,o)?new Na(i.key,Ci.min()):o);var i,o}function Js(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.Ge.isEqual(e.Ge)&&(0===t.type?t.value.isEqual(e.value):1===t.type?t.data.isEqual(e.data)&&t.Qe.isEqual(e.Qe):2!==t.type||Ti(t.fieldTransforms,t.fieldTransforms,function(t,e){return r=e,(n=t).field.isEqual(r.field)&&(i=n.transform,o=r.transform,i instanceof Ds&&o instanceof Ds||i instanceof Vs&&o instanceof Vs?Ti(i.elements,o.elements,Go):i instanceof js&&o instanceof js?Go(i.je,o.je):i instanceof Ss&&o instanceof Ss);var n,r,i,o}))}function Zs(t){return t instanceof Aa?t.version:Ci.min()}var $s,ta,ea=(o(ia,ta=Xs),ia),na=(o(ra,$s=Xs),ra);function ra(t,e,n,r){var i=this;return(i=$s.call(this)||this).key=t,i.data=e,i.Qe=n,i.Ge=r,i.type=1,i}function ia(t,e,n){var r=this;return(r=ta.call(this)||this).key=t,r.value=e,r.Ge=n,r.type=0,r}function oa(t,e){return n=t,r=e instanceof Aa?e.data():da.empty(),i=new va(r),n.Qe.fields.forEach(function(t){var e;t.m()||(null!==(e=n.data.field(t))?i.set(t,e):i.delete(t))}),i.Je();var n,r,i}var sa,aa=(o(ua,sa=Xs),ua);function ua(t,e){var n=this;return(n=sa.call(this)||this).key=t,n.fieldTransforms=e,n.type=2,n.Ge=Ws.exists(!0),n}function ha(t,e,n){for(var r=new va(e),i=0;i<t.fieldTransforms.length;i++){var o=t.fieldTransforms[i];r.set(o.field,n[i])}return r.Je()}var ca,la,fa=(o(wa,la=Xs),wa),pa=(o(ma,ca=Xs),ma),da=(ga.empty=function(){return new ga({mapValue:{}})},ga.prototype.field=function(t){if(t.m())return this.proto;for(var e=this.proto,n=0;n<t.length-1;++n){if(!e.mapValue.fields)return null;if(!ns(e=e.mapValue.fields[t.get(n)]))return null}return(e=(e.mapValue.fields||{})[t._()])||null},ga.prototype.isEqual=function(t){return Go(this.proto,t.proto)},ga),va=(ya.prototype.set=function(t,e){return this.tn(t,e),this},ya.prototype.delete=function(t){return this.tn(t,null),this},ya.prototype.tn=function(t,e){for(var n=this.Ze,r=0;r<t.length-1;++r)var i=t.get(r),o=n.get(i),n=(o instanceof Map||(o=o&&10===qo(o)?new Map(Object.entries(o.mapValue.fields||{})):new Map,n.set(i,o)),o);n.set(t._(),e)},ya.prototype.Je=function(){var t=this.en(Yr.p(),this.Ze);return null!=t?new da(t):this.Xe},ya.prototype.en=function(r,t){var i=this,o=!1,e=this.Xe.field(r),s=ns(e)?Object.assign({},e.mapValue.fields):{};return t.forEach(function(t,e){var n;t instanceof Map?null!=(n=i.en(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},ya);function ya(t){void 0===t&&(t=da.empty()),this.Xe=t,this.Ze=new Map}function ga(t){this.proto=t}function ma(t,e){var n=this;return(n=ca.call(this)||this).key=t,n.Ge=e,n.type=4,n}function wa(t,e){var n=this;return(n=la.call(this)||this).key=t,n.Ge=e,n.type=3,n}function ba(t,e){this.key=t,this.version=e}var Ea,Ia,Ta,Aa=(o(Oa,Ta=ba),Oa.prototype.field=function(t){return this.nn.field(t)},Oa.prototype.data=function(){return this.nn},Oa.prototype.sn=function(){return this.nn.proto},Oa.prototype.isEqual=function(t){return t instanceof Oa&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.Ye===t.Ye&&this.hasCommittedMutations===t.hasCommittedMutations&&this.nn.isEqual(t.nn)},Oa.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.nn.toString()+", {hasLocalMutations: "+this.Ye+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(Oa.prototype,"hasPendingWrites",{get:function(){return this.Ye||this.hasCommittedMutations},enumerable:!1,configurable:!0}),Oa),Na=(o(La,Ia=ba),La.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(La.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!1,configurable:!0}),La.prototype.isEqual=function(t){return t instanceof La&&t.hasCommittedMutations===this.hasCommittedMutations&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},La),Ra=(o(Da,Ea=ba),Da.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(Da.prototype,"hasPendingWrites",{get:function(){return!0},enumerable:!1,configurable:!0}),Da.prototype.isEqual=function(t){return t instanceof Da&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},Da),Sa=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.rn=n,this.filters=r,this.limit=i,this.on=o,this.startAt=s,this.endAt=a,this.un=null,this.cn=null,this.startAt,this.endAt};function Da(){return null!==Ea&&Ea.apply(this,arguments)||this}function La(t,e,n){var r=this;return(r=Ia.call(this,t,e)||this).hasCommittedMutations=!(!n||!n.hasCommittedMutations),r}function Oa(t,e,n,r){var i=this;return(i=Ta.call(this,t,e)||this).nn=n,i.Ye=!!r.Ye,i.hasCommittedMutations=!!r.hasCommittedMutations,i}function Pa(t){return new Sa(t)}function ka(t){return!qi(t.limit)&&"F"===t.on}function Va(t){return!qi(t.limit)&&"L"===t.on}function _a(t){return 0<t.rn.length?t.rn[0].field:null}function Ua(t){for(var e=0,n=t.filters;e<n.length;e++){var r=n[e];if(r.an())return r.field}return null}function Ca(t){return null!==t.collectionGroup}function ja(t){var e=t;if(null===e.un){e.un=[];var n=Ua(e),r=_a(e);if(null!==n&&null===r)n.V()||e.un.push(new Iu(n)),e.un.push(new Iu(Yr.v(),"asc"));else{for(var i,o=!1,s=0,a=e.rn;s<a.length;s++){var u=a[s];e.un.push(u),u.field.V()&&(o=!0)}o||(i=0<e.rn.length?e.rn[e.rn.length-1].dir:"asc",e.un.push(new Iu(Yr.v(),i)))}}return e.un}function Ma(t){var e=t;if(!e.cn)if("F"===e.on)e.cn=Wi(e.path,e.collectionGroup,ja(e),e.filters,e.limit,e.startAt,e.endAt);else{for(var n=[],r=0,i=ja(e);r<i.length;r++){var o=i[r],s="desc"===o.dir?"asc":"desc";n.push(new Iu(o.field,s))}var a=e.endAt?new du(e.endAt.position,!e.endAt.before):null,u=e.startAt?new du(e.startAt.position,!e.startAt.before):null;e.cn=Wi(e.path,e.collectionGroup,n,e.filters,e.limit,a,u)}return e.cn}function xa(t,e,n){return new Sa(t.path,t.collectionGroup,t.rn.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Ba(t,e){return new Sa(t.path,t.collectionGroup,t.rn.slice(),t.filters.slice(),t.limit,t.on,e,t.endAt)}function Fa(t,e){return new Sa(t.path,t.collectionGroup,t.rn.slice(),t.filters.slice(),t.limit,t.on,t.startAt,e)}function qa(t,e){return Hi(Ma(t),Ma(e))&&t.on===e.on}function Ga(t){return Qi(Ma(t))+"|lt:"+t.on}function za(t){return"Query(target="+(e=Ma(t),n=e.path.R(),null!==e.collectionGroup&&(n+=" collectionGroup="+e.collectionGroup),0<e.filters.length&&(n+=", filters: ["+e.filters.map(function(t){return(e=t).field.R()+" "+e.op+" "+Ho(e.value);var e}).join(", ")+"]"),qi(e.limit)||(n+=", limit: "+e.limit),0<e.orderBy.length&&(n+=", orderBy: ["+e.orderBy.map(function(t){return(e=t).field.R()+" ("+e.dir+")";var e}).join(", ")+"]"),e.startAt&&(n+=", startAt: "+wu(e.startAt)),e.endAt&&(n+=", endAt: "+wu(e.endAt)),"Target("+n+")")+"; limitType="+t.on+")";var e,n}function Wa(i,t){return r=i,o=t.key.path,(null!==r.collectionGroup?t.key.F(r.collectionGroup)&&r.path.T(o):Kr.N(r.path)?r.path.isEqual(o):r.path.I(o))&&function(t){for(var e=0,n=i.rn;e<n.length;e++){var r=n[e];if(!r.field.V()&&null===t.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,(!(e=i).startAt||bu(e.startAt,ja(e),n))&&(!e.endAt||!bu(e.endAt,ja(e),n)));var e,n,r,o}function Qa(a){return function(t,e){for(var n=!1,r=0,i=ja(a);r<i.length;r++){var o=i[r],s=function(t,i,e){var n=t.field.V()?Kr.i(i.key,e.key):function(t,e){var n=i.field(t),r=e.field(t);return null!==n&&null!==r?Wo(n,r):xr()}(t.field,e);switch(t.dir){case"asc":return n;case"desc":return-1*n;default:return xr()}}(o,t,e);if(0!==s)return s;n=n||o.field.V()}return 0}}var Ha,Xa=(o(Ya,Ha=function(){}),Ya.create=function(t,e,n){if(t.V())return"in"===e||"not-in"===e?this.hn(t,e,n):new $a(t,e,n);if(ts(n)){if("=="!==e&&"!="!==e)throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. Null only supports '==' and '!=' comparisons.");return new Ya(t,e,n)}if(es(n)){if("=="!==e&&"!="!==e)throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. NaN only supports '==' and '!=' comparisons.");return new Ya(t,e,n)}return"array-contains"===e?new cu(t,n):"in"===e?new lu(t,n):"not-in"===e?new fu(t,n):"array-contains-any"===e?new pu(t,n):new Ya(t,e,n)},Ya.hn=function(t,e,n){return new("in"===e?tu:eu)(t,n)},Ya.prototype.matches=function(t){var e=t.field(this.field);return"!="===this.op?null!==e&&this.ln(Wo(e,this.value)):null!==e&&qo(this.value)===qo(e)&&this.ln(Wo(e,this.value))},Ya.prototype.ln=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 xr()}},Ya.prototype.an=function(){return 0<=["<","<=",">",">=","!=","not-in"].indexOf(this.op)},Ya);function Ya(t,e,n){var r=this;return(r=Ha.call(this)||this).field=t,r.op=e,r.value=n,r}var Ka,Ja,Za,$a=(o(iu,Za=Xa),iu.prototype.matches=function(t){var e=Kr.i(t.key,this.key);return this.ln(e)},iu),tu=(o(ru,Ja=Xa),ru.prototype.matches=function(e){return this.keys.some(function(t){return t.isEqual(e.key)})},ru),eu=(o(nu,Ka=Xa),nu.prototype.matches=function(e){return!this.keys.some(function(t){return t.isEqual(e.key)})},nu);function nu(t,e){var n=this;return(n=Ka.call(this,t,"not-in",e)||this).keys=ou(0,e),n}function ru(t,e){var n=this;return(n=Ja.call(this,t,"in",e)||this).keys=ou(0,e),n}function iu(t,e,n){var r=this;return(r=Za.call(this,t,e,n)||this).key=Kr.D(n.referenceValue),r}function ou(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map(function(t){return Kr.D(t.referenceValue)})}var su,au,uu,hu,cu=(o(mu,hu=Xa),mu.prototype.matches=function(t){var e=t.field(this.field);return $o(e)&&zo(e.arrayValue,this.value)},mu),lu=(o(gu,uu=Xa),gu.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&zo(this.value.arrayValue,e)},gu),fu=(o(yu,au=Xa),yu.prototype.matches=function(t){if(zo(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var e=t.field(this.field);return null!==e&&!zo(this.value.arrayValue,e)},yu),pu=(o(vu,su=Xa),vu.prototype.matches=function(t){var e=this,n=t.field(this.field);return!(!$o(n)||!n.arrayValue.values)&&n.arrayValue.values.some(function(t){return zo(e.value.arrayValue,t)})},vu),du=function(t,e){this.position=t,this.before=e};function vu(t,e){return su.call(this,t,"array-contains-any",e)||this}function yu(t,e){return au.call(this,t,"not-in",e)||this}function gu(t,e){return uu.call(this,t,"in",e)||this}function mu(t,e){return hu.call(this,t,"array-contains",e)||this}function wu(t){return(t.before?"b":"a")+":"+t.position.map(Ho).join(",")}function bu(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.V()?Kr.i(Kr.D(s.referenceValue),n.key):Wo(s,n.field(o.field));if("desc"===o.dir&&(r*=-1),0!==r)break}return t.before?r<=0:r<0}function Eu(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(!Go(t.position[n],e.position[n]))return!1;return!0}var Iu=function(t,e){void 0===e&&(e="asc"),this.field=t,this.dir=e};function Tu(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})}var Au=(Su.prototype.reset=function(){this.Tn=0},Su.prototype.An=function(){this.Tn=this.mn},Su.prototype.Rn=function(t){var e=this;this.cancel();var n=Math.floor(this.Tn+this.yn()),r=Math.max(0,Date.now()-this.In),i=Math.max(0,n-r);0<i&&Ur("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.Tn+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.En=this._n.Pn(this.fn,i,function(){return e.In=Date.now(),t()}),this.Tn*=this.wn,this.Tn<this.dn&&(this.Tn=this.dn),this.Tn>this.mn&&(this.Tn=this.mn)},Su.prototype.pn=function(){null!==this.En&&(this.En.gn(),this.En=null)},Su.prototype.cancel=function(){null!==this.En&&(this.En.cancel(),this.En=null)},Su.prototype.yn=function(){return(Math.random()-.5)*this.Tn},Su),Nu=(Ru.prototype.catch=function(t){return this.next(void 0,t)},Ru.prototype.next=function(r,i){var o=this;return this.Sn&&xr(),this.Sn=!0,this.bn?this.error?this.Cn(i,this.error):this.Dn(r,this.result):new Ru(function(e,n){o.Vn=function(t){o.Dn(r,t).next(e,n)},o.vn=function(t){o.Cn(i,t).next(e,n)}})},Ru.prototype.Fn=function(){var n=this;return new Promise(function(t,e){n.next(t,e)})},Ru.prototype.Nn=function(t){try{var e=t();return e instanceof Ru?e:Ru.resolve(e)}catch(t){return Ru.reject(t)}},Ru.prototype.Dn=function(t,e){return t?this.Nn(function(){return t(e)}):Ru.resolve(e)},Ru.prototype.Cn=function(t,e){return t?this.Nn(function(){return t(e)}):Ru.reject(e)},Ru.resolve=function(n){return new Ru(function(t,e){t(n)})},Ru.reject=function(n){return new Ru(function(t,e){e(n)})},Ru.$n=function(t){return new Ru(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()})},Ru.kn=function(t){for(var n=Ru.resolve(!1),e=0,r=t;e<r.length;e++)!function(e){n=n.next(function(t){return t?Ru.resolve(t):e()})}(r[e]);return n},Ru.forEach=function(t,n){var r=this,i=[];return t.forEach(function(t,e){i.push(n.call(r,t,e))}),this.$n(i)},Ru);function Ru(t){var e=this;this.Vn=null,this.vn=null,this.result=void 0,this.error=void 0,this.bn=!1,this.Sn=!1,t(function(t){e.bn=!0,e.result=t,e.Vn&&e.Vn(t)},function(t){e.bn=!0,e.error=t,e.vn&&e.vn(t)})}function Su(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this._n=t,this.fn=e,this.dn=n,this.wn=r,this.mn=i,this.Tn=0,this.En=null,this.In=Date.now(),this.reset()}function Du(t){return"IndexedDbTransactionError"===t.name}function Lu(){return"undefined"!=typeof document?document:null}var Ou=(Vu.qn=function(t,e,n,r,i){var o=new Vu(t,e,Date.now()+n,r,i);return o.start(n),o},Vu.prototype.start=function(t){var e=this;this.Un=setTimeout(function(){return e.Bn()},t)},Vu.prototype.gn=function(){return this.Bn()},Vu.prototype.cancel=function(t){null!==this.Un&&(this.clearTimeout(),this.Ln.reject(new Pr(Or.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},Vu.prototype.Bn=function(){var e=this;this.xn.Qn(function(){return null!==e.Un?(e.clearTimeout(),e.op().then(function(t){return e.Ln.resolve(t)})):Promise.resolve()})},Vu.prototype.clearTimeout=function(){null!==this.Un&&(this.Mn(this),clearTimeout(this.Un),this.Un=null)},Vu),Pu=(Object.defineProperty(ku.prototype,"Zn",{get:function(){return this.Gn},enumerable:!1,configurable:!0}),ku.prototype.Qn=function(t){this.enqueue(t)},ku.prototype.ts=function(t){this.es(),this.ns(t)},ku.prototype.ss=function(){var t;this.Gn||(this.Gn=!0,(t=Lu())&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Xn))},ku.prototype.enqueue=function(t){return this.es(),this.Gn?new Promise(function(t){}):this.ns(t)},ku.prototype.rs=function(t){var e=this;this.Wn.push(t),this.Qn(function(){return e.os()})},ku.prototype.os=function(){return w(this,void 0,void 0,function(){var e,n=this;return b(this,function(t){switch(t.label){case 0:if(0===this.Wn.length)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.Wn[0]()];case 2:return t.sent(),this.Wn.shift(),this.Jn.reset(),[3,4];case 3:if(!Du(e=t.sent()))throw e;return Ur("AsyncQueue","Operation failed with retryable error: "+e),[3,4];case 4:0<this.Wn.length&&this.Jn.Rn(function(){return n.os()}),t.label=5;case 5:return[2]}})})},ku.prototype.ns=function(t){var r=this,e=this.jn.then(function(){return r.Hn=!0,t().catch(function(t){throw r.Kn=t,r.Hn=!1,Cr("INTERNAL UNHANDLED ERROR: ",(n=(e=t).message||"",e.stack&&(n=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),n)),t;var e,n}).then(function(t){return r.Hn=!1,t})});return this.jn=e},ku.prototype.Pn=function(t,e,n){var r=this;this.es(),-1<this.Yn.indexOf(t)&&(e=0);var i=Ou.qn(this,t,e,n,function(t){return r.us(t)});return this.zn.push(i),i},ku.prototype.es=function(){this.Kn&&xr()},ku.prototype.cs=function(){},ku.prototype.hs=function(){return w(this,void 0,void 0,function(){var e;return b(this,function(t){switch(t.label){case 0:return[4,e=this.jn];case 1:t.sent(),t.label=2;case 2:if(e!==this.jn)return[3,0];t.label=3;case 3:return[2]}})})},ku.prototype.ls=function(t){for(var e=0,n=this.zn;e<n.length;e++)if(n[e].fn===t)return!0;return!1},ku.prototype._s=function(r){var i=this;return this.hs().then(function(){i.zn.sort(function(t,e){return t.On-e.On});for(var t=0,e=i.zn;t<e.length;t++){var n=e[t];if(n.gn(),"all"!==r&&n.fn===r)break}return i.hs()})},ku.prototype.fs=function(t){this.Yn.push(t)},ku.prototype.us=function(t){var e=this.zn.indexOf(t);this.zn.splice(e,1)},ku);function ku(){var e=this;this.jn=Promise.resolve(),this.Wn=[],this.Gn=!1,this.zn=[],this.Kn=null,this.Hn=!1,this.Yn=[],this.Jn=new Au(this,"async_queue_retry"),this.Xn=function(){var t=Lu();t&&Ur("AsyncQueue","Visibility state changed to  ",t.visibilityState),e.Jn.pn()};var t=Lu();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.Xn)}function Vu(t,e,n,r,i){this.xn=t,this.fn=e,this.On=n,this.op=r,this.Mn=i,this.Ln=new Tu,this.then=this.Ln.promise.then.bind(this.Ln.promise),this.Ln.promise.catch(function(t){})}function _u(t,e){if(Cr("AsyncQueue",e+": "+t),Du(t))return new Pr(Or.UNAVAILABLE,e+": "+t);throw t}function Uu(){this.ds=void 0,this.listeners=[]}function Cu(){this.ws=new _i(Ga,qa),this.onlineState="Unknown",this.Ts=new Set}function ju(u,h){return w(this,void 0,void 0,function(){var e,n,r,i,o,s,a;return b(this,function(t){switch(t.label){case 0:if(e=u,n=h.query,r=!1,(i=e.ws.get(n))||(r=!0,i=new Uu),!r)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),o=i,[4,e.Es(n)];case 2:return o.ds=t.sent(),[3,4];case 3:return s=t.sent(),a=_u(s,"Initialization of query '"+za(h.query)+"' failed"),[2,void h.onError(a)];case 4:return e.ws.set(n,i),i.listeners.push(h),h.Is(e.onlineState),i.ds&&h.As(i.ds)&&xu(e),[2]}})})}function Mu(s,a){return w(this,void 0,void 0,function(){var e,n,r,i,o;return b(this,function(t){return e=s,n=a.query,r=!1,(i=e.ws.get(n))&&0<=(o=i.listeners.indexOf(a))&&(i.listeners.splice(o,1),r=0===i.listeners.length),r?[2,(e.ws.delete(n),e.Rs(n))]:[2]})})}function xu(t){t.Ts.forEach(function(t){t.next()})}var Bu=(Gu.prototype.As=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 Io(t.query,t.docs,t.Bt,e,t.Qt,t.fromCache,t.jt,!0)}var o=!1;return this.Ps?this.gs(t)&&(this.ys.next(t),o=!0):this.Vs(t,this.onlineState)&&(this.vs(t),o=!0),this.ps=t,o},Gu.prototype.onError=function(t){this.ys.error(t)},Gu.prototype.Is=function(t){this.onlineState=t;var e=!1;return this.ps&&!this.Ps&&this.Vs(this.ps,t)&&(this.vs(this.ps),e=!0),e},Gu.prototype.Vs=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.bs&&n||t.docs.m()&&"Offline"!==e)},Gu.prototype.gs=function(t){if(0<t.docChanges.length)return!0;var e=this.ps&&this.ps.hasPendingWrites!==t.hasPendingWrites;return!(!t.jt&&!e)&&!0===this.options.includeMetadataChanges},Gu.prototype.vs=function(t){t=Io.Gt(t.query,t.docs,t.Qt,t.fromCache),this.Ps=!0,this.ys.next(t)},Gu),Fu=(qu.prototype.Ss=function(){return null!=this.uid},qu.prototype.Cs=function(){return this.Ss()?"uid:"+this.uid:"anonymous-user"},qu.prototype.isEqual=function(t){return t.uid===this.uid},qu);function qu(t){this.uid=t}function Gu(t,e,n){this.query=t,this.ys=e,this.Ps=!1,this.ps=null,this.onlineState="Unknown",this.options=n||{}}Fu.UNAUTHENTICATED=new Fu(null),Fu.Ds=new Fu("google-credentials-uid"),Fu.Fs=new Fu("first-party-uid");var zu=(Wu.prototype.$s=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},Wu.prototype.next=function(){var t=++this.previousValue;return this.ks&&this.ks(t),t},Wu);function Wu(t,e){var n=this;this.previousValue=t,e&&(e.Ns=function(t){return n.$s(t)},this.ks=function(t){return e.xs(t)})}zu.Os=-1;var Qu=(oh.prototype.Ms=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},oh.prototype.Ls=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},oh.prototype.qs=function(){var t={activeTargetIds:this.activeTargetIds.A(),updateTimeMs:Date.now()};return JSON.stringify(t)},oh),Hu=(ih.prototype.js=function(t){},ih.prototype.Ws=function(t,e,n){},ih.prototype.Gs=function(t){return this.Us.Ms(t),this.Bs[t]||"not-current"},ih.prototype.zs=function(t,e,n){this.Bs[t]=e},ih.prototype.Ks=function(t){this.Us.Ls(t)},ih.prototype.Hs=function(t){return this.Us.activeTargetIds.has(t)},ih.prototype.Ys=function(t){delete this.Bs[t]},ih.prototype.Js=function(){return this.Us.activeTargetIds},ih.prototype.Xs=function(t){return this.Us.activeTargetIds.has(t)},ih.prototype.start=function(){return this.Us=new Qu,Promise.resolve()},ih.prototype.Zs=function(t,e,n){},ih.prototype.ti=function(t){},ih.prototype.ei=function(){},ih.prototype.xs=function(t){},ih),Xu=(rh.prototype.si=function(t,e,n){for(var r=n.ii,i=0;i<this.mutations.length;i++){var o=this.mutations[i];o.key.isEqual(t)&&(e=Ys(o,e,r[i]))}return e},rh.prototype.ri=function(t,e){for(var n=0,r=this.baseMutations;n<r.length;n++){var i=r[n];i.key.isEqual(t)&&(e=Ks(i,e,e,this.ni))}for(var o=e,s=0,a=this.mutations;s<a.length;s++){var u=a[s];u.key.isEqual(t)&&(e=Ks(u,e,o,this.ni))}return e},rh.prototype.oi=function(n){var r=this,i=n;return this.mutations.forEach(function(t){var e=r.ri(t.key,n.get(t.key));e&&(i=i.rt(t.key,e))}),i},rh.prototype.keys=function(){return this.mutations.reduce(function(t,e){return t.add(e.key)},mo())},rh.prototype.isEqual=function(t){return this.batchId===t.batchId&&Ti(this.mutations,t.mutations,Js)&&Ti(this.baseMutations,t.baseMutations,Js)},rh),Yu=(nh.from=function(t,e,n){Br(t.mutations.length===n.length);for(var r=yo,i=t.mutations,o=0;o<i.length;o++)r=r.rt(i[o].key,n[o].version);return new nh(t,e,n,r)},nh),Ku=(eh.prototype._i=function(e,n){var r=this;return this.hi.fi(e,n).next(function(t){return r.di(e,n,t)})},eh.prototype.di=function(t,r,i){return this.ai.wi(t,r).next(function(t){for(var e=0,n=i;e<n.length;e++)t=n[e].ri(r,t);return t})},eh.prototype.mi=function(t,e,i){var o=lo;return e.forEach(function(t,e){for(var n=0,r=i;n<r.length;n++)e=r[n].ri(t,e);o=o.rt(t,e)}),o},eh.prototype.Ti=function(e,t){var n=this;return this.ai.getEntries(e,t).next(function(t){return n.Ei(e,t)})},eh.prototype.Ei=function(r,i){var o=this;return this.hi.Ii(r,i).next(function(t){var e=o.mi(r,i,t),n=lo;return e.forEach(function(t,e){e=e||new Na(t,Ci.min()),n=n.rt(t,e)}),n})},eh.prototype.Ai=function(t,e,n){return r=e,Kr.N(r.path)&&null===r.collectionGroup&&0===r.filters.length?this.Ri(t,e.path):Ca(e)?this.yi(t,e,n):this.Pi(t,e,n);var r},eh.prototype.Ri=function(t,e){return this._i(t,new Kr(e)).next(function(t){var e=vo;return t instanceof Aa&&(e=e.rt(t.key,t)),e})},eh.prototype.yi=function(i,o,s){var a=this,u=o.collectionGroup,h=vo;return this.li.pi(i,u).next(function(t){return Nu.forEach(t,function(t){var e,n,r=(e=o,n=t.child(u),new Sa(n,null,e.rn.slice(),e.filters.slice(),e.limit,e.on,e.startAt,e.endAt));return a.Pi(i,r,s).next(function(t){t.forEach(function(t,e){h=h.rt(t,e)})})}).next(function(){return h})})},eh.prototype.Pi=function(e,n,t){var c,l,r=this;return this.ai.Ai(e,n,t).next(function(t){return c=t,r.hi.gi(e,n)}).next(function(t){return l=t,r.Vi(e,l,c).next(function(t){c=t;for(var e=0,n=l;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),h=Ks(s,u,u,r.ni);c=h instanceof Aa?c.rt(a,h):c.remove(a)}})}).next(function(){return c.forEach(function(t,e){Wa(n,e)||(c=c.remove(t))}),c})},eh.prototype.Vi=function(t,e,n){for(var r=mo(),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 na&&null===n.get(u.key)&&(r=r.add(u.key))}var h=n;return this.ai.getEntries(t,r).next(function(t){return t.forEach(function(t,e){null!==e&&e instanceof Aa&&(h=h.rt(t,e))}),h})},eh),Ju=(th.Si=function(t,e){for(var n=mo(),r=mo(),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 th(t,e.fromCache,n,r)},th),Zu=($u.Ni=function(t){return new $u(t,$u.$i,$u.ki)},$u);function $u(t,e,n){this.Ci=t,this.Di=e,this.Fi=n}function th(t,e,n,r){this.targetId=t,this.fromCache=e,this.vi=n,this.bi=r}function eh(t,e,n){this.ai=t,this.hi=e,this.li=n}function nh(t,e,n,r){this.batch=t,this.ui=e,this.ii=n,this.ci=r}function rh(t,e,n,r){this.batchId=t,this.ni=e,this.baseMutations=n,this.mutations=r}function ih(){this.Us=new Qu,this.Bs={},this.Qs=null,this.Ns=null}function oh(){this.activeTargetIds=wo}Zu.xi=-1,Zu.Oi=1048576,Zu.Mi=41943040,Zu.$i=10,Zu.ki=1e3,Zu.Li=new Zu(Zu.Mi,Zu.$i,Zu.ki),Zu.qi=new Zu(Zu.xi,0,0);var sh=(ph.prototype.Bi=function(t,e){return this.Ui.add(e),Nu.resolve()},ph.prototype.pi=function(t,e){return Nu.resolve(this.Ui.getEntries(e))},ph),ah=(fh.prototype.add=function(t){var e=t._(),n=t.h(),r=this.index[e]||new ho(Hr.i),i=!r.has(n);return this.index[e]=r.add(n),i},fh.prototype.has=function(t){var e=t._(),n=t.h(),r=this.index[e];return r&&r.has(n)},fh.prototype.getEntries=function(t){return(this.index[t]||new ho(Hr.i)).A()},fh),uh=(lh.prototype.next=function(){return this.Qi+=2,this.Qi},lh.ji=function(){return new lh(0)},lh.Wi=function(){return new lh(-1)},lh),hh=(ch.prototype.ir=function(e){var n=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",function(t){return e.rr(t,n.zi)})},ch);function ch(t,e,n){this.persistence=t,this.Gi=e,this.zi=new no(Ii),this.Ki=new _i(Qi,Hi),this.Hi=Ci.min(),this.hi=t.Yi(n),this.Ji=t.Xi(),this.Zi=t.tr(),this.er=new Ku(this.Ji,this.hi,this.persistence.nr()),this.Gi.sr(this.er)}function lh(t){this.Qi=t}function fh(){this.index={}}function ph(){this.Ui=new ah}function dh(t,c){var l=t;return l.persistence.runTransaction("Acknowledge batch","readwrite-primary",function(t){var e,n,i,o,s,r,a,u=c.batch.keys(),h=l.Ji.ur({cr:!0});return e=l,n=t,o=h,s=(i=c).batch,r=s.keys(),a=Nu.resolve(),r.forEach(function(r){a=a.next(function(){return o.wi(n,r)}).next(function(t){var e=t,n=i.ci.get(r);Br(null!==n),(!e||e.version.L(n)<0)&&(e=s.si(r,e,i))&&o.ar(e,i.ui)})}),a.next(function(){return e.hi.hr(n,s)}).next(function(){return h.apply(t)}).next(function(){return l.hi.lr(t)}).next(function(){return l.er.Ti(t,u)})})}function vh(t){var e=t;return e.persistence.runTransaction("Get last remote snapshot version","readonly",function(t){return e.Zi._r(t)})}function yh(t,s){var c=t,l=s.et,f=c.zi;return c.persistence.runTransaction("Apply remote event","readwrite-primary",function(u){var i=c.Ji.ur({cr:!0});f=c.zi;var h=[];s.zt.forEach(function(t,e){var n,r,i,o,s,a=f.get(e);a&&(h.push(c.Zi.dr(u,t.ne,e).next(function(){return c.Zi.wr(u,t.te,e)})),0<(n=t.resumeToken).M()&&(r=a.st(n,l).nt(u.mr),f=f.rt(e,r),i=a,s=t,Br(0<(o=r).resumeToken.M()),(0===i.resumeToken.M()||3e8<=o.et.J()-i.et.J()||0<s.te.size+s.ee.size+s.ne.size)&&h.push(c.Zi.Tr(u,r))))});var t,o=lo,n=mo();return s.Ht.forEach(function(t,e){n=n.add(t)}),h.push(i.getEntries(u,n).next(function(r){s.Ht.forEach(function(t,e){var n=r.get(t);e instanceof Na&&e.version.isEqual(Ci.min())?(i.Er(t,l),o=o.rt(t,e)):null==n||0<e.version.L(n.version)||0===e.version.L(n.version)&&n.hasPendingWrites?(i.ar(e,l),o=o.rt(t,e)):Ur("LocalStore","Ignoring outdated watch update for ",t,". Current version:",n.version," Watch version:",e.version),s.Yt.has(t)&&h.push(c.persistence.Ar.Ir(u,t))})})),l.isEqual(Ci.min())||(t=c.Zi._r(u).next(function(t){return c.Zi.Rr(u,u.mr,l)}),h.push(t)),Nu.$n(h).next(function(){return i.apply(u)}).next(function(){return c.er.Ei(u,o)})}).then(function(t){return c.zi=f,t})}function gh(o,s,a){return w(this,void 0,void 0,function(){var e,n,r,i;return b(this,function(t){switch(t.label){case 0:n=(e=o).zi.get(s),r=a?"readwrite":"readwrite-primary",t.label=1;case 1:return t.trys.push([1,4,,5]),a?[3,3]:[4,e.persistence.runTransaction("Release target",r,function(t){return e.persistence.Ar.removeTarget(t,n)})];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:if(!Du(i=t.sent()))throw i;return Ur("LocalStore","Failed to update sequence numbers for target "+s+": "+i),[3,5];case 5:return e.zi=e.zi.remove(s),e.Ki.delete(n.target),[2]}})})}function mh(t,s,a){var u=t,h=Ci.min(),c=mo();return u.persistence.runTransaction("Execute query","readonly",function(e){return t=u,n=e,r=Ma(s),(void 0!==(o=(i=t).Ki.get(r))?Nu.resolve(i.zi.get(o)):i.Zi.Pr(n,r)).next(function(t){if(t)return h=t.lastLimboFreeSnapshotVersion,u.Zi.pr(e,t.targetId).next(function(t){c=t})}).next(function(){return u.Gi.Ai(e,s,a?h:Ci.min(),a?c:mo())}).next(function(t){return{documents:t,gr:c}});var t,n,r,i,o})}function wh(e){return w(this,void 0,void 0,function(){return b(this,function(t){if(e.code!==Or.FAILED_PRECONDITION||"The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab."!==e.message)throw e;return Ur("LocalStore","Unexpectedly lost primary lease"),[2]})})}function bh(t,e){this.user=e,this.type="OAuth",this.Ur={},this.Ur.Authorization="Bearer "+t}function Eh(t,e,n,r,i){var o=this;this.Bo=t,this.Qo=e,this.xn=n,this.jo={},this.Wo=[],this.Go=new Map,this.zo=new Set,this.Ko=[],this.Ho=i,this.Ho.Yo(function(t){n.Qn(function(){return w(o,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return nc(this)?(Ur("RemoteStore","Restarting streams for network reachability change."),[4,function(n){return w(this,void 0,void 0,function(){var e;return b(this,function(t){switch(t.label){case 0:return(e=n).zo.add(4),[4,Xh(e)];case 1:return t.sent(),e.Jo.set("Unknown"),e.zo.delete(4),[4,Hh(e)];case 2:return t.sent(),[2]}})})}(this)]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})})}),this.Jo=new Uh(n,r)}var Ih,Th,Ah,Nh=(Qh.prototype.m=function(){return this.Vr.m()},Qh.prototype.Cr=function(t,e){var n=new Rh(t,e);this.Vr=this.Vr.add(n),this.br=this.br.add(n)},Qh.prototype.Dr=function(t,e){var n=this;t.forEach(function(t){return n.Cr(t,e)})},Qh.prototype.Fr=function(t,e){this.Nr(new Rh(t,e))},Qh.prototype.$r=function(t,e){var n=this;t.forEach(function(t){return n.Fr(t,e)})},Qh.prototype.kr=function(t){var e=this,n=new Kr(new Hr([])),r=new Rh(n,t),i=new Rh(n,t+1),o=[];return this.br.Ft([r,i],function(t){e.Nr(t),o.push(t.key)}),o},Qh.prototype.Or=function(){var e=this;this.Vr.forEach(function(t){return e.Nr(t)})},Qh.prototype.Nr=function(t){this.Vr=this.Vr.delete(t),this.br=this.br.delete(t)},Qh.prototype.Mr=function(t){var e=new Kr(new Hr([])),n=new Rh(e,t),r=new Rh(e,t+1),i=mo();return this.br.Ft([n,r],function(t){i=i.add(t.key)}),i},Qh.prototype.Lr=function(t){var e=new Rh(t,0),n=this.Vr.$t(e);return null!==n&&t.isEqual(n.key)},Qh),Rh=(Wh.vr=function(t,e){return Kr.i(t.key,e.key)||Ii(t.qr,e.qr)},Wh.Sr=function(t,e){return Ii(t.qr,e.qr)||Kr.i(t.key,e.key)},Wh),Sh=(zh.prototype.getToken=function(){return Promise.resolve(null)},zh.prototype.Qr=function(){},zh.prototype.jr=function(t){(this.Br=t)(Fu.UNAUTHENTICATED)},zh.prototype.Wr=function(){this.Br=null},zh),Dh=(Gh.prototype.getToken=function(){var e=this,n=this.Kr,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(function(t){return e.Kr!==n?(Ur("FirebaseCredentialsProvider","getToken aborted due to token change."),e.getToken()):t?(Br("string"==typeof t.accessToken),new bh(t.accessToken,e.currentUser)):null}):Promise.resolve(null)},Gh.prototype.Qr=function(){this.forceRefresh=!0},Gh.prototype.jr=function(t){this.Br=t,this.zr&&t(this.currentUser)},Gh.prototype.Wr=function(){this.auth&&this.auth.removeAuthTokenListener(this.Gr),this.Gr=null,this.Br=null},Gh.prototype.Hr=function(){var t=this.auth&&this.auth.getUid();return Br(null===t||"string"==typeof t),new Fu(t)},Gh),Lh=(Object.defineProperty(qh.prototype,"Ur",{get:function(){var t={"X-Goog-AuthUser":this.Jr},e=this.Yr.auth.getAuthHeaderValueForFirstParty([]);return e&&(t.Authorization=e),t},enumerable:!1,configurable:!0}),qh),Oh=(Fh.prototype.getToken=function(){return Promise.resolve(new Lh(this.Yr,this.Jr))},Fh.prototype.jr=function(t){t(Fu.Fs)},Fh.prototype.Wr=function(){},Fh.prototype.Qr=function(){},Fh),Ph=(Bh.prototype.io=function(){return 1===this.state||2===this.state||4===this.state},Bh.prototype.ro=function(){return 2===this.state},Bh.prototype.start=function(){3!==this.state?this.auth():this.oo()},Bh.prototype.stop=function(){return w(this,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return this.io()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},Bh.prototype.uo=function(){this.state=0,this.Jn.reset()},Bh.prototype.co=function(){var t=this;this.ro()&&null===this.so&&(this.so=this._n.Pn(this.Xr,6e4,function(){return t.ao()}))},Bh.prototype.ho=function(t){this.lo(),this.stream.send(t)},Bh.prototype.ao=function(){return w(this,void 0,void 0,function(){return b(this,function(t){return this.ro()?[2,this.close(0)]:[2]})})},Bh.prototype.lo=function(){this.so&&(this.so.cancel(),this.so=null)},Bh.prototype.close=function(e,n){return w(this,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return this.lo(),this.Jn.cancel(),this.no++,3!==e?this.Jn.reset():n&&n.code===Or.RESOURCE_EXHAUSTED?(Cr(n.toString()),Cr("Using maximum backoff delay to prevent overloading the backend."),this.Jn.An()):n&&n.code===Or.UNAUTHENTICATED&&this.eo.Qr(),null!==this.stream&&(this._o(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.fo(n)];case 1:return t.sent(),[2]}})})},Bh.prototype._o=function(){},Bh.prototype.auth=function(){var n=this;this.state=1;var t=this.do(this.no),e=this.no;this.eo.getToken().then(function(t){n.no===e&&n.wo(t)},function(e){t(function(){var t=new Pr(Or.UNKNOWN,"Fetching auth token failed: "+e.message);return n.mo(t)})})},Bh.prototype.wo=function(t){var e=this,n=this.do(this.no);this.stream=this.To(t),this.stream.Eo(function(){n(function(){return e.state=2,e.listener.Eo()})}),this.stream.fo(function(t){n(function(){return e.mo(t)})}),this.stream.onMessage(function(t){n(function(){return e.onMessage(t)})})},Bh.prototype.oo=function(){var t=this;this.state=4,this.Jn.Rn(function(){return w(t,void 0,void 0,function(){return b(this,function(t){return this.state=0,this.start(),[2]})})})},Bh.prototype.mo=function(t){return Ur("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},Bh.prototype.do=function(e){var n=this;return function(t){n._n.Qn(function(){return n.no===e?t():(Ur("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},Bh),kh=(o(xh,Ah=Ph),xh.prototype.To=function(t){return this.Zr.Io("Listen",t)},xh.prototype.onMessage=function(t){this.Jn.reset();var e=function(t,e){var n,r,i,o;if("targetChange"in e){e.targetChange;var s="NO_CHANGE"===(o=e.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===o?1:"REMOVE"===o?2:"CURRENT"===o?3:"RESET"===o?4:xr(),a=e.targetChange.targetIds||[],u=(i=e.targetChange.resumeToken,t.Be?(Br(void 0===i||"string"==typeof i),Ai.fromBase64String(i||"")):(Br(void 0===i||i instanceof Uint8Array),Ai.fromUint8Array(i||new Uint8Array))),h=e.targetChange.cause,c=h&&(r=void 0===(n=h).code?Or.UNKNOWN:eo(n.code),new Pr(r,n.message||"")),l=new So(s,a,u,c||null)}else if("documentChange"in e){e.documentChange;var f=e.documentChange;f.document,f.document.name,f.document.updateTime;var p=ds(t,f.document.name),d=ls(f.document.updateTime),v=new da({mapValue:{fields:f.document.fields}}),y=new Aa(p,d,v,{}),g=f.targetIds||[],m=f.removedTargetIds||[];l=new No(g,m,y.key,y)}else if("documentDelete"in e){e.documentDelete;var w=e.documentDelete;w.document;var b=ds(t,w.document),E=w.readTime?ls(w.readTime):Ci.min(),I=new Na(b,E),T=w.removedTargetIds||[];l=new No([],T,I.key,I)}else if("documentRemove"in e){e.documentRemove;var A=e.documentRemove;A.document;var N=ds(t,A.document),R=A.removedTargetIds||[];l=new No([],R,N,null)}else{if(!("filter"in e))return xr();e.filter;var S=e.filter;S.targetId;var D=S.count||0,L=new Yi(D),O=S.targetId;l=new Ro(O,L)}return l}(this.serializer,t),n=function(t){if(!("targetChange"in t))return Ci.min();var e=t.targetChange;return(!e.targetIds||!e.targetIds.length)&&e.readTime?ls(e.readTime):Ci.min()}(t);return this.listener.Ao(e,n)},xh.prototype.Ro=function(t){var e,n,r,i,o={};o.database=ys(this.serializer),o.addTarget=(e=this.serializer,i=(n=t).target,(r=Xi(i)?{documents:{documents:[vs(e,i.path)]}}:{query:ws(e,i)}).targetId=n.targetId,0<n.resumeToken.M()&&(r.resumeToken=cs(e,n.resumeToken)),r);var s,a,u=(this.serializer,s=t,null==(a=function(){switch(s.tt){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return xr()}}())?null:{"goog-listen-tags":a});u&&(o.labels=u),this.ho(o)},xh.prototype.yo=function(t){var e={};e.database=ys(this.serializer),e.removeTarget=t,this.ho(e)},xh),Vh=(o(Mh,Th=Ph),Object.defineProperty(Mh.prototype,"po",{get:function(){return this.Po},enumerable:!1,configurable:!0}),Mh.prototype.start=function(){this.Po=!1,this.lastStreamToken=void 0,Th.prototype.start.call(this)},Mh.prototype._o=function(){this.Po&&this.Vo([])},Mh.prototype.To=function(t){return this.Zr.Io("Write",t)},Mh.prototype.onMessage=function(t){if(Br(!!t.streamToken),this.lastStreamToken=t.streamToken,this.Po){this.Jn.reset();var e=(r=t.writeResults,i=t.commitTime,r&&0<r.length?(Br(void 0!==i),r.map(function(t){return function(t,e){var n=t.updateTime?ls(t.updateTime):ls(e);n.isEqual(Ci.min())&&(n=ls(e));var r=null;return t.transformResults&&0<t.transformResults.length&&(r=t.transformResults),new zs(n,r)}(t,i)})):[]),n=ls(t.commitTime);return this.listener.vo(n,e)}var r,i;return Br(!t.writeResults||0===t.writeResults.length),this.Po=!0,this.listener.bo()},Mh.prototype.So=function(){var t={};t.database=ys(this.serializer),this.ho(t)},Mh.prototype.Vo=function(t){var e=this,n={streamToken:this.lastStreamToken,writes:t.map(function(t){return ms(e.serializer,t)})};this.ho(n)},Mh),_h=(o(jh,Ih=function(){}),jh.prototype.Do=function(){if(this.Co)throw new Pr(Or.FAILED_PRECONDITION,"The client has already been terminated.")},jh.prototype.Fo=function(e,n,r){var i=this;return this.Do(),this.credentials.getToken().then(function(t){return i.Zr.Fo(e,n,r,t)}).catch(function(t){throw t.code===Or.UNAUTHENTICATED&&i.credentials.Qr(),t})},jh.prototype.No=function(e,n,r){var i=this;return this.Do(),this.credentials.getToken().then(function(t){return i.Zr.No(e,n,r,t)}).catch(function(t){throw t.code===Or.UNAUTHENTICATED&&i.credentials.Qr(),t})},jh.prototype.terminate=function(){this.Co=!1},jh),Uh=(Ch.prototype.Oo=function(){var t=this;0===this.$o&&(this.Mo("Unknown"),this.ko=this.xn.Pn("online_state_timeout",1e4,function(){return t.ko=null,t.Lo("Backend didn't respond within 10 seconds."),t.Mo("Offline"),Promise.resolve()}))},Ch.prototype.qo=function(t){"Online"===this.state?this.Mo("Unknown"):(this.$o++,1<=this.$o&&(this.Uo(),this.Lo("Connection failed 1 times. Most recent error: "+t.toString()),this.Mo("Offline")))},Ch.prototype.set=function(t){this.Uo(),this.$o=0,"Online"===t&&(this.xo=!1),this.Mo(t)},Ch.prototype.Mo=function(t){t!==this.state&&(this.state=t,this.Qs(t))},Ch.prototype.Lo=function(t){var e="Could not reach Cloud Firestore backend. "+t+"\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.";this.xo?(Cr(e),this.xo=!1):Ur("OnlineStateTracker",e)},Ch.prototype.Uo=function(){null!==this.ko&&(this.ko.cancel(),this.ko=null)},Ch);function Ch(t,e){this.xn=t,this.Qs=e,this.state="Unknown",this.$o=0,this.ko=null,this.xo=!0}function jh(t,e,n){var r=this;return(r=Ih.call(this)||this).credentials=t,r.Zr=e,r.serializer=n,r.Co=!1,r}function Mh(t,e,n,r,i){var o=this;return(o=Th.call(this,t,"write_stream_connection_backoff","write_stream_idle",e,n,i)||this).serializer=r,o.Po=!1,o}function xh(t,e,n,r,i){var o=this;return(o=Ah.call(this,t,"listen_stream_connection_backoff","listen_stream_idle",e,n,i)||this).serializer=r,o}function Bh(t,e,n,r,i,o){this._n=t,this.Xr=n,this.Zr=r,this.eo=i,this.listener=o,this.state=0,this.no=0,this.so=null,this.stream=null,this.Jn=new Au(t,e)}function Fh(t,e){this.Yr=t,this.Jr=e}function qh(t,e){this.Yr=t,this.Jr=e,this.type="FirstParty",this.user=Fu.Fs}function Gh(t){var e=this;this.Gr=null,this.currentUser=Fu.UNAUTHENTICATED,this.zr=!1,this.Kr=0,this.Br=null,this.forceRefresh=!1,this.Gr=function(){e.Kr++,e.currentUser=e.Hr(),e.zr=!0,e.Br&&e.Br(e.currentUser)},this.Kr=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.Gr):(this.Gr(null),t.get().then(function(t){e.auth=t,e.Gr&&e.auth.addAuthTokenListener(e.Gr)},function(){}))}function zh(){this.Br=null}function Wh(t,e){this.key=t,this.qr=e}function Qh(){this.Vr=new ho(Rh.vr),this.br=new ho(Rh.Sr)}function Hh(r){return w(this,void 0,void 0,function(){var e,n;return b(this,function(t){switch(t.label){case 0:if(!nc(r))return[3,4];e=0,n=r.Ko,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 Xh(r){return w(this,void 0,void 0,function(){var e,n;return b(this,function(t){switch(t.label){case 0:e=0,n=r.Ko,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 Yh(n){return w(this,void 0,void 0,function(){var e;return b(this,function(t){switch(t.label){case 0:return e=n,Ur("RemoteStore","RemoteStore shutting down."),e.zo.add(5),[4,Xh(e)];case 1:return t.sent(),e.Ho.ei(),e.Jo.set("Unknown"),[2]}})})}function Kh(t,e){var n=t;n.Go.has(e.targetId)||(n.Go.set(e.targetId,e),ec(n)?tc(n):cc(n).ro()&&Zh(n,e))}function Jh(t,e){var n=t,r=cc(n);n.Go.delete(e),r.ro()&&$h(n,e),0===n.Go.size&&(r.ro()?r.co():nc(n)&&n.Jo.set("Unknown"))}function Zh(t,e){t.Xo.Ee(e.targetId),cc(t).Ro(e)}function $h(t,e){t.Xo.Ee(e),cc(t).yo(e)}function tc(e){e.Xo=new Lo({qe:function(t){return e.jo.qe(t)},Ue:function(t){return e.Go.get(t)||null}}),cc(e).start(),e.Jo.Oo()}function ec(t){return nc(t)&&!cc(t).io()&&0<t.Go.size}function nc(t){return 0===t.zo.size}function rc(t){t.Xo=void 0}function ic(a,u,h){return w(this,void 0,void 0,function(){var n,o,s;return b(this,function(t){switch(t.label){case 0:if(a.Jo.set("Online"),!(u instanceof So&&2===u.state&&u.cause))return[3,6];t.label=1;case 1:return t.trys.push([1,3,,5]),[4,function(o,s){return w(this,void 0,void 0,function(){var e,n,r,i;return b(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.Go.has(i)?[4,o.jo.Zo(i,e)]:[3,3]):[3,5];case 2:t.sent(),o.Go.delete(i),o.Xo.removeTarget(i),t.label=3;case 3:t.label=4;case 4:return n++,[3,1];case 5:return[2]}})})}(a,u)];case 2:return t.sent(),[3,5];case 3:return n=t.sent(),Ur("RemoteStore","Failed to remove targets %s: %s ",u.targetIds.join(","),n),[4,oc(a,n)];case 4:return t.sent(),[3,5];case 5:return[3,13];case 6:if(u instanceof No?a.Xo.Ve(u):u instanceof Ro?a.Xo.$e(u):a.Xo.Se(u),h.isEqual(Ci.min()))return[3,13];t.label=7;case 7:return t.trys.push([7,11,,13]),[4,vh(a.Bo)];case 8:return o=t.sent(),0<=h.L(o)?[4,(i=h,(e=(r=a).Xo.Oe(i)).zt.forEach(function(t,e){var n;0<t.resumeToken.M()&&((n=r.Go.get(e))&&r.Go.set(e,n.st(t.resumeToken,i)))}),e.Kt.forEach(function(t){var e,n=r.Go.get(t);n&&(r.Go.set(t,n.st(Ai.q,n.et)),$h(r,t),e=new Zi(n.target,t,1,n.sequenceNumber),Zh(r,e))}),r.jo.tu(e))]:[3,10];case 9:t.sent(),t.label=10;case 10:return[3,13];case 11:return Ur("RemoteStore","Failed to raise snapshot:",s=t.sent()),[4,oc(a,s)];case 12:return t.sent(),[3,13];case 13:return[2]}var r,i,e})})}function oc(n,r,i){return w(this,void 0,void 0,function(){var e=this;return b(this,function(t){switch(t.label){case 0:if(!Du(r))throw r;return n.zo.add(1),[4,Xh(n)];case 1:return t.sent(),n.Jo.set("Offline"),i=i||function(){return vh(n.Bo)},n.xn.rs(function(){return w(e,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return Ur("RemoteStore","Retrying IndexedDB access"),[4,i()];case 1:return t.sent(),n.zo.delete(1),[4,Hh(n)];case 2:return t.sent(),[2]}})})}),[2]}})})}function sc(e,n){return n().catch(function(t){return oc(e,t,n)})}function ac(h){return w(this,void 0,void 0,function(){var i,o,s,a,u;return b(this,function(t){switch(t.label){case 0:o=lc(i=h),s=0<i.Wo.length?i.Wo[i.Wo.length-1].batchId:-1,t.label=1;case 1:if(!(nc(i)&&i.Wo.length<10))return[3,7];t.label=2;case 2:return t.trys.push([2,4,,6]),[4,(e=i.Bo,n=s,(r=e).persistence.runTransaction("Get next mutation batch","readonly",function(t){return void 0===n&&(n=-1),r.hi.yr(t,n)}))];case 3:return null===(a=t.sent())?(0===i.Wo.length&&o.co(),[3,7]):(s=a.batchId,function(t,e){t.Wo.push(e);var n=lc(t);n.ro()&&n.po&&n.Vo(e.mutations)}(i,a),[3,6]);case 4:return u=t.sent(),[4,oc(i,u)];case 5:return t.sent(),[3,6];case 6:return[3,1];case 7:return uc(i)&&hc(i),[2]}var e,n,r})})}function uc(t){return nc(t)&&!lc(t).io()&&0<t.Wo.length}function hc(t){lc(t).start()}function cc(n){var t,e,r,i,o=this;return n.su||(n.su=(t=n.Qo,e=n.xn,r={Eo:function(n){return w(this,void 0,void 0,function(){return b(this,function(t){return n.Go.forEach(function(t,e){Zh(n,t)}),[2]})})}.bind(null,n),fo:function(e,n){return w(this,void 0,void 0,function(){return b(this,function(t){return rc(e),ec(e)?(e.Jo.qo(n),tc(e)):e.Jo.set("Unknown"),[2]})})}.bind(null,n),Ao:ic.bind(null,n)},(i=t).Do(),new kh(e,i.Zr,i.credentials,i.serializer,r)),n.Ko.push(function(e){return w(o,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return e?(n.su.uo(),ec(n)?tc(n):n.Jo.set("Unknown"),[3,3]):[3,1];case 1:return[4,n.su.stop()];case 2:t.sent(),rc(n),t.label=3;case 3:return[2]}})})})),n.su}function lc(n){var t,e,r,i,o=this;return n.iu||(n.iu=(t=n.Qo,e=n.xn,r={Eo:function(e){return w(this,void 0,void 0,function(){return b(this,function(t){return lc(e).So(),[2]})})}.bind(null,n),fo:function(e,n){return w(this,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return n&&lc(e).po?[4,function(r,i){return w(this,void 0,void 0,function(){var e,n;return b(this,function(t){switch(t.label){case 0:return to(n=i.code)&&n!==Or.ABORTED?(e=r.Wo.shift(),lc(r).uo(),[4,sc(r,function(){return r.jo.nu(e.batchId,i)})]):[3,3];case 1:return t.sent(),[4,ac(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 uc(e)&&hc(e),[2]}})})}.bind(null,n),bo:function(o){return w(this,void 0,void 0,function(){var e,n,r,i;return b(this,function(t){for(e=lc(o),n=0,r=o.Wo;n<r.length;n++)i=r[n],e.Vo(i.mutations);return[2]})})}.bind(null,n),vo:function(r,i,o){return w(this,void 0,void 0,function(){var e,n;return b(this,function(t){switch(t.label){case 0:return e=r.Wo.shift(),n=Yu.from(e,i,o),[4,sc(r,function(){return r.jo.eu(n)})];case 1:return t.sent(),[4,ac(r)];case 2:return t.sent(),[2]}})})}.bind(null,n)},(i=t).Do(),new Vh(e,i.Zr,i.credentials,i.serializer,r)),n.Ko.push(function(e){return w(o,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return e?(n.iu.uo(),[4,ac(n)]):[3,2];case 1:return t.sent(),[3,4];case 2:return[4,n.iu.stop()];case 3:t.sent(),0<n.Wo.length&&(Ur("RemoteStore","Stopping write stream with "+n.Wo.length+" pending writes"),n.Wo=[]),t.label=4;case 4:return[2]}})})})),n.iu}function fc(t,e,n){this.query=t,this.targetId=e,this.view=n}var pc=function(t){this.key=t},dc=function(t){this.key=t},vc=(Object.defineProperty(wc.prototype,"hu",{get:function(){return this.ru},enumerable:!1,configurable:!0}),wc.prototype.lu=function(t,e){var a=this,u=e?e._u:new Eo,h=e?e.au:this.au,c=e?e.Qt:this.Qt,l=h,f=!1,p=ka(this.query)&&h.size===this.query.limit?h.last():null,d=Va(this.query)&&h.size===this.query.limit?h.first():null;if(t.at(function(t,e){var n=h.get(t),r=(r=e instanceof Aa?e:null)&&(Wa(a.query,r)?r:null),i=!!n&&a.Qt.has(n.key),o=!!r&&(r.Ye||a.Qt.has(r.key)&&r.hasCommittedMutations),s=!1;n&&r?n.data().isEqual(r.data())?i!==o&&(u.track({type:3,doc:r}),s=!0):a.fu(n,r)||(u.track({type:2,doc:r}),s=!0,(p&&0<a.cu(r,p)||d&&a.cu(r,d)<0)&&(f=!0)):!n&&r?(u.track({type:0,doc:r}),s=!0):n&&!r&&(u.track({type:1,doc:n}),s=!0,(p||d)&&(f=!0)),s&&(c=r?(l=l.add(r),o?c.add(t):c.delete(t)):(l=l.delete(t),c.delete(t)))}),ka(this.query)||Va(this.query))for(;l.size>this.query.limit;){var n=ka(this.query)?l.last():l.first(),l=l.delete(n.key),c=c.delete(n.key);u.track({type:1,doc:n})}return{au:l,_u:u,du:f,Qt:c}},wc.prototype.fu=function(t,e){return t.Ye&&e.hasCommittedMutations&&!e.Ye},wc.prototype.wu=function(t,e,n){var o=this,r=this.au;this.au=t.au,this.Qt=t.Qt;var i=t._u.Ut();i.sort(function(t,e){return r=t.type,i=e.type,n(r)-n(i)||o.cu(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 xr()}}var r,i}),this.mu(n);var s=e?this.Tu():[],a=0===this.uu.size&&this.Zt?1:0,u=a!==this.ou;return this.ou=a,0!==i.length||u?{snapshot:new Io(this.query,t.au,r,i,t.Qt,0==a,u,!1),Eu:s}:{Eu:s}},wc.prototype.Is=function(t){return this.Zt&&"Offline"===t?(this.Zt=!1,this.wu({au:this.au,_u:new Eo,Qt:this.Qt,du:!1},!1)):{Eu:[]}},wc.prototype.Iu=function(t){return!this.ru.has(t)&&!!this.au.has(t)&&!this.au.get(t).Ye},wc.prototype.mu=function(t){var e=this;t&&(t.te.forEach(function(t){return e.ru=e.ru.add(t)}),t.ee.forEach(function(t){}),t.ne.forEach(function(t){return e.ru=e.ru.delete(t)}),this.Zt=t.Zt)},wc.prototype.Tu=function(){var e=this;if(!this.Zt)return[];var n=this.uu;this.uu=mo(),this.au.forEach(function(t){e.Iu(t.key)&&(e.uu=e.uu.add(t.key))});var r=[];return n.forEach(function(t){e.uu.has(t)||r.push(new dc(t))}),this.uu.forEach(function(t){n.has(t)||r.push(new pc(t))}),r},wc.prototype.Au=function(t){this.ru=t.gr,this.uu=mo();var e=this.lu(t.documents);return this.wu(e,!0)},wc.prototype.Ru=function(){return Io.Gt(this.query,this.au,this.Qt,0===this.ou)},wc),yc=function(t){this.key=t,this.yu=!1},gc=(Object.defineProperty(mc.prototype,"Mu",{get:function(){return!0===this.Ou},enumerable:!1,configurable:!0}),mc);function mc(t,e,n,r,i,o){this.Bo=t,this.Pu=e,this.pu=n,this.gu=r,this.currentUser=i,this.Vu=o,this.vu={},this.bu=new _i(Ga,qa),this.Su=new Map,this.Cu=[],this.Du=new no(Kr.i),this.Fu=new Map,this.Nu=new Nh,this.$u={},this.ku=new Map,this.xu=uh.Wi(),this.onlineState="Unknown",this.Ou=void 0}function wc(t,e){this.query=t,this.ru=e,this.ou=null,this.Zt=!1,this.uu=mo(),this.Qt=mo(),this.cu=Qa(t),this.au=new bo(this.cu)}function bc(l,f){return w(this,void 0,void 0,function(){var o,s,a,u,h,c;return b(this,function(t){switch(t.label){case 0:return(n=l).Pu.jo.tu=Ic.bind(null,n),n.Pu.jo.qe=function(t,e){var n=t,r=n.Fu.get(e);if(r&&r.yu)return mo().add(r.key);var i=mo(),o=n.Su.get(e);if(!o)return i;for(var s=0,a=o;s<a.length;s++){var u=a[s],h=n.bu.get(u);i=i.kt(h.view.hu)}return i}.bind(null,n),n.Pu.jo.Zo=function(a,u,h){return w(this,void 0,void 0,function(){var e,n,r,i,o,s;return b(this,function(t){switch(t.label){case 0:return(e=a).gu.zs(u,"rejected",h),n=e.Fu.get(u),(r=n&&n.key)?(i=(i=new no(Kr.i)).rt(r,new Na(r,Ci.min())),o=mo().add(r),s=new To(Ci.min(),new Map,new ho(Ii),i,o),[4,Ic(e,s)]):[3,2];case 1:return t.sent(),e.Du=e.Du.remove(r),e.Fu.delete(u),Lc(e),[3,4];case 2:return[4,gh(e.Bo,u,!1).then(function(){return Rc(e,u,h)}).catch(wh)];case 3:t.sent(),t.label=4;case 4:return[2]}})})}.bind(null,n),n.vu.Ao=function(t,e){for(var n=t,r=!1,i=0,o=e;i<o.length;i++){var s=o[i],a=s.query,u=n.ws.get(a);if(u){for(var h=0,c=u.listeners;h<c.length;h++)c[h].As(s)&&(r=!0);u.ds=s}}r&&xu(n)}.bind(null,n.pu),n.vu.Lu=function(t,e,n){var r=t,i=r.ws.get(e);if(i)for(var o=0,s=i.listeners;o<s.length;o++)s[o].onError(n);r.ws.delete(e)}.bind(null,n.pu),(u=(o=n).bu.get(f))?(s=u.targetId,o.gu.Gs(s),a=u.view.Ru(),[3,4]):[3,1];case 1:return[4,(e=o.Bo,r=Ma(f),(i=e).persistence.runTransaction("Allocate target","readwrite",function(e){var n;return i.Zi.Pr(e,r).next(function(t){return t?(n=t,Nu.resolve(n)):i.Zi.qu(e).next(function(t){return n=new Zi(r,t,0,e.mr),i.Zi.Uu(e,n).next(function(){return n})})})}).then(function(t){var e=i.zi.get(t.targetId);return(null===e||0<t.et.L(e.et))&&(i.zi=i.zi.rt(t.targetId,t),i.Ki.set(r,t.targetId)),t}))];case 2:return h=t.sent(),c=o.gu.Gs(h.targetId),s=h.targetId,[4,function(a,u,h,c){return w(this,void 0,void 0,function(){var e,n,r,i,o,s;return b(this,function(t){switch(t.label){case 0:return a.Bu=function(t,e,n){return function(i,o,s,a){return w(this,void 0,void 0,function(){var n,e,r;return b(this,function(t){switch(t.label){case 0:return(n=o.view.lu(s)).du?[4,mh(i.Bo,o.query,!1).then(function(t){var e=t.documents;return o.view.lu(e,n)})]:[3,2];case 1:n=t.sent(),t.label=2;case 2:return e=a&&a.zt.get(o.targetId),r=o.view.wu(n,i.Mu,e),[2,(Dc(i,o.targetId,r.Eu),r.snapshot)]}})})}(a,t,e,n)},[4,mh(a.Bo,u,!0)];case 1:return e=t.sent(),n=new vc(u,e.gr),r=n.lu(e.documents),i=Ao.Xt(h,c&&"Offline"!==a.onlineState),o=n.wu(r,a.Mu,i),Dc(a,h,o.Eu),s=new fc(u,h,n),a.bu.set(u,s),a.Su.has(h)?a.Su.get(h).push(u):a.Su.set(h,[u]),[2,o.snapshot]}})})}(o,f,s,"current"===c)];case 3:a=t.sent(),o.Mu&&Kh(o.Pu,h),t.label=4;case 4:return[2,a]}var e,r,i,n})})}function Ec(y,g,m){return w(this,void 0,void 0,function(){var u,p,d,v;return b(this,function(t){switch(t.label){case 0:(a=y).Pu.jo.eu=function(i,o){return w(this,void 0,void 0,function(){var e,n,r;return b(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,dh(e.Bo,o)];case 2:return r=t.sent(),Nc(e,n,null),Ac(e,n),e.gu.Ws(n,"acknowledged"),[4,Oc(e,r)];case 3:return t.sent(),[3,6];case 4:return[4,wh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})}.bind(null,a),a.Pu.jo.nu=function(s,a,u){return w(this,void 0,void 0,function(){var n,o;return b(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.Bo,r=a,(i=e).persistence.runTransaction("Reject batch","readwrite-primary",function(e){var n;return i.hi.Wu(e,r).next(function(t){return Br(null!==t),n=t.keys(),i.hi.hr(e,t)}).next(function(){return i.hi.lr(e)}).next(function(){return i.er.Ti(e,n)})}))];case 2:return o=t.sent(),Nc(n,a,u),Ac(n,a),n.gu.Ws(a,"rejected",u),[4,Oc(n,o)];case 3:return t.sent(),[3,6];case 4:return[4,wh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}var e,r,i})})}.bind(null,a),u=a,t.label=1;case 1:return t.trys.push([1,5,,6]),[4,(o=u.Bo,h=g,l=o,f=Ui.now(),s=h.reduce(function(t,e){return t.add(e.key)},mo()),l.persistence.runTransaction("Locally write mutations","readwrite",function(u){return l.er.Ti(u,s).next(function(t){c=t;for(var a,e,n=[],r=0,i=h;r<i.length;r++){var o=i[r],s=(a=o,e=c.get(o.key),a instanceof aa?function(t){for(var e=null,n=0,r=a.fieldTransforms;n<r.length;n++){var i=r[n],o=t instanceof Aa?t.field(i.field):void 0,s=As(i.transform,o||null);null!=s&&(e=null==e?(new va).set(i.field,s):e.set(i.field,s))}return e?e.Je():null}(e):null);null!=s&&n.push(new na(o.key,s,function a(t){var u=[];return qr(t.fields||{},function(t,e){var n=new Yr([t]);if(ns(e)){var r=a(e.mapValue).fields;if(0===r.length)u.push(n);else for(var i=0,o=r;i<o.length;i++){var s=o[i];u.push(n.child(s))}}else u.push(n)}),new qs(u)}(s.proto.mapValue),Ws.exists(!0)))}return l.hi.Qu(u,f,n,h)})}).then(function(t){var e=t.oi(c);return{batchId:t.batchId,ju:e}}))];case 2:return p=t.sent(),u.gu.js(p.batchId),e=u,n=p.batchId,r=m,i=(i=(i=e.$u[e.currentUser.Cs()])||new no(Ii)).rt(n,r),e.$u[e.currentUser.Cs()]=i,[4,Oc(u,p.ju)];case 3:return t.sent(),[4,ac(u.Pu)];case 4:return t.sent(),[3,6];case 5:return d=t.sent(),v=_u(d,"Failed to persist write"),m.reject(v),[3,6];case 6:return[2]}var e,n,r,i,o,h,c,l,f,s,a})})}function Ic(n,i){return w(this,void 0,void 0,function(){var r,e;return b(this,function(t){switch(t.label){case 0:r=n,t.label=1;case 1:return t.trys.push([1,4,,6]),[4,yh(r.Bo,i)];case 2:return e=t.sent(),i.zt.forEach(function(t,e){var n=r.Fu.get(e);n&&(Br(t.te.size+t.ee.size+t.ne.size<=1),0<t.te.size?n.yu=!0:0<t.ee.size?Br(n.yu):0<t.ne.size&&(Br(n.yu),n.yu=!1))}),[4,Oc(r,e,i)];case 3:return t.sent(),[3,6];case 4:return[4,wh(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})}function Tc(t,r,e){var i,n=t;(n.Mu&&0===e||!n.Mu&&1===e)&&(i=[],n.bu.forEach(function(t,e){var n=e.view.Is(r);n.snapshot&&i.push(n.snapshot)}),function(t,i){var e=t;e.onlineState=i;var o=!1;e.ws.forEach(function(t,e){for(var n=0,r=e.listeners;n<r.length;n++)r[n].Is(i)&&(o=!0)}),o&&xu(e)}(n.pu,r),i.length&&n.vu.Ao(i),n.onlineState=r,n.Mu&&n.gu.ti(r))}function Ac(t,e){(t.ku.get(e)||[]).forEach(function(t){t.resolve()}),t.ku.delete(e)}function Nc(t,e,n){var r,i=t,o=i.$u[i.currentUser.Cs()];o&&((r=o.get(e))&&(n?r.reject(n):r.resolve(),o=o.remove(e)),i.$u[i.currentUser.Cs()]=o)}function Rc(e,t,n){void 0===n&&(n=null),e.gu.Ks(t);for(var r=0,i=e.Su.get(t);r<i.length;r++){var o=i[r];e.bu.delete(o),n&&e.vu.Lu(o,n)}e.Su.delete(t),e.Mu&&e.Nu.kr(t).forEach(function(t){e.Nu.Lr(t)||Sc(e,t)})}function Sc(t,e){var n=t.Du.get(e);null!==n&&(Jh(t.Pu,n),t.Du=t.Du.remove(e),t.Fu.delete(n),Lc(t))}function Dc(t,e,n){for(var r,i,o=0,s=n;o<s.length;o++){var a=s[o];a instanceof pc?(t.Nu.Cr(a.key,e),r=t,i=void 0,i=a.key,r.Du.get(i)||(Ur("SyncEngine","New document in limbo: "+i),r.Cu.push(i),Lc(r))):a instanceof dc?(Ur("SyncEngine","Document no longer in limbo: "+a.key),t.Nu.Fr(a.key,e),t.Nu.Lr(a.key)||Sc(t,a.key)):xr()}}function Lc(t){for(;0<t.Cu.length&&t.Du.size<t.Vu;){var e=t.Cu.shift(),n=t.xu.next();t.Fu.set(n,new yc(e)),t.Du=t.Du.rt(e,n),Kh(t.Pu,new Zi(Ma(Pa(e.path)),n,2,zu.Os))}}function Oc(n,s,a){return w(this,void 0,void 0,function(){var r,i,o,e;return b(this,function(t){switch(t.label){case 0:return i=[],o=[],e=[],(r=n).bu.m()?[3,3]:(r.bu.forEach(function(t,n){e.push(r.Bu(n,s,a).then(function(t){var e;t&&(r.Mu&&r.gu.zs(n.targetId,t.fromCache?"not-current":"current"),i.push(t),e=Ju.Si(n.targetId,t),o.push(e))}))}),[4,Promise.all(e)]);case 1:return t.sent(),r.vu.Ao(i),[4,function(c,l){return w(this,void 0,void 0,function(){var r,e,n,i,o,s,a,u,h;return b(this,function(t){switch(t.label){case 0:r=c,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r.persistence.runTransaction("notifyLocalViewChanges","readwrite",function(n){return Nu.forEach(l,function(e){return Nu.forEach(e.vi,function(t){return r.persistence.Ar.Cr(n,e.targetId,t)}).next(function(){return Nu.forEach(e.bi,function(t){return r.persistence.Ar.Fr(n,e.targetId,t)})})})})];case 2:return t.sent(),[3,4];case 3:if(!Du(e=t.sent()))throw e;return Ur("LocalStore","Failed to update sequence numbers: "+e),[3,4];case 4:for(n=0,i=l;n<i.length;n++)o=i[n],s=o.targetId,o.fromCache||(a=r.zi.get(s),u=a.et,h=a.it(u),r.zi=r.zi.rt(s,h));return[2]}})})}(r.Bo,o)];case 2:t.sent(),t.label=3;case 3:return[2]}})})}function Pc(i,o){return w(this,void 0,void 0,function(){var n,r;return b(this,function(t){switch(t.label){case 0:return(n=i).currentUser.isEqual(o)?[3,3]:(Ur("SyncEngine","User change. New user:",o.Cs()),[4,function(i,o){return w(this,void 0,void 0,function(){var e,n,m,r;return b(this,function(t){switch(t.label){case 0:return n=(e=i).hi,m=e.er,[4,e.persistence.runTransaction("Handle user change","readonly",function(y){var g;return e.hi.zu(y).next(function(t){return g=t,n=e.persistence.Yi(o),m=new Ku(e.Ji,n,e.persistence.nr()),n.zu(y)}).next(function(t){for(var e=[],n=[],r=mo(),i=0,o=g;i<o.length;i++){var s=o[i];e.push(s.batchId);for(var a=0,u=s.mutations;a<u.length;a++)var h=u[a],r=r.add(h.key)}for(var c=0,l=t;c<l.length;c++){var f=l[c];n.push(f.batchId);for(var p=0,d=f.mutations;p<d.length;p++){var v=d[p];r=r.add(v.key)}}return m.Ti(y,r).next(function(t){return{Ku:t,Hu:e,Yu:n}})})})];case 1:return r=t.sent(),[2,(e.hi=n,e.er=m,e.Gi.sr(e.er),r)]}})})}(n.Bo,o)]);case 1:return r=t.sent(),n.currentUser=o,(e=n).ku.forEach(function(t){t.forEach(function(t){t.reject(new Pr(Or.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.ku.clear(),n.gu.Zs(o,r.Hu,r.Yu),[4,Oc(n,r.Ku)];case 2:t.sent(),t.label=3;case 3:return[2]}var e})})}var kc,Vc=(Mc.prototype.sr=function(t){this.Ju=t},Mc.prototype.Ai=function(e,r,i,o){var s=this;return 0===r.filters.length&&null===r.limit&&null==r.startAt&&null==r.endAt&&(0===r.rn.length||1===r.rn.length&&r.rn[0].field.V())||i.isEqual(Ci.min())?this.Xu(e,r):this.Ju.Ti(e,o).next(function(t){var n=s.Zu(r,t);return(ka(r)||Va(r))&&s.du(r.on,n,o,i)?s.Xu(e,r):(_r()<=a.DEBUG&&Ur("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),za(r)),s.Ju.Ai(e,r,i).next(function(e){return n.forEach(function(t){e=e.rt(t.key,t)}),e}))})},Mc.prototype.Zu=function(n,t){var r=new ho(Qa(n));return t.forEach(function(t,e){e instanceof Aa&&Wa(n,e)&&(r=r.add(e))}),r},Mc.prototype.du=function(t,e,n,r){if(n.size!==e.size)return!0;var i="F"===t?e.last():e.first();return!!i&&(i.hasPendingWrites||0<i.version.L(r))},Mc.prototype.Xu=function(t,e){return _r()<=a.DEBUG&&Ur("IndexFreeQueryEngine","Using full collection scan to execute query:",za(e)),this.Ju.Ai(t,e,Ci.min())},Mc),_c=(jc.prototype.nc=function(t){return Nu.resolve(0===this.hi.length)},jc.prototype.Qu=function(t,e,n,r){var i=this.tc;this.tc++,0<this.hi.length&&this.hi[this.hi.length-1];var o=new Xu(i,e,n,r);this.hi.push(o);for(var s=0,a=r;s<a.length;s++){var u=a[s];this.ec=this.ec.add(new Rh(u.key,i)),this.li.Bi(t,u.key.path.h())}return Nu.resolve(o)},jc.prototype.Wu=function(t,e){return Nu.resolve(this.sc(e))},jc.prototype.yr=function(t,e){var n=e+1,r=this.ic(n),i=r<0?0:r;return Nu.resolve(this.hi.length>i?this.hi[i]:null)},jc.prototype.Gu=function(){return Nu.resolve(0===this.hi.length?-1:this.tc-1)},jc.prototype.zu=function(t){return Nu.resolve(this.hi.slice())},jc.prototype.fi=function(t,e){var n=this,r=new Rh(e,0),i=new Rh(e,Number.POSITIVE_INFINITY),o=[];return this.ec.Ft([r,i],function(t){var e=n.sc(t.qr);o.push(e)}),Nu.resolve(o)},jc.prototype.Ii=function(t,e){var r=this,i=new ho(Ii);return e.forEach(function(t){var e=new Rh(t,0),n=new Rh(t,Number.POSITIVE_INFINITY);r.ec.Ft([e,n],function(t){i=i.add(t.qr)})}),Nu.resolve(this.rc(i))},jc.prototype.gi=function(t,e){var n=e.path,r=n.length+1,i=n;Kr.N(i)||(i=i.child(""));var o=new Rh(new Kr(i),0),s=new ho(Ii);return this.ec.Nt(function(t){var e=t.key.path;return!!n.T(e)&&(e.length===r&&(s=s.add(t.qr)),!0)},o),Nu.resolve(this.rc(s))},jc.prototype.rc=function(t){var n=this,r=[];return t.forEach(function(t){var e=n.sc(t);null!==e&&r.push(e)}),r},jc.prototype.hr=function(n,r){var i=this;Br(0===this.oc(r.batchId,"removed")),this.hi.shift();var o=this.ec;return Nu.forEach(r.mutations,function(t){var e=new Rh(t.key,r.batchId);return o=o.delete(e),i.Ar.uc(n,t.key)}).next(function(){i.ec=o})},jc.prototype.cc=function(t){},jc.prototype.Lr=function(t,e){var n=new Rh(e,0),r=this.ec.$t(n);return Nu.resolve(e.isEqual(r&&r.key))},jc.prototype.lr=function(t){return this.hi.length,Nu.resolve()},jc.prototype.oc=function(t,e){return this.ic(t)},jc.prototype.ic=function(t){return 0===this.hi.length?0:t-this.hi[0].batchId},jc.prototype.sc=function(t){var e=this.ic(t);return e<0||e>=this.hi.length?null:this.hi[e]},jc),Uc=(Cc.prototype.ar=function(t,e,n){var r=e.key,i=this.docs.get(r),o=i?i.size:0,s=this.ac(e);return this.docs=this.docs.rt(r,{hc:e,size:s,readTime:n}),this.size+=s-o,this.li.Bi(t,r.path.h())},Cc.prototype.Er=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},Cc.prototype.wi=function(t,e){var n=this.docs.get(e);return Nu.resolve(n?n.hc:null)},Cc.prototype.getEntries=function(t,e){var n=this,r=lo;return e.forEach(function(t){var e=n.docs.get(t);r=r.rt(t,e?e.hc:null)}),Nu.resolve(r)},Cc.prototype.Ai=function(t,e,n){for(var r=vo,i=new Kr(e.path.child("")),o=this.docs._t(i);o.It();){var s=o.Et(),a=s.key,u=s.value,h=u.hc,c=u.readTime;if(!e.path.T(a.path))break;c.L(n)<=0||h instanceof Aa&&Wa(e,h)&&(r=r.rt(h.key,h))}return Nu.resolve(r)},Cc.prototype.lc=function(t,e){return Nu.forEach(this.docs,function(t){return e(t)})},Cc.prototype.ur=function(t){return new Cc._c(this)},Cc.prototype.fc=function(t){return Nu.resolve(this.size)},Cc);function Cc(t,e){this.li=t,this.ac=e,this.docs=new no(Kr.i),this.size=0}function jc(t,e){this.li=t,this.Ar=e,this.hi=[],this.tc=1,this.ec=new ho(Rh.vr)}function Mc(){}function xc(t){var e=this;return(e=kc.call(this)||this).Ic=t,e}function Bc(){this.ju=new _i(function(t){return t.toString()},function(t,e){return t.isEqual(e)}),this.dc=!1}Uc._c=(Object.defineProperty(Bc.prototype,"readTime",{get:function(){return this.wc},set:function(t){this.wc=t},enumerable:!1,configurable:!0}),Bc.prototype.ar=function(t,e){this.mc(),this.readTime=e,this.ju.set(t.key,t)},Bc.prototype.Er=function(t,e){this.mc(),e&&(this.readTime=e),this.ju.set(t,null)},Bc.prototype.wi=function(t,e){this.mc();var n=this.ju.get(e);return void 0!==n?Nu.resolve(n):this.Tc(t,e)},Bc.prototype.getEntries=function(t,e){return this.Ec(t,e)},Bc.prototype.apply=function(t){return this.mc(),this.dc=!0,this.wu(t)},Bc.prototype.mc=function(){},o(xc,kc=Bc),xc.prototype.wu=function(n){var r=this,i=[];return this.ju.forEach(function(t,e){e?i.push(r.Ic.ar(n,e,r.readTime)):r.Ic.Er(t)}),Nu.$n(i)},xc.prototype.Tc=function(t,e){return this.Ic.wi(t,e)},xc.prototype.Ec=function(t,e){return this.Ic.getEntries(t,e)},xc);var Fc,qc,Gc=(al.prototype.Ce=function(t,n){return this.Ac.forEach(function(t,e){return n(e)}),Nu.resolve()},al.prototype._r=function(t){return Nu.resolve(this.lastRemoteSnapshotVersion)},al.prototype.gc=function(t){return Nu.resolve(this.Rc)},al.prototype.qu=function(t){return this.highestTargetId=this.Pc.next(),Nu.resolve(this.highestTargetId)},al.prototype.Rr=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.Rc&&(this.Rc=e),Nu.resolve()},al.prototype.Vc=function(t){this.Ac.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.Pc=new uh(e),this.highestTargetId=e),t.sequenceNumber>this.Rc&&(this.Rc=t.sequenceNumber)},al.prototype.Uu=function(t,e){return this.Vc(e),this.targetCount+=1,Nu.resolve()},al.prototype.Tr=function(t,e){return this.Vc(e),Nu.resolve()},al.prototype.vc=function(t,e){return this.Ac.delete(e.target),this.yc.kr(e.targetId),--this.targetCount,Nu.resolve()},al.prototype.bc=function(n,r,i){var o=this,s=0,a=[];return this.Ac.forEach(function(t,e){e.sequenceNumber<=r&&null===i.get(e.targetId)&&(o.Ac.delete(t),a.push(o.Sc(n,e.targetId)),s++)}),Nu.$n(a).next(function(){return s})},al.prototype.Cc=function(t){return Nu.resolve(this.targetCount)},al.prototype.Pr=function(t,e){var n=this.Ac.get(e)||null;return Nu.resolve(n)},al.prototype.wr=function(t,e,n){return this.yc.Dr(e,n),Nu.resolve()},al.prototype.dr=function(e,t,n){this.yc.$r(t,n);var r=this.persistence.Ar,i=[];return r&&t.forEach(function(t){i.push(r.uc(e,t))}),Nu.$n(i)},al.prototype.Sc=function(t,e){return this.yc.kr(e),Nu.resolve()},al.prototype.pr=function(t,e){var n=this.yc.Mr(e);return Nu.resolve(n)},al.prototype.Lr=function(t,e){return Nu.resolve(this.yc.Lr(e))},al),zc=(sl.prototype.start=function(){return Promise.resolve()},sl.prototype.ei=function(){return this.Nc=!1,Promise.resolve()},Object.defineProperty(sl.prototype,"kc",{get:function(){return this.Nc},enumerable:!1,configurable:!0}),sl.prototype.xc=function(){},sl.prototype.Oc=function(){},sl.prototype.nr=function(){return this.li},sl.prototype.Yi=function(t){var e=this.Dc[t.Cs()];return e||(e=new _c(this.li,this.Ar),this.Dc[t.Cs()]=e),e},sl.prototype.tr=function(){return this.Zi},sl.prototype.Xi=function(){return this.ai},sl.prototype.runTransaction=function(t,e,n){var r=this;Ur("MemoryPersistence","Starting transaction:",t);var i=new Wc(this.Fc.next());return this.Ar.Mc(),n(i).next(function(t){return r.Ar.Lc(i).next(function(){return t})}).Fn().then(function(t){return i.qc(),t})},sl.prototype.Uc=function(e,n){return Nu.kn(Object.values(this.Dc).map(function(t){return function(){return t.Lr(e,n)}}))},sl),Wc=(ol.prototype.Qc=function(t){this.Bc.push(t)},ol.prototype.qc=function(){this.Bc.forEach(function(t){return t()})},o(il,qc=ol),il),Qc=(rl.Gc=function(t){return new rl(t)},Object.defineProperty(rl.prototype,"zc",{get:function(){if(this.Wc)return this.Wc;throw xr()},enumerable:!1,configurable:!0}),rl.prototype.Cr=function(t,e,n){return this.jc.Cr(n,e),this.zc.delete(n.toString()),Nu.resolve()},rl.prototype.Fr=function(t,e,n){return this.jc.Fr(n,e),this.zc.add(n.toString()),Nu.resolve()},rl.prototype.uc=function(t,e){return this.zc.add(e.toString()),Nu.resolve()},rl.prototype.removeTarget=function(t,e){var n=this;this.jc.kr(e.targetId).forEach(function(t){return n.zc.add(t.toString())});var r=this.persistence.tr();return r.pr(t,e.targetId).next(function(t){t.forEach(function(t){return n.zc.add(t.toString())})}).next(function(){return r.vc(t,e)})},rl.prototype.Mc=function(){this.Wc=new Set},rl.prototype.Lc=function(n){var r=this,i=this.persistence.Xi().ur();return Nu.forEach(this.zc,function(t){var e=Kr.C(t);return r.Kc(n,e).next(function(t){t||i.Er(e)})}).next(function(){return r.Wc=null,i.apply(n)})},rl.prototype.Ir=function(t,e){var n=this;return this.Kc(t,e).next(function(t){t?n.zc.delete(e.toString()):n.zc.add(e.toString())})},rl.prototype.$c=function(t){return 0},rl.prototype.Kc=function(t,e){var n=this;return Nu.kn([function(){return Nu.resolve(n.jc.Lr(e))},function(){return n.persistence.tr().Lr(t,e)},function(){return n.persistence.Uc(t,e)}])},rl),Hc=(nl.prototype.Eo=function(t){this.Jc=t},nl.prototype.fo=function(t){this.Xc=t},nl.prototype.onMessage=function(t){this.Zc=t},nl.prototype.close=function(){this.Yc()},nl.prototype.send=function(t){this.Hc(t)},nl.prototype.ta=function(){this.Jc()},nl.prototype.ea=function(t){this.Xc(t)},nl.prototype.na=function(t){this.Zc(t)},nl),Xc={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"},Yc=(el.prototype.Fo=function(e,t,n,r){var i=this.oa(e,t);Ur("RestConnection","Sending: ",i,n);var o={};return this.ua(o,r),this.ca(e,i,o,n).then(function(t){return Ur("RestConnection","Received: ",t),t},function(t){throw jr("RestConnection",e+" failed with error: ",t,"url: ",i,"request:",n),t})},el.prototype.No=function(t,e,n,r){return this.Fo(t,e,n,r)},el.prototype.ua=function(t,e){if(t["X-Goog-Api-Client"]="gl-js/ fire/7.22.0",t["Content-Type"]="text/plain",e)for(var n in e.Ur)e.Ur.hasOwnProperty(n)&&(t[n]=e.Ur[n])},el.prototype.oa=function(t,e){var n=Xc[t];return this.ia+"/v1/"+e+":"+n},o(tl,Fc=el),tl.prototype.ca=function(u,e,n,r){return new Promise(function(o,s){var a=new Rr;a.listenOnce(Ar.COMPLETE,function(){try{switch(a.getLastErrorCode()){case Tr.NO_ERROR:var t=a.getResponseJson();Ur("Connection","XHR received:",JSON.stringify(t)),o(t);break;case Tr.TIMEOUT:Ur("Connection",'RPC "'+u+'" timed out'),s(new Pr(Or.DEADLINE_EXCEEDED,"Request time out"));break;case Tr.HTTP_ERROR:var e,n,r=a.getStatus();Ur("Connection",'RPC "'+u+'" failed with status:',r,"response text:",a.getResponseText()),0<r?(e=a.getResponseJson().error)&&e.status&&e.message?(i=e.status.toLowerCase().replace("_","-"),n=0<=Object.values(Or).indexOf(i)?i:Or.UNKNOWN,s(new Pr(n,e.message))):s(new Pr(Or.UNKNOWN,"Server responded with status "+a.getStatus())):s(new Pr(Or.UNAVAILABLE,"Connection failed."));break;default:xr()}}finally{Ur("Connection",'RPC "'+u+'" completed.')}var i});var t=JSON.stringify(r);a.send(e,"POST",t,n,15)})},tl.prototype.Io=function(t,e){var n,r,i=[this.ia,"/","google.firestore.v1.Firestore","/",t,"/channel"],o=Ir(),s={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.B.projectId+"/databases/"+this.B.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling};this.ua(s.initMessageHeaders,e),"undefined"!=typeof window&&(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(v())||"object"==typeof navigator&&"ReactNative"===navigator.product||0<=v().indexOf("Electron/")||(0<=(r=v()).indexOf("MSIE ")||0<=r.indexOf("Trident/"))||0<=v().indexOf("MSAppHost/")||"object"==typeof(n="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0)&&void 0!==n.id||(s.httpHeadersOverwriteParam="$httpHeaders");var a=i.join("");Ur("Connection","Creating WebChannel: "+a,s);function u(t,e){h.listen(t,function(t){try{e(t)}catch(t){setTimeout(function(){throw t},0)}})}var h=o.createWebChannel(a,s),c=!1,l=!1,f=new Hc({Hc:function(t){l?Ur("Connection","Not sending because WebChannel is closed:",t):(c||(Ur("Connection","Opening WebChannel transport."),h.open(),c=!0),Ur("Connection","WebChannel sending:",t),h.send(t))},Yc:function(){return h.close()}});return u(Nr.EventType.OPEN,function(){l||Ur("Connection","WebChannel transport opened.")}),u(Nr.EventType.CLOSE,function(){l||(l=!0,Ur("Connection","WebChannel transport closed"),f.ea())}),u(Nr.EventType.ERROR,function(t){l||(l=!0,jr("Connection","WebChannel transport errored:",t),f.ea(new Pr(Or.UNAVAILABLE,"The operation could not be completed")))}),u(Nr.EventType.MESSAGE,function(t){var e,n,r,i,o,s;l||(Br(!!(n=t.data[0])),(r=n.error||(null===(e=n[0])||void 0===e?void 0:e.error))?(Ur("Connection","WebChannel received error:",r),i=r.status,o=function(){var t=Ki[i];if(void 0!==t)return eo(t)}(),s=r.message,void 0===o&&(o=Or.INTERNAL,s="Unknown error status: "+i+" with message "+r.message),l=!0,f.ea(new Pr(o,s)),h.close()):(Ur("Connection","WebChannel received:",n),f.na(n)))}),setTimeout(function(){f.ta()},0),f},tl),Kc=($c.prototype.Yo=function(t){this.fa.push(t)},$c.prototype.ei=function(){window.removeEventListener("online",this.aa),window.removeEventListener("offline",this.la)},$c.prototype.da=function(){window.addEventListener("online",this.aa),window.addEventListener("offline",this.la)},$c.prototype.ha=function(){Ur("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.fa;t<e.length;t++)(0,e[t])(0)},$c.prototype._a=function(){Ur("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.fa;t<e.length;t++)(0,e[t])(1)},$c.wa=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},$c),Jc=(Zc.prototype.Yo=function(t){},Zc.prototype.ei=function(){},Zc);function Zc(){}function $c(){var t=this;this.aa=function(){return t.ha()},this.la=function(){return t._a()},this.fa=[],this.da()}function tl(t){var e=this;return(e=Fc.call(this,t)||this).forceLongPolling=t.forceLongPolling,e}function el(t){this.sa=t,this.B=t.B;var e=t.ssl?"https":"http";this.ia=e+"://"+t.host,this.ra="projects/"+this.B.projectId+"/databases/"+this.B.database+"/documents"}function nl(t){this.Hc=t.Hc,this.Yc=t.Yc}function rl(t){this.persistence=t,this.jc=new Nh,this.Wc=null}function il(t){var e=this;return(e=qc.call(this)||this).mr=t,e}function ol(){this.Bc=[]}function sl(t){var e=this;this.Dc={},this.Fc=new zu(0),this.Nc=!1,this.Nc=!0,this.Ar=t(this),this.Zi=new Gc(this),this.li=new sh,this.ai=new Uc(this.li,function(t){return e.Ar.$c(t)})}function al(t){this.persistence=t,this.Ac=new _i(Qi,Hi),this.lastRemoteSnapshotVersion=Ci.min(),this.highestTargetId=0,this.Rc=0,this.yc=new Nh,this.targetCount=0,this.Pc=uh.ji()}function ul(t){return new os(t,!0)}var hl,cl,ll="You are using the memory-only build of Firestore. Persistence support is only available via the @firebase/firestore bundle or the firebase-firestore.js build.",fl=(Al.prototype.initialize=function(e){return w(this,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return this.gu=this.ma(e),this.persistence=this.Ta(e),[4,this.persistence.start()];case 1:return t.sent(),this.Ea=this.Ia(e),this.Bo=this.Aa(e),[2]}})})},Al.prototype.Ia=function(t){return null},Al.prototype.Aa=function(t){return e=this.persistence,n=new Vc,r=t.Ra,new hh(e,n,r);var e,n,r},Al.prototype.Ta=function(t){if(t.persistenceSettings.ya)throw new Pr(Or.FAILED_PRECONDITION,ll);return new zc(Qc.Gc)},Al.prototype.ma=function(t){return new Hu},Al.prototype.terminate=function(){return w(this,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return this.Ea&&this.Ea.stop(),[4,this.gu.ei()];case 1:return t.sent(),[4,this.persistence.ei()];case 2:return t.sent(),[2]}})})},Al.prototype.clearPersistence=function(t,e){throw new Pr(Or.FAILED_PRECONDITION,ll)},Al),pl=(Tl.prototype.initialize=function(n,r){return w(this,void 0,void 0,function(){var e=this;return b(this,function(t){switch(t.label){case 0:return this.Bo?[3,2]:(this.Bo=n.Bo,this.gu=n.gu,this.Qo=this.Pa(r),this.Pu=this.pa(r),this.pu=this.ga(r),this.Va=this.va(r),this.gu.Qs=function(t){return Tc(e.Va,t,1)},this.Pu.jo.ba=Pc.bind(null,this.Va),[4,function(n,r){return w(this,void 0,void 0,function(){var e;return b(this,function(t){switch(t.label){case 0:return e=n,r?(e.zo.delete(2),[4,Hh(e)]):[3,2];case 1:return t.sent(),[3,5];case 2:return r?[3,4]:(e.zo.add(2),[4,Xh(e)]);case 3:t.sent(),e.Jo.set("Unknown"),t.label=4;case 4:t.label=5;case 5:return[2]}})})}(this.Pu,this.Va.Mu)]);case 1:t.sent(),t.label=2;case 2:return[2]}})})},Tl.prototype.ga=function(t){return new Cu},Tl.prototype.Pa=function(t){var e,n,r=ul(t.sa.B),i=(e=t.sa,new Yc(e));return n=t.credentials,new _h(n,i,r)},Tl.prototype.pa=function(t){var e=this,n=this.Bo,r=this.Qo,i=t.xn,o=function(t){return Tc(e.Va,t,0)},s=new(Kc.wa()?Kc:Jc);return new Eh(n,r,i,o,s)},Tl.prototype.va=function(t){return e=this.Bo,n=this.Pu,r=this.pu,i=this.gu,o=t.Ra,s=t.Vu,a=!t.persistenceSettings.ya||!t.persistenceSettings.synchronizeTabs,u=new gc(e,n,r,i,o,s),a&&(u.Ou=!0),u;var e,n,r,i,o,s,a,u},Tl.prototype.terminate=function(){return Yh(this.Pu)},Tl),dl=(Il.prototype.next=function(t){this.observer.next&&this.Sa(this.observer.next,t)},Il.prototype.error=function(t){this.observer.error?this.Sa(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)},Il.prototype.Ca=function(){this.muted=!0},Il.prototype.Sa=function(t,e){var n=this;this.muted||setTimeout(function(){n.muted||t(e)},0)},Il),vl=function(t){!function(){if(!(t instanceof Array)||t.length<1)throw new Pr(Or.INVALID_ARGUMENT,"Function FieldPath() requires its fieldNames argument to be an array with at least 1 element.")}();for(var e=0;e<t.length;++e)if(oi("FieldPath","string",e,t[e]),0===t[e].length)throw new Pr(Or.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this.Da=new Yr(t)},yl=(o(El,cl=vl),El.documentId=function(){return new El(Yr.v().R())},El.prototype.isEqual=function(t){if(!(t instanceof El))throw yi("isEqual","FieldPath",1,t);return this.Da.isEqual(t.Da)},El),gl=new RegExp("[~\\*/\\[\\]]"),ml=function(t){this.Fa=t},wl=(o(bl,hl=ml),bl.prototype.Na=function(t){if(2!==t.$a)throw 1===t.$a?t.ka(this.Fa+"() can only appear at the top level of your update data"):t.ka(this.Fa+"() cannot be used with set() unless you pass {merge:true}");return t.Qe.push(t.path),null},bl.prototype.isEqual=function(t){return t instanceof bl},bl);function bl(){return null!==hl&&hl.apply(this,arguments)||this}function El(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return cl.call(this,t)||this}function Il(t){this.observer=t,this.muted=!1}function Tl(){}function Al(){}function Nl(t,e,n){return new Xl({$a:3,xa:e.settings.xa,methodName:t.Fa,Oa:n},e.B,e.serializer,e.ignoreUndefinedProperties)}var Rl,Sl,Dl,Ll,Ol=(o(Ql,Ll=ml),Ql.prototype.Na=function(t){return new Fs(t.path,new Ss)},Ql.prototype.isEqual=function(t){return t instanceof Ql},Ql),Pl=(o(Wl,Dl=ml),Wl.prototype.Na=function(t){var e=Nl(this,t,!0),n=this.Ma.map(function(t){return nf(t,e)}),r=new Ds(n);return new Fs(t.path,r)},Wl.prototype.isEqual=function(t){return this===t},Wl),kl=(o(zl,Sl=ml),zl.prototype.Na=function(t){var e=Nl(this,t,!0),n=this.Ma.map(function(t){return nf(t,e)}),r=new Vs(n);return new Fs(t.path,r)},zl.prototype.isEqual=function(t){return this===t},zl),Vl=(o(Gl,Rl=ml),Gl.prototype.Na=function(t){var e=new js(t.serializer,us(t.serializer,this.La));return new Fs(t.path,e)},Gl.prototype.isEqual=function(t){return this===t},Gl),_l=(Object.defineProperty(ql.prototype,"latitude",{get:function(){return this.qa},enumerable:!1,configurable:!0}),Object.defineProperty(ql.prototype,"longitude",{get:function(){return this.Ua},enumerable:!1,configurable:!0}),ql.prototype.isEqual=function(t){return this.qa===t.qa&&this.Ua===t.Ua},ql.prototype.toJSON=function(){return{latitude:this.qa,longitude:this.Ua}},ql.prototype.H=function(t){return Ii(this.qa,t.qa)||Ii(this.Ua,t.Ua)},ql),Ul=function(t){this.Ba=t},Cl=/^__.*__$/,jl=function(t,e,n){this.Qa=t,this.ja=e,this.Wa=n},Ml=(Fl.prototype.Ga=function(t,e){var n=[];return null!==this.Qe?n.push(new na(t,this.data,this.Qe,e)):n.push(new ea(t,this.data,e)),0<this.fieldTransforms.length&&n.push(new aa(t,this.fieldTransforms)),n},Fl),xl=(Bl.prototype.Ga=function(t,e){var n=[new na(t,this.data,this.Qe,e)];return 0<this.fieldTransforms.length&&n.push(new aa(t,this.fieldTransforms)),n},Bl);function Bl(t,e,n){this.data=t,this.Qe=e,this.fieldTransforms=n}function Fl(t,e,n){this.data=t,this.Qe=e,this.fieldTransforms=n}function ql(t,e){if(ni("GeoPoint",arguments,2),oi("GeoPoint","number",1,t),oi("GeoPoint","number",2,e),!isFinite(t)||t<-90||90<t)throw new Pr(Or.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||180<e)throw new Pr(Or.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this.qa=t,this.Ua=e}function Gl(t,e){var n=this;return(n=Rl.call(this,t)||this).La=e,n}function zl(t,e){var n=this;return(n=Sl.call(this,t)||this).Ma=e,n}function Wl(t,e){var n=this;return(n=Dl.call(this,t)||this).Ma=e,n}function Ql(){return null!==Ll&&Ll.apply(this,arguments)||this}function Hl(t){switch(t){case 0:case 2:case 1:return 1;case 3:case 4:return;default:throw xr()}}var Xl=(Object.defineProperty(Jl.prototype,"path",{get:function(){return this.settings.path},enumerable:!1,configurable:!0}),Object.defineProperty(Jl.prototype,"$a",{get:function(){return this.settings.$a},enumerable:!1,configurable:!0}),Jl.prototype.Ka=function(t){return new Jl(Object.assign(Object.assign({},this.settings),t),this.B,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.Qe)},Jl.prototype.Ha=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.Ka({path:n,Oa:!1});return r.Ya(t),r},Jl.prototype.Ja=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.Ka({path:n,Oa:!1});return r.za(),r},Jl.prototype.Xa=function(t){return this.Ka({path:void 0,Oa:!0})},Jl.prototype.ka=function(t){return hf(t,this.settings.methodName,this.settings.Za||!1,this.path,this.settings.xa)},Jl.prototype.contains=function(e){return void 0!==this.Qe.find(function(t){return e.T(t)})||void 0!==this.fieldTransforms.find(function(t){return e.T(t.field)})},Jl.prototype.za=function(){if(this.path)for(var t=0;t<this.path.length;t++)this.Ya(this.path.get(t))},Jl.prototype.Ya=function(t){if(0===t.length)throw this.ka("Document fields must not be empty");if(Hl(this.$a)&&Cl.test(t))throw this.ka('Document fields cannot begin and end with "__"')},Jl),Yl=(Kl.prototype.th=function(t,e,n,r){return void 0===r&&(r=!1),new Xl({$a:t,methodName:e,xa:n,path:Yr.p(),Oa:!1,Za:r},this.B,this.serializer,this.ignoreUndefinedProperties)},Kl);function Kl(t,e,n){this.B=t,this.ignoreUndefinedProperties=e,this.serializer=n||ul(t)}function Jl(t,e,n,r,i,o){this.settings=t,this.B=e,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===i&&this.za(),this.fieldTransforms=i||[],this.Qe=o||[]}function Zl(t,e,n,r,i,o){void 0===o&&(o={});var s=t.th(o.merge||o.mergeFields?2:0,e,n,i);sf("Data must be an object, but it was:",s,r);var a,u,h=rf(r,s);if(o.merge)a=new qs(s.Qe),u=s.fieldTransforms;else if(o.mergeFields){for(var c=[],l=0,f=o.mergeFields;l<f.length;l++){var p=f[l],d=void 0;if(p instanceof vl)d=p.Da;else{if("string"!=typeof p)throw xr();d=uf(e,p,n)}if(!s.contains(d))throw new Pr(Or.INVALID_ARGUMENT,"Field '"+d+"' is specified in your field mask but missing from your input data.");cf(c,d)||c.push(d)}a=new qs(c),u=s.fieldTransforms.filter(function(t){return a.Ke(t.field)})}else a=null,u=s.fieldTransforms;return new Ml(new da(h),a,u)}function $l(t,o,s,e){var a=t.th(1,o,s);sf("Data must be an object, but it was:",a,e);var u=[],h=new va;qr(e,function(t,e){var n,r=uf(o,t,s),i=a.Ja(r);e instanceof wl||e instanceof Ul&&e.Ba instanceof wl?u.push(r):null!=(n=nf(e,i))&&(u.push(r),h.set(r,n))});var n=new qs(u);return new xl(h.Je(),n,a.fieldTransforms)}function tf(t,e,n,r,i,o){var s=t.th(1,e,n),a=[af(e,r,n)],u=[i];if(o.length%2!=0)throw new Pr(Or.INVALID_ARGUMENT,"Function "+e+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var h=0;h<o.length;h+=2)a.push(af(e,o[h])),u.push(o[h+1]);for(var c,l,f,p,d=[],v=new va,y=a.length-1;0<=y;--y){cf(d,a[y])||(c=a[y],l=u[y],f=s.Ja(c),l instanceof wl||l instanceof Ul&&l.Ba instanceof wl?d.push(c):null!=(p=nf(l,f))&&(d.push(c),v.set(c,p)))}var g=new qs(d);return new xl(v.Je(),g,s.fieldTransforms)}function ef(t,e,n,r){return void 0===r&&(r=!1),nf(n,t.th(r?4:3,e))}function nf(s,t){if(s instanceof Ul&&(s=s.Ba),of(s))return sf("Unsupported field value:",t,s),rf(s,t);if(s instanceof ml)return function(t,e){if(!Hl(e.$a))throw e.ka(t.Fa+"() can only be used with update() and set()");if(!e.path)throw e.ka(t.Fa+"() is not currently supported inside arrays");var n=t.Na(e);n&&e.fieldTransforms.push(n)}(s,t),null;if(t.path&&t.Qe.push(t.path),s instanceof Array){if(t.settings.Oa&&4!==t.$a)throw t.ka("Nested arrays are not supported");return function(t){for(var e=[],n=0,r=0,i=s;r<i.length;r++){var o=nf(i[r],t.Xa(n));null==o&&(o={nullValue:"NULL_VALUE"}),e.push(o),n++}return{arrayValue:{values:e}}}(t)}return function(t,e){if(null===t)return{nullValue:"NULL_VALUE"};if("number"==typeof t)return us(e.serializer,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var n=Ui.fromDate(t);return{timestampValue:hs(e.serializer,n)}}if(t instanceof Ui){var r=new Ui(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:hs(e.serializer,r)}}if(t instanceof _l)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof Ri)return{bytesValue:cs(e.serializer,t.U)};if(t instanceof jl){var i=e.B,o=t.Qa;if(!o.isEqual(i))throw e.ka("Document reference is for database "+o.projectId+"/"+o.database+" but should be for database "+i.projectId+"/"+i.database);return{referenceValue:fs(t.Qa||e.B,t.ja.path)}}if(void 0===t&&e.ignoreUndefinedProperties)return null;throw e.ka("Unsupported field value: "+pi(t))}(s,t)}function rf(t,r){var i={};return Gr(t)?r.path&&0<r.path.length&&r.Qe.push(r.path):qr(t,function(t,e){var n=nf(e,r.Ha(t));null!=n&&(i[t]=n)}),{mapValue:{fields:i}}}function of(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Ui||t instanceof _l||t instanceof Ri||t instanceof jl||t instanceof ml)}function sf(t,e,n){if(!of(n)||!fi(n)){var r=pi(n);throw"an object"===r?e.ka(t+" a custom object"):e.ka(t+" "+r)}}function af(t,e,n){if(e instanceof vl)return e.Da;if("string"==typeof e)return uf(t,e);throw hf("Field path arguments must be of type string or FieldPath.",t,!1,void 0,n)}function uf(t,e,n){try{return function(e){if(0<=e.search(gl))throw new Pr(Or.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new(yl.bind.apply(yl,s([void 0],e.split("."))))}catch(t){throw new Pr(Or.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'")}}(e).Da}catch(e){throw hf(e instanceof Error?e.message:e.toString(),t,!1,void 0,n)}}function hf(t,e,n,r,i){var o=r&&!r.m(),s=void 0!==i,a="Function "+e+"() called with invalid data";n&&(a+=" (via `toFirestore()`)");var u="";return(o||s)&&(u+=" (found",o&&(u+=" in field "+r),s&&(u+=" in document "+i),u+=")"),new Pr(Or.INVALID_ARGUMENT,(a+=". ")+t+u)}function cf(t,e){return t.some(function(t){return t.isEqual(e)})}var lf=(yf.prototype.rh=function(r){return w(this,void 0,void 0,function(){var e,n=this;return b(this,function(t){switch(t.label){case 0:if(this.oh(),0<this.mutations.length)throw new Pr(Or.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,function(a,u){return w(this,void 0,void 0,function(){var i,e,n,r,o,s;return b(this,function(t){switch(t.label){case 0:return e=ys((i=a).serializer)+"/documents",n={documents:u.map(function(t){return ps(i.serializer,t)})},[4,i.No("BatchGetDocuments",e,n)];case 1:return r=t.sent(),o=new Map,r.forEach(function(t){var e,n,r=(e=i.serializer,"found"in(n=t)?function(t,e){Br(!!e.found),e.found.name,e.found.updateTime;var n=ds(t,e.found.name),r=ls(e.found.updateTime),i=new da({mapValue:{fields:e.found.fields}});return new Aa(n,r,i,{})}(e,n):"missing"in n?function(t,e){Br(!!e.missing),Br(!!e.readTime);var n=ds(t,e.missing),r=ls(e.readTime);return new Na(n,r)}(e,n):xr());o.set(r.key.toString(),r)}),s=[],[2,(u.forEach(function(t){var e=o.get(t.toString());Br(!!e),s.push(e)}),s)]}})})}(this.Qo,r)];case 1:return[2,((e=t.sent()).forEach(function(t){t instanceof Na||t instanceof Aa?n.uh(t):xr()}),e)]}})})},yf.prototype.set=function(t,e){this.write(e.Ga(t,this.Ge(t))),this.ih.add(t.toString())},yf.prototype.update=function(t,e){try{this.write(e.Ga(t,this.ah(t)))}catch(t){this.sh=t}this.ih.add(t.toString())},yf.prototype.delete=function(t){this.write([new fa(t,this.Ge(t))]),this.ih.add(t.toString())},yf.prototype.commit=function(){return w(this,void 0,void 0,function(){var e,r=this;return b(this,function(t){switch(t.label){case 0:if(this.oh(),this.sh)throw this.sh;return e=this.eh,this.mutations.forEach(function(t){e.delete(t.key.toString())}),e.forEach(function(t,e){var n=Kr.C(e);r.mutations.push(new pa(n,r.Ge(n)))}),[4,function(i,o){return w(this,void 0,void 0,function(){var e,n,r;return b(this,function(t){switch(t.label){case 0:return n=ys((e=i).serializer)+"/documents",r={writes:o.map(function(t){return ms(e.serializer,t)})},[4,e.Fo("Commit",n,r)];case 1:return t.sent(),[2]}})})}(this.Qo,this.mutations)];case 1:return t.sent(),this.nh=!0,[2]}})})},yf.prototype.uh=function(t){var e;if(t instanceof Aa)e=t.version;else{if(!(t instanceof Na))throw xr();e=Ci.min()}var n=this.eh.get(t.key.toString());if(n){if(!e.isEqual(n))throw new Pr(Or.ABORTED,"Document version changed between two reads.")}else this.eh.set(t.key.toString(),e)},yf.prototype.Ge=function(t){var e=this.eh.get(t.toString());return!this.ih.has(t.toString())&&e?Ws.updateTime(e):Ws.He()},yf.prototype.ah=function(t){var e=this.eh.get(t.toString());if(this.ih.has(t.toString())||!e)return Ws.exists(!0);if(e.isEqual(Ci.min()))throw new Pr(Or.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Ws.updateTime(e)},yf.prototype.write=function(t){this.oh(),this.mutations=this.mutations.concat(t)},yf.prototype.oh=function(){},yf),ff=(vf.prototype.run=function(){this.lh()},vf.prototype.lh=function(){var t=this;this.Jn.Rn(function(){return w(t,void 0,void 0,function(){var e,n,r=this;return b(this,function(t){return e=new lf(this.Qo),(n=this._h(e))&&n.then(function(t){r.xn.Qn(function(){return e.commit().then(function(){r.Ln.resolve(t)}).catch(function(t){r.fh(t)})})}).catch(function(t){r.fh(t)}),[2]})})})},vf.prototype._h=function(t){try{var e=this.updateFunction(t);return!qi(e)&&e.catch&&e.then?e:(this.Ln.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.Ln.reject(t),null}},vf.prototype.fh=function(t){var e=this;0<this.hh&&this.dh(t)?(--this.hh,this.xn.Qn(function(){return e.lh(),Promise.resolve()})):this.Ln.reject(t)},vf.prototype.dh=function(t){if("FirebaseError"!==t.name)return!1;var e=t.code;return"aborted"===e||"failed-precondition"===e||!to(e)},vf),pf=(df.prototype.start=function(t,e,n,r){var i=this;this.mh(),this.sa=t;var o=new Tu,s=!1;return this.credentials.jr(function(t){return s?void i.xn.rs(function(){return function(r,i){return w(this,void 0,void 0,function(){var e,n;return b(this,function(t){switch(t.label){case 0:return(e=r).xn.cs(),Ur("RemoteStore","RemoteStore received new credentials"),n=nc(e),e.zo.add(3),[4,Xh(e)];case 1:return t.sent(),n&&e.Jo.set("Unknown"),[4,e.jo.ba(i)];case 2:return t.sent(),e.zo.delete(3),[4,Hh(e)];case 3:return t.sent(),[2]}})})}(i.Pu,t)}):(s=!0,Ur("FirestoreClient","Initializing. user=",t.uid),i.Th(e,n,r,t,o).then(i.wh.resolve,i.wh.reject))}),this.xn.Qn(function(){return i.wh.promise}),o.promise},df.prototype.enableNetwork=function(){var e=this;return this.mh(),this.xn.enqueue(function(){return e.persistence.Oc(!0),(t=e.Pu).zo.delete(0),Hh(t);var t})},df.prototype.Th=function(i,o,s,a,u){return w(this,void 0,void 0,function(){var e,n,r=this;return b(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),e={xn:this.xn,sa:this.sa,clientId:this.clientId,credentials:this.credentials,Ra:a,Vu:100,persistenceSettings:s},[4,i.initialize(e)];case 1:return t.sent(),[4,o.initialize(i,e)];case 2:return t.sent(),this.persistence=i.persistence,this.gu=i.gu,this.Bo=i.Bo,this.Ea=i.Ea,this.Qo=o.Qo,this.Pu=o.Pu,this.Va=o.Va,this.Eh=o.pu,this.Eh.Es=bc.bind(null,this.Va),this.Eh.Rs=function(i,o){return w(this,void 0,void 0,function(){var e,n,r;return b(this,function(t){switch(t.label){case 0:return n=(e=i).bu.get(o),1<(r=e.Su.get(n.targetId)).length?[2,(e.Su.set(n.targetId,r.filter(function(t){return!qa(t,o)})),void e.bu.delete(o))]:e.Mu?(e.gu.Ks(n.targetId),e.gu.Xs(n.targetId)?[3,2]:[4,gh(e.Bo,n.targetId,!1).then(function(){e.gu.Ys(n.targetId),Jh(e.Pu,n.targetId),Rc(e,n.targetId)}).catch(wh)]):[3,3];case 1:t.sent(),t.label=2;case 2:return[3,5];case 3:return Rc(e,n.targetId),[4,gh(e.Bo,n.targetId,!0)];case 4:t.sent(),t.label=5;case 5:return[2]}})})}.bind(null,this.Va),this.persistence.xc(function(){return w(r,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return[4,this.terminate()];case 1:return t.sent(),[2]}})})}),u.resolve(),[3,4];case 3:if(n=t.sent(),u.reject(n),!this.Ih(n))throw n;return[2,(console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+n),this.Th(new fl,new pl,{ya:!1},a,u))];case 4:return[2]}})})},df.prototype.Ih=function(t){return"FirebaseError"===t.name?t.code===Or.FAILED_PRECONDITION||t.code===Or.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code},df.prototype.mh=function(){if(this.xn.Zn)throw new Pr(Or.FAILED_PRECONDITION,"The client has already been terminated.")},df.prototype.disableNetwork=function(){var t=this;return this.mh(),this.xn.enqueue(function(){return t.persistence.Oc(!1),function(n){return w(this,void 0,void 0,function(){var e;return b(this,function(t){switch(t.label){case 0:return(e=n).zo.add(0),[4,Xh(e)];case 1:return t.sent(),e.Jo.set("Offline"),[2]}})})}(t.Pu)})},df.prototype.terminate=function(){var t=this;this.xn.ss();var r=new Tu;return this.xn.ts(function(){return w(t,void 0,void 0,function(){var e,n;return b(this,function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),this.Ea&&this.Ea.stop(),[4,Yh(this.Pu)];case 1:return t.sent(),[4,this.gu.ei()];case 2:return t.sent(),[4,this.persistence.ei()];case 3:return t.sent(),this.credentials.Wr(),r.resolve(),[3,5];case 4:return e=t.sent(),n=_u(e,"Failed to shutdown persistence"),r.reject(n),[3,5];case 5:return[2]}})})}),r.promise},df.prototype.waitForPendingWrites=function(){var t=this;this.mh();var e=new Tu;return this.xn.Qn(function(){return function(a,u){return w(this,void 0,void 0,function(){var n,r,i,o,s;return b(this,function(t){switch(t.label){case 0:nc((n=a).Pu)||Ur("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.Bo).persistence.runTransaction("Get highest unacknowledged batch id","readonly",function(t){return e.hi.Gu(t)})];case 2:return-1===(r=t.sent())?[2,void u.resolve()]:((i=n.ku.get(r)||[]).push(u),n.ku.set(r,i),[3,4]);case 3:return o=t.sent(),s=_u(o,"Initialization of waitForPendingWrites() operation failed"),u.reject(s),[3,4];case 4:return[2]}var e})})}(t.Va,e)}),e.promise},df.prototype.listen=function(t,e,n){var r=this;this.mh();var i=new dl(n),o=new Bu(t,i,e);return this.xn.Qn(function(){return ju(r.Eh,o)}),function(){i.Ca(),r.xn.Qn(function(){return Mu(r.Eh,o)})}},df.prototype.Ah=function(r){return w(this,void 0,void 0,function(){var e,n=this;return b(this,function(t){switch(t.label){case 0:return this.mh(),[4,this.wh.promise];case 1:return t.sent(),e=new Tu,[2,(this.xn.Qn(function(){return function(s,a,u){return w(this,void 0,void 0,function(){var r,i,o;return b(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,(e=a,(n=s).persistence.runTransaction("read document","readonly",function(t){return n.er._i(t,e)}))];case 1:return(r=t.sent())instanceof Aa?u.resolve(r):r instanceof Na?u.resolve(null):u.reject(new Pr(Or.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 i=t.sent(),o=_u(i,"Failed to get document '"+a+" from cache"),u.reject(o),[3,3];case 3:return[2]}var e,n})})}(n.Bo,r,e)}),e.promise)]}})})},df.prototype.Rh=function(h,c){return void 0===c&&(c={}),w(this,void 0,void 0,function(){var e,u=this;return b(this,function(t){switch(t.label){case 0:return this.mh(),[4,this.wh.promise];case 1:return t.sent(),e=new Tu,[2,(this.xn.Qn(function(){return n=u.Eh,r=u.xn,i=h,o=c,s=e,t=new dl({next:function(t){r.Qn(function(){return Mu(n,a)});var e=t.docs.has(i);!e&&t.fromCache?s.reject(new Pr(Or.UNAVAILABLE,"Failed to get document because the client is offline.")):e&&t.fromCache&&o&&"server"===o.source?s.reject(new Pr(Or.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 Bu(Pa(i.path),t,{includeMetadataChanges:!0,bs:!0}),ju(n,a);var n,r,i,o,s,t,a}),e.promise)]}})})},df.prototype.yh=function(r){return w(this,void 0,void 0,function(){var e,n=this;return b(this,function(t){switch(t.label){case 0:return this.mh(),[4,this.wh.promise];case 1:return t.sent(),e=new Tu,[2,(this.xn.Qn(function(){return function(a,u,h){return w(this,void 0,void 0,function(){var e,n,r,i,o,s;return b(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,mh(a,u,!0)];case 1:return e=t.sent(),n=new vc(u,e.gr),r=n.lu(e.documents),i=n.wu(r,!1),h.resolve(i.snapshot),[3,3];case 2:return o=t.sent(),s=_u(o,"Failed to execute query '"+u+" against cache"),h.reject(s),[3,3];case 3:return[2]}})})}(n.Bo,r,e)}),e.promise)]}})})},df.prototype.Ph=function(h,c){return void 0===c&&(c={}),w(this,void 0,void 0,function(){var a,u=this;return b(this,function(t){switch(t.label){case 0:return this.mh(),[4,this.wh.promise];case 1:return t.sent(),a=new Tu,[2,(this.xn.Qn(function(){return e=u.Eh,n=u.xn,t=h,r=c,i=a,o=new dl({next:function(t){n.Qn(function(){return Mu(e,s)}),t.fromCache&&"server"===r.source?i.reject(new Pr(Or.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 Bu(t,o,{includeMetadataChanges:!0,bs:!0}),ju(e,s);var e,n,t,r,i,o,s}),a.promise)]}})})},df.prototype.write=function(t){var e=this;this.mh();var n=new Tu;return this.xn.Qn(function(){return Ec(e.Va,t,n)}),n.promise},df.prototype.B=function(){return this.sa.B},df.prototype.ph=function(t){var e=this;this.mh();var r=new dl(t);return this.xn.Qn(function(){return w(e,void 0,void 0,function(){return b(this,function(t){return[2,(e=this.Eh,n=r,e.Ts.add(n),void n.next())];var e,n})})}),function(){r.Ca(),e.xn.Qn(function(){return w(e,void 0,void 0,function(){return b(this,function(t){return[2,void this.Eh.Ts.delete(r)]})})})}},Object.defineProperty(df.prototype,"gh",{get:function(){return this.xn.Zn},enumerable:!1,configurable:!0}),df.prototype.transaction=function(t){var e=this;this.mh();var n=new Tu;return this.xn.Qn(function(){return new ff(e.xn,e.Qo,t,n).run(),Promise.resolve()}),n.promise},df);function df(t,e){this.credentials=t,this.xn=e,this.clientId=bi.k(),this.wh=new Tu}function vf(t,e,n,r){this.xn=t,this.Qo=e,this.updateFunction=n,this.Ln=r,this.hh=5,this.Jn=new Au(this.xn,"transaction_retry")}function yf(t){this.Qo=t,this.eh=new Map,this.mutations=[],this.nh=!1,this.sh=null,this.ih=new Set}function gf(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 mf,wf,bf=(Mf.prototype.Ch=function(t){switch(qo(t)){case 0:return null;case 1:return t.booleanValue;case 2:return Yo(t.integerValue||t.doubleValue);case 3:return this.Dh(t.timestampValue);case 4:return this.Fh(t);case 5:return t.stringValue;case 6:return this.Sh(Ko(t.bytesValue));case 7:return this.Nh(t.referenceValue);case 8:return this.$h(t.geoPointValue);case 9:return this.kh(t.arrayValue);case 10:return this.xh(t.mapValue);default:throw xr()}},Mf.prototype.xh=function(t){var n=this,r={};return qr(t.fields||{},function(t,e){r[t]=n.Ch(e)}),r},Mf.prototype.$h=function(t){return new _l(Yo(t.latitude),Yo(t.longitude))},Mf.prototype.kh=function(t){var e=this;return(t.values||[]).map(function(t){return e.Ch(t)})},Mf.prototype.Fh=function(t){switch(this.Vh){case"previous":var e=function t(e){var n=e.mapValue.fields.__previous_value__;return xo(n)?t(n):n}(t);return null==e?null:this.Ch(e);case"estimate":return this.Dh(Bo(t));default:return null}},Mf.prototype.Dh=function(t){var e=Xo(t),n=new Ui(e.seconds,e.nanos);return this.timestampsInSnapshots?n:n.toDate()},Mf.prototype.Nh=function(t){var e=Hr.P(t);Br(Is(e));var n=new Vi(e.get(1),e.get(3)),r=new Kr(e.u(5));return n.isEqual(this.B)||Cr("Document "+r+" contains a document reference within a different database ("+n.projectId+"/"+n.database+") which is not supported. It will be treated as a reference in the current database ("+this.B.projectId+"/"+this.B.database+") instead."),this.bh(r)},Mf),Ef=Zu.xi,If=(jf.prototype.isEqual=function(t){return this.host===t.host&&this.ssl===t.ssl&&this.timestampsInSnapshots===t.timestampsInSnapshots&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties},jf),Tf=(Object.defineProperty(Cf.prototype,"zh",{get:function(){return this.Kh||(this.Kh=new Yl(this.Qa,this.Gh.ignoreUndefinedProperties)),this.Kh},enumerable:!1,configurable:!0}),Cf.prototype.settings=function(t){ni("Firestore.settings",arguments,1),oi("Firestore.settings","object",1,t),t.merge&&delete(t=Object.assign(Object.assign({},this.Gh),t)).merge;var e=new If(t);if(this.Bh&&!this.Gh.isEqual(e))throw new Pr(Or.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only call settings() before calling any other methods on a Firestore object.");void 0!==(this.Gh=e).credentials&&(this.Wh=function(t){if(!t)return new Sh;switch(t.type){case"gapi":var e=t.client;return Br(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new Oh(e,t.sessionIndex||"0");case"provider":return t.client;default:throw new Pr(Or.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(e.credentials))},Cf.prototype.enableNetwork=function(){return this.Uh(),this.Bh.enableNetwork()},Cf.prototype.disableNetwork=function(){return this.Uh(),this.Bh.disableNetwork()},Cf.prototype.enablePersistence=function(t){var e,n;if(this.Bh)throw new Pr(Or.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only call enablePersistence() before calling any other methods on a Firestore object.");var r=!1,i=!1;if(t&&(void 0!==t.experimentalTabSynchronization&&Cr("The 'experimentalTabSynchronization' setting will be removed. Use 'synchronizeTabs' instead."),r=null!==(n=null!==(e=t.synchronizeTabs)&&void 0!==e?e:t.experimentalTabSynchronization)&&void 0!==n&&n,i=!!t.experimentalForceOwningTab&&t.experimentalForceOwningTab,r&&i))throw new Pr(Or.INVALID_ARGUMENT,"The 'experimentalForceOwningTab' setting cannot be used with 'synchronizeTabs'.");return this.Hh(this.Oh,this.Mh,{ya:!0,cacheSizeBytes:this.Gh.cacheSizeBytes,synchronizeTabs:r,Yh:i})},Cf.prototype.clearPersistence=function(){return w(this,void 0,void 0,function(){var n,e=this;return b(this,function(t){if(void 0!==this.Bh&&!this.Bh.gh)throw new Pr(Or.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");return n=new Tu,[2,(this.qh.ts(function(){return w(e,void 0,void 0,function(){var e;return b(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.Oh.clearPersistence(this.Qa,this.jh)];case 1:return t.sent(),n.resolve(),[3,3];case 2:return e=t.sent(),n.reject(e),[3,3];case 3:return[2]}})})}),n.promise)]})})},Cf.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(Cf.prototype,"Jh",{get:function(){return this.Uh(),this.Bh.gh},enumerable:!1,configurable:!0}),Cf.prototype.waitForPendingWrites=function(){return this.Uh(),this.Bh.waitForPendingWrites()},Cf.prototype.onSnapshotsInSync=function(t){if(this.Uh(),gf(t))return this.Bh.ph(t);oi("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.Bh.ph(e)},Cf.prototype.Uh=function(){return this.Bh||this.Hh(new fl,new pl,{ya:!1}),this.Bh},Cf.prototype.Xh=function(){return new Oi(this.Qa,this.jh,this.Gh.host,this.Gh.ssl,this.Gh.experimentalForceLongPolling)},Cf.prototype.Hh=function(t,e,n){var r=this.Xh();return this.Bh=new pf(this.Wh,this.qh),this.Bh.start(r,t,e,n)},Cf.Qh=function(t){if(e=t.options,!Object.prototype.hasOwnProperty.call(e,"projectId"))throw new Pr(Or.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');var e,n=t.options.projectId;if(!n||"string"!=typeof n)throw new Pr(Or.INVALID_ARGUMENT,"projectId must be a string in FirebaseApp.options");return new Vi(n)},Object.defineProperty(Cf.prototype,"app",{get:function(){if(!this.Lh)throw new Pr(Or.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.Lh},enumerable:!1,configurable:!0}),Cf.prototype.collection=function(t){return ni("Firestore.collection",arguments,1),oi("Firestore.collection","non-empty string",1,t),this.Uh(),new Qf(Hr.P(t),this,null)},Cf.prototype.doc=function(t){return ni("Firestore.doc",arguments,1),oi("Firestore.doc","non-empty string",1,t),this.Uh(),Rf.Zh(Hr.P(t),this,null)},Cf.prototype.collectionGroup=function(t){if(ni("Firestore.collectionGroup",arguments,1),oi("Firestore.collectionGroup","non-empty string",1,t),0<=t.indexOf("/"))throw new Pr(Or.INVALID_ARGUMENT,"Invalid collection ID '"+t+"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.");return this.Uh(),new zf((e=t,new Sa(Hr.p(),e)),this,null);var e},Cf.prototype.runTransaction=function(e){var n=this;return ni("Firestore.runTransaction",arguments,1),oi("Firestore.runTransaction","function",1,e),this.Uh().transaction(function(t){return e(new Af(n,t))})},Cf.prototype.batch=function(){return this.Uh(),new Nf(this)},Object.defineProperty(Cf,"logLevel",{get:function(){switch(_r()){case a.DEBUG:return"debug";case a.ERROR:return"error";case a.SILENT:return"silent";case a.WARN:return"warn";case a.INFO:return"info";case a.VERBOSE:return"verbose";default:return"error"}},enumerable:!1,configurable:!0}),Cf.setLogLevel=function(t){ni("Firestore.setLogLevel",arguments,1),ci("setLogLevel",["debug","error","silent","warn","info","verbose"],1,t),kr.setLogLevel(t)},Cf.prototype.tl=function(){return this.Gh.timestampsInSnapshots},Cf.prototype.el=function(){return this.Gh},Cf),Af=(Uf.prototype.get=function(t){var n=this;ni("Transaction.get",arguments,1);var r=$f("Transaction.get",t,this.nl);return this.sl.rh([r.ja]).then(function(t){if(!t||1!==t.length)return xr();var e=t[0];if(e instanceof Na)return new Df(n.nl,r.ja,null,!1,!1,r.Wa);if(e instanceof Aa)return new Df(n.nl,r.ja,e,!1,!1,r.Wa);throw xr()})},Uf.prototype.set=function(t,e,n){ii("Transaction.set",arguments,2,3);var r=$f("Transaction.set",t,this.nl);n=Kf("Transaction.set",n);var i=tp(r.Wa,e,n),o=Zl(this.nl.zh,"Transaction.set",r.ja,i,null!==r.Wa,n);return this.sl.set(r.ja,o),this},Uf.prototype.update=function(t,e,n){for(var r,i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return i="string"==typeof e||e instanceof yl?(ri("Transaction.update",arguments,3),r=$f("Transaction.update",t,this.nl),tf(this.nl.zh,"Transaction.update",r.ja,e,n,o)):(ni("Transaction.update",arguments,2),r=$f("Transaction.update",t,this.nl),$l(this.nl.zh,"Transaction.update",r.ja,e)),this.sl.update(r.ja,i),this},Uf.prototype.delete=function(t){ni("Transaction.delete",arguments,1);var e=$f("Transaction.delete",t,this.nl);return this.sl.delete(e.ja),this},Uf),Nf=(_f.prototype.set=function(t,e,n){ii("WriteBatch.set",arguments,2,3),this.ol();var r=$f("WriteBatch.set",t,this.nl);n=Kf("WriteBatch.set",n);var i=tp(r.Wa,e,n),o=Zl(this.nl.zh,"WriteBatch.set",r.ja,i,null!==r.Wa,n);return this.il=this.il.concat(o.Ga(r.ja,Ws.He())),this},_f.prototype.update=function(t,e,n){for(var r,i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return this.ol(),i="string"==typeof e||e instanceof yl?(ri("WriteBatch.update",arguments,3),r=$f("WriteBatch.update",t,this.nl),tf(this.nl.zh,"WriteBatch.update",r.ja,e,n,o)):(ni("WriteBatch.update",arguments,2),r=$f("WriteBatch.update",t,this.nl),$l(this.nl.zh,"WriteBatch.update",r.ja,e)),this.il=this.il.concat(i.Ga(r.ja,Ws.exists(!0))),this},_f.prototype.delete=function(t){ni("WriteBatch.delete",arguments,1),this.ol();var e=$f("WriteBatch.delete",t,this.nl);return this.il=this.il.concat(new fa(e.ja,Ws.He())),this},_f.prototype.commit=function(){return this.ol(),this.rl=!0,0<this.il.length?this.nl.Uh().write(this.il):Promise.resolve()},_f.prototype.ol=function(){if(this.rl)throw new Pr(Or.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},_f),Rf=(o(Vf,wf=jl),Vf.Zh=function(t,e,n){if(t.length%2!=0)throw new Pr(Or.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.R()+" has "+t.length);return new Vf(new Kr(t),e,n)},Object.defineProperty(Vf.prototype,"id",{get:function(){return this.ja.path._()},enumerable:!1,configurable:!0}),Object.defineProperty(Vf.prototype,"parent",{get:function(){return new Qf(this.ja.path.h(),this.firestore,this.Wa)},enumerable:!1,configurable:!0}),Object.defineProperty(Vf.prototype,"path",{get:function(){return this.ja.path.R()},enumerable:!1,configurable:!0}),Vf.prototype.collection=function(t){if(ni("DocumentReference.collection",arguments,1),oi("DocumentReference.collection","non-empty string",1,t),!t)throw new Pr(Or.INVALID_ARGUMENT,"Must provide a non-empty collection name to collection()");var e=Hr.P(t);return new Qf(this.ja.path.child(e),this.firestore,null)},Vf.prototype.isEqual=function(t){if(!(t instanceof Vf))throw yi("isEqual","DocumentReference",1,t);return this.firestore===t.firestore&&this.ja.isEqual(t.ja)&&this.Wa===t.Wa},Vf.prototype.set=function(t,e){ii("DocumentReference.set",arguments,1,2),e=Kf("DocumentReference.set",e);var n=tp(this.Wa,t,e),r=Zl(this.firestore.zh,"DocumentReference.set",this.ja,n,null!==this.Wa,e);return this.Bh.write(r.Ga(this.ja,Ws.He()))},Vf.prototype.update=function(t,e){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return n="string"==typeof t||t instanceof yl?(ri("DocumentReference.update",arguments,2),tf(this.firestore.zh,"DocumentReference.update",this.ja,t,e,r)):(ni("DocumentReference.update",arguments,1),$l(this.firestore.zh,"DocumentReference.update",this.ja,t)),this.Bh.write(n.Ga(this.ja,Ws.exists(!0)))},Vf.prototype.delete=function(){return ni("DocumentReference.delete",arguments,0),this.Bh.write([new fa(this.ja,Ws.He())])},Vf.prototype.onSnapshot=function(){for(var t,e,n,r=this,i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];ii("DocumentReference.onSnapshot",arguments,1,4);var s={includeMetadataChanges:!1},a=0;"object"!=typeof i[a]||gf(i[a])||(vi("DocumentReference.onSnapshot",s=i[a],["includeMetadataChanges"]),ui("DocumentReference.onSnapshot","boolean","includeMetadataChanges",s.includeMetadataChanges),a++);var u,h={includeMetadataChanges:s.includeMetadataChanges};gf(i[a])?(u=i[a],i[a]=null===(t=u.next)||void 0===t?void 0:t.bind(u),i[a+1]=null===(e=u.error)||void 0===e?void 0:e.bind(u),i[a+2]=null===(n=u.complete)||void 0===n?void 0:n.bind(u)):(oi("DocumentReference.onSnapshot","function",a,i[a]),si("DocumentReference.onSnapshot","function",a+1,i[a+1]),si("DocumentReference.onSnapshot","function",a+2,i[a+2]));var c={next:function(t){i[a]&&i[a](r.ul(t))},error:i[a+1],complete:i[a+2]};return this.Bh.listen(Pa(this.ja.path),h,c)},Vf.prototype.get=function(t){var e=this;ii("DocumentReference.get",arguments,0,1),Zf("DocumentReference.get",t);var n=this.firestore.Uh();return t&&"cache"===t.source?n.Ah(this.ja).then(function(t){return new Df(e.firestore,e.ja,t,!0,t instanceof Aa&&t.Ye,e.Wa)}):n.Rh(this.ja,t).then(function(t){return e.ul(t)})},Vf.prototype.withConverter=function(t){return new Vf(this.ja,this.firestore,t)},Vf.prototype.ul=function(t){var e=t.docs.get(this.ja);return new Df(this.firestore,this.ja,e,t.fromCache,t.hasPendingWrites,this.Wa)},Vf),Sf=(kf.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},kf),Df=(Pf.prototype.data=function(t){var e=this;if(ii("DocumentSnapshot.data",arguments,0,1),t=Jf("DocumentSnapshot.data",t),this.cl){if(this.Wa){var n=new Lf(this.nl,this.ja,this.cl,this.al,this.hl,null);return this.Wa.fromFirestore(n,t)}return new bf(this.nl.Qa,this.nl.tl(),t.serverTimestamps||"none",function(t){return new Rf(t,e.nl,null)},function(t){return new ki(t)}).Ch(this.cl.sn())}},Pf.prototype.get=function(t,e){var n=this;if(ii("DocumentSnapshot.get",arguments,1,2),e=Jf("DocumentSnapshot.get",e),this.cl){var r=this.cl.data().field(af("DocumentSnapshot.get",t,this.ja));if(null!==r)return new bf(this.nl.Qa,this.nl.tl(),e.serverTimestamps||"none",function(t){return new Rf(t,n.nl,n.Wa)},function(t){return new ki(t)}).Ch(r)}},Object.defineProperty(Pf.prototype,"id",{get:function(){return this.ja.path._()},enumerable:!1,configurable:!0}),Object.defineProperty(Pf.prototype,"ref",{get:function(){return new Rf(this.ja,this.nl,this.Wa)},enumerable:!1,configurable:!0}),Object.defineProperty(Pf.prototype,"exists",{get:function(){return null!==this.cl},enumerable:!1,configurable:!0}),Object.defineProperty(Pf.prototype,"metadata",{get:function(){return new Sf(this.hl,this.al)},enumerable:!1,configurable:!0}),Pf.prototype.isEqual=function(t){if(!(t instanceof Pf))throw yi("isEqual","DocumentSnapshot",1,t);return this.nl===t.nl&&this.al===t.al&&this.ja.isEqual(t.ja)&&(null===this.cl?null===t.cl:this.cl.isEqual(t.cl))&&this.Wa===t.Wa},Pf),Lf=(o(Of,mf=Df),Of.prototype.data=function(t){return mf.prototype.data.call(this,t)},Of);function Of(){return null!==mf&&mf.apply(this,arguments)||this}function Pf(t,e,n,r,i,o){this.nl=t,this.ja=e,this.cl=n,this.al=r,this.hl=i,this.Wa=o}function kf(t,e){this.hasPendingWrites=t,this.fromCache=e}function Vf(t,e,n){var r=this;return(r=wf.call(this,e.Qa,t,n)||this).ja=t,r.firestore=e,r.Wa=n,r.Bh=r.firestore.Uh(),r}function _f(t){this.nl=t,this.il=[],this.rl=!1}function Uf(t,e){this.nl=t,this.sl=e}function Cf(t,e,n,r){var i=this;if(void 0===n&&(n=new fl),void 0===r&&(r=new pl),this.Oh=n,this.Mh=r,this.Lh=null,this.qh=new Pu,this.INTERNAL={delete:function(){return w(i,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return this.Uh(),[4,this.Bh.terminate()];case 1:return t.sent(),[2]}})})}},"object"==typeof t.options){var o=t;this.Lh=o,this.Qa=Cf.Qh(o),this.jh=o.name,this.Wh=new Dh(e)}else{var s=t;if(!s.projectId)throw new Pr(Or.INVALID_ARGUMENT,"Must provide projectId");this.Qa=new Vi(s.projectId,s.database),this.jh="[DEFAULT]",this.Wh=new Sh}this.Gh=new If({})}function jf(t){var e,n,r,i;if(void 0===t.host){if(void 0!==t.ssl)throw new Pr(Or.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else ai("settings","non-empty string","host",t.host),this.host=t.host,ui("settings","boolean","ssl",t.ssl),this.ssl=null===(e=t.ssl)||void 0===e||e;if(vi("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling","ignoreUndefinedProperties"]),ui("settings","object","credentials",t.credentials),this.credentials=t.credentials,ui("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),ui("settings","boolean","ignoreUndefinedProperties",t.ignoreUndefinedProperties),!0===t.timestampsInSnapshots?Cr("The setting 'timestampsInSnapshots: true' is no longer required and should be removed."):!1===t.timestampsInSnapshots&&Cr("Support for 'timestampsInSnapshots: false' will be removed soon. You must update your code to handle Timestamp objects."),this.timestampsInSnapshots=null===(n=t.timestampsInSnapshots)||void 0===n||n,this.ignoreUndefinedProperties=null!==(r=t.ignoreUndefinedProperties)&&void 0!==r&&r,ui("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=Zu.Mi;else{if(t.cacheSizeBytes!==Ef&&t.cacheSizeBytes<Zu.Oi)throw new Pr(Or.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+Zu.Oi);this.cacheSizeBytes=t.cacheSizeBytes}ui("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.experimentalForceLongPolling=null!==(i=t.experimentalForceLongPolling)&&void 0!==i&&i}function Mf(t,e,n,r,i){this.B=t,this.timestampsInSnapshots=e,this.Vh=n,this.bh=r,this.Sh=i}function xf(t,e,n){if("string"==typeof n){if(""===n)throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!Ca(e)&&-1!==n.indexOf("/"))throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '"+n+"' contains a '/' character.");var r=e.path.child(Hr.P(n));if(!Kr.N(r))throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '"+r+"' is not because it has an odd number of segments ("+r.length+").");return Jo(t,new Kr(r))}if(n instanceof jl)return Jo(t,n.ja);throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+pi(n)+".")}function Bf(t,e){if(!Array.isArray(t)||0===t.length)throw new Pr(Or.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(10<t.length)throw new Pr(Or.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.");if("in"===e||"array-contains-any"===e){if(0<=t.indexOf(null))throw new Pr(Or.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'null' in the value array.");if(0<t.filter(function(t){return Number.isNaN(t)}).length)throw new Pr(Or.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'NaN' in the value array.")}}function Ff(t,e,n){if(!n.isEqual(e))throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, >, or >=) on field '"+e.toString()+"' and so you must also use '"+e.toString()+"' as your first orderBy(), but your first orderBy() is on field '"+n.toString()+"' instead.")}function qf(t){if(Va(t)&&0===t.rn.length)throw new Pr(Or.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var Gf,zf=(Yf.prototype.where=function(t,e,n){ni("Query.where",arguments,3),di("Query.where",3,n);var r,i,o=ci("Query.where",["<","<=","==","!=",">=",">","array-contains","in","array-contains-any","not-in"],2,e),s=af("Query.where",t),a=function(t,e,n,r,i,o,s){var a;if(i.V()){if("array-contains"===o||"array-contains-any"===o)throw new Pr(Or.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o+"' queries on FieldPath.documentId().");if("in"===o||"not-in"===o){Bf(s,o);for(var u=[],h=0,c=s;h<c.length;h++){var l=c[h];u.push(xf(r,t,l))}a={arrayValue:{values:u}}}else a=xf(r,t,s)}else"in"!==o&&"not-in"!==o&&"array-contains-any"!==o||Bf(s,o),a=ef(n,e,s,"in"===o||"not-in"===o);var f=Xa.create(i,o,a);return function(t,e){if(e.an()){var n=Ua(t);if(null!==n&&!n.isEqual(e.field))throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, >, or >=) must be on the same field. But you have inequality filters on '"+n.toString()+"' and '"+e.field.toString()+"'");var r=_a(t);null!==r&&Ff(0,e.field,r)}var i=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!==i)throw i===e.op?new Pr(Or.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+e.op.toString()+"' filter."):new Pr(Or.INVALID_ARGUMENT,"Invalid query. You cannot use '"+e.op.toString()+"' filters with '"+i.toString()+"' filters.")}(t,f),f}(this.ll,"Query.where",this.firestore.zh,this.firestore.Qa,s,o,n);return new Yf((r=this.ll,i=r.filters.concat([a]),new Sa(r.path,r.collectionGroup,r.rn.slice(),i,r.limit,r.on,r.startAt,r.endAt)),this.firestore,this.Wa)},Yf.prototype.orderBy=function(t,e){var n;if(ii("Query.orderBy",arguments,1,2),si("Query.orderBy","non-empty string",2,e),void 0===e||"asc"===e)n="asc";else{if("desc"!==e)throw new Pr(Or.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+e+"', expected 'asc' or 'desc'.");n="desc"}var r,i,o=af("Query.orderBy",t),s=function(t,e,n){if(null!==t.startAt)throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r,i,o,s=new Iu(e,n);return i=s,null!==_a(r=t)||null!==(o=Ua(r))&&Ff(0,o,i.field),s}(this.ll,o,n);return new Yf((r=this.ll,i=r.rn.concat([s]),new Sa(r.path,r.collectionGroup,i,r.filters.slice(),r.limit,r.on,r.startAt,r.endAt)),this.firestore,this.Wa)},Yf.prototype.limit=function(t){return ni("Query.limit",arguments,1),oi("Query.limit","number",1,t),gi("Query.limit",1,t),new Yf(xa(this.ll,t,"F"),this.firestore,this.Wa)},Yf.prototype.limitToLast=function(t){return ni("Query.limitToLast",arguments,1),oi("Query.limitToLast","number",1,t),gi("Query.limitToLast",1,t),new Yf(xa(this.ll,t,"L"),this.firestore,this.Wa)},Yf.prototype.startAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];ri("Query.startAt",arguments,1);var r=this._l("Query.startAt",t,e,!0);return new Yf(Ba(this.ll,r),this.firestore,this.Wa)},Yf.prototype.startAfter=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];ri("Query.startAfter",arguments,1);var r=this._l("Query.startAfter",t,e,!1);return new Yf(Ba(this.ll,r),this.firestore,this.Wa)},Yf.prototype.endBefore=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];ri("Query.endBefore",arguments,1);var r=this._l("Query.endBefore",t,e,!0);return new Yf(Fa(this.ll,r),this.firestore,this.Wa)},Yf.prototype.endAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];ri("Query.endAt",arguments,1);var r=this._l("Query.endAt",t,e,!1);return new Yf(Fa(this.ll,r),this.firestore,this.Wa)},Yf.prototype.isEqual=function(t){if(!(t instanceof Yf))throw yi("isEqual","Query",1,t);return this.firestore===t.firestore&&qa(this.ll,t.ll)&&this.Wa===t.Wa},Yf.prototype.withConverter=function(t){return new Yf(this.ll,this.firestore,t)},Yf.prototype._l=function(c,t,e,n){if(di(c,1,t),t instanceof Df)return ni(c,s([t],e),1),function(t,e,n,r){if(!n)throw new Pr(Or.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+c+"().");for(var i=[],o=0,s=ja(t);o<s.length;o++){var a=s[o];if(a.field.V())i.push(Jo(e,n.key));else{var u=n.field(a.field);if(xo(u))throw new Pr(Or.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){var h=a.field.R();throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+h+"' (used as the orderBy) does not exist.")}i.push(u)}}return new du(i,r)}(this.ll,this.firestore.Qa,t.cl,n);var r=[t].concat(e);return function(t,e,n,r,i,o){var s=t.rn;if(i.length>s.length)throw new Pr(Or.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 h=i[u];if(s[u].field.V()){if("string"!=typeof h)throw new Pr(Or.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+r+"(), but got a "+typeof h);if(!Ca(t)&&-1!==h.indexOf("/"))throw new Pr(Or.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 '"+h+"' contains a slash.");var c=t.path.child(Hr.P(h));if(!Kr.N(c))throw new Pr(Or.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 '"+c+"' is not because it contains an odd number of segments.");var l=new Kr(c);a.push(Jo(e,l))}else{var f=ef(n,r,h);a.push(f)}}return new du(a,o)}(this.ll,this.firestore.Qa,this.firestore.zh,c,r,n)},Yf.prototype.onSnapshot=function(){for(var t,e,n,r=this,i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];ii("Query.onSnapshot",arguments,1,4);var s,a={},u=0;"object"!=typeof i[u]||gf(i[u])||(vi("Query.onSnapshot",a=i[u],["includeMetadataChanges"]),ui("Query.onSnapshot","boolean","includeMetadataChanges",a.includeMetadataChanges),u++),gf(i[u])?(s=i[u],i[u]=null===(t=s.next)||void 0===t?void 0:t.bind(s),i[u+1]=null===(e=s.error)||void 0===e?void 0:e.bind(s),i[u+2]=null===(n=s.complete)||void 0===n?void 0:n.bind(s)):(oi("Query.onSnapshot","function",u,i[u]),si("Query.onSnapshot","function",u+1,i[u+1]),si("Query.onSnapshot","function",u+2,i[u+2]));var h={next:function(t){i[u]&&i[u](new Wf(r.firestore,r.ll,t,r.Wa))},error:i[u+1],complete:i[u+2]};return qf(this.ll),this.firestore.Uh().listen(this.ll,a,h)},Yf.prototype.get=function(t){var e=this;ii("Query.get",arguments,0,1),Zf("Query.get",t),qf(this.ll);var n=this.firestore.Uh();return(t&&"cache"===t.source?n.yh(this.ll):n.Ph(this.ll,t)).then(function(t){return new Wf(e.firestore,e.ll,t,e.Wa)})},Yf),Wf=(Object.defineProperty(Xf.prototype,"docs",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!1,configurable:!0}),Object.defineProperty(Xf.prototype,"empty",{get:function(){return this.dl.docs.m()},enumerable:!1,configurable:!0}),Object.defineProperty(Xf.prototype,"size",{get:function(){return this.dl.docs.size},enumerable:!1,configurable:!0}),Xf.prototype.forEach=function(e,n){var r=this;ii("QuerySnapshot.forEach",arguments,1,2),oi("QuerySnapshot.forEach","function",1,e),this.dl.docs.forEach(function(t){e.call(n,r.Tl(t,r.metadata.fromCache,r.dl.Qt.has(t.key)))})},Object.defineProperty(Xf.prototype,"query",{get:function(){return new zf(this.fl,this.nl,this.Wa)},enumerable:!1,configurable:!0}),Xf.prototype.docChanges=function(t){t&&(vi("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),ui("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this.dl.Wt)throw new Pr(Or.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this.wl&&this.ml===e||(this.wl=function(i,e,o){if(i.Bt.m()){var n=0;return i.docChanges.map(function(t){var e=o(t.doc,i.fromCache,i.Qt.has(t.doc.key));return t.doc,{type:"added",doc:e,oldIndex:-1,newIndex:n++}})}var s=i.Bt;return i.docChanges.filter(function(t){return e||3!==t.type}).map(function(t){var e=o(t.doc,i.fromCache,i.Qt.has(t.doc.key)),n=-1,r=-1;return 0!==t.type&&(n=s.indexOf(t.doc.key),s=s.delete(t.doc.key)),1!==t.type&&(r=(s=s.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 xr()}}(t.type),doc:e,oldIndex:n,newIndex:r}})}(this.dl,e,this.Tl.bind(this)),this.ml=e),this.wl},Xf.prototype.isEqual=function(t){if(!(t instanceof Xf))throw yi("isEqual","QuerySnapshot",1,t);return this.nl===t.nl&&qa(this.fl,t.fl)&&this.dl.isEqual(t.dl)&&this.Wa===t.Wa},Xf.prototype.Tl=function(t,e,n){return new Lf(this.nl,t.key,t,e,n,this.Wa)},Xf),Qf=(o(Hf,Gf=zf),Object.defineProperty(Hf.prototype,"id",{get:function(){return this.ll.path._()},enumerable:!1,configurable:!0}),Object.defineProperty(Hf.prototype,"parent",{get:function(){var t=this.ll.path.h();return t.m()?null:new Rf(new Kr(t),this.firestore,null)},enumerable:!1,configurable:!0}),Object.defineProperty(Hf.prototype,"path",{get:function(){return this.ll.path.R()},enumerable:!1,configurable:!0}),Hf.prototype.doc=function(t){ii("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=bi.k()),oi("CollectionReference.doc","non-empty string",1,t);var e=Hr.P(t);return Rf.Zh(this.ll.path.child(e),this.firestore,this.Wa)},Hf.prototype.add=function(t){ni("CollectionReference.add",arguments,1);var e=this.Wa?this.Wa.toFirestore(t):t;oi("CollectionReference.add","object",1,e);var n=this.doc();return new Rf(n.ja,this.firestore,null).set(e).then(function(){return n})},Hf.prototype.withConverter=function(t){return new Hf(this.El,this.firestore,t)},Hf);function Hf(t,e,n){var r=this;if(((r=Gf.call(this,Pa(t),e,n)||this).El=t).length%2!=1)throw new Pr(Or.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t.R()+" has "+t.length);return r}function Xf(t,e,n,r){this.nl=t,this.fl=e,this.dl=n,this.Wa=r,this.wl=null,this.ml=null,this.metadata=new Sf(n.hasPendingWrites,n.fromCache)}function Yf(t,e,n){this.ll=t,this.firestore=e,this.Wa=n}function Kf(t,e){if(void 0===e)return{merge:!1};if(vi(t,e,["merge","mergeFields"]),ui(t,"boolean","merge",e.merge),void 0!==(n=e.mergeFields)&&function(t,e,n,r){if(!(n instanceof Array))throw new Pr(Or.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+pi(n));for(var i=0;i<n.length;++i)if(!r(n[i]))throw new Pr(Or.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be a string or a FieldPath, but the value at index "+i+" was: "+pi(n[i]))}(t,"mergeFields",n,function(t){return"string"==typeof t||t instanceof yl}),void 0!==e.mergeFields&&void 0!==e.merge)throw new Pr(Or.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');var n;return e}function Jf(t,e){return void 0===e?{}:(vi(t,e,["serverTimestamps"]),hi(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function Zf(t,e){si(t,"object",1,e),e&&(vi(t,e,["source"]),hi(t,0,"source",e.source,["default","server","cache"]))}function $f(t,e,n){if(e instanceof jl){if(e.firestore!==n)throw new Pr(Or.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw yi(t,"DocumentReference",1,e)}function tp(t,e,n){return t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e}var ep,np,rp=(o(op,ep=Ul),op.serverTimestamp=function(){ei("FieldValue.serverTimestamp",arguments);var t=new Ol("serverTimestamp");return t.Fa="FieldValue.serverTimestamp",new op(t)},op.delete=function(){ei("FieldValue.delete",arguments);var t=new wl("deleteField");return t.Fa="FieldValue.delete",new op(t)},op.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];ri("FieldValue.arrayUnion",arguments,1);var n=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return ri("arrayUnion()",arguments,1),new Pl("arrayUnion",t)}.apply(void 0,t);return n.Fa="FieldValue.arrayUnion",new op(n)},op.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];ri("FieldValue.arrayRemove",arguments,1);var n=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return ri("arrayRemove()",arguments,1),new kl("arrayRemove",t)}.apply(void 0,t);return n.Fa="FieldValue.arrayRemove",new op(n)},op.increment=function(t){oi("FieldValue.increment","number",1,t),ni("FieldValue.increment",arguments,1);var e=new Vl("increment",t);return e.Fa="FieldValue.increment",new op(e)},op.prototype.isEqual=function(t){return this.Ba.isEqual(t.Ba)},op),ip={Firestore:Tf,GeoPoint:_l,Timestamp:Ui,Blob:ki,Transaction:Af,WriteBatch:Nf,DocumentReference:Rf,DocumentSnapshot:Df,Query:zf,QueryDocumentSnapshot:Lf,QuerySnapshot:Wf,CollectionReference:Qf,FieldPath:yl,FieldValue:rp,setLogLevel:Tf.setLogLevel,CACHE_SIZE_UNLIMITED:Ef};function op(){return null!==ep&&ep.apply(this,arguments)||this}(np=r.default).INTERNAL.registerComponent(new Sr("firestore",function(t){return e=t.getProvider("app").getImmediate(),n=t.getProvider("auth-internal"),new Tf(e,n,new fl,new pl);var e,n},"PUBLIC").setServiceProps(Object.assign({},ip))),np.registerVersion("@firebase/firestore","1.17.2")}).apply(this,arguments)}catch(t){throw console.error(t),new Error("Cannot instantiate firebase-firestore.memory.js - be sure to load firebase-app.js first.")}});
  //# sourceMappingURL=firebase-firestore.memory.js.map
  