!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).firebase)}(this,function(Te){"use strict";try{!function(){function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=e(Te),n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};var d=function(){return(d=Object.assign||function(e){for(var t,r=1,n=arguments.length;ra[0]&&t[1]>6,u=63&u;c||(u=64,a||(l=64)),n.push(r[i>>2],r[(3&i)<<4|s>>4],r[l],r[u])}return n.join("")},encodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(function(e){for(var t=[],r=0,n=0;n>6|192:(55296==(64512&o)&&n+1>18|240,t[r++]=o>>12&63|128):t[r++]=o>>12|224,t[r++]=o>>6&63|128),t[r++]=63&o|128)}return t}(e),t)},decodeString:function(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){for(var t=[],r=0,n=0;r>10)),t[n++]=String.fromCharCode(56320+(1023&o))):(i=e[r++],a=e[r++],t[n++]=String.fromCharCode((15&s)<<12|(63&i)<<6|63&a))}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray:function(e,t){this.init_();for(var r=t?this.charToByteMapWebSafe_:this.charToByteMap_,n=[],o=0;o>4),64!==s&&(n.push(a<<4&240|s>>2),64!==c&&n.push(s<<6&192|c))}return n},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var e=0;e=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}},c=(r.prototype.wrapCallback=function(r){var n=this;return function(e,t){e?n.reject(e):n.resolve(t),"function"==typeof r&&(n.promise.catch(function(){}),1===r.length?r(e):r(e,t))}},r);function r(){var r=this;this.reject=function(){},this.resolve=function(){},this.promise=new Promise(function(e,t){r.resolve=e,r.reject=t})}function o(){return"indexedDB"in self&&null!=indexedDB}var i,u="FirebaseError",l=(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(h,i=Error),h);function h(e,t,r){t=i.call(this,t)||this;return t.code=e,t.customData=r,t.name=u,Object.setPrototypeOf(t,h.prototype),Error.captureStackTrace&&Error.captureStackTrace(t,p.prototype.create),t}var p=(f.prototype.create=function(e){for(var t=[],r=1;r"})):"Error",e=this.serviceName+": "+e+" ("+i+").";return new l(i,e,o)},f);function f(e,t,r){this.service=e,this.serviceName=t,this.errors=r}var b=/\{\$([^}]+)}/g;function E(e){return JSON.parse(e)}function _(e){return"object"==typeof(e=function(e){var t={},r={},n={},o="";try{var i=e.split("."),t=E(a(i[0])||""),r=E(a(i[1])||""),o=i[2],n=r.d||{};delete r.d}catch(e){}return{header:t,claims:r,data:n,signature:o}}(e).claims)&&e.hasOwnProperty("iat")?e.iat:null}var w,k=(m.prototype.setInstantiationMode=function(e){return this.instantiationMode=e,this},m.prototype.setMultipleInstances=function(e){return this.multipleInstances=e,this},m.prototype.setServiceProps=function(e){return this.serviceProps=e,this},m.prototype.setInstanceCreatedCallback=function(e){return this.onInstanceCreated=e,this},m);function m(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}(R=w=w||{})[R.DEBUG=0]="DEBUG",R[R.VERBOSE=1]="VERBOSE",R[R.INFO=2]="INFO",R[R.WARN=3]="WARN",R[R.ERROR=4]="ERROR",R[R.SILENT=5]="SILENT";function T(e,t){for(var r=[],n=2;nthis.upperBound&&(this.nextErrorWaitInterval=this.upperBound),e},F);function F(e,t,r,n,o){if(this.operation=e,this.retryPolicy=t,this.getWaitDuration=r,this.lowerBound=n,this.upperBound=o,this.pending=null,o<(this.nextErrorWaitInterval=n))throw new Error("Proactive refresh lower bound greater than upper bound!")}function V(){return self.grecaptcha}function U(e){if(!M(e).activated)throw I.create("use-before-activation",{appName:e.name})}function K(e,a){var s=e.url,c=e.body;return g(this,void 0,void 0,function(){var t,r,n,o,i;return v(this,function(e){switch(e.label){case 0:r={"Content-Type":"application/json"},(t=a.getImmediate({optional:!0}))&&(r["X-Firebase-Client"]=t.getPlatformInfoString()),r={method:"POST",body:JSON.stringify(c),headers:r},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,fetch(s,r)];case 2:return i=e.sent(),[3,4];case 3:throw r=e.sent(),I.create("fetch-network-error",{originalErrorMessage:r.message});case 4:if(200!==i.status)throw I.create("fetch-status-error",{httpStatus:i.status});e.label=5;case 5:return e.trys.push([5,7,,8]),[4,i.json()];case 6:return n=e.sent(),[3,8];case 7:throw o=e.sent(),I.create("fetch-parse-error",{originalErrorMessage:o.message});case 8:if(!(i=n.ttl.match(/^([\d.]+)(s)$/))||!i[2]||isNaN(Number(i[1])))throw I.create("fetch-parse-error",{originalErrorMessage:"ttl field (timeToLive) is not in standard Protobuf Duration format: "+n.ttl});return o=1e3*Number(i[1]),i=Date.now(),[2,{token:n.attestationToken,expireTimeMillis:i+o,issuedAtTimeMillis:i}]}})})}function G(e,t){var r=e.options,n=r.projectId,e=r.appId,r=r.apiKey;return{url:D+"/projects/"+n+"/apps/"+e+":"+H+"?key="+r,body:{debug_token:t}}}var $="firebase-app-check-database",z=1,X="firebase-app-check-store",J="debug-token",Y=null;function q(){return Y=Y||new Promise(function(t,r){try{var e=indexedDB.open($,z);e.onsuccess=function(e){t(e.target.result)},e.onerror=function(e){r(I.create("storage-open",{originalErrorMessage:null===(e=e.target.error)||void 0===e?void 0:e.message}))},e.onupgradeneeded=function(e){var t=e.target.result;0===e.oldVersion&&t.createObjectStore(X,{keyPath:"compositeKey"})}}catch(e){r(I.create("storage-open",{originalErrorMessage:e.message}))}})}function Z(r,i){return g(this,void 0,void 0,function(){var n,t,o;return v(this,function(e){switch(e.label){case 0:return[4,q()];case 1:return t=e.sent(),n=t.transaction(X,"readwrite"),t=n.objectStore(X),o=t.put({compositeKey:r,value:i}),[2,new Promise(function(t,r){o.onsuccess=function(e){t()},n.onerror=function(e){r(I.create("storage-set",{originalErrorMessage:null===(e=e.target.error)||void 0===e?void 0:e.message}))}})]}})})}function Q(r){return g(this,void 0,void 0,function(){var n,t,o;return v(this,function(e){switch(e.label){case 0:return[4,q()];case 1:return t=e.sent(),n=t.transaction(X,"readonly"),t=n.objectStore(X),o=t.get(r),[2,new Promise(function(t,r){o.onsuccess=function(e){e=e.target.result;t(e?e.value:void 0)},n.onerror=function(e){r(I.create("storage-get",{originalErrorMessage:null===(e=e.target.error)||void 0===e?void 0:e.message}))}})]}})})}function ee(e){return e.options.appId+"-"+e.name}var te=new R("@firebase/app-check");function re(n){return g(this,void 0,void 0,function(){var t,r;return v(this,function(e){switch(e.label){case 0:if(!o())return[3,5];t=void 0,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,Q(ee(n))];case 2:return t=e.sent(),[3,4];case 3:return r=e.sent(),te.warn("Failed to read token from indexeddb. Error: "+r),[3,4];case 4:return[2,t];case 5:return[2,void 0]}})})}function ne(e,t){return o()?Z(ee(e),t).catch(function(e){te.warn("Failed to write token to indexeddb. Error: "+e)}):Promise.resolve()}function oe(){return g(this,void 0,void 0,function(){var t;return v(this,function(e){switch(e.label){case 0:t=void 0,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,Q(J)];case 2:return t=e.sent(),[3,4];case 3:return e.sent(),[3,4];case 4:return t?[2,t]:(t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),Z(J,t).catch(function(e){return te.warn("Failed to persist debug token to indexeddb. Error: "+e)}),console.log("AppCheck debug token: "+t+". You will need to whitelist it in the Firebase console for it to work"),[2,t])}})})}var ie={error:"UNKNOWN_ERROR"};function ae(h,p,f){return void 0===f&&(f=!1),g(this,void 0,void 0,function(){var r,n,o,i,a,s,c,u,l;return v(this,function(e){switch(e.label){case 0:return U(h),r=M(h),n=r.token,o=void 0,n?[3,2]:[4,r.cachedTokenPromise];case 1:(i=e.sent())&&le(i)&&(n=i,B(h,d(d({},r),{token:n})),ue(h,{token:n.token})),e.label=2;case 2:return!f&&n&&le(n)?[2,{token:n.token}]:L.enabled?(a=K,s=G,c=[h],[4,function(){return g(this,void 0,void 0,function(){var t;return v(this,function(e){if((t=L).enabled&&t.token)return[2,t.token.promise];throw Error("\n Can't get debug token in production mode.\n ")})})}()]):[3,6];case 3:return[4,a.apply(void 0,[s.apply(void 0,c.concat([e.sent()])),p])];case 4:return u=e.sent(),[4,ne(h,u)];case 5:return e.sent(),B(h,d(d({},r),{token:u})),[2,{token:u.token}];case 6:return e.trys.push([6,8,,9]),[4,r.provider.getToken()];case 7:return n=e.sent(),[3,9];case 8:return u=e.sent(),te.error(u),o=u,[3,9];case 9:return n?[3,10]:(t=o,l={token:function(e){return y.encodeString(JSON.stringify(e),!1)}(ie),error:t},[3,12]);case 10:return l={token:n.token},B(h,d(d({},r),{token:n})),[4,ne(h,n)];case 11:e.sent(),e.label=12;case 12:return ue(h,l),[2,l]}var t})})}function se(e,t,r,n,o){var i,a=M(e),r={next:n,error:o,type:r},r=d(d({},a),{tokenObservers:s(s([],a.tokenObservers),[r])});r.tokenRefresher||(t=function(r,n){var e=this;return new j(function(){return g(e,void 0,void 0,function(){var t;return v(this,function(e){switch(e.label){case 0:return M(r).token?[3,2]:[4,ae(r,n)];case 1:return t=e.sent(),[3,4];case 2:return[4,ae(r,n,!0)];case 3:t=e.sent(),e.label=4;case 4:if(t.error)throw t.error;return[2]}})})},function(){return!0},function(){var e=M(r);if(e.token){var t=e.token.issuedAtTimeMillis+.5*(e.token.expireTimeMillis-e.token.issuedAtTimeMillis)+3e5,e=e.token.expireTimeMillis-3e5,t=Math.min(t,e);return Math.max(0,t-Date.now())}return 0},W.RETRIAL_MIN_WAIT,W.RETRIAL_MAX_WAIT)}(e,t),r.tokenRefresher=t),!r.tokenRefresher.isRunning()&&a.isTokenAutoRefreshEnabled&&r.tokenRefresher.start(),a.token&&le(a.token)?(i=a.token,Promise.resolve().then(function(){return n({token:i.token})}).catch(function(){})):null==a.token&&a.cachedTokenPromise.then(function(e){e&&le(e)&&n({token:e.token})}).catch(function(){}),B(e,r)}function ce(e,t){var r=M(e),n=r.tokenObservers.filter(function(e){return e.next!==t});0===n.length&&r.tokenRefresher&&r.tokenRefresher.isRunning()&&r.tokenRefresher.stop(),B(e,d(d({},r),{tokenObservers:n}))}function ue(e,t){for(var r=0,n=M(e).tokenObservers;r