text: !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("@firebase/app-compat"),require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app-compat","@firebase/app"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).firebase,e.firebase.INTERNAL.modularAPIs)}(this,function(ct,lt){"use strict";try{!(function(){function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t,r=e(ct);class o extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,o.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,n.prototype.create)}}class n{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){var n,r=t[0]||{},i=`${this.service}/${e}`,a=this.errors[e],a=a?(n=r,a.replace(s,(e,t)=>{var r=n[t];return null!=r?String(r):`<${t}?>`})):"Error",a=`${this.serviceName}: ${a} (${i}).`;return new o(i,a,r)}}const s=/\{\$([^}]+)}/g;function i(e,n){return new Promise((t,r)=>{e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{var t;r(`${n}: ${null===(t=e.target.error)||void 0===t?void 0:t.message}`)}})}class c{constructor(e){this._db=e,this.objectStoreNames=this._db.objectStoreNames}transaction(e,t="readonly"){return new l(this._db.transaction.call(this._db,e,t))}createObjectStore(e,t){return new a(this._db.createObjectStore(e,t))}close(){this._db.close()}}class l{constructor(e){this._transaction=e,this.complete=new Promise((e,t)=>{this._transaction.oncomplete=function(){e()},this._transaction.onerror=()=>{t(this._transaction.error)},this._transaction.onabort=()=>{t(this._transaction.error)}})}objectStore(e){return new a(this._transaction.objectStore(e))}}class a{constructor(e){this._store=e}index(e){return new u(this._store.index(e))}createIndex(e,t,r){return new u(this._store.createIndex(e,t,r))}get(e){return i(this._store.get(e),"Error reading from IndexedDB")}put(e,t){return i(this._store.put(e,t),"Error writing to IndexedDB")}delete(e){return i(this._store.delete(e),"Error deleting from IndexedDB")}clear(){return i(this._store.clear(),"Error clearing IndexedDB object store")}}class u{constructor(e){this._index=e}get(e){return i(this._index.get(e),"Error reading from IndexedDB")}}class d{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,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}}(de=t=t||{})[de.DEBUG=0]="DEBUG",de[de.VERBOSE=1]="VERBOSE",de[de.INFO=2]="INFO",de[de.WARN=3]="WARN",de[de.ERROR=4]="ERROR",de[de.SILENT=5]="SILENT";const p={debug:t.DEBUG,verbose:t.VERBOSE,info:t.INFO,warn:t.WARN,error:t.ERROR,silent:t.SILENT},f=t.INFO,g={[t.DEBUG]:"log",[t.VERBOSE]:"log",[t.INFO]:"info",[t.WARN]:"warn",[t.ERROR]:"error"},h=(e,t,...r)=>{if(!(t<e.logLevel)){var n=(new Date).toISOString(),i=g[t];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[i](`[${n}]  ${e.name}:`,...r)}};var m="@firebase/installations",v="0.5.8";const b=1e4,w=`w:${v}`,_="FIS_v2",E="https://firebaseinstallations.googleapis.com/v1",y=36e5;const I=new n("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 T(e){return e instanceof o&&e.code.includes("request-failed")}function S({projectId:e}){return`${E}/projects/${e}/installations`}function N(e){return{token:e.token,requestStatus:2,expiresIn:(e=e.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()}}async function k(e,t){var r=(await t.json()).error;return I.create("request-failed",{requestName:e,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function C({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function A(e,{refreshToken:t}){const r=C(e);return r.append("Authorization",(t=t,`${_} ${t}`)),r}async function O(e){var t=await e();return 500<=t.status&&t.status<600?e():t}function R(t){return new Promise(e=>{setTimeout(e,t)})}const P=/^[cdef][\w-]{21}$/,M="";function B(){try{const t=new Uint8Array(17),r=self.crypto||self.msCrypto;r.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 P.test(e)?e:M}catch(e){return M}}function L(e){return`${e.appName}!${e.appId}`}const j=new Map;function $(e,t){var r=L(e);D(r,t),function(e,t){const r=function(){!U&&"BroadcastChannel"in self&&(U=new BroadcastChannel("[Firebase] FID Change"),U.onmessage=e=>{D(e.data.key,e.data.fid)});return U}();r&&r.postMessage({key:e,fid:t});0===j.size&&U&&(U.close(),U=null)}(r,t)}function D(e,t){var r=j.get(e);if(r)for(const n of r)n(t)}let U=null;const F="firebase-installations-store";let q=null;function x(){var e,i,a;return q=q||(e="firebase-installations-database",i=1,a=(e,t)=>{0===t&&e.createObjectStore(F)},new Promise((t,r)=>{try{const n=indexedDB.open(e,i);n.onsuccess=e=>{t(new c(e.target.result))},n.onerror=e=>{var t;r(`Error opening indexedDB: ${null===(t=e.target.error)||void 0===t?void 0:t.message}`)},n.onupgradeneeded=e=>{a(new c(n.result),e.oldVersion,e.newVersion,new l(n.transaction))}}catch(e){r(`Error opening indexedDB: ${e.message}`)}})),q}async function H(e,t){var r=L(e);const n=await x(),i=n.transaction(F,"readwrite"),a=i.objectStore(F);var o=await a.get(r);return await a.put(t,r),await i.complete,o&&o.fid===t.fid||$(e,t.fid),t}async function V(e){var t=L(e);const r=await x(),n=r.transaction(F,"readwrite");await n.objectStore(F).delete(t),await n.complete}async function W(e,t){var r=L(e);const n=await x(),i=n.transaction(F,"readwrite"),a=i.objectStore(F);var o=await a.get(r),s=t(o);return void 0===s?await a.delete(r):await a.put(s,r),await i.complete,!s||o&&o.fid===s.fid||$(e,s.fid),s}async function z(r){let n;var e=await W(r.appConfig,e=>{var t=G(e||{fid:B(),registrationStatus:0}),t=function(e,t){{if(0!==t.registrationStatus)return 1===t.registrationStatus?{installationEntry:t,registrationPromise:async function(e){let t=await K(e.appConfig);for(;1===t.registrationStatus;)await R(100),t=await K(e.appConfig);if(0!==t.registrationStatus)return t;{var{installationEntry:r,registrationPromise:n}=await z(e);return n||r}}(e)}:{installationEntry:t};if(!navigator.onLine){var r=Promise.reject(I.create("app-offline"));return{installationEntry:t,registrationPromise:r}}var n={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},r=async function(t,r){try{var e=await async function({appConfig:e,heartbeatServiceProvider:t},{fid:r}){const n=S(e),i=C(e),a=t.getImmediate({optional:!0});!a||(o=await a.getHeartbeatsHeader())&&i.append("x-firebase-client",o);var o={fid:r,authVersion:_,appId:e.appId,sdkVersion:w};const s={method:"POST",headers:i,body:JSON.stringify(o)},c=await O(()=>fetch(n,s));if(c.ok){o=await c.json();return{fid:o.fid||r,registrationStatus:2,refreshToken:o.refreshToken,authToken:N(o.authToken)}}throw await k("Create Installation",c)}(t,r);return H(t.appConfig,e)}catch(e){throw T(e)&&409===e.customData.serverCode?await V(t.appConfig):await H(t.appConfig,{fid:r.fid,registrationStatus:0}),e}}(e,n);return{installationEntry:n,registrationPromise:r}}}(r,t);return n=t.registrationPromise,t.installationEntry});return e.fid===M?{installationEntry:await n}:{installationEntry:e,registrationPromise:n}}function K(e){return W(e,e=>{if(!e)throw I.create("installation-not-found");return G(e)})}function G(e){return 1===(t=e).registrationStatus&&t.registrationTime+b<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function J({appConfig:e,heartbeatServiceProvider:t},r){const n=([i,a]=[e,r["fid"]],`${S(i)}/${a}/authTokens:generate`);var i,a;const o=A(e,r),s=t.getImmediate({optional:!0});!s||(c=await s.getHeartbeatsHeader())&&o.append("x-firebase-client",c);var c={installation:{sdkVersion:w,appId:e.appId}};const l={method:"POST",headers:o,body:JSON.stringify(c)},u=await O(()=>fetch(n,l));if(u.ok)return N(await u.json());throw await k("Generate Auth Token",u)}async function Y(n,i=!1){let a;var e=await W(n.appConfig,e=>{if(!Q(e))throw I.create("not-registered");var t,r=e.authToken;if(i||2!==(t=r).requestStatus||function(e){var t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+y}(t)){if(1===r.requestStatus)return a=async function(e,t){let r=await Z(e.appConfig);for(;1===r.authToken.requestStatus;)await R(100),r=await Z(e.appConfig);var n=r.authToken;return 0===n.requestStatus?Y(e,t):n}(n,i),e;if(!navigator.onLine)throw I.create("app-offline");r=(t=e,r={requestStatus:1,requestTime:Date.now()},Object.assign(Object.assign({},t),{authToken:r}));return a=async function(t,r){try{var n=await J(t,r),e=Object.assign(Object.assign({},r),{authToken:n});return await H(t.appConfig,e),n}catch(e){throw!T(e)||401!==e.customData.serverCode&&404!==e.customData.serverCode?(n=Object.assign(Object.assign({},r),{authToken:{requestStatus:0}}),await H(t.appConfig,n)):await V(t.appConfig),e}}(n,r),r}return e});return a?await a:e.authToken}function Z(e){return W(e,e=>{if(!Q(e))throw I.create("not-registered");var t,r=e.authToken;return 1===(t=r).requestStatus&&t.requestTime+b<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}function Q(e){return void 0!==e&&2===e.registrationStatus}async function X(e,t=!1){var r,n=e;return await((r=(await z(n)).registrationPromise)&&await r),(await Y(n,t)).token}function ee(e){return I.create("missing-app-config-values",{valueName:e})}const te="installations",re=e=>{var t=e.getProvider("app").getImmediate();return{app:t,appConfig:function(e){if(!e||!e.options)throw ee("App Configuration");if(!e.name)throw ee("App Name");for(const t of["projectId","apiKey","appId"])if(!e.options[t])throw ee(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t),heartbeatServiceProvider:lt._getProvider(t,"heartbeat"),_delete:()=>Promise.resolve()}},ne=e=>{var t=e.getProvider("app").getImmediate();const r=lt._getProvider(t,te).getImmediate();return{getId:()=>async function(e){var t=e;const{installationEntry:r,registrationPromise:n}=await z(t);return(n||Y(t)).catch(console.error),r.fid}(r),getToken:e=>X(r,e)}};lt._registerComponent(new d(te,re,"PUBLIC")),lt._registerComponent(new d("installations-internal",ne,"PRIVATE")),lt.registerVersion(m,v),lt.registerVersion(m,v,"esm2017");const ie="@firebase/performance",ae="0.5.8",oe=ae,se="FB-PERF-TRACE-MEASURE",ce="@firebase/performance/config",le="@firebase/performance/configexpire";var ue,de,pe,v="Performance";const fe=new n("performance",v,{"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":"initializePerformance() has already been called with different options. To avoid this error, call initializePerformance() with the same options as when it was originally called, or call getPerformance() to return the already initialized instance."}),ge=new class{constructor(e){this.name=e,this._logLevel=f,this._logHandler=h,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in t))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?p[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,t.DEBUG,...e),this._logHandler(this,t.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,t.VERBOSE,...e),this._logHandler(this,t.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,t.INFO,...e),this._logHandler(this,t.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,t.WARN,...e),this._logHandler(this,t.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,t.ERROR,...e),this._logHandler(this,t.ERROR,...e)}}(v);ge.logLevel=t.INFO;let he,me;class ve{constructor(e){if(!(this.window=e))throw fe.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,r){this.performance&&this.performance.measure&&this.performance.measure(e,t,r)}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&&"undefined"!=typeof navigator&&navigator.cookieEnabled?"object"==typeof indexedDB||(ge.info("IndexedDB is not supported by current browswer"),!1):(ge.info("Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled."),!1)}setupObserver(e,r){if(this.PerformanceObserver){const t=new this.PerformanceObserver(e=>{for(const t of e.getEntries())r(t)});t.observe({entryTypes:[e]})}}static getInstance(){return void 0===he&&(he=new ve(me)),he}}let be;function we(e,t){var r=e.length-t.length;if(r<0||1<r)throw fe.create("invalid String merger input");const n=[];for(let i=0;i<e.length;i++)n.push(e.charAt(i)),t.length>i&&n.push(t.charAt(i));return n.join("")}let _e;class Ee{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=we("hts/frbslgigp.ogepscmv/ieo/eaylg","tp:/ieaeogn-agolai.o/1frlglgc/o"),this.transportKey=we("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===_e&&(_e=new Ee),_e}}(de=ue=ue||{})[de.UNKNOWN=0]="UNKNOWN",de[de.VISIBLE=1]="VISIBLE",de[de.HIDDEN=2]="HIDDEN";const ye=["firebase_","google_","ga_"],Ie=new RegExp("^[a-zA-Z]\\w*$");function Te(){switch(ve.getInstance().document.visibilityState){case"visible":return ue.VISIBLE;case"hidden":return ue.HIDDEN;default:return ue.UNKNOWN}}function Se(e){var t=null===(t=e.options)||void 0===t?void 0:t.appId;if(!t)throw fe.create("no app id");return t}const Ne="0.0.1",ke={loggingEnabled:!0},Ce="FIREBASE_INSTALLATIONS_AUTH";function Ae(e,t){var n,i,r=function(){const e=ve.getInstance().localStorage;if(e){var t=e.getItem(le);if(t&&function(e){return Number(e)>Date.now()}(t)){t=e.getItem(ce);if(t)try{return JSON.parse(t)}catch(e){return}}}}();return r?(Re(r),Promise.resolve()):(i=t,function(e){const t=e.getToken();return t.then(e=>{}),t}((n=e).installations).then(e=>{var t=function(e){var t=null===(t=e.options)||void 0===t?void 0:t.projectId;if(!t)throw fe.create("no project id");return t}(n.app),r=function(e){var t=null===(t=e.options)||void 0===t?void 0:t.apiKey;if(!t)throw fe.create("no api key");return t}(n.app),r=new Request(`https://firebaseremoteconfig.googleapis.com/v1/projects/${t}/namespaces/fireperf:fetch?key=${r}`,{method:"POST",headers:{Authorization:`${Ce} ${e}`},body:JSON.stringify({app_instance_id:i,app_instance_id_token:e,app_id:Se(n.app),app_version:oe,sdk_version:Ne})});return fetch(r).then(e=>{if(e.ok)return e.json();throw fe.create("RC response not ok")})}).catch(()=>{ge.info(Oe)}).then(Re).then(e=>function(e){const t=ve.getInstance().localStorage;e&&t&&(t.setItem(ce,JSON.stringify(e)),t.setItem(le,String(Date.now()+60*Ee.getInstance().configTimeToLive*60*1e3)))}(e),()=>{}))}const Oe="Could not fetch config, will use default configs";function Re(e){if(!e)return e;const t=Ee.getInstance();var r=e.entries||{};return void 0!==r.fpr_enabled?t.loggingEnabled="true"===String(r.fpr_enabled):t.loggingEnabled=ke.loggingEnabled,r.fpr_log_source&&(t.logSource=Number(r.fpr_log_source)),r.fpr_log_endpoint_url&&(t.logEndPointUrl=r.fpr_log_endpoint_url),r.fpr_log_transport_key&&(t.transportKey=r.fpr_log_transport_key),void 0!==r.fpr_vc_network_request_sampling_rate&&(t.networkRequestsSamplingRate=Number(r.fpr_vc_network_request_sampling_rate)),void 0!==r.fpr_vc_trace_sampling_rate&&(t.tracesSamplingRate=Number(r.fpr_vc_trace_sampling_rate)),t.logTraceAfterSampling=Pe(t.tracesSamplingRate),t.logNetworkAfterSampling=Pe(t.networkRequestsSamplingRate),e}function Pe(e){return Math.random()<=e}let Me=1,Be;function Le(e){var t;return Me=2,Be=Be||(t=e,function(){const r=ve.getInstance().document;return new Promise(e=>{if(r&&"complete"!==r.readyState){const t=()=>{"complete"===r.readyState&&(r.removeEventListener("readystatechange",t),e())};r.addEventListener("readystatechange",t)}else e()})}().then(()=>function(e){const t=e.getId();return t.then(e=>{be=e}),t}(t.installations)).then(e=>Ae(t,e)).then(()=>je(),()=>je())),Be}function je(){Me=3}const $e=1e4,De=3,Ue=1e3;let Fe=De,qe=[],xe=!1;function He(e){setTimeout(()=>{if(0!==Fe)return qe.length?void function(){const e=qe.splice(0,Ue),t=e.map(e=>({source_extension_json_proto3:e.message,event_time_ms:String(e.eventTime)})),r={request_time_ms:String(Date.now()),client_info:{client_type:1,js_client_info:{}},log_source:Ee.getInstance().logSource,log_event:t};!function(e,n){return function(e){var t=Ee.getInstance().getFlTransportFullUrl();return fetch(t,{method:"POST",body:JSON.stringify(e)})}(e).then(e=>(e.ok||ge.info("Call to Firebase backend failed."),e.json())).then(e=>{var t=Number(e.nextRequestWaitMillis);let r=$e;isNaN(t)||(r=Math.max(t,r));t=e.logResponseDetails;Array.isArray(t)&&0<t.length&&"RETRY_REQUEST_LATER"===t[0].responseAction&&(qe=[...n,...qe],ge.info("Retry transport request later.")),Fe=De,He(r)})}(r,e).catch(()=>{qe=[...e,...qe],Fe--,ge.info(`Tries left: ${Fe}.`),He($e)})}():He($e)},e)}function Ve(t){return(...e)=>{!function(e){if(!e.eventTime||!e.message)throw fe.create("invalid cc log");qe=[...qe,e]}({message:t(...e),eventTime:Date.now()})}}let We;function ze(e,t){We=We||Ve(Je),We(e,t)}function Ke(e){var t=Ee.getInstance();!t.instrumentationEnabled&&e.isAuto||(t.dataCollectionEnabled||e.isAuto)&&ve.getInstance().requiredApisAvailable()&&(e.isAuto&&Te()!==ue.VISIBLE||(3===Me?Ge(e):Le(e.performanceController).then(()=>Ge(e),()=>Ge(e))))}function Ge(e){var t;!be||(t=Ee.getInstance()).loggingEnabled&&t.logTraceAfterSampling&&setTimeout(()=>ze(e,1),0)}function Je(e,t){return 0===t?(r={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},r={application_info:Ye(e.performanceController.app),network_request_metric:r},JSON.stringify(r)):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);var r=e.getAttributes();0!==Object.keys(r).length&&(t.custom_attributes=r);r={application_info:Ye(e.performanceController.app),trace_metric:t};return JSON.stringify(r)}(e);var r}function Ye(e){return{google_app_id:Se(e),app_instance_id:be,web_app_info:{sdk_version:oe,page_url:ve.getInstance().getUrl(),service_worker_status:"serviceWorker"in(t=ve.getInstance().navigator)?t.serviceWorker.controller?2:3:1,visibility_state:Te(),effective_connection_type:function(){var e=ve.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}}()},application_process_state:0};var t}const Ze=["_fp","_fcp","_fid"];class Qe{constructor(e,t,r=!1,n){this.performanceController=e,this.name=t,this.isAuto=r,this.state=1,this.customAttributes={},this.counters={},this.api=ve.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=n||`${se}-${this.randomId}-${this.name}`,n&&this.calculateTraceMetrics())}start(){if(1!==this.state)throw fe.create("trace started",{traceName:this.name});this.api.mark(this.traceStartMark),this.state=2}stop(){if(2!==this.state)throw fe.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(),Ke(this)}record(e,t,r){if(e<=0)throw fe.create("nonpositive trace startTime",{traceName:this.name});if(t<=0)throw fe.create("nonpositive trace duration",{traceName:this.name});if(this.durationUs=Math.floor(1e3*t),this.startTimeUs=Math.floor(1e3*e),r&&r.attributes&&(this.customAttributes=Object.assign({},r.attributes)),r&&r.metrics)for(const n of Object.keys(r.metrics))isNaN(Number(r.metrics[n]))||(this.counters[n]=Math.floor(Number(r.metrics[n])));Ke(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(n=e,i=this.name,0===n.length||100<n.length||!(i&&i.startsWith("_wt_")&&-1<Ze.indexOf(n))&&n.startsWith("_"))throw fe.create("invalid custom metric name",{customMetricName:e});var r,n,i;this.counters[e]=(t=null!=t?t:0,(r=Math.floor(t))<t&&ge.info(`Metric value should be an Integer, setting the value as : ${r}.`),r)}getMetric(e){return this.counters[e]||0}putAttribute(e,t){var r,n,i=!(0===(r=e).length||40<r.length)&&(!ye.some(e=>r.startsWith(e))&&!!r.match(Ie)),a=0!==(n=t).length&&n.length<=100;if(i&&a)this.customAttributes[e]=t;else{if(!i)throw fe.create("invalid attribute name",{attributeName:e});if(!a)throw fe.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(){var e=this.api.getEntriesByName(this.traceMeasure),e=e&&e[0];e&&(this.durationUs=Math.floor(1e3*e.duration),this.startTimeUs=Math.floor(1e3*(e.startTime+this.api.getTimeOrigin())))}static createOobTrace(e,t,r,n){var i=ve.getInstance().getUrl();if(i){const a=new Qe(e,"_wt_"+i,!0);i=Math.floor(1e3*ve.getInstance().getTimeOrigin());a.setStartTime(i),t&&t[0]&&(a.setDuration(Math.floor(1e3*t[0].duration)),a.putMetric("domInteractive",Math.floor(1e3*t[0].domInteractive)),a.putMetric("domContentLoadedEventEnd",Math.floor(1e3*t[0].domContentLoadedEventEnd)),a.putMetric("loadEventEnd",Math.floor(1e3*t[0].loadEventEnd)));r&&((i=r.find(e=>"first-paint"===e.name))&&i.startTime&&a.putMetric("_fp",Math.floor(1e3*i.startTime)),(i=r.find(e=>"first-contentful-paint"===e.name))&&i.startTime&&a.putMetric("_fcp",Math.floor(1e3*i.startTime)),n&&a.putMetric("_fid",Math.floor(1e3*n))),Ke(a)}}static createUserTimingTrace(e,t){Ke(new Qe(e,t,!1,t))}}function Xe(e,t){const r=t;var n,i,a;r&&void 0!==r.responseStart&&(a=ve.getInstance().getTimeOrigin(),n=Math.floor(1e3*(r.startTime+a)),i=r.responseStart?Math.floor(1e3*(r.responseStart-r.startTime)):void 0,a=Math.floor(1e3*(r.responseEnd-r.startTime)),function(e){const t=Ee.getInstance();var r,n,i;t.instrumentationEnabled&&(r=e.url,n=t.logEndPointUrl.split("?")[0],i=t.flTransportEndpointUrl.split("?")[0],r!==n&&r!==i&&t.loggingEnabled&&t.logNetworkAfterSampling&&setTimeout(()=>ze(e,0),0))}({performanceController:e,url:r.name&&r.name.split("?")[0],responsePayloadBytes:r.transferSize,startTimeUs:n,timeToResponseInitiatedUs:i,timeToResponseCompletedUs:a}))}const et=5e3;function tt(e){be&&(setTimeout(()=>function(r){const e=ve.getInstance(),n=e.getEntriesByType("navigation"),i=e.getEntriesByType("paint");if(e.onFirstInputDelay){let t=setTimeout(()=>{Qe.createOobTrace(r,n,i),t=void 0},et);e.onFirstInputDelay(e=>{t&&(clearTimeout(t),Qe.createOobTrace(r,n,i,e))})}else Qe.createOobTrace(r,n,i)}(e),0),setTimeout(()=>function(t){const e=ve.getInstance(),r=e.getEntriesByType("resource");for(const n of r)Xe(t,n);e.setupObserver("resource",e=>Xe(t,e))}(e),0),setTimeout(()=>function(t){const e=ve.getInstance(),r=e.getEntriesByType("measure");for(const n of r)rt(t,n);e.setupObserver("measure",e=>rt(t,e))}(e),0))}function rt(e,t){const r=t.name;r.substring(0,se.length)!==se&&Qe.createUserTimingTrace(e,r)}class nt{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),ve.getInstance().requiredApisAvailable()?new Promise((t,r)=>{try{let e=!0;const n="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(n);i.onsuccess=()=>{i.result.close(),e||self.indexedDB.deleteDatabase(n),t(!0)},i.onupgradeneeded=()=>{e=!1},i.onerror=()=>{var e;r((null===(e=i.error)||void 0===e?void 0:e.message)||"")}}catch(e){r(e)}}).then(e=>{e&&(xe||(He(5500),xe=!0),Le(this).then(()=>tt(this),()=>tt(this)),this.initialized=!0)}).catch(e=>{ge.info(`Environment doesn't support IndexedDB: ${e}`)}):ge.info('Firebase Performance cannot start if the browser does not support "Fetch" and "Promise", or cookies are disabled.'))}set instrumentationEnabled(e){Ee.getInstance().instrumentationEnabled=e}get instrumentationEnabled(){return Ee.getInstance().instrumentationEnabled}set dataCollectionEnabled(e){Ee.getInstance().dataCollectionEnabled=e}get dataCollectionEnabled(){return Ee.getInstance().dataCollectionEnabled}}const it="[DEFAULT]";const at=(e,{options:t})=>{var r=e.getProvider("app").getImmediate(),n=e.getProvider("installations-internal").getImmediate();if(r.name!==it)throw fe.create("FB not default");if("undefined"==typeof window)throw fe.create("no window");e=window,me=e;const i=new nt(r,n);return i._init(t),i};lt._registerComponent(new d("performance",at,"PUBLIC")),lt.registerVersion(ie,ae),lt.registerVersion(ie,ae,"esm2017");class ot{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 t=this._delegate,r=e,t=(e=t)&&e._delegate?e._delegate:e,new Qe(t,r);var t,r}}function st(e){var t=e.getProvider("app-compat").getImmediate(),r=e.getProvider("performance").getImmediate();return new ot(t,r)}(pe=r.default).INTERNAL.registerComponent(new d("performance-compat",st,"PUBLIC")),pe.registerVersion("@firebase/performance-compat","0.1.8")}).apply(this,arguments)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-performance-compat.js - be sure to load firebase-app.js first.")}});
  //# sourceMappingURL=firebase-performance-compat.js.map
  