Files
Excalidraw/excalidraw/excalidraw-app/build/assets/index.esm-h2kZ9fZN.js
T
Yuzhong Zhang b9ba07ea5d app init
2025-07-05 23:27:59 +08:00

1082 lines
352 KiB
JavaScript

import{g as Ei,i as Sh,a as Dh,b as Nh,c as Ah,d as Ch,e as kh,h as X,L as Ue,j as xh,C as Rh,f as Oh}from"./index.esm-J35DBGFx.js";import{_ as C,f as $,d as g,e as m}from"./index-2K3MavtT.js";/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var Ti=function(e,t){return Ti=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},Ti(e,t)};function Ph(e,t){Ti(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Ou(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}var Lh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},S,Ji=Ji||{},R=Lh||self;function lr(){}function _i(e){var t=typeof e;return t=t!="object"?t:e?Array.isArray(e)?"array":t:"null",t=="array"||t=="object"&&typeof e.length=="number"}function Ln(e){var t=typeof e;return t=="object"&&e!=null||t=="function"}function Mh(e){return Object.prototype.hasOwnProperty.call(e,ci)&&e[ci]||(e[ci]=++Fh)}var ci="closure_uid_"+(1e9*Math.random()>>>0),Fh=0;function Vh(e,t,n){return e.call.apply(e.bind,arguments)}function Uh(e,t,n){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var i=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(i,r),e.apply(t,i)}}return function(){return e.apply(t,arguments)}}function ut(e,t,n){return Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?ut=Vh:ut=Uh,ut.apply(null,arguments)}function Jn(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var r=n.slice();return r.push.apply(r,arguments),e.apply(this,r)}}function qt(){return Date.now()}function vt(e,t){function n(){}n.prototype=t.prototype,e.X=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Kb=function(r,i,o){for(var s=Array(arguments.length-2),u=2;u<arguments.length;u++)s[u-2]=arguments[u];return t.prototype[i].apply(r,s)}}function ue(){this.j=this.j,this.i=this.i}var qh=0;ue.prototype.j=!1;ue.prototype.ja=function(){!this.j&&(this.j=!0,this.G(),qh!=0)&&Mh(this)};ue.prototype.G=function(){if(this.i)for(;this.i.length;)this.i.shift()()};var Pu=Array.prototype.indexOf?function(e,t){return Array.prototype.indexOf.call(e,t,void 0)}:function(e,t){if(typeof e=="string")return typeof t!="string"||t.length!=1?-1:e.indexOf(t,0);for(var n=0;n<e.length;n++)if(n in e&&e[n]===t)return n;return-1},Lu=Array.prototype.forEach?function(e,t,n){Array.prototype.forEach.call(e,t,n)}:function(e,t,n){for(var r=e.length,i=typeof e=="string"?e.split(""):e,o=0;o<r;o++)o in i&&t.call(n,i[o],o,e)};function Bh(e){t:{for(var t=kl,n=e.length,r=typeof e=="string"?e.split(""):e,i=0;i<n;i++)if(i in r&&t.call(void 0,r[i],i,e)){t=i;break t}t=-1}return 0>t?null:typeof e=="string"?e.charAt(t):e[t]}function fs(e){return Array.prototype.concat.apply([],arguments)}function Zi(e){var t=e.length;if(0<t){for(var n=Array(t),r=0;r<t;r++)n[r]=e[r];return n}return[]}function fr(e){return/^[\s\xa0]*$/.test(e)}var ps=String.prototype.trim?function(e){return e.trim()}:function(e){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(e)[1]};function ft(e,t){return e.indexOf(t)!=-1}function hi(e,t){return e<t?-1:e>t?1:0}var pt;t:{var ds=R.navigator;if(ds){var ys=ds.userAgent;if(ys){pt=ys;break t}}pt=""}function to(e,t,n){for(var r in e)t.call(n,e[r],r,e)}function Mu(e){var t={};for(var n in e)t[n]=e[n];return t}var vs="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Fu(e,t){for(var n,r,i=1;i<arguments.length;i++){r=arguments[i];for(n in r)e[n]=r[n];for(var o=0;o<vs.length;o++)n=vs[o],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function eo(e){return eo[" "](e),e}eo[" "]=lr;function jh(e,t){var n=zh;return Object.prototype.hasOwnProperty.call(n,e)?n[e]:n[e]=t(e)}var Kh=ft(pt,"Opera"),re=ft(pt,"Trident")||ft(pt,"MSIE"),Vu=ft(pt,"Edge"),Si=Vu||re,Uu=ft(pt,"Gecko")&&!(ft(pt.toLowerCase(),"webkit")&&!ft(pt,"Edge"))&&!(ft(pt,"Trident")||ft(pt,"MSIE"))&&!ft(pt,"Edge"),Gh=ft(pt.toLowerCase(),"webkit")&&!ft(pt,"Edge");function qu(){var e=R.document;return e?e.documentMode:void 0}var pr;t:{var li="",fi=function(){var e=pt;if(Uu)return/rv:([^\);]+)(\)|;)/.exec(e);if(Vu)return/Edge\/([\d\.]+)/.exec(e);if(re)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(e);if(Gh)return/WebKit\/(\S+)/.exec(e);if(Kh)return/(?:Version)[ \/]?(\S+)/.exec(e)}();if(fi&&(li=fi?fi[1]:""),re){var pi=qu();if(pi!=null&&pi>parseFloat(li)){pr=String(pi);break t}}pr=li}var zh={};function Bu(e){return jh(e,function(){for(var t=0,n=ps(String(pr)).split("."),r=ps(String(e)).split("."),i=Math.max(n.length,r.length),o=0;t==0&&o<i;o++){var s=n[o]||"",u=r[o]||"";do{if(s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],u=/(\d*)(\D*)(.*)/.exec(u)||["","","",""],s[0].length==0&&u[0].length==0)break;t=hi(s[1].length==0?0:parseInt(s[1],10),u[1].length==0?0:parseInt(u[1],10))||hi(s[2].length==0,u[2].length==0)||hi(s[2],u[2]),s=s[3],u=u[3]}while(t==0)}return 0<=t})}var Di;if(R.document&&re){var ms=qu();Di=ms||parseInt(pr,10)||void 0}else Di=void 0;var ju=Di,no=!re||9<=Number(ju),Qh=re&&!Bu("9"),$h=function(){if(!R.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{R.addEventListener("test",lr,t),R.removeEventListener("test",lr,t)}catch{}return e}();function at(e,t){this.type=e,this.a=this.target=t,this.defaultPrevented=!1}at.prototype.b=function(){this.defaultPrevented=!0};function wn(e,t){if(at.call(this,e?e.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,e){var n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;if(this.target=e.target||e.srcElement,this.a=t,t=e.relatedTarget){if(Uu){t:{try{eo(t.nodeName);var i=!0;break t}catch{}i=!1}i||(t=null)}}else n=="mouseover"?t=e.fromElement:n=="mouseout"&&(t=e.toElement);this.relatedTarget=t,r?(this.clientX=r.clientX!==void 0?r.clientX:r.pageX,this.clientY=r.clientY!==void 0?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=e.clientX!==void 0?e.clientX:e.pageX,this.clientY=e.clientY!==void 0?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType=typeof e.pointerType=="string"?e.pointerType:Hh[e.pointerType]||"",this.c=e,e.defaultPrevented&&this.b()}}vt(wn,at);var Hh={2:"touch",3:"pen",4:"mouse"};wn.prototype.b=function(){wn.X.b.call(this);var e=this.c;if(e.preventDefault)e.preventDefault();else if(e.returnValue=!1,Qh)try{(e.ctrlKey||112<=e.keyCode&&123>=e.keyCode)&&(e.keyCode=-1)}catch{}};var Mn="closure_listenable_"+(1e6*Math.random()|0),Wh=0;function Xh(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ca=i,this.key=++Wh,this.Y=this.Z=!1}function Mr(e){e.Y=!0,e.listener=null,e.proxy=null,e.src=null,e.ca=null}function Fr(e){this.src=e,this.a={},this.b=0}Fr.prototype.add=function(e,t,n,r,i){var o=e.toString();e=this.a[o],e||(e=this.a[o]=[],this.b++);var s=Ai(e,t,r,i);return-1<s?(t=e[s],n||(t.Z=!1)):(t=new Xh(t,this.src,o,!!r,i),t.Z=n,e.push(t)),t};function Ni(e,t){var n=t.type;if(n in e.a){var r=e.a[n],i=Pu(r,t),o;(o=0<=i)&&Array.prototype.splice.call(r,i,1),o&&(Mr(t),e.a[n].length==0&&(delete e.a[n],e.b--))}}function Ai(e,t,n,r){for(var i=0;i<e.length;++i){var o=e[i];if(!o.Y&&o.listener==t&&o.capture==!!n&&o.ca==r)return i}return-1}var ro="closure_lm_"+(1e6*Math.random()|0),di={};function io(e,t,n,r,i){if(r&&r.once)return Gu(e,t,n,r,i);if(Array.isArray(t)){for(var o=0;o<t.length;o++)io(e,t[o],n,r,i);return null}return n=uo(n),e&&e[Mn]?e.va(t,n,Ln(r)?!!r.capture:!!r,i):Ku(e,t,n,!1,r,i)}function Ku(e,t,n,r,i,o){if(!t)throw Error("Invalid event type");var s=Ln(i)?!!i.capture:!!i;if(s&&!no)return null;var u=so(e);if(u||(e[ro]=u=new Fr(e)),n=u.add(t,n,r,s,o),n.proxy)return n;if(r=Yh(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)$h||(i=s),i===void 0&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(Qu(t.toString()),r);else if(e.addListener&&e.removeListener)e.addListener(r);else throw Error("addEventListener and attachEvent are unavailable.");return n}function Yh(){var e=Jh,t=no?function(n){return e.call(t.src,t.listener,n)}:function(n){if(n=e.call(t.src,t.listener,n),!n)return n};return t}function Gu(e,t,n,r,i){if(Array.isArray(t)){for(var o=0;o<t.length;o++)Gu(e,t[o],n,r,i);return null}return n=uo(n),e&&e[Mn]?e.wa(t,n,Ln(r)?!!r.capture:!!r,i):Ku(e,t,n,!0,r,i)}function zu(e,t,n,r,i){if(Array.isArray(t))for(var o=0;o<t.length;o++)zu(e,t[o],n,r,i);else r=Ln(r)?!!r.capture:!!r,n=uo(n),e&&e[Mn]?(e=e.c,t=String(t).toString(),t in e.a&&(o=e.a[t],n=Ai(o,n,r,i),-1<n&&(Mr(o[n]),Array.prototype.splice.call(o,n,1),o.length==0&&(delete e.a[t],e.b--)))):e&&(e=so(e))&&(t=e.a[t.toString()],e=-1,t&&(e=Ai(t,n,r,i)),(n=-1<e?t[e]:null)&&oo(n))}function oo(e){if(typeof e!="number"&&e&&!e.Y){var t=e.src;if(t&&t[Mn])Ni(t.c,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(Qu(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=so(t))?(Ni(n,e),n.b==0&&(n.src=null,t[ro]=null)):Mr(e)}}}function Qu(e){return e in di?di[e]:di[e]="on"+e}function gs(e,t){var n=e.listener,r=e.ca||e.src;return e.Z&&oo(e),n.call(r,t)}function Jh(e,t){if(e.Y)return!0;if(!no){if(!t)t:{t=["window","event"];for(var n=R,r=0;r<t.length;r++)if(n=n[t[r]],n==null){t=null;break t}t=n}return t=new wn(t,this),gs(e,t)}return gs(e,new wn(t,this))}function so(e){return e=e[ro],e instanceof Fr?e:null}var yi="__closure_events_fn_"+(1e9*Math.random()>>>0);function uo(e){return typeof e=="function"?e:(e[yi]||(e[yi]=function(t){return e.handleEvent(t)}),e[yi])}function At(){ue.call(this),this.c=new Fr(this),this.J=this,this.C=null}vt(At,ue);At.prototype[Mn]=!0;S=At.prototype;S.addEventListener=function(e,t,n,r){io(this,e,t,n,r)};S.removeEventListener=function(e,t,n,r){zu(this,e,t,n,r)};function rt(e,t){var n,r=e.C;if(r)for(n=[];r;r=r.C)n.push(r);if(e=e.J,r=t.type||t,typeof t=="string")t=new at(t,e);else if(t instanceof at)t.target=t.target||e;else{var i=t;t=new at(r,e),Fu(t,i)}if(i=!0,n)for(var o=n.length-1;0<=o;o--){var s=t.a=n[o];i=Zn(s,r,!0,t)&&i}if(s=t.a=e,i=Zn(s,r,!0,t)&&i,i=Zn(s,r,!1,t)&&i,n)for(o=0;o<n.length;o++)s=t.a=n[o],i=Zn(s,r,!1,t)&&i}S.G=function(){if(At.X.G.call(this),this.c){var e=this.c,t;for(t in e.a){for(var n=e.a[t],r=0;r<n.length;r++)Mr(n[r]);delete e.a[t],e.b--}}this.C=null};S.va=function(e,t,n,r){return this.c.add(String(e),t,!1,n,r)};S.wa=function(e,t,n,r){return this.c.add(String(e),t,!0,n,r)};function Zn(e,t,n,r){if(t=e.c.a[String(t)],!t)return!0;t=t.concat();for(var i=!0,o=0;o<t.length;++o){var s=t[o];if(s&&!s.Y&&s.capture==n){var u=s.listener,a=s.ca||s.src;s.Z&&Ni(e.c,s),i=u.call(a,r)!==!1&&i}}return i&&!r.defaultPrevented}var ao=R.JSON.stringify;function $u(){this.b=this.a=null}var Hu=new(function(){function e(t,n){this.c=t,this.f=n,this.b=0,this.a=null}return e.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},e}())(function(){return new co},function(e){e.reset()});$u.prototype.add=function(e,t){var n=Hu.get();n.set(e,t),this.b?this.b.next=n:this.a=n,this.b=n};function Zh(){var e=Xu,t=null;return e.a&&(t=e.a,e.a=e.a.next,e.a||(e.b=null),t.next=null),t}function co(){this.next=this.b=this.a=null}co.prototype.set=function(e,t){this.a=e,this.b=t,this.next=null};co.prototype.reset=function(){this.next=this.b=this.a=null};function tl(e){R.setTimeout(function(){throw e},0)}function Wu(e,t){Ci||el(),ki||(Ci(),ki=!0),Xu.add(e,t)}var Ci;function el(){var e=R.Promise.resolve(void 0);Ci=function(){e.then(nl)}}var ki=!1,Xu=new $u;function nl(){for(var e;e=Zh();){try{e.a.call(e.b)}catch(n){tl(n)}var t=Hu;t.f(e),100>t.b&&(t.b++,e.next=t.a,t.a=e)}ki=!1}function Vr(e,t){At.call(this),this.b=e||1,this.a=t||R,this.f=ut(this.Za,this),this.g=qt()}vt(Vr,At);S=Vr.prototype;S.aa=!1;S.M=null;S.Za=function(){if(this.aa){var e=qt()-this.g;0<e&&e<.8*this.b?this.M=this.a.setTimeout(this.f,this.b-e):(this.M&&(this.a.clearTimeout(this.M),this.M=null),rt(this,"tick"),this.aa&&(ho(this),this.start()))}};S.start=function(){this.aa=!0,this.M||(this.M=this.a.setTimeout(this.f,this.b),this.g=qt())};function ho(e){e.aa=!1,e.M&&(e.a.clearTimeout(e.M),e.M=null)}S.G=function(){Vr.X.G.call(this),ho(this),delete this.a};function lo(e,t,n){if(typeof e=="function")n&&(e=ut(e,n));else if(e&&typeof e.handleEvent=="function")e=ut(e.handleEvent,e);else throw Error("Invalid listener argument");return 2147483647<Number(t)?-1:R.setTimeout(e,t||0)}function Yu(e){e.a=lo(function(){e.a=null,e.c&&(e.c=!1,Yu(e))},e.h);var t=e.b;e.b=null,e.g.apply(null,t)}var rl=function(e){Ph(t,e);function t(n,r){var i=e.call(this)||this;return i.g=n,i.h=r,i.b=null,i.c=!1,i.a=null,i}return t.prototype.f=function(n){this.b=arguments,this.a?this.c=!0:Yu(this)},t.prototype.G=function(){e.prototype.G.call(this),this.a&&(R.clearTimeout(this.a),this.a=null,this.c=!1,this.b=null)},t}(ue);function bn(e){ue.call(this),this.b=e,this.a={}}vt(bn,ue);var ws=[];function Ju(e,t,n,r){Array.isArray(n)||(n&&(ws[0]=n.toString()),n=ws);for(var i=0;i<n.length;i++){var o=io(t,n[i],r||e.handleEvent,!1,e.b||e);if(!o)break;e.a[o.key]=o}}function Zu(e){to(e.a,function(t,n){this.a.hasOwnProperty(n)&&oo(t)},e),e.a={}}bn.prototype.G=function(){bn.X.G.call(this),Zu(this)};bn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};function fo(){this.a=!0}function il(e,t,n,r,i,o){e.info(function(){if(e.a)if(o)for(var s="",u=o.split("&"),a=0;a<u.length;a++){var c=u[a].split("=");if(1<c.length){var h=c[0];c=c[1];var l=h.split("_");s=2<=l.length&&l[1]=="type"?s+(h+"="+c+"&"):s+(h+"=redacted&")}}else s=null;else s=o;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+t+`
`+n+`
`+s})}function ol(e,t,n,r,i,o,s){e.info(function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+t+`
`+n+`
`+o+" "+s})}function Le(e,t,n,r){e.info(function(){return"XMLHTTP TEXT ("+t+"): "+ul(e,n)+(r?" "+r:"")})}function sl(e,t){e.info(function(){return"TIMEOUT: "+t})}fo.prototype.info=function(){};function ul(e,t){if(!e.a)return t;if(!t)return null;try{var n=JSON.parse(t);if(n){for(e=0;e<n.length;e++)if(Array.isArray(n[e])){var r=n[e];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var o=i[0];if(o!="noop"&&o!="stop"&&o!="close")for(var s=1;s<i.length;s++)i[s]=""}}}}return ao(n)}catch{return t}}var _e={},bs=null;function Ur(){return bs=bs||new At}_e.Fa="serverreachability";function ta(e){at.call(this,_e.Fa,e)}vt(ta,at);function In(e){var t=Ur();rt(t,new ta(t))}_e.STAT_EVENT="statevent";function ea(e,t){at.call(this,_e.STAT_EVENT,e),this.stat=t}vt(ea,at);function dt(e){var t=Ur();rt(t,new ea(t,e))}_e.Ga="timingevent";function na(e){at.call(this,_e.Ga,e)}vt(na,at);function Fn(e,t){if(typeof e!="function")throw Error("Fn must not be null and must be a function");return R.setTimeout(function(){e()},t)}var qr={NO_ERROR:0,$a:1,nb:2,mb:3,hb:4,lb:5,ob:6,Da:7,TIMEOUT:8,rb:9},ra={fb:"complete",Bb:"success",Ea:"error",Da:"abort",tb:"ready",ub:"readystatechange",TIMEOUT:"timeout",pb:"incrementaldata",sb:"progress",ib:"downloadprogress",Jb:"uploadprogress"};function ia(){}ia.prototype.a=null;function Is(e){var t;return(t=e.a)||(t=e.a={}),t}function oa(){}var Vn={OPEN:"a",eb:"b",Ea:"c",qb:"d"};function po(){at.call(this,"d")}vt(po,at);function yo(){at.call(this,"c")}vt(yo,at);var sa;function ua(){}vt(ua,ia);sa=new ua;function Un(e,t,n,r){this.g=e,this.c=t,this.f=n,this.S=r||1,this.J=new bn(this),this.P=al,e=Si?125:void 0,this.R=new Vr(e),this.B=null,this.b=!1,this.j=this.l=this.i=this.H=this.u=this.T=this.o=null,this.s=[],this.a=null,this.D=0,this.h=this.m=null,this.N=-1,this.A=!1,this.O=0,this.F=null,this.V=this.C=this.U=this.I=!1}var al=45e3,aa={},xi={};S=Un.prototype;S.setTimeout=function(e){this.P=e};function Ri(e,t,n){e.H=1,e.i=jr(zt(t)),e.j=n,e.I=!0,ca(e,null)}function ca(e,t){e.u=qt(),qn(e),e.l=zt(e.i);var n=e.l,r=e.S;Array.isArray(r)||(r=[String(r)]),ya(n.b,"t",r),e.D=0,e.a=Oa(e.g,e.g.C?t:null),0<e.O&&(e.F=new rl(ut(e.Ca,e,e.a),e.O)),Ju(e.J,e.a,"readystatechange",e.Xa),t=e.B?Mu(e.B):{},e.j?(e.m||(e.m="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.a.ba(e.l,e.m,e.j,t)):(e.m="GET",e.a.ba(e.l,e.m,null,t)),In(),il(e.c,e.m,e.l,e.f,e.S,e.j)}S.Xa=function(e){e=e.target;var t=this.F;t&&te(e)==3?t.f():this.Ca(e)};S.Ca=function(e){try{if(e==this.a)t:{var t=te(this.a),n=this.a.ua(),r=this.a.W();if(!(3>t||t==3&&!Si&&!this.a.$())){this.A||t!=4||n==7||(n==8||0>=r?In(3):In(2)),Br(this);var i=this.a.W();this.N=i;var o=this.a.$();if(this.b=i==200,ol(this.c,this.m,this.l,this.f,this.S,t,i),this.b){if(this.U&&!this.C){e:{if(this.a){var s,u=this.a;if((s=u.a?u.a.getResponseHeader("X-HTTP-Initial-Response"):null)&&!fr(s)){var a=s;break e}}a=null}if(a)Le(this.c,this.f,a,"Initial handshake response via X-HTTP-Initial-Response"),this.C=!0,Oi(this,a);else{this.b=!1,this.h=3,dt(12),Fe(this),dr(this);break t}}this.I?(ha(this,t,o),Si&&this.b&&t==3&&(Ju(this.J,this.R,"tick",this.Wa),this.R.start())):(Le(this.c,this.f,o,null),Oi(this,o)),t==4&&Fe(this),this.b&&!this.A&&(t==4?Ca(this.g,this):(this.b=!1,qn(this)))}else i==400&&0<o.indexOf("Unknown SID")?(this.h=3,dt(12)):(this.h=0,dt(13)),Fe(this),dr(this)}}}catch{}finally{}};function ha(e,t,n){for(var r=!0;!e.A&&e.D<n.length;){var i=cl(e,n);if(i==xi){t==4&&(e.h=4,dt(14),r=!1),Le(e.c,e.f,null,"[Incomplete Response]");break}else if(i==aa){e.h=4,dt(15),Le(e.c,e.f,n,"[Invalid Chunk]"),r=!1;break}else Le(e.c,e.f,i,null),Oi(e,i)}t==4&&n.length==0&&(e.h=1,dt(16),r=!1),e.b=e.b&&r,r?0<n.length&&!e.V&&(e.V=!0,t=e.g,t.a==e&&t.U&&!t.F&&(t.c.info("Great, no buffering proxy detected. Bytes received: "+n.length),To(t),t.F=!0,dt(11))):(Le(e.c,e.f,n,"[Invalid Chunked Response]"),Fe(e),dr(e))}S.Wa=function(){if(this.a){var e=te(this.a),t=this.a.$();this.D<t.length&&(Br(this),ha(this,e,t),this.b&&e!=4&&qn(this))}};function cl(e,t){var n=e.D,r=t.indexOf(`
`,n);return r==-1?xi:(n=Number(t.substring(n,r)),isNaN(n)?aa:(r+=1,r+n>t.length?xi:(t=t.substr(r,n),e.D=r+n,t)))}S.cancel=function(){this.A=!0,Fe(this)};function qn(e){e.T=qt()+e.P,la(e,e.P)}function la(e,t){if(e.o!=null)throw Error("WatchDog timer not null");e.o=Fn(ut(e.Va,e),t)}function Br(e){e.o&&(R.clearTimeout(e.o),e.o=null)}S.Va=function(){this.o=null;var e=qt();0<=e-this.T?(sl(this.c,this.l),this.H!=2&&(In(),dt(17)),Fe(this),this.h=2,dr(this)):la(this,this.T-e)};function dr(e){e.g.v==0||e.A||Ca(e.g,e)}function Fe(e){Br(e);var t=e.F;t&&typeof t.ja=="function"&&t.ja(),e.F=null,ho(e.R),Zu(e.J),e.a&&(t=e.a,e.a=null,t.abort(),t.ja())}function Oi(e,t){try{var n=e.g;if(n.v!=0&&(n.a==e||Pi(n.b,e))){if(n.I=e.N,!e.C&&Pi(n.b,e)&&n.v==3){try{var r=n.ka.a.parse(t)}catch{r=null}if(Array.isArray(r)&&r.length==3){var i=r;if(i[0]==0){t:if(!n.j){if(n.a)if(n.a.u+3e3<e.u)gr(n),Gr(n);else break t;Eo(n),dt(18)}}else n.oa=i[1],0<n.oa-n.P&&37500>i[2]&&n.H&&n.o==0&&!n.m&&(n.m=Fn(ut(n.Sa,n),6e3));if(1>=ga(n.b)&&n.ea){try{n.ea()}catch{}n.ea=void 0}}else pe(n,11)}else if((e.C||n.a==e)&&gr(n),!fr(t))for(t=r=n.ka.a.parse(t),r=0;r<t.length;r++)if(i=t[r],n.P=i[0],i=i[1],n.v==2)if(i[0]=="c"){n.J=i[1],n.ga=i[2];var o=i[3];o!=null&&(n.ha=o,n.c.info("VER="+n.ha));var s=i[4];s!=null&&(n.pa=s,n.c.info("SVER="+n.pa));var u=i[5];if(u!=null&&typeof u=="number"&&0<u){var a=1.5*u;n.D=a,n.c.info("backChannelRequestTimeoutMs_="+a)}a=n;var c=e.a;if(c){var h=c.a?c.a.getResponseHeader("X-Client-Wire-Protocol"):null;if(h){var l=a.b;!l.a&&(ft(h,"spdy")||ft(h,"quic")||ft(h,"h2"))&&(l.f=l.g,l.a=new Set,l.b&&(go(l,l.b),l.b=null))}if(a.A){var f=c.a?c.a.getResponseHeader("X-HTTP-Session-Id"):null;f&&(a.na=f,K(a.B,a.A,f))}}n.v=3,n.f&&n.f.ta(),n.U&&(n.N=qt()-e.u,n.c.info("Handshake RTT: "+n.N+"ms")),a=n;var y=e;if(a.la=Ra(a,a.C?a.ga:null,a.fa),y.C){wa(a.b,y);var p=y,v=a.D;v&&p.setTimeout(v),p.o&&(Br(p),qn(p)),a.a=y}else Na(a);0<n.g.length&&zr(n)}else i[0]!="stop"&&i[0]!="close"||pe(n,7);else n.v==3&&(i[0]=="stop"||i[0]=="close"?i[0]=="stop"?pe(n,7):Io(n):i[0]!="noop"&&n.f&&n.f.sa(i),n.o=0)}In(4)}catch{}}function hl(e){if(e.K&&typeof e.K=="function")return e.K();if(typeof e=="string")return e.split("");if(_i(e)){for(var t=[],n=e.length,r=0;r<n;r++)t.push(e[r]);return t}t=[],n=0;for(r in e)t[n++]=e[r];return e=t}function vo(e,t){if(e.forEach&&typeof e.forEach=="function")e.forEach(t,void 0);else if(_i(e)||typeof e=="string")Lu(e,t,void 0);else{if(e.L&&typeof e.L=="function")var n=e.L();else if(e.K&&typeof e.K=="function")n=void 0;else if(_i(e)||typeof e=="string"){n=[];for(var r=e.length,i=0;i<r;i++)n.push(i)}else for(i in n=[],r=0,e)n[r++]=i;r=hl(e),i=r.length;for(var o=0;o<i;o++)t.call(void 0,r[o],n&&n[o],e)}}function nn(e,t){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(e)if(e instanceof nn)for(n=e.L(),r=0;r<n.length;r++)this.set(n[r],e.get(n[r]));else for(r in e)this.set(r,e[r])}S=nn.prototype;S.K=function(){mo(this);for(var e=[],t=0;t<this.a.length;t++)e.push(this.b[this.a[t]]);return e};S.L=function(){return mo(this),this.a.concat()};function mo(e){if(e.c!=e.a.length){for(var t=0,n=0;t<e.a.length;){var r=e.a[t];we(e.b,r)&&(e.a[n++]=r),t++}e.a.length=n}if(e.c!=e.a.length){var i={};for(n=t=0;t<e.a.length;)r=e.a[t],we(i,r)||(e.a[n++]=r,i[r]=1),t++;e.a.length=n}}S.get=function(e,t){return we(this.b,e)?this.b[e]:t};S.set=function(e,t){we(this.b,e)||(this.c++,this.a.push(e)),this.b[e]=t};S.forEach=function(e,t){for(var n=this.L(),r=0;r<n.length;r++){var i=n[r],o=this.get(i);e.call(t,o,i,this)}};function we(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var fa=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function ll(e,t){if(e){e=e.split("&");for(var n=0;n<e.length;n++){var r=e[n].indexOf("="),i=null;if(0<=r){var o=e[n].substring(0,r);i=e[n].substring(r+1)}else o=e[n];t(o,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}function be(e,t){if(this.c=this.j=this.f="",this.h=null,this.i=this.g="",this.a=!1,e instanceof be){this.a=t!==void 0?t:e.a,yr(this,e.f),this.j=e.j,vr(this,e.c),mr(this,e.h),this.g=e.g,t=e.b;var n=new En;n.c=t.c,t.a&&(n.a=new nn(t.a),n.b=t.b),Es(this,n),this.i=e.i}else e&&(n=String(e).match(fa))?(this.a=!!t,yr(this,n[1]||"",!0),this.j=vn(n[2]||""),vr(this,n[3]||"",!0),mr(this,n[4]),this.g=vn(n[5]||"",!0),Es(this,n[6]||"",!0),this.i=vn(n[7]||"")):(this.a=!!t,this.b=new En(null,this.a))}be.prototype.toString=function(){var e=[],t=this.f;t&&e.push(dn(t,Ts,!0),":");var n=this.c;return(n||t=="file")&&(e.push("//"),(t=this.j)&&e.push(dn(t,Ts,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),n=this.h,n!=null&&e.push(":",String(n))),(n=this.g)&&(this.c&&n.charAt(0)!="/"&&e.push("/"),e.push(dn(n,n.charAt(0)=="/"?vl:yl,!0))),(n=this.b.toString())&&e.push("?",n),(n=this.i)&&e.push("#",dn(n,gl)),e.join("")};function zt(e){return new be(e)}function yr(e,t,n){e.f=n?vn(t,!0):t,e.f&&(e.f=e.f.replace(/:$/,""))}function vr(e,t,n){e.c=n?vn(t,!0):t}function mr(e,t){if(t){if(t=Number(t),isNaN(t)||0>t)throw Error("Bad port number "+t);e.h=t}else e.h=null}function Es(e,t,n){t instanceof En?(e.b=t,wl(e.b,e.a)):(n||(t=dn(t,ml)),e.b=new En(t,e.a))}function K(e,t,n){e.b.set(t,n)}function jr(e){return K(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^qt()).toString(36)),e}function fl(e){return e instanceof be?zt(e):new be(e,void 0)}function pl(e,t,n,r){var i=new be(null,void 0);return e&&yr(i,e),t&&vr(i,t),n&&mr(i,n),r&&(i.g=r),i}function vn(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function dn(e,t,n){return typeof e=="string"?(e=encodeURI(e).replace(t,dl),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function dl(e){return e=e.charCodeAt(0),"%"+(e>>4&15).toString(16)+(e&15).toString(16)}var Ts=/[#\/\?@]/g,yl=/[#\?:]/g,vl=/[#\?]/g,ml=/[#\?@]/g,gl=/#/g;function En(e,t){this.b=this.a=null,this.c=e||null,this.f=!!t}function ae(e){e.a||(e.a=new nn,e.b=0,e.c&&ll(e.c,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)}))}S=En.prototype;S.add=function(e,t){ae(this),this.c=null,e=rn(this,e);var n=this.a.get(e);return n||this.a.set(e,n=[]),n.push(t),this.b+=1,this};function pa(e,t){ae(e),t=rn(e,t),we(e.a.b,t)&&(e.c=null,e.b-=e.a.get(t).length,e=e.a,we(e.b,t)&&(delete e.b[t],e.c--,e.a.length>2*e.c&&mo(e)))}function da(e,t){return ae(e),t=rn(e,t),we(e.a.b,t)}S.forEach=function(e,t){ae(this),this.a.forEach(function(n,r){Lu(n,function(i){e.call(t,i,r,this)},this)},this)};S.L=function(){ae(this);for(var e=this.a.K(),t=this.a.L(),n=[],r=0;r<t.length;r++)for(var i=e[r],o=0;o<i.length;o++)n.push(t[r]);return n};S.K=function(e){ae(this);var t=[];if(typeof e=="string")da(this,e)&&(t=fs(t,this.a.get(rn(this,e))));else{e=this.a.K();for(var n=0;n<e.length;n++)t=fs(t,e[n])}return t};S.set=function(e,t){return ae(this),this.c=null,e=rn(this,e),da(this,e)&&(this.b-=this.a.get(e).length),this.a.set(e,[t]),this.b+=1,this};S.get=function(e,t){return e?(e=this.K(e),0<e.length?String(e[0]):t):t};function ya(e,t,n){pa(e,t),0<n.length&&(e.c=null,e.a.set(rn(e,t),Zi(n)),e.b+=n.length)}S.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var e=[],t=this.a.L(),n=0;n<t.length;n++){var r=t[n],i=encodeURIComponent(String(r));r=this.K(r);for(var o=0;o<r.length;o++){var s=i;r[o]!==""&&(s+="="+encodeURIComponent(String(r[o]))),e.push(s)}}return this.c=e.join("&")};function rn(e,t){return t=String(t),e.f&&(t=t.toLowerCase()),t}function wl(e,t){t&&!e.f&&(ae(e),e.c=null,e.a.forEach(function(n,r){var i=r.toLowerCase();r!=i&&(pa(this,r),ya(this,i,n))},e)),e.f=t}var bl=function(){function e(t,n){this.b=t,this.a=n}return e}();function va(e){this.g=e||Il,R.PerformanceNavigationTiming?(e=R.performance.getEntriesByType("navigation"),e=0<e.length&&(e[0].nextHopProtocol=="hq"||e[0].nextHopProtocol=="h2")):e=!!(R.ia&&R.ia.ya&&R.ia.ya()&&R.ia.ya().Lb),this.f=e?this.g:1,this.a=null,1<this.f&&(this.a=new Set),this.b=null,this.c=[]}var Il=10;function ma(e){return e.b?!0:e.a?e.a.size>=e.f:!1}function ga(e){return e.b?1:e.a?e.a.size:0}function Pi(e,t){return e.b?e.b==t:e.a?e.a.has(t):!1}function go(e,t){e.a?e.a.add(t):e.b=t}function wa(e,t){e.b&&e.b==t?e.b=null:e.a&&e.a.has(t)&&e.a.delete(t)}va.prototype.cancel=function(){var e,t;if(this.c=ba(this),this.b)this.b.cancel(),this.b=null;else if(this.a&&this.a.size!==0){try{for(var n=Ou(this.a.values()),r=n.next();!r.done;r=n.next()){var i=r.value;i.cancel()}}catch(o){e={error:o}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.a.clear()}};function ba(e){var t,n;if(e.b!=null)return e.c.concat(e.b.s);if(e.a!=null&&e.a.size!==0){var r=e.c;try{for(var i=Ou(e.a.values()),o=i.next();!o.done;o=i.next()){var s=o.value;r=r.concat(s.s)}}catch(u){t={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}return Zi(e.c)}function wo(){}wo.prototype.stringify=function(e){return R.JSON.stringify(e,void 0)};wo.prototype.parse=function(e){return R.JSON.parse(e,void 0)};function El(){this.a=new wo}function Tl(e,t,n){var r=n||"";try{vo(e,function(i,o){var s=i;Ln(i)&&(s=ao(i)),t.push(r+o+"="+encodeURIComponent(s))})}catch(i){throw t.push(r+"type="+encodeURIComponent("_badmap")),i}}function _l(e,t){var n=new fo;if(R.Image){var r=new Image;r.onload=Jn(tr,n,r,"TestLoadImage: loaded",!0,t),r.onerror=Jn(tr,n,r,"TestLoadImage: error",!1,t),r.onabort=Jn(tr,n,r,"TestLoadImage: abort",!1,t),r.ontimeout=Jn(tr,n,r,"TestLoadImage: timeout",!1,t),R.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}function tr(e,t,n,r,i){try{t.onload=null,t.onerror=null,t.onabort=null,t.ontimeout=null,i(r)}catch{}}var Sl=R.JSON.parse;function Z(e){At.call(this),this.headers=new nn,this.H=e||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=Dl,this.D=this.F=!1}vt(Z,At);var Dl="",Nl=/^https?$/i,Al=["POST","PUT"];S=Z.prototype;S.ba=function(e,t,n,r){if(this.a)throw Error("[goog.net.XhrIo] Object is active with another request="+this.B+"; newUri="+e);t=t?t.toUpperCase():"GET",this.B=e,this.f="",this.h=0,this.u=!1,this.b=!0,this.a=new XMLHttpRequest,this.s=this.H?Is(this.H):Is(sa),this.a.onreadystatechange=ut(this.za,this);try{this.A=!0,this.a.open(t,String(e),!0),this.A=!1}catch(o){_s(this,o);return}e=n||"";var i=new nn(this.headers);r&&vo(r,function(o,s){i.set(s,o)}),r=Bh(i.L()),n=R.FormData&&e instanceof R.FormData,!(0<=Pu(Al,t))||r||n||i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach(function(o,s){this.a.setRequestHeader(s,o)},this),this.I&&(this.a.responseType=this.I),"withCredentials"in this.a&&this.a.withCredentials!==this.F&&(this.a.withCredentials=this.F);try{Ta(this),0<this.o&&((this.D=Cl(this.a))?(this.a.timeout=this.o,this.a.ontimeout=ut(this.xa,this)):this.m=lo(this.xa,this.o,this)),this.l=!0,this.a.send(e),this.l=!1}catch(o){_s(this,o)}};function Cl(e){return re&&Bu(9)&&typeof e.timeout=="number"&&e.ontimeout!==void 0}function kl(e){return e.toLowerCase()=="content-type"}S.xa=function(){typeof Ji<"u"&&this.a&&(this.f="Timed out after "+this.o+"ms, aborting",this.h=8,rt(this,"timeout"),this.abort(8))};function _s(e,t){e.b=!1,e.a&&(e.g=!0,e.a.abort(),e.g=!1),e.f=t,e.h=5,Ia(e),Kr(e)}function Ia(e){e.u||(e.u=!0,rt(e,"complete"),rt(e,"error"))}S.abort=function(e){this.a&&this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1,this.h=e||7,rt(this,"complete"),rt(this,"abort"),Kr(this))};S.G=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),Kr(this,!0)),Z.X.G.call(this)};S.za=function(){this.j||(this.A||this.l||this.g?Ea(this):this.Ua())};S.Ua=function(){Ea(this)};function Ea(e){if(e.b&&typeof Ji<"u"&&(!e.s[1]||te(e)!=4||e.W()!=2)){if(e.l&&te(e)==4)lo(e.za,0,e);else if(rt(e,"readystatechange"),te(e)==4){e.b=!1;try{{var t=e.W();t:switch(t){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var n=!0;break t;default:n=!1}var r;if(!(r=n)){var i;if(i=t===0){var o=String(e.B).match(fa)[1]||null;if(!o&&R.self&&R.self.location){var s=R.self.location.protocol;o=s.substr(0,s.length-1)}i=!Nl.test(o?o.toLowerCase():"")}r=i}var u=r}if(u)rt(e,"complete"),rt(e,"success");else{e.h=6;try{var a=2<te(e)?e.a.statusText:""}catch{a=""}e.f=a+" ["+e.W()+"]",Ia(e)}}finally{Kr(e)}}}}function Kr(e,t){if(e.a){Ta(e);var n=e.a,r=e.s[0]?lr:null;e.a=null,e.s=null,t||rt(e,"ready");try{n.onreadystatechange=r}catch{}}}function Ta(e){e.a&&e.D&&(e.a.ontimeout=null),e.m&&(R.clearTimeout(e.m),e.m=null)}function te(e){return e.a?e.a.readyState:0}S.W=function(){try{return 2<te(this)?this.a.status:-1}catch{return-1}};S.$=function(){try{return this.a?this.a.responseText:""}catch{return""}};S.Pa=function(e){if(this.a){var t=this.a.responseText;return e&&t.indexOf(e)==0&&(t=t.substring(e.length)),Sl(t)}};S.ua=function(){return this.h};S.Qa=function(){return typeof this.f=="string"?this.f:String(this.f)};function xl(e){var t="";return to(e,function(n,r){t+=r,t+=":",t+=n,t+=`\r
`}),t}function bo(e,t,n){t:{for(r in n){var r=!1;break t}r=!0}r||(n=xl(n),typeof e=="string"?n!=null&&encodeURIComponent(String(n)):K(e,t,n))}function fn(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function _a(e){this.pa=0,this.g=[],this.c=new fo,this.ga=this.la=this.B=this.fa=this.a=this.na=this.A=this.V=this.i=this.O=this.l=null,this.Oa=this.R=0,this.La=fn("failFast",!1,e),this.H=this.m=this.j=this.h=this.f=null,this.S=!0,this.I=this.oa=this.P=-1,this.T=this.o=this.u=0,this.Ha=fn("baseRetryDelayMs",5e3,e),this.Ra=fn("retryDelaySeedMs",1e4,e),this.Ma=fn("forwardChannelMaxRetries",2,e),this.ma=fn("forwardChannelRequestTimeoutMs",2e4,e),this.Na=e&&e.g||void 0,this.D=void 0,this.C=e&&e.supportsCrossDomainXhr||!1,this.J="",this.b=new va(e&&e.concurrentRequestLimit),this.ka=new El,this.da=e&&e.fastHandshake||!1,this.Ia=e&&e.b||!1,e&&e.f&&(this.c.a=!1),e&&e.forceLongPolling&&(this.S=!1),this.U=!this.da&&this.S&&e&&e.detectBufferingProxy||!1,this.ea=void 0,this.N=0,this.F=!1,this.s=null,(this.Ka=e&&e.c||!1)&&this.c.info("Opt-in to enable Chrome Origin Trials.")}S=_a.prototype;S.ha=8;S.v=1;function Io(e){if(Sa(e),e.v==3){var t=e.R++,n=zt(e.B);K(n,"SID",e.J),K(n,"RID",t),K(n,"TYPE","terminate"),Bn(e,n),t=new Un(e,e.c,t,void 0),t.H=2,t.i=jr(zt(n)),n=!1,R.navigator&&R.navigator.sendBeacon&&(n=R.navigator.sendBeacon(t.i.toString(),"")),!n&&R.Image&&(new Image().src=t.i,n=!0),n||(t.a=Oa(t.g,null),t.a.ba(t.i)),t.u=qt(),qn(t)}xa(e)}function Gr(e){e.a&&(To(e),e.a.cancel(),e.a=null)}function Sa(e){Gr(e),e.j&&(R.clearTimeout(e.j),e.j=null),gr(e),e.b.cancel(),e.h&&(typeof e.h=="number"&&R.clearTimeout(e.h),e.h=null)}function vi(e,t){e.g.push(new bl(e.Oa++,t)),e.v==3&&zr(e)}function zr(e){ma(e.b)||e.h||(e.h=!0,Wu(e.Ba,e),e.u=0)}function Rl(e,t){return ga(e.b)>=e.b.f-(e.h?1:0)?!1:e.h?(e.g=t.s.concat(e.g),!0):e.v==1||e.v==2||e.u>=(e.La?0:e.Ma)?!1:(e.h=Fn(ut(e.Ba,e,t),ka(e,e.u)),e.u++,!0)}S.Ba=function(e){if(this.h)if(this.h=null,this.v==1){if(!e){this.R=Math.floor(1e5*Math.random()),e=this.R++;var t=new Un(this,this.c,e,void 0),n=this.l;this.O&&(n?(n=Mu(n),Fu(n,this.O)):n=this.O),this.i===null&&(t.B=n);var r;if(this.da)t:{for(var i=r=0;i<this.g.length;i++){e:{var o=this.g[i];if("__data__"in o.a&&(o=o.a.__data__,typeof o=="string")){o=o.length;break e}o=void 0}if(o===void 0)break;if(r+=o,4096<r){r=i;break t}if(r===4096||i===this.g.length-1){r=i+1;break t}}r=1e3}else r=1e3;r=Da(this,t,r),i=zt(this.B),K(i,"RID",e),K(i,"CVER",22),this.A&&K(i,"X-HTTP-Session-Id",this.A),Bn(this,i),this.i&&n&&bo(i,this.i,n),go(this.b,t),this.Ia&&K(i,"TYPE","init"),this.da?(K(i,"$req",r),K(i,"SID","null"),t.U=!0,Ri(t,i,null)):Ri(t,i,r),this.v=2}}else this.v==3&&(e?Ss(this,e):this.g.length==0||ma(this.b)||Ss(this))};function Ss(e,t){var n;t?n=t.f:n=e.R++;var r=zt(e.B);K(r,"SID",e.J),K(r,"RID",n),K(r,"AID",e.P),Bn(e,r),e.i&&e.l&&bo(r,e.i,e.l),n=new Un(e,e.c,n,e.u+1),e.i===null&&(n.B=e.l),t&&(e.g=t.s.concat(e.g)),t=Da(e,n,1e3),n.setTimeout(Math.round(.5*e.ma)+Math.round(.5*e.ma*Math.random())),go(e.b,n),Ri(n,r,t)}function Bn(e,t){e.f&&vo({},function(n,r){K(t,r,n)})}function Da(e,t,n){n=Math.min(e.g.length,n);var r=e.f?ut(e.f.Ja,e.f,e):null;t:for(var i=e.g,o=-1;;){var s=["count="+n];o==-1?0<n?(o=i[0].b,s.push("ofs="+o)):o=0:s.push("ofs="+o);for(var u=!0,a=0;a<n;a++){var c=i[a].b,h=i[a].a;if(c-=o,0>c)o=Math.max(0,i[a].b-100),u=!1;else try{Tl(h,s,"req"+c+"_")}catch{r&&r(h)}}if(u){r=s.join("&");break t}}return e=e.g.splice(0,n),t.s=e,r}function Na(e){e.a||e.j||(e.T=1,Wu(e.Aa,e),e.o=0)}function Eo(e){return e.a||e.j||3<=e.o?!1:(e.T++,e.j=Fn(ut(e.Aa,e),ka(e,e.o)),e.o++,!0)}S.Aa=function(){if(this.j=null,Aa(this),this.U&&!(this.F||this.a==null||0>=this.N)){var e=2*this.N;this.c.info("BP detection timer enabled: "+e),this.s=Fn(ut(this.Ta,this),e)}};S.Ta=function(){this.s&&(this.s=null,this.c.info("BP detection timeout reached."),this.c.info("Buffering proxy detected and switch to long-polling!"),this.H=!1,this.F=!0,dt(10),Gr(this),Aa(this))};function To(e){e.s!=null&&(R.clearTimeout(e.s),e.s=null)}function Aa(e){e.a=new Un(e,e.c,"rpc",e.T),e.i===null&&(e.a.B=e.l),e.a.O=0;var t=zt(e.la);K(t,"RID","rpc"),K(t,"SID",e.J),K(t,"CI",e.H?"0":"1"),K(t,"AID",e.P),Bn(e,t),K(t,"TYPE","xmlhttp"),e.i&&e.l&&bo(t,e.i,e.l),e.D&&e.a.setTimeout(e.D);var n=e.a;e=e.ga,n.H=1,n.i=jr(zt(t)),n.j=null,n.I=!0,ca(n,e)}S.Sa=function(){this.m!=null&&(this.m=null,Gr(this),Eo(this),dt(19))};function gr(e){e.m!=null&&(R.clearTimeout(e.m),e.m=null)}function Ca(e,t){var n=null;if(e.a==t){gr(e),To(e),e.a=null;var r=2}else if(Pi(e.b,t))n=t.s,wa(e.b,t),r=1;else return;if(e.I=t.N,e.v!=0){if(t.b)if(r==1){n=t.j?t.j.length:0,t=qt()-t.u;var i=e.u;r=Ur(),rt(r,new na(r)),zr(e)}else Na(e);else if(i=t.h,i==3||i==0&&0<e.I||!(r==1&&Rl(e,t)||r==2&&Eo(e)))switch(n&&0<n.length&&(t=e.b,t.c=t.c.concat(n)),i){case 1:pe(e,5);break;case 4:pe(e,10);break;case 3:pe(e,6);break;default:pe(e,2)}}}function ka(e,t){var n=e.Ha+Math.floor(Math.random()*e.Ra);return e.f||(n*=2),n*t}function pe(e,t){if(e.c.info("Error code "+t),t==2){var n=null;e.f&&(n=null);var r=ut(e.Ya,e);n||(n=new be("//www.google.com/images/cleardot.gif"),R.location&&R.location.protocol=="http"||yr(n,"https"),jr(n)),_l(n.toString(),r)}else dt(2);e.v=0,e.f&&e.f.ra(t),xa(e),Sa(e)}S.Ya=function(e){e?(this.c.info("Successfully pinged google.com"),dt(2)):(this.c.info("Failed to ping google.com"),dt(1))};function xa(e){e.v=0,e.I=-1,e.f&&((ba(e.b).length!=0||e.g.length!=0)&&(e.b.c.length=0,Zi(e.g),e.g.length=0),e.f.qa())}function Ra(e,t,n){var r=fl(n);if(r.c!="")t&&vr(r,t+"."+r.c),mr(r,r.h);else{var i=R.location;r=pl(i.protocol,t?t+"."+i.hostname:i.hostname,+i.port,n)}return e.V&&to(e.V,function(o,s){K(r,s,o)}),t=e.A,n=e.na,t&&n&&K(r,t,n),K(r,"VER",e.ha),Bn(e,r),r}function Oa(e,t){if(t&&!e.C)throw Error("Can't create secondary domain capable XhrIo object.");return t=new Z(e.Na),t.F=e.C,t}function Pa(){}S=Pa.prototype;S.ta=function(){};S.sa=function(){};S.ra=function(){};S.qa=function(){};S.Ja=function(){};function wr(){if(re&&!(10<=Number(ju)))throw Error("Environmental error: no available transport.")}wr.prototype.a=function(e,t){return new Ct(e,t)};function Ct(e,t){At.call(this),this.a=new _a(t),this.o=e,this.b=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.a.l=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.a&&(e?e["X-WebChannel-Client-Profile"]=t.a:e={"X-WebChannel-Client-Profile":t.a}),this.a.O=e,(e=t&&t.httpHeadersOverwriteParam)&&!fr(e)&&(this.a.i=e),this.m=t&&t.supportsCrossDomainXhr||!1,this.l=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!fr(t)&&(this.a.A=t,e=this.b,e!==null&&t in e&&(e=this.b,t in e&&delete e[t])),this.f=new on(this)}vt(Ct,At);Ct.prototype.g=function(){this.a.f=this.f,this.m&&(this.a.C=!0);var e=this.a,t=this.o,n=this.b||void 0;dt(0),e.fa=t,e.V=n||{},e.H=e.S,e.B=Ra(e,null,e.fa),zr(e)};Ct.prototype.close=function(){Io(this.a)};Ct.prototype.h=function(e){if(typeof e=="string"){var t={};t.__data__=e,vi(this.a,t)}else this.l?(t={},t.__data__=ao(e),vi(this.a,t)):vi(this.a,e)};Ct.prototype.G=function(){this.a.f=null,delete this.f,Io(this.a),delete this.a,Ct.X.G.call(this)};function La(e){po.call(this);var t=e.__sm__;if(t){t:{for(var n in t){e=n;break t}e=void 0}(this.c=e)?(e=this.c,this.data=t!==null&&e in t?t[e]:void 0):this.data=t}else this.data=e}vt(La,po);function Ma(){yo.call(this),this.status=1}vt(Ma,yo);function on(e){this.a=e}vt(on,Pa);on.prototype.ta=function(){rt(this.a,"a")};on.prototype.sa=function(e){rt(this.a,new La(e))};on.prototype.ra=function(e){rt(this.a,new Ma)};on.prototype.qa=function(){rt(this.a,"b")};wr.prototype.createWebChannel=wr.prototype.a;Ct.prototype.send=Ct.prototype.h;Ct.prototype.open=Ct.prototype.g;Ct.prototype.close=Ct.prototype.close;qr.NO_ERROR=0;qr.TIMEOUT=8;qr.HTTP_ERROR=6;ra.COMPLETE="complete";oa.EventType=Vn;Vn.OPEN="a";Vn.CLOSE="b";Vn.ERROR="c";Vn.MESSAGE="d";At.prototype.listen=At.prototype.va;Z.prototype.listenOnce=Z.prototype.wa;Z.prototype.getLastError=Z.prototype.Qa;Z.prototype.getLastErrorCode=Z.prototype.ua;Z.prototype.getStatus=Z.prototype.W;Z.prototype.getResponseJson=Z.prototype.Pa;Z.prototype.getResponseText=Z.prototype.$;Z.prototype.send=Z.prototype.ba;var Ol=function(){return new wr},Pl=function(){return Ur()},mi=qr,Ll=ra,Ml=_e,Ds={gb:0,jb:1,kb:2,Db:3,Ib:4,Fb:5,Gb:6,Eb:7,Cb:8,Hb:9,PROXY:10,NOPROXY:11,Ab:12,wb:13,xb:14,vb:15,yb:16,zb:17,bb:18,ab:19,cb:20},er=oa,Fl=Z,Vl={};/**
* @license
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var St=function(){function e(t,n){var r=this;this.previousValue=t,n&&(n.sequenceNumberHandler=function(i){return r.t(i)},this.i=function(i){return n.writeSequenceNumber(i)})}return e.prototype.t=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},e.prototype.next=function(){var t=++this.previousValue;return this.i&&this.i(t),t},e}();St.o=-1;/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var d={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"},w=function(e){function t(n,r){var i=this;return(i=e.call(this,r)||this).code=n,i.message=r,i.name="FirebaseError",i.toString=function(){return i.name+": [code="+i.code+"]: "+i.message},i}return C(t,e),t}(Error),Rt=new xh("@firebase/firestore");function Li(){return Rt.logLevel}function I(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(Rt.logLevel<=Ue.DEBUG){var r=t.map(_o);Rt.debug.apply(Rt,$(["Firestore (8.3.3): "+e],r))}}function W(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(Rt.logLevel<=Ue.ERROR){var r=t.map(_o);Rt.error.apply(Rt,$(["Firestore (8.3.3): "+e],r))}}function Mi(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(Rt.logLevel<=Ue.WARN){var r=t.map(_o);Rt.warn.apply(Rt,$(["Firestore (8.3.3): "+e],r))}}function _o(e){if(typeof e=="string")return e;try{return t=e,JSON.stringify(t)}catch{return e}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var t}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function D(e){e===void 0&&(e="Unexpected state");var t="FIRESTORE (8.3.3) INTERNAL ASSERTION FAILED: "+e;throw W(t),new Error(t)}function x(e,t){e||D()}function _(e,t){return e}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Ul(e){var t=typeof self<"u"&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&typeof t.getRandomValues=="function")t.getRandomValues(n);else for(var r=0;r<e;r++)n[r]=Math.floor(256*Math.random());return n}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Fa=function(){function e(){}return e.u=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=Math.floor(256/t.length)*t.length,r="";r.length<20;)for(var i=Ul(40),o=0;o<i.length;++o)r.length<20&&i[o]<n&&(r+=t.charAt(i[o]%t.length));return r},e}();function L(e,t){return e<t?-1:e>t?1:0}function qe(e,t,n){return e.length===t.length&&e.every(function(r,i){return n(r,t[i])})}function Va(e){return e+"\0"}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var gt=function(){function e(t,n){if(this.seconds=t,this.nanoseconds=n,n<0)throw new w(d.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(n>=1e9)throw new w(d.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(t<-62135596800)throw new w(d.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new w(d.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}return e.now=function(){return e.fromMillis(Date.now())},e.fromDate=function(t){return e.fromMillis(t.getTime())},e.fromMillis=function(t){var n=Math.floor(t/1e3);return new e(n,1e6*(t-1e3*n))},e.prototype.toDate=function(){return new Date(this.toMillis())},e.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},e.prototype._compareTo=function(t){return this.seconds===t.seconds?L(this.nanoseconds,t.nanoseconds):L(this.seconds,t.seconds)},e.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},e.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},e.prototype.toJSON=function(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}},e.prototype.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")},e}(),P=function(){function e(t){this.timestamp=t}return e.fromTimestamp=function(t){return new e(t)},e.min=function(){return new e(new gt(0,0))},e.prototype.compareTo=function(t){return this.timestamp._compareTo(t.timestamp)},e.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},e.prototype.toMicroseconds=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},e.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},e.prototype.toTimestamp=function(){return this.timestamp},e}();/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*//**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Ns(e){var t=0;for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function jn(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function Ua(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var qa=function(){function e(t,n,r){n===void 0?n=0:n>t.length&&D(),r===void 0?r=t.length-n:r>t.length-n&&D(),this.segments=t,this.offset=n,this.len=r}return Object.defineProperty(e.prototype,"length",{get:function(){return this.len},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){return e.comparator(this,t)===0},e.prototype.child=function(t){var n=this.segments.slice(this.offset,this.limit());return t instanceof e?t.forEach(function(r){n.push(r)}):n.push(t),this.construct(n)},e.prototype.limit=function(){return this.offset+this.length},e.prototype.popFirst=function(t){return t=t===void 0?1:t,this.construct(this.segments,this.offset+t,this.length-t)},e.prototype.popLast=function(){return this.construct(this.segments,this.offset,this.length-1)},e.prototype.firstSegment=function(){return this.segments[this.offset]},e.prototype.lastSegment=function(){return this.get(this.length-1)},e.prototype.get=function(t){return this.segments[this.offset+t]},e.prototype.isEmpty=function(){return this.length===0},e.prototype.isPrefixOf=function(t){if(t.length<this.length)return!1;for(var n=0;n<this.length;n++)if(this.get(n)!==t.get(n))return!1;return!0},e.prototype.isImmediateParentOf=function(t){if(this.length+1!==t.length)return!1;for(var n=0;n<this.length;n++)if(this.get(n)!==t.get(n))return!1;return!0},e.prototype.forEach=function(t){for(var n=this.offset,r=this.limit();n<r;n++)t(this.segments[n])},e.prototype.toArray=function(){return this.segments.slice(this.offset,this.limit())},e.comparator=function(t,n){for(var r=Math.min(t.length,n.length),i=0;i<r;i++){var o=t.get(i),s=n.get(i);if(o<s)return-1;if(o>s)return 1}return t.length<n.length?-1:t.length>n.length?1:0},e}(),V=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t.prototype.construct=function(n,r,i){return new t(n,r,i)},t.prototype.canonicalString=function(){return this.toArray().join("/")},t.prototype.toString=function(){return this.canonicalString()},t.fromString=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];for(var i=[],o=0,s=n;o<s.length;o++){var u=s[o];if(u.indexOf("//")>=0)throw new w(d.INVALID_ARGUMENT,"Invalid segment ("+u+"). Paths must not contain // in them.");i.push.apply(i,u.split("/").filter(function(a){return a.length>0}))}return new t(i)},t.emptyPath=function(){return new t([])},t}(qa),ql=/^[_a-zA-Z][_a-zA-Z0-9]*$/,xt=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t.prototype.construct=function(n,r,i){return new t(n,r,i)},t.isValidIdentifier=function(n){return ql.test(n)},t.prototype.canonicalString=function(){return this.toArray().map(function(n){return n=n.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),t.isValidIdentifier(n)||(n="`"+n+"`"),n}).join(".")},t.prototype.toString=function(){return this.canonicalString()},t.prototype.isKeyField=function(){return this.length===1&&this.get(0)==="__name__"},t.keyField=function(){return new t(["__name__"])},t.fromServerFormat=function(n){for(var r=[],i="",o=0,s=function(){if(i.length===0)throw new w(d.INVALID_ARGUMENT,"Invalid field path ("+n+"). Paths must not be empty, begin with '.', end with '.', or contain '..'");r.push(i),i=""},u=!1;o<n.length;){var a=n[o];if(a==="\\"){if(o+1===n.length)throw new w(d.INVALID_ARGUMENT,"Path has trailing escape character: "+n);var c=n[o+1];if(c!=="\\"&&c!=="."&&c!=="`")throw new w(d.INVALID_ARGUMENT,"Path has invalid escape sequence: "+n);i+=c,o+=2}else a==="`"?(u=!u,o++):a!=="."||u?(i+=a,o++):(s(),o++)}if(s(),u)throw new w(d.INVALID_ARGUMENT,"Unterminated ` in path: "+n);return new t(r)},t.emptyPath=function(){return new t([])},t}(qa),Be=function(){function e(t){this.fields=t,t.sort(xt.comparator)}return e.prototype.covers=function(t){for(var n=0,r=this.fields;n<r.length;n++)if(r[n].isPrefixOf(t))return!0;return!1},e.prototype.isEqual=function(t){return qe(this.fields,t.fields,function(n,r){return n.isEqual(r)})},e}(),wt=function(){function e(t){this.binaryString=t}return e.fromBase64String=function(t){return new e(atob(t))},e.fromUint8Array=function(t){return new e(function(n){for(var r="",i=0;i<n.length;++i)r+=String.fromCharCode(n[i]);return r}(t))},e.prototype.toBase64=function(){return t=this.binaryString,btoa(t);var t},e.prototype.toUint8Array=function(){return function(t){for(var n=new Uint8Array(t.length),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}(this.binaryString)},e.prototype.approximateByteSize=function(){return 2*this.binaryString.length},e.prototype.compareTo=function(t){return L(this.binaryString,t.binaryString)},e.prototype.isEqual=function(t){return this.binaryString===t.binaryString},e}();wt.EMPTY_BYTE_STRING=new wt("");var Bl=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ie(e){if(x(!!e),typeof e=="string"){var t=0,n=Bl.exec(e);if(x(!!n),n[1]){var r=n[1];r=(r+"000000000").substr(0,9),t=Number(r)}var i=new Date(e);return{seconds:Math.floor(i.getTime()/1e3),nanos:t}}return{seconds:H(e.seconds),nanos:H(e.nanos)}}function H(e){return typeof e=="number"?e:typeof e=="string"?Number(e):0}function je(e){return typeof e=="string"?wt.fromBase64String(e):wt.fromUint8Array(e)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function So(e){var t,n;return((n=(((t=e==null?void 0:e.mapValue)===null||t===void 0?void 0:t.fields)||{}).__type__)===null||n===void 0?void 0:n.stringValue)==="server_timestamp"}function Ba(e){var t=e.mapValue.fields.__previous_value__;return So(t)?Ba(t):t}function Tn(e){var t=ie(e.mapValue.fields.__local_write_time__.timestampValue);return new gt(t.seconds,t.nanos)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Se(e){return e==null}function br(e){return e===0&&1/e==-1/0}function ja(e){return typeof e=="number"&&Number.isInteger(e)&&!br(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var N=function(){function e(t){this.path=t}return e.fromPath=function(t){return new e(V.fromString(t))},e.fromName=function(t){return new e(V.fromString(t).popFirst(5))},e.prototype.hasCollectionId=function(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t},e.prototype.isEqual=function(t){return t!==null&&V.comparator(this.path,t.path)===0},e.prototype.toString=function(){return this.path.toString()},e.comparator=function(t,n){return V.comparator(t.path,n.path)},e.isDocumentKey=function(t){return t.length%2==0},e.fromSegments=function(t){return new e(new V(t.slice()))},e}();/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function oe(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?So(e)?4:10:D()}function Vt(e,t){var n=oe(e);if(n!==oe(t))return!1;switch(n){case 0:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return Tn(e).isEqual(Tn(t));case 3:return function(r,i){if(typeof r.timestampValue=="string"&&typeof i.timestampValue=="string"&&r.timestampValue.length===i.timestampValue.length)return r.timestampValue===i.timestampValue;var o=ie(r.timestampValue),s=ie(i.timestampValue);return o.seconds===s.seconds&&o.nanos===s.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(r,i){return je(r.bytesValue).isEqual(je(i.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(r,i){return H(r.geoPointValue.latitude)===H(i.geoPointValue.latitude)&&H(r.geoPointValue.longitude)===H(i.geoPointValue.longitude)}(e,t);case 2:return function(r,i){if("integerValue"in r&&"integerValue"in i)return H(r.integerValue)===H(i.integerValue);if("doubleValue"in r&&"doubleValue"in i){var o=H(r.doubleValue),s=H(i.doubleValue);return o===s?br(o)===br(s):isNaN(o)&&isNaN(s)}return!1}(e,t);case 9:return qe(e.arrayValue.values||[],t.arrayValue.values||[],Vt);case 10:return function(r,i){var o=r.mapValue.fields||{},s=i.mapValue.fields||{};if(Ns(o)!==Ns(s))return!1;for(var u in o)if(o.hasOwnProperty(u)&&(s[u]===void 0||!Vt(o[u],s[u])))return!1;return!0}(e,t);default:return D()}}function _n(e,t){return(e.values||[]).find(function(n){return Vt(n,t)})!==void 0}function Ke(e,t){var n=oe(e),r=oe(t);if(n!==r)return L(n,r);switch(n){case 0:return 0;case 1:return L(e.booleanValue,t.booleanValue);case 2:return function(i,o){var s=H(i.integerValue||i.doubleValue),u=H(o.integerValue||o.doubleValue);return s<u?-1:s>u?1:s===u?0:isNaN(s)?isNaN(u)?0:-1:1}(e,t);case 3:return As(e.timestampValue,t.timestampValue);case 4:return As(Tn(e),Tn(t));case 5:return L(e.stringValue,t.stringValue);case 6:return function(i,o){var s=je(i),u=je(o);return s.compareTo(u)}(e.bytesValue,t.bytesValue);case 7:return function(i,o){for(var s=i.split("/"),u=o.split("/"),a=0;a<s.length&&a<u.length;a++){var c=L(s[a],u[a]);if(c!==0)return c}return L(s.length,u.length)}(e.referenceValue,t.referenceValue);case 8:return function(i,o){var s=L(H(i.latitude),H(o.latitude));return s!==0?s:L(H(i.longitude),H(o.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return function(i,o){for(var s=i.values||[],u=o.values||[],a=0;a<s.length&&a<u.length;++a){var c=Ke(s[a],u[a]);if(c)return c}return L(s.length,u.length)}(e.arrayValue,t.arrayValue);case 10:return function(i,o){var s=i.fields||{},u=Object.keys(s),a=o.fields||{},c=Object.keys(a);u.sort(),c.sort();for(var h=0;h<u.length&&h<c.length;++h){var l=L(u[h],c[h]);if(l!==0)return l;var f=Ke(s[u[h]],a[c[h]]);if(f!==0)return f}return L(u.length,c.length)}(e.mapValue,t.mapValue);default:throw D()}}function As(e,t){if(typeof e=="string"&&typeof t=="string"&&e.length===t.length)return L(e,t);var n=ie(e),r=ie(t),i=L(n.seconds,r.seconds);return i!==0?i:L(n.nanos,r.nanos)}function Do(e){return Fi(e)}function Fi(e){return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(r){var i=ie(r);return"time("+i.seconds+","+i.nanos+")"}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?je(e.bytesValue).toBase64():"referenceValue"in e?(n=e.referenceValue,N.fromName(n).toString()):"geoPointValue"in e?"geo("+(t=e.geoPointValue).latitude+","+t.longitude+")":"arrayValue"in e?function(r){for(var i="[",o=!0,s=0,u=r.values||[];s<u.length;s++)o?o=!1:i+=",",i+=Fi(u[s]);return i+"]"}(e.arrayValue):"mapValue"in e?function(r){for(var i="{",o=!0,s=0,u=Object.keys(r.fields||{}).sort();s<u.length;s++){var a=u[s];o?o=!1:i+=",",i+=a+":"+Fi(r.fields[a])}return i+"}"}(e.mapValue):D();var t,n}function Ir(e,t){return{referenceValue:"projects/"+e.projectId+"/databases/"+e.database+"/documents/"+t.path.canonicalString()}}function Vi(e){return!!e&&"integerValue"in e}function No(e){return!!e&&"arrayValue"in e}function Cs(e){return!!e&&"nullValue"in e}function ks(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function Ui(e){return!!e&&"mapValue"in e}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var _t=function(){function e(t){this.overlayMap=new Map,this.partialValue=t}return e.empty=function(){return new e({mapValue:{}})},e.prototype.field=function(t){return e.extractNestedValue(this.buildProto(),t)},e.prototype.toProto=function(){return this.field(xt.emptyPath())},e.prototype.set=function(t,n){this.setOverlay(t,n)},e.prototype.setAll=function(t){var n=this;t.forEach(function(r,i){r?n.set(i,r):n.delete(i)})},e.prototype.delete=function(t){this.setOverlay(t,null)},e.prototype.isEqual=function(t){return Vt(this.buildProto(),t.buildProto())},e.prototype.setOverlay=function(t,n){for(var r=this.overlayMap,i=0;i<t.length-1;++i){var o=t.get(i),s=r.get(o);s instanceof Map?r=s:s&&oe(s)===10?(s=new Map(Object.entries(s.mapValue.fields||{})),r.set(o,s),r=s):(s=new Map,r.set(o,s),r=s)}r.set(t.lastSegment(),n)},e.prototype.applyOverlay=function(t,n){var r=this,i=!1,o=e.extractNestedValue(this.partialValue,t),s=Ui(o)?Object.assign({},o.mapValue.fields):{};return n.forEach(function(u,a){if(u instanceof Map){var c=r.applyOverlay(t.child(a),u);c!=null&&(s[a]=c,i=!0)}else u!==null?(s[a]=u,i=!0):s.hasOwnProperty(a)&&(delete s[a],i=!0)}),i?{mapValue:{fields:s}}:null},e.prototype.buildProto=function(){var t=this.applyOverlay(xt.emptyPath(),this.overlayMap);return t!=null&&(this.partialValue=t,this.overlayMap.clear()),this.partialValue},e.extractNestedValue=function(t,n){if(n.isEmpty())return t;for(var r=t,i=0;i<n.length-1;++i)if(!r.mapValue.fields||!Ui(r=r.mapValue.fields[n.get(i)]))return null;return(r=(r.mapValue.fields||{})[n.lastSegment()])||null},e.prototype.clone=function(){return new e(this.buildProto())},e}();function Ka(e){var t=[];return jn(e.fields||{},function(n,r){var i=new xt([n]);if(Ui(r)){var o=Ka(r.mapValue).fields;if(o.length===0)t.push(i);else for(var s=0,u=o;s<u.length;s++){var a=u[s];t.push(i.child(a))}}else t.push(i)}),new Be(t)}var ct=function(){function e(t,n,r,i,o){this.key=t,this.documentType=n,this.version=r,this.data=i,this.documentState=o}return e.newInvalidDocument=function(t){return new e(t,0,P.min(),_t.empty(),0)},e.newFoundDocument=function(t,n,r){return new e(t,1,n,r,0)},e.newNoDocument=function(t,n){return new e(t,2,n,_t.empty(),0)},e.newUnknownDocument=function(t,n){return new e(t,3,n,_t.empty(),2)},e.prototype.convertToFoundDocument=function(t,n){return this.version=t,this.documentType=1,this.data=n,this.documentState=0,this},e.prototype.convertToNoDocument=function(t){return this.version=t,this.documentType=2,this.data=_t.empty(),this.documentState=0,this},e.prototype.convertToUnknownDocument=function(t){return this.version=t,this.documentType=3,this.data=_t.empty(),this.documentState=2,this},e.prototype.setHasCommittedMutations=function(){return this.documentState=2,this},e.prototype.setHasLocalMutations=function(){return this.documentState=1,this},Object.defineProperty(e.prototype,"hasLocalMutations",{get:function(){return this.documentState===1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasCommittedMutations",{get:function(){return this.documentState===2},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return this.hasLocalMutations||this.hasCommittedMutations},enumerable:!1,configurable:!0}),e.prototype.isValidDocument=function(){return this.documentType!==0},e.prototype.isFoundDocument=function(){return this.documentType===1},e.prototype.isNoDocument=function(){return this.documentType===2},e.prototype.isUnknownDocument=function(){return this.documentType===3},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)},e.prototype.clone=function(){return new e(this.key,this.documentType,this.version,this.data.clone(),this.documentState)},e.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+JSON.stringify(this.data.toProto())+", {documentType: "+this.documentType+"}), {documentState: "+this.documentState+"})"},e}(),jl=function(e,t,n,r,i,o,s){t===void 0&&(t=null),n===void 0&&(n=[]),r===void 0&&(r=[]),i===void 0&&(i=null),o===void 0&&(o=null),s===void 0&&(s=null),this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=s,this.h=null};/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function xs(e,t,n,r,i,o,s){return t===void 0&&(t=null),n===void 0&&(n=[]),r===void 0&&(r=[]),i===void 0&&(i=null),o===void 0&&(o=null),s===void 0&&(s=null),new jl(e,t,n,r,i,o,s)}function Kn(e){var t=_(e);if(t.h===null){var n=t.path.canonicalString();t.collectionGroup!==null&&(n+="|cg:"+t.collectionGroup),n+="|f:",n+=t.filters.map(function(r){return function(i){return i.field.canonicalString()+i.op.toString()+Do(i.value)}(r)}).join(","),n+="|ob:",n+=t.orderBy.map(function(r){return function(i){return i.field.canonicalString()+i.dir}(r)}).join(","),Se(t.limit)||(n+="|l:",n+=t.limit),t.startAt&&(n+="|lb:",n+=Tr(t.startAt)),t.endAt&&(n+="|ub:",n+=Tr(t.endAt)),t.h=n}return t.h}function Qr(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(var n=0;n<e.orderBy.length;n++)if(!Xl(e.orderBy[n],t.orderBy[n]))return!1;if(e.filters.length!==t.filters.length)return!1;for(var r=0;r<e.filters.length;r++)if(i=e.filters[r],o=t.filters[r],i.op!==o.op||!i.field.isEqual(o.field)||!Vt(i.value,o.value))return!1;var i,o;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!Os(e.startAt,t.startAt)&&Os(e.endAt,t.endAt)}function Er(e){return N.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}var Dt=function(e){function t(n,r,i){var o=this;return(o=e.call(this)||this).field=n,o.op=r,o.value=i,o}return C(t,e),t.create=function(n,r,i){return n.isKeyField()?r==="in"||r==="not-in"?this.l(n,r,i):new Kl(n,r,i):r==="array-contains"?new Ql(n,i):r==="in"?new $l(n,i):r==="not-in"?new Hl(n,i):r==="array-contains-any"?new Wl(n,i):new t(n,r,i)},t.l=function(n,r,i){return r==="in"?new Gl(n,i):new zl(n,i)},t.prototype.matches=function(n){var r=n.data.field(this.field);return this.op==="!="?r!==null&&this.m(Ke(r,this.value)):r!==null&&oe(this.value)===oe(r)&&this.m(Ke(r,this.value))},t.prototype.m=function(n){switch(this.op){case"<":return n<0;case"<=":return n<=0;case"==":return n===0;case"!=":return n!==0;case">":return n>0;case">=":return n>=0;default:return D()}},t.prototype.g=function(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0},t}(function(){}),Kl=function(e){function t(n,r,i){var o=this;return(o=e.call(this,n,r,i)||this).key=N.fromName(i.referenceValue),o}return C(t,e),t.prototype.matches=function(n){var r=N.comparator(n.key,this.key);return this.m(r)},t}(Dt),Gl=function(e){function t(n,r){var i=this;return(i=e.call(this,n,"in",r)||this).keys=Ga("in",r),i}return C(t,e),t.prototype.matches=function(n){return this.keys.some(function(r){return r.isEqual(n.key)})},t}(Dt),zl=function(e){function t(n,r){var i=this;return(i=e.call(this,n,"not-in",r)||this).keys=Ga("not-in",r),i}return C(t,e),t.prototype.matches=function(n){return!this.keys.some(function(r){return r.isEqual(n.key)})},t}(Dt);function Ga(e,t){var n;return(((n=t.arrayValue)===null||n===void 0?void 0:n.values)||[]).map(function(r){return N.fromName(r.referenceValue)})}var Ql=function(e){function t(n,r){return e.call(this,n,"array-contains",r)||this}return C(t,e),t.prototype.matches=function(n){var r=n.data.field(this.field);return No(r)&&_n(r.arrayValue,this.value)},t}(Dt),$l=function(e){function t(n,r){return e.call(this,n,"in",r)||this}return C(t,e),t.prototype.matches=function(n){var r=n.data.field(this.field);return r!==null&&_n(this.value.arrayValue,r)},t}(Dt),Hl=function(e){function t(n,r){return e.call(this,n,"not-in",r)||this}return C(t,e),t.prototype.matches=function(n){if(_n(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var r=n.data.field(this.field);return r!==null&&!_n(this.value.arrayValue,r)},t}(Dt),Wl=function(e){function t(n,r){return e.call(this,n,"array-contains-any",r)||this}return C(t,e),t.prototype.matches=function(n){var r=this,i=n.data.field(this.field);return!(!No(i)||!i.arrayValue.values)&&i.arrayValue.values.some(function(o){return _n(r.value.arrayValue,o)})},t}(Dt),Sn=function(e,t){this.position=e,this.before=t};function Tr(e){return(e.before?"b":"a")+":"+e.position.map(function(t){return Do(t)}).join(",")}var Ve=function(e,t){t===void 0&&(t="asc"),this.field=e,this.dir=t};function Xl(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}function Rs(e,t,n){for(var r=0,i=0;i<e.position.length;i++){var o=t[i],s=e.position[i];if(r=o.field.isKeyField()?N.comparator(N.fromName(s.referenceValue),n.key):Ke(s,n.data.field(o.field)),o.dir==="desc"&&(r*=-1),r!==0)break}return e.before?r<=0:r<0}function Os(e,t){if(e===null)return t===null;if(t===null||e.before!==t.before||e.position.length!==t.position.length)return!1;for(var n=0;n<e.position.length;n++)if(!Vt(e.position[n],t.position[n]))return!1;return!0}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Qt=function(e,t,n,r,i,o,s,u){t===void 0&&(t=null),n===void 0&&(n=[]),r===void 0&&(r=[]),i===void 0&&(i=null),o===void 0&&(o="F"),s===void 0&&(s=null),u===void 0&&(u=null),this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=o,this.startAt=s,this.endAt=u,this.p=null,this.T=null,this.startAt,this.endAt};function za(e,t,n,r,i,o,s,u){return new Qt(e,t,n,r,i,o,s,u)}function Gn(e){return new Qt(e)}function sr(e){return!Se(e.limit)&&e.limitType==="F"}function _r(e){return!Se(e.limit)&&e.limitType==="L"}function Ao(e){return e.explicitOrderBy.length>0?e.explicitOrderBy[0].field:null}function Co(e){for(var t=0,n=e.filters;t<n.length;t++){var r=n[t];if(r.g())return r.field}return null}function ko(e){return e.collectionGroup!==null}function Ge(e){var t=_(e);if(t.p===null){t.p=[];var n=Co(t),r=Ao(t);if(n!==null&&r===null)n.isKeyField()||t.p.push(new Ve(n)),t.p.push(new Ve(xt.keyField(),"asc"));else{for(var i=!1,o=0,s=t.explicitOrderBy;o<s.length;o++){var u=s[o];t.p.push(u),u.field.isKeyField()&&(i=!0)}if(!i){var a=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";t.p.push(new Ve(xt.keyField(),a))}}}return t.p}function Ut(e){var t=_(e);if(!t.T)if(t.limitType==="F")t.T=xs(t.path,t.collectionGroup,Ge(t),t.filters,t.limit,t.startAt,t.endAt);else{for(var n=[],r=0,i=Ge(t);r<i.length;r++){var o=i[r],s=o.dir==="desc"?"asc":"desc";n.push(new Ve(o.field,s))}var u=t.endAt?new Sn(t.endAt.position,!t.endAt.before):null,a=t.startAt?new Sn(t.startAt.position,!t.startAt.before):null;t.T=xs(t.path,t.collectionGroup,n,t.filters,t.limit,u,a)}return t.T}function Qa(e,t,n){return new Qt(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function zn(e,t){return Qr(Ut(e),Ut(t))&&e.limitType===t.limitType}function $a(e){return Kn(Ut(e))+"|lt:"+e.limitType}function qi(e){return"Query(target="+function(t){var n=t.path.canonicalString();return t.collectionGroup!==null&&(n+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(n+=", filters: ["+t.filters.map(function(r){return(i=r).field.canonicalString()+" "+i.op+" "+Do(i.value);var i}).join(", ")+"]"),Se(t.limit)||(n+=", limit: "+t.limit),t.orderBy.length>0&&(n+=", orderBy: ["+t.orderBy.map(function(r){return function(i){return i.field.canonicalString()+" ("+i.dir+")"}(r)}).join(", ")+"]"),t.startAt&&(n+=", startAt: "+Tr(t.startAt)),t.endAt&&(n+=", endAt: "+Tr(t.endAt)),"Target("+n+")"}(Ut(e))+"; limitType="+e.limitType+")"}function Qn(e,t){return t.isFoundDocument()&&function(n,r){var i=r.key.path;return n.collectionGroup!==null?r.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(i):N.isDocumentKey(n.path)?n.path.isEqual(i):n.path.isImmediateParentOf(i)}(e,t)&&function(n,r){for(var i=0,o=n.explicitOrderBy;i<o.length;i++){var s=o[i];if(!s.field.isKeyField()&&r.data.field(s.field)===null)return!1}return!0}(e,t)&&function(n,r){for(var i=0,o=n.filters;i<o.length;i++)if(!o[i].matches(r))return!1;return!0}(e,t)&&function(n,r){return!(n.startAt&&!Rs(n.startAt,Ge(n),r))&&(!n.endAt||!Rs(n.endAt,Ge(n),r))}(e,t)}function Ha(e){return function(t,n){for(var r=!1,i=0,o=Ge(e);i<o.length;i++){var s=o[i],u=Yl(s,t,n);if(u!==0)return u;r=r||s.field.isKeyField()}return 0}}function Yl(e,t,n){var r=e.field.isKeyField()?N.comparator(t.key,n.key):function(i,o,s){var u=o.data.field(i),a=s.data.field(i);return u!==null&&a!==null?Ke(u,a):D()}(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return D()}}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Wa(e,t){if(e.I){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:br(t)?"-0":t}}function Xa(e){return{integerValue:""+e}}function Ya(e,t){return ja(t)?Xa(t):Wa(e,t)}/**
* @license
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var $r=function(){this._=void 0};function Jl(e,t,n){return e instanceof ze?function(r,i){var o={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:r.seconds,nanos:r.nanoseconds}}}};return i&&(o.fields.__previous_value__=i),{mapValue:o}}(n,t):e instanceof Ie?Za(e,t):e instanceof Ee?tc(e,t):function(r,i){var o=Ja(r,i),s=Ps(o)+Ps(r.A);return Vi(o)&&Vi(r.A)?Xa(s):Wa(r.R,s)}(e,t)}function Zl(e,t,n){return e instanceof Ie?Za(e,t):e instanceof Ee?tc(e,t):n}function Ja(e,t){return e instanceof Qe?Vi(n=t)||function(r){return!!r&&"doubleValue"in r}(n)?t:{integerValue:0}:null;var n}var ze=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t}($r),Ie=function(e){function t(n){var r=this;return(r=e.call(this)||this).elements=n,r}return C(t,e),t}($r);function Za(e,t){for(var n=ec(t),r=function(s){n.some(function(u){return Vt(u,s)})||n.push(s)},i=0,o=e.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var Ee=function(e){function t(n){var r=this;return(r=e.call(this)||this).elements=n,r}return C(t,e),t}($r);function tc(e,t){for(var n=ec(t),r=function(s){n=n.filter(function(u){return!Vt(u,s)})},i=0,o=e.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var Qe=function(e){function t(n,r){var i=this;return(i=e.call(this)||this).R=n,i.A=r,i}return C(t,e),t}($r);function Ps(e){return H(e.integerValue||e.doubleValue)}function ec(e){return No(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var $n=function(e,t){this.field=e,this.transform=t},tf=function(e,t){this.version=e,this.transformResults=t},st=function(){function e(t,n){this.updateTime=t,this.exists=n}return e.none=function(){return new e},e.exists=function(t){return new e(void 0,t)},e.updateTime=function(t){return new e(t)},Object.defineProperty(e.prototype,"isNone",{get:function(){return this.updateTime===void 0&&this.exists===void 0},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)},e}();function ur(e,t){return e.updateTime!==void 0?t.isFoundDocument()&&t.version.isEqual(e.updateTime):e.exists===void 0||e.exists===t.isFoundDocument()}var Hr=function(){};function ef(e,t,n){e instanceof Hn?function(r,i,o){var s=r.value.clone(),u=Fs(r.fieldTransforms,i,o.transformResults);s.setAll(u),i.convertToFoundDocument(o.version,s).setHasCommittedMutations()}(e,t,n):e instanceof ce?function(r,i,o){if(ur(r.precondition,i)){var s=Fs(r.fieldTransforms,i,o.transformResults),u=i.data;u.setAll(nc(r)),u.setAll(s),i.convertToFoundDocument(o.version,u).setHasCommittedMutations()}else i.convertToUnknownDocument(o.version)}(e,t,n):function(r,i,o){i.convertToNoDocument(o.version).setHasCommittedMutations()}(0,t,n)}function Bi(e,t,n){e instanceof Hn?function(r,i,o){if(ur(r.precondition,i)){var s=r.value.clone(),u=Vs(r.fieldTransforms,o,i);s.setAll(u),i.convertToFoundDocument(Ms(i),s).setHasLocalMutations()}}(e,t,n):e instanceof ce?function(r,i,o){if(ur(r.precondition,i)){var s=Vs(r.fieldTransforms,o,i),u=i.data;u.setAll(nc(r)),u.setAll(s),i.convertToFoundDocument(Ms(i),u).setHasLocalMutations()}}(e,t,n):function(r,i){ur(r.precondition,i)&&i.convertToNoDocument(P.min())}(e,t)}function nf(e,t){for(var n=null,r=0,i=e.fieldTransforms;r<i.length;r++){var o=i[r],s=t.data.field(o.field),u=Ja(o.transform,s||null);u!=null&&(n==null&&(n=_t.empty()),n.set(o.field,u))}return n||null}function Ls(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!function(n,r){return n===void 0&&r===void 0||!(!n||!r)&&qe(n,r,function(i,o){return function(s,u){return s.field.isEqual(u.field)&&function(a,c){return a instanceof Ie&&c instanceof Ie||a instanceof Ee&&c instanceof Ee?qe(a.elements,c.elements,Vt):a instanceof Qe&&c instanceof Qe?Vt(a.A,c.A):a instanceof ze&&c instanceof ze}(s.transform,u.transform)}(i,o)})}(e.fieldTransforms,t.fieldTransforms)&&(e.type===0?e.value.isEqual(t.value):e.type!==1||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}function Ms(e){return e.isFoundDocument()?e.version:P.min()}var Hn=function(e){function t(n,r,i,o){o===void 0&&(o=[]);var s=this;return(s=e.call(this)||this).key=n,s.value=r,s.precondition=i,s.fieldTransforms=o,s.type=0,s}return C(t,e),t}(Hr),ce=function(e){function t(n,r,i,o,s){s===void 0&&(s=[]);var u=this;return(u=e.call(this)||this).key=n,u.data=r,u.fieldMask=i,u.precondition=o,u.fieldTransforms=s,u.type=1,u}return C(t,e),t}(Hr);function nc(e){var t=new Map;return e.fieldMask.fields.forEach(function(n){if(!n.isEmpty()){var r=e.data.field(n);t.set(n,r)}}),t}function Fs(e,t,n){var r=new Map;x(e.length===n.length);for(var i=0;i<n.length;i++){var o=e[i],s=o.transform,u=t.data.field(o.field);r.set(o.field,Zl(s,u,n[i]))}return r}function Vs(e,t,n){for(var r=new Map,i=0,o=e;i<o.length;i++){var s=o[i],u=s.transform,a=n.data.field(s.field);r.set(s.field,Jl(u,a,t))}return r}var Q,F,Wn=function(e){function t(n,r){var i=this;return(i=e.call(this)||this).key=n,i.precondition=r,i.type=2,i.fieldTransforms=[],i}return C(t,e),t}(Hr),xo=function(e){function t(n,r){var i=this;return(i=e.call(this)||this).key=n,i.precondition=r,i.type=3,i.fieldTransforms=[],i}return C(t,e),t}(Hr),rf=function(e){this.count=e};function rc(e){switch(e){case d.OK:return D();case d.CANCELLED:case d.UNKNOWN:case d.DEADLINE_EXCEEDED:case d.RESOURCE_EXHAUSTED:case d.INTERNAL:case d.UNAVAILABLE:case d.UNAUTHENTICATED:return!1;case d.INVALID_ARGUMENT:case d.NOT_FOUND:case d.ALREADY_EXISTS:case d.PERMISSION_DENIED:case d.FAILED_PRECONDITION:case d.ABORTED:case d.OUT_OF_RANGE:case d.UNIMPLEMENTED:case d.DATA_LOSS:return!0;default:return D()}}function ic(e){if(e===void 0)return W("GRPC error has no .code"),d.UNKNOWN;switch(e){case Q.OK:return d.OK;case Q.CANCELLED:return d.CANCELLED;case Q.UNKNOWN:return d.UNKNOWN;case Q.DEADLINE_EXCEEDED:return d.DEADLINE_EXCEEDED;case Q.RESOURCE_EXHAUSTED:return d.RESOURCE_EXHAUSTED;case Q.INTERNAL:return d.INTERNAL;case Q.UNAVAILABLE:return d.UNAVAILABLE;case Q.UNAUTHENTICATED:return d.UNAUTHENTICATED;case Q.INVALID_ARGUMENT:return d.INVALID_ARGUMENT;case Q.NOT_FOUND:return d.NOT_FOUND;case Q.ALREADY_EXISTS:return d.ALREADY_EXISTS;case Q.PERMISSION_DENIED:return d.PERMISSION_DENIED;case Q.FAILED_PRECONDITION:return d.FAILED_PRECONDITION;case Q.ABORTED:return d.ABORTED;case Q.OUT_OF_RANGE:return d.OUT_OF_RANGE;case Q.UNIMPLEMENTED:return d.UNIMPLEMENTED;case Q.DATA_LOSS:return d.DATA_LOSS;default:return D()}}(F=Q||(Q={}))[F.OK=0]="OK",F[F.CANCELLED=1]="CANCELLED",F[F.UNKNOWN=2]="UNKNOWN",F[F.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",F[F.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",F[F.NOT_FOUND=5]="NOT_FOUND",F[F.ALREADY_EXISTS=6]="ALREADY_EXISTS",F[F.PERMISSION_DENIED=7]="PERMISSION_DENIED",F[F.UNAUTHENTICATED=16]="UNAUTHENTICATED",F[F.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",F[F.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",F[F.ABORTED=10]="ABORTED",F[F.OUT_OF_RANGE=11]="OUT_OF_RANGE",F[F.UNIMPLEMENTED=12]="UNIMPLEMENTED",F[F.INTERNAL=13]="INTERNAL",F[F.UNAVAILABLE=14]="UNAVAILABLE",F[F.DATA_LOSS=15]="DATA_LOSS";/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var ht=function(){function e(t,n){this.comparator=t,this.root=n||Xt.EMPTY}return e.prototype.insert=function(t,n){return new e(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,Xt.BLACK,null,null))},e.prototype.remove=function(t){return new e(this.comparator,this.root.remove(t,this.comparator).copy(null,null,Xt.BLACK,null,null))},e.prototype.get=function(t){for(var n=this.root;!n.isEmpty();){var r=this.comparator(t,n.key);if(r===0)return n.value;r<0?n=n.left:r>0&&(n=n.right)}return null},e.prototype.indexOf=function(t){for(var n=0,r=this.root;!r.isEmpty();){var i=this.comparator(t,r.key);if(i===0)return n+r.left.size;i<0?r=r.left:(n+=r.left.size+1,r=r.right)}return-1},e.prototype.isEmpty=function(){return this.root.isEmpty()},Object.defineProperty(e.prototype,"size",{get:function(){return this.root.size},enumerable:!1,configurable:!0}),e.prototype.minKey=function(){return this.root.minKey()},e.prototype.maxKey=function(){return this.root.maxKey()},e.prototype.inorderTraversal=function(t){return this.root.inorderTraversal(t)},e.prototype.forEach=function(t){this.inorderTraversal(function(n,r){return t(n,r),!1})},e.prototype.toString=function(){var t=[];return this.inorderTraversal(function(n,r){return t.push(n+":"+r),!1}),"{"+t.join(", ")+"}"},e.prototype.reverseTraversal=function(t){return this.root.reverseTraversal(t)},e.prototype.getIterator=function(){return new nr(this.root,null,this.comparator,!1)},e.prototype.getIteratorFrom=function(t){return new nr(this.root,t,this.comparator,!1)},e.prototype.getReverseIterator=function(){return new nr(this.root,null,this.comparator,!0)},e.prototype.getReverseIteratorFrom=function(t){return new nr(this.root,t,this.comparator,!0)},e}(),nr=function(){function e(t,n,r,i){this.isReverse=i,this.nodeStack=[];for(var o=1;!t.isEmpty();)if(o=n?r(t.key,n):1,i&&(o*=-1),o<0)t=this.isReverse?t.left:t.right;else{if(o===0){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}return e.prototype.getNext=function(){var t=this.nodeStack.pop(),n={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return n},e.prototype.hasNext=function(){return this.nodeStack.length>0},e.prototype.peek=function(){if(this.nodeStack.length===0)return null;var t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}},e}(),Xt=function(){function e(t,n,r,i,o){this.key=t,this.value=n,this.color=r??e.RED,this.left=i??e.EMPTY,this.right=o??e.EMPTY,this.size=this.left.size+1+this.right.size}return e.prototype.copy=function(t,n,r,i,o){return new e(t??this.key,n??this.value,r??this.color,i??this.left,o??this.right)},e.prototype.isEmpty=function(){return!1},e.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},e.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},e.prototype.min=function(){return this.left.isEmpty()?this:this.left.min()},e.prototype.minKey=function(){return this.min().key},e.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},e.prototype.insert=function(t,n,r){var i=this,o=r(t,i.key);return(i=o<0?i.copy(null,null,null,i.left.insert(t,n,r),null):o===0?i.copy(null,n,null,null,null):i.copy(null,null,null,null,i.right.insert(t,n,r))).fixUp()},e.prototype.removeMin=function(){if(this.left.isEmpty())return e.EMPTY;var t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),(t=t.copy(null,null,null,t.left.removeMin(),null)).fixUp()},e.prototype.remove=function(t,n){var r,i=this;if(n(t,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),n(t,i.key)===0){if(i.right.isEmpty())return e.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,n))}return i.fixUp()},e.prototype.isRed=function(){return this.color},e.prototype.fixUp=function(){var t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t},e.prototype.moveRedLeft=function(){var t=this.colorFlip();return t.right.left.isRed()&&(t=(t=(t=t.copy(null,null,null,null,t.right.rotateRight())).rotateLeft()).colorFlip()),t},e.prototype.moveRedRight=function(){var t=this.colorFlip();return t.left.left.isRed()&&(t=(t=t.rotateRight()).colorFlip()),t},e.prototype.rotateLeft=function(){var t=this.copy(null,null,e.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},e.prototype.rotateRight=function(){var t=this.copy(null,null,e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},e.prototype.colorFlip=function(){var t=this.left.copy(null,null,!this.left.color,null,null),n=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,n)},e.prototype.checkMaxDepth=function(){var t=this.check();return Math.pow(2,t)<=this.size+1},e.prototype.check=function(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw D();var t=this.left.check();if(t!==this.right.check())throw D();return t+(this.isRed()?0:1)},e}();Xt.EMPTY=null,Xt.RED=!0,Xt.BLACK=!1,Xt.EMPTY=new(function(){function e(){this.size=0}return Object.defineProperty(e.prototype,"key",{get:function(){throw D()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){throw D()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"color",{get:function(){throw D()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"left",{get:function(){throw D()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"right",{get:function(){throw D()},enumerable:!1,configurable:!0}),e.prototype.copy=function(t,n,r,i,o){return this},e.prototype.insert=function(t,n,r){return new Xt(t,n)},e.prototype.remove=function(t,n){return this},e.prototype.isEmpty=function(){return!0},e.prototype.inorderTraversal=function(t){return!1},e.prototype.reverseTraversal=function(t){return!1},e.prototype.minKey=function(){return null},e.prototype.maxKey=function(){return null},e.prototype.isRed=function(){return!1},e.prototype.checkMaxDepth=function(){return!0},e.prototype.check=function(){return 0},e}());/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var J=function(){function e(t){this.comparator=t,this.data=new ht(this.comparator)}return e.prototype.has=function(t){return this.data.get(t)!==null},e.prototype.first=function(){return this.data.minKey()},e.prototype.last=function(){return this.data.maxKey()},Object.defineProperty(e.prototype,"size",{get:function(){return this.data.size},enumerable:!1,configurable:!0}),e.prototype.indexOf=function(t){return this.data.indexOf(t)},e.prototype.forEach=function(t){this.data.inorderTraversal(function(n,r){return t(n),!1})},e.prototype.forEachInRange=function(t,n){for(var r=this.data.getIteratorFrom(t[0]);r.hasNext();){var i=r.getNext();if(this.comparator(i.key,t[1])>=0)return;n(i.key)}},e.prototype.forEachWhile=function(t,n){var r;for(r=n!==void 0?this.data.getIteratorFrom(n):this.data.getIterator();r.hasNext();)if(!t(r.getNext().key))return},e.prototype.firstAfterOrEqual=function(t){var n=this.data.getIteratorFrom(t);return n.hasNext()?n.getNext().key:null},e.prototype.getIterator=function(){return new Us(this.data.getIterator())},e.prototype.getIteratorFrom=function(t){return new Us(this.data.getIteratorFrom(t))},e.prototype.add=function(t){return this.copy(this.data.remove(t).insert(t,!0))},e.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},e.prototype.isEmpty=function(){return this.data.isEmpty()},e.prototype.unionWith=function(t){var n=this;return n.size<t.size&&(n=t,t=this),t.forEach(function(r){n=n.add(r)}),n},e.prototype.isEqual=function(t){if(!(t instanceof e)||this.size!==t.size)return!1;for(var n=this.data.getIterator(),r=t.data.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(this.comparator(i,o)!==0)return!1}return!0},e.prototype.toArray=function(){var t=[];return this.forEach(function(n){t.push(n)}),t},e.prototype.toString=function(){var t=[];return this.forEach(function(n){return t.push(n)}),"SortedSet("+t.toString()+")"},e.prototype.copy=function(t){var n=new e(this.comparator);return n.data=t,n},e}(),Us=function(){function e(t){this.iter=t}return e.prototype.getNext=function(){return this.iter.getNext().key},e.prototype.hasNext=function(){return this.iter.hasNext()},e}(),of=new ht(N.comparator);function Ot(){return of}var sf=new ht(N.comparator);function ji(){return sf}var uf=new ht(N.comparator);function af(){return uf}var cf=new J(N.comparator);function B(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=cf,r=0,i=e;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var hf=new J(L);function Wr(){return hf}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Ro=function(){function e(t,n,r,i,o){this.snapshotVersion=t,this.targetChanges=n,this.targetMismatches=r,this.documentUpdates=i,this.resolvedLimboDocuments=o}return e.createSynthesizedRemoteEventForCurrentChange=function(t,n){var r=new Map;return r.set(t,Oo.createSynthesizedTargetChangeForCurrentChange(t,n)),new e(P.min(),r,Wr(),Ot(),B())},e}(),Oo=function(){function e(t,n,r,i,o){this.resumeToken=t,this.current=n,this.addedDocuments=r,this.modifiedDocuments=i,this.removedDocuments=o}return e.createSynthesizedTargetChangeForCurrentChange=function(t,n){return new e(wt.EMPTY_BYTE_STRING,n,B(),B(),B())},e}(),ar=function(e,t,n,r){this.v=e,this.removedTargetIds=t,this.key=n,this.P=r},oc=function(e,t){this.targetId=e,this.V=t},sc=function(e,t,n,r){n===void 0&&(n=wt.EMPTY_BYTE_STRING),r===void 0&&(r=null),this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r},qs=function(){function e(){this.S=0,this.D=js(),this.C=wt.EMPTY_BYTE_STRING,this.N=!1,this.F=!0}return Object.defineProperty(e.prototype,"current",{get:function(){return this.N},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"resumeToken",{get:function(){return this.C},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"k",{get:function(){return this.S!==0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"O",{get:function(){return this.F},enumerable:!1,configurable:!0}),e.prototype.$=function(t){t.approximateByteSize()>0&&(this.F=!0,this.C=t)},e.prototype.M=function(){var t=B(),n=B(),r=B();return this.D.forEach(function(i,o){switch(o){case 0:t=t.add(i);break;case 2:n=n.add(i);break;case 1:r=r.add(i);break;default:D()}}),new Oo(this.C,this.N,t,n,r)},e.prototype.L=function(){this.F=!1,this.D=js()},e.prototype.B=function(t,n){this.F=!0,this.D=this.D.insert(t,n)},e.prototype.q=function(t){this.F=!0,this.D=this.D.remove(t)},e.prototype.U=function(){this.S+=1},e.prototype.K=function(){this.S-=1},e.prototype.j=function(){this.F=!0,this.N=!0},e}(),lf=function(){function e(t){this.W=t,this.G=new Map,this.H=Ot(),this.J=Bs(),this.Y=new J(L)}return e.prototype.X=function(t){for(var n=0,r=t.v;n<r.length;n++){var i=r[n];t.P&&t.P.isFoundDocument()?this.Z(i,t.P):this.tt(i,t.key,t.P)}for(var o=0,s=t.removedTargetIds;o<s.length;o++)i=s[o],this.tt(i,t.key,t.P)},e.prototype.et=function(t){var n=this;this.forEachTarget(t,function(r){var i=n.nt(r);switch(t.state){case 0:n.st(r)&&i.$(t.resumeToken);break;case 1:i.K(),i.k||i.L(),i.$(t.resumeToken);break;case 2:i.K(),i.k||n.removeTarget(r);break;case 3:n.st(r)&&(i.j(),i.$(t.resumeToken));break;case 4:n.st(r)&&(n.it(r),i.$(t.resumeToken));break;default:D()}})},e.prototype.forEachTarget=function(t,n){var r=this;t.targetIds.length>0?t.targetIds.forEach(n):this.G.forEach(function(i,o){r.st(o)&&n(o)})},e.prototype.rt=function(t){var n=t.targetId,r=t.V.count,i=this.ot(n);if(i){var o=i.target;if(Er(o))if(r===0){var s=new N(o.path);this.tt(n,s,ct.newNoDocument(s,P.min()))}else x(r===1);else this.ct(n)!==r&&(this.it(n),this.Y=this.Y.add(n))}},e.prototype.ut=function(t){var n=this,r=new Map;this.G.forEach(function(s,u){var a=n.ot(u);if(a){if(s.current&&Er(a.target)){var c=new N(a.target.path);n.H.get(c)!==null||n.at(u,c)||n.tt(u,c,ct.newNoDocument(c,t))}s.O&&(r.set(u,s.M()),s.L())}});var i=B();this.J.forEach(function(s,u){var a=!0;u.forEachWhile(function(c){var h=n.ot(c);return!h||h.purpose===2||(a=!1,!1)}),a&&(i=i.add(s))});var o=new Ro(t,r,this.Y,this.H,i);return this.H=Ot(),this.J=Bs(),this.Y=new J(L),o},e.prototype.Z=function(t,n){if(this.st(t)){var r=this.at(t,n.key)?2:0;this.nt(t).B(n.key,r),this.H=this.H.insert(n.key,n),this.J=this.J.insert(n.key,this.ht(n.key).add(t))}},e.prototype.tt=function(t,n,r){if(this.st(t)){var i=this.nt(t);this.at(t,n)?i.B(n,1):i.q(n),this.J=this.J.insert(n,this.ht(n).delete(t)),r&&(this.H=this.H.insert(n,r))}},e.prototype.removeTarget=function(t){this.G.delete(t)},e.prototype.ct=function(t){var n=this.nt(t).M();return this.W.getRemoteKeysForTarget(t).size+n.addedDocuments.size-n.removedDocuments.size},e.prototype.U=function(t){this.nt(t).U()},e.prototype.nt=function(t){var n=this.G.get(t);return n||(n=new qs,this.G.set(t,n)),n},e.prototype.ht=function(t){var n=this.J.get(t);return n||(n=new J(L),this.J=this.J.insert(t,n)),n},e.prototype.st=function(t){var n=this.ot(t)!==null;return n||I("WatchChangeAggregator","Detected inactive target",t),n},e.prototype.ot=function(t){var n=this.G.get(t);return n&&n.k?null:this.W.lt(t)},e.prototype.it=function(t){var n=this;this.G.set(t,new qs),this.W.getRemoteKeysForTarget(t).forEach(function(r){n.tt(t,r,null)})},e.prototype.at=function(t,n){return this.W.getRemoteKeysForTarget(t).has(n)},e}();function Bs(){return new ht(N.comparator)}function js(){return new ht(N.comparator)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var ff={asc:"ASCENDING",desc:"DESCENDING"},pf={"<":"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"},df=function(e,t){this.databaseId=e,this.I=t};function Dn(e,t){return e.I?new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+t.nanoseconds).slice(-9)+"Z":{seconds:""+t.seconds,nanos:t.nanoseconds}}function uc(e,t){return e.I?t.toBase64():t.toUint8Array()}function yf(e,t){return Dn(e,t.toTimestamp())}function yt(e){return x(!!e),P.fromTimestamp(function(t){var n=ie(t);return new gt(n.seconds,n.nanos)}(e))}function Po(e,t){return function(n){return new V(["projects",n.projectId,"databases",n.database])}(e).child("documents").child(t).canonicalString()}function ac(e){var t=V.fromString(e);return x(yc(t)),t}function Nn(e,t){return Po(e.databaseId,t.path)}function jt(e,t){var n=ac(t);if(n.get(1)!==e.databaseId.projectId)throw new w(d.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new w(d.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new N(hc(n))}function Ki(e,t){return Po(e.databaseId,t)}function cc(e){var t=ac(e);return t.length===4?V.emptyPath():hc(t)}function An(e){return new V(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function hc(e){return x(e.length>4&&e.get(4)==="documents"),e.popFirst(5)}function Ks(e,t,n){return{name:Nn(e,t),fields:n.toProto().mapValue.fields}}function vf(e,t,n){var r=jt(e,t.name),i=yt(t.updateTime),o=new _t({mapValue:{fields:t.fields}}),s=ct.newFoundDocument(r,i,o);return n&&s.setHasCommittedMutations(),n?s.setHasCommittedMutations():s}function Sr(e,t){var n;if(t instanceof Hn)n={update:Ks(e,t.key,t.value)};else if(t instanceof Wn)n={delete:Nn(e,t.key)};else if(t instanceof ce)n={update:Ks(e,t.key,t.data),updateMask:If(t.fieldMask)};else{if(!(t instanceof xo))return D();n={verify:Nn(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map(function(r){return function(i,o){var s=o.transform;if(s instanceof ze)return{fieldPath:o.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(s instanceof Ie)return{fieldPath:o.field.canonicalString(),appendMissingElements:{values:s.elements}};if(s instanceof Ee)return{fieldPath:o.field.canonicalString(),removeAllFromArray:{values:s.elements}};if(s instanceof Qe)return{fieldPath:o.field.canonicalString(),increment:s.A};throw D()}(0,r)})),t.precondition.isNone||(n.currentDocument=function(r,i){return i.updateTime!==void 0?{updateTime:yf(r,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:D()}(e,t.precondition)),n}function Gs(e,t){var n=t.currentDocument?function(c){return c.updateTime!==void 0?st.updateTime(yt(c.updateTime)):c.exists!==void 0?st.exists(c.exists):st.none()}(t.currentDocument):st.none(),r=t.updateTransforms?t.updateTransforms.map(function(c){return function(h,l){var f=null;if("setToServerValue"in l)x(l.setToServerValue==="REQUEST_TIME"),f=new ze;else if("appendMissingElements"in l){var y=l.appendMissingElements.values||[];f=new Ie(y)}else if("removeAllFromArray"in l){var p=l.removeAllFromArray.values||[];f=new Ee(p)}else"increment"in l?f=new Qe(h,l.increment):D();var v=xt.fromServerFormat(l.fieldPath);return new $n(v,f)}(e,c)}):[];if(t.update){t.update.name;var i=jt(e,t.update.name),o=new _t({mapValue:{fields:t.update.fields}});if(t.updateMask){var s=function(c){var h=c.fieldPaths||[];return new Be(h.map(function(l){return xt.fromServerFormat(l)}))}(t.updateMask);return new ce(i,o,s,n,r)}return new Hn(i,o,n,r)}if(t.delete){var u=jt(e,t.delete);return new Wn(u,n)}if(t.verify){var a=jt(e,t.verify);return new xo(a,n)}return D()}function lc(e,t){return{documents:[Ki(e,t.path)]}}function fc(e,t){var n={structuredQuery:{}},r=t.path;t.collectionGroup!==null?(n.parent=Ki(e,r),n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(n.parent=Ki(e,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);var i=function(u){if(u.length!==0){var a=u.map(function(c){return function(h){if(h.op==="=="){if(ks(h.value))return{unaryFilter:{field:xe(h.field),op:"IS_NAN"}};if(Cs(h.value))return{unaryFilter:{field:xe(h.field),op:"IS_NULL"}}}else if(h.op==="!="){if(ks(h.value))return{unaryFilter:{field:xe(h.field),op:"IS_NOT_NAN"}};if(Cs(h.value))return{unaryFilter:{field:xe(h.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:xe(h.field),op:gf(h.op),value:h.value}}}(c)});return a.length===1?a[0]:{compositeFilter:{op:"AND",filters:a}}}}(t.filters);i&&(n.structuredQuery.where=i);var o=function(u){if(u.length!==0)return u.map(function(a){return function(c){return{field:xe(c.field),direction:mf(c.dir)}}(a)})}(t.orderBy);o&&(n.structuredQuery.orderBy=o);var s=function(u,a){return u.I||Se(a)?a:{value:a}}(e,t.limit);return s!==null&&(n.structuredQuery.limit=s),t.startAt&&(n.structuredQuery.startAt=zs(t.startAt)),t.endAt&&(n.structuredQuery.endAt=zs(t.endAt)),n}function pc(e){var t=cc(e.parent),n=e.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){x(r===1);var o=n.from[0];o.allDescendants?i=o.collectionId:t=t.child(o.collectionId)}var s=[];n.where&&(s=dc(n.where));var u=[];n.orderBy&&(u=n.orderBy.map(function(l){return function(f){return new Ve(Me(f.field),function(y){switch(y){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(f.direction))}(l)}));var a=null;n.limit&&(a=function(l){var f;return Se(f=typeof l=="object"?l.value:l)?null:f}(n.limit));var c=null;n.startAt&&(c=Qs(n.startAt));var h=null;return n.endAt&&(h=Qs(n.endAt)),za(t,i,u,s,a,"F",c,h)}function dc(e){return e?e.unaryFilter!==void 0?[bf(e)]:e.fieldFilter!==void 0?[wf(e)]:e.compositeFilter!==void 0?e.compositeFilter.filters.map(function(t){return dc(t)}).reduce(function(t,n){return t.concat(n)}):D():[]}function zs(e){return{before:e.before,values:e.position}}function Qs(e){var t=!!e.before,n=e.values||[];return new Sn(n,t)}function mf(e){return ff[e]}function gf(e){return pf[e]}function xe(e){return{fieldPath:e.canonicalString()}}function Me(e){return xt.fromServerFormat(e.fieldPath)}function wf(e){return Dt.create(Me(e.fieldFilter.field),function(t){switch(t){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":default:return D()}}(e.fieldFilter.op),e.fieldFilter.value)}function bf(e){switch(e.unaryFilter.op){case"IS_NAN":var t=Me(e.unaryFilter.field);return Dt.create(t,"==",{doubleValue:NaN});case"IS_NULL":var n=Me(e.unaryFilter.field);return Dt.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var r=Me(e.unaryFilter.field);return Dt.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":var i=Me(e.unaryFilter.field);return Dt.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":default:return D()}}function If(e){var t=[];return e.fields.forEach(function(n){return t.push(n.canonicalString())}),{fieldPaths:t}}function yc(e){return e.length>=4&&e.get(0)==="projects"&&e.get(2)==="databases"}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Pt(e){for(var t="",n=0;n<e.length;n++)t.length>0&&(t=$s(t)),t=Ef(e.get(n),t);return $s(t)}function Ef(e,t){for(var n=t,r=e.length,i=0;i<r;i++){var o=e.charAt(i);switch(o){case"\0":n+="";break;case"":n+="";break;default:n+=o}}return n}function $s(e){return e+""}function Bt(e){var t=e.length;if(x(t>=2),t===2)return x(e.charAt(0)===""&&e.charAt(1)===""),V.emptyPath();for(var n=t-2,r=[],i="",o=0;o<t;){var s=e.indexOf("",o);switch((s<0||s>n)&&D(),e.charAt(s+1)){case"":var u=e.substring(o,s),a=void 0;i.length===0?a=u:(a=i+=u,i=""),r.push(a);break;case"":i+=e.substring(o,s),i+="\0";break;case"":i+=e.substring(o,s+1);break;default:D()}o=s+2}return new V(r)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Tf=function(e,t){this.seconds=e,this.nanoseconds=t},It=function(e,t,n){this.ownerId=e,this.allowTabSynchronization=t,this.leaseTimestampMs=n};It.store="owner",It.key="owner";var ee=function(e,t,n){this.userId=e,this.lastAcknowledgedBatchId=t,this.lastStreamToken=n};ee.store="mutationQueues",ee.keyPath="userId";var j=function(e,t,n,r,i){this.userId=e,this.batchId=t,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};j.store="mutations",j.keyPath="batchId",j.userMutationsIndex="userMutationsIndex",j.userMutationsKeyPath=["userId","batchId"];var it=function(){function e(){}return e.prefixForUser=function(t){return[t]},e.prefixForPath=function(t,n){return[t,Pt(n)]},e.key=function(t,n,r){return[t,Pt(n),r]},e}();it.store="documentMutations",it.PLACEHOLDER=new it;var _f=function(e,t){this.path=e,this.readTime=t},Sf=function(e,t){this.path=e,this.version=t},z=function(e,t,n,r,i,o){this.unknownDocument=e,this.noDocument=t,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o};z.store="remoteDocuments",z.readTimeIndex="readTimeIndex",z.readTimeIndexPath="readTime",z.collectionReadTimeIndex="collectionReadTimeIndex",z.collectionReadTimeIndexPath=["parentPath","readTime"];var Mt=function(e){this.byteSize=e};Mt.store="remoteDocumentGlobal",Mt.key="remoteDocumentGlobalKey";var mt=function(e,t,n,r,i,o,s){this.targetId=e,this.canonicalId=t,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=o,this.query=s};mt.store="targets",mt.keyPath="targetId",mt.queryTargetsIndexName="queryTargetsIndex",mt.queryTargetsKeyPath=["canonicalId","targetId"];var nt=function(e,t,n){this.targetId=e,this.path=t,this.sequenceNumber=n};nt.store="targetDocuments",nt.keyPath=["targetId","path"],nt.documentTargetsIndex="documentTargetsIndex",nt.documentTargetsKeyPath=["path","targetId"];var Et=function(e,t,n,r){this.highestTargetId=e,this.highestListenSequenceNumber=t,this.lastRemoteSnapshotVersion=n,this.targetCount=r};Et.key="targetGlobalKey",Et.store="targetGlobal";var ve=function(e,t){this.collectionId=e,this.parent=t};ve.store="collectionParents",ve.keyPath=["collectionId","parent"];var Kt=function(e,t,n,r){this.clientId=e,this.updateTimeMs=t,this.networkEnabled=n,this.inForeground=r};Kt.store="clientMetadata",Kt.keyPath="clientId";var $e=function(e,t,n){this.bundleId=e,this.createTime=t,this.version=n};$e.store="bundles",$e.keyPath="bundleId";var He=function(e,t,n){this.name=e,this.readTime=t,this.bundledQuery=n};He.store="namedQueries",He.keyPath="name";var Df=$($([],$($([],$($([],$($([],[ee.store,j.store,it.store,z.store,mt.store,It.store,Et.store,nt.store]),[Kt.store])),[Mt.store])),[ve.store])),[$e.store,He.store]),vc="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",mc=function(){function e(){this.onCommittedListeners=[]}return e.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},e.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEach(function(t){return t()})},e}(),kt=function(){var e=this;this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})},b=function(){function e(t){var n=this;this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(function(r){n.isDone=!0,n.result=r,n.nextCallback&&n.nextCallback(r)},function(r){n.isDone=!0,n.error=r,n.catchCallback&&n.catchCallback(r)})}return e.prototype.catch=function(t){return this.next(void 0,t)},e.prototype.next=function(t,n){var r=this;return this.callbackAttached&&D(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(t,this.result):new e(function(i,o){r.nextCallback=function(s){r.wrapSuccess(t,s).next(i,o)},r.catchCallback=function(s){r.wrapFailure(n,s).next(i,o)}})},e.prototype.toPromise=function(){var t=this;return new Promise(function(n,r){t.next(n,r)})},e.prototype.wrapUserFunction=function(t){try{var n=t();return n instanceof e?n:e.resolve(n)}catch(r){return e.reject(r)}},e.prototype.wrapSuccess=function(t,n){return t?this.wrapUserFunction(function(){return t(n)}):e.resolve(n)},e.prototype.wrapFailure=function(t,n){return t?this.wrapUserFunction(function(){return t(n)}):e.reject(n)},e.resolve=function(t){return new e(function(n,r){n(t)})},e.reject=function(t){return new e(function(n,r){r(t)})},e.waitFor=function(t){return new e(function(n,r){var i=0,o=0,s=!1;t.forEach(function(u){++i,u.next(function(){++o,s&&o===i&&n()},function(a){return r(a)})}),s=!0,o===i&&n()})},e.or=function(t){for(var n=e.resolve(!1),r=function(s){n=n.next(function(u){return u?e.resolve(u):s()})},i=0,o=t;i<o.length;i++)r(o[i]);return n},e.forEach=function(t,n){var r=this,i=[];return t.forEach(function(o,s){i.push(n.call(r,o,s))}),this.waitFor(i)},e}(),gc=function(){function e(t,n){var r=this;this.action=t,this.transaction=n,this.aborted=!1,this.ft=new kt,this.transaction.oncomplete=function(){r.ft.resolve()},this.transaction.onabort=function(){n.error?r.ft.reject(new mn(t,n.error)):r.ft.resolve()},this.transaction.onerror=function(i){var o=Lo(i.target.error);r.ft.reject(new mn(t,o))}}return e.open=function(t,n,r,i){try{return new e(n,t.transaction(i,r))}catch(o){throw new mn(n,o)}},Object.defineProperty(e.prototype,"dt",{get:function(){return this.ft.promise},enumerable:!1,configurable:!0}),e.prototype.abort=function(t){t&&this.ft.reject(t),this.aborted||(I("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},e.prototype.store=function(t){var n=this.transaction.objectStore(t);return new Af(n)},e}(),We=function(){function e(t,n,r){this.name=t,this.version=n,this.wt=r,e._t(Ei())===12.2&&W("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}return e.delete=function(t){return I("SimpleDb","Removing database:",t),fe(window.indexedDB.deleteDatabase(t)).toPromise()},e.yt=function(){if(typeof indexedDB>"u")return!1;if(e.gt())return!0;var t=Ei(),n=e._t(t),r=0<n&&n<10,i=e.Et(t),o=0<i&&i<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||r||o)},e.gt=function(){var t;return typeof process<"u"&&((t=Vl)===null||t===void 0?void 0:t.Tt)==="YES"},e.It=function(t,n){return t.store(n)},e._t=function(t){var n=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),r=n?n[1].split("_").slice(0,2).join("."):"-1";return Number(r)},e.Et=function(t){var n=t.match(/Android ([\d.]+)/i),r=n?n[1].split(".").slice(0,2).join("."):"-1";return Number(r)},e.prototype.At=function(t){return g(this,void 0,void 0,function(){var n,r=this;return m(this,function(i){switch(i.label){case 0:return this.db?[3,2]:(I("SimpleDb","Opening database:",this.name),n=this,[4,new Promise(function(o,s){var u=indexedDB.open(r.name,r.version);u.onsuccess=function(a){var c=a.target.result;o(c)},u.onblocked=function(){s(new mn(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},u.onerror=function(a){var c=a.target.error;c.name==="VersionError"?s(new w(d.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):s(new mn(t,c))},u.onupgradeneeded=function(a){I("SimpleDb",'Database "'+r.name+'" requires upgrade from version:',a.oldVersion);var c=a.target.result;r.wt.Rt(c,u.transaction,a.oldVersion,r.version).next(function(){I("SimpleDb","Database upgrade to version "+r.version+" complete")})}})]);case 1:n.db=i.sent(),i.label=2;case 2:return[2,(this.bt&&(this.db.onversionchange=function(o){return r.bt(o)}),this.db)]}})})},e.prototype.vt=function(t){this.bt=t,this.db&&(this.db.onversionchange=function(n){return t(n)})},e.prototype.runTransaction=function(t,n,r,i){return g(this,void 0,void 0,function(){var o,s,u,a,c;return m(this,function(h){switch(h.label){case 0:o=n==="readonly",s=0,u=function(){var l,f,y,p,v;return m(this,function(E){switch(E.label){case 0:++s,E.label=1;case 1:return E.trys.push([1,4,,5]),[4,a.At(t)];case 2:return a.db=E.sent(),l=gc.open(a.db,t,o?"readonly":"readwrite",r),f=i(l).catch(function(T){return l.abort(T),b.reject(T)}).toPromise(),y={},f.catch(function(){}),[4,l.dt];case 3:return[2,(y.value=(E.sent(),f),y)];case 4:return p=E.sent(),v=p.name!=="FirebaseError"&&s<3,I("SimpleDb","Transaction failed with error:",p.message,"Retrying:",v),a.close(),v?[3,5]:[2,{value:Promise.reject(p)}];case 5:return[2]}})},a=this,h.label=1;case 1:return[5,u()];case 2:if(typeof(c=h.sent())=="object")return[2,c.value];h.label=3;case 3:return[3,1];case 4:return[2]}})})},e.prototype.close=function(){this.db&&this.db.close(),this.db=void 0},e}(),Nf=function(){function e(t){this.Pt=t,this.Vt=!1,this.St=null}return Object.defineProperty(e.prototype,"isDone",{get:function(){return this.Vt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Dt",{get:function(){return this.St},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cursor",{set:function(t){this.Pt=t},enumerable:!1,configurable:!0}),e.prototype.done=function(){this.Vt=!0},e.prototype.Ct=function(t){this.St=t},e.prototype.delete=function(){return fe(this.Pt.delete())},e}(),mn=function(e){function t(n,r){var i=this;return(i=e.call(this,d.UNAVAILABLE,"IndexedDB transaction '"+n+"' failed: "+r)||this).name="IndexedDbTransactionError",i}return C(t,e),t}(w);function De(e){return e.name==="IndexedDbTransactionError"}var Af=function(){function e(t){this.store=t}return e.prototype.put=function(t,n){var r;return n!==void 0?(I("SimpleDb","PUT",this.store.name,t,n),r=this.store.put(n,t)):(I("SimpleDb","PUT",this.store.name,"<auto-key>",t),r=this.store.put(t)),fe(r)},e.prototype.add=function(t){return I("SimpleDb","ADD",this.store.name,t,t),fe(this.store.add(t))},e.prototype.get=function(t){var n=this;return fe(this.store.get(t)).next(function(r){return r===void 0&&(r=null),I("SimpleDb","GET",n.store.name,t,r),r})},e.prototype.delete=function(t){return I("SimpleDb","DELETE",this.store.name,t),fe(this.store.delete(t))},e.prototype.count=function(){return I("SimpleDb","COUNT",this.store.name),fe(this.store.count())},e.prototype.Nt=function(t,n){var r=this.cursor(this.options(t,n)),i=[];return this.xt(r,function(o,s){i.push(s)}).next(function(){return i})},e.prototype.Ft=function(t,n){I("SimpleDb","DELETE ALL",this.store.name);var r=this.options(t,n);r.kt=!1;var i=this.cursor(r);return this.xt(i,function(o,s,u){return u.delete()})},e.prototype.Ot=function(t,n){var r;n?r=t:(r={},n=t);var i=this.cursor(r);return this.xt(i,n)},e.prototype.$t=function(t){var n=this.cursor({});return new b(function(r,i){n.onerror=function(o){var s=Lo(o.target.error);i(s)},n.onsuccess=function(o){var s=o.target.result;s?t(s.primaryKey,s.value).next(function(u){u?s.continue():r()}):r()}})},e.prototype.xt=function(t,n){var r=[];return new b(function(i,o){t.onerror=function(s){o(s.target.error)},t.onsuccess=function(s){var u=s.target.result;if(u){var a=new Nf(u),c=n(u.primaryKey,u.value,a);if(c instanceof b){var h=c.catch(function(l){return a.done(),b.reject(l)});r.push(h)}a.isDone?i():a.Dt===null?u.continue():u.continue(a.Dt)}else i()}}).next(function(){return b.waitFor(r)})},e.prototype.options=function(t,n){var r;return t!==void 0&&(typeof t=="string"?r=t:n=t),{index:r,range:n}},e.prototype.cursor=function(t){var n="next";if(t.reverse&&(n="prev"),t.index){var r=this.store.index(t.index);return t.kt?r.openKeyCursor(t.range,n):r.openCursor(t.range,n)}return this.store.openCursor(t.range,n)},e}();function fe(e){return new b(function(t,n){e.onsuccess=function(r){var i=r.target.result;t(i)},e.onerror=function(r){var i=Lo(r.target.error);n(i)}})}var Hs=!1;function Lo(e){var t=We._t(Ei());if(t>=12.2&&t<13){var n="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(n)>=0){var r=new w("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '"+n+"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");return Hs||(Hs=!0,setTimeout(function(){throw r},0)),r}}return e}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Ws=function(e){function t(n,r){var i=this;return(i=e.call(this)||this).Mt=n,i.currentSequenceNumber=r,i}return C(t,e),t}(mc);function bt(e,t){var n=_(e);return We.It(n.Mt,t)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Mo=function(){function e(t,n,r,i){this.batchId=t,this.localWriteTime=n,this.baseMutations=r,this.mutations=i}return e.prototype.applyToRemoteDocument=function(t,n){for(var r=n.mutationResults,i=0;i<this.mutations.length;i++){var o=this.mutations[i];o.key.isEqual(t.key)&&ef(o,t,r[i])}},e.prototype.applyToLocalView=function(t){for(var n=0,r=this.baseMutations;n<r.length;n++)(s=r[n]).key.isEqual(t.key)&&Bi(s,t,this.localWriteTime);for(var i=0,o=this.mutations;i<o.length;i++){var s;(s=o[i]).key.isEqual(t.key)&&Bi(s,t,this.localWriteTime)}},e.prototype.applyToLocalDocumentSet=function(t){var n=this;this.mutations.forEach(function(r){var i=t.get(r.key),o=i;n.applyToLocalView(o),i.isValidDocument()||o.convertToNoDocument(P.min())})},e.prototype.keys=function(){return this.mutations.reduce(function(t,n){return t.add(n.key)},B())},e.prototype.isEqual=function(t){return this.batchId===t.batchId&&qe(this.mutations,t.mutations,function(n,r){return Ls(n,r)})&&qe(this.baseMutations,t.baseMutations,function(n,r){return Ls(n,r)})},e}(),Cf=function(){function e(t,n,r,i){this.batch=t,this.commitVersion=n,this.mutationResults=r,this.docVersions=i}return e.from=function(t,n,r){x(t.mutations.length===r.length);for(var i=af(),o=t.mutations,s=0;s<o.length;s++)i=i.insert(o[s].key,r[s].version);return new e(t,n,r,i)},e}(),Xr=function(){function e(t,n,r,i,o,s,u){o===void 0&&(o=P.min()),s===void 0&&(s=P.min()),u===void 0&&(u=wt.EMPTY_BYTE_STRING),this.target=t,this.targetId=n,this.purpose=r,this.sequenceNumber=i,this.snapshotVersion=o,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=u}return e.prototype.withSequenceNumber=function(t){return new e(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)},e.prototype.withResumeToken=function(t,n){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,t)},e.prototype.withLastLimboFreeSnapshotVersion=function(t){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken)},e}(),wc=function(e){this.Lt=e};function Gi(e,t){if(t.document)return vf(e.Lt,t.document,!!t.hasCommittedMutations);if(t.noDocument){var n=N.fromSegments(t.noDocument.path),r=Ye(t.noDocument.readTime),i=ct.newNoDocument(n,r);return t.hasCommittedMutations?i.setHasCommittedMutations():i}if(t.unknownDocument){var o=N.fromSegments(t.unknownDocument.path);return r=Ye(t.unknownDocument.version),ct.newUnknownDocument(o,r)}return D()}function Xs(e,t,n){var r=Fo(n),i=t.key.path.popLast().toArray();if(t.isFoundDocument()){var o=function(l,f){return{name:Nn(l,f.key),fields:f.data.toProto().mapValue.fields,updateTime:Dn(l,f.version.toTimestamp())}}(e.Lt,t),s=t.hasCommittedMutations;return new z(null,null,o,s,r,i)}if(t.isNoDocument()){var u=t.key.path.toArray(),a=Xe(t.version);return s=t.hasCommittedMutations,new z(null,new _f(u,a),null,s,r,i)}if(t.isUnknownDocument()){var c=t.key.path.toArray(),h=Xe(t.version);return new z(new Sf(c,h),null,null,!0,r,i)}return D()}function Fo(e){var t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function bc(e){var t=new gt(e[0],e[1]);return P.fromTimestamp(t)}function Xe(e){var t=e.toTimestamp();return new Tf(t.seconds,t.nanoseconds)}function Ye(e){var t=new gt(e.seconds,e.nanoseconds);return P.fromTimestamp(t)}function Oe(e,t){for(var n=(t.baseMutations||[]).map(function(a){return Gs(e.Lt,a)}),r=0;r<t.mutations.length-1;++r){var i=t.mutations[r];if(r+1<t.mutations.length&&t.mutations[r+1].transform!==void 0){var o=t.mutations[r+1];i.updateTransforms=o.transform.fieldTransforms,t.mutations.splice(r+1,1),++r}}var s=t.mutations.map(function(a){return Gs(e.Lt,a)}),u=gt.fromMillis(t.localWriteTimeMs);return new Mo(t.batchId,u,n,s)}function yn(e){var t,n,r=Ye(e.readTime),i=e.lastLimboFreeSnapshotVersion!==void 0?Ye(e.lastLimboFreeSnapshotVersion):P.min();return e.query.documents!==void 0?(x((n=e.query).documents.length===1),t=Ut(Gn(cc(n.documents[0])))):t=function(o){return Ut(pc(o))}(e.query),new Xr(t,e.targetId,0,e.lastListenSequenceNumber,r,i,wt.fromBase64String(e.resumeToken))}function Ic(e,t){var n,r=Xe(t.snapshotVersion),i=Xe(t.lastLimboFreeSnapshotVersion);n=Er(t.target)?lc(e.Lt,t.target):fc(e.Lt,t.target);var o=t.resumeToken.toBase64();return new mt(t.targetId,Kn(t.target),r,o,t.sequenceNumber,i,n)}function Ec(e){var t=pc({parent:e.parent,structuredQuery:e.structuredQuery});return e.limitType==="LAST"?Qa(t,t.limit,"L"):t}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var kf=function(){function e(){}return e.prototype.getBundleMetadata=function(t,n){return Ys(t).get(n).next(function(r){if(r)return{id:(i=r).bundleId,createTime:Ye(i.createTime),version:i.version};var i})},e.prototype.saveBundleMetadata=function(t,n){return Ys(t).put({bundleId:(r=n).id,createTime:Xe(yt(r.createTime)),version:r.version});var r},e.prototype.getNamedQuery=function(t,n){return Js(t).get(n).next(function(r){if(r)return{name:(i=r).name,query:Ec(i.bundledQuery),readTime:Ye(i.readTime)};var i})},e.prototype.saveNamedQuery=function(t,n){return Js(t).put(function(r){return{name:r.name,readTime:Xe(yt(r.readTime)),bundledQuery:r.bundledQuery}}(n))},e}();function Ys(e){return bt(e,$e.store)}function Js(e){return bt(e,He.store)}/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var xf=function(){function e(){this.Bt=new Vo}return e.prototype.addToCollectionParentIndex=function(t,n){return this.Bt.add(n),b.resolve()},e.prototype.getCollectionParents=function(t,n){return b.resolve(this.Bt.getEntries(n))},e}(),Vo=function(){function e(){this.index={}}return e.prototype.add=function(t){var n=t.lastSegment(),r=t.popLast(),i=this.index[n]||new J(V.comparator),o=!i.has(r);return this.index[n]=i.add(r),o},e.prototype.has=function(t){var n=t.lastSegment(),r=t.popLast(),i=this.index[n];return i&&i.has(r)},e.prototype.getEntries=function(t){return(this.index[t]||new J(V.comparator)).toArray()},e}(),Rf=function(){function e(){this.qt=new Vo}return e.prototype.addToCollectionParentIndex=function(t,n){var r=this;if(!this.qt.has(n)){var i=n.lastSegment(),o=n.popLast();t.addOnCommittedListener(function(){r.qt.add(n)});var s={collectionId:i,parent:Pt(o)};return Zs(t).put(s)}return b.resolve()},e.prototype.getCollectionParents=function(t,n){var r=[],i=IDBKeyRange.bound([n,""],[Va(n),""],!1,!0);return Zs(t).Nt(i).next(function(o){for(var s=0,u=o;s<u.length;s++){var a=u[s];if(a.collectionId!==n)break;r.push(Bt(a.parent))}return r})},e}();function Zs(e){return bt(e,ve.store)}/**
* @license
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var tu={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},Lt=function(){function e(t,n,r){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=n,this.maximumSequenceNumbersToCollect=r}return e.withCacheSize=function(t){return new e(t,e.DEFAULT_COLLECTION_PERCENTILE,e.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)},e}();/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Tc(e,t,n){var r=e.store(j.store),i=e.store(it.store),o=[],s=IDBKeyRange.only(n.batchId),u=0,a=r.Ot({range:s},function(p,v,E){return u++,E.delete()});o.push(a.next(function(){x(u===1)}));for(var c=[],h=0,l=n.mutations;h<l.length;h++){var f=l[h],y=it.key(t,f.key.path,n.batchId);o.push(i.delete(y)),c.push(f.key)}return b.waitFor(o).next(function(){return c})}function Dr(e){if(!e)return 0;var t;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw D();t=e.noDocument}return JSON.stringify(t).length}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/Lt.DEFAULT_COLLECTION_PERCENTILE=10,Lt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Lt.DEFAULT=new Lt(41943040,Lt.DEFAULT_COLLECTION_PERCENTILE,Lt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Lt.DISABLED=new Lt(-1,0,0);var Of=function(){function e(t,n,r,i){this.userId=t,this.R=n,this.Ut=r,this.referenceDelegate=i,this.Qt={}}return e.Kt=function(t,n,r,i){return x(t.uid!==""),new e(t.isAuthenticated()?t.uid:"",n,r,i)},e.prototype.checkEmpty=function(t){var n=!0,r=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return $t(t).Ot({index:j.userMutationsIndex,range:r},function(i,o,s){n=!1,s.done()}).next(function(){return n})},e.prototype.addMutationBatch=function(t,n,r,i){var o=this,s=Pe(t),u=$t(t);return u.add({}).next(function(a){x(typeof a=="number");for(var c=new Mo(a,n,r,i),h=function(T,k,A){var O=A.baseMutations.map(function(q){return Sr(T.Lt,q)}),M=A.mutations.map(function(q){return Sr(T.Lt,q)});return new j(k,A.batchId,A.localWriteTime.toMillis(),O,M)}(o.R,o.userId,c),l=[],f=new J(function(T,k){return L(T.canonicalString(),k.canonicalString())}),y=0,p=i;y<p.length;y++){var v=p[y],E=it.key(o.userId,v.key.path,a);f=f.add(v.key.path.popLast()),l.push(u.put(h)),l.push(s.put(E,it.PLACEHOLDER))}return f.forEach(function(T){l.push(o.Ut.addToCollectionParentIndex(t,T))}),t.addOnCommittedListener(function(){o.Qt[a]=c.keys()}),b.waitFor(l).next(function(){return c})})},e.prototype.lookupMutationBatch=function(t,n){var r=this;return $t(t).get(n).next(function(i){return i?(x(i.userId===r.userId),Oe(r.R,i)):null})},e.prototype.jt=function(t,n){var r=this;return this.Qt[n]?b.resolve(this.Qt[n]):this.lookupMutationBatch(t,n).next(function(i){if(i){var o=i.keys();return r.Qt[n]=o,o}return null})},e.prototype.getNextMutationBatchAfterBatchId=function(t,n){var r=this,i=n+1,o=IDBKeyRange.lowerBound([this.userId,i]),s=null;return $t(t).Ot({index:j.userMutationsIndex,range:o},function(u,a,c){a.userId===r.userId&&(x(a.batchId>=i),s=Oe(r.R,a)),c.done()}).next(function(){return s})},e.prototype.getHighestUnacknowledgedBatchId=function(t){var n=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return $t(t).Ot({index:j.userMutationsIndex,range:n,reverse:!0},function(i,o,s){r=o.batchId,s.done()}).next(function(){return r})},e.prototype.getAllMutationBatches=function(t){var n=this,r=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return $t(t).Nt(j.userMutationsIndex,r).next(function(i){return i.map(function(o){return Oe(n.R,o)})})},e.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,n){var r=this,i=it.prefixForPath(this.userId,n.path),o=IDBKeyRange.lowerBound(i),s=[];return Pe(t).Ot({range:o},function(u,a,c){var h=u[0],l=u[1],f=u[2],y=Bt(l);if(h===r.userId&&n.path.isEqual(y))return $t(t).get(f).next(function(p){if(!p)throw D();x(p.userId===r.userId),s.push(Oe(r.R,p))});c.done()}).next(function(){return s})},e.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,n){var r=this,i=new J(L),o=[];return n.forEach(function(s){var u=it.prefixForPath(r.userId,s.path),a=IDBKeyRange.lowerBound(u),c=Pe(t).Ot({range:a},function(h,l,f){var y=h[0],p=h[1],v=h[2],E=Bt(p);y===r.userId&&s.path.isEqual(E)?i=i.add(v):f.done()});o.push(c)}),b.waitFor(o).next(function(){return r.Wt(t,i)})},e.prototype.getAllMutationBatchesAffectingQuery=function(t,n){var r=this,i=n.path,o=i.length+1,s=it.prefixForPath(this.userId,i),u=IDBKeyRange.lowerBound(s),a=new J(L);return Pe(t).Ot({range:u},function(c,h,l){var f=c[0],y=c[1],p=c[2],v=Bt(y);f===r.userId&&i.isPrefixOf(v)?v.length===o&&(a=a.add(p)):l.done()}).next(function(){return r.Wt(t,a)})},e.prototype.Wt=function(t,n){var r=this,i=[],o=[];return n.forEach(function(s){o.push($t(t).get(s).next(function(u){if(u===null)throw D();x(u.userId===r.userId),i.push(Oe(r.R,u))}))}),b.waitFor(o).next(function(){return i})},e.prototype.removeMutationBatch=function(t,n){var r=this;return Tc(t.Mt,this.userId,n).next(function(i){return t.addOnCommittedListener(function(){r.Gt(n.batchId)}),b.forEach(i,function(o){return r.referenceDelegate.markPotentiallyOrphaned(t,o)})})},e.prototype.Gt=function(t){delete this.Qt[t]},e.prototype.performConsistencyCheck=function(t){var n=this;return this.checkEmpty(t).next(function(r){if(!r)return b.resolve();var i=IDBKeyRange.lowerBound(it.prefixForUser(n.userId)),o=[];return Pe(t).Ot({range:i},function(s,u,a){if(s[0]===n.userId){var c=Bt(s[1]);o.push(c)}else a.done()}).next(function(){x(o.length===0)})})},e.prototype.containsKey=function(t,n){return _c(t,this.userId,n)},e.prototype.zt=function(t){var n=this;return Sc(t).get(this.userId).next(function(r){return r||new ee(n.userId,-1,"")})},e}();function _c(e,t,n){var r=it.prefixForPath(t,n.path),i=r[1],o=IDBKeyRange.lowerBound(r),s=!1;return Pe(e).Ot({range:o,kt:!0},function(u,a,c){var h=u[0],l=u[1];u[2],h===t&&l===i&&(s=!0),c.done()}).next(function(){return s})}function $t(e){return bt(e,j.store)}function Pe(e){return bt(e,it.store)}function Sc(e){return bt(e,ee.store)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Nr=function(){function e(t){this.Ht=t}return e.prototype.next=function(){return this.Ht+=2,this.Ht},e.Jt=function(){return new e(0)},e.Yt=function(){return new e(-1)},e}(),Pf=function(){function e(t,n){this.referenceDelegate=t,this.R=n}return e.prototype.allocateTargetId=function(t){var n=this;return this.Xt(t).next(function(r){var i=new Nr(r.highestTargetId);return r.highestTargetId=i.next(),n.Zt(t,r).next(function(){return r.highestTargetId})})},e.prototype.getLastRemoteSnapshotVersion=function(t){return this.Xt(t).next(function(n){return P.fromTimestamp(new gt(n.lastRemoteSnapshotVersion.seconds,n.lastRemoteSnapshotVersion.nanoseconds))})},e.prototype.getHighestSequenceNumber=function(t){return this.Xt(t).next(function(n){return n.highestListenSequenceNumber})},e.prototype.setTargetsMetadata=function(t,n,r){var i=this;return this.Xt(t).next(function(o){return o.highestListenSequenceNumber=n,r&&(o.lastRemoteSnapshotVersion=r.toTimestamp()),n>o.highestListenSequenceNumber&&(o.highestListenSequenceNumber=n),i.Zt(t,o)})},e.prototype.addTargetData=function(t,n){var r=this;return this.te(t,n).next(function(){return r.Xt(t).next(function(i){return i.targetCount+=1,r.ee(n,i),r.Zt(t,i)})})},e.prototype.updateTargetData=function(t,n){return this.te(t,n)},e.prototype.removeTargetData=function(t,n){var r=this;return this.removeMatchingKeysForTargetId(t,n.targetId).next(function(){return Re(t).delete(n.targetId)}).next(function(){return r.Xt(t)}).next(function(i){return x(i.targetCount>0),i.targetCount-=1,r.Zt(t,i)})},e.prototype.removeTargets=function(t,n,r){var i=this,o=0,s=[];return Re(t).Ot(function(u,a){var c=yn(a);c.sequenceNumber<=n&&r.get(c.targetId)===null&&(o++,s.push(i.removeTargetData(t,c)))}).next(function(){return b.waitFor(s)}).next(function(){return o})},e.prototype.forEachTarget=function(t,n){return Re(t).Ot(function(r,i){var o=yn(i);n(o)})},e.prototype.Xt=function(t){return eu(t).get(Et.key).next(function(n){return x(n!==null),n})},e.prototype.Zt=function(t,n){return eu(t).put(Et.key,n)},e.prototype.te=function(t,n){return Re(t).put(Ic(this.R,n))},e.prototype.ee=function(t,n){var r=!1;return t.targetId>n.highestTargetId&&(n.highestTargetId=t.targetId,r=!0),t.sequenceNumber>n.highestListenSequenceNumber&&(n.highestListenSequenceNumber=t.sequenceNumber,r=!0),r},e.prototype.getTargetCount=function(t){return this.Xt(t).next(function(n){return n.targetCount})},e.prototype.getTargetData=function(t,n){var r=Kn(n),i=IDBKeyRange.bound([r,Number.NEGATIVE_INFINITY],[r,Number.POSITIVE_INFINITY]),o=null;return Re(t).Ot({range:i,index:mt.queryTargetsIndexName},function(s,u,a){var c=yn(u);Qr(n,c.target)&&(o=c,a.done())}).next(function(){return o})},e.prototype.addMatchingKeys=function(t,n,r){var i=this,o=[],s=Yt(t);return n.forEach(function(u){var a=Pt(u.path);o.push(s.put(new nt(r,a))),o.push(i.referenceDelegate.addReference(t,r,u))}),b.waitFor(o)},e.prototype.removeMatchingKeys=function(t,n,r){var i=this,o=Yt(t);return b.forEach(n,function(s){var u=Pt(s.path);return b.waitFor([o.delete([r,u]),i.referenceDelegate.removeReference(t,r,s)])})},e.prototype.removeMatchingKeysForTargetId=function(t,n){var r=Yt(t),i=IDBKeyRange.bound([n],[n+1],!1,!0);return r.delete(i)},e.prototype.getMatchingKeysForTargetId=function(t,n){var r=IDBKeyRange.bound([n],[n+1],!1,!0),i=Yt(t),o=B();return i.Ot({range:r,kt:!0},function(s,u,a){var c=Bt(s[1]),h=new N(c);o=o.add(h)}).next(function(){return o})},e.prototype.containsKey=function(t,n){var r=Pt(n.path),i=IDBKeyRange.bound([r],[Va(r)],!1,!0),o=0;return Yt(t).Ot({index:nt.documentTargetsIndex,kt:!0,range:i},function(s,u,a){var c=s[0];s[1],c!==0&&(o++,a.done())}).next(function(){return o>0})},e.prototype.lt=function(t,n){return Re(t).get(n).next(function(r){return r?yn(r):null})},e}();/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Re(e){return bt(e,mt.store)}function eu(e){return bt(e,Et.store)}function Yt(e){return bt(e,nt.store)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Ne(e){return g(this,void 0,void 0,function(){return m(this,function(t){if(e.code!==d.FAILED_PRECONDITION||e.message!==vc)throw e;return I("LocalStore","Unexpectedly lost primary lease"),[2]})})}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function nu(e,t){var n=e[0],r=e[1],i=t[0],o=t[1],s=L(n,i);return s===0?L(r,o):s}var Lf=function(){function e(t){this.ne=t,this.buffer=new J(nu),this.se=0}return e.prototype.ie=function(){return++this.se},e.prototype.re=function(t){var n=[t,this.ie()];if(this.buffer.size<this.ne)this.buffer=this.buffer.add(n);else{var r=this.buffer.last();nu(n,r)<0&&(this.buffer=this.buffer.delete(r).add(n))}},Object.defineProperty(e.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!1,configurable:!0}),e}(),Mf=function(){function e(t,n){this.garbageCollector=t,this.asyncQueue=n,this.oe=!1,this.ce=null}return e.prototype.start=function(t){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.ue(t)},e.prototype.stop=function(){this.ce&&(this.ce.cancel(),this.ce=null)},Object.defineProperty(e.prototype,"started",{get:function(){return this.ce!==null},enumerable:!1,configurable:!0}),e.prototype.ue=function(t){var n=this,r=this.oe?3e5:6e4;I("LruGarbageCollector","Garbage collection scheduled in "+r+"ms"),this.ce=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",r,function(){return g(n,void 0,void 0,function(){var i;return m(this,function(o){switch(o.label){case 0:this.ce=null,this.oe=!0,o.label=1;case 1:return o.trys.push([1,3,,7]),[4,t.collectGarbage(this.garbageCollector)];case 2:return o.sent(),[3,7];case 3:return De(i=o.sent())?(I("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",i),[3,6]):[3,4];case 4:return[4,Ne(i)];case 5:o.sent(),o.label=6;case 6:return[3,7];case 7:return[4,this.ue(t)];case 8:return o.sent(),[2]}})})})},e}(),Ff=function(){function e(t,n){this.ae=t,this.params=n}return e.prototype.calculateTargetCount=function(t,n){return this.ae.he(t).next(function(r){return Math.floor(n/100*r)})},e.prototype.nthSequenceNumber=function(t,n){var r=this;if(n===0)return b.resolve(St.o);var i=new Lf(n);return this.ae.forEachTarget(t,function(o){return i.re(o.sequenceNumber)}).next(function(){return r.ae.le(t,function(o){return i.re(o)})}).next(function(){return i.maxValue})},e.prototype.removeTargets=function(t,n,r){return this.ae.removeTargets(t,n,r)},e.prototype.removeOrphanedDocuments=function(t,n){return this.ae.removeOrphanedDocuments(t,n)},e.prototype.collect=function(t,n){var r=this;return this.params.cacheSizeCollectionThreshold===-1?(I("LruGarbageCollector","Garbage collection skipped; disabled"),b.resolve(tu)):this.getCacheSize(t).next(function(i){return i<r.params.cacheSizeCollectionThreshold?(I("LruGarbageCollector","Garbage collection skipped; Cache size "+i+" is lower than threshold "+r.params.cacheSizeCollectionThreshold),tu):r.fe(t,n)})},e.prototype.getCacheSize=function(t){return this.ae.getCacheSize(t)},e.prototype.fe=function(t,n){var r,i,o,s,u,a,c,h=this,l=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next(function(f){return f>h.params.maximumSequenceNumbersToCollect?(I("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+h.params.maximumSequenceNumbersToCollect+" from "+f),i=h.params.maximumSequenceNumbersToCollect):i=f,s=Date.now(),h.nthSequenceNumber(t,i)}).next(function(f){return r=f,u=Date.now(),h.removeTargets(t,r,n)}).next(function(f){return o=f,a=Date.now(),h.removeOrphanedDocuments(t,r)}).next(function(f){return c=Date.now(),Li()<=Ue.DEBUG&&I("LruGarbageCollector",`LRU Garbage Collection
Counted targets in `+(s-l)+`ms
Determined least recently used `+i+" in "+(u-s)+`ms
Removed `+o+" targets in "+(a-u)+`ms
Removed `+f+" documents in "+(c-a)+`ms
Total Duration: `+(c-l)+"ms"),b.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:o,documentsRemoved:f})})},e}(),Vf=function(){function e(t,n){this.db=t,this.garbageCollector=function(r,i){return new Ff(r,i)}(this,n)}return e.prototype.he=function(t){var n=this.de(t);return this.db.getTargetCache().getTargetCount(t).next(function(r){return n.next(function(i){return r+i})})},e.prototype.de=function(t){var n=0;return this.le(t,function(r){n++}).next(function(){return n})},e.prototype.forEachTarget=function(t,n){return this.db.getTargetCache().forEachTarget(t,n)},e.prototype.le=function(t,n){return this.we(t,function(r,i){return n(i)})},e.prototype.addReference=function(t,n,r){return rr(t,r)},e.prototype.removeReference=function(t,n,r){return rr(t,r)},e.prototype.removeTargets=function(t,n,r){return this.db.getTargetCache().removeTargets(t,n,r)},e.prototype.markPotentiallyOrphaned=function(t,n){return rr(t,n)},e.prototype._e=function(t,n){return function(r,i){var o=!1;return Sc(r).$t(function(s){return _c(r,s,i).next(function(u){return u&&(o=!0),b.resolve(!u)})}).next(function(){return o})}(t,n)},e.prototype.removeOrphanedDocuments=function(t,n){var r=this,i=this.db.getRemoteDocumentCache().newChangeBuffer(),o=[],s=0;return this.we(t,function(u,a){if(a<=n){var c=r._e(t,u).next(function(h){if(!h)return s++,i.getEntry(t,u).next(function(){return i.removeEntry(u),Yt(t).delete([0,Pt(u.path)])})});o.push(c)}}).next(function(){return b.waitFor(o)}).next(function(){return i.apply(t)}).next(function(){return s})},e.prototype.removeTarget=function(t,n){var r=n.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,r)},e.prototype.updateLimboDocument=function(t,n){return rr(t,n)},e.prototype.we=function(t,n){var r,i=Yt(t),o=St.o;return i.Ot({index:nt.documentTargetsIndex},function(s,u){var a=s[0],c=(s[1],u.path),h=u.sequenceNumber;a===0?(o!==St.o&&n(new N(Bt(r)),o),o=h,r=c):o=St.o}).next(function(){o!==St.o&&n(new N(Bt(r)),o)})},e.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},e}();function rr(e,t){return Yt(e).put(function(n,r){return new nt(0,Pt(n.path),r)}(t,e.currentSequenceNumber))}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var sn=function(){function e(t,n){this.mapKeyFn=t,this.equalsFn=n,this.inner={}}return e.prototype.get=function(t){var n=this.mapKeyFn(t),r=this.inner[n];if(r!==void 0)for(var i=0,o=r;i<o.length;i++){var s=o[i],u=s[0],a=s[1];if(this.equalsFn(u,t))return a}},e.prototype.has=function(t){return this.get(t)!==void 0},e.prototype.set=function(t,n){var r=this.mapKeyFn(t),i=this.inner[r];if(i!==void 0){for(var o=0;o<i.length;o++)if(this.equalsFn(i[o][0],t))return void(i[o]=[t,n]);i.push([t,n])}else this.inner[r]=[[t,n]]},e.prototype.delete=function(t){var n=this.mapKeyFn(t),r=this.inner[n];if(r===void 0)return!1;for(var i=0;i<r.length;i++)if(this.equalsFn(r[i][0],t))return r.length===1?delete this.inner[n]:r.splice(i,1),!0;return!1},e.prototype.forEach=function(t){jn(this.inner,function(n,r){for(var i=0,o=r;i<o.length;i++){var s=o[i],u=s[0],a=s[1];t(u,a)}})},e.prototype.isEmpty=function(){return Ua(this.inner)},e}(),Dc=function(){function e(){this.changes=new sn(function(t){return t.toString()},function(t,n){return t.isEqual(n)}),this.changesApplied=!1}return e.prototype.getReadTime=function(t){var n=this.changes.get(t);return n?n.readTime:P.min()},e.prototype.addEntry=function(t,n){this.assertNotApplied(),this.changes.set(t.key,{document:t,readTime:n})},e.prototype.removeEntry=function(t,n){n===void 0&&(n=null),this.assertNotApplied(),this.changes.set(t,{document:ct.newInvalidDocument(t),readTime:n})},e.prototype.getEntry=function(t,n){this.assertNotApplied();var r=this.changes.get(n);return r!==void 0?b.resolve(r.document):this.getFromCache(t,n)},e.prototype.getEntries=function(t,n){return this.getAllFromCache(t,n)},e.prototype.apply=function(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)},e.prototype.assertNotApplied=function(){},e}(),Uf=function(){function e(t,n){this.R=t,this.Ut=n}return e.prototype.addEntry=function(t,n,r){return Wt(t).put(ir(n),r)},e.prototype.removeEntry=function(t,n){var r=Wt(t),i=ir(n);return r.delete(i)},e.prototype.updateMetadata=function(t,n){var r=this;return this.getMetadata(t).next(function(i){return i.byteSize+=n,r.me(t,i)})},e.prototype.getEntry=function(t,n){var r=this;return Wt(t).get(ir(n)).next(function(i){return r.ye(n,i)})},e.prototype.ge=function(t,n){var r=this;return Wt(t).get(ir(n)).next(function(i){return{document:r.ye(n,i),size:Dr(i)}})},e.prototype.getEntries=function(t,n){var r=this,i=Ot();return this.pe(t,n,function(o,s){var u=r.ye(o,s);i=i.insert(o,u)}).next(function(){return i})},e.prototype.Ee=function(t,n){var r=this,i=Ot(),o=new ht(N.comparator);return this.pe(t,n,function(s,u){var a=r.ye(s,u);i=i.insert(s,a),o=o.insert(s,Dr(u))}).next(function(){return{documents:i,Te:o}})},e.prototype.pe=function(t,n,r){if(n.isEmpty())return b.resolve();var i=IDBKeyRange.bound(n.first().path.toArray(),n.last().path.toArray()),o=n.getIterator(),s=o.getNext();return Wt(t).Ot({range:i},function(u,a,c){for(var h=N.fromSegments(u);s&&N.comparator(s,h)<0;)r(s,null),s=o.getNext();s&&s.isEqual(h)&&(r(s,a),s=o.hasNext()?o.getNext():null),s?c.Ct(s.path.toArray()):c.done()}).next(function(){for(;s;)r(s,null),s=o.hasNext()?o.getNext():null})},e.prototype.getDocumentsMatchingQuery=function(t,n,r){var i=this,o=Ot(),s=n.path.length+1,u={};if(r.isEqual(P.min())){var a=n.path.toArray();u.range=IDBKeyRange.lowerBound(a)}else{var c=n.path.toArray(),h=Fo(r);u.range=IDBKeyRange.lowerBound([c,h],!0),u.index=z.collectionReadTimeIndex}return Wt(t).Ot(u,function(l,f,y){if(l.length===s){var p=Gi(i.R,f);n.path.isPrefixOf(p.key.path)?Qn(n,p)&&(o=o.insert(p.key,p)):y.done()}}).next(function(){return o})},e.prototype.newChangeBuffer=function(t){return new qf(this,!!t&&t.trackRemovals)},e.prototype.getSize=function(t){return this.getMetadata(t).next(function(n){return n.byteSize})},e.prototype.getMetadata=function(t){return ru(t).get(Mt.key).next(function(n){return x(!!n),n})},e.prototype.me=function(t,n){return ru(t).put(Mt.key,n)},e.prototype.ye=function(t,n){if(n){var r=Gi(this.R,n);if(!r.isNoDocument()||!r.version.isEqual(P.min()))return r}return ct.newInvalidDocument(t)},e}(),qf=function(e){function t(n,r){var i=this;return(i=e.call(this)||this).Ie=n,i.trackRemovals=r,i.Ae=new sn(function(o){return o.toString()},function(o,s){return o.isEqual(s)}),i}return C(t,e),t.prototype.applyChanges=function(n){var r=this,i=[],o=0,s=new J(function(u,a){return L(u.canonicalString(),a.canonicalString())});return this.changes.forEach(function(u,a){var c=r.Ae.get(u);if(a.document.isValidDocument()){var h=Xs(r.Ie.R,a.document,r.getReadTime(u));s=s.add(u.path.popLast());var l=Dr(h);o+=l-c,i.push(r.Ie.addEntry(n,u,h))}else if(o-=c,r.trackRemovals){var f=Xs(r.Ie.R,ct.newNoDocument(u,P.min()),r.getReadTime(u));i.push(r.Ie.addEntry(n,u,f))}else i.push(r.Ie.removeEntry(n,u))}),s.forEach(function(u){i.push(r.Ie.Ut.addToCollectionParentIndex(n,u))}),i.push(this.Ie.updateMetadata(n,o)),b.waitFor(i)},t.prototype.getFromCache=function(n,r){var i=this;return this.Ie.ge(n,r).next(function(o){return i.Ae.set(r,o.size),o.document})},t.prototype.getAllFromCache=function(n,r){var i=this;return this.Ie.Ee(n,r).next(function(o){var s=o.documents;return o.Te.forEach(function(u,a){i.Ae.set(u,a)}),s})},t}(Dc);/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function ru(e){return bt(e,Mt.store)}function Wt(e){return bt(e,z.store)}function ir(e){return e.path.toArray()}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Bf=function(){function e(t){this.R=t}return e.prototype.Rt=function(t,n,r,i){var o=this;x(r<i&&r>=0&&i<=11);var s=new gc("createOrUpgrade",n);r<1&&i>=1&&(function(a){a.createObjectStore(It.store)}(t),function(a){a.createObjectStore(ee.store,{keyPath:ee.keyPath}),a.createObjectStore(j.store,{keyPath:j.keyPath,autoIncrement:!0}).createIndex(j.userMutationsIndex,j.userMutationsKeyPath,{unique:!0}),a.createObjectStore(it.store)}(t),iu(t),function(a){a.createObjectStore(z.store)}(t));var u=b.resolve();return r<3&&i>=3&&(r!==0&&(function(a){a.deleteObjectStore(nt.store),a.deleteObjectStore(mt.store),a.deleteObjectStore(Et.store)}(t),iu(t)),u=u.next(function(){return function(a){var c=a.store(Et.store),h=new Et(0,0,P.min().toTimestamp(),0);return c.put(Et.key,h)}(s)})),r<4&&i>=4&&(r!==0&&(u=u.next(function(){return function(a,c){return c.store(j.store).Nt().next(function(h){a.deleteObjectStore(j.store),a.createObjectStore(j.store,{keyPath:j.keyPath,autoIncrement:!0}).createIndex(j.userMutationsIndex,j.userMutationsKeyPath,{unique:!0});var l=c.store(j.store),f=h.map(function(y){return l.put(y)});return b.waitFor(f)})}(t,s)})),u=u.next(function(){(function(a){a.createObjectStore(Kt.store,{keyPath:Kt.keyPath})})(t)})),r<5&&i>=5&&(u=u.next(function(){return o.Re(s)})),r<6&&i>=6&&(u=u.next(function(){return function(a){a.createObjectStore(Mt.store)}(t),o.be(s)})),r<7&&i>=7&&(u=u.next(function(){return o.ve(s)})),r<8&&i>=8&&(u=u.next(function(){return o.Pe(t,s)})),r<9&&i>=9&&(u=u.next(function(){(function(a){a.objectStoreNames.contains("remoteDocumentChanges")&&a.deleteObjectStore("remoteDocumentChanges")})(t),function(a){var c=a.objectStore(z.store);c.createIndex(z.readTimeIndex,z.readTimeIndexPath,{unique:!1}),c.createIndex(z.collectionReadTimeIndex,z.collectionReadTimeIndexPath,{unique:!1})}(n)})),r<10&&i>=10&&(u=u.next(function(){return o.Ve(s)})),r<11&&i>=11&&(u=u.next(function(){(function(a){a.createObjectStore($e.store,{keyPath:$e.keyPath})})(t),function(a){a.createObjectStore(He.store,{keyPath:He.keyPath})}(t)})),u},e.prototype.be=function(t){var n=0;return t.store(z.store).Ot(function(r,i){n+=Dr(i)}).next(function(){var r=new Mt(n);return t.store(Mt.store).put(Mt.key,r)})},e.prototype.Re=function(t){var n=this,r=t.store(ee.store),i=t.store(j.store);return r.Nt().next(function(o){return b.forEach(o,function(s){var u=IDBKeyRange.bound([s.userId,-1],[s.userId,s.lastAcknowledgedBatchId]);return i.Nt(j.userMutationsIndex,u).next(function(a){return b.forEach(a,function(c){x(c.userId===s.userId);var h=Oe(n.R,c);return Tc(t,s.userId,h).next(function(){})})})})})},e.prototype.ve=function(t){var n=t.store(nt.store),r=t.store(z.store);return t.store(Et.store).get(Et.key).next(function(i){var o=[];return r.Ot(function(s,u){var a=new V(s),c=function(h){return[0,Pt(h)]}(a);o.push(n.get(c).next(function(h){return h?b.resolve():function(l){return n.put(new nt(0,Pt(l),i.highestListenSequenceNumber))}(a)}))}).next(function(){return b.waitFor(o)})})},e.prototype.Pe=function(t,n){t.createObjectStore(ve.store,{keyPath:ve.keyPath});var r=n.store(ve.store),i=new Vo,o=function(s){if(i.add(s)){var u=s.lastSegment(),a=s.popLast();return r.put({collectionId:u,parent:Pt(a)})}};return n.store(z.store).Ot({kt:!0},function(s,u){var a=new V(s);return o(a.popLast())}).next(function(){return n.store(it.store).Ot({kt:!0},function(s,u){s[0];var a=s[1],c=(s[2],Bt(a));return o(c.popLast())})})},e.prototype.Ve=function(t){var n=this,r=t.store(mt.store);return r.Ot(function(i,o){var s=yn(o),u=Ic(n.R,s);return r.put(u)})},e}();function iu(e){e.createObjectStore(nt.store,{keyPath:nt.keyPath}).createIndex(nt.documentTargetsIndex,nt.documentTargetsKeyPath,{unique:!0}),e.createObjectStore(mt.store,{keyPath:mt.keyPath}).createIndex(mt.queryTargetsIndexName,mt.queryTargetsKeyPath,{unique:!0}),e.createObjectStore(Et.store)}var gi="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",jf=function(){function e(t,n,r,i,o,s,u,a,c,h){if(this.allowTabSynchronization=t,this.persistenceKey=n,this.clientId=r,this.Se=o,this.window=s,this.document=u,this.De=c,this.Ce=h,this.Ne=null,this.xe=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Fe=null,this.inForeground=!1,this.ke=null,this.Oe=null,this.$e=Number.NEGATIVE_INFINITY,this.Me=function(l){return Promise.resolve()},!e.yt())throw new w(d.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new Vf(this,i),this.Le=n+"main",this.R=new wc(a),this.Be=new We(this.Le,11,new Bf(this.R)),this.qe=new Pf(this.referenceDelegate,this.R),this.Ut=new Rf,this.Ue=function(l,f){return new Uf(l,f)}(this.R,this.Ut),this.Qe=new kf,this.window&&this.window.localStorage?this.Ke=this.window.localStorage:(this.Ke=null,h===!1&&W("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}return e.prototype.start=function(){var t=this;return this.je().then(function(){if(!t.isPrimary&&!t.allowTabSynchronization)throw new w(d.FAILED_PRECONDITION,gi);return t.We(),t.Ge(),t.ze(),t.runTransaction("getHighestListenSequenceNumber","readonly",function(n){return t.qe.getHighestSequenceNumber(n)})}).then(function(n){t.Ne=new St(n,t.De)}).then(function(){t.xe=!0}).catch(function(n){return t.Be&&t.Be.close(),Promise.reject(n)})},e.prototype.He=function(t){var n=this;return this.Me=function(r){return g(n,void 0,void 0,function(){return m(this,function(i){return this.started?[2,t(r)]:[2]})})},t(this.isPrimary)},e.prototype.setDatabaseDeletedListener=function(t){var n=this;this.Be.vt(function(r){return g(n,void 0,void 0,function(){return m(this,function(i){switch(i.label){case 0:return r.newVersion===null?[4,t()]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}})})})},e.prototype.setNetworkEnabled=function(t){var n=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.Se.enqueueAndForget(function(){return g(n,void 0,void 0,function(){return m(this,function(r){switch(r.label){case 0:return this.started?[4,this.je()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})}))},e.prototype.je=function(){var t=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",function(n){return or(n).put(new Kt(t.clientId,Date.now(),t.networkEnabled,t.inForeground)).next(function(){if(t.isPrimary)return t.Je(n).next(function(r){r||(t.isPrimary=!1,t.Se.enqueueRetryable(function(){return t.Me(!1)}))})}).next(function(){return t.Ye(n)}).next(function(r){return t.isPrimary&&!r?t.Xe(n).next(function(){return!1}):!!r&&t.Ze(n).next(function(){return!0})})}).catch(function(n){if(De(n))return I("IndexedDbPersistence","Failed to extend owner lease: ",n),t.isPrimary;if(!t.allowTabSynchronization)throw n;return I("IndexedDbPersistence","Releasing owner lease after error during lease refresh",n),!1}).then(function(n){t.isPrimary!==n&&t.Se.enqueueRetryable(function(){return t.Me(n)}),t.isPrimary=n})},e.prototype.Je=function(t){var n=this;return pn(t).get(It.key).next(function(r){return b.resolve(n.tn(r))})},e.prototype.en=function(t){return or(t).delete(this.clientId)},e.prototype.nn=function(){return g(this,void 0,void 0,function(){var t,n,r,i,o=this;return m(this,function(s){switch(s.label){case 0:return!this.isPrimary||this.sn(this.$e,18e5)?[3,2]:(this.$e=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",function(u){var a=bt(u,Kt.store);return a.Nt().next(function(c){var h=o.rn(c,18e5),l=c.filter(function(f){return h.indexOf(f)===-1});return b.forEach(l,function(f){return a.delete(f.clientId)}).next(function(){return l})})}).catch(function(){return[]})]);case 1:if(t=s.sent(),this.Ke)for(n=0,r=t;n<r.length;n++)i=r[n],this.Ke.removeItem(this.on(i.clientId));s.label=2;case 2:return[2]}})})},e.prototype.ze=function(){var t=this;this.Oe=this.Se.enqueueAfterDelay("client_metadata_refresh",4e3,function(){return t.je().then(function(){return t.nn()}).then(function(){return t.ze()})})},e.prototype.tn=function(t){return!!t&&t.ownerId===this.clientId},e.prototype.Ye=function(t){var n=this;return this.Ce?b.resolve(!0):pn(t).get(It.key).next(function(r){if(r!==null&&n.sn(r.leaseTimestampMs,5e3)&&!n.cn(r.ownerId)){if(n.tn(r)&&n.networkEnabled)return!0;if(!n.tn(r)){if(!r.allowTabSynchronization)throw new w(d.FAILED_PRECONDITION,gi);return!1}}return!(!n.networkEnabled||!n.inForeground)||or(t).Nt().next(function(i){return n.rn(i,5e3).find(function(o){if(n.clientId!==o.clientId){var s=!n.networkEnabled&&o.networkEnabled,u=!n.inForeground&&o.inForeground,a=n.networkEnabled===o.networkEnabled;if(s||u&&a)return!0}return!1})===void 0})}).next(function(r){return n.isPrimary!==r&&I("IndexedDbPersistence","Client "+(r?"is":"is not")+" eligible for a primary lease."),r})},e.prototype.shutdown=function(){return g(this,void 0,void 0,function(){var t=this;return m(this,function(n){switch(n.label){case 0:return this.xe=!1,this.un(),this.Oe&&(this.Oe.cancel(),this.Oe=null),this.an(),this.hn(),[4,this.Be.runTransaction("shutdown","readwrite",[It.store,Kt.store],function(r){var i=new Ws(r,St.o);return t.Xe(i).next(function(){return t.en(i)})})];case 1:return n.sent(),this.Be.close(),this.ln(),[2]}})})},e.prototype.rn=function(t,n){var r=this;return t.filter(function(i){return r.sn(i.updateTimeMs,n)&&!r.cn(i.clientId)})},e.prototype.fn=function(){var t=this;return this.runTransaction("getActiveClients","readonly",function(n){return or(n).Nt().next(function(r){return t.rn(r,18e5).map(function(i){return i.clientId})})})},Object.defineProperty(e.prototype,"started",{get:function(){return this.xe},enumerable:!1,configurable:!0}),e.prototype.getMutationQueue=function(t){return Of.Kt(t,this.R,this.Ut,this.referenceDelegate)},e.prototype.getTargetCache=function(){return this.qe},e.prototype.getRemoteDocumentCache=function(){return this.Ue},e.prototype.getIndexManager=function(){return this.Ut},e.prototype.getBundleCache=function(){return this.Qe},e.prototype.runTransaction=function(t,n,r){var i=this;I("IndexedDbPersistence","Starting transaction:",t);var o,s=n==="readonly"?"readonly":"readwrite";return this.Be.runTransaction(t,s,Df,function(u){return o=new Ws(u,i.Ne?i.Ne.next():St.o),n==="readwrite-primary"?i.Je(o).next(function(a){return!!a||i.Ye(o)}).next(function(a){if(!a)throw W("Failed to obtain primary lease for action '"+t+"'."),i.isPrimary=!1,i.Se.enqueueRetryable(function(){return i.Me(!1)}),new w(d.FAILED_PRECONDITION,vc);return r(o)}).next(function(a){return i.Ze(o).next(function(){return a})}):i.dn(o).next(function(){return r(o)})}).then(function(u){return o.raiseOnCommittedEvent(),u})},e.prototype.dn=function(t){var n=this;return pn(t).get(It.key).next(function(r){if(r!==null&&n.sn(r.leaseTimestampMs,5e3)&&!n.cn(r.ownerId)&&!n.tn(r)&&!(n.Ce||n.allowTabSynchronization&&r.allowTabSynchronization))throw new w(d.FAILED_PRECONDITION,gi)})},e.prototype.Ze=function(t){var n=new It(this.clientId,this.allowTabSynchronization,Date.now());return pn(t).put(It.key,n)},e.yt=function(){return We.yt()},e.prototype.Xe=function(t){var n=this,r=pn(t);return r.get(It.key).next(function(i){return n.tn(i)?(I("IndexedDbPersistence","Releasing primary lease."),r.delete(It.key)):b.resolve()})},e.prototype.sn=function(t,n){var r=Date.now();return!(t<r-n||t>r&&(W("Detected an update time that is in the future: "+t+" > "+r),1))},e.prototype.We=function(){var t=this;this.document!==null&&typeof this.document.addEventListener=="function"&&(this.ke=function(){t.Se.enqueueAndForget(function(){return t.inForeground=t.document.visibilityState==="visible",t.je()})},this.document.addEventListener("visibilitychange",this.ke),this.inForeground=this.document.visibilityState==="visible")},e.prototype.an=function(){this.ke&&(this.document.removeEventListener("visibilitychange",this.ke),this.ke=null)},e.prototype.Ge=function(){var t,n=this;typeof((t=this.window)===null||t===void 0?void 0:t.addEventListener)=="function"&&(this.Fe=function(){n.un(),n.Se.enqueueAndForget(function(){return n.shutdown()})},this.window.addEventListener("unload",this.Fe))},e.prototype.hn=function(){this.Fe&&(this.window.removeEventListener("unload",this.Fe),this.Fe=null)},e.prototype.cn=function(t){var n;try{var r=((n=this.Ke)===null||n===void 0?void 0:n.getItem(this.on(t)))!==null;return I("IndexedDbPersistence","Client '"+t+"' "+(r?"is":"is not")+" zombied in LocalStorage"),r}catch(i){return W("IndexedDbPersistence","Failed to get zombied client id.",i),!1}},e.prototype.un=function(){if(this.Ke)try{this.Ke.setItem(this.on(this.clientId),String(Date.now()))}catch(t){W("Failed to set zombie client id.",t)}},e.prototype.ln=function(){if(this.Ke)try{this.Ke.removeItem(this.on(this.clientId))}catch{}},e.prototype.on=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},e}();function pn(e){return bt(e,It.store)}function or(e){return bt(e,Kt.store)}function Uo(e,t){var n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}var Nc=function(){function e(t,n,r){this.Ue=t,this._n=n,this.Ut=r}return e.prototype.mn=function(t,n){var r=this;return this._n.getAllMutationBatchesAffectingDocumentKey(t,n).next(function(i){return r.yn(t,n,i)})},e.prototype.yn=function(t,n,r){return this.Ue.getEntry(t,n).next(function(i){for(var o=0,s=r;o<s.length;o++)s[o].applyToLocalView(i);return i})},e.prototype.gn=function(t,n){t.forEach(function(r,i){for(var o=0,s=n;o<s.length;o++)s[o].applyToLocalView(i)})},e.prototype.pn=function(t,n){var r=this;return this.Ue.getEntries(t,n).next(function(i){return r.En(t,i).next(function(){return i})})},e.prototype.En=function(t,n){var r=this;return this._n.getAllMutationBatchesAffectingDocumentKeys(t,n).next(function(i){return r.gn(n,i)})},e.prototype.getDocumentsMatchingQuery=function(t,n,r){return function(i){return N.isDocumentKey(i.path)&&i.collectionGroup===null&&i.filters.length===0}(n)?this.Tn(t,n.path):ko(n)?this.In(t,n,r):this.An(t,n,r)},e.prototype.Tn=function(t,n){return this.mn(t,new N(n)).next(function(r){var i=ji();return r.isFoundDocument()&&(i=i.insert(r.key,r)),i})},e.prototype.In=function(t,n,r){var i=this,o=n.collectionGroup,s=ji();return this.Ut.getCollectionParents(t,o).next(function(u){return b.forEach(u,function(a){var c=function(h,l){return new Qt(l,null,h.explicitOrderBy.slice(),h.filters.slice(),h.limit,h.limitType,h.startAt,h.endAt)}(n,a.child(o));return i.An(t,c,r).next(function(h){h.forEach(function(l,f){s=s.insert(l,f)})})}).next(function(){return s})})},e.prototype.An=function(t,n,r){var i,o,s=this;return this.Ue.getDocumentsMatchingQuery(t,n,r).next(function(u){return i=u,s._n.getAllMutationBatchesAffectingQuery(t,n)}).next(function(u){return o=u,s.Rn(t,o,i).next(function(a){i=a;for(var c=0,h=o;c<h.length;c++)for(var l=h[c],f=0,y=l.mutations;f<y.length;f++){var p=y[f],v=p.key,E=i.get(v);E==null&&(E=ct.newInvalidDocument(v),i=i.insert(v,E)),Bi(p,E,l.localWriteTime),E.isFoundDocument()||(i=i.remove(v))}})}).next(function(){return i.forEach(function(u,a){Qn(n,a)||(i=i.remove(u))}),i})},e.prototype.Rn=function(t,n,r){for(var i=B(),o=0,s=n;o<s.length;o++)for(var u=0,a=s[o].mutations;u<a.length;u++){var c=a[u];c instanceof ce&&r.get(c.key)===null&&(i=i.add(c.key))}var h=r;return this.Ue.getEntries(t,i).next(function(l){return l.forEach(function(f,y){y.isFoundDocument()&&(h=h.insert(f,y))}),h})},e}(),Kf=function(){function e(t,n,r,i){this.targetId=t,this.fromCache=n,this.bn=r,this.vn=i}return e.Pn=function(t,n){for(var r=B(),i=B(),o=0,s=n.docChanges;o<s.length;o++){var u=s[o];switch(u.type){case 0:r=r.add(u.doc.key);break;case 1:i=i.add(u.doc.key)}}return new e(t,n.fromCache,r,i)},e}(),Ac=function(){function e(){}return e.prototype.Vn=function(t){this.Sn=t},e.prototype.getDocumentsMatchingQuery=function(t,n,r,i){var o=this;return function(s){return s.filters.length===0&&s.limit===null&&s.startAt==null&&s.endAt==null&&(s.explicitOrderBy.length===0||s.explicitOrderBy.length===1&&s.explicitOrderBy[0].field.isKeyField())}(n)||r.isEqual(P.min())?this.Dn(t,n):this.Sn.pn(t,i).next(function(s){var u=o.Cn(n,s);return(sr(n)||_r(n))&&o.Nn(n.limitType,u,i,r)?o.Dn(t,n):(Li()<=Ue.DEBUG&&I("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),qi(n)),o.Sn.getDocumentsMatchingQuery(t,n,r).next(function(a){return u.forEach(function(c){a=a.insert(c.key,c)}),a}))})},e.prototype.Cn=function(t,n){var r=new J(Ha(t));return n.forEach(function(i,o){Qn(t,o)&&(r=r.add(o))}),r},e.prototype.Nn=function(t,n,r,i){if(r.size!==n.size)return!0;var o=t==="F"?n.last():n.first();return!!o&&(o.hasPendingWrites||o.version.compareTo(i)>0)},e.prototype.Dn=function(t,n){return Li()<=Ue.DEBUG&&I("QueryEngine","Using full collection scan to execute query:",qi(n)),this.Sn.getDocumentsMatchingQuery(t,n,P.min())},e}(),Gf=function(){function e(t,n,r,i){this.persistence=t,this.xn=n,this.R=i,this.Fn=new ht(L),this.kn=new sn(function(o){return Kn(o)},Qr),this.On=P.min(),this._n=t.getMutationQueue(r),this.$n=t.getRemoteDocumentCache(),this.qe=t.getTargetCache(),this.Mn=new Nc(this.$n,this._n,this.persistence.getIndexManager()),this.Qe=t.getBundleCache(),this.xn.Vn(this.Mn)}return e.prototype.collectGarbage=function(t){var n=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",function(r){return t.collect(r,n.Fn)})},e}();/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Cc(e,t,n,r){return new Gf(e,t,n,r)}function kc(e,t){return g(this,void 0,void 0,function(){var n,r,i,o;return m(this,function(s){switch(s.label){case 0:return n=_(e),r=n._n,i=n.Mn,[4,n.persistence.runTransaction("Handle user change","readonly",function(u){var a;return n._n.getAllMutationBatches(u).next(function(c){return a=c,r=n.persistence.getMutationQueue(t),i=new Nc(n.$n,r,n.persistence.getIndexManager()),r.getAllMutationBatches(u)}).next(function(c){for(var h=[],l=[],f=B(),y=0,p=a;y<p.length;y++){var v=p[y];h.push(v.batchId);for(var E=0,T=v.mutations;E<T.length;E++){var k=T[E];f=f.add(k.key)}}for(var A=0,O=c;A<O.length;A++){var M=O[A];l.push(M.batchId);for(var q=0,et=M.mutations;q<et.length;q++){var ai=et[q];f=f.add(ai.key)}}return i.pn(u,f).next(function(ln){return{Ln:ln,removedBatchIds:h,addedBatchIds:l}})})})];case 1:return o=s.sent(),[2,(n._n=r,n.Mn=i,n.xn.Vn(n.Mn),o)]}})})}function zf(e,t){var n=_(e);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",function(r){var i=t.batch.keys(),o=n.$n.newChangeBuffer({trackRemovals:!0});return function(s,u,a,c){var h=a.batch,l=h.keys(),f=b.resolve();return l.forEach(function(y){f=f.next(function(){return c.getEntry(u,y)}).next(function(p){var v=a.docVersions.get(y);x(v!==null),p.version.compareTo(v)<0&&(h.applyToRemoteDocument(p,a),p.isValidDocument()&&c.addEntry(p,a.commitVersion))})}),f.next(function(){return s._n.removeMutationBatch(u,h)})}(n,r,t,o).next(function(){return o.apply(r)}).next(function(){return n._n.performConsistencyCheck(r)}).next(function(){return n.Mn.pn(r,i)})})}function xc(e){var t=_(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",function(n){return t.qe.getLastRemoteSnapshotVersion(n)})}function Qf(e,t){var n=_(e),r=t.snapshotVersion,i=n.Fn;return n.persistence.runTransaction("Apply remote event","readwrite-primary",function(o){var s=n.$n.newChangeBuffer({trackRemovals:!0});i=n.Fn;var u=[];t.targetChanges.forEach(function(h,l){var f=i.get(l);if(f){u.push(n.qe.removeMatchingKeys(o,h.removedDocuments,l).next(function(){return n.qe.addMatchingKeys(o,h.addedDocuments,l)}));var y=h.resumeToken;if(y.approximateByteSize()>0){var p=f.withResumeToken(y,r).withSequenceNumber(o.currentSequenceNumber);i=i.insert(l,p),function(v,E,T){return x(E.resumeToken.approximateByteSize()>0),v.resumeToken.approximateByteSize()===0||E.snapshotVersion.toMicroseconds()-v.snapshotVersion.toMicroseconds()>=3e8||T.addedDocuments.size+T.modifiedDocuments.size+T.removedDocuments.size>0}(f,p,h)&&u.push(n.qe.updateTargetData(o,p))}}});var a=Ot();if(t.documentUpdates.forEach(function(h,l){t.resolvedLimboDocuments.has(h)&&u.push(n.persistence.referenceDelegate.updateLimboDocument(o,h))}),u.push($f(o,s,t.documentUpdates,r,void 0).next(function(h){a=h})),!r.isEqual(P.min())){var c=n.qe.getLastRemoteSnapshotVersion(o).next(function(h){return n.qe.setTargetsMetadata(o,o.currentSequenceNumber,r)});u.push(c)}return b.waitFor(u).next(function(){return s.apply(o)}).next(function(){return n.Mn.En(o,a)}).next(function(){return a})}).then(function(o){return n.Fn=i,o})}function $f(e,t,n,r,i){var o=B();return n.forEach(function(s){return o=o.add(s)}),t.getEntries(e,o).next(function(s){var u=Ot();return n.forEach(function(a,c){var h=s.get(a),l=(i==null?void 0:i.get(a))||r;c.isNoDocument()&&c.version.isEqual(P.min())?(t.removeEntry(a,l),u=u.insert(a,c)):!h.isValidDocument()||c.version.compareTo(h.version)>0||c.version.compareTo(h.version)===0&&h.hasPendingWrites?(t.addEntry(c,l),u=u.insert(a,c)):I("LocalStore","Ignoring outdated watch update for ",a,". Current version:",h.version," Watch version:",c.version)}),u})}function Hf(e,t){var n=_(e);return n.persistence.runTransaction("Get next mutation batch","readonly",function(r){return t===void 0&&(t=-1),n._n.getNextMutationBatchAfterBatchId(r,t)})}function Ar(e,t){var n=_(e);return n.persistence.runTransaction("Allocate target","readwrite",function(r){var i;return n.qe.getTargetData(r,t).next(function(o){return o?(i=o,b.resolve(i)):n.qe.allocateTargetId(r).next(function(s){return i=new Xr(t,s,0,r.currentSequenceNumber),n.qe.addTargetData(r,i).next(function(){return i})})})}).then(function(r){var i=n.Fn.get(r.targetId);return(i===null||r.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(n.Fn=n.Fn.insert(r.targetId,r),n.kn.set(t,r.targetId)),r})}function Je(e,t,n){return g(this,void 0,void 0,function(){var r,i,o,s;return m(this,function(u){switch(u.label){case 0:r=_(e),i=r.Fn.get(t),o=n?"readwrite":"readwrite-primary",u.label=1;case 1:return u.trys.push([1,4,,5]),n?[3,3]:[4,r.persistence.runTransaction("Release target",o,function(a){return r.persistence.referenceDelegate.removeTarget(a,i)})];case 2:u.sent(),u.label=3;case 3:return[3,5];case 4:if(!De(s=u.sent()))throw s;return I("LocalStore","Failed to update sequence numbers for target "+t+": "+s),[3,5];case 5:return r.Fn=r.Fn.remove(t),r.kn.delete(i.target),[2]}})})}function Cr(e,t,n){var r=_(e),i=P.min(),o=B();return r.persistence.runTransaction("Execute query","readonly",function(s){return function(u,a,c){var h=_(u),l=h.kn.get(c);return l!==void 0?b.resolve(h.Fn.get(l)):h.qe.getTargetData(a,c)}(r,s,Ut(t)).next(function(u){if(u)return i=u.lastLimboFreeSnapshotVersion,r.qe.getMatchingKeysForTargetId(s,u.targetId).next(function(a){o=a})}).next(function(){return r.xn.getDocumentsMatchingQuery(s,t,n?i:P.min(),n?o:B())}).next(function(u){return{documents:u,Bn:o}})})}function Rc(e,t){var n=_(e),r=_(n.qe),i=n.Fn.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",function(o){return r.lt(o,t).next(function(s){return s?s.target:null})})}function Oc(e){var t=_(e);return t.persistence.runTransaction("Get new document changes","readonly",function(n){return function(r,i,o){var s=_(r),u=Ot(),a=Fo(o),c=Wt(i),h=IDBKeyRange.lowerBound(a,!0);return c.Ot({index:z.readTimeIndex,range:h},function(l,f){var y=Gi(s.R,f);u=u.insert(y.key,y),a=f.readTime}).next(function(){return{wn:u,readTime:bc(a)}})}(t.$n,n,t.On)}).then(function(n){var r=n.wn,i=n.readTime;return t.On=i,r})}function Wf(e){return g(this,void 0,void 0,function(){var t;return m(this,function(n){return[2,(t=_(e)).persistence.runTransaction("Synchronize last document change read time","readonly",function(r){return function(i){var o=Wt(i),s=P.min();return o.Ot({index:z.readTimeIndex,reverse:!0},function(u,a,c){a.readTime&&(s=bc(a.readTime)),c.done()}).next(function(){return s})}(r)}).then(function(r){t.On=r})]})})}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Xf=function(){function e(t){this.R=t,this.Kn=new Map,this.jn=new Map}return e.prototype.getBundleMetadata=function(t,n){return b.resolve(this.Kn.get(n))},e.prototype.saveBundleMetadata=function(t,n){var r;return this.Kn.set(n.id,{id:(r=n).id,version:r.version,createTime:yt(r.createTime)}),b.resolve()},e.prototype.getNamedQuery=function(t,n){return b.resolve(this.jn.get(n))},e.prototype.saveNamedQuery=function(t,n){return this.jn.set(n.name,function(r){return{name:r.name,query:Ec(r.bundledQuery),readTime:yt(r.readTime)}}(n)),b.resolve()},e}(),qo=function(){function e(){this.Wn=new J(tt.Gn),this.zn=new J(tt.Hn)}return e.prototype.isEmpty=function(){return this.Wn.isEmpty()},e.prototype.addReference=function(t,n){var r=new tt(t,n);this.Wn=this.Wn.add(r),this.zn=this.zn.add(r)},e.prototype.Jn=function(t,n){var r=this;t.forEach(function(i){return r.addReference(i,n)})},e.prototype.removeReference=function(t,n){this.Yn(new tt(t,n))},e.prototype.Xn=function(t,n){var r=this;t.forEach(function(i){return r.removeReference(i,n)})},e.prototype.Zn=function(t){var n=this,r=new N(new V([])),i=new tt(r,t),o=new tt(r,t+1),s=[];return this.zn.forEachInRange([i,o],function(u){n.Yn(u),s.push(u.key)}),s},e.prototype.ts=function(){var t=this;this.Wn.forEach(function(n){return t.Yn(n)})},e.prototype.Yn=function(t){this.Wn=this.Wn.delete(t),this.zn=this.zn.delete(t)},e.prototype.es=function(t){var n=new N(new V([])),r=new tt(n,t),i=new tt(n,t+1),o=B();return this.zn.forEachInRange([r,i],function(s){o=o.add(s.key)}),o},e.prototype.containsKey=function(t){var n=new tt(t,0),r=this.Wn.firstAfterOrEqual(n);return r!==null&&t.isEqual(r.key)},e}(),tt=function(){function e(t,n){this.key=t,this.ns=n}return e.Gn=function(t,n){return N.comparator(t.key,n.key)||L(t.ns,n.ns)},e.Hn=function(t,n){return L(t.ns,n.ns)||N.comparator(t.key,n.key)},e}(),Yf=function(){function e(t,n){this.Ut=t,this.referenceDelegate=n,this._n=[],this.ss=1,this.rs=new J(tt.Gn)}return e.prototype.checkEmpty=function(t){return b.resolve(this._n.length===0)},e.prototype.addMutationBatch=function(t,n,r,i){var o=this.ss;this.ss++,this._n.length>0&&this._n[this._n.length-1];var s=new Mo(o,n,r,i);this._n.push(s);for(var u=0,a=i;u<a.length;u++){var c=a[u];this.rs=this.rs.add(new tt(c.key,o)),this.Ut.addToCollectionParentIndex(t,c.key.path.popLast())}return b.resolve(s)},e.prototype.lookupMutationBatch=function(t,n){return b.resolve(this.os(n))},e.prototype.getNextMutationBatchAfterBatchId=function(t,n){var r=n+1,i=this.cs(r),o=i<0?0:i;return b.resolve(this._n.length>o?this._n[o]:null)},e.prototype.getHighestUnacknowledgedBatchId=function(){return b.resolve(this._n.length===0?-1:this.ss-1)},e.prototype.getAllMutationBatches=function(t){return b.resolve(this._n.slice())},e.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,n){var r=this,i=new tt(n,0),o=new tt(n,Number.POSITIVE_INFINITY),s=[];return this.rs.forEachInRange([i,o],function(u){var a=r.os(u.ns);s.push(a)}),b.resolve(s)},e.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,n){var r=this,i=new J(L);return n.forEach(function(o){var s=new tt(o,0),u=new tt(o,Number.POSITIVE_INFINITY);r.rs.forEachInRange([s,u],function(a){i=i.add(a.ns)})}),b.resolve(this.us(i))},e.prototype.getAllMutationBatchesAffectingQuery=function(t,n){var r=n.path,i=r.length+1,o=r;N.isDocumentKey(o)||(o=o.child(""));var s=new tt(new N(o),0),u=new J(L);return this.rs.forEachWhile(function(a){var c=a.key.path;return!!r.isPrefixOf(c)&&(c.length===i&&(u=u.add(a.ns)),!0)},s),b.resolve(this.us(u))},e.prototype.us=function(t){var n=this,r=[];return t.forEach(function(i){var o=n.os(i);o!==null&&r.push(o)}),r},e.prototype.removeMutationBatch=function(t,n){var r=this;x(this.hs(n.batchId,"removed")===0),this._n.shift();var i=this.rs;return b.forEach(n.mutations,function(o){var s=new tt(o.key,n.batchId);return i=i.delete(s),r.referenceDelegate.markPotentiallyOrphaned(t,o.key)}).next(function(){r.rs=i})},e.prototype.Gt=function(t){},e.prototype.containsKey=function(t,n){var r=new tt(n,0),i=this.rs.firstAfterOrEqual(r);return b.resolve(n.isEqual(i&&i.key))},e.prototype.performConsistencyCheck=function(t){return this._n.length,b.resolve()},e.prototype.hs=function(t,n){return this.cs(t)},e.prototype.cs=function(t){return this._n.length===0?0:t-this._n[0].batchId},e.prototype.os=function(t){var n=this.cs(t);return n<0||n>=this._n.length?null:this._n[n]},e}(),Jf=function(){function e(t,n){this.Ut=t,this.ls=n,this.docs=new ht(N.comparator),this.size=0}return e.prototype.addEntry=function(t,n,r){var i=n.key,o=this.docs.get(i),s=o?o.size:0,u=this.ls(n);return this.docs=this.docs.insert(i,{document:n.clone(),size:u,readTime:r}),this.size+=u-s,this.Ut.addToCollectionParentIndex(t,i.path.popLast())},e.prototype.removeEntry=function(t){var n=this.docs.get(t);n&&(this.docs=this.docs.remove(t),this.size-=n.size)},e.prototype.getEntry=function(t,n){var r=this.docs.get(n);return b.resolve(r?r.document.clone():ct.newInvalidDocument(n))},e.prototype.getEntries=function(t,n){var r=this,i=Ot();return n.forEach(function(o){var s=r.docs.get(o);i=i.insert(o,s?s.document.clone():ct.newInvalidDocument(o))}),b.resolve(i)},e.prototype.getDocumentsMatchingQuery=function(t,n,r){for(var i=Ot(),o=new N(n.path.child("")),s=this.docs.getIteratorFrom(o);s.hasNext();){var u=s.getNext(),a=u.key,c=u.value,h=c.document,l=c.readTime;if(!n.path.isPrefixOf(a.path))break;l.compareTo(r)<=0||Qn(n,h)&&(i=i.insert(h.key,h.clone()))}return b.resolve(i)},e.prototype.fs=function(t,n){return b.forEach(this.docs,function(r){return n(r)})},e.prototype.newChangeBuffer=function(t){return new Zf(this)},e.prototype.getSize=function(t){return b.resolve(this.size)},e}(),Zf=function(e){function t(n){var r=this;return(r=e.call(this)||this).Ie=n,r}return C(t,e),t.prototype.applyChanges=function(n){var r=this,i=[];return this.changes.forEach(function(o,s){s.document.isValidDocument()?i.push(r.Ie.addEntry(n,s.document,r.getReadTime(o))):r.Ie.removeEntry(o)}),b.waitFor(i)},t.prototype.getFromCache=function(n,r){return this.Ie.getEntry(n,r)},t.prototype.getAllFromCache=function(n,r){return this.Ie.getEntries(n,r)},t}(Dc),tp=function(){function e(t){this.persistence=t,this.ds=new sn(function(n){return Kn(n)},Qr),this.lastRemoteSnapshotVersion=P.min(),this.highestTargetId=0,this.ws=0,this._s=new qo,this.targetCount=0,this.ys=Nr.Jt()}return e.prototype.forEachTarget=function(t,n){return this.ds.forEach(function(r,i){return n(i)}),b.resolve()},e.prototype.getLastRemoteSnapshotVersion=function(t){return b.resolve(this.lastRemoteSnapshotVersion)},e.prototype.getHighestSequenceNumber=function(t){return b.resolve(this.ws)},e.prototype.allocateTargetId=function(t){return this.highestTargetId=this.ys.next(),b.resolve(this.highestTargetId)},e.prototype.setTargetsMetadata=function(t,n,r){return r&&(this.lastRemoteSnapshotVersion=r),n>this.ws&&(this.ws=n),b.resolve()},e.prototype.te=function(t){this.ds.set(t.target,t);var n=t.targetId;n>this.highestTargetId&&(this.ys=new Nr(n),this.highestTargetId=n),t.sequenceNumber>this.ws&&(this.ws=t.sequenceNumber)},e.prototype.addTargetData=function(t,n){return this.te(n),this.targetCount+=1,b.resolve()},e.prototype.updateTargetData=function(t,n){return this.te(n),b.resolve()},e.prototype.removeTargetData=function(t,n){return this.ds.delete(n.target),this._s.Zn(n.targetId),this.targetCount-=1,b.resolve()},e.prototype.removeTargets=function(t,n,r){var i=this,o=0,s=[];return this.ds.forEach(function(u,a){a.sequenceNumber<=n&&r.get(a.targetId)===null&&(i.ds.delete(u),s.push(i.removeMatchingKeysForTargetId(t,a.targetId)),o++)}),b.waitFor(s).next(function(){return o})},e.prototype.getTargetCount=function(t){return b.resolve(this.targetCount)},e.prototype.getTargetData=function(t,n){var r=this.ds.get(n)||null;return b.resolve(r)},e.prototype.addMatchingKeys=function(t,n,r){return this._s.Jn(n,r),b.resolve()},e.prototype.removeMatchingKeys=function(t,n,r){this._s.Xn(n,r);var i=this.persistence.referenceDelegate,o=[];return i&&n.forEach(function(s){o.push(i.markPotentiallyOrphaned(t,s))}),b.waitFor(o)},e.prototype.removeMatchingKeysForTargetId=function(t,n){return this._s.Zn(n),b.resolve()},e.prototype.getMatchingKeysForTargetId=function(t,n){var r=this._s.es(n);return b.resolve(r)},e.prototype.containsKey=function(t,n){return b.resolve(this._s.containsKey(n))},e}(),ep=function(){function e(t,n){var r=this;this.gs={},this.Ne=new St(0),this.xe=!1,this.xe=!0,this.referenceDelegate=t(this),this.qe=new tp(this),this.Ut=new xf,this.Ue=function(i,o){return new Jf(i,function(s){return r.referenceDelegate.ps(s)})}(this.Ut),this.R=new wc(n),this.Qe=new Xf(this.R)}return e.prototype.start=function(){return Promise.resolve()},e.prototype.shutdown=function(){return this.xe=!1,Promise.resolve()},Object.defineProperty(e.prototype,"started",{get:function(){return this.xe},enumerable:!1,configurable:!0}),e.prototype.setDatabaseDeletedListener=function(){},e.prototype.setNetworkEnabled=function(){},e.prototype.getIndexManager=function(){return this.Ut},e.prototype.getMutationQueue=function(t){var n=this.gs[t.toKey()];return n||(n=new Yf(this.Ut,this.referenceDelegate),this.gs[t.toKey()]=n),n},e.prototype.getTargetCache=function(){return this.qe},e.prototype.getRemoteDocumentCache=function(){return this.Ue},e.prototype.getBundleCache=function(){return this.Qe},e.prototype.runTransaction=function(t,n,r){var i=this;I("MemoryPersistence","Starting transaction:",t);var o=new np(this.Ne.next());return this.referenceDelegate.Es(),r(o).next(function(s){return i.referenceDelegate.Ts(o).next(function(){return s})}).toPromise().then(function(s){return o.raiseOnCommittedEvent(),s})},e.prototype.Is=function(t,n){return b.or(Object.values(this.gs).map(function(r){return function(){return r.containsKey(t,n)}}))},e}(),np=function(e){function t(n){var r=this;return(r=e.call(this)||this).currentSequenceNumber=n,r}return C(t,e),t}(mc),rp=function(){function e(t){this.persistence=t,this.As=new qo,this.Rs=null}return e.bs=function(t){return new e(t)},Object.defineProperty(e.prototype,"vs",{get:function(){if(this.Rs)return this.Rs;throw D()},enumerable:!1,configurable:!0}),e.prototype.addReference=function(t,n,r){return this.As.addReference(r,n),this.vs.delete(r.toString()),b.resolve()},e.prototype.removeReference=function(t,n,r){return this.As.removeReference(r,n),this.vs.add(r.toString()),b.resolve()},e.prototype.markPotentiallyOrphaned=function(t,n){return this.vs.add(n.toString()),b.resolve()},e.prototype.removeTarget=function(t,n){var r=this;this.As.Zn(n.targetId).forEach(function(o){return r.vs.add(o.toString())});var i=this.persistence.getTargetCache();return i.getMatchingKeysForTargetId(t,n.targetId).next(function(o){o.forEach(function(s){return r.vs.add(s.toString())})}).next(function(){return i.removeTargetData(t,n)})},e.prototype.Es=function(){this.Rs=new Set},e.prototype.Ts=function(t){var n=this,r=this.persistence.getRemoteDocumentCache().newChangeBuffer();return b.forEach(this.vs,function(i){var o=N.fromPath(i);return n.Ps(t,o).next(function(s){s||r.removeEntry(o)})}).next(function(){return n.Rs=null,r.apply(t)})},e.prototype.updateLimboDocument=function(t,n){var r=this;return this.Ps(t,n).next(function(i){i?r.vs.delete(n.toString()):r.vs.add(n.toString())})},e.prototype.ps=function(t){return 0},e.prototype.Ps=function(t,n){var r=this;return b.or([function(){return b.resolve(r.As.containsKey(n))},function(){return r.persistence.getTargetCache().containsKey(t,n)},function(){return r.persistence.Is(t,n)}])},e}(),Tt=function(){function e(t){this.uid=t}return e.prototype.isAuthenticated=function(){return this.uid!=null},e.prototype.toKey=function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"},e.prototype.isEqual=function(t){return t.uid===this.uid},e}();/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function ou(e,t){return"firestore_clients_"+e+"_"+t}function su(e,t,n){var r="firestore_mutations_"+e+"_"+n;return t.isAuthenticated()&&(r+="_"+t.uid),r}function wi(e,t){return"firestore_targets_"+e+"_"+t}Tt.UNAUTHENTICATED=new Tt(null),Tt.GOOGLE_CREDENTIALS=new Tt("google-credentials-uid"),Tt.FIRST_PARTY=new Tt("first-party-uid");var uu=function(){function e(t,n,r,i){this.user=t,this.batchId=n,this.state=r,this.error=i}return e.Vs=function(t,n,r){var i,o=JSON.parse(r),s=typeof o=="object"&&["pending","acknowledged","rejected"].indexOf(o.state)!==-1&&(o.error===void 0||typeof o.error=="object");return s&&o.error&&(s=typeof o.error.message=="string"&&typeof o.error.code=="string")&&(i=new w(o.error.code,o.error.message)),s?new e(t,n,o.state,i):(W("SharedClientState","Failed to parse mutation state for ID '"+n+"': "+r),null)},e.prototype.Ss=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},e}(),bi=function(){function e(t,n,r){this.targetId=t,this.state=n,this.error=r}return e.Vs=function(t,n){var r,i=JSON.parse(n),o=typeof i=="object"&&["not-current","current","rejected"].indexOf(i.state)!==-1&&(i.error===void 0||typeof i.error=="object");return o&&i.error&&(o=typeof i.error.message=="string"&&typeof i.error.code=="string")&&(r=new w(i.error.code,i.error.message)),o?new e(t,i.state,r):(W("SharedClientState","Failed to parse target state for ID '"+t+"': "+n),null)},e.prototype.Ss=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},e}(),au=function(){function e(t,n){this.clientId=t,this.activeTargetIds=n}return e.Vs=function(t,n){for(var r=JSON.parse(n),i=typeof r=="object"&&r.activeTargetIds instanceof Array,o=Wr(),s=0;i&&s<r.activeTargetIds.length;++s)i=ja(r.activeTargetIds[s]),o=o.add(r.activeTargetIds[s]);return i?new e(t,o):(W("SharedClientState","Failed to parse client data for instance '"+t+"': "+n),null)},e}(),ip=function(){function e(t,n){this.clientId=t,this.onlineState=n}return e.Vs=function(t){var n=JSON.parse(t);return typeof n=="object"&&["Unknown","Online","Offline"].indexOf(n.onlineState)!==-1&&typeof n.clientId=="string"?new e(n.clientId,n.onlineState):(W("SharedClientState","Failed to parse online state: "+t),null)},e}(),zi=function(){function e(){this.activeTargetIds=Wr()}return e.prototype.Ds=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},e.prototype.Cs=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},e.prototype.Ss=function(){var t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)},e}(),Ii=function(){function e(t,n,r,i,o){this.window=t,this.Se=n,this.persistenceKey=r,this.Ns=i,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.xs=this.Fs.bind(this),this.ks=new ht(L),this.started=!1,this.Os=[];var s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=o,this.$s=ou(this.persistenceKey,this.Ns),this.Ms=function(u){return"firestore_sequence_number_"+u}(this.persistenceKey),this.ks=this.ks.insert(this.Ns,new zi),this.Ls=new RegExp("^firestore_clients_"+s+"_([^_]*)$"),this.Bs=new RegExp("^firestore_mutations_"+s+"_(\\d+)(?:_(.*))?$"),this.qs=new RegExp("^firestore_targets_"+s+"_(\\d+)$"),this.Us=function(u){return"firestore_online_state_"+u}(this.persistenceKey),this.Qs=function(u){return"firestore_bundle_loaded_"+u}(this.persistenceKey),this.window.addEventListener("storage",this.xs)}return e.yt=function(t){return!(!t||!t.localStorage)},e.prototype.start=function(){return g(this,void 0,void 0,function(){var t,n,r,i,o,s,u,a,c,h,l,f=this;return m(this,function(y){switch(y.label){case 0:return[4,this.syncEngine.fn()];case 1:for(t=y.sent(),n=0,r=t;n<r.length;n++)(i=r[n])!==this.Ns&&(o=this.getItem(ou(this.persistenceKey,i)))&&(s=au.Vs(i,o))&&(this.ks=this.ks.insert(s.clientId,s));for(this.Ks(),(u=this.storage.getItem(this.Us))&&(a=this.js(u))&&this.Ws(a),c=0,h=this.Os;c<h.length;c++)l=h[c],this.Fs(l);return this.Os=[],this.window.addEventListener("unload",function(){return f.shutdown()}),this.started=!0,[2]}})})},e.prototype.writeSequenceNumber=function(t){this.setItem(this.Ms,JSON.stringify(t))},e.prototype.getAllActiveQueryTargets=function(){return this.Gs(this.ks)},e.prototype.isActiveQueryTarget=function(t){var n=!1;return this.ks.forEach(function(r,i){i.activeTargetIds.has(t)&&(n=!0)}),n},e.prototype.addPendingMutation=function(t){this.zs(t,"pending")},e.prototype.updateMutationState=function(t,n,r){this.zs(t,n,r),this.Hs(t)},e.prototype.addLocalQueryTarget=function(t){var n="not-current";if(this.isActiveQueryTarget(t)){var r=this.storage.getItem(wi(this.persistenceKey,t));if(r){var i=bi.Vs(t,r);i&&(n=i.state)}}return this.Js.Ds(t),this.Ks(),n},e.prototype.removeLocalQueryTarget=function(t){this.Js.Cs(t),this.Ks()},e.prototype.isLocalQueryTarget=function(t){return this.Js.activeTargetIds.has(t)},e.prototype.clearQueryState=function(t){this.removeItem(wi(this.persistenceKey,t))},e.prototype.updateQueryState=function(t,n,r){this.Ys(t,n,r)},e.prototype.handleUserChange=function(t,n,r){var i=this;n.forEach(function(o){i.Hs(o)}),this.currentUser=t,r.forEach(function(o){i.addPendingMutation(o)})},e.prototype.setOnlineState=function(t){this.Xs(t)},e.prototype.notifyBundleLoaded=function(){this.Zs()},e.prototype.shutdown=function(){this.started&&(this.window.removeEventListener("storage",this.xs),this.removeItem(this.$s),this.started=!1)},e.prototype.getItem=function(t){var n=this.storage.getItem(t);return I("SharedClientState","READ",t,n),n},e.prototype.setItem=function(t,n){I("SharedClientState","SET",t,n),this.storage.setItem(t,n)},e.prototype.removeItem=function(t){I("SharedClientState","REMOVE",t),this.storage.removeItem(t)},e.prototype.Fs=function(t){var n=this,r=t;if(r.storageArea===this.storage){if(I("SharedClientState","EVENT",r.key,r.newValue),r.key===this.$s)return void W("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Se.enqueueRetryable(function(){return g(n,void 0,void 0,function(){var i,o,s,u,a,c;return m(this,function(h){if(this.started){if(r.key!==null){if(this.Ls.test(r.key)){if(r.newValue==null)return i=this.ti(r.key),[2,this.ei(i,null)];if(o=this.ni(r.key,r.newValue))return[2,this.ei(o.clientId,o)]}else if(this.Bs.test(r.key)){if(r.newValue!==null&&(s=this.si(r.key,r.newValue)))return[2,this.ii(s)]}else if(this.qs.test(r.key)){if(r.newValue!==null&&(u=this.ri(r.key,r.newValue)))return[2,this.oi(u)]}else if(r.key===this.Us){if(r.newValue!==null&&(a=this.js(r.newValue)))return[2,this.Ws(a)]}else if(r.key===this.Ms)(c=function(l){var f=St.o;if(l!=null)try{var y=JSON.parse(l);x(typeof y=="number"),f=y}catch(p){W("SharedClientState","Failed to read sequence number from WebStorage",p)}return f}(r.newValue))!==St.o&&this.sequenceNumberHandler(c);else if(r.key===this.Qs)return[2,this.syncEngine.ci()]}}else this.Os.push(r);return[2]})})})}},Object.defineProperty(e.prototype,"Js",{get:function(){return this.ks.get(this.Ns)},enumerable:!1,configurable:!0}),e.prototype.Ks=function(){this.setItem(this.$s,this.Js.Ss())},e.prototype.zs=function(t,n,r){var i=new uu(this.currentUser,t,n,r),o=su(this.persistenceKey,this.currentUser,t);this.setItem(o,i.Ss())},e.prototype.Hs=function(t){var n=su(this.persistenceKey,this.currentUser,t);this.removeItem(n)},e.prototype.Xs=function(t){var n={clientId:this.Ns,onlineState:t};this.storage.setItem(this.Us,JSON.stringify(n))},e.prototype.Ys=function(t,n,r){var i=wi(this.persistenceKey,t),o=new bi(t,n,r);this.setItem(i,o.Ss())},e.prototype.Zs=function(){this.setItem(this.Qs,"value-not-used")},e.prototype.ti=function(t){var n=this.Ls.exec(t);return n?n[1]:null},e.prototype.ni=function(t,n){var r=this.ti(t);return au.Vs(r,n)},e.prototype.si=function(t,n){var r=this.Bs.exec(t),i=Number(r[1]),o=r[2]!==void 0?r[2]:null;return uu.Vs(new Tt(o),i,n)},e.prototype.ri=function(t,n){var r=this.qs.exec(t),i=Number(r[1]);return bi.Vs(i,n)},e.prototype.js=function(t){return ip.Vs(t)},e.prototype.ii=function(t){return g(this,void 0,void 0,function(){return m(this,function(n){return t.user.uid===this.currentUser.uid?[2,this.syncEngine.ui(t.batchId,t.state,t.error)]:(I("SharedClientState","Ignoring mutation for non-active user "+t.user.uid),[2])})})},e.prototype.oi=function(t){return this.syncEngine.ai(t.targetId,t.state,t.error)},e.prototype.ei=function(t,n){var r=this,i=n?this.ks.insert(t,n):this.ks.remove(t),o=this.Gs(this.ks),s=this.Gs(i),u=[],a=[];return s.forEach(function(c){o.has(c)||u.push(c)}),o.forEach(function(c){s.has(c)||a.push(c)}),this.syncEngine.hi(u,a).then(function(){r.ks=i})},e.prototype.Ws=function(t){this.ks.get(t.clientId)&&this.onlineStateHandler(t.onlineState)},e.prototype.Gs=function(t){var n=Wr();return t.forEach(function(r,i){n=n.unionWith(i.activeTargetIds)}),n},e}(),Pc=function(){function e(){this.li=new zi,this.fi={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}return e.prototype.addPendingMutation=function(t){},e.prototype.updateMutationState=function(t,n,r){},e.prototype.addLocalQueryTarget=function(t){return this.li.Ds(t),this.fi[t]||"not-current"},e.prototype.updateQueryState=function(t,n,r){this.fi[t]=n},e.prototype.removeLocalQueryTarget=function(t){this.li.Cs(t)},e.prototype.isLocalQueryTarget=function(t){return this.li.activeTargetIds.has(t)},e.prototype.clearQueryState=function(t){delete this.fi[t]},e.prototype.getAllActiveQueryTargets=function(){return this.li.activeTargetIds},e.prototype.isActiveQueryTarget=function(t){return this.li.activeTargetIds.has(t)},e.prototype.start=function(){return this.li=new zi,Promise.resolve()},e.prototype.handleUserChange=function(t,n,r){},e.prototype.setOnlineState=function(t){},e.prototype.shutdown=function(){},e.prototype.writeSequenceNumber=function(t){},e.prototype.notifyBundleLoaded=function(){},e}(),op=function(){function e(){}return e.prototype.di=function(t){},e.prototype.shutdown=function(){},e}(),cu=function(){function e(){var t=this;this.wi=function(){return t._i()},this.mi=function(){return t.yi()},this.gi=[],this.pi()}return e.prototype.di=function(t){this.gi.push(t)},e.prototype.shutdown=function(){window.removeEventListener("online",this.wi),window.removeEventListener("offline",this.mi)},e.prototype.pi=function(){window.addEventListener("online",this.wi),window.addEventListener("offline",this.mi)},e.prototype._i=function(){I("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,n=this.gi;t<n.length;t++)(0,n[t])(0)},e.prototype.yi=function(){I("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,n=this.gi;t<n.length;t++)(0,n[t])(1)},e.yt=function(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0},e}(),sp={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"},up=function(){function e(t){this.Ei=t.Ei,this.Ti=t.Ti}return e.prototype.Ii=function(t){this.Ai=t},e.prototype.Ri=function(t){this.bi=t},e.prototype.onMessage=function(t){this.vi=t},e.prototype.close=function(){this.Ti()},e.prototype.send=function(t){this.Ei(t)},e.prototype.Pi=function(){this.Ai()},e.prototype.Vi=function(t){this.bi(t)},e.prototype.Si=function(t){this.vi(t)},e}(),ap=function(e){function t(n){var r=this;return(r=e.call(this,n)||this).forceLongPolling=n.forceLongPolling,r.autoDetectLongPolling=n.autoDetectLongPolling,r}return C(t,e),t.prototype.ki=function(n,r,i,o){return new Promise(function(s,u){var a=new Fl;a.listenOnce(Ll.COMPLETE,function(){try{switch(a.getLastErrorCode()){case mi.NO_ERROR:var h=a.getResponseJson();I("Connection","XHR received:",JSON.stringify(h)),s(h);break;case mi.TIMEOUT:I("Connection",'RPC "'+n+'" timed out'),u(new w(d.DEADLINE_EXCEEDED,"Request time out"));break;case mi.HTTP_ERROR:var l=a.getStatus();if(I("Connection",'RPC "'+n+'" failed with status:',l,"response text:",a.getResponseText()),l>0){var f=a.getResponseJson().error;if(f&&f.status&&f.message){var y=function(p){var v=p.toLowerCase().replace(/_/g,"-");return Object.values(d).indexOf(v)>=0?v:d.UNKNOWN}(f.status);u(new w(y,f.message))}else u(new w(d.UNKNOWN,"Server responded with status "+a.getStatus()))}else u(new w(d.UNAVAILABLE,"Connection failed."));break;default:D()}}finally{I("Connection",'RPC "'+n+'" completed.')}});var c=JSON.stringify(o);a.send(r,"POST",c,i,15)})},t.prototype.$i=function(n,r){var i=[this.Di,"/","google.firestore.v1.Firestore","/",n,"/channel"],o=Ol(),s=Pl(),u={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.Fi(u.initMessageHeaders,r),Sh()||Dh()||Nh()||Ah()||Ch()||kh()||(u.httpHeadersOverwriteParam="$httpHeaders");var a=i.join("");I("Connection","Creating WebChannel: "+a,u);var c=o.createWebChannel(a,u),h=!1,l=!1,f=new up({Ei:function(p){l?I("Connection","Not sending because WebChannel is closed:",p):(h||(I("Connection","Opening WebChannel transport."),c.open(),h=!0),I("Connection","WebChannel sending:",p),c.send(p))},Ti:function(){return c.close()}}),y=function(p,v,E){p.listen(v,function(T){try{E(T)}catch(k){setTimeout(function(){throw k},0)}})};return y(c,er.EventType.OPEN,function(){l||I("Connection","WebChannel transport opened.")}),y(c,er.EventType.CLOSE,function(){l||(l=!0,I("Connection","WebChannel transport closed"),f.Vi())}),y(c,er.EventType.ERROR,function(p){l||(l=!0,Mi("Connection","WebChannel transport errored:",p),f.Vi(new w(d.UNAVAILABLE,"The operation could not be completed")))}),y(c,er.EventType.MESSAGE,function(p){var v;if(!l){var E=p.data[0];x(!!E);var T=E,k=T.error||((v=T[0])===null||v===void 0?void 0:v.error);if(k){I("Connection","WebChannel received error:",k);var A=k.status,O=function(q){var et=Q[q];if(et!==void 0)return ic(et)}(A),M=k.message;O===void 0&&(O=d.INTERNAL,M="Unknown error status: "+A+" with message "+k.message),l=!0,f.Vi(new w(O,M)),c.close()}else I("Connection","WebChannel received:",E),f.Si(E)}}),y(s,Ml.STAT_EVENT,function(p){p.stat===Ds.PROXY?I("Connection","Detected buffering proxy"):p.stat===Ds.NOPROXY&&I("Connection","Detected no buffering proxy")}),setTimeout(function(){f.Pi()},0),f},t}(function(){function e(t){this.databaseInfo=t,this.databaseId=t.databaseId;var n=t.ssl?"https":"http";this.Di=n+"://"+t.host,this.Ci="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}return e.prototype.Ni=function(t,n,r,i){var o=this.xi(t,n);I("RestConnection","Sending: ",o,r);var s={};return this.Fi(s,i),this.ki(t,o,s,r).then(function(u){return I("RestConnection","Received: ",u),u},function(u){throw Mi("RestConnection",t+" failed with error: ",u,"url: ",o,"request:",r),u})},e.prototype.Oi=function(t,n,r,i){return this.Ni(t,n,r,i)},e.prototype.Fi=function(t,n){if(t["X-Goog-Api-Client"]="gl-js/ fire/8.3.3",t["X-Firebase-GMPID"]=this.databaseInfo.appId,t["Content-Type"]="text/plain",n)for(var r in n.authHeaders)n.authHeaders.hasOwnProperty(r)&&(t[r]=n.authHeaders[r])},e.prototype.xi=function(t,n){var r=sp[t];return this.Di+"/v1/"+n+":"+r},e}());/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*//**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Lc(){return typeof window<"u"?window:null}function cr(){return typeof document<"u"?document:null}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Yr(e){return new df(e,!0)}var Bo=function(){function e(t,n,r,i,o){r===void 0&&(r=1e3),i===void 0&&(i=1.5),o===void 0&&(o=6e4),this.Se=t,this.timerId=n,this.Mi=r,this.Li=i,this.Bi=o,this.qi=0,this.Ui=null,this.Qi=Date.now(),this.reset()}return e.prototype.reset=function(){this.qi=0},e.prototype.Ki=function(){this.qi=this.Bi},e.prototype.ji=function(t){var n=this;this.cancel();var r=Math.floor(this.qi+this.Wi()),i=Math.max(0,Date.now()-this.Qi),o=Math.max(0,r-i);o>0&&I("ExponentialBackoff","Backing off for "+o+" ms (base delay: "+this.qi+" ms, delay with jitter: "+r+" ms, last attempt: "+i+" ms ago)"),this.Ui=this.Se.enqueueAfterDelay(this.timerId,o,function(){return n.Qi=Date.now(),t()}),this.qi*=this.Li,this.qi<this.Mi&&(this.qi=this.Mi),this.qi>this.Bi&&(this.qi=this.Bi)},e.prototype.Gi=function(){this.Ui!==null&&(this.Ui.skipDelay(),this.Ui=null)},e.prototype.cancel=function(){this.Ui!==null&&(this.Ui.cancel(),this.Ui=null)},e.prototype.Wi=function(){return(Math.random()-.5)*this.qi},e}(),Mc=function(){function e(t,n,r,i,o,s){this.Se=t,this.zi=r,this.Hi=i,this.Ji=o,this.listener=s,this.state=0,this.Yi=0,this.Xi=null,this.stream=null,this.Zi=new Bo(t,n)}return e.prototype.tr=function(){return this.state===1||this.state===2||this.state===4},e.prototype.er=function(){return this.state===2},e.prototype.start=function(){this.state!==3?this.auth():this.nr()},e.prototype.stop=function(){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return this.tr()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},e.prototype.sr=function(){this.state=0,this.Zi.reset()},e.prototype.ir=function(){var t=this;this.er()&&this.Xi===null&&(this.Xi=this.Se.enqueueAfterDelay(this.zi,6e4,function(){return t.rr()}))},e.prototype.cr=function(t){this.ur(),this.stream.send(t)},e.prototype.rr=function(){return g(this,void 0,void 0,function(){return m(this,function(t){return this.er()?[2,this.close(0)]:[2]})})},e.prototype.ur=function(){this.Xi&&(this.Xi.cancel(),this.Xi=null)},e.prototype.close=function(t,n){return g(this,void 0,void 0,function(){return m(this,function(r){switch(r.label){case 0:return this.ur(),this.Zi.cancel(),this.Yi++,t!==3?this.Zi.reset():n&&n.code===d.RESOURCE_EXHAUSTED?(W(n.toString()),W("Using maximum backoff delay to prevent overloading the backend."),this.Zi.Ki()):n&&n.code===d.UNAUTHENTICATED&&this.Ji.invalidateToken(),this.stream!==null&&(this.ar(),this.stream.close(),this.stream=null),this.state=t,[4,this.listener.Ri(n)];case 1:return r.sent(),[2]}})})},e.prototype.ar=function(){},e.prototype.auth=function(){var t=this;this.state=1;var n=this.hr(this.Yi),r=this.Yi;this.Ji.getToken().then(function(i){t.Yi===r&&t.lr(i)},function(i){n(function(){var o=new w(d.UNKNOWN,"Fetching auth token failed: "+i.message);return t.dr(o)})})},e.prototype.lr=function(t){var n=this,r=this.hr(this.Yi);this.stream=this.wr(t),this.stream.Ii(function(){r(function(){return n.state=2,n.listener.Ii()})}),this.stream.Ri(function(i){r(function(){return n.dr(i)})}),this.stream.onMessage(function(i){r(function(){return n.onMessage(i)})})},e.prototype.nr=function(){var t=this;this.state=4,this.Zi.ji(function(){return g(t,void 0,void 0,function(){return m(this,function(n){return this.state=0,this.start(),[2]})})})},e.prototype.dr=function(t){return I("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},e.prototype.hr=function(t){var n=this;return function(r){n.Se.enqueueAndForget(function(){return n.Yi===t?r():(I("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},e}(),cp=function(e){function t(n,r,i,o,s){var u=this;return(u=e.call(this,n,"listen_stream_connection_backoff","listen_stream_idle",r,i,s)||this).R=o,u}return C(t,e),t.prototype.wr=function(n){return this.Hi.$i("Listen",n)},t.prototype.onMessage=function(n){this.Zi.reset();var r=function(o,s){var u;if("targetChange"in s){s.targetChange;var a=function(E){return E==="NO_CHANGE"?0:E==="ADD"?1:E==="REMOVE"?2:E==="CURRENT"?3:E==="RESET"?4:D()}(s.targetChange.targetChangeType||"NO_CHANGE"),c=s.targetChange.targetIds||[],h=function(E,T){return E.I?(x(T===void 0||typeof T=="string"),wt.fromBase64String(T||"")):(x(T===void 0||T instanceof Uint8Array),wt.fromUint8Array(T||new Uint8Array))}(o,s.targetChange.resumeToken),l=(f=s.targetChange.cause)&&function(E){var T=E.code===void 0?d.UNKNOWN:ic(E.code);return new w(T,E.message||"")}(f);u=new sc(a,c,h,l||null)}else if("documentChange"in s){s.documentChange,(a=s.documentChange).document,a.document.name,a.document.updateTime,c=jt(o,a.document.name),h=yt(a.document.updateTime);var f=new _t({mapValue:{fields:a.document.fields}}),y=(l=ct.newFoundDocument(c,h,f),a.targetIds||[]),p=a.removedTargetIds||[];u=new ar(y,p,l.key,l)}else if("documentDelete"in s)s.documentDelete,(a=s.documentDelete).document,c=jt(o,a.document),h=a.readTime?yt(a.readTime):P.min(),f=ct.newNoDocument(c,h),l=a.removedTargetIds||[],u=new ar([],l,f.key,f);else if("documentRemove"in s)s.documentRemove,(a=s.documentRemove).document,c=jt(o,a.document),h=a.removedTargetIds||[],u=new ar([],h,c,null);else{if(!("filter"in s))return D();s.filter;var v=s.filter;v.targetId,a=v.count||0,c=new rf(a),h=v.targetId,u=new oc(h,c)}return u}(this.R,n),i=function(o){if(!("targetChange"in o))return P.min();var s=o.targetChange;return s.targetIds&&s.targetIds.length?P.min():s.readTime?yt(s.readTime):P.min()}(n);return this.listener._r(r,i)},t.prototype.mr=function(n){var r={};r.database=An(this.R),r.addTarget=function(o,s){var u,a=s.target;return(u=Er(a)?{documents:lc(o,a)}:{query:fc(o,a)}).targetId=s.targetId,s.resumeToken.approximateByteSize()>0?u.resumeToken=uc(o,s.resumeToken):s.snapshotVersion.compareTo(P.min())>0&&(u.readTime=Dn(o,s.snapshotVersion.toTimestamp())),u}(this.R,n);var i=function(o,s){var u=function(a,c){switch(c){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return D()}}(0,s.purpose);return u==null?null:{"goog-listen-tags":u}}(this.R,n);i&&(r.labels=i),this.cr(r)},t.prototype.yr=function(n){var r={};r.database=An(this.R),r.removeTarget=n,this.cr(r)},t}(Mc),hp=function(e){function t(n,r,i,o,s){var u=this;return(u=e.call(this,n,"write_stream_connection_backoff","write_stream_idle",r,i,s)||this).R=o,u.gr=!1,u}return C(t,e),Object.defineProperty(t.prototype,"pr",{get:function(){return this.gr},enumerable:!1,configurable:!0}),t.prototype.start=function(){this.gr=!1,this.lastStreamToken=void 0,e.prototype.start.call(this)},t.prototype.ar=function(){this.gr&&this.Er([])},t.prototype.wr=function(n){return this.Hi.$i("Write",n)},t.prototype.onMessage=function(n){if(x(!!n.streamToken),this.lastStreamToken=n.streamToken,this.gr){this.Zi.reset();var r=function(o,s){return o&&o.length>0?(x(s!==void 0),o.map(function(u){return function(a,c){var h=a.updateTime?yt(a.updateTime):yt(c);return h.isEqual(P.min())&&(h=yt(c)),new tf(h,a.transformResults||[])}(u,s)})):[]}(n.writeResults,n.commitTime),i=yt(n.commitTime);return this.listener.Tr(i,r)}return x(!n.writeResults||n.writeResults.length===0),this.gr=!0,this.listener.Ir()},t.prototype.Ar=function(){var n={};n.database=An(this.R),this.cr(n)},t.prototype.Er=function(n){var r=this,i={streamToken:this.lastStreamToken,writes:n.map(function(o){return Sr(r.R,o)})};this.cr(i)},t}(Mc),lp=function(e){function t(n,r,i){var o=this;return(o=e.call(this)||this).credentials=n,o.Hi=r,o.R=i,o.Rr=!1,o}return C(t,e),t.prototype.br=function(){if(this.Rr)throw new w(d.FAILED_PRECONDITION,"The client has already been terminated.")},t.prototype.Ni=function(n,r,i){var o=this;return this.br(),this.credentials.getToken().then(function(s){return o.Hi.Ni(n,r,i,s)}).catch(function(s){throw s.code===d.UNAUTHENTICATED&&o.credentials.invalidateToken(),s})},t.prototype.Oi=function(n,r,i){var o=this;return this.br(),this.credentials.getToken().then(function(s){return o.Hi.Oi(n,r,i,s)}).catch(function(s){throw s.code===d.UNAUTHENTICATED&&o.credentials.invalidateToken(),s})},t.prototype.terminate=function(){this.Rr=!1},t}(function(){}),fp=function(){function e(t,n){this.asyncQueue=t,this.onlineStateHandler=n,this.state="Unknown",this.vr=0,this.Pr=null,this.Vr=!0}return e.prototype.Sr=function(){var t=this;this.vr===0&&(this.Dr("Unknown"),this.Pr=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,function(){return t.Pr=null,t.Cr("Backend didn't respond within 10 seconds."),t.Dr("Offline"),Promise.resolve()}))},e.prototype.Nr=function(t){this.state==="Online"?this.Dr("Unknown"):(this.vr++,this.vr>=1&&(this.Fr(),this.Cr("Connection failed 1 times. Most recent error: "+t.toString()),this.Dr("Offline")))},e.prototype.set=function(t){this.Fr(),this.vr=0,t==="Online"&&(this.Vr=!1),this.Dr(t)},e.prototype.Dr=function(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))},e.prototype.Cr=function(t){var n="Could not reach Cloud Firestore backend. "+t+`
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.Vr?(W(n),this.Vr=!1):I("OnlineStateTracker",n)},e.prototype.Fr=function(){this.Pr!==null&&(this.Pr.cancel(),this.Pr=null)},e}(),pp=function(e,t,n,r,i){var o=this;this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.kr=[],this.Or=new Map,this.$r=new Set,this.Mr=[],this.Lr=i,this.Lr.di(function(s){n.enqueueAndForget(function(){return g(o,void 0,void 0,function(){return m(this,function(u){switch(u.label){case 0:return he(this)?(I("RemoteStore","Restarting streams for network reachability change."),[4,function(a){return g(this,void 0,void 0,function(){var c;return m(this,function(h){switch(h.label){case 0:return(c=_(a)).$r.add(4),[4,un(c)];case 1:return h.sent(),c.Br.set("Unknown"),c.$r.delete(4),[4,Xn(c)];case 2:return h.sent(),[2]}})})}(this)]):[3,2];case 1:u.sent(),u.label=2;case 2:return[2]}})})})}),this.Br=new fp(n,r)};/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Xn(e){return g(this,void 0,void 0,function(){var t,n;return m(this,function(r){switch(r.label){case 0:if(!he(e))return[3,4];t=0,n=e.Mr,r.label=1;case 1:return t<n.length?[4,(0,n[t])(!0)]:[3,4];case 2:r.sent(),r.label=3;case 3:return t++,[3,1];case 4:return[2]}})})}function un(e){return g(this,void 0,void 0,function(){var t,n;return m(this,function(r){switch(r.label){case 0:t=0,n=e.Mr,r.label=1;case 1:return t<n.length?[4,(0,n[t])(!1)]:[3,4];case 2:r.sent(),r.label=3;case 3:return t++,[3,1];case 4:return[2]}})})}function Jr(e,t){var n=_(e);n.Or.has(t.targetId)||(n.Or.set(t.targetId,t),Go(n)?Ko(n):cn(n).er()&&jo(n,t))}function Cn(e,t){var n=_(e),r=cn(n);n.Or.delete(t),r.er()&&Fc(n,t),n.Or.size===0&&(r.er()?r.ir():he(n)&&n.Br.set("Unknown"))}function jo(e,t){e.qr.U(t.targetId),cn(e).mr(t)}function Fc(e,t){e.qr.U(t),cn(e).yr(t)}function Ko(e){e.qr=new lf({getRemoteKeysForTarget:function(t){return e.remoteSyncer.getRemoteKeysForTarget(t)},lt:function(t){return e.Or.get(t)||null}}),cn(e).start(),e.Br.Sr()}function Go(e){return he(e)&&!cn(e).tr()&&e.Or.size>0}function he(e){return _(e).$r.size===0}function Vc(e){e.qr=void 0}function dp(e){return g(this,void 0,void 0,function(){return m(this,function(t){return e.Or.forEach(function(n,r){jo(e,n)}),[2]})})}function yp(e,t){return g(this,void 0,void 0,function(){return m(this,function(n){return Vc(e),Go(e)?(e.Br.Nr(t),Ko(e)):e.Br.set("Unknown"),[2]})})}function vp(e,t,n){return g(this,void 0,void 0,function(){var r,i,o;return m(this,function(s){switch(s.label){case 0:if(e.Br.set("Online"),!(t instanceof sc&&t.state===2&&t.cause))return[3,6];s.label=1;case 1:return s.trys.push([1,3,,5]),[4,function(u,a){return g(this,void 0,void 0,function(){var c,h,l,f;return m(this,function(y){switch(y.label){case 0:c=a.cause,h=0,l=a.targetIds,y.label=1;case 1:return h<l.length?(f=l[h],u.Or.has(f)?[4,u.remoteSyncer.rejectListen(f,c)]:[3,3]):[3,5];case 2:y.sent(),u.Or.delete(f),u.qr.removeTarget(f),y.label=3;case 3:y.label=4;case 4:return h++,[3,1];case 5:return[2]}})})}(e,t)];case 2:return s.sent(),[3,5];case 3:return r=s.sent(),I("RemoteStore","Failed to remove targets %s: %s ",t.targetIds.join(","),r),[4,kr(e,r)];case 4:return s.sent(),[3,5];case 5:return[3,13];case 6:if(t instanceof ar?e.qr.X(t):t instanceof oc?e.qr.rt(t):e.qr.et(t),n.isEqual(P.min()))return[3,13];s.label=7;case 7:return s.trys.push([7,11,,13]),[4,xc(e.localStore)];case 8:return i=s.sent(),n.compareTo(i)>=0?[4,function(u,a){var c=u.qr.ut(a);return c.targetChanges.forEach(function(h,l){if(h.resumeToken.approximateByteSize()>0){var f=u.Or.get(l);f&&u.Or.set(l,f.withResumeToken(h.resumeToken,a))}}),c.targetMismatches.forEach(function(h){var l=u.Or.get(h);if(l){u.Or.set(h,l.withResumeToken(wt.EMPTY_BYTE_STRING,l.snapshotVersion)),Fc(u,h);var f=new Xr(l.target,h,1,l.sequenceNumber);jo(u,f)}}),u.remoteSyncer.applyRemoteEvent(c)}(e,n)]:[3,10];case 9:s.sent(),s.label=10;case 10:return[3,13];case 11:return I("RemoteStore","Failed to raise snapshot:",o=s.sent()),[4,kr(e,o)];case 12:return s.sent(),[3,13];case 13:return[2]}})})}function kr(e,t,n){return g(this,void 0,void 0,function(){var r=this;return m(this,function(i){switch(i.label){case 0:if(!De(t))throw t;return e.$r.add(1),[4,un(e)];case 1:return i.sent(),e.Br.set("Offline"),n||(n=function(){return xc(e.localStore)}),e.asyncQueue.enqueueRetryable(function(){return g(r,void 0,void 0,function(){return m(this,function(o){switch(o.label){case 0:return I("RemoteStore","Retrying IndexedDB access"),[4,n()];case 1:return o.sent(),e.$r.delete(1),[4,Xn(e)];case 2:return o.sent(),[2]}})})}),[2]}})})}function Uc(e,t){return t().catch(function(n){return kr(e,n,t)})}function an(e){return g(this,void 0,void 0,function(){var t,n,r,i,o;return m(this,function(s){switch(s.label){case 0:t=_(e),n=se(t),r=t.kr.length>0?t.kr[t.kr.length-1].batchId:-1,s.label=1;case 1:if(!function(u){return he(u)&&u.kr.length<10}(t))return[3,7];s.label=2;case 2:return s.trys.push([2,4,,6]),[4,Hf(t.localStore,r)];case 3:return(i=s.sent())===null?(t.kr.length===0&&n.ir(),[3,7]):(r=i.batchId,function(u,a){u.kr.push(a);var c=se(u);c.er()&&c.pr&&c.Er(a.mutations)}(t,i),[3,6]);case 4:return o=s.sent(),[4,kr(t,o)];case 5:return s.sent(),[3,6];case 6:return[3,1];case 7:return qc(t)&&Bc(t),[2]}})})}function qc(e){return he(e)&&!se(e).tr()&&e.kr.length>0}function Bc(e){se(e).start()}function mp(e){return g(this,void 0,void 0,function(){return m(this,function(t){return se(e).Ar(),[2]})})}function gp(e){return g(this,void 0,void 0,function(){var t,n,r,i;return m(this,function(o){for(t=se(e),n=0,r=e.kr;n<r.length;n++)i=r[n],t.Er(i.mutations);return[2]})})}function wp(e,t,n){return g(this,void 0,void 0,function(){var r,i;return m(this,function(o){switch(o.label){case 0:return r=e.kr.shift(),i=Cf.from(r,t,n),[4,Uc(e,function(){return e.remoteSyncer.applySuccessfulWrite(i)})];case 1:return o.sent(),[4,an(e)];case 2:return o.sent(),[2]}})})}function bp(e,t){return g(this,void 0,void 0,function(){return m(this,function(n){switch(n.label){case 0:return t&&se(e).pr?[4,function(r,i){return g(this,void 0,void 0,function(){var o,s;return m(this,function(u){switch(u.label){case 0:return rc(s=i.code)&&s!==d.ABORTED?(o=r.kr.shift(),se(r).sr(),[4,Uc(r,function(){return r.remoteSyncer.rejectFailedWrite(o.batchId,i)})]):[3,3];case 1:return u.sent(),[4,an(r)];case 2:u.sent(),u.label=3;case 3:return[2]}})})}(e,t)]:[3,2];case 1:n.sent(),n.label=2;case 2:return qc(e)&&Bc(e),[2]}})})}function Qi(e,t){return g(this,void 0,void 0,function(){var n;return m(this,function(r){switch(r.label){case 0:return n=_(e),t?(n.$r.delete(2),[4,Xn(n)]):[3,2];case 1:return r.sent(),[3,5];case 2:return t?[3,4]:(n.$r.add(2),[4,un(n)]);case 3:r.sent(),n.Br.set("Unknown"),r.label=4;case 4:r.label=5;case 5:return[2]}})})}function cn(e){var t=this;return e.Ur||(e.Ur=function(n,r,i){var o=_(n);return o.br(),new cp(r,o.Hi,o.credentials,o.R,i)}(e.datastore,e.asyncQueue,{Ii:dp.bind(null,e),Ri:yp.bind(null,e),_r:vp.bind(null,e)}),e.Mr.push(function(n){return g(t,void 0,void 0,function(){return m(this,function(r){switch(r.label){case 0:return n?(e.Ur.sr(),Go(e)?Ko(e):e.Br.set("Unknown"),[3,3]):[3,1];case 1:return[4,e.Ur.stop()];case 2:r.sent(),Vc(e),r.label=3;case 3:return[2]}})})})),e.Ur}function se(e){var t=this;return e.Qr||(e.Qr=function(n,r,i){var o=_(n);return o.br(),new hp(r,o.Hi,o.credentials,o.R,i)}(e.datastore,e.asyncQueue,{Ii:mp.bind(null,e),Ri:bp.bind(null,e),Ir:gp.bind(null,e),Tr:wp.bind(null,e)}),e.Mr.push(function(n){return g(t,void 0,void 0,function(){return m(this,function(r){switch(r.label){case 0:return n?(e.Qr.sr(),[4,an(e)]):[3,2];case 1:return r.sent(),[3,4];case 2:return[4,e.Qr.stop()];case 3:r.sent(),e.kr.length>0&&(I("RemoteStore","Stopping write stream with "+e.kr.length+" pending writes"),e.kr=[]),r.label=4;case 4:return[2]}})})})),e.Qr}var Ip=function(){function e(t,n,r,i,o){this.asyncQueue=t,this.timerId=n,this.targetTimeMs=r,this.op=i,this.removalCallback=o,this.deferred=new kt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(function(s){})}return e.createAndSchedule=function(t,n,r,i,o){var s=new e(t,n,Date.now()+r,i,o);return s.start(r),s},e.prototype.start=function(t){var n=this;this.timerHandle=setTimeout(function(){return n.handleDelayElapsed()},t)},e.prototype.skipDelay=function(){return this.handleDelayElapsed()},e.prototype.cancel=function(t){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new w(d.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},e.prototype.handleDelayElapsed=function(){var t=this;this.asyncQueue.enqueueAndForget(function(){return t.timerHandle!==null?(t.clearTimeout(),t.op().then(function(n){return t.deferred.resolve(n)})):Promise.resolve()})},e.prototype.clearTimeout=function(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)},e}();function hn(e,t){if(W("AsyncQueue",t+": "+e),De(e))return new w(d.UNAVAILABLE,t+": "+e);throw e}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var jc=function(){function e(t){this.comparator=t?function(n,r){return t(n,r)||N.comparator(n.key,r.key)}:function(n,r){return N.comparator(n.key,r.key)},this.keyedMap=ji(),this.sortedSet=new ht(this.comparator)}return e.emptySet=function(t){return new e(t.comparator)},e.prototype.has=function(t){return this.keyedMap.get(t)!=null},e.prototype.get=function(t){return this.keyedMap.get(t)},e.prototype.first=function(){return this.sortedSet.minKey()},e.prototype.last=function(){return this.sortedSet.maxKey()},e.prototype.isEmpty=function(){return this.sortedSet.isEmpty()},e.prototype.indexOf=function(t){var n=this.keyedMap.get(t);return n?this.sortedSet.indexOf(n):-1},Object.defineProperty(e.prototype,"size",{get:function(){return this.sortedSet.size},enumerable:!1,configurable:!0}),e.prototype.forEach=function(t){this.sortedSet.inorderTraversal(function(n,r){return t(n),!1})},e.prototype.add=function(t){var n=this.delete(t.key);return n.copy(n.keyedMap.insert(t.key,t),n.sortedSet.insert(t,null))},e.prototype.delete=function(t){var n=this.get(t);return n?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(n)):this},e.prototype.isEqual=function(t){if(!(t instanceof e)||this.size!==t.size)return!1;for(var n=this.sortedSet.getIterator(),r=t.sortedSet.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(!i.isEqual(o))return!1}return!0},e.prototype.toString=function(){var t=[];return this.forEach(function(n){t.push(n.toString())}),t.length===0?"DocumentSet ()":`DocumentSet (
`+t.join(`
`)+`
)`},e.prototype.copy=function(t,n){var r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r},e}(),hu=function(){function e(){this.Kr=new ht(N.comparator)}return e.prototype.track=function(t){var n=t.doc.key,r=this.Kr.get(n);r?t.type!==0&&r.type===3?this.Kr=this.Kr.insert(n,t):t.type===3&&r.type!==1?this.Kr=this.Kr.insert(n,{type:r.type,doc:t.doc}):t.type===2&&r.type===2?this.Kr=this.Kr.insert(n,{type:2,doc:t.doc}):t.type===2&&r.type===0?this.Kr=this.Kr.insert(n,{type:0,doc:t.doc}):t.type===1&&r.type===0?this.Kr=this.Kr.remove(n):t.type===1&&r.type===2?this.Kr=this.Kr.insert(n,{type:1,doc:r.doc}):t.type===0&&r.type===1?this.Kr=this.Kr.insert(n,{type:2,doc:t.doc}):D():this.Kr=this.Kr.insert(n,t)},e.prototype.jr=function(){var t=[];return this.Kr.inorderTraversal(function(n,r){t.push(r)}),t},e}(),xr=function(){function e(t,n,r,i,o,s,u,a){this.query=t,this.docs=n,this.oldDocs=r,this.docChanges=i,this.mutatedKeys=o,this.fromCache=s,this.syncStateChanged=u,this.excludesMetadataChanges=a}return e.fromInitialDocuments=function(t,n,r,i){var o=[];return n.forEach(function(s){o.push({type:0,doc:s})}),new e(t,n,jc.emptySet(n),o,r,i,!0,!1)},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return!this.mutatedKeys.isEmpty()},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&zn(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;var n=this.docChanges,r=t.docChanges;if(n.length!==r.length)return!1;for(var i=0;i<n.length;i++)if(n[i].type!==r[i].type||!n[i].doc.isEqual(r[i].doc))return!1;return!0},e}(),Ep=function(){this.Wr=void 0,this.listeners=[]},Tp=function(){this.queries=new sn(function(e){return $a(e)},zn),this.onlineState="Unknown",this.Gr=new Set};/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function zo(e,t){return g(this,void 0,void 0,function(){var n,r,i,o,s,u,a;return m(this,function(c){switch(c.label){case 0:if(n=_(e),r=t.query,i=!1,(o=n.queries.get(r))||(i=!0,o=new Ep),!i)return[3,4];c.label=1;case 1:return c.trys.push([1,3,,4]),s=o,[4,n.onListen(r)];case 2:return s.Wr=c.sent(),[3,4];case 3:return u=c.sent(),a=hn(u,"Initialization of query '"+qi(t.query)+"' failed"),[2,void t.onError(a)];case 4:return n.queries.set(r,o),o.listeners.push(t),t.zr(n.onlineState),o.Wr&&t.Hr(o.Wr)&&$o(n),[2]}})})}function Qo(e,t){return g(this,void 0,void 0,function(){var n,r,i,o,s;return m(this,function(u){return n=_(e),r=t.query,i=!1,(o=n.queries.get(r))&&(s=o.listeners.indexOf(t))>=0&&(o.listeners.splice(s,1),i=o.listeners.length===0),i?[2,(n.queries.delete(r),n.onUnlisten(r))]:[2]})})}function _p(e,t){for(var n=_(e),r=!1,i=0,o=t;i<o.length;i++){var s=o[i],u=s.query,a=n.queries.get(u);if(a){for(var c=0,h=a.listeners;c<h.length;c++)h[c].Hr(s)&&(r=!0);a.Wr=s}}r&&$o(n)}function Sp(e,t,n){var r=_(e),i=r.queries.get(t);if(i)for(var o=0,s=i.listeners;o<s.length;o++)s[o].onError(n);r.queries.delete(t)}function $o(e){e.Gr.forEach(function(t){t.next()})}var Ho=function(){function e(t,n,r){this.query=t,this.Jr=n,this.Yr=!1,this.Xr=null,this.onlineState="Unknown",this.options=r||{}}return e.prototype.Hr=function(t){if(!this.options.includeMetadataChanges){for(var n=[],r=0,i=t.docChanges;r<i.length;r++){var o=i[r];o.type!==3&&n.push(o)}t=new xr(t.query,t.docs,t.oldDocs,n,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0)}var s=!1;return this.Yr?this.Zr(t)&&(this.Jr.next(t),s=!0):this.eo(t,this.onlineState)&&(this.no(t),s=!0),this.Xr=t,s},e.prototype.onError=function(t){this.Jr.error(t)},e.prototype.zr=function(t){this.onlineState=t;var n=!1;return this.Xr&&!this.Yr&&this.eo(this.Xr,t)&&(this.no(this.Xr),n=!0),n},e.prototype.eo=function(t,n){if(!t.fromCache)return!0;var r=n!=="Offline";return!(this.options.so&&r||t.docs.isEmpty()&&n!=="Offline")},e.prototype.Zr=function(t){if(t.docChanges.length>0)return!0;var n=this.Xr&&this.Xr.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!n)&&this.options.includeMetadataChanges===!0},e.prototype.no=function(t){t=xr.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.Yr=!0,this.Jr.next(t)},e}();/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Kc=function(e){this.key=e},Gc=function(e){this.key=e},zc=function(){function e(t,n){this.query=t,this.uo=n,this.ao=null,this.current=!1,this.ho=B(),this.mutatedKeys=B(),this.lo=Ha(t),this.fo=new jc(this.lo)}return Object.defineProperty(e.prototype,"wo",{get:function(){return this.uo},enumerable:!1,configurable:!0}),e.prototype._o=function(t,n){var r=this,i=n?n.mo:new hu,o=n?n.fo:this.fo,s=n?n.mutatedKeys:this.mutatedKeys,u=o,a=!1,c=sr(this.query)&&o.size===this.query.limit?o.last():null,h=_r(this.query)&&o.size===this.query.limit?o.first():null;if(t.inorderTraversal(function(f,y){var p=o.get(f),v=Qn(r.query,y)?y:null,E=!!p&&r.mutatedKeys.has(p.key),T=!!v&&(v.hasLocalMutations||r.mutatedKeys.has(v.key)&&v.hasCommittedMutations),k=!1;p&&v?p.data.isEqual(v.data)?E!==T&&(i.track({type:3,doc:v}),k=!0):r.yo(p,v)||(i.track({type:2,doc:v}),k=!0,(c&&r.lo(v,c)>0||h&&r.lo(v,h)<0)&&(a=!0)):!p&&v?(i.track({type:0,doc:v}),k=!0):p&&!v&&(i.track({type:1,doc:p}),k=!0,(c||h)&&(a=!0)),k&&(v?(u=u.add(v),s=T?s.add(f):s.delete(f)):(u=u.delete(f),s=s.delete(f)))}),sr(this.query)||_r(this.query))for(;u.size>this.query.limit;){var l=sr(this.query)?u.last():u.first();u=u.delete(l.key),s=s.delete(l.key),i.track({type:1,doc:l})}return{fo:u,mo:i,Nn:a,mutatedKeys:s}},e.prototype.yo=function(t,n){return t.hasLocalMutations&&n.hasCommittedMutations&&!n.hasLocalMutations},e.prototype.applyChanges=function(t,n,r){var i=this,o=this.fo;this.fo=t.fo,this.mutatedKeys=t.mutatedKeys;var s=t.mo.jr();s.sort(function(h,l){return function(f,y){var p=function(v){switch(v){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return D()}};return p(f)-p(y)}(h.type,l.type)||i.lo(h.doc,l.doc)}),this.po(r);var u=n?this.Eo():[],a=this.ho.size===0&&this.current?1:0,c=a!==this.ao;return this.ao=a,s.length!==0||c?{snapshot:new xr(this.query,t.fo,o,s,t.mutatedKeys,a===0,c,!1),To:u}:{To:u}},e.prototype.zr=function(t){return this.current&&t==="Offline"?(this.current=!1,this.applyChanges({fo:this.fo,mo:new hu,mutatedKeys:this.mutatedKeys,Nn:!1},!1)):{To:[]}},e.prototype.Io=function(t){return!this.uo.has(t)&&!!this.fo.has(t)&&!this.fo.get(t).hasLocalMutations},e.prototype.po=function(t){var n=this;t&&(t.addedDocuments.forEach(function(r){return n.uo=n.uo.add(r)}),t.modifiedDocuments.forEach(function(r){}),t.removedDocuments.forEach(function(r){return n.uo=n.uo.delete(r)}),this.current=t.current)},e.prototype.Eo=function(){var t=this;if(!this.current)return[];var n=this.ho;this.ho=B(),this.fo.forEach(function(i){t.Io(i.key)&&(t.ho=t.ho.add(i.key))});var r=[];return n.forEach(function(i){t.ho.has(i)||r.push(new Gc(i))}),this.ho.forEach(function(i){n.has(i)||r.push(new Kc(i))}),r},e.prototype.Ao=function(t){this.uo=t.Bn,this.ho=B();var n=this._o(t.documents);return this.applyChanges(n,!0)},e.prototype.Ro=function(){return xr.fromInitialDocuments(this.query,this.fo,this.mutatedKeys,this.ao===0)},e}(),Dp=function(e,t,n){this.query=e,this.targetId=t,this.view=n},Np=function(e){this.key=e,this.bo=!1},Ap=function(){function e(t,n,r,i,o,s){this.localStore=t,this.remoteStore=n,this.eventManager=r,this.sharedClientState=i,this.currentUser=o,this.maxConcurrentLimboResolutions=s,this.vo={},this.Po=new sn(function(u){return $a(u)},zn),this.Vo=new Map,this.So=new Set,this.Do=new ht(N.comparator),this.Co=new Map,this.No=new qo,this.xo={},this.Fo=new Map,this.ko=Nr.Yt(),this.onlineState="Unknown",this.Oo=void 0}return Object.defineProperty(e.prototype,"isPrimaryClient",{get:function(){return this.Oo===!0},enumerable:!1,configurable:!0}),e}();function Cp(e,t){return g(this,void 0,void 0,function(){var n,r,i,o,s,u;return m(this,function(a){switch(a.label){case 0:return n=Zo(e),(o=n.Po.get(t))?(r=o.targetId,n.sharedClientState.addLocalQueryTarget(r),i=o.view.Ro(),[3,4]):[3,1];case 1:return[4,Ar(n.localStore,Ut(t))];case 2:return s=a.sent(),u=n.sharedClientState.addLocalQueryTarget(s.targetId),r=s.targetId,[4,Wo(n,t,r,u==="current")];case 3:i=a.sent(),n.isPrimaryClient&&Jr(n.remoteStore,s),a.label=4;case 4:return[2,i]}})})}function Wo(e,t,n,r){return g(this,void 0,void 0,function(){var i,o,s,u,a,c;return m(this,function(h){switch(h.label){case 0:return e.$o=function(l,f,y){return function(p,v,E,T){return g(this,void 0,void 0,function(){var k,A,O;return m(this,function(M){switch(M.label){case 0:return k=v.view._o(E),k.Nn?[4,Cr(p.localStore,v.query,!1).then(function(q){var et=q.documents;return v.view._o(et,k)})]:[3,2];case 1:k=M.sent(),M.label=2;case 2:return A=T&&T.targetChanges.get(v.targetId),O=v.view.applyChanges(k,p.isPrimaryClient,A),[2,($i(p,v.targetId,O.To),O.snapshot)]}})})}(e,l,f,y)},[4,Cr(e.localStore,t,!0)];case 1:return i=h.sent(),o=new zc(t,i.Bn),s=o._o(i.documents),u=Oo.createSynthesizedTargetChangeForCurrentChange(n,r&&e.onlineState!=="Offline"),a=o.applyChanges(s,e.isPrimaryClient,u),$i(e,n,a.To),c=new Dp(t,n,o),[2,(e.Po.set(t,c),e.Vo.has(n)?e.Vo.get(n).push(t):e.Vo.set(n,[t]),a.snapshot)]}})})}function kp(e,t){return g(this,void 0,void 0,function(){var n,r,i;return m(this,function(o){switch(o.label){case 0:return n=_(e),r=n.Po.get(t),(i=n.Vo.get(r.targetId)).length>1?[2,(n.Vo.set(r.targetId,i.filter(function(s){return!zn(s,t)})),void n.Po.delete(t))]:n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)?[3,2]:[4,Je(n.localStore,r.targetId,!1).then(function(){n.sharedClientState.clearQueryState(r.targetId),Cn(n.remoteStore,r.targetId),Ze(n,r.targetId)}).catch(Ne)]):[3,3];case 1:o.sent(),o.label=2;case 2:return[3,5];case 3:return Ze(n,r.targetId),[4,Je(n.localStore,r.targetId,!0)];case 4:o.sent(),o.label=5;case 5:return[2]}})})}function xp(e,t,n){return g(this,void 0,void 0,function(){var r,i,o,s;return m(this,function(u){switch(u.label){case 0:r=ts(e),u.label=1;case 1:return u.trys.push([1,5,,6]),[4,function(a,c){var h,l=_(a),f=gt.now(),y=c.reduce(function(p,v){return p.add(v.key)},B());return l.persistence.runTransaction("Locally write mutations","readwrite",function(p){return l.Mn.pn(p,y).next(function(v){h=v;for(var E=[],T=0,k=c;T<k.length;T++){var A=k[T],O=nf(A,h.get(A.key));O!=null&&E.push(new ce(A.key,O,Ka(O.toProto().mapValue),st.exists(!0)))}return l._n.addMutationBatch(p,f,E,c)})}).then(function(p){return p.applyToLocalDocumentSet(h),{batchId:p.batchId,changes:h}})}(r.localStore,t)];case 2:return i=u.sent(),r.sharedClientState.addPendingMutation(i.batchId),function(a,c,h){var l=a.xo[a.currentUser.toKey()];l||(l=new ht(L)),l=l.insert(c,h),a.xo[a.currentUser.toKey()]=l}(r,i.batchId,n),[4,le(r,i.changes)];case 3:return u.sent(),[4,an(r.remoteStore)];case 4:return u.sent(),[3,6];case 5:return o=u.sent(),s=hn(o,"Failed to persist write"),n.reject(s),[3,6];case 6:return[2]}})})}function Qc(e,t){return g(this,void 0,void 0,function(){var n,r;return m(this,function(i){switch(i.label){case 0:n=_(e),i.label=1;case 1:return i.trys.push([1,4,,6]),[4,Qf(n.localStore,t)];case 2:return r=i.sent(),t.targetChanges.forEach(function(o,s){var u=n.Co.get(s);u&&(x(o.addedDocuments.size+o.modifiedDocuments.size+o.removedDocuments.size<=1),o.addedDocuments.size>0?u.bo=!0:o.modifiedDocuments.size>0?x(u.bo):o.removedDocuments.size>0&&(x(u.bo),u.bo=!1))}),[4,le(n,r,t)];case 3:return i.sent(),[3,6];case 4:return[4,Ne(i.sent())];case 5:return i.sent(),[3,6];case 6:return[2]}})})}function lu(e,t,n){var r=_(e);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){var i=[];r.Po.forEach(function(o,s){var u=s.view.zr(t);u.snapshot&&i.push(u.snapshot)}),function(o,s){var u=_(o);u.onlineState=s;var a=!1;u.queries.forEach(function(c,h){for(var l=0,f=h.listeners;l<f.length;l++)f[l].zr(s)&&(a=!0)}),a&&$o(u)}(r.eventManager,t),i.length&&r.vo._r(i),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}function Rp(e,t,n){return g(this,void 0,void 0,function(){var r,i,o,s,u,a;return m(this,function(c){switch(c.label){case 0:return(r=_(e)).sharedClientState.updateQueryState(t,"rejected",n),i=r.Co.get(t),(o=i&&i.key)?(s=(s=new ht(N.comparator)).insert(o,ct.newNoDocument(o,P.min())),u=B().add(o),a=new Ro(P.min(),new Map,new J(L),s,u),[4,Qc(r,a)]):[3,2];case 1:return c.sent(),r.Do=r.Do.remove(o),r.Co.delete(t),Jo(r),[3,4];case 2:return[4,Je(r.localStore,t,!1).then(function(){return Ze(r,t,n)}).catch(Ne)];case 3:c.sent(),c.label=4;case 4:return[2]}})})}function Op(e,t){return g(this,void 0,void 0,function(){var n,r,i;return m(this,function(o){switch(o.label){case 0:n=_(e),r=t.batch.batchId,o.label=1;case 1:return o.trys.push([1,4,,6]),[4,zf(n.localStore,t)];case 2:return i=o.sent(),Yo(n,r,null),Xo(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),[4,le(n,i)];case 3:return o.sent(),[3,6];case 4:return[4,Ne(o.sent())];case 5:return o.sent(),[3,6];case 6:return[2]}})})}function Pp(e,t,n){return g(this,void 0,void 0,function(){var r,i;return m(this,function(o){switch(o.label){case 0:r=_(e),o.label=1;case 1:return o.trys.push([1,4,,6]),[4,function(s,u){var a=_(s);return a.persistence.runTransaction("Reject batch","readwrite-primary",function(c){var h;return a._n.lookupMutationBatch(c,u).next(function(l){return x(l!==null),h=l.keys(),a._n.removeMutationBatch(c,l)}).next(function(){return a._n.performConsistencyCheck(c)}).next(function(){return a.Mn.pn(c,h)})})}(r.localStore,t)];case 2:return i=o.sent(),Yo(r,t,n),Xo(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),[4,le(r,i)];case 3:return o.sent(),[3,6];case 4:return[4,Ne(o.sent())];case 5:return o.sent(),[3,6];case 6:return[2]}})})}function Lp(e,t){return g(this,void 0,void 0,function(){var n,r,i,o,s;return m(this,function(u){switch(u.label){case 0:he((n=_(e)).remoteStore)||I("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,function(a){var c=_(a);return c.persistence.runTransaction("Get highest unacknowledged batch id","readonly",function(h){return c._n.getHighestUnacknowledgedBatchId(h)})}(n.localStore)];case 2:return(r=u.sent())===-1?[2,void t.resolve()]:((i=n.Fo.get(r)||[]).push(t),n.Fo.set(r,i),[3,4]);case 3:return o=u.sent(),s=hn(o,"Initialization of waitForPendingWrites() operation failed"),t.reject(s),[3,4];case 4:return[2]}})})}function Xo(e,t){(e.Fo.get(t)||[]).forEach(function(n){n.resolve()}),e.Fo.delete(t)}function Yo(e,t,n){var r=_(e),i=r.xo[r.currentUser.toKey()];if(i){var o=i.get(t);o&&(n?o.reject(n):o.resolve(),i=i.remove(t)),r.xo[r.currentUser.toKey()]=i}}function Ze(e,t,n){n===void 0&&(n=null),e.sharedClientState.removeLocalQueryTarget(t);for(var r=0,i=e.Vo.get(t);r<i.length;r++){var o=i[r];e.Po.delete(o),n&&e.vo.Mo(o,n)}e.Vo.delete(t),e.isPrimaryClient&&e.No.Zn(t).forEach(function(s){e.No.containsKey(s)||$c(e,s)})}function $c(e,t){e.So.delete(t.path.canonicalString());var n=e.Do.get(t);n!==null&&(Cn(e.remoteStore,n),e.Do=e.Do.remove(t),e.Co.delete(n),Jo(e))}function $i(e,t,n){for(var r=0,i=n;r<i.length;r++){var o=i[r];o instanceof Kc?(e.No.addReference(o.key,t),Mp(e,o)):o instanceof Gc?(I("SyncEngine","Document no longer in limbo: "+o.key),e.No.removeReference(o.key,t),e.No.containsKey(o.key)||$c(e,o.key)):D()}}function Mp(e,t){var n=t.key,r=n.path.canonicalString();e.Do.get(n)||e.So.has(r)||(I("SyncEngine","New document in limbo: "+n),e.So.add(r),Jo(e))}function Jo(e){for(;e.So.size>0&&e.Do.size<e.maxConcurrentLimboResolutions;){var t=e.So.values().next().value;e.So.delete(t);var n=new N(V.fromString(t)),r=e.ko.next();e.Co.set(r,new Np(n)),e.Do=e.Do.insert(n,r),Jr(e.remoteStore,new Xr(Ut(Gn(n.path)),r,2,St.o))}}function le(e,t,n){return g(this,void 0,void 0,function(){var r,i,o,s;return m(this,function(u){switch(u.label){case 0:return r=_(e),i=[],o=[],s=[],r.Po.isEmpty()?[3,3]:(r.Po.forEach(function(a,c){s.push(r.$o(c,t,n).then(function(h){if(h){r.isPrimaryClient&&r.sharedClientState.updateQueryState(c.targetId,h.fromCache?"not-current":"current"),i.push(h);var l=Kf.Pn(c.targetId,h);o.push(l)}}))}),[4,Promise.all(s)]);case 1:return u.sent(),r.vo._r(i),[4,function(a,c){return g(this,void 0,void 0,function(){var h,l,f,y,p,v,E,T,k;return m(this,function(A){switch(A.label){case 0:h=_(a),A.label=1;case 1:return A.trys.push([1,3,,4]),[4,h.persistence.runTransaction("notifyLocalViewChanges","readwrite",function(O){return b.forEach(c,function(M){return b.forEach(M.bn,function(q){return h.persistence.referenceDelegate.addReference(O,M.targetId,q)}).next(function(){return b.forEach(M.vn,function(q){return h.persistence.referenceDelegate.removeReference(O,M.targetId,q)})})})})];case 2:return A.sent(),[3,4];case 3:if(!De(l=A.sent()))throw l;return I("LocalStore","Failed to update sequence numbers: "+l),[3,4];case 4:for(f=0,y=c;f<y.length;f++)p=y[f],v=p.targetId,p.fromCache||(E=h.Fn.get(v),T=E.snapshotVersion,k=E.withLastLimboFreeSnapshotVersion(T),h.Fn=h.Fn.insert(v,k));return[2]}})})}(r.localStore,o)];case 2:u.sent(),u.label=3;case 3:return[2]}})})}function Fp(e,t){return g(this,void 0,void 0,function(){var n,r;return m(this,function(i){switch(i.label){case 0:return(n=_(e)).currentUser.isEqual(t)?[3,3]:(I("SyncEngine","User change. New user:",t.toKey()),[4,kc(n.localStore,t)]);case 1:return r=i.sent(),n.currentUser=t,function(o,s){o.Fo.forEach(function(u){u.forEach(function(a){a.reject(new w(d.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),o.Fo.clear()}(n),n.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),[4,le(n,r.Ln)];case 2:i.sent(),i.label=3;case 3:return[2]}})})}function Vp(e,t){var n=_(e),r=n.Co.get(t);if(r&&r.bo)return B().add(r.key);var i=B(),o=n.Vo.get(t);if(!o)return i;for(var s=0,u=o;s<u.length;s++){var a=u[s],c=n.Po.get(a);i=i.unionWith(c.view.wo)}return i}function Up(e,t){return g(this,void 0,void 0,function(){var n,r,i;return m(this,function(o){switch(o.label){case 0:return[4,Cr((n=_(e)).localStore,t.query,!0)];case 1:return r=o.sent(),i=t.view.Ao(r),[2,(n.isPrimaryClient&&$i(n,t.targetId,i.To),i)]}})})}function qp(e){return g(this,void 0,void 0,function(){var t;return m(this,function(n){return[2,Oc((t=_(e)).localStore).then(function(r){return le(t,r)})]})})}function Bp(e,t,n,r){return g(this,void 0,void 0,function(){var i,o;return m(this,function(s){switch(s.label){case 0:return[4,function(u,a){var c=_(u),h=_(c._n);return c.persistence.runTransaction("Lookup mutation documents","readonly",function(l){return h.jt(l,a).next(function(f){return f?c.Mn.pn(l,f):b.resolve(null)})})}((i=_(e)).localStore,t)];case 1:return(o=s.sent())===null?[3,6]:n!=="pending"?[3,3]:[4,an(i.remoteStore)];case 2:return s.sent(),[3,4];case 3:n==="acknowledged"||n==="rejected"?(Yo(i,t,r||null),Xo(i,t),function(u,a){_(_(u)._n).Gt(a)}(i.localStore,t)):D(),s.label=4;case 4:return[4,le(i,o)];case 5:return s.sent(),[3,7];case 6:I("SyncEngine","Cannot apply mutation batch with id: "+t),s.label=7;case 7:return[2]}})})}function jp(e,t){return g(this,void 0,void 0,function(){var n,r,i,o,s,u,a,c;return m(this,function(h){switch(h.label){case 0:return Zo(n=_(e)),ts(n),t!==!0||n.Oo===!0?[3,3]:(r=n.sharedClientState.getAllActiveQueryTargets(),[4,fu(n,r.toArray())]);case 1:return i=h.sent(),n.Oo=!0,[4,Qi(n.remoteStore,!0)];case 2:for(h.sent(),o=0,s=i;o<s.length;o++)u=s[o],Jr(n.remoteStore,u);return[3,7];case 3:return t!==!1||n.Oo===!1?[3,7]:(a=[],c=Promise.resolve(),n.Vo.forEach(function(l,f){n.sharedClientState.isLocalQueryTarget(f)?a.push(f):c=c.then(function(){return Ze(n,f),Je(n.localStore,f,!0)}),Cn(n.remoteStore,f)}),[4,c]);case 4:return h.sent(),[4,fu(n,a)];case 5:return h.sent(),function(l){var f=_(l);f.Co.forEach(function(y,p){Cn(f.remoteStore,p)}),f.No.ts(),f.Co=new Map,f.Do=new ht(N.comparator)}(n),n.Oo=!1,[4,Qi(n.remoteStore,!1)];case 6:h.sent(),h.label=7;case 7:return[2]}})})}function fu(e,t,n){return g(this,void 0,void 0,function(){var r,i,o,s,u,a,c,h,l,f,y,p,v,E;return m(this,function(T){switch(T.label){case 0:r=_(e),i=[],o=[],s=0,u=t,T.label=1;case 1:return s<u.length?(a=u[s],c=void 0,(h=r.Vo.get(a))&&h.length!==0?[4,Ar(r.localStore,Ut(h[0]))]:[3,7]):[3,13];case 2:c=T.sent(),l=0,f=h,T.label=3;case 3:return l<f.length?(y=f[l],p=r.Po.get(y),[4,Up(r,p)]):[3,6];case 4:(v=T.sent()).snapshot&&o.push(v.snapshot),T.label=5;case 5:return l++,[3,3];case 6:return[3,11];case 7:return[4,Rc(r.localStore,a)];case 8:return E=T.sent(),[4,Ar(r.localStore,E)];case 9:return c=T.sent(),[4,Wo(r,Hc(E),a,!1)];case 10:T.sent(),T.label=11;case 11:i.push(c),T.label=12;case 12:return s++,[3,1];case 13:return[2,(r.vo._r(o),i)]}})})}function Hc(e){return za(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function Kp(e){var t=_(e);return _(_(t.localStore).persistence).fn()}function Gp(e,t,n,r){return g(this,void 0,void 0,function(){var i,o,s;return m(this,function(u){switch(u.label){case 0:return(i=_(e)).Oo?(I("SyncEngine","Ignoring unexpected query state notification."),[3,8]):[3,1];case 1:if(!i.Vo.has(t))return[3,8];switch(n){case"current":case"not-current":return[3,2];case"rejected":return[3,5]}return[3,7];case 2:return[4,Oc(i.localStore)];case 3:return o=u.sent(),s=Ro.createSynthesizedRemoteEventForCurrentChange(t,n==="current"),[4,le(i,o,s)];case 4:return u.sent(),[3,8];case 5:return[4,Je(i.localStore,t,!0)];case 6:return u.sent(),Ze(i,t,r),[3,8];case 7:D(),u.label=8;case 8:return[2]}})})}function zp(e,t,n){return g(this,void 0,void 0,function(){var r,i,o,s,u,a,c,h,l,f;return m(this,function(y){switch(y.label){case 0:if(!(r=Zo(e)).Oo)return[3,10];i=0,o=t,y.label=1;case 1:return i<o.length?(s=o[i],r.Vo.has(s)?(I("SyncEngine","Adding an already active target "+s),[3,5]):[4,Rc(r.localStore,s)]):[3,6];case 2:return u=y.sent(),[4,Ar(r.localStore,u)];case 3:return a=y.sent(),[4,Wo(r,Hc(u),a.targetId,!1)];case 4:y.sent(),Jr(r.remoteStore,a),y.label=5;case 5:return i++,[3,1];case 6:c=function(p){return m(this,function(v){switch(v.label){case 0:return r.Vo.has(p)?[4,Je(r.localStore,p,!1).then(function(){Cn(r.remoteStore,p),Ze(r,p)}).catch(Ne)]:[3,2];case 1:v.sent(),v.label=2;case 2:return[2]}})},h=0,l=n,y.label=7;case 7:return h<l.length?(f=l[h],[5,c(f)]):[3,10];case 8:y.sent(),y.label=9;case 9:return h++,[3,7];case 10:return[2]}})})}function Zo(e){var t=_(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=Qc.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=Vp.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Rp.bind(null,t),t.vo._r=_p.bind(null,t.eventManager),t.vo.Mo=Sp.bind(null,t.eventManager),t}function ts(e){var t=_(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=Op.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Pp.bind(null,t),t}var Wc=function(){function e(){this.synchronizeTabs=!1}return e.prototype.initialize=function(t){return g(this,void 0,void 0,function(){return m(this,function(n){switch(n.label){case 0:return this.R=Yr(t.databaseInfo.databaseId),this.sharedClientState=this.Bo(t),this.persistence=this.qo(t),[4,this.persistence.start()];case 1:return n.sent(),this.gcScheduler=this.Uo(t),this.localStore=this.Qo(t),[2]}})})},e.prototype.Uo=function(t){return null},e.prototype.Qo=function(t){return Cc(this.persistence,new Ac,t.initialUser,this.R)},e.prototype.qo=function(t){return new ep(rp.bs,this.R)},e.prototype.Bo=function(t){return new Pc},e.prototype.terminate=function(){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return this.gcScheduler&&this.gcScheduler.stop(),[4,this.sharedClientState.shutdown()];case 1:return t.sent(),[4,this.persistence.shutdown()];case 2:return t.sent(),[2]}})})},e}(),Xc=function(e){function t(n,r,i){var o=this;return(o=e.call(this)||this).Ko=n,o.cacheSizeBytes=r,o.forceOwnership=i,o.synchronizeTabs=!1,o}return C(t,e),t.prototype.initialize=function(n){return g(this,void 0,void 0,function(){return m(this,function(r){switch(r.label){case 0:return[4,e.prototype.initialize.call(this,n)];case 1:return r.sent(),[4,Wf(this.localStore)];case 2:return r.sent(),[4,this.Ko.initialize(this,n)];case 3:return r.sent(),[4,ts(this.Ko.syncEngine)];case 4:return r.sent(),[4,an(this.Ko.remoteStore)];case 5:return r.sent(),[2]}})})},t.prototype.Qo=function(n){return Cc(this.persistence,new Ac,n.initialUser,this.R)},t.prototype.Uo=function(n){var r=this.persistence.referenceDelegate.garbageCollector;return new Mf(r,n.asyncQueue)},t.prototype.qo=function(n){var r=Uo(n.databaseInfo.databaseId,n.databaseInfo.persistenceKey),i=this.cacheSizeBytes!==void 0?Lt.withCacheSize(this.cacheSizeBytes):Lt.DEFAULT;return new jf(this.synchronizeTabs,r,n.clientId,i,n.asyncQueue,Lc(),cr(),this.R,this.sharedClientState,!!this.forceOwnership)},t.prototype.Bo=function(n){return new Pc},t}(Wc),Qp=function(e){function t(n,r){var i=this;return(i=e.call(this,n,r,!1)||this).Ko=n,i.cacheSizeBytes=r,i.synchronizeTabs=!0,i}return C(t,e),t.prototype.initialize=function(n){return g(this,void 0,void 0,function(){var r,i=this;return m(this,function(o){switch(o.label){case 0:return[4,e.prototype.initialize.call(this,n)];case 1:return o.sent(),r=this.Ko.syncEngine,this.sharedClientState instanceof Ii?(this.sharedClientState.syncEngine={ui:Bp.bind(null,r),ai:Gp.bind(null,r),hi:zp.bind(null,r),fn:Kp.bind(null,r),ci:qp.bind(null,r)},[4,this.sharedClientState.start()]):[3,3];case 2:o.sent(),o.label=3;case 3:return[4,this.persistence.He(function(s){return g(i,void 0,void 0,function(){return m(this,function(u){switch(u.label){case 0:return[4,jp(this.Ko.syncEngine,s)];case 1:return u.sent(),this.gcScheduler&&(s&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):s||this.gcScheduler.stop()),[2]}})})})];case 4:return o.sent(),[2]}})})},t.prototype.Bo=function(n){var r=Lc();if(!Ii.yt(r))throw new w(d.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var i=Uo(n.databaseInfo.databaseId,n.databaseInfo.persistenceKey);return new Ii(r,n.asyncQueue,i,n.clientId,n.initialUser)},t}(Xc),Hi=function(){function e(){}return e.prototype.initialize=function(t,n){return g(this,void 0,void 0,function(){var r=this;return m(this,function(i){switch(i.label){case 0:return this.localStore?[3,2]:(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(n),this.remoteStore=this.createRemoteStore(n),this.eventManager=this.createEventManager(n),this.syncEngine=this.createSyncEngine(n,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=function(o){return lu(r.syncEngine,o,1)},this.remoteStore.remoteSyncer.handleCredentialChange=Fp.bind(null,this.syncEngine),[4,Qi(this.remoteStore,this.syncEngine.isPrimaryClient)]);case 1:i.sent(),i.label=2;case 2:return[2]}})})},e.prototype.createEventManager=function(t){return new Tp},e.prototype.createDatastore=function(t){var n,r=Yr(t.databaseInfo.databaseId),i=(n=t.databaseInfo,new ap(n));return function(o,s,u){return new lp(o,s,u)}(t.credentials,i,r)},e.prototype.createRemoteStore=function(t){var n,r,i,o,s,u=this;return n=this.localStore,r=this.datastore,i=t.asyncQueue,o=function(a){return lu(u.syncEngine,a,0)},s=cu.yt()?new cu:new op,new pp(n,r,i,o,s)},e.prototype.createSyncEngine=function(t,n){return function(r,i,o,s,u,a,c){var h=new Ap(r,i,o,s,u,a);return c&&(h.Oo=!0),h}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,n)},e.prototype.terminate=function(){return function(t){return g(this,void 0,void 0,function(){var n;return m(this,function(r){switch(r.label){case 0:return n=_(t),I("RemoteStore","RemoteStore shutting down."),n.$r.add(5),[4,un(n)];case 1:return r.sent(),n.Lr.shutdown(),n.Br.set("Unknown"),[2]}})})}(this.remoteStore)},e}();/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*//**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Zr=function(){function e(t){this.observer=t,this.muted=!1}return e.prototype.next=function(t){this.observer.next&&this.jo(this.observer.next,t)},e.prototype.error=function(t){this.observer.error?this.jo(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)},e.prototype.Wo=function(){this.muted=!0},e.prototype.jo=function(t,n){var r=this;this.muted||setTimeout(function(){r.muted||t(n)},0)},e}(),$p=function(){function e(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}return e.prototype.lookup=function(t){return g(this,void 0,void 0,function(){var n,r=this;return m(this,function(i){switch(i.label){case 0:if(this.ensureCommitNotCalled(),this.mutations.length>0)throw new w(d.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,function(o,s){return g(this,void 0,void 0,function(){var u,a,c,h,l,f;return m(this,function(y){switch(y.label){case 0:return u=_(o),a=An(u.R)+"/documents",c={documents:s.map(function(p){return Nn(u.R,p)})},[4,u.Oi("BatchGetDocuments",a,c)];case 1:return h=y.sent(),l=new Map,h.forEach(function(p){var v=function(E,T){return"found"in T?function(k,A){x(!!A.found),A.found.name,A.found.updateTime;var O=jt(k,A.found.name),M=yt(A.found.updateTime),q=new _t({mapValue:{fields:A.found.fields}});return ct.newFoundDocument(O,M,q)}(E,T):"missing"in T?function(k,A){x(!!A.missing),x(!!A.readTime);var O=jt(k,A.missing),M=yt(A.readTime);return ct.newNoDocument(O,M)}(E,T):D()}(u.R,p);l.set(v.key.toString(),v)}),f=[],[2,(s.forEach(function(p){var v=l.get(p.toString());x(!!v),f.push(v)}),f)]}})})}(this.datastore,t)];case 1:return[2,((n=i.sent()).forEach(function(o){return r.recordVersion(o)}),n)]}})})},e.prototype.set=function(t,n){this.write(n.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())},e.prototype.update=function(t,n){try{this.write(n.toMutation(t,this.preconditionForUpdate(t)))}catch(r){this.lastWriteError=r}this.writtenDocs.add(t.toString())},e.prototype.delete=function(t){this.write(new Wn(t,this.precondition(t))),this.writtenDocs.add(t.toString())},e.prototype.commit=function(){return g(this,void 0,void 0,function(){var t,n=this;return m(this,function(r){switch(r.label){case 0:if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;return t=this.readVersions,this.mutations.forEach(function(i){t.delete(i.key.toString())}),t.forEach(function(i,o){var s=N.fromPath(o);n.mutations.push(new xo(s,n.precondition(s)))}),[4,function(i,o){return g(this,void 0,void 0,function(){var s,u,a;return m(this,function(c){switch(c.label){case 0:return s=_(i),u=An(s.R)+"/documents",a={writes:o.map(function(h){return Sr(s.R,h)})},[4,s.Ni("Commit",u,a)];case 1:return c.sent(),[2]}})})}(this.datastore,this.mutations)];case 1:return r.sent(),this.committed=!0,[2]}})})},e.prototype.recordVersion=function(t){var n;if(t.isFoundDocument())n=t.version;else{if(!t.isNoDocument())throw D();n=P.min()}var r=this.readVersions.get(t.key.toString());if(r){if(!n.isEqual(r))throw new w(d.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),n)},e.prototype.precondition=function(t){var n=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&n?st.updateTime(n):st.none()},e.prototype.preconditionForUpdate=function(t){var n=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&n){if(n.isEqual(P.min()))throw new w(d.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return st.updateTime(n)}return st.exists(!0)},e.prototype.write=function(t){this.ensureCommitNotCalled(),this.mutations.push(t)},e.prototype.ensureCommitNotCalled=function(){},e}(),Hp=function(){function e(t,n,r,i){this.asyncQueue=t,this.datastore=n,this.updateFunction=r,this.deferred=i,this.ec=5,this.Zi=new Bo(this.asyncQueue,"transaction_retry")}return e.prototype.run=function(){this.nc()},e.prototype.nc=function(){var t=this;this.Zi.ji(function(){return g(t,void 0,void 0,function(){var n,r,i=this;return m(this,function(o){return n=new $p(this.datastore),(r=this.sc(n))&&r.then(function(s){i.asyncQueue.enqueueAndForget(function(){return n.commit().then(function(){i.deferred.resolve(s)}).catch(function(u){i.ic(u)})})}).catch(function(s){i.ic(s)}),[2]})})})},e.prototype.sc=function(t){try{var n=this.updateFunction(t);return!Se(n)&&n.catch&&n.then?n:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(r){return this.deferred.reject(r),null}},e.prototype.ic=function(t){var n=this;this.ec>0&&this.rc(t)?(this.ec-=1,this.asyncQueue.enqueueAndForget(function(){return n.nc(),Promise.resolve()})):this.deferred.reject(t)},e.prototype.rc=function(t){if(t.name==="FirebaseError"){var n=t.code;return n==="aborted"||n==="failed-precondition"||!rc(n)}return!1},e}(),Wp=function(){function e(t,n,r){var i=this;this.credentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=Tt.UNAUTHENTICATED,this.clientId=Fa.u(),this.credentialListener=function(){},this.receivedInitialUser=new kt,this.credentials.setChangeListener(function(o){I("FirestoreClient","Received user=",o.uid),i.user=o,i.credentialListener(o),i.receivedInitialUser.resolve()})}return e.prototype.getConfiguration=function(){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return[4,this.receivedInitialUser.promise];case 1:return[2,(t.sent(),{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,credentials:this.credentials,initialUser:this.user,maxConcurrentLimboResolutions:100})]}})})},e.prototype.setCredentialChangeListener=function(t){var n=this;this.credentialListener=t,this.receivedInitialUser.promise.then(function(){return n.credentialListener(n.user)})},e.prototype.verifyNotTerminated=function(){if(this.asyncQueue.isShuttingDown)throw new w(d.FAILED_PRECONDITION,"The client has already been terminated.")},e.prototype.terminate=function(){var t=this;this.asyncQueue.enterRestrictedMode();var n=new kt;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(function(){return g(t,void 0,void 0,function(){var r,i;return m(this,function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),this.onlineComponents?[4,this.onlineComponents.terminate()]:[3,2];case 1:o.sent(),o.label=2;case 2:return this.offlineComponents?[4,this.offlineComponents.terminate()]:[3,4];case 3:o.sent(),o.label=4;case 4:return this.credentials.removeChangeListener(),n.resolve(),[3,6];case 5:return r=o.sent(),i=hn(r,"Failed to shutdown persistence"),n.reject(i),[3,6];case 6:return[2]}})})}),n.promise},e}();/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Yc(e,t){return g(this,void 0,void 0,function(){var n,r,i=this;return m(this,function(o){switch(o.label){case 0:return e.asyncQueue.verifyOperationInProgress(),I("FirestoreClient","Initializing OfflineComponentProvider"),[4,e.getConfiguration()];case 1:return n=o.sent(),[4,t.initialize(n)];case 2:return o.sent(),r=n.initialUser,e.setCredentialChangeListener(function(s){r.isEqual(s)||(r=s,e.asyncQueue.enqueueRetryable(function(){return g(i,void 0,void 0,function(){return m(this,function(u){switch(u.label){case 0:return[4,kc(t.localStore,s)];case 1:return u.sent(),[2]}})})}))}),t.persistence.setDatabaseDeletedListener(function(){return e.terminate()}),e.offlineComponents=t,[2]}})})}function Jc(e,t){return g(this,void 0,void 0,function(){var n,r;return m(this,function(i){switch(i.label){case 0:return e.asyncQueue.verifyOperationInProgress(),[4,es(e)];case 1:return n=i.sent(),I("FirestoreClient","Initializing OnlineComponentProvider"),[4,e.getConfiguration()];case 2:return r=i.sent(),[4,t.initialize(n,r)];case 3:return i.sent(),e.setCredentialChangeListener(function(o){return e.asyncQueue.enqueueRetryable(function(){return function(s,u){return g(this,void 0,void 0,function(){var a,c;return m(this,function(h){switch(h.label){case 0:return(a=_(s)).asyncQueue.verifyOperationInProgress(),I("RemoteStore","RemoteStore received new credentials"),c=he(a),a.$r.add(3),[4,un(a)];case 1:return h.sent(),c&&a.Br.set("Unknown"),[4,a.remoteSyncer.handleCredentialChange(u)];case 2:return h.sent(),a.$r.delete(3),[4,Xn(a)];case 3:return h.sent(),[2]}})})}(t.remoteStore,o)})}),e.onlineComponents=t,[2]}})})}function es(e){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return e.offlineComponents?[3,2]:(I("FirestoreClient","Using default OfflineComponentProvider"),[4,Yc(e,new Wc)]);case 1:t.sent(),t.label=2;case 2:return[2,e.offlineComponents]}})})}function ti(e){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return e.onlineComponents?[3,2]:(I("FirestoreClient","Using default OnlineComponentProvider"),[4,Jc(e,new Hi)]);case 1:t.sent(),t.label=2;case 2:return[2,e.onlineComponents]}})})}function pu(e){return es(e).then(function(t){return t.persistence})}function Zc(e){return es(e).then(function(t){return t.localStore})}function du(e){return ti(e).then(function(t){return t.remoteStore})}function th(e){return ti(e).then(function(t){return t.syncEngine})}function tn(e){return g(this,void 0,void 0,function(){var t,n;return m(this,function(r){switch(r.label){case 0:return[4,ti(e)];case 1:return t=r.sent(),[2,((n=t.eventManager).onListen=Cp.bind(null,t.syncEngine),n.onUnlisten=kp.bind(null,t.syncEngine),n)]}})})}function yu(e,t,n){var r=this;n===void 0&&(n={});var i=new kt;return e.asyncQueue.enqueueAndForget(function(){return g(r,void 0,void 0,function(){var o;return m(this,function(s){switch(s.label){case 0:return o=function(u,a,c,h,l){var f=new Zr({next:function(p){a.enqueueAndForget(function(){return Qo(u,y)});var v=p.docs.has(c);!v&&p.fromCache?l.reject(new w(d.UNAVAILABLE,"Failed to get document because the client is offline.")):v&&p.fromCache&&h&&h.source==="server"?l.reject(new w(d.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.)')):l.resolve(p)},error:function(p){return l.reject(p)}}),y=new Ho(Gn(c.path),f,{includeMetadataChanges:!0,so:!0});return zo(u,y)},[4,tn(e)];case 1:return[2,o.apply(void 0,[s.sent(),e.asyncQueue,t,n,i])]}})})}),i.promise}function vu(e,t,n){var r=this;n===void 0&&(n={});var i=new kt;return e.asyncQueue.enqueueAndForget(function(){return g(r,void 0,void 0,function(){var o;return m(this,function(s){switch(s.label){case 0:return o=function(u,a,c,h,l){var f=new Zr({next:function(p){a.enqueueAndForget(function(){return Qo(u,y)}),p.fromCache&&h.source==="server"?l.reject(new w(d.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.)')):l.resolve(p)},error:function(p){return l.reject(p)}}),y=new Ho(c,f,{includeMetadataChanges:!0,so:!0});return zo(u,y)},[4,tn(e)];case 1:return[2,o.apply(void 0,[s.sent(),e.asyncQueue,t,n,i])]}})})}),i.promise}var Xp=function(e,t,n,r,i,o,s){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=o,this.autoDetectLongPolling=s},Rr=function(){function e(t,n){this.projectId=t,this.database=n||"(default)"}return Object.defineProperty(e.prototype,"isDefaultDatabase",{get:function(){return this.database==="(default)"},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){return t instanceof e&&t.projectId===this.projectId&&t.database===this.database},e}(),mu=new Map,Yp=function(e,t){this.user=t,this.type="OAuth",this.authHeaders={},this.authHeaders.Authorization="Bearer "+e},gu=function(){function e(){this.changeListener=null}return e.prototype.getToken=function(){return Promise.resolve(null)},e.prototype.invalidateToken=function(){},e.prototype.setChangeListener=function(t){this.changeListener=t,t(Tt.UNAUTHENTICATED)},e.prototype.removeChangeListener=function(){this.changeListener=null},e}(),Jp=function(){function e(t){var n=this;this.oc=null,this.currentUser=Tt.UNAUTHENTICATED,this.receivedInitialUser=!1,this.cc=0,this.changeListener=null,this.forceRefresh=!1,this.oc=function(){n.cc++,n.currentUser=n.uc(),n.receivedInitialUser=!0,n.changeListener&&n.changeListener(n.currentUser)},this.cc=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.oc):(this.oc(null),t.get().then(function(r){n.auth=r,n.oc&&n.auth.addAuthTokenListener(n.oc)},function(){}))}return e.prototype.getToken=function(){var t=this,n=this.cc,r=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(r).then(function(i){return t.cc!==n?(I("FirebaseCredentialsProvider","getToken aborted due to token change."),t.getToken()):i?(x(typeof i.accessToken=="string"),new Yp(i.accessToken,t.currentUser)):null}):Promise.resolve(null)},e.prototype.invalidateToken=function(){this.forceRefresh=!0},e.prototype.setChangeListener=function(t){this.changeListener=t,this.receivedInitialUser&&t(this.currentUser)},e.prototype.removeChangeListener=function(){this.auth&&this.auth.removeAuthTokenListener(this.oc),this.oc=null,this.changeListener=null},e.prototype.uc=function(){var t=this.auth&&this.auth.getUid();return x(t===null||typeof t=="string"),new Tt(t)},e}(),Zp=function(){function e(t,n,r){this.ac=t,this.hc=n,this.lc=r,this.type="FirstParty",this.user=Tt.FIRST_PARTY}return Object.defineProperty(e.prototype,"authHeaders",{get:function(){var t={"X-Goog-AuthUser":this.hc},n=this.ac.auth.getAuthHeaderValueForFirstParty([]);return n&&(t.Authorization=n),this.lc&&(t["X-Goog-Iam-Authorization-Token"]=this.lc),t},enumerable:!1,configurable:!0}),e}(),td=function(){function e(t,n,r){this.ac=t,this.hc=n,this.lc=r}return e.prototype.getToken=function(){return Promise.resolve(new Zp(this.ac,this.hc,this.lc))},e.prototype.setChangeListener=function(t){t(Tt.FIRST_PARTY)},e.prototype.removeChangeListener=function(){},e.prototype.invalidateToken=function(){},e}();/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function ns(e,t,n){if(!n)throw new w(d.INVALID_ARGUMENT,"Function "+e+"() cannot be called with an empty "+t+".")}function rs(e,t){if(t===void 0)return{merge:!1};if(t.mergeFields!==void 0&&t.merge!==void 0)throw new w(d.INVALID_ARGUMENT,"Invalid options passed to function "+e+'(): You cannot specify both "merge" and "mergeFields".');return t}function eh(e,t,n,r){if(t===!0&&r===!0)throw new w(d.INVALID_ARGUMENT,e+" and "+n+" cannot be used together.")}function wu(e){if(!N.isDocumentKey(e))throw new w(d.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+e+" has "+e.length+".")}function bu(e){if(N.isDocumentKey(e))throw new w(d.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+e+" has "+e.length+".")}function ei(e){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="string")return e.length>20&&(e=e.substring(0,20)+"..."),JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return""+e;if(typeof e=="object"){if(e instanceof Array)return"an array";var t=function(n){if(n.constructor){var r=/function\s+([^\s(]+)\s*\(/.exec(n.constructor.toString());if(r&&r.length>1)return r[1]}return null}(e);return t?"a custom "+t+" object":"an object"}return typeof e=="function"?"a function":D()}function U(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new w(d.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=ei(e);throw new w(d.INVALID_ARGUMENT,"Expected type '"+t.name+"', but it was: "+n)}return e}function Iu(e,t){if(t<=0)throw new w(d.INVALID_ARGUMENT,"Function "+e+"() requires a positive number, but it was: "+t+".")}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Eu=function(){function e(t){var n;if(t.host===void 0){if(t.ssl!==void 0)throw new w(d.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=(n=t.ssl)===null||n===void 0||n;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,t.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;else{if(t.cacheSizeBytes!==-1&&t.cacheSizeBytes<1048576)throw new w(d.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,eh("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}return e.prototype.isEqual=function(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties},e}(),kn=function(){function e(t,n){this._persistenceKey="(lite)",this._settings=new Eu({}),this._settingsFrozen=!1,t instanceof Rr?(this._databaseId=t,this._credentials=new gu):(this._app=t,this._databaseId=function(r){if(!Object.prototype.hasOwnProperty.apply(r.options,["projectId"]))throw new w(d.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Rr(r.options.projectId)}(t),this._credentials=new Jp(n))}return Object.defineProperty(e.prototype,"app",{get:function(){if(!this._app)throw new w(d.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_initialized",{get:function(){return this._settingsFrozen},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_terminated",{get:function(){return this._terminateTask!==void 0},enumerable:!1,configurable:!0}),e.prototype._setSettings=function(t){if(this._settingsFrozen)throw new w(d.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new Eu(t),t.credentials!==void 0&&(this._credentials=function(n){if(!n)return new gu;switch(n.type){case"gapi":var r=n.client;return x(!(typeof r!="object"||r===null||!r.auth||!r.auth.getAuthHeaderValueForFirstParty)),new td(r,n.sessionIndex||"0",n.iamToken||null);case"provider":return n.client;default:throw new w(d.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(t.credentials))},e.prototype._getSettings=function(){return this._settings},e.prototype._freezeSettings=function(){return this._settingsFrozen=!0,this._settings},e.prototype._delete=function(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask},e.prototype.toJSON=function(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}},e.prototype._terminate=function(){return t=this,(n=mu.get(t))&&(I("ComponentProvider","Removing Datastore"),mu.delete(t),n.terminate()),Promise.resolve();var t,n},e}(),G=function(){function e(t,n,r){this._converter=n,this._key=r,this.type="document",this.firestore=t}return Object.defineProperty(e.prototype,"_path",{get:function(){return this._key.path},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this._key.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return new ne(this.firestore,this._converter,this._key.path.popLast())},enumerable:!1,configurable:!0}),e.prototype.withConverter=function(t){return new e(this.firestore,t,this._key)},e}(),Nt=function(){function e(t,n,r){this._converter=n,this._query=r,this.type="query",this.firestore=t}return e.prototype.withConverter=function(t){return new e(this.firestore,t,this._query)},e}(),ne=function(e){function t(n,r,i){var o=this;return(o=e.call(this,n,r,Gn(i))||this).firestore=n,o._path=i,o.type="collection",o}return C(t,e),Object.defineProperty(t.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){var n=this._path.popLast();return n.isEmpty()?null:new G(this.firestore,null,new N(n))},enumerable:!1,configurable:!0}),t.prototype.withConverter=function(n){return new t(this.firestore,n,this._path)},t}(Nt);/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function nh(e,t){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];if(e=X(e),ns("collection","path",t),e instanceof kn)return bu(n=V.fromString.apply(V,$([t],r))),new ne(e,null,n);if(!(e instanceof G||e instanceof ne))throw new w(d.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return bu(n=V.fromString.apply(V,$([e.path],r)).child(V.fromString(t))),new ne(e.firestore,null,n)}function hr(e,t){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];if(e=X(e),arguments.length===1&&(t=Fa.u()),ns("doc","path",t),e instanceof kn)return wu(n=V.fromString.apply(V,$([t],r))),new G(e,null,new N(n));if(!(e instanceof G||e instanceof ne))throw new w(d.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return wu(n=e._path.child(V.fromString.apply(V,$([t],r)))),new G(e.firestore,e instanceof ne?e._converter:null,new N(n))}function rh(e,t){return e=X(e),t=X(t),(e instanceof G||e instanceof ne)&&(t instanceof G||t instanceof ne)&&e.firestore===t.firestore&&e.path===t.path&&e._converter===t._converter}function ih(e,t){return e=X(e),t=X(t),e instanceof Nt&&t instanceof Nt&&e.firestore===t.firestore&&zn(e._query,t._query)&&e._converter===t._converter}var ed=function(){function e(){var t=this;this.fc=Promise.resolve(),this.dc=[],this.wc=!1,this._c=[],this.mc=null,this.yc=!1,this.gc=[],this.Zi=new Bo(this,"async_queue_retry"),this.Ec=function(){var r=cr();r&&I("AsyncQueue","Visibility state changed to "+r.visibilityState),t.Zi.Gi()};var n=cr();n&&typeof n.addEventListener=="function"&&n.addEventListener("visibilitychange",this.Ec)}return Object.defineProperty(e.prototype,"isShuttingDown",{get:function(){return this.wc},enumerable:!1,configurable:!0}),e.prototype.enqueueAndForget=function(t){this.enqueue(t)},e.prototype.enqueueAndForgetEvenWhileRestricted=function(t){this.Tc(),this.Ic(t)},e.prototype.enterRestrictedMode=function(){if(!this.wc){this.wc=!0;var t=cr();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.Ec)}},e.prototype.enqueue=function(t){return this.Tc(),this.wc?new Promise(function(n){}):this.Ic(t)},e.prototype.enqueueRetryable=function(t){var n=this;this.enqueueAndForget(function(){return n.dc.push(t),n.Ac()})},e.prototype.Ac=function(){return g(this,void 0,void 0,function(){var t,n=this;return m(this,function(r){switch(r.label){case 0:if(this.dc.length===0)return[3,5];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.dc[0]()];case 2:return r.sent(),this.dc.shift(),this.Zi.reset(),[3,4];case 3:if(!De(t=r.sent()))throw t;return I("AsyncQueue","Operation failed with retryable error: "+t),[3,4];case 4:this.dc.length>0&&this.Zi.ji(function(){return n.Ac()}),r.label=5;case 5:return[2]}})})},e.prototype.Ic=function(t){var n=this,r=this.fc.then(function(){return n.yc=!0,t().catch(function(i){throw n.mc=i,n.yc=!1,W("INTERNAL UNHANDLED ERROR: ",function(o){var s=o.message||"";return o.stack&&(s=o.stack.includes(o.message)?o.stack:o.message+`
`+o.stack),s}(i)),i}).then(function(i){return n.yc=!1,i})});return this.fc=r,r},e.prototype.enqueueAfterDelay=function(t,n,r){var i=this;this.Tc(),this.gc.indexOf(t)>-1&&(n=0);var o=Ip.createAndSchedule(this,t,n,r,function(s){return i.Rc(s)});return this._c.push(o),o},e.prototype.Tc=function(){this.mc&&D()},e.prototype.verifyOperationInProgress=function(){},e.prototype.bc=function(){return g(this,void 0,void 0,function(){var t;return m(this,function(n){switch(n.label){case 0:return[4,t=this.fc];case 1:n.sent(),n.label=2;case 2:if(t!==this.fc)return[3,0];n.label=3;case 3:return[2]}})})},e.prototype.vc=function(t){for(var n=0,r=this._c;n<r.length;n++)if(r[n].timerId===t)return!0;return!1},e.prototype.Pc=function(t){var n=this;return this.bc().then(function(){n._c.sort(function(s,u){return s.targetTimeMs-u.targetTimeMs});for(var r=0,i=n._c;r<i.length;r++){var o=i[r];if(o.skipDelay(),t!=="all"&&o.timerId===t)break}return n.bc()})},e.prototype.Vc=function(t){this.gc.push(t)},e.prototype.Rc=function(t){var n=this._c.indexOf(t);this._c.splice(n,1)},e}();function en(e){return function(t,n){if(typeof t!="object"||t===null)return!1;for(var r=t,i=0,o=["next","error","complete"];i<o.length;i++){var s=o[i];if(s in r&&typeof r[s]=="function")return!0}return!1}(e)}var nd=-1,Y=function(e){function t(n,r){var i=this;return(i=e.call(this,n,r)||this)._queue=new ed,i._persistenceKey="name"in n?n.name:"[DEFAULT]",i}return C(t,e),t.prototype._terminate=function(){return this._firestoreClient||oh(this),this._firestoreClient.terminate()},t}(kn);/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function ot(e){return e._firestoreClient||oh(e),e._firestoreClient.verifyNotTerminated(),e._firestoreClient}function oh(e){var t,n=e._freezeSettings(),r=function(i,o,s,u){return new Xp(i,o,s,u.host,u.ssl,u.experimentalForceLongPolling,u.experimentalAutoDetectLongPolling)}(e._databaseId,((t=e._app)===null||t===void 0?void 0:t.options.appId)||"",e._persistenceKey,n);e._firestoreClient=new Wp(e._credentials,e._queue,r)}function Tu(e,t,n){var r=this,i=new kt;return e.asyncQueue.enqueue(function(){return g(r,void 0,void 0,function(){var o;return m(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,Yc(e,n)];case 1:return s.sent(),[4,Jc(e,t)];case 2:return s.sent(),i.resolve(),[3,4];case 3:if(!function(u){return u.name==="FirebaseError"?u.code===d.FAILED_PRECONDITION||u.code===d.UNIMPLEMENTED:!(typeof DOMException<"u"&&u instanceof DOMException)||u.code===22||u.code===20||u.code===11}(o=s.sent()))throw o;return console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+o),i.reject(o),[3,4];case 4:return[2]}})})}).then(function(){return i.promise})}function _u(e){if(e._initialized||e._terminated)throw new w(d.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Ft=function(){function e(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=0;r<t.length;++r)if(t[r].length===0)throw new w(d.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new xt(t)}return e.prototype.isEqual=function(t){return this._internalPath.isEqual(t._internalPath)},e}(),Te=function(){function e(t){this._byteString=t}return e.fromBase64String=function(t){try{return new e(wt.fromBase64String(t))}catch(n){throw new w(d.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+n)}},e.fromUint8Array=function(t){return new e(wt.fromUint8Array(t))},e.prototype.toBase64=function(){return this._byteString.toBase64()},e.prototype.toUint8Array=function(){return this._byteString.toUint8Array()},e.prototype.toString=function(){return"Bytes(base64: "+this.toBase64()+")"},e.prototype.isEqual=function(t){return this._byteString.isEqual(t._byteString)},e}(),Ae=function(e){this._methodName=e},ni=function(){function e(t,n){if(!isFinite(t)||t<-90||t>90)throw new w(d.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(n)||n<-180||n>180)throw new w(d.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+n);this._lat=t,this._long=n}return Object.defineProperty(e.prototype,"latitude",{get:function(){return this._lat},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"longitude",{get:function(){return this._long},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){return this._lat===t._lat&&this._long===t._long},e.prototype.toJSON=function(){return{latitude:this._lat,longitude:this._long}},e.prototype._compareTo=function(t){return L(this._lat,t._lat)||L(this._long,t._long)},e}(),rd=/^__.*__$/,id=function(){function e(t,n,r){this.data=t,this.fieldMask=n,this.fieldTransforms=r}return e.prototype.toMutation=function(t,n){return this.fieldMask!==null?new ce(t,this.data,this.fieldMask,n,this.fieldTransforms):new Hn(t,this.data,n,this.fieldTransforms)},e}(),sh=function(){function e(t,n,r){this.data=t,this.fieldMask=n,this.fieldTransforms=r}return e.prototype.toMutation=function(t,n){return new ce(t,this.data,this.fieldMask,n,this.fieldTransforms)},e}();/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function uh(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw D()}}var ah=function(){function e(t,n,r,i,o,s){this.settings=t,this.databaseId=n,this.R=r,this.ignoreUndefinedProperties=i,o===void 0&&this.Sc(),this.fieldTransforms=o||[],this.fieldMask=s||[]}return Object.defineProperty(e.prototype,"path",{get:function(){return this.settings.path},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Dc",{get:function(){return this.settings.Dc},enumerable:!1,configurable:!0}),e.prototype.Cc=function(t){return new e(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.R,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)},e.prototype.Nc=function(t){var n,r=(n=this.path)===null||n===void 0?void 0:n.child(t),i=this.Cc({path:r,xc:!1});return i.Fc(t),i},e.prototype.kc=function(t){var n,r=(n=this.path)===null||n===void 0?void 0:n.child(t),i=this.Cc({path:r,xc:!1});return i.Sc(),i},e.prototype.Oc=function(t){return this.Cc({path:void 0,xc:!0})},e.prototype.$c=function(t){return Or(t,this.settings.methodName,this.settings.Mc||!1,this.path,this.settings.Lc)},e.prototype.contains=function(t){return this.fieldMask.find(function(n){return t.isPrefixOf(n)})!==void 0||this.fieldTransforms.find(function(n){return t.isPrefixOf(n.field)})!==void 0},e.prototype.Sc=function(){if(this.path)for(var t=0;t<this.path.length;t++)this.Fc(this.path.get(t))},e.prototype.Fc=function(t){if(t.length===0)throw this.$c("Document fields must not be empty");if(uh(this.Dc)&&rd.test(t))throw this.$c('Document fields cannot begin and end with "__"')},e}(),od=function(){function e(t,n,r){this.databaseId=t,this.ignoreUndefinedProperties=n,this.R=r||Yr(t)}return e.prototype.Bc=function(t,n,r,i){return i===void 0&&(i=!1),new ah({Dc:t,methodName:n,Lc:r,path:xt.emptyPath(),xc:!1,Mc:i},this.databaseId,this.R,this.ignoreUndefinedProperties)},e}();function Ce(e){var t=e._freezeSettings(),n=Yr(e._databaseId);return new od(e._databaseId,!!t.ignoreUndefinedProperties,n)}function ri(e,t,n,r,i,o){o===void 0&&(o={});var s=e.Bc(o.merge||o.mergeFields?2:0,t,n,i);us("Data must be an object, but it was:",s,r);var u,a,c=lh(r,s);if(o.merge)u=new Be(s.fieldMask),a=s.fieldTransforms;else if(o.mergeFields){for(var h=[],l=0,f=o.mergeFields;l<f.length;l++){var y=Wi(t,f[l],n);if(!s.contains(y))throw new w(d.INVALID_ARGUMENT,"Field '"+y+"' is specified in your field mask but missing from your input data.");ph(h,y)||h.push(y)}u=new Be(h),a=s.fieldTransforms.filter(function(p){return u.covers(p.field)})}else u=null,a=s.fieldTransforms;return new id(new _t(c),u,a)}var is=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t.prototype._toFieldTransform=function(n){if(n.Dc!==2)throw n.Dc===1?n.$c(this._methodName+"() can only appear at the top level of your update data"):n.$c(this._methodName+"() cannot be used with set() unless you pass {merge:true}");return n.fieldMask.push(n.path),null},t.prototype.isEqual=function(n){return n instanceof t},t}(Ae);function ch(e,t,n){return new ah({Dc:3,Lc:t.settings.Lc,methodName:e._methodName,xc:n},t.databaseId,t.R,t.ignoreUndefinedProperties)}var sd=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t.prototype._toFieldTransform=function(n){return new $n(n.path,new ze)},t.prototype.isEqual=function(n){return n instanceof t},t}(Ae),ud=function(e){function t(n,r){var i=this;return(i=e.call(this,n)||this).qc=r,i}return C(t,e),t.prototype._toFieldTransform=function(n){var r=ch(this,n,!0),i=this.qc.map(function(s){return ke(s,r)}),o=new Ie(i);return new $n(n.path,o)},t.prototype.isEqual=function(n){return this===n},t}(Ae),ad=function(e){function t(n,r){var i=this;return(i=e.call(this,n)||this).qc=r,i}return C(t,e),t.prototype._toFieldTransform=function(n){var r=ch(this,n,!0),i=this.qc.map(function(s){return ke(s,r)}),o=new Ee(i);return new $n(n.path,o)},t.prototype.isEqual=function(n){return this===n},t}(Ae),cd=function(e){function t(n,r){var i=this;return(i=e.call(this,n)||this).Uc=r,i}return C(t,e),t.prototype._toFieldTransform=function(n){var r=new Qe(n.R,Ya(n.R,this.Uc));return new $n(n.path,r)},t.prototype.isEqual=function(n){return this===n},t}(Ae);function os(e,t,n,r){var i=e.Bc(1,t,n);us("Data must be an object, but it was:",i,r);var o=[],s=_t.empty();jn(r,function(a,c){var h=as(t,a,n);c=X(c);var l=i.kc(h);if(c instanceof is)o.push(h);else{var f=ke(c,l);f!=null&&(o.push(h),s.set(h,f))}});var u=new Be(o);return new sh(s,u,i.fieldTransforms)}function ss(e,t,n,r,i,o){var s=e.Bc(1,t,n),u=[Wi(t,r,n)],a=[i];if(o.length%2!=0)throw new w(d.INVALID_ARGUMENT,"Function "+t+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var c=0;c<o.length;c+=2)u.push(Wi(t,o[c])),a.push(o[c+1]);for(var h=[],l=_t.empty(),f=u.length-1;f>=0;--f)if(!ph(h,u[f])){var y=u[f],p=a[f];p=X(p);var v=s.kc(y);if(p instanceof is)h.push(y);else{var E=ke(p,v);E!=null&&(h.push(y),l.set(y,E))}}var T=new Be(h);return new sh(l,T,s.fieldTransforms)}function hh(e,t,n,r){return r===void 0&&(r=!1),ke(n,e.Bc(r?4:3,t))}function ke(e,t){if(fh(e=X(e)))return us("Unsupported field value:",t,e),lh(e,t);if(e instanceof Ae)return function(n,r){if(!uh(r.Dc))throw r.$c(n._methodName+"() can only be used with update() and set()");if(!r.path)throw r.$c(n._methodName+"() is not currently supported inside arrays");var i=n._toFieldTransform(r);i&&r.fieldTransforms.push(i)}(e,t),null;if(e===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.xc&&t.Dc!==4)throw t.$c("Nested arrays are not supported");return function(n,r){for(var i=[],o=0,s=0,u=n;s<u.length;s++){var a=ke(u[s],r.Oc(o));a==null&&(a={nullValue:"NULL_VALUE"}),i.push(a),o++}return{arrayValue:{values:i}}}(e,t)}return function(n,r){if((n=X(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return Ya(r.R,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){var i=gt.fromDate(n);return{timestampValue:Dn(r.R,i)}}if(n instanceof gt)return i=new gt(n.seconds,1e3*Math.floor(n.nanoseconds/1e3)),{timestampValue:Dn(r.R,i)};if(n instanceof ni)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof Te)return{bytesValue:uc(r.R,n._byteString)};if(n instanceof G){i=r.databaseId;var o=n.firestore._databaseId;if(!o.isEqual(i))throw r.$c("Document reference is for database "+o.projectId+"/"+o.database+" but should be for database "+i.projectId+"/"+i.database);return{referenceValue:Po(n.firestore._databaseId||r.databaseId,n._key.path)}}throw r.$c("Unsupported field value: "+ei(n))}(e,t)}function lh(e,t){var n={};return Ua(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):jn(e,function(r,i){var o=ke(i,t.Nc(r));o!=null&&(n[r]=o)}),{mapValue:{fields:n}}}function fh(e){return!(typeof e!="object"||e===null||e instanceof Array||e instanceof Date||e instanceof gt||e instanceof ni||e instanceof Te||e instanceof G||e instanceof Ae)}function us(e,t,n){if(!fh(n)||!function(i){return typeof i=="object"&&i!==null&&(Object.getPrototypeOf(i)===Object.prototype||Object.getPrototypeOf(i)===null)}(n)){var r=ei(n);throw r==="an object"?t.$c(e+" a custom object"):t.$c(e+" "+r)}}function Wi(e,t,n){if((t=X(t))instanceof Ft)return t._internalPath;if(typeof t=="string")return as(e,t);throw Or("Field path arguments must be of type string or FieldPath.",e,!1,void 0,n)}var hd=new RegExp("[~\\*/\\[\\]]");function as(e,t,n){if(t.search(hd)>=0)throw Or("Invalid field path ("+t+"). Paths must not contain '~', '*', '/', '[', or ']'",e,!1,void 0,n);try{return new(Ft.bind.apply(Ft,$([void 0],t.split("."))))()._internalPath}catch{throw Or("Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'",e,!1,void 0,n)}}function Or(e,t,n,r,i){var o=r&&!r.isEmpty(),s=i!==void 0,u="Function "+t+"() called with invalid data";n&&(u+=" (via `toFirestore()`)");var a="";return(o||s)&&(a+=" (found",o&&(a+=" in field "+r),s&&(a+=" in document "+i),a+=")"),new w(d.INVALID_ARGUMENT,(u+=". ")+e+a)}function ph(e,t){return e.some(function(n){return n.isEqual(t)})}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var xn=function(){function e(t,n,r,i,o){this._firestore=t,this._userDataWriter=n,this._key=r,this._document=i,this._converter=o}return Object.defineProperty(e.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ref",{get:function(){return new G(this._firestore,this._converter,this._key)},enumerable:!1,configurable:!0}),e.prototype.exists=function(){return this._document!==null},e.prototype.data=function(){if(this._document){if(this._converter){var t=new ld(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.toProto())}},e.prototype.get=function(t){if(this._document){var n=this._document.data.field(Pr("DocumentSnapshot.get",t));if(n!==null)return this._userDataWriter.convertValue(n)}},e}(),ld=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t.prototype.data=function(){return e.prototype.data.call(this)},t}(xn);function Pr(e,t){return typeof t=="string"?as(e,t):t instanceof Ft?t._internalPath:t._delegate._internalPath}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var de=function(){function e(t,n){this.hasPendingWrites=t,this.fromCache=n}return e.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},e}(),Gt=function(e){function t(n,r,i,o,s,u){var a=this;return(a=e.call(this,n,r,i,o,u)||this)._firestore=n,a._firestoreImpl=n,a.metadata=s,a}return C(t,e),t.prototype.exists=function(){return e.prototype.exists.call(this)},t.prototype.data=function(n){if(n===void 0&&(n={}),this._document){if(this._converter){var r=new gn(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(r,n)}return this._userDataWriter.convertValue(this._document.data.toProto(),n.serverTimestamps)}},t.prototype.get=function(n,r){if(r===void 0&&(r={}),this._document){var i=this._document.data.field(Pr("DocumentSnapshot.get",n));if(i!==null)return this._userDataWriter.convertValue(i,r.serverTimestamps)}},t}(xn),gn=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t.prototype.data=function(n){return n===void 0&&(n={}),e.prototype.data.call(this,n)},t}(Gt),Jt=function(){function e(t,n,r,i){this._firestore=t,this._userDataWriter=n,this._snapshot=i,this.metadata=new de(i.hasPendingWrites,i.fromCache),this.query=r}return Object.defineProperty(e.prototype,"docs",{get:function(){var t=[];return this.forEach(function(n){return t.push(n)}),t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"empty",{get:function(){return this.size===0},enumerable:!1,configurable:!0}),e.prototype.forEach=function(t,n){var r=this;this._snapshot.docs.forEach(function(i){t.call(n,new gn(r._firestore,r._userDataWriter,i.key,i,new de(r._snapshot.mutatedKeys.has(i.key),r._snapshot.fromCache),r.query._converter))})},e.prototype.docChanges=function(t){t===void 0&&(t={});var n=!!t.includeMetadataChanges;if(n&&this._snapshot.excludesMetadataChanges)throw new w(d.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===n||(this._cachedChanges=function(r,i){if(r._snapshot.oldDocs.isEmpty()){var o=0;return r._snapshot.docChanges.map(function(u){var a=new gn(r._firestore,r._userDataWriter,u.doc.key,u.doc,new de(r._snapshot.mutatedKeys.has(u.doc.key),r._snapshot.fromCache),r.query._converter);return u.doc,{type:"added",doc:a,oldIndex:-1,newIndex:o++}})}var s=r._snapshot.oldDocs;return r._snapshot.docChanges.filter(function(u){return i||u.type!==3}).map(function(u){var a=new gn(r._firestore,r._userDataWriter,u.doc.key,u.doc,new de(r._snapshot.mutatedKeys.has(u.doc.key),r._snapshot.fromCache),r.query._converter),c=-1,h=-1;return u.type!==0&&(c=s.indexOf(u.doc.key),s=s.delete(u.doc.key)),u.type!==1&&(h=(s=s.add(u.doc)).indexOf(u.doc.key)),{type:fd(u.type),doc:a,oldIndex:c,newIndex:h}})}(this,n),this._cachedChangesIncludeMetadataChanges=n),this._cachedChanges},e}();function fd(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return D()}}function dh(e,t){return e instanceof Gt&&t instanceof Gt?e._firestore===t._firestore&&e._key.isEqual(t._key)&&(e._document===null?t._document===null:e._document.isEqual(t._document))&&e._converter===t._converter:e instanceof Jt&&t instanceof Jt&&e._firestore===t._firestore&&ih(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function yh(e){if(_r(e)&&e.explicitOrderBy.length===0)throw new w(d.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var Yn=function(){};function Ht(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0,i=t;r<i.length;r++){var o=i[r];e=o._apply(e)}return e}var pd=function(e){function t(n,r,i){var o=this;return(o=e.call(this)||this).Qc=n,o.Kc=r,o.jc=i,o.type="where",o}return C(t,e),t.prototype._apply=function(n){var r=Ce(n.firestore),i=function(o,s,u,a,c,h,l){var f;if(c.isKeyField()){if(h==="array-contains"||h==="array-contains-any")throw new w(d.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+h+"' queries on FieldPath.documentId().");if(h==="in"||h==="not-in"){Cu(l,h);for(var y=[],p=0,v=l;p<v.length;p++){var E=v[p];y.push(Au(a,o,E))}f={arrayValue:{values:y}}}else f=Au(a,o,l)}else h!=="in"&&h!=="not-in"&&h!=="array-contains-any"||Cu(l,h),f=hh(u,"where",l,h==="in"||h==="not-in");var T=Dt.create(c,h,f);return function(k,A){if(A.g()){var O=Co(k);if(O!==null&&!O.isEqual(A.field))throw new w(d.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '"+O.toString()+"' and '"+A.field.toString()+"'");var M=Ao(k);M!==null&&mh(k,A.field,M)}var q=function(et,ai){for(var ln=0,hs=et.filters;ln<hs.length;ln++){var ls=hs[ln];if(ai.indexOf(ls.op)>=0)return ls.op}return null}(k,function(et){switch(et){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[]}}(A.op));if(q!==null)throw q===A.op?new w(d.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+A.op.toString()+"' filter."):new w(d.INVALID_ARGUMENT,"Invalid query. You cannot use '"+A.op.toString()+"' filters with '"+q.toString()+"' filters.")}(o,T),T}(n._query,0,r,n.firestore._databaseId,this.Qc,this.Kc,this.jc);return new Nt(n.firestore,n._converter,function(o,s){var u=o.filters.concat([s]);return new Qt(o.path,o.collectionGroup,o.explicitOrderBy.slice(),u,o.limit,o.limitType,o.startAt,o.endAt)}(n._query,i))},t}(Yn),dd=function(e){function t(n,r){var i=this;return(i=e.call(this)||this).Qc=n,i.Wc=r,i.type="orderBy",i}return C(t,e),t.prototype._apply=function(n){var r=function(i,o,s){if(i.startAt!==null)throw new w(d.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(i.endAt!==null)throw new w(d.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var u=new Ve(o,s);return function(a,c){if(Ao(a)===null){var h=Co(a);h!==null&&mh(a,h,c.field)}}(i,u),u}(n._query,this.Qc,this.Wc);return new Nt(n.firestore,n._converter,function(i,o){var s=i.explicitOrderBy.concat([o]);return new Qt(i.path,i.collectionGroup,s,i.filters.slice(),i.limit,i.limitType,i.startAt,i.endAt)}(n._query,r))},t}(Yn),Su=function(e){function t(n,r,i){var o=this;return(o=e.call(this)||this).type=n,o.Gc=r,o.zc=i,o}return C(t,e),t.prototype._apply=function(n){return new Nt(n.firestore,n._converter,Qa(n._query,this.Gc,this.zc))},t}(Yn),Du=function(e){function t(n,r,i){var o=this;return(o=e.call(this)||this).type=n,o.Hc=r,o.Jc=i,o}return C(t,e),t.prototype._apply=function(n){var r=vh(n,this.type,this.Hc,this.Jc);return new Nt(n.firestore,n._converter,function(i,o){return new Qt(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,o,i.endAt)}(n._query,r))},t}(Yn),Nu=function(e){function t(n,r,i){var o=this;return(o=e.call(this)||this).type=n,o.Hc=r,o.Jc=i,o}return C(t,e),t.prototype._apply=function(n){var r=vh(n,this.type,this.Hc,this.Jc);return new Nt(n.firestore,n._converter,function(i,o){return new Qt(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,i.startAt,o)}(n._query,r))},t}(Yn);function vh(e,t,n,r){if(n[0]=X(n[0]),n[0]instanceof xn)return function(o,s,u,a,c){if(!a)throw new w(d.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+u+"().");for(var h=[],l=0,f=Ge(o);l<f.length;l++){var y=f[l];if(y.field.isKeyField())h.push(Ir(s,a.key));else{var p=a.data.field(y.field);if(So(p))throw new w(d.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+y.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(p===null){var v=y.field.canonicalString();throw new w(d.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+v+"' (used as the orderBy) does not exist.")}h.push(p)}}return new Sn(h,c)}(e._query,e.firestore._databaseId,t,n[0]._document,r);var i=Ce(e.firestore);return function(o,s,u,a,c,h){var l=o.explicitOrderBy;if(c.length>l.length)throw new w(d.INVALID_ARGUMENT,"Too many arguments provided to "+a+"(). The number of arguments must be less than or equal to the number of orderBy() clauses");for(var f=[],y=0;y<c.length;y++){var p=c[y];if(l[y].field.isKeyField()){if(typeof p!="string")throw new w(d.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+a+"(), but got a "+typeof p);if(!ko(o)&&p.indexOf("/")!==-1)throw new w(d.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to "+a+"() must be a plain document ID, but '"+p+"' contains a slash.");var v=o.path.child(V.fromString(p));if(!N.isDocumentKey(v))throw new w(d.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to "+a+"() must result in a valid document path, but '"+v+"' is not because it contains an odd number of segments.");var E=new N(v);f.push(Ir(s,E))}else{var T=hh(u,a,p);f.push(T)}}return new Sn(f,h)}(e._query,e.firestore._databaseId,i,t,n,r)}function Au(e,t,n){if(typeof(n=X(n))=="string"){if(n==="")throw new w(d.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!ko(t)&&n.indexOf("/")!==-1)throw new w(d.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=t.path.child(V.fromString(n));if(!N.isDocumentKey(r))throw new w(d.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 Ir(e,new N(r))}if(n instanceof G)return Ir(e,n._key);throw new w(d.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+ei(n)+".")}function Cu(e,t){if(!Array.isArray(e)||e.length===0)throw new w(d.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+t.toString()+"' filters.");if(e.length>10)throw new w(d.INVALID_ARGUMENT,"Invalid Query. '"+t.toString()+"' filters support a maximum of 10 elements in the value array.")}function mh(e,t,n){if(!n.isEqual(t))throw new w(d.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '"+t.toString()+"' and so you must also use '"+t.toString()+"' as your first argument to orderBy(), but your first orderBy() is on field '"+n.toString()+"' instead.")}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var cs=function(){function e(){}return e.prototype.convertValue=function(t,n){switch(n===void 0&&(n="none"),oe(t)){case 0:return null;case 1:return t.booleanValue;case 2:return H(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,n);case 5:return t.stringValue;case 6:return this.convertBytes(je(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,n);case 10:return this.convertObject(t.mapValue,n);default:throw D()}},e.prototype.convertObject=function(t,n){var r=this,i={};return jn(t.fields||{},function(o,s){i[o]=r.convertValue(s,n)}),i},e.prototype.convertGeoPoint=function(t){return new ni(H(t.latitude),H(t.longitude))},e.prototype.convertArray=function(t,n){var r=this;return(t.values||[]).map(function(i){return r.convertValue(i,n)})},e.prototype.convertServerTimestamp=function(t,n){switch(n){case"previous":var r=Ba(t);return r==null?null:this.convertValue(r,n);case"estimate":return this.convertTimestamp(Tn(t));default:return null}},e.prototype.convertTimestamp=function(t){var n=ie(t);return new gt(n.seconds,n.nanos)},e.prototype.convertDocumentKey=function(t,n){var r=V.fromString(t);x(yc(r));var i=new Rr(r.get(1),r.get(3)),o=new N(r.popFirst(5));return i.isEqual(n)||W("Document "+o+" contains a document reference within a different database ("+i.projectId+"/"+i.database+") which is not supported. It will be treated as a reference in the current database ("+n.projectId+"/"+n.database+") instead."),o},e}();/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function ii(e,t,n){return e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t}var yd=function(e){function t(n){var r=this;return(r=e.call(this)||this).firestore=n,r}return C(t,e),t.prototype.convertBytes=function(n){return new Te(n)},t.prototype.convertReference=function(n){var r=this.convertDocumentKey(n,this.firestore._databaseId);return new G(this.firestore,null,r)},t}(cs),vd=function(){function e(t,n){this._firestore=t,this._commitHandler=n,this._mutations=[],this._committed=!1,this._dataReader=Ce(t)}return e.prototype.set=function(t,n,r){this._verifyNotCommitted();var i=Zt(t,this._firestore),o=ii(i._converter,n,r),s=ri(this._dataReader,"WriteBatch.set",i._key,o,i._converter!==null,r);return this._mutations.push(s.toMutation(i._key,st.none())),this},e.prototype.update=function(t,n,r){for(var i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];this._verifyNotCommitted();var s,u=Zt(t,this._firestore);return s=typeof(n=X(n))=="string"||n instanceof Ft?ss(this._dataReader,"WriteBatch.update",u._key,n,r,i):os(this._dataReader,"WriteBatch.update",u._key,n),this._mutations.push(s.toMutation(u._key,st.exists(!0))),this},e.prototype.delete=function(t){this._verifyNotCommitted();var n=Zt(t,this._firestore);return this._mutations=this._mutations.concat(new Wn(n._key,st.none())),this},e.prototype.commit=function(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()},e.prototype._verifyNotCommitted=function(){if(this._committed)throw new w(d.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},e}();/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Zt(e,t){if((e=X(e)).firestore!==t)throw new w(d.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var me=function(e){function t(n){var r=this;return(r=e.call(this)||this).firestore=n,r}return C(t,e),t.prototype.convertBytes=function(n){return new Te(n)},t.prototype.convertReference=function(n){var r=this.convertDocumentKey(n,this.firestore._databaseId);return new G(this.firestore,null,r)},t}(cs);function ku(e,t,n){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];e=U(e,G);var o=U(e.firestore,Y),s=Ce(o);return Rn(o,[(typeof(t=X(t))=="string"||t instanceof Ft?ss(s,"updateDoc",e._key,t,n,r):os(s,"updateDoc",e._key,t)).toMutation(e._key,st.exists(!0))])}function gh(e){for(var t,n,r,i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];e=X(e);var s={includeMetadataChanges:!1},u=0;typeof i[u]!="object"||en(i[u])||(s=i[u],u++);var a,c,h,l={includeMetadataChanges:s.includeMetadataChanges};if(en(i[u])){var f=i[u];i[u]=(t=f.next)===null||t===void 0?void 0:t.bind(f),i[u+1]=(n=f.error)===null||n===void 0?void 0:n.bind(f),i[u+2]=(r=f.complete)===null||r===void 0?void 0:r.bind(f)}if(e instanceof G)c=U(e.firestore,Y),h=Gn(e._key.path),a={next:function(v){i[u]&&i[u](Xi(c,e,v))},error:i[u+1],complete:i[u+2]};else{var y=U(e,Nt);c=U(y.firestore,Y),h=y._query;var p=new me(c);a={next:function(v){i[u]&&i[u](new Jt(c,p,y,v))},error:i[u+1],complete:i[u+2]},yh(e._query)}return function(v,E,T,k){var A=this,O=new Zr(k),M=new Ho(E,O,T);return v.asyncQueue.enqueueAndForget(function(){return g(A,void 0,void 0,function(){var q;return m(this,function(et){switch(et.label){case 0:return q=zo,[4,tn(v)];case 1:return[2,q.apply(void 0,[et.sent(),M])]}})})}),function(){O.Wo(),v.asyncQueue.enqueueAndForget(function(){return g(A,void 0,void 0,function(){var q;return m(this,function(et){switch(et.label){case 0:return q=Qo,[4,tn(v)];case 1:return[2,q.apply(void 0,[et.sent(),M])]}})})})}}(ot(c),h,l,a)}function Rn(e,t){return function(n,r){var i=this,o=new kt;return n.asyncQueue.enqueueAndForget(function(){return g(i,void 0,void 0,function(){var s;return m(this,function(u){switch(u.label){case 0:return s=xp,[4,th(n)];case 1:return[2,s.apply(void 0,[u.sent(),r,o])]}})})}),o.promise}(ot(e),t)}function Xi(e,t,n){var r=n.docs.get(t._key),i=new me(e);return new Gt(e,i,t._key,r,new de(n.hasPendingWrites,n.fromCache),t._converter)}/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var md=function(e){function t(n,r){var i=this;return(i=e.call(this,n,r)||this)._firestore=n,i}return C(t,e),t.prototype.get=function(n){var r=this,i=Zt(n,this._firestore),o=new me(this._firestore);return e.prototype.get.call(this,n).then(function(s){return new Gt(r._firestore,o,i._key,s._document,new de(!1,!1),i._converter)})},t}(function(){function e(t,n){this._firestore=t,this._transaction=n,this._dataReader=Ce(t)}return e.prototype.get=function(t){var n=this,r=Zt(t,this._firestore),i=new yd(this._firestore);return this._transaction.lookup([r._key]).then(function(o){if(!o||o.length!==1)return D();var s=o[0];if(s.isFoundDocument())return new xn(n._firestore,i,s.key,s,r._converter);if(s.isNoDocument())return new xn(n._firestore,i,r._key,null,r._converter);throw D()})},e.prototype.set=function(t,n,r){var i=Zt(t,this._firestore),o=ii(i._converter,n,r),s=ri(this._dataReader,"Transaction.set",i._key,o,i._converter!==null,r);return this._transaction.set(i._key,s),this},e.prototype.update=function(t,n,r){for(var i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];var s,u=Zt(t,this._firestore);return s=typeof(n=X(n))=="string"||n instanceof Ft?ss(this._dataReader,"Transaction.update",u._key,n,r,i):os(this._dataReader,"Transaction.update",u._key,n),this._transaction.update(u._key,s),this},e.prototype.delete=function(t){var n=Zt(t,this._firestore);return this._transaction.delete(n._key),this},e}());/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function xu(){if(typeof Uint8Array>"u")throw new w(d.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function Ru(){if(typeof atob>"u")throw new w(d.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var wh=function(){function e(t){this._delegate=t}return e.fromBase64String=function(t){return Ru(),new e(Te.fromBase64String(t))},e.fromUint8Array=function(t){return xu(),new e(Te.fromUint8Array(t))},e.prototype.toBase64=function(){return Ru(),this._delegate.toBase64()},e.prototype.toUint8Array=function(){return xu(),this._delegate.toUint8Array()},e.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},e.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},e}(),gd=function(){function e(){}return e.prototype.enableIndexedDbPersistence=function(t,n){return function(r,i){_u(r=U(r,Y));var o=ot(r),s=r._freezeSettings(),u=new Hi;return Tu(o,u,new Xc(u,s.cacheSizeBytes,i==null?void 0:i.forceOwnership))}(t._delegate,{forceOwnership:n})},e.prototype.enableMultiTabIndexedDbPersistence=function(t){return function(n){_u(n=U(n,Y));var r=ot(n),i=n._freezeSettings(),o=new Hi;return Tu(r,o,new Qp(o,i.cacheSizeBytes))}(t._delegate)},e.prototype.clearIndexedDbPersistence=function(t){return function(n){var r=this;if(n._initialized&&!n._terminated)throw new w(d.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");var i=new kt;return n._queue.enqueueAndForgetEvenWhileRestricted(function(){return g(r,void 0,void 0,function(){var o;return m(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,function(u){return g(this,void 0,void 0,function(){var a;return m(this,function(c){switch(c.label){case 0:return We.yt()?(a=u+"main",[4,We.delete(a)]):[2,Promise.resolve()];case 1:return c.sent(),[2]}})})}(Uo(n._databaseId,n._persistenceKey))];case 1:return s.sent(),i.resolve(),[3,3];case 2:return o=s.sent(),i.reject(o),[3,3];case 3:return[2]}})})}),i.promise}(t._delegate)},e}(),bh=function(){function e(t,n,r){var i=this;this._delegate=n,this.Yc=r,this.INTERNAL={delete:function(){return i.terminate()}},t instanceof Rr||(this.Xc=t)}return Object.defineProperty(e.prototype,"_databaseId",{get:function(){return this._delegate._databaseId},enumerable:!1,configurable:!0}),e.prototype.settings=function(t){t.merge&&delete(t=Object.assign(Object.assign({},this._delegate._getSettings()),t)).merge,this._delegate._setSettings(t)},e.prototype.useEmulator=function(t,n){(function(r,i,o){var s=(r=U(r,kn))._getSettings();s.host!=="firestore.googleapis.com"&&s.host!==i&&Mi("Host has been set in both settings() and useEmulator(), emulator host will be used"),r._setSettings(Object.assign(Object.assign({},s),{host:i+":"+o,ssl:!1}))})(this._delegate,t,n)},e.prototype.enableNetwork=function(){return function(t){var n=this;return t.asyncQueue.enqueue(function(){return g(n,void 0,void 0,function(){var r,i;return m(this,function(o){switch(o.label){case 0:return[4,pu(t)];case 1:return r=o.sent(),[4,du(t)];case 2:return i=o.sent(),[2,(r.setNetworkEnabled(!0),function(s){var u=_(s);return u.$r.delete(0),Xn(u)}(i))]}})})})}(ot(U(this._delegate,Y)))},e.prototype.disableNetwork=function(){return function(t){var n=this;return t.asyncQueue.enqueue(function(){return g(n,void 0,void 0,function(){var r,i;return m(this,function(o){switch(o.label){case 0:return[4,pu(t)];case 1:return r=o.sent(),[4,du(t)];case 2:return i=o.sent(),[2,(r.setNetworkEnabled(!1),function(s){return g(this,void 0,void 0,function(){var u;return m(this,function(a){switch(a.label){case 0:return(u=_(s)).$r.add(0),[4,un(u)];case 1:return a.sent(),u.Br.set("Offline"),[2]}})})}(i))]}})})})}(ot(U(this._delegate,Y)))},e.prototype.enablePersistence=function(t){var n=!1,r=!1;return t&&eh("synchronizeTabs",n=!!t.synchronizeTabs,"experimentalForceOwningTab",r=!!t.experimentalForceOwningTab),n?this.Yc.enableMultiTabIndexedDbPersistence(this):this.Yc.enableIndexedDbPersistence(this,r)},e.prototype.clearPersistence=function(){return this.Yc.clearIndexedDbPersistence(this)},e.prototype.terminate=function(){return this.Xc&&(this.Xc._removeServiceInstance("firestore"),this.Xc._removeServiceInstance("firestore-exp")),this._delegate._delete()},e.prototype.waitForPendingWrites=function(){return function(t){var n=this,r=new kt;return t.asyncQueue.enqueueAndForget(function(){return g(n,void 0,void 0,function(){var i;return m(this,function(o){switch(o.label){case 0:return i=Lp,[4,th(t)];case 1:return[2,i.apply(void 0,[o.sent(),r])]}})})}),r.promise}(ot(U(this._delegate,Y)))},e.prototype.onSnapshotsInSync=function(t){return function(n,r){return function(i,o){var s=this,u=new Zr(o);return i.asyncQueue.enqueueAndForget(function(){return g(s,void 0,void 0,function(){var a;return m(this,function(c){switch(c.label){case 0:return a=function(h,l){_(h).Gr.add(l),l.next()},[4,tn(i)];case 1:return[2,a.apply(void 0,[c.sent(),u])]}})})}),function(){u.Wo(),i.asyncQueue.enqueueAndForget(function(){return g(s,void 0,void 0,function(){var a;return m(this,function(c){switch(c.label){case 0:return a=function(h,l){_(h).Gr.delete(l)},[4,tn(i)];case 1:return[2,a.apply(void 0,[c.sent(),u])]}})})})}}(ot(n=U(n,Y)),en(r)?r:{next:r})}(this._delegate,t)},Object.defineProperty(e.prototype,"app",{get:function(){if(!this.Xc)throw new w(d.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.Xc},enumerable:!1,configurable:!0}),e.prototype.collection=function(t){try{return new Lr(this,nh(this._delegate,t))}catch(n){throw lt(n,"collection()","Firestore.collection()")}},e.prototype.doc=function(t){try{return new ge(this,hr(this._delegate,t))}catch(n){throw lt(n,"doc()","Firestore.doc()")}},e.prototype.collectionGroup=function(t){try{return new ui(this,function(n,r){if(n=U(n,kn),ns("collectionGroup","collection id",r),r.indexOf("/")>=0)throw new w(d.INVALID_ARGUMENT,"Invalid collection ID '"+r+"' passed to function collectionGroup(). Collection IDs must not contain '/'.");return new Nt(n,null,function(i){return new Qt(V.emptyPath(),i)}(r))}(this._delegate,t))}catch(n){throw lt(n,"collectionGroup()","Firestore.collectionGroup()")}},e.prototype.runTransaction=function(t){var n=this;return function(r,i){return function(o,s){var u=this,a=new kt;return o.asyncQueue.enqueueAndForget(function(){return g(u,void 0,void 0,function(){var c;return m(this,function(h){switch(h.label){case 0:return[4,function(l){return ti(l).then(function(f){return f.datastore})}(o)];case 1:return c=h.sent(),new Hp(o.asyncQueue,c,s,a).run(),[2]}})})}),a.promise}(ot(r),function(o){return i(new md(r,o))})}(this._delegate,function(r){return t(new Ih(n,r))})},e.prototype.batch=function(){var t=this;return ot(this._delegate),new Eh(new vd(this._delegate,function(n){return Rn(t._delegate,n)}))},e.prototype.loadBundle=function(t){throw new w(d.FAILED_PRECONDITION,'"loadBundle()" does not exist, have you imported "firebase/firestore/bundle"?')},e.prototype.namedQuery=function(t){throw new w(d.FAILED_PRECONDITION,'"namedQuery()" does not exist, have you imported "firebase/firestore/bundle"?')},e}(),oi=function(e){function t(n){var r=this;return(r=e.call(this)||this).firestore=n,r}return C(t,e),t.prototype.convertBytes=function(n){return new wh(new Te(n))},t.prototype.convertReference=function(n){var r=this.convertDocumentKey(n,this.firestore._databaseId);return ge.Zc(r,this.firestore,null)},t}(cs);function wd(e){var t;t=e,Rt.setLogLevel(t)}var Ih=function(){function e(t,n){this._firestore=t,this._delegate=n,this._userDataWriter=new oi(t)}return e.prototype.get=function(t){var n=this,r=ye(t);return this._delegate.get(r).then(function(i){return new On(n._firestore,new Gt(n._firestore._delegate,n._userDataWriter,i._key,i._document,i.metadata,r._converter))})},e.prototype.set=function(t,n,r){var i=ye(t);return r?(rs("Transaction.set",r),this._delegate.set(i,n,r)):this._delegate.set(i,n),this},e.prototype.update=function(t,n,r){for(var i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];var u=ye(t);return arguments.length===2?this._delegate.update(u,n):(i=this._delegate).update.apply(i,$([u,n,r],o)),this},e.prototype.delete=function(t){var n=ye(t);return this._delegate.delete(n),this},e}(),Eh=function(){function e(t){this._delegate=t}return e.prototype.set=function(t,n,r){var i=ye(t);return r?(rs("WriteBatch.set",r),this._delegate.set(i,n,r)):this._delegate.set(i,n),this},e.prototype.update=function(t,n,r){for(var i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];var u=ye(t);return arguments.length===2?this._delegate.update(u,n):(i=this._delegate).update.apply(i,$([u,n,r],o)),this},e.prototype.delete=function(t){var n=ye(t);return this._delegate.delete(n),this},e.prototype.commit=function(){return this._delegate.commit()},e}(),si=function(){function e(t,n,r){this._firestore=t,this._userDataWriter=n,this._delegate=r}return e.prototype.fromFirestore=function(t,n){var r=new gn(this._firestore._delegate,this._userDataWriter,t._key,t._document,t.metadata,null);return this._delegate.fromFirestore(new Pn(this._firestore,r),n??{})},e.prototype.toFirestore=function(t,n){return n?this._delegate.toFirestore(t,n):this._delegate.toFirestore(t)},e.tu=function(t,n){var r=e.eu,i=r.get(t);i||(i=new WeakMap,r.set(t,i));var o=i.get(n);return o||(o=new e(t,new oi(t),n),i.set(n,o)),o},e}();si.eu=new WeakMap;var ge=function(){function e(t,n){this.firestore=t,this._delegate=n,this._userDataWriter=new oi(t)}return e.nu=function(t,n,r){if(t.length%2!=0)throw new w(d.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.canonicalString()+" has "+t.length);return new e(n,new G(n._delegate,r,new N(t)))},e.Zc=function(t,n,r){return new e(n,new G(n._delegate,r,t))},Object.defineProperty(e.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return new Lr(this.firestore,this._delegate.parent)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this._delegate.path},enumerable:!1,configurable:!0}),e.prototype.collection=function(t){try{return new Lr(this.firestore,nh(this._delegate,t))}catch(n){throw lt(n,"collection()","DocumentReference.collection()")}},e.prototype.isEqual=function(t){return(t=X(t))instanceof G&&rh(this._delegate,t)},e.prototype.set=function(t,n){n=rs("DocumentReference.set",n);try{return function(r,i,o){r=U(r,G);var s=U(r.firestore,Y),u=ii(r._converter,i,o);return Rn(s,[ri(Ce(s),"setDoc",r._key,u,r._converter!==null,o).toMutation(r._key,st.none())])}(this._delegate,t,n)}catch(r){throw lt(r,"setDoc()","DocumentReference.set()")}},e.prototype.update=function(t,n){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];try{return arguments.length===1?ku(this._delegate,t):ku.apply(void 0,$([this._delegate,t,n],r))}catch(o){throw lt(o,"updateDoc()","DocumentReference.update()")}},e.prototype.delete=function(){return Rn(U((t=this._delegate).firestore,Y),[new Wn(t._key,st.none())]);var t},e.prototype.onSnapshot=function(){for(var t=this,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=Th(n),o=_h(n,function(s){return new On(t.firestore,new Gt(t.firestore._delegate,t._userDataWriter,s._key,s._document,s.metadata,t._delegate._converter))});return gh(this._delegate,i,o)},e.prototype.get=function(t){var n=this;return((t==null?void 0:t.source)==="cache"?function(r){r=U(r,G);var i=U(r.firestore,Y),o=ot(i),s=new me(i);return function(u,a){var c=this,h=new kt;return u.asyncQueue.enqueueAndForget(function(){return g(c,void 0,void 0,function(){var l;return m(this,function(f){switch(f.label){case 0:return l=function(y,p,v){return g(this,void 0,void 0,function(){var E,T;return m(this,function(k){switch(k.label){case 0:return k.trys.push([0,2,,3]),[4,function(A,O){var M=_(A);return M.persistence.runTransaction("read document","readonly",function(q){return M.Mn.mn(q,O)})}(y,p)];case 1:return(T=k.sent()).isFoundDocument()?v.resolve(T):T.isNoDocument()?v.resolve(null):v.reject(new w(d.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 E=k.sent(),T=hn(E,"Failed to get document '"+p+" from cache"),v.reject(T),[3,3];case 3:return[2]}})})},[4,Zc(u)];case 1:return[2,l.apply(void 0,[f.sent(),a,h])]}})})}),h.promise}(o,r._key).then(function(u){return new Gt(i,s,r._key,u,new de(u!==null&&u.hasLocalMutations,!0),r._converter)})}(this._delegate):(t==null?void 0:t.source)==="server"?function(r){r=U(r,G);var i=U(r.firestore,Y);return yu(ot(i),r._key,{source:"server"}).then(function(o){return Xi(i,r,o)})}(this._delegate):function(r){r=U(r,G);var i=U(r.firestore,Y);return yu(ot(i),r._key).then(function(o){return Xi(i,r,o)})}(this._delegate)).then(function(r){return new On(n.firestore,new Gt(n.firestore._delegate,n._userDataWriter,r._key,r._document,r.metadata,n._delegate._converter))})},e.prototype.withConverter=function(t){return new e(this.firestore,t?this._delegate.withConverter(si.tu(this.firestore,t)):this._delegate.withConverter(null))},e}();function lt(e,t,n){return e.message=e.message.replace(t,n),e}function Th(e){for(var t=0,n=e;t<n.length;t++){var r=n[t];if(typeof r=="object"&&!en(r))return r}return{}}function _h(e,t){var n,r,i;return{next:function(o){i.next&&i.next(t(o))},error:(n=(i=en(e[0])?e[0]:en(e[1])?e[1]:typeof e[0]=="function"?{next:e[0],error:e[1],complete:e[2]}:{next:e[1],error:e[2],complete:e[3]}).error)===null||n===void 0?void 0:n.bind(i),complete:(r=i.complete)===null||r===void 0?void 0:r.bind(i)}}var On=function(){function e(t,n){this._firestore=t,this._delegate=n}return Object.defineProperty(e.prototype,"ref",{get:function(){return new ge(this._firestore,this._delegate.ref)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadata",{get:function(){return this._delegate.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"exists",{get:function(){return this._delegate.exists()},enumerable:!1,configurable:!0}),e.prototype.data=function(t){return this._delegate.data(t)},e.prototype.get=function(t,n){return this._delegate.get(t,n)},e.prototype.isEqual=function(t){return dh(this._delegate,t._delegate)},e}(),Pn=function(e){function t(){return e!==null&&e.apply(this,arguments)||this}return C(t,e),t.prototype.data=function(n){return this._delegate.data(n)},t}(On),ui=function(){function e(t,n){this.firestore=t,this._delegate=n,this._userDataWriter=new oi(t)}return e.prototype.where=function(t,n,r){try{return new e(this.firestore,Ht(this._delegate,function(i,o,s){var u=o,a=Pr("where",i);return new pd(a,u,s)}(t,n,r)))}catch(i){throw lt(i,/(orderBy|where)\(\)/,"Query.$1()")}},e.prototype.orderBy=function(t,n){try{return new e(this.firestore,Ht(this._delegate,function(r,i){i===void 0&&(i="asc");var o=i,s=Pr("orderBy",r);return new dd(s,o)}(t,n)))}catch(r){throw lt(r,/(orderBy|where)\(\)/,"Query.$1()")}},e.prototype.limit=function(t){try{return new e(this.firestore,Ht(this._delegate,function(n){return Iu("limit",n),new Su("limit",n,"F")}(t)))}catch(n){throw lt(n,"limit()","Query.limit()")}},e.prototype.limitToLast=function(t){try{return new e(this.firestore,Ht(this._delegate,function(n){return Iu("limitToLast",n),new Su("limitToLast",n,"L")}(t)))}catch(n){throw lt(n,"limitToLast()","Query.limitToLast()")}},e.prototype.startAt=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return new e(this.firestore,Ht(this._delegate,(function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return new Du("startAt",r,!0)}).apply(void 0,t)))}catch(r){throw lt(r,"startAt()","Query.startAt()")}},e.prototype.startAfter=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return new e(this.firestore,Ht(this._delegate,(function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return new Du("startAfter",r,!1)}).apply(void 0,t)))}catch(r){throw lt(r,"startAfter()","Query.startAfter()")}},e.prototype.endBefore=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return new e(this.firestore,Ht(this._delegate,(function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return new Nu("endBefore",r,!0)}).apply(void 0,t)))}catch(r){throw lt(r,"endBefore()","Query.endBefore()")}},e.prototype.endAt=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return new e(this.firestore,Ht(this._delegate,(function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return new Nu("endAt",r,!1)}).apply(void 0,t)))}catch(r){throw lt(r,"endAt()","Query.endAt()")}},e.prototype.isEqual=function(t){return ih(this._delegate,t._delegate)},e.prototype.get=function(t){var n=this;return((t==null?void 0:t.source)==="cache"?function(r){r=U(r,Nt);var i=U(r.firestore,Y),o=ot(i),s=new me(i);return function(u,a){var c=this,h=new kt;return u.asyncQueue.enqueueAndForget(function(){return g(c,void 0,void 0,function(){var l;return m(this,function(f){switch(f.label){case 0:return l=function(y,p,v){return g(this,void 0,void 0,function(){var E,T,k,A,O;return m(this,function(M){switch(M.label){case 0:return M.trys.push([0,2,,3]),[4,Cr(y,p,!0)];case 1:return O=M.sent(),E=new zc(p,O.Bn),T=E._o(O.documents),k=E.applyChanges(T,!1),v.resolve(k.snapshot),[3,3];case 2:return A=M.sent(),O=hn(A,"Failed to execute query '"+p+" against cache"),v.reject(O),[3,3];case 3:return[2]}})})},[4,Zc(u)];case 1:return[2,l.apply(void 0,[f.sent(),a,h])]}})})}),h.promise}(o,r._query).then(function(u){return new Jt(i,s,r,u)})}(this._delegate):(t==null?void 0:t.source)==="server"?function(r){r=U(r,Nt);var i=U(r.firestore,Y),o=ot(i),s=new me(i);return vu(o,r._query,{source:"server"}).then(function(u){return new Jt(i,s,r,u)})}(this._delegate):function(r){r=U(r,Nt);var i=U(r.firestore,Y),o=ot(i),s=new me(i);return yh(r._query),vu(o,r._query).then(function(u){return new Jt(i,s,r,u)})}(this._delegate)).then(function(r){return new Yi(n.firestore,new Jt(n.firestore._delegate,n._userDataWriter,n._delegate,r._snapshot))})},e.prototype.onSnapshot=function(){for(var t=this,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=Th(n),o=_h(n,function(s){return new Yi(t.firestore,new Jt(t.firestore._delegate,t._userDataWriter,t._delegate,s._snapshot))});return gh(this._delegate,i,o)},e.prototype.withConverter=function(t){return new e(this.firestore,t?this._delegate.withConverter(si.tu(this.firestore,t)):this._delegate.withConverter(null))},e}(),bd=function(){function e(t,n){this._firestore=t,this._delegate=n}return Object.defineProperty(e.prototype,"type",{get:function(){return this._delegate.type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doc",{get:function(){return new Pn(this._firestore,this._delegate.doc)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"oldIndex",{get:function(){return this._delegate.oldIndex},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"newIndex",{get:function(){return this._delegate.newIndex},enumerable:!1,configurable:!0}),e}(),Yi=function(){function e(t,n){this._firestore=t,this._delegate=n}return Object.defineProperty(e.prototype,"query",{get:function(){return new ui(this._firestore,this._delegate.query)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadata",{get:function(){return this._delegate.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this._delegate.size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"empty",{get:function(){return this._delegate.empty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"docs",{get:function(){var t=this;return this._delegate.docs.map(function(n){return new Pn(t._firestore,n)})},enumerable:!1,configurable:!0}),e.prototype.docChanges=function(t){var n=this;return this._delegate.docChanges(t).map(function(r){return new bd(n._firestore,r)})},e.prototype.forEach=function(t,n){var r=this;this._delegate.forEach(function(i){t.call(n,new Pn(r._firestore,i))})},e.prototype.isEqual=function(t){return dh(this._delegate,t._delegate)},e}(),Lr=function(e){function t(n,r){var i=this;return(i=e.call(this,n,r)||this).firestore=n,i._delegate=r,i}return C(t,e),Object.defineProperty(t.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this._delegate.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){var n=this._delegate.parent;return n?new ge(this.firestore,n):null},enumerable:!1,configurable:!0}),t.prototype.doc=function(n){try{return new ge(this.firestore,n===void 0?hr(this._delegate):hr(this._delegate,n))}catch(r){throw lt(r,"doc()","CollectionReference.doc()")}},t.prototype.add=function(n){var r=this;return function(i,o){var s=U(i.firestore,Y),u=hr(i),a=ii(i._converter,o);return Rn(s,[ri(Ce(i.firestore),"addDoc",u._key,a,i._converter!==null,{}).toMutation(u._key,st.exists(!1))]).then(function(){return u})}(this._delegate,n).then(function(i){return new ge(r.firestore,i)})},t.prototype.isEqual=function(n){return rh(this._delegate,n._delegate)},t.prototype.withConverter=function(n){return new t(this.firestore,n?this._delegate.withConverter(si.tu(this.firestore,n)):this._delegate.withConverter(null))},t}(ui);function ye(e){return U(e,G)}/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Id=function(){function e(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._delegate=new(Ft.bind.apply(Ft,$([void 0],t)))}return e.documentId=function(){return new e(xt.keyField().canonicalString())},e.prototype.isEqual=function(t){return(t=X(t))instanceof Ft&&this._delegate._internalPath.isEqual(t._internalPath)},e}(),Ed=function(){function e(t){this._delegate=t}return e.serverTimestamp=function(){var t=new sd("serverTimestamp");return t._methodName="FieldValue.serverTimestamp",new e(t)},e.delete=function(){var t=new is("deleteField");return t._methodName="FieldValue.delete",new e(t)},e.arrayUnion=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=(function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return new ud("arrayUnion",i)}).apply(void 0,t);return r._methodName="FieldValue.arrayUnion",new e(r)},e.arrayRemove=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=(function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return new ad("arrayRemove",i)}).apply(void 0,t);return r._methodName="FieldValue.arrayRemove",new e(r)},e.increment=function(t){var n=function(r){return new cd("increment",r)}(t);return n._methodName="FieldValue.increment",new e(n)},e.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},e}(),Td={Firestore:bh,GeoPoint:ni,Timestamp:gt,Blob:wh,Transaction:Ih,WriteBatch:Eh,DocumentReference:ge,DocumentSnapshot:On,Query:ui,QueryDocumentSnapshot:Pn,QuerySnapshot:Yi,CollectionReference:Lr,FieldPath:Id,FieldValue:Ed,setLogLevel:wd,CACHE_SIZE_UNLIMITED:nd};/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function _d(e){(function(t,n){t.INTERNAL.registerComponent(new Rh("firestore",function(r){var i=r.getProvider("app").getImmediate();return n(i,r.getProvider("auth-internal"))},"PUBLIC").setServiceProps(Object.assign({},Td)))})(e,function(t,n){return new bh(t,new Y(t,n),new gd)}),e.registerVersion("@firebase/firestore","2.2.3")}_d(Oh);
//# sourceMappingURL=index.esm-h2kZ9fZN.js.map