import{g as t}from"./p-2d180048.js";
/**
 * @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 e={NODE_CLIENT:false,NODE_ADMIN:false,SDK_VERSION:"${JSCORE_VERSION}"};
/**
 * @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 s=function(t,e){if(!t){throw n(e)}};const n=function(t){return new Error("Firebase Database ("+e.SDK_VERSION+") INTERNAL ASSERT FAILED: "+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 i=function(t){const e=[];let s=0;for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);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&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320){i=65536+((i&1023)<<10)+(t.charCodeAt(++n)&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 r=function(t){const e=[];let s=0,n=0;while(s<t.length){const i=t[s++];if(i<128){e[n++]=String.fromCharCode(i)}else if(i>191&&i<224){const r=t[s++];e[n++]=String.fromCharCode((i&31)<<6|r&63)}else if(i>239&&i<365){const r=t[s++];const o=t[s++];const a=t[s++];const c=((i&7)<<18|(r&63)<<12|(o&63)<<6|a&63)-65536;e[n++]=String.fromCharCode(55296+(c>>10));e[n++]=String.fromCharCode(56320+(c&1023))}else{const r=t[s++];const o=t[s++];e[n++]=String.fromCharCode((i&15)<<12|(r&63)<<6|o&63)}}return e.join("")};const o={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 n=[];for(let e=0;e<t.length;e+=3){const i=t[e];const r=e+1<t.length;const o=r?t[e+1]:0;const a=e+2<t.length;const c=a?t[e+2]:0;const h=i>>2;const f=(i&3)<<4|o>>4;let u=(o&15)<<2|c>>6;let l=c&63;if(!a){l=64;if(!r){u=64}}n.push(s[h],s[f],s[u],s[l])}return n.join("")},encodeString(t,e){if(this.HAS_NATIVE_SUPPORT&&!e){return btoa(t)}return this.encodeByteArray(i(t),e)},decodeString(t,e){if(this.HAS_NATIVE_SUPPORT&&!e){return atob(t)}return r(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const s=e?this.charToByteMapWebSafe_:this.charToByteMap_;const n=[];for(let e=0;e<t.length;){const i=s[t.charAt(e++)];const r=e<t.length;const o=r?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 f=h?s[t.charAt(e)]:64;++e;if(i==null||o==null||c==null||f==null){throw Error()}const u=i<<2|o>>4;n.push(u);if(c!==64){const t=o<<4&240|c>>2;n.push(t);if(f!==64){const t=c<<6&192|f;n.push(t)}}}return n},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 a=function(t){const e=i(t);return o.encodeByteArray(e,true)};const c=function(t){return a(t).replace(/\./g,"")};const h=function(t){try{return o.decodeString(t,true)}catch(t){console.error("base64Decode failed: ",t)}return null};
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function f(t){return u(undefined,t)}function u(t,e){if(!(e instanceof Object)){return e}switch(e.constructor){case Date:const s=e;return new Date(s.getTime());case Object:if(t===undefined){t={}}break;case Array:t=[];break;default:return e}for(const s in e){if(!e.hasOwnProperty(s)||!l(s)){continue}t[s]=u(t[s],e[s])}return t}function l(t){return t!=="__proto__"}
/**
 * @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 d{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)}}}}}
/**
 * @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 p(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 s={alg:"none",type:"JWT"};const n=e||"demo-project";const i=t.iat||0;const r=t.sub||t.user_id;if(!r){throw new Error("mockUserToken must contain 'sub' or 'user_id' field!")}const o=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:i,exp:i+3600,auth_time:i,sub:r,user_id:r,firebase:{sign_in_provider:"custom",identities:{}}},t);const a="";return[c(JSON.stringify(s)),c(JSON.stringify(o)),a].join(".")}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function g(){if(typeof navigator!=="undefined"&&typeof navigator["userAgent"]==="string"){return navigator["userAgent"]}else{return""}}function b(){return typeof window!=="undefined"&&!!(window["cordova"]||window["phonegap"]||window["PhoneGap"])&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(g())}function w(){try{return Object.prototype.toString.call(t.process)==="[object process]"}catch(t){return false}}function m(){const t=typeof chrome==="object"?chrome.runtime:typeof browser==="object"?browser.runtime:undefined;return typeof t==="object"&&t.id!==undefined}function y(){return typeof navigator==="object"&&navigator["product"]==="ReactNative"}function E(){return g().indexOf("Electron/")>=0}function v(){const t=g();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function I(){return g().indexOf("MSAppHost/")>=0}function S(){return e.NODE_ADMIN===true}function O(){return!w()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function $(){return typeof indexedDB==="object"}function D(){return new Promise(((t,e)=>{try{let s=true;const n="validate-browser-context-for-indexeddb-analytics-module";const i=self.indexedDB.open(n);i.onsuccess=()=>{i.result.close();if(!s){self.indexedDB.deleteDatabase(n)}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 A="FirebaseError";class N extends Error{constructor(t,e,s){super(e);this.code=t;this.customData=s;this.name=A;Object.setPrototypeOf(this,N.prototype);if(Error.captureStackTrace){Error.captureStackTrace(this,j.prototype.create)}}}class j{constructor(t,e,s){this.service=t;this.serviceName=e;this.errors=s}create(t,...e){const s=e[0]||{};const n=`${this.service}/${t}`;const i=this.errors[t];const r=i?C(i,s):"Error";const o=`${this.serviceName}: ${r} (${n}).`;const a=new N(n,o,s);return a}}function C(t,e){return t.replace(T,((t,s)=>{const n=e[s];return n!=null?String(n):`<${s}?>`}))}const T=/\{\$([^}]+)}/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.
 */function _(t){return JSON.parse(t)}function M(t){return JSON.stringify(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 k=function(t){let e={},s={},n={},i="";try{const r=t.split(".");e=_(h(r[0])||"");s=_(h(r[1])||"");i=r[2];n=s["d"]||{};delete s["d"]}catch(t){}return{header:e,claims:s,data:n,signature:i}};const R=function(t){const e=k(t),s=e.claims;return!!s&&typeof s==="object"&&s.hasOwnProperty("iat")};const x=function(t){const e=k(t).claims;return typeof e==="object"&&e["admin"]===true};
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function L(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function B(t,e){if(Object.prototype.hasOwnProperty.call(t,e)){return t[e]}else{return undefined}}function P(t){for(const e in t){if(Object.prototype.hasOwnProperty.call(t,e)){return false}}return true}function F(t,e,s){const n={};for(const i in t){if(Object.prototype.hasOwnProperty.call(t,i)){n[i]=e.call(s,t[i],i,t)}}return n}function U(t,e){if(t===e){return true}const s=Object.keys(t);const n=Object.keys(e);for(const i of s){if(!n.includes(i)){return false}const s=t[i];const r=e[i];if(H(s)&&H(r)){if(!U(s,r)){return false}}else if(s!==r){return false}}for(const t of n){if(!s.includes(t)){return false}}return true}function H(t){return t!==null&&typeof t==="object"}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function V(t){const e=[];for(const[s,n]of Object.entries(t)){if(Array.isArray(n)){n.forEach((t=>{e.push(encodeURIComponent(s)+"="+encodeURIComponent(t))}))}else{e.push(encodeURIComponent(s)+"="+encodeURIComponent(n))}}return e.length?"&"+e.join("&"):""}function J(t){const e={};const s=t.replace(/^\?/,"").split("&");s.forEach((t=>{if(t){const[s,n]=t.split("=");e[decodeURIComponent(s)]=decodeURIComponent(n)}}));return e}function z(t){const e=t.indexOf("?");if(!e){return""}const s=t.indexOf("#",e);return t.substring(e,s>0?s:undefined)}
/**
 * @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 W{constructor(){this.chain_=[];this.buf_=[];this.W_=[];this.pad_=[];this.inbuf_=0;this.total_=0;this.blockSize=512/8;this.pad_[0]=128;for(let t=1;t<this.blockSize;++t){this.pad_[t]=0}this.reset()}reset(){this.chain_[0]=1732584193;this.chain_[1]=4023233417;this.chain_[2]=2562383102;this.chain_[3]=271733878;this.chain_[4]=3285377520;this.inbuf_=0;this.total_=0}compress_(t,e){if(!e){e=0}const s=this.W_;if(typeof t==="string"){for(let n=0;n<16;n++){s[n]=t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|t.charCodeAt(e+3);e+=4}}else{for(let n=0;n<16;n++){s[n]=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3];e+=4}}for(let t=16;t<80;t++){const e=s[t-3]^s[t-8]^s[t-14]^s[t-16];s[t]=(e<<1|e>>>31)&4294967295}let n=this.chain_[0];let i=this.chain_[1];let r=this.chain_[2];let o=this.chain_[3];let a=this.chain_[4];let c,h;for(let t=0;t<80;t++){if(t<40){if(t<20){c=o^i&(r^o);h=1518500249}else{c=i^r^o;h=1859775393}}else{if(t<60){c=i&r|o&(i|r);h=2400959708}else{c=i^r^o;h=3395469782}}const e=(n<<5|n>>>27)+c+a+h+s[t]&4294967295;a=o;o=r;r=(i<<30|i>>>2)&4294967295;i=n;n=e}this.chain_[0]=this.chain_[0]+n&4294967295;this.chain_[1]=this.chain_[1]+i&4294967295;this.chain_[2]=this.chain_[2]+r&4294967295;this.chain_[3]=this.chain_[3]+o&4294967295;this.chain_[4]=this.chain_[4]+a&4294967295}update(t,e){if(t==null){return}if(e===undefined){e=t.length}const s=e-this.blockSize;let n=0;const i=this.buf_;let r=this.inbuf_;while(n<e){if(r===0){while(n<=s){this.compress_(t,n);n+=this.blockSize}}if(typeof t==="string"){while(n<e){i[r]=t.charCodeAt(n);++r;++n;if(r===this.blockSize){this.compress_(i);r=0;break}}}else{while(n<e){i[r]=t[n];++r;++n;if(r===this.blockSize){this.compress_(i);r=0;break}}}}this.inbuf_=r;this.total_+=e}digest(){const t=[];let e=this.total_*8;if(this.inbuf_<56){this.update(this.pad_,56-this.inbuf_)}else{this.update(this.pad_,this.blockSize-(this.inbuf_-56))}for(let t=this.blockSize-1;t>=56;t--){this.buf_[t]=e&255;e/=256}this.compress_(this.buf_);let s=0;for(let e=0;e<5;e++){for(let n=24;n>=0;n-=8){t[s]=this.chain_[e]>>n&255;++s}}return t}}function G(t,e){const s=new K(t,e);return s.subscribe.bind(s)}class K{constructor(t,e){this.observers=[];this.unsubscribes=[];this.observerCount=0;this.task=Promise.resolve();this.finalized=false;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,s){let n;if(t===undefined&&e===undefined&&s===undefined){throw new Error("Missing Observer.")}if(q(t,["next","error","complete"])){n=t}else{n={next:t,error:e,complete:s}}if(n.next===undefined){n.next=Q}if(n.error===undefined){n.error=Q}if(n.complete===undefined){n.complete=Q}const i=this.unsubscribeOne.bind(this,this.observers.length);if(this.finalized){this.task.then((()=>{try{if(this.finalError){n.error(this.finalError)}else{n.complete()}}catch(t){}return}))}this.observers.push(n);return i}unsubscribeOne(t){if(this.observers===undefined||this.observers[t]===undefined){return}delete this.observers[t];this.observerCount-=1;if(this.observerCount===0&&this.onNoObservers!==undefined){this.onNoObservers(this)}}forEachObserver(t){if(this.finalized){return}for(let e=0;e<this.observers.length;e++){this.sendOne(e,t)}}sendOne(t,e){this.task.then((()=>{if(this.observers!==undefined&&this.observers[t]!==undefined){try{e(this.observers[t])}catch(t){if(typeof console!=="undefined"&&console.error){console.error(t)}}}}))}close(t){if(this.finalized){return}this.finalized=true;if(t!==undefined){this.finalError=t}this.task.then((()=>{this.observers=undefined;this.onNoObservers=undefined}))}}function q(t,e){if(typeof t!=="object"||t===null){return false}for(const s of e){if(s in t&&typeof t[s]==="function"){return true}}return false}function Q(){}function X(t,e){return`${t} failed: ${e} argument `}
/**
 * @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 Y=function(t){const e=[];let n=0;for(let i=0;i<t.length;i++){let r=t.charCodeAt(i);if(r>=55296&&r<=56319){const e=r-55296;i++;s(i<t.length,"Surrogate pair missing trail surrogate.");const n=t.charCodeAt(i)-56320;r=65536+(e<<10)+n}if(r<128){e[n++]=r}else if(r<2048){e[n++]=r>>6|192;e[n++]=r&63|128}else if(r<65536){e[n++]=r>>12|224;e[n++]=r>>6&63|128;e[n++]=r&63|128}else{e[n++]=r>>18|240;e[n++]=r>>12&63|128;e[n++]=r>>6&63|128;e[n++]=r&63|128}}return e};const Z=function(t){let e=0;for(let s=0;s<t.length;s++){const n=t.charCodeAt(s);if(n<128){e++}else if(n<2048){e+=2}else if(n>=55296&&n<=56319){e+=4;s++}else{e+=3}}return e};
/**
 * @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 tt(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 et(t,e){return new Promise(((s,n)=>{t.onsuccess=t=>{s(t.target.result)};t.onerror=t=>{var s;n(`${e}: ${(s=t.target.error)===null||s===void 0?void 0:s.message}`)}}))}class st{constructor(t){this._db=t;this.objectStoreNames=this._db.objectStoreNames}transaction(t,e="readonly"){return new nt(this._db.transaction.call(this._db,t,e))}createObjectStore(t,e){return new it(this._db.createObjectStore(t,e))}close(){this._db.close()}}class nt{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 it(this._transaction.objectStore(t))}}class it{constructor(t){this._store=t}index(t){return new rt(this._store.index(t))}createIndex(t,e,s){return new rt(this._store.createIndex(t,e,s))}get(t){const e=this._store.get(t);return et(e,"Error reading from IndexedDB")}put(t,e){const s=this._store.put(t,e);return et(s,"Error writing to IndexedDB")}delete(t){const e=this._store.delete(t);return et(e,"Error deleting from IndexedDB")}clear(){const t=this._store.clear();return et(t,"Error clearing IndexedDB object store")}}class rt{constructor(t){this._index=t}get(t){const e=this._index.get(t);return et(e,"Error reading from IndexedDB")}}function ot(t,e,s){return new Promise(((n,i)=>{try{const r=indexedDB.open(t,e);r.onsuccess=t=>{n(new st(t.target.result))};r.onerror=t=>{var e;i(`Error opening indexedDB: ${(e=t.target.error)===null||e===void 0?void 0:e.message}`)};r.onupgradeneeded=t=>{s(new st(r.result),t.oldVersion,t.newVersion,new nt(r.transaction))}}catch(t){i(`Error opening indexedDB: ${t.message}`)}}))}class at{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 ct="[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 ht{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 d;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 n=(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(n){return null}else{throw t}}}else{if(n){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(ut(t)){try{this.getOrInitializeService({instanceIdentifier:ct})}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=ct){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=ct){return this.instances.has(t)}getOptions(t=ct){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 n=this.getOrInitializeService({instanceIdentifier:s,options:e});for(const[t,e]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(t);if(s===i){e.resolve(n)}}return n}onInit(t,e){var s;const n=this.normalizeInstanceIdentifier(e);const i=(s=this.onInitCallbacks.get(n))!==null&&s!==void 0?s:new Set;i.add(t);this.onInitCallbacks.set(n,i);const r=this.instances.get(n);if(r){t(r,n)}return()=>{i.delete(t)}}invokeOnInitCallbacks(t,e){const s=this.onInitCallbacks.get(e);if(!s){return}for(const n of s){try{n(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:ft(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=ct){if(this.component){return this.component.multipleInstances?t:ct}else{return t}}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function ft(t){return t===ct?undefined:t}function ut(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 lt{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 ht(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 dt;(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"})(dt||(dt={}));const pt={debug:dt.DEBUG,verbose:dt.VERBOSE,info:dt.INFO,warn:dt.WARN,error:dt.ERROR,silent:dt.SILENT};const gt=dt.INFO;const bt={[dt.DEBUG]:"log",[dt.VERBOSE]:"log",[dt.INFO]:"info",[dt.WARN]:"warn",[dt.ERROR]:"error"};const wt=(t,e,...s)=>{if(e<t.logLevel){return}const n=(new Date).toISOString();const i=bt[e];if(i){console[i](`[${n}]  ${t.name}:`,...s)}else{throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)}};class mt{constructor(t){this.name=t;this._logLevel=gt;this._logHandler=wt;this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in dt)){throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``)}this._logLevel=t}setLogLevel(t){this._logLevel=typeof t==="string"?pt[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,dt.DEBUG,...t);this._logHandler(this,dt.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,dt.VERBOSE,...t);this._logHandler(this,dt.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,dt.INFO,...t);this._logHandler(this,dt.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,dt.WARN,...t);this._logHandler(this,dt.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,dt.ERROR,...t);this._logHandler(this,dt.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 yt{constructor(t){this.container=t}getPlatformInfoString(){const t=this.container.getProviders();return t.map((t=>{if(Et(t)){const e=t.getImmediate();return`${e.library}/${e.version}`}else{return null}})).filter((t=>t)).join(" ")}}function Et(t){const e=t.getComponent();return(e===null||e===void 0?void 0:e.type)==="VERSION"}const vt="@firebase/app";const It="0.7.21";
/**
 * @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 St=new mt("@firebase/app");const Ot="@firebase/app-compat";const $t="@firebase/analytics-compat";const Dt="@firebase/analytics";const At="@firebase/app-check-compat";const Nt="@firebase/app-check";const jt="@firebase/auth";const Ct="@firebase/auth-compat";const Tt="@firebase/database";const _t="@firebase/database-compat";const Mt="@firebase/functions";const kt="@firebase/functions-compat";const Rt="@firebase/installations";const xt="@firebase/installations-compat";const Lt="@firebase/messaging";const Bt="@firebase/messaging-compat";const Pt="@firebase/performance";const Ft="@firebase/performance-compat";const Ut="@firebase/remote-config";const Ht="@firebase/remote-config-compat";const Vt="@firebase/storage";const Jt="@firebase/storage-compat";const zt="@firebase/firestore";const Wt="@firebase/firestore-compat";const Gt="firebase";const Kt="9.6.11";
/**
 * @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 qt="[DEFAULT]";const Qt={[vt]:"fire-core",[Ot]:"fire-core-compat",[Dt]:"fire-analytics",[$t]:"fire-analytics-compat",[Nt]:"fire-app-check",[At]:"fire-app-check-compat",[jt]:"fire-auth",[Ct]:"fire-auth-compat",[Tt]:"fire-rtdb",[_t]:"fire-rtdb-compat",[Mt]:"fire-fn",[kt]:"fire-fn-compat",[Rt]:"fire-iid",[xt]:"fire-iid-compat",[Lt]:"fire-fcm",[Bt]:"fire-fcm-compat",[Pt]:"fire-perf",[Ft]:"fire-perf-compat",[Ut]:"fire-rc",[Ht]:"fire-rc-compat",[Vt]:"fire-gcs",[Jt]:"fire-gcs-compat",[zt]:"fire-fst",[Wt]:"fire-fst-compat","fire-js":"fire-js",[Gt]:"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 Xt=new Map;const Yt=new Map;function Zt(t,e){try{t.container.addComponent(e)}catch(s){St.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,s)}}function te(t){const e=t.name;if(Yt.has(e)){St.debug(`There were multiple attempts to register component ${e}.`);return false}Yt.set(e,t);for(const e of Xt.values()){Zt(e,t)}return true}function ee(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 se={["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 ne=new j("app","Firebase",se);
/**
 * @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 ie{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 at("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 ne.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 re=Kt;function oe(t,e={}){if(typeof e!=="object"){const t=e;e={name:t}}const s=Object.assign({name:qt,automaticDataCollectionEnabled:false},e);const n=s.name;if(typeof n!=="string"||!n){throw ne.create("bad-app-name",{appName:String(n)})}const i=Xt.get(n);if(i){if(U(t,i.options)&&U(s,i.config)){return i}else{throw ne.create("duplicate-app",{appName:n})}}const r=new lt(n);for(const t of Yt.values()){r.addComponent(t)}const o=new ie(t,s,r);Xt.set(n,o);return o}function ae(t=qt){const e=Xt.get(t);if(!e){throw ne.create("no-app",{appName:t})}return e}function ce(t,e,s){var n;let i=(n=Qt[t])!==null&&n!==void 0?n:t;if(s){i+=`-${s}`}const r=i.match(/\s|\//);const o=e.match(/\s|\//);if(r||o){const t=[`Unable to register library "${i}" with version "${e}":`];if(r){t.push(`library name "${i}" contains illegal characters (whitespace or "/")`)}if(r&&o){t.push("and")}if(o){t.push(`version name "${e}" contains illegal characters (whitespace or "/")`)}St.warn(t.join(" "));return}te(new at(`${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 he="firebase-heartbeat-database";const fe=1;const ue="firebase-heartbeat-store";let le=null;function de(){if(!le){le=ot(he,fe,((t,e)=>{switch(e){case 0:t.createObjectStore(ue)}})).catch((t=>{throw ne.create("storage-open",{originalErrorMessage:t.message})}))}return le}async function pe(t){try{const e=await de();return e.transaction(ue).objectStore(ue).get(be(t))}catch(t){throw ne.create("storage-get",{originalErrorMessage:t.message})}}async function ge(t,e){try{const s=await de();const n=s.transaction(ue,"readwrite");const i=n.objectStore(ue);await i.put(e,be(t));return n.complete}catch(t){throw ne.create("storage-set",{originalErrorMessage:t.message})}}function be(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 we=1024;const me=30*24*60*60*1e3;class ye{constructor(t){this.container=t;this._heartbeatsCache=null;const e=this.container.getProvider("app").getImmediate();this._storage=new Ie(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=Ee();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<=me}));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=Ee();const{heartbeatsToSend:e,unsentEntries:s}=ve(this._heartbeatsCache.heartbeats);const n=c(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 n}}function Ee(){const t=new Date;return t.toISOString().substring(0,10)}function ve(t,e=we){const s=[];let n=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(Se(s)>e){s.pop();break}}else{t.dates.push(i.date);if(Se(s)>e){t.dates.pop();break}}n=n.slice(1)}return{heartbeatsToSend:s,unsentEntries:n}}class Ie{constructor(t){this.app=t;this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){if(!$()){return false}else{return D().then((()=>true)).catch((()=>false))}}async read(){const t=await this._canUseIndexedDBPromise;if(!t){return{heartbeats:[]}}else{const t=await pe(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 ge(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 ge(this.app,{lastSentHeartbeatDate:(e=t.lastSentHeartbeatDate)!==null&&e!==void 0?e:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...t.heartbeats]})}}}function Se(t){return c(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 Oe(t){te(new at("platform-logger",(t=>new yt(t)),"PRIVATE"));te(new at("heartbeat",(t=>new ye(t)),"PRIVATE"));ce(vt,It,t);ce(vt,It,"esm2017");ce("fire-js","")}Oe("");export{F as A,Z as B,at as C,d as D,j as E,N as F,X as G,n as H,S as I,x as J,R as K,dt as L,f as M,a as N,p as O,O as P,$ as Q,E as R,re as S,I as T,te as _,b as a,y as b,h as c,ae as d,ee as e,U as f,tt as g,m as h,oe as i,G as j,J as k,z as l,mt as m,g as n,v as o,P as p,V as q,ce as r,s,o as t,M as u,_ as v,L as w,Y as x,W as y,B as z};
//# sourceMappingURL=p-a1c2b210.js.map