PageSourceSearch

https://askaichat.app/cms_nuxt/B_8nBYrU.js

js askaichat.app collected 2026-10-02 04:17:34 UTC 307,591 bytes, 1 lines download raw bytes

1import{St as t,jt as e}from"./DIU4zoEY.js";import{A as n,B as i,C as s,D as r,E as o,F as a,G as h,H as l,I as u,J as c,K as d,M as f,N as p,O as g,P as m,R as _,S as y,T as v,U as w,V as T,W as E,X as C,Y as b,Z as I,_ as S,a as k,d as R,f as N,h as A,j as x,k as D,m as O,p as P,q as L,v as M,w as F,x as U,y as V,z as q}from"./B-mhidQU.js";import{a as j,i as B,n as H,o as W,t as $}from"./DCmQ6r5t.js";import"./BpU5WkIR.js";var z,G=[];!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(z||(z={}));var K,Q={debug:z.DEBUG,verbose:z.VERBOSE,info:z.INFO,warn:z.WARN,error:z.ERROR,silent:z.SILENT},X=z.INFO,Y={[z.DEBUG]:"log",[z.VERBOSE]:"log",[z.INFO]:"info",[z.WARN]:"warn",[z.ERROR]:"error"},J=(t,e,...n)=>{if(e<t.logLevel)return;const i=(new Date).toISOString(),s=Y[e];if(!s)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[s](`[${i}]  ${t.name}:`,...n)},Z="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},tt={};(function(){var t;function e(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}function n(t,e,n){n||(n=0);var i=Array(16);if("string"==typeof e)for(var s=0;16>s;++s)i[s]=e.charCodeAt(n++)|e.charCodeAt(n++)<<8|e.charCodeAt(n++)<<16|e.charCodeAt(n++)<<24;else for(s=0;16>s;++s)i[s]=e[n++]|e[n++]<<8|e[n++]<<16|e[n++]<<24;e=t.g[0],n=t.g[1],s=t.g[2];var r=t.g[3],o=e+(r^n&(s^r))+i[0]+3614090360&4294967295;o=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=(n=(s=(r=(e=n+(o<<7&4294967295|o>>>25))+((o=r+(s^e&(n^s))+i[1]+3905402710&4294967295)<<12&4294967295|o>>>20))+((o=s+(n^r&(e^n))+i[2]+606105819&4294967295)<<17&4294967295|o>>>15))+((o=n+(e^s&(r^e))+i[3]+3250441966&4294967295)<<22&4294967295|o>>>10))+((o=e+(r^n&(s^r))+i[4]+4118548399&4294967295)<<7&4294967295|o>>>25))+((o=r+(s^e&(n^s))+i[5]+1200080426&4294967295)<<12&4294967295|o>>>20))+((o=s+(n^r&(e^n))+i[6]+2821735955&4294967295)<<17&4294967295|o>>>15))+((o=n+(e^s&(r^e))+i[7]+4249261313&4294967295)<<22&4294967295|o>>>10))+((o=e+(r^n&(s^r))+i[8]+1770035416&4294967295)<<7&4294967295|o>>>25))+((o=r+(s^e&(n^s))+i[9]+2336552879&4294967295)<<12&4294967295|o>>>20))+((o=s+(n^r&(e^n))+i[10]+4294925233&4294967295)<<17&4294967295|o>>>15))+((o=n+(e^s&(r^e))+i[11]+2304563134&4294967295)<<22&4294967295|o>>>10))+((o=e+(r^n&(s^r))+i[12]+1804603682&4294967295)<<7&4294967295|o>>>25))+((o=r+(s^e&(n^s))+i[13]+4254626195&4294967295)<<12&4294967295|o>>>20))+((o=s+(n^r&(e^n))+i[14]+2792965006&4294967295)<<17&4294967295|o>>>15))+((o=n+(e^s&(r^e))+i[15]+1236535329&4294967295)<<22&4294967295|o>>>10))+((o=e+(s^r&(n^s))+i[1]+4129170786&4294967295)<<5&4294967295|o>>>27))+((o=r+(n^s&(e^n))+i[6]+3225465664&4294967295)<<9&4294967295|o>>>23))+((o=s+(e^n&(r^e))+i[11]+643717713&4294967295)<<14&4294967295|o>>>18))+((o=n+(r^e&(s^r))+i[0]+3921069994&4294967295)<<20&4294967295|o>>>12))+((o=e+(s^r&(n^s))+i[5]+3593408605&4294967295)<<5&4294967295|o>>>27))+((o=r+(n^s&(e^n))+i[10]+38016083&4294967295)<<9&4294967295|o>>>23))+((o=s+(e^n&(r^e))+i[15]+3634488961&4294967295)<<14&4294967295|o>>>18))+((o=n+(r^e&(s^r))+i[4]+3889429448&4294967295)<<20&4294967295|o>>>12))+((o=e+(s^r&(n^s))+i[9]+568446438&4294967295)<<5&4294967295|o>>>27))+((o=r+(n^s&(e^n))+i[14]+3275163606&4294967295)<<9&4294967295|o>>>23))+((o=s+(e^n&(r^e))+i[3]+4107603335&4294967295)<<14&4294967295|o>>>18))+((o=n+(r^e&(s^r))+i[8]+1163531501&4294967295)<<20&4294967295|o>>>12))+((o=e+(s^r&(n^s))+i[13]+2850285829&4294967295)<<5&4294967295|o>>>27))+((o=r+(n^s&(e^n))+i[2]+4243563512&4294967295)<<9&4294967295|o>>>23))+((o=s+(e^n&(r^e))+i[7]+1735328473&4294967295)<<14&4294967295|o>>>18))+((o=n+(r^e&(s^r))+i[12]+2368359562&4294967295)<<20&4294967295|o>>>12))+((o=e+(n^s^r)+i[5]+4294588738&4294967295)<<4&4294967295|o>>>28))+((o=r+(e^n^s)+i[8]+2272392833&4294967295)<<11&4294967295|o>>>21))+((o=s+(r^e^n)+i[11]+1839030562&4294967295)<<16&4294967295|o>>>16))+((o=n+(s^r^e)+i[14]+4259657740&4294967295)<<23&4294967295|o>>>9))+((o=e+(n^s^r)+i[1]+2763975236&4294967295)<<4&4294967295|o>>>28))+((o=r+(e^n^s)+i[4]+1272893353&4294967295)<<11&4294967295|o>>>21))+((o=s+(r^e^n)+i[7]+4139469664&4294967295)<<16&4294967295|o>>>16))+((o=n+(s^r^e)+i[10]+3200236656&4294967295)<<23&4294967295|o>>>9))+((o=e+(n^s^r)+i[13]+681279174&4294967295)<<4&4294967295|o>>>28))+((o=r+(e^n^s)+i[0]+3936430074&4294967295)<<11&4294967295|o>>>21))+((o=s+(r^e^n)+i[3]+3572445317&4294967295)<<16&4294967295|o>>>16))+((o=n+(s^r^e)+i[6]+76029189&4294967295)<<23&4294967295|o>>>9))+((o=e+(n^s^r)+i[9]+3654602809&4294967295)<<4&4294967295|o>>>28))+((o=r+(e^n^s)+i[12]+3873151461&4294967295)<<11&4294967295|o>>>21))+((o=s+(r^e^n)+i[15]+530742520&4294967295)<<16&4294967295|o>>>16))+((o=n+(s^r^e)+i[2]+3299628645&4294967295)<<23&4294967295|o>>>9))+((o=e+(s^(n|~r))+i[0]+4096336452&4294967295)<<6&4294967295|o>>>26))+((o=r+(n^(e|~s))+i[7]+1126891415&4294967295)<<10&4294967295|o>>>22))+((o=s+(e^(r|~n))+i[14]+2878612391&4294967295)<<15&4294967295|o>>>17))+((o=n+(r^(s|~e))+i[5]+4237533241&4294967295)<<21&4294967295|o>>>11))+((o=e+(s^(n|~r))+i[12]+1700485571&4294967295)<<6&4294967295|o>>>26))+((o=r+(n^(e|~s))+i[3]+2399980690&4294967295)<<10&4294967295|o>>>22))+((o=s+(e^(r|~n))+i[10]+4293915773&4294967295)<<15&4294967295|o>>>17))+((o=n+(r^(s|~e))+i[1]+2240044497&4294967295)<<21&4294967295|o>>>11))+((o=e+(s^(n|~r))+i[8]+1873313359&4294967295)<<6&4294967295|o>>>26))+((o=r+(n^(e|~s))+i[15]+4264355552&4294967295)<<10&4294967295|o>>>22))+((o=s+(e^(r|~n))+i[6]+2734768916&4294967295)<<15&4294967295|o>>>17))+((o=n+(r^(s|~e))+i[13]+1309151649&4294967295)<<21&4294967295|o>>>11))+((r=(e=n+((o=e+(s^(n|~r))+i[4]+4149444226&4294967295)<<6&4294967295|o>>>26))+((o=r+(n^(e|~s))+i[11]+3174756917&4294967295)<<10&4294967295|o>>>22))^((s=r+((o=s+(e^(r|~n))+i[2]+718787259&4294967295)<<15&4294967295|o>>>17))|~e))+i[9]+3951481745&4294967295,t.g[0]=t.g[0]+e&4294967295,t.g[1]=t.g[1]+(s+(o<<21&4294967295|o>>>11))&4294967295,t.g[2]=t.g[2]+s&4294967295,t.g[3]=t.g[3]+r&4294967295}function i(t,e){this.h=e;for(var n=[],i=!0,s=t.length-1;0<=s;s--){var r=0|t[s];i&&r==e||(n[s]=r,i=!1)}this.g=n}!function(t,e){function n(){}n.prototype=e.prototype,t.D=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.C=function(t,n,i){for(var s=Array(arguments.length-2),r=2;r<arguments.length;r++)s[r-2]=arguments[r];return e.prototype[n].apply(t,s)}}(e,function(){this.blockSize=-1}),e.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},e.prototype.u=function(t,e){void 0===e&&(e=t.length);for(var i=e-this.blockSize,s=this.B,r=this.h,o=0;o<e;){if(0==r)for(;o<=i;)n(this,t,o),o+=this.blockSize;if("string"==typeof t){for(;o<e;)if(s[r++]=t.charCodeAt(o++),r==this.blockSize){n(this,s),r=0;break}}else for(;o<e;)if(s[r++]=t[o++],r==this.blockSize){n(this,s),r=0;break}}this.h=r,this.o+=e},e.prototype.v=function(){var t=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);t[0]=128;for(var e=1;e<t.length-8;++e)t[e]=0;var n=8*this.o;for(e=t.length-8;e<t.length;++e)t[e]=255&n,n/=256;for(this.u(t),t=Array(16),e=n=0;4>e;++e)for(var i=0;32>i;i+=8)t[n++]=this.g[e]>>>i&255;return t};var s={};function r(t){return-128<=t&&128>t?function(t,e){var n=s;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(t,function(t){return new i([0|t],0>t?-1:0)}):new i([0|t],0>t?-1:0)}function o(t){if(isNaN(t)||!isFinite(t))return a;
1if(0>t)return d(o(-t));for(var e=[],n=1,s=0;t>=n;s++)e[s]=t/n|0,n*=4294967296;return new i(e,0)}var a=r(0),h=r(1),l=r(16777216);function u(t){if(0!=t.h)return!1;for(var e=0;e<t.g.length;e++)if(0!=t.g[e])return!1;return!0}function c(t){return-1==t.h}function d(t){for(var e=t.g.length,n=[],s=0;s<e;s++)n[s]=~t.g[s];return new i(n,~t.h).add(h)}function f(t,e){return t.add(d(e))}function p(t,e){for(;(65535&t[e])!=t[e];)t[e+1]+=t[e]>>>16,t[e]&=65535,e++}function g(t,e){this.g=t,this.h=e}function m(t,e){if(u(e))throw Error("division by zero");if(u(t))return new g(a,a);if(c(t))return e=m(d(t),e),new g(d(e.g),d(e.h));if(c(e))return e=m(t,d(e)),new g(d(e.g),e.h);if(30<t.g.length){if(c(t)||c(e))throw Error("slowDivide_ only works with positive integers.");for(var n=h,i=e;0>=i.l(t);)n=_(n),i=_(i);var s=y(n,1),r=y(i,1);for(i=y(i,2),n=y(n,2);!u(i);){var l=r.add(i);0>=l.l(t)&&(s=s.add(n),r=l),i=y(i,1),n=y(n,1)}return e=f(t,s.j(e)),new g(s,e)}for(s=a;0<=t.l(e);){for(n=Math.max(1,Math.floor(t.m()/e.m())),i=48>=(i=Math.ceil(Math.log(n)/Math.LN2))?1:Math.pow(2,i-48),l=(r=o(n)).j(e);c(l)||0<l.l(t);)l=(r=o(n-=i)).j(e);u(r)&&(r=h),s=s.add(r),t=f(t,l)}return new g(s,t)}function _(t){for(var e=t.g.length+1,n=[],s=0;s<e;s++)n[s]=t.i(s)<<1|t.i(s-1)>>>31;return new i(n,t.h)}function y(t,e){var n=e>>5;e%=32;for(var s=t.g.length-n,r=[],o=0;o<s;o++)r[o]=0<e?t.i(o+n)>>>e|t.i(o+n+1)<<32-e:t.i(o+n);return new i(r,t.h)}(t=i.prototype).m=function(){if(c(this))return-d(this).m();for(var t=0,e=1,n=0;n<this.g.length;n++){var i=this.i(n);t+=(0<=i?i:4294967296+i)*e,e*=4294967296}return t},t.toString=function(t){if(2>(t=t||10)||36<t)throw Error("radix out of range: "+t);if(u(this))return"0";if(c(this))return"-"+d(this).toString(t);for(var e=o(Math.pow(t,6)),n=this,i="";;){var s=m(n,e).g,r=((0<(n=f(n,s.j(e))).g.length?n.g[0]:n.h)>>>0).toString(t);if(u(n=s))return r+i;for(;6>r.length;)r="0"+r;i=r+i}},t.i=function(t){return 0>t?0:t<this.g.length?this.g[t]:this.h},t.l=function(t){return c(t=f(this,t))?-1:u(t)?0:1},t.abs=function(){return c(this)?d(this):this},t.add=function(t){for(var e=Math.max(this.g.length,t.g.length),n=[],s=0,r=0;r<=e;r++){var o=s+(65535&this.i(r))+(65535&t.i(r)),a=(o>>>16)+(this.i(r)>>>16)+(t.i(r)>>>16);s=a>>>16,o&=65535,a&=65535,n[r]=a<<16|o}return new i(n,-2147483648&n[n.length-1]?-1:0)},t.j=function(t){if(u(this)||u(t))return a;if(c(this))return c(t)?d(this).j(d(t)):d(d(this).j(t));if(c(t))return d(this.j(d(t)));if(0>
1this.l(l)&&0>t.l(l))return o(this.m()*t.m());for(var e=this.g.length+t.g.length,n=[],s=0;s<2*e;s++)n[s]=0;for(s=0;s<this.g.length;s++)for(var r=0;r<t.g.length;r++){var h=this.i(s)>>>16,f=65535&this.i(s),g=t.i(r)>>>16,m=65535&t.i(r);n[2*s+2*r]+=f*m,p(n,2*s+2*r),n[2*s+2*r+1]+=h*m,p(n,2*s+2*r+1),n[2*s+2*r+1]+=f*g,p(n,2*s+2*r+1),n[2*s+2*r+2]+=h*g,p(n,2*s+2*r+2)}for(s=0;s<e;s++)n[s]=n[2*s+1]<<16|n[2*s];for(s=e;s<2*e;s++)n[s]=0;return new i(n,0)},t.A=function(t){return m(this,t).h},t.and=function(t){for(var e=Math.max(this.g.length,t.g.length),n=[],s=0;s<e;s++)n[s]=this.i(s)&t.i(s);return new i(n,this.h&t.h)},t.or=function(t){for(var e=Math.max(this.g.length,t.g.length),n=[],s=0;s<e;s++)n[s]=this.i(s)|t.i(s);return new i(n,this.h|t.h)},t.xor=function(t){for(var e=Math.max(this.g.length,t.g.length),n=[],s=0;s<e;s++)n[s]=this.i(s)^t.i(s);return new i(n,this.h^t.h)},e.prototype.digest=e.prototype.v,e.prototype.reset=e.prototype.s,e.prototype.update=e.prototype.u,tt.Md5=e,i.prototype.add=i.prototype.add,i.prototype.multiply=i.prototype.j,i.prototype.modulo=i.prototype.A,i.prototype.compare=i.prototype.l,i.prototype.toNumber=i.prototype.m,i.prototype.toString=i.prototype.toString,i.prototype.getBits=i.prototype.i,i.fromNumber=o,i.fromString=function t(e,n){if(0==e.length)throw Error("number format error: empty string");if(2>(n=n||10)||36<n)throw Error("radix out of range: "+n);if("-"==e.charAt(0))return d(t(e.substring(1),n));if(0<=e.indexOf("-"))throw Error('number format error: interior "-" character');for(var i=o(Math.pow(n,8)),s=a,r=0;r<e.length;r+=8){var h=Math.min(8,e.length-r),l=parseInt(e.substring(r,r+h),n);8>h?(h=o(Math.pow(n,h)),s=s.j(h).add(o(l))):s=(s=s.j(i)).add(o(l))}return s},K=tt.Integer=i}).apply(void 0!==Z?Z:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var et,nt,it,st,rt,ot,at,ht,lt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},ut={};(function(){var t,e="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,n){return t==Array.prototype||t==Object.prototype||(t[e]=n.value),t};var n=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof lt&&lt];for(var e=0;e<t.length;++e){var n=t[e];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")}(this);!function(t,i){if(i)t:{var s=n;t=t.split(".");for(var r=0;r<t.length-1;r++){var o=t[r];if(!(o in s))break t;s=s[o]}(i=i(r=s[t=t[t.length-1]]))!=r&&null!=i&&e(s,t,{configurable:!0,writable:!0,value:i})}}("Array.prototype.values",function(t){return t||function(){return function(t,e){t instanceof String&&(t+="");var n=0,i=!1,s={next:function(){if(!i&&n<t.length){var s=n++;return{value:e(s,t[s]),done:!1}}return i=!0,{done:!0,value:void 0}}};return s[Symbol.iterator]=function(){return s},s}(this,function(t,e){return e})}});var i=i||{},s=this||self;function r(t){var e=typeof t;return"array"==(e="object"!=e?e:t?Array.isArray(t)?"array":e:"null")||"object"==e&&"number"==typeof t.length}function o(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}function a(t,e,n){return t.call.apply(t.bind,arguments)}function h(t,e,n){if(!t)throw Error();if(2<arguments.length){var i=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,i),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function l(t,e,n){return(l=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?a:h).apply(null,arguments)}function u(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}function c(t,e){function n(){}n.prototype=e.prototype,t.aa=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.Qb=function(t,n,i){for(var s=Array(arguments.length-2),r=2;r<arguments.length;r++)s[r-2]=arguments[r];return e.prototype[n].apply(t,s)}}function d(t){const e=t.length;if(0<e){const n=Array(e);for(let i=0;i<e;i++)n[i]=t[i];return n}return[]}function f(t,e){for(let n=1;n<arguments.length;n++){const e=arguments[n];if(r(e)){const n=t.length||0,i=e.length||0;t.length=n+i;for(let s=0;s<i;s++)t[n+s]=e[s]}else t.push(e)}}function p(t){return/^[\s\xa0]*$/.test(t)}function g(){var t=s.navigator;return t&&(t=t.userAgent)?t:""}function m(t){return m[" "](t),t}m[" "]=function(){};var _=!(-1==g().indexOf("Gecko")||-1!=g().toLowerCase().indexOf("webkit")&&-1==g().indexOf("Edge")||-1!=g().indexOf("Trident")||-1!=g().indexOf("MSIE")||-1!=g().indexOf("Edge"));function y(t,e,n){for(const i in t)e.call(n,t[i],i,t)}function v(t){const e={};for(const n in t)e[n]=t[n];return e}const w="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleStr
1ing toString valueOf".split(" ");function T(t,e){let n,i;for(let s=1;s<arguments.length;s++){for(n in i=arguments[s],i)t[n]=i[n];for(let e=0;e<w.length;e++)n=w[e],Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}}function E(t){var e=1;t=t.split(":");const n=[];for(;0<e&&t.length;)n.push(t.shift()),e--;return t.length&&n.push(t.join(":")),n}function C(t){s.setTimeout(()=>{throw t},0)}function b(){var t=N;let e=null;return t.g&&(e=t.g,t.g=t.g.next,t.g||(t.h=null),e.next=null),e}var I=new class{constructor(t,e){this.i=t,this.j=e,this.h=0,this.g=null}get(){let t;return 0<this.h?(this.h--,t=this.g,this.g=t.next,t.next=null):t=this.i(),t}}(()=>new S,t=>t.reset());class S{constructor(){this.next=this.g=this.h=null}set(t,e){this.h=t,this.g=e,this.next=null}reset(){this.next=this.g=this.h=null}}let k,R=!1,N=new class{constructor(){this.h=this.g=null}add(t,e){const n=I.get();n.set(t,e),this.h?this.h.next=n:this.g=n,this.h=n}},A=()=>{const t=s.Promise.resolve(void 0);k=()=>{t.then(x)}};var x=()=>{for(var t;t=b();){try{t.h.call(t.g)}catch(n){C(n)}var e=I;e.j(t),100>e.h&&(e.h++,t.next=e.g,e.g=t)}R=!1};function D(){this.s=this.s,this.C=this.C}function O(t,e){this.type=t,this.g=this.target=e,this.defaultPrevented=!1}D.prototype.s=!1,D.prototype.ma=function(){this.s||(this.s=!0,this.N())},D.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},O.prototype.h=function(){this.defaultPrevented=!0};var P=function(){if(!s.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{const t=()=>{};s.addEventListener("test",t,e),s.removeEventListener("test",t,e)}catch(n){}return t}();function L(t,e){if(O.call(this,t?t.type:""),this.relatedTarget=this.g=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.state=null,this.pointerId=0,this.pointerType="",this.i=null,t){var n=this.type=t.type,i=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.g=e,e=t.relatedTarget){if(_){t:{try{m(e.nodeName);var s=!0;break t}catch(r){}s=!1}s||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,i?(this.clientX=void 0!==i.clientX?i.clientX:i.pageX,this.clientY=void 0!==i.clientY?i.clientY:i.pageY,this.screenX=i.screenX||0,this.screenY=i.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:M[t.pointerType]||"",this.state=t.state,this.i=t,t.defaultPrevented&&L.aa.h.call(this)}}c(L,O);var M={2:"touch",3:"pen",4:"mouse"};L.prototype.h=function(){L.aa.h.call(this);var t=this.i;t.preventDefault?t.preventDefault():t.returnValue=!1};var F="closure_listenable_"+(1e6*Math.random()|0),U=0;function V(t,e,n,i,s){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!i,this.ha=s,this.key=++U,this.da=this.fa=!1}function q(t){t.da=!0,t.listener=null,t.proxy=null,t.src=null,t.ha=null}function j(t){this.src=t,this.g={},this.h=0}function B(t,e){var n=e.type;if(n in t.g){var i,s=t.g[n],r=Array.prototype.indexOf.call(s,e,void 0);(i=0<=r)&&Array.prototype.splice.call(s,r,1),i&&(q(e),0==t.g[n].length&&(delete t.g[n],t.h--))}}function H(t,e,n,i){for(var s=0;s<t.length;++s){var r=t[s];if(!r.da&&r.listener==e&&r.capture==!!n&&r.ha==i)return s}return-1}j.prototype.add=function(t,e,n,i,s){var r=t.toString();(t=this.g[r])||(t=this.g[r]=[],this.h++);var o=H(t,e,i,s);return-1<o?(e=t[o],n||(e.fa=!1)):((e=new V(e,this.src,r,!!i,s)).fa=n,t.push(e)),e};var W="closure_lm_"+(1e6*Math.random()|0),$={};function z(t,e,n,i,s){if(i&&i.once)return K(t,e,n,i,s);if(Array.isArray(e)){for(var r=0;r<e.length;r++)z(t,e[r],n,i,s);return null}return n=ct(n),t&&t[F]?t.K(e,n,o(i)?!!i.capture:!!i,s):G(t,e,n,!1,i,s)}function G(t,e,n,i,s,r){if(!e)throw Error("Invalid event type");var a=o(s)?!!s.capture:!!s,h=Z(t);if(h||(t[W]=h=new j(t)),(n=h.add(e,n,i,a,r)).proxy)return n;if(i=function(){function t(n){return e.call(t.src,t.listener,n)}const e=J;return t}(),n.proxy=i,i.src=t,i.listener=n,t.addEventListener)P||(s=a),void 0===s&&(s=!1),t.addEventListener(e.toString(),i,s);else if(t.attachEvent)t.attachEvent(Y(e.toString()),i);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(i)}return n}function K(t,e,n,i,s){if(Array.isArray(e)){for(var r=0;r<e.length;r++)K(t,e[r],n,i,s);return null}return n=ct(n),t&&t[F]?t.L(e,n,o(i)?!!i.capture:!!i,s):G(t,e,n,!0,i,s)}function Q(t,e,n,i,s){if(Array.isArray(e))for(var r=0;r<e.length;r++)Q(t,e[r],n,i,s);else i=o(i)?!!i.capture:!!i,n=ct(n),t&&t[F]?(t=t.i,(e=String(e).toString())in t.g&&(-1<(n=H(r=t.g[e],n,i,s))&&(q(r[n]),Array.prototype.splice.call(r,n,1),0==r.length&&(delete t.g[e],t.h--)))):t&&(t=Z(t))&&(e=t.g[e.toString()],t=-1,e&&(t=H(e,n,i,s)),(n=-1<t?e[t]:null)&&X(n))}function X(t){if("number"!=typeof t&&t&&!t.da){var e=t.src;if(e&&e[F])B(e.i,t);else{var n=t.type,i=t.proxy;e.removeEventListener?e.removeEventListener(n,i,t.capture):e.detachEvent?e.detachEvent(Y(n),i):e.addListener&&e.removeListener&&e.removeListener(i),(n=Z(e))?(B(n,t),0==n.h&&(n.src=null,e[W]=null)):q(t)}}}function Y(t){return t in $?$[t]:$[t]="on"+t}function J(t,e){if(t.da)t=!0;else{e=new L(e,this);var n=t.listener,i=t.ha||t.src;t.fa&&X(t),t=n.call(i,e)}return t}function Z(t){return(t=t[W])instanceof j?t:null}var tt="__closure_events_fn_"+(1e9*Math.random()>>>0);function ct(t){return"function"==typeof t?t:(t[tt]||(t[tt]=function(e){return t.handleEvent(e)}),t[tt])}function dt(){D.call(this),this.i=new j(this),this.M=this,this.F=null}function ft(t,e){var n,i=t.F;if(i)for(n=[];i;i=i.F)n.push(i);if(t=t.M,i=e.type||e,"string"==typeof e)e=new O(e,t);else if(e instanceof O)e.target=e.target||t;else{var s=e;T(e=new O(i,t),s)}if(s=!0,n)for(var r=n.length-1;0<=r;r--){var o=e.g=n[r];s=pt(o,i,!0,e)&&s}if(s=pt(o=e.g=t,i,!0,e)&&s,s=pt(o,i,!1,e)&&s,n)for(r=0;r<n.length;r++)s=pt(o=e.g=n[r],i,!1,e)&&s}function pt(t,e,n,i){if(!(e=t.i.g[String(e)]))return!0;e=e.concat();for(var s=!0,r=0;r<e.length;++r){var o=e[r];if(o&&!o.da&&o.capture==n){var a=o.listener,h=o.ha||o.src;o.fa&&B(t.i,o),s=!1!==a.call(h,i)&&s}}return s&&!i.defaultPrevented}function gt(t,e,n){if("function"==typeof t)n&&(t=l(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=l(t.handleEvent,t)}return 2147483647<Number(e)?-1:s.setTimeout(t,e||0)}function mt(t){t.g=gt(()=>{t.g=null,t.i&&(t.i=!1,mt(t))},t.l);const e=t.h;t.h=null,t.m.apply(null,e)}c(dt,D),dt.prototype[F]=!0,dt.prototype.removeEventListener=function(t,e,n,i){Q(this,t,e,n,i)},dt.prototype.N=function(){if(dt.aa.N.call(this),this.i){var t,e=this.i;for(t in e.g){for(var n=e.g[t],i=0;i<n.length;i++)q(n[i]);delete e.g[t],e.h--}}this.F=null},dt.prototype.K=function(t,e,n,i){return this.i.add(String(t),e,!1,n,i)},dt.prototype.L=function(t,e,n,i){return this.i.add(String(t),e,!0,n,i)};class _t extends D{constructor(t,e){super(),this.m=t,this.l=e,this.h=null,this.i=!1,this.g=null}j(t){this.h=arguments,this.g?this.i=!0:mt(this)}N(){super.N(),this.g&&(s.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function yt(t){D.call(this),this.h=t,this.g={}}c(yt,D);var vt=[];function wt(t){y(t.g,function(t,e){this.g.hasOwnProperty(e)&&X(t)},t),t.g={}}yt.prototype.N=function(){yt.aa.N.call(this),wt(this)},yt.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Tt=s.JSON.stringify,Et=s.JSON.parse,Ct=class{stringify(t){return s.JSON.stringify(t,void 0)}parse(t){return s.JSON.parse(t,void 0)}};function bt(){}function It(t){return t.h||(t.h=t.i())}function St(){}bt.prototype.h=null;var kt={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function Rt(){O.call(this,"d")}function Nt(){O.call(this,"c")}c(Rt,O),c(Nt,O);var At={},xt=null;function Dt(){return xt=xt||new dt}function Ot(t){O.call(this,At.La,t)}function Pt(t){const e=Dt();ft(e,new Ot(e))}function Lt(t,e){O.call(this,At.STAT_EVENT,t),this.stat=e}function Mt(t){const e=Dt();ft(e,new Lt(e,t))}function Ft(t,e){O.call(this,At.Ma,t),this.size=e}function Ut(t,e){if("function"!=typeof t)throw Error("Fn must not be null and must be a function");return s.setTimeout(function(){t()},e)}function Vt(){this.g=!0}function qt(t,e,n,i){t.info(function(){return"XMLHTTP TEXT ("+e+"): "+function(t,e){if(!t.g)return e;if(!e)return null;try{var n=JSON.parse(e);if(n)for(t=0;t<n.length;t++)if(Array.isArray(n[t])){var i=n[t];if(!(2>i.length)){var s=i[1];if(Array.isArray(s)&&!(1>s.length)){var r=s[0];if("noop"!=r&&"stop"!=r&&"close"!=r)for(var o=1;o<s.length;o++)s[o]=""}}}return Tt(n)}catch(a){return e}}(t,n)+(i?" "+i:"")})}At.La="serverreachability",c(Ot,O),At.STAT_EVENT="statevent",c(Lt,O),At.Ma="timingevent",c(Ft,O),Vt.prototype.xa=function(){this.g=!1},Vt.prototype.info=function(){};var jt,Bt={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},Ht={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"};function Wt(){}function $t(t,e,n,i){this.j=t,this.i=e,this.l=n,this.R=i||1,this.U=new yt(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new zt}function zt(){this.i=null,this.g="",this.h=!1}c(Wt,bt),Wt.prototype.g=function(){return new XMLHttpRequest},Wt.prototype.i=function(){return{}},jt=new Wt;var Gt={},Kt={};function Qt(t,e,n){t.L=1,t.v=Te(me(e)),t.m=n,t.P=!0,Xt(t,null)}function Xt(t,e){t.F=Date.now(),Zt(t),t.A=me(t.v);var n=t.A,i=t.R;Array.isArray(i)||(i=[String(i)]),Le(n.i,"t",i),t.C=0,n=t.j.J,t.h=new zt,t.g=Cn(t.j,n?e:null,!t.m),0<t.O&&(t.M=new _t(l(t.Y,t,t.g),t.O)),e=t.U,n=t.g,i=t.ca;var s="readystatechange";Array.isArray(s)||(s&&(vt[0]=s.toString()),s=vt);for(var r=0;r<s.length;r++){var o=z(n,s[r],i||e.handleEvent,!1,e.h||e);if(!o)break;e.g[o.key]=o}e=t.H?v(t.H):{},t.m?(t.u||(t.u="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.g.ea(t.A,t.u,t.m,e)):(t.u="GET",t.g.ea(t.A,t.u,null,e)),Pt(),function(t,e,n,i,s,r){t.info(function(){if(t.g)if(r)for(var o="",a=r.split("&"),h=0;h<a.length;h++){var l=a[h].split("=");if(1<l.length){var u=l[0];l=l[1];var c=u.split("_");o=2<=c.length&&"type"==c[1]?o+(u+"=")+l+"&":o+(u+"=redacted&")}}else o=null;else o=r;return"XMLHTTP REQ ("+i+") [attempt "+s+"]: "+e+"\n"+n+"\n"+o})}(t.i,t.u,t.A,t.l,t.R,t.m)}function Yt(t){return!!t.g&&("GET"==t.u&&2!=t.L&&t.j.Ca)}function Jt(t,e){var n=t.C,i=e.indexOf("\n",n);return-1==i?Kt:(n=Number(e.substring(n,i)),isNaN(n)?Gt:(i+=1)+n>e.length?Kt:(e=e.slice(i,i+n),t.C=i+n,e))}function Zt(t){t.S=Date.now()+t.I,te(t,t.I)}function te(t,e){if(null!=t.B)throw Error("WatchDog timer not null");t.B=Ut(l(t.ba,t),e)}function ee(t){t.B&&(s.clearTimeout(t.B),t.B=null)}function ne(t){0==t.j.G||t.J||yn(t.j,t)}function ie(t){ee(t);var e=t.M;e&&"function"==typeof e.ma&&e.ma(),t.M=null,wt(t.U),t.g&&(e=t.g,t.g=null,e.abort(),e.ma())}function se(t,e){try{var n=t.j;if(0!=n.G&&(n.g==t||le(n.h,t)))if(!t.K&&le(n.h,t)&&3==n.G){try{var i=n.Da.g.parse(e)}catch(u){i=null}if(Array.isArray(i)&&3==i.length){var s=i;if(0==s[0]){t:if(!n.u){if(n.g){if(!(n.g.F+3e3<t.F))break t;_n(n),an(n)}pn(n),Mt(18)}}else n.za=s[1],0<n.za-n.T&&37500>s[2]&&n.F&&0==n.v&&!n.C&&(n.C=Ut(l(n.Za,n),6e3));if(1>=he(n.h)&&n.ca){try{n.ca()}catch(u){}n.ca=void 0}}else wn(n,11)}else if((t.K||n.g==t)&&_n(n),!p(e))for(s=n.Da.g.parse(e),e=0;e<s.length;e++){let l=s[e];if(n.T=l[0],l=l[1],2==n.G)if("c"==l[0]){n.K=l[1],n.ia=l[2];const e=l[3];null!=e&&(n.la=e,n.j.info("VER="+n.la));const s=l[4];null!=s&&(n.Aa=s,n.j.info("SVER="+n.Aa));const u=l[5];null!=u&&"number"==typeof u&&0<u&&(i=1.5*u,n.L=i,n.j.info("backChannelRequestTimeoutMs_="+i)),i=n;const c=t.g;if(c){const t=c.g?c.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(t){var r=i.h;r.g||-1==t.indexOf("spdy")&&-1==t.indexOf("quic")&&-1==t.indexOf("h2")||(r.j=r.l,r.g=new Set,r.h&&(ue(r,r.h),r.h=null))}if(i.D){const t=c.g?c.g.getResponseHeader("X-HTTP-Session-Id"):null;t&&(i.ya=t,we(i.I,i.D,t))}}n.G=3,n.l&&n.l.ua(),n.ba&&(n.R=Date.now()-t.F,n.j.info("Handshake RTT: "+n.R+"ms"));var o=t;if((i=n).qa=En(i,i.J?i.ia:null,i.W),o.K){ce(i.h,o);var a=o,h=i.L;h&&(a.I=h),a.B&&(ee(a),Zt(a)),i.g=o}else fn(i);0<n.i.length&&ln(n)}else"stop"!=l[0]&&"close"!=l[0]||wn(n,7);else 3==n.G&&("stop"==l[0]||"close"==l[0]?"stop"==l[0]?wn(n,7):on(n):"noop"!=l[0]&&n.l&&n.l.ta(l),n.v=0)}Pt()}catch(u){}}$t.prototype.ca=function(t){t=t.target;const e=this.M;e&&3==en(t)?e.j():this.Y(t)},$t.prototype.Y=function(t){try{if(t==this.g)t:{const d=en(this.g);var e=this.g.Ba();this.g.Z();if(!(3>d)&&(3!=d||this.g&&(this.h.h||this.g.oa()||nn(this.g)))){this.J||4!=d||7==e||Pt(),ee(this);var n=this.g.Z();this.X=n;e:if(Yt(this)){var i=nn(this.g);t="";var r=i.length,o=4==en(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){ie(this),ne(this);var a="";break e}this.h.i=new s.TextDecoder}for(e=0;e<r;e++)this.h.h=!0,t+=this.h.i.decode(i[e],{stream:!(o&&e==r-1)});i.length=0,this.h.g+=t,this.C=0,a=this.h.g}else a=this.g.oa();if(this.o=200==n,function(t,e,n,i,s,r,o){t.info(function(){return"XMLHTTP RESP ("+i+") [ attempt "+s+"]: "+e+"\n"+n+"\n"+r+" "+o})}(this.i,this.u,this.A,this.l,this.R,d,n),this.o){if(this.T&&!this.K){e:{if(this.g){var h,l=this.g;if((h=l.g?l.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!p(h)){var u=h;break e}}u=null}if(!(n=u)){this.o=!1,this.s=3,Mt(12),ie(this),ne(this);break t}qt(this.i,this.l,n,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,se(this,n)}if(this.P){let t;for(n=!0;!this.J&&this.C<a.length;){if(t=Jt(this,a),t==Kt){4==d&&(this.s=4,Mt(14),n=!1),qt(this.i,this.l,null,"[Incomplete Response]");break}if(t==Gt){this.s=4,Mt(15),qt(this.i,this.l,a,"[Invalid Chunk]"),n=!1;break}qt(this.i,this.l,t,null),se(this,t)}if(Yt(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=d||0!=a.length||this.h.h||(this.s=1,Mt(16),n=!1),this.o=this.o&&n,n){if(0<a.length&&!this.W){this.W=!0;var c=this.j;c.g==this&&c.ba&&!c.M&&(c.j.info("Great, no buffering proxy detected. Bytes received: "+a.length),gn(c),c.M=!0,Mt(11))}}else qt(this.i,this.l,a,"[Invalid Chunked Response]"),ie(this),ne(this)}else qt(this.i,this.l,a,null),se(this,a);4==d&&ie(this),this.o&&!this.J&&(4==d?yn(this.j,this):(this.o=!1,Zt(this)))}else(function(t){const e={};t=(t.g&&2<=en(t)&&t.g.getAllResponseHeaders()||"").split("\r\n");for(let i=0;i<t.length;i++){if(p(t[i]))continue;var n=E(t[i]);const s=n[0];if("string"!=typeof(n=n[1]))continue;n=n.trim();const r=e[s]||[];e[s]=r,r.push(n)}!function(t,e){for(const n in t)e.call(void 0,t[n],n,t)}(e,function(t){return t.join(", ")})})(this.g),400==n&&0<a.indexOf("Unknown SID")?(this.s=3,Mt(12)):(this.s=0,Mt(13)),ie(this),ne(this)}}}catch(d){}},$t.prototype.cancel=function(){this.J=!0,ie(this)},$t.prototype.ba=function(){this.B=null;const t=Date.now();0<=t-this.S?(function(t,e){t.info(function(){return"TIMEOUT: "+e})}(this.i,this.A),2!=this.L&&(Pt(),Mt(17)),ie(this),this.s=2,ne(this)):te(this,this.S-t)};var re=class{constructor(t,e){this.g=t,this.map=e}};function oe(t){this.l=t||10,s.PerformanceNavigationTiming?t=0<(t=s.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):t=!!(s.chrome&&s.chrome.loadTimes&&s.chrome.loadTimes()&&s.chrome.loadTimes().wasFetchedViaSpdy),this.j=t?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function ae(t){return!!t.h||!!t.g&&t.g.size>=t.j}function he(t){return t.h?1:t.g?t.g.size:0}function le(t,e){return t.h?t.h==e:!!t.g&&t.g.has(e)}function ue(t,e){t.g?t.g.add(e):t.h=e}function ce(t,e){t.h&&t.h==e?t.h=null:t.g&&t.g.has(e)&&t.g.delete(e)}function de(t){if(null!=t.h)return t.i.concat(t.h.D);if(null!=t.g&&0!==t.g.size){let e=t.i;for(const n of t.g.values())e=e.concat(n.D);return e}return d(t.i)}function fe(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(r(t)||"st
1ring"==typeof t)Array.prototype.forEach.call(t,e,void 0);else for(var n=function(t){if(t.na&&"function"==typeof t.na)return t.na();if(!t.V||"function"!=typeof t.V){if("undefined"!=typeof Map&&t instanceof Map)return Array.from(t.keys());if(!("undefined"!=typeof Set&&t instanceof Set)){if(r(t)||"string"==typeof t){var e=[];t=t.length;for(var n=0;n<t;n++)e.push(n);return e}e=[],n=0;for(const i in t)e[n++]=i;return e}}}(t),i=function(t){if(t.V&&"function"==typeof t.V)return t.V();if("undefined"!=typeof Map&&t instanceof Map||"undefined"!=typeof Set&&t instanceof Set)return Array.from(t.values());if("string"==typeof t)return t.split("");if(r(t)){for(var e=[],n=t.length,i=0;i<n;i++)e.push(t[i]);return e}for(i in e=[],n=0,t)e[n++]=t[i];return e}(t),s=i.length,o=0;o<s;o++)e.call(void 0,i[o],n&&n[o],t)}oe.prototype.cancel=function(){if(this.i=de(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(const t of this.g.values())t.cancel();this.g.clear()}};var pe=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function ge(t){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,t instanceof ge){this.h=t.h,_e(this,t.j),this.o=t.o,this.g=t.g,ye(this,t.s),this.l=t.l;var e=t.i,n=new xe;n.i=e.i,e.g&&(n.g=new Map(e.g),n.h=e.h),ve(this,n),this.m=t.m}else t&&(e=String(t).match(pe))?(this.h=!1,_e(this,e[1]||"",!0),this.o=Ee(e[2]||""),this.g=Ee(e[3]||"",!0),ye(this,e[4]),this.l=Ee(e[5]||"",!0),ve(this,e[6]||"",!0),this.m=Ee(e[7]||"")):(this.h=!1,this.i=new xe(null,this.h))}function me(t){return new ge(t)}function _e(t,e,n){t.j=n?Ee(e,!0):e,t.j&&(t.j=t.j.replace(/:$/,""))}function ye(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.s=e}else t.s=null}function ve(t,e,n){e instanceof xe?(t.i=e,function(t,e){e&&!t.j&&(De(t),t.i=null,t.g.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(Oe(this,e),Le(this,n,t))},t)),t.j=e}(t.i,t.h)):(n||(e=Ce(e,Ne)),t.i=new xe(e,t.h))}function we(t,e,n){t.i.set(e,n)}function Te(t){return we(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),t}function Ee(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Ce(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,be),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function be(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}ge.prototype.toString=function(){var t=[],e=this.j;e&&t.push(Ce(e,Se,!0),":");var n=this.g;return(n||"file"==e)&&(t.push("//"),(e=this.o)&&t.push(Ce(e,Se,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.s)&&t.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&t.push("/"),t.push(Ce(n,"/"==n.charAt(0)?Re:ke,!0))),(n=this.i.toString())&&t.push("?",n),(n=this.m)&&t.push("#",Ce(n,Ae)),t.join("")};var Ie,Se=/[#\/\?@]/g,ke=/[#\?:]/g,Re=/[#\?]/g,Ne=/[#\?@]/g,Ae=/#/g;function xe(t,e){this.h=this.g=null,this.i=t||null,this.j=!!e}function De(t){t.g||(t.g=new Map,t.h=0,t.i&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var i=t[n].indexOf("="),s=null;if(0<=i){var r=t[n].substring(0,i);s=t[n].substring(i+1)}else r=t[n];e(r,s?decodeURIComponent(s.replace(/\+/g," ")):"")}}}(t.i,function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)}))}function Oe(t,e){De(t),e=Me(t,e),t.g.has(e)&&(t.i=null,t.h-=t.g.get(e).length,t.g.delete(e))}function Pe(t,e){return De(t),e=Me(t,e),t.g.has(e)}function Le(t,e,n){Oe(t,e),0<n.length&&(t.i=null,t.g.set(Me(t,e),d(n)),t.h+=n.length)}function Me(t,e){return e=String(e),t.j&&(e=e.toLowerCase()),e}function Fe(t,e,n,i,s){try{s&&(s.onload=null,s.onerror=null,s.onabort=null,s.ontimeout=null),i(n)}catch(r){}}function Ue(){this.g=new Ct}function Ve(t,e,n){const i=n||"";try{fe(t,function(t,n){let s=t;o(t)&&(s=Tt(t)),e.push(i+n+"="+encodeURIComponent(s))})}catch(s){throw e.push(i+"type=_badmap"),s}}function qe(t){this.l=t.Ub||null,this.j=t.eb||!1}function je(t,e){dt.call(this),this.D=t,this.o=e,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}function Be(t){t.j.read().then(t.Pa.bind(t)).catch(t.ga.bind(t))}function He(t){t.readyState=4,t.l=null,t.j=null,t.v=null,We(t)}function We(t){t.onreadystatechange&&t.onreadystatechange.call(t)}function $e(t){let e="";return y(t,function(t,n){e+=n,e+=":",e+=t,e+="\r\n"}),e}function ze(t,e,n){t:{for(i in n){var i=!1;break t}i=!0}i||(n=$e(n),"string"==typeof t||we(t,e,n))}function Ge(t){dt.call(this),this.headers=new Map,this.o=t||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}(t=xe.prototype).add=function(t,e){De(this),this.i=null,t=Me(this,t);var n=this.g.get(t);return n||this.g.set(t,n=[]),n.push(e),this.h+=1,this},t.forEach=function(t,e){De(this),this.g.forEach(function(n,i){n.forEac
1h(function(n){t.call(e,n,i,this)},this)},this)},t.na=function(){De(this);const t=Array.from(this.g.values()),e=Array.from(this.g.keys()),n=[];for(let i=0;i<e.length;i++){const s=t[i];for(let t=0;t<s.length;t++)n.push(e[i])}return n},t.V=function(t){De(this);let e=[];if("string"==typeof t)Pe(this,t)&&(e=e.concat(this.g.get(Me(this,t))));else{t=Array.from(this.g.values());for(let n=0;n<t.length;n++)e=e.concat(t[n])}return e},t.set=function(t,e){return De(this),this.i=null,Pe(this,t=Me(this,t))&&(this.h-=this.g.get(t).length),this.g.set(t,[e]),this.h+=1,this},t.get=function(t,e){return t&&0<(t=this.V(t)).length?String(t[0]):e},t.toString=function(){if(this.i)return this.i;if(!this.g)return"";const t=[],e=Array.from(this.g.keys());for(var n=0;n<e.length;n++){var i=e[n];const r=encodeURIComponent(String(i)),o=this.V(i);for(i=0;i<o.length;i++){var s=r;""!==o[i]&&(s+="="+encodeURIComponent(String(o[i]))),t.push(s)}}return this.i=t.join("&")},c(qe,bt),qe.prototype.g=function(){return new je(this.l,this.j)},qe.prototype.i=(Ie={},function(){return Ie}),c(je,dt),(t=je.prototype).open=function(t,e){if(0!=this.readyState)throw this.abort(),Error("Error reopening a connection");this.B=t,this.A=e,this.readyState=1,We(this)},t.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const e={headers:this.u,method:this.B,credentials:this.m,cache:void 0};t&&(e.body=t),(this.D||s).fetch(new Request(this.A,e)).then(this.Sa.bind(this),this.ga.bind(this))},t.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,He(this)),this.readyState=0},t.Sa=function(t){if(this.g&&(this.l=t,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=t.headers,this.readyState=2,We(this)),this.g&&(this.readyState=3,We(this),this.g)))if("arraybuffer"===this.responseType)t.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(void 0!==s.ReadableStream&&"body"in t){if(this.j=t.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;Be(this)}else t.text().then(this.Ra.bind(this),this.ga.bind(this))},t.Pa=function(t){if(this.g){if(this.o&&t.value)this.response.push(t.value);else if(!this.o){var e=t.value?t.value:new Uint8Array(0);(e=this.v.decode(e,{stream:!t.done}))&&(this.response=this.responseText+=e)}t.done?He(this):We(this),3==this.readyState&&Be(this)}},t.Ra=function(t){this.g&&(this.response=this.responseText=t,He(this))},t.Qa=function(t){this.g&&(this.response=t,He(this))},t.ga=function(){this.g&&He(this)},t.setRequestHeader=function(t,e){this.u.append(t,e)},t.getResponseHeader=function(t){return this.h&&this.h.get(t.toLowerCase())||""},t.getAllResponseHeaders=function(){if(!this.h)return"";const t=[],e=this.h.entries();for(var n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},Object.defineProperty(je.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(t){this.m=t?"include":"same-origin"}}),c(Ge,dt);var Ke=/^https?$/i,Qe=["POST","PUT"];function Xe(t,e){t.h=!1,t.g&&(t.j=!0,t.g.abort(),t.j=!1),t.l=e,t.m=5,Ye(t),Ze(t)}function Ye(t){t.A||(t.A=!0,ft(t,"complete"),ft(t,"error"))}function Je(t){if(t.h&&void 0!==i&&(!t.v[1]||4!=en(t)||2!=t.Z()))if(t.u&&4==en(t))gt(t.Ea,0,t);else if(ft(t,"readystatechange"),4==en(t)){t.h=!1;try{const i=t.Z();t:switch(i){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var e=!0;break t;default:e=!1}var n;if(!(n=e)){var r;if(r=0===i){var o=String(t.D).match(pe)[1]||null;!o&&s.self&&s.self.location&&(o=s.self.location.protocol.slice(0,-1)),r=!Ke.test(o?o.toLowerCase():"")}n=r}if(n)ft(t,"complete"),ft(t,"success");else{t.m=6;try{var a=2<en(t)?t.g.statusText:""}catch(h){a=""}t.l=a+" ["+t.Z()+"]",Ye(t)}}finally{Ze(t)}}}function Ze(t,e){if(t.g){tn(t);const i=t.g,s=t.v[0]?()=>{}:null;t.g=null,t.v=null,e||ft(t,"ready");try{i.onreadystatechange=s}catch(n){}}}function tn(t){t.I&&(s.clearTimeout(t.I),t.I=null)}function en(t){return t.g?t.g.readyState:0}function nn(t){try{if(!t.g)return null;if("response"in t.g)return t.g.response;switch(t.H){case"":case"text":return t.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in t.g)return t.g.mozResponseArrayBuffer}return null}catch(e){return null}}
1function sn(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function rn(t){this.Aa=0,this.i=[],this.j=new Vt,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=sn("failFast",!1,t),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=sn("baseRetryDelayMs",5e3,t),this.cb=sn("retryDelaySeedMs",1e4,t),this.Wa=sn("forwardChannelMaxRetries",2,t),this.wa=sn("forwardChannelRequestTimeoutMs",2e4,t),this.pa=t&&t.xmlHttpFactory||void 0,this.Xa=t&&t.Tb||void 0,this.Ca=t&&t.useFetchStreams||!1,this.L=void 0,this.J=t&&t.supportsCrossDomainXhr||!1,this.K="",this.h=new oe(t&&t.concurrentRequestLimit),this.Da=new Ue,this.P=t&&t.fastHandshake||!1,this.O=t&&t.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=t&&t.Rb||!1,t&&t.xa&&this.j.xa(),t&&t.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&t&&t.detectBufferingProxy||!1,this.ja=void 0,t&&t.longPollingTimeout&&0<t.longPollingTimeout&&(this.ja=t.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}function on(t){if(hn(t),3==t.G){var e=t.U++,n=me(t.I);if(we(n,"SID",t.K),we(n,"RID",e),we(n,"TYPE","terminate"),cn(t,n),(e=new $t(t,t.j,e)).L=2,e.v=Te(me(n)),n=!1,s.navigator&&s.navigator.sendBeacon)try{n=s.navigator.sendBeacon(e.v.toString(),"")}catch(i){}!n&&s.Image&&((new Image).src=e.v,n=!0),n||(e.g=Cn(e.j,null),e.g.ea(e.v)),e.F=Date.now(),Zt(e)}Tn(t)}function an(t){t.g&&(gn(t),t.g.cancel(),t.g=null)}function hn(t){an(t),t.u&&(s.clearTimeout(t.u),t.u=null),_n(t),t.h.cancel(),t.s&&("number"==typeof t.s&&s.clearTimeout(t.s),t.s=null)}function ln(t){if(!ae(t.h)&&!t.s){t.s=!0;var e=t.Ga;k||A(),R||(k(),R=!0),N.add(e,t),t.B=0}}function un(t,e){var n;n=e?e.l:t.U++;const i=me(t.I);we(i,"SID",t.K),we(i,"RID",n),we(i,"AID",t.T),cn(t,i),t.m&&t.o&&ze(i,t.m,t.o),n=new $t(t,t.j,n,t.B+1),null===t.m&&(n.H=t.o),e&&(t.i=e.D.concat(t.i)),e=dn(t,n,1e3),n.I=Math.round(.5*t.wa)+Math.round(.5*t.wa*Math.random()),ue(t.h,n),Qt(n,i,e)}function cn(t,e){t.H&&y(t.H,function(t,n){we(e,n,t)}),t.l&&fe({},function(t,n){we(e,n,t)})}function dn(t,e,n){n=Math.min(t.i.length,n);var i=t.l?l(t.l.Na,t.l,t):null;t:{var s=t.i;let e=-1;for(;;){const t=["count="+n];-1==e?0<n?(e=s[0].g,t.push("ofs="+e)):e=0:t.push("ofs="+e);let o=!0;for(let a=0;a<n;a++){let n=s[a].g;const h=s[a].map;if(n-=e,0>n)e=Math.max(0,s[a].g-100),o=!1;else try{Ve(h,t,"req"+n+"_")}catch(r){i&&i(h)}}if(o){i=t.join("&");break t}}}return t=t.i.splice(0,n),e.D=t,i}function fn(t){if(!t.g&&!t.u){t.Y=1;var e=t.Fa;k||A(),R||(k(),R=!0),N.add(e,t),t.v=0}}function pn(t){return!(t.g||t.u||3<=t.v)&&(t.Y++,t.u=Ut(l(t.Fa,t),vn(t,t.v)),t.v++,!0)}function gn(t){null!=t.A&&(s.clearTimeout(t.A),t.A=null)}function mn(t){t.g=new $t(t,t.j,"rpc",t.Y),null===t.m&&(t.g.H=t.o),t.g.O=0;var e=me(t.qa);we(e,"RID","rpc"),we(e,"SID",t.K),we(e,"AID",t.T),we(e,"CI",t.F?"0":"1"),!t.F&&t.ja&&we(e,"TO",t.ja),we(e,"TYPE","xmlhttp"),cn(t,e),t.m&&t.o&&ze(e,t.m,t.o),t.L&&(t.g.I=t.L);var n=t.g;t=t.ia,n.L=1,n.v=Te(me(e)),n.m=null,n.P=!0,Xt(n,t)}function _n(t){null!=t.C&&(s.clearTimeout(t.C),t.C=null)}function yn(t,e){var n=null;if(t.g==e){_n(t),gn(t),t.g=null;var i=2}else{if(!le(t.h,e))return;n=e.D,ce(t.h,e),i=1}if(0!=t.G)if(e.o)if(1==i){n=e.m?e.m.length:0,e=Date.now()-e.F;var s=t.B;ft(i=Dt(),new Ft(i,n)),ln(t)}else fn(t);else if(3==(s=e.s)||0==s&&0<e.X||!(1==i&&function(t,e){return!(he(t.h)>=t.h.j-(t.s?1:0)||(t.s?(t.i=e.D.concat(t.i),0):1==t.G||2==t.G||t.B>=(t.Va?0:t.Wa)||(t.s=Ut(l(t.Ga,t,e),vn(t,t.B)),t.B++,0)))}(t,e)||2==i&&pn(t)))switch(n&&0<n.length&&(e=t.h,e.i=e.i.concat(n)),s){case 1:wn(t,5);break;case 4:wn(t,10);break;case 3:wn(t,6);break;default:wn(t,2)}}function vn(t,e){let n=t.Ta+Math.floor(Math.random()*t.cb);return t.isActive()||(n*=2),n*e}function wn(t,e){if(t.j.info("Error code "+e),2==e){var n=l(t.fb,t),i=t.Xa;const e=!i;i=new ge(i||"//www.google.com/images/cleardot.gif"),s.location&&"http"==s.location.protocol||_e(i,"https"),Te(i),e?function(t,e){const n=new Vt;if(s.Image){const i=new Image;i.onload=u(Fe,n,"TestLoadImage: loaded",!0,e,i),i.onerror=u(Fe,n,"TestLoadImage: error",!1,e,i),i.onabort=u(Fe,n,"TestLoadImage: abort",!1,e,i),i.ontimeout=u(Fe,n,"TestLoadImage: timeout",!1,e,i),s.setTimeout(function(){i.ontimeout&&i.ontimeout()},1e4),i.src=t}else e(!1)}(i.toString(),n):function(t,e){new Vt;const n=new AbortController,i=setTimeout(()=>{n.abort(),Fe(0,0,!1,e)},1e4);fetch(t,{signal:n.signal}).then(t=>{clearTimeout(i),t.ok?Fe(0,0,!0,e):Fe(0,0,!1,e)}
1).catch(()=>{clearTimeout(i),Fe(0,0,!1,e)})}(i.toString(),n)}else Mt(2);t.G=0,t.l&&t.l.sa(e),Tn(t),hn(t)}function Tn(t){if(t.G=0,t.ka=[],t.l){const e=de(t.h);0==e.length&&0==t.i.length||(f(t.ka,e),f(t.ka,t.i),t.h.i.length=0,d(t.i),t.i.length=0),t.l.ra()}}function En(t,e,n){var i=n instanceof ge?me(n):new ge(n);if(""!=i.g)e&&(i.g=e+"."+i.g),ye(i,i.s);else{var r=s.location;i=r.protocol,e=e?e+"."+r.hostname:r.hostname,r=+r.port;var o=new ge(null);i&&_e(o,i),e&&(o.g=e),r&&ye(o,r),n&&(o.l=n),i=o}return n=t.D,e=t.ya,n&&e&&we(i,n,e),we(i,"VER",t.la),cn(t,i),i}function Cn(t,e,n){if(e&&!t.J)throw Error("Can't create secondary domain capable XhrIo object.");return(e=t.Ca&&!t.pa?new Ge(new qe({eb:n})):new Ge(t.pa)).Ha(t.J),e}function bn(){}function In(){}function Sn(t,e){dt.call(this),this.g=new rn(e),this.l=t,this.h=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.g.o=t,t=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(t?t["X-WebChannel-Content-Type"]=e.messageContentType:t={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.va&&(t?t["X-WebChannel-Client-Profile"]=e.va:t={"X-WebChannel-Client-Profile":e.va}),this.g.S=t,(t=e&&e.Sb)&&!p(t)&&(this.g.m=t),this.v=e&&e.supportsCrossDomainXhr||!1,this.u=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!p(e)&&(this.g.D=e,null!==(t=this.h)&&e in t&&(e in(t=this.h)&&delete t[e])),this.j=new Nn(this)}function kn(t){Rt.call(this),t.__headers__&&(this.headers=t.__headers__,this.statusCode=t.__status__,delete t.__headers__,delete t.__status__);var e=t.__sm__;if(e){t:{for(const n in e){t=n;break t}t=void 0}(this.i=t)&&(t=this.i,e=null!==e&&t in e?e[t]:void 0),this.data=e}else this.data=t}function Rn(){Nt.call(this),this.status=1}function Nn(t){this.g=t}(t=Ge.prototype).Ha=function(t){this.J=t},t.ea=function(t,e,n,i){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+t);e=e?e.toUpperCase():"GET",this.D=t,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():jt.g(),this.v=this.o?It(this.o):It(jt),this.g.onreadystatechange=l(this.Ea,this);try{this.B=!0,this.g.open(e,String(t),!0),this.B=!1}catch(o){return void Xe(this,o)}if(t=n||"",n=new Map(this.headers),i)if(Object.getPrototypeOf(i)===Object.prototype)for(var r in i)n.set(r,i[r]);else{if("function"!=typeof i.keys||"function"!=typeof i.get)throw Error("Unknown input type for opt_headers: "+String(i));for(const t of i.keys())n.set(t,i.get(t))}i=Array.from(n.keys()).find(t=>"content-type"==t.toLowerCase()),r=s.FormData&&t instanceof s.FormData,!(0<=Array.prototype.indexOf.call(Qe,e,void 0))||i||r||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[s,a]of n)this.g.setRequestHeader(s,a);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{tn(this),this.u=!0,this.g.send(t),this.u=!1}catch(o){Xe(this,o)}},t.abort=function(t){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=t||7,ft(this,"complete"),ft(this,"abort"),Ze(this))},t.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Ze(this,!0)),Ge.aa.N.call(this)},t.Ea=function(){this.s||(this.B||this.u||this.j?Je(this):this.bb())},t.bb=function(){Je(this)},t.isActive=function(){return!!this.g},t.Z=function(){try{return 2<en(this)?this.g.status:-1}catch(Ie){return-1}},t.oa=function(){try{return this.g?this.g.responseText:""}catch(Ie){return""}},t.Oa=function(t){if(this.g){var e=this.g.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Et(e)}},t.Ba=function(){return this.m},t.Ka=function(){return"string"==typeof this.l?this.l:String(this.l)},(t=rn.prototype).la=8,t.G=1,t.connect=function(t,e,n,i){Mt(0),this.W=t,this.H=e||{},n&&void 0!==i&&(this.H.OSID=n,this.H.OAID=i),this.F=this.X,this.I=En(this,null,this.W),ln(this)},t.Ga=function(t){if(this.s)if(this.s=null,1==this.G){if(!t){this.U=Math.floor(1e5*Math.random()),t=this.U++;const s=new $t(this,this.j,t);let r=this.o;if(this.S&&(r?(r=v(r),T(r,this.S)):r=this.S),null!==this.m||this.O||(s.H=r,r=null),this.P)t:{for(var e=0,n=0;n<this.i.length;n++){var i=this.i[n];if(void 0===(i="__data__"in i.map&&"string"==typeof(i=i.map.__data__)?i.length:void 0))break;if(4096<(e+=i)){e=n;break t}if(4096===e||n===this.i.length-1){e=n+1;break t}}e=1e3}else e=1e3;
1e=dn(this,s,e),we(n=me(this.I),"RID",t),we(n,"CVER",22),this.D&&we(n,"X-HTTP-Session-Id",this.D),cn(this,n),r&&(this.O?e="headers="+encodeURIComponent(String($e(r)))+"&"+e:this.m&&ze(n,this.m,r)),ue(this.h,s),this.Ua&&we(n,"TYPE","init"),this.P?(we(n,"$req",e),we(n,"SID","null"),s.T=!0,Qt(s,n,null)):Qt(s,n,e),this.G=2}}else 3==this.G&&(t?un(this,t):0==this.i.length||ae(this.h)||un(this))},t.Fa=function(){if(this.u=null,mn(this),this.ba&&!(this.M||null==this.g||0>=this.R)){var t=2*this.R;this.j.info("BP detection timer enabled: "+t),this.A=Ut(l(this.ab,this),t)}},t.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Mt(10),an(this),mn(this))},t.Za=function(){null!=this.C&&(this.C=null,an(this),pn(this),Mt(19))},t.fb=function(t){t?(this.j.info("Successfully pinged google.com"),Mt(2)):(this.j.info("Failed to ping google.com"),Mt(1))},t.isActive=function(){return!!this.l&&this.l.isActive(this)},(t=bn.prototype).ua=function(){},t.ta=function(){},t.sa=function(){},t.ra=function(){},t.isActive=function(){return!0},t.Na=function(){},In.prototype.g=function(t,e){return new Sn(t,e)},c(Sn,dt),Sn.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Sn.prototype.close=function(){on(this.g)},Sn.prototype.o=function(t){var e=this.g;if("string"==typeof t){var n={};n.__data__=t,t=n}else this.u&&((n={}).__data__=Tt(t),t=n);e.i.push(new re(e.Ya++,t)),3==e.G&&ln(e)},Sn.prototype.N=function(){this.g.l=null,delete this.j,on(this.g),delete this.g,Sn.aa.N.call(this)},c(kn,Rt),c(Rn,Nt),c(Nn,bn),Nn.prototype.ua=function(){ft(this.g,"a")},Nn.prototype.ta=function(t){ft(this.g,new kn(t))},Nn.prototype.sa=function(t){ft(this.g,new Rn)},Nn.prototype.ra=function(){ft(this.g,"b")},In.prototype.createWebChannel=In.prototype.g,Sn.prototype.send=Sn.prototype.o,Sn.prototype.open=Sn.prototype.m,Sn.prototype.close=Sn.prototype.close,ht=ut.createWebChannelTransport=function(){return new In},at=ut.getStatEventTarget=function(){return Dt()},ot=ut.Event=At,rt=ut.Stat={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Bt.NO_ERROR=0,Bt.TIMEOUT=8,Bt.HTTP_ERROR=6,st=ut.ErrorCode=Bt,Ht.COMPLETE="complete",it=ut.EventType=Ht,St.EventType=kt,kt.OPEN="a",kt.CLOSE="b",kt.ERROR="c",kt.MESSAGE="d",dt.prototype.listen=dt.prototype.K,nt=ut.WebChannel=St,ut.FetchXmlHttpFactory=qe,Ge.prototype.listenOnce=Ge.prototype.L,Ge.prototype.getLastError=Ge.prototype.Ka,Ge.prototype.getLastErrorCode=Ge.prototype.Ba,Ge.prototype.getStatus=Ge.prototype.Z,Ge.prototype.getResponseJson=Ge.prototype.Oa,Ge.prototype.getResponseText=Ge.prototype.oa,Ge.prototype.send=Ge.prototype.ea,Ge.prototype.setWithCredentials=Ge.prototype.Ha,et=ut.XhrIo=Ge}).apply(void 0!==lt?lt:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var ct="@firebase/firestore",dt="4.8.0",ft=class{constructor(t){this.uid=t}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}};ft.UNAUTHENTICATED=new ft(null),ft.GOOGLE_CREDENTIALS=new ft("google-credentials-uid"),ft.FIRST_PARTY=new ft("first-party-uid"),ft.MOCK_USER=new ft("mock-user");var pt="11.10.0",gt=new class{constructor(t){this.name=t,this._logLevel=X,this._logHandler=J,this._userLogHandler=null,G.push(this)}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in z))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel="string"==typeof t?Q[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,z.DEBUG,...t),this._logHandler(this,z.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,z.VERBOSE,...t),this._logHandler(this,z.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,z.INFO,...t),this._logHandler(this,z.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,z.WARN,...t),this._logHandler(this,z.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,z.ERROR,...t),this._logHandler(this,z.ERROR,...t)}}("@firebase/firestore");function mt(){return gt.logLevel}function _t(t,...e){if(gt.logLevel<=z.DEBUG){const n=e.map(wt);gt.debug(`Firestore (${pt}): ${t}`,...n)}}function yt(t,...e){if(gt.logLevel<=z.ERROR){const n=e.map(wt);gt.error(`Firestore (${pt}): ${t}`,...n)}}function vt(t,...e){if(gt.logLevel<=z.WARN){const n=e.map(wt);gt.warn(`Firestore (${pt}): ${t}`,...n)}}function wt(t){if("string"==typeof t)return t;try{return function(t){return JSON.stringify(t)}(t)}catch(e){return t}}function Tt(t,e,n){let i="Unexpected state";"string"==typeof e?i=e:n=e,Et(t,i,n)}function Et(t,e,n){let i=`FIRESTORE (${pt}) INTERNAL ASSERTION FAILED: ${e} (ID: ${t.toString(16)})`;if(void 0!==n)try{i+=" CONTEXT: "+JSON.stringify(n)}catch(t){i+=" CONTEXT: "+n}throw yt(i),new Error(i)}function Ct(t,e,n,i){let s="Unexpected state";"string"==typeof n?s=n:i=n,t||Et(e,s,i)}function bt(t,e){return t}
1var It={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"},St=class extends U{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}},kt=class{constructor(){this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}},Rt=class{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}},Nt=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable(()=>e(ft.UNAUTHENTICATED))}shutdown(){}},At=class{constructor(t){this.t=t,this.currentUser=ft.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,e){Ct(void 0===this.o,42304);let n=this.i;const i=t=>this.i!==n?(n=this.i,e(t)):Promise.resolve();let s=new kt;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new kt,t.enqueueRetryable(()=>i(this.currentUser))};const r=()=>{const e=s;t.enqueueRetryable(async()=>{await e.promise,await i(this.currentUser)})},o=t=>{_t("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=t,this.o&&(this.auth.addAuthTokenListener(this.o),r())};this.t.onInit(t=>o(t)),setTimeout(()=>{if(!this.auth){const t=this.t.getImmediate({optional:!0});t?o(t):(_t("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new kt)}},0),r()}getToken(){const t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then(e=>this.i!==t?(_t("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):e?(Ct("string"==typeof e.accessToken,31837,{l:e}),new Rt(e.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const t=this.auth&&this.auth.getUid();return Ct(null===t||"string"==typeof t,2055,{h:t}),new ft(t)}},xt=class{constructor(t,e,n){this.P=t,this.T=e,this.I=n,this.type="FirstParty",this.user=ft.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);const t=this.R();return t&&this.A.set("Authorization",t),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}},Dt=class{constructor(t,e,n){this.P=t,this.T=e,this.I=n}getToken(){return Promise.resolve(new xt(this.P,this.T,this.I))}start(t,e){t.enqueueRetryable(()=>e(ft.FIRST_PARTY))}shutdown(){}invalidateToken(){}},Ot=class{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}},Pt=class{constructor(t,e){this.V=e,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,P(t)&&t.settings.appCheckToken&&(this.p=t.settings.appCheckToken)}start(t,e){Ct(void 0===this.o,3512);const n=t=>{null!=t.error&&_t("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${t.error.message}`);const n=t.token!==this.m;return this.m=t.token,_t("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?e(t.token):Promise.resolve()};this.o=e=>{t.enqueueRetryable(()=>n(e))};const i=t=>{_t("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=t,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(t=>i(t)),setTimeout(()=>{if(!this.appCheck){const t=this.V.getImmediate({optional:!0});t?i(t):_t("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new Ot(this.p));const t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then(t=>t?(Ct("string"==typeof t.token,44558,{tokenResult:t}),this.m=t.token,new Ot(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}};function Lt(t){const e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(let i=0;i<t;
1i++)n[i]=Math.floor(256*Math.random());return n}function Mt(){return new TextEncoder}var Ft=class{static newId(){const t=62*Math.floor(256/62);let e="";for(;e.length<20;){const n=Lt(40);for(let i=0;i<n.length;++i)e.length<20&&n[i]<t&&(e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n[i]%62))}return e}};function Ut(t,e){return t<e?-1:t>e?1:0}function Vt(t,e){let n=0;for(;n<t.length&&n<e.length;){const i=t.codePointAt(n),s=e.codePointAt(n);if(i!==s){if(i<128&&s<128)return Ut(i,s);{const r=Mt(),o=jt(r.encode(qt(t,n)),r.encode(qt(e,n)));return 0!==o?o:Ut(i,s)}}n+=i>65535?2:1}return Ut(t.length,e.length)}function qt(t,e){return t.codePointAt(e)>65535?t.substring(e,e+2):t.substring(e,e+1)}function jt(t,e){for(let n=0;n<t.length&&n<e.length;++n)if(t[n]!==e[n])return Ut(t[n],e[n]);return Ut(t.length,e.length)}function Bt(t,e,n){return t.length===e.length&&t.every((t,i)=>n(t,e[i]))}var Ht="__name__",Wt=class t{constructor(t,e,n){void 0===e?e=0:e>t.length&&Tt(637,{offset:e,range:t.length}),void 0===n?n=t.length-e:n>t.length-e&&Tt(1746,{length:n,range:t.length-e}),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(e){return 0===t.comparator(this,e)}child(e){const n=this.segments.slice(this.offset,this.limit());return e instanceof t?e.forEach(t=>{n.push(t)}):n.push(e),this.construct(n)}limit(){return this.offset+this.length}popFirst(t){return t=void 0===t?1:t,this.construct(this.segments,this.offset+t,this.length-t)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(t){return this.segments[this.offset+t]}isEmpty(){return 0===this.length}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,n){const i=Math.min(e.length,n.length);for(let s=0;s<i;s++){const i=t.compareSegments(e.get(s),n.get(s));if(0!==i)return i}return Ut(e.length,n.length)}static compareSegments(e,n){const i=t.isNumericId(e),s=t.isNumericId(n);return i&&!s?-1:!i&&s?1:i&&s?t.extractNumericId(e).compare(t.extractNumericId(n)):Vt(e,n)}static isNumericId(t){return t.startsWith("__id")&&t.endsWith("__")}static extractNumericId(t){return K.fromString(t.substring(4,t.length-2))}},$t=class t extends Wt{construct(e,n,i){return new t(e,n,i)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const n=[];for(const t of e){if(t.indexOf("//")>=0)throw new St(It.INVALID_ARGUMENT,`Invalid segment (${t}). Paths must not contain // in them.`);n.push(...t.split("/").filter(t=>t.length>0))}return new t(n)}static emptyPath(){return new t([])}},zt=/^[_a-zA-Z][_a-zA-Z0-9]*$/,Gt=class t extends Wt{construct(e,n,i){return new t(e,n,i)}static isValidIdentifier(t){return zt.test(t)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),t.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===Ht}static keyField(){return new t([Ht])}static fromServerFormat(e){const n=[];let i="",s=0;const r=()=>{if(0===i.length)throw new St(It.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);n.push(i),i=""};let o=!1;for(;s<e.length;){const t=e[s];if("\\"===t){if(s+1===e.length)throw new St(It.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[s+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new St(It.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);i+=t,s+=2}else"`"===t?(o=!o,s++):"."!==t||o?(i+=t,s++):(r(),s++)}if(r(),o)throw new St(It.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new t(n)}static emptyPath(){return new t([])}},Kt=class t{constructor(t){this.path=t}static fromPath(e){return new t($t.fromString(e))}static fromName(e){return new t($t.fromString(e).popFirst(5))}static empty(){return new t($t.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return null!==t&&0===$t.comparator(this.path,t.path)}toString(){return this.path.toString()}static comparator(t,e){return $t.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(e){return new t(new $t(e.slice()))}};function Qt(t,e){const n={typeString:t};return e&&(n.value=e),n}function Xt(t,e){if(!function(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(t))throw new St(It.INVALID_ARGUMENT,"JSON must be an object");let n;for(const i in e)if(e[i]){const s=e[i].typeString,r="value"in e[i]?{value:e[i].value}:void 0;if(!(i in t)){n=`JSON missing required field: '${i}'`;break}const o=t[i];if(s&&typeof o!==s){n=`JSON field '${i}' must be a ${s}.`;break}if(void 0!==r&&o!==r.value){n=`Expected '${i}' field to equal '${r.value}'`;break}}if(n)throw new St(It.INVALID_ARGUMENT,n);return!0}var Yt=-62135596800,Jt=1e6,Zt=class t{static now(){return t.fromMillis(Date.now())}static fromDate(e){return t.fromMillis(e.getTime())}static fromMillis(e){const n=Math.floor(e/1e3),i=Math.floor((e-1e3*n)*Jt);return new t(n,i)}constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new St(It.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new St(It.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<Yt)throw new St(It.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new St(It.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/Jt}_compareTo(t){return this.seconds===t.seconds?Ut(this.nanoseconds,t.nanoseconds):Ut(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:t._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(Xt(e,t._jsonSchema))return new t(e.seconds,e.nanoseconds)}valueOf(){const t=this.seconds-Yt;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}
1};Zt._jsonSchemaVersion="firestore/timestamp/1.0",Zt._jsonSchema={type:Qt("string",Zt._jsonSchemaVersion),seconds:Qt("number"),nanoseconds:Qt("number")};var te=class t{static fromTimestamp(e){return new t(e)}static min(){return new t(new Zt(0,0))}static max(){return new t(new Zt(253402300799,999999999))}constructor(t){this.timestamp=t}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}};function ee(t){return new ne(t.readTime,t.key,-1)}var ne=class t{constructor(t,e,n){this.readTime=t,this.documentKey=e,this.largestBatchId=n}static min(){return new t(te.min(),Kt.empty(),-1)}static max(){return new t(te.max(),Kt.empty(),-1)}};function ie(t,e){let n=t.readTime.compareTo(e.readTime);return 0!==n?n:(n=Kt.comparator(t.documentKey,e.documentKey),0!==n?n:Ut(t.largestBatchId,e.largestBatchId))}var se=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(t=>t())}},re=class t{constructor(t){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(t){return this.next(void 0,t)}next(e,n){return this.callbackAttached&&Tt(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(e,this.result):new t((t,i)=>{this.nextCallback=n=>{this.wrapSuccess(e,n).next(t,i)},this.catchCallback=e=>{this.wrapFailure(n,e).next(t,i)}})}toPromise(){return new Promise((t,e)=>{this.next(t,e)})}wrapUserFunction(e){try{const n=e();return n instanceof t?n:t.resolve(n)}catch(e){return t.reject(e)}}wrapSuccess(e,n){return e?this.wrapUserFunction(()=>e(n)):t.resolve(n)}wrapFailure(e,n){return e?this.wrapUserFunction(()=>e(n)):t.reject(n)}static resolve(e){return new t((t,n)=>{t(e)})}static reject(e){return new t((t,n)=>{n(e)})}static waitFor(e){return new t((t,n)=>{let i=0,s=0,r=!1;e.forEach(e=>{++i,e.next(()=>{++s,r&&s===i&&t()},t=>n(t))}),r=!0,s===i&&t()})}static or(e){let n=t.resolve(!1);for(const i of e)n=n.next(e=>e?t.resolve(e):i());return n}static forEach(t,e){const n=[];return t.forEach((t,i)=>{n.push(e.call(this,t,i))}),this.waitFor(n)}static mapArray(e,n){return new t((t,i)=>{const s=e.length,r=new Array(s);let o=0;for(let a=0;a<s;a++){const h=a;n(e[h]).next(e=>{r[h]=e,++o,o===s&&t(r)},t=>i(t))}})}static doWhile(e,n){return new t((t,i)=>{const s=()=>{!0===e()?n().next(()=>{s()},i):t()};s()})}};function oe(t){return"IndexedDbTransactionError"===t.name}var ae=class{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=t=>this._e(t),this.ae=t=>e.writeSequenceNumber(t))}_e(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.ae&&this.ae(t),t}};ae.ue=-1;function he(t){return null==t}function le(t){return 0===t&&1/t==-1/0}var ue="owner",ce="mutationQueues",de="mutations",fe="documentMutations",pe="remoteDocumentGlobal",ge="targets",me="targetDocuments",_e="targetGlobal",ye="collectionParents",ve="clientMetadata",we="bundles",Te="namedQueries",Ee="documentOverlays";function Ce(t){let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function be(t,e){for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}var Ie=class t{constructor(t,e){this.comparator=t,this.root=e||ke.EMPTY}insert(e,n){return new t(this.comparator,this.root.insert(e,n,this.comparator).copy(null,null,ke.BLACK,null,null))}remove(e){return new t(this.comparator,this.root.remove(e,this.comparator).copy(null,null,ke.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){const n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null}indexOf(t){let e=0,n=this.root;for(;!n.isEmpty();){const i=this.comparator(t,n.key);if(0===i)return e+n.left.size;i<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal((e,n)=>(t(e,n),!1))}toString(){const t=[];return this.inorderTraversal((e,n)=>(t.push(`${e}:${n}`),!1)),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new Se(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new Se(this.root,t,this.comparator,!1)}getReverseIterator(){return new Se(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new Se(this.root,t,this.comparator,!0)}},Se=class{constructor(t,e,n,i){this.isReverse=i,this.nodeStack=[];let s=1;for(;!t.isEmpty();)if(s=e?n(t.key,e):1,e&&i&&(s*=-1),s<0)t=this.isReverse?t.left:t.right;else{if(0===s){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}},ke=class t{constructor(e,n,i,s,r){this.key=e,this.value=n,this.color=null!=i?i:t.RED,this.left=null!=s?s:t.EMPTY,this.right=null!=r?r:t.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,n,i,s,r){return new t(null!=e?e:this.key,null!=n?n:this.value,
vendor: 4,344 bytes, line 1
1null!=i?i:this.color,null!=s?s:this.left,null!=r?r:this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,n){let i=this;const s=n(t,i.key);return i=s<0?i.copy(null,null,null,i.left.insert(t,e,n),null):0===s?i.copy(null,e,null,null,null):i.copy(null,null,null,null,i.right.insert(t,e,n)),i.fixUp()}removeMin(){if(this.left.isEmpty())return t.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,n){let i,s=this;if(n(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,n),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),0===n(e,s.key)){if(s.right.isEmpty())return t.EMPTY;i=s.right.min(),s=s.copy(i.key,i.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,n))}return s.fixUp()}isRed(){return this.color}fixUp(){let 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}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw Tt(43730,{key:this.key,value:this.value});if(this.right.isRed())throw Tt(14113,{key:this.key,value:this.value});const t=this.left.check();if(t!==this.right.check())throw Tt(27949);return t+(this.isRed()?0:1)}};ke.EMPTY=null,ke.RED=!0,ke.BLACK=!1,ke.EMPTY=new class{constructor(){this.size=0}get key(){throw Tt(57766)}get value(){throw Tt(16141)}get color(){throw Tt(16727)}get left(){throw Tt(29726)}get right(){throw Tt(36894)}copy(t,e,n,i,s){return this}insert(t,e,n){return new ke(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};var Re=class t{constructor(t){this.comparator=t,this.data=new Ie(this.comparator)}has(t){return null!==this.data.get(t)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal((e,n)=>(t(e),!1))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const i=n.getNext();if(this.comparator(i.key,t[1])>=0)return;e(i.key)}}forEachWhile(t,e){let n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new Ne(this.data.getIterator())}getIteratorFrom(t){return new Ne(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach(t=>{e=e.add(t)}),e}isEqual(e){if(!(e instanceof t))return!1;if(this.size!==e.size)return!1;const n=this.data.getIterator(),i=e.data.getIterator();for(;n.hasNext();){const t=n.getNext().key,e=i.getNext().key;if(0!==this.comparator(t,e))return!1}return!0}toArray(){const t=[];
1return this.forEach(e=>{t.push(e)}),t}toString(){const t=[];return this.forEach(e=>t.push(e)),"SortedSet("+t.toString()+")"}copy(e){const n=new t(this.comparator);return n.data=e,n}},Ne=class{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}},Ae=class t{constructor(t){this.fields=t,t.sort(Gt.comparator)}static empty(){return new t([])}unionWith(e){let n=new Re(Gt.comparator);for(const t of this.fields)n=n.add(t);for(const t of e)n=n.add(t);return new t(n.toArray())}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return Bt(this.fields,t.fields,(t,e)=>t.isEqual(e))}},xe=class extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}},De=class t{constructor(t){this.binaryString=t}static fromBase64String(e){const n=function(t){try{return atob(t)}catch(t){throw"undefined"!=typeof DOMException&&t instanceof DOMException?new xe("Invalid base64 string: "+t):t}}(e);return new t(n)}static fromUint8Array(e){const n=function(t){let e="";for(let n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(e);return new t(n)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return t=this.binaryString,btoa(t);var t}toUint8Array(){return function(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return Ut(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}};De.EMPTY_BYTE_STRING=new De("");var Oe=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Pe(t){if(Ct(!!t,39018),"string"==typeof t){let e=0;const n=Oe.exec(t);if(Ct(!!n,46558,{timestamp:t}),n[1]){let t=n[1];t=(t+"000000000").substr(0,9),e=Number(t)}const i=new Date(t);return{seconds:Math.floor(i.getTime()/1e3),nanos:e}}return{seconds:Le(t.seconds),nanos:Le(t.nanos)}}function Le(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function Me(t){return"string"==typeof t?De.fromBase64String(t):De.fromUint8Array(t)}var Fe="server_timestamp",Ue="__type__",Ve="__previous_value__",qe="__local_write_time__";function je(t){var e,n;return(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{})[Ue])||void 0===n?void 0:n.stringValue)===Fe}function Be(t){const e=t.mapValue.fields[Ve];return je(e)?Be(e):e}function He(t){const e=Pe(t.mapValue.fields[qe].timestampValue);return new Zt(e.seconds,e.nanos)}var We="(default)",$e=class t{constructor(t,e){this.projectId=t,this.database=e||We}static empty(){return new t("","")}get isDefaultDatabase(){return this.database===We}isEqual(e){return e instanceof t&&e.projectId===this.projectId&&e.database===this.database}},ze="__max__",Ge={fields:{__type__:{stringValue:ze}}},Ke="value";function Qe(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?je(t)?4:ln(t)?9007199254740991:an(t)?10:11:Tt(28295,{value:t})}function Xe(t,e){if(t===e)return!0;const n=Qe(t);if(n!==Qe(e))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return He(t).isEqual(He(e));case 3:return function(t,e){if("string"==typeof t.timestampValue&&"string"==typeof e.timestampValue&&t.timestampValue.length===e.timestampValue.length)return t.timestampValue===e.timestampValue;const n=Pe(t.timestampValue),i=Pe(e.timestampValue);return n.seconds===i.seconds&&n.nanos===i.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(t,e){return Me(t.bytesValue).isEqual(Me(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return Le(t.geoPointValue.latitude)===Le(e.geoPointValue.latitude)&&Le(t.geoPointValue.longitude)===Le(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return Le(t.integerValue)===Le(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){const n=Le(t.doubleValue),i=Le(e.doubleValue);return n===i?le(n)===le(i):isNaN(n)&&isNaN(i)}return!1}(t,e);case 9:return Bt(t.arrayValue.values||[],e.arrayValue.values||[],Xe);case 10:case 11:return function(t,e){const n=t.mapValue.fields||{},i=e.mapValue.fields||{};if(Ce(n)!==Ce(i))return!1;for(const s in n)if(n.hasOwnProperty(s)&&(void 0===i[s]||!Xe(n[s],i[s])
1))return!1;return!0}(t,e);default:return Tt(52216,{left:t})}}function Ye(t,e){return void 0!==(t.values||[]).find(t=>Xe(t,e))}function Je(t,e){if(t===e)return 0;const n=Qe(t),i=Qe(e);if(n!==i)return Ut(n,i);switch(n){case 0:case 9007199254740991:return 0;case 1:return Ut(t.booleanValue,e.booleanValue);case 2:return function(t,e){const n=Le(t.integerValue||t.doubleValue),i=Le(e.integerValue||e.doubleValue);return n<i?-1:n>i?1:n===i?0:isNaN(n)?isNaN(i)?0:-1:1}(t,e);case 3:return Ze(t.timestampValue,e.timestampValue);case 4:return Ze(He(t),He(e));case 5:return Vt(t.stringValue,e.stringValue);case 6:return function(t,e){const n=Me(t),i=Me(e);return n.compareTo(i)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){const n=t.split("/"),i=e.split("/");for(let s=0;s<n.length&&s<i.length;s++){const t=Ut(n[s],i[s]);if(0!==t)return t}return Ut(n.length,i.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){const n=Ut(Le(t.latitude),Le(e.latitude));return 0!==n?n:Ut(Le(t.longitude),Le(e.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return tn(t.arrayValue,e.arrayValue);case 10:return function(t,e){var n,i,s,r;const o=t.fields||{},a=e.fields||{},h=null===(n=o[Ke])||void 0===n?void 0:n.arrayValue,l=null===(i=a[Ke])||void 0===i?void 0:i.arrayValue,u=Ut((null===(s=null==h?void 0:h.values)||void 0===s?void 0:s.length)||0,(null===(r=null==l?void 0:l.values)||void 0===r?void 0:r.length)||0);return 0!==u?u:tn(h,l)}(t.mapValue,e.mapValue);case 11:return function(t,e){if(t===Ge&&e===Ge)return 0;if(t===Ge)return 1;if(e===Ge)return-1;const n=t.fields||{},i=Object.keys(n),s=e.fields||{},r=Object.keys(s);i.sort(),r.sort();for(let o=0;o<i.length&&o<r.length;++o){const t=Vt(i[o],r[o]);if(0!==t)return t;const e=Je(n[i[o]],s[r[o]]);if(0!==e)return e}return Ut(i.length,r.length)}(t.mapValue,e.mapValue);default:throw Tt(23264,{le:n})}}function Ze(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return Ut(t,e);const n=Pe(t),i=Pe(e),s=Ut(n.seconds,i.seconds);return 0!==s?s:Ut(n.nanos,i.nanos)}function tn(t,e){const n=t.values||[],i=e.values||[];for(let s=0;s<n.length&&s<i.length;++s){const t=Je(n[s],i[s]);if(t)return t}return Ut(n.length,i.length)}function en(t){return nn(t)}function nn(t){return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?function(t){const e=Pe(t);return`time(${e.seconds},${e.nanos})`}(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?function(t){return Me(t).toBase64()}(t.bytesValue):"referenceValue"in t?function(t){return Kt.fromName(t).toString()}(t.referenceValue):"geoPointValue"in t?function(t){return`geo(${t.latitude},${t.longitude})`}(t.geoPointValue):"arrayValue"in t?function(t){let e="[",n=!0;for(const i of t.values||[])n?n=!1:e+=",",e+=nn(i);return e+"]"}(t.arrayValue):"mapValue"in t?function(t){const e=Object.keys(t.fields||{}).sort();let n="{",i=!0;for(const s of e)i?i=!1:n+=",",n+=`${s}:${nn(t.fields[s])}`;return n+"}"}(t.mapValue):Tt(61005,{value:t})}function sn(t){return!!t&&"integerValue"in t}function rn(t){return!!t&&"arrayValue"in t}function on(t){return!!t&&"mapValue"in t}function an(t){var e,n;return"__vector__"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function hn(t){if(t.geoPointValue)return{geoPointValue:Object.assign({},t.geoPointValue)};if(t.timestampValue&&"object"==typeof t.timestampValue)return{timestampValue:Object.assign({},t.timestampValue)};if(t.mapValue){const e={mapValue:{fields:{}}};return be(t.mapValue.fields,(t,n)=>e.mapValue.fields[t]=hn(n)),e}if(t.arrayValue){const e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=hn(t.arrayValue.values[n]);return e}return Object.assign({},t)}function ln(t){return(((t.mapValue||{}).fields||{}).__type__||{}).stringValue===ze}var un=class t{constructor(t){this.value=t}static empty(){return new t({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(e=(e.mapValue.fields||{})[t.get(n)],!on(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=hn(e)}setAll(t){let e=Gt.emptyPath(),n={},i=[];t.forEach((t,s)=>{if(!e.isImmediateParentOf(s)){const t=this.getFieldsMap(e);this.applyChanges(t,n,i),n={},i=[],e=s.popLast()}t?n[s.lastSegment()]=hn(t):i.push(s.lastSegment())});const s=this.getFieldsMap(e);this.applyChanges(s,n,i)}delete(t){const e=this.field(t.popLast());on(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return Xe(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let i=e.mapValue.fields[t.get(n)];on(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=i),e=i}return e.mapValue.fields}
1applyChanges(t,e,n){be(e,(e,n)=>t[e]=n);for(const i of n)delete t[i]}clone(){return new t(hn(this.value))}},cn=class t{constructor(t,e,n,i,s,r,o){this.key=t,this.documentType=e,this.version=n,this.readTime=i,this.createTime=s,this.data=r,this.documentState=o}static newInvalidDocument(e){return new t(e,0,te.min(),te.min(),te.min(),un.empty(),0)}static newFoundDocument(e,n,i,s){return new t(e,1,n,te.min(),i,s,0)}static newNoDocument(e,n){return new t(e,2,n,te.min(),te.min(),un.empty(),0)}static newUnknownDocument(e,n){return new t(e,3,n,te.min(),te.min(),un.empty(),2)}convertToFoundDocument(t,e){return!this.createTime.isEqual(te.min())||2!==this.documentType&&0!==this.documentType||(this.createTime=t),this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=un.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=un.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=te.min(),this}setReadTime(t){return this.readTime=t,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(e){return e instanceof t&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new t(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}},dn=class{constructor(t,e){this.position=t,this.inclusive=e}};function fn(t,e,n){let i=0;for(let s=0;s<t.position.length;s++){const r=e[s],o=t.position[s];if(i=r.field.isKeyField()?Kt.comparator(Kt.fromName(o.referenceValue),n.key):Je(o,n.data.field(r.field)),"desc"===r.dir&&(i*=-1),0!==i)break}return i}function pn(t,e){if(null===t)return null===e;if(null===e)return!1;if(t.inclusive!==e.inclusive||t.position.length!==e.position.length)return!1;for(let n=0;n<t.position.length;n++)if(!Xe(t.position[n],e.position[n]))return!1;return!0}var gn=class{constructor(t,e="asc"){this.field=t,this.dir=e}};function mn(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}var _n=class{},yn=class t extends _n{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(e,n,i){return e.isKeyField()?"in"===n||"not-in"===n?this.createKeyFieldInFilter(e,n,i):new In(e,n,i):"array-contains"===n?new Nn(e,i):"in"===n?new An(e,i):"not-in"===n?new xn(e,i):"array-contains-any"===n?new Dn(e,i):new t(e,n,i)}static createKeyFieldInFilter(t,e,n){return"in"===e?new Sn(t,n):new kn(t,n)}matches(t){const e=t.data.field(this.field);return"!="===this.op?null!==e&&void 0===e.nullValue&&this.matchesComparison(Je(e,this.value)):null!==e&&Qe(this.value)===Qe(e)&&this.matchesComparison(Je(e,this.value))}matchesComparison(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return Tt(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}},vn=class t extends _n{constructor(t,e){super(),this.filters=t,this.op=e,this.he=null}static create(e,n){return new t(e,n)}matches(t){return wn(this)?void 0===this.filters.find(e=>!e.matches(t)):void 0!==this.filters.find(e=>e.matches(t))}getFlattenedFilters(){return null!==this.he||(this.he=this.filters.reduce((t,e)=>t.concat(e.getFlattenedFilters()),[])),this.he}getFilters(){return Object.assign([],this.filters)}};function wn(t){return"and"===t.op}function Tn(t){return function(t){for(const e of t.filters)if(e instanceof vn)return!1;return!0}(t)&&wn(t)}function En(t){if(t instanceof yn)return t.field.canonicalString()+t.op.toString()+en(t.value);if(Tn(t))return t.filters.map(t=>En(t)).join(",");{const e=t.filters.map(t=>En(t)).join(",");return`${t.op}(${e})`}}function Cn(t,e){return t instanceof yn?function(t,e){return e instanceof yn&&t.op===e.op&&t.field.isEqual(e.field)&&Xe(t.value,e.value)}(t,e):t instanceof vn?function(t,e){return e instanceof vn&&t.op===e.op&&t.filters.length===e.filters.length&&t.filters.reduce((t,n,i)=>t&&Cn(n,e.filters[i]),!0)}(t,e):void Tt(19439)}function bn(t){return t instanceof yn?function(t){return`${t.field.canonicalString()} ${t.op} ${en(t.value)}`}(t):t instanceof vn?function(t){return t.op.toString()+" {"+t.getFilters().map(bn).join(" ,")+"}"}(t):"Filter"}var In=class extends yn{constructor(t,e,n){super(t,e,n),this.key=Kt.fromName(n.referenceValue)}matches(t){const e=Kt.comparator(t.key,this.key);return this.matchesComparison(e)}},Sn=class extends yn{constructor(t,e){super(t,"in",e),this.keys=Rn("in",e)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}},kn=class extends yn{constructor(t,e){super(t,"not-in",e),this.keys=Rn("not-in",e)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}};function Rn(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map(t=>Kt.fromName(t.referenceValue))}var Nn=class extends yn{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return rn(e)&&Ye(e.arrayValue,this.value)}},An=class extends yn{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return null!==e&&Ye(this.value.arrayValue,e)}},xn=class extends yn{constructor(t,e){super(t,"not-in",e)}matches(t){if(Ye(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return null!==e&&void 0===e.nullValue&&!Ye(this.value.arrayValue,e)}},Dn=class extends yn{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!rn(e)||!e.arrayValue.values)&&e.arrayValue.values.some(t=>Ye(this.value.arrayValue,t))}},On=class{constructor(t,e=null,n=[],i=[],s=null,r=null,o=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=i,this.limit=s,this.startAt=r,this.endAt=o,this.Pe=null}};function Pn(t,e=null,n=[],i=[],s=null,r=null,o=null){return new On(t,e,n,i,s,r,o)}function Ln(t){const e=bt(t);if(null===e.Pe){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(t=>En(t)).join(","),t+="|ob:",t+=e.orderBy.map(t=>function(t){return t.field.canonicalString()+t.dir}(t)).join(","),he(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(t=>en(t)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(t=>en(t)).join(",")),e.Pe=t}return e.Pe}function Mn(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(let n=0;n<t.orderBy.length;n++)if(!mn(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(let n=0;n<t.filters.length;n++)if(!Cn(t.filters[n],e.filters[n]))return!1;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!pn(t.startAt,e.startAt)&&pn(t.endAt,e.endAt)}var Fn=class{constructor(t,e=null,n=[],i=[],s=null,r="F",o=null,a=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=i,this.limit=s,this.limitType=r,this.startAt=o,this.endAt=a,this.Te=null,this.Ie=null,this.de=null,this.startAt,this.endAt}};function Un(t){return 0===t.filters.length&&null===t.limit&&null==t.startAt&&null==t.endAt&&(0===t.explicitOrderBy.length||1===t.explicitOrderBy.length&&t.explicitOrderBy[0].field.isKeyField())}function Vn(t){const e=bt(t);if(null===e.Te){e.Te=[];const t=new Set;for(const i of e.explicitOrderBy)e.Te.push(i),t.add(i.field.canonicalString());const n=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(t){let e=new Re(Gt.comparator);
1return t.filters.forEach(t=>{t.getFlattenedFilters().forEach(t=>{t.isInequality()&&(e=e.add(t.field))})}),e})(e).forEach(i=>{t.has(i.canonicalString())||i.isKeyField()||e.Te.push(new gn(i,n))}),t.has(Gt.keyField().canonicalString())||e.Te.push(new gn(Gt.keyField(),n))}return e.Te}function qn(t){const e=bt(t);return e.Ie||(e.Ie=function(t,e){if("F"===t.limitType)return Pn(t.path,t.collectionGroup,e,t.filters,t.limit,t.startAt,t.endAt);{e=e.map(t=>{const e="desc"===t.dir?"asc":"desc";return new gn(t.field,e)});const n=t.endAt?new dn(t.endAt.position,t.endAt.inclusive):null,i=t.startAt?new dn(t.startAt.position,t.startAt.inclusive):null;return Pn(t.path,t.collectionGroup,e,t.filters,t.limit,n,i)}}(e,Vn(t))),e.Ie}function jn(t,e,n){return new Fn(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Bn(t,e){return Mn(qn(t),qn(e))&&t.limitType===e.limitType}function Hn(t){return`${Ln(qn(t))}|lt:${t.limitType}`}function Wn(t){return`Query(target=${function(t){let e=t.path.canonicalString();return null!==t.collectionGroup&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=`, filters: [${t.filters.map(t=>bn(t)).join(", ")}]`),he(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=`, orderBy: [${t.orderBy.map(t=>function(t){return`${t.field.canonicalString()} (${t.dir})`}(t)).join(", ")}]`),t.startAt&&(e+=", startAt: ",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map(t=>en(t)).join(",")),t.endAt&&(e+=", endAt: ",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map(t=>en(t)).join(",")),`Target(${e})`}(qn(t))}; limitType=${t.limitType})`}function $n(t,e){return e.isFoundDocument()&&function(t,e){const n=e.key.path;return null!==t.collectionGroup?e.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(n):Kt.isDocumentKey(t.path)?t.path.isEqual(n):t.path.isImmediateParentOf(n)}(t,e)&&function(t,e){for(const n of Vn(t))if(!n.field.isKeyField()&&null===e.data.field(n.field))return!1;return!0}(t,e)&&function(t,e){for(const n of t.filters)if(!n.matches(e))return!1;return!0}(t,e)&&function(t,e){return!(t.startAt&&!function(t,e,n){const i=fn(t,e,n);return t.inclusive?i<=0:i<0}(t.startAt,Vn(t),e))&&!(t.endAt&&!function(t,e,n){const i=fn(t,e,n);return t.inclusive?i>=0:i>0}(t.endAt,Vn(t),e))}(t,e)}function zn(t,e,n){const i=t.field.isKeyField()?Kt.comparator(e.key,n.key):function(t,e,n){const i=e.data.field(t),s=n.data.field(t);return null!==i&&null!==s?Je(i,s):Tt(42886)}(t.field,e,n);switch(t.dir){case"asc":return i;case"desc":return-1*i;default:return Tt(19790,{direction:t.dir})}}var Gn=class{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.innerSize=0}get(t){const e=this.mapKeyFn(t),n=this.inner[e];if(void 0!==n)for(const[i,s]of n)if(this.equalsFn(i,t))return s}has(t){return void 0!==this.get(t)}set(t,e){const n=this.mapKeyFn(t),i=this.inner[n];if(void 0===i)return this.inner[n]=[[t,e]],void this.innerSize++;for(let s=0;s<i.length;s++)if(this.equalsFn(i[s][0],t))return void(i[s]=[t,e]);i.push([t,e]),this.innerSize++}delete(t){const e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(let i=0;i<n.length;i++)if(this.equalsFn(n[i][0],t))return 1===n.length?delete this.inner[e]:n.splice(i,1),this.innerSize--,!0;return!1}forEach(t){be(this.inner,(e,n)=>{for(const[i,s]of n)t(i,s)})}isEmpty(){return function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}(this.inner)}size(){return this.innerSize}},Kn=new Ie(Kt.comparator);function Qn(){return Kn}var Xn=new Ie(Kt.comparator);function Yn(...t){let e=Xn;for(const n of t)e=e.insert(n.key,n);return e}function Jn(t){let e=Xn;return t.forEach((t,n)=>e=e.insert(t,n.overlayedDocument)),e}function Zn(){return ei()}function ti(){return ei()}function ei(){return new Gn(t=>t.toString(),(t,e)=>t.isEqual(e))}new Ie(Kt.comparator);var ni=new Re(Kt.comparator);function ii(...t){let e=ni;for(const n of t)e=e.add(n);return e}var si=new Re(Ut);var ri=class{constructor(){this._=void 0}};function oi(t,e,n){return t instanceof hi?function(t,e){const n={fields:{[Ue]:{stringValue:Fe},[qe]:{timestampValue:{seconds:t.seconds,nanos:t.nanoseconds}}}};return e&&je(e)&&(e=Be(e)),e&&(n.fields[Ve]=e),{mapValue:n}}(n,e):t instanceof li?ui(t,e):t instanceof ci?di(t,e):function(t,e){const n=function(t,e){return t instanceof fi?function(t){return sn(t)||function(t){return!!t&&"doubleValue"in t}(t)}(e)?e:{integerValue:0}:null}(t,e),i=pi(n)+pi(t.Ee);return sn(n)&&sn(t.Ee)?function(t){return{integerValue:""+t}}(i):function(t,e){if(t.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:le(e)?"-0":e}}(t.serializer,i)}(t,e)}function ai(t,e,n){return t instanceof li?ui(t,e):t instanceof ci?di(t,e):n}var hi=class extends ri{},li=class extends ri{constructor(t){super(),this.elements=t}};function ui(t,e){const n=gi(e);for(const i of t.elements)n.some(t=>Xe(t,i))||n.push(i);return{arrayValue:{values:n}}}var ci=class extends ri{constructor(t){super(),this.elements=t}};function di(t,e){let n=gi(e);for(const i of t.elements)n=n.filter(t=>!Xe(t,i));return{arrayValue:{values:n}}}var fi=class extends ri{constructor(t,e){super(),this.serializer
1=t,this.Ee=e}};function pi(t){return Le(t.integerValue||t.doubleValue)}function gi(t){return rn(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}var mi=class t{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new t}static exists(e){return new t(void 0,e)}static updateTime(e){return new t(e)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}};function _i(t,e){return void 0!==t.updateTime?e.isFoundDocument()&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e.isFoundDocument()}var yi=class{};function vi(t,e){if(!t.hasLocalMutations||e&&0===e.fields.length)return null;if(null===e)return t.isNoDocument()?new Ai(t.key,mi.none()):new Ci(t.key,t.data,mi.none());{const n=t.data,i=un.empty();let s=new Re(Gt.comparator);for(let t of e.fields)if(!s.has(t)){let e=n.field(t);null===e&&t.length>1&&(t=t.popLast(),e=n.field(t)),null===e?i.delete(t):i.set(t,e),s=s.add(t)}return new bi(t.key,i,new Ae(s.toArray()),mi.none())}}function wi(t,e,n){t instanceof Ci?function(t,e,n){const i=t.value.clone(),s=Si(t.fieldTransforms,e,n.transformResults);i.setAll(s),e.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(t,e,n):t instanceof bi?function(t,e,n){if(!_i(t.precondition,e))return void e.convertToUnknownDocument(n.version);const i=Si(t.fieldTransforms,e,n.transformResults),s=e.data;s.setAll(Ii(t)),s.setAll(i),e.convertToFoundDocument(n.version,s).setHasCommittedMutations()}(t,e,n):function(t,e,n){e.convertToNoDocument(n.version).setHasCommittedMutations()}(0,e,n)}function Ti(t,e,n,i){return t instanceof Ci?function(t,e,n,i){if(!_i(t.precondition,e))return n;const s=t.value.clone(),r=ki(t.fieldTransforms,i,e);return s.setAll(r),e.convertToFoundDocument(e.version,s).setHasLocalMutations(),null}(t,e,n,i):t instanceof bi?function(t,e,n,i){if(!_i(t.precondition,e))return n;const s=ki(t.fieldTransforms,i,e),r=e.data;return r.setAll(Ii(t)),r.setAll(s),e.convertToFoundDocument(e.version,r).setHasLocalMutations(),null===n?null:n.unionWith(t.fieldMask.fields).unionWith(t.fieldTransforms.map(t=>t.field))}(t,e,n,i):function(t,e,n){return _i(t.precondition,e)?(e.convertToNoDocument(e.version).setHasLocalMutations(),null):n}(t,e,n)}function Ei(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!function(t,e){return void 0===t&&void 0===e||!(!t||!e)&&Bt(t,e,(t,e)=>function(t,e){return t.field.isEqual(e.field)&&function(t,e){return t instanceof li&&e instanceof li||t instanceof ci&&e instanceof ci?Bt(t.elements,e.elements,Xe):t instanceof fi&&e instanceof fi?Xe(t.Ee,e.Ee):t instanceof hi&&e instanceof hi}(t.transform,e.transform)}(t,e))}(t.fieldTransforms,e.fieldTransforms)&&(0===t.type?t.value.isEqual(e.value):1!==t.type||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}var Ci=class extends yi{constructor(t,e,n,i=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}},bi=class extends yi{constructor(t,e,n,i,s=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=i,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}};function Ii(t){const e=new Map;return t.fieldMask.fields.forEach(n=>{if(!n.isEmpty()){const i=t.data.field(n);e.set(n,i)}}),e}function Si(t,e,n){const i=new Map;Ct(t.length===n.length,32656,{Ae:n.length,Re:t.length});for(let s=0;s<n.length;s++){const r=t[s],o=r.transform,a=e.data.field(r.field);i.set(r.field,ai(o,a,n[s]))}return i}function ki(t,e,n){const i=new Map;for(const s of t){const t=s.transform,r=n.data.field(s.field);i.set(s.field,oi(t,r,e))}return i}var Ri,Ni,Ai=class extends yi{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},xi=class{constructor(t,e,n,i){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=i}applyToRemoteDocument(t,e){const n=e.mutationResults;for(let i=0;i<this.mutations.length;i++){const e=this.mutations[i];e.key.isEqual(t.key)&&wi(e,t,n[i])}}applyToLocalView(t,e){for(const n of this.baseMutations)n.key.isEqual(t.key)&&(e=Ti(n,t,e,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(t.key)&&(e=Ti(n,t,e,this.localWriteTime));return e}applyToLocalDocumentSet(t,e){const n=ti();return this.mutations.forEach(i=>
1{const s=t.get(i.key),r=s.overlayedDocument;let o=this.applyToLocalView(r,s.mutatedFields);o=e.has(i.key)?null:o;const a=vi(r,o);null!==a&&n.set(i.key,a),r.isValidDocument()||r.convertToNoDocument(te.min())}),n}keys(){return this.mutations.reduce((t,e)=>t.add(e.key),ii())}isEqual(t){return this.batchId===t.batchId&&Bt(this.mutations,t.mutations,(t,e)=>Ei(t,e))&&Bt(this.baseMutations,t.baseMutations,(t,e)=>Ei(t,e))}},Di=class{constructor(t,e){this.largestBatchId=t,this.mutation=e}getKey(){return this.mutation.key}isEqual(t){return null!==t&&this.mutation===t.mutation}toString(){return`Overlay{\n      largestBatchId: ${this.largestBatchId},\n      mutation: ${this.mutation.toString()}\n    }`}};(Ni=Ri||(Ri={}))[Ni.OK=0]="OK",Ni[Ni.CANCELLED=1]="CANCELLED",Ni[Ni.UNKNOWN=2]="UNKNOWN",Ni[Ni.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Ni[Ni.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Ni[Ni.NOT_FOUND=5]="NOT_FOUND",Ni[Ni.ALREADY_EXISTS=6]="ALREADY_EXISTS",Ni[Ni.PERMISSION_DENIED=7]="PERMISSION_DENIED",Ni[Ni.UNAUTHENTICATED=16]="UNAUTHENTICATED",Ni[Ni.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Ni[Ni.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Ni[Ni.ABORTED=10]="ABORTED",Ni[Ni.OUT_OF_RANGE=11]="OUT_OF_RANGE",Ni[Ni.UNIMPLEMENTED=12]="UNIMPLEMENTED",Ni[Ni.INTERNAL=13]="INTERNAL",Ni[Ni.UNAVAILABLE=14]="UNAVAILABLE",Ni[Ni.DATA_LOSS=15]="DATA_LOSS";new K([4294967295,4294967295],0);var Oi=class{constructor(t,e){this.databaseId=t,this.useProto3Json=e}};function Pi(t){return Ct(!!t,49232),te.fromTimestamp(function(t){const e=Pe(t);return new Zt(e.seconds,e.nanos)}(t))}function Li(t,e){const n=function(t){return new $t(["projects",t.projectId,"databases",t.database])}(t).child("documents");return void 0===e?n:n.child(e)}function Mi(t){const e=function(t){const e=$t.fromString(t);return Ct(function(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}(e),10190,{key:e.toString()}),e}(t);return 4===e.length?$t.emptyPath():function(t){return Ct(t.length>4&&"documents"===t.get(4),29091,{key:t.toString()}),t.popFirst(5)}(e)}function Fi(t){let e=Mi(t.parent);const n=t.structuredQuery,i=n.from?n.from.length:0;let s=null;if(i>0){Ct(1===i,65062);const t=n.from[0];t.allDescendants?s=t.collectionId:e=e.child(t.collectionId)}let r=[];n.where&&(r=function(t){const e=Ui(t);return e instanceof vn&&Tn(e)?e.getFilters():[e]}(n.where));let o=[];n.orderBy&&(o=function(t){return t.map(t=>function(t){return new gn(Vi(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))}(t))}(n.orderBy));let a=null;n.limit&&(a=function(t){let e;return e="object"==typeof t?t.value:t,he(e)?null:e}(n.limit));let h=null;n.startAt&&(h=function(t){const e=!!t.before,n=t.values||[];return new dn(n,e)}(n.startAt));let l=null;return n.endAt&&(l=function(t){const e=!t.before,n=t.values||[];return new dn(n,e)}(n.endAt)),function(t,e,n,i,s,r,o,a){return new Fn(t,e,n,i,s,r,o,a)}(e,s,o,r,a,"F",h,l)}function Ui(t){return void 0!==t.unaryFilter?function(t){switch(t.unaryFilter.op){case"IS_NAN":const e=Vi(t.unaryFilter.field);return yn.create(e,"==",{doubleValue:NaN});case"IS_NULL":const n=Vi(t.unaryFilter.field);return yn.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=Vi(t.unaryFilter.field);return yn.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const s=Vi(t.unaryFilter.field);return yn.create(s,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return Tt(61313);default:return Tt(60726)}}(t):void 0!==t.fieldFilter?function(t){return yn.create(Vi(t.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":return Tt(58110);default:return Tt(50506)}}(t.fieldFilter.op),t.fieldFilter.value)}(t):void 0!==t.compositeFilter?function(t){return vn.create(t.compositeFilter.filters.map(t=>Ui(t)),function(t){switch(t){case"AND":return"and";case"OR":return"or";default:return Tt(1026)}}(t.compositeFilter.op))}(t):Tt(30097,{filter:t})}function Vi(t){return Gt.fromServerFormat(t.fieldPath)}var qi=class{constructor(t){this.gt=t}};function ji(t){const e=Fi({parent:t.parent,structuredQuery:t.structuredQuery});return"LAST"===t.limitType?jn(e,e.limit,"L"):e}var Bi=class{constructor(){}bt(t,e){this.Dt(t,e),e.vt()}Dt(t,e){if("nullValue"in t)this.Ct(e,5);else if("booleanValue"in t)this.Ct(e,10),e.Ft(t.booleanValue?1:0);else if("integerValue"in t)this.Ct(e,15),e.Ft(Le(t.integerValue));else if("doubleValue"in t){const n=Le(t.doubleValue);isNaN(n)?this.Ct(e,13):(this.Ct(e,15),le(n)?e.Ft(0):e.Ft(n))}else if("timestampValue"in t){let n=t.timestampValue;this.Ct(e,20),"string"==typeof n&&(n=Pe(n)),e.Mt(`${n.seconds||""}`),e.Ft(n.nanos||0)}else if("stringValue"in t)this.xt(t.stringValue,e),this.Ot(e);else if("bytesValue"in t)this.Ct(e,30),e.Nt(Me(t.bytesValue)),this.Ot(e);else if("referenceValue"in t)this.Bt(t.referenceValue,e);else if("geoPointValue"in t){const n=t.geoPointValue;this.Ct(e,45),e.Ft(n.latitude||0),e.Ft(n.longitude||0)}else"mapValue"in t?ln(t)?this.Ct(e,Number.MAX_SAFE_INTEGER):an(t)?this.Lt(t.mapValue,e):(this.kt(t.mapValue,e),this.Ot(e)):"arrayValue"in t?(this.qt(t.arrayValue,e),this.Ot(e)):Tt(19022,{Qt:t})}xt(t,e){this.Ct(e,25),this.$t(t,e)}$t(t,e){e.Mt(t)}kt(t,e){const n=t.fields||{};this.Ct(e,55);for(const i of Object.keys(n))this.xt(i,e),this.Dt(n[i],e)}Lt(t,e){var n,i;const s=t.fields||{};this.Ct(e,53);const r=Ke,o=(null===(i=null===(n=s[r].arrayValue)||void 0===n?void 0:n.values)||void 0===i?void 0:i.length)||0;this.Ct(e,15),e.Ft(Le(o)),this.xt(r,e),this.Dt(s[r],e)}qt(t,e){const n=t.values||[];this.Ct(e,50);for(const i of n)this.Dt(i,e)}Bt(t,e){this.Ct(e,37),Kt.fromName(t).path.forEach(t=>{this.Ct(e,60),this.$t(t,e)})}Ct(t,e){t.Ft(e)}Ot(t){t.Ft(2)}};Bi.Ut=new Bi;var Hi=class{constructor(){this.Dn=new Wi}addToCollectionParentIndex(t,e){return this.Dn.add(e),re.resolve()}getCollectionParents(t,e){return re.resolve(this.Dn.getEntries(e))}addFieldIndex(t,e){return re.resolve()}deleteFieldIndex(t,e){return re.resolve()}deleteAllFieldIndexes(t){return re.resolve()}createTargetIndexes(t,e){return re.resolve()}getDocumentsMatchingTarget(t,e){return re.resolve(null)}getIndexType(t,e){return re.resolve(0)}getFieldIndexes(t,e){return re.resolve([])}getNextCollectionGroupToUpdate(t){return re.resolve(null)}getMinOffset(t,e){return re.resolve(ne.min())}getMinOffsetFromCollectionGroup(t,e){return re.resolve(ne.min())}updateCollectionGroup(t,e,n){return re.resolve()}updateIndexEntries(t,e){return re.resolve()}},Wi=class{constructor(){this.index={}}add(t){const e=t.lastSegment(),n=t.popLast(),i=this.index[e]||new Re($t.comparator),s=!i.has(n);return this.index[e]=i.add(n),s}has(t){const e=t.lastSegment(),n=t.popLast(),i=this.index[e];return i&&i.has(n)}getEntries(t){return(this.index[t]||new Re($t.comparator)).toArray()}},$i=41943040,zi=class t{static withCacheSize(e){return new t(e,t.DEFAULT_COLLECTION_PE
1RCENTILE,t.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}};zi.DEFAULT_COLLECTION_PERCENTILE=10,zi.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,zi.DEFAULT=new zi($i,zi.DEFAULT_COLLECTION_PERCENTILE,zi.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),zi.DISABLED=new zi(-1,0,0);var Gi=class t{constructor(t){this._r=t}next(){return this._r+=2,this._r}static ar(){return new t(0)}static ur(){return new t(-1)}},Ki=class{constructor(){this.changes=new Gn(t=>t.toString(),(t,e)=>t.isEqual(e)),this.changesApplied=!1}addEntry(t){this.assertNotApplied(),this.changes.set(t.key,t)}removeEntry(t,e){this.assertNotApplied(),this.changes.set(t,cn.newInvalidDocument(t).setReadTime(e))}getEntry(t,e){this.assertNotApplied();const n=this.changes.get(e);return void 0!==n?re.resolve(n):this.getFromCache(t,e)}getEntries(t,e){return this.getAllFromCache(t,e)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}},Qi=class{constructor(t,e){this.overlayedDocument=t,this.mutatedFields=e}},Xi=class{constructor(t,e,n,i){this.remoteDocumentCache=t,this.mutationQueue=e,this.documentOverlayCache=n,this.indexManager=i}getDocument(t,e){let n=null;return this.documentOverlayCache.getOverlay(t,e).next(i=>(n=i,this.remoteDocumentCache.getEntry(t,e))).next(t=>(null!==n&&Ti(n.mutation,t,Ae.empty(),Zt.now()),t))}getDocuments(t,e){return this.remoteDocumentCache.getEntries(t,e).next(e=>this.getLocalViewOfDocuments(t,e,ii()).next(()=>e))}getLocalViewOfDocuments(t,e,n=ii()){const i=Zn();return this.populateOverlays(t,i,e).next(()=>this.computeViews(t,e,i,n).next(t=>{let e=Yn();return t.forEach((t,n)=>{e=e.insert(t,n.overlayedDocument)}),e}))}getOverlayedDocuments(t,e){const n=Zn();return this.populateOverlays(t,n,e).next(()=>this.computeViews(t,e,n,ii()))}populateOverlays(t,e,n){const i=[];return n.forEach(t=>{e.has(t)||i.push(t)}),this.documentOverlayCache.getOverlays(t,i).next(t=>{t.forEach((t,n)=>{e.set(t,n)})})}computeViews(t,e,n,i){let s=Qn();const r=ei(),o=ei();return e.forEach((t,e)=>{const o=n.get(e.key);i.has(e.key)&&(void 0===o||o.mutation instanceof bi)?s=s.insert(e.key,e):void 0!==o?(r.set(e.key,o.mutation.getFieldMask()),Ti(o.mutation,e,o.mutation.getFieldMask(),Zt.now())):r.set(e.key,Ae.empty())}),this.recalculateAndSaveOverlays(t,s).next(t=>(t.forEach((t,e)=>r.set(t,e)),e.forEach((t,e)=>{var n;return o.set(t,new Qi(e,null!==(n=r.get(t))&&void 0!==n?n:null))}),o))}recalculateAndSaveOverlays(t,e){const n=ei();let i=new Ie((t,e)=>t-e),s=ii();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,e).next(t=>{for(const s of t)s.keys().forEach(t=>{const r=e.get(t);if(null===r)return;let o=n.get(t)||Ae.empty();o=s.applyToLocalView(r,o),n.set(t,o);const a=(i.get(s.batchId)||ii()).add(t);i=i.insert(s.batchId,a)})}).next(()=>{const r=[],o=i.getReverseIterator();for(;o.hasNext();){const i=o.getNext(),a=i.key,h=i.value,l=ti();h.forEach(t=>{if(!s.has(t)){const i=vi(e.get(t),n.get(t));null!==i&&l.set(t,i),s=s.add(t)}}),r.push(this.documentOverlayCache.saveOverlays(t,a,l))}return re.waitFor(r)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(t,e){return this.remoteDocumentCache.getEntries(t,e).next(e=>this.recalculateAndSaveOverlays(t,e))}getDocumentsMatchingQuery(t,e,n,i){return function(t){return Kt.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}(e)?this.getDocumentsMatchingDocumentQuery(t,e.path):function(t){return null!==t.collectionGroup}(e)?this.getDocumentsMatchingCollectionGroupQuery(t,e,n,i):this.getDocumentsMatchingCollectionQuery(t,e,n,i)}getNextDocuments(t,e,n,i){return this.remoteDocumentCache.getAllFromCollectionGroup(t,e,n,i).next(s=>{const r=i-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(t,e,n.largestBatchId,i-s.size):re.resolve(Zn());let o=-1,a=s;return r.next(e=>re.forEach(e,(e,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),s.get(e)?re.resolve():this.remoteDocumentCache.getEntry(t,e).next(t=>{a=a.insert(e,t)}))).next(()=>this.populateOverlays(t,e,s)).next(()=>this.computeViews(t,a,e,ii())).next(t=>({batchId:o,changes:Jn(t)})))})}getDocumentsMatchingDocumentQuery(t,e){return this.getDocument(t,new Kt(e)).next(t=>{let e=Yn();
1return t.isFoundDocument()&&(e=e.insert(t.key,t)),e})}getDocumentsMatchingCollectionGroupQuery(t,e,n,i){const s=e.collectionGroup;let r=Yn();return this.indexManager.getCollectionParents(t,s).next(o=>re.forEach(o,o=>{const a=function(t,e){return new Fn(e,null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(e,o.child(s));return this.getDocumentsMatchingCollectionQuery(t,a,n,i).next(t=>{t.forEach((t,e)=>{r=r.insert(t,e)})})}).next(()=>r))}getDocumentsMatchingCollectionQuery(t,e,n,i){let s;return this.documentOverlayCache.getOverlaysForCollection(t,e.path,n.largestBatchId).next(r=>(s=r,this.remoteDocumentCache.getDocumentsMatchingQuery(t,e,n,s,i))).next(t=>{s.forEach((e,n)=>{const i=n.getKey();null===t.get(i)&&(t=t.insert(i,cn.newInvalidDocument(i)))});let n=Yn();return t.forEach((t,i)=>{const r=s.get(t);void 0!==r&&Ti(r.mutation,i,Ae.empty(),Zt.now()),$n(e,i)&&(n=n.insert(t,i))}),n})}},Yi=class{constructor(t){this.serializer=t,this.Br=new Map,this.Lr=new Map}getBundleMetadata(t,e){return re.resolve(this.Br.get(e))}saveBundleMetadata(t,e){return this.Br.set(e.id,function(t){return{id:t.id,version:t.version,createTime:Pi(t.createTime)}}(e)),re.resolve()}getNamedQuery(t,e){return re.resolve(this.Lr.get(e))}saveNamedQuery(t,e){return this.Lr.set(e.name,function(t){return{name:t.name,query:ji(t.bundledQuery),readTime:Pi(t.readTime)}}(e)),re.resolve()}},Ji=class{constructor(){this.overlays=new Ie(Kt.comparator),this.kr=new Map}getOverlay(t,e){return re.resolve(this.overlays.get(e))}getOverlays(t,e){const n=Zn();return re.forEach(e,e=>this.getOverlay(t,e).next(t=>{null!==t&&n.set(e,t)})).next(()=>n)}saveOverlays(t,e,n){return n.forEach((n,i)=>{this.wt(t,e,i)}),re.resolve()}removeOverlaysForBatchId(t,e,n){const i=this.kr.get(n);return void 0!==i&&(i.forEach(t=>this.overlays=this.overlays.remove(t)),this.kr.delete(n)),re.resolve()}getOverlaysForCollection(t,e,n){const i=Zn(),s=e.length+1,r=new Kt(e.child("")),o=this.overlays.getIteratorFrom(r);for(;o.hasNext();){const t=o.getNext().value,r=t.getKey();if(!e.isPrefixOf(r.path))break;r.path.length===s&&t.largestBatchId>n&&i.set(t.getKey(),t)}return re.resolve(i)}getOverlaysForCollectionGroup(t,e,n,i){let s=new Ie((t,e)=>t-e);const r=this.overlays.getIterator();for(;r.hasNext();){const t=r.getNext().value;if(t.getKey().getCollectionGroup()===e&&t.largestBatchId>n){let e=s.get(t.largestBatchId);null===e&&(e=Zn(),s=s.insert(t.largestBatchId,e)),e.set(t.getKey(),t)}}const o=Zn(),a=s.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach((t,e)=>o.set(t,e)),!(o.size()>=i)););return re.resolve(o)}wt(t,e,n){const i=this.overlays.get(n.key);if(null!==i){const t=this.kr.get(i.largestBatchId).delete(n.key);this.kr.set(i.largestBatchId,t)}this.overlays=this.overlays.insert(n.key,new Di(e,n));let s=this.kr.get(e);void 0===s&&(s=ii(),this.kr.set(e,s)),this.kr.set(e,s.add(n.key))}},Zi=class{constructor(){this.sessionToken=De.EMPTY_BYTE_STRING}getSessionToken(t){return re.resolve(this.sessionToken)}setSessionToken(t,e){return this.sessionToken=e,re.resolve()}},ts=class{constructor(){this.qr=new Re(es.Qr),this.$r=new Re(es.Ur)}isEmpty(){return this.qr.isEmpty()}addReference(t,e){const n=new es(t,e);this.qr=this.qr.add(n),this.$r=this.$r.add(n)}Kr(t,e){t.forEach(t=>this.addReference(t,e))}removeReference(t,e){this.Wr(new es(t,e))}Gr(t,e){t.forEach(t=>this.removeReference(t,e))}zr(t){const e=new Kt(new $t([])),n=new es(e,t),i=new es(e,t+1),s=[];return this.$r.forEachInRange([n,i],t=>{this.Wr(t),s.push(t.key)}),s}jr(){this.qr.forEach(t=>this.Wr(t))}Wr(t){this.qr=this.qr.delete(t),this.$r=this.$r.delete(t)}Jr(t){const e=new Kt(new $t([])),n=new es(e,t),i=new es(e,t+1);let s=ii();return this.$r.forEachInRange([n,i],t=>{s=s.add(t.key)}),s}containsKey(t){const e=new es(t,0),n=this.qr.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)}},es=class{constructor(t,e){this.key=t,this.Hr=e}static Qr(t,e){return Kt.comparator(t.key,e.key)||Ut(t.Hr,e.Hr)}static Ur(t,e){return Ut(t.Hr,e.Hr)||Kt.comparator(t.key,e.key)}},ns=class{constructor(t,e){this.indexManager=t,this.referenceDelegate=e,this.mutation
1Queue=[],this.er=1,this.Yr=new Re(es.Qr)}checkEmpty(t){return re.resolve(0===this.mutationQueue.length)}addMutationBatch(t,e,n,i){const s=this.er;this.er++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const r=new xi(s,e,n,i);this.mutationQueue.push(r);for(const o of i)this.Yr=this.Yr.add(new es(o.key,s)),this.indexManager.addToCollectionParentIndex(t,o.key.path.popLast());return re.resolve(r)}lookupMutationBatch(t,e){return re.resolve(this.Zr(e))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,i=this.Xr(n),s=i<0?0:i;return re.resolve(this.mutationQueue.length>s?this.mutationQueue[s]:null)}getHighestUnacknowledgedBatchId(){return re.resolve(0===this.mutationQueue.length?-1:this.er-1)}getAllMutationBatches(t){return re.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(t,e){const n=new es(e,0),i=new es(e,Number.POSITIVE_INFINITY),s=[];return this.Yr.forEachInRange([n,i],t=>{const e=this.Zr(t.Hr);s.push(e)}),re.resolve(s)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new Re(Ut);return e.forEach(t=>{const e=new es(t,0),i=new es(t,Number.POSITIVE_INFINITY);this.Yr.forEachInRange([e,i],t=>{n=n.add(t.Hr)})}),re.resolve(this.ei(n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,i=n.length+1;let s=n;Kt.isDocumentKey(s)||(s=s.child(""));const r=new es(new Kt(s),0);let o=new Re(Ut);return this.Yr.forEachWhile(t=>{const e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===i&&(o=o.add(t.Hr)),!0)},r),re.resolve(this.ei(o))}ei(t){const e=[];return t.forEach(t=>{const n=this.Zr(t);null!==n&&e.push(n)}),e}removeMutationBatch(t,e){Ct(0===this.ti(e.batchId,"removed"),55003),this.mutationQueue.shift();let n=this.Yr;return re.forEach(e.mutations,i=>{const s=new es(i.key,e.batchId);return n=n.delete(s),this.referenceDelegate.markPotentiallyOrphaned(t,i.key)}).next(()=>{this.Yr=n})}rr(t){}containsKey(t,e){const n=new es(e,0),i=this.Yr.firstAfterOrEqual(n);return re.resolve(e.isEqual(i&&i.key))}performConsistencyCheck(t){return this.mutationQueue.length,re.resolve()}ti(t,e){return this.Xr(t)}Xr(t){return 0===this.mutationQueue.length?0:t-this.mutationQueue[0].batchId}Zr(t){const e=this.Xr(t);return e<0||e>=this.mutationQueue.length?null:this.mutationQueue[e]}},is=class{constructor(t){this.ni=t,this.docs=new Ie(Kt.comparator),this.size=0}setIndexManager(t){this.indexManager=t}addEntry(t,e){const n=e.key,i=this.docs.get(n),s=i?i.size:0,r=this.ni(e);return this.docs=this.docs.insert(n,{document:e.mutableCopy(),size:r}),this.size+=r-s,this.indexManager.addToCollectionParentIndex(t,n.path.popLast())}removeEntry(t){const e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)}getEntry(t,e){const n=this.docs.get(e);return re.resolve(n?n.document.mutableCopy():cn.newInvalidDocument(e))}getEntries(t,e){let n=Qn();return e.forEach(t=>{const e=this.docs.get(t);n=n.insert(t,e?e.document.mutableCopy():cn.newInvalidDocument(t))}),re.resolve(n)}getDocumentsMatchingQuery(t,e,n,i){let s=Qn();const r=e.path,o=new Kt(r.child("__id-9223372036854775808__")),a=this.docs.getIteratorFrom(o);for(;a.hasNext();){const{key:t,value:{document:o}}=a.getNext();if(!r.isPrefixOf(t.path))break;t.path.length>r.length+1||ie(ee(o),n)<=0||(i.has(o.key)||$n(e,o))&&(s=s.insert(o.key,o.mutableCopy()))}return re.resolve(s)}getAllFromCollectionGroup(t,e,n,i){Tt(9500)}ri(t,e){return re.forEach(this.docs,t=>e(t))}newChangeBuffer(t){return new ss(this)}getSize(t){return re.resolve(this.size)}},ss=class extends Ki{constructor(t){super(),this.Or=t}applyChanges(t){const e=[];
1return this.changes.forEach((n,i)=>{i.isValidDocument()?e.push(this.Or.addEntry(t,i)):this.Or.removeEntry(n)}),re.waitFor(e)}getFromCache(t,e){return this.Or.getEntry(t,e)}getAllFromCache(t,e){return this.Or.getEntries(t,e)}},rs=class{constructor(t){this.persistence=t,this.ii=new Gn(t=>Ln(t),Mn),this.lastRemoteSnapshotVersion=te.min(),this.highestTargetId=0,this.si=0,this.oi=new ts,this.targetCount=0,this._i=Gi.ar()}forEachTarget(t,e){return this.ii.forEach((t,n)=>e(n)),re.resolve()}getLastRemoteSnapshotVersion(t){return re.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return re.resolve(this.si)}allocateTargetId(t){return this.highestTargetId=this._i.next(),re.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.si&&(this.si=e),re.resolve()}hr(t){this.ii.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this._i=new Gi(e),this.highestTargetId=e),t.sequenceNumber>this.si&&(this.si=t.sequenceNumber)}addTargetData(t,e){return this.hr(e),this.targetCount+=1,re.resolve()}updateTargetData(t,e){return this.hr(e),re.resolve()}removeTargetData(t,e){return this.ii.delete(e.target),this.oi.zr(e.targetId),this.targetCount-=1,re.resolve()}removeTargets(t,e,n){let i=0;const s=[];return this.ii.forEach((r,o)=>{o.sequenceNumber<=e&&null===n.get(o.targetId)&&(this.ii.delete(r),s.push(this.removeMatchingKeysForTargetId(t,o.targetId)),i++)}),re.waitFor(s).next(()=>i)}getTargetCount(t){return re.resolve(this.targetCount)}getTargetData(t,e){const n=this.ii.get(e)||null;return re.resolve(n)}addMatchingKeys(t,e,n){return this.oi.Kr(e,n),re.resolve()}removeMatchingKeys(t,e,n){this.oi.Gr(e,n);const i=this.persistence.referenceDelegate,s=[];return i&&e.forEach(e=>{s.push(i.markPotentiallyOrphaned(t,e))}),re.waitFor(s)}removeMatchingKeysForTargetId(t,e){return this.oi.zr(e),re.resolve()}getMatchingKeysForTargetId(t,e){const n=this.oi.Jr(e);return re.resolve(n)}containsKey(t,e){return re.resolve(this.oi.containsKey(e))}},os=class{constructor(t,e){this.ai={},this.overlays={},this.ui=new ae(0),this.ci=!1,this.ci=!0,this.li=new Zi,this.referenceDelegate=t(this),this.hi=new rs(this),this.indexManager=new Hi,this.remoteDocumentCache=function(t){return new is(t)}(t=>this.referenceDelegate.Pi(t)),this.serializer=new qi(e),this.Ti=new Yi(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ci=!1,Promise.resolve()}get started(){return this.ci}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(t){return this.indexManager}getDocumentOverlayCache(t){let e=this.overlays[t.toKey()];return e||(e=new Ji,this.overlays[t.toKey()]=e),e}getMutationQueue(t,e){let n=this.ai[t.toKey()];return n||(n=new ns(e,this.referenceDelegate),this.ai[t.toKey()]=n),n}getGlobalsCache(){return this.li}getTargetCache(){return this.hi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ti}runTransaction(t,e,n){_t("MemoryPersistence","Starting transaction:",t);const i=new as(this.ui.next());return this.referenceDelegate.Ii(),n(i).next(t=>this.referenceDelegate.di(i).next(()=>t)).toPromise().then(t=>(i.raiseOnCommittedEvent(),t))}Ei(t,e){return re.or(Object.values(this.ai).map(n=>()=>n.containsKey(t,e)))}},as=class extends se{constructor(t){super(),this.currentSequenceNumber=t}},hs=class t{constructor(t){this.persistence=t,this.Ai=new ts,this.Ri=null}static Vi(e){return new t(e)}get mi(){if(this.Ri)return this.Ri;throw Tt(60996)}addReference(t,e,n){return this.Ai.addReference(n,e),this.mi.delete(n.toString()),re.resolve()}removeReference(t,e,n){return this.Ai.removeReference(n,e),this.mi.add(n.toString()),re.resolve()}markPotentiallyOrphaned(t,e){return this.mi.add(e.toString()),re.resolve()}removeTarget(t,e){this.Ai.zr(e.targetId).forEach(t=>this.mi.add(t.toString()));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(t,e.targetId).next(t=>{t.forEach(t=>this.mi.add(t.toString()))}).next(()=>n.removeTargetData(t,e))}Ii(){this.Ri=new Set}di(t){const e=this.persistence.getRemoteDocumentCache().newChangeBuffer();return re.forEach(this.mi,n=>{const i=Kt.fromPath(n);return this.fi(t,i).next(t=>{t||e.removeEntry(i,te.min())})}).next(()=>(this.Ri=null,e.apply(t)))}updateLimboDocument(t,e){return this.fi(t,e).next(t=>{t?this.mi.delete(e.toString()):this.mi.add(e.toString())})}Pi(t){return 0}fi(t,e){return re.or([()=>re.resolve(this.Ai.containsKey(e)),()=>this.persistence.getTargetCache().containsKey(t,e),()=>this.persistence.Ei(t,e)])}},ls=class t{constructor(t,e,n,i){this.targetId=t,this.fromCache=e,this.Is=n,this.ds=i}static Es(e,n){let i=ii(),s=ii();for(const t of n.docChanges)switch(t.type){case 0:i=i.add(t.doc.key);break;case 1:s=s.add(t.doc.key)}return new t(e,n.fromCache,i,s)}},us=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(t){this._documentReadCount+=t}},cs=class{constructor(){this.As=!1,this.Rs=!1,this.Vs=100,this.fs=T()?8:function(t){const e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)}(p())>0?6:4}initialize(t,e){this.gs=t,this.indexManager=e,this.As=!0}getDocumentsMatchingQuery(t,e,n,i){const s={result:null};return this.ps(t,e).next(t=>{s.result=t}).next(()=>{if(!s.result)return this.ys(t,e,i,n).next(t=>{s.result=t})}).next(()=>{if(s.result)return;const n=new us;return this.ws(t,e,n).next(i=>{if(s.result=i,this.Rs)return this.Ss(t,e,n,i.size)})}).next(()=>s.result)}Ss(t,e,n,i){return n.documentReadCount<this.Vs?(mt()<=z.DEBUG&&_t("QueryEngine","SDK will not create cache indexes for query:",Wn(e),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),re.resolve()):(mt()<=z.DEBUG&&_t("QueryEngine","Query:",Wn(e),"scans",n.documentReadCount,"local documents and returns",i,"documents as results."),n.documentReadCount>this.fs*i?(mt()<=z.DEBUG&&_t("QueryEngine","The SDK decides to create cache indexes for query:",Wn(e),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(t,qn(e))):re.resolve())}ps(t,e){if(Un(e))return re.resolve(null);let n=qn(e);return this.indexManager.getIndexType(t,n).next(i=>0===i?null:(null!==e.limit&&1===i&&(e=jn(e,null,"F"),n=qn(e)),this.indexManager.getDocumentsMatchingTarget(t,n).next(i=>{const s=ii(...i);return this.gs.getDocuments(t,s).next(i=>this.indexManager.getMinOffset(t,n).next(n=>{const r=this.bs(e,i);return this.Ds(e,r,s,n.readTime)?this.ps(t,jn(e,null,"F")):this.vs(t,r,e,n)}))})))}ys(t,e,n,i){return Un(e)||i.isEqual(te.min())?re.resolve(null):this.gs.getDocuments(t,n).next(s=>{const r=this.bs(e,s);return this.Ds(e,r,n,i)?re.resolve(null):(mt()<=z.DEBUG&&_t("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),Wn(e)),this.vs(t,r,e,function(t,e){const n=t.toTimestamp().seconds,i=t.toTimestamp().nanoseconds+1,s=te.fromTimestamp(1e9===i?new Zt(n+1,0):new Zt(n,i));return new ne(s,Kt.empty(),e)}(i,-1)).next(t=>t))})}bs(t,e){let n=new Re(function(t){return(e,n)=>{let i=!1;for(const s of Vn(t)){const t=zn(s,e,n);if(0!==t)return t;i=i||s.field.isKeyField()}return 0}}(t));return e.forEach((e,i)=>{$n(t,i)&&(n=n.add(i))}),n}Ds(t,e,n,i){if(null===t.limit)return!1;if(n.size!==e.size)return!0;const s="F"===t.limitType?e.last():e.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(i)>0)}ws(t,e,n){return mt()<=z.DEBUG&&_t("QueryEngine","Using full collection scan to execute query:",Wn(e)),this.gs.getDocumentsMatchingQuery(t,e,ne.min(),n)}vs(t,e,n,i){return this.gs.getDocumentsMatchingQuery(t,n,i).next(t=>
1(e.forEach(e=>{t=t.insert(e.key,e)}),t))}},ds=class{constructor(t,e,n,i){this.persistence=t,this.Cs=e,this.serializer=i,this.Fs=new Ie(Ut),this.Ms=new Gn(t=>Ln(t),Mn),this.xs=new Map,this.Os=t.getRemoteDocumentCache(),this.hi=t.getTargetCache(),this.Ti=t.getBundleCache(),this.Ns(n)}Ns(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new Xi(this.Os,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Os.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",e=>t.collect(e,this.Fs))}};var fs=class{constructor(){this.activeTargetIds=si}Gs(t){this.activeTargetIds=this.activeTargetIds.add(t)}zs(t){this.activeTargetIds=this.activeTargetIds.delete(t)}Ws(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}},ps=class{constructor(){this.Fo=new fs,this.Mo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t,e=!0){return e&&this.Fo.Gs(t),this.Mo[t]||"not-current"}updateQueryState(t,e,n){this.Mo[t]=e}removeLocalQueryTarget(t){this.Fo.zs(t)}isLocalQueryTarget(t){return this.Fo.activeTargetIds.has(t)}clearQueryState(t){delete this.Mo[t]}getAllActiveQueryTargets(){return this.Fo.activeTargetIds}isActiveQueryTarget(t){return this.Fo.activeTargetIds.has(t)}start(){return this.Fo=new fs,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}},gs=class{xo(t){}shutdown(){}},ms="ConnectivityMonitor",_s=class{constructor(){this.Oo=()=>this.No(),this.Bo=()=>this.Lo(),this.ko=[],this.qo()}xo(t){this.ko.push(t)}shutdown(){window.removeEventListener("online",this.Oo),window.removeEventListener("offline",this.Bo)}qo(){window.addEventListener("online",this.Oo),window.addEventListener("offline",this.Bo)}No(){_t(ms,"Network connectivity changed: AVAILABLE");for(const t of this.ko)t(0)}Lo(){_t(ms,"Network connectivity changed: UNAVAILABLE");for(const t of this.ko)t(1)}static C(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}},ys=null;function vs(){return null===ys?ys=268435456+Math.round(2147483648*Math.random()):ys++,"0x"+ys.toString(16)}var ws="RestConnection",Ts={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"},Es=class{get Qo(){return!1}constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),i=encodeURIComponent(this.databaseId.database);this.$o=e+"://"+t.host,this.Uo=`projects/${n}/databases/${i}`,this.Ko=this.databaseId.database===We?`project_id=${n}`:`project_id=${n}&database_id=${i}`}Wo(t,e,n,i,s){const r=vs(),o=this.Go(t,e.toUriEncodedString());_t(ws,`Sending RPC '${t}' ${r}:`,o,n);const h={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.Ko};this.zo(h,i,s);const{host:l}=new URL(o),u=a(l);return this.jo(t,o,h,n,u).then(e=>(_t(ws,`Received RPC '${t}' ${r}: `,e),e),e=>{throw vt(ws,`RPC '${t}' ${r} failed with error: `,e,"url: ",o,"request:",n),e})}Jo(t,e,n,i,s,r){return this.Wo(t,e,n,i,s)}zo(t,e,n){t["X-Goog-Api-Client"]="gl-js/ fire/"+pt,t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach((e,n)=>t[n]=e),n&&n.headers.forEach((e,n)=>t[n]=e)}Go(t,e){const n=Ts[t];return`${this.$o}/v1/${e}:${n}`}terminate(){}},Cs=class{constructor(t){this.Ho=t.Ho,this.Yo=t.Yo}Zo(t){this.Xo=t}e_(t){this.t_=t}n_(t){this.r_=t}onMessage(t){this.i_=t}close(){this.Yo()}send(t){this.Ho(t)}s_(){this.Xo()}o_(){this.t_()}__(t){this.r_(t)}a_(t){this.i_(t)}},bs="WebChannelConnection",Is=class extends Es{constructor(t){super(t),this.u_=[],this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams,this.longPollingOptions=t.longPollingOptions}jo(t,e,n,i,s){const r=vs();return new Promise((s,o)=>{const a=new et;a.setWithCredentials(!0),a.listenOnce(it.COMPLETE,()=>{try{switch(a.getLastErrorCode()){case st.NO_ERROR:const e=a.getResponseJson();_t(bs,`XHR for RPC '${t}' ${r} received:`,JSON.stringify(e)),s(e);break;case st.TIMEOUT:_t(bs,`RPC '${t}' ${r} timed out`),o(new St(It.DEADLINE_EXCEEDED,"Request time out"));break;case st.HTTP_ERROR:const n=a.getStatus();if(_t(bs,`RPC '${t}' ${r} failed with status:`,n,"response text:",a.getResponseText()),n>0){let t=a.getResponseJson();Array.isArray(t)&&(t=t[0]);const e=null==t?void 0:t.error;if(e&&e.status&&e.message){const t=function(t){const e=t.toLowerCase().replace(/_/g,"-");return Object.values(It).indexOf(e)>=0?e:It.UNKNOWN}(e.status);o(new St(t,e.message))}else o(new St(It.UNKNOWN,"Server responded with status "+a.getStatus()))}else o(new St(It.UNAVAILABLE,"Connection failed."));break;default:Tt(9055,{c_:t,streamId:r,l_:a.getLastErrorCode(),h_:a.getLastError()})}}finally{_t(bs,`RPC '${t}' ${r} completed.`)}});const h=JSON.stringify(i);_t(bs,`RPC '${t}' ${r} sending request:`,i),a.send(e,"POST",h,n,15)})}P_(t,e,n){const i=vs(),s=[this.$o,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=ht(),o=at
1(),a={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},h=this.longPollingOptions.timeoutSeconds;void 0!==h&&(a.longPollingTimeout=Math.round(1e3*h)),this.useFetchStreams&&(a.useFetchStreams=!0),this.zo(a.initMessageHeaders,e,n),a.encodeInitMessageHeaders=!0;const l=s.join("");_t(bs,`Creating RPC '${t}' stream ${i}: ${l}`,a);const u=r.createWebChannel(l,a);this.T_(u);let c=!1,d=!1;const f=new Cs({Ho:e=>{d?_t(bs,`Not sending because RPC '${t}' stream ${i} is closed:`,e):(c||(_t(bs,`Opening RPC '${t}' stream ${i} transport.`),u.open(),c=!0),_t(bs,`RPC '${t}' stream ${i} sending:`,e),u.send(e))},Yo:()=>u.close()}),p=(t,e,n)=>{t.listen(e,t=>{try{n(t)}catch(t){setTimeout(()=>{throw t},0)}})};return p(u,nt.EventType.OPEN,()=>{d||(_t(bs,`RPC '${t}' stream ${i} transport opened.`),f.s_())}),p(u,nt.EventType.CLOSE,()=>{d||(d=!0,_t(bs,`RPC '${t}' stream ${i} transport closed`),f.__(),this.I_(u))}),p(u,nt.EventType.ERROR,e=>{d||(d=!0,vt(bs,`RPC '${t}' stream ${i} transport errored. Name:`,e.name,"Message:",e.message),f.__(new St(It.UNAVAILABLE,"The operation could not be completed")))}),p(u,nt.EventType.MESSAGE,e=>{var n;if(!d){const s=e.data[0];Ct(!!s,16349);const r=s,o=(null==r?void 0:r.error)||(null===(n=r[0])||void 0===n?void 0:n.error);if(o){_t(bs,`RPC '${t}' stream ${i} received error:`,o);const e=o.status;let n=function(t){const e=Ri[t];if(void 0!==e)return function(t){if(void 0===t)return yt("GRPC error has no .code"),It.UNKNOWN;switch(t){case Ri.OK:return It.OK;case Ri.CANCELLED:return It.CANCELLED;case Ri.UNKNOWN:return It.UNKNOWN;case Ri.DEADLINE_EXCEEDED:return It.DEADLINE_EXCEEDED;case Ri.RESOURCE_EXHAUSTED:return It.RESOURCE_EXHAUSTED;case Ri.INTERNAL:return It.INTERNAL;case Ri.UNAVAILABLE:return It.UNAVAILABLE;case Ri.UNAUTHENTICATED:return It.UNAUTHENTICATED;case Ri.INVALID_ARGUMENT:return It.INVALID_ARGUMENT;case Ri.NOT_FOUND:return It.NOT_FOUND;case Ri.ALREADY_EXISTS:return It.ALREADY_EXISTS;case Ri.PERMISSION_DENIED:return It.PERMISSION_DENIED;case Ri.FAILED_PRECONDITION:return It.FAILED_PRECONDITION;case Ri.ABORTED:return It.ABORTED;case Ri.OUT_OF_RANGE:return It.OUT_OF_RANGE;case Ri.UNIMPLEMENTED:return It.UNIMPLEMENTED;case Ri.DATA_LOSS:return It.DATA_LOSS;default:return Tt(39323,{code:t})}}(e)}(e),s=o.message;void 0===n&&(n=It.INTERNAL,s="Unknown error status: "+e+" with message "+o.message),d=!0,f.__(new St(n,s)),u.close()}else _t(bs,`RPC '${t}' stream ${i} received:`,s),f.a_(s)}}),p(o,ot.STAT_EVENT,e=>{e.stat===rt.PROXY?_t(bs,`RPC '${t}' stream ${i} detected buffering proxy`):e.stat===rt.NOPROXY&&_t(bs,`RPC '${t}' stream ${i} detected no buffering proxy`)}),setTimeout(()=>{f.o_()},0),f}terminate(){this.u_.forEach(t=>t.close()),this.u_=[]}T_(t){this.u_.push(t)}I_(t){this.u_=this.u_.filter(e=>e===t)}};function Ss(){return"undefined"!=typeof document?document:null}function ks(t){return new Oi(t,!0)}var Rs=class{constructor(t,e,n=1e3,i=1.5,s=6e4){this.Fi=t,this.timerId=e,this.d_=n,this.E_=i,this.A_=s,this.R_=0,this.V_=null,this.m_=Date.now(),this.reset()}reset(){this.R_=0}f_(){this.R_=this.A_}g_(t){this.cancel();const e=Math.floor(this.R_+this.p_()),n=Math.max(0,Date.now()-this.m_),i=Math.max(0,e-n);i>0&&_t("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.R_} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.V_=this.Fi.enqueueAfterDelay(this.timerId,i,()=>(this.m_=Date.now(),t())),this.R_*=this.E_,this.R_<this.d_&&(this.R_=this.d_),this.R_>this.A_&&(this.R_=this.A_)}y_(){null!==this.V_&&(this.V_.skipDelay(),this.V_=null)}cancel(){null!==this.V_&&(this.V_.cancel(),this.V_=null)}p_(){return(Math.random()-.5)*this.R_}},Ns=class{},As=class extends Ns{constructor(t,e,n,i){super(),this.authCredentials=t,this.appCheckCredentials=e,this.connection=n,this.serializer=i,this.ra=!1}ia(){if(this.ra)throw new St(It.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(t,e,n,i){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,r])=>this.connection.Wo(t,Li(e,n),i,s,r)).catch(t=>{throw"FirebaseError"===t.name?(t.code===It.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new St(It.UNKNOWN,t.toString())})}Jo(t,e,n,i,s){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([r,o])=>this.connection.Jo(t,Li(e,n),i,r,o,s)).catch(t=>{throw"FirebaseError"===t.name?(t.code===It.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new St(It.UNKNOWN,t.toString())})}terminate(){this.ra=!0,this.connection.terminate()}},xs=class{constructor(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.sa=0,this.oa=null,this._a=!0}aa(){0===this.sa&&(this.ua("Unknown"),this.oa=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.oa=null,this.ca("Backend didn't respond within 10 seconds."),this.ua("Offline"),Promise.resolve())))}la(t){"Online"===this.state?this.ua("Unknown"):(this.sa++,this.sa>=1&&(this.ha(),this.ca(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.ua("Offline")))}set(t){this.ha(),this.sa=0,"Online"===t&&(this._a=!1),this.ua(t)}ua(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}ca(t){const e=`Could not reach Cloud Firestore backend. ${t}\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this._a?(yt(e),this._a=!1):_t("OnlineStateTracker",e)}ha(){null!==this.oa&&(this.oa.cancel(),this.oa=null)}},Ds="RemoteStore",Os=class{constructor(t,e,n,i,s){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.Pa=[],this.Ta=new Map,this.Ia=new Set,this.da=[],this.Ea=s,this.Ea.xo(t=>{n.enqueueAndForget(async()=>
1{Ms(this)&&(_t(Ds,"Restarting streams for network reachability change."),await async function(t){const e=bt(t);e.Ia.add(4),await Ls(e),e.Aa.set("Unknown"),e.Ia.delete(4),await Ps(e)}(this))})}),this.Aa=new xs(n,i)}};async function Ps(t){if(Ms(t))for(const e of t.da)await e(!0)}async function Ls(t){for(const e of t.da)await e(!1)}function Ms(t){return 0===bt(t).Ia.size}var Fs,Us,Vs=class t{constructor(t,e,n,i,s){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=i,this.removalCallback=s,this.deferred=new kt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(t=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,n,i,s,r){const o=Date.now()+i,a=new t(e,n,o,s,r);return a.start(i),a}start(t){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new St(It.CANCELLED,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then(t=>this.deferred.resolve(t))):Promise.resolve())}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}},qs=class{constructor(){this.queries=js(),this.onlineState="Unknown",this.Da=new Set}terminate(){!function(t,e){const n=bt(t),i=n.queries;n.queries=js(),i.forEach((t,n)=>{for(const i of n.wa)i.onError(e)})}(this,new St(It.ABORTED,"Firestore shutting down"))}};function js(){return new Gn(t=>Hn(t),Bn)}(Us=Fs||(Fs={})).Fa="default",Us.Cache="cache";var Bs=class{constructor(t,e,n,i,s,r){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=i,this.currentUser=s,this.maxConcurrentLimboResolutions=r,this.hu={},this.Pu=new Gn(t=>Hn(t),Bn),this.Tu=new Map,this.Iu=new Set,this.du=new Ie(Kt.comparator),this.Eu=new Map,this.Au=new ts,this.Ru={},this.Vu=new Map,this.mu=Gi.ur(),this.onlineState="Unknown",this.fu=void 0}get isPrimaryClient(){return!0===this.fu}};function Hs(t,e,n){const i=bt(t);if(i.isPrimaryClient&&0===n||!i.isPrimaryClient&&1===n){const t=[];i.Pu.forEach((n,i)=>{const s=i.view.va(e);s.snapshot&&t.push(s.snapshot)}),function(t,e){const n=bt(t);n.onlineState=e;let i=!1;n.queries.forEach((t,n)=>{for(const s of n.wa)s.va(e)&&(i=!0)}),i&&function(t){t.Da.forEach(t=>{t.next()})}(n)}(i.eventManager,e),t.length&&i.hu.J_(t),i.onlineState=e,i.isPrimaryClient&&i.sharedClientState.setOnlineState(e)}}async function Ws(t,e){const n=bt(t);if(!n.currentUser.isEqual(e)){_t("SyncEngine","User change. New user:",e.toKey());const t=await async function(t,e){const n=bt(t);return await n.persistence.runTransaction("Handle user change","readonly",t=>{let i;
1return n.mutationQueue.getAllMutationBatches(t).next(s=>(i=s,n.Ns(e),n.mutationQueue.getAllMutationBatches(t))).next(e=>{const s=[],r=[];let o=ii();for(const t of i){s.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}for(const t of e){r.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}return n.localDocuments.getDocuments(t,o).next(t=>({Bs:t,removedBatchIds:s,addedBatchIds:r}))})})}(n.localStore,e);n.currentUser=e,function(t,e){t.Vu.forEach(t=>{t.forEach(t=>{t.reject(new St(It.CANCELLED,e))})}),t.Vu.clear()}(n,"'waitForPendingWrites' promise is rejected due to a user change."),n.sharedClientState.handleUserChange(e,t.removedBatchIds,t.addedBatchIds),await async function(t,e,n){const i=bt(t),s=[],r=[],o=[];i.Pu.isEmpty()||(i.Pu.forEach((t,a)=>{o.push(i.gu(a,e,n).then(t=>{var e;if((t||n)&&i.isPrimaryClient){const s=t?!t.fromCache:null===(e=null==n?void 0:n.targetChanges.get(a.targetId))||void 0===e?void 0:e.current;i.sharedClientState.updateQueryState(a.targetId,s?"current":"not-current")}if(t){s.push(t);const e=ls.Es(a.targetId,t);r.push(e)}}))}),await Promise.all(o),i.hu.J_(s),await async function(t,e){const n=bt(t);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",t=>re.forEach(e,e=>re.forEach(e.Is,i=>n.persistence.referenceDelegate.addReference(t,e.targetId,i)).next(()=>re.forEach(e.ds,i=>n.persistence.referenceDelegate.removeReference(t,e.targetId,i)))))}catch(t){if(!oe(t))throw t;_t("LocalStore","Failed to update sequence numbers: "+t)}for(const i of e){const t=i.targetId;if(!i.fromCache){const e=n.Fs.get(t),i=e.snapshotVersion,s=e.withLastLimboFreeSnapshotVersion(i);n.Fs=n.Fs.insert(t,s)}}}(i.localStore,r))}(n,t.Bs)}}var $s=class{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(t){this.serializer=ks(t.databaseInfo.databaseId),this.sharedClientState=this.bu(t),this.persistence=this.Du(t),await this.persistence.start(),this.localStore=this.vu(t),this.gcScheduler=this.Cu(t,this.localStore),this.indexBackfillerScheduler=this.Fu(t,this.localStore)}Cu(t,e){return null}Fu(t,e){return null}vu(t){return function(t,e,n,i){return new ds(t,e,n,i)}(this.persistence,new cs,t.initialUser,this.serializer)}Du(t){return new os(hs.Vi,this.serializer)}bu(t){return new ps}async terminate(){var t,e;null===(t=this.gcScheduler)||void 0===t||t.stop(),null===(e=this.indexBackfillerScheduler)||void 0===e||e.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};$s.provider={build:()=>new $s};var zs=class{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=t=>Hs(this.syncEngine,t,1),this.remoteStore.remoteSyncer.handleCredentialChange=Ws.bind(null,this.syncEngine),await async function(t,e){const n=bt(t);e?(n.Ia.delete(2),await Ps(n)):e||(n.Ia.add(2),await Ls(n),n.Aa.set("Unknown"))}(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return new qs}createDatastore(t){const e=ks(t.databaseInfo.databaseId),n=function(t){return new Is(t)}(t.databaseInfo);return function(t,e,n,i){return new As(t,e,n,i)}(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return function(t,e,n,i,s){return new Os(t,e,n,i,s)}(this.localStore,this.datastore,t.asyncQueue,t=>Hs(this.syncEngine,t,0),_s.C()?new _s:new gs)}createSyncEngine(t,e){return function(t,e,n,i,s,r,o){const a=new Bs(t,e,n,i,s,r);return o&&(a.fu=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}async terminate(){var t,e;await async function(t){const e=bt(t);_t(Ds,"RemoteStore shutting down."),e.Ia.add(5),await Ls(e),e.Ea.shutdown(),e.Aa.set("Unknown")}(this.remoteStore),null===(t=this.datastore)||void 0===t||t.terminate(),null===(e=this.eventManager)||void 0===e||e.terminate()}};zs.provider={build:()=>new zs};var Gs=new Map,Ks=!0,Qs=class{constructor(t){var e,n;if(void 0===t.host){if(void 0!==t.ssl)throw new St(It.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=Ks}else this.host=t.host,this.ssl=null!==(e=t.ssl)&&void 0!==e?e:Ks;if(this.isUsingEmulator=void 0!==t.emulatorOptions,this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,this.localCache=t.localCache,void 0===t.cacheSizeBytes)this.cacheSizeBytes=$i;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new St(It.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}(function(t,e,n,i){if(!0===e&&!0===i)throw new St(It.INVALID_ARGUMENT,`${t} and ${n} cannot be used together.`)})("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===t.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=function(t){const e={};return void 0!==t.timeoutSeconds&&(e.timeoutSeconds=t.timeoutSeconds),e}(null!==(n=t.experimentalLongPollingOptions)&&void 0!==n?n:{}),function(t){if(void 0!==t.timeoutSeconds){if(isNaN(t.timeoutSeconds))throw new St(It.INVALID_ARGUMENT,`invalid long polling timeout: ${t.timeoutSeconds} (must not be NaN)`);if(t.timeoutSeconds<5)throw new St(It.INVALID_ARGUMENT,`invalid long polling timeout: ${t.timeoutSeconds} (minimum allowed value is 5)`);if(t.timeoutSeconds>30)throw new St(It.INVALID_ARGUMENT,`invalid long polling timeout: ${t.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!t.useFetchStreams}isEqual(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&&function(t,e){return t.timeoutSeconds===e.timeoutSeconds}(this.experimentalLongPollingOptions,t.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}},Xs=class{constructor(t,e,n,i){this._authCredentials=t,this._appCheckCredentials=e,this._databaseId=n,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Qs({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new St(It.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return"notTerminated"!==this._terminateTask}_setSettings(t){if(this._settingsFrozen)throw new St(It.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 Qs(t),this._emulatorOptions=t.emulatorOptions||{},void 0!==t.credentials&&(this._authCredentials=function(t){if(!t)return new Nt;switch(t.type){case"firstParty":return new Dt(t.sessionIndex||"0",t.i
1amToken||null,t.authTokenFactory||null);case"provider":return t.client;default:throw new St(It.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(t.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const e=Gs.get(t);e&&(_t("ComponentProvider","Removing Datastore"),Gs.delete(t),e.terminate())}(this),Promise.resolve()}},Ys=class t{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(e){return new t(this.firestore,e,this._query)}},Js=class t{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Zs(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new t(this.firestore,e,this._key)}toJSON(){return{type:t._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,n,i){if(Xt(n,t._jsonSchema))return new t(e,i||null,new Kt($t.fromString(n.referencePath)))}};Js._jsonSchemaVersion="firestore/documentReference/1.0",Js._jsonSchema={type:Qt("string",Js._jsonSchemaVersion),referencePath:Qt("string")};var Zs=class t extends Ys{constructor(t,e,n){super(t,e,function(t){return new Fn(t)}(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new Js(this.firestore,null,new Kt(t))}withConverter(e){return new t(this.firestore,e,this._path)}},tr="AsyncQueue",er=class{constructor(t=Promise.resolve()){this.Zu=[],this.Xu=!1,this.ec=[],this.tc=null,this.nc=!1,this.rc=!1,this.sc=[],this.F_=new Rs(this,"async_queue_retry"),this.oc=()=>{const t=Ss();t&&_t(tr,"Visibility state changed to "+t.visibilityState),this.F_.y_()},this._c=t;const e=Ss();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.oc)}get isShuttingDown(){return this.Xu}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.ac(),this.uc(t)}enterRestrictedMode(t){if(!this.Xu){this.Xu=!0,this.rc=t||!1;const e=Ss();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("visibilitychange",this.oc)}}enqueue(t){if(this.ac(),this.Xu)return new Promise(()=>{});const e=new kt;return this.uc(()=>this.Xu&&this.rc?Promise.resolve():(t().then(e.resolve,e.reject),e.promise)).then(()=>e.promise)}enqueueRetryable(t){this.enqueueAndForget(()=>(this.Zu.push(t),this.cc()))}async cc(){if(0!==this.Zu.length){try{await this.Zu[0](),this.Zu.shift(),this.F_.reset()}catch(t){if(!oe(t))throw t;_t(tr,"Operation failed with retryable error: "+t)}this.Zu.length>0&&this.F_.g_(()=>this.cc())}}uc(t){const e=this._c.then(()=>(this.nc=!0,t().catch(t=>{throw this.tc=t,this.nc=!1,yt("INTERNAL UNHANDLED ERROR: ",nr(t)),t}).then(t=>(this.nc=!1,t))));return this._c=e,e}enqueueAfterDelay(t,e,n){this.ac(),this.sc.indexOf(t)>-1&&(e=0);const i=Vs.createAndSchedule(this,t,e,n,t=>this.lc(t));return this.ec.push(i),i}ac(){this.tc&&Tt(47125,{hc:nr(this.tc)})}verifyOperationInProgress(){}async Pc(){let t;do{t=this._c,await t}while(t!==this._c)}Tc(t){for(const e of this.ec)if(e.timerId===t)return!0;return!1}Ic(t){return this.Pc().then(()=>{this.ec.sort((t,e)=>t.targetTimeMs-e.targetTimeMs);for(const e of this.ec)if(e.skipDelay(),"all"!==t&&e.timerId===t)break;return this.Pc()})}dc(t){this.sc.push(t)}lc(t){const e=this.ec.indexOf(t);this.ec.splice(e,1)}};function nr(t){let e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e}var ir=class extends Xs{constructor(t,e,n,i){super(t,e,n,i),this.type="firestore",this._queue=new er,this._persistenceKey=(null==i?void 0:i.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const t=this._firestoreClient.terminate();this._queue=new er(t),this._firestoreClient=void 0,await t}}},sr=class t{constructor(t){this._byteString=t}static fromBase64String(e){try{return new t(De.fromBase64String(e))}catch(e){throw new St(It.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new t(De.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}toJSON(){return{type:t._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(Xt(e,t._jsonSchema))return t.fromBase64String(e.bytes)}};
1sr._jsonSchemaVersion="firestore/bytes/1.0",sr._jsonSchema={type:Qt("string",sr._jsonSchemaVersion),bytes:Qt("string")};var rr=class{constructor(...t){for(let e=0;e<t.length;++e)if(0===t[e].length)throw new St(It.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new Gt(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}},or=class t{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new St(It.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new St(It.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}_compareTo(t){return Ut(this._lat,t._lat)||Ut(this._long,t._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:t._jsonSchemaVersion}}static fromJSON(e){if(Xt(e,t._jsonSchema))return new t(e.latitude,e.longitude)}};or._jsonSchemaVersion="firestore/geoPoint/1.0",or._jsonSchema={type:Qt("string",or._jsonSchemaVersion),latitude:Qt("number"),longitude:Qt("number")};var ar=class t{constructor(t){this._values=(t||[]).map(t=>t)}toArray(){return this._values.map(t=>t)}isEqual(t){return function(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;++n)if(t[n]!==e[n])return!1;return!0}(this._values,t._values)}toJSON(){return{type:t._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(Xt(e,t._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(t=>"number"==typeof t))return new t(e.vectorValues);throw new St(It.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}};ar._jsonSchemaVersion="firestore/vectorValue/1.0",ar._jsonSchema={type:Qt("string",ar._jsonSchemaVersion),vectorValues:Qt("object")};var hr=new RegExp("[~\\*/\\[\\]]");function lr(t,e,n,i,s){const r=i&&!i.isEmpty(),o=void 0!==s;let a=`Function ${e}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let h="";return(r||o)&&(h+=" (found",r&&(h+=` in field ${i}`),o&&(h+=` in document ${s}`),h+=")"),new St(It.INVALID_ARGUMENT,a+t+h)}var ur=class{constructor(t,e,n,i,s){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=i,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new Js(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const t=new cr(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(dr("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}}},cr=class extends ur{data(){return super.data()}};function dr(t,e){return"string"==typeof e?function(t,e,n){if(e.search(hr)>=0)throw lr(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new rr(...e.split("."))._internalPath}catch(i){throw lr(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}(t,e):e instanceof rr?e._internalPath:e._delegate._internalPath}var fr=class{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}},pr=class t extends ur{constructor(t,e,n,i,s,r){super(t,e,n,i,r),this._firestore=t,this._firestoreImpl=t,this.metadata=s}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new gr(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){const n=this._document.data.field(dr("DocumentSnapshot.get",t));if(null!==n)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new St(It.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,n={};return n.type=t._jsonSchemaVersion,n.bundle="",n.bundleSource="DocumentSnapshot",n.bundleName=this._key.toString(),e&&e.isValidDocument()&&e.isFoundDocument()?(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),n.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),n):n}};pr._jsonSchemaVersion="firestore/documentSnapshot/1.0",pr._jsonSchema={type:Qt("string",pr._jsonSchemaVersion),bundleSource:Qt("string","DocumentSnapshot"),bundleName:Qt("string"),bundle:Qt("string")};var gr=class extends pr{data(t={}){return super.data(t)}},mr=class t{constructor(t,e,n,i){this._firestore=t,this._userDataWriter=e,this._snapshot=i,this.metadata=new fr(i.hasPendingWrites,i.fromCache),this.query=n}get docs(){const t=[];
1return this.forEach(e=>t.push(e)),t}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(t,e){this._snapshot.docs.forEach(n=>{t.call(e,new gr(this._firestore,this._userDataWriter,n.key,n,new fr(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(t={}){const e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new St(It.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(t,e){if(t._snapshot.oldDocs.isEmpty()){let e=0;return t._snapshot.docChanges.map(n=>{const i=new gr(t._firestore,t._userDataWriter,n.doc.key,n.doc,new fr(t._snapshot.mutatedKeys.has(n.doc.key),t._snapshot.fromCache),t.query.converter);return n.doc,{type:"added",doc:i,oldIndex:-1,newIndex:e++}})}{let n=t._snapshot.oldDocs;return t._snapshot.docChanges.filter(t=>e||3!==t.type).map(e=>{const i=new gr(t._firestore,t._userDataWriter,e.doc.key,e.doc,new fr(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query.converter);let s=-1,r=-1;return 0!==e.type&&(s=n.indexOf(e.doc.key),n=n.delete(e.doc.key)),1!==e.type&&(n=n.add(e.doc),r=n.indexOf(e.doc.key)),{type:_r(e.type),doc:i,oldIndex:s,newIndex:r}})}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new St(It.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=t._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=Ft.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const n=[],i=[],s=[];return this.docs.forEach(t=>{null!==t._document&&(n.push(t._document),i.push(this._userDataWriter.convertObjectMap(t._document.data.value.mapValue.fields,"previous")),s.push(t.ref.path))}),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}};function _r(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Tt(61501,{type:t})}}mr._jsonSchemaVersion="firestore/querySnapshot/1.0",mr._jsonSchema={type:Qt("string",mr._jsonSchemaVersion),bundleSource:Qt("string","QuerySnapshot"),bundleName:Qt("string"),bundle:Qt("string")},function(t,e=!0){(function(t){pt=t})(R),O(new M("firestore",(t,{instanceIdentifier:n,options:i})=>{const s=t.getProvider("app").getImmediate(),r=new ir(new At(t.getProvider("auth-internal")),new Pt(s,t.getProvider("app-check-internal")),function(t,e){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new St(It.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new $e(t.options.projectId,e)}(s,n),s);return i=Object.assign({useFetchStreams:e},i),r._setSettings(i),r},"PUBLIC").setMultipleInstances(!0)),S(ct,dt,t),S(ct,dt,"esm2017")}();var yr,vr=[];!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(yr||(yr={}));var wr={debug:yr.DEBUG,verbose:yr.VERBOSE,info:yr.INFO,warn:yr.WARN,error:yr.ERROR,silent:yr.SILENT},Tr=yr.INFO,Er={[yr.DEBUG]:"log",[yr.VERBOSE]:"log",[yr.INFO]:"info",[yr.WARN]:"warn",[yr.ERROR]:"error"},Cr=(t,e,...n)=>{if(e<t.logLevel)return;const i=(new Date).toISOString(),s=Er[e];if(!s)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[s](`[${i}]  ${t.name}:`,...n)},br="@firebase/database",Ir="1.0.20",Sr="";var kr=class{constructor(t){this.domStorage_=t,this.prefix_="firebase:"}set(t,e){null==e?this.domStorage_.removeItem(this.prefixedName_(t)):this.domStorage_.setItem(this.prefixedName_(t),C(e))}get(t){const e=this.domStorage_.getItem(this.prefixedName_(t));return null==e?null:w(e)}remove(t){this.domStorage_.removeItem(this.prefixedName_(t))}prefixedName_(t){return this.prefix_+t}toString(){return this.domStorage_.toString()}},Rr=class{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(t,e){null==e?delete this.cache_[t]:this.cache_[t]=e}get(t){return r(this.cache_,t)?this.cache_[t]:null}remove(t){delete this.cache_[t]}},Nr=function(t){try{if("undefined"!=typeof window&&void 0!==window[t]){const e=window[t];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new kr(e)}}catch(e){}return new Rr},Ar=Nr("localStorage"),xr=Nr("sessionStorage"),Dr=new class{constructor(t){this.name=t,this._logLevel=Tr,this._logHandler=Cr,this._userLogHandler=null,vr.push(this)}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in yr))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel="string"==typeof t?wr[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,yr.DEBUG,...t),this._logHandler(this,yr.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,yr.VERBOSE,...t),this._logHandler(this,yr.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,yr.INFO,...t),this._logHandler(this,yr.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,yr.WARN,...t),this._logHandler(this,yr.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,yr.ERROR,...t),this._logHandler(this,yr.ERROR,...t)}}("@firebase/database"),Or=function(){let t=1;return function(){return t++}}(),Pr=function(t){const e=b(t),n=new y;n.update(e);const i=n.digest();return v.encodeByteArray(i)},Lr=function(...t){let e="";for(let n=0;n<t.length;n++){const i=t[n];Array.isArray(i)||i&&"object"==typeof i&&"number"==typeof i.length?e+=Lr.apply(null,i):e+="object"==typeof i?C(i):i,e+=" "}return e},Mr=null,Fr=!0,Ur=function(...t){var e,n;if(!0===Fr&&(Fr=!1,null===Mr&&!0===xr.get("logging_enabled")&&(e=!0,s(!n||!0===e||!1===e,"Can't turn on custom loggers persistently."),!0===e?(Dr.logLevel=yr.VERBOSE,Mr=Dr.log.bind(Dr),n&&xr.set("logging_enabled",!0)):"function"==typeof e?Mr=e:(Mr=null,xr.remove("logging_enabled")))),Mr){const e=Lr.apply(null,t);Mr(e)}},Vr=function(t){return function(...e){Ur(t,...e)}},qr=function(...t){const e="FIREBASE INTERNAL ERROR: "+Lr(...t);Dr.error(e)},jr=function(...t){const e=`FIREBASE FATAL ERROR: ${Lr(...t)}`;throw Dr.error(e),new Error(e)},Br=function(...t){const e="FIREBASE WARNING: "+Lr(...t);Dr.warn(e)},Hr=function(t){return"number"==typeof t&&(t!=t||t===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY)},Wr="[MIN_NAME]",$r="[MAX_NAME]",zr=function(t,e){if(t===e)return 0;if(t===Wr||e===$r)return-1;if(e===Wr||t===$r)return 1;{const n=to(t),i=to(e);return null!==n?null!==i?n-i===0?t.length-e.length:n-i:-1:null!==i?1:t<e?-1:1}},Gr=function(t,e){return t===e?0:t<e?-1:1},Kr=function(t,e){if(e&&t in e)return e[t];throw new Error("Missing required key ("+t+") in object: "+C(e))},Qr=function(t){if("object"!=typeof t||null===t)return C(t);const e=[];for(const i in t)e.push(i);e.sort();let n="{";for(let i=0;i<e.length;i++)0!==i&&(n+=","),n+=C(e[i]),n+=":",n+=Qr(t[e[i]]);return n+="}",n},Xr=function(t,e){const n=t.length;if(n<=e)return[t];const i=[];for(let s=0;s<n;s+=e)s+e>n?i.push(t.substring(s,n)):i.push(t.substring(s,s+e));return i};function Yr(t,e){for(const n in t)t.hasOwnProperty(n)&&e(n,t[n])}var Jr=function(t){s(!Hr(t),"Invalid JSON number");let e,n,i,r,o;0===t?(n=0,i=0,e=1/t==-1/0?1:0):(e=t<0,(t=Math.abs(t))>=Math.pow(2,-1022)?(r=Math.min(Math.floor(Math.log(t)/Math.LN2),1023),n=r+1023,i=Math.round(t*Math.pow(2,52-r)-Math.pow(2,52))):(n=0,i=Math.round(t/Math.pow(2,-1074))));const a=[];for(o=52;o;o-=1)a.push(i%2?1:0),i=Math.floor(i/2);for(o=11;o;o-=1)a.push(n%2?1:0),n=Math.floor(n/2);a.push(e?1:0),a.reverse();const h=a.join("");let l="";for(o=0;o<64;o+=8){let t=parseInt(h.substr(o,8),2).toString(16);1===t.length&&(t="0"+t),l+=t}return l.toLowerCase()}
1,Zr=new RegExp("^-?(0*)\\d{1,10}$"),to=function(t){if(Zr.test(t)){const e=Number(t);if(e>=-2147483648&&e<=2147483647)return e}return null},eo=function(t){try{t()}catch(e){setTimeout(()=>{const t=e.stack||"";throw Br("Exception was thrown by user callback.",t),e},Math.floor(0))}},no=function(t,e){const n=setTimeout(t,e);return"number"==typeof n&&"undefined"!=typeof Deno&&Deno.unrefTimer?Deno.unrefTimer(n):"object"==typeof n&&n.unref&&n.unref(),n},io=class{constructor(t,e){this.appCheckProvider=e,this.appName=t.name,P(t)&&t.settings.appCheckToken&&(this.serverAppAppCheckToken=t.settings.appCheckToken),this.appCheck=null==e?void 0:e.getImmediate({optional:!0}),this.appCheck||null==e||e.get().then(t=>this.appCheck=t)}getToken(t){if(this.serverAppAppCheckToken){if(t)throw new Error("Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.");return Promise.resolve({token:this.serverAppAppCheckToken})}return this.appCheck?this.appCheck.getToken(t):new Promise((e,n)=>{setTimeout(()=>{this.appCheck?this.getToken(t).then(e,n):e(null)},0)})}addTokenChangeListener(t){var e;null===(e=this.appCheckProvider)||void 0===e||e.get().then(e=>e.addTokenListener(t))}notifyForInvalidToken(){Br(`Provided AppCheck credentials for the app named "${this.appName}" are invalid. This usually indicates your app was not initialized correctly.`)}},so=class{constructor(t,e,n){this.appName_=t,this.firebaseOptions_=e,this.authProvider_=n,this.auth_=null,this.auth_=n.getImmediate({optional:!0}),this.auth_||n.onInit(t=>this.auth_=t)}getToken(t){return this.auth_?this.auth_.getToken(t).catch(t=>t&&"auth/token-not-initialized"===t.code?(Ur("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(t)):new Promise((e,n)=>{setTimeout(()=>{this.auth_?this.getToken(t).then(e,n):e(null)},0)})}addTokenChangeListener(t){this.auth_?this.auth_.addAuthTokenListener(t):this.authProvider_.get().then(e=>e.addAuthTokenListener(t))}removeTokenChangeListener(t){this.authProvider_.get().then(e=>e.removeAuthTokenListener(t))}notifyForInvalidToken(){let t='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?t+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?t+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':t+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',Br(t)}},ro=class{constructor(t){this.accessToken=t}getToken(t){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(t){t(this.accessToken)}removeTokenChangeListener(t){}notifyForInvalidToken(){}};ro.OWNER="owner";var oo="5",ao=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,ho="ac",lo="websocket",uo="long_polling",co=class{constructor(t,e,n,i,s=!1,r="",o=!1,a=!1,h=null){this.secure=e,this.namespace=n,this.webSocketOnly=i,this.nodeAdmin=s,this.persistenceKey=r,this.includeNamespaceInQueryParams=o,this.isUsingEmulator=a,this.emulatorOptions=h,this._host=t.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=Ar.get("host:"+t)||this._host}isCacheableHost(){return"s-"===this.internalHost.substr(0,2)}isCustomHost(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain}get host(){return this._host}set host(t){t!==this.internalHost&&(this.internalHost=t,this.isCacheableHost()&&Ar.set("host:"+this._host,this.internalHost))}toString(){let t=this.toURLString();return this.persistenceKey&&(t+="<"+this.persistenceKey+">"),t}toURLString(){const t=this.secure?"https://":"http://",e=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${t}${this.host}/${e}`}};function fo(t,e,n){let i;if(s("string"==typeof e,"typeof type must == string"),s("object"==typeof n,"typeof params must == object"),e===lo)i=(t.secure?"wss://":"ws://")+t.internalHost+"/.ws?";else{if(e!==uo)throw new Error("Unknown connection type: "+e);i=(t.secure?"https://":"http://")+t.internalHost+"/.lp?"}(function(t){return t.host!==t.internalHost||t.isCustomHost()||t.includeNamespaceInQueryParams})(t)&&(n.ns=t.namespace);const r=[];return Yr(n,(t,e)=>{r.push(t+"="+e)}
1),i+r.join("&")}var po=class{constructor(){this.counters_={}}incrementCounter(t,e=1){r(this.counters_,t)||(this.counters_[t]=0),this.counters_[t]+=e}get(){return D(this.counters_)}},go={},mo={};function _o(t){const e=t.toString();return go[e]||(go[e]=new po),go[e]}var yo=class{constructor(t){this.onMessage_=t,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(t,e){this.closeAfterResponse=t,this.onClose=e,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(t,e){for(this.pendingResponses[t]=e;this.pendingResponses[this.currentResponseNum];){const t=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let e=0;e<t.length;++e)t[e]&&eo(()=>{this.onMessage_(t[e])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}},vo="start",wo=class t{constructor(t,e,n,i,s,r,o){this.connId=t,this.repoInfo=e,this.applicationId=n,this.appCheckToken=i,this.authToken=s,this.transportSessionId=r,this.lastSessionId=o,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Vr(t),this.stats_=_o(e),this.urlFn=t=>(this.appCheckToken&&(t[ho]=this.appCheckToken),fo(e,uo,t))}open(t,e){this.curSegmentNum=0,this.onDisconnect_=e,this.myPacketOrderer=new yo(t),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(3e4)),function(t){if(q()||"complete"===document.readyState)t();else{let e=!1;const n=function(){document.body?e||(e=!0,t()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{"complete"===document.readyState&&n()}),window.attachEvent("onload",n))}}(()=>{if(this.isClosed_)return;this.scriptTagHolder=new To((...t)=>{const[e,n,i,s,r]=t;if(this.incrementIncomingBytes_(t),this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,e===vo)this.id=n,this.password=i;else{if("close"!==e)throw new Error("Unrecognized command received: "+e);n?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(n,()=>{this.onClosed_()})):this.onClosed_()}},(...t)=>{const[e,n]=t;this.incrementIncomingBytes_(t),this.myPacketOrderer.handleResponse(e,n)},()=>{this.onClosed_()},this.urlFn);const t={};t[vo]="t",t.ser=Math.floor(1e8*Math.random()),this.scriptTagHolder.uniqueCallbackIdentifier&&(t.cb=this.scriptTagHolder.uniqueCallbackIdentifier),t.v=oo,this.transportSessionId&&(t.s=this.transportSessionId),this.lastSessionId&&(t.ls=this.lastSessionId),this.applicationId&&(t.p=this.applicationId),this.appCheckToken&&(t[ho]=this.appCheckToken),"undefined"!=typeof location&&location.hostname&&ao.test(location.hostname)&&(t.r="f");const e=this.urlFn(t);this.log_("Connecting via long-poll to "+e),this.scriptTagHolder.addTag(e,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){t.forceAllow_=!0}static forceDisallow(){t.forceDisallow_=!0}static isAvailable(){return!q()&&(!!t.forceAllow_||!(t.forceDisallow_||"undefined"==typeof document||null==document.createElement||"object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href)||"object"==typeof Windows&&"object"==typeof Windows.UI))}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(t){const e=C(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);const n=o(e),i=Xr(n,1840);for(let s=0;s<i.length;s++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[s]),this.curSegmentNum++}addDisconnectPingFrame(t,e){if(q())return;this.myDisconnFrame=document.createElement("iframe");const n={dframe:"t"};n.id=t,n.pw=e,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(t){const e=C(t).length;this.bytesReceived+=e,this.stats_.incrementCounter("bytes_received",e)}},To=class t{constructor(e,n,i,s){if(this.onDisconnect=i,this.urlFn=s,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0,q())this.commandCB=e,this.onMessageCB=n;else{this.uniqueCallbackIdentifier=Or(),window["pLPCommand"+this.uniqueCallbackIdentifier]=e,window["pRTLPCB"+this.uniqueCallbackIdentifier]=n,this.myIFrame=t.createI
1Frame_();let i="";this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,11)&&(i='<script>document.domain="'+document.domain+'";<\/script>');const s="<html><body>"+i+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(s),this.myIFrame.doc.close()}catch(r){Ur("frame writing exception"),r.stack&&Ur(r.stack),Ur(r)}}}static createIFrame_(){const t=document.createElement("iframe");if(t.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(t);try{t.contentWindow.document||Ur("No IE domain setting required")}catch(e){t.src="javascript:void((function(){document.open();document.domain='"+document.domain+"';document.close();})())"}return t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document),t}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{null!==this.myIFrame&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const t=this.onDisconnect;t&&(this.onDisconnect=null,t())}startLongPoll(t,e){for(this.myID=t,this.myPW=e,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const t={};t.id=this.myID,t.pw=this.myPW,t.ser=this.currentSerial;let e=this.urlFn(t),n="",i=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+30+n.length<=1870;){const t=this.pendingSegs.shift();n=n+"&seg"+i+"="+t.seg+"&ts"+i+"="+t.ts+"&d"+i+"="+t.d,i++}return e+=n,this.addLongPollTag_(e,this.currentSerial),!0}return!1}enqueueSegment(t,e,n){this.pendingSegs.push({seg:t,ts:e,d:n}),this.alive&&this.newRequest_()}addLongPollTag_(t,e){this.outstandingRequests.add(e);const n=()=>{this.outstandingRequests.delete(e),this.newRequest_()},i=setTimeout(n,Math.floor(25e3));this.addTag(t,()=>{clearTimeout(i),n()})}addTag(t,e){q()?this.doNodeLongPoll(t,e):setTimeout(()=>{try{if(!this.sendNewPolls)return;const n=this.myIFrame.doc.createElement("script");n.type="text/javascript",n.async=!0,n.src=t,n.onload=n.onreadystatechange=function(){const t=n.readyState;t&&"loaded"!==t&&"complete"!==t||(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),e())},n.onerror=()=>{Ur("Long-poll script failed to load: "+t),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(n)}catch(n){}},Math.floor(1))}},Eo=null;"undefined"!=typeof MozWebSocket?Eo=MozWebSocket:"undefined"!=typeof WebSocket&&(Eo=WebSocket);var Co=class t{constructor(e,n,i,s,r,o,a){this.connId=e,this.applicationId=i,this.appCheckToken=s,this.authToken=r,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Vr(this.connId),this.stats_=_o(n),this.connURL=t.connectionURL_(n,o,a,s,i),this.nodeAdmin=n.nodeAdmin}static connectionURL_(t,e,n,i,s){const r={};return r.v=oo,!q()&&"undefined"!=typeof location&&location.hostname&&ao.test(location.hostname)&&(r.r="f"),e&&(r.s=e),n&&(r.ls=n),i&&(r[ho]=i),s&&(r.p=s),fo(t,lo,r)}open(t,e){this.onDisconnect=e,this.onMessage=t,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,Ar.set("previous_websocket_failure",!0);try{let t;if(q()){const e=this.nodeAdmin?"AdminNode":"Node";t={headers:{"User-Agent":`Firebase/${oo}/${Sr}/${process.platform}/${e}`,"X-Firebase-GMPID":this.applicationId||""}},this.authToken&&(t.headers.Authorization=`Bearer ${this.authToken}`),this.appCheckToken&&(t.headers["X-Firebase-AppCheck"]=this.appCheckToken);const n={},i=0===this.connURL.indexOf("wss://")?n.HTTPS_PROXY||n.https_proxy:n.HTTP_PROXY||n.http_proxy;i&&(t.proxy={origin:i})}this.mySock=new Eo(this.connURL,[],t)}catch(n){this.log_("Error instantiating WebSocket.");const t=n.message||n.data;return t&&this.log_(t),void this.onClosed_()}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=t=>{this.handleIncomingFrame(t)},this.mySock.onerror=t=>{this.log_("WebSocket error.  Closing connection.");const e=t.message||t.data;e&&this.log_(e),this.onClosed_()}}start(){}static forceDisallow(){t.forceDisallow_=!0}static isAvailable(){let e=!1;if("undefined"!=typeof navigator&&navigator.userAgent){const t=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/);t&&t.length>1&&parseFloat(t[1])<4.4&&(e=!0)}return!e&&null!==Eo&&!t.forceDisallow_}static previouslyFailed(){return Ar.isInMemoryStorage||!0===Ar.get("previous_websocket_failure")}markConnectionHealthy(){Ar.remove("previous_websocket_failure")}appendFrame_(t){if(this.frames.push(t),this.frames.length===this.totalFrames){const t=this.frames.join("");this.frames=null;const e=w(t);this.onMessage(e)}}handleNewFrameCount_(t){this.totalFrames=t,this.frames=[]}extractFrameCount_(t){if(s(null===this.frames,"We already have a frame buffer"),t.length<=6){const e=Number(t);if(!isNaN(e))return this.handleNewFrameCount_(e),null}return this.handleNewFrameCount_(1),t}handleIncomingFrame(t){if(null===this.mySock)return;const e=t.data;if(this.bytesReceived+=e.length,this.stats_.incrementCounter("bytes_received",e.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(e);else{const t=this.extractFrameCount_(e);null!==t&&this.appendFrame_(t)}}send(t){this.resetKeepAlive();const e=C(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);const n=Xr(e,16384);n.length>1&&this.sendString_(String(n.length));for(let i=0;i<n.length;i++)this.sendString_(n[i])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(45e3))}sendString_(t){try{this.mySock.send(t)}catch(e){this.log_("Exception thrown from WebSocket.send():",e.message||e.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}};Co.responsesRequiredToBeHealthy=2,Co.healthyTimeout=3e4;var bo=class t{static get ALL_TRANSPORTS(){return[wo,Co]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}constructor(t){this.initTransports_(t)}initTransports_(e){const n=Co&&Co.isAvailable();let i=n&&!Co.previouslyFailed();if(e.webSocketOnly&&(n||Br("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),i=!0),i)this.transports_=[Co];else{const e=this.transports_=[];for(const n of t.ALL_TRANSPORTS)n&&n.isAvailable()&&e.push(n);t.globalTransportInitialized_=!0}}initialTransport(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return this.transports_.length>1?this.transports_[1]:null}};bo.globalTransportInitialized_=!1;var Io=class{constructor(t,e,n,i,s,r,o,a,h,l){this.id=t,this.repoInfo_=e,this.applicationId_=n,this.appCheckToken_=i,this.authToken_=s,this.onMessage_=r,this.onReady_=o,this.onDisconnect_=a,this.onKill_=h,this.lastSessionId=l,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=Vr("c:"+this.id+":"),this.transportManager_=new bo(e),this.log_("Connection created"),this.start_()}start_(){const t=this.transportManager_.initialTransport();this.conn_=new t(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=t.responsesRequiredToBeHealthy||0;const e=this.connReceiver_(this.conn_),n=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(e,n)},Math.floor(0));const i=t.healthyTimeout||0;i>0&&(this.healthyTimeout_=no(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>102400?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes.  Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>10240?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes.  Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(i)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(t){return e=>{t===this.conn_?this.onConnectionLost_(e):t===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(t){return e=>{2!==this.state_&&(t===this.rx_?this.onPrimaryMessageReceived_(e):t===this.secondaryConn_?this.onSecondaryMessageReceived_(e):this.log_("message on old connection"))}}sendRequest(t){const e={t:"d",d:t};this.sendData_(e)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(t){if("t"in t){const e=t.t;"a"===e?this.upgradeIfSecondaryHealthy_():"r"===e?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===e&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(t){const e=Kr("t",t),n=Kr("d",t);if("c"===e)this.onSecondaryControl_(n);else{if("d"!==e)throw new Error("Unknown protocol layer: "+e);this.pendingDataMessages.push(n)}}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t
vendor: 6,656 bytes, line 1
1:"c",d:{t:"p",d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(t){const e=Kr("t",t),n=Kr("d",t);"c"===e?this.onControl_(n):"d"===e&&this.onDataMessage_(n)}onDataMessage_(t){this.onPrimaryResponse_(),this.onMessage_(t)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(t){const e=Kr("t",t);if("d"in t){const n=t.d;if("h"===e){const t=Object.assign({},n);this.repoInfo_.isUsingEmulator&&(t.h=this.repoInfo_.host),this.onHandshake_(t)}else if("n"===e){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let t=0;t<this.pendingDataMessages.length;++t)this.onDataMessage_(this.pendingDataMessages[t]);this.pendingDataMessages=[],this.tryCleanupConnection()}else"s"===e?this.onConnectionShutdown_(n):"r"===e?this.onReset_(n):"e"===e?qr("Server Error: "+n):"o"===e?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):qr("Unknown control packet command: "+e)}}onHandshake_(t){const e=t.ts,n=t.v,i=t.h;this.sessionId=t.s,this.repoInfo_.host=i,0===this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,e),oo!==n&&Br("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){const t=this.transportManager_.upgradeTransport();t&&this.startUpgrade_(t)}startUpgrade_(t){this.secondaryConn_=new t(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=t.responsesRequiredToBeHealthy||0;const e=this.connReceiver_(this.secondaryConn_),n=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(e,n),no(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(6e4))}onReset_(t){this.log_("Reset packet received.  New host: "+t),this.repoInfo_.host=t,1===this.state_?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(t,e){this.log_("Realtime connection established."),this.conn_=t,this.state_=1,this.onReady_&&(this.onReady_(e,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):no(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))}sendPingOnPrimaryIfNecessary_(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))}onSecondaryConnectionLost_(){const t=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==t&&this.rx_!==t||this.close()}onConnectionLost_(t){this.conn_=null,t||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(Ar.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()}onConnectionShutdown_(t){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(t),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(t){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(t)}close(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}},So=class{put(t,e,n,i){}merge(t,e,n,i){}refreshAuthToken(t){}refreshAppCheckToken(t){}onDisconnectPut(t,e,n){}onDisconnectMerge(t,e,n){}onDisconnectCancel(t,e){}reportStats(t){}},ko=class{constructor(t){this.allowedEvents_=t,this.listeners_={},s(Array.isArray(t)&&t.length>0,"Requires a non-empty array")}trigger(t,...e){if(Array.isArray(this.listeners_[t])){const n=[...this.listeners_[t]];for(let t=0;t<n.length;t++)n[t].callback.apply(n[t].context,e)}}on(t,e,n){this.validateEventType_(t),this.listeners_[t]=this.listeners_[t]||[],this.listeners_[t].push({callback:e,context:n});const i=this.getInitialEvent(t);i&&e.apply(n,i)}off(t,e,n){this.validateEventType_(t);const i=this.listeners_[t]||[];for(let s=0;s<i.length;s++)if(i[s].callback===e&&(!n||n===i[s].context))return void i.splice(s,1)}validateEventType_(t){s(this.allowedEvents_.find(e=>e===t),"Unknown event: "+t)}},Ro=class t extends ko{static getInstance(){return new t}constructor(){super(["online"]),this.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||_()||(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}getInitialEvent(t){return s("online"===t,"Unknown event type: "+t),[this.online_]}currentlyOnline(){return this.online_}},No=class{constructor(t,e){if(void 0===e){this.pieces_=t.split("/");let e=0;for(let t=0;t<this.pieces_.length;t++)this.pieces_[t].length>0&&(this.pieces_[e]=this.pieces_[t],e++);this.pieces_.length=e,this.pieceNum_=0}else this.pieces_=t,this.pieceNum_=e}toString(){let t="";for(let e=this.pieceNum_;e<this.pieces_.length;e++)""!==this.pieces_[e]&&(t+="/"+this.pieces_[e]);return t||"/"}};function Ao(){return new No("")}function xo(t){return t.pieceNum_>=t.pieces_.length?null:t.pieces_[t.pieceNum_]}function Do(t){return t.pieces_.length-t.pieceNum_}function Oo(t){let e=t.pieceNum_;return e<t.pieces_.length&&e++,new No(t.pieces_,e)}function Po(t){return t.pieceNum_<t.pieces_.length?t.pieces_[t.pieces_.length-1]:null}function Lo(t,e=0){return t.pieces_.slice(t.pieceNum_+e)}function Mo(t){if(t.pieceNum_>=t.pieces_.length)return null;const e=[];for(let n=t.pieceNum_;n<t.pieces_.length-1;n++)e.push(t.pieces_[n]);return new No(e,0)}function Fo(t,e){const n=[];for(let i=t.pieceNum_;i<t.pieces_.length;i++)n.push(t.pieces_[i]);if(e instanceof No)for(let i=e.pieceNum_;i<e.pieces_.length;i++)n.push(e.pieces_[i]);else{const t=e.split("/");for(let e=0;e<t.length;e++)t[e].length>0&&n.push(t[e])}return new No(n,0)}function Uo(t){return t.pieceNum_>=t.pieces_.length}function Vo(t,e){const n=xo(t),i=xo(e);if(null===n)return e;if(n===i)return Vo(Oo(t),Oo(e));
1throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")}function qo(t,e){if(Do(t)!==Do(e))return!1;for(let n=t.pieceNum_,i=e.pieceNum_;n<=t.pieces_.length;n++,i++)if(t.pieces_[n]!==e.pieces_[i])return!1;return!0}function jo(t,e){let n=t.pieceNum_,i=e.pieceNum_;if(Do(t)>Do(e))return!1;for(;n<t.pieces_.length;){if(t.pieces_[n]!==e.pieces_[i])return!1;++n,++i}return!0}var Bo=class{constructor(t,e){this.errorPrefix_=e,this.parts_=Lo(t,0),this.byteLength_=Math.max(1,this.parts_.length);for(let n=0;n<this.parts_.length;n++)this.byteLength_+=c(this.parts_[n]);Ho(this)}};function Ho(t){if(t.byteLength_>768)throw new Error(t.errorPrefix_+"has a key path longer than 768 bytes ("+t.byteLength_+").");if(t.parts_.length>32)throw new Error(t.errorPrefix_+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+Wo(t))}function Wo(t){return 0===t.parts_.length?"":"in property '"+t.parts_.join(".")+"'"}var $o=class t extends ko{static getInstance(){return new t}constructor(){let t,e;super(["visible"]),"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(e="visibilitychange",t="hidden"):void 0!==document.mozHidden?(e="mozvisibilitychange",t="mozHidden"):void 0!==document.msHidden?(e="msvisibilitychange",t="msHidden"):void 0!==document.webkitHidden&&(e="webkitvisibilitychange",t="webkitHidden")),this.visible_=!0,e&&document.addEventListener(e,()=>{const e=!document[t];e!==this.visible_&&(this.visible_=e,this.trigger("visible",e))},!1)}getInitialEvent(t){return s("visible"===t,"Unknown event type: "+t),[this.visible_]}},zo=1e3,Go=class t extends So{constructor(e,n,i,s,r,o,a,h){if(super(),this.repoInfo_=e,this.applicationId_=n,this.onDataUpdate_=i,this.onConnectStatus_=s,this.onServerInfoUpdate_=r,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=h,this.id=t.nextPersistentConnectionId_++,this.log_=Vr("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=zo,this.maxReconnectDelay_=3e5,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,h&&!q())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");$o.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&Ro.getInstance().on("online",this.onOnline_,this)}sendRequest(t,e,n){const i=++this.requestNumber_,r={r:i,a:t,b:e};this.log_(C(r)),s(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(r),n&&(this.requestCBHash_[i]=n)}get(t){this.initConnection_();const e=new V,n={action:"g",request:{p:t._path.toString(),q:t._queryObject},onComplete:t=>{const n=t.d;"ok"===t.s?e.resolve(n):e.reject(n)}};this.outstandingGets_.push(n),this.outstandingGetCount_++;const i=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(i),e.promise}listen(t,e,n,i){this.initConnection_();const r=t._queryIdentifier,o=t._path.toString();this.log_("Listen called for "+o+" "+r),this.listens.has(o)||this.listens.set(o,new Map),s(t._queryParams.isDefault()||!t._queryParams.loadsAllData(),"listen() called for non-default but complete query"),s(!this.listens.get(o).has(r),"listen() called twice for same path/queryId.");const a={onComplete:i,hashFn:e,query:t,tag:n};this.listens.get(o).set(r,a),this.connected_&&this.sendListen_(a)}sendGet_(t){const e=this.outstandingGets_[t];this.sendRequest("g",e.request,n=>{delete this.outstandingGets_[t],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),e.onComplete&&e.onComplete(n)})}sendListen_(e){const n=e.query,i=n._path.toString(),s=n._queryIdentifier;this.log_("Listen on "+i+" for "+s);const r={p:i};e.tag&&(r.q=n._queryObject,r.t=e.tag),r.h=e.hashFn(),this.sendRequest("q",r,r=>{const o=r.d,a=r.s;t.warnOnListenWarnings_(o,n),(this.listens.get(i)&&this.listens.get(i).get(s))===e&&(this.log_("listen response",r),"ok"!==a&&this.removeListen_(i,s),e.onComplete&&e.onComplete(a,o))})}static warnOnListenWarnings_(t,e){if(t&&"object"==typeof t&&r(t,"w")){const n=L(t,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){const t='".indexOn": "'+e._queryParams.getIndex().toString()+'"',n=e._path.toString();Br(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${t} at ${n} to your security rules for better performance.`)}}}refreshAuthToken(t){this.authToken_=t,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(t)}reduceReconnectDelayIfAdminCredential_(t){(t&&40===t.length||m(t))&&(this.log_("Admin auth credential detected.  Reducing max reconnect time."),this.maxReconnectDelay_=3e4)}refreshAppCheckToken(t){this.appCheckToken_=t,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const t=this.authToken_,e=l(t)?"auth":"gauth",n={cred:t};null===this.authOverride_?n.noauth=!0:"object"==typeof this.authOverride_&&(n.authvar=this.authOverride_),this.sendRequest(e,n,e=>{const n=e.s,i=e.d||"error";this.authToken_===t&&("ok"===n?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(n,i))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},t=>{const e=t.s,n=t.d||"error";"ok"===e?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(e,n)})}unlisten(t,e){const n=t._path.toString(),i=t._queryIdentifier;this.log_("Unlisten called for "+n+" "+i),s(t._queryParams.isDefault()||!t._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(n,i)&&this.connected_&&this.sendUnlisten_(n,i,t._queryObject,e)}sendUnlisten_(t,e,n,i){this.log_("Unlisten on "+t+" for "+e);const s={p:t};i&&(s.q=n,s.t=i),this.sendRequest("n",s)}onDisconnectPut(t,e,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",t,e,n):this.onDisconnectRequestQueue_.push({pathString:t,action:"o",data:e,onComplete:n})}onDisconnectMerge(t,e,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",t,e,n):this.onDisconnectRequestQueue_.push({pathString:t,action:"om",data:e,onComplete:n})}onDisconnectCancel(t,e){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",t,null,e):this.onDisconnectRequestQueue_.push({pathString:t,action:"oc",data:null,onComplete:e})}sendOnDisconnect_(t,e,n,i){const s={p:e,d:n};this.log_("onDisconnect "+t,s),this.sendRequest(t,s,t=>{i&&setTimeout(()=>{i(t.s,t.d)},Math.floor(0))})}put(t,e,n,i){this.putInternal("p",t,e,n,i)}merge(t,e,n,i){this.putInternal("m",t,e,n,i)}putInternal(t,e,n,i,s){this.initConnection_();const r={p:e,d:n};void 0!==s&&(r.h=s),this.outstandingPuts_.push({action:t,request:r,onComplete:i}),this.outstandingPutCount_++;const o=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(o):this.log_("Buffering put: "+e)}sendPut_(t){const e=this.outstandingPuts_[t].action,n=this.outstandingPuts_[t].request,i=this.outstandingPuts_[t].onComplete;this.outstandingPuts_[t].queued=this.connected_,this.sendRequest(e,n,n=>{this.log_(e+" response",n),delete this.outstandingPuts_[t],this.outstandingPutCount_--,0===this.outstandingPutCount_&&(this.outstandingPuts_=[]),i&&i(n.s,n.d)})}reportStats(t){if(this.connected_){const e={c:t};this.log_("reportStats",e),this.sendRequest("s",e,t=>{if("ok"!==t.s){const e=t.d;this.log_("reportStats","Error sending stats: "+e)}})}}onDataMessage_(t){if("r"in t){this.log_("from server: "+C(t));const e=t.r,n=this.requestCBHash_[e];n&&(delete this.requestCBHash_[e],n(t.b))}else{if("error"in t)throw"A server-side error has occurred: "+t.error;"a"in t&&this.onDataPush_(t.a,t.b)}}onDataPush_(t,e){this.log_("handleServerMessage",t,e),"d"===t?this.onDataUpdate_(e.p,e.d,!1,e.t):"m"===t?this.onDataUpdate_(e.p,e.d,!0,e.t):"c"===t?this.onListenRevoked_(e.p,e.q):"ac"===t?this.onAuthRevoked_(e.s,e.d):"apc"===t?this.onAppCheckRevoked_(e.s,e.d):"sd"===t?this.onSecurityDebugPacket_(e):qr("Unrecognized action received from server: "+C(t)+"\nAre you using the latest client?")}onReady_(t,e){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(t),this.lastSessionId=e,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(t){s(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(t))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(t){t&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible.  Reducing delay."),this.reconnectDelay_=zo,this.realtime_||this.scheduleConnect_(0)),this.visible_=t}onOnline_(t){t?(this.log_("Browser went online."),this.reconnectDelay_=zo,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline.  Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&((new Date).getTime()-this.lastConnectionEstablishedTime_>3e4&&(this.reconnectDelay_=zo),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible.  Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime());const t=Math.max(0,(new Date).getTime()-this.lastConnectionAttemptTime_);let e=Math.max(0,this.reconnectDelay_-t);
1e=Math.random()*e,this.log_("Trying to reconnect in "+e+"ms"),this.scheduleConnect_(e),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),n=this.onReady_.bind(this),i=this.onRealtimeDisconnect_.bind(this),r=this.id+":"+t.nextConnectionId_++,o=this.lastSessionId;let a=!1,h=null;const l=function(){h?h.close():(a=!0,i())},u=function(t){s(h,"sendRequest call when we're not connected not allowed."),h.sendRequest(t)};this.realtime_={close:l,sendRequest:u};const c=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[t,s]=await Promise.all([this.authTokenProvider_.getToken(c),this.appCheckTokenProvider_.getToken(c)]);a?Ur("getToken() completed but was canceled"):(Ur("getToken() completed. Creating connection."),this.authToken_=t&&t.accessToken,this.appCheckToken_=s&&s.token,h=new Io(r,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,n,i,t=>{Br(t+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")},o))}catch(qr){this.log_("Failed to get token: "+qr),a||(this.repoInfo_.nodeAdmin&&Br(qr),l())}}}interrupt(t){Ur("Interrupting connection for reason: "+t),this.interruptReasons_[t]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(t){Ur("Resuming connection for reason: "+t),delete this.interruptReasons_[t],u(this.interruptReasons_)&&(this.reconnectDelay_=zo,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(t){const e=t-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:e})}cancelSentTransactions_(){for(let t=0;t<this.outstandingPuts_.length;t++){const e=this.outstandingPuts_[t];e&&"h"in e.request&&e.queued&&(e.onComplete&&e.onComplete("disconnect"),delete this.outstandingPuts_[t],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])}onListenRevoked_(t,e){let n;n=e?e.map(t=>Qr(t)).join("$"):"default";const i=this.removeListen_(t,n);i&&i.onComplete&&i.onComplete("permission_denied")}removeListen_(t,e){const n=new No(t).toString();let i;if(this.listens.has(n)){const t=this.listens.get(n);i=t.get(e),t.delete(e),0===t.size&&this.listens.delete(n)}else i=void 0;return i}onAuthRevoked_(t,e){Ur("Auth token revoked: "+t+"/"+e),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==t&&"permission_denied"!==t||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=3&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(t,e){Ur("App check token revoked: "+t+"/"+e),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==t&&"permission_denied"!==t||(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=3&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(t){this.securityDebugCallback_?this.securityDebugCallback_(t):"msg"in t&&console.log("FIREBASE: "+t.msg.replace("\n","\nFIREBASE: "))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const t of this.listens.values())for(const e of t.values())this.sendListen_(e);for(let t=0;t<this.outstandingPuts_.length;t++)this.outstandingPuts_[t]&&this.sendPut_(t);for(;this.onDisconnectRequestQueue_.length;){const t=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(t.action,t.pathString,t.data,t.onComplete)}for(let t=0;t<this.outstandingGets_.length;t++)this.outstandingGets_[t]&&this.sendGet_(t)}sendConnectStats_(){const t={};let e="js";q()&&(e=this.repoInfo_.nodeAdmin?"admin_node":"node"),t["sdk."+e+"."+Sr.replace(/\./g,"-")]=1,_()?t["framework.cordova"]=1:i()&&(t["framework.reactnative"]=1),this.reportStats(t)}shouldReconnect_(){const t=Ro.getInstance().currentlyOnline();return u(this.interruptReasons_)&&t}};Go.nextPersistentConnectionId_=0,Go.nextConnectionId_=0;var Ko,Qo=class t{constructor(t,e){this.name=t,this.node=e}static Wrap(e,n){return new t(e,n)}},Xo=class{getCompare(){return this.compare.bind(this)}indexedValueChanged(t,e){const n=new Qo(Wr,t),i=new Qo(Wr,e);return 0!==this.compare(n,i)}
vendor: 8,555 bytes, line 1
1minPost(){return Qo.MIN}},Yo=class extends Xo{static get __EMPTY_NODE(){return Ko}static set __EMPTY_NODE(t){Ko=t}compare(t,e){return zr(t.name,e.name)}isDefinedOn(t){throw F("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(t,e){return!1}minPost(){return Qo.MIN}maxPost(){return new Qo($r,Ko)}makePost(t,e){return s("string"==typeof t,"KeyIndex indexValue must always be a string."),new Qo(t,Ko)}toString(){return".key"}},Jo=new Yo,Zo=class{constructor(t,e,n,i,s=null){this.isReverse_=i,this.resultGenerator_=s,this.nodeStack_=[];let r=1;for(;!t.isEmpty();)if(r=e?n(t.key,e):1,i&&(r*=-1),r<0)t=this.isReverse_?t.left:t.right;else{if(0===r){this.nodeStack_.push(t);break}this.nodeStack_.push(t),t=this.isReverse_?t.right:t.left}}getNext(){if(0===this.nodeStack_.length)return null;let t,e=this.nodeStack_.pop();if(t=this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value},this.isReverse_)for(e=e.left;!e.isEmpty();)this.nodeStack_.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack_.push(e),e=e.left;return t}hasNext(){return this.nodeStack_.length>0}peek(){if(0===this.nodeStack_.length)return null;const t=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value}}},ta=class t{constructor(e,n,i,s,r){this.key=e,this.value=n,this.color=null!=i?i:t.RED,this.left=null!=s?s:na.EMPTY_NODE,this.right=null!=r?r:na.EMPTY_NODE}copy(e,n,i,s,r){return new t(null!=e?e:this.key,null!=n?n:this.value,null!=i?i:this.color,null!=s?s:this.left,null!=r?r:this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||!!t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,n){let i=this;const s=n(t,i.key);return i=s<0?i.copy(null,null,null,i.left.insert(t,e,n),null):0===s?i.copy(null,e,null,null,null):i.copy(null,null,null,null,i.right.insert(t,e,n)),i.fixUp_()}removeMin_(){if(this.left.isEmpty())return na.EMPTY_NODE;let t=this;return t.left.isRed_()||t.left.left.isRed_()||(t=t.moveRedLeft_()),t=t.copy(null,null,null,t.left.removeMin_(),null),t.fixUp_()}remove(t,e){let n,i;if(n=this,e(t,n.key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(t,e),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===e(t,n.key)){if(n.right.isEmpty())return na.EMPTY_NODE;i=n.right.min_(),n=n.copy(i.key,i.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(t,e))}return n.fixUp_()}isRed_(){return this.color}fixUp_(){let 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}moveRedLeft_(){let t=this.colorFlip_();return t.right.left.isRed_()&&(t=t.copy(null,null,null,null,t.right.rotateRight_()),t=t.rotateLeft_(),t=t.colorFlip_()),t}moveRedRight_(){let t=this.colorFlip_();return t.left.left.isRed_()&&(t=t.rotateRight_(),t=t.colorFlip_()),t}rotateLeft_(){const e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth_(){const t=this.check_();return Math.pow(2,t)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const t=this.left.check_();if(t!==this.right.check_())throw new Error("Black depths differ");return t+(this.isRed_()?0:1)}};ta.RED=!0,ta.BLACK=!1;var ea,na=class t{constructor(e,n=t.EMPTY_NODE){this.comparator_=e,this.root_=n}insert(e,n){return new t(this.comparator_,this.root_.insert(e,n,this.comparator_).copy(null,null,ta.BLACK,null,null))}remove(e){return new t(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,ta.BLACK,null,null))}get(t){let e,n=this.root_;for(;!n.isEmpty();){if(e=this.comparator_(t,n.key),0===e)return n.value;e<0?n=n.left:e>0&&(n=n.right)}return null}getPredecessorKey(t){let e,n=this.root_,i=null;for(;!n.isEmpty();){if(e=this.comparator_(t,n.key),0===e){if(n.left.isEmpty())return i?i.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}e<0?n=n.left:e>0&&(i=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key.  What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(t){return this.root_.inorderTraversal(t)}reverseTraversal(t){return this.root_.reverseTraversal(t)}getIterator(t){return new Zo(this.root_,null,this.comparator_,!1,t)}getIteratorFrom(t,e){return new Zo(this.root_,t,this.comparator_,!1,e)}getReverseIteratorFrom(t,e){return new Zo(this.root_,t,this.comparator_,!0,e)}getReverseIterator(t){return new Zo(this.root_,null,this.comparator_,!0,t)}};function ia(t,e){return zr(t.name,e.name)}function sa(t,e){return zr(t,e)}na.EMPTY_NODE=new class{copy(t,e,n,i,s){return this}insert(t,e,n){return new ta(t,e,null)}remove(t,e){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}};var ra,oa,aa,ha=function(t){return"number"==typeof t?"number:"+Jr(t):"string:"+t},la=function(t){if(t.isLeafNode()){const e=t.val();s("string"==typeof e||"number"==typeof e||"object"==typeof e&&r(e,".sv"),"Priority must be a string or number.")}else s(t===ea||t.isEmpty(),"priority of unexpected type.");s(t===ea||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")},ua=class t{static set __childrenNodeConstructor(t){ra=t}static get __childrenNodeConstructor(){return ra}constructor(e,n=t.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=n,this.lazyHash_=null,s(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),la(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new t(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:t.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return Uo(e)?this:".priority"===xo(e)?this.priorityNode_:t.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(t,e){return null}updateImmediateChild(e,n){return".priority"===e?this.updatePriority(n):n.isEmpty()&&".priority"!==e?this:t.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,n).updatePriority(this.priorityNode_)}updateChild(e,n){const i=xo(e);return null===i?n:n.isEmpty()&&".priority"!==i?this:(s(".priority"!==i||1===Do(e),".priority must be the last token in a path"),this.updateImmediateChild(i,t.__childrenNodeConstructor.EMPTY_NODE.updateChild(Oo(e),n)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(t,e){return!1}val(t){return t&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(null===this.lazyHash_){let t="";this.priorityNode_.isEmpty()||(t+="priority:"+ha(this.priorityNode_.val())+":");const e=typeof this.value_;t+=e+":",t+="number"===e?Jr(this.value_):this.value_,this.lazyHash_=Pr(t)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===t.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof t.__childrenNodeConstructor?-1:(s(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const n=typeof e.value_,i=typeof this.value_,r=t.VALUE_TYPE_ORDER.indexOf(n),o=t.VALUE_TYPE_ORDER.indexOf(i);return s(r>=0,"Unknown leaf type: "+n),s(o>=0,"Unknown leaf type: "+i),r===o?"object"===i?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:o-r}withIndex(){return this}isIndexed(){return!0}equals(t){if(t===this)return!0;
1if(t.isLeafNode()){const e=t;return this.value_===e.value_&&this.priorityNode_.equals(e.priorityNode_)}return!1}};ua.VALUE_TYPE_ORDER=["object","boolean","number","string"];var ca,da,fa=new class extends Xo{compare(t,e){const n=t.node.getPriority(),i=e.node.getPriority(),s=n.compareTo(i);return 0===s?zr(t.name,e.name):s}isDefinedOn(t){return!t.getPriority().isEmpty()}indexedValueChanged(t,e){return!t.getPriority().equals(e.getPriority())}minPost(){return Qo.MIN}maxPost(){return new Qo($r,new ua("[PRIORITY-POST]",aa))}makePost(t,e){const n=oa(t);return new Qo(e,new ua("[PRIORITY-POST]",n))}toString(){return".priority"}},pa=Math.log(2),ga=class{constructor(t){var e;this.count=(e=t+1,parseInt(Math.log(e)/pa,10)),this.current_=this.count-1;const n=(i=this.count,parseInt(Array(i+1).join("1"),2));var i;this.bits_=t+1&n}nextBitIsOne(){const t=!(this.bits_&1<<this.current_);return this.current_--,t}},ma=function(t,e,n,i){t.sort(e);const s=function(e,i){const r=i-e;let o,a;if(0===r)return null;if(1===r)return o=t[e],a=n?n(o):o,new ta(a,o.node,ta.BLACK,null,null);{const h=parseInt(r/2,10)+e,l=s(e,h),u=s(h+1,i);return o=t[h],a=n?n(o):o,new ta(a,o.node,ta.BLACK,l,u)}},r=function(e){let i=null,r=null,o=t.length;const a=function(e,i){const r=o-e,a=o;o-=e;const l=s(r+1,a),u=t[r],c=n?n(u):u;h(new ta(c,u.node,i,null,l))},h=function(t){i?(i.left=t,i=t):(r=t,i=t)};for(let t=0;t<e.count;++t){const n=e.nextBitIsOne(),i=Math.pow(2,e.count-(t+1));n?a(i,ta.BLACK):(a(i,ta.BLACK),a(i,ta.RED))}return r}(new ga(t.length));return new na(i||e,r)},_a={},ya=class t{static get Default(){return s(_a&&fa,"ChildrenNode.ts has not been loaded"),ca=ca||new t({".priority":_a},{".priority":fa})}constructor(t,e){this.indexes_=t,this.indexSet_=e}get(t){const e=L(this.indexes_,t);if(!e)throw new Error("No index defined for "+t);return e instanceof na?e:null}hasIndex(t){return r(this.indexSet_,t.toString())}addIndex(e,n){s(e!==Jo,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const i=[];let r=!1;const o=n.getIterator(Qo.Wrap);let a,h=o.getNext();for(;h;)r=r||e.isDefinedOn(h.node),i.push(h),h=o.getNext();a=r?ma(i,e.getCompare()):_a;const l=e.toString(),u=Object.assign({},this.indexSet_);u[l]=e;const c=Object.assign({},this.indexes_);return c[l]=a,new t(c,u)}addToIndexes(e,n){const i=E(this.indexes_,(t,i)=>{const r=L(this.indexSet_,i);if(s(r,"Missing index implementation for "+i),t===_a){if(r.isDefinedOn(e.node)){const t=[],i=n.getIterator(Qo.Wrap);let s=i.getNext();for(;s;)s.name!==e.name&&t.push(s),s=i.getNext();return t.push(e),ma(t,r.getCompare())}return _a}{const i=n.get(e.name);let s=t;return i&&(s=s.remove(new Qo(e.name,i))),s.insert(e,e.node)}});return new t(i,this.indexSet_)}removeFromIndexes(e,n){const i=E(this.indexes_,t=>{if(t===_a)return t;{const i=n.get(e.name);return i?t.remove(new Qo(e.name,i)):t}});return new t(i,this.indexSet_)}},va=class t{static get EMPTY_NODE(){return da||(da=new t(new na(sa),null,ya.Default))}constructor(t,e,n){this.children_=t,this.priorityNode_=e,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&la(this.priorityNode_),this.children_.isEmpty()&&s(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||da}updatePriority(e){return this.children_.isEmpty()?this:new t(this.children_,e,this.indexMap_)}getImmediateChild(t){if(".priority"===t)return this.getPriority();{const e=this.children_.get(t);return null===e?da:e}}getChild(t){const e=xo(t);return null===e?this:this.getImmediateChild(e).getChild(Oo(t))}hasChild(t){return null!==this.children_.get(t)}updateImmediateChild(e,n){if(s(n,"We should always be passing snapshot nodes"),".priority"===e)return this.updatePriority(n);{const i=new Qo(e,n);let s,r;n.isEmpty()?(s=this.children_.remove(e),r=this.indexMap_.removeFromIndexes(i,this.children_)):(s=this.children_.insert(e,n),r=this.indexMap_.addToIndexes(i,this.children_));const o=s.isEmpty()?da:this.priorityNode_;return new t(s,o,r)}}updateChild(t,e){const n=xo(t);if(null===n)return e;{s(".priority"!==xo(t)||1===Do(t),".priority must be the last token in a path");const i=this.getImmediateChild(n).updateChild(Oo(t),e);return this.updateImmediateChild(n,i)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const n={};let i=0,s=0,r=!0;if(this.forEachChild(fa,(o,a)=>{n[o]=a.val(e),i++,r&&t.INTEGER_REGEXP_.test(o)?s=Math.max(s,Number(o)):r=!1}),!e&&r&&s<2*i){const t=[];for(const e in n)t[e]=n[e];return t}
1return e&&!this.getPriority().isEmpty()&&(n[".priority"]=this.getPriority().val()),n}hash(){if(null===this.lazyHash_){let t="";this.getPriority().isEmpty()||(t+="priority:"+ha(this.getPriority().val())+":"),this.forEachChild(fa,(e,n)=>{const i=n.hash();""!==i&&(t+=":"+e+":"+i)}),this.lazyHash_=""===t?"":Pr(t)}return this.lazyHash_}getPredecessorChildName(t,e,n){const i=this.resolveIndex_(n);if(i){const n=i.getPredecessorKey(new Qo(t,e));return n?n.name:null}return this.children_.getPredecessorKey(t)}getFirstChildName(t){const e=this.resolveIndex_(t);if(e){const t=e.minKey();return t&&t.name}return this.children_.minKey()}getFirstChild(t){const e=this.getFirstChildName(t);return e?new Qo(e,this.children_.get(e)):null}getLastChildName(t){const e=this.resolveIndex_(t);if(e){const t=e.maxKey();return t&&t.name}return this.children_.maxKey()}getLastChild(t){const e=this.getLastChildName(t);return e?new Qo(e,this.children_.get(e)):null}forEachChild(t,e){const n=this.resolveIndex_(t);return n?n.inorderTraversal(t=>e(t.name,t.node)):this.children_.inorderTraversal(e)}getIterator(t){return this.getIteratorFrom(t.minPost(),t)}getIteratorFrom(t,e){const n=this.resolveIndex_(e);if(n)return n.getIteratorFrom(t,t=>t);{const n=this.children_.getIteratorFrom(t.name,Qo.Wrap);let i=n.peek();for(;null!=i&&e.compare(i,t)<0;)n.getNext(),i=n.peek();return n}}getReverseIterator(t){return this.getReverseIteratorFrom(t.maxPost(),t)}getReverseIteratorFrom(t,e){const n=this.resolveIndex_(e);if(n)return n.getReverseIteratorFrom(t,t=>t);{const n=this.children_.getReverseIteratorFrom(t.name,Qo.Wrap);let i=n.peek();for(;null!=i&&e.compare(i,t)>0;)n.getNext(),i=n.peek();return n}}compareTo(t){return this.isEmpty()?t.isEmpty()?0:-1:t.isLeafNode()||t.isEmpty()?1:t===wa?-1:0}withIndex(e){if(e===Jo||this.indexMap_.hasIndex(e))return this;{const n=this.indexMap_.addIndex(e,this.children_);return new t(this.children_,this.priorityNode_,n)}}isIndexed(t){return t===Jo||this.indexMap_.hasIndex(t)}equals(t){if(t===this)return!0;if(t.isLeafNode())return!1;{const e=t;if(this.getPriority().equals(e.getPriority())){if(this.children_.count()===e.children_.count()){const t=this.getIterator(fa),n=e.getIterator(fa);let i=t.getNext(),s=n.getNext();for(;i&&s;){if(i.name!==s.name||!i.node.equals(s.node))return!1;i=t.getNext(),s=n.getNext()}return null===i&&null===s}return!1}return!1}}resolveIndex_(t){return t===Jo?null:this.indexMap_.get(t.toString())}};va.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;var wa=new class extends va{constructor(){super(new na(sa),va.EMPTY_NODE,ya.Default)}compareTo(t){return t===this?0:1}equals(t){return t===this}getPriority(){return this}getImmediateChild(t){return va.EMPTY_NODE}isEmpty(){return!1}};Object.defineProperties(Qo,{MIN:{value:new Qo(Wr,va.EMPTY_NODE)},MAX:{value:new Qo($r,wa)}}),Yo.__EMPTY_NODE=va.EMPTY_NODE,ua.__childrenNodeConstructor=va,ea=wa,function(t){aa=t}(wa);function Ta(t,e=null){if(null===t)return va.EMPTY_NODE;if("object"==typeof t&&".priority"in t&&(e=t[".priority"]),s(null===e||"string"==typeof e||"number"==typeof e||"object"==typeof e&&".sv"in e,"Invalid priority type found: "+typeof e),"object"==typeof t&&".value"in t&&null!==t[".value"]&&(t=t[".value"]),"object"!=typeof t||".sv"in t)return new ua(t,Ta(e));if(t instanceof Array){let n=va.EMPTY_NODE;return Yr(t,(e,i)=>{if(r(t,e)&&"."!==e.substring(0,1)){const t=Ta(i);!t.isLeafNode()&&t.isEmpty()||(n=n.updateImmediateChild(e,t))}}),n.updatePriority(Ta(e))}{const n=[];let i=!1;if(Yr(t,(t,e)=>{if("."!==t.substring(0,1)){const s=Ta(e);s.isEmpty()||(i=i||!s.getPriority().isEmpty(),n.push(new Qo(t,s)))}}),0===n.length)return va.EMPTY_NODE;const s=ma(n,ia,t=>t.name,sa);if(i){const t=ma(n,fa.getCompare());return new va(s,Ta(e),new ya({".priority":t},{".priority":fa}))}return new va(s,Ta(e),ya.Default)}}!function(t){oa=t}(Ta);var Ea=class extends Xo{constructor(t){super(),this.indexPath_=t,s(!Uo(t)&&".priority"!==xo(t),"Can't create PathIndex with empty path or .priority key")}extractChild(t){return t.getChild(this.indexPath_)}isDefinedOn(t){return!t.getChild(this.indexPath_).isEmpty()}compare(t,e){const n=this.extractChild(t.node),i=this.extractChild(e.node),s=n.compareTo(i);return 0===s?zr(t.name,e.name):s}makePost(t,e){const n=Ta(t),i=va.EMPTY_NODE.updateChild(this.indexPath_,n);return new Qo(e,i)}maxPost(){const t=va.EMPTY_NODE.updateChild(this.indexPath_,wa);return new Qo($r,t)}toString(){return Lo(this.indexPath_,0).join("/")}},Ca=new class extends Xo{compare(t,e){const n=t.node.compareTo(e.node);return 0===n?zr(t.name,e.name):n}isDefinedOn(t){return!0}indexedValueChanged(t,e){return!t.equals(e)}
1minPost(){return Qo.MIN}maxPost(){return Qo.MAX}makePost(t,e){const n=Ta(t);return new Qo(e,n)}toString(){return".value"}};function ba(t,e,n){return{type:"child_changed",snapshotNode:e,childName:t,oldSnap:n}}var Ia=class t{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=fa}hasStart(){return this.startSet_}isViewFromLeft(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_}getIndexStartValue(){return s(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return s(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:Wr}hasEnd(){return this.endSet_}getIndexEndValue(){return s(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return s(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:$r}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&""!==this.viewFrom_}getLimit(){return s(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===fa}copy(){const e=new t;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.startAfterSet_=this.startAfterSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.endBeforeSet_=this.endBeforeSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}};function Sa(t){const e={};if(t.isDefault())return e;let n;if(t.index_===fa?n="$priority":t.index_===Ca?n="$value":t.index_===Jo?n="$key":(s(t.index_ instanceof Ea,"Unrecognized index type!"),n=t.index_.toString()),e.orderBy=C(n),t.startSet_){const n=t.startAfterSet_?"startAfter":"startAt";e[n]=C(t.indexStartValue_),t.startNameSet_&&(e[n]+=","+C(t.indexStartName_))}if(t.endSet_){const n=t.endBeforeSet_?"endBefore":"endAt";e[n]=C(t.indexEndValue_),t.endNameSet_&&(e[n]+=","+C(t.indexEndName_))}return t.limitSet_&&(t.isViewFromLeft()?e.limitToFirst=t.limit_:e.limitToLast=t.limit_),e}function ka(t){const e={};if(t.startSet_&&(e.sp=t.indexStartValue_,t.startNameSet_&&(e.sn=t.indexStartName_),e.sin=!t.startAfterSet_),t.endSet_&&(e.ep=t.indexEndValue_,t.endNameSet_&&(e.en=t.indexEndName_),e.ein=!t.endBeforeSet_),t.limitSet_){e.l=t.limit_;let n=t.viewFrom_;""===n&&(n=t.isViewFromLeft()?"l":"r"),e.vf=n}return t.index_!==fa&&(e.i=t.index_.toString()),e}var Ra=class t extends So{reportStats(t){throw new Error("Method not implemented.")}static getListenId_(t,e){return void 0!==e?"tag$"+e:(s(t._queryParams.isDefault(),"should have a tag if it's not a default query."),t._path.toString())}constructor(t,e,n,i){super(),this.repoInfo_=t,this.onDataUpdate_=e,this.authTokenProvider_=n,this.appCheckTokenProvider_=i,this.log_=Vr("p:rest:"),this.listens_={}}listen(e,n,i,s){const r=e._path.toString();this.log_("Listen called for "+r+" "+e._queryIdentifier);const o=t.getListenId_(e,i),a={};this.listens_[o]=a;const h=Sa(e._queryParams);this.restRequest_(r+".json",h,(t,e)=>{let n=e;if(404===t&&(n=null,t=null),null===t&&this.onDataUpdate_(r,n,!1,i),L(this.listens_,o)===a){let e;e=t?401===t?"permission_denied":"rest_error:"+t:"ok",s(e,null)}})}unlisten(e,n){const i=t.getListenId_(e,n);delete this.listens_[i]}get(t){const e=Sa(t._queryParams),n=t._path.toString(),i=new V;return this.restRequest_(n+".json",e,(t,e)=>{let s=e;404===t&&(s=null,t=null),null===t?(this.onDataUpdate_(n,s,!1,null),i.resolve(s)):i.reject(new Error(s))}),i.promise}refreshAuthToken(t){}restRequest_(t,e={},n){return e.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([i,s])=>{i&&i.accessToken&&(e.auth=i.accessToken),s&&s.token&&(e.ac=s.token);const r=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+t+"?ns="+this.repoInfo_.namespace+d(e);this.log_("Sending REST request for "+r);const o=new XMLHttpRequest;o.onreadystatechange=()=>{if(n&&4===o.readyState){this.log_("REST Response for "+r+" received. status:",o.status,"response:",o.responseText);let e=null;if(o.status>=200&&o.status<300){try{e=w(o.responseText)}catch(t){Br("Failed to parse JSON response for "+r+": "+o.responseText)}n(null,e)}else 401!==o.status&&404!==o.status&&Br("Got unsuccessful REST response for "+r+" Status: "+o.status),n(o.status);n=null}},o.open("GET",r,!0),o.send()})}},Na=class{constructor(){this.rootNode_=va.EMPTY_NODE}getNode(t){return this.rootNode_.getChild(t)}updateSnapshot(t,e){this.rootNode_=this.rootNode_.updateChild(t,e)}};function Aa(){return{value:null,children:new Map}}function xa(t,e,n){if(Uo(e))t.value=n,t.children.clear();else if(null!==t.value)t.value=t.value.updateChild(e,n);else{const i=xo(e);t.children.has(i)||t.children.set(i,Aa());xa(t.children.get(i),e=Oo(e),n)}}function Da(t,e,n){null!==t.value?n(e,t.value):function(t,e){t.children.forEac
1h((t,n)=>{e(n,t)})}(t,(t,i)=>{Da(i,new No(e.toString()+"/"+t),n)})}var Oa,Pa=class{constructor(t){this.collection_=t,this.last_=null}get(){const t=this.collection_.get(),e=Object.assign({},t);return this.last_&&Yr(this.last_,(t,n)=>{e[t]=e[t]-n}),this.last_=t,e}},La=class{constructor(t,e){this.server_=e,this.statsToReport_={},this.statsListener_=new Pa(t);const n=1e4+2e4*Math.random();no(this.reportStats_.bind(this),Math.floor(n))}reportStats_(){const t=this.statsListener_.get(),e={};let n=!1;Yr(t,(t,i)=>{i>0&&r(this.statsToReport_,t)&&(e[t]=i,n=!0)}),n&&this.server_.reportStats(e),no(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}};function Ma(t){return{fromUser:!1,fromServer:!0,queryId:t,tagged:!0}}!function(t){t[t.OVERWRITE=0]="OVERWRITE",t[t.MERGE=1]="MERGE",t[t.ACK_USER_WRITE=2]="ACK_USER_WRITE",t[t.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(Oa||(Oa={}));var Fa,Ua=class t{constructor(t,e,n){this.path=t,this.affectedTree=e,this.revert=n,this.type=Oa.ACK_USER_WRITE,this.source={fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}operationForChild(e){if(Uo(this.path)){if(null!=this.affectedTree.value)return s(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const n=this.affectedTree.subtree(new No(e));return new t(Ao(),n,this.revert)}}return s(xo(this.path)===e,"operationForChild called for unrelated child."),new t(Oo(this.path),this.affectedTree,this.revert)}},Va=class t{constructor(t,e,n){this.source=t,this.path=e,this.snap=n,this.type=Oa.OVERWRITE}operationForChild(e){return Uo(this.path)?new t(this.source,Ao(),this.snap.getImmediateChild(e)):new t(this.source,Oo(this.path),this.snap)}},qa=class t{constructor(t,e,n){this.source=t,this.path=e,this.children=n,this.type=Oa.MERGE}operationForChild(e){if(Uo(this.path)){const n=this.children.subtree(new No(e));return n.isEmpty()?null:n.value?new Va(this.source,Ao(),n.value):new t(this.source,Ao(),n)}return s(xo(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new t(this.source,Oo(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}},ja=class{constructor(t,e,n){this.node_=t,this.fullyInitialized_=e,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(t){if(Uo(t))return this.isFullyInitialized()&&!this.filtered_;const e=xo(t);return this.isCompleteForChild(e)}isCompleteForChild(t){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(t)}getNode(){return this.node_}};function Ba(t,e,n,i,s,r){const o=i.filter(t=>t.type===n);o.sort((e,n)=>function(t,e,n){if(null==e.childName||null==n.childName)throw F("Should only compare child_ events.");const i=new Qo(e.childName,e.snapshotNode),s=new Qo(n.childName,n.snapshotNode);return t.index_.compare(i,s)}(t,e,n)),o.forEach(n=>{const i=function(t,e,n){return"value"===e.type||"child_removed"===e.type||(e.prevName=n.getPredecessorChildName(e.childName,e.snapshotNode,t.index_)),e}(t,n,r);s.forEach(s=>{s.respondsTo(n.type)&&e.push(s.createEvent(i,t.query_))})})}function Ha(t,e){return{eventCache:t,serverCache:e}}function Wa(t,e,n,i){return Ha(new ja(e,n,i),t.serverCache)}function $a(t,e,n,i){return Ha(t.eventCache,new ja(e,n,i))}function za(t){return t.eventCache.isFullyInitialized()?t.eventCache.getNode():null}function Ga(t){return t.serverCache.isFullyInitialized()?t.serverCache.getNode():null}var Ka=class t{static fromObject(e){let n=new t(null);return Yr(e,(t,e)=>{n=n.set(new No(t),e)}),n}constructor(t,e=(()=>(Fa||(Fa=new na(Gr)),Fa))()){this.value=t,this.children=e}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(t,e){if(null!=this.value&&e(this.value))return{path:Ao(),value:this.value};if(Uo(t))return null;{const n=xo(t),i=this.children.get(n);if(null!==i){const s=i.findRootMostMatchingPathAndValue(Oo(t),e);return null!=s?{path:Fo(new No(n),s.path),value:s.value}:null}return null}}findRootMostValueAndPath(t){return this.findRootMostMatchingPathAndValue(t,()=>!0)}subtree(e){if(Uo(e))return this;{const n=xo(e),i=this.children.get(n);return null!==i?i.subtree(Oo(e)):new t(null)}}set(e,n){if(Uo(e))return new t(n,this.children);{const i=xo(e),s=(this.children.get(i)||new t(null)).set(Oo(e),n),r=this.children.insert(i,s);return new t(this.value,r)}}remove(e){if(Uo(e))return this.children.isEmpty()?new t(null):new t(null,this.children);{const n=xo(e),i=this.children.get(n);if(i){const s=i.remove(Oo(e));let r;return r=s.isEmpty()?this.children.remove(n):this.children.insert(n,s),null===this.value&&r.isEmpty()?new t(null):new t(this.value,r)}return this}}get(t){if(Uo(t))return this.value;{const e=xo(t),n=this.children.get(e);return n?n.get(Oo(t)):null}}setTree(e,n){if(Uo(e))return n;{const i=xo(e),s=(this.children.get(i)||new t(null)).setTree(Oo(e),n);let r;return r=s.isEmpty()?this.children.remove(i):this.children.insert(i,s),new t(this.value,r)}}fold(t){return this.fold_(Ao(),t)}fold_(t,e){const n={};return this.children.inorderTraversal((i,s)=>{n[i]=s.fold_(Fo(t,i),e)}
1),e(t,this.value,n)}findOnPath(t,e){return this.findOnPath_(t,Ao(),e)}findOnPath_(t,e,n){const i=!!this.value&&n(e,this.value);if(i)return i;if(Uo(t))return null;{const i=xo(t),s=this.children.get(i);return s?s.findOnPath_(Oo(t),Fo(e,i),n):null}}foreachOnPath(t,e){return this.foreachOnPath_(t,Ao(),e)}foreachOnPath_(e,n,i){if(Uo(e))return this;{this.value&&i(n,this.value);const s=xo(e),r=this.children.get(s);return r?r.foreachOnPath_(Oo(e),Fo(n,s),i):new t(null)}}foreach(t){this.foreach_(Ao(),t)}foreach_(t,e){this.children.inorderTraversal((n,i)=>{i.foreach_(Fo(t,n),e)}),this.value&&e(t,this.value)}foreachChild(t){this.children.inorderTraversal((e,n)=>{n.value&&t(e,n.value)})}},Qa=class t{constructor(t){this.writeTree_=t}static empty(){return new t(new Ka(null))}};function Xa(t,e,n){if(Uo(e))return new Qa(new Ka(n));{const i=t.writeTree_.findRootMostValueAndPath(e);if(null!=i){const s=i.path;let r=i.value;const o=Vo(s,e);return r=r.updateChild(o,n),new Qa(t.writeTree_.set(s,r))}{const i=new Ka(n),s=t.writeTree_.setTree(e,i);return new Qa(s)}}}function Ya(t,e,n){let i=t;return Yr(n,(t,n)=>{i=Xa(i,Fo(e,t),n)}),i}function Ja(t,e){if(Uo(e))return Qa.empty();{const n=t.writeTree_.setTree(e,new Ka(null));return new Qa(n)}}function Za(t,e){return null!=th(t,e)}function th(t,e){const n=t.writeTree_.findRootMostValueAndPath(e);return null!=n?t.writeTree_.get(n.path).getChild(Vo(n.path,e)):null}function eh(t){const e=[],n=t.writeTree_.value;return null!=n?n.isLeafNode()||n.forEachChild(fa,(t,n)=>{e.push(new Qo(t,n))}):t.writeTree_.children.inorderTraversal((t,n)=>{null!=n.value&&e.push(new Qo(t,n.value))}),e}function nh(t,e){if(Uo(e))return t;{const n=th(t,e);return new Qa(null!=n?new Ka(n):t.writeTree_.subtree(e))}}function ih(t){return t.writeTree_.isEmpty()}function sh(t,e){return rh(Ao(),t.writeTree_,e)}function rh(t,e,n){if(null!=e.value)return n.updateChild(t,e.value);{let i=null;return e.children.inorderTraversal((e,r)=>{".priority"===e?(s(null!==r.value,"Priority writes must always be leaf nodes"),i=r.value):n=rh(Fo(t,e),r,n)}),n.getChild(t).isEmpty()||null===i||(n=n.updateChild(Fo(t,".priority"),i)),n}}function oh(t,e){return vh(e,t)}function ah(t,e){const n=t.allWrites.findIndex(t=>t.writeId===e);s(n>=0,"removeWrite called with nonexistent writeId.");const i=t.allWrites[n];t.allWrites.splice(n,1);let r=i.visible,o=!1,a=t.allWrites.length-1;for(;r&&a>=0;){const e=t.allWrites[a];e.visible&&(a>=n&&hh(e,i.path)?r=!1:jo(i.path,e.path)&&(o=!0)),a--}if(r){if(o)return function(t){t.visibleWrites=uh(t.allWrites,lh,Ao()),t.allWrites.length>0?t.lastWriteId=t.allWrites[t.allWrites.length-1].writeId:t.lastWriteId=-1}(t),!0;if(i.snap)t.visibleWrites=Ja(t.visibleWrites,i.path);else{Yr(i.children,e=>{t.visibleWrites=Ja(t.visibleWrites,Fo(i.path,e))})}return!0}return!1}function hh(t,e){if(t.snap)return jo(t.path,e);for(const n in t.children)if(t.children.hasOwnProperty(n)&&jo(Fo(t.path,n),e))return!0;return!1}function lh(t){return t.visible}function uh(t,e,n){let i=Qa.empty();for(let s=0;s<t.length;++s){const r=t[s];if(e(r)){const t=r.path;let e;if(r.snap)jo(n,t)?(e=Vo(n,t),i=Xa(i,e,r.snap)):jo(t,n)&&(e=Vo(t,n),i=Xa(i,Ao(),r.snap.getChild(e)));else{if(!r.children)throw F("WriteRecord should have .snap or .children");if(jo(n,t))e=Vo(n,t),i=Ya(i,e,r.children);else if(jo(t,n))if(e=Vo(t,n),Uo(e))i=Ya(i,Ao(),r.children);else{const t=L(r.children,xo(e));if(t){const n=t.getChild(Oo(e));i=Xa(i,Ao(),n)}}}}}return i}function ch(t,e,n,i,s){if(i||s){const r=nh(t.visibleWrites,e);if(!s&&ih(r))return n;if(s||null!=n||Za(r,Ao())){const r=function(t){return(t.visible||s)&&(!i||!~i.indexOf(t.writeId))&&(jo(t.path,e)||jo(e,t.path))};return sh(uh(t.allWrites,r,e),n||va.EMPTY_NODE)}return null}{const i=th(t.visibleWrites,e);if(null!=i)return i;{const i=nh(t.visibleWrites,e);return ih(i)?n:null!=n||Za(i,Ao())?sh(i,n||va.EMPTY_NODE):null}}}function dh(t,e,n,i){return ch(t.writeTree,t.treePath,e,n,i)}function fh(t,e){return function(t,e,n){let i=va.EMPTY_NODE;const s=th(t.visibleWrites,e);if(s)return s.isLeafNode()||s.forEachChild(fa,(t,e)=>{i=i.updateImmediateChild(t,e)}),i;if(n){const s=nh(t.visibleWrites,e);
1return n.forEachChild(fa,(t,e)=>{const n=sh(nh(s,new No(t)),e);i=i.updateImmediateChild(t,n)}),eh(s).forEach(t=>{i=i.updateImmediateChild(t.name,t.node)}),i}return eh(nh(t.visibleWrites,e)).forEach(t=>{i=i.updateImmediateChild(t.name,t.node)}),i}(t.writeTree,t.treePath,e)}function ph(t,e,n,i){return function(t,e,n,i,r){s(i||r,"Either existingEventSnap or existingServerSnap must exist");const o=Fo(e,n);if(Za(t.visibleWrites,o))return null;{const e=nh(t.visibleWrites,o);return ih(e)?r.getChild(n):sh(e,r.getChild(n))}}(t.writeTree,t.treePath,e,n,i)}function gh(t,e){return function(t,e){return th(t.visibleWrites,e)}(t.writeTree,Fo(t.treePath,e))}function mh(t,e,n,i,s,r){return function(t,e,n,i,s,r,o){let a;const h=nh(t.visibleWrites,e),l=th(h,Ao());if(null!=l)a=l;else{if(null==n)return[];a=sh(h,n)}if(a=a.withIndex(o),a.isEmpty()||a.isLeafNode())return[];{const t=[],e=o.getCompare(),n=r?a.getReverseIteratorFrom(i,o):a.getIteratorFrom(i,o);let h=n.getNext();for(;h&&t.length<s;)0!==e(h,i)&&t.push(h),h=n.getNext();return t}}(t.writeTree,t.treePath,e,n,i,s,r)}function _h(t,e,n){return function(t,e,n,i){const s=Fo(e,n),r=th(t.visibleWrites,s);return null!=r?r:i.isCompleteForChild(n)?sh(nh(t.visibleWrites,s),i.getNode().getImmediateChild(n)):null}(t.writeTree,t.treePath,e,n)}function yh(t,e){return vh(Fo(t.treePath,e),t.writeTree)}function vh(t,e){return{treePath:t,writeTree:e}}var wh,Th,Eh=class{constructor(){this.changeMap=new Map}trackChildChange(t){const e=t.type,n=t.childName;s("child_added"===e||"child_changed"===e||"child_removed"===e,"Only child changes supported for tracking"),s(".priority"!==n,"Only non-priority child changes can be tracked.");const i=this.changeMap.get(n);if(i){const s=i.type;if("child_added"===e&&"child_removed"===s)this.changeMap.set(n,ba(n,t.snapshotNode,i.snapshotNode));else if("child_removed"===e&&"child_added"===s)this.changeMap.delete(n);else if("child_removed"===e&&"child_changed"===s)this.changeMap.set(n,(r=n,{type:"child_removed",snapshotNode:i.oldSnap,childName:r}));else if("child_changed"===e&&"child_added"===s)this.changeMap.set(n,function(t,e){return{type:"child_added",snapshotNode:e,childName:t}}(n,t.snapshotNode));else{if("child_changed"!==e||"child_changed"!==s)throw F("Illegal combination of changes: "+t+" occurred after "+i);this.changeMap.set(n,ba(n,t.snapshotNode,i.oldSnap))}}else this.changeMap.set(n,t);var r}getChanges(){return Array.from(this.changeMap.values())}},Ch=new class{getCompleteChild(t){return null}getChildAfterChild(t,e,n){return null}},bh=class{constructor(t,e,n=null){this.writes_=t,this.viewCache_=e,this.optCompleteServerCache_=n}getCompleteChild(t){const e=this.viewCache_.eventCache;if(e.isCompleteForChild(t))return e.getNode().getImmediateChild(t);{const e=null!=this.optCompleteServerCache_?new ja(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return _h(this.writes_,t,e)}}getChildAfterChild(t,e,n){const i=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:Ga(this.viewCache_),s=mh(this.writes_,i,e,1,n,t);return 0===s.length?null:s[0]}};function Ih(t,e,n,i,r){const o=new Eh;let a,h;if(n.type===Oa.OVERWRITE){const l=n;l.source.fromUser?a=Rh(t,e,l.path,l.snap,i,r,o):(s(l.source.fromServer,"Unknown source."),h=l.source.tagged||e.serverCache.isFiltered()&&!Uo(l.path),a=kh(t,e,l.path,l.snap,i,r,h,o))}else if(n.type===Oa.MERGE){const l=n;l.source.fromUser?a=function(t,e,n,i,s,r,o){let a=e;return i.foreach((i,h)=>{const l=Fo(n,i);Nh(e,xo(l))&&(a=Rh(t,a,l,h,s,r,o))}),i.foreach((i,h)=>{const l=Fo(n,i);Nh(e,xo(l))||(a=Rh(t,a,l,h,s,r,o))}),a}(t,e,l.path,l.children,i,r,o):(s(l.source.fromServer,"Unknown source."),h=l.source.tagged||e.serverCache.isFiltered(),a=xh(t,e,l.path,l.children,i,r,h,o))}else if(n.type===Oa.ACK_USER_WRITE){const h=n;a=h.revert?function(t,e,n,i,r,o){let a;if(null!=gh(i,n))return e;{const h=new bh(i,e,r),l=e.eventCache.getNode();let u;if(Uo(n)||".priority"===xo(n)){let n;if(e.serverCache.isFullyInitialized())n=dh(i,Ga(e));else{const t=e.serverCache.getNode();s(t instanceof va,"serverChildren would be complete if leaf node"),n=fh(i,t)}u=t.filter.updateFullNode(l,n,o)}else{const s=xo(n);let r=_h(i,s,e.serverCache);null==r&&e.serverCache.isCompleteForChild(s)&&(r=l.getImmediateChild(s)),u=null!=r?t.filter.updateChild(l,s,r,Oo(n),h,o):e.eventCache.getNode().hasChild(s)?t.filter.updateChild(l,s,va.EMPTY_NODE,Oo(n),h,o):l,u.isEmpty()&&e.serverCache.isFullyInitialized()&&(a=dh(i,Ga(e)),a.isLeafNode()&&(u=t.filter.updateFullNode(u,a,o)))}return a=e.serverCache.isFullyInitialized()||null!=gh(i,Ao()),Wa(e,u,a,t.filter.filtersNodes())}}(t,e,h.path,i,r,o):function(t,e,n,i,s,r,o){if(null!=gh(s,n))return e;const a=e.serverCache.isFiltered(),h=e.serverCache;if(null!=i.value){if(Uo(n)&&h.isFullyInitialized()||h.isCompleteForPath(n))return kh(t,e,n,h.getNode().getChild(n),s,r,a,o);if(Uo(n)){let i=new Ka(null);
vendor: 4,683 bytes, line 1
1return h.getNode().forEachChild(Jo,(t,e)=>{i=i.set(new No(t),e)}),xh(t,e,n,i,s,r,a,o)}return e}{let l=new Ka(null);return i.foreach((t,e)=>{const i=Fo(n,t);h.isCompleteForPath(i)&&(l=l.set(t,h.getNode().getChild(i)))}),xh(t,e,n,l,s,r,a,o)}}(t,e,h.path,h.affectedTree,i,r,o)}else{if(n.type!==Oa.LISTEN_COMPLETE)throw F("Unknown operation type: "+n.type);a=function(t,e,n,i,s){const r=e.serverCache;return Sh(t,$a(e,r.getNode(),r.isFullyInitialized()||Uo(n),r.isFiltered()),n,i,Ch,s)}(t,e,n.path,i,o)}const l=o.getChanges();return function(t,e,n){const i=e.eventCache;if(i.isFullyInitialized()){const s=i.getNode().isLeafNode()||i.getNode().isEmpty(),r=za(t);(n.length>0||!t.eventCache.isFullyInitialized()||s&&!i.getNode().equals(r)||!i.getNode().getPriority().equals(r.getPriority()))&&n.push({type:"value",snapshotNode:za(e)})}}(e,a,l),{viewCache:a,changes:l}}function Sh(t,e,n,i,r,o){const a=e.eventCache;if(null!=gh(i,n))return e;{let h,l;if(Uo(n))if(s(e.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),e.serverCache.isFiltered()){const n=Ga(e),s=fh(i,n instanceof va?n:va.EMPTY_NODE);h=t.filter.updateFullNode(e.eventCache.getNode(),s,o)}else{const n=dh(i,Ga(e));h=t.filter.updateFullNode(e.eventCache.getNode(),n,o)}else{const u=xo(n);if(".priority"===u){s(1===Do(n),"Can't have a priority with additional path components");const r=a.getNode();l=e.serverCache.getNode();const o=ph(i,n,r,l);h=null!=o?t.filter.updatePriority(r,o):a.getNode()}else{const s=Oo(n);let c;if(a.isCompleteForChild(u)){l=e.serverCache.getNode();const t=ph(i,n,a.getNode(),l);c=null!=t?a.getNode().getImmediateChild(u).updateChild(s,t):a.getNode().getImmediateChild(u)}else c=_h(i,u,e.serverCache);h=null!=c?t.filter.updateChild(a.getNode(),u,c,s,r,o):a.getNode()}}return Wa(e,h,a.isFullyInitialized()||Uo(n),t.filter.filtersNodes())}}function kh(t,e,n,i,s,r,o,a){const h=e.serverCache;let l;const u=o?t.filter:t.filter.getIndexedFilter();if(Uo(n))l=u.updateFullNode(h.getNode(),i,null);else if(u.filtersNodes()&&!h.isFiltered()){const t=h.getNode().updateChild(n,i);l=u.updateFullNode(h.getNode(),t,null)}else{const t=xo(n);if(!h.isCompleteForPath(n)&&Do(n)>1)return e;const s=Oo(n),r=h.getNode().getImmediateChild(t).updateChild(s,i);l=".priority"===t?u.updatePriority(h.getNode(),r):u.updateChild(h.getNode(),t,r,s,Ch,null)}const c=$a(e,l,h.isFullyInitialized()||Uo(n),u.filtersNodes());return Sh(t,c,n,s,new bh(s,c,r),a)}function Rh(t,e,n,i,s,r,o){const a=e.eventCache;let h,l;const u=new bh(s,e,r);if(Uo(n))l=t.filter.updateFullNode(e.eventCache.getNode(),i,o),h=Wa(e,l,!0,t.filter.filtersNodes());else{const s=xo(n);if(".priority"===s)l=t.filter.updatePriority(e.eventCache.getNode(),i),h=Wa(e,l,a.isFullyInitialized(),a.isFiltered());else{const r=Oo(n),l=a.getNode().getImmediateChild(s);let c;if(Uo(r))c=i;else{const t=u.getCompleteChild(s);c=null!=t?".priority"===Po(r)&&t.getChild(Mo(r)).isEmpty()?t:t.updateChild(r,i):va.EMPTY_NODE}h=l.equals(c)?e:Wa(e,t.filter.updateChild(a.getNode(),s,c,r,u,o),a.isFullyInitialized(),t.filter.filtersNodes())}}return h}function Nh(t,e){return t.eventCache.isCompleteForChild(e)}function Ah(t,e,n){return n.foreach((t,n)=>{e=e.updateChild(t,n)}),e}function xh(t,e,n,i,s,r,o,a){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let h,l=e;h=Uo(n)?i:new Ka(null).setTree(n,i);const u=e.serverCache.getNode();return h.children.inorderTraversal((n,i)=>{if(u.hasChild(n)){const h=Ah(0,e.serverCache.getNode().getImmediateChild(n),i);l=kh(t,l,new No(n),h,s,r,o,a)}}),h.children.inorderTraversal((n,i)=>{const h=!e.serverCache.isCompleteForChild(n)&&null===i.value;if(!u.hasChild(n)&&!h){const h=Ah(0,e.serverCache.getNode().getImmediateChild(n),i);l=kh(t,l,new No(n),h,s,r,o,a)}}),l}function Dh(t,e){const n=Ga(t.viewCache_);return n&&(t.query._queryParams.loadsAllData()||!Uo(e)&&!n.getImmediateChild(xo(e)).isEmpty())?n.getChild(e):null}function Oh(t,e,n,i){e.type===Oa.MERGE&&null!==e.source.queryId&&(s(Ga(t.viewCache_),"We should always have a full cache before handling merges"),s(za(t.viewCache_),"Missing event cache, even though we have a server cache"));const r=t.viewCache_,o=Ih(t.processor_,r,e,n,i);var a,h;return a=t.processor_,h=o.viewCache,s(h.eventCache.getNode().isIndexed(a.filter.getIndex()),"Event snap not indexed"),s(h.serverCache.getNode().isIndexed(a.filter.getIndex()),"Server snap not indexed"),s(o.viewCache.serverCache.isFullyInitialized()||!r.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),t.viewCache_=o.viewCache,function(t,e,n,i){const s=i?[i]:t.eventRegistrations_;return function(t,e,n,i){const s=[],r=[];
1return e.forEach(e=>{var n;"child_changed"===e.type&&t.index_.indexedValueChanged(e.oldSnap,e.snapshotNode)&&r.push((n=e.childName,{type:"child_moved",snapshotNode:e.snapshotNode,childName:n}))}),Ba(t,s,"child_removed",e,i,n),Ba(t,s,"child_added",e,i,n),Ba(t,s,"child_moved",r,i,n),Ba(t,s,"child_changed",e,i,n),Ba(t,s,"value",e,i,n),s}(t.eventGenerator_,e,n,s)}(t,o.changes,o.viewCache.eventCache.getNode(),null)}function Ph(t,e,n,i){const r=e.source.queryId;if(null!==r){const o=t.views.get(r);return s(null!=o,"SyncTree gave us an op for an invalid query."),Oh(o,e,n,i)}{let s=[];for(const r of t.views.values())s=s.concat(Oh(r,e,n,i));return s}}function Lh(t,e){let n=null;for(const i of t.views.values())n=n||Dh(i,e);return n}var Mh=class{constructor(t){this.listenProvider_=t,this.syncPointTree_=new Ka(null),this.pendingWriteTree_={visibleWrites:Qa.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}};function Fh(t,e,n,i,r){return function(t,e,n,i,r){s(i>t.lastWriteId,"Stacking an older write on top of newer ones"),void 0===r&&(r=!0),t.allWrites.push({path:e,snap:n,writeId:i,visible:r}),r&&(t.visibleWrites=Xa(t.visibleWrites,e,n)),t.lastWriteId=i}(t.pendingWriteTree_,e,n,i,r),r?jh(t,new Va({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},e,n)):[]}function Uh(t,e,n=!1){const i=function(t,e){for(let n=0;n<t.allWrites.length;n++){const i=t.allWrites[n];if(i.writeId===e)return i}return null}(t.pendingWriteTree_,e);if(ah(t.pendingWriteTree_,e)){let e=new Ka(null);return null!=i.snap?e=e.set(Ao(),!0):Yr(i.children,t=>{e=e.set(new No(t),!0)}),jh(t,new Ua(i.path,e,n))}return[]}function Vh(t,e,n){return jh(t,new Va({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},e,n))}function qh(t,e,n){return ch(t.pendingWriteTree_,e,t.syncPointTree_.findOnPath(e,(t,n)=>{const i=Lh(n,Vo(t,e));if(i)return i}),n,!0)}function jh(t,e){return Bh(e,t.syncPointTree_,null,oh(t.pendingWriteTree_,Ao()))}function Bh(t,e,n,i){if(Uo(t.path))return Hh(t,e,n,i);{const s=e.get(Ao());null==n&&null!=s&&(n=Lh(s,Ao()));let r=[];const o=xo(t.path),a=t.operationForChild(o),h=e.children.get(o);if(h&&a){const t=n?n.getImmediateChild(o):null,e=yh(i,o);r=r.concat(Bh(a,h,t,e))}return s&&(r=r.concat(Ph(s,t,i,n))),r}}function Hh(t,e,n,i){const s=e.get(Ao());null==n&&null!=s&&(n=Lh(s,Ao()));let r=[];return e.children.inorderTraversal((e,s)=>{const o=n?n.getImmediateChild(e):null,a=yh(i,e),h=t.operationForChild(e);h&&(r=r.concat(Hh(h,s,o,a)))}),s&&(r=r.concat(Ph(s,t,i,n))),r}function Wh(t,e){return t.tagToQueryMap.get(e)}function $h(t){const e=t.indexOf("$");return s(-1!==e&&e<t.length-1,"Bad queryKey."),{queryId:t.substr(e+1),path:new No(t.substr(0,e))}}function zh(t,e,n){const i=t.syncPointTree_.get(e);return s(i,"Missing sync point for query tag that we're tracking"),Ph(i,n,oh(t.pendingWriteTree_,e),null)}var Gh=class t{constructor(t){this.node_=t}getImmediateChild(e){const n=this.node_.getImmediateChild(e);return new t(n)}node(){return this.node_}},Kh=class t{constructor(t,e){this.syncTree_=t,this.path_=e}getImmediateChild(e){const n=Fo(this.path_,e);return new t(this.syncTree_,n)}node(){return qh(this.syncTree_,this.path_)}},Qh=function(t,e,n){return t&&"object"==typeof t?(s(".sv"in t,"Unexpected leaf node or priority contents"),"string"==typeof t[".sv"]?Xh(t[".sv"],e,n):"object"==typeof t[".sv"]?Yh(t[".sv"],e):void s(!1,"Unexpected server value: "+JSON.stringify(t,null,2))):t},Xh=function(t,e,n){if("timestamp"===t)return n.timestamp;s(!1,"Unexpected server value: "+t)},Yh=function(t,e,n){t.hasOwnProperty("increment")||s(!1,"Unexpected server value: "+JSON.stringify(t,null,2));const i=t.increment;"number"!=typeof i&&s(!1,"Unexpected increment value: "+i);const r=e.node();if(s(null!=r,"Expected ChildrenNode.EMPTY_NODE for nulls"),!r.isLeafNode())return i;const o=r.getValue();return"number"!=typeof o?i:o+i},Jh=function(t,e,n){return Zh(t,new Gh(e),n)};function Zh(t,e,n){const i=t.getPriority().val(),s=Qh(i,e.getImmediateChild(".priority"),n);let r;if(t.isLeafNode()){const i=t,r=Qh(i.getValue(),e,n);
1return r!==i.getValue()||s!==i.getPriority().val()?new ua(r,Ta(s)):t}{const i=t;return r=i,s!==i.getPriority().val()&&(r=r.updatePriority(new ua(s))),i.forEachChild(fa,(t,i)=>{const s=Zh(i,e.getImmediateChild(t),n);s!==i&&(r=r.updateImmediateChild(t,s))}),r}}var tl=class{constructor(t="",e=null,n={children:{},childCount:0}){this.name=t,this.parent=e,this.node=n}};function el(t,e){let n=e instanceof No?e:new No(e),i=t,s=xo(n);for(;null!==s;){const t=L(i.node.children,s)||{children:{},childCount:0};i=new tl(s,i,t),n=Oo(n),s=xo(n)}return i}function nl(t){return t.node.value}function il(t,e){t.node.value=e,hl(t)}function sl(t){return t.node.childCount>0}function rl(t,e){Yr(t.node.children,(n,i)=>{e(new tl(n,t,i))})}function ol(t,e,n,i){n&&!i&&e(t),rl(t,t=>{ol(t,e,!0,i)}),n&&i&&e(t)}function al(t){return new No(null===t.parent?t.name:al(t.parent)+"/"+t.name)}function hl(t){null!==t.parent&&function(t,e,n){const i=function(t){return void 0===nl(t)&&!sl(t)}(n),s=r(t.node.children,e);i&&s?(delete t.node.children[e],t.node.childCount--,hl(t)):i||s||(t.node.children[e]=n.node,t.node.childCount++,hl(t))}(t.parent,t.name,t)}var ll=/[\[\].#$\/\u0000-\u001F\u007F]/,ul=/[\[\].#$\u0000-\u001F\u007F]/,cl=10485760,dl=function(t){return"string"==typeof t&&0!==t.length&&!ll.test(t)},fl=function(t){return t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),function(t){return"string"==typeof t&&0!==t.length&&!ul.test(t)}(t)},pl=function(t,e,n){const i=n instanceof No?new Bo(n,t):n;if(void 0===e)throw new Error(t+"contains undefined "+Wo(i));if("function"==typeof e)throw new Error(t+"contains a function "+Wo(i)+" with contents = "+e.toString());if(Hr(e))throw new Error(t+"contains "+e.toString()+" "+Wo(i));if("string"==typeof e&&e.length>cl/3&&c(e)>cl)throw new Error(t+"contains a string greater than 10485760 utf8 bytes "+Wo(i)+" ('"+e.substring(0,50)+"...')");if(e&&"object"==typeof e){let n=!1,s=!1;if(Yr(e,(e,r)=>{if(".value"===e)n=!0;else if(".priority"!==e&&".sv"!==e&&(s=!0,!dl(e)))throw new Error(t+" contains an invalid key ("+e+") "+Wo(i)+'.  Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');!function(t,e){t.parts_.length>0&&(t.byteLength_+=1),t.parts_.push(e),t.byteLength_+=c(e),Ho(t)}(i,e),pl(t,r,i),function(t){const e=t.parts_.pop();t.byteLength_-=c(e),t.parts_.length>0&&(t.byteLength_-=1)}(i)}),n&&s)throw new Error(t+' contains ".value" child '+Wo(i)+" in addition to actual children.")}},gl=class{constructor(){this.eventLists_=[],this.recursionDepth_=0}};function ml(t,e,n){!function(t,e){let n=null;for(let i=0;i<e.length;i++){const s=e[i],r=s.getPath();null===n||qo(r,n.path)||(t.eventLists_.push(n),n=null),null===n&&(n={events:[],path:r}),n.events.push(s)}n&&t.eventLists_.push(n)}(t,n),function(t,e){t.recursionDepth_++;let n=!0;for(let i=0;i<t.eventLists_.length;i++){const s=t.eventLists_[i];if(s){e(s.path)?(_l(t.eventLists_[i]),t.eventLists_[i]=null):n=!1}}n&&(t.eventLists_=[]);t.recursionDepth_--}(t,t=>jo(t,e)||jo(e,t))}function _l(t){for(let e=0;e<t.events.length;e++){const n=t.events[e];if(null!==n){t.events[e]=null;const i=n.getEventRunner();Mr&&Ur("event: "+n.toString()),eo(i)}}}var yl=class{constructor(t,e,n,i){this.repoInfo_=t,this.forceRestClient_=e,this.authTokenProvider_=n,this.appCheckProvider_=i,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new gl,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Aa(),this.transactionQueueTree_=new tl,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}};function vl(t,e,n){if(t.stats_=_o(t.repoInfo_),t.forceRestClient_||("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0)t.server_=new Ra(t.repoInfo_,(e,n,i,s)=>{El(t,e,n,i,s)},t.authTokenProvider_,t.appCheckProvider_),setTimeout(()=>Cl(t,!0),0);else{if(null!=n){if("object"!=typeof n)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{C(n)}catch(i){throw new Error("Invalid authOverride provided: "+i)}}t.persistentConnection_=new Go(t.repoInfo_,e,(e,n,i,s)=>{El(t,e,n,i,s)},e=>{Cl(t,e)},e=>{!function(t,e){Yr(e,(e,n)=>{bl(t,e,n)})}(t,e)},t.authTokenProvider_,t.appCheckProvider_,n),t.server_=t.persistentConnection_}t.authTokenProvider_.addTokenChangeListener(e=>{t.server_.refreshAuthToken(e)}),t.appCheckProvider_.addTokenChangeListener(e=>{t.server_.refreshAppCheckToken(e.token)}),t.statsReporter_=function(t,e){const n=t.toString();return mo[n]||(mo[n]=e()),mo[n]}(t.repoInfo_,()=>new La(t.stats_,t.server_)),t.infoData_=new Na,t.infoSyncTree_=new Mh({startListening:(e,n,i,s)=>{let r=[];const o=t.infoData_.getNode(e._path);return o.isEmpty()||(r=Vh(t.infoSyncTree_,e._path,o),setTimeout(()=>{s("ok")},0)),r},stopListening:()=>{}}),bl(t,"connected",!1),t.serverSyncTree_=new Mh({startListening:(e,n,i,s)=>(t.server_.listen(e,i,n,(n,i)=>{const r=s(n,i);ml(t.eventQueue_,e._path,r)}),[]),stopListening:(e,n)=>{t.server_.unlisten(e,n)}})}function wl(t){const e=t.infoData_.getNode(new No(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+e}
1function Tl(t){return(e=(e={timestamp:wl(t)})||{}).timestamp=e.timestamp||(new Date).getTime(),e;var e}function El(t,e,n,i,s){t.dataUpdateCount++;const r=new No(e);n=t.interceptServerDataCallback_?t.interceptServerDataCallback_(e,n):n;let o=[];if(s)if(i){const e=E(n,t=>Ta(t));o=function(t,e,n,i){const s=Wh(t,i);if(s){const i=$h(s),r=i.path,o=i.queryId,a=Vo(r,e),h=Ka.fromObject(n);return zh(t,r,new qa(Ma(o),a,h))}return[]}(t.serverSyncTree_,r,e,s)}else{const e=Ta(n);o=function(t,e,n,i){const s=Wh(t,i);if(null!=s){const i=$h(s),r=i.path,o=i.queryId,a=Vo(r,e);return zh(t,r,new Va(Ma(o),a,n))}return[]}(t.serverSyncTree_,r,e,s)}else if(i){const e=E(n,t=>Ta(t));o=function(t,e,n){const i=Ka.fromObject(n);return jh(t,new qa({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},e,i))}(t.serverSyncTree_,r,e)}else{const e=Ta(n);o=Vh(t.serverSyncTree_,r,e)}let a=r;o.length>0&&(a=Nl(t,r)),ml(t.eventQueue_,a,o)}function Cl(t,e){bl(t,"connected",e),!1===e&&function(t){Sl(t,"onDisconnectEvents");const e=Tl(t),n=Aa();Da(t.onDisconnect_,Ao(),(i,s)=>{const r=function(t,e,n,i){return Zh(e,new Kh(n,t),i)}(i,s,t.serverSyncTree_,e);xa(n,i,r)});let i=[];Da(n,Ao(),(e,n)=>{i=i.concat(Vh(t.serverSyncTree_,e,n)),Nl(t,function(t,e){const n=al(Al(t,e)),i=el(t.transactionQueueTree_,e);return function(t,e,n){let i=n?t:t.parent;for(;null!==i;){if(e(i))return!0;i=i.parent}}(i,e=>{Pl(t,e)}),Pl(t,i),ol(i,e=>{Pl(t,e)}),n}(t,e))}),t.onDisconnect_=Aa(),ml(t.eventQueue_,Ao(),i)}(t)}function bl(t,e,n){const i=new No("/.info/"+e),s=Ta(n);t.infoData_.updateSnapshot(i,s);const r=Vh(t.infoSyncTree_,i,s);ml(t.eventQueue_,i,r)}function Il(t){return t.nextWriteId_++}function Sl(t,...e){let n="";t.persistentConnection_&&(n=t.persistentConnection_.id+":"),Ur(n,...e)}function kl(t,e,n){return qh(t.serverSyncTree_,e,n)||va.EMPTY_NODE}function Rl(t,e=t.transactionQueueTree_){if(e||Ol(t,e),nl(e)){const n=xl(t,e);s(n.length>0,"Sending zero length transaction queue"),n.every(t=>0===t.status)&&function(t,e,n){const i=kl(t,e,n.map(t=>t.currentWriteId));let r=i;const o=i.hash();for(let l=0;l<n.length;l++){const t=n[l];s(0===t.status,"tryToSendTransactionQueue_: items in queue should all be run."),t.status=1,t.retryCount++;const i=Vo(e,t.path);r=r.updateChild(i,t.currentOutputSnapshotRaw)}const a=r.val(!0),h=e;t.server_.put(h.toString(),a,i=>{Sl(t,"transaction put response",{path:h.toString(),status:i});let s=[];if("ok"===i){const i=[];for(let e=0;e<n.length;e++)n[e].status=2,s=s.concat(Uh(t.serverSyncTree_,n[e].currentWriteId)),n[e].onComplete&&i.push(()=>n[e].onComplete(null,!0,n[e].currentOutputSnapshotResolved)),n[e].unwatcher();Ol(t,el(t.transactionQueueTree_,e)),Rl(t,t.transactionQueueTree_),ml(t.eventQueue_,e,s);for(let t=0;t<i.length;t++)eo(i[t])}else{if("datastale"===i)for(let t=0;t<n.length;t++)3===n[t].status?n[t].status=4:n[t].status=0;else{Br("transaction at "+h.toString()+" failed: "+i);for(let t=0;t<n.length;t++)n[t].status=4,n[t].abortReason=i}Nl(t,e)}},o)}(t,al(e),n)}else sl(e)&&rl(e,e=>{Rl(t,e)})}function Nl(t,e){const n=Al(t,e),i=al(n);return function(t,e,n){if(0===e.length)return;const i=[];let o=[];const a=e.filter(t=>0===t.status).map(t=>t.currentWriteId);for(let h=0;h<e.length;h++){const l=e[h],u=Vo(n,l.path);let c,d=!1;if(s(null!==u,"rerunTransactionsUnderNode_: relativePath should not be null."),4===l.status)d=!0,c=l.abortReason,o=o.concat(Uh(t.serverSyncTree_,l.currentWriteId,!0));else if(0===l.status)if(l.retryCount>=25)d=!0,c="maxretry",o=o.concat(Uh(t.serverSyncTree_,l.currentWriteId,!0));else{const n=kl(t,l.path,a);l.currentInputSnapshot=n;const i=e[h].update(n.val());if(void 0!==i){pl("transaction failed: Data returned ",i,l.path);let e=Ta(i);"object"==typeof i&&null!=i&&r(i,".priority")||(e=e.updatePriority(n.getPriority()));const s=l.currentWriteId,h=Tl(t),u=Jh(e,n,h);l.currentOutputSnapshotRaw=e,l.currentOutputSnapshotResolved=u,l.currentWriteId=Il(t),a.splice(a.indexOf(s),1),o=o.concat(Fh(t.serverSyncTree_,l.path,u,l.currentWriteId,l.applyLocally)),o=o.concat(Uh(t.serverSyncTree_,s,!0))}else d=!0,c="nodata",o=o.concat(Uh(t.serverSyncTree_,l.currentWriteId,!0))}ml(t.eventQueue_,n,o),o=[],d&&(e[h].status=2,function(t){setTimeout(t,Math.floor(0))}(e[h].unwatcher),e[h].onComplete&&("nodata"===c?i.push(()=>e[h].onComplete(null,!1,e[h].currentInputSnapshot)):i.push(()=>e[h].onComplete(new Error(c),!1,null))))}Ol(t,t.transactionQueueTree_);for(let s=0;s<i.length;s++)eo(i[s]);Rl(t,t.transactionQueueTree_)}(t,xl(t,n),i),i}function Al(t,e){let n,i=t.transactionQueueTree_;
1for(n=xo(e);null!==n&&void 0===nl(i);)i=el(i,n),n=xo(e=Oo(e));return i}function xl(t,e){const n=[];return Dl(t,e,n),n.sort((t,e)=>t.order-e.order),n}function Dl(t,e,n){const i=nl(e);if(i)for(let s=0;s<i.length;s++)n.push(i[s]);rl(e,e=>{Dl(t,e,n)})}function Ol(t,e){const n=nl(e);if(n){let t=0;for(let e=0;e<n.length;e++)2!==n[e].status&&(n[t]=n[e],t++);n.length=t,il(e,n.length>0?n:void 0)}rl(e,e=>{Ol(t,e)})}function Pl(t,e){const n=nl(e);if(n){const i=[];let r=[],o=-1;for(let e=0;e<n.length;e++)3===n[e].status||(1===n[e].status?(s(o===e-1,"All SENT items should be at beginning of queue."),o=e,n[e].status=3,n[e].abortReason="set"):(s(0===n[e].status,"Unexpected transaction status in abort"),n[e].unwatcher(),r=r.concat(Uh(t.serverSyncTree_,n[e].currentWriteId,!0)),n[e].onComplete&&i.push(n[e].onComplete.bind(null,new Error("set"),!1,null))));-1===o?il(e,void 0):n.length=o+1,ml(t.eventQueue_,al(e),r);for(let t=0;t<i.length;t++)eo(i[t])}}var Ll=function(t,e){const n=Ml(t),i=n.namespace;"firebase.com"===n.domain&&jr(n.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),i&&"undefined"!==i||"localhost"===n.domain||jr("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),n.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&Br("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");const s="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new co(n.host,n.secure,i,s,e,"",i!==n.subdomain),path:new No(n.pathString)}},Ml=function(t){let e="",n="",i="",s="",r="",o=!0,a="https",h=443;if("string"==typeof t){let l=t.indexOf("//");l>=0&&(a=t.substring(0,l-1),t=t.substring(l+2));let u=t.indexOf("/");-1===u&&(u=t.length);let c=t.indexOf("?");-1===c&&(c=t.length),e=t.substring(0,Math.min(u,c)),u<c&&(s=function(t){let e="";const n=t.split("/");for(let s=0;s<n.length;s++)if(n[s].length>0){let t=n[s];try{t=decodeURIComponent(t.replace(/\+/g," "))}catch(i){}e+="/"+t}return e}(t.substring(u,c)));const d=function(t){const e={};"?"===t.charAt(0)&&(t=t.substring(1));for(const n of t.split("&")){if(0===n.length)continue;const i=n.split("=");2===i.length?e[decodeURIComponent(i[0])]=decodeURIComponent(i[1]):Br(`Invalid query segment '${n}' in query '${t}'`)}return e}(t.substring(Math.min(t.length,c)));l=e.indexOf(":"),l>=0?(o="https"===a||"wss"===a,h=parseInt(e.substring(l+1),10)):l=e.length;const f=e.slice(0,l);if("localhost"===f.toLowerCase())n="localhost";else if(f.split(".").length<=2)n=f;else{const t=e.indexOf(".");i=e.substring(0,t).toLowerCase(),n=e.substring(t+1),r=i}"ns"in d&&(r=d.ns)}return{host:e,port:h,domain:n,subdomain:i,secure:o,scheme:a,pathString:s,namespace:r}},Fl=class t{constructor(t,e,n,i){this._repo=t,this._path=e,this._queryParams=n,this._orderByCalled=i}get key(){return Uo(this._path)?null:Po(this._path)}get ref(){return new Ul(this._repo,this._path)}get _queryIdentifier(){const t=ka(this._queryParams),e=Qr(t);return"{}"===e?"default":e}get _queryObject(){return ka(this._queryParams)}isEqual(e){if(!((e=f(e))instanceof t))return!1;const n=this._repo===e._repo,i=qo(this._path,e._path),s=this._queryIdentifier===e._queryIdentifier;return n&&i&&s}toJSON(){return this.toString()}toString(){return this._repo.toString()+function(t){let e="";for(let n=t.pieceNum_;n<t.pieces_.length;n++)""!==t.pieces_[n]&&(e+="/"+encodeURIComponent(String(t.pieces_[n])));return e||"/"}(this._path)}},Ul=class t extends Fl{constructor(t,e){super(t,e,new Ia,!1)}get parent(){const e=Mo(this._path);return null===e?null:new t(this._repo,e)}get root(){let t=this;for(;null!==t.parent;)t=t.parent;return t}};!function(t){s(!wh,"__referenceConstructor has already been defined"),wh=t}(Ul),function(t){s(!Th,"__referenceConstructor has already been defined"),Th=t}(Ul);var Vl={},ql=!1;function jl(t,e,i,s,r){let o=s||t.options.databaseURL;void 0===o&&(t.options.projectId||jr("Can't determine Firebase Database URL. Be sure to include  a Project ID when calling firebase.initializeApp()."),Ur("Using default host for project ",t.options.projectId),o=`${t.options.projectId}-default-rtdb.firebaseio.com`);let a,h,l=Ll(o,r),u=l.repoInfo;"undefined"!=typeof process&&(h={}.FIREBASE_DATABASE_EMULATOR_HOST),h?(a=!0,o=`http://${h}?ns=${u.namespace}`,l=Ll(o,r),u=l.repoInfo):a=!l.repoInfo.secure;const c=r&&a?new ro(ro.OWNER):new so(t.name,t.options,e);!function(t,e){const i=e.path.toString();if("string"!=typeof e.repoInfo.host||0===e.repoInfo.host.length||!dl(e.repoInfo.namespace)&&"localhost"!==e.repoInfo.host.split(":")[0]||0!==i.length&&!fl(i))throw new Error(n(t,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')}("Invalid Firebase Database URL",l),Uo(l.path)||jr("Database URL must point to the root of a Firebase Database (not including a child path).");const d=function(t,e,n,i){let s=Vl[e.name];s||(s={},Vl[e.name]=s);let r=s[t.toURLString()];r&&jr("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.");return r=new yl(t,ql,n,i),s[t.toURLString()]=r,r}(u,t,c,new io(t,i));return new Hl(d,t)}var Bl,Hl=class{constructor(t,e){this._repoInternal=t,this.app=e,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(vl(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Ul(this._repo,Ao())),this._rootInternal}_delete(){return null!==this._rootInternal&&(!function(t,e){const n=Vl[e];n&&n[t.key]===t||jr(`Database ${e}(${t.repoInfo_}) has already been deleted.`),function(t){t.persistentConnection_&&t.persistentConnection_.interrupt("repo_interrupt")}(t),delete n[t.key]}(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(t){null===this._rootInternal&&jr("Cannot call "+t+" on a deleted database.")}};Go.prototype.simpleListen=function(t,e){this.sendRequest("q",{p:t},e)},Go.prototype.echo=function(t,e){this.sendRequest("echo",{d:t},e)},function(t){Sr=t}(R),O(new M("database",(t,{instanceIdentifier:e})=>jl(t.getProvider("app").getImmediate(),t.getProvider("auth-internal"),t.getProvider("app-check-internal"),e),"PUBLIC").setMultipleInstances(!0)),S(br,Ir,Bl),S(br,Ir,"esm2017");var Wl,$l="firebasestorage.googleapis.com",zl=class t extends U{constructor(e,n,i=0){super(Gl(e),`Firebase Storage: ${n} (${Gl(e)})`),this.status_=i,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,t.prototype)}get status(){return this.status_}set status(t){this.status_=t}
1_codeEquals(t){return Gl(t)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(t){this.customData.serverResponse=t,this.customData.serverResponse?this.message=`${this._baseMessage}\n${this.customData.serverResponse}`:this.message=this._baseMessage}};function Gl(t){return"storage/"+t}function Kl(){return new zl(Wl.UNKNOWN,"An unknown error occurred, please check the error payload for server response.")}function Ql(){return new zl(Wl.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function Xl(){return new zl(Wl.CANCELED,"User canceled the upload/download.")}function Yl(){return new zl(Wl.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function Jl(t){return new zl(Wl.INVALID_ARGUMENT,t)}function Zl(){return new zl(Wl.APP_DELETED,"The Firebase app was deleted.")}function tu(t,e){return new zl(Wl.INVALID_FORMAT,"String does not match format '"+t+"': "+e)}function eu(t){throw new zl(Wl.INTERNAL_ERROR,"Internal error: "+t)}!function(t){t.UNKNOWN="unknown",t.OBJECT_NOT_FOUND="object-not-found",t.BUCKET_NOT_FOUND="bucket-not-found",t.PROJECT_NOT_FOUND="project-not-found",t.QUOTA_EXCEEDED="quota-exceeded",t.UNAUTHENTICATED="unauthenticated",t.UNAUTHORIZED="unauthorized",t.UNAUTHORIZED_APP="unauthorized-app",t.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",t.INVALID_CHECKSUM="invalid-checksum",t.CANCELED="canceled",t.INVALID_EVENT_NAME="invalid-event-name",t.INVALID_URL="invalid-url",t.INVALID_DEFAULT_BUCKET="invalid-default-bucket",t.NO_DEFAULT_BUCKET="no-default-bucket",t.CANNOT_SLICE_BLOB="cannot-slice-blob",t.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",t.NO_DOWNLOAD_URL="no-download-url",t.INVALID_ARGUMENT="invalid-argument",t.INVALID_ARGUMENT_COUNT="invalid-argument-count",t.APP_DELETED="app-deleted",t.INVALID_ROOT_OPERATION="invalid-root-operation",t.INVALID_FORMAT="invalid-format",t.INTERNAL_ERROR="internal-error",t.UNSUPPORTED_ENVIRONMENT="unsupported-environment"}(Wl||(Wl={}));var nu,iu=class t{constructor(t,e){this.bucket=t,this.path_=e}get path(){return this.path_}get isRoot(){return 0===this.path.length}fullServerUrl(){const t=encodeURIComponent;return"/b/"+t(this.bucket)+"/o/"+t(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,n){let i;try{i=t.makeFromUrl(e,n)}catch(r){return new t(e,"")}if(""===i.path)return i;throw s=e,new zl(Wl.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+s+"'.");var s}static makeFromUrl(e,n){let i=null;const s="([A-Za-z0-9.\\-_]+)";const r=new RegExp("^gs://([A-Za-z0-9.\\-_]+)(/(.*))?$","i");function o(t){t.path_=decodeURIComponent(t.path)}const a=n.replace(/[.]/g,"\\."),h=[{regex:r,indices:{bucket:1,path:3},postModify:function(t){"/"===t.path.charAt(t.path.length-1)&&(t.path_=t.path_.slice(0,-1))}},{regex:new RegExp(`^https?://${a}/v[A-Za-z0-9_]+/b/${s}/o(/([^?#]*).*)?$`,"i"),indices:{bucket:1,path:3},postModify:o},{regex:new RegExp(`^https?://${n===$l?"(?:storage.googleapis.com|storage.cloud.google.com)":n}/${s}/([^?#]*)`,"i"),indices:{bucket:1,path:2},postModify:o}];for(let l=0;l<h.length;l++){const n=h[l],s=n.regex.exec(e);if(s){const e=s[n.indices.bucket];let r=s[n.indices.path];r||(r=""),i=new t(e,r),n.postModify(i);break}}if(null==i)throw function(t){return new zl(Wl.INVALID_URL,"Invalid URL '"+t+"'.")}(e);return i}},su=class{constructor(t){this.promise_=Promise.reject(t)}getPromise(){return this.promise_}cancel(t=!1){}};function ru(t){return"string"==typeof t||t instanceof String}function ou(t){return au()&&t instanceof Blob}function au(){return"undefined"!=typeof Blob}function hu(t,e,n,i){if(i<e)throw Jl(`Invalid value for '${t}'. Expected ${e} or greater.`);if(i>n)throw Jl(`Invalid value for '${t}'. Expected ${n} or less.`)}function lu(t,e,n){let i=e;return null==n&&(i=`https://${e}`),`${n}://${i}/v0${t}`}function uu(t){const e=encodeURIComponent;let n="?";for(const i in t)if(t.hasOwnProperty(i)){n=n+(e(i)+"="+e(t[i]))+"&"}return n=n.slice(0,-1),n}function cu(t,e){const n=t>=500&&t<600,i=-1!==[408,429].indexOf(t),s=-1!==e.indexOf(t);return n||i||s}
1!function(t){t[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT"}(nu||(nu={}));var du=class{constructor(t,e,n,i,s,r,o,a,h,l,u,c=!0,d=!1){this.url_=t,this.method_=e,this.headers_=n,this.body_=i,this.successCodes_=s,this.additionalRetryCodes_=r,this.callback_=o,this.errorCallback_=a,this.timeout_=h,this.progressCallback_=l,this.connectionFactory_=u,this.retry=c,this.isUsingEmulator=d,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((t,e)=>{this.resolve_=t,this.reject_=e,this.start_()})}start_(){const t=(t,e)=>{const n=this.resolve_,i=this.reject_,s=e.connection;if(e.wasSuccessCode)try{const t=this.callback_(s,s.getResponse());void 0!==t?n(t):n()}catch(r){i(r)}else if(null!==s){const t=Kl();t.serverResponse=s.getErrorText(),this.errorCallback_?i(this.errorCallback_(s,t)):i(t)}else e.canceled?i(this.appDelete_?Zl():Xl()):i(Ql())};this.canceled_?t(0,new fu(!1,null,!0)):this.backoffId_=function(t,e,n){let i=1,s=null,r=null,o=!1,a=0;function h(){return 2===a}let l=!1;function u(...t){l||(l=!0,e.apply(null,t))}function c(e){s=setTimeout(()=>{s=null,t(f,h())},e)}function d(){r&&clearTimeout(r)}function f(t,...e){if(l)return void d();if(t)return d(),void u.call(null,t,...e);if(h()||o)return d(),void u.call(null,t,...e);let n;i<64&&(i*=2),1===a?(a=2,n=0):n=1e3*(i+Math.random()),c(n)}let p=!1;function g(t){p||(p=!0,d(),l||(null!==s?(t||(a=2),clearTimeout(s),c(0)):t||(a=1)))}return c(0),r=setTimeout(()=>{o=!0,g(!0)},n),g}((t,e)=>{if(e)return void t(!1,new fu(!1,null,!0));const n=this.connectionFactory_();this.pendingConnection_=n;const i=t=>{const e=t.loaded,n=t.lengthComputable?t.total:-1;null!==this.progressCallback_&&this.progressCallback_(e,n)};null!==this.progressCallback_&&n.addUploadProgressListener(i),n.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{null!==this.progressCallback_&&n.removeUploadProgressListener(i),this.pendingConnection_=null;const e=n.getErrorCode()===nu.NO_ERROR,s=n.getStatus();if(!e||cu(s,this.additionalRetryCodes_)&&this.retry){const e=n.getErrorCode()===nu.ABORT;return void t(!1,new fu(!1,null,e))}const r=-1!==this.successCodes_.indexOf(s);t(!0,new fu(r,n))})},t,this.timeout_)}getPromise(){return this.promise_}cancel(t){this.canceled_=!0,this.appDelete_=t||!1,null!==this.backoffId_&&(0,this.backoffId_)(!1),null!==this.pendingConnection_&&this.pendingConnection_.abort()}},fu=class{constructor(t,e,n){this.wasSuccessCode=t,this.connection=e,this.canceled=!!n}};function pu(){return"undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0}function gu(...t){const e=pu();if(void 0!==e){const n=new e;for(let e=0;e<t.length;e++)n.append(t[e]);return n.getBlob()}if(au())return new Blob(t);throw new zl(Wl.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}function mu(t){if("undefined"==typeof atob)throw e="base-64",new zl(Wl.UNSUPPORTED_ENVIRONMENT,`${e} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`);var e;return atob(t)}var _u="raw",yu="base64",vu="base64url",wu="data_url",Tu=class{constructor(t,e){this.data=t,this.contentType=e||null}};function Eu(t,e){switch(t){case _u:return new Tu(Cu(e));case yu:case vu:return new Tu(bu(t,e));case wu:return new Tu(function(t){const e=new Iu(t);return e.base64?bu(yu,e.rest):function(t){let e;try{e=decodeURIComponent(t)}catch(n){throw tu(wu,"Malformed data URL.")}return Cu(e)}(e.rest)}(e),new Iu(e).contentType)}throw Kl()}function Cu(t){const e=[];for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);if(i<=127)e.push(i);else if(i<=2047)e.push(192|i>>6,128|63&i);else if(55296==(64512&i))if(n<t.length-1&&56320==(64512&t.charCodeAt(n+1))){i=65536|(1023&i)<<10|1023&t.charCodeAt(++n),e.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i)}else e.push(239,191,189);else 56320==(64512&i)?e.push(239,191,189):e.push(224|i>>12,128|i>>6&63,128|63&i)}return new Uint8Array(e)}function bu(t,e){switch(t){case yu:{const n=-1!==e.indexOf("-"),i=-1!==e.indexOf("_");if(n||i)throw tu(t,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?");break}case vu:{const n=-1!==e.indexOf("+"),i=-1!==e.indexOf("/");if(n||i)throw tu(t,"Invalid character '"+(n?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let n;try{n=mu(e)}
1catch(s){if(s.message.includes("polyfill"))throw s;throw tu(t,"Invalid character found")}const i=new Uint8Array(n.length);for(let r=0;r<n.length;r++)i[r]=n.charCodeAt(r);return i}var Iu=class{constructor(t){this.base64=!1,this.contentType=null;const e=t.match(/^data:([^,]+)?,/);if(null===e)throw tu(wu,"Must be formatted 'data:[<mediatype>][;base64],<data>");const n=e[1]||null;var i,s;null!=n&&(this.base64=(s=";base64",(i=n).length>=s.length&&i.substring(i.length-s.length)===s),this.contentType=this.base64?n.substring(0,n.length-7):n),this.rest=t.substring(t.indexOf(",")+1)}};var Su=class t{constructor(t,e){let n=0,i="";ou(t)?(this.data_=t,n=t.size,i=t.type):t instanceof ArrayBuffer?(e?this.data_=new Uint8Array(t):(this.data_=new Uint8Array(t.byteLength),this.data_.set(new Uint8Array(t))),n=this.data_.length):t instanceof Uint8Array&&(e?this.data_=t:(this.data_=new Uint8Array(t.length),this.data_.set(t)),n=t.length),this.size_=n,this.type_=i}size(){return this.size_}type(){return this.type_}slice(e,n){if(ou(this.data_)){const i=function(t,e,n){return t.webkitSlice?t.webkitSlice(e,n):t.mozSlice?t.mozSlice(e,n):t.slice?t.slice(e,n):null}(this.data_,e,n);return null===i?null:new t(i)}{const i=new Uint8Array(this.data_.buffer,e,n-e);return new t(i,!0)}}static getBlob(...e){if(au()){const n=e.map(e=>e instanceof t?e.data_:e);return new t(gu.apply(null,n))}{const n=e.map(t=>ru(t)?Eu(_u,t).data:t.data_);let i=0;n.forEach(t=>{i+=t.byteLength});const s=new Uint8Array(i);let r=0;return n.forEach(t=>{for(let e=0;e<t.length;e++)s[r++]=t[e]}),new t(s,!0)}}uploadData(){return this.data_}};function ku(t){let e;try{e=JSON.parse(t)}catch(i){return null}return"object"!=typeof(n=e)||Array.isArray(n)?null:e;var n}function Ru(t){const e=t.lastIndexOf("/",t.length-2);return-1===e?t:t.slice(e+1)}function Nu(t,e){return e}var Au=class{constructor(t,e,n,i){this.server=t,this.local=e||t,this.writable=!!n,this.xform=i||Nu}},xu=null;function Du(){if(xu)return xu;const t=[];t.push(new Au("bucket")),t.push(new Au("generation")),t.push(new Au("metageneration")),t.push(new Au("name","fullPath",!0));const e=new Au("name");e.xform=function(t,e){return function(t){return!ru(t)||t.length<2?t:Ru(t)}(e)},t.push(e);const n=new Au("size");return n.xform=function(t,e){return void 0!==e?Number(e):e},t.push(n),t.push(new Au("timeCreated")),t.push(new Au("updated")),t.push(new Au("md5Hash",null,!0)),t.push(new Au("cacheControl",null,!0)),t.push(new Au("contentDisposition",null,!0)),t.push(new Au("contentEncoding",null,!0)),t.push(new Au("contentLanguage",null,!0)),t.push(new Au("contentType",null,!0)),t.push(new Au("metadata","customMetadata",!0)),xu=t}function Ou(t,e,n){const i={type:"file"},s=n.length;for(let r=0;r<s;r++){const t=n[r];i[t.local]=t.xform(i,e[t.server])}return function(t,e){Object.defineProperty(t,"ref",{get:function(){const n=t.bucket,i=t.fullPath,s=new iu(n,i);return e._makeStorageReference(s)}})}(i,t),i}function Pu(t,e,n){const i=ku(e);return null===i?null:Ou(t,i,n)}function Lu(t,e){const n={},i=e.length;for(let s=0;s<i;s++){const i=e[s];i.writable&&(n[i.server]=t[i.local])}return JSON.stringify(n)}var Mu="prefixes",Fu="items";function Uu(t,e,n){const i=ku(n);return null===i?null:function(t,e,n){const i={prefixes:[],items:[],nextPageToken:n.nextPageToken};if(n[Mu])for(const s of n[Mu]){const n=s.replace(/\/$/,""),r=t._makeStorageReference(new iu(e,n));i.prefixes.push(r)}if(n[Fu])for(const s of n[Fu]){const n=t._makeStorageReference(new iu(e,s.name));i.items.push(n)}return i}(t,e,i)}var Vu=class{constructor(t,e,n,i){this.url=t,this.method=e,this.handler=n,this.timeout=i,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}};function qu(t){if(!t)throw Kl()}function ju(t,e){return function(n,i){const s=Pu(t,i,e);return qu(null!==s),s}}function Bu(t,e){return function(n,i){const s=Pu(t,i,e);return qu(null!==s),function(t,e,n,i){const s=ku(e);if(null===s)return null;if(!ru(s.downloadTokens))return null;const r=s.downloadTokens;if(0===r.length)return null;const o=encodeURIComponent;return r.split(",").map(e=>{const s=t.bucket,r=t.fullPath;return lu("/b/"+o(s)+"/o/"+o(r),n,i)+uu({alt:"media",token:e})})[0]}(s,i,t.host,t._protocol)}}function Hu(t){return function(e,n){let i;var s,r;return 401===e.getStatus()?i=e.getErrorText().includes("Firebase App Check token is invali
1d")?new zl(Wl.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project."):new zl(Wl.UNAUTHENTICATED,"User is not authenticated, please authenticate using Firebase Authentication and try again."):402===e.getStatus()?(r=t.bucket,i=new zl(Wl.QUOTA_EXCEEDED,"Quota for bucket '"+r+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===e.getStatus()?(s=t.path,i=new zl(Wl.UNAUTHORIZED,"User does not have permission to access '"+s+"'.")):i=n,i.status=e.getStatus(),i.serverResponse=n.serverResponse,i}}function Wu(t){const e=Hu(t);return function(n,i){let s=e(n,i);var r;return 404===n.getStatus()&&(r=t.path,s=new zl(Wl.OBJECT_NOT_FOUND,"Object '"+r+"' does not exist.")),s.serverResponse=i.serverResponse,s}}function $u(t,e,n,i,s){const r={};e.isRoot?r.prefix="":r.prefix=e.path+"/",n&&n.length>0&&(r.delimiter=n),i&&(r.pageToken=i),s&&(r.maxResults=s);const o=lu(e.bucketOnlyServerUrl(),t.host,t._protocol),a=t.maxOperationRetryTime,h=new Vu(o,"GET",function(t,e){return function(n,i){const s=Uu(t,e,i);return qu(null!==s),s}}(t,e.bucket),a);return h.urlParams=r,h.errorHandler=Hu(e),h}function zu(t,e,n){const i=Object.assign({},n);return i.fullPath=t.path,i.size=e.size(),i.contentType||(i.contentType=function(t,e){return t&&t.contentType||e&&e.type()||"application/octet-stream"}(null,e)),i}function Gu(t,e,n,i,s){const r=e.bucketOnlyServerUrl(),o={"X-Goog-Upload-Protocol":"multipart"};const a=function(){let t="";for(let e=0;e<2;e++)t+=Math.random().toString().slice(2);return t}();o["Content-Type"]="multipart/related; boundary="+a;const h=zu(e,i,s),l="--"+a+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+Lu(h,n)+"\r\n--"+a+"\r\nContent-Type: "+h.contentType+"\r\n\r\n",u="\r\n--"+a+"--",c=Su.getBlob(l,i,u);if(null===c)throw Yl();const d={name:h.fullPath},f=lu(r,t.host,t._protocol),p=t.maxUploadRetryTime,g=new Vu(f,"POST",ju(t,n),p);return g.urlParams=d,g.headers=o,g.body=c.uploadData(),g.errorHandler=Hu(e),g}var Ku=class{constructor(t,e,n,i){this.current=t,this.total=e,this.finalized=!!n,this.metadata=i||null}};function Qu(t,e){let n=null;try{n=t.getResponseHeader("X-Goog-Upload-Status")}catch(i){qu(!1)}return qu(!!n&&-1!==(e||["active"]).indexOf(n)),n}var Xu=262144;function Yu(t,e,n,i,s,r,o,a){const h=new Ku(0,0);if(o?(h.current=o.current,h.total=o.total):(h.current=0,h.total=i.size()),i.size()!==h.total)throw new zl(Wl.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.");const l=h.total-h.current;let u=l;s>0&&(u=Math.min(u,s));const c=h.current,d=c+u;let f="";f=0===u?"finalize":l===u?"upload, finalize":"upload";const p={"X-Goog-Upload-Command":f,"X-Goog-Upload-Offset":`${h.current}`},g=i.slice(c,d);if(null===g)throw Yl();const m=e.maxUploadRetryTime,_=new Vu(n,"POST",function(t,n){const s=Qu(t,["active","final"]),o=h.current+u,a=i.size();let l;return l="final"===s?ju(e,r)(t,n):null,new Ku(o,a,"final"===s,l)},m);return _.headers=p,_.body=g.uploadData(),_.progressCallback=a||null,_.errorHandler=Hu(t),_}var Ju="running",Zu="paused",tc="success",ec="canceled",nc="error";function ic(t){switch(t){case"running":case"pausing":case"canceling":return Ju;case"paused":return Zu;case"success":return tc;case"canceled":return ec;default:return nc}}var sc=class{constructor(t,e,n){if("function"==typeof t||null!=e||null!=n)this.next=t,this.error=null!=e?e:void 0,this.complete=null!=n?n:void 0;else{const e=t;this.next=e.next,this.error=e.error,this.complete=e.complete}}};function rc(t){return(...e)=>{Promise.resolve().then(()=>t(...e))}}var oc=class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=nu.NO_ERROR,this.sendPromise_=new Promise(t=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=nu.ABORT,t()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=nu.NETWORK_ERROR,t()}),this.xhr_.addEventListener("load",()=>{t()})})}send(t,e,n,i,s){if(this.sent_)throw eu("cannot .send() more than once");if(a(t)&&n&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(e,t,!0),void 0!==s)for(const r in s)s.hasOwnProperty(r)&&this.xhr_.setRequestHeader(r,s[r].toString());return void 0!==i?this.xhr_.send(i):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw eu("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw eu("cannot .getStatus() before sending");try{return this.xhr_.status}catch(t){return-1}}getResponse(){if(!this.sent_)throw eu("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw eu("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(t){return this.xhr_.getResponseHeader(t)}addUploadProgressListener(t){null!=this.xhr_.upload&&this.xhr_.upload.addEventListener("progress",t)}removeUploadProgressListener(t){null!=this.xhr_.upload&&this.xhr_.upload.removeEventListener("progress",t)}},ac=class extends oc{initXhr(){this.xhr_.responseType="text"}};function hc(){return new ac}var lc=class{isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}constructor(t,e,n=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=t,this._blob=e,this._metadata=n,this._mappings=Du(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=t=>{if(this._request=void 0,this._chunkMultiplier=1,t._codeEquals(Wl.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{const e=this.isExponentialBackoffExpired();if(cu(t.status,[])){if(!e)return this.sleepTime=Math.max(2*this.sleepTime,1e3),this._needToFetchStatus=!0,void this.completeTransitions_();t=Ql()}this._error=t,this._transition("error")}},this._metadataErrorHandler=t=>{this._request=void 0,t._codeEquals(Wl.CANCELED)?this.completeTransitions_():(this._error=t,this._transition("error"))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((t,e)=>{this._resolve=t,this._reject=e,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){const t=this._transferred;return e=>this._updateProgress(t+e)}_shouldDoResumable(t){return t.size()>262144}_start(){"running"===this._state&&void 0===this._request&&(this._resumable?void 0===this._uploadUrl?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(t){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([e,n])=>{switch(this._state){case"running":t(e,n);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused")}})}_createResumable(){this._resolveToken((t,e)=>{const n=function(t,e,n,i,s){const r=e.bucketOnlyServerUrl(),o=zu(e,i,s),a={name:o.fullPath},h=lu(r,t.host,t._protocol),l={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${i.size()}`,"X-Goog-Upload-Header-Content-Type":o.contentType,"Content-Type":"application/json; charset=utf-8"},u=Lu(o,n),c=t.maxUploadRetryTime,d=new Vu(h,"POST",function(t){let e;Qu(t);try{e=t.getResponseHeader("X-Goog-Upload-URL")}catch(n){qu(!1)}return qu(ru(e)),e},c);
1return d.urlParams=a,d.headers=l,d.body=u,d.errorHandler=Hu(e),d}(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),i=this._ref.storage._makeRequest(n,hc,t,e);this._request=i,i.getPromise().then(t=>{this._request=void 0,this._uploadUrl=t,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){const t=this._uploadUrl;this._resolveToken((e,n)=>{const i=function(t,e,n,i){const s=t.maxUploadRetryTime,r=new Vu(n,"POST",function(t){const e=Qu(t,["active","final"]);let n=null;try{n=t.getResponseHeader("X-Goog-Upload-Size-Received")}catch(r){qu(!1)}n||qu(!1);const s=Number(n);return qu(!isNaN(s)),new Ku(s,i.size(),"final"===e)},s);return r.headers={"X-Goog-Upload-Command":"query"},r.errorHandler=Hu(e),r}(this._ref.storage,this._ref._location,t,this._blob),s=this._ref.storage._makeRequest(i,hc,e,n);this._request=s,s.getPromise().then(t=>{this._request=void 0,this._updateProgress(t.current),this._needToFetchStatus=!1,t.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){const t=Xu*this._chunkMultiplier,e=new Ku(this._transferred,this._blob.size()),n=this._uploadUrl;this._resolveToken((i,s)=>{let r;try{r=Yu(this._ref._location,this._ref.storage,n,this._blob,t,this._mappings,e,this._makeProgressCallback())}catch(a){return this._error=a,void this._transition("error")}const o=this._ref.storage._makeRequest(r,hc,i,s,!1);this._request=o,o.getPromise().then(t=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(t.current),t.finalized?(this._metadata=t.metadata,this._transition("success")):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){Xu*this._chunkMultiplier*2<33554432&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((t,e)=>{const n=function(t,e,n){const i=lu(e.fullServerUrl(),t.host,t._protocol),s=t.maxOperationRetryTime,r=new Vu(i,"GET",ju(t,n),s);return r.errorHandler=Wu(e),r}(this._ref.storage,this._ref._location,this._mappings),i=this._ref.storage._makeRequest(n,hc,t,e);this._request=i,i.getPromise().then(t=>{this._request=void 0,this._metadata=t,this._transition("success")},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((t,e)=>{const n=Gu(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),i=this._ref.storage._makeRequest(n,hc,t,e);this._request=i,i.getPromise().then(t=>{this._request=void 0,this._metadata=t,this._updateProgress(this._blob.size()),this._transition("success")},this._errorHandler)})}_updateProgress(t){const e=this._transferred;this._transferred=t,this._transferred!==e&&this._notifyObservers()}_transition(t){if(this._state!==t)switch(t){case"canceling":case"pausing":this._state=t,void 0!==this._request?this._request.cancel():this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_());break;case"running":const e="paused"===this._state;this._state=t,e&&(this._notifyObservers(),this._start());break;case"paused":case"error":case"success":this._state=t,this._notifyObservers();break;case"canceled":this._error=Xl(),this._state=t,this._notifyObservers()}}completeTransitions_(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start()}}get snapshot(){const t=ic(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:t,metadata:this._metadata,task:this,ref:this._ref}}on(t,e,n,i){const s=new sc(e||void 0,n||void 0,i||void 0);return this._addObserver(s),()=>{this._removeObserver(s)}}then(t,e){return this._promise.then(t,e)}catch(t){return this.then(null,t)}_addObserver(t){this._observers.push(t),this._notifyObserver(t)}_removeObserver(t){const e=this._observers.indexOf(t);-1!==e&&this._observers.splice(e,1)}_notifyObservers(){this._finishPromise(),this._observers.slice().forEach(t=>{this._notifyObserver(t)})}_finishPromise(){if(void 0!==this._resolve){let t=!0;switch(ic(this._state)){case tc:rc(this._resolve.bind(null,this.snapshot))();break;case ec:case nc:rc(this._reject.bind(null,this._error))();break;default:t=!1}t&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(t){switch(ic(this._state)){case Ju:case Zu:t.next&&rc(t.next.bind(t,this.snapshot))();break;case tc:t.complete&&rc(t.complete.bind(t))();break;default:t.error&&rc(t.error.bind(t,this._error))()}}resume(){const t="paused"===this._state||"pausing"===this._state;return t&&this._transition("running"),t}
1pause(){const t="running"===this._state;return t&&this._transition("pausing"),t}cancel(){const t="running"===this._state||"pausing"===this._state;return t&&this._transition("canceling"),t}},uc=class t{constructor(t,e){this._service=t,this._location=e instanceof iu?e:iu.makeFromUrl(e,t.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,n){return new t(e,n)}get root(){const t=new iu(this._location.bucket,"");return this._newRef(this._service,t)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return Ru(this._location.path)}get storage(){return this._service}get parent(){const e=function(t){if(0===t.length)return null;const e=t.lastIndexOf("/");return-1===e?"":t.slice(0,e)}(this._location.path);if(null===e)return null;const n=new iu(this._location.bucket,e);return new t(this._service,n)}_throwIfRoot(t){if(""===this._location.path)throw function(t){return new zl(Wl.INVALID_ROOT_OPERATION,"The operation '"+t+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}(t)}};function cc(t){const e={prefixes:[],items:[]};return dc(t,e).then(()=>e)}async function dc(t,e,n){const i=await function(t,e){null!=e&&"number"==typeof e.maxResults&&hu("options.maxResults",1,1e3,e.maxResults);const n=e||{},i=$u(t.storage,t._location,"/",n.pageToken,n.maxResults);return t.storage.makeRequestWithTokens(i,hc)}(t,{pageToken:n});e.prefixes.push(...i.prefixes),e.items.push(...i.items),null!=i.nextPageToken&&await dc(t,e,i.nextPageToken)}function fc(t){t._throwIfRoot("getDownloadURL");const e=function(t,e,n){const i=lu(e.fullServerUrl(),t.host,t._protocol),s=t.maxOperationRetryTime,r=new Vu(i,"GET",Bu(t,n),s);return r.errorHandler=Wu(e),r}(t.storage,t._location,Du());return t.storage.makeRequestWithTokens(e,hc).then(t=>{if(null===t)throw new zl(Wl.NO_DOWNLOAD_URL,"The given file does not have any download URLs.");return t})}function pc(t,e){if(t instanceof _c){const n=t;if(null==n._bucket)throw new zl(Wl.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the 'storageBucket' property when initializing the app?");const i=new uc(n,n._bucket);return null!=e?pc(i,e):i}return void 0!==e?function(t,e){const n=function(t,e){const n=e.split("/").filter(t=>t.length>0).join("/");return 0===t.length?n:t+"/"+n}(t._location.path,e),i=new iu(t._location.bucket,n);return new uc(t.storage,i)}(t,e):t}function gc(t,e){if(e&&/^[A-Za-z]+:\/\//.test(e)){if(t instanceof _c)return new uc(t,e);throw Jl("To use ref(service, url), the first argument must be a Storage instance.")}return pc(t,e)}function mc(t,e){const n=null==e?void 0:e.storageBucket;return null==n?null:iu.makeFromBucketSpec(n,t)}var _c=class{constructor(t,e,n,i,s,r=!1){this.app=t,this._authProvider=e,this._appCheckProvider=n,this._url=i,this._firebaseVersion=s,this._isUsingEmulator=r,this._bucket=null,this._host=$l,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=i?iu.makeFromBucketSpec(i,this._host):mc(this._host,this.app.options)}get host(){return this._host}set host(t){this._host=t,null!=this._url?this._bucket=iu.makeFromBucketSpec(this._url,t):this._bucket=mc(t,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(t){hu("time",0,Number.POSITIVE_INFINITY,t),this._maxUploadRetryTime=t}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(t){hu("time",0,Number.POSITIVE_INFINITY,t),this._maxOperationRetryTime=t}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const t=this._authProvider.getImmediate({optional:!0});if(t){const e=await t.getToken();if(null!==e)return e.accessToken}return null}async _getAppCheckToken(){if(P(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const t=this._appCheckProvider.getImmediate({optional:!0});return t?(await t.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEac
1h(t=>t.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(t){return new uc(this,t)}_makeRequest(t,e,n,i,s=!0){if(this._deleted)return new su(Zl());{const r=function(t,e,n,i,s,r,o=!0,a=!1){const h=uu(t.urlParams),l=t.url+h,u=Object.assign({},t.headers);return function(t,e){e&&(t["X-Firebase-GMPID"]=e)}(u,e),function(t,e){null!==e&&e.length>0&&(t.Authorization="Firebase "+e)}(u,n),function(t,e){t["X-Firebase-Storage-Version"]="webjs/"+(null!=e?e:"AppManager")}(u,r),function(t,e){null!==e&&(t["X-Firebase-AppCheck"]=e)}(u,i),new du(l,t.method,u,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,s,o,a)}(t,this._appId,n,i,e,this._firebaseVersion,s,this._isUsingEmulator);return this._requests.add(r),r.getPromise().then(()=>this._requests.delete(r),()=>this._requests.delete(r)),r}}async makeRequestWithTokens(t,e){const[n,i]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(t,e,n,i).getPromise()}},yc="@firebase/storage",vc="0.13.14",wc="storage";function Tc(t,e,n){return function(t,e,n){t._throwIfRoot("uploadBytes");const i=Gu(t.storage,t._location,Du(),new Su(e,!0),n);return t.storage.makeRequestWithTokens(i,hc).then(e=>({metadata:e,ref:t}))}(t=f(t),e,n)}function Ec(t,e,n){return function(t,e,n){return t._throwIfRoot("uploadBytesResumable"),new lc(t,new Su(e),n)}(t=f(t),e,n)}function Cc(t){return cc(t=f(t))}function bc(t){return fc(t=f(t))}function Ic(t,e){return gc(t=f(t),e)}function Sc(t=A(),e){t=f(t);const n=N(t,wc).getImmediate({identifier:e}),i=x("storage");return i&&function(t,e,n,i={}){!function(t,e,n,i={}){t.host=`${e}:${n}`;const s=a(e);s&&(h(`https://${t.host}/b`),I("Storage",!0)),t._isUsingEmulator=!0,t._protocol=s?"https":"http";const{mockUserToken:r}=i;r&&(t._overrideAuthToken="string"==typeof r?r:g(r,t.app.options.projectId))}(t,e,n,i)}(n,...i),n}function kc(t,{instanceIdentifier:e}){const n=t.getProvider("app").getImmediate(),i=t.getProvider("auth-internal"),s=t.getProvider("app-check-internal");return new _c(n,i,s,e,R)}O(new M(wc,kc,"PUBLIC").setMultipleInstances(!0)),S(yc,vc,""),S(yc,vc,"esm2017"),t();var Rc=new WeakMap;function Nc(t,e){return Rc.has(e)||Rc.set(e,t||{f:{},r:{},s:{},u:{}}),Rc.get(e)}var Ac=Symbol("VueFireAuth");function xc({dependencies:t,initialUser:n}){return(i,s)=>{const[r,o]=function(t,n,i,s,r=k(t,s)){const o=B(t,n).run(()=>e(i));return H.set(t,o),n.provide(Ac,r),[o,r]}(i,s,n,t);j(r,o)}}function Dc(t){return Sc(W(t))}function Oc(t,{firebaseApp:e,modules:n=[]}){t.provide($,e);for(const i of n)i(e,t)}export{Nc as a,Ic as c,or as d,Zt as f,Dc as i,Tc as l,xc as n,bc as o,Ac as r,Cc as s,Oc as t,Ec as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.