/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const t=function(t){const e=[];let s=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);if(i<128){e[s++]=i}else if(i<2048){e[s++]=i>>6|192;e[s++]=i&63|128}else if((i&64512)===55296&&r+1<t.length&&(t.charCodeAt(r+1)&64512)===56320){i=65536+((i&1023)<<10)+(t.charCodeAt(++r)&1023);e[s++]=i>>18|240;e[s++]=i>>12&63|128;e[s++]=i>>6&63|128;e[s++]=i&63|128}else{e[s++]=i>>12|224;e[s++]=i>>6&63|128;e[s++]=i&63|128}}return e};const e=function(t){const e=[];let s=0,r=0;while(s<t.length){const i=t[s++];if(i<128){e[r++]=String.fromCharCode(i)}else if(i>191&&i<224){const n=t[s++];e[r++]=String.fromCharCode((i&31)<<6|n&63)}else if(i>239&&i<365){const n=t[s++];const o=t[s++];const a=t[s++];const c=((i&7)<<18|(n&63)<<12|(o&63)<<6|a&63)-65536;e[r++]=String.fromCharCode(55296+(c>>10));e[r++]=String.fromCharCode(56320+(c&1023))}else{const n=t[s++];const o=t[s++];e[r++]=String.fromCharCode((i&15)<<12|(n&63)<<6|o&63)}}return e.join("")};const s={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz"+"0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob==="function",encodeByteArray(t,e){if(!Array.isArray(t)){throw Error("encodeByteArray takes an array as a parameter")}this.init_();const s=e?this.byteToCharMapWebSafe_:this.byteToCharMap_;const r=[];for(let e=0;e<t.length;e+=3){const i=t[e];const n=e+1<t.length;const o=n?t[e+1]:0;const a=e+2<t.length;const c=a?t[e+2]:0;const h=i>>2;const l=(i&3)<<4|o>>4;let f=(o&15)<<2|c>>6;let u=c&63;if(!a){u=64;if(!n){f=64}}r.push(s[h],s[l],s[f],s[u])}return r.join("")},encodeString(e,s){if(this.HAS_NATIVE_SUPPORT&&!s){return btoa(e)}return this.encodeByteArray(t(e),s)},decodeString(t,s){if(this.HAS_NATIVE_SUPPORT&&!s){return atob(t)}return e(this.decodeStringToByteArray(t,s))},decodeStringToByteArray(t,e){this.init_();const s=e?this.charToByteMapWebSafe_:this.charToByteMap_;const r=[];for(let e=0;e<t.length;){const i=s[t.charAt(e++)];const n=e<t.length;const o=n?s[t.charAt(e)]:0;++e;const a=e<t.length;const c=a?s[t.charAt(e)]:64;++e;const h=e<t.length;const l=h?s[t.charAt(e)]:64;++e;if(i==null||o==null||c==null||l==null){throw Error()}const f=i<<2|o>>4;r.push(f);if(c!==64){const t=o<<4&240|c>>2;r.push(t);if(l!==64){const t=c<<6&192|l;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;if(t>=this.ENCODED_VALS_BASE.length){this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t;this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t}}}}};const r=function(e){const r=t(e);return s.encodeByteArray(r,true)};const i=function(t){return r(t).replace(/\./g,"")};
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class n{constructor(){this.reject=()=>{};this.resolve=()=>{};this.promise=new Promise(((t,e)=>{this.resolve=t;this.reject=e}))}wrapCallback(t){return(e,s)=>{if(e){this.reject(e)}else{this.resolve(s)}if(typeof t==="function"){this.promise.catch((()=>{}));if(t.length===1){t(e)}else{t(e,s)}}}}}function o(){return typeof indexedDB==="object"}function a(){return new Promise(((t,e)=>{try{let s=true;const r="validate-browser-context-for-indexeddb-analytics-module";const i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close();if(!s){self.indexedDB.deleteDatabase(r)}t(true)};i.onupgradeneeded=()=>{s=false};i.onerror=()=>{var t;e(((t=i.error)===null||t===void 0?void 0:t.message)||"")}}catch(t){e(t)}}))}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const c="FirebaseError";class h extends Error{constructor(t,e,s){super(e);this.code=t;this.customData=s;this.name=c;Object.setPrototypeOf(this,h.prototype);if(Error.captureStackTrace){Error.captureStackTrace(this,l.prototype.create)}}}class l{constructor(t,e,s){this.service=t;this.serviceName=e;this.errors=s}create(t,...e){const s=e[0]||{};const r=`${this.service}/${t}`;const i=this.errors[t];const n=i?f(i,s):"Error";const o=`${this.serviceName}: ${n} (${r}).`;const a=new h(r,o,s);return a}}function f(t,e){return t.replace(u,((t,s)=>{const r=e[s];return r!=null?String(r):`<${s}?>`}))}const u=/\{\$([^}]+)}/g;function p(t,e){if(t===e){return true}const s=Object.keys(t);const r=Object.keys(e);for(const i of s){if(!r.includes(i)){return false}const s=t[i];const n=e[i];if(d(s)&&d(n)){if(!p(s,n)){return false}}else if(s!==n){return false}}for(const t of r){if(!s.includes(t)){return false}}return true}function d(t){return t!==null&&typeof t==="object"}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function g(t){if(t&&t._delegate){return t._delegate}else{return t}}
/**
 * @license
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function b(t,e){return new Promise(((s,r)=>{t.onsuccess=t=>{s(t.target.result)};t.onerror=t=>{var s;r(`${e}: ${(s=t.target.error)===null||s===void 0?void 0:s.message}`)}}))}class w{constructor(t){this._db=t;this.objectStoreNames=this._db.objectStoreNames}transaction(t,e="readonly"){return new m(this._db.transaction.call(this._db,t,e))}createObjectStore(t,e){return new E(this._db.createObjectStore(t,e))}close(){this._db.close()}}class m{constructor(t){this._transaction=t;this.complete=new Promise(((t,e)=>{this._transaction.oncomplete=function(){t()};this._transaction.onerror=()=>{e(this._transaction.error)};this._transaction.onabort=()=>{e(this._transaction.error)}}))}objectStore(t){return new E(this._transaction.objectStore(t))}}class E{constructor(t){this._store=t}index(t){return new y(this._store.index(t))}createIndex(t,e,s){return new y(this._store.createIndex(t,e,s))}get(t){const e=this._store.get(t);return b(e,"Error reading from IndexedDB")}put(t,e){const s=this._store.put(t,e);return b(s,"Error writing to IndexedDB")}delete(t){const e=this._store.delete(t);return b(e,"Error deleting from IndexedDB")}clear(){const t=this._store.clear();return b(t,"Error clearing IndexedDB object store")}}class y{constructor(t){this._index=t}get(t){const e=this._index.get(t);return b(e,"Error reading from IndexedDB")}}function v(t,e,s){return new Promise(((r,i)=>{try{const n=indexedDB.open(t,e);n.onsuccess=t=>{r(new w(t.target.result))};n.onerror=t=>{var e;i(`Error opening indexedDB: ${(e=t.target.error)===null||e===void 0?void 0:e.message}`)};n.onupgradeneeded=t=>{s(new w(n.result),t.oldVersion,t.newVersion,new m(n.transaction))}}catch(t){i(`Error opening indexedDB: ${t.message}`)}}))}class ${constructor(t,e,s){this.name=t;this.instanceFactory=e;this.type=s;this.multipleInstances=false;this.serviceProps={};this.instantiationMode="LAZY";this.onInstanceCreated=null}setInstantiationMode(t){this.instantiationMode=t;return this}setMultipleInstances(t){this.multipleInstances=t;return this}setServiceProps(t){this.serviceProps=t;return this}setInstanceCreatedCallback(t){this.onInstanceCreated=t;return this}}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const I="[DEFAULT]";
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class S{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 n;this.instancesDeferred.set(e,t);if(this.isInitialized(e)||this.shouldAutoInitialize()){try{const s=this.getOrInitializeService({instanceIdentifier:e});if(s){t.resolve(s)}}catch(t){}}}return this.instancesDeferred.get(e).promise}getImmediate(t){var e;const s=this.normalizeInstanceIdentifier(t===null||t===void 0?void 0:t.identifier);const r=(e=t===null||t===void 0?void 0:t.optional)!==null&&e!==void 0?e:false;if(this.isInitialized(s)||this.shouldAutoInitialize()){try{return this.getOrInitializeService({instanceIdentifier:s})}catch(t){if(r){return null}else{throw t}}}else{if(r){return null}else{throw Error(`Service ${this.name} is not available`)}}}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`)}this.component=t;if(!this.shouldAutoInitialize()){return}if(D(t)){try{this.getOrInitializeService({instanceIdentifier:I})}catch(t){}}for(const[t,e]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const t=this.getOrInitializeService({instanceIdentifier:s});e.resolve(t)}catch(t){}}}clearInstance(t=I){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 this.component!=null}isInitialized(t=I){return this.instances.has(t)}getOptions(t=I){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t;const s=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(s)){throw Error(`${this.name}(${s}) has already been initialized`)}if(!this.isComponentSet()){throw Error(`Component ${this.name} has not been registered yet`)}const r=this.getOrInitializeService({instanceIdentifier:s,options:e});for(const[t,e]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(t);if(s===i){e.resolve(r)}}return r}onInit(t,e){var s;const r=this.normalizeInstanceIdentifier(e);const i=(s=this.onInitCallbacks.get(r))!==null&&s!==void 0?s:new Set;i.add(t);this.onInitCallbacks.set(r,i);const n=this.instances.get(r);if(n){t(n,r)}return()=>{i.delete(t)}}invokeOnInitCallbacks(t,e){const s=this.onInitCallbacks.get(e);if(!s){return}for(const r of s){try{r(t,e)}catch(t){}}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let s=this.instances.get(t);if(!s&&this.component){s=this.component.instanceFactory(this.container,{instanceIdentifier:A(t),options:e});this.instances.set(t,s);this.instancesOptions.set(t,e);this.invokeOnInitCallbacks(s,t);if(this.component.onInstanceCreated){try{this.component.onInstanceCreated(this.container,t,s)}catch(t){}}}return s||null}normalizeInstanceIdentifier(t=I){if(this.component){return this.component.multipleInstances?t:I}else{return t}}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function A(t){return t===I?undefined:t}function D(t){return t.instantiationMode==="EAGER"}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class O{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){const e=this.getProvider(t.name);if(e.isComponentSet()){this.providers.delete(t.name)}this.addComponent(t)}getProvider(t){if(this.providers.has(t)){return this.providers.get(t)}const e=new S(t,this);this.providers.set(t,e);return e}getProviders(){return Array.from(this.providers.values())}}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var C;(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"})(C||(C={}));const N={debug:C.DEBUG,verbose:C.VERBOSE,info:C.INFO,warn:C.WARN,error:C.ERROR,silent:C.SILENT};const M=C.INFO;const B={[C.DEBUG]:"log",[C.VERBOSE]:"log",[C.INFO]:"info",[C.WARN]:"warn",[C.ERROR]:"error"};const T=(t,e,...s)=>{if(e<t.logLevel){return}const r=(new Date).toISOString();const i=B[e];if(i){console[i](`[${r}]  ${t.name}:`,...s)}else{throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)}};class L{constructor(t){this.name=t;this._logLevel=M;this._logHandler=T;this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in C)){throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``)}this._logLevel=t}setLogLevel(t){this._logLevel=typeof t==="string"?N[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if(typeof t!=="function"){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,C.DEBUG,...t);this._logHandler(this,C.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,C.VERBOSE,...t);this._logHandler(this,C.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,C.INFO,...t);this._logHandler(this,C.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,C.WARN,...t);this._logHandler(this,C.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,C.ERROR,...t);this._logHandler(this,C.ERROR,...t)}}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class x{constructor(t){this.container=t}getPlatformInfoString(){const t=this.container.getProviders();return t.map((t=>{if(P(t)){const e=t.getImmediate();return`${e.library}/${e.version}`}else{return null}})).filter((t=>t)).join(" ")}}function P(t){const e=t.getComponent();return(e===null||e===void 0?void 0:e.type)==="VERSION"}const j="@firebase/app";const k="0.7.22";
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const F=new L("@firebase/app");const _="@firebase/app-compat";const R="@firebase/analytics-compat";const H="@firebase/analytics";const V="@firebase/app-check-compat";const z="@firebase/app-check";const U="@firebase/auth";const W="@firebase/auth-compat";const G="@firebase/database";const J="@firebase/database-compat";const X="@firebase/functions";const Y="@firebase/functions-compat";const Z="@firebase/installations";const q="@firebase/installations-compat";const K="@firebase/messaging";const Q="@firebase/messaging-compat";const tt="@firebase/performance";const et="@firebase/performance-compat";const st="@firebase/remote-config";const rt="@firebase/remote-config-compat";const it="@firebase/storage";const nt="@firebase/storage-compat";const ot="@firebase/firestore";const at="@firebase/firestore-compat";const ct="firebase";const ht="9.7.0";
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const lt="[DEFAULT]";const ft={[j]:"fire-core",[_]:"fire-core-compat",[H]:"fire-analytics",[R]:"fire-analytics-compat",[z]:"fire-app-check",[V]:"fire-app-check-compat",[U]:"fire-auth",[W]:"fire-auth-compat",[G]:"fire-rtdb",[J]:"fire-rtdb-compat",[X]:"fire-fn",[Y]:"fire-fn-compat",[Z]:"fire-iid",[q]:"fire-iid-compat",[K]:"fire-fcm",[Q]:"fire-fcm-compat",[tt]:"fire-perf",[et]:"fire-perf-compat",[st]:"fire-rc",[rt]:"fire-rc-compat",[it]:"fire-gcs",[nt]:"fire-gcs-compat",[ot]:"fire-fst",[at]:"fire-fst-compat","fire-js":"fire-js",[ct]:"fire-js-all"};
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const ut=new Map;const pt=new Map;function dt(t,e){try{t.container.addComponent(e)}catch(s){F.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,s)}}function gt(t){const e=t.name;if(pt.has(e)){F.debug(`There were multiple attempts to register component ${e}.`);return false}pt.set(e,t);for(const e of ut.values()){dt(e,t)}return true}function bt(t,e){const s=t.container.getProvider("heartbeat").getImmediate({optional:true});if(s){void s.triggerHeartbeat()}return t.container.getProvider(e)}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const wt={["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}."};const mt=new l("app","Firebase",wt);
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class Et{constructor(t,e,s){this._isDeleted=false;this._options=Object.assign({},t);this._config=Object.assign({},e);this._name=e.name;this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled;this._container=s;this.container.addComponent(new $("app",(()=>this),"PUBLIC"))}get automaticDataCollectionEnabled(){this.checkDestroyed();return this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed();this._automaticDataCollectionEnabled=t}get name(){this.checkDestroyed();return this._name}get options(){this.checkDestroyed();return this._options}get config(){this.checkDestroyed();return this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted){throw mt.create("app-deleted",{appName:this._name})}}}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const yt=ht;function vt(t,e={}){if(typeof e!=="object"){const t=e;e={name:t}}const s=Object.assign({name:lt,automaticDataCollectionEnabled:false},e);const r=s.name;if(typeof r!=="string"||!r){throw mt.create("bad-app-name",{appName:String(r)})}const i=ut.get(r);if(i){if(p(t,i.options)&&p(s,i.config)){return i}else{throw mt.create("duplicate-app",{appName:r})}}const n=new O(r);for(const t of pt.values()){n.addComponent(t)}const o=new Et(t,s,n);ut.set(r,o);return o}function $t(t=lt){const e=ut.get(t);if(!e){throw mt.create("no-app",{appName:t})}return e}function It(t,e,s){var r;let i=(r=ft[t])!==null&&r!==void 0?r:t;if(s){i+=`-${s}`}const n=i.match(/\s|\//);const o=e.match(/\s|\//);if(n||o){const t=[`Unable to register library "${i}" with version "${e}":`];if(n){t.push(`library name "${i}" contains illegal characters (whitespace or "/")`)}if(n&&o){t.push("and")}if(o){t.push(`version name "${e}" contains illegal characters (whitespace or "/")`)}F.warn(t.join(" "));return}gt(new $(`${i}-version`,(()=>({library:i,version:e})),"VERSION"))}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const St="firebase-heartbeat-database";const At=1;const Dt="firebase-heartbeat-store";let Ot=null;function Ct(){if(!Ot){Ot=v(St,At,((t,e)=>{switch(e){case 0:t.createObjectStore(Dt)}})).catch((t=>{throw mt.create("storage-open",{originalErrorMessage:t.message})}))}return Ot}async function Nt(t){try{const e=await Ct();return e.transaction(Dt).objectStore(Dt).get(Bt(t))}catch(t){throw mt.create("storage-get",{originalErrorMessage:t.message})}}async function Mt(t,e){try{const s=await Ct();const r=s.transaction(Dt,"readwrite");const i=r.objectStore(Dt);await i.put(e,Bt(t));return r.complete}catch(t){throw mt.create("storage-set",{originalErrorMessage:t.message})}}function Bt(t){return`${t.name}!${t.options.appId}`}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const Tt=1024;const Lt=30*24*60*60*1e3;class xt{constructor(t){this.container=t;this._heartbeatsCache=null;const e=this.container.getProvider("app").getImmediate();this._storage=new kt(e);this._heartbeatsCachePromise=this._storage.read().then((t=>{this._heartbeatsCache=t;return t}))}async triggerHeartbeat(){const t=this.container.getProvider("platform-logger").getImmediate();const e=t.getPlatformInfoString();const s=Pt();if(this._heartbeatsCache===null){this._heartbeatsCache=await this._heartbeatsCachePromise}if(this._heartbeatsCache.lastSentHeartbeatDate===s||this._heartbeatsCache.heartbeats.some((t=>t.date===s))){return}else{this._heartbeatsCache.heartbeats.push({date:s,agent:e})}this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter((t=>{const e=new Date(t.date).valueOf();const s=Date.now();return s-e<=Lt}));return this._storage.overwrite(this._heartbeatsCache)}async getHeartbeatsHeader(){if(this._heartbeatsCache===null){await this._heartbeatsCachePromise}if(this._heartbeatsCache===null||this._heartbeatsCache.heartbeats.length===0){return""}const t=Pt();const{heartbeatsToSend:e,unsentEntries:s}=jt(this._heartbeatsCache.heartbeats);const r=i(JSON.stringify({version:2,heartbeats:e}));this._heartbeatsCache.lastSentHeartbeatDate=t;if(s.length>0){this._heartbeatsCache.heartbeats=s;await this._storage.overwrite(this._heartbeatsCache)}else{this._heartbeatsCache.heartbeats=[];void this._storage.overwrite(this._heartbeatsCache)}return r}}function Pt(){const t=new Date;return t.toISOString().substring(0,10)}function jt(t,e=Tt){const s=[];let r=t.slice();for(const i of t){const t=s.find((t=>t.agent===i.agent));if(!t){s.push({agent:i.agent,dates:[i.date]});if(Ft(s)>e){s.pop();break}}else{t.dates.push(i.date);if(Ft(s)>e){t.dates.pop();break}}r=r.slice(1)}return{heartbeatsToSend:s,unsentEntries:r}}class kt{constructor(t){this.app=t;this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){if(!o()){return false}else{return a().then((()=>true)).catch((()=>false))}}async read(){const t=await this._canUseIndexedDBPromise;if(!t){return{heartbeats:[]}}else{const t=await Nt(this.app);return t||{heartbeats:[]}}}async overwrite(t){var e;const s=await this._canUseIndexedDBPromise;if(!s){return}else{const s=await this.read();return Mt(this.app,{lastSentHeartbeatDate:(e=t.lastSentHeartbeatDate)!==null&&e!==void 0?e:s.lastSentHeartbeatDate,heartbeats:t.heartbeats})}}async add(t){var e;const s=await this._canUseIndexedDBPromise;if(!s){return}else{const s=await this.read();return Mt(this.app,{lastSentHeartbeatDate:(e=t.lastSentHeartbeatDate)!==null&&e!==void 0?e:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...t.heartbeats]})}}}function Ft(t){return i(JSON.stringify({version:2,heartbeats:t})).length}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function _t(t){gt(new $("platform-logger",(t=>new x(t)),"PRIVATE"));gt(new $("heartbeat",(t=>new xt(t)),"PRIVATE"));It(j,k,t);It(j,k,"esm2017");It("fire-js","")}_t("");export{$ as C,h as F,yt as S,bt as _,g as a,gt as b,$t as g,vt as i,It as r};
//# sourceMappingURL=p-98d7792a.js.map