UNPKG

firebase

Version:

Firebase JavaScript library for web and Node.js

3 lines (2 loc) • 47.7 kB
!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";var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function r(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function o(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e}function a(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var n in t)t.hasOwnProperty(n)&&"__proto__"!==n&&(e[n]=a(e[n],t[n]));return e}var s=function(){function e(){var e=this;this.reject=function(){},this.resolve=function(){},this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))}return e.prototype.wrapCallback=function(e){var t=this;return function(n,r){n?t.reject(n):t.resolve(r),"function"==typeof e&&(t.promise.catch((function(){})),1===e.length?e(n):e(n,r))}},e}();var c=function(t){function n(e,r,i){var o=t.call(this,r)||this;return o.code=e,o.customData=i,o.name="FirebaseError",Object.setPrototypeOf(o,n.prototype),Error.captureStackTrace&&Error.captureStackTrace(o,u.prototype.create),o}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,t),n}(Error),u=function(){function e(e,t,n){this.service=e,this.serviceName=t,this.errors=n}return e.prototype.create=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=t[0]||{},i=this.service+"/"+e,o=this.errors[e],a=o?l(o,r):"Error",s=this.serviceName+": "+a+" ("+i+").",u=new c(i,s,r);return u},e}();function l(e,t){return e.replace(p,(function(e,n){var r=t[n];return null!=r?String(r):"<"+n+"?>"}))}var p=/\{\$([^}]+)}/g;var f=function(){function e(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}return e.prototype.setInstantiationMode=function(e){return this.instantiationMode=e,this},e.prototype.setMultipleInstances=function(e){return this.multipleInstances=e,this},e.prototype.setServiceProps=function(e){return this.serviceProps=e,this},e.prototype.setInstanceCreatedCallback=function(e){return this.onInstanceCreated=e,this},e}(),d="[DEFAULT]",h=function(){function e(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.onInitCallbacks=new Map}return e.prototype.get=function(e){var t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){var n=new s;if(this.instancesDeferred.set(t,n),this.isInitialized(t)||this.shouldAutoInitialize())try{var r=this.getOrInitializeService({instanceIdentifier:t});r&&n.resolve(r)}catch(e){}}return this.instancesDeferred.get(t).promise},e.prototype.getImmediate=function(e){var t,n=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),r=null!==(t=null==e?void 0:e.optional)&&void 0!==t&&t;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(r)return null;throw Error("Service "+this.name+" is not available")}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(e){if(r)return null;throw e}},e.prototype.getComponent=function(){return this.component},e.prototype.setComponent=function(e){var t,n;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(function(e){return"EAGER"===e.instantiationMode}(e))try{this.getOrInitializeService({instanceIdentifier:d})}catch(e){}try{for(var o=r(this.instancesDeferred.entries()),a=o.next();!a.done;a=o.next()){var s=i(a.value,2),c=s[0],u=s[1],l=this.normalizeInstanceIdentifier(c);try{var p=this.getOrInitializeService({instanceIdentifier:l});u.resolve(p)}catch(e){}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}}},e.prototype.clearInstance=function(e){void 0===e&&(e=d),this.instancesDeferred.delete(e),this.instances.delete(e)},e.prototype.delete=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return e=Array.from(this.instances.values()),[4,Promise.all(o(o([],i(e.filter((function(e){return"INTERNAL"in e})).map((function(e){return e.INTERNAL.delete()})))),i(e.filter((function(e){return"_delete"in e})).map((function(e){return e._delete()})))))];case 1:return t.sent(),[2]}}))}))},e.prototype.isComponentSet=function(){return null!=this.component},e.prototype.isInitialized=function(e){return void 0===e&&(e=d),this.instances.has(e)},e.prototype.initialize=function(e){var t,n;void 0===e&&(e={});var o=e.options,a=void 0===o?{}:o,s=this.normalizeInstanceIdentifier(e.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");var c=this.getOrInitializeService({instanceIdentifier:s,options:a});try{for(var u=r(this.instancesDeferred.entries()),l=u.next();!l.done;l=u.next()){var p=i(l.value,2),f=p[0],d=p[1];s===this.normalizeInstanceIdentifier(f)&&d.resolve(c)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}return c},e.prototype.onInit=function(e,t){var n,r=this.normalizeInstanceIdentifier(t),i=null!==(n=this.onInitCallbacks.get(r))&&void 0!==n?n:new Set;i.add(e),this.onInitCallbacks.set(r,i);var o=this.instances.get(r);return o&&e(o,r),function(){i.delete(e)}},e.prototype.invokeOnInitCallbacks=function(e,t){var n,i,o=this.onInitCallbacks.get(t);if(o)try{for(var a=r(o),s=a.next();!s.done;s=a.next()){var c=s.value;try{c(e,t)}catch(e){}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}},e.prototype.getOrInitializeService=function(e){var t,n=e.instanceIdentifier,r=e.options,i=void 0===r?{}:r,o=this.instances.get(n);if(!o&&this.component&&(o=this.component.instanceFactory(this.container,{instanceIdentifier:(t=n,t===d?void 0:t),options:i}),this.instances.set(n,o),this.invokeOnInitCallbacks(o,n),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,n,o)}catch(e){}return o||null},e.prototype.normalizeInstanceIdentifier=function(e){return void 0===e&&(e=d),this.component?this.component.multipleInstances?e:d:e},e.prototype.shouldAutoInitialize=function(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode},e}();var m,g,v=function(){function e(e){this.name=e,this.providers=new Map}return e.prototype.addComponent=function(e){var t=this.getProvider(e.name);if(t.isComponentSet())throw new Error("Component "+e.name+" has already been registered with "+this.name);t.setComponent(e)},e.prototype.addOrOverwriteComponent=function(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)},e.prototype.getProvider=function(e){if(this.providers.has(e))return this.providers.get(e);var t=new h(e,this);return this.providers.set(e,t),t},e.prototype.getProviders=function(){return Array.from(this.providers.values())},e}(),y=[];!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(g||(g={}));var b={debug:g.DEBUG,verbose:g.VERBOSE,info:g.INFO,warn:g.WARN,error:g.ERROR,silent:g.SILENT},w=g.INFO,_=((m={})[g.DEBUG]="log",m[g.VERBOSE]="log",m[g.INFO]="info",m[g.WARN]="warn",m[g.ERROR]="error",m),I=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(!(t<e.logLevel)){var i=(new Date).toISOString(),a=_[t];if(!a)throw new Error("Attempted to log a message with an invalid logType (value: "+t+")");console[a].apply(console,o(["["+i+"] "+e.name+":"],n))}},E=function(){function e(e){this.name=e,this._logLevel=w,this._logHandler=I,this._userLogHandler=null,y.push(this)}return Object.defineProperty(e.prototype,"logLevel",{get:function(){return this._logLevel},set:function(e){if(!(e in g))throw new TypeError('Invalid value "'+e+'" assigned to `logLevel`');this._logLevel=e},enumerable:!1,configurable:!0}),e.prototype.setLogLevel=function(e){this._logLevel="string"==typeof e?b[e]:e},Object.defineProperty(e.prototype,"logHandler",{get:function(){return this._logHandler},set:function(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"userLogHandler",{get:function(){return this._userLogHandler},set:function(e){this._userLogHandler=e},enumerable:!1,configurable:!0}),e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._userLogHandler&&this._userLogHandler.apply(this,o([this,g.DEBUG],e)),this._logHandler.apply(this,o([this,g.DEBUG],e))},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._userLogHandler&&this._userLogHandler.apply(this,o([this,g.VERBOSE],e)),this._logHandler.apply(this,o([this,g.VERBOSE],e))},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._userLogHandler&&this._userLogHandler.apply(this,o([this,g.INFO],e)),this._logHandler.apply(this,o([this,g.INFO],e))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._userLogHandler&&this._userLogHandler.apply(this,o([this,g.WARN],e)),this._logHandler.apply(this,o([this,g.WARN],e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._userLogHandler&&this._userLogHandler.apply(this,o([this,g.ERROR],e)),this._logHandler.apply(this,o([this,g.ERROR],e))},e}();class S{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map((e=>{if(function(e){const t=e.getComponent();return"VERSION"===(null==t?void 0:t.type)}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null})).filter((e=>e)).join(" ")}}const T="@firebase/app-exp",C=new E("@firebase/app"),A="[DEFAULT]",N={[T]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics-exp":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check-exp":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth-exp":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions-exp":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations-exp":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging-exp":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance-exp":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config-exp":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","fire-js":"fire-js","firebase-exp":"fire-js-all"},O=new Map,k=new Map;function D(e,t){try{e.container.addComponent(t)}catch(n){C.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function P(e){const t=e.name;if(k.has(t))return C.debug(`There were multiple attempts to register component ${t}.`),!1;k.set(t,e);for(const t of O.values())D(t,e);return!0}function R(e,t){return e.container.getProvider(t)}const x=new u("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$appName}","duplicate-app":"Firebase App named '{$appName}' already exists","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."});class L{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new f("app-exp",(()=>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 container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw x.create("app-deleted",{appName:this._name})}}const j="9.0.0-beta.7";function M(e,t={}){if("object"!=typeof t){t={name:t}}const n=Object.assign({name:A,automaticDataCollectionEnabled:!1},t),r=n.name;if("string"!=typeof r||!r)throw x.create("bad-app-name",{appName:String(r)});if(O.has(r))throw x.create("duplicate-app",{appName:r});const i=new v(r);for(const e of k.values())i.addComponent(e);const o=new L(e,n,i);return O.set(r,o),o}async function B(e){const t=e.name;O.has(t)&&(O.delete(t),await Promise.all(e.container.getProviders().map((e=>e.delete()))),e.isDeleted=!0)}function F(e,t,n){var r;let i=null!==(r=N[e])&&void 0!==r?r:e;n&&(i+=`-${n}`);const o=i.match(/\s|\//),a=t.match(/\s|\//);if(o||a){const e=[`Unable to register library "${i}" with version "${t}":`];return o&&e.push(`library name "${i}" contains illegal characters (whitespace or "/")`),o&&a&&e.push("and"),a&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void C.warn(e.join(" "))}P(new f(`${i}-version`,(()=>({library:i,version:t})),"VERSION"))}function U(e,t){if(null!==e&&"function"!=typeof e)throw x.create("invalid-log-argument");!function(e,t){for(var n=function(n){var r=null;t&&t.level&&(r=b[t.level]),n.userLogHandler=null===e?null:function(t,n){for(var i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];var a=i.map((function(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((function(e){return e})).join(" ");n>=(null!=r?r:t.logLevel)&&e({level:g[n].toLowerCase(),message:a,args:i,type:t.name})}},r=0,i=y;r<i.length;r++)n(i[r])}(e,t)}function $(e){var t;t=e,y.forEach((function(e){e.setLogLevel(t)}))}var q;P(new f("platform-logger",(e=>new S(e)),"PRIVATE")),F(T,"0.0.900-exp.6ef484a04",q),F("fire-js","");var z=Object.freeze({__proto__:null,SDK_VERSION:j,_DEFAULT_ENTRY_NAME:A,_addComponent:D,_addOrOverwriteComponent:function(e,t){e.container.addOrOverwriteComponent(t)},_apps:O,_clearComponents:function(){k.clear()},_components:k,_getProvider:R,_registerComponent:P,_removeServiceInstance:function(e,t,n="[DEFAULT]"){R(e,t).clearInstance(n)},deleteApp:B,getApp:function(e="[DEFAULT]"){const t=O.get(e);if(!t)throw x.create("no-app",{appName:e});return t},getApps:function(){return Array.from(O.values())},initializeApp:M,onLog:U,registerVersion:F,setLogLevel:$});class V{constructor(e,t){this._delegate=e,this.firebase=t,D(e,new f("app-compat",(()=>this),"PUBLIC"))}get automaticDataCollectionEnabled(){return this._delegate.automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.automaticDataCollectionEnabled=e}get name(){return this._delegate.name}get options(){return this._delegate.options}delete(){return this.firebase.INTERNAL.removeApp(this.name),B(this._delegate)}_getService(e,t="[DEFAULT]"){return this._delegate.checkDestroyed(),this._delegate.container.getProvider(e).getImmediate({identifier:t})}}const H=new u("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 K(e){const t={},n={__esModule:!0,initializeApp:function(r,i={}){const o=M(r,i),a=new e(o,n);return t[o.name]=a,a},app:r,registerVersion:F,setLogLevel:$,onLog:U,apps:null,SDK_VERSION:j,INTERNAL:{registerComponent:function(t){const i=t.name,o=i.replace("-compat","");if(P(t)&&"PUBLIC"===t.type){const s=(e=r())=>{if("function"!=typeof e[o])throw H.create("invalid-app-argument",{appName:i});return e[o]()};void 0!==t.serviceProps&&a(s,t.serviceProps),n[o]=s,e.prototype[o]=function(...e){return this._getService.bind(this,i).apply(this,t.multipleInstances?e:[])}}return"PUBLIC"===t.type?n[o]:null},removeApp:function(e){delete t[e]},useAsService:function(e,t){if("serverAuth"===t)return null;return t},modularAPIs:z}};function r(e){if(n=t,r=e=e||A,!Object.prototype.hasOwnProperty.call(n,r))throw H.create("no-app",{appName:e});var n,r;return t[e]}return n.default=n,Object.defineProperty(n,"apps",{get:function(){return Object.keys(t).map((e=>t[e]))}}),r.App=e,n}const W=function(){const e=K(V);e.SDK_VERSION=`${e.SDK_VERSION}_LITE`;const t=e.INTERNAL.registerComponent;return e.INTERNAL.registerComponent=function(e){if("PUBLIC"===e.type&&!e.name.includes("performance")&&!e.name.includes("installations"))throw Error(`${name} cannot register with the standalone perf instance`);return t(e)},e}();!function(e){F("@firebase/app-compat","0.0.900-exp.6ef484a04",e)}("lite");function G(e){return Array.prototype.slice.call(e)}function J(e){return new Promise((function(t,n){e.onsuccess=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Y(e,t,n){var r,i=new Promise((function(i,o){J(r=e[t].apply(e,n)).then(i,o)}));return i.request=r,i}function X(e,t,n){var r=Y(e,t,n);return r.then((function(e){if(e)return new re(e,r.request)}))}function Z(e,t,n){n.forEach((function(n){Object.defineProperty(e.prototype,n,{get:function(){return this[t][n]},set:function(e){this[t][n]=e}})}))}function Q(e,t,n,r){r.forEach((function(r){r in n.prototype&&(e.prototype[r]=function(){return Y(this[t],r,arguments)})}))}function ee(e,t,n,r){r.forEach((function(r){r in n.prototype&&(e.prototype[r]=function(){return this[t][r].apply(this[t],arguments)})}))}function te(e,t,n,r){r.forEach((function(r){r in n.prototype&&(e.prototype[r]=function(){return X(this[t],r,arguments)})}))}function ne(e){this._index=e}function re(e,t){this._cursor=e,this._request=t}function ie(e){this._store=e}function oe(e){this._tx=e,this.complete=new Promise((function(t,n){e.oncomplete=function(){t()},e.onerror=function(){n(e.error)},e.onabort=function(){n(e.error)}}))}function ae(e,t,n){this._db=e,this.oldVersion=t,this.transaction=new oe(n)}function se(e){this._db=e}W.registerVersion("firebase-exp","9.0.0-beta.7","app-compat"),Z(ne,"_index",["name","keyPath","multiEntry","unique"]),Q(ne,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),te(ne,"_index",IDBIndex,["openCursor","openKeyCursor"]),Z(re,"_cursor",["direction","key","primaryKey","value"]),Q(re,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach((function(e){e in IDBCursor.prototype&&(re.prototype[e]=function(){var t=this,n=arguments;return Promise.resolve().then((function(){return t._cursor[e].apply(t._cursor,n),J(t._request).then((function(e){if(e)return new re(e,t._request)}))}))})})),ie.prototype.createIndex=function(){return new ne(this._store.createIndex.apply(this._store,arguments))},ie.prototype.index=function(){return new ne(this._store.index.apply(this._store,arguments))},Z(ie,"_store",["name","keyPath","indexNames","autoIncrement"]),Q(ie,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),te(ie,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),ee(ie,"_store",IDBObjectStore,["deleteIndex"]),oe.prototype.objectStore=function(){return new ie(this._tx.objectStore.apply(this._tx,arguments))},Z(oe,"_tx",["objectStoreNames","mode"]),ee(oe,"_tx",IDBTransaction,["abort"]),ae.prototype.createObjectStore=function(){return new ie(this._db.createObjectStore.apply(this._db,arguments))},Z(ae,"_db",["name","version","objectStoreNames"]),ee(ae,"_db",IDBDatabase,["deleteObjectStore","close"]),se.prototype.transaction=function(){return new oe(this._db.transaction.apply(this._db,arguments))},Z(se,"_db",["name","version","objectStoreNames"]),ee(se,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach((function(e){[ie,ne].forEach((function(t){e in t.prototype&&(t.prototype[e.replace("open","iterate")]=function(){var t=G(arguments),n=t[t.length-1],r=this._store||this._index,i=r[e].apply(r,t.slice(0,-1));i.onsuccess=function(){n(i.result)}})}))})),[ne,ie].forEach((function(e){e.prototype.getAll||(e.prototype.getAll=function(e,t){var n=this,r=[];return new Promise((function(i){n.iterateCursor(e,(function(e){e?(r.push(e.value),void 0===t||r.length!=t?e.continue():i(r)):i(r)}))}))})}));const ce="0.0.900-exp.6ef484a04",ue=1e4,le=`w:${ce}`,pe="FIS_v2",fe=36e5,de=new u("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 he(e){return e instanceof c&&e.code.includes("request-failed")}function me({projectId:e}){return`https://firebaseinstallations.googleapis.com/v1/projects/${e}/installations`}function ge(e){return{token:e.token,requestStatus:2,expiresIn:(t=e.expiresIn,Number(t.replace("s","000"))),creationTime:Date.now()};var t}async function ve(e,t){const n=(await t.json()).error;return de.create("request-failed",{requestName:e,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function ye({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function be(e,{refreshToken:t}){const n=ye(e);return n.append("Authorization",function(e){return`FIS_v2 ${e}`}(t)),n}async function we(e){const t=await e();return t.status>=500&&t.status<600?e():t}function _e(e){return new Promise((t=>{setTimeout(t,e)}))}const Ie=/^[cdef][\w-]{21}$/;function Ee(){try{const e=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16;const t=function(e){return(t=e,btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_")).substr(0,22);var t}(e);return Ie.test(t)?t:""}catch(e){return""}}function Se(e){return`${e.appName}!${e.appId}`}const Te=new Map;function Ce(e,t){const n=Se(e);Ae(n,t),function(e,t){const n=function(){!Ne&&"BroadcastChannel"in self&&(Ne=new BroadcastChannel("[Firebase] FID Change"),Ne.onmessage=e=>{Ae(e.data.key,e.data.fid)});return Ne}();n&&n.postMessage({key:e,fid:t});0===Te.size&&Ne&&(Ne.close(),Ne=null)}(n,t)}function Ae(e,t){const n=Te.get(e);if(n)for(const e of n)e(t)}let Ne=null;const Oe="firebase-installations-store";let ke=null;function De(){return ke||(ke=function(e,t,n){var r=Y(indexedDB,"open",[e,t]),i=r.request;return i&&(i.onupgradeneeded=function(e){n&&n(new ae(i.result,e.oldVersion,i.transaction))}),r.then((function(e){return new se(e)}))}("firebase-installations-database",1,(e=>{switch(e.oldVersion){case 0:e.createObjectStore(Oe)}}))),ke}async function Pe(e,t){const n=Se(e),r=(await De()).transaction(Oe,"readwrite"),i=r.objectStore(Oe),o=await i.get(n);return await i.put(t,n),await r.complete,o&&o.fid===t.fid||Ce(e,t.fid),t}async function Re(e){const t=Se(e),n=(await De()).transaction(Oe,"readwrite");await n.objectStore(Oe).delete(t),await n.complete}async function xe(e,t){const n=Se(e),r=(await De()).transaction(Oe,"readwrite"),i=r.objectStore(Oe),o=await i.get(n),a=t(o);return void 0===a?await i.delete(n):await i.put(a,n),await r.complete,!a||o&&o.fid===a.fid||Ce(e,a.fid),a}async function Le(e){let t;const n=await xe(e,(n=>{const r=function(e){return Be(e||{fid:Ee(),registrationStatus:0})}(n),i=function(e,t){if(0===t.registrationStatus){if(!navigator.onLine){return{installationEntry:t,registrationPromise:Promise.reject(de.create("app-offline"))}}const n={fid:t.fid,registrationStatus:1,registrationTime:Date.now()};return{installationEntry:n,registrationPromise:async function(e,t){try{return Pe(e,await async function(e,{fid:t}){const n=me(e),r=ye(e),i={fid:t,authVersion:pe,appId:e.appId,sdkVersion:le},o={method:"POST",headers:r,body:JSON.stringify(i)},a=await we((()=>fetch(n,o)));if(a.ok){const e=await a.json();return{fid:e.fid||t,registrationStatus:2,refreshToken:e.refreshToken,authToken:ge(e.authToken)}}throw await ve("Create Installation",a)}(e,t))}catch(n){throw he(n)&&409===n.customData.serverCode?await Re(e):await Pe(e,{fid:t.fid,registrationStatus:0}),n}}(e,n)}}return 1===t.registrationStatus?{installationEntry:t,registrationPromise:je(e)}:{installationEntry:t}}(e,r);return t=i.registrationPromise,i.installationEntry}));return""===n.fid?{installationEntry:await t}:{installationEntry:n,registrationPromise:t}}async function je(e){let t=await Me(e);for(;1===t.registrationStatus;)await _e(100),t=await Me(e);if(0===t.registrationStatus){const{installationEntry:t,registrationPromise:n}=await Le(e);return n||t}return t}function Me(e){return xe(e,(e=>{if(!e)throw de.create("installation-not-found");return Be(e)}))}function Be(e){return 1===(t=e).registrationStatus&&t.registrationTime+ue<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function Fe({appConfig:e,platformLoggerProvider:t},n){const r=function(e,{fid:t}){return`${me(e)}/${t}/authTokens:generate`}(e,n),i=be(e,n),o=t.getImmediate({optional:!0});o&&i.append("x-firebase-client",o.getPlatformInfoString());const a={installation:{sdkVersion:le}},s={method:"POST",headers:i,body:JSON.stringify(a)},c=await we((()=>fetch(r,s)));if(c.ok){return ge(await c.json())}throw await ve("Generate Auth Token",c)}async function Ue(e,t=!1){let n;const r=await xe(e.appConfig,(r=>{if(!qe(r))throw de.create("not-registered");const i=r.authToken;if(!t&&function(e){return 2===e.requestStatus&&!function(e){const t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+fe}(e)}(i))return r;if(1===i.requestStatus)return n=async function(e,t){let n=await $e(e.appConfig);for(;1===n.authToken.requestStatus;)await _e(100),n=await $e(e.appConfig);const r=n.authToken;return 0===r.requestStatus?Ue(e,t):r}(e,t),r;{if(!navigator.onLine)throw de.create("app-offline");const t=function(e){const t={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},e),{authToken:t})}(r);return n=async function(e,t){try{const n=await Fe(e,t),r=Object.assign(Object.assign({},t),{authToken:n});return await Pe(e.appConfig,r),n}catch(n){if(!he(n)||401!==n.customData.serverCode&&404!==n.customData.serverCode){const n=Object.assign(Object.assign({},t),{authToken:{requestStatus:0}});await Pe(e.appConfig,n)}else await Re(e.appConfig);throw n}}(e,t),t}}));return n?await n:r.authToken}function $e(e){return xe(e,(e=>{if(!qe(e))throw de.create("not-registered");const t=e.authToken;return 1===(n=t).requestStatus&&n.requestTime+ue<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e;var n}))}function qe(e){return void 0!==e&&2===e.registrationStatus}async function ze(e,t=!1){const n=e;await async function(e){const{registrationPromise:t}=await Le(e);t&&await t}(n.appConfig);return(await Ue(n,t)).token}function Ve(e){return de.create("missing-app-config-values",{valueName:e})}const He="installations-exp",Ke=e=>{const t=R(e.getProvider("app-exp").getImmediate(),He).getImmediate();return{getId:()=>async function(e){const t=e,{installationEntry:n,registrationPromise:r}=await Le(t.appConfig);return r?r.catch(console.error):Ue(t).catch(console.error),n.fid}(t),getToken:e=>ze(t,e)}};P(new f(He,(e=>{const t=e.getProvider("app-exp").getImmediate();return{app:t,appConfig:function(e){if(!e||!e.options)throw Ve("App Configuration");if(!e.name)throw Ve("App Name");const t=["projectId","apiKey","appId"];for(const n of t)if(!e.options[n])throw Ve(n);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t),platformLoggerProvider:R(t,"platform-logger"),_delete:()=>Promise.resolve()}}),"PUBLIC")),P(new f("installations-exp-internal",Ke,"PRIVATE")),F("@firebase/installations-exp",ce);const We="0.0.900-exp.6ef484a04",Ge=We,Je="FB-PERF-TRACE-MEASURE",Ye="_wt_",Xe="_fcp",Ze="_fid",Qe="@firebase/performance/config",et="@firebase/performance/configexpire",tt="Performance",nt=new u("performance",tt,{"trace started":"Trace {$traceName} was started before.","trace stopped":"Trace {$traceName} is not running.","nonpositive trace startTime":"Trace {$traceName} startTime should be positive.","nonpositive trace duration":"Trace {$traceName} duration should be positive.","no window":"Window is not available.","no app id":"App id is not available.","no project id":"Project id is not available.","no api key":"Api key is not available.","invalid cc log":"Attempted to queue invalid cc event","FB not default":"Performance can only start when Firebase app instance is the default one.","RC response not ok":"RC response is not ok","invalid attribute name":"Attribute name {$attributeName} is invalid.","invalid attribute value":"Attribute value {$attributeValue} is invalid.","invalid custom metric name":"Custom metric name {$customMetricName} is invalid","invalid String merger input":"Input for String merger is invalid, contact support team to resolve.","already initialized":"Performance can only be initialized once."}),rt=new E(tt);let it,ot,at,st;rt.logLevel=g.INFO;class ct{constructor(e){if(this.window=e,!e)throw nt.create("no window");this.performance=e.performance,this.PerformanceObserver=e.PerformanceObserver,this.windowLocation=e.location,this.navigator=e.navigator,this.document=e.document,this.navigator&&this.navigator.cookieEnabled&&(this.localStorage=e.localStorage),e.perfMetrics&&e.perfMetrics.onFirstInputDelay&&(this.onFirstInputDelay=e.perfMetrics.onFirstInputDelay)}getUrl(){return this.windowLocation.href.split("?")[0]}mark(e){this.performance&&this.performance.mark&&this.performance.mark(e)}measure(e,t,n){this.performance&&this.performance.measure&&this.performance.measure(e,t,n)}getEntriesByType(e){return this.performance&&this.performance.getEntriesByType?this.performance.getEntriesByType(e):[]}getEntriesByName(e){return this.performance&&this.performance.getEntriesByName?this.performance.getEntriesByName(e):[]}getTimeOrigin(){return this.performance&&(this.performance.timeOrigin||this.performance.timing.navigationStart)}requiredApisAvailable(){return fetch&&Promise&&this.navigator&&this.navigator.cookieEnabled?"indexedDB"in self&&null!=indexedDB||(rt.info("IndexedDB is not supported by current browswer"),!1):(rt.info("Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled."),!1)}setupObserver(e,t){if(!this.PerformanceObserver)return;new this.PerformanceObserver((e=>{for(const n of e.getEntries())t(n)})).observe({entryTypes:[e]})}static getInstance(){return void 0===it&&(it=new ct(ot)),it}}function ut(){return at}function lt(e,t){const n=e.length-t.length;if(n<0||n>1)throw nt.create("invalid String merger input");const r=[];for(let n=0;n<e.length;n++)r.push(e.charAt(n)),t.length>n&&r.push(t.charAt(n));return r.join("")}class pt{constructor(){this.instrumentationEnabled=!0,this.dataCollectionEnabled=!0,this.loggingEnabled=!1,this.tracesSamplingRate=1,this.networkRequestsSamplingRate=1,this.logEndPointUrl="https://firebaselogging.googleapis.com/v0cc/log?format=json_proto",this.flTransportEndpointUrl=lt("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),this.transportKey=lt("AzSC8r6ReiGqFMyfvgow","Iayx0u-XT3vksVM-pIV"),this.logSource=462,this.logTraceAfterSampling=!1,this.logNetworkAfterSampling=!1,this.configTimeToLive=12}getFlTransportFullUrl(){return this.flTransportEndpointUrl.concat("?key=",this.transportKey)}static getInstance(){return void 0===st&&(st=new pt),st}}var ft;!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.VISIBLE=1]="VISIBLE",e[e.HIDDEN=2]="HIDDEN"}(ft||(ft={}));const dt=["firebase_","google_","ga_"],ht=new RegExp("^[a-zA-Z]\\w*$");function mt(){const e=ct.getInstance().navigator;return"serviceWorker"in e?e.serviceWorker.controller?2:3:1}function gt(){switch(ct.getInstance().document.visibilityState){case"visible":return ft.VISIBLE;case"hidden":return ft.HIDDEN;default:return ft.UNKNOWN}}function vt(){const e=ct.getInstance().navigator.connection;switch(e&&e.effectiveType){case"slow-2g":return 1;case"2g":return 2;case"3g":return 3;case"4g":return 4;default:return 0}}function yt(e){var t;const n=null===(t=e.options)||void 0===t?void 0:t.appId;if(!n)throw nt.create("no app id");return n}const bt="0.0.1",wt=!0,_t="FIREBASE_INSTALLATIONS_AUTH";function It(e,t){const n=function(){const e=ct.getInstance().localStorage;if(!e)return;const t=e.getItem(et);if(!(t&&(n=t,Number(n)>Date.now())))return;var n;const r=e.getItem(Qe);if(!r)return;try{return JSON.parse(r)}catch(e){return}}();return n?(St(n),Promise.resolve()):function(e,t){return function(e){const t=e.getToken();return t.then((e=>{})),t}(e.installations).then((n=>{const r=function(e){var t;const n=null===(t=e.options)||void 0===t?void 0:t.projectId;if(!n)throw nt.create("no project id");return n}(e.app),i=function(e){var t;const n=null===(t=e.options)||void 0===t?void 0:t.apiKey;if(!n)throw nt.create("no api key");return n}(e.app),o=new Request(`https://firebaseremoteconfig.googleapis.com/v1/projects/${r}/namespaces/fireperf:fetch?key=${i}`,{method:"POST",headers:{Authorization:`${_t} ${n}`},body:JSON.stringify({app_instance_id:t,app_instance_id_token:n,app_id:yt(e.app),app_version:Ge,sdk_version:bt})});return fetch(o).then((e=>{if(e.ok)return e.json();throw nt.create("RC response not ok")}))})).catch((()=>{rt.info(Et)}))}(e,t).then(St).then((e=>function(e){const t=ct.getInstance().localStorage;if(!e||!t)return;t.setItem(Qe,JSON.stringify(e)),t.setItem(et,String(Date.now()+60*pt.getInstance().configTimeToLive*60*1e3))}(e)),(()=>{}))}const Et="Could not fetch config, will use default configs";function St(e){if(!e)return e;const t=pt.getInstance(),n=e.entries||{};return void 0!==n.fpr_enabled?t.loggingEnabled="true"===String(n.fpr_enabled):t.loggingEnabled=wt,n.fpr_log_source&&(t.logSource=Number(n.fpr_log_source)),n.fpr_log_endpoint_url&&(t.logEndPointUrl=n.fpr_log_endpoint_url),n.fpr_log_transport_key&&(t.transportKey=n.fpr_log_transport_key),void 0!==n.fpr_vc_network_request_sampling_rate&&(t.networkRequestsSamplingRate=Number(n.fpr_vc_network_request_sampling_rate)),void 0!==n.fpr_vc_trace_sampling_rate&&(t.tracesSamplingRate=Number(n.fpr_vc_trace_sampling_rate)),t.logTraceAfterSampling=Tt(t.tracesSamplingRate),t.logNetworkAfterSampling=Tt(t.networkRequestsSamplingRate),e}function Tt(e){return Math.random()<=e}let Ct,At=1;function Nt(e){return At=2,Ct=Ct||function(e){return function(){const e=ct.getInstance().document;return new Promise((t=>{if(e&&"complete"!==e.readyState){const n=()=>{"complete"===e.readyState&&(e.removeEventListener("readystatechange",n),t())};e.addEventListener("readystatechange",n)}else t()}))}().then((()=>function(e){const t=e.getId();return t.then((e=>{at=e})),t}(e.installations))).then((t=>It(e,t))).then((()=>Ot()),(()=>Ot()))}(e),Ct}function Ot(){At=3}const kt=1e4;let Dt,Pt=3,Rt=[],xt=!1;function Lt(e){setTimeout((()=>{if(0!==Pt)return Rt.length?void function(){const e=Rt.splice(0,1e3),t=e.map((e=>({source_extension_json_proto3:e.message,event_time_ms:String(e.eventTime)})));(function(e,t){return function(e){const t=pt.getInstance().getFlTransportFullUrl();return fetch(t,{method:"POST",body:JSON.stringify(e)})}(e).then((e=>(e.ok||rt.info("Call to Firebase backend failed."),e.json()))).then((e=>{const n=Number(e.nextRequestWaitMillis);let r=kt;isNaN(n)||(r=Math.max(n,r));const i=e.logResponseDetails;Array.isArray(i)&&i.length>0&&"RETRY_REQUEST_LATER"===i[0].responseAction&&(Rt=[...t,...Rt],rt.info("Retry transport request later.")),Pt=3,Lt(r)}))})({request_time_ms:String(Date.now()),client_info:{client_type:1,js_client_info:{}},log_source:pt.getInstance().logSource,log_event:t},e).catch((()=>{Rt=[...e,...Rt],Pt--,rt.info(`Tries left: ${Pt}.`),Lt(kt)}))}():Lt(kt)}),e)}function jt(e){return(...t)=>{!function(e){if(!e.eventTime||!e.message)throw nt.create("invalid cc log");Rt=[...Rt,e]}({message:e(...t),eventTime:Date.now()})}}function Mt(e,t){Dt||(Dt=jt(Ut)),Dt(e,t)}function Bt(e){const t=pt.getInstance();!t.instrumentationEnabled&&e.isAuto||(t.dataCollectionEnabled||e.isAuto)&&ct.getInstance().requiredApisAvailable()&&(e.isAuto&&gt()!==ft.VISIBLE||(3===At?Ft(e):Nt(e.performanceController).then((()=>Ft(e)),(()=>Ft(e)))))}function Ft(e){if(!ut())return;const t=pt.getInstance();t.loggingEnabled&&t.logTraceAfterSampling&&setTimeout((()=>Mt(e,1)),0)}function Ut(e,t){return 0===t?function(e){const t={url:e.url,http_method:e.httpMethod||0,http_response_code:200,response_payload_bytes:e.responsePayloadBytes,client_start_time_us:e.startTimeUs,time_to_response_initiated_us:e.timeToResponseInitiatedUs,time_to_response_completed_us:e.timeToResponseCompletedUs},n={application_info:$t(e.performanceController.app),network_request_metric:t};return JSON.stringify(n)}(e):function(e){const t={name:e.name,is_auto:e.isAuto,client_start_time_us:e.startTimeUs,duration_us:e.durationUs};0!==Object.keys(e.counters).length&&(t.counters=e.counters);const n=e.getAttributes();0!==Object.keys(n).length&&(t.custom_attributes=n);const r={application_info:$t(e.performanceController.app),trace_metric:t};return JSON.stringify(r)}(e)}function $t(e){return{google_app_id:yt(e),app_instance_id:ut(),web_app_info:{sdk_version:Ge,page_url:ct.getInstance().getUrl(),service_worker_status:mt(),visibility_state:gt(),effective_connection_type:vt()},application_process_state:0}}const qt=["_fp",Xe,Ze];class zt{constructor(e,t,n=!1,r){this.performanceController=e,this.name=t,this.isAuto=n,this.state=1,this.customAttributes={},this.counters={},this.api=ct.getInstance(),this.randomId=Math.floor(1e6*Math.random()),this.isAuto||(this.traceStartMark=`FB-PERF-TRACE-START-${this.randomId}-${this.name}`,this.traceStopMark=`FB-PERF-TRACE-STOP-${this.randomId}-${this.name}`,this.traceMeasure=r||`FB-PERF-TRACE-MEASURE-${this.randomId}-${this.name}`,r&&this.calculateTraceMetrics())}start(){if(1!==this.state)throw nt.create("trace started",{traceName:this.name});this.api.mark(this.traceStartMark),this.state=2}stop(){if(2!==this.state)throw nt.create("trace stopped",{traceName:this.name});this.state=3,this.api.mark(this.traceStopMark),this.api.measure(this.traceMeasure,this.traceStartMark,this.traceStopMark),this.calculateTraceMetrics(),Bt(this)}record(e,t,n){if(e<=0)throw nt.create("nonpositive trace startTime",{traceName:this.name});if(t<=0)throw nt.create("nonpositive trace duration",{traceName:this.name});if(this.durationUs=Math.floor(1e3*t),this.startTimeUs=Math.floor(1e3*e),n&&n.attributes&&(this.customAttributes=Object.assign({},n.attributes)),n&&n.metrics)for(const e of Object.keys(n.metrics))isNaN(Number(n.metrics[e]))||(this.counters[e]=Number(Math.floor(n.metrics[e])));Bt(this)}incrementMetric(e,t=1){void 0===this.counters[e]?this.putMetric(e,t):this.putMetric(e,this.counters[e]+t)}putMetric(e,t){if(!function(e,t){return!(0===e.length||e.length>100)&&(t&&t.startsWith(Ye)&&qt.indexOf(e)>-1||!e.startsWith("_"))}(e,this.name))throw nt.create("invalid custom metric name",{customMetricName:e});this.counters[e]=function(e){const t=Math.floor(e);return t<e&&rt.info(`Metric value should be an Integer, setting the value as : ${t}.`),t}(t)}getMetric(e){return this.counters[e]||0}putAttribute(e,t){const n=function(e){return!(0===e.length||e.length>40)&&(!dt.some((t=>e.startsWith(t)))&&!!e.match(ht))}(e),r=function(e){return 0!==e.length&&e.length<=100}(t);if(n&&r)this.customAttributes[e]=t;else{if(!n)throw nt.create("invalid attribute name",{attributeName:e});if(!r)throw nt.create("invalid attribute value",{attributeValue:t})}}getAttribute(e){return this.customAttributes[e]}removeAttribute(e){void 0!==this.customAttributes[e]&&delete this.customAttributes[e]}getAttributes(){return Object.assign({},this.customAttributes)}setStartTime(e){this.startTimeUs=e}setDuration(e){this.durationUs=e}calculateTraceMetrics(){const e=this.api.getEntriesByName(this.traceMeasure),t=e&&e[0];t&&(this.durationUs=Math.floor(1e3*t.duration),this.startTimeUs=Math.floor(1e3*(t.startTime+this.api.getTimeOrigin())))}static createOobTrace(e,t,n,r){const i=ct.getInstance().getUrl();if(!i)return;const o=new zt(e,Ye+i,!0),a=Math.floor(1e3*ct.getInstance().getTimeOrigin());o.setStartTime(a),t&&t[0]&&(o.setDuration(Math.floor(1e3*t[0].duration)),o.putMetric("domInteractive",Math.floor(1e3*t[0].domInteractive)),o.putMetric("domContentLoadedEventEnd",Math.floor(1e3*t[0].domContentLoadedEventEnd)),o.putMetric("loadEventEnd",Math.floor(1e3*t[0].loadEventEnd)));if(n){const e=n.find((e=>"first-paint"===e.name));e&&e.startTime&&o.putMetric("_fp",Math.floor(1e3*e.startTime));const t=n.find((e=>"first-contentful-paint"===e.name));t&&t.startTime&&o.putMetric(Xe,Math.floor(1e3*t.startTime)),r&&o.putMetric(Ze,Math.floor(1e3*r))}Bt(o)}static createUserTimingTrace(e,t){Bt(new zt(e,t,!1,t))}}function Vt(e,t){const n=t;if(!n||void 0===n.responseStart)return;const r=ct.getInstance().getTimeOrigin(),i=Math.floor(1e3*(n.startTime+r)),o=n.responseStart?Math.floor(1e3*(n.responseStart-n.startTime)):void 0,a=Math.floor(1e3*(n.responseEnd-n.startTime));!function(e){const t=pt.getInstance();if(!t.instrumentationEnabled)return;const n=e.url,r=t.logEndPointUrl.split("?")[0],i=t.flTransportEndpointUrl.split("?")[0];n!==r&&n!==i&&t.loggingEnabled&&t.logNetworkAfterSampling&&setTimeout((()=>Mt(e,0)),0)}({performanceController:e,url:n.name&&n.name.split("?")[0],responsePayloadBytes:n.transferSize,startTimeUs:i,timeToResponseInitiatedUs:o,timeToResponseCompletedUs:a})}function Ht(e){ut()&&(setTimeout((()=>function(e){const t=ct.getInstance(),n=t.getEntriesByType("navigation"),r=t.getEntriesByType("paint");if(t.onFirstInputDelay){let i=setTimeout((()=>{zt.createOobTrace(e,n,r),i=void 0}),5e3);t.onFirstInputDelay((t=>{i&&(clearTimeout(i),zt.createOobTrace(e,n,r,t))}))}else zt.createOobTrace(e,n,r)}(e)),0),setTimeout((()=>function(e){const t=ct.getInstance(),n=t.getEntriesByType("resource");for(const t of n)Vt(e,t);t.setupObserver("resource",(t=>Vt(e,t)))}(e)),0),setTimeout((()=>function(e){const t=ct.getInstance(),n=t.getEntriesByType("measure");for(const t of n)Kt(e,t);t.setupObserver("measure",(t=>Kt(e,t)))}(e)),0))}function Kt(e,t){const n=t.name;n.substring(0,Je.length)!==Je&&zt.createUserTimingTrace(e,n)}class Wt{constructor(e,t){this.app=e,this.installations=t,this.initialized=!1}_init(e){this.initialized||(void 0!==(null==e?void 0:e.dataCollectionEnabled)&&(this.dataCollectionEnabled=e.dataCollectionEnabled),void 0!==(null==e?void 0:e.instrumentationEnabled)&&(this.instrumentationEnabled=e.instrumentationEnabled),ct.getInstance().requiredApisAvailable()?new Promise((function(e,t){try{var n=!0,r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=function(){i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=function(){n=!1},i.onerror=function(){var e;t((null===(e=i.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}})).then((e=>{e&&(xt||(Lt(5500),xt=!0),Nt(this).then((()=>Ht(this)),(()=>Ht(this))),this.initialized=!0)})).catch((e=>{rt.info(`Environment doesn't support IndexedDB: ${e}`)})):rt.info('Firebase Performance cannot start if the browser does not support "Fetch" and "Promise", or cookies are disabled.'))}set instrumentationEnabled(e){pt.getInstance().instrumentationEnabled=e}get instrumentationEnabled(){return pt.getInstance().instrumentationEnabled}set dataCollectionEnabled(e){pt.getInstance().dataCollectionEnabled=e}get dataCollectionEnabled(){return pt.getInstance().dataCollectionEnabled}}P(new f("performance-exp",((e,{options:t})=>{const n=e.getProvider("app-exp").getImmediate(),r=e.getProvider("installations-exp-internal").getImmediate();if("[DEFAULT]"!==n.name)throw nt.create("FB not default");if("undefined"==typeof window)throw nt.create("no window");!function(e){ot=e}(window);const i=new Wt(n,r);return i._init(t),i}),"PUBLIC")),F("@firebase/performance-exp",We);class Gt{constructor(e,t){this.app=e,this._delegate=t}get instrumentationEnabled(){return this._delegate.instrumentationEnabled}set instrumentationEnabled(e){this._delegate.instrumentationEnabled=e}get dataCollectionEnabled(){return this._delegate.dataCollectionEnabled}set dataCollectionEnabled(e){this._delegate.dataCollectionEnabled=e}trace(e){return function(e,t){var n;return e=(n=e)&&n._delegate?n._delegate:n,new zt(e,t)}(this._delegate,e)}}function Jt(e){const t=e.getProvider("app-compat").getImmediate(),n=e.getProvider("performance-exp").getImmediate();return new Gt(t,n)}var Yt;(Yt=W).INTERNAL.registerComponent(new f("performance-compat",Jt,"PUBLIC")),Yt.registerVersion("@firebase/performance-compat","0.0.900-exp.6ef484a04");return W.registerVersion("firebase-exp","9.0.0-beta.7","compat-lite"),W})); //# sourceMappingURL=firebase-performance-standalone-compat.es2017.js.map