firebase
Version:
Firebase JavaScript library for web and Node.js
7 lines • 786 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).firebase=t()}(this,function(){"use strict";const t={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},f=function(e,t){if(!e)throw u(t)},u=function(e){return new Error("Firebase Database ("+t.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)},n=function(t){const n=[];let r=0;for(let i=0;i<t.length;i++){let e=t.charCodeAt(i);e<128?n[r++]=e:(e<2048?n[r++]=e>>6|192:(55296==(64512&e)&&i+1<t.length&&56320==(64512&t.charCodeAt(i+1))?(e=65536+((1023&e)<<10)+(1023&t.charCodeAt(++i)),n[r++]=e>>18|240,n[r++]=e>>12&63|128):n[r++]=e>>12|224,n[r++]=e>>6&63|128),n[r++]=63&e|128)}return n},r={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(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();var r=e?this.byteToCharMapWebSafe_:this.byteToCharMap_;const i=[];for(let u=0;u<n.length;u+=3){var s=n[u],a=u+1<n.length,o=a?n[u+1]:0,c=u+2<n.length,l=c?n[u+2]:0;let e=(15&o)<<2|l>>6,t=63&l;c||(t=64,a||(e=64)),i.push(r[s>>2],r[(3&s)<<4|o>>4],r[e],r[t])}return i.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(n(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let n=0,r=0;for(;n<e.length;){var i,s,a=e[n++];a<128?t[r++]=String.fromCharCode(a):191<a&&a<224?(i=e[n++],t[r++]=String.fromCharCode((31&a)<<6|63&i)):239<a&&a<365?(s=((7&a)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t[r++]=String.fromCharCode(55296+(s>>10)),t[r++]=String.fromCharCode(56320+(1023&s))):(i=e[n++],s=e[n++],t[r++]=String.fromCharCode((15&a)<<12|(63&i)<<6|63&s))}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();var n=t?this.charToByteMapWebSafe_:this.charToByteMap_;const r=[];for(let c=0;c<e.length;){var i=n[e.charAt(c++)],s=c<e.length?n[e.charAt(c)]:0;++c;var a=c<e.length?n[e.charAt(c)]:64;++c;var o=c<e.length?n[e.charAt(c)]:64;if(++c,null==i||null==s||null==a||null==o)throw new l;r.push(i<<2|s>>4),64!==a&&(r.push(s<<4&240|a>>2),64!==o&&r.push(a<<6&192|o))}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class l extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}function i(e){var t=n(e);return r.encodeByteArray(t,!0)}const s=function(e){return i(e).replace(/\./g,"")},a=function(e){try{return r.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function c(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:const n=t;return new Date(n.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(const r in t)t.hasOwnProperty(r)&&"__proto__"!==r&&(e[r]=c(e[r],t[r]));return e}function o(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}const e=()=>o().__FIREBASE_DEFAULTS__,h=()=>{if("undefined"!=typeof process&&void 0!==process.env){var e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0}},d=()=>{if("undefined"!=typeof document){let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}var t=e&&a(e[1]);return t&&JSON.parse(t)}},p=()=>{try{return e()||h()||d()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},g=()=>{var e;return null===(e=p())||void 0===e?void 0:e.config};var m,v,_;class y{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(n){return(e,t)=>{e?this.reject(e):this.resolve(t),"function"==typeof n&&(this.promise.catch(()=>{}),1===n.length?n(e):n(e,t))}}}function w(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');var n=t||"demo-project",r=e.iat||0,i=e.sub||e.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");i=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:{}}},e);return[s(JSON.stringify({alg:"none",type:"JWT"})),s(JSON.stringify(i)),""].join(".")}function b(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function I(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(b())}function T(){var e=null===(e=p())||void 0===e?void 0:e.forceEnvironment;if("node"===e)return!0;if("browser"===e)return!1;try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}function E(){return"object"==typeof self&&self.self===self}function C(){var e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}function S(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function k(){const e=b();return 0<=e.indexOf("MSIE ")||0<=e.indexOf("Trident/")}function A(){return!0===t.NODE_ADMIN}function N(){return!T()&&navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function R(){try{return"object"==typeof indexedDB}catch(e){return!1}}function P(){return new Promise((t,n)=>{try{let e=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),e||self.indexedDB.deleteDatabase(r),t(!0)},i.onupgradeneeded=()=>{e=!1},i.onerror=()=>{var e;n((null===(e=i.error)||void 0===e?void 0:e.message)||"")}}catch(e){n(e)}})}function D(){return!("undefined"==typeof navigator||!navigator.cookieEnabled)}class x extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,x.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,O.prototype.create)}}class O{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){var r,n=t[0]||{},i=`${this.service}/${e}`,s=this.errors[e],s=s?(r=n,s.replace(M,(e,t)=>{var n=r[t];return null!=n?String(n):`<${t}?>`})):"Error",s=`${this.serviceName}: ${s} (${i}).`;return new x(i,s,n)}}const M=/\{\$([^}]+)}/g;function L(e){return JSON.parse(e)}function F(e){return JSON.stringify(e)}function U(e){let t={},n={},r={},i="";try{var s=e.split(".");t=L(a(s[0])||""),n=L(a(s[1])||""),i=s[2],r=n.d||{},delete n.d}catch(e){}return{header:t,claims:n,data:r,signature:i}}function V(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function q(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]}function j(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function B(e,t,n){const r={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=t.call(n,e[i],i,e));return r}function z(e,t){if(e===t)return!0;const n=Object.keys(e),r=Object.keys(t);for(const a of n){if(!r.includes(a))return!1;var i=e[a],s=t[a];if($(i)&&$(s)){if(!z(i,s))return!1}else if(i!==s)return!1}for(const o of r)if(!n.includes(o))return!1;return!0}function $(e){return null!==e&&"object"==typeof e}function K(e){const t=[];for(const[n,r]of Object.entries(e))Array.isArray(r)?r.forEach(e=>{t.push(encodeURIComponent(n)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return t.length?"&"+t.join("&"):""}function G(e){const r={},t=e.replace(/^\?/,"").split("&");return t.forEach(e=>{var t,n;e&&([t,n]=e.split("="),r[decodeURIComponent(t)]=decodeURIComponent(n))}),r}function W(e){var t=e.indexOf("?");if(!t)return"";var n=e.indexOf("#",t);return e.substring(t,0<n?n:void 0)}class H{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=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_(n,r){r=r||0;const i=this.W_;if("string"==typeof n)for(let e=0;e<16;e++)i[e]=n.charCodeAt(r)<<24|n.charCodeAt(r+1)<<16|n.charCodeAt(r+2)<<8|n.charCodeAt(r+3),r+=4;else for(let t=0;t<16;t++)i[t]=n[r]<<24|n[r+1]<<16|n[r+2]<<8|n[r+3],r+=4;for(let d=16;d<80;d++){var e=i[d-3]^i[d-8]^i[d-14]^i[d-16];i[d]=4294967295&(e<<1|e>>>31)}let t=this.chain_[0],s=this.chain_[1],a=this.chain_[2],o=this.chain_[3],c=this.chain_[4],l,u;for(let p=0;p<80;p++){u=p<40?p<20?(l=o^s&(a^o),1518500249):(l=s^a^o,1859775393):p<60?(l=s&a|o&(s|a),2400959708):(l=s^a^o,3395469782);var h=(t<<5|t>>>27)+l+c+u+i[p]&4294967295;c=o,o=a,a=4294967295&(s<<30|s>>>2),s=t,t=h}this.chain_[0]=this.chain_[0]+t&4294967295,this.chain_[1]=this.chain_[1]+s&4294967295,this.chain_[2]=this.chain_[2]+a&4294967295,this.chain_[3]=this.chain_[3]+o&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(n,r){if(null!=n){var i=(r=void 0===r?n.length:r)-this.blockSize;let e=0;const s=this.buf_;let t=this.inbuf_;for(;e<r;){if(0===t)for(;e<=i;)this.compress_(n,e),e+=this.blockSize;if("string"==typeof n){for(;e<r;)if(s[t]=n.charCodeAt(e),++t,++e,t===this.blockSize){this.compress_(s),t=0;break}}else for(;e<r;)if(s[t]=n[e],++t,++e,t===this.blockSize){this.compress_(s),t=0;break}}this.inbuf_=t,this.total_+=r}}digest(){const t=[];let e=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let r=this.blockSize-1;56<=r;r--)this.buf_[r]=255&e,e/=256;this.compress_(this.buf_);let n=0;for(let i=0;i<5;i++)for(let e=24;0<=e;e-=8)t[n]=this.chain_[i]>>e&255,++n;return t}}function Q(e,t){const n=new Y(e,t);return n.subscribe.bind(n)}class Y{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(e=>{this.error(e)})}next(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,n){let r;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");r=function(e,t){if("object"!=typeof e||null===e)return!1;for(const n of t)if(n in e&&"function"==typeof e[n])return!0;return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:n},void 0===r.next&&(r.next=J),void 0===r.error&&(r.error=J),void 0===r.complete&&(r.complete=J);var i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch(e){}}),this.observers.push(r),i}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],--this.observerCount,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(e,t){this.task.then(()=>{if(void 0!==this.observers&&void 0!==this.observers[e])try{t(this.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}})}close(e){this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function J(){}function X(e,t,n,r){let i;if(r<t?i="at least "+t:n<r&&(i=0===n?"none":"no more than "+n),i){var s=e+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+i+".";throw new Error(s)}}function Z(e,t){return`${e} failed: ${t} argument `}function ee(e,t,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(Z(e,t)+"must be a valid function.")}function te(e,t,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(Z(e,t)+"must be a valid context object.")}function ne(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)})}const re=function(e){let t=0;for(let r=0;r<e.length;r++){var n=e.charCodeAt(r);n<128?t++:n<2048?t+=2:55296<=n&&n<=56319?(t+=4,r++):t+=3}return t},ie=1e3,se=2,ae=144e5,oe=.5;function ce(e,t=ie,n=se){var r=t*Math.pow(n,e),i=Math.round(oe*r*(Math.random()-.5)*2);return Math.min(ae,r+i)}function le(e){return e&&e._delegate?e._delegate:e}class ue{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}const he="[DEFAULT]";class de{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){var t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const r=new y;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{var n=this.getOrInitializeService({instanceIdentifier:t});n&&r.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),n=null!==(n=null==e?void 0:e.optional)&&void 0!==n&&n;if(!this.isInitialized(t)&&!this.shouldAutoInitialize()){if(n)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:t})}catch(e){if(n)return null;throw e}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if("EAGER"===e.instantiationMode)try{this.getOrInitializeService({instanceIdentifier:he})}catch(e){}for(var[t,n]of this.instancesDeferred.entries()){t=this.normalizeInstanceIdentifier(t);try{var r=this.getOrInitializeService({instanceIdentifier:t});n.resolve(r)}catch(e){}}}}clearInstance(e=he){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=he){return this.instances.has(e)}getOptions(e=he){return this.instancesOptions.get(e)||{}}initialize(e={}){var{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.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`);var r,i,s=this.getOrInitializeService({instanceIdentifier:n,options:t});for([r,i]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(r)&&i.resolve(s);return s}onInit(e,t){var n=this.normalizeInstanceIdentifier(t);const r=null!==(i=this.onInitCallbacks.get(n))&&void 0!==i?i:new Set;r.add(e),this.onInitCallbacks.set(n,r);var i=this.instances.get(n);return i&&e(i,n),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){var n=this.onInitCallbacks.get(t);if(n)for(const r of n)try{r(e,t)}catch(e){}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(r=e)===he?void 0:r,options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch(e){}var r;return n||null}normalizeInstanceIdentifier(e=he){return!this.component||this.component.multipleInstances?e:he}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class pe{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){const t=this.getProvider(e.name);t.isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);var t=new de(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}const fe=[];(v=m=m||{})[v.DEBUG=0]="DEBUG",v[v.VERBOSE=1]="VERBOSE",v[v.INFO=2]="INFO",v[v.WARN=3]="WARN",v[v.ERROR=4]="ERROR",v[v.SILENT=5]="SILENT";const ge={debug:m.DEBUG,verbose:m.VERBOSE,info:m.INFO,warn:m.WARN,error:m.ERROR,silent:m.SILENT},me=m.INFO,ve={[m.DEBUG]:"log",[m.VERBOSE]:"log",[m.INFO]:"info",[m.WARN]:"warn",[m.ERROR]:"error"},_e=(e,t,...n)=>{if(!(t<e.logLevel)){var r=(new Date).toISOString(),i=ve[t];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[i](`[${r}] ${e.name}:`,...n)}};class ye{constructor(e){this.name=e,this._logLevel=me,this._logHandler=_e,this._userLogHandler=null,fe.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in m))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?ge[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,m.DEBUG,...e),this._logHandler(this,m.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,m.VERBOSE,...e),this._logHandler(this,m.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,m.INFO,...e),this._logHandler(this,m.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,m.WARN,...e),this._logHandler(this,m.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,m.ERROR,...e),this._logHandler(this,m.ERROR,...e)}}const we=(t,e)=>e.some(e=>t instanceof e);let be,Ie;const Te=new WeakMap,Ee=new WeakMap,Ce=new WeakMap,Se=new WeakMap,ke=new WeakMap;let Ae={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return Ee.get(e);if("objectStoreNames"===t)return e.objectStoreNames||Ce.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Pe(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e}};function Ne(r){return r!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(Ie=Ie||[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey]).includes(r)?function(...e){return r.apply(De(this),e),Pe(Te.get(this))}:function(...e){return Pe(r.apply(De(this),e))}:function(e,...t){var n=r.call(De(this),e,...t);return Ce.set(n,e.sort?e.sort():[e]),Pe(n)}}function Re(e){return"function"==typeof e?Ne(e):(e instanceof IDBTransaction&&(s=e,Ee.has(s)||(t=new Promise((e,t)=>{const n=()=>{s.removeEventListener("complete",r),s.removeEventListener("error",i),s.removeEventListener("abort",i)},r=()=>{e(),n()},i=()=>{t(s.error||new DOMException("AbortError","AbortError")),n()};s.addEventListener("complete",r),s.addEventListener("error",i),s.addEventListener("abort",i)}),Ee.set(s,t))),we(e,be=be||[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])?new Proxy(e,Ae):e);var s,t}function Pe(e){if(e instanceof IDBRequest)return function(s){const e=new Promise((e,t)=>{const n=()=>{s.removeEventListener("success",r),s.removeEventListener("error",i)},r=()=>{e(Pe(s.result)),n()},i=()=>{t(s.error),n()};s.addEventListener("success",r),s.addEventListener("error",i)});return e.then(e=>{e instanceof IDBCursor&&Te.set(e,s)}).catch(()=>{}),ke.set(e,s),e}(e);if(Se.has(e))return Se.get(e);var t=Re(e);return t!==e&&(Se.set(e,t),ke.set(t,e)),t}const De=e=>ke.get(e);function xe(e,t,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const a=indexedDB.open(e,t),o=Pe(a);return r&&a.addEventListener("upgradeneeded",e=>{r(Pe(a.result),e.oldVersion,e.newVersion,Pe(a.transaction),e)}),n&&a.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),o.then(e=>{s&&e.addEventListener("close",()=>s()),i&&e.addEventListener("versionchange",e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),o}function Oe(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",e=>t(e.oldVersion,e)),Pe(n).then(()=>{})}const Me=["get","getKey","getAll","getAllKeys","count"],Le=["put","add","delete","clear"],Fe=new Map;function Ue(e,t){if(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t){if(Fe.get(t))return Fe.get(t);const i=t.replace(/FromIndex$/,""),s=t!==i,a=Le.includes(i);if(i in(s?IDBIndex:IDBObjectStore).prototype&&(a||Me.includes(i))){var n=async function(e,...t){var n=this.transaction(e,a?"readwrite":"readonly");let r=n.store;return s&&(r=r.index(t.shift())),(await Promise.all([r[i](...t),a&&n.done]))[0]};return Fe.set(t,n),n}}}Ae={..._=Ae,get:(e,t,n)=>Ue(e,t)||_.get(e,t,n),has:(e,t)=>!!Ue(e,t)||_.has(e,t)};class Ve{constructor(e){this.container=e}getPlatformInfoString(){const e=this.container.getProviders();return e.map(e=>{if("VERSION"!==(null==(t=e.getComponent())?void 0:t.type))return null;var t,t=e.getImmediate();return`${t.library}/${t.version}`}).filter(e=>e).join(" ")}}const qe="@firebase/app",je="0.10.5",Be=new ye("@firebase/app");var ze;const $e="[DEFAULT]",Ke={"@firebase/app":"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","@firebase/vertexai-preview":"fire-vertex","fire-js":"fire-js",firebase:"fire-js-all"},Ge=new Map,We=new Map,He=new Map;function Qe(t,n){try{t.container.addComponent(n)}catch(e){Be.debug(`Component ${n.name} failed to register with FirebaseApp ${t.name}`,e)}}function Ye(e,t){e.container.addOrOverwriteComponent(t)}function Je(e){var t=e.name;if(He.has(t))return Be.debug(`There were multiple attempts to register component ${t}.`),!1;He.set(t,e);for(const n of Ge.values())Qe(n,e);for(const r of We.values())Qe(r,e);return!0}function Xe(e,t){const n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function Ze(e){return void 0!==e.options}function et(e){return void 0!==e.settings}const tt=new O("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","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","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","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.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."});class nt{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new ue("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}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(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw tt.create("app-deleted",{appName:this._name})}}class rt extends nt{constructor(e,t,n,r){var i=void 0!==t.automaticDataCollectionEnabled&&t.automaticDataCollectionEnabled,s={name:n,automaticDataCollectionEnabled:i};void 0!==e.apiKey?super(e,s,r):super(e.options,s,r),this._serverConfig=Object.assign({automaticDataCollectionEnabled:i},t),this._finalizationRegistry=new FinalizationRegistry(()=>{this.automaticCleanup()}),this._refCount=0,this.incRefCount(this._serverConfig.releaseOnDeref),this._serverConfig.releaseOnDeref=void 0,t.releaseOnDeref=void 0,ct(qe,je,"serverapp")}toJSON(){}get refCount(){return this._refCount}incRefCount(e){this.isDeleted||(this._refCount++,void 0!==e&&this._finalizationRegistry.register(e,this))}decRefCount(){return this.isDeleted?0:--this._refCount}automaticCleanup(){ot(this)}get settings(){return this.checkDestroyed(),this._serverConfig}checkDestroyed(){if(this.isDeleted)throw tt.create("server-app-deleted")}}const it="10.12.2";function st(e,t={}){let n=e;if("object"!=typeof t){const i=t;t={name:i}}var r=Object.assign({name:$e,automaticDataCollectionEnabled:!1},t);const i=r.name;if("string"!=typeof i||!i)throw tt.create("bad-app-name",{appName:String(i)});if(n=n||g(),!n)throw tt.create("no-options");var s=Ge.get(i);if(s){if(z(n,s.options)&&z(r,s.config))return s;throw tt.create("duplicate-app",{appName:i})}const a=new pe(i);for(const o of He.values())a.addComponent(o);r=new nt(n,r,a);return Ge.set(i,r),r}function at(e=$e){var t=Ge.get(e);if(!t&&e===$e&&g())return st();if(!t)throw tt.create("no-app",{appName:e});return t}async function ot(e){let t=!1;var n=e.name;if(Ge.has(n))t=!0,Ge.delete(n);else if(We.has(n)){const r=e;r.decRefCount()<=0&&(We.delete(n),t=!0)}t&&(await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function ct(e,t,n){let r=null!==(s=Ke[e])&&void 0!==s?s:e;n&&(r+=`-${n}`);var i=r.match(/\s|\//),s=t.match(/\s|\//);if(i||s){const a=[`Unable to register library "${r}" with version "${t}":`];return i&&a.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&s&&a.push("and"),s&&a.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void Be.warn(a.join(" "))}Je(new ue(`${r}-version`,()=>({library:r,version:t}),"VERSION"))}function lt(e,t){if(null!==e&&"function"!=typeof e)throw tt.create("invalid-log-argument");!function(s,e){for(const t of fe){let i=null;e&&e.level&&(i=ge[e.level]),t.userLogHandler=null===s?null:(e,t,...n)=>{var r=n.map(e=>{if(null==e)return null;if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return e.toString();if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch(e){return null}}).filter(e=>e).join(" ");t>=(null!==i&&void 0!==i?i:e.logLevel)&&s({level:m[t].toLowerCase(),message:r,args:n,type:e.name})}}}(e,t)}function ut(e){var t;t=e,fe.forEach(e=>{e.setLogLevel(t)})}const ht="firebase-heartbeat-database",dt=1,pt="firebase-heartbeat-store";let ft=null;function gt(){return ft=ft||xe(ht,dt,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(pt)}catch(e){console.warn(e)}}}).catch(e=>{throw tt.create("idb-open",{originalErrorMessage:e.message})}),ft}async function mt(e,t){try{const r=await gt(),i=r.transaction(pt,"readwrite"),s=i.objectStore(pt);await s.put(t,vt(e)),await i.done}catch(e){var n;e instanceof x?Be.warn(e.message):(n=tt.create("idb-set",{originalErrorMessage:null==e?void 0:e.message}),Be.warn(n.message))}}function vt(e){return`${e.name}!${e.options.appId}`}class _t{constructor(e){this.container=e,this._heartbeatsCache=null;var t=this.container.getProvider("app").getImmediate();this._storage=new wt(t),this._heartbeatsCachePromise=this._storage.read().then(e=>this._heartbeatsCache=e)}async triggerHeartbeat(){var e;const t=this.container.getProvider("platform-logger").getImmediate();var n=t.getPlatformInfoString();const r=yt();if((null!=(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)||(this._heartbeatsCache=await this._heartbeatsCachePromise,null!=(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)))&&this._heartbeatsCache.lastSentHeartbeatDate!==r&&!this._heartbeatsCache.heartbeats.some(e=>e.date===r))return this._heartbeatsCache.heartbeats.push({date:r,agent:n}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(e=>{var t=new Date(e.date).valueOf();return Date.now()-t<=2592e6}),this._storage.overwrite(this._heartbeatsCache)}async getHeartbeatsHeader(){if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==(null===(n=this._heartbeatsCache)||void 0===n?void 0:n.heartbeats)||0===this._heartbeatsCache.heartbeats.length)return"";var e=yt(),{heartbeatsToSend:t,unsentEntries:n}=function(e,t=1024){const n=[];let r=e.slice();for(const i of e){const s=n.find(e=>e.agent===i.agent);if(s){if(s.dates.push(i.date),bt(n)>t){s.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),bt(n)>t){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}(this._heartbeatsCache.heartbeats),t=s(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,0<n.length?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),t}}function yt(){const e=new Date;return e.toISOString().substring(0,10)}class wt{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!R()&&P().then(()=>!0).catch(()=>!1)}async read(){if(await this._canUseIndexedDBPromise){var e=await async function(e){try{const n=await gt(),r=n.transaction(pt);var t=await r.objectStore(pt).get(vt(e));return await r.done,t}catch(e){e instanceof x?Be.warn(e.message):(t=tt.create("idb-get",{originalErrorMessage:null==e?void 0:e.message}),Be.warn(t.message))}}(this.app);return null!=e&&e.heartbeats?e:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){var n=await this.read();return mt(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){var n=await this.read();return mt(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:[...n.heartbeats,...e.heartbeats]})}}}function bt(e){return s(JSON.stringify({version:2,heartbeats:e})).length}ze="",Je(new ue("platform-logger",e=>new Ve(e),"PRIVATE")),Je(new ue("heartbeat",e=>new _t(e),"PRIVATE")),ct(qe,je,ze),ct(qe,je,"esm2017"),ct("fire-js","");var It=Object.freeze({__proto__:null,SDK_VERSION:it,_DEFAULT_ENTRY_NAME:$e,_addComponent:Qe,_addOrOverwriteComponent:Ye,_apps:Ge,_clearComponents:function(){He.clear()},_components:He,_getProvider:Xe,_isFirebaseApp:Ze,_isFirebaseServerApp:et,_registerComponent:Je,_removeServiceInstance:function(e,t,n=$e){Xe(e,t).clearInstance(n)},_serverApps:We,deleteApp:ot,getApp:at,getApps:function(){return Array.from(Ge.values())},initializeApp:st,initializeServerApp:function(e,t){if(E())throw tt.create("invalid-server-app-environment");void 0===t.automaticDataCollectionEnabled&&(t.automaticDataCollectionEnabled=!1);let n;n=Ze(e)?e.options:e;const r=Object.assign(Object.assign({},t),n);if(void 0!==r.releaseOnDeref&&delete r.releaseOnDeref,void 0!==t.releaseOnDeref&&"undefined"==typeof FinalizationRegistry)throw tt.create("finalization-registry-not-supported",{});var i=""+[...JSON.stringify(r)].reduce((e,t)=>Math.imul(31,e)+t.charCodeAt(0)|0,0);const s=We.get(i);if(s)return s.incRefCount(t.releaseOnDeref),s;const a=new pe(i);for(const c of He.values())a.addComponent(c);var o=new rt(n,t,i,a);return We.set(i,o),o},onLog:lt,registerVersion:ct,setLogLevel:ut,FirebaseError:x});class Tt{constructor(e,t){this._delegate=e,this.firebase=t,Qe(e,new ue("app-compat",()=>this,"PUBLIC")),this.container=e.container}get automaticDataCollectionEnabled(){return this._delegate.automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this._delegate.automaticDataCollectionEnabled=e}get name(){return this._delegate.name}get options(){return this._delegate.options}delete(){return new Promise(e=>{this._delegate.checkDestroyed(),e()}).then(()=>(this.firebase.INTERNAL.removeApp(this.name),ot(this._delegate)))}_getService(e,t=$e){var n;this._delegate.checkDestroyed();const r=this._delegate.container.getProvider(e);return r.isInitialized()||"EXPLICIT"!==(null===(n=r.getComponent())||void 0===n?void 0:n.instantiationMode)||r.initialize(),r.getImmediate({identifier:t})}_removeServiceInstance(e,t=$e){this._delegate.container.getProvider(e).clearInstance(t)}_addComponent(e){Qe(this._delegate,e)}_addOrOverwriteComponent(e){Ye(this._delegate,e)}toJSON(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}}}const Et=new O("app-compat","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance."});function Ct(i){const s={},a={__esModule:!0,initializeApp:function(e,t={}){var n=st(e,t);if(V(s,n.name))return s[n.name];var r=new i(n,a);return s[n.name]=r},app:o,registerVersion:ct,setLogLevel:ut,onLog:lt,apps:null,SDK_VERSION:it,INTERNAL:{registerComponent:function(n){const r=n.name,t=r.replace("-compat","");{var e;Je(n)&&"PUBLIC"===n.type&&(e=(e=o())=>{if("function"!=typeof e[t])throw Et.create("invalid-app-argument",{appName:r});return e[t]()},void 0!==n.serviceProps&&c(e,n.serviceProps),a[t]=e,i.prototype[t]=function(...e){const t=this._getService.bind(this,r);return t.apply(this,n.multipleInstances?e:[])})}return"PUBLIC"===n.type?a[t]:null},removeApp:function(e){delete s[e]},useAsService:function(e,t){if("serverAuth"===t)return null;var n=t;return n},modularAPIs:It}};function o(e){if(e=e||$e,!V(s,e))throw Et.create("no-app",{appName:e});return s[e]}return a.default=a,Object.defineProperty(a,"apps",{get:function(){return Object.keys(s).map(e=>s[e])}}),o.App=i,a}var St=function e(){const t=Ct(Tt);return t.INTERNAL=Object.assign(Object.assign({},t.INTERNAL),{createFirebaseNamespace:e,extendNamespace:function(e){c(t,e)},createSubscribe:Q,ErrorFactory:O,deepExtend:c}),t}();const kt=new ye("@firebase/app-compat");if(E()&&void 0!==self.firebase){kt.warn(`
Warning: Firebase is already defined in the global scope. Please make sure
Firebase library is only loaded once.
`);const TP=self.firebase.SDK_VERSION;TP&&0<=TP.indexOf("LITE")&&kt.warn(`
Warning: You are trying to load Firebase while using Firebase Performance standalone script.
You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.
`)}const At=St;ct("@firebase/app-compat","0.2.35",void 0);At.registerVersion("firebase","10.12.2","app-compat");var Nt="@firebase/installations",Rt="0.6.7";const Pt=1e4,Dt="w:0.6.7",xt="FIS_v2",Ot="https://firebaseinstallations.googleapis.com/v1",Mt=36e5;const Lt=new O("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function Ft(e){return e instanceof x&&e.code.includes("request-failed")}function Ut({projectId:e}){return`${Ot}/projects/${e}/installations`}function Vt(e){return{token:e.token,requestStatus:2,expiresIn:(e=e.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()}}async function qt(e,t){var n=(await t.json()).error;return Lt.create("request-failed",{requestName:e,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function jt({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function Bt(e,{refreshToken:t}){const n=jt(e);return n.append("Authorization",(t=t,`${xt} ${t}`)),n}async function zt(e){var t=await e();return 500<=t.status&&t.status<600?e():t}function $t(t){return new Promise(e=>{setTimeout(e,t)})}const Kt=/^[cdef][\w-]{21}$/,Gt="";function Wt(){try{const t=new Uint8Array(17),n=self.crypto||self.msCrypto;n.getRandomValues(t),t[0]=112+t[0]%16;var e=function(e){const t=function(e){const t=btoa(String.fromCharCode(...e));return t.replace(/\+/g,"-").replace(/\//g,"_")}(e);return t.substr(0,22)}(t);return Kt.test(e)?e:Gt}catch(e){return Gt}}function Ht(e){return`${e.appName}!${e.appId}`}const Qt=new Map;function Yt(e,t){var n=Ht(e);Jt(n,t),function(e,t){const n=function(){!Xt&&"BroadcastChannel"in self&&(Xt=new BroadcastChannel("[Firebase] FID Change"),Xt.onmessage=e=>{Jt(e.data.key,e.data.fid)});return Xt}();n&&n.postMessage({key:e,fid:t});0===Qt.size&&Xt&&(Xt.close(),Xt=null)}(n,t)}function Jt(e,t){var n=Qt.get(e);if(n)for(const r of n)r(t)}let Xt=null;const Zt="firebase-installations-store";let en=null;function tn(){return en=en||xe("firebase-installations-database",1,{upgrade:(e,t)=>{0===t&&e.createObjectStore(Zt)}}),en}async function nn(e,t){var n=Ht(e);const r=await tn(),i=r.transaction(Zt,"readwrite"),s=i.objectStore(Zt);var a=await s.get(n);return await s.put(t,n),await i.done,a&&a.fid===t.fid||Yt(e,t.fid),t}async function rn(e){var t=Ht(e);const n=await tn(),r=n.transaction(Zt,"readwrite");await r.objectStore(Zt).delete(t),await r.done}async function sn(e,t){var n=Ht(e);const r=await tn(),i=r.transaction(Zt,"readwrite"),s=i.objectStore(Zt);var a=await s.get(n),o=t(a);return void 0===o?await s.delete(n):await s.put(o,n),await i.done,!o||a&&a.fid===o.fid||Yt(e,o.fid),o}async function an(n){let r;var e=await sn(n.appConfig,e=>{var t=cn(e||{fid:Wt(),registrationStatus:0}),t=function(e,t){{if(0!==t.registrationStatus)return 1===t.registrationStatus?{installationEntry:t,registrationPromise:async function(e){let t=await on(e.appConfig);for(;1===t.registrationStatus;)await $t(100),t=await on(e.appConfig);if(0!==t.registrationStatus)return t;{var{installationEntry:n,registrationPromise:r}=await an(e);return r||n}}(e)}:{installationEntry:t};if(!navigator.onLine){var n=Promise.reject(Lt.create("app-offline"));return{installationEntry:t,registrationPromise:n}}var r={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},n=async function(t,n){try{var e=await async function({appConfig:e,heartbeatServiceProvider:t},{fid:n}){const r=Ut(e),i=jt(e),s=t.getImmediate({optional:!0});!s||(a=await s.getHeartbeatsHeader())&&i.append("x-firebase-client",a);var a={fid:n,authVersion:xt,appId:e.appId,sdkVersion:Dt};const o={method:"POST",headers:i,body:JSON.stringify(a)},c=await zt(()=>fetch(r,o));if(c.ok){a=await c.json();return{fid:a.fid||n,registrationStatus:2,refreshToken:a.refreshToken,authToken:Vt(a.authToken)}}throw await qt("Create Installation",c)}(t,n);return nn(t.appConfig,e)}catch(e){throw Ft(e)&&409===e.customData.serverCode?await rn(t.appConfig):await nn(t.appConfig,{fid:n.fid,registrationStatus:0}),e}}(e,r);return{installationEntry:r,registrationPromise:n}}}(n,t);return r=t.registrationPromise,t.installationEntry});return e.fid===Gt?{installationEntry:await r}:{installationEntry:e,registrationPromise:r}}function on(e){return sn(e,e=>{if(!e)throw Lt.create("installation-not-found");return cn(e)})}function cn(e){return 1===(t=e).registrationStatus&&t.registrationTime+Pt<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function ln({appConfig:e,heartbeatServiceProvider:t},n){const r=([i,s]=[e,n["fid"]],`${Ut(i)}/${s}/authTokens:generate`);var i,s;const a=Bt(e,n),o=t.getImmediate({optional:!0});!o||(c=await o.getHeartbeatsHeader())&&a.append("x-firebase-client",c);var c={installation:{sdkVersion:Dt,appId:e.appId}};const l={method:"POST",headers:a,body:JSON.stringify(c)},u=await zt(()=>fetch(r,l));if(u.ok)return Vt(await u.json());throw await qt("Generate Auth Token",u)}async function un(r,i=!1){let s;var e=await sn(r.appConfig,e=>{if(!dn(e))throw Lt.create("not-registered");var t,n=e.authToken;if(i||2!==(t=n).requestStatus||function(e){var t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+Mt}(t)){if(1===n.requestStatus)return s=async function(e,t){let n=await hn(e.appConfig);for(;1===n.authToken.requestStatus;)await $t(100),n=await hn(e.appConfig);var r=n.authToken;return 0===r.requestStatus?un(e,t):r}(r,i),e;if(!navigator.onLine)throw Lt.create("app-offline");n=(t=e,n={requestStatus:1,requestTime:Date.now()},Object.assign(Object.assign({},t),{authToken:n}));return s=async function(t,n){try{var r=await ln(t,n),e=Object.assign(Object.assign({},n),{authToken:r});return await nn(t.appConfig,e),r}catch(e){throw!Ft(e)||401!==e.customData.serverCode&&404!==e.customData.serverCode?(r=Object.assign(Object.assign({},n),{authToken:{requestStatus:0}}),await nn(t.appConfig,r)):await rn(t.appConfig),e}}(r,n),n}return e});return s?await s:e.authToken}function hn(e){return sn(e,e=>{if(!dn(e))throw Lt.create("not-registered");var t,n=e.authToken;return 1===(t=n).requestStatus&&t.requestTime+Pt<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}function dn(e){return void 0!==e&&2===e.registrationStatus}async function pn(e,t=!1){var n,r=e;return await((n=(await an(r)).registrationPromise)&&await n),(await un(r,t)).token}function fn(e){return Lt.create("missing-app-config-values",{valueName:e})}const gn="installations",mn=e=>{var t=e.getProvider("app").getImmediate();return{app:t,appConfig:function(e){if(!e||!e.options)throw fn("App Configuration");if(!e.name)throw fn("App Name");for(const t of["projectId","apiKey","appId"])if(!e.options[t])throw fn(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t),heartbeatServiceProvider:Xe(t,"heartbeat"),_delete:()=>Promise.resolve()}},vn=e=>{const t=Xe(e.getProvider("app").getImmediate(),gn).getImmediate();return{getId:()=>async function(e){var t=e;const{installationEntry:n,registrationPromise:r}=await an(t);return(r||un(t)).catch(console.error),n.fid}(t),getToken:e=>pn(t,e)}};Je(new ue(gn,mn,"PUBLIC")),Je(new ue("installations-internal",vn,"PRIVATE")),ct(Nt,Rt),ct(Nt,Rt,"esm2017");const _n="analytics",yn="firebase_id",wn="origin",bn="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",In="https://www.googletagmanager.com/gtag/js",Tn=new ye("@firebase/analytics"),En=new O("analytics","Analytics",{"already-exists":"A Firebase Analytics instance with the appId {$id} already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-intialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invalid-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."});function Cn(e){if(e.startsWith(In))return e;var t=En.create("invalid-gtag-resource",{gtagURL:e});return Tn.warn(t.message),""}function Sn(e){return Promise.all(e.map(e=>e.catch(e=>e)))}function kn(e,t){const n=function(e,t){let n;return window.trustedTypes&&(n=window.trustedTypes.createPolicy(e,t)),n}("firebase-js-sdk-policy",{createScriptURL:Cn}),r=document.createElement("script");var i=`${In}?l=${e}&id=${t}`;r.src=n?null===n||void 0===n?void 0:n.createScriptURL(i):i,r.async=!0,document.head.appendChild(r)}function An(d,p,f,g){return async function(e,...t){try{var n,r,i,s,a,o,c,l,u,h;"event"===e?([n,r]=t,await async function(e,n,r,i,s){try{let t=[];if(s&&s.send_to){let e=s.send_to;Array.isArray(e)||(e=[e]);const c=await Sn(r);for(const l of e){var a=c.find(e=>e.measurementId===l),o=a&&n[a.appId];if(!o){t=[];break}t.push(o)}}0===t.length&&(t=Object.values(n)),await Promise.all(t),e("event",i,s||{})}catch(e){Tn.error(e)}}(d,p,f,n,r)):"config"===e?([i,s]=t,await async function(e,t,n,r,i,s){var a=r[i];try{if(a)await t[a];else{const c=await Sn(n);var o=c.find(e=>e.measurementId===i);o&&await t[o.appId]}}catch(e){Tn.error(e)}e("config",i,s)}(d,p,f,g,i,s)):"consent"===e?([a,o]=t,d("consent",a,o)):"get"===e?([c,l,u]=t,d("get",c,l,u)):"set"===e?([h]=t,d("set",h)):d(e,...t)}catch(e){Tn.error(e)}}}const Nn=30;const Rn=new class{constructor(e={},t=1e3){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}};async function Pn(e){var t,{appId:n,apiKey:r}=e,r={method:"GET",headers:new Headers({Accept:"application/json","x-goog-api-key":r})},n=bn.replace("{app-id}",n);const i=await fetch(n,r);if(200===i.status||304===i.status)return i.json();{let e="";try{var s=await i.json();null!==(t=s.error)&&void 0!==t&&t.message&&(e=s.error.message)}catch(e){}throw En.create("config-fetch-failed",{httpStatus:i.status,responseMessage:e})}}async function Dn(e,t=Rn,n){var{appId:r,apiKey:i,measurementId:s}=e.options;if(!r)throw En.create("no-app-id");if(!i){if(s)return{measurementId:s,appId:r};throw En.create("no-api-key")}var a=t.getThrottleMetadata(r)||{backoffCount:0,throttleEndTimeMillis:Date.now()};const o=new Mn;return setTimeout(async()=>{o.abort()},void 0!==n?n:6e4),async function t(n,{throttleEndTimeMillis:e,backoffCount:r},i,s=Rn){var a;const{appId:o,measurementId:c}=n;try{await xn(i,e)}catch(e){if(c)return Tn.warn("Timed out fetching this Firebase app's measurement ID from the server."+` Falling back to the measurement ID ${c}`+` provided in the "measurementId" field in the local Firebase config. [${null==e?void 0:e.message}]`),{appId:o,measurementId:c};throw e}try{const l=await Pn(n);return s.deleteThrottleMetadata(o),l}catch(e){const u=e;if(!On(u)){if(s.deleteThrottleMetadata(o),c)return Tn.warn("Failed to fetch this Firebase app's measurem