firebase 10.11.1-dataconnect-preview.f2ddc3d7b → 10.11.1-dataconnect-preview.42eb5e521
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/dist/esm/index.esm.js +1 -1
- package/app/dist/index.cjs.js +1 -1
- package/app/dist/index.mjs +1 -1
- package/compat/app/dist/esm/index.esm.js +1 -1
- package/compat/app/dist/index.cjs.js +1 -1
- package/compat/app/dist/index.mjs +1 -1
- package/compat/dist/esm/index.esm.js +2 -2
- package/compat/dist/index.node.cjs +2 -2
- package/compat/dist/index.rn.cjs.js +2 -2
- package/firebase-analytics-compat.js +1 -1
- package/firebase-analytics.js +1 -1
- package/firebase-app-check-compat.js +1 -1
- package/firebase-app-check.js +1 -1
- package/firebase-app-compat.js +2 -2
- package/firebase-app.js +5 -5
- package/firebase-auth-compat.js +1 -1
- package/firebase-auth-cordova.js +1 -1
- package/firebase-auth-web-extension.js +1 -1
- package/firebase-auth.js +1 -1
- package/firebase-compat.js +3 -3
- package/firebase-data-connect.js +1 -1
- package/firebase-database-compat.js +1 -1
- package/firebase-database.js +1 -1
- package/firebase-firestore-compat.js +1 -1
- package/firebase-firestore-lite.js +1 -1
- package/firebase-firestore.js +1 -1
- package/firebase-functions-compat.js +1 -1
- package/firebase-functions.js +1 -1
- package/firebase-installations-compat.js +1 -1
- package/firebase-installations.js +1 -1
- package/firebase-messaging-compat.js +1 -1
- package/firebase-messaging-sw.js +1 -1
- package/firebase-messaging.js +1 -1
- package/firebase-performance-compat.js +1 -1
- package/firebase-performance-standalone-compat.es2017.js +21 -21
- package/firebase-performance-standalone-compat.js +1 -1
- package/firebase-performance.js +1 -1
- package/firebase-remote-config-compat.js +1 -1
- package/firebase-remote-config.js +1 -1
- package/firebase-storage-compat.js +1 -1
- package/firebase-storage.js +1 -1
- package/package.json +28 -28
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!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(Ke,Ue){"use strict";try{!(function(){function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u,t,a,r=e(Ke);function g(){try{return"object"==typeof indexedDB}catch(e){return}}class c extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,c.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,i.prototype.create)}}class i{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){var a,r=t[0]||{},i=`${this.service}/${e}`,s=this.errors[e],s=s?(a=r,s.replace(n,(e,t)=>{var r=a[t];return null!=r?String(r):`<${t}?>`})):"Error",s=`${this.serviceName}: ${s} (${i}).`;return new c(i,s,r)}}const n=/\{\$([^}]+)}/g;function s(e){return e&&e._delegate?e._delegate:e}class o{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}}(t=u=u||{})[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT";const l={debug:u.DEBUG,verbose:u.VERBOSE,info:u.INFO,warn:u.WARN,error:u.ERROR,silent:u.SILENT},h=u.INFO,d={[u.DEBUG]:"log",[u.VERBOSE]:"log",[u.INFO]:"info",[u.WARN]:"warn",[u.ERROR]:"error"},f=(e,t,...r)=>{if(!(t<e.logLevel)){var a=(new Date).toISOString(),i=d[t];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[i](`[${a}] ${e.name}:`,...r)}};class p{constructor(e){this.name=e,this._logLevel=h,this._logHandler=f,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in u))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?l[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,u.DEBUG,...e),this._logHandler(this,u.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,u.VERBOSE,...e),this._logHandler(this,u.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,u.INFO,...e),this._logHandler(this,u.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,u.WARN,...e),this._logHandler(this,u.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,u.ERROR,...e),this._logHandler(this,u.ERROR,...e)}}const m=(t,e)=>e.some(e=>t instanceof e);let v,w;const _=new WeakMap,b=new WeakMap,y=new WeakMap,S=new WeakMap,E=new WeakMap;let C={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return b.get(e);if("objectStoreNames"===t)return e.objectStoreNames||y.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return L(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e}};function I(a){return a!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(w=w||[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey]).includes(a)?function(...e){return a.apply(M(this),e),L(_.get(this))}:function(...e){return L(a.apply(M(this),e))}:function(e,...t){var r=a.call(M(this),e,...t);return y.set(r,e.sort?e.sort():[e]),L(r)}}function T(e){return"function"==typeof e?I(e):(e instanceof IDBTransaction&&(s=e,b.has(s)||(t=new Promise((e,t)=>{const r=()=>{s.removeEventListener("complete",a),s.removeEventListener("error",i),s.removeEventListener("abort",i)},a=()=>{e(),r()},i=()=>{t(s.error||new DOMException("AbortError","AbortError")),r()};s.addEventListener("complete",a),s.addEventListener("error",i),s.addEventListener("abort",i)}),b.set(s,t))),m(e,v=v||[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])?new Proxy(e,C):e);var s,t}function L(e){if(e instanceof IDBRequest)return function(s){const e=new Promise((e,t)=>{const r=()=>{s.removeEventListener("success",a),s.removeEventListener("error",i)},a=()=>{e(L(s.result)),r()},i=()=>{t(s.error),r()};s.addEventListener("success",a),s.addEventListener("error",i)});return e.then(e=>{e instanceof IDBCursor&&_.set(e,s)}).catch(()=>{}),E.set(e,s),e}(e);if(S.has(e))return S.get(e);var t=T(e);return t!==e&&(S.set(e,t),E.set(t,e)),t}const M=e=>E.get(e);const D=["get","getKey","getAll","getAllKeys","count"],F=["put","add","delete","clear"],P=new Map;function k(e,t){if(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t){if(P.get(t))return P.get(t);const i=t.replace(/FromIndex$/,""),s=t!==i,n=F.includes(i);if(i in(s?IDBIndex:IDBObjectStore).prototype&&(n||D.includes(i))){var r=async function(e,...t){var r=this.transaction(e,n?"readwrite":"readonly");let a=r.store;return s&&(a=a.index(t.shift())),(await Promise.all([a[i](...t),n&&r.done]))[0]};return P.set(t,r),r}}}C={...a=C,get:(e,t,r)=>k(e,t)||a.get(e,t,r),has:(e,t)=>!!k(e,t)||a.has(e,t)};var O="@firebase/installations",N="0.6.6-dataconnect-preview.f2ddc3d7b";const j=1e4,A=`w:${N}`,R="FIS_v2",B="https://firebaseinstallations.googleapis.com/v1",$=36e5;var H;const x=new i("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 V(e){return e instanceof c&&e.code.includes("request-failed")}function q({projectId:e}){return`${B}/projects/${e}/installations`}function K(e){return{token:e.token,requestStatus:2,expiresIn:(e=e.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()}}async function U(e,t){var r=(await t.json()).error;return x.create("request-failed",{requestName:e,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function z({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function G(e,{refreshToken:t}){const r=z(e);return r.append("Authorization",(t=t,`${R} ${t}`)),r}async function W(e){var t=await e();return 500<=t.status&&t.status<600?e():t}function J(t){return new Promise(e=>{setTimeout(e,t)})}const Y=/^[cdef][\w-]{21}$/,Z="";function Q(){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 Y.test(e)?e:Z}catch(e){return Z}}function X(e){return`${e.appName}!${e.appId}`}const ee=new Map;function te(e,t){var r=X(e);re(r,t),function(e,t){const r=function(){!ae&&"BroadcastChannel"in self&&(ae=new BroadcastChannel("[Firebase] FID Change"),ae.onmessage=e=>{re(e.data.key,e.data.fid)});return ae}();r&&r.postMessage({key:e,fid:t});0===ee.size&&ae&&(ae.close(),ae=null)}(r,t)}function re(e,t){var r=ee.get(e);if(r)for(const a of r)a(t)}let ae=null;const ie="firebase-installations-store";let se=null;function ne(){return se=se||function(e,t,{blocked:r,upgrade:a,blocking:i,terminated:s}){const n=indexedDB.open(e,t),o=L(n);return a&&n.addEventListener("upgradeneeded",e=>{a(L(n.result),e.oldVersion,e.newVersion,L(n.transaction),e)}),r&&n.addEventListener("blocked",e=>r(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}("firebase-installations-database",1,{upgrade:(e,t)=>{0===t&&e.createObjectStore(ie)}}),se}async function oe(e,t){var r=X(e);const a=await ne(),i=a.transaction(ie,"readwrite"),s=i.objectStore(ie);var n=await s.get(r);return await s.put(t,r),await i.done,n&&n.fid===t.fid||te(e,t.fid),t}async function ce(e){var t=X(e);const r=await ne(),a=r.transaction(ie,"readwrite");await a.objectStore(ie).delete(t),await a.done}async function le(e,t){var r=X(e);const a=await ne(),i=a.transaction(ie,"readwrite"),s=i.objectStore(ie);var n=await s.get(r),o=t(n);return void 0===o?await s.delete(r):await s.put(o,r),await i.done,!o||n&&n.fid===o.fid||te(e,o.fid),o}async function ue(r){let a;var e=await le(r.appConfig,e=>{var t=he(e||{fid:Q(),registrationStatus:0}),t=function(e,t){{if(0!==t.registrationStatus)return 1===t.registrationStatus?{installationEntry:t,registrationPromise:async function(e){let t=await ge(e.appConfig);for(;1===t.registrationStatus;)await J(100),t=await ge(e.appConfig);if(0!==t.registrationStatus)return t;{var{installationEntry:r,registrationPromise:a}=await ue(e);return a||r}}(e)}:{installationEntry:t};if(!navigator.onLine){var r=Promise.reject(x.create("app-offline"));return{installationEntry:t,registrationPromise:r}}var a={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 a=q(e),i=z(e),s=t.getImmediate({optional:!0});!s||(n=await s.getHeartbeatsHeader())&&i.append("x-firebase-client",n);var n={fid:r,authVersion:R,appId:e.appId,sdkVersion:A};const o={method:"POST",headers:i,body:JSON.stringify(n)},c=await W(()=>fetch(a,o));if(c.ok){n=await c.json();return{fid:n.fid||r,registrationStatus:2,refreshToken:n.refreshToken,authToken:K(n.authToken)}}throw await U("Create Installation",c)}(t,r);return oe(t.appConfig,e)}catch(e){throw V(e)&&409===e.customData.serverCode?await ce(t.appConfig):await oe(t.appConfig,{fid:r.fid,registrationStatus:0}),e}}(e,a);return{installationEntry:a,registrationPromise:r}}}(r,t);return a=t.registrationPromise,t.installationEntry});return e.fid===Z?{installationEntry:await a}:{installationEntry:e,registrationPromise:a}}function ge(e){return le(e,e=>{if(!e)throw x.create("installation-not-found");return he(e)})}function he(e){return 1===(t=e).registrationStatus&&t.registrationTime+j<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function de({appConfig:e,heartbeatServiceProvider:t},r){const a=([i,s]=[e,r["fid"]],`${q(i)}/${s}/authTokens:generate`);var i,s;const n=G(e,r),o=t.getImmediate({optional:!0});!o||(c=await o.getHeartbeatsHeader())&&n.append("x-firebase-client",c);var c={installation:{sdkVersion:A,appId:e.appId}};const l={method:"POST",headers:n,body:JSON.stringify(c)},u=await W(()=>fetch(a,l));if(u.ok)return K(await u.json());throw await U("Generate Auth Token",u)}async function fe(a,i=!1){let s;var e=await le(a.appConfig,e=>{if(!me(e))throw x.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+$}(t)){if(1===r.requestStatus)return s=async function(e,t){let r=await pe(e.appConfig);for(;1===r.authToken.requestStatus;)await J(100),r=await pe(e.appConfig);var a=r.authToken;return 0===a.requestStatus?fe(e,t):a}(a,i),e;if(!navigator.onLine)throw x.create("app-offline");r=(t=e,r={requestStatus:1,requestTime:Date.now()},Object.assign(Object.assign({},t),{authToken:r}));return s=async function(t,r){try{var a=await de(t,r),e=Object.assign(Object.assign({},r),{authToken:a});return await oe(t.appConfig,e),a}catch(e){throw!V(e)||401!==e.customData.serverCode&&404!==e.customData.serverCode?(a=Object.assign(Object.assign({},r),{authToken:{requestStatus:0}}),await oe(t.appConfig,a)):await ce(t.appConfig),e}}(a,r),r}return e});return s?await s:e.authToken}function pe(e){return le(e,e=>{if(!me(e))throw x.create("not-registered");var t,r=e.authToken;return 1===(t=r).requestStatus&&t.requestTime+j<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}function me(e){return void 0!==e&&2===e.registrationStatus}async function ve(e,t=!1){var r,a=e;return await((r=(await ue(a)).registrationPromise)&&await r),(await fe(a,t)).token}function we(e){return x.create("missing-app-config-values",{valueName:e})}const _e="installations",be=e=>{var t=e.getProvider("app").getImmediate();return{app:t,appConfig:function(e){if(!e||!e.options)throw we("App Configuration");if(!e.name)throw we("App Name");for(const t of["projectId","apiKey","appId"])if(!e.options[t])throw we(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t),heartbeatServiceProvider:Ue._getProvider(t,"heartbeat"),_delete:()=>Promise.resolve()}},ye=e=>{var t=e.getProvider("app").getImmediate();const r=Ue._getProvider(t,_e).getImmediate();return{getId:()=>async function(e){var t=e;const{installationEntry:r,registrationPromise:a}=await ue(t);return(a||fe(t)).catch(console.error),r.fid}(r),getToken:e=>ve(r,e)}};Ue._registerComponent(new o(_e,be,"PUBLIC")),Ue._registerComponent(new o("installations-internal",ye,"PRIVATE")),Ue.registerVersion(O,N),Ue.registerVersion(O,N,"esm2017");const Se="@firebase/remote-config",Ee="0.4.6-dataconnect-preview.f2ddc3d7b";class Ce{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}const Ie=new i("remoteconfig","Remote Config",{"registration-window":"Undefined window object. This SDK only supports usage in a browser environment.","registration-project-id":"Undefined project identifier. Check Firebase app initialization.","registration-api-key":"Undefined API key. Check Firebase app initialization.","registration-app-id":"Undefined app identifier. Check Firebase app initialization.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}.","fetch-client-network":"Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-timeout":'The config fetch request timed out. Configure timeout using "fetchTimeoutMillis" SDK setting.',"fetch-throttle":'The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',"fetch-client-parse":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","indexed-db-unavailable":"Indexed DB is not supported by current browser"});const Te=["1","true","t","yes","y","on"];class Le{constructor(e,t=""){this._source=e,this._value=t}asString(){return this._value}asBoolean(){return"static"!==this._source&&0<=Te.indexOf(this._value.toLowerCase())}asNumber(){if("static"===this._source)return 0;let e=Number(this._value);return isNaN(e)&&(e=0),e}getSource(){return this._source}}async function Me(e){const t=s(e);var[r,a]=await Promise.all([t._storage.getLastSuccessfulFetchResponse(),t._storage.getActiveConfigEtag()]);return!!(r&&r.config&&r.eTag&&r.eTag!==a)&&(await Promise.all([t._storageCache.setActiveConfig(r.config),t._storage.setActiveConfigEtag(r.eTag)]),!0)}function De(e){const t=s(e);return t._initializePromise||(t._initializePromise=t._storageCache.loadFromStorage().then(()=>{t._isInitializationComplete=!0})),t._initializePromise}async function Fe(t){const r=s(t),e=new Ce;setTimeout(async()=>{e.abort()},r.settings.fetchTimeoutMillis);try{await r._client.fetch({cacheMaxAgeMillis:r.settings.minimumFetchIntervalMillis,signal:e}),await r._storageCache.setLastFetchStatus("success")}catch(e){var a=(i="fetch-throttle",(t=e)instanceof c&&-1!==t.code.indexOf(i)?"throttle":"failure");throw await r._storageCache.setLastFetchStatus(a),e}var i}function Pe(r){const e=s(r);return[t={},a={}]=[e._storageCache.getActiveConfig(),e.defaultConfig],Object.keys(Object.assign(Object.assign({},t),a)).reduce((e,t)=>(e[t]=ke(r,t),e),{});var t,a}function ke(e,t){const r=s(e);r._isInitializationComplete||r._logger.debug(`A value was requested for key "${t}" before SDK initialization completed.`+" Await on ensureInitialized if the intent was to get a previously activated value.");var a=r._storageCache.getActiveConfig();return a&&void 0!==a[t]?new Le("remote",a[t]):r.defaultConfig&&void 0!==r.defaultConfig[t]?new Le("default",String(r.defaultConfig[t])):(r._logger.debug(`Returning static value for key "${t}".`+" Define a default or remote value if this is unintentional."),new Le("static"))}class Oe{constructor(e,t,r,a){this.client=e,this.storage=t,this.storageCache=r,this.logger=a}isCachedDataFresh(e,t){if(!t)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;var r=Date.now()-t,a=r<=e;return this.logger.debug("Config fetch cache check."+` Cache age millis: ${r}.`+` Cache max age millis (minimumFetchIntervalMillis setting): ${e}.`+` Is cache hit: ${a}.`),a}async fetch(e){var[t,r]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(r&&this.isCachedDataFresh(e.cacheMaxAgeMillis,t))return r;e.eTag=r&&r.eTag;r=await this.client.fetch(e);const a=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===r.status&&a.push(this.storage.setLastSuccessfulFetchResponse(r)),await Promise.all(a),r}}class Ne{constructor(e,t,r,a,i,s){this.firebaseInstallations=e,this.sdkVersion=t,this.namespace=r,this.projectId=a,this.apiKey=i,this.appId=s}async fetch(r){var e,[t,a]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),i=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,s={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":r.eTag||"*"},a={sdk_version:this.sdkVersion,app_instance_id:t,app_instance_id_token:a,app_id:this.appId,language_code:(e=navigator).languages&&e.languages[0]||e.language},a={method:"POST",headers:s,body:JSON.stringify(a)},i=fetch(i,a),a=new Promise((e,t)=>{r.signal.addEventListener(()=>{const e=new Error("The operation was aborted.");e.name="AbortError",t(e)})});let n;try{await Promise.race([i,a]),n=await i}catch(e){let t="fetch-client-network";throw"AbortError"===(null==e?void 0:e.name)&&(t="fetch-timeout"),Ie.create(t,{originalErrorMessage:null==e?void 0:e.message})}let o=n.status;i=n.headers.get("ETag")||void 0;let c,l;if(200===n.status){let e;try{e=await n.json()}catch(e){throw Ie.create("fetch-client-parse",{originalErrorMessage:null==e?void 0:e.message})}c=e.entries,l=e.state}if("INSTANCE_STATE_UNSPECIFIED"===l?o=500:"NO_CHANGE"===l?o=304:"NO_TEMPLATE"!==l&&"EMPTY_CONFIG"!==l||(c={}),304!==o&&200!==o)throw Ie.create("fetch-status",{httpStatus:o});return{status:o,eTag:i,config:c}}}class je{constructor(e,t){this.client=e,this.storage=t}async fetch(e){var t=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(e,t)}async attemptFetch(t,{throttleEndTimeMillis:r,backoffCount:a}){var i,s;i=t.signal,s=r,await new Promise((e,t)=>{var r=Math.max(s-Date.now(),0);const a=setTimeout(e,r);i.addEventListener(()=>{clearTimeout(a),t(Ie.create("fetch-throttle",{throttleEndTimeMillis:s}))})});try{var n=await this.client.fetch(t);return await this.storage.deleteThrottleMetadata(),n}catch(e){if(!function(e){if(e instanceof c&&e.customData){var t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}}(e))throw e;var o={throttleEndTimeMillis:Date.now()+(r=2,n=1e3*Math.pow(r,a),o=Math.round(.5*n*(Math.random()-.5)*2),Math.min(144e5,n+o)),backoffCount:a+1};return await this.storage.setThrottleMetadata(o),this.attemptFetch(t,o)}}}class Ae{constructor(e,t,r,a,i){this.app=e,this._client=t,this._storageCache=r,this._storage=a,this._logger=i,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}get fetchTimeMillis(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1}get lastFetchStatus(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"}}function Re(e,t){var r=e.target.error||void 0;return Ie.create(t,{originalErrorMessage:r&&(null==r?void 0:r.message)})}const Be="app_namespace_store";class $e{constructor(e,t,r,a=function(){return new Promise((t,r)=>{try{const e=indexedDB.open("firebase_remote_config",1);e.onerror=e=>{r(Re(e,"storage-open"))},e.onsuccess=e=>{t(e.target.result)},e.onupgradeneeded=e=>{const t=e.target.result;0===e.oldVersion&&t.createObjectStore(Be,{keyPath:"compositeKey"})}}catch(e){r(Ie.create("storage-open",{originalErrorMessage:null==e?void 0:e.message}))}})}()){this.appId=e,this.appName=t,this.namespace=r,this.openDbPromise=a}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(e){return this.set("last_fetch_status",e)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(e){return this.set("last_successful_fetch_timestamp_millis",e)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(e){return this.set("last_successful_fetch_response",e)}getActiveConfig(){return this.get("active_config")}setActiveConfig(e){return this.set("active_config",e)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(e){return this.set("active_config_etag",e)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(e){return this.set("throttle_metadata",e)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(n){const o=await this.openDbPromise;return new Promise((r,t)=>{const e=o.transaction([Be],"readonly"),a=e.objectStore(Be);var i=this.createCompositeKey(n);try{const s=a.get(i);s.onerror=e=>{t(Re(e,"storage-get"))},s.onsuccess=e=>{var t=e.target.result;r(t?t.value:void 0)}}catch(e){t(Ie.create("storage-get",{originalErrorMessage:null==e?void 0:e.message}))}})}async set(n,o){const c=await this.openDbPromise;return new Promise((e,t)=>{const r=c.transaction([Be],"readwrite"),a=r.objectStore(Be);var i=this.createCompositeKey(n);try{const s=a.put({compositeKey:i,value:o});s.onerror=e=>{t(Re(e,"storage-set"))},s.onsuccess=()=>{e()}}catch(e){t(Ie.create("storage-set",{originalErrorMessage:null==e?void 0:e.message}))}})}async delete(n){const o=await this.openDbPromise;return new Promise((e,t)=>{const r=o.transaction([Be],"readwrite"),a=r.objectStore(Be);var i=this.createCompositeKey(n);try{const s=a.delete(i);s.onerror=e=>{t(Re(e,"storage-delete"))},s.onsuccess=()=>{e()}}catch(e){t(Ie.create("storage-delete",{originalErrorMessage:null==e?void 0:e.message}))}})}createCompositeKey(e){return[this.appId,this.appName,this.namespace,e].join()}}class He{constructor(e){this.storage=e}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){var e=this.storage.getLastFetchStatus(),t=this.storage.getLastSuccessfulFetchTimestampMillis(),r=this.storage.getActiveConfig(),e=await e;e&&(this.lastFetchStatus=e);t=await t;t&&(this.lastSuccessfulFetchTimestampMillis=t);r=await r;r&&(this.activeConfig=r)}setLastFetchStatus(e){return this.lastFetchStatus=e,this.storage.setLastFetchStatus(e)}setLastSuccessfulFetchTimestampMillis(e){return this.lastSuccessfulFetchTimestampMillis=e,this.storage.setLastSuccessfulFetchTimestampMillis(e)}setActiveConfig(e){return this.activeConfig=e,this.storage.setActiveConfig(e)}}async function xe(){if(!g())return!1;try{return await new Promise((t,r)=>{try{let e=!0;const a="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(a);i.onsuccess=()=>{i.result.close(),e||self.indexedDB.deleteDatabase(a),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)}})}catch(e){return!1}}Ue._registerComponent(new o("remote-config",function(e,{instanceIdentifier:t}){var r=e.getProvider("app").getImmediate(),a=e.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw Ie.create("registration-window");if(!g())throw Ie.create("indexed-db-unavailable");var{projectId:i,apiKey:s,appId:n}=r.options;if(!i)throw Ie.create("registration-project-id");if(!s)throw Ie.create("registration-api-key");if(!n)throw Ie.create("registration-app-id");t=t||"firebase";const o=new $e(n,r.name,t),c=new He(o),l=new p(Se);l.logLevel=u.ERROR;n=new Ne(a,Ue.SDK_VERSION,t,i,s,n),n=new je(n,o),n=new Oe(n,o,c,l),n=new Ae(r,n,c,o,l);return De(n),n},"PUBLIC").setMultipleInstances(!0)),Ue.registerVersion(Se,Ee),Ue.registerVersion(Se,Ee,"esm2017");class Ve{constructor(e,t){this.app=e,this._delegate=t}get defaultConfig(){return this._delegate.defaultConfig}set defaultConfig(e){this._delegate.defaultConfig=e}get fetchTimeMillis(){return this._delegate.fetchTimeMillis}get lastFetchStatus(){return this._delegate.lastFetchStatus}get settings(){return this._delegate.settings}set settings(e){this._delegate.settings=e}activate(){return Me(this._delegate)}ensureInitialized(){return De(this._delegate)}fetch(){return Fe(this._delegate)}fetchAndActivate(){return async function(e){return await Fe(e=s(e)),Me(e)}(this._delegate)}getAll(){return Pe(this._delegate)}getBoolean(e){return ke(s(this._delegate),e).asBoolean()}getNumber(e){return ke(s(this._delegate),e).asNumber()}getString(e){return ke(s(this._delegate),e).asString()}getValue(e){return ke(this._delegate,e)}setLogLevel(e){!function(e,t){const r=s(e);switch(t){case"debug":r._logger.logLevel=u.DEBUG;break;case"silent":r._logger.logLevel=u.SILENT;break;default:r._logger.logLevel=u.ERROR}}(this._delegate,e)}}function qe(e,{instanceIdentifier:t}){var r=e.getProvider("app-compat").getImmediate(),a=e.getProvider("remote-config").getImmediate({identifier:t});return new Ve(r,a)}(H=r.default).INTERNAL.registerComponent(new o("remoteConfig-compat",qe,"PUBLIC").setMultipleInstances(!0).setServiceProps({isSupported:xe})),H.registerVersion("@firebase/remote-config-compat","0.2.6-dataconnect-preview.f2ddc3d7b")}).apply(this,arguments)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-remote-config-compat.js - be sure to load firebase-app.js first.")}});
|
|
1
|
+
!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(Ke,Ue){"use strict";try{!(function(){function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u,t,a,r=e(Ke);function g(){try{return"object"==typeof indexedDB}catch(e){return}}class c extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,c.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,i.prototype.create)}}class i{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){var a,r=t[0]||{},i=`${this.service}/${e}`,s=this.errors[e],s=s?(a=r,s.replace(n,(e,t)=>{var r=a[t];return null!=r?String(r):`<${t}?>`})):"Error",s=`${this.serviceName}: ${s} (${i}).`;return new c(i,s,r)}}const n=/\{\$([^}]+)}/g;function s(e){return e&&e._delegate?e._delegate:e}class o{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}}(t=u=u||{})[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT";const l={debug:u.DEBUG,verbose:u.VERBOSE,info:u.INFO,warn:u.WARN,error:u.ERROR,silent:u.SILENT},h=u.INFO,d={[u.DEBUG]:"log",[u.VERBOSE]:"log",[u.INFO]:"info",[u.WARN]:"warn",[u.ERROR]:"error"},f=(e,t,...r)=>{if(!(t<e.logLevel)){var a=(new Date).toISOString(),i=d[t];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[i](`[${a}] ${e.name}:`,...r)}};class p{constructor(e){this.name=e,this._logLevel=h,this._logHandler=f,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in u))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?l[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,u.DEBUG,...e),this._logHandler(this,u.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,u.VERBOSE,...e),this._logHandler(this,u.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,u.INFO,...e),this._logHandler(this,u.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,u.WARN,...e),this._logHandler(this,u.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,u.ERROR,...e),this._logHandler(this,u.ERROR,...e)}}const m=(t,e)=>e.some(e=>t instanceof e);let v,w;const _=new WeakMap,b=new WeakMap,y=new WeakMap,S=new WeakMap,E=new WeakMap;let C={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return b.get(e);if("objectStoreNames"===t)return e.objectStoreNames||y.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return L(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e}};function I(a){return a!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(w=w||[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey]).includes(a)?function(...e){return a.apply(M(this),e),L(_.get(this))}:function(...e){return L(a.apply(M(this),e))}:function(e,...t){var r=a.call(M(this),e,...t);return y.set(r,e.sort?e.sort():[e]),L(r)}}function T(e){return"function"==typeof e?I(e):(e instanceof IDBTransaction&&(s=e,b.has(s)||(t=new Promise((e,t)=>{const r=()=>{s.removeEventListener("complete",a),s.removeEventListener("error",i),s.removeEventListener("abort",i)},a=()=>{e(),r()},i=()=>{t(s.error||new DOMException("AbortError","AbortError")),r()};s.addEventListener("complete",a),s.addEventListener("error",i),s.addEventListener("abort",i)}),b.set(s,t))),m(e,v=v||[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])?new Proxy(e,C):e);var s,t}function L(e){if(e instanceof IDBRequest)return function(s){const e=new Promise((e,t)=>{const r=()=>{s.removeEventListener("success",a),s.removeEventListener("error",i)},a=()=>{e(L(s.result)),r()},i=()=>{t(s.error),r()};s.addEventListener("success",a),s.addEventListener("error",i)});return e.then(e=>{e instanceof IDBCursor&&_.set(e,s)}).catch(()=>{}),E.set(e,s),e}(e);if(S.has(e))return S.get(e);var t=T(e);return t!==e&&(S.set(e,t),E.set(t,e)),t}const M=e=>E.get(e);const D=["get","getKey","getAll","getAllKeys","count"],F=["put","add","delete","clear"],P=new Map;function k(e,t){if(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t){if(P.get(t))return P.get(t);const i=t.replace(/FromIndex$/,""),s=t!==i,n=F.includes(i);if(i in(s?IDBIndex:IDBObjectStore).prototype&&(n||D.includes(i))){var r=async function(e,...t){var r=this.transaction(e,n?"readwrite":"readonly");let a=r.store;return s&&(a=a.index(t.shift())),(await Promise.all([a[i](...t),n&&r.done]))[0]};return P.set(t,r),r}}}C={...a=C,get:(e,t,r)=>k(e,t)||a.get(e,t,r),has:(e,t)=>!!k(e,t)||a.has(e,t)};var O="@firebase/installations",N="0.6.6-dataconnect-preview.42eb5e521";const j=1e4,A=`w:${N}`,R="FIS_v2",B="https://firebaseinstallations.googleapis.com/v1",$=36e5;var H;const x=new i("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 V(e){return e instanceof c&&e.code.includes("request-failed")}function q({projectId:e}){return`${B}/projects/${e}/installations`}function K(e){return{token:e.token,requestStatus:2,expiresIn:(e=e.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()}}async function U(e,t){var r=(await t.json()).error;return x.create("request-failed",{requestName:e,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function z({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function G(e,{refreshToken:t}){const r=z(e);return r.append("Authorization",(t=t,`${R} ${t}`)),r}async function W(e){var t=await e();return 500<=t.status&&t.status<600?e():t}function J(t){return new Promise(e=>{setTimeout(e,t)})}const Y=/^[cdef][\w-]{21}$/,Z="";function Q(){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 Y.test(e)?e:Z}catch(e){return Z}}function X(e){return`${e.appName}!${e.appId}`}const ee=new Map;function te(e,t){var r=X(e);re(r,t),function(e,t){const r=function(){!ae&&"BroadcastChannel"in self&&(ae=new BroadcastChannel("[Firebase] FID Change"),ae.onmessage=e=>{re(e.data.key,e.data.fid)});return ae}();r&&r.postMessage({key:e,fid:t});0===ee.size&&ae&&(ae.close(),ae=null)}(r,t)}function re(e,t){var r=ee.get(e);if(r)for(const a of r)a(t)}let ae=null;const ie="firebase-installations-store";let se=null;function ne(){return se=se||function(e,t,{blocked:r,upgrade:a,blocking:i,terminated:s}){const n=indexedDB.open(e,t),o=L(n);return a&&n.addEventListener("upgradeneeded",e=>{a(L(n.result),e.oldVersion,e.newVersion,L(n.transaction),e)}),r&&n.addEventListener("blocked",e=>r(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}("firebase-installations-database",1,{upgrade:(e,t)=>{0===t&&e.createObjectStore(ie)}}),se}async function oe(e,t){var r=X(e);const a=await ne(),i=a.transaction(ie,"readwrite"),s=i.objectStore(ie);var n=await s.get(r);return await s.put(t,r),await i.done,n&&n.fid===t.fid||te(e,t.fid),t}async function ce(e){var t=X(e);const r=await ne(),a=r.transaction(ie,"readwrite");await a.objectStore(ie).delete(t),await a.done}async function le(e,t){var r=X(e);const a=await ne(),i=a.transaction(ie,"readwrite"),s=i.objectStore(ie);var n=await s.get(r),o=t(n);return void 0===o?await s.delete(r):await s.put(o,r),await i.done,!o||n&&n.fid===o.fid||te(e,o.fid),o}async function ue(r){let a;var e=await le(r.appConfig,e=>{var t=he(e||{fid:Q(),registrationStatus:0}),t=function(e,t){{if(0!==t.registrationStatus)return 1===t.registrationStatus?{installationEntry:t,registrationPromise:async function(e){let t=await ge(e.appConfig);for(;1===t.registrationStatus;)await J(100),t=await ge(e.appConfig);if(0!==t.registrationStatus)return t;{var{installationEntry:r,registrationPromise:a}=await ue(e);return a||r}}(e)}:{installationEntry:t};if(!navigator.onLine){var r=Promise.reject(x.create("app-offline"));return{installationEntry:t,registrationPromise:r}}var a={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 a=q(e),i=z(e),s=t.getImmediate({optional:!0});!s||(n=await s.getHeartbeatsHeader())&&i.append("x-firebase-client",n);var n={fid:r,authVersion:R,appId:e.appId,sdkVersion:A};const o={method:"POST",headers:i,body:JSON.stringify(n)},c=await W(()=>fetch(a,o));if(c.ok){n=await c.json();return{fid:n.fid||r,registrationStatus:2,refreshToken:n.refreshToken,authToken:K(n.authToken)}}throw await U("Create Installation",c)}(t,r);return oe(t.appConfig,e)}catch(e){throw V(e)&&409===e.customData.serverCode?await ce(t.appConfig):await oe(t.appConfig,{fid:r.fid,registrationStatus:0}),e}}(e,a);return{installationEntry:a,registrationPromise:r}}}(r,t);return a=t.registrationPromise,t.installationEntry});return e.fid===Z?{installationEntry:await a}:{installationEntry:e,registrationPromise:a}}function ge(e){return le(e,e=>{if(!e)throw x.create("installation-not-found");return he(e)})}function he(e){return 1===(t=e).registrationStatus&&t.registrationTime+j<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function de({appConfig:e,heartbeatServiceProvider:t},r){const a=([i,s]=[e,r["fid"]],`${q(i)}/${s}/authTokens:generate`);var i,s;const n=G(e,r),o=t.getImmediate({optional:!0});!o||(c=await o.getHeartbeatsHeader())&&n.append("x-firebase-client",c);var c={installation:{sdkVersion:A,appId:e.appId}};const l={method:"POST",headers:n,body:JSON.stringify(c)},u=await W(()=>fetch(a,l));if(u.ok)return K(await u.json());throw await U("Generate Auth Token",u)}async function fe(a,i=!1){let s;var e=await le(a.appConfig,e=>{if(!me(e))throw x.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+$}(t)){if(1===r.requestStatus)return s=async function(e,t){let r=await pe(e.appConfig);for(;1===r.authToken.requestStatus;)await J(100),r=await pe(e.appConfig);var a=r.authToken;return 0===a.requestStatus?fe(e,t):a}(a,i),e;if(!navigator.onLine)throw x.create("app-offline");r=(t=e,r={requestStatus:1,requestTime:Date.now()},Object.assign(Object.assign({},t),{authToken:r}));return s=async function(t,r){try{var a=await de(t,r),e=Object.assign(Object.assign({},r),{authToken:a});return await oe(t.appConfig,e),a}catch(e){throw!V(e)||401!==e.customData.serverCode&&404!==e.customData.serverCode?(a=Object.assign(Object.assign({},r),{authToken:{requestStatus:0}}),await oe(t.appConfig,a)):await ce(t.appConfig),e}}(a,r),r}return e});return s?await s:e.authToken}function pe(e){return le(e,e=>{if(!me(e))throw x.create("not-registered");var t,r=e.authToken;return 1===(t=r).requestStatus&&t.requestTime+j<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}function me(e){return void 0!==e&&2===e.registrationStatus}async function ve(e,t=!1){var r,a=e;return await((r=(await ue(a)).registrationPromise)&&await r),(await fe(a,t)).token}function we(e){return x.create("missing-app-config-values",{valueName:e})}const _e="installations",be=e=>{var t=e.getProvider("app").getImmediate();return{app:t,appConfig:function(e){if(!e||!e.options)throw we("App Configuration");if(!e.name)throw we("App Name");for(const t of["projectId","apiKey","appId"])if(!e.options[t])throw we(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t),heartbeatServiceProvider:Ue._getProvider(t,"heartbeat"),_delete:()=>Promise.resolve()}},ye=e=>{var t=e.getProvider("app").getImmediate();const r=Ue._getProvider(t,_e).getImmediate();return{getId:()=>async function(e){var t=e;const{installationEntry:r,registrationPromise:a}=await ue(t);return(a||fe(t)).catch(console.error),r.fid}(r),getToken:e=>ve(r,e)}};Ue._registerComponent(new o(_e,be,"PUBLIC")),Ue._registerComponent(new o("installations-internal",ye,"PRIVATE")),Ue.registerVersion(O,N),Ue.registerVersion(O,N,"esm2017");const Se="@firebase/remote-config",Ee="0.4.6-dataconnect-preview.42eb5e521";class Ce{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}const Ie=new i("remoteconfig","Remote Config",{"registration-window":"Undefined window object. This SDK only supports usage in a browser environment.","registration-project-id":"Undefined project identifier. Check Firebase app initialization.","registration-api-key":"Undefined API key. Check Firebase app initialization.","registration-app-id":"Undefined app identifier. Check Firebase app initialization.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}.","fetch-client-network":"Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-timeout":'The config fetch request timed out. Configure timeout using "fetchTimeoutMillis" SDK setting.',"fetch-throttle":'The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',"fetch-client-parse":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","indexed-db-unavailable":"Indexed DB is not supported by current browser"});const Te=["1","true","t","yes","y","on"];class Le{constructor(e,t=""){this._source=e,this._value=t}asString(){return this._value}asBoolean(){return"static"!==this._source&&0<=Te.indexOf(this._value.toLowerCase())}asNumber(){if("static"===this._source)return 0;let e=Number(this._value);return isNaN(e)&&(e=0),e}getSource(){return this._source}}async function Me(e){const t=s(e);var[r,a]=await Promise.all([t._storage.getLastSuccessfulFetchResponse(),t._storage.getActiveConfigEtag()]);return!!(r&&r.config&&r.eTag&&r.eTag!==a)&&(await Promise.all([t._storageCache.setActiveConfig(r.config),t._storage.setActiveConfigEtag(r.eTag)]),!0)}function De(e){const t=s(e);return t._initializePromise||(t._initializePromise=t._storageCache.loadFromStorage().then(()=>{t._isInitializationComplete=!0})),t._initializePromise}async function Fe(t){const r=s(t),e=new Ce;setTimeout(async()=>{e.abort()},r.settings.fetchTimeoutMillis);try{await r._client.fetch({cacheMaxAgeMillis:r.settings.minimumFetchIntervalMillis,signal:e}),await r._storageCache.setLastFetchStatus("success")}catch(e){var a=(i="fetch-throttle",(t=e)instanceof c&&-1!==t.code.indexOf(i)?"throttle":"failure");throw await r._storageCache.setLastFetchStatus(a),e}var i}function Pe(r){const e=s(r);return[t={},a={}]=[e._storageCache.getActiveConfig(),e.defaultConfig],Object.keys(Object.assign(Object.assign({},t),a)).reduce((e,t)=>(e[t]=ke(r,t),e),{});var t,a}function ke(e,t){const r=s(e);r._isInitializationComplete||r._logger.debug(`A value was requested for key "${t}" before SDK initialization completed.`+" Await on ensureInitialized if the intent was to get a previously activated value.");var a=r._storageCache.getActiveConfig();return a&&void 0!==a[t]?new Le("remote",a[t]):r.defaultConfig&&void 0!==r.defaultConfig[t]?new Le("default",String(r.defaultConfig[t])):(r._logger.debug(`Returning static value for key "${t}".`+" Define a default or remote value if this is unintentional."),new Le("static"))}class Oe{constructor(e,t,r,a){this.client=e,this.storage=t,this.storageCache=r,this.logger=a}isCachedDataFresh(e,t){if(!t)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;var r=Date.now()-t,a=r<=e;return this.logger.debug("Config fetch cache check."+` Cache age millis: ${r}.`+` Cache max age millis (minimumFetchIntervalMillis setting): ${e}.`+` Is cache hit: ${a}.`),a}async fetch(e){var[t,r]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(r&&this.isCachedDataFresh(e.cacheMaxAgeMillis,t))return r;e.eTag=r&&r.eTag;r=await this.client.fetch(e);const a=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===r.status&&a.push(this.storage.setLastSuccessfulFetchResponse(r)),await Promise.all(a),r}}class Ne{constructor(e,t,r,a,i,s){this.firebaseInstallations=e,this.sdkVersion=t,this.namespace=r,this.projectId=a,this.apiKey=i,this.appId=s}async fetch(r){var e,[t,a]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),i=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,s={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":r.eTag||"*"},a={sdk_version:this.sdkVersion,app_instance_id:t,app_instance_id_token:a,app_id:this.appId,language_code:(e=navigator).languages&&e.languages[0]||e.language},a={method:"POST",headers:s,body:JSON.stringify(a)},i=fetch(i,a),a=new Promise((e,t)=>{r.signal.addEventListener(()=>{const e=new Error("The operation was aborted.");e.name="AbortError",t(e)})});let n;try{await Promise.race([i,a]),n=await i}catch(e){let t="fetch-client-network";throw"AbortError"===(null==e?void 0:e.name)&&(t="fetch-timeout"),Ie.create(t,{originalErrorMessage:null==e?void 0:e.message})}let o=n.status;i=n.headers.get("ETag")||void 0;let c,l;if(200===n.status){let e;try{e=await n.json()}catch(e){throw Ie.create("fetch-client-parse",{originalErrorMessage:null==e?void 0:e.message})}c=e.entries,l=e.state}if("INSTANCE_STATE_UNSPECIFIED"===l?o=500:"NO_CHANGE"===l?o=304:"NO_TEMPLATE"!==l&&"EMPTY_CONFIG"!==l||(c={}),304!==o&&200!==o)throw Ie.create("fetch-status",{httpStatus:o});return{status:o,eTag:i,config:c}}}class je{constructor(e,t){this.client=e,this.storage=t}async fetch(e){var t=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(e,t)}async attemptFetch(t,{throttleEndTimeMillis:r,backoffCount:a}){var i,s;i=t.signal,s=r,await new Promise((e,t)=>{var r=Math.max(s-Date.now(),0);const a=setTimeout(e,r);i.addEventListener(()=>{clearTimeout(a),t(Ie.create("fetch-throttle",{throttleEndTimeMillis:s}))})});try{var n=await this.client.fetch(t);return await this.storage.deleteThrottleMetadata(),n}catch(e){if(!function(e){if(e instanceof c&&e.customData){var t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}}(e))throw e;var o={throttleEndTimeMillis:Date.now()+(r=2,n=1e3*Math.pow(r,a),o=Math.round(.5*n*(Math.random()-.5)*2),Math.min(144e5,n+o)),backoffCount:a+1};return await this.storage.setThrottleMetadata(o),this.attemptFetch(t,o)}}}class Ae{constructor(e,t,r,a,i){this.app=e,this._client=t,this._storageCache=r,this._storage=a,this._logger=i,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}get fetchTimeMillis(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1}get lastFetchStatus(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"}}function Re(e,t){var r=e.target.error||void 0;return Ie.create(t,{originalErrorMessage:r&&(null==r?void 0:r.message)})}const Be="app_namespace_store";class $e{constructor(e,t,r,a=function(){return new Promise((t,r)=>{try{const e=indexedDB.open("firebase_remote_config",1);e.onerror=e=>{r(Re(e,"storage-open"))},e.onsuccess=e=>{t(e.target.result)},e.onupgradeneeded=e=>{const t=e.target.result;0===e.oldVersion&&t.createObjectStore(Be,{keyPath:"compositeKey"})}}catch(e){r(Ie.create("storage-open",{originalErrorMessage:null==e?void 0:e.message}))}})}()){this.appId=e,this.appName=t,this.namespace=r,this.openDbPromise=a}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(e){return this.set("last_fetch_status",e)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(e){return this.set("last_successful_fetch_timestamp_millis",e)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(e){return this.set("last_successful_fetch_response",e)}getActiveConfig(){return this.get("active_config")}setActiveConfig(e){return this.set("active_config",e)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(e){return this.set("active_config_etag",e)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(e){return this.set("throttle_metadata",e)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(n){const o=await this.openDbPromise;return new Promise((r,t)=>{const e=o.transaction([Be],"readonly"),a=e.objectStore(Be);var i=this.createCompositeKey(n);try{const s=a.get(i);s.onerror=e=>{t(Re(e,"storage-get"))},s.onsuccess=e=>{var t=e.target.result;r(t?t.value:void 0)}}catch(e){t(Ie.create("storage-get",{originalErrorMessage:null==e?void 0:e.message}))}})}async set(n,o){const c=await this.openDbPromise;return new Promise((e,t)=>{const r=c.transaction([Be],"readwrite"),a=r.objectStore(Be);var i=this.createCompositeKey(n);try{const s=a.put({compositeKey:i,value:o});s.onerror=e=>{t(Re(e,"storage-set"))},s.onsuccess=()=>{e()}}catch(e){t(Ie.create("storage-set",{originalErrorMessage:null==e?void 0:e.message}))}})}async delete(n){const o=await this.openDbPromise;return new Promise((e,t)=>{const r=o.transaction([Be],"readwrite"),a=r.objectStore(Be);var i=this.createCompositeKey(n);try{const s=a.delete(i);s.onerror=e=>{t(Re(e,"storage-delete"))},s.onsuccess=()=>{e()}}catch(e){t(Ie.create("storage-delete",{originalErrorMessage:null==e?void 0:e.message}))}})}createCompositeKey(e){return[this.appId,this.appName,this.namespace,e].join()}}class He{constructor(e){this.storage=e}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){var e=this.storage.getLastFetchStatus(),t=this.storage.getLastSuccessfulFetchTimestampMillis(),r=this.storage.getActiveConfig(),e=await e;e&&(this.lastFetchStatus=e);t=await t;t&&(this.lastSuccessfulFetchTimestampMillis=t);r=await r;r&&(this.activeConfig=r)}setLastFetchStatus(e){return this.lastFetchStatus=e,this.storage.setLastFetchStatus(e)}setLastSuccessfulFetchTimestampMillis(e){return this.lastSuccessfulFetchTimestampMillis=e,this.storage.setLastSuccessfulFetchTimestampMillis(e)}setActiveConfig(e){return this.activeConfig=e,this.storage.setActiveConfig(e)}}async function xe(){if(!g())return!1;try{return await new Promise((t,r)=>{try{let e=!0;const a="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(a);i.onsuccess=()=>{i.result.close(),e||self.indexedDB.deleteDatabase(a),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)}})}catch(e){return!1}}Ue._registerComponent(new o("remote-config",function(e,{instanceIdentifier:t}){var r=e.getProvider("app").getImmediate(),a=e.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw Ie.create("registration-window");if(!g())throw Ie.create("indexed-db-unavailable");var{projectId:i,apiKey:s,appId:n}=r.options;if(!i)throw Ie.create("registration-project-id");if(!s)throw Ie.create("registration-api-key");if(!n)throw Ie.create("registration-app-id");t=t||"firebase";const o=new $e(n,r.name,t),c=new He(o),l=new p(Se);l.logLevel=u.ERROR;n=new Ne(a,Ue.SDK_VERSION,t,i,s,n),n=new je(n,o),n=new Oe(n,o,c,l),n=new Ae(r,n,c,o,l);return De(n),n},"PUBLIC").setMultipleInstances(!0)),Ue.registerVersion(Se,Ee),Ue.registerVersion(Se,Ee,"esm2017");class Ve{constructor(e,t){this.app=e,this._delegate=t}get defaultConfig(){return this._delegate.defaultConfig}set defaultConfig(e){this._delegate.defaultConfig=e}get fetchTimeMillis(){return this._delegate.fetchTimeMillis}get lastFetchStatus(){return this._delegate.lastFetchStatus}get settings(){return this._delegate.settings}set settings(e){this._delegate.settings=e}activate(){return Me(this._delegate)}ensureInitialized(){return De(this._delegate)}fetch(){return Fe(this._delegate)}fetchAndActivate(){return async function(e){return await Fe(e=s(e)),Me(e)}(this._delegate)}getAll(){return Pe(this._delegate)}getBoolean(e){return ke(s(this._delegate),e).asBoolean()}getNumber(e){return ke(s(this._delegate),e).asNumber()}getString(e){return ke(s(this._delegate),e).asString()}getValue(e){return ke(this._delegate,e)}setLogLevel(e){!function(e,t){const r=s(e);switch(t){case"debug":r._logger.logLevel=u.DEBUG;break;case"silent":r._logger.logLevel=u.SILENT;break;default:r._logger.logLevel=u.ERROR}}(this._delegate,e)}}function qe(e,{instanceIdentifier:t}){var r=e.getProvider("app-compat").getImmediate(),a=e.getProvider("remote-config").getImmediate({identifier:t});return new Ve(r,a)}(H=r.default).INTERNAL.registerComponent(new o("remoteConfig-compat",qe,"PUBLIC").setMultipleInstances(!0).setServiceProps({isSupported:xe})),H.registerVersion("@firebase/remote-config-compat","0.2.6-dataconnect-preview.42eb5e521")}).apply(this,arguments)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-remote-config-compat.js - be sure to load firebase-app.js first.")}});
|
|
2
2
|
//# sourceMappingURL=firebase-remote-config-compat.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{registerVersion as e,_registerComponent as t,_getProvider,getApp as r,SDK_VERSION as n}from"https://www.gstatic.com/firebasejs/10.11.1-dataconnect-preview.f2ddc3d7b/firebase-app.js";function isIndexedDBAvailable(){try{return"object"==typeof indexedDB}catch(e){return!1}}class FirebaseError extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,FirebaseError.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,ErrorFactory.prototype.create)}}class ErrorFactory{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},n=`${this.service}/${e}`,s=this.errors[e],i=s?function replaceTemplate(e,t){return e.replace(a,((e,r)=>{const n=t[r];return null!=n?String(n):`<${r}?>`}))}(s,r):"Error",o=`${this.serviceName}: ${i} (${n}).`;return new FirebaseError(n,o,r)}}const a=/\{\$([^}]+)}/g;function calculateBackoffMillis(e,t=1e3,r=2){const n=t*Math.pow(r,e),a=Math.round(.5*n*(Math.random()-.5)*2);return Math.min(144e5,n+a)}function getModularInstance(e){return e&&e._delegate?e._delegate:e}class Component{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}}var s;!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"}(s||(s={}));const i={debug:s.DEBUG,verbose:s.VERBOSE,info:s.INFO,warn:s.WARN,error:s.ERROR,silent:s.SILENT},o=s.INFO,c={[s.DEBUG]:"log",[s.VERBOSE]:"log",[s.INFO]:"info",[s.WARN]:"warn",[s.ERROR]:"error"},defaultLogHandler=(e,t,...r)=>{if(t<e.logLevel)return;const n=(new Date).toISOString(),a=c[t];if(!a)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[a](`[${n}] ${e.name}:`,...r)};class Logger{constructor(e){this.name=e,this._logLevel=o,this._logHandler=defaultLogHandler,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in s))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?i[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,s.DEBUG,...e),this._logHandler(this,s.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,s.VERBOSE,...e),this._logHandler(this,s.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,s.INFO,...e),this._logHandler(this,s.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,s.WARN,...e),this._logHandler(this,s.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,s.ERROR,...e),this._logHandler(this,s.ERROR,...e)}}let l,u;const g=new WeakMap,h=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakMap;let m={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return h.get(e);if("objectStoreNames"===t)return e.objectStoreNames||d.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return wrap(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function wrapFunction(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?function getCursorAdvanceMethods(){return u||(u=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}().includes(e)?function(...t){return e.apply(unwrap(this),t),wrap(g.get(this))}:function(...t){return wrap(e.apply(unwrap(this),t))}:function(t,...r){const n=e.call(unwrap(this),t,...r);return d.set(n,t.sort?t.sort():[t]),wrap(n)}}function transformCachableValue(e){return"function"==typeof e?wrapFunction(e):(e instanceof IDBTransaction&&function cacheDonePromiseForTransaction(e){if(h.has(e))return;const t=new Promise(((t,r)=>{const unlisten=()=>{e.removeEventListener("complete",complete),e.removeEventListener("error",error),e.removeEventListener("abort",error)},complete=()=>{t(),unlisten()},error=()=>{r(e.error||new DOMException("AbortError","AbortError")),unlisten()};e.addEventListener("complete",complete),e.addEventListener("error",error),e.addEventListener("abort",error)}));h.set(e,t)}(e),t=e,function getIdbProxyableTypes(){return l||(l=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}().some((e=>t instanceof e))?new Proxy(e,m):e);var t}function wrap(e){if(e instanceof IDBRequest)return function promisifyRequest(e){const t=new Promise(((t,r)=>{const unlisten=()=>{e.removeEventListener("success",success),e.removeEventListener("error",error)},success=()=>{t(wrap(e.result)),unlisten()},error=()=>{r(e.error),unlisten()};e.addEventListener("success",success),e.addEventListener("error",error)}));return t.then((t=>{t instanceof IDBCursor&&g.set(t,e)})).catch((()=>{})),p.set(t,e),t}(e);if(f.has(e))return f.get(e);const t=transformCachableValue(e);return t!==e&&(f.set(e,t),p.set(t,e)),t}const unwrap=e=>p.get(e);const w=["get","getKey","getAll","getAllKeys","count"],v=["put","add","delete","clear"],E=new Map;function getMethod(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(E.get(t))return E.get(t);const r=t.replace(/FromIndex$/,""),n=t!==r,a=v.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!a&&!w.includes(r))return;const method=async function(e,...t){const s=this.transaction(e,a?"readwrite":"readonly");let i=s.store;return n&&(i=i.index(t.shift())),(await Promise.all([i[r](...t),a&&s.done]))[0]};return E.set(t,method),method}!function replaceTraps(e){m=e(m)}((e=>({...e,get:(t,r,n)=>getMethod(t,r)||e.get(t,r,n),has:(t,r)=>!!getMethod(t,r)||e.has(t,r)})));const y="@firebase/installations",b="0.6.6-dataconnect-preview.f2ddc3d7b",I=`w:${b}`,C=new ErrorFactory("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 isServerError(e){return e instanceof FirebaseError&&e.code.includes("request-failed")}function getInstallationsEndpoint({projectId:e}){return`https://firebaseinstallations.googleapis.com/v1/projects/${e}/installations`}function extractAuthTokenInfoFromResponse(e){return{token:e.token,requestStatus:2,expiresIn:(t=e.expiresIn,Number(t.replace("s","000"))),creationTime:Date.now()};var t}async function getErrorFromResponse(e,t){const r=(await t.json()).error;return C.create("request-failed",{requestName:e,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function getHeaders({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function getHeadersWithAuth(e,{refreshToken:t}){const r=getHeaders(e);return r.append("Authorization",function getAuthorizationHeader(e){return`FIS_v2 ${e}`}(t)),r}async function retryIfServerError(e){const t=await e();return t.status>=500&&t.status<600?e():t}function sleep(e){return new Promise((t=>{setTimeout(t,e)}))}const S=/^[cdef][\w-]{21}$/;function generateFid(){try{const e=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16;const t=function encode(e){return function bufferToBase64UrlSafe(e){return btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_")}(e).substr(0,22)}(e);return S.test(t)?t:""}catch(e){return""}}function getKey(e){return`${e.appName}!${e.appId}`}const T=new Map;function fidChanged(e,t){const r=getKey(e);callFidChangeCallbacks(r,t),function broadcastFidChange(e,t){const r=function getBroadcastChannel(){!_&&"BroadcastChannel"in self&&(_=new BroadcastChannel("[Firebase] FID Change"),_.onmessage=e=>{callFidChangeCallbacks(e.data.key,e.data.fid)});return _}();r&&r.postMessage({key:e,fid:t});!function closeBroadcastChannel(){0===T.size&&_&&(_.close(),_=null)}()}(r,t)}function callFidChangeCallbacks(e,t){const r=T.get(e);if(r)for(const e of r)e(t)}let _=null;const F="firebase-installations-store";let M=null;function getDbPromise(){return M||(M=function openDB(e,t,{blocked:r,upgrade:n,blocking:a,terminated:s}={}){const i=indexedDB.open(e,t),o=wrap(i);return n&&i.addEventListener("upgradeneeded",(e=>{n(wrap(i.result),e.oldVersion,e.newVersion,wrap(i.transaction),e)})),r&&i.addEventListener("blocked",(e=>r(e.oldVersion,e.newVersion,e))),o.then((e=>{s&&e.addEventListener("close",(()=>s())),a&&e.addEventListener("versionchange",(e=>a(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),o}("firebase-installations-database",1,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(F)}})),M}async function set(e,t){const r=getKey(e),n=(await getDbPromise()).transaction(F,"readwrite"),a=n.objectStore(F),s=await a.get(r);return await a.put(t,r),await n.done,s&&s.fid===t.fid||fidChanged(e,t.fid),t}async function remove(e){const t=getKey(e),r=(await getDbPromise()).transaction(F,"readwrite");await r.objectStore(F).delete(t),await r.done}async function update(e,t){const r=getKey(e),n=(await getDbPromise()).transaction(F,"readwrite"),a=n.objectStore(F),s=await a.get(r),i=t(s);return void 0===i?await a.delete(r):await a.put(i,r),await n.done,!i||s&&s.fid===i.fid||fidChanged(e,i.fid),i}async function getInstallationEntry(e){let t;const r=await update(e.appConfig,(r=>{const n=function updateOrCreateInstallationEntry(e){return clearTimedOutRequest(e||{fid:generateFid(),registrationStatus:0})}(r),a=function triggerRegistrationIfNecessary(e,t){if(0===t.registrationStatus){if(!navigator.onLine){return{installationEntry:t,registrationPromise:Promise.reject(C.create("app-offline"))}}const r={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},n=async function registerInstallation(e,t){try{const r=await async function createInstallationRequest({appConfig:e,heartbeatServiceProvider:t},{fid:r}){const n=getInstallationsEndpoint(e),a=getHeaders(e),s=t.getImmediate({optional:!0});if(s){const e=await s.getHeartbeatsHeader();e&&a.append("x-firebase-client",e)}const i={fid:r,authVersion:"FIS_v2",appId:e.appId,sdkVersion:I},o={method:"POST",headers:a,body:JSON.stringify(i)},c=await retryIfServerError((()=>fetch(n,o)));if(c.ok){const e=await c.json();return{fid:e.fid||r,registrationStatus:2,refreshToken:e.refreshToken,authToken:extractAuthTokenInfoFromResponse(e.authToken)}}throw await getErrorFromResponse("Create Installation",c)}(e,t);return set(e.appConfig,r)}catch(r){throw isServerError(r)&&409===r.customData.serverCode?await remove(e.appConfig):await set(e.appConfig,{fid:t.fid,registrationStatus:0}),r}}(e,r);return{installationEntry:r,registrationPromise:n}}return 1===t.registrationStatus?{installationEntry:t,registrationPromise:waitUntilFidRegistration(e)}:{installationEntry:t}}(e,n);return t=a.registrationPromise,a.installationEntry}));return""===r.fid?{installationEntry:await t}:{installationEntry:r,registrationPromise:t}}async function waitUntilFidRegistration(e){let t=await updateInstallationRequest(e.appConfig);for(;1===t.registrationStatus;)await sleep(100),t=await updateInstallationRequest(e.appConfig);if(0===t.registrationStatus){const{installationEntry:t,registrationPromise:r}=await getInstallationEntry(e);return r||t}return t}function updateInstallationRequest(e){return update(e,(e=>{if(!e)throw C.create("installation-not-found");return clearTimedOutRequest(e)}))}function clearTimedOutRequest(e){return function hasInstallationRequestTimedOut(e){return 1===e.registrationStatus&&e.registrationTime+1e4<Date.now()}(e)?{fid:e.fid,registrationStatus:0}:e}async function generateAuthTokenRequest({appConfig:e,heartbeatServiceProvider:t},r){const n=function getGenerateAuthTokenEndpoint(e,{fid:t}){return`${getInstallationsEndpoint(e)}/${t}/authTokens:generate`}(e,r),a=getHeadersWithAuth(e,r),s=t.getImmediate({optional:!0});if(s){const e=await s.getHeartbeatsHeader();e&&a.append("x-firebase-client",e)}const i={installation:{sdkVersion:I,appId:e.appId}},o={method:"POST",headers:a,body:JSON.stringify(i)},c=await retryIfServerError((()=>fetch(n,o)));if(c.ok){return extractAuthTokenInfoFromResponse(await c.json())}throw await getErrorFromResponse("Generate Auth Token",c)}async function refreshAuthToken(e,t=!1){let r;const n=await update(e.appConfig,(n=>{if(!isEntryRegistered(n))throw C.create("not-registered");const a=n.authToken;if(!t&&function isAuthTokenValid(e){return 2===e.requestStatus&&!function isAuthTokenExpired(e){const t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+36e5}(e)}(a))return n;if(1===a.requestStatus)return r=async function waitUntilAuthTokenRequest(e,t){let r=await updateAuthTokenRequest(e.appConfig);for(;1===r.authToken.requestStatus;)await sleep(100),r=await updateAuthTokenRequest(e.appConfig);const n=r.authToken;return 0===n.requestStatus?refreshAuthToken(e,t):n}(e,t),n;{if(!navigator.onLine)throw C.create("app-offline");const t=function makeAuthTokenRequestInProgressEntry(e){const t={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},e),{authToken:t})}(n);return r=async function fetchAuthTokenFromServer(e,t){try{const r=await generateAuthTokenRequest(e,t),n=Object.assign(Object.assign({},t),{authToken:r});return await set(e.appConfig,n),r}catch(r){if(!isServerError(r)||401!==r.customData.serverCode&&404!==r.customData.serverCode){const r=Object.assign(Object.assign({},t),{authToken:{requestStatus:0}});await set(e.appConfig,r)}else await remove(e.appConfig);throw r}}(e,t),t}}));return r?await r:n.authToken}function updateAuthTokenRequest(e){return update(e,(e=>{if(!isEntryRegistered(e))throw C.create("not-registered");return function hasAuthTokenRequestTimedOut(e){return 1===e.requestStatus&&e.requestTime+1e4<Date.now()}(e.authToken)?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e}))}function isEntryRegistered(e){return void 0!==e&&2===e.registrationStatus}async function getToken(e,t=!1){const r=e;await async function completeInstallationRegistration(e){const{registrationPromise:t}=await getInstallationEntry(e);t&&await t}(r);return(await refreshAuthToken(r,t)).token}function getMissingValueError(e){return C.create("missing-app-config-values",{valueName:e})}const publicFactory=e=>{const t=e.getProvider("app").getImmediate(),r=function extractAppConfig(e){if(!e||!e.options)throw getMissingValueError("App Configuration");if(!e.name)throw getMissingValueError("App Name");const t=["projectId","apiKey","appId"];for(const r of t)if(!e.options[r])throw getMissingValueError(r);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t);return{app:t,appConfig:r,heartbeatServiceProvider:_getProvider(t,"heartbeat"),_delete:()=>Promise.resolve()}},internalFactory=e=>{const t=e.getProvider("app").getImmediate(),r=_getProvider(t,"installations").getImmediate();return{getId:()=>async function getId(e){const t=e,{installationEntry:r,registrationPromise:n}=await getInstallationEntry(t);return n?n.catch(console.error):refreshAuthToken(t).catch(console.error),r.fid}(r),getToken:e=>getToken(r,e)}};!function registerInstallations(){t(new Component("installations",publicFactory,"PUBLIC")),t(new Component("installations-internal",internalFactory,"PRIVATE"))}(),e(y,b),e(y,b,"esm2017");const k="@firebase/remote-config",R="0.4.6-dataconnect-preview.f2ddc3d7b";class RemoteConfigAbortSignal{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach((e=>e()))}}const L=new ErrorFactory("remoteconfig","Remote Config",{"registration-window":"Undefined window object. This SDK only supports usage in a browser environment.","registration-project-id":"Undefined project identifier. Check Firebase app initialization.","registration-api-key":"Undefined API key. Check Firebase app initialization.","registration-app-id":"Undefined app identifier. Check Firebase app initialization.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}.","fetch-client-network":"Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-timeout":'The config fetch request timed out. Configure timeout using "fetchTimeoutMillis" SDK setting.',"fetch-throttle":'The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',"fetch-client-parse":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","indexed-db-unavailable":"Indexed DB is not supported by current browser"});const A=["1","true","t","yes","y","on"];class Value{constructor(e,t=""){this._source=e,this._value=t}asString(){return this._value}asBoolean(){return"static"!==this._source&&A.indexOf(this._value.toLowerCase())>=0}asNumber(){if("static"===this._source)return 0;let e=Number(this._value);return isNaN(e)&&(e=0),e}getSource(){return this._source}}function getRemoteConfig(e=r()){e=getModularInstance(e);return _getProvider(e,"remote-config").getImmediate()}async function activate(e){const t=getModularInstance(e),[r,n]=await Promise.all([t._storage.getLastSuccessfulFetchResponse(),t._storage.getActiveConfigEtag()]);return!!(r&&r.config&&r.eTag&&r.eTag!==n)&&(await Promise.all([t._storageCache.setActiveConfig(r.config),t._storage.setActiveConfigEtag(r.eTag)]),!0)}function ensureInitialized(e){const t=getModularInstance(e);return t._initializePromise||(t._initializePromise=t._storageCache.loadFromStorage().then((()=>{t._isInitializationComplete=!0}))),t._initializePromise}async function fetchConfig(e){const t=getModularInstance(e),r=new RemoteConfigAbortSignal;setTimeout((async()=>{r.abort()}),t.settings.fetchTimeoutMillis);try{await t._client.fetch({cacheMaxAgeMillis:t.settings.minimumFetchIntervalMillis,signal:r}),await t._storageCache.setLastFetchStatus("success")}catch(e){const r=function hasErrorCode(e,t){return e instanceof FirebaseError&&-1!==e.code.indexOf(t)}(e,"fetch-throttle")?"throttle":"failure";throw await t._storageCache.setLastFetchStatus(r),e}}function getAll(e){const t=getModularInstance(e);return function getAllKeys(e={},t={}){return Object.keys(Object.assign(Object.assign({},e),t))}(t._storageCache.getActiveConfig(),t.defaultConfig).reduce(((t,r)=>(t[r]=getValue(e,r),t)),{})}function getBoolean(e,t){return getValue(getModularInstance(e),t).asBoolean()}function getNumber(e,t){return getValue(getModularInstance(e),t).asNumber()}function getString(e,t){return getValue(getModularInstance(e),t).asString()}function getValue(e,t){const r=getModularInstance(e);r._isInitializationComplete||r._logger.debug(`A value was requested for key "${t}" before SDK initialization completed. Await on ensureInitialized if the intent was to get a previously activated value.`);const n=r._storageCache.getActiveConfig();return n&&void 0!==n[t]?new Value("remote",n[t]):r.defaultConfig&&void 0!==r.defaultConfig[t]?new Value("default",String(r.defaultConfig[t])):(r._logger.debug(`Returning static value for key "${t}". Define a default or remote value if this is unintentional.`),new Value("static"))}function setLogLevel(e,t){const r=getModularInstance(e);switch(t){case"debug":r._logger.logLevel=s.DEBUG;break;case"silent":r._logger.logLevel=s.SILENT;break;default:r._logger.logLevel=s.ERROR}}class CachingClient{constructor(e,t,r,n){this.client=e,this.storage=t,this.storageCache=r,this.logger=n}isCachedDataFresh(e,t){if(!t)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;const r=Date.now()-t,n=r<=e;return this.logger.debug(`Config fetch cache check. Cache age millis: ${r}. Cache max age millis (minimumFetchIntervalMillis setting): ${e}. Is cache hit: ${n}.`),n}async fetch(e){const[t,r]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(r&&this.isCachedDataFresh(e.cacheMaxAgeMillis,t))return r;e.eTag=r&&r.eTag;const n=await this.client.fetch(e),a=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===n.status&&a.push(this.storage.setLastSuccessfulFetchResponse(n)),await Promise.all(a),n}}function getUserLanguage(e=navigator){return e.languages&&e.languages[0]||e.language}class RestClient{constructor(e,t,r,n,a,s){this.firebaseInstallations=e,this.sdkVersion=t,this.namespace=r,this.projectId=n,this.apiKey=a,this.appId=s}async fetch(e){const[t,r]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),n=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,a={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":e.eTag||"*"},s={sdk_version:this.sdkVersion,app_instance_id:t,app_instance_id_token:r,app_id:this.appId,language_code:getUserLanguage()},i={method:"POST",headers:a,body:JSON.stringify(s)},o=fetch(n,i),c=new Promise(((t,r)=>{e.signal.addEventListener((()=>{const e=new Error("The operation was aborted.");e.name="AbortError",r(e)}))}));let l;try{await Promise.race([o,c]),l=await o}catch(e){let t="fetch-client-network";throw"AbortError"===(null==e?void 0:e.name)&&(t="fetch-timeout"),L.create(t,{originalErrorMessage:null==e?void 0:e.message})}let u=l.status;const g=l.headers.get("ETag")||void 0;let h,d;if(200===l.status){let e;try{e=await l.json()}catch(e){throw L.create("fetch-client-parse",{originalErrorMessage:null==e?void 0:e.message})}h=e.entries,d=e.state}if("INSTANCE_STATE_UNSPECIFIED"===d?u=500:"NO_CHANGE"===d?u=304:"NO_TEMPLATE"!==d&&"EMPTY_CONFIG"!==d||(h={}),304!==u&&200!==u)throw L.create("fetch-status",{httpStatus:u});return{status:u,eTag:g,config:h}}}class RetryingClient{constructor(e,t){this.client=e,this.storage=t}async fetch(e){const t=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(e,t)}async attemptFetch(e,{throttleEndTimeMillis:t,backoffCount:r}){await function setAbortableTimeout(e,t){return new Promise(((r,n)=>{const a=Math.max(t-Date.now(),0),s=setTimeout(r,a);e.addEventListener((()=>{clearTimeout(s),n(L.create("fetch-throttle",{throttleEndTimeMillis:t}))}))}))}(e.signal,t);try{const t=await this.client.fetch(e);return await this.storage.deleteThrottleMetadata(),t}catch(t){if(!function isRetriableError(e){if(!(e instanceof FirebaseError&&e.customData))return!1;const t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}(t))throw t;const n={throttleEndTimeMillis:Date.now()+calculateBackoffMillis(r),backoffCount:r+1};return await this.storage.setThrottleMetadata(n),this.attemptFetch(e,n)}}}class RemoteConfig{constructor(e,t,r,n,a){this.app=e,this._client=t,this._storageCache=r,this._storage=n,this._logger=a,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}get fetchTimeMillis(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1}get lastFetchStatus(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"}}function toFirebaseError(e,t){const r=e.target.error||void 0;return L.create(t,{originalErrorMessage:r&&(null==r?void 0:r.message)})}class Storage{constructor(e,t,r,n=function openDatabase(){return new Promise(((e,t)=>{try{const r=indexedDB.open("firebase_remote_config",1);r.onerror=e=>{t(toFirebaseError(e,"storage-open"))},r.onsuccess=t=>{e(t.target.result)},r.onupgradeneeded=e=>{const t=e.target.result;0===e.oldVersion&&t.createObjectStore("app_namespace_store",{keyPath:"compositeKey"})}}catch(e){t(L.create("storage-open",{originalErrorMessage:null==e?void 0:e.message}))}}))}()){this.appId=e,this.appName=t,this.namespace=r,this.openDbPromise=n}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(e){return this.set("last_fetch_status",e)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(e){return this.set("last_successful_fetch_timestamp_millis",e)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(e){return this.set("last_successful_fetch_response",e)}getActiveConfig(){return this.get("active_config")}setActiveConfig(e){return this.set("active_config",e)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(e){return this.set("active_config_etag",e)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(e){return this.set("throttle_metadata",e)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(e){const t=await this.openDbPromise;return new Promise(((r,n)=>{const a=t.transaction(["app_namespace_store"],"readonly").objectStore("app_namespace_store"),s=this.createCompositeKey(e);try{const e=a.get(s);e.onerror=e=>{n(toFirebaseError(e,"storage-get"))},e.onsuccess=e=>{const t=e.target.result;r(t?t.value:void 0)}}catch(e){n(L.create("storage-get",{originalErrorMessage:null==e?void 0:e.message}))}}))}async set(e,t){const r=await this.openDbPromise;return new Promise(((n,a)=>{const s=r.transaction(["app_namespace_store"],"readwrite").objectStore("app_namespace_store"),i=this.createCompositeKey(e);try{const e=s.put({compositeKey:i,value:t});e.onerror=e=>{a(toFirebaseError(e,"storage-set"))},e.onsuccess=()=>{n()}}catch(e){a(L.create("storage-set",{originalErrorMessage:null==e?void 0:e.message}))}}))}async delete(e){const t=await this.openDbPromise;return new Promise(((r,n)=>{const a=t.transaction(["app_namespace_store"],"readwrite").objectStore("app_namespace_store"),s=this.createCompositeKey(e);try{const e=a.delete(s);e.onerror=e=>{n(toFirebaseError(e,"storage-delete"))},e.onsuccess=()=>{r()}}catch(e){n(L.create("storage-delete",{originalErrorMessage:null==e?void 0:e.message}))}}))}createCompositeKey(e){return[this.appId,this.appName,this.namespace,e].join()}}class StorageCache{constructor(e){this.storage=e}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){const e=this.storage.getLastFetchStatus(),t=this.storage.getLastSuccessfulFetchTimestampMillis(),r=this.storage.getActiveConfig(),n=await e;n&&(this.lastFetchStatus=n);const a=await t;a&&(this.lastSuccessfulFetchTimestampMillis=a);const s=await r;s&&(this.activeConfig=s)}setLastFetchStatus(e){return this.lastFetchStatus=e,this.storage.setLastFetchStatus(e)}setLastSuccessfulFetchTimestampMillis(e){return this.lastSuccessfulFetchTimestampMillis=e,this.storage.setLastSuccessfulFetchTimestampMillis(e)}setActiveConfig(e){return this.activeConfig=e,this.storage.setActiveConfig(e)}}async function fetchAndActivate(e){return e=getModularInstance(e),await fetchConfig(e),activate(e)}async function isSupported(){if(!isIndexedDBAvailable())return!1;try{return await function validateIndexedDBOpenable(){return new Promise(((e,t)=>{try{let r=!0;const n="validate-browser-context-for-indexeddb-analytics-module",a=self.indexedDB.open(n);a.onsuccess=()=>{a.result.close(),r||self.indexedDB.deleteDatabase(n),e(!0)},a.onupgradeneeded=()=>{r=!1},a.onerror=()=>{var e;t((null===(e=a.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}}))}()}catch(e){return!1}}!function registerRemoteConfig(){t(new Component("remote-config",(function remoteConfigFactory(e,{instanceIdentifier:t}){const r=e.getProvider("app").getImmediate(),a=e.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw L.create("registration-window");if(!isIndexedDBAvailable())throw L.create("indexed-db-unavailable");const{projectId:i,apiKey:o,appId:c}=r.options;if(!i)throw L.create("registration-project-id");if(!o)throw L.create("registration-api-key");if(!c)throw L.create("registration-app-id");t=t||"firebase";const l=new Storage(c,r.name,t),u=new StorageCache(l),g=new Logger(k);g.logLevel=s.ERROR;const h=new RestClient(a,n,t,i,o,c),d=new RetryingClient(h,l),f=new CachingClient(d,l,u,g),p=new RemoteConfig(r,f,u,l,g);return ensureInitialized(p),p}),"PUBLIC").setMultipleInstances(!0)),e(k,R),e(k,R,"esm2017")}();export{activate,ensureInitialized,fetchAndActivate,fetchConfig,getAll,getBoolean,getNumber,getRemoteConfig,getString,getValue,isSupported,setLogLevel};
|
|
1
|
+
import{registerVersion as e,_registerComponent as t,_getProvider,getApp as r,SDK_VERSION as n}from"https://www.gstatic.com/firebasejs/10.11.1-dataconnect-preview.42eb5e521/firebase-app.js";function isIndexedDBAvailable(){try{return"object"==typeof indexedDB}catch(e){return!1}}class FirebaseError extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,FirebaseError.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,ErrorFactory.prototype.create)}}class ErrorFactory{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},n=`${this.service}/${e}`,s=this.errors[e],i=s?function replaceTemplate(e,t){return e.replace(a,((e,r)=>{const n=t[r];return null!=n?String(n):`<${r}?>`}))}(s,r):"Error",o=`${this.serviceName}: ${i} (${n}).`;return new FirebaseError(n,o,r)}}const a=/\{\$([^}]+)}/g;function calculateBackoffMillis(e,t=1e3,r=2){const n=t*Math.pow(r,e),a=Math.round(.5*n*(Math.random()-.5)*2);return Math.min(144e5,n+a)}function getModularInstance(e){return e&&e._delegate?e._delegate:e}class Component{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}}var s;!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"}(s||(s={}));const i={debug:s.DEBUG,verbose:s.VERBOSE,info:s.INFO,warn:s.WARN,error:s.ERROR,silent:s.SILENT},o=s.INFO,c={[s.DEBUG]:"log",[s.VERBOSE]:"log",[s.INFO]:"info",[s.WARN]:"warn",[s.ERROR]:"error"},defaultLogHandler=(e,t,...r)=>{if(t<e.logLevel)return;const n=(new Date).toISOString(),a=c[t];if(!a)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[a](`[${n}] ${e.name}:`,...r)};class Logger{constructor(e){this.name=e,this._logLevel=o,this._logHandler=defaultLogHandler,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in s))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?i[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,s.DEBUG,...e),this._logHandler(this,s.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,s.VERBOSE,...e),this._logHandler(this,s.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,s.INFO,...e),this._logHandler(this,s.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,s.WARN,...e),this._logHandler(this,s.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,s.ERROR,...e),this._logHandler(this,s.ERROR,...e)}}let l,u;const g=new WeakMap,h=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakMap;let m={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return h.get(e);if("objectStoreNames"===t)return e.objectStoreNames||d.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return wrap(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function wrapFunction(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?function getCursorAdvanceMethods(){return u||(u=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}().includes(e)?function(...t){return e.apply(unwrap(this),t),wrap(g.get(this))}:function(...t){return wrap(e.apply(unwrap(this),t))}:function(t,...r){const n=e.call(unwrap(this),t,...r);return d.set(n,t.sort?t.sort():[t]),wrap(n)}}function transformCachableValue(e){return"function"==typeof e?wrapFunction(e):(e instanceof IDBTransaction&&function cacheDonePromiseForTransaction(e){if(h.has(e))return;const t=new Promise(((t,r)=>{const unlisten=()=>{e.removeEventListener("complete",complete),e.removeEventListener("error",error),e.removeEventListener("abort",error)},complete=()=>{t(),unlisten()},error=()=>{r(e.error||new DOMException("AbortError","AbortError")),unlisten()};e.addEventListener("complete",complete),e.addEventListener("error",error),e.addEventListener("abort",error)}));h.set(e,t)}(e),t=e,function getIdbProxyableTypes(){return l||(l=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}().some((e=>t instanceof e))?new Proxy(e,m):e);var t}function wrap(e){if(e instanceof IDBRequest)return function promisifyRequest(e){const t=new Promise(((t,r)=>{const unlisten=()=>{e.removeEventListener("success",success),e.removeEventListener("error",error)},success=()=>{t(wrap(e.result)),unlisten()},error=()=>{r(e.error),unlisten()};e.addEventListener("success",success),e.addEventListener("error",error)}));return t.then((t=>{t instanceof IDBCursor&&g.set(t,e)})).catch((()=>{})),p.set(t,e),t}(e);if(f.has(e))return f.get(e);const t=transformCachableValue(e);return t!==e&&(f.set(e,t),p.set(t,e)),t}const unwrap=e=>p.get(e);const w=["get","getKey","getAll","getAllKeys","count"],v=["put","add","delete","clear"],E=new Map;function getMethod(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(E.get(t))return E.get(t);const r=t.replace(/FromIndex$/,""),n=t!==r,a=v.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!a&&!w.includes(r))return;const method=async function(e,...t){const s=this.transaction(e,a?"readwrite":"readonly");let i=s.store;return n&&(i=i.index(t.shift())),(await Promise.all([i[r](...t),a&&s.done]))[0]};return E.set(t,method),method}!function replaceTraps(e){m=e(m)}((e=>({...e,get:(t,r,n)=>getMethod(t,r)||e.get(t,r,n),has:(t,r)=>!!getMethod(t,r)||e.has(t,r)})));const y="@firebase/installations",b="0.6.6-dataconnect-preview.42eb5e521",I=`w:${b}`,C=new ErrorFactory("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 isServerError(e){return e instanceof FirebaseError&&e.code.includes("request-failed")}function getInstallationsEndpoint({projectId:e}){return`https://firebaseinstallations.googleapis.com/v1/projects/${e}/installations`}function extractAuthTokenInfoFromResponse(e){return{token:e.token,requestStatus:2,expiresIn:(t=e.expiresIn,Number(t.replace("s","000"))),creationTime:Date.now()};var t}async function getErrorFromResponse(e,t){const r=(await t.json()).error;return C.create("request-failed",{requestName:e,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function getHeaders({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function getHeadersWithAuth(e,{refreshToken:t}){const r=getHeaders(e);return r.append("Authorization",function getAuthorizationHeader(e){return`FIS_v2 ${e}`}(t)),r}async function retryIfServerError(e){const t=await e();return t.status>=500&&t.status<600?e():t}function sleep(e){return new Promise((t=>{setTimeout(t,e)}))}const S=/^[cdef][\w-]{21}$/;function generateFid(){try{const e=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16;const t=function encode(e){return function bufferToBase64UrlSafe(e){return btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_")}(e).substr(0,22)}(e);return S.test(t)?t:""}catch(e){return""}}function getKey(e){return`${e.appName}!${e.appId}`}const T=new Map;function fidChanged(e,t){const r=getKey(e);callFidChangeCallbacks(r,t),function broadcastFidChange(e,t){const r=function getBroadcastChannel(){!_&&"BroadcastChannel"in self&&(_=new BroadcastChannel("[Firebase] FID Change"),_.onmessage=e=>{callFidChangeCallbacks(e.data.key,e.data.fid)});return _}();r&&r.postMessage({key:e,fid:t});!function closeBroadcastChannel(){0===T.size&&_&&(_.close(),_=null)}()}(r,t)}function callFidChangeCallbacks(e,t){const r=T.get(e);if(r)for(const e of r)e(t)}let _=null;const F="firebase-installations-store";let M=null;function getDbPromise(){return M||(M=function openDB(e,t,{blocked:r,upgrade:n,blocking:a,terminated:s}={}){const i=indexedDB.open(e,t),o=wrap(i);return n&&i.addEventListener("upgradeneeded",(e=>{n(wrap(i.result),e.oldVersion,e.newVersion,wrap(i.transaction),e)})),r&&i.addEventListener("blocked",(e=>r(e.oldVersion,e.newVersion,e))),o.then((e=>{s&&e.addEventListener("close",(()=>s())),a&&e.addEventListener("versionchange",(e=>a(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),o}("firebase-installations-database",1,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(F)}})),M}async function set(e,t){const r=getKey(e),n=(await getDbPromise()).transaction(F,"readwrite"),a=n.objectStore(F),s=await a.get(r);return await a.put(t,r),await n.done,s&&s.fid===t.fid||fidChanged(e,t.fid),t}async function remove(e){const t=getKey(e),r=(await getDbPromise()).transaction(F,"readwrite");await r.objectStore(F).delete(t),await r.done}async function update(e,t){const r=getKey(e),n=(await getDbPromise()).transaction(F,"readwrite"),a=n.objectStore(F),s=await a.get(r),i=t(s);return void 0===i?await a.delete(r):await a.put(i,r),await n.done,!i||s&&s.fid===i.fid||fidChanged(e,i.fid),i}async function getInstallationEntry(e){let t;const r=await update(e.appConfig,(r=>{const n=function updateOrCreateInstallationEntry(e){return clearTimedOutRequest(e||{fid:generateFid(),registrationStatus:0})}(r),a=function triggerRegistrationIfNecessary(e,t){if(0===t.registrationStatus){if(!navigator.onLine){return{installationEntry:t,registrationPromise:Promise.reject(C.create("app-offline"))}}const r={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},n=async function registerInstallation(e,t){try{const r=await async function createInstallationRequest({appConfig:e,heartbeatServiceProvider:t},{fid:r}){const n=getInstallationsEndpoint(e),a=getHeaders(e),s=t.getImmediate({optional:!0});if(s){const e=await s.getHeartbeatsHeader();e&&a.append("x-firebase-client",e)}const i={fid:r,authVersion:"FIS_v2",appId:e.appId,sdkVersion:I},o={method:"POST",headers:a,body:JSON.stringify(i)},c=await retryIfServerError((()=>fetch(n,o)));if(c.ok){const e=await c.json();return{fid:e.fid||r,registrationStatus:2,refreshToken:e.refreshToken,authToken:extractAuthTokenInfoFromResponse(e.authToken)}}throw await getErrorFromResponse("Create Installation",c)}(e,t);return set(e.appConfig,r)}catch(r){throw isServerError(r)&&409===r.customData.serverCode?await remove(e.appConfig):await set(e.appConfig,{fid:t.fid,registrationStatus:0}),r}}(e,r);return{installationEntry:r,registrationPromise:n}}return 1===t.registrationStatus?{installationEntry:t,registrationPromise:waitUntilFidRegistration(e)}:{installationEntry:t}}(e,n);return t=a.registrationPromise,a.installationEntry}));return""===r.fid?{installationEntry:await t}:{installationEntry:r,registrationPromise:t}}async function waitUntilFidRegistration(e){let t=await updateInstallationRequest(e.appConfig);for(;1===t.registrationStatus;)await sleep(100),t=await updateInstallationRequest(e.appConfig);if(0===t.registrationStatus){const{installationEntry:t,registrationPromise:r}=await getInstallationEntry(e);return r||t}return t}function updateInstallationRequest(e){return update(e,(e=>{if(!e)throw C.create("installation-not-found");return clearTimedOutRequest(e)}))}function clearTimedOutRequest(e){return function hasInstallationRequestTimedOut(e){return 1===e.registrationStatus&&e.registrationTime+1e4<Date.now()}(e)?{fid:e.fid,registrationStatus:0}:e}async function generateAuthTokenRequest({appConfig:e,heartbeatServiceProvider:t},r){const n=function getGenerateAuthTokenEndpoint(e,{fid:t}){return`${getInstallationsEndpoint(e)}/${t}/authTokens:generate`}(e,r),a=getHeadersWithAuth(e,r),s=t.getImmediate({optional:!0});if(s){const e=await s.getHeartbeatsHeader();e&&a.append("x-firebase-client",e)}const i={installation:{sdkVersion:I,appId:e.appId}},o={method:"POST",headers:a,body:JSON.stringify(i)},c=await retryIfServerError((()=>fetch(n,o)));if(c.ok){return extractAuthTokenInfoFromResponse(await c.json())}throw await getErrorFromResponse("Generate Auth Token",c)}async function refreshAuthToken(e,t=!1){let r;const n=await update(e.appConfig,(n=>{if(!isEntryRegistered(n))throw C.create("not-registered");const a=n.authToken;if(!t&&function isAuthTokenValid(e){return 2===e.requestStatus&&!function isAuthTokenExpired(e){const t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+36e5}(e)}(a))return n;if(1===a.requestStatus)return r=async function waitUntilAuthTokenRequest(e,t){let r=await updateAuthTokenRequest(e.appConfig);for(;1===r.authToken.requestStatus;)await sleep(100),r=await updateAuthTokenRequest(e.appConfig);const n=r.authToken;return 0===n.requestStatus?refreshAuthToken(e,t):n}(e,t),n;{if(!navigator.onLine)throw C.create("app-offline");const t=function makeAuthTokenRequestInProgressEntry(e){const t={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},e),{authToken:t})}(n);return r=async function fetchAuthTokenFromServer(e,t){try{const r=await generateAuthTokenRequest(e,t),n=Object.assign(Object.assign({},t),{authToken:r});return await set(e.appConfig,n),r}catch(r){if(!isServerError(r)||401!==r.customData.serverCode&&404!==r.customData.serverCode){const r=Object.assign(Object.assign({},t),{authToken:{requestStatus:0}});await set(e.appConfig,r)}else await remove(e.appConfig);throw r}}(e,t),t}}));return r?await r:n.authToken}function updateAuthTokenRequest(e){return update(e,(e=>{if(!isEntryRegistered(e))throw C.create("not-registered");return function hasAuthTokenRequestTimedOut(e){return 1===e.requestStatus&&e.requestTime+1e4<Date.now()}(e.authToken)?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e}))}function isEntryRegistered(e){return void 0!==e&&2===e.registrationStatus}async function getToken(e,t=!1){const r=e;await async function completeInstallationRegistration(e){const{registrationPromise:t}=await getInstallationEntry(e);t&&await t}(r);return(await refreshAuthToken(r,t)).token}function getMissingValueError(e){return C.create("missing-app-config-values",{valueName:e})}const publicFactory=e=>{const t=e.getProvider("app").getImmediate(),r=function extractAppConfig(e){if(!e||!e.options)throw getMissingValueError("App Configuration");if(!e.name)throw getMissingValueError("App Name");const t=["projectId","apiKey","appId"];for(const r of t)if(!e.options[r])throw getMissingValueError(r);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t);return{app:t,appConfig:r,heartbeatServiceProvider:_getProvider(t,"heartbeat"),_delete:()=>Promise.resolve()}},internalFactory=e=>{const t=e.getProvider("app").getImmediate(),r=_getProvider(t,"installations").getImmediate();return{getId:()=>async function getId(e){const t=e,{installationEntry:r,registrationPromise:n}=await getInstallationEntry(t);return n?n.catch(console.error):refreshAuthToken(t).catch(console.error),r.fid}(r),getToken:e=>getToken(r,e)}};!function registerInstallations(){t(new Component("installations",publicFactory,"PUBLIC")),t(new Component("installations-internal",internalFactory,"PRIVATE"))}(),e(y,b),e(y,b,"esm2017");const k="@firebase/remote-config",R="0.4.6-dataconnect-preview.42eb5e521";class RemoteConfigAbortSignal{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach((e=>e()))}}const L=new ErrorFactory("remoteconfig","Remote Config",{"registration-window":"Undefined window object. This SDK only supports usage in a browser environment.","registration-project-id":"Undefined project identifier. Check Firebase app initialization.","registration-api-key":"Undefined API key. Check Firebase app initialization.","registration-app-id":"Undefined app identifier. Check Firebase app initialization.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}.","fetch-client-network":"Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-timeout":'The config fetch request timed out. Configure timeout using "fetchTimeoutMillis" SDK setting.',"fetch-throttle":'The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',"fetch-client-parse":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","indexed-db-unavailable":"Indexed DB is not supported by current browser"});const A=["1","true","t","yes","y","on"];class Value{constructor(e,t=""){this._source=e,this._value=t}asString(){return this._value}asBoolean(){return"static"!==this._source&&A.indexOf(this._value.toLowerCase())>=0}asNumber(){if("static"===this._source)return 0;let e=Number(this._value);return isNaN(e)&&(e=0),e}getSource(){return this._source}}function getRemoteConfig(e=r()){e=getModularInstance(e);return _getProvider(e,"remote-config").getImmediate()}async function activate(e){const t=getModularInstance(e),[r,n]=await Promise.all([t._storage.getLastSuccessfulFetchResponse(),t._storage.getActiveConfigEtag()]);return!!(r&&r.config&&r.eTag&&r.eTag!==n)&&(await Promise.all([t._storageCache.setActiveConfig(r.config),t._storage.setActiveConfigEtag(r.eTag)]),!0)}function ensureInitialized(e){const t=getModularInstance(e);return t._initializePromise||(t._initializePromise=t._storageCache.loadFromStorage().then((()=>{t._isInitializationComplete=!0}))),t._initializePromise}async function fetchConfig(e){const t=getModularInstance(e),r=new RemoteConfigAbortSignal;setTimeout((async()=>{r.abort()}),t.settings.fetchTimeoutMillis);try{await t._client.fetch({cacheMaxAgeMillis:t.settings.minimumFetchIntervalMillis,signal:r}),await t._storageCache.setLastFetchStatus("success")}catch(e){const r=function hasErrorCode(e,t){return e instanceof FirebaseError&&-1!==e.code.indexOf(t)}(e,"fetch-throttle")?"throttle":"failure";throw await t._storageCache.setLastFetchStatus(r),e}}function getAll(e){const t=getModularInstance(e);return function getAllKeys(e={},t={}){return Object.keys(Object.assign(Object.assign({},e),t))}(t._storageCache.getActiveConfig(),t.defaultConfig).reduce(((t,r)=>(t[r]=getValue(e,r),t)),{})}function getBoolean(e,t){return getValue(getModularInstance(e),t).asBoolean()}function getNumber(e,t){return getValue(getModularInstance(e),t).asNumber()}function getString(e,t){return getValue(getModularInstance(e),t).asString()}function getValue(e,t){const r=getModularInstance(e);r._isInitializationComplete||r._logger.debug(`A value was requested for key "${t}" before SDK initialization completed. Await on ensureInitialized if the intent was to get a previously activated value.`);const n=r._storageCache.getActiveConfig();return n&&void 0!==n[t]?new Value("remote",n[t]):r.defaultConfig&&void 0!==r.defaultConfig[t]?new Value("default",String(r.defaultConfig[t])):(r._logger.debug(`Returning static value for key "${t}". Define a default or remote value if this is unintentional.`),new Value("static"))}function setLogLevel(e,t){const r=getModularInstance(e);switch(t){case"debug":r._logger.logLevel=s.DEBUG;break;case"silent":r._logger.logLevel=s.SILENT;break;default:r._logger.logLevel=s.ERROR}}class CachingClient{constructor(e,t,r,n){this.client=e,this.storage=t,this.storageCache=r,this.logger=n}isCachedDataFresh(e,t){if(!t)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;const r=Date.now()-t,n=r<=e;return this.logger.debug(`Config fetch cache check. Cache age millis: ${r}. Cache max age millis (minimumFetchIntervalMillis setting): ${e}. Is cache hit: ${n}.`),n}async fetch(e){const[t,r]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(r&&this.isCachedDataFresh(e.cacheMaxAgeMillis,t))return r;e.eTag=r&&r.eTag;const n=await this.client.fetch(e),a=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===n.status&&a.push(this.storage.setLastSuccessfulFetchResponse(n)),await Promise.all(a),n}}function getUserLanguage(e=navigator){return e.languages&&e.languages[0]||e.language}class RestClient{constructor(e,t,r,n,a,s){this.firebaseInstallations=e,this.sdkVersion=t,this.namespace=r,this.projectId=n,this.apiKey=a,this.appId=s}async fetch(e){const[t,r]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),n=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,a={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":e.eTag||"*"},s={sdk_version:this.sdkVersion,app_instance_id:t,app_instance_id_token:r,app_id:this.appId,language_code:getUserLanguage()},i={method:"POST",headers:a,body:JSON.stringify(s)},o=fetch(n,i),c=new Promise(((t,r)=>{e.signal.addEventListener((()=>{const e=new Error("The operation was aborted.");e.name="AbortError",r(e)}))}));let l;try{await Promise.race([o,c]),l=await o}catch(e){let t="fetch-client-network";throw"AbortError"===(null==e?void 0:e.name)&&(t="fetch-timeout"),L.create(t,{originalErrorMessage:null==e?void 0:e.message})}let u=l.status;const g=l.headers.get("ETag")||void 0;let h,d;if(200===l.status){let e;try{e=await l.json()}catch(e){throw L.create("fetch-client-parse",{originalErrorMessage:null==e?void 0:e.message})}h=e.entries,d=e.state}if("INSTANCE_STATE_UNSPECIFIED"===d?u=500:"NO_CHANGE"===d?u=304:"NO_TEMPLATE"!==d&&"EMPTY_CONFIG"!==d||(h={}),304!==u&&200!==u)throw L.create("fetch-status",{httpStatus:u});return{status:u,eTag:g,config:h}}}class RetryingClient{constructor(e,t){this.client=e,this.storage=t}async fetch(e){const t=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(e,t)}async attemptFetch(e,{throttleEndTimeMillis:t,backoffCount:r}){await function setAbortableTimeout(e,t){return new Promise(((r,n)=>{const a=Math.max(t-Date.now(),0),s=setTimeout(r,a);e.addEventListener((()=>{clearTimeout(s),n(L.create("fetch-throttle",{throttleEndTimeMillis:t}))}))}))}(e.signal,t);try{const t=await this.client.fetch(e);return await this.storage.deleteThrottleMetadata(),t}catch(t){if(!function isRetriableError(e){if(!(e instanceof FirebaseError&&e.customData))return!1;const t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}(t))throw t;const n={throttleEndTimeMillis:Date.now()+calculateBackoffMillis(r),backoffCount:r+1};return await this.storage.setThrottleMetadata(n),this.attemptFetch(e,n)}}}class RemoteConfig{constructor(e,t,r,n,a){this.app=e,this._client=t,this._storageCache=r,this._storage=n,this._logger=a,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}get fetchTimeMillis(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1}get lastFetchStatus(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"}}function toFirebaseError(e,t){const r=e.target.error||void 0;return L.create(t,{originalErrorMessage:r&&(null==r?void 0:r.message)})}class Storage{constructor(e,t,r,n=function openDatabase(){return new Promise(((e,t)=>{try{const r=indexedDB.open("firebase_remote_config",1);r.onerror=e=>{t(toFirebaseError(e,"storage-open"))},r.onsuccess=t=>{e(t.target.result)},r.onupgradeneeded=e=>{const t=e.target.result;0===e.oldVersion&&t.createObjectStore("app_namespace_store",{keyPath:"compositeKey"})}}catch(e){t(L.create("storage-open",{originalErrorMessage:null==e?void 0:e.message}))}}))}()){this.appId=e,this.appName=t,this.namespace=r,this.openDbPromise=n}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(e){return this.set("last_fetch_status",e)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(e){return this.set("last_successful_fetch_timestamp_millis",e)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(e){return this.set("last_successful_fetch_response",e)}getActiveConfig(){return this.get("active_config")}setActiveConfig(e){return this.set("active_config",e)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(e){return this.set("active_config_etag",e)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(e){return this.set("throttle_metadata",e)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(e){const t=await this.openDbPromise;return new Promise(((r,n)=>{const a=t.transaction(["app_namespace_store"],"readonly").objectStore("app_namespace_store"),s=this.createCompositeKey(e);try{const e=a.get(s);e.onerror=e=>{n(toFirebaseError(e,"storage-get"))},e.onsuccess=e=>{const t=e.target.result;r(t?t.value:void 0)}}catch(e){n(L.create("storage-get",{originalErrorMessage:null==e?void 0:e.message}))}}))}async set(e,t){const r=await this.openDbPromise;return new Promise(((n,a)=>{const s=r.transaction(["app_namespace_store"],"readwrite").objectStore("app_namespace_store"),i=this.createCompositeKey(e);try{const e=s.put({compositeKey:i,value:t});e.onerror=e=>{a(toFirebaseError(e,"storage-set"))},e.onsuccess=()=>{n()}}catch(e){a(L.create("storage-set",{originalErrorMessage:null==e?void 0:e.message}))}}))}async delete(e){const t=await this.openDbPromise;return new Promise(((r,n)=>{const a=t.transaction(["app_namespace_store"],"readwrite").objectStore("app_namespace_store"),s=this.createCompositeKey(e);try{const e=a.delete(s);e.onerror=e=>{n(toFirebaseError(e,"storage-delete"))},e.onsuccess=()=>{r()}}catch(e){n(L.create("storage-delete",{originalErrorMessage:null==e?void 0:e.message}))}}))}createCompositeKey(e){return[this.appId,this.appName,this.namespace,e].join()}}class StorageCache{constructor(e){this.storage=e}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){const e=this.storage.getLastFetchStatus(),t=this.storage.getLastSuccessfulFetchTimestampMillis(),r=this.storage.getActiveConfig(),n=await e;n&&(this.lastFetchStatus=n);const a=await t;a&&(this.lastSuccessfulFetchTimestampMillis=a);const s=await r;s&&(this.activeConfig=s)}setLastFetchStatus(e){return this.lastFetchStatus=e,this.storage.setLastFetchStatus(e)}setLastSuccessfulFetchTimestampMillis(e){return this.lastSuccessfulFetchTimestampMillis=e,this.storage.setLastSuccessfulFetchTimestampMillis(e)}setActiveConfig(e){return this.activeConfig=e,this.storage.setActiveConfig(e)}}async function fetchAndActivate(e){return e=getModularInstance(e),await fetchConfig(e),activate(e)}async function isSupported(){if(!isIndexedDBAvailable())return!1;try{return await function validateIndexedDBOpenable(){return new Promise(((e,t)=>{try{let r=!0;const n="validate-browser-context-for-indexeddb-analytics-module",a=self.indexedDB.open(n);a.onsuccess=()=>{a.result.close(),r||self.indexedDB.deleteDatabase(n),e(!0)},a.onupgradeneeded=()=>{r=!1},a.onerror=()=>{var e;t((null===(e=a.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}}))}()}catch(e){return!1}}!function registerRemoteConfig(){t(new Component("remote-config",(function remoteConfigFactory(e,{instanceIdentifier:t}){const r=e.getProvider("app").getImmediate(),a=e.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw L.create("registration-window");if(!isIndexedDBAvailable())throw L.create("indexed-db-unavailable");const{projectId:i,apiKey:o,appId:c}=r.options;if(!i)throw L.create("registration-project-id");if(!o)throw L.create("registration-api-key");if(!c)throw L.create("registration-app-id");t=t||"firebase";const l=new Storage(c,r.name,t),u=new StorageCache(l),g=new Logger(k);g.logLevel=s.ERROR;const h=new RestClient(a,n,t,i,o,c),d=new RetryingClient(h,l),f=new CachingClient(d,l,u,g),p=new RemoteConfig(r,f,u,l,g);return ensureInitialized(p),p}),"PUBLIC").setMultipleInstances(!0)),e(k,R),e(k,R,"esm2017")}();export{activate,ensureInitialized,fetchAndActivate,fetchConfig,getAll,getBoolean,getNumber,getRemoteConfig,getString,getValue,isSupported,setLogLevel};
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=firebase-remote-config.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!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(tt,rt){"use strict";try{!(function(){function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g,i,t,r,s,n=e(tt);function o(t){const r=[];let s=0;for(let n=0;n<t.length;n++){let e=t.charCodeAt(n);e<128?r[s++]=e:(e<2048?r[s++]=e>>6|192:(55296==(64512&e)&&n+1<t.length&&56320==(64512&t.charCodeAt(n+1))?(e=65536+((1023&e)<<10)+(1023&t.charCodeAt(++n)),r[s++]=e>>18|240,r[s++]=e>>12&63|128):r[s++]=e>>12|224,r[s++]=e>>6&63|128),r[s++]=63&e|128)}return r}const a={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(r,e){if(!Array.isArray(r))throw Error("encodeByteArray takes an array as a parameter");this.init_();var s=e?this.byteToCharMapWebSafe_:this.byteToCharMap_;const n=[];for(let u=0;u<r.length;u+=3){var i=r[u],o=u+1<r.length,a=o?r[u+1]:0,h=u+2<r.length,l=h?r[u+2]:0;let e=(15&a)<<2|l>>6,t=63&l;h||(t=64,o||(e=64)),n.push(s[i>>2],s[(3&i)<<4|a>>4],s[e],s[t])}return n.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(o(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let r=0,s=0;for(;r<e.length;){var n,i,o=e[r++];o<128?t[s++]=String.fromCharCode(o):191<o&&o<224?(n=e[r++],t[s++]=String.fromCharCode((31&o)<<6|63&n)):239<o&&o<365?(i=((7&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,t[s++]=String.fromCharCode(55296+(i>>10)),t[s++]=String.fromCharCode(56320+(1023&i))):(n=e[r++],i=e[r++],t[s++]=String.fromCharCode((15&o)<<12|(63&n)<<6|63&i))}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();var r=t?this.charToByteMapWebSafe_:this.charToByteMap_;const s=[];for(let h=0;h<e.length;){var n=r[e.charAt(h++)],i=h<e.length?r[e.charAt(h)]:0;++h;var o=h<e.length?r[e.charAt(h)]:64;++h;var a=h<e.length?r[e.charAt(h)]:64;if(++h,null==n||null==i||null==o||null==a)throw new l;s.push(n<<2|i>>4),64!==o&&(s.push(i<<4&240|o>>2),64!==a&&s.push(o<<6&192|a))}return s},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 h(e){return u(e).replace(/\./g,"")}const u=function(e){var t=o(e);return a.encodeByteArray(t,!0)};class c extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,c.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,d.prototype.create)}}class d{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){var s,r=t[0]||{},n=`${this.service}/${e}`,i=this.errors[e],i=i?(s=r,i.replace(_,(e,t)=>{var r=s[t];return null!=r?String(r):`<${t}?>`})):"Error",i=`${this.serviceName}: ${i} (${n}).`;return new c(n,i,r)}}const _=/\{\$([^}]+)}/g;function p(e){return e&&e._delegate?e._delegate:e}class f{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}}const m="firebasestorage.googleapis.com",b="storageBucket";class v extends c{constructor(e,t,r=0){super(T(e),`Firebase Storage: ${t} (${T(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,v.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return T(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}\n${this.customData.serverResponse}`:this.message=this._baseMessage}}function T(e){return"storage/"+e}function R(){return new v(g.UNKNOWN,"An unknown error occurred, please check the error payload for server response.")}function w(){return new v(g.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function E(){return new v(g.CANCELED,"User canceled the upload/download.")}function y(){return new v(g.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function k(e){return new v(g.INVALID_ARGUMENT,e)}function A(){return new v(g.APP_DELETED,"The Firebase app was deleted.")}function C(e){return new v(g.INVALID_ROOT_OPERATION,"The operation '"+e+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function S(e,t){return new v(g.INVALID_FORMAT,"String does not match format '"+e+"': "+t)}function O(e){throw new v(g.INTERNAL_ERROR,"Internal error: "+e)}(t=g=g||{}).UNKNOWN="unknown",t.OBJECT_NOT_FOUND="object-not-found",t.BUCKET_NOT_FOUND="bucket-not-found",t.PROJECT_NOT_FOUND="project-not-found",t.QUOTA_EXCEEDED="quota-exceeded",t.UNAUTHENTICATED="unauthenticated",t.UNAUTHORIZED="unauthorized",t.UNAUTHORIZED_APP="unauthorized-app",t.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",t.INVALID_CHECKSUM="invalid-checksum",t.CANCELED="canceled",t.INVALID_EVENT_NAME="invalid-event-name",t.INVALID_URL="invalid-url",t.INVALID_DEFAULT_BUCKET="invalid-default-bucket",t.NO_DEFAULT_BUCKET="no-default-bucket",t.CANNOT_SLICE_BLOB="cannot-slice-blob",t.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",t.NO_DOWNLOAD_URL="no-download-url",t.INVALID_ARGUMENT="invalid-argument",t.INVALID_ARGUMENT_COUNT="invalid-argument-count",t.APP_DELETED="app-deleted",t.INVALID_ROOT_OPERATION="invalid-root-operation",t.INVALID_FORMAT="invalid-format",t.INTERNAL_ERROR="internal-error",t.UNSUPPORTED_ENVIRONMENT="unsupported-environment";class U{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return 0===this.path.length}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o"}static makeFromBucketSpec(t,e){let r;try{r=U.makeFromUrl(t,e)}catch(e){return new U(t,"")}if(""===r.path)return r;throw t=t,new v(g.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+t+"'.")}static makeFromUrl(e,t){let r=null;var s="([A-Za-z0-9.\\-_]+)";var n=new RegExp("^gs://"+s+"(/(.*))?$","i");function i(e){e.path_=decodeURIComponent(e.path)}var o=t.replace(/[.]/g,"\\."),a=new RegExp(`^https?://${o}/v[A-Za-z0-9_]+/b/${s}/o(/([^?#]*).*)?$`,"i"),o=t===m?"(?:storage.googleapis.com|storage.cloud.google.com)":t,h=[{regex:n,indices:{bucket:1,path:3},postModify:function(e){"/"===e.path.charAt(e.path.length-1)&&(e.path_=e.path_.slice(0,-1))}},{regex:a,indices:{bucket:1,path:3},postModify:i},{regex:new RegExp(`^https?://${o}/${s}/([^?#]*)`,"i"),indices:{bucket:1,path:2},postModify:i}];for(let c=0;c<h.length;c++){const d=h[c];var l=d.regex.exec(e);if(l){var u=l[d.indices.bucket];let e=l[d.indices.path];e=e||"",r=new U(u,e),d.postModify(r);break}}if(null==r)throw t=e,new v(g.INVALID_URL,"Invalid URL '"+t+"'.");return r}}class N{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=0){}}function x(e){return"string"==typeof e||e instanceof String}function I(e){return P()&&e instanceof Blob}function P(){return"undefined"!=typeof Blob}function D(e,t,r,s){if(s<t)throw k(`Invalid value for '${e}'. Expected ${t} or greater.`);if(r<s)throw k(`Invalid value for '${e}'. Expected ${r} or less.`)}function L(e,t,r){let s=null==r?`https://${t}`:t;return`${r}://${s}/v0${e}`}function M(e){const t=encodeURIComponent;let r="?";for(const n in e){var s;e.hasOwnProperty(n)&&(s=t(n)+"="+t(e[n]),r=r+s+"&")}return r=r.slice(0,-1),r}function B(e,t){var r=500<=e&&e<600,s=-1!==[408,429].indexOf(e),n=-1!==t.indexOf(e);return r||s||n}(t=i=i||{})[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT";class F{constructor(e,t,r,s,n,i,o,a,h,l,u,c=!0){this.url_=e,this.method_=t,this.headers_=r,this.body_=s,this.successCodes_=n,this.additionalRetryCodes_=i,this.callback_=o,this.errorCallback_=a,this.timeout_=h,this.progressCallback_=l,this.connectionFactory_=u,this.retry=c,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((e,t)=>{this.resolve_=e,this.reject_=t,this.start_()})}start_(){var e=(r,e)=>{if(e)r(!1,new q(!1,null,!0));else{const s=this.connectionFactory_();this.pendingConnection_=s;const n=e=>{var t=e.loaded,r=e.lengthComputable?e.total:-1;null!==this.progressCallback_&&this.progressCallback_(t,r)};null!==this.progressCallback_&&s.addUploadProgressListener(n),s.send(this.url_,this.method_,this.body_,this.headers_).then(()=>{null!==this.progressCallback_&&s.removeUploadProgressListener(n),this.pendingConnection_=null;var e=s.getErrorCode()===i.NO_ERROR,t=s.getStatus();!e||B(t,this.additionalRetryCodes_)&&this.retry?(e=s.getErrorCode()===i.ABORT,r(!1,new q(!1,null,e))):(t=-1!==this.successCodes_.indexOf(t),r(!0,new q(t,s)))})}},t=(e,t)=>{const r=this.resolve_,s=this.reject_,n=t.connection;if(t.wasSuccessCode)try{var i=this.callback_(n,n.getResponse());void 0!==i?r(i):r()}catch(e){s(e)}else if(null!==n){const a=R();a.serverResponse=n.getErrorText(),this.errorCallback_?s(this.errorCallback_(n,a)):s(a)}else{var o;t.canceled?(o=(this.appDelete_?A:E)(),s(o)):(o=w(),s(o))}};this.canceled_?t(0,new q(!1,null,!0)):this.backoffId_=function(t,r,e){let s=1,n=null,i=null,o=!1,a=0;function h(){return 2===a}let l=!1;function u(...e){l||(l=!0,r.apply(null,e))}function c(e){n=setTimeout(()=>{n=null,t(_,h())},e)}function d(){i&&clearTimeout(i)}function _(t,...r){if(l)d();else{if(t)return d(),void u.call(null,t,...r);if(h()||o)return d(),void u.call(null,t,...r);s<64&&(s*=2);let e;e=1===a?(a=2,0):1e3*(s+Math.random()),c(e)}}let p=!1;function f(e){p||(p=!0,d(),l||(null!==n?(e||(a=2),clearTimeout(n),c(0)):e||(a=1)))}return c(0),i=setTimeout(()=>{f(o=!0)},e),f}(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,null!==this.backoffId_&&(0,this.backoffId_)(!1),null!==this.pendingConnection_&&this.pendingConnection_.abort()}}class q{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}}function V(...t){const r="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0;if(void 0!==r){const s=new r;for(let e=0;e<t.length;e++)s.append(t[e]);return s.getBlob()}if(P())return new Blob(t);throw new v(g.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}function H(e){if("undefined"==typeof atob)throw new v(g.UNSUPPORTED_ENVIRONMENT,"base-64 is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.");return atob(e)}const j={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class W{constructor(e,t){this.data=e,this.contentType=t||null}}function z(e,t){switch(e){case j.RAW:return new W($(t));case j.BASE64:case j.BASE64URL:return new W(G(e,t));case j.DATA_URL:return new W((r=t,(s=new X(r)).base64?G(j.BASE64,s.rest):function(e){let t;try{t=decodeURIComponent(e)}catch(e){throw S(j.DATA_URL,"Malformed data URL.")}return $(t)}(s.rest)),(r=t,new X(r).contentType))}var r,s;throw R()}function $(t){const r=[];for(let i=0;i<t.length;i++){let e=t.charCodeAt(i);var s,n;e<=127?r.push(e):e<=2047?r.push(192|e>>6,128|63&e):55296==(64512&e)?i<t.length-1&&56320==(64512&t.charCodeAt(i+1))?(s=e,n=t.charCodeAt(++i),e=65536|(1023&s)<<10|1023&n,r.push(240|e>>18,128|e>>12&63,128|e>>6&63,128|63&e)):r.push(239,191,189):56320==(64512&e)?r.push(239,191,189):r.push(224|e>>12,128|e>>6&63,128|63&e)}return new Uint8Array(r)}function G(t,e){switch(t){case j.BASE64:var r=-1!==e.indexOf("-"),s=-1!==e.indexOf("_");if(r||s)throw S(t,"Invalid character '"+(r?"-":"_")+"' found: is it base64url encoded?");break;case j.BASE64URL:s=-1!==e.indexOf("+"),r=-1!==e.indexOf("/");if(s||r)throw S(t,"Invalid character '"+(s?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/")}let n;try{n=H(e)}catch(e){if(e.message.includes("polyfill"))throw e;throw S(t,"Invalid character found")}const i=new Uint8Array(n.length);for(let o=0;o<n.length;o++)i[o]=n.charCodeAt(o);return i}class X{constructor(e){this.base64=!1,this.contentType=null;var t,r,s=e.match(/^data:([^,]+)?,/);if(null===s)throw S(j.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const n=s[1]||null;null!=n&&(this.base64=(t=n,r=";base64",t.length>=r.length&&t.substring(t.length-r.length)===r),this.contentType=this.base64?n.substring(0,n.length-";base64".length):n),this.rest=e.substring(e.indexOf(",")+1)}}class K{constructor(e,t){let r=0,s="";I(e)?(this.data_=e,r=e.size,s=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),r=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),r=e.length),this.size_=r,this.type_=s}size(){return this.size_}type(){return this.type_}slice(e,t){if(I(this.data_)){var r=this.data_,r=(n=e,i=t,(s=r).webkitSlice?s.webkitSlice(n,i):s.mozSlice?s.mozSlice(n,i):s.slice?s.slice(n,i):null);return null===r?null:new K(r)}var s,n,i,r=new Uint8Array(this.data_.buffer,e,t-e);return new K(r,!0)}static getBlob(...e){if(P()){var t=e.map(e=>e instanceof K?e.data_:e);return new K(V.apply(null,t))}{const s=e.map(e=>x(e)?z(j.RAW,e).data:e.data_);let t=0;s.forEach(e=>{t+=e.byteLength});const n=new Uint8Array(t);let r=0;return s.forEach(e=>{for(let t=0;t<e.length;t++)n[r++]=e[t]}),new K(n,!0)}}uploadData(){return this.data_}}function Z(e){let t;try{t=JSON.parse(e)}catch(e){return null}return"object"!=typeof(e=t)||Array.isArray(e)?null:t}function J(e){var t=e.lastIndexOf("/",e.length-2);return-1===t?e:e.slice(t+1)}function Y(e,t){return t}class Q{constructor(e,t,r,s){this.server=e,this.local=t||e,this.writable=!!r,this.xform=s||Y}}let ee=null;function te(){if(ee)return ee;const e=[];e.push(new Q("bucket")),e.push(new Q("generation")),e.push(new Q("metageneration")),e.push(new Q("name","fullPath",!0));const t=new Q("name");t.xform=function(e,t){return!x(t=t)||t.length<2?t:J(t)},e.push(t);const r=new Q("size");return r.xform=function(e,t){return void 0!==t?Number(t):t},e.push(r),e.push(new Q("timeCreated")),e.push(new Q("updated")),e.push(new Q("md5Hash",null,!0)),e.push(new Q("cacheControl",null,!0)),e.push(new Q("contentDisposition",null,!0)),e.push(new Q("contentEncoding",null,!0)),e.push(new Q("contentLanguage",null,!0)),e.push(new Q("contentType",null,!0)),e.push(new Q("metadata","customMetadata",!0)),ee=e,ee}function re(r,s){Object.defineProperty(r,"ref",{get:function(){var e=r.bucket,t=r.fullPath,t=new U(e,t);return s._makeStorageReference(t)}})}function se(e,t,r){var s=Z(t);return null===s?null:function(e,t,r){const s={type:"file"};var n=r.length;for(let i=0;i<n;i++){const o=r[i];s[o.local]=o.xform(s,t[o.server])}return re(s,e),s}(e,s,r)}function ne(e,t){const r={};var s=t.length;for(let i=0;i<s;i++){var n=t[i];n.writable&&(r[n.server]=e[n.local])}return JSON.stringify(r)}const ie="prefixes";function oe(e,t,r){var s=Z(r);return null===s?null:function(e,t,r){const s={prefixes:[],items:[],nextPageToken:r.nextPageToken};if(r[ie])for(const o of r[ie]){var n=o.replace(/\/$/,""),n=e._makeStorageReference(new U(t,n));s.prefixes.push(n)}if(r.items)for(const a of r.items){var i=e._makeStorageReference(new U(t,a.name));s.items.push(i)}return s}(e,t,s)}class ae{constructor(e,t,r,s){this.url=e,this.method=t,this.handler=r,this.timeout=s,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}function he(e){if(!e)throw R()}function le(s,n){return function(e,t){var r=se(s,t,n);return he(null!==r),r}}function ue(s,n){return function(e,t){var r=oe(s,n,t);return he(null!==r),r}}function ce(s,n){return function(e,t){var r=se(s,t,n);return he(null!==r),function(s,e,n,i){var t=Z(e);if(null===t)return null;if(!x(t.downloadTokens))return null;const r=t.downloadTokens;if(0===r.length)return null;const o=encodeURIComponent,a=r.split(",");return a.map(e=>{var t=s.bucket,r=s.fullPath;return L("/b/"+o(t)+"/o/"+o(r),n,i)+M({alt:"media",token:e})})[0]}(r,t,s.host,s._protocol)}}function de(n){return function(e,t){let r;var s;return r=401===e.getStatus()?e.getErrorText().includes("Firebase App Check token is invalid")?new v(g.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project."):new v(g.UNAUTHENTICATED,"User is not authenticated, please authenticate using Firebase Authentication and try again."):402===e.getStatus()?(s=n.bucket,new v(g.QUOTA_EXCEEDED,"Quota for bucket '"+s+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===e.getStatus()?(s=n.path,new v(g.UNAUTHORIZED,"User does not have permission to access '"+s+"'.")):t,r.status=e.getStatus(),r.serverResponse=t.serverResponse,r}}function _e(s){const n=de(s);return function(e,t){let r=n(e,t);return 404===e.getStatus()&&(r=(e=s.path,new v(g.OBJECT_NOT_FOUND,"Object '"+e+"' does not exist."))),r.serverResponse=t.serverResponse,r}}function pe(e,t,r){var s=L(t.fullServerUrl(),e.host,e._protocol),n=e.maxOperationRetryTime;const i=new ae(s,"GET",le(e,r),n);return i.errorHandler=_e(t),i}function fe(e,t,r){const s=Object.assign({},r);return s.fullPath=e.path,s.size=t.size(),s.contentType||(s.contentType=(e=t,(t=null)&&t.contentType||e&&e.type()||"application/octet-stream")),s}function ge(e,t,r,s,n){var i=t.bucketOnlyServerUrl();const o={"X-Goog-Upload-Protocol":"multipart"};var a=function(){let e="";for(let t=0;t<2;t++)e+=Math.random().toString().slice(2);return e}();o["Content-Type"]="multipart/related; boundary="+a;var h=fe(t,s,n),l="--"+a+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+ne(h,r)+"\r\n--"+a+"\r\nContent-Type: "+h.contentType+"\r\n\r\n",a="\r\n--"+a+"--";const u=K.getBlob(l,s,a);if(null===u)throw y();a={name:h.fullPath},h=L(i,e.host,e._protocol),i=e.maxUploadRetryTime;const c=new ae(h,"POST",le(e,r),i);return c.urlParams=a,c.headers=o,c.body=u.uploadData(),c.errorHandler=de(t),c}class me{constructor(e,t,r,s){this.current=e,this.total=t,this.finalized=!!r,this.metadata=s||null}}function be(e,t){let r=null;try{r=e.getResponseHeader("X-Goog-Upload-Status")}catch(e){he(!1)}const s=t||["active"];return he(!!r&&-1!==s.indexOf(r)),r}function ve(e,t,r,s,n){var i=t.bucketOnlyServerUrl(),o=fe(t,s,n),a={name:o.fullPath},h=L(i,e.host,e._protocol),l={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${s.size()}`,"X-Goog-Upload-Header-Content-Type":o.contentType,"Content-Type":"application/json; charset=utf-8"},i=ne(o,r),o=e.maxUploadRetryTime;const u=new ae(h,"POST",function(e){be(e);let t;try{t=e.getResponseHeader("X-Goog-Upload-URL")}catch(e){he(!1)}return he(x(t)),t},o);return u.urlParams=a,u.headers=l,u.body=i,u.errorHandler=de(t),u}function Te(e,t,r,n){var s=e.maxUploadRetryTime;const i=new ae(r,"POST",function(e){var t=be(e,["active","final"]);let r=null;try{r=e.getResponseHeader("X-Goog-Upload-Size-Received")}catch(e){he(!1)}r||he(!1);var s=Number(r);return he(!isNaN(s)),new me(s,n.size(),"final"===t)},s);return i.headers={"X-Goog-Upload-Command":"query"},i.errorHandler=de(t),i}function Re(e,o,t,a,r,h,s,n){const l=new me(0,0);if(s?(l.current=s.current,l.total=s.total):(l.current=0,l.total=a.size()),a.size()!==l.total)throw new v(g.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.");var i=l.total-l.current;let u=i;0<r&&(u=Math.min(u,r));var c=l.current,d=c+u;let _="";_=0===u?"finalize":i===u?"upload, finalize":"upload";i={"X-Goog-Upload-Command":_,"X-Goog-Upload-Offset":`${l.current}`};const p=a.slice(c,d);if(null===p)throw y();d=o.maxUploadRetryTime;const f=new ae(t,"POST",function(e,t){var r=be(e,["active","final"]),s=l.current+u,n=a.size();let i;return i="final"===r?le(o,h)(e,t):null,new me(s,n,"final"===r,i)},d);return f.headers=i,f.body=p.uploadData(),f.progressCallback=n||null,f.errorHandler=de(e),f}const we={STATE_CHANGED:"state_changed"},Ee={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function ye(e){switch(e){case"running":case"pausing":case"canceling":return Ee.RUNNING;case"paused":return Ee.PAUSED;case"success":return Ee.SUCCESS;case"canceled":return Ee.CANCELED;default:return Ee.ERROR}}class ke{constructor(e,t,r){var s;"function"==typeof e||null!=t||null!=r?(this.next=e,this.error=null!=t?t:void 0,this.complete=null!=r?r:void 0):(this.next=(s=e).next,this.error=s.error,this.complete=s.complete)}}function Ae(t){return(...e)=>{Promise.resolve().then(()=>t(...e))}}class Ce extends class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=i.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=i.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=i.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,r,s){if(this.sent_)throw O("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(t,e,!0),void 0!==s)for(const n in s)s.hasOwnProperty(n)&&this.xhr_.setRequestHeader(n,s[n].toString());return void 0!==r?this.xhr_.send(r):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw O("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw O("cannot .getStatus() before sending");try{return this.xhr_.status}catch(e){return-1}}getResponse(){if(!this.sent_)throw O("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw O("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){null!=this.xhr_.upload&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){null!=this.xhr_.upload&&this.xhr_.upload.removeEventListener("progress",e)}}{initXhr(){this.xhr_.responseType="text"}}function Se(){return new Ce}class Oe{constructor(e,t,r=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=e,this._blob=t,this._metadata=r,this._mappings=te(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=e=>{if(this._request=void 0,this._chunkMultiplier=1,e._codeEquals(g.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{var t=this.isExponentialBackoffExpired();if(B(e.status,[])){if(!t)return this.sleepTime=Math.max(2*this.sleepTime,1e3),this._needToFetchStatus=!0,void this.completeTransitions_();e=w()}this._error=e,this._transition("error")}},this._metadataErrorHandler=e=>{this._request=void 0,e._codeEquals(g.CANCELED)?this.completeTransitions_():(this._error=e,this._transition("error"))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t,this._start()}),this._promise.then(null,()=>{})}isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}_makeProgressCallback(){const t=this._transferred;return e=>this._updateProgress(t+e)}_shouldDoResumable(e){return 262144<e.size()}_start(){"running"===this._state&&void 0===this._request&&(this._resumable?void 0===this._uploadUrl?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(r){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([e,t])=>{switch(this._state){case"running":r(e,t);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused")}})}_createResumable(){this._resolveToken((e,t)=>{var r=ve(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const s=this._ref.storage._makeRequest(r,Se,e,t);this._request=s,s.getPromise().then(e=>{this._request=void 0,this._uploadUrl=e,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){const n=this._uploadUrl;this._resolveToken((e,t)=>{var r=Te(this._ref.storage,this._ref._location,n,this._blob);const s=this._ref.storage._makeRequest(r,Se,e,t);this._request=s,s.getPromise().then(e=>{this._request=void 0,this._updateProgress(e.current),this._needToFetchStatus=!1,e.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){const n=262144*this._chunkMultiplier,i=new me(this._transferred,this._blob.size()),o=this._uploadUrl;this._resolveToken((e,t)=>{let r;try{r=Re(this._ref._location,this._ref.storage,o,this._blob,n,this._mappings,i,this._makeProgressCallback())}catch(e){return this._error=e,void this._transition("error")}const s=this._ref.storage._makeRequest(r,Se,e,t,!1);this._request=s,s.getPromise().then(e=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(e.current),e.finalized?(this._metadata=e.metadata,this._transition("success")):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){2*(262144*this._chunkMultiplier)<33554432&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{var r=pe(this._ref.storage,this._ref._location,this._mappings);const s=this._ref.storage._makeRequest(r,Se,e,t);this._request=s,s.getPromise().then(e=>{this._request=void 0,this._metadata=e,this._transition("success")},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,t)=>{var r=ge(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const s=this._ref.storage._makeRequest(r,Se,e,t);this._request=s,s.getPromise().then(e=>{this._request=void 0,this._metadata=e,this._updateProgress(this._blob.size()),this._transition("success")},this._errorHandler)})}_updateProgress(e){var t=this._transferred;this._transferred=e,this._transferred!==t&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case"canceling":case"pausing":this._state=e,void 0!==this._request?this._request.cancel():this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_());break;case"running":var t="paused"===this._state;this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":this._state=e,this._notifyObservers();break;case"canceled":this._error=E(),this._state=e,this._notifyObservers();break;case"error":case"success":this._state=e,this._notifyObservers()}}completeTransitions_(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start()}}get snapshot(){var e=ye(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,r,s){const n=new ke(t||void 0,r||void 0,s||void 0);return this._addObserver(n),()=>{this._removeObserver(n)}}then(e,t){return this._promise.then(e,t)}catch(e){return this.then(null,e)}_addObserver(e){this._observers.push(e),this._notifyObserver(e)}_removeObserver(e){var t=this._observers.indexOf(e);-1!==t&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise();const e=this._observers.slice();e.forEach(e=>{this._notifyObserver(e)})}_finishPromise(){if(void 0!==this._resolve){let e=!0;switch(ye(this._state)){case Ee.SUCCESS:Ae(this._resolve.bind(null,this.snapshot))();break;case Ee.CANCELED:case Ee.ERROR:const t=this._reject;Ae(t.bind(null,this._error))();break;default:e=!1}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(ye(this._state)){case Ee.RUNNING:case Ee.PAUSED:e.next&&Ae(e.next.bind(e,this.snapshot))();break;case Ee.SUCCESS:e.complete&&Ae(e.complete.bind(e))();break;case Ee.CANCELED:case Ee.ERROR:default:e.error&&Ae(e.error.bind(e,this._error))()}}resume(){var e="paused"===this._state||"pausing"===this._state;return e&&this._transition("running"),e}pause(){var e="running"===this._state;return e&&this._transition("pausing"),e}cancel(){var e="running"===this._state||"pausing"===this._state;return e&&this._transition("canceling"),e}}class Ue{constructor(e,t){this._service=e,t instanceof U?this._location=t:this._location=U.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new Ue(e,t)}get root(){var e=new U(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return J(this._location.path)}get storage(){return this._service}get parent(){var e=function(e){if(0===e.length)return null;var t=e.lastIndexOf("/");return-1===t?"":e.slice(0,t)}(this._location.path);if(null===e)return null;e=new U(this._location.bucket,e);return new Ue(this._service,e)}_throwIfRoot(e){if(""===this._location.path)throw C(e)}}function Ne(e){const t={prefixes:[],items:[]};return async function e(t,r,s){const n={pageToken:s};const i=await xe(t,n);r.prefixes.push(...i.prefixes);r.items.push(...i.items);null!=i.nextPageToken&&await e(t,r,i.nextPageToken)}(e,t).then(()=>t)}function xe(e,t){null!=t&&"number"==typeof t.maxResults&&D("options.maxResults",1,1e3,t.maxResults);var r=t||{},r=function(e,t,r,s,n){const i={};t.isRoot?i.prefix="":i.prefix=t.path+"/",r&&0<r.length&&(i.delimiter=r),s&&(i.pageToken=s),n&&(i.maxResults=n);var o=L(t.bucketOnlyServerUrl(),e.host,e._protocol),a=e.maxOperationRetryTime;const h=new ae(o,"GET",ue(e,t.bucket),a);return h.urlParams=i,h.errorHandler=de(t),h}(e.storage,e._location,"/",r.pageToken,r.maxResults);return e.storage.makeRequestWithTokens(r,Se)}function Ie(e,t){e._throwIfRoot("updateMetadata");var r=function(e,t,r,s){var n=L(t.fullServerUrl(),e.host,e._protocol),i=ne(r,s),o=e.maxOperationRetryTime;const a=new ae(n,"PATCH",le(e,s),o);return a.headers={"Content-Type":"application/json; charset=utf-8"},a.body=i,a.errorHandler=_e(t),a}(e.storage,e._location,t,te());return e.storage.makeRequestWithTokens(r,Se)}function Pe(e){e._throwIfRoot("getDownloadURL");var t=function(e,t,r){var s=L(t.fullServerUrl(),e.host,e._protocol),n=e.maxOperationRetryTime;const i=new ae(s,"GET",ce(e,r),n);return i.errorHandler=_e(t),i}(e.storage,e._location,te());return e.storage.makeRequestWithTokens(t,Se).then(e=>{if(null===e)throw new v(g.NO_DOWNLOAD_URL,"The given file does not have any download URLs.");return e})}function De(e){e._throwIfRoot("deleteObject");var t=function(e,t){var r=L(t.fullServerUrl(),e.host,e._protocol),s=e.maxOperationRetryTime;const n=new ae(r,"DELETE",function(e,t){},s);return n.successCodes=[200,204],n.errorHandler=_e(t),n}(e.storage,e._location);return e.storage.makeRequestWithTokens(t,Se)}function Le(e,t){var r,s=(r=e._location.path,s=t.split("/").filter(e=>0<e.length).join("/"),0===r.length?s:r+"/"+s),s=new U(e._location.bucket,s);return new Ue(e.storage,s)}function Me(e,t){if(e instanceof Ve){var r=e;if(null==r._bucket)throw new v(g.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+b+"' property when initializing the app?");r=new Ue(r,r._bucket);return null!=t?Me(r,t):r}return void 0!==t?Le(e,t):e}function Be(e,t){if(t&&/^[A-Za-z]+:\/\//.test(t)){if(e instanceof Ve)return r=e,s=t,new Ue(r,s);throw k("To use ref(service, url), the first argument must be a Storage instance.")}return Me(e,t);var r,s}function Fe(e,t){var r=null==t?void 0:t[b];return null==r?null:U.makeFromBucketSpec(r,e)}function qe(e,t,r,s={}){e.host=`${t}:${r}`,e._protocol="http";var n=s["mockUserToken"];n&&(e._overrideAuthToken="string"==typeof n?n:function(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 r=t||"demo-project",s=e.iat||0,n=e.sub||e.user_id;if(!n)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");return n=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:n,user_id:n,firebase:{sign_in_provider:"custom",identities:{}}},e),[h(JSON.stringify({alg:"none",type:"JWT"})),h(JSON.stringify(n)),""].join(".")}(n,e.app.options.projectId))}class Ve{constructor(e,t,r,s,n){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=s,this._firebaseVersion=n,this._bucket=null,this._host=m,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=s?U.makeFromBucketSpec(s,this._host):Fe(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,null!=this._url?this._bucket=U.makeFromBucketSpec(this._url,e):this._bucket=Fe(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){D("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){D("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){var t=await e.getToken();if(null!==t)return t.accessToken}return null}async _getAppCheckToken(){const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new Ue(this,e)}_makeRequest(e,t,r,s,n=!0){if(this._deleted)return new N(A());{const u=([i,o,a,e,r,s,t=!0]=[e,this._appId,r,s,t,this._firebaseVersion,n],h=M(i.urlParams),l=i.url+h,h=Object.assign({},i.headers),n=h,(o=o)&&(n["X-Firebase-GMPID"]=o),o=h,null!==(a=a)&&0<a.length&&(o.Authorization="Firebase "+a),s=s,h["X-Firebase-Storage-Version"]="webjs/"+(null!=s?s:"AppManager"),s=h,null!==(e=e)&&(s["X-Firebase-AppCheck"]=e),new F(l,i.method,h,i.body,i.successCodes,i.additionalRetryCodes,i.handler,i.errorHandler,i.timeout,i.progressCallback,r,t));return this._requests.add(u),u.getPromise().then(()=>this._requests.delete(u),()=>this._requests.delete(u)),u}var i,o,a,h,l}async makeRequestWithTokens(e,t){var[r,s]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,r,s).getPromise()}}const He="@firebase/storage",je="0.12.4-dataconnect-preview.f2ddc3d7b";function We(e,t,r){return e=p(e),t=t,r=r,(e=e)._throwIfRoot("uploadBytesResumable"),new Oe(e,new K(t),r)}function ze(e){return function(e){e._throwIfRoot("getMetadata");var t=pe(e.storage,e._location,te());return e.storage.makeRequestWithTokens(t,Se)}(e=p(e))}function $e(e,t){return Be(e=p(e),t)}function Ge(e,{instanceIdentifier:t}){var r=e.getProvider("app").getImmediate(),s=e.getProvider("auth-internal"),n=e.getProvider("app-check-internal");return new Ve(r,s,n,t,rt.SDK_VERSION)}rt._registerComponent(new f("storage",Ge,"PUBLIC").setMultipleInstances(!0)),rt.registerVersion(He,je,""),rt.registerVersion(He,je,"esm2017");class Xe{constructor(e,t,r){this._delegate=e,this.task=t,this.ref=r}get bytesTransferred(){return this._delegate.bytesTransferred}get metadata(){return this._delegate.metadata}get state(){return this._delegate.state}get totalBytes(){return this._delegate.totalBytes}}class Ke{constructor(e,t){this._delegate=e,this._ref=t,this.cancel=this._delegate.cancel.bind(this._delegate),this.catch=this._delegate.catch.bind(this._delegate),this.pause=this._delegate.pause.bind(this._delegate),this.resume=this._delegate.resume.bind(this._delegate)}get snapshot(){return new Xe(this._delegate.snapshot,this,this._ref)}then(t,e){return this._delegate.then(e=>{if(t)return t(new Xe(e,this,this._ref))},e)}on(e,t,r,s){let n=void 0;return t&&(n="function"==typeof t?e=>t(new Xe(e,this,this._ref)):{next:t.next?e=>t.next(new Xe(e,this,this._ref)):void 0,complete:t.complete||void 0,error:t.error||void 0}),this._delegate.on(e,n,r||void 0,s||void 0)}}class Ze{constructor(e,t){this._delegate=e,this._service=t}get prefixes(){return this._delegate.prefixes.map(e=>new Je(e,this._service))}get items(){return this._delegate.items.map(e=>new Je(e,this._service))}get nextPageToken(){return this._delegate.nextPageToken||null}}class Je{constructor(e,t){this._delegate=e,this.storage=t}get name(){return this._delegate.name}get bucket(){return this._delegate.bucket}get fullPath(){return this._delegate.fullPath}toString(){return this._delegate.toString()}child(e){var t=Le(this._delegate,e);return new Je(t,this.storage)}get root(){return new Je(this._delegate.root,this.storage)}get parent(){var e=this._delegate.parent;return null==e?null:new Je(e,this.storage)}put(e,t){return this._throwIfRoot("put"),new Ke(We(this._delegate,e,t),this)}putString(e,t=j.RAW,r){this._throwIfRoot("putString");var s=z(t,e);const n=Object.assign({},r);return null==n.contentType&&null!=s.contentType&&(n.contentType=s.contentType),new Ke(new Oe(this._delegate,new K(s.data,!0),n),this)}listAll(){return Ne(p(this._delegate)).then(e=>new Ze(e,this.storage))}list(e){return t=this._delegate,e=e||void 0,xe(t=p(t),e).then(e=>new Ze(e,this.storage));var t}getMetadata(){return ze(this._delegate)}updateMetadata(e){return Ie(p(this._delegate),e)}getDownloadURL(){return Pe(p(this._delegate))}delete(){return this._throwIfRoot("delete"),De(p(this._delegate))}_throwIfRoot(e){if(""===this._delegate._location.path)throw C(e)}}class Ye{constructor(e,t){this.app=e,this._delegate=t}get maxOperationRetryTime(){return this._delegate.maxOperationRetryTime}get maxUploadRetryTime(){return this._delegate.maxUploadRetryTime}ref(e){if(Qe(e))throw k("ref() expected a child path but got a URL, use refFromURL instead.");return new Je($e(this._delegate,e),this)}refFromURL(e){if(!Qe(e))throw k("refFromURL() expected a full URL but got a child path, use ref() instead.");try{U.makeFromUrl(e,this._delegate.host)}catch(e){throw k("refFromUrl() expected a valid full URL but got an invalid one.")}return new Je($e(this._delegate,e),this)}setMaxUploadRetryTime(e){this._delegate.maxUploadRetryTime=e}setMaxOperationRetryTime(e){this._delegate.maxOperationRetryTime=e}useEmulator(e,t,r={}){var s;[s,e,t,r={}]=[this._delegate,e,t,r],qe(s,e,t,r)}}function Qe(e){return/^[A-Za-z]+:\/\//.test(e)}function et(e,{instanceIdentifier:t}){var r=e.getProvider("app-compat").getImmediate(),s=e.getProvider("storage").getImmediate({identifier:t});return new Ye(r,s)}r=n.default,s={TaskState:Ee,TaskEvent:we,StringFormat:j,Storage:Ye,Reference:Je},r.INTERNAL.registerComponent(new f("storage-compat",et,"PUBLIC").setServiceProps(s).setMultipleInstances(!0)),r.registerVersion("@firebase/storage-compat","0.3.7-dataconnect-preview.f2ddc3d7b")}).apply(this,arguments)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-storage-compat.js - be sure to load firebase-app.js first.")}});
|
|
1
|
+
!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(tt,rt){"use strict";try{!(function(){function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g,i,t,r,s,n=e(tt);function o(t){const r=[];let s=0;for(let n=0;n<t.length;n++){let e=t.charCodeAt(n);e<128?r[s++]=e:(e<2048?r[s++]=e>>6|192:(55296==(64512&e)&&n+1<t.length&&56320==(64512&t.charCodeAt(n+1))?(e=65536+((1023&e)<<10)+(1023&t.charCodeAt(++n)),r[s++]=e>>18|240,r[s++]=e>>12&63|128):r[s++]=e>>12|224,r[s++]=e>>6&63|128),r[s++]=63&e|128)}return r}const a={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(r,e){if(!Array.isArray(r))throw Error("encodeByteArray takes an array as a parameter");this.init_();var s=e?this.byteToCharMapWebSafe_:this.byteToCharMap_;const n=[];for(let u=0;u<r.length;u+=3){var i=r[u],o=u+1<r.length,a=o?r[u+1]:0,h=u+2<r.length,l=h?r[u+2]:0;let e=(15&a)<<2|l>>6,t=63&l;h||(t=64,o||(e=64)),n.push(s[i>>2],s[(3&i)<<4|a>>4],s[e],s[t])}return n.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(o(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let r=0,s=0;for(;r<e.length;){var n,i,o=e[r++];o<128?t[s++]=String.fromCharCode(o):191<o&&o<224?(n=e[r++],t[s++]=String.fromCharCode((31&o)<<6|63&n)):239<o&&o<365?(i=((7&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,t[s++]=String.fromCharCode(55296+(i>>10)),t[s++]=String.fromCharCode(56320+(1023&i))):(n=e[r++],i=e[r++],t[s++]=String.fromCharCode((15&o)<<12|(63&n)<<6|63&i))}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();var r=t?this.charToByteMapWebSafe_:this.charToByteMap_;const s=[];for(let h=0;h<e.length;){var n=r[e.charAt(h++)],i=h<e.length?r[e.charAt(h)]:0;++h;var o=h<e.length?r[e.charAt(h)]:64;++h;var a=h<e.length?r[e.charAt(h)]:64;if(++h,null==n||null==i||null==o||null==a)throw new l;s.push(n<<2|i>>4),64!==o&&(s.push(i<<4&240|o>>2),64!==a&&s.push(o<<6&192|a))}return s},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 h(e){return u(e).replace(/\./g,"")}const u=function(e){var t=o(e);return a.encodeByteArray(t,!0)};class c extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,c.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,d.prototype.create)}}class d{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){var s,r=t[0]||{},n=`${this.service}/${e}`,i=this.errors[e],i=i?(s=r,i.replace(_,(e,t)=>{var r=s[t];return null!=r?String(r):`<${t}?>`})):"Error",i=`${this.serviceName}: ${i} (${n}).`;return new c(n,i,r)}}const _=/\{\$([^}]+)}/g;function p(e){return e&&e._delegate?e._delegate:e}class f{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}}const m="firebasestorage.googleapis.com",b="storageBucket";class v extends c{constructor(e,t,r=0){super(T(e),`Firebase Storage: ${t} (${T(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,v.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return T(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}\n${this.customData.serverResponse}`:this.message=this._baseMessage}}function T(e){return"storage/"+e}function R(){return new v(g.UNKNOWN,"An unknown error occurred, please check the error payload for server response.")}function w(){return new v(g.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function E(){return new v(g.CANCELED,"User canceled the upload/download.")}function y(){return new v(g.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function k(e){return new v(g.INVALID_ARGUMENT,e)}function A(){return new v(g.APP_DELETED,"The Firebase app was deleted.")}function C(e){return new v(g.INVALID_ROOT_OPERATION,"The operation '"+e+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function S(e,t){return new v(g.INVALID_FORMAT,"String does not match format '"+e+"': "+t)}function O(e){throw new v(g.INTERNAL_ERROR,"Internal error: "+e)}(t=g=g||{}).UNKNOWN="unknown",t.OBJECT_NOT_FOUND="object-not-found",t.BUCKET_NOT_FOUND="bucket-not-found",t.PROJECT_NOT_FOUND="project-not-found",t.QUOTA_EXCEEDED="quota-exceeded",t.UNAUTHENTICATED="unauthenticated",t.UNAUTHORIZED="unauthorized",t.UNAUTHORIZED_APP="unauthorized-app",t.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",t.INVALID_CHECKSUM="invalid-checksum",t.CANCELED="canceled",t.INVALID_EVENT_NAME="invalid-event-name",t.INVALID_URL="invalid-url",t.INVALID_DEFAULT_BUCKET="invalid-default-bucket",t.NO_DEFAULT_BUCKET="no-default-bucket",t.CANNOT_SLICE_BLOB="cannot-slice-blob",t.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",t.NO_DOWNLOAD_URL="no-download-url",t.INVALID_ARGUMENT="invalid-argument",t.INVALID_ARGUMENT_COUNT="invalid-argument-count",t.APP_DELETED="app-deleted",t.INVALID_ROOT_OPERATION="invalid-root-operation",t.INVALID_FORMAT="invalid-format",t.INTERNAL_ERROR="internal-error",t.UNSUPPORTED_ENVIRONMENT="unsupported-environment";class U{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return 0===this.path.length}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o"}static makeFromBucketSpec(t,e){let r;try{r=U.makeFromUrl(t,e)}catch(e){return new U(t,"")}if(""===r.path)return r;throw t=t,new v(g.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+t+"'.")}static makeFromUrl(e,t){let r=null;var s="([A-Za-z0-9.\\-_]+)";var n=new RegExp("^gs://"+s+"(/(.*))?$","i");function i(e){e.path_=decodeURIComponent(e.path)}var o=t.replace(/[.]/g,"\\."),a=new RegExp(`^https?://${o}/v[A-Za-z0-9_]+/b/${s}/o(/([^?#]*).*)?$`,"i"),o=t===m?"(?:storage.googleapis.com|storage.cloud.google.com)":t,h=[{regex:n,indices:{bucket:1,path:3},postModify:function(e){"/"===e.path.charAt(e.path.length-1)&&(e.path_=e.path_.slice(0,-1))}},{regex:a,indices:{bucket:1,path:3},postModify:i},{regex:new RegExp(`^https?://${o}/${s}/([^?#]*)`,"i"),indices:{bucket:1,path:2},postModify:i}];for(let c=0;c<h.length;c++){const d=h[c];var l=d.regex.exec(e);if(l){var u=l[d.indices.bucket];let e=l[d.indices.path];e=e||"",r=new U(u,e),d.postModify(r);break}}if(null==r)throw t=e,new v(g.INVALID_URL,"Invalid URL '"+t+"'.");return r}}class N{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=0){}}function x(e){return"string"==typeof e||e instanceof String}function I(e){return P()&&e instanceof Blob}function P(){return"undefined"!=typeof Blob}function D(e,t,r,s){if(s<t)throw k(`Invalid value for '${e}'. Expected ${t} or greater.`);if(r<s)throw k(`Invalid value for '${e}'. Expected ${r} or less.`)}function L(e,t,r){let s=null==r?`https://${t}`:t;return`${r}://${s}/v0${e}`}function M(e){const t=encodeURIComponent;let r="?";for(const n in e){var s;e.hasOwnProperty(n)&&(s=t(n)+"="+t(e[n]),r=r+s+"&")}return r=r.slice(0,-1),r}function B(e,t){var r=500<=e&&e<600,s=-1!==[408,429].indexOf(e),n=-1!==t.indexOf(e);return r||s||n}(t=i=i||{})[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT";class F{constructor(e,t,r,s,n,i,o,a,h,l,u,c=!0){this.url_=e,this.method_=t,this.headers_=r,this.body_=s,this.successCodes_=n,this.additionalRetryCodes_=i,this.callback_=o,this.errorCallback_=a,this.timeout_=h,this.progressCallback_=l,this.connectionFactory_=u,this.retry=c,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((e,t)=>{this.resolve_=e,this.reject_=t,this.start_()})}start_(){var e=(r,e)=>{if(e)r(!1,new q(!1,null,!0));else{const s=this.connectionFactory_();this.pendingConnection_=s;const n=e=>{var t=e.loaded,r=e.lengthComputable?e.total:-1;null!==this.progressCallback_&&this.progressCallback_(t,r)};null!==this.progressCallback_&&s.addUploadProgressListener(n),s.send(this.url_,this.method_,this.body_,this.headers_).then(()=>{null!==this.progressCallback_&&s.removeUploadProgressListener(n),this.pendingConnection_=null;var e=s.getErrorCode()===i.NO_ERROR,t=s.getStatus();!e||B(t,this.additionalRetryCodes_)&&this.retry?(e=s.getErrorCode()===i.ABORT,r(!1,new q(!1,null,e))):(t=-1!==this.successCodes_.indexOf(t),r(!0,new q(t,s)))})}},t=(e,t)=>{const r=this.resolve_,s=this.reject_,n=t.connection;if(t.wasSuccessCode)try{var i=this.callback_(n,n.getResponse());void 0!==i?r(i):r()}catch(e){s(e)}else if(null!==n){const a=R();a.serverResponse=n.getErrorText(),this.errorCallback_?s(this.errorCallback_(n,a)):s(a)}else{var o;t.canceled?(o=(this.appDelete_?A:E)(),s(o)):(o=w(),s(o))}};this.canceled_?t(0,new q(!1,null,!0)):this.backoffId_=function(t,r,e){let s=1,n=null,i=null,o=!1,a=0;function h(){return 2===a}let l=!1;function u(...e){l||(l=!0,r.apply(null,e))}function c(e){n=setTimeout(()=>{n=null,t(_,h())},e)}function d(){i&&clearTimeout(i)}function _(t,...r){if(l)d();else{if(t)return d(),void u.call(null,t,...r);if(h()||o)return d(),void u.call(null,t,...r);s<64&&(s*=2);let e;e=1===a?(a=2,0):1e3*(s+Math.random()),c(e)}}let p=!1;function f(e){p||(p=!0,d(),l||(null!==n?(e||(a=2),clearTimeout(n),c(0)):e||(a=1)))}return c(0),i=setTimeout(()=>{f(o=!0)},e),f}(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,null!==this.backoffId_&&(0,this.backoffId_)(!1),null!==this.pendingConnection_&&this.pendingConnection_.abort()}}class q{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}}function V(...t){const r="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0;if(void 0!==r){const s=new r;for(let e=0;e<t.length;e++)s.append(t[e]);return s.getBlob()}if(P())return new Blob(t);throw new v(g.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}function H(e){if("undefined"==typeof atob)throw new v(g.UNSUPPORTED_ENVIRONMENT,"base-64 is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.");return atob(e)}const j={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class W{constructor(e,t){this.data=e,this.contentType=t||null}}function z(e,t){switch(e){case j.RAW:return new W($(t));case j.BASE64:case j.BASE64URL:return new W(G(e,t));case j.DATA_URL:return new W((r=t,(s=new X(r)).base64?G(j.BASE64,s.rest):function(e){let t;try{t=decodeURIComponent(e)}catch(e){throw S(j.DATA_URL,"Malformed data URL.")}return $(t)}(s.rest)),(r=t,new X(r).contentType))}var r,s;throw R()}function $(t){const r=[];for(let i=0;i<t.length;i++){let e=t.charCodeAt(i);var s,n;e<=127?r.push(e):e<=2047?r.push(192|e>>6,128|63&e):55296==(64512&e)?i<t.length-1&&56320==(64512&t.charCodeAt(i+1))?(s=e,n=t.charCodeAt(++i),e=65536|(1023&s)<<10|1023&n,r.push(240|e>>18,128|e>>12&63,128|e>>6&63,128|63&e)):r.push(239,191,189):56320==(64512&e)?r.push(239,191,189):r.push(224|e>>12,128|e>>6&63,128|63&e)}return new Uint8Array(r)}function G(t,e){switch(t){case j.BASE64:var r=-1!==e.indexOf("-"),s=-1!==e.indexOf("_");if(r||s)throw S(t,"Invalid character '"+(r?"-":"_")+"' found: is it base64url encoded?");break;case j.BASE64URL:s=-1!==e.indexOf("+"),r=-1!==e.indexOf("/");if(s||r)throw S(t,"Invalid character '"+(s?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/")}let n;try{n=H(e)}catch(e){if(e.message.includes("polyfill"))throw e;throw S(t,"Invalid character found")}const i=new Uint8Array(n.length);for(let o=0;o<n.length;o++)i[o]=n.charCodeAt(o);return i}class X{constructor(e){this.base64=!1,this.contentType=null;var t,r,s=e.match(/^data:([^,]+)?,/);if(null===s)throw S(j.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const n=s[1]||null;null!=n&&(this.base64=(t=n,r=";base64",t.length>=r.length&&t.substring(t.length-r.length)===r),this.contentType=this.base64?n.substring(0,n.length-";base64".length):n),this.rest=e.substring(e.indexOf(",")+1)}}class K{constructor(e,t){let r=0,s="";I(e)?(this.data_=e,r=e.size,s=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),r=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),r=e.length),this.size_=r,this.type_=s}size(){return this.size_}type(){return this.type_}slice(e,t){if(I(this.data_)){var r=this.data_,r=(n=e,i=t,(s=r).webkitSlice?s.webkitSlice(n,i):s.mozSlice?s.mozSlice(n,i):s.slice?s.slice(n,i):null);return null===r?null:new K(r)}var s,n,i,r=new Uint8Array(this.data_.buffer,e,t-e);return new K(r,!0)}static getBlob(...e){if(P()){var t=e.map(e=>e instanceof K?e.data_:e);return new K(V.apply(null,t))}{const s=e.map(e=>x(e)?z(j.RAW,e).data:e.data_);let t=0;s.forEach(e=>{t+=e.byteLength});const n=new Uint8Array(t);let r=0;return s.forEach(e=>{for(let t=0;t<e.length;t++)n[r++]=e[t]}),new K(n,!0)}}uploadData(){return this.data_}}function Z(e){let t;try{t=JSON.parse(e)}catch(e){return null}return"object"!=typeof(e=t)||Array.isArray(e)?null:t}function J(e){var t=e.lastIndexOf("/",e.length-2);return-1===t?e:e.slice(t+1)}function Y(e,t){return t}class Q{constructor(e,t,r,s){this.server=e,this.local=t||e,this.writable=!!r,this.xform=s||Y}}let ee=null;function te(){if(ee)return ee;const e=[];e.push(new Q("bucket")),e.push(new Q("generation")),e.push(new Q("metageneration")),e.push(new Q("name","fullPath",!0));const t=new Q("name");t.xform=function(e,t){return!x(t=t)||t.length<2?t:J(t)},e.push(t);const r=new Q("size");return r.xform=function(e,t){return void 0!==t?Number(t):t},e.push(r),e.push(new Q("timeCreated")),e.push(new Q("updated")),e.push(new Q("md5Hash",null,!0)),e.push(new Q("cacheControl",null,!0)),e.push(new Q("contentDisposition",null,!0)),e.push(new Q("contentEncoding",null,!0)),e.push(new Q("contentLanguage",null,!0)),e.push(new Q("contentType",null,!0)),e.push(new Q("metadata","customMetadata",!0)),ee=e,ee}function re(r,s){Object.defineProperty(r,"ref",{get:function(){var e=r.bucket,t=r.fullPath,t=new U(e,t);return s._makeStorageReference(t)}})}function se(e,t,r){var s=Z(t);return null===s?null:function(e,t,r){const s={type:"file"};var n=r.length;for(let i=0;i<n;i++){const o=r[i];s[o.local]=o.xform(s,t[o.server])}return re(s,e),s}(e,s,r)}function ne(e,t){const r={};var s=t.length;for(let i=0;i<s;i++){var n=t[i];n.writable&&(r[n.server]=e[n.local])}return JSON.stringify(r)}const ie="prefixes";function oe(e,t,r){var s=Z(r);return null===s?null:function(e,t,r){const s={prefixes:[],items:[],nextPageToken:r.nextPageToken};if(r[ie])for(const o of r[ie]){var n=o.replace(/\/$/,""),n=e._makeStorageReference(new U(t,n));s.prefixes.push(n)}if(r.items)for(const a of r.items){var i=e._makeStorageReference(new U(t,a.name));s.items.push(i)}return s}(e,t,s)}class ae{constructor(e,t,r,s){this.url=e,this.method=t,this.handler=r,this.timeout=s,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}function he(e){if(!e)throw R()}function le(s,n){return function(e,t){var r=se(s,t,n);return he(null!==r),r}}function ue(s,n){return function(e,t){var r=oe(s,n,t);return he(null!==r),r}}function ce(s,n){return function(e,t){var r=se(s,t,n);return he(null!==r),function(s,e,n,i){var t=Z(e);if(null===t)return null;if(!x(t.downloadTokens))return null;const r=t.downloadTokens;if(0===r.length)return null;const o=encodeURIComponent,a=r.split(",");return a.map(e=>{var t=s.bucket,r=s.fullPath;return L("/b/"+o(t)+"/o/"+o(r),n,i)+M({alt:"media",token:e})})[0]}(r,t,s.host,s._protocol)}}function de(n){return function(e,t){let r;var s;return r=401===e.getStatus()?e.getErrorText().includes("Firebase App Check token is invalid")?new v(g.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project."):new v(g.UNAUTHENTICATED,"User is not authenticated, please authenticate using Firebase Authentication and try again."):402===e.getStatus()?(s=n.bucket,new v(g.QUOTA_EXCEEDED,"Quota for bucket '"+s+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===e.getStatus()?(s=n.path,new v(g.UNAUTHORIZED,"User does not have permission to access '"+s+"'.")):t,r.status=e.getStatus(),r.serverResponse=t.serverResponse,r}}function _e(s){const n=de(s);return function(e,t){let r=n(e,t);return 404===e.getStatus()&&(r=(e=s.path,new v(g.OBJECT_NOT_FOUND,"Object '"+e+"' does not exist."))),r.serverResponse=t.serverResponse,r}}function pe(e,t,r){var s=L(t.fullServerUrl(),e.host,e._protocol),n=e.maxOperationRetryTime;const i=new ae(s,"GET",le(e,r),n);return i.errorHandler=_e(t),i}function fe(e,t,r){const s=Object.assign({},r);return s.fullPath=e.path,s.size=t.size(),s.contentType||(s.contentType=(e=t,(t=null)&&t.contentType||e&&e.type()||"application/octet-stream")),s}function ge(e,t,r,s,n){var i=t.bucketOnlyServerUrl();const o={"X-Goog-Upload-Protocol":"multipart"};var a=function(){let e="";for(let t=0;t<2;t++)e+=Math.random().toString().slice(2);return e}();o["Content-Type"]="multipart/related; boundary="+a;var h=fe(t,s,n),l="--"+a+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+ne(h,r)+"\r\n--"+a+"\r\nContent-Type: "+h.contentType+"\r\n\r\n",a="\r\n--"+a+"--";const u=K.getBlob(l,s,a);if(null===u)throw y();a={name:h.fullPath},h=L(i,e.host,e._protocol),i=e.maxUploadRetryTime;const c=new ae(h,"POST",le(e,r),i);return c.urlParams=a,c.headers=o,c.body=u.uploadData(),c.errorHandler=de(t),c}class me{constructor(e,t,r,s){this.current=e,this.total=t,this.finalized=!!r,this.metadata=s||null}}function be(e,t){let r=null;try{r=e.getResponseHeader("X-Goog-Upload-Status")}catch(e){he(!1)}const s=t||["active"];return he(!!r&&-1!==s.indexOf(r)),r}function ve(e,t,r,s,n){var i=t.bucketOnlyServerUrl(),o=fe(t,s,n),a={name:o.fullPath},h=L(i,e.host,e._protocol),l={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${s.size()}`,"X-Goog-Upload-Header-Content-Type":o.contentType,"Content-Type":"application/json; charset=utf-8"},i=ne(o,r),o=e.maxUploadRetryTime;const u=new ae(h,"POST",function(e){be(e);let t;try{t=e.getResponseHeader("X-Goog-Upload-URL")}catch(e){he(!1)}return he(x(t)),t},o);return u.urlParams=a,u.headers=l,u.body=i,u.errorHandler=de(t),u}function Te(e,t,r,n){var s=e.maxUploadRetryTime;const i=new ae(r,"POST",function(e){var t=be(e,["active","final"]);let r=null;try{r=e.getResponseHeader("X-Goog-Upload-Size-Received")}catch(e){he(!1)}r||he(!1);var s=Number(r);return he(!isNaN(s)),new me(s,n.size(),"final"===t)},s);return i.headers={"X-Goog-Upload-Command":"query"},i.errorHandler=de(t),i}function Re(e,o,t,a,r,h,s,n){const l=new me(0,0);if(s?(l.current=s.current,l.total=s.total):(l.current=0,l.total=a.size()),a.size()!==l.total)throw new v(g.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.");var i=l.total-l.current;let u=i;0<r&&(u=Math.min(u,r));var c=l.current,d=c+u;let _="";_=0===u?"finalize":i===u?"upload, finalize":"upload";i={"X-Goog-Upload-Command":_,"X-Goog-Upload-Offset":`${l.current}`};const p=a.slice(c,d);if(null===p)throw y();d=o.maxUploadRetryTime;const f=new ae(t,"POST",function(e,t){var r=be(e,["active","final"]),s=l.current+u,n=a.size();let i;return i="final"===r?le(o,h)(e,t):null,new me(s,n,"final"===r,i)},d);return f.headers=i,f.body=p.uploadData(),f.progressCallback=n||null,f.errorHandler=de(e),f}const we={STATE_CHANGED:"state_changed"},Ee={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function ye(e){switch(e){case"running":case"pausing":case"canceling":return Ee.RUNNING;case"paused":return Ee.PAUSED;case"success":return Ee.SUCCESS;case"canceled":return Ee.CANCELED;default:return Ee.ERROR}}class ke{constructor(e,t,r){var s;"function"==typeof e||null!=t||null!=r?(this.next=e,this.error=null!=t?t:void 0,this.complete=null!=r?r:void 0):(this.next=(s=e).next,this.error=s.error,this.complete=s.complete)}}function Ae(t){return(...e)=>{Promise.resolve().then(()=>t(...e))}}class Ce extends class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=i.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=i.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=i.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,r,s){if(this.sent_)throw O("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(t,e,!0),void 0!==s)for(const n in s)s.hasOwnProperty(n)&&this.xhr_.setRequestHeader(n,s[n].toString());return void 0!==r?this.xhr_.send(r):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw O("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw O("cannot .getStatus() before sending");try{return this.xhr_.status}catch(e){return-1}}getResponse(){if(!this.sent_)throw O("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw O("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){null!=this.xhr_.upload&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){null!=this.xhr_.upload&&this.xhr_.upload.removeEventListener("progress",e)}}{initXhr(){this.xhr_.responseType="text"}}function Se(){return new Ce}class Oe{constructor(e,t,r=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=e,this._blob=t,this._metadata=r,this._mappings=te(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=e=>{if(this._request=void 0,this._chunkMultiplier=1,e._codeEquals(g.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{var t=this.isExponentialBackoffExpired();if(B(e.status,[])){if(!t)return this.sleepTime=Math.max(2*this.sleepTime,1e3),this._needToFetchStatus=!0,void this.completeTransitions_();e=w()}this._error=e,this._transition("error")}},this._metadataErrorHandler=e=>{this._request=void 0,e._codeEquals(g.CANCELED)?this.completeTransitions_():(this._error=e,this._transition("error"))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t,this._start()}),this._promise.then(null,()=>{})}isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}_makeProgressCallback(){const t=this._transferred;return e=>this._updateProgress(t+e)}_shouldDoResumable(e){return 262144<e.size()}_start(){"running"===this._state&&void 0===this._request&&(this._resumable?void 0===this._uploadUrl?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(r){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([e,t])=>{switch(this._state){case"running":r(e,t);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused")}})}_createResumable(){this._resolveToken((e,t)=>{var r=ve(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const s=this._ref.storage._makeRequest(r,Se,e,t);this._request=s,s.getPromise().then(e=>{this._request=void 0,this._uploadUrl=e,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){const n=this._uploadUrl;this._resolveToken((e,t)=>{var r=Te(this._ref.storage,this._ref._location,n,this._blob);const s=this._ref.storage._makeRequest(r,Se,e,t);this._request=s,s.getPromise().then(e=>{this._request=void 0,this._updateProgress(e.current),this._needToFetchStatus=!1,e.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){const n=262144*this._chunkMultiplier,i=new me(this._transferred,this._blob.size()),o=this._uploadUrl;this._resolveToken((e,t)=>{let r;try{r=Re(this._ref._location,this._ref.storage,o,this._blob,n,this._mappings,i,this._makeProgressCallback())}catch(e){return this._error=e,void this._transition("error")}const s=this._ref.storage._makeRequest(r,Se,e,t,!1);this._request=s,s.getPromise().then(e=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(e.current),e.finalized?(this._metadata=e.metadata,this._transition("success")):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){2*(262144*this._chunkMultiplier)<33554432&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{var r=pe(this._ref.storage,this._ref._location,this._mappings);const s=this._ref.storage._makeRequest(r,Se,e,t);this._request=s,s.getPromise().then(e=>{this._request=void 0,this._metadata=e,this._transition("success")},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,t)=>{var r=ge(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata);const s=this._ref.storage._makeRequest(r,Se,e,t);this._request=s,s.getPromise().then(e=>{this._request=void 0,this._metadata=e,this._updateProgress(this._blob.size()),this._transition("success")},this._errorHandler)})}_updateProgress(e){var t=this._transferred;this._transferred=e,this._transferred!==t&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case"canceling":case"pausing":this._state=e,void 0!==this._request?this._request.cancel():this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_());break;case"running":var t="paused"===this._state;this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":this._state=e,this._notifyObservers();break;case"canceled":this._error=E(),this._state=e,this._notifyObservers();break;case"error":case"success":this._state=e,this._notifyObservers()}}completeTransitions_(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start()}}get snapshot(){var e=ye(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,r,s){const n=new ke(t||void 0,r||void 0,s||void 0);return this._addObserver(n),()=>{this._removeObserver(n)}}then(e,t){return this._promise.then(e,t)}catch(e){return this.then(null,e)}_addObserver(e){this._observers.push(e),this._notifyObserver(e)}_removeObserver(e){var t=this._observers.indexOf(e);-1!==t&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise();const e=this._observers.slice();e.forEach(e=>{this._notifyObserver(e)})}_finishPromise(){if(void 0!==this._resolve){let e=!0;switch(ye(this._state)){case Ee.SUCCESS:Ae(this._resolve.bind(null,this.snapshot))();break;case Ee.CANCELED:case Ee.ERROR:const t=this._reject;Ae(t.bind(null,this._error))();break;default:e=!1}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(ye(this._state)){case Ee.RUNNING:case Ee.PAUSED:e.next&&Ae(e.next.bind(e,this.snapshot))();break;case Ee.SUCCESS:e.complete&&Ae(e.complete.bind(e))();break;case Ee.CANCELED:case Ee.ERROR:default:e.error&&Ae(e.error.bind(e,this._error))()}}resume(){var e="paused"===this._state||"pausing"===this._state;return e&&this._transition("running"),e}pause(){var e="running"===this._state;return e&&this._transition("pausing"),e}cancel(){var e="running"===this._state||"pausing"===this._state;return e&&this._transition("canceling"),e}}class Ue{constructor(e,t){this._service=e,t instanceof U?this._location=t:this._location=U.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new Ue(e,t)}get root(){var e=new U(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return J(this._location.path)}get storage(){return this._service}get parent(){var e=function(e){if(0===e.length)return null;var t=e.lastIndexOf("/");return-1===t?"":e.slice(0,t)}(this._location.path);if(null===e)return null;e=new U(this._location.bucket,e);return new Ue(this._service,e)}_throwIfRoot(e){if(""===this._location.path)throw C(e)}}function Ne(e){const t={prefixes:[],items:[]};return async function e(t,r,s){const n={pageToken:s};const i=await xe(t,n);r.prefixes.push(...i.prefixes);r.items.push(...i.items);null!=i.nextPageToken&&await e(t,r,i.nextPageToken)}(e,t).then(()=>t)}function xe(e,t){null!=t&&"number"==typeof t.maxResults&&D("options.maxResults",1,1e3,t.maxResults);var r=t||{},r=function(e,t,r,s,n){const i={};t.isRoot?i.prefix="":i.prefix=t.path+"/",r&&0<r.length&&(i.delimiter=r),s&&(i.pageToken=s),n&&(i.maxResults=n);var o=L(t.bucketOnlyServerUrl(),e.host,e._protocol),a=e.maxOperationRetryTime;const h=new ae(o,"GET",ue(e,t.bucket),a);return h.urlParams=i,h.errorHandler=de(t),h}(e.storage,e._location,"/",r.pageToken,r.maxResults);return e.storage.makeRequestWithTokens(r,Se)}function Ie(e,t){e._throwIfRoot("updateMetadata");var r=function(e,t,r,s){var n=L(t.fullServerUrl(),e.host,e._protocol),i=ne(r,s),o=e.maxOperationRetryTime;const a=new ae(n,"PATCH",le(e,s),o);return a.headers={"Content-Type":"application/json; charset=utf-8"},a.body=i,a.errorHandler=_e(t),a}(e.storage,e._location,t,te());return e.storage.makeRequestWithTokens(r,Se)}function Pe(e){e._throwIfRoot("getDownloadURL");var t=function(e,t,r){var s=L(t.fullServerUrl(),e.host,e._protocol),n=e.maxOperationRetryTime;const i=new ae(s,"GET",ce(e,r),n);return i.errorHandler=_e(t),i}(e.storage,e._location,te());return e.storage.makeRequestWithTokens(t,Se).then(e=>{if(null===e)throw new v(g.NO_DOWNLOAD_URL,"The given file does not have any download URLs.");return e})}function De(e){e._throwIfRoot("deleteObject");var t=function(e,t){var r=L(t.fullServerUrl(),e.host,e._protocol),s=e.maxOperationRetryTime;const n=new ae(r,"DELETE",function(e,t){},s);return n.successCodes=[200,204],n.errorHandler=_e(t),n}(e.storage,e._location);return e.storage.makeRequestWithTokens(t,Se)}function Le(e,t){var r,s=(r=e._location.path,s=t.split("/").filter(e=>0<e.length).join("/"),0===r.length?s:r+"/"+s),s=new U(e._location.bucket,s);return new Ue(e.storage,s)}function Me(e,t){if(e instanceof Ve){var r=e;if(null==r._bucket)throw new v(g.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+b+"' property when initializing the app?");r=new Ue(r,r._bucket);return null!=t?Me(r,t):r}return void 0!==t?Le(e,t):e}function Be(e,t){if(t&&/^[A-Za-z]+:\/\//.test(t)){if(e instanceof Ve)return r=e,s=t,new Ue(r,s);throw k("To use ref(service, url), the first argument must be a Storage instance.")}return Me(e,t);var r,s}function Fe(e,t){var r=null==t?void 0:t[b];return null==r?null:U.makeFromBucketSpec(r,e)}function qe(e,t,r,s={}){e.host=`${t}:${r}`,e._protocol="http";var n=s["mockUserToken"];n&&(e._overrideAuthToken="string"==typeof n?n:function(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 r=t||"demo-project",s=e.iat||0,n=e.sub||e.user_id;if(!n)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");return n=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:n,user_id:n,firebase:{sign_in_provider:"custom",identities:{}}},e),[h(JSON.stringify({alg:"none",type:"JWT"})),h(JSON.stringify(n)),""].join(".")}(n,e.app.options.projectId))}class Ve{constructor(e,t,r,s,n){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=s,this._firebaseVersion=n,this._bucket=null,this._host=m,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=s?U.makeFromBucketSpec(s,this._host):Fe(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,null!=this._url?this._bucket=U.makeFromBucketSpec(this._url,e):this._bucket=Fe(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){D("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){D("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){var t=await e.getToken();if(null!==t)return t.accessToken}return null}async _getAppCheckToken(){const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new Ue(this,e)}_makeRequest(e,t,r,s,n=!0){if(this._deleted)return new N(A());{const u=([i,o,a,e,r,s,t=!0]=[e,this._appId,r,s,t,this._firebaseVersion,n],h=M(i.urlParams),l=i.url+h,h=Object.assign({},i.headers),n=h,(o=o)&&(n["X-Firebase-GMPID"]=o),o=h,null!==(a=a)&&0<a.length&&(o.Authorization="Firebase "+a),s=s,h["X-Firebase-Storage-Version"]="webjs/"+(null!=s?s:"AppManager"),s=h,null!==(e=e)&&(s["X-Firebase-AppCheck"]=e),new F(l,i.method,h,i.body,i.successCodes,i.additionalRetryCodes,i.handler,i.errorHandler,i.timeout,i.progressCallback,r,t));return this._requests.add(u),u.getPromise().then(()=>this._requests.delete(u),()=>this._requests.delete(u)),u}var i,o,a,h,l}async makeRequestWithTokens(e,t){var[r,s]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,r,s).getPromise()}}const He="@firebase/storage",je="0.12.4-dataconnect-preview.42eb5e521";function We(e,t,r){return e=p(e),t=t,r=r,(e=e)._throwIfRoot("uploadBytesResumable"),new Oe(e,new K(t),r)}function ze(e){return function(e){e._throwIfRoot("getMetadata");var t=pe(e.storage,e._location,te());return e.storage.makeRequestWithTokens(t,Se)}(e=p(e))}function $e(e,t){return Be(e=p(e),t)}function Ge(e,{instanceIdentifier:t}){var r=e.getProvider("app").getImmediate(),s=e.getProvider("auth-internal"),n=e.getProvider("app-check-internal");return new Ve(r,s,n,t,rt.SDK_VERSION)}rt._registerComponent(new f("storage",Ge,"PUBLIC").setMultipleInstances(!0)),rt.registerVersion(He,je,""),rt.registerVersion(He,je,"esm2017");class Xe{constructor(e,t,r){this._delegate=e,this.task=t,this.ref=r}get bytesTransferred(){return this._delegate.bytesTransferred}get metadata(){return this._delegate.metadata}get state(){return this._delegate.state}get totalBytes(){return this._delegate.totalBytes}}class Ke{constructor(e,t){this._delegate=e,this._ref=t,this.cancel=this._delegate.cancel.bind(this._delegate),this.catch=this._delegate.catch.bind(this._delegate),this.pause=this._delegate.pause.bind(this._delegate),this.resume=this._delegate.resume.bind(this._delegate)}get snapshot(){return new Xe(this._delegate.snapshot,this,this._ref)}then(t,e){return this._delegate.then(e=>{if(t)return t(new Xe(e,this,this._ref))},e)}on(e,t,r,s){let n=void 0;return t&&(n="function"==typeof t?e=>t(new Xe(e,this,this._ref)):{next:t.next?e=>t.next(new Xe(e,this,this._ref)):void 0,complete:t.complete||void 0,error:t.error||void 0}),this._delegate.on(e,n,r||void 0,s||void 0)}}class Ze{constructor(e,t){this._delegate=e,this._service=t}get prefixes(){return this._delegate.prefixes.map(e=>new Je(e,this._service))}get items(){return this._delegate.items.map(e=>new Je(e,this._service))}get nextPageToken(){return this._delegate.nextPageToken||null}}class Je{constructor(e,t){this._delegate=e,this.storage=t}get name(){return this._delegate.name}get bucket(){return this._delegate.bucket}get fullPath(){return this._delegate.fullPath}toString(){return this._delegate.toString()}child(e){var t=Le(this._delegate,e);return new Je(t,this.storage)}get root(){return new Je(this._delegate.root,this.storage)}get parent(){var e=this._delegate.parent;return null==e?null:new Je(e,this.storage)}put(e,t){return this._throwIfRoot("put"),new Ke(We(this._delegate,e,t),this)}putString(e,t=j.RAW,r){this._throwIfRoot("putString");var s=z(t,e);const n=Object.assign({},r);return null==n.contentType&&null!=s.contentType&&(n.contentType=s.contentType),new Ke(new Oe(this._delegate,new K(s.data,!0),n),this)}listAll(){return Ne(p(this._delegate)).then(e=>new Ze(e,this.storage))}list(e){return t=this._delegate,e=e||void 0,xe(t=p(t),e).then(e=>new Ze(e,this.storage));var t}getMetadata(){return ze(this._delegate)}updateMetadata(e){return Ie(p(this._delegate),e)}getDownloadURL(){return Pe(p(this._delegate))}delete(){return this._throwIfRoot("delete"),De(p(this._delegate))}_throwIfRoot(e){if(""===this._delegate._location.path)throw C(e)}}class Ye{constructor(e,t){this.app=e,this._delegate=t}get maxOperationRetryTime(){return this._delegate.maxOperationRetryTime}get maxUploadRetryTime(){return this._delegate.maxUploadRetryTime}ref(e){if(Qe(e))throw k("ref() expected a child path but got a URL, use refFromURL instead.");return new Je($e(this._delegate,e),this)}refFromURL(e){if(!Qe(e))throw k("refFromURL() expected a full URL but got a child path, use ref() instead.");try{U.makeFromUrl(e,this._delegate.host)}catch(e){throw k("refFromUrl() expected a valid full URL but got an invalid one.")}return new Je($e(this._delegate,e),this)}setMaxUploadRetryTime(e){this._delegate.maxUploadRetryTime=e}setMaxOperationRetryTime(e){this._delegate.maxOperationRetryTime=e}useEmulator(e,t,r={}){var s;[s,e,t,r={}]=[this._delegate,e,t,r],qe(s,e,t,r)}}function Qe(e){return/^[A-Za-z]+:\/\//.test(e)}function et(e,{instanceIdentifier:t}){var r=e.getProvider("app-compat").getImmediate(),s=e.getProvider("storage").getImmediate({identifier:t});return new Ye(r,s)}r=n.default,s={TaskState:Ee,TaskEvent:we,StringFormat:j,Storage:Ye,Reference:Je},r.INTERNAL.registerComponent(new f("storage-compat",et,"PUBLIC").setServiceProps(s).setMultipleInstances(!0)),r.registerVersion("@firebase/storage-compat","0.3.7-dataconnect-preview.42eb5e521")}).apply(this,arguments)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-storage-compat.js - be sure to load firebase-app.js first.")}});
|
|
2
2
|
//# sourceMappingURL=firebase-storage-compat.js.map
|