firebase 9.17.2 → 9.18.0

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/app/dist/esm/index.esm.js +1 -1
  3. package/app/dist/index.cjs.js +1 -1
  4. package/app/dist/index.mjs +1 -1
  5. package/compat/app/dist/esm/index.esm.js +1 -1
  6. package/compat/app/dist/index.cjs.js +1 -1
  7. package/compat/app/dist/index.mjs +1 -1
  8. package/compat/dist/esm/index.esm.js +2 -2
  9. package/compat/dist/index.node.cjs +2 -2
  10. package/compat/dist/index.rn.cjs.js +2 -2
  11. package/firebase-analytics.js +1 -1
  12. package/firebase-app-check.js +1 -1
  13. package/firebase-app-compat.js +2 -2
  14. package/firebase-app.js +5 -5
  15. package/firebase-auth-compat.js +1 -1
  16. package/firebase-auth-compat.js.map +1 -1
  17. package/firebase-auth-cordova.js +1 -1
  18. package/firebase-auth-cordova.js.map +1 -1
  19. package/firebase-auth-react-native.js +1 -1
  20. package/firebase-auth-react-native.js.map +1 -1
  21. package/firebase-auth.js +1 -1
  22. package/firebase-auth.js.map +1 -1
  23. package/firebase-compat.js +4 -4
  24. package/firebase-compat.js.map +1 -1
  25. package/firebase-database.js +1 -1
  26. package/firebase-firestore-compat.js +1 -1
  27. package/firebase-firestore-compat.js.map +1 -1
  28. package/firebase-firestore-lite.js +1 -1
  29. package/firebase-firestore-lite.js.map +1 -1
  30. package/firebase-firestore.js +1 -1
  31. package/firebase-firestore.js.map +1 -1
  32. package/firebase-functions.js +1 -1
  33. package/firebase-installations.js +1 -1
  34. package/firebase-messaging-sw.js +1 -1
  35. package/firebase-messaging.js +1 -1
  36. package/firebase-performance-standalone-compat.es2017.js +5 -5
  37. package/firebase-performance-standalone-compat.js +1 -1
  38. package/firebase-performance.js +1 -1
  39. package/firebase-remote-config.js +1 -1
  40. package/firebase-storage.js +1 -1
  41. package/package.json +7 -7
@@ -1,3 +1,3 @@
1
- import{registerVersion as t,_registerComponent as e,_getProvider as n,getApp as s,SDK_VERSION as r}from"https://www.gstatic.com/firebasejs/9.17.2/firebase-app.js";function a(){try{return"object"==typeof indexedDB}catch(t){return!1}}class i extends Error{constructor(t,e,n){super(e),this.code=t,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,i.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,o.prototype.create)}}class o{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(t,...e){const n=e[0]||{},s=`${this.service}/${t}`,r=this.errors[t],a=r?function(t,e){return t.replace(c,((t,n)=>{const s=e[n];return null!=s?String(s):`<${n}?>`}))}(r,n):"Error",o=`${this.serviceName}: ${a} (${s}).`;return new i(s,o,n)}}const c=/\{\$([^}]+)}/g;function u(t,e=1e3,n=2){const s=e*Math.pow(n,t),r=Math.round(.5*s*(Math.random()-.5)*2);return Math.min(144e5,s+r)}function l(t){return t&&t._delegate?t._delegate:t}class g{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}var h;!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(h||(h={}));const f={debug:h.DEBUG,verbose:h.VERBOSE,info:h.INFO,warn:h.WARN,error:h.ERROR,silent:h.SILENT},d=h.INFO,p={[h.DEBUG]:"log",[h.VERBOSE]:"log",[h.INFO]:"info",[h.WARN]:"warn",[h.ERROR]:"error"},m=(t,e,...n)=>{if(e<t.logLevel)return;const s=(new Date).toISOString(),r=p[e];if(!r)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[r](`[${s}] ${t.name}:`,...n)};class w{constructor(t){this.name=t,this._logLevel=d,this._logHandler=m,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in h))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel="string"==typeof t?f[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,h.DEBUG,...t),this._logHandler(this,h.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,h.VERBOSE,...t),this._logHandler(this,h.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,h.INFO,...t),this._logHandler(this,h.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,h.WARN,...t),this._logHandler(this,h.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,h.ERROR,...t),this._logHandler(this,h.ERROR,...t)}}let v,_;const y=new WeakMap,b=new WeakMap,E=new WeakMap,S=new WeakMap,I=new WeakMap;let C={get(t,e,n){if(t instanceof IDBTransaction){if("done"===e)return b.get(t);if("objectStoreNames"===e)return t.objectStoreNames||E.get(t);if("store"===e)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return M(t[e])},set:(t,e,n)=>(t[e]=n,!0),has:(t,e)=>t instanceof IDBTransaction&&("done"===e||"store"===e)||e in t};function T(t){return t!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(_||(_=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(D(this),e),M(y.get(this))}:function(...e){return M(t.apply(D(this),e))}:function(e,...n){const s=t.call(D(this),e,...n);return E.set(s,e.sort?e.sort():[e]),M(s)}}function L(t){return"function"==typeof t?T(t):(t instanceof IDBTransaction&&function(t){if(b.has(t))return;const e=new Promise(((e,n)=>{const s=()=>{t.removeEventListener("complete",r),t.removeEventListener("error",a),t.removeEventListener("abort",a)},r=()=>{e(),s()},a=()=>{n(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",r),t.addEventListener("error",a),t.addEventListener("abort",a)}));b.set(t,e)}(t),e=t,(v||(v=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some((t=>e instanceof t))?new Proxy(t,C):t);var e}function M(t){if(t instanceof IDBRequest)return function(t){const e=new Promise(((e,n)=>{const s=()=>{t.removeEventListener("success",r),t.removeEventListener("error",a)},r=()=>{e(M(t.result)),s()},a=()=>{n(t.error),s()};t.addEventListener("success",r),t.addEventListener("error",a)}));return e.then((e=>{e instanceof IDBCursor&&y.set(e,t)})).catch((()=>{})),I.set(e,t),e}(t);if(S.has(t))return S.get(t);const e=L(t);return e!==t&&(S.set(t,e),I.set(e,t)),e}const D=t=>I.get(t);const k=["get","getKey","getAll","getAllKeys","count"],F=["put","add","delete","clear"],P=new Map;function O(t,e){if(!(t instanceof IDBDatabase)||e in t||"string"!=typeof e)return;if(P.get(e))return P.get(e);const n=e.replace(/FromIndex$/,""),s=e!==n,r=F.includes(n);if(!(n in(s?IDBIndex:IDBObjectStore).prototype)||!r&&!k.includes(n))return;const a=async function(t,...e){const a=this.transaction(t,r?"readwrite":"readonly");let i=a.store;return s&&(i=i.index(e.shift())),(await Promise.all([i[n](...e),r&&a.done]))[0]};return P.set(e,a),a}C=(t=>({...t,get:(e,n,s)=>O(e,n)||t.get(e,n,s),has:(e,n)=>!!O(e,n)||t.has(e,n)}))(C);const N="@firebase/installations",j=new o("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function R(t){return t instanceof i&&t.code.includes("request-failed")}function A({projectId:t}){return`https://firebaseinstallations.googleapis.com/v1/projects/${t}/installations`}function B(t){return{token:t.token,requestStatus:2,expiresIn:(e=t.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()};var e}async function $(t,e){const n=(await e.json()).error;return j.create("request-failed",{requestName:t,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function H({apiKey:t}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":t})}function x(t,{refreshToken:e}){const n=H(t);return n.append("Authorization",function(t){return`FIS_v2 ${t}`}(e)),n}async function q(t){const e=await t();return e.status>=500&&e.status<600?t():e}function K(t){return new Promise((e=>{setTimeout(e,t)}))}const U=/^[cdef][\w-]{21}$/;function V(){try{const t=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(t),t[0]=112+t[0]%16;const e=function(t){return(e=t,btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_")).substr(0,22);var e}(t);return U.test(e)?e:""}catch(t){return""}}function z(t){return`${t.appName}!${t.appId}`}const G=new Map;function W(t,e){const n=z(t);J(n,e),function(t,e){const n=function(){!Y&&"BroadcastChannel"in self&&(Y=new BroadcastChannel("[Firebase] FID Change"),Y.onmessage=t=>{J(t.data.key,t.data.fid)});return Y}();n&&n.postMessage({key:t,fid:e});0===G.size&&Y&&(Y.close(),Y=null)}(n,e)}function J(t,e){const n=G.get(t);if(n)for(const t of n)t(e)}let Y=null;const Z="firebase-installations-store";let Q=null;function X(){return Q||(Q=function(t,e,{blocked:n,upgrade:s,blocking:r,terminated:a}={}){const i=indexedDB.open(t,e),o=M(i);return s&&i.addEventListener("upgradeneeded",(t=>{s(M(i.result),t.oldVersion,t.newVersion,M(i.transaction))})),n&&i.addEventListener("blocked",(()=>n())),o.then((t=>{a&&t.addEventListener("close",(()=>a())),r&&t.addEventListener("versionchange",(()=>r()))})).catch((()=>{})),o}("firebase-installations-database",1,{upgrade:(t,e)=>{if(0===e)t.createObjectStore(Z)}})),Q}async function tt(t,e){const n=z(t),s=(await X()).transaction(Z,"readwrite"),r=s.objectStore(Z),a=await r.get(n);return await r.put(e,n),await s.done,a&&a.fid===e.fid||W(t,e.fid),e}async function et(t){const e=z(t),n=(await X()).transaction(Z,"readwrite");await n.objectStore(Z).delete(e),await n.done}async function nt(t,e){const n=z(t),s=(await X()).transaction(Z,"readwrite"),r=s.objectStore(Z),a=await r.get(n),i=e(a);return void 0===i?await r.delete(n):await r.put(i,n),await s.done,!i||a&&a.fid===i.fid||W(t,i.fid),i}async function st(t){let e;const n=await nt(t.appConfig,(n=>{const s=function(t){return it(t||{fid:V(),registrationStatus:0})}(n),r=function(t,e){if(0===e.registrationStatus){if(!navigator.onLine){return{installationEntry:e,registrationPromise:Promise.reject(j.create("app-offline"))}}const n={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},s=async function(t,e){try{const n=await async function({appConfig:t,heartbeatServiceProvider:e},{fid:n}){const s=A(t),r=H(t),a=e.getImmediate({optional:!0});if(a){const t=await a.getHeartbeatsHeader();t&&r.append("x-firebase-client",t)}const i={fid:n,authVersion:"FIS_v2",appId:t.appId,sdkVersion:"w:0.6.4"},o={method:"POST",headers:r,body:JSON.stringify(i)},c=await q((()=>fetch(s,o)));if(c.ok){const t=await c.json();return{fid:t.fid||n,registrationStatus:2,refreshToken:t.refreshToken,authToken:B(t.authToken)}}throw await $("Create Installation",c)}(t,e);return tt(t.appConfig,n)}catch(n){throw R(n)&&409===n.customData.serverCode?await et(t.appConfig):await tt(t.appConfig,{fid:e.fid,registrationStatus:0}),n}}(t,n);return{installationEntry:n,registrationPromise:s}}return 1===e.registrationStatus?{installationEntry:e,registrationPromise:rt(t)}:{installationEntry:e}}(t,s);return e=r.registrationPromise,r.installationEntry}));return""===n.fid?{installationEntry:await e}:{installationEntry:n,registrationPromise:e}}async function rt(t){let e=await at(t.appConfig);for(;1===e.registrationStatus;)await K(100),e=await at(t.appConfig);if(0===e.registrationStatus){const{installationEntry:e,registrationPromise:n}=await st(t);return n||e}return e}function at(t){return nt(t,(t=>{if(!t)throw j.create("installation-not-found");return it(t)}))}function it(t){return 1===(e=t).registrationStatus&&e.registrationTime+1e4<Date.now()?{fid:t.fid,registrationStatus:0}:t;var e}async function ot({appConfig:t,heartbeatServiceProvider:e},n){const s=function(t,{fid:e}){return`${A(t)}/${e}/authTokens:generate`}(t,n),r=x(t,n),a=e.getImmediate({optional:!0});if(a){const t=await a.getHeartbeatsHeader();t&&r.append("x-firebase-client",t)}const i={installation:{sdkVersion:"w:0.6.4",appId:t.appId}},o={method:"POST",headers:r,body:JSON.stringify(i)},c=await q((()=>fetch(s,o)));if(c.ok){return B(await c.json())}throw await $("Generate Auth Token",c)}async function ct(t,e=!1){let n;const s=await nt(t.appConfig,(s=>{if(!lt(s))throw j.create("not-registered");const r=s.authToken;if(!e&&function(t){return 2===t.requestStatus&&!function(t){const e=Date.now();return e<t.creationTime||t.creationTime+t.expiresIn<e+36e5}(t)}(r))return s;if(1===r.requestStatus)return n=async function(t,e){let n=await ut(t.appConfig);for(;1===n.authToken.requestStatus;)await K(100),n=await ut(t.appConfig);const s=n.authToken;return 0===s.requestStatus?ct(t,e):s}(t,e),s;{if(!navigator.onLine)throw j.create("app-offline");const e=function(t){const e={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},t),{authToken:e})}(s);return n=async function(t,e){try{const n=await ot(t,e),s=Object.assign(Object.assign({},e),{authToken:n});return await tt(t.appConfig,s),n}catch(n){if(!R(n)||401!==n.customData.serverCode&&404!==n.customData.serverCode){const n=Object.assign(Object.assign({},e),{authToken:{requestStatus:0}});await tt(t.appConfig,n)}else await et(t.appConfig);throw n}}(t,e),e}}));return n?await n:s.authToken}function ut(t){return nt(t,(t=>{if(!lt(t))throw j.create("not-registered");const e=t.authToken;return 1===(n=e).requestStatus&&n.requestTime+1e4<Date.now()?Object.assign(Object.assign({},t),{authToken:{requestStatus:0}}):t;var n}))}function lt(t){return void 0!==t&&2===t.registrationStatus}async function gt(t,e=!1){const n=t;await async function(t){const{registrationPromise:e}=await st(t);e&&await e}(n);return(await ct(n,e)).token}function ht(t){return j.create("missing-app-config-values",{valueName:t})}const ft=t=>{const e=t.getProvider("app").getImmediate(),s=n(e,"installations").getImmediate();return{getId:()=>async function(t){const e=t,{installationEntry:n,registrationPromise:s}=await st(e);return s?s.catch(console.error):ct(e).catch(console.error),n.fid}(s),getToken:t=>gt(s,t)}};e(new g("installations",(t=>{const e=t.getProvider("app").getImmediate(),s=function(t){if(!t||!t.options)throw ht("App Configuration");if(!t.name)throw ht("App Name");const e=["projectId","apiKey","appId"];for(const n of e)if(!t.options[n])throw ht(n);return{appName:t.name,projectId:t.options.projectId,apiKey:t.options.apiKey,appId:t.options.appId}}(e);return{app:e,appConfig:s,heartbeatServiceProvider:n(e,"heartbeat"),_delete:()=>Promise.resolve()}}),"PUBLIC")),e(new g("installations-internal",ft,"PRIVATE")),t(N,"0.6.4"),t(N,"0.6.4","esm2017");const dt="@firebase/remote-config";class pt{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}abort(){this.listeners.forEach((t=>t()))}}const mt=new o("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 wt=["1","true","t","yes","y","on"];class vt{constructor(t,e=""){this._source=t,this._value=e}asString(){return this._value}asBoolean(){return"static"!==this._source&&wt.indexOf(this._value.toLowerCase())>=0}asNumber(){if("static"===this._source)return 0;let t=Number(this._value);return isNaN(t)&&(t=0),t}getSource(){return this._source}}function _t(t=s()){t=l(t);return n(t,"remote-config").getImmediate()}async function yt(t){const e=l(t),[n,s]=await Promise.all([e._storage.getLastSuccessfulFetchResponse(),e._storage.getActiveConfigEtag()]);return!!(n&&n.config&&n.eTag&&n.eTag!==s)&&(await Promise.all([e._storageCache.setActiveConfig(n.config),e._storage.setActiveConfigEtag(n.eTag)]),!0)}function bt(t){const e=l(t);return e._initializePromise||(e._initializePromise=e._storageCache.loadFromStorage().then((()=>{e._isInitializationComplete=!0}))),e._initializePromise}async function Et(t){const e=l(t),n=new pt;setTimeout((async()=>{n.abort()}),e.settings.fetchTimeoutMillis);try{await e._client.fetch({cacheMaxAgeMillis:e.settings.minimumFetchIntervalMillis,signal:n}),await e._storageCache.setLastFetchStatus("success")}catch(t){const n=function(t,e){return t instanceof i&&-1!==t.code.indexOf(e)}(t,"fetch-throttle")?"throttle":"failure";throw await e._storageCache.setLastFetchStatus(n),t}}function St(t){const e=l(t);return function(t={},e={}){return Object.keys(Object.assign(Object.assign({},t),e))}(e._storageCache.getActiveConfig(),e.defaultConfig).reduce(((e,n)=>(e[n]=Lt(t,n),e)),{})}function It(t,e){return Lt(l(t),e).asBoolean()}function Ct(t,e){return Lt(l(t),e).asNumber()}function Tt(t,e){return Lt(l(t),e).asString()}function Lt(t,e){const n=l(t);n._isInitializationComplete||n._logger.debug(`A value was requested for key "${e}" before SDK initialization completed. Await on ensureInitialized if the intent was to get a previously activated value.`);const s=n._storageCache.getActiveConfig();return s&&void 0!==s[e]?new vt("remote",s[e]):n.defaultConfig&&void 0!==n.defaultConfig[e]?new vt("default",String(n.defaultConfig[e])):(n._logger.debug(`Returning static value for key "${e}". Define a default or remote value if this is unintentional.`),new vt("static"))}function Mt(t,e){const n=l(t);switch(e){case"debug":n._logger.logLevel=h.DEBUG;break;case"silent":n._logger.logLevel=h.SILENT;break;default:n._logger.logLevel=h.ERROR}}class Dt{constructor(t,e,n,s){this.client=t,this.storage=e,this.storageCache=n,this.logger=s}isCachedDataFresh(t,e){if(!e)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;const n=Date.now()-e,s=n<=t;return this.logger.debug(`Config fetch cache check. Cache age millis: ${n}. Cache max age millis (minimumFetchIntervalMillis setting): ${t}. Is cache hit: ${s}.`),s}async fetch(t){const[e,n]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(n&&this.isCachedDataFresh(t.cacheMaxAgeMillis,e))return n;t.eTag=n&&n.eTag;const s=await this.client.fetch(t),r=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===s.status&&r.push(this.storage.setLastSuccessfulFetchResponse(s)),await Promise.all(r),s}}function kt(t=navigator){return t.languages&&t.languages[0]||t.language}class Ft{constructor(t,e,n,s,r,a){this.firebaseInstallations=t,this.sdkVersion=e,this.namespace=n,this.projectId=s,this.apiKey=r,this.appId=a}async fetch(t){const[e,n]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),s=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,r={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":t.eTag||"*"},a={sdk_version:this.sdkVersion,app_instance_id:e,app_instance_id_token:n,app_id:this.appId,language_code:kt()},i={method:"POST",headers:r,body:JSON.stringify(a)},o=fetch(s,i),c=new Promise(((e,n)=>{t.signal.addEventListener((()=>{const t=new Error("The operation was aborted.");t.name="AbortError",n(t)}))}));let u;try{await Promise.race([o,c]),u=await o}catch(t){let e="fetch-client-network";throw"AbortError"===(null==t?void 0:t.name)&&(e="fetch-timeout"),mt.create(e,{originalErrorMessage:null==t?void 0:t.message})}let l=u.status;const g=u.headers.get("ETag")||void 0;let h,f;if(200===u.status){let t;try{t=await u.json()}catch(t){throw mt.create("fetch-client-parse",{originalErrorMessage:null==t?void 0:t.message})}h=t.entries,f=t.state}if("INSTANCE_STATE_UNSPECIFIED"===f?l=500:"NO_CHANGE"===f?l=304:"NO_TEMPLATE"!==f&&"EMPTY_CONFIG"!==f||(h={}),304!==l&&200!==l)throw mt.create("fetch-status",{httpStatus:l});return{status:l,eTag:g,config:h}}}class Pt{constructor(t,e){this.client=t,this.storage=e}async fetch(t){const e=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(t,e)}async attemptFetch(t,{throttleEndTimeMillis:e,backoffCount:n}){await function(t,e){return new Promise(((n,s)=>{const r=Math.max(e-Date.now(),0),a=setTimeout(n,r);t.addEventListener((()=>{clearTimeout(a),s(mt.create("fetch-throttle",{throttleEndTimeMillis:e}))}))}))}(t.signal,e);try{const e=await this.client.fetch(t);return await this.storage.deleteThrottleMetadata(),e}catch(e){if(!function(t){if(!(t instanceof i&&t.customData))return!1;const e=Number(t.customData.httpStatus);return 429===e||500===e||503===e||504===e}(e))throw e;const s={throttleEndTimeMillis:Date.now()+u(n),backoffCount:n+1};return await this.storage.setThrottleMetadata(s),this.attemptFetch(t,s)}}}class Ot{constructor(t,e,n,s,r){this.app=t,this._client=e,this._storageCache=n,this._storage=s,this._logger=r,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 Nt(t,e){const n=t.target.error||void 0;return mt.create(e,{originalErrorMessage:n&&(null==n?void 0:n.message)})}class jt{constructor(t,e,n,s=function(){return new Promise(((t,e)=>{try{const n=indexedDB.open("firebase_remote_config",1);n.onerror=t=>{e(Nt(t,"storage-open"))},n.onsuccess=e=>{t(e.target.result)},n.onupgradeneeded=t=>{const e=t.target.result;0===t.oldVersion&&e.createObjectStore("app_namespace_store",{keyPath:"compositeKey"})}}catch(t){e(mt.create("storage-open",{originalErrorMessage:null==t?void 0:t.message}))}}))}()){this.appId=t,this.appName=e,this.namespace=n,this.openDbPromise=s}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(t){return this.set("last_fetch_status",t)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(t){return this.set("last_successful_fetch_timestamp_millis",t)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(t){return this.set("last_successful_fetch_response",t)}getActiveConfig(){return this.get("active_config")}setActiveConfig(t){return this.set("active_config",t)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(t){return this.set("active_config_etag",t)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(t){return this.set("throttle_metadata",t)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(t){const e=await this.openDbPromise;return new Promise(((n,s)=>{const r=e.transaction(["app_namespace_store"],"readonly").objectStore("app_namespace_store"),a=this.createCompositeKey(t);try{const t=r.get(a);t.onerror=t=>{s(Nt(t,"storage-get"))},t.onsuccess=t=>{const e=t.target.result;n(e?e.value:void 0)}}catch(t){s(mt.create("storage-get",{originalErrorMessage:null==t?void 0:t.message}))}}))}async set(t,e){const n=await this.openDbPromise;return new Promise(((s,r)=>{const a=n.transaction(["app_namespace_store"],"readwrite").objectStore("app_namespace_store"),i=this.createCompositeKey(t);try{const t=a.put({compositeKey:i,value:e});t.onerror=t=>{r(Nt(t,"storage-set"))},t.onsuccess=()=>{s()}}catch(t){r(mt.create("storage-set",{originalErrorMessage:null==t?void 0:t.message}))}}))}async delete(t){const e=await this.openDbPromise;return new Promise(((n,s)=>{const r=e.transaction(["app_namespace_store"],"readwrite").objectStore("app_namespace_store"),a=this.createCompositeKey(t);try{const t=r.delete(a);t.onerror=t=>{s(Nt(t,"storage-delete"))},t.onsuccess=()=>{n()}}catch(t){s(mt.create("storage-delete",{originalErrorMessage:null==t?void 0:t.message}))}}))}createCompositeKey(t){return[this.appId,this.appName,this.namespace,t].join()}}class Rt{constructor(t){this.storage=t}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){const t=this.storage.getLastFetchStatus(),e=this.storage.getLastSuccessfulFetchTimestampMillis(),n=this.storage.getActiveConfig(),s=await t;s&&(this.lastFetchStatus=s);const r=await e;r&&(this.lastSuccessfulFetchTimestampMillis=r);const a=await n;a&&(this.activeConfig=a)}setLastFetchStatus(t){return this.lastFetchStatus=t,this.storage.setLastFetchStatus(t)}setLastSuccessfulFetchTimestampMillis(t){return this.lastSuccessfulFetchTimestampMillis=t,this.storage.setLastSuccessfulFetchTimestampMillis(t)}setActiveConfig(t){return this.activeConfig=t,this.storage.setActiveConfig(t)}}async function At(t){return t=l(t),await Et(t),yt(t)}async function Bt(){if(!a())return!1;try{return await new Promise(((t,e)=>{try{let n=!0;const s="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(s);r.onsuccess=()=>{r.result.close(),n||self.indexedDB.deleteDatabase(s),t(!0)},r.onupgradeneeded=()=>{n=!1},r.onerror=()=>{var t;e((null===(t=r.error)||void 0===t?void 0:t.message)||"")}}catch(t){e(t)}}))}catch(t){return!1}}e(new g("remote-config",(function(t,{instanceIdentifier:e}){const n=t.getProvider("app").getImmediate(),s=t.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw mt.create("registration-window");if(!a())throw mt.create("indexed-db-unavailable");const{projectId:i,apiKey:o,appId:c}=n.options;if(!i)throw mt.create("registration-project-id");if(!o)throw mt.create("registration-api-key");if(!c)throw mt.create("registration-app-id");e=e||"firebase";const u=new jt(c,n.name,e),l=new Rt(u),g=new w(dt);g.logLevel=h.ERROR;const f=new Ft(s,r,e,i,o,c),d=new Pt(f,u),p=new Dt(d,u,l,g),m=new Ot(n,p,l,u,g);return bt(m),m}),"PUBLIC").setMultipleInstances(!0)),t(dt,"0.4.4"),t(dt,"0.4.4","esm2017");export{yt as activate,bt as ensureInitialized,At as fetchAndActivate,Et as fetchConfig,St as getAll,It as getBoolean,Ct as getNumber,_t as getRemoteConfig,Tt as getString,Lt as getValue,Bt as isSupported,Mt as setLogLevel};
1
+ import{registerVersion as t,_registerComponent as e,_getProvider as n,getApp as s,SDK_VERSION as r}from"https://www.gstatic.com/firebasejs/9.18.0/firebase-app.js";function a(){try{return"object"==typeof indexedDB}catch(t){return!1}}class i extends Error{constructor(t,e,n){super(e),this.code=t,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,i.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,o.prototype.create)}}class o{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(t,...e){const n=e[0]||{},s=`${this.service}/${t}`,r=this.errors[t],a=r?function(t,e){return t.replace(c,((t,n)=>{const s=e[n];return null!=s?String(s):`<${n}?>`}))}(r,n):"Error",o=`${this.serviceName}: ${a} (${s}).`;return new i(s,o,n)}}const c=/\{\$([^}]+)}/g;function u(t,e=1e3,n=2){const s=e*Math.pow(n,t),r=Math.round(.5*s*(Math.random()-.5)*2);return Math.min(144e5,s+r)}function l(t){return t&&t._delegate?t._delegate:t}class g{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}var h;!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(h||(h={}));const f={debug:h.DEBUG,verbose:h.VERBOSE,info:h.INFO,warn:h.WARN,error:h.ERROR,silent:h.SILENT},d=h.INFO,p={[h.DEBUG]:"log",[h.VERBOSE]:"log",[h.INFO]:"info",[h.WARN]:"warn",[h.ERROR]:"error"},m=(t,e,...n)=>{if(e<t.logLevel)return;const s=(new Date).toISOString(),r=p[e];if(!r)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[r](`[${s}] ${t.name}:`,...n)};class w{constructor(t){this.name=t,this._logLevel=d,this._logHandler=m,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in h))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel="string"==typeof t?f[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,h.DEBUG,...t),this._logHandler(this,h.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,h.VERBOSE,...t),this._logHandler(this,h.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,h.INFO,...t),this._logHandler(this,h.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,h.WARN,...t),this._logHandler(this,h.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,h.ERROR,...t),this._logHandler(this,h.ERROR,...t)}}let v,_;const y=new WeakMap,b=new WeakMap,E=new WeakMap,S=new WeakMap,I=new WeakMap;let C={get(t,e,n){if(t instanceof IDBTransaction){if("done"===e)return b.get(t);if("objectStoreNames"===e)return t.objectStoreNames||E.get(t);if("store"===e)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return M(t[e])},set:(t,e,n)=>(t[e]=n,!0),has:(t,e)=>t instanceof IDBTransaction&&("done"===e||"store"===e)||e in t};function T(t){return t!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(_||(_=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(D(this),e),M(y.get(this))}:function(...e){return M(t.apply(D(this),e))}:function(e,...n){const s=t.call(D(this),e,...n);return E.set(s,e.sort?e.sort():[e]),M(s)}}function L(t){return"function"==typeof t?T(t):(t instanceof IDBTransaction&&function(t){if(b.has(t))return;const e=new Promise(((e,n)=>{const s=()=>{t.removeEventListener("complete",r),t.removeEventListener("error",a),t.removeEventListener("abort",a)},r=()=>{e(),s()},a=()=>{n(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",r),t.addEventListener("error",a),t.addEventListener("abort",a)}));b.set(t,e)}(t),e=t,(v||(v=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some((t=>e instanceof t))?new Proxy(t,C):t);var e}function M(t){if(t instanceof IDBRequest)return function(t){const e=new Promise(((e,n)=>{const s=()=>{t.removeEventListener("success",r),t.removeEventListener("error",a)},r=()=>{e(M(t.result)),s()},a=()=>{n(t.error),s()};t.addEventListener("success",r),t.addEventListener("error",a)}));return e.then((e=>{e instanceof IDBCursor&&y.set(e,t)})).catch((()=>{})),I.set(e,t),e}(t);if(S.has(t))return S.get(t);const e=L(t);return e!==t&&(S.set(t,e),I.set(e,t)),e}const D=t=>I.get(t);const k=["get","getKey","getAll","getAllKeys","count"],F=["put","add","delete","clear"],P=new Map;function O(t,e){if(!(t instanceof IDBDatabase)||e in t||"string"!=typeof e)return;if(P.get(e))return P.get(e);const n=e.replace(/FromIndex$/,""),s=e!==n,r=F.includes(n);if(!(n in(s?IDBIndex:IDBObjectStore).prototype)||!r&&!k.includes(n))return;const a=async function(t,...e){const a=this.transaction(t,r?"readwrite":"readonly");let i=a.store;return s&&(i=i.index(e.shift())),(await Promise.all([i[n](...e),r&&a.done]))[0]};return P.set(e,a),a}C=(t=>({...t,get:(e,n,s)=>O(e,n)||t.get(e,n,s),has:(e,n)=>!!O(e,n)||t.has(e,n)}))(C);const N="@firebase/installations",j=new o("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function R(t){return t instanceof i&&t.code.includes("request-failed")}function A({projectId:t}){return`https://firebaseinstallations.googleapis.com/v1/projects/${t}/installations`}function B(t){return{token:t.token,requestStatus:2,expiresIn:(e=t.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()};var e}async function $(t,e){const n=(await e.json()).error;return j.create("request-failed",{requestName:t,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function H({apiKey:t}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":t})}function x(t,{refreshToken:e}){const n=H(t);return n.append("Authorization",function(t){return`FIS_v2 ${t}`}(e)),n}async function q(t){const e=await t();return e.status>=500&&e.status<600?t():e}function K(t){return new Promise((e=>{setTimeout(e,t)}))}const U=/^[cdef][\w-]{21}$/;function V(){try{const t=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(t),t[0]=112+t[0]%16;const e=function(t){return(e=t,btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_")).substr(0,22);var e}(t);return U.test(e)?e:""}catch(t){return""}}function z(t){return`${t.appName}!${t.appId}`}const G=new Map;function W(t,e){const n=z(t);J(n,e),function(t,e){const n=function(){!Y&&"BroadcastChannel"in self&&(Y=new BroadcastChannel("[Firebase] FID Change"),Y.onmessage=t=>{J(t.data.key,t.data.fid)});return Y}();n&&n.postMessage({key:t,fid:e});0===G.size&&Y&&(Y.close(),Y=null)}(n,e)}function J(t,e){const n=G.get(t);if(n)for(const t of n)t(e)}let Y=null;const Z="firebase-installations-store";let Q=null;function X(){return Q||(Q=function(t,e,{blocked:n,upgrade:s,blocking:r,terminated:a}={}){const i=indexedDB.open(t,e),o=M(i);return s&&i.addEventListener("upgradeneeded",(t=>{s(M(i.result),t.oldVersion,t.newVersion,M(i.transaction))})),n&&i.addEventListener("blocked",(()=>n())),o.then((t=>{a&&t.addEventListener("close",(()=>a())),r&&t.addEventListener("versionchange",(()=>r()))})).catch((()=>{})),o}("firebase-installations-database",1,{upgrade:(t,e)=>{if(0===e)t.createObjectStore(Z)}})),Q}async function tt(t,e){const n=z(t),s=(await X()).transaction(Z,"readwrite"),r=s.objectStore(Z),a=await r.get(n);return await r.put(e,n),await s.done,a&&a.fid===e.fid||W(t,e.fid),e}async function et(t){const e=z(t),n=(await X()).transaction(Z,"readwrite");await n.objectStore(Z).delete(e),await n.done}async function nt(t,e){const n=z(t),s=(await X()).transaction(Z,"readwrite"),r=s.objectStore(Z),a=await r.get(n),i=e(a);return void 0===i?await r.delete(n):await r.put(i,n),await s.done,!i||a&&a.fid===i.fid||W(t,i.fid),i}async function st(t){let e;const n=await nt(t.appConfig,(n=>{const s=function(t){return it(t||{fid:V(),registrationStatus:0})}(n),r=function(t,e){if(0===e.registrationStatus){if(!navigator.onLine){return{installationEntry:e,registrationPromise:Promise.reject(j.create("app-offline"))}}const n={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},s=async function(t,e){try{const n=await async function({appConfig:t,heartbeatServiceProvider:e},{fid:n}){const s=A(t),r=H(t),a=e.getImmediate({optional:!0});if(a){const t=await a.getHeartbeatsHeader();t&&r.append("x-firebase-client",t)}const i={fid:n,authVersion:"FIS_v2",appId:t.appId,sdkVersion:"w:0.6.4"},o={method:"POST",headers:r,body:JSON.stringify(i)},c=await q((()=>fetch(s,o)));if(c.ok){const t=await c.json();return{fid:t.fid||n,registrationStatus:2,refreshToken:t.refreshToken,authToken:B(t.authToken)}}throw await $("Create Installation",c)}(t,e);return tt(t.appConfig,n)}catch(n){throw R(n)&&409===n.customData.serverCode?await et(t.appConfig):await tt(t.appConfig,{fid:e.fid,registrationStatus:0}),n}}(t,n);return{installationEntry:n,registrationPromise:s}}return 1===e.registrationStatus?{installationEntry:e,registrationPromise:rt(t)}:{installationEntry:e}}(t,s);return e=r.registrationPromise,r.installationEntry}));return""===n.fid?{installationEntry:await e}:{installationEntry:n,registrationPromise:e}}async function rt(t){let e=await at(t.appConfig);for(;1===e.registrationStatus;)await K(100),e=await at(t.appConfig);if(0===e.registrationStatus){const{installationEntry:e,registrationPromise:n}=await st(t);return n||e}return e}function at(t){return nt(t,(t=>{if(!t)throw j.create("installation-not-found");return it(t)}))}function it(t){return 1===(e=t).registrationStatus&&e.registrationTime+1e4<Date.now()?{fid:t.fid,registrationStatus:0}:t;var e}async function ot({appConfig:t,heartbeatServiceProvider:e},n){const s=function(t,{fid:e}){return`${A(t)}/${e}/authTokens:generate`}(t,n),r=x(t,n),a=e.getImmediate({optional:!0});if(a){const t=await a.getHeartbeatsHeader();t&&r.append("x-firebase-client",t)}const i={installation:{sdkVersion:"w:0.6.4",appId:t.appId}},o={method:"POST",headers:r,body:JSON.stringify(i)},c=await q((()=>fetch(s,o)));if(c.ok){return B(await c.json())}throw await $("Generate Auth Token",c)}async function ct(t,e=!1){let n;const s=await nt(t.appConfig,(s=>{if(!lt(s))throw j.create("not-registered");const r=s.authToken;if(!e&&function(t){return 2===t.requestStatus&&!function(t){const e=Date.now();return e<t.creationTime||t.creationTime+t.expiresIn<e+36e5}(t)}(r))return s;if(1===r.requestStatus)return n=async function(t,e){let n=await ut(t.appConfig);for(;1===n.authToken.requestStatus;)await K(100),n=await ut(t.appConfig);const s=n.authToken;return 0===s.requestStatus?ct(t,e):s}(t,e),s;{if(!navigator.onLine)throw j.create("app-offline");const e=function(t){const e={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},t),{authToken:e})}(s);return n=async function(t,e){try{const n=await ot(t,e),s=Object.assign(Object.assign({},e),{authToken:n});return await tt(t.appConfig,s),n}catch(n){if(!R(n)||401!==n.customData.serverCode&&404!==n.customData.serverCode){const n=Object.assign(Object.assign({},e),{authToken:{requestStatus:0}});await tt(t.appConfig,n)}else await et(t.appConfig);throw n}}(t,e),e}}));return n?await n:s.authToken}function ut(t){return nt(t,(t=>{if(!lt(t))throw j.create("not-registered");const e=t.authToken;return 1===(n=e).requestStatus&&n.requestTime+1e4<Date.now()?Object.assign(Object.assign({},t),{authToken:{requestStatus:0}}):t;var n}))}function lt(t){return void 0!==t&&2===t.registrationStatus}async function gt(t,e=!1){const n=t;await async function(t){const{registrationPromise:e}=await st(t);e&&await e}(n);return(await ct(n,e)).token}function ht(t){return j.create("missing-app-config-values",{valueName:t})}const ft=t=>{const e=t.getProvider("app").getImmediate(),s=n(e,"installations").getImmediate();return{getId:()=>async function(t){const e=t,{installationEntry:n,registrationPromise:s}=await st(e);return s?s.catch(console.error):ct(e).catch(console.error),n.fid}(s),getToken:t=>gt(s,t)}};e(new g("installations",(t=>{const e=t.getProvider("app").getImmediate(),s=function(t){if(!t||!t.options)throw ht("App Configuration");if(!t.name)throw ht("App Name");const e=["projectId","apiKey","appId"];for(const n of e)if(!t.options[n])throw ht(n);return{appName:t.name,projectId:t.options.projectId,apiKey:t.options.apiKey,appId:t.options.appId}}(e);return{app:e,appConfig:s,heartbeatServiceProvider:n(e,"heartbeat"),_delete:()=>Promise.resolve()}}),"PUBLIC")),e(new g("installations-internal",ft,"PRIVATE")),t(N,"0.6.4"),t(N,"0.6.4","esm2017");const dt="@firebase/remote-config";class pt{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}abort(){this.listeners.forEach((t=>t()))}}const mt=new o("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 wt=["1","true","t","yes","y","on"];class vt{constructor(t,e=""){this._source=t,this._value=e}asString(){return this._value}asBoolean(){return"static"!==this._source&&wt.indexOf(this._value.toLowerCase())>=0}asNumber(){if("static"===this._source)return 0;let t=Number(this._value);return isNaN(t)&&(t=0),t}getSource(){return this._source}}function _t(t=s()){t=l(t);return n(t,"remote-config").getImmediate()}async function yt(t){const e=l(t),[n,s]=await Promise.all([e._storage.getLastSuccessfulFetchResponse(),e._storage.getActiveConfigEtag()]);return!!(n&&n.config&&n.eTag&&n.eTag!==s)&&(await Promise.all([e._storageCache.setActiveConfig(n.config),e._storage.setActiveConfigEtag(n.eTag)]),!0)}function bt(t){const e=l(t);return e._initializePromise||(e._initializePromise=e._storageCache.loadFromStorage().then((()=>{e._isInitializationComplete=!0}))),e._initializePromise}async function Et(t){const e=l(t),n=new pt;setTimeout((async()=>{n.abort()}),e.settings.fetchTimeoutMillis);try{await e._client.fetch({cacheMaxAgeMillis:e.settings.minimumFetchIntervalMillis,signal:n}),await e._storageCache.setLastFetchStatus("success")}catch(t){const n=function(t,e){return t instanceof i&&-1!==t.code.indexOf(e)}(t,"fetch-throttle")?"throttle":"failure";throw await e._storageCache.setLastFetchStatus(n),t}}function St(t){const e=l(t);return function(t={},e={}){return Object.keys(Object.assign(Object.assign({},t),e))}(e._storageCache.getActiveConfig(),e.defaultConfig).reduce(((e,n)=>(e[n]=Lt(t,n),e)),{})}function It(t,e){return Lt(l(t),e).asBoolean()}function Ct(t,e){return Lt(l(t),e).asNumber()}function Tt(t,e){return Lt(l(t),e).asString()}function Lt(t,e){const n=l(t);n._isInitializationComplete||n._logger.debug(`A value was requested for key "${e}" before SDK initialization completed. Await on ensureInitialized if the intent was to get a previously activated value.`);const s=n._storageCache.getActiveConfig();return s&&void 0!==s[e]?new vt("remote",s[e]):n.defaultConfig&&void 0!==n.defaultConfig[e]?new vt("default",String(n.defaultConfig[e])):(n._logger.debug(`Returning static value for key "${e}". Define a default or remote value if this is unintentional.`),new vt("static"))}function Mt(t,e){const n=l(t);switch(e){case"debug":n._logger.logLevel=h.DEBUG;break;case"silent":n._logger.logLevel=h.SILENT;break;default:n._logger.logLevel=h.ERROR}}class Dt{constructor(t,e,n,s){this.client=t,this.storage=e,this.storageCache=n,this.logger=s}isCachedDataFresh(t,e){if(!e)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;const n=Date.now()-e,s=n<=t;return this.logger.debug(`Config fetch cache check. Cache age millis: ${n}. Cache max age millis (minimumFetchIntervalMillis setting): ${t}. Is cache hit: ${s}.`),s}async fetch(t){const[e,n]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(n&&this.isCachedDataFresh(t.cacheMaxAgeMillis,e))return n;t.eTag=n&&n.eTag;const s=await this.client.fetch(t),r=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===s.status&&r.push(this.storage.setLastSuccessfulFetchResponse(s)),await Promise.all(r),s}}function kt(t=navigator){return t.languages&&t.languages[0]||t.language}class Ft{constructor(t,e,n,s,r,a){this.firebaseInstallations=t,this.sdkVersion=e,this.namespace=n,this.projectId=s,this.apiKey=r,this.appId=a}async fetch(t){const[e,n]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),s=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,r={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":t.eTag||"*"},a={sdk_version:this.sdkVersion,app_instance_id:e,app_instance_id_token:n,app_id:this.appId,language_code:kt()},i={method:"POST",headers:r,body:JSON.stringify(a)},o=fetch(s,i),c=new Promise(((e,n)=>{t.signal.addEventListener((()=>{const t=new Error("The operation was aborted.");t.name="AbortError",n(t)}))}));let u;try{await Promise.race([o,c]),u=await o}catch(t){let e="fetch-client-network";throw"AbortError"===(null==t?void 0:t.name)&&(e="fetch-timeout"),mt.create(e,{originalErrorMessage:null==t?void 0:t.message})}let l=u.status;const g=u.headers.get("ETag")||void 0;let h,f;if(200===u.status){let t;try{t=await u.json()}catch(t){throw mt.create("fetch-client-parse",{originalErrorMessage:null==t?void 0:t.message})}h=t.entries,f=t.state}if("INSTANCE_STATE_UNSPECIFIED"===f?l=500:"NO_CHANGE"===f?l=304:"NO_TEMPLATE"!==f&&"EMPTY_CONFIG"!==f||(h={}),304!==l&&200!==l)throw mt.create("fetch-status",{httpStatus:l});return{status:l,eTag:g,config:h}}}class Pt{constructor(t,e){this.client=t,this.storage=e}async fetch(t){const e=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(t,e)}async attemptFetch(t,{throttleEndTimeMillis:e,backoffCount:n}){await function(t,e){return new Promise(((n,s)=>{const r=Math.max(e-Date.now(),0),a=setTimeout(n,r);t.addEventListener((()=>{clearTimeout(a),s(mt.create("fetch-throttle",{throttleEndTimeMillis:e}))}))}))}(t.signal,e);try{const e=await this.client.fetch(t);return await this.storage.deleteThrottleMetadata(),e}catch(e){if(!function(t){if(!(t instanceof i&&t.customData))return!1;const e=Number(t.customData.httpStatus);return 429===e||500===e||503===e||504===e}(e))throw e;const s={throttleEndTimeMillis:Date.now()+u(n),backoffCount:n+1};return await this.storage.setThrottleMetadata(s),this.attemptFetch(t,s)}}}class Ot{constructor(t,e,n,s,r){this.app=t,this._client=e,this._storageCache=n,this._storage=s,this._logger=r,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 Nt(t,e){const n=t.target.error||void 0;return mt.create(e,{originalErrorMessage:n&&(null==n?void 0:n.message)})}class jt{constructor(t,e,n,s=function(){return new Promise(((t,e)=>{try{const n=indexedDB.open("firebase_remote_config",1);n.onerror=t=>{e(Nt(t,"storage-open"))},n.onsuccess=e=>{t(e.target.result)},n.onupgradeneeded=t=>{const e=t.target.result;0===t.oldVersion&&e.createObjectStore("app_namespace_store",{keyPath:"compositeKey"})}}catch(t){e(mt.create("storage-open",{originalErrorMessage:null==t?void 0:t.message}))}}))}()){this.appId=t,this.appName=e,this.namespace=n,this.openDbPromise=s}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(t){return this.set("last_fetch_status",t)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(t){return this.set("last_successful_fetch_timestamp_millis",t)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(t){return this.set("last_successful_fetch_response",t)}getActiveConfig(){return this.get("active_config")}setActiveConfig(t){return this.set("active_config",t)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(t){return this.set("active_config_etag",t)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(t){return this.set("throttle_metadata",t)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(t){const e=await this.openDbPromise;return new Promise(((n,s)=>{const r=e.transaction(["app_namespace_store"],"readonly").objectStore("app_namespace_store"),a=this.createCompositeKey(t);try{const t=r.get(a);t.onerror=t=>{s(Nt(t,"storage-get"))},t.onsuccess=t=>{const e=t.target.result;n(e?e.value:void 0)}}catch(t){s(mt.create("storage-get",{originalErrorMessage:null==t?void 0:t.message}))}}))}async set(t,e){const n=await this.openDbPromise;return new Promise(((s,r)=>{const a=n.transaction(["app_namespace_store"],"readwrite").objectStore("app_namespace_store"),i=this.createCompositeKey(t);try{const t=a.put({compositeKey:i,value:e});t.onerror=t=>{r(Nt(t,"storage-set"))},t.onsuccess=()=>{s()}}catch(t){r(mt.create("storage-set",{originalErrorMessage:null==t?void 0:t.message}))}}))}async delete(t){const e=await this.openDbPromise;return new Promise(((n,s)=>{const r=e.transaction(["app_namespace_store"],"readwrite").objectStore("app_namespace_store"),a=this.createCompositeKey(t);try{const t=r.delete(a);t.onerror=t=>{s(Nt(t,"storage-delete"))},t.onsuccess=()=>{n()}}catch(t){s(mt.create("storage-delete",{originalErrorMessage:null==t?void 0:t.message}))}}))}createCompositeKey(t){return[this.appId,this.appName,this.namespace,t].join()}}class Rt{constructor(t){this.storage=t}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){const t=this.storage.getLastFetchStatus(),e=this.storage.getLastSuccessfulFetchTimestampMillis(),n=this.storage.getActiveConfig(),s=await t;s&&(this.lastFetchStatus=s);const r=await e;r&&(this.lastSuccessfulFetchTimestampMillis=r);const a=await n;a&&(this.activeConfig=a)}setLastFetchStatus(t){return this.lastFetchStatus=t,this.storage.setLastFetchStatus(t)}setLastSuccessfulFetchTimestampMillis(t){return this.lastSuccessfulFetchTimestampMillis=t,this.storage.setLastSuccessfulFetchTimestampMillis(t)}setActiveConfig(t){return this.activeConfig=t,this.storage.setActiveConfig(t)}}async function At(t){return t=l(t),await Et(t),yt(t)}async function Bt(){if(!a())return!1;try{return await new Promise(((t,e)=>{try{let n=!0;const s="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(s);r.onsuccess=()=>{r.result.close(),n||self.indexedDB.deleteDatabase(s),t(!0)},r.onupgradeneeded=()=>{n=!1},r.onerror=()=>{var t;e((null===(t=r.error)||void 0===t?void 0:t.message)||"")}}catch(t){e(t)}}))}catch(t){return!1}}e(new g("remote-config",(function(t,{instanceIdentifier:e}){const n=t.getProvider("app").getImmediate(),s=t.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw mt.create("registration-window");if(!a())throw mt.create("indexed-db-unavailable");const{projectId:i,apiKey:o,appId:c}=n.options;if(!i)throw mt.create("registration-project-id");if(!o)throw mt.create("registration-api-key");if(!c)throw mt.create("registration-app-id");e=e||"firebase";const u=new jt(c,n.name,e),l=new Rt(u),g=new w(dt);g.logLevel=h.ERROR;const f=new Ft(s,r,e,i,o,c),d=new Pt(f,u),p=new Dt(d,u,l,g),m=new Ot(n,p,l,u,g);return bt(m),m}),"PUBLIC").setMultipleInstances(!0)),t(dt,"0.4.4"),t(dt,"0.4.4","esm2017");export{yt as activate,bt as ensureInitialized,At as fetchAndActivate,Et as fetchConfig,St as getAll,It as getBoolean,Ct as getNumber,_t as getRemoteConfig,Tt as getString,Lt as getValue,Bt as isSupported,Mt as setLogLevel};
2
2
 
3
3
  //# sourceMappingURL=firebase-remote-config.js.map
@@ -1,3 +1,3 @@
1
- import{_getProvider as e,getApp as t,_registerComponent as n,registerVersion as r,SDK_VERSION as s}from"https://www.gstatic.com/firebasejs/9.17.2/firebase-app.js";const o=function(e){const t=[];let n=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);s<128?t[n++]=s:s<2048?(t[n++]=s>>6|192,t[n++]=63&s|128):55296==(64512&s)&&r+1<e.length&&56320==(64512&e.charCodeAt(r+1))?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++r)),t[n++]=s>>18|240,t[n++]=s>>12&63|128,t[n++]=s>>6&63|128,t[n++]=63&s|128):(t[n++]=s>>12|224,t[n++]=s>>6&63|128,t[n++]=63&s|128)}return t},i={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(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let t=0;t<e.length;t+=3){const s=e[t],o=t+1<e.length,i=o?e[t+1]:0,a=t+2<e.length,c=a?e[t+2]:0,u=s>>2,h=(3&s)<<4|i>>4;let l=(15&i)<<2|c>>6,_=63&c;a||(_=64,o||(l=64)),r.push(n[u],n[h],n[l],n[_])}return r.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 n=0,r=0;for(;n<e.length;){const s=e[n++];if(s<128)t[r++]=String.fromCharCode(s);else if(s>191&&s<224){const o=e[n++];t[r++]=String.fromCharCode((31&s)<<6|63&o)}else if(s>239&&s<365){const o=((7&s)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(o>>10)),t[r++]=String.fromCharCode(56320+(1023&o))}else{const o=e[n++],i=e[n++];t[r++]=String.fromCharCode((15&s)<<12|(63&o)<<6|63&i)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let t=0;t<e.length;){const s=n[e.charAt(t++)],o=t<e.length?n[e.charAt(t)]:0;++t;const i=t<e.length?n[e.charAt(t)]:64;++t;const c=t<e.length?n[e.charAt(t)]:64;if(++t,null==s||null==o||null==i||null==c)throw new a;const u=s<<2|o>>4;if(r.push(u),64!==i){const e=o<<4&240|i>>2;if(r.push(e),64!==c){const e=i<<6&192|c;r.push(e)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class a extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const c=function(e){return function(e){const t=o(e);return i.encodeByteArray(t,!0)}(e).replace(/\./g,"")};const u=()=>function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__,h=()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&function(e){try{return i.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null}(e[1]);return t&&JSON.parse(t)},l=()=>{try{return u()||(()=>{if("undefined"==typeof process||void 0===process.env)return;const e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||h()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},_=e=>{const t=(e=>{var t,n;return null===(n=null===(t=l())||void 0===t?void 0:t.emulatorHosts)||void 0===n?void 0:n[e]})(e);if(!t)return;const n=t.lastIndexOf(":");if(n<=0||n+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const r=parseInt(t.substring(n+1),10);return"["===t[0]?[t.substring(1,n-1),r]:[t.substring(0,n),r]};class d extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,d.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,p.prototype.create)}}class p{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){const n=t[0]||{},r=`${this.service}/${e}`,s=this.errors[e],o=s?function(e,t){return e.replace(f,((e,n)=>{const r=t[n];return null!=r?String(r):`<${n}?>`}))}(s,n):"Error",i=`${this.serviceName}: ${o} (${r}).`;return new d(r,i,n)}}const f=/\{\$([^}]+)}/g;function g(e){return e&&e._delegate?e._delegate:e}class m{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}class b extends d{constructor(e,t,n=0){super(y(e),`Firebase Storage: ${t} (${y(e)})`),this.status_=n,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,b.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return y(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}}var T,E;function y(e){return"storage/"+e}function R(){return new b(T.UNKNOWN,"An unknown error occurred, please check the error payload for server response.")}function w(){return new b(T.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function v(){return new b(T.CANCELED,"User canceled the upload/download.")}function k(){return new b(T.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function A(e){return new b(T.INVALID_ARGUMENT,e)}function S(){return new b(T.APP_DELETED,"The Firebase app was deleted.")}function O(e){return new b(T.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 C(e,t){return new b(T.INVALID_FORMAT,"String does not match format '"+e+"': "+t)}function U(e){throw new b(T.INTERNAL_ERROR,"Internal error: "+e)}!function(e){e.UNKNOWN="unknown",e.OBJECT_NOT_FOUND="object-not-found",e.BUCKET_NOT_FOUND="bucket-not-found",e.PROJECT_NOT_FOUND="project-not-found",e.QUOTA_EXCEEDED="quota-exceeded",e.UNAUTHENTICATED="unauthenticated",e.UNAUTHORIZED="unauthorized",e.UNAUTHORIZED_APP="unauthorized-app",e.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",e.INVALID_CHECKSUM="invalid-checksum",e.CANCELED="canceled",e.INVALID_EVENT_NAME="invalid-event-name",e.INVALID_URL="invalid-url",e.INVALID_DEFAULT_BUCKET="invalid-default-bucket",e.NO_DEFAULT_BUCKET="no-default-bucket",e.CANNOT_SLICE_BLOB="cannot-slice-blob",e.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",e.NO_DOWNLOAD_URL="no-download-url",e.INVALID_ARGUMENT="invalid-argument",e.INVALID_ARGUMENT_COUNT="invalid-argument-count",e.APP_DELETED="app-deleted",e.INVALID_ROOT_OPERATION="invalid-root-operation",e.INVALID_FORMAT="invalid-format",e.INTERNAL_ERROR="internal-error",e.UNSUPPORTED_ENVIRONMENT="unsupported-environment"}(T||(T={}));class N{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(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let n;try{n=N.makeFromUrl(e,t)}catch(t){return new N(e,"")}if(""===n.path)return n;throw r=e,new b(T.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+r+"'.");var r}static makeFromUrl(e,t){let n=null;const r="([A-Za-z0-9.\\-_]+)";const s=new RegExp("^gs://"+r+"(/(.*))?$","i");function o(e){e.path_=decodeURIComponent(e.path)}const i=t.replace(/[.]/g,"\\."),a=[{regex:s,indices:{bucket:1,path:3},postModify:function(e){"/"===e.path.charAt(e.path.length-1)&&(e.path_=e.path_.slice(0,-1))}},{regex:new RegExp(`^https?://${i}/v[A-Za-z0-9_]+/b/${r}/o(/([^?#]*).*)?$`,"i"),indices:{bucket:1,path:3},postModify:o},{regex:new RegExp(`^https?://${"firebasestorage.googleapis.com"===t?"(?:storage.googleapis.com|storage.cloud.google.com)":t}/${r}/([^?#]*)`,"i"),indices:{bucket:1,path:2},postModify:o}];for(let t=0;t<a.length;t++){const r=a[t],s=r.regex.exec(e);if(s){const e=s[r.indices.bucket];let t=s[r.indices.path];t||(t=""),n=new N(e,t),r.postModify(n);break}}if(null==n)throw function(e){return new b(T.INVALID_URL,"Invalid URL '"+e+"'.")}(e);return n}}class I{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}function x(e){return"string"==typeof e||e instanceof String}function D(e){return P()&&e instanceof Blob}function P(){return"undefined"!=typeof Blob&&!function(){var e;const t=null===(e=l())||void 0===e?void 0:e.forceEnvironment;if("node"===t)return!0;if("browser"===t)return!1;try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}()}function L(e,t,n,r){if(r<t)throw A(`Invalid value for '${e}'. Expected ${t} or greater.`);if(r>n)throw A(`Invalid value for '${e}'. Expected ${n} or less.`)}function B(e,t,n){let r=t;return null==n&&(r=`https://${t}`),`${n}://${r}/v0${e}`}function M(e){const t=encodeURIComponent;let n="?";for(const r in e)if(e.hasOwnProperty(r)){n=n+(t(r)+"="+t(e[r]))+"&"}return n=n.slice(0,-1),n}function F(e,t){const n=e>=500&&e<600,r=-1!==[408,429].indexOf(e),s=-1!==t.indexOf(e);return n||r||s}!function(e){e[e.NO_ERROR=0]="NO_ERROR",e[e.NETWORK_ERROR=1]="NETWORK_ERROR",e[e.ABORT=2]="ABORT"}(E||(E={}));class q{constructor(e,t,n,r,s,o,i,a,c,u,h,l=!0){this.url_=e,this.method_=t,this.headers_=n,this.body_=r,this.successCodes_=s,this.additionalRetryCodes_=o,this.callback_=i,this.errorCallback_=a,this.timeout_=c,this.progressCallback_=u,this.connectionFactory_=h,this.retry=l,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_(){const e=(e,t)=>{if(t)return void e(!1,new H(!1,null,!0));const n=this.connectionFactory_();this.pendingConnection_=n;const r=e=>{const t=e.loaded,n=e.lengthComputable?e.total:-1;null!==this.progressCallback_&&this.progressCallback_(t,n)};null!==this.progressCallback_&&n.addUploadProgressListener(r),n.send(this.url_,this.method_,this.body_,this.headers_).then((()=>{null!==this.progressCallback_&&n.removeUploadProgressListener(r),this.pendingConnection_=null;const t=n.getErrorCode()===E.NO_ERROR,s=n.getStatus();if(!t||F(s,this.additionalRetryCodes_)&&this.retry){const t=n.getErrorCode()===E.ABORT;return void e(!1,new H(!1,null,t))}const o=-1!==this.successCodes_.indexOf(s);e(!0,new H(o,n))}))},t=(e,t)=>{const n=this.resolve_,r=this.reject_,s=t.connection;if(t.wasSuccessCode)try{const e=this.callback_(s,s.getResponse());void 0!==e?n(e):n()}catch(e){r(e)}else if(null!==s){const e=R();e.serverResponse=s.getErrorText(),this.errorCallback_?r(this.errorCallback_(s,e)):r(e)}else if(t.canceled){r(this.appDelete_?S():v())}else{r(w())}};this.canceled_?t(0,new H(!1,null,!0)):this.backoffId_=function(e,t,n){let r=1,s=null,o=null,i=!1,a=0;function c(){return 2===a}let u=!1;function h(...e){u||(u=!0,t.apply(null,e))}function l(t){s=setTimeout((()=>{s=null,e(d,c())}),t)}function _(){o&&clearTimeout(o)}function d(e,...t){if(u)return void _();if(e)return _(),void h.call(null,e,...t);if(c()||i)return _(),void h.call(null,e,...t);let n;r<64&&(r*=2),1===a?(a=2,n=0):n=1e3*(r+Math.random()),l(n)}let p=!1;function f(e){p||(p=!0,_(),u||(null!==s?(e||(a=2),clearTimeout(s),l(0)):e||(a=1)))}return l(0),o=setTimeout((()=>{i=!0,f(!0)}),n),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 H{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}}function V(){return"undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0}function W(...e){const t=V();if(void 0!==t){const n=new t;for(let t=0;t<e.length;t++)n.append(e[t]);return n.getBlob()}if(P())return new Blob(e);throw new b(T.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}function j(e){if("undefined"==typeof atob)throw t="base-64",new b(T.UNSUPPORTED_ENVIRONMENT,`${t} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`);var t;return atob(e)}const $={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class z{constructor(e,t){this.data=e,this.contentType=t||null}}function G(e,t){switch(e){case $.RAW:return new z(X(t));case $.BASE64:case $.BASE64URL:return new z(K(e,t));case $.DATA_URL:return new z(function(e){const t=new J(e);return t.base64?K($.BASE64,t.rest):function(e){let t;try{t=decodeURIComponent(e)}catch(e){throw C($.DATA_URL,"Malformed data URL.")}return X(t)}(t.rest)}(t),new J(t).contentType)}throw R()}function X(e){const t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<=127)t.push(r);else if(r<=2047)t.push(192|r>>6,128|63&r);else if(55296==(64512&r)){if(n<e.length-1&&56320==(64512&e.charCodeAt(n+1))){r=65536|(1023&r)<<10|1023&e.charCodeAt(++n),t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r)}else t.push(239,191,189)}else 56320==(64512&r)?t.push(239,191,189):t.push(224|r>>12,128|r>>6&63,128|63&r)}return new Uint8Array(t)}function K(e,t){switch(e){case $.BASE64:{const n=-1!==t.indexOf("-"),r=-1!==t.indexOf("_");if(n||r){throw C(e,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?")}break}case $.BASE64URL:{const n=-1!==t.indexOf("+"),r=-1!==t.indexOf("/");if(n||r){throw C(e,"Invalid character '"+(n?"+":"/")+"' found: is it base64 encoded?")}t=t.replace(/-/g,"+").replace(/_/g,"/");break}}let n;try{n=j(t)}catch(t){if(t.message.includes("polyfill"))throw t;throw C(e,"Invalid character found")}const r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}class J{constructor(e){this.base64=!1,this.contentType=null;const t=e.match(/^data:([^,]+)?,/);if(null===t)throw C($.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const n=t[1]||null;null!=n&&(this.base64=function(e,t){if(!(e.length>=t.length))return!1;return e.substring(e.length-t.length)===t}(n,";base64"),this.contentType=this.base64?n.substring(0,n.length-";base64".length):n),this.rest=e.substring(e.indexOf(",")+1)}}class Z{constructor(e,t){let n=0,r="";D(e)?(this.data_=e,n=e.size,r=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),n=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),n=e.length),this.size_=n,this.type_=r}size(){return this.size_}type(){return this.type_}slice(e,t){if(D(this.data_)){const n=function(e,t,n){return e.webkitSlice?e.webkitSlice(t,n):e.mozSlice?e.mozSlice(t,n):e.slice?e.slice(t,n):null}(this.data_,e,t);return null===n?null:new Z(n)}{const n=new Uint8Array(this.data_.buffer,e,t-e);return new Z(n,!0)}}static getBlob(...e){if(P()){const t=e.map((e=>e instanceof Z?e.data_:e));return new Z(W.apply(null,t))}{const t=e.map((e=>x(e)?G($.RAW,e).data:e.data_));let n=0;t.forEach((e=>{n+=e.byteLength}));const r=new Uint8Array(n);let s=0;return t.forEach((e=>{for(let t=0;t<e.length;t++)r[s++]=e[t]})),new Z(r,!0)}}uploadData(){return this.data_}}function Y(e){let t;try{t=JSON.parse(e)}catch(e){return null}return"object"!=typeof(n=t)||Array.isArray(n)?null:t;var n}function Q(e){const t=e.lastIndexOf("/",e.length-2);return-1===t?e:e.slice(t+1)}function ee(e,t){return t}class te{constructor(e,t,n,r){this.server=e,this.local=t||e,this.writable=!!n,this.xform=r||ee}}let ne=null;function re(){if(ne)return ne;const e=[];e.push(new te("bucket")),e.push(new te("generation")),e.push(new te("metageneration")),e.push(new te("name","fullPath",!0));const t=new te("name");t.xform=function(e,t){return function(e){return!x(e)||e.length<2?e:Q(e)}(t)},e.push(t);const n=new te("size");return n.xform=function(e,t){return void 0!==t?Number(t):t},e.push(n),e.push(new te("timeCreated")),e.push(new te("updated")),e.push(new te("md5Hash",null,!0)),e.push(new te("cacheControl",null,!0)),e.push(new te("contentDisposition",null,!0)),e.push(new te("contentEncoding",null,!0)),e.push(new te("contentLanguage",null,!0)),e.push(new te("contentType",null,!0)),e.push(new te("metadata","customMetadata",!0)),ne=e,ne}function se(e,t,n){const r={type:"file"},s=n.length;for(let e=0;e<s;e++){const s=n[e];r[s.local]=s.xform(r,t[s.server])}return function(e,t){Object.defineProperty(e,"ref",{get:function(){const n=e.bucket,r=e.fullPath,s=new N(n,r);return t._makeStorageReference(s)}})}(r,e),r}function oe(e,t,n){const r=Y(t);if(null===r)return null;return se(e,r,n)}function ie(e,t){const n={},r=t.length;for(let s=0;s<r;s++){const r=t[s];r.writable&&(n[r.server]=e[r.local])}return JSON.stringify(n)}function ae(e,t,n){const r=Y(n);if(null===r)return null;return function(e,t,n){const r={prefixes:[],items:[],nextPageToken:n.nextPageToken};if(n.prefixes)for(const s of n.prefixes){const n=s.replace(/\/$/,""),o=e._makeStorageReference(new N(t,n));r.prefixes.push(o)}if(n.items)for(const s of n.items){const n=e._makeStorageReference(new N(t,s.name));r.items.push(n)}return r}(e,t,r)}class ce{constructor(e,t,n,r){this.url=e,this.method=t,this.handler=n,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}function ue(e){if(!e)throw R()}function he(e,t){return function(n,r){const s=oe(e,r,t);return ue(null!==s),s}}function le(e,t){return function(n,r){const s=oe(e,r,t);return ue(null!==s),function(e,t,n,r){const s=Y(t);if(null===s)return null;if(!x(s.downloadTokens))return null;const o=s.downloadTokens;if(0===o.length)return null;const i=encodeURIComponent;return o.split(",").map((t=>{const s=e.bucket,o=e.fullPath;return B("/b/"+i(s)+"/o/"+i(o),n,r)+M({alt:"media",token:t})}))[0]}(s,r,e.host,e._protocol)}}function _e(e){return function(t,n){let r;var s,o;return 401===t.getStatus()?r=t.getErrorText().includes("Firebase App Check token is invalid")?new b(T.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project."):new b(T.UNAUTHENTICATED,"User is not authenticated, please authenticate using Firebase Authentication and try again."):402===t.getStatus()?(o=e.bucket,r=new b(T.QUOTA_EXCEEDED,"Quota for bucket '"+o+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===t.getStatus()?(s=e.path,r=new b(T.UNAUTHORIZED,"User does not have permission to access '"+s+"'.")):r=n,r.status=t.getStatus(),r.serverResponse=n.serverResponse,r}}function de(e){const t=_e(e);return function(n,r){let s=t(n,r);var o;return 404===n.getStatus()&&(o=e.path,s=new b(T.OBJECT_NOT_FOUND,"Object '"+o+"' does not exist.")),s.serverResponse=r.serverResponse,s}}function pe(e,t,n){const r=B(t.fullServerUrl(),e.host,e._protocol),s=e.maxOperationRetryTime,o=new ce(r,"GET",he(e,n),s);return o.errorHandler=de(t),o}function fe(e,t,n,r,s){const o={};t.isRoot?o.prefix="":o.prefix=t.path+"/",n&&n.length>0&&(o.delimiter=n),r&&(o.pageToken=r),s&&(o.maxResults=s);const i=B(t.bucketOnlyServerUrl(),e.host,e._protocol),a=e.maxOperationRetryTime,c=new ce(i,"GET",function(e,t){return function(n,r){const s=ae(e,t,r);return ue(null!==s),s}}(e,t.bucket),a);return c.urlParams=o,c.errorHandler=_e(t),c}function ge(e,t,n){const r=B(t.fullServerUrl(),e.host,e._protocol)+"?alt=media",s=e.maxOperationRetryTime,o=new ce(r,"GET",((e,t)=>t),s);return o.errorHandler=de(t),void 0!==n&&(o.headers.Range=`bytes=0-${n}`,o.successCodes=[200,206]),o}function me(e,t,n){const r=Object.assign({},n);return r.fullPath=e.path,r.size=t.size(),r.contentType||(r.contentType=function(e,t){return e&&e.contentType||t&&t.type()||"application/octet-stream"}(null,t)),r}function be(e,t,n,r,s){const o=t.bucketOnlyServerUrl(),i={"X-Goog-Upload-Protocol":"multipart"};const a=function(){let e="";for(let t=0;t<2;t++)e+=Math.random().toString().slice(2);return e}();i["Content-Type"]="multipart/related; boundary="+a;const c=me(t,r,s),u="--"+a+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+ie(c,n)+"\r\n--"+a+"\r\nContent-Type: "+c.contentType+"\r\n\r\n",h="\r\n--"+a+"--",l=Z.getBlob(u,r,h);if(null===l)throw k();const _={name:c.fullPath},d=B(o,e.host,e._protocol),p=e.maxUploadRetryTime,f=new ce(d,"POST",he(e,n),p);return f.urlParams=_,f.headers=i,f.body=l.uploadData(),f.errorHandler=_e(t),f}class Te{constructor(e,t,n,r){this.current=e,this.total=t,this.finalized=!!n,this.metadata=r||null}}function Ee(e,t){let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Status")}catch(e){ue(!1)}return ue(!!n&&-1!==(t||["active"]).indexOf(n)),n}function ye(e,t,n,r,s,o,i,a){const c=new Te(0,0);if(i?(c.current=i.current,c.total=i.total):(c.current=0,c.total=r.size()),r.size()!==c.total)throw new b(T.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.");const u=c.total-c.current;let h=u;s>0&&(h=Math.min(h,s));const l=c.current,_=l+h;let d="";d=0===h?"finalize":u===h?"upload, finalize":"upload";const p={"X-Goog-Upload-Command":d,"X-Goog-Upload-Offset":`${c.current}`},f=r.slice(l,_);if(null===f)throw k();const g=t.maxUploadRetryTime,m=new ce(n,"POST",(function(e,n){const s=Ee(e,["active","final"]),i=c.current+h,a=r.size();let u;return u="final"===s?he(t,o)(e,n):null,new Te(i,a,"final"===s,u)}),g);return m.headers=p,m.body=f.uploadData(),m.progressCallback=a||null,m.errorHandler=_e(e),m}const Re={STATE_CHANGED:"state_changed"},we={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function ve(e){switch(e){case"running":case"pausing":case"canceling":return we.RUNNING;case"paused":return we.PAUSED;case"success":return we.SUCCESS;case"canceled":return we.CANCELED;default:return we.ERROR}}class ke{constructor(e,t,n){if("function"==typeof e||null!=t||null!=n)this.next=e,this.error=null!=t?t:void 0,this.complete=null!=n?n:void 0;else{const t=e;this.next=t.next,this.error=t.error,this.complete=t.complete}}}function Ae(e){return(...t)=>{Promise.resolve().then((()=>e(...t)))}}class Se{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=E.NO_ERROR,this.sendPromise_=new Promise((e=>{this.xhr_.addEventListener("abort",(()=>{this.errorCode_=E.ABORT,e()})),this.xhr_.addEventListener("error",(()=>{this.errorCode_=E.NETWORK_ERROR,e()})),this.xhr_.addEventListener("load",(()=>{e()}))}))}send(e,t,n,r){if(this.sent_)throw U("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(t,e,!0),void 0!==r)for(const e in r)r.hasOwnProperty(e)&&this.xhr_.setRequestHeader(e,r[e].toString());return void 0!==n?this.xhr_.send(n):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw U("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw U("cannot .getStatus() before sending");try{return this.xhr_.status}catch(e){return-1}}getResponse(){if(!this.sent_)throw U("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw U("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)}}class Oe extends Se{initXhr(){this.xhr_.responseType="text"}}function Ce(){return new Oe}class Ue extends Se{initXhr(){this.xhr_.responseType="arraybuffer"}}function Ne(){return new Ue}class Ie extends Se{initXhr(){this.xhr_.responseType="blob"}}function xe(){return new Ie}class De{constructor(e,t,n=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=n,this._mappings=re(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=e=>{if(this._request=void 0,this._chunkMultiplier=1,e._codeEquals(T.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{const t=this.isExponentialBackoffExpired();if(F(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(T.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 e=this._transferred;return t=>this._updateProgress(e+t)}_shouldDoResumable(e){return e.size()>262144}_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(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then((([t,n])=>{switch(this._state){case"running":e(t,n);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused")}}))}_createResumable(){this._resolveToken(((e,t)=>{const n=function(e,t,n,r,s){const o=t.bucketOnlyServerUrl(),i=me(t,r,s),a={name:i.fullPath},c=B(o,e.host,e._protocol),u={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${r.size()}`,"X-Goog-Upload-Header-Content-Type":i.contentType,"Content-Type":"application/json; charset=utf-8"},h=ie(i,n),l=e.maxUploadRetryTime,_=new ce(c,"POST",(function(e){let t;Ee(e);try{t=e.getResponseHeader("X-Goog-Upload-URL")}catch(e){ue(!1)}return ue(x(t)),t}),l);return _.urlParams=a,_.headers=u,_.body=h,_.errorHandler=_e(t),_}(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,Ce,e,t);this._request=r,r.getPromise().then((e=>{this._request=void 0,this._uploadUrl=e,this._needToFetchStatus=!1,this.completeTransitions_()}),this._errorHandler)}))}_fetchStatus(){const e=this._uploadUrl;this._resolveToken(((t,n)=>{const r=function(e,t,n,r){const s=e.maxUploadRetryTime,o=new ce(n,"POST",(function(e){const t=Ee(e,["active","final"]);let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Size-Received")}catch(e){ue(!1)}n||ue(!1);const s=Number(n);return ue(!isNaN(s)),new Te(s,r.size(),"final"===t)}),s);return o.headers={"X-Goog-Upload-Command":"query"},o.errorHandler=_e(t),o}(this._ref.storage,this._ref._location,e,this._blob),s=this._ref.storage._makeRequest(r,Ce,t,n);this._request=s,s.getPromise().then((e=>{e=e,this._request=void 0,this._updateProgress(e.current),this._needToFetchStatus=!1,e.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()}),this._errorHandler)}))}_continueUpload(){const e=262144*this._chunkMultiplier,t=new Te(this._transferred,this._blob.size()),n=this._uploadUrl;this._resolveToken(((r,s)=>{let o;try{o=ye(this._ref._location,this._ref.storage,n,this._blob,e,this._mappings,t,this._makeProgressCallback())}catch(e){return this._error=e,void this._transition("error")}const i=this._ref.storage._makeRequest(o,Ce,r,s,!1);this._request=i,i.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)=>{const n=pe(this._ref.storage,this._ref._location,this._mappings),r=this._ref.storage._makeRequest(n,Ce,e,t);this._request=r,r.getPromise().then((e=>{this._request=void 0,this._metadata=e,this._transition("success")}),this._metadataErrorHandler)}))}_oneShotUpload(){this._resolveToken(((e,t)=>{const n=be(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,Ce,e,t);this._request=r,r.getPromise().then((e=>{this._request=void 0,this._metadata=e,this._updateProgress(this._blob.size()),this._transition("success")}),this._errorHandler)}))}_updateProgress(e){const 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":const t="paused"===this._state;this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":case"error":case"success":this._state=e,this._notifyObservers();break;case"canceled":this._error=v(),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(){const e=ve(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,n,r){const s=new ke(t||void 0,n||void 0,r||void 0);return this._addObserver(s),()=>{this._removeObserver(s)}}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){const t=this._observers.indexOf(e);-1!==t&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise();this._observers.slice().forEach((e=>{this._notifyObserver(e)}))}_finishPromise(){if(void 0!==this._resolve){let e=!0;switch(ve(this._state)){case we.SUCCESS:Ae(this._resolve.bind(null,this.snapshot))();break;case we.CANCELED:case we.ERROR:Ae(this._reject.bind(null,this._error))();break;default:e=!1}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(ve(this._state)){case we.RUNNING:case we.PAUSED:e.next&&Ae(e.next.bind(e,this.snapshot))();break;case we.SUCCESS:e.complete&&Ae(e.complete.bind(e))();break;default:e.error&&Ae(e.error.bind(e,this._error))()}}resume(){const e="paused"===this._state||"pausing"===this._state;return e&&this._transition("running"),e}pause(){const e="running"===this._state;return e&&this._transition("pausing"),e}cancel(){const e="running"===this._state||"pausing"===this._state;return e&&this._transition("canceling"),e}}class Pe{constructor(e,t){this._service=e,this._location=t instanceof N?t:N.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new Pe(e,t)}get root(){const e=new N(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return Q(this._location.path)}get storage(){return this._service}get parent(){const e=function(e){if(0===e.length)return null;const t=e.lastIndexOf("/");return-1===t?"":e.slice(0,t)}(this._location.path);if(null===e)return null;const t=new N(this._location.bucket,e);return new Pe(this._service,t)}_throwIfRoot(e){if(""===this._location.path)throw O(e)}}function Le(e,t,n){e._throwIfRoot("uploadBytes");const r=be(e.storage,e._location,re(),new Z(t,!0),n);return e.storage.makeRequestWithTokens(r,Ce).then((t=>({metadata:t,ref:e})))}function Be(e){const t={prefixes:[],items:[]};return Me(e,t).then((()=>t))}async function Me(e,t,n){const r={pageToken:n},s=await Fe(e,r);t.prefixes.push(...s.prefixes),t.items.push(...s.items),null!=s.nextPageToken&&await Me(e,t,s.nextPageToken)}function Fe(e,t){null!=t&&"number"==typeof t.maxResults&&L("options.maxResults",1,1e3,t.maxResults);const n=t||{},r=fe(e.storage,e._location,"/",n.pageToken,n.maxResults);return e.storage.makeRequestWithTokens(r,Ce)}function qe(e,t){e._throwIfRoot("updateMetadata");const n=function(e,t,n,r){const s=B(t.fullServerUrl(),e.host,e._protocol),o=ie(n,r),i=e.maxOperationRetryTime,a=new ce(s,"PATCH",he(e,r),i);return a.headers={"Content-Type":"application/json; charset=utf-8"},a.body=o,a.errorHandler=de(t),a}(e.storage,e._location,t,re());return e.storage.makeRequestWithTokens(n,Ce)}function He(e){e._throwIfRoot("getDownloadURL");const t=function(e,t,n){const r=B(t.fullServerUrl(),e.host,e._protocol),s=e.maxOperationRetryTime,o=new ce(r,"GET",le(e,n),s);return o.errorHandler=de(t),o}(e.storage,e._location,re());return e.storage.makeRequestWithTokens(t,Ce).then((e=>{if(null===e)throw new b(T.NO_DOWNLOAD_URL,"The given file does not have any download URLs.");return e}))}function Ve(e){e._throwIfRoot("deleteObject");const t=function(e,t){const n=B(t.fullServerUrl(),e.host,e._protocol),r=e.maxOperationRetryTime,s=new ce(n,"DELETE",(function(e,t){}),r);return s.successCodes=[200,204],s.errorHandler=de(t),s}(e.storage,e._location);return e.storage.makeRequestWithTokens(t,Ce)}function We(e,t){const n=function(e,t){const n=t.split("/").filter((e=>e.length>0)).join("/");return 0===e.length?n:e+"/"+n}(e._location.path,t),r=new N(e._location.bucket,n);return new Pe(e.storage,r)}function je(e,t){if(e instanceof Xe){const n=e;if(null==n._bucket)throw new b(T.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the 'storageBucket' property when initializing the app?");const r=new Pe(n,n._bucket);return null!=t?je(r,t):r}return void 0!==t?We(e,t):e}function $e(e,t){if(t&&/^[A-Za-z]+:\/\//.test(t)){if(e instanceof Xe)return new Pe(e,t);throw A("To use ref(service, url), the first argument must be a Storage instance.")}return je(e,t)}function ze(e,t){const n=null==t?void 0:t.storageBucket;return null==n?null:N.makeFromBucketSpec(n,e)}function Ge(e,t,n,r={}){e.host=`${t}:${n}`,e._protocol="http";const{mockUserToken:s}=r;s&&(e._overrideAuthToken="string"==typeof s?s: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.');const n=t||"demo-project",r=e.iat||0,s=e.sub||e.user_id;if(!s)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:r,exp:r+3600,auth_time:r,sub:s,user_id:s,firebase:{sign_in_provider:"custom",identities:{}}},e);return[c(JSON.stringify({alg:"none",type:"JWT"})),c(JSON.stringify(o)),""].join(".")}(s,e.app.options.projectId))}class Xe{constructor(e,t,n,r,s){this.app=e,this._authProvider=t,this._appCheckProvider=n,this._url=r,this._firebaseVersion=s,this._bucket=null,this._host="firebasestorage.googleapis.com",this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=r?N.makeFromBucketSpec(r,this._host):ze(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,null!=this._url?this._bucket=N.makeFromBucketSpec(this._url,e):this._bucket=ze(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){L("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){L("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){const t=await e.getToken();if(null!==t)return t.accessToken}return null}async _getAppCheckToken(){const e=this._appCheckProvider.getImmediate({optional:!0});if(e){return(await e.getToken()).token}return null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach((e=>e.cancel())),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new Pe(this,e)}_makeRequest(e,t,n,r,s=!0){if(this._deleted)return new I(S());{const o=function(e,t,n,r,s,o,i=!0){const a=M(e.urlParams),c=e.url+a,u=Object.assign({},e.headers);return function(e,t){t&&(e["X-Firebase-GMPID"]=t)}(u,t),function(e,t){null!==t&&t.length>0&&(e.Authorization="Firebase "+t)}(u,n),function(e,t){e["X-Firebase-Storage-Version"]="webjs/"+(null!=t?t:"AppManager")}(u,o),function(e,t){null!==t&&(e["X-Firebase-AppCheck"]=t)}(u,r),new q(c,e.method,u,e.body,e.successCodes,e.additionalRetryCodes,e.handler,e.errorHandler,e.timeout,e.progressCallback,s,i)}(e,this._appId,n,r,t,this._firebaseVersion,s);return this._requests.add(o),o.getPromise().then((()=>this._requests.delete(o)),(()=>this._requests.delete(o))),o}}async makeRequestWithTokens(e,t){const[n,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,n,r).getPromise()}}const Ke="@firebase/storage";function Je(e,t){return function(e,t){e._throwIfRoot("getBytes");const n=ge(e.storage,e._location,t);return e.storage.makeRequestWithTokens(n,Ne).then((e=>void 0!==t?e.slice(0,t):e))}(e=g(e),t)}function Ze(e,t,n){return Le(e=g(e),t,n)}function Ye(e,t,n,r){return function(e,t,n=$.RAW,r){e._throwIfRoot("uploadString");const s=G(n,t),o=Object.assign({},r);return null==o.contentType&&null!=s.contentType&&(o.contentType=s.contentType),Le(e,s.data,o)}(e=g(e),t,n,r)}function Qe(e,t,n){return function(e,t,n){return e._throwIfRoot("uploadBytesResumable"),new De(e,new Z(t),n)}(e=g(e),t,n)}function et(e){return function(e){e._throwIfRoot("getMetadata");const t=pe(e.storage,e._location,re());return e.storage.makeRequestWithTokens(t,Ce)}(e=g(e))}function tt(e,t){return qe(e=g(e),t)}function nt(e,t){return Fe(e=g(e),t)}function rt(e){return Be(e=g(e))}function st(e){return He(e=g(e))}function ot(e){return Ve(e=g(e))}function it(e,t){return $e(e=g(e),t)}function at(e,t){return We(e,t)}function ct(n=t(),r){n=g(n);const s=e(n,"storage").getImmediate({identifier:r}),o=_("storage");return o&&ut(s,...o),s}function ut(e,t,n,r={}){Ge(e,t,n,r)}function ht(e,t){return function(e,t){e._throwIfRoot("getBlob");const n=ge(e.storage,e._location,t);return e.storage.makeRequestWithTokens(n,xe).then((e=>void 0!==t?e.slice(0,t):e))}(e=g(e),t)}function lt(e,t){throw new Error("getStream() is only supported by NodeJS builds")}function _t(e,{instanceIdentifier:t}){const n=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),o=e.getProvider("app-check-internal");return new Xe(n,r,o,t,s)}n(new m("storage",_t,"PUBLIC").setMultipleInstances(!0)),r(Ke,"0.11.2",""),r(Ke,"0.11.2","esm2017");export{b as StorageError,T as StorageErrorCode,$ as StringFormat,Z as _FbsBlob,N as _Location,Re as _TaskEvent,we as _TaskState,De as _UploadTask,G as _dataFromString,at as _getChild,A as _invalidArgument,O as _invalidRootOperation,ut as connectStorageEmulator,ot as deleteObject,ht as getBlob,Je as getBytes,st as getDownloadURL,et as getMetadata,ct as getStorage,lt as getStream,nt as list,rt as listAll,it as ref,tt as updateMetadata,Ze as uploadBytes,Qe as uploadBytesResumable,Ye as uploadString};
1
+ import{_getProvider as e,getApp as t,_registerComponent as n,registerVersion as r,SDK_VERSION as s}from"https://www.gstatic.com/firebasejs/9.18.0/firebase-app.js";const o=function(e){const t=[];let n=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);s<128?t[n++]=s:s<2048?(t[n++]=s>>6|192,t[n++]=63&s|128):55296==(64512&s)&&r+1<e.length&&56320==(64512&e.charCodeAt(r+1))?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++r)),t[n++]=s>>18|240,t[n++]=s>>12&63|128,t[n++]=s>>6&63|128,t[n++]=63&s|128):(t[n++]=s>>12|224,t[n++]=s>>6&63|128,t[n++]=63&s|128)}return t},i={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(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let t=0;t<e.length;t+=3){const s=e[t],o=t+1<e.length,i=o?e[t+1]:0,a=t+2<e.length,c=a?e[t+2]:0,u=s>>2,h=(3&s)<<4|i>>4;let l=(15&i)<<2|c>>6,_=63&c;a||(_=64,o||(l=64)),r.push(n[u],n[h],n[l],n[_])}return r.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 n=0,r=0;for(;n<e.length;){const s=e[n++];if(s<128)t[r++]=String.fromCharCode(s);else if(s>191&&s<224){const o=e[n++];t[r++]=String.fromCharCode((31&s)<<6|63&o)}else if(s>239&&s<365){const o=((7&s)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(o>>10)),t[r++]=String.fromCharCode(56320+(1023&o))}else{const o=e[n++],i=e[n++];t[r++]=String.fromCharCode((15&s)<<12|(63&o)<<6|63&i)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let t=0;t<e.length;){const s=n[e.charAt(t++)],o=t<e.length?n[e.charAt(t)]:0;++t;const i=t<e.length?n[e.charAt(t)]:64;++t;const c=t<e.length?n[e.charAt(t)]:64;if(++t,null==s||null==o||null==i||null==c)throw new a;const u=s<<2|o>>4;if(r.push(u),64!==i){const e=o<<4&240|i>>2;if(r.push(e),64!==c){const e=i<<6&192|c;r.push(e)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class a extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const c=function(e){return function(e){const t=o(e);return i.encodeByteArray(t,!0)}(e).replace(/\./g,"")};const u=()=>function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__,h=()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&function(e){try{return i.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null}(e[1]);return t&&JSON.parse(t)},l=()=>{try{return u()||(()=>{if("undefined"==typeof process||void 0===process.env)return;const e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||h()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},_=e=>{const t=(e=>{var t,n;return null===(n=null===(t=l())||void 0===t?void 0:t.emulatorHosts)||void 0===n?void 0:n[e]})(e);if(!t)return;const n=t.lastIndexOf(":");if(n<=0||n+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const r=parseInt(t.substring(n+1),10);return"["===t[0]?[t.substring(1,n-1),r]:[t.substring(0,n),r]};class d extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,d.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,p.prototype.create)}}class p{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){const n=t[0]||{},r=`${this.service}/${e}`,s=this.errors[e],o=s?function(e,t){return e.replace(f,((e,n)=>{const r=t[n];return null!=r?String(r):`<${n}?>`}))}(s,n):"Error",i=`${this.serviceName}: ${o} (${r}).`;return new d(r,i,n)}}const f=/\{\$([^}]+)}/g;function g(e){return e&&e._delegate?e._delegate:e}class m{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}class b extends d{constructor(e,t,n=0){super(y(e),`Firebase Storage: ${t} (${y(e)})`),this.status_=n,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,b.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return y(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}}var T,E;function y(e){return"storage/"+e}function R(){return new b(T.UNKNOWN,"An unknown error occurred, please check the error payload for server response.")}function w(){return new b(T.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function v(){return new b(T.CANCELED,"User canceled the upload/download.")}function k(){return new b(T.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function A(e){return new b(T.INVALID_ARGUMENT,e)}function S(){return new b(T.APP_DELETED,"The Firebase app was deleted.")}function O(e){return new b(T.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 C(e,t){return new b(T.INVALID_FORMAT,"String does not match format '"+e+"': "+t)}function U(e){throw new b(T.INTERNAL_ERROR,"Internal error: "+e)}!function(e){e.UNKNOWN="unknown",e.OBJECT_NOT_FOUND="object-not-found",e.BUCKET_NOT_FOUND="bucket-not-found",e.PROJECT_NOT_FOUND="project-not-found",e.QUOTA_EXCEEDED="quota-exceeded",e.UNAUTHENTICATED="unauthenticated",e.UNAUTHORIZED="unauthorized",e.UNAUTHORIZED_APP="unauthorized-app",e.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",e.INVALID_CHECKSUM="invalid-checksum",e.CANCELED="canceled",e.INVALID_EVENT_NAME="invalid-event-name",e.INVALID_URL="invalid-url",e.INVALID_DEFAULT_BUCKET="invalid-default-bucket",e.NO_DEFAULT_BUCKET="no-default-bucket",e.CANNOT_SLICE_BLOB="cannot-slice-blob",e.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",e.NO_DOWNLOAD_URL="no-download-url",e.INVALID_ARGUMENT="invalid-argument",e.INVALID_ARGUMENT_COUNT="invalid-argument-count",e.APP_DELETED="app-deleted",e.INVALID_ROOT_OPERATION="invalid-root-operation",e.INVALID_FORMAT="invalid-format",e.INTERNAL_ERROR="internal-error",e.UNSUPPORTED_ENVIRONMENT="unsupported-environment"}(T||(T={}));class N{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(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let n;try{n=N.makeFromUrl(e,t)}catch(t){return new N(e,"")}if(""===n.path)return n;throw r=e,new b(T.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+r+"'.");var r}static makeFromUrl(e,t){let n=null;const r="([A-Za-z0-9.\\-_]+)";const s=new RegExp("^gs://"+r+"(/(.*))?$","i");function o(e){e.path_=decodeURIComponent(e.path)}const i=t.replace(/[.]/g,"\\."),a=[{regex:s,indices:{bucket:1,path:3},postModify:function(e){"/"===e.path.charAt(e.path.length-1)&&(e.path_=e.path_.slice(0,-1))}},{regex:new RegExp(`^https?://${i}/v[A-Za-z0-9_]+/b/${r}/o(/([^?#]*).*)?$`,"i"),indices:{bucket:1,path:3},postModify:o},{regex:new RegExp(`^https?://${"firebasestorage.googleapis.com"===t?"(?:storage.googleapis.com|storage.cloud.google.com)":t}/${r}/([^?#]*)`,"i"),indices:{bucket:1,path:2},postModify:o}];for(let t=0;t<a.length;t++){const r=a[t],s=r.regex.exec(e);if(s){const e=s[r.indices.bucket];let t=s[r.indices.path];t||(t=""),n=new N(e,t),r.postModify(n);break}}if(null==n)throw function(e){return new b(T.INVALID_URL,"Invalid URL '"+e+"'.")}(e);return n}}class I{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}function x(e){return"string"==typeof e||e instanceof String}function D(e){return P()&&e instanceof Blob}function P(){return"undefined"!=typeof Blob&&!function(){var e;const t=null===(e=l())||void 0===e?void 0:e.forceEnvironment;if("node"===t)return!0;if("browser"===t)return!1;try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}()}function L(e,t,n,r){if(r<t)throw A(`Invalid value for '${e}'. Expected ${t} or greater.`);if(r>n)throw A(`Invalid value for '${e}'. Expected ${n} or less.`)}function B(e,t,n){let r=t;return null==n&&(r=`https://${t}`),`${n}://${r}/v0${e}`}function M(e){const t=encodeURIComponent;let n="?";for(const r in e)if(e.hasOwnProperty(r)){n=n+(t(r)+"="+t(e[r]))+"&"}return n=n.slice(0,-1),n}function F(e,t){const n=e>=500&&e<600,r=-1!==[408,429].indexOf(e),s=-1!==t.indexOf(e);return n||r||s}!function(e){e[e.NO_ERROR=0]="NO_ERROR",e[e.NETWORK_ERROR=1]="NETWORK_ERROR",e[e.ABORT=2]="ABORT"}(E||(E={}));class q{constructor(e,t,n,r,s,o,i,a,c,u,h,l=!0){this.url_=e,this.method_=t,this.headers_=n,this.body_=r,this.successCodes_=s,this.additionalRetryCodes_=o,this.callback_=i,this.errorCallback_=a,this.timeout_=c,this.progressCallback_=u,this.connectionFactory_=h,this.retry=l,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_(){const e=(e,t)=>{if(t)return void e(!1,new H(!1,null,!0));const n=this.connectionFactory_();this.pendingConnection_=n;const r=e=>{const t=e.loaded,n=e.lengthComputable?e.total:-1;null!==this.progressCallback_&&this.progressCallback_(t,n)};null!==this.progressCallback_&&n.addUploadProgressListener(r),n.send(this.url_,this.method_,this.body_,this.headers_).then((()=>{null!==this.progressCallback_&&n.removeUploadProgressListener(r),this.pendingConnection_=null;const t=n.getErrorCode()===E.NO_ERROR,s=n.getStatus();if(!t||F(s,this.additionalRetryCodes_)&&this.retry){const t=n.getErrorCode()===E.ABORT;return void e(!1,new H(!1,null,t))}const o=-1!==this.successCodes_.indexOf(s);e(!0,new H(o,n))}))},t=(e,t)=>{const n=this.resolve_,r=this.reject_,s=t.connection;if(t.wasSuccessCode)try{const e=this.callback_(s,s.getResponse());void 0!==e?n(e):n()}catch(e){r(e)}else if(null!==s){const e=R();e.serverResponse=s.getErrorText(),this.errorCallback_?r(this.errorCallback_(s,e)):r(e)}else if(t.canceled){r(this.appDelete_?S():v())}else{r(w())}};this.canceled_?t(0,new H(!1,null,!0)):this.backoffId_=function(e,t,n){let r=1,s=null,o=null,i=!1,a=0;function c(){return 2===a}let u=!1;function h(...e){u||(u=!0,t.apply(null,e))}function l(t){s=setTimeout((()=>{s=null,e(d,c())}),t)}function _(){o&&clearTimeout(o)}function d(e,...t){if(u)return void _();if(e)return _(),void h.call(null,e,...t);if(c()||i)return _(),void h.call(null,e,...t);let n;r<64&&(r*=2),1===a?(a=2,n=0):n=1e3*(r+Math.random()),l(n)}let p=!1;function f(e){p||(p=!0,_(),u||(null!==s?(e||(a=2),clearTimeout(s),l(0)):e||(a=1)))}return l(0),o=setTimeout((()=>{i=!0,f(!0)}),n),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 H{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}}function V(){return"undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0}function W(...e){const t=V();if(void 0!==t){const n=new t;for(let t=0;t<e.length;t++)n.append(e[t]);return n.getBlob()}if(P())return new Blob(e);throw new b(T.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}function j(e){if("undefined"==typeof atob)throw t="base-64",new b(T.UNSUPPORTED_ENVIRONMENT,`${t} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`);var t;return atob(e)}const $={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class z{constructor(e,t){this.data=e,this.contentType=t||null}}function G(e,t){switch(e){case $.RAW:return new z(X(t));case $.BASE64:case $.BASE64URL:return new z(K(e,t));case $.DATA_URL:return new z(function(e){const t=new J(e);return t.base64?K($.BASE64,t.rest):function(e){let t;try{t=decodeURIComponent(e)}catch(e){throw C($.DATA_URL,"Malformed data URL.")}return X(t)}(t.rest)}(t),new J(t).contentType)}throw R()}function X(e){const t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<=127)t.push(r);else if(r<=2047)t.push(192|r>>6,128|63&r);else if(55296==(64512&r)){if(n<e.length-1&&56320==(64512&e.charCodeAt(n+1))){r=65536|(1023&r)<<10|1023&e.charCodeAt(++n),t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r)}else t.push(239,191,189)}else 56320==(64512&r)?t.push(239,191,189):t.push(224|r>>12,128|r>>6&63,128|63&r)}return new Uint8Array(t)}function K(e,t){switch(e){case $.BASE64:{const n=-1!==t.indexOf("-"),r=-1!==t.indexOf("_");if(n||r){throw C(e,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?")}break}case $.BASE64URL:{const n=-1!==t.indexOf("+"),r=-1!==t.indexOf("/");if(n||r){throw C(e,"Invalid character '"+(n?"+":"/")+"' found: is it base64 encoded?")}t=t.replace(/-/g,"+").replace(/_/g,"/");break}}let n;try{n=j(t)}catch(t){if(t.message.includes("polyfill"))throw t;throw C(e,"Invalid character found")}const r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}class J{constructor(e){this.base64=!1,this.contentType=null;const t=e.match(/^data:([^,]+)?,/);if(null===t)throw C($.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const n=t[1]||null;null!=n&&(this.base64=function(e,t){if(!(e.length>=t.length))return!1;return e.substring(e.length-t.length)===t}(n,";base64"),this.contentType=this.base64?n.substring(0,n.length-";base64".length):n),this.rest=e.substring(e.indexOf(",")+1)}}class Z{constructor(e,t){let n=0,r="";D(e)?(this.data_=e,n=e.size,r=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),n=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),n=e.length),this.size_=n,this.type_=r}size(){return this.size_}type(){return this.type_}slice(e,t){if(D(this.data_)){const n=function(e,t,n){return e.webkitSlice?e.webkitSlice(t,n):e.mozSlice?e.mozSlice(t,n):e.slice?e.slice(t,n):null}(this.data_,e,t);return null===n?null:new Z(n)}{const n=new Uint8Array(this.data_.buffer,e,t-e);return new Z(n,!0)}}static getBlob(...e){if(P()){const t=e.map((e=>e instanceof Z?e.data_:e));return new Z(W.apply(null,t))}{const t=e.map((e=>x(e)?G($.RAW,e).data:e.data_));let n=0;t.forEach((e=>{n+=e.byteLength}));const r=new Uint8Array(n);let s=0;return t.forEach((e=>{for(let t=0;t<e.length;t++)r[s++]=e[t]})),new Z(r,!0)}}uploadData(){return this.data_}}function Y(e){let t;try{t=JSON.parse(e)}catch(e){return null}return"object"!=typeof(n=t)||Array.isArray(n)?null:t;var n}function Q(e){const t=e.lastIndexOf("/",e.length-2);return-1===t?e:e.slice(t+1)}function ee(e,t){return t}class te{constructor(e,t,n,r){this.server=e,this.local=t||e,this.writable=!!n,this.xform=r||ee}}let ne=null;function re(){if(ne)return ne;const e=[];e.push(new te("bucket")),e.push(new te("generation")),e.push(new te("metageneration")),e.push(new te("name","fullPath",!0));const t=new te("name");t.xform=function(e,t){return function(e){return!x(e)||e.length<2?e:Q(e)}(t)},e.push(t);const n=new te("size");return n.xform=function(e,t){return void 0!==t?Number(t):t},e.push(n),e.push(new te("timeCreated")),e.push(new te("updated")),e.push(new te("md5Hash",null,!0)),e.push(new te("cacheControl",null,!0)),e.push(new te("contentDisposition",null,!0)),e.push(new te("contentEncoding",null,!0)),e.push(new te("contentLanguage",null,!0)),e.push(new te("contentType",null,!0)),e.push(new te("metadata","customMetadata",!0)),ne=e,ne}function se(e,t,n){const r={type:"file"},s=n.length;for(let e=0;e<s;e++){const s=n[e];r[s.local]=s.xform(r,t[s.server])}return function(e,t){Object.defineProperty(e,"ref",{get:function(){const n=e.bucket,r=e.fullPath,s=new N(n,r);return t._makeStorageReference(s)}})}(r,e),r}function oe(e,t,n){const r=Y(t);if(null===r)return null;return se(e,r,n)}function ie(e,t){const n={},r=t.length;for(let s=0;s<r;s++){const r=t[s];r.writable&&(n[r.server]=e[r.local])}return JSON.stringify(n)}function ae(e,t,n){const r=Y(n);if(null===r)return null;return function(e,t,n){const r={prefixes:[],items:[],nextPageToken:n.nextPageToken};if(n.prefixes)for(const s of n.prefixes){const n=s.replace(/\/$/,""),o=e._makeStorageReference(new N(t,n));r.prefixes.push(o)}if(n.items)for(const s of n.items){const n=e._makeStorageReference(new N(t,s.name));r.items.push(n)}return r}(e,t,r)}class ce{constructor(e,t,n,r){this.url=e,this.method=t,this.handler=n,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}function ue(e){if(!e)throw R()}function he(e,t){return function(n,r){const s=oe(e,r,t);return ue(null!==s),s}}function le(e,t){return function(n,r){const s=oe(e,r,t);return ue(null!==s),function(e,t,n,r){const s=Y(t);if(null===s)return null;if(!x(s.downloadTokens))return null;const o=s.downloadTokens;if(0===o.length)return null;const i=encodeURIComponent;return o.split(",").map((t=>{const s=e.bucket,o=e.fullPath;return B("/b/"+i(s)+"/o/"+i(o),n,r)+M({alt:"media",token:t})}))[0]}(s,r,e.host,e._protocol)}}function _e(e){return function(t,n){let r;var s,o;return 401===t.getStatus()?r=t.getErrorText().includes("Firebase App Check token is invalid")?new b(T.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project."):new b(T.UNAUTHENTICATED,"User is not authenticated, please authenticate using Firebase Authentication and try again."):402===t.getStatus()?(o=e.bucket,r=new b(T.QUOTA_EXCEEDED,"Quota for bucket '"+o+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===t.getStatus()?(s=e.path,r=new b(T.UNAUTHORIZED,"User does not have permission to access '"+s+"'.")):r=n,r.status=t.getStatus(),r.serverResponse=n.serverResponse,r}}function de(e){const t=_e(e);return function(n,r){let s=t(n,r);var o;return 404===n.getStatus()&&(o=e.path,s=new b(T.OBJECT_NOT_FOUND,"Object '"+o+"' does not exist.")),s.serverResponse=r.serverResponse,s}}function pe(e,t,n){const r=B(t.fullServerUrl(),e.host,e._protocol),s=e.maxOperationRetryTime,o=new ce(r,"GET",he(e,n),s);return o.errorHandler=de(t),o}function fe(e,t,n,r,s){const o={};t.isRoot?o.prefix="":o.prefix=t.path+"/",n&&n.length>0&&(o.delimiter=n),r&&(o.pageToken=r),s&&(o.maxResults=s);const i=B(t.bucketOnlyServerUrl(),e.host,e._protocol),a=e.maxOperationRetryTime,c=new ce(i,"GET",function(e,t){return function(n,r){const s=ae(e,t,r);return ue(null!==s),s}}(e,t.bucket),a);return c.urlParams=o,c.errorHandler=_e(t),c}function ge(e,t,n){const r=B(t.fullServerUrl(),e.host,e._protocol)+"?alt=media",s=e.maxOperationRetryTime,o=new ce(r,"GET",((e,t)=>t),s);return o.errorHandler=de(t),void 0!==n&&(o.headers.Range=`bytes=0-${n}`,o.successCodes=[200,206]),o}function me(e,t,n){const r=Object.assign({},n);return r.fullPath=e.path,r.size=t.size(),r.contentType||(r.contentType=function(e,t){return e&&e.contentType||t&&t.type()||"application/octet-stream"}(null,t)),r}function be(e,t,n,r,s){const o=t.bucketOnlyServerUrl(),i={"X-Goog-Upload-Protocol":"multipart"};const a=function(){let e="";for(let t=0;t<2;t++)e+=Math.random().toString().slice(2);return e}();i["Content-Type"]="multipart/related; boundary="+a;const c=me(t,r,s),u="--"+a+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+ie(c,n)+"\r\n--"+a+"\r\nContent-Type: "+c.contentType+"\r\n\r\n",h="\r\n--"+a+"--",l=Z.getBlob(u,r,h);if(null===l)throw k();const _={name:c.fullPath},d=B(o,e.host,e._protocol),p=e.maxUploadRetryTime,f=new ce(d,"POST",he(e,n),p);return f.urlParams=_,f.headers=i,f.body=l.uploadData(),f.errorHandler=_e(t),f}class Te{constructor(e,t,n,r){this.current=e,this.total=t,this.finalized=!!n,this.metadata=r||null}}function Ee(e,t){let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Status")}catch(e){ue(!1)}return ue(!!n&&-1!==(t||["active"]).indexOf(n)),n}function ye(e,t,n,r,s,o,i,a){const c=new Te(0,0);if(i?(c.current=i.current,c.total=i.total):(c.current=0,c.total=r.size()),r.size()!==c.total)throw new b(T.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.");const u=c.total-c.current;let h=u;s>0&&(h=Math.min(h,s));const l=c.current,_=l+h;let d="";d=0===h?"finalize":u===h?"upload, finalize":"upload";const p={"X-Goog-Upload-Command":d,"X-Goog-Upload-Offset":`${c.current}`},f=r.slice(l,_);if(null===f)throw k();const g=t.maxUploadRetryTime,m=new ce(n,"POST",(function(e,n){const s=Ee(e,["active","final"]),i=c.current+h,a=r.size();let u;return u="final"===s?he(t,o)(e,n):null,new Te(i,a,"final"===s,u)}),g);return m.headers=p,m.body=f.uploadData(),m.progressCallback=a||null,m.errorHandler=_e(e),m}const Re={STATE_CHANGED:"state_changed"},we={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function ve(e){switch(e){case"running":case"pausing":case"canceling":return we.RUNNING;case"paused":return we.PAUSED;case"success":return we.SUCCESS;case"canceled":return we.CANCELED;default:return we.ERROR}}class ke{constructor(e,t,n){if("function"==typeof e||null!=t||null!=n)this.next=e,this.error=null!=t?t:void 0,this.complete=null!=n?n:void 0;else{const t=e;this.next=t.next,this.error=t.error,this.complete=t.complete}}}function Ae(e){return(...t)=>{Promise.resolve().then((()=>e(...t)))}}class Se{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=E.NO_ERROR,this.sendPromise_=new Promise((e=>{this.xhr_.addEventListener("abort",(()=>{this.errorCode_=E.ABORT,e()})),this.xhr_.addEventListener("error",(()=>{this.errorCode_=E.NETWORK_ERROR,e()})),this.xhr_.addEventListener("load",(()=>{e()}))}))}send(e,t,n,r){if(this.sent_)throw U("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(t,e,!0),void 0!==r)for(const e in r)r.hasOwnProperty(e)&&this.xhr_.setRequestHeader(e,r[e].toString());return void 0!==n?this.xhr_.send(n):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw U("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw U("cannot .getStatus() before sending");try{return this.xhr_.status}catch(e){return-1}}getResponse(){if(!this.sent_)throw U("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw U("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)}}class Oe extends Se{initXhr(){this.xhr_.responseType="text"}}function Ce(){return new Oe}class Ue extends Se{initXhr(){this.xhr_.responseType="arraybuffer"}}function Ne(){return new Ue}class Ie extends Se{initXhr(){this.xhr_.responseType="blob"}}function xe(){return new Ie}class De{constructor(e,t,n=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=n,this._mappings=re(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=e=>{if(this._request=void 0,this._chunkMultiplier=1,e._codeEquals(T.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{const t=this.isExponentialBackoffExpired();if(F(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(T.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 e=this._transferred;return t=>this._updateProgress(e+t)}_shouldDoResumable(e){return e.size()>262144}_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(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then((([t,n])=>{switch(this._state){case"running":e(t,n);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused")}}))}_createResumable(){this._resolveToken(((e,t)=>{const n=function(e,t,n,r,s){const o=t.bucketOnlyServerUrl(),i=me(t,r,s),a={name:i.fullPath},c=B(o,e.host,e._protocol),u={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${r.size()}`,"X-Goog-Upload-Header-Content-Type":i.contentType,"Content-Type":"application/json; charset=utf-8"},h=ie(i,n),l=e.maxUploadRetryTime,_=new ce(c,"POST",(function(e){let t;Ee(e);try{t=e.getResponseHeader("X-Goog-Upload-URL")}catch(e){ue(!1)}return ue(x(t)),t}),l);return _.urlParams=a,_.headers=u,_.body=h,_.errorHandler=_e(t),_}(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,Ce,e,t);this._request=r,r.getPromise().then((e=>{this._request=void 0,this._uploadUrl=e,this._needToFetchStatus=!1,this.completeTransitions_()}),this._errorHandler)}))}_fetchStatus(){const e=this._uploadUrl;this._resolveToken(((t,n)=>{const r=function(e,t,n,r){const s=e.maxUploadRetryTime,o=new ce(n,"POST",(function(e){const t=Ee(e,["active","final"]);let n=null;try{n=e.getResponseHeader("X-Goog-Upload-Size-Received")}catch(e){ue(!1)}n||ue(!1);const s=Number(n);return ue(!isNaN(s)),new Te(s,r.size(),"final"===t)}),s);return o.headers={"X-Goog-Upload-Command":"query"},o.errorHandler=_e(t),o}(this._ref.storage,this._ref._location,e,this._blob),s=this._ref.storage._makeRequest(r,Ce,t,n);this._request=s,s.getPromise().then((e=>{e=e,this._request=void 0,this._updateProgress(e.current),this._needToFetchStatus=!1,e.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()}),this._errorHandler)}))}_continueUpload(){const e=262144*this._chunkMultiplier,t=new Te(this._transferred,this._blob.size()),n=this._uploadUrl;this._resolveToken(((r,s)=>{let o;try{o=ye(this._ref._location,this._ref.storage,n,this._blob,e,this._mappings,t,this._makeProgressCallback())}catch(e){return this._error=e,void this._transition("error")}const i=this._ref.storage._makeRequest(o,Ce,r,s,!1);this._request=i,i.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)=>{const n=pe(this._ref.storage,this._ref._location,this._mappings),r=this._ref.storage._makeRequest(n,Ce,e,t);this._request=r,r.getPromise().then((e=>{this._request=void 0,this._metadata=e,this._transition("success")}),this._metadataErrorHandler)}))}_oneShotUpload(){this._resolveToken(((e,t)=>{const n=be(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,Ce,e,t);this._request=r,r.getPromise().then((e=>{this._request=void 0,this._metadata=e,this._updateProgress(this._blob.size()),this._transition("success")}),this._errorHandler)}))}_updateProgress(e){const 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":const t="paused"===this._state;this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":case"error":case"success":this._state=e,this._notifyObservers();break;case"canceled":this._error=v(),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(){const e=ve(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,n,r){const s=new ke(t||void 0,n||void 0,r||void 0);return this._addObserver(s),()=>{this._removeObserver(s)}}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){const t=this._observers.indexOf(e);-1!==t&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise();this._observers.slice().forEach((e=>{this._notifyObserver(e)}))}_finishPromise(){if(void 0!==this._resolve){let e=!0;switch(ve(this._state)){case we.SUCCESS:Ae(this._resolve.bind(null,this.snapshot))();break;case we.CANCELED:case we.ERROR:Ae(this._reject.bind(null,this._error))();break;default:e=!1}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(ve(this._state)){case we.RUNNING:case we.PAUSED:e.next&&Ae(e.next.bind(e,this.snapshot))();break;case we.SUCCESS:e.complete&&Ae(e.complete.bind(e))();break;default:e.error&&Ae(e.error.bind(e,this._error))()}}resume(){const e="paused"===this._state||"pausing"===this._state;return e&&this._transition("running"),e}pause(){const e="running"===this._state;return e&&this._transition("pausing"),e}cancel(){const e="running"===this._state||"pausing"===this._state;return e&&this._transition("canceling"),e}}class Pe{constructor(e,t){this._service=e,this._location=t instanceof N?t:N.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new Pe(e,t)}get root(){const e=new N(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return Q(this._location.path)}get storage(){return this._service}get parent(){const e=function(e){if(0===e.length)return null;const t=e.lastIndexOf("/");return-1===t?"":e.slice(0,t)}(this._location.path);if(null===e)return null;const t=new N(this._location.bucket,e);return new Pe(this._service,t)}_throwIfRoot(e){if(""===this._location.path)throw O(e)}}function Le(e,t,n){e._throwIfRoot("uploadBytes");const r=be(e.storage,e._location,re(),new Z(t,!0),n);return e.storage.makeRequestWithTokens(r,Ce).then((t=>({metadata:t,ref:e})))}function Be(e){const t={prefixes:[],items:[]};return Me(e,t).then((()=>t))}async function Me(e,t,n){const r={pageToken:n},s=await Fe(e,r);t.prefixes.push(...s.prefixes),t.items.push(...s.items),null!=s.nextPageToken&&await Me(e,t,s.nextPageToken)}function Fe(e,t){null!=t&&"number"==typeof t.maxResults&&L("options.maxResults",1,1e3,t.maxResults);const n=t||{},r=fe(e.storage,e._location,"/",n.pageToken,n.maxResults);return e.storage.makeRequestWithTokens(r,Ce)}function qe(e,t){e._throwIfRoot("updateMetadata");const n=function(e,t,n,r){const s=B(t.fullServerUrl(),e.host,e._protocol),o=ie(n,r),i=e.maxOperationRetryTime,a=new ce(s,"PATCH",he(e,r),i);return a.headers={"Content-Type":"application/json; charset=utf-8"},a.body=o,a.errorHandler=de(t),a}(e.storage,e._location,t,re());return e.storage.makeRequestWithTokens(n,Ce)}function He(e){e._throwIfRoot("getDownloadURL");const t=function(e,t,n){const r=B(t.fullServerUrl(),e.host,e._protocol),s=e.maxOperationRetryTime,o=new ce(r,"GET",le(e,n),s);return o.errorHandler=de(t),o}(e.storage,e._location,re());return e.storage.makeRequestWithTokens(t,Ce).then((e=>{if(null===e)throw new b(T.NO_DOWNLOAD_URL,"The given file does not have any download URLs.");return e}))}function Ve(e){e._throwIfRoot("deleteObject");const t=function(e,t){const n=B(t.fullServerUrl(),e.host,e._protocol),r=e.maxOperationRetryTime,s=new ce(n,"DELETE",(function(e,t){}),r);return s.successCodes=[200,204],s.errorHandler=de(t),s}(e.storage,e._location);return e.storage.makeRequestWithTokens(t,Ce)}function We(e,t){const n=function(e,t){const n=t.split("/").filter((e=>e.length>0)).join("/");return 0===e.length?n:e+"/"+n}(e._location.path,t),r=new N(e._location.bucket,n);return new Pe(e.storage,r)}function je(e,t){if(e instanceof Xe){const n=e;if(null==n._bucket)throw new b(T.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the 'storageBucket' property when initializing the app?");const r=new Pe(n,n._bucket);return null!=t?je(r,t):r}return void 0!==t?We(e,t):e}function $e(e,t){if(t&&/^[A-Za-z]+:\/\//.test(t)){if(e instanceof Xe)return new Pe(e,t);throw A("To use ref(service, url), the first argument must be a Storage instance.")}return je(e,t)}function ze(e,t){const n=null==t?void 0:t.storageBucket;return null==n?null:N.makeFromBucketSpec(n,e)}function Ge(e,t,n,r={}){e.host=`${t}:${n}`,e._protocol="http";const{mockUserToken:s}=r;s&&(e._overrideAuthToken="string"==typeof s?s: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.');const n=t||"demo-project",r=e.iat||0,s=e.sub||e.user_id;if(!s)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:r,exp:r+3600,auth_time:r,sub:s,user_id:s,firebase:{sign_in_provider:"custom",identities:{}}},e);return[c(JSON.stringify({alg:"none",type:"JWT"})),c(JSON.stringify(o)),""].join(".")}(s,e.app.options.projectId))}class Xe{constructor(e,t,n,r,s){this.app=e,this._authProvider=t,this._appCheckProvider=n,this._url=r,this._firebaseVersion=s,this._bucket=null,this._host="firebasestorage.googleapis.com",this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=r?N.makeFromBucketSpec(r,this._host):ze(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,null!=this._url?this._bucket=N.makeFromBucketSpec(this._url,e):this._bucket=ze(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){L("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){L("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){const t=await e.getToken();if(null!==t)return t.accessToken}return null}async _getAppCheckToken(){const e=this._appCheckProvider.getImmediate({optional:!0});if(e){return(await e.getToken()).token}return null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach((e=>e.cancel())),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new Pe(this,e)}_makeRequest(e,t,n,r,s=!0){if(this._deleted)return new I(S());{const o=function(e,t,n,r,s,o,i=!0){const a=M(e.urlParams),c=e.url+a,u=Object.assign({},e.headers);return function(e,t){t&&(e["X-Firebase-GMPID"]=t)}(u,t),function(e,t){null!==t&&t.length>0&&(e.Authorization="Firebase "+t)}(u,n),function(e,t){e["X-Firebase-Storage-Version"]="webjs/"+(null!=t?t:"AppManager")}(u,o),function(e,t){null!==t&&(e["X-Firebase-AppCheck"]=t)}(u,r),new q(c,e.method,u,e.body,e.successCodes,e.additionalRetryCodes,e.handler,e.errorHandler,e.timeout,e.progressCallback,s,i)}(e,this._appId,n,r,t,this._firebaseVersion,s);return this._requests.add(o),o.getPromise().then((()=>this._requests.delete(o)),(()=>this._requests.delete(o))),o}}async makeRequestWithTokens(e,t){const[n,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,n,r).getPromise()}}const Ke="@firebase/storage";function Je(e,t){return function(e,t){e._throwIfRoot("getBytes");const n=ge(e.storage,e._location,t);return e.storage.makeRequestWithTokens(n,Ne).then((e=>void 0!==t?e.slice(0,t):e))}(e=g(e),t)}function Ze(e,t,n){return Le(e=g(e),t,n)}function Ye(e,t,n,r){return function(e,t,n=$.RAW,r){e._throwIfRoot("uploadString");const s=G(n,t),o=Object.assign({},r);return null==o.contentType&&null!=s.contentType&&(o.contentType=s.contentType),Le(e,s.data,o)}(e=g(e),t,n,r)}function Qe(e,t,n){return function(e,t,n){return e._throwIfRoot("uploadBytesResumable"),new De(e,new Z(t),n)}(e=g(e),t,n)}function et(e){return function(e){e._throwIfRoot("getMetadata");const t=pe(e.storage,e._location,re());return e.storage.makeRequestWithTokens(t,Ce)}(e=g(e))}function tt(e,t){return qe(e=g(e),t)}function nt(e,t){return Fe(e=g(e),t)}function rt(e){return Be(e=g(e))}function st(e){return He(e=g(e))}function ot(e){return Ve(e=g(e))}function it(e,t){return $e(e=g(e),t)}function at(e,t){return We(e,t)}function ct(n=t(),r){n=g(n);const s=e(n,"storage").getImmediate({identifier:r}),o=_("storage");return o&&ut(s,...o),s}function ut(e,t,n,r={}){Ge(e,t,n,r)}function ht(e,t){return function(e,t){e._throwIfRoot("getBlob");const n=ge(e.storage,e._location,t);return e.storage.makeRequestWithTokens(n,xe).then((e=>void 0!==t?e.slice(0,t):e))}(e=g(e),t)}function lt(e,t){throw new Error("getStream() is only supported by NodeJS builds")}function _t(e,{instanceIdentifier:t}){const n=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),o=e.getProvider("app-check-internal");return new Xe(n,r,o,t,s)}n(new m("storage",_t,"PUBLIC").setMultipleInstances(!0)),r(Ke,"0.11.2",""),r(Ke,"0.11.2","esm2017");export{b as StorageError,T as StorageErrorCode,$ as StringFormat,Z as _FbsBlob,N as _Location,Re as _TaskEvent,we as _TaskState,De as _UploadTask,G as _dataFromString,at as _getChild,A as _invalidArgument,O as _invalidRootOperation,ut as connectStorageEmulator,ot as deleteObject,ht as getBlob,Je as getBytes,st as getDownloadURL,et as getMetadata,ct as getStorage,lt as getStream,nt as list,rt as listAll,it as ref,tt as updateMetadata,Ze as uploadBytes,Qe as uploadBytesResumable,Ye as uploadString};
2
2
 
3
3
  //# sourceMappingURL=firebase-storage.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase",
3
- "version": "9.17.2",
3
+ "version": "9.18.0",
4
4
  "description": "Firebase JavaScript library for web and Node.js",
5
5
  "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
6
6
  "license": "Apache-2.0",
@@ -373,15 +373,15 @@
373
373
  "test:ci": "echo 'No test suite for firebase wrapper'"
374
374
  },
375
375
  "dependencies": {
376
- "@firebase/app": "0.9.4",
377
- "@firebase/app-compat": "0.2.4",
376
+ "@firebase/app": "0.9.5",
377
+ "@firebase/app-compat": "0.2.5",
378
378
  "@firebase/app-types": "0.9.0",
379
- "@firebase/auth": "0.21.4",
380
- "@firebase/auth-compat": "0.3.4",
379
+ "@firebase/auth": "0.21.5",
380
+ "@firebase/auth-compat": "0.3.5",
381
381
  "@firebase/database": "0.14.4",
382
382
  "@firebase/database-compat": "0.3.4",
383
- "@firebase/firestore": "3.8.4",
384
- "@firebase/firestore-compat": "0.3.4",
383
+ "@firebase/firestore": "3.9.0",
384
+ "@firebase/firestore-compat": "0.3.5",
385
385
  "@firebase/functions": "0.9.4",
386
386
  "@firebase/functions-compat": "0.3.4",
387
387
  "@firebase/installations": "0.6.4",