@retter/sdk 0.7.1-development → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/index.js +2 -0
- package/bundle/index.js.LICENSE.txt +133 -0
- package/dist/Auth.d.ts +95 -0
- package/dist/Auth.js +311 -0
- package/dist/Auth.js.map +1 -0
- package/dist/Request.d.ts +13 -0
- package/dist/Request.js +120 -0
- package/dist/Request.js.map +1 -0
- package/dist/helpers.d.ts +4 -0
- package/dist/helpers.js +33 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +704 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +170 -0
- package/dist/types.js +32 -0
- package/dist/types.js.map +1 -0
- package/package.json +1 -1
package/bundle/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Retter=e():t.Retter=e()}(self,(()=>(()=>{var t={4444:(t,e,n)=>{"use strict";n.d(e,{BH:()=>a,G6:()=>g,L:()=>s,LL:()=>w,Mn:()=>m,Sg:()=>u,ZR:()=>b,b$:()=>d,d:()=>f,eu:()=>v,hl:()=>y,m9:()=>D,ne:()=>N,pd:()=>x,ru:()=>l,tV:()=>o,uI:()=>h,vZ:()=>T,w1:()=>p,xO:()=>S,xb:()=>_,z$:()=>c,zd:()=>A});const r=function(t){const e=[];let n=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=63&i|128):55296==(64512&i)&&r+1<t.length&&56320==(64512&t.charCodeAt(r+1))?(i=65536+((1023&i)<<10)+(1023&t.charCodeAt(++r)),e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=63&i|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=63&i|128)}return e},i={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let e=0;e<t.length;e+=3){const i=t[e],s=e+1<t.length,o=s?t[e+1]:0,a=e+2<t.length,u=a?t[e+2]:0,c=i>>2,h=(3&i)<<4|o>>4;let l=(15&o)<<2|u>>6,d=63&u;a||(d=64,s||(l=64)),r.push(n[c],n[h],n[l],n[d])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(r(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n++];if(i<128)e[r++]=String.fromCharCode(i);else if(i>191&&i<224){const s=t[n++];e[r++]=String.fromCharCode((31&i)<<6|63&s)}else if(i>239&&i<365){const s=((7&i)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536;e[r++]=String.fromCharCode(55296+(s>>10)),e[r++]=String.fromCharCode(56320+(1023&s))}else{const s=t[n++],o=t[n++];e[r++]=String.fromCharCode((15&i)<<12|(63&s)<<6|63&o)}}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let e=0;e<t.length;){const i=n[t.charAt(e++)],s=e<t.length?n[t.charAt(e)]:0;++e;const o=e<t.length?n[t.charAt(e)]:64;++e;const a=e<t.length?n[t.charAt(e)]:64;if(++e,null==i||null==s||null==o||null==a)throw Error();const u=i<<2|s>>4;if(r.push(u),64!==o){const t=s<<4&240|o>>2;if(r.push(t),64!==a){const t=o<<6&192|a;r.push(t)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},s=function(t){return function(t){const e=r(t);return i.encodeByteArray(e,!0)}(t).replace(/\./g,"")},o=function(t){try{return i.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};class a{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}wrapCallback(t){return(e,n)=>{e?this.reject(e):this.resolve(n),"function"==typeof t&&(this.promise.catch((()=>{})),1===t.length?t(e):t(e,n))}}}function u(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=e||"demo-project",r=t.iat||0,i=t.sub||t.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:r,exp:r+3600,auth_time:r,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},t);return[s(JSON.stringify({alg:"none",type:"JWT"})),s(JSON.stringify(o)),""].join(".")}function c(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function h(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(c())}function l(){const t="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof t&&void 0!==t.id}function d(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function f(){return c().indexOf("Electron/")>=0}function p(){const t=c();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function m(){return c().indexOf("MSAppHost/")>=0}function g(){return!function(){try{return"[object process]"===Object.prototype.toString.call(n.g.process)}catch(t){return!1}}()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function y(){return"object"==typeof indexedDB}function v(){return new Promise(((t,e)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),t(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{var t;e((null===(t=i.error)||void 0===t?void 0:t.message)||"")}}catch(t){e(t)}}))}class b extends Error{constructor(t,e,n){super(e),this.code=t,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,b.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,w.prototype.create)}}class w{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(t,...e){const n=e[0]||{},r=`${this.service}/${t}`,i=this.errors[t],s=i?function(t,e){return t.replace(I,((t,n)=>{const r=e[n];return null!=r?String(r):`<${n}?>`}))}(i,n):"Error",o=`${this.serviceName}: ${s} (${r}).`;return new b(r,o,n)}}const I=/\{\$([^}]+)}/g;function _(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function T(t,e){if(t===e)return!0;const n=Object.keys(t),r=Object.keys(e);for(const i of n){if(!r.includes(i))return!1;const n=t[i],s=e[i];if(E(n)&&E(s)){if(!T(n,s))return!1}else if(n!==s)return!1}for(const t of r)if(!n.includes(t))return!1;return!0}function E(t){return null!==t&&"object"==typeof t}function S(t){const e=[];for(const[n,r]of Object.entries(t))Array.isArray(r)?r.forEach((t=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(t))})):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function A(t){const e={};return t.replace(/^\?/,"").split("&").forEach((t=>{if(t){const[n,r]=t.split("=");e[decodeURIComponent(n)]=decodeURIComponent(r)}})),e}function x(t){const e=t.indexOf("?");if(!e)return"";const n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}function N(t,e){const n=new k(t,e);return n.subscribe.bind(n)}class k{constructor(t,e){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then((()=>{t(this)})).catch((t=>{this.error(t)}))}next(t){this.forEachObserver((e=>{e.next(t)}))}error(t){this.forEachObserver((e=>{e.error(t)})),this.close(t)}complete(){this.forEachObserver((t=>{t.complete()})),this.close()}subscribe(t,e,n){let r;if(void 0===t&&void 0===e&&void 0===n)throw new Error("Missing Observer.");r=function(t,e){if("object"!=typeof t||null===t)return!1;for(const e of["next","error","complete"])if(e in t&&"function"==typeof t[e])return!0;return!1}(t)?t:{next:t,error:e,complete:n},void 0===r.next&&(r.next=C),void 0===r.error&&(r.error=C),void 0===r.complete&&(r.complete=C);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then((()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch(t){}})),this.observers.push(r),i}unsubscribeOne(t){void 0!==this.observers&&void 0!==this.observers[t]&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}sendOne(t,e){this.task.then((()=>{if(void 0!==this.observers&&void 0!==this.observers[t])try{e(this.observers[t])}catch(t){"undefined"!=typeof console&&console.error&&console.error(t)}}))}close(t){this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then((()=>{this.observers=void 0,this.onNoObservers=void 0})))}}function C(){}function D(t){return t&&t._delegate?t._delegate:t}},9669:(t,e,n)=>{t.exports=n(1609)},5448:(t,e,n)=>{"use strict";var r=n(4867),i=n(6026),s=n(4372),o=n(5327),a=n(4097),u=n(4109),c=n(7985),h=n(5061),l=n(5655),d=n(5263);t.exports=function(t){return new Promise((function(e,n){var f,p=t.data,m=t.headers,g=t.responseType;function y(){t.cancelToken&&t.cancelToken.unsubscribe(f),t.signal&&t.signal.removeEventListener("abort",f)}r.isFormData(p)&&delete m["Content-Type"];var v=new XMLHttpRequest;if(t.auth){var b=t.auth.username||"",w=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";m.Authorization="Basic "+btoa(b+":"+w)}var I=a(t.baseURL,t.url);function _(){if(v){var r="getAllResponseHeaders"in v?u(v.getAllResponseHeaders()):null,s={data:g&&"text"!==g&&"json"!==g?v.response:v.responseText,status:v.status,statusText:v.statusText,headers:r,config:t,request:v};i((function(t){e(t),y()}),(function(t){n(t),y()}),s),v=null}}if(v.open(t.method.toUpperCase(),o(I,t.params,t.paramsSerializer),!0),v.timeout=t.timeout,"onloadend"in v?v.onloadend=_:v.onreadystatechange=function(){v&&4===v.readyState&&(0!==v.status||v.responseURL&&0===v.responseURL.indexOf("file:"))&&setTimeout(_)},v.onabort=function(){v&&(n(h("Request aborted",t,"ECONNABORTED",v)),v=null)},v.onerror=function(){n(h("Network Error",t,null,v)),v=null},v.ontimeout=function(){var e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",r=t.transitional||l.transitional;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),n(h(e,t,r.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",v)),v=null},r.isStandardBrowserEnv()){var T=(t.withCredentials||c(I))&&t.xsrfCookieName?s.read(t.xsrfCookieName):void 0;T&&(m[t.xsrfHeaderName]=T)}"setRequestHeader"in v&&r.forEach(m,(function(t,e){void 0===p&&"content-type"===e.toLowerCase()?delete m[e]:v.setRequestHeader(e,t)})),r.isUndefined(t.withCredentials)||(v.withCredentials=!!t.withCredentials),g&&"json"!==g&&(v.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&v.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&v.upload&&v.upload.addEventListener("progress",t.onUploadProgress),(t.cancelToken||t.signal)&&(f=function(t){v&&(n(!t||t&&t.type?new d("canceled"):t),v.abort(),v=null)},t.cancelToken&&t.cancelToken.subscribe(f),t.signal&&(t.signal.aborted?f():t.signal.addEventListener("abort",f))),p||(p=null),v.send(p)}))}},1609:(t,e,n)=>{"use strict";var r=n(4867),i=n(1849),s=n(321),o=n(7185),a=function t(e){var n=new s(e),a=i(s.prototype.request,n);return r.extend(a,s.prototype,n),r.extend(a,n),a.create=function(n){return t(o(e,n))},a}(n(5655));a.Axios=s,a.Cancel=n(5263),a.CancelToken=n(4972),a.isCancel=n(6502),a.VERSION=n(7288).version,a.all=function(t){return Promise.all(t)},a.spread=n(8713),a.isAxiosError=n(6268),t.exports=a,t.exports.default=a},5263:t=>{"use strict";function e(t){this.message=t}e.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},e.prototype.__CANCEL__=!0,t.exports=e},4972:(t,e,n)=>{"use strict";var r=n(5263);function i(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var n=this;this.promise.then((function(t){if(n._listeners){var e,r=n._listeners.length;for(e=0;e<r;e++)n._listeners[e](t);n._listeners=null}})),this.promise.then=function(t){var e,r=new Promise((function(t){n.subscribe(t),e=t})).then(t);return r.cancel=function(){n.unsubscribe(e)},r},t((function(t){n.reason||(n.reason=new r(t),e(n.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},i.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},i.source=function(){var t;return{token:new i((function(e){t=e})),cancel:t}},t.exports=i},6502:t=>{"use strict";t.exports=function(t){return!(!t||!t.__CANCEL__)}},321:(t,e,n)=>{"use strict";var r=n(4867),i=n(5327),s=n(782),o=n(3572),a=n(7185),u=n(4875),c=u.validators;function h(t){this.defaults=t,this.interceptors={request:new s,response:new s}}h.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=a(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=t.transitional;void 0!==e&&u.assertOptions(e,{silentJSONParsing:c.transitional(c.boolean),forcedJSONParsing:c.transitional(c.boolean),clarifyTimeoutError:c.transitional(c.boolean)},!1);var n=[],r=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(r=r&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(t){s.push(t.fulfilled,t.rejected)})),!r){var h=[o,void 0];for(Array.prototype.unshift.apply(h,n),h=h.concat(s),i=Promise.resolve(t);h.length;)i=i.then(h.shift(),h.shift());return i}for(var l=t;n.length;){var d=n.shift(),f=n.shift();try{l=d(l)}catch(t){f(t);break}}try{i=o(l)}catch(t){return Promise.reject(t)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},h.prototype.getUri=function(t){return t=a(this.defaults,t),i(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function(t){h.prototype[t]=function(e,n){return this.request(a(n||{},{method:t,url:e,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(t){h.prototype[t]=function(e,n,r){return this.request(a(r||{},{method:t,url:e,data:n}))}})),t.exports=h},782:(t,e,n)=>{"use strict";var r=n(4867);function i(){this.handlers=[]}i.prototype.use=function(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},i.prototype.forEach=function(t){r.forEach(this.handlers,(function(e){null!==e&&t(e)}))},t.exports=i},4097:(t,e,n)=>{"use strict";var r=n(1793),i=n(7303);t.exports=function(t,e){return t&&!r(e)?i(t,e):e}},5061:(t,e,n)=>{"use strict";var r=n(481);t.exports=function(t,e,n,i,s){var o=new Error(t);return r(o,e,n,i,s)}},3572:(t,e,n)=>{"use strict";var r=n(4867),i=n(8527),s=n(6502),o=n(5655),a=n(5263);function u(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new a("canceled")}t.exports=function(t){return u(t),t.headers=t.headers||{},t.data=i.call(t,t.data,t.headers,t.transformRequest),t.headers=r.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||o.adapter)(t).then((function(e){return u(t),e.data=i.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return s(e)||(u(t),e&&e.response&&(e.response.data=i.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))}},481:t=>{"use strict";t.exports=function(t,e,n,r,i){return t.config=e,n&&(t.code=n),t.request=r,t.response=i,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t}},7185:(t,e,n)=>{"use strict";var r=n(4867);t.exports=function(t,e){e=e||{};var n={};function i(t,e){return r.isPlainObject(t)&&r.isPlainObject(e)?r.merge(t,e):r.isPlainObject(e)?r.merge({},e):r.isArray(e)?e.slice():e}function s(n){return r.isUndefined(e[n])?r.isUndefined(t[n])?void 0:i(void 0,t[n]):i(t[n],e[n])}function o(t){if(!r.isUndefined(e[t]))return i(void 0,e[t])}function a(n){return r.isUndefined(e[n])?r.isUndefined(t[n])?void 0:i(void 0,t[n]):i(void 0,e[n])}function u(n){return n in e?i(t[n],e[n]):n in t?i(void 0,t[n]):void 0}var c={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:u};return r.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=c[t]||s,i=e(t);r.isUndefined(i)&&e!==u||(n[t]=i)})),n}},6026:(t,e,n)=>{"use strict";var r=n(5061);t.exports=function(t,e,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?e(r("Request failed with status code "+n.status,n.config,null,n.request,n)):t(n)}},8527:(t,e,n)=>{"use strict";var r=n(4867),i=n(5655);t.exports=function(t,e,n){var s=this||i;return r.forEach(n,(function(n){t=n.call(s,t,e)})),t}},5655:(t,e,n)=>{"use strict";var r=n(4867),i=n(6016),s=n(481),o={"Content-Type":"application/x-www-form-urlencoded"};function a(t,e){!r.isUndefined(t)&&r.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var u,c={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(u=n(5448)),u),transformRequest:[function(t,e){return i(e,"Accept"),i(e,"Content-Type"),r.isFormData(t)||r.isArrayBuffer(t)||r.isBuffer(t)||r.isStream(t)||r.isFile(t)||r.isBlob(t)?t:r.isArrayBufferView(t)?t.buffer:r.isURLSearchParams(t)?(a(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):r.isObject(t)||e&&"application/json"===e["Content-Type"]?(a(e,"application/json"),function(t,e,n){if(r.isString(t))try{return(0,JSON.parse)(t),r.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(0,JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||c.transitional,n=e&&e.silentJSONParsing,i=e&&e.forcedJSONParsing,o=!n&&"json"===this.responseType;if(o||i&&r.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(o){if("SyntaxError"===t.name)throw s(t,this,"E_JSON_PARSE");throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(t){c.headers[t]={}})),r.forEach(["post","put","patch"],(function(t){c.headers[t]=r.merge(o)})),t.exports=c},7288:t=>{t.exports={version:"0.24.0"}},1849:t=>{"use strict";t.exports=function(t,e){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return t.apply(e,n)}}},5327:(t,e,n)=>{"use strict";var r=n(4867);function i(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}t.exports=function(t,e,n){if(!e)return t;var s;if(n)s=n(e);else if(r.isURLSearchParams(e))s=e.toString();else{var o=[];r.forEach(e,(function(t,e){null!=t&&(r.isArray(t)?e+="[]":t=[t],r.forEach(t,(function(t){r.isDate(t)?t=t.toISOString():r.isObject(t)&&(t=JSON.stringify(t)),o.push(i(e)+"="+i(t))})))})),s=o.join("&")}if(s){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t}},7303:t=>{"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},4372:(t,e,n)=>{"use strict";var r=n(4867);t.exports=r.isStandardBrowserEnv()?{write:function(t,e,n,i,s,o){var a=[];a.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(s)&&a.push("domain="+s),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},1793:t=>{"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},6268:t=>{"use strict";t.exports=function(t){return"object"==typeof t&&!0===t.isAxiosError}},7985:(t,e,n)=>{"use strict";var r=n(4867);t.exports=r.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(t){var r=t;return e&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=i(window.location.href),function(e){var n=r.isString(e)?i(e):e;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0}},6016:(t,e,n)=>{"use strict";var r=n(4867);t.exports=function(t,e){r.forEach(t,(function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])}))}},4109:(t,e,n)=>{"use strict";var r=n(4867),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,n,s,o={};return t?(r.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=r.trim(t.substr(0,s)).toLowerCase(),n=r.trim(t.substr(s+1)),e){if(o[e]&&i.indexOf(e)>=0)return;o[e]="set-cookie"===e?(o[e]?o[e]:[]).concat([n]):o[e]?o[e]+", "+n:n}})),o):o}},8713:t=>{"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},4875:(t,e,n)=>{"use strict";var r=n(7288).version,i={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){i[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}}));var s={};i.transitional=function(t,e,n){function i(t,e){return"[Axios v"+r+"] Transitional option '"+t+"'"+e+(n?". "+n:"")}return function(n,r,o){if(!1===t)throw new Error(i(r," has been removed"+(e?" in "+e:"")));return e&&!s[r]&&(s[r]=!0,console.warn(i(r," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(n,r,o)}},t.exports={assertOptions:function(t,e,n){if("object"!=typeof t)throw new TypeError("options must be an object");for(var r=Object.keys(t),i=r.length;i-- >0;){var s=r[i],o=e[s];if(o){var a=t[s],u=void 0===a||o(a,s,t);if(!0!==u)throw new TypeError("option "+s+" must be "+u)}else if(!0!==n)throw Error("Unknown option "+s)}},validators:i}},4867:(t,e,n)=>{"use strict";var r=n(1849),i=Object.prototype.toString;function s(t){return"[object Array]"===i.call(t)}function o(t){return void 0===t}function a(t){return null!==t&&"object"==typeof t}function u(t){if("[object Object]"!==i.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function c(t){return"[object Function]"===i.call(t)}function h(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),s(t))for(var n=0,r=t.length;n<r;n++)e.call(null,t[n],n,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}t.exports={isArray:s,isArrayBuffer:function(t){return"[object ArrayBuffer]"===i.call(t)},isBuffer:function(t){return null!==t&&!o(t)&&null!==t.constructor&&!o(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:a,isPlainObject:u,isUndefined:o,isDate:function(t){return"[object Date]"===i.call(t)},isFile:function(t){return"[object File]"===i.call(t)},isBlob:function(t){return"[object Blob]"===i.call(t)},isFunction:c,isStream:function(t){return a(t)&&c(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:h,merge:function t(){var e={};function n(n,r){u(e[r])&&u(n)?e[r]=t(e[r],n):u(n)?e[r]=t({},n):s(n)?e[r]=n.slice():e[r]=n}for(var r=0,i=arguments.length;r<i;r++)h(arguments[r],n);return e},extend:function(t,e,n){return h(e,(function(e,i){t[i]=n&&"function"==typeof e?r(e,n):e})),t},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}}},5503:(t,e,n)=>{"use strict";n.r(e),n.d(e,{FirebaseError:()=>r.ZR,SDK_VERSION:()=>r.Jn,_DEFAULT_ENTRY_NAME:()=>r.l4,_addComponent:()=>r.H9,_addOrOverwriteComponent:()=>r.Vr,_apps:()=>r.Af,_clearComponents:()=>r.Z8,_components:()=>r.lz,_getProvider:()=>r.qX,_registerComponent:()=>r.Xd,_removeServiceInstance:()=>r.wN,deleteApp:()=>r.P2,getApp:()=>r.Mq,getApps:()=>r.C6,initializeApp:()=>r.ZF,onLog:()=>r.TP,registerVersion:()=>r.KN,setLogLevel:()=>r.Ub});var r=n(389);(0,r.KN)("firebase","9.8.2","app")},6757:(t,e,n)=>{"use strict";n.r(e),n.d(e,{ActionCodeOperation:()=>d,ActionCodeURL:()=>Lt,AuthCredential:()=>At,AuthErrorCodes:()=>g,EmailAuthCredential:()=>Ct,EmailAuthProvider:()=>Vt,FacebookAuthProvider:()=>Bt,FactorId:()=>u,GithubAuthProvider:()=>zt,GoogleAuthProvider:()=>qt,OAuthCredential:()=>Ot,OAuthProvider:()=>jt,OperationType:()=>l,PhoneAuthCredential:()=>Pt,PhoneAuthProvider:()=>Mn,PhoneMultiFactorGenerator:()=>Ar,ProviderId:()=>c,RecaptchaVerifier:()=>kn,SAMLAuthProvider:()=>Gt,SignInMethod:()=>h,TwitterAuthProvider:()=>Wt,applyActionCode:()=>pe,beforeAuthStateChanged:()=>Fe,browserLocalPersistence:()=>Xe,browserPopupRedirectResolver:()=>Er,browserSessionPersistence:()=>en,checkActionCode:()=>me,confirmPasswordReset:()=>fe,connectAuthEmulator:()=>Tt,createUserWithEmailAndPassword:()=>ye,debugErrorMap:()=>f,deleteUser:()=>ze,fetchSignInMethodsForEmail:()=>_e,getAdditionalUserInfo:()=>Le,getAuth:()=>Dr,getIdToken:()=>W,getIdTokenResult:()=>$,getMultiFactorResolver:()=>We,getRedirectResult:()=>rr,inMemoryPersistence:()=>st,indexedDBLocalPersistence:()=>yn,initializeAuth:()=>k,isSignInWithEmailLink:()=>we,linkWithCredential:()=>oe,linkWithPhoneNumber:()=>On,linkWithPopup:()=>Wn,linkWithRedirect:()=>nr,multiFactor:()=>Ye,onAuthStateChanged:()=>Ue,onIdTokenChanged:()=>Ve,parseActionCodeURL:()=>Mt,prodErrorMap:()=>p,reauthenticateWithCredential:()=>ae,reauthenticateWithPhoneNumber:()=>Rn,reauthenticateWithPopup:()=>Gn,reauthenticateWithRedirect:()=>er,reload:()=>tt,sendEmailVerification:()=>Te,sendPasswordResetEmail:()=>de,sendSignInLinkToEmail:()=>be,setPersistence:()=>Me,signInAnonymously:()=>Qt,signInWithCredential:()=>se,signInWithCustomToken:()=>ue,signInWithEmailAndPassword:()=>ve,signInWithEmailLink:()=>Ie,signInWithPhoneNumber:()=>Dn,signInWithPopup:()=>Kn,signInWithRedirect:()=>tr,signOut:()=>qe,unlink:()=>te,updateCurrentUser:()=>Be,updateEmail:()=>Ae,updatePassword:()=>xe,updatePhoneNumber:()=>Ln,updateProfile:()=>Se,useDeviceLanguage:()=>je,verifyBeforeUpdateEmail:()=>Ee,verifyPasswordResetCode:()=>ge});var r=n(4444),i=n(389);function s(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}Object.create,Object.create;var o=n(3333),a=n(8463);const u={PHONE:"phone"},c={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},h={EMAIL_LINK:"emailLink",EMAIL_PASSWORD:"password",FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PHONE:"phone",TWITTER:"twitter.com"},l={LINK:"link",REAUTHENTICATE:"reauthenticate",SIGN_IN:"signIn"},d={EMAIL_SIGNIN:"EMAIL_SIGNIN",PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",REVERT_SECOND_FACTOR_ADDITION:"REVERT_SECOND_FACTOR_ADDITION",VERIFY_AND_CHANGE_EMAIL:"VERIFY_AND_CHANGE_EMAIL",VERIFY_EMAIL:"VERIFY_EMAIL"};const f=function(){return{"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-change-needs-verification":"Multi-factor users must always have a verified email.","email-already-in-use":"The email address is already in use by another account.","emulator-config-failed":'Auth instance has already been used to make a network call. Auth can no longer be configured to use the emulator. Try calling "connectAuthEmulator()" sooner.',"expired-action-code":"The action code has expired.","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal AuthError has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registed for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal AuthError has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure to use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-emulator-scheme":"Emulator URL must start with a valid scheme (http:// or https://).","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-multi-factor-session":"The request does not contain a valid proof of first factor successful sign-in.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","login-blocked":"Login blocked by user-provided method: {$originalMessage}","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal AuthError has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-multi-factor-info":"No second factor identifier is provided.","missing-multi-factor-session":"The request is missing proof of first factor successful sign-in.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","multi-factor-info-not-found":"The user does not have a second factor matching the identifier provided.","multi-factor-auth-required":"Proof of ownership of a second factor is required to complete sign-in.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal AuthError has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","second-factor-already-in-use":"The second factor is already enrolled on this account.","maximum-second-factor-count-exceeded":"The maximum allowed number of second factors on a user has been exceeded.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.","unsupported-first-factor":"Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","unverified-email":"The operation requires a verified email.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled.","already-initialized":"initializeAuth() has already been called with different options. To avoid this error, call initializeAuth() with the same options as when it was originally called, or call getAuth() to return the already initialized instance."}},p=function(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}},m=new r.LL("auth","Firebase",{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}),g={ADMIN_ONLY_OPERATION:"auth/admin-restricted-operation",ARGUMENT_ERROR:"auth/argument-error",APP_NOT_AUTHORIZED:"auth/app-not-authorized",APP_NOT_INSTALLED:"auth/app-not-installed",CAPTCHA_CHECK_FAILED:"auth/captcha-check-failed",CODE_EXPIRED:"auth/code-expired",CORDOVA_NOT_READY:"auth/cordova-not-ready",CORS_UNSUPPORTED:"auth/cors-unsupported",CREDENTIAL_ALREADY_IN_USE:"auth/credential-already-in-use",CREDENTIAL_MISMATCH:"auth/custom-token-mismatch",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"auth/requires-recent-login",DEPENDENT_SDK_INIT_BEFORE_AUTH:"auth/dependent-sdk-initialized-before-auth",DYNAMIC_LINK_NOT_ACTIVATED:"auth/dynamic-link-not-activated",EMAIL_CHANGE_NEEDS_VERIFICATION:"auth/email-change-needs-verification",EMAIL_EXISTS:"auth/email-already-in-use",EMULATOR_CONFIG_FAILED:"auth/emulator-config-failed",EXPIRED_OOB_CODE:"auth/expired-action-code",EXPIRED_POPUP_REQUEST:"auth/cancelled-popup-request",INTERNAL_ERROR:"auth/internal-error",INVALID_API_KEY:"auth/invalid-api-key",INVALID_APP_CREDENTIAL:"auth/invalid-app-credential",INVALID_APP_ID:"auth/invalid-app-id",INVALID_AUTH:"auth/invalid-user-token",INVALID_AUTH_EVENT:"auth/invalid-auth-event",INVALID_CERT_HASH:"auth/invalid-cert-hash",INVALID_CODE:"auth/invalid-verification-code",INVALID_CONTINUE_URI:"auth/invalid-continue-uri",INVALID_CORDOVA_CONFIGURATION:"auth/invalid-cordova-configuration",INVALID_CUSTOM_TOKEN:"auth/invalid-custom-token",INVALID_DYNAMIC_LINK_DOMAIN:"auth/invalid-dynamic-link-domain",INVALID_EMAIL:"auth/invalid-email",INVALID_EMULATOR_SCHEME:"auth/invalid-emulator-scheme",INVALID_IDP_RESPONSE:"auth/invalid-credential",INVALID_MESSAGE_PAYLOAD:"auth/invalid-message-payload",INVALID_MFA_SESSION:"auth/invalid-multi-factor-session",INVALID_OAUTH_CLIENT_ID:"auth/invalid-oauth-client-id",INVALID_OAUTH_PROVIDER:"auth/invalid-oauth-provider",INVALID_OOB_CODE:"auth/invalid-action-code",INVALID_ORIGIN:"auth/unauthorized-domain",INVALID_PASSWORD:"auth/wrong-password",INVALID_PERSISTENCE:"auth/invalid-persistence-type",INVALID_PHONE_NUMBER:"auth/invalid-phone-number",INVALID_PROVIDER_ID:"auth/invalid-provider-id",INVALID_RECIPIENT_EMAIL:"auth/invalid-recipient-email",INVALID_SENDER:"auth/invalid-sender",INVALID_SESSION_INFO:"auth/invalid-verification-id",INVALID_TENANT_ID:"auth/invalid-tenant-id",MFA_INFO_NOT_FOUND:"auth/multi-factor-info-not-found",MFA_REQUIRED:"auth/multi-factor-auth-required",MISSING_ANDROID_PACKAGE_NAME:"auth/missing-android-pkg-name",MISSING_APP_CREDENTIAL:"auth/missing-app-credential",MISSING_AUTH_DOMAIN:"auth/auth-domain-config-required",MISSING_CODE:"auth/missing-verification-code",MISSING_CONTINUE_URI:"auth/missing-continue-uri",MISSING_IFRAME_START:"auth/missing-iframe-start",MISSING_IOS_BUNDLE_ID:"auth/missing-ios-bundle-id",MISSING_OR_INVALID_NONCE:"auth/missing-or-invalid-nonce",MISSING_MFA_INFO:"auth/missing-multi-factor-info",MISSING_MFA_SESSION:"auth/missing-multi-factor-session",MISSING_PHONE_NUMBER:"auth/missing-phone-number",MISSING_SESSION_INFO:"auth/missing-verification-id",MODULE_DESTROYED:"auth/app-deleted",NEED_CONFIRMATION:"auth/account-exists-with-different-credential",NETWORK_REQUEST_FAILED:"auth/network-request-failed",NULL_USER:"auth/null-user",NO_AUTH_EVENT:"auth/no-auth-event",NO_SUCH_PROVIDER:"auth/no-such-provider",OPERATION_NOT_ALLOWED:"auth/operation-not-allowed",OPERATION_NOT_SUPPORTED:"auth/operation-not-supported-in-this-environment",POPUP_BLOCKED:"auth/popup-blocked",POPUP_CLOSED_BY_USER:"auth/popup-closed-by-user",PROVIDER_ALREADY_LINKED:"auth/provider-already-linked",QUOTA_EXCEEDED:"auth/quota-exceeded",REDIRECT_CANCELLED_BY_USER:"auth/redirect-cancelled-by-user",REDIRECT_OPERATION_PENDING:"auth/redirect-operation-pending",REJECTED_CREDENTIAL:"auth/rejected-credential",SECOND_FACTOR_ALREADY_ENROLLED:"auth/second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"auth/maximum-second-factor-count-exceeded",TENANT_ID_MISMATCH:"auth/tenant-id-mismatch",TIMEOUT:"auth/timeout",TOKEN_EXPIRED:"auth/user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"auth/too-many-requests",UNAUTHORIZED_DOMAIN:"auth/unauthorized-continue-uri",UNSUPPORTED_FIRST_FACTOR:"auth/unsupported-first-factor",UNSUPPORTED_PERSISTENCE:"auth/unsupported-persistence-type",UNSUPPORTED_TENANT_OPERATION:"auth/unsupported-tenant-operation",UNVERIFIED_EMAIL:"auth/unverified-email",USER_CANCELLED:"auth/user-cancelled",USER_DELETED:"auth/user-not-found",USER_DISABLED:"auth/user-disabled",USER_MISMATCH:"auth/user-mismatch",USER_SIGNED_OUT:"auth/user-signed-out",WEAK_PASSWORD:"auth/weak-password",WEB_STORAGE_UNSUPPORTED:"auth/web-storage-unsupported",ALREADY_INITIALIZED:"auth/already-initialized"},y=new o.Yd("@firebase/auth");function v(t,...e){y.logLevel<=o.in.ERROR&&y.error(`Auth (${i.Jn}): ${t}`,...e)}function b(t,...e){throw T(t,...e)}function w(t,...e){return T(t,...e)}function I(t,e,n){const i=Object.assign(Object.assign({},p()),{[e]:n});return new r.LL("auth","Firebase",i).create(e,{appName:t.name})}function _(t,e,n){if(!(e instanceof n))throw n.name!==e.constructor.name&&b(t,"argument-error"),I(t,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function T(t,...e){if("string"!=typeof t){const n=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=t.name),t._errorFactory.create(n,...r)}return m.create(t,...e)}function E(t,e,...n){if(!t)throw T(e,...n)}function S(t){const e="INTERNAL ASSERTION FAILED: "+t;throw v(e),new Error(e)}function A(t,e){t||S(e)}const x=new Map;function N(t){A(t instanceof Function,"Expected a class definition");let e=x.get(t);return e?(A(e instanceof t,"Instance stored in cache mismatched with class"),e):(e=new t,x.set(t,e),e)}function k(t,e){const n=(0,i.qX)(t,"auth");if(n.isInitialized()){const t=n.getImmediate(),i=n.getOptions();if((0,r.vZ)(i,null!=e?e:{}))return t;b(t,"already-initialized")}return n.initialize({options:e})}function C(){var t;return"undefined"!=typeof self&&(null===(t=self.location)||void 0===t?void 0:t.href)||""}function D(){return"http:"===O()||"https:"===O()}function O(){var t;return"undefined"!=typeof self&&(null===(t=self.location)||void 0===t?void 0:t.protocol)||null}class R{constructor(t,e){this.shortDelay=t,this.longDelay=e,A(e>t,"Short delay should be less than long delay!"),this.isMobile=(0,r.uI)()||(0,r.b$)()}get(){return"undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(D()||(0,r.ru)()||"connection"in navigator)&&!navigator.onLine?Math.min(5e3,this.shortDelay):this.isMobile?this.longDelay:this.shortDelay}}function P(t,e){A(t.emulator,"Emulator should always be set here");const{url:n}=t.emulator;return e?`${n}${e.startsWith("/")?e.slice(1):e}`:n}class L{static initialize(t,e,n){this.fetchImpl=t,e&&(this.headersImpl=e),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:void S("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){return this.headersImpl?this.headersImpl:"undefined"!=typeof self&&"Headers"in self?self.Headers:void S("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){return this.responseImpl?this.responseImpl:"undefined"!=typeof self&&"Response"in self?self.Response:void S("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const M={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error"},V=new R(3e4,6e4);function F(t,e){return t.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:t.tenantId}):e}async function U(t,e,n,i,s={}){return j(t,s,(async()=>{let s={},o={};i&&("GET"===e?o=i:s={body:JSON.stringify(i)});const a=(0,r.xO)(Object.assign({key:t.config.apiKey},o)).slice(1),u=await t._getAdditionalHeaders();return u["Content-Type"]="application/json",t.languageCode&&(u["X-Firebase-Locale"]=t.languageCode),L.fetch()(q(t,t.config.apiHost,n,a),Object.assign({method:e,headers:u,referrerPolicy:"no-referrer"},s))}))}async function j(t,e,n){t._canInitEmulator=!1;const i=Object.assign(Object.assign({},M),e);try{const e=new z(t),r=await Promise.race([n(),e.promise]);e.clearNetworkTimeout();const s=await r.json();if("needConfirmation"in s)throw K(t,"account-exists-with-different-credential",s);if(r.ok&&!("errorMessage"in s))return s;{const e=r.ok?s.errorMessage:s.error.message,[n,o]=e.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw K(t,"credential-already-in-use",s);if("EMAIL_EXISTS"===n)throw K(t,"email-already-in-use",s);if("USER_DISABLED"===n)throw K(t,"user-disabled",s);const a=i[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw I(t,a,o);b(t,a)}}catch(e){if(e instanceof r.ZR)throw e;b(t,"network-request-failed")}}async function B(t,e,n,r,i={}){const s=await U(t,e,n,r,i);return"mfaPendingCredential"in s&&b(t,"multi-factor-auth-required",{_serverResponse:s}),s}function q(t,e,n,r){const i=`${e}${n}?${r}`;return t.config.emulator?P(t.config,i):`${t.config.apiScheme}://${i}`}class z{constructor(t){this.auth=t,this.timer=null,this.promise=new Promise(((t,e)=>{this.timer=setTimeout((()=>e(w(this.auth,"network-request-failed"))),V.get())}))}clearNetworkTimeout(){clearTimeout(this.timer)}}function K(t,e,n){const r={appName:t.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=w(t,e,r);return i.customData._tokenResponse=n,i}function G(t){if(t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))return e.toUTCString()}catch(t){}}function W(t,e=!1){return(0,r.m9)(t).getIdToken(e)}async function $(t,e=!1){const n=(0,r.m9)(t),i=await n.getIdToken(e),s=Y(i);E(s&&s.exp&&s.auth_time&&s.iat,n.auth,"internal-error");const o="object"==typeof s.firebase?s.firebase:void 0,a=null==o?void 0:o.sign_in_provider;return{claims:s,token:i,authTime:G(H(s.auth_time)),issuedAtTime:G(H(s.iat)),expirationTime:G(H(s.exp)),signInProvider:a||null,signInSecondFactor:(null==o?void 0:o.sign_in_second_factor)||null}}function H(t){return 1e3*Number(t)}function Y(t){const[e,n,i]=t.split(".");if(void 0===e||void 0===n||void 0===i)return v("JWT malformed, contained fewer than 3 sections"),null;try{const t=(0,r.tV)(n);return t?JSON.parse(t):(v("Failed to decode base64 JWT payload"),null)}catch(t){return v("Caught error parsing JWT payload as JSON",t),null}}async function Q(t,e,n=!1){if(n)return e;try{return await e}catch(e){throw e instanceof r.ZR&&function({code:t}){return"auth/user-disabled"===t||"auth/user-token-expired"===t}(e)&&t.auth.currentUser===t&&await t.auth.signOut(),e}}class Z{constructor(t){this.user=t,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,null!==this.timerId&&clearTimeout(this.timerId))}getInterval(t){var e;if(t){const t=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),t}{this.errorBackoff=3e4;const t=(null!==(e=this.user.stsTokenManager.expirationTime)&&void 0!==e?e:0)-Date.now()-3e5;return Math.max(0,t)}}schedule(t=!1){if(!this.isRunning)return;const e=this.getInterval(t);this.timerId=setTimeout((async()=>{await this.iteration()}),e)}async iteration(){try{await this.user.getIdToken(!0)}catch(t){return void("auth/network-request-failed"===t.code&&this.schedule(!0))}this.schedule()}}class J{constructor(t,e){this.createdAt=t,this.lastLoginAt=e,this._initializeTime()}_initializeTime(){this.lastSignInTime=G(this.lastLoginAt),this.creationTime=G(this.createdAt)}_copy(t){this.createdAt=t.createdAt,this.lastLoginAt=t.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function X(t){var e;const n=t.auth,r=await t.getIdToken(),i=await Q(t,async function(t,e){return U(t,"POST","/v1/accounts:lookup",e)}(n,{idToken:r}));E(null==i?void 0:i.users.length,n,"internal-error");const o=i.users[0];t._notifyReloadListener(o);const a=(null===(e=o.providerUserInfo)||void 0===e?void 0:e.length)?o.providerUserInfo.map((t=>{var{providerId:e}=t,n=s(t,["providerId"]);return{providerId:e,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}})):[],u=(c=t.providerData,h=a,[...c.filter((t=>!h.some((e=>e.providerId===t.providerId)))),...h]);var c,h;const l=t.isAnonymous,d=!(t.email&&o.passwordHash||(null==u?void 0:u.length)),f=!!l&&d,p={uid:o.localId,displayName:o.displayName||null,photoURL:o.photoUrl||null,email:o.email||null,emailVerified:o.emailVerified||!1,phoneNumber:o.phoneNumber||null,tenantId:o.tenantId||null,providerData:u,metadata:new J(o.createdAt,o.lastLoginAt),isAnonymous:f};Object.assign(t,p)}async function tt(t){const e=(0,r.m9)(t);await X(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}class et{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(t){E(t.idToken,"internal-error"),E(void 0!==t.idToken,"internal-error"),E(void 0!==t.refreshToken,"internal-error");const e="expiresIn"in t&&void 0!==t.expiresIn?Number(t.expiresIn):function(t){const e=Y(t);return E(e,"internal-error"),E(void 0!==e.exp,"internal-error"),E(void 0!==e.iat,"internal-error"),Number(e.exp)-Number(e.iat)}(t.idToken);this.updateTokensAndExpiration(t.idToken,t.refreshToken,e)}async getToken(t,e=!1){return E(!this.accessToken||this.refreshToken,t,"user-token-expired"),e||!this.accessToken||this.isExpired?this.refreshToken?(await this.refresh(t,this.refreshToken),this.accessToken):null:this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(t,e){const{accessToken:n,refreshToken:i,expiresIn:s}=await async function(t,e){const n=await j(t,{},(async()=>{const n=(0,r.xO)({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:i,apiKey:s}=t.config,o=q(t,i,"/v1/token",`key=${s}`),a=await t._getAdditionalHeaders();return a["Content-Type"]="application/x-www-form-urlencoded",L.fetch()(o,{method:"POST",headers:a,body:n})}));return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}(t,e);this.updateTokensAndExpiration(n,i,Number(s))}updateTokensAndExpiration(t,e,n){this.refreshToken=e||null,this.accessToken=t||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(t,e){const{refreshToken:n,accessToken:r,expirationTime:i}=e,s=new et;return n&&(E("string"==typeof n,"internal-error",{appName:t}),s.refreshToken=n),r&&(E("string"==typeof r,"internal-error",{appName:t}),s.accessToken=r),i&&(E("number"==typeof i,"internal-error",{appName:t}),s.expirationTime=i),s}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(t){this.accessToken=t.accessToken,this.refreshToken=t.refreshToken,this.expirationTime=t.expirationTime}_clone(){return Object.assign(new et,this.toJSON())}_performRefresh(){return S("not implemented")}}function nt(t,e){E("string"==typeof t||void 0===t,"internal-error",{appName:e})}class rt{constructor(t){var{uid:e,auth:n,stsTokenManager:r}=t,i=s(t,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new Z(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?[...i.providerData]:[],this.metadata=new J(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(t){const e=await Q(this,this.stsTokenManager.getToken(this.auth,t));return E(e,this.auth,"internal-error"),this.accessToken!==e&&(this.accessToken=e,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),e}getIdTokenResult(t){return $(this,t)}reload(){return tt(this)}_assign(t){this!==t&&(E(this.uid===t.uid,this.auth,"internal-error"),this.displayName=t.displayName,this.photoURL=t.photoURL,this.email=t.email,this.emailVerified=t.emailVerified,this.phoneNumber=t.phoneNumber,this.isAnonymous=t.isAnonymous,this.tenantId=t.tenantId,this.providerData=t.providerData.map((t=>Object.assign({},t))),this.metadata._copy(t.metadata),this.stsTokenManager._assign(t.stsTokenManager))}_clone(t){return new rt(Object.assign(Object.assign({},this),{auth:t,stsTokenManager:this.stsTokenManager._clone()}))}_onReload(t){E(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=t,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(t){this.reloadListener?this.reloadListener(t):this.reloadUserInfo=t}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(t,e=!1){let n=!1;t.idToken&&t.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(t),n=!0),e&&await X(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){const t=await this.getIdToken();return await Q(this,async function(t,e){return U(t,"POST","/v1/accounts:delete",e)}(this.auth,{idToken:t})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map((t=>Object.assign({},t))),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(t,e){var n,r,i,s,o,a,u,c;const h=null!==(n=e.displayName)&&void 0!==n?n:void 0,l=null!==(r=e.email)&&void 0!==r?r:void 0,d=null!==(i=e.phoneNumber)&&void 0!==i?i:void 0,f=null!==(s=e.photoURL)&&void 0!==s?s:void 0,p=null!==(o=e.tenantId)&&void 0!==o?o:void 0,m=null!==(a=e._redirectEventId)&&void 0!==a?a:void 0,g=null!==(u=e.createdAt)&&void 0!==u?u:void 0,y=null!==(c=e.lastLoginAt)&&void 0!==c?c:void 0,{uid:v,emailVerified:b,isAnonymous:w,providerData:I,stsTokenManager:_}=e;E(v&&_,t,"internal-error");const T=et.fromJSON(this.name,_);E("string"==typeof v,t,"internal-error"),nt(h,t.name),nt(l,t.name),E("boolean"==typeof b,t,"internal-error"),E("boolean"==typeof w,t,"internal-error"),nt(d,t.name),nt(f,t.name),nt(p,t.name),nt(m,t.name),nt(g,t.name),nt(y,t.name);const S=new rt({uid:v,auth:t,email:l,emailVerified:b,displayName:h,isAnonymous:w,photoURL:f,phoneNumber:d,tenantId:p,stsTokenManager:T,createdAt:g,lastLoginAt:y});return I&&Array.isArray(I)&&(S.providerData=I.map((t=>Object.assign({},t)))),m&&(S._redirectEventId=m),S}static async _fromIdTokenResponse(t,e,n=!1){const r=new et;r.updateFromServerResponse(e);const i=new rt({uid:e.localId,auth:t,stsTokenManager:r,isAnonymous:n});return await X(i),i}}class it{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(t,e){this.storage[t]=e}async _get(t){const e=this.storage[t];return void 0===e?null:e}async _remove(t){delete this.storage[t]}_addListener(t,e){}_removeListener(t,e){}}it.type="NONE";const st=it;function ot(t,e,n){return`firebase:${t}:${e}:${n}`}class at{constructor(t,e,n){this.persistence=t,this.auth=e,this.userKey=n;const{config:r,name:i}=this.auth;this.fullUserKey=ot(this.userKey,r.apiKey,i),this.fullPersistenceKey=ot("persistence",r.apiKey,i),this.boundEventHandler=e._onStorageEvent.bind(e),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(t){return this.persistence._set(this.fullUserKey,t.toJSON())}async getCurrentUser(){const t=await this.persistence._get(this.fullUserKey);return t?rt._fromJSON(this.auth,t):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(t){if(this.persistence===t)return;const e=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=t,e?this.setCurrentUser(e):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(t,e,n="authUser"){if(!e.length)return new at(N(st),t,n);const r=(await Promise.all(e.map((async t=>{if(await t._isAvailable())return t})))).filter((t=>t));let i=r[0]||N(st);const s=ot(n,t.config.apiKey,t.name);let o=null;for(const n of e)try{const e=await n._get(s);if(e){const r=rt._fromJSON(t,e);n!==i&&(o=r),i=n;break}}catch(t){}const a=r.filter((t=>t._shouldAllowMigration));return i._shouldAllowMigration&&a.length?(i=a[0],o&&await i._set(s,o.toJSON()),await Promise.all(e.map((async t=>{if(t!==i)try{await t._remove(s)}catch(t){}}))),new at(i,t,n)):new at(i,t,n)}}function ut(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(dt(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(ct(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(pt(e))return"Blackberry";if(mt(e))return"Webos";if(ht(e))return"Safari";if((e.includes("chrome/")||lt(e))&&!e.includes("edge/"))return"Chrome";if(ft(e))return"Android";{const e=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=t.match(e);if(2===(null==n?void 0:n.length))return n[1]}return"Other"}function ct(t=(0,r.z$)()){return/firefox\//i.test(t)}function ht(t=(0,r.z$)()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function lt(t=(0,r.z$)()){return/crios\//i.test(t)}function dt(t=(0,r.z$)()){return/iemobile/i.test(t)}function ft(t=(0,r.z$)()){return/android/i.test(t)}function pt(t=(0,r.z$)()){return/blackberry/i.test(t)}function mt(t=(0,r.z$)()){return/webos/i.test(t)}function gt(t=(0,r.z$)()){return/iphone|ipad|ipod/i.test(t)}function yt(t=(0,r.z$)()){return gt(t)||ft(t)||mt(t)||pt(t)||/windows phone/i.test(t)||dt(t)}function vt(t,e=[]){let n;switch(t){case"Browser":n=ut((0,r.z$)());break;case"Worker":n=`${ut((0,r.z$)())}-${t}`;break;default:n=t}const s=e.length?e.join(","):"FirebaseCore-web";return`${n}/JsCore/${i.Jn}/${s}`}class bt{constructor(t){this.auth=t,this.queue=[]}pushCallback(t,e){const n=e=>new Promise(((n,r)=>{try{n(t(e))}catch(t){r(t)}}));n.onAbort=e,this.queue.push(n);const r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(t){if(this.auth.currentUser===t)return;const e=[];try{for(const n of this.queue)await n(t),n.onAbort&&e.push(n.onAbort)}catch(t){e.reverse();for(const t of e)try{t()}catch(t){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:t.message})}}}class wt{constructor(t,e,n){this.app=t,this.heartbeatServiceProvider=e,this.config=n,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new _t(this),this.idTokenSubscription=new _t(this),this.beforeStateQueue=new bt(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=m,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=t.name,this.clientVersion=n.sdkClientVersion}_initializeWithPersistence(t,e){return e&&(this._popupRedirectResolver=N(e)),this._initializationPromise=this.queue((async()=>{var n,r;if(!this._deleted&&(this.persistenceManager=await at.create(this,t),!this._deleted)){if(null===(n=this._popupRedirectResolver)||void 0===n?void 0:n._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(t){}await this.initializeCurrentUser(e),this.lastNotifiedUid=(null===(r=this.currentUser)||void 0===r?void 0:r.uid)||null,this._deleted||(this._isInitialized=!0)}})),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const t=await this.assertedPersistence.getCurrentUser();return this.currentUser||t?this.currentUser&&t&&this.currentUser.uid===t.uid?(this._currentUser._assign(t),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(t,!0):void 0}async initializeCurrentUser(t){var e;const n=await this.assertedPersistence.getCurrentUser();let r=n,i=!1;if(t&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const n=null===(e=this.redirectUser)||void 0===e?void 0:e._redirectEventId,s=null==r?void 0:r._redirectEventId,o=await this.tryRedirectSignIn(t);n&&n!==s||!(null==o?void 0:o.user)||(r=o.user,i=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(r)}catch(t){r=n,this._popupRedirectResolver._overrideRedirectResult(this,(()=>Promise.reject(t)))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return E(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(t){let e=null;try{e=await this._popupRedirectResolver._completeRedirectFn(this,t,!0)}catch(t){await this._setRedirectUser(null)}return e}async reloadAndSetCurrentUserOrClear(t){try{await X(t)}catch(t){if("auth/network-request-failed"!==t.code)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(t)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(t){const e=t?(0,r.m9)(t):null;return e&&E(e.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(e&&e._clone(this))}async _updateCurrentUser(t,e=!1){if(!this._deleted)return t&&E(this.tenantId===t.tenantId,this,"tenant-id-mismatch"),e||await this.beforeStateQueue.runMiddleware(t),this.queue((async()=>{await this.directlySetCurrentUser(t),this.notifyAuthListeners()}))}async signOut(){return await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0)}setPersistence(t){return this.queue((async()=>{await this.assertedPersistence.setPersistence(N(t))}))}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(t){this._errorFactory=new r.LL("auth","Firebase",t())}onAuthStateChanged(t,e,n){return this.registerStateListener(this.authStateSubscription,t,e,n)}beforeAuthStateChanged(t,e){return this.beforeStateQueue.pushCallback(t,e)}onIdTokenChanged(t,e,n){return this.registerStateListener(this.idTokenSubscription,t,e,n)}toJSON(){var t;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null===(t=this._currentUser)||void 0===t?void 0:t.toJSON()}}async _setRedirectUser(t,e){const n=await this.getOrInitRedirectPersistenceManager(e);return null===t?n.removeCurrentUser():n.setCurrentUser(t)}async getOrInitRedirectPersistenceManager(t){if(!this.redirectPersistenceManager){const e=t&&N(t)||this._popupRedirectResolver;E(e,this,"argument-error"),this.redirectPersistenceManager=await at.create(this,[N(e._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(t){var e,n;return this._isInitialized&&await this.queue((async()=>{})),(null===(e=this._currentUser)||void 0===e?void 0:e._redirectEventId)===t?this._currentUser:(null===(n=this.redirectUser)||void 0===n?void 0:n._redirectEventId)===t?this.redirectUser:null}async _persistUserIfCurrent(t){if(t===this.currentUser)return this.queue((async()=>this.directlySetCurrentUser(t)))}_notifyListenersIfCurrent(t){t===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var t,e;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const n=null!==(e=null===(t=this.currentUser)||void 0===t?void 0:t.uid)&&void 0!==e?e:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(t,e,n,r){if(this._deleted)return()=>{};const i="function"==typeof e?e:e.next.bind(e),s=this._isInitialized?Promise.resolve():this._initializationPromise;return E(s,this,"internal-error"),s.then((()=>i(this.currentUser))),"function"==typeof e?t.addObserver(e,n,r):t.addObserver(e)}async directlySetCurrentUser(t){this.currentUser&&this.currentUser!==t&&(this._currentUser._stopProactiveRefresh(),t&&this.isProactiveRefreshEnabled&&t._startProactiveRefresh()),this.currentUser=t,t?await this.assertedPersistence.setCurrentUser(t):await this.assertedPersistence.removeCurrentUser()}queue(t){return this.operations=this.operations.then(t,t),this.operations}get assertedPersistence(){return E(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(t){t&&!this.frameworks.includes(t)&&(this.frameworks.push(t),this.frameworks.sort(),this.clientVersion=vt(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var t;const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const n=await(null===(t=this.heartbeatServiceProvider.getImmediate({optional:!0}))||void 0===t?void 0:t.getHeartbeatsHeader());return n&&(e["X-Firebase-Client"]=n),e}}function It(t){return(0,r.m9)(t)}class _t{constructor(t){this.auth=t,this.observer=null,this.addObserver=(0,r.ne)((t=>this.observer=t))}get next(){return E(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}function Tt(t,e,n){const r=It(t);E(r._canInitEmulator,r,"emulator-config-failed"),E(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const i=!!(null==n?void 0:n.disableWarnings),s=Et(e),{host:o,port:a}=function(t){const e=Et(t),n=/(\/\/)?([^?#/]+)/.exec(t.substr(e.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){const t=i[1];return{host:t,port:St(r.substr(t.length+1))}}{const[t,e]=r.split(":");return{host:t,port:St(e)}}}(e),u=null===a?"":`:${a}`;r.config.emulator={url:`${s}//${o}${u}/`},r.settings.appVerificationDisabledForTesting=!0,r.emulatorConfig=Object.freeze({host:o,port:a,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:i})}),i||function(){function t(){const t=document.createElement("p"),e=t.style;t.innerText="Running in emulator mode. Do not use with production credentials.",e.position="fixed",e.width="100%",e.backgroundColor="#ffffff",e.border=".1em solid #000000",e.color="#b50000",e.bottom="0px",e.left="0px",e.margin="0px",e.zIndex="10000",e.textAlign="center",t.classList.add("firebase-emulator-warning"),document.body.appendChild(t)}"undefined"!=typeof console&&"function"==typeof console.info&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),"undefined"!=typeof window&&"undefined"!=typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",t):t())}()}function Et(t){const e=t.indexOf(":");return e<0?"":t.substr(0,e+1)}function St(t){if(!t)return null;const e=Number(t);return isNaN(e)?null:e}class At{constructor(t,e){this.providerId=t,this.signInMethod=e}toJSON(){return S("not implemented")}_getIdTokenResponse(t){return S("not implemented")}_linkToIdToken(t,e){return S("not implemented")}_getReauthenticationResolver(t){return S("not implemented")}}async function xt(t,e){return U(t,"POST","/v1/accounts:resetPassword",F(t,e))}async function Nt(t,e){return U(t,"POST","/v1/accounts:update",e)}async function kt(t,e){return U(t,"POST","/v1/accounts:sendOobCode",F(t,e))}class Ct extends At{constructor(t,e,n,r=null){super("password",n),this._email=t,this._password=e,this._tenantId=r}static _fromEmailAndPassword(t,e){return new Ct(t,e,"password")}static _fromEmailAndCode(t,e,n=null){return new Ct(t,e,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(t){const e="string"==typeof t?JSON.parse(t):t;if((null==e?void 0:e.email)&&(null==e?void 0:e.password)){if("password"===e.signInMethod)return this._fromEmailAndPassword(e.email,e.password);if("emailLink"===e.signInMethod)return this._fromEmailAndCode(e.email,e.password,e.tenantId)}return null}async _getIdTokenResponse(t){switch(this.signInMethod){case"password":return async function(t,e){return B(t,"POST","/v1/accounts:signInWithPassword",F(t,e))}(t,{returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(t,e){return B(t,"POST","/v1/accounts:signInWithEmailLink",F(t,e))}(t,{email:this._email,oobCode:this._password});default:b(t,"internal-error")}}async _linkToIdToken(t,e){switch(this.signInMethod){case"password":return Nt(t,{idToken:e,returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return async function(t,e){return B(t,"POST","/v1/accounts:signInWithEmailLink",F(t,e))}(t,{idToken:e,email:this._email,oobCode:this._password});default:b(t,"internal-error")}}_getReauthenticationResolver(t){return this._getIdTokenResponse(t)}}async function Dt(t,e){return B(t,"POST","/v1/accounts:signInWithIdp",F(t,e))}class Ot extends At{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(t){const e=new Ot(t.providerId,t.signInMethod);return t.idToken||t.accessToken?(t.idToken&&(e.idToken=t.idToken),t.accessToken&&(e.accessToken=t.accessToken),t.nonce&&!t.pendingToken&&(e.nonce=t.nonce),t.pendingToken&&(e.pendingToken=t.pendingToken)):t.oauthToken&&t.oauthTokenSecret?(e.accessToken=t.oauthToken,e.secret=t.oauthTokenSecret):b("argument-error"),e}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(t){const e="string"==typeof t?JSON.parse(t):t,{providerId:n,signInMethod:r}=e,i=s(e,["providerId","signInMethod"]);if(!n||!r)return null;const o=new Ot(n,r);return o.idToken=i.idToken||void 0,o.accessToken=i.accessToken||void 0,o.secret=i.secret,o.nonce=i.nonce,o.pendingToken=i.pendingToken||null,o}_getIdTokenResponse(t){return Dt(t,this.buildRequest())}_linkToIdToken(t,e){const n=this.buildRequest();return n.idToken=e,Dt(t,n)}_getReauthenticationResolver(t){const e=this.buildRequest();return e.autoCreate=!1,Dt(t,e)}buildRequest(){const t={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)t.pendingToken=this.pendingToken;else{const e={};this.idToken&&(e.id_token=this.idToken),this.accessToken&&(e.access_token=this.accessToken),this.secret&&(e.oauth_token_secret=this.secret),e.providerId=this.providerId,this.nonce&&!this.pendingToken&&(e.nonce=this.nonce),t.postBody=(0,r.xO)(e)}return t}}const Rt={USER_NOT_FOUND:"user-not-found"};class Pt extends At{constructor(t){super("phone","phone"),this.params=t}static _fromVerification(t,e){return new Pt({verificationId:t,verificationCode:e})}static _fromTokenResponse(t,e){return new Pt({phoneNumber:t,temporaryProof:e})}_getIdTokenResponse(t){return async function(t,e){return B(t,"POST","/v1/accounts:signInWithPhoneNumber",F(t,e))}(t,this._makeVerificationRequest())}_linkToIdToken(t,e){return async function(t,e){const n=await B(t,"POST","/v1/accounts:signInWithPhoneNumber",F(t,e));if(n.temporaryProof)throw K(t,"account-exists-with-different-credential",n);return n}(t,Object.assign({idToken:e},this._makeVerificationRequest()))}_getReauthenticationResolver(t){return async function(t,e){return B(t,"POST","/v1/accounts:signInWithPhoneNumber",F(t,Object.assign(Object.assign({},e),{operation:"REAUTH"})),Rt)}(t,this._makeVerificationRequest())}_makeVerificationRequest(){const{temporaryProof:t,phoneNumber:e,verificationId:n,verificationCode:r}=this.params;return t&&e?{temporaryProof:t,phoneNumber:e}:{sessionInfo:n,code:r}}toJSON(){const t={providerId:this.providerId};return this.params.phoneNumber&&(t.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(t.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(t.verificationCode=this.params.verificationCode),this.params.verificationId&&(t.verificationId=this.params.verificationId),t}static fromJSON(t){"string"==typeof t&&(t=JSON.parse(t));const{verificationId:e,verificationCode:n,phoneNumber:r,temporaryProof:i}=t;return n||e||r||i?new Pt({verificationId:e,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class Lt{constructor(t){var e,n,i,s,o,a;const u=(0,r.zd)((0,r.pd)(t)),c=null!==(e=u.apiKey)&&void 0!==e?e:null,h=null!==(n=u.oobCode)&&void 0!==n?n:null,l=function(t){switch(t){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}(null!==(i=u.mode)&&void 0!==i?i:null);E(c&&h&&l,"argument-error"),this.apiKey=c,this.operation=l,this.code=h,this.continueUrl=null!==(s=u.continueUrl)&&void 0!==s?s:null,this.languageCode=null!==(o=u.languageCode)&&void 0!==o?o:null,this.tenantId=null!==(a=u.tenantId)&&void 0!==a?a:null}static parseLink(t){const e=function(t){const e=(0,r.zd)((0,r.pd)(t)).link,n=e?(0,r.zd)((0,r.pd)(e)).deep_link_id:null,i=(0,r.zd)((0,r.pd)(t)).deep_link_id;return(i?(0,r.zd)((0,r.pd)(i)).link:null)||i||n||e||t}(t);try{return new Lt(e)}catch(t){return null}}}function Mt(t){return Lt.parseLink(t)}class Vt{constructor(){this.providerId=Vt.PROVIDER_ID}static credential(t,e){return Ct._fromEmailAndPassword(t,e)}static credentialWithLink(t,e){const n=Lt.parseLink(e);return E(n,"argument-error"),Ct._fromEmailAndCode(t,n.code,n.tenantId)}}Vt.PROVIDER_ID="password",Vt.EMAIL_PASSWORD_SIGN_IN_METHOD="password",Vt.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class Ft{constructor(t){this.providerId=t,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(t){this.defaultLanguageCode=t}setCustomParameters(t){return this.customParameters=t,this}getCustomParameters(){return this.customParameters}}class Ut extends Ft{constructor(){super(...arguments),this.scopes=[]}addScope(t){return this.scopes.includes(t)||this.scopes.push(t),this}getScopes(){return[...this.scopes]}}class jt extends Ut{static credentialFromJSON(t){const e="string"==typeof t?JSON.parse(t):t;return E("providerId"in e&&"signInMethod"in e,"argument-error"),Ot._fromParams(e)}credential(t){return this._credential(Object.assign(Object.assign({},t),{nonce:t.rawNonce}))}_credential(t){return E(t.idToken||t.accessToken,"argument-error"),Ot._fromParams(Object.assign(Object.assign({},t),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(t){return jt.oauthCredentialFromTaggedObject(t)}static credentialFromError(t){return jt.oauthCredentialFromTaggedObject(t.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthIdToken:e,oauthAccessToken:n,oauthTokenSecret:r,pendingToken:i,nonce:s,providerId:o}=t;if(!(n||r||e||i))return null;if(!o)return null;try{return new jt(o)._credential({idToken:e,accessToken:n,nonce:s,pendingToken:i})}catch(t){return null}}}class Bt extends Ut{constructor(){super("facebook.com")}static credential(t){return Ot._fromParams({providerId:Bt.PROVIDER_ID,signInMethod:Bt.FACEBOOK_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return Bt.credentialFromTaggedObject(t)}static credentialFromError(t){return Bt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t))return null;if(!t.oauthAccessToken)return null;try{return Bt.credential(t.oauthAccessToken)}catch(t){return null}}}Bt.FACEBOOK_SIGN_IN_METHOD="facebook.com",Bt.PROVIDER_ID="facebook.com";class qt extends Ut{constructor(){super("google.com"),this.addScope("profile")}static credential(t,e){return Ot._fromParams({providerId:qt.PROVIDER_ID,signInMethod:qt.GOOGLE_SIGN_IN_METHOD,idToken:t,accessToken:e})}static credentialFromResult(t){return qt.credentialFromTaggedObject(t)}static credentialFromError(t){return qt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthIdToken:e,oauthAccessToken:n}=t;if(!e&&!n)return null;try{return qt.credential(e,n)}catch(t){return null}}}qt.GOOGLE_SIGN_IN_METHOD="google.com",qt.PROVIDER_ID="google.com";class zt extends Ut{constructor(){super("github.com")}static credential(t){return Ot._fromParams({providerId:zt.PROVIDER_ID,signInMethod:zt.GITHUB_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return zt.credentialFromTaggedObject(t)}static credentialFromError(t){return zt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!("oauthAccessToken"in t))return null;if(!t.oauthAccessToken)return null;try{return zt.credential(t.oauthAccessToken)}catch(t){return null}}}zt.GITHUB_SIGN_IN_METHOD="github.com",zt.PROVIDER_ID="github.com";class Kt extends At{constructor(t,e){super(t,t),this.pendingToken=e}_getIdTokenResponse(t){return Dt(t,this.buildRequest())}_linkToIdToken(t,e){const n=this.buildRequest();return n.idToken=e,Dt(t,n)}_getReauthenticationResolver(t){const e=this.buildRequest();return e.autoCreate=!1,Dt(t,e)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(t){const e="string"==typeof t?JSON.parse(t):t,{providerId:n,signInMethod:r,pendingToken:i}=e;return n&&r&&i&&n===r?new Kt(n,i):null}static _create(t,e){return new Kt(t,e)}buildRequest(){return{requestUri:"http://localhost",returnSecureToken:!0,pendingToken:this.pendingToken}}}class Gt extends Ft{constructor(t){E(t.startsWith("saml."),"argument-error"),super(t)}static credentialFromResult(t){return Gt.samlCredentialFromTaggedObject(t)}static credentialFromError(t){return Gt.samlCredentialFromTaggedObject(t.customData||{})}static credentialFromJSON(t){const e=Kt.fromJSON(t);return E(e,"argument-error"),e}static samlCredentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{pendingToken:e,providerId:n}=t;if(!e||!n)return null;try{return Kt._create(n,e)}catch(t){return null}}}class Wt extends Ut{constructor(){super("twitter.com")}static credential(t,e){return Ot._fromParams({providerId:Wt.PROVIDER_ID,signInMethod:Wt.TWITTER_SIGN_IN_METHOD,oauthToken:t,oauthTokenSecret:e})}static credentialFromResult(t){return Wt.credentialFromTaggedObject(t)}static credentialFromError(t){return Wt.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{oauthAccessToken:e,oauthTokenSecret:n}=t;if(!e||!n)return null;try{return Wt.credential(e,n)}catch(t){return null}}}async function $t(t,e){return B(t,"POST","/v1/accounts:signUp",F(t,e))}Wt.TWITTER_SIGN_IN_METHOD="twitter.com",Wt.PROVIDER_ID="twitter.com";class Ht{constructor(t){this.user=t.user,this.providerId=t.providerId,this._tokenResponse=t._tokenResponse,this.operationType=t.operationType}static async _fromIdTokenResponse(t,e,n,r=!1){const i=await rt._fromIdTokenResponse(t,n,r),s=Yt(n);return new Ht({user:i,providerId:s,_tokenResponse:n,operationType:e})}static async _forOperation(t,e,n){await t._updateTokensIfNecessary(n,!0);const r=Yt(n);return new Ht({user:t,providerId:r,_tokenResponse:n,operationType:e})}}function Yt(t){return t.providerId?t.providerId:"phoneNumber"in t?"phone":null}async function Qt(t){var e;const n=It(t);if(await n._initializationPromise,null===(e=n.currentUser)||void 0===e?void 0:e.isAnonymous)return new Ht({user:n.currentUser,providerId:null,operationType:"signIn"});const r=await $t(n,{returnSecureToken:!0}),i=await Ht._fromIdTokenResponse(n,"signIn",r,!0);return await n._updateCurrentUser(i.user),i}class Zt extends r.ZR{constructor(t,e,n,r){var i;super(e.code,e.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,Zt.prototype),this.customData={appName:t.name,tenantId:null!==(i=t.tenantId)&&void 0!==i?i:void 0,_serverResponse:e.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(t,e,n,r){return new Zt(t,e,n,r)}}function Jt(t,e,n,r){return("reauthenticate"===e?n._getReauthenticationResolver(t):n._getIdTokenResponse(t)).catch((n=>{if("auth/multi-factor-auth-required"===n.code)throw Zt._fromErrorAndOperation(t,n,e,r);throw n}))}function Xt(t){return new Set(t.map((({providerId:t})=>t)).filter((t=>!!t)))}async function te(t,e){const n=(0,r.m9)(t);await ne(!0,n,e);const{providerUserInfo:i}=await async function(t,e){return U(t,"POST","/v1/accounts:update",e)}(n.auth,{idToken:await n.getIdToken(),deleteProvider:[e]}),s=Xt(i||[]);return n.providerData=n.providerData.filter((t=>s.has(t.providerId))),s.has("phone")||(n.phoneNumber=null),await n.auth._persistUserIfCurrent(n),n}async function ee(t,e,n=!1){const r=await Q(t,e._linkToIdToken(t.auth,await t.getIdToken()),n);return Ht._forOperation(t,"link",r)}async function ne(t,e,n){await X(e);const r=!1===t?"provider-already-linked":"no-such-provider";E(Xt(e.providerData).has(n)===t,e.auth,r)}async function re(t,e,n=!1){const{auth:r}=t,i="reauthenticate";try{const s=await Q(t,Jt(r,i,e,t),n);E(s.idToken,r,"internal-error");const o=Y(s.idToken);E(o,r,"internal-error");const{sub:a}=o;return E(t.uid===a,r,"user-mismatch"),Ht._forOperation(t,i,s)}catch(t){throw"auth/user-not-found"===(null==t?void 0:t.code)&&b(r,"user-mismatch"),t}}async function ie(t,e,n=!1){const r="signIn",i=await Jt(t,r,e),s=await Ht._fromIdTokenResponse(t,r,i);return n||await t._updateCurrentUser(s.user),s}async function se(t,e){return ie(It(t),e)}async function oe(t,e){const n=(0,r.m9)(t);return await ne(!1,n,e.providerId),ee(n,e)}async function ae(t,e){return re((0,r.m9)(t),e)}async function ue(t,e){const n=It(t),r=await async function(t,e){return B(t,"POST","/v1/accounts:signInWithCustomToken",F(t,e))}(n,{token:e,returnSecureToken:!0}),i=await Ht._fromIdTokenResponse(n,"signIn",r);return await n._updateCurrentUser(i.user),i}class ce{constructor(t,e){this.factorId=t,this.uid=e.mfaEnrollmentId,this.enrollmentTime=new Date(e.enrolledAt).toUTCString(),this.displayName=e.displayName}static _fromServerResponse(t,e){return"phoneInfo"in e?he._fromServerResponse(t,e):b(t,"internal-error")}}class he extends ce{constructor(t){super("phone",t),this.phoneNumber=t.phoneInfo}static _fromServerResponse(t,e){return new he(e)}}function le(t,e,n){var r;E((null===(r=n.url)||void 0===r?void 0:r.length)>0,t,"invalid-continue-uri"),E(void 0===n.dynamicLinkDomain||n.dynamicLinkDomain.length>0,t,"invalid-dynamic-link-domain"),e.continueUrl=n.url,e.dynamicLinkDomain=n.dynamicLinkDomain,e.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(E(n.iOS.bundleId.length>0,t,"missing-ios-bundle-id"),e.iOSBundleId=n.iOS.bundleId),n.android&&(E(n.android.packageName.length>0,t,"missing-android-pkg-name"),e.androidInstallApp=n.android.installApp,e.androidMinimumVersionCode=n.android.minimumVersion,e.androidPackageName=n.android.packageName)}async function de(t,e,n){const i=(0,r.m9)(t),s={requestType:"PASSWORD_RESET",email:e};n&&le(i,s,n),await async function(t,e){return kt(t,e)}(i,s)}async function fe(t,e,n){await xt((0,r.m9)(t),{oobCode:e,newPassword:n})}async function pe(t,e){await async function(t,e){return U(t,"POST","/v1/accounts:update",F(t,e))}((0,r.m9)(t),{oobCode:e})}async function me(t,e){const n=(0,r.m9)(t),i=await xt(n,{oobCode:e}),s=i.requestType;switch(E(s,n,"internal-error"),s){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":E(i.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":E(i.mfaInfo,n,"internal-error");default:E(i.email,n,"internal-error")}let o=null;return i.mfaInfo&&(o=ce._fromServerResponse(It(n),i.mfaInfo)),{data:{email:("VERIFY_AND_CHANGE_EMAIL"===i.requestType?i.newEmail:i.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===i.requestType?i.email:i.newEmail)||null,multiFactorInfo:o},operation:s}}async function ge(t,e){const{data:n}=await me((0,r.m9)(t),e);return n.email}async function ye(t,e,n){const r=It(t),i=await $t(r,{returnSecureToken:!0,email:e,password:n}),s=await Ht._fromIdTokenResponse(r,"signIn",i);return await r._updateCurrentUser(s.user),s}function ve(t,e,n){return se((0,r.m9)(t),Vt.credential(e,n))}async function be(t,e,n){const i=(0,r.m9)(t),s={requestType:"EMAIL_SIGNIN",email:e};E(n.handleCodeInApp,i,"argument-error"),n&&le(i,s,n),await async function(t,e){return kt(t,e)}(i,s)}function we(t,e){const n=Lt.parseLink(e);return"EMAIL_SIGNIN"===(null==n?void 0:n.operation)}async function Ie(t,e,n){const i=(0,r.m9)(t),s=Vt.credentialWithLink(e,n||C());return E(s._tenantId===(i.tenantId||null),i,"tenant-id-mismatch"),se(i,s)}async function _e(t,e){const n={identifier:e,continueUri:D()?C():"http://localhost"},{signinMethods:i}=await async function(t,e){return U(t,"POST","/v1/accounts:createAuthUri",F(t,e))}((0,r.m9)(t),n);return i||[]}async function Te(t,e){const n=(0,r.m9)(t),i={requestType:"VERIFY_EMAIL",idToken:await t.getIdToken()};e&&le(n.auth,i,e);const{email:s}=await async function(t,e){return kt(t,e)}(n.auth,i);s!==t.email&&await t.reload()}async function Ee(t,e,n){const i=(0,r.m9)(t),s={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await t.getIdToken(),newEmail:e};n&&le(i.auth,s,n);const{email:o}=await async function(t,e){return kt(t,e)}(i.auth,s);o!==t.email&&await t.reload()}async function Se(t,{displayName:e,photoURL:n}){if(void 0===e&&void 0===n)return;const i=(0,r.m9)(t),s={idToken:await i.getIdToken(),displayName:e,photoUrl:n,returnSecureToken:!0},o=await Q(i,async function(t,e){return U(t,"POST","/v1/accounts:update",e)}(i.auth,s));i.displayName=o.displayName||null,i.photoURL=o.photoUrl||null;const a=i.providerData.find((({providerId:t})=>"password"===t));a&&(a.displayName=i.displayName,a.photoURL=i.photoURL),await i._updateTokensIfNecessary(o)}function Ae(t,e){return Ne((0,r.m9)(t),e,null)}function xe(t,e){return Ne((0,r.m9)(t),null,e)}async function Ne(t,e,n){const{auth:r}=t,i={idToken:await t.getIdToken(),returnSecureToken:!0};e&&(i.email=e),n&&(i.password=n);const s=await Q(t,Nt(r,i));await t._updateTokensIfNecessary(s,!0)}class ke{constructor(t,e,n={}){this.isNewUser=t,this.providerId=e,this.profile=n}}class Ce extends ke{constructor(t,e,n,r){super(t,e,n),this.username=r}}class De extends ke{constructor(t,e){super(t,"facebook.com",e)}}class Oe extends Ce{constructor(t,e){super(t,"github.com",e,"string"==typeof(null==e?void 0:e.login)?null==e?void 0:e.login:null)}}class Re extends ke{constructor(t,e){super(t,"google.com",e)}}class Pe extends Ce{constructor(t,e,n){super(t,"twitter.com",e,n)}}function Le(t){const{user:e,_tokenResponse:n}=t;return e.isAnonymous&&!n?{providerId:null,isNewUser:!1,profile:null}:function(t){var e,n;if(!t)return null;const{providerId:r}=t,i=t.rawUserInfo?JSON.parse(t.rawUserInfo):{},s=t.isNewUser||"identitytoolkit#SignupNewUserResponse"===t.kind;if(!r&&(null==t?void 0:t.idToken)){const r=null===(n=null===(e=Y(t.idToken))||void 0===e?void 0:e.firebase)||void 0===n?void 0:n.sign_in_provider;if(r)return new ke(s,"anonymous"!==r&&"custom"!==r?r:null)}if(!r)return null;switch(r){case"facebook.com":return new De(s,i);case"github.com":return new Oe(s,i);case"google.com":return new Re(s,i);case"twitter.com":return new Pe(s,i,t.screenName||null);case"custom":case"anonymous":return new ke(s,null);default:return new ke(s,r,i)}}(n)}function Me(t,e){return(0,r.m9)(t).setPersistence(e)}function Ve(t,e,n,i){return(0,r.m9)(t).onIdTokenChanged(e,n,i)}function Fe(t,e,n){return(0,r.m9)(t).beforeAuthStateChanged(e,n)}function Ue(t,e,n,i){return(0,r.m9)(t).onAuthStateChanged(e,n,i)}function je(t){(0,r.m9)(t).useDeviceLanguage()}function Be(t,e){return(0,r.m9)(t).updateCurrentUser(e)}function qe(t){return(0,r.m9)(t).signOut()}async function ze(t){return(0,r.m9)(t).delete()}class Ke{constructor(t,e){this.type=t,this.credential=e}static _fromIdtoken(t){return new Ke("enroll",t)}static _fromMfaPendingCredential(t){return new Ke("signin",t)}toJSON(){return{multiFactorSession:{["enroll"===this.type?"idToken":"pendingCredential"]:this.credential}}}static fromJSON(t){var e,n;if(null==t?void 0:t.multiFactorSession){if(null===(e=t.multiFactorSession)||void 0===e?void 0:e.pendingCredential)return Ke._fromMfaPendingCredential(t.multiFactorSession.pendingCredential);if(null===(n=t.multiFactorSession)||void 0===n?void 0:n.idToken)return Ke._fromIdtoken(t.multiFactorSession.idToken)}return null}}class Ge{constructor(t,e,n){this.session=t,this.hints=e,this.signInResolver=n}static _fromError(t,e){const n=It(t),r=e.customData._serverResponse,i=(r.mfaInfo||[]).map((t=>ce._fromServerResponse(n,t)));E(r.mfaPendingCredential,n,"internal-error");const s=Ke._fromMfaPendingCredential(r.mfaPendingCredential);return new Ge(s,i,(async t=>{const i=await t._process(n,s);delete r.mfaInfo,delete r.mfaPendingCredential;const o=Object.assign(Object.assign({},r),{idToken:i.idToken,refreshToken:i.refreshToken});switch(e.operationType){case"signIn":const t=await Ht._fromIdTokenResponse(n,e.operationType,o);return await n._updateCurrentUser(t.user),t;case"reauthenticate":return E(e.user,n,"internal-error"),Ht._forOperation(e.user,e.operationType,o);default:b(n,"internal-error")}}))}async resolveSignIn(t){const e=t;return this.signInResolver(e)}}function We(t,e){var n;const i=(0,r.m9)(t),s=e;return E(e.customData.operationType,i,"argument-error"),E(null===(n=s.customData._serverResponse)||void 0===n?void 0:n.mfaPendingCredential,i,"argument-error"),Ge._fromError(i,s)}class $e{constructor(t){this.user=t,this.enrolledFactors=[],t._onReload((e=>{e.mfaInfo&&(this.enrolledFactors=e.mfaInfo.map((e=>ce._fromServerResponse(t.auth,e))))}))}static _fromUser(t){return new $e(t)}async getSession(){return Ke._fromIdtoken(await this.user.getIdToken())}async enroll(t,e){const n=t,r=await this.getSession(),i=await Q(this.user,n._process(this.user.auth,r,e));return await this.user._updateTokensIfNecessary(i),this.user.reload()}async unenroll(t){const e="string"==typeof t?t:t.uid,n=await this.user.getIdToken(),r=await Q(this.user,(i=this.user.auth,s={idToken:n,mfaEnrollmentId:e},U(i,"POST","/v2/accounts/mfaEnrollment:withdraw",F(i,s))));var i,s;this.enrolledFactors=this.enrolledFactors.filter((({uid:t})=>t!==e)),await this.user._updateTokensIfNecessary(r);try{await this.user.reload()}catch(t){if("auth/user-token-expired"!==t.code)throw t}}}const He=new WeakMap;function Ye(t){const e=(0,r.m9)(t);return He.has(e)||He.set(e,$e._fromUser(e)),He.get(e)}const Qe="__sak";class Ze{constructor(t,e){this.storageRetriever=t,this.type=e}_isAvailable(){try{return this.storage?(this.storage.setItem(Qe,"1"),this.storage.removeItem(Qe),Promise.resolve(!0)):Promise.resolve(!1)}catch(t){return Promise.resolve(!1)}}_set(t,e){return this.storage.setItem(t,JSON.stringify(e)),Promise.resolve()}_get(t){const e=this.storage.getItem(t);return Promise.resolve(e?JSON.parse(e):null)}_remove(t){return this.storage.removeItem(t),Promise.resolve()}get storage(){return this.storageRetriever()}}class Je extends Ze{constructor(){super((()=>window.localStorage),"LOCAL"),this.boundEventHandler=(t,e)=>this.onStorageEvent(t,e),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=function(){const t=(0,r.z$)();return ht(t)||gt(t)}()&&function(){try{return!(!window||window===window.top)}catch(t){return!1}}(),this.fallbackToPolling=yt(),this._shouldAllowMigration=!0}forAllChangedKeys(t){for(const e of Object.keys(this.listeners)){const n=this.storage.getItem(e),r=this.localCache[e];n!==r&&t(e,r,n)}}onStorageEvent(t,e=!1){if(!t.key)return void this.forAllChangedKeys(((t,e,n)=>{this.notifyListeners(t,n)}));const n=t.key;if(e?this.detachListener():this.stopPolling(),this.safariLocalStorageNotSynced){const r=this.storage.getItem(n);if(t.newValue!==r)null!==t.newValue?this.storage.setItem(n,t.newValue):this.storage.removeItem(n);else if(this.localCache[n]===t.newValue&&!e)return}const i=()=>{const t=this.storage.getItem(n);(e||this.localCache[n]!==t)&&this.notifyListeners(n,t)},s=this.storage.getItem(n);(0,r.w1)()&&10===document.documentMode&&s!==t.newValue&&t.newValue!==t.oldValue?setTimeout(i,10):i()}notifyListeners(t,e){this.localCache[t]=e;const n=this.listeners[t];if(n)for(const t of Array.from(n))t(e?JSON.parse(e):e)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((()=>{this.forAllChangedKeys(((t,e,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:t,oldValue:e,newValue:n}),!0)}))}),1e3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(t,e){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[t]||(this.listeners[t]=new Set,this.localCache[t]=this.storage.getItem(t)),this.listeners[t].add(e)}_removeListener(t,e){this.listeners[t]&&(this.listeners[t].delete(e),0===this.listeners[t].size&&delete this.listeners[t]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(t,e){await super._set(t,e),this.localCache[t]=JSON.stringify(e)}async _get(t){const e=await super._get(t);return this.localCache[t]=JSON.stringify(e),e}async _remove(t){await super._remove(t),delete this.localCache[t]}}Je.type="LOCAL";const Xe=Je;class tn extends Ze{constructor(){super((()=>window.sessionStorage),"SESSION")}_addListener(t,e){}_removeListener(t,e){}}tn.type="SESSION";const en=tn;class nn{constructor(t){this.eventTarget=t,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){const e=this.receivers.find((e=>e.isListeningto(t)));if(e)return e;const n=new nn(t);return this.receivers.push(n),n}isListeningto(t){return this.eventTarget===t}async handleEvent(t){const e=t,{eventId:n,eventType:r,data:i}=e.data,s=this.handlersMap[r];if(!(null==s?void 0:s.size))return;e.ports[0].postMessage({status:"ack",eventId:n,eventType:r});const o=Array.from(s).map((async t=>t(e.origin,i))),a=await function(t){return Promise.all(t.map((async t=>{try{return{fulfilled:!0,value:await t}}catch(t){return{fulfilled:!1,reason:t}}})))}(o);e.ports[0].postMessage({status:"done",eventId:n,eventType:r,response:a})}_subscribe(t,e){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[t]||(this.handlersMap[t]=new Set),this.handlersMap[t].add(e)}_unsubscribe(t,e){this.handlersMap[t]&&e&&this.handlersMap[t].delete(e),e&&0!==this.handlersMap[t].size||delete this.handlersMap[t],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}function rn(t="",e=10){let n="";for(let t=0;t<e;t++)n+=Math.floor(10*Math.random());return t+n}nn.receivers=[];class sn{constructor(t){this.target=t,this.handlers=new Set}removeMessageHandler(t){t.messageChannel&&(t.messageChannel.port1.removeEventListener("message",t.onMessage),t.messageChannel.port1.close()),this.handlers.delete(t)}async _send(t,e,n=50){const r="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!r)throw new Error("connection_unavailable");let i,s;return new Promise(((o,a)=>{const u=rn("",20);r.port1.start();const c=setTimeout((()=>{a(new Error("unsupported_event"))}),n);s={messageChannel:r,onMessage(t){const e=t;if(e.data.eventId===u)switch(e.data.status){case"ack":clearTimeout(c),i=setTimeout((()=>{a(new Error("timeout"))}),3e3);break;case"done":clearTimeout(i),o(e.data.response);break;default:clearTimeout(c),clearTimeout(i),a(new Error("invalid_response"))}}},this.handlers.add(s),r.port1.addEventListener("message",s.onMessage),this.target.postMessage({eventType:t,eventId:u,data:e},[r.port2])})).finally((()=>{s&&this.removeMessageHandler(s)}))}}function on(){return window}function an(){return void 0!==on().WorkerGlobalScope&&"function"==typeof on().importScripts}const un="firebaseLocalStorageDb",cn="firebaseLocalStorage",hn="fbase_key";class ln{constructor(t){this.request=t}toPromise(){return new Promise(((t,e)=>{this.request.addEventListener("success",(()=>{t(this.request.result)})),this.request.addEventListener("error",(()=>{e(this.request.error)}))}))}}function dn(t,e){return t.transaction([cn],e?"readwrite":"readonly").objectStore(cn)}function fn(){const t=indexedDB.open(un,1);return new Promise(((e,n)=>{t.addEventListener("error",(()=>{n(t.error)})),t.addEventListener("upgradeneeded",(()=>{const e=t.result;try{e.createObjectStore(cn,{keyPath:hn})}catch(t){n(t)}})),t.addEventListener("success",(async()=>{const n=t.result;n.objectStoreNames.contains(cn)?e(n):(n.close(),await function(){const t=indexedDB.deleteDatabase(un);return new ln(t).toPromise()}(),e(await fn()))}))}))}async function pn(t,e,n){const r=dn(t,!0).put({[hn]:e,value:n});return new ln(r).toPromise()}function mn(t,e){const n=dn(t,!0).delete(e);return new ln(n).toPromise()}class gn{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then((()=>{}),(()=>{}))}async _openDb(){return this.db||(this.db=await fn()),this.db}async _withRetries(t){let e=0;for(;;)try{const e=await this._openDb();return await t(e)}catch(t){if(e++>3)throw t;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return an()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=nn._getInstance(an()?self:null),this.receiver._subscribe("keyChanged",(async(t,e)=>({keyProcessed:(await this._poll()).includes(e.key)}))),this.receiver._subscribe("ping",(async(t,e)=>["keyChanged"]))}async initializeSender(){var t,e;if(this.activeServiceWorker=await async function(){if(!(null===navigator||void 0===navigator?void 0:navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch(t){return null}}(),!this.activeServiceWorker)return;this.sender=new sn(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&(null===(t=n[0])||void 0===t?void 0:t.fulfilled)&&(null===(e=n[0])||void 0===e?void 0:e.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(t){var e;if(this.sender&&this.activeServiceWorker&&((null===(e=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===e?void 0:e.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:t},this.serviceWorkerReceiverAvailable?800:50)}catch(e){}}async _isAvailable(){try{if(!indexedDB)return!1;const t=await fn();return await pn(t,Qe,"1"),await mn(t,Qe),!0}catch(t){}return!1}async _withPendingWrite(t){this.pendingWrites++;try{await t()}finally{this.pendingWrites--}}async _set(t,e){return this._withPendingWrite((async()=>(await this._withRetries((n=>pn(n,t,e))),this.localCache[t]=e,this.notifyServiceWorker(t))))}async _get(t){const e=await this._withRetries((e=>async function(t,e){const n=dn(t,!1).get(e),r=await new ln(n).toPromise();return void 0===r?null:r.value}(e,t)));return this.localCache[t]=e,e}async _remove(t){return this._withPendingWrite((async()=>(await this._withRetries((e=>mn(e,t))),delete this.localCache[t],this.notifyServiceWorker(t))))}async _poll(){const t=await this._withRetries((t=>{const e=dn(t,!1).getAll();return new ln(e).toPromise()}));if(!t)return[];if(0!==this.pendingWrites)return[];const e=[],n=new Set;for(const{fbase_key:r,value:i}of t)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),e.push(r));for(const t of Object.keys(this.localCache))this.localCache[t]&&!n.has(t)&&(this.notifyListeners(t,null),e.push(t));return e}notifyListeners(t,e){this.localCache[t]=e;const n=this.listeners[t];if(n)for(const t of Array.from(n))t(e)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((async()=>this._poll()),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(t,e){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[t]||(this.listeners[t]=new Set,this._get(t)),this.listeners[t].add(e)}_removeListener(t,e){this.listeners[t]&&(this.listeners[t].delete(e),0===this.listeners[t].size&&delete this.listeners[t]),0===Object.keys(this.listeners).length&&this.stopPolling()}}gn.type="LOCAL";const yn=gn;function vn(t){return new Promise(((e,n)=>{const r=document.createElement("script");var i,s;r.setAttribute("src",t),r.onload=e,r.onerror=t=>{const e=w("internal-error");e.customData=t,n(e)},r.type="text/javascript",r.charset="UTF-8",(null!==(s=null===(i=document.getElementsByTagName("head"))||void 0===i?void 0:i[0])&&void 0!==s?s:document).appendChild(r)}))}function bn(t){return`__${t}${Math.floor(1e6*Math.random())}`}const wn=1e12;class In{constructor(t){this.auth=t,this.counter=wn,this._widgets=new Map}render(t,e){const n=this.counter;return this._widgets.set(n,new _n(t,this.auth.name,e||{})),this.counter++,n}reset(t){var e;const n=t||wn;null===(e=this._widgets.get(n))||void 0===e||e.delete(),this._widgets.delete(n)}getResponse(t){var e;const n=t||wn;return(null===(e=this._widgets.get(n))||void 0===e?void 0:e.getResponse())||""}async execute(t){var e;const n=t||wn;return null===(e=this._widgets.get(n))||void 0===e||e.execute(),""}}class _n{constructor(t,e,n){this.params=n,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};const r="string"==typeof t?document.getElementById(t):t;E(r,"argument-error",{appName:e}),this.container=r,this.isVisible="invisible"!==this.params.size,this.isVisible?this.execute():this.container.addEventListener("click",this.clickHandler)}getResponse(){return this.checkIfDeleted(),this.responseToken}delete(){this.checkIfDeleted(),this.deleted=!0,this.timerId&&(clearTimeout(this.timerId),this.timerId=null),this.container.removeEventListener("click",this.clickHandler)}execute(){this.checkIfDeleted(),this.timerId||(this.timerId=window.setTimeout((()=>{this.responseToken=function(t){const e=[],n="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let t=0;t<50;t++)e.push(n.charAt(Math.floor(Math.random()*n.length)));return e.join("")}();const{callback:t,"expired-callback":e}=this.params;if(t)try{t(this.responseToken)}catch(t){}this.timerId=window.setTimeout((()=>{if(this.timerId=null,this.responseToken=null,e)try{e()}catch(t){}this.isVisible&&this.execute()}),6e4)}),500))}checkIfDeleted(){if(this.deleted)throw new Error("reCAPTCHA mock was already deleted!")}}const Tn=bn("rcb"),En=new R(3e4,6e4);class Sn{constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!on().grecaptcha}load(t,e=""){return E(function(t){return t.length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(t)}(e),t,"argument-error"),this.shouldResolveImmediately(e)?Promise.resolve(on().grecaptcha):new Promise(((n,i)=>{const s=on().setTimeout((()=>{i(w(t,"network-request-failed"))}),En.get());on()[Tn]=()=>{on().clearTimeout(s),delete on()[Tn];const r=on().grecaptcha;if(!r)return void i(w(t,"internal-error"));const o=r.render;r.render=(t,e)=>{const n=o(t,e);return this.counter++,n},this.hostLanguage=e,n(r)},vn(`https://www.google.com/recaptcha/api.js??${(0,r.xO)({onload:Tn,render:"explicit",hl:e})}`).catch((()=>{clearTimeout(s),i(w(t,"internal-error"))}))}))}clearedOneInstance(){this.counter--}shouldResolveImmediately(t){return!!on().grecaptcha&&(t===this.hostLanguage||this.counter>0||this.librarySeparatelyLoaded)}}class An{async load(t){return new In(t)}clearedOneInstance(){}}const xn="recaptcha",Nn={theme:"light",type:"image"};class kn{constructor(t,e=Object.assign({},Nn),n){this.parameters=e,this.type=xn,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=It(n),this.isInvisible="invisible"===this.parameters.size,E("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");const r="string"==typeof t?document.getElementById(t):t;E(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=this.auth.settings.appVerificationDisabledForTesting?new An:new Sn,this.validateStartingState()}async verify(){this.assertNotDestroyed();const t=await this.render(),e=this.getAssertedRecaptcha();return e.getResponse(t)||new Promise((n=>{const r=t=>{t&&(this.tokenChangeListeners.delete(r),n(t))};this.tokenChangeListeners.add(r),this.isInvisible&&e.execute(t)}))}render(){try{this.assertNotDestroyed()}catch(t){return Promise.reject(t)}return this.renderPromise||(this.renderPromise=this.makeRenderPromise().catch((t=>{throw this.renderPromise=null,t}))),this.renderPromise}_reset(){this.assertNotDestroyed(),null!==this.widgetId&&this.getAssertedRecaptcha().reset(this.widgetId)}clear(){this.assertNotDestroyed(),this.destroyed=!0,this._recaptchaLoader.clearedOneInstance(),this.isInvisible||this.container.childNodes.forEach((t=>{this.container.removeChild(t)}))}validateStartingState(){E(!this.parameters.sitekey,this.auth,"argument-error"),E(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),E("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(t){return e=>{if(this.tokenChangeListeners.forEach((t=>t(e))),"function"==typeof t)t(e);else if("string"==typeof t){const n=on()[t];"function"==typeof n&&n(e)}}}assertNotDestroyed(){E(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let t=this.container;if(!this.isInvisible){const e=document.createElement("div");t.appendChild(e),t=e}this.widgetId=this.getAssertedRecaptcha().render(t,this.parameters)}return this.widgetId}async init(){E(D()&&!an(),this.auth,"internal-error"),await function(){let t=null;return new Promise((e=>{"complete"!==document.readyState?(t=()=>e(),window.addEventListener("load",t)):e()})).catch((e=>{throw t&&window.removeEventListener("load",t),e}))}(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);const t=await async function(t){return(await U(t,"GET","/v1/recaptchaParams")).recaptchaSiteKey||""}(this.auth);E(t,this.auth,"internal-error"),this.parameters.sitekey=t}getAssertedRecaptcha(){return E(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}class Cn{constructor(t,e){this.verificationId=t,this.onConfirmation=e}confirm(t){const e=Pt._fromVerification(this.verificationId,t);return this.onConfirmation(e)}}async function Dn(t,e,n){const i=It(t),s=await Pn(i,e,(0,r.m9)(n));return new Cn(s,(t=>se(i,t)))}async function On(t,e,n){const i=(0,r.m9)(t);await ne(!1,i,"phone");const s=await Pn(i.auth,e,(0,r.m9)(n));return new Cn(s,(t=>oe(i,t)))}async function Rn(t,e,n){const i=(0,r.m9)(t),s=await Pn(i.auth,e,(0,r.m9)(n));return new Cn(s,(t=>ae(i,t)))}async function Pn(t,e,n){var r;const i=await n.verify();try{let s;if(E("string"==typeof i,t,"argument-error"),E(n.type===xn,t,"argument-error"),s="string"==typeof e?{phoneNumber:e}:e,"session"in s){const e=s.session;if("phoneNumber"in s){E("enroll"===e.type,t,"internal-error");const n=await function(t,e){return U(t,"POST","/v2/accounts/mfaEnrollment:start",F(t,e))}(t,{idToken:e.credential,phoneEnrollmentInfo:{phoneNumber:s.phoneNumber,recaptchaToken:i}});return n.phoneSessionInfo.sessionInfo}{E("signin"===e.type,t,"internal-error");const n=(null===(r=s.multiFactorHint)||void 0===r?void 0:r.uid)||s.multiFactorUid;E(n,t,"missing-multi-factor-info");const o=await function(t,e){return U(t,"POST","/v2/accounts/mfaSignIn:start",F(t,e))}(t,{mfaPendingCredential:e.credential,mfaEnrollmentId:n,phoneSignInInfo:{recaptchaToken:i}});return o.phoneResponseInfo.sessionInfo}}{const{sessionInfo:e}=await async function(t,e){return U(t,"POST","/v1/accounts:sendVerificationCode",F(t,e))}(t,{phoneNumber:s.phoneNumber,recaptchaToken:i});return e}}finally{n._reset()}}async function Ln(t,e){await ee((0,r.m9)(t),e)}class Mn{constructor(t){this.providerId=Mn.PROVIDER_ID,this.auth=It(t)}verifyPhoneNumber(t,e){return Pn(this.auth,t,(0,r.m9)(e))}static credential(t,e){return Pt._fromVerification(t,e)}static credentialFromResult(t){const e=t;return Mn.credentialFromTaggedObject(e)}static credentialFromError(t){return Mn.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;const{phoneNumber:e,temporaryProof:n}=t;return e&&n?Pt._fromTokenResponse(e,n):null}}function Vn(t,e){return e?N(e):(E(t._popupRedirectResolver,t,"argument-error"),t._popupRedirectResolver)}Mn.PROVIDER_ID="phone",Mn.PHONE_SIGN_IN_METHOD="phone";class Fn extends At{constructor(t){super("custom","custom"),this.params=t}_getIdTokenResponse(t){return Dt(t,this._buildIdpRequest())}_linkToIdToken(t,e){return Dt(t,this._buildIdpRequest(e))}_getReauthenticationResolver(t){return Dt(t,this._buildIdpRequest())}_buildIdpRequest(t){const e={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return t&&(e.idToken=t),e}}function Un(t){return ie(t.auth,new Fn(t),t.bypassAuthState)}function jn(t){const{auth:e,user:n}=t;return E(n,e,"internal-error"),re(n,new Fn(t),t.bypassAuthState)}async function Bn(t){const{auth:e,user:n}=t;return E(n,e,"internal-error"),ee(n,new Fn(t),t.bypassAuthState)}class qn{constructor(t,e,n,r,i=!1){this.auth=t,this.resolver=n,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(e)?e:[e]}execute(){return new Promise((async(t,e)=>{this.pendingPromise={resolve:t,reject:e};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(t){this.reject(t)}}))}async onAuthEvent(t){const{urlResponse:e,sessionId:n,postBody:r,tenantId:i,error:s,type:o}=t;if(s)return void this.reject(s);const a={auth:this.auth,requestUri:e,sessionId:n,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(a))}catch(t){this.reject(t)}}onError(t){this.reject(t)}getIdpTask(t){switch(t){case"signInViaPopup":case"signInViaRedirect":return Un;case"linkViaPopup":case"linkViaRedirect":return Bn;case"reauthViaPopup":case"reauthViaRedirect":return jn;default:b(this.auth,"internal-error")}}resolve(t){A(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(t),this.unregisterAndCleanUp()}reject(t){A(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(t),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const zn=new R(2e3,1e4);async function Kn(t,e,n){const r=It(t);_(t,e,Ft);const i=Vn(r,n);return new $n(r,"signInViaPopup",e,i).executeNotNull()}async function Gn(t,e,n){const i=(0,r.m9)(t);_(i.auth,e,Ft);const s=Vn(i.auth,n);return new $n(i.auth,"reauthViaPopup",e,s,i).executeNotNull()}async function Wn(t,e,n){const i=(0,r.m9)(t);_(i.auth,e,Ft);const s=Vn(i.auth,n);return new $n(i.auth,"linkViaPopup",e,s,i).executeNotNull()}class $n extends qn{constructor(t,e,n,r,i){super(t,e,r,i),this.provider=n,this.authWindow=null,this.pollId=null,$n.currentPopupAction&&$n.currentPopupAction.cancel(),$n.currentPopupAction=this}async executeNotNull(){const t=await this.execute();return E(t,this.auth,"internal-error"),t}async onExecution(){A(1===this.filter.length,"Popup operations only handle one event");const t=rn();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],t),this.authWindow.associatedEvent=t,this.resolver._originValidation(this.auth).catch((t=>{this.reject(t)})),this.resolver._isIframeWebStorageSupported(this.auth,(t=>{t||this.reject(w(this.auth,"web-storage-unsupported"))})),this.pollUserCancellation()}get eventId(){var t;return(null===(t=this.authWindow)||void 0===t?void 0:t.associatedEvent)||null}cancel(){this.reject(w(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,$n.currentPopupAction=null}pollUserCancellation(){const t=()=>{var e,n;(null===(n=null===(e=this.authWindow)||void 0===e?void 0:e.window)||void 0===n?void 0:n.closed)?this.pollId=window.setTimeout((()=>{this.pollId=null,this.reject(w(this.auth,"popup-closed-by-user"))}),2e3):this.pollId=window.setTimeout(t,zn.get())};t()}}$n.currentPopupAction=null;const Hn=new Map;class Yn extends qn{constructor(t,e,n=!1){super(t,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],e,void 0,n),this.eventId=null}async execute(){let t=Hn.get(this.auth._key());if(!t){try{const e=await async function(t,e){const n=Xn(e),r=Jn(t);if(!await r._isAvailable())return!1;const i="true"===await r._get(n);return await r._remove(n),i}(this.resolver,this.auth)?await super.execute():null;t=()=>Promise.resolve(e)}catch(e){t=()=>Promise.reject(e)}Hn.set(this.auth._key(),t)}return this.bypassAuthState||Hn.set(this.auth._key(),(()=>Promise.resolve(null))),t()}async onAuthEvent(t){if("signInViaRedirect"===t.type)return super.onAuthEvent(t);if("unknown"!==t.type){if(t.eventId){const e=await this.auth._redirectUserForId(t.eventId);if(e)return this.user=e,super.onAuthEvent(t);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}async function Qn(t,e){return Jn(t)._set(Xn(e),"true")}function Zn(t,e){Hn.set(t._key(),e)}function Jn(t){return N(t._redirectPersistence)}function Xn(t){return ot("pendingRedirect",t.config.apiKey,t.name)}function tr(t,e,n){return async function(t,e,n){const r=It(t);_(t,e,Ft);const i=Vn(r,n);return await Qn(i,r),i._openRedirect(r,e,"signInViaRedirect")}(t,e,n)}function er(t,e,n){return async function(t,e,n){const i=(0,r.m9)(t);_(i.auth,e,Ft);const s=Vn(i.auth,n);await Qn(s,i.auth);const o=await sr(i);return s._openRedirect(i.auth,e,"reauthViaRedirect",o)}(t,e,n)}function nr(t,e,n){return async function(t,e,n){const i=(0,r.m9)(t);_(i.auth,e,Ft);const s=Vn(i.auth,n);await ne(!1,i,e.providerId),await Qn(s,i.auth);const o=await sr(i);return s._openRedirect(i.auth,e,"linkViaRedirect",o)}(t,e,n)}async function rr(t,e){return await It(t)._initializationPromise,ir(t,e,!1)}async function ir(t,e,n=!1){const r=It(t),i=Vn(r,e),s=new Yn(r,i,n),o=await s.execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,e)),o}async function sr(t){const e=rn(`${t.uid}:::`);return t._redirectEventId=e,await t.auth._setRedirectUser(t),await t.auth._persistUserIfCurrent(t),e}class or{constructor(t){this.auth=t,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(t){this.consumers.add(t),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,t)&&(this.sendToConsumer(this.queuedRedirectEvent,t),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(t){this.consumers.delete(t)}onEvent(t){if(this.hasEventBeenHandled(t))return!1;let e=!1;return this.consumers.forEach((n=>{this.isEventForConsumer(t,n)&&(e=!0,this.sendToConsumer(t,n),this.saveEventToCache(t))})),this.hasHandledPotentialRedirect||!function(t){switch(t.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return ur(t);default:return!1}}(t)||(this.hasHandledPotentialRedirect=!0,e||(this.queuedRedirectEvent=t,e=!0)),e}sendToConsumer(t,e){var n;if(t.error&&!ur(t)){const r=(null===(n=t.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error";e.onError(w(this.auth,r))}else e.onAuthEvent(t)}isEventForConsumer(t,e){const n=null===e.eventId||!!t.eventId&&t.eventId===e.eventId;return e.filter.includes(t.type)&&n}hasEventBeenHandled(t){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(ar(t))}saveEventToCache(t){this.cachedEventUids.add(ar(t)),this.lastProcessedEventTime=Date.now()}}function ar(t){return[t.type,t.eventId,t.sessionId,t.tenantId].filter((t=>t)).join("-")}function ur({type:t,error:e}){return"unknown"===t&&"auth/no-auth-event"===(null==e?void 0:e.code)}const cr=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,hr=/^https?/;function lr(t){const e=C(),{protocol:n,hostname:r}=new URL(e);if(t.startsWith("chrome-extension://")){const i=new URL(t);return""===i.hostname&&""===r?"chrome-extension:"===n&&t.replace("chrome-extension://","")===e.replace("chrome-extension://",""):"chrome-extension:"===n&&i.hostname===r}if(!hr.test(n))return!1;if(cr.test(t))return r===t;const i=t.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}const dr=new R(3e4,6e4);function fr(){const t=on().___jsl;if(null==t?void 0:t.H)for(const e of Object.keys(t.H))if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=[...t.H[e].L],t.CP)for(let e=0;e<t.CP.length;e++)t.CP[e]=null}let pr=null;function mr(t){return pr=pr||function(t){return new Promise(((e,n)=>{var r,i,s;function o(){fr(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{fr(),n(w(t,"network-request-failed"))},timeout:dr.get()})}if(null===(i=null===(r=on().gapi)||void 0===r?void 0:r.iframes)||void 0===i?void 0:i.Iframe)e(gapi.iframes.getContext());else{if(!(null===(s=on().gapi)||void 0===s?void 0:s.load)){const e=bn("iframefcb");return on()[e]=()=>{gapi.load?o():n(w(t,"network-request-failed"))},vn(`https://apis.google.com/js/api.js?onload=${e}`).catch((t=>n(t)))}o()}})).catch((t=>{throw pr=null,t}))}(t),pr}const gr=new R(5e3,15e3),yr={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},vr=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function br(t){const e=t.config;E(e.authDomain,t,"auth-domain-config-required");const n=e.emulator?P(e,"emulator/auth/iframe"):`https://${t.config.authDomain}/__/auth/iframe`,s={apiKey:e.apiKey,appName:t.name,v:i.Jn},o=vr.get(t.config.apiHost);o&&(s.eid=o);const a=t._getFrameworks();return a.length&&(s.fw=a.join(",")),`${n}?${(0,r.xO)(s).slice(1)}`}const wr={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class Ir{constructor(t){this.window=t,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(t){}}}function _r(t,e,n,s,o,a){E(t.config.authDomain,t,"auth-domain-config-required"),E(t.config.apiKey,t,"invalid-api-key");const u={apiKey:t.config.apiKey,appName:t.name,authType:n,redirectUrl:s,v:i.Jn,eventId:o};if(e instanceof Ft){e.setDefaultLanguage(t.languageCode),u.providerId=e.providerId||"",(0,r.xb)(e.getCustomParameters())||(u.customParameters=JSON.stringify(e.getCustomParameters()));for(const[t,e]of Object.entries(a||{}))u[t]=e}if(e instanceof Ut){const t=e.getScopes().filter((t=>""!==t));t.length>0&&(u.scopes=t.join(","))}t.tenantId&&(u.tid=t.tenantId);const c=u;for(const t of Object.keys(c))void 0===c[t]&&delete c[t];return`${function({config:t}){return t.emulator?P(t,"emulator/auth/handler"):`https://${t.authDomain}/__/auth/handler`}(t)}?${(0,r.xO)(c).slice(1)}`}const Tr="webStorageSupport",Er=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=en,this._completeRedirectFn=ir,this._overrideRedirectResult=Zn}async _openPopup(t,e,n,i){var s;return A(null===(s=this.eventManagers[t._key()])||void 0===s?void 0:s.manager,"_initialize() not called before _openPopup()"),function(t,e,n,i=500,s=600){const o=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-i)/2,0).toString();let u="";const c=Object.assign(Object.assign({},wr),{width:i.toString(),height:s.toString(),top:o,left:a}),h=(0,r.z$)().toLowerCase();n&&(u=lt(h)?"_blank":n),ct(h)&&(e=e||"http://localhost",c.scrollbars="yes");const l=Object.entries(c).reduce(((t,[e,n])=>`${t}${e}=${n},`),"");if(function(t=(0,r.z$)()){var e;return gt(t)&&!!(null===(e=window.navigator)||void 0===e?void 0:e.standalone)}(h)&&"_self"!==u)return function(t,e){const n=document.createElement("a");n.href=t,n.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}(e||"",u),new Ir(null);const d=window.open(e||"",u,l);E(d,t,"popup-blocked");try{d.focus()}catch(t){}return new Ir(d)}(t,_r(t,e,n,C(),i),rn())}async _openRedirect(t,e,n,r){var i;return await this._originValidation(t),i=_r(t,e,n,C(),r),on().location.href=i,new Promise((()=>{}))}_initialize(t){const e=t._key();if(this.eventManagers[e]){const{manager:t,promise:n}=this.eventManagers[e];return t?Promise.resolve(t):(A(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(t);return this.eventManagers[e]={promise:n},n.catch((()=>{delete this.eventManagers[e]})),n}async initAndGetManager(t){const e=await async function(t){const e=await mr(t),n=on().gapi;return E(n,t,"internal-error"),e.open({where:document.body,url:br(t),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:yr,dontclear:!0},(e=>new Promise((async(n,r)=>{await e.restyle({setHideOnLeave:!1});const i=w(t,"network-request-failed"),s=on().setTimeout((()=>{r(i)}),gr.get());function o(){on().clearTimeout(s),n(e)}e.ping(o).then(o,(()=>{r(i)}))}))))}(t),n=new or(t);return e.register("authEvent",(e=>(E(null==e?void 0:e.authEvent,t,"invalid-auth-event"),{status:n.onEvent(e.authEvent)?"ACK":"ERROR"})),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[t._key()]={manager:n},this.iframes[t._key()]=e,n}_isIframeWebStorageSupported(t,e){this.iframes[t._key()].send(Tr,{type:Tr},(n=>{var r;const i=null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.webStorageSupport;void 0!==i&&e(!!i),b(t,"internal-error")}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(t){const e=t._key();return this.originValidationPromises[e]||(this.originValidationPromises[e]=async function(t){if(t.config.emulator)return;const{authorizedDomains:e}=await async function(t,e={}){return U(t,"GET","/v1/projects",e)}(t);for(const t of e)try{if(lr(t))return}catch(t){}b(t,"unauthorized-domain")}(t)),this.originValidationPromises[e]}get _shouldInitProactively(){return yt()||ht()||gt()}};class Sr extends class{constructor(t){this.factorId=t}_process(t,e,n){switch(e.type){case"enroll":return this._finalizeEnroll(t,e.credential,n);case"signin":return this._finalizeSignIn(t,e.credential);default:return S("unexpected MultiFactorSessionType")}}}{constructor(t){super("phone"),this.credential=t}static _fromCredential(t){return new Sr(t)}_finalizeEnroll(t,e,n){return function(t,e){return U(t,"POST","/v2/accounts/mfaEnrollment:finalize",F(t,e))}(t,{idToken:e,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(t,e){return function(t,e){return U(t,"POST","/v2/accounts/mfaSignIn:finalize",F(t,e))}(t,{mfaPendingCredential:e,phoneVerificationInfo:this.credential._makeVerificationRequest()})}}class Ar{constructor(){}static assertion(t){return Sr._fromCredential(t)}}Ar.FACTOR_ID="phone";var xr,Nr="@firebase/auth",kr="0.20.2";class Cr{constructor(t){this.auth=t,this.internalListeners=new Map}getUid(){var t;return this.assertAuthConfigured(),(null===(t=this.auth.currentUser)||void 0===t?void 0:t.uid)||null}async getToken(t){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(t)}:null}addAuthTokenListener(t){if(this.assertAuthConfigured(),this.internalListeners.has(t))return;const e=this.auth.onIdTokenChanged((e=>{var n;t((null===(n=e)||void 0===n?void 0:n.stsTokenManager.accessToken)||null)}));this.internalListeners.set(t,e),this.updateProactiveRefresh()}removeAuthTokenListener(t){this.assertAuthConfigured();const e=this.internalListeners.get(t);e&&(this.internalListeners.delete(t),e(),this.updateProactiveRefresh())}assertAuthConfigured(){E(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function Dr(t=(0,i.Mq)()){const e=(0,i.qX)(t,"auth");return e.isInitialized()?e.getImmediate():k(t,{popupRedirectResolver:Er,persistence:[yn,Xe,en]})}xr="Browser",(0,i.Xd)(new a.wA("auth",((t,{options:e})=>{const n=t.getProvider("app").getImmediate(),r=t.getProvider("heartbeat"),{apiKey:i,authDomain:s}=n.options;return((t,n)=>{E(i&&!i.includes(":"),"invalid-api-key",{appName:t.name}),E(!(null==s?void 0:s.includes(":")),"argument-error",{appName:t.name});const r={apiKey:i,authDomain:s,clientPlatform:xr,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:vt(xr)},o=new wt(t,n,r);return function(t,e){const n=(null==e?void 0:e.persistence)||[],r=(Array.isArray(n)?n:[n]).map(N);(null==e?void 0:e.errorMap)&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,null==e?void 0:e.popupRedirectResolver)}(o,e),o})(n,r)}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(((t,e,n)=>{t.getProvider("auth-internal").initialize()}))),(0,i.Xd)(new a.wA("auth-internal",(t=>{return e=It(t.getProvider("auth").getImmediate()),new Cr(e);var e}),"PRIVATE").setInstantiationMode("EXPLICIT")),(0,i.KN)(Nr,kr,void 0),(0,i.KN)(Nr,kr,"esm2017")},1591:(t,e,n)=>{"use strict";n.r(e),n.d(e,{AbstractUserDataWriter:()=>mp,Bytes:()=>hf,CACHE_SIZE_UNLIMITED:()=>Kd,CollectionReference:()=>Ld,DocumentReference:()=>Rd,DocumentSnapshot:()=>zf,FieldPath:()=>uf,FieldValue:()=>lf,Firestore:()=>Gd,FirestoreError:()=>Rr,GeoPoint:()=>df,LoadBundleTask:()=>zd,Query:()=>Pd,QueryConstraint:()=>Yf,QueryDocumentSnapshot:()=>Kf,QuerySnapshot:()=>Gf,SnapshotMetadata:()=>qf,Timestamp:()=>Qr,Transaction:()=>Lp,WriteBatch:()=>vp,_DatabaseId:()=>gi,_DocumentKey:()=>wi,_EmptyAppCheckTokenProvider:()=>zr,_EmptyAuthCredentialsProvider:()=>Mr,_FieldPath:()=>ii,_cast:()=>Nd,_debugAssert:()=>Cr,_isBase64Available:()=>oi,_logWarn:()=>Ar,_setIndexConfiguration:()=>zp,_validateIsNotUsedTogether:()=>Ed,addDoc:()=>Cp,arrayRemove:()=>jp,arrayUnion:()=>Up,clearIndexedDbPersistence:()=>Xd,collection:()=>Md,collectionGroup:()=>Vd,connectFirestoreEmulator:()=>Od,deleteDoc:()=>kp,deleteField:()=>Vp,disableNetwork:()=>nf,doc:()=>Fd,documentId:()=>cf,enableIndexedDbPersistence:()=>Qd,enableMultiTabIndexedDbPersistence:()=>Zd,enableNetwork:()=>ef,endAt:()=>cp,endBefore:()=>up,ensureFirestoreConfigured:()=>Hd,executeWrite:()=>Rp,getDoc:()=>wp,getDocFromCache:()=>_p,getDocFromServer:()=>Tp,getDocs:()=>Ep,getDocsFromCache:()=>Sp,getDocsFromServer:()=>Ap,getFirestore:()=>$d,increment:()=>Bp,initializeFirestore:()=>Wd,limit:()=>np,limitToLast:()=>rp,loadBundle:()=>sf,namedQuery:()=>of,onSnapshot:()=>Dp,onSnapshotsInSync:()=>Op,orderBy:()=>tp,query:()=>Qf,queryEqual:()=>jd,refEqual:()=>Ud,runTransaction:()=>Mp,serverTimestamp:()=>Fp,setDoc:()=>xp,setLogLevel:()=>Tr,snapshotEqual:()=>$f,startAfter:()=>op,startAt:()=>sp,terminate:()=>rf,updateDoc:()=>Np,waitForPendingWrites:()=>tf,where:()=>Jf,writeBatch:()=>qp});var r,i=n(389),s=n(8463),o=n(3333),a=n(4444),u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{},c={},h=h||{},l=u||self;function d(){}function f(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 p(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var m="closure_uid_"+(1e9*Math.random()>>>0),g=0;function y(t,e,n){return t.call.apply(t.bind,arguments)}function v(t,e,n){if(!t)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function b(t,e,n){return(b=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?y:v).apply(null,arguments)}function w(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 I(t,e){function n(){}n.prototype=e.prototype,t.Z=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.Vb=function(t,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return e.prototype[n].apply(t,i)}}function _(){this.s=this.s,this.o=this.o}var T={};_.prototype.s=!1,_.prototype.na=function(){if(!this.s&&(this.s=!0,this.M(),0)){var t=function(t){return Object.prototype.hasOwnProperty.call(t,m)&&t[m]||(t[m]=++g)}(this);delete T[t]}},_.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};const E=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if("string"==typeof t)return"string"!=typeof e||1!=e.length?-1:t.indexOf(e,0);for(let n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},S=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){const r=t.length,i="string"==typeof t?t.split(""):t;for(let s=0;s<r;s++)s in i&&e.call(n,i[s],s,t)};function A(t){return Array.prototype.concat.apply([],arguments)}function x(t){const e=t.length;if(0<e){const n=Array(e);for(let r=0;r<e;r++)n[r]=t[r];return n}return[]}function N(t){return/^[\s\xa0]*$/.test(t)}var k,C=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function D(t,e){return-1!=t.indexOf(e)}function O(t,e){return t<e?-1:t>e?1:0}t:{var R=l.navigator;if(R){var P=R.userAgent;if(P){k=P;break t}}k=""}function L(t,e,n){for(const r in t)e.call(n,t[r],r,t)}function M(t){const e={};for(const n in t)e[n]=t[n];return e}var V="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function F(t,e){let n,r;for(let e=1;e<arguments.length;e++){for(n in r=arguments[e],r)t[n]=r[n];for(let e=0;e<V.length;e++)n=V[e],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function U(t){return U[" "](t),t}U[" "]=d;var j,B,q=D(k,"Opera"),z=D(k,"Trident")||D(k,"MSIE"),K=D(k,"Edge"),G=K||z,W=D(k,"Gecko")&&!(D(k.toLowerCase(),"webkit")&&!D(k,"Edge"))&&!(D(k,"Trident")||D(k,"MSIE"))&&!D(k,"Edge"),$=D(k.toLowerCase(),"webkit")&&!D(k,"Edge");function H(){var t=l.document;return t?t.documentMode:void 0}t:{var Y="",Q=(B=k,W?/rv:([^\);]+)(\)|;)/.exec(B):K?/Edge\/([\d\.]+)/.exec(B):z?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(B):$?/WebKit\/(\S+)/.exec(B):q?/(?:Version)[ \/]?(\S+)/.exec(B):void 0);if(Q&&(Y=Q?Q[1]:""),z){var Z=H();if(null!=Z&&Z>parseFloat(Y)){j=String(Z);break t}}j=Y}var J,X={};function tt(){return t=X,Object.prototype.hasOwnProperty.call(t,9)?t[9]:t[9]=function(){let t=0;const e=C(String(j)).split("."),n=C("9").split("."),r=Math.max(e.length,n.length);for(let o=0;0==t&&o<r;o++){var i=e[o]||"",s=n[o]||"";do{if(i=/(\d*)(\D*)(.*)/.exec(i)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],0==i[0].length&&0==s[0].length)break;t=O(0==i[1].length?0:parseInt(i[1],10),0==s[1].length?0:parseInt(s[1],10))||O(0==i[2].length,0==s[2].length)||O(i[2],s[2]),i=i[3],s=s[3]}while(0==t)}return 0<=t}();var t}l.document&&z?J=H()||parseInt(j,10)||void 0:J=void 0;var et=J,nt=function(){if(!l.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{l.addEventListener("test",d,e),l.removeEventListener("test",d,e)}catch(t){}return t}();function rt(t,e){this.type=t,this.g=this.target=e,this.defaultPrevented=!1}function it(t,e){if(rt.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,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.g=e,e=t.relatedTarget){if(W){t:{try{U(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:st[t.pointerType]||"",this.state=t.state,this.i=t,t.defaultPrevented&&it.Z.h.call(this)}}rt.prototype.h=function(){this.defaultPrevented=!0},I(it,rt);var st={2:"touch",3:"pen",4:"mouse"};it.prototype.h=function(){it.Z.h.call(this);var t=this.i;t.preventDefault?t.preventDefault():t.returnValue=!1};var ot="closure_listenable_"+(1e6*Math.random()|0),at=0;function ut(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.ia=i,this.key=++at,this.ca=this.fa=!1}function ct(t){t.ca=!0,t.listener=null,t.proxy=null,t.src=null,t.ia=null}function ht(t){this.src=t,this.g={},this.h=0}function lt(t,e){var n=e.type;if(n in t.g){var r,i=t.g[n],s=E(i,e);(r=0<=s)&&Array.prototype.splice.call(i,s,1),r&&(ct(e),0==t.g[n].length&&(delete t.g[n],t.h--))}}function dt(t,e,n,r){for(var i=0;i<t.length;++i){var s=t[i];if(!s.ca&&s.listener==e&&s.capture==!!n&&s.ia==r)return i}return-1}ht.prototype.add=function(t,e,n,r,i){var s=t.toString();(t=this.g[s])||(t=this.g[s]=[],this.h++);var o=dt(t,e,r,i);return-1<o?(e=t[o],n||(e.fa=!1)):((e=new ut(e,this.src,s,!!r,i)).fa=n,t.push(e)),e};var ft="closure_lm_"+(1e6*Math.random()|0),pt={};function mt(t,e,n,r,i){if(r&&r.once)return yt(t,e,n,r,i);if(Array.isArray(e)){for(var s=0;s<e.length;s++)mt(t,e[s],n,r,i);return null}return n=Et(n),t&&t[ot]?t.N(e,n,p(r)?!!r.capture:!!r,i):gt(t,e,n,!1,r,i)}function gt(t,e,n,r,i,s){if(!e)throw Error("Invalid event type");var o=p(i)?!!i.capture:!!i,a=_t(t);if(a||(t[ft]=a=new ht(t)),(n=a.add(e,n,r,o,s)).proxy)return n;if(r=function(){var t=It;return function e(n){return t.call(e.src,e.listener,n)}}(),n.proxy=r,r.src=t,r.listener=n,t.addEventListener)nt||(i=o),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(wt(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function yt(t,e,n,r,i){if(Array.isArray(e)){for(var s=0;s<e.length;s++)yt(t,e[s],n,r,i);return null}return n=Et(n),t&&t[ot]?t.O(e,n,p(r)?!!r.capture:!!r,i):gt(t,e,n,!0,r,i)}function vt(t,e,n,r,i){if(Array.isArray(e))for(var s=0;s<e.length;s++)vt(t,e[s],n,r,i);else r=p(r)?!!r.capture:!!r,n=Et(n),t&&t[ot]?(t=t.i,(e=String(e).toString())in t.g&&-1<(n=dt(s=t.g[e],n,r,i))&&(ct(s[n]),Array.prototype.splice.call(s,n,1),0==s.length&&(delete t.g[e],t.h--))):t&&(t=_t(t))&&(e=t.g[e.toString()],t=-1,e&&(t=dt(e,n,r,i)),(n=-1<t?e[t]:null)&&bt(n))}function bt(t){if("number"!=typeof t&&t&&!t.ca){var e=t.src;if(e&&e[ot])lt(e.i,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(wt(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=_t(e))?(lt(n,t),0==n.h&&(n.src=null,e[ft]=null)):ct(t)}}}function wt(t){return t in pt?pt[t]:pt[t]="on"+t}function It(t,e){if(t.ca)t=!0;else{e=new it(e,this);var n=t.listener,r=t.ia||t.src;t.fa&&bt(t),t=n.call(r,e)}return t}function _t(t){return(t=t[ft])instanceof ht?t:null}var Tt="__closure_events_fn_"+(1e9*Math.random()>>>0);function Et(t){return"function"==typeof t?t:(t[Tt]||(t[Tt]=function(e){return t.handleEvent(e)}),t[Tt])}function St(){_.call(this),this.i=new ht(this),this.P=this,this.I=null}function At(t,e){var n,r=t.I;if(r)for(n=[];r;r=r.I)n.push(r);if(t=t.P,r=e.type||e,"string"==typeof e)e=new rt(e,t);else if(e instanceof rt)e.target=e.target||t;else{var i=e;F(e=new rt(r,t),i)}if(i=!0,n)for(var s=n.length-1;0<=s;s--){var o=e.g=n[s];i=xt(o,r,!0,e)&&i}if(i=xt(o=e.g=t,r,!0,e)&&i,i=xt(o,r,!1,e)&&i,n)for(s=0;s<n.length;s++)i=xt(o=e.g=n[s],r,!1,e)&&i}function xt(t,e,n,r){if(!(e=t.i.g[String(e)]))return!0;e=e.concat();for(var i=!0,s=0;s<e.length;++s){var o=e[s];if(o&&!o.ca&&o.capture==n){var a=o.listener,u=o.ia||o.src;o.fa&<(t.i,o),i=!1!==a.call(u,r)&&i}}return i&&!r.defaultPrevented}I(St,_),St.prototype[ot]=!0,St.prototype.removeEventListener=function(t,e,n,r){vt(this,t,e,n,r)},St.prototype.M=function(){if(St.Z.M.call(this),this.i){var t,e=this.i;for(t in e.g){for(var n=e.g[t],r=0;r<n.length;r++)ct(n[r]);delete e.g[t],e.h--}}this.I=null},St.prototype.N=function(t,e,n,r){return this.i.add(String(t),e,!1,n,r)},St.prototype.O=function(t,e,n,r){return this.i.add(String(t),e,!0,n,r)};var Nt=l.JSON.stringify;function kt(){var t=Mt;let e=null;return t.g&&(e=t.g,t.g=t.g.next,t.g||(t.h=null),e.next=null),e}var Ct,Dt=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 Ot),(t=>t.reset()));class Ot{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}}function Rt(t){l.setTimeout((()=>{throw t}),0)}function Pt(t,e){Ct||function(){var t=l.Promise.resolve(void 0);Ct=function(){t.then(Vt)}}(),Lt||(Ct(),Lt=!0),Mt.add(t,e)}var Lt=!1,Mt=new class{constructor(){this.h=this.g=null}add(t,e){const n=Dt.get();n.set(t,e),this.h?this.h.next=n:this.g=n,this.h=n}};function Vt(){for(var t;t=kt();){try{t.h.call(t.g)}catch(t){Rt(t)}var e=Dt;e.j(t),100>e.h&&(e.h++,t.next=e.g,e.g=t)}Lt=!1}function Ft(t,e){St.call(this),this.h=t||1,this.g=e||l,this.j=b(this.kb,this),this.l=Date.now()}function Ut(t){t.da=!1,t.S&&(t.g.clearTimeout(t.S),t.S=null)}function jt(t,e,n){if("function"==typeof t)n&&(t=b(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=b(t.handleEvent,t)}return 2147483647<Number(e)?-1:l.setTimeout(t,e||0)}function Bt(t){t.g=jt((()=>{t.g=null,t.i&&(t.i=!1,Bt(t))}),t.j);const e=t.h;t.h=null,t.m.apply(null,e)}I(Ft,St),(r=Ft.prototype).da=!1,r.S=null,r.kb=function(){if(this.da){var t=Date.now()-this.l;0<t&&t<.8*this.h?this.S=this.g.setTimeout(this.j,this.h-t):(this.S&&(this.g.clearTimeout(this.S),this.S=null),At(this,"tick"),this.da&&(Ut(this),this.start()))}},r.start=function(){this.da=!0,this.S||(this.S=this.g.setTimeout(this.j,this.h),this.l=Date.now())},r.M=function(){Ft.Z.M.call(this),Ut(this),delete this.g};class qt extends _{constructor(t,e){super(),this.m=t,this.j=e,this.h=null,this.i=!1,this.g=null}l(t){this.h=arguments,this.g?this.i=!0:Bt(this)}M(){super.M(),this.g&&(l.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function zt(t){_.call(this),this.h=t,this.g={}}I(zt,_);var Kt=[];function Gt(t,e,n,r){Array.isArray(n)||(n&&(Kt[0]=n.toString()),n=Kt);for(var i=0;i<n.length;i++){var s=mt(e,n[i],r||t.handleEvent,!1,t.h||t);if(!s)break;t.g[s.key]=s}}function Wt(t){L(t.g,(function(t,e){this.g.hasOwnProperty(e)&&bt(t)}),t),t.g={}}function $t(){this.g=!0}function Ht(t,e,n,r){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 r=n[t];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<i.length;o++)i[o]=""}}}return Nt(n)}catch(t){return e}}(t,n)+(r?" "+r:"")}))}zt.prototype.M=function(){zt.Z.M.call(this),Wt(this)},zt.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},$t.prototype.Aa=function(){this.g=!1},$t.prototype.info=function(){};var Yt={},Qt=null;function Zt(){return Qt=Qt||new St}function Jt(t){rt.call(this,Yt.Ma,t)}function Xt(t){const e=Zt();At(e,new Jt(e,t))}function te(t,e){rt.call(this,Yt.STAT_EVENT,t),this.stat=e}function ee(t){const e=Zt();At(e,new te(e,t))}function ne(t,e){rt.call(this,Yt.Na,t),this.size=e}function re(t,e){if("function"!=typeof t)throw Error("Fn must not be null and must be a function");return l.setTimeout((function(){t()}),e)}Yt.Ma="serverreachability",I(Jt,rt),Yt.STAT_EVENT="statevent",I(te,rt),Yt.Na="timingevent",I(ne,rt);var ie={NO_ERROR:0,lb:1,yb:2,xb:3,sb:4,wb:5,zb:6,Ja:7,TIMEOUT:8,Cb:9},se={qb:"complete",Mb:"success",Ka:"error",Ja:"abort",Eb:"ready",Fb:"readystatechange",TIMEOUT:"timeout",Ab:"incrementaldata",Db:"progress",tb:"downloadprogress",Ub:"uploadprogress"};function oe(){}function ae(t){return t.h||(t.h=t.i())}function ue(){}oe.prototype.h=null;var ce,he={OPEN:"a",pb:"b",Ka:"c",Bb:"d"};function le(){rt.call(this,"d")}function de(){rt.call(this,"c")}function fe(){}function pe(t,e,n,r){this.l=t,this.j=e,this.m=n,this.X=r||1,this.V=new zt(this),this.P=ge,t=G?125:void 0,this.W=new Ft(t),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.Y=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.N=-1,this.I=!1,this.O=0,this.L=null,this.aa=this.J=this.$=this.U=!1,this.h=new me}function me(){this.i=null,this.g="",this.h=!1}I(le,rt),I(de,rt),I(fe,oe),fe.prototype.g=function(){return new XMLHttpRequest},fe.prototype.i=function(){return{}},ce=new fe;var ge=45e3,ye={},ve={};function be(t,e,n){t.K=1,t.v=qe(Me(e)),t.s=n,t.U=!0,we(t,null)}function we(t,e){t.F=Date.now(),Ee(t),t.A=Me(t.v);var n=t.A,r=t.X;Array.isArray(r)||(r=[String(r)]),en(n.h,"t",r),t.C=0,n=t.l.H,t.h=new me,t.g=nr(t.l,n?e:null,!t.s),0<t.O&&(t.L=new qt(b(t.Ia,t,t.g),t.O)),Gt(t.V,t.g,"readystatechange",t.gb),e=t.H?M(t.H):{},t.s?(t.u||(t.u="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.g.ea(t.A,t.u,t.s,e)):(t.u="GET",t.g.ea(t.A,t.u,null,e)),Xt(1),function(t,e,n,r,i,s){t.info((function(){if(t.g)if(s)for(var o="",a=s.split("&"),u=0;u<a.length;u++){var c=a[u].split("=");if(1<c.length){var h=c[0];c=c[1];var l=h.split("_");o=2<=l.length&&"type"==l[1]?o+(h+"=")+c+"&":o+(h+"=redacted&")}}else o=null;else o=s;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+e+"\n"+n+"\n"+o}))}(t.j,t.u,t.A,t.m,t.X,t.s)}function Ie(t){return!!t.g&&"GET"==t.u&&2!=t.K&&t.l.Ba}function _e(t,e,n){let r,i=!0;for(;!t.I&&t.C<n.length;){if(r=Te(t,n),r==ve){4==e&&(t.o=4,ee(14),i=!1),Ht(t.j,t.m,null,"[Incomplete Response]");break}if(r==ye){t.o=4,ee(15),Ht(t.j,t.m,n,"[Invalid Chunk]"),i=!1;break}Ht(t.j,t.m,r,null),ke(t,r)}Ie(t)&&r!=ve&&r!=ye&&(t.h.g="",t.C=0),4!=e||0!=n.length||t.h.h||(t.o=1,ee(16),i=!1),t.i=t.i&&i,i?0<n.length&&!t.aa&&(t.aa=!0,(e=t.l).g==t&&e.$&&!e.L&&(e.h.info("Great, no buffering proxy detected. Bytes received: "+n.length),Hn(e),e.L=!0,ee(11))):(Ht(t.j,t.m,n,"[Invalid Chunked Response]"),Ne(t),xe(t))}function Te(t,e){var n=t.C,r=e.indexOf("\n",n);return-1==r?ve:(n=Number(e.substring(n,r)),isNaN(n)?ye:(r+=1)+n>e.length?ve:(e=e.substr(r,n),t.C=r+n,e))}function Ee(t){t.Y=Date.now()+t.P,Se(t,t.P)}function Se(t,e){if(null!=t.B)throw Error("WatchDog timer not null");t.B=re(b(t.eb,t),e)}function Ae(t){t.B&&(l.clearTimeout(t.B),t.B=null)}function xe(t){0==t.l.G||t.I||Zn(t.l,t)}function Ne(t){Ae(t);var e=t.L;e&&"function"==typeof e.na&&e.na(),t.L=null,Ut(t.W),Wt(t.V),t.g&&(e=t.g,t.g=null,e.abort(),e.na())}function ke(t,e){try{var n=t.l;if(0!=n.G&&(n.g==t||un(n.i,t)))if(n.I=t.N,!t.J&&un(n.i,t)&&3==n.G){try{var r=n.Ca.g.parse(e)}catch(t){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){t:if(!n.u){if(n.g){if(!(n.g.F+3e3<t.F))break t;Qn(n),Un(n)}$n(n),ee(18)}}else n.ta=i[1],0<n.ta-n.U&&37500>i[2]&&n.N&&0==n.A&&!n.v&&(n.v=re(b(n.ab,n),6e3));if(1>=an(n.i)&&n.ka){try{n.ka()}catch(t){}n.ka=void 0}}else Xn(n,11)}else if((t.J||n.g==t)&&Qn(n),!N(e))for(i=n.Ca.g.parse(e),e=0;e<i.length;e++){let c=i[e];if(n.U=c[0],c=c[1],2==n.G)if("c"==c[0]){n.J=c[1],n.la=c[2];const e=c[3];null!=e&&(n.ma=e,n.h.info("VER="+n.ma));const i=c[4];null!=i&&(n.za=i,n.h.info("SVER="+n.za));const h=c[5];null!=h&&"number"==typeof h&&0<h&&(r=1.5*h,n.K=r,n.h.info("backChannelRequestTimeoutMs_="+r)),r=n;const l=t.g;if(l){const t=l.g?l.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(t){var s=r.i;!s.g&&(D(t,"spdy")||D(t,"quic")||D(t,"h2"))&&(s.j=s.l,s.g=new Set,s.h&&(cn(s,s.h),s.h=null))}if(r.D){const t=l.g?l.g.getResponseHeader("X-HTTP-Session-Id"):null;t&&(r.sa=t,Be(r.F,r.D,t))}}n.G=3,n.j&&n.j.xa(),n.$&&(n.O=Date.now()-t.F,n.h.info("Handshake RTT: "+n.O+"ms"));var o=t;if((r=n).oa=er(r,r.H?r.la:null,r.W),o.J){hn(r.i,o);var a=o,u=r.K;u&&a.setTimeout(u),a.B&&(Ae(a),Ee(a)),r.g=o}else Wn(r);0<n.l.length&&qn(n)}else"stop"!=c[0]&&"close"!=c[0]||Xn(n,7);else 3==n.G&&("stop"==c[0]||"close"==c[0]?"stop"==c[0]?Xn(n,7):Fn(n):"noop"!=c[0]&&n.j&&n.j.wa(c),n.A=0)}Xt(4)}catch(t){}}function Ce(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(f(t)||"string"==typeof t)S(t,e,void 0);else{if(t.T&&"function"==typeof t.T)var n=t.T();else if(t.R&&"function"==typeof t.R)n=void 0;else if(f(t)||"string"==typeof t){n=[];for(var r=t.length,i=0;i<r;i++)n.push(i)}else for(i in n=[],r=0,t)n[r++]=i;r=function(t){if(t.R&&"function"==typeof t.R)return t.R();if("string"==typeof t)return t.split("");if(f(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t),i=r.length;for(var s=0;s<i;s++)e.call(void 0,r[s],n&&n[s],t)}}function De(t,e){this.h={},this.g=[],this.i=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(t)if(t instanceof De)for(n=t.T(),r=0;r<n.length;r++)this.set(n[r],t.get(n[r]));else for(r in t)this.set(r,t[r])}function Oe(t){if(t.i!=t.g.length){for(var e=0,n=0;e<t.g.length;){var r=t.g[e];Re(t.h,r)&&(t.g[n++]=r),e++}t.g.length=n}if(t.i!=t.g.length){var i={};for(n=e=0;e<t.g.length;)Re(i,r=t.g[e])||(t.g[n++]=r,i[r]=1),e++;t.g.length=n}}function Re(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(r=pe.prototype).setTimeout=function(t){this.P=t},r.gb=function(t){t=t.target;const e=this.L;e&&3==Rn(t)?e.l():this.Ia(t)},r.Ia=function(t){try{if(t==this.g)t:{const h=Rn(this.g);var e=this.g.Da();const d=this.g.ba();if(!(3>h)&&(3!=h||G||this.g&&(this.h.h||this.g.ga()||Pn(this.g)))){this.I||4!=h||7==e||Xt(8==e||0>=d?3:2),Ae(this);var n=this.g.ba();this.N=n;e:if(Ie(this)){var r=Pn(this.g);t="";var i=r.length,s=4==Rn(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Ne(this),xe(this);var o="";break e}this.h.i=new l.TextDecoder}for(e=0;e<i;e++)this.h.h=!0,t+=this.h.i.decode(r[e],{stream:s&&e==i-1});r.splice(0,i),this.h.g+=t,this.C=0,o=this.h.g}else o=this.g.ga();if(this.i=200==n,function(t,e,n,r,i,s,o){t.info((function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+e+"\n"+n+"\n"+s+" "+o}))}(this.j,this.u,this.A,this.m,this.X,h,n),this.i){if(this.$&&!this.J){e:{if(this.g){var a,u=this.g;if((a=u.g?u.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!N(a)){var c=a;break e}}c=null}if(!(n=c)){this.i=!1,this.o=3,ee(12),Ne(this),xe(this);break t}Ht(this.j,this.m,n,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,ke(this,n)}this.U?(_e(this,h,o),G&&this.i&&3==h&&(Gt(this.V,this.W,"tick",this.fb),this.W.start())):(Ht(this.j,this.m,o,null),ke(this,o)),4==h&&Ne(this),this.i&&!this.I&&(4==h?Zn(this.l,this):(this.i=!1,Ee(this)))}else 400==n&&0<o.indexOf("Unknown SID")?(this.o=3,ee(12)):(this.o=0,ee(13)),Ne(this),xe(this)}}}catch(t){}},r.fb=function(){if(this.g){var t=Rn(this.g),e=this.g.ga();this.C<e.length&&(Ae(this),_e(this,t,e),this.i&&4!=t&&Ee(this))}},r.cancel=function(){this.I=!0,Ne(this)},r.eb=function(){this.B=null;const t=Date.now();0<=t-this.Y?(function(t,e){t.info((function(){return"TIMEOUT: "+e}))}(this.j,this.A),2!=this.K&&(Xt(3),ee(17)),Ne(this),this.o=2,xe(this)):Se(this,this.Y-t)},(r=De.prototype).R=function(){Oe(this);for(var t=[],e=0;e<this.g.length;e++)t.push(this.h[this.g[e]]);return t},r.T=function(){return Oe(this),this.g.concat()},r.get=function(t,e){return Re(this.h,t)?this.h[t]:e},r.set=function(t,e){Re(this.h,t)||(this.i++,this.g.push(t)),this.h[t]=e},r.forEach=function(t,e){for(var n=this.T(),r=0;r<n.length;r++){var i=n[r],s=this.get(i);t.call(e,s,i,this)}};var Pe=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Le(t,e){if(this.i=this.s=this.j="",this.m=null,this.o=this.l="",this.g=!1,t instanceof Le){this.g=void 0!==e?e:t.g,Ve(this,t.j),this.s=t.s,Fe(this,t.i),Ue(this,t.m),this.l=t.l,e=t.h;var n=new Ze;n.i=e.i,e.g&&(n.g=new De(e.g),n.h=e.h),je(this,n),this.o=t.o}else t&&(n=String(t).match(Pe))?(this.g=!!e,Ve(this,n[1]||"",!0),this.s=ze(n[2]||""),Fe(this,n[3]||"",!0),Ue(this,n[4]),this.l=ze(n[5]||"",!0),je(this,n[6]||"",!0),this.o=ze(n[7]||"")):(this.g=!!e,this.h=new Ze(null,this.g))}function Me(t){return new Le(t)}function Ve(t,e,n){t.j=n?ze(e,!0):e,t.j&&(t.j=t.j.replace(/:$/,""))}function Fe(t,e,n){t.i=n?ze(e,!0):e}function Ue(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.m=e}else t.m=null}function je(t,e,n){e instanceof Ze?(t.h=e,function(t,e){e&&!t.j&&(Je(t),t.i=null,t.g.forEach((function(t,e){var n=e.toLowerCase();e!=n&&(Xe(this,e),en(this,n,t))}),t)),t.j=e}(t.h,t.g)):(n||(e=Ke(e,Ye)),t.h=new Ze(e,t.g))}function Be(t,e,n){t.h.set(e,n)}function qe(t){return Be(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),t}function ze(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Ke(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,Ge),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function Ge(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}Le.prototype.toString=function(){var t=[],e=this.j;e&&t.push(Ke(e,We,!0),":");var n=this.i;return(n||"file"==e)&&(t.push("//"),(e=this.s)&&t.push(Ke(e,We,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&&t.push(":",String(n))),(n=this.l)&&(this.i&&"/"!=n.charAt(0)&&t.push("/"),t.push(Ke(n,"/"==n.charAt(0)?He:$e,!0))),(n=this.h.toString())&&t.push("?",n),(n=this.o)&&t.push("#",Ke(n,Qe)),t.join("")};var We=/[#\/\?@]/g,$e=/[#\?:]/g,He=/[#\?]/g,Ye=/[#\?@]/g,Qe=/#/g;function Ze(t,e){this.h=this.g=null,this.i=t||null,this.j=!!e}function Je(t){t.g||(t.g=new De,t.h=0,t.i&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var s=t[n].substring(0,r);i=t[n].substring(r+1)}else s=t[n];e(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(t.i,(function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)})))}function Xe(t,e){Je(t),e=nn(t,e),Re(t.g.h,e)&&(t.i=null,t.h-=t.g.get(e).length,Re((t=t.g).h,e)&&(delete t.h[e],t.i--,t.g.length>2*t.i&&Oe(t)))}function tn(t,e){return Je(t),e=nn(t,e),Re(t.g.h,e)}function en(t,e,n){Xe(t,e),0<n.length&&(t.i=null,t.g.set(nn(t,e),x(n)),t.h+=n.length)}function nn(t,e){return e=String(e),t.j&&(e=e.toLowerCase()),e}function rn(t){this.l=t||sn,t=l.PerformanceNavigationTiming?0<(t=l.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(l.g&&l.g.Ea&&l.g.Ea()&&l.g.Ea().Zb),this.j=t?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}(r=Ze.prototype).add=function(t,e){Je(this),this.i=null,t=nn(this,t);var n=this.g.get(t);return n||this.g.set(t,n=[]),n.push(e),this.h+=1,this},r.forEach=function(t,e){Je(this),this.g.forEach((function(n,r){S(n,(function(n){t.call(e,n,r,this)}),this)}),this)},r.T=function(){Je(this);for(var t=this.g.R(),e=this.g.T(),n=[],r=0;r<e.length;r++)for(var i=t[r],s=0;s<i.length;s++)n.push(e[r]);return n},r.R=function(t){Je(this);var e=[];if("string"==typeof t)tn(this,t)&&(e=A(e,this.g.get(nn(this,t))));else{t=this.g.R();for(var n=0;n<t.length;n++)e=A(e,t[n])}return e},r.set=function(t,e){return Je(this),this.i=null,tn(this,t=nn(this,t))&&(this.h-=this.g.get(t).length),this.g.set(t,[e]),this.h+=1,this},r.get=function(t,e){return t&&0<(t=this.R(t)).length?String(t[0]):e},r.toString=function(){if(this.i)return this.i;if(!this.g)return"";for(var t=[],e=this.g.T(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.R(r);for(var s=0;s<r.length;s++){var o=i;""!==r[s]&&(o+="="+encodeURIComponent(String(r[s]))),t.push(o)}}return this.i=t.join("&")};var sn=10;function on(t){return!!t.h||!!t.g&&t.g.size>=t.j}function an(t){return t.h?1:t.g?t.g.size:0}function un(t,e){return t.h?t.h==e:!!t.g&&t.g.has(e)}function cn(t,e){t.g?t.g.add(e):t.h=e}function hn(t,e){t.h&&t.h==e?t.h=null:t.g&&t.g.has(e)&&t.g.delete(e)}function ln(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 x(t.i)}function dn(){}function fn(){this.g=new dn}function pn(t,e,n){const r=n||"";try{Ce(t,(function(t,n){let i=t;p(t)&&(i=Nt(t)),e.push(r+n+"="+encodeURIComponent(i))}))}catch(t){throw e.push(r+"type="+encodeURIComponent("_badmap")),t}}function mn(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}function gn(t){this.l=t.$b||null,this.j=t.ib||!1}function yn(t,e){St.call(this),this.D=t,this.u=e,this.m=void 0,this.readyState=vn,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}rn.prototype.cancel=function(){if(this.i=ln(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()}},dn.prototype.stringify=function(t){return l.JSON.stringify(t,void 0)},dn.prototype.parse=function(t){return l.JSON.parse(t,void 0)},I(gn,oe),gn.prototype.g=function(){return new yn(this.l,this.j)},gn.prototype.i=function(t){return function(){return t}}({}),I(yn,St);var vn=0;function bn(t){t.j.read().then(t.Sa.bind(t)).catch(t.ha.bind(t))}function wn(t){t.readyState=4,t.l=null,t.j=null,t.A=null,In(t)}function In(t){t.onreadystatechange&&t.onreadystatechange.call(t)}(r=yn.prototype).open=function(t,e){if(this.readyState!=vn)throw this.abort(),Error("Error reopening a connection");this.C=t,this.B=e,this.readyState=1,In(this)},r.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const e={headers:this.v,method:this.C,credentials:this.m,cache:void 0};t&&(e.body=t),(this.D||l).fetch(new Request(this.B,e)).then(this.Va.bind(this),this.ha.bind(this))},r.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted."),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,wn(this)),this.readyState=vn},r.Va=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,In(this)),this.g&&(this.readyState=3,In(this),this.g)))if("arraybuffer"===this.responseType)t.arrayBuffer().then(this.Ta.bind(this),this.ha.bind(this));else if(void 0!==l.ReadableStream&&"body"in t){if(this.j=t.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;bn(this)}else t.text().then(this.Ua.bind(this),this.ha.bind(this))},r.Sa=function(t){if(this.g){if(this.u&&t.value)this.response.push(t.value);else if(!this.u){var e=t.value?t.value:new Uint8Array(0);(e=this.A.decode(e,{stream:!t.done}))&&(this.response=this.responseText+=e)}t.done?wn(this):In(this),3==this.readyState&&bn(this)}},r.Ua=function(t){this.g&&(this.response=this.responseText=t,wn(this))},r.Ta=function(t){this.g&&(this.response=t,wn(this))},r.ha=function(){this.g&&wn(this)},r.setRequestHeader=function(t,e){this.v.append(t,e)},r.getResponseHeader=function(t){return this.h&&this.h.get(t.toLowerCase())||""},r.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(yn.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(t){this.m=t?"include":"same-origin"}});var _n=l.JSON.parse;function Tn(t){St.call(this),this.headers=new De,this.u=t||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=En,this.K=this.L=!1}I(Tn,St);var En="",Sn=/^https?$/i,An=["POST","PUT"];function xn(t){return"content-type"==t.toLowerCase()}function Nn(t,e){t.h=!1,t.g&&(t.l=!0,t.g.abort(),t.l=!1),t.j=e,t.m=5,kn(t),Dn(t)}function kn(t){t.D||(t.D=!0,At(t,"complete"),At(t,"error"))}function Cn(t){if(t.h&&void 0!==h&&(!t.C[1]||4!=Rn(t)||2!=t.ba()))if(t.v&&4==Rn(t))jt(t.Fa,0,t);else if(At(t,"readystatechange"),4==Rn(t)){t.h=!1;try{const a=t.ba();t:switch(a){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===a){var i=String(t.H).match(Pe)[1]||null;if(!i&&l.self&&l.self.location){var s=l.self.location.protocol;i=s.substr(0,s.length-1)}r=!Sn.test(i?i.toLowerCase():"")}n=r}if(n)At(t,"complete"),At(t,"success");else{t.m=6;try{var o=2<Rn(t)?t.g.statusText:""}catch(t){o=""}t.j=o+" ["+t.ba()+"]",kn(t)}}finally{Dn(t)}}}function Dn(t,e){if(t.g){On(t);const n=t.g,r=t.C[0]?d:null;t.g=null,t.C=null,e||At(t,"ready");try{n.onreadystatechange=r}catch(t){}}}function On(t){t.g&&t.K&&(t.g.ontimeout=null),t.A&&(l.clearTimeout(t.A),t.A=null)}function Rn(t){return t.g?t.g.readyState:0}function Pn(t){try{if(!t.g)return null;if("response"in t.g)return t.g.response;switch(t.J){case En:case"text":return t.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in t.g)return t.g.mozResponseArrayBuffer}return null}catch(t){return null}}function Ln(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}r||(n=function(t){let e="";return L(t,(function(t,n){e+=n,e+=":",e+=t,e+="\r\n"})),e}(n),"string"==typeof t?null!=n&&encodeURIComponent(String(n)):Be(t,e,n))}function Mn(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function Vn(t){this.za=0,this.l=[],this.h=new $t,this.la=this.oa=this.F=this.W=this.g=this.sa=this.D=this.aa=this.o=this.P=this.s=null,this.Za=this.V=0,this.Xa=Mn("failFast",!1,t),this.N=this.v=this.u=this.m=this.j=null,this.X=!0,this.I=this.ta=this.U=-1,this.Y=this.A=this.C=0,this.Pa=Mn("baseRetryDelayMs",5e3,t),this.$a=Mn("retryDelaySeedMs",1e4,t),this.Ya=Mn("forwardChannelMaxRetries",2,t),this.ra=Mn("forwardChannelRequestTimeoutMs",2e4,t),this.qa=t&&t.xmlHttpFactory||void 0,this.Ba=t&&t.Yb||!1,this.K=void 0,this.H=t&&t.supportsCrossDomainXhr||!1,this.J="",this.i=new rn(t&&t.concurrentRequestLimit),this.Ca=new fn,this.ja=t&&t.fastHandshake||!1,this.Ra=t&&t.Wb||!1,t&&t.Aa&&this.h.Aa(),t&&t.forceLongPolling&&(this.X=!1),this.$=!this.ja&&this.X&&t&&t.detectBufferingProxy||!1,this.ka=void 0,this.O=0,this.L=!1,this.B=null,this.Wa=!t||!1!==t.Xb}function Fn(t){if(jn(t),3==t.G){var e=t.V++,n=Me(t.F);Be(n,"SID",t.J),Be(n,"RID",e),Be(n,"TYPE","terminate"),Kn(t,n),(e=new pe(t,t.h,e,void 0)).K=2,e.v=qe(Me(n)),n=!1,l.navigator&&l.navigator.sendBeacon&&(n=l.navigator.sendBeacon(e.v.toString(),"")),!n&&l.Image&&((new Image).src=e.v,n=!0),n||(e.g=nr(e.l,null),e.g.ea(e.v)),e.F=Date.now(),Ee(e)}tr(t)}function Un(t){t.g&&(Hn(t),t.g.cancel(),t.g=null)}function jn(t){Un(t),t.u&&(l.clearTimeout(t.u),t.u=null),Qn(t),t.i.cancel(),t.m&&("number"==typeof t.m&&l.clearTimeout(t.m),t.m=null)}function Bn(t,e){t.l.push(new class{constructor(t,e){this.h=t,this.g=e}}(t.Za++,e)),3==t.G&&qn(t)}function qn(t){on(t.i)||t.m||(t.m=!0,Pt(t.Ha,t),t.C=0)}function zn(t,e){var n;n=e?e.m:t.V++;const r=Me(t.F);Be(r,"SID",t.J),Be(r,"RID",n),Be(r,"AID",t.U),Kn(t,r),t.o&&t.s&&Ln(r,t.o,t.s),n=new pe(t,t.h,n,t.C+1),null===t.o&&(n.H=t.s),e&&(t.l=e.D.concat(t.l)),e=Gn(t,n,1e3),n.setTimeout(Math.round(.5*t.ra)+Math.round(.5*t.ra*Math.random())),cn(t.i,n),be(n,r,e)}function Kn(t,e){t.j&&Ce({},(function(t,n){Be(e,n,t)}))}function Gn(t,e,n){n=Math.min(t.l.length,n);var r=t.j?b(t.j.Oa,t.j,t):null;t:{var i=t.l;let e=-1;for(;;){const t=["count="+n];-1==e?0<n?(e=i[0].h,t.push("ofs="+e)):e=0:t.push("ofs="+e);let s=!0;for(let o=0;o<n;o++){let n=i[o].h;const a=i[o].g;if(n-=e,0>n)e=Math.max(0,i[o].h-100),s=!1;else try{pn(a,t,"req"+n+"_")}catch(t){r&&r(a)}}if(s){r=t.join("&");break t}}}return t=t.l.splice(0,n),e.D=t,r}function Wn(t){t.g||t.u||(t.Y=1,Pt(t.Ga,t),t.A=0)}function $n(t){return!(t.g||t.u||3<=t.A||(t.Y++,t.u=re(b(t.Ga,t),Jn(t,t.A)),t.A++,0))}function Hn(t){null!=t.B&&(l.clearTimeout(t.B),t.B=null)}function Yn(t){t.g=new pe(t,t.h,"rpc",t.Y),null===t.o&&(t.g.H=t.s),t.g.O=0;var e=Me(t.oa);Be(e,"RID","rpc"),Be(e,"SID",t.J),Be(e,"CI",t.N?"0":"1"),Be(e,"AID",t.U),Kn(t,e),Be(e,"TYPE","xmlhttp"),t.o&&t.s&&Ln(e,t.o,t.s),t.K&&t.g.setTimeout(t.K);var n=t.g;t=t.la,n.K=1,n.v=qe(Me(e)),n.s=null,n.U=!0,we(n,t)}function Qn(t){null!=t.v&&(l.clearTimeout(t.v),t.v=null)}function Zn(t,e){var n=null;if(t.g==e){Qn(t),Hn(t),t.g=null;var r=2}else{if(!un(t.i,e))return;n=e.D,hn(t.i,e),r=1}if(t.I=e.N,0!=t.G)if(e.i)if(1==r){n=e.s?e.s.length:0,e=Date.now()-e.F;var i=t.C;At(r=Zt(),new ne(r,n,e,i)),qn(t)}else Wn(t);else if(3==(i=e.o)||0==i&&0<t.I||!(1==r&&function(t,e){return!(an(t.i)>=t.i.j-(t.m?1:0)||(t.m?(t.l=e.D.concat(t.l),0):1==t.G||2==t.G||t.C>=(t.Xa?0:t.Ya)||(t.m=re(b(t.Ha,t,e),Jn(t,t.C)),t.C++,0)))}(t,e)||2==r&&$n(t)))switch(n&&0<n.length&&(e=t.i,e.i=e.i.concat(n)),i){case 1:Xn(t,5);break;case 4:Xn(t,10);break;case 3:Xn(t,6);break;default:Xn(t,2)}}function Jn(t,e){let n=t.Pa+Math.floor(Math.random()*t.$a);return t.j||(n*=2),n*e}function Xn(t,e){if(t.h.info("Error code "+e),2==e){var n=null;t.j&&(n=null);var r=b(t.jb,t);n||(n=new Le("//www.google.com/images/cleardot.gif"),l.location&&"http"==l.location.protocol||Ve(n,"https"),qe(n)),function(t,e){const n=new $t;if(l.Image){const r=new Image;r.onload=w(mn,n,r,"TestLoadImage: loaded",!0,e),r.onerror=w(mn,n,r,"TestLoadImage: error",!1,e),r.onabort=w(mn,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=w(mn,n,r,"TestLoadImage: timeout",!1,e),l.setTimeout((function(){r.ontimeout&&r.ontimeout()}),1e4),r.src=t}else e(!1)}(n.toString(),r)}else ee(2);t.G=0,t.j&&t.j.va(e),tr(t),jn(t)}function tr(t){t.G=0,t.I=-1,t.j&&(0==ln(t.i).length&&0==t.l.length||(t.i.i.length=0,x(t.l),t.l.length=0),t.j.ua())}function er(t,e,n){let r=function(t){return t instanceof Le?Me(t):new Le(t,void 0)}(n);if(""!=r.i)e&&Fe(r,e+"."+r.i),Ue(r,r.m);else{const t=l.location;r=function(t,e,n,r){var i=new Le(null,void 0);return t&&Ve(i,t),e&&Fe(i,e),n&&Ue(i,n),r&&(i.l=r),i}(t.protocol,e?e+"."+t.hostname:t.hostname,+t.port,n)}return t.aa&&L(t.aa,(function(t,e){Be(r,e,t)})),e=t.D,n=t.sa,e&&n&&Be(r,e,n),Be(r,"VER",t.ma),Kn(t,r),r}function nr(t,e,n){if(e&&!t.H)throw Error("Can't create secondary domain capable XhrIo object.");return(e=n&&t.Ba&&!t.qa?new Tn(new gn({ib:!0})):new Tn(t.qa)).L=t.H,e}function rr(){}function ir(){if(z&&!(10<=Number(et)))throw Error("Environmental error: no available transport.")}function sr(t,e){St.call(this),this.g=new Vn(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.s=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.ya&&(t?t["X-WebChannel-Client-Profile"]=e.ya:t={"X-WebChannel-Client-Profile":e.ya}),this.g.P=t,(t=e&&e.httpHeadersOverwriteParam)&&!N(t)&&(this.g.o=t),this.A=e&&e.supportsCrossDomainXhr||!1,this.v=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!N(e)&&(this.g.D=e,null!==(t=this.h)&&e in t&&e in(t=this.h)&&delete t[e]),this.j=new ur(this)}function or(t){le.call(this);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 ar(){de.call(this),this.status=1}function ur(t){this.g=t}(r=Tn.prototype).ea=function(t,e,n,r){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+t);e=e?e.toUpperCase():"GET",this.H=t,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=this.u?this.u.g():ce.g(),this.C=this.u?ae(this.u):ae(ce),this.g.onreadystatechange=b(this.Fa,this);try{this.F=!0,this.g.open(e,String(t),!0),this.F=!1}catch(t){return void Nn(this,t)}t=n||"";const i=new De(this.headers);r&&Ce(r,(function(t,e){i.set(e,t)})),r=function(t){t:{var e=xn;const n=t.length,r="string"==typeof t?t.split(""):t;for(let i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t)){e=i;break t}e=-1}return 0>e?null:"string"==typeof t?t.charAt(e):t[e]}(i.T()),n=l.FormData&&t instanceof l.FormData,!(0<=E(An,e))||r||n||i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach((function(t,e){this.g.setRequestHeader(e,t)}),this),this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{On(this),0<this.B&&((this.K=function(t){return z&&tt()&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(this.g))?(this.g.timeout=this.B,this.g.ontimeout=b(this.pa,this)):this.A=jt(this.pa,this.B,this)),this.v=!0,this.g.send(t),this.v=!1}catch(t){Nn(this,t)}},r.pa=function(){void 0!==h&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,At(this,"timeout"),this.abort(8))},r.abort=function(t){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=t||7,At(this,"complete"),At(this,"abort"),Dn(this))},r.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),Dn(this,!0)),Tn.Z.M.call(this)},r.Fa=function(){this.s||(this.F||this.v||this.l?Cn(this):this.cb())},r.cb=function(){Cn(this)},r.ba=function(){try{return 2<Rn(this)?this.g.status:-1}catch(t){return-1}},r.ga=function(){try{return this.g?this.g.responseText:""}catch(t){return""}},r.Qa=function(t){if(this.g){var e=this.g.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),_n(e)}},r.Da=function(){return this.m},r.La=function(){return"string"==typeof this.j?this.j:String(this.j)},(r=Vn.prototype).ma=8,r.G=1,r.hb=function(t){try{this.h.info("Origin Trials invoked: "+t)}catch(t){}},r.Ha=function(t){if(this.m)if(this.m=null,1==this.G){if(!t){this.V=Math.floor(1e5*Math.random()),t=this.V++;const i=new pe(this,this.h,t,void 0);let s=this.s;if(this.P&&(s?(s=M(s),F(s,this.P)):s=this.P),null===this.o&&(i.H=s),this.ja)t:{for(var e=0,n=0;n<this.l.length;n++){var r=this.l[n];if(void 0===(r="__data__"in r.g&&"string"==typeof(r=r.g.__data__)?r.length:void 0))break;if(4096<(e+=r)){e=n;break t}if(4096===e||n===this.l.length-1){e=n+1;break t}}e=1e3}else e=1e3;e=Gn(this,i,e),Be(n=Me(this.F),"RID",t),Be(n,"CVER",22),this.D&&Be(n,"X-HTTP-Session-Id",this.D),Kn(this,n),this.o&&s&&Ln(n,this.o,s),cn(this.i,i),this.Ra&&Be(n,"TYPE","init"),this.ja?(Be(n,"$req",e),Be(n,"SID","null"),i.$=!0,be(i,n,null)):be(i,n,e),this.G=2}}else 3==this.G&&(t?zn(this,t):0==this.l.length||on(this.i)||zn(this))},r.Ga=function(){if(this.u=null,Yn(this),this.$&&!(this.L||null==this.g||0>=this.O)){var t=2*this.O;this.h.info("BP detection timer enabled: "+t),this.B=re(b(this.bb,this),t)}},r.bb=function(){this.B&&(this.B=null,this.h.info("BP detection timeout reached."),this.h.info("Buffering proxy detected and switch to long-polling!"),this.N=!1,this.L=!0,ee(10),Un(this),Yn(this))},r.ab=function(){null!=this.v&&(this.v=null,Un(this),$n(this),ee(19))},r.jb=function(t){t?(this.h.info("Successfully pinged google.com"),ee(2)):(this.h.info("Failed to ping google.com"),ee(1))},(r=rr.prototype).xa=function(){},r.wa=function(){},r.va=function(){},r.ua=function(){},r.Oa=function(){},ir.prototype.g=function(t,e){return new sr(t,e)},I(sr,St),sr.prototype.m=function(){this.g.j=this.j,this.A&&(this.g.H=!0);var t=this.g,e=this.l,n=this.h||void 0;t.Wa&&(t.h.info("Origin Trials enabled."),Pt(b(t.hb,t,e))),ee(0),t.W=e,t.aa=n||{},t.N=t.X,t.F=er(t,null,t.W),qn(t)},sr.prototype.close=function(){Fn(this.g)},sr.prototype.u=function(t){if("string"==typeof t){var e={};e.__data__=t,Bn(this.g,e)}else this.v?((e={}).__data__=Nt(t),Bn(this.g,e)):Bn(this.g,t)},sr.prototype.M=function(){this.g.j=null,delete this.j,Fn(this.g),delete this.g,sr.Z.M.call(this)},I(or,le),I(ar,de),I(ur,rr),ur.prototype.xa=function(){At(this.g,"a")},ur.prototype.wa=function(t){At(this.g,new or(t))},ur.prototype.va=function(t){At(this.g,new ar(t))},ur.prototype.ua=function(){At(this.g,"b")},ir.prototype.createWebChannel=ir.prototype.g,sr.prototype.send=sr.prototype.u,sr.prototype.open=sr.prototype.m,sr.prototype.close=sr.prototype.close,ie.NO_ERROR=0,ie.TIMEOUT=8,ie.HTTP_ERROR=6,se.COMPLETE="complete",ue.EventType=he,he.OPEN="a",he.CLOSE="b",he.ERROR="c",he.MESSAGE="d",St.prototype.listen=St.prototype.N,Tn.prototype.listenOnce=Tn.prototype.O,Tn.prototype.getLastError=Tn.prototype.La,Tn.prototype.getLastErrorCode=Tn.prototype.Da,Tn.prototype.getStatus=Tn.prototype.ba,Tn.prototype.getResponseJson=Tn.prototype.Qa,Tn.prototype.getResponseText=Tn.prototype.ga,Tn.prototype.send=Tn.prototype.ea;var cr=c.createWebChannelTransport=function(){return new ir},hr=c.getStatEventTarget=function(){return Zt()},lr=c.ErrorCode=ie,dr=c.EventType=se,fr=c.Event=Yt,pr=c.Stat={rb:0,ub:1,vb:2,Ob:3,Tb:4,Qb:5,Rb:6,Pb:7,Nb:8,Sb:9,PROXY:10,NOPROXY:11,Lb:12,Hb:13,Ib:14,Gb:15,Jb:16,Kb:17,nb:18,mb:19,ob:20},mr=c.FetchXmlHttpFactory=gn,gr=c.WebChannel=ue,yr=c.XhrIo=Tn;const vr="@firebase/firestore";class br{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}}br.UNAUTHENTICATED=new br(null),br.GOOGLE_CREDENTIALS=new br("google-credentials-uid"),br.FIRST_PARTY=new br("first-party-uid"),br.MOCK_USER=new br("mock-user");let wr="9.8.0";const Ir=new o.Yd("@firebase/firestore");function _r(){return Ir.logLevel}function Tr(t){Ir.setLogLevel(t)}function Er(t,...e){if(Ir.logLevel<=o.in.DEBUG){const n=e.map(xr);Ir.debug(`Firestore (${wr}): ${t}`,...n)}}function Sr(t,...e){if(Ir.logLevel<=o.in.ERROR){const n=e.map(xr);Ir.error(`Firestore (${wr}): ${t}`,...n)}}function Ar(t,...e){if(Ir.logLevel<=o.in.WARN){const n=e.map(xr);Ir.warn(`Firestore (${wr}): ${t}`,...n)}}function xr(t){if("string"==typeof t)return t;try{return e=t,JSON.stringify(e)}catch(e){return t}var e}function Nr(t="Unexpected state"){const e=`FIRESTORE (${wr}) INTERNAL ASSERTION FAILED: `+t;throw Sr(e),new Error(e)}function kr(t,e){t||Nr()}function Cr(t,e){t||Nr()}function Dr(t,e){return t}const Or={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class Rr extends a.ZR{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class Pr{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}class Lr{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class Mr{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable((()=>e(br.UNAUTHENTICATED)))}shutdown(){}}class Vr{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable((()=>e(this.token.user)))}shutdown(){this.changeListener=null}}class Fr{constructor(t){this.t=t,this.currentUser=br.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,e){let n=this.i;const r=t=>this.i!==n?(n=this.i,e(t)):Promise.resolve();let i=new Pr;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new Pr,t.enqueueRetryable((()=>r(this.currentUser)))};const s=()=>{const e=i;t.enqueueRetryable((async()=>{await e.promise,await r(this.currentUser)}))},o=t=>{Er("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=t,this.auth.addAuthTokenListener(this.o),s()};this.t.onInit((t=>o(t))),setTimeout((()=>{if(!this.auth){const t=this.t.getImmediate({optional:!0});t?o(t):(Er("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new Pr)}}),0),s()}getToken(){const t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then((e=>this.i!==t?(Er("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):e?(kr("string"==typeof e.accessToken),new Lr(e.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){const t=this.auth&&this.auth.getUid();return kr(null===t||"string"==typeof t),new br(t)}}class Ur{constructor(t,e,n){this.type="FirstParty",this.user=br.FIRST_PARTY,this.headers=new Map,this.headers.set("X-Goog-AuthUser",e);const r=t.auth.getAuthHeaderValueForFirstParty([]);r&&this.headers.set("Authorization",r),n&&this.headers.set("X-Goog-Iam-Authorization-Token",n)}}class jr{constructor(t,e,n){this.h=t,this.l=e,this.m=n}getToken(){return Promise.resolve(new Ur(this.h,this.l,this.m))}start(t,e){t.enqueueRetryable((()=>e(br.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class Br{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class qr{constructor(t){this.g=t,this.forceRefresh=!1,this.appCheck=null,this.p=null}start(t,e){const n=t=>{null!=t.error&&Er("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${t.error.message}`);const n=t.token!==this.p;return this.p=t.token,Er("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?e(t.token):Promise.resolve()};this.o=e=>{t.enqueueRetryable((()=>n(e)))};const r=t=>{Er("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=t,this.appCheck.addTokenListener(this.o)};this.g.onInit((t=>r(t))),setTimeout((()=>{if(!this.appCheck){const t=this.g.getImmediate({optional:!0});t?r(t):Er("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){const t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then((t=>t?(kr("string"==typeof t.token),this.p=t.token,new Br(t.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}class zr{getToken(){return Promise.resolve(new Br(""))}invalidateToken(){}start(t,e){}shutdown(){}}class Kr{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=t=>this.I(t),this.T=t=>e.writeSequenceNumber(t))}I(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.T&&this.T(t),t}}function Gr(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 e=0;e<t;e++)n[e]=Math.floor(256*Math.random());return n}Kr.A=-1;class Wr{static R(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length;let n="";for(;n.length<20;){const r=Gr(40);for(let i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%t.length))}return n}}function $r(t,e){return t<e?-1:t>e?1:0}function Hr(t,e,n){return t.length===e.length&&t.every(((t,r)=>n(t,e[r])))}function Yr(t){return t+"\0"}class Qr{constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new Rr(Or.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}static now(){return Qr.fromMillis(Date.now())}static fromDate(t){return Qr.fromMillis(t.getTime())}static fromMillis(t){const e=Math.floor(t/1e3),n=Math.floor(1e6*(t-1e3*e));return new Qr(e,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(t){return this.seconds===t.seconds?$r(this.nanoseconds,t.nanoseconds):$r(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{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class Zr{constructor(t){this.timestamp=t}static fromTimestamp(t){return new Zr(t)}static min(){return new Zr(new Qr(0,0))}static max(){return new Zr(new Qr(253402300799,999999999))}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 Jr(t){let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function Xr(t,e){for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function ti(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}class ei{constructor(t,e,n){void 0===e?e=0:e>t.length&&Nr(),void 0===n?n=t.length-e:n>t.length-e&&Nr(),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return 0===ei.comparator(this,t)}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof ei?t.forEach((t=>{e.push(t)})):e.push(t),this.construct(e)}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(t,e){const n=Math.min(t.length,e.length);for(let r=0;r<n;r++){const n=t.get(r),i=e.get(r);if(n<i)return-1;if(n>i)return 1}return t.length<e.length?-1:t.length>e.length?1:0}}class ni extends ei{construct(t,e,n){return new ni(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new Rr(Or.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter((t=>t.length>0)))}return new ni(e)}static emptyPath(){return new ni([])}}const ri=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ii extends ei{construct(t,e,n){return new ii(t,e,n)}static isValidIdentifier(t){return ri.test(t)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ii.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new ii(["__name__"])}static fromServerFormat(t){const e=[];let n="",r=0;const i=()=>{if(0===n.length)throw new Rr(Or.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let s=!1;for(;r<t.length;){const e=t[r];if("\\"===e){if(r+1===t.length)throw new Rr(Or.INVALID_ARGUMENT,"Path has trailing escape character: "+t);const e=t[r+1];if("\\"!==e&&"."!==e&&"`"!==e)throw new Rr(Or.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=e,r+=2}else"`"===e?(s=!s,r++):"."!==e||s?(n+=e,r++):(i(),r++)}if(i(),s)throw new Rr(Or.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new ii(e)}static emptyPath(){return new ii([])}}class si{constructor(t){this.fields=t,t.sort(ii.comparator)}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return Hr(this.fields,t.fields,((t,e)=>t.isEqual(e)))}}function oi(){return"undefined"!=typeof atob}class ai{constructor(t){this.binaryString=t}static fromBase64String(t){const e=atob(t);return new ai(e)}static fromUint8Array(t){const e=function(t){let e="";for(let n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(t);return new ai(e)}[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 $r(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}ai.EMPTY_BYTE_STRING=new ai("");const ui=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ci(t){if(kr(!!t),"string"==typeof t){let e=0;const n=ui.exec(t);if(kr(!!n),n[1]){let t=n[1];t=(t+"000000000").substr(0,9),e=Number(t)}const r=new Date(t);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:hi(t.seconds),nanos:hi(t.nanos)}}function hi(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function li(t){return"string"==typeof t?ai.fromBase64String(t):ai.fromUint8Array(t)}function di(t){var e,n;return"server_timestamp"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function fi(t){const e=t.mapValue.fields.__previous_value__;return di(e)?fi(e):e}function pi(t){const e=ci(t.mapValue.fields.__local_write_time__.timestampValue);return new Qr(e.seconds,e.nanos)}class mi{constructor(t,e,n,r,i,s,o,a){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=o,this.useFetchStreams=a}}class gi{constructor(t,e){this.projectId=t,this.database=e||"(default)"}static empty(){return new gi("","")}get isDefaultDatabase(){return"(default)"===this.database}isEqual(t){return t instanceof gi&&t.projectId===this.projectId&&t.database===this.database}}function yi(t){return null==t}function vi(t){return 0===t&&1/t==-1/0}function bi(t){return"number"==typeof t&&Number.isInteger(t)&&!vi(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}class wi{constructor(t){this.path=t}static fromPath(t){return new wi(ni.fromString(t))}static fromName(t){return new wi(ni.fromString(t).popFirst(5))}static empty(){return new wi(ni.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===ni.comparator(this.path,t.path)}toString(){return this.path.toString()}static comparator(t,e){return ni.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new wi(new ni(t.slice()))}}const Ii={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},_i={nullValue:"NULL_VALUE"};function Ti(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?di(t)?4:Vi(t)?9007199254740991:10:Nr()}function Ei(t,e){if(t===e)return!0;const n=Ti(t);if(n!==Ti(e))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return pi(t).isEqual(pi(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=ci(t.timestampValue),r=ci(e.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(t,e){return li(t.bytesValue).isEqual(li(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return hi(t.geoPointValue.latitude)===hi(e.geoPointValue.latitude)&&hi(t.geoPointValue.longitude)===hi(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return hi(t.integerValue)===hi(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){const n=hi(t.doubleValue),r=hi(e.doubleValue);return n===r?vi(n)===vi(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return Hr(t.arrayValue.values||[],e.arrayValue.values||[],Ei);case 10:return function(t,e){const n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(Jr(n)!==Jr(r))return!1;for(const t in n)if(n.hasOwnProperty(t)&&(void 0===r[t]||!Ei(n[t],r[t])))return!1;return!0}(t,e);default:return Nr()}}function Si(t,e){return void 0!==(t.values||[]).find((t=>Ei(t,e)))}function Ai(t,e){if(t===e)return 0;const n=Ti(t),r=Ti(e);if(n!==r)return $r(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return $r(t.booleanValue,e.booleanValue);case 2:return function(t,e){const n=hi(t.integerValue||t.doubleValue),r=hi(e.integerValue||e.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(t,e);case 3:return xi(t.timestampValue,e.timestampValue);case 4:return xi(pi(t),pi(e));case 5:return $r(t.stringValue,e.stringValue);case 6:return function(t,e){const n=li(t),r=li(e);return n.compareTo(r)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){const n=t.split("/"),r=e.split("/");for(let t=0;t<n.length&&t<r.length;t++){const e=$r(n[t],r[t]);if(0!==e)return e}return $r(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){const n=$r(hi(t.latitude),hi(e.latitude));return 0!==n?n:$r(hi(t.longitude),hi(e.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return function(t,e){const n=t.values||[],r=e.values||[];for(let t=0;t<n.length&&t<r.length;++t){const e=Ai(n[t],r[t]);if(e)return e}return $r(n.length,r.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){if(t===Ii.mapValue&&e===Ii.mapValue)return 0;if(t===Ii.mapValue)return 1;if(e===Ii.mapValue)return-1;const n=t.fields||{},r=Object.keys(n),i=e.fields||{},s=Object.keys(i);r.sort(),s.sort();for(let t=0;t<r.length&&t<s.length;++t){const e=$r(r[t],s[t]);if(0!==e)return e;const o=Ai(n[r[t]],i[s[t]]);if(0!==o)return o}return $r(r.length,s.length)}(t.mapValue,e.mapValue);default:throw Nr()}}function xi(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return $r(t,e);const n=ci(t),r=ci(e),i=$r(n.seconds,r.seconds);return 0!==i?i:$r(n.nanos,r.nanos)}function Ni(t){return ki(t)}function ki(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=ci(t);return`time(${e.seconds},${e.nanos})`}(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?li(t.bytesValue).toBase64():"referenceValue"in t?(n=t.referenceValue,wi.fromName(n).toString()):"geoPointValue"in t?`geo(${(e=t.geoPointValue).latitude},${e.longitude})`:"arrayValue"in t?function(t){let e="[",n=!0;for(const r of t.values||[])n?n=!1:e+=",",e+=ki(r);return e+"]"}(t.arrayValue):"mapValue"in t?function(t){const e=Object.keys(t.fields||{}).sort();let n="{",r=!0;for(const i of e)r?r=!1:n+=",",n+=`${i}:${ki(t.fields[i])}`;return n+"}"}(t.mapValue):Nr();var e,n}function Ci(t,e){return{referenceValue:`projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`}}function Di(t){return!!t&&"integerValue"in t}function Oi(t){return!!t&&"arrayValue"in t}function Ri(t){return!!t&&"nullValue"in t}function Pi(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function Li(t){return!!t&&"mapValue"in t}function Mi(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 Xr(t.mapValue.fields,((t,n)=>e.mapValue.fields[t]=Mi(n))),e}if(t.arrayValue){const e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=Mi(t.arrayValue.values[n]);return e}return Object.assign({},t)}function Vi(t){return"__max__"===(((t.mapValue||{}).fields||{}).__type__||{}).stringValue}function Fi(t){return"nullValue"in t?_i:"booleanValue"in t?{booleanValue:!1}:"integerValue"in t||"doubleValue"in t?{doubleValue:NaN}:"timestampValue"in t?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in t?{stringValue:""}:"bytesValue"in t?{bytesValue:""}:"referenceValue"in t?Ci(gi.empty(),wi.empty()):"geoPointValue"in t?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in t?{arrayValue:{}}:"mapValue"in t?{mapValue:{}}:Nr()}function Ui(t){return"nullValue"in t?{booleanValue:!1}:"booleanValue"in t?{doubleValue:NaN}:"integerValue"in t||"doubleValue"in t?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in t?{stringValue:""}:"stringValue"in t?{bytesValue:""}:"bytesValue"in t?Ci(gi.empty(),wi.empty()):"referenceValue"in t?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in t?{arrayValue:{}}:"arrayValue"in t?{mapValue:{}}:"mapValue"in t?Ii:Nr()}function ji(t,e){const n=Ai(t.value,e.value);return 0!==n?n:t.inclusive&&!e.inclusive?-1:!t.inclusive&&e.inclusive?1:0}function Bi(t,e){const n=Ai(t.value,e.value);return 0!==n?n:t.inclusive&&!e.inclusive?1:!t.inclusive&&e.inclusive?-1:0}class qi{constructor(t){this.value=t}static empty(){return new qi({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)],!Li(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=Mi(e)}setAll(t){let e=ii.emptyPath(),n={},r=[];t.forEach(((t,i)=>{if(!e.isImmediateParentOf(i)){const t=this.getFieldsMap(e);this.applyChanges(t,n,r),n={},r=[],e=i.popLast()}t?n[i.lastSegment()]=Mi(t):r.push(i.lastSegment())}));const i=this.getFieldsMap(e);this.applyChanges(i,n,r)}delete(t){const e=this.field(t.popLast());Li(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return Ei(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 r=e.mapValue.fields[t.get(n)];Li(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=r),e=r}return e.mapValue.fields}applyChanges(t,e,n){Xr(e,((e,n)=>t[e]=n));for(const e of n)delete t[e]}clone(){return new qi(Mi(this.value))}}function zi(t){const e=[];return Xr(t.fields,((t,n)=>{const r=new ii([t]);if(Li(n)){const t=zi(n.mapValue).fields;if(0===t.length)e.push(r);else for(const n of t)e.push(r.child(n))}else e.push(r)})),new si(e)}class Ki{constructor(t,e,n,r,i,s){this.key=t,this.documentType=e,this.version=n,this.readTime=r,this.data=i,this.documentState=s}static newInvalidDocument(t){return new Ki(t,0,Zr.min(),Zr.min(),qi.empty(),0)}static newFoundDocument(t,e,n){return new Ki(t,1,e,Zr.min(),n,0)}static newNoDocument(t,e){return new Ki(t,2,e,Zr.min(),qi.empty(),0)}static newUnknownDocument(t,e){return new Ki(t,3,e,Zr.min(),qi.empty(),2)}convertToFoundDocument(t,e){return this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=qi.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=qi.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,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(t){return t instanceof Ki&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new Ki(this.key,this.documentType,this.version,this.readTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class Gi{constructor(t,e,n,r){this.indexId=t,this.collectionGroup=e,this.fields=n,this.indexState=r}}function Wi(t){return t.fields.find((t=>2===t.kind))}function $i(t){return t.fields.filter((t=>2!==t.kind))}Gi.UNKNOWN_ID=-1;class Hi{constructor(t,e){this.fieldPath=t,this.kind=e}}class Yi{constructor(t,e){this.sequenceNumber=t,this.offset=e}static empty(){return new Yi(0,Ji.min())}}function Qi(t,e){const n=t.toTimestamp().seconds,r=t.toTimestamp().nanoseconds+1,i=Zr.fromTimestamp(1e9===r?new Qr(n+1,0):new Qr(n,r));return new Ji(i,wi.empty(),e)}function Zi(t){return new Ji(t.readTime,t.key,-1)}class Ji{constructor(t,e,n){this.readTime=t,this.documentKey=e,this.largestBatchId=n}static min(){return new Ji(Zr.min(),wi.empty(),-1)}static max(){return new Ji(Zr.max(),wi.empty(),-1)}}function Xi(t,e){let n=t.readTime.compareTo(e.readTime);return 0!==n?n:(n=wi.comparator(t.documentKey,e.documentKey),0!==n?n:$r(t.largestBatchId,e.largestBatchId))}class ts{constructor(t,e){this.comparator=t,this.root=e||ns.EMPTY}insert(t,e){return new ts(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,ns.BLACK,null,null))}remove(t){return new ts(this.comparator,this.root.remove(t,this.comparator).copy(null,null,ns.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 r=this.comparator(t,n.key);if(0===r)return e+n.left.size;r<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 es(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new es(this.root,t,this.comparator,!1)}getReverseIterator(){return new es(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new es(this.root,t,this.comparator,!0)}}class es{constructor(t,e,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!t.isEmpty();)if(i=e?n(t.key,e):1,e&&r&&(i*=-1),i<0)t=this.isReverse?t.left:t.right;else{if(0===i){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}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}}}class ns{constructor(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:ns.RED,this.left=null!=r?r:ns.EMPTY,this.right=null!=i?i:ns.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,n,r,i){return new ns(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)}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 r=this;const i=n(t,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n)),r.fixUp()}removeMin(){if(this.left.isEmpty())return ns.EMPTY;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,r=this;if(e(t,r.key)<0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(t,e),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===e(t,r.key)){if(r.right.isEmpty())return ns.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(t,e))}return r.fixUp()}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 t=this.copy(null,null,ns.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,ns.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}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 Nr();if(this.right.isRed())throw Nr();const t=this.left.check();if(t!==this.right.check())throw Nr();return t+(this.isRed()?0:1)}}ns.EMPTY=null,ns.RED=!0,ns.BLACK=!1,ns.EMPTY=new class{constructor(){this.size=0}get key(){throw Nr()}get value(){throw Nr()}get color(){throw Nr()}get left(){throw Nr()}get right(){throw Nr()}copy(t,e,n,r,i){return this}insert(t,e,n){return new ns(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}};class rs{constructor(t){this.comparator=t,this.data=new ts(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 r=n.getNext();if(this.comparator(r.key,t[1])>=0)return;e(r.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 is(this.data.getIterator())}getIteratorFrom(t){return new is(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(t){if(!(t instanceof rs))return!1;if(this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const t=e.getNext().key,r=n.getNext().key;if(0!==this.comparator(t,r))return!1}return!0}toArray(){const t=[];return this.forEach((e=>{t.push(e)})),t}toString(){const t=[];return this.forEach((e=>t.push(e))),"SortedSet("+t.toString()+")"}copy(t){const e=new rs(this.comparator);return e.data=t,e}}class is{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function ss(t){return t.hasNext()?t.getNext():void 0}class os{constructor(t,e=null,n=[],r=[],i=null,s=null,o=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=s,this.endAt=o,this.P=null}}function as(t,e=null,n=[],r=[],i=null,s=null,o=null){return new os(t,e,n,r,i,s,o)}function us(t){const e=Dr(t);if(null===e.P){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((t=>{return(e=t).field.canonicalString()+e.op.toString()+Ni(e.value);var e})).join(","),t+="|ob:",t+=e.orderBy.map((t=>function(t){return t.field.canonicalString()+t.dir}(t))).join(","),yi(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((t=>Ni(t))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((t=>Ni(t))).join(",")),e.P=t}return e.P}function cs(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(!Ss(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(let i=0;i<t.filters.length;i++)if(n=t.filters[i],r=e.filters[i],n.op!==r.op||!n.field.isEqual(r.field)||!Ei(n.value,r.value))return!1;var n,r;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!xs(t.startAt,e.startAt)&&xs(t.endAt,e.endAt)}function hs(t){return wi.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}function ls(t,e){return t.filters.filter((t=>t instanceof ps&&t.field.isEqual(e)))}function ds(t,e,n){let r=_i,i=!0;for(const n of ls(t,e)){let t=_i,e=!0;switch(n.op){case"<":case"<=":t=Fi(n.value);break;case"==":case"in":case">=":t=n.value;break;case">":t=n.value,e=!1;break;case"!=":case"not-in":t=_i}ji({value:r,inclusive:i},{value:t,inclusive:e})<0&&(r=t,i=e)}if(null!==n)for(let s=0;s<t.orderBy.length;++s)if(t.orderBy[s].field.isEqual(e)){const t=n.position[s];ji({value:r,inclusive:i},{value:t,inclusive:n.inclusive})<0&&(r=t,i=n.inclusive);break}return{value:r,inclusive:i}}function fs(t,e,n){let r=Ii,i=!0;for(const n of ls(t,e)){let t=Ii,e=!0;switch(n.op){case">=":case">":t=Ui(n.value),e=!1;break;case"==":case"in":case"<=":t=n.value;break;case"<":t=n.value,e=!1;break;case"!=":case"not-in":t=Ii}Bi({value:r,inclusive:i},{value:t,inclusive:e})>0&&(r=t,i=e)}if(null!==n)for(let s=0;s<t.orderBy.length;++s)if(t.orderBy[s].field.isEqual(e)){const t=n.position[s];Bi({value:r,inclusive:i},{value:t,inclusive:n.inclusive})>0&&(r=t,i=n.inclusive);break}return{value:r,inclusive:i}}class ps extends class{}{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?"in"===e||"not-in"===e?this.V(t,e,n):new ms(t,e,n):"array-contains"===e?new bs(t,n):"in"===e?new ws(t,n):"not-in"===e?new Is(t,n):"array-contains-any"===e?new _s(t,n):new ps(t,e,n)}static V(t,e,n){return"in"===e?new gs(t,n):new ys(t,n)}matches(t){const e=t.data.field(this.field);return"!="===this.op?null!==e&&this.v(Ai(e,this.value)):null!==e&&Ti(this.value)===Ti(e)&&this.v(Ai(e,this.value))}v(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 Nr()}}S(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}}class ms extends ps{constructor(t,e,n){super(t,e,n),this.key=wi.fromName(n.referenceValue)}matches(t){const e=wi.comparator(t.key,this.key);return this.v(e)}}class gs extends ps{constructor(t,e){super(t,"in",e),this.keys=vs(0,e)}matches(t){return this.keys.some((e=>e.isEqual(t.key)))}}class ys extends ps{constructor(t,e){super(t,"not-in",e),this.keys=vs(0,e)}matches(t){return!this.keys.some((e=>e.isEqual(t.key)))}}function vs(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map((t=>wi.fromName(t.referenceValue)))}class bs extends ps{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return Oi(e)&&Si(e.arrayValue,this.value)}}class ws extends ps{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return null!==e&&Si(this.value.arrayValue,e)}}class Is extends ps{constructor(t,e){super(t,"not-in",e)}matches(t){if(Si(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return null!==e&&!Si(this.value.arrayValue,e)}}class _s extends ps{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!Oi(e)||!e.arrayValue.values)&&e.arrayValue.values.some((t=>Si(this.value.arrayValue,t)))}}class Ts{constructor(t,e){this.position=t,this.inclusive=e}}class Es{constructor(t,e="asc"){this.field=t,this.dir=e}}function Ss(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}function As(t,e,n){let r=0;for(let i=0;i<t.position.length;i++){const s=e[i],o=t.position[i];if(r=s.field.isKeyField()?wi.comparator(wi.fromName(o.referenceValue),n.key):Ai(o,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return r}function xs(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(!Ei(t.position[n],e.position[n]))return!1;return!0}class Ns{constructor(t,e=null,n=[],r=[],i=null,s="F",o=null,a=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=s,this.startAt=o,this.endAt=a,this.D=null,this.C=null,this.startAt,this.endAt}}function ks(t,e,n,r,i,s,o,a){return new Ns(t,e,n,r,i,s,o,a)}function Cs(t){return new Ns(t)}function Ds(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function Os(t){for(const e of t.filters)if(e.S())return e.field;return null}function Rs(t){return null!==t.collectionGroup}function Ps(t){const e=Dr(t);if(null===e.D){e.D=[];const t=Os(e),n=Ds(e);if(null!==t&&null===n)t.isKeyField()||e.D.push(new Es(t)),e.D.push(new Es(ii.keyField(),"asc"));else{let t=!1;for(const n of e.explicitOrderBy)e.D.push(n),n.field.isKeyField()&&(t=!0);if(!t){const t=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e.D.push(new Es(ii.keyField(),t))}}}return e.D}function Ls(t){const e=Dr(t);if(!e.C)if("F"===e.limitType)e.C=as(e.path,e.collectionGroup,Ps(e),e.filters,e.limit,e.startAt,e.endAt);else{const t=[];for(const n of Ps(e)){const e="desc"===n.dir?"asc":"desc";t.push(new Es(n.field,e))}const n=e.endAt?new Ts(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new Ts(e.startAt.position,e.startAt.inclusive):null;e.C=as(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}return e.C}function Ms(t,e,n){return new Ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Vs(t,e){return cs(Ls(t),Ls(e))&&t.limitType===e.limitType}function Fs(t){return`${us(Ls(t))}|lt:${t.limitType}`}function Us(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=>{return`${(e=t).field.canonicalString()} ${e.op} ${Ni(e.value)}`;var e})).join(", ")}]`),yi(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=>Ni(t))).join(",")),t.endAt&&(e+=", endAt: ",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map((t=>Ni(t))).join(",")),`Target(${e})`}(Ls(t))}; limitType=${t.limitType})`}function js(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):wi.isDocumentKey(t.path)?t.path.isEqual(n):t.path.isImmediateParentOf(n)}(t,e)&&function(t,e){for(const n of t.explicitOrderBy)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 r=As(t,e,n);return t.inclusive?r<=0:r<0}(t.startAt,Ps(t),e)||t.endAt&&!function(t,e,n){const r=As(t,e,n);return t.inclusive?r>=0:r>0}(t.endAt,Ps(t),e))}(t,e)}function Bs(t){return t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2))}function qs(t){return(e,n)=>{let r=!1;for(const i of Ps(t)){const t=zs(i,e,n);if(0!==t)return t;r=r||i.field.isKeyField()}return 0}}function zs(t,e,n){const r=t.field.isKeyField()?wi.comparator(e.key,n.key):function(t,e,n){const r=e.data.field(t),i=n.data.field(t);return null!==r&&null!==i?Ai(r,i):Nr()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return Nr()}}function Ks(t,e){if(t.N){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:vi(e)?"-0":e}}function Gs(t){return{integerValue:""+t}}function Ws(t,e){return bi(e)?Gs(e):Ks(t,e)}class $s{constructor(){this._=void 0}}function Hs(t,e,n){return t instanceof Zs?function(t,e){const n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:t.seconds,nanos:t.nanoseconds}}}};return e&&(n.fields.__previous_value__=e),{mapValue:n}}(n,e):t instanceof Js?Xs(t,e):t instanceof to?eo(t,e):function(t,e){const n=Qs(t,e),r=ro(n)+ro(t.k);return Di(n)&&Di(t.k)?Gs(r):Ks(t.M,r)}(t,e)}function Ys(t,e,n){return t instanceof Js?Xs(t,e):t instanceof to?eo(t,e):n}function Qs(t,e){return t instanceof no?Di(n=e)||function(t){return!!t&&"doubleValue"in t}(n)?e:{integerValue:0}:null;var n}class Zs extends $s{}class Js extends $s{constructor(t){super(),this.elements=t}}function Xs(t,e){const n=io(e);for(const e of t.elements)n.some((t=>Ei(t,e)))||n.push(e);return{arrayValue:{values:n}}}class to extends $s{constructor(t){super(),this.elements=t}}function eo(t,e){let n=io(e);for(const e of t.elements)n=n.filter((t=>!Ei(t,e)));return{arrayValue:{values:n}}}class no extends $s{constructor(t,e){super(),this.M=t,this.k=e}}function ro(t){return hi(t.integerValue||t.doubleValue)}function io(t){return Oi(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}class so{constructor(t,e){this.field=t,this.transform=e}}class oo{constructor(t,e){this.version=t,this.transformResults=e}}class ao{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new ao}static exists(t){return new ao(void 0,t)}static updateTime(t){return new ao(t)}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 uo(t,e){return void 0!==t.updateTime?e.isFoundDocument()&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e.isFoundDocument()}class co{}function ho(t,e,n){t instanceof go?function(t,e,n){const r=t.value.clone(),i=bo(t.fieldTransforms,e,n.transformResults);r.setAll(i),e.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(t,e,n):t instanceof yo?function(t,e,n){if(!uo(t.precondition,e))return void e.convertToUnknownDocument(n.version);const r=bo(t.fieldTransforms,e,n.transformResults),i=e.data;i.setAll(vo(t)),i.setAll(r),e.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(t,e,n):function(t,e,n){e.convertToNoDocument(n.version).setHasCommittedMutations()}(0,e,n)}function lo(t,e,n){t instanceof go?function(t,e,n){if(!uo(t.precondition,e))return;const r=t.value.clone(),i=wo(t.fieldTransforms,n,e);r.setAll(i),e.convertToFoundDocument(mo(e),r).setHasLocalMutations()}(t,e,n):t instanceof yo?function(t,e,n){if(!uo(t.precondition,e))return;const r=wo(t.fieldTransforms,n,e),i=e.data;i.setAll(vo(t)),i.setAll(r),e.convertToFoundDocument(mo(e),i).setHasLocalMutations()}(t,e,n):function(t,e){uo(t.precondition,e)&&e.convertToNoDocument(Zr.min())}(t,e)}function fo(t,e){let n=null;for(const r of t.fieldTransforms){const t=e.data.field(r.field),i=Qs(r.transform,t||null);null!=i&&(null==n&&(n=qi.empty()),n.set(r.field,i))}return n||null}function po(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)&&Hr(t,e,((t,e)=>function(t,e){return t.field.isEqual(e.field)&&function(t,e){return t instanceof Js&&e instanceof Js||t instanceof to&&e instanceof to?Hr(t.elements,e.elements,Ei):t instanceof no&&e instanceof no?Ei(t.k,e.k):t instanceof Zs&&e instanceof Zs}(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))}function mo(t){return t.isFoundDocument()?t.version:Zr.min()}class go extends co{constructor(t,e,n,r=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=r,this.type=0}}class yo extends co{constructor(t,e,n,r,i=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=r,this.fieldTransforms=i,this.type=1}}function vo(t){const e=new Map;return t.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){const r=t.data.field(n);e.set(n,r)}})),e}function bo(t,e,n){const r=new Map;kr(t.length===n.length);for(let i=0;i<n.length;i++){const s=t[i],o=s.transform,a=e.data.field(s.field);r.set(s.field,Ys(o,a,n[i]))}return r}function wo(t,e,n){const r=new Map;for(const i of t){const t=i.transform,s=n.data.field(i.field);r.set(i.field,Hs(t,s,e))}return r}class Io extends co{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}}class _o extends co{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}}class To{constructor(t){this.count=t}}var Eo,So;function Ao(t){switch(t){default:return Nr();case Or.CANCELLED:case Or.UNKNOWN:case Or.DEADLINE_EXCEEDED:case Or.RESOURCE_EXHAUSTED:case Or.INTERNAL:case Or.UNAVAILABLE:case Or.UNAUTHENTICATED:return!1;case Or.INVALID_ARGUMENT:case Or.NOT_FOUND:case Or.ALREADY_EXISTS:case Or.PERMISSION_DENIED:case Or.FAILED_PRECONDITION:case Or.ABORTED:case Or.OUT_OF_RANGE:case Or.UNIMPLEMENTED:case Or.DATA_LOSS:return!0}}function xo(t){if(void 0===t)return Sr("GRPC error has no .code"),Or.UNKNOWN;switch(t){case Eo.OK:return Or.OK;case Eo.CANCELLED:return Or.CANCELLED;case Eo.UNKNOWN:return Or.UNKNOWN;case Eo.DEADLINE_EXCEEDED:return Or.DEADLINE_EXCEEDED;case Eo.RESOURCE_EXHAUSTED:return Or.RESOURCE_EXHAUSTED;case Eo.INTERNAL:return Or.INTERNAL;case Eo.UNAVAILABLE:return Or.UNAVAILABLE;case Eo.UNAUTHENTICATED:return Or.UNAUTHENTICATED;case Eo.INVALID_ARGUMENT:return Or.INVALID_ARGUMENT;case Eo.NOT_FOUND:return Or.NOT_FOUND;case Eo.ALREADY_EXISTS:return Or.ALREADY_EXISTS;case Eo.PERMISSION_DENIED:return Or.PERMISSION_DENIED;case Eo.FAILED_PRECONDITION:return Or.FAILED_PRECONDITION;case Eo.ABORTED:return Or.ABORTED;case Eo.OUT_OF_RANGE:return Or.OUT_OF_RANGE;case Eo.UNIMPLEMENTED:return Or.UNIMPLEMENTED;case Eo.DATA_LOSS:return Or.DATA_LOSS;default:return Nr()}}(So=Eo||(Eo={}))[So.OK=0]="OK",So[So.CANCELLED=1]="CANCELLED",So[So.UNKNOWN=2]="UNKNOWN",So[So.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",So[So.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",So[So.NOT_FOUND=5]="NOT_FOUND",So[So.ALREADY_EXISTS=6]="ALREADY_EXISTS",So[So.PERMISSION_DENIED=7]="PERMISSION_DENIED",So[So.UNAUTHENTICATED=16]="UNAUTHENTICATED",So[So.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",So[So.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",So[So.ABORTED=10]="ABORTED",So[So.OUT_OF_RANGE=11]="OUT_OF_RANGE",So[So.UNIMPLEMENTED=12]="UNIMPLEMENTED",So[So.INTERNAL=13]="INTERNAL",So[So.UNAVAILABLE=14]="UNAVAILABLE",So[So.DATA_LOSS=15]="DATA_LOSS";class No{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[e,r]of n)if(this.equalsFn(e,t))return r}has(t){return void 0!==this.get(t)}set(t,e){const n=this.mapKeyFn(t),r=this.inner[n];if(void 0===r)return this.inner[n]=[[t,e]],void this.innerSize++;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],t))return void(r[n]=[t,e]);r.push([t,e]),this.innerSize++}delete(t){const e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],t))return 1===n.length?delete this.inner[e]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(t){Xr(this.inner,((e,n)=>{for(const[e,r]of n)t(e,r)}))}isEmpty(){return ti(this.inner)}size(){return this.innerSize}}const ko=new ts(wi.comparator);function Co(){return ko}const Do=new ts(wi.comparator);function Oo(...t){let e=Do;for(const n of t)e=e.insert(n.key,n);return e}function Ro(){return new No((t=>t.toString()),((t,e)=>t.isEqual(e)))}const Po=new ts(wi.comparator),Lo=new rs(wi.comparator);function Mo(...t){let e=Lo;for(const n of t)e=e.add(n);return e}const Vo=new rs($r);function Fo(){return Vo}class Uo{constructor(t,e,n,r,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(t,e){const n=new Map;return n.set(t,jo.createSynthesizedTargetChangeForCurrentChange(t,e)),new Uo(Zr.min(),n,Fo(),Co(),Mo())}}class jo{constructor(t,e,n,r,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(t,e){return new jo(ai.EMPTY_BYTE_STRING,e,Mo(),Mo(),Mo())}}class Bo{constructor(t,e,n,r){this.O=t,this.removedTargetIds=e,this.key=n,this.F=r}}class qo{constructor(t,e){this.targetId=t,this.$=e}}class zo{constructor(t,e,n=ai.EMPTY_BYTE_STRING,r=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r}}class Ko{constructor(){this.B=0,this.L=$o(),this.U=ai.EMPTY_BYTE_STRING,this.q=!1,this.K=!0}get current(){return this.q}get resumeToken(){return this.U}get G(){return 0!==this.B}get j(){return this.K}W(t){t.approximateByteSize()>0&&(this.K=!0,this.U=t)}H(){let t=Mo(),e=Mo(),n=Mo();return this.L.forEach(((r,i)=>{switch(i){case 0:t=t.add(r);break;case 2:e=e.add(r);break;case 1:n=n.add(r);break;default:Nr()}})),new jo(this.U,this.q,t,e,n)}J(){this.K=!1,this.L=$o()}Y(t,e){this.K=!0,this.L=this.L.insert(t,e)}X(t){this.K=!0,this.L=this.L.remove(t)}Z(){this.B+=1}tt(){this.B-=1}et(){this.K=!0,this.q=!0}}class Go{constructor(t){this.nt=t,this.st=new Map,this.it=Co(),this.rt=Wo(),this.ot=new rs($r)}ut(t){for(const e of t.O)t.F&&t.F.isFoundDocument()?this.at(e,t.F):this.ct(e,t.key,t.F);for(const e of t.removedTargetIds)this.ct(e,t.key,t.F)}ht(t){this.forEachTarget(t,(e=>{const n=this.lt(e);switch(t.state){case 0:this.ft(e)&&n.W(t.resumeToken);break;case 1:n.tt(),n.G||n.J(),n.W(t.resumeToken);break;case 2:n.tt(),n.G||this.removeTarget(e);break;case 3:this.ft(e)&&(n.et(),n.W(t.resumeToken));break;case 4:this.ft(e)&&(this.dt(e),n.W(t.resumeToken));break;default:Nr()}}))}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.st.forEach(((t,n)=>{this.ft(n)&&e(n)}))}_t(t){const e=t.targetId,n=t.$.count,r=this.wt(e);if(r){const t=r.target;if(hs(t))if(0===n){const n=new wi(t.path);this.ct(e,n,Ki.newNoDocument(n,Zr.min()))}else kr(1===n);else this.gt(e)!==n&&(this.dt(e),this.ot=this.ot.add(e))}}yt(t){const e=new Map;this.st.forEach(((n,r)=>{const i=this.wt(r);if(i){if(n.current&&hs(i.target)){const e=new wi(i.target.path);null!==this.it.get(e)||this.It(r,e)||this.ct(r,e,Ki.newNoDocument(e,t))}n.j&&(e.set(r,n.H()),n.J())}}));let n=Mo();this.rt.forEach(((t,e)=>{let r=!0;e.forEachWhile((t=>{const e=this.wt(t);return!e||2===e.purpose||(r=!1,!1)})),r&&(n=n.add(t))})),this.it.forEach(((e,n)=>n.setReadTime(t)));const r=new Uo(t,e,this.ot,this.it,n);return this.it=Co(),this.rt=Wo(),this.ot=new rs($r),r}at(t,e){if(!this.ft(t))return;const n=this.It(t,e.key)?2:0;this.lt(t).Y(e.key,n),this.it=this.it.insert(e.key,e),this.rt=this.rt.insert(e.key,this.Tt(e.key).add(t))}ct(t,e,n){if(!this.ft(t))return;const r=this.lt(t);this.It(t,e)?r.Y(e,1):r.X(e),this.rt=this.rt.insert(e,this.Tt(e).delete(t)),n&&(this.it=this.it.insert(e,n))}removeTarget(t){this.st.delete(t)}gt(t){const e=this.lt(t).H();return this.nt.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}Z(t){this.lt(t).Z()}lt(t){let e=this.st.get(t);return e||(e=new Ko,this.st.set(t,e)),e}Tt(t){let e=this.rt.get(t);return e||(e=new rs($r),this.rt=this.rt.insert(t,e)),e}ft(t){const e=null!==this.wt(t);return e||Er("WatchChangeAggregator","Detected inactive target",t),e}wt(t){const e=this.st.get(t);return e&&e.G?null:this.nt.Et(t)}dt(t){this.st.set(t,new Ko),this.nt.getRemoteKeysForTarget(t).forEach((e=>{this.ct(t,e,null)}))}It(t,e){return this.nt.getRemoteKeysForTarget(t).has(e)}}function Wo(){return new ts(wi.comparator)}function $o(){return new ts(wi.comparator)}const Ho={asc:"ASCENDING",desc:"DESCENDING"},Yo={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"};class Qo{constructor(t,e){this.databaseId=t,this.N=e}}function Zo(t,e){return t.N?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function Jo(t,e){return t.N?e.toBase64():e.toUint8Array()}function Xo(t,e){return Zo(t,e.toTimestamp())}function ta(t){return kr(!!t),Zr.fromTimestamp(function(t){const e=ci(t);return new Qr(e.seconds,e.nanos)}(t))}function ea(t,e){return function(t){return new ni(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).canonicalString()}function na(t){const e=ni.fromString(t);return kr(Ea(e)),e}function ra(t,e){return ea(t.databaseId,e.path)}function ia(t,e){const n=na(e);if(n.get(1)!==t.databaseId.projectId)throw new Rr(Or.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new Rr(Or.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new wi(ua(n))}function sa(t,e){return ea(t.databaseId,e)}function oa(t){const e=na(t);return 4===e.length?ni.emptyPath():ua(e)}function aa(t){return new ni(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function ua(t){return kr(t.length>4&&"documents"===t.get(4)),t.popFirst(5)}function ca(t,e,n){return{name:ra(t,e),fields:n.value.mapValue.fields}}function ha(t,e,n){const r=ia(t,e.name),i=ta(e.updateTime),s=new qi({mapValue:{fields:e.fields}}),o=Ki.newFoundDocument(r,i,s);return n&&o.setHasCommittedMutations(),n?o.setHasCommittedMutations():o}function la(t,e){let n;if(e instanceof go)n={update:ca(t,e.key,e.value)};else if(e instanceof Io)n={delete:ra(t,e.key)};else if(e instanceof yo)n={update:ca(t,e.key,e.data),updateMask:Ta(e.fieldMask)};else{if(!(e instanceof _o))return Nr();n={verify:ra(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((t=>function(t,e){const n=e.transform;if(n instanceof Zs)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof Js)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof to)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof no)return{fieldPath:e.field.canonicalString(),increment:n.k};throw Nr()}(0,t)))),e.precondition.isNone||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:Xo(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:Nr()}(t,e.precondition)),n}function da(t,e){const n=e.currentDocument?function(t){return void 0!==t.updateTime?ao.updateTime(ta(t.updateTime)):void 0!==t.exists?ao.exists(t.exists):ao.none()}(e.currentDocument):ao.none(),r=e.updateTransforms?e.updateTransforms.map((e=>function(t,e){let n=null;if("setToServerValue"in e)kr("REQUEST_TIME"===e.setToServerValue),n=new Zs;else if("appendMissingElements"in e){const t=e.appendMissingElements.values||[];n=new Js(t)}else if("removeAllFromArray"in e){const t=e.removeAllFromArray.values||[];n=new to(t)}else"increment"in e?n=new no(t,e.increment):Nr();const r=ii.fromServerFormat(e.fieldPath);return new so(r,n)}(t,e))):[];if(e.update){e.update.name;const i=ia(t,e.update.name),s=new qi({mapValue:{fields:e.update.fields}});if(e.updateMask){const t=function(t){const e=t.fieldPaths||[];return new si(e.map((t=>ii.fromServerFormat(t))))}(e.updateMask);return new yo(i,s,t,n,r)}return new go(i,s,n,r)}if(e.delete){const r=ia(t,e.delete);return new Io(r,n)}if(e.verify){const r=ia(t,e.verify);return new _o(r,n)}return Nr()}function fa(t,e){return{documents:[sa(t,e.path)]}}function pa(t,e){const n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=sa(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=sa(t,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);const i=function(t){if(0===t.length)return;const e=t.map((t=>function(t){if("=="===t.op){if(Pi(t.value))return{unaryFilter:{field:ba(t.field),op:"IS_NAN"}};if(Ri(t.value))return{unaryFilter:{field:ba(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(Pi(t.value))return{unaryFilter:{field:ba(t.field),op:"IS_NOT_NAN"}};if(Ri(t.value))return{unaryFilter:{field:ba(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:ba(t.field),op:va(t.op),value:t.value}}}(t)));return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}(e.filters);i&&(n.structuredQuery.where=i);const s=function(t){if(0!==t.length)return t.map((t=>function(t){return{field:ba(t.field),direction:ya(t.dir)}}(t)))}(e.orderBy);s&&(n.structuredQuery.orderBy=s);const o=function(t,e){return t.N||yi(e)?e:{value:e}}(t,e.limit);var a;return null!==o&&(n.structuredQuery.limit=o),e.startAt&&(n.structuredQuery.startAt={before:(a=e.startAt).inclusive,values:a.position}),e.endAt&&(n.structuredQuery.endAt=function(t){return{before:!t.inclusive,values:t.position}}(e.endAt)),n}function ma(t){let e=oa(t.parent);const n=t.structuredQuery,r=n.from?n.from.length:0;let i=null;if(r>0){kr(1===r);const t=n.from[0];t.allDescendants?i=t.collectionId:e=e.child(t.collectionId)}let s=[];n.where&&(s=ga(n.where));let o=[];n.orderBy&&(o=n.orderBy.map((t=>function(t){return new Es(wa(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))}(t))));let a=null;n.limit&&(a=function(t){let e;return e="object"==typeof t?t.value:t,yi(e)?null:e}(n.limit));let u=null;n.startAt&&(u=function(t){const e=!!t.before,n=t.values||[];return new Ts(n,e)}(n.startAt));let c=null;return n.endAt&&(c=function(t){const e=!t.before,n=t.values||[];return new Ts(n,e)}(n.endAt)),ks(e,i,o,s,a,"F",u,c)}function ga(t){return t?void 0!==t.unaryFilter?[_a(t)]:void 0!==t.fieldFilter?[Ia(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map((t=>ga(t))).reduce(((t,e)=>t.concat(e))):Nr():[]}function ya(t){return Ho[t]}function va(t){return Yo[t]}function ba(t){return{fieldPath:t.canonicalString()}}function wa(t){return ii.fromServerFormat(t.fieldPath)}function Ia(t){return ps.create(wa(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";default:return Nr()}}(t.fieldFilter.op),t.fieldFilter.value)}function _a(t){switch(t.unaryFilter.op){case"IS_NAN":const e=wa(t.unaryFilter.field);return ps.create(e,"==",{doubleValue:NaN});case"IS_NULL":const n=wa(t.unaryFilter.field);return ps.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const r=wa(t.unaryFilter.field);return ps.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const i=wa(t.unaryFilter.field);return ps.create(i,"!=",{nullValue:"NULL_VALUE"});default:return Nr()}}function Ta(t){const e=[];return t.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function Ea(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}function Sa(t){let e="";for(let n=0;n<t.length;n++)e.length>0&&(e=xa(e)),e=Aa(t.get(n),e);return xa(e)}function Aa(t,e){let n=e;const r=t.length;for(let e=0;e<r;e++){const r=t.charAt(e);switch(r){case"\0":n+="";break;case"":n+="";break;default:n+=r}}return n}function xa(t){return t+""}function Na(t){const e=t.length;if(kr(e>=2),2===e)return kr(""===t.charAt(0)&&""===t.charAt(1)),ni.emptyPath();const n=e-2,r=[];let i="";for(let s=0;s<e;){const e=t.indexOf("",s);switch((e<0||e>n)&&Nr(),t.charAt(e+1)){case"":const n=t.substring(s,e);let o;0===i.length?o=n:(i+=n,o=i,i=""),r.push(o);break;case"":i+=t.substring(s,e),i+="\0";break;case"":i+=t.substring(s,e+1);break;default:Nr()}s=e+2}return new ni(r)}const ka=["userId","batchId"];function Ca(t,e){return[t,Sa(e)]}function Da(t,e,n){return[t,Sa(e),n]}const Oa={},Ra=["prefixPath","collectionGroup","readTime","documentId"],Pa=["prefixPath","collectionGroup","documentId"],La=["collectionGroup","readTime","prefixPath","documentId"],Ma=["canonicalId","targetId"],Va=["targetId","path"],Fa=["path","targetId"],Ua=["collectionId","parent"],ja=["indexId","uid"],Ba=["uid","sequenceNumber"],qa=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],za=["indexId","uid","orderedDocumentKey"],Ka=["userId","collectionPath","documentId"],Ga=["userId","collectionPath","largestBatchId"],Wa=["userId","collectionGroup","largestBatchId"],$a=["mutationQueues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries"],Ha=[...$a,"documentOverlays"],Ya=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],Qa=[...Ya,"indexConfiguration","indexState","indexEntries"],Za="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class Ja{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((t=>t()))}}class Xa{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(t,e){return this.callbackAttached&&Nr(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(e,this.error):this.wrapSuccess(t,this.result):new Xa(((n,r)=>{this.nextCallback=e=>{this.wrapSuccess(t,e).next(n,r)},this.catchCallback=t=>{this.wrapFailure(e,t).next(n,r)}}))}toPromise(){return new Promise(((t,e)=>{this.next(t,e)}))}wrapUserFunction(t){try{const e=t();return e instanceof Xa?e:Xa.resolve(e)}catch(t){return Xa.reject(t)}}wrapSuccess(t,e){return t?this.wrapUserFunction((()=>t(e))):Xa.resolve(e)}wrapFailure(t,e){return t?this.wrapUserFunction((()=>t(e))):Xa.reject(e)}static resolve(t){return new Xa(((e,n)=>{e(t)}))}static reject(t){return new Xa(((e,n)=>{n(t)}))}static waitFor(t){return new Xa(((e,n)=>{let r=0,i=0,s=!1;t.forEach((t=>{++r,t.next((()=>{++i,s&&i===r&&e()}),(t=>n(t)))})),s=!0,i===r&&e()}))}static or(t){let e=Xa.resolve(!1);for(const n of t)e=e.next((t=>t?Xa.resolve(t):n()));return e}static forEach(t,e){const n=[];return t.forEach(((t,r)=>{n.push(e.call(this,t,r))})),this.waitFor(n)}}class tu{constructor(t,e){this.action=t,this.transaction=e,this.aborted=!1,this.At=new Pr,this.transaction.oncomplete=()=>{this.At.resolve()},this.transaction.onabort=()=>{e.error?this.At.reject(new ru(t,e.error)):this.At.resolve()},this.transaction.onerror=e=>{const n=uu(e.target.error);this.At.reject(new ru(t,n))}}static open(t,e,n,r){try{return new tu(e,t.transaction(r,n))}catch(t){throw new ru(e,t)}}get Rt(){return this.At.promise}abort(t){t&&this.At.reject(t),this.aborted||(Er("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}bt(){const t=this.transaction;this.aborted||"function"!=typeof t.commit||t.commit()}store(t){const e=this.transaction.objectStore(t);return new su(e)}}class eu{constructor(t,e,n){this.name=t,this.version=e,this.Pt=n,12.2===eu.Vt((0,a.z$)())&&Sr("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}static delete(t){return Er("SimpleDb","Removing database:",t),ou(window.indexedDB.deleteDatabase(t)).toPromise()}static vt(){if(!(0,a.hl)())return!1;if(eu.St())return!0;const t=(0,a.z$)(),e=eu.Vt(t),n=0<e&&e<10,r=eu.Dt(t),i=0<r&&r<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||n||i)}static St(){var t;return"undefined"!=typeof process&&"YES"===(null===(t=process.env)||void 0===t?void 0:t.Ct)}static xt(t,e){return t.store(e)}static Vt(t){const e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)}static Dt(t){const e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)}async Nt(t){return this.db||(Er("SimpleDb","Opening database:",this.name),this.db=await new Promise(((e,n)=>{const r=indexedDB.open(this.name,this.version);r.onsuccess=t=>{const n=t.target.result;e(n)},r.onblocked=()=>{n(new ru(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},r.onerror=e=>{const r=e.target.error;"VersionError"===r.name?n(new Rr(Or.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):"InvalidStateError"===r.name?n(new Rr(Or.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+r)):n(new ru(t,r))},r.onupgradeneeded=t=>{Er("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',t.oldVersion);const e=t.target.result;this.Pt.kt(e,r.transaction,t.oldVersion,this.version).next((()=>{Er("SimpleDb","Database upgrade to version "+this.version+" complete")}))}}))),this.Mt&&(this.db.onversionchange=t=>this.Mt(t)),this.db}Ot(t){this.Mt=t,this.db&&(this.db.onversionchange=e=>t(e))}async runTransaction(t,e,n,r){const i="readonly"===e;let s=0;for(;;){++s;try{this.db=await this.Nt(t);const e=tu.open(this.db,t,i?"readonly":"readwrite",n),s=r(e).next((t=>(e.bt(),t))).catch((t=>(e.abort(t),Xa.reject(t)))).toPromise();return s.catch((()=>{})),await e.Rt,s}catch(t){const e="FirebaseError"!==t.name&&s<3;if(Er("SimpleDb","Transaction failed with error:",t.message,"Retrying:",e),this.close(),!e)return Promise.reject(t)}}}close(){this.db&&this.db.close(),this.db=void 0}}class nu{constructor(t){this.Ft=t,this.$t=!1,this.Bt=null}get isDone(){return this.$t}get Lt(){return this.Bt}set cursor(t){this.Ft=t}done(){this.$t=!0}Ut(t){this.Bt=t}delete(){return ou(this.Ft.delete())}}class ru extends Rr{constructor(t,e){super(Or.UNAVAILABLE,`IndexedDB transaction '${t}' failed: ${e}`),this.name="IndexedDbTransactionError"}}function iu(t){return"IndexedDbTransactionError"===t.name}class su{constructor(t){this.store=t}put(t,e){let n;return void 0!==e?(Er("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(Er("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),ou(n)}add(t){return Er("SimpleDb","ADD",this.store.name,t,t),ou(this.store.add(t))}get(t){return ou(this.store.get(t)).next((e=>(void 0===e&&(e=null),Er("SimpleDb","GET",this.store.name,t,e),e)))}delete(t){return Er("SimpleDb","DELETE",this.store.name,t),ou(this.store.delete(t))}count(){return Er("SimpleDb","COUNT",this.store.name),ou(this.store.count())}qt(t,e){const n=this.options(t,e);if(n.index||"function"!=typeof this.store.getAll){const t=this.cursor(n),e=[];return this.Kt(t,((t,n)=>{e.push(n)})).next((()=>e))}{const t=this.store.getAll(n.range);return new Xa(((e,n)=>{t.onerror=t=>{n(t.target.error)},t.onsuccess=t=>{e(t.target.result)}}))}}Gt(t,e){const n=this.store.getAll(t,null===e?void 0:e);return new Xa(((t,e)=>{n.onerror=t=>{e(t.target.error)},n.onsuccess=e=>{t(e.target.result)}}))}Qt(t,e){Er("SimpleDb","DELETE ALL",this.store.name);const n=this.options(t,e);n.jt=!1;const r=this.cursor(n);return this.Kt(r,((t,e,n)=>n.delete()))}Wt(t,e){let n;e?n=t:(n={},e=t);const r=this.cursor(n);return this.Kt(r,e)}zt(t){const e=this.cursor({});return new Xa(((n,r)=>{e.onerror=t=>{const e=uu(t.target.error);r(e)},e.onsuccess=e=>{const r=e.target.result;r?t(r.primaryKey,r.value).next((t=>{t?r.continue():n()})):n()}}))}Kt(t,e){const n=[];return new Xa(((r,i)=>{t.onerror=t=>{i(t.target.error)},t.onsuccess=t=>{const i=t.target.result;if(!i)return void r();const s=new nu(i),o=e(i.primaryKey,i.value,s);if(o instanceof Xa){const t=o.catch((t=>(s.done(),Xa.reject(t))));n.push(t)}s.isDone?r():null===s.Lt?i.continue():i.continue(s.Lt)}})).next((()=>Xa.waitFor(n)))}options(t,e){let n;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}}cursor(t){let e="next";if(t.reverse&&(e="prev"),t.index){const n=this.store.index(t.index);return t.jt?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)}}function ou(t){return new Xa(((e,n)=>{t.onsuccess=t=>{const n=t.target.result;e(n)},t.onerror=t=>{const e=uu(t.target.error);n(e)}}))}let au=!1;function uu(t){const e=eu.Vt((0,a.z$)());if(e>=12.2&&e<13){const e="An internal error was encountered in the Indexed Database server";if(t.message.indexOf(e)>=0){const t=new Rr("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${e}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return au||(au=!0,setTimeout((()=>{throw t}),0)),t}}return t}class cu extends Ja{constructor(t,e){super(),this.Ht=t,this.currentSequenceNumber=e}}function hu(t,e){const n=Dr(t);return eu.xt(n.Ht,e)}class lu{constructor(t,e,n,r){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(t,e){const n=e.mutationResults;for(let e=0;e<this.mutations.length;e++){const r=this.mutations[e];r.key.isEqual(t.key)&&ho(r,t,n[e])}}applyToLocalView(t){for(const e of this.baseMutations)e.key.isEqual(t.key)&&lo(e,t,this.localWriteTime);for(const e of this.mutations)e.key.isEqual(t.key)&&lo(e,t,this.localWriteTime)}applyToLocalDocumentSet(t){this.mutations.forEach((e=>{const n=t.get(e.key),r=n;this.applyToLocalView(r),n.isValidDocument()||r.convertToNoDocument(Zr.min())}))}keys(){return this.mutations.reduce(((t,e)=>t.add(e.key)),Mo())}isEqual(t){return this.batchId===t.batchId&&Hr(this.mutations,t.mutations,((t,e)=>po(t,e)))&&Hr(this.baseMutations,t.baseMutations,((t,e)=>po(t,e)))}}class du{constructor(t,e,n,r){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=r}static from(t,e,n){kr(t.mutations.length===n.length);let r=Po;const i=t.mutations;for(let t=0;t<i.length;t++)r=r.insert(i[t].key,n[t].version);return new du(t,e,n,r)}}class fu{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 }`}}class pu{constructor(t,e,n,r,i=Zr.min(),s=Zr.min(),o=ai.EMPTY_BYTE_STRING){this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o}withSequenceNumber(t){return new pu(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}withResumeToken(t,e){return new pu(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)}withLastLimboFreeSnapshotVersion(t){return new pu(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken)}}class mu{constructor(t){this.Jt=t}}function gu(t,e){const n=e.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:yu(e.readTime),hasCommittedMutations:e.hasCommittedMutations};if(e.isFoundDocument())r.document=function(t,e){return{name:ra(t,e.key),fields:e.data.value.mapValue.fields,updateTime:Zo(t,e.version.toTimestamp())}}(t.Jt,e);else if(e.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:vu(e.version)};else{if(!e.isUnknownDocument())return Nr();r.unknownDocument={path:n.path.toArray(),version:vu(e.version)}}return r}function yu(t){const e=t.toTimestamp();return[e.seconds,e.nanoseconds]}function vu(t){const e=t.toTimestamp();return{seconds:e.seconds,nanoseconds:e.nanoseconds}}function bu(t){const e=new Qr(t.seconds,t.nanoseconds);return Zr.fromTimestamp(e)}function wu(t,e){const n=(e.baseMutations||[]).map((e=>da(t.Jt,e)));for(let t=0;t<e.mutations.length-1;++t){const n=e.mutations[t];if(t+1<e.mutations.length&&void 0!==e.mutations[t+1].transform){const r=e.mutations[t+1];n.updateTransforms=r.transform.fieldTransforms,e.mutations.splice(t+1,1),++t}}const r=e.mutations.map((e=>da(t.Jt,e))),i=Qr.fromMillis(e.localWriteTimeMs);return new lu(e.batchId,i,n,r)}function Iu(t){const e=bu(t.readTime),n=void 0!==t.lastLimboFreeSnapshotVersion?bu(t.lastLimboFreeSnapshotVersion):Zr.min();let r;var i;return void 0!==t.query.documents?(kr(1===(i=t.query).documents.length),r=Ls(Cs(oa(i.documents[0])))):r=function(t){return Ls(ma(t))}(t.query),new pu(r,t.targetId,0,t.lastListenSequenceNumber,e,n,ai.fromBase64String(t.resumeToken))}function _u(t,e){const n=vu(e.snapshotVersion),r=vu(e.lastLimboFreeSnapshotVersion);let i;i=hs(e.target)?fa(t.Jt,e.target):pa(t.Jt,e.target);const s=e.resumeToken.toBase64();return{targetId:e.targetId,canonicalId:us(e.target),readTime:n,resumeToken:s,lastListenSequenceNumber:e.sequenceNumber,lastLimboFreeSnapshotVersion:r,query:i}}function Tu(t){const e=ma({parent:t.parent,structuredQuery:t.structuredQuery});return"LAST"===t.limitType?Ms(e,e.limit,"L"):e}function Eu(t,e){return new fu(e.largestBatchId,da(t.Jt,e.overlayMutation))}function Su(t,e){const n=e.path.lastSegment();return[t,Sa(e.path.popLast()),n]}class Au{getBundleMetadata(t,e){return xu(t).get(e).next((t=>{if(t)return{id:(e=t).bundleId,createTime:bu(e.createTime),version:e.version};var e}))}saveBundleMetadata(t,e){return xu(t).put({bundleId:(n=e).id,createTime:vu(ta(n.createTime)),version:n.version});var n}getNamedQuery(t,e){return Nu(t).get(e).next((t=>{if(t)return{name:(e=t).name,query:Tu(e.bundledQuery),readTime:bu(e.readTime)};var e}))}saveNamedQuery(t,e){return Nu(t).put(function(t){return{name:t.name,readTime:vu(ta(t.readTime)),bundledQuery:t.bundledQuery}}(e))}}function xu(t){return hu(t,"bundles")}function Nu(t){return hu(t,"namedQueries")}class ku{constructor(t,e){this.M=t,this.userId=e}static Yt(t,e){const n=e.uid||"";return new ku(t,n)}getOverlay(t,e){return Cu(t).get(Su(this.userId,e)).next((t=>t?Eu(this.M,t):null))}saveOverlays(t,e,n){const r=[];return n.forEach(((n,i)=>{const s=new fu(e,i);r.push(this.Xt(t,s))})),Xa.waitFor(r)}removeOverlaysForBatchId(t,e,n){const r=new Set;e.forEach((t=>r.add(Sa(t.getCollectionPath()))));const i=[];return r.forEach((e=>{const r=IDBKeyRange.bound([this.userId,e,n],[this.userId,e,n+1],!1,!0);i.push(Cu(t).Qt("collectionPathOverlayIndex",r))})),Xa.waitFor(i)}getOverlaysForCollection(t,e,n){const r=Ro(),i=Sa(e),s=IDBKeyRange.bound([this.userId,i,n],[this.userId,i,Number.POSITIVE_INFINITY],!0);return Cu(t).qt("collectionPathOverlayIndex",s).next((t=>{for(const e of t){const t=Eu(this.M,e);r.set(t.getKey(),t)}return r}))}getOverlaysForCollectionGroup(t,e,n,r){const i=Ro();let s;const o=IDBKeyRange.bound([this.userId,e,n],[this.userId,e,Number.POSITIVE_INFINITY],!0);return Cu(t).Wt({index:"collectionGroupOverlayIndex",range:o},((t,e,n)=>{const o=Eu(this.M,e);i.size()<r||o.largestBatchId===s?(i.set(o.getKey(),o),s=o.largestBatchId):n.done()})).next((()=>i))}Xt(t,e){return Cu(t).put(function(t,e,n){const[r,i,s]=Su(e,n.mutation.key);return{userId:e,collectionPath:i,documentId:s,collectionGroup:n.mutation.key.getCollectionGroup(),largestBatchId:n.largestBatchId,overlayMutation:la(t.Jt,n.mutation)}}(this.M,this.userId,e))}}function Cu(t){return hu(t,"documentOverlays")}class Du{constructor(){}Zt(t,e){this.te(t,e),e.ee()}te(t,e){if("nullValue"in t)this.ne(e,5);else if("booleanValue"in t)this.ne(e,10),e.se(t.booleanValue?1:0);else if("integerValue"in t)this.ne(e,15),e.se(hi(t.integerValue));else if("doubleValue"in t){const n=hi(t.doubleValue);isNaN(n)?this.ne(e,13):(this.ne(e,15),vi(n)?e.se(0):e.se(n))}else if("timestampValue"in t){const n=t.timestampValue;this.ne(e,20),"string"==typeof n?e.ie(n):(e.ie(`${n.seconds||""}`),e.se(n.nanos||0))}else if("stringValue"in t)this.re(t.stringValue,e),this.oe(e);else if("bytesValue"in t)this.ne(e,30),e.ue(li(t.bytesValue)),this.oe(e);else if("referenceValue"in t)this.ae(t.referenceValue,e);else if("geoPointValue"in t){const n=t.geoPointValue;this.ne(e,45),e.se(n.latitude||0),e.se(n.longitude||0)}else"mapValue"in t?Vi(t)?this.ne(e,Number.MAX_SAFE_INTEGER):(this.ce(t.mapValue,e),this.oe(e)):"arrayValue"in t?(this.he(t.arrayValue,e),this.oe(e)):Nr()}re(t,e){this.ne(e,25),this.le(t,e)}le(t,e){e.ie(t)}ce(t,e){const n=t.fields||{};this.ne(e,55);for(const t of Object.keys(n))this.re(t,e),this.te(n[t],e)}he(t,e){const n=t.values||[];this.ne(e,50);for(const t of n)this.te(t,e)}ae(t,e){this.ne(e,37),wi.fromName(t).path.forEach((t=>{this.ne(e,60),this.le(t,e)}))}ne(t,e){t.se(e)}oe(t){t.se(2)}}function Ou(t){if(0===t)return 8;let e=0;return t>>4==0&&(e+=4,t<<=4),t>>6==0&&(e+=2,t<<=2),t>>7==0&&(e+=1),e}function Ru(t){const e=64-function(t){let e=0;for(let n=0;n<8;++n){const r=Ou(255&t[n]);if(e+=r,8!==r)break}return e}(t);return Math.ceil(e/8)}Du.fe=new Du;class Pu{constructor(){this.buffer=new Uint8Array(1024),this.position=0}de(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this._e(n.value),n=e.next();this.we()}me(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this.ge(n.value),n=e.next();this.ye()}pe(t){for(const e of t){const t=e.charCodeAt(0);if(t<128)this._e(t);else if(t<2048)this._e(960|t>>>6),this._e(128|63&t);else if(e<"\ud800"||"\udbff"<e)this._e(480|t>>>12),this._e(128|63&t>>>6),this._e(128|63&t);else{const t=e.codePointAt(0);this._e(240|t>>>18),this._e(128|63&t>>>12),this._e(128|63&t>>>6),this._e(128|63&t)}}this.we()}Ie(t){for(const e of t){const t=e.charCodeAt(0);if(t<128)this.ge(t);else if(t<2048)this.ge(960|t>>>6),this.ge(128|63&t);else if(e<"\ud800"||"\udbff"<e)this.ge(480|t>>>12),this.ge(128|63&t>>>6),this.ge(128|63&t);else{const t=e.codePointAt(0);this.ge(240|t>>>18),this.ge(128|63&t>>>12),this.ge(128|63&t>>>6),this.ge(128|63&t)}}this.ye()}Te(t){const e=this.Ee(t),n=Ru(e);this.Ae(1+n),this.buffer[this.position++]=255&n;for(let t=e.length-n;t<e.length;++t)this.buffer[this.position++]=255&e[t]}Re(t){const e=this.Ee(t),n=Ru(e);this.Ae(1+n),this.buffer[this.position++]=~(255&n);for(let t=e.length-n;t<e.length;++t)this.buffer[this.position++]=~(255&e[t])}be(){this.Pe(255),this.Pe(255)}Ve(){this.ve(255),this.ve(255)}reset(){this.position=0}seed(t){this.Ae(t.length),this.buffer.set(t,this.position),this.position+=t.length}Se(){return this.buffer.slice(0,this.position)}Ee(t){const e=function(t){const e=new DataView(new ArrayBuffer(8));return e.setFloat64(0,t,!1),new Uint8Array(e.buffer)}(t),n=0!=(128&e[0]);e[0]^=n?255:128;for(let t=1;t<e.length;++t)e[t]^=n?255:0;return e}_e(t){const e=255&t;0===e?(this.Pe(0),this.Pe(255)):255===e?(this.Pe(255),this.Pe(0)):this.Pe(e)}ge(t){const e=255&t;0===e?(this.ve(0),this.ve(255)):255===e?(this.ve(255),this.ve(0)):this.ve(t)}we(){this.Pe(0),this.Pe(1)}ye(){this.ve(0),this.ve(1)}Pe(t){this.Ae(1),this.buffer[this.position++]=t}ve(t){this.Ae(1),this.buffer[this.position++]=~t}Ae(t){const e=t+this.position;if(e<=this.buffer.length)return;let n=2*this.buffer.length;n<e&&(n=e);const r=new Uint8Array(n);r.set(this.buffer),this.buffer=r}}class Lu{constructor(t){this.De=t}ue(t){this.De.de(t)}ie(t){this.De.pe(t)}se(t){this.De.Te(t)}ee(){this.De.be()}}class Mu{constructor(t){this.De=t}ue(t){this.De.me(t)}ie(t){this.De.Ie(t)}se(t){this.De.Re(t)}ee(){this.De.Ve()}}class Vu{constructor(){this.De=new Pu,this.Ce=new Lu(this.De),this.xe=new Mu(this.De)}seed(t){this.De.seed(t)}Ne(t){return 0===t?this.Ce:this.xe}Se(){return this.De.Se()}reset(){this.De.reset()}}class Fu{constructor(t,e,n,r){this.indexId=t,this.documentKey=e,this.arrayValue=n,this.directionalValue=r}ke(){const t=this.directionalValue.length,e=0===t||255===this.directionalValue[t-1]?t+1:t,n=new Uint8Array(e);return n.set(this.directionalValue,0),e!==t?n.set([0],this.directionalValue.length):++n[n.length-1],new Fu(this.indexId,this.documentKey,this.arrayValue,n)}}function Uu(t,e){let n=t.indexId-e.indexId;return 0!==n?n:(n=ju(t.arrayValue,e.arrayValue),0!==n?n:(n=ju(t.directionalValue,e.directionalValue),0!==n?n:wi.comparator(t.documentKey,e.documentKey)))}function ju(t,e){for(let n=0;n<t.length&&n<e.length;++n){const r=t[n]-e[n];if(0!==r)return r}return t.length-e.length}class Bu{constructor(t){this.collectionId=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment(),this.Me=t.orderBy,this.Oe=[];for(const e of t.filters){const t=e;t.S()?this.Fe=t:this.Oe.push(t)}}$e(t){const e=Wi(t);if(void 0!==e&&!this.Be(e))return!1;const n=$i(t);let r=0,i=0;for(;r<n.length&&this.Be(n[r]);++r);if(r===n.length)return!0;if(void 0!==this.Fe){const t=n[r];if(!this.Le(this.Fe,t)||!this.Ue(this.Me[i++],t))return!1;++r}for(;r<n.length;++r){const t=n[r];if(i>=this.Me.length||!this.Ue(this.Me[i++],t))return!1}return!0}Be(t){for(const e of this.Oe)if(this.Le(e,t))return!0;return!1}Le(t,e){if(void 0===t||!t.field.isEqual(e.fieldPath))return!1;const n="array-contains"===t.op||"array-contains-any"===t.op;return 2===e.kind===n}Ue(t,e){return!!t.field.isEqual(e.fieldPath)&&(0===e.kind&&"asc"===t.dir||1===e.kind&&"desc"===t.dir)}}class qu{constructor(){this.qe=new zu}addToCollectionParentIndex(t,e){return this.qe.add(e),Xa.resolve()}getCollectionParents(t,e){return Xa.resolve(this.qe.getEntries(e))}addFieldIndex(t,e){return Xa.resolve()}deleteFieldIndex(t,e){return Xa.resolve()}getDocumentsMatchingTarget(t,e){return Xa.resolve(null)}getIndexType(t,e){return Xa.resolve(0)}getFieldIndexes(t,e){return Xa.resolve([])}getNextCollectionGroupToUpdate(t){return Xa.resolve(null)}getMinOffset(t,e){return Xa.resolve(Ji.min())}updateCollectionGroup(t,e,n){return Xa.resolve()}updateIndexEntries(t,e){return Xa.resolve()}}class zu{constructor(){this.index={}}add(t){const e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new rs(ni.comparator),i=!r.has(n);return this.index[e]=r.add(n),i}has(t){const e=t.lastSegment(),n=t.popLast(),r=this.index[e];return r&&r.has(n)}getEntries(t){return(this.index[t]||new rs(ni.comparator)).toArray()}}const Ku=new Uint8Array(0);class Gu{constructor(t,e){this.user=t,this.databaseId=e,this.Ke=new zu,this.Ge=new No((t=>us(t)),((t,e)=>cs(t,e))),this.uid=t.uid||""}addToCollectionParentIndex(t,e){if(!this.Ke.has(e)){const n=e.lastSegment(),r=e.popLast();t.addOnCommittedListener((()=>{this.Ke.add(e)}));const i={collectionId:n,parent:Sa(r)};return Wu(t).put(i)}return Xa.resolve()}getCollectionParents(t,e){const n=[],r=IDBKeyRange.bound([e,""],[Yr(e),""],!1,!0);return Wu(t).qt(r).next((t=>{for(const r of t){if(r.collectionId!==e)break;n.push(Na(r.parent))}return n}))}addFieldIndex(t,e){const n=Hu(t),r=function(t){return{indexId:t.indexId,collectionGroup:t.collectionGroup,fields:t.fields.map((t=>[t.fieldPath.canonicalString(),t.kind]))}}(e);return delete r.indexId,n.add(r).next()}deleteFieldIndex(t,e){const n=Hu(t),r=Yu(t),i=$u(t);return n.delete(e.indexId).next((()=>r.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0)))).next((()=>i.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0))))}getDocumentsMatchingTarget(t,e){const n=$u(t);let r=!0;const i=new Map;return Xa.forEach(this.Qe(e),(e=>this.je(t,e).next((t=>{r&&(r=!!t),i.set(e,t)})))).next((()=>{if(r){let t=Mo();const r=[];return Xa.forEach(i,((i,s)=>{var o;Er("IndexedDbIndexManager",`Using index ${o=i,`id=${o.indexId}|cg=${o.collectionGroup}|f=${o.fields.map((t=>`${t.fieldPath}:${t.kind}`)).join(",")}`} to execute ${us(e)}`);const a=function(t,e){const n=Wi(e);if(void 0===n)return null;for(const e of ls(t,n.fieldPath))switch(e.op){case"array-contains-any":return e.value.arrayValue.values||[];case"array-contains":return[e.value]}return null}(s,i),u=function(t,e){const n=new Map;for(const r of $i(e))for(const e of ls(t,r.fieldPath))switch(e.op){case"==":case"in":n.set(r.fieldPath.canonicalString(),e.value);break;case"not-in":case"!=":return n.set(r.fieldPath.canonicalString(),e.value),Array.from(n.values())}return null}(s,i),c=function(t,e){const n=[];let r=!0;for(const i of $i(e)){const e=0===i.kind?ds(t,i.fieldPath,t.startAt):fs(t,i.fieldPath,t.startAt);n.push(e.value),r&&(r=e.inclusive)}return new Ts(n,r)}(s,i),h=function(t,e){const n=[];let r=!0;for(const i of $i(e)){const e=0===i.kind?fs(t,i.fieldPath,t.endAt):ds(t,i.fieldPath,t.endAt);n.push(e.value),r&&(r=e.inclusive)}return new Ts(n,r)}(s,i),l=this.We(i,s,c),d=this.We(i,s,h),f=this.ze(i,s,u),p=this.He(i.indexId,a,l,c.inclusive,d,h.inclusive,f);return Xa.forEach(p,(i=>n.Gt(i,e.limit).next((e=>{e.forEach((e=>{const n=wi.fromSegments(e.documentKey);t.has(n)||(t=t.add(n),r.push(n))}))}))))})).next((()=>r))}return Xa.resolve(null)}))}Qe(t){let e=this.Ge.get(t);return e||(e=[t],this.Ge.set(t,e),e)}He(t,e,n,r,i,s,o){const a=(null!=e?e.length:1)*Math.max(n.length,i.length),u=a/(null!=e?e.length:1),c=[];for(let h=0;h<a;++h){const a=e?this.Je(e[h/u]):Ku,l=this.Ye(t,a,n[h%u],r),d=this.Xe(t,a,i[h%u],s),f=o.map((e=>this.Ye(t,a,e,!0)));c.push(...this.createRange(l,d,f))}return c}Ye(t,e,n,r){const i=new Fu(t,wi.empty(),e,n);return r?i:i.ke()}Xe(t,e,n,r){const i=new Fu(t,wi.empty(),e,n);return r?i.ke():i}je(t,e){const n=new Bu(e),r=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment();return this.getFieldIndexes(t,r).next((t=>{let e=null;for(const r of t)n.$e(r)&&(!e||r.fields.length>e.fields.length)&&(e=r);return e}))}getIndexType(t,e){let n=2;return Xa.forEach(this.Qe(e),(e=>this.je(t,e).next((t=>{t?0!==n&&t.fields.length<function(t){let e=new rs(ii.comparator),n=!1;for(const r of t.filters){const t=r;t.field.isKeyField()||("array-contains"===t.op||"array-contains-any"===t.op?n=!0:e=e.add(t.field))}for(const n of t.orderBy)n.field.isKeyField()||(e=e.add(n.field));return e.size+(n?1:0)}(e)&&(n=1):n=0})))).next((()=>n))}Ze(t,e){const n=new Vu;for(const r of $i(t)){const t=e.data.field(r.fieldPath);if(null==t)return null;const i=n.Ne(r.kind);Du.fe.Zt(t,i)}return n.Se()}Je(t){const e=new Vu;return Du.fe.Zt(t,e.Ne(0)),e.Se()}tn(t,e){const n=new Vu;return Du.fe.Zt(Ci(this.databaseId,e),n.Ne(function(t){const e=$i(t);return 0===e.length?0:e[e.length-1].kind}(t))),n.Se()}ze(t,e,n){if(null===n)return[];let r=[];r.push(new Vu);let i=0;for(const s of $i(t)){const t=n[i++];for(const n of r)if(this.en(e,s.fieldPath)&&Oi(t))r=this.nn(r,s,t);else{const e=n.Ne(s.kind);Du.fe.Zt(t,e)}}return this.sn(r)}We(t,e,n){return this.ze(t,e,n.position)}sn(t){const e=[];for(let n=0;n<t.length;++n)e[n]=t[n].Se();return e}nn(t,e,n){const r=[...t],i=[];for(const t of n.arrayValue.values||[])for(const n of r){const r=new Vu;r.seed(n.Se()),Du.fe.Zt(t,r.Ne(e.kind)),i.push(r)}return i}en(t,e){return!!t.filters.find((t=>t instanceof ps&&t.field.isEqual(e)&&("in"===t.op||"not-in"===t.op)))}getFieldIndexes(t,e){const n=Hu(t),r=Yu(t);return(e?n.qt("collectionGroupIndex",IDBKeyRange.bound(e,e)):n.qt()).next((t=>{const e=[];return Xa.forEach(t,(t=>r.get([t.indexId,this.uid]).next((n=>{e.push(function(t,e){const n=e?new Yi(e.sequenceNumber,new Ji(bu(e.readTime),new wi(Na(e.documentKey)),e.largestBatchId)):Yi.empty(),r=t.fields.map((([t,e])=>new Hi(ii.fromServerFormat(t),e)));return new Gi(t.indexId,t.collectionGroup,r,n)}(t,n))})))).next((()=>e))}))}getNextCollectionGroupToUpdate(t){return this.getFieldIndexes(t).next((t=>0===t.length?null:(t.sort(((t,e)=>{const n=t.indexState.sequenceNumber-e.indexState.sequenceNumber;return 0!==n?n:$r(t.collectionGroup,e.collectionGroup)})),t[0].collectionGroup)))}updateCollectionGroup(t,e,n){const r=Hu(t),i=Yu(t);return this.rn(t).next((t=>r.qt("collectionGroupIndex",IDBKeyRange.bound(e,e)).next((e=>Xa.forEach(e,(e=>i.put(function(t,e,n,r){return{indexId:t,uid:e.uid||"",sequenceNumber:n,readTime:vu(r.readTime),documentKey:Sa(r.documentKey.path),largestBatchId:r.largestBatchId}}(e.indexId,this.user,t,n))))))))}updateIndexEntries(t,e){const n=new Map;return Xa.forEach(e,((e,r)=>{const i=n.get(e.collectionGroup);return(i?Xa.resolve(i):this.getFieldIndexes(t,e.collectionGroup)).next((i=>(n.set(e.collectionGroup,i),Xa.forEach(i,(n=>this.on(t,e,n).next((e=>{const i=this.un(r,n);return e.isEqual(i)?Xa.resolve():this.an(t,r,n,e,i)})))))))}))}cn(t,e,n,r){return $u(t).put({indexId:r.indexId,uid:this.uid,arrayValue:r.arrayValue,directionalValue:r.directionalValue,orderedDocumentKey:this.tn(n,e.key),documentKey:e.key.path.toArray()})}hn(t,e,n,r){return $u(t).delete([r.indexId,this.uid,r.arrayValue,r.directionalValue,this.tn(n,e.key),e.key.path.toArray()])}on(t,e,n){const r=$u(t);let i=new rs(Uu);return r.Wt({index:"documentKeyIndex",range:IDBKeyRange.only([n.indexId,this.uid,this.tn(n,e)])},((t,r)=>{i=i.add(new Fu(n.indexId,e,r.arrayValue,r.directionalValue))})).next((()=>i))}un(t,e){let n=new rs(Uu);const r=this.Ze(e,t);if(null==r)return n;const i=Wi(e);if(null!=i){const s=t.data.field(i.fieldPath);if(Oi(s))for(const i of s.arrayValue.values||[])n=n.add(new Fu(e.indexId,t.key,this.Je(i),r))}else n=n.add(new Fu(e.indexId,t.key,Ku,r));return n}an(t,e,n,r,i){Er("IndexedDbIndexManager","Updating index entries for document '%s'",e.key);const s=[];return function(t,e,n,r,i){const s=t.getIterator(),o=e.getIterator();let a=ss(s),u=ss(o);for(;a||u;){let t=!1,e=!1;if(a&&u){const r=n(a,u);r<0?e=!0:r>0&&(t=!0)}else null!=a?e=!0:t=!0;t?(r(u),u=ss(o)):e?(i(a),a=ss(s)):(a=ss(s),u=ss(o))}}(r,i,Uu,(r=>{s.push(this.cn(t,e,n,r))}),(r=>{s.push(this.hn(t,e,n,r))})),Xa.waitFor(s)}rn(t){let e=1;return Yu(t).Wt({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},((t,n,r)=>{r.done(),e=n.sequenceNumber+1})).next((()=>e))}createRange(t,e,n){n=n.sort(((t,e)=>Uu(t,e))).filter(((t,e,n)=>!e||0!==Uu(t,n[e-1])));const r=[];r.push(t);for(const i of n){const n=Uu(i,t),s=Uu(i,e);if(0===n)r[0]=t.ke();else if(n>0&&s<0)r.push(i),r.push(i.ke());else if(s>0)break}r.push(e);const i=[];for(let t=0;t<r.length;t+=2)i.push(IDBKeyRange.bound([r[t].indexId,this.uid,r[t].arrayValue,r[t].directionalValue,Ku,[]],[r[t+1].indexId,this.uid,r[t+1].arrayValue,r[t+1].directionalValue,Ku,[]]));return i}getMinOffset(t,e){let n;return Xa.forEach(this.Qe(e),(e=>this.je(t,e).next((t=>{t?(!n||Xi(t.indexState.offset,n)<0)&&(n=t.indexState.offset):n=Ji.min()})))).next((()=>n))}}function Wu(t){return hu(t,"collectionParents")}function $u(t){return hu(t,"indexEntries")}function Hu(t){return hu(t,"indexConfiguration")}function Yu(t){return hu(t,"indexState")}const Qu={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class Zu{constructor(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}static withCacheSize(t){return new Zu(t,Zu.DEFAULT_COLLECTION_PERCENTILE,Zu.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}function Ju(t,e,n){const r=t.store("mutations"),i=t.store("documentMutations"),s=[],o=IDBKeyRange.only(n.batchId);let a=0;const u=r.Wt({range:o},((t,e,n)=>(a++,n.delete())));s.push(u.next((()=>{kr(1===a)})));const c=[];for(const t of n.mutations){const r=Da(e,t.key.path,n.batchId);s.push(i.delete(r)),c.push(t.key)}return Xa.waitFor(s).next((()=>c))}function Xu(t){if(!t)return 0;let e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw Nr();e=t.noDocument}return JSON.stringify(e).length}Zu.DEFAULT_COLLECTION_PERCENTILE=10,Zu.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Zu.DEFAULT=new Zu(41943040,Zu.DEFAULT_COLLECTION_PERCENTILE,Zu.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Zu.DISABLED=new Zu(-1,0,0);class tc{constructor(t,e,n,r){this.userId=t,this.M=e,this.indexManager=n,this.referenceDelegate=r,this.ln={}}static Yt(t,e,n,r){kr(""!==t.uid);const i=t.isAuthenticated()?t.uid:"";return new tc(i,e,n,r)}checkEmpty(t){let e=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return nc(t).Wt({index:"userMutationsIndex",range:n},((t,n,r)=>{e=!1,r.done()})).next((()=>e))}addMutationBatch(t,e,n,r){const i=rc(t),s=nc(t);return s.add({}).next((o=>{kr("number"==typeof o);const a=new lu(o,e,n,r),u=function(t,e,n){const r=n.baseMutations.map((e=>la(t.Jt,e))),i=n.mutations.map((e=>la(t.Jt,e)));return{userId:e,batchId:n.batchId,localWriteTimeMs:n.localWriteTime.toMillis(),baseMutations:r,mutations:i}}(this.M,this.userId,a),c=[];let h=new rs(((t,e)=>$r(t.canonicalString(),e.canonicalString())));for(const t of r){const e=Da(this.userId,t.key.path,o);h=h.add(t.key.path.popLast()),c.push(s.put(u)),c.push(i.put(e,Oa))}return h.forEach((e=>{c.push(this.indexManager.addToCollectionParentIndex(t,e))})),t.addOnCommittedListener((()=>{this.ln[o]=a.keys()})),Xa.waitFor(c).next((()=>a))}))}lookupMutationBatch(t,e){return nc(t).get(e).next((t=>t?(kr(t.userId===this.userId),wu(this.M,t)):null))}fn(t,e){return this.ln[e]?Xa.resolve(this.ln[e]):this.lookupMutationBatch(t,e).next((t=>{if(t){const n=t.keys();return this.ln[e]=n,n}return null}))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,r=IDBKeyRange.lowerBound([this.userId,n]);let i=null;return nc(t).Wt({index:"userMutationsIndex",range:r},((t,e,r)=>{e.userId===this.userId&&(kr(e.batchId>=n),i=wu(this.M,e)),r.done()})).next((()=>i))}getHighestUnacknowledgedBatchId(t){const e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=-1;return nc(t).Wt({index:"userMutationsIndex",range:e,reverse:!0},((t,e,r)=>{n=e.batchId,r.done()})).next((()=>n))}getAllMutationBatches(t){const e=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return nc(t).qt("userMutationsIndex",e).next((t=>t.map((t=>wu(this.M,t)))))}getAllMutationBatchesAffectingDocumentKey(t,e){const n=Ca(this.userId,e.path),r=IDBKeyRange.lowerBound(n),i=[];return rc(t).Wt({range:r},((n,r,s)=>{const[o,a,u]=n,c=Na(a);if(o===this.userId&&e.path.isEqual(c))return nc(t).get(u).next((t=>{if(!t)throw Nr();kr(t.userId===this.userId),i.push(wu(this.M,t))}));s.done()})).next((()=>i))}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new rs($r);const r=[];return e.forEach((e=>{const i=Ca(this.userId,e.path),s=IDBKeyRange.lowerBound(i),o=rc(t).Wt({range:s},((t,r,i)=>{const[s,o,a]=t,u=Na(o);s===this.userId&&e.path.isEqual(u)?n=n.add(a):i.done()}));r.push(o)})),Xa.waitFor(r).next((()=>this.dn(t,n)))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,r=n.length+1,i=Ca(this.userId,n),s=IDBKeyRange.lowerBound(i);let o=new rs($r);return rc(t).Wt({range:s},((t,e,i)=>{const[s,a,u]=t,c=Na(a);s===this.userId&&n.isPrefixOf(c)?c.length===r&&(o=o.add(u)):i.done()})).next((()=>this.dn(t,o)))}dn(t,e){const n=[],r=[];return e.forEach((e=>{r.push(nc(t).get(e).next((t=>{if(null===t)throw Nr();kr(t.userId===this.userId),n.push(wu(this.M,t))})))})),Xa.waitFor(r).next((()=>n))}removeMutationBatch(t,e){return Ju(t.Ht,this.userId,e).next((n=>(t.addOnCommittedListener((()=>{this._n(e.batchId)})),Xa.forEach(n,(e=>this.referenceDelegate.markPotentiallyOrphaned(t,e))))))}_n(t){delete this.ln[t]}performConsistencyCheck(t){return this.checkEmpty(t).next((e=>{if(!e)return Xa.resolve();const n=IDBKeyRange.lowerBound([this.userId]),r=[];return rc(t).Wt({range:n},((t,e,n)=>{if(t[0]===this.userId){const e=Na(t[1]);r.push(e)}else n.done()})).next((()=>{kr(0===r.length)}))}))}containsKey(t,e){return ec(t,this.userId,e)}wn(t){return ic(t).get(this.userId).next((t=>t||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""}))}}function ec(t,e,n){const r=Ca(e,n.path),i=r[1],s=IDBKeyRange.lowerBound(r);let o=!1;return rc(t).Wt({range:s,jt:!0},((t,n,r)=>{const[s,a,u]=t;s===e&&a===i&&(o=!0),r.done()})).next((()=>o))}function nc(t){return hu(t,"mutations")}function rc(t){return hu(t,"documentMutations")}function ic(t){return hu(t,"mutationQueues")}class sc{constructor(t){this.mn=t}next(){return this.mn+=2,this.mn}static gn(){return new sc(0)}static yn(){return new sc(-1)}}class oc{constructor(t,e){this.referenceDelegate=t,this.M=e}allocateTargetId(t){return this.pn(t).next((e=>{const n=new sc(e.highestTargetId);return e.highestTargetId=n.next(),this.In(t,e).next((()=>e.highestTargetId))}))}getLastRemoteSnapshotVersion(t){return this.pn(t).next((t=>Zr.fromTimestamp(new Qr(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))))}getHighestSequenceNumber(t){return this.pn(t).next((t=>t.highestListenSequenceNumber))}setTargetsMetadata(t,e,n){return this.pn(t).next((r=>(r.highestListenSequenceNumber=e,n&&(r.lastRemoteSnapshotVersion=n.toTimestamp()),e>r.highestListenSequenceNumber&&(r.highestListenSequenceNumber=e),this.In(t,r))))}addTargetData(t,e){return this.Tn(t,e).next((()=>this.pn(t).next((n=>(n.targetCount+=1,this.En(e,n),this.In(t,n))))))}updateTargetData(t,e){return this.Tn(t,e)}removeTargetData(t,e){return this.removeMatchingKeysForTargetId(t,e.targetId).next((()=>ac(t).delete(e.targetId))).next((()=>this.pn(t))).next((e=>(kr(e.targetCount>0),e.targetCount-=1,this.In(t,e))))}removeTargets(t,e,n){let r=0;const i=[];return ac(t).Wt(((s,o)=>{const a=Iu(o);a.sequenceNumber<=e&&null===n.get(a.targetId)&&(r++,i.push(this.removeTargetData(t,a)))})).next((()=>Xa.waitFor(i))).next((()=>r))}forEachTarget(t,e){return ac(t).Wt(((t,n)=>{const r=Iu(n);e(r)}))}pn(t){return uc(t).get("targetGlobalKey").next((t=>(kr(null!==t),t)))}In(t,e){return uc(t).put("targetGlobalKey",e)}Tn(t,e){return ac(t).put(_u(this.M,e))}En(t,e){let n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n}getTargetCount(t){return this.pn(t).next((t=>t.targetCount))}getTargetData(t,e){const n=us(e),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let i=null;return ac(t).Wt({range:r,index:"queryTargetsIndex"},((t,n,r)=>{const s=Iu(n);cs(e,s.target)&&(i=s,r.done())})).next((()=>i))}addMatchingKeys(t,e,n){const r=[],i=cc(t);return e.forEach((e=>{const s=Sa(e.path);r.push(i.put({targetId:n,path:s})),r.push(this.referenceDelegate.addReference(t,n,e))})),Xa.waitFor(r)}removeMatchingKeys(t,e,n){const r=cc(t);return Xa.forEach(e,(e=>{const i=Sa(e.path);return Xa.waitFor([r.delete([n,i]),this.referenceDelegate.removeReference(t,n,e)])}))}removeMatchingKeysForTargetId(t,e){const n=cc(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)}getMatchingKeysForTargetId(t,e){const n=IDBKeyRange.bound([e],[e+1],!1,!0),r=cc(t);let i=Mo();return r.Wt({range:n,jt:!0},((t,e,n)=>{const r=Na(t[1]),s=new wi(r);i=i.add(s)})).next((()=>i))}containsKey(t,e){const n=Sa(e.path),r=IDBKeyRange.bound([n],[Yr(n)],!1,!0);let i=0;return cc(t).Wt({index:"documentTargetsIndex",jt:!0,range:r},(([t,e],n,r)=>{0!==t&&(i++,r.done())})).next((()=>i>0))}Et(t,e){return ac(t).get(e).next((t=>t?Iu(t):null))}}function ac(t){return hu(t,"targets")}function uc(t){return hu(t,"targetGlobal")}function cc(t){return hu(t,"targetDocuments")}async function hc(t){if(t.code!==Or.FAILED_PRECONDITION||t.message!==Za)throw t;Er("LocalStore","Unexpectedly lost primary lease")}function lc([t,e],[n,r]){const i=$r(t,n);return 0===i?$r(e,r):i}class dc{constructor(t){this.An=t,this.buffer=new rs(lc),this.Rn=0}bn(){return++this.Rn}Pn(t){const e=[t,this.bn()];if(this.buffer.size<this.An)this.buffer=this.buffer.add(e);else{const t=this.buffer.last();lc(e,t)<0&&(this.buffer=this.buffer.delete(t).add(e))}}get maxValue(){return this.buffer.last()[0]}}class fc{constructor(t,e){this.garbageCollector=t,this.asyncQueue=e,this.Vn=!1,this.vn=null}start(t){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Sn(t)}stop(){this.vn&&(this.vn.cancel(),this.vn=null)}get started(){return null!==this.vn}Sn(t){const e=this.Vn?3e5:6e4;Er("LruGarbageCollector",`Garbage collection scheduled in ${e}ms`),this.vn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.vn=null,this.Vn=!0;try{await t.collectGarbage(this.garbageCollector)}catch(t){iu(t)?Er("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",t):await hc(t)}await this.Sn(t)}))}}class pc{constructor(t,e){this.Dn=t,this.params=e}calculateTargetCount(t,e){return this.Dn.Cn(t).next((t=>Math.floor(e/100*t)))}nthSequenceNumber(t,e){if(0===e)return Xa.resolve(Kr.A);const n=new dc(e);return this.Dn.forEachTarget(t,(t=>n.Pn(t.sequenceNumber))).next((()=>this.Dn.xn(t,(t=>n.Pn(t))))).next((()=>n.maxValue))}removeTargets(t,e,n){return this.Dn.removeTargets(t,e,n)}removeOrphanedDocuments(t,e){return this.Dn.removeOrphanedDocuments(t,e)}collect(t,e){return-1===this.params.cacheSizeCollectionThreshold?(Er("LruGarbageCollector","Garbage collection skipped; disabled"),Xa.resolve(Qu)):this.getCacheSize(t).next((n=>n<this.params.cacheSizeCollectionThreshold?(Er("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Qu):this.Nn(t,e)))}getCacheSize(t){return this.Dn.getCacheSize(t)}Nn(t,e){let n,r,i,s,a,u,c;const h=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next((e=>(e>this.params.maximumSequenceNumbersToCollect?(Er("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${e}`),r=this.params.maximumSequenceNumbersToCollect):r=e,s=Date.now(),this.nthSequenceNumber(t,r)))).next((r=>(n=r,a=Date.now(),this.removeTargets(t,n,e)))).next((e=>(i=e,u=Date.now(),this.removeOrphanedDocuments(t,n)))).next((t=>(c=Date.now(),_r()<=o.in.DEBUG&&Er("LruGarbageCollector",`LRU Garbage Collection\n\tCounted targets in ${s-h}ms\n\tDetermined least recently used ${r} in `+(a-s)+"ms\n"+`\tRemoved ${i} targets in `+(u-a)+"ms\n"+`\tRemoved ${t} documents in `+(c-u)+"ms\n"+`Total Duration: ${c-h}ms`),Xa.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:t}))))}}class mc{constructor(t,e){this.db=t,this.garbageCollector=function(t,e){return new pc(t,e)}(this,e)}Cn(t){const e=this.kn(t);return this.db.getTargetCache().getTargetCount(t).next((t=>e.next((e=>t+e))))}kn(t){let e=0;return this.xn(t,(t=>{e++})).next((()=>e))}forEachTarget(t,e){return this.db.getTargetCache().forEachTarget(t,e)}xn(t,e){return this.Mn(t,((t,n)=>e(n)))}addReference(t,e,n){return gc(t,n)}removeReference(t,e,n){return gc(t,n)}removeTargets(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)}markPotentiallyOrphaned(t,e){return gc(t,e)}On(t,e){return function(t,e){let n=!1;return ic(t).zt((r=>ec(t,r,e).next((t=>(t&&(n=!0),Xa.resolve(!t)))))).next((()=>n))}(t,e)}removeOrphanedDocuments(t,e){const n=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[];let i=0;return this.Mn(t,((s,o)=>{if(o<=e){const e=this.On(t,s).next((e=>{if(!e)return i++,n.getEntry(t,s).next((()=>(n.removeEntry(s,Zr.min()),cc(t).delete([0,Sa(s.path)]))))}));r.push(e)}})).next((()=>Xa.waitFor(r))).next((()=>n.apply(t))).next((()=>i))}removeTarget(t,e){const n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)}updateLimboDocument(t,e){return gc(t,e)}Mn(t,e){const n=cc(t);let r,i=Kr.A;return n.Wt({index:"documentTargetsIndex"},(([t,n],{path:s,sequenceNumber:o})=>{0===t?(i!==Kr.A&&e(new wi(Na(r)),i),i=o,r=s):i=Kr.A})).next((()=>{i!==Kr.A&&e(new wi(Na(r)),i)}))}getCacheSize(t){return this.db.getRemoteDocumentCache().getSize(t)}}function gc(t,e){return cc(t).put(function(t,e){return{targetId:0,path:Sa(t.path),sequenceNumber:e}}(e,t.currentSequenceNumber))}class yc{constructor(){this.changes=new No((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,Ki.newInvalidDocument(t).setReadTime(e))}getEntry(t,e){this.assertNotApplied();const n=this.changes.get(e);return void 0!==n?Xa.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(){}}class vc{constructor(t){this.M=t}setIndexManager(t){this.indexManager=t}addEntry(t,e,n){return Ic(t).put(n)}removeEntry(t,e,n){return Ic(t).delete(function(t,e){const n=t.path.toArray();return[n.slice(0,n.length-2),n[n.length-2],yu(e),n[n.length-1]]}(e,n))}updateMetadata(t,e){return this.getMetadata(t).next((n=>(n.byteSize+=e,this.Fn(t,n))))}getEntry(t,e){let n=Ki.newInvalidDocument(e);return Ic(t).Wt({index:"documentKeyIndex",range:IDBKeyRange.only(_c(e))},((t,r)=>{n=this.$n(e,r)})).next((()=>n))}Bn(t,e){let n={size:0,document:Ki.newInvalidDocument(e)};return Ic(t).Wt({index:"documentKeyIndex",range:IDBKeyRange.only(_c(e))},((t,r)=>{n={document:this.$n(e,r),size:Xu(r)}})).next((()=>n))}getEntries(t,e){let n=Co();return this.Ln(t,e,((t,e)=>{const r=this.$n(t,e);n=n.insert(t,r)})).next((()=>n))}Un(t,e){let n=Co(),r=new ts(wi.comparator);return this.Ln(t,e,((t,e)=>{const i=this.$n(t,e);n=n.insert(t,i),r=r.insert(t,Xu(e))})).next((()=>({documents:n,qn:r})))}Ln(t,e,n){if(e.isEmpty())return Xa.resolve();let r=new rs(Ec);e.forEach((t=>r=r.add(t)));const i=IDBKeyRange.bound(_c(r.first()),_c(r.last())),s=r.getIterator();let o=s.getNext();return Ic(t).Wt({index:"documentKeyIndex",range:i},((t,e,r)=>{const i=wi.fromSegments([...e.prefixPath,e.collectionGroup,e.documentId]);for(;o&&Ec(o,i)<0;)n(o,null),o=s.getNext();o&&o.isEqual(i)&&(n(o,e),o=s.hasNext()?s.getNext():null),o?r.Ut(_c(o)):r.done()})).next((()=>{for(;o;)n(o,null),o=s.hasNext()?s.getNext():null}))}getAllFromCollection(t,e,n){const r=[e.popLast().toArray(),e.lastSegment(),yu(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],i=[e.popLast().toArray(),e.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return Ic(t).qt(IDBKeyRange.bound(r,i,!0)).next((t=>{let e=Co();for(const n of t){const t=this.$n(wi.fromSegments(n.prefixPath.concat(n.collectionGroup,n.documentId)),n);e=e.insert(t.key,t)}return e}))}getAllFromCollectionGroup(t,e,n,r){let i=Co();const s=Tc(e,n),o=Tc(e,Ji.max());return Ic(t).Wt({index:"collectionGroupIndex",range:IDBKeyRange.bound(s,o,!0)},((t,e,n)=>{const s=this.$n(wi.fromSegments(e.prefixPath.concat(e.collectionGroup,e.documentId)),e);i=i.insert(s.key,s),i.size===r&&n.done()})).next((()=>i))}newChangeBuffer(t){return new bc(this,!!t&&t.trackRemovals)}getSize(t){return this.getMetadata(t).next((t=>t.byteSize))}getMetadata(t){return wc(t).get("remoteDocumentGlobalKey").next((t=>(kr(!!t),t)))}Fn(t,e){return wc(t).put("remoteDocumentGlobalKey",e)}$n(t,e){if(e){const t=function(t,e){let n;if(e.document)n=ha(t.Jt,e.document,!!e.hasCommittedMutations);else if(e.noDocument){const t=wi.fromSegments(e.noDocument.path),r=bu(e.noDocument.readTime);n=Ki.newNoDocument(t,r),e.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!e.unknownDocument)return Nr();{const t=wi.fromSegments(e.unknownDocument.path),r=bu(e.unknownDocument.version);n=Ki.newUnknownDocument(t,r)}}return e.readTime&&n.setReadTime(function(t){const e=new Qr(t[0],t[1]);return Zr.fromTimestamp(e)}(e.readTime)),n}(this.M,e);if(!t.isNoDocument()||!t.version.isEqual(Zr.min()))return t}return Ki.newInvalidDocument(t)}}class bc extends yc{constructor(t,e){super(),this.Kn=t,this.trackRemovals=e,this.Gn=new No((t=>t.toString()),((t,e)=>t.isEqual(e)))}applyChanges(t){const e=[];let n=0,r=new rs(((t,e)=>$r(t.canonicalString(),e.canonicalString())));return this.changes.forEach(((i,s)=>{const o=this.Gn.get(i);if(e.push(this.Kn.removeEntry(t,i,o.readTime)),s.isValidDocument()){const a=gu(this.Kn.M,s);r=r.add(i.path.popLast());const u=Xu(a);n+=u-o.size,e.push(this.Kn.addEntry(t,i,a))}else if(n-=o.size,this.trackRemovals){const n=gu(this.Kn.M,s.convertToNoDocument(Zr.min()));e.push(this.Kn.addEntry(t,i,n))}})),r.forEach((n=>{e.push(this.Kn.indexManager.addToCollectionParentIndex(t,n))})),e.push(this.Kn.updateMetadata(t,n)),Xa.waitFor(e)}getFromCache(t,e){return this.Kn.Bn(t,e).next((t=>(this.Gn.set(e,{size:t.size,readTime:t.document.readTime}),t.document)))}getAllFromCache(t,e){return this.Kn.Un(t,e).next((({documents:t,qn:e})=>(e.forEach(((e,n)=>{this.Gn.set(e,{size:n,readTime:t.get(e).readTime})})),t)))}}function wc(t){return hu(t,"remoteDocumentGlobal")}function Ic(t){return hu(t,"remoteDocumentsV14")}function _c(t){const e=t.path.toArray();return[e.slice(0,e.length-2),e[e.length-2],e[e.length-1]]}function Tc(t,e){const n=e.documentKey.path.toArray();return[t,yu(e.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function Ec(t,e){const n=t.path.toArray(),r=e.path.toArray();let i=0;for(let t=0;t<n.length-2&&t<r.length-2;++t)if(i=$r(n[t],r[t]),i)return i;return i=$r(n.length,r.length),i||(i=$r(n[n.length-2],r[r.length-2]),i||$r(n[n.length-1],r[r.length-1]))}class Sc{constructor(t){this.M=t}kt(t,e,n,r){const i=new tu("createOrUpgrade",e);n<1&&r>=1&&(function(t){t.createObjectStore("owner")}(t),function(t){t.createObjectStore("mutationQueues",{keyPath:"userId"}),t.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",ka,{unique:!0}),t.createObjectStore("documentMutations")}(t),Ac(t),function(t){t.createObjectStore("remoteDocuments")}(t));let s=Xa.resolve();return n<3&&r>=3&&(0!==n&&(function(t){t.deleteObjectStore("targetDocuments"),t.deleteObjectStore("targets"),t.deleteObjectStore("targetGlobal")}(t),Ac(t)),s=s.next((()=>function(t){const e=t.store("targetGlobal"),n={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:Zr.min().toTimestamp(),targetCount:0};return e.put("targetGlobalKey",n)}(i)))),n<4&&r>=4&&(0!==n&&(s=s.next((()=>function(t,e){return e.store("mutations").qt().next((n=>{t.deleteObjectStore("mutations"),t.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",ka,{unique:!0});const r=e.store("mutations"),i=n.map((t=>r.put(t)));return Xa.waitFor(i)}))}(t,i)))),s=s.next((()=>{!function(t){t.createObjectStore("clientMetadata",{keyPath:"clientId"})}(t)}))),n<5&&r>=5&&(s=s.next((()=>this.Qn(i)))),n<6&&r>=6&&(s=s.next((()=>(function(t){t.createObjectStore("remoteDocumentGlobal")}(t),this.jn(i))))),n<7&&r>=7&&(s=s.next((()=>this.Wn(i)))),n<8&&r>=8&&(s=s.next((()=>this.zn(t,i)))),n<9&&r>=9&&(s=s.next((()=>{!function(t){t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges")}(t)}))),n<10&&r>=10&&(s=s.next((()=>this.Hn(i)))),n<11&&r>=11&&(s=s.next((()=>{!function(t){t.createObjectStore("bundles",{keyPath:"bundleId"})}(t),function(t){t.createObjectStore("namedQueries",{keyPath:"name"})}(t)}))),n<12&&r>=12&&(s=s.next((()=>{!function(t){const e=t.createObjectStore("documentOverlays",{keyPath:Ka});e.createIndex("collectionPathOverlayIndex",Ga,{unique:!1}),e.createIndex("collectionGroupOverlayIndex",Wa,{unique:!1})}(t)}))),n<13&&r>=13&&(s=s.next((()=>function(t){const e=t.createObjectStore("remoteDocumentsV14",{keyPath:Ra});e.createIndex("documentKeyIndex",Pa),e.createIndex("collectionGroupIndex",La)}(t))).next((()=>this.Jn(t,i))).next((()=>t.deleteObjectStore("remoteDocuments")))),n<14&&r>=14&&(s=s.next((()=>{!function(t){t.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),t.createObjectStore("indexState",{keyPath:ja}).createIndex("sequenceNumberIndex",Ba,{unique:!1}),t.createObjectStore("indexEntries",{keyPath:qa}).createIndex("documentKeyIndex",za,{unique:!1})}(t)}))),s}jn(t){let e=0;return t.store("remoteDocuments").Wt(((t,n)=>{e+=Xu(n)})).next((()=>{const n={byteSize:e};return t.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",n)}))}Qn(t){const e=t.store("mutationQueues"),n=t.store("mutations");return e.qt().next((e=>Xa.forEach(e,(e=>{const r=IDBKeyRange.bound([e.userId,-1],[e.userId,e.lastAcknowledgedBatchId]);return n.qt("userMutationsIndex",r).next((n=>Xa.forEach(n,(n=>{kr(n.userId===e.userId);const r=wu(this.M,n);return Ju(t,e.userId,r).next((()=>{}))}))))}))))}Wn(t){const e=t.store("targetDocuments"),n=t.store("remoteDocuments");return t.store("targetGlobal").get("targetGlobalKey").next((t=>{const r=[];return n.Wt(((n,i)=>{const s=new ni(n),o=function(t){return[0,Sa(t)]}(s);r.push(e.get(o).next((n=>n?Xa.resolve():(n=>e.put({targetId:0,path:Sa(n),sequenceNumber:t.highestListenSequenceNumber}))(s))))})).next((()=>Xa.waitFor(r)))}))}zn(t,e){t.createObjectStore("collectionParents",{keyPath:Ua});const n=e.store("collectionParents"),r=new zu,i=t=>{if(r.add(t)){const e=t.lastSegment(),r=t.popLast();return n.put({collectionId:e,parent:Sa(r)})}};return e.store("remoteDocuments").Wt({jt:!0},((t,e)=>{const n=new ni(t);return i(n.popLast())})).next((()=>e.store("documentMutations").Wt({jt:!0},(([t,e,n],r)=>{const s=Na(e);return i(s.popLast())}))))}Hn(t){const e=t.store("targets");return e.Wt(((t,n)=>{const r=Iu(n),i=_u(this.M,r);return e.put(i)}))}Jn(t,e){const n=e.store("remoteDocuments"),r=[];return n.Wt(((t,n)=>{const i=e.store("remoteDocumentsV14"),s=(o=n,o.document?new wi(ni.fromString(o.document.name).popFirst(5)):o.noDocument?wi.fromSegments(o.noDocument.path):o.unknownDocument?wi.fromSegments(o.unknownDocument.path):Nr()).path.toArray();var o;const a={prefixPath:s.slice(0,s.length-2),collectionGroup:s[s.length-2],documentId:s[s.length-1],readTime:n.readTime||[0,0],unknownDocument:n.unknownDocument,noDocument:n.noDocument,document:n.document,hasCommittedMutations:!!n.hasCommittedMutations};r.push(i.put(a))})).next((()=>Xa.waitFor(r)))}}function Ac(t){t.createObjectStore("targetDocuments",{keyPath:Va}).createIndex("documentTargetsIndex",Fa,{unique:!0}),t.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",Ma,{unique:!0}),t.createObjectStore("targetGlobal")}const xc="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.";class Nc{constructor(t,e,n,r,i,s,o,a,u,c,h=13){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.Yn=i,this.window=s,this.document=o,this.Xn=u,this.Zn=c,this.ts=h,this.es=null,this.ns=!1,this.isPrimary=!1,this.networkEnabled=!0,this.ss=null,this.inForeground=!1,this.rs=null,this.os=null,this.us=Number.NEGATIVE_INFINITY,this.cs=t=>Promise.resolve(),!Nc.vt())throw new Rr(Or.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new mc(this,r),this.hs=e+"main",this.M=new mu(a),this.ls=new eu(this.hs,this.ts,new Sc(this.M)),this.fs=new oc(this.referenceDelegate,this.M),this.ds=function(t){return new vc(t)}(this.M),this._s=new Au,this.window&&this.window.localStorage?this.ws=this.window.localStorage:(this.ws=null,!1===c&&Sr("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.gs().then((()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new Rr(Or.FAILED_PRECONDITION,xc);return this.ys(),this.ps(),this.Is(),this.runTransaction("getHighestListenSequenceNumber","readonly",(t=>this.fs.getHighestSequenceNumber(t)))})).then((t=>{this.es=new Kr(t,this.Xn)})).then((()=>{this.ns=!0})).catch((t=>(this.ls&&this.ls.close(),Promise.reject(t))))}Ts(t){return this.cs=async e=>{if(this.started)return t(e)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.ls.Ot((async e=>{null===e.newVersion&&await t()}))}setNetworkEnabled(t){this.networkEnabled!==t&&(this.networkEnabled=t,this.Yn.enqueueAndForget((async()=>{this.started&&await this.gs()})))}gs(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(t=>Cc(t).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next((()=>{if(this.isPrimary)return this.Es(t).next((t=>{t||(this.isPrimary=!1,this.Yn.enqueueRetryable((()=>this.cs(!1))))}))})).next((()=>this.As(t))).next((e=>this.isPrimary&&!e?this.Rs(t).next((()=>!1)):!!e&&this.bs(t).next((()=>!0)))))).catch((t=>{if(iu(t))return Er("IndexedDbPersistence","Failed to extend owner lease: ",t),this.isPrimary;if(!this.allowTabSynchronization)throw t;return Er("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1})).then((t=>{this.isPrimary!==t&&this.Yn.enqueueRetryable((()=>this.cs(t))),this.isPrimary=t}))}Es(t){return kc(t).get("owner").next((t=>Xa.resolve(this.Ps(t))))}Vs(t){return Cc(t).delete(this.clientId)}async vs(){if(this.isPrimary&&!this.Ss(this.us,18e5)){this.us=Date.now();const t=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(t=>{const e=hu(t,"clientMetadata");return e.qt().next((t=>{const n=this.Ds(t,18e5),r=t.filter((t=>-1===n.indexOf(t)));return Xa.forEach(r,(t=>e.delete(t.clientId))).next((()=>r))}))})).catch((()=>[]));if(this.ws)for(const e of t)this.ws.removeItem(this.Cs(e.clientId))}}Is(){this.os=this.Yn.enqueueAfterDelay("client_metadata_refresh",4e3,(()=>this.gs().then((()=>this.vs())).then((()=>this.Is()))))}Ps(t){return!!t&&t.ownerId===this.clientId}As(t){return this.Zn?Xa.resolve(!0):kc(t).get("owner").next((e=>{if(null!==e&&this.Ss(e.leaseTimestampMs,5e3)&&!this.xs(e.ownerId)){if(this.Ps(e)&&this.networkEnabled)return!0;if(!this.Ps(e)){if(!e.allowTabSynchronization)throw new Rr(Or.FAILED_PRECONDITION,xc);return!1}}return!(!this.networkEnabled||!this.inForeground)||Cc(t).qt().next((t=>void 0===this.Ds(t,5e3).find((t=>{if(this.clientId!==t.clientId){const e=!this.networkEnabled&&t.networkEnabled,n=!this.inForeground&&t.inForeground,r=this.networkEnabled===t.networkEnabled;if(e||n&&r)return!0}return!1}))))})).next((t=>(this.isPrimary!==t&&Er("IndexedDbPersistence",`Client ${t?"is":"is not"} eligible for a primary lease.`),t)))}async shutdown(){this.ns=!1,this.Ns(),this.os&&(this.os.cancel(),this.os=null),this.ks(),this.Ms(),await this.ls.runTransaction("shutdown","readwrite",["owner","clientMetadata"],(t=>{const e=new cu(t,Kr.A);return this.Rs(e).next((()=>this.Vs(e)))})),this.ls.close(),this.Os()}Ds(t,e){return t.filter((t=>this.Ss(t.updateTimeMs,e)&&!this.xs(t.clientId)))}Fs(){return this.runTransaction("getActiveClients","readonly",(t=>Cc(t).qt().next((t=>this.Ds(t,18e5).map((t=>t.clientId))))))}get started(){return this.ns}getMutationQueue(t,e){return tc.Yt(t,this.M,e,this.referenceDelegate)}getTargetCache(){return this.fs}getRemoteDocumentCache(){return this.ds}getIndexManager(t){return new Gu(t,this.M.Jt.databaseId)}getDocumentOverlayCache(t){return ku.Yt(this.M,t)}getBundleCache(){return this._s}runTransaction(t,e,n){Er("IndexedDbPersistence","Starting transaction:",t);const r="readonly"===e?"readonly":"readwrite",i=14===(s=this.ts)?Qa:13===s?Ya:12===s?Ha:11===s?$a:void Nr();var s;let o;return this.ls.runTransaction(t,r,i,(r=>(o=new cu(r,this.es?this.es.next():Kr.A),"readwrite-primary"===e?this.Es(o).next((t=>!!t||this.As(o))).next((e=>{if(!e)throw Sr(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.Yn.enqueueRetryable((()=>this.cs(!1))),new Rr(Or.FAILED_PRECONDITION,Za);return n(o)})).next((t=>this.bs(o).next((()=>t)))):this.$s(o).next((()=>n(o)))))).then((t=>(o.raiseOnCommittedEvent(),t)))}$s(t){return kc(t).get("owner").next((t=>{if(null!==t&&this.Ss(t.leaseTimestampMs,5e3)&&!this.xs(t.ownerId)&&!this.Ps(t)&&!(this.Zn||this.allowTabSynchronization&&t.allowTabSynchronization))throw new Rr(Or.FAILED_PRECONDITION,xc)}))}bs(t){const e={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return kc(t).put("owner",e)}static vt(){return eu.vt()}Rs(t){const e=kc(t);return e.get("owner").next((t=>this.Ps(t)?(Er("IndexedDbPersistence","Releasing primary lease."),e.delete("owner")):Xa.resolve()))}Ss(t,e){const n=Date.now();return!(t<n-e||t>n&&(Sr(`Detected an update time that is in the future: ${t} > ${n}`),1))}ys(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.rs=()=>{this.Yn.enqueueAndForget((()=>(this.inForeground="visible"===this.document.visibilityState,this.gs())))},this.document.addEventListener("visibilitychange",this.rs),this.inForeground="visible"===this.document.visibilityState)}ks(){this.rs&&(this.document.removeEventListener("visibilitychange",this.rs),this.rs=null)}ps(){var t;"function"==typeof(null===(t=this.window)||void 0===t?void 0:t.addEventListener)&&(this.ss=()=>{this.Ns(),(0,a.G6)()&&navigator.appVersion.match(/Version\/1[45]/)&&this.Yn.enterRestrictedMode(!0),this.Yn.enqueueAndForget((()=>this.shutdown()))},this.window.addEventListener("pagehide",this.ss))}Ms(){this.ss&&(this.window.removeEventListener("pagehide",this.ss),this.ss=null)}xs(t){var e;try{const n=null!==(null===(e=this.ws)||void 0===e?void 0:e.getItem(this.Cs(t)));return Er("IndexedDbPersistence",`Client '${t}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(t){return Sr("IndexedDbPersistence","Failed to get zombied client id.",t),!1}}Ns(){if(this.ws)try{this.ws.setItem(this.Cs(this.clientId),String(Date.now()))}catch(t){Sr("Failed to set zombie client id.",t)}}Os(){if(this.ws)try{this.ws.removeItem(this.Cs(this.clientId))}catch(t){}}Cs(t){return`firestore_zombie_${this.persistenceKey}_${t}`}}function kc(t){return hu(t,"owner")}function Cc(t){return hu(t,"clientMetadata")}function Dc(t,e){let n=t.projectId;return t.isDefaultDatabase||(n+="."+t.database),"firestore/"+e+"/"+n+"/"}class Oc{constructor(t,e,n){this.ds=t,this.Bs=e,this.indexManager=n}Ls(t,e){return this.Bs.getAllMutationBatchesAffectingDocumentKey(t,e).next((n=>this.Us(t,e,n)))}Us(t,e,n){return this.ds.getEntry(t,e).next((t=>{for(const e of n)e.applyToLocalView(t);return t}))}qs(t,e){t.forEach(((t,n)=>{for(const t of e)t.applyToLocalView(n)}))}Ks(t,e){return this.ds.getEntries(t,e).next((e=>this.Gs(t,e).next((()=>e))))}Gs(t,e){return this.Bs.getAllMutationBatchesAffectingDocumentKeys(t,e).next((t=>this.qs(e,t)))}Qs(t,e,n){return function(t){return wi.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}(e)?this.js(t,e.path):Rs(e)?this.Ws(t,e,n):this.zs(t,e,n)}js(t,e){return this.Ls(t,new wi(e)).next((t=>{let e=Oo();return t.isFoundDocument()&&(e=e.insert(t.key,t)),e}))}Ws(t,e,n){const r=e.collectionGroup;let i=Oo();return this.indexManager.getCollectionParents(t,r).next((s=>Xa.forEach(s,(s=>{const o=function(t,e){return new Ns(e,null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(e,s.child(r));return this.zs(t,o,n).next((t=>{t.forEach(((t,e)=>{i=i.insert(t,e)}))}))})).next((()=>i))))}zs(t,e,n){let r;return this.ds.getAllFromCollection(t,e.path,n).next((n=>(r=n,this.Bs.getAllMutationBatchesAffectingQuery(t,e)))).next((t=>{for(const e of t)for(const t of e.mutations){const n=t.key;let i=r.get(n);null==i&&(i=Ki.newInvalidDocument(n),r=r.insert(n,i)),lo(t,i,e.localWriteTime),i.isFoundDocument()||(r=r.remove(n))}})).next((()=>(r.forEach(((t,n)=>{js(e,n)||(r=r.remove(t))})),r)))}}class Rc{constructor(t,e,n,r){this.targetId=t,this.fromCache=e,this.Hs=n,this.Js=r}static Ys(t,e){let n=Mo(),r=Mo();for(const t of e.docChanges)switch(t.type){case 0:n=n.add(t.doc.key);break;case 1:r=r.add(t.doc.key)}return new Rc(t,e.fromCache,n,r)}}class Pc{constructor(){this.Xs=!1}initialize(t,e){this.Zs=t,this.indexManager=e,this.Xs=!0}Qs(t,e,n,r){return this.ti(t,e).next((i=>i||this.ei(t,e,r,n))).next((n=>n||this.ni(t,e)))}ti(t,e){return Xa.resolve(null)}ei(t,e,n,r){return function(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())}(e)||r.isEqual(Zr.min())?this.ni(t,e):this.Zs.Ks(t,n).next((i=>{const s=this.si(e,i);return this.ii(e,s,n,r)?this.ni(t,e):(_r()<=o.in.DEBUG&&Er("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),Us(e)),this.ri(t,s,e,Qi(r,-1)))}))}si(t,e){let n=new rs(qs(t));return e.forEach(((e,r)=>{js(t,r)&&(n=n.add(r))})),n}ii(t,e,n,r){if(null===t.limit)return!1;if(n.size!==e.size)return!0;const i="F"===t.limitType?e.last():e.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}ni(t,e){return _r()<=o.in.DEBUG&&Er("QueryEngine","Using full collection scan to execute query:",Us(e)),this.Zs.Qs(t,e,Ji.min())}ri(t,e,n,r){return this.Zs.Qs(t,n,r).next((t=>(e.forEach((e=>{t=t.insert(e.key,e)})),t)))}}class Lc{constructor(t,e,n,r){this.persistence=t,this.oi=e,this.M=r,this.ui=new ts($r),this.ai=new No((t=>us(t)),cs),this.ci=new Map,this.hi=t.getRemoteDocumentCache(),this.fs=t.getTargetCache(),this._s=t.getBundleCache(),this.li(n)}li(t){this.indexManager=this.persistence.getIndexManager(t),this.Bs=this.persistence.getMutationQueue(t,this.indexManager),this.fi=new Oc(this.hi,this.Bs,this.indexManager),this.hi.setIndexManager(this.indexManager),this.oi.initialize(this.fi,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(e=>t.collect(e,this.ui)))}}function Mc(t,e,n,r){return new Lc(t,e,n,r)}async function Vc(t,e){const n=Dr(t);return await n.persistence.runTransaction("Handle user change","readonly",(t=>{let r;return n.Bs.getAllMutationBatches(t).next((i=>(r=i,n.li(e),n.Bs.getAllMutationBatches(t)))).next((e=>{const i=[],s=[];let o=Mo();for(const t of r){i.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}for(const t of e){s.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}return n.fi.Ks(t,o).next((t=>({di:t,removedBatchIds:i,addedBatchIds:s})))}))}))}function Fc(t){const e=Dr(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.fs.getLastRemoteSnapshotVersion(t)))}function Uc(t,e,n){let r=Mo();return n.forEach((t=>r=r.add(t))),e.getEntries(t,r).next((t=>{let r=Co();return n.forEach(((n,i)=>{const s=t.get(n);i.isNoDocument()&&i.version.isEqual(Zr.min())?(e.removeEntry(n,i.readTime),r=r.insert(n,i)):!s.isValidDocument()||i.version.compareTo(s.version)>0||0===i.version.compareTo(s.version)&&s.hasPendingWrites?(e.addEntry(i),r=r.insert(n,i)):Er("LocalStore","Ignoring outdated watch update for ",n,". Current version:",s.version," Watch version:",i.version)})),r}))}function jc(t,e){const n=Dr(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(t=>(void 0===e&&(e=-1),n.Bs.getNextMutationBatchAfterBatchId(t,e))))}function Bc(t,e){const n=Dr(t);return n.persistence.runTransaction("Allocate target","readwrite",(t=>{let r;return n.fs.getTargetData(t,e).next((i=>i?(r=i,Xa.resolve(r)):n.fs.allocateTargetId(t).next((i=>(r=new pu(e,i,0,t.currentSequenceNumber),n.fs.addTargetData(t,r).next((()=>r)))))))})).then((t=>{const r=n.ui.get(t.targetId);return(null===r||t.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.ui=n.ui.insert(t.targetId,t),n.ai.set(e,t.targetId)),t}))}async function qc(t,e,n){const r=Dr(t),i=r.ui.get(e),s=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",s,(t=>r.persistence.referenceDelegate.removeTarget(t,i)))}catch(t){if(!iu(t))throw t;Er("LocalStore",`Failed to update sequence numbers for target ${e}: ${t}`)}r.ui=r.ui.remove(e),r.ai.delete(i.target)}function zc(t,e,n){const r=Dr(t);let i=Zr.min(),s=Mo();return r.persistence.runTransaction("Execute query","readonly",(t=>function(t,e,n){const r=Dr(t),i=r.ai.get(n);return void 0!==i?Xa.resolve(r.ui.get(i)):r.fs.getTargetData(e,n)}(r,t,Ls(e)).next((e=>{if(e)return i=e.lastLimboFreeSnapshotVersion,r.fs.getMatchingKeysForTargetId(t,e.targetId).next((t=>{s=t}))})).next((()=>r.oi.Qs(t,e,n?i:Zr.min(),n?s:Mo()))).next((t=>(Wc(r,Bs(e),t),{documents:t,_i:s})))))}function Kc(t,e){const n=Dr(t),r=Dr(n.fs),i=n.ui.get(e);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(t=>r.Et(t,e).next((t=>t?t.target:null))))}function Gc(t,e){const n=Dr(t),r=n.ci.get(e)||Zr.min();return n.persistence.runTransaction("Get new document changes","readonly",(t=>n.hi.getAllFromCollectionGroup(t,e,Qi(r,-1),Number.MAX_SAFE_INTEGER))).then((t=>(Wc(n,e,t),t)))}function Wc(t,e,n){let r=Zr.min();n.forEach(((t,e)=>{e.readTime.compareTo(r)>0&&(r=e.readTime)})),t.ci.set(e,r)}async function $c(t,e,n=Mo()){const r=await Bc(t,Ls(Tu(e.bundledQuery))),i=Dr(t);return i.persistence.runTransaction("Save named query","readwrite",(t=>{const s=ta(e.readTime);if(r.snapshotVersion.compareTo(s)>=0)return i._s.saveNamedQuery(t,e);const o=r.withResumeToken(ai.EMPTY_BYTE_STRING,s);return i.ui=i.ui.insert(o.targetId,o),i.fs.updateTargetData(t,o).next((()=>i.fs.removeMatchingKeysForTargetId(t,r.targetId))).next((()=>i.fs.addMatchingKeys(t,n,r.targetId))).next((()=>i._s.saveNamedQuery(t,e)))}))}class Hc{constructor(t){this.M=t,this.yi=new Map,this.pi=new Map}getBundleMetadata(t,e){return Xa.resolve(this.yi.get(e))}saveBundleMetadata(t,e){var n;return this.yi.set(e.id,{id:(n=e).id,version:n.version,createTime:ta(n.createTime)}),Xa.resolve()}getNamedQuery(t,e){return Xa.resolve(this.pi.get(e))}saveNamedQuery(t,e){return this.pi.set(e.name,function(t){return{name:t.name,query:Tu(t.bundledQuery),readTime:ta(t.readTime)}}(e)),Xa.resolve()}}class Yc{constructor(){this.overlays=new ts(wi.comparator),this.Ii=new Map}getOverlay(t,e){return Xa.resolve(this.overlays.get(e))}saveOverlays(t,e,n){return n.forEach(((n,r)=>{this.Xt(t,e,r)})),Xa.resolve()}removeOverlaysForBatchId(t,e,n){const r=this.Ii.get(n);return void 0!==r&&(r.forEach((t=>this.overlays=this.overlays.remove(t))),this.Ii.delete(n)),Xa.resolve()}getOverlaysForCollection(t,e,n){const r=Ro(),i=e.length+1,s=new wi(e.child("")),o=this.overlays.getIteratorFrom(s);for(;o.hasNext();){const t=o.getNext().value,s=t.getKey();if(!e.isPrefixOf(s.path))break;s.path.length===i&&t.largestBatchId>n&&r.set(t.getKey(),t)}return Xa.resolve(r)}getOverlaysForCollectionGroup(t,e,n,r){let i=new ts(((t,e)=>t-e));const s=this.overlays.getIterator();for(;s.hasNext();){const t=s.getNext().value;if(t.getKey().getCollectionGroup()===e&&t.largestBatchId>n){let e=i.get(t.largestBatchId);null===e&&(e=Ro(),i=i.insert(t.largestBatchId,e)),e.set(t.getKey(),t)}}const o=Ro(),a=i.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach(((t,e)=>o.set(t,e))),!(o.size()>=r)););return Xa.resolve(o)}Xt(t,e,n){if(null===n)return;const r=this.overlays.get(n.key);if(null!==r){const t=this.Ii.get(r.largestBatchId).delete(n.key);this.Ii.set(r.largestBatchId,t)}this.overlays=this.overlays.insert(n.key,new fu(e,n));let i=this.Ii.get(e);void 0===i&&(i=Mo(),this.Ii.set(e,i)),this.Ii.set(e,i.add(n.key))}}class Qc{constructor(){this.Ti=new rs(Zc.Ei),this.Ai=new rs(Zc.Ri)}isEmpty(){return this.Ti.isEmpty()}addReference(t,e){const n=new Zc(t,e);this.Ti=this.Ti.add(n),this.Ai=this.Ai.add(n)}bi(t,e){t.forEach((t=>this.addReference(t,e)))}removeReference(t,e){this.Pi(new Zc(t,e))}Vi(t,e){t.forEach((t=>this.removeReference(t,e)))}vi(t){const e=new wi(new ni([])),n=new Zc(e,t),r=new Zc(e,t+1),i=[];return this.Ai.forEachInRange([n,r],(t=>{this.Pi(t),i.push(t.key)})),i}Si(){this.Ti.forEach((t=>this.Pi(t)))}Pi(t){this.Ti=this.Ti.delete(t),this.Ai=this.Ai.delete(t)}Di(t){const e=new wi(new ni([])),n=new Zc(e,t),r=new Zc(e,t+1);let i=Mo();return this.Ai.forEachInRange([n,r],(t=>{i=i.add(t.key)})),i}containsKey(t){const e=new Zc(t,0),n=this.Ti.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)}}class Zc{constructor(t,e){this.key=t,this.Ci=e}static Ei(t,e){return wi.comparator(t.key,e.key)||$r(t.Ci,e.Ci)}static Ri(t,e){return $r(t.Ci,e.Ci)||wi.comparator(t.key,e.key)}}class Jc{constructor(t,e){this.indexManager=t,this.referenceDelegate=e,this.Bs=[],this.xi=1,this.Ni=new rs(Zc.Ei)}checkEmpty(t){return Xa.resolve(0===this.Bs.length)}addMutationBatch(t,e,n,r){const i=this.xi;this.xi++,this.Bs.length>0&&this.Bs[this.Bs.length-1];const s=new lu(i,e,n,r);this.Bs.push(s);for(const e of r)this.Ni=this.Ni.add(new Zc(e.key,i)),this.indexManager.addToCollectionParentIndex(t,e.key.path.popLast());return Xa.resolve(s)}lookupMutationBatch(t,e){return Xa.resolve(this.ki(e))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,r=this.Mi(n),i=r<0?0:r;return Xa.resolve(this.Bs.length>i?this.Bs[i]:null)}getHighestUnacknowledgedBatchId(){return Xa.resolve(0===this.Bs.length?-1:this.xi-1)}getAllMutationBatches(t){return Xa.resolve(this.Bs.slice())}getAllMutationBatchesAffectingDocumentKey(t,e){const n=new Zc(e,0),r=new Zc(e,Number.POSITIVE_INFINITY),i=[];return this.Ni.forEachInRange([n,r],(t=>{const e=this.ki(t.Ci);i.push(e)})),Xa.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new rs($r);return e.forEach((t=>{const e=new Zc(t,0),r=new Zc(t,Number.POSITIVE_INFINITY);this.Ni.forEachInRange([e,r],(t=>{n=n.add(t.Ci)}))})),Xa.resolve(this.Oi(n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,r=n.length+1;let i=n;wi.isDocumentKey(i)||(i=i.child(""));const s=new Zc(new wi(i),0);let o=new rs($r);return this.Ni.forEachWhile((t=>{const e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===r&&(o=o.add(t.Ci)),!0)}),s),Xa.resolve(this.Oi(o))}Oi(t){const e=[];return t.forEach((t=>{const n=this.ki(t);null!==n&&e.push(n)})),e}removeMutationBatch(t,e){kr(0===this.Fi(e.batchId,"removed")),this.Bs.shift();let n=this.Ni;return Xa.forEach(e.mutations,(r=>{const i=new Zc(r.key,e.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(t,r.key)})).next((()=>{this.Ni=n}))}_n(t){}containsKey(t,e){const n=new Zc(e,0),r=this.Ni.firstAfterOrEqual(n);return Xa.resolve(e.isEqual(r&&r.key))}performConsistencyCheck(t){return this.Bs.length,Xa.resolve()}Fi(t,e){return this.Mi(t)}Mi(t){return 0===this.Bs.length?0:t-this.Bs[0].batchId}ki(t){const e=this.Mi(t);return e<0||e>=this.Bs.length?null:this.Bs[e]}}class Xc{constructor(t){this.$i=t,this.docs=new ts(wi.comparator),this.size=0}setIndexManager(t){this.indexManager=t}addEntry(t,e){const n=e.key,r=this.docs.get(n),i=r?r.size:0,s=this.$i(e);return this.docs=this.docs.insert(n,{document:e.mutableCopy(),size:s}),this.size+=s-i,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 Xa.resolve(n?n.document.mutableCopy():Ki.newInvalidDocument(e))}getEntries(t,e){let n=Co();return e.forEach((t=>{const e=this.docs.get(t);n=n.insert(t,e?e.document.mutableCopy():Ki.newInvalidDocument(t))})),Xa.resolve(n)}getAllFromCollection(t,e,n){let r=Co();const i=new wi(e.child("")),s=this.docs.getIteratorFrom(i);for(;s.hasNext();){const{key:t,value:{document:i}}=s.getNext();if(!e.isPrefixOf(t.path))break;t.path.length>e.length+1||Xi(Zi(i),n)<=0||(r=r.insert(i.key,i.mutableCopy()))}return Xa.resolve(r)}getAllFromCollectionGroup(t,e,n,r){Nr()}Bi(t,e){return Xa.forEach(this.docs,(t=>e(t)))}newChangeBuffer(t){return new th(this)}getSize(t){return Xa.resolve(this.size)}}class th extends yc{constructor(t){super(),this.Kn=t}applyChanges(t){const e=[];return this.changes.forEach(((n,r)=>{r.isValidDocument()?e.push(this.Kn.addEntry(t,r)):this.Kn.removeEntry(n)})),Xa.waitFor(e)}getFromCache(t,e){return this.Kn.getEntry(t,e)}getAllFromCache(t,e){return this.Kn.getEntries(t,e)}}class eh{constructor(t){this.persistence=t,this.Li=new No((t=>us(t)),cs),this.lastRemoteSnapshotVersion=Zr.min(),this.highestTargetId=0,this.Ui=0,this.qi=new Qc,this.targetCount=0,this.Ki=sc.gn()}forEachTarget(t,e){return this.Li.forEach(((t,n)=>e(n))),Xa.resolve()}getLastRemoteSnapshotVersion(t){return Xa.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return Xa.resolve(this.Ui)}allocateTargetId(t){return this.highestTargetId=this.Ki.next(),Xa.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.Ui&&(this.Ui=e),Xa.resolve()}Tn(t){this.Li.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this.Ki=new sc(e),this.highestTargetId=e),t.sequenceNumber>this.Ui&&(this.Ui=t.sequenceNumber)}addTargetData(t,e){return this.Tn(e),this.targetCount+=1,Xa.resolve()}updateTargetData(t,e){return this.Tn(e),Xa.resolve()}removeTargetData(t,e){return this.Li.delete(e.target),this.qi.vi(e.targetId),this.targetCount-=1,Xa.resolve()}removeTargets(t,e,n){let r=0;const i=[];return this.Li.forEach(((s,o)=>{o.sequenceNumber<=e&&null===n.get(o.targetId)&&(this.Li.delete(s),i.push(this.removeMatchingKeysForTargetId(t,o.targetId)),r++)})),Xa.waitFor(i).next((()=>r))}getTargetCount(t){return Xa.resolve(this.targetCount)}getTargetData(t,e){const n=this.Li.get(e)||null;return Xa.resolve(n)}addMatchingKeys(t,e,n){return this.qi.bi(e,n),Xa.resolve()}removeMatchingKeys(t,e,n){this.qi.Vi(e,n);const r=this.persistence.referenceDelegate,i=[];return r&&e.forEach((e=>{i.push(r.markPotentiallyOrphaned(t,e))})),Xa.waitFor(i)}removeMatchingKeysForTargetId(t,e){return this.qi.vi(e),Xa.resolve()}getMatchingKeysForTargetId(t,e){const n=this.qi.Di(e);return Xa.resolve(n)}containsKey(t,e){return Xa.resolve(this.qi.containsKey(e))}}class nh{constructor(t,e){this.Gi={},this.overlays={},this.es=new Kr(0),this.ns=!1,this.ns=!0,this.referenceDelegate=t(this),this.fs=new eh(this),this.indexManager=new qu,this.ds=function(t){return new Xc(t)}((t=>this.referenceDelegate.Qi(t))),this.M=new mu(e),this._s=new Hc(this.M)}start(){return Promise.resolve()}shutdown(){return this.ns=!1,Promise.resolve()}get started(){return this.ns}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(t){return this.indexManager}getDocumentOverlayCache(t){let e=this.overlays[t.toKey()];return e||(e=new Yc,this.overlays[t.toKey()]=e),e}getMutationQueue(t,e){let n=this.Gi[t.toKey()];return n||(n=new Jc(e,this.referenceDelegate),this.Gi[t.toKey()]=n),n}getTargetCache(){return this.fs}getRemoteDocumentCache(){return this.ds}getBundleCache(){return this._s}runTransaction(t,e,n){Er("MemoryPersistence","Starting transaction:",t);const r=new rh(this.es.next());return this.referenceDelegate.ji(),n(r).next((t=>this.referenceDelegate.Wi(r).next((()=>t)))).toPromise().then((t=>(r.raiseOnCommittedEvent(),t)))}zi(t,e){return Xa.or(Object.values(this.Gi).map((n=>()=>n.containsKey(t,e))))}}class rh extends Ja{constructor(t){super(),this.currentSequenceNumber=t}}class ih{constructor(t){this.persistence=t,this.Hi=new Qc,this.Ji=null}static Yi(t){return new ih(t)}get Xi(){if(this.Ji)return this.Ji;throw Nr()}addReference(t,e,n){return this.Hi.addReference(n,e),this.Xi.delete(n.toString()),Xa.resolve()}removeReference(t,e,n){return this.Hi.removeReference(n,e),this.Xi.add(n.toString()),Xa.resolve()}markPotentiallyOrphaned(t,e){return this.Xi.add(e.toString()),Xa.resolve()}removeTarget(t,e){this.Hi.vi(e.targetId).forEach((t=>this.Xi.add(t.toString())));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(t,e.targetId).next((t=>{t.forEach((t=>this.Xi.add(t.toString())))})).next((()=>n.removeTargetData(t,e)))}ji(){this.Ji=new Set}Wi(t){const e=this.persistence.getRemoteDocumentCache().newChangeBuffer();return Xa.forEach(this.Xi,(n=>{const r=wi.fromPath(n);return this.Zi(t,r).next((t=>{t||e.removeEntry(r,Zr.min())}))})).next((()=>(this.Ji=null,e.apply(t))))}updateLimboDocument(t,e){return this.Zi(t,e).next((t=>{t?this.Xi.delete(e.toString()):this.Xi.add(e.toString())}))}Qi(t){return 0}Zi(t,e){return Xa.or([()=>Xa.resolve(this.Hi.containsKey(e)),()=>this.persistence.getTargetCache().containsKey(t,e),()=>this.persistence.zi(t,e)])}}function sh(t,e){return`firestore_clients_${t}_${e}`}function oh(t,e,n){let r=`firestore_mutations_${t}_${n}`;return e.isAuthenticated()&&(r+=`_${e.uid}`),r}function ah(t,e){return`firestore_targets_${t}_${e}`}class uh{constructor(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}static tr(t,e,n){const r=JSON.parse(n);let i,s="object"==typeof r&&-1!==["pending","acknowledged","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error);return s&&r.error&&(s="string"==typeof r.error.message&&"string"==typeof r.error.code,s&&(i=new Rr(r.error.code,r.error.message))),s?new uh(t,e,r.state,i):(Sr("SharedClientState",`Failed to parse mutation state for ID '${e}': ${n}`),null)}er(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class ch{constructor(t,e,n){this.targetId=t,this.state=e,this.error=n}static tr(t,e){const n=JSON.parse(e);let r,i="object"==typeof n&&-1!==["not-current","current","rejected"].indexOf(n.state)&&(void 0===n.error||"object"==typeof n.error);return i&&n.error&&(i="string"==typeof n.error.message&&"string"==typeof n.error.code,i&&(r=new Rr(n.error.code,n.error.message))),i?new ch(t,n.state,r):(Sr("SharedClientState",`Failed to parse target state for ID '${t}': ${e}`),null)}er(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class hh{constructor(t,e){this.clientId=t,this.activeTargetIds=e}static tr(t,e){const n=JSON.parse(e);let r="object"==typeof n&&n.activeTargetIds instanceof Array,i=Fo();for(let t=0;r&&t<n.activeTargetIds.length;++t)r=bi(n.activeTargetIds[t]),i=i.add(n.activeTargetIds[t]);return r?new hh(t,i):(Sr("SharedClientState",`Failed to parse client data for instance '${t}': ${e}`),null)}}class lh{constructor(t,e){this.clientId=t,this.onlineState=e}static tr(t){const e=JSON.parse(t);return"object"==typeof e&&-1!==["Unknown","Online","Offline"].indexOf(e.onlineState)&&"string"==typeof e.clientId?new lh(e.clientId,e.onlineState):(Sr("SharedClientState",`Failed to parse online state: ${t}`),null)}}class dh{constructor(){this.activeTargetIds=Fo()}nr(t){this.activeTargetIds=this.activeTargetIds.add(t)}sr(t){this.activeTargetIds=this.activeTargetIds.delete(t)}er(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}}class fh{constructor(t,e,n,r,i){this.window=t,this.Yn=e,this.persistenceKey=n,this.ir=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.rr=this.ur.bind(this),this.ar=new ts($r),this.started=!1,this.cr=[];const s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.hr=sh(this.persistenceKey,this.ir),this.lr=function(t){return`firestore_sequence_number_${t}`}(this.persistenceKey),this.ar=this.ar.insert(this.ir,new dh),this.dr=new RegExp(`^firestore_clients_${s}_([^_]*)$`),this._r=new RegExp(`^firestore_mutations_${s}_(\\d+)(?:_(.*))?$`),this.wr=new RegExp(`^firestore_targets_${s}_(\\d+)$`),this.mr=function(t){return`firestore_online_state_${t}`}(this.persistenceKey),this.gr=function(t){return`firestore_bundle_loaded_v2_${t}`}(this.persistenceKey),this.window.addEventListener("storage",this.rr)}static vt(t){return!(!t||!t.localStorage)}async start(){const t=await this.syncEngine.Fs();for(const e of t){if(e===this.ir)continue;const t=this.getItem(sh(this.persistenceKey,e));if(t){const n=hh.tr(e,t);n&&(this.ar=this.ar.insert(n.clientId,n))}}this.yr();const e=this.storage.getItem(this.mr);if(e){const t=this.pr(e);t&&this.Ir(t)}for(const t of this.cr)this.ur(t);this.cr=[],this.window.addEventListener("pagehide",(()=>this.shutdown())),this.started=!0}writeSequenceNumber(t){this.setItem(this.lr,JSON.stringify(t))}getAllActiveQueryTargets(){return this.Tr(this.ar)}isActiveQueryTarget(t){let e=!1;return this.ar.forEach(((n,r)=>{r.activeTargetIds.has(t)&&(e=!0)})),e}addPendingMutation(t){this.Er(t,"pending")}updateMutationState(t,e,n){this.Er(t,e,n),this.Ar(t)}addLocalQueryTarget(t){let e="not-current";if(this.isActiveQueryTarget(t)){const n=this.storage.getItem(ah(this.persistenceKey,t));if(n){const r=ch.tr(t,n);r&&(e=r.state)}}return this.Rr.nr(t),this.yr(),e}removeLocalQueryTarget(t){this.Rr.sr(t),this.yr()}isLocalQueryTarget(t){return this.Rr.activeTargetIds.has(t)}clearQueryState(t){this.removeItem(ah(this.persistenceKey,t))}updateQueryState(t,e,n){this.br(t,e,n)}handleUserChange(t,e,n){e.forEach((t=>{this.Ar(t)})),this.currentUser=t,n.forEach((t=>{this.addPendingMutation(t)}))}setOnlineState(t){this.Pr(t)}notifyBundleLoaded(t){this.Vr(t)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.rr),this.removeItem(this.hr),this.started=!1)}getItem(t){const e=this.storage.getItem(t);return Er("SharedClientState","READ",t,e),e}setItem(t,e){Er("SharedClientState","SET",t,e),this.storage.setItem(t,e)}removeItem(t){Er("SharedClientState","REMOVE",t),this.storage.removeItem(t)}ur(t){const e=t;if(e.storageArea===this.storage){if(Er("SharedClientState","EVENT",e.key,e.newValue),e.key===this.hr)return void Sr("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Yn.enqueueRetryable((async()=>{if(this.started){if(null!==e.key)if(this.dr.test(e.key)){if(null==e.newValue){const t=this.vr(e.key);return this.Sr(t,null)}{const t=this.Dr(e.key,e.newValue);if(t)return this.Sr(t.clientId,t)}}else if(this._r.test(e.key)){if(null!==e.newValue){const t=this.Cr(e.key,e.newValue);if(t)return this.Nr(t)}}else if(this.wr.test(e.key)){if(null!==e.newValue){const t=this.kr(e.key,e.newValue);if(t)return this.Mr(t)}}else if(e.key===this.mr){if(null!==e.newValue){const t=this.pr(e.newValue);if(t)return this.Ir(t)}}else if(e.key===this.lr){const t=function(t){let e=Kr.A;if(null!=t)try{const n=JSON.parse(t);kr("number"==typeof n),e=n}catch(t){Sr("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(e.newValue);t!==Kr.A&&this.sequenceNumberHandler(t)}else if(e.key===this.gr){const t=this.Or(e.newValue);await Promise.all(t.map((t=>this.syncEngine.Fr(t))))}}else this.cr.push(e)}))}}get Rr(){return this.ar.get(this.ir)}yr(){this.setItem(this.hr,this.Rr.er())}Er(t,e,n){const r=new uh(this.currentUser,t,e,n),i=oh(this.persistenceKey,this.currentUser,t);this.setItem(i,r.er())}Ar(t){const e=oh(this.persistenceKey,this.currentUser,t);this.removeItem(e)}Pr(t){const e={clientId:this.ir,onlineState:t};this.storage.setItem(this.mr,JSON.stringify(e))}br(t,e,n){const r=ah(this.persistenceKey,t),i=new ch(t,e,n);this.setItem(r,i.er())}Vr(t){const e=JSON.stringify(Array.from(t));this.setItem(this.gr,e)}vr(t){const e=this.dr.exec(t);return e?e[1]:null}Dr(t,e){const n=this.vr(t);return hh.tr(n,e)}Cr(t,e){const n=this._r.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return uh.tr(new br(i),r,e)}kr(t,e){const n=this.wr.exec(t),r=Number(n[1]);return ch.tr(r,e)}pr(t){return lh.tr(t)}Or(t){return JSON.parse(t)}async Nr(t){if(t.user.uid===this.currentUser.uid)return this.syncEngine.$r(t.batchId,t.state,t.error);Er("SharedClientState",`Ignoring mutation for non-active user ${t.user.uid}`)}Mr(t){return this.syncEngine.Br(t.targetId,t.state,t.error)}Sr(t,e){const n=e?this.ar.insert(t,e):this.ar.remove(t),r=this.Tr(this.ar),i=this.Tr(n),s=[],o=[];return i.forEach((t=>{r.has(t)||s.push(t)})),r.forEach((t=>{i.has(t)||o.push(t)})),this.syncEngine.Lr(s,o).then((()=>{this.ar=n}))}Ir(t){this.ar.get(t.clientId)&&this.onlineStateHandler(t.onlineState)}Tr(t){let e=Fo();return t.forEach(((t,n)=>{e=e.unionWith(n.activeTargetIds)})),e}}class ph{constructor(){this.Ur=new dh,this.qr={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t){return this.Ur.nr(t),this.qr[t]||"not-current"}updateQueryState(t,e,n){this.qr[t]=e}removeLocalQueryTarget(t){this.Ur.sr(t)}isLocalQueryTarget(t){return this.Ur.activeTargetIds.has(t)}clearQueryState(t){delete this.qr[t]}getAllActiveQueryTargets(){return this.Ur.activeTargetIds}isActiveQueryTarget(t){return this.Ur.activeTargetIds.has(t)}start(){return this.Ur=new dh,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}class mh{Kr(t){}shutdown(){}}class gh{constructor(){this.Gr=()=>this.Qr(),this.jr=()=>this.Wr(),this.zr=[],this.Hr()}Kr(t){this.zr.push(t)}shutdown(){window.removeEventListener("online",this.Gr),window.removeEventListener("offline",this.jr)}Hr(){window.addEventListener("online",this.Gr),window.addEventListener("offline",this.jr)}Qr(){Er("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const t of this.zr)t(0)}Wr(){Er("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const t of this.zr)t(1)}static vt(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}const yh={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"};class vh{constructor(t){this.Jr=t.Jr,this.Yr=t.Yr}Xr(t){this.Zr=t}eo(t){this.no=t}onMessage(t){this.so=t}close(){this.Yr()}send(t){this.Jr(t)}io(){this.Zr()}ro(t){this.no(t)}oo(t){this.so(t)}}class bh extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http";this.uo=e+"://"+t.host,this.ao="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}co(t,e,n,r,i){const s=this.ho(t,e);Er("RestConnection","Sending: ",s,n);const o={};return this.lo(o,r,i),this.fo(t,s,o,n).then((t=>(Er("RestConnection","Received: ",t),t)),(e=>{throw Ar("RestConnection",`${t} failed with error: `,e,"url: ",s,"request:",n),e}))}_o(t,e,n,r,i){return this.co(t,e,n,r,i)}lo(t,e,n){t["X-Goog-Api-Client"]="gl-js/ fire/"+wr,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))}ho(t,e){const n=yh[t];return`${this.uo}/v1/${e}:${n}`}}{constructor(t){super(t),this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams}fo(t,e,n,r){return new Promise(((i,s)=>{const o=new yr;o.listenOnce(dr.COMPLETE,(()=>{try{switch(o.getLastErrorCode()){case lr.NO_ERROR:const e=o.getResponseJson();Er("Connection","XHR received:",JSON.stringify(e)),i(e);break;case lr.TIMEOUT:Er("Connection",'RPC "'+t+'" timed out'),s(new Rr(Or.DEADLINE_EXCEEDED,"Request time out"));break;case lr.HTTP_ERROR:const n=o.getStatus();if(Er("Connection",'RPC "'+t+'" failed with status:',n,"response text:",o.getResponseText()),n>0){const t=o.getResponseJson().error;if(t&&t.status&&t.message){const e=function(t){const e=t.toLowerCase().replace(/_/g,"-");return Object.values(Or).indexOf(e)>=0?e:Or.UNKNOWN}(t.status);s(new Rr(e,t.message))}else s(new Rr(Or.UNKNOWN,"Server responded with status "+o.getStatus()))}else s(new Rr(Or.UNAVAILABLE,"Connection failed."));break;default:Nr()}}finally{Er("Connection",'RPC "'+t+'" completed.')}}));const a=JSON.stringify(r);o.send(e,"POST",a,n,15)}))}wo(t,e,n){const r=[this.uo,"/","google.firestore.v1.Firestore","/",t,"/channel"],i=cr(),s=hr(),o={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.useFetchStreams&&(o.xmlHttpFactory=new mr({})),this.lo(o.initMessageHeaders,e,n),(0,a.uI)()||(0,a.b$)()||(0,a.d)()||(0,a.w1)()||(0,a.Mn)()||(0,a.ru)()||(o.httpHeadersOverwriteParam="$httpHeaders");const u=r.join("");Er("Connection","Creating WebChannel: "+u,o);const c=i.createWebChannel(u,o);let h=!1,l=!1;const d=new vh({Jr:t=>{l?Er("Connection","Not sending because WebChannel is closed:",t):(h||(Er("Connection","Opening WebChannel transport."),c.open(),h=!0),Er("Connection","WebChannel sending:",t),c.send(t))},Yr:()=>c.close()}),f=(t,e,n)=>{t.listen(e,(t=>{try{n(t)}catch(t){setTimeout((()=>{throw t}),0)}}))};return f(c,gr.EventType.OPEN,(()=>{l||Er("Connection","WebChannel transport opened.")})),f(c,gr.EventType.CLOSE,(()=>{l||(l=!0,Er("Connection","WebChannel transport closed"),d.ro())})),f(c,gr.EventType.ERROR,(t=>{l||(l=!0,Ar("Connection","WebChannel transport errored:",t),d.ro(new Rr(Or.UNAVAILABLE,"The operation could not be completed")))})),f(c,gr.EventType.MESSAGE,(t=>{var e;if(!l){const n=t.data[0];kr(!!n);const r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){Er("Connection","WebChannel received error:",i);const t=i.status;let e=function(t){const e=Eo[t];if(void 0!==e)return xo(e)}(t),n=i.message;void 0===e&&(e=Or.INTERNAL,n="Unknown error status: "+t+" with message "+i.message),l=!0,d.ro(new Rr(e,n)),c.close()}else Er("Connection","WebChannel received:",n),d.oo(n)}})),f(s,fr.STAT_EVENT,(t=>{t.stat===pr.PROXY?Er("Connection","Detected buffering proxy"):t.stat===pr.NOPROXY&&Er("Connection","Detected no buffering proxy")})),setTimeout((()=>{d.io()}),0),d}}function wh(){return"undefined"!=typeof window?window:null}function Ih(){return"undefined"!=typeof document?document:null}function _h(t){return new Qo(t,!0)}class Th{constructor(t,e,n=1e3,r=1.5,i=6e4){this.Yn=t,this.timerId=e,this.mo=n,this.yo=r,this.po=i,this.Io=0,this.To=null,this.Eo=Date.now(),this.reset()}reset(){this.Io=0}Ao(){this.Io=this.po}Ro(t){this.cancel();const e=Math.floor(this.Io+this.bo()),n=Math.max(0,Date.now()-this.Eo),r=Math.max(0,e-n);r>0&&Er("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.Io} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.To=this.Yn.enqueueAfterDelay(this.timerId,r,(()=>(this.Eo=Date.now(),t()))),this.Io*=this.yo,this.Io<this.mo&&(this.Io=this.mo),this.Io>this.po&&(this.Io=this.po)}Po(){null!==this.To&&(this.To.skipDelay(),this.To=null)}cancel(){null!==this.To&&(this.To.cancel(),this.To=null)}bo(){return(Math.random()-.5)*this.Io}}class Eh{constructor(t,e,n,r,i,s,o,a){this.Yn=t,this.Vo=n,this.vo=r,this.So=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.Do=0,this.Co=null,this.xo=null,this.stream=null,this.No=new Th(t,e)}ko(){return 1===this.state||5===this.state||this.Mo()}Mo(){return 2===this.state||3===this.state}start(){4!==this.state?this.auth():this.Oo()}async stop(){this.ko()&&await this.close(0)}Fo(){this.state=0,this.No.reset()}$o(){this.Mo()&&null===this.Co&&(this.Co=this.Yn.enqueueAfterDelay(this.Vo,6e4,(()=>this.Bo())))}Lo(t){this.Uo(),this.stream.send(t)}async Bo(){if(this.Mo())return this.close(0)}Uo(){this.Co&&(this.Co.cancel(),this.Co=null)}qo(){this.xo&&(this.xo.cancel(),this.xo=null)}async close(t,e){this.Uo(),this.qo(),this.No.cancel(),this.Do++,4!==t?this.No.reset():e&&e.code===Or.RESOURCE_EXHAUSTED?(Sr(e.toString()),Sr("Using maximum backoff delay to prevent overloading the backend."),this.No.Ao()):e&&e.code===Or.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.Ko(),this.stream.close(),this.stream=null),this.state=t,await this.listener.eo(e)}Ko(){}auth(){this.state=1;const t=this.Go(this.Do),e=this.Do;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([t,n])=>{this.Do===e&&this.Qo(t,n)}),(e=>{t((()=>{const t=new Rr(Or.UNKNOWN,"Fetching auth token failed: "+e.message);return this.jo(t)}))}))}Qo(t,e){const n=this.Go(this.Do);this.stream=this.Wo(t,e),this.stream.Xr((()=>{n((()=>(this.state=2,this.xo=this.Yn.enqueueAfterDelay(this.vo,1e4,(()=>(this.Mo()&&(this.state=3),Promise.resolve()))),this.listener.Xr())))})),this.stream.eo((t=>{n((()=>this.jo(t)))})),this.stream.onMessage((t=>{n((()=>this.onMessage(t)))}))}Oo(){this.state=5,this.No.Ro((async()=>{this.state=0,this.start()}))}jo(t){return Er("PersistentStream",`close with error: ${t}`),this.stream=null,this.close(4,t)}Go(t){return e=>{this.Yn.enqueueAndForget((()=>this.Do===t?e():(Er("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class Sh extends Eh{constructor(t,e,n,r,i,s){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,r,s),this.M=i}Wo(t,e){return this.So.wo("Listen",t,e)}onMessage(t){this.No.reset();const e=function(t,e){let n;if("targetChange"in e){e.targetChange;const r=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:Nr()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],s=function(t,e){return t.N?(kr(void 0===e||"string"==typeof e),ai.fromBase64String(e||"")):(kr(void 0===e||e instanceof Uint8Array),ai.fromUint8Array(e||new Uint8Array))}(t,e.targetChange.resumeToken),o=e.targetChange.cause,a=o&&function(t){const e=void 0===t.code?Or.UNKNOWN:xo(t.code);return new Rr(e,t.message||"")}(o);n=new zo(r,i,s,a||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const i=ia(t,r.document.name),s=ta(r.document.updateTime),o=new qi({mapValue:{fields:r.document.fields}}),a=Ki.newFoundDocument(i,s,o),u=r.targetIds||[],c=r.removedTargetIds||[];n=new Bo(u,c,a.key,a)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const i=ia(t,r.document),s=r.readTime?ta(r.readTime):Zr.min(),o=Ki.newNoDocument(i,s),a=r.removedTargetIds||[];n=new Bo([],a,o.key,o)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const i=ia(t,r.document),s=r.removedTargetIds||[];n=new Bo([],s,i,null)}else{if(!("filter"in e))return Nr();{e.filter;const t=e.filter;t.targetId;const r=t.count||0,i=new To(r),s=t.targetId;n=new qo(s,i)}}return n}(this.M,t),n=function(t){if(!("targetChange"in t))return Zr.min();const e=t.targetChange;return e.targetIds&&e.targetIds.length?Zr.min():e.readTime?ta(e.readTime):Zr.min()}(t);return this.listener.zo(e,n)}Ho(t){const e={};e.database=aa(this.M),e.addTarget=function(t,e){let n;const r=e.target;return n=hs(r)?{documents:fa(t,r)}:{query:pa(t,r)},n.targetId=e.targetId,e.resumeToken.approximateByteSize()>0?n.resumeToken=Jo(t,e.resumeToken):e.snapshotVersion.compareTo(Zr.min())>0&&(n.readTime=Zo(t,e.snapshotVersion.toTimestamp())),n}(this.M,t);const n=function(t,e){const n=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return Nr()}}(0,e.purpose);return null==n?null:{"goog-listen-tags":n}}(this.M,t);n&&(e.labels=n),this.Lo(e)}Jo(t){const e={};e.database=aa(this.M),e.removeTarget=t,this.Lo(e)}}class Ah extends Eh{constructor(t,e,n,r,i,s){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,r,s),this.M=i,this.Yo=!1}get Xo(){return this.Yo}start(){this.Yo=!1,this.lastStreamToken=void 0,super.start()}Ko(){this.Yo&&this.Zo([])}Wo(t,e){return this.So.wo("Write",t,e)}onMessage(t){if(kr(!!t.streamToken),this.lastStreamToken=t.streamToken,this.Yo){this.No.reset();const e=function(t,e){return t&&t.length>0?(kr(void 0!==e),t.map((t=>function(t,e){let n=t.updateTime?ta(t.updateTime):ta(e);return n.isEqual(Zr.min())&&(n=ta(e)),new oo(n,t.transformResults||[])}(t,e)))):[]}(t.writeResults,t.commitTime),n=ta(t.commitTime);return this.listener.tu(n,e)}return kr(!t.writeResults||0===t.writeResults.length),this.Yo=!0,this.listener.eu()}nu(){const t={};t.database=aa(this.M),this.Lo(t)}Zo(t){const e={streamToken:this.lastStreamToken,writes:t.map((t=>la(this.M,t)))};this.Lo(e)}}class xh extends class{}{constructor(t,e,n,r){super(),this.authCredentials=t,this.appCheckCredentials=e,this.So=n,this.M=r,this.su=!1}iu(){if(this.su)throw new Rr(Or.FAILED_PRECONDITION,"The client has already been terminated.")}co(t,e,n){return this.iu(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([r,i])=>this.So.co(t,e,n,r,i))).catch((t=>{throw"FirebaseError"===t.name?(t.code===Or.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new Rr(Or.UNKNOWN,t.toString())}))}_o(t,e,n){return this.iu(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([r,i])=>this.So._o(t,e,n,r,i))).catch((t=>{throw"FirebaseError"===t.name?(t.code===Or.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new Rr(Or.UNKNOWN,t.toString())}))}terminate(){this.su=!0}}class Nh{constructor(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.ru=0,this.ou=null,this.uu=!0}au(){0===this.ru&&(this.cu("Unknown"),this.ou=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.ou=null,this.hu("Backend didn't respond within 10 seconds."),this.cu("Offline"),Promise.resolve()))))}lu(t){"Online"===this.state?this.cu("Unknown"):(this.ru++,this.ru>=1&&(this.fu(),this.hu(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.cu("Offline")))}set(t){this.fu(),this.ru=0,"Online"===t&&(this.uu=!1),this.cu(t)}cu(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}hu(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.uu?(Sr(e),this.uu=!1):Er("OnlineStateTracker",e)}fu(){null!==this.ou&&(this.ou.cancel(),this.ou=null)}}class kh{constructor(t,e,n,r,i){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.du=[],this._u=new Map,this.wu=new Set,this.mu=[],this.gu=i,this.gu.Kr((t=>{n.enqueueAndForget((async()=>{Fh(this)&&(Er("RemoteStore","Restarting streams for network reachability change."),await async function(t){const e=Dr(t);e.wu.add(4),await Dh(e),e.yu.set("Unknown"),e.wu.delete(4),await Ch(e)}(this))}))})),this.yu=new Nh(n,r)}}async function Ch(t){if(Fh(t))for(const e of t.mu)await e(!0)}async function Dh(t){for(const e of t.mu)await e(!1)}function Oh(t,e){const n=Dr(t);n._u.has(e.targetId)||(n._u.set(e.targetId,e),Vh(n)?Mh(n):nl(n).Mo()&&Ph(n,e))}function Rh(t,e){const n=Dr(t),r=nl(n);n._u.delete(e),r.Mo()&&Lh(n,e),0===n._u.size&&(r.Mo()?r.$o():Fh(n)&&n.yu.set("Unknown"))}function Ph(t,e){t.pu.Z(e.targetId),nl(t).Ho(e)}function Lh(t,e){t.pu.Z(e),nl(t).Jo(e)}function Mh(t){t.pu=new Go({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),Et:e=>t._u.get(e)||null}),nl(t).start(),t.yu.au()}function Vh(t){return Fh(t)&&!nl(t).ko()&&t._u.size>0}function Fh(t){return 0===Dr(t).wu.size}function Uh(t){t.pu=void 0}async function jh(t){t._u.forEach(((e,n)=>{Ph(t,e)}))}async function Bh(t,e){Uh(t),Vh(t)?(t.yu.lu(e),Mh(t)):t.yu.set("Unknown")}async function qh(t,e,n){if(t.yu.set("Online"),e instanceof zo&&2===e.state&&e.cause)try{await async function(t,e){const n=e.cause;for(const r of e.targetIds)t._u.has(r)&&(await t.remoteSyncer.rejectListen(r,n),t._u.delete(r),t.pu.removeTarget(r))}(t,e)}catch(n){Er("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),n),await zh(t,n)}else if(e instanceof Bo?t.pu.ut(e):e instanceof qo?t.pu._t(e):t.pu.ht(e),!n.isEqual(Zr.min()))try{const e=await Fc(t.localStore);n.compareTo(e)>=0&&await function(t,e){const n=t.pu.yt(e);return n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){const i=t._u.get(r);i&&t._u.set(r,i.withResumeToken(n.resumeToken,e))}})),n.targetMismatches.forEach((e=>{const n=t._u.get(e);if(!n)return;t._u.set(e,n.withResumeToken(ai.EMPTY_BYTE_STRING,n.snapshotVersion)),Lh(t,e);const r=new pu(n.target,e,1,n.sequenceNumber);Ph(t,r)})),t.remoteSyncer.applyRemoteEvent(n)}(t,n)}catch(e){Er("RemoteStore","Failed to raise snapshot:",e),await zh(t,e)}}async function zh(t,e,n){if(!iu(e))throw e;t.wu.add(1),await Dh(t),t.yu.set("Offline"),n||(n=()=>Fc(t.localStore)),t.asyncQueue.enqueueRetryable((async()=>{Er("RemoteStore","Retrying IndexedDB access"),await n(),t.wu.delete(1),await Ch(t)}))}function Kh(t,e){return e().catch((n=>zh(t,n,e)))}async function Gh(t){const e=Dr(t),n=rl(e);let r=e.du.length>0?e.du[e.du.length-1].batchId:-1;for(;Wh(e);)try{const t=await jc(e.localStore,r);if(null===t){0===e.du.length&&n.$o();break}r=t.batchId,$h(e,t)}catch(t){await zh(e,t)}Hh(e)&&Yh(e)}function Wh(t){return Fh(t)&&t.du.length<10}function $h(t,e){t.du.push(e);const n=rl(t);n.Mo()&&n.Xo&&n.Zo(e.mutations)}function Hh(t){return Fh(t)&&!rl(t).ko()&&t.du.length>0}function Yh(t){rl(t).start()}async function Qh(t){rl(t).nu()}async function Zh(t){const e=rl(t);for(const n of t.du)e.Zo(n.mutations)}async function Jh(t,e,n){const r=t.du.shift(),i=du.from(r,e,n);await Kh(t,(()=>t.remoteSyncer.applySuccessfulWrite(i))),await Gh(t)}async function Xh(t,e){e&&rl(t).Xo&&await async function(t,e){if(Ao(n=e.code)&&n!==Or.ABORTED){const n=t.du.shift();rl(t).Fo(),await Kh(t,(()=>t.remoteSyncer.rejectFailedWrite(n.batchId,e))),await Gh(t)}var n}(t,e),Hh(t)&&Yh(t)}async function tl(t,e){const n=Dr(t);n.asyncQueue.verifyOperationInProgress(),Er("RemoteStore","RemoteStore received new credentials");const r=Fh(n);n.wu.add(3),await Dh(n),r&&n.yu.set("Unknown"),await n.remoteSyncer.handleCredentialChange(e),n.wu.delete(3),await Ch(n)}async function el(t,e){const n=Dr(t);e?(n.wu.delete(2),await Ch(n)):e||(n.wu.add(2),await Dh(n),n.yu.set("Unknown"))}function nl(t){return t.Iu||(t.Iu=function(t,e,n){const r=Dr(t);return r.iu(),new Sh(e,r.So,r.authCredentials,r.appCheckCredentials,r.M,n)}(t.datastore,t.asyncQueue,{Xr:jh.bind(null,t),eo:Bh.bind(null,t),zo:qh.bind(null,t)}),t.mu.push((async e=>{e?(t.Iu.Fo(),Vh(t)?Mh(t):t.yu.set("Unknown")):(await t.Iu.stop(),Uh(t))}))),t.Iu}function rl(t){return t.Tu||(t.Tu=function(t,e,n){const r=Dr(t);return r.iu(),new Ah(e,r.So,r.authCredentials,r.appCheckCredentials,r.M,n)}(t.datastore,t.asyncQueue,{Xr:Qh.bind(null,t),eo:Xh.bind(null,t),eu:Zh.bind(null,t),tu:Jh.bind(null,t)}),t.mu.push((async e=>{e?(t.Tu.Fo(),await Gh(t)):(await t.Tu.stop(),t.du.length>0&&(Er("RemoteStore",`Stopping write stream with ${t.du.length} pending writes`),t.du=[]))}))),t.Tu}class il{constructor(t,e,n,r,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new Pr,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((t=>{}))}static createAndSchedule(t,e,n,r,i){const s=Date.now()+n,o=new il(t,e,s,r,i);return o.start(n),o}start(t){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new Rr(Or.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)}}function sl(t,e){if(Sr("AsyncQueue",`${e}: ${t}`),iu(t))return new Rr(Or.UNAVAILABLE,`${e}: ${t}`);throw t}class ol{constructor(t){this.comparator=t?(e,n)=>t(e,n)||wi.comparator(e.key,n.key):(t,e)=>wi.comparator(t.key,e.key),this.keyedMap=Oo(),this.sortedSet=new ts(this.comparator)}static emptySet(t){return new ol(t.comparator)}has(t){return null!=this.keyedMap.get(t)}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal(((e,n)=>(t(e),!1)))}add(t){const e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))}delete(t){const e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this}isEqual(t){if(!(t instanceof ol))return!1;if(this.size!==t.size)return!1;const e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();for(;e.hasNext();){const t=e.getNext().key,r=n.getNext().key;if(!t.isEqual(r))return!1}return!0}toString(){const t=[];return this.forEach((e=>{t.push(e.toString())})),0===t.length?"DocumentSet ()":"DocumentSet (\n "+t.join(" \n")+"\n)"}copy(t,e){const n=new ol;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n}}class al{constructor(){this.Eu=new ts(wi.comparator)}track(t){const e=t.doc.key,n=this.Eu.get(e);n?0!==t.type&&3===n.type?this.Eu=this.Eu.insert(e,t):3===t.type&&1!==n.type?this.Eu=this.Eu.insert(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.Eu=this.Eu.insert(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.Eu=this.Eu.insert(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.Eu=this.Eu.remove(e):1===t.type&&2===n.type?this.Eu=this.Eu.insert(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.Eu=this.Eu.insert(e,{type:2,doc:t.doc}):Nr():this.Eu=this.Eu.insert(e,t)}Au(){const t=[];return this.Eu.inorderTraversal(((e,n)=>{t.push(n)})),t}}class ul{constructor(t,e,n,r,i,s,o,a){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=o,this.excludesMetadataChanges=a}static fromInitialDocuments(t,e,n,r){const i=[];return e.forEach((t=>{i.push({type:0,doc:t})})),new ul(t,e,ol.emptySet(e),i,n,r,!0,!1)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&Vs(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].type!==n[t].type||!e[t].doc.isEqual(n[t].doc))return!1;return!0}}class cl{constructor(){this.Ru=void 0,this.listeners=[]}}class hl{constructor(){this.queries=new No((t=>Fs(t)),Vs),this.onlineState="Unknown",this.bu=new Set}}async function ll(t,e){const n=Dr(t),r=e.query;let i=!1,s=n.queries.get(r);if(s||(i=!0,s=new cl),i)try{s.Ru=await n.onListen(r)}catch(t){const n=sl(t,`Initialization of query '${Us(e.query)}' failed`);return void e.onError(n)}n.queries.set(r,s),s.listeners.push(e),e.Pu(n.onlineState),s.Ru&&e.Vu(s.Ru)&&ml(n)}async function dl(t,e){const n=Dr(t),r=e.query;let i=!1;const s=n.queries.get(r);if(s){const t=s.listeners.indexOf(e);t>=0&&(s.listeners.splice(t,1),i=0===s.listeners.length)}if(i)return n.queries.delete(r),n.onUnlisten(r)}function fl(t,e){const n=Dr(t);let r=!1;for(const t of e){const e=t.query,i=n.queries.get(e);if(i){for(const e of i.listeners)e.Vu(t)&&(r=!0);i.Ru=t}}r&&ml(n)}function pl(t,e,n){const r=Dr(t),i=r.queries.get(e);if(i)for(const t of i.listeners)t.onError(n);r.queries.delete(e)}function ml(t){t.bu.forEach((t=>{t.next()}))}class gl{constructor(t,e,n){this.query=t,this.vu=e,this.Su=!1,this.Du=null,this.onlineState="Unknown",this.options=n||{}}Vu(t){if(!this.options.includeMetadataChanges){const e=[];for(const n of t.docChanges)3!==n.type&&e.push(n);t=new ul(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0)}let e=!1;return this.Su?this.Cu(t)&&(this.vu.next(t),e=!0):this.xu(t,this.onlineState)&&(this.Nu(t),e=!0),this.Du=t,e}onError(t){this.vu.error(t)}Pu(t){this.onlineState=t;let e=!1;return this.Du&&!this.Su&&this.xu(this.Du,t)&&(this.Nu(this.Du),e=!0),e}xu(t,e){if(!t.fromCache)return!0;const n="Offline"!==e;return!(this.options.ku&&n||t.docs.isEmpty()&&"Offline"!==e)}Cu(t){if(t.docChanges.length>0)return!0;const e=this.Du&&this.Du.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges}Nu(t){t=ul.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.Su=!0,this.vu.next(t)}}class yl{constructor(t,e){this.payload=t,this.byteLength=e}Mu(){return"metadata"in this.payload}}class vl{constructor(t){this.M=t}wi(t){return ia(this.M,t)}mi(t){return t.metadata.exists?ha(this.M,t.document,!1):Ki.newNoDocument(this.wi(t.metadata.name),this.gi(t.metadata.readTime))}gi(t){return ta(t)}}class bl{constructor(t,e,n){this.Ou=t,this.localStore=e,this.M=n,this.queries=[],this.documents=[],this.collectionGroups=new Set,this.progress=wl(t)}Fu(t){this.progress.bytesLoaded+=t.byteLength;let e=this.progress.documentsLoaded;if(t.payload.namedQuery)this.queries.push(t.payload.namedQuery);else if(t.payload.documentMetadata){this.documents.push({metadata:t.payload.documentMetadata}),t.payload.documentMetadata.exists||++e;const n=ni.fromString(t.payload.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else t.payload.document&&(this.documents[this.documents.length-1].document=t.payload.document,++e);return e!==this.progress.documentsLoaded?(this.progress.documentsLoaded=e,Object.assign({},this.progress)):null}$u(t){const e=new Map,n=new vl(this.M);for(const r of t)if(r.metadata.queries){const t=n.wi(r.metadata.name);for(const n of r.metadata.queries){const r=(e.get(n)||Mo()).add(t);e.set(n,r)}}return e}async complete(){const t=await async function(t,e,n,r){const i=Dr(t);let s=Mo(),o=Co();for(const t of n){const n=e.wi(t.metadata.name);t.document&&(s=s.add(n));const r=e.mi(t);r.setReadTime(e.gi(t.metadata.readTime)),o=o.insert(n,r)}const a=i.hi.newChangeBuffer({trackRemovals:!0}),u=await Bc(i,function(t){return Ls(Cs(ni.fromString(`__bundle__/docs/${t}`)))}(r));return i.persistence.runTransaction("Apply bundle documents","readwrite",(t=>Uc(t,a,o).next((e=>(a.apply(t),e))).next((e=>i.fs.removeMatchingKeysForTargetId(t,u.targetId).next((()=>i.fs.addMatchingKeys(t,s,u.targetId))).next((()=>i.fi.Gs(t,e))).next((()=>e))))))}(this.localStore,new vl(this.M),this.documents,this.Ou.id),e=this.$u(this.documents);for(const t of this.queries)await $c(this.localStore,t,e.get(t.name));return this.progress.taskState="Success",{progress:this.progress,Bu:this.collectionGroups,Lu:t}}}function wl(t){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}class Il{constructor(t){this.key=t}}class _l{constructor(t){this.key=t}}class Tl{constructor(t,e){this.query=t,this.Uu=e,this.qu=null,this.current=!1,this.Ku=Mo(),this.mutatedKeys=Mo(),this.Gu=qs(t),this.Qu=new ol(this.Gu)}get ju(){return this.Uu}Wu(t,e){const n=e?e.zu:new al,r=e?e.Qu:this.Qu;let i=e?e.mutatedKeys:this.mutatedKeys,s=r,o=!1;const a="F"===this.query.limitType&&r.size===this.query.limit?r.last():null,u="L"===this.query.limitType&&r.size===this.query.limit?r.first():null;if(t.inorderTraversal(((t,e)=>{const c=r.get(t),h=js(this.query,e)?e:null,l=!!c&&this.mutatedKeys.has(c.key),d=!!h&&(h.hasLocalMutations||this.mutatedKeys.has(h.key)&&h.hasCommittedMutations);let f=!1;c&&h?c.data.isEqual(h.data)?l!==d&&(n.track({type:3,doc:h}),f=!0):this.Hu(c,h)||(n.track({type:2,doc:h}),f=!0,(a&&this.Gu(h,a)>0||u&&this.Gu(h,u)<0)&&(o=!0)):!c&&h?(n.track({type:0,doc:h}),f=!0):c&&!h&&(n.track({type:1,doc:c}),f=!0,(a||u)&&(o=!0)),f&&(h?(s=s.add(h),i=d?i.add(t):i.delete(t)):(s=s.delete(t),i=i.delete(t)))})),null!==this.query.limit)for(;s.size>this.query.limit;){const t="F"===this.query.limitType?s.last():s.first();s=s.delete(t.key),i=i.delete(t.key),n.track({type:1,doc:t})}return{Qu:s,zu:n,ii:o,mutatedKeys:i}}Hu(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations}applyChanges(t,e,n){const r=this.Qu;this.Qu=t.Qu,this.mutatedKeys=t.mutatedKeys;const i=t.zu.Au();i.sort(((t,e)=>function(t,e){const n=t=>{switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Nr()}};return n(t)-n(e)}(t.type,e.type)||this.Gu(t.doc,e.doc))),this.Ju(n);const s=e?this.Yu():[],o=0===this.Ku.size&&this.current?1:0,a=o!==this.qu;return this.qu=o,0!==i.length||a?{snapshot:new ul(this.query,t.Qu,r,i,t.mutatedKeys,0===o,a,!1),Xu:s}:{Xu:s}}Pu(t){return this.current&&"Offline"===t?(this.current=!1,this.applyChanges({Qu:this.Qu,zu:new al,mutatedKeys:this.mutatedKeys,ii:!1},!1)):{Xu:[]}}Zu(t){return!this.Uu.has(t)&&!!this.Qu.has(t)&&!this.Qu.get(t).hasLocalMutations}Ju(t){t&&(t.addedDocuments.forEach((t=>this.Uu=this.Uu.add(t))),t.modifiedDocuments.forEach((t=>{})),t.removedDocuments.forEach((t=>this.Uu=this.Uu.delete(t))),this.current=t.current)}Yu(){if(!this.current)return[];const t=this.Ku;this.Ku=Mo(),this.Qu.forEach((t=>{this.Zu(t.key)&&(this.Ku=this.Ku.add(t.key))}));const e=[];return t.forEach((t=>{this.Ku.has(t)||e.push(new _l(t))})),this.Ku.forEach((n=>{t.has(n)||e.push(new Il(n))})),e}ta(t){this.Uu=t._i,this.Ku=Mo();const e=this.Wu(t.documents);return this.applyChanges(e,!0)}ea(){return ul.fromInitialDocuments(this.query,this.Qu,this.mutatedKeys,0===this.qu)}}class El{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class Sl{constructor(t){this.key=t,this.na=!1}}class Al{constructor(t,e,n,r,i,s){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.sa={},this.ia=new No((t=>Fs(t)),Vs),this.ra=new Map,this.oa=new Set,this.ua=new ts(wi.comparator),this.aa=new Map,this.ca=new Qc,this.ha={},this.la=new Map,this.fa=sc.yn(),this.onlineState="Unknown",this.da=void 0}get isPrimaryClient(){return!0===this.da}}async function xl(t,e){const n=Xl(t);let r,i;const s=n.ia.get(e);if(s)r=s.targetId,n.sharedClientState.addLocalQueryTarget(r),i=s.view.ea();else{const t=await Bc(n.localStore,Ls(e));n.isPrimaryClient&&Oh(n.remoteStore,t);const s=n.sharedClientState.addLocalQueryTarget(t.targetId);r=t.targetId,i=await Nl(n,e,r,"current"===s)}return i}async function Nl(t,e,n,r){t._a=(e,n,r)=>async function(t,e,n,r){let i=e.view.Wu(n);i.ii&&(i=await zc(t.localStore,e.query,!1).then((({documents:t})=>e.view.Wu(t,i))));const s=r&&r.targetChanges.get(e.targetId),o=e.view.applyChanges(i,t.isPrimaryClient,s);return Ul(t,e.targetId,o.Xu),o.snapshot}(t,e,n,r);const i=await zc(t.localStore,e,!0),s=new Tl(e,i._i),o=s.Wu(i.documents),a=jo.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==t.onlineState),u=s.applyChanges(o,t.isPrimaryClient,a);Ul(t,n,u.Xu);const c=new El(e,n,s);return t.ia.set(e,c),t.ra.has(n)?t.ra.get(n).push(e):t.ra.set(n,[e]),u.snapshot}async function kl(t,e){const n=Dr(t),r=n.ia.get(e),i=n.ra.get(r.targetId);if(i.length>1)return n.ra.set(r.targetId,i.filter((t=>!Vs(t,e)))),void n.ia.delete(e);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await qc(n.localStore,r.targetId,!1).then((()=>{n.sharedClientState.clearQueryState(r.targetId),Rh(n.remoteStore,r.targetId),Vl(n,r.targetId)})).catch(hc)):(Vl(n,r.targetId),await qc(n.localStore,r.targetId,!0))}async function Cl(t,e){const n=Dr(t);try{const t=await function(t,e){const n=Dr(t),r=e.snapshotVersion;let i=n.ui;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(t=>{const s=n.hi.newChangeBuffer({trackRemovals:!0});i=n.ui;const o=[];e.targetChanges.forEach(((s,a)=>{const u=i.get(a);if(!u)return;o.push(n.fs.removeMatchingKeys(t,s.removedDocuments,a).next((()=>n.fs.addMatchingKeys(t,s.addedDocuments,a))));let c=u.withSequenceNumber(t.currentSequenceNumber);e.targetMismatches.has(a)?c=c.withResumeToken(ai.EMPTY_BYTE_STRING,Zr.min()).withLastLimboFreeSnapshotVersion(Zr.min()):s.resumeToken.approximateByteSize()>0&&(c=c.withResumeToken(s.resumeToken,r)),i=i.insert(a,c),function(t,e,n){return 0===t.resumeToken.approximateByteSize()||e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(u,c,s)&&o.push(n.fs.updateTargetData(t,c))}));let a=Co();if(e.documentUpdates.forEach((r=>{e.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(t,r))})),o.push(Uc(t,s,e.documentUpdates).next((t=>{a=t}))),!r.isEqual(Zr.min())){const e=n.fs.getLastRemoteSnapshotVersion(t).next((e=>n.fs.setTargetsMetadata(t,t.currentSequenceNumber,r)));o.push(e)}return Xa.waitFor(o).next((()=>s.apply(t))).next((()=>n.fi.Gs(t,a))).next((()=>a))})).then((t=>(n.ui=i,t)))}(n.localStore,e);e.targetChanges.forEach(((t,e)=>{const r=n.aa.get(e);r&&(kr(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1),t.addedDocuments.size>0?r.na=!0:t.modifiedDocuments.size>0?kr(r.na):t.removedDocuments.size>0&&(kr(r.na),r.na=!1))})),await ql(n,t,e)}catch(t){await hc(t)}}function Dl(t,e,n){const r=Dr(t);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const t=[];r.ia.forEach(((n,r)=>{const i=r.view.Pu(e);i.snapshot&&t.push(i.snapshot)})),function(t,e){const n=Dr(t);n.onlineState=e;let r=!1;n.queries.forEach(((t,n)=>{for(const t of n.listeners)t.Pu(e)&&(r=!0)})),r&&ml(n)}(r.eventManager,e),t.length&&r.sa.zo(t),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function Ol(t,e,n){const r=Dr(t);r.sharedClientState.updateQueryState(e,"rejected",n);const i=r.aa.get(e),s=i&&i.key;if(s){let t=new ts(wi.comparator);t=t.insert(s,Ki.newNoDocument(s,Zr.min()));const n=Mo().add(s),i=new Uo(Zr.min(),new Map,new rs($r),t,n);await Cl(r,i),r.ua=r.ua.remove(s),r.aa.delete(e),Bl(r)}else await qc(r.localStore,e,!1).then((()=>Vl(r,e,n))).catch(hc)}async function Rl(t,e){const n=Dr(t),r=e.batch.batchId;try{const t=await function(t,e){const n=Dr(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(t=>{const r=e.batch.keys(),i=n.hi.newChangeBuffer({trackRemovals:!0});return function(t,e,n,r){const i=n.batch,s=i.keys();let o=Xa.resolve();return s.forEach((t=>{o=o.next((()=>r.getEntry(e,t))).next((e=>{const s=n.docVersions.get(t);kr(null!==s),e.version.compareTo(s)<0&&(i.applyToRemoteDocument(e,n),e.isValidDocument()&&(e.setReadTime(n.commitVersion),r.addEntry(e)))}))})),o.next((()=>t.Bs.removeMutationBatch(e,i)))}(n,t,e,i).next((()=>i.apply(t))).next((()=>n.Bs.performConsistencyCheck(t))).next((()=>n.fi.Ks(t,r)))}))}(n.localStore,e);Ml(n,r,null),Ll(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await ql(n,t)}catch(t){await hc(t)}}async function Pl(t,e,n){const r=Dr(t);try{const t=await function(t,e){const n=Dr(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",(t=>{let r;return n.Bs.lookupMutationBatch(t,e).next((e=>(kr(null!==e),r=e.keys(),n.Bs.removeMutationBatch(t,e)))).next((()=>n.Bs.performConsistencyCheck(t))).next((()=>n.fi.Ks(t,r)))}))}(r.localStore,e);Ml(r,e,n),Ll(r,e),r.sharedClientState.updateMutationState(e,"rejected",n),await ql(r,t)}catch(n){await hc(n)}}function Ll(t,e){(t.la.get(e)||[]).forEach((t=>{t.resolve()})),t.la.delete(e)}function Ml(t,e,n){const r=Dr(t);let i=r.ha[r.currentUser.toKey()];if(i){const t=i.get(e);t&&(n?t.reject(n):t.resolve(),i=i.remove(e)),r.ha[r.currentUser.toKey()]=i}}function Vl(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const r of t.ra.get(e))t.ia.delete(r),n&&t.sa.wa(r,n);t.ra.delete(e),t.isPrimaryClient&&t.ca.vi(e).forEach((e=>{t.ca.containsKey(e)||Fl(t,e)}))}function Fl(t,e){t.oa.delete(e.path.canonicalString());const n=t.ua.get(e);null!==n&&(Rh(t.remoteStore,n),t.ua=t.ua.remove(e),t.aa.delete(n),Bl(t))}function Ul(t,e,n){for(const r of n)r instanceof Il?(t.ca.addReference(r.key,e),jl(t,r)):r instanceof _l?(Er("SyncEngine","Document no longer in limbo: "+r.key),t.ca.removeReference(r.key,e),t.ca.containsKey(r.key)||Fl(t,r.key)):Nr()}function jl(t,e){const n=e.key,r=n.path.canonicalString();t.ua.get(n)||t.oa.has(r)||(Er("SyncEngine","New document in limbo: "+n),t.oa.add(r),Bl(t))}function Bl(t){for(;t.oa.size>0&&t.ua.size<t.maxConcurrentLimboResolutions;){const e=t.oa.values().next().value;t.oa.delete(e);const n=new wi(ni.fromString(e)),r=t.fa.next();t.aa.set(r,new Sl(n)),t.ua=t.ua.insert(n,r),Oh(t.remoteStore,new pu(Ls(Cs(n.path)),r,2,Kr.A))}}async function ql(t,e,n){const r=Dr(t),i=[],s=[],o=[];r.ia.isEmpty()||(r.ia.forEach(((t,a)=>{o.push(r._a(a,e,n).then((t=>{if(t){r.isPrimaryClient&&r.sharedClientState.updateQueryState(a.targetId,t.fromCache?"not-current":"current"),i.push(t);const e=Rc.Ys(a.targetId,t);s.push(e)}})))})),await Promise.all(o),r.sa.zo(i),await async function(t,e){const n=Dr(t);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(t=>Xa.forEach(e,(e=>Xa.forEach(e.Hs,(r=>n.persistence.referenceDelegate.addReference(t,e.targetId,r))).next((()=>Xa.forEach(e.Js,(r=>n.persistence.referenceDelegate.removeReference(t,e.targetId,r)))))))))}catch(t){if(!iu(t))throw t;Er("LocalStore","Failed to update sequence numbers: "+t)}for(const t of e){const e=t.targetId;if(!t.fromCache){const t=n.ui.get(e),r=t.snapshotVersion,i=t.withLastLimboFreeSnapshotVersion(r);n.ui=n.ui.insert(e,i)}}}(r.localStore,s))}async function zl(t,e){const n=Dr(t);if(!n.currentUser.isEqual(e)){Er("SyncEngine","User change. New user:",e.toKey());const t=await Vc(n.localStore,e);n.currentUser=e,function(t,e){t.la.forEach((t=>{t.forEach((t=>{t.reject(new Rr(Or.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),t.la.clear()}(n),n.sharedClientState.handleUserChange(e,t.removedBatchIds,t.addedBatchIds),await ql(n,t.di)}}function Kl(t,e){const n=Dr(t),r=n.aa.get(e);if(r&&r.na)return Mo().add(r.key);{let t=Mo();const r=n.ra.get(e);if(!r)return t;for(const e of r){const r=n.ia.get(e);t=t.unionWith(r.view.ju)}return t}}async function Gl(t,e){const n=Dr(t),r=await zc(n.localStore,e.query,!0),i=e.view.ta(r);return n.isPrimaryClient&&Ul(n,e.targetId,i.Xu),i}async function Wl(t,e){const n=Dr(t);return Gc(n.localStore,e).then((t=>ql(n,t)))}async function $l(t,e,n,r){const i=Dr(t),s=await function(t,e){const n=Dr(t),r=Dr(n.Bs);return n.persistence.runTransaction("Lookup mutation documents","readonly",(t=>r.fn(t,e).next((e=>e?n.fi.Ks(t,e):Xa.resolve(null)))))}(i.localStore,e);null!==s?("pending"===n?await Gh(i.remoteStore):"acknowledged"===n||"rejected"===n?(Ml(i,e,r||null),Ll(i,e),function(t,e){Dr(Dr(t).Bs)._n(e)}(i.localStore,e)):Nr(),await ql(i,s)):Er("SyncEngine","Cannot apply mutation batch with id: "+e)}async function Hl(t,e,n){const r=Dr(t),i=[],s=[];for(const t of e){let e;const n=r.ra.get(t);if(n&&0!==n.length){e=await Bc(r.localStore,Ls(n[0]));for(const t of n){const e=r.ia.get(t),n=await Gl(r,e);n.snapshot&&s.push(n.snapshot)}}else{const n=await Kc(r.localStore,t);e=await Bc(r.localStore,n),await Nl(r,Yl(n),t,!1)}i.push(e)}return r.sa.zo(s),i}function Yl(t){return ks(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)}function Ql(t){const e=Dr(t);return Dr(Dr(e.localStore).persistence).Fs()}async function Zl(t,e,n,r){const i=Dr(t);if(i.da)return void Er("SyncEngine","Ignoring unexpected query state notification.");const s=i.ra.get(e);if(s&&s.length>0)switch(n){case"current":case"not-current":{const t=await Gc(i.localStore,Bs(s[0])),r=Uo.createSynthesizedRemoteEventForCurrentChange(e,"current"===n);await ql(i,t,r);break}case"rejected":await qc(i.localStore,e,!0),Vl(i,e,r);break;default:Nr()}}async function Jl(t,e,n){const r=Xl(t);if(r.da){for(const t of e){if(r.ra.has(t)){Er("SyncEngine","Adding an already active target "+t);continue}const e=await Kc(r.localStore,t),n=await Bc(r.localStore,e);await Nl(r,Yl(e),n.targetId,!1),Oh(r.remoteStore,n)}for(const t of n)r.ra.has(t)&&await qc(r.localStore,t,!1).then((()=>{Rh(r.remoteStore,t),Vl(r,t)})).catch(hc)}}function Xl(t){const e=Dr(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=Cl.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Kl.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=Ol.bind(null,e),e.sa.zo=fl.bind(null,e.eventManager),e.sa.wa=pl.bind(null,e.eventManager),e}function td(t){const e=Dr(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=Rl.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=Pl.bind(null,e),e}class ed{constructor(){this.synchronizeTabs=!1}async initialize(t){this.M=_h(t.databaseInfo.databaseId),this.sharedClientState=this.ga(t),this.persistence=this.ya(t),await this.persistence.start(),this.gcScheduler=this.pa(t),this.localStore=this.Ia(t)}pa(t){return null}Ia(t){return Mc(this.persistence,new Pc,t.initialUser,this.M)}ya(t){return new nh(ih.Yi,this.M)}ga(t){return new ph}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class nd extends ed{constructor(t,e,n){super(),this.Ta=t,this.cacheSizeBytes=e,this.forceOwnership=n,this.synchronizeTabs=!1}async initialize(t){await super.initialize(t),await this.Ta.initialize(this,t),await td(this.Ta.syncEngine),await Gh(this.Ta.remoteStore),await this.persistence.Ts((()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(this.localStore),Promise.resolve())))}Ia(t){return Mc(this.persistence,new Pc,t.initialUser,this.M)}pa(t){const e=this.persistence.referenceDelegate.garbageCollector;return new fc(e,t.asyncQueue)}ya(t){const e=Dc(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?Zu.withCacheSize(this.cacheSizeBytes):Zu.DEFAULT;return new Nc(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,wh(),Ih(),this.M,this.sharedClientState,!!this.forceOwnership)}ga(t){return new ph}}class rd extends nd{constructor(t,e){super(t,e,!1),this.Ta=t,this.cacheSizeBytes=e,this.synchronizeTabs=!0}async initialize(t){await super.initialize(t);const e=this.Ta.syncEngine;this.sharedClientState instanceof fh&&(this.sharedClientState.syncEngine={$r:$l.bind(null,e),Br:Zl.bind(null,e),Lr:Jl.bind(null,e),Fs:Ql.bind(null,e),Fr:Wl.bind(null,e)},await this.sharedClientState.start()),await this.persistence.Ts((async t=>{await async function(t,e){const n=Dr(t);if(Xl(n),td(n),!0===e&&!0!==n.da){const t=n.sharedClientState.getAllActiveQueryTargets(),e=await Hl(n,t.toArray());n.da=!0,await el(n.remoteStore,!0);for(const t of e)Oh(n.remoteStore,t)}else if(!1===e&&!1!==n.da){const t=[];let e=Promise.resolve();n.ra.forEach(((r,i)=>{n.sharedClientState.isLocalQueryTarget(i)?t.push(i):e=e.then((()=>(Vl(n,i),qc(n.localStore,i,!0)))),Rh(n.remoteStore,i)})),await e,await Hl(n,t),function(t){const e=Dr(t);e.aa.forEach(((t,n)=>{Rh(e.remoteStore,n)})),e.ca.Si(),e.aa=new Map,e.ua=new ts(wi.comparator)}(n),n.da=!1,await el(n.remoteStore,!1)}}(this.Ta.syncEngine,t),this.gcScheduler&&(t&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):t||this.gcScheduler.stop())}))}ga(t){const e=wh();if(!fh.vt(e))throw new Rr(Or.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=Dc(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new fh(e,t.asyncQueue,n,t.clientId,t.initialUser)}}class id{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=>Dl(this.syncEngine,t,1),this.remoteStore.remoteSyncer.handleCredentialChange=zl.bind(null,this.syncEngine),await el(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return new hl}createDatastore(t){const e=_h(t.databaseInfo.databaseId),n=(r=t.databaseInfo,new bh(r));var r;return function(t,e,n,r){return new xh(t,e,n,r)}(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return e=this.localStore,n=this.datastore,r=t.asyncQueue,i=t=>Dl(this.syncEngine,t,0),s=gh.vt()?new gh:new mh,new kh(e,n,r,i,s);var e,n,r,i,s}createSyncEngine(t,e){return function(t,e,n,r,i,s,o){const a=new Al(t,e,n,r,i,s);return o&&(a.da=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}terminate(){return async function(t){const e=Dr(t);Er("RemoteStore","RemoteStore shutting down."),e.wu.add(5),await Dh(e),e.gu.shutdown(),e.yu.set("Unknown")}(this.remoteStore)}}function sd(t,e=10240){let n=0;return{async read(){if(n<t.byteLength){const r={value:t.slice(n,n+e),done:!1};return n+=e,r}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.reject("unimplemented")}}class od{constructor(t){this.observer=t,this.muted=!1}next(t){this.observer.next&&this.Ea(this.observer.next,t)}error(t){this.observer.error?this.Ea(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)}Aa(){this.muted=!0}Ea(t,e){this.muted||setTimeout((()=>{this.muted||t(e)}),0)}}class ad{constructor(t,e){this.Ra=t,this.M=e,this.metadata=new Pr,this.buffer=new Uint8Array,this.ba=new TextDecoder("utf-8"),this.Pa().then((t=>{t&&t.Mu()?this.metadata.resolve(t.payload.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null==t?void 0:t.payload)}`))}),(t=>this.metadata.reject(t)))}close(){return this.Ra.cancel()}async getMetadata(){return this.metadata.promise}async ma(){return await this.getMetadata(),this.Pa()}async Pa(){const t=await this.Va();if(null===t)return null;const e=this.ba.decode(t),n=Number(e);isNaN(n)&&this.va(`length string (${e}) is not valid number`);const r=await this.Sa(n);return new yl(JSON.parse(r),t.length+n)}Da(){return this.buffer.findIndex((t=>t==="{".charCodeAt(0)))}async Va(){for(;this.Da()<0&&!await this.Ca(););if(0===this.buffer.length)return null;const t=this.Da();t<0&&this.va("Reached the end of bundle when a length string is expected.");const e=this.buffer.slice(0,t);return this.buffer=this.buffer.slice(t),e}async Sa(t){for(;this.buffer.length<t;)await this.Ca()&&this.va("Reached the end of bundle when more is expected.");const e=this.ba.decode(this.buffer.slice(0,t));return this.buffer=this.buffer.slice(t),e}va(t){throw this.Ra.cancel(),new Error(`Invalid bundle format: ${t}`)}async Ca(){const t=await this.Ra.read();if(!t.done){const e=new Uint8Array(this.buffer.length+t.value.length);e.set(this.buffer),e.set(t.value,this.buffer.length),this.buffer=e}return t.done}}class ud{constructor(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}async lookup(t){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw new Rr(Or.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");const e=await async function(t,e){const n=Dr(t),r=aa(n.M)+"/documents",i={documents:e.map((t=>ra(n.M,t)))},s=await n._o("BatchGetDocuments",r,i),o=new Map;s.forEach((t=>{const e=function(t,e){return"found"in e?function(t,e){kr(!!e.found),e.found.name,e.found.updateTime;const n=ia(t,e.found.name),r=ta(e.found.updateTime),i=new qi({mapValue:{fields:e.found.fields}});return Ki.newFoundDocument(n,r,i)}(t,e):"missing"in e?function(t,e){kr(!!e.missing),kr(!!e.readTime);const n=ia(t,e.missing),r=ta(e.readTime);return Ki.newNoDocument(n,r)}(t,e):Nr()}(n.M,t);o.set(e.key.toString(),e)}));const a=[];return e.forEach((t=>{const e=o.get(t.toString());kr(!!e),a.push(e)})),a}(this.datastore,t);return e.forEach((t=>this.recordVersion(t))),e}set(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())}update(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t.toString())}delete(t){this.write(new Io(t,this.precondition(t))),this.writtenDocs.add(t.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;const t=this.readVersions;this.mutations.forEach((e=>{t.delete(e.key.toString())})),t.forEach(((t,e)=>{const n=wi.fromPath(e);this.mutations.push(new _o(n,this.precondition(n)))})),await async function(t,e){const n=Dr(t),r=aa(n.M)+"/documents",i={writes:e.map((t=>la(n.M,t)))};await n.co("Commit",r,i)}(this.datastore,this.mutations),this.committed=!0}recordVersion(t){let e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw Nr();e=Zr.min()}const n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new Rr(Or.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)}precondition(t){const e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?ao.updateTime(e):ao.none()}preconditionForUpdate(t){const e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(Zr.min()))throw new Rr(Or.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return ao.updateTime(e)}return ao.exists(!0)}write(t){this.ensureCommitNotCalled(),this.mutations.push(t)}ensureCommitNotCalled(){}}class cd{constructor(t,e,n,r,i){this.asyncQueue=t,this.datastore=e,this.options=n,this.updateFunction=r,this.deferred=i,this.xa=n.maxAttempts,this.No=new Th(this.asyncQueue,"transaction_retry")}run(){this.xa-=1,this.Na()}Na(){this.No.Ro((async()=>{const t=new ud(this.datastore),e=this.ka(t);e&&e.then((e=>{this.asyncQueue.enqueueAndForget((()=>t.commit().then((()=>{this.deferred.resolve(e)})).catch((t=>{this.Ma(t)}))))})).catch((t=>{this.Ma(t)}))}))}ka(t){try{const e=this.updateFunction(t);return!yi(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}}Ma(t){this.xa>0&&this.Oa(t)?(this.xa-=1,this.asyncQueue.enqueueAndForget((()=>(this.Na(),Promise.resolve())))):this.deferred.reject(t)}Oa(t){if("FirebaseError"===t.name){const e=t.code;return"aborted"===e||"failed-precondition"===e||!Ao(e)}return!1}}class hd{constructor(t,e,n,r){this.authCredentials=t,this.appCheckCredentials=e,this.asyncQueue=n,this.databaseInfo=r,this.user=br.UNAUTHENTICATED,this.clientId=Wr.R(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,(async t=>{Er("FirestoreClient","Received user=",t.uid),await this.authCredentialListener(t),this.user=t})),this.appCheckCredentials.start(n,(t=>(Er("FirestoreClient","Received new app check token=",t),this.appCheckCredentialListener(t,this.user))))}async getConfiguration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(t){this.authCredentialListener=t}setAppCheckTokenChangeListener(t){this.appCheckCredentialListener=t}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new Rr(Or.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const t=new Pr;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this.onlineComponents&&await this.onlineComponents.terminate(),this.offlineComponents&&await this.offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(e){const n=sl(e,"Failed to shutdown persistence");t.reject(n)}})),t.promise}}async function ld(t,e){t.asyncQueue.verifyOperationInProgress(),Er("FirestoreClient","Initializing OfflineComponentProvider");const n=await t.getConfiguration();await e.initialize(n);let r=n.initialUser;t.setCredentialChangeListener((async t=>{r.isEqual(t)||(await Vc(e.localStore,t),r=t)})),e.persistence.setDatabaseDeletedListener((()=>t.terminate())),t.offlineComponents=e}async function dd(t,e){t.asyncQueue.verifyOperationInProgress();const n=await fd(t);Er("FirestoreClient","Initializing OnlineComponentProvider");const r=await t.getConfiguration();await e.initialize(n,r),t.setCredentialChangeListener((t=>tl(e.remoteStore,t))),t.setAppCheckTokenChangeListener(((t,n)=>tl(e.remoteStore,n))),t.onlineComponents=e}async function fd(t){return t.offlineComponents||(Er("FirestoreClient","Using default OfflineComponentProvider"),await ld(t,new ed)),t.offlineComponents}async function pd(t){return t.onlineComponents||(Er("FirestoreClient","Using default OnlineComponentProvider"),await dd(t,new id)),t.onlineComponents}function md(t){return fd(t).then((t=>t.persistence))}function gd(t){return fd(t).then((t=>t.localStore))}function yd(t){return pd(t).then((t=>t.remoteStore))}function vd(t){return pd(t).then((t=>t.syncEngine))}async function bd(t){const e=await pd(t),n=e.eventManager;return n.onListen=xl.bind(null,e.syncEngine),n.onUnlisten=kl.bind(null,e.syncEngine),n}function wd(t,e,n={}){const r=new Pr;return t.asyncQueue.enqueueAndForget((async()=>function(t,e,n,r,i){const s=new od({next:s=>{e.enqueueAndForget((()=>dl(t,o)));const a=s.docs.has(n);!a&&s.fromCache?i.reject(new Rr(Or.UNAVAILABLE,"Failed to get document because the client is offline.")):a&&s.fromCache&&r&&"server"===r.source?i.reject(new Rr(Or.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):i.resolve(s)},error:t=>i.reject(t)}),o=new gl(Cs(n.path),s,{includeMetadataChanges:!0,ku:!0});return ll(t,o)}(await bd(t),t.asyncQueue,e,n,r))),r.promise}function Id(t,e,n={}){const r=new Pr;return t.asyncQueue.enqueueAndForget((async()=>function(t,e,n,r,i){const s=new od({next:n=>{e.enqueueAndForget((()=>dl(t,o))),n.fromCache&&"server"===r.source?i.reject(new Rr(Or.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):i.resolve(n)},error:t=>i.reject(t)}),o=new gl(n,s,{includeMetadataChanges:!0,ku:!0});return ll(t,o)}(await bd(t),t.asyncQueue,e,n,r))),r.promise}const _d=new Map;function Td(t,e,n){if(!n)throw new Rr(Or.INVALID_ARGUMENT,`Function ${t}() cannot be called with an empty ${e}.`)}function Ed(t,e,n,r){if(!0===e&&!0===r)throw new Rr(Or.INVALID_ARGUMENT,`${t} and ${n} cannot be used together.`)}function Sd(t){if(!wi.isDocumentKey(t))throw new Rr(Or.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function Ad(t){if(wi.isDocumentKey(t))throw new Rr(Or.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`)}function xd(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=`${t.substring(0,20)}...`),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";{const e=function(t){return t.constructor?t.constructor.name:null}(t);return e?`a custom ${e} object`:"an object"}}return"function"==typeof t?"a function":Nr()}function Nd(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new Rr(Or.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=xd(t);throw new Rr(Or.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${n}`)}}return t}function kd(t,e){if(e<=0)throw new Rr(Or.INVALID_ARGUMENT,`Function ${t}() requires a positive number, but it was: ${e}.`)}class Cd{constructor(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new Rr(Or.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=null===(e=t.ssl)||void 0===e||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new Rr(Or.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.useFetchStreams=!!t.useFetchStreams,Ed("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}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&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class Dd{constructor(t,e,n){this._authCredentials=e,this._appCheckCredentials=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Cd({}),this._settingsFrozen=!1,t instanceof gi?this._databaseId=t:(this._app=t,this._databaseId=function(t){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new Rr(Or.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new gi(t.options.projectId)}(t))}get app(){if(!this._app)throw new Rr(Or.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 void 0!==this._terminateTask}_setSettings(t){if(this._settingsFrozen)throw new Rr(Or.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 Cd(t),void 0!==t.credentials&&(this._authCredentials=function(t){if(!t)return new Mr;switch(t.type){case"gapi":const e=t.client;return kr(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new jr(e,t.sessionIndex||"0",t.iamToken||null);case"provider":return t.client;default:throw new Rr(Or.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(t.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const e=_d.get(t);e&&(Er("ComponentProvider","Removing Datastore"),_d.delete(t),e.terminate())}(this),Promise.resolve()}}function Od(t,e,n,r={}){var i;const s=(t=Nd(t,Dd))._getSettings();if("firestore.googleapis.com"!==s.host&&s.host!==e&&Ar("Host has been set in both settings() and useEmulator(), emulator host will be used"),t._setSettings(Object.assign(Object.assign({},s),{host:`${e}:${n}`,ssl:!1})),r.mockUserToken){let e,n;if("string"==typeof r.mockUserToken)e=r.mockUserToken,n=br.MOCK_USER;else{e=(0,a.Sg)(r.mockUserToken,null===(i=t._app)||void 0===i?void 0:i.options.projectId);const s=r.mockUserToken.sub||r.mockUserToken.user_id;if(!s)throw new Rr(Or.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new br(s)}t._authCredentials=new Vr(new Lr(e,n))}}class Rd{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 Ld(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new Rd(this.firestore,t,this._key)}}class Pd{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new Pd(this.firestore,t,this._query)}}class Ld extends Pd{constructor(t,e,n){super(t,e,Cs(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 Rd(this.firestore,null,new wi(t))}withConverter(t){return new Ld(this.firestore,t,this._path)}}function Md(t,e,...n){if(t=(0,a.m9)(t),Td("collection","path",e),t instanceof Dd){const r=ni.fromString(e,...n);return Ad(r),new Ld(t,null,r)}{if(!(t instanceof Rd||t instanceof Ld))throw new Rr(Or.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ni.fromString(e,...n));return Ad(r),new Ld(t.firestore,null,r)}}function Vd(t,e){if(t=Nd(t,Dd),Td("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new Rr(Or.INVALID_ARGUMENT,`Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new Pd(t,null,function(t){return new Ns(ni.emptyPath(),t)}(e))}function Fd(t,e,...n){if(t=(0,a.m9)(t),1===arguments.length&&(e=Wr.R()),Td("doc","path",e),t instanceof Dd){const r=ni.fromString(e,...n);return Sd(r),new Rd(t,null,new wi(r))}{if(!(t instanceof Rd||t instanceof Ld))throw new Rr(Or.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ni.fromString(e,...n));return Sd(r),new Rd(t.firestore,t instanceof Ld?t.converter:null,new wi(r))}}function Ud(t,e){return t=(0,a.m9)(t),e=(0,a.m9)(e),(t instanceof Rd||t instanceof Ld)&&(e instanceof Rd||e instanceof Ld)&&t.firestore===e.firestore&&t.path===e.path&&t.converter===e.converter}function jd(t,e){return t=(0,a.m9)(t),e=(0,a.m9)(e),t instanceof Pd&&e instanceof Pd&&t.firestore===e.firestore&&Vs(t._query,e._query)&&t.converter===e.converter}class Bd{constructor(){this.Fa=Promise.resolve(),this.$a=[],this.Ba=!1,this.La=[],this.Ua=null,this.qa=!1,this.Ka=!1,this.Ga=[],this.No=new Th(this,"async_queue_retry"),this.Qa=()=>{const t=Ih();t&&Er("AsyncQueue","Visibility state changed to "+t.visibilityState),this.No.Po()};const t=Ih();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.Qa)}get isShuttingDown(){return this.Ba}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.ja(),this.Wa(t)}enterRestrictedMode(t){if(!this.Ba){this.Ba=!0,this.Ka=t||!1;const e=Ih();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("visibilitychange",this.Qa)}}enqueue(t){if(this.ja(),this.Ba)return new Promise((()=>{}));const e=new Pr;return this.Wa((()=>this.Ba&&this.Ka?Promise.resolve():(t().then(e.resolve,e.reject),e.promise))).then((()=>e.promise))}enqueueRetryable(t){this.enqueueAndForget((()=>(this.$a.push(t),this.za())))}async za(){if(0!==this.$a.length){try{await this.$a[0](),this.$a.shift(),this.No.reset()}catch(t){if(!iu(t))throw t;Er("AsyncQueue","Operation failed with retryable error: "+t)}this.$a.length>0&&this.No.Ro((()=>this.za()))}}Wa(t){const e=this.Fa.then((()=>(this.qa=!0,t().catch((t=>{this.Ua=t,this.qa=!1;const e=function(t){let e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e}(t);throw Sr("INTERNAL UNHANDLED ERROR: ",e),t})).then((t=>(this.qa=!1,t))))));return this.Fa=e,e}enqueueAfterDelay(t,e,n){this.ja(),this.Ga.indexOf(t)>-1&&(e=0);const r=il.createAndSchedule(this,t,e,n,(t=>this.Ha(t)));return this.La.push(r),r}ja(){this.Ua&&Nr()}verifyOperationInProgress(){}async Ja(){let t;do{t=this.Fa,await t}while(t!==this.Fa)}Ya(t){for(const e of this.La)if(e.timerId===t)return!0;return!1}Xa(t){return this.Ja().then((()=>{this.La.sort(((t,e)=>t.targetTimeMs-e.targetTimeMs));for(const e of this.La)if(e.skipDelay(),"all"!==t&&e.timerId===t)break;return this.Ja()}))}Za(t){this.Ga.push(t)}Ha(t){const e=this.La.indexOf(t);this.La.splice(e,1)}}function qd(t){return function(t,e){if("object"!=typeof t||null===t)return!1;const n=t;for(const t of["next","error","complete"])if(t in n&&"function"==typeof n[t])return!0;return!1}(t)}class zd{constructor(){this._progressObserver={},this._taskCompletionResolver=new Pr,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(t,e,n){this._progressObserver={next:t,error:e,complete:n}}catch(t){return this._taskCompletionResolver.promise.catch(t)}then(t,e){return this._taskCompletionResolver.promise.then(t,e)}_completeWith(t){this._updateProgress(t),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(t)}_failWith(t){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(t),this._taskCompletionResolver.reject(t)}_updateProgress(t){this._lastProgress=t,this._progressObserver.next&&this._progressObserver.next(t)}}const Kd=-1;class Gd extends Dd{constructor(t,e,n){super(t,e,n),this.type="firestore",this._queue=new Bd,this._persistenceKey="name"in t?t.name:"[DEFAULT]"}_terminate(){return this._firestoreClient||Yd(this),this._firestoreClient.terminate()}}function Wd(t,e){const n=(0,i.qX)(t,"firestore");if(n.isInitialized()){const t=n.getImmediate(),r=n.getOptions();if((0,a.vZ)(r,e))return t;throw new Rr(Or.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(void 0!==e.cacheSizeBytes&&-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new Rr(Or.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return n.initialize({options:e})}function $d(t=(0,i.Mq)()){return(0,i.qX)(t,"firestore").getImmediate()}function Hd(t){return t._firestoreClient||Yd(t),t._firestoreClient.verifyNotTerminated(),t._firestoreClient}function Yd(t){var e;const n=t._freezeSettings(),r=function(t,e,n,r){return new mi(t,e,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,r.useFetchStreams)}(t._databaseId,(null===(e=t._app)||void 0===e?void 0:e.options.appId)||"",t._persistenceKey,n);t._firestoreClient=new hd(t._authCredentials,t._appCheckCredentials,t._queue,r)}function Qd(t,e){af(t=Nd(t,Gd));const n=Hd(t),r=t._freezeSettings(),i=new id;return Jd(n,i,new nd(i,r.cacheSizeBytes,null==e?void 0:e.forceOwnership))}function Zd(t){af(t=Nd(t,Gd));const e=Hd(t),n=t._freezeSettings(),r=new id;return Jd(e,r,new rd(r,n.cacheSizeBytes))}function Jd(t,e,n){const r=new Pr;return t.asyncQueue.enqueue((async()=>{try{await ld(t,n),await dd(t,e),r.resolve()}catch(t){if(!function(t){return"FirebaseError"===t.name?t.code===Or.FAILED_PRECONDITION||t.code===Or.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code}(t))throw t;console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+t),r.reject(t)}})).then((()=>r.promise))}function Xd(t){if(t._initialized&&!t._terminated)throw new Rr(Or.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const e=new Pr;return t._queue.enqueueAndForgetEvenWhileRestricted((async()=>{try{await async function(t){if(!eu.vt())return Promise.resolve();const e=t+"main";await eu.delete(e)}(Dc(t._databaseId,t._persistenceKey)),e.resolve()}catch(t){e.reject(t)}})),e.promise}function tf(t){return function(t){const e=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e){const n=Dr(t);Fh(n.remoteStore)||Er("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const t=await function(t){const e=Dr(t);return e.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(t=>e.Bs.getHighestUnacknowledgedBatchId(t)))}(n.localStore);if(-1===t)return void e.resolve();const r=n.la.get(t)||[];r.push(e),n.la.set(t,r)}catch(t){const n=sl(t,"Initialization of waitForPendingWrites() operation failed");e.reject(n)}}(await vd(t),e))),e.promise}(Hd(t=Nd(t,Gd)))}function ef(t){return function(t){return t.asyncQueue.enqueue((async()=>{const e=await md(t),n=await yd(t);return e.setNetworkEnabled(!0),function(t){const e=Dr(t);return e.wu.delete(0),Ch(e)}(n)}))}(Hd(t=Nd(t,Gd)))}function nf(t){return function(t){return t.asyncQueue.enqueue((async()=>{const e=await md(t),n=await yd(t);return e.setNetworkEnabled(!1),async function(t){const e=Dr(t);e.wu.add(0),await Dh(e),e.yu.set("Offline")}(n)}))}(Hd(t=Nd(t,Gd)))}function rf(t){return(0,i.wN)(t.app,"firestore"),t._delete()}function sf(t,e){const n=Hd(t=Nd(t,Gd)),r=new zd;return function(t,e,n,r){const i=function(t,e){let n;return n="string"==typeof t?(new TextEncoder).encode(t):t,function(t,e){return new ad(t,e)}(function(t,e){if(t instanceof Uint8Array)return sd(t,e);if(t instanceof ArrayBuffer)return sd(new Uint8Array(t),e);if(t instanceof ReadableStream)return t.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(n),e)}(n,_h(e));t.asyncQueue.enqueueAndForget((async()=>{!function(t,e,n){const r=Dr(t);(async function(t,e,n){try{const r=await e.getMetadata();if(await function(t,e){const n=Dr(t),r=ta(e.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",(t=>n._s.getBundleMetadata(t,e.id))).then((t=>!!t&&t.createTime.compareTo(r)>=0))}(t.localStore,r))return await e.close(),n._completeWith(function(t){return{taskState:"Success",documentsLoaded:t.totalDocuments,bytesLoaded:t.totalBytes,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}(r)),Promise.resolve(new Set);n._updateProgress(wl(r));const i=new bl(r,t.localStore,e.M);let s=await e.ma();for(;s;){const t=await i.Fu(s);t&&n._updateProgress(t),s=await e.ma()}const o=await i.complete();return await ql(t,o.Lu,void 0),await function(t,e){const n=Dr(t);return n.persistence.runTransaction("Save bundle","readwrite",(t=>n._s.saveBundleMetadata(t,e)))}(t.localStore,r),n._completeWith(o.progress),Promise.resolve(o.Bu)}catch(t){return Ar("SyncEngine",`Loading bundle failed with ${t}`),n._failWith(t),Promise.resolve(new Set)}})(r,e,n).then((t=>{r.sharedClientState.notifyBundleLoaded(t)}))}(await vd(t),i,r)}))}(n,t._databaseId,e,r),r}function of(t,e){return function(t,e){return t.asyncQueue.enqueue((async()=>function(t,e){const n=Dr(t);return n.persistence.runTransaction("Get named query","readonly",(t=>n._s.getNamedQuery(t,e)))}(await gd(t),e)))}(Hd(t=Nd(t,Gd)),e).then((e=>e?new Pd(t,null,e.query):null))}function af(t){if(t._initialized||t._terminated)throw new Rr(Or.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}class uf{constructor(...t){for(let e=0;e<t.length;++e)if(0===t[e].length)throw new Rr(Or.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ii(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function cf(){return new uf("__name__")}class hf{constructor(t){this._byteString=t}static fromBase64String(t){try{return new hf(ai.fromBase64String(t))}catch(t){throw new Rr(Or.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(t){return new hf(ai.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}}class lf{constructor(t){this._methodName=t}}class df{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new Rr(Or.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new Rr(Or.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}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(t){return $r(this._lat,t._lat)||$r(this._long,t._long)}}const ff=/^__.*__$/;class pf{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return null!==this.fieldMask?new yo(t,this.data,this.fieldMask,e,this.fieldTransforms):new go(t,this.data,e,this.fieldTransforms)}}class mf{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new yo(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function gf(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Nr()}}class yf{constructor(t,e,n,r,i,s){this.settings=t,this.databaseId=e,this.M=n,this.ignoreUndefinedProperties=r,void 0===i&&this.tc(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get ec(){return this.settings.ec}nc(t){return new yf(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.M,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}sc(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.nc({path:n,ic:!1});return r.rc(t),r}oc(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.nc({path:n,ic:!1});return r.tc(),r}uc(t){return this.nc({path:void 0,ic:!0})}ac(t){return Vf(t,this.settings.methodName,this.settings.cc||!1,this.path,this.settings.hc)}contains(t){return void 0!==this.fieldMask.find((e=>t.isPrefixOf(e)))||void 0!==this.fieldTransforms.find((e=>t.isPrefixOf(e.field)))}tc(){if(this.path)for(let t=0;t<this.path.length;t++)this.rc(this.path.get(t))}rc(t){if(0===t.length)throw this.ac("Document fields must not be empty");if(gf(this.ec)&&ff.test(t))throw this.ac('Document fields cannot begin and end with "__"')}}class vf{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.M=n||_h(t)}lc(t,e,n,r=!1){return new yf({ec:t,methodName:e,hc:n,path:ii.emptyPath(),ic:!1,cc:r},this.databaseId,this.M,this.ignoreUndefinedProperties)}}function bf(t){const e=t._freezeSettings(),n=_h(t._databaseId);return new vf(t._databaseId,!!e.ignoreUndefinedProperties,n)}function wf(t,e,n,r,i,s={}){const o=t.lc(s.merge||s.mergeFields?2:0,e,n,i);Rf("Data must be an object, but it was:",o,r);const a=Df(r,o);let u,c;if(s.merge)u=new si(o.fieldMask),c=o.fieldTransforms;else if(s.mergeFields){const t=[];for(const r of s.mergeFields){const i=Pf(e,r,n);if(!o.contains(i))throw new Rr(Or.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);Ff(t,i)||t.push(i)}u=new si(t),c=o.fieldTransforms.filter((t=>u.covers(t.field)))}else u=null,c=o.fieldTransforms;return new pf(new qi(a),u,c)}class If extends lf{_toFieldTransform(t){if(2!==t.ec)throw 1===t.ec?t.ac(`${this._methodName}() can only appear at the top level of your update data`):t.ac(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof If}}function _f(t,e,n){return new yf({ec:3,hc:e.settings.hc,methodName:t._methodName,ic:n},e.databaseId,e.M,e.ignoreUndefinedProperties)}class Tf extends lf{_toFieldTransform(t){return new so(t.path,new Zs)}isEqual(t){return t instanceof Tf}}class Ef extends lf{constructor(t,e){super(t),this.fc=e}_toFieldTransform(t){const e=_f(this,t,!0),n=this.fc.map((t=>Cf(t,e))),r=new Js(n);return new so(t.path,r)}isEqual(t){return this===t}}class Sf extends lf{constructor(t,e){super(t),this.fc=e}_toFieldTransform(t){const e=_f(this,t,!0),n=this.fc.map((t=>Cf(t,e))),r=new to(n);return new so(t.path,r)}isEqual(t){return this===t}}class Af extends lf{constructor(t,e){super(t),this.dc=e}_toFieldTransform(t){const e=new no(t.M,Ws(t.M,this.dc));return new so(t.path,e)}isEqual(t){return this===t}}function xf(t,e,n,r){const i=t.lc(1,e,n);Rf("Data must be an object, but it was:",i,r);const s=[],o=qi.empty();Xr(r,((t,r)=>{const u=Mf(e,t,n);r=(0,a.m9)(r);const c=i.oc(u);if(r instanceof If)s.push(u);else{const t=Cf(r,c);null!=t&&(s.push(u),o.set(u,t))}}));const u=new si(s);return new mf(o,u,i.fieldTransforms)}function Nf(t,e,n,r,i,s){const o=t.lc(1,e,n),u=[Pf(e,r,n)],c=[i];if(s.length%2!=0)throw new Rr(Or.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let t=0;t<s.length;t+=2)u.push(Pf(e,s[t])),c.push(s[t+1]);const h=[],l=qi.empty();for(let t=u.length-1;t>=0;--t)if(!Ff(h,u[t])){const e=u[t];let n=c[t];n=(0,a.m9)(n);const r=o.oc(e);if(n instanceof If)h.push(e);else{const t=Cf(n,r);null!=t&&(h.push(e),l.set(e,t))}}const d=new si(h);return new mf(l,d,o.fieldTransforms)}function kf(t,e,n,r=!1){return Cf(n,t.lc(r?4:3,e))}function Cf(t,e){if(Of(t=(0,a.m9)(t)))return Rf("Unsupported field value:",e,t),Df(t,e);if(t instanceof lf)return function(t,e){if(!gf(e.ec))throw e.ac(`${t._methodName}() can only be used with update() and set()`);if(!e.path)throw e.ac(`${t._methodName}() is not currently supported inside arrays`);const n=t._toFieldTransform(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.ic&&4!==e.ec)throw e.ac("Nested arrays are not supported");return function(t,e){const n=[];let r=0;for(const i of t){let t=Cf(i,e.uc(r));null==t&&(t={nullValue:"NULL_VALUE"}),n.push(t),r++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(null===(t=(0,a.m9)(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t)return Ws(e.M,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){const n=Qr.fromDate(t);return{timestampValue:Zo(e.M,n)}}if(t instanceof Qr){const n=new Qr(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:Zo(e.M,n)}}if(t instanceof df)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof hf)return{bytesValue:Jo(e.M,t._byteString)};if(t instanceof Rd){const n=e.databaseId,r=t.firestore._databaseId;if(!r.isEqual(n))throw e.ac(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:ea(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.ac(`Unsupported field value: ${xd(t)}`)}(t,e)}function Df(t,e){const n={};return ti(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Xr(t,((t,r)=>{const i=Cf(r,e.sc(t));null!=i&&(n[t]=i)})),{mapValue:{fields:n}}}function Of(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Qr||t instanceof df||t instanceof hf||t instanceof Rd||t instanceof lf)}function Rf(t,e,n){if(!Of(n)||!function(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(n)){const r=xd(n);throw"an object"===r?e.ac(t+" a custom object"):e.ac(t+" "+r)}}function Pf(t,e,n){if((e=(0,a.m9)(e))instanceof uf)return e._internalPath;if("string"==typeof e)return Mf(t,e);throw Vf("Field path arguments must be of type string or ",t,!1,void 0,n)}const Lf=new RegExp("[~\\*/\\[\\]]");function Mf(t,e,n){if(e.search(Lf)>=0)throw Vf(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new uf(...e.split("."))._internalPath}catch(r){throw Vf(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function Vf(t,e,n,r,i){const s=r&&!r.isEmpty(),o=void 0!==i;let a=`Function ${e}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let u="";return(s||o)&&(u+=" (found",s&&(u+=` in field ${r}`),o&&(u+=` in document ${i}`),u+=")"),new Rr(Or.INVALID_ARGUMENT,a+t+u)}function Ff(t,e){return t.some((t=>t.isEqual(e)))}class Uf{constructor(t,e,n,r,i){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new Rd(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const t=new jf(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(Bf("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}}}class jf extends Uf{data(){return super.data()}}function Bf(t,e){return"string"==typeof e?Mf(t,e):e instanceof uf?e._internalPath:e._delegate._internalPath}class qf{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class zf extends Uf{constructor(t,e,n,r,i,s){super(t,e,n,r,s),this._firestore=t,this._firestoreImpl=t,this.metadata=i}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new Kf(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(Bf("DocumentSnapshot.get",t));if(null!==n)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}}class Kf extends zf{data(t={}){return super.data(t)}}class Gf{constructor(t,e,n,r){this._firestore=t,this._userDataWriter=e,this._snapshot=r,this.metadata=new qf(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){const t=[];return 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 Kf(this._firestore,this._userDataWriter,n.key,n,new qf(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 Rr(Or.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=>({type:"added",doc:new Kf(t._firestore,t._userDataWriter,n.doc.key,n.doc,new qf(t._snapshot.mutatedKeys.has(n.doc.key),t._snapshot.fromCache),t.query.converter),oldIndex:-1,newIndex:e++})))}{let n=t._snapshot.oldDocs;return t._snapshot.docChanges.filter((t=>e||3!==t.type)).map((e=>{const r=new Kf(t._firestore,t._userDataWriter,e.doc.key,e.doc,new qf(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query.converter);let i=-1,s=-1;return 0!==e.type&&(i=n.indexOf(e.doc.key),n=n.delete(e.doc.key)),1!==e.type&&(n=n.add(e.doc),s=n.indexOf(e.doc.key)),{type:Wf(e.type),doc:r,oldIndex:i,newIndex:s}}))}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}}function Wf(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Nr()}}function $f(t,e){return t instanceof zf&&e instanceof zf?t._firestore===e._firestore&&t._key.isEqual(e._key)&&(null===t._document?null===e._document:t._document.isEqual(e._document))&&t._converter===e._converter:t instanceof Gf&&e instanceof Gf&&t._firestore===e._firestore&&jd(t.query,e.query)&&t.metadata.isEqual(e.metadata)&&t._snapshot.isEqual(e._snapshot)}function Hf(t){if("L"===t.limitType&&0===t.explicitOrderBy.length)throw new Rr(Or.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Yf{}function Qf(t,...e){for(const n of e)t=n._apply(t);return t}class Zf extends Yf{constructor(t,e,n){super(),this._c=t,this.wc=e,this.mc=n,this.type="where"}_apply(t){const e=bf(t.firestore),n=function(t,e,n,r,i,s,o){let a;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new Rr(Or.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){dp(o,s);const e=[];for(const n of o)e.push(lp(r,t,n));a={arrayValue:{values:e}}}else a=lp(r,t,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||dp(o,s),a=kf(n,"where",o,"in"===s||"not-in"===s);const u=ps.create(i,s,a);return function(t,e){if(e.S()){const n=Os(t);if(null!==n&&!n.isEqual(e.field))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);const r=Ds(t);null!==r&&fp(0,e.field,r)}const n=function(t,e){for(const n of t.filters)if(e.indexOf(n.op)>=0)return n.op;return null}(t,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==n)throw n===e.op?new Rr(Or.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new Rr(Or.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}(t,u),u}(t._query,0,e,t.firestore._databaseId,this._c,this.wc,this.mc);return new Pd(t.firestore,t.converter,function(t,e){const n=t.filters.concat([e]);return new Ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}(t._query,n))}}function Jf(t,e,n){const r=e,i=Bf("where",t);return new Zf(i,r,n)}class Xf extends Yf{constructor(t,e){super(),this._c=t,this.gc=e,this.type="orderBy"}_apply(t){const e=function(t,e,n){if(null!==t.startAt)throw new Rr(Or.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new Rr(Or.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");const r=new Es(e,n);return function(t,e){if(null===Ds(t)){const n=Os(t);null!==n&&fp(0,n,e.field)}}(t,r),r}(t._query,this._c,this.gc);return new Pd(t.firestore,t.converter,function(t,e){const n=t.explicitOrderBy.concat([e]);return new Ns(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(t._query,e))}}function tp(t,e="asc"){const n=e,r=Bf("orderBy",t);return new Xf(r,n)}class ep extends Yf{constructor(t,e,n){super(),this.type=t,this.yc=e,this.Ic=n}_apply(t){return new Pd(t.firestore,t.converter,Ms(t._query,this.yc,this.Ic))}}function np(t){return kd("limit",t),new ep("limit",t,"F")}function rp(t){return kd("limitToLast",t),new ep("limitToLast",t,"L")}class ip extends Yf{constructor(t,e,n){super(),this.type=t,this.Tc=e,this.Ec=n}_apply(t){const e=hp(t,this.type,this.Tc,this.Ec);return new Pd(t.firestore,t.converter,function(t,e){return new Ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)}(t._query,e))}}function sp(...t){return new ip("startAt",t,!0)}function op(...t){return new ip("startAfter",t,!1)}class ap extends Yf{constructor(t,e,n){super(),this.type=t,this.Tc=e,this.Ec=n}_apply(t){const e=hp(t,this.type,this.Tc,this.Ec);return new Pd(t.firestore,t.converter,function(t,e){return new Ns(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)}(t._query,e))}}function up(...t){return new ap("endBefore",t,!1)}function cp(...t){return new ap("endAt",t,!0)}function hp(t,e,n,r){if(n[0]=(0,a.m9)(n[0]),n[0]instanceof Uf)return function(t,e,n,r,i){if(!r)throw new Rr(Or.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const s=[];for(const n of Ps(t))if(n.field.isKeyField())s.push(Ci(e,r.key));else{const t=r.data.field(n.field);if(di(t))throw new Rr(Or.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+n.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===t){const t=n.field.canonicalString();throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`)}s.push(t)}return new Ts(s,i)}(t._query,t.firestore._databaseId,e,n[0]._document,r);{const i=bf(t.firestore);return function(t,e,n,r,i,s){const o=t.explicitOrderBy;if(i.length>o.length)throw new Rr(Or.INVALID_ARGUMENT,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const a=[];for(let s=0;s<i.length;s++){const u=i[s];if(o[s].field.isKeyField()){if("string"!=typeof u)throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof u}`);if(!Rs(t)&&-1!==u.indexOf("/"))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${u}' contains a slash.`);const n=t.path.child(ni.fromString(u));if(!wi.isDocumentKey(n))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);const i=new wi(n);a.push(Ci(e,i))}else{const t=kf(n,r,u);a.push(t)}}return new Ts(a,s)}(t._query,t.firestore._databaseId,i,e,n,r)}}function lp(t,e,n){if("string"==typeof(n=(0,a.m9)(n))){if(""===n)throw new Rr(Or.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Rs(e)&&-1!==n.indexOf("/"))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=e.path.child(ni.fromString(n));if(!wi.isDocumentKey(r))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Ci(t,new wi(r))}if(n instanceof Rd)return Ci(t,n._key);throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${xd(n)}.`)}function dp(t,e){if(!Array.isArray(t)||0===t.length)throw new Rr(Or.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);if(t.length>10)throw new Rr(Or.INVALID_ARGUMENT,`Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`)}function fp(t,e,n){if(!n.isEqual(e))throw new Rr(Or.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}const pp={maxAttempts:5};class mp{convertValue(t,e="none"){switch(Ti(t)){case 0:return null;case 1:return t.booleanValue;case 2:return hi(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(li(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw Nr()}}convertObject(t,e){const n={};return Xr(t.fields,((t,r)=>{n[t]=this.convertValue(r,e)})),n}convertGeoPoint(t){return new df(hi(t.latitude),hi(t.longitude))}convertArray(t,e){return(t.values||[]).map((t=>this.convertValue(t,e)))}convertServerTimestamp(t,e){switch(e){case"previous":const n=fi(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(pi(t));default:return null}}convertTimestamp(t){const e=ci(t);return new Qr(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=ni.fromString(t);kr(Ea(n));const r=new gi(n.get(1),n.get(3)),i=new wi(n.popFirst(5));return r.isEqual(e)||Sr(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),i}}function gp(t,e,n){let r;return r=t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e,r}class yp extends mp{constructor(t){super(),this.firestore=t}convertBytes(t){return new hf(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new Rd(this.firestore,null,e)}}class vp{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=bf(t)}set(t,e,n){this._verifyNotCommitted();const r=bp(t,this._firestore),i=gp(r.converter,e,n),s=wf(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,ao.none())),this}update(t,e,n,...r){this._verifyNotCommitted();const i=bp(t,this._firestore);let s;return s="string"==typeof(e=(0,a.m9)(e))||e instanceof uf?Nf(this._dataReader,"WriteBatch.update",i._key,e,n,r):xf(this._dataReader,"WriteBatch.update",i._key,e),this._mutations.push(s.toMutation(i._key,ao.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=bp(t,this._firestore);return this._mutations=this._mutations.concat(new Io(e._key,ao.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new Rr(Or.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function bp(t,e){if((t=(0,a.m9)(t)).firestore!==e)throw new Rr(Or.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return t}function wp(t){t=Nd(t,Rd);const e=Nd(t.firestore,Gd);return wd(Hd(e),t._key).then((n=>Pp(e,t,n)))}class Ip extends mp{constructor(t){super(),this.firestore=t}convertBytes(t){return new hf(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new Rd(this.firestore,null,e)}}function _p(t){t=Nd(t,Rd);const e=Nd(t.firestore,Gd),n=Hd(e),r=new Ip(e);return function(t,e){const n=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){try{const r=await function(t,e){const n=Dr(t);return n.persistence.runTransaction("read document","readonly",(t=>n.fi.Ls(t,e)))}(t,e);r.isFoundDocument()?n.resolve(r):r.isNoDocument()?n.resolve(null):n.reject(new Rr(Or.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)"))}catch(t){const r=sl(t,`Failed to get document '${e} from cache`);n.reject(r)}}(await gd(t),e,n))),n.promise}(n,t._key).then((n=>new zf(e,r,t._key,n,new qf(null!==n&&n.hasLocalMutations,!0),t.converter)))}function Tp(t){t=Nd(t,Rd);const e=Nd(t.firestore,Gd);return wd(Hd(e),t._key,{source:"server"}).then((n=>Pp(e,t,n)))}function Ep(t){t=Nd(t,Pd);const e=Nd(t.firestore,Gd),n=Hd(e),r=new Ip(e);return Hf(t._query),Id(n,t._query).then((n=>new Gf(e,r,t,n)))}function Sp(t){t=Nd(t,Pd);const e=Nd(t.firestore,Gd),n=Hd(e),r=new Ip(e);return function(t,e){const n=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){try{const r=await zc(t,e,!0),i=new Tl(e,r._i),s=i.Wu(r.documents),o=i.applyChanges(s,!1);n.resolve(o.snapshot)}catch(t){const r=sl(t,`Failed to execute query '${e} against cache`);n.reject(r)}}(await gd(t),e,n))),n.promise}(n,t._query).then((n=>new Gf(e,r,t,n)))}function Ap(t){t=Nd(t,Pd);const e=Nd(t.firestore,Gd),n=Hd(e),r=new Ip(e);return Id(n,t._query,{source:"server"}).then((n=>new Gf(e,r,t,n)))}function xp(t,e,n){t=Nd(t,Rd);const r=Nd(t.firestore,Gd),i=gp(t.converter,e,n);return Rp(r,[wf(bf(r),"setDoc",t._key,i,null!==t.converter,n).toMutation(t._key,ao.none())])}function Np(t,e,n,...r){t=Nd(t,Rd);const i=Nd(t.firestore,Gd),s=bf(i);let o;return o="string"==typeof(e=(0,a.m9)(e))||e instanceof uf?Nf(s,"updateDoc",t._key,e,n,r):xf(s,"updateDoc",t._key,e),Rp(i,[o.toMutation(t._key,ao.exists(!0))])}function kp(t){return Rp(Nd(t.firestore,Gd),[new Io(t._key,ao.none())])}function Cp(t,e){const n=Nd(t.firestore,Gd),r=Fd(t),i=gp(t.converter,e);return Rp(n,[wf(bf(t.firestore),"addDoc",r._key,i,null!==t.converter,{}).toMutation(r._key,ao.exists(!1))]).then((()=>r))}function Dp(t,...e){var n,r,i;t=(0,a.m9)(t);let s={includeMetadataChanges:!1},o=0;"object"!=typeof e[o]||qd(e[o])||(s=e[o],o++);const u={includeMetadataChanges:s.includeMetadataChanges};if(qd(e[o])){const t=e[o];e[o]=null===(n=t.next)||void 0===n?void 0:n.bind(t),e[o+1]=null===(r=t.error)||void 0===r?void 0:r.bind(t),e[o+2]=null===(i=t.complete)||void 0===i?void 0:i.bind(t)}let c,h,l;if(t instanceof Rd)h=Nd(t.firestore,Gd),l=Cs(t._key.path),c={next:n=>{e[o]&&e[o](Pp(h,t,n))},error:e[o+1],complete:e[o+2]};else{const n=Nd(t,Pd);h=Nd(n.firestore,Gd),l=n._query;const r=new Ip(h);c={next:t=>{e[o]&&e[o](new Gf(h,r,n,t))},error:e[o+1],complete:e[o+2]},Hf(t._query)}return function(t,e,n,r){const i=new od(r),s=new gl(e,i,n);return t.asyncQueue.enqueueAndForget((async()=>ll(await bd(t),s))),()=>{i.Aa(),t.asyncQueue.enqueueAndForget((async()=>dl(await bd(t),s)))}}(Hd(h),l,u,c)}function Op(t,e){return function(t,e){const n=new od(e);return t.asyncQueue.enqueueAndForget((async()=>function(t,e){Dr(t).bu.add(e),e.next()}(await bd(t),n))),()=>{n.Aa(),t.asyncQueue.enqueueAndForget((async()=>function(t,e){Dr(t).bu.delete(e)}(await bd(t),n)))}}(Hd(t=Nd(t,Gd)),qd(e)?e:{next:e})}function Rp(t,e){return function(t,e){const n=new Pr;return t.asyncQueue.enqueueAndForget((async()=>async function(t,e,n){const r=td(t);try{const t=await function(t,e){const n=Dr(t),r=Qr.now(),i=e.reduce(((t,e)=>t.add(e.key)),Mo());let s;return n.persistence.runTransaction("Locally write mutations","readwrite",(t=>n.fi.Ks(t,i).next((i=>{s=i;const o=[];for(const t of e){const e=fo(t,s.get(t.key));null!=e&&o.push(new yo(t.key,e,zi(e.value.mapValue),ao.exists(!0)))}return n.Bs.addMutationBatch(t,r,o,e)})))).then((t=>(t.applyToLocalDocumentSet(s),{batchId:t.batchId,changes:s})))}(r.localStore,e);r.sharedClientState.addPendingMutation(t.batchId),function(t,e,n){let r=t.ha[t.currentUser.toKey()];r||(r=new ts($r)),r=r.insert(e,n),t.ha[t.currentUser.toKey()]=r}(r,t.batchId,n),await ql(r,t.changes),await Gh(r.remoteStore)}catch(t){const e=sl(t,"Failed to persist write");n.reject(e)}}(await vd(t),e,n))),n.promise}(Hd(t),e)}function Pp(t,e,n){const r=n.docs.get(e._key),i=new Ip(t);return new zf(t,i,e._key,r,new qf(n.hasPendingWrites,n.fromCache),e.converter)}class Lp extends class{constructor(t,e){this._firestore=t,this._transaction=e,this._dataReader=bf(t)}get(t){const e=bp(t,this._firestore),n=new yp(this._firestore);return this._transaction.lookup([e._key]).then((t=>{if(!t||1!==t.length)return Nr();const r=t[0];if(r.isFoundDocument())return new Uf(this._firestore,n,r.key,r,e.converter);if(r.isNoDocument())return new Uf(this._firestore,n,e._key,null,e.converter);throw Nr()}))}set(t,e,n){const r=bp(t,this._firestore),i=gp(r.converter,e,n),s=wf(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,s),this}update(t,e,n,...r){const i=bp(t,this._firestore);let s;return s="string"==typeof(e=(0,a.m9)(e))||e instanceof uf?Nf(this._dataReader,"Transaction.update",i._key,e,n,r):xf(this._dataReader,"Transaction.update",i._key,e),this._transaction.update(i._key,s),this}delete(t){const e=bp(t,this._firestore);return this._transaction.delete(e._key),this}}{constructor(t,e){super(t,e),this._firestore=t}get(t){const e=bp(t,this._firestore),n=new Ip(this._firestore);return super.get(t).then((t=>new zf(this._firestore,n,e._key,t._document,new qf(!1,!1),e.converter)))}}function Mp(t,e,n){t=Nd(t,Gd);const r=Object.assign(Object.assign({},pp),n);return function(t){if(t.maxAttempts<1)throw new Rr(Or.INVALID_ARGUMENT,"Max attempts must be at least 1")}(r),function(t,e,n){const r=new Pr;return t.asyncQueue.enqueueAndForget((async()=>{const i=await function(t){return pd(t).then((t=>t.datastore))}(t);new cd(t.asyncQueue,i,n,e,r).run()})),r.promise}(Hd(t),(n=>e(new Lp(t,n))),r)}function Vp(){return new If("deleteField")}function Fp(){return new Tf("serverTimestamp")}function Up(...t){return new Ef("arrayUnion",t)}function jp(...t){return new Sf("arrayRemove",t)}function Bp(t){return new Af("increment",t)}function qp(t){return Hd(t=Nd(t,Gd)),new vp(t,(e=>Rp(t,e)))}function zp(t,e){Hd(t=Nd(t,Gd));const n="string"==typeof e?function(t){try{return JSON.parse(t)}catch(t){throw new Rr(Or.INVALID_ARGUMENT,"Failed to parse JSON:"+t.message)}}(e):e,r=[];if(Array.isArray(n.indexes))for(const t of n.indexes){const e=Kp(t,"collectionGroup"),n=[];if(Array.isArray(t.fields))for(const e of t.fields){const t=Mf("setIndexConfiguration",Kp(e,"fieldPath"));"CONTAINS"===e.arrayConfig?n.push(new Hi(t,2)):"ASCENDING"===e.order?n.push(new Hi(t,0)):"DESCENDING"===e.order&&n.push(new Hi(t,1))}r.push(new Gi(Gi.UNKNOWN_ID,e,n,Yi.empty()))}return Promise.resolve()}function Kp(t,e){if("string"!=typeof t[e])throw new Rr(Or.INVALID_ARGUMENT,"Missing string value for: "+e);return t[e]}!function(t,e=!0){!function(t){wr=t}(i.Jn),(0,i.Xd)(new s.wA("firestore",((t,{options:n})=>{const r=t.getProvider("app").getImmediate(),i=new Gd(r,new Fr(t.getProvider("auth-internal")),new qr(t.getProvider("app-check-internal")));return n=Object.assign({useFetchStreams:e},n),i._setSettings(n),i}),"PUBLIC")),(0,i.KN)(vr,"3.4.9",t),(0,i.KN)(vr,"3.4.9","esm2017")}()},646:function(t){t.exports=function(){"use strict";function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}return function e(n,r){function i(e,i,s){if("undefined"!=typeof document){"number"==typeof(s=t({},r,s)).expires&&(s.expires=new Date(Date.now()+864e5*s.expires)),s.expires&&(s.expires=s.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var a in s)s[a]&&(o+="; "+a,!0!==s[a]&&(o+="="+s[a].split(";")[0]));return document.cookie=e+"="+n.write(i,e)+o}}return Object.create({set:i,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split("; "):[],r={},i=0;i<e.length;i++){var s=e[i].split("="),o=s.slice(1).join("=");try{var a=decodeURIComponent(s[0]);if(r[a]=n.read(o,a),t===a)break}catch(t){}}return t?r[t]:r}},remove:function(e,n){i(e,"",t({},n,{expires:-1}))},withAttributes:function(n){return e(this.converter,t({},this.attributes,n))},withConverter:function(n){return e(t({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}()},6245:(t,e,n)=>{"use strict";function r(t){this.message=t}n.r(e),n.d(e,{InvalidTokenError:()=>o,default:()=>a}),r.prototype=new Error,r.prototype.name="InvalidCharacterError";var i="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,s=0,o=0,a="";i=e.charAt(o++);~i&&(n=s%4?64*n+i:i,s++%4)?a+=String.fromCharCode(255&n>>(-2*s&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return a};function s(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(i(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return i(e)}}function o(t){this.message=t}o.prototype=new Error,o.prototype.name="InvalidTokenError";const a=function(t,e){if("string"!=typeof t)throw new o("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(s(t.split(".")[n]))}catch(t){throw new o("Invalid token specified: "+t.message)}}},4143:(t,e,n)=>{"use strict";n.r(e),n.d(e,{ArgumentOutOfRangeError:()=>C.W,AsyncSubject:()=>h.c,BehaviorSubject:()=>u.X,ConnectableObservable:()=>i.c,EMPTY:()=>Y.E,EmptyError:()=>D.K,GroupedObservable:()=>s.T,NEVER:()=>lt,Notification:()=>S.P,NotificationKind:()=>S.W,ObjectUnsubscribedError:()=>O.N,Observable:()=>r.y,ReplaySubject:()=>c.t,Scheduler:()=>_.b,Subject:()=>a.xQ,Subscriber:()=>E.L,Subscription:()=>T.w,TimeoutError:()=>P.W,UnsubscriptionError:()=>R.B,VirtualAction:()=>I,VirtualTimeScheduler:()=>w,animationFrame:()=>b,animationFrameScheduler:()=>v,asap:()=>l.e,asapScheduler:()=>l.E,async:()=>d.P,asyncScheduler:()=>d.z,bindCallback:()=>U,bindNodeCallback:()=>q,combineLatest:()=>W.aj,concat:()=>$.z,config:()=>kt.v,defer:()=>H.P,empty:()=>Y.c,forkJoin:()=>J,from:()=>Z.D,fromEvent:()=>et,fromEventPattern:()=>rt,generate:()=>it,identity:()=>N.y,iif:()=>ot,interval:()=>ut,isObservable:()=>k,merge:()=>ht.T,never:()=>dt,noop:()=>x.Z,observable:()=>o.L,of:()=>ft.of,onErrorResumeNext:()=>pt,pairs:()=>mt,partition:()=>wt,pipe:()=>A.z,queue:()=>f.c,queueScheduler:()=>f.N,race:()=>It.S3,range:()=>_t,scheduled:()=>Nt.x,throwError:()=>Et._,timer:()=>St.H,using:()=>At,zip:()=>xt.$R});var r=n(2772),i=n(3140),s=n(1120),o=n(5050),a=n(211),u=n(9233),c=n(2630),h=n(364),l=n(6650),d=n(964),f=n(2546),p=n(5987),m=n(6114),g=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return p.ZT(e,t),e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0?t.prototype.requestAsyncId.call(this,e,n,r):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame((function(){return e.flush(null)}))))},e.prototype.recycleAsyncId=function(e,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,n,r);0===e.actions.length&&(cancelAnimationFrame(n),e.scheduled=void 0)},e}(m.o),y=n(8399),v=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return p.ZT(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,n=this.actions,r=-1,i=n.length;t=t||n.shift();do{if(e=t.execute(t.state,t.delay))break}while(++r<i&&(t=n.shift()));if(this.active=!1,e){for(;++r<i&&(t=n.shift());)t.unsubscribe();throw e}},e}(y.v))(g),b=v,w=function(t){function e(e,n){void 0===e&&(e=I),void 0===n&&(n=Number.POSITIVE_INFINITY);var r=t.call(this,e,(function(){return r.frame}))||this;return r.maxFrames=n,r.frame=0,r.index=-1,r}return p.ZT(e,t),e.prototype.flush=function(){for(var t,e,n=this.actions,r=this.maxFrames;(e=n[0])&&e.delay<=r&&(n.shift(),this.frame=e.delay,!(t=e.execute(e.state,e.delay))););if(t){for(;e=n.shift();)e.unsubscribe();throw t}},e.frameTimeFactor=10,e}(y.v),I=function(t){function e(e,n,r){void 0===r&&(r=e.index+=1);var i=t.call(this,e,n)||this;return i.scheduler=e,i.work=n,i.index=r,i.active=!0,i.index=e.index=r,i}return p.ZT(e,t),e.prototype.schedule=function(n,r){if(void 0===r&&(r=0),!this.id)return t.prototype.schedule.call(this,n,r);this.active=!1;var i=new e(this.scheduler,this.work);return this.add(i),i.schedule(n,r)},e.prototype.requestAsyncId=function(t,n,r){void 0===r&&(r=0),this.delay=t.frame+r;var i=t.actions;return i.push(this),i.sort(e.sortActions),!0},e.prototype.recycleAsyncId=function(t,e,n){void 0===n&&(n=0)},e.prototype._execute=function(e,n){if(!0===this.active)return t.prototype._execute.call(this,e,n)},e.sortActions=function(t,e){return t.delay===e.delay?t.index===e.index?0:t.index>e.index?1:-1:t.delay>e.delay?1:-1},e}(m.o),_=n(8725),T=n(8760),E=n(979),S=n(2632),A=n(2561),x=n(3306),N=n(3608);function k(t){return!!t&&(t instanceof r.y||"function"==typeof t.lift&&"function"==typeof t.subscribe)}var C=n(6565),D=n(6929),O=n(1016),R=n(8782),P=n(1462),L=n(5709),M=n(3642),V=n(9026),F=n(7507);function U(t,e,n){if(e){if(!(0,F.K)(e))return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return U(t,n).apply(void 0,r).pipe((0,L.U)((function(t){return(0,V.k)(t)?e.apply(void 0,t):e(t)})))};n=e}return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var s,o=this,a={context:o,subject:s,callbackFunc:t,scheduler:n};return new r.y((function(r){if(n){var i={args:e,subscriber:r,params:a};return n.schedule(j,0,i)}if(!s){s=new h.c;try{t.apply(o,e.concat([function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];s.next(t.length<=1?t[0]:t),s.complete()}]))}catch(t){(0,M._)(s)?s.error(t):console.warn(t)}}return s.subscribe(r)}))}}function j(t){var e=this,n=t.args,r=t.subscriber,i=t.params,s=i.callbackFunc,o=i.context,a=i.scheduler,u=i.subject;if(!u){u=i.subject=new h.c;try{s.apply(o,n.concat([function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.length<=1?t[0]:t;e.add(a.schedule(B,0,{value:r,subject:u}))}]))}catch(t){u.error(t)}}this.add(u.subscribe(r))}function B(t){var e=t.value,n=t.subject;n.next(e),n.complete()}function q(t,e,n){if(e){if(!(0,F.K)(e))return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return q(t,n).apply(void 0,r).pipe((0,L.U)((function(t){return(0,V.k)(t)?e.apply(void 0,t):e(t)})))};n=e}return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var s={subject:void 0,args:e,callbackFunc:t,scheduler:n,context:this};return new r.y((function(r){var i=s.context,o=s.subject;if(n)return n.schedule(z,0,{params:s,subscriber:r,context:i});if(!o){o=s.subject=new h.c;try{t.apply(i,e.concat([function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t.shift();n?o.error(n):(o.next(t.length<=1?t[0]:t),o.complete())}]))}catch(t){(0,M._)(o)?o.error(t):console.warn(t)}}return o.subscribe(r)}))}}function z(t){var e=this,n=t.params,r=t.subscriber,i=t.context,s=n.callbackFunc,o=n.args,a=n.scheduler,u=n.subject;if(!u){u=n.subject=new h.c;try{s.apply(i,o.concat([function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.shift();if(r)e.add(a.schedule(G,0,{err:r,subject:u}));else{var i=t.length<=1?t[0]:t;e.add(a.schedule(K,0,{value:i,subject:u}))}}]))}catch(t){this.add(a.schedule(G,0,{err:t,subject:u}))}}this.add(u.subscribe(r))}function K(t){var e=t.value,n=t.subject;n.next(e),n.complete()}function G(t){var e=t.err;t.subject.error(e)}var W=n(5142),$=n(9795),H=n(1410),Y=n(5631),Q=n(2009),Z=n(5760);function J(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(1===t.length){var n=t[0];if((0,V.k)(n))return X(n,null);if((0,Q.K)(n)&&Object.getPrototypeOf(n)===Object.prototype){var r=Object.keys(n);return X(r.map((function(t){return n[t]})),r)}}if("function"==typeof t[t.length-1]){var i=t.pop();return X(t=1===t.length&&(0,V.k)(t[0])?t[0]:t,null).pipe((0,L.U)((function(t){return i.apply(void 0,t)})))}return X(t,null)}function X(t,e){return new r.y((function(n){var r=t.length;if(0!==r)for(var i=new Array(r),s=0,o=0,a=function(a){var u=(0,Z.D)(t[a]),c=!1;n.add(u.subscribe({next:function(t){c||(c=!0,o++),i[a]=t},error:function(t){return n.error(t)},complete:function(){++s!==r&&c||(o===r&&n.next(e?e.reduce((function(t,e,n){return t[e]=i[n],t}),{}):i),n.complete())}}))},u=0;u<r;u++)a(u);else n.complete()}))}var tt=n(4156);function et(t,e,n,i){return(0,tt.m)(n)&&(i=n,n=void 0),i?et(t,e,n).pipe((0,L.U)((function(t){return(0,V.k)(t)?i.apply(void 0,t):i(t)}))):new r.y((function(r){nt(t,e,(function(t){arguments.length>1?r.next(Array.prototype.slice.call(arguments)):r.next(t)}),r,n)}))}function nt(t,e,n,r,i){var s;if(function(t){return t&&"function"==typeof t.addEventListener&&"function"==typeof t.removeEventListener}(t)){var o=t;t.addEventListener(e,n,i),s=function(){return o.removeEventListener(e,n,i)}}else if(function(t){return t&&"function"==typeof t.on&&"function"==typeof t.off}(t)){var a=t;t.on(e,n),s=function(){return a.off(e,n)}}else if(function(t){return t&&"function"==typeof t.addListener&&"function"==typeof t.removeListener}(t)){var u=t;t.addListener(e,n),s=function(){return u.removeListener(e,n)}}else{if(!t||!t.length)throw new TypeError("Invalid event target");for(var c=0,h=t.length;c<h;c++)nt(t[c],e,n,r,i)}r.add(s)}function rt(t,e,n){return n?rt(t,e).pipe((0,L.U)((function(t){return(0,V.k)(t)?n.apply(void 0,t):n(t)}))):new r.y((function(n){var r,i=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.next(1===t.length?t[0]:t)};try{r=t(i)}catch(t){return void n.error(t)}if((0,tt.m)(e))return function(){return e(i,r)}}))}function it(t,e,n,i,s){var o,a;if(1==arguments.length){var u=t;a=u.initialState,e=u.condition,n=u.iterate,o=u.resultSelector||N.y,s=u.scheduler}else void 0===i||(0,F.K)(i)?(a=t,o=N.y,s=i):(a=t,o=i);return new r.y((function(t){var r=a;if(s)return s.schedule(st,0,{subscriber:t,iterate:n,condition:e,resultSelector:o,state:r});for(;;){if(e){var i=void 0;try{i=e(r)}catch(e){return void t.error(e)}if(!i){t.complete();break}}var u=void 0;try{u=o(r)}catch(e){return void t.error(e)}if(t.next(u),t.closed)break;try{r=n(r)}catch(e){return void t.error(e)}}}))}function st(t){var e=t.subscriber,n=t.condition;if(!e.closed){if(t.needIterate)try{t.state=t.iterate(t.state)}catch(t){return void e.error(t)}else t.needIterate=!0;if(n){var r=void 0;try{r=n(t.state)}catch(t){return void e.error(t)}if(!r)return void e.complete();if(e.closed)return}var i;try{i=t.resultSelector(t.state)}catch(t){return void e.error(t)}if(!e.closed&&(e.next(i),!e.closed))return this.schedule(t)}}function ot(t,e,n){return void 0===e&&(e=Y.E),void 0===n&&(n=Y.E),(0,H.P)((function(){return t()?e:n}))}var at=n(5812);function ut(t,e){return void 0===t&&(t=0),void 0===e&&(e=d.P),(!(0,at.k)(t)||t<0)&&(t=0),e&&"function"==typeof e.schedule||(e=d.P),new r.y((function(n){return n.add(e.schedule(ct,t,{subscriber:n,counter:0,period:t})),n}))}function ct(t){var e=t.subscriber,n=t.counter,r=t.period;e.next(n),this.schedule({subscriber:e,counter:n+1,period:r},r)}var ht=n(4370),lt=new r.y(x.Z);function dt(){return lt}var ft=n(8170);function pt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)return Y.E;var n=t[0],i=t.slice(1);return 1===t.length&&(0,V.k)(n)?pt.apply(void 0,n):new r.y((function(t){var e=function(){return t.add(pt.apply(void 0,i).subscribe(t))};return(0,Z.D)(n).subscribe({next:function(e){t.next(e)},error:e,complete:e})}))}function mt(t,e){return e?new r.y((function(n){var r=Object.keys(t),i=new T.w;return i.add(e.schedule(gt,0,{keys:r,index:0,subscriber:n,subscription:i,obj:t})),i})):new r.y((function(e){for(var n=Object.keys(t),r=0;r<n.length&&!e.closed;r++){var i=n[r];t.hasOwnProperty(i)&&e.next([i,t[i]])}e.complete()}))}function gt(t){var e=t.keys,n=t.index,r=t.subscriber,i=t.subscription,s=t.obj;if(!r.closed)if(n<e.length){var o=e[n];r.next([o,s[o]]),i.add(this.schedule({keys:e,index:n+1,subscriber:r,subscription:i,obj:s}))}else r.complete()}var yt=n(9067),vt=n(7843),bt=n(6008);function wt(t,e,n){return[(0,bt.h)(e,n)(new r.y((0,vt.s)(t))),(0,bt.h)((0,yt.f)(e,n))(new r.y((0,vt.s)(t)))]}var It=n(8821);function _t(t,e,n){return void 0===t&&(t=0),new r.y((function(r){void 0===e&&(e=t,t=0);var i=0,s=t;if(n)return n.schedule(Tt,0,{index:i,count:e,start:t,subscriber:r});for(;;){if(i++>=e){r.complete();break}if(r.next(s++),r.closed)break}}))}function Tt(t){var e=t.start,n=t.index,r=t.count,i=t.subscriber;n>=r?i.complete():(i.next(e),i.closed||(t.index=n+1,t.start=e+1,this.schedule(t)))}var Et=n(4944),St=n(9604);function At(t,e){return new r.y((function(n){var r,i;try{r=t()}catch(t){return void n.error(t)}try{i=e(r)}catch(t){return void n.error(t)}var s=(i?(0,Z.D)(i):Y.E).subscribe(n);return function(){s.unsubscribe(),r&&r.unsubscribe()}}))}var xt=n(5080),Nt=n(8107),kt=n(150)},364:(t,e,n)=>{"use strict";n.d(e,{c:()=>o});var r=n(5987),i=n(211),s=n(8760),o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.value=null,e.hasNext=!1,e.hasCompleted=!1,e}return r.ZT(e,t),e.prototype._subscribe=function(e){return this.hasError?(e.error(this.thrownError),s.w.EMPTY):this.hasCompleted&&this.hasNext?(e.next(this.value),e.complete(),s.w.EMPTY):t.prototype._subscribe.call(this,e)},e.prototype.next=function(t){this.hasCompleted||(this.value=t,this.hasNext=!0)},e.prototype.error=function(e){this.hasCompleted||t.prototype.error.call(this,e)},e.prototype.complete=function(){this.hasCompleted=!0,this.hasNext&&t.prototype.next.call(this,this.value),t.prototype.complete.call(this)},e}(i.xQ)},9233:(t,e,n)=>{"use strict";n.d(e,{X:()=>o});var r=n(5987),i=n(211),s=n(1016),o=function(t){function e(e){var n=t.call(this)||this;return n._value=e,n}return r.ZT(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var n=t.prototype._subscribe.call(this,e);return n&&!n.closed&&e.next(this._value),n},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new s.N;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(i.xQ)},2632:(t,e,n)=>{"use strict";n.d(e,{P:()=>a,W:()=>r});var r,i=n(5631),s=n(8170),o=n(4944);r||(r={});var a=function(){function t(t,e,n){this.kind=t,this.value=e,this.error=n,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,n){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return n&&n()}},t.prototype.accept=function(t,e,n){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,n)},t.prototype.toObservable=function(){switch(this.kind){case"N":return(0,s.of)(this.value);case"E":return(0,o._)(this.error);case"C":return(0,i.c)()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}()},2772:(t,e,n)=>{"use strict";n.d(e,{y:()=>h});var r=n(3642),i=n(979),s=n(3142),o=n(2174),a=n(5050),u=n(2561),c=n(150),h=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(t,e,n){var r=this.operator,a=function(t,e,n){if(t){if(t instanceof i.L)return t;if(t[s.b])return t[s.b]()}return t||e||n?new i.L(t,e,n):new i.L(o.c)}(t,e,n);if(r?a.add(r.call(a,this.source)):a.add(this.source||c.v.useDeprecatedSynchronousErrorHandling&&!a.syncErrorThrowable?this._subscribe(a):this._trySubscribe(a)),c.v.useDeprecatedSynchronousErrorHandling&&a.syncErrorThrowable&&(a.syncErrorThrowable=!1,a.syncErrorThrown))throw a.syncErrorValue;return a},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){c.v.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),(0,r._)(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var n=this;return new(e=l(e))((function(e,r){var i;i=n.subscribe((function(e){try{t(e)}catch(t){r(t),i&&i.unsubscribe()}}),r,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[a.L]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:(0,u.U)(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=l(t))((function(t,n){var r;e.subscribe((function(t){return r=t}),(function(t){return n(t)}),(function(){return t(r)}))}))},t.create=function(e){return new t(e)},t}();function l(t){if(t||(t=c.v.Promise||Promise),!t)throw new Error("no Promise impl found");return t}},2174:(t,e,n)=>{"use strict";n.d(e,{c:()=>s});var r=n(150),i=n(1644),s={closed:!0,next:function(t){},error:function(t){if(r.v.useDeprecatedSynchronousErrorHandling)throw t;(0,i.z)(t)},complete:function(){}}},2039:(t,e,n)=>{"use strict";n.d(e,{L:()=>i});var r=n(5987),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n,r,i){this.destination.next(e)},e.prototype.notifyError=function(t,e){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(n(979).L)},2630:(t,e,n)=>{"use strict";n.d(e,{t:()=>h});var r=n(5987),i=n(211),s=n(2546),o=n(8760),a=n(9276),u=n(1016),c=n(8253),h=function(t){function e(e,n,r){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===n&&(n=Number.POSITIVE_INFINITY);var i=t.call(this)||this;return i.scheduler=r,i._events=[],i._infiniteTimeWindow=!1,i._bufferSize=e<1?1:e,i._windowTime=n<1?1:n,n===Number.POSITIVE_INFINITY?(i._infiniteTimeWindow=!0,i.next=i.nextInfiniteTimeWindow):i.next=i.nextTimeWindow,i}return r.ZT(e,t),e.prototype.nextInfiniteTimeWindow=function(e){if(!this.isStopped){var n=this._events;n.push(e),n.length>this._bufferSize&&n.shift()}t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this.isStopped||(this._events.push(new l(this._getNow(),e)),this._trimBufferThenGetEvents()),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,n=this._infiniteTimeWindow,r=n?this._events:this._trimBufferThenGetEvents(),i=this.scheduler,s=r.length;if(this.closed)throw new u.N;if(this.isStopped||this.hasError?e=o.w.EMPTY:(this.observers.push(t),e=new c.W(this,t)),i&&t.add(t=new a.ht(t,i)),n)for(var h=0;h<s&&!t.closed;h++)t.next(r[h]);else for(h=0;h<s&&!t.closed;h++)t.next(r[h].value);return this.hasError?t.error(this.thrownError):this.isStopped&&t.complete(),e},e.prototype._getNow=function(){return(this.scheduler||s.c).now()},e.prototype._trimBufferThenGetEvents=function(){for(var t=this._getNow(),e=this._bufferSize,n=this._windowTime,r=this._events,i=r.length,s=0;s<i&&!(t-r[s].time<n);)s++;return i>e&&(s=Math.max(s,i-e)),s>0&&r.splice(0,s),r},e}(i.xQ),l=function(){return function(t,e){this.time=t,this.value=e}}()},8725:(t,e,n)=>{"use strict";n.d(e,{b:()=>r});var r=function(){function t(e,n){void 0===n&&(n=t.now),this.SchedulerAction=e,this.now=n}return t.prototype.schedule=function(t,e,n){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(n,e)},t.now=function(){return Date.now()},t}()},211:(t,e,n)=>{"use strict";n.d(e,{Yc:()=>h,xQ:()=>l});var r=n(5987),i=n(2772),s=n(979),o=n(8760),a=n(1016),u=n(8253),c=n(3142),h=function(t){function e(e){var n=t.call(this,e)||this;return n.destination=e,n}return r.ZT(e,t),e}(s.L),l=function(t){function e(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r.ZT(e,t),e.prototype[c.b]=function(){return new h(this)},e.prototype.lift=function(t){var e=new d(this,this);return e.operator=t,e},e.prototype.next=function(t){if(this.closed)throw new a.N;if(!this.isStopped)for(var e=this.observers,n=e.length,r=e.slice(),i=0;i<n;i++)r[i].next(t)},e.prototype.error=function(t){if(this.closed)throw new a.N;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,n=e.length,r=e.slice(),i=0;i<n;i++)r[i].error(t);this.observers.length=0},e.prototype.complete=function(){if(this.closed)throw new a.N;this.isStopped=!0;for(var t=this.observers,e=t.length,n=t.slice(),r=0;r<e;r++)n[r].complete();this.observers.length=0},e.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},e.prototype._trySubscribe=function(e){if(this.closed)throw new a.N;return t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){if(this.closed)throw new a.N;return this.hasError?(t.error(this.thrownError),o.w.EMPTY):this.isStopped?(t.complete(),o.w.EMPTY):(this.observers.push(t),new u.W(this,t))},e.prototype.asObservable=function(){var t=new i.y;return t.source=this,t},e.create=function(t,e){return new d(t,e)},e}(i.y),d=function(t){function e(e,n){var r=t.call(this)||this;return r.destination=e,r.source=n,r}return r.ZT(e,t),e.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},e.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},e.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},e.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):o.w.EMPTY},e}(l)},8253:(t,e,n)=>{"use strict";n.d(e,{W:()=>i});var r=n(5987),i=function(t){function e(e,n){var r=t.call(this)||this;return r.subject=e,r.subscriber=n,r.closed=!1,r}return r.ZT(e,t),e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var n=e.indexOf(this.subscriber);-1!==n&&e.splice(n,1)}}},e}(n(8760).w)},979:(t,e,n)=>{"use strict";n.d(e,{L:()=>h});var r=n(5987),i=n(4156),s=n(2174),o=n(8760),a=n(3142),u=n(150),c=n(1644),h=function(t){function e(n,r,i){var o=t.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=s.c;break;case 1:if(!n){o.destination=s.c;break}if("object"==typeof n){n instanceof e?(o.syncErrorThrowable=n.syncErrorThrowable,o.destination=n,n.add(o)):(o.syncErrorThrowable=!0,o.destination=new l(o,n));break}default:o.syncErrorThrowable=!0,o.destination=new l(o,n,r,i)}return o}return r.ZT(e,t),e.prototype[a.b]=function(){return this},e.create=function(t,n,r){var i=new e(t,n,r);return i.syncErrorThrowable=!1,i},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},e}(o.w),l=function(t){function e(e,n,r,o){var a,u=t.call(this)||this;u._parentSubscriber=e;var c=u;return(0,i.m)(n)?a=n:n&&(a=n.next,r=n.error,o=n.complete,n!==s.c&&(c=Object.create(n),(0,i.m)(c.unsubscribe)&&u.add(c.unsubscribe.bind(c)),c.unsubscribe=u.unsubscribe.bind(u))),u._context=c,u._next=a,u._error=r,u._complete=o,u}return r.ZT(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;u.v.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,n=u.v.useDeprecatedSynchronousErrorHandling;if(this._error)n&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)n?(e.syncErrorValue=t,e.syncErrorThrown=!0):(0,c.z)(t),this.unsubscribe();else{if(this.unsubscribe(),n)throw t;(0,c.z)(t)}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var n=function(){return t._complete.call(t._context)};u.v.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),u.v.useDeprecatedSynchronousErrorHandling)throw t;(0,c.z)(t)}},e.prototype.__tryOrSetError=function(t,e,n){if(!u.v.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,n)}catch(e){return u.v.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):((0,c.z)(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(h)},8760:(t,e,n)=>{"use strict";n.d(e,{w:()=>a});var r=n(9026),i=n(2009),s=n(4156),o=n(8782),a=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}var e;return t.prototype.unsubscribe=function(){var e;if(!this.closed){var n=this,a=n._parentOrParents,c=n._ctorUnsubscribe,h=n._unsubscribe,l=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,a instanceof t)a.remove(this);else if(null!==a)for(var d=0;d<a.length;++d)a[d].remove(this);if((0,s.m)(h)){c&&(this._unsubscribe=void 0);try{h.call(this)}catch(t){e=t instanceof o.B?u(t.errors):[t]}}if((0,r.k)(l)){d=-1;for(var f=l.length;++d<f;){var p=l[d];if((0,i.K)(p))try{p.unsubscribe()}catch(t){e=e||[],t instanceof o.B?e=e.concat(u(t.errors)):e.push(t)}}}if(e)throw new o.B(e)}},t.prototype.add=function(e){var n=e;if(!e)return t.EMPTY;switch(typeof e){case"function":n=new t(e);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof t)){var r=n;(n=new t)._subscriptions=[r]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var i=n._parentOrParents;if(null===i)n._parentOrParents=this;else if(i instanceof t){if(i===this)return n;n._parentOrParents=[i,this]}else{if(-1!==i.indexOf(this))return n;i.push(this)}var s=this._subscriptions;return null===s?this._subscriptions=[n]:s.push(n),n},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}},t.EMPTY=((e=new t).closed=!0,e),t}();function u(t){return t.reduce((function(t,e){return t.concat(e instanceof o.B?e.errors:e)}),[])}},150:(t,e,n)=>{"use strict";n.d(e,{v:()=>i});var r=!1,i={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack,r=t},get useDeprecatedSynchronousErrorHandling(){return r}}},7604:(t,e,n)=>{"use strict";n.d(e,{Ds:()=>u,IY:()=>a,ft:()=>c});var r=n(5987),i=n(979),s=n(2772),o=n(7843),a=function(t){function e(e){var n=t.call(this)||this;return n.parent=e,n}return r.ZT(e,t),e.prototype._next=function(t){this.parent.notifyNext(t)},e.prototype._error=function(t){this.parent.notifyError(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},e}(i.L),u=(i.L,function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(){this.destination.complete()},e}(i.L));function c(t,e){if(!e.closed)return t instanceof s.y?t.subscribe(e):(0,o.s)(t)(e)}i.L},3140:(t,e,n)=>{"use strict";n.d(e,{N:()=>h,c:()=>c});var r=n(5987),i=n(211),s=n(2772),o=n(979),a=n(8760),u=n(3018),c=function(t){function e(e,n){var r=t.call(this)||this;return r.source=e,r.subjectFactory=n,r._refCount=0,r._isComplete=!1,r}return r.ZT(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new a.w).add(this.source.subscribe(new l(this.getSubject(),this))),t.closed&&(this._connection=null,t=a.w.EMPTY)),t},e.prototype.refCount=function(){return(0,u.x)()(this)},e}(s.y),h=function(){var t=c.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:t._subscribe},_isComplete:{value:t._isComplete,writable:!0},getSubject:{value:t.getSubject},connect:{value:t.connect},refCount:{value:t.refCount}}}(),l=function(t){function e(e,n){var r=t.call(this,e)||this;return r.connectable=n,r}return r.ZT(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(i.Yc);o.L},5142:(t,e,n)=>{"use strict";n.d(e,{Ms:()=>l,aj:()=>h});var r=n(5987),i=n(7507),s=n(9026),o=n(2039),a=n(2080),u=n(3375),c={};function h(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=void 0,r=void 0;return(0,i.K)(t[t.length-1])&&(r=t.pop()),"function"==typeof t[t.length-1]&&(n=t.pop()),1===t.length&&(0,s.k)(t[0])&&(t=t[0]),(0,u.n)(t,r).lift(new l(n))}var l=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new d(t,this.resultSelector))},t}(),d=function(t){function e(e,n){var r=t.call(this,e)||this;return r.resultSelector=n,r.active=0,r.values=[],r.observables=[],r}return r.ZT(e,t),e.prototype._next=function(t){this.values.push(c),this.observables.push(t)},e.prototype._complete=function(){var t=this.observables,e=t.length;if(0===e)this.destination.complete();else{this.active=e,this.toRespond=e;for(var n=0;n<e;n++){var r=t[n];this.add((0,a.D)(this,r,void 0,n))}}},e.prototype.notifyComplete=function(t){0==(this.active-=1)&&this.destination.complete()},e.prototype.notifyNext=function(t,e,n){var r=this.values,i=r[n],s=this.toRespond?i===c?--this.toRespond:this.toRespond:0;r[n]=e,0===s&&(this.resultSelector?this._tryResultSelector(r):this.destination.next(r.slice()))},e.prototype._tryResultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(o.L)},9795:(t,e,n)=>{"use strict";n.d(e,{z:()=>s});var r=n(8170),i=n(2257);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0,i.u)()(r.of.apply(void 0,t))}},1410:(t,e,n)=>{"use strict";n.d(e,{P:()=>o});var r=n(2772),i=n(5760),s=n(5631);function o(t){return new r.y((function(e){var n;try{n=t()}catch(t){return void e.error(t)}return(n?(0,i.D)(n):(0,s.c)()).subscribe(e)}))}},5631:(t,e,n)=>{"use strict";n.d(e,{E:()=>i,c:()=>s});var r=n(2772),i=new r.y((function(t){return t.complete()}));function s(t){return t?function(t){return new r.y((function(e){return t.schedule((function(){return e.complete()}))}))}(t):i}},5760:(t,e,n)=>{"use strict";n.d(e,{D:()=>o});var r=n(2772),i=n(7843),s=n(8107);function o(t,e){return e?(0,s.x)(t,e):t instanceof r.y?t:new r.y((0,i.s)(t))}},3375:(t,e,n)=>{"use strict";n.d(e,{n:()=>o});var r=n(2772),i=n(6900),s=n(3109);function o(t,e){return e?(0,s.r)(t,e):new r.y((0,i.V)(t))}},4370:(t,e,n)=>{"use strict";n.d(e,{T:()=>a});var r=n(2772),i=n(7507),s=n(2556),o=n(3375);function a(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Number.POSITIVE_INFINITY,a=null,u=t[t.length-1];return(0,i.K)(u)?(a=t.pop(),t.length>1&&"number"==typeof t[t.length-1]&&(n=t.pop())):"number"==typeof u&&(n=t.pop()),null===a&&1===t.length&&t[0]instanceof r.y?t[0]:(0,s.J)(n)((0,o.n)(t,a))}},8170:(t,e,n)=>{"use strict";n.d(e,{of:()=>o});var r=n(7507),i=n(3375),s=n(3109);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[t.length-1];return(0,r.K)(n)?(t.pop(),(0,s.r)(t,n)):(0,i.n)(t)}},8821:(t,e,n)=>{"use strict";n.d(e,{S3:()=>u});var r=n(5987),i=n(9026),s=n(3375),o=n(2039),a=n(2080);function u(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(1===t.length){if(!(0,i.k)(t[0]))return t[0];t=t[0]}return(0,s.n)(t,void 0).lift(new c)}var c=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new h(t))},t}(),h=function(t){function e(e){var n=t.call(this,e)||this;return n.hasFirst=!1,n.observables=[],n.subscriptions=[],n}return r.ZT(e,t),e.prototype._next=function(t){this.observables.push(t)},e.prototype._complete=function(){var t=this.observables,e=t.length;if(0===e)this.destination.complete();else{for(var n=0;n<e&&!this.hasFirst;n++){var r=t[n],i=(0,a.D)(this,r,void 0,n);this.subscriptions&&this.subscriptions.push(i),this.add(i)}this.observables=null}},e.prototype.notifyNext=function(t,e,n){if(!this.hasFirst){this.hasFirst=!0;for(var r=0;r<this.subscriptions.length;r++)if(r!==n){var i=this.subscriptions[r];i.unsubscribe(),this.remove(i)}this.subscriptions=null}this.destination.next(e)},e}(o.L)},4944:(t,e,n)=>{"use strict";n.d(e,{_:()=>i});var r=n(2772);function i(t,e){return e?new r.y((function(n){return e.schedule(s,0,{error:t,subscriber:n})})):new r.y((function(e){return e.error(t)}))}function s(t){var e=t.error;t.subscriber.error(e)}},9604:(t,e,n)=>{"use strict";n.d(e,{H:()=>a});var r=n(2772),i=n(964),s=n(5812),o=n(7507);function a(t,e,n){void 0===t&&(t=0);var a=-1;return(0,s.k)(e)?a=Number(e)<1?1:Number(e):(0,o.K)(e)&&(n=e),(0,o.K)(n)||(n=i.P),new r.y((function(e){var r=(0,s.k)(t)?t:+t-n.now();return n.schedule(u,r,{index:0,period:a,subscriber:e})}))}function u(t){var e=t.index,n=t.period,r=t.subscriber;if(r.next(e),!r.closed){if(-1===n)return r.complete();t.index=e+1,this.schedule(t,n)}}},5080:(t,e,n)=>{"use strict";n.d(e,{$R:()=>c,mx:()=>h});var r=n(5987),i=n(3375),s=n(9026),o=n(979),a=n(999),u=n(7604);function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[t.length-1];return"function"==typeof n&&t.pop(),(0,i.n)(t,void 0).lift(new h(n))}var h=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new l(t,this.resultSelector))},t}(),l=function(t){function e(e,n,r){void 0===r&&(r=Object.create(null));var i=t.call(this,e)||this;return i.resultSelector=n,i.iterators=[],i.active=0,i.resultSelector="function"==typeof n?n:void 0,i}return r.ZT(e,t),e.prototype._next=function(t){var e=this.iterators;(0,s.k)(t)?e.push(new f(t)):"function"==typeof t[a.hZ]?e.push(new d(t[a.hZ]())):e.push(new p(this.destination,this,t))},e.prototype._complete=function(){var t=this.iterators,e=t.length;if(this.unsubscribe(),0!==e){this.active=e;for(var n=0;n<e;n++){var r=t[n];r.stillUnsubscribed?this.destination.add(r.subscribe()):this.active--}}else this.destination.complete()},e.prototype.notifyInactive=function(){this.active--,0===this.active&&this.destination.complete()},e.prototype.checkIterators=function(){for(var t=this.iterators,e=t.length,n=this.destination,r=0;r<e;r++)if("function"==typeof(o=t[r]).hasValue&&!o.hasValue())return;var i=!1,s=[];for(r=0;r<e;r++){var o,a=(o=t[r]).next();if(o.hasCompleted()&&(i=!0),a.done)return void n.complete();s.push(a.value)}this.resultSelector?this._tryresultSelector(s):n.next(s),i&&n.complete()},e.prototype._tryresultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(o.L),d=function(){function t(t){this.iterator=t,this.nextResult=t.next()}return t.prototype.hasValue=function(){return!0},t.prototype.next=function(){var t=this.nextResult;return this.nextResult=this.iterator.next(),t},t.prototype.hasCompleted=function(){var t=this.nextResult;return Boolean(t&&t.done)},t}(),f=function(){function t(t){this.array=t,this.index=0,this.length=0,this.length=t.length}return t.prototype[a.hZ]=function(){return this},t.prototype.next=function(t){var e=this.index++,n=this.array;return e<this.length?{value:n[e],done:!1}:{value:null,done:!0}},t.prototype.hasValue=function(){return this.array.length>this.index},t.prototype.hasCompleted=function(){return this.array.length===this.index},t}(),p=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.parent=n,i.observable=r,i.stillUnsubscribed=!0,i.buffer=[],i.isComplete=!1,i}return r.ZT(e,t),e.prototype[a.hZ]=function(){return this},e.prototype.next=function(){var t=this.buffer;return 0===t.length&&this.isComplete?{value:null,done:!0}:{value:t.shift(),done:!1}},e.prototype.hasValue=function(){return this.buffer.length>0},e.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},e.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},e.prototype.notifyNext=function(t){this.buffer.push(t),this.parent.checkIterators()},e.prototype.subscribe=function(){return(0,u.ft)(this.observable,new u.IY(this))},e}(u.Ds)},2257:(t,e,n)=>{"use strict";n.d(e,{u:()=>i});var r=n(2556);function i(){return(0,r.J)(1)}},6008:(t,e,n)=>{"use strict";n.d(e,{h:()=>s});var r=n(5987),i=n(979);function s(t,e){return function(n){return n.lift(new o(t,e))}}var o=function(){function t(t,e){this.predicate=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.predicate,this.thisArg))},t}(),a=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.thisArg=r,i.count=0,i}return r.ZT(e,t),e.prototype._next=function(t){var e;try{e=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}e&&this.destination.next(t)},e}(i.L)},1120:(t,e,n)=>{"use strict";n.d(e,{T:()=>d,v:()=>u});var r=n(5987),i=n(979),s=n(8760),o=n(2772),a=n(211);function u(t,e,n,r){return function(i){return i.lift(new c(t,e,n,r))}}var c=function(){function t(t,e,n,r){this.keySelector=t,this.elementSelector=e,this.durationSelector=n,this.subjectSelector=r}return t.prototype.call=function(t,e){return e.subscribe(new h(t,this.keySelector,this.elementSelector,this.durationSelector,this.subjectSelector))},t}(),h=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.keySelector=n,o.elementSelector=r,o.durationSelector=i,o.subjectSelector=s,o.groups=null,o.attemptedToUnsubscribe=!1,o.count=0,o}return r.ZT(e,t),e.prototype._next=function(t){var e;try{e=this.keySelector(t)}catch(t){return void this.error(t)}this._group(t,e)},e.prototype._group=function(t,e){var n=this.groups;n||(n=this.groups=new Map);var r,i=n.get(e);if(this.elementSelector)try{r=this.elementSelector(t)}catch(t){this.error(t)}else r=t;if(!i){i=this.subjectSelector?this.subjectSelector():new a.xQ,n.set(e,i);var s=new d(e,i,this);if(this.destination.next(s),this.durationSelector){var o=void 0;try{o=this.durationSelector(new d(e,i))}catch(t){return void this.error(t)}this.add(o.subscribe(new l(e,i,this)))}}i.closed||i.next(r)},e.prototype._error=function(t){var e=this.groups;e&&(e.forEach((function(e,n){e.error(t)})),e.clear()),this.destination.error(t)},e.prototype._complete=function(){var t=this.groups;t&&(t.forEach((function(t,e){t.complete()})),t.clear()),this.destination.complete()},e.prototype.removeGroup=function(t){this.groups.delete(t)},e.prototype.unsubscribe=function(){this.closed||(this.attemptedToUnsubscribe=!0,0===this.count&&t.prototype.unsubscribe.call(this))},e}(i.L),l=function(t){function e(e,n,r){var i=t.call(this,n)||this;return i.key=e,i.group=n,i.parent=r,i}return r.ZT(e,t),e.prototype._next=function(t){this.complete()},e.prototype._unsubscribe=function(){var t=this.parent,e=this.key;this.key=this.parent=null,t&&t.removeGroup(e)},e}(i.L),d=function(t){function e(e,n,r){var i=t.call(this)||this;return i.key=e,i.groupSubject=n,i.refCountSubscription=r,i}return r.ZT(e,t),e.prototype._subscribe=function(t){var e=new s.w,n=this.refCountSubscription,r=this.groupSubject;return n&&!n.closed&&e.add(new f(n)),e.add(r.subscribe(t)),e},e}(o.y),f=function(t){function e(e){var n=t.call(this)||this;return n.parent=e,e.count++,n}return r.ZT(e,t),e.prototype.unsubscribe=function(){var e=this.parent;e.closed||this.closed||(t.prototype.unsubscribe.call(this),e.count-=1,0===e.count&&e.attemptedToUnsubscribe&&e.unsubscribe())},e}(s.w)},5709:(t,e,n)=>{"use strict";n.d(e,{U:()=>s});var r=n(5987),i=n(979);function s(t,e){return function(n){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new o(t,e))}}var o=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.project,this.thisArg))},t}(),a=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.project=n,i.count=0,i.thisArg=r||i,i}return r.ZT(e,t),e.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(i.L)},2556:(t,e,n)=>{"use strict";n.d(e,{J:()=>s});var r=n(7746),i=n(3608);function s(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),(0,r.zg)(i.y,t)}},7746:(t,e,n)=>{"use strict";n.d(e,{VS:()=>h,zg:()=>a});var r=n(5987),i=n(5709),s=n(5760),o=n(7604);function a(t,e,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),"function"==typeof e?function(r){return r.pipe(a((function(n,r){return(0,s.D)(t(n,r)).pipe((0,i.U)((function(t,i){return e(n,t,r,i)})))}),n))}:("number"==typeof e&&(n=e),function(e){return e.lift(new u(t,n))})}var u=function(){function t(t,e){void 0===e&&(e=Number.POSITIVE_INFINITY),this.project=t,this.concurrent=e}return t.prototype.call=function(t,e){return e.subscribe(new c(t,this.project,this.concurrent))},t}(),c=function(t){function e(e,n,r){void 0===r&&(r=Number.POSITIVE_INFINITY);var i=t.call(this,e)||this;return i.project=n,i.concurrent=r,i.hasCompleted=!1,i.buffer=[],i.active=0,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){this.active<this.concurrent?this._tryNext(t):this.buffer.push(t)},e.prototype._tryNext=function(t){var e,n=this.index++;try{e=this.project(t,n)}catch(t){return void this.destination.error(t)}this.active++,this._innerSub(e)},e.prototype._innerSub=function(t){var e=new o.IY(this),n=this.destination;n.add(e);var r=(0,o.ft)(t,e);r!==e&&n.add(r)},e.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t.length>0?this._next(t.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},e}(o.Ds),h=a},9276:(t,e,n)=>{"use strict";n.d(e,{QV:()=>o,ht:()=>u});var r=n(5987),i=n(979),s=n(2632);function o(t,e){return void 0===e&&(e=0),function(n){return n.lift(new a(t,e))}}var a=function(){function t(t,e){void 0===e&&(e=0),this.scheduler=t,this.delay=e}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.scheduler,this.delay))},t}(),u=function(t){function e(e,n,r){void 0===r&&(r=0);var i=t.call(this,e)||this;return i.scheduler=n,i.delay=r,i}return r.ZT(e,t),e.dispatch=function(t){var e=t.notification,n=t.destination;e.observe(n),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(e.dispatch,this.delay,new c(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(s.P.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(s.P.createError(t)),this.unsubscribe()},e.prototype._complete=function(){this.scheduleMessage(s.P.createComplete()),this.unsubscribe()},e}(i.L),c=function(){return function(t,e){this.notification=t,this.destination=e}}()},3018:(t,e,n)=>{"use strict";n.d(e,{x:()=>s});var r=n(5987),i=n(979);function s(){return function(t){return t.lift(new o(t))}}var o=function(){function t(t){this.connectable=t}return t.prototype.call=function(t,e){var n=this.connectable;n._refCount++;var r=new a(t,n),i=e.subscribe(r);return r.closed||(r.connection=n.connect()),i},t}(),a=function(t){function e(e,n){var r=t.call(this,e)||this;return r.connectable=n,r}return r.ZT(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var n=this.connection,r=t._connection;this.connection=null,!r||n&&r!==n||r.unsubscribe()}}else this.connection=null},e}(i.L)},3109:(t,e,n)=>{"use strict";n.d(e,{r:()=>s});var r=n(2772),i=n(8760);function s(t,e){return new r.y((function(n){var r=new i.w,s=0;return r.add(e.schedule((function(){s!==t.length?(n.next(t[s++]),n.closed||r.add(this.schedule())):n.complete()}))),r}))}},8107:(t,e,n)=>{"use strict";n.d(e,{x:()=>h});var r=n(2772),i=n(8760),s=n(5050),o=n(3109),a=n(999),u=n(336),c=n(9217);function h(t,e){if(null!=t){if(function(t){return t&&"function"==typeof t[s.L]}(t))return function(t,e){return new r.y((function(n){var r=new i.w;return r.add(e.schedule((function(){var i=t[s.L]();r.add(i.subscribe({next:function(t){r.add(e.schedule((function(){return n.next(t)})))},error:function(t){r.add(e.schedule((function(){return n.error(t)})))},complete:function(){r.add(e.schedule((function(){return n.complete()})))}}))}))),r}))}(t,e);if((0,u.t)(t))return function(t,e){return new r.y((function(n){var r=new i.w;return r.add(e.schedule((function(){return t.then((function(t){r.add(e.schedule((function(){n.next(t),r.add(e.schedule((function(){return n.complete()})))})))}),(function(t){r.add(e.schedule((function(){return n.error(t)})))}))}))),r}))}(t,e);if((0,c.z)(t))return(0,o.r)(t,e);if(function(t){return t&&"function"==typeof t[a.hZ]}(t)||"string"==typeof t)return function(t,e){if(!t)throw new Error("Iterable cannot be null");return new r.y((function(n){var r,s=new i.w;return s.add((function(){r&&"function"==typeof r.return&&r.return()})),s.add(e.schedule((function(){r=t[a.hZ](),s.add(e.schedule((function(){if(!n.closed){var t,e;try{var i=r.next();t=i.value,e=i.done}catch(t){return void n.error(t)}e?n.complete():(n.next(t),this.schedule())}})))}))),s}))}(t,e)}throw new TypeError((null!==t&&typeof t||t)+" is not observable")}},6114:(t,e,n)=>{"use strict";n.d(e,{o:()=>i});var r=n(5987),i=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r.pending=!1,r}return r.ZT(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var n=this.id,r=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(r,n,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(r,this.id,e),this},e.prototype.requestAsyncId=function(t,e,n){return void 0===n&&(n=0),setInterval(t.flush.bind(t,this),n)},e.prototype.recycleAsyncId=function(t,e,n){if(void 0===n&&(n=0),null!==n&&this.delay===n&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(t,e);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var n=!1,r=void 0;try{this.work(t)}catch(t){n=!0,r=!!t&&t||new Error(t)}if(n)return this.unsubscribe(),r},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,n=e.actions,r=n.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==r&&n.splice(r,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(function(t){function e(e,n){return t.call(this)||this}return r.ZT(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(n(8760).w))},8399:(t,e,n)=>{"use strict";n.d(e,{v:()=>s});var r=n(5987),i=n(8725),s=function(t){function e(n,r){void 0===r&&(r=i.b.now);var s=t.call(this,n,(function(){return e.delegate&&e.delegate!==s?e.delegate.now():r()}))||this;return s.actions=[],s.active=!1,s.scheduled=void 0,s}return r.ZT(e,t),e.prototype.schedule=function(n,r,i){return void 0===r&&(r=0),e.delegate&&e.delegate!==this?e.delegate.schedule(n,r,i):t.prototype.schedule.call(this,n,r,i)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var n;this.active=!0;do{if(n=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,n){for(;t=e.shift();)t.unsubscribe();throw n}}},e}(i.b)},6650:(t,e,n)=>{"use strict";n.d(e,{e:()=>h,E:()=>c});var r=n(5987),i=1,s=function(){return Promise.resolve()}(),o={};function a(t){return t in o&&(delete o[t],!0)}var u=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return r.ZT(e,t),e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0?t.prototype.requestAsyncId.call(this,e,n,r):(e.actions.push(this),e.scheduled||(e.scheduled=(u=e.flush.bind(e,null),c=i++,o[c]=!0,s.then((function(){return a(c)&&u()})),c)));var u,c},e.prototype.recycleAsyncId=function(e,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,n,r);0===e.actions.length&&(a(n),e.scheduled=void 0)},e}(n(6114).o),c=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,n=this.actions,r=-1,i=n.length;t=t||n.shift();do{if(e=t.execute(t.state,t.delay))break}while(++r<i&&(t=n.shift()));if(this.active=!1,e){for(;++r<i&&(t=n.shift());)t.unsubscribe();throw e}},e}(n(8399).v))(u),h=c},964:(t,e,n)=>{"use strict";n.d(e,{P:()=>s,z:()=>i});var r=n(6114),i=new(n(8399).v)(r.o),s=i},2546:(t,e,n)=>{"use strict";n.d(e,{c:()=>o,N:()=>s});var r=n(5987),i=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return r.ZT(e,t),e.prototype.schedule=function(e,n){return void 0===n&&(n=0),n>0?t.prototype.schedule.call(this,e,n):(this.delay=n,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,n){return n>0||this.closed?t.prototype.execute.call(this,e,n):this._execute(e,n)},e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0?t.prototype.requestAsyncId.call(this,e,n,r):e.flush(this)},e}(n(6114).o),s=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e}(n(8399).v))(i),o=s},999:(t,e,n)=>{"use strict";function r(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}n.d(e,{hZ:()=>i});var i=r()},5050:(t,e,n)=>{"use strict";n.d(e,{L:()=>r});var r=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}()},3142:(t,e,n)=>{"use strict";n.d(e,{b:()=>r});var r=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}()},6565:(t,e,n)=>{"use strict";n.d(e,{W:()=>r});var r=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}()},6929:(t,e,n)=>{"use strict";n.d(e,{K:()=>r});var r=function(){function t(){return Error.call(this),this.message="no elements in sequence",this.name="EmptyError",this}return t.prototype=Object.create(Error.prototype),t}()},1016:(t,e,n)=>{"use strict";n.d(e,{N:()=>r});var r=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}()},1462:(t,e,n)=>{"use strict";n.d(e,{W:()=>r});var r=function(){function t(){return Error.call(this),this.message="Timeout has occurred",this.name="TimeoutError",this}return t.prototype=Object.create(Error.prototype),t}()},8782:(t,e,n)=>{"use strict";n.d(e,{B:()=>r});var r=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}()},3642:(t,e,n)=>{"use strict";n.d(e,{_:()=>i});var r=n(979);function i(t){for(;t;){var e=t,n=e.closed,i=e.destination,s=e.isStopped;if(n||s)return!1;t=i&&i instanceof r.L?i:null}return!0}},1644:(t,e,n)=>{"use strict";function r(t){setTimeout((function(){throw t}),0)}n.d(e,{z:()=>r})},3608:(t,e,n)=>{"use strict";function r(t){return t}n.d(e,{y:()=>r})},9026:(t,e,n)=>{"use strict";n.d(e,{k:()=>r});var r=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}()},9217:(t,e,n)=>{"use strict";n.d(e,{z:()=>r});var r=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t}},4156:(t,e,n)=>{"use strict";function r(t){return"function"==typeof t}n.d(e,{m:()=>r})},5812:(t,e,n)=>{"use strict";n.d(e,{k:()=>i});var r=n(9026);function i(t){return!(0,r.k)(t)&&t-parseFloat(t)+1>=0}},2009:(t,e,n)=>{"use strict";function r(t){return null!==t&&"object"==typeof t}n.d(e,{K:()=>r})},336:(t,e,n)=>{"use strict";function r(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}n.d(e,{t:()=>r})},7507:(t,e,n)=>{"use strict";function r(t){return t&&"function"==typeof t.schedule}n.d(e,{K:()=>r})},3306:(t,e,n)=>{"use strict";function r(){}n.d(e,{Z:()=>r})},9067:(t,e,n)=>{"use strict";function r(t,e){function n(){return!n.pred.apply(n.thisArg,arguments)}return n.pred=t,n.thisArg=e,n}n.d(e,{f:()=>r})},2561:(t,e,n)=>{"use strict";n.d(e,{U:()=>s,z:()=>i});var r=n(3608);function i(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s(t)}function s(t){return 0===t.length?r.y:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)}}},7843:(t,e,n)=>{"use strict";n.d(e,{s:()=>h});var r=n(6900),i=n(1644),s=n(999),o=n(5050),a=n(9217),u=n(336),c=n(2009),h=function(t){if(t&&"function"==typeof t[o.L])return h=t,function(t){var e=h[o.L]();if("function"!=typeof e.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return e.subscribe(t)};if((0,a.z)(t))return(0,r.V)(t);if((0,u.t)(t))return n=t,function(t){return n.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,i.z),t};if(t&&"function"==typeof t[s.hZ])return e=t,function(t){for(var n=e[s.hZ]();;){var r=void 0;try{r=n.next()}catch(e){return t.error(e),t}if(r.done){t.complete();break}if(t.next(r.value),t.closed)break}return"function"==typeof n.return&&t.add((function(){n.return&&n.return()})),t};var e,n,h,l=(0,c.K)(t)?"an invalid object":"'"+t+"'";throw new TypeError("You provided "+l+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")}},6900:(t,e,n)=>{"use strict";n.d(e,{V:()=>r});var r=function(t){return function(e){for(var n=0,r=t.length;n<r&&!e.closed;n++)e.next(t[n]);e.complete()}}},2080:(t,e,n)=>{"use strict";n.d(e,{D:()=>a});var r=n(5987),i=function(t){function e(e,n,r){var i=t.call(this)||this;return i.parent=e,i.outerValue=n,i.outerIndex=r,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this.index++,this)},e.prototype._error=function(t){this.parent.notifyError(t,this),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(n(979).L),s=n(7843),o=n(2772);function a(t,e,n,r,a){if(void 0===a&&(a=new i(t,n,r)),!a.closed)return e instanceof o.y?e.subscribe(a):(0,s.s)(e)(a)}},1717:(t,e,n)=>{"use strict";n.r(e),n.d(e,{audit:()=>s,auditTime:()=>h,buffer:()=>l,bufferCount:()=>m,bufferTime:()=>w,bufferToggle:()=>C,bufferWhen:()=>R,catchError:()=>M,combineAll:()=>j,combineLatest:()=>z,concat:()=>G,concatAll:()=>W.u,concatMap:()=>H,concatMapTo:()=>Y,count:()=>Q,debounce:()=>X,debounceTime:()=>nt,defaultIfEmpty:()=>ot,delay:()=>lt,delayWhen:()=>gt,dematerialize:()=>It,distinct:()=>Et,distinctUntilChanged:()=>xt,distinctUntilKeyChanged:()=>Ct,elementAt:()=>qt,endWith:()=>Kt,every:()=>Gt,exhaust:()=>Ht,exhaustMap:()=>Jt,expand:()=>ee,filter:()=>Ot.h,finalize:()=>ie,find:()=>ae,findIndex:()=>he,first:()=>de,flatMap:()=>$.VS,groupBy:()=>fe.v,ignoreElements:()=>pe,isEmpty:()=>ye,last:()=>Te,map:()=>Zt.U,mapTo:()=>Ee,materialize:()=>xe,max:()=>Le,merge:()=>Ve,mergeAll:()=>Fe.J,mergeMap:()=>$.zg,mergeMapTo:()=>Ue,mergeScan:()=>je,min:()=>ze,multicast:()=>Ge,observeOn:()=>$e.QV,onErrorResumeNext:()=>He,pairwise:()=>Ze,partition:()=>en,pluck:()=>nn,publish:()=>on,publishBehavior:()=>un,publishLast:()=>hn,publishReplay:()=>dn,race:()=>pn,reduce:()=>Pe,refCount:()=>xn.x,repeat:()=>mn,repeatWhen:()=>vn,retry:()=>In,retryWhen:()=>En,sample:()=>Nn,sampleTime:()=>Dn,scan:()=>Ce,sequenceEqual:()=>Ln,share:()=>jn,shareReplay:()=>Bn,single:()=>qn,skip:()=>Gn,skipLast:()=>Hn,skipUntil:()=>Zn,skipWhile:()=>tr,startWith:()=>rr,subscribeOn:()=>ar,switchAll:()=>dr,switchMap:()=>cr,switchMapTo:()=>fr,take:()=>Ut,takeLast:()=>we,takeUntil:()=>pr,takeWhile:()=>yr,tap:()=>_r,throttle:()=>Ar,throttleTime:()=>kr,throwIfEmpty:()=>Pt,timeInterval:()=>Pr,timeout:()=>Br,timeoutWith:()=>Vr,timestamp:()=>qr,toArray:()=>Gr,window:()=>Wr,windowCount:()=>Yr,windowTime:()=>Jr,windowToggle:()=>si,windowWhen:()=>ui,withLatestFrom:()=>li,zip:()=>mi,zipAll:()=>gi});var r=n(5987),i=n(7604);function s(t){return function(e){return e.lift(new o(t))}}var o=function(){function t(t){this.durationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.durationSelector))},t}(),a=function(t){function e(e,n){var r=t.call(this,e)||this;return r.durationSelector=n,r.hasValue=!1,r}return r.ZT(e,t),e.prototype._next=function(t){if(this.value=t,this.hasValue=!0,!this.throttled){var e=void 0;try{e=(0,this.durationSelector)(t)}catch(t){return this.destination.error(t)}var n=(0,i.ft)(e,new i.IY(this));!n||n.closed?this.clearThrottle():this.add(this.throttled=n)}},e.prototype.clearThrottle=function(){var t=this,e=t.value,n=t.hasValue,r=t.throttled;r&&(this.remove(r),this.throttled=void 0,r.unsubscribe()),n&&(this.value=void 0,this.hasValue=!1,this.destination.next(e))},e.prototype.notifyNext=function(){this.clearThrottle()},e.prototype.notifyComplete=function(){this.clearThrottle()},e}(i.Ds),u=n(964),c=n(9604);function h(t,e){return void 0===e&&(e=u.P),s((function(){return(0,c.H)(t,e)}))}function l(t){return function(e){return e.lift(new d(t))}}var d=function(){function t(t){this.closingNotifier=t}return t.prototype.call=function(t,e){return e.subscribe(new f(t,this.closingNotifier))},t}(),f=function(t){function e(e,n){var r=t.call(this,e)||this;return r.buffer=[],r.add((0,i.ft)(n,new i.IY(r))),r}return r.ZT(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype.notifyNext=function(){var t=this.buffer;this.buffer=[],this.destination.next(t)},e}(i.Ds),p=n(979);function m(t,e){return void 0===e&&(e=null),function(n){return n.lift(new g(t,e))}}var g=function(){function t(t,e){this.bufferSize=t,this.startBufferEvery=e,this.subscriberClass=e&&t!==e?v:y}return t.prototype.call=function(t,e){return e.subscribe(new this.subscriberClass(t,this.bufferSize,this.startBufferEvery))},t}(),y=function(t){function e(e,n){var r=t.call(this,e)||this;return r.bufferSize=n,r.buffer=[],r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.buffer;e.push(t),e.length==this.bufferSize&&(this.destination.next(e),this.buffer=[])},e.prototype._complete=function(){var e=this.buffer;e.length>0&&this.destination.next(e),t.prototype._complete.call(this)},e}(p.L),v=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.bufferSize=n,i.startBufferEvery=r,i.buffers=[],i.count=0,i}return r.ZT(e,t),e.prototype._next=function(t){var e=this,n=e.bufferSize,r=e.startBufferEvery,i=e.buffers,s=e.count;this.count++,s%r==0&&i.push([]);for(var o=i.length;o--;){var a=i[o];a.push(t),a.length===n&&(i.splice(o,1),this.destination.next(a))}},e.prototype._complete=function(){for(var e=this.buffers,n=this.destination;e.length>0;){var r=e.shift();r.length>0&&n.next(r)}t.prototype._complete.call(this)},e}(p.L),b=n(7507);function w(t){var e=arguments.length,n=u.P;(0,b.K)(arguments[arguments.length-1])&&(n=arguments[arguments.length-1],e--);var r=null;e>=2&&(r=arguments[1]);var i=Number.POSITIVE_INFINITY;return e>=3&&(i=arguments[2]),function(e){return e.lift(new I(t,r,i,n))}}var I=function(){function t(t,e,n,r){this.bufferTimeSpan=t,this.bufferCreationInterval=e,this.maxBufferSize=n,this.scheduler=r}return t.prototype.call=function(t,e){return e.subscribe(new T(t,this.bufferTimeSpan,this.bufferCreationInterval,this.maxBufferSize,this.scheduler))},t}(),_=function(){return function(){this.buffer=[]}}(),T=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;o.bufferTimeSpan=n,o.bufferCreationInterval=r,o.maxBufferSize=i,o.scheduler=s,o.contexts=[];var a=o.openContext();if(o.timespanOnly=null==r||r<0,o.timespanOnly){var u={subscriber:o,context:a,bufferTimeSpan:n};o.add(a.closeAction=s.schedule(E,n,u))}else{var c={subscriber:o,context:a},h={bufferTimeSpan:n,bufferCreationInterval:r,subscriber:o,scheduler:s};o.add(a.closeAction=s.schedule(A,n,c)),o.add(s.schedule(S,r,h))}return o}return r.ZT(e,t),e.prototype._next=function(t){for(var e,n=this.contexts,r=n.length,i=0;i<r;i++){var s=n[i],o=s.buffer;o.push(t),o.length==this.maxBufferSize&&(e=s)}e&&this.onBufferFull(e)},e.prototype._error=function(e){this.contexts.length=0,t.prototype._error.call(this,e)},e.prototype._complete=function(){for(var e=this.contexts,n=this.destination;e.length>0;){var r=e.shift();n.next(r.buffer)}t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.contexts=null},e.prototype.onBufferFull=function(t){this.closeContext(t);var e=t.closeAction;if(e.unsubscribe(),this.remove(e),!this.closed&&this.timespanOnly){t=this.openContext();var n=this.bufferTimeSpan,r={subscriber:this,context:t,bufferTimeSpan:n};this.add(t.closeAction=this.scheduler.schedule(E,n,r))}},e.prototype.openContext=function(){var t=new _;return this.contexts.push(t),t},e.prototype.closeContext=function(t){this.destination.next(t.buffer);var e=this.contexts;(e?e.indexOf(t):-1)>=0&&e.splice(e.indexOf(t),1)},e}(p.L);function E(t){var e=t.subscriber,n=t.context;n&&e.closeContext(n),e.closed||(t.context=e.openContext(),t.context.closeAction=this.schedule(t,t.bufferTimeSpan))}function S(t){var e=t.bufferCreationInterval,n=t.bufferTimeSpan,r=t.subscriber,i=t.scheduler,s=r.openContext();r.closed||(r.add(s.closeAction=i.schedule(A,n,{subscriber:r,context:s})),this.schedule(t,e))}function A(t){var e=t.subscriber,n=t.context;e.closeContext(n)}var x=n(8760),N=n(2080),k=n(2039);function C(t,e){return function(n){return n.lift(new D(t,e))}}var D=function(){function t(t,e){this.openings=t,this.closingSelector=e}return t.prototype.call=function(t,e){return e.subscribe(new O(t,this.openings,this.closingSelector))},t}(),O=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.closingSelector=r,i.contexts=[],i.add((0,N.D)(i,n)),i}return r.ZT(e,t),e.prototype._next=function(t){for(var e=this.contexts,n=e.length,r=0;r<n;r++)e[r].buffer.push(t)},e.prototype._error=function(e){for(var n=this.contexts;n.length>0;){var r=n.shift();r.subscription.unsubscribe(),r.buffer=null,r.subscription=null}this.contexts=null,t.prototype._error.call(this,e)},e.prototype._complete=function(){for(var e=this.contexts;e.length>0;){var n=e.shift();this.destination.next(n.buffer),n.subscription.unsubscribe(),n.buffer=null,n.subscription=null}this.contexts=null,t.prototype._complete.call(this)},e.prototype.notifyNext=function(t,e){t?this.closeBuffer(t):this.openBuffer(e)},e.prototype.notifyComplete=function(t){this.closeBuffer(t.context)},e.prototype.openBuffer=function(t){try{var e=this.closingSelector.call(this,t);e&&this.trySubscribe(e)}catch(t){this._error(t)}},e.prototype.closeBuffer=function(t){var e=this.contexts;if(e&&t){var n=t.buffer,r=t.subscription;this.destination.next(n),e.splice(e.indexOf(t),1),this.remove(r),r.unsubscribe()}},e.prototype.trySubscribe=function(t){var e=this.contexts,n=new x.w,r={buffer:[],subscription:n};e.push(r);var i=(0,N.D)(this,t,r);!i||i.closed?this.closeBuffer(r):(i.context=r,this.add(i),n.add(i))},e}(k.L);function R(t){return function(e){return e.lift(new P(t))}}var P=function(){function t(t){this.closingSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new L(t,this.closingSelector))},t}(),L=function(t){function e(e,n){var r=t.call(this,e)||this;return r.closingSelector=n,r.subscribing=!1,r.openBuffer(),r}return r.ZT(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype._complete=function(){var e=this.buffer;e&&this.destination.next(e),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.buffer=void 0,this.subscribing=!1},e.prototype.notifyNext=function(){this.openBuffer()},e.prototype.notifyComplete=function(){this.subscribing?this.complete():this.openBuffer()},e.prototype.openBuffer=function(){var t=this.closingSubscription;t&&(this.remove(t),t.unsubscribe());var e,n=this.buffer;this.buffer&&this.destination.next(n),this.buffer=[];try{e=(0,this.closingSelector)()}catch(t){return this.error(t)}t=new x.w,this.closingSubscription=t,this.add(t),this.subscribing=!0,t.add((0,i.ft)(e,new i.IY(this))),this.subscribing=!1},e}(i.Ds);function M(t){return function(e){var n=new V(t),r=e.lift(n);return n.caught=r}}var V=function(){function t(t){this.selector=t}return t.prototype.call=function(t,e){return e.subscribe(new F(t,this.selector,this.caught))},t}(),F=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.selector=n,i.caught=r,i}return r.ZT(e,t),e.prototype.error=function(e){if(!this.isStopped){var n=void 0;try{n=this.selector(e,this.caught)}catch(e){return void t.prototype.error.call(this,e)}this._unsubscribeAndRecycle();var r=new i.IY(this);this.add(r);var s=(0,i.ft)(n,r);s!==r&&this.add(s)}},e}(i.Ds),U=n(5142);function j(t){return function(e){return e.lift(new U.Ms(t))}}var B=n(9026),q=n(5760);function z(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=null;return"function"==typeof t[t.length-1]&&(n=t.pop()),1===t.length&&(0,B.k)(t[0])&&(t=t[0].slice()),function(e){return e.lift.call((0,q.D)([e].concat(t)),new U.Ms(n))}}var K=n(9795);function G(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return e.lift.call(K.z.apply(void 0,[e].concat(t)))}}var W=n(2257),$=n(7746);function H(t,e){return(0,$.zg)(t,e,1)}function Y(t,e){return H((function(){return t}),e)}function Q(t){return function(e){return e.lift(new Z(t,e))}}var Z=function(){function t(t,e){this.predicate=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new J(t,this.predicate,this.source))},t}(),J=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.source=r,i.count=0,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){this.predicate?this._tryPredicate(t):this.count++},e.prototype._tryPredicate=function(t){var e;try{e=this.predicate(t,this.index++,this.source)}catch(t){return void this.destination.error(t)}e&&this.count++},e.prototype._complete=function(){this.destination.next(this.count),this.destination.complete()},e}(p.L);function X(t){return function(e){return e.lift(new tt(t))}}var tt=function(){function t(t){this.durationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new et(t,this.durationSelector))},t}(),et=function(t){function e(e,n){var r=t.call(this,e)||this;return r.durationSelector=n,r.hasValue=!1,r}return r.ZT(e,t),e.prototype._next=function(t){try{var e=this.durationSelector.call(this,t);e&&this._tryNext(t,e)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){this.emitValue(),this.destination.complete()},e.prototype._tryNext=function(t,e){var n=this.durationSubscription;this.value=t,this.hasValue=!0,n&&(n.unsubscribe(),this.remove(n)),(n=(0,i.ft)(e,new i.IY(this)))&&!n.closed&&this.add(this.durationSubscription=n)},e.prototype.notifyNext=function(){this.emitValue()},e.prototype.notifyComplete=function(){this.emitValue()},e.prototype.emitValue=function(){if(this.hasValue){var e=this.value,n=this.durationSubscription;n&&(this.durationSubscription=void 0,n.unsubscribe(),this.remove(n)),this.value=void 0,this.hasValue=!1,t.prototype._next.call(this,e)}},e}(i.Ds);function nt(t,e){return void 0===e&&(e=u.P),function(n){return n.lift(new rt(t,e))}}var rt=function(){function t(t,e){this.dueTime=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new it(t,this.dueTime,this.scheduler))},t}(),it=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.dueTime=n,i.scheduler=r,i.debouncedSubscription=null,i.lastValue=null,i.hasValue=!1,i}return r.ZT(e,t),e.prototype._next=function(t){this.clearDebounce(),this.lastValue=t,this.hasValue=!0,this.add(this.debouncedSubscription=this.scheduler.schedule(st,this.dueTime,this))},e.prototype._complete=function(){this.debouncedNext(),this.destination.complete()},e.prototype.debouncedNext=function(){if(this.clearDebounce(),this.hasValue){var t=this.lastValue;this.lastValue=null,this.hasValue=!1,this.destination.next(t)}},e.prototype.clearDebounce=function(){var t=this.debouncedSubscription;null!==t&&(this.remove(t),t.unsubscribe(),this.debouncedSubscription=null)},e}(p.L);function st(t){t.debouncedNext()}function ot(t){return void 0===t&&(t=null),function(e){return e.lift(new at(t))}}var at=function(){function t(t){this.defaultValue=t}return t.prototype.call=function(t,e){return e.subscribe(new ut(t,this.defaultValue))},t}(),ut=function(t){function e(e,n){var r=t.call(this,e)||this;return r.defaultValue=n,r.isEmpty=!0,r}return r.ZT(e,t),e.prototype._next=function(t){this.isEmpty=!1,this.destination.next(t)},e.prototype._complete=function(){this.isEmpty&&this.destination.next(this.defaultValue),this.destination.complete()},e}(p.L);function ct(t){return t instanceof Date&&!isNaN(+t)}var ht=n(2632);function lt(t,e){void 0===e&&(e=u.P);var n=ct(t)?+t-e.now():Math.abs(t);return function(t){return t.lift(new dt(n,e))}}var dt=function(){function t(t,e){this.delay=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new ft(t,this.delay,this.scheduler))},t}(),ft=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.delay=n,i.scheduler=r,i.queue=[],i.active=!1,i.errored=!1,i}return r.ZT(e,t),e.dispatch=function(t){for(var e=t.source,n=e.queue,r=t.scheduler,i=t.destination;n.length>0&&n[0].time-r.now()<=0;)n.shift().notification.observe(i);if(n.length>0){var s=Math.max(0,n[0].time-r.now());this.schedule(t,s)}else this.unsubscribe(),e.active=!1},e.prototype._schedule=function(t){this.active=!0,this.destination.add(t.schedule(e.dispatch,this.delay,{source:this,destination:this.destination,scheduler:t}))},e.prototype.scheduleNotification=function(t){if(!0!==this.errored){var e=this.scheduler,n=new pt(e.now()+this.delay,t);this.queue.push(n),!1===this.active&&this._schedule(e)}},e.prototype._next=function(t){this.scheduleNotification(ht.P.createNext(t))},e.prototype._error=function(t){this.errored=!0,this.queue=[],this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.scheduleNotification(ht.P.createComplete()),this.unsubscribe()},e}(p.L),pt=function(){return function(t,e){this.time=t,this.notification=e}}(),mt=n(2772);function gt(t,e){return e?function(n){return new bt(n,e).lift(new yt(t))}:function(e){return e.lift(new yt(t))}}var yt=function(){function t(t){this.delayDurationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new vt(t,this.delayDurationSelector))},t}(),vt=function(t){function e(e,n){var r=t.call(this,e)||this;return r.delayDurationSelector=n,r.completed=!1,r.delayNotifierSubscriptions=[],r.index=0,r}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n,r,i){this.destination.next(t),this.removeSubscription(i),this.tryComplete()},e.prototype.notifyError=function(t,e){this._error(t)},e.prototype.notifyComplete=function(t){var e=this.removeSubscription(t);e&&this.destination.next(e),this.tryComplete()},e.prototype._next=function(t){var e=this.index++;try{var n=this.delayDurationSelector(t,e);n&&this.tryDelay(n,t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){this.completed=!0,this.tryComplete(),this.unsubscribe()},e.prototype.removeSubscription=function(t){t.unsubscribe();var e=this.delayNotifierSubscriptions.indexOf(t);return-1!==e&&this.delayNotifierSubscriptions.splice(e,1),t.outerValue},e.prototype.tryDelay=function(t,e){var n=(0,N.D)(this,t,e);n&&!n.closed&&(this.destination.add(n),this.delayNotifierSubscriptions.push(n))},e.prototype.tryComplete=function(){this.completed&&0===this.delayNotifierSubscriptions.length&&this.destination.complete()},e}(k.L),bt=function(t){function e(e,n){var r=t.call(this)||this;return r.source=e,r.subscriptionDelay=n,r}return r.ZT(e,t),e.prototype._subscribe=function(t){this.subscriptionDelay.subscribe(new wt(t,this.source))},e}(mt.y),wt=function(t){function e(e,n){var r=t.call(this)||this;return r.parent=e,r.source=n,r.sourceSubscribed=!1,r}return r.ZT(e,t),e.prototype._next=function(t){this.subscribeToSource()},e.prototype._error=function(t){this.unsubscribe(),this.parent.error(t)},e.prototype._complete=function(){this.unsubscribe(),this.subscribeToSource()},e.prototype.subscribeToSource=function(){this.sourceSubscribed||(this.sourceSubscribed=!0,this.unsubscribe(),this.source.subscribe(this.parent))},e}(p.L);function It(){return function(t){return t.lift(new _t)}}var _t=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Tt(t))},t}(),Tt=function(t){function e(e){return t.call(this,e)||this}return r.ZT(e,t),e.prototype._next=function(t){t.observe(this.destination)},e}(p.L);function Et(t,e){return function(n){return n.lift(new St(t,e))}}var St=function(){function t(t,e){this.keySelector=t,this.flushes=e}return t.prototype.call=function(t,e){return e.subscribe(new At(t,this.keySelector,this.flushes))},t}(),At=function(t){function e(e,n,r){var s=t.call(this,e)||this;return s.keySelector=n,s.values=new Set,r&&s.add((0,i.ft)(r,new i.IY(s))),s}return r.ZT(e,t),e.prototype.notifyNext=function(){this.values.clear()},e.prototype.notifyError=function(t){this._error(t)},e.prototype._next=function(t){this.keySelector?this._useKeySelector(t):this._finalizeNext(t,t)},e.prototype._useKeySelector=function(t){var e,n=this.destination;try{e=this.keySelector(t)}catch(t){return void n.error(t)}this._finalizeNext(e,t)},e.prototype._finalizeNext=function(t,e){var n=this.values;n.has(t)||(n.add(t),this.destination.next(e))},e}(i.Ds);function xt(t,e){return function(n){return n.lift(new Nt(t,e))}}var Nt=function(){function t(t,e){this.compare=t,this.keySelector=e}return t.prototype.call=function(t,e){return e.subscribe(new kt(t,this.compare,this.keySelector))},t}(),kt=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.keySelector=r,i.hasKey=!1,"function"==typeof n&&(i.compare=n),i}return r.ZT(e,t),e.prototype.compare=function(t,e){return t===e},e.prototype._next=function(t){var e;try{var n=this.keySelector;e=n?n(t):t}catch(t){return this.destination.error(t)}var r=!1;if(this.hasKey)try{r=(0,this.compare)(this.key,e)}catch(t){return this.destination.error(t)}else this.hasKey=!0;r||(this.key=e,this.destination.next(t))},e}(p.L);function Ct(t,e){return xt((function(n,r){return e?e(n[t],r[t]):n[t]===r[t]}))}var Dt=n(6565),Ot=n(6008),Rt=n(6929);function Pt(t){return void 0===t&&(t=Vt),function(e){return e.lift(new Lt(t))}}var Lt=function(){function t(t){this.errorFactory=t}return t.prototype.call=function(t,e){return e.subscribe(new Mt(t,this.errorFactory))},t}(),Mt=function(t){function e(e,n){var r=t.call(this,e)||this;return r.errorFactory=n,r.hasValue=!1,r}return r.ZT(e,t),e.prototype._next=function(t){this.hasValue=!0,this.destination.next(t)},e.prototype._complete=function(){if(this.hasValue)return this.destination.complete();var t=void 0;try{t=this.errorFactory()}catch(e){t=e}this.destination.error(t)},e}(p.L);function Vt(){return new Rt.K}var Ft=n(5631);function Ut(t){return function(e){return 0===t?(0,Ft.c)():e.lift(new jt(t))}}var jt=function(){function t(t){if(this.total=t,this.total<0)throw new Dt.W}return t.prototype.call=function(t,e){return e.subscribe(new Bt(t,this.total))},t}(),Bt=function(t){function e(e,n){var r=t.call(this,e)||this;return r.total=n,r.count=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.total,n=++this.count;n<=e&&(this.destination.next(t),n===e&&(this.destination.complete(),this.unsubscribe()))},e}(p.L);function qt(t,e){if(t<0)throw new Dt.W;var n=arguments.length>=2;return function(r){return r.pipe((0,Ot.h)((function(e,n){return n===t})),Ut(1),n?ot(e):Pt((function(){return new Dt.W})))}}var zt=n(8170);function Kt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return(0,K.z)(e,zt.of.apply(void 0,t))}}function Gt(t,e){return function(n){return n.lift(new Wt(t,e,n))}}var Wt=function(){function t(t,e,n){this.predicate=t,this.thisArg=e,this.source=n}return t.prototype.call=function(t,e){return e.subscribe(new $t(t,this.predicate,this.thisArg,this.source))},t}(),$t=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.predicate=n,s.thisArg=r,s.source=i,s.index=0,s.thisArg=r||s,s}return r.ZT(e,t),e.prototype.notifyComplete=function(t){this.destination.next(t),this.destination.complete()},e.prototype._next=function(t){var e=!1;try{e=this.predicate.call(this.thisArg,t,this.index++,this.source)}catch(t){return void this.destination.error(t)}e||this.notifyComplete(!1)},e.prototype._complete=function(){this.notifyComplete(!0)},e}(p.L);function Ht(){return function(t){return t.lift(new Yt)}}var Yt=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Qt(t))},t}(),Qt=function(t){function e(e){var n=t.call(this,e)||this;return n.hasCompleted=!1,n.hasSubscription=!1,n}return r.ZT(e,t),e.prototype._next=function(t){this.hasSubscription||(this.hasSubscription=!0,this.add((0,i.ft)(t,new i.IY(this))))},e.prototype._complete=function(){this.hasCompleted=!0,this.hasSubscription||this.destination.complete()},e.prototype.notifyComplete=function(){this.hasSubscription=!1,this.hasCompleted&&this.destination.complete()},e}(i.Ds),Zt=n(5709);function Jt(t,e){return e?function(n){return n.pipe(Jt((function(n,r){return(0,q.D)(t(n,r)).pipe((0,Zt.U)((function(t,i){return e(n,t,r,i)})))})))}:function(e){return e.lift(new Xt(t))}}var Xt=function(){function t(t){this.project=t}return t.prototype.call=function(t,e){return e.subscribe(new te(t,this.project))},t}(),te=function(t){function e(e,n){var r=t.call(this,e)||this;return r.project=n,r.hasSubscription=!1,r.hasCompleted=!1,r.index=0,r}return r.ZT(e,t),e.prototype._next=function(t){this.hasSubscription||this.tryNext(t)},e.prototype.tryNext=function(t){var e,n=this.index++;try{e=this.project(t,n)}catch(t){return void this.destination.error(t)}this.hasSubscription=!0,this._innerSub(e)},e.prototype._innerSub=function(t){var e=new i.IY(this),n=this.destination;n.add(e);var r=(0,i.ft)(t,e);r!==e&&n.add(r)},e.prototype._complete=function(){this.hasCompleted=!0,this.hasSubscription||this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(){this.hasSubscription=!1,this.hasCompleted&&this.destination.complete()},e}(i.Ds);function ee(t,e,n){return void 0===e&&(e=Number.POSITIVE_INFINITY),e=(e||0)<1?Number.POSITIVE_INFINITY:e,function(r){return r.lift(new ne(t,e,n))}}var ne=function(){function t(t,e,n){this.project=t,this.concurrent=e,this.scheduler=n}return t.prototype.call=function(t,e){return e.subscribe(new re(t,this.project,this.concurrent,this.scheduler))},t}(),re=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.project=n,s.concurrent=r,s.scheduler=i,s.index=0,s.active=0,s.hasCompleted=!1,r<Number.POSITIVE_INFINITY&&(s.buffer=[]),s}return r.ZT(e,t),e.dispatch=function(t){var e=t.subscriber,n=t.result,r=t.value,i=t.index;e.subscribeToProjection(n,r,i)},e.prototype._next=function(t){var n=this.destination;if(n.closed)this._complete();else{var r=this.index++;if(this.active<this.concurrent){n.next(t);try{var i=(0,this.project)(t,r);if(this.scheduler){var s={subscriber:this,result:i,value:t,index:r};this.destination.add(this.scheduler.schedule(e.dispatch,0,s))}else this.subscribeToProjection(i,t,r)}catch(t){n.error(t)}}else this.buffer.push(t)}},e.prototype.subscribeToProjection=function(t,e,n){this.active++,this.destination.add((0,i.ft)(t,new i.IY(this)))},e.prototype._complete=function(){this.hasCompleted=!0,this.hasCompleted&&0===this.active&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this._next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t&&t.length>0&&this._next(t.shift()),this.hasCompleted&&0===this.active&&this.destination.complete()},e}(i.Ds);function ie(t){return function(e){return e.lift(new se(t))}}var se=function(){function t(t){this.callback=t}return t.prototype.call=function(t,e){return e.subscribe(new oe(t,this.callback))},t}(),oe=function(t){function e(e,n){var r=t.call(this,e)||this;return r.add(new x.w(n)),r}return r.ZT(e,t),e}(p.L);function ae(t,e){if("function"!=typeof t)throw new TypeError("predicate is not a function");return function(n){return n.lift(new ue(t,n,!1,e))}}var ue=function(){function t(t,e,n,r){this.predicate=t,this.source=e,this.yieldIndex=n,this.thisArg=r}return t.prototype.call=function(t,e){return e.subscribe(new ce(t,this.predicate,this.source,this.yieldIndex,this.thisArg))},t}(),ce=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.predicate=n,o.source=r,o.yieldIndex=i,o.thisArg=s,o.index=0,o}return r.ZT(e,t),e.prototype.notifyComplete=function(t){var e=this.destination;e.next(t),e.complete(),this.unsubscribe()},e.prototype._next=function(t){var e=this.predicate,n=this.thisArg,r=this.index++;try{e.call(n||this,t,r,this.source)&&this.notifyComplete(this.yieldIndex?r:t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){this.notifyComplete(this.yieldIndex?-1:void 0)},e}(p.L);function he(t,e){return function(n){return n.lift(new ue(t,n,!0,e))}}var le=n(3608);function de(t,e){var n=arguments.length>=2;return function(r){return r.pipe(t?(0,Ot.h)((function(e,n){return t(e,n,r)})):le.y,Ut(1),n?ot(e):Pt((function(){return new Rt.K})))}}var fe=n(1120);function pe(){return function(t){return t.lift(new me)}}var me=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new ge(t))},t}(),ge=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.ZT(e,t),e.prototype._next=function(t){},e}(p.L);function ye(){return function(t){return t.lift(new ve)}}var ve=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new be(t))},t}(),be=function(t){function e(e){return t.call(this,e)||this}return r.ZT(e,t),e.prototype.notifyComplete=function(t){var e=this.destination;e.next(t),e.complete()},e.prototype._next=function(t){this.notifyComplete(!1)},e.prototype._complete=function(){this.notifyComplete(!0)},e}(p.L);function we(t){return function(e){return 0===t?(0,Ft.c)():e.lift(new Ie(t))}}var Ie=function(){function t(t){if(this.total=t,this.total<0)throw new Dt.W}return t.prototype.call=function(t,e){return e.subscribe(new _e(t,this.total))},t}(),_e=function(t){function e(e,n){var r=t.call(this,e)||this;return r.total=n,r.ring=new Array,r.count=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.ring,n=this.total,r=this.count++;e.length<n?e.push(t):e[r%n]=t},e.prototype._complete=function(){var t=this.destination,e=this.count;if(e>0)for(var n=this.count>=this.total?this.total:this.count,r=this.ring,i=0;i<n;i++){var s=e++%n;t.next(r[s])}t.complete()},e}(p.L);function Te(t,e){var n=arguments.length>=2;return function(r){return r.pipe(t?(0,Ot.h)((function(e,n){return t(e,n,r)})):le.y,we(1),n?ot(e):Pt((function(){return new Rt.K})))}}function Ee(t){return function(e){return e.lift(new Se(t))}}var Se=function(){function t(t){this.value=t}return t.prototype.call=function(t,e){return e.subscribe(new Ae(t,this.value))},t}(),Ae=function(t){function e(e,n){var r=t.call(this,e)||this;return r.value=n,r}return r.ZT(e,t),e.prototype._next=function(t){this.destination.next(this.value)},e}(p.L);function xe(){return function(t){return t.lift(new Ne)}}var Ne=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new ke(t))},t}(),ke=function(t){function e(e){return t.call(this,e)||this}return r.ZT(e,t),e.prototype._next=function(t){this.destination.next(ht.P.createNext(t))},e.prototype._error=function(t){var e=this.destination;e.next(ht.P.createError(t)),e.complete()},e.prototype._complete=function(){var t=this.destination;t.next(ht.P.createComplete()),t.complete()},e}(p.L);function Ce(t,e){var n=!1;return arguments.length>=2&&(n=!0),function(r){return r.lift(new De(t,e,n))}}var De=function(){function t(t,e,n){void 0===n&&(n=!1),this.accumulator=t,this.seed=e,this.hasSeed=n}return t.prototype.call=function(t,e){return e.subscribe(new Oe(t,this.accumulator,this.seed,this.hasSeed))},t}(),Oe=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.accumulator=n,s._seed=r,s.hasSeed=i,s.index=0,s}return r.ZT(e,t),Object.defineProperty(e.prototype,"seed",{get:function(){return this._seed},set:function(t){this.hasSeed=!0,this._seed=t},enumerable:!0,configurable:!0}),e.prototype._next=function(t){if(this.hasSeed)return this._tryNext(t);this.seed=t,this.destination.next(t)},e.prototype._tryNext=function(t){var e,n=this.index++;try{e=this.accumulator(this.seed,t,n)}catch(t){this.destination.error(t)}this.seed=e,this.destination.next(e)},e}(p.L),Re=n(2561);function Pe(t,e){return arguments.length>=2?function(n){return(0,Re.z)(Ce(t,e),we(1),ot(e))(n)}:function(e){return(0,Re.z)(Ce((function(e,n,r){return t(e,n,r+1)})),we(1))(e)}}function Le(t){return Pe("function"==typeof t?function(e,n){return t(e,n)>0?e:n}:function(t,e){return t>e?t:e})}var Me=n(4370);function Ve(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return e.lift.call(Me.T.apply(void 0,[e].concat(t)))}}var Fe=n(2556);function Ue(t,e,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),"function"==typeof e?(0,$.zg)((function(){return t}),e,n):("number"==typeof e&&(n=e),(0,$.zg)((function(){return t}),n))}function je(t,e,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),function(r){return r.lift(new Be(t,e,n))}}var Be=function(){function t(t,e,n){this.accumulator=t,this.seed=e,this.concurrent=n}return t.prototype.call=function(t,e){return e.subscribe(new qe(t,this.accumulator,this.seed,this.concurrent))},t}(),qe=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.accumulator=n,s.acc=r,s.concurrent=i,s.hasValue=!1,s.hasCompleted=!1,s.buffer=[],s.active=0,s.index=0,s}return r.ZT(e,t),e.prototype._next=function(t){if(this.active<this.concurrent){var e=this.index++,n=this.destination,r=void 0;try{r=(0,this.accumulator)(this.acc,t,e)}catch(t){return n.error(t)}this.active++,this._innerSub(r)}else this.buffer.push(t)},e.prototype._innerSub=function(t){var e=new i.IY(this),n=this.destination;n.add(e);var r=(0,i.ft)(t,e);r!==e&&n.add(r)},e.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&(!1===this.hasValue&&this.destination.next(this.acc),this.destination.complete()),this.unsubscribe()},e.prototype.notifyNext=function(t){var e=this.destination;this.acc=t,this.hasValue=!0,e.next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t.length>0?this._next(t.shift()):0===this.active&&this.hasCompleted&&(!1===this.hasValue&&this.destination.next(this.acc),this.destination.complete())},e}(i.Ds);function ze(t){return Pe("function"==typeof t?function(e,n){return t(e,n)<0?e:n}:function(t,e){return t<e?t:e})}var Ke=n(3140);function Ge(t,e){return function(n){var r;if(r="function"==typeof t?t:function(){return t},"function"==typeof e)return n.lift(new We(r,e));var i=Object.create(n,Ke.N);return i.source=n,i.subjectFactory=r,i}}var We=function(){function t(t,e){this.subjectFactory=t,this.selector=e}return t.prototype.call=function(t,e){var n=this.selector,r=this.subjectFactory(),i=n(r).subscribe(t);return i.add(e.subscribe(r)),i},t}(),$e=n(9276);function He(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 1===t.length&&(0,B.k)(t[0])&&(t=t[0]),function(e){return e.lift(new Ye(t))}}var Ye=function(){function t(t){this.nextSources=t}return t.prototype.call=function(t,e){return e.subscribe(new Qe(t,this.nextSources))},t}(),Qe=function(t){function e(e,n){var r=t.call(this,e)||this;return r.destination=e,r.nextSources=n,r}return r.ZT(e,t),e.prototype.notifyError=function(){this.subscribeToNextSource()},e.prototype.notifyComplete=function(){this.subscribeToNextSource()},e.prototype._error=function(t){this.subscribeToNextSource(),this.unsubscribe()},e.prototype._complete=function(){this.subscribeToNextSource(),this.unsubscribe()},e.prototype.subscribeToNextSource=function(){var t=this.nextSources.shift();if(t){var e=new i.IY(this),n=this.destination;n.add(e);var r=(0,i.ft)(t,e);r!==e&&n.add(r)}else this.destination.complete()},e}(i.Ds);function Ze(){return function(t){return t.lift(new Je)}}var Je=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Xe(t))},t}(),Xe=function(t){function e(e){var n=t.call(this,e)||this;return n.hasPrev=!1,n}return r.ZT(e,t),e.prototype._next=function(t){var e;this.hasPrev?e=[this.prev,t]:this.hasPrev=!0,this.prev=t,e&&this.destination.next(e)},e}(p.L),tn=n(9067);function en(t,e){return function(n){return[(0,Ot.h)(t,e)(n),(0,Ot.h)((0,tn.f)(t,e))(n)]}}function nn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t.length;if(0===n)throw new Error("list of properties cannot be empty.");return function(e){return(0,Zt.U)(rn(t,n))(e)}}function rn(t,e){return function(n){for(var r=n,i=0;i<e;i++){var s=null!=r?r[t[i]]:void 0;if(void 0===s)return;r=s}return r}}var sn=n(211);function on(t){return t?Ge((function(){return new sn.xQ}),t):Ge(new sn.xQ)}var an=n(9233);function un(t){return function(e){return Ge(new an.X(t))(e)}}var cn=n(364);function hn(){return function(t){return Ge(new cn.c)(t)}}var ln=n(2630);function dn(t,e,n,r){n&&"function"!=typeof n&&(r=n);var i="function"==typeof n?n:void 0,s=new ln.t(t,e,r);return function(t){return Ge((function(){return s}),i)(t)}}var fn=n(8821);function pn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return 1===t.length&&(0,B.k)(t[0])&&(t=t[0]),e.lift.call(fn.S3.apply(void 0,[e].concat(t)))}}function mn(t){return void 0===t&&(t=-1),function(e){return 0===t?(0,Ft.c)():t<0?e.lift(new gn(-1,e)):e.lift(new gn(t-1,e))}}var gn=function(){function t(t,e){this.count=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new yn(t,this.count,this.source))},t}(),yn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.count=n,i.source=r,i}return r.ZT(e,t),e.prototype.complete=function(){if(!this.isStopped){var e=this.source,n=this.count;if(0===n)return t.prototype.complete.call(this);n>-1&&(this.count=n-1),e.subscribe(this._unsubscribeAndRecycle())}},e}(p.L);function vn(t){return function(e){return e.lift(new bn(t))}}var bn=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){return e.subscribe(new wn(t,this.notifier,e))},t}(),wn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.notifier=n,i.source=r,i.sourceIsBeingSubscribedTo=!0,i}return r.ZT(e,t),e.prototype.notifyNext=function(){this.sourceIsBeingSubscribedTo=!0,this.source.subscribe(this)},e.prototype.notifyComplete=function(){if(!1===this.sourceIsBeingSubscribedTo)return t.prototype.complete.call(this)},e.prototype.complete=function(){if(this.sourceIsBeingSubscribedTo=!1,!this.isStopped){if(this.retries||this.subscribeToRetries(),!this.retriesSubscription||this.retriesSubscription.closed)return t.prototype.complete.call(this);this._unsubscribeAndRecycle(),this.notifications.next(void 0)}},e.prototype._unsubscribe=function(){var t=this.notifications,e=this.retriesSubscription;t&&(t.unsubscribe(),this.notifications=void 0),e&&(e.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},e.prototype._unsubscribeAndRecycle=function(){var e=this._unsubscribe;return this._unsubscribe=null,t.prototype._unsubscribeAndRecycle.call(this),this._unsubscribe=e,this},e.prototype.subscribeToRetries=function(){var e;this.notifications=new sn.xQ;try{e=(0,this.notifier)(this.notifications)}catch(e){return t.prototype.complete.call(this)}this.retries=e,this.retriesSubscription=(0,i.ft)(e,new i.IY(this))},e}(i.Ds);function In(t){return void 0===t&&(t=-1),function(e){return e.lift(new _n(t,e))}}var _n=function(){function t(t,e){this.count=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new Tn(t,this.count,this.source))},t}(),Tn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.count=n,i.source=r,i}return r.ZT(e,t),e.prototype.error=function(e){if(!this.isStopped){var n=this.source,r=this.count;if(0===r)return t.prototype.error.call(this,e);r>-1&&(this.count=r-1),n.subscribe(this._unsubscribeAndRecycle())}},e}(p.L);function En(t){return function(e){return e.lift(new Sn(t,e))}}var Sn=function(){function t(t,e){this.notifier=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new An(t,this.notifier,this.source))},t}(),An=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.notifier=n,i.source=r,i}return r.ZT(e,t),e.prototype.error=function(e){if(!this.isStopped){var n=this.errors,r=this.retries,s=this.retriesSubscription;if(r)this.errors=void 0,this.retriesSubscription=void 0;else{n=new sn.xQ;try{r=(0,this.notifier)(n)}catch(e){return t.prototype.error.call(this,e)}s=(0,i.ft)(r,new i.IY(this))}this._unsubscribeAndRecycle(),this.errors=n,this.retries=r,this.retriesSubscription=s,n.next(e)}},e.prototype._unsubscribe=function(){var t=this.errors,e=this.retriesSubscription;t&&(t.unsubscribe(),this.errors=void 0),e&&(e.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},e.prototype.notifyNext=function(){var t=this._unsubscribe;this._unsubscribe=null,this._unsubscribeAndRecycle(),this._unsubscribe=t,this.source.subscribe(this)},e}(i.Ds),xn=n(3018);function Nn(t){return function(e){return e.lift(new kn(t))}}var kn=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var n=new Cn(t),r=e.subscribe(n);return r.add((0,i.ft)(this.notifier,new i.IY(n))),r},t}(),Cn=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hasValue=!1,e}return r.ZT(e,t),e.prototype._next=function(t){this.value=t,this.hasValue=!0},e.prototype.notifyNext=function(){this.emitValue()},e.prototype.notifyComplete=function(){this.emitValue()},e.prototype.emitValue=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.value))},e}(i.Ds);function Dn(t,e){return void 0===e&&(e=u.P),function(n){return n.lift(new On(t,e))}}var On=function(){function t(t,e){this.period=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new Rn(t,this.period,this.scheduler))},t}(),Rn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.period=n,i.scheduler=r,i.hasValue=!1,i.add(r.schedule(Pn,n,{subscriber:i,period:n})),i}return r.ZT(e,t),e.prototype._next=function(t){this.lastValue=t,this.hasValue=!0},e.prototype.notifyNext=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.lastValue))},e}(p.L);function Pn(t){var e=t.subscriber,n=t.period;e.notifyNext(),this.schedule(t,n)}function Ln(t,e){return function(n){return n.lift(new Mn(t,e))}}var Mn=function(){function t(t,e){this.compareTo=t,this.comparator=e}return t.prototype.call=function(t,e){return e.subscribe(new Vn(t,this.compareTo,this.comparator))},t}(),Vn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.compareTo=n,i.comparator=r,i._a=[],i._b=[],i._oneComplete=!1,i.destination.add(n.subscribe(new Fn(e,i))),i}return r.ZT(e,t),e.prototype._next=function(t){this._oneComplete&&0===this._b.length?this.emit(!1):(this._a.push(t),this.checkValues())},e.prototype._complete=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0,this.unsubscribe()},e.prototype.checkValues=function(){for(var t=this,e=t._a,n=t._b,r=t.comparator;e.length>0&&n.length>0;){var i=e.shift(),s=n.shift(),o=!1;try{o=r?r(i,s):i===s}catch(t){this.destination.error(t)}o||this.emit(!1)}},e.prototype.emit=function(t){var e=this.destination;e.next(t),e.complete()},e.prototype.nextB=function(t){this._oneComplete&&0===this._a.length?this.emit(!1):(this._b.push(t),this.checkValues())},e.prototype.completeB=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0},e}(p.L),Fn=function(t){function e(e,n){var r=t.call(this,e)||this;return r.parent=n,r}return r.ZT(e,t),e.prototype._next=function(t){this.parent.nextB(t)},e.prototype._error=function(t){this.parent.error(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.completeB(),this.unsubscribe()},e}(p.L);function Un(){return new sn.xQ}function jn(){return function(t){return(0,xn.x)()(Ge(Un)(t))}}function Bn(t,e,n){var r;return r=t&&"object"==typeof t?t:{bufferSize:t,windowTime:e,refCount:!1,scheduler:n},function(t){return t.lift(function(t){var e,n,r=t.bufferSize,i=void 0===r?Number.POSITIVE_INFINITY:r,s=t.windowTime,o=void 0===s?Number.POSITIVE_INFINITY:s,a=t.refCount,u=t.scheduler,c=0,h=!1,l=!1;return function(t){var r;c++,!e||h?(h=!1,e=new ln.t(i,o,u),r=e.subscribe(this),n=t.subscribe({next:function(t){e.next(t)},error:function(t){h=!0,e.error(t)},complete:function(){l=!0,n=void 0,e.complete()}})):r=e.subscribe(this),this.add((function(){c--,r.unsubscribe(),n&&!l&&a&&0===c&&(n.unsubscribe(),n=void 0,e=void 0)}))}}(r))}}function qn(t){return function(e){return e.lift(new zn(t,e))}}var zn=function(){function t(t,e){this.predicate=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new Kn(t,this.predicate,this.source))},t}(),Kn=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.source=r,i.seenValue=!1,i.index=0,i}return r.ZT(e,t),e.prototype.applySingleValue=function(t){this.seenValue?this.destination.error("Sequence contains more than one element"):(this.seenValue=!0,this.singleValue=t)},e.prototype._next=function(t){var e=this.index++;this.predicate?this.tryNext(t,e):this.applySingleValue(t)},e.prototype.tryNext=function(t,e){try{this.predicate(t,e,this.source)&&this.applySingleValue(t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){var t=this.destination;this.index>0?(t.next(this.seenValue?this.singleValue:void 0),t.complete()):t.error(new Rt.K)},e}(p.L);function Gn(t){return function(e){return e.lift(new Wn(t))}}var Wn=function(){function t(t){this.total=t}return t.prototype.call=function(t,e){return e.subscribe(new $n(t,this.total))},t}(),$n=function(t){function e(e,n){var r=t.call(this,e)||this;return r.total=n,r.count=0,r}return r.ZT(e,t),e.prototype._next=function(t){++this.count>this.total&&this.destination.next(t)},e}(p.L);function Hn(t){return function(e){return e.lift(new Yn(t))}}var Yn=function(){function t(t){if(this._skipCount=t,this._skipCount<0)throw new Dt.W}return t.prototype.call=function(t,e){return 0===this._skipCount?e.subscribe(new p.L(t)):e.subscribe(new Qn(t,this._skipCount))},t}(),Qn=function(t){function e(e,n){var r=t.call(this,e)||this;return r._skipCount=n,r._count=0,r._ring=new Array(n),r}return r.ZT(e,t),e.prototype._next=function(t){var e=this._skipCount,n=this._count++;if(n<e)this._ring[n]=t;else{var r=n%e,i=this._ring,s=i[r];i[r]=t,this.destination.next(s)}},e}(p.L);function Zn(t){return function(e){return e.lift(new Jn(t))}}var Jn=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){return e.subscribe(new Xn(t,this.notifier))},t}(),Xn=function(t){function e(e,n){var r=t.call(this,e)||this;r.hasValue=!1;var s=new i.IY(r);r.add(s),r.innerSubscription=s;var o=(0,i.ft)(n,s);return o!==s&&(r.add(o),r.innerSubscription=o),r}return r.ZT(e,t),e.prototype._next=function(e){this.hasValue&&t.prototype._next.call(this,e)},e.prototype.notifyNext=function(){this.hasValue=!0,this.innerSubscription&&this.innerSubscription.unsubscribe()},e.prototype.notifyComplete=function(){},e}(i.Ds);function tr(t){return function(e){return e.lift(new er(t))}}var er=function(){function t(t){this.predicate=t}return t.prototype.call=function(t,e){return e.subscribe(new nr(t,this.predicate))},t}(),nr=function(t){function e(e,n){var r=t.call(this,e)||this;return r.predicate=n,r.skipping=!0,r.index=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e=this.destination;this.skipping&&this.tryCallPredicate(t),this.skipping||e.next(t)},e.prototype.tryCallPredicate=function(t){try{var e=this.predicate(t,this.index++);this.skipping=Boolean(e)}catch(t){this.destination.error(t)}},e}(p.L);function rr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[t.length-1];return(0,b.K)(n)?(t.pop(),function(e){return(0,K.z)(t,e,n)}):function(e){return(0,K.z)(t,e)}}var ir=n(6650),sr=n(5812),or=function(t){function e(e,n,r){void 0===n&&(n=0),void 0===r&&(r=ir.e);var i=t.call(this)||this;return i.source=e,i.delayTime=n,i.scheduler=r,(!(0,sr.k)(n)||n<0)&&(i.delayTime=0),r&&"function"==typeof r.schedule||(i.scheduler=ir.e),i}return r.ZT(e,t),e.create=function(t,n,r){return void 0===n&&(n=0),void 0===r&&(r=ir.e),new e(t,n,r)},e.dispatch=function(t){var e=t.source,n=t.subscriber;return this.add(e.subscribe(n))},e.prototype._subscribe=function(t){var n=this.delayTime,r=this.source;return this.scheduler.schedule(e.dispatch,n,{source:r,subscriber:t})},e}(mt.y);function ar(t,e){return void 0===e&&(e=0),function(n){return n.lift(new ur(t,e))}}var ur=function(){function t(t,e){this.scheduler=t,this.delay=e}return t.prototype.call=function(t,e){return new or(e,this.delay,this.scheduler).subscribe(t)},t}();function cr(t,e){return"function"==typeof e?function(n){return n.pipe(cr((function(n,r){return(0,q.D)(t(n,r)).pipe((0,Zt.U)((function(t,i){return e(n,t,r,i)})))})))}:function(e){return e.lift(new hr(t))}}var hr=function(){function t(t){this.project=t}return t.prototype.call=function(t,e){return e.subscribe(new lr(t,this.project))},t}(),lr=function(t){function e(e,n){var r=t.call(this,e)||this;return r.project=n,r.index=0,r}return r.ZT(e,t),e.prototype._next=function(t){var e,n=this.index++;try{e=this.project(t,n)}catch(t){return void this.destination.error(t)}this._innerSub(e)},e.prototype._innerSub=function(t){var e=this.innerSubscription;e&&e.unsubscribe();var n=new i.IY(this),r=this.destination;r.add(n),this.innerSubscription=(0,i.ft)(t,n),this.innerSubscription!==n&&r.add(this.innerSubscription)},e.prototype._complete=function(){var e=this.innerSubscription;e&&!e.closed||t.prototype._complete.call(this),this.unsubscribe()},e.prototype._unsubscribe=function(){this.innerSubscription=void 0},e.prototype.notifyComplete=function(){this.innerSubscription=void 0,this.isStopped&&t.prototype._complete.call(this)},e.prototype.notifyNext=function(t){this.destination.next(t)},e}(i.Ds);function dr(){return cr(le.y)}function fr(t,e){return e?cr((function(){return t}),e):cr((function(){return t}))}function pr(t){return function(e){return e.lift(new mr(t))}}var mr=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var n=new gr(t),r=(0,i.ft)(this.notifier,new i.IY(n));return r&&!n.seenValue?(n.add(r),e.subscribe(n)):n},t}(),gr=function(t){function e(e){var n=t.call(this,e)||this;return n.seenValue=!1,n}return r.ZT(e,t),e.prototype.notifyNext=function(){this.seenValue=!0,this.complete()},e.prototype.notifyComplete=function(){},e}(i.Ds);function yr(t,e){return void 0===e&&(e=!1),function(n){return n.lift(new vr(t,e))}}var vr=function(){function t(t,e){this.predicate=t,this.inclusive=e}return t.prototype.call=function(t,e){return e.subscribe(new br(t,this.predicate,this.inclusive))},t}(),br=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.predicate=n,i.inclusive=r,i.index=0,i}return r.ZT(e,t),e.prototype._next=function(t){var e,n=this.destination;try{e=this.predicate(t,this.index++)}catch(t){return void n.error(t)}this.nextOrComplete(t,e)},e.prototype.nextOrComplete=function(t,e){var n=this.destination;Boolean(e)?n.next(t):(this.inclusive&&n.next(t),n.complete())},e}(p.L),wr=n(3306),Ir=n(4156);function _r(t,e,n){return function(r){return r.lift(new Tr(t,e,n))}}var Tr=function(){function t(t,e,n){this.nextOrObserver=t,this.error=e,this.complete=n}return t.prototype.call=function(t,e){return e.subscribe(new Er(t,this.nextOrObserver,this.error,this.complete))},t}(),Er=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s._tapNext=wr.Z,s._tapError=wr.Z,s._tapComplete=wr.Z,s._tapError=r||wr.Z,s._tapComplete=i||wr.Z,(0,Ir.m)(n)?(s._context=s,s._tapNext=n):n&&(s._context=n,s._tapNext=n.next||wr.Z,s._tapError=n.error||wr.Z,s._tapComplete=n.complete||wr.Z),s}return r.ZT(e,t),e.prototype._next=function(t){try{this._tapNext.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.next(t)},e.prototype._error=function(t){try{this._tapError.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.error(t)},e.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(t){return void this.destination.error(t)}return this.destination.complete()},e}(p.L),Sr={leading:!0,trailing:!1};function Ar(t,e){return void 0===e&&(e=Sr),function(n){return n.lift(new xr(t,!!e.leading,!!e.trailing))}}var xr=function(){function t(t,e,n){this.durationSelector=t,this.leading=e,this.trailing=n}return t.prototype.call=function(t,e){return e.subscribe(new Nr(t,this.durationSelector,this.leading,this.trailing))},t}(),Nr=function(t){function e(e,n,r,i){var s=t.call(this,e)||this;return s.destination=e,s.durationSelector=n,s._leading=r,s._trailing=i,s._hasValue=!1,s}return r.ZT(e,t),e.prototype._next=function(t){this._hasValue=!0,this._sendValue=t,this._throttled||(this._leading?this.send():this.throttle(t))},e.prototype.send=function(){var t=this._hasValue,e=this._sendValue;t&&(this.destination.next(e),this.throttle(e)),this._hasValue=!1,this._sendValue=void 0},e.prototype.throttle=function(t){var e=this.tryDurationSelector(t);e&&this.add(this._throttled=(0,i.ft)(e,new i.IY(this)))},e.prototype.tryDurationSelector=function(t){try{return this.durationSelector(t)}catch(t){return this.destination.error(t),null}},e.prototype.throttlingDone=function(){var t=this._throttled,e=this._trailing;t&&t.unsubscribe(),this._throttled=void 0,e&&this.send()},e.prototype.notifyNext=function(){this.throttlingDone()},e.prototype.notifyComplete=function(){this.throttlingDone()},e}(i.Ds);function kr(t,e,n){return void 0===e&&(e=u.P),void 0===n&&(n=Sr),function(r){return r.lift(new Cr(t,e,n.leading,n.trailing))}}var Cr=function(){function t(t,e,n,r){this.duration=t,this.scheduler=e,this.leading=n,this.trailing=r}return t.prototype.call=function(t,e){return e.subscribe(new Dr(t,this.duration,this.scheduler,this.leading,this.trailing))},t}(),Dr=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.duration=n,o.scheduler=r,o.leading=i,o.trailing=s,o._hasTrailingValue=!1,o._trailingValue=null,o}return r.ZT(e,t),e.prototype._next=function(t){this.throttled?this.trailing&&(this._trailingValue=t,this._hasTrailingValue=!0):(this.add(this.throttled=this.scheduler.schedule(Or,this.duration,{subscriber:this})),this.leading?this.destination.next(t):this.trailing&&(this._trailingValue=t,this._hasTrailingValue=!0))},e.prototype._complete=function(){this._hasTrailingValue?(this.destination.next(this._trailingValue),this.destination.complete()):this.destination.complete()},e.prototype.clearThrottle=function(){var t=this.throttled;t&&(this.trailing&&this._hasTrailingValue&&(this.destination.next(this._trailingValue),this._trailingValue=null,this._hasTrailingValue=!1),t.unsubscribe(),this.remove(t),this.throttled=null)},e}(p.L);function Or(t){t.subscriber.clearThrottle()}var Rr=n(1410);function Pr(t){return void 0===t&&(t=u.P),function(e){return(0,Rr.P)((function(){return e.pipe(Ce((function(e,n){var r=e.current;return{value:n,current:t.now(),last:r}}),{current:t.now(),value:void 0,last:void 0}),(0,Zt.U)((function(t){var e=t.current,n=t.last,r=t.value;return new Lr(r,e-n)})))}))}}var Lr=function(){return function(t,e){this.value=t,this.interval=e}}(),Mr=n(1462);function Vr(t,e,n){return void 0===n&&(n=u.P),function(r){var i=ct(t),s=i?+t-n.now():Math.abs(t);return r.lift(new Fr(s,i,e,n))}}var Fr=function(){function t(t,e,n,r){this.waitFor=t,this.absoluteTimeout=e,this.withObservable=n,this.scheduler=r}return t.prototype.call=function(t,e){return e.subscribe(new Ur(t,this.absoluteTimeout,this.waitFor,this.withObservable,this.scheduler))},t}(),Ur=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;return o.absoluteTimeout=n,o.waitFor=r,o.withObservable=i,o.scheduler=s,o.scheduleTimeout(),o}return r.ZT(e,t),e.dispatchTimeout=function(t){var e=t.withObservable;t._unsubscribeAndRecycle(),t.add((0,i.ft)(e,new i.IY(t)))},e.prototype.scheduleTimeout=function(){var t=this.action;t?this.action=t.schedule(this,this.waitFor):this.add(this.action=this.scheduler.schedule(e.dispatchTimeout,this.waitFor,this))},e.prototype._next=function(e){this.absoluteTimeout||this.scheduleTimeout(),t.prototype._next.call(this,e)},e.prototype._unsubscribe=function(){this.action=void 0,this.scheduler=null,this.withObservable=null},e}(i.Ds),jr=n(4944);function Br(t,e){return void 0===e&&(e=u.P),Vr(t,(0,jr._)(new Mr.W),e)}function qr(t){return void 0===t&&(t=u.P),(0,Zt.U)((function(e){return new zr(e,t.now())}))}var zr=function(){return function(t,e){this.value=t,this.timestamp=e}}();function Kr(t,e,n){return 0===n?[e]:(t.push(e),t)}function Gr(){return Pe(Kr,[])}function Wr(t){return function(e){return e.lift(new $r(t))}}var $r=function(){function t(t){this.windowBoundaries=t}return t.prototype.call=function(t,e){var n=new Hr(t),r=e.subscribe(n);return r.closed||n.add((0,i.ft)(this.windowBoundaries,new i.IY(n))),r},t}(),Hr=function(t){function e(e){var n=t.call(this,e)||this;return n.window=new sn.xQ,e.next(n.window),n}return r.ZT(e,t),e.prototype.notifyNext=function(){this.openWindow()},e.prototype.notifyError=function(t){this._error(t)},e.prototype.notifyComplete=function(){this._complete()},e.prototype._next=function(t){this.window.next(t)},e.prototype._error=function(t){this.window.error(t),this.destination.error(t)},e.prototype._complete=function(){this.window.complete(),this.destination.complete()},e.prototype._unsubscribe=function(){this.window=null},e.prototype.openWindow=function(){var t=this.window;t&&t.complete();var e=this.destination,n=this.window=new sn.xQ;e.next(n)},e}(i.Ds);function Yr(t,e){return void 0===e&&(e=0),function(n){return n.lift(new Qr(t,e))}}var Qr=function(){function t(t,e){this.windowSize=t,this.startWindowEvery=e}return t.prototype.call=function(t,e){return e.subscribe(new Zr(t,this.windowSize,this.startWindowEvery))},t}(),Zr=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.destination=e,i.windowSize=n,i.startWindowEvery=r,i.windows=[new sn.xQ],i.count=0,e.next(i.windows[0]),i}return r.ZT(e,t),e.prototype._next=function(t){for(var e=this.startWindowEvery>0?this.startWindowEvery:this.windowSize,n=this.destination,r=this.windowSize,i=this.windows,s=i.length,o=0;o<s&&!this.closed;o++)i[o].next(t);var a=this.count-r+1;if(a>=0&&a%e==0&&!this.closed&&i.shift().complete(),++this.count%e==0&&!this.closed){var u=new sn.xQ;i.push(u),n.next(u)}},e.prototype._error=function(t){var e=this.windows;if(e)for(;e.length>0&&!this.closed;)e.shift().error(t);this.destination.error(t)},e.prototype._complete=function(){var t=this.windows;if(t)for(;t.length>0&&!this.closed;)t.shift().complete();this.destination.complete()},e.prototype._unsubscribe=function(){this.count=0,this.windows=null},e}(p.L);function Jr(t){var e=u.P,n=null,r=Number.POSITIVE_INFINITY;return(0,b.K)(arguments[3])&&(e=arguments[3]),(0,b.K)(arguments[2])?e=arguments[2]:(0,sr.k)(arguments[2])&&(r=Number(arguments[2])),(0,b.K)(arguments[1])?e=arguments[1]:(0,sr.k)(arguments[1])&&(n=Number(arguments[1])),function(i){return i.lift(new Xr(t,n,r,e))}}var Xr=function(){function t(t,e,n,r){this.windowTimeSpan=t,this.windowCreationInterval=e,this.maxWindowSize=n,this.scheduler=r}return t.prototype.call=function(t,e){return e.subscribe(new ei(t,this.windowTimeSpan,this.windowCreationInterval,this.maxWindowSize,this.scheduler))},t}(),ti=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._numberOfNextedValues=0,e}return r.ZT(e,t),e.prototype.next=function(e){this._numberOfNextedValues++,t.prototype.next.call(this,e)},Object.defineProperty(e.prototype,"numberOfNextedValues",{get:function(){return this._numberOfNextedValues},enumerable:!0,configurable:!0}),e}(sn.xQ),ei=function(t){function e(e,n,r,i,s){var o=t.call(this,e)||this;o.destination=e,o.windowTimeSpan=n,o.windowCreationInterval=r,o.maxWindowSize=i,o.scheduler=s,o.windows=[];var a=o.openWindow();if(null!==r&&r>=0){var u={subscriber:o,window:a,context:null},c={windowTimeSpan:n,windowCreationInterval:r,subscriber:o,scheduler:s};o.add(s.schedule(ii,n,u)),o.add(s.schedule(ri,r,c))}else{var h={subscriber:o,window:a,windowTimeSpan:n};o.add(s.schedule(ni,n,h))}return o}return r.ZT(e,t),e.prototype._next=function(t){for(var e=this.windows,n=e.length,r=0;r<n;r++){var i=e[r];i.closed||(i.next(t),i.numberOfNextedValues>=this.maxWindowSize&&this.closeWindow(i))}},e.prototype._error=function(t){for(var e=this.windows;e.length>0;)e.shift().error(t);this.destination.error(t)},e.prototype._complete=function(){for(var t=this.windows;t.length>0;){var e=t.shift();e.closed||e.complete()}this.destination.complete()},e.prototype.openWindow=function(){var t=new ti;return this.windows.push(t),this.destination.next(t),t},e.prototype.closeWindow=function(t){t.complete();var e=this.windows;e.splice(e.indexOf(t),1)},e}(p.L);function ni(t){var e=t.subscriber,n=t.windowTimeSpan,r=t.window;r&&e.closeWindow(r),t.window=e.openWindow(),this.schedule(t,n)}function ri(t){var e=t.windowTimeSpan,n=t.subscriber,r=t.scheduler,i=t.windowCreationInterval,s=n.openWindow(),o=this,a={action:o,subscription:null},u={subscriber:n,window:s,context:a};a.subscription=r.schedule(ii,e,u),o.add(a.subscription),o.schedule(t,i)}function ii(t){var e=t.subscriber,n=t.window,r=t.context;r&&r.action&&r.subscription&&r.action.remove(r.subscription),e.closeWindow(n)}function si(t,e){return function(n){return n.lift(new oi(t,e))}}var oi=function(){function t(t,e){this.openings=t,this.closingSelector=e}return t.prototype.call=function(t,e){return e.subscribe(new ai(t,this.openings,this.closingSelector))},t}(),ai=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.openings=n,i.closingSelector=r,i.contexts=[],i.add(i.openSubscription=(0,N.D)(i,n,n)),i}return r.ZT(e,t),e.prototype._next=function(t){var e=this.contexts;if(e)for(var n=e.length,r=0;r<n;r++)e[r].window.next(t)},e.prototype._error=function(e){var n=this.contexts;if(this.contexts=null,n)for(var r=n.length,i=-1;++i<r;){var s=n[i];s.window.error(e),s.subscription.unsubscribe()}t.prototype._error.call(this,e)},e.prototype._complete=function(){var e=this.contexts;if(this.contexts=null,e)for(var n=e.length,r=-1;++r<n;){var i=e[r];i.window.complete(),i.subscription.unsubscribe()}t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.contexts;if(this.contexts=null,t)for(var e=t.length,n=-1;++n<e;){var r=t[n];r.window.unsubscribe(),r.subscription.unsubscribe()}},e.prototype.notifyNext=function(t,e,n,r,i){if(t===this.openings){var s=void 0;try{s=(0,this.closingSelector)(e)}catch(t){return this.error(t)}var o=new sn.xQ,a=new x.w,u={window:o,subscription:a};this.contexts.push(u);var c=(0,N.D)(this,s,u);c.closed?this.closeWindow(this.contexts.length-1):(c.context=u,a.add(c)),this.destination.next(o)}else this.closeWindow(this.contexts.indexOf(t))},e.prototype.notifyError=function(t){this.error(t)},e.prototype.notifyComplete=function(t){t!==this.openSubscription&&this.closeWindow(this.contexts.indexOf(t.context))},e.prototype.closeWindow=function(t){if(-1!==t){var e=this.contexts,n=e[t],r=n.window,i=n.subscription;e.splice(t,1),r.complete(),i.unsubscribe()}},e}(k.L);function ui(t){return function(e){return e.lift(new ci(t))}}var ci=function(){function t(t){this.closingSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new hi(t,this.closingSelector))},t}(),hi=function(t){function e(e,n){var r=t.call(this,e)||this;return r.destination=e,r.closingSelector=n,r.openWindow(),r}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n,r,i){this.openWindow(i)},e.prototype.notifyError=function(t){this._error(t)},e.prototype.notifyComplete=function(t){this.openWindow(t)},e.prototype._next=function(t){this.window.next(t)},e.prototype._error=function(t){this.window.error(t),this.destination.error(t),this.unsubscribeClosingNotification()},e.prototype._complete=function(){this.window.complete(),this.destination.complete(),this.unsubscribeClosingNotification()},e.prototype.unsubscribeClosingNotification=function(){this.closingNotification&&this.closingNotification.unsubscribe()},e.prototype.openWindow=function(t){void 0===t&&(t=null),t&&(this.remove(t),t.unsubscribe());var e=this.window;e&&e.complete();var n,r=this.window=new sn.xQ;this.destination.next(r);try{n=(0,this.closingSelector)()}catch(t){return this.destination.error(t),void this.window.error(t)}this.add(this.closingNotification=(0,N.D)(this,n))},e}(k.L);function li(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){var n;"function"==typeof t[t.length-1]&&(n=t.pop());var r=t;return e.lift(new di(r,n))}}var di=function(){function t(t,e){this.observables=t,this.project=e}return t.prototype.call=function(t,e){return e.subscribe(new fi(t,this.observables,this.project))},t}(),fi=function(t){function e(e,n,r){var i=t.call(this,e)||this;i.observables=n,i.project=r,i.toRespond=[];var s=n.length;i.values=new Array(s);for(var o=0;o<s;o++)i.toRespond.push(o);for(o=0;o<s;o++){var a=n[o];i.add((0,N.D)(i,a,void 0,o))}return i}return r.ZT(e,t),e.prototype.notifyNext=function(t,e,n){this.values[n]=e;var r=this.toRespond;if(r.length>0){var i=r.indexOf(n);-1!==i&&r.splice(i,1)}},e.prototype.notifyComplete=function(){},e.prototype._next=function(t){if(0===this.toRespond.length){var e=[t].concat(this.values);this.project?this._tryProject(e):this.destination.next(e)}},e.prototype._tryProject=function(t){var e;try{e=this.project.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(k.L),pi=n(5080);function mi(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return e.lift.call(pi.$R.apply(void 0,[e].concat(t)))}}function gi(t){return function(e){return e.lift(new pi.mx(t))}}},5987:(t,e,n)=>{"use strict";n.d(e,{ZT:()=>i});var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},r(t,e)};function i(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}},8977:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{u(r.next(t))}catch(t){s(t)}}function a(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=s(n(6245)),a=s(n(646)),u=n(1382),c=n(9699),h=function(){function t(t){this.clientConfig=t,this.tokenStorageKey="RIO_TOKENS_KEY.".concat(t.projectId)}return t.prototype.setHttp=function(t){this.http=t},t.prototype.storeTokenData=function(t){var e;return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){return n=(0,u.getRuntime)(),void 0===t||(n===c.Runtime.web&&(localStorage.setItem(this.tokenStorageKey,JSON.stringify(t)),(null===(e=this.clientConfig)||void 0===e?void 0:e.useCookies)&&a.default.set(this.tokenStorageKey,JSON.stringify(t))),this.currentTokenData=t),[2]}))}))},t.prototype.clearTokenData=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){return(0,u.getRuntime)()===c.Runtime.web&&(localStorage.removeItem(this.tokenStorageKey),a.default.remove(this.tokenStorageKey)),this.currentTokenData=void 0,[2]}))}))},t.prototype.getCurrentTokenData=function(){var t;return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){return(0,u.getRuntime)()===c.Runtime.web?((null===(t=this.clientConfig)||void 0===t?void 0:t.useCookies)&&(n=a.default.get(this.tokenStorageKey))&&"undefined"!==n&&(e=JSON.parse(n)),e||(n=localStorage.getItem(this.tokenStorageKey))&&"undefined"!==n&&(e=JSON.parse(n))):e=this.currentTokenData,!e||e.accessTokenDecoded&&e.refreshTokenDecoded||(e.accessTokenDecoded=this.decodeToken(e.accessToken),e.refreshTokenDecoded=this.decodeToken(e.refreshToken)),[2,e]}))}))},t.prototype.getCurrentUser=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.getCurrentTokenData()];case 1:return[2,null==(t=e.sent())?void 0:t.accessTokenDecoded]}}))}))},t.prototype.getTokenData=function(){var t,e;return r(this,void 0,void 0,(function(){var n,r,s,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.getCurrentTokenData()];case 1:return(n=i.sent())?(r=n.diff+Math.round((new Date).getTime()/1e3)+30,n.accessTokenDecoded=this.decodeToken(n.accessToken),n.refreshTokenDecoded=this.decodeToken(n.refreshToken),s=null!==(t=n.accessTokenDecoded.exp)&&void 0!==t?t:0,(null!==(e=n.refreshTokenDecoded.exp)&&void 0!==e?e:0)>r&&s<=r?[4,this.getFreshToken(n.refreshToken)]:[3,3]):[2,void 0];case 2:return(o=i.sent()).accessTokenDecoded=this.decodeToken(o.accessToken),o.refreshTokenDecoded=this.decodeToken(o.refreshToken),[2,o];case 3:return[2,n]}}))}))},t.prototype.decodeToken=function(t){return(0,o.default)(t)},t.prototype.formatTokenData=function(t){return t.accessTokenDecoded=this.decodeToken(t.accessToken),t.refreshTokenDecoded=this.decodeToken(t.refreshToken),t.accessTokenDecoded.iat&&(t.diff=t.accessTokenDecoded.iat-Math.floor(Date.now()/1e3)),t},t.prototype.getFreshToken=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.http.call(this.clientConfig.projectId,"/TOKEN/refresh",{method:"post",data:{refreshToken:t}})];case 1:return e=n.sent(),[2,this.formatTokenData(e.data)]}}))}))},t.prototype.signIn=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.http.call(this.clientConfig.projectId,"/TOKEN/auth",{method:"post",data:{customToken:t}})];case 1:return e=n.sent().data,[2,this.formatTokenData(e)]}}))}))},t.prototype.signOut=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),[4,this.getCurrentTokenData()];case 1:return(t=e.sent())?[4,this.http.call(this.clientConfig.projectId,"/TOKEN/signOut",{method:"post",headers:{Authorization:"Bearer ".concat(t.accessToken)}})]:[3,3];case 2:e.sent(),e.label=3;case 3:return[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},t.prototype.getAuthStatus=function(t){if(t&&t.accessTokenDecoded){var e=t.accessTokenDecoded;return{uid:e.userId,identity:e.identity,authStatus:c.RetterAuthStatus.SIGNED_IN}}return{authStatus:c.RetterAuthStatus.SIGNED_OUT}},t}();e.default=h},6905:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)},i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{u(r.next(t))}catch(t){s(t)}}function a(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}u((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var a=o(n(9669)),u=n(1382),c=n(9699),h=[{id:c.RetterRegion.euWest1,url:"api.retter.io"},{id:c.RetterRegion.euWest1Beta,url:"test-api.retter.io"}],l=function(){function t(t){this.createAxiosInstance(),this.url=t.url,t.region||(t.region=c.RetterRegion.euWest1),this.region=h.find((function(e){return e.id===t.region})),this.culture=t.culture,this.platform=t.culture}return t.prototype.createAxiosInstance=function(){this.axiosInstance=a.default.create({responseType:"json",headers:{"Content-Type":"application/json"},timeout:3e4})},t.prototype.buildUrl=function(t,e){var n=this.url?"".concat(this.url):"".concat(t,".").concat(this.region.url);return"https://".concat(n,"/").concat(t,"/").concat(e.startsWith("/")?e.substr(1):e)},t.prototype.call=function(t,e,n){return i(this,void 0,void 0,(function(){var i,o;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),!(i=r({},n.params)).__culture&&this.culture&&(i.__culture=this.culture),!i.__platform&&this.platform&&(i.__platform=this.platform),"get"===n.method&&!1!==n.base64Encode&&n.data&&(o=(0,u.base64Encode)(JSON.stringify((0,u.sort)(n.data))),delete n.data,i.data=o,i.__isbase64=!0),[4,this.axiosInstance(r(r({url:this.buildUrl(t,e)},n),{params:i}))];case 1:return[2,s.sent()];case 2:throw s.sent();case 3:return[2]}}))}))},t}();e.default=l},1382:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sort=e.base64Encode=e.getRuntime=void 0;var r=n(9699);e.getRuntime=function(){return"undefined"!=typeof document?r.Runtime.web:r.Runtime.node},e.base64Encode=function(t){return Buffer.from(t).toString("base64")},e.sort=function t(e){return null==e?e:Array.isArray(e)?e.sort().map(t):"object"==typeof e?Object.keys(e).sort().reduce((function(n,r){return n[r]=t(e[r]),n}),{}):e}},3607:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),s=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{u(r.next(t))}catch(t){s(t)}}function a(t){try{u(r.throw(t))}catch(t){s(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},u=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var c=n(1591),h=n(5503),l=n(1591),d=n(6757),f=n(4143),p=n(1717),m=u(n(8977)),g=u(n(6905)),y=n(9699);s(n(9699),e);var v=function(){function t(){this.initialized=!1,this.authQueue=new f.Subject,this.actionQueue=new f.Subject,this.authStatusSubject=new f.ReplaySubject(1),this.cloudObjects=[],this.listeners={}}return t.getInstance=function(e){var n=t.instances.find((function(t){var n;return(null===(n=t.clientConfig)||void 0===n?void 0:n.projectId)===e.projectId}));if(n)return n;var r=new t;return r.init(e),t.instances.push(r),r},t.prototype.init=function(t){var e=this;if(this.initialized)throw new Error("SDK already initialized.");this.initialized=!0,t.retryConfig||(t.retryConfig={}),t.retryConfig.delay||(t.retryConfig.delay=50),t.retryConfig.count||(t.retryConfig.count=3),t.retryConfig.rate||(t.retryConfig.rate=1.5),this.clientConfig=t,this.auth=new m.default(t),this.http=new g.default(t),this.auth.setHttp(this.http),this.processAuthQueue(),this.processActionQueue(),setTimeout((function(){return o(e,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return[4,this.auth.getCurrentTokenData()];case 1:return t=e.sent(),this.fireAuthStatus({tokenData:t}),[2]}}))}))}),1)},t.prototype.processAuthQueue=function(){var t=this,e=this.authQueue.pipe((0,p.concatMap)((function(e){return(0,f.defer)((function(){return o(t,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.auth.signIn(e.data)];case 1:return t=r.sent(),[2,{action:e,response:t}];case 2:throw n=r.sent(),{action:e,responseError:n};case 3:return[2]}}))}))})).pipe((0,p.materialize)())})),(0,p.share)());e.pipe((0,p.filter)((function(t){return t.hasValue&&"N"===t.kind})),(0,p.map)((function(t){var e;return r(r({},t.value),{tokenData:null===(e=t.value)||void 0===e?void 0:e.response})})),(0,p.switchMap)((function(e){return o(t,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.storeTokenData(e)];case 1:return t.sent(),[2,e]}}))}))})),(0,p.switchMap)((function(e){return o(t,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return this.firebaseAuth?[4,(0,d.signOut)(this.firebaseAuth)]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.clearFirebase(),e.tokenData?[4,this.initFirebase(e)]:[3,4];case 3:t.sent(),t.label=4;case 4:return this.fireAuthStatus(e),[2,e]}}))}))}))).subscribe((function(e){var n,r;(null===(n=e.action)||void 0===n?void 0:n.resolve)&&e.action.resolve(null===(r=t.auth)||void 0===r?void 0:r.getAuthStatus(e.tokenData))})),e.pipe((0,p.filter)((function(t){return!1===t.hasValue&&"E"===t.kind}))).subscribe((function(t){var e;if(t.error&&t.error.action&&t.error.action.resolve){var n={authStatus:y.RetterAuthStatus.AUTH_FAILED,message:null===(e=t.error.responseError.response)||void 0===e?void 0:e.data};t.error.action.resolve(n)}})),this.authStatus.subscribe()},t.prototype.processActionQueue=function(){var t=this,e=this.actionQueue.asObservable().pipe((0,p.concatMap)(this.getActionWithTokenData.bind(this)),(0,p.tap)(this.fireAuthStatus.bind(this)),(0,p.filter)((function(t){return null!==t.tokenData})),(0,p.switchMap)((function(e){return o(t,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.storeTokenData(e)];case 1:return t.sent(),[2,e]}}))}))})),(0,p.mergeMap)(this.processAction.bind(this)),(0,p.share)());e.pipe((0,p.filter)((function(t){return t.hasValue&&"N"===t.kind}))).subscribe((function(t){t.value&&t.value.action&&t.value.action.resolve&&t.value.response&&t.value.action.resolve(t.value.response)})),e.pipe((0,p.filter)((function(t){return!1===t.hasValue&&"E"===t.kind}))).subscribe((function(t){t.error&&t.error.action&&t.error.action.reject&&t.error.responseError&&t.error.action.reject(t.error.responseError)}))},t.prototype.sendToAuthQueue=function(t){return o(this,void 0,void 0,(function(){var e=this;return a(this,(function(n){return[2,new Promise((function(n,i){e.authQueue.next(r(r({},t),{reject:i,resolve:n}))}))]}))}))},t.prototype.sendToActionQueue=function(t){return o(this,void 0,void 0,(function(){var e=this;return a(this,(function(n){return[2,new Promise((function(n,i){e.actionQueue.next(r(r({},t),{reject:i,resolve:n}))}))]}))}))},t.prototype.getActionWithTokenData=function(t){return o(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,5]),n={action:t},[4,this.auth.getTokenData()];case 1:return n.tokenData=r.sent(),e=n,[4,this.initFirebase(e)];case 2:return r.sent(),[2,e];case 3:return r.sent(),[4,this.signOut()];case 4:return r.sent(),[2,{action:t}];case 5:return[2]}}))}))},t.prototype.fireAuthStatus=function(t){var e=this.auth.getAuthStatus(t.tokenData);this.authStatusSubject.next(e)},t.prototype.storeTokenData=function(t){return o(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.auth.storeTokenData(t.tokenData)];case 1:return e.sent(),[2]}}))}))},t.prototype.processAction=function(t){var e,n=this;return(null===(e=t.action)||void 0===e?void 0:e.action)===y.RetterActions.EMPTY?(0,f.defer)((function(){return(0,f.of)(r(r({},t),{response:!0}))})).pipe((0,p.materialize)()):(0,f.defer)((function(){return o(n,void 0,void 0,(function(){var e,n,i;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),e=this.getCosEndpoint(t),[4,this.http.call(this.clientConfig.projectId,e.path,e.params)];case 1:return n=s.sent(),[2,r(r({},t),{response:n})];case 2:throw(i=s.sent()).response&&403===i.response.status&&i.response.data&&"ACCESS_DENIED"===i.response.data.code&&this.signOut(),r(r({},t),{responseError:i});case 3:return[2]}}))}))})).pipe((0,p.materialize)())},t.prototype.initFirebase=function(t){var e;return o(this,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:return!(n=null===(e=t.tokenData)||void 0===e?void 0:e.firebase)||this.firebase?[2,t]:(this.firebase=(0,h.initializeApp)({apiKey:n.apiKey,authDomain:n.projectId+".firebaseapp.com",projectId:n.projectId},this.clientConfig.projectId),this.firestore=(0,c.getFirestore)(this.firebase),this.firebaseAuth=(0,d.getAuth)(this.firebase),[4,(0,d.signInWithCustomToken)(this.firebaseAuth,n.customToken)]);case 1:return r.sent(),[2,t]}}))}))},t.prototype.clearFirebase=function(){this.firebase=void 0,this.firestore=void 0,this.firebaseAuth=void 0},t.prototype.getCosEndpoint=function(t){var e,n,i,s,o,a,u,c,h,l=t.action,d=l.data,f={};for(var p in d.queryStringParams||[])f[p]=d.queryStringParams[p];f.__culture=null!==(e=d.culture)&&void 0!==e?e:(null===(n=this.clientConfig)||void 0===n?void 0:n.culture)||"en-us",(d.platform||(null===(i=this.clientConfig)||void 0===i?void 0:i.platform))&&(f.__platform=null!==(s=d.platform)&&void 0!==s?s:null===(o=this.clientConfig)||void 0===o?void 0:o.platform);var m={params:f,method:null!==(a=d.httpMethod)&&void 0!==a?a:"post",data:d.body,base64Encode:null===(u=d.base64Encode)||void 0===u||u,headers:r({},d.headers)},g=null!==(c=d.token)&&void 0!==c?c:null===(h=t.tokenData)||void 0===h?void 0:h.accessToken;if(g&&(m.headers.Authorization="Bearer ".concat(g)),l.action===y.RetterActions.COS_INSTANCE){var v=d.key?"".concat(d.key.name,"!").concat(d.key.value):d.instanceId;return{path:"INSTANCE/".concat(d.classId).concat(v?"/".concat(v):""),params:m}}return l.action===y.RetterActions.COS_STATE?{path:"STATE/".concat(d.classId,"/").concat(d.instanceId),params:m}:l.action===y.RetterActions.COS_LIST?{path:"LIST/".concat(d.classId),params:m}:l.action===y.RetterActions.COS_STATIC_CALL?{path:"CALL/".concat(d.classId,"/").concat(d.method).concat(d.pathParams?"/".concat(d.pathParams):""),params:m}:{path:"CALL/".concat(d.classId,"/").concat(d.method,"/").concat(d.instanceId).concat(d.pathParams?"/".concat(d.pathParams):""),params:m}},t.prototype.getFirebaseListener=function(t,e,n){var r=(0,l.doc)(this.firestore,e,n);return(0,l.onSnapshot)(r,(function(e){for(var n=Object.assign({},e.data()),r=0,i=Object.keys(n);r<i.length;r++){var s=i[r];s.startsWith("__")&&delete n[s]}t.next(n)}))},t.prototype.getFirebaseState=function(t){return o(this,void 0,void 0,(function(){var e,n,r,i,s=this;return a(this,(function(o){switch(o.label){case 0:return e=this.clientConfig.projectId,[4,this.auth.getCurrentUser()];case 1:return n=o.sent(),r=[],[2,{state:{role:{queue:(i={role:new f.ReplaySubject(1),user:new f.ReplaySubject(1),public:new f.ReplaySubject(1)}).role,subscribe:function(o){if(!s.listeners["".concat(e,"_").concat(t.classId,"_").concat(t.instanceId,"_role")]){var a=s.getFirebaseListener(i.role,"/projects/".concat(e,"/classes/").concat(t.classId,"/instances/").concat(t.instanceId,"/roleState"),n.identity);r.push(a),s.listeners["".concat(e,"_").concat(t.classId,"_").concat(t.instanceId,"_role")]=a}return i.role.subscribe(o)}},user:{queue:i.user,subscribe:function(o){if(!s.listeners["".concat(e,"_").concat(t.classId,"_").concat(t.instanceId,"_user")]){var a=s.getFirebaseListener(i.user,"/projects/".concat(e,"/classes/").concat(t.classId,"/instances/").concat(t.instanceId,"/userState"),n.userId);r.push(a),s.listeners["".concat(e,"_").concat(t.classId,"_").concat(t.instanceId,"_user")]=a}return i.user.subscribe(o)}},public:{queue:i.public,subscribe:function(n){if(!s.listeners["".concat(e,"_").concat(t.classId,"_").concat(t.instanceId,"_public")]){var o=s.getFirebaseListener(i.public,"/projects/".concat(e,"/classes/").concat(t.classId,"/instances"),t.instanceId);r.push(o),s.listeners["".concat(e,"_").concat(t.classId,"_").concat(t.instanceId,"_public")]=o}return i.public.subscribe(n)}}},unsubscribers:r}]}}))}))},t.prototype.clearCloudObjects=function(){return o(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return(t=Object.values(this.listeners)).length>0&&(t.map((function(t){return t()})),this.cloudObjects.map((function(t){var e,n,r,i,s,o;null===(n=null===(e=t.state)||void 0===e?void 0:e.role.queue)||void 0===n||n.complete(),null===(i=null===(r=t.state)||void 0===r?void 0:r.user.queue)||void 0===i||i.complete(),null===(o=null===(s=t.state)||void 0===s?void 0:s.public.queue)||void 0===o||o.complete()}))),this.listeners={},this.cloudObjects.map((function(t){return t.unsubscribers.map((function(t){return t()}))})),this.cloudObjects=[],this.firebaseAuth?[4,(0,d.signOut)(this.firebaseAuth)]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.clearFirebase(),[2]}}))}))},t.prototype.authenticateWithCustomToken=function(t){return o(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return[4,this.sendToAuthQueue({action:y.RetterActions.SIGN_IN,data:t})];case 1:return[2,e.sent()]}}))}))},t.prototype.signOut=function(){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return[4,this.clearCloudObjects()];case 1:return t.sent(),[4,this.auth.signOut()];case 2:return t.sent(),[4,this.auth.clearTokenData()];case 3:return t.sent(),this.fireAuthStatus({}),[2]}}))}))},t.prototype.getCurrentUser=function(){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.auth.getCurrentUser()];case 1:return[2,t.sent()]}}))}))},t.prototype.getCloudObject=function(t){var e,n,i,s;return o(this,void 0,void 0,(function(){var u,c,h,l,d,f,p,m,g,v,b=this;return a(this,(function(w){switch(w.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return t.instanceId&&t.useLocal?[4,this.sendToActionQueue({action:y.RetterActions.EMPTY})]:[3,2];case 1:return w.sent(),[3,4];case 2:return[4,this.sendToActionQueue({action:y.RetterActions.COS_INSTANCE,data:t})];case 3:c=w.sent().data,u=c,t.instanceId=u.instanceId,w.label=4;case 4:return(h=this.cloudObjects.find((function(e){return e.config.classId===t.classId&&e.config.instanceId===t.instanceId})))?[2,{call:h.call,state:h.state,listInstances:h.listInstances,getState:h.getState,methods:null!==(e=null==u?void 0:u.methods)&&void 0!==e?e:[],instanceId:t.instanceId,response:h.response,isNewInstance:!1}]:[4,this.getFirebaseState(t)];case 5:return l=w.sent(),d=l.state,f=l.unsubscribers,p=function(e){return o(b,void 0,void 0,(function(){var n;return a(this,(function(i){switch(i.label){case 0:e.retryConfig=r(r({},this.clientConfig.retryConfig),e.retryConfig),i.label=1;case 1:return i.trys.push([1,3,,8]),[4,this.sendToActionQueue({action:y.RetterActions.COS_CALL,data:r(r({},e),{classId:t.classId,instanceId:t.instanceId})})];case 2:return[2,i.sent()];case 3:return n=i.sent(),--e.retryConfig.count,e.retryConfig.delay*=e.retryConfig.rate,n.response&&570===n.response.status&&e.retryConfig.count>0?[4,new Promise((function(t){return setTimeout(t,e.retryConfig.delay)}))]:[3,6];case 4:return i.sent(),[4,p(e)];case 5:return[2,i.sent()];case 6:throw n;case 7:return[3,8];case 8:return[2]}}))}))},m=function(e){return o(b,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.sendToActionQueue({action:y.RetterActions.COS_STATE,data:r(r({},e),{classId:t.classId,instanceId:t.instanceId})})];case 1:return[2,n.sent()]}}))}))},g=function(e){return o(b,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.sendToActionQueue({action:y.RetterActions.COS_LIST,data:r(r({},e),{classId:t.classId})})];case 1:return[2,n.sent().data.instanceIds]}}))}))},v={call:p,state:d,getState:m,listInstances:g,methods:null!==(n=null==u?void 0:u.methods)&&void 0!==n?n:[],response:null!==(i=null==u?void 0:u.response)&&void 0!==i?i:null,instanceId:t.instanceId,isNewInstance:null!==(s=null==u?void 0:u.newInstance)&&void 0!==s&&s},this.cloudObjects.push(r(r({},v),{config:t,unsubscribers:f})),[2,v]}}))}))},t.prototype.makeStaticCall=function(t){return o(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(!this.initialized)throw new Error("Retter SDK not initialized.");return[4,this.sendToActionQueue({action:y.RetterActions.COS_STATIC_CALL,data:r(r({},t),{classId:t.classId})})];case 1:return[2,e.sent()]}}))}))},Object.defineProperty(t.prototype,"authStatus",{get:function(){return this.authStatusSubject.asObservable().pipe((0,p.distinctUntilChanged)((function(t,e){return t.authStatus===e.authStatus&&t.identity===e.identity&&t.uid===e.uid})))},enumerable:!1,configurable:!0}),t.instances=[],t}();e.default=v},9699:(t,e)=>{"use strict";var n,r,i,s;Object.defineProperty(e,"__esModule",{value:!0}),e.Runtime=e.RetterAuthStatus=e.RetterActions=e.RetterRegion=void 0,(s=e.RetterRegion||(e.RetterRegion={}))[s.euWest1=0]="euWest1",s[s.euWest1Beta=1]="euWest1Beta",(i=e.RetterActions||(e.RetterActions={})).EMPTY="EMPTY",i.SIGN_IN="SIGN_IN",i.COS_CALL="COS_CALL",i.COS_LIST="COS_LIST",i.COS_STATE="COS_STATE",i.COS_INSTANCE="COS_INSTANCE",i.COS_STATIC_CALL="COS_STATIC_CALL",(r=e.RetterAuthStatus||(e.RetterAuthStatus={})).SIGNED_IN="SIGNED_IN",r.SIGNED_OUT="SIGNED_OUT",r.AUTH_FAILED="AUTH_FAILED",(n=e.Runtime||(e.Runtime={})).web="web",n.node="node"},389:(t,e,n)=>{"use strict";n.d(e,{ZR:()=>s.ZR,Jn:()=>F,l4:()=>A,H9:()=>C,Vr:()=>D,Af:()=>N,Z8:()=>L,lz:()=>k,qX:()=>R,Xd:()=>O,wN:()=>P,P2:()=>q,Mq:()=>j,C6:()=>B,ZF:()=>U,TP:()=>K,KN:()=>z,Ub:()=>G});var r=n(8463),i=n(3333),s=n(4444);let o,a;const u=new WeakMap,c=new WeakMap,h=new WeakMap,l=new WeakMap,d=new WeakMap;let f={get(t,e,n){if(t instanceof IDBTransaction){if("done"===e)return c.get(t);if("objectStoreNames"===e)return t.objectStoreNames||h.get(t);if("store"===e)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return m(t[e])},set:(t,e,n)=>(t[e]=n,!0),has:(t,e)=>t instanceof IDBTransaction&&("done"===e||"store"===e)||e in t};function p(t){return"function"==typeof t?(e=t)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(a||(a=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(g(this),t),m(u.get(this))}:function(...t){return m(e.apply(g(this),t))}:function(t,...n){const r=e.call(g(this),t,...n);return h.set(r,t.sort?t.sort():[t]),m(r)}:(t instanceof IDBTransaction&&function(t){if(c.has(t))return;const e=new Promise(((e,n)=>{const r=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",s),t.removeEventListener("abort",s)},i=()=>{e(),r()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),r()};t.addEventListener("complete",i),t.addEventListener("error",s),t.addEventListener("abort",s)}));c.set(t,e)}(t),n=t,(o||(o=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some((t=>n instanceof t))?new Proxy(t,f):t);var e,n}function m(t){if(t instanceof IDBRequest)return function(t){const e=new Promise(((e,n)=>{const r=()=>{t.removeEventListener("success",i),t.removeEventListener("error",s)},i=()=>{e(m(t.result)),r()},s=()=>{n(t.error),r()};t.addEventListener("success",i),t.addEventListener("error",s)}));return e.then((e=>{e instanceof IDBCursor&&u.set(e,t)})).catch((()=>{})),d.set(e,t),e}(t);if(l.has(t))return l.get(t);const e=p(t);return e!==t&&(l.set(t,e),d.set(e,t)),e}const g=t=>d.get(t),y=["get","getKey","getAll","getAllKeys","count"],v=["put","add","delete","clear"],b=new Map;function w(t,e){if(!(t instanceof IDBDatabase)||e in t||"string"!=typeof e)return;if(b.get(e))return b.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,i=v.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!y.includes(n))return;const s=async function(t,...e){const s=this.transaction(t,i?"readwrite":"readonly");let o=s.store;return r&&(o=o.index(e.shift())),(await Promise.all([o[n](...e),i&&s.done]))[0]};return b.set(e,s),s}var I;I=f,f={...I,get:(t,e,n)=>w(t,e)||I.get(t,e,n),has:(t,e)=>!!w(t,e)||I.has(t,e)};class _{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map((t=>{if(function(t){const e=t.getComponent();return"VERSION"===(null==e?void 0:e.type)}(t)){const e=t.getImmediate();return`${e.library}/${e.version}`}return null})).filter((t=>t)).join(" ")}}const T="@firebase/app",E="0.7.25",S=new i.Yd("@firebase/app"),A="[DEFAULT]",x={[T]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","fire-js":"fire-js",firebase:"fire-js-all"},N=new Map,k=new Map;function C(t,e){try{t.container.addComponent(e)}catch(n){S.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function D(t,e){t.container.addOrOverwriteComponent(e)}function O(t){const e=t.name;if(k.has(e))return S.debug(`There were multiple attempts to register component ${e}.`),!1;k.set(e,t);for(const e of N.values())C(e,t);return!0}function R(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function P(t,e,n=A){R(t,e).clearInstance(n)}function L(){k.clear()}const M=new s.LL("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$appName}","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}."});class V{constructor(t,e,n){this._isDeleted=!1,this._options=Object.assign({},t),this._config=Object.assign({},e),this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new r.wA("app",(()=>this),"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw M.create("app-deleted",{appName:this._name})}}const F="9.8.2";function U(t,e={}){"object"!=typeof e&&(e={name:e});const n=Object.assign({name:A,automaticDataCollectionEnabled:!1},e),i=n.name;if("string"!=typeof i||!i)throw M.create("bad-app-name",{appName:String(i)});const o=N.get(i);if(o){if((0,s.vZ)(t,o.options)&&(0,s.vZ)(n,o.config))return o;throw M.create("duplicate-app",{appName:i})}const a=new r.H0(i);for(const t of k.values())a.addComponent(t);const u=new V(t,n,a);return N.set(i,u),u}function j(t=A){const e=N.get(t);if(!e)throw M.create("no-app",{appName:t});return e}function B(){return Array.from(N.values())}async function q(t){const e=t.name;N.has(e)&&(N.delete(e),await Promise.all(t.container.getProviders().map((t=>t.delete()))),t.isDeleted=!0)}function z(t,e,n){var i;let s=null!==(i=x[t])&&void 0!==i?i:t;n&&(s+=`-${n}`);const o=s.match(/\s|\//),a=e.match(/\s|\//);if(o||a){const t=[`Unable to register library "${s}" with version "${e}":`];return o&&t.push(`library name "${s}" contains illegal characters (whitespace or "/")`),o&&a&&t.push("and"),a&&t.push(`version name "${e}" contains illegal characters (whitespace or "/")`),void S.warn(t.join(" "))}O(new r.wA(`${s}-version`,(()=>({library:s,version:e})),"VERSION"))}function K(t,e){if(null!==t&&"function"!=typeof t)throw M.create("invalid-log-argument");(0,i.Am)(t,e)}function G(t){(0,i.Ub)(t)}const W="firebase-heartbeat-store";let $=null;function H(){return $||($=function(t,e,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(t,e),a=m(o);return r&&o.addEventListener("upgradeneeded",(t=>{r(m(o.result),t.oldVersion,t.newVersion,m(o.transaction))})),n&&o.addEventListener("blocked",(()=>n())),a.then((t=>{s&&t.addEventListener("close",(()=>s())),i&&t.addEventListener("versionchange",(()=>i()))})).catch((()=>{})),a}("firebase-heartbeat-database",1,{upgrade:(t,e)=>{0===e&&t.createObjectStore(W)}}).catch((t=>{throw M.create("storage-open",{originalErrorMessage:t.message})}))),$}async function Y(t,e){try{const n=(await H()).transaction(W,"readwrite"),r=n.objectStore(W);return await r.put(e,Q(t)),n.done}catch(t){throw M.create("storage-set",{originalErrorMessage:t.message})}}function Q(t){return`${t.name}!${t.options.appId}`}class Z{constructor(t){this.container=t,this._heartbeatsCache=null;const e=this.container.getProvider("app").getImmediate();this._storage=new X(e),this._heartbeatsCachePromise=this._storage.read().then((t=>(this._heartbeatsCache=t,t)))}async triggerHeartbeat(){const t=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),e=J();if(null===this._heartbeatsCache&&(this._heartbeatsCache=await this._heartbeatsCachePromise),this._heartbeatsCache.lastSentHeartbeatDate!==e&&!this._heartbeatsCache.heartbeats.some((t=>t.date===e)))return this._heartbeatsCache.heartbeats.push({date:e,agent:t}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter((t=>{const e=new Date(t.date).valueOf();return Date.now()-e<=2592e6})),this._storage.overwrite(this._heartbeatsCache)}async getHeartbeatsHeader(){if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null===this._heartbeatsCache||0===this._heartbeatsCache.heartbeats.length)return"";const t=J(),{heartbeatsToSend:e,unsentEntries:n}=function(t,e=1024){const n=[];let r=t.slice();for(const i of t){const t=n.find((t=>t.agent===i.agent));if(t){if(t.dates.push(i.date),tt(n)>e){t.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),tt(n)>e){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}(this._heartbeatsCache.heartbeats),r=(0,s.L)(JSON.stringify({version:2,heartbeats:e}));return this._heartbeatsCache.lastSentHeartbeatDate=t,n.length>0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}}function J(){return(new Date).toISOString().substring(0,10)}class X{constructor(t){this.app=t,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!(0,s.hl)()&&(0,s.eu)().then((()=>!0)).catch((()=>!1))}async read(){return await this._canUseIndexedDBPromise&&await async function(t){try{return(await H()).transaction(W).objectStore(W).get(Q(t))}catch(t){throw M.create("storage-get",{originalErrorMessage:t.message})}}(this.app)||{heartbeats:[]}}async overwrite(t){var e;if(await this._canUseIndexedDBPromise){const n=await this.read();return Y(this.app,{lastSentHeartbeatDate:null!==(e=t.lastSentHeartbeatDate)&&void 0!==e?e:n.lastSentHeartbeatDate,heartbeats:t.heartbeats})}}async add(t){var e;if(await this._canUseIndexedDBPromise){const n=await this.read();return Y(this.app,{lastSentHeartbeatDate:null!==(e=t.lastSentHeartbeatDate)&&void 0!==e?e:n.lastSentHeartbeatDate,heartbeats:[...n.heartbeats,...t.heartbeats]})}}}function tt(t){return(0,s.L)(JSON.stringify({version:2,heartbeats:t})).length}O(new r.wA("platform-logger",(t=>new _(t)),"PRIVATE")),O(new r.wA("heartbeat",(t=>new Z(t)),"PRIVATE")),z(T,E,""),z(T,E,"esm2017"),z("fire-js","")},8463:(t,e,n)=>{"use strict";n.d(e,{H0:()=>a,wA:()=>i});var r=n(4444);class i{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}const s="[DEFAULT]";class o{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){const t=new r.BH;if(this.instancesDeferred.set(e,t),this.isInitialized(e)||this.shouldAutoInitialize())try{const n=this.getOrInitializeService({instanceIdentifier:e});n&&t.resolve(n)}catch(t){}}return this.instancesDeferred.get(e).promise}getImmediate(t){var e;const n=this.normalizeInstanceIdentifier(null==t?void 0:t.identifier),r=null!==(e=null==t?void 0:t.optional)&&void 0!==e&&e;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(r)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(t){if(r)return null;throw t}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,this.shouldAutoInitialize()){if(function(t){return"EAGER"===t.instantiationMode}(t))try{this.getOrInitializeService({instanceIdentifier:s})}catch(t){}for(const[t,e]of this.instancesDeferred.entries()){const n=this.normalizeInstanceIdentifier(t);try{const t=this.getOrInitializeService({instanceIdentifier:n});e.resolve(t)}catch(t){}}}}clearInstance(t="[DEFAULT]"){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter((t=>"INTERNAL"in t)).map((t=>t.INTERNAL.delete())),...t.filter((t=>"_delete"in t)).map((t=>t._delete()))])}isComponentSet(){return null!=this.component}isInitialized(t="[DEFAULT]"){return this.instances.has(t)}getOptions(t="[DEFAULT]"){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,n=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:n,options:e});for(const[t,e]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(t)&&e.resolve(r);return r}onInit(t,e){var n;const r=this.normalizeInstanceIdentifier(e),i=null!==(n=this.onInitCallbacks.get(r))&&void 0!==n?n:new Set;i.add(t),this.onInitCallbacks.set(r,i);const s=this.instances.get(r);return s&&t(s,r),()=>{i.delete(t)}}invokeOnInitCallbacks(t,e){const n=this.onInitCallbacks.get(e);if(n)for(const r of n)try{r(t,e)}catch(t){}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let n=this.instances.get(t);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(r=t,r===s?void 0:r),options:e}),this.instances.set(t,n),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(n,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,n)}catch(t){}var r;return n||null}normalizeInstanceIdentifier(t="[DEFAULT]"){return this.component?this.component.multipleInstances?t:s:t}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class a{constructor(t){this.name=t,this.providers=new Map}addComponent(t){const e=this.getProvider(t.name);if(e.isComponentSet())throw new Error(`Component ${t.name} has already been registered with ${this.name}`);e.setComponent(t)}addOrOverwriteComponent(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const e=new o(t,this);return this.providers.set(t,e),e}getProviders(){return Array.from(this.providers.values())}}},3333:(t,e,n)=>{"use strict";n.d(e,{Am:()=>l,Ub:()=>h,Yd:()=>c,in:()=>i});const r=[];var i;!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"}(i||(i={}));const s={debug:i.DEBUG,verbose:i.VERBOSE,info:i.INFO,warn:i.WARN,error:i.ERROR,silent:i.SILENT},o=i.INFO,a={[i.DEBUG]:"log",[i.VERBOSE]:"log",[i.INFO]:"info",[i.WARN]:"warn",[i.ERROR]:"error"},u=(t,e,...n)=>{if(e<t.logLevel)return;const r=(new Date).toISOString(),i=a[e];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[i](`[${r}] ${t.name}:`,...n)};class c{constructor(t){this.name=t,this._logLevel=o,this._logHandler=u,this._userLogHandler=null,r.push(this)}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in i))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel="string"==typeof t?s[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,i.DEBUG,...t),this._logHandler(this,i.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,i.VERBOSE,...t),this._logHandler(this,i.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,i.INFO,...t),this._logHandler(this,i.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,i.WARN,...t),this._logHandler(this,i.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,i.ERROR,...t),this._logHandler(this,i.ERROR,...t)}}function h(t){r.forEach((e=>{e.setLogLevel(t)}))}function l(t,e){for(const n of r){let r=null;e&&e.level&&(r=s[e.level]),n.userLogHandler=null===t?null:(e,n,...s)=>{const o=s.map((t=>{if(null==t)return null;if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t)return t.toString();if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch(t){return null}})).filter((t=>t)).join(" ");n>=(null!=r?r:e.logLevel)&&t({level:i[n].toLowerCase(),message:o,args:s,type:e.name})}}}}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r].call(s.exports,s,s.exports,n),s.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r=n(3607);return r.default})()));
|