@neurosity/sdk 6.5.4 → 6.6.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.
- package/dist/browser/neurosity.iife.js +34070 -21604
- package/dist/browser/neurosity.js +55 -41
- package/dist/browser/neurosity.js.map +1 -1
- package/dist/cjs/api/firebase/FirebaseApp.d.ts +5 -5
- package/dist/cjs/api/firebase/FirebaseApp.js +5 -5
- package/dist/cjs/api/firebase/FirebaseDevice.d.ts +1 -1
- package/dist/cjs/api/firebase/FirebaseDevice.js +1 -1
- package/dist/cjs/api/firebase/FirebaseUser.d.ts +1 -1
- package/dist/cjs/api/firebase/FirebaseUser.js +1 -1
- package/dist/cjs/api/firebase/deviceStore.js +1 -1
- package/dist/electron/index.js +4 -4
- package/dist/electron/index.js.map +1 -1
- package/dist/esm/api/firebase/FirebaseApp.d.ts +5 -5
- package/dist/esm/api/firebase/FirebaseApp.js +5 -5
- package/dist/esm/api/firebase/FirebaseDevice.d.ts +1 -1
- package/dist/esm/api/firebase/FirebaseDevice.js +1 -1
- package/dist/esm/api/firebase/FirebaseUser.d.ts +1 -1
- package/dist/esm/api/firebase/FirebaseUser.js +1 -1
- package/dist/esm/api/firebase/deviceStore.js +1 -1
- package/dist/esm/neurosity.mjs +34067 -21601
- package/dist/examples/neurosity.iife.js +34070 -21604
- package/dist/examples/neurosity.js +55 -41
- package/dist/examples/neurosity.mjs +34067 -21601
- package/package.json +2 -2
|
@@ -458,54 +458,68 @@ var t,e,n=module.exports={};function r(){throw new Error("setTimeout has not bee
|
|
|
458
458
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"audit",{enumerable:!0,get:function(){return e.audit}}),Object.defineProperty(exports,"auditTime",{enumerable:!0,get:function(){return r.auditTime}}),Object.defineProperty(exports,"buffer",{enumerable:!0,get:function(){return t.buffer}}),Object.defineProperty(exports,"bufferCount",{enumerable:!0,get:function(){return n.bufferCount}}),Object.defineProperty(exports,"bufferTime",{enumerable:!0,get:function(){return o.bufferTime}}),Object.defineProperty(exports,"bufferToggle",{enumerable:!0,get:function(){return i.bufferToggle}}),Object.defineProperty(exports,"bufferWhen",{enumerable:!0,get:function(){return a.bufferWhen}}),Object.defineProperty(exports,"catchError",{enumerable:!0,get:function(){return u.catchError}}),Object.defineProperty(exports,"combineAll",{enumerable:!0,get:function(){return p.combineAll}}),Object.defineProperty(exports,"combineLatest",{enumerable:!0,get:function(){return s.combineLatest}}),Object.defineProperty(exports,"combineLatestAll",{enumerable:!0,get:function(){return l.combineLatestAll}}),Object.defineProperty(exports,"combineLatestWith",{enumerable:!0,get:function(){return c.combineLatestWith}}),Object.defineProperty(exports,"concat",{enumerable:!0,get:function(){return f.concat}}),Object.defineProperty(exports,"concatAll",{enumerable:!0,get:function(){return b.concatAll}}),Object.defineProperty(exports,"concatMap",{enumerable:!0,get:function(){return m.concatMap}}),Object.defineProperty(exports,"concatMapTo",{enumerable:!0,get:function(){return d.concatMapTo}}),Object.defineProperty(exports,"concatWith",{enumerable:!0,get:function(){return g.concatWith}}),Object.defineProperty(exports,"connect",{enumerable:!0,get:function(){return y.connect}}),Object.defineProperty(exports,"count",{enumerable:!0,get:function(){return x.count}}),Object.defineProperty(exports,"debounce",{enumerable:!0,get:function(){return O.debounce}}),Object.defineProperty(exports,"debounceTime",{enumerable:!0,get:function(){return q.debounceTime}}),Object.defineProperty(exports,"defaultIfEmpty",{enumerable:!0,get:function(){return j.defaultIfEmpty}}),Object.defineProperty(exports,"delay",{enumerable:!0,get:function(){return P.delay}}),Object.defineProperty(exports,"delayWhen",{enumerable:!0,get:function(){return h.delayWhen}}),Object.defineProperty(exports,"dematerialize",{enumerable:!0,get:function(){return w.dematerialize}}),Object.defineProperty(exports,"distinct",{enumerable:!0,get:function(){return W.distinct}}),Object.defineProperty(exports,"distinctUntilChanged",{enumerable:!0,get:function(){return T.distinctUntilChanged}}),Object.defineProperty(exports,"distinctUntilKeyChanged",{enumerable:!0,get:function(){return k.distinctUntilKeyChanged}}),Object.defineProperty(exports,"elementAt",{enumerable:!0,get:function(){return A.elementAt}}),Object.defineProperty(exports,"endWith",{enumerable:!0,get:function(){return M.endWith}}),Object.defineProperty(exports,"every",{enumerable:!0,get:function(){return E.every}}),Object.defineProperty(exports,"exhaust",{enumerable:!0,get:function(){return L.exhaust}}),Object.defineProperty(exports,"exhaustAll",{enumerable:!0,get:function(){return z.exhaustAll}}),Object.defineProperty(exports,"exhaustMap",{enumerable:!0,get:function(){return C.exhaustMap}}),Object.defineProperty(exports,"expand",{enumerable:!0,get:function(){return v.expand}}),Object.defineProperty(exports,"filter",{enumerable:!0,get:function(){return I.filter}}),Object.defineProperty(exports,"finalize",{enumerable:!0,get:function(){return U.finalize}}),Object.defineProperty(exports,"find",{enumerable:!0,get:function(){return R.find}}),Object.defineProperty(exports,"findIndex",{enumerable:!0,get:function(){return B.findIndex}}),Object.defineProperty(exports,"first",{enumerable:!0,get:function(){return S.first}}),Object.defineProperty(exports,"flatMap",{enumerable:!0,get:function(){return X.flatMap}}),Object.defineProperty(exports,"groupBy",{enumerable:!0,get:function(){return F.groupBy}}),Object.defineProperty(exports,"ignoreElements",{enumerable:!0,get:function(){return K.ignoreElements}}),Object.defineProperty(exports,"isEmpty",{enumerable:!0,get:function(){return N.isEmpty}}),Object.defineProperty(exports,"last",{enumerable:!0,get:function(){return _.last}}),Object.defineProperty(exports,"map",{enumerable:!0,get:function(){return D.map}}),Object.defineProperty(exports,"mapTo",{enumerable:!0,get:function(){return G.mapTo}}),Object.defineProperty(exports,"materialize",{enumerable:!0,get:function(){return H.materialize}}),Object.defineProperty(exports,"max",{enumerable:!0,get:function(){return J.max}}),Object.defineProperty(exports,"merge",{enumerable:!0,get:function(){return Q.merge}}),Object.defineProperty(exports,"mergeAll",{enumerable:!0,get:function(){return V.mergeAll}}),Object.defineProperty(exports,"mergeMap",{enumerable:!0,get:function(){return Y.mergeMap}}),Object.defineProperty(exports,"mergeMapTo",{enumerable:!0,get:function(){return Z.mergeMapTo}}),Object.defineProperty(exports,"mergeScan",{enumerable:!0,get:function(){return $.mergeScan}}),Object.defineProperty(exports,"mergeWith",{enumerable:!0,get:function(){return ee.mergeWith}}),Object.defineProperty(exports,"min",{enumerable:!0,get:function(){return re.min}}),Object.defineProperty(exports,"multicast",{enumerable:!0,get:function(){return te.multicast}}),Object.defineProperty(exports,"observeOn",{enumerable:!0,get:function(){return ne.observeOn}}),Object.defineProperty(exports,"onErrorResumeNext",{enumerable:!0,get:function(){return oe.onErrorResumeNext}}),Object.defineProperty(exports,"pairwise",{enumerable:!0,get:function(){return ie.pairwise}}),Object.defineProperty(exports,"partition",{enumerable:!0,get:function(){return ae.partition}}),Object.defineProperty(exports,"pluck",{enumerable:!0,get:function(){return ue.pluck}}),Object.defineProperty(exports,"publish",{enumerable:!0,get:function(){return pe.publish}}),Object.defineProperty(exports,"publishBehavior",{enumerable:!0,get:function(){return le.publishBehavior}}),Object.defineProperty(exports,"publishLast",{enumerable:!0,get:function(){return se.publishLast}}),Object.defineProperty(exports,"publishReplay",{enumerable:!0,get:function(){return ce.publishReplay}}),Object.defineProperty(exports,"race",{enumerable:!0,get:function(){return fe.race}}),Object.defineProperty(exports,"raceWith",{enumerable:!0,get:function(){return be.raceWith}}),Object.defineProperty(exports,"reduce",{enumerable:!0,get:function(){return me.reduce}}),Object.defineProperty(exports,"refCount",{enumerable:!0,get:function(){return Oe.refCount}}),Object.defineProperty(exports,"repeat",{enumerable:!0,get:function(){return de.repeat}}),Object.defineProperty(exports,"repeatWhen",{enumerable:!0,get:function(){return ge.repeatWhen}}),Object.defineProperty(exports,"retry",{enumerable:!0,get:function(){return ye.retry}}),Object.defineProperty(exports,"retryWhen",{enumerable:!0,get:function(){return xe.retryWhen}}),Object.defineProperty(exports,"sample",{enumerable:!0,get:function(){return qe.sample}}),Object.defineProperty(exports,"sampleTime",{enumerable:!0,get:function(){return je.sampleTime}}),Object.defineProperty(exports,"scan",{enumerable:!0,get:function(){return Pe.scan}}),Object.defineProperty(exports,"sequenceEqual",{enumerable:!0,get:function(){return he.sequenceEqual}}),Object.defineProperty(exports,"share",{enumerable:!0,get:function(){return we.share}}),Object.defineProperty(exports,"shareReplay",{enumerable:!0,get:function(){return We.shareReplay}}),Object.defineProperty(exports,"single",{enumerable:!0,get:function(){return Te.single}}),Object.defineProperty(exports,"skip",{enumerable:!0,get:function(){return ke.skip}}),Object.defineProperty(exports,"skipLast",{enumerable:!0,get:function(){return Ae.skipLast}}),Object.defineProperty(exports,"skipUntil",{enumerable:!0,get:function(){return Me.skipUntil}}),Object.defineProperty(exports,"skipWhile",{enumerable:!0,get:function(){return Ee.skipWhile}}),Object.defineProperty(exports,"startWith",{enumerable:!0,get:function(){return Le.startWith}}),Object.defineProperty(exports,"subscribeOn",{enumerable:!0,get:function(){return ze.subscribeOn}}),Object.defineProperty(exports,"switchAll",{enumerable:!0,get:function(){return Ce.switchAll}}),Object.defineProperty(exports,"switchMap",{enumerable:!0,get:function(){return ve.switchMap}}),Object.defineProperty(exports,"switchMapTo",{enumerable:!0,get:function(){return Ie.switchMapTo}}),Object.defineProperty(exports,"switchScan",{enumerable:!0,get:function(){return Ue.switchScan}}),Object.defineProperty(exports,"take",{enumerable:!0,get:function(){return Re.take}}),Object.defineProperty(exports,"takeLast",{enumerable:!0,get:function(){return Be.takeLast}}),Object.defineProperty(exports,"takeUntil",{enumerable:!0,get:function(){return Se.takeUntil}}),Object.defineProperty(exports,"takeWhile",{enumerable:!0,get:function(){return Fe.takeWhile}}),Object.defineProperty(exports,"tap",{enumerable:!0,get:function(){return Ke.tap}}),Object.defineProperty(exports,"throttle",{enumerable:!0,get:function(){return Ne.throttle}}),Object.defineProperty(exports,"throttleTime",{enumerable:!0,get:function(){return _e.throttleTime}}),Object.defineProperty(exports,"throwIfEmpty",{enumerable:!0,get:function(){return De.throwIfEmpty}}),Object.defineProperty(exports,"timeInterval",{enumerable:!0,get:function(){return Ge.timeInterval}}),Object.defineProperty(exports,"timeout",{enumerable:!0,get:function(){return He.timeout}}),Object.defineProperty(exports,"timeoutWith",{enumerable:!0,get:function(){return Je.timeoutWith}}),Object.defineProperty(exports,"timestamp",{enumerable:!0,get:function(){return Qe.timestamp}}),Object.defineProperty(exports,"toArray",{enumerable:!0,get:function(){return Ve.toArray}}),Object.defineProperty(exports,"window",{enumerable:!0,get:function(){return Xe.window}}),Object.defineProperty(exports,"windowCount",{enumerable:!0,get:function(){return Ye.windowCount}}),Object.defineProperty(exports,"windowTime",{enumerable:!0,get:function(){return Ze.windowTime}}),Object.defineProperty(exports,"windowToggle",{enumerable:!0,get:function(){return $e.windowToggle}}),Object.defineProperty(exports,"windowWhen",{enumerable:!0,get:function(){return er.windowWhen}}),Object.defineProperty(exports,"withLatestFrom",{enumerable:!0,get:function(){return rr.withLatestFrom}}),Object.defineProperty(exports,"zip",{enumerable:!0,get:function(){return tr.zip}}),Object.defineProperty(exports,"zipAll",{enumerable:!0,get:function(){return nr.zipAll}}),Object.defineProperty(exports,"zipWith",{enumerable:!0,get:function(){return or.zipWith}});var e=require("../internal/operators/audit"),r=require("../internal/operators/auditTime"),t=require("../internal/operators/buffer"),n=require("../internal/operators/bufferCount"),o=require("../internal/operators/bufferTime"),i=require("../internal/operators/bufferToggle"),a=require("../internal/operators/bufferWhen"),u=require("../internal/operators/catchError"),p=require("../internal/operators/combineAll"),l=require("../internal/operators/combineLatestAll"),s=require("../internal/operators/combineLatest"),c=require("../internal/operators/combineLatestWith"),f=require("../internal/operators/concat"),b=require("../internal/operators/concatAll"),m=require("../internal/operators/concatMap"),d=require("../internal/operators/concatMapTo"),g=require("../internal/operators/concatWith"),y=require("../internal/operators/connect"),x=require("../internal/operators/count"),O=require("../internal/operators/debounce"),q=require("../internal/operators/debounceTime"),j=require("../internal/operators/defaultIfEmpty"),P=require("../internal/operators/delay"),h=require("../internal/operators/delayWhen"),w=require("../internal/operators/dematerialize"),W=require("../internal/operators/distinct"),T=require("../internal/operators/distinctUntilChanged"),k=require("../internal/operators/distinctUntilKeyChanged"),A=require("../internal/operators/elementAt"),M=require("../internal/operators/endWith"),E=require("../internal/operators/every"),L=require("../internal/operators/exhaust"),z=require("../internal/operators/exhaustAll"),C=require("../internal/operators/exhaustMap"),v=require("../internal/operators/expand"),I=require("../internal/operators/filter"),U=require("../internal/operators/finalize"),R=require("../internal/operators/find"),B=require("../internal/operators/findIndex"),S=require("../internal/operators/first"),F=require("../internal/operators/groupBy"),K=require("../internal/operators/ignoreElements"),N=require("../internal/operators/isEmpty"),_=require("../internal/operators/last"),D=require("../internal/operators/map"),G=require("../internal/operators/mapTo"),H=require("../internal/operators/materialize"),J=require("../internal/operators/max"),Q=require("../internal/operators/merge"),V=require("../internal/operators/mergeAll"),X=require("../internal/operators/flatMap"),Y=require("../internal/operators/mergeMap"),Z=require("../internal/operators/mergeMapTo"),$=require("../internal/operators/mergeScan"),ee=require("../internal/operators/mergeWith"),re=require("../internal/operators/min"),te=require("../internal/operators/multicast"),ne=require("../internal/operators/observeOn"),oe=require("../internal/operators/onErrorResumeNext"),ie=require("../internal/operators/pairwise"),ae=require("../internal/operators/partition"),ue=require("../internal/operators/pluck"),pe=require("../internal/operators/publish"),le=require("../internal/operators/publishBehavior"),se=require("../internal/operators/publishLast"),ce=require("../internal/operators/publishReplay"),fe=require("../internal/operators/race"),be=require("../internal/operators/raceWith"),me=require("../internal/operators/reduce"),de=require("../internal/operators/repeat"),ge=require("../internal/operators/repeatWhen"),ye=require("../internal/operators/retry"),xe=require("../internal/operators/retryWhen"),Oe=require("../internal/operators/refCount"),qe=require("../internal/operators/sample"),je=require("../internal/operators/sampleTime"),Pe=require("../internal/operators/scan"),he=require("../internal/operators/sequenceEqual"),we=require("../internal/operators/share"),We=require("../internal/operators/shareReplay"),Te=require("../internal/operators/single"),ke=require("../internal/operators/skip"),Ae=require("../internal/operators/skipLast"),Me=require("../internal/operators/skipUntil"),Ee=require("../internal/operators/skipWhile"),Le=require("../internal/operators/startWith"),ze=require("../internal/operators/subscribeOn"),Ce=require("../internal/operators/switchAll"),ve=require("../internal/operators/switchMap"),Ie=require("../internal/operators/switchMapTo"),Ue=require("../internal/operators/switchScan"),Re=require("../internal/operators/take"),Be=require("../internal/operators/takeLast"),Se=require("../internal/operators/takeUntil"),Fe=require("../internal/operators/takeWhile"),Ke=require("../internal/operators/tap"),Ne=require("../internal/operators/throttle"),_e=require("../internal/operators/throttleTime"),De=require("../internal/operators/throwIfEmpty"),Ge=require("../internal/operators/timeInterval"),He=require("../internal/operators/timeout"),Je=require("../internal/operators/timeoutWith"),Qe=require("../internal/operators/timestamp"),Ve=require("../internal/operators/toArray"),Xe=require("../internal/operators/window"),Ye=require("../internal/operators/windowCount"),Ze=require("../internal/operators/windowTime"),$e=require("../internal/operators/windowToggle"),er=require("../internal/operators/windowWhen"),rr=require("../internal/operators/withLatestFrom"),tr=require("../internal/operators/zip"),nr=require("../internal/operators/zipAll"),or=require("../internal/operators/zipWith");
|
|
459
459
|
},{"../internal/operators/audit":"OSTs","../internal/operators/auditTime":"qRa1","../internal/operators/buffer":"dt28","../internal/operators/bufferCount":"j5Mb","../internal/operators/bufferTime":"ZXjh","../internal/operators/bufferToggle":"sEzB","../internal/operators/bufferWhen":"DhIa","../internal/operators/catchError":"ZY8e","../internal/operators/combineAll":"bYSN","../internal/operators/combineLatestAll":"KhWj","../internal/operators/combineLatest":"xTmU","../internal/operators/combineLatestWith":"X904","../internal/operators/concat":"Ge6C","../internal/operators/concatAll":"SHNp","../internal/operators/concatMap":"u95e","../internal/operators/concatMapTo":"haX1","../internal/operators/concatWith":"wpEC","../internal/operators/connect":"aOS7","../internal/operators/count":"O922","../internal/operators/debounce":"WKkD","../internal/operators/debounceTime":"N6Fx","../internal/operators/defaultIfEmpty":"Fah0","../internal/operators/delay":"NHnw","../internal/operators/delayWhen":"UAqC","../internal/operators/dematerialize":"xeau","../internal/operators/distinct":"vBqk","../internal/operators/distinctUntilChanged":"Z6Fo","../internal/operators/distinctUntilKeyChanged":"rOn3","../internal/operators/elementAt":"vaXs","../internal/operators/endWith":"w35o","../internal/operators/every":"DFe2","../internal/operators/exhaust":"Bq0T","../internal/operators/exhaustAll":"ftIR","../internal/operators/exhaustMap":"BqMb","../internal/operators/expand":"TgHY","../internal/operators/filter":"IFp1","../internal/operators/finalize":"Z4yU","../internal/operators/find":"M6jc","../internal/operators/findIndex":"hdxC","../internal/operators/first":"eND7","../internal/operators/groupBy":"JSNM","../internal/operators/ignoreElements":"JGPk","../internal/operators/isEmpty":"G3o6","../internal/operators/last":"H8OC","../internal/operators/map":"N8Yl","../internal/operators/mapTo":"qCL4","../internal/operators/materialize":"LGra","../internal/operators/max":"wP5t","../internal/operators/merge":"Jh4T","../internal/operators/mergeAll":"leLE","../internal/operators/flatMap":"zBzv","../internal/operators/mergeMap":"mGWE","../internal/operators/mergeMapTo":"AZnr","../internal/operators/mergeScan":"L3Pv","../internal/operators/mergeWith":"ivs5","../internal/operators/min":"JiR9","../internal/operators/multicast":"eORA","../internal/operators/observeOn":"kKa0","../internal/operators/onErrorResumeNext":"i85H","../internal/operators/pairwise":"VnbW","../internal/operators/partition":"Zauj","../internal/operators/pluck":"u2jJ","../internal/operators/publish":"nPBI","../internal/operators/publishBehavior":"ndtv","../internal/operators/publishLast":"gdMW","../internal/operators/publishReplay":"HR0g","../internal/operators/race":"jVuL","../internal/operators/raceWith":"XeEu","../internal/operators/reduce":"gTgQ","../internal/operators/repeat":"UNCB","../internal/operators/repeatWhen":"aBtb","../internal/operators/retry":"IqOO","../internal/operators/retryWhen":"fivK","../internal/operators/refCount":"WUVS","../internal/operators/sample":"ueQ5","../internal/operators/sampleTime":"VxDF","../internal/operators/scan":"haGV","../internal/operators/sequenceEqual":"iZ1A","../internal/operators/share":"wd7X","../internal/operators/shareReplay":"RJoj","../internal/operators/single":"pOFx","../internal/operators/skip":"dhrz","../internal/operators/skipLast":"CBAe","../internal/operators/skipUntil":"TT30","../internal/operators/skipWhile":"TIPQ","../internal/operators/startWith":"p6pO","../internal/operators/subscribeOn":"cqCB","../internal/operators/switchAll":"De8H","../internal/operators/switchMap":"J2D0","../internal/operators/switchMapTo":"W7ik","../internal/operators/switchScan":"sDl1","../internal/operators/take":"mmu8","../internal/operators/takeLast":"BkG9","../internal/operators/takeUntil":"tosq","../internal/operators/takeWhile":"ic82","../internal/operators/tap":"uDXP","../internal/operators/throttle":"KrMa","../internal/operators/throttleTime":"i2pQ","../internal/operators/throwIfEmpty":"hR0o","../internal/operators/timeInterval":"OBGt","../internal/operators/timeout":"jt1g","../internal/operators/timeoutWith":"Vs6L","../internal/operators/timestamp":"XUFT","../internal/operators/toArray":"Dse9","../internal/operators/window":"MnAl","../internal/operators/windowCount":"ycrj","../internal/operators/windowTime":"fQsK","../internal/operators/windowToggle":"vmsA","../internal/operators/windowWhen":"SO6T","../internal/operators/withLatestFrom":"KD22","../internal/operators/zip":"qevp","../internal/operators/zipAll":"GYYb","../internal/operators/zipWith":"O3Ok"}],"jIGR":[function(require,module,exports) {
|
|
460
460
|
"use strict";module.exports=function r(t,e){if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;var o,n,u;if(Array.isArray(t)){if((o=t.length)!=e.length)return!1;for(n=o;0!=n--;)if(!r(t[n],e[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();if((o=(u=Object.keys(t)).length)!==Object.keys(e).length)return!1;for(n=o;0!=n--;)if(!Object.prototype.hasOwnProperty.call(e,u[n]))return!1;for(n=o;0!=n--;){var f=u[n];if(!r(t[f],e[f]))return!1}return!0}return t!=t&&e!=e};
|
|
461
|
-
},{}],"
|
|
462
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.__assign=void 0,exports.__asyncDelegator=g,exports.__asyncGenerator=m,exports.__asyncValues=O,exports.__await=x,exports.__awaiter=s,exports.__classPrivateFieldGet=T,exports.__classPrivateFieldIn=k,exports.__classPrivateFieldSet=I,exports.__createBinding=void 0,exports.__decorate=o,exports.__esDecorate=i,exports.__exportStar=d,exports.__extends=t,exports.__generator=p,exports.__importDefault=E,exports.__importStar=S,exports.__makeTemplateObject=j,exports.__metadata=l,exports.__param=a,exports.__propKey=u,exports.__read=_,exports.__rest=n,exports.__runInitializers=c,exports.__setFunctionName=f,exports.__spread=v,exports.__spreadArray=w,exports.__spreadArrays=b,exports.__values=h;var e=function(t,r){return(e=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])})(t,r)};function t(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var r=function(){return exports.__assign=r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function n(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function o(e,t,r,n){var o,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function a(e,t){return function(r,n){t(r,n,e)}}function i(e,t,r,n,o,a){function i(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var c,u=n.kind,f="getter"===u?"get":"setter"===u?"set":"value",l=!t&&e?n.static?e:e.prototype:null,s=t||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),p=!1,y=r.length-1;y>=0;y--){var d={};for(var h in n)d[h]="access"===h?{}:n[h];for(var h in n.access)d.access[h]=n.access[h];d.addInitializer=function(e){if(p)throw new TypeError("Cannot add initializers after decoration has completed");a.push(i(e||null))};var _=(0,r[y])("accessor"===u?{get:s.get,set:s.set}:s[f],d);if("accessor"===u){if(void 0===_)continue;if(null===_||"object"!=typeof _)throw new TypeError("Object expected");(c=i(_.get))&&(s.get=c),(c=i(_.set))&&(s.set=c),(c=i(_.init))&&o.push(c)}else(c=i(_))&&("field"===u?o.push(c):s[f]=c)}l&&Object.defineProperty(l,n.name,s),p=!0}function c(e,t,r){for(var n=arguments.length>2,o=0;o<t.length;o++)r=n?t[o].call(e,r):t[o].call(e);return n?r:void 0}function u(e){return"symbol"==typeof e?e:"".concat(e)}function f(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function l(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function s(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{u(n.next(e))}catch(t){a(t)}}function c(e){try{u(n.throw(e))}catch(t){a(t)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,c)}u((n=n.apply(e,t||[])).next())})}function p(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(u){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(u){c=[6,u],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}exports.__assign=r;var y=Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&("get"in o?t.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function d(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||y(t,e,r)}function h(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(c){o={error:c}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function v(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(_(arguments[t]));return e}function b(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var a=arguments[t],i=0,c=a.length;i<c;i++,o++)n[o]=a[i];return n}function w(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function x(e){return this instanceof x?(this.v=e,this):new x(e)}function m(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),a=[];return n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n;function i(e){o[e]&&(n[e]=function(t){return new Promise(function(r,n){a.push([e,t,r,n])>1||c(e,t)})})}function c(e,t){try{(r=o[e](t)).value instanceof x?Promise.resolve(r.value.v).then(u,f):l(a[0][2],r)}catch(n){l(a[0][3],n)}var r}function u(e){c("next",e)}function f(e){c("throw",e)}function l(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function g(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:x(e[n](t)),done:!1}:o?o(t):t}:o}}function O(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof h?h(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,o){(function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)})(n,o,(t=e[r](t)).done,t.value)})}}}function j(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}exports.__createBinding=y;var P=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function S(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&y(t,e,r);return P(t,e),t}function E(e){return e&&e.__esModule?e:{default:e}}function T(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function I(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r}function k(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}
|
|
463
|
-
},{}],"KxmD":[function(require,module,exports) {
|
|
461
|
+
},{}],"chA2":[function(require,module,exports) {
|
|
464
462
|
var global = arguments[3];
|
|
465
|
-
var e=arguments[3];Object.defineProperty(exports,"__esModule",{value:!0}),exports.Sha1=exports.RANDOM_FACTOR=exports.MAX_VALUE_MILLIS=exports.FirebaseError=exports.ErrorFactory=exports.Deferred=exports.CONSTANTS=void 0,exports.areCookiesEnabled=D,exports.assertionError=exports.assert=void 0,exports.async=re,exports.base64urlEncodeWithoutPadding=exports.base64Encode=exports.base64Decode=exports.base64=void 0,exports.calculateBackoffMillis=ve,exports.contains=z,exports.createMockUserToken=v,exports.createSubscribe=Z,exports.decode=void 0,exports.deepCopy=f,exports.deepEqual=G,exports.deepExtend=p,exports.errorPrefix=ie,exports.extractQuerystring=$,exports.getGlobal=N,exports.getModularInstance=ye,exports.getUA=b,exports.isAdmin=void 0,exports.isBrowser=x,exports.isBrowserExtension=g,exports.isElectron=A,exports.isEmpty=q,exports.isIE=m,exports.isIndexedDBAvailable=w,exports.isMobileCordova=_,exports.isNode=y,exports.isNodeSdk=O,exports.isReactNative=E,exports.isSafari=C,exports.isUWP=S,exports.issuedAtTime=exports.isValidTimestamp=exports.isValidFormat=void 0,exports.jsonEval=P,exports.map=H,exports.ordinal=be,exports.querystring=X,exports.querystringDecode=Q,exports.safeGet=J,exports.stringToByteArray=exports.stringLength=void 0,exports.stringify=L,exports.validateArgCount=void 0,exports.validateCallback=ae,exports.validateContextObject=ce,exports.validateIndexedDBOpenable=T,exports.validateNamespace=se;var r=require("tslib"),t={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"};exports.CONSTANTS=t;var o=function(e,r){if(!e)throw n(r)};exports.assert=o;var n=function(e){return new Error("Firebase Database ("+t.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)};exports.assertionError=n;var i=function(e){for(var r=[],t=0,o=0;o<e.length;o++){var n=e.charCodeAt(o);n<128?r[t++]=n:n<2048?(r[t++]=n>>6|192,r[t++]=63&n|128):55296==(64512&n)&&o+1<e.length&&56320==(64512&e.charCodeAt(o+1))?(n=65536+((1023&n)<<10)+(1023&e.charCodeAt(++o)),r[t++]=n>>18|240,r[t++]=n>>12&63|128,r[t++]=n>>6&63|128,r[t++]=63&n|128):(r[t++]=n>>12|224,r[t++]=n>>6&63|128,r[t++]=63&n|128)}return r},s=function(e){for(var r=[],t=0,o=0;t<e.length;){var n=e[t++];if(n<128)r[o++]=String.fromCharCode(n);else if(n>191&&n<224){var i=e[t++];r[o++]=String.fromCharCode((31&n)<<6|63&i)}else if(n>239&&n<365){var s=((7&n)<<18|(63&(i=e[t++]))<<12|(63&(a=e[t++]))<<6|63&e[t++])-65536;r[o++]=String.fromCharCode(55296+(s>>10)),r[o++]=String.fromCharCode(56320+(1023&s))}else{i=e[t++];var a=e[t++];r[o++]=String.fromCharCode((15&n)<<12|(63&i)<<6|63&a)}}return r.join("")},a={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray:function(e,r){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var t=r?this.byteToCharMapWebSafe_:this.byteToCharMap_,o=[],n=0;n<e.length;n+=3){var i=e[n],s=n+1<e.length,a=s?e[n+1]:0,c=n+2<e.length,u=c?e[n+2]:0,h=i>>2,f=(3&i)<<4|a>>4,p=(15&a)<<2|u>>6,d=63&u;c||(d=64,s||(p=64)),o.push(t[h],t[f],t[p],t[d])}return o.join("")},encodeString:function(e,r){return this.HAS_NATIVE_SUPPORT&&!r?btoa(e):this.encodeByteArray(i(e),r)},decodeString:function(e,r){return this.HAS_NATIVE_SUPPORT&&!r?atob(e):s(this.decodeStringToByteArray(e,r))},decodeStringToByteArray:function(e,r){this.init_();for(var t=r?this.charToByteMapWebSafe_:this.charToByteMap_,o=[],n=0;n<e.length;){var i=t[e.charAt(n++)],s=n<e.length?t[e.charAt(n)]:0,a=++n<e.length?t[e.charAt(n)]:64,c=++n<e.length?t[e.charAt(n)]:64;if(++n,null==i||null==s||null==a||null==c)throw Error();var u=i<<2|s>>4;if(o.push(u),64!==a){var h=s<<4&240|a>>2;if(o.push(h),64!==c){var f=a<<6&192|c;o.push(f)}}}return o},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var 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)}}};exports.base64=a;var c=function(e){var r=i(e);return a.encodeByteArray(r,!0)};exports.base64Encode=c;var u=function(e){return c(e).replace(/\./g,"")};exports.base64urlEncodeWithoutPadding=u;var h=function(e){try{return a.decodeString(e,!0)}catch(r){console.error("base64Decode failed: ",r)}return null};function f(e){return p(void 0,e)}function p(e,r){if(!(r instanceof Object))return r;switch(r.constructor){case Date:return new Date(r.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return r}for(var t in r)r.hasOwnProperty(t)&&d(t)&&(e[t]=p(e[t],r[t]));return e}function d(e){return"__proto__"!==e}exports.base64Decode=h;var l=function(){function e(){var e=this;this.reject=function(){},this.resolve=function(){},this.promise=new Promise(function(r,t){e.resolve=r,e.reject=t})}return e.prototype.wrapCallback=function(e){var r=this;return function(t,o){t?r.reject(t):r.resolve(o),"function"==typeof e&&(r.promise.catch(function(){}),1===e.length?e(t):e(t,o))}},e}();function v(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');var o=t||"demo-project",n=e.iat||0,i=e.sub||e.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");var s=(0,r.__assign)({iss:"https://securetoken.google.com/"+o,aud:o,iat:n,exp:n+3600,auth_time:n,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},e);return[u(JSON.stringify({alg:"none",type:"JWT"})),u(JSON.stringify(s)),""].join(".")}function b(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function _(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(b())}function y(){try{return"[object process]"===Object.prototype.toString.call(e.process)}catch(r){return!1}}function x(){return"object"==typeof self&&self.self===self}function g(){var e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}function E(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function A(){return b().indexOf("Electron/")>=0}function m(){var e=b();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0}function S(){return b().indexOf("MSAppHost/")>=0}function O(){return!0===t.NODE_CLIENT||!0===t.NODE_ADMIN}function C(){return!y()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function w(){return"indexedDB"in self&&null!=indexedDB}function T(){return new Promise(function(e,r){try{var t=!0,o="validate-browser-context-for-indexeddb-analytics-module",n=self.indexedDB.open(o);n.onsuccess=function(){n.result.close(),t||self.indexedDB.deleteDatabase(o),e(!0)},n.onupgradeneeded=function(){t=!1},n.onerror=function(){var e;r((null===(e=n.error)||void 0===e?void 0:e.message)||"")}}catch(i){r(i)}})}function D(){return!(!navigator||!navigator.cookieEnabled)}function N(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("Unable to locate global object.")}exports.Deferred=l;var M="FirebaseError",j=function(e){function t(r,o,n){var i=e.call(this,o)||this;return i.code=r,i.customData=n,i.name=M,Object.setPrototypeOf(i,t.prototype),Error.captureStackTrace&&Error.captureStackTrace(i,k.prototype.create),i}return(0,r.__extends)(t,e),t}(Error);exports.FirebaseError=j;var k=function(){function e(e,r,t){this.service=e,this.serviceName=r,this.errors=t}return e.prototype.create=function(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];var o=r[0]||{},n=this.service+"/"+e,i=this.errors[e],s=i?B(i,o):"Error",a=this.serviceName+": "+s+" ("+n+").";return new j(n,a,o)},e}();function B(e,r){return e.replace(I,function(e,t){var o=r[t];return null!=o?String(o):"<"+t+"?>"})}exports.ErrorFactory=k;var I=/\{\$([^}]+)}/g;function P(e){return JSON.parse(e)}function L(e){return JSON.stringify(e)}var V=function(e){var r={},t={},o={},n="";try{var i=e.split(".");r=P(h(i[0])||""),t=P(h(i[1])||""),n=i[2],o=t.d||{},delete t.d}catch(s){}return{header:r,claims:t,data:o,signature:n}};exports.decode=V;var R=function(e){var r=V(e).claims,t=Math.floor((new Date).getTime()/1e3),o=0,n=0;return"object"==typeof r&&(r.hasOwnProperty("nbf")?o=r.nbf:r.hasOwnProperty("iat")&&(o=r.iat),n=r.hasOwnProperty("exp")?r.exp:o+86400),!!t&&!!o&&!!n&&t>=o&&t<=n};exports.isValidTimestamp=R;var W=function(e){var r=V(e).claims;return"object"==typeof r&&r.hasOwnProperty("iat")?r.iat:null};exports.issuedAtTime=W;var U=function(e){var r=V(e).claims;return!!r&&"object"==typeof r&&r.hasOwnProperty("iat")};exports.isValidFormat=U;var F=function(e){var r=V(e).claims;return"object"==typeof r&&!0===r.admin};function z(e,r){return Object.prototype.hasOwnProperty.call(e,r)}function J(e,r){return Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0}function q(e){for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))return!1;return!0}function H(e,r,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=r.call(t,e[n],n,e));return o}function G(e,r){if(e===r)return!0;for(var t=Object.keys(e),o=Object.keys(r),n=0,i=t;n<i.length;n++){var s=i[n];if(!o.includes(s))return!1;var a=e[s],c=r[s];if(K(a)&&K(c)){if(!G(a,c))return!1}else if(a!==c)return!1}for(var u=0,h=o;u<h.length;u++){s=h[u];if(!t.includes(s))return!1}return!0}function K(e){return null!==e&&"object"==typeof e}function X(e){for(var r=[],t=function(e,t){Array.isArray(t)?t.forEach(function(t){r.push(encodeURIComponent(e)+"="+encodeURIComponent(t))}):r.push(encodeURIComponent(e)+"="+encodeURIComponent(t))},o=0,n=Object.entries(e);o<n.length;o++){var i=n[o];t(i[0],i[1])}return r.length?"&"+r.join("&"):""}function Q(e){var r={};return e.replace(/^\?/,"").split("&").forEach(function(e){if(e){var t=e.split("="),o=t[0],n=t[1];r[decodeURIComponent(o)]=decodeURIComponent(n)}}),r}function $(e){var r=e.indexOf("?");if(!r)return"";var t=e.indexOf("#",r);return e.substring(r,t>0?t:void 0)}exports.isAdmin=F;var Y=function(){function e(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(var e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}return e.prototype.reset=function(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0},e.prototype.compress_=function(e,r){r||(r=0);var t=this.W_;if("string"==typeof e)for(var o=0;o<16;o++)t[o]=e.charCodeAt(r)<<24|e.charCodeAt(r+1)<<16|e.charCodeAt(r+2)<<8|e.charCodeAt(r+3),r+=4;else for(o=0;o<16;o++)t[o]=e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3],r+=4;for(o=16;o<80;o++){var n=t[o-3]^t[o-8]^t[o-14]^t[o-16];t[o]=4294967295&(n<<1|n>>>31)}var i,s,a=this.chain_[0],c=this.chain_[1],u=this.chain_[2],h=this.chain_[3],f=this.chain_[4];for(o=0;o<80;o++){o<40?o<20?(i=h^c&(u^h),s=1518500249):(i=c^u^h,s=1859775393):o<60?(i=c&u|h&(c|u),s=2400959708):(i=c^u^h,s=3395469782);n=(a<<5|a>>>27)+i+f+s+t[o]&4294967295;f=h,h=u,u=4294967295&(c<<30|c>>>2),c=a,a=n}this.chain_[0]=this.chain_[0]+a&4294967295,this.chain_[1]=this.chain_[1]+c&4294967295,this.chain_[2]=this.chain_[2]+u&4294967295,this.chain_[3]=this.chain_[3]+h&4294967295,this.chain_[4]=this.chain_[4]+f&4294967295},e.prototype.update=function(e,r){if(null!=e){void 0===r&&(r=e.length);for(var t=r-this.blockSize,o=0,n=this.buf_,i=this.inbuf_;o<r;){if(0===i)for(;o<=t;)this.compress_(e,o),o+=this.blockSize;if("string"==typeof e){for(;o<r;)if(n[i]=e.charCodeAt(o),++o,++i===this.blockSize){this.compress_(n),i=0;break}}else for(;o<r;)if(n[i]=e[o],++o,++i===this.blockSize){this.compress_(n),i=0;break}}this.inbuf_=i,this.total_+=r}},e.prototype.digest=function(){var e=[],r=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(var t=this.blockSize-1;t>=56;t--)this.buf_[t]=255&r,r/=256;this.compress_(this.buf_);var o=0;for(t=0;t<5;t++)for(var n=24;n>=0;n-=8)e[o]=this.chain_[t]>>n&255,++o;return e},e}();function Z(e,r){var t=new ee(e,r);return t.subscribe.bind(t)}exports.Sha1=Y;var ee=function(){function e(e,r){var t=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=r,this.task.then(function(){e(t)}).catch(function(e){t.error(e)})}return e.prototype.next=function(e){this.forEachObserver(function(r){r.next(e)})},e.prototype.error=function(e){this.forEachObserver(function(r){r.error(e)}),this.close(e)},e.prototype.complete=function(){this.forEachObserver(function(e){e.complete()}),this.close()},e.prototype.subscribe=function(e,r,t){var o,n=this;if(void 0===e&&void 0===r&&void 0===t)throw new Error("Missing Observer.");void 0===(o=te(e,["next","error","complete"])?e:{next:e,error:r,complete:t}).next&&(o.next=oe),void 0===o.error&&(o.error=oe),void 0===o.complete&&(o.complete=oe);var i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(function(){try{n.finalError?o.error(n.finalError):o.complete()}catch(e){}}),this.observers.push(o),i},e.prototype.unsubscribeOne=function(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))},e.prototype.forEachObserver=function(e){if(!this.finalized)for(var r=0;r<this.observers.length;r++)this.sendOne(r,e)},e.prototype.sendOne=function(e,r){var t=this;this.task.then(function(){if(void 0!==t.observers&&void 0!==t.observers[e])try{r(t.observers[e])}catch(o){"undefined"!=typeof console&&console.error&&console.error(o)}})},e.prototype.close=function(e){var r=this;this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then(function(){r.observers=void 0,r.onNoObservers=void 0}))},e}();function re(e,r){return function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];Promise.resolve(!0).then(function(){e.apply(void 0,t)}).catch(function(e){r&&r(e)})}}function te(e,r){if("object"!=typeof e||null===e)return!1;for(var t=0,o=r;t<o.length;t++){var n=o[t];if(n in e&&"function"==typeof e[n])return!0}return!1}function oe(){}var ne=function(e,r,t,o){var n;if(o<r?n="at least "+r:o>t&&(n=0===t?"none":"no more than "+t),n)throw new Error(e+" failed: Was called with "+o+(1===o?" argument.":" arguments.")+" Expects "+n+".")};function ie(e,r){return e+" failed: "+r+" argument "}function se(e,r,t){if((!t||r)&&"string"!=typeof r)throw new Error(ie(e,"namespace")+"must be a valid firebase namespace.")}function ae(e,r,t,o){if((!o||t)&&"function"!=typeof t)throw new Error(ie(e,r)+"must be a valid function.")}function ce(e,r,t,o){if((!o||t)&&("object"!=typeof t||null===t))throw new Error(ie(e,r)+"must be a valid context object.")}exports.validateArgCount=ne;var ue=function(e){for(var r=[],t=0,n=0;n<e.length;n++){var i=e.charCodeAt(n);if(i>=55296&&i<=56319){var s=i-55296;o(++n<e.length,"Surrogate pair missing trail surrogate."),i=65536+(s<<10)+(e.charCodeAt(n)-56320)}i<128?r[t++]=i:i<2048?(r[t++]=i>>6|192,r[t++]=63&i|128):i<65536?(r[t++]=i>>12|224,r[t++]=i>>6&63|128,r[t++]=63&i|128):(r[t++]=i>>18|240,r[t++]=i>>12&63|128,r[t++]=i>>6&63|128,r[t++]=63&i|128)}return r};exports.stringToByteArray=ue;var he=function(e){for(var r=0,t=0;t<e.length;t++){var o=e.charCodeAt(t);o<128?r++:o<2048?r+=2:o>=55296&&o<=56319?(r+=4,t++):r+=3}return r};exports.stringLength=he;var fe=1e3,pe=2,de=144e5;exports.MAX_VALUE_MILLIS=de;var le=.5;function ve(e,r,t){void 0===r&&(r=fe),void 0===t&&(t=pe);var o=r*Math.pow(t,e),n=Math.round(le*o*(Math.random()-.5)*2);return Math.min(de,o+n)}function be(e){return Number.isFinite(e)?e+_e(e):""+e}function _e(e){var r=(e=Math.abs(e))%100;if(r>=10&&r<=20)return"th";var t=e%10;return 1===t?"st":2===t?"nd":3===t?"rd":"th"}function ye(e){return e&&e._delegate?e._delegate:e}exports.RANDOM_FACTOR=le;
|
|
466
|
-
},{"tslib":"f2sD"}],"sLOu":[function(require,module,exports) {
|
|
467
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Provider=exports.ComponentContainer=exports.Component=void 0;var t=require("tslib"),e=require("@firebase/util"),n=function(){function t(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}return t.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},t.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},t.prototype.setServiceProps=function(t){return this.serviceProps=t,this},t.prototype.setInstanceCreatedCallback=function(t){return this.onInstanceCreated=t,this},t}();exports.Component=n;var i="[DEFAULT]",r=function(){function n(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}return n.prototype.get=function(t){var n=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(n)){var i=new e.Deferred;if(this.instancesDeferred.set(n,i),this.isInitialized(n)||this.shouldAutoInitialize())try{var r=this.getOrInitializeService({instanceIdentifier:n});r&&i.resolve(r)}catch(o){}}return this.instancesDeferred.get(n).promise},n.prototype.getImmediate=function(t){var e,n=this.normalizeInstanceIdentifier(null==t?void 0:t.identifier),i=null!==(e=null==t?void 0:t.optional)&&void 0!==e&&e;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(i)return null;throw Error("Service "+this.name+" is not available")}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(r){if(i)return null;throw r}},n.prototype.getComponent=function(){return this.component},n.prototype.setComponent=function(e){var n,r;if(e.name!==this.name)throw Error("Mismatching Component "+e.name+" for Provider "+this.name+".");if(this.component)throw Error("Component for "+this.name+" has already been provided");if(this.component=e,this.shouldAutoInitialize()){if(s(e))try{this.getOrInitializeService({instanceIdentifier:i})}catch(u){}try{for(var o=(0,t.__values)(this.instancesDeferred.entries()),a=o.next();!a.done;a=o.next()){var c=(0,t.__read)(a.value,2),h=c[0],l=c[1],p=this.normalizeInstanceIdentifier(h);try{var d=this.getOrInitializeService({instanceIdentifier:p});l.resolve(d)}catch(u){}}}catch(f){n={error:f}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}},n.prototype.clearInstance=function(t){void 0===t&&(t=i),this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)},n.prototype.delete=function(){return(0,t.__awaiter)(this,void 0,void 0,function(){var e;return(0,t.__generator)(this,function(n){switch(n.label){case 0:return e=Array.from(this.instances.values()),[4,Promise.all((0,t.__spreadArray)((0,t.__spreadArray)([],(0,t.__read)(e.filter(function(t){return"INTERNAL"in t}).map(function(t){return t.INTERNAL.delete()}))),(0,t.__read)(e.filter(function(t){return"_delete"in t}).map(function(t){return t._delete()}))))];case 1:return n.sent(),[2]}})})},n.prototype.isComponentSet=function(){return null!=this.component},n.prototype.isInitialized=function(t){return void 0===t&&(t=i),this.instances.has(t)},n.prototype.getOptions=function(t){return void 0===t&&(t=i),this.instancesOptions.get(t)||{}},n.prototype.initialize=function(e){var n,i;void 0===e&&(e={});var r=e.options,o=void 0===r?{}:r,s=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(s))throw Error(this.name+"("+s+") has already been initialized");if(!this.isComponentSet())throw Error("Component "+this.name+" has not been registered yet");var a=this.getOrInitializeService({instanceIdentifier:s,options:o});try{for(var c=(0,t.__values)(this.instancesDeferred.entries()),h=c.next();!h.done;h=c.next()){var l=(0,t.__read)(h.value,2),p=l[0],d=l[1];s===this.normalizeInstanceIdentifier(p)&&d.resolve(a)}}catch(u){n={error:u}}finally{try{h&&!h.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}return a},n.prototype.onInit=function(t,e){var n,i=this.normalizeInstanceIdentifier(e),r=null!==(n=this.onInitCallbacks.get(i))&&void 0!==n?n:new Set;r.add(t),this.onInitCallbacks.set(i,r);var o=this.instances.get(i);return o&&t(o,i),function(){r.delete(t)}},n.prototype.invokeOnInitCallbacks=function(e,n){var i,r,o=this.onInitCallbacks.get(n);if(o)try{for(var s=(0,t.__values)(o),a=s.next();!a.done;a=s.next()){var c=a.value;try{c(e,n)}catch(h){}}}catch(l){i={error:l}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}},n.prototype.getOrInitializeService=function(t){var e=t.instanceIdentifier,n=t.options,i=void 0===n?{}:n,r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:o(e),options:i}),this.instances.set(e,r),this.instancesOptions.set(e,i),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch(s){}return r||null},n.prototype.normalizeInstanceIdentifier=function(t){return void 0===t&&(t=i),this.component?this.component.multipleInstances?t:i:t},n.prototype.shouldAutoInitialize=function(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode},n}();function o(t){return t===i?void 0:t}function s(t){return"EAGER"===t.instantiationMode}exports.Provider=r;var a=function(){function t(t){this.name=t,this.providers=new Map}return t.prototype.addComponent=function(t){var e=this.getProvider(t.name);if(e.isComponentSet())throw new Error("Component "+t.name+" has already been registered with "+this.name);e.setComponent(t)},t.prototype.addOrOverwriteComponent=function(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)},t.prototype.getProvider=function(t){if(this.providers.has(t))return this.providers.get(t);var e=new r(t,this);return this.providers.set(t,e),e},t.prototype.getProviders=function(){return Array.from(this.providers.values())},t}();exports.ComponentContainer=a;
|
|
468
|
-
},{"tslib":"f2sD","@firebase/util":"KxmD"}],"TUpU":[function(require,module,exports) {
|
|
469
|
-
"use strict";function e(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var o=Array(e),n=0;for(t=0;t<r;t++)for(var l=arguments[t],i=0,s=l.length;i<s;i++,n++)o[n]=l[i];return o}var t;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Logger=exports.LogLevel=void 0,exports.setLogLevel=g,exports.setUserLogHandler=u;var r,o=[];exports.LogLevel=r,function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(r||(exports.LogLevel=r={}));var n={debug:r.DEBUG,verbose:r.VERBOSE,info:r.INFO,warn:r.WARN,error:r.ERROR,silent:r.SILENT},l=r.INFO,i=((t={})[r.DEBUG]="log",t[r.VERBOSE]="log",t[r.INFO]="info",t[r.WARN]="warn",t[r.ERROR]="error",t),s=function(t,r){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];if(!(r<t.logLevel)){var l=(new Date).toISOString(),s=i[r];if(!s)throw new Error("Attempted to log a message with an invalid logType (value: "+r+")");console[s].apply(console,e(["["+l+"] "+t.name+":"],o))}},a=function(){function t(e){this.name=e,this._logLevel=l,this._logHandler=s,this._userLogHandler=null,o.push(this)}return Object.defineProperty(t.prototype,"logLevel",{get:function(){return this._logLevel},set:function(e){if(!(e in r))throw new TypeError('Invalid value "'+e+'" assigned to `logLevel`');this._logLevel=e},enumerable:!1,configurable:!0}),t.prototype.setLogLevel=function(e){this._logLevel="string"==typeof e?n[e]:e},Object.defineProperty(t.prototype,"logHandler",{get:function(){return this._logHandler},set:function(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userLogHandler",{get:function(){return this._userLogHandler},set:function(e){this._userLogHandler=e},enumerable:!1,configurable:!0}),t.prototype.debug=function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];this._userLogHandler&&this._userLogHandler.apply(this,e([this,r.DEBUG],t)),this._logHandler.apply(this,e([this,r.DEBUG],t))},t.prototype.log=function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];this._userLogHandler&&this._userLogHandler.apply(this,e([this,r.VERBOSE],t)),this._logHandler.apply(this,e([this,r.VERBOSE],t))},t.prototype.info=function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];this._userLogHandler&&this._userLogHandler.apply(this,e([this,r.INFO],t)),this._logHandler.apply(this,e([this,r.INFO],t))},t.prototype.warn=function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];this._userLogHandler&&this._userLogHandler.apply(this,e([this,r.WARN],t)),this._logHandler.apply(this,e([this,r.WARN],t))},t.prototype.error=function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];this._userLogHandler&&this._userLogHandler.apply(this,e([this,r.ERROR],t)),this._logHandler.apply(this,e([this,r.ERROR],t))},t}();function g(e){o.forEach(function(t){t.setLogLevel(e)})}function u(e,t){for(var l=function(o){var l=null;t&&t.level&&(l=n[t.level]),o.userLogHandler=null===e?null:function(t,o){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var s=n.map(function(e){if(null==e)return null;if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return e.toString();if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch(t){return null}}).filter(function(e){return e}).join(" ");o>=(null!=l?l:t.logLevel)&&e({level:r[o].toLowerCase(),message:s,args:n,type:t.name})}},i=0,s=o;i<s.length;i++){l(s[i])}}exports.Logger=a;
|
|
470
|
-
},{}],"VxYX":[function(require,module,exports) {
|
|
471
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.firebase=exports.default=void 0;var e,n,t=require("tslib"),r=require("@firebase/util"),i=require("@firebase/component"),a=require("@firebase/logger"),o=((e={})["no-app"]="No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()",e["bad-app-name"]="Illegal App name: '{$appName}",e["duplicate-app"]="Firebase App named '{$appName}' already exists",e["app-deleted"]="Firebase App named '{$appName}' already deleted",e["invalid-app-argument"]="firebase.{$appName}() takes either no argument or a Firebase App instance.",e["invalid-log-argument"]="First argument to `onLog` must be null or a function.",e),s=new r.ErrorFactory("app","Firebase",o),p="@firebase/app",c="0.6.30",l="@firebase/analytics",u="@firebase/app-check",f="@firebase/auth",d="@firebase/database",m="@firebase/functions",b="@firebase/installations",h="@firebase/messaging",g="@firebase/performance",v="@firebase/remote-config",y="@firebase/storage",_="@firebase/firestore",w="firebase-wrapper",N="[DEFAULT]",C=((n={})[p]="fire-core",n[l]="fire-analytics",n[u]="fire-app-check",n[f]="fire-auth",n[d]="fire-rtdb",n[m]="fire-fn",n[b]="fire-iid",n[h]="fire-fcm",n[g]="fire-perf",n[v]="fire-rc",n[y]="fire-gcs",n[_]="fire-fst",n["fire-js"]="fire-js",n[w]="fire-js-all",n),E=new a.Logger("@firebase/app"),I=function(){function e(e,n,t){var a=this;this.firebase_=t,this.isDeleted_=!1,this.name_=n.name,this.automaticDataCollectionEnabled_=n.automaticDataCollectionEnabled||!1,this.options_=(0,r.deepCopy)(e),this.container=new i.ComponentContainer(n.name),this._addComponent(new i.Component("app",function(){return a},"PUBLIC")),this.firebase_.INTERNAL.components.forEach(function(e){return a._addComponent(e)})}return Object.defineProperty(e.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this.automaticDataCollectionEnabled_},set:function(e){this.checkDestroyed_(),this.automaticDataCollectionEnabled_=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!1,configurable:!0}),e.prototype.delete=function(){var e=this;return new Promise(function(n){e.checkDestroyed_(),n()}).then(function(){return e.firebase_.INTERNAL.removeApp(e.name_),Promise.all(e.container.getProviders().map(function(e){return e.delete()}))}).then(function(){e.isDeleted_=!0})},e.prototype._getService=function(e,n){var t;void 0===n&&(n=N),this.checkDestroyed_();var r=this.container.getProvider(e);return r.isInitialized()||"EXPLICIT"!==(null===(t=r.getComponent())||void 0===t?void 0:t.instantiationMode)||r.initialize(),r.getImmediate({identifier:n})},e.prototype._removeServiceInstance=function(e,n){void 0===n&&(n=N),this.container.getProvider(e).clearInstance(n)},e.prototype._addComponent=function(e){try{this.container.addComponent(e)}catch(n){E.debug("Component "+e.name+" failed to register with FirebaseApp "+this.name,n)}},e.prototype._addOrOverwriteComponent=function(e){this.container.addOrOverwriteComponent(e)},e.prototype.toJSON=function(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}},e.prototype.checkDestroyed_=function(){if(this.isDeleted_)throw s.create("app-deleted",{appName:this.name_})},e}();I.prototype.name&&I.prototype.options||I.prototype.delete||console.log("dc");var A="8.10.0";function P(e){var n={},t=new Map,o={__esModule:!0,initializeApp:function(t,i){void 0===i&&(i={});if("object"!=typeof i||null===i){var a=i;i={name:a}}var p=i;void 0===p.name&&(p.name=N);var c=p.name;if("string"!=typeof c||!c)throw s.create("bad-app-name",{appName:String(c)});if((0,r.contains)(n,c))throw s.create("duplicate-app",{appName:c});var l=new e(t,p,o);return n[c]=l,l},app:p,registerVersion:function(e,n,t){var r,a=null!==(r=C[e])&&void 0!==r?r:e;t&&(a+="-"+t);var o=a.match(/\s|\//),s=n.match(/\s|\//);if(o||s){var p=['Unable to register library "'+a+'" with version "'+n+'":'];return o&&p.push('library name "'+a+'" contains illegal characters (whitespace or "/")'),o&&s&&p.push("and"),s&&p.push('version name "'+n+'" contains illegal characters (whitespace or "/")'),void E.warn(p.join(" "))}c(new i.Component(a+"-version",function(){return{library:a,version:n}},"VERSION"))},setLogLevel:a.setLogLevel,onLog:function(e,n){if(null!==e&&"function"!=typeof e)throw s.create("invalid-log-argument");(0,a.setUserLogHandler)(e,n)},apps:null,SDK_VERSION:A,INTERNAL:{registerComponent:c,removeApp:function(e){delete n[e]},components:t,useAsService:function(e,n){if("serverAuth"===n)return null;return n}}};function p(e){if(e=e||N,!(0,r.contains)(n,e))throw s.create("no-app",{appName:e});return n[e]}function c(i){var a=i.name;if(t.has(a))return E.debug("There were multiple attempts to register component "+a+"."),"PUBLIC"===i.type?o[a]:null;if(t.set(a,i),"PUBLIC"===i.type){var c=function(e){if(void 0===e&&(e=p()),"function"!=typeof e[a])throw s.create("invalid-app-argument",{appName:a});return e[a]()};void 0!==i.serviceProps&&(0,r.deepExtend)(c,i.serviceProps),o[a]=c,e.prototype[a]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return this._getService.bind(this,a).apply(this,i.multipleInstances?e:[])}}for(var l=0,u=Object.keys(n);l<u.length;l++){var f=u[l];n[f]._addComponent(i)}return"PUBLIC"===i.type?o[a]:null}return o.default=o,Object.defineProperty(o,"apps",{get:function(){return Object.keys(n).map(function(e){return n[e]})}}),p.App=e,o}function F(){var e=P(I);return e.INTERNAL=(0,t.__assign)((0,t.__assign)({},e.INTERNAL),{createFirebaseNamespace:F,extendNamespace:function(n){(0,r.deepExtend)(e,n)},createSubscribe:r.createSubscribe,ErrorFactory:r.ErrorFactory,deepExtend:r.deepExtend}),e}var L=F(),D=function(){function e(e){this.container=e}return e.prototype.getPlatformInfoString=function(){return this.container.getProviders().map(function(e){if(k(e)){var n=e.getImmediate();return n.library+"/"+n.version}return null}).filter(function(e){return e}).join(" ")},e}();function k(e){var n=e.getComponent();return"VERSION"===(null==n?void 0:n.type)}function O(e,n){e.INTERNAL.registerComponent(new i.Component("platform-logger",function(e){return new D(e)},"PRIVATE")),e.registerVersion(p,c,n),e.registerVersion("fire-js","")}if((0,r.isBrowser)()&&void 0!==self.firebase){E.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n ");var j=self.firebase.SDK_VERSION;j&&j.indexOf("LITE")>=0&&E.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n ")}var S=L.initializeApp;L.initializeApp=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return(0,r.isNode)()&&E.warn('\n Warning: This is a browser-targeted Firebase bundle but it appears it is being\n run in a Node environment. If running in a Node environment, make sure you\n are using the bundle specified by the "main" field in package.json.\n \n If you are using Webpack, you can specify "main" as the first item in\n "resolve.mainFields":\n https://webpack.js.org/configuration/resolve/#resolvemainfields\n \n If using Rollup, use the @rollup/plugin-node-resolve plugin and specify "main"\n as the first item in "mainFields", e.g. [\'main\', \'module\'].\n https://github.com/rollup/@rollup/plugin-node-resolve\n '),S.apply(void 0,e)};var x=L;exports.firebase=x,O(x);var R=x;exports.default=R;
|
|
472
|
-
},{"tslib":"f2sD","@firebase/util":"KxmD","@firebase/component":"sLOu","@firebase/logger":"TUpU"}],"OJEJ":[function(require,module,exports) {
|
|
473
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e.default}});var e=r(require("@firebase/app"));function r(e){return e&&e.__esModule?e:{default:e}}var t="firebase",u="8.10.1";e.default.registerVersion(t,u,"app"),e.default.SDK_VERSION=u;
|
|
474
|
-
},{"@firebase/app":"VxYX"}],"EMWj":[function(require,module,exports) {
|
|
475
463
|
var process = require("process");
|
|
476
|
-
var e=require("process");Object.defineProperty(exports,"__esModule",{value:!0}),exports.enableLogging=exports.ServerValue=exports.Reference=exports.Query=exports.OnDisconnect=exports.Database=exports.DataSnapshot=void 0,exports.registerDatabase=nl;var t=a(require("@firebase/app")),n=require("@firebase/component"),r=require("@firebase/util"),i=require("tslib"),o=require("@firebase/logger");function a(e){return e&&e.__esModule?e:{default:e}}var s="@firebase/database",u="0.11.0",l="";function c(e){l=e}var h=function(){function e(e){this.domStorage_=e,this.prefix_="firebase:"}return e.prototype.set=function(e,t){null==t?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),(0,r.stringify)(t))},e.prototype.get=function(e){var t=this.domStorage_.getItem(this.prefixedName_(e));return null==t?null:(0,r.jsonEval)(t)},e.prototype.remove=function(e){this.domStorage_.removeItem(this.prefixedName_(e))},e.prototype.prefixedName_=function(e){return this.prefix_+e},e.prototype.toString=function(){return this.domStorage_.toString()},e}(),d=function(){function e(){this.cache_={},this.isInMemoryStorage=!0}return e.prototype.set=function(e,t){null==t?delete this.cache_[e]:this.cache_[e]=t},e.prototype.get=function(e){return(0,r.contains)(this.cache_,e)?this.cache_[e]:null},e.prototype.remove=function(e){delete this.cache_[e]},e}(),p=function(e){try{if("undefined"!=typeof window&&void 0!==window[e]){var t=window[e];return t.setItem("firebase:sentinel","cache"),t.removeItem("firebase:sentinel"),new h(t)}}catch(n){}return new d},f=p("localStorage"),_=p("sessionStorage"),v=new o.Logger("@firebase/database"),y=function(){var e=1;return function(){return e++}}(),g=function(e){var t=(0,r.stringToByteArray)(e),n=new r.Sha1;n.update(t);var i=n.digest();return r.base64.encodeByteArray(i)},m=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n="",i=0;i<e.length;i++){var o=e[i];Array.isArray(o)||o&&"object"==typeof o&&"number"==typeof o.length?n+=m.apply(null,o):n+="object"==typeof o?(0,r.stringify)(o):o,n+=" "}return n},C=null,w=!0,b=function(e,t){(0,r.assert)(!t||!0===e||!1===e,"Can't turn on custom loggers persistently."),!0===e?(v.logLevel=o.LogLevel.VERBOSE,C=v.log.bind(v),t&&_.set("logging_enabled",!0)):"function"==typeof e?C=e:(C=null,_.remove("logging_enabled"))};exports.enableLogging=b;var T=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(!0===w&&(w=!1,null===C&&!0===_.get("logging_enabled")&&b(!0)),C){var n=m.apply(null,e);C(n)}},k=function(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];T.apply(void 0,(0,i.__spreadArray)([e],(0,i.__read)(t)))}},I=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n="FIREBASE INTERNAL ERROR: "+m.apply(void 0,(0,i.__spreadArray)([],(0,i.__read)(e)));v.error(n)},E=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n="FIREBASE FATAL ERROR: "+m.apply(void 0,(0,i.__spreadArray)([],(0,i.__read)(e)));throw v.error(n),new Error(n)},S=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n="FIREBASE WARNING: "+m.apply(void 0,(0,i.__spreadArray)([],(0,i.__read)(e)));v.warn(n)},P=function(){"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&S("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},x=function(e){return"number"==typeof e&&(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},N=function(e){if((0,r.isNodeSdk)()||"complete"===document.readyState)e();else{var t=!1,n=function(){document.body?t||(t=!0,e()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&n()}),window.attachEvent("onload",n))}},R="[MIN_NAME]",A="[MAX_NAME]",D=function(e,t){if(e===t)return 0;if(e===R||t===A)return-1;if(t===R||e===A)return 1;var n=z(e),r=z(t);return null!==n?null!==r?n-r==0?e.length-t.length:n-r:-1:null!==r?1:e<t?-1:1},O=function(e,t){return e===t?0:e<t?-1:1},M=function(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+(0,r.stringify)(t))},q=function(e){if("object"!=typeof e||null===e)return(0,r.stringify)(e);var t=[];for(var n in e)t.push(n);t.sort();for(var i="{",o=0;o<t.length;o++)0!==o&&(i+=","),i+=(0,r.stringify)(t[o]),i+=":",i+=q(e[t[o]]);return i+="}"},F=function(e,t){var n=e.length;if(n<=t)return[e];for(var r=[],i=0;i<n;i+=t)i+t>n?r.push(e.substring(i,n)):r.push(e.substring(i,i+t));return r};function L(e,t){for(var n in e)e.hasOwnProperty(n)&&t(n,e[n])}var W=function(e){(0,r.assert)(!x(e),"Invalid JSON number");var t,n,i,o,a;0===e?(n=0,i=0,t=1/e==-1/0?1:0):(t=e<0,(e=Math.abs(e))>=Math.pow(2,-1022)?(n=(o=Math.min(Math.floor(Math.log(e)/Math.LN2),1023))+1023,i=Math.round(e*Math.pow(2,52-o)-Math.pow(2,52))):(n=0,i=Math.round(e/Math.pow(2,-1074))));var s=[];for(a=52;a;a-=1)s.push(i%2?1:0),i=Math.floor(i/2);for(a=11;a;a-=1)s.push(n%2?1:0),n=Math.floor(n/2);s.push(t?1:0),s.reverse();var u=s.join(""),l="";for(a=0;a<64;a+=8){var c=parseInt(u.substr(a,8),2).toString(16);1===c.length&&(c="0"+c),l+=c}return l.toLowerCase()},j=function(){return!("object"!=typeof window||!window.chrome||!window.chrome.extension||/^chrome/.test(window.location.href))},U=function(){return"object"==typeof Windows&&"object"==typeof Windows.UI};function B(e,t){var n="Unknown Error";"too_big"===e?n="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"===e?n="Client doesn't have permission to access the desired data.":"unavailable"===e&&(n="The service is unavailable");var r=new Error(e+" at "+t._path.toString()+": "+n);return r.code=e.toUpperCase(),r}var V=new RegExp("^-?(0*)\\d{1,10}$"),Q=-2147483648,H=2147483647,z=function(e){if(V.test(e)){var t=Number(e);if(t>=Q&&t<=H)return t}return null},Y=function(e){try{e()}catch(t){setTimeout(function(){var e=t.stack||"";throw S("Exception was thrown by user callback.",e),t},Math.floor(0))}},K=function(){return("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},G=function(e,t){var n=setTimeout(e,t);return"object"==typeof n&&n.unref&&n.unref(),n},$=function(){function e(e,t){var n=this;this.appName_=e,this.appCheckProvider=t,this.appCheck=null==t?void 0:t.getImmediate({optional:!0}),this.appCheck||null==t||t.get().then(function(e){return n.appCheck=e})}return e.prototype.getToken=function(e){var t=this;return this.appCheck?this.appCheck.getToken(e):new Promise(function(n,r){setTimeout(function(){t.appCheck?t.getToken(e).then(n,r):n(null)},0)})},e.prototype.addTokenChangeListener=function(e){var t;null===(t=this.appCheckProvider)||void 0===t||t.get().then(function(t){return t.addTokenListener(e)})},e.prototype.notifyForInvalidToken=function(){S('Provided AppCheck credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly.')},e}(),J=function(){function e(e,t,n){var r=this;this.appName_=e,this.firebaseOptions_=t,this.authProvider_=n,this.auth_=null,this.auth_=n.getImmediate({optional:!0}),this.auth_||n.onInit(function(e){return r.auth_=e})}return e.prototype.getToken=function(e){var t=this;return this.auth_?this.auth_.getToken(e).catch(function(e){return e&&"auth/token-not-initialized"===e.code?(T("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(e)}):new Promise(function(n,r){setTimeout(function(){t.auth_?t.getToken(e).then(n,r):n(null)},0)})},e.prototype.addTokenChangeListener=function(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then(function(t){return t.addAuthTokenListener(e)})},e.prototype.removeTokenChangeListener=function(e){this.authProvider_.get().then(function(t){return t.removeAuthTokenListener(e)})},e.prototype.notifyForInvalidToken=function(){var e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',S(e)},e}(),X=function(){function e(e){this.accessToken=e}return e.prototype.getToken=function(e){return Promise.resolve({accessToken:this.accessToken})},e.prototype.addTokenChangeListener=function(e){e(this.accessToken)},e.prototype.removeTokenChangeListener=function(e){},e.prototype.notifyForInvalidToken=function(){},e.OWNER="owner",e}(),Z="5",ee="v",te="s",ne="r",re="f",ie=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,oe="ls",ae="p",se="ac",ue="websocket",le="long_polling",ce=function(){function e(e,t,n,r,i,o,a){void 0===i&&(i=!1),void 0===o&&(o=""),void 0===a&&(a=!1),this.secure=t,this.namespace=n,this.webSocketOnly=r,this.nodeAdmin=i,this.persistenceKey=o,this.includeNamespaceInQueryParams=a,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=f.get("host:"+e)||this._host}return e.prototype.isCacheableHost=function(){return"s-"===this.internalHost.substr(0,2)},e.prototype.isCustomHost=function(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain},Object.defineProperty(e.prototype,"host",{get:function(){return this._host},set:function(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&f.set("host:"+this._host,this.internalHost))},enumerable:!1,configurable:!0}),e.prototype.toString=function(){var e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e},e.prototype.toURLString=function(){var e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?"?ns="+this.namespace:"";return""+e+this.host+"/"+t},e}();function he(e){return e.host!==e.internalHost||e.isCustomHost()||e.includeNamespaceInQueryParams}function de(e,t,n){var i;if((0,r.assert)("string"==typeof t,"typeof type must == string"),(0,r.assert)("object"==typeof n,"typeof params must == object"),t===ue)i=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==le)throw new Error("Unknown connection type: "+t);i=(e.secure?"https://":"http://")+e.internalHost+"/.lp?"}he(e)&&(n.ns=e.namespace);var o=[];return L(n,function(e,t){o.push(e+"="+t)}),i+o.join("&")}var pe=function(){function e(){this.counters_={}}return e.prototype.incrementCounter=function(e,t){void 0===t&&(t=1),(0,r.contains)(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t},e.prototype.get=function(){return(0,r.deepCopy)(this.counters_)},e}(),fe={},_e={};function ve(e){var t=e.toString();return fe[t]||(fe[t]=new pe),fe[t]}function ye(e,t){var n=e.toString();return _e[n]||(_e[n]=t()),_e[n]}var ge=function(){function e(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}return e.prototype.closeAfter=function(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)},e.prototype.handleResponse=function(e,t){var n=this;this.pendingResponses[e]=t;for(var r=function(){var e=i.pendingResponses[i.currentResponseNum];delete i.pendingResponses[i.currentResponseNum];for(var t=function(t){e[t]&&Y(function(){n.onMessage_(e[t])})},r=0;r<e.length;++r)t(r);if(i.currentResponseNum===i.closeAfterResponse)return i.onClose&&(i.onClose(),i.onClose=null),"break";i.currentResponseNum++},i=this;this.pendingResponses[this.currentResponseNum];){if("break"===r())break}},e}(),me="start",Ce="close",we="pLPCommand",be="pRTLPCB",Te="id",ke="pw",Ie="ser",Ee="cb",Se="seg",Pe="ts",xe="d",Ne="dframe",Re=1870,Ae=30,De=Re-Ae,Oe=25e3,Me=3e4,qe=function(){function e(e,t,n,r,i,o,a){var s=this;this.connId=e,this.repoInfo=t,this.applicationId=n,this.appCheckToken=r,this.authToken=i,this.transportSessionId=o,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=k(e),this.stats_=ve(t),this.urlFn=function(e){return s.appCheckToken&&(e[se]=s.appCheckToken),de(t,le,e)}}return e.prototype.open=function(e,t){var n=this;this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new ge(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(function(){n.log_("Timed out trying to connect."),n.onClosed_(),n.connectTimeoutTimer_=null},Math.floor(Me)),N(function(){if(!n.isClosed_){n.scriptTagHolder=new Fe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=(0,i.__read)(e,5),o=r[0],a=r[1],s=r[2];if(r[3],r[4],n.incrementIncomingBytes_(e),n.scriptTagHolder)if(n.connectTimeoutTimer_&&(clearTimeout(n.connectTimeoutTimer_),n.connectTimeoutTimer_=null),n.everConnected_=!0,o===me)n.id=a,n.password=s;else{if(o!==Ce)throw new Error("Unrecognized command received: "+o);a?(n.scriptTagHolder.sendNewPolls=!1,n.myPacketOrderer.closeAfter(a,function(){n.onClosed_()})):n.onClosed_()}},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=(0,i.__read)(e,2),o=r[0],a=r[1];n.incrementIncomingBytes_(e),n.myPacketOrderer.handleResponse(o,a)},function(){n.onClosed_()},n.urlFn);var e={};e[me]="t",e[Ie]=Math.floor(1e8*Math.random()),n.scriptTagHolder.uniqueCallbackIdentifier&&(e[Ee]=n.scriptTagHolder.uniqueCallbackIdentifier),e[ee]=Z,n.transportSessionId&&(e[te]=n.transportSessionId),n.lastSessionId&&(e[oe]=n.lastSessionId),n.applicationId&&(e[ae]=n.applicationId),n.appCheckToken&&(e[se]=n.appCheckToken),"undefined"!=typeof location&&location.hostname&&ie.test(location.hostname)&&(e[ne]=re);var t=n.urlFn(e);n.log_("Connecting via long-poll to "+t),n.scriptTagHolder.addTag(t,function(){})}})},e.prototype.start=function(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)},e.forceAllow=function(){e.forceAllow_=!0},e.forceDisallow=function(){e.forceDisallow_=!0},e.isAvailable=function(){return!(0,r.isNodeSdk)()&&(!!e.forceAllow_||!e.forceDisallow_&&"undefined"!=typeof document&&null!=document.createElement&&!j()&&!U())},e.prototype.markConnectionHealthy=function(){},e.prototype.shutdown_=function(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)},e.prototype.onClosed_=function(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))},e.prototype.close=function(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())},e.prototype.send=function(e){var t=(0,r.stringify)(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);for(var n=(0,r.base64Encode)(t),i=F(n,De),o=0;o<i.length;o++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[o]),this.curSegmentNum++},e.prototype.addDisconnectPingFrame=function(e,t){if(!(0,r.isNodeSdk)()){this.myDisconnFrame=document.createElement("iframe");var n={};n[Ne]="t",n[Te]=e,n[ke]=t,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}},e.prototype.incrementIncomingBytes_=function(e){var t=(0,r.stringify)(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)},e}(),Fe=function(){function e(t,n,i,o){if(this.onDisconnect=i,this.urlFn=o,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0,(0,r.isNodeSdk)())this.commandCB=t,this.onMessageCB=n;else{this.uniqueCallbackIdentifier=y(),window[we+this.uniqueCallbackIdentifier]=t,window[be+this.uniqueCallbackIdentifier]=n,this.myIFrame=e.createIFrame_();var a="";if(this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,"javascript:".length))a='<script>document.domain="'+document.domain+'";<\/script>';var s="<html><body>"+a+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(s),this.myIFrame.doc.close()}catch(u){T("frame writing exception"),u.stack&&T(u.stack),T(u)}}}return e.createIFrame_=function(){var e=document.createElement("iframe");if(e.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(e);try{e.contentWindow.document||T("No IE domain setting required")}catch(n){var t=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+t+"';document.close();})())"}return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e},e.prototype.close=function(){var e=this;this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.innerHTML="",setTimeout(function(){null!==e.myIFrame&&(document.body.removeChild(e.myIFrame),e.myIFrame=null)},Math.floor(0)));var t=this.onDisconnect;t&&(this.onDisconnect=null,t())},e.prototype.startLongPoll=function(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););},e.prototype.newRequest_=function(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;var e={};e[Te]=this.myID,e[ke]=this.myPW,e[Ie]=this.currentSerial;for(var t=this.urlFn(e),n="",r=0;this.pendingSegs.length>0;){if(!(this.pendingSegs[0].d.length+Ae+n.length<=Re))break;var i=this.pendingSegs.shift();n=n+"&"+Se+r+"="+i.seg+"&"+Pe+r+"="+i.ts+"&"+xe+r+"="+i.d,r++}return t+=n,this.addLongPollTag_(t,this.currentSerial),!0}return!1},e.prototype.enqueueSegment=function(e,t,n){this.pendingSegs.push({seg:e,ts:t,d:n}),this.alive&&this.newRequest_()},e.prototype.addLongPollTag_=function(e,t){var n=this;this.outstandingRequests.add(t);var r=function(){n.outstandingRequests.delete(t),n.newRequest_()},i=setTimeout(r,Math.floor(Oe));this.addTag(e,function(){clearTimeout(i),r()})},e.prototype.addTag=function(e,t){var n=this;(0,r.isNodeSdk)()?this.doNodeLongPoll(e,t):setTimeout(function(){try{if(!n.sendNewPolls)return;var r=n.myIFrame.doc.createElement("script");r.type="text/javascript",r.async=!0,r.src=e,r.onload=r.onreadystatechange=function(){var e=r.readyState;e&&"loaded"!==e&&"complete"!==e||(r.onload=r.onreadystatechange=null,r.parentNode&&r.parentNode.removeChild(r),t())},r.onerror=function(){T("Long-poll script failed to load: "+e),n.sendNewPolls=!1,n.close()},n.myIFrame.doc.body.appendChild(r)}catch(i){}},Math.floor(1))},e}(),Le=16384,We=45e3,je=null;"undefined"!=typeof MozWebSocket?je=MozWebSocket:"undefined"!=typeof WebSocket&&(je=WebSocket);var Ue=function(){function t(e,n,r,i,o,a,s){this.connId=e,this.applicationId=r,this.appCheckToken=i,this.authToken=o,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=k(this.connId),this.stats_=ve(n),this.connURL=t.connectionURL_(n,a,s,i),this.nodeAdmin=n.nodeAdmin}return t.connectionURL_=function(e,t,n,i){var o={};return o[ee]=Z,!(0,r.isNodeSdk)()&&"undefined"!=typeof location&&location.hostname&&ie.test(location.hostname)&&(o[ne]=re),t&&(o[te]=t),n&&(o[oe]=n),i&&(o[se]=i),de(e,ue,o)},t.prototype.open=function(t,n){var i=this;this.onDisconnect=n,this.onMessage=t,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,f.set("previous_websocket_failure",!0);try{if((0,r.isNodeSdk)()){var o=this.nodeAdmin?"AdminNode":"Node",a={headers:{"User-Agent":"Firebase/"+Z+"/"+l+"/"+e.platform+"/"+o,"X-Firebase-GMPID":this.applicationId||""}};this.authToken&&(a.headers.Authorization="Bearer "+this.authToken),this.appCheckToken&&(a.headers["X-Firebase-AppCheck"]=this.appCheckToken);var s=e.env,u=0===this.connURL.indexOf("wss://")?s.HTTPS_PROXY||s.https_proxy:s.HTTP_PROXY||s.http_proxy;u&&(a.proxy={origin:u}),this.mySock=new je(this.connURL,[],a)}else{a={headers:{"X-Firebase-GMPID":this.applicationId||"","X-Firebase-AppCheck":this.appCheckToken||""}};this.mySock=new je(this.connURL,[],a)}}catch(h){this.log_("Error instantiating WebSocket.");var c=h.message||h.data;return c&&this.log_(c),void this.onClosed_()}this.mySock.onopen=function(){i.log_("Websocket connected."),i.everConnected_=!0},this.mySock.onclose=function(){i.log_("Websocket connection was disconnected."),i.mySock=null,i.onClosed_()},this.mySock.onmessage=function(e){i.handleIncomingFrame(e)},this.mySock.onerror=function(e){i.log_("WebSocket error. Closing connection.");var t=e.message||e.data;t&&i.log_(t),i.onClosed_()}},t.prototype.start=function(){},t.forceDisallow=function(){t.forceDisallow_=!0},t.isAvailable=function(){var e=!1;if("undefined"!=typeof navigator&&navigator.userAgent){var n=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/);n&&n.length>1&&parseFloat(n[1])<4.4&&(e=!0)}return!e&&null!==je&&!t.forceDisallow_},t.previouslyFailed=function(){return f.isInMemoryStorage||!0===f.get("previous_websocket_failure")},t.prototype.markConnectionHealthy=function(){f.remove("previous_websocket_failure")},t.prototype.appendFrame_=function(e){if(this.frames.push(e),this.frames.length===this.totalFrames){var t=this.frames.join("");this.frames=null;var n=(0,r.jsonEval)(t);this.onMessage(n)}},t.prototype.handleNewFrameCount_=function(e){this.totalFrames=e,this.frames=[]},t.prototype.extractFrameCount_=function(e){if((0,r.assert)(null===this.frames,"We already have a frame buffer"),e.length<=6){var t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e},t.prototype.handleIncomingFrame=function(e){if(null!==this.mySock){var t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(t);else{var n=this.extractFrameCount_(t);null!==n&&this.appendFrame_(n)}}},t.prototype.send=function(e){this.resetKeepAlive();var t=(0,r.stringify)(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);var n=F(t,Le);n.length>1&&this.sendString_(String(n.length));for(var i=0;i<n.length;i++)this.sendString_(n[i])},t.prototype.shutdown_=function(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)},t.prototype.onClosed_=function(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))},t.prototype.close=function(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())},t.prototype.resetKeepAlive=function(){var e=this;clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(function(){e.mySock&&e.sendString_("0"),e.resetKeepAlive()},Math.floor(We))},t.prototype.sendString_=function(e){try{this.mySock.send(e)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}},t.responsesRequiredToBeHealthy=2,t.healthyTimeout=3e4,t}(),Be=function(){function e(e){this.initTransports_(e)}return Object.defineProperty(e,"ALL_TRANSPORTS",{get:function(){return[qe,Ue]},enumerable:!1,configurable:!0}),e.prototype.initTransports_=function(t){var n,r,o=Ue&&Ue.isAvailable(),a=o&&!Ue.previouslyFailed();if(t.webSocketOnly&&(o||S("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),a=!0),a)this.transports_=[Ue];else{var s=this.transports_=[];try{for(var u=(0,i.__values)(e.ALL_TRANSPORTS),l=u.next();!l.done;l=u.next()){var c=l.value;c&&c.isAvailable()&&s.push(c)}}catch(h){n={error:h}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}},e.prototype.initialTransport=function(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")},e.prototype.upgradeTransport=function(){return this.transports_.length>1?this.transports_[1]:null},e}(),Ve=6e4,Qe=5e3,He=10240,ze=102400,Ye="t",Ke="d",Ge="s",$e="r",Je="e",Xe="o",Ze="a",et="n",tt="p",nt="h",rt=function(){function e(e,t,n,r,i,o,a,s,u,l){this.id=e,this.repoInfo_=t,this.applicationId_=n,this.appCheckToken_=r,this.authToken_=i,this.onMessage_=o,this.onReady_=a,this.onDisconnect_=s,this.onKill_=u,this.lastSessionId=l,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=k("c:"+this.id+":"),this.transportManager_=new Be(t),this.log_("Connection created"),this.start_()}return e.prototype.start_=function(){var e=this,t=this.transportManager_.initialTransport();this.conn_=new t(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=t.responsesRequiredToBeHealthy||0;var n=this.connReceiver_(this.conn_),r=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(function(){e.conn_&&e.conn_.open(n,r)},Math.floor(0));var i=t.healthyTimeout||0;i>0&&(this.healthyTimeout_=G(function(){e.healthyTimeout_=null,e.isHealthy_||(e.conn_&&e.conn_.bytesReceived>ze?(e.log_("Connection exceeded healthy timeout but has received "+e.conn_.bytesReceived+" bytes. Marking connection healthy."),e.isHealthy_=!0,e.conn_.markConnectionHealthy()):e.conn_&&e.conn_.bytesSent>He?e.log_("Connection exceeded healthy timeout but has sent "+e.conn_.bytesSent+" bytes. Leaving connection alive."):(e.log_("Closing unhealthy connection after timeout."),e.close()))},Math.floor(i)))},e.prototype.nextTransportId_=function(){return"c:"+this.id+":"+this.connectionCount++},e.prototype.disconnReceiver_=function(e){var t=this;return function(n){e===t.conn_?t.onConnectionLost_(n):e===t.secondaryConn_?(t.log_("Secondary connection lost."),t.onSecondaryConnectionLost_()):t.log_("closing an old connection")}},e.prototype.connReceiver_=function(e){var t=this;return function(n){2!==t.state_&&(e===t.rx_?t.onPrimaryMessageReceived_(n):e===t.secondaryConn_?t.onSecondaryMessageReceived_(n):t.log_("message on old connection"))}},e.prototype.sendRequest=function(e){var t={t:"d",d:e};this.sendData_(t)},e.prototype.tryCleanupConnection=function(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)},e.prototype.onSecondaryControl_=function(e){if(Ye in e){var t=e[Ye];t===Ze?this.upgradeIfSecondaryHealthy_():t===$e?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):t===Xe&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}},e.prototype.onSecondaryMessageReceived_=function(e){var t=M("t",e),n=M("d",e);if("c"===t)this.onSecondaryControl_(n);else{if("d"!==t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(n)}},e.prototype.upgradeIfSecondaryHealthy_=function(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:tt,d:{}}}))},e.prototype.proceedWithUpgrade_=function(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:Ze,d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:et,d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()},e.prototype.onPrimaryMessageReceived_=function(e){var t=M("t",e),n=M("d",e);"c"===t?this.onControl_(n):"d"===t&&this.onDataMessage_(n)},e.prototype.onDataMessage_=function(e){this.onPrimaryResponse_(),this.onMessage_(e)},e.prototype.onPrimaryResponse_=function(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))},e.prototype.onControl_=function(e){var t=M(Ye,e);if(Ke in e){var n=e[Ke];if(t===nt)this.onHandshake_(n);else if(t===et){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(var r=0;r<this.pendingDataMessages.length;++r)this.onDataMessage_(this.pendingDataMessages[r]);this.pendingDataMessages=[],this.tryCleanupConnection()}else t===Ge?this.onConnectionShutdown_(n):t===$e?this.onReset_(n):t===Je?I("Server Error: "+n):t===Xe?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):I("Unknown control packet command: "+t)}},e.prototype.onHandshake_=function(e){var t=e.ts,n=e.v,r=e.h;this.sessionId=e.s,this.repoInfo_.host=r,0===this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),Z!==n&&S("Protocol version mismatch detected"),this.tryStartUpgrade_())},e.prototype.tryStartUpgrade_=function(){var e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)},e.prototype.startUpgrade_=function(e){var t=this;this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;var n=this.connReceiver_(this.secondaryConn_),r=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(n,r),G(function(){t.secondaryConn_&&(t.log_("Timed out trying to upgrade."),t.secondaryConn_.close())},Math.floor(Ve))},e.prototype.onReset_=function(e){this.log_("Reset packet received. New host: "+e),this.repoInfo_.host=e,1===this.state_?this.close():(this.closeConnections_(),this.start_())},e.prototype.onConnectionEstablished_=function(e,t){var n=this;this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):G(function(){n.sendPingOnPrimaryIfNecessary_()},Math.floor(Qe))},e.prototype.sendPingOnPrimaryIfNecessary_=function(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:tt,d:{}}}))},e.prototype.onSecondaryConnectionLost_=function(){var e=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==e&&this.rx_!==e||this.close()},e.prototype.onConnectionLost_=function(e){this.conn_=null,e||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(f.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()},e.prototype.onConnectionShutdown_=function(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()},e.prototype.sendData_=function(e){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(e)},e.prototype.close=function(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))},e.prototype.closeConnections_=function(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)},e}(),it=function(){function e(){}return e.prototype.put=function(e,t,n,r){},e.prototype.merge=function(e,t,n,r){},e.prototype.refreshAuthToken=function(e){},e.prototype.refreshAppCheckToken=function(e){},e.prototype.onDisconnectPut=function(e,t,n){},e.prototype.onDisconnectMerge=function(e,t,n){},e.prototype.onDisconnectCancel=function(e,t){},e.prototype.reportStats=function(e){},e}(),ot=function(){function e(e){this.allowedEvents_=e,this.listeners_={},(0,r.assert)(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}return e.prototype.trigger=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(Array.isArray(this.listeners_[e]))for(var r=(0,i.__spreadArray)([],(0,i.__read)(this.listeners_[e])),o=0;o<r.length;o++)r[o].callback.apply(r[o].context,t)},e.prototype.on=function(e,t,n){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:n});var r=this.getInitialEvent(e);r&&t.apply(n,r)},e.prototype.off=function(e,t,n){this.validateEventType_(e);for(var r=this.listeners_[e]||[],i=0;i<r.length;i++)if(r[i].callback===t&&(!n||n===r[i].context))return void r.splice(i,1)},e.prototype.validateEventType_=function(e){(0,r.assert)(this.allowedEvents_.find(function(t){return t===e}),"Unknown event: "+e)},e}(),at=function(e){function t(){var t=e.call(this,["online"])||this;return t.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||(0,r.isMobileCordova)()||(window.addEventListener("online",function(){t.online_||(t.online_=!0,t.trigger("online",!0))},!1),window.addEventListener("offline",function(){t.online_&&(t.online_=!1,t.trigger("online",!1))},!1)),t}return(0,i.__extends)(t,e),t.getInstance=function(){return new t},t.prototype.getInitialEvent=function(e){return(0,r.assert)("online"===e,"Unknown event type: "+e),[this.online_]},t.prototype.currentlyOnline=function(){return this.online_},t}(ot),st=32,ut=768,lt=function(){function e(e,t){if(void 0===t){this.pieces_=e.split("/");for(var n=0,r=0;r<this.pieces_.length;r++)this.pieces_[r].length>0&&(this.pieces_[n]=this.pieces_[r],n++);this.pieces_.length=n,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}return e.prototype.toString=function(){for(var e="",t=this.pieceNum_;t<this.pieces_.length;t++)""!==this.pieces_[t]&&(e+="/"+this.pieces_[t]);return e||"/"},e}();function ct(){return new lt("")}function ht(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function dt(e){return e.pieces_.length-e.pieceNum_}function pt(e){var t=e.pieceNum_;return t<e.pieces_.length&&t++,new lt(e.pieces_,t)}function ft(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function _t(e){for(var t="",n=e.pieceNum_;n<e.pieces_.length;n++)""!==e.pieces_[n]&&(t+="/"+encodeURIComponent(String(e.pieces_[n])));return t||"/"}function vt(e,t){return void 0===t&&(t=0),e.pieces_.slice(e.pieceNum_+t)}function yt(e){if(e.pieceNum_>=e.pieces_.length)return null;for(var t=[],n=e.pieceNum_;n<e.pieces_.length-1;n++)t.push(e.pieces_[n]);return new lt(t,0)}function gt(e,t){for(var n=[],r=e.pieceNum_;r<e.pieces_.length;r++)n.push(e.pieces_[r]);if(t instanceof lt)for(r=t.pieceNum_;r<t.pieces_.length;r++)n.push(t.pieces_[r]);else{var i=t.split("/");for(r=0;r<i.length;r++)i[r].length>0&&n.push(i[r])}return new lt(n,0)}function mt(e){return e.pieceNum_>=e.pieces_.length}function Ct(e,t){var n=ht(e),r=ht(t);if(null===n)return t;if(n===r)return Ct(pt(e),pt(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function wt(e,t){for(var n=vt(e,0),r=vt(t,0),i=0;i<n.length&&i<r.length;i++){var o=D(n[i],r[i]);if(0!==o)return o}return n.length===r.length?0:n.length<r.length?-1:1}function bt(e,t){if(dt(e)!==dt(t))return!1;for(var n=e.pieceNum_,r=t.pieceNum_;n<=e.pieces_.length;n++,r++)if(e.pieces_[n]!==t.pieces_[r])return!1;return!0}function Tt(e,t){var n=e.pieceNum_,r=t.pieceNum_;if(dt(e)>dt(t))return!1;for(;n<e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[r])return!1;++n,++r}return!0}var kt=function(){return function(e,t){this.errorPrefix_=t,this.parts_=vt(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(var n=0;n<this.parts_.length;n++)this.byteLength_+=(0,r.stringLength)(this.parts_[n]);St(this)}}();function It(e,t){e.parts_.length>0&&(e.byteLength_+=1),e.parts_.push(t),e.byteLength_+=(0,r.stringLength)(t),St(e)}function Et(e){var t=e.parts_.pop();e.byteLength_-=(0,r.stringLength)(t),e.parts_.length>0&&(e.byteLength_-=1)}function St(e){if(e.byteLength_>ut)throw new Error(e.errorPrefix_+"has a key path longer than "+ut+" bytes ("+e.byteLength_+").");if(e.parts_.length>st)throw new Error(e.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+st+") or object contains a cycle "+Pt(e))}function Pt(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}var xt,Nt,Rt=function(e){function t(){var t,n,r=e.call(this,["visible"])||this;return"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(n="visibilitychange",t="hidden"):void 0!==document.mozHidden?(n="mozvisibilitychange",t="mozHidden"):void 0!==document.msHidden?(n="msvisibilitychange",t="msHidden"):void 0!==document.webkitHidden&&(n="webkitvisibilitychange",t="webkitHidden")),r.visible_=!0,n&&document.addEventListener(n,function(){var e=!document[t];e!==r.visible_&&(r.visible_=e,r.trigger("visible",e))},!1),r}return(0,i.__extends)(t,e),t.getInstance=function(){return new t},t.prototype.getInitialEvent=function(e){return(0,r.assert)("visible"===e,"Unknown event type: "+e),[this.visible_]},t}(ot),At=1e3,Dt=3e5,Ot=3e3,Mt=3e4,qt=1.3,Ft=3e4,Lt="server_kill",Wt=3,jt=function(e){function t(n,i,o,a,s,u,l,c){var h=e.call(this)||this;if(h.repoInfo_=n,h.applicationId_=i,h.onDataUpdate_=o,h.onConnectStatus_=a,h.onServerInfoUpdate_=s,h.authTokenProvider_=u,h.appCheckTokenProvider_=l,h.authOverride_=c,h.id=t.nextPersistentConnectionId_++,h.log_=k("p:"+h.id+":"),h.interruptReasons_={},h.listens=new Map,h.outstandingPuts_=[],h.outstandingGets_=[],h.outstandingPutCount_=0,h.outstandingGetCount_=0,h.onDisconnectRequestQueue_=[],h.connected_=!1,h.reconnectDelay_=At,h.maxReconnectDelay_=Dt,h.securityDebugCallback_=null,h.lastSessionId=null,h.establishConnectionTimer_=null,h.visible_=!1,h.requestCBHash_={},h.requestNumber_=0,h.realtime_=null,h.authToken_=null,h.appCheckToken_=null,h.forceTokenRefresh_=!1,h.invalidAuthTokenCount_=0,h.invalidAppCheckTokenCount_=0,h.firstConnection_=!0,h.lastConnectionAttemptTime_=null,h.lastConnectionEstablishedTime_=null,c&&!(0,r.isNodeSdk)())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");return Rt.getInstance().on("visible",h.onVisible_,h),-1===n.host.indexOf("fblocal")&&at.getInstance().on("online",h.onOnline_,h),h}return(0,i.__extends)(t,e),t.prototype.sendRequest=function(e,t,n){var i=++this.requestNumber_,o={r:i,a:e,b:t};this.log_((0,r.stringify)(o)),(0,r.assert)(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(o),n&&(this.requestCBHash_[i]=n)},t.prototype.get=function(e){var t=this;this.initConnection_();var n=new r.Deferred,i={p:e._path.toString(),q:e._queryObject},o={action:"g",request:i,onComplete:function(e){var r=e.d;"ok"===e.s?(t.onDataUpdate_(i.p,r,!1,null),n.resolve(r)):n.reject(r)}};this.outstandingGets_.push(o),this.outstandingGetCount_++;var a=this.outstandingGets_.length-1;return this.connected_||setTimeout(function(){var e=t.outstandingGets_[a];void 0!==e&&o===e&&(delete t.outstandingGets_[a],t.outstandingGetCount_--,0===t.outstandingGetCount_&&(t.outstandingGets_=[]),t.log_("get "+a+" timed out on connection"),n.reject(new Error("Client is offline.")))},Ot),this.connected_&&this.sendGet_(a),n.promise},t.prototype.listen=function(e,t,n,i){this.initConnection_();var o=e._queryIdentifier,a=e._path.toString();this.log_("Listen called for "+a+" "+o),this.listens.has(a)||this.listens.set(a,new Map),(0,r.assert)(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),(0,r.assert)(!this.listens.get(a).has(o),"listen() called twice for same path/queryId.");var s={onComplete:i,hashFn:t,query:e,tag:n};this.listens.get(a).set(o,s),this.connected_&&this.sendListen_(s)},t.prototype.sendGet_=function(e){var t=this,n=this.outstandingGets_[e];this.sendRequest("g",n.request,function(r){delete t.outstandingGets_[e],t.outstandingGetCount_--,0===t.outstandingGetCount_&&(t.outstandingGets_=[]),n.onComplete&&n.onComplete(r)})},t.prototype.sendListen_=function(e){var n=this,r=e.query,i=r._path.toString(),o=r._queryIdentifier;this.log_("Listen on "+i+" for "+o);var a={p:i};e.tag&&(a.q=r._queryObject,a.t=e.tag),a.h=e.hashFn(),this.sendRequest("q",a,function(a){var s=a.d,u=a.s;t.warnOnListenWarnings_(s,r),(n.listens.get(i)&&n.listens.get(i).get(o))===e&&(n.log_("listen response",a),"ok"!==u&&n.removeListen_(i,o),e.onComplete&&e.onComplete(u,s))})},t.warnOnListenWarnings_=function(e,t){if(e&&"object"==typeof e&&(0,r.contains)(e,"w")){var n=(0,r.safeGet)(e,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){var i='".indexOn": "'+t._queryParams.getIndex().toString()+'"',o=t._path.toString();S("Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding "+i+" at "+o+" to your security rules for better performance.")}}},t.prototype.refreshAuthToken=function(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},function(){}),this.reduceReconnectDelayIfAdminCredential_(e)},t.prototype.reduceReconnectDelayIfAdminCredential_=function(e){(e&&40===e.length||(0,r.isAdmin)(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=Mt)},t.prototype.refreshAppCheckToken=function(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},function(){})},t.prototype.tryAuth=function(){var e=this;if(this.connected_&&this.authToken_){var t=this.authToken_,n=(0,r.isValidFormat)(t)?"auth":"gauth",i={cred:t};null===this.authOverride_?i.noauth=!0:"object"==typeof this.authOverride_&&(i.authvar=this.authOverride_),this.sendRequest(n,i,function(n){var r=n.s,i=n.d||"error";e.authToken_===t&&("ok"===r?e.invalidAuthTokenCount_=0:e.onAuthRevoked_(r,i))})}},t.prototype.tryAppCheck=function(){var e=this;this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},function(t){var n=t.s,r=t.d||"error";"ok"===n?e.invalidAppCheckTokenCount_=0:e.onAppCheckRevoked_(n,r)})},t.prototype.unlisten=function(e,t){var n=e._path.toString(),i=e._queryIdentifier;this.log_("Unlisten called for "+n+" "+i),(0,r.assert)(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(n,i)&&this.connected_&&this.sendUnlisten_(n,i,e._queryObject,t)},t.prototype.sendUnlisten_=function(e,t,n,r){this.log_("Unlisten on "+e+" for "+t);var i={p:e};r&&(i.q=n,i.t=r),this.sendRequest("n",i)},t.prototype.onDisconnectPut=function(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:n})},t.prototype.onDisconnectMerge=function(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:n})},t.prototype.onDisconnectCancel=function(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})},t.prototype.sendOnDisconnect_=function(e,t,n,r){var i={p:t,d:n};this.log_("onDisconnect "+e,i),this.sendRequest(e,i,function(e){r&&setTimeout(function(){r(e.s,e.d)},Math.floor(0))})},t.prototype.put=function(e,t,n,r){this.putInternal("p",e,t,n,r)},t.prototype.merge=function(e,t,n,r){this.putInternal("m",e,t,n,r)},t.prototype.putInternal=function(e,t,n,r,i){this.initConnection_();var o={p:t,d:n};void 0!==i&&(o.h=i),this.outstandingPuts_.push({action:e,request:o,onComplete:r}),this.outstandingPutCount_++;var a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+t)},t.prototype.sendPut_=function(e){var t=this,n=this.outstandingPuts_[e].action,r=this.outstandingPuts_[e].request,i=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(n,r,function(r){t.log_(n+" response",r),delete t.outstandingPuts_[e],t.outstandingPutCount_--,0===t.outstandingPutCount_&&(t.outstandingPuts_=[]),i&&i(r.s,r.d)})},t.prototype.reportStats=function(e){var t=this;if(this.connected_){var n={c:e};this.log_("reportStats",n),this.sendRequest("s",n,function(e){if("ok"!==e.s){var n=e.d;t.log_("reportStats","Error sending stats: "+n)}})}},t.prototype.onDataMessage_=function(e){if("r"in e){this.log_("from server: "+(0,r.stringify)(e));var t=e.r,n=this.requestCBHash_[t];n&&(delete this.requestCBHash_[t],n(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}},t.prototype.onDataPush_=function(e,t){this.log_("handleServerMessage",e,t),"d"===e?this.onDataUpdate_(t.p,t.d,!1,t.t):"m"===e?this.onDataUpdate_(t.p,t.d,!0,t.t):"c"===e?this.onListenRevoked_(t.p,t.q):"ac"===e?this.onAuthRevoked_(t.s,t.d):"apc"===e?this.onAppCheckRevoked_(t.s,t.d):"sd"===e?this.onSecurityDebugPacket_(t):I("Unrecognized action received from server: "+(0,r.stringify)(e)+"\nAre you using the latest client?")},t.prototype.onReady_=function(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)},t.prototype.scheduleConnect_=function(e){var t=this;(0,r.assert)(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(function(){t.establishConnectionTimer_=null,t.establishConnection_()},Math.floor(e))},t.prototype.initConnection_=function(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)},t.prototype.onVisible_=function(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=At,this.realtime_||this.scheduleConnect_(0)),this.visible_=e},t.prototype.onOnline_=function(e){e?(this.log_("Browser went online."),this.reconnectDelay_=At,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())},t.prototype.onRealtimeDisconnect_=function(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){if(this.visible_){if(this.lastConnectionEstablishedTime_){(new Date).getTime()-this.lastConnectionEstablishedTime_>Ft&&(this.reconnectDelay_=At),this.lastConnectionEstablishedTime_=null}}else this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime();var e=(new Date).getTime()-this.lastConnectionAttemptTime_,t=Math.max(0,this.reconnectDelay_-e);t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*qt)}this.onConnectStatus_(!1)},t.prototype.establishConnection_=function(){return(0,i.__awaiter)(this,void 0,void 0,function(){var e,n,o,a,s,u,l,c,h,d,p,f,_,v,y=this;return(0,i.__generator)(this,function(g){switch(g.label){case 0:if(!this.shouldReconnect_())return[3,4];this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null,e=this.onDataMessage_.bind(this),n=this.onReady_.bind(this),o=this.onRealtimeDisconnect_.bind(this),a=this.id+":"+t.nextConnectionId_++,s=this.lastSessionId,u=!1,l=null,c=function(){l?l.close():(u=!0,o())},h=function(e){(0,r.assert)(l,"sendRequest call when we're not connected not allowed."),l.sendRequest(e)},this.realtime_={close:c,sendRequest:h},d=this.forceTokenRefresh_,this.forceTokenRefresh_=!1,g.label=1;case 1:return g.trys.push([1,3,,4]),[4,Promise.all([this.authTokenProvider_.getToken(d),this.appCheckTokenProvider_.getToken(d)])];case 2:return p=i.__read.apply(void 0,[g.sent(),2]),f=p[0],_=p[1],u?T("getToken() completed but was canceled"):(T("getToken() completed. Creating connection."),this.authToken_=f&&f.accessToken,this.appCheckToken_=_&&_.token,l=new rt(a,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,n,o,function(e){S(e+" ("+y.repoInfo_.toString()+")"),y.interrupt(Lt)},s)),[3,4];case 3:return v=g.sent(),this.log_("Failed to get token: "+v),u||(this.repoInfo_.nodeAdmin&&S(v),c()),[3,4];case 4:return[2]}})})},t.prototype.interrupt=function(e){T("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())},t.prototype.resume=function(e){T("Resuming connection for reason: "+e),delete this.interruptReasons_[e],(0,r.isEmpty)(this.interruptReasons_)&&(this.reconnectDelay_=At,this.realtime_||this.scheduleConnect_(0))},t.prototype.handleTimestamp_=function(e){var t=e-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})},t.prototype.cancelSentTransactions_=function(){for(var e=0;e<this.outstandingPuts_.length;e++){var t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])},t.prototype.onListenRevoked_=function(e,t){var n;n=t?t.map(function(e){return q(e)}).join("$"):"default";var r=this.removeListen_(e,n);r&&r.onComplete&&r.onComplete("permission_denied")},t.prototype.removeListen_=function(e,t){var n,r=new lt(e).toString();if(this.listens.has(r)){var i=this.listens.get(r);n=i.get(t),i.delete(t),0===i.size&&this.listens.delete(r)}else n=void 0;return n},t.prototype.onAuthRevoked_=function(e,t){T("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=Wt&&(this.reconnectDelay_=Mt,this.authTokenProvider_.notifyForInvalidToken()))},t.prototype.onAppCheckRevoked_=function(e,t){T("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=Wt&&this.appCheckTokenProvider_.notifyForInvalidToken())},t.prototype.onSecurityDebugPacket_=function(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace("\n","\nFIREBASE: "))},t.prototype.restoreState_=function(){var e,t,n,r;this.tryAuth(),this.tryAppCheck();try{for(var o=(0,i.__values)(this.listens.values()),a=o.next();!a.done;a=o.next()){var s=a.value;try{for(var u=(n=void 0,(0,i.__values)(s.values())),l=u.next();!l.done;l=u.next()){var c=l.value;this.sendListen_(c)}}catch(p){n={error:p}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}}catch(f){e={error:f}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}for(var h=0;h<this.outstandingPuts_.length;h++)this.outstandingPuts_[h]&&this.sendPut_(h);for(;this.onDisconnectRequestQueue_.length;){var d=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(d.action,d.pathString,d.data,d.onComplete)}for(h=0;h<this.outstandingGets_.length;h++)this.outstandingGets_[h]&&this.sendGet_(h)},t.prototype.sendConnectStats_=function(){var e={},t="js";(0,r.isNodeSdk)()&&(t=this.repoInfo_.nodeAdmin?"admin_node":"node"),e["sdk."+t+"."+l.replace(/\./g,"-")]=1,(0,r.isMobileCordova)()?e["framework.cordova"]=1:(0,r.isReactNative)()&&(e["framework.reactnative"]=1),this.reportStats(e)},t.prototype.shouldReconnect_=function(){var e=at.getInstance().currentlyOnline();return(0,r.isEmpty)(this.interruptReasons_)&&e},t.nextPersistentConnectionId_=0,t.nextConnectionId_=0,t}(it),Ut=function(){function e(e,t){this.name=e,this.node=t}return e.Wrap=function(t,n){return new e(t,n)},e}(),Bt=function(){function e(){}return e.prototype.getCompare=function(){return this.compare.bind(this)},e.prototype.indexedValueChanged=function(e,t){var n=new Ut(R,e),r=new Ut(R,t);return 0!==this.compare(n,r)},e.prototype.minPost=function(){return Ut.MIN},e}(),Vt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,i.__extends)(t,e),Object.defineProperty(t,"__EMPTY_NODE",{get:function(){return xt},set:function(e){xt=e},enumerable:!1,configurable:!0}),t.prototype.compare=function(e,t){return D(e.name,t.name)},t.prototype.isDefinedOn=function(e){throw(0,r.assertionError)("KeyIndex.isDefinedOn not expected to be called.")},t.prototype.indexedValueChanged=function(e,t){return!1},t.prototype.minPost=function(){return Ut.MIN},t.prototype.maxPost=function(){return new Ut(A,xt)},t.prototype.makePost=function(e,t){return(0,r.assert)("string"==typeof e,"KeyIndex indexValue must always be a string."),new Ut(e,xt)},t.prototype.toString=function(){return".key"},t}(Bt),Qt=new Vt,Ht=function(){function e(e,t,n,r,i){void 0===i&&(i=null),this.isReverse_=r,this.resultGenerator_=i,this.nodeStack_=[];for(var o=1;!e.isEmpty();)if(e=e,o=t?n(e.key,t):1,r&&(o*=-1),o<0)e=this.isReverse_?e.left:e.right;else{if(0===o){this.nodeStack_.push(e);break}this.nodeStack_.push(e),e=this.isReverse_?e.right:e.left}}return e.prototype.getNext=function(){if(0===this.nodeStack_.length)return null;var e,t=this.nodeStack_.pop();if(e=this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value},this.isReverse_)for(t=t.left;!t.isEmpty();)this.nodeStack_.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack_.push(t),t=t.left;return e},e.prototype.hasNext=function(){return this.nodeStack_.length>0},e.prototype.peek=function(){if(0===this.nodeStack_.length)return null;var e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}},e}(),zt=function(){function e(t,n,r,i,o){this.key=t,this.value=n,this.color=null!=r?r:e.RED,this.left=null!=i?i:Kt.EMPTY_NODE,this.right=null!=o?o:Kt.EMPTY_NODE}return e.prototype.copy=function(t,n,r,i,o){return new e(null!=t?t:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},e.prototype.count=function(){return this.left.count()+1+this.right.count()},e.prototype.isEmpty=function(){return!1},e.prototype.inorderTraversal=function(e){return this.left.inorderTraversal(e)||!!e(this.key,this.value)||this.right.inorderTraversal(e)},e.prototype.reverseTraversal=function(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)},e.prototype.min_=function(){return this.left.isEmpty()?this:this.left.min_()},e.prototype.minKey=function(){return this.min_().key},e.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},e.prototype.insert=function(e,t,n){var r=this,i=n(e,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n))).fixUp_()},e.prototype.removeMin_=function(){if(this.left.isEmpty())return Kt.EMPTY_NODE;var e=this;return e.left.isRed_()||e.left.left.isRed_()||(e=e.moveRedLeft_()),(e=e.copy(null,null,null,e.left.removeMin_(),null)).fixUp_()},e.prototype.remove=function(e,t){var n,r;if(t(e,(n=this).key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===t(e,n.key)){if(n.right.isEmpty())return Kt.EMPTY_NODE;r=n.right.min_(),n=n.copy(r.key,r.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp_()},e.prototype.isRed_=function(){return this.color},e.prototype.fixUp_=function(){var e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e},e.prototype.moveRedLeft_=function(){var e=this.colorFlip_();return e.right.left.isRed_()&&(e=(e=(e=e.copy(null,null,null,null,e.right.rotateRight_())).rotateLeft_()).colorFlip_()),e},e.prototype.moveRedRight_=function(){var e=this.colorFlip_();return e.left.left.isRed_()&&(e=(e=e.rotateRight_()).colorFlip_()),e},e.prototype.rotateLeft_=function(){var t=this.copy(null,null,e.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},e.prototype.rotateRight_=function(){var t=this.copy(null,null,e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},e.prototype.colorFlip_=function(){var e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)},e.prototype.checkMaxDepth_=function(){var e=this.check_();return Math.pow(2,e)<=this.count()+1},e.prototype.check_=function(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");var e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)},e.RED=!0,e.BLACK=!1,e}(),Yt=function(){function e(){}return e.prototype.copy=function(e,t,n,r,i){return this},e.prototype.insert=function(e,t,n){return new zt(e,t,null)},e.prototype.remove=function(e,t){return this},e.prototype.count=function(){return 0},e.prototype.isEmpty=function(){return!0},e.prototype.inorderTraversal=function(e){return!1},e.prototype.reverseTraversal=function(e){return!1},e.prototype.minKey=function(){return null},e.prototype.maxKey=function(){return null},e.prototype.check_=function(){return 0},e.prototype.isRed_=function(){return!1},e}(),Kt=function(){function e(t,n){void 0===n&&(n=e.EMPTY_NODE),this.comparator_=t,this.root_=n}return e.prototype.insert=function(t,n){return new e(this.comparator_,this.root_.insert(t,n,this.comparator_).copy(null,null,zt.BLACK,null,null))},e.prototype.remove=function(t){return new e(this.comparator_,this.root_.remove(t,this.comparator_).copy(null,null,zt.BLACK,null,null))},e.prototype.get=function(e){for(var t,n=this.root_;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key)))return n.value;t<0?n=n.left:t>0&&(n=n.right)}return null},e.prototype.getPredecessorKey=function(e){for(var t,n=this.root_,r=null;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key))){if(n.left.isEmpty())return r?r.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}t<0?n=n.left:t>0&&(r=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")},e.prototype.isEmpty=function(){return this.root_.isEmpty()},e.prototype.count=function(){return this.root_.count()},e.prototype.minKey=function(){return this.root_.minKey()},e.prototype.maxKey=function(){return this.root_.maxKey()},e.prototype.inorderTraversal=function(e){return this.root_.inorderTraversal(e)},e.prototype.reverseTraversal=function(e){return this.root_.reverseTraversal(e)},e.prototype.getIterator=function(e){return new Ht(this.root_,null,this.comparator_,!1,e)},e.prototype.getIteratorFrom=function(e,t){return new Ht(this.root_,e,this.comparator_,!1,t)},e.prototype.getReverseIteratorFrom=function(e,t){return new Ht(this.root_,e,this.comparator_,!0,t)},e.prototype.getReverseIterator=function(e){return new Ht(this.root_,null,this.comparator_,!0,e)},e.EMPTY_NODE=new Yt,e}();function Gt(e,t){return D(e.name,t.name)}function $t(e,t){return D(e,t)}function Jt(e){Nt=e}var Xt,Zt,en,tn=function(e){return"number"==typeof e?"number:"+W(e):"string:"+e},nn=function(e){if(e.isLeafNode()){var t=e.val();(0,r.assert)("string"==typeof t||"number"==typeof t||"object"==typeof t&&(0,r.contains)(t,".sv"),"Priority must be a string or number.")}else(0,r.assert)(e===Nt||e.isEmpty(),"priority of unexpected type.");(0,r.assert)(e===Nt||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")},rn=function(){function e(t,n){void 0===n&&(n=e.__childrenNodeConstructor.EMPTY_NODE),this.value_=t,this.priorityNode_=n,this.lazyHash_=null,(0,r.assert)(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),nn(this.priorityNode_)}return Object.defineProperty(e,"__childrenNodeConstructor",{get:function(){return Xt},set:function(e){Xt=e},enumerable:!1,configurable:!0}),e.prototype.isLeafNode=function(){return!0},e.prototype.getPriority=function(){return this.priorityNode_},e.prototype.updatePriority=function(t){return new e(this.value_,t)},e.prototype.getImmediateChild=function(t){return".priority"===t?this.priorityNode_:e.__childrenNodeConstructor.EMPTY_NODE},e.prototype.getChild=function(t){return mt(t)?this:".priority"===ht(t)?this.priorityNode_:e.__childrenNodeConstructor.EMPTY_NODE},e.prototype.hasChild=function(){return!1},e.prototype.getPredecessorChildName=function(e,t){return null},e.prototype.updateImmediateChild=function(t,n){return".priority"===t?this.updatePriority(n):n.isEmpty()&&".priority"!==t?this:e.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(t,n).updatePriority(this.priorityNode_)},e.prototype.updateChild=function(t,n){var i=ht(t);return null===i?n:n.isEmpty()&&".priority"!==i?this:((0,r.assert)(".priority"!==i||1===dt(t),".priority must be the last token in a path"),this.updateImmediateChild(i,e.__childrenNodeConstructor.EMPTY_NODE.updateChild(pt(t),n)))},e.prototype.isEmpty=function(){return!1},e.prototype.numChildren=function(){return 0},e.prototype.forEachChild=function(e,t){return!1},e.prototype.val=function(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()},e.prototype.hash=function(){if(null===this.lazyHash_){var e="";this.priorityNode_.isEmpty()||(e+="priority:"+tn(this.priorityNode_.val())+":");var t=typeof this.value_;e+=t+":",e+="number"===t?W(this.value_):this.value_,this.lazyHash_=g(e)}return this.lazyHash_},e.prototype.getValue=function(){return this.value_},e.prototype.compareTo=function(t){return t===e.__childrenNodeConstructor.EMPTY_NODE?1:t instanceof e.__childrenNodeConstructor?-1:((0,r.assert)(t.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(t))},e.prototype.compareToLeafNode_=function(t){var n=typeof t.value_,i=typeof this.value_,o=e.VALUE_TYPE_ORDER.indexOf(n),a=e.VALUE_TYPE_ORDER.indexOf(i);return(0,r.assert)(o>=0,"Unknown leaf type: "+n),(0,r.assert)(a>=0,"Unknown leaf type: "+i),o===a?"object"===i?0:this.value_<t.value_?-1:this.value_===t.value_?0:1:a-o},e.prototype.withIndex=function(){return this},e.prototype.isIndexed=function(){return!0},e.prototype.equals=function(e){if(e===this)return!0;if(e.isLeafNode()){var t=e;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}return!1},e.VALUE_TYPE_ORDER=["object","boolean","number","string"],e}();function on(e){Zt=e}function an(e){en=e}var sn,un,ln=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,i.__extends)(t,e),t.prototype.compare=function(e,t){var n=e.node.getPriority(),r=t.node.getPriority(),i=n.compareTo(r);return 0===i?D(e.name,t.name):i},t.prototype.isDefinedOn=function(e){return!e.getPriority().isEmpty()},t.prototype.indexedValueChanged=function(e,t){return!e.getPriority().equals(t.getPriority())},t.prototype.minPost=function(){return Ut.MIN},t.prototype.maxPost=function(){return new Ut(A,new rn("[PRIORITY-POST]",en))},t.prototype.makePost=function(e,t){var n=Zt(e);return new Ut(t,new rn("[PRIORITY-POST]",n))},t.prototype.toString=function(){return".priority"},t}(Bt),cn=new ln,hn=Math.log(2),dn=function(){function e(e){var t;this.count=(t=e+1,parseInt(Math.log(t)/hn,10)),this.current_=this.count-1;var n,r=(n=this.count,parseInt(Array(n+1).join("1"),2));this.bits_=e+1&r}return e.prototype.nextBitIsOne=function(){var e=!(this.bits_&1<<this.current_);return this.current_--,e},e}(),pn=function(e,t,n,r){e.sort(t);var i=function(t,r){var o,a,s=r-t;if(0===s)return null;if(1===s)return o=e[t],a=n?n(o):o,new zt(a,o.node,zt.BLACK,null,null);var u=parseInt(s/2,10)+t,l=i(t,u),c=i(u+1,r);return o=e[u],a=n?n(o):o,new zt(a,o.node,zt.BLACK,l,c)},o=function(t){for(var r=null,o=null,a=e.length,s=function(t,r){var o=a-t,s=a;a-=t;var l=i(o+1,s),c=e[o],h=n?n(c):c;u(new zt(h,c.node,r,null,l))},u=function(e){r?(r.left=e,r=e):(o=e,r=e)},l=0;l<t.count;++l){var c=t.nextBitIsOne(),h=Math.pow(2,t.count-(l+1));c?s(h,zt.BLACK):(s(h,zt.BLACK),s(h,zt.RED))}return o}(new dn(e.length));return new Kt(r||t,o)},fn={},_n=function(){function e(e,t){this.indexes_=e,this.indexSet_=t}return Object.defineProperty(e,"Default",{get:function(){return(0,r.assert)(fn&&cn,"ChildrenNode.ts has not been loaded"),sn=sn||new e({".priority":fn},{".priority":cn})},enumerable:!1,configurable:!0}),e.prototype.get=function(e){var t=(0,r.safeGet)(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof Kt?t:null},e.prototype.hasIndex=function(e){return(0,r.contains)(this.indexSet_,e.toString())},e.prototype.addIndex=function(t,n){(0,r.assert)(t!==Qt,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var o,a=[],s=!1,u=n.getIterator(Ut.Wrap),l=u.getNext();l;)s=s||t.isDefinedOn(l.node),a.push(l),l=u.getNext();o=s?pn(a,t.getCompare()):fn;var c=t.toString(),h=(0,i.__assign)({},this.indexSet_);h[c]=t;var d=(0,i.__assign)({},this.indexes_);return d[c]=o,new e(d,h)},e.prototype.addToIndexes=function(t,n){var i=this;return new e((0,r.map)(this.indexes_,function(e,o){var a=(0,r.safeGet)(i.indexSet_,o);if((0,r.assert)(a,"Missing index implementation for "+o),e===fn){if(a.isDefinedOn(t.node)){for(var s=[],u=n.getIterator(Ut.Wrap),l=u.getNext();l;)l.name!==t.name&&s.push(l),l=u.getNext();return s.push(t),pn(s,a.getCompare())}return fn}var c=n.get(t.name),h=e;return c&&(h=h.remove(new Ut(t.name,c))),h.insert(t,t.node)}),this.indexSet_)},e.prototype.removeFromIndexes=function(t,n){return new e((0,r.map)(this.indexes_,function(e){if(e===fn)return e;var r=n.get(t.name);return r?e.remove(new Ut(t.name,r)):e}),this.indexSet_)},e}(),vn=function(){function e(e,t,n){this.children_=e,this.priorityNode_=t,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&nn(this.priorityNode_),this.children_.isEmpty()&&(0,r.assert)(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}return Object.defineProperty(e,"EMPTY_NODE",{get:function(){return un||(un=new e(new Kt($t),null,_n.Default))},enumerable:!1,configurable:!0}),e.prototype.isLeafNode=function(){return!1},e.prototype.getPriority=function(){return this.priorityNode_||un},e.prototype.updatePriority=function(t){return this.children_.isEmpty()?this:new e(this.children_,t,this.indexMap_)},e.prototype.getImmediateChild=function(e){if(".priority"===e)return this.getPriority();var t=this.children_.get(e);return null===t?un:t},e.prototype.getChild=function(e){var t=ht(e);return null===t?this:this.getImmediateChild(t).getChild(pt(e))},e.prototype.hasChild=function(e){return null!==this.children_.get(e)},e.prototype.updateImmediateChild=function(t,n){if((0,r.assert)(n,"We should always be passing snapshot nodes"),".priority"===t)return this.updatePriority(n);var i=new Ut(t,n),o=void 0,a=void 0;n.isEmpty()?(o=this.children_.remove(t),a=this.indexMap_.removeFromIndexes(i,this.children_)):(o=this.children_.insert(t,n),a=this.indexMap_.addToIndexes(i,this.children_));var s=o.isEmpty()?un:this.priorityNode_;return new e(o,s,a)},e.prototype.updateChild=function(e,t){var n=ht(e);if(null===n)return t;(0,r.assert)(".priority"!==ht(e)||1===dt(e),".priority must be the last token in a path");var i=this.getImmediateChild(n).updateChild(pt(e),t);return this.updateImmediateChild(n,i)},e.prototype.isEmpty=function(){return this.children_.isEmpty()},e.prototype.numChildren=function(){return this.children_.count()},e.prototype.val=function(t){if(this.isEmpty())return null;var n={},r=0,i=0,o=!0;if(this.forEachChild(cn,function(a,s){n[a]=s.val(t),r++,o&&e.INTEGER_REGEXP_.test(a)?i=Math.max(i,Number(a)):o=!1}),!t&&o&&i<2*r){var a=[];for(var s in n)a[s]=n[s];return a}return t&&!this.getPriority().isEmpty()&&(n[".priority"]=this.getPriority().val()),n},e.prototype.hash=function(){if(null===this.lazyHash_){var e="";this.getPriority().isEmpty()||(e+="priority:"+tn(this.getPriority().val())+":"),this.forEachChild(cn,function(t,n){var r=n.hash();""!==r&&(e+=":"+t+":"+r)}),this.lazyHash_=""===e?"":g(e)}return this.lazyHash_},e.prototype.getPredecessorChildName=function(e,t,n){var r=this.resolveIndex_(n);if(r){var i=r.getPredecessorKey(new Ut(e,t));return i?i.name:null}return this.children_.getPredecessorKey(e)},e.prototype.getFirstChildName=function(e){var t=this.resolveIndex_(e);if(t){var n=t.minKey();return n&&n.name}return this.children_.minKey()},e.prototype.getFirstChild=function(e){var t=this.getFirstChildName(e);return t?new Ut(t,this.children_.get(t)):null},e.prototype.getLastChildName=function(e){var t=this.resolveIndex_(e);if(t){var n=t.maxKey();return n&&n.name}return this.children_.maxKey()},e.prototype.getLastChild=function(e){var t=this.getLastChildName(e);return t?new Ut(t,this.children_.get(t)):null},e.prototype.forEachChild=function(e,t){var n=this.resolveIndex_(e);return n?n.inorderTraversal(function(e){return t(e.name,e.node)}):this.children_.inorderTraversal(t)},e.prototype.getIterator=function(e){return this.getIteratorFrom(e.minPost(),e)},e.prototype.getIteratorFrom=function(e,t){var n=this.resolveIndex_(t);if(n)return n.getIteratorFrom(e,function(e){return e});for(var r=this.children_.getIteratorFrom(e.name,Ut.Wrap),i=r.peek();null!=i&&t.compare(i,e)<0;)r.getNext(),i=r.peek();return r},e.prototype.getReverseIterator=function(e){return this.getReverseIteratorFrom(e.maxPost(),e)},e.prototype.getReverseIteratorFrom=function(e,t){var n=this.resolveIndex_(t);if(n)return n.getReverseIteratorFrom(e,function(e){return e});for(var r=this.children_.getReverseIteratorFrom(e.name,Ut.Wrap),i=r.peek();null!=i&&t.compare(i,e)>0;)r.getNext(),i=r.peek();return r},e.prototype.compareTo=function(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===gn?-1:0},e.prototype.withIndex=function(t){if(t===Qt||this.indexMap_.hasIndex(t))return this;var n=this.indexMap_.addIndex(t,this.children_);return new e(this.children_,this.priorityNode_,n)},e.prototype.isIndexed=function(e){return e===Qt||this.indexMap_.hasIndex(e)},e.prototype.equals=function(e){if(e===this)return!0;if(e.isLeafNode())return!1;var t=e;if(this.getPriority().equals(t.getPriority())){if(this.children_.count()===t.children_.count()){for(var n=this.getIterator(cn),r=t.getIterator(cn),i=n.getNext(),o=r.getNext();i&&o;){if(i.name!==o.name||!i.node.equals(o.node))return!1;i=n.getNext(),o=r.getNext()}return null===i&&null===o}return!1}return!1},e.prototype.resolveIndex_=function(e){return e===Qt?null:this.indexMap_.get(e.toString())},e.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,e}(),yn=function(e){function t(){return e.call(this,new Kt($t),vn.EMPTY_NODE,_n.Default)||this}return(0,i.__extends)(t,e),t.prototype.compareTo=function(e){return e===this?0:1},t.prototype.equals=function(e){return e===this},t.prototype.getPriority=function(){return this},t.prototype.getImmediateChild=function(e){return vn.EMPTY_NODE},t.prototype.isEmpty=function(){return!1},t}(vn),gn=new yn;Object.defineProperties(Ut,{MIN:{value:new Ut(R,vn.EMPTY_NODE)},MAX:{value:new Ut(A,gn)}}),Vt.__EMPTY_NODE=vn.EMPTY_NODE,rn.__childrenNodeConstructor=vn,Jt(gn),an(gn);var mn=!0;function Cn(e,t){if(void 0===t&&(t=null),null===e)return vn.EMPTY_NODE;if("object"==typeof e&&".priority"in e&&(t=e[".priority"]),(0,r.assert)(null===t||"string"==typeof t||"number"==typeof t||"object"==typeof t&&".sv"in t,"Invalid priority type found: "+typeof t),"object"==typeof e&&".value"in e&&null!==e[".value"]&&(e=e[".value"]),"object"!=typeof e||".sv"in e)return new rn(e,Cn(t));if(e instanceof Array||!mn){var n=vn.EMPTY_NODE;return L(e,function(t,i){if((0,r.contains)(e,t)&&"."!==t.substring(0,1)){var o=Cn(i);!o.isLeafNode()&&o.isEmpty()||(n=n.updateImmediateChild(t,o))}}),n.updatePriority(Cn(t))}var i=[],o=!1;if(L(e,function(e,t){if("."!==e.substring(0,1)){var n=Cn(t);n.isEmpty()||(o=o||!n.getPriority().isEmpty(),i.push(new Ut(e,n)))}}),0===i.length)return vn.EMPTY_NODE;var a=pn(i,Gt,function(e){return e.name},$t);if(o){var s=pn(i,cn.getCompare());return new vn(a,Cn(t),new _n({".priority":s},{".priority":cn}))}return new vn(a,Cn(t),_n.Default)}on(Cn);var wn=function(e){function t(t){var n=e.call(this)||this;return n.indexPath_=t,(0,r.assert)(!mt(t)&&".priority"!==ht(t),"Can't create PathIndex with empty path or .priority key"),n}return(0,i.__extends)(t,e),t.prototype.extractChild=function(e){return e.getChild(this.indexPath_)},t.prototype.isDefinedOn=function(e){return!e.getChild(this.indexPath_).isEmpty()},t.prototype.compare=function(e,t){var n=this.extractChild(e.node),r=this.extractChild(t.node),i=n.compareTo(r);return 0===i?D(e.name,t.name):i},t.prototype.makePost=function(e,t){var n=Cn(e),r=vn.EMPTY_NODE.updateChild(this.indexPath_,n);return new Ut(t,r)},t.prototype.maxPost=function(){var e=vn.EMPTY_NODE.updateChild(this.indexPath_,gn);return new Ut(A,e)},t.prototype.toString=function(){return vt(this.indexPath_,0).join("/")},t}(Bt),bn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,i.__extends)(t,e),t.prototype.compare=function(e,t){var n=e.node.compareTo(t.node);return 0===n?D(e.name,t.name):n},t.prototype.isDefinedOn=function(e){return!0},t.prototype.indexedValueChanged=function(e,t){return!e.equals(t)},t.prototype.minPost=function(){return Ut.MIN},t.prototype.maxPost=function(){return Ut.MAX},t.prototype.makePost=function(e,t){var n=Cn(e);return new Ut(t,n)},t.prototype.toString=function(){return".value"},t}(Bt),Tn=new bn,kn="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",In="-",En="z",Sn=786,Pn=function(){var e=0,t=[];return function(n){var i,o=n===e;e=n;var a=new Array(8);for(i=7;i>=0;i--)a[i]=kn.charAt(n%64),n=Math.floor(n/64);(0,r.assert)(0===n,"Cannot push at time == 0");var s=a.join("");if(o){for(i=11;i>=0&&63===t[i];i--)t[i]=0;t[i]++}else for(i=0;i<12;i++)t[i]=Math.floor(64*Math.random());for(i=0;i<12;i++)s+=kn.charAt(t[i]);return(0,r.assert)(20===s.length,"nextPushId: Length should be 20."),s}}(),xn=function(e){if(e===""+H)return In;var t=z(e);if(null!=t)return""+(t+1);for(var n=new Array(e.length),r=0;r<n.length;r++)n[r]=e.charAt(r);if(n.length<Sn)return n.push(In),n.join("");for(var i=n.length-1;i>=0&&n[i]===En;)i--;if(-1===i)return A;var o=n[i],a=kn.charAt(kn.indexOf(o)+1);return n[i]=a,n.slice(0,i+1).join("")},Nn=function(e){if(e===""+Q)return R;var t=z(e);if(null!=t)return""+(t-1);for(var n=new Array(e.length),r=0;r<n.length;r++)n[r]=e.charAt(r);return n[n.length-1]===In?1===n.length?""+H:(delete n[n.length-1],n.join("")):(n[n.length-1]=kn.charAt(kn.indexOf(n[n.length-1])-1),n.join("")+En.repeat(Sn-n.length))};function Rn(e){return{type:"value",snapshotNode:e}}function An(e,t){return{type:"child_added",snapshotNode:t,childName:e}}function Dn(e,t){return{type:"child_removed",snapshotNode:t,childName:e}}function On(e,t,n){return{type:"child_changed",snapshotNode:t,childName:e,oldSnap:n}}function Mn(e,t){return{type:"child_moved",snapshotNode:t,childName:e}}var qn=function(){function e(e){this.index_=e}return e.prototype.updateChild=function(e,t,n,i,o,a){(0,r.assert)(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");var s=e.getImmediateChild(t);return s.getChild(i).equals(n.getChild(i))&&s.isEmpty()===n.isEmpty()?e:(null!=a&&(n.isEmpty()?e.hasChild(t)?a.trackChildChange(Dn(t,s)):(0,r.assert)(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):s.isEmpty()?a.trackChildChange(An(t,n)):a.trackChildChange(On(t,n,s))),e.isLeafNode()&&n.isEmpty()?e:e.updateImmediateChild(t,n).withIndex(this.index_))},e.prototype.updateFullNode=function(e,t,n){return null!=n&&(e.isLeafNode()||e.forEachChild(cn,function(e,r){t.hasChild(e)||n.trackChildChange(Dn(e,r))}),t.isLeafNode()||t.forEachChild(cn,function(t,r){if(e.hasChild(t)){var i=e.getImmediateChild(t);i.equals(r)||n.trackChildChange(On(t,r,i))}else n.trackChildChange(An(t,r))})),t.withIndex(this.index_)},e.prototype.updatePriority=function(e,t){return e.isEmpty()?vn.EMPTY_NODE:e.updatePriority(t)},e.prototype.filtersNodes=function(){return!1},e.prototype.getIndexedFilter=function(){return this},e.prototype.getIndex=function(){return this.index_},e}(),Fn=function(){function e(t){this.indexedFilter_=new qn(t.getIndex()),this.index_=t.getIndex(),this.startPost_=e.getStartPost_(t),this.endPost_=e.getEndPost_(t)}return e.prototype.getStartPost=function(){return this.startPost_},e.prototype.getEndPost=function(){return this.endPost_},e.prototype.matches=function(e){return this.index_.compare(this.getStartPost(),e)<=0&&this.index_.compare(e,this.getEndPost())<=0},e.prototype.updateChild=function(e,t,n,r,i,o){return this.matches(new Ut(t,n))||(n=vn.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,n,r,i,o)},e.prototype.updateFullNode=function(e,t,n){t.isLeafNode()&&(t=vn.EMPTY_NODE);var r=t.withIndex(this.index_);r=r.updatePriority(vn.EMPTY_NODE);var i=this;return t.forEachChild(cn,function(e,t){i.matches(new Ut(e,t))||(r=r.updateImmediateChild(e,vn.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,r,n)},e.prototype.updatePriority=function(e,t){return e},e.prototype.filtersNodes=function(){return!0},e.prototype.getIndexedFilter=function(){return this.indexedFilter_},e.prototype.getIndex=function(){return this.index_},e.getStartPost_=function(e){if(e.hasStart()){var t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}return e.getIndex().minPost()},e.getEndPost_=function(e){if(e.hasEnd()){var t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}return e.getIndex().maxPost()},e}(),Ln=function(){function e(e){this.rangedFilter_=new Fn(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft()}return e.prototype.updateChild=function(e,t,n,r,i,o){return this.rangedFilter_.matches(new Ut(t,n))||(n=vn.EMPTY_NODE),e.getImmediateChild(t).equals(n)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,n,r,i,o):this.fullLimitUpdateChild_(e,t,n,i,o)},e.prototype.updateFullNode=function(e,t,n){var r;if(t.isLeafNode()||t.isEmpty())r=vn.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<t.numChildren()&&t.isIndexed(this.index_)){r=vn.EMPTY_NODE.withIndex(this.index_);var i=void 0;i=this.reverse_?t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);for(var o=0;i.hasNext()&&o<this.limit_;){var a=i.getNext();if(!(this.reverse_?this.index_.compare(this.rangedFilter_.getStartPost(),a)<=0:this.index_.compare(a,this.rangedFilter_.getEndPost())<=0))break;r=r.updateImmediateChild(a.name,a.node),o++}}else{r=(r=t.withIndex(this.index_)).updatePriority(vn.EMPTY_NODE);var s=void 0,u=void 0,l=void 0;i=void 0;if(this.reverse_){i=r.getReverseIterator(this.index_),s=this.rangedFilter_.getEndPost(),u=this.rangedFilter_.getStartPost();var c=this.index_.getCompare();l=function(e,t){return c(t,e)}}else i=r.getIterator(this.index_),s=this.rangedFilter_.getStartPost(),u=this.rangedFilter_.getEndPost(),l=this.index_.getCompare();o=0;for(var h=!1;i.hasNext();){a=i.getNext();!h&&l(s,a)<=0&&(h=!0),h&&o<this.limit_&&l(a,u)<=0?o++:r=r.updateImmediateChild(a.name,vn.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,r,n)},e.prototype.updatePriority=function(e,t){return e},e.prototype.filtersNodes=function(){return!0},e.prototype.getIndexedFilter=function(){return this.rangedFilter_.getIndexedFilter()},e.prototype.getIndex=function(){return this.index_},e.prototype.fullLimitUpdateChild_=function(e,t,n,i,o){var a;if(this.reverse_){var s=this.index_.getCompare();a=function(e,t){return s(t,e)}}else a=this.index_.getCompare();var u=e;(0,r.assert)(u.numChildren()===this.limit_,"");var l=new Ut(t,n),c=this.reverse_?u.getFirstChild(this.index_):u.getLastChild(this.index_),h=this.rangedFilter_.matches(l);if(u.hasChild(t)){for(var d=u.getImmediateChild(t),p=i.getChildAfterChild(this.index_,c,this.reverse_);null!=p&&(p.name===t||u.hasChild(p.name));)p=i.getChildAfterChild(this.index_,p,this.reverse_);var f=null==p?1:a(p,l);if(h&&!n.isEmpty()&&f>=0)return null!=o&&o.trackChildChange(On(t,n,d)),u.updateImmediateChild(t,n);null!=o&&o.trackChildChange(Dn(t,d));var _=u.updateImmediateChild(t,vn.EMPTY_NODE);return null!=p&&this.rangedFilter_.matches(p)?(null!=o&&o.trackChildChange(An(p.name,p.node)),_.updateImmediateChild(p.name,p.node)):_}return n.isEmpty()?e:h&&a(c,l)>=0?(null!=o&&(o.trackChildChange(Dn(c.name,c.node)),o.trackChildChange(An(t,n))),u.updateImmediateChild(t,n).updateImmediateChild(c.name,vn.EMPTY_NODE)):e},e}(),Wn=function(){function e(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=cn}return e.prototype.hasStart=function(){return this.startSet_},e.prototype.hasStartAfter=function(){return this.startAfterSet_},e.prototype.hasEndBefore=function(){return this.endBeforeSet_},e.prototype.isViewFromLeft=function(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_},e.prototype.getIndexStartValue=function(){return(0,r.assert)(this.startSet_,"Only valid if start has been set"),this.indexStartValue_},e.prototype.getIndexStartName=function(){return(0,r.assert)(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:R},e.prototype.hasEnd=function(){return this.endSet_},e.prototype.getIndexEndValue=function(){return(0,r.assert)(this.endSet_,"Only valid if end has been set"),this.indexEndValue_},e.prototype.getIndexEndName=function(){return(0,r.assert)(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:A},e.prototype.hasLimit=function(){return this.limitSet_},e.prototype.hasAnchoredLimit=function(){return this.limitSet_&&""!==this.viewFrom_},e.prototype.getLimit=function(){return(0,r.assert)(this.limitSet_,"Only valid if limit has been set"),this.limit_},e.prototype.getIndex=function(){return this.index_},e.prototype.loadsAllData=function(){return!(this.startSet_||this.endSet_||this.limitSet_)},e.prototype.isDefault=function(){return this.loadsAllData()&&this.index_===cn},e.prototype.copy=function(){var t=new e;return t.limitSet_=this.limitSet_,t.limit_=this.limit_,t.startSet_=this.startSet_,t.indexStartValue_=this.indexStartValue_,t.startNameSet_=this.startNameSet_,t.indexStartName_=this.indexStartName_,t.endSet_=this.endSet_,t.indexEndValue_=this.indexEndValue_,t.endNameSet_=this.endNameSet_,t.indexEndName_=this.indexEndName_,t.index_=this.index_,t.viewFrom_=this.viewFrom_,t},e}();function jn(e){return e.loadsAllData()?new qn(e.getIndex()):e.hasLimit()?new Ln(e):new Fn(e)}function Un(e,t){var n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="l",n}function Bn(e,t){var n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="r",n}function Vn(e,t,n){var r=e.copy();return r.startSet_=!0,void 0===t&&(t=null),r.indexStartValue_=t,null!=n?(r.startNameSet_=!0,r.indexStartName_=n):(r.startNameSet_=!1,r.indexStartName_=""),r}function Qn(e,t,n){var r;if(e.index_===Qt)"string"==typeof t&&(t=xn(t)),r=Vn(e,t,n);else{r=Vn(e,t,null==n?A:xn(n))}return r.startAfterSet_=!0,r}function Hn(e,t,n){var r=e.copy();return r.endSet_=!0,void 0===t&&(t=null),r.indexEndValue_=t,void 0!==n?(r.endNameSet_=!0,r.indexEndName_=n):(r.endNameSet_=!1,r.indexEndName_=""),r}function zn(e,t,n){var r;return e.index_===Qt?("string"==typeof t&&(t=Nn(t)),r=Hn(e,t,n)):r=Hn(e,t,null==n?R:Nn(n)),r.endBeforeSet_=!0,r}function Yn(e,t){var n=e.copy();return n.index_=t,n}function Kn(e){var t,n={};return e.isDefault()?n:(e.index_===cn?t="$priority":e.index_===Tn?t="$value":e.index_===Qt?t="$key":((0,r.assert)(e.index_ instanceof wn,"Unrecognized index type!"),t=e.index_.toString()),n.orderBy=(0,r.stringify)(t),e.startSet_&&(n.startAt=(0,r.stringify)(e.indexStartValue_),e.startNameSet_&&(n.startAt+=","+(0,r.stringify)(e.indexStartName_))),e.endSet_&&(n.endAt=(0,r.stringify)(e.indexEndValue_),e.endNameSet_&&(n.endAt+=","+(0,r.stringify)(e.indexEndName_))),e.limitSet_&&(e.isViewFromLeft()?n.limitToFirst=e.limit_:n.limitToLast=e.limit_),n)}function Gn(e){var t={};if(e.startSet_&&(t.sp=e.indexStartValue_,e.startNameSet_&&(t.sn=e.indexStartName_)),e.endSet_&&(t.ep=e.indexEndValue_,e.endNameSet_&&(t.en=e.indexEndName_)),e.limitSet_){t.l=e.limit_;var n=e.viewFrom_;""===n&&(n=e.isViewFromLeft()?"l":"r"),t.vf=n}return e.index_!==cn&&(t.i=e.index_.toString()),t}var $n=function(e){function t(t,n,r,i){var o=e.call(this)||this;return o.repoInfo_=t,o.onDataUpdate_=n,o.authTokenProvider_=r,o.appCheckTokenProvider_=i,o.log_=k("p:rest:"),o.listens_={},o}return(0,i.__extends)(t,e),t.prototype.reportStats=function(e){throw new Error("Method not implemented.")},t.getListenId_=function(e,t){return void 0!==t?"tag$"+t:((0,r.assert)(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())},t.prototype.listen=function(e,n,i,o){var a=this,s=e._path.toString();this.log_("Listen called for "+s+" "+e._queryIdentifier);var u=t.getListenId_(e,i),l={};this.listens_[u]=l;var c=Kn(e._queryParams);this.restRequest_(s+".json",c,function(e,t){var n=t;(404===e&&(n=null,e=null),null===e&&a.onDataUpdate_(s,n,!1,i),(0,r.safeGet)(a.listens_,u)===l)&&o(e?401===e?"permission_denied":"rest_error:"+e:"ok",null)})},t.prototype.unlisten=function(e,n){var r=t.getListenId_(e,n);delete this.listens_[r]},t.prototype.get=function(e){var t=this,n=Kn(e._queryParams),i=e._path.toString(),o=new r.Deferred;return this.restRequest_(i+".json",n,function(e,n){var r=n;404===e&&(r=null,e=null),null===e?(t.onDataUpdate_(i,r,!1,null),o.resolve(r)):o.reject(new Error(r))}),o.promise},t.prototype.refreshAuthToken=function(e){},t.prototype.restRequest_=function(e,t,n){var o=this;return void 0===t&&(t={}),t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(function(a){var s=(0,i.__read)(a,2),u=s[0],l=s[1];u&&u.accessToken&&(t.auth=u.accessToken),l&&l.token&&(t.ac=l.token);var c=(o.repoInfo_.secure?"https://":"http://")+o.repoInfo_.host+e+"?ns="+o.repoInfo_.namespace+(0,r.querystring)(t);o.log_("Sending REST request for "+c);var h=new XMLHttpRequest;h.onreadystatechange=function(){if(n&&4===h.readyState){o.log_("REST Response for "+c+" received. status:",h.status,"response:",h.responseText);var e=null;if(h.status>=200&&h.status<300){try{e=(0,r.jsonEval)(h.responseText)}catch(t){S("Failed to parse JSON response for "+c+": "+h.responseText)}n(null,e)}else 401!==h.status&&404!==h.status&&S("Got unsuccessful REST response for "+c+" Status: "+h.status),n(h.status);n=null}},h.open("GET",c,!0),h.send()})},t}(it),Jn=function(){function e(){this.rootNode_=vn.EMPTY_NODE}return e.prototype.getNode=function(e){return this.rootNode_.getChild(e)},e.prototype.updateSnapshot=function(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)},e}();function Xn(){return{value:null,children:new Map}}function Zn(e,t,n){if(mt(t))e.value=n,e.children.clear();else if(null!==e.value)e.value=e.value.updateChild(t,n);else{var r=ht(t);e.children.has(r)||e.children.set(r,Xn()),Zn(e.children.get(r),t=pt(t),n)}}function er(e,t){if(mt(t))return e.value=null,e.children.clear(),!0;if(null!==e.value){if(e.value.isLeafNode())return!1;var n=e.value;return e.value=null,n.forEachChild(cn,function(t,n){Zn(e,new lt(t),n)}),er(e,t)}if(e.children.size>0){var r=ht(t);if(t=pt(t),e.children.has(r))er(e.children.get(r),t)&&e.children.delete(r);return 0===e.children.size}return!0}function tr(e,t,n){null!==e.value?n(t,e.value):nr(e,function(e,r){tr(r,new lt(t.toString()+"/"+e),n)})}function nr(e,t){e.children.forEach(function(e,n){t(n,e)})}var rr,ir=function(){function e(e){this.collection_=e,this.last_=null}return e.prototype.get=function(){var e=this.collection_.get(),t=(0,i.__assign)({},e);return this.last_&&L(this.last_,function(e,n){t[e]=t[e]-n}),this.last_=e,t},e}(),or=1e4,ar=3e4,sr=3e5,ur=function(){function e(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new ir(e);var n=or+(ar-or)*Math.random();G(this.reportStats_.bind(this),Math.floor(n))}return e.prototype.reportStats_=function(){var e=this,t=this.statsListener_.get(),n={},i=!1;L(t,function(t,o){o>0&&(0,r.contains)(e.statsToReport_,t)&&(n[t]=o,i=!0)}),i&&this.server_.reportStats(n),G(this.reportStats_.bind(this),Math.floor(2*Math.random()*sr))},e}();function lr(e,t){e.statsToReport_[t]=!0}function cr(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function hr(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function dr(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}!function(e){e[e.OVERWRITE=0]="OVERWRITE",e[e.MERGE=1]="MERGE",e[e.ACK_USER_WRITE=2]="ACK_USER_WRITE",e[e.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(rr||(rr={}));var pr,fr=function(){function e(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=rr.ACK_USER_WRITE,this.source=cr()}return e.prototype.operationForChild=function(t){if(mt(this.path)){if(null!=this.affectedTree.value)return(0,r.assert)(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var n=this.affectedTree.subtree(new lt(t));return new e(ct(),n,this.revert)}return(0,r.assert)(ht(this.path)===t,"operationForChild called for unrelated child."),new e(pt(this.path),this.affectedTree,this.revert)},e}(),_r=function(){function e(e,t){this.source=e,this.path=t,this.type=rr.LISTEN_COMPLETE}return e.prototype.operationForChild=function(t){return mt(this.path)?new e(this.source,ct()):new e(this.source,pt(this.path))},e}(),vr=function(){function e(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=rr.OVERWRITE}return e.prototype.operationForChild=function(t){return mt(this.path)?new e(this.source,ct(),this.snap.getImmediateChild(t)):new e(this.source,pt(this.path),this.snap)},e}(),yr=function(){function e(e,t,n){this.source=e,this.path=t,this.children=n,this.type=rr.MERGE}return e.prototype.operationForChild=function(t){if(mt(this.path)){var n=this.children.subtree(new lt(t));return n.isEmpty()?null:n.value?new vr(this.source,ct(),n.value):new e(this.source,ct(),n)}return(0,r.assert)(ht(this.path)===t,"Can't get a merge for a child not on the path of the operation"),new e(this.source,pt(this.path),this.children)},e.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"},e}(),gr=function(){function e(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}return e.prototype.isFullyInitialized=function(){return this.fullyInitialized_},e.prototype.isFiltered=function(){return this.filtered_},e.prototype.isCompleteForPath=function(e){if(mt(e))return this.isFullyInitialized()&&!this.filtered_;var t=ht(e);return this.isCompleteForChild(t)},e.prototype.isCompleteForChild=function(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)},e.prototype.getNode=function(){return this.node_},e}(),mr=function(){return function(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}();function Cr(e,t,n,r){var i=[],o=[];return t.forEach(function(t){"child_changed"===t.type&&e.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&&o.push(Mn(t.childName,t.snapshotNode))}),wr(e,i,"child_removed",t,r,n),wr(e,i,"child_added",t,r,n),wr(e,i,"child_moved",o,r,n),wr(e,i,"child_changed",t,r,n),wr(e,i,"value",t,r,n),i}function wr(e,t,n,r,i,o){var a=r.filter(function(e){return e.type===n});a.sort(function(t,n){return Tr(e,t,n)}),a.forEach(function(n){var r=br(e,n,o);i.forEach(function(i){i.respondsTo(n.type)&&t.push(i.createEvent(r,e.query_))})})}function br(e,t,n){return"value"===t.type||"child_removed"===t.type?t:(t.prevName=n.getPredecessorChildName(t.childName,t.snapshotNode,e.index_),t)}function Tr(e,t,n){if(null==t.childName||null==n.childName)throw(0,r.assertionError)("Should only compare child_ events.");var i=new Ut(t.childName,t.snapshotNode),o=new Ut(n.childName,n.snapshotNode);return e.index_.compare(i,o)}function kr(e,t){return{eventCache:e,serverCache:t}}function Ir(e,t,n,r){return kr(new gr(t,n,r),e.serverCache)}function Er(e,t,n,r){return kr(e.eventCache,new gr(t,n,r))}function Sr(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function Pr(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}var xr=function(){return pr||(pr=new Kt(O)),pr},Nr=function(){function e(e,t){void 0===t&&(t=xr()),this.value=e,this.children=t}return e.fromObject=function(t){var n=new e(null);return L(t,function(e,t){n=n.set(new lt(e),t)}),n},e.prototype.isEmpty=function(){return null===this.value&&this.children.isEmpty()},e.prototype.findRootMostMatchingPathAndValue=function(e,t){if(null!=this.value&&t(this.value))return{path:ct(),value:this.value};if(mt(e))return null;var n=ht(e),r=this.children.get(n);if(null!==r){var i=r.findRootMostMatchingPathAndValue(pt(e),t);return null!=i?{path:gt(new lt(n),i.path),value:i.value}:null}return null},e.prototype.findRootMostValueAndPath=function(e){return this.findRootMostMatchingPathAndValue(e,function(){return!0})},e.prototype.subtree=function(t){if(mt(t))return this;var n=ht(t),r=this.children.get(n);return null!==r?r.subtree(pt(t)):new e(null)},e.prototype.set=function(t,n){if(mt(t))return new e(n,this.children);var r=ht(t),i=(this.children.get(r)||new e(null)).set(pt(t),n),o=this.children.insert(r,i);return new e(this.value,o)},e.prototype.remove=function(t){if(mt(t))return this.children.isEmpty()?new e(null):new e(null,this.children);var n=ht(t),r=this.children.get(n);if(r){var i=r.remove(pt(t)),o=void 0;return o=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),null===this.value&&o.isEmpty()?new e(null):new e(this.value,o)}return this},e.prototype.get=function(e){if(mt(e))return this.value;var t=ht(e),n=this.children.get(t);return n?n.get(pt(e)):null},e.prototype.setTree=function(t,n){if(mt(t))return n;var r=ht(t),i=(this.children.get(r)||new e(null)).setTree(pt(t),n),o=void 0;return o=i.isEmpty()?this.children.remove(r):this.children.insert(r,i),new e(this.value,o)},e.prototype.fold=function(e){return this.fold_(ct(),e)},e.prototype.fold_=function(e,t){var n={};return this.children.inorderTraversal(function(r,i){n[r]=i.fold_(gt(e,r),t)}),t(e,this.value,n)},e.prototype.findOnPath=function(e,t){return this.findOnPath_(e,ct(),t)},e.prototype.findOnPath_=function(e,t,n){var r=!!this.value&&n(t,this.value);if(r)return r;if(mt(e))return null;var i=ht(e),o=this.children.get(i);return o?o.findOnPath_(pt(e),gt(t,i),n):null},e.prototype.foreachOnPath=function(e,t){return this.foreachOnPath_(e,ct(),t)},e.prototype.foreachOnPath_=function(t,n,r){if(mt(t))return this;this.value&&r(n,this.value);var i=ht(t),o=this.children.get(i);return o?o.foreachOnPath_(pt(t),gt(n,i),r):new e(null)},e.prototype.foreach=function(e){this.foreach_(ct(),e)},e.prototype.foreach_=function(e,t){this.children.inorderTraversal(function(n,r){r.foreach_(gt(e,n),t)}),this.value&&t(e,this.value)},e.prototype.foreachChild=function(e){this.children.inorderTraversal(function(t,n){n.value&&e(t,n.value)})},e}(),Rr=function(){function e(e){this.writeTree_=e}return e.empty=function(){return new e(new Nr(null))},e}();function Ar(e,t,n){if(mt(t))return new Rr(new Nr(n));var r=e.writeTree_.findRootMostValueAndPath(t);if(null!=r){var i=r.path,o=r.value,a=Ct(i,t);return o=o.updateChild(a,n),new Rr(e.writeTree_.set(i,o))}var s=new Nr(n),u=e.writeTree_.setTree(t,s);return new Rr(u)}function Dr(e,t,n){var r=e;return L(n,function(e,n){r=Ar(r,gt(t,e),n)}),r}function Or(e,t){if(mt(t))return Rr.empty();var n=e.writeTree_.setTree(t,new Nr(null));return new Rr(n)}function Mr(e,t){return null!=qr(e,t)}function qr(e,t){var n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(Ct(n.path,t)):null}function Fr(e){var t=[],n=e.writeTree_.value;return null!=n?n.isLeafNode()||n.forEachChild(cn,function(e,n){t.push(new Ut(e,n))}):e.writeTree_.children.inorderTraversal(function(e,n){null!=n.value&&t.push(new Ut(e,n.value))}),t}function Lr(e,t){if(mt(t))return e;var n=qr(e,t);return new Rr(null!=n?new Nr(n):e.writeTree_.subtree(t))}function Wr(e){return e.writeTree_.isEmpty()}function jr(e,t){return Ur(ct(),e.writeTree_,t)}function Ur(e,t,n){if(null!=t.value)return n.updateChild(e,t.value);var i=null;return t.children.inorderTraversal(function(t,o){".priority"===t?((0,r.assert)(null!==o.value,"Priority writes must always be leaf nodes"),i=o.value):n=Ur(gt(e,t),o,n)}),n.getChild(e).isEmpty()||null===i||(n=n.updateChild(gt(e,".priority"),i)),n}function Br(e,t){return hi(t,e)}function Vr(e,t,n,i,o){(0,r.assert)(i>e.lastWriteId,"Stacking an older write on top of newer ones"),void 0===o&&(o=!0),e.allWrites.push({path:t,snap:n,writeId:i,visible:o}),o&&(e.visibleWrites=Ar(e.visibleWrites,t,n)),e.lastWriteId=i}function Qr(e,t,n,i){(0,r.assert)(i>e.lastWriteId,"Stacking an older merge on top of newer ones"),e.allWrites.push({path:t,children:n,writeId:i,visible:!0}),e.visibleWrites=Dr(e.visibleWrites,t,n),e.lastWriteId=i}function Hr(e,t){for(var n=0;n<e.allWrites.length;n++){var r=e.allWrites[n];if(r.writeId===t)return r}return null}function zr(e,t){var n=e.allWrites.findIndex(function(e){return e.writeId===t});(0,r.assert)(n>=0,"removeWrite called with nonexistent writeId.");var i=e.allWrites[n];e.allWrites.splice(n,1);for(var o=i.visible,a=!1,s=e.allWrites.length-1;o&&s>=0;){var u=e.allWrites[s];u.visible&&(s>=n&&Yr(u,i.path)?o=!1:Tt(i.path,u.path)&&(a=!0)),s--}if(o){if(a)return Kr(e),!0;i.snap?e.visibleWrites=Or(e.visibleWrites,i.path):L(i.children,function(t){e.visibleWrites=Or(e.visibleWrites,gt(i.path,t))});return!0}return!1}function Yr(e,t){if(e.snap)return Tt(e.path,t);for(var n in e.children)if(e.children.hasOwnProperty(n)&&Tt(gt(e.path,n),t))return!0;return!1}function Kr(e){e.visibleWrites=$r(e.allWrites,Gr,ct()),e.allWrites.length>0?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1}function Gr(e){return e.visible}function $r(e,t,n){for(var i=Rr.empty(),o=0;o<e.length;++o){var a=e[o];if(t(a)){var s=a.path,u=void 0;if(a.snap)Tt(n,s)?i=Ar(i,u=Ct(n,s),a.snap):Tt(s,n)&&(u=Ct(s,n),i=Ar(i,ct(),a.snap.getChild(u)));else{if(!a.children)throw(0,r.assertionError)("WriteRecord should have .snap or .children");if(Tt(n,s))i=Dr(i,u=Ct(n,s),a.children);else if(Tt(s,n))if(mt(u=Ct(s,n)))i=Dr(i,ct(),a.children);else{var l=(0,r.safeGet)(a.children,ht(u));if(l){var c=l.getChild(pt(u));i=Ar(i,ct(),c)}}}}}return i}function Jr(e,t,n,r,i){if(r||i){var o=Lr(e.visibleWrites,t);if(!i&&Wr(o))return n;if(i||null!=n||Mr(o,ct())){return jr($r(e.allWrites,function(e){return(e.visible||i)&&(!r||!~r.indexOf(e.writeId))&&(Tt(e.path,t)||Tt(t,e.path))},t),n||vn.EMPTY_NODE)}return null}var a=qr(e.visibleWrites,t);if(null!=a)return a;var s=Lr(e.visibleWrites,t);return Wr(s)?n:null!=n||Mr(s,ct())?jr(s,n||vn.EMPTY_NODE):null}function Xr(e,t,n){var r=vn.EMPTY_NODE,i=qr(e.visibleWrites,t);if(i)return i.isLeafNode()||i.forEachChild(cn,function(e,t){r=r.updateImmediateChild(e,t)}),r;if(n){var o=Lr(e.visibleWrites,t);return n.forEachChild(cn,function(e,t){var n=jr(Lr(o,new lt(e)),t);r=r.updateImmediateChild(e,n)}),Fr(o).forEach(function(e){r=r.updateImmediateChild(e.name,e.node)}),r}return Fr(Lr(e.visibleWrites,t)).forEach(function(e){r=r.updateImmediateChild(e.name,e.node)}),r}function Zr(e,t,n,i,o){(0,r.assert)(i||o,"Either existingEventSnap or existingServerSnap must exist");var a=gt(t,n);if(Mr(e.visibleWrites,a))return null;var s=Lr(e.visibleWrites,a);return Wr(s)?o.getChild(n):jr(s,o.getChild(n))}function ei(e,t,n,r){var i=gt(t,n),o=qr(e.visibleWrites,i);return null!=o?o:r.isCompleteForChild(n)?jr(Lr(e.visibleWrites,i),r.getNode().getImmediateChild(n)):null}function ti(e,t){return qr(e.visibleWrites,t)}function ni(e,t,n,r,i,o,a){var s,u=Lr(e.visibleWrites,t),l=qr(u,ct());if(null!=l)s=l;else{if(null==n)return[];s=jr(u,n)}if((s=s.withIndex(a)).isEmpty()||s.isLeafNode())return[];for(var c=[],h=a.getCompare(),d=o?s.getReverseIteratorFrom(r,a):s.getIteratorFrom(r,a),p=d.getNext();p&&c.length<i;)0!==h(p,r)&&c.push(p),p=d.getNext();return c}function ri(){return{visibleWrites:Rr.empty(),allWrites:[],lastWriteId:-1}}function ii(e,t,n,r){return Jr(e.writeTree,e.treePath,t,n,r)}function oi(e,t){return Xr(e.writeTree,e.treePath,t)}function ai(e,t,n,r){return Zr(e.writeTree,e.treePath,t,n,r)}function si(e,t){return ti(e.writeTree,gt(e.treePath,t))}function ui(e,t,n,r,i,o){return ni(e.writeTree,e.treePath,t,n,r,i,o)}function li(e,t,n){return ei(e.writeTree,e.treePath,t,n)}function ci(e,t){return hi(gt(e.treePath,t),e.writeTree)}function hi(e,t){return{treePath:e,writeTree:t}}var di=function(){function e(){this.changeMap=new Map}return e.prototype.trackChildChange=function(e){var t=e.type,n=e.childName;(0,r.assert)("child_added"===t||"child_changed"===t||"child_removed"===t,"Only child changes supported for tracking"),(0,r.assert)(".priority"!==n,"Only non-priority child changes can be tracked.");var i=this.changeMap.get(n);if(i){var o=i.type;if("child_added"===t&&"child_removed"===o)this.changeMap.set(n,On(n,e.snapshotNode,i.snapshotNode));else if("child_removed"===t&&"child_added"===o)this.changeMap.delete(n);else if("child_removed"===t&&"child_changed"===o)this.changeMap.set(n,Dn(n,i.oldSnap));else if("child_changed"===t&&"child_added"===o)this.changeMap.set(n,An(n,e.snapshotNode));else{if("child_changed"!==t||"child_changed"!==o)throw(0,r.assertionError)("Illegal combination of changes: "+e+" occurred after "+i);this.changeMap.set(n,On(n,e.snapshotNode,i.oldSnap))}}else this.changeMap.set(n,e)},e.prototype.getChanges=function(){return Array.from(this.changeMap.values())},e}(),pi=function(){function e(){}return e.prototype.getCompleteChild=function(e){return null},e.prototype.getChildAfterChild=function(e,t,n){return null},e}(),fi=new pi,_i=function(){function e(e,t,n){void 0===n&&(n=null),this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=n}return e.prototype.getCompleteChild=function(e){var t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);var n=null!=this.optCompleteServerCache_?new gr(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return li(this.writes_,e,n)},e.prototype.getChildAfterChild=function(e,t,n){var r=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:Pr(this.viewCache_),i=ui(this.writes_,r,t,1,n,e);return 0===i.length?null:i[0]},e}();function vi(e){return{filter:e}}function yi(e,t){(0,r.assert)(t.eventCache.getNode().isIndexed(e.filter.getIndex()),"Event snap not indexed"),(0,r.assert)(t.serverCache.getNode().isIndexed(e.filter.getIndex()),"Server snap not indexed")}function gi(e,t,n,i,o){var a,s,u=new di;if(n.type===rr.OVERWRITE){var l=n;l.source.fromUser?a=bi(e,t,l.path,l.snap,i,o,u):((0,r.assert)(l.source.fromServer,"Unknown source."),s=l.source.tagged||t.serverCache.isFiltered()&&!mt(l.path),a=wi(e,t,l.path,l.snap,i,o,s,u))}else if(n.type===rr.MERGE){var c=n;c.source.fromUser?a=ki(e,t,c.path,c.children,i,o,u):((0,r.assert)(c.source.fromServer,"Unknown source."),s=c.source.tagged||t.serverCache.isFiltered(),a=Ei(e,t,c.path,c.children,i,o,s,u))}else if(n.type===rr.ACK_USER_WRITE){var h=n;a=h.revert?xi(e,t,h.path,i,o,u):Si(e,t,h.path,h.affectedTree,i,o,u)}else{if(n.type!==rr.LISTEN_COMPLETE)throw(0,r.assertionError)("Unknown operation type: "+n.type);a=Pi(e,t,n.path,i,u)}var d=u.getChanges();return mi(t,a,d),{viewCache:a,changes:d}}function mi(e,t,n){var r=t.eventCache;if(r.isFullyInitialized()){var i=r.getNode().isLeafNode()||r.getNode().isEmpty(),o=Sr(e);(n.length>0||!e.eventCache.isFullyInitialized()||i&&!r.getNode().equals(o)||!r.getNode().getPriority().equals(o.getPriority()))&&n.push(Rn(Sr(t)))}}function Ci(e,t,n,i,o,a){var s=t.eventCache;if(null!=si(i,n))return t;var u=void 0,l=void 0;if(mt(n))if((0,r.assert)(t.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t.serverCache.isFiltered()){var c=Pr(t),h=oi(i,c instanceof vn?c:vn.EMPTY_NODE);u=e.filter.updateFullNode(t.eventCache.getNode(),h,a)}else{var d=ii(i,Pr(t));u=e.filter.updateFullNode(t.eventCache.getNode(),d,a)}else{var p=ht(n);if(".priority"===p){(0,r.assert)(1===dt(n),"Can't have a priority with additional path components");var f=s.getNode(),_=ai(i,n,f,l=t.serverCache.getNode());u=null!=_?e.filter.updatePriority(f,_):s.getNode()}else{var v=pt(n),y=void 0;if(s.isCompleteForChild(p)){l=t.serverCache.getNode();var g=ai(i,n,s.getNode(),l);y=null!=g?s.getNode().getImmediateChild(p).updateChild(v,g):s.getNode().getImmediateChild(p)}else y=li(i,p,t.serverCache);u=null!=y?e.filter.updateChild(s.getNode(),p,y,v,o,a):s.getNode()}}return Ir(t,u,s.isFullyInitialized()||mt(n),e.filter.filtersNodes())}function wi(e,t,n,r,i,o,a,s){var u,l=t.serverCache,c=a?e.filter:e.filter.getIndexedFilter();if(mt(n))u=c.updateFullNode(l.getNode(),r,null);else if(c.filtersNodes()&&!l.isFiltered()){var h=l.getNode().updateChild(n,r);u=c.updateFullNode(l.getNode(),h,null)}else{var d=ht(n);if(!l.isCompleteForPath(n)&&dt(n)>1)return t;var p=pt(n),f=l.getNode().getImmediateChild(d).updateChild(p,r);u=".priority"===d?c.updatePriority(l.getNode(),f):c.updateChild(l.getNode(),d,f,p,fi,null)}var _=Er(t,u,l.isFullyInitialized()||mt(n),c.filtersNodes());return Ci(e,_,n,i,new _i(i,_,o),s)}function bi(e,t,n,r,i,o,a){var s,u,l=t.eventCache,c=new _i(i,t,o);if(mt(n))u=e.filter.updateFullNode(t.eventCache.getNode(),r,a),s=Ir(t,u,!0,e.filter.filtersNodes());else{var h=ht(n);if(".priority"===h)u=e.filter.updatePriority(t.eventCache.getNode(),r),s=Ir(t,u,l.isFullyInitialized(),l.isFiltered());else{var d=pt(n),p=l.getNode().getImmediateChild(h),f=void 0;if(mt(d))f=r;else{var _=c.getCompleteChild(h);f=null!=_?".priority"===ft(d)&&_.getChild(yt(d)).isEmpty()?_:_.updateChild(d,r):vn.EMPTY_NODE}if(p.equals(f))s=t;else s=Ir(t,e.filter.updateChild(l.getNode(),h,f,d,c,a),l.isFullyInitialized(),e.filter.filtersNodes())}}return s}function Ti(e,t){return e.eventCache.isCompleteForChild(t)}function ki(e,t,n,r,i,o,a){var s=t;return r.foreach(function(r,u){var l=gt(n,r);Ti(t,ht(l))&&(s=bi(e,s,l,u,i,o,a))}),r.foreach(function(r,u){var l=gt(n,r);Ti(t,ht(l))||(s=bi(e,s,l,u,i,o,a))}),s}function Ii(e,t,n){return n.foreach(function(e,n){t=t.updateChild(e,n)}),t}function Ei(e,t,n,r,i,o,a,s){if(t.serverCache.getNode().isEmpty()&&!t.serverCache.isFullyInitialized())return t;var u,l=t;u=mt(n)?r:new Nr(null).setTree(n,r);var c=t.serverCache.getNode();return u.children.inorderTraversal(function(n,r){if(c.hasChild(n)){var u=t.serverCache.getNode().getImmediateChild(n),h=Ii(e,u,r);l=wi(e,l,new lt(n),h,i,o,a,s)}}),u.children.inorderTraversal(function(n,r){var u=!t.serverCache.isCompleteForChild(n)&&void 0===r.value;if(!c.hasChild(n)&&!u){var h=t.serverCache.getNode().getImmediateChild(n),d=Ii(e,h,r);l=wi(e,l,new lt(n),d,i,o,a,s)}}),l}function Si(e,t,n,r,i,o,a){if(null!=si(i,n))return t;var s=t.serverCache.isFiltered(),u=t.serverCache;if(null!=r.value){if(mt(n)&&u.isFullyInitialized()||u.isCompleteForPath(n))return wi(e,t,n,u.getNode().getChild(n),i,o,s,a);if(mt(n)){var l=new Nr(null);return u.getNode().forEachChild(Qt,function(e,t){l=l.set(new lt(e),t)}),Ei(e,t,n,l,i,o,s,a)}return t}var c=new Nr(null);return r.foreach(function(e,t){var r=gt(n,e);u.isCompleteForPath(r)&&(c=c.set(e,u.getNode().getChild(r)))}),Ei(e,t,n,c,i,o,s,a)}function Pi(e,t,n,r,i){var o=t.serverCache;return Ci(e,Er(t,o.getNode(),o.isFullyInitialized()||mt(n),o.isFiltered()),n,r,fi,i)}function xi(e,t,n,i,o,a){var s;if(null!=si(i,n))return t;var u=new _i(i,t,o),l=t.eventCache.getNode(),c=void 0;if(mt(n)||".priority"===ht(n)){var h=void 0;if(t.serverCache.isFullyInitialized())h=ii(i,Pr(t));else{var d=t.serverCache.getNode();(0,r.assert)(d instanceof vn,"serverChildren would be complete if leaf node"),h=oi(i,d)}h=h,c=e.filter.updateFullNode(l,h,a)}else{var p=ht(n),f=li(i,p,t.serverCache);null==f&&t.serverCache.isCompleteForChild(p)&&(f=l.getImmediateChild(p)),(c=null!=f?e.filter.updateChild(l,p,f,pt(n),u,a):t.eventCache.getNode().hasChild(p)?e.filter.updateChild(l,p,vn.EMPTY_NODE,pt(n),u,a):l).isEmpty()&&t.serverCache.isFullyInitialized()&&(s=ii(i,Pr(t))).isLeafNode()&&(c=e.filter.updateFullNode(c,s,a))}return s=t.serverCache.isFullyInitialized()||null!=si(i,ct()),Ir(t,c,s,e.filter.filtersNodes())}var Ni,Ri=function(){function e(e,t){this.query_=e,this.eventRegistrations_=[];var n=this.query_._queryParams,r=new qn(n.getIndex()),i=jn(n);this.processor_=vi(i);var o=t.serverCache,a=t.eventCache,s=r.updateFullNode(vn.EMPTY_NODE,o.getNode(),null),u=i.updateFullNode(vn.EMPTY_NODE,a.getNode(),null),l=new gr(s,o.isFullyInitialized(),r.filtersNodes()),c=new gr(u,a.isFullyInitialized(),i.filtersNodes());this.viewCache_=kr(c,l),this.eventGenerator_=new mr(this.query_)}return Object.defineProperty(e.prototype,"query",{get:function(){return this.query_},enumerable:!1,configurable:!0}),e}();function Ai(e){return e.viewCache_.serverCache.getNode()}function Di(e){return Sr(e.viewCache_)}function Oi(e,t){var n=Pr(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!mt(t)&&!n.getImmediateChild(ht(t)).isEmpty())?n.getChild(t):null}function Mi(e){return 0===e.eventRegistrations_.length}function qi(e,t){e.eventRegistrations_.push(t)}function Fi(e,t,n){var i=[];if(n){(0,r.assert)(null==t,"A cancel should cancel all event registrations.");var o=e.query._path;e.eventRegistrations_.forEach(function(e){var t=e.createCancelEvent(n,o);t&&i.push(t)})}if(t){for(var a=[],s=0;s<e.eventRegistrations_.length;++s){var u=e.eventRegistrations_[s];if(u.matches(t)){if(t.hasAnyCallback()){a=a.concat(e.eventRegistrations_.slice(s+1));break}}else a.push(u)}e.eventRegistrations_=a}else e.eventRegistrations_=[];return i}function Li(e,t,n,i){t.type===rr.MERGE&&null!==t.source.queryId&&((0,r.assert)(Pr(e.viewCache_),"We should always have a full cache before handling merges"),(0,r.assert)(Sr(e.viewCache_),"Missing event cache, even though we have a server cache"));var o=e.viewCache_,a=gi(e.processor_,o,t,n,i);return yi(e.processor_,a.viewCache),(0,r.assert)(a.viewCache.serverCache.isFullyInitialized()||!o.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),e.viewCache_=a.viewCache,ji(e,a.changes,a.viewCache.eventCache.getNode(),null)}function Wi(e,t){var n=e.viewCache_.eventCache,r=[];n.getNode().isLeafNode()||n.getNode().forEachChild(cn,function(e,t){r.push(An(e,t))});return n.isFullyInitialized()&&r.push(Rn(n.getNode())),ji(e,r,n.getNode(),t)}function ji(e,t,n,r){var i=r?[r]:e.eventRegistrations_;return Cr(e.eventGenerator_,t,n,i)}var Ui,Bi=function(){return function(){this.views=new Map}}();function Vi(e){(0,r.assert)(!Ni,"__referenceConstructor has already been defined"),Ni=e}function Qi(){return(0,r.assert)(Ni,"Reference.ts has not been loaded"),Ni}function Hi(e){return 0===e.views.size}function zi(e,t,n,o){var a,s,u=t.source.queryId;if(null!==u){var l=e.views.get(u);return(0,r.assert)(null!=l,"SyncTree gave us an op for an invalid query."),Li(l,t,n,o)}var c=[];try{for(var h=(0,i.__values)(e.views.values()),d=h.next();!d.done;d=h.next()){l=d.value;c=c.concat(Li(l,t,n,o))}}catch(p){a={error:p}}finally{try{d&&!d.done&&(s=h.return)&&s.call(h)}finally{if(a)throw a.error}}return c}function Yi(e,t,n,r,i){var o=t._queryIdentifier,a=e.views.get(o);if(!a){var s=ii(n,i?r:null),u=!1;s?u=!0:r instanceof vn?(s=oi(n,r),u=!1):(s=vn.EMPTY_NODE,u=!1);var l=kr(new gr(s,u,!1),new gr(r,i,!1));return new Ri(t,l)}return a}function Ki(e,t,n,r,i,o){var a=Yi(e,t,r,i,o);return e.views.has(t._queryIdentifier)||e.views.set(t._queryIdentifier,a),qi(a,n),Wi(a,n)}function Gi(e,t,n,r){var o,a,s=t._queryIdentifier,u=[],l=[],c=eo(e);if("default"===s)try{for(var h=(0,i.__values)(e.views.entries()),d=h.next();!d.done;d=h.next()){var p=(0,i.__read)(d.value,2),f=p[0],_=p[1];l=l.concat(Fi(_,n,r)),Mi(_)&&(e.views.delete(f),_.query._queryParams.loadsAllData()||u.push(_.query))}}catch(v){o={error:v}}finally{try{d&&!d.done&&(a=h.return)&&a.call(h)}finally{if(o)throw o.error}}else(_=e.views.get(s))&&(l=l.concat(Fi(_,n,r)),Mi(_)&&(e.views.delete(s),_.query._queryParams.loadsAllData()||u.push(_.query)));return c&&!eo(e)&&u.push(new(Qi())(t._repo,t._path)),{removed:u,events:l}}function $i(e){var t,n,r=[];try{for(var o=(0,i.__values)(e.views.values()),a=o.next();!a.done;a=o.next()){var s=a.value;s.query._queryParams.loadsAllData()||r.push(s)}}catch(u){t={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r}function Ji(e,t){var n,r,o=null;try{for(var a=(0,i.__values)(e.views.values()),s=a.next();!s.done;s=a.next()){var u=s.value;o=o||Oi(u,t)}}catch(l){n={error:l}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return o}function Xi(e,t){if(t._queryParams.loadsAllData())return to(e);var n=t._queryIdentifier;return e.views.get(n)}function Zi(e,t){return null!=Xi(e,t)}function eo(e){return null!=to(e)}function to(e){var t,n;try{for(var r=(0,i.__values)(e.views.values()),o=r.next();!o.done;o=r.next()){var a=o.value;if(a.query._queryParams.loadsAllData())return a}}catch(s){t={error:s}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return null}function no(e){(0,r.assert)(!Ui,"__referenceConstructor has already been defined"),Ui=e}function ro(){return(0,r.assert)(Ui,"Reference.ts has not been loaded"),Ui}var io=1,oo=function(){return function(e){this.listenProvider_=e,this.syncPointTree_=new Nr(null),this.pendingWriteTree_=ri(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}();function ao(e,t,n,r,i){return Vr(e.pendingWriteTree_,t,n,r,i),i?Co(e,new vr(cr(),t,n)):[]}function so(e,t,n,r){Qr(e.pendingWriteTree_,t,n,r);var i=Nr.fromObject(n);return Co(e,new yr(cr(),t,i))}function uo(e,t,n){void 0===n&&(n=!1);var r=Hr(e.pendingWriteTree_,t);if(zr(e.pendingWriteTree_,t)){var i=new Nr(null);return null!=r.snap?i=i.set(ct(),!0):L(r.children,function(e){i=i.set(new lt(e),!0)}),Co(e,new fr(r.path,i,n))}return[]}function lo(e,t,n){return Co(e,new vr(hr(),t,n))}function co(e,t,n){var r=Nr.fromObject(n);return Co(e,new yr(hr(),t,r))}function ho(e,t){return Co(e,new _r(hr(),t))}function po(e,t,n){var r=Eo(e,n);if(r){var i=So(r),o=i.path,a=i.queryId,s=Ct(o,t);return Po(e,o,new _r(dr(a),s))}return[]}function fo(e,t,n,r){var i=t._path,o=e.syncPointTree_.get(i),a=[];if(o&&("default"===t._queryIdentifier||Zi(o,t))){var s=Gi(o,t,n,r);Hi(o)&&(e.syncPointTree_=e.syncPointTree_.remove(i));var u=s.removed;a=s.events;var l=-1!==u.findIndex(function(e){return e._queryParams.loadsAllData()}),c=e.syncPointTree_.findOnPath(i,function(e,t){return eo(t)});if(l&&!c){var h=e.syncPointTree_.subtree(i);if(!h.isEmpty())for(var d=xo(h),p=0;p<d.length;++p){var f=d[p],_=f.query,v=To(e,f);e.listenProvider_.startListening(No(_),ko(e,_),v.hashFn,v.onComplete)}}if(!c&&u.length>0&&!r)if(l){e.listenProvider_.stopListening(No(t),null)}else u.forEach(function(t){var n=e.queryToTagMap.get(Io(t));e.listenProvider_.stopListening(No(t),n)});Ro(e,u)}return a}function _o(e,t,n,r){var i=Eo(e,r);if(null!=i){var o=So(i),a=o.path,s=o.queryId,u=Ct(a,t);return Po(e,a,new vr(dr(s),u,n))}return[]}function vo(e,t,n,r){var i=Eo(e,r);if(i){var o=So(i),a=o.path,s=o.queryId,u=Ct(a,t),l=Nr.fromObject(n);return Po(e,a,new yr(dr(s),u,l))}return[]}function yo(e,t,n){var i=t._path,o=null,a=!1;e.syncPointTree_.foreachOnPath(i,function(e,t){var n=Ct(e,i);o=o||Ji(t,n),a=a||eo(t)});var s,u=e.syncPointTree_.get(i);(u?(a=a||eo(u),o=o||Ji(u,ct())):(u=new Bi,e.syncPointTree_=e.syncPointTree_.set(i,u)),null!=o)?s=!0:(s=!1,o=vn.EMPTY_NODE,e.syncPointTree_.subtree(i).foreachChild(function(e,t){var n=Ji(t,ct());n&&(o=o.updateImmediateChild(e,n))}));var l=Zi(u,t);if(!l&&!t._queryParams.loadsAllData()){var c=Io(t);(0,r.assert)(!e.queryToTagMap.has(c),"View does not exist, but we have a tag");var h=Ao();e.queryToTagMap.set(c,h),e.tagToQueryMap.set(h,c)}var d=Ki(u,t,n,Br(e.pendingWriteTree_,i),o,s);if(!l&&!a){var p=Xi(u,t);d=d.concat(Do(e,t,p))}return d}function go(e,t,n){var r=e.pendingWriteTree_,i=e.syncPointTree_.findOnPath(t,function(e,n){var r=Ji(n,Ct(e,t));if(r)return r});return Jr(r,t,i,n,!0)}function mo(e,t){var n=t._path,r=null;e.syncPointTree_.foreachOnPath(n,function(e,t){var i=Ct(e,n);r=r||Ji(t,i)});var i=e.syncPointTree_.get(n);i?r=r||Ji(i,ct()):(i=new Bi,e.syncPointTree_=e.syncPointTree_.set(n,i));var o=null!=r,a=o?new gr(r,!0,!1):null;return Di(Yi(i,t,Br(e.pendingWriteTree_,t._path),o?a.getNode():vn.EMPTY_NODE,o))}function Co(e,t){return wo(t,e.syncPointTree_,null,Br(e.pendingWriteTree_,ct()))}function wo(e,t,n,r){if(mt(e.path))return bo(e,t,n,r);var i=t.get(ct());null==n&&null!=i&&(n=Ji(i,ct()));var o=[],a=ht(e.path),s=e.operationForChild(a),u=t.children.get(a);if(u&&s){var l=n?n.getImmediateChild(a):null,c=ci(r,a);o=o.concat(wo(s,u,l,c))}return i&&(o=o.concat(zi(i,e,r,n))),o}function bo(e,t,n,r){var i=t.get(ct());null==n&&null!=i&&(n=Ji(i,ct()));var o=[];return t.children.inorderTraversal(function(t,i){var a=n?n.getImmediateChild(t):null,s=ci(r,t),u=e.operationForChild(t);u&&(o=o.concat(bo(u,i,a,s)))}),i&&(o=o.concat(zi(i,e,r,n))),o}function To(e,t){var n=t.query,r=ko(e,n);return{hashFn:function(){return(Ai(t)||vn.EMPTY_NODE).hash()},onComplete:function(t){if("ok"===t)return r?po(e,n._path,r):ho(e,n._path);var i=B(t,n);return fo(e,n,null,i)}}}function ko(e,t){var n=Io(t);return e.queryToTagMap.get(n)}function Io(e){return e._path.toString()+"$"+e._queryIdentifier}function Eo(e,t){return e.tagToQueryMap.get(t)}function So(e){var t=e.indexOf("$");return(0,r.assert)(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new lt(e.substr(0,t))}}function Po(e,t,n){var i=e.syncPointTree_.get(t);return(0,r.assert)(i,"Missing sync point for query tag that we're tracking"),zi(i,n,Br(e.pendingWriteTree_,t),null)}function xo(e){return e.fold(function(e,t,n){if(t&&eo(t))return[to(t)];var r=[];return t&&(r=$i(t)),L(n,function(e,t){r=r.concat(t)}),r})}function No(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?new(ro())(e._repo,e._path):e}function Ro(e,t){for(var n=0;n<t.length;++n){var r=t[n];if(!r._queryParams.loadsAllData()){var i=Io(r),o=e.queryToTagMap.get(i);e.queryToTagMap.delete(i),e.tagToQueryMap.delete(o)}}}function Ao(){return io++}function Do(e,t,n){var i=t._path,o=ko(e,t),a=To(e,n),s=e.listenProvider_.startListening(No(t),o,a.hashFn,a.onComplete),u=e.syncPointTree_.subtree(i);if(o)(0,r.assert)(!eo(u.value),"If we're adding a query, it shouldn't be shadowed");else for(var l=u.fold(function(e,t,n){if(!mt(e)&&t&&eo(t))return[to(t).query];var r=[];return t&&(r=r.concat($i(t).map(function(e){return e.query}))),L(n,function(e,t){r=r.concat(t)}),r}),c=0;c<l.length;++c){var h=l[c];e.listenProvider_.stopListening(No(h),ko(e,h))}return s}var Oo=function(){function e(e){this.node_=e}return e.prototype.getImmediateChild=function(t){return new e(this.node_.getImmediateChild(t))},e.prototype.node=function(){return this.node_},e}(),Mo=function(){function e(e,t){this.syncTree_=e,this.path_=t}return e.prototype.getImmediateChild=function(t){var n=gt(this.path_,t);return new e(this.syncTree_,n)},e.prototype.node=function(){return go(this.syncTree_,this.path_)},e}(),qo=function(e){return(e=e||{}).timestamp=e.timestamp||(new Date).getTime(),e},Fo=function(e,t,n){return e&&"object"==typeof e?((0,r.assert)(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?Lo(e[".sv"],t,n):"object"==typeof e[".sv"]?Wo(e[".sv"],t):void(0,r.assert)(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e},Lo=function(e,t,n){switch(e){case"timestamp":return n.timestamp;default:(0,r.assert)(!1,"Unexpected server value: "+e)}},Wo=function(e,t,n){e.hasOwnProperty("increment")||(0,r.assert)(!1,"Unexpected server value: "+JSON.stringify(e,null,2));var i=e.increment;"number"!=typeof i&&(0,r.assert)(!1,"Unexpected increment value: "+i);var o=t.node();if((0,r.assert)(null!=o,"Expected ChildrenNode.EMPTY_NODE for nulls"),!o.isLeafNode())return i;var a=o.getValue();return"number"!=typeof a?i:a+i},jo=function(e,t,n,r){return Bo(t,new Mo(n,e),r)},Uo=function(e,t,n){return Bo(e,new Oo(t),n)};function Bo(e,t,n){var r,i=e.getPriority().val(),o=Fo(i,t.getImmediateChild(".priority"),n);if(e.isLeafNode()){var a=e,s=Fo(a.getValue(),t,n);return s!==a.getValue()||o!==a.getPriority().val()?new rn(s,Cn(o)):e}var u=e;return r=u,o!==u.getPriority().val()&&(r=r.updatePriority(new rn(o))),u.forEachChild(cn,function(e,i){var o=Bo(i,t.getImmediateChild(e),n);o!==i&&(r=r.updateImmediateChild(e,o))}),r}var Vo=function(){return function(e,t,n){void 0===e&&(e=""),void 0===t&&(t=null),void 0===n&&(n={children:{},childCount:0}),this.name=e,this.parent=t,this.node=n}}();function Qo(e,t){for(var n=t instanceof lt?t:new lt(t),i=e,o=ht(n);null!==o;){var a=(0,r.safeGet)(i.node.children,o)||{children:{},childCount:0};i=new Vo(o,i,a),o=ht(n=pt(n))}return i}function Ho(e){return e.node.value}function zo(e,t){e.node.value=t,Zo(e)}function Yo(e){return e.node.childCount>0}function Ko(e){return void 0===Ho(e)&&!Yo(e)}function Go(e,t){L(e.node.children,function(n,r){t(new Vo(n,e,r))})}function $o(e,t,n,r){n&&!r&&t(e),Go(e,function(e){$o(e,t,!0,r)}),n&&r&&t(e)}function Jo(e,t,n){for(var r=n?e:e.parent;null!==r;){if(t(r))return!0;r=r.parent}return!1}function Xo(e){return new lt(null===e.parent?e.name:Xo(e.parent)+"/"+e.name)}function Zo(e){null!==e.parent&&ea(e.parent,e.name,e)}function ea(e,t,n){var i=Ko(n),o=(0,r.contains)(e.node.children,t);i&&o?(delete e.node.children[t],e.node.childCount--,Zo(e)):i||o||(e.node.children[t]=n.node,e.node.childCount++,Zo(e))}var ta=/[\[\].#$\/\u0000-\u001F\u007F]/,na=/[\[\].#$\u0000-\u001F\u007F]/,ra=10485760,ia=function(e){return"string"==typeof e&&0!==e.length&&!ta.test(e)},oa=function(e){return"string"==typeof e&&0!==e.length&&!na.test(e)},aa=function(e){return e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),oa(e)},sa=function(e){return null===e||"string"==typeof e||"number"==typeof e&&!x(e)||e&&"object"==typeof e&&(0,r.contains)(e,".sv")},ua=function(e,t,n,i){i&&void 0===t||la((0,r.errorPrefix)(e,"value"),t,n)},la=function(e,t,n){var i=n instanceof lt?new kt(n,e):n;if(void 0===t)throw new Error(e+"contains undefined "+Pt(i));if("function"==typeof t)throw new Error(e+"contains a function "+Pt(i)+" with contents = "+t.toString());if(x(t))throw new Error(e+"contains "+t.toString()+" "+Pt(i));if("string"==typeof t&&t.length>ra/3&&(0,r.stringLength)(t)>ra)throw new Error(e+"contains a string greater than "+ra+" utf8 bytes "+Pt(i)+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){var o=!1,a=!1;if(L(t,function(t,n){if(".value"===t)o=!0;else if(".priority"!==t&&".sv"!==t&&(a=!0,!ia(t)))throw new Error(e+" contains an invalid key ("+t+") "+Pt(i)+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');It(i,t),la(e,n,i),Et(i)}),o&&a)throw new Error(e+' contains ".value" child '+Pt(i)+" in addition to actual children.")}},ca=function(e,t){var n,r;for(n=0;n<t.length;n++)for(var i=vt(r=t[n]),o=0;o<i.length;o++)if(".priority"===i[o]&&o===i.length-1);else if(!ia(i[o]))throw new Error(e+"contains an invalid key ("+i[o]+") in path "+r.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');t.sort(wt);var a=null;for(n=0;n<t.length;n++){if(r=t[n],null!==a&&Tt(a,r))throw new Error(e+"contains a path "+a.toString()+" that is ancestor of another path "+r.toString());a=r}},ha=function(e,t,n,i){if(!i||void 0!==t){var o=(0,r.errorPrefix)(e,"values");if(!t||"object"!=typeof t||Array.isArray(t))throw new Error(o+" must be an object containing the children to replace.");var a=[];L(t,function(e,t){var r=new lt(e);if(la(o,t,gt(n,r)),".priority"===ft(r)&&!sa(t))throw new Error(o+"contains an invalid value for '"+r.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");a.push(r)}),ca(o,a)}},da=function(e,t,n){if(!n||void 0!==t){if(x(t))throw new Error((0,r.errorPrefix)(e,"priority")+"is "+t.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!sa(t))throw new Error((0,r.errorPrefix)(e,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}},pa=function(e,t,n){if(!n||void 0!==t)switch(t){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:throw new Error((0,r.errorPrefix)(e,"eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}},fa=function(e,t,n,i){if(!(i&&void 0===n||ia(n)))throw new Error((0,r.errorPrefix)(e,t)+'was an invalid key = "'+n+'". Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')},_a=function(e,t,n,i){if(!(i&&void 0===n||oa(n)))throw new Error((0,r.errorPrefix)(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},va=function(e,t,n,r){n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),_a(e,t,n,r)},ya=function(e,t){if(".info"===ht(t))throw new Error(e+" failed = Can't modify data under /.info/")},ga=function(e,t){var n=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!ia(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&&!aa(n))throw new Error((0,r.errorPrefix)(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')},ma=function(e,t,n,i){if((!i||void 0!==n)&&"boolean"!=typeof n)throw new Error((0,r.errorPrefix)(e,t)+"must be a boolean.")},Ca=function(){return function(){this.eventLists_=[],this.recursionDepth_=0}}();function wa(e,t){for(var n=null,r=0;r<t.length;r++){var i=t[r],o=i.getPath();null===n||bt(o,n.path)||(e.eventLists_.push(n),n=null),null===n&&(n={events:[],path:o}),n.events.push(i)}n&&e.eventLists_.push(n)}function ba(e,t,n){wa(e,n),ka(e,function(e){return bt(e,t)})}function Ta(e,t,n){wa(e,n),ka(e,function(e){return Tt(e,t)||Tt(t,e)})}function ka(e,t){e.recursionDepth_++;for(var n=!0,r=0;r<e.eventLists_.length;r++){var i=e.eventLists_[r];if(i)t(i.path)?(Ia(e.eventLists_[r]),e.eventLists_[r]=null):n=!1}n&&(e.eventLists_=[]),e.recursionDepth_--}function Ia(e){for(var t=0;t<e.events.length;t++){var n=e.events[t];if(null!==n){e.events[t]=null;var r=n.getEventRunner();C&&T("event: "+n.toString()),Y(r)}}}var Ea="repo_interrupt",Sa=25,Pa=function(){function e(e,t,n,r){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=n,this.appCheckProvider_=r,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new Ca,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Xn(),this.transactionQueueTree_=new Vo,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}return e.prototype.toString=function(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host},e}();function xa(e,t,n){if(e.stats_=ve(e.repoInfo_),e.forceRestClient_||K())e.server_=new $n(e.repoInfo_,function(t,n,r,i){Aa(e,t,n,r,i)},e.authTokenProvider_,e.appCheckProvider_),setTimeout(function(){return Oa(e,!0)},0);else{if(null!=n){if("object"!=typeof n)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{(0,r.stringify)(n)}catch(i){throw new Error("Invalid authOverride provided: "+i)}}e.persistentConnection_=new jt(e.repoInfo_,t,function(t,n,r,i){Aa(e,t,n,r,i)},function(t){Oa(e,t)},function(t){Ma(e,t)},e.authTokenProvider_,e.appCheckProvider_,n),e.server_=e.persistentConnection_}e.authTokenProvider_.addTokenChangeListener(function(t){e.server_.refreshAuthToken(t)}),e.appCheckProvider_.addTokenChangeListener(function(t){e.server_.refreshAppCheckToken(t.token)}),e.statsReporter_=ye(e.repoInfo_,function(){return new ur(e.stats_,e.server_)}),e.infoData_=new Jn,e.infoSyncTree_=new oo({startListening:function(t,n,r,i){var o=[],a=e.infoData_.getNode(t._path);return a.isEmpty()||(o=lo(e.infoSyncTree_,t._path,a),setTimeout(function(){i("ok")},0)),o},stopListening:function(){}}),qa(e,"connected",!1),e.serverSyncTree_=new oo({startListening:function(t,n,r,i){return e.server_.listen(t,r,n,function(n,r){var o=i(n,r);Ta(e.eventQueue_,t._path,o)}),[]},stopListening:function(t,n){e.server_.unlisten(t,n)}})}function Na(e){var t=e.infoData_.getNode(new lt(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t}function Ra(e){return qo({timestamp:Na(e)})}function Aa(e,t,n,i,o){e.dataUpdateCount++;var a=new lt(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;var s=[];if(o)if(i){var u=(0,r.map)(n,function(e){return Cn(e)});s=vo(e.serverSyncTree_,a,u,o)}else{var l=Cn(n);s=_o(e.serverSyncTree_,a,l,o)}else if(i){var c=(0,r.map)(n,function(e){return Cn(e)});s=co(e.serverSyncTree_,a,c)}else{var h=Cn(n);s=lo(e.serverSyncTree_,a,h)}var d=a;s.length>0&&(d=is(e,a)),Ta(e.eventQueue_,d,s)}function Da(e,t){e.interceptServerDataCallback_=t}function Oa(e,t){qa(e,"connected",t),!1===t&&Ua(e)}function Ma(e,t){L(t,function(t,n){qa(e,t,n)})}function qa(e,t,n){var r=new lt("/.info/"+t),i=Cn(n);e.infoData_.updateSnapshot(r,i);var o=lo(e.infoSyncTree_,r,i);Ta(e.eventQueue_,r,o)}function Fa(e){return e.nextWriteId_++}function La(e,t){var n=mo(e.serverSyncTree_,t);return null!=n?Promise.resolve(n):e.server_.get(t).then(function(n){var r=Cn(n).withIndex(t._queryParams.getIndex()),i=lo(e.serverSyncTree_,t._path,r);return ba(e.eventQueue_,t._path,i),Promise.resolve(r)},function(n){return Xa(e,"get for query "+(0,r.stringify)(t)+" failed: "+n),Promise.reject(new Error(n))})}function Wa(e,t,n,r,i){Xa(e,"set",{path:t.toString(),value:n,priority:r});var o=Ra(e),a=Cn(n,r),s=go(e.serverSyncTree_,t),u=Uo(a,s,o),l=Fa(e),c=ao(e.serverSyncTree_,t,u,l,!0);wa(e.eventQueue_,c),e.server_.put(t.toString(),a.val(!0),function(n,r){var o="ok"===n;o||S("set at "+t+" failed: "+n);var a=uo(e.serverSyncTree_,l,!o);Ta(e.eventQueue_,t,a),Za(e,i,n,r)});var h=cs(e,t);is(e,h),Ta(e.eventQueue_,h,[])}function ja(e,t,n,r){Xa(e,"update",{path:t.toString(),value:n});var i=!0,o=Ra(e),a={};if(L(n,function(n,r){i=!1,a[n]=jo(gt(t,n),Cn(r),e.serverSyncTree_,o)}),i)T("update() called with empty data. Don't do anything."),Za(e,r,"ok",void 0);else{var s=Fa(e),u=so(e.serverSyncTree_,t,a,s);wa(e.eventQueue_,u),e.server_.merge(t.toString(),n,function(n,i){var o="ok"===n;o||S("update at "+t+" failed: "+n);var a=uo(e.serverSyncTree_,s,!o),u=a.length>0?is(e,t):t;Ta(e.eventQueue_,u,a),Za(e,r,n,i)}),L(n,function(n){var r=cs(e,gt(t,n));is(e,r)}),Ta(e.eventQueue_,t,[])}}function Ua(e){Xa(e,"onDisconnectEvents");var t=Ra(e),n=Xn();tr(e.onDisconnect_,ct(),function(r,i){var o=jo(r,i,e.serverSyncTree_,t);Zn(n,r,o)});var r=[];tr(n,ct(),function(t,n){r=r.concat(lo(e.serverSyncTree_,t,n));var i=cs(e,t);is(e,i)}),e.onDisconnect_=Xn(),Ta(e.eventQueue_,ct(),r)}function Ba(e,t,n){e.server_.onDisconnectCancel(t.toString(),function(r,i){"ok"===r&&er(e.onDisconnect_,t),Za(e,n,r,i)})}function Va(e,t,n,r){var i=Cn(n);e.server_.onDisconnectPut(t.toString(),i.val(!0),function(n,o){"ok"===n&&Zn(e.onDisconnect_,t,i),Za(e,r,n,o)})}function Qa(e,t,n,r,i){var o=Cn(n,r);e.server_.onDisconnectPut(t.toString(),o.val(!0),function(n,r){"ok"===n&&Zn(e.onDisconnect_,t,o),Za(e,i,n,r)})}function Ha(e,t,n,i){if((0,r.isEmpty)(n))return T("onDisconnect().update() called with empty data. Don't do anything."),void Za(e,i,"ok",void 0);e.server_.onDisconnectMerge(t.toString(),n,function(r,o){"ok"===r&&L(n,function(n,r){var i=Cn(r);Zn(e.onDisconnect_,gt(t,n),i)}),Za(e,i,r,o)})}function za(e,t,n){var r;r=".info"===ht(t._path)?yo(e.infoSyncTree_,t,n):yo(e.serverSyncTree_,t,n),ba(e.eventQueue_,t._path,r)}function Ya(e,t,n){var r;r=".info"===ht(t._path)?fo(e.infoSyncTree_,t,n):fo(e.serverSyncTree_,t,n),ba(e.eventQueue_,t._path,r)}function Ka(e){e.persistentConnection_&&e.persistentConnection_.interrupt(Ea)}function Ga(e){e.persistentConnection_&&e.persistentConnection_.resume(Ea)}function $a(e,t){if(void 0===t&&(t=!1),"undefined"!=typeof console){var n;t?(e.statsListener_||(e.statsListener_=new ir(e.stats_)),n=e.statsListener_.get()):n=e.stats_.get();var r=Object.keys(n).reduce(function(e,t){return Math.max(t.length,e)},0);L(n,function(e,t){for(var n=e,i=e.length;i<r+2;i++)n+=" ";console.log(n+t)})}}function Ja(e,t){e.stats_.incrementCounter(t),lr(e.statsReporter_,t)}function Xa(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r="";e.persistentConnection_&&(r=e.persistentConnection_.id+":"),T.apply(void 0,(0,i.__spreadArray)([r],(0,i.__read)(t)))}function Za(e,t,n,r){t&&Y(function(){if("ok"===n)t(null);else{var e=(n||"error").toUpperCase(),i=e;r&&(i+=": "+r);var o=new Error(i);o.code=e,t(o)}})}function es(e,t,n,i,o,a){Xa(e,"transaction on "+t);var s={path:t,update:n,onComplete:i,status:null,order:y(),applyLocally:a,retryCount:0,unwatcher:o,abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},u=ts(e,t,void 0);s.currentInputSnapshot=u;var l=s.update(u.val());if(void 0===l)s.unwatcher(),s.currentOutputSnapshotRaw=null,s.currentOutputSnapshotResolved=null,s.onComplete&&s.onComplete(null,!1,s.currentInputSnapshot);else{la("transaction failed: Data returned ",l,s.path),s.status=0;var c=Qo(e.transactionQueueTree_,t),h=Ho(c)||[];h.push(s),zo(c,h);var d=void 0;if("object"==typeof l&&null!==l&&(0,r.contains)(l,".priority"))d=(0,r.safeGet)(l,".priority"),(0,r.assert)(sa(d),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.");else d=(go(e.serverSyncTree_,t)||vn.EMPTY_NODE).getPriority().val();var p=Ra(e),f=Cn(l,d),_=Uo(f,u,p);s.currentOutputSnapshotRaw=f,s.currentOutputSnapshotResolved=_,s.currentWriteId=Fa(e);var v=ao(e.serverSyncTree_,t,_,s.currentWriteId,s.applyLocally);Ta(e.eventQueue_,t,v),ns(e,e.transactionQueueTree_)}}function ts(e,t,n){return go(e.serverSyncTree_,t,n)||vn.EMPTY_NODE}function ns(e,t){if(void 0===t&&(t=e.transactionQueueTree_),t||ls(e,t),Ho(t)){var n=ss(e,t);(0,r.assert)(n.length>0,"Sending zero length transaction queue"),n.every(function(e){return 0===e.status})&&rs(e,Xo(t),n)}else Yo(t)&&Go(t,function(t){ns(e,t)})}function rs(e,t,n){for(var i=n.map(function(e){return e.currentWriteId}),o=ts(e,t,i),a=o,s=o.hash(),u=0;u<n.length;u++){var l=n[u];(0,r.assert)(0===l.status,"tryToSendTransactionQueue_: items in queue should all be run."),l.status=1,l.retryCount++;var c=Ct(t,l.path);a=a.updateChild(c,l.currentOutputSnapshotRaw)}var h=a.val(!0),d=t;e.server_.put(d.toString(),h,function(r){Xa(e,"transaction put response",{path:d.toString(),status:r});var i=[];if("ok"===r){for(var o=[],a=function(t){n[t].status=2,i=i.concat(uo(e.serverSyncTree_,n[t].currentWriteId)),n[t].onComplete&&o.push(function(){return n[t].onComplete(null,!0,n[t].currentOutputSnapshotResolved)}),n[t].unwatcher()},s=0;s<n.length;s++)a(s);ls(e,Qo(e.transactionQueueTree_,t)),ns(e,e.transactionQueueTree_),Ta(e.eventQueue_,t,i);for(s=0;s<o.length;s++)Y(o[s])}else{if("datastale"===r)for(s=0;s<n.length;s++)3===n[s].status?n[s].status=4:n[s].status=0;else{S("transaction at "+d.toString()+" failed: "+r);for(s=0;s<n.length;s++)n[s].status=4,n[s].abortReason=r}is(e,t)}},s)}function is(e,t){var n=as(e,t),r=Xo(n);return os(e,ss(e,n),r),r}function os(e,t,n){if(0!==t.length){for(var i=[],o=[],a=t.filter(function(e){return 0===e.status}).map(function(e){return e.currentWriteId}),s=function(s){var u,l,c=t[s],h=Ct(n,c.path),d=!1;if((0,r.assert)(null!==h,"rerunTransactionsUnderNode_: relativePath should not be null."),4===c.status)d=!0,u=c.abortReason,o=o.concat(uo(e.serverSyncTree_,c.currentWriteId,!0));else if(0===c.status)if(c.retryCount>=Sa)d=!0,u="maxretry",o=o.concat(uo(e.serverSyncTree_,c.currentWriteId,!0));else{var p=ts(e,c.path,a);c.currentInputSnapshot=p;var f=t[s].update(p.val());if(void 0!==f){la("transaction failed: Data returned ",f,c.path);var _=Cn(f);"object"==typeof f&&null!=f&&(0,r.contains)(f,".priority")||(_=_.updatePriority(p.getPriority()));var v=c.currentWriteId,y=Ra(e),g=Uo(_,p,y);c.currentOutputSnapshotRaw=_,c.currentOutputSnapshotResolved=g,c.currentWriteId=Fa(e),a.splice(a.indexOf(v),1),o=(o=o.concat(ao(e.serverSyncTree_,c.path,g,c.currentWriteId,c.applyLocally))).concat(uo(e.serverSyncTree_,v,!0))}else d=!0,u="nodata",o=o.concat(uo(e.serverSyncTree_,c.currentWriteId,!0))}Ta(e.eventQueue_,n,o),o=[],d&&(t[s].status=2,l=t[s].unwatcher,setTimeout(l,Math.floor(0)),t[s].onComplete&&("nodata"===u?i.push(function(){return t[s].onComplete(null,!1,t[s].currentInputSnapshot)}):i.push(function(){return t[s].onComplete(new Error(u),!1,null)})))},u=0;u<t.length;u++)s(u);ls(e,e.transactionQueueTree_);for(u=0;u<i.length;u++)Y(i[u]);ns(e,e.transactionQueueTree_)}}function as(e,t){var n,r=e.transactionQueueTree_;for(n=ht(t);null!==n&&void 0===Ho(r);)r=Qo(r,n),n=ht(t=pt(t));return r}function ss(e,t){var n=[];return us(e,t,n),n.sort(function(e,t){return e.order-t.order}),n}function us(e,t,n){var r=Ho(t);if(r)for(var i=0;i<r.length;i++)n.push(r[i]);Go(t,function(t){us(e,t,n)})}function ls(e,t){var n=Ho(t);if(n){for(var r=0,i=0;i<n.length;i++)2!==n[i].status&&(n[r]=n[i],r++);n.length=r,zo(t,n.length>0?n:void 0)}Go(t,function(t){ls(e,t)})}function cs(e,t){var n=Xo(as(e,t)),r=Qo(e.transactionQueueTree_,t);return Jo(r,function(t){hs(e,t)}),hs(e,r),$o(r,function(t){hs(e,t)}),n}function hs(e,t){var n=Ho(t);if(n){for(var i=[],o=[],a=-1,s=0;s<n.length;s++)3===n[s].status||(1===n[s].status?((0,r.assert)(a===s-1,"All SENT items should be at beginning of queue."),a=s,n[s].status=3,n[s].abortReason="set"):((0,r.assert)(0===n[s].status,"Unexpected transaction status in abort"),n[s].unwatcher(),o=o.concat(uo(e.serverSyncTree_,n[s].currentWriteId,!0)),n[s].onComplete&&i.push(n[s].onComplete.bind(null,new Error("set"),!1,null))));-1===a?zo(t,void 0):n.length=a+1,Ta(e.eventQueue_,Xo(t),o);for(s=0;s<i.length;s++)Y(i[s])}}function ds(e){for(var t="",n=e.split("/"),r=0;r<n.length;r++)if(n[r].length>0){var i=n[r];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch(o){}t+="/"+i}return t}function ps(e){var t,n,r={};"?"===e.charAt(0)&&(e=e.substring(1));try{for(var o=(0,i.__values)(e.split("&")),a=o.next();!a.done;a=o.next()){var s=a.value;if(0!==s.length){var u=s.split("=");2===u.length?r[decodeURIComponent(u[0])]=decodeURIComponent(u[1]):S("Invalid query segment '"+s+"' in query '"+e+"'")}}}catch(l){t={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r}var fs=function(e,t){var n=_s(e),r=n.namespace;"firebase.com"===n.domain&&E(n.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),r&&"undefined"!==r||"localhost"===n.domain||E("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),n.secure||P();var i="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new ce(n.host,n.secure,r,t,i,"",r!==n.subdomain),path:new lt(n.pathString)}},_s=function(e){var t="",n="",r="",i="",o="",a=!0,s="https",u=443;if("string"==typeof e){var l=e.indexOf("//");l>=0&&(s=e.substring(0,l-1),e=e.substring(l+2));var c=e.indexOf("/");-1===c&&(c=e.length);var h=e.indexOf("?");-1===h&&(h=e.length),t=e.substring(0,Math.min(c,h)),c<h&&(i=ds(e.substring(c,h)));var d=ps(e.substring(Math.min(e.length,h)));(l=t.indexOf(":"))>=0?(a="https"===s||"wss"===s,u=parseInt(t.substring(l+1),10)):l=t.length;var p=t.slice(0,l);if("localhost"===p.toLowerCase())n="localhost";else if(p.split(".").length<=2)n=p;else{var f=t.indexOf(".");r=t.substring(0,f).toLowerCase(),n=t.substring(f+1),o=r}"ns"in d&&(o=d.ns)}return{host:t,port:u,domain:n,subdomain:r,secure:a,scheme:s,pathString:i,namespace:o}},vs=function(){function e(e,t,n,r){this.eventType=e,this.eventRegistration=t,this.snapshot=n,this.prevName=r}return e.prototype.getPath=function(){var e=this.snapshot.ref;return"value"===this.eventType?e._path:e.parent._path},e.prototype.getEventType=function(){return this.eventType},e.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},e.prototype.toString=function(){return this.getPath().toString()+":"+this.eventType+":"+(0,r.stringify)(this.snapshot.exportVal())},e}(),ys=function(){function e(e,t,n){this.eventRegistration=e,this.error=t,this.path=n}return e.prototype.getPath=function(){return this.path},e.prototype.getEventType=function(){return"cancel"},e.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},e.prototype.toString=function(){return this.path.toString()+":cancel"},e}(),gs=function(){function e(e,t){this.snapshotCallback=e,this.cancelCallback=t}return e.prototype.onValue=function(e,t){this.snapshotCallback.call(null,e,t)},e.prototype.onCancel=function(e){return(0,r.assert)(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)},Object.defineProperty(e.prototype,"hasCancelCallback",{get:function(){return!!this.cancelCallback},enumerable:!1,configurable:!0}),e.prototype.matches=function(e){return this.snapshotCallback===e.snapshotCallback||void 0!==this.snapshotCallback.userCallback&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context},e}(),ms=function(){function e(e,t){this._repo=e,this._path=t}return e.prototype.cancel=function(){var e=new r.Deferred;return Ba(this._repo,this._path,e.wrapCallback(function(){})),e.promise},e.prototype.remove=function(){ya("OnDisconnect.remove",this._path);var e=new r.Deferred;return Va(this._repo,this._path,null,e.wrapCallback(function(){})),e.promise},e.prototype.set=function(e){ya("OnDisconnect.set",this._path),ua("OnDisconnect.set",e,this._path,!1);var t=new r.Deferred;return Va(this._repo,this._path,e,t.wrapCallback(function(){})),t.promise},e.prototype.setWithPriority=function(e,t){ya("OnDisconnect.setWithPriority",this._path),ua("OnDisconnect.setWithPriority",e,this._path,!1),da("OnDisconnect.setWithPriority",t,!1);var n=new r.Deferred;return Qa(this._repo,this._path,e,t,n.wrapCallback(function(){})),n.promise},e.prototype.update=function(e){ya("OnDisconnect.update",this._path),ha("OnDisconnect.update",e,this._path,!1);var t=new r.Deferred;return Ha(this._repo,this._path,e,t.wrapCallback(function(){})),t.promise},e}(),Cs=function(){function e(e,t,n,r){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=r}return Object.defineProperty(e.prototype,"key",{get:function(){return mt(this._path)?null:ft(this._path)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ref",{get:function(){return new ks(this._repo,this._path)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_queryIdentifier",{get:function(){var e=Gn(this._queryParams),t=q(e);return"{}"===t?"default":t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_queryObject",{get:function(){return Gn(this._queryParams)},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){if(!((t=(0,r.getModularInstance)(t))instanceof e))return!1;var n=this._repo===t._repo,i=bt(this._path,t._path),o=this._queryIdentifier===t._queryIdentifier;return n&&i&&o},e.prototype.toJSON=function(){return this.toString()},e.prototype.toString=function(){return this._repo.toString()+_t(this._path)},e}();function ws(e,t){if(!0===e._orderByCalled)throw new Error(t+": You can't combine multiple orderBy calls.")}function bs(e){var t=null,n=null;if(e.hasStart()&&(t=e.getIndexStartValue()),e.hasEnd()&&(n=e.getIndexEndValue()),e.getIndex()===Qt){var i="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",o="Query: When ordering by key, the argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() must be a string.";if(e.hasStart()){if(e.getIndexStartName()!==R)throw new Error(i);if("string"!=typeof t)throw new Error(o)}if(e.hasEnd()){if(e.getIndexEndName()!==A)throw new Error(i);if("string"!=typeof n)throw new Error(o)}}else if(e.getIndex()===cn){if(null!=t&&!sa(t)||null!=n&&!sa(n))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), startAfter() endAt(), endBefore(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if((0,r.assert)(e.getIndex()instanceof wn||e.getIndex()===Tn,"unknown index type."),null!=t&&"object"==typeof t||null!=n&&"object"==typeof n)throw new Error("Query: First argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() cannot be an object.")}function Ts(e){if(e.hasStart()&&e.hasEnd()&&e.hasLimit()&&!e.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), startAfter(), endAt(), endBefore(), and limit(). Use limitToFirst() or limitToLast() instead.")}var ks=function(e){function t(t,n){return e.call(this,t,n,new Wn,!1)||this}return(0,i.__extends)(t,e),Object.defineProperty(t.prototype,"parent",{get:function(){var e=yt(this._path);return null===e?null:new t(this._repo,e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e},enumerable:!1,configurable:!0}),t}(Cs),Is=function(){function e(e,t,n){this._node=e,this.ref=t,this._index=n}return Object.defineProperty(e.prototype,"priority",{get:function(){return this._node.getPriority().val()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"key",{get:function(){return this.ref.key},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this._node.numChildren()},enumerable:!1,configurable:!0}),e.prototype.child=function(t){var n=new lt(t),r=Ps(this.ref,t);return new e(this._node.getChild(n),r,cn)},e.prototype.exists=function(){return!this._node.isEmpty()},e.prototype.exportVal=function(){return this._node.val(!0)},e.prototype.forEach=function(t){var n=this;return!this._node.isLeafNode()&&!!this._node.forEachChild(this._index,function(r,i){return t(new e(i,Ps(n.ref,r),cn))})},e.prototype.hasChild=function(e){var t=new lt(e);return!this._node.getChild(t).isEmpty()},e.prototype.hasChildren=function(){return!this._node.isLeafNode()&&!this._node.isEmpty()},e.prototype.toJSON=function(){return this.exportVal()},e.prototype.val=function(){return this._node.val()},e}();function Es(e,t){return(e=(0,r.getModularInstance)(e))._checkNotDeleted("ref"),void 0!==t?Ps(e._root,t):e._root}function Ss(e,t){(e=(0,r.getModularInstance)(e))._checkNotDeleted("refFromURL");var n=fs(t,e._repo.repoInfo_.nodeAdmin);ga("refFromURL",n);var i=n.repoInfo;return e._repo.repoInfo_.isCustomHost()||i.host===e._repo.repoInfo_.host||E("refFromURL: Host name does not match the current database: (found "+i.host+" but expected "+e._repo.repoInfo_.host+")"),Es(e,n.path.toString())}function Ps(e,t){return null===ht((e=(0,r.getModularInstance)(e))._path)?va("child","path",t,!1):_a("child","path",t,!1),new ks(e._repo,gt(e._path,t))}function xs(e,t){e=(0,r.getModularInstance)(e),ya("push",e._path),ua("push",t,e._path,!0);var n,i=Na(e._repo),o=Pn(i),a=Ps(e,o),s=Ps(e,o);return n=null!=t?Rs(s,t).then(function(){return s}):Promise.resolve(s),a.then=n.then.bind(n),a.catch=n.then.bind(n,void 0),a}function Ns(e){return ya("remove",e._path),Rs(e,null)}function Rs(e,t){e=(0,r.getModularInstance)(e),ya("set",e._path),ua("set",t,e._path,!1);var n=new r.Deferred;return Wa(e._repo,e._path,t,null,n.wrapCallback(function(){})),n.promise}function As(e,t){e=(0,r.getModularInstance)(e),ya("setPriority",e._path),da("setPriority",t,!1);var n=new r.Deferred;return Wa(e._repo,gt(e._path,".priority"),t,null,n.wrapCallback(function(){})),n.promise}function Ds(e,t,n){if(ya("setWithPriority",e._path),ua("setWithPriority",t,e._path,!1),da("setWithPriority",n,!1),".length"===e.key||".keys"===e.key)throw"setWithPriority failed: "+e.key+" is a read-only object.";var i=new r.Deferred;return Wa(e._repo,e._path,t,n,i.wrapCallback(function(){})),i.promise}function Os(e,t){ha("update",t,e._path,!1);var n=new r.Deferred;return ja(e._repo,e._path,t,n.wrapCallback(function(){})),n.promise}function Ms(e){return La((e=(0,r.getModularInstance)(e))._repo,e).then(function(t){return new Is(t,new ks(e._repo,e._path),e._queryParams.getIndex())})}var qs=function(){function e(e){this.callbackContext=e}return e.prototype.respondsTo=function(e){return"value"===e},e.prototype.createEvent=function(e,t){var n=t._queryParams.getIndex();return new vs("value",this,new Is(e.snapshotNode,new ks(t._repo,t._path),n))},e.prototype.getEventRunner=function(e){var t=this;return"cancel"===e.getEventType()?function(){return t.callbackContext.onCancel(e.error)}:function(){return t.callbackContext.onValue(e.snapshot,null)}},e.prototype.createCancelEvent=function(e,t){return this.callbackContext.hasCancelCallback?new ys(this,e,t):null},e.prototype.matches=function(t){return t instanceof e&&(!t.callbackContext||!this.callbackContext||t.callbackContext.matches(this.callbackContext))},e.prototype.hasAnyCallback=function(){return null!==this.callbackContext},e}(),Fs=function(){function e(e,t){this.eventType=e,this.callbackContext=t}return e.prototype.respondsTo=function(e){var t="children_added"===e?"child_added":e;return t="children_removed"===t?"child_removed":t,this.eventType===t},e.prototype.createCancelEvent=function(e,t){return this.callbackContext.hasCancelCallback?new ys(this,e,t):null},e.prototype.createEvent=function(e,t){(0,r.assert)(null!=e.childName,"Child events should have a childName.");var n=Ps(new ks(t._repo,t._path),e.childName),i=t._queryParams.getIndex();return new vs(e.type,this,new Is(e.snapshotNode,n,i),e.prevName)},e.prototype.getEventRunner=function(e){var t=this;return"cancel"===e.getEventType()?function(){return t.callbackContext.onCancel(e.error)}:function(){return t.callbackContext.onValue(e.snapshot,e.prevName)}},e.prototype.matches=function(t){return t instanceof e&&(this.eventType===t.eventType&&(!this.callbackContext||!t.callbackContext||this.callbackContext.matches(t.callbackContext)))},e.prototype.hasAnyCallback=function(){return!!this.callbackContext},e}();function Ls(e,t,n,r,i){var o;if("object"==typeof r&&(o=void 0,i=r),"function"==typeof r&&(o=r),i&&i.onlyOnce){var a=n,s=function(t,n){Ya(e._repo,e,l),a(t,n)};s.userCallback=n.userCallback,s.context=n.context,n=s}var u=new gs(n,o||void 0),l="value"===t?new qs(u):new Fs(t,u);return za(e._repo,e,l),function(){return Ya(e._repo,e,l)}}function Ws(e,t,n,r){return Ls(e,"value",t,n,r)}function js(e,t,n,r){return Ls(e,"child_added",t,n,r)}function Us(e,t,n,r){return Ls(e,"child_changed",t,n,r)}function Bs(e,t,n,r){return Ls(e,"child_moved",t,n,r)}function Vs(e,t,n,r){return Ls(e,"child_removed",t,n,r)}function Qs(e,t,n){var r=null,i=n?new gs(n):null;"value"===t?r=new qs(i):t&&(r=new Fs(t,i)),Ya(e._repo,e,r)}var Hs=function(){return function(){}}(),zs=function(e){function t(t,n){var r=e.call(this)||this;return r._value=t,r._key=n,r}return(0,i.__extends)(t,e),t.prototype._apply=function(e){ua("endAt",this._value,e._path,!0);var t=Hn(e._queryParams,this._value,this._key);if(Ts(t),bs(t),e._queryParams.hasEnd())throw new Error("endAt: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new Cs(e._repo,e._path,t,e._orderByCalled)},t}(Hs);function Ys(e,t){return fa("endAt","key",t,!0),new zs(e,t)}var Ks=function(e){function t(t,n){var r=e.call(this)||this;return r._value=t,r._key=n,r}return(0,i.__extends)(t,e),t.prototype._apply=function(e){ua("endBefore",this._value,e._path,!1);var t=zn(e._queryParams,this._value,this._key);if(Ts(t),bs(t),e._queryParams.hasEnd())throw new Error("endBefore: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new Cs(e._repo,e._path,t,e._orderByCalled)},t}(Hs);function Gs(e,t){return fa("endBefore","key",t,!0),new Ks(e,t)}var $s=function(e){function t(t,n){var r=e.call(this)||this;return r._value=t,r._key=n,r}return(0,i.__extends)(t,e),t.prototype._apply=function(e){ua("startAt",this._value,e._path,!0);var t=Vn(e._queryParams,this._value,this._key);if(Ts(t),bs(t),e._queryParams.hasStart())throw new Error("startAt: Starting point was already set (by another call to startAt, startBefore or equalTo).");return new Cs(e._repo,e._path,t,e._orderByCalled)},t}(Hs);function Js(e,t){return void 0===e&&(e=null),fa("startAt","key",t,!0),new $s(e,t)}var Xs=function(e){function t(t,n){var r=e.call(this)||this;return r._value=t,r._key=n,r}return(0,i.__extends)(t,e),t.prototype._apply=function(e){ua("startAfter",this._value,e._path,!1);var t=Qn(e._queryParams,this._value,this._key);if(Ts(t),bs(t),e._queryParams.hasStart())throw new Error("startAfter: Starting point was already set (by another call to startAt, startAfter, or equalTo).");return new Cs(e._repo,e._path,t,e._orderByCalled)},t}(Hs);function Zs(e,t){return fa("startAfter","key",t,!0),new Xs(e,t)}var eu=function(e){function t(t){var n=e.call(this)||this;return n._limit=t,n}return(0,i.__extends)(t,e),t.prototype._apply=function(e){if(e._queryParams.hasLimit())throw new Error("limitToFirst: Limit was already set (by another call to limitToFirst or limitToLast).");return new Cs(e._repo,e._path,Un(e._queryParams,this._limit),e._orderByCalled)},t}(Hs);function tu(e){if("number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToFirst: First argument must be a positive integer.");return new eu(e)}var nu=function(e){function t(t){var n=e.call(this)||this;return n._limit=t,n}return(0,i.__extends)(t,e),t.prototype._apply=function(e){if(e._queryParams.hasLimit())throw new Error("limitToLast: Limit was already set (by another call to limitToFirst or limitToLast).");return new Cs(e._repo,e._path,Bn(e._queryParams,this._limit),e._orderByCalled)},t}(Hs);function ru(e){if("number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToLast: First argument must be a positive integer.");return new nu(e)}var iu=function(e){function t(t){var n=e.call(this)||this;return n._path=t,n}return(0,i.__extends)(t,e),t.prototype._apply=function(e){ws(e,"orderByChild");var t=new lt(this._path);if(mt(t))throw new Error("orderByChild: cannot pass in empty path. Use orderByValue() instead.");var n=new wn(t),r=Yn(e._queryParams,n);return bs(r),new Cs(e._repo,e._path,r,!0)},t}(Hs);function ou(e){if("$key"===e)throw new Error('orderByChild: "$key" is invalid. Use orderByKey() instead.');if("$priority"===e)throw new Error('orderByChild: "$priority" is invalid. Use orderByPriority() instead.');if("$value"===e)throw new Error('orderByChild: "$value" is invalid. Use orderByValue() instead.');return _a("orderByChild","path",e,!1),new iu(e)}var au=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,i.__extends)(t,e),t.prototype._apply=function(e){ws(e,"orderByKey");var t=Yn(e._queryParams,Qt);return bs(t),new Cs(e._repo,e._path,t,!0)},t}(Hs);function su(){return new au}var uu=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,i.__extends)(t,e),t.prototype._apply=function(e){ws(e,"orderByPriority");var t=Yn(e._queryParams,cn);return bs(t),new Cs(e._repo,e._path,t,!0)},t}(Hs);function lu(){return new uu}var cu=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,i.__extends)(t,e),t.prototype._apply=function(e){ws(e,"orderByValue");var t=Yn(e._queryParams,Tn);return bs(t),new Cs(e._repo,e._path,t,!0)},t}(Hs);function hu(){return new cu}var du=function(e){function t(t,n){var r=e.call(this)||this;return r._value=t,r._key=n,r}return(0,i.__extends)(t,e),t.prototype._apply=function(e){if(ua("equalTo",this._value,e._path,!1),e._queryParams.hasStart())throw new Error("equalTo: Starting point was already set (by another call to startAt/startAfter or equalTo).");if(e._queryParams.hasEnd())throw new Error("equalTo: Ending point was already set (by another call to endAt/endBefore or equalTo).");return new zs(this._value,this._key)._apply(new $s(this._value,this._key)._apply(e))},t}(Hs);function pu(e,t){return fa("equalTo","key",t,!0),new du(e,t)}function fu(e){for(var t,n,o=[],a=1;a<arguments.length;a++)o[a-1]=arguments[a];var s=(0,r.getModularInstance)(e);try{for(var u=(0,i.__values)(o),l=u.next();!l.done;l=u.next()){s=l.value._apply(s)}}catch(c){t={error:c}}finally{try{l&&!l.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}return s}Vi(ks),no(ks);var _u="FIREBASE_DATABASE_EMULATOR_HOST",vu={},yu=!1;function gu(e,t,n,r){e.repoInfo_=new ce(t+":"+n,!1,e.repoInfo_.namespace,e.repoInfo_.webSocketOnly,e.repoInfo_.nodeAdmin,e.repoInfo_.persistenceKey,e.repoInfo_.includeNamespaceInQueryParams),r&&(e.authTokenProvider_=r)}function mu(t,n,r,i,o){var a=i||t.options.databaseURL;void 0===a&&(t.options.projectId||E("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),T("Using default host for project ",t.options.projectId),a=t.options.projectId+"-default-rtdb.firebaseio.com");var s,u=fs(a,o),l=u.repoInfo,c=void 0;void 0!==e&&(c=e.env[_u]),c?(s=!0,a="http://"+c+"?ns="+l.namespace,l=(u=fs(a,o)).repoInfo):s=!u.repoInfo.secure;var h=o&&s?new X(X.OWNER):new J(t.name,t.options,n);ga("Invalid Firebase Database URL",u),mt(u.path)||E("Database URL must point to the root of a Firebase Database (not including a child path).");var d=wu(l,t,h,new $(t.name,r));return new Tu(d,t)}function Cu(e,t){var n=vu[t];n&&n[e.key]===e||E("Database "+t+"("+e.repoInfo_+") has already been deleted."),Ka(e),delete n[e.key]}function wu(e,t,n,r){var i=vu[t.name];i||(i={},vu[t.name]=i);var o=i[e.toURLString()];return o&&E("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),o=new Pa(e,yu,n,r),i[e.toURLString()]=o,o}function bu(e){yu=e}var Tu=function(){function e(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}return Object.defineProperty(e.prototype,"_repo",{get:function(){return this._instanceStarted||(xa(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_root",{get:function(){return this._rootInternal||(this._rootInternal=new ks(this._repo,ct())),this._rootInternal},enumerable:!1,configurable:!0}),e.prototype._delete=function(){return null!==this._rootInternal&&(Cu(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()},e.prototype._checkNotDeleted=function(e){null===this._rootInternal&&E("Cannot call "+e+" on a deleted database.")},e}();function ku(e,t,n,i){void 0===i&&(i={}),(e=(0,r.getModularInstance)(e))._checkNotDeleted("useEmulator"),e._instanceStarted&&E("Cannot call useEmulator() after instance has already been initialized.");var o=e._repoInternal,a=void 0;if(o.repoInfo_.nodeAdmin)i.mockUserToken&&E('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),a=new X(X.OWNER);else if(i.mockUserToken){var s="string"==typeof i.mockUserToken?i.mockUserToken:(0,r.createMockUserToken)(i.mockUserToken,e.app.options.projectId);a=new X(s)}gu(o,t,n,a)}function Iu(e){(e=(0,r.getModularInstance)(e))._checkNotDeleted("goOffline"),Ka(e._repo)}function Eu(e){(e=(0,r.getModularInstance)(e))._checkNotDeleted("goOnline"),Ga(e._repo)}var Su={".sv":"timestamp"};function Pu(){return Su}function xu(e){return{".sv":{increment:e}}}var Nu=function(){function e(e,t){this.committed=e,this.snapshot=t}return e.prototype.toJSON=function(){return{committed:this.committed,snapshot:this.snapshot.toJSON()}},e}();function Ru(e,t,n){var i;if(e=(0,r.getModularInstance)(e),ya("Reference.transaction",e._path),".length"===e.key||".keys"===e.key)throw"Reference.transaction failed: "+e.key+" is a read-only object.";var o=null===(i=null==n?void 0:n.applyLocally)||void 0===i||i,a=new r.Deferred,s=Ws(e,function(){});return es(e._repo,e._path,t,function(t,n,r){var i=null;t?a.reject(t):(i=new Is(r,new ks(e._repo,e._path),cn),a.resolve(new Nu(n,i)))},s,o),a.promise}var Au=function(){function e(e){this._delegate=e}return e.prototype.cancel=function(e){(0,r.validateArgCount)("OnDisconnect.cancel",0,1,arguments.length),(0,r.validateCallback)("OnDisconnect.cancel","onComplete",e,!0);var t=this._delegate.cancel();return e&&t.then(function(){return e(null)},function(t){return e(t)}),t},e.prototype.remove=function(e){(0,r.validateArgCount)("OnDisconnect.remove",0,1,arguments.length),(0,r.validateCallback)("OnDisconnect.remove","onComplete",e,!0);var t=this._delegate.remove();return e&&t.then(function(){return e(null)},function(t){return e(t)}),t},e.prototype.set=function(e,t){(0,r.validateArgCount)("OnDisconnect.set",1,2,arguments.length),(0,r.validateCallback)("OnDisconnect.set","onComplete",t,!0);var n=this._delegate.set(e);return t&&n.then(function(){return t(null)},function(e){return t(e)}),n},e.prototype.setWithPriority=function(e,t,n){(0,r.validateArgCount)("OnDisconnect.setWithPriority",2,3,arguments.length),(0,r.validateCallback)("OnDisconnect.setWithPriority","onComplete",n,!0);var i=this._delegate.setWithPriority(e,t);return n&&i.then(function(){return n(null)},function(e){return n(e)}),i},e.prototype.update=function(e,t){if((0,r.validateArgCount)("OnDisconnect.update",1,2,arguments.length),Array.isArray(e)){for(var n={},i=0;i<e.length;++i)n[""+i]=e[i];e=n,S("Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}(0,r.validateCallback)("OnDisconnect.update","onComplete",t,!0);var o=this._delegate.update(e);return t&&o.then(function(){return t(null)},function(e){return t(e)}),o},e}();exports.OnDisconnect=Au;var Du=function(){function e(e,t){this.committed=e,this.snapshot=t}return e.prototype.toJSON=function(){return(0,r.validateArgCount)("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}},e}(),Ou=function(){function e(e,t){this._database=e,this._delegate=t}return e.prototype.val=function(){return(0,r.validateArgCount)("DataSnapshot.val",0,0,arguments.length),this._delegate.val()},e.prototype.exportVal=function(){return(0,r.validateArgCount)("DataSnapshot.exportVal",0,0,arguments.length),this._delegate.exportVal()},e.prototype.toJSON=function(){return(0,r.validateArgCount)("DataSnapshot.toJSON",0,1,arguments.length),this._delegate.toJSON()},e.prototype.exists=function(){return(0,r.validateArgCount)("DataSnapshot.exists",0,0,arguments.length),this._delegate.exists()},e.prototype.child=function(t){return(0,r.validateArgCount)("DataSnapshot.child",0,1,arguments.length),t=String(t),_a("DataSnapshot.child","path",t,!1),new e(this._database,this._delegate.child(t))},e.prototype.hasChild=function(e){return(0,r.validateArgCount)("DataSnapshot.hasChild",1,1,arguments.length),_a("DataSnapshot.hasChild","path",e,!1),this._delegate.hasChild(e)},e.prototype.getPriority=function(){return(0,r.validateArgCount)("DataSnapshot.getPriority",0,0,arguments.length),this._delegate.priority},e.prototype.forEach=function(t){var n=this;return(0,r.validateArgCount)("DataSnapshot.forEach",1,1,arguments.length),(0,r.validateCallback)("DataSnapshot.forEach","action",t,!1),this._delegate.forEach(function(r){return t(new e(n._database,r))})},e.prototype.hasChildren=function(){return(0,r.validateArgCount)("DataSnapshot.hasChildren",0,0,arguments.length),this._delegate.hasChildren()},Object.defineProperty(e.prototype,"key",{get:function(){return this._delegate.key},enumerable:!1,configurable:!0}),e.prototype.numChildren=function(){return(0,r.validateArgCount)("DataSnapshot.numChildren",0,0,arguments.length),this._delegate.size},e.prototype.getRef=function(){return(0,r.validateArgCount)("DataSnapshot.ref",0,0,arguments.length),new qu(this._database,this._delegate.ref)},Object.defineProperty(e.prototype,"ref",{get:function(){return this.getRef()},enumerable:!1,configurable:!0}),e}();exports.DataSnapshot=Ou;var Mu=function(){function e(e,t){this.database=e,this._delegate=t}return e.prototype.on=function(t,n,i,o){var a,s=this;(0,r.validateArgCount)("Query.on",2,4,arguments.length),(0,r.validateCallback)("Query.on","callback",n,!1);var u=e.getCancelAndContextArgs_("Query.on",i,o),l=function(e,t){n.call(u.context,new Ou(s.database,e),t)};l.userCallback=n,l.context=u.context;var c=null===(a=u.cancel)||void 0===a?void 0:a.bind(u.context);switch(t){case"value":return Ws(this._delegate,l,c),n;case"child_added":return js(this._delegate,l,c),n;case"child_removed":return Vs(this._delegate,l,c),n;case"child_changed":return Us(this._delegate,l,c),n;case"child_moved":return Bs(this._delegate,l,c),n;default:throw new Error((0,r.errorPrefix)("Query.on","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}},e.prototype.off=function(e,t,n){if((0,r.validateArgCount)("Query.off",0,3,arguments.length),pa("Query.off",e,!0),(0,r.validateCallback)("Query.off","callback",t,!0),(0,r.validateContextObject)("Query.off","context",n,!0),t){var i=function(){};i.userCallback=t,i.context=n,Qs(this._delegate,e,i)}else Qs(this._delegate,e)},e.prototype.get=function(){var e=this;return Ms(this._delegate).then(function(t){return new Ou(e.database,t)})},e.prototype.once=function(t,n,i,o){var a=this;(0,r.validateArgCount)("Query.once",1,4,arguments.length),(0,r.validateCallback)("Query.once","callback",n,!0);var s=e.getCancelAndContextArgs_("Query.once",i,o),u=new r.Deferred,l=function(e,t){var r=new Ou(a.database,e);n&&n.call(s.context,r,t),u.resolve(r)};l.userCallback=n,l.context=s.context;var c=function(e){s.cancel&&s.cancel.call(s.context,e),u.reject(e)};switch(t){case"value":Ws(this._delegate,l,c,{onlyOnce:!0});break;case"child_added":js(this._delegate,l,c,{onlyOnce:!0});break;case"child_removed":Vs(this._delegate,l,c,{onlyOnce:!0});break;case"child_changed":Us(this._delegate,l,c,{onlyOnce:!0});break;case"child_moved":Bs(this._delegate,l,c,{onlyOnce:!0});break;default:throw new Error((0,r.errorPrefix)("Query.once","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}return u.promise},e.prototype.limitToFirst=function(t){return(0,r.validateArgCount)("Query.limitToFirst",1,1,arguments.length),new e(this.database,fu(this._delegate,tu(t)))},e.prototype.limitToLast=function(t){return(0,r.validateArgCount)("Query.limitToLast",1,1,arguments.length),new e(this.database,fu(this._delegate,ru(t)))},e.prototype.orderByChild=function(t){return(0,r.validateArgCount)("Query.orderByChild",1,1,arguments.length),new e(this.database,fu(this._delegate,ou(t)))},e.prototype.orderByKey=function(){return(0,r.validateArgCount)("Query.orderByKey",0,0,arguments.length),new e(this.database,fu(this._delegate,su()))},e.prototype.orderByPriority=function(){return(0,r.validateArgCount)("Query.orderByPriority",0,0,arguments.length),new e(this.database,fu(this._delegate,lu()))},e.prototype.orderByValue=function(){return(0,r.validateArgCount)("Query.orderByValue",0,0,arguments.length),new e(this.database,fu(this._delegate,hu()))},e.prototype.startAt=function(t,n){return void 0===t&&(t=null),(0,r.validateArgCount)("Query.startAt",0,2,arguments.length),new e(this.database,fu(this._delegate,Js(t,n)))},e.prototype.startAfter=function(t,n){return void 0===t&&(t=null),(0,r.validateArgCount)("Query.startAfter",0,2,arguments.length),new e(this.database,fu(this._delegate,Zs(t,n)))},e.prototype.endAt=function(t,n){return void 0===t&&(t=null),(0,r.validateArgCount)("Query.endAt",0,2,arguments.length),new e(this.database,fu(this._delegate,Ys(t,n)))},e.prototype.endBefore=function(t,n){return void 0===t&&(t=null),(0,r.validateArgCount)("Query.endBefore",0,2,arguments.length),new e(this.database,fu(this._delegate,Gs(t,n)))},e.prototype.equalTo=function(t,n){return(0,r.validateArgCount)("Query.equalTo",1,2,arguments.length),new e(this.database,fu(this._delegate,pu(t,n)))},e.prototype.toString=function(){return(0,r.validateArgCount)("Query.toString",0,0,arguments.length),this._delegate.toString()},e.prototype.toJSON=function(){return(0,r.validateArgCount)("Query.toJSON",0,1,arguments.length),this._delegate.toJSON()},e.prototype.isEqual=function(t){if((0,r.validateArgCount)("Query.isEqual",1,1,arguments.length),!(t instanceof e)){throw new Error("Query.isEqual failed: First argument must be an instance of firebase.database.Query.")}return this._delegate.isEqual(t._delegate)},e.getCancelAndContextArgs_=function(e,t,n){var i={cancel:void 0,context:void 0};if(t&&n)i.cancel=t,(0,r.validateCallback)(e,"cancel",i.cancel,!0),i.context=n,(0,r.validateContextObject)(e,"context",i.context,!0);else if(t)if("object"==typeof t&&null!==t)i.context=t;else{if("function"!=typeof t)throw new Error((0,r.errorPrefix)(e,"cancelOrContext")+" must either be a cancel callback or a context object.");i.cancel=t}return i},Object.defineProperty(e.prototype,"ref",{get:function(){return new qu(this.database,new ks(this._delegate._repo,this._delegate._path))},enumerable:!1,configurable:!0}),e}();exports.Query=Mu;var qu=function(e){function t(t,n){var r=e.call(this,t,new Cs(n._repo,n._path,new Wn,!1))||this;return r.database=t,r._delegate=n,r}return(0,i.__extends)(t,e),t.prototype.getKey=function(){return(0,r.validateArgCount)("Reference.key",0,0,arguments.length),this._delegate.key},t.prototype.child=function(e){return(0,r.validateArgCount)("Reference.child",1,1,arguments.length),"number"==typeof e&&(e=String(e)),new t(this.database,Ps(this._delegate,e))},t.prototype.getParent=function(){(0,r.validateArgCount)("Reference.parent",0,0,arguments.length);var e=this._delegate.parent;return e?new t(this.database,e):null},t.prototype.getRoot=function(){return(0,r.validateArgCount)("Reference.root",0,0,arguments.length),new t(this.database,this._delegate.root)},t.prototype.set=function(e,t){(0,r.validateArgCount)("Reference.set",1,2,arguments.length),(0,r.validateCallback)("Reference.set","onComplete",t,!0);var n=Rs(this._delegate,e);return t&&n.then(function(){return t(null)},function(e){return t(e)}),n},t.prototype.update=function(e,t){if((0,r.validateArgCount)("Reference.update",1,2,arguments.length),Array.isArray(e)){for(var n={},i=0;i<e.length;++i)n[""+i]=e[i];e=n,S("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}ya("Reference.update",this._delegate._path),(0,r.validateCallback)("Reference.update","onComplete",t,!0);var o=Os(this._delegate,e);return t&&o.then(function(){return t(null)},function(e){return t(e)}),o},t.prototype.setWithPriority=function(e,t,n){(0,r.validateArgCount)("Reference.setWithPriority",2,3,arguments.length),(0,r.validateCallback)("Reference.setWithPriority","onComplete",n,!0);var i=Ds(this._delegate,e,t);return n&&i.then(function(){return n(null)},function(e){return n(e)}),i},t.prototype.remove=function(e){(0,r.validateArgCount)("Reference.remove",0,1,arguments.length),(0,r.validateCallback)("Reference.remove","onComplete",e,!0);var t=Ns(this._delegate);return e&&t.then(function(){return e(null)},function(t){return e(t)}),t},t.prototype.transaction=function(e,t,n){var i=this;(0,r.validateArgCount)("Reference.transaction",1,3,arguments.length),(0,r.validateCallback)("Reference.transaction","transactionUpdate",e,!1),(0,r.validateCallback)("Reference.transaction","onComplete",t,!0),ma("Reference.transaction","applyLocally",n,!0);var o=Ru(this._delegate,e,{applyLocally:n}).then(function(e){return new Du(e.committed,new Ou(i.database,e.snapshot))});return t&&o.then(function(e){return t(null,e.committed,e.snapshot)},function(e){return t(e,!1,null)}),o},t.prototype.setPriority=function(e,t){(0,r.validateArgCount)("Reference.setPriority",1,2,arguments.length),(0,r.validateCallback)("Reference.setPriority","onComplete",t,!0);var n=As(this._delegate,e);return t&&n.then(function(){return t(null)},function(e){return t(e)}),n},t.prototype.push=function(e,n){var i=this;(0,r.validateArgCount)("Reference.push",0,2,arguments.length),(0,r.validateCallback)("Reference.push","onComplete",n,!0);var o=xs(this._delegate,e),a=o.then(function(e){return new t(i.database,e)});n&&a.then(function(){return n(null)},function(e){return n(e)});var s=new t(this.database,o);return s.then=a.then.bind(a),s.catch=a.catch.bind(a,void 0),s},t.prototype.onDisconnect=function(){return ya("Reference.onDisconnect",this._delegate._path),new Au(new ms(this._delegate._repo,this._delegate._path))},Object.defineProperty(t.prototype,"key",{get:function(){return this.getKey()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this.getParent()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return this.getRoot()},enumerable:!1,configurable:!0}),t}(Mu);exports.Reference=qu;var Fu=function(){function e(e,t){var n=this;this._delegate=e,this.app=t,this.INTERNAL={delete:function(){return n._delegate._delete()}}}return e.prototype.useEmulator=function(e,t,n){void 0===n&&(n={}),ku(this._delegate,e,t,n)},e.prototype.ref=function(e){if((0,r.validateArgCount)("database.ref",0,1,arguments.length),e instanceof qu){var t=Ss(this._delegate,e.toString());return new qu(this,t)}t=Es(this._delegate,e);return new qu(this,t)},e.prototype.refFromURL=function(e){(0,r.validateArgCount)("database.refFromURL",1,1,arguments.length);var t=Ss(this._delegate,e);return new qu(this,t)},e.prototype.goOffline=function(){return(0,r.validateArgCount)("database.goOffline",0,0,arguments.length),Iu(this._delegate)},e.prototype.goOnline=function(){return(0,r.validateArgCount)("database.goOnline",0,0,arguments.length),Eu(this._delegate)},e.ServerValue={TIMESTAMP:Pu(),increment:function(e){return xu(e)}},e}();exports.Database=Fu;var Lu=function(){Ue.forceDisallow(),qe.forceAllow()},Wu=function(){qe.forceDisallow()},ju=function(){return Ue.isAvailable()},Uu=function(e,t){e._delegate._repo.persistentConnection_.securityDebugCallback_=t},Bu=function(e,t){$a(e._delegate._repo,t)},Vu=function(e,t){Ja(e._delegate._repo,t)},Qu=function(e){return e._delegate._repo.dataUpdateCount},Hu=function(e,t){return Da(e._delegate._repo,t)};function zu(e){var t=e.app,r=e.url,i=e.version,o=e.customAuthImpl,a=e.namespace,s=e.nodeAdmin,u=void 0!==s&&s;c(i);var l=new n.Provider("auth-internal",new n.ComponentContainer("database-standalone"));return l.setComponent(new n.Component("auth-internal",function(){return o},"PRIVATE")),{instance:new Fu(mu(t,l,void 0,r,u),t),namespace:a}}var Yu=Object.freeze({__proto__:null,forceLongPolling:Lu,forceWebSockets:Wu,isWebSocketsAvailable:ju,setSecurityDebugCallback:Uu,stats:Bu,statsIncrementCounter:Vu,dataUpdateCount:Qu,interceptServerData:Hu,initStandalone:zu}),Ku=jt;jt.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},jt.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)};var Gu=rt,$u=function(e){var t=jt.prototype.put;return jt.prototype.put=function(n,r,i,o){void 0!==o&&(o=e()),t.call(this,n,r,i,o)},function(){jt.prototype.put=t}},Ju=ce,Xu=function(e){return e._delegate._queryIdentifier},Zu=function(e){bu(e)},el=Object.freeze({__proto__:null,DataConnection:Ku,RealTimeConnection:Gu,hijackHash:$u,ConnectionTarget:Ju,queryIdentifier:Xu,forceRestClient:Zu}),tl=Fu.ServerValue;function nl(e){c(e.SDK_VERSION);var t=e.INTERNAL.registerComponent(new n.Component("database",function(e,t){var n=t.instanceIdentifier,r=e.getProvider("app").getImmediate(),i=e.getProvider("auth-internal"),o=e.getProvider("app-check-internal");return new Fu(mu(r,i,o,n),r)},"PUBLIC").setServiceProps({Reference:qu,Query:Mu,Database:Fu,DataSnapshot:Ou,enableLogging:b,INTERNAL:Yu,ServerValue:tl,TEST_ACCESS:el}).setMultipleInstances(!0));e.registerVersion(s,u),(0,r.isNodeSdk)()&&(module.exports=t)}exports.ServerValue=tl,nl(t.default);
|
|
477
|
-
},{"
|
|
478
|
-
"use strict";require("@firebase/
|
|
479
|
-
},{"@firebase/
|
|
464
|
+
var t=arguments[3],e=require("process");Object.defineProperty(exports,"__esModule",{value:!0}),exports.Sha1=exports.RANDOM_FACTOR=exports.MAX_VALUE_MILLIS=exports.FirebaseError=exports.ErrorFactory=exports.Deferred=exports.DecodeBase64StringError=exports.CONSTANTS=void 0,exports.areCookiesEnabled=V,exports.assertionError=exports.assert=void 0,exports.async=ft,exports.base64urlEncodeWithoutPadding=exports.base64Encode=exports.base64Decode=exports.base64=void 0,exports.calculateBackoffMillis=Ct,exports.contains=Y,exports.createMockUserToken=O,exports.createSubscribe=ht,exports.decode=void 0,exports.deepCopy=l,exports.deepEqual=rt,exports.deepExtend=p,exports.errorPrefix=bt,exports.extractQuerystring=at,exports.getExperimentalSetting=exports.getDefaults=exports.getDefaultEmulatorHostnameAndPort=exports.getDefaultEmulatorHost=exports.getDefaultAppConfig=void 0,exports.getGlobal=b,exports.getModularInstance=Tt,exports.getUA=C,exports.isAdmin=void 0,exports.isBrowser=T,exports.isBrowserExtension=N,exports.isElectron=j,exports.isEmpty=tt,exports.isIE=B,exports.isIndexedDBAvailable=L,exports.isMobileCordova=D,exports.isNode=w,exports.isNodeSdk=I,exports.isReactNative=M,exports.isSafari=P,exports.isUWP=k,exports.issuedAtTime=exports.isValidTimestamp=exports.isValidFormat=void 0,exports.jsonEval=H,exports.map=et,exports.ordinal=Dt,exports.promiseWithTimeout=nt,exports.querystring=st,exports.querystringDecode=it,exports.safeGet=Z,exports.stringToByteArray=exports.stringLength=void 0,exports.stringify=J,exports.validateArgCount=exports.uuidv4=void 0,exports.validateCallback=_t,exports.validateContextObject=gt,exports.validateIndexedDBOpenable=R,exports.validateNamespace=xt;const r={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"};exports.CONSTANTS=r;const o=function(t,e){if(!t)throw n(e)};exports.assert=o;const n=function(t){return new Error("Firebase Database ("+r.SDK_VERSION+") INTERNAL ASSERT FAILED: "+t)};exports.assertionError=n;const s=function(t){const e=[];let r=0;for(let o=0;o<t.length;o++){let n=t.charCodeAt(o);n<128?e[r++]=n:n<2048?(e[r++]=n>>6|192,e[r++]=63&n|128):55296==(64512&n)&&o+1<t.length&&56320==(64512&t.charCodeAt(o+1))?(n=65536+((1023&n)<<10)+(1023&t.charCodeAt(++o)),e[r++]=n>>18|240,e[r++]=n>>12&63|128,e[r++]=n>>6&63|128,e[r++]=63&n|128):(e[r++]=n>>12|224,e[r++]=n>>6&63|128,e[r++]=63&n|128)}return e},i=function(t){const e=[];let r=0,o=0;for(;r<t.length;){const n=t[r++];if(n<128)e[o++]=String.fromCharCode(n);else if(n>191&&n<224){const s=t[r++];e[o++]=String.fromCharCode((31&n)<<6|63&s)}else if(n>239&&n<365){const s=((7&n)<<18|(63&t[r++])<<12|(63&t[r++])<<6|63&t[r++])-65536;e[o++]=String.fromCharCode(55296+(s>>10)),e[o++]=String.fromCharCode(56320+(1023&s))}else{const s=t[r++],i=t[r++];e[o++]=String.fromCharCode((15&n)<<12|(63&s)<<6|63&i)}}return e.join("")},a={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const r=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,o=[];for(let n=0;n<t.length;n+=3){const e=t[n],s=n+1<t.length,i=s?t[n+1]:0,a=n+2<t.length,c=a?t[n+2]:0,h=e>>2,u=(3&e)<<4|i>>4;let f=(15&i)<<2|c>>6,l=63&c;a||(l=64,s||(f=64)),o.push(r[h],r[u],r[f],r[l])}return o.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(s(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):i(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const r=e?this.charToByteMapWebSafe_:this.charToByteMap_,o=[];for(let n=0;n<t.length;){const e=r[t.charAt(n++)],s=n<t.length?r[t.charAt(n)]:0,i=++n<t.length?r[t.charAt(n)]:64,a=++n<t.length?r[t.charAt(n)]:64;if(++n,null==e||null==s||null==i||null==a)throw new c;const h=e<<2|s>>4;if(o.push(h),64!==i){const t=s<<4&240|i>>2;if(o.push(t),64!==a){const t=i<<6&192|a;o.push(t)}}}return o},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};exports.base64=a;class c extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}exports.DecodeBase64StringError=c;const h=function(t){const e=s(t);return a.encodeByteArray(e,!0)};exports.base64Encode=h;const u=function(t){return h(t).replace(/\./g,"")};exports.base64urlEncodeWithoutPadding=u;const f=function(t){try{return a.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function l(t){return p(void 0,t)}function p(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(const r in e)e.hasOwnProperty(r)&&d(r)&&(t[r]=p(t[r],e[r]));return t}function d(t){return"__proto__"!==t}function b(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t)return t;throw new Error("Unable to locate global object.")}exports.base64Decode=f;const x=()=>b().__FIREBASE_DEFAULTS__,_=()=>{if(void 0===e||void 0===e.env)return},g=()=>{if("undefined"==typeof document)return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(r){return}const e=t&&f(t[1]);return e&&JSON.parse(e)},y=()=>{try{return x()||_()||g()}catch(t){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`)}};exports.getDefaults=y;const v=t=>{var e,r;return null===(r=null===(e=y())||void 0===e?void 0:e.emulatorHosts)||void 0===r?void 0:r[t]};exports.getDefaultEmulatorHost=v;const E=t=>{const e=v(t);if(!e)return;const r=e.lastIndexOf(":");if(r<=0||r+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const o=parseInt(e.substring(r+1),10);return"["===e[0]?[e.substring(1,r-1),o]:[e.substring(0,r),o]};exports.getDefaultEmulatorHostnameAndPort=E;const m=()=>{var t;return null===(t=y())||void 0===t?void 0:t.config};exports.getDefaultAppConfig=m;const S=t=>{var e;return null===(e=y())||void 0===e?void 0:e[`_${t}`]};exports.getExperimentalSetting=S;class A{constructor(){this.reject=(()=>{}),this.resolve=(()=>{}),this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}wrapCallback(t){return(e,r)=>{e?this.reject(e):this.resolve(r),"function"==typeof t&&(this.promise.catch(()=>{}),1===t.length?t(e):t(e,r))}}}function O(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const r=e||"demo-project",o=t.iat||0,n=t.sub||t.user_id;if(!n)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const s=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:o,exp:o+3600,auth_time:o,sub:n,user_id:n,firebase:{sign_in_provider:"custom",identities:{}}},t);return[u(JSON.stringify({alg:"none",type:"JWT"})),u(JSON.stringify(s)),""].join(".")}function C(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function D(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(C())}function w(){var e;const r=null===(e=y())||void 0===e?void 0:e.forceEnvironment;if("node"===r)return!0;if("browser"===r)return!1;try{return"[object process]"===Object.prototype.toString.call(t.process)}catch(o){return!1}}function T(){return"object"==typeof self&&self.self===self}function N(){const t="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof t&&void 0!==t.id}function M(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function j(){return C().indexOf("Electron/")>=0}function B(){const t=C();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function k(){return C().indexOf("MSAppHost/")>=0}function I(){return!0===r.NODE_CLIENT||!0===r.NODE_ADMIN}function P(){return!w()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function L(){try{return"object"==typeof indexedDB}catch(t){return!1}}function R(){return new Promise((t,e)=>{try{let o=!0;const n="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(n);s.onsuccess=(()=>{s.result.close(),o||self.indexedDB.deleteDatabase(n),t(!0)}),s.onupgradeneeded=(()=>{o=!1}),s.onerror=(()=>{var t;e((null===(t=s.error)||void 0===t?void 0:t.message)||"")})}catch(r){e(r)}})}function V(){return!("undefined"==typeof navigator||!navigator.cookieEnabled)}exports.Deferred=A;const F="FirebaseError";class U extends Error{constructor(t,e,r){super(e),this.code=t,this.customData=r,this.name=F,Object.setPrototypeOf(this,U.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,W.prototype.create)}}exports.FirebaseError=U;class W{constructor(t,e,r){this.service=t,this.serviceName=e,this.errors=r}create(t,...e){const r=e[0]||{},o=`${this.service}/${t}`,n=this.errors[t],s=n?$(n,r):"Error",i=`${this.serviceName}: ${s} (${o}).`;return new U(o,i,r)}}function $(t,e){return t.replace(z,(t,r)=>{const o=e[r];return null!=o?String(o):`<${r}?>`})}exports.ErrorFactory=W;const z=/\{\$([^}]+)}/g;function H(t){return JSON.parse(t)}function J(t){return JSON.stringify(t)}const q=function(t){let e={},r={},o={},n="";try{const i=t.split(".");e=H(f(i[0])||""),r=H(f(i[1])||""),n=i[2],o=r.d||{},delete r.d}catch(s){}return{header:e,claims:r,data:o,signature:n}};exports.decode=q;const G=function(t){const e=q(t).claims,r=Math.floor((new Date).getTime()/1e3);let o=0,n=0;return"object"==typeof e&&(e.hasOwnProperty("nbf")?o=e.nbf:e.hasOwnProperty("iat")&&(o=e.iat),n=e.hasOwnProperty("exp")?e.exp:o+86400),!!r&&!!o&&!!n&&r>=o&&r<=n};exports.isValidTimestamp=G;const K=function(t){const e=q(t).claims;return"object"==typeof e&&e.hasOwnProperty("iat")?e.iat:null};exports.issuedAtTime=K;const X=function(t){const e=q(t).claims;return!!e&&"object"==typeof e&&e.hasOwnProperty("iat")};exports.isValidFormat=X;const Q=function(t){const e=q(t).claims;return"object"==typeof e&&!0===e.admin};function Y(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Z(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function tt(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function et(t,e,r){const o={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(o[n]=e.call(r,t[n],n,t));return o}function rt(t,e){if(t===e)return!0;const r=Object.keys(t),o=Object.keys(e);for(const n of r){if(!o.includes(n))return!1;const r=t[n],s=e[n];if(ot(r)&&ot(s)){if(!rt(r,s))return!1}else if(r!==s)return!1}for(const n of o)if(!r.includes(n))return!1;return!0}function ot(t){return null!==t&&"object"==typeof t}function nt(t,e=2e3){const r=new A;return setTimeout(()=>r.reject("timeout!"),e),t.then(r.resolve,r.reject),r.promise}function st(t){const e=[];for(const[r,o]of Object.entries(t))Array.isArray(o)?o.forEach(t=>{e.push(encodeURIComponent(r)+"="+encodeURIComponent(t))}):e.push(encodeURIComponent(r)+"="+encodeURIComponent(o));return e.length?"&"+e.join("&"):""}function it(t){const e={};return t.replace(/^\?/,"").split("&").forEach(t=>{if(t){const[r,o]=t.split("=");e[decodeURIComponent(r)]=decodeURIComponent(o)}}),e}function at(t){const e=t.indexOf("?");if(!e)return"";const r=t.indexOf("#",e);return t.substring(e,r>0?r:void 0)}exports.isAdmin=Q;class ct{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let t=1;t<this.blockSize;++t)this.pad_[t]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(t,e){e||(e=0);const r=this.W_;if("string"==typeof t)for(let u=0;u<16;u++)r[u]=t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|t.charCodeAt(e+3),e+=4;else for(let u=0;u<16;u++)r[u]=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3],e+=4;for(let u=16;u<80;u++){const t=r[u-3]^r[u-8]^r[u-14]^r[u-16];r[u]=4294967295&(t<<1|t>>>31)}let o,n,s=this.chain_[0],i=this.chain_[1],a=this.chain_[2],c=this.chain_[3],h=this.chain_[4];for(let u=0;u<80;u++){u<40?u<20?(o=c^i&(a^c),n=1518500249):(o=i^a^c,n=1859775393):u<60?(o=i&a|c&(i|a),n=2400959708):(o=i^a^c,n=3395469782);const t=(s<<5|s>>>27)+o+h+n+r[u]&4294967295;h=c,c=a,a=4294967295&(i<<30|i>>>2),i=s,s=t}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+i&4294967295,this.chain_[2]=this.chain_[2]+a&4294967295,this.chain_[3]=this.chain_[3]+c&4294967295,this.chain_[4]=this.chain_[4]+h&4294967295}update(t,e){if(null==t)return;void 0===e&&(e=t.length);const r=e-this.blockSize;let o=0;const n=this.buf_;let s=this.inbuf_;for(;o<e;){if(0===s)for(;o<=r;)this.compress_(t,o),o+=this.blockSize;if("string"==typeof t){for(;o<e;)if(n[s]=t.charCodeAt(o),++o,++s===this.blockSize){this.compress_(n),s=0;break}}else for(;o<e;)if(n[s]=t[o],++o,++s===this.blockSize){this.compress_(n),s=0;break}}this.inbuf_=s,this.total_+=e}digest(){const t=[];let e=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let o=this.blockSize-1;o>=56;o--)this.buf_[o]=255&e,e/=256;this.compress_(this.buf_);let r=0;for(let o=0;o<5;o++)for(let e=24;e>=0;e-=8)t[r]=this.chain_[o]>>e&255,++r;return t}}function ht(t,e){const r=new ut(t,e);return r.subscribe.bind(r)}exports.Sha1=ct;class ut{constructor(t,e){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then(()=>{t(this)}).catch(t=>{this.error(t)})}next(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}complete(){this.forEachObserver(t=>{t.complete()}),this.close()}subscribe(t,e,r){let o;if(void 0===t&&void 0===e&&void 0===r)throw new Error("Missing Observer.");void 0===(o=lt(t,["next","error","complete"])?t:{next:t,error:e,complete:r}).next&&(o.next=pt),void 0===o.error&&(o.error=pt),void 0===o.complete&&(o.complete=pt);const n=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?o.error(this.finalError):o.complete()}catch(t){}}),this.observers.push(o),n}unsubscribeOne(t){void 0!==this.observers&&void 0!==this.observers[t]&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}sendOne(t,e){this.task.then(()=>{if(void 0!==this.observers&&void 0!==this.observers[t])try{e(this.observers[t])}catch(r){"undefined"!=typeof console&&console.error&&console.error(r)}})}close(t){this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function ft(t,e){return(...r)=>{Promise.resolve(!0).then(()=>{t(...r)}).catch(t=>{e&&e(t)})}}function lt(t,e){if("object"!=typeof t||null===t)return!1;for(const r of e)if(r in t&&"function"==typeof t[r])return!0;return!1}function pt(){}const dt=function(t,e,r,o){let n;if(o<e?n="at least "+e:o>r&&(n=0===r?"none":"no more than "+r),n){throw new Error(t+" failed: Was called with "+o+(1===o?" argument.":" arguments.")+" Expects "+n+".")}};function bt(t,e){return`${t} failed: ${e} argument `}function xt(t,e,r){if((!r||e)&&"string"!=typeof e)throw new Error(bt(t,"namespace")+"must be a valid firebase namespace.")}function _t(t,e,r,o){if((!o||r)&&"function"!=typeof r)throw new Error(bt(t,e)+"must be a valid function.")}function gt(t,e,r,o){if((!o||r)&&("object"!=typeof r||null===r))throw new Error(bt(t,e)+"must be a valid context object.")}exports.validateArgCount=dt;const yt=function(t){const e=[];let r=0;for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);if(s>=55296&&s<=56319){const e=s-55296;o(++n<t.length,"Surrogate pair missing trail surrogate."),s=65536+(e<<10)+(t.charCodeAt(n)-56320)}s<128?e[r++]=s:s<2048?(e[r++]=s>>6|192,e[r++]=63&s|128):s<65536?(e[r++]=s>>12|224,e[r++]=s>>6&63|128,e[r++]=63&s|128):(e[r++]=s>>18|240,e[r++]=s>>12&63|128,e[r++]=s>>6&63|128,e[r++]=63&s|128)}return e};exports.stringToByteArray=yt;const vt=function(t){let e=0;for(let r=0;r<t.length;r++){const o=t.charCodeAt(r);o<128?e++:o<2048?e+=2:o>=55296&&o<=56319?(e+=4,r++):e+=3}return e};exports.stringLength=vt;const Et=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})};exports.uuidv4=Et;const mt=1e3,St=2,At=144e5;exports.MAX_VALUE_MILLIS=At;const Ot=.5;function Ct(t,e=mt,r=St){const o=e*Math.pow(r,t),n=Math.round(Ot*o*(Math.random()-.5)*2);return Math.min(At,o+n)}function Dt(t){return Number.isFinite(t)?t+wt(t):`${t}`}function wt(t){const e=(t=Math.abs(t))%100;if(e>=10&&e<=20)return"th";const r=t%10;return 1===r?"st":2===r?"nd":3===r?"rd":"th"}function Tt(t){return t&&t._delegate?t._delegate:t}exports.RANDOM_FACTOR=Ot;
|
|
465
|
+
},{"process":"pBGv"}],"vhY9":[function(require,module,exports) {
|
|
466
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Provider=exports.ComponentContainer=exports.Component=void 0;var t=require("@firebase/util");class e{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}}exports.Component=e;const n="[DEFAULT]";class i{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const n=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(n)){const e=new t.Deferred;if(this.instancesDeferred.set(n,e),this.isInitialized(n)||this.shouldAutoInitialize())try{const t=this.getOrInitializeService({instanceIdentifier:n});t&&e.resolve(t)}catch(i){}}return this.instancesDeferred.get(n).promise}getImmediate(t){var e;const n=this.normalizeInstanceIdentifier(null==t?void 0:t.identifier),i=null!==(e=null==t?void 0:t.optional)&&void 0!==e&&e;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(i)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(s){if(i)return null;throw s}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,this.shouldAutoInitialize()){if(r(t))try{this.getOrInitializeService({instanceIdentifier:n})}catch(e){}for(const[t,n]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(t);try{const t=this.getOrInitializeService({instanceIdentifier:i});n.resolve(t)}catch(e){}}}}clearInstance(t=n){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...t.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return null!=this.component}isInitialized(t=n){return this.instances.has(t)}getOptions(t=n){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,n=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:n,options:e});for(const[s,r]of this.instancesDeferred.entries()){n===this.normalizeInstanceIdentifier(s)&&r.resolve(i)}return i}onInit(t,e){var n;const i=this.normalizeInstanceIdentifier(e),s=null!==(n=this.onInitCallbacks.get(i))&&void 0!==n?n:new Set;s.add(t),this.onInitCallbacks.set(i,s);const r=this.instances.get(i);return r&&t(r,i),()=>{s.delete(t)}}invokeOnInitCallbacks(t,e){const n=this.onInitCallbacks.get(e);if(n)for(const s of n)try{s(t,e)}catch(i){}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let n=this.instances.get(t);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:s(t),options:e}),this.instances.set(t,n),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(n,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,n)}catch(i){}return n||null}normalizeInstanceIdentifier(t=n){return this.component?this.component.multipleInstances?t:n:t}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}function s(t){return t===n?void 0:t}function r(t){return"EAGER"===t.instantiationMode}exports.Provider=i;class o{constructor(t){this.name=t,this.providers=new Map}addComponent(t){const e=this.getProvider(t.name);if(e.isComponentSet())throw new Error(`Component ${t.name} has already been registered with ${this.name}`);e.setComponent(t)}addOrOverwriteComponent(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const e=new i(t,this);return this.providers.set(t,e),e}getProviders(){return Array.from(this.providers.values())}}exports.ComponentContainer=o;
|
|
467
|
+
},{"@firebase/util":"chA2"}],"JJem":[function(require,module,exports) {
|
|
468
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Logger=exports.LogLevel=void 0,exports.setLogLevel=i,exports.setUserLogHandler=g;const e=[];var r;exports.LogLevel=r,function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(r||(exports.LogLevel=r={}));const t={debug:r.DEBUG,verbose:r.VERBOSE,info:r.INFO,warn:r.WARN,error:r.ERROR,silent:r.SILENT},o=r.INFO,l={[r.DEBUG]:"log",[r.VERBOSE]:"log",[r.INFO]:"info",[r.WARN]:"warn",[r.ERROR]:"error"},s=(e,r,...t)=>{if(r<e.logLevel)return;const o=(new Date).toISOString(),s=l[r];if(!s)throw new Error(`Attempted to log a message with an invalid logType (value: ${r})`);console[s](`[${o}] ${e.name}:`,...t)};class n{constructor(r){this.name=r,this._logLevel=o,this._logHandler=s,this._userLogHandler=null,e.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in r))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?t[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,r.DEBUG,...e),this._logHandler(this,r.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,r.VERBOSE,...e),this._logHandler(this,r.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,r.INFO,...e),this._logHandler(this,r.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,r.WARN,...e),this._logHandler(this,r.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,r.ERROR,...e),this._logHandler(this,r.ERROR,...e)}}function i(r){e.forEach(e=>{e.setLogLevel(r)})}function g(o,l){for(const s of e){let e=null;l&&l.level&&(e=t[l.level]),s.userLogHandler=null===o?null:(t,l,...s)=>{const n=s.map(e=>{if(null==e)return null;if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return e.toString();if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch(r){return null}}).filter(e=>e).join(" ");l>=(null!=e?e:t.logLevel)&&o({level:r[l].toLowerCase(),message:n,args:s,type:t.name})}}}exports.Logger=n;
|
|
469
|
+
},{}],"F1qz":[function(require,module,exports) {
|
|
470
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.i=exports.a=void 0,exports.r=v,exports.u=void 0,exports.w=I;const e=(e,t)=>t.some(t=>e instanceof t);let t,r;function n(){return t||(t=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function o(){return r||(r=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}exports.i=e;const s=new WeakMap,i=new WeakMap,a=new WeakMap,c=new WeakMap,u=new WeakMap;function p(e){const t=new Promise((t,r)=>{const n=()=>{e.removeEventListener("success",o),e.removeEventListener("error",s)},o=()=>{t(I(e.result)),n()},s=()=>{r(e.error),n()};e.addEventListener("success",o),e.addEventListener("error",s)});return t.then(t=>{t instanceof IDBCursor&&s.set(t,e)}).catch(()=>{}),u.set(t,e),t}function f(e){if(i.has(e))return;const t=new Promise((t,r)=>{const n=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",s),e.removeEventListener("abort",s)},o=()=>{t(),n()},s=()=>{r(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",o),e.addEventListener("error",s),e.addEventListener("abort",s)});i.set(e,t)}exports.a=u;let d={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return i.get(e);if("objectStoreNames"===t)return e.objectStoreNames||a.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return I(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function v(e){d=e(d)}function D(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?o().includes(e)?function(...t){return e.apply(B(this),t),I(s.get(this))}:function(...t){return I(e.apply(B(this),t))}:function(t,...r){const n=e.call(B(this),t,...r);return a.set(n,t.sort?t.sort():[t]),I(n)}}function m(t){return"function"==typeof t?D(t):(t instanceof IDBTransaction&&f(t),e(t,n())?new Proxy(t,d):t)}function I(e){if(e instanceof IDBRequest)return p(e);if(c.has(e))return c.get(e);const t=m(e);return t!==e&&(c.set(e,t),u.set(t,e)),t}const B=e=>u.get(e);exports.u=B;
|
|
471
|
+
},{}],"JZvK":[function(require,module,exports) {
|
|
472
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.deleteDB=n,exports.openDB=t,Object.defineProperty(exports,"unwrap",{enumerable:!0,get:function(){return e.u}}),Object.defineProperty(exports,"wrap",{enumerable:!0,get:function(){return e.w}});var e=require("./wrap-idb-value.js");function t(t,n,{blocked:r,upgrade:o,blocking:d,terminated:i}={}){const s=indexedDB.open(t,n),a=(0,e.w)(s);return o&&s.addEventListener("upgradeneeded",t=>{o((0,e.w)(s.result),t.oldVersion,t.newVersion,(0,e.w)(s.transaction))}),r&&s.addEventListener("blocked",()=>r()),a.then(e=>{i&&e.addEventListener("close",()=>i()),d&&e.addEventListener("versionchange",()=>d())}).catch(()=>{}),a}function n(t,{blocked:n}={}){const r=indexedDB.deleteDatabase(t);return n&&r.addEventListener("blocked",()=>n()),(0,e.w)(r).then(()=>void 0)}const r=["get","getKey","getAll","getAllKeys","count"],o=["put","add","delete","clear"],d=new Map;function i(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(d.get(t))return d.get(t);const n=t.replace(/FromIndex$/,""),i=t!==n,s=o.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!s&&!r.includes(n))return;const a=async function(e,...t){const r=this.transaction(e,s?"readwrite":"readonly");let o=r.store;return i&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),s&&r.done]))[0]};return d.set(t,a),a}(0,e.r)(e=>({...e,get:(t,n,r)=>i(t,n)||e.get(t,n,r),has:(t,n)=>!!i(t,n)||e.has(t,n)}));
|
|
473
|
+
},{"./wrap-idb-value.js":"F1qz"}],"h2Mb":[function(require,module,exports) {
|
|
474
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"FirebaseError",{enumerable:!0,get:function(){return a.FirebaseError}}),exports._DEFAULT_ENTRY_NAME=exports.SDK_VERSION=void 0,exports._addComponent=L,exports._addOrOverwriteComponent=M,exports._apps=void 0,exports._clearComponents=V,exports._components=void 0,exports._getProvider=U,exports._registerComponent=T,exports._removeServiceInstance=R,exports.deleteApp=Q,exports.getApp=Y,exports.getApps=G,exports.initializeApp=W,exports.onLog=Z,exports.registerVersion=X,exports.setLogLevel=ee;var e=require("@firebase/component"),t=require("@firebase/logger"),a=require("@firebase/util"),r=require("idb");class n{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(i(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null}).filter(e=>e).join(" ")}}function i(e){const t=e.getComponent();return"VERSION"===(null==t?void 0:t.type)}const s="@firebase/app",o="0.9.5",c=new t.Logger("@firebase/app"),p="@firebase/app-compat",h="@firebase/analytics-compat",l="@firebase/analytics",f="@firebase/app-check-compat",d="@firebase/app-check",b="@firebase/auth",g="@firebase/auth-compat",u="@firebase/database",m="@firebase/database-compat",_="@firebase/functions",w="@firebase/functions-compat",v="@firebase/installations",D="@firebase/installations-compat",C="@firebase/messaging",E="@firebase/messaging-compat",y="@firebase/performance",x="@firebase/performance-compat",I="@firebase/remote-config",S="@firebase/remote-config-compat",P="@firebase/storage",O="@firebase/storage-compat",A="@firebase/firestore",$="@firebase/firestore-compat",N="firebase",F="9.18.0",j="[DEFAULT]";exports._DEFAULT_ENTRY_NAME=j;const k={[s]:"fire-core",[p]:"fire-core-compat",[l]:"fire-analytics",[h]:"fire-analytics-compat",[d]:"fire-app-check",[f]:"fire-app-check-compat",[b]:"fire-auth",[g]:"fire-auth-compat",[u]:"fire-rtdb",[m]:"fire-rtdb-compat",[_]:"fire-fn",[w]:"fire-fn-compat",[v]:"fire-iid",[D]:"fire-iid-compat",[C]:"fire-fcm",[E]:"fire-fcm-compat",[y]:"fire-perf",[x]:"fire-perf-compat",[I]:"fire-rc",[S]:"fire-rc-compat",[P]:"fire-gcs",[O]:"fire-gcs-compat",[A]:"fire-fst",[$]:"fire-fst-compat","fire-js":"fire-js",[N]:"fire-js-all"},B=new Map;exports._apps=B;const H=new Map;function L(e,t){try{e.container.addComponent(t)}catch(a){c.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,a)}}function M(e,t){e.container.addOrOverwriteComponent(t)}function T(e){const t=e.name;if(H.has(t))return c.debug(`There were multiple attempts to register component ${t}.`),!1;H.set(t,e);for(const a of B.values())L(a,e);return!0}function U(e,t){const a=e.container.getProvider("heartbeat").getImmediate({optional:!0});return a&&a.triggerHeartbeat(),e.container.getProvider(t)}function R(e,t,a=j){U(e,t).clearInstance(a)}function V(){H.clear()}exports._components=H;const q={"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$appName}","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}."},z=new a.ErrorFactory("app","Firebase",q);class J{constructor(t,a,r){this._isDeleted=!1,this._options=Object.assign({},t),this._config=Object.assign({},a),this._name=a.name,this._automaticDataCollectionEnabled=a.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new e.Component("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw z.create("app-deleted",{appName:this._name})}}const K=F;function W(t,r={}){let n=t;if("object"!=typeof r){r={name:r}}const i=Object.assign({name:j,automaticDataCollectionEnabled:!1},r),s=i.name;if("string"!=typeof s||!s)throw z.create("bad-app-name",{appName:String(s)});if(n||(n=(0,a.getDefaultAppConfig)()),!n)throw z.create("no-options");const o=B.get(s);if(o){if((0,a.deepEqual)(n,o.options)&&(0,a.deepEqual)(i,o.config))return o;throw z.create("duplicate-app",{appName:s})}const c=new e.ComponentContainer(s);for(const e of H.values())c.addComponent(e);const p=new J(n,i,c);return B.set(s,p),p}function Y(e=j){const t=B.get(e);if(!t&&e===j)return W();if(!t)throw z.create("no-app",{appName:e});return t}function G(){return Array.from(B.values())}async function Q(e){const t=e.name;B.has(t)&&(B.delete(t),await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function X(t,a,r){var n;let i=null!==(n=k[t])&&void 0!==n?n:t;r&&(i+=`-${r}`);const s=i.match(/\s|\//),o=a.match(/\s|\//);if(s||o){const e=[`Unable to register library "${i}" with version "${a}":`];return s&&e.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&o&&e.push("and"),o&&e.push(`version name "${a}" contains illegal characters (whitespace or "/")`),void c.warn(e.join(" "))}T(new e.Component(`${i}-version`,()=>({library:i,version:a}),"VERSION"))}function Z(e,a){if(null!==e&&"function"!=typeof e)throw z.create("invalid-log-argument");(0,t.setUserLogHandler)(e,a)}function ee(e){(0,t.setLogLevel)(e)}exports.SDK_VERSION="9.18.0";const te="firebase-heartbeat-database",ae=1,re="firebase-heartbeat-store";let ne=null;function ie(){return ne||(ne=(0,r.openDB)(te,ae,{upgrade:(e,t)=>{switch(t){case 0:e.createObjectStore(re)}}}).catch(e=>{throw z.create("idb-open",{originalErrorMessage:e.message})})),ne}async function se(e){try{return(await ie()).transaction(re).objectStore(re).get(ce(e))}catch(t){if(t instanceof a.FirebaseError)c.warn(t.message);else{const e=z.create("idb-get",{originalErrorMessage:null==t?void 0:t.message});c.warn(e.message)}}}async function oe(e,t){try{const n=(await ie()).transaction(re,"readwrite"),i=n.objectStore(re);return await i.put(t,ce(e)),n.done}catch(r){if(r instanceof a.FirebaseError)c.warn(r.message);else{const e=z.create("idb-set",{originalErrorMessage:null==r?void 0:r.message});c.warn(e.message)}}}function ce(e){return`${e.name}!${e.options.appId}`}const pe=1024,he=2592e6;class le{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new be(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){const e=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),t=fe();if(null===this._heartbeatsCache&&(this._heartbeatsCache=await this._heartbeatsCachePromise),this._heartbeatsCache.lastSentHeartbeatDate!==t&&!this._heartbeatsCache.heartbeats.some(e=>e.date===t))return this._heartbeatsCache.heartbeats.push({date:t,agent:e}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(e=>{const t=new Date(e.date).valueOf();return Date.now()-t<=he}),this._storage.overwrite(this._heartbeatsCache)}async getHeartbeatsHeader(){if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null===this._heartbeatsCache||0===this._heartbeatsCache.heartbeats.length)return"";const e=fe(),{heartbeatsToSend:t,unsentEntries:r}=de(this._heartbeatsCache.heartbeats),n=(0,a.base64urlEncodeWithoutPadding)(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),n}}function fe(){return(new Date).toISOString().substring(0,10)}function de(e,t=pe){const a=[];let r=e.slice();for(const n of e){const e=a.find(e=>e.agent===n.agent);if(e){if(e.dates.push(n.date),ge(a)>t){e.dates.pop();break}}else if(a.push({agent:n.agent,dates:[n.date]}),ge(a)>t){a.pop();break}r=r.slice(1)}return{heartbeatsToSend:a,unsentEntries:r}}class be{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!(0,a.isIndexedDBAvailable)()&&(0,a.validateIndexedDBOpenable)().then(()=>!0).catch(()=>!1)}async read(){if(await this._canUseIndexedDBPromise){return await se(this.app)||{heartbeats:[]}}return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const a=await this.read();return oe(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:a.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){const a=await this.read();return oe(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:a.lastSentHeartbeatDate,heartbeats:[...a.heartbeats,...e.heartbeats]})}}}function ge(e){return(0,a.base64urlEncodeWithoutPadding)(JSON.stringify({version:2,heartbeats:e})).length}function ue(t){T(new e.Component("platform-logger",e=>new n(e),"PRIVATE")),T(new e.Component("heartbeat",e=>new le(e),"PRIVATE")),X(s,o,t),X(s,o,"esm2017"),X("fire-js","")}ue("");
|
|
475
|
+
},{"@firebase/component":"vhY9","@firebase/logger":"JJem","@firebase/util":"chA2","idb":"JZvK"}],"CMFQ":[function(require,module,exports) {
|
|
476
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=require("@firebase/util"),t=require("@firebase/component"),n=i(require("@firebase/app")),r=require("@firebase/logger");function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(a=function(e){return e?n:t})(e)}function i(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=a(t);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}class o{constructor(e,r){this._delegate=e,this.firebase=r,(0,n._addComponent)(e,new t.Component("app-compat",()=>this,"PUBLIC")),this.container=e.container}get automaticDataCollectionEnabled(){return this._delegate.automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this._delegate.automaticDataCollectionEnabled=e}get name(){return this._delegate.name}get options(){return this._delegate.options}delete(){return new Promise(e=>{this._delegate.checkDestroyed(),e()}).then(()=>(this.firebase.INTERNAL.removeApp(this.name),(0,n.deleteApp)(this._delegate)))}_getService(e,t=n._DEFAULT_ENTRY_NAME){var r;this._delegate.checkDestroyed();const a=this._delegate.container.getProvider(e);return a.isInitialized()||"EXPLICIT"!==(null===(r=a.getComponent())||void 0===r?void 0:r.instantiationMode)||a.initialize(),a.getImmediate({identifier:t})}_removeServiceInstance(e,t=n._DEFAULT_ENTRY_NAME){this._delegate.container.getProvider(e).clearInstance(t)}_addComponent(e){(0,n._addComponent)(this._delegate,e)}_addOrOverwriteComponent(e){(0,n._addOrOverwriteComponent)(this._delegate,e)}toJSON(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}}}const s={"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance."},p=new e.ErrorFactory("app-compat","Firebase",s);function c(t){const r={},a={__esModule:!0,initializeApp:function(i,o={}){const s=n.initializeApp(i,o);if((0,e.contains)(r,s.name))return r[s.name];const p=new t(s,a);return r[s.name]=p,p},app:i,registerVersion:n.registerVersion,setLogLevel:n.setLogLevel,onLog:n.onLog,apps:null,SDK_VERSION:n.SDK_VERSION,INTERNAL:{registerComponent:function(r){const o=r.name,s=o.replace("-compat","");if(n._registerComponent(r)&&"PUBLIC"===r.type){const n=(e=i())=>{if("function"!=typeof e[s])throw p.create("invalid-app-argument",{appName:o});return e[s]()};void 0!==r.serviceProps&&(0,e.deepExtend)(n,r.serviceProps),a[s]=n,t.prototype[s]=function(...e){const t=this._getService.bind(this,o);return t.apply(this,r.multipleInstances?e:[])}}return"PUBLIC"===r.type?a[s]:null},removeApp:function(e){delete r[e]},useAsService:function(e,t){if("serverAuth"===t)return null;return t},modularAPIs:n}};function i(t){if(t=t||n._DEFAULT_ENTRY_NAME,!(0,e.contains)(r,t))throw p.create("no-app",{appName:t});return r[t]}return a.default=a,Object.defineProperty(a,"apps",{get:function(){return Object.keys(r).map(e=>r[e])}}),i.App=t,a}function l(){const t=c(o);return t.INTERNAL=Object.assign(Object.assign({},t.INTERNAL),{createFirebaseNamespace:l,extendNamespace:function(n){(0,e.deepExtend)(t,n)},createSubscribe:e.createSubscribe,ErrorFactory:e.ErrorFactory,deepExtend:e.deepExtend}),t}const u=l(),d=new r.Logger("@firebase/app-compat"),f="@firebase/app-compat",m="0.2.5";function g(e){(0,n.registerVersion)(f,m,e)}if((0,e.isBrowser)()&&void 0!==self.firebase){d.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n ");const e=self.firebase.SDK_VERSION;e&&e.indexOf("LITE")>=0&&d.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n ")}const b=u;exports.default=b,g();
|
|
477
|
+
},{"@firebase/util":"chA2","@firebase/component":"vhY9","@firebase/app":"h2Mb","@firebase/logger":"JJem"}],"tq2Y":[function(require,module,exports) {
|
|
478
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e.default}});var e=r(require("@firebase/app-compat"));function r(e){return e&&e.__esModule?e:{default:e}}var t="firebase",a="9.18.0";e.default.registerVersion(t,a,"app-compat");
|
|
479
|
+
},{"@firebase/app-compat":"CMFQ"}],"Q6BU":[function(require,module,exports) {
|
|
480
|
+
var process = require("process");
|
|
481
|
+
var e=require("process");Object.defineProperty(exports,"__esModule",{value:!0}),exports._TEST_ACCESS_hijackHash=exports._TEST_ACCESS_forceRestClient=exports._ReferenceImpl=exports._QueryParams=exports._QueryImpl=exports.TransactionResult=exports.QueryConstraint=exports.OnDisconnect=exports.Database=exports.DataSnapshot=void 0,exports._repoManagerDatabaseFromApp=ol,exports._setSDKVersion=l,exports._validateWritablePath=exports._validatePathString=void 0,exports.child=pa,exports.connectDatabaseEmulator=fl,exports.enableLogging=yl,exports.endAt=Ma,exports.endBefore=Fa,exports.equalTo=el,exports.forceLongPolling=_l,exports.forceWebSockets=dl,exports.get=Ta,exports.getDatabase=pl,exports.goOffline=ml,exports.goOnline=gl,exports.increment=Tl,exports.limitToFirst=ja,exports.limitToLast=Va,exports.off=Ra,exports.onChildAdded=Sa,exports.onChildChanged=xa,exports.onChildMoved=Pa,exports.onChildRemoved=Na,exports.onDisconnect=fa,exports.onValue=Ea,exports.orderByChild=Ya,exports.orderByKey=Ka,exports.orderByPriority=$a,exports.orderByValue=Ja,exports.push=ma,exports.query=tl,exports.ref=da,exports.refFromURL=_a,exports.remove=ga,exports.runTransaction=bl,exports.serverTimestamp=wl,exports.set=ya,exports.setPriority=va,exports.setWithPriority=Ca,exports.startAfter=Ua,exports.startAt=Oa,exports.update=wa;var t=require("@firebase/app"),n=require("@firebase/component"),i=require("@firebase/util"),s=require("@firebase/logger");const r="@firebase/database",o="0.14.4";let a="";function l(e){a=e}class h{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){null==t?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),(0,i.stringify)(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return null==t?null:(0,i.jsonEval)(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}class c{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){null==t?delete this.cache_[e]:this.cache_[e]=t}get(e){return(0,i.contains)(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}const u=function(e){try{if("undefined"!=typeof window&&void 0!==window[e]){const t=window[e];return t.setItem("firebase:sentinel","cache"),t.removeItem("firebase:sentinel"),new h(t)}}catch(t){}return new c},d=u("localStorage"),_=u("sessionStorage"),p=new s.Logger("@firebase/database"),f=function(){let e=1;return function(){return e++}}(),m=function(e){const t=(0,i.stringToByteArray)(e),n=new i.Sha1;n.update(t);const s=n.digest();return i.base64.encodeByteArray(s)},g=function(...e){let t="";for(let n=0;n<e.length;n++){const s=e[n];Array.isArray(s)||s&&"object"==typeof s&&"number"==typeof s.length?t+=g.apply(null,s):t+="object"==typeof s?(0,i.stringify)(s):s,t+=" "}return t};let y=null,v=!0;const C=function(e,t){(0,i.assert)(!t||!0===e||!1===e,"Can't turn on custom loggers persistently."),!0===e?(p.logLevel=s.LogLevel.VERBOSE,y=p.log.bind(p),t&&_.set("logging_enabled",!0)):"function"==typeof e?y=e:(y=null,_.remove("logging_enabled"))},w=function(...e){if(!0===v&&(v=!1,null===y&&!0===_.get("logging_enabled")&&C(!0)),y){const t=g.apply(null,e);y(t)}},T=function(e){return function(...t){w(e,...t)}},I=function(...e){const t="FIREBASE INTERNAL ERROR: "+g(...e);p.error(t)},b=function(...e){const t=`FIREBASE FATAL ERROR: ${g(...e)}`;throw p.error(t),new Error(t)},k=function(...e){const t="FIREBASE WARNING: "+g(...e);p.warn(t)},E=function(){"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&k("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},S=function(e){return"number"==typeof e&&(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},x=function(e){if((0,i.isNodeSdk)()||"complete"===document.readyState)e();else{let t=!1;const n=function(){document.body?t||(t=!0,e()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{"complete"===document.readyState&&n()}),window.attachEvent("onload",n))}},P="[MIN_NAME]",N="[MAX_NAME]",R=function(e,t){if(e===t)return 0;if(e===P||t===N)return-1;if(t===P||e===N)return 1;{const n=V(e),i=V(t);return null!==n?null!==i?n-i==0?e.length-t.length:n-i:-1:null!==i?1:e<t?-1:1}},D=function(e,t){return e===t?0:e<t?-1:1},A=function(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+(0,i.stringify)(t))},M=function(e){if("object"!=typeof e||null===e)return(0,i.stringify)(e);const t=[];for(const i in e)t.push(i);t.sort();let n="{";for(let s=0;s<t.length;s++)0!==s&&(n+=","),n+=(0,i.stringify)(t[s]),n+=":",n+=M(e[t[s]]);return n+="}"},q=function(e,t){const n=e.length;if(n<=t)return[e];const i=[];for(let s=0;s<n;s+=t)s+t>n?i.push(e.substring(s,n)):i.push(e.substring(s,s+t));return i};function F(e,t){for(const n in e)e.hasOwnProperty(n)&&t(n,e[n])}const L=function(e){(0,i.assert)(!S(e),"Invalid JSON number");let t,n,s,r,o;0===e?(n=0,s=0,t=1/e==-1/0?1:0):(t=e<0,(e=Math.abs(e))>=Math.pow(2,-1022)?(n=(r=Math.min(Math.floor(Math.log(e)/Math.LN2),1023))+1023,s=Math.round(e*Math.pow(2,52-r)-Math.pow(2,52))):(n=0,s=Math.round(e/Math.pow(2,-1074))));const a=[];for(o=52;o;o-=1)a.push(s%2?1:0),s=Math.floor(s/2);for(o=11;o;o-=1)a.push(n%2?1:0),n=Math.floor(n/2);a.push(t?1:0),a.reverse();const l=a.join("");let h="";for(o=0;o<64;o+=8){let e=parseInt(l.substr(o,8),2).toString(16);1===e.length&&(e="0"+e),h+=e}return h.toLowerCase()},O=function(){return!("object"!=typeof window||!window.chrome||!window.chrome.extension||/^chrome/.test(window.location.href))},W=function(){return"object"==typeof Windows&&"object"==typeof Windows.UI};function U(e,t){let n="Unknown Error";"too_big"===e?n="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"===e?n="Client doesn't have permission to access the desired data.":"unavailable"===e&&(n="The service is unavailable");const i=new Error(e+" at "+t._path.toString()+": "+n);return i.code=e.toUpperCase(),i}const B=new RegExp("^-?(0*)\\d{1,10}$"),j=-2147483648,H=2147483647,V=function(e){if(B.test(e)){const t=Number(e);if(t>=-2147483648&&t<=2147483647)return t}return null},z=function(e){try{e()}catch(t){setTimeout(()=>{const e=t.stack||"";throw k("Exception was thrown by user callback.",e),t},Math.floor(0))}},Y=function(){return("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},Q=function(e,t){const n=setTimeout(e,t);return"number"==typeof n&&"undefined"!=typeof Deno&&Deno.unrefTimer?Deno.unrefTimer(n):"object"==typeof n&&n.unref&&n.unref(),n};class K{constructor(e,t){this.appName_=e,this.appCheckProvider=t,this.appCheck=null==t?void 0:t.getImmediate({optional:!0}),this.appCheck||null==t||t.get().then(e=>this.appCheck=e)}getToken(e){return this.appCheck?this.appCheck.getToken(e):new Promise((t,n)=>{setTimeout(()=>{this.appCheck?this.getToken(e).then(t,n):t(null)},0)})}addTokenChangeListener(e){var t;null===(t=this.appCheckProvider)||void 0===t||t.get().then(t=>t.addTokenListener(e))}notifyForInvalidToken(){k(`Provided AppCheck credentials for the app named "${this.appName_}" `+"are invalid. This usually indicates your app was not initialized correctly.")}}class G{constructor(e,t,n){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=n,this.auth_=null,this.auth_=n.getImmediate({optional:!0}),this.auth_||n.onInit(e=>this.auth_=e)}getToken(e){return this.auth_?this.auth_.getToken(e).catch(e=>e&&"auth/token-not-initialized"===e.code?(w("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(e)):new Promise((t,n)=>{setTimeout(()=>{this.auth_?this.getToken(e).then(t,n):t(null)},0)})}addTokenChangeListener(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then(t=>t.addAuthTokenListener(e))}removeTokenChangeListener(e){this.authProvider_.get().then(t=>t.removeAuthTokenListener(e))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',k(e)}}class ${constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}$.OWNER="owner";const X="5",J="v",Z="s",ee="r",te="f",ne=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,ie="ls",se="p",re="ac",oe="websocket",ae="long_polling";class le{constructor(e,t,n,i,s=!1,r="",o=!1,a=!1){this.secure=t,this.namespace=n,this.webSocketOnly=i,this.nodeAdmin=s,this.persistenceKey=r,this.includeNamespaceInQueryParams=o,this.isUsingEmulator=a,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=d.get("host:"+e)||this._host}isCacheableHost(){return"s-"===this.internalHost.substr(0,2)}isCustomHost(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&d.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){const e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${t}`}}function he(e){return e.host!==e.internalHost||e.isCustomHost()||e.includeNamespaceInQueryParams}function ce(e,t,n){let s;if((0,i.assert)("string"==typeof t,"typeof type must == string"),(0,i.assert)("object"==typeof n,"typeof params must == object"),t===oe)s=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==ae)throw new Error("Unknown connection type: "+t);s=(e.secure?"https://":"http://")+e.internalHost+"/.lp?"}he(e)&&(n.ns=e.namespace);const r=[];return F(n,(e,t)=>{r.push(e+"="+t)}),s+r.join("&")}class ue{constructor(){this.counters_={}}incrementCounter(e,t=1){(0,i.contains)(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return(0,i.deepCopy)(this.counters_)}}const de={},_e={};function pe(e){const t=e.toString();return de[t]||(de[t]=new ue),de[t]}function fe(e,t){const n=e.toString();return _e[n]||(_e[n]=t()),_e[n]}class me{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const e=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let t=0;t<e.length;++t)e[t]&&z(()=>{this.onMessage_(e[t])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}const ge="start",ye="close",ve="pLPCommand",Ce="pRTLPCB",we="id",Te="pw",Ie="ser",be="cb",ke="seg",Ee="ts",Se="d",xe="dframe",Pe=1870,Ne=30,Re=Pe-Ne,De=25e3,Ae=3e4;class Me{constructor(e,t,n,i,s,r,o){this.connId=e,this.repoInfo=t,this.applicationId=n,this.appCheckToken=i,this.authToken=s,this.transportSessionId=r,this.lastSessionId=o,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=T(e),this.stats_=pe(t),this.urlFn=(e=>(this.appCheckToken&&(e[re]=this.appCheckToken),ce(t,ae,e)))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new me(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(Ae)),x(()=>{if(this.isClosed_)return;this.scriptTagHolder=new qe((...e)=>{const[t,n,i,s,r]=e;if(this.incrementIncomingBytes_(e),this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,t===ge)this.id=n,this.password=i;else{if(t!==ye)throw new Error("Unrecognized command received: "+t);n?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(n,()=>{this.onClosed_()})):this.onClosed_()}},(...e)=>{const[t,n]=e;this.incrementIncomingBytes_(e),this.myPacketOrderer.handleResponse(t,n)},()=>{this.onClosed_()},this.urlFn);const e={};e[ge]="t",e[Ie]=Math.floor(1e8*Math.random()),this.scriptTagHolder.uniqueCallbackIdentifier&&(e[be]=this.scriptTagHolder.uniqueCallbackIdentifier),e[J]=X,this.transportSessionId&&(e[Z]=this.transportSessionId),this.lastSessionId&&(e[ie]=this.lastSessionId),this.applicationId&&(e[se]=this.applicationId),this.appCheckToken&&(e[re]=this.appCheckToken),"undefined"!=typeof location&&location.hostname&&ne.test(location.hostname)&&(e[ee]=te);const t=this.urlFn(e);this.log_("Connecting via long-poll to "+t),this.scriptTagHolder.addTag(t,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){Me.forceAllow_=!0}static forceDisallow(){Me.forceDisallow_=!0}static isAvailable(){return!(0,i.isNodeSdk)()&&(!!Me.forceAllow_||!Me.forceDisallow_&&"undefined"!=typeof document&&null!=document.createElement&&!O()&&!W())}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){const t=(0,i.stringify)(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const n=(0,i.base64Encode)(t),s=q(n,Re);for(let i=0;i<s.length;i++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,s.length,s[i]),this.curSegmentNum++}addDisconnectPingFrame(e,t){if((0,i.isNodeSdk)())return;this.myDisconnFrame=document.createElement("iframe");const n={};n[xe]="t",n[we]=e,n[Te]=t,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=(0,i.stringify)(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class qe{constructor(e,t,n,s){if(this.onDisconnect=n,this.urlFn=s,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0,(0,i.isNodeSdk)())this.commandCB=e,this.onMessageCB=t;else{this.uniqueCallbackIdentifier=f(),window[ve+this.uniqueCallbackIdentifier]=e,window[Ce+this.uniqueCallbackIdentifier]=t,this.myIFrame=qe.createIFrame_();let n="";if(this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,"javascript:".length)){n='<script>document.domain="'+document.domain+'";<\/script>'}const i="<html><body>"+n+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(i),this.myIFrame.doc.close()}catch(r){w("frame writing exception"),r.stack&&w(r.stack),w(r)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(e);try{e.contentWindow.document||w("No IE domain setting required")}catch(t){const n=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+n+"';document.close();})())"}return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{null!==this.myIFrame&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const e={};e[we]=this.myID,e[Te]=this.myPW,e[Ie]=this.currentSerial;let t=this.urlFn(e),n="",i=0;for(;this.pendingSegs.length>0;){if(!(this.pendingSegs[0].d.length+Ne+n.length<=Pe))break;{const e=this.pendingSegs.shift();n=n+"&"+ke+i+"="+e.seg+"&"+Ee+i+"="+e.ts+"&"+Se+i+"="+e.d,i++}}return t+=n,this.addLongPollTag_(t,this.currentSerial),!0}return!1}enqueueSegment(e,t,n){this.pendingSegs.push({seg:e,ts:t,d:n}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const n=()=>{this.outstandingRequests.delete(t),this.newRequest_()},i=setTimeout(n,Math.floor(De));this.addTag(e,()=>{clearTimeout(i),n()})}addTag(e,t){(0,i.isNodeSdk)()?this.doNodeLongPoll(e,t):setTimeout(()=>{try{if(!this.sendNewPolls)return;const i=this.myIFrame.doc.createElement("script");i.type="text/javascript",i.async=!0,i.src=e,i.onload=i.onreadystatechange=function(){const e=i.readyState;e&&"loaded"!==e&&"complete"!==e||(i.onload=i.onreadystatechange=null,i.parentNode&&i.parentNode.removeChild(i),t())},i.onerror=(()=>{w("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()}),this.myIFrame.doc.body.appendChild(i)}catch(n){}},Math.floor(1))}}const Fe=16384,Le=45e3;let Oe=null;"undefined"!=typeof MozWebSocket?Oe=MozWebSocket:"undefined"!=typeof WebSocket&&(Oe=WebSocket);class We{constructor(e,t,n,i,s,r,o){this.connId=e,this.applicationId=n,this.appCheckToken=i,this.authToken=s,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=T(this.connId),this.stats_=pe(t),this.connURL=We.connectionURL_(t,r,o,i,n),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,n,s,r){const o={};return o[J]=X,!(0,i.isNodeSdk)()&&"undefined"!=typeof location&&location.hostname&&ne.test(location.hostname)&&(o[ee]=te),t&&(o[Z]=t),n&&(o[ie]=n),s&&(o[re]=s),r&&(o[se]=r),ce(e,oe,o)}open(t,n){this.onDisconnect=n,this.onMessage=t,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,d.set("previous_websocket_failure",!0);try{let t;if((0,i.isNodeSdk)()){const n=this.nodeAdmin?"AdminNode":"Node";t={headers:{"User-Agent":`Firebase/${X}/${a}/${e.platform}/${n}`,"X-Firebase-GMPID":this.applicationId||""}},this.authToken&&(t.headers.Authorization=`Bearer ${this.authToken}`),this.appCheckToken&&(t.headers["X-Firebase-AppCheck"]=this.appCheckToken);const i=e.env,s=0===this.connURL.indexOf("wss://")?i.HTTPS_PROXY||i.https_proxy:i.HTTP_PROXY||i.http_proxy;s&&(t.proxy={origin:s})}this.mySock=new Oe(this.connURL,[],t)}catch(s){this.log_("Error instantiating WebSocket.");const e=s.message||s.data;return e&&this.log_(e),void this.onClosed_()}this.mySock.onopen=(()=>{this.log_("Websocket connected."),this.everConnected_=!0}),this.mySock.onclose=(()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()}),this.mySock.onmessage=(e=>{this.handleIncomingFrame(e)}),this.mySock.onerror=(e=>{this.log_("WebSocket error. Closing connection.");const t=e.message||e.data;t&&this.log_(t),this.onClosed_()})}start(){}static forceDisallow(){We.forceDisallow_=!0}static isAvailable(){let e=!1;if("undefined"!=typeof navigator&&navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,n=navigator.userAgent.match(t);n&&n.length>1&&parseFloat(n[1])<4.4&&(e=!0)}return!e&&null!==Oe&&!We.forceDisallow_}static previouslyFailed(){return d.isInMemoryStorage||!0===d.get("previous_websocket_failure")}markConnectionHealthy(){d.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const e=this.frames.join("");this.frames=null;const t=(0,i.jsonEval)(e);this.onMessage(t)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if((0,i.assert)(null===this.frames,"We already have a frame buffer"),e.length<=6){const t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(null===this.mySock)return;const t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(t);else{const e=this.extractFrameCount_(t);null!==e&&this.appendFrame_(e)}}send(e){this.resetKeepAlive();const t=(0,i.stringify)(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const n=q(t,Fe);n.length>1&&this.sendString_(String(n.length));for(let i=0;i<n.length;i++)this.sendString_(n[i])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(Le))}sendString_(e){try{this.mySock.send(e)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}We.responsesRequiredToBeHealthy=2,We.healthyTimeout=3e4;class Ue{constructor(e){this.initTransports_(e)}static get ALL_TRANSPORTS(){return[Me,We]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}initTransports_(e){const t=We&&We.isAvailable();let n=t&&!We.previouslyFailed();if(e.webSocketOnly&&(t||k("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),n=!0),n)this.transports_=[We];else{const e=this.transports_=[];for(const t of Ue.ALL_TRANSPORTS)t&&t.isAvailable()&&e.push(t);Ue.globalTransportInitialized_=!0}}initialTransport(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return this.transports_.length>1?this.transports_[1]:null}}Ue.globalTransportInitialized_=!1;const Be=6e4,je=5e3,He=10240,Ve=102400,ze="t",Ye="d",Qe="s",Ke="r",Ge="e",$e="o",Xe="a",Je="n",Ze="p",et="h";class tt{constructor(e,t,n,i,s,r,o,a,l,h){this.id=e,this.repoInfo_=t,this.applicationId_=n,this.appCheckToken_=i,this.authToken_=s,this.onMessage_=r,this.onReady_=o,this.onDisconnect_=a,this.onKill_=l,this.lastSessionId=h,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=T("c:"+this.id+":"),this.transportManager_=new Ue(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),n=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(t,n)},Math.floor(0));const i=e.healthyTimeout||0;i>0&&(this.healthyTimeout_=Q(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>Ve?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>He?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(i)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(e){return t=>{e===this.conn_?this.onConnectionLost_(t):e===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(e){return t=>{2!==this.state_&&(e===this.rx_?this.onPrimaryMessageReceived_(t):e===this.secondaryConn_?this.onSecondaryMessageReceived_(t):this.log_("message on old connection"))}}sendRequest(e){const t={t:"d",d:e};this.sendData_(t)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){if(ze in e){const t=e[ze];t===Xe?this.upgradeIfSecondaryHealthy_():t===Ke?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):t===$e&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=A("t",e),n=A("d",e);if("c"===t)this.onSecondaryControl_(n);else{if("d"!==t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(n)}}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:Ze,d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:Xe,d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:Je,d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=A("t",e),n=A("d",e);"c"===t?this.onControl_(n):"d"===t&&this.onDataMessage_(n)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){const t=A(ze,e);if(Ye in e){const n=e[Ye];if(t===et){const e=Object.assign({},n);this.repoInfo_.isUsingEmulator&&(e.h=this.repoInfo_.host),this.onHandshake_(e)}else if(t===Je){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let e=0;e<this.pendingDataMessages.length;++e)this.onDataMessage_(this.pendingDataMessages[e]);this.pendingDataMessages=[],this.tryCleanupConnection()}else t===Qe?this.onConnectionShutdown_(n):t===Ke?this.onReset_(n):t===Ge?I("Server Error: "+n):t===$e?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):I("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,n=e.v,i=e.h;this.sessionId=e.s,this.repoInfo_.host=i,0===this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),X!==n&&k("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){const e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.secondaryConn_),n=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,n),Q(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(Be))}onReset_(e){this.log_("Reset packet received. New host: "+e),this.repoInfo_.host=e,1===this.state_?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Q(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(je))}sendPingOnPrimaryIfNecessary_(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:Ze,d:{}}}))}onSecondaryConnectionLost_(){const e=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==e&&this.rx_!==e||this.close()}onConnectionLost_(e){this.conn_=null,e||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(d.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(e)}close(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}class nt{put(e,t,n,i){}merge(e,t,n,i){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,n){}onDisconnectMerge(e,t,n){}onDisconnectCancel(e,t){}reportStats(e){}}class it{constructor(e){this.allowedEvents_=e,this.listeners_={},(0,i.assert)(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}trigger(e,...t){if(Array.isArray(this.listeners_[e])){const n=[...this.listeners_[e]];for(let e=0;e<n.length;e++)n[e].callback.apply(n[e].context,t)}}on(e,t,n){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:n});const i=this.getInitialEvent(e);i&&t.apply(n,i)}off(e,t,n){this.validateEventType_(e);const i=this.listeners_[e]||[];for(let s=0;s<i.length;s++)if(i[s].callback===t&&(!n||n===i[s].context))return void i.splice(s,1)}validateEventType_(e){(0,i.assert)(this.allowedEvents_.find(t=>t===e),"Unknown event: "+e)}}class st extends it{constructor(){super(["online"]),this.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||(0,i.isMobileCordova)()||(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}static getInstance(){return new st}getInitialEvent(e){return(0,i.assert)("online"===e,"Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}const rt=32,ot=768;class at{constructor(e,t){if(void 0===t){this.pieces_=e.split("/");let t=0;for(let e=0;e<this.pieces_.length;e++)this.pieces_[e].length>0&&(this.pieces_[t]=this.pieces_[e],t++);this.pieces_.length=t,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)""!==this.pieces_[t]&&(e+="/"+this.pieces_[t]);return e||"/"}}function lt(){return new at("")}function ht(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function ct(e){return e.pieces_.length-e.pieceNum_}function ut(e){let t=e.pieceNum_;return t<e.pieces_.length&&t++,new at(e.pieces_,t)}function dt(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function _t(e){let t="";for(let n=e.pieceNum_;n<e.pieces_.length;n++)""!==e.pieces_[n]&&(t+="/"+encodeURIComponent(String(e.pieces_[n])));return t||"/"}function pt(e,t=0){return e.pieces_.slice(e.pieceNum_+t)}function ft(e){if(e.pieceNum_>=e.pieces_.length)return null;const t=[];for(let n=e.pieceNum_;n<e.pieces_.length-1;n++)t.push(e.pieces_[n]);return new at(t,0)}function mt(e,t){const n=[];for(let i=e.pieceNum_;i<e.pieces_.length;i++)n.push(e.pieces_[i]);if(t instanceof at)for(let i=t.pieceNum_;i<t.pieces_.length;i++)n.push(t.pieces_[i]);else{const e=t.split("/");for(let t=0;t<e.length;t++)e[t].length>0&&n.push(e[t])}return new at(n,0)}function gt(e){return e.pieceNum_>=e.pieces_.length}function yt(e,t){const n=ht(e),i=ht(t);if(null===n)return t;if(n===i)return yt(ut(e),ut(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function vt(e,t){const n=pt(e,0),i=pt(t,0);for(let s=0;s<n.length&&s<i.length;s++){const e=R(n[s],i[s]);if(0!==e)return e}return n.length===i.length?0:n.length<i.length?-1:1}function Ct(e,t){if(ct(e)!==ct(t))return!1;for(let n=e.pieceNum_,i=t.pieceNum_;n<=e.pieces_.length;n++,i++)if(e.pieces_[n]!==t.pieces_[i])return!1;return!0}function wt(e,t){let n=e.pieceNum_,i=t.pieceNum_;if(ct(e)>ct(t))return!1;for(;n<e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[i])return!1;++n,++i}return!0}class Tt{constructor(e,t){this.errorPrefix_=t,this.parts_=pt(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let n=0;n<this.parts_.length;n++)this.byteLength_+=(0,i.stringLength)(this.parts_[n]);kt(this)}}function It(e,t){e.parts_.length>0&&(e.byteLength_+=1),e.parts_.push(t),e.byteLength_+=(0,i.stringLength)(t),kt(e)}function bt(e){const t=e.parts_.pop();e.byteLength_-=(0,i.stringLength)(t),e.parts_.length>0&&(e.byteLength_-=1)}function kt(e){if(e.byteLength_>ot)throw new Error(e.errorPrefix_+"has a key path longer than "+ot+" bytes ("+e.byteLength_+").");if(e.parts_.length>rt)throw new Error(e.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+rt+") or object contains a cycle "+Et(e))}function Et(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}class St extends it{constructor(){let e,t;super(["visible"]),"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(t="visibilitychange",e="hidden"):void 0!==document.mozHidden?(t="mozvisibilitychange",e="mozHidden"):void 0!==document.msHidden?(t="msvisibilitychange",e="msHidden"):void 0!==document.webkitHidden&&(t="webkitvisibilitychange",e="webkitHidden")),this.visible_=!0,t&&document.addEventListener(t,()=>{const t=!document[e];t!==this.visible_&&(this.visible_=t,this.trigger("visible",t))},!1)}static getInstance(){return new St}getInitialEvent(e){return(0,i.assert)("visible"===e,"Unknown event type: "+e),[this.visible_]}}const xt=1e3,Pt=3e5,Nt=3e4,Rt=1.3,Dt=3e4,At="server_kill",Mt=3;class qt extends nt{constructor(e,t,n,s,r,o,a,l){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=n,this.onConnectStatus_=s,this.onServerInfoUpdate_=r,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=l,this.id=qt.nextPersistentConnectionId_++,this.log_=T("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=xt,this.maxReconnectDelay_=Pt,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,l&&!(0,i.isNodeSdk)())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");St.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&st.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,n){const s=++this.requestNumber_,r={r:s,a:e,b:t};this.log_((0,i.stringify)(r)),(0,i.assert)(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(r),n&&(this.requestCBHash_[s]=n)}get(e){this.initConnection_();const t=new i.Deferred,n={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:e=>{const n=e.d;"ok"===e.s?t.resolve(n):t.reject(n)}};this.outstandingGets_.push(n),this.outstandingGetCount_++;const s=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(s),t.promise}listen(e,t,n,s){this.initConnection_();const r=e._queryIdentifier,o=e._path.toString();this.log_("Listen called for "+o+" "+r),this.listens.has(o)||this.listens.set(o,new Map),(0,i.assert)(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),(0,i.assert)(!this.listens.get(o).has(r),"listen() called twice for same path/queryId.");const a={onComplete:s,hashFn:t,query:e,tag:n};this.listens.get(o).set(r,a),this.connected_&&this.sendListen_(a)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,n=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),t.onComplete&&t.onComplete(n)})}sendListen_(e){const t=e.query,n=t._path.toString(),i=t._queryIdentifier;this.log_("Listen on "+n+" for "+i);const s={p:n};e.tag&&(s.q=t._queryObject,s.t=e.tag),s.h=e.hashFn(),this.sendRequest("q",s,s=>{const r=s.d,o=s.s;qt.warnOnListenWarnings_(r,t),(this.listens.get(n)&&this.listens.get(n).get(i))===e&&(this.log_("listen response",s),"ok"!==o&&this.removeListen_(n,i),e.onComplete&&e.onComplete(o,r))})}static warnOnListenWarnings_(e,t){if(e&&"object"==typeof e&&(0,i.contains)(e,"w")){const n=(0,i.safeGet)(e,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){const e='".indexOn": "'+t._queryParams.getIndex().toString()+'"',n=t._path.toString();k("Using an unspecified index. Your data will be downloaded and "+`filtered on the client. Consider adding ${e} at `+`${n} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&40===e.length||(0,i.isAdmin)(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=Nt)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const e=this.authToken_,t=(0,i.isValidFormat)(e)?"auth":"gauth",n={cred:e};null===this.authOverride_?n.noauth=!0:"object"==typeof this.authOverride_&&(n.authvar=this.authOverride_),this.sendRequest(t,n,t=>{const n=t.s,i=t.d||"error";this.authToken_===e&&("ok"===n?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(n,i))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{const t=e.s,n=e.d||"error";"ok"===t?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,n)})}unlisten(e,t){const n=e._path.toString(),s=e._queryIdentifier;this.log_("Unlisten called for "+n+" "+s),(0,i.assert)(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(n,s)&&this.connected_&&this.sendUnlisten_(n,s,e._queryObject,t)}sendUnlisten_(e,t,n,i){this.log_("Unlisten on "+e+" for "+t);const s={p:e};i&&(s.q=n,s.t=i),this.sendRequest("n",s)}onDisconnectPut(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:n})}onDisconnectMerge(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:n})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,n,i){const s={p:t,d:n};this.log_("onDisconnect "+e,s),this.sendRequest(e,s,e=>{i&&setTimeout(()=>{i(e.s,e.d)},Math.floor(0))})}put(e,t,n,i){this.putInternal("p",e,t,n,i)}merge(e,t,n,i){this.putInternal("m",e,t,n,i)}putInternal(e,t,n,i,s){this.initConnection_();const r={p:t,d:n};void 0!==s&&(r.h=s),this.outstandingPuts_.push({action:e,request:r,onComplete:i}),this.outstandingPutCount_++;const o=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(o):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,n=this.outstandingPuts_[e].request,i=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,n,n=>{this.log_(t+" response",n),delete this.outstandingPuts_[e],this.outstandingPutCount_--,0===this.outstandingPutCount_&&(this.outstandingPuts_=[]),i&&i(n.s,n.d)})}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,e=>{if("ok"!==e.s){const t=e.d;this.log_("reportStats","Error sending stats: "+t)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+(0,i.stringify)(e));const t=e.r,n=this.requestCBHash_[t];n&&(delete this.requestCBHash_[t],n(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),"d"===e?this.onDataUpdate_(t.p,t.d,!1,t.t):"m"===e?this.onDataUpdate_(t.p,t.d,!0,t.t):"c"===e?this.onListenRevoked_(t.p,t.q):"ac"===e?this.onAuthRevoked_(t.s,t.d):"apc"===e?this.onAppCheckRevoked_(t.s,t.d):"sd"===e?this.onSecurityDebugPacket_(t):I("Unrecognized action received from server: "+(0,i.stringify)(e)+"\nAre you using the latest client?")}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){(0,i.assert)(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=xt,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=xt,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){if(this.visible_){if(this.lastConnectionEstablishedTime_){(new Date).getTime()-this.lastConnectionEstablishedTime_>Dt&&(this.reconnectDelay_=xt),this.lastConnectionEstablishedTime_=null}}else this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime();const e=(new Date).getTime()-this.lastConnectionAttemptTime_;let t=Math.max(0,this.reconnectDelay_-e);t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*Rt)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),t=this.onReady_.bind(this),n=this.onRealtimeDisconnect_.bind(this),s=this.id+":"+qt.nextConnectionId_++,r=this.lastSessionId;let o=!1,a=null;const l=function(){a?a.close():(o=!0,n())},h=function(e){(0,i.assert)(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(e)};this.realtime_={close:l,sendRequest:h};const c=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[i,h]=await Promise.all([this.authTokenProvider_.getToken(c),this.appCheckTokenProvider_.getToken(c)]);o?w("getToken() completed but was canceled"):(w("getToken() completed. Creating connection."),this.authToken_=i&&i.accessToken,this.appCheckToken_=h&&h.token,a=new tt(s,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,n,e=>{k(e+" ("+this.repoInfo_.toString()+")"),this.interrupt(At)},r))}catch(I){this.log_("Failed to get token: "+I),o||(this.repoInfo_.nodeAdmin&&k(I),l())}}}interrupt(e){w("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){w("Resuming connection for reason: "+e),delete this.interruptReasons_[e],(0,i.isEmpty)(this.interruptReasons_)&&(this.reconnectDelay_=xt,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){const t=e-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let n;n=t?t.map(e=>M(e)).join("$"):"default";const i=this.removeListen_(e,n);i&&i.onComplete&&i.onComplete("permission_denied")}removeListen_(e,t){const n=new at(e).toString();let i;if(this.listens.has(n)){const e=this.listens.get(n);i=e.get(t),e.delete(t),0===e.size&&this.listens.delete(n)}else i=void 0;return i}onAuthRevoked_(e,t){w("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=Mt&&(this.reconnectDelay_=Nt,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){w("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=Mt&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace("\n","\nFIREBASE: "))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const t of e.values())this.sendListen_(t);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){const e={};let t="js";(0,i.isNodeSdk)()&&(t=this.repoInfo_.nodeAdmin?"admin_node":"node"),e["sdk."+t+"."+a.replace(/\./g,"-")]=1,(0,i.isMobileCordova)()?e["framework.cordova"]=1:(0,i.isReactNative)()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=st.getInstance().currentlyOnline();return(0,i.isEmpty)(this.interruptReasons_)&&e}}qt.nextPersistentConnectionId_=0,qt.nextConnectionId_=0;class Ft{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new Ft(e,t)}}class Lt{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){const n=new Ft(P,e),i=new Ft(P,t);return 0!==this.compare(n,i)}minPost(){return Ft.MIN}}let Ot;class Wt extends Lt{static get __EMPTY_NODE(){return Ot}static set __EMPTY_NODE(e){Ot=e}compare(e,t){return R(e.name,t.name)}isDefinedOn(e){throw(0,i.assertionError)("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return Ft.MIN}maxPost(){return new Ft(N,Ot)}makePost(e,t){return(0,i.assert)("string"==typeof e,"KeyIndex indexValue must always be a string."),new Ft(e,Ot)}toString(){return".key"}}const Ut=new Wt;class Bt{constructor(e,t,n,i,s=null){this.isReverse_=i,this.resultGenerator_=s,this.nodeStack_=[];let r=1;for(;!e.isEmpty();)if(e=e,r=t?n(e.key,t):1,i&&(r*=-1),r<0)e=this.isReverse_?e.left:e.right;else{if(0===r){this.nodeStack_.push(e);break}this.nodeStack_.push(e),e=this.isReverse_?e.right:e.left}}getNext(){if(0===this.nodeStack_.length)return null;let e,t=this.nodeStack_.pop();if(e=this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value},this.isReverse_)for(t=t.left;!t.isEmpty();)this.nodeStack_.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack_.push(t),t=t.left;return e}hasNext(){return this.nodeStack_.length>0}peek(){if(0===this.nodeStack_.length)return null;const e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class jt{constructor(e,t,n,i,s){this.key=e,this.value=t,this.color=null!=n?n:jt.RED,this.left=null!=i?i:Vt.EMPTY_NODE,this.right=null!=s?s:Vt.EMPTY_NODE}copy(e,t,n,i,s){return new jt(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=i?i:this.left,null!=s?s:this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||!!e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,n){let i=this;const s=n(e,i.key);return(i=s<0?i.copy(null,null,null,i.left.insert(e,t,n),null):0===s?i.copy(null,t,null,null,null):i.copy(null,null,null,null,i.right.insert(e,t,n))).fixUp_()}removeMin_(){if(this.left.isEmpty())return Vt.EMPTY_NODE;let e=this;return e.left.isRed_()||e.left.left.isRed_()||(e=e.moveRedLeft_()),(e=e.copy(null,null,null,e.left.removeMin_(),null)).fixUp_()}remove(e,t){let n,i;if(t(e,(n=this).key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===t(e,n.key)){if(n.right.isEmpty())return Vt.EMPTY_NODE;i=n.right.min_(),n=n.copy(i.key,i.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=(e=(e=e.copy(null,null,null,null,e.right.rotateRight_())).rotateLeft_()).colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=(e=e.rotateRight_()).colorFlip_()),e}rotateLeft_(){const e=this.copy(null,null,jt.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,jt.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth_(){const e=this.check_();return Math.pow(2,e)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}jt.RED=!0,jt.BLACK=!1;class Ht{copy(e,t,n,i,s){return this}insert(e,t,n){return new jt(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}}class Vt{constructor(e,t=Vt.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new Vt(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,jt.BLACK,null,null))}remove(e){return new Vt(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,jt.BLACK,null,null))}get(e){let t,n=this.root_;for(;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key)))return n.value;t<0?n=n.left:t>0&&(n=n.right)}return null}getPredecessorKey(e){let t,n=this.root_,i=null;for(;!n.isEmpty();){if(0===(t=this.comparator_(e,n.key))){if(n.left.isEmpty())return i?i.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}t<0?n=n.left:t>0&&(i=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new Bt(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new Bt(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new Bt(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new Bt(this.root_,null,this.comparator_,!0,e)}}function zt(e,t){return R(e.name,t.name)}function Yt(e,t){return R(e,t)}let Qt;function Kt(e){Qt=e}Vt.EMPTY_NODE=new Ht;const Gt=function(e){return"number"==typeof e?"number:"+L(e):"string:"+e},$t=function(e){if(e.isLeafNode()){const t=e.val();(0,i.assert)("string"==typeof t||"number"==typeof t||"object"==typeof t&&(0,i.contains)(t,".sv"),"Priority must be a string or number.")}else(0,i.assert)(e===Qt||e.isEmpty(),"priority of unexpected type.");(0,i.assert)(e===Qt||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};let Xt,Jt,Zt;class en{constructor(e,t=en.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,(0,i.assert)(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),$t(this.priorityNode_)}static set __childrenNodeConstructor(e){Xt=e}static get __childrenNodeConstructor(){return Xt}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new en(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:en.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return gt(e)?this:".priority"===ht(e)?this.priorityNode_:en.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return".priority"===e?this.updatePriority(t):t.isEmpty()&&".priority"!==e?this:en.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const n=ht(e);return null===n?t:t.isEmpty()&&".priority"!==n?this:((0,i.assert)(".priority"!==n||1===ct(e),".priority must be the last token in a path"),this.updateImmediateChild(n,en.__childrenNodeConstructor.EMPTY_NODE.updateChild(ut(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(null===this.lazyHash_){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+Gt(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",e+="number"===t?L(this.value_):this.value_,this.lazyHash_=m(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===en.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof en.__childrenNodeConstructor?-1:((0,i.assert)(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,n=typeof this.value_,s=en.VALUE_TYPE_ORDER.indexOf(t),r=en.VALUE_TYPE_ORDER.indexOf(n);return(0,i.assert)(s>=0,"Unknown leaf type: "+t),(0,i.assert)(r>=0,"Unknown leaf type: "+n),s===r?"object"===n?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:r-s}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){const t=e;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}return!1}}function tn(e){Jt=e}function nn(e){Zt=e}en.VALUE_TYPE_ORDER=["object","boolean","number","string"];class sn extends Lt{compare(e,t){const n=e.node.getPriority(),i=t.node.getPriority(),s=n.compareTo(i);return 0===s?R(e.name,t.name):s}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return Ft.MIN}maxPost(){return new Ft(N,new en("[PRIORITY-POST]",Zt))}makePost(e,t){const n=Jt(e);return new Ft(t,new en("[PRIORITY-POST]",n))}toString(){return".priority"}}const rn=new sn,on=Math.log(2);class an{constructor(e){this.count=(e=>parseInt(Math.log(e)/on,10))(e+1),this.current_=this.count-1;const t=(e=>parseInt(Array(e+1).join("1"),2))(this.count);this.bits_=e+1&t}nextBitIsOne(){const e=!(this.bits_&1<<this.current_);return this.current_--,e}}const ln=function(e,t,n,i){e.sort(t);const s=function(t,i){const r=i-t;let o,a;if(0===r)return null;if(1===r)return o=e[t],a=n?n(o):o,new jt(a,o.node,jt.BLACK,null,null);{const l=parseInt(r/2,10)+t,h=s(t,l),c=s(l+1,i);return o=e[l],a=n?n(o):o,new jt(a,o.node,jt.BLACK,h,c)}},r=function(t){let i=null,r=null,o=e.length;const a=function(t,i){const r=o-t,a=o;o-=t;const h=s(r+1,a),c=e[r],u=n?n(c):c;l(new jt(u,c.node,i,null,h))},l=function(e){i?(i.left=e,i=e):(r=e,i=e)};for(let e=0;e<t.count;++e){const n=t.nextBitIsOne(),i=Math.pow(2,t.count-(e+1));n?a(i,jt.BLACK):(a(i,jt.BLACK),a(i,jt.RED))}return r}(new an(e.length));return new Vt(i||t,r)};let hn;const cn={};class un{constructor(e,t){this.indexes_=e,this.indexSet_=t}static get Default(){return(0,i.assert)(cn&&rn,"ChildrenNode.ts has not been loaded"),hn=hn||new un({".priority":cn},{".priority":rn})}get(e){const t=(0,i.safeGet)(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof Vt?t:null}hasIndex(e){return(0,i.contains)(this.indexSet_,e.toString())}addIndex(e,t){(0,i.assert)(e!==Ut,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const n=[];let s=!1;const r=t.getIterator(Ft.Wrap);let o,a=r.getNext();for(;a;)s=s||e.isDefinedOn(a.node),n.push(a),a=r.getNext();o=s?ln(n,e.getCompare()):cn;const l=e.toString(),h=Object.assign({},this.indexSet_);h[l]=e;const c=Object.assign({},this.indexes_);return c[l]=o,new un(c,h)}addToIndexes(e,t){const n=(0,i.map)(this.indexes_,(n,s)=>{const r=(0,i.safeGet)(this.indexSet_,s);if((0,i.assert)(r,"Missing index implementation for "+s),n===cn){if(r.isDefinedOn(e.node)){const n=[],i=t.getIterator(Ft.Wrap);let s=i.getNext();for(;s;)s.name!==e.name&&n.push(s),s=i.getNext();return n.push(e),ln(n,r.getCompare())}return cn}{const i=t.get(e.name);let s=n;return i&&(s=s.remove(new Ft(e.name,i))),s.insert(e,e.node)}});return new un(n,this.indexSet_)}removeFromIndexes(e,t){const n=(0,i.map)(this.indexes_,n=>{if(n===cn)return n;{const i=t.get(e.name);return i?n.remove(new Ft(e.name,i)):n}});return new un(n,this.indexSet_)}}let dn;class _n{constructor(e,t,n){this.children_=e,this.priorityNode_=t,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&$t(this.priorityNode_),this.children_.isEmpty()&&(0,i.assert)(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return dn||(dn=new _n(new Vt(Yt),null,un.Default))}isLeafNode(){return!1}getPriority(){return this.priorityNode_||dn}updatePriority(e){return this.children_.isEmpty()?this:new _n(this.children_,e,this.indexMap_)}getImmediateChild(e){if(".priority"===e)return this.getPriority();{const t=this.children_.get(e);return null===t?dn:t}}getChild(e){const t=ht(e);return null===t?this:this.getImmediateChild(t).getChild(ut(e))}hasChild(e){return null!==this.children_.get(e)}updateImmediateChild(e,t){if((0,i.assert)(t,"We should always be passing snapshot nodes"),".priority"===e)return this.updatePriority(t);{const n=new Ft(e,t);let i,s;t.isEmpty()?(i=this.children_.remove(e),s=this.indexMap_.removeFromIndexes(n,this.children_)):(i=this.children_.insert(e,t),s=this.indexMap_.addToIndexes(n,this.children_));const r=i.isEmpty()?dn:this.priorityNode_;return new _n(i,r,s)}}updateChild(e,t){const n=ht(e);if(null===n)return t;{(0,i.assert)(".priority"!==ht(e)||1===ct(e),".priority must be the last token in a path");const s=this.getImmediateChild(n).updateChild(ut(e),t);return this.updateImmediateChild(n,s)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let n=0,i=0,s=!0;if(this.forEachChild(rn,(r,o)=>{t[r]=o.val(e),n++,s&&_n.INTEGER_REGEXP_.test(r)?i=Math.max(i,Number(r)):s=!1}),!e&&s&&i<2*n){const e=[];for(const n in t)e[n]=t[n];return e}return e&&!this.getPriority().isEmpty()&&(t[".priority"]=this.getPriority().val()),t}hash(){if(null===this.lazyHash_){let e="";this.getPriority().isEmpty()||(e+="priority:"+Gt(this.getPriority().val())+":"),this.forEachChild(rn,(t,n)=>{const i=n.hash();""!==i&&(e+=":"+t+":"+i)}),this.lazyHash_=""===e?"":m(e)}return this.lazyHash_}getPredecessorChildName(e,t,n){const i=this.resolveIndex_(n);if(i){const n=i.getPredecessorKey(new Ft(e,t));return n?n.name:null}return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const e=t.minKey();return e&&e.name}return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new Ft(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const e=t.maxKey();return e&&e.name}return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new Ft(t,this.children_.get(t)):null}forEachChild(e,t){const n=this.resolveIndex_(e);return n?n.inorderTraversal(e=>t(e.name,e.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const n=this.resolveIndex_(t);if(n)return n.getIteratorFrom(e,e=>e);{const n=this.children_.getIteratorFrom(e.name,Ft.Wrap);let i=n.peek();for(;null!=i&&t.compare(i,e)<0;)n.getNext(),i=n.peek();return n}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const n=this.resolveIndex_(t);if(n)return n.getReverseIteratorFrom(e,e=>e);{const n=this.children_.getReverseIteratorFrom(e.name,Ft.Wrap);let i=n.peek();for(;null!=i&&t.compare(i,e)>0;)n.getNext(),i=n.peek();return n}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===fn?-1:0}withIndex(e){if(e===Ut||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new _n(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===Ut||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const t=e;if(this.getPriority().equals(t.getPriority())){if(this.children_.count()===t.children_.count()){const e=this.getIterator(rn),n=t.getIterator(rn);let i=e.getNext(),s=n.getNext();for(;i&&s;){if(i.name!==s.name||!i.node.equals(s.node))return!1;i=e.getNext(),s=n.getNext()}return null===i&&null===s}return!1}return!1}}resolveIndex_(e){return e===Ut?null:this.indexMap_.get(e.toString())}}_n.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class pn extends _n{constructor(){super(new Vt(Yt),_n.EMPTY_NODE,un.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return _n.EMPTY_NODE}isEmpty(){return!1}}const fn=new pn;Object.defineProperties(Ft,{MIN:{value:new Ft(P,_n.EMPTY_NODE)},MAX:{value:new Ft(N,fn)}}),Wt.__EMPTY_NODE=_n.EMPTY_NODE,en.__childrenNodeConstructor=_n,Kt(fn),nn(fn);const mn=!0;function gn(e,t=null){if(null===e)return _n.EMPTY_NODE;if("object"==typeof e&&".priority"in e&&(t=e[".priority"]),(0,i.assert)(null===t||"string"==typeof t||"number"==typeof t||"object"==typeof t&&".sv"in t,"Invalid priority type found: "+typeof t),"object"==typeof e&&".value"in e&&null!==e[".value"]&&(e=e[".value"]),"object"!=typeof e||".sv"in e){return new en(e,gn(t))}if(e instanceof Array||!mn){let n=_n.EMPTY_NODE;return F(e,(t,s)=>{if((0,i.contains)(e,t)&&"."!==t.substring(0,1)){const e=gn(s);!e.isLeafNode()&&e.isEmpty()||(n=n.updateImmediateChild(t,e))}}),n.updatePriority(gn(t))}{const n=[];let i=!1;if(F(e,(e,t)=>{if("."!==e.substring(0,1)){const s=gn(t);s.isEmpty()||(i=i||!s.getPriority().isEmpty(),n.push(new Ft(e,s)))}}),0===n.length)return _n.EMPTY_NODE;const s=ln(n,zt,e=>e.name,Yt);if(i){const e=ln(n,rn.getCompare());return new _n(s,gn(t),new un({".priority":e},{".priority":rn}))}return new _n(s,gn(t),un.Default)}}tn(gn);class yn extends Lt{constructor(e){super(),this.indexPath_=e,(0,i.assert)(!gt(e)&&".priority"!==ht(e),"Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const n=this.extractChild(e.node),i=this.extractChild(t.node),s=n.compareTo(i);return 0===s?R(e.name,t.name):s}makePost(e,t){const n=gn(e),i=_n.EMPTY_NODE.updateChild(this.indexPath_,n);return new Ft(t,i)}maxPost(){const e=_n.EMPTY_NODE.updateChild(this.indexPath_,fn);return new Ft(N,e)}toString(){return pt(this.indexPath_,0).join("/")}}class vn extends Lt{compare(e,t){const n=e.node.compareTo(t.node);return 0===n?R(e.name,t.name):n}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return Ft.MIN}maxPost(){return Ft.MAX}makePost(e,t){const n=gn(e);return new Ft(t,n)}toString(){return".value"}}const Cn=new vn;function wn(e){return{type:"value",snapshotNode:e}}function Tn(e,t){return{type:"child_added",snapshotNode:t,childName:e}}function In(e,t){return{type:"child_removed",snapshotNode:t,childName:e}}function bn(e,t,n){return{type:"child_changed",snapshotNode:t,childName:e,oldSnap:n}}function kn(e,t){return{type:"child_moved",snapshotNode:t,childName:e}}class En{constructor(e){this.index_=e}updateChild(e,t,n,s,r,o){(0,i.assert)(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const a=e.getImmediateChild(t);return a.getChild(s).equals(n.getChild(s))&&a.isEmpty()===n.isEmpty()?e:(null!=o&&(n.isEmpty()?e.hasChild(t)?o.trackChildChange(In(t,a)):(0,i.assert)(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(Tn(t,n)):o.trackChildChange(bn(t,n,a))),e.isLeafNode()&&n.isEmpty()?e:e.updateImmediateChild(t,n).withIndex(this.index_))}updateFullNode(e,t,n){return null!=n&&(e.isLeafNode()||e.forEachChild(rn,(e,i)=>{t.hasChild(e)||n.trackChildChange(In(e,i))}),t.isLeafNode()||t.forEachChild(rn,(t,i)=>{if(e.hasChild(t)){const s=e.getImmediateChild(t);s.equals(i)||n.trackChildChange(bn(t,i,s))}else n.trackChildChange(Tn(t,i))})),t.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?_n.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}class Sn{constructor(e){this.indexedFilter_=new En(e.getIndex()),this.index_=e.getIndex(),this.startPost_=Sn.getStartPost_(e),this.endPost_=Sn.getEndPost_(e),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){const t=this.startIsInclusive_?this.index_.compare(this.getStartPost(),e)<=0:this.index_.compare(this.getStartPost(),e)<0,n=this.endIsInclusive_?this.index_.compare(e,this.getEndPost())<=0:this.index_.compare(e,this.getEndPost())<0;return t&&n}updateChild(e,t,n,i,s,r){return this.matches(new Ft(t,n))||(n=_n.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,n,i,s,r)}updateFullNode(e,t,n){t.isLeafNode()&&(t=_n.EMPTY_NODE);let i=t.withIndex(this.index_);i=i.updatePriority(_n.EMPTY_NODE);const s=this;return t.forEachChild(rn,(e,t)=>{s.matches(new Ft(e,t))||(i=i.updateImmediateChild(e,_n.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,i,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){if(e.hasStart()){const t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){const t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}return e.getIndex().maxPost()}}class xn{constructor(e){this.withinDirectionalStart=(e=>this.reverse_?this.withinEndPost(e):this.withinStartPost(e)),this.withinDirectionalEnd=(e=>this.reverse_?this.withinStartPost(e):this.withinEndPost(e)),this.withinStartPost=(e=>{const t=this.index_.compare(this.rangedFilter_.getStartPost(),e);return this.startIsInclusive_?t<=0:t<0}),this.withinEndPost=(e=>{const t=this.index_.compare(e,this.rangedFilter_.getEndPost());return this.endIsInclusive_?t<=0:t<0}),this.rangedFilter_=new Sn(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft(),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}updateChild(e,t,n,i,s,r){return this.rangedFilter_.matches(new Ft(t,n))||(n=_n.EMPTY_NODE),e.getImmediateChild(t).equals(n)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,n,i,s,r):this.fullLimitUpdateChild_(e,t,n,s,r)}updateFullNode(e,t,n){let i;if(t.isLeafNode()||t.isEmpty())i=_n.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<t.numChildren()&&t.isIndexed(this.index_)){let e;i=_n.EMPTY_NODE.withIndex(this.index_),e=this.reverse_?t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let n=0;for(;e.hasNext()&&n<this.limit_;){const t=e.getNext();if(this.withinDirectionalStart(t)){if(!this.withinDirectionalEnd(t))break;i=i.updateImmediateChild(t.name,t.node),n++}}}else{let e;i=(i=t.withIndex(this.index_)).updatePriority(_n.EMPTY_NODE),e=this.reverse_?i.getReverseIterator(this.index_):i.getIterator(this.index_);let n=0;for(;e.hasNext();){const t=e.getNext();n<this.limit_&&this.withinDirectionalStart(t)&&this.withinDirectionalEnd(t)?n++:i=i.updateImmediateChild(t.name,_n.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,i,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,n,s,r){let o;if(this.reverse_){const e=this.index_.getCompare();o=((t,n)=>e(n,t))}else o=this.index_.getCompare();const a=e;(0,i.assert)(a.numChildren()===this.limit_,"");const l=new Ft(t,n),h=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),c=this.rangedFilter_.matches(l);if(a.hasChild(t)){const e=a.getImmediateChild(t);let i=s.getChildAfterChild(this.index_,h,this.reverse_);for(;null!=i&&(i.name===t||a.hasChild(i.name));)i=s.getChildAfterChild(this.index_,i,this.reverse_);const u=null==i?1:o(i,l);if(c&&!n.isEmpty()&&u>=0)return null!=r&&r.trackChildChange(bn(t,n,e)),a.updateImmediateChild(t,n);{null!=r&&r.trackChildChange(In(t,e));const n=a.updateImmediateChild(t,_n.EMPTY_NODE);return null!=i&&this.rangedFilter_.matches(i)?(null!=r&&r.trackChildChange(Tn(i.name,i.node)),n.updateImmediateChild(i.name,i.node)):n}}return n.isEmpty()?e:c&&o(h,l)>=0?(null!=r&&(r.trackChildChange(In(h.name,h.node)),r.trackChildChange(Tn(t,n))),a.updateImmediateChild(t,n).updateImmediateChild(h.name,_n.EMPTY_NODE)):e}}class Pn{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=rn}hasStart(){return this.startSet_}isViewFromLeft(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_}getIndexStartValue(){return(0,i.assert)(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return(0,i.assert)(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:P}hasEnd(){return this.endSet_}getIndexEndValue(){return(0,i.assert)(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return(0,i.assert)(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:N}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&""!==this.viewFrom_}getLimit(){return(0,i.assert)(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===rn}copy(){const e=new Pn;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.startAfterSet_=this.startAfterSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.endBeforeSet_=this.endBeforeSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function Nn(e){return e.loadsAllData()?new En(e.getIndex()):e.hasLimit()?new xn(e):new Sn(e)}function Rn(e,t){const n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="l",n}function Dn(e,t){const n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="r",n}function An(e,t,n){const i=e.copy();return i.startSet_=!0,void 0===t&&(t=null),i.indexStartValue_=t,null!=n?(i.startNameSet_=!0,i.indexStartName_=n):(i.startNameSet_=!1,i.indexStartName_=""),i}function Mn(e,t,n){let i;return(i=e.index_===Ut||n?An(e,t,n):An(e,t,N)).startAfterSet_=!0,i}function qn(e,t,n){const i=e.copy();return i.endSet_=!0,void 0===t&&(t=null),i.indexEndValue_=t,void 0!==n?(i.endNameSet_=!0,i.indexEndName_=n):(i.endNameSet_=!1,i.indexEndName_=""),i}function Fn(e,t,n){let i;return(i=e.index_===Ut||n?qn(e,t,n):qn(e,t,P)).endBeforeSet_=!0,i}function Ln(e,t){const n=e.copy();return n.index_=t,n}function On(e){const t={};if(e.isDefault())return t;let n;if(e.index_===rn?n="$priority":e.index_===Cn?n="$value":e.index_===Ut?n="$key":((0,i.assert)(e.index_ instanceof yn,"Unrecognized index type!"),n=e.index_.toString()),t.orderBy=(0,i.stringify)(n),e.startSet_){const n=e.startAfterSet_?"startAfter":"startAt";t[n]=(0,i.stringify)(e.indexStartValue_),e.startNameSet_&&(t[n]+=","+(0,i.stringify)(e.indexStartName_))}if(e.endSet_){const n=e.endBeforeSet_?"endBefore":"endAt";t[n]=(0,i.stringify)(e.indexEndValue_),e.endNameSet_&&(t[n]+=","+(0,i.stringify)(e.indexEndName_))}return e.limitSet_&&(e.isViewFromLeft()?t.limitToFirst=e.limit_:t.limitToLast=e.limit_),t}function Wn(e){const t={};if(e.startSet_&&(t.sp=e.indexStartValue_,e.startNameSet_&&(t.sn=e.indexStartName_),t.sin=!e.startAfterSet_),e.endSet_&&(t.ep=e.indexEndValue_,e.endNameSet_&&(t.en=e.indexEndName_),t.ein=!e.endBeforeSet_),e.limitSet_){t.l=e.limit_;let n=e.viewFrom_;""===n&&(n=e.isViewFromLeft()?"l":"r"),t.vf=n}return e.index_!==rn&&(t.i=e.index_.toString()),t}exports._QueryParams=Pn;class Un extends nt{constructor(e,t,n,i){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=n,this.appCheckTokenProvider_=i,this.log_=T("p:rest:"),this.listens_={}}reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return void 0!==t?"tag$"+t:((0,i.assert)(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}listen(e,t,n,s){const r=e._path.toString();this.log_("Listen called for "+r+" "+e._queryIdentifier);const o=Un.getListenId_(e,n),a={};this.listens_[o]=a;const l=On(e._queryParams);this.restRequest_(r+".json",l,(e,t)=>{let l=t;if(404===e&&(l=null,e=null),null===e&&this.onDataUpdate_(r,l,!1,n),(0,i.safeGet)(this.listens_,o)===a){let t;s(t=e?401===e?"permission_denied":"rest_error:"+e:"ok",null)}})}unlisten(e,t){const n=Un.getListenId_(e,t);delete this.listens_[n]}get(e){const t=On(e._queryParams),n=e._path.toString(),s=new i.Deferred;return this.restRequest_(n+".json",t,(e,t)=>{let i=t;404===e&&(i=null,e=null),null===e?(this.onDataUpdate_(n,i,!1,null),s.resolve(i)):s.reject(new Error(i))}),s.promise}refreshAuthToken(e){}restRequest_(e,t={},n){return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([s,r])=>{s&&s.accessToken&&(t.auth=s.accessToken),r&&r.token&&(t.ac=r.token);const o=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+(0,i.querystring)(t);this.log_("Sending REST request for "+o);const a=new XMLHttpRequest;a.onreadystatechange=(()=>{if(n&&4===a.readyState){this.log_("REST Response for "+o+" received. status:",a.status,"response:",a.responseText);let t=null;if(a.status>=200&&a.status<300){try{t=(0,i.jsonEval)(a.responseText)}catch(e){k("Failed to parse JSON response for "+o+": "+a.responseText)}n(null,t)}else 401!==a.status&&404!==a.status&&k("Got unsuccessful REST response for "+o+" Status: "+a.status),n(a.status);n=null}}),a.open("GET",o,!0),a.send()})}}class Bn{constructor(){this.rootNode_=_n.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}function jn(){return{value:null,children:new Map}}function Hn(e,t,n){if(gt(t))e.value=n,e.children.clear();else if(null!==e.value)e.value=e.value.updateChild(t,n);else{const i=ht(t);e.children.has(i)||e.children.set(i,jn()),Hn(e.children.get(i),t=ut(t),n)}}function Vn(e,t){if(gt(t))return e.value=null,e.children.clear(),!0;if(null!==e.value){if(e.value.isLeafNode())return!1;{const n=e.value;return e.value=null,n.forEachChild(rn,(t,n)=>{Hn(e,new at(t),n)}),Vn(e,t)}}if(e.children.size>0){const n=ht(t);if(t=ut(t),e.children.has(n)){Vn(e.children.get(n),t)&&e.children.delete(n)}return 0===e.children.size}return!0}function zn(e,t,n){null!==e.value?n(t,e.value):Yn(e,(e,i)=>{zn(i,new at(t.toString()+"/"+e),n)})}function Yn(e,t){e.children.forEach((e,n)=>{t(n,e)})}class Qn{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t=Object.assign({},e);return this.last_&&F(this.last_,(e,n)=>{t[e]=t[e]-n}),this.last_=e,t}}const Kn=1e4,Gn=3e4,$n=3e5;class Xn{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new Qn(e);const n=Kn+(Gn-Kn)*Math.random();Q(this.reportStats_.bind(this),Math.floor(n))}reportStats_(){const e=this.statsListener_.get(),t={};let n=!1;F(e,(e,s)=>{s>0&&(0,i.contains)(this.statsToReport_,e)&&(t[e]=s,n=!0)}),n&&this.server_.reportStats(t),Q(this.reportStats_.bind(this),Math.floor(2*Math.random()*$n))}}var Jn;function Zn(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function ei(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function ti(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}!function(e){e[e.OVERWRITE=0]="OVERWRITE",e[e.MERGE=1]="MERGE",e[e.ACK_USER_WRITE=2]="ACK_USER_WRITE",e[e.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(Jn||(Jn={}));class ni{constructor(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=Jn.ACK_USER_WRITE,this.source=Zn()}operationForChild(e){if(gt(this.path)){if(null!=this.affectedTree.value)return(0,i.assert)(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new at(e));return new ni(lt(),t,this.revert)}}return(0,i.assert)(ht(this.path)===e,"operationForChild called for unrelated child."),new ni(ut(this.path),this.affectedTree,this.revert)}}class ii{constructor(e,t){this.source=e,this.path=t,this.type=Jn.LISTEN_COMPLETE}operationForChild(e){return gt(this.path)?new ii(this.source,lt()):new ii(this.source,ut(this.path))}}class si{constructor(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=Jn.OVERWRITE}operationForChild(e){return gt(this.path)?new si(this.source,lt(),this.snap.getImmediateChild(e)):new si(this.source,ut(this.path),this.snap)}}class ri{constructor(e,t,n){this.source=e,this.path=t,this.children=n,this.type=Jn.MERGE}operationForChild(e){if(gt(this.path)){const t=this.children.subtree(new at(e));return t.isEmpty()?null:t.value?new si(this.source,lt(),t.value):new ri(this.source,lt(),t)}return(0,i.assert)(ht(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new ri(this.source,ut(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class oi{constructor(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(gt(e))return this.isFullyInitialized()&&!this.filtered_;const t=ht(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}class ai{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function li(e,t,n,i){const s=[],r=[];return t.forEach(t=>{"child_changed"===t.type&&e.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&&r.push(kn(t.childName,t.snapshotNode))}),hi(e,s,"child_removed",t,i,n),hi(e,s,"child_added",t,i,n),hi(e,s,"child_moved",r,i,n),hi(e,s,"child_changed",t,i,n),hi(e,s,"value",t,i,n),s}function hi(e,t,n,i,s,r){const o=i.filter(e=>e.type===n);o.sort((t,n)=>ui(e,t,n)),o.forEach(n=>{const i=ci(e,n,r);s.forEach(s=>{s.respondsTo(n.type)&&t.push(s.createEvent(i,e.query_))})})}function ci(e,t,n){return"value"===t.type||"child_removed"===t.type?t:(t.prevName=n.getPredecessorChildName(t.childName,t.snapshotNode,e.index_),t)}function ui(e,t,n){if(null==t.childName||null==n.childName)throw(0,i.assertionError)("Should only compare child_ events.");const s=new Ft(t.childName,t.snapshotNode),r=new Ft(n.childName,n.snapshotNode);return e.index_.compare(s,r)}function di(e,t){return{eventCache:e,serverCache:t}}function _i(e,t,n,i){return di(new oi(t,n,i),e.serverCache)}function pi(e,t,n,i){return di(e.eventCache,new oi(t,n,i))}function fi(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function mi(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}let gi;const yi=()=>(gi||(gi=new Vt(D)),gi);class vi{constructor(e,t=yi()){this.value=e,this.children=t}static fromObject(e){let t=new vi(null);return F(e,(e,n)=>{t=t.set(new at(e),n)}),t}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(null!=this.value&&t(this.value))return{path:lt(),value:this.value};if(gt(e))return null;{const n=ht(e),i=this.children.get(n);if(null!==i){const s=i.findRootMostMatchingPathAndValue(ut(e),t);if(null!=s){return{path:mt(new at(n),s.path),value:s.value}}return null}return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(gt(e))return this;{const t=ht(e),n=this.children.get(t);return null!==n?n.subtree(ut(e)):new vi(null)}}set(e,t){if(gt(e))return new vi(t,this.children);{const n=ht(e),i=(this.children.get(n)||new vi(null)).set(ut(e),t),s=this.children.insert(n,i);return new vi(this.value,s)}}remove(e){if(gt(e))return this.children.isEmpty()?new vi(null):new vi(null,this.children);{const t=ht(e),n=this.children.get(t);if(n){const i=n.remove(ut(e));let s;return s=i.isEmpty()?this.children.remove(t):this.children.insert(t,i),null===this.value&&s.isEmpty()?new vi(null):new vi(this.value,s)}return this}}get(e){if(gt(e))return this.value;{const t=ht(e),n=this.children.get(t);return n?n.get(ut(e)):null}}setTree(e,t){if(gt(e))return t;{const n=ht(e),i=(this.children.get(n)||new vi(null)).setTree(ut(e),t);let s;return s=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),new vi(this.value,s)}}fold(e){return this.fold_(lt(),e)}fold_(e,t){const n={};return this.children.inorderTraversal((i,s)=>{n[i]=s.fold_(mt(e,i),t)}),t(e,this.value,n)}findOnPath(e,t){return this.findOnPath_(e,lt(),t)}findOnPath_(e,t,n){const i=!!this.value&&n(t,this.value);if(i)return i;if(gt(e))return null;{const i=ht(e),s=this.children.get(i);return s?s.findOnPath_(ut(e),mt(t,i),n):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,lt(),t)}foreachOnPath_(e,t,n){if(gt(e))return this;{this.value&&n(t,this.value);const i=ht(e),s=this.children.get(i);return s?s.foreachOnPath_(ut(e),mt(t,i),n):new vi(null)}}foreach(e){this.foreach_(lt(),e)}foreach_(e,t){this.children.inorderTraversal((n,i)=>{i.foreach_(mt(e,n),t)}),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal((t,n)=>{n.value&&e(t,n.value)})}}class Ci{constructor(e){this.writeTree_=e}static empty(){return new Ci(new vi(null))}}function wi(e,t,n){if(gt(t))return new Ci(new vi(n));{const i=e.writeTree_.findRootMostValueAndPath(t);if(null!=i){const s=i.path;let r=i.value;const o=yt(s,t);return r=r.updateChild(o,n),new Ci(e.writeTree_.set(s,r))}{const i=new vi(n),s=e.writeTree_.setTree(t,i);return new Ci(s)}}}function Ti(e,t,n){let i=e;return F(n,(e,n)=>{i=wi(i,mt(t,e),n)}),i}function Ii(e,t){if(gt(t))return Ci.empty();{const n=e.writeTree_.setTree(t,new vi(null));return new Ci(n)}}function bi(e,t){return null!=ki(e,t)}function ki(e,t){const n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(yt(n.path,t)):null}function Ei(e){const t=[],n=e.writeTree_.value;return null!=n?n.isLeafNode()||n.forEachChild(rn,(e,n)=>{t.push(new Ft(e,n))}):e.writeTree_.children.inorderTraversal((e,n)=>{null!=n.value&&t.push(new Ft(e,n.value))}),t}function Si(e,t){if(gt(t))return e;{const n=ki(e,t);return new Ci(null!=n?new vi(n):e.writeTree_.subtree(t))}}function xi(e){return e.writeTree_.isEmpty()}function Pi(e,t){return Ni(lt(),e.writeTree_,t)}function Ni(e,t,n){if(null!=t.value)return n.updateChild(e,t.value);{let s=null;return t.children.inorderTraversal((t,r)=>{".priority"===t?((0,i.assert)(null!==r.value,"Priority writes must always be leaf nodes"),s=r.value):n=Ni(mt(e,t),r,n)}),n.getChild(e).isEmpty()||null===s||(n=n.updateChild(mt(e,".priority"),s)),n}}function Ri(e,t){return es(t,e)}function Di(e,t,n,s,r){(0,i.assert)(s>e.lastWriteId,"Stacking an older write on top of newer ones"),void 0===r&&(r=!0),e.allWrites.push({path:t,snap:n,writeId:s,visible:r}),r&&(e.visibleWrites=wi(e.visibleWrites,t,n)),e.lastWriteId=s}function Ai(e,t,n,s){(0,i.assert)(s>e.lastWriteId,"Stacking an older merge on top of newer ones"),e.allWrites.push({path:t,children:n,writeId:s,visible:!0}),e.visibleWrites=Ti(e.visibleWrites,t,n),e.lastWriteId=s}function Mi(e,t){for(let n=0;n<e.allWrites.length;n++){const i=e.allWrites[n];if(i.writeId===t)return i}return null}function qi(e,t){const n=e.allWrites.findIndex(e=>e.writeId===t);(0,i.assert)(n>=0,"removeWrite called with nonexistent writeId.");const s=e.allWrites[n];e.allWrites.splice(n,1);let r=s.visible,o=!1,a=e.allWrites.length-1;for(;r&&a>=0;){const t=e.allWrites[a];t.visible&&(a>=n&&Fi(t,s.path)?r=!1:wt(s.path,t.path)&&(o=!0)),a--}if(r){if(o)return Li(e),!0;if(s.snap)e.visibleWrites=Ii(e.visibleWrites,s.path);else{F(s.children,t=>{e.visibleWrites=Ii(e.visibleWrites,mt(s.path,t))})}return!0}return!1}function Fi(e,t){if(e.snap)return wt(e.path,t);for(const n in e.children)if(e.children.hasOwnProperty(n)&&wt(mt(e.path,n),t))return!0;return!1}function Li(e){e.visibleWrites=Wi(e.allWrites,Oi,lt()),e.allWrites.length>0?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1}function Oi(e){return e.visible}function Wi(e,t,n){let s=Ci.empty();for(let r=0;r<e.length;++r){const o=e[r];if(t(o)){const e=o.path;let t;if(o.snap)wt(n,e)?s=wi(s,t=yt(n,e),o.snap):wt(e,n)&&(t=yt(e,n),s=wi(s,lt(),o.snap.getChild(t)));else{if(!o.children)throw(0,i.assertionError)("WriteRecord should have .snap or .children");if(wt(n,e))s=Ti(s,t=yt(n,e),o.children);else if(wt(e,n))if(gt(t=yt(e,n)))s=Ti(s,lt(),o.children);else{const e=(0,i.safeGet)(o.children,ht(t));if(e){const n=e.getChild(ut(t));s=wi(s,lt(),n)}}}}}return s}function Ui(e,t,n,i,s){if(i||s){const r=Si(e.visibleWrites,t);if(!s&&xi(r))return n;if(s||null!=n||bi(r,lt())){const r=function(e){return(e.visible||s)&&(!i||!~i.indexOf(e.writeId))&&(wt(e.path,t)||wt(t,e.path))};return Pi(Wi(e.allWrites,r,t),n||_n.EMPTY_NODE)}return null}{const i=ki(e.visibleWrites,t);if(null!=i)return i;{const i=Si(e.visibleWrites,t);if(xi(i))return n;if(null!=n||bi(i,lt())){return Pi(i,n||_n.EMPTY_NODE)}return null}}}function Bi(e,t,n){let i=_n.EMPTY_NODE;const s=ki(e.visibleWrites,t);if(s)return s.isLeafNode()||s.forEachChild(rn,(e,t)=>{i=i.updateImmediateChild(e,t)}),i;if(n){const s=Si(e.visibleWrites,t);return n.forEachChild(rn,(e,t)=>{const n=Pi(Si(s,new at(e)),t);i=i.updateImmediateChild(e,n)}),Ei(s).forEach(e=>{i=i.updateImmediateChild(e.name,e.node)}),i}return Ei(Si(e.visibleWrites,t)).forEach(e=>{i=i.updateImmediateChild(e.name,e.node)}),i}function ji(e,t,n,s,r){(0,i.assert)(s||r,"Either existingEventSnap or existingServerSnap must exist");const o=mt(t,n);if(bi(e.visibleWrites,o))return null;{const t=Si(e.visibleWrites,o);return xi(t)?r.getChild(n):Pi(t,r.getChild(n))}}function Hi(e,t,n,i){const s=mt(t,n),r=ki(e.visibleWrites,s);if(null!=r)return r;if(i.isCompleteForChild(n)){return Pi(Si(e.visibleWrites,s),i.getNode().getImmediateChild(n))}return null}function Vi(e,t){return ki(e.visibleWrites,t)}function zi(e,t,n,i,s,r,o){let a;const l=Si(e.visibleWrites,t),h=ki(l,lt());if(null!=h)a=h;else{if(null==n)return[];a=Pi(l,n)}if((a=a.withIndex(o)).isEmpty()||a.isLeafNode())return[];{const e=[],t=o.getCompare(),n=r?a.getReverseIteratorFrom(i,o):a.getIteratorFrom(i,o);let l=n.getNext();for(;l&&e.length<s;)0!==t(l,i)&&e.push(l),l=n.getNext();return e}}function Yi(){return{visibleWrites:Ci.empty(),allWrites:[],lastWriteId:-1}}function Qi(e,t,n,i){return Ui(e.writeTree,e.treePath,t,n,i)}function Ki(e,t){return Bi(e.writeTree,e.treePath,t)}function Gi(e,t,n,i){return ji(e.writeTree,e.treePath,t,n,i)}function $i(e,t){return Vi(e.writeTree,mt(e.treePath,t))}function Xi(e,t,n,i,s,r){return zi(e.writeTree,e.treePath,t,n,i,s,r)}function Ji(e,t,n){return Hi(e.writeTree,e.treePath,t,n)}function Zi(e,t){return es(mt(e.treePath,t),e.writeTree)}function es(e,t){return{treePath:e,writeTree:t}}class ts{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,n=e.childName;(0,i.assert)("child_added"===t||"child_changed"===t||"child_removed"===t,"Only child changes supported for tracking"),(0,i.assert)(".priority"!==n,"Only non-priority child changes can be tracked.");const s=this.changeMap.get(n);if(s){const r=s.type;if("child_added"===t&&"child_removed"===r)this.changeMap.set(n,bn(n,e.snapshotNode,s.snapshotNode));else if("child_removed"===t&&"child_added"===r)this.changeMap.delete(n);else if("child_removed"===t&&"child_changed"===r)this.changeMap.set(n,In(n,s.oldSnap));else if("child_changed"===t&&"child_added"===r)this.changeMap.set(n,Tn(n,e.snapshotNode));else{if("child_changed"!==t||"child_changed"!==r)throw(0,i.assertionError)("Illegal combination of changes: "+e+" occurred after "+s);this.changeMap.set(n,bn(n,e.snapshotNode,s.oldSnap))}}else this.changeMap.set(n,e)}getChanges(){return Array.from(this.changeMap.values())}}class ns{getCompleteChild(e){return null}getChildAfterChild(e,t,n){return null}}const is=new ns;class ss{constructor(e,t,n=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=n}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const t=null!=this.optCompleteServerCache_?new oi(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return Ji(this.writes_,e,t)}}getChildAfterChild(e,t,n){const i=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:mi(this.viewCache_),s=Xi(this.writes_,i,t,1,n,e);return 0===s.length?null:s[0]}}function rs(e){return{filter:e}}function os(e,t){(0,i.assert)(t.eventCache.getNode().isIndexed(e.filter.getIndex()),"Event snap not indexed"),(0,i.assert)(t.serverCache.getNode().isIndexed(e.filter.getIndex()),"Server snap not indexed")}function as(e,t,n,s,r){const o=new ts;let a,l;if(n.type===Jn.OVERWRITE){const h=n;h.source.fromUser?a=us(e,t,h.path,h.snap,s,r,o):((0,i.assert)(h.source.fromServer,"Unknown source."),l=h.source.tagged||t.serverCache.isFiltered()&&!gt(h.path),a=cs(e,t,h.path,h.snap,s,r,l,o))}else if(n.type===Jn.MERGE){const h=n;h.source.fromUser?a=_s(e,t,h.path,h.children,s,r,o):((0,i.assert)(h.source.fromServer,"Unknown source."),l=h.source.tagged||t.serverCache.isFiltered(),a=fs(e,t,h.path,h.children,s,r,l,o))}else if(n.type===Jn.ACK_USER_WRITE){const i=n;a=i.revert?ys(e,t,i.path,s,r,o):ms(e,t,i.path,i.affectedTree,s,r,o)}else{if(n.type!==Jn.LISTEN_COMPLETE)throw(0,i.assertionError)("Unknown operation type: "+n.type);a=gs(e,t,n.path,s,o)}const h=o.getChanges();return ls(t,a,h),{viewCache:a,changes:h}}function ls(e,t,n){const i=t.eventCache;if(i.isFullyInitialized()){const s=i.getNode().isLeafNode()||i.getNode().isEmpty(),r=fi(e);(n.length>0||!e.eventCache.isFullyInitialized()||s&&!i.getNode().equals(r)||!i.getNode().getPriority().equals(r.getPriority()))&&n.push(wn(fi(t)))}}function hs(e,t,n,s,r,o){const a=t.eventCache;if(null!=$i(s,n))return t;{let l,h;if(gt(n))if((0,i.assert)(t.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t.serverCache.isFiltered()){const n=mi(t),i=Ki(s,n instanceof _n?n:_n.EMPTY_NODE);l=e.filter.updateFullNode(t.eventCache.getNode(),i,o)}else{const n=Qi(s,mi(t));l=e.filter.updateFullNode(t.eventCache.getNode(),n,o)}else{const c=ht(n);if(".priority"===c){(0,i.assert)(1===ct(n),"Can't have a priority with additional path components");const r=a.getNode(),o=Gi(s,n,r,h=t.serverCache.getNode());l=null!=o?e.filter.updatePriority(r,o):a.getNode()}else{const i=ut(n);let u;if(a.isCompleteForChild(c)){h=t.serverCache.getNode();const e=Gi(s,n,a.getNode(),h);u=null!=e?a.getNode().getImmediateChild(c).updateChild(i,e):a.getNode().getImmediateChild(c)}else u=Ji(s,c,t.serverCache);l=null!=u?e.filter.updateChild(a.getNode(),c,u,i,r,o):a.getNode()}}return _i(t,l,a.isFullyInitialized()||gt(n),e.filter.filtersNodes())}}function cs(e,t,n,i,s,r,o,a){const l=t.serverCache;let h;const c=o?e.filter:e.filter.getIndexedFilter();if(gt(n))h=c.updateFullNode(l.getNode(),i,null);else if(c.filtersNodes()&&!l.isFiltered()){const e=l.getNode().updateChild(n,i);h=c.updateFullNode(l.getNode(),e,null)}else{const e=ht(n);if(!l.isCompleteForPath(n)&&ct(n)>1)return t;const s=ut(n),r=l.getNode().getImmediateChild(e).updateChild(s,i);h=".priority"===e?c.updatePriority(l.getNode(),r):c.updateChild(l.getNode(),e,r,s,is,null)}const u=pi(t,h,l.isFullyInitialized()||gt(n),c.filtersNodes());return hs(e,u,n,s,new ss(s,u,r),a)}function us(e,t,n,i,s,r,o){const a=t.eventCache;let l,h;const c=new ss(s,t,r);if(gt(n))h=e.filter.updateFullNode(t.eventCache.getNode(),i,o),l=_i(t,h,!0,e.filter.filtersNodes());else{const s=ht(n);if(".priority"===s)h=e.filter.updatePriority(t.eventCache.getNode(),i),l=_i(t,h,a.isFullyInitialized(),a.isFiltered());else{const r=ut(n),h=a.getNode().getImmediateChild(s);let u;if(gt(r))u=i;else{const e=c.getCompleteChild(s);u=null!=e?".priority"===dt(r)&&e.getChild(ft(r)).isEmpty()?e:e.updateChild(r,i):_n.EMPTY_NODE}if(h.equals(u))l=t;else{l=_i(t,e.filter.updateChild(a.getNode(),s,u,r,c,o),a.isFullyInitialized(),e.filter.filtersNodes())}}}return l}function ds(e,t){return e.eventCache.isCompleteForChild(t)}function _s(e,t,n,i,s,r,o){let a=t;return i.foreach((i,l)=>{const h=mt(n,i);ds(t,ht(h))&&(a=us(e,a,h,l,s,r,o))}),i.foreach((i,l)=>{const h=mt(n,i);ds(t,ht(h))||(a=us(e,a,h,l,s,r,o))}),a}function ps(e,t,n){return n.foreach((e,n)=>{t=t.updateChild(e,n)}),t}function fs(e,t,n,i,s,r,o,a){if(t.serverCache.getNode().isEmpty()&&!t.serverCache.isFullyInitialized())return t;let l,h=t;l=gt(n)?i:new vi(null).setTree(n,i);const c=t.serverCache.getNode();return l.children.inorderTraversal((n,i)=>{if(c.hasChild(n)){const l=t.serverCache.getNode().getImmediateChild(n),c=ps(e,l,i);h=cs(e,h,new at(n),c,s,r,o,a)}}),l.children.inorderTraversal((n,i)=>{const l=!t.serverCache.isCompleteForChild(n)&&null===i.value;if(!c.hasChild(n)&&!l){const l=t.serverCache.getNode().getImmediateChild(n),c=ps(e,l,i);h=cs(e,h,new at(n),c,s,r,o,a)}}),h}function ms(e,t,n,i,s,r,o){if(null!=$i(s,n))return t;const a=t.serverCache.isFiltered(),l=t.serverCache;if(null!=i.value){if(gt(n)&&l.isFullyInitialized()||l.isCompleteForPath(n))return cs(e,t,n,l.getNode().getChild(n),s,r,a,o);if(gt(n)){let i=new vi(null);return l.getNode().forEachChild(Ut,(e,t)=>{i=i.set(new at(e),t)}),fs(e,t,n,i,s,r,a,o)}return t}{let h=new vi(null);return i.foreach((e,t)=>{const i=mt(n,e);l.isCompleteForPath(i)&&(h=h.set(e,l.getNode().getChild(i)))}),fs(e,t,n,h,s,r,a,o)}}function gs(e,t,n,i,s){const r=t.serverCache;return hs(e,pi(t,r.getNode(),r.isFullyInitialized()||gt(n),r.isFiltered()),n,i,is,s)}function ys(e,t,n,s,r,o){let a;if(null!=$i(s,n))return t;{const l=new ss(s,t,r),h=t.eventCache.getNode();let c;if(gt(n)||".priority"===ht(n)){let n;if(t.serverCache.isFullyInitialized())n=Qi(s,mi(t));else{const e=t.serverCache.getNode();(0,i.assert)(e instanceof _n,"serverChildren would be complete if leaf node"),n=Ki(s,e)}n=n,c=e.filter.updateFullNode(h,n,o)}else{const i=ht(n);let r=Ji(s,i,t.serverCache);null==r&&t.serverCache.isCompleteForChild(i)&&(r=h.getImmediateChild(i)),(c=null!=r?e.filter.updateChild(h,i,r,ut(n),l,o):t.eventCache.getNode().hasChild(i)?e.filter.updateChild(h,i,_n.EMPTY_NODE,ut(n),l,o):h).isEmpty()&&t.serverCache.isFullyInitialized()&&(a=Qi(s,mi(t))).isLeafNode()&&(c=e.filter.updateFullNode(c,a,o))}return a=t.serverCache.isFullyInitialized()||null!=$i(s,lt()),_i(t,c,a,e.filter.filtersNodes())}}class vs{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const n=this.query_._queryParams,i=new En(n.getIndex()),s=Nn(n);this.processor_=rs(s);const r=t.serverCache,o=t.eventCache,a=i.updateFullNode(_n.EMPTY_NODE,r.getNode(),null),l=s.updateFullNode(_n.EMPTY_NODE,o.getNode(),null),h=new oi(a,r.isFullyInitialized(),i.filtersNodes()),c=new oi(l,o.isFullyInitialized(),s.filtersNodes());this.viewCache_=di(c,h),this.eventGenerator_=new ai(this.query_)}get query(){return this.query_}}function Cs(e){return e.viewCache_.serverCache.getNode()}function ws(e){return fi(e.viewCache_)}function Ts(e,t){const n=mi(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!gt(t)&&!n.getImmediateChild(ht(t)).isEmpty())?n.getChild(t):null}function Is(e){return 0===e.eventRegistrations_.length}function bs(e,t){e.eventRegistrations_.push(t)}function ks(e,t,n){const s=[];if(n){(0,i.assert)(null==t,"A cancel should cancel all event registrations.");const r=e.query._path;e.eventRegistrations_.forEach(e=>{const t=e.createCancelEvent(n,r);t&&s.push(t)})}if(t){let n=[];for(let i=0;i<e.eventRegistrations_.length;++i){const s=e.eventRegistrations_[i];if(s.matches(t)){if(t.hasAnyCallback()){n=n.concat(e.eventRegistrations_.slice(i+1));break}}else n.push(s)}e.eventRegistrations_=n}else e.eventRegistrations_=[];return s}function Es(e,t,n,s){t.type===Jn.MERGE&&null!==t.source.queryId&&((0,i.assert)(mi(e.viewCache_),"We should always have a full cache before handling merges"),(0,i.assert)(fi(e.viewCache_),"Missing event cache, even though we have a server cache"));const r=e.viewCache_,o=as(e.processor_,r,t,n,s);return os(e.processor_,o.viewCache),(0,i.assert)(o.viewCache.serverCache.isFullyInitialized()||!r.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),e.viewCache_=o.viewCache,xs(e,o.changes,o.viewCache.eventCache.getNode(),null)}function Ss(e,t){const n=e.viewCache_.eventCache,i=[];if(!n.getNode().isLeafNode()){n.getNode().forEachChild(rn,(e,t)=>{i.push(Tn(e,t))})}return n.isFullyInitialized()&&i.push(wn(n.getNode())),xs(e,i,n.getNode(),t)}function xs(e,t,n,i){const s=i?[i]:e.eventRegistrations_;return li(e.eventGenerator_,t,n,s)}let Ps,Ns;class Rs{constructor(){this.views=new Map}}function Ds(e){(0,i.assert)(!Ps,"__referenceConstructor has already been defined"),Ps=e}function As(){return(0,i.assert)(Ps,"Reference.ts has not been loaded"),Ps}function Ms(e){return 0===e.views.size}function qs(e,t,n,s){const r=t.source.queryId;if(null!==r){const o=e.views.get(r);return(0,i.assert)(null!=o,"SyncTree gave us an op for an invalid query."),Es(o,t,n,s)}{let i=[];for(const r of e.views.values())i=i.concat(Es(r,t,n,s));return i}}function Fs(e,t,n,i,s){const r=t._queryIdentifier,o=e.views.get(r);if(!o){let e=Qi(n,s?i:null),r=!1;e?r=!0:i instanceof _n?(e=Ki(n,i),r=!1):(e=_n.EMPTY_NODE,r=!1);const o=di(new oi(e,r,!1),new oi(i,s,!1));return new vs(t,o)}return o}function Ls(e,t,n,i,s,r){const o=Fs(e,t,i,s,r);return e.views.has(t._queryIdentifier)||e.views.set(t._queryIdentifier,o),bs(o,n),Ss(o,n)}function Os(e,t,n,i){const s=t._queryIdentifier,r=[];let o=[];const a=Hs(e);if("default"===s)for(const[l,h]of e.views.entries())o=o.concat(ks(h,n,i)),Is(h)&&(e.views.delete(l),h.query._queryParams.loadsAllData()||r.push(h.query));else{const t=e.views.get(s);t&&(o=o.concat(ks(t,n,i)),Is(t)&&(e.views.delete(s),t.query._queryParams.loadsAllData()||r.push(t.query)))}return a&&!Hs(e)&&r.push(new(As())(t._repo,t._path)),{removed:r,events:o}}function Ws(e){const t=[];for(const n of e.views.values())n.query._queryParams.loadsAllData()||t.push(n);return t}function Us(e,t){let n=null;for(const i of e.views.values())n=n||Ts(i,t);return n}function Bs(e,t){if(t._queryParams.loadsAllData())return Vs(e);{const n=t._queryIdentifier;return e.views.get(n)}}function js(e,t){return null!=Bs(e,t)}function Hs(e){return null!=Vs(e)}function Vs(e){for(const t of e.views.values())if(t.query._queryParams.loadsAllData())return t;return null}function zs(e){(0,i.assert)(!Ns,"__referenceConstructor has already been defined"),Ns=e}function Ys(){return(0,i.assert)(Ns,"Reference.ts has not been loaded"),Ns}let Qs=1;class Ks{constructor(e){this.listenProvider_=e,this.syncPointTree_=new vi(null),this.pendingWriteTree_=Yi(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function Gs(e,t,n,i,s){return Di(e.pendingWriteTree_,t,n,i,s),s?lr(e,new si(Zn(),t,n)):[]}function $s(e,t,n,i){Ai(e.pendingWriteTree_,t,n,i);const s=vi.fromObject(n);return lr(e,new ri(Zn(),t,s))}function Xs(e,t,n=!1){const i=Mi(e.pendingWriteTree_,t);if(qi(e.pendingWriteTree_,t)){let t=new vi(null);return null!=i.snap?t=t.set(lt(),!0):F(i.children,e=>{t=t.set(new at(e),!0)}),lr(e,new ni(i.path,t,n))}return[]}function Js(e,t,n){return lr(e,new si(ei(),t,n))}function Zs(e,t,n){const i=vi.fromObject(n);return lr(e,new ri(ei(),t,i))}function er(e,t){return lr(e,new ii(ei(),t))}function tr(e,t,n){const i=pr(e,n);if(i){const n=fr(i),s=n.path,r=n.queryId,o=yt(s,t);return mr(e,s,new ii(ti(r),o))}return[]}function nr(e,t,n,i,s=!1){const r=t._path,o=e.syncPointTree_.get(r);let a=[];if(o&&("default"===t._queryIdentifier||js(o,t))){const l=Os(o,t,n,i);Ms(o)&&(e.syncPointTree_=e.syncPointTree_.remove(r));const h=l.removed;if(a=l.events,!s){const n=-1!==h.findIndex(e=>e._queryParams.loadsAllData()),s=e.syncPointTree_.findOnPath(r,(e,t)=>Hs(t));if(n&&!s){const t=e.syncPointTree_.subtree(r);if(!t.isEmpty()){const n=gr(t);for(let t=0;t<n.length;++t){const i=n[t],s=i.query,r=ur(e,i);e.listenProvider_.startListening(yr(s),dr(e,s),r.hashFn,r.onComplete)}}}if(!s&&h.length>0&&!i)if(n){const n=null;e.listenProvider_.stopListening(yr(t),n)}else h.forEach(t=>{const n=e.queryToTagMap.get(_r(t));e.listenProvider_.stopListening(yr(t),n)})}vr(e,h)}return a}function ir(e,t,n,i){const s=pr(e,i);if(null!=s){const i=fr(s),r=i.path,o=i.queryId,a=yt(r,t);return mr(e,r,new si(ti(o),a,n))}return[]}function sr(e,t,n,i){const s=pr(e,i);if(s){const i=fr(s),r=i.path,o=i.queryId,a=yt(r,t),l=vi.fromObject(n);return mr(e,r,new ri(ti(o),a,l))}return[]}function rr(e,t,n,s=!1){const r=t._path;let o=null,a=!1;e.syncPointTree_.foreachOnPath(r,(e,t)=>{const n=yt(e,r);o=o||Us(t,n),a=a||Hs(t)});let l,h=e.syncPointTree_.get(r);if(h?(a=a||Hs(h),o=o||Us(h,lt())):(h=new Rs,e.syncPointTree_=e.syncPointTree_.set(r,h)),null!=o)l=!0;else{l=!1,o=_n.EMPTY_NODE,e.syncPointTree_.subtree(r).foreachChild((e,t)=>{const n=Us(t,lt());n&&(o=o.updateImmediateChild(e,n))})}const c=js(h,t);if(!c&&!t._queryParams.loadsAllData()){const n=_r(t);(0,i.assert)(!e.queryToTagMap.has(n),"View does not exist, but we have a tag");const s=Cr();e.queryToTagMap.set(n,s),e.tagToQueryMap.set(s,n)}let u=Ls(h,t,n,Ri(e.pendingWriteTree_,r),o,l);if(!c&&!a&&!s){const n=Bs(h,t);u=u.concat(wr(e,t,n))}return u}function or(e,t,n){const i=e.pendingWriteTree_,s=e.syncPointTree_.findOnPath(t,(e,n)=>{const i=Us(n,yt(e,t));if(i)return i});return Ui(i,t,s,n,!0)}function ar(e,t){const n=t._path;let i=null;e.syncPointTree_.foreachOnPath(n,(e,t)=>{const s=yt(e,n);i=i||Us(t,s)});let s=e.syncPointTree_.get(n);s?i=i||Us(s,lt()):(s=new Rs,e.syncPointTree_=e.syncPointTree_.set(n,s));const r=null!=i,o=r?new oi(i,!0,!1):null;return ws(Fs(s,t,Ri(e.pendingWriteTree_,t._path),r?o.getNode():_n.EMPTY_NODE,r))}function lr(e,t){return hr(t,e.syncPointTree_,null,Ri(e.pendingWriteTree_,lt()))}function hr(e,t,n,i){if(gt(e.path))return cr(e,t,n,i);{const s=t.get(lt());null==n&&null!=s&&(n=Us(s,lt()));let r=[];const o=ht(e.path),a=e.operationForChild(o),l=t.children.get(o);if(l&&a){const e=n?n.getImmediateChild(o):null,t=Zi(i,o);r=r.concat(hr(a,l,e,t))}return s&&(r=r.concat(qs(s,e,i,n))),r}}function cr(e,t,n,i){const s=t.get(lt());null==n&&null!=s&&(n=Us(s,lt()));let r=[];return t.children.inorderTraversal((t,s)=>{const o=n?n.getImmediateChild(t):null,a=Zi(i,t),l=e.operationForChild(t);l&&(r=r.concat(cr(l,s,o,a)))}),s&&(r=r.concat(qs(s,e,i,n))),r}function ur(e,t){const n=t.query,i=dr(e,n);return{hashFn:()=>{return(Cs(t)||_n.EMPTY_NODE).hash()},onComplete:t=>{if("ok"===t)return i?tr(e,n._path,i):er(e,n._path);{const i=U(t,n);return nr(e,n,null,i)}}}}function dr(e,t){const n=_r(t);return e.queryToTagMap.get(n)}function _r(e){return e._path.toString()+"$"+e._queryIdentifier}function pr(e,t){return e.tagToQueryMap.get(t)}function fr(e){const t=e.indexOf("$");return(0,i.assert)(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new at(e.substr(0,t))}}function mr(e,t,n){const s=e.syncPointTree_.get(t);return(0,i.assert)(s,"Missing sync point for query tag that we're tracking"),qs(s,n,Ri(e.pendingWriteTree_,t),null)}function gr(e){return e.fold((e,t,n)=>{if(t&&Hs(t)){return[Vs(t)]}{let e=[];return t&&(e=Ws(t)),F(n,(t,n)=>{e=e.concat(n)}),e}})}function yr(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?new(Ys())(e._repo,e._path):e}function vr(e,t){for(let n=0;n<t.length;++n){const i=t[n];if(!i._queryParams.loadsAllData()){const t=_r(i),n=e.queryToTagMap.get(t);e.queryToTagMap.delete(t),e.tagToQueryMap.delete(n)}}}function Cr(){return Qs++}function wr(e,t,n){const s=t._path,r=dr(e,t),o=ur(e,n),a=e.listenProvider_.startListening(yr(t),r,o.hashFn,o.onComplete),l=e.syncPointTree_.subtree(s);if(r)(0,i.assert)(!Hs(l.value),"If we're adding a query, it shouldn't be shadowed");else{const t=l.fold((e,t,n)=>{if(!gt(e)&&t&&Hs(t))return[Vs(t).query];{let e=[];return t&&(e=e.concat(Ws(t).map(e=>e.query))),F(n,(t,n)=>{e=e.concat(n)}),e}});for(let n=0;n<t.length;++n){const i=t[n];e.listenProvider_.stopListening(yr(i),dr(e,i))}}return a}class Tr{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new Tr(t)}node(){return this.node_}}class Ir{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=mt(this.path_,e);return new Ir(this.syncTree_,t)}node(){return or(this.syncTree_,this.path_)}}const br=function(e){return(e=e||{}).timestamp=e.timestamp||(new Date).getTime(),e},kr=function(e,t,n){return e&&"object"==typeof e?((0,i.assert)(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?Er(e[".sv"],t,n):"object"==typeof e[".sv"]?Sr(e[".sv"],t):void(0,i.assert)(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e},Er=function(e,t,n){switch(e){case"timestamp":return n.timestamp;default:(0,i.assert)(!1,"Unexpected server value: "+e)}},Sr=function(e,t,n){e.hasOwnProperty("increment")||(0,i.assert)(!1,"Unexpected server value: "+JSON.stringify(e,null,2));const s=e.increment;"number"!=typeof s&&(0,i.assert)(!1,"Unexpected increment value: "+s);const r=t.node();if((0,i.assert)(null!=r,"Expected ChildrenNode.EMPTY_NODE for nulls"),!r.isLeafNode())return s;const o=r.getValue();return"number"!=typeof o?s:o+s},xr=function(e,t,n,i){return Nr(t,new Ir(n,e),i)},Pr=function(e,t,n){return Nr(e,new Tr(t),n)};function Nr(e,t,n){const i=e.getPriority().val(),s=kr(i,t.getImmediateChild(".priority"),n);let r;if(e.isLeafNode()){const i=e,r=kr(i.getValue(),t,n);return r!==i.getValue()||s!==i.getPriority().val()?new en(r,gn(s)):e}{const i=e;return r=i,s!==i.getPriority().val()&&(r=r.updatePriority(new en(s))),i.forEachChild(rn,(e,i)=>{const s=Nr(i,t.getImmediateChild(e),n);s!==i&&(r=r.updateImmediateChild(e,s))}),r}}class Rr{constructor(e="",t=null,n={children:{},childCount:0}){this.name=e,this.parent=t,this.node=n}}function Dr(e,t){let n=t instanceof at?t:new at(t),s=e,r=ht(n);for(;null!==r;){const e=(0,i.safeGet)(s.node.children,r)||{children:{},childCount:0};s=new Rr(r,s,e),r=ht(n=ut(n))}return s}function Ar(e){return e.node.value}function Mr(e,t){e.node.value=t,Br(e)}function qr(e){return e.node.childCount>0}function Fr(e){return void 0===Ar(e)&&!qr(e)}function Lr(e,t){F(e.node.children,(n,i)=>{t(new Rr(n,e,i))})}function Or(e,t,n,i){n&&!i&&t(e),Lr(e,e=>{Or(e,t,!0,i)}),n&&i&&t(e)}function Wr(e,t,n){let i=n?e:e.parent;for(;null!==i;){if(t(i))return!0;i=i.parent}return!1}function Ur(e){return new at(null===e.parent?e.name:Ur(e.parent)+"/"+e.name)}function Br(e){null!==e.parent&&jr(e.parent,e.name,e)}function jr(e,t,n){const s=Fr(n),r=(0,i.contains)(e.node.children,t);s&&r?(delete e.node.children[t],e.node.childCount--,Br(e)):s||r||(e.node.children[t]=n.node,e.node.childCount++,Br(e))}const Hr=/[\[\].#$\/\u0000-\u001F\u007F]/,Vr=/[\[\].#$\u0000-\u001F\u007F]/,zr=10485760,Yr=function(e){return"string"==typeof e&&0!==e.length&&!Hr.test(e)},Qr=function(e){return"string"==typeof e&&0!==e.length&&!Vr.test(e)},Kr=function(e){return e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),Qr(e)},Gr=function(e){return null===e||"string"==typeof e||"number"==typeof e&&!S(e)||e&&"object"==typeof e&&(0,i.contains)(e,".sv")},$r=function(e,t,n,s){s&&void 0===t||Xr((0,i.errorPrefix)(e,"value"),t,n)},Xr=function(e,t,n){const s=n instanceof at?new Tt(n,e):n;if(void 0===t)throw new Error(e+"contains undefined "+Et(s));if("function"==typeof t)throw new Error(e+"contains a function "+Et(s)+" with contents = "+t.toString());if(S(t))throw new Error(e+"contains "+t.toString()+" "+Et(s));if("string"==typeof t&&t.length>10485760/3&&(0,i.stringLength)(t)>10485760)throw new Error(e+"contains a string greater than 10485760 utf8 bytes "+Et(s)+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){let n=!1,i=!1;if(F(t,(t,r)=>{if(".value"===t)n=!0;else if(".priority"!==t&&".sv"!==t&&(i=!0,!Yr(t)))throw new Error(e+" contains an invalid key ("+t+") "+Et(s)+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');It(s,t),Xr(e,r,s),bt(s)}),n&&i)throw new Error(e+' contains ".value" child '+Et(s)+" in addition to actual children.")}},Jr=function(e,t){let n,i;for(n=0;n<t.length;n++){const s=pt(i=t[n]);for(let t=0;t<s.length;t++)if(".priority"===s[t]&&t===s.length-1);else if(!Yr(s[t]))throw new Error(e+"contains an invalid key ("+s[t]+") in path "+i.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"')}t.sort(vt);let s=null;for(n=0;n<t.length;n++){if(i=t[n],null!==s&&wt(s,i))throw new Error(e+"contains a path "+s.toString()+" that is ancestor of another path "+i.toString());s=i}},Zr=function(e,t,n,s){if(s&&void 0===t)return;const r=(0,i.errorPrefix)(e,"values");if(!t||"object"!=typeof t||Array.isArray(t))throw new Error(r+" must be an object containing the children to replace.");const o=[];F(t,(e,t)=>{const i=new at(e);if(Xr(r,t,mt(n,i)),".priority"===dt(i)&&!Gr(t))throw new Error(r+"contains an invalid value for '"+i.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");o.push(i)}),Jr(r,o)},eo=function(e,t,n){if(!n||void 0!==t){if(S(t))throw new Error((0,i.errorPrefix)(e,"priority")+"is "+t.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!Gr(t))throw new Error((0,i.errorPrefix)(e,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}},to=function(e,t,n,s){if(!(s&&void 0===n||Yr(n)))throw new Error((0,i.errorPrefix)(e,t)+'was an invalid key = "'+n+'". Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')},no=function(e,t,n,s){if(!(s&&void 0===n||Qr(n)))throw new Error((0,i.errorPrefix)(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')};exports._validatePathString=no;const io=function(e,t,n,i){n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),no(e,t,n,i)},so=function(e,t){if(".info"===ht(t))throw new Error(e+" failed = Can't modify data under /.info/")};exports._validateWritablePath=so;const ro=function(e,t){const n=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!Yr(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&&!Kr(n))throw new Error((0,i.errorPrefix)(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')};class oo{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function ao(e,t){let n=null;for(let i=0;i<t.length;i++){const s=t[i],r=s.getPath();null===n||Ct(r,n.path)||(e.eventLists_.push(n),n=null),null===n&&(n={events:[],path:r}),n.events.push(s)}n&&e.eventLists_.push(n)}function lo(e,t,n){ao(e,n),co(e,e=>Ct(e,t))}function ho(e,t,n){ao(e,n),co(e,e=>wt(e,t)||wt(t,e))}function co(e,t){e.recursionDepth_++;let n=!0;for(let i=0;i<e.eventLists_.length;i++){const s=e.eventLists_[i];if(s){t(s.path)?(uo(e.eventLists_[i]),e.eventLists_[i]=null):n=!1}}n&&(e.eventLists_=[]),e.recursionDepth_--}function uo(e){for(let t=0;t<e.events.length;t++){const n=e.events[t];if(null!==n){e.events[t]=null;const i=n.getEventRunner();y&&w("event: "+n.toString()),z(i)}}}const _o="repo_interrupt",po=25;class fo{constructor(e,t,n,i){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=n,this.appCheckProvider_=i,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new oo,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=jn(),this.transactionQueueTree_=new Rr,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function mo(e,t,n){if(e.stats_=pe(e.repoInfo_),e.forceRestClient_||Y())e.server_=new Un(e.repoInfo_,(t,n,i,s)=>{vo(e,t,n,i,s)},e.authTokenProvider_,e.appCheckProvider_),setTimeout(()=>Co(e,!0),0);else{if(null!=n){if("object"!=typeof n)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{(0,i.stringify)(n)}catch(s){throw new Error("Invalid authOverride provided: "+s)}}e.persistentConnection_=new qt(e.repoInfo_,t,(t,n,i,s)=>{vo(e,t,n,i,s)},t=>{Co(e,t)},t=>{wo(e,t)},e.authTokenProvider_,e.appCheckProvider_,n),e.server_=e.persistentConnection_}e.authTokenProvider_.addTokenChangeListener(t=>{e.server_.refreshAuthToken(t)}),e.appCheckProvider_.addTokenChangeListener(t=>{e.server_.refreshAppCheckToken(t.token)}),e.statsReporter_=fe(e.repoInfo_,()=>new Xn(e.stats_,e.server_)),e.infoData_=new Bn,e.infoSyncTree_=new Ks({startListening:(t,n,i,s)=>{let r=[];const o=e.infoData_.getNode(t._path);return o.isEmpty()||(r=Js(e.infoSyncTree_,t._path,o),setTimeout(()=>{s("ok")},0)),r},stopListening:()=>{}}),To(e,"connected",!1),e.serverSyncTree_=new Ks({startListening:(t,n,i,s)=>(e.server_.listen(t,i,n,(n,i)=>{const r=s(n,i);ho(e.eventQueue_,t._path,r)}),[]),stopListening:(t,n)=>{e.server_.unlisten(t,n)}})}function go(e){const t=e.infoData_.getNode(new at(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t}function yo(e){return br({timestamp:go(e)})}function vo(e,t,n,s,r){e.dataUpdateCount++;const o=new at(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;let a=[];if(r)if(s){const t=(0,i.map)(n,e=>gn(e));a=sr(e.serverSyncTree_,o,t,r)}else{const t=gn(n);a=ir(e.serverSyncTree_,o,t,r)}else if(s){const t=(0,i.map)(n,e=>gn(e));a=Zs(e.serverSyncTree_,o,t)}else{const t=gn(n);a=Js(e.serverSyncTree_,o,t)}let l=o;a.length>0&&(l=jo(e,o)),ho(e.eventQueue_,l,a)}function Co(e,t){To(e,"connected",t),!1===t&&So(e)}function wo(e,t){F(t,(t,n)=>{To(e,t,n)})}function To(e,t,n){const i=new at("/.info/"+t),s=gn(n);e.infoData_.updateSnapshot(i,s);const r=Js(e.infoSyncTree_,i,s);ho(e.eventQueue_,i,r)}function Io(e){return e.nextWriteId_++}function bo(e,t,n){const s=ar(e.serverSyncTree_,t);return null!=s?Promise.resolve(s):e.server_.get(t).then(i=>{const s=gn(i).withIndex(t._queryParams.getIndex());let r;if(rr(e.serverSyncTree_,t,n,!0),t._queryParams.loadsAllData())r=Js(e.serverSyncTree_,t._path,s);else{const n=dr(e.serverSyncTree_,t);r=ir(e.serverSyncTree_,t._path,s,n)}return ho(e.eventQueue_,t._path,r),nr(e.serverSyncTree_,t,n,null,!0),s},n=>(Fo(e,"get for query "+(0,i.stringify)(t)+" failed: "+n),Promise.reject(new Error(n))))}function ko(e,t,n,i,s){Fo(e,"set",{path:t.toString(),value:n,priority:i});const r=yo(e),o=gn(n,i),a=or(e.serverSyncTree_,t),l=Pr(o,a,r),h=Io(e),c=Gs(e.serverSyncTree_,t,l,h,!0);ao(e.eventQueue_,c),e.server_.put(t.toString(),o.val(!0),(n,i)=>{const r="ok"===n;r||k("set at "+t+" failed: "+n);const o=Xs(e.serverSyncTree_,h,!r);ho(e.eventQueue_,t,o),Lo(e,s,n,i)});const u=Ko(e,t);jo(e,u),ho(e.eventQueue_,u,[])}function Eo(e,t,n,i){Fo(e,"update",{path:t.toString(),value:n});let s=!0;const r=yo(e),o={};if(F(n,(n,i)=>{s=!1,o[n]=xr(mt(t,n),gn(i),e.serverSyncTree_,r)}),s)w("update() called with empty data. Don't do anything."),Lo(e,i,"ok",void 0);else{const s=Io(e),r=$s(e.serverSyncTree_,t,o,s);ao(e.eventQueue_,r),e.server_.merge(t.toString(),n,(n,r)=>{const o="ok"===n;o||k("update at "+t+" failed: "+n);const a=Xs(e.serverSyncTree_,s,!o),l=a.length>0?jo(e,t):t;ho(e.eventQueue_,l,a),Lo(e,i,n,r)}),F(n,n=>{const i=Ko(e,mt(t,n));jo(e,i)}),ho(e.eventQueue_,t,[])}}function So(e){Fo(e,"onDisconnectEvents");const t=yo(e),n=jn();zn(e.onDisconnect_,lt(),(i,s)=>{const r=xr(i,s,e.serverSyncTree_,t);Hn(n,i,r)});let i=[];zn(n,lt(),(t,n)=>{i=i.concat(Js(e.serverSyncTree_,t,n));const s=Ko(e,t);jo(e,s)}),e.onDisconnect_=jn(),ho(e.eventQueue_,lt(),i)}function xo(e,t,n){e.server_.onDisconnectCancel(t.toString(),(i,s)=>{"ok"===i&&Vn(e.onDisconnect_,t),Lo(e,n,i,s)})}function Po(e,t,n,i){const s=gn(n);e.server_.onDisconnectPut(t.toString(),s.val(!0),(n,r)=>{"ok"===n&&Hn(e.onDisconnect_,t,s),Lo(e,i,n,r)})}function No(e,t,n,i,s){const r=gn(n,i);e.server_.onDisconnectPut(t.toString(),r.val(!0),(n,i)=>{"ok"===n&&Hn(e.onDisconnect_,t,r),Lo(e,s,n,i)})}function Ro(e,t,n,s){if((0,i.isEmpty)(n))return w("onDisconnect().update() called with empty data. Don't do anything."),void Lo(e,s,"ok",void 0);e.server_.onDisconnectMerge(t.toString(),n,(i,r)=>{"ok"===i&&F(n,(n,i)=>{const s=gn(i);Hn(e.onDisconnect_,mt(t,n),s)}),Lo(e,s,i,r)})}function Do(e,t,n){let i;i=".info"===ht(t._path)?rr(e.infoSyncTree_,t,n):rr(e.serverSyncTree_,t,n),lo(e.eventQueue_,t._path,i)}function Ao(e,t,n){let i;i=".info"===ht(t._path)?nr(e.infoSyncTree_,t,n):nr(e.serverSyncTree_,t,n),lo(e.eventQueue_,t._path,i)}function Mo(e){e.persistentConnection_&&e.persistentConnection_.interrupt(_o)}function qo(e){e.persistentConnection_&&e.persistentConnection_.resume(_o)}function Fo(e,...t){let n="";e.persistentConnection_&&(n=e.persistentConnection_.id+":"),w(n,...t)}function Lo(e,t,n,i){t&&z(()=>{if("ok"===n)t(null);else{const e=(n||"error").toUpperCase();let s=e;i&&(s+=": "+i);const r=new Error(s);r.code=e,t(r)}})}function Oo(e,t,n,s,r,o){Fo(e,"transaction on "+t);const a={path:t,update:n,onComplete:s,status:null,order:f(),applyLocally:o,retryCount:0,unwatcher:r,abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},l=Wo(e,t,void 0);a.currentInputSnapshot=l;const h=a.update(l.val());if(void 0===h)a.unwatcher(),a.currentOutputSnapshotRaw=null,a.currentOutputSnapshotResolved=null,a.onComplete&&a.onComplete(null,!1,a.currentInputSnapshot);else{Xr("transaction failed: Data returned ",h,a.path),a.status=0;const n=Dr(e.transactionQueueTree_,t),s=Ar(n)||[];let r;if(s.push(a),Mr(n,s),"object"==typeof h&&null!==h&&(0,i.contains)(h,".priority"))r=(0,i.safeGet)(h,".priority"),(0,i.assert)(Gr(r),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.");else{r=(or(e.serverSyncTree_,t)||_n.EMPTY_NODE).getPriority().val()}const o=yo(e),c=gn(h,r),u=Pr(c,l,o);a.currentOutputSnapshotRaw=c,a.currentOutputSnapshotResolved=u,a.currentWriteId=Io(e);const d=Gs(e.serverSyncTree_,t,u,a.currentWriteId,a.applyLocally);ho(e.eventQueue_,t,d),Uo(e,e.transactionQueueTree_)}}function Wo(e,t,n){return or(e.serverSyncTree_,t,n)||_n.EMPTY_NODE}function Uo(e,t=e.transactionQueueTree_){if(t||Qo(e,t),Ar(t)){const n=zo(e,t);(0,i.assert)(n.length>0,"Sending zero length transaction queue"),n.every(e=>0===e.status)&&Bo(e,Ur(t),n)}else qr(t)&&Lr(t,t=>{Uo(e,t)})}function Bo(e,t,n){const s=n.map(e=>e.currentWriteId),r=Wo(e,t,s);let o=r;const a=r.hash();for(let c=0;c<n.length;c++){const e=n[c];(0,i.assert)(0===e.status,"tryToSendTransactionQueue_: items in queue should all be run."),e.status=1,e.retryCount++;const s=yt(t,e.path);o=o.updateChild(s,e.currentOutputSnapshotRaw)}const l=o.val(!0),h=t;e.server_.put(h.toString(),l,i=>{Fo(e,"transaction put response",{path:h.toString(),status:i});let s=[];if("ok"===i){const i=[];for(let t=0;t<n.length;t++)n[t].status=2,s=s.concat(Xs(e.serverSyncTree_,n[t].currentWriteId)),n[t].onComplete&&i.push(()=>n[t].onComplete(null,!0,n[t].currentOutputSnapshotResolved)),n[t].unwatcher();Qo(e,Dr(e.transactionQueueTree_,t)),Uo(e,e.transactionQueueTree_),ho(e.eventQueue_,t,s);for(let e=0;e<i.length;e++)z(i[e])}else{if("datastale"===i)for(let e=0;e<n.length;e++)3===n[e].status?n[e].status=4:n[e].status=0;else{k("transaction at "+h.toString()+" failed: "+i);for(let e=0;e<n.length;e++)n[e].status=4,n[e].abortReason=i}jo(e,t)}},a)}function jo(e,t){const n=Vo(e,t),i=Ur(n);return Ho(e,zo(e,n),i),i}function Ho(e,t,n){if(0===t.length)return;const s=[];let r=[];const o=t.filter(e=>0===e.status).map(e=>e.currentWriteId);for(let l=0;l<t.length;l++){const h=t[l],c=yt(n,h.path);let u,d=!1;if((0,i.assert)(null!==c,"rerunTransactionsUnderNode_: relativePath should not be null."),4===h.status)d=!0,u=h.abortReason,r=r.concat(Xs(e.serverSyncTree_,h.currentWriteId,!0));else if(0===h.status)if(h.retryCount>=po)d=!0,u="maxretry",r=r.concat(Xs(e.serverSyncTree_,h.currentWriteId,!0));else{const n=Wo(e,h.path,o);h.currentInputSnapshot=n;const s=t[l].update(n.val());if(void 0!==s){Xr("transaction failed: Data returned ",s,h.path);let t=gn(s);"object"==typeof s&&null!=s&&(0,i.contains)(s,".priority")||(t=t.updatePriority(n.getPriority()));const a=h.currentWriteId,l=yo(e),c=Pr(t,n,l);h.currentOutputSnapshotRaw=t,h.currentOutputSnapshotResolved=c,h.currentWriteId=Io(e),o.splice(o.indexOf(a),1),r=(r=r.concat(Gs(e.serverSyncTree_,h.path,c,h.currentWriteId,h.applyLocally))).concat(Xs(e.serverSyncTree_,a,!0))}else d=!0,u="nodata",r=r.concat(Xs(e.serverSyncTree_,h.currentWriteId,!0))}ho(e.eventQueue_,n,r),r=[],d&&(t[l].status=2,a=t[l].unwatcher,setTimeout(a,Math.floor(0)),t[l].onComplete&&("nodata"===u?s.push(()=>t[l].onComplete(null,!1,t[l].currentInputSnapshot)):s.push(()=>t[l].onComplete(new Error(u),!1,null))))}var a;Qo(e,e.transactionQueueTree_);for(let i=0;i<s.length;i++)z(s[i]);Uo(e,e.transactionQueueTree_)}function Vo(e,t){let n,i=e.transactionQueueTree_;for(n=ht(t);null!==n&&void 0===Ar(i);)i=Dr(i,n),n=ht(t=ut(t));return i}function zo(e,t){const n=[];return Yo(e,t,n),n.sort((e,t)=>e.order-t.order),n}function Yo(e,t,n){const i=Ar(t);if(i)for(let s=0;s<i.length;s++)n.push(i[s]);Lr(t,t=>{Yo(e,t,n)})}function Qo(e,t){const n=Ar(t);if(n){let e=0;for(let t=0;t<n.length;t++)2!==n[t].status&&(n[e]=n[t],e++);n.length=e,Mr(t,n.length>0?n:void 0)}Lr(t,t=>{Qo(e,t)})}function Ko(e,t){const n=Ur(Vo(e,t)),i=Dr(e.transactionQueueTree_,t);return Wr(i,t=>{Go(e,t)}),Go(e,i),Or(i,t=>{Go(e,t)}),n}function Go(e,t){const n=Ar(t);if(n){const s=[];let r=[],o=-1;for(let t=0;t<n.length;t++)3===n[t].status||(1===n[t].status?((0,i.assert)(o===t-1,"All SENT items should be at beginning of queue."),o=t,n[t].status=3,n[t].abortReason="set"):((0,i.assert)(0===n[t].status,"Unexpected transaction status in abort"),n[t].unwatcher(),r=r.concat(Xs(e.serverSyncTree_,n[t].currentWriteId,!0)),n[t].onComplete&&s.push(n[t].onComplete.bind(null,new Error("set"),!1,null))));-1===o?Mr(t,void 0):n.length=o+1,ho(e.eventQueue_,Ur(t),r);for(let e=0;e<s.length;e++)z(s[e])}}function $o(e){let t="";const n=e.split("/");for(let s=0;s<n.length;s++)if(n[s].length>0){let e=n[s];try{e=decodeURIComponent(e.replace(/\+/g," "))}catch(i){}t+="/"+e}return t}function Xo(e){const t={};"?"===e.charAt(0)&&(e=e.substring(1));for(const n of e.split("&")){if(0===n.length)continue;const i=n.split("=");2===i.length?t[decodeURIComponent(i[0])]=decodeURIComponent(i[1]):k(`Invalid query segment '${n}' in query '${e}'`)}return t}const Jo=function(e,t){const n=Zo(e),i=n.namespace;"firebase.com"===n.domain&&b(n.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),i&&"undefined"!==i||"localhost"===n.domain||b("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),n.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&k("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");const s="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new le(n.host,n.secure,i,s,t,"",i!==n.subdomain),path:new at(n.pathString)}},Zo=function(e){let t="",n="",i="",s="",r="",o=!0,a="https",l=443;if("string"==typeof e){let h=e.indexOf("//");h>=0&&(a=e.substring(0,h-1),e=e.substring(h+2));let c=e.indexOf("/");-1===c&&(c=e.length);let u=e.indexOf("?");-1===u&&(u=e.length),t=e.substring(0,Math.min(c,u)),c<u&&(s=$o(e.substring(c,u)));const d=Xo(e.substring(Math.min(e.length,u)));(h=t.indexOf(":"))>=0?(o="https"===a||"wss"===a,l=parseInt(t.substring(h+1),10)):h=t.length;const _=t.slice(0,h);if("localhost"===_.toLowerCase())n="localhost";else if(_.split(".").length<=2)n=_;else{const e=t.indexOf(".");i=t.substring(0,e).toLowerCase(),n=t.substring(e+1),r=i}"ns"in d&&(r=d.ns)}return{host:t,port:l,domain:n,subdomain:i,secure:o,scheme:a,pathString:s,namespace:r}},ea="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",ta=function(){let e=0;const t=[];return function(n){const s=n===e;let r;e=n;const o=new Array(8);for(r=7;r>=0;r--)o[r]=ea.charAt(n%64),n=Math.floor(n/64);(0,i.assert)(0===n,"Cannot push at time == 0");let a=o.join("");if(s){for(r=11;r>=0&&63===t[r];r--)t[r]=0;t[r]++}else for(r=0;r<12;r++)t[r]=Math.floor(64*Math.random());for(r=0;r<12;r++)a+=ea.charAt(t[r]);return(0,i.assert)(20===a.length,"nextPushId: Length should be 20."),a}}();class na{constructor(e,t,n,i){this.eventType=e,this.eventRegistration=t,this.snapshot=n,this.prevName=i}getPath(){const e=this.snapshot.ref;return"value"===this.eventType?e._path:e.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+(0,i.stringify)(this.snapshot.exportVal())}}class ia{constructor(e,t,n){this.eventRegistration=e,this.error=t,this.path=n}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}class sa{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return(0,i.assert)(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||void 0!==this.snapshotCallback.userCallback&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}class ra{constructor(e,t){this._repo=e,this._path=t}cancel(){const e=new i.Deferred;return xo(this._repo,this._path,e.wrapCallback(()=>{})),e.promise}remove(){so("OnDisconnect.remove",this._path);const e=new i.Deferred;return Po(this._repo,this._path,null,e.wrapCallback(()=>{})),e.promise}set(e){so("OnDisconnect.set",this._path),$r("OnDisconnect.set",e,this._path,!1);const t=new i.Deferred;return Po(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}setWithPriority(e,t){so("OnDisconnect.setWithPriority",this._path),$r("OnDisconnect.setWithPriority",e,this._path,!1),eo("OnDisconnect.setWithPriority",t,!1);const n=new i.Deferred;return No(this._repo,this._path,e,t,n.wrapCallback(()=>{})),n.promise}update(e){so("OnDisconnect.update",this._path),Zr("OnDisconnect.update",e,this._path,!1);const t=new i.Deferred;return Ro(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}}exports.OnDisconnect=ra;class oa{constructor(e,t,n,i){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=i}get key(){return gt(this._path)?null:dt(this._path)}get ref(){return new ca(this._repo,this._path)}get _queryIdentifier(){const e=Wn(this._queryParams),t=M(e);return"{}"===t?"default":t}get _queryObject(){return Wn(this._queryParams)}isEqual(e){if(!((e=(0,i.getModularInstance)(e))instanceof oa))return!1;const t=this._repo===e._repo,n=Ct(this._path,e._path),s=this._queryIdentifier===e._queryIdentifier;return t&&n&&s}toJSON(){return this.toString()}toString(){return this._repo.toString()+_t(this._path)}}function aa(e,t){if(!0===e._orderByCalled)throw new Error(t+": You can't combine multiple orderBy calls.")}function la(e){let t=null,n=null;if(e.hasStart()&&(t=e.getIndexStartValue()),e.hasEnd()&&(n=e.getIndexEndValue()),e.getIndex()===Ut){const i="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",s="Query: When ordering by key, the argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() must be a string.";if(e.hasStart()){if(e.getIndexStartName()!==P)throw new Error(i);if("string"!=typeof t)throw new Error(s)}if(e.hasEnd()){if(e.getIndexEndName()!==N)throw new Error(i);if("string"!=typeof n)throw new Error(s)}}else if(e.getIndex()===rn){if(null!=t&&!Gr(t)||null!=n&&!Gr(n))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), startAfter() endAt(), endBefore(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if((0,i.assert)(e.getIndex()instanceof yn||e.getIndex()===Cn,"unknown index type."),null!=t&&"object"==typeof t||null!=n&&"object"==typeof n)throw new Error("Query: First argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() cannot be an object.")}function ha(e){if(e.hasStart()&&e.hasEnd()&&e.hasLimit()&&!e.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), startAfter(), endAt(), endBefore(), and limit(). Use limitToFirst() or limitToLast() instead.")}exports._QueryImpl=oa;class ca extends oa{constructor(e,t){super(e,t,new Pn,!1)}get parent(){const e=ft(this._path);return null===e?null:new ca(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}exports._ReferenceImpl=ca;class ua{constructor(e,t,n){this._node=e,this.ref=t,this._index=n}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const t=new at(e),n=pa(this.ref,e);return new ua(this._node.getChild(t),n,rn)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){if(this._node.isLeafNode())return!1;return!!this._node.forEachChild(this._index,(t,n)=>e(new ua(n,pa(this.ref,t),rn)))}hasChild(e){const t=new at(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return!this._node.isLeafNode()&&!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function da(e,t){return(e=(0,i.getModularInstance)(e))._checkNotDeleted("ref"),void 0!==t?pa(e._root,t):e._root}function _a(e,t){(e=(0,i.getModularInstance)(e))._checkNotDeleted("refFromURL");const n=Jo(t,e._repo.repoInfo_.nodeAdmin);ro("refFromURL",n);const s=n.repoInfo;return e._repo.repoInfo_.isCustomHost()||s.host===e._repo.repoInfo_.host||b("refFromURL: Host name does not match the current database: (found "+s.host+" but expected "+e._repo.repoInfo_.host+")"),da(e,n.path.toString())}function pa(e,t){return null===ht((e=(0,i.getModularInstance)(e))._path)?io("child","path",t,!1):no("child","path",t,!1),new ca(e._repo,mt(e._path,t))}function fa(e){return e=(0,i.getModularInstance)(e),new ra(e._repo,e._path)}function ma(e,t){e=(0,i.getModularInstance)(e),so("push",e._path),$r("push",t,e._path,!0);const n=go(e._repo),s=ta(n),r=pa(e,s),o=pa(e,s);let a;return a=null!=t?ya(o,t).then(()=>o):Promise.resolve(o),r.then=a.then.bind(a),r.catch=a.then.bind(a,void 0),r}function ga(e){return so("remove",e._path),ya(e,null)}function ya(e,t){e=(0,i.getModularInstance)(e),so("set",e._path),$r("set",t,e._path,!1);const n=new i.Deferred;return ko(e._repo,e._path,t,null,n.wrapCallback(()=>{})),n.promise}function va(e,t){e=(0,i.getModularInstance)(e),so("setPriority",e._path),eo("setPriority",t,!1);const n=new i.Deferred;return ko(e._repo,mt(e._path,".priority"),t,null,n.wrapCallback(()=>{})),n.promise}function Ca(e,t,n){if(so("setWithPriority",e._path),$r("setWithPriority",t,e._path,!1),eo("setWithPriority",n,!1),".length"===e.key||".keys"===e.key)throw"setWithPriority failed: "+e.key+" is a read-only object.";const s=new i.Deferred;return ko(e._repo,e._path,t,n,s.wrapCallback(()=>{})),s.promise}function wa(e,t){Zr("update",t,e._path,!1);const n=new i.Deferred;return Eo(e._repo,e._path,t,n.wrapCallback(()=>{})),n.promise}function Ta(e){e=(0,i.getModularInstance)(e);const t=new sa(()=>{}),n=new Ia(t);return bo(e._repo,e,n).then(t=>new ua(t,new ca(e._repo,e._path),e._queryParams.getIndex()))}exports.DataSnapshot=ua;class Ia{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){const n=t._queryParams.getIndex();return new na("value",this,new ua(e.snapshotNode,new ca(t._repo,t._path),n))}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new ia(this,e,t):null}matches(e){return e instanceof Ia&&(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}class ba{constructor(e,t){this.eventType=e,this.callbackContext=t}respondsTo(e){let t="children_added"===e?"child_added":e;return t="children_removed"===t?"child_removed":t,this.eventType===t}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new ia(this,e,t):null}createEvent(e,t){(0,i.assert)(null!=e.childName,"Child events should have a childName.");const n=pa(new ca(t._repo,t._path),e.childName),s=t._queryParams.getIndex();return new na(e.type,this,new ua(e.snapshotNode,n,s),e.prevName)}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof ba&&(this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)))}hasAnyCallback(){return!!this.callbackContext}}function ka(e,t,n,i,s){let r;if("object"==typeof i&&(r=void 0,s=i),"function"==typeof i&&(r=i),s&&s.onlyOnce){const t=n,i=(n,i)=>{Ao(e._repo,e,a),t(n,i)};i.userCallback=n.userCallback,i.context=n.context,n=i}const o=new sa(n,r||void 0),a="value"===t?new Ia(o):new ba(t,o);return Do(e._repo,e,a),()=>Ao(e._repo,e,a)}function Ea(e,t,n,i){return ka(e,"value",t,n,i)}function Sa(e,t,n,i){return ka(e,"child_added",t,n,i)}function xa(e,t,n,i){return ka(e,"child_changed",t,n,i)}function Pa(e,t,n,i){return ka(e,"child_moved",t,n,i)}function Na(e,t,n,i){return ka(e,"child_removed",t,n,i)}function Ra(e,t,n){let i=null;const s=n?new sa(n):null;"value"===t?i=new Ia(s):t&&(i=new ba(t,s)),Ao(e._repo,e,i)}class Da{}exports.QueryConstraint=Da;class Aa extends Da{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){$r("endAt",this._value,e._path,!0);const t=qn(e._queryParams,this._value,this._key);if(ha(t),la(t),e._queryParams.hasEnd())throw new Error("endAt: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new oa(e._repo,e._path,t,e._orderByCalled)}}function Ma(e,t){return to("endAt","key",t,!0),new Aa(e,t)}class qa extends Da{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){$r("endBefore",this._value,e._path,!1);const t=Fn(e._queryParams,this._value,this._key);if(ha(t),la(t),e._queryParams.hasEnd())throw new Error("endBefore: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new oa(e._repo,e._path,t,e._orderByCalled)}}function Fa(e,t){return to("endBefore","key",t,!0),new qa(e,t)}class La extends Da{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){$r("startAt",this._value,e._path,!0);const t=An(e._queryParams,this._value,this._key);if(ha(t),la(t),e._queryParams.hasStart())throw new Error("startAt: Starting point was already set (by another call to startAt, startBefore or equalTo).");return new oa(e._repo,e._path,t,e._orderByCalled)}}function Oa(e=null,t){return to("startAt","key",t,!0),new La(e,t)}class Wa extends Da{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){$r("startAfter",this._value,e._path,!1);const t=Mn(e._queryParams,this._value,this._key);if(ha(t),la(t),e._queryParams.hasStart())throw new Error("startAfter: Starting point was already set (by another call to startAt, startAfter, or equalTo).");return new oa(e._repo,e._path,t,e._orderByCalled)}}function Ua(e,t){return to("startAfter","key",t,!0),new Wa(e,t)}class Ba extends Da{constructor(e){super(),this._limit=e}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToFirst: Limit was already set (by another call to limitToFirst or limitToLast).");return new oa(e._repo,e._path,Rn(e._queryParams,this._limit),e._orderByCalled)}}function ja(e){if("number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToFirst: First argument must be a positive integer.");return new Ba(e)}class Ha extends Da{constructor(e){super(),this._limit=e}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToLast: Limit was already set (by another call to limitToFirst or limitToLast).");return new oa(e._repo,e._path,Dn(e._queryParams,this._limit),e._orderByCalled)}}function Va(e){if("number"!=typeof e||Math.floor(e)!==e||e<=0)throw new Error("limitToLast: First argument must be a positive integer.");return new Ha(e)}class za extends Da{constructor(e){super(),this._path=e}_apply(e){aa(e,"orderByChild");const t=new at(this._path);if(gt(t))throw new Error("orderByChild: cannot pass in empty path. Use orderByValue() instead.");const n=new yn(t),i=Ln(e._queryParams,n);return la(i),new oa(e._repo,e._path,i,!0)}}function Ya(e){if("$key"===e)throw new Error('orderByChild: "$key" is invalid. Use orderByKey() instead.');if("$priority"===e)throw new Error('orderByChild: "$priority" is invalid. Use orderByPriority() instead.');if("$value"===e)throw new Error('orderByChild: "$value" is invalid. Use orderByValue() instead.');return no("orderByChild","path",e,!1),new za(e)}class Qa extends Da{_apply(e){aa(e,"orderByKey");const t=Ln(e._queryParams,Ut);return la(t),new oa(e._repo,e._path,t,!0)}}function Ka(){return new Qa}class Ga extends Da{_apply(e){aa(e,"orderByPriority");const t=Ln(e._queryParams,rn);return la(t),new oa(e._repo,e._path,t,!0)}}function $a(){return new Ga}class Xa extends Da{_apply(e){aa(e,"orderByValue");const t=Ln(e._queryParams,Cn);return la(t),new oa(e._repo,e._path,t,!0)}}function Ja(){return new Xa}class Za extends Da{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){if($r("equalTo",this._value,e._path,!1),e._queryParams.hasStart())throw new Error("equalTo: Starting point was already set (by another call to startAt/startAfter or equalTo).");if(e._queryParams.hasEnd())throw new Error("equalTo: Ending point was already set (by another call to endAt/endBefore or equalTo).");return new Aa(this._value,this._key)._apply(new La(this._value,this._key)._apply(e))}}function el(e,t){return to("equalTo","key",t,!0),new Za(e,t)}function tl(e,...t){let n=(0,i.getModularInstance)(e);for(const i of t)n=i._apply(n);return n}Ds(ca),zs(ca);const nl="FIREBASE_DATABASE_EMULATOR_HOST",il={};let sl=!1;function rl(e,t,n,i){e.repoInfo_=new le(`${t}:${n}`,!1,e.repoInfo_.namespace,e.repoInfo_.webSocketOnly,e.repoInfo_.nodeAdmin,e.repoInfo_.persistenceKey,e.repoInfo_.includeNamespaceInQueryParams,!0),i&&(e.authTokenProvider_=i)}function ol(t,n,i,s,r){let o=s||t.options.databaseURL;void 0===o&&(t.options.projectId||b("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),w("Using default host for project ",t.options.projectId),o=`${t.options.projectId}-default-rtdb.firebaseio.com`);let a,l=Jo(o,r),h=l.repoInfo,c=void 0;void 0!==e&&e.env&&(c=e.env[nl]),c?(a=!0,o=`http://${c}?ns=${h.namespace}`,h=(l=Jo(o,r)).repoInfo):a=!l.repoInfo.secure;const u=r&&a?new $($.OWNER):new G(t.name,t.options,n);ro("Invalid Firebase Database URL",l),gt(l.path)||b("Database URL must point to the root of a Firebase Database (not including a child path).");const d=ll(h,t,u,new K(t.name,i));return new cl(d,t)}function al(e,t){const n=il[t];n&&n[e.key]===e||b(`Database ${t}(${e.repoInfo_}) has already been deleted.`),Mo(e),delete n[e.key]}function ll(e,t,n,i){let s=il[t.name];s||(s={},il[t.name]=s);let r=s[e.toURLString()];return r&&b("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),r=new fo(e,sl,n,i),s[e.toURLString()]=r,r}function hl(e){sl=e}class cl{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(mo(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new ca(this._repo,lt())),this._rootInternal}_delete(){return null!==this._rootInternal&&(al(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){null===this._rootInternal&&b("Cannot call "+e+" on a deleted database.")}}function ul(){Ue.IS_TRANSPORT_INITIALIZED&&k("Transport has already been initialized. Please call this function before calling ref or setting up a listener")}function dl(){ul(),Me.forceDisallow()}function _l(){ul(),We.forceDisallow(),Me.forceAllow()}function pl(e=(0,t.getApp)(),n){const s=(0,t._getProvider)(e,"database").getImmediate({identifier:n});if(!s._instanceStarted){const e=(0,i.getDefaultEmulatorHostnameAndPort)("database");e&&fl(s,...e)}return s}function fl(e,t,n,s={}){(e=(0,i.getModularInstance)(e))._checkNotDeleted("useEmulator"),e._instanceStarted&&b("Cannot call useEmulator() after instance has already been initialized.");const r=e._repoInternal;let o=void 0;if(r.repoInfo_.nodeAdmin)s.mockUserToken&&b('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new $($.OWNER);else if(s.mockUserToken){const t="string"==typeof s.mockUserToken?s.mockUserToken:(0,i.createMockUserToken)(s.mockUserToken,e.app.options.projectId);o=new $(t)}rl(r,t,n,o)}function ml(e){(e=(0,i.getModularInstance)(e))._checkNotDeleted("goOffline"),Mo(e._repo)}function gl(e){(e=(0,i.getModularInstance)(e))._checkNotDeleted("goOnline"),qo(e._repo)}function yl(e,t){C(e,t)}function vl(e){l(t.SDK_VERSION),(0,t._registerComponent)(new n.Component("database",(e,{instanceIdentifier:t})=>{return ol(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t)},"PUBLIC").setMultipleInstances(!0)),(0,t.registerVersion)(r,o,e),(0,t.registerVersion)(r,o,"esm2017")}exports.Database=cl;const Cl={".sv":"timestamp"};function wl(){return Cl}function Tl(e){return{".sv":{increment:e}}}class Il{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return{committed:this.committed,snapshot:this.snapshot.toJSON()}}}function bl(e,t,n){var s;if(e=(0,i.getModularInstance)(e),so("Reference.transaction",e._path),".length"===e.key||".keys"===e.key)throw"Reference.transaction failed: "+e.key+" is a read-only object.";const r=null===(s=null==n?void 0:n.applyLocally)||void 0===s||s,o=new i.Deferred,a=Ea(e,()=>{});return Oo(e._repo,e._path,t,(t,n,i)=>{let s=null;t?o.reject(t):(s=new ua(i,new ca(e._repo,e._path),rn),o.resolve(new Il(n,s)))},a,r),o.promise}exports.TransactionResult=Il,qt.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},qt.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)};const kl=function(e){const t=qt.prototype.put;return qt.prototype.put=function(n,i,s,r){void 0!==r&&(r=e()),t.call(this,n,i,s,r)},function(){qt.prototype.put=t}};exports._TEST_ACCESS_hijackHash=kl;const El=function(e){hl(e)};exports._TEST_ACCESS_forceRestClient=El,vl();
|
|
482
|
+
},{"@firebase/app":"h2Mb","@firebase/component":"vhY9","@firebase/util":"chA2","@firebase/logger":"JJem","process":"pBGv"}],"sWIc":[function(require,module,exports) {
|
|
483
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.registerDatabase=m;var e=l(require("@firebase/app-compat")),t=require("@firebase/component"),a=require("@firebase/database"),n=require("@firebase/util"),r=require("@firebase/logger");function l(e){return e&&e.__esModule?e:{default:e}}const i="@firebase/database-compat",o="0.3.4",s=new r.Logger("@firebase/database-compat"),d=function(e){const t="FIREBASE WARNING: "+e;s.warn(t)},c=function(e,t,a,r){if((!r||void 0!==a)&&"boolean"!=typeof a)throw new Error((0,n.errorPrefix)(e,t)+"must be a boolean.")},h=function(e,t,a){if(!a||void 0!==t)switch(t){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:throw new Error((0,n.errorPrefix)(e,"eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}};class u{constructor(e){this._delegate=e}cancel(e){(0,n.validateArgCount)("OnDisconnect.cancel",0,1,arguments.length),(0,n.validateCallback)("OnDisconnect.cancel","onComplete",e,!0);const t=this._delegate.cancel();return e&&t.then(()=>e(null),t=>e(t)),t}remove(e){(0,n.validateArgCount)("OnDisconnect.remove",0,1,arguments.length),(0,n.validateCallback)("OnDisconnect.remove","onComplete",e,!0);const t=this._delegate.remove();return e&&t.then(()=>e(null),t=>e(t)),t}set(e,t){(0,n.validateArgCount)("OnDisconnect.set",1,2,arguments.length),(0,n.validateCallback)("OnDisconnect.set","onComplete",t,!0);const a=this._delegate.set(e);return t&&a.then(()=>t(null),e=>t(e)),a}setWithPriority(e,t,a){(0,n.validateArgCount)("OnDisconnect.setWithPriority",2,3,arguments.length),(0,n.validateCallback)("OnDisconnect.setWithPriority","onComplete",a,!0);const r=this._delegate.setWithPriority(e,t);return a&&r.then(()=>a(null),e=>a(e)),r}update(e,t){if((0,n.validateArgCount)("OnDisconnect.update",1,2,arguments.length),Array.isArray(e)){const t={};for(let a=0;a<e.length;++a)t[""+a]=e[a];e=t,d("Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}(0,n.validateCallback)("OnDisconnect.update","onComplete",t,!0);const a=this._delegate.update(e);return t&&a.then(()=>t(null),e=>t(e)),a}}class g{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return(0,n.validateArgCount)("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}}}class v{constructor(e,t){this._database=e,this._delegate=t}val(){return(0,n.validateArgCount)("DataSnapshot.val",0,0,arguments.length),this._delegate.val()}exportVal(){return(0,n.validateArgCount)("DataSnapshot.exportVal",0,0,arguments.length),this._delegate.exportVal()}toJSON(){return(0,n.validateArgCount)("DataSnapshot.toJSON",0,1,arguments.length),this._delegate.toJSON()}exists(){return(0,n.validateArgCount)("DataSnapshot.exists",0,0,arguments.length),this._delegate.exists()}child(e){return(0,n.validateArgCount)("DataSnapshot.child",0,1,arguments.length),e=String(e),(0,a._validatePathString)("DataSnapshot.child","path",e,!1),new v(this._database,this._delegate.child(e))}hasChild(e){return(0,n.validateArgCount)("DataSnapshot.hasChild",1,1,arguments.length),(0,a._validatePathString)("DataSnapshot.hasChild","path",e,!1),this._delegate.hasChild(e)}getPriority(){return(0,n.validateArgCount)("DataSnapshot.getPriority",0,0,arguments.length),this._delegate.priority}forEach(e){return(0,n.validateArgCount)("DataSnapshot.forEach",1,1,arguments.length),(0,n.validateCallback)("DataSnapshot.forEach","action",e,!1),this._delegate.forEach(t=>e(new v(this._database,t)))}hasChildren(){return(0,n.validateArgCount)("DataSnapshot.hasChildren",0,0,arguments.length),this._delegate.hasChildren()}get key(){return this._delegate.key}numChildren(){return(0,n.validateArgCount)("DataSnapshot.numChildren",0,0,arguments.length),this._delegate.size}getRef(){return(0,n.validateArgCount)("DataSnapshot.ref",0,0,arguments.length),new f(this._database,this._delegate.ref)}get ref(){return this.getRef()}}class _{constructor(e,t){this.database=e,this._delegate=t}on(e,t,r,l){var i;(0,n.validateArgCount)("Query.on",2,4,arguments.length),(0,n.validateCallback)("Query.on","callback",t,!1);const o=_.getCancelAndContextArgs_("Query.on",r,l),s=(e,a)=>{t.call(o.context,new v(this.database,e),a)};s.userCallback=t,s.context=o.context;const d=null===(i=o.cancel)||void 0===i?void 0:i.bind(o.context);switch(e){case"value":return(0,a.onValue)(this._delegate,s,d),t;case"child_added":return(0,a.onChildAdded)(this._delegate,s,d),t;case"child_removed":return(0,a.onChildRemoved)(this._delegate,s,d),t;case"child_changed":return(0,a.onChildChanged)(this._delegate,s,d),t;case"child_moved":return(0,a.onChildMoved)(this._delegate,s,d),t;default:throw new Error((0,n.errorPrefix)("Query.on","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}off(e,t,r){if((0,n.validateArgCount)("Query.off",0,3,arguments.length),h("Query.off",e,!0),(0,n.validateCallback)("Query.off","callback",t,!0),(0,n.validateContextObject)("Query.off","context",r,!0),t){const n=()=>{};n.userCallback=t,n.context=r,(0,a.off)(this._delegate,e,n)}else(0,a.off)(this._delegate,e)}get(){return(0,a.get)(this._delegate).then(e=>new v(this.database,e))}once(e,t,r,l){(0,n.validateArgCount)("Query.once",1,4,arguments.length),(0,n.validateCallback)("Query.once","callback",t,!0);const i=_.getCancelAndContextArgs_("Query.once",r,l),o=new n.Deferred,s=(e,a)=>{const n=new v(this.database,e);t&&t.call(i.context,n,a),o.resolve(n)};s.userCallback=t,s.context=i.context;const d=e=>{i.cancel&&i.cancel.call(i.context,e),o.reject(e)};switch(e){case"value":(0,a.onValue)(this._delegate,s,d,{onlyOnce:!0});break;case"child_added":(0,a.onChildAdded)(this._delegate,s,d,{onlyOnce:!0});break;case"child_removed":(0,a.onChildRemoved)(this._delegate,s,d,{onlyOnce:!0});break;case"child_changed":(0,a.onChildChanged)(this._delegate,s,d,{onlyOnce:!0});break;case"child_moved":(0,a.onChildMoved)(this._delegate,s,d,{onlyOnce:!0});break;default:throw new Error((0,n.errorPrefix)("Query.once","eventType")+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}return o.promise}limitToFirst(e){return(0,n.validateArgCount)("Query.limitToFirst",1,1,arguments.length),new _(this.database,(0,a.query)(this._delegate,(0,a.limitToFirst)(e)))}limitToLast(e){return(0,n.validateArgCount)("Query.limitToLast",1,1,arguments.length),new _(this.database,(0,a.query)(this._delegate,(0,a.limitToLast)(e)))}orderByChild(e){return(0,n.validateArgCount)("Query.orderByChild",1,1,arguments.length),new _(this.database,(0,a.query)(this._delegate,(0,a.orderByChild)(e)))}orderByKey(){return(0,n.validateArgCount)("Query.orderByKey",0,0,arguments.length),new _(this.database,(0,a.query)(this._delegate,(0,a.orderByKey)()))}orderByPriority(){return(0,n.validateArgCount)("Query.orderByPriority",0,0,arguments.length),new _(this.database,(0,a.query)(this._delegate,(0,a.orderByPriority)()))}orderByValue(){return(0,n.validateArgCount)("Query.orderByValue",0,0,arguments.length),new _(this.database,(0,a.query)(this._delegate,(0,a.orderByValue)()))}startAt(e=null,t){return(0,n.validateArgCount)("Query.startAt",0,2,arguments.length),new _(this.database,(0,a.query)(this._delegate,(0,a.startAt)(e,t)))}startAfter(e=null,t){return(0,n.validateArgCount)("Query.startAfter",0,2,arguments.length),new _(this.database,(0,a.query)(this._delegate,(0,a.startAfter)(e,t)))}endAt(e=null,t){return(0,n.validateArgCount)("Query.endAt",0,2,arguments.length),new _(this.database,(0,a.query)(this._delegate,(0,a.endAt)(e,t)))}endBefore(e=null,t){return(0,n.validateArgCount)("Query.endBefore",0,2,arguments.length),new _(this.database,(0,a.query)(this._delegate,(0,a.endBefore)(e,t)))}equalTo(e,t){return(0,n.validateArgCount)("Query.equalTo",1,2,arguments.length),new _(this.database,(0,a.query)(this._delegate,(0,a.equalTo)(e,t)))}toString(){return(0,n.validateArgCount)("Query.toString",0,0,arguments.length),this._delegate.toString()}toJSON(){return(0,n.validateArgCount)("Query.toJSON",0,1,arguments.length),this._delegate.toJSON()}isEqual(e){if((0,n.validateArgCount)("Query.isEqual",1,1,arguments.length),!(e instanceof _)){throw new Error("Query.isEqual failed: First argument must be an instance of firebase.database.Query.")}return this._delegate.isEqual(e._delegate)}static getCancelAndContextArgs_(e,t,a){const r={cancel:void 0,context:void 0};if(t&&a)r.cancel=t,(0,n.validateCallback)(e,"cancel",r.cancel,!0),r.context=a,(0,n.validateContextObject)(e,"context",r.context,!0);else if(t)if("object"==typeof t&&null!==t)r.context=t;else{if("function"!=typeof t)throw new Error((0,n.errorPrefix)(e,"cancelOrContext")+" must either be a cancel callback or a context object.");r.cancel=t}return r}get ref(){return new f(this.database,new a._ReferenceImpl(this._delegate._repo,this._delegate._path))}}class f extends _{constructor(e,t){super(e,new a._QueryImpl(t._repo,t._path,new a._QueryParams,!1)),this.database=e,this._delegate=t}getKey(){return(0,n.validateArgCount)("Reference.key",0,0,arguments.length),this._delegate.key}child(e){return(0,n.validateArgCount)("Reference.child",1,1,arguments.length),"number"==typeof e&&(e=String(e)),new f(this.database,(0,a.child)(this._delegate,e))}getParent(){(0,n.validateArgCount)("Reference.parent",0,0,arguments.length);const e=this._delegate.parent;return e?new f(this.database,e):null}getRoot(){return(0,n.validateArgCount)("Reference.root",0,0,arguments.length),new f(this.database,this._delegate.root)}set(e,t){(0,n.validateArgCount)("Reference.set",1,2,arguments.length),(0,n.validateCallback)("Reference.set","onComplete",t,!0);const r=(0,a.set)(this._delegate,e);return t&&r.then(()=>t(null),e=>t(e)),r}update(e,t){if((0,n.validateArgCount)("Reference.update",1,2,arguments.length),Array.isArray(e)){const t={};for(let a=0;a<e.length;++a)t[""+a]=e[a];e=t,d("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}(0,a._validateWritablePath)("Reference.update",this._delegate._path),(0,n.validateCallback)("Reference.update","onComplete",t,!0);const r=(0,a.update)(this._delegate,e);return t&&r.then(()=>t(null),e=>t(e)),r}setWithPriority(e,t,r){(0,n.validateArgCount)("Reference.setWithPriority",2,3,arguments.length),(0,n.validateCallback)("Reference.setWithPriority","onComplete",r,!0);const l=(0,a.setWithPriority)(this._delegate,e,t);return r&&l.then(()=>r(null),e=>r(e)),l}remove(e){(0,n.validateArgCount)("Reference.remove",0,1,arguments.length),(0,n.validateCallback)("Reference.remove","onComplete",e,!0);const t=(0,a.remove)(this._delegate);return e&&t.then(()=>e(null),t=>e(t)),t}transaction(e,t,r){(0,n.validateArgCount)("Reference.transaction",1,3,arguments.length),(0,n.validateCallback)("Reference.transaction","transactionUpdate",e,!1),(0,n.validateCallback)("Reference.transaction","onComplete",t,!0),c("Reference.transaction","applyLocally",r,!0);const l=(0,a.runTransaction)(this._delegate,e,{applyLocally:r}).then(e=>new g(e.committed,new v(this.database,e.snapshot)));return t&&l.then(e=>t(null,e.committed,e.snapshot),e=>t(e,!1,null)),l}setPriority(e,t){(0,n.validateArgCount)("Reference.setPriority",1,2,arguments.length),(0,n.validateCallback)("Reference.setPriority","onComplete",t,!0);const r=(0,a.setPriority)(this._delegate,e);return t&&r.then(()=>t(null),e=>t(e)),r}push(e,t){(0,n.validateArgCount)("Reference.push",0,2,arguments.length),(0,n.validateCallback)("Reference.push","onComplete",t,!0);const r=(0,a.push)(this._delegate,e),l=r.then(e=>new f(this.database,e));t&&l.then(()=>t(null),e=>t(e));const i=new f(this.database,r);return i.then=l.then.bind(l),i.catch=l.catch.bind(l,void 0),i}onDisconnect(){return(0,a._validateWritablePath)("Reference.onDisconnect",this._delegate._path),new u(new a.OnDisconnect(this._delegate._repo,this._delegate._path))}get key(){return this.getKey()}get parent(){return this.getParent()}get root(){return this.getRoot()}}class C{constructor(e,t){this._delegate=e,this.app=t,this.INTERNAL={delete:()=>this._delegate._delete(),forceWebSockets:a.forceWebSockets,forceLongPolling:a.forceLongPolling}}useEmulator(e,t,n={}){(0,a.connectDatabaseEmulator)(this._delegate,e,t,n)}ref(e){if((0,n.validateArgCount)("database.ref",0,1,arguments.length),e instanceof f){const t=(0,a.refFromURL)(this._delegate,e.toString());return new f(this,t)}{const t=(0,a.ref)(this._delegate,e);return new f(this,t)}}refFromURL(e){(0,n.validateArgCount)("database.refFromURL",1,1,arguments.length);const t=(0,a.refFromURL)(this._delegate,e);return new f(this,t)}goOffline(){return(0,n.validateArgCount)("database.goOffline",0,0,arguments.length),(0,a.goOffline)(this._delegate)}goOnline(){return(0,n.validateArgCount)("database.goOnline",0,0,arguments.length),(0,a.goOnline)(this._delegate)}}function p({app:e,url:n,version:r,customAuthImpl:l,namespace:i,nodeAdmin:o=!1}){(0,a._setSDKVersion)(r);const s=new t.Provider("auth-internal",new t.ComponentContainer("database-standalone"));return s.setComponent(new t.Component("auth-internal",()=>l,"PRIVATE")),{instance:new C((0,a._repoManagerDatabaseFromApp)(e,s,void 0,n,o),e),namespace:i}}C.ServerValue={TIMESTAMP:(0,a.serverTimestamp)(),increment:e=>(0,a.increment)(e)};var y=Object.freeze({__proto__:null,initStandalone:p});const b=C.ServerValue;function m(e){e.INTERNAL.registerComponent(new t.Component("database-compat",(e,{instanceIdentifier:t})=>{const a=e.getProvider("app-compat").getImmediate(),n=e.getProvider("database").getImmediate({identifier:t});return new C(n,a)},"PUBLIC").setServiceProps({Reference:f,Query:_,Database:C,DataSnapshot:v,enableLogging:a.enableLogging,INTERNAL:y,ServerValue:b}).setMultipleInstances(!0)),e.registerVersion(i,o)}m(e.default);
|
|
484
|
+
},{"@firebase/app-compat":"CMFQ","@firebase/component":"vhY9","@firebase/database":"Q6BU","@firebase/util":"chA2","@firebase/logger":"JJem"}],"h3PO":[function(require,module,exports) {
|
|
485
|
+
"use strict";require("@firebase/database-compat");
|
|
486
|
+
},{"@firebase/database-compat":"sWIc"}],"z5kx":[function(require,module,exports) {
|
|
487
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.$=Ht,exports.D=exports.C=exports.B=exports.A=void 0,exports.E=b,exports.F=void 0,exports.G=Ue,exports.W=exports.V=exports.U=exports.T=exports.S=exports.R=exports.Q=exports.P=exports.O=exports.N=exports.M=exports.L=exports.K=exports.J=exports.I=exports.H=void 0,exports.X=St,exports.Y=Ft,exports.Z=Vt,exports._=qt,exports.a=void 0,exports.a0=Kt,exports.a1=Bt,exports.a2=Jt,exports.a3=$t,exports.a4=Yt,exports.a5=Xt,exports.a6=Qt,exports.a7=Zt,exports.a8=en,exports.a9=tn,exports.aA=ge,exports.aB=_r,exports.aC=ur,exports.aD=cr,exports.aE=Me,exports.aG=exports.aF=void 0,exports.aH=De,exports.aI=Jn,exports.aL=exports.aK=exports.aJ=void 0,exports.aa=rn,exports.ab=sn,exports.ac=on,exports.ad=void 0,exports.ae=pt,exports.af=cn,exports.ag=un,exports.ah=dn,exports.ai=X,exports.aj=Q,exports.ak=Ct,exports.al=_n,exports.am=ae,exports.an=On,exports.ao=xn,exports.ap=A,exports.aq=Re,exports.ar=Ee,exports.as=I,exports.at=Zr,exports.au=Rr,exports.av=Ne,exports.aw=_,exports.ax=E,exports.ay=void 0,exports.az=N,exports.b=void 0,exports.c=Zi,exports.d=tr,exports.e=er,exports.f=hr,exports.g=gr,exports.h=mr,exports.i=void 0,exports.j=Ir,exports.k=void 0,exports.l=ji,exports.m=void 0,exports.n=gs,exports.o=void 0,exports.p=yn,exports.q=Tn,exports.r=Hi,exports.s=qi,exports.t=wn,exports.u=Gi,exports.v=En,exports.w=kn,exports.x=An,exports.y=Rn,exports.z=Nn;var e=require("@firebase/util"),t=require("@firebase/app"),n=require("@firebase/logger"),i=require("tslib"),r=require("@firebase/component");const s={PHONE:"phone"};exports.F=s;const o={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"};exports.o=o;const a={EMAIL_LINK:"emailLink",EMAIL_PASSWORD:"password",FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PHONE:"phone",TWITTER:"twitter.com"};exports.S=a;const c={LINK:"link",REAUTHENTICATE:"reauthenticate",SIGN_IN:"signIn"};exports.O=c;const u={EMAIL_SIGNIN:"EMAIL_SIGNIN",PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",REVERT_SECOND_FACTOR_ADDITION:"REVERT_SECOND_FACTOR_ADDITION",VERIFY_AND_CHANGE_EMAIL:"VERIFY_AND_CHANGE_EMAIL",VERIFY_EMAIL:"VERIFY_EMAIL"};function d(){return{"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-change-needs-verification":"Multi-factor users must always have a verified email.","email-already-in-use":"The email address is already in use by another account.","emulator-config-failed":'Auth instance has already been used to make a network call. Auth can no longer be configured to use the emulator. Try calling "connectAuthEmulator()" sooner.',"expired-action-code":"The action code has expired.","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal AuthError has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registed for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal AuthError has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure to use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-emulator-scheme":"Emulator URL must start with a valid scheme (http:// or https://).","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-multi-factor-session":"The request does not contain a valid proof of first factor successful sign-in.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","login-blocked":"Login blocked by user-provided method: {$originalMessage}","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal AuthError has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-multi-factor-info":"No second factor identifier is provided.","missing-multi-factor-session":"The request is missing proof of first factor successful sign-in.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","multi-factor-info-not-found":"The user does not have a second factor matching the identifier provided.","multi-factor-auth-required":"Proof of ownership of a second factor is required to complete sign-in.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal AuthError has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","second-factor-already-in-use":"The second factor is already enrolled on this account.","maximum-second-factor-count-exceeded":"The maximum allowed number of second factors on a user has been exceeded.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.","unsupported-first-factor":"Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","unverified-email":"The operation requires a verified email.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled.","already-initialized":"initializeAuth() has already been called with different options. To avoid this error, call initializeAuth() with the same options as when it was originally called, or call getAuth() to return the already initialized instance."}}function l(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}exports.A=u;const h=d;exports.B=h;const p=l;exports.C=p;const m=new e.ErrorFactory("auth","Firebase",l()),f={ADMIN_ONLY_OPERATION:"auth/admin-restricted-operation",ARGUMENT_ERROR:"auth/argument-error",APP_NOT_AUTHORIZED:"auth/app-not-authorized",APP_NOT_INSTALLED:"auth/app-not-installed",CAPTCHA_CHECK_FAILED:"auth/captcha-check-failed",CODE_EXPIRED:"auth/code-expired",CORDOVA_NOT_READY:"auth/cordova-not-ready",CORS_UNSUPPORTED:"auth/cors-unsupported",CREDENTIAL_ALREADY_IN_USE:"auth/credential-already-in-use",CREDENTIAL_MISMATCH:"auth/custom-token-mismatch",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"auth/requires-recent-login",DEPENDENT_SDK_INIT_BEFORE_AUTH:"auth/dependent-sdk-initialized-before-auth",DYNAMIC_LINK_NOT_ACTIVATED:"auth/dynamic-link-not-activated",EMAIL_CHANGE_NEEDS_VERIFICATION:"auth/email-change-needs-verification",EMAIL_EXISTS:"auth/email-already-in-use",EMULATOR_CONFIG_FAILED:"auth/emulator-config-failed",EXPIRED_OOB_CODE:"auth/expired-action-code",EXPIRED_POPUP_REQUEST:"auth/cancelled-popup-request",INTERNAL_ERROR:"auth/internal-error",INVALID_API_KEY:"auth/invalid-api-key",INVALID_APP_CREDENTIAL:"auth/invalid-app-credential",INVALID_APP_ID:"auth/invalid-app-id",INVALID_AUTH:"auth/invalid-user-token",INVALID_AUTH_EVENT:"auth/invalid-auth-event",INVALID_CERT_HASH:"auth/invalid-cert-hash",INVALID_CODE:"auth/invalid-verification-code",INVALID_CONTINUE_URI:"auth/invalid-continue-uri",INVALID_CORDOVA_CONFIGURATION:"auth/invalid-cordova-configuration",INVALID_CUSTOM_TOKEN:"auth/invalid-custom-token",INVALID_DYNAMIC_LINK_DOMAIN:"auth/invalid-dynamic-link-domain",INVALID_EMAIL:"auth/invalid-email",INVALID_EMULATOR_SCHEME:"auth/invalid-emulator-scheme",INVALID_IDP_RESPONSE:"auth/invalid-credential",INVALID_MESSAGE_PAYLOAD:"auth/invalid-message-payload",INVALID_MFA_SESSION:"auth/invalid-multi-factor-session",INVALID_OAUTH_CLIENT_ID:"auth/invalid-oauth-client-id",INVALID_OAUTH_PROVIDER:"auth/invalid-oauth-provider",INVALID_OOB_CODE:"auth/invalid-action-code",INVALID_ORIGIN:"auth/unauthorized-domain",INVALID_PASSWORD:"auth/wrong-password",INVALID_PERSISTENCE:"auth/invalid-persistence-type",INVALID_PHONE_NUMBER:"auth/invalid-phone-number",INVALID_PROVIDER_ID:"auth/invalid-provider-id",INVALID_RECIPIENT_EMAIL:"auth/invalid-recipient-email",INVALID_SENDER:"auth/invalid-sender",INVALID_SESSION_INFO:"auth/invalid-verification-id",INVALID_TENANT_ID:"auth/invalid-tenant-id",MFA_INFO_NOT_FOUND:"auth/multi-factor-info-not-found",MFA_REQUIRED:"auth/multi-factor-auth-required",MISSING_ANDROID_PACKAGE_NAME:"auth/missing-android-pkg-name",MISSING_APP_CREDENTIAL:"auth/missing-app-credential",MISSING_AUTH_DOMAIN:"auth/auth-domain-config-required",MISSING_CODE:"auth/missing-verification-code",MISSING_CONTINUE_URI:"auth/missing-continue-uri",MISSING_IFRAME_START:"auth/missing-iframe-start",MISSING_IOS_BUNDLE_ID:"auth/missing-ios-bundle-id",MISSING_OR_INVALID_NONCE:"auth/missing-or-invalid-nonce",MISSING_MFA_INFO:"auth/missing-multi-factor-info",MISSING_MFA_SESSION:"auth/missing-multi-factor-session",MISSING_PHONE_NUMBER:"auth/missing-phone-number",MISSING_SESSION_INFO:"auth/missing-verification-id",MODULE_DESTROYED:"auth/app-deleted",NEED_CONFIRMATION:"auth/account-exists-with-different-credential",NETWORK_REQUEST_FAILED:"auth/network-request-failed",NULL_USER:"auth/null-user",NO_AUTH_EVENT:"auth/no-auth-event",NO_SUCH_PROVIDER:"auth/no-such-provider",OPERATION_NOT_ALLOWED:"auth/operation-not-allowed",OPERATION_NOT_SUPPORTED:"auth/operation-not-supported-in-this-environment",POPUP_BLOCKED:"auth/popup-blocked",POPUP_CLOSED_BY_USER:"auth/popup-closed-by-user",PROVIDER_ALREADY_LINKED:"auth/provider-already-linked",QUOTA_EXCEEDED:"auth/quota-exceeded",REDIRECT_CANCELLED_BY_USER:"auth/redirect-cancelled-by-user",REDIRECT_OPERATION_PENDING:"auth/redirect-operation-pending",REJECTED_CREDENTIAL:"auth/rejected-credential",SECOND_FACTOR_ALREADY_ENROLLED:"auth/second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"auth/maximum-second-factor-count-exceeded",TENANT_ID_MISMATCH:"auth/tenant-id-mismatch",TIMEOUT:"auth/timeout",TOKEN_EXPIRED:"auth/user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"auth/too-many-requests",UNAUTHORIZED_DOMAIN:"auth/unauthorized-continue-uri",UNSUPPORTED_FIRST_FACTOR:"auth/unsupported-first-factor",UNSUPPORTED_PERSISTENCE:"auth/unsupported-persistence-type",UNSUPPORTED_TENANT_OPERATION:"auth/unsupported-tenant-operation",UNVERIFIED_EMAIL:"auth/unverified-email",USER_CANCELLED:"auth/user-cancelled",USER_DELETED:"auth/user-not-found",USER_DISABLED:"auth/user-disabled",USER_MISMATCH:"auth/user-mismatch",USER_SIGNED_OUT:"auth/user-signed-out",WEAK_PASSWORD:"auth/weak-password",WEB_STORAGE_UNSUPPORTED:"auth/web-storage-unsupported",ALREADY_INITIALIZED:"auth/already-initialized"};exports.D=f;const g=new n.Logger("@firebase/auth");function v(e,...i){g.logLevel<=n.LogLevel.ERROR&&g.error(`Auth (${t.SDK_VERSION}): ${e}`,...i)}function I(e,...t){throw w(e,...t)}function _(e,...t){return w(e,...t)}function y(t,n,i){const r=Object.assign(Object.assign({},p()),{[n]:i});return new e.ErrorFactory("auth","Firebase",r).create(n,{appName:t.name})}function T(e,t,n){if(!(t instanceof n))throw n.name!==t.constructor.name&&I(e,"argument-error"),y(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.`+"Did you pass a reference from a different Auth SDK?")}function w(e,...t){if("string"!=typeof e){const n=t[0],i=[...t.slice(1)];return i[0]&&(i[0].appName=e.name),e._errorFactory.create(n,...i)}return m.create(e,...t)}function E(e,t,...n){if(!e)throw w(t,...n)}function k(e){const t="INTERNAL ASSERTION FAILED: "+e;throw v(t),new Error(t)}function A(e,t){e||k(t)}const R=new Map;function N(e){A(e instanceof Function,"Expected a class definition");let t=R.get(e);return t?(A(t instanceof e,"Instance stored in cache mismatched with class"),t):(t=new e,R.set(e,t),t)}function b(n,i){const r=(0,t._getProvider)(n,"auth");if(r.isInitialized()){const t=r.getImmediate(),n=r.getOptions();if((0,e.deepEqual)(n,null!=i?i:{}))return t;I(t,"already-initialized")}return r.initialize({options:i})}function S(e,t){const n=(null==t?void 0:t.persistence)||[],i=(Array.isArray(n)?n:[n]).map(N);(null==t?void 0:t.errorMap)&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(i,null==t?void 0:t.popupRedirectResolver)}function O(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.href)||""}function P(){return"http:"===D()||"https:"===D()}function D(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.protocol)||null}function C(){return!("undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(P()||(0,e.isBrowserExtension)()||"connection"in navigator))||navigator.onLine}function L(){if("undefined"==typeof navigator)return null;const e=navigator;return e.languages&&e.languages[0]||e.language||null}class M{constructor(t,n){this.shortDelay=t,this.longDelay=n,A(n>t,"Short delay should be less than long delay!"),this.isMobile=(0,e.isMobileCordova)()||(0,e.isReactNative)()}get(){return C()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function x(e,t){A(e.emulator,"Emulator should always be set here");const{url:n}=e.emulator;return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}class U{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:void k("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){return this.headersImpl?this.headersImpl:"undefined"!=typeof self&&"Headers"in self?self.Headers:void k("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){return this.responseImpl?this.responseImpl:"undefined"!=typeof self&&"Response"in self?self.Response:void k("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}exports.aK=U;const F={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error"},V=new M(3e4,6e4);function q(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function j(t,n,i,r,s={}){return H(t,s,async()=>{let s={},o={};r&&("GET"===n?o=r:s={body:JSON.stringify(r)});const a=(0,e.querystring)(Object.assign({key:t.config.apiKey},o)).slice(1),c=await t._getAdditionalHeaders();return c["Content-Type"]="application/json",t.languageCode&&(c["X-Firebase-Locale"]=t.languageCode),U.fetch()(G(t,t.config.apiHost,i,a),Object.assign({method:n,headers:c,referrerPolicy:"no-referrer"},s))})}async function H(t,n,i){t._canInitEmulator=!1;const r=Object.assign(Object.assign({},F),n);try{const n=new W(t),o=await Promise.race([i(),n.promise]);n.clearNetworkTimeout();const a=await o.json();if("needConfirmation"in a)throw K(t,"account-exists-with-different-credential",a);if(o.ok&&!("errorMessage"in a))return a;{const e=o.ok?a.errorMessage:a.error.message,[n,i]=e.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw K(t,"credential-already-in-use",a);if("EMAIL_EXISTS"===n)throw K(t,"email-already-in-use",a);if("USER_DISABLED"===n)throw K(t,"user-disabled",a);const s=r[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(i)throw y(t,s,i);I(t,s)}}catch(s){if(s instanceof e.FirebaseError)throw s;I(t,"internal-error",{message:String(s)})}}async function z(e,t,n,i,r={}){const s=await j(e,t,n,i,r);return"mfaPendingCredential"in s&&I(e,"multi-factor-auth-required",{_serverResponse:s}),s}function G(e,t,n,i){const r=`${t}${n}?${i}`;return e.config.emulator?x(e.config,r):`${e.config.apiScheme}://${r}`}class W{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(_(this.auth,"network-request-failed")),V.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function K(e,t,n){const i={appName:e.name};n.email&&(i.email=n.email),n.phoneNumber&&(i.phoneNumber=n.phoneNumber);const r=_(e,t,i);return r.customData._tokenResponse=n,r}async function B(e,t){return j(e,"POST","/v1/accounts:delete",t)}async function J(e,t){return j(e,"POST","/v1/accounts:update",t)}async function $(e,t){return j(e,"POST","/v1/accounts:lookup",t)}function Y(e){if(e)try{const n=new Date(Number(e));if(!isNaN(n.getTime()))return n.toUTCString()}catch(t){}}function X(t,n=!1){return(0,e.getModularInstance)(t).getIdToken(n)}async function Q(t,n=!1){const i=(0,e.getModularInstance)(t),r=await i.getIdToken(n),s=ee(r);E(s&&s.exp&&s.auth_time&&s.iat,i.auth,"internal-error");const o="object"==typeof s.firebase?s.firebase:void 0,a=null==o?void 0:o.sign_in_provider;return{claims:s,token:r,authTime:Y(Z(s.auth_time)),issuedAtTime:Y(Z(s.iat)),expirationTime:Y(Z(s.exp)),signInProvider:a||null,signInSecondFactor:(null==o?void 0:o.sign_in_second_factor)||null}}function Z(e){return 1e3*Number(e)}function ee(t){const[n,i,r]=t.split(".");if(void 0===n||void 0===i||void 0===r)return v("JWT malformed, contained fewer than 3 sections"),null;try{const t=(0,e.base64Decode)(i);return t?JSON.parse(t):(v("Failed to decode base64 JWT payload"),null)}catch(s){return v("Caught error parsing JWT payload as JSON",null==s?void 0:s.toString()),null}}function te(e){const t=ee(e);return E(t,"internal-error"),E(void 0!==t.exp,"internal-error"),E(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}async function ne(t,n,i=!1){if(i)return n;try{return await n}catch(r){throw r instanceof e.FirebaseError&&ie(r)&&t.auth.currentUser===t&&await t.auth.signOut(),r}}function ie({code:e}){return"auth/user-disabled"===e||"auth/user-token-expired"===e}class re{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,null!==this.timerId&&clearTimeout(this.timerId))}getInterval(e){var t;if(e){const e=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e}{this.errorBackoff=3e4;const e=(null!==(t=this.user.stsTokenManager.expirationTime)&&void 0!==t?t:0)-Date.now()-3e5;return Math.max(0,e)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){return void("auth/network-request-failed"===(null==e?void 0:e.code)&&this.schedule(!0))}this.schedule()}}class se{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Y(this.lastLoginAt),this.creationTime=Y(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function oe(e){var t;const n=e.auth,i=await e.getIdToken(),r=await ne(e,$(n,{idToken:i}));E(null==r?void 0:r.users.length,n,"internal-error");const s=r.users[0];e._notifyReloadListener(s);const o=(null===(t=s.providerUserInfo)||void 0===t?void 0:t.length)?ue(s.providerUserInfo):[],a=ce(e.providerData,o),c=e.isAnonymous,u=!(e.email&&s.passwordHash||(null==a?void 0:a.length)),d=!!c&&u,l={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:a,metadata:new se(s.createdAt,s.lastLoginAt),isAnonymous:d};Object.assign(e,l)}async function ae(t){const n=(0,e.getModularInstance)(t);await oe(n),await n.auth._persistUserIfCurrent(n),n.auth._notifyListenersIfCurrent(n)}function ce(e,t){return[...e.filter(e=>!t.some(t=>t.providerId===e.providerId)),...t]}function ue(e){return e.map(e=>{var{providerId:t}=e,n=(0,i.__rest)(e,["providerId"]);return{providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}})}async function de(t,n){const i=await H(t,{},async()=>{const i=(0,e.querystring)({grant_type:"refresh_token",refresh_token:n}).slice(1),{tokenApiHost:r,apiKey:s}=t.config,o=G(t,r,"/v1/token",`key=${s}`),a=await t._getAdditionalHeaders();return a["Content-Type"]="application/x-www-form-urlencoded",U.fetch()(o,{method:"POST",headers:a,body:i})});return{accessToken:i.access_token,expiresIn:i.expires_in,refreshToken:i.refresh_token}}class le{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){E(e.idToken,"internal-error"),E(void 0!==e.idToken,"internal-error"),E(void 0!==e.refreshToken,"internal-error");const t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):te(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}async getToken(e,t=!1){return E(!this.accessToken||this.refreshToken,e,"user-token-expired"),t||!this.accessToken||this.isExpired?this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null:this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:n,refreshToken:i,expiresIn:r}=await de(e,t);this.updateTokensAndExpiration(n,i,Number(r))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(e,t){const{refreshToken:n,accessToken:i,expirationTime:r}=t,s=new le;return n&&(E("string"==typeof n,"internal-error",{appName:e}),s.refreshToken=n),i&&(E("string"==typeof i,"internal-error",{appName:e}),s.accessToken=i),r&&(E("number"==typeof r,"internal-error",{appName:e}),s.expirationTime=r),s}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new le,this.toJSON())}_performRefresh(){return k("not implemented")}}function he(e,t){E("string"==typeof e||void 0===e,"internal-error",{appName:t})}class pe{constructor(e){var{uid:t,auth:n,stsTokenManager:r}=e,s=(0,i.__rest)(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new re(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new se(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const t=await ne(this,this.stsTokenManager.getToken(this.auth,e));return E(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return Q(this,e)}reload(){return ae(this)}_assign(e){this!==e&&(E(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(e=>Object.assign({},e)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new pe(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){E(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let n=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),t&&await oe(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){const e=await this.getIdToken();return await ne(this,B(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var n,i,r,s,o,a,c,u;const d=null!==(n=t.displayName)&&void 0!==n?n:void 0,l=null!==(i=t.email)&&void 0!==i?i:void 0,h=null!==(r=t.phoneNumber)&&void 0!==r?r:void 0,p=null!==(s=t.photoURL)&&void 0!==s?s:void 0,m=null!==(o=t.tenantId)&&void 0!==o?o:void 0,f=null!==(a=t._redirectEventId)&&void 0!==a?a:void 0,g=null!==(c=t.createdAt)&&void 0!==c?c:void 0,v=null!==(u=t.lastLoginAt)&&void 0!==u?u:void 0,{uid:I,emailVerified:_,isAnonymous:y,providerData:T,stsTokenManager:w}=t;E(I&&w,e,"internal-error");const k=le.fromJSON(this.name,w);E("string"==typeof I,e,"internal-error"),he(d,e.name),he(l,e.name),E("boolean"==typeof _,e,"internal-error"),E("boolean"==typeof y,e,"internal-error"),he(h,e.name),he(p,e.name),he(m,e.name),he(f,e.name),he(g,e.name),he(v,e.name);const A=new pe({uid:I,auth:e,email:l,emailVerified:_,displayName:d,isAnonymous:y,photoURL:p,phoneNumber:h,tenantId:m,stsTokenManager:k,createdAt:g,lastLoginAt:v});return T&&Array.isArray(T)&&(A.providerData=T.map(e=>Object.assign({},e))),f&&(A._redirectEventId=f),A}static async _fromIdTokenResponse(e,t,n=!1){const i=new le;i.updateFromServerResponse(t);const r=new pe({uid:t.localId,auth:e,stsTokenManager:i,isAnonymous:n});return await oe(r),r}}exports.aF=pe;class me{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}me.type="NONE";const fe=me;function ge(e,t,n){return`firebase:${e}:${t}:${n}`}exports.L=fe;class ve{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;const{config:i,name:r}=this.auth;this.fullUserKey=ge(this.userKey,i.apiKey,r),this.fullPersistenceKey=ge("persistence",i.apiKey,r),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);return e?pe._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=e,t?this.setCurrentUser(t):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,n="authUser"){if(!t.length)return new ve(N(fe),e,n);const i=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let r=i[0]||N(fe);const s=ge(n,e.config.apiKey,e.name);let o=null;for(const u of t)try{const t=await u._get(s);if(t){const n=pe._fromJSON(e,t);u!==r&&(o=n),r=u;break}}catch(c){}const a=i.filter(e=>e._shouldAllowMigration);return r._shouldAllowMigration&&a.length?(r=a[0],o&&await r._set(s,o.toJSON()),await Promise.all(t.map(async e=>{if(e!==r)try{await e._remove(s)}catch(c){}})),new ve(r,e,n)):new ve(r,e,n)}}function Ie(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(we(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(_e(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(ke(t))return"Blackberry";if(Ae(t))return"Webos";if(ye(t))return"Safari";if((t.includes("chrome/")||Te(t))&&!t.includes("edge/"))return"Chrome";if(Ee(t))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=e.match(t);if(2===(null==n?void 0:n.length))return n[1]}return"Other"}function _e(t=(0,e.getUA)()){return/firefox\//i.test(t)}function ye(t=(0,e.getUA)()){const n=t.toLowerCase();return n.includes("safari/")&&!n.includes("chrome/")&&!n.includes("crios/")&&!n.includes("android")}function Te(t=(0,e.getUA)()){return/crios\//i.test(t)}function we(t=(0,e.getUA)()){return/iemobile/i.test(t)}function Ee(t=(0,e.getUA)()){return/android/i.test(t)}function ke(t=(0,e.getUA)()){return/blackberry/i.test(t)}function Ae(t=(0,e.getUA)()){return/webos/i.test(t)}function Re(t=(0,e.getUA)()){return/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&/mobile/i.test(t)}function Ne(t=(0,e.getUA)()){return/(iPad|iPhone|iPod).*OS 7_\d/i.test(t)||/(iPad|iPhone|iPod).*OS 8_\d/i.test(t)}function be(t=(0,e.getUA)()){var n;return Re(t)&&!!(null===(n=window.navigator)||void 0===n?void 0:n.standalone)}function Se(){return(0,e.isIE)()&&10===document.documentMode}function Oe(t=(0,e.getUA)()){return Re(t)||Ee(t)||Ae(t)||ke(t)||/windows phone/i.test(t)||we(t)}function Pe(){try{return!(!window||window===window.top)}catch(e){return!1}}function De(n,i=[]){let r;switch(n){case"Browser":r=Ie((0,e.getUA)());break;case"Worker":r=`${Ie((0,e.getUA)())}-${n}`;break;default:r=n}const s=i.length?i.join(","):"FirebaseCore-web";return`${r}/JsCore/${t.SDK_VERSION}/${s}`}class Ce{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const n=t=>new Promise((n,i)=>{try{n(e(t))}catch(r){i(r)}});n.onAbort=t,this.queue.push(n);const i=this.queue.length-1;return()=>{this.queue[i]=(()=>Promise.resolve())}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const n of this.queue)await n(e),n.onAbort&&t.push(n.onAbort)}catch(n){t.reverse();for(const e of t)try{e()}catch(i){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:null==n?void 0:n.message})}}}class Le{constructor(e,t,n){this.app=e,this.heartbeatServiceProvider=t,this.config=n,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new xe(this),this.idTokenSubscription=new xe(this),this.beforeStateQueue=new Ce(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=m,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=n.sdkClientVersion}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=N(t)),this._initializationPromise=this.queue(async()=>{var n,i;if(!this._deleted&&(this.persistenceManager=await ve.create(this,e),!this._deleted)){if(null===(n=this._popupRedirectResolver)||void 0===n?void 0:n._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(r){}await this.initializeCurrentUser(t),this.lastNotifiedUid=(null===(i=this.currentUser)||void 0===i?void 0:i.uid)||null,this._deleted||(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();return this.currentUser||e?this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),void(await this.currentUser.getIdToken())):void(await this._updateCurrentUser(e,!0)):void 0}async initializeCurrentUser(e){var t;const n=await this.assertedPersistence.getCurrentUser();let i=n,r=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const n=null===(t=this.redirectUser)||void 0===t?void 0:t._redirectEventId,s=null==i?void 0:i._redirectEventId,o=await this.tryRedirectSignIn(e);n&&n!==s||null==o||!o.user||(i=o.user,r=!0)}if(!i)return this.directlySetCurrentUser(null);if(!i._redirectEventId){if(r)try{await this.beforeStateQueue.runMiddleware(i)}catch(s){i=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(s))}return i?this.reloadAndSetCurrentUserOrClear(i):this.directlySetCurrentUser(null)}return E(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===i._redirectEventId?this.directlySetCurrentUser(i):this.reloadAndSetCurrentUserOrClear(i)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch(n){await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await oe(e)}catch(t){if("auth/network-request-failed"!==(null==t?void 0:t.code))return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=L()}async _delete(){this._deleted=!0}async updateCurrentUser(t){const n=t?(0,e.getModularInstance)(t):null;return n&&E(n.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(n&&n._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&E(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0)}setPersistence(e){return this.queue(async()=>{await this.assertedPersistence.setPersistence(N(e))})}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(t){this._errorFactory=new e.ErrorFactory("auth","Firebase",t())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null===(e=this._currentUser)||void 0===e?void 0:e.toJSON()}}async _setRedirectUser(e,t){const n=await this.getOrInitRedirectPersistenceManager(t);return null===e?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&N(e)||this._popupRedirectResolver;E(t,this,"argument-error"),this.redirectPersistenceManager=await ve.create(this,[N(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,n;return this._isInitialized&&await this.queue(async()=>{}),(null===(t=this._currentUser)||void 0===t?void 0:t._redirectEventId)===e?this._currentUser:(null===(n=this.redirectUser)||void 0===n?void 0:n._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const n=null!==(t=null===(e=this.currentUser)||void 0===e?void 0:e.uid)&&void 0!==t?t:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,n,i){if(this._deleted)return()=>{};const r="function"==typeof t?t:t.next.bind(t),s=this._isInitialized?Promise.resolve():this._initializationPromise;return E(s,this,"internal-error"),s.then(()=>r(this.currentUser)),"function"==typeof t?e.addObserver(t,n,i):e.addObserver(t)}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return E(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=De(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const n=await(null===(e=this.heartbeatServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getHeartbeatsHeader());return n&&(t["X-Firebase-Client"]=n),t}}function Me(t){return(0,e.getModularInstance)(t)}exports.aG=Le;class xe{constructor(t){this.auth=t,this.observer=null,this.addObserver=(0,e.createSubscribe)(e=>this.observer=e)}get next(){return E(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}function Ue(e,t,n){const i=Me(e);E(i._canInitEmulator,i,"emulator-config-failed"),E(/^https?:\/\//.test(t),i,"invalid-emulator-scheme");const r=!!(null==n?void 0:n.disableWarnings),s=Fe(t),{host:o,port:a}=Ve(t),c=null===a?"":`:${a}`;i.config.emulator={url:`${s}//${o}${c}/`},i.settings.appVerificationDisabledForTesting=!0,i.emulatorConfig=Object.freeze({host:o,port:a,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:r})}),r||je()}function Fe(e){const t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function Ve(e){const t=Fe(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};const i=n[2].split("@").pop()||"",r=/^(\[[^\]]+\])(:|$)/.exec(i);if(r){const e=r[1];return{host:e,port:qe(i.substr(e.length+1))}}{const[e,t]=i.split(":");return{host:e,port:qe(t)}}}function qe(e){if(!e)return null;const t=Number(e);return isNaN(t)?null:t}function je(){function e(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}"undefined"!=typeof console&&"function"==typeof console.info&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),"undefined"!=typeof window&&"undefined"!=typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",e):e())}class He{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return k("not implemented")}_getIdTokenResponse(e){return k("not implemented")}_linkToIdToken(e,t){return k("not implemented")}_getReauthenticationResolver(e){return k("not implemented")}}async function ze(e,t){return j(e,"POST","/v1/accounts:resetPassword",q(e,t))}async function Ge(e,t){return j(e,"POST","/v1/accounts:update",t)}async function We(e,t){return j(e,"POST","/v1/accounts:update",q(e,t))}async function Ke(e,t){return z(e,"POST","/v1/accounts:signInWithPassword",q(e,t))}async function Be(e,t){return j(e,"POST","/v1/accounts:sendOobCode",q(e,t))}async function Je(e,t){return Be(e,t)}async function $e(e,t){return Be(e,t)}async function Ye(e,t){return Be(e,t)}async function Xe(e,t){return Be(e,t)}async function Qe(e,t){return z(e,"POST","/v1/accounts:signInWithEmailLink",q(e,t))}async function Ze(e,t){return z(e,"POST","/v1/accounts:signInWithEmailLink",q(e,t))}exports.H=He;class et extends He{constructor(e,t,n,i=null){super("password",n),this._email=e,this._password=t,this._tenantId=i}static _fromEmailAndPassword(e,t){return new et(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new et(e,t,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t="string"==typeof e?JSON.parse(e):e;if((null==t?void 0:t.email)&&(null==t?void 0:t.password)){if("password"===t.signInMethod)return this._fromEmailAndPassword(t.email,t.password);if("emailLink"===t.signInMethod)return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":return Ke(e,{returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return Qe(e,{email:this._email,oobCode:this._password});default:I(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return Ge(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password});case"emailLink":return Ze(e,{idToken:t,email:this._email,oobCode:this._password});default:I(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function tt(e,t){return z(e,"POST","/v1/accounts:signInWithIdp",q(e,t))}exports.I=et;const nt="http://localhost";class it extends He{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new it(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):I("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:r}=t,s=(0,i.__rest)(t,["providerId","signInMethod"]);if(!n||!r)return null;const o=new it(n,r);return o.idToken=s.idToken||void 0,o.accessToken=s.accessToken||void 0,o.secret=s.secret,o.nonce=s.nonce,o.pendingToken=s.pendingToken||null,o}_getIdTokenResponse(e){return tt(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,tt(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,tt(e,t)}buildRequest(){const t={requestUri:nt,returnSecureToken:!0};if(this.pendingToken)t.pendingToken=this.pendingToken;else{const n={};this.idToken&&(n.id_token=this.idToken),this.accessToken&&(n.access_token=this.accessToken),this.secret&&(n.oauth_token_secret=this.secret),n.providerId=this.providerId,this.nonce&&!this.pendingToken&&(n.nonce=this.nonce),t.postBody=(0,e.querystring)(n)}return t}}async function rt(e,t){return j(e,"POST","/v1/accounts:sendVerificationCode",q(e,t))}async function st(e,t){return z(e,"POST","/v1/accounts:signInWithPhoneNumber",q(e,t))}async function ot(e,t){const n=await z(e,"POST","/v1/accounts:signInWithPhoneNumber",q(e,t));if(n.temporaryProof)throw K(e,"account-exists-with-different-credential",n);return n}exports.J=it;const at={USER_NOT_FOUND:"user-not-found"};async function ct(e,t){return z(e,"POST","/v1/accounts:signInWithPhoneNumber",q(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),at)}class ut extends He{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new ut({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new ut({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return st(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return ot(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return ct(e,this._makeVerificationRequest())}_makeVerificationRequest(){const{temporaryProof:e,phoneNumber:t,verificationId:n,verificationCode:i}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:n,code:i}}toJSON(){const e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(e){"string"==typeof e&&(e=JSON.parse(e));const{verificationId:t,verificationCode:n,phoneNumber:i,temporaryProof:r}=e;return n||t||i||r?new ut({verificationId:t,verificationCode:n,phoneNumber:i,temporaryProof:r}):null}}function dt(e){switch(e){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function lt(t){const n=(0,e.querystringDecode)((0,e.extractQuerystring)(t)).link,i=n?(0,e.querystringDecode)((0,e.extractQuerystring)(n)).deep_link_id:null,r=(0,e.querystringDecode)((0,e.extractQuerystring)(t)).deep_link_id;return(r?(0,e.querystringDecode)((0,e.extractQuerystring)(r)).link:null)||r||i||n||t}exports.K=ut;class ht{constructor(t){var n,i,r,s,o,a;const c=(0,e.querystringDecode)((0,e.extractQuerystring)(t)),u=null!==(n=c.apiKey)&&void 0!==n?n:null,d=null!==(i=c.oobCode)&&void 0!==i?i:null,l=dt(null!==(r=c.mode)&&void 0!==r?r:null);E(u&&d&&l,"argument-error"),this.apiKey=u,this.operation=l,this.code=d,this.continueUrl=null!==(s=c.continueUrl)&&void 0!==s?s:null,this.languageCode=null!==(o=c.languageCode)&&void 0!==o?o:null,this.tenantId=null!==(a=c.tenantId)&&void 0!==a?a:null}static parseLink(e){const t=lt(e);try{return new ht(t)}catch(n){return null}}}function pt(e){return ht.parseLink(e)}exports.ad=ht;class mt{constructor(){this.providerId=mt.PROVIDER_ID}static credential(e,t){return et._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const n=ht.parseLink(t);return E(n,"argument-error"),et._fromEmailAndCode(e,n.code,n.tenantId)}}exports.M=mt,mt.PROVIDER_ID="password",mt.EMAIL_PASSWORD_SIGN_IN_METHOD="password",mt.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class ft{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}class gt extends ft{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class vt extends gt{static credentialFromJSON(e){const t="string"==typeof e?JSON.parse(e):e;return E("providerId"in t&&"signInMethod"in t,"argument-error"),it._fromParams(t)}credential(e){return this._credential(Object.assign(Object.assign({},e),{nonce:e.rawNonce}))}_credential(e){return E(e.idToken||e.accessToken,"argument-error"),it._fromParams(Object.assign(Object.assign({},e),{providerId:this.providerId,signInMethod:this.providerId}))}static credentialFromResult(e){return vt.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return vt.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n,oauthTokenSecret:i,pendingToken:r,nonce:s,providerId:o}=e;if(!(n||i||t||r))return null;if(!o)return null;try{return new vt(o)._credential({idToken:t,accessToken:n,nonce:s,pendingToken:r})}catch(a){return null}}}exports.U=vt;class It extends gt{constructor(){super("facebook.com")}static credential(e){return it._fromParams({providerId:It.PROVIDER_ID,signInMethod:It.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return It.credentialFromTaggedObject(e)}static credentialFromError(e){return It.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return It.credential(e.oauthAccessToken)}catch(t){return null}}}exports.N=It,It.FACEBOOK_SIGN_IN_METHOD="facebook.com",It.PROVIDER_ID="facebook.com";class _t extends gt{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return it._fromParams({providerId:_t.PROVIDER_ID,signInMethod:_t.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return _t.credentialFromTaggedObject(e)}static credentialFromError(e){return _t.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return _t.credential(t,n)}catch(i){return null}}}exports.Q=_t,_t.GOOGLE_SIGN_IN_METHOD="google.com",_t.PROVIDER_ID="google.com";class yt extends gt{constructor(){super("github.com")}static credential(e){return it._fromParams({providerId:yt.PROVIDER_ID,signInMethod:yt.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return yt.credentialFromTaggedObject(e)}static credentialFromError(e){return yt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!(e&&"oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return yt.credential(e.oauthAccessToken)}catch(t){return null}}}exports.T=yt,yt.GITHUB_SIGN_IN_METHOD="github.com",yt.PROVIDER_ID="github.com";const Tt="http://localhost";class wt extends He{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return tt(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,tt(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,tt(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(e){const t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:i,pendingToken:r}=t;return n&&i&&r&&n===i?new wt(n,r):null}static _create(e,t){return new wt(e,t)}buildRequest(){return{requestUri:Tt,returnSecureToken:!0,pendingToken:this.pendingToken}}}exports.aL=wt;const Et="saml.";class kt extends ft{constructor(e){E(e.startsWith(Et),"argument-error"),super(e)}static credentialFromResult(e){return kt.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return kt.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){const t=wt.fromJSON(e);return E(t,"argument-error"),t}static samlCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{pendingToken:t,providerId:n}=e;if(!t||!n)return null;try{return wt._create(n,t)}catch(i){return null}}}exports.V=kt;class At extends gt{constructor(){super("twitter.com")}static credential(e,t){return it._fromParams({providerId:At.PROVIDER_ID,signInMethod:At.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return At.credentialFromTaggedObject(e)}static credentialFromError(e){return At.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return At.credential(t,n)}catch(i){return null}}}async function Rt(e,t){return z(e,"POST","/v1/accounts:signUp",q(e,t))}exports.W=At,At.TWITTER_SIGN_IN_METHOD="twitter.com",At.PROVIDER_ID="twitter.com";class Nt{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,i=!1){const r=await pe._fromIdTokenResponse(e,n,i),s=bt(n);return new Nt({user:r,providerId:s,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);const i=bt(n);return new Nt({user:e,providerId:i,_tokenResponse:n,operationType:t})}}function bt(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}async function St(e){var t;const n=Me(e);if(await n._initializationPromise,null===(t=n.currentUser)||void 0===t?void 0:t.isAnonymous)return new Nt({user:n.currentUser,providerId:null,operationType:"signIn"});const i=await Rt(n,{returnSecureToken:!0}),r=await Nt._fromIdTokenResponse(n,"signIn",i,!0);return await n._updateCurrentUser(r.user),r}class Ot extends e.FirebaseError{constructor(e,t,n,i){var r;super(t.code,t.message),this.operationType=n,this.user=i,Object.setPrototypeOf(this,Ot.prototype),this.customData={appName:e.name,tenantId:null!==(r=e.tenantId)&&void 0!==r?r:void 0,_serverResponse:t.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(e,t,n,i){return new Ot(e,t,n,i)}}function Pt(e,t,n,i){return("reauthenticate"===t?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(n=>{if("auth/multi-factor-auth-required"===n.code)throw Ot._fromErrorAndOperation(e,n,t,i);throw n})}function Dt(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function Ct(t,n){const i=(0,e.getModularInstance)(t);await Mt(!0,i,n);const{providerUserInfo:r}=await J(i.auth,{idToken:await i.getIdToken(),deleteProvider:[n]}),s=Dt(r||[]);return i.providerData=i.providerData.filter(e=>s.has(e.providerId)),s.has("phone")||(i.phoneNumber=null),await i.auth._persistUserIfCurrent(i),i}async function Lt(e,t,n=!1){const i=await ne(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return Nt._forOperation(e,"link",i)}async function Mt(e,t,n){await oe(t);const i=!1===e?"provider-already-linked":"no-such-provider";E(Dt(t.providerData).has(n)===e,t.auth,i)}async function xt(e,t,n=!1){const{auth:i}=e;try{const s=await ne(e,Pt(i,"reauthenticate",t,e),n);E(s.idToken,i,"internal-error");const o=ee(s.idToken);E(o,i,"internal-error");const{sub:a}=o;return E(e.uid===a,i,"user-mismatch"),Nt._forOperation(e,"reauthenticate",s)}catch(r){throw"auth/user-not-found"===(null==r?void 0:r.code)&&I(i,"user-mismatch"),r}}async function Ut(e,t,n=!1){const i=await Pt(e,"signIn",t),r=await Nt._fromIdTokenResponse(e,"signIn",i);return n||await e._updateCurrentUser(r.user),r}async function Ft(e,t){return Ut(Me(e),t)}async function Vt(t,n){const i=(0,e.getModularInstance)(t);return await Mt(!1,i,n.providerId),Lt(i,n)}async function qt(t,n){return xt((0,e.getModularInstance)(t),n)}async function jt(e,t){return z(e,"POST","/v1/accounts:signInWithCustomToken",q(e,t))}async function Ht(e,t){const n=Me(e),i=await jt(n,{token:t,returnSecureToken:!0}),r=await Nt._fromIdTokenResponse(n,"signIn",i);return await n._updateCurrentUser(r.user),r}class zt{constructor(e,t){this.factorId=e,this.uid=t.mfaEnrollmentId,this.enrollmentTime=new Date(t.enrolledAt).toUTCString(),this.displayName=t.displayName}static _fromServerResponse(e,t){return"phoneInfo"in t?Gt._fromServerResponse(e,t):I(e,"internal-error")}}class Gt extends zt{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new Gt(t)}}function Wt(e,t,n){var i;E((null===(i=n.url)||void 0===i?void 0:i.length)>0,e,"invalid-continue-uri"),E(void 0===n.dynamicLinkDomain||n.dynamicLinkDomain.length>0,e,"invalid-dynamic-link-domain"),t.continueUrl=n.url,t.dynamicLinkDomain=n.dynamicLinkDomain,t.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(E(n.iOS.bundleId.length>0,e,"missing-ios-bundle-id"),t.iOSBundleId=n.iOS.bundleId),n.android&&(E(n.android.packageName.length>0,e,"missing-android-pkg-name"),t.androidInstallApp=n.android.installApp,t.androidMinimumVersionCode=n.android.minimumVersion,t.androidPackageName=n.android.packageName)}async function Kt(t,n,i){const r=(0,e.getModularInstance)(t),s={requestType:"PASSWORD_RESET",email:n};i&&Wt(r,s,i),await $e(r,s)}async function Bt(t,n,i){await ze((0,e.getModularInstance)(t),{oobCode:n,newPassword:i})}async function Jt(t,n){await We((0,e.getModularInstance)(t),{oobCode:n})}async function $t(t,n){const i=(0,e.getModularInstance)(t),r=await ze(i,{oobCode:n}),s=r.requestType;switch(E(s,i,"internal-error"),s){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":E(r.newEmail,i,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":E(r.mfaInfo,i,"internal-error");default:E(r.email,i,"internal-error")}let o=null;return r.mfaInfo&&(o=zt._fromServerResponse(Me(i),r.mfaInfo)),{data:{email:("VERIFY_AND_CHANGE_EMAIL"===r.requestType?r.newEmail:r.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===r.requestType?r.email:r.newEmail)||null,multiFactorInfo:o},operation:s}}async function Yt(t,n){const{data:i}=await $t((0,e.getModularInstance)(t),n);return i.email}async function Xt(e,t,n){const i=Me(e),r=await Rt(i,{returnSecureToken:!0,email:t,password:n}),s=await Nt._fromIdTokenResponse(i,"signIn",r);return await i._updateCurrentUser(s.user),s}function Qt(t,n,i){return Ft((0,e.getModularInstance)(t),mt.credential(n,i))}async function Zt(t,n,i){const r=(0,e.getModularInstance)(t),s={requestType:"EMAIL_SIGNIN",email:n};E(i.handleCodeInApp,r,"argument-error"),i&&Wt(r,s,i),await Ye(r,s)}function en(e,t){const n=ht.parseLink(t);return"EMAIL_SIGNIN"===(null==n?void 0:n.operation)}async function tn(t,n,i){const r=(0,e.getModularInstance)(t),s=mt.credentialWithLink(n,i||O());return E(s._tenantId===(r.tenantId||null),r,"tenant-id-mismatch"),Ft(r,s)}async function nn(e,t){return j(e,"POST","/v1/accounts:createAuthUri",q(e,t))}async function rn(t,n){const i={identifier:n,continueUri:P()?O():"http://localhost"},{signinMethods:r}=await nn((0,e.getModularInstance)(t),i);return r||[]}async function sn(t,n){const i=(0,e.getModularInstance)(t),r={requestType:"VERIFY_EMAIL",idToken:await t.getIdToken()};n&&Wt(i.auth,r,n);const{email:s}=await Je(i.auth,r);s!==t.email&&await t.reload()}async function on(t,n,i){const r=(0,e.getModularInstance)(t),s={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await t.getIdToken(),newEmail:n};i&&Wt(r.auth,s,i);const{email:o}=await Xe(r.auth,s);o!==t.email&&await t.reload()}async function an(e,t){return j(e,"POST","/v1/accounts:update",t)}async function cn(t,{displayName:n,photoURL:i}){if(void 0===n&&void 0===i)return;const r=(0,e.getModularInstance)(t),s={idToken:await r.getIdToken(),displayName:n,photoUrl:i,returnSecureToken:!0},o=await ne(r,an(r.auth,s));r.displayName=o.displayName||null,r.photoURL=o.photoUrl||null;const a=r.providerData.find(({providerId:e})=>"password"===e);a&&(a.displayName=r.displayName,a.photoURL=r.photoURL),await r._updateTokensIfNecessary(o)}function un(t,n){return ln((0,e.getModularInstance)(t),n,null)}function dn(t,n){return ln((0,e.getModularInstance)(t),null,n)}async function ln(e,t,n){const{auth:i}=e,r={idToken:await e.getIdToken(),returnSecureToken:!0};t&&(r.email=t),n&&(r.password=n);const s=await ne(e,Ge(i,r));await e._updateTokensIfNecessary(s,!0)}function hn(e){var t,n;if(!e)return null;const{providerId:i}=e,r=e.rawUserInfo?JSON.parse(e.rawUserInfo):{},s=e.isNewUser||"identitytoolkit#SignupNewUserResponse"===e.kind;if(!i&&(null==e?void 0:e.idToken)){const i=null===(n=null===(t=ee(e.idToken))||void 0===t?void 0:t.firebase)||void 0===n?void 0:n.sign_in_provider;if(i){return new pn(s,"anonymous"!==i&&"custom"!==i?i:null)}}if(!i)return null;switch(i){case"facebook.com":return new fn(s,r);case"github.com":return new gn(s,r);case"google.com":return new vn(s,r);case"twitter.com":return new In(s,r,e.screenName||null);case"custom":case"anonymous":return new pn(s,null);default:return new pn(s,i,r)}}class pn{constructor(e,t,n={}){this.isNewUser=e,this.providerId=t,this.profile=n}}class mn extends pn{constructor(e,t,n,i){super(e,t,n),this.username=i}}class fn extends pn{constructor(e,t){super(e,"facebook.com",t)}}class gn extends mn{constructor(e,t){super(e,"github.com",t,"string"==typeof(null==t?void 0:t.login)?null==t?void 0:t.login:null)}}class vn extends pn{constructor(e,t){super(e,"google.com",t)}}class In extends mn{constructor(e,t,n){super(e,"twitter.com",t,n)}}function _n(e){const{user:t,_tokenResponse:n}=e;return t.isAnonymous&&!n?{providerId:null,isNewUser:!1,profile:null}:hn(n)}function yn(t,n){return(0,e.getModularInstance)(t).setPersistence(n)}function Tn(t,n,i,r){return(0,e.getModularInstance)(t).onIdTokenChanged(n,i,r)}function wn(t,n,i){return(0,e.getModularInstance)(t).beforeAuthStateChanged(n,i)}function En(t,n,i,r){return(0,e.getModularInstance)(t).onAuthStateChanged(n,i,r)}function kn(t){(0,e.getModularInstance)(t).useDeviceLanguage()}function An(t,n){return(0,e.getModularInstance)(t).updateCurrentUser(n)}function Rn(t){return(0,e.getModularInstance)(t).signOut()}async function Nn(t){return(0,e.getModularInstance)(t).delete()}class bn{constructor(e,t,n){this.type=e,this.credential=t,this.auth=n}static _fromIdtoken(e,t){return new bn("enroll",e,t)}static _fromMfaPendingCredential(e){return new bn("signin",e)}toJSON(){return{multiFactorSession:{["enroll"===this.type?"idToken":"pendingCredential"]:this.credential}}}static fromJSON(e){var t,n;if(null==e?void 0:e.multiFactorSession){if(null===(t=e.multiFactorSession)||void 0===t?void 0:t.pendingCredential)return bn._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(null===(n=e.multiFactorSession)||void 0===n?void 0:n.idToken)return bn._fromIdtoken(e.multiFactorSession.idToken)}return null}}class Sn{constructor(e,t,n){this.session=e,this.hints=t,this.signInResolver=n}static _fromError(e,t){const n=Me(e),i=t.customData._serverResponse,r=(i.mfaInfo||[]).map(e=>zt._fromServerResponse(n,e));E(i.mfaPendingCredential,n,"internal-error");const s=bn._fromMfaPendingCredential(i.mfaPendingCredential);return new Sn(s,r,async e=>{const r=await e._process(n,s);delete i.mfaInfo,delete i.mfaPendingCredential;const o=Object.assign(Object.assign({},i),{idToken:r.idToken,refreshToken:r.refreshToken});switch(t.operationType){case"signIn":const e=await Nt._fromIdTokenResponse(n,t.operationType,o);return await n._updateCurrentUser(e.user),e;case"reauthenticate":return E(t.user,n,"internal-error"),Nt._forOperation(t.user,t.operationType,o);default:I(n,"internal-error")}})}async resolveSignIn(e){const t=e;return this.signInResolver(t)}}function On(t,n){var i;const r=(0,e.getModularInstance)(t),s=n;return E(n.customData.operationType,r,"argument-error"),E(null===(i=s.customData._serverResponse)||void 0===i?void 0:i.mfaPendingCredential,r,"argument-error"),Sn._fromError(r,s)}function Pn(e,t){return j(e,"POST","/v2/accounts/mfaEnrollment:start",q(e,t))}function Dn(e,t){return j(e,"POST","/v2/accounts/mfaEnrollment:finalize",q(e,t))}function Cn(e,t){return j(e,"POST","/v2/accounts/mfaEnrollment:withdraw",q(e,t))}class Ln{constructor(e){this.user=e,this.enrolledFactors=[],e._onReload(t=>{t.mfaInfo&&(this.enrolledFactors=t.mfaInfo.map(t=>zt._fromServerResponse(e.auth,t)))})}static _fromUser(e){return new Ln(e)}async getSession(){return bn._fromIdtoken(await this.user.getIdToken(),this.user.auth)}async enroll(e,t){const n=e,i=await this.getSession(),r=await ne(this.user,n._process(this.user.auth,i,t));return await this.user._updateTokensIfNecessary(r),this.user.reload()}async unenroll(e){const t="string"==typeof e?e:e.uid,n=await this.user.getIdToken();try{const e=await ne(this.user,Cn(this.user.auth,{idToken:n,mfaEnrollmentId:t}));this.enrolledFactors=this.enrolledFactors.filter(({uid:e})=>e!==t),await this.user._updateTokensIfNecessary(e),await this.user.reload()}catch(i){throw i}}}const Mn=new WeakMap;function xn(t){const n=(0,e.getModularInstance)(t);return Mn.has(n)||Mn.set(n,Ln._fromUser(n)),Mn.get(n)}const Un="__sak";class Fn{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Un,"1"),this.storage.removeItem(Un),Promise.resolve(!0)):Promise.resolve(!1)}catch(e){return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}function Vn(){const t=(0,e.getUA)();return ye(t)||Re(t)}const qn=1e3,jn=10;class Hn extends Fn{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=((e,t)=>this.onStorageEvent(e,t)),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=Vn()&&Pe(),this.fallbackToPolling=Oe(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const n=this.storage.getItem(t),i=this.localCache[t];n!==i&&e(t,i,n)}}onStorageEvent(e,t=!1){if(!e.key)return void this.forAllChangedKeys((e,t,n)=>{this.notifyListeners(e,n)});const n=e.key;if(t?this.detachListener():this.stopPolling(),this.safariLocalStorageNotSynced){const i=this.storage.getItem(n);if(e.newValue!==i)null!==e.newValue?this.storage.setItem(n,e.newValue):this.storage.removeItem(n);else if(this.localCache[n]===e.newValue&&!t)return}const i=()=>{const e=this.storage.getItem(n);(t||this.localCache[n]!==e)&&this.notifyListeners(n,e)},r=this.storage.getItem(n);Se()&&r!==e.newValue&&e.newValue!==e.oldValue?setTimeout(i,jn):i()}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const i of Array.from(n))i(t?JSON.parse(t):t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:n}),!0)})},qn)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Hn.type="LOCAL";const zn=Hn;exports.b=zn;class Gn extends Fn{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Gn.type="SESSION";const Wn=Gn;function Kn(e){return Promise.all(e.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}exports.a=Wn;class Bn{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(t=>t.isListeningto(e));if(t)return t;const n=new Bn(e);return this.receivers.push(n),n}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:n,eventType:i,data:r}=t.data,s=this.handlersMap[i];if(!(null==s?void 0:s.size))return;t.ports[0].postMessage({status:"ack",eventId:n,eventType:i});const o=Array.from(s).map(async e=>e(t.origin,r)),a=await Kn(o);t.ports[0].postMessage({status:"done",eventId:n,eventType:i,response:a})}_subscribe(e,t){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),t&&0!==this.handlersMap[e].size||delete this.handlersMap[e],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}function Jn(e="",t=10){let n="";for(let i=0;i<t;i++)n+=Math.floor(10*Math.random());return e+n}Bn.receivers=[];class $n{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,n=50){const i="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!i)throw new Error("connection_unavailable");let r,s;return new Promise((o,a)=>{const c=Jn("",20);i.port1.start();const u=setTimeout(()=>{a(new Error("unsupported_event"))},n);s={messageChannel:i,onMessage(e){const t=e;if(t.data.eventId===c)switch(t.data.status){case"ack":clearTimeout(u),r=setTimeout(()=>{a(new Error("timeout"))},3e3);break;case"done":clearTimeout(r),o(t.data.response);break;default:clearTimeout(u),clearTimeout(r),a(new Error("invalid_response"))}}},this.handlers.add(s),i.port1.addEventListener("message",s.onMessage),this.target.postMessage({eventType:e,eventId:c,data:t},[i.port2])}).finally(()=>{s&&this.removeMessageHandler(s)})}}function Yn(){return window}function Xn(e){Yn().location.href=e}function Qn(){return void 0!==Yn().WorkerGlobalScope&&"function"==typeof Yn().importScripts}async function Zn(){if(!(null===navigator||void 0===navigator?void 0:navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch(e){return null}}function ei(){var e;return(null===(e=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===e?void 0:e.controller)||null}function ti(){return Qn()?self:null}const ni="firebaseLocalStorageDb",ii=1,ri="firebaseLocalStorage",si="fbase_key";class oi{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function ai(e,t){return e.transaction([ri],t?"readwrite":"readonly").objectStore(ri)}function ci(){const e=indexedDB.deleteDatabase(ni);return new oi(e).toPromise()}function ui(){const e=indexedDB.open(ni,ii);return new Promise((t,n)=>{e.addEventListener("error",()=>{n(e.error)}),e.addEventListener("upgradeneeded",()=>{const t=e.result;try{t.createObjectStore(ri,{keyPath:si})}catch(i){n(i)}}),e.addEventListener("success",async()=>{const n=e.result;n.objectStoreNames.contains(ri)?t(n):(n.close(),await ci(),t(await ui()))})})}async function di(e,t,n){const i=ai(e,!0).put({[si]:t,value:n});return new oi(i).toPromise()}async function li(e,t){const n=ai(e,!1).get(t),i=await new oi(n).toPromise();return void 0===i?null:i.value}function hi(e,t){const n=ai(e,!0).delete(t);return new oi(n).toPromise()}const pi=800,mi=3;class fi{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await ui(),this.db)}async _withRetries(e){let t=0;for(;;)try{const i=await this._openDb();return await e(i)}catch(n){if(t++>mi)throw n;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Qn()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Bn._getInstance(ti()),this.receiver._subscribe("keyChanged",async(e,t)=>{return{keyProcessed:(await this._poll()).includes(t.key)}}),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;if(this.activeServiceWorker=await Zn(),!this.activeServiceWorker)return;this.sender=new $n(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&(null===(e=n[0])||void 0===e?void 0:e.fulfilled)&&(null===(t=n[0])||void 0===t?void 0:t.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(this.sender&&this.activeServiceWorker&&ei()===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch(t){}}async _isAvailable(){try{if(!indexedDB)return!1;const t=await ui();return await di(t,Un,"1"),await hi(t,Un),!0}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(n=>di(n,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(t=>li(t,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>hi(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(e=>{const t=ai(e,!1).getAll();return new oi(t).toPromise()});if(!e)return[];if(0!==this.pendingWrites)return[];const t=[],n=new Set;for(const{fbase_key:i,value:r}of e)n.add(i),JSON.stringify(this.localCache[i])!==JSON.stringify(r)&&(this.notifyListeners(i,r),t.push(i));for(const i of Object.keys(this.localCache))this.localCache[i]&&!n.has(i)&&(this.notifyListeners(i,null),t.push(i));return t}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const i of Array.from(n))i(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),pi)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&this.stopPolling()}}fi.type="LOCAL";const gi=fi;function vi(e,t){return j(e,"POST","/v2/accounts/mfaSignIn:start",q(e,t))}function Ii(e,t){return j(e,"POST","/v2/accounts/mfaSignIn:finalize",q(e,t))}async function _i(e){return(await j(e,"GET","/v1/recaptchaParams")).recaptchaSiteKey||""}function yi(){var e,t;return null!==(t=null===(e=document.getElementsByTagName("head"))||void 0===e?void 0:e[0])&&void 0!==t?t:document}function Ti(e){return new Promise((t,n)=>{const i=document.createElement("script");i.setAttribute("src",e),i.onload=t,i.onerror=(e=>{const t=_("internal-error");t.customData=e,n(t)}),i.type="text/javascript",i.charset="UTF-8",yi().appendChild(i)})}function wi(e){return`__${e}${Math.floor(1e6*Math.random())}`}exports.i=gi;const Ei=500,ki=6e4,Ai=1e12;class Ri{constructor(e){this.auth=e,this.counter=Ai,this._widgets=new Map}render(e,t){const n=this.counter;return this._widgets.set(n,new Ni(e,this.auth.name,t||{})),this.counter++,n}reset(e){var t;const n=e||Ai;null===(t=this._widgets.get(n))||void 0===t||t.delete(),this._widgets.delete(n)}getResponse(e){var t;const n=e||Ai;return(null===(t=this._widgets.get(n))||void 0===t?void 0:t.getResponse())||""}async execute(e){var t;const n=e||Ai;return null===(t=this._widgets.get(n))||void 0===t||t.execute(),""}}class Ni{constructor(e,t,n){this.params=n,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=(()=>{this.execute()});const i="string"==typeof e?document.getElementById(e):e;E(i,"argument-error",{appName:t}),this.container=i,this.isVisible="invisible"!==this.params.size,this.isVisible?this.execute():this.container.addEventListener("click",this.clickHandler)}getResponse(){return this.checkIfDeleted(),this.responseToken}delete(){this.checkIfDeleted(),this.deleted=!0,this.timerId&&(clearTimeout(this.timerId),this.timerId=null),this.container.removeEventListener("click",this.clickHandler)}execute(){this.checkIfDeleted(),this.timerId||(this.timerId=window.setTimeout(()=>{this.responseToken=bi(50);const{callback:e,"expired-callback":t}=this.params;if(e)try{e(this.responseToken)}catch(n){}this.timerId=window.setTimeout(()=>{if(this.timerId=null,this.responseToken=null,t)try{t()}catch(n){}this.isVisible&&this.execute()},ki)},Ei))}checkIfDeleted(){if(this.deleted)throw new Error("reCAPTCHA mock was already deleted!")}}function bi(e){const t=[],n="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let i=0;i<e;i++)t.push(n.charAt(Math.floor(Math.random()*n.length)));return t.join("")}const Si=wi("rcb"),Oi=new M(3e4,6e4),Pi="https://www.google.com/recaptcha/api.js?";class Di{constructor(){var e;this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!(null===(e=Yn().grecaptcha)||void 0===e?void 0:e.render)}load(t,n=""){return E(Ci(n),t,"argument-error"),this.shouldResolveImmediately(n)?Promise.resolve(Yn().grecaptcha):new Promise((i,r)=>{const s=Yn().setTimeout(()=>{r(_(t,"network-request-failed"))},Oi.get());Yn()[Si]=(()=>{Yn().clearTimeout(s),delete Yn()[Si];const e=Yn().grecaptcha;if(!e)return void r(_(t,"internal-error"));const o=e.render;e.render=((e,t)=>{const n=o(e,t);return this.counter++,n}),this.hostLanguage=n,i(e)}),Ti(`${Pi}?${(0,e.querystring)({onload:Si,render:"explicit",hl:n})}`).catch(()=>{clearTimeout(s),r(_(t,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){var t;return!!(null===(t=Yn().grecaptcha)||void 0===t?void 0:t.render)&&(e===this.hostLanguage||this.counter>0||this.librarySeparatelyLoaded)}}function Ci(e){return e.length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e)}class Li{async load(e){return new Ri(e)}clearedOneInstance(){}}const Mi="recaptcha",xi={theme:"light",type:"image"};class Ui{constructor(e,t=Object.assign({},xi),n){this.parameters=t,this.type=Mi,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=Me(n),this.isInvisible="invisible"===this.parameters.size,E("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment");const i="string"==typeof e?document.getElementById(e):e;E(i,this.auth,"argument-error"),this.container=i,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=this.auth.settings.appVerificationDisabledForTesting?new Li:new Di,this.validateStartingState()}async verify(){this.assertNotDestroyed();const e=await this.render(),t=this.getAssertedRecaptcha(),n=t.getResponse(e);return n||new Promise(n=>{const i=e=>{e&&(this.tokenChangeListeners.delete(i),n(e))};this.tokenChangeListeners.add(i),this.isInvisible&&t.execute(e)})}render(){try{this.assertNotDestroyed()}catch(e){return Promise.reject(e)}return this.renderPromise?this.renderPromise:(this.renderPromise=this.makeRenderPromise().catch(e=>{throw this.renderPromise=null,e}),this.renderPromise)}_reset(){this.assertNotDestroyed(),null!==this.widgetId&&this.getAssertedRecaptcha().reset(this.widgetId)}clear(){this.assertNotDestroyed(),this.destroyed=!0,this._recaptchaLoader.clearedOneInstance(),this.isInvisible||this.container.childNodes.forEach(e=>{this.container.removeChild(e)})}validateStartingState(){E(!this.parameters.sitekey,this.auth,"argument-error"),E(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),E("undefined"!=typeof document,this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(e){return t=>{if(this.tokenChangeListeners.forEach(e=>e(t)),"function"==typeof e)e(t);else if("string"==typeof e){const n=Yn()[e];"function"==typeof n&&n(t)}}}assertNotDestroyed(){E(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let e=this.container;if(!this.isInvisible){const t=document.createElement("div");e.appendChild(t),e=t}this.widgetId=this.getAssertedRecaptcha().render(e,this.parameters)}return this.widgetId}async init(){E(P()&&!Qn(),this.auth,"internal-error"),await Fi(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);const e=await _i(this.auth);E(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return E(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}function Fi(){let e=null;return new Promise(t=>{"complete"!==document.readyState?(e=(()=>t()),window.addEventListener("load",e)):t()}).catch(t=>{throw e&&window.removeEventListener("load",e),t})}exports.R=Ui;class Vi{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){const t=ut._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}async function qi(t,n,i){const r=Me(t),s=await zi(r,n,(0,e.getModularInstance)(i));return new Vi(s,e=>Ft(r,e))}async function ji(t,n,i){const r=(0,e.getModularInstance)(t);await Mt(!1,r,"phone");const s=await zi(r.auth,n,(0,e.getModularInstance)(i));return new Vi(s,e=>Vt(r,e))}async function Hi(t,n,i){const r=(0,e.getModularInstance)(t),s=await zi(r.auth,n,(0,e.getModularInstance)(i));return new Vi(s,e=>qt(r,e))}async function zi(e,t,n){var i;const r=await n.verify();try{let s;if(E("string"==typeof r,e,"argument-error"),E(n.type===Mi,e,"argument-error"),"session"in(s="string"==typeof t?{phoneNumber:t}:t)){const t=s.session;if("phoneNumber"in s){return E("enroll"===t.type,e,"internal-error"),(await Pn(e,{idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:s.phoneNumber,recaptchaToken:r}})).phoneSessionInfo.sessionInfo}{E("signin"===t.type,e,"internal-error");const n=(null===(i=s.multiFactorHint)||void 0===i?void 0:i.uid)||s.multiFactorUid;return E(n,e,"missing-multi-factor-info"),(await vi(e,{mfaPendingCredential:t.credential,mfaEnrollmentId:n,phoneSignInInfo:{recaptchaToken:r}})).phoneResponseInfo.sessionInfo}}{const{sessionInfo:t}=await rt(e,{phoneNumber:s.phoneNumber,recaptchaToken:r});return t}}finally{n._reset()}}async function Gi(t,n){await Lt((0,e.getModularInstance)(t),n)}class Wi{constructor(e){this.providerId=Wi.PROVIDER_ID,this.auth=Me(e)}verifyPhoneNumber(t,n){return zi(this.auth,t,(0,e.getModularInstance)(n))}static credential(e,t){return ut._fromVerification(e,t)}static credentialFromResult(e){const t=e;return Wi.credentialFromTaggedObject(t)}static credentialFromError(e){return Wi.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{phoneNumber:t,temporaryProof:n}=e;return t&&n?ut._fromTokenResponse(t,n):null}}function Ki(e,t){return t?N(t):(E(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}exports.P=Wi,Wi.PROVIDER_ID="phone",Wi.PHONE_SIGN_IN_METHOD="phone";class Bi extends He{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return tt(e,this._buildIdpRequest())}_linkToIdToken(e,t){return tt(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return tt(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function Ji(e){return Ut(e.auth,new Bi(e),e.bypassAuthState)}function $i(e){const{auth:t,user:n}=e;return E(n,t,"internal-error"),xt(n,new Bi(e),e.bypassAuthState)}async function Yi(e){const{auth:t,user:n}=e;return E(n,t,"internal-error"),Lt(n,new Bi(e),e.bypassAuthState)}class Xi{constructor(e,t,n,i,r=!1){this.auth=e,this.resolver=n,this.user=i,this.bypassAuthState=r,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(n){this.reject(n)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:n,postBody:i,tenantId:r,error:s,type:o}=e;if(s)return void this.reject(s);const a={auth:this.auth,requestUri:t,sessionId:n,tenantId:r||void 0,postBody:i||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(a))}catch(c){this.reject(c)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Ji;case"linkViaPopup":case"linkViaRedirect":return Yi;case"reauthViaPopup":case"reauthViaRedirect":return $i;default:I(this.auth,"internal-error")}}resolve(e){A(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){A(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const Qi=new M(2e3,1e4);async function Zi(e,t,n){const i=Me(e);T(e,t,ft);const r=Ki(i,n);return new nr(i,"signInViaPopup",t,r).executeNotNull()}async function er(t,n,i){const r=(0,e.getModularInstance)(t);T(r.auth,n,ft);const s=Ki(r.auth,i);return new nr(r.auth,"reauthViaPopup",n,s,r).executeNotNull()}async function tr(t,n,i){const r=(0,e.getModularInstance)(t);T(r.auth,n,ft);const s=Ki(r.auth,i);return new nr(r.auth,"linkViaPopup",n,s,r).executeNotNull()}class nr extends Xi{constructor(e,t,n,i,r){super(e,t,i,r),this.provider=n,this.authWindow=null,this.pollId=null,nr.currentPopupAction&&nr.currentPopupAction.cancel(),nr.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return E(e,this.auth,"internal-error"),e}async onExecution(){A(1===this.filter.length,"Popup operations only handle one event");const e=Jn();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(e=>{this.reject(e)}),this.resolver._isIframeWebStorageSupported(this.auth,e=>{e||this.reject(_(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return(null===(e=this.authWindow)||void 0===e?void 0:e.associatedEvent)||null}cancel(){this.reject(_(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,nr.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,n;null!==(n=null===(t=this.authWindow)||void 0===t?void 0:t.window)&&void 0!==n&&n.closed?this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(_(this.auth,"popup-closed-by-user"))},2e3):this.pollId=window.setTimeout(e,Qi.get())};e()}}nr.currentPopupAction=null;const ir="pendingRedirect",rr=new Map;class sr extends Xi{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=rr.get(this.auth._key());if(!e){try{const n=await or(this.resolver,this.auth)?await super.execute():null;e=(()=>Promise.resolve(n))}catch(t){e=(()=>Promise.reject(t))}rr.set(this.auth._key(),e)}return this.bypassAuthState||rr.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"!==e.type){if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}async function or(e,t){const n=lr(t),i=dr(e);if(!(await i._isAvailable()))return!1;const r="true"===await i._get(n);return await i._remove(n),r}async function ar(e,t){return dr(e)._set(lr(t),"true")}function cr(){rr.clear()}function ur(e,t){rr.set(e._key(),t)}function dr(e){return N(e._redirectPersistence)}function lr(e){return ge(ir,e.config.apiKey,e.name)}function hr(e,t,n){return pr(e,t,n)}async function pr(e,t,n){const i=Me(e);T(e,t,ft),await i._initializationPromise;const r=Ki(i,n);return await ar(r,i),r._openRedirect(i,t,"signInViaRedirect")}function mr(e,t,n){return fr(e,t,n)}async function fr(t,n,i){const r=(0,e.getModularInstance)(t);T(r.auth,n,ft),await r.auth._initializationPromise;const s=Ki(r.auth,i);await ar(s,r.auth);const o=await yr(r);return s._openRedirect(r.auth,n,"reauthViaRedirect",o)}function gr(e,t,n){return vr(e,t,n)}async function vr(t,n,i){const r=(0,e.getModularInstance)(t);T(r.auth,n,ft),await r.auth._initializationPromise;const s=Ki(r.auth,i);await Mt(!1,r,n.providerId),await ar(s,r.auth);const o=await yr(r);return s._openRedirect(r.auth,n,"linkViaRedirect",o)}async function Ir(e,t){return await Me(e)._initializationPromise,_r(e,t,!1)}async function _r(e,t,n=!1){const i=Me(e),r=Ki(i,t),s=new sr(i,r,n),o=await s.execute();return o&&!n&&(delete o.user._redirectEventId,await i._persistUserIfCurrent(o.user),await i._setRedirectUser(null,t)),o}async function yr(e){const t=Jn(`${e.uid}:::`);return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}const Tr=6e5;class wr{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(n=>{this.isEventForConsumer(e,n)&&(t=!0,this.sendToConsumer(e,n),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!Ar(e)?t:(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0),t)}sendToConsumer(e,t){var n;if(e.error&&!kr(e)){const i=(null===(n=e.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error";t.onError(_(this.auth,i))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=Tr&&this.cachedEventUids.clear(),this.cachedEventUids.has(Er(e))}saveEventToCache(e){this.cachedEventUids.add(Er(e)),this.lastProcessedEventTime=Date.now()}}function Er(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function kr({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}function Ar(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return kr(e);default:return!1}}async function Rr(e,t={}){return j(e,"GET","/v1/projects",t)}exports.ay=wr;const Nr=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,br=/^https?/;async function Sr(e){if(e.config.emulator)return;const{authorizedDomains:t}=await Rr(e);for(const i of t)try{if(Or(i))return}catch(n){}I(e,"unauthorized-domain")}function Or(e){const t=O(),{protocol:n,hostname:i}=new URL(t);if(e.startsWith("chrome-extension://")){const r=new URL(e);return""===r.hostname&&""===i?"chrome-extension:"===n&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):"chrome-extension:"===n&&r.hostname===i}if(!br.test(n))return!1;if(Nr.test(e))return i===e;const r=e.replace(/\./g,"\\.");return new RegExp("^(.+\\."+r+"|"+r+")$","i").test(i)}const Pr=new M(3e4,6e4);function Dr(){const e=Yn().___jsl;if(null==e?void 0:e.H)for(const t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let n=0;n<e.CP.length;n++)e.CP[n]=null}function Cr(e){return new Promise((t,n)=>{var i,r,s;function o(){Dr(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{Dr(),n(_(e,"network-request-failed"))},timeout:Pr.get()})}if(null===(r=null===(i=Yn().gapi)||void 0===i?void 0:i.iframes)||void 0===r?void 0:r.Iframe)t(gapi.iframes.getContext());else{if(null===(s=Yn().gapi)||void 0===s||!s.load){const t=wi("iframefcb");return Yn()[t]=(()=>{gapi.load?o():n(_(e,"network-request-failed"))}),Ti(`https://apis.google.com/js/api.js?onload=${t}`).catch(e=>n(e))}o()}}).catch(e=>{throw Lr=null,e})}let Lr=null;function Mr(e){return Lr=Lr||Cr(e)}const xr=new M(5e3,15e3),Ur="__/auth/iframe",Fr="emulator/auth/iframe",Vr={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},qr=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function jr(n){const i=n.config;E(i.authDomain,n,"auth-domain-config-required");const r=i.emulator?x(i,Fr):`https://${n.config.authDomain}/${Ur}`,s={apiKey:i.apiKey,appName:n.name,v:t.SDK_VERSION},o=qr.get(n.config.apiHost);o&&(s.eid=o);const a=n._getFrameworks();return a.length&&(s.fw=a.join(",")),`${r}?${(0,e.querystring)(s).slice(1)}`}async function Hr(e){const t=await Mr(e),n=Yn().gapi;return E(n,e,"internal-error"),t.open({where:document.body,url:jr(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Vr,dontclear:!0},t=>new Promise(async(n,i)=>{await t.restyle({setHideOnLeave:!1});const r=_(e,"network-request-failed"),s=Yn().setTimeout(()=>{i(r)},xr.get());function o(){Yn().clearTimeout(s),n(t)}t.ping(o).then(o,()=>{i(r)})}))}const zr={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Gr=500,Wr=600,Kr="_blank",Br="http://localhost";class Jr{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function $r(t,n,i,r=Gr,s=Wr){const o=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const u=Object.assign(Object.assign({},zr),{width:r.toString(),height:s.toString(),top:o,left:a}),d=(0,e.getUA)().toLowerCase();i&&(c=Te(d)?Kr:i),_e(d)&&(n=n||Br,u.scrollbars="yes");const l=Object.entries(u).reduce((e,[t,n])=>`${e}${t}=${n},`,"");if(be(d)&&"_self"!==c)return Yr(n||"",c),new Jr(null);const h=window.open(n||"",c,l);E(h,t,"popup-blocked");try{h.focus()}catch(p){}return new Jr(h)}function Yr(e,t){const n=document.createElement("a");n.href=e,n.target=t;const i=document.createEvent("MouseEvent");i.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(i)}exports.aJ=Jr;const Xr="__/auth/handler",Qr="emulator/auth/handler";function Zr(n,i,r,s,o,a){E(n.config.authDomain,n,"auth-domain-config-required"),E(n.config.apiKey,n,"invalid-api-key");const c={apiKey:n.config.apiKey,appName:n.name,authType:r,redirectUrl:s,v:t.SDK_VERSION,eventId:o};if(i instanceof ft){i.setDefaultLanguage(n.languageCode),c.providerId=i.providerId||"",(0,e.isEmpty)(i.getCustomParameters())||(c.customParameters=JSON.stringify(i.getCustomParameters()));for(const[e,t]of Object.entries(a||{}))c[e]=t}if(i instanceof gt){const e=i.getScopes().filter(e=>""!==e);e.length>0&&(c.scopes=e.join(","))}n.tenantId&&(c.tid=n.tenantId);const u=c;for(const e of Object.keys(u))void 0===u[e]&&delete u[e];return`${es(n)}?${(0,e.querystring)(u).slice(1)}`}function es({config:e}){return e.emulator?x(e,Qr):`https://${e.authDomain}/${Xr}`}const ts="webStorageSupport";class ns{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Wn,this._completeRedirectFn=_r,this._overrideRedirectResult=ur}async _openPopup(e,t,n,i){var r;return A(null===(r=this.eventManagers[e._key()])||void 0===r?void 0:r.manager,"_initialize() not called before _openPopup()"),$r(e,Zr(e,t,n,O(),i),Jn())}async _openRedirect(e,t,n,i){return await this._originValidation(e),Xn(Zr(e,t,n,O(),i)),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:e,promise:n}=this.eventManagers[t];return e?Promise.resolve(e):(A(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch(()=>{delete this.eventManagers[t]}),n}async initAndGetManager(e){const t=await Hr(e),n=new wr(e);return t.register("authEvent",t=>{return E(null==t?void 0:t.authEvent,e,"invalid-auth-event"),{status:n.onEvent(t.authEvent)?"ACK":"ERROR"}},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:n},this.iframes[e._key()]=t,n}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(ts,{type:ts},n=>{var i;const r=null===(i=null==n?void 0:n[0])||void 0===i?void 0:i[ts];void 0!==r&&t(!!r),I(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=Sr(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return Oe()||ye()||Re()}}const is=ns;exports.k=is;class rs{constructor(e){this.factorId=e}_process(e,t,n){switch(t.type){case"enroll":return this._finalizeEnroll(e,t.credential,n);case"signin":return this._finalizeSignIn(e,t.credential);default:return k("unexpected MultiFactorSessionType")}}}class ss extends rs{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new ss(e)}_finalizeEnroll(e,t,n){return Dn(e,{idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(e,t){return Ii(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()})}}class os{constructor(){}static assertion(e){return ss._fromCredential(e)}}exports.m=os,os.FACTOR_ID="phone";var as="@firebase/auth",cs="0.21.5";class us{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),(null===(e=this.auth.currentUser)||void 0===e?void 0:e.uid)||null}async getToken(e){if(this.assertAuthConfigured(),await this.auth._initializationPromise,!this.auth.currentUser)return null;return{accessToken:await this.auth.currentUser.getIdToken(e)}}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(t=>{e((null==t?void 0:t.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){E(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function ds(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}function ls(e){(0,t._registerComponent)(new r.Component("auth",(t,{options:n})=>{const i=t.getProvider("app").getImmediate(),r=t.getProvider("heartbeat"),{apiKey:s,authDomain:o}=i.options;return((t,i)=>{E(s&&!s.includes(":"),"invalid-api-key",{appName:t.name}),E(!(null==o?void 0:o.includes(":")),"argument-error",{appName:t.name});const r={apiKey:s,authDomain:o,clientPlatform:e,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:De(e)},a=new Le(t,i,r);return S(a,n),a})(i,r)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider("auth-internal").initialize()})),(0,t._registerComponent)(new r.Component("auth-internal",e=>{return(e=>new us(e))(Me(e.getProvider("auth").getImmediate()))},"PRIVATE").setInstantiationMode("EXPLICIT")),(0,t.registerVersion)(as,cs,ds(e)),(0,t.registerVersion)(as,cs,"esm2017")}const hs=300,ps=(0,e.getExperimentalSetting)("authIdTokenMaxAge")||300;let ms=null;const fs=e=>async t=>{const n=t&&await t.getIdTokenResult(),i=n&&((new Date).getTime()-Date.parse(n.issuedAtTime))/1e3;if(i&&i>ps)return;const r=null==n?void 0:n.token;ms!==r&&(ms=r,await fetch(e,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))};function gs(n=(0,t.getApp)()){const i=(0,t._getProvider)(n,"auth");if(i.isInitialized())return i.getImmediate();const r=b(n,{popupRedirectResolver:is,persistence:[gi,zn,Wn]}),s=(0,e.getExperimentalSetting)("authTokenSyncURL");if(s){const e=fs(s);wn(r,e,()=>e(r.currentUser)),Tn(r,t=>e(t))}const o=(0,e.getDefaultEmulatorHost)("auth");return o&&Ue(r,`http://${o}`),r}ls("Browser");
|
|
488
|
+
},{"@firebase/util":"chA2","@firebase/app":"h2Mb","@firebase/logger":"JJem","tslib":"vCxL","@firebase/component":"vhY9"}],"eL7N":[function(require,module,exports) {
|
|
489
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ActionCodeOperation",{enumerable:!0,get:function(){return e.A}}),Object.defineProperty(exports,"ActionCodeURL",{enumerable:!0,get:function(){return e.ad}}),Object.defineProperty(exports,"AuthCredential",{enumerable:!0,get:function(){return e.H}}),Object.defineProperty(exports,"AuthErrorCodes",{enumerable:!0,get:function(){return e.D}}),Object.defineProperty(exports,"AuthImpl",{enumerable:!0,get:function(){return e.aG}}),Object.defineProperty(exports,"AuthPopup",{enumerable:!0,get:function(){return e.aJ}}),Object.defineProperty(exports,"EmailAuthCredential",{enumerable:!0,get:function(){return e.I}}),Object.defineProperty(exports,"EmailAuthProvider",{enumerable:!0,get:function(){return e.M}}),Object.defineProperty(exports,"FacebookAuthProvider",{enumerable:!0,get:function(){return e.N}}),Object.defineProperty(exports,"FactorId",{enumerable:!0,get:function(){return e.F}}),Object.defineProperty(exports,"FetchProvider",{enumerable:!0,get:function(){return e.aK}}),Object.defineProperty(exports,"GithubAuthProvider",{enumerable:!0,get:function(){return e.T}}),Object.defineProperty(exports,"GoogleAuthProvider",{enumerable:!0,get:function(){return e.Q}}),Object.defineProperty(exports,"OAuthCredential",{enumerable:!0,get:function(){return e.J}}),Object.defineProperty(exports,"OAuthProvider",{enumerable:!0,get:function(){return e.U}}),Object.defineProperty(exports,"OperationType",{enumerable:!0,get:function(){return e.O}}),Object.defineProperty(exports,"PhoneAuthCredential",{enumerable:!0,get:function(){return e.K}}),Object.defineProperty(exports,"PhoneAuthProvider",{enumerable:!0,get:function(){return e.P}}),Object.defineProperty(exports,"PhoneMultiFactorGenerator",{enumerable:!0,get:function(){return e.m}}),Object.defineProperty(exports,"ProviderId",{enumerable:!0,get:function(){return e.o}}),Object.defineProperty(exports,"RecaptchaVerifier",{enumerable:!0,get:function(){return e.R}}),Object.defineProperty(exports,"SAMLAuthCredential",{enumerable:!0,get:function(){return e.aL}}),Object.defineProperty(exports,"SAMLAuthProvider",{enumerable:!0,get:function(){return e.V}}),Object.defineProperty(exports,"SignInMethod",{enumerable:!0,get:function(){return e.S}}),Object.defineProperty(exports,"TwitterAuthProvider",{enumerable:!0,get:function(){return e.W}}),Object.defineProperty(exports,"UserImpl",{enumerable:!0,get:function(){return e.aF}}),Object.defineProperty(exports,"_assert",{enumerable:!0,get:function(){return e.ax}}),Object.defineProperty(exports,"_castAuth",{enumerable:!0,get:function(){return e.aE}}),Object.defineProperty(exports,"_fail",{enumerable:!0,get:function(){return e.as}}),Object.defineProperty(exports,"_generateEventId",{enumerable:!0,get:function(){return e.aI}}),Object.defineProperty(exports,"_getClientVersion",{enumerable:!0,get:function(){return e.aH}}),Object.defineProperty(exports,"_getInstance",{enumerable:!0,get:function(){return e.az}}),Object.defineProperty(exports,"_getRedirectResult",{enumerable:!0,get:function(){return e.aB}}),Object.defineProperty(exports,"_overrideRedirectResult",{enumerable:!0,get:function(){return e.aC}}),Object.defineProperty(exports,"_persistenceKeyName",{enumerable:!0,get:function(){return e.aA}}),exports.addFrameworkForLogging=k,Object.defineProperty(exports,"applyActionCode",{enumerable:!0,get:function(){return e.a2}}),Object.defineProperty(exports,"beforeAuthStateChanged",{enumerable:!0,get:function(){return e.t}}),Object.defineProperty(exports,"browserLocalPersistence",{enumerable:!0,get:function(){return e.b}}),Object.defineProperty(exports,"browserPopupRedirectResolver",{enumerable:!0,get:function(){return e.k}}),Object.defineProperty(exports,"browserSessionPersistence",{enumerable:!0,get:function(){return e.a}}),Object.defineProperty(exports,"checkActionCode",{enumerable:!0,get:function(){return e.a3}}),Object.defineProperty(exports,"confirmPasswordReset",{enumerable:!0,get:function(){return e.a1}}),Object.defineProperty(exports,"connectAuthEmulator",{enumerable:!0,get:function(){return e.G}}),exports.cordovaPopupRedirectResolver=void 0,Object.defineProperty(exports,"createUserWithEmailAndPassword",{enumerable:!0,get:function(){return e.a5}}),Object.defineProperty(exports,"debugErrorMap",{enumerable:!0,get:function(){return e.B}}),Object.defineProperty(exports,"deleteUser",{enumerable:!0,get:function(){return e.z}}),Object.defineProperty(exports,"fetchSignInMethodsForEmail",{enumerable:!0,get:function(){return e.aa}}),Object.defineProperty(exports,"getAdditionalUserInfo",{enumerable:!0,get:function(){return e.al}}),Object.defineProperty(exports,"getAuth",{enumerable:!0,get:function(){return e.n}}),Object.defineProperty(exports,"getIdToken",{enumerable:!0,get:function(){return e.ai}}),Object.defineProperty(exports,"getIdTokenResult",{enumerable:!0,get:function(){return e.aj}}),Object.defineProperty(exports,"getMultiFactorResolver",{enumerable:!0,get:function(){return e.an}}),Object.defineProperty(exports,"getRedirectResult",{enumerable:!0,get:function(){return e.j}}),Object.defineProperty(exports,"inMemoryPersistence",{enumerable:!0,get:function(){return e.L}}),Object.defineProperty(exports,"indexedDBLocalPersistence",{enumerable:!0,get:function(){return e.i}}),Object.defineProperty(exports,"initializeAuth",{enumerable:!0,get:function(){return e.E}}),Object.defineProperty(exports,"isSignInWithEmailLink",{enumerable:!0,get:function(){return e.a8}}),Object.defineProperty(exports,"linkWithCredential",{enumerable:!0,get:function(){return e.Z}}),Object.defineProperty(exports,"linkWithPhoneNumber",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(exports,"linkWithPopup",{enumerable:!0,get:function(){return e.d}}),Object.defineProperty(exports,"linkWithRedirect",{enumerable:!0,get:function(){return e.g}}),Object.defineProperty(exports,"multiFactor",{enumerable:!0,get:function(){return e.ao}}),Object.defineProperty(exports,"onAuthStateChanged",{enumerable:!0,get:function(){return e.v}}),Object.defineProperty(exports,"onIdTokenChanged",{enumerable:!0,get:function(){return e.q}}),Object.defineProperty(exports,"parseActionCodeURL",{enumerable:!0,get:function(){return e.ae}}),Object.defineProperty(exports,"prodErrorMap",{enumerable:!0,get:function(){return e.C}}),Object.defineProperty(exports,"reauthenticateWithCredential",{enumerable:!0,get:function(){return e._}}),Object.defineProperty(exports,"reauthenticateWithPhoneNumber",{enumerable:!0,get:function(){return e.r}}),Object.defineProperty(exports,"reauthenticateWithPopup",{enumerable:!0,get:function(){return e.e}}),Object.defineProperty(exports,"reauthenticateWithRedirect",{enumerable:!0,get:function(){return e.h}}),Object.defineProperty(exports,"reload",{enumerable:!0,get:function(){return e.am}}),Object.defineProperty(exports,"sendEmailVerification",{enumerable:!0,get:function(){return e.ab}}),Object.defineProperty(exports,"sendPasswordResetEmail",{enumerable:!0,get:function(){return e.a0}}),Object.defineProperty(exports,"sendSignInLinkToEmail",{enumerable:!0,get:function(){return e.a7}}),Object.defineProperty(exports,"setPersistence",{enumerable:!0,get:function(){return e.p}}),Object.defineProperty(exports,"signInAnonymously",{enumerable:!0,get:function(){return e.X}}),Object.defineProperty(exports,"signInWithCredential",{enumerable:!0,get:function(){return e.Y}}),Object.defineProperty(exports,"signInWithCustomToken",{enumerable:!0,get:function(){return e.$}}),Object.defineProperty(exports,"signInWithEmailAndPassword",{enumerable:!0,get:function(){return e.a6}}),Object.defineProperty(exports,"signInWithEmailLink",{enumerable:!0,get:function(){return e.a9}}),Object.defineProperty(exports,"signInWithPhoneNumber",{enumerable:!0,get:function(){return e.s}}),Object.defineProperty(exports,"signInWithPopup",{enumerable:!0,get:function(){return e.c}}),Object.defineProperty(exports,"signInWithRedirect",{enumerable:!0,get:function(){return e.f}}),Object.defineProperty(exports,"signOut",{enumerable:!0,get:function(){return e.y}}),Object.defineProperty(exports,"unlink",{enumerable:!0,get:function(){return e.ak}}),Object.defineProperty(exports,"updateCurrentUser",{enumerable:!0,get:function(){return e.x}}),Object.defineProperty(exports,"updateEmail",{enumerable:!0,get:function(){return e.ag}}),Object.defineProperty(exports,"updatePassword",{enumerable:!0,get:function(){return e.ah}}),Object.defineProperty(exports,"updatePhoneNumber",{enumerable:!0,get:function(){return e.u}}),Object.defineProperty(exports,"updateProfile",{enumerable:!0,get:function(){return e.af}}),Object.defineProperty(exports,"useDeviceLanguage",{enumerable:!0,get:function(){return e.w}}),Object.defineProperty(exports,"verifyBeforeUpdateEmail",{enumerable:!0,get:function(){return e.ac}}),Object.defineProperty(exports,"verifyPasswordResetCode",{enumerable:!0,get:function(){return e.a4}});var e=require("./index-3363a72a.js"),t=require("@firebase/util");function n(){return window}require("@firebase/app"),require("@firebase/logger"),require("tslib"),require("@firebase/component");const r=2e3;async function o(t,r,o){var i;const{BuildInfo:u}=n();(0,e.ap)(r.sessionId,"AuthEvent did not contain a session ID");const a=await c(r.sessionId),s={};return(0,e.aq)()?s.ibi=u.packageName:(0,e.ar)()?s.apn=u.packageName:(0,e.as)(t,"operation-not-supported-in-this-environment"),u.displayName&&(s.appDisplayName=u.displayName),s.sessionId=a,(0,e.at)(t,o,r.type,void 0,null!==(i=r.eventId)&&void 0!==i?i:void 0,s)}async function i(t){const{BuildInfo:r}=n(),o={};(0,e.aq)()?o.iosBundleId=r.packageName:(0,e.ar)()?o.androidPackageName=r.packageName:(0,e.as)(t,"operation-not-supported-in-this-environment"),await(0,e.au)(t,o)}function u(t){const{cordova:r}=n();return new Promise(n=>{r.plugins.browsertab.isAvailable(o=>{let i=null;o?r.plugins.browsertab.openUrl(t):i=r.InAppBrowser.open(t,(0,e.av)()?"_blank":"_system","location=yes"),n(i)})})}async function a(t,o,i){const{cordova:u}=n();let a=()=>{};try{await new Promise((n,s)=>{let c=null;function l(){var e;n();const t=null===(e=u.plugins.browsertab)||void 0===e?void 0:e.close;"function"==typeof t&&t(),"function"==typeof(null==i?void 0:i.close)&&i.close()}function d(){c||(c=window.setTimeout(()=>{s((0,e.aw)(t,"redirect-cancelled-by-user"))},r))}function p(){"visible"===(null===document||void 0===document?void 0:document.visibilityState)&&d()}o.addPassiveListener(l),document.addEventListener("resume",d,!1),(0,e.ar)()&&document.addEventListener("visibilitychange",p,!1),a=(()=>{o.removePassiveListener(l),document.removeEventListener("resume",d,!1),document.removeEventListener("visibilitychange",p,!1),c&&window.clearTimeout(c)})})}finally{a()}}function s(t){var r,o,i,u,a,s,c,l,d,p;const f=n();(0,e.ax)("function"==typeof(null===(r=null==f?void 0:f.universalLinks)||void 0===r?void 0:r.subscribe),t,"invalid-cordova-configuration",{missingPlugin:"cordova-universal-links-plugin-fix"}),(0,e.ax)(void 0!==(null===(o=null==f?void 0:f.BuildInfo)||void 0===o?void 0:o.packageName),t,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-buildInfo"}),(0,e.ax)("function"==typeof(null===(a=null===(u=null===(i=null==f?void 0:f.cordova)||void 0===i?void 0:i.plugins)||void 0===u?void 0:u.browsertab)||void 0===a?void 0:a.openUrl),t,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),(0,e.ax)("function"==typeof(null===(l=null===(c=null===(s=null==f?void 0:f.cordova)||void 0===s?void 0:s.plugins)||void 0===c?void 0:c.browsertab)||void 0===l?void 0:l.isAvailable),t,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-browsertab"}),(0,e.ax)("function"==typeof(null===(p=null===(d=null==f?void 0:f.cordova)||void 0===d?void 0:d.InAppBrowser)||void 0===p?void 0:p.open),t,"invalid-cordova-configuration",{missingPlugin:"cordova-plugin-inappbrowser"})}async function c(e){const t=l(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")}function l(t){if((0,e.ap)(/[0-9a-zA-Z]+/.test(t),"Can only convert alpha-numeric strings"),"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);const n=new ArrayBuffer(t.length),r=new Uint8Array(n);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r}const d=20;class p extends e.ay{constructor(){super(...arguments),this.passiveListeners=new Set,this.initPromise=new Promise(e=>{this.resolveInialized=e})}addPassiveListener(e){this.passiveListeners.add(e)}removePassiveListener(e){this.passiveListeners.delete(e)}resetRedirect(){this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1}onEvent(e){return this.resolveInialized(),this.passiveListeners.forEach(t=>t(e)),super.onEvent(e)}async initialized(){await this.initPromise}}function f(t,n,r=null){return{type:n,eventId:r,urlResponse:null,sessionId:y(),postBody:null,tenantId:t.tenantId,error:(0,e.aw)(t,"no-auth-event")}}function b(e,t){return P()._set(v(e),t)}async function g(e){const t=await P()._get(v(e));return t&&await P()._remove(v(e)),t}function m(t,n){var r,o;const i=x(n);if(i.includes("/__/auth/callback")){const n=O(i),u=n.firebaseError?h(decodeURIComponent(n.firebaseError)):null,a=null===(o=null===(r=null==u?void 0:u.code)||void 0===r?void 0:r.split("auth/"))||void 0===o?void 0:o[1],s=a?(0,e.aw)(a):null;return s?{type:t.type,eventId:t.eventId,tenantId:t.tenantId,error:s,urlResponse:null,sessionId:null,postBody:null}:{type:t.type,eventId:t.eventId,tenantId:t.tenantId,sessionId:t.sessionId,urlResponse:i,postBody:null}}return null}function y(){const e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let n=0;n<d;n++){const n=Math.floor(Math.random()*t.length);e.push(t.charAt(n))}return e.join("")}function P(){return(0,e.az)(e.b)}function v(t){return(0,e.aA)("authEvent",t.config.apiKey,t.name)}function h(e){try{return JSON.parse(e)}catch(t){return null}}function x(e){const t=O(e),n=t.link?decodeURIComponent(t.link):void 0,r=O(n).link,o=t.deep_link_id?decodeURIComponent(t.deep_link_id):void 0;return O(o).link||o||r||n||e}function O(e){if(!(null==e?void 0:e.includes("?")))return{};const[n,...r]=e.split("?");return(0,t.querystringDecode)(r.join("?"))}const j=500;class w{constructor(){this._redirectPersistence=e.a,this._shouldInitProactively=!0,this.eventManagers=new Map,this.originValidationPromises={},this._completeRedirectFn=e.aB,this._overrideRedirectResult=e.aC}async _initialize(e){const t=e._key();let n=this.eventManagers.get(t);return n||(n=new p(e),this.eventManagers.set(t,n),this.attachCallbackListeners(e,n)),n}_openPopup(t){(0,e.as)(t,"operation-not-supported-in-this-environment")}async _openRedirect(t,n,r,i){s(t);const c=await this._initialize(t);await c.initialized(),c.resetRedirect(),(0,e.aD)(),await this._originValidation(t);const l=f(t,r,i);await b(t,l);const d=await o(t,l,n);return a(t,c,await u(d))}_isIframeWebStorageSupported(e,t){throw new Error("Method not implemented.")}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=i(e)),this.originValidationPromises[t]}attachCallbackListeners(e,t){const{universalLinks:r,handleOpenURL:o,BuildInfo:i}=n(),u=setTimeout(async()=>{await g(e),t.onEvent(A())},j),a=async n=>{clearTimeout(u);const r=await g(e);let o=null;r&&(null==n?void 0:n.url)&&(o=m(r,n.url)),t.onEvent(o||A())};void 0!==r&&"function"==typeof r.subscribe&&r.subscribe(null,a);const s=o,c=`${i.packageName.toLowerCase()}://`;n().handleOpenURL=(async e=>{if(e.toLowerCase().startsWith(c)&&a({url:e}),"function"==typeof s)try{s(e)}catch(t){console.error(t)}})}}const I=w;function A(){return{type:"unknown",eventId:null,sessionId:null,urlResponse:null,postBody:null,tenantId:null,error:(0,e.aw)("no-auth-event")}}function k(t,n){(0,e.aE)(t)._logFramework(n)}exports.cordovaPopupRedirectResolver=I;
|
|
490
|
+
},{"./index-3363a72a.js":"z5kx","@firebase/util":"chA2","@firebase/app":"h2Mb","@firebase/logger":"JJem","tslib":"vCxL","@firebase/component":"vhY9"}],"h9Y9":[function(require,module,exports) {
|
|
480
491
|
var global = arguments[3];
|
|
481
|
-
var t=arguments[3],e=n(require("@firebase/app"));function n(t){return t&&t.__esModule?t:{default:t}}(function(){var n,i="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,n){t!=Array.prototype&&t!=Object.prototype&&(t[e]=n.value)};var r=function(e){e=["object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof t&&t,e];for(var n=0;n<e.length;++n){var i=e[n];if(i&&i.Math==Math)return i}return globalThis}(this);function o(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}function a(t){var e="undefined"!=typeof Symbol&&Symbol.iterator&&t[Symbol.iterator];return e?e.call(t):{next:o(t)}}!function(t,e){if(e){var n=r;t=t.split(".");for(var o=0;o<t.length-1;o++){var a=t[o];a in n||(n[a]={}),n=n[a]}(e=e(o=n[t=t[t.length-1]]))!=o&&null!=e&&i(n,t,{configurable:!0,writable:!0,value:e})}}("Promise",function(t){function e(t){this.b=0,this.c=void 0,this.a=[];var e=this.f();try{t(e.resolve,e.reject)}catch(n){e.reject(n)}}function n(){this.a=null}function i(t){return t instanceof e?t:new e(function(e){e(t)})}if(t)return t;n.prototype.b=function(t){if(null==this.a){this.a=[];var e=this;this.c(function(){e.g()})}this.a.push(t)};var o=r.setTimeout;n.prototype.c=function(t){o(t,0)},n.prototype.g=function(){for(;this.a&&this.a.length;){var t=this.a;this.a=[];for(var e=0;e<t.length;++e){var n=t[e];t[e]=null;try{n()}catch(i){this.f(i)}}}this.a=null},n.prototype.f=function(t){this.c(function(){throw t})},e.prototype.f=function(){function t(t){return function(i){n||(n=!0,t.call(e,i))}}var e=this,n=!1;return{resolve:t(this.m),reject:t(this.g)}},e.prototype.m=function(t){if(t===this)this.g(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof e)this.s(t);else{t:switch(typeof t){case"object":var n=null!=t;break t;case"function":n=!0;break t;default:n=!1}n?this.v(t):this.h(t)}},e.prototype.v=function(t){var e=void 0;try{e=t.then}catch(n){return void this.g(n)}"function"==typeof e?this.u(e,t):this.h(t)},e.prototype.g=function(t){this.i(2,t)},e.prototype.h=function(t){this.i(1,t)},e.prototype.i=function(t,e){if(0!=this.b)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.b);this.b=t,this.c=e,this.l()},e.prototype.l=function(){if(null!=this.a){for(var t=0;t<this.a.length;++t)s.b(this.a[t]);this.a=null}};var s=new n;return e.prototype.s=function(t){var e=this.f();t.Ra(e.resolve,e.reject)},e.prototype.u=function(t,e){var n=this.f();try{t.call(e,n.resolve,n.reject)}catch(i){n.reject(i)}},e.prototype.then=function(t,n){function i(t,e){return"function"==typeof t?function(e){try{r(t(e))}catch(n){o(n)}}:e}var r,o,a=new e(function(t,e){r=t,o=e});return this.Ra(i(t,r),i(n,o)),a},e.prototype.catch=function(t){return this.then(void 0,t)},e.prototype.Ra=function(t,e){function n(){switch(i.b){case 1:t(i.c);break;case 2:e(i.c);break;default:throw Error("Unexpected state: "+i.b)}}var i=this;null==this.a?s.b(n):this.a.push(n)},e.resolve=i,e.reject=function(t){return new e(function(e,n){n(t)})},e.race=function(t){return new e(function(e,n){for(var r=a(t),o=r.next();!o.done;o=r.next())i(o.value).Ra(e,n)})},e.all=function(t){var n=a(t),r=n.next();return r.done?i([]):new e(function(t,e){function o(e){return function(n){a[e]=n,0==--s&&t(a)}}var a=[],s=0;do{a.push(void 0),s++,i(r.value).Ra(o(a.length-1),e),r=n.next()}while(!r.done)})},e});var s=s||{},u=this||self,c=/^[\w+/_-]+[=]{0,2}$/,h=null;function l(t){return(t=t.querySelector&&t.querySelector("script[nonce]"))&&(t=t.nonce||t.getAttribute("nonce"))&&c.test(t)?t:""}function f(){}function d(t){var e=typeof t;return"object"!=e?e:t?Array.isArray(t)?"array":e:"null"}function p(t){var e=d(t);return"array"==e||"object"==e&&"number"==typeof t.length}function v(t){return"function"==d(t)}function m(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}function g(t){return Object.prototype.hasOwnProperty.call(t,b)&&t[b]||(t[b]=++y)}var b="closure_uid_"+(1e9*Math.random()>>>0),y=0;function w(t,e,n){return t.call.apply(t.bind,arguments)}function I(t,e,n){if(!t)throw Error();if(2<arguments.length){var i=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,i),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function T(t,e,n){return(T=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?w:I).apply(null,arguments)}function E(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}var A=Date.now;function k(t,e){function n(){}n.prototype=e.prototype,t.bb=e.prototype,t.prototype=new n,t.prototype.constructor=t}function S(t){return t}function N(t,e,n){this.code=C+t,this.message=e||R[t]||"",this.a=n||null}function _(t){var e=t&&t.code;return e?new N(e.substring(C.length),t.message,t.serverResponse):null}k(N,Error),N.prototype.w=function(){var t={code:this.code,message:this.message};return this.a&&(t.serverResponse=this.a),t},N.prototype.toJSON=function(){return this.w()};var O,C="auth/",R={"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-change-needs-verification":"Multi-factor users must always have a verified email.","email-already-in-use":"The email address is already in use by another account.","expired-action-code":"The action code has expired. ","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal error has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registed for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal error has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure to use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-multi-factor-session":"The request does not contain a valid proof of first factor successful sign-in.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","multi-factor-info-not-found":"The user does not have a second factor matching the identifier provided.","multi-factor-auth-required":"Proof of ownership of a second factor is required to complete sign-in.","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal error has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-multi-factor-info":"No second factor identifier is provided.","missing-multi-factor-session":"The request is missing proof of first factor successful sign-in.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network error (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal error has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","second-factor-already-in-use":"The second factor is already enrolled on this account.","maximum-second-factor-count-exceeded":"The maximum allowed number of second factors on a user has been exceeded.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.","unsupported-first-factor":"Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","unverified-email":"The operation requires a verified email.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled."},P={ld:{Ua:"https://staging-identitytoolkit.sandbox.googleapis.com/identitytoolkit/v3/relyingparty/",$a:"https://staging-securetoken.sandbox.googleapis.com/v1/token",Xa:"https://staging-identitytoolkit.sandbox.googleapis.com/v2/",id:"b"},sd:{Ua:"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",$a:"https://securetoken.googleapis.com/v1/token",Xa:"https://identitytoolkit.googleapis.com/v2/",id:"p"},ud:{Ua:"https://staging-www.sandbox.googleapis.com/identitytoolkit/v3/relyingparty/",$a:"https://staging-securetoken.sandbox.googleapis.com/v1/token",Xa:"https://staging-identitytoolkit.sandbox.googleapis.com/v2/",id:"s"},vd:{Ua:"https://www-googleapis-test.sandbox.google.com/identitytoolkit/v3/relyingparty/",$a:"https://test-securetoken.sandbox.googleapis.com/v1/token",Xa:"https://test-identitytoolkit.sandbox.googleapis.com/v2/",id:"t"}};function D(t){for(var e in P)if(P[e].id===t)return{firebaseEndpoint:(t=P[e]).Ua,secureTokenEndpoint:t.$a,identityPlatformEndpoint:t.Xa};return null}function L(t){if(!t)return!1;try{return!!t.$goog_Thenable}catch(e){return!1}}function x(t){if(Error.captureStackTrace)Error.captureStackTrace(this,x);else{var e=Error().stack;e&&(this.stack=e)}t&&(this.message=String(t))}function M(t,e){for(var n="",i=(t=t.split("%s")).length-1,r=0;r<i;r++)n+=t[r]+(r<e.length?e[r]:"%s");x.call(this,n+t[i])}function j(t,e){throw new M("Failure"+(t?": "+t:""),Array.prototype.slice.call(arguments,1))}function U(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function V(t,e){t.f(e),100>t.b&&(t.b++,e.next=t.a,t.a=e)}function F(){this.b=this.a=null}O=D("__EID__")?"__EID__":void 0,k(x,Error),x.prototype.name="CustomError",k(M,x),M.prototype.name="AssertionError",U.prototype.get=function(){if(0<this.b){this.b--;var t=this.a;this.a=t.next,t.next=null}else t=this.c();return t};var q=new U(function(){return new H},function(t){t.reset()});function K(){var t=Ie,e=null;return t.a&&(e=t.a,t.a=t.a.next,t.a||(t.b=null),e.next=null),e}function H(){this.next=this.b=this.a=null}F.prototype.add=function(t,e){var n=q.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},H.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null},H.prototype.reset=function(){this.next=this.b=this.a=null};var G=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if("string"==typeof t)return"string"!=typeof e||1!=e.length?-1:t.indexOf(e,0);for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},B=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var i=t.length,r="string"==typeof t?t.split(""):t,o=0;o<i;o++)o in r&&e.call(n,r[o],o,t)};var W=Array.prototype.filter?function(t,e){return Array.prototype.filter.call(t,e,void 0)}:function(t,e){for(var n=t.length,i=[],r=0,o="string"==typeof t?t.split(""):t,a=0;a<n;a++)if(a in o){var s=o[a];e.call(void 0,s,a,t)&&(i[r++]=s)}return i},X=Array.prototype.map?function(t,e){return Array.prototype.map.call(t,e,void 0)}:function(t,e){for(var n=t.length,i=Array(n),r="string"==typeof t?t.split(""):t,o=0;o<n;o++)o in r&&(i[o]=e.call(void 0,r[o],o,t));return i},J=Array.prototype.some?function(t,e){return Array.prototype.some.call(t,e,void 0)}:function(t,e){for(var n=t.length,i="string"==typeof t?t.split(""):t,r=0;r<n;r++)if(r in i&&e.call(void 0,i[r],r,t))return!0;return!1};function Y(t,e){return 0<=G(t,e)}function z(t,e){var n;return(n=0<=(e=G(t,e)))&&Array.prototype.splice.call(t,e,1),n}function $(t,e){!function(t,e){for(var n="string"==typeof t?t.split(""):t,i=t.length-1;0<=i;--i)i in n&&e.call(void 0,n[i],i,t)}(t,function(n,i){e.call(void 0,n,i,t)&&1==Array.prototype.splice.call(t,i,1).length&&0})}function Z(t){return Array.prototype.concat.apply([],arguments)}function Q(t){var e=t.length;if(0<e){for(var n=Array(e),i=0;i<e;i++)n[i]=t[i];return n}return[]}var tt,et=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]},nt=/&/g,it=/</g,rt=/>/g,ot=/"/g,at=/'/g,st=/\x00/g,ut=/[\x00&<>"']/;function ct(t,e){return-1!=t.indexOf(e)}function ht(t,e){return t<e?-1:t>e?1:0}t:{var lt=u.navigator;if(lt){var ft=lt.userAgent;if(ft){tt=ft;break t}}tt=""}function dt(t){return ct(tt,t)}function pt(t,e){for(var n in t)e.call(void 0,t[n],n,t)}function vt(t){for(var e in t)return!1;return!0}function mt(t){var e,n={};for(e in t)n[e]=t[e];return n}var gt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function bt(t,e){for(var n,i,r=1;r<arguments.length;r++){for(n in i=arguments[r])t[n]=i[n];for(var o=0;o<gt.length;o++)n=gt[o],Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}}function yt(t,e){t:{try{var n=t&&t.ownerDocument,i=n&&(n.defaultView||n.parentWindow);if((i=i||u).Element&&i.Location){var r=i;break t}}catch(a){}r=null}if(r&&void 0!==r[e]&&(!t||!(t instanceof r[e])&&(t instanceof r.Location||t instanceof r.Element))){if(m(t))try{var o=t.constructor.displayName||t.constructor.name||Object.prototype.toString.call(t)}catch(a){o="<object could not be stringified>"}else o=void 0===t?"undefined":null===t?"null":typeof t;j("Argument is not a %s (or a non-Element, non-Location mock); got: %s",e,o)}}function wt(t,e){this.a=t===At&&e||"",this.b=Et}function It(t){return t instanceof wt&&t.constructor===wt&&t.b===Et?t.a:(j("expected object of type Const, got '"+t+"'"),"type_error:Const")}wt.prototype.ta=!0,wt.prototype.sa=function(){return this.a},wt.prototype.toString=function(){return"Const{"+this.a+"}"};var Tt,Et={},At={};function kt(){if(void 0===Tt){var t=null,e=u.trustedTypes;if(e&&e.createPolicy){try{t=e.createPolicy("goog#html",{createHTML:S,createScript:S,createScriptURL:S})}catch(n){u.console&&u.console.error(n.message)}Tt=t}else Tt=t}return Tt}function St(t,e){this.a=e===Rt?t:""}function Nt(t){return t instanceof St&&t.constructor===St?t.a:(j("expected object of type TrustedResourceUrl, got '"+t+"' of type "+d(t)),"type_error:TrustedResourceUrl")}function _t(t,e){var n=It(t);if(!Ct.test(n))throw Error("Invalid TrustedResourceUrl format: "+n);return function(t){var e=kt();return new St(t=e?e.createScriptURL(t):t,Rt)}(t=n.replace(Ot,function(t,i){if(!Object.prototype.hasOwnProperty.call(e,i))throw Error('Found marker, "'+i+'", in format string, "'+n+'", but no valid label mapping found in args: '+JSON.stringify(e));return(t=e[i])instanceof wt?It(t):encodeURIComponent(String(t))}))}St.prototype.ta=!0,St.prototype.sa=function(){return this.a.toString()},St.prototype.toString=function(){return"TrustedResourceUrl{"+this.a+"}"};var Ot=/%{(\w+)}/g,Ct=/^((https:)?\/\/[0-9a-z.:[\]-]+\/|\/[^/\\]|[^:/\\%]+\/|[^:/\\%]*[?#]|about:blank#)/i,Rt={};function Pt(t,e){this.a=e===Vt?t:""}function Dt(t){return t instanceof Pt&&t.constructor===Pt?t.a:(j("expected object of type SafeUrl, got '"+t+"' of type "+d(t)),"type_error:SafeUrl")}Pt.prototype.ta=!0,Pt.prototype.sa=function(){return this.a.toString()},Pt.prototype.toString=function(){return"SafeUrl{"+this.a+"}"};var Lt=/^(?:audio\/(?:3gpp2|3gpp|aac|L16|midi|mp3|mp4|mpeg|oga|ogg|opus|x-m4a|x-matroska|x-wav|wav|webm)|font\/\w+|image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp|x-icon)|text\/csv|video\/(?:mpeg|mp4|ogg|webm|quicktime|x-matroska))(?:;\w+=(?:\w+|"[\w;,= ]+"))*$/i,xt=/^data:(.*);base64,[a-z0-9+\/]+=*$/i,Mt=/^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i;function jt(t){if(t instanceof Pt)return t;if(t="object"==typeof t&&t.ta?t.sa():String(t),Mt.test(t))t=new Pt(t,Vt);else{var e=(t=(t=String(t)).replace(/(%0A|%0D)/g,"")).match(xt);t=e&&Lt.test(e[1])?new Pt(t,Vt):null}return t}function Ut(t){return t instanceof Pt?t:(t="object"==typeof t&&t.ta?t.sa():String(t),Mt.test(t)||(t="about:invalid#zClosurez"),new Pt(t,Vt))}var Vt={},Ft=new Pt("about:invalid#zClosurez",Vt);function qt(t,e,n){this.a=n===Kt?t:""}qt.prototype.ta=!0,qt.prototype.sa=function(){return this.a.toString()},qt.prototype.toString=function(){return"SafeHtml{"+this.a+"}"};var Kt={};function Ht(t,e,n,i){return t=t instanceof Pt?t:Ut(t),e=e||u,n=n instanceof wt?It(n):n||"",e.open(Dt(t),n,i,void 0)}function Gt(t,e){for(var n=t.split("%s"),i="",r=Array.prototype.slice.call(arguments,1);r.length&&1<n.length;)i+=n.shift()+r.shift();return i+n.join("%s")}function Bt(t){return ut.test(t)&&(-1!=t.indexOf("&")&&(t=t.replace(nt,"&")),-1!=t.indexOf("<")&&(t=t.replace(it,"<")),-1!=t.indexOf(">")&&(t=t.replace(rt,">")),-1!=t.indexOf('"')&&(t=t.replace(ot,""")),-1!=t.indexOf("'")&&(t=t.replace(at,"'")),-1!=t.indexOf("\0")&&(t=t.replace(st,"�"))),t}function Wt(t){return Wt[" "](t),t}Wt[" "]=f;var Xt,Jt,Yt=dt("Opera"),zt=dt("Trident")||dt("MSIE"),$t=dt("Edge"),Zt=$t||zt,Qt=dt("Gecko")&&!(ct(tt.toLowerCase(),"webkit")&&!dt("Edge"))&&!(dt("Trident")||dt("MSIE"))&&!dt("Edge"),te=ct(tt.toLowerCase(),"webkit")&&!dt("Edge");function ee(){var t=u.document;return t?t.documentMode:void 0}t:{var ne="",ie=(Jt=tt,Qt?/rv:([^\);]+)(\)|;)/.exec(Jt):$t?/Edge\/([\d\.]+)/.exec(Jt):zt?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(Jt):te?/WebKit\/(\S+)/.exec(Jt):Yt?/(?:Version)[ \/]?(\S+)/.exec(Jt):void 0);if(ie&&(ne=ie?ie[1]:""),zt){var re=ee();if(null!=re&&re>parseFloat(ne)){Xt=String(re);break t}}Xt=ne}var oe,ae={};function se(t){return function(t,e){var n=ae;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(t,function(){for(var e=0,n=et(String(Xt)).split("."),i=et(String(t)).split("."),r=Math.max(n.length,i.length),o=0;0==e&&o<r;o++){var a=n[o]||"",s=i[o]||"";do{if(a=/(\d*)(\D*)(.*)/.exec(a)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],0==a[0].length&&0==s[0].length)break;e=ht(0==a[1].length?0:parseInt(a[1],10),0==s[1].length?0:parseInt(s[1],10))||ht(0==a[2].length,0==s[2].length)||ht(a[2],s[2]),a=a[3],s=s[3]}while(0==e)}return 0<=e})}if(u.document&&zt){var ue=ee();oe=ue||(parseInt(Xt,10)||void 0)}else oe=void 0;var ce=oe;try{new self.OffscreenCanvas(0,0).getContext("2d")}catch(Jt){}var he=!zt||9<=Number(ce);function le(t){var e=document;return"string"==typeof t?e.getElementById(t):t}function fe(t,e){pt(e,function(e,n){e&&"object"==typeof e&&e.ta&&(e=e.sa()),"style"==n?t.style.cssText=e:"class"==n?t.className=e:"for"==n?t.htmlFor=e:ve.hasOwnProperty(n)?t.setAttribute(ve[n],e):0==n.lastIndexOf("aria-",0)||0==n.lastIndexOf("data-",0)?t.setAttribute(n,e):t[n]=e})}var de,pe,ve={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",nonce:"nonce",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"};function me(t,e,n){var i=arguments,r=document,o=String(i[0]),a=i[1];if(!he&&a&&(a.name||a.type)){if(o=["<",o],a.name&&o.push(' name="',Bt(a.name),'"'),a.type){o.push(' type="',Bt(a.type),'"');var s={};bt(s,a),delete s.type,a=s}o.push(">"),o=o.join("")}return o=ge(r,o),a&&("string"==typeof a?o.className=a:Array.isArray(a)?o.className=a.join(" "):fe(o,a)),2<i.length&&function(t,e,n){function i(n){n&&e.appendChild("string"==typeof n?t.createTextNode(n):n)}for(var r=2;r<n.length;r++){var o=n[r];if(!p(o)||m(o)&&0<o.nodeType)i(o);else{t:{if(o&&"number"==typeof o.length){if(m(o)){var a="function"==typeof o.item||"string"==typeof o.item;break t}if(v(o)){a="function"==typeof o.item;break t}}a=!1}B(a?Q(o):o,i)}}}(r,o,i),o}function ge(t,e){return e=String(e),"application/xhtml+xml"===t.contentType&&(e=e.toLowerCase()),t.createElement(e)}function be(t){u.setTimeout(function(){throw t},0)}function ye(t,e){pe||function(){if(u.Promise&&u.Promise.resolve){var t=u.Promise.resolve(void 0);pe=function(){t.then(Te)}}else pe=function(){var t=Te;!v(u.setImmediate)||u.Window&&u.Window.prototype&&!dt("Edge")&&u.Window.prototype.setImmediate==u.setImmediate?(de||(de=function(){var t=u.MessageChannel;if(void 0===t&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&!dt("Presto")&&(t=function(){var t=ge(document,"IFRAME");t.style.display="none",document.documentElement.appendChild(t);var e=t.contentWindow;(t=e.document).open(),t.close();var n="callImmediate"+Math.random(),i="file:"==e.location.protocol?"*":e.location.protocol+"//"+e.location.host;t=T(function(t){"*"!=i&&t.origin!=i||t.data!=n||this.port1.onmessage()},this),e.addEventListener("message",t,!1),this.port1={},this.port2={postMessage:function(){e.postMessage(n,i)}}}),void 0!==t&&!dt("Trident")&&!dt("MSIE")){var e=new t,n={},i=n;return e.port1.onmessage=function(){if(void 0!==n.next){var t=(n=n.next).Hb;n.Hb=null,t()}},function(t){i.next={Hb:t},i=i.next,e.port2.postMessage(0)}}return function(t){u.setTimeout(t,0)}}()),de(t)):u.setImmediate(t)}}(),we||(pe(),we=!0),Ie.add(t,e)}var we=!1,Ie=new F;function Te(){for(var t;t=K();){try{t.a.call(t.b)}catch(e){be(e)}V(q,t)}we=!1}function Ee(t,e){if(this.a=Ae,this.i=void 0,this.f=this.b=this.c=null,this.g=this.h=!1,t!=f)try{var n=this;t.call(e,function(t){Me(n,ke,t)},function(t){if(!(t instanceof He))try{if(t instanceof Error)throw t;throw Error("Promise rejected.")}catch(e){}Me(n,Se,t)})}catch(i){Me(this,Se,i)}}var Ae=0,ke=2,Se=3;function Ne(){this.next=this.f=this.b=this.g=this.a=null,this.c=!1}Ne.prototype.reset=function(){this.f=this.b=this.g=this.a=null,this.c=!1};var _e=new U(function(){return new Ne},function(t){t.reset()});function Oe(t,e,n){var i=_e.get();return i.g=t,i.b=e,i.f=n,i}function Ce(t){if(t instanceof Ee)return t;var e=new Ee(f);return Me(e,ke,t),e}function Re(t){return new Ee(function(e,n){n(t)})}function Pe(t,e,n){je(t,e,n,null)||ye(E(e,t))}function De(t){return new Ee(function(e){var n=t.length,i=[];if(n)for(var r=function(t,r,o){n--,i[t]=r?{Qb:!0,value:o}:{Qb:!1,reason:o},0==n&&e(i)},o=0;o<t.length;o++)Pe(t[o],E(r,o,!0),E(r,o,!1));else e(i)})}function Le(t,e){t.b||t.a!=ke&&t.a!=Se||Ue(t),t.f?t.f.next=e:t.b=e,t.f=e}function xe(t,e,n,i){var r=Oe(null,null,null);return r.a=new Ee(function(t,o){r.g=e?function(n){try{var r=e.call(i,n);t(r)}catch(a){o(a)}}:t,r.b=n?function(e){try{var r=n.call(i,e);void 0===r&&e instanceof He?o(e):t(r)}catch(a){o(a)}}:o}),r.a.c=t,Le(t,r),r.a}function Me(t,e,n){t.a==Ae&&(t===n&&(e=Se,n=new TypeError("Promise cannot resolve to itself")),t.a=1,je(n,t.$c,t.ad,t)||(t.i=n,t.a=e,t.c=null,Ue(t),e!=Se||n instanceof He||function(t,e){t.g=!0,ye(function(){t.g&&Ke.call(null,e)})}(t,n)))}function je(t,e,n,i){if(t instanceof Ee)return Le(t,Oe(e||f,n||null,i)),!0;if(L(t))return t.then(e,n,i),!0;if(m(t))try{var r=t.then;if(v(r))return function(t,e,n,i,r){function o(t){a||(a=!0,i.call(r,t))}var a=!1;try{e.call(t,function(t){a||(a=!0,n.call(r,t))},o)}catch(s){o(s)}}(t,r,e,n,i),!0}catch(o){return n.call(i,o),!0}return!1}function Ue(t){t.h||(t.h=!0,ye(t.gc,t))}function Ve(t){var e=null;return t.b&&(e=t.b,t.b=e.next,e.next=null),t.b||(t.f=null),e}function Fe(t,e,n,i){if(n==Se&&e.b&&!e.c)for(;t&&t.g;t=t.c)t.g=!1;if(e.a)e.a.c=null,qe(e,n,i);else try{e.c?e.g.call(e.f):qe(e,n,i)}catch(r){Ke.call(null,r)}V(_e,e)}function qe(t,e,n){e==ke?t.g.call(t.f,n):t.b&&t.b.call(t.f,n)}Ee.prototype.then=function(t,e,n){return xe(this,v(t)?t:null,v(e)?e:null,n)},Ee.prototype.$goog_Thenable=!0,(n=Ee.prototype).oa=function(t,e){return(t=Oe(t,t,e)).c=!0,Le(this,t),this},n.o=function(t,e){return xe(this,null,t,e)},n.cancel=function(t){if(this.a==Ae){var e=new He(t);ye(function(){!function t(e,n){if(e.a==Ae)if(e.c){var i=e.c;if(i.b){for(var r=0,o=null,a=null,s=i.b;s&&(s.c||(r++,s.a==e&&(o=s),!(o&&1<r)));s=s.next)o||(a=s);o&&(i.a==Ae&&1==r?t(i,n):(a?((r=a).next==i.f&&(i.f=r),r.next=r.next.next):Ve(i),Fe(i,o,Se,n)))}e.c=null}else Me(e,Se,n)}(this,e)},this)}},n.$c=function(t){this.a=Ae,Me(this,ke,t)},n.ad=function(t){this.a=Ae,Me(this,Se,t)},n.gc=function(){for(var t;t=Ve(this);)Fe(this,t,this.a,this.i);this.h=!1};var Ke=be;function He(t){x.call(this,t)}function Ge(){0!=Be&&(We[g(this)]=this),this.ya=this.ya,this.pa=this.pa}k(He,x),He.prototype.name="cancel";var Be=0,We={};function Xe(t){if(!t.ya&&(t.ya=!0,t.Da(),0!=Be)){var e=g(t);if(0!=Be&&t.pa&&0<t.pa.length)throw Error(t+" did not empty its onDisposeCallbacks queue. This probably means it overrode dispose() or disposeInternal() without calling the superclass' method.");delete We[e]}}Ge.prototype.ya=!1,Ge.prototype.Da=function(){if(this.pa)for(;this.pa.length;)this.pa.shift()()};var Je=Object.freeze||function(t){return t},Ye=!zt||9<=Number(ce),ze=zt&&!se("9"),$e=function(){if(!u.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{u.addEventListener("test",f,e),u.removeEventListener("test",f,e)}catch(n){}return t}();function Ze(t,e){this.type=t,this.b=this.target=e,this.defaultPrevented=!1}function Qe(t,e){if(Ze.call(this,t?t.type:""),this.relatedTarget=this.b=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.pointerId=0,this.pointerType="",this.a=null,t){var n=this.type=t.type,i=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.b=e,e=t.relatedTarget){if(Qt){t:{try{Wt(e.nodeName);var r=!0;break t}catch(o){}r=!1}r||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,i?(this.clientX=void 0!==i.clientX?i.clientX:i.pageX,this.clientY=void 0!==i.clientY?i.clientY:i.pageY,this.screenX=i.screenX||0,this.screenY=i.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:tn[t.pointerType]||"",this.a=t,t.defaultPrevented&&this.preventDefault()}}Ze.prototype.preventDefault=function(){this.defaultPrevented=!0},k(Qe,Ze);var tn=Je({2:"touch",3:"pen",4:"mouse"});Qe.prototype.preventDefault=function(){Qe.bb.preventDefault.call(this);var t=this.a;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,ze)try{(t.ctrlKey||112<=t.keyCode&&123>=t.keyCode)&&(t.keyCode=-1)}catch(e){}},Qe.prototype.g=function(){return this.a};var en="closure_listenable_"+(1e6*Math.random()|0),nn=0;function rn(t,e,n,i,r){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!i,this.Wa=r,this.key=++nn,this.wa=this.Qa=!1}function on(t){t.wa=!0,t.listener=null,t.proxy=null,t.src=null,t.Wa=null}function an(t){this.src=t,this.a={},this.b=0}function sn(t,e){var n=e.type;n in t.a&&z(t.a[n],e)&&(on(e),0==t.a[n].length&&(delete t.a[n],t.b--))}function un(t,e,n,i){for(var r=0;r<t.length;++r){var o=t[r];if(!o.wa&&o.listener==e&&o.capture==!!n&&o.Wa==i)return r}return-1}an.prototype.add=function(t,e,n,i,r){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var a=un(t,e,i,r);return-1<a?(e=t[a],n||(e.Qa=!1)):((e=new rn(e,this.src,o,!!i,r)).Qa=n,t.push(e)),e};var cn="closure_lm_"+(1e6*Math.random()|0),hn={};function ln(t,e,n,i,r){if(i&&i.once)dn(t,e,n,i,r);else if(Array.isArray(e))for(var o=0;o<e.length;o++)ln(t,e[o],n,i,r);else n=Tn(n),t&&t[en]?An(t,e,n,m(i)?!!i.capture:!!i,r):fn(t,e,n,!1,i,r)}function fn(t,e,n,i,r,o){if(!e)throw Error("Invalid event type");var a=m(r)?!!r.capture:!!r,s=wn(t);if(s||(t[cn]=s=new an(t)),!(n=s.add(e,n,i,a,o)).proxy){if(i=function(){var t=yn,e=Ye?function(n){return t.call(e.src,e.listener,n)}:function(n){if(!(n=t.call(e.src,e.listener,n)))return n};return e}(),n.proxy=i,i.src=t,i.listener=n,t.addEventListener)$e||(r=a),void 0===r&&(r=!1),t.addEventListener(e.toString(),i,r);else if(t.attachEvent)t.attachEvent(mn(e.toString()),i);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(i)}0}}function dn(t,e,n,i,r){if(Array.isArray(e))for(var o=0;o<e.length;o++)dn(t,e[o],n,i,r);else n=Tn(n),t&&t[en]?kn(t,e,n,m(i)?!!i.capture:!!i,r):fn(t,e,n,!0,i,r)}function pn(t,e,n,i,r){if(Array.isArray(e))for(var o=0;o<e.length;o++)pn(t,e[o],n,i,r);else i=m(i)?!!i.capture:!!i,n=Tn(n),t&&t[en]?(t=t.v,(e=String(e).toString())in t.a&&(-1<(n=un(o=t.a[e],n,i,r))&&(on(o[n]),Array.prototype.splice.call(o,n,1),0==o.length&&(delete t.a[e],t.b--)))):t&&(t=wn(t))&&(e=t.a[e.toString()],t=-1,e&&(t=un(e,n,i,r)),(n=-1<t?e[t]:null)&&vn(n))}function vn(t){if("number"!=typeof t&&t&&!t.wa){var e=t.src;if(e&&e[en])sn(e.v,t);else{var n=t.type,i=t.proxy;e.removeEventListener?e.removeEventListener(n,i,t.capture):e.detachEvent?e.detachEvent(mn(n),i):e.addListener&&e.removeListener&&e.removeListener(i),0,(n=wn(e))?(sn(n,t),0==n.b&&(n.src=null,e[cn]=null)):on(t)}}}function mn(t){return t in hn?hn[t]:hn[t]="on"+t}function gn(t,e,n,i){var r=!0;if((t=wn(t))&&(e=t.a[e.toString()]))for(e=e.concat(),t=0;t<e.length;t++){var o=e[t];o&&o.capture==n&&!o.wa&&(o=bn(o,i),r=r&&!1!==o)}return r}function bn(t,e){var n=t.listener,i=t.Wa||t.src;return t.Qa&&vn(t),n.call(i,e)}function yn(t,e){if(t.wa)return!0;if(!Ye){if(!e)t:{e=["window","event"];for(var n=u,i=0;i<e.length;i++)if(null==(n=n[e[i]])){e=null;break t}e=n}if(e=new Qe(i=e,this),n=!0,!(0>i.keyCode||null!=i.returnValue)){t:{var r=!1;if(0==i.keyCode)try{i.keyCode=-1;break t}catch(a){r=!0}(r||null==i.returnValue)&&(i.returnValue=!0)}for(i=[],r=e.b;r;r=r.parentNode)i.push(r);for(t=t.type,r=i.length-1;0<=r;r--){e.b=i[r];var o=gn(i[r],t,!0,e);n=n&&o}for(r=0;r<i.length;r++)e.b=i[r],o=gn(i[r],t,!1,e),n=n&&o}return n}return bn(t,new Qe(e,this))}function wn(t){return(t=t[cn])instanceof an?t:null}var In="__closure_events_fn_"+(1e9*Math.random()>>>0);function Tn(t){return v(t)?t:(t[In]||(t[In]=function(e){return t.handleEvent(e)}),t[In])}function En(){Ge.call(this),this.v=new an(this),this.bc=this,this.hb=null}function An(t,e,n,i,r){t.v.add(String(e),n,!1,i,r)}function kn(t,e,n,i,r){t.v.add(String(e),n,!0,i,r)}function Sn(t,e,n,i){if(!(e=t.v.a[String(e)]))return!0;e=e.concat();for(var r=!0,o=0;o<e.length;++o){var a=e[o];if(a&&!a.wa&&a.capture==n){var s=a.listener,u=a.Wa||a.src;a.Qa&&sn(t.v,a),r=!1!==s.call(u,i)&&r}}return r&&!i.defaultPrevented}function Nn(t,e,n){if(v(t))n&&(t=T(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=T(t.handleEvent,t)}return 2147483647<Number(e)?-1:u.setTimeout(t,e||0)}function _n(t){var e=null;return new Ee(function(n,i){-1==(e=Nn(function(){n(void 0)},t))&&i(Error("Failed to schedule timer."))}).o(function(t){throw u.clearTimeout(e),t})}function On(t){if(t.X&&"function"==typeof t.X)return t.X();if("string"==typeof t)return t.split("");if(p(t)){for(var e=[],n=t.length,i=0;i<n;i++)e.push(t[i]);return e}for(i in e=[],n=0,t)e[n++]=t[i];return e}function Cn(t){if(t.Y&&"function"==typeof t.Y)return t.Y();if(!t.X||"function"!=typeof t.X){if(p(t)||"string"==typeof t){var e=[];t=t.length;for(var n=0;n<t;n++)e.push(n);return e}for(var i in e=[],n=0,t)e[n++]=i;return e}}function Rn(t,e){this.b={},this.a=[],this.c=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var i=0;i<n;i+=2)this.set(arguments[i],arguments[i+1])}else if(t)if(t instanceof Rn)for(n=t.Y(),i=0;i<n.length;i++)this.set(n[i],t.get(n[i]));else for(i in t)this.set(i,t[i])}function Pn(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var i=t.a[e];Dn(t.b,i)&&(t.a[n++]=i),e++}t.a.length=n}if(t.c!=t.a.length){var r={};for(n=e=0;e<t.a.length;)Dn(r,i=t.a[e])||(t.a[n++]=i,r[i]=1),e++;t.a.length=n}}function Dn(t,e){return Object.prototype.hasOwnProperty.call(t,e)}k(En,Ge),En.prototype[en]=!0,En.prototype.addEventListener=function(t,e,n,i){ln(this,t,e,n,i)},En.prototype.removeEventListener=function(t,e,n,i){pn(this,t,e,n,i)},En.prototype.dispatchEvent=function(t){var e,n=this.hb;if(n)for(e=[];n;n=n.hb)e.push(n);n=this.bc;var i=t.type||t;if("string"==typeof t)t=new Ze(t,n);else if(t instanceof Ze)t.target=t.target||n;else{var r=t;bt(t=new Ze(i,n),r)}if(r=!0,e)for(var o=e.length-1;0<=o;o--){var a=t.b=e[o];r=Sn(a,i,!0,t)&&r}if(r=Sn(a=t.b=n,i,!0,t)&&r,r=Sn(a,i,!1,t)&&r,e)for(o=0;o<e.length;o++)r=Sn(a=t.b=e[o],i,!1,t)&&r;return r},En.prototype.Da=function(){if(En.bb.Da.call(this),this.v){var t,e=this.v;for(t in e.a){for(var n=e.a[t],i=0;i<n.length;i++)0,on(n[i]);delete e.a[t],e.b--}}this.hb=null},(n=Rn.prototype).X=function(){Pn(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},n.Y=function(){return Pn(this),this.a.concat()},n.clear=function(){this.b={},this.c=this.a.length=0},n.get=function(t,e){return Dn(this.b,t)?this.b[t]:e},n.set=function(t,e){Dn(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},n.forEach=function(t,e){for(var n=this.Y(),i=0;i<n.length;i++){var r=n[i],o=this.get(r);t.call(e,o,r,this)}};var Ln=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function xn(t,e){var n;this.a=this.l=this.c="",this.g=null,this.h=this.f="",this.i=!1,t instanceof xn?(this.i=void 0!==e?e:t.i,Mn(this,t.c),this.l=t.l,this.a=t.a,jn(this,t.g),this.f=t.f,Un(this,ii(t.b)),this.h=t.h):t&&(n=String(t).match(Ln))?(this.i=!!e,Mn(this,n[1]||"",!0),this.l=Hn(n[2]||""),this.a=Hn(n[3]||"",!0),jn(this,n[4]),this.f=Hn(n[5]||"",!0),Un(this,n[6]||"",!0),this.h=Hn(n[7]||"")):(this.i=!!e,this.b=new $n(null,this.i))}function Mn(t,e,n){t.c=n?Hn(e,!0):e,t.c&&(t.c=t.c.replace(/:$/,""))}function jn(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.g=e}else t.g=null}function Un(t,e,n){e instanceof $n?(t.b=e,function(t,e){e&&!t.f&&(Zn(t),t.c=null,t.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(ti(this,e),ni(this,n,t))},t)),t.f=e}(t.b,t.i)):(n||(e=Gn(e,Yn)),t.b=new $n(e,t.i))}function Vn(t,e,n){t.b.set(e,n)}function Fn(t,e){return t.b.get(e)}function qn(t){return t instanceof xn?new xn(t):new xn(t,void 0)}function Kn(t,e,n,i){var r=new xn(null,void 0);return t&&Mn(r,t),e&&(r.a=e),n&&jn(r,n),i&&(r.f=i),r}function Hn(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Gn(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,Bn),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function Bn(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}xn.prototype.toString=function(){var t=[],e=this.c;e&&t.push(Gn(e,Wn,!0),":");var n=this.a;return(n||"file"==e)&&(t.push("//"),(e=this.l)&&t.push(Gn(e,Wn,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.g)&&t.push(":",String(n))),(n=this.f)&&(this.a&&"/"!=n.charAt(0)&&t.push("/"),t.push(Gn(n,"/"==n.charAt(0)?Jn:Xn,!0))),(n=this.b.toString())&&t.push("?",n),(n=this.h)&&t.push("#",Gn(n,zn)),t.join("")},xn.prototype.resolve=function(t){var e=new xn(this),n=!!t.c;n?Mn(e,t.c):n=!!t.l,n?e.l=t.l:n=!!t.a,n?e.a=t.a:n=null!=t.g;var i=t.f;if(n)jn(e,t.g);else if(n=!!t.f){if("/"!=i.charAt(0))if(this.a&&!this.f)i="/"+i;else{var r=e.f.lastIndexOf("/");-1!=r&&(i=e.f.substr(0,r+1)+i)}if(".."==(r=i)||"."==r)i="";else if(ct(r,"./")||ct(r,"/.")){i=0==r.lastIndexOf("/",0),r=r.split("/");for(var o=[],a=0;a<r.length;){var s=r[a++];"."==s?i&&a==r.length&&o.push(""):".."==s?((1<o.length||1==o.length&&""!=o[0])&&o.pop(),i&&a==r.length&&o.push("")):(o.push(s),i=!0)}i=o.join("/")}else i=r}return n?e.f=i:n=""!==t.b.toString(),n?Un(e,ii(t.b)):n=!!t.h,n&&(e.h=t.h),e};var Wn=/[#\/\?@]/g,Xn=/[#\?:]/g,Jn=/[#\?]/g,Yn=/[#\?@]/g,zn=/#/g;function $n(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function Zn(t){t.a||(t.a=new Rn,t.b=0,t.c&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var i=t[n].indexOf("="),r=null;if(0<=i){var o=t[n].substring(0,i);r=t[n].substring(i+1)}else o=t[n];e(o,r?decodeURIComponent(r.replace(/\+/g," ")):"")}}}(t.c,function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)}))}function Qn(t){var e=Cn(t);if(void 0===e)throw Error("Keys are undefined");var n=new $n(null,void 0);t=On(t);for(var i=0;i<e.length;i++){var r=e[i],o=t[i];Array.isArray(o)?ni(n,r,o):n.add(r,o)}return n}function ti(t,e){Zn(t),e=ri(t,e),Dn(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,Dn((t=t.a).b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&Pn(t)))}function ei(t,e){return Zn(t),e=ri(t,e),Dn(t.a.b,e)}function ni(t,e,n){ti(t,e),0<n.length&&(t.c=null,t.a.set(ri(t,e),Q(n)),t.b+=n.length)}function ii(t){var e=new $n;return e.c=t.c,t.a&&(e.a=new Rn(t.a),e.b=t.b),e}function ri(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}function oi(t){var e=[];return function t(e,n,i){if(null==n)i.push("null");else{if("object"==typeof n){if(Array.isArray(n)){var r=n;n=r.length,i.push("[");for(var o="",a=0;a<n;a++)i.push(o),t(e,r[a],i),o=",";return void i.push("]")}if(!(n instanceof String||n instanceof Number||n instanceof Boolean)){for(r in i.push("{"),o="",n)Object.prototype.hasOwnProperty.call(n,r)&&("function"!=typeof(a=n[r])&&(i.push(o),ci(r,i),i.push(":"),t(e,a,i),o=","));return void i.push("}")}n=n.valueOf()}switch(typeof n){case"string":ci(n,i);break;case"number":i.push(isFinite(n)&&!isNaN(n)?String(n):"null");break;case"boolean":i.push(String(n));break;case"function":i.push("null");break;default:throw Error("Unknown type: "+typeof n)}}}(new ai,t,e),e.join("")}function ai(){}(n=$n.prototype).add=function(t,e){Zn(this),this.c=null,t=ri(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},n.clear=function(){this.a=this.c=null,this.b=0},n.forEach=function(t,e){Zn(this),this.a.forEach(function(n,i){B(n,function(n){t.call(e,n,i,this)},this)},this)},n.Y=function(){Zn(this);for(var t=this.a.X(),e=this.a.Y(),n=[],i=0;i<e.length;i++)for(var r=t[i],o=0;o<r.length;o++)n.push(e[i]);return n},n.X=function(t){Zn(this);var e=[];if("string"==typeof t)ei(this,t)&&(e=Z(e,this.a.get(ri(this,t))));else{t=this.a.X();for(var n=0;n<t.length;n++)e=Z(e,t[n])}return e},n.set=function(t,e){return Zn(this),this.c=null,ei(this,t=ri(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},n.get=function(t,e){return t&&0<(t=this.X(t)).length?String(t[0]):e},n.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var t=[],e=this.a.Y(),n=0;n<e.length;n++){var i=e[n],r=encodeURIComponent(String(i));i=this.X(i);for(var o=0;o<i.length;o++){var a=r;""!==i[o]&&(a+="="+encodeURIComponent(String(i[o]))),t.push(a)}}return this.c=t.join("&")};var si={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\u000b"},ui=/\uffff/.test("")?/[\\"\x00-\x1f\x7f-\uffff]/g:/[\\"\x00-\x1f\x7f-\xff]/g;function ci(t,e){e.push('"',t.replace(ui,function(t){var e=si[t];return e||(e="\\u"+(65536|t.charCodeAt(0)).toString(16).substr(1),si[t]=e),e}),'"')}function hi(){var t=Oi();return zt&&!!ce&&11==ce||/Edge\/\d+/.test(t)}function li(){return u.window&&u.window.location.href||self&&self.location&&self.location.href||""}function fi(t,e){e=e||u.window;var n="about:blank";t&&(n=Dt(jt(t)||Ft)),e.location.href=n}function di(t){return!!((t=(t||Oi()).toLowerCase()).match(/android/)||t.match(/webos/)||t.match(/iphone|ipad|ipod/)||t.match(/blackberry/)||t.match(/windows phone/)||t.match(/iemobile/))}function pi(t){t=t||u.window;try{t.close()}catch(e){}}function vi(t,e,n){var i=Math.floor(1e9*Math.random()).toString();e=e||500,n=n||600;var r=(window.screen.availHeight-n)/2,o=(window.screen.availWidth-e)/2;for(a in e={width:e,height:n,top:0<r?r:0,left:0<o?o:0,location:!0,resizable:!0,statusbar:!0,toolbar:!1},n=Oi().toLowerCase(),i&&(e.target=i,ct(n,"crios/")&&(e.target="_blank")),Si(Oi())==Ai&&(t=t||"http://localhost",e.scrollbars=!0),n=t||"",(t=e)||(t={}),i=window,e=n instanceof Pt?n:jt(void 0!==n.href?n.href:String(n))||Ft,n=t.target||n.target,r=[],t)switch(a){case"width":case"height":case"top":case"left":r.push(a+"="+t[a]);break;case"target":case"noopener":case"noreferrer":break;default:r.push(a+"="+(t[a]?1:0))}var a=r.join(",");if((dt("iPhone")&&!dt("iPod")&&!dt("iPad")||dt("iPad")||dt("iPod"))&&i.navigator&&i.navigator.standalone&&n&&"_self"!=n?(yt(a=ge(document,"A"),"HTMLAnchorElement"),e=e instanceof Pt?e:Ut(e),a.href=Dt(e),a.setAttribute("target",n),t.noreferrer&&a.setAttribute("rel","noreferrer"),(t=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,i,1),a.dispatchEvent(t),a={}):t.noreferrer?(a=Ht("",i,n,a),t=Dt(e),a&&(Zt&&ct(t,";")&&(t="'"+t.replace(/'/g,"%27")+"'"),a.opener=null,t='<meta name="referrer" content="no-referrer"><meta http-equiv="refresh" content="0; url='+Bt(t)+'">',t=new qt(t=(i=kt())?i.createHTML(t):t,null,Kt),i=a.document)&&(i.write(function(t){return t instanceof qt&&t.constructor===qt?t.a:(j("expected object of type SafeHtml, got '"+t+"' of type "+d(t)),"type_error:SafeHtml")}(t)),i.close())):(a=Ht(e,i,n,a))&&t.noopener&&(a.opener=null),a)try{a.focus()}catch(s){}return a}var mi=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,gi=/^[^@]+@[^@]+$/;function bi(){var t=null;return new Ee(function(e){"complete"==u.document.readyState?e():(t=function(){e()},dn(window,"load",t))}).o(function(e){throw pn(window,"load",t),e})}function yi(t){return t=t||Oi(),!("file:"!==Li()&&"ionic:"!==Li()||!t.toLowerCase().match(/iphone|ipad|ipod|android/))}function wi(){var t=u.window;try{return!(!t||t==t.top)}catch(e){return!1}}function Ii(){return void 0!==u.WorkerGlobalScope&&"function"==typeof u.importScripts}function Ti(){return e.default.INTERNAL.hasOwnProperty("reactNative")?"ReactNative":e.default.INTERNAL.hasOwnProperty("node")?"Node":Ii()?"Worker":"Browser"}function Ei(){var t=Ti();return"ReactNative"===t||"Node"===t}var Ai="Firefox",ki="Chrome";function Si(t){var e=t.toLowerCase();return ct(e,"opera/")||ct(e,"opr/")||ct(e,"opios/")?"Opera":ct(e,"iemobile")?"IEMobile":ct(e,"msie")||ct(e,"trident/")?"IE":ct(e,"edge/")?"Edge":ct(e,"firefox/")?Ai:ct(e,"silk/")?"Silk":ct(e,"blackberry")?"Blackberry":ct(e,"webos")?"Webos":!ct(e,"safari/")||ct(e,"chrome/")||ct(e,"crios/")||ct(e,"android")?!ct(e,"chrome/")&&!ct(e,"crios/")||ct(e,"edge/")?ct(e,"android")?"Android":(t=t.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))&&2==t.length?t[1]:"Other":ki:"Safari"}var Ni={md:"FirebaseCore-web",od:"FirebaseUI-web"};function _i(t,e){e=e||[];var n,i=[],r={};for(n in Ni)r[Ni[n]]=!0;for(n=0;n<e.length;n++)void 0!==r[e[n]]&&(delete r[e[n]],i.push(e[n]));return i.sort(),(e=i).length||(e=["FirebaseCore-web"]),"Browser"===(i=Ti())?i=Si(r=Oi()):"Worker"===i&&(i=Si(r=Oi())+"-"+i),i+"/JsCore/"+t+"/"+e.join(",")}function Oi(){return u.navigator&&u.navigator.userAgent||""}function Ci(t,e){t=t.split("."),e=e||u;for(var n=0;n<t.length&&"object"==typeof e&&null!=e;n++)e=e[t[n]];return n!=t.length&&(e=void 0),e}function Ri(){try{var t=u.localStorage,e=Vi();if(t)return t.setItem(e,"1"),t.removeItem(e),!hi()||!!u.indexedDB}catch(n){return Ii()&&!!u.indexedDB}return!1}function Pi(){return(Di()||"chrome-extension:"===Li()||yi())&&!Ei()&&Ri()&&!Ii()}function Di(){return"http:"===Li()||"https:"===Li()}function Li(){return u.location&&u.location.protocol||null}function xi(t){return!di(t=t||Oi())&&Si(t)!=Ai}function Mi(t){return void 0===t?null:oi(t)}function ji(t){var e,n={};for(e in t)t.hasOwnProperty(e)&&null!==t[e]&&void 0!==t[e]&&(n[e]=t[e]);return n}function Ui(t){if(null!==t)return JSON.parse(t)}function Vi(t){return t||Math.floor(1e9*Math.random()).toString()}function Fi(t){return"Safari"!=Si(t=t||Oi())&&!t.toLowerCase().match(/iphone|ipad|ipod/)}function qi(){var t=u.___jsl;if(t&&t.H)for(var e in t.H)if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=t.H[e].L.concat(),t.CP)for(var n=0;n<t.CP.length;n++)t.CP[n]=null}function Ki(t,e){if(t>e)throw Error("Short delay should be less than long delay!");this.a=t,this.c=e,t=Oi(),e=Ti(),this.b=di(t)||"ReactNative"===e}function Hi(){var t=u.document;return!t||void 0===t.visibilityState||"visible"==t.visibilityState}function Gi(t){try{var e=new Date(parseInt(t,10));if(!isNaN(e.getTime())&&!/[^0-9]/.test(t))return e.toUTCString()}catch(n){}return null}function Bi(){return!(!Ci("fireauth.oauthhelper",u)&&!Ci("fireauth.iframe",u))}Ki.prototype.get=function(){var t=u.navigator;return!t||"boolean"!=typeof t.onLine||!Di()&&"chrome-extension:"!==Li()&&void 0===t.connection||t.onLine?this.b?this.c:this.a:Math.min(5e3,this.a)};var Wi,Xi={};function Ji(t){Xi[t]||(Xi[t]=!0,"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(t))}try{var Yi={};Object.defineProperty(Yi,"abcd",{configurable:!0,enumerable:!0,value:1}),Object.defineProperty(Yi,"abcd",{configurable:!0,enumerable:!0,value:2}),Wi=2==Yi.abcd}catch(Jt){Wi=!1}function zi(t,e,n){Wi?Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:n}):t[e]=n}function $i(t,e){if(e)for(var n in e)e.hasOwnProperty(n)&&zi(t,n,e[n])}function Zi(t){var e={};return $i(e,t),e}function Qi(t){var e=t;if("object"==typeof t&&null!=t)for(var n in e="length"in t?[]:{},t)zi(e,n,Qi(t[n]));return e}function tr(t){var e=t&&(t[or]?"phone":null);if(!(e&&t&&t[rr]))throw new N("internal-error","Internal assert: invalid MultiFactorInfo object");zi(this,"uid",t[rr]),zi(this,"displayName",t[nr]||null);var n=null;t[ir]&&(n=new Date(t[ir]).toUTCString()),zi(this,"enrollmentTime",n),zi(this,"factorId",e)}function er(t){try{var e=new ar(t)}catch(n){e=null}return e}tr.prototype.w=function(){return{uid:this.uid,displayName:this.displayName,factorId:this.factorId,enrollmentTime:this.enrollmentTime}};var nr="displayName",ir="enrolledAt",rr="mfaEnrollmentId",or="phoneInfo";function ar(t){tr.call(this,t),zi(this,"phoneNumber",t[or])}function sr(t){var e={},n=t[lr],i=t[dr],r=t[pr];if(t=er(t[fr]),!r||r!=cr&&r!=hr&&!n||r==hr&&!i||r==ur&&!t)throw Error("Invalid checkActionCode response!");r==hr?(e[mr]=n||null,e[br]=n||null,e[vr]=i):(e[mr]=i||null,e[br]=i||null,e[vr]=n||null),e[gr]=t||null,zi(this,wr,r),zi(this,yr,Qi(e))}k(ar,tr),ar.prototype.w=function(){var t=ar.bb.w.call(this);return t.phoneNumber=this.phoneNumber,t};var ur="REVERT_SECOND_FACTOR_ADDITION",cr="EMAIL_SIGNIN",hr="VERIFY_AND_CHANGE_EMAIL",lr="email",fr="mfaInfo",dr="newEmail",pr="requestType",vr="email",mr="fromEmail",gr="multiFactorInfo",br="previousEmail",yr="data",wr="operation";function Ir(t){var e=Fn(t=qn(t),Tr)||null,n=Fn(t,Er)||null,i=Fn(t,Sr)||null;if(i=i&&_r[i]||null,!e||!n||!i)throw new N("argument-error",Tr+", "+Er+"and "+Sr+" are required in a valid action code URL.");$i(this,{apiKey:e,operation:i,code:n,continueUrl:Fn(t,Ar)||null,languageCode:Fn(t,kr)||null,tenantId:Fn(t,Nr)||null})}var Tr="apiKey",Er="oobCode",Ar="continueUrl",kr="languageCode",Sr="mode",Nr="tenantId",_r={recoverEmail:"RECOVER_EMAIL",resetPassword:"PASSWORD_RESET",revertSecondFactorAddition:ur,signIn:cr,verifyAndChangeEmail:hr,verifyEmail:"VERIFY_EMAIL"};function Or(t){try{return new Ir(t)}catch(e){return null}}function Cr(t){var e=t[xr];if(void 0===e)throw new N("missing-continue-uri");if("string"!=typeof e||"string"==typeof e&&!e.length)throw new N("invalid-continue-uri");this.h=e,this.b=this.a=null,this.g=!1;var n=t[Rr];if(n&&"object"==typeof n){e=n[Ur];var i=n[Mr];if(n=n[jr],"string"==typeof e&&e.length){if(this.a=e,void 0!==i&&"boolean"!=typeof i)throw new N("argument-error",Mr+" property must be a boolean when specified.");if(this.g=!!i,void 0!==n&&("string"!=typeof n||"string"==typeof n&&!n.length))throw new N("argument-error",jr+" property must be a non empty string when specified.");this.b=n||null}else{if(void 0!==e)throw new N("argument-error",Ur+" property must be a non empty string when specified.");if(void 0!==i||void 0!==n)throw new N("missing-android-pkg-name")}}else if(void 0!==n)throw new N("argument-error",Rr+" property must be a non null object when specified.");if(this.f=null,(e=t[Lr])&&"object"==typeof e){if("string"==typeof(e=e[Vr])&&e.length)this.f=e;else if(void 0!==e)throw new N("argument-error",Vr+" property must be a non empty string when specified.")}else if(void 0!==e)throw new N("argument-error",Lr+" property must be a non null object when specified.");if(void 0!==(e=t[Dr])&&"boolean"!=typeof e)throw new N("argument-error",Dr+" property must be a boolean when specified.");if(this.c=!!e,void 0!==(t=t[Pr])&&("string"!=typeof t||"string"==typeof t&&!t.length))throw new N("argument-error",Pr+" property must be a non empty string when specified.");this.i=t||null}var Rr="android",Pr="dynamicLinkDomain",Dr="handleCodeInApp",Lr="iOS",xr="url",Mr="installApp",jr="minimumVersion",Ur="packageName",Vr="bundleId";function Fr(t){var e={};for(var n in e.continueUrl=t.h,e.canHandleCodeInApp=t.c,(e.androidPackageName=t.a)&&(e.androidMinimumVersion=t.b,e.androidInstallApp=t.g),e.iOSBundleId=t.f,e.dynamicLinkDomain=t.i,e)null===e[n]&&delete e[n];return e}var qr=null;function Kr(t){var e=[];return function(t,e){function n(e){for(;i<t.length;){var n=t.charAt(i++),r=qr[n];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return e}!function(){if(!qr){qr={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++)for(var i=t.concat(e[n].split("")),r=0;r<i.length;r++){var o=i[r];void 0===qr[o]&&(qr[o]=r)}}}();for(var i=0;;){var r=n(-1),o=n(0),a=n(64),s=n(64);if(64===s&&-1===r)break;e(r<<2|o>>4),64!=a&&(e(o<<4&240|a>>2),64!=s&&e(a<<6&192|s))}}(t,function(t){e.push(t)}),e}function Hr(t){var e=Br(t);if(!(e&&e.sub&&e.iss&&e.aud&&e.exp))throw Error("Invalid JWT");this.h=t,this.a=e.exp,this.i=e.sub,t=Date.now()/1e3,this.g=e.iat||(t>this.a?this.a:t),this.b=e.provider_id||e.firebase&&e.firebase.sign_in_provider||null,this.f=e.firebase&&e.firebase.tenant||null,this.c=!!e.is_anonymous||"anonymous"==this.b}function Gr(t){try{return new Hr(t)}catch(e){return null}}function Br(t){if(!t)return null;if(3!=(t=t.split(".")).length)return null;for(var e=(4-(t=t[1]).length%4)%4,n=0;n<e;n++)t+=".";try{var i=Kr(t);for(t=[],n=e=0;e<i.length;){var r=i[e++];if(128>r)t[n++]=String.fromCharCode(r);else if(191<r&&224>r){var o=i[e++];t[n++]=String.fromCharCode((31&r)<<6|63&o)}else if(239<r&&365>r){o=i[e++];var a=i[e++],s=((7&r)<<18|(63&o)<<12|(63&a)<<6|63&i[e++])-65536;t[n++]=String.fromCharCode(55296+(s>>10)),t[n++]=String.fromCharCode(56320+(1023&s))}else o=i[e++],a=i[e++],t[n++]=String.fromCharCode((15&r)<<12|(63&o)<<6|63&a)}return JSON.parse(t.join(""))}catch(u){}return null}Hr.prototype.T=function(){return this.f},Hr.prototype.l=function(){return this.c},Hr.prototype.toString=function(){return this.h};var Wr="oauth_consumer_key oauth_nonce oauth_signature oauth_signature_method oauth_timestamp oauth_token oauth_version".split(" "),Xr=["client_id","response_type","scope","redirect_uri","state"],Jr={nd:{Ja:"locale",va:700,ua:600,fa:"facebook.com",Ya:Xr},pd:{Ja:null,va:500,ua:750,fa:"github.com",Ya:Xr},qd:{Ja:"hl",va:515,ua:680,fa:"google.com",Ya:Xr},wd:{Ja:"lang",va:485,ua:705,fa:"twitter.com",Ya:Wr},kd:{Ja:"locale",va:640,ua:600,fa:"apple.com",Ya:[]}};function Yr(t){for(var e in Jr)if(Jr[e].fa==t)return Jr[e];return null}function zr(t){var e={};e["facebook.com"]=eo,e["google.com"]=io,e["github.com"]=no,e["twitter.com"]=ro;var n=t&&t[Zr];try{if(n)return e[n]?new e[n](t):new to(t);if(void 0!==t[$r])return new Qr(t)}catch(i){}return null}var $r="idToken",Zr="providerId";function Qr(t){var e=t[Zr];if(!e&&t[$r]){var n=Gr(t[$r]);n&&n.b&&(e=n.b)}if(!e)throw Error("Invalid additional user info!");"anonymous"!=e&&"custom"!=e||(e=null),n=!1,void 0!==t.isNewUser?n=!!t.isNewUser:"identitytoolkit#SignupNewUserResponse"===t.kind&&(n=!0),zi(this,"providerId",e),zi(this,"isNewUser",n)}function to(t){Qr.call(this,t),zi(this,"profile",Qi((t=Ui(t.rawUserInfo||"{}"))||{}))}function eo(t){if(to.call(this,t),"facebook.com"!=this.providerId)throw Error("Invalid provider ID!")}function no(t){if(to.call(this,t),"github.com"!=this.providerId)throw Error("Invalid provider ID!");zi(this,"username",this.profile&&this.profile.login||null)}function io(t){if(to.call(this,t),"google.com"!=this.providerId)throw Error("Invalid provider ID!")}function ro(t){if(to.call(this,t),"twitter.com"!=this.providerId)throw Error("Invalid provider ID!");zi(this,"username",t.screenName||null)}function oo(t){var e=qn(t),n=Fn(e,"link"),i=Fn(qn(n),"link");return e=Fn(e,"deep_link_id"),Fn(qn(e),"link")||e||i||n||t}function ao(t,e){if(!t&&!e)throw new N("internal-error","Internal assert: no raw session string available");if(t&&e)throw new N("internal-error","Internal assert: unable to determine the session type");this.a=t||null,this.b=e||null,this.type=this.a?so:uo}k(to,Qr),k(eo,to),k(no,to),k(io,to),k(ro,to);var so="enroll",uo="signin";function co(){}function ho(t,e){return t.then(function(t){if(t[Za]){var n=Gr(t[Za]);if(!n||e!=n.i)throw new N("user-mismatch");return t}throw new N("user-mismatch")}).o(function(t){throw t&&t.code&&t.code==C+"user-not-found"?new N("user-mismatch"):t})}function lo(t,e){if(!e)throw new N("internal-error","failed to construct a credential");this.a=e,zi(this,"providerId",t),zi(this,"signInMethod",t)}function fo(t){return{pendingToken:t.a,requestUri:"http://localhost"}}function po(t){if(t&&t.providerId&&t.signInMethod&&0==t.providerId.indexOf("saml.")&&t.pendingToken)try{return new lo(t.providerId,t.pendingToken)}catch(e){}return null}function vo(t,e,n){if(this.a=null,e.idToken||e.accessToken)e.idToken&&zi(this,"idToken",e.idToken),e.accessToken&&zi(this,"accessToken",e.accessToken),e.nonce&&!e.pendingToken&&zi(this,"nonce",e.nonce),e.pendingToken&&(this.a=e.pendingToken);else{if(!e.oauthToken||!e.oauthTokenSecret)throw new N("internal-error","failed to construct a credential");zi(this,"accessToken",e.oauthToken),zi(this,"secret",e.oauthTokenSecret)}zi(this,"providerId",t),zi(this,"signInMethod",n)}function mo(t){var e={};return t.idToken&&(e.id_token=t.idToken),t.accessToken&&(e.access_token=t.accessToken),t.secret&&(e.oauth_token_secret=t.secret),e.providerId=t.providerId,t.nonce&&!t.a&&(e.nonce=t.nonce),e={postBody:Qn(e).toString(),requestUri:"http://localhost"},t.a&&(delete e.postBody,e.pendingToken=t.a),e}function go(t){if(t&&t.providerId&&t.signInMethod){var e={idToken:t.oauthIdToken,accessToken:t.oauthTokenSecret?null:t.oauthAccessToken,oauthTokenSecret:t.oauthTokenSecret,oauthToken:t.oauthTokenSecret&&t.oauthAccessToken,nonce:t.nonce,pendingToken:t.pendingToken};try{return new vo(t.providerId,e,t.signInMethod)}catch(n){}}return null}function bo(t,e){this.Qc=e||[],$i(this,{providerId:t,isOAuthProvider:!0}),this.Jb={},this.qb=(Yr(t)||{}).Ja||null,this.pb=null}function yo(t){if("string"!=typeof t||0!=t.indexOf("saml."))throw new N("argument-error",'SAML provider IDs must be prefixed with "saml."');bo.call(this,t,[])}function wo(t){bo.call(this,t,Xr),this.a=[]}function Io(){wo.call(this,"facebook.com")}function To(t){if(!t)throw new N("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return m(t)&&(e=t.accessToken),(new Io).credential({accessToken:e})}function Eo(){wo.call(this,"github.com")}function Ao(t){if(!t)throw new N("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return m(t)&&(e=t.accessToken),(new Eo).credential({accessToken:e})}function ko(){wo.call(this,"google.com"),this.Ca("profile")}function So(t,e){var n=t;return m(t)&&(n=t.idToken,e=t.accessToken),(new ko).credential({idToken:n,accessToken:e})}function No(){bo.call(this,"twitter.com",Wr)}function _o(t,e){var n=t;if(m(n)||(n={oauthToken:t,oauthTokenSecret:e}),!n.oauthToken||!n.oauthTokenSecret)throw new N("argument-error","credential failed: expected 2 arguments (the OAuth access token and secret).");return new vo("twitter.com",n,"twitter.com")}function Oo(t,e,n){this.a=t,this.f=e,zi(this,"providerId","password"),zi(this,"signInMethod",n===Ro.EMAIL_LINK_SIGN_IN_METHOD?Ro.EMAIL_LINK_SIGN_IN_METHOD:Ro.EMAIL_PASSWORD_SIGN_IN_METHOD)}function Co(t){return t&&t.email&&t.password?new Oo(t.email,t.password,t.signInMethod):null}function Ro(){$i(this,{providerId:"password",isOAuthProvider:!1})}function Po(t,e){if(!(e=Do(e)))throw new N("argument-error","Invalid email link!");return new Oo(t,e.code,Ro.EMAIL_LINK_SIGN_IN_METHOD)}function Do(t){return(t=Or(t=oo(t)))&&t.operation===cr?t:null}function Lo(t){if(!(t.fb&&t.eb||t.La&&t.ea))throw new N("internal-error");this.a=t,zi(this,"providerId","phone"),this.fa="phone",zi(this,"signInMethod","phone")}function xo(t){if(t&&"phone"===t.providerId&&(t.verificationId&&t.verificationCode||t.temporaryProof&&t.phoneNumber)){var e={};return B(["verificationId","verificationCode","temporaryProof","phoneNumber"],function(n){t[n]&&(e[n]=t[n])}),new Lo(e)}return null}function Mo(t){return t.a.La&&t.a.ea?{temporaryProof:t.a.La,phoneNumber:t.a.ea}:{sessionInfo:t.a.fb,code:t.a.eb}}function jo(t){try{this.a=t||e.default.auth()}catch(n){throw new N("argument-error","Either an instance of firebase.auth.Auth must be passed as an argument to the firebase.auth.PhoneAuthProvider constructor, or the default firebase App instance must be initialized via firebase.initializeApp().")}$i(this,{providerId:"phone",isOAuthProvider:!1})}function Uo(t,e){if(!t)throw new N("missing-verification-id");if(!e)throw new N("missing-verification-code");return new Lo({fb:t,eb:e})}function Vo(t){if(t.temporaryProof&&t.phoneNumber)return new Lo({La:t.temporaryProof,ea:t.phoneNumber});var e=t&&t.providerId;if(!e||"password"===e)return null;var n=t&&t.oauthAccessToken,i=t&&t.oauthTokenSecret,r=t&&t.nonce,o=t&&t.oauthIdToken,a=t&&t.pendingToken;try{switch(e){case"google.com":return So(o,n);case"facebook.com":return To(n);case"github.com":return Ao(n);case"twitter.com":return _o(n,i);default:return n||i||o||a?a?0==e.indexOf("saml.")?new lo(e,a):new vo(e,{pendingToken:a,idToken:t.oauthIdToken,accessToken:t.oauthAccessToken},e):new wo(e).credential({idToken:o,accessToken:n,rawNonce:r}):null}}catch(s){return null}}function Fo(t){if(!t.isOAuthProvider)throw new N("invalid-oauth-provider")}function qo(t,e,n,i,r,o,a){if(this.c=t,this.b=e||null,this.g=n||null,this.f=i||null,this.i=o||null,this.h=a||null,this.a=r||null,!this.g&&!this.a)throw new N("invalid-auth-event");if(this.g&&this.a)throw new N("invalid-auth-event");if(this.g&&!this.f)throw new N("invalid-auth-event")}function Ko(t){return(t=t||{}).type?new qo(t.type,t.eventId,t.urlResponse,t.sessionId,t.error&&_(t.error),t.postBody,t.tenantId):null}function Ho(){this.b=null,this.a=[]}ao.prototype.Ha=function(){return this.a?Ce(this.a):Ce(this.b)},ao.prototype.w=function(){return this.type==so?{multiFactorSession:{idToken:this.a}}:{multiFactorSession:{pendingCredential:this.b}}},co.prototype.ka=function(){},co.prototype.b=function(){},co.prototype.c=function(){},co.prototype.w=function(){},lo.prototype.ka=function(t){return ws(t,fo(this))},lo.prototype.b=function(t,e){var n=fo(this);return n.idToken=e,Is(t,n)},lo.prototype.c=function(t,e){return ho(Ts(t,fo(this)),e)},lo.prototype.w=function(){return{providerId:this.providerId,signInMethod:this.signInMethod,pendingToken:this.a}},vo.prototype.ka=function(t){return ws(t,mo(this))},vo.prototype.b=function(t,e){var n=mo(this);return n.idToken=e,Is(t,n)},vo.prototype.c=function(t,e){return ho(Ts(t,mo(this)),e)},vo.prototype.w=function(){var t={providerId:this.providerId,signInMethod:this.signInMethod};return this.idToken&&(t.oauthIdToken=this.idToken),this.accessToken&&(t.oauthAccessToken=this.accessToken),this.secret&&(t.oauthTokenSecret=this.secret),this.nonce&&(t.nonce=this.nonce),this.a&&(t.pendingToken=this.a),t},bo.prototype.Ka=function(t){return this.Jb=mt(t),this},k(yo,bo),k(wo,bo),wo.prototype.Ca=function(t){return Y(this.a,t)||this.a.push(t),this},wo.prototype.Rb=function(){return Q(this.a)},wo.prototype.credential=function(t,e){var n;if(!(n=m(t)?{idToken:t.idToken||null,accessToken:t.accessToken||null,nonce:t.rawNonce||null}:{idToken:t||null,accessToken:e||null}).idToken&&!n.accessToken)throw new N("argument-error","credential failed: must provide the ID token and/or the access token.");return new vo(this.providerId,n,this.providerId)},k(Io,wo),zi(Io,"PROVIDER_ID","facebook.com"),zi(Io,"FACEBOOK_SIGN_IN_METHOD","facebook.com"),k(Eo,wo),zi(Eo,"PROVIDER_ID","github.com"),zi(Eo,"GITHUB_SIGN_IN_METHOD","github.com"),k(ko,wo),zi(ko,"PROVIDER_ID","google.com"),zi(ko,"GOOGLE_SIGN_IN_METHOD","google.com"),k(No,bo),zi(No,"PROVIDER_ID","twitter.com"),zi(No,"TWITTER_SIGN_IN_METHOD","twitter.com"),Oo.prototype.ka=function(t){return this.signInMethod==Ro.EMAIL_LINK_SIGN_IN_METHOD?iu(t,Cs,{email:this.a,oobCode:this.f}):iu(t,Zs,{email:this.a,password:this.f})},Oo.prototype.b=function(t,e){return this.signInMethod==Ro.EMAIL_LINK_SIGN_IN_METHOD?iu(t,Rs,{idToken:e,email:this.a,oobCode:this.f}):iu(t,Gs,{idToken:e,email:this.a,password:this.f})},Oo.prototype.c=function(t,e){return ho(this.ka(t),e)},Oo.prototype.w=function(){return{email:this.a,password:this.f,signInMethod:this.signInMethod}},$i(Ro,{PROVIDER_ID:"password"}),$i(Ro,{EMAIL_LINK_SIGN_IN_METHOD:"emailLink"}),$i(Ro,{EMAIL_PASSWORD_SIGN_IN_METHOD:"password"}),Lo.prototype.ka=function(t){return t.gb(Mo(this))},Lo.prototype.b=function(t,e){var n=Mo(this);return n.idToken=e,iu(t,tu,n)},Lo.prototype.c=function(t,e){var n=Mo(this);return n.operation="REAUTH",ho(t=iu(t,eu,n),e)},Lo.prototype.w=function(){var t={providerId:"phone"};return this.a.fb&&(t.verificationId=this.a.fb),this.a.eb&&(t.verificationCode=this.a.eb),this.a.La&&(t.temporaryProof=this.a.La),this.a.ea&&(t.phoneNumber=this.a.ea),t},jo.prototype.gb=function(t,e){var n=this.a.a;return Ce(e.verify()).then(function(i){if("string"!=typeof i)throw new N("argument-error","An implementation of firebase.auth.ApplicationVerifier.prototype.verify() must return a firebase.Promise that resolves with a string.");switch(e.type){case"recaptcha":var r=m(t)?t.session:null,o=m(t)?t.phoneNumber:t;return(r&&r.type==so?r.Ha().then(function(t){return iu(n,Ws,{idToken:t,phoneEnrollmentInfo:{phoneNumber:o,recaptchaToken:i}}).then(function(t){return t.phoneSessionInfo.sessionInfo})}):r&&r.type==uo?r.Ha().then(function(e){return function(t,e){return iu(t,Xs,e).then(function(t){return t.phoneResponseInfo.sessionInfo})}(n,{mfaPendingCredential:e,mfaEnrollmentId:t.multiFactorHint&&t.multiFactorHint.uid||t.multiFactorUid,phoneSignInInfo:{recaptchaToken:i}})}):function(t,e){return iu(t,Ks,e)}(n,{phoneNumber:o,recaptchaToken:i})).then(function(t){return"function"==typeof e.reset&&e.reset(),t},function(t){throw"function"==typeof e.reset&&e.reset(),t});default:throw new N("argument-error",'Only firebase.auth.ApplicationVerifiers with type="recaptcha" are currently supported.')}})},$i(jo,{PROVIDER_ID:"phone"}),$i(jo,{PHONE_SIGN_IN_METHOD:"phone"}),qo.prototype.getUid=function(){var t=[];return t.push(this.c),this.b&&t.push(this.b),this.f&&t.push(this.f),this.h&&t.push(this.h),t.join("-")},qo.prototype.T=function(){return this.h},qo.prototype.w=function(){return{type:this.c,eventId:this.b,urlResponse:this.g,sessionId:this.f,postBody:this.i,tenantId:this.h,error:this.a&&this.a.w()}};var Go,Bo=null;function Wo(t){var e="unauthorized-domain",n=void 0,i=qn(t);t=i.a,"chrome-extension"==(i=i.c)?n=Gt("This chrome extension ID (chrome-extension://%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",t):"http"==i||"https"==i?n=Gt("This domain (%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",t):e="operation-not-supported-in-this-environment",N.call(this,e,n)}function Xo(t,e,n){N.call(this,t,n),(t=e||{}).Kb&&zi(this,"email",t.Kb),t.ea&&zi(this,"phoneNumber",t.ea),t.credential&&zi(this,"credential",t.credential),t.$b&&zi(this,"tenantId",t.$b)}function Jo(t){if(t.code){var e=t.code||"";0==e.indexOf(C)&&(e=e.substring(C.length));var n={credential:Vo(t),$b:t.tenantId};if(t.email)n.Kb=t.email;else if(t.phoneNumber)n.ea=t.phoneNumber;else if(!n.credential)return new N(e,t.message||void 0);return new Xo(e,n,t.message)}return null}function Yo(){}function zo(t){return t.c||(t.c=t.b())}function $o(){}function Zo(t){if(!t.f&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(var e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],n=0;n<e.length;n++){var i=e[n];try{return new ActiveXObject(i),t.f=i}catch(r){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed")}return t.f}function Qo(){}function ta(){this.a=new XDomainRequest,this.readyState=0,this.onreadystatechange=null,this.responseType=this.responseText=this.response="",this.status=-1,this.statusText="",this.a.onload=T(this.qc,this),this.a.onerror=T(this.Tb,this),this.a.onprogress=T(this.rc,this),this.a.ontimeout=T(this.vc,this)}function ea(t,e){t.readyState=e,t.onreadystatechange&&t.onreadystatechange()}function na(t,e,n){this.reset(t,e,n,void 0,void 0)}k(Wo,N),k(Xo,N),Xo.prototype.w=function(){var t={code:this.code,message:this.message};this.email&&(t.email=this.email),this.phoneNumber&&(t.phoneNumber=this.phoneNumber),this.tenantId&&(t.tenantId=this.tenantId);var e=this.credential&&this.credential.w();return e&&bt(t,e),t},Xo.prototype.toJSON=function(){return this.w()},Yo.prototype.c=null,k($o,Yo),$o.prototype.a=function(){var t=Zo(this);return t?new ActiveXObject(t):new XMLHttpRequest},$o.prototype.b=function(){var t={};return Zo(this)&&(t[0]=!0,t[1]=!0),t},Go=new $o,k(Qo,Yo),Qo.prototype.a=function(){var t=new XMLHttpRequest;if("withCredentials"in t)return t;if("undefined"!=typeof XDomainRequest)return new ta;throw Error("Unsupported browser")},Qo.prototype.b=function(){return{}},(n=ta.prototype).open=function(t,e,n){if(null!=n&&!n)throw Error("Only async requests are supported.");this.a.open(t,e)},n.send=function(t){if(t){if("string"!=typeof t)throw Error("Only string data is supported");this.a.send(t)}else this.a.send()},n.abort=function(){this.a.abort()},n.setRequestHeader=function(){},n.getResponseHeader=function(t){return"content-type"==t.toLowerCase()?this.a.contentType:""},n.qc=function(){this.status=200,this.response=this.responseText=this.a.responseText,ea(this,4)},n.Tb=function(){this.status=500,this.response=this.responseText="",ea(this,4)},n.vc=function(){this.Tb()},n.rc=function(){this.status=200,ea(this,1)},n.getAllResponseHeaders=function(){return"content-type: "+this.a.contentType},na.prototype.a=null;function ia(t){this.f=t,this.b=this.c=this.a=null}function ra(t,e){this.name=t,this.value=e}na.prototype.reset=function(t,e,n,i,r){"number"==typeof r||0,i||A(),delete this.a},ra.prototype.toString=function(){return this.name};var oa=new ra("SEVERE",1e3),aa=new ra("WARNING",900),sa=new ra("CONFIG",700),ua=new ra("FINE",500);ia.prototype.log=function(t,e,n){if(t.value>=function t(e){return e.c?e.c:e.a?t(e.a):(j("Root logger has no level set."),null)}(this).value)for(v(e)&&(e=e()),t=new na(t,String(e),this.f),n&&(t.a=n),n=this;n;)n=n.a};var ca={},ha=null;function la(t){var e;if(ha||(ha=new ia(""),ca[""]=ha,ha.c=sa),!(e=ca[t])){e=new ia(t);var n=t.lastIndexOf("."),i=t.substr(n+1);(n=la(t.substr(0,n))).b||(n.b={}),n.b[i]=e,e.a=n,ca[t]=e}return e}function fa(t,e){t&&t.log(ua,e,void 0)}function da(t){this.f=t}function pa(t){En.call(this),this.u=t,this.h=void 0,this.readyState=va,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.l=new Headers,this.b=null,this.s="GET",this.f="",this.a=!1,this.i=la("goog.net.FetchXmlHttp"),this.m=this.c=this.g=null}k(da,Yo),da.prototype.a=function(){return new pa(this.f)},da.prototype.b=function(t){return function(){return t}}({}),k(pa,En);var va=0;function ma(t){t.c.read().then(t.pc.bind(t)).catch(t.Va.bind(t))}function ga(t){t.readyState=4,t.g=null,t.c=null,t.m=null,ba(t)}function ba(t){t.onreadystatechange&&t.onreadystatechange.call(t)}function ya(t){En.call(this),this.headers=new Rn,this.D=t||null,this.c=!1,this.C=this.a=null,this.h=this.P=this.l="",this.f=this.N=this.i=this.J=!1,this.g=0,this.s=null,this.m=wa,this.u=this.S=!1}(n=pa.prototype).open=function(t,e){if(this.readyState!=va)throw this.abort(),Error("Error reopening a connection");this.s=t,this.f=e,this.readyState=1,ba(this)},n.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.a=!0;var e={headers:this.l,method:this.s,credentials:this.h,cache:void 0};t&&(e.body=t),this.u.fetch(new Request(this.f,e)).then(this.uc.bind(this),this.Va.bind(this))},n.abort=function(){this.response=this.responseText="",this.l=new Headers,this.status=0,this.c&&this.c.cancel("Request was aborted."),1<=this.readyState&&this.a&&4!=this.readyState&&(this.a=!1,ga(this)),this.readyState=va},n.uc=function(t){this.a&&(this.g=t,this.b||(this.status=this.g.status,this.statusText=this.g.statusText,this.b=t.headers,this.readyState=2,ba(this)),this.a&&(this.readyState=3,ba(this),this.a&&("arraybuffer"===this.responseType?t.arrayBuffer().then(this.sc.bind(this),this.Va.bind(this)):void 0!==u.ReadableStream&&"body"in t?(this.response=this.responseText="",this.c=t.body.getReader(),this.m=new TextDecoder,ma(this)):t.text().then(this.tc.bind(this),this.Va.bind(this)))))},n.pc=function(t){if(this.a){var e=this.m.decode(t.value?t.value:new Uint8Array(0),{stream:!t.done});e&&(this.response=this.responseText+=e),t.done?ga(this):ba(this),3==this.readyState&&ma(this)}},n.tc=function(t){this.a&&(this.response=this.responseText=t,ga(this))},n.sc=function(t){this.a&&(this.response=t,ga(this))},n.Va=function(t){var e=this.i;e&&e.log(aa,"Failed to fetch url "+this.f,t instanceof Error?t:Error(t)),this.a&&ga(this)},n.setRequestHeader=function(t,e){this.l.append(t,e)},n.getResponseHeader=function(t){return this.b?this.b.get(t.toLowerCase())||"":((t=this.i)&&t.log(aa,"Attempting to get response header but no headers have been received for url: "+this.f,void 0),"")},n.getAllResponseHeaders=function(){if(!this.b){var t=this.i;return t&&t.log(aa,"Attempting to get all response headers but no headers have been received for url: "+this.f,void 0),""}t=[];for(var e=this.b.entries(),n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},Object.defineProperty(pa.prototype,"withCredentials",{get:function(){return"include"===this.h},set:function(t){this.h=t?"include":"same-origin"}}),k(ya,En);var wa="";ya.prototype.b=la("goog.net.XhrIo");var Ia=/^https?$/i,Ta=["POST","PUT"];function Ea(t,e,n,i,r){if(t.a)throw Error("[goog.net.XhrIo] Object is active with another request="+t.l+"; newUri="+e);n=n?n.toUpperCase():"GET",t.l=e,t.h="",t.P=n,t.J=!1,t.c=!0,t.a=t.D?t.D.a():Go.a(),t.C=t.D?zo(t.D):zo(Go),t.a.onreadystatechange=T(t.Wb,t);try{fa(t.b,Pa(t,"Opening Xhr")),t.N=!0,t.a.open(n,String(e),!0),t.N=!1}catch(a){return fa(t.b,Pa(t,"Error opening Xhr: "+a.message)),void ka(t,a)}e=i||"";var o=new Rn(t.headers);r&&function(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(p(t)||"string"==typeof t)B(t,e,void 0);else for(var n=Cn(t),i=On(t),r=i.length,o=0;o<r;o++)e.call(void 0,i[o],n&&n[o],t)}(r,function(t,e){o.set(e,t)}),r=function(t){t:{for(var e=Aa,n=t.length,i="string"==typeof t?t.split(""):t,r=0;r<n;r++)if(r in i&&e.call(void 0,i[r],r,t)){e=r;break t}e=-1}return 0>e?null:"string"==typeof t?t.charAt(e):t[e]}(o.Y()),i=u.FormData&&e instanceof u.FormData,!Y(Ta,n)||r||i||o.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),o.forEach(function(t,e){this.a.setRequestHeader(e,t)},t),t.m&&(t.a.responseType=t.m),"withCredentials"in t.a&&t.a.withCredentials!==t.S&&(t.a.withCredentials=t.S);try{Oa(t),0<t.g&&(t.u=function(t){return zt&&se(9)&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(t.a),fa(t.b,Pa(t,"Will abort after "+t.g+"ms if incomplete, xhr2 "+t.u)),t.u?(t.a.timeout=t.g,t.a.ontimeout=T(t.Ma,t)):t.s=Nn(t.Ma,t.g,t)),fa(t.b,Pa(t,"Sending request")),t.i=!0,t.a.send(e),t.i=!1}catch(a){fa(t.b,Pa(t,"Send error: "+a.message)),ka(t,a)}}function Aa(t){return"content-type"==t.toLowerCase()}function ka(t,e){t.c=!1,t.a&&(t.f=!0,t.a.abort(),t.f=!1),t.h=e,Sa(t),_a(t)}function Sa(t){t.J||(t.J=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function Na(t){if(t.c&&void 0!==s)if(t.C[1]&&4==Ca(t)&&2==Ra(t))fa(t.b,Pa(t,"Local request error detected and ignored"));else if(t.i&&4==Ca(t))Nn(t.Wb,0,t);else if(t.dispatchEvent("readystatechange"),4==Ca(t)){fa(t.b,Pa(t,"Request complete")),t.c=!1;try{var e,n=Ra(t);t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var i=!0;break t;default:i=!1}if(!(e=i)){var r;if(r=0===n){var o=String(t.l).match(Ln)[1]||null;if(!o&&u.self&&u.self.location){var a=u.self.location.protocol;o=a.substr(0,a.length-1)}r=!Ia.test(o?o.toLowerCase():"")}e=r}if(e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{try{var c=2<Ca(t)?t.a.statusText:""}catch(h){fa(t.b,"Can not get status: "+h.message),c=""}t.h=c+" ["+Ra(t)+"]",Sa(t)}}finally{_a(t)}}}function _a(t,e){if(t.a){Oa(t);var n=t.a,i=t.C[0]?f:null;t.a=null,t.C=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=i}catch(r){(t=t.b)&&t.log(oa,"Problem encountered resetting onreadystatechange: "+r.message,void 0)}}}function Oa(t){t.a&&t.u&&(t.a.ontimeout=null),t.s&&(u.clearTimeout(t.s),t.s=null)}function Ca(t){return t.a?t.a.readyState:0}function Ra(t){try{return 2<Ca(t)?t.a.status:-1}catch(e){return-1}}function Pa(t,e){return e+" ["+t.P+" "+t.l+" "+Ra(t)+"]"}function Da(t){var e=Ga;this.g=[],this.u=e,this.s=t||null,this.f=this.a=!1,this.c=void 0,this.v=this.C=this.i=!1,this.h=0,this.b=null,this.l=0}function La(t,e,n){t.a=!0,t.c=n,t.f=!e,Ua(t)}function xa(t){if(t.a){if(!t.v)throw new Va(t);t.v=!1}}function Ma(t,e,n,i){t.g.push([e,n,i]),t.a&&Ua(t)}function ja(t){return J(t.g,function(t){return v(t[1])})}function Ua(t){if(t.h&&t.a&&ja(t)){var e=t.h,n=Ka[e];n&&(u.clearTimeout(n.a),delete Ka[e]),t.h=0}t.b&&(t.b.l--,delete t.b),e=t.c;for(var i=n=!1;t.g.length&&!t.i;){var r=t.g.shift(),o=r[0],a=r[1];if(r=r[2],o=t.f?a:o)try{var s=o.call(r||t.s,e);void 0!==s&&(t.f=t.f&&(s==e||s instanceof Error),t.c=e=s),(L(e)||"function"==typeof u.Promise&&e instanceof u.Promise)&&(i=!0,t.i=!0)}catch(c){e=c,t.f=!0,ja(t)||(n=!0)}}t.c=e,i&&(s=T(t.m,t,!0),i=T(t.m,t,!1),e instanceof Da?(Ma(e,s,i),e.C=!0):e.then(s,i)),n&&(e=new qa(e),Ka[e.a]=e,t.h=e.a)}function Va(){x.call(this)}function Fa(){x.call(this)}function qa(t){this.a=u.setTimeout(T(this.c,this),0),this.b=t}(n=ya.prototype).Ma=function(){void 0!==s&&this.a&&(this.h="Timed out after "+this.g+"ms, aborting",fa(this.b,Pa(this,this.h)),this.dispatchEvent("timeout"),this.abort(8))},n.abort=function(){this.a&&this.c&&(fa(this.b,Pa(this,"Aborting")),this.c=!1,this.f=!0,this.a.abort(),this.f=!1,this.dispatchEvent("complete"),this.dispatchEvent("abort"),_a(this))},n.Da=function(){this.a&&(this.c&&(this.c=!1,this.f=!0,this.a.abort(),this.f=!1),_a(this,!0)),ya.bb.Da.call(this)},n.Wb=function(){this.ya||(this.N||this.i||this.f?Na(this):this.Jc())},n.Jc=function(){Na(this)},n.getResponse=function(){try{if(!this.a)return null;if("response"in this.a)return this.a.response;switch(this.m){case wa:case"text":return this.a.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in this.a)return this.a.mozResponseArrayBuffer}var t=this.b;return t&&t.log(oa,"Response type "+this.m+" is not supported on this browser",void 0),null}catch(e){return fa(this.b,"Can not get response: "+e.message),null}},Da.prototype.cancel=function(t){if(this.a)this.c instanceof Da&&this.c.cancel();else{if(this.b){var e=this.b;delete this.b,t?e.cancel(t):(e.l--,0>=e.l&&e.cancel())}this.u?this.u.call(this.s,this):this.v=!0,this.a||(t=new Fa(this),xa(this),La(this,!1,t))}},Da.prototype.m=function(t,e){this.i=!1,La(this,t,e)},Da.prototype.then=function(t,e,n){var i,r,o=new Ee(function(t,e){i=t,r=e});return Ma(this,i,function(t){t instanceof Fa?o.cancel():r(t)}),o.then(t,e,n)},Da.prototype.$goog_Thenable=!0,k(Va,x),Va.prototype.message="Deferred has already fired",Va.prototype.name="AlreadyCalledError",k(Fa,x),Fa.prototype.message="Deferred was canceled",Fa.prototype.name="CanceledError",qa.prototype.c=function(){throw delete Ka[this.a],this.b};var Ka={};function Ha(t){var e={},n=e.document||document,i=Nt(t).toString(),r=ge(document,"SCRIPT"),o={Xb:r,Ma:void 0},a=new Da(o),s=null,c=null!=e.timeout?e.timeout:5e3;return 0<c&&(s=window.setTimeout(function(){Ba(r,!0);var t=new Ja(Xa,"Timeout reached for loading script "+i);xa(a),La(a,!1,t)},c),o.Ma=s),r.onload=r.onreadystatechange=function(){r.readyState&&"loaded"!=r.readyState&&"complete"!=r.readyState||(Ba(r,e.xd||!1,s),xa(a),La(a,!0,null))},r.onerror=function(){Ba(r,!0,s);var t=new Ja(Wa,"Error while loading script "+i);xa(a),La(a,!1,t)},bt(o=e.attributes||{},{type:"text/javascript",charset:"UTF-8"}),fe(r,o),function(t,e){yt(t,"HTMLScriptElement"),t.src=Nt(e),(e=t.ownerDocument&&t.ownerDocument.defaultView)&&e!=u?e=l(e.document):(null===h&&(h=l(u.document)),e=h),e&&t.setAttribute("nonce",e)}(r,t),function(t){var e;return(e=(t||document).getElementsByTagName("HEAD"))&&0!=e.length?e[0]:t.documentElement}(n).appendChild(r),a}function Ga(){if(this&&this.Xb){var t=this.Xb;t&&"SCRIPT"==t.tagName&&Ba(t,!0,this.Ma)}}function Ba(t,e,n){null!=n&&u.clearTimeout(n),t.onload=f,t.onerror=f,t.onreadystatechange=f,e&&window.setTimeout(function(){t&&t.parentNode&&t.parentNode.removeChild(t)},0)}var Wa=0,Xa=1;function Ja(t,e){var n="Jsloader error (code #"+t+")";e&&(n+=": "+e),x.call(this,n),this.code=t}function Ya(t){this.f=t}function za(t,n,i){if(this.c=t,t=n||{},this.l=t.secureTokenEndpoint||"https://securetoken.googleapis.com/v1/token",this.m=t.secureTokenTimeout||Qa,this.g=mt(t.secureTokenHeaders||ts),this.h=t.firebaseEndpoint||"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",this.i=t.identityPlatformEndpoint||"https://identitytoolkit.googleapis.com/v2/",this.v=t.firebaseTimeout||es,this.a=mt(t.firebaseHeaders||ns),i&&(this.a["X-Client-Version"]=i,this.g["X-Client-Version"]=i),i="Node"==Ti(),!(i=u.XMLHttpRequest||i&&e.default.INTERNAL.node&&e.default.INTERNAL.node.XMLHttpRequest)&&!Ii())throw new N("internal-error","The XMLHttpRequest compatibility library was not found.");this.f=void 0,Ii()?this.f=new da(self):Ei()?this.f=new Ya(i):this.f=new Qo,this.b=null}k(Ja,x),k(Ya,Yo),Ya.prototype.a=function(){return new this.f},Ya.prototype.b=function(){return{}};var $a,Za="idToken",Qa=new Ki(3e4,6e4),ts={"Content-Type":"application/x-www-form-urlencoded"},es=new Ki(3e4,6e4),ns={"Content-Type":"application/json"};function is(t,e){e?t.a["X-Firebase-Locale"]=e:delete t.a["X-Firebase-Locale"]}function rs(t,e){e&&(t.l=os("https://securetoken.googleapis.com/v1/token",e),t.h=os("https://www.googleapis.com/identitytoolkit/v3/relyingparty/",e),t.i=os("https://identitytoolkit.googleapis.com/v2/",e))}function os(t,e){return t=qn(t),e=qn(e.url),t.f=t.a+t.f,Mn(t,e.c),t.a=e.a,jn(t,e.g),t.toString()}function as(t,e){e?(t.a["X-Client-Version"]=e,t.g["X-Client-Version"]=e):(delete t.a["X-Client-Version"],delete t.g["X-Client-Version"])}function ss(t,e,n,i,r,o,a){(function(){var t=Oi();return!((t=Si(t)!=ki?null:(t=t.match(/\sChrome\/(\d+)/i))&&2==t.length?parseInt(t[1],10):null)&&30>t||zt&&ce&&!(9<ce))})()||Ii()?t=T(t.u,t):($a||($a=new Ee(function(t,e){!function(t,e){if(((window.gapi||{}).client||{}).request)t();else{u[cs]=function(){((window.gapi||{}).client||{}).request?t():e(Error("CORS_UNSUPPORTED"))};var n=_t(us,{onload:cs});!function(t,e){Ma(t,null,e,void 0)}(Ha(n),function(){e(Error("CORS_UNSUPPORTED"))})}}(t,e)})),t=T(t.s,t)),t(e,n,i,r,o,a)}za.prototype.T=function(){return this.b},za.prototype.u=function(t,e,n,i,r,o){if(Ii()&&(void 0===u.fetch||void 0===u.Headers||void 0===u.Request))throw new N("operation-not-supported-in-this-environment","fetch, Headers and Request native APIs or equivalent Polyfills must be available to support HTTP requests from a Worker environment.");var a=new ya(this.f);if(o){a.g=Math.max(0,o);var s=setTimeout(function(){a.dispatchEvent("timeout")},o)}An(a,"complete",function(){s&&clearTimeout(s);var t=null;try{t=JSON.parse(function(t){try{return t.a?t.a.responseText:""}catch(e){return fa(t.b,"Can not get responseText: "+e.message),""}}(this))||null}catch(n){t=null}e&&e(t)}),kn(a,"ready",function(){s&&clearTimeout(s),Xe(this)}),kn(a,"timeout",function(){s&&clearTimeout(s),Xe(this),e&&e(null)}),Ea(a,t,n,i,r)};var us=new wt(At,"https://apis.google.com/js/client.js?onload=%{onload}"),cs="__fcb"+Math.floor(1e6*Math.random()).toString();function hs(t,e,n,i,r,o,a){var s=qn(e+n);Vn(s,"key",t.c),a&&Vn(s,"cb",Date.now().toString());var u="GET"==i;if(u)for(var c in r)r.hasOwnProperty(c)&&Vn(s,c,r[c]);return new Ee(function(e,n){ss(t,s.toString(),function(t){t?t.error?n(ou(t,o||{})):e(t):n(new N("network-request-failed"))},i,u?void 0:oi(ji(r)),t.a,t.v.get())})}function ls(t){if("string"!=typeof(t=t.email)||!gi.test(t))throw new N("invalid-email")}function fs(t){"email"in t&&ls(t)}function ds(t){if(!t[Za]){if(t.mfaPendingCredential)throw new N("multi-factor-auth-required",null,mt(t));throw new N("internal-error")}}function ps(t){if(t.phoneNumber||t.temporaryProof){if(!t.phoneNumber||!t.temporaryProof)throw new N("internal-error")}else{if(!t.sessionInfo)throw new N("missing-verification-id");if(!t.code)throw new N("missing-verification-code")}}za.prototype.s=function(t,e,n,i,r){var o=this;$a.then(function(){window.gapi.client.setApiKey(o.c);var a=window.gapi.auth.getToken();window.gapi.auth.setToken(null),window.gapi.client.request({path:t,method:n,body:i,headers:r,authType:"none",callback:function(t){window.gapi.auth.setToken(a),e&&e(t)}})}).o(function(t){e&&e({error:{message:t&&t.message||"CORS_UNSUPPORTED"}})})},za.prototype.Ab=function(){return iu(this,Bs,{})},za.prototype.Cb=function(t,e){return iu(this,Hs,{idToken:t,email:e})},za.prototype.Db=function(t,e){return iu(this,Gs,{idToken:t,password:e})};var vs={displayName:"DISPLAY_NAME",photoUrl:"PHOTO_URL"};function ms(t){if(!t.phoneVerificationInfo)throw new N("internal-error");if(!t.phoneVerificationInfo.sessionInfo)throw new N("missing-verification-id");if(!t.phoneVerificationInfo.code)throw new N("missing-verification-code")}function gs(t){if(!t.requestUri||!t.sessionId&&!t.postBody&&!t.pendingToken)throw new N("internal-error")}function bs(t,e){return e.oauthIdToken&&e.providerId&&0==e.providerId.indexOf("oidc.")&&!e.pendingToken&&(t.sessionId?e.nonce=t.sessionId:t.postBody&&(ei(t=new $n(t.postBody),"nonce")&&(e.nonce=t.get("nonce")))),e}function ys(t){var e=null;if(t.needConfirmation?(t.code="account-exists-with-different-credential",e=Jo(t)):"FEDERATED_USER_ID_ALREADY_LINKED"==t.errorMessage?(t.code="credential-already-in-use",e=Jo(t)):"EMAIL_EXISTS"==t.errorMessage?(t.code="email-already-in-use",e=Jo(t)):t.errorMessage&&(e=ru(t.errorMessage)),e)throw e;ds(t)}function ws(t,e){return e.returnIdpCredential=!0,iu(t,Js,e)}function Is(t,e){return e.returnIdpCredential=!0,iu(t,zs,e)}function Ts(t,e){return e.returnIdpCredential=!0,e.autoCreate=!1,iu(t,Ys,e)}function Es(t){if(!t.oobCode)throw new N("invalid-action-code")}(n=za.prototype).Eb=function(t,e){var n={idToken:t},i=[];return pt(vs,function(t,r){var o=e[r];null===o?i.push(t):r in e&&(n[r]=o)}),i.length&&(n.deleteAttribute=i),iu(this,Hs,n)},n.wb=function(t,e){return bt(t={requestType:"PASSWORD_RESET",email:t},e),iu(this,Us,t)},n.xb=function(t,e){return bt(t={requestType:"EMAIL_SIGNIN",email:t},e),iu(this,xs,t)},n.vb=function(t,e){return bt(t={requestType:"VERIFY_EMAIL",idToken:t},e),iu(this,Ms,t)},n.Fb=function(t,e,n){return bt(t={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:t,newEmail:e},n),iu(this,js,t)},n.gb=function(t){return iu(this,Qs,t)},n.ob=function(t,e){return iu(this,qs,{oobCode:t,newPassword:e})},n.Sa=function(t){return iu(this,ks,{oobCode:t})},n.kb=function(t){return iu(this,As,{oobCode:t})};var As={endpoint:"setAccountInfo",A:Es,Z:"email",B:!0},ks={endpoint:"resetPassword",A:Es,G:function(t){var e=t.requestType;if(!e||!t.email&&"EMAIL_SIGNIN"!=e&&"VERIFY_AND_CHANGE_EMAIL"!=e)throw new N("internal-error")},B:!0},Ss={endpoint:"signupNewUser",A:function(t){if(ls(t),!t.password)throw new N("weak-password")},G:ds,V:!0,B:!0},Ns={endpoint:"createAuthUri",B:!0},_s={endpoint:"deleteAccount",O:["idToken"]},Os={endpoint:"setAccountInfo",O:["idToken","deleteProvider"],A:function(t){if(!Array.isArray(t.deleteProvider))throw new N("internal-error")}},Cs={endpoint:"emailLinkSignin",O:["email","oobCode"],A:ls,G:ds,V:!0,B:!0},Rs={endpoint:"emailLinkSignin",O:["idToken","email","oobCode"],A:ls,G:ds,V:!0},Ps={endpoint:"accounts/mfaEnrollment:finalize",O:["idToken","phoneVerificationInfo"],A:ms,G:ds,B:!0,Na:!0},Ds={endpoint:"accounts/mfaSignIn:finalize",O:["mfaPendingCredential","phoneVerificationInfo"],A:ms,G:ds,B:!0,Na:!0},Ls={endpoint:"getAccountInfo"},xs={endpoint:"getOobConfirmationCode",O:["requestType"],A:function(t){if("EMAIL_SIGNIN"!=t.requestType)throw new N("internal-error");ls(t)},Z:"email",B:!0},Ms={endpoint:"getOobConfirmationCode",O:["idToken","requestType"],A:function(t){if("VERIFY_EMAIL"!=t.requestType)throw new N("internal-error")},Z:"email",B:!0},js={endpoint:"getOobConfirmationCode",O:["idToken","newEmail","requestType"],A:function(t){if("VERIFY_AND_CHANGE_EMAIL"!=t.requestType)throw new N("internal-error")},Z:"email",B:!0},Us={endpoint:"getOobConfirmationCode",O:["requestType"],A:function(t){if("PASSWORD_RESET"!=t.requestType)throw new N("internal-error");ls(t)},Z:"email",B:!0},Vs={mb:!0,endpoint:"getProjectConfig",Vb:"GET"},Fs={mb:!0,endpoint:"getRecaptchaParam",Vb:"GET",G:function(t){if(!t.recaptchaSiteKey)throw new N("internal-error")}},qs={endpoint:"resetPassword",A:Es,Z:"email",B:!0},Ks={endpoint:"sendVerificationCode",O:["phoneNumber","recaptchaToken"],Z:"sessionInfo",B:!0},Hs={endpoint:"setAccountInfo",O:["idToken"],A:fs,V:!0},Gs={endpoint:"setAccountInfo",O:["idToken"],A:function(t){if(fs(t),!t.password)throw new N("weak-password")},G:ds,V:!0},Bs={endpoint:"signupNewUser",G:ds,V:!0,B:!0},Ws={endpoint:"accounts/mfaEnrollment:start",O:["idToken","phoneEnrollmentInfo"],A:function(t){if(!t.phoneEnrollmentInfo)throw new N("internal-error");if(!t.phoneEnrollmentInfo.phoneNumber)throw new N("missing-phone-number");if(!t.phoneEnrollmentInfo.recaptchaToken)throw new N("missing-app-credential")},G:function(t){if(!t.phoneSessionInfo||!t.phoneSessionInfo.sessionInfo)throw new N("internal-error")},B:!0,Na:!0},Xs={endpoint:"accounts/mfaSignIn:start",O:["mfaPendingCredential","mfaEnrollmentId","phoneSignInInfo"],A:function(t){if(!t.phoneSignInInfo||!t.phoneSignInInfo.recaptchaToken)throw new N("missing-app-credential")},G:function(t){if(!t.phoneResponseInfo||!t.phoneResponseInfo.sessionInfo)throw new N("internal-error")},B:!0,Na:!0},Js={endpoint:"verifyAssertion",A:gs,Za:bs,G:ys,V:!0,B:!0},Ys={endpoint:"verifyAssertion",A:gs,Za:bs,G:function(t){if(t.errorMessage&&"USER_NOT_FOUND"==t.errorMessage)throw new N("user-not-found");if(t.errorMessage)throw ru(t.errorMessage);ds(t)},V:!0,B:!0},zs={endpoint:"verifyAssertion",A:function(t){if(gs(t),!t.idToken)throw new N("internal-error")},Za:bs,G:ys,V:!0},$s={endpoint:"verifyCustomToken",A:function(t){if(!t.token)throw new N("invalid-custom-token")},G:ds,V:!0,B:!0},Zs={endpoint:"verifyPassword",A:function(t){if(ls(t),!t.password)throw new N("wrong-password")},G:ds,V:!0,B:!0},Qs={endpoint:"verifyPhoneNumber",A:ps,G:ds,B:!0},tu={endpoint:"verifyPhoneNumber",A:function(t){if(!t.idToken)throw new N("internal-error");ps(t)},G:function(t){if(t.temporaryProof)throw t.code="credential-already-in-use",Jo(t);ds(t)}},eu={Ib:{USER_NOT_FOUND:"user-not-found"},endpoint:"verifyPhoneNumber",A:ps,G:ds,B:!0},nu={endpoint:"accounts/mfaEnrollment:withdraw",O:["idToken","mfaEnrollmentId"],G:function(t){if(!!t[Za]^!!t.refreshToken)throw new N("internal-error")},B:!0,Na:!0};function iu(t,e,n){if(!function(t,e){if(!e||!e.length)return!0;if(!t)return!1;for(var n=0;n<e.length;n++){var i=t[e[n]];if(null==i||""===i)return!1}return!0}(n,e.O))return Re(new N("internal-error"));var i,r=!!e.Na,o=e.Vb||"POST";return Ce(n).then(e.A).then(function(){return e.V&&(n.returnSecureToken=!0),e.B&&t.b&&void 0===n.tenantId&&(n.tenantId=t.b),hs(t,r?t.i:t.h,e.endpoint,o,n,e.Ib,e.mb||!1)}).then(function(t){return i=t,e.Za?e.Za(n,i):i}).then(e.G).then(function(){if(!e.Z)return i;if(!(e.Z in i))throw new N("internal-error");return i[e.Z]})}function ru(t){return ou({error:{errors:[{message:t}],code:400,message:t}})}function ou(t,e){var n=(t.error&&t.error.errors&&t.error.errors[0]||{}).reason||"",i={keyInvalid:"invalid-api-key",ipRefererBlocked:"app-not-authorized"};if(n=i[n]?new N(i[n]):null)return n;for(var r in n=t.error&&t.error.message||"",bt(i={INVALID_CUSTOM_TOKEN:"invalid-custom-token",CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_EMAIL:"invalid-email",INVALID_PASSWORD:"wrong-password",USER_DISABLED:"user-disabled",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_OR_INVALID_NONCE:"missing-or-invalid-nonce",INVALID_MESSAGE_PAYLOAD:"invalid-message-payload",INVALID_RECIPIENT_EMAIL:"invalid-recipient-email",INVALID_SENDER:"invalid-sender",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",INVALID_PROVIDER_ID:"invalid-provider-id",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",CORS_UNSUPPORTED:"cors-unsupported",DYNAMIC_LINK_NOT_ACTIVATED:"dynamic-link-not-activated",INVALID_APP_ID:"invalid-app-id",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",WEAK_PASSWORD:"weak-password",OPERATION_NOT_ALLOWED:"operation-not-allowed",USER_CANCELLED:"user-cancelled",CAPTCHA_CHECK_FAILED:"captcha-check-failed",INVALID_APP_CREDENTIAL:"invalid-app-credential",INVALID_CODE:"invalid-verification-code",INVALID_PHONE_NUMBER:"invalid-phone-number",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_APP_CREDENTIAL:"missing-app-credential",MISSING_CODE:"missing-verification-code",MISSING_PHONE_NUMBER:"missing-phone-number",MISSING_SESSION_INFO:"missing-verification-id",QUOTA_EXCEEDED:"quota-exceeded",SESSION_EXPIRED:"code-expired",REJECTED_CREDENTIAL:"rejected-credential",INVALID_CONTINUE_URI:"invalid-continue-uri",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",MISSING_IOS_BUNDLE_ID:"missing-ios-bundle-id",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_DYNAMIC_LINK_DOMAIN:"invalid-dynamic-link-domain",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",INVALID_CERT_HASH:"invalid-cert-hash",UNSUPPORTED_TENANT_OPERATION:"unsupported-tenant-operation",INVALID_TENANT_ID:"invalid-tenant-id",TENANT_ID_MISMATCH:"tenant-id-mismatch",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",EMAIL_CHANGE_NEEDS_VERIFICATION:"email-change-needs-verification",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",UNSUPPORTED_FIRST_FACTOR:"unsupported-first-factor",UNVERIFIED_EMAIL:"unverified-email"},e||{}),e=(e=n.match(/^[^\s]+\s*:\s*([\s\S]*)$/))&&1<e.length?e[1]:void 0,i)if(0===n.indexOf(r))return new N(i[r],e);return!e&&t&&(e=Mi(t)),new N("internal-error",e)}function au(t){this.b=t,this.a=null,this.sb=function(t){return(hu||(hu=new Ee(function(t,e){function n(){qi(),Ci("gapi.load")("gapi.iframes",{callback:t,ontimeout:function(){qi(),e(Error("Network Error"))},timeout:uu.get()})}if(Ci("gapi.iframes.Iframe"))t();else if(Ci("gapi.load"))n();else{var i="__iframefcb"+Math.floor(1e6*Math.random()).toString();u[i]=function(){Ci("gapi.load")?n():e(Error("Network Error"))},Ce(Ha(i=_t(su,{onload:i}))).o(function(){e(Error("Network Error"))})}}).o(function(t){throw hu=null,t}))).then(function(){return new Ee(function(e,n){Ci("gapi.iframes.getContext")().open({where:document.body,url:t.b,messageHandlersFilter:Ci("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"),attributes:{style:{position:"absolute",top:"-100px",width:"1px",height:"1px"}},dontclear:!0},function(i){function r(){clearTimeout(o),e()}t.a=i,t.a.restyle({setHideOnLeave:!1});var o=setTimeout(function(){n(Error("Network Error"))},cu.get());i.ping(r).then(r,function(){n(Error("Network Error"))})})})})}(this)}var su=new wt(At,"https://apis.google.com/js/api.js?onload=%{onload}"),uu=new Ki(3e4,6e4),cu=new Ki(5e3,15e3),hu=null;function lu(t,e,n,i){this.l=t,this.h=e,this.i=n,this.g=i,this.f=null,this.g?t=Kn((t=qn(this.g.url)).c,t.a,t.g,"/emulator/auth/iframe"):t=Kn("https",this.l,null,"/__/auth/iframe"),this.a=t,Vn(this.a,"apiKey",this.h),Vn(this.a,"appName",this.i),this.b=null,this.c=[]}function fu(t,e,n,i,r,o){this.u=t,this.s=e,this.c=n,this.m=i,this.v=o,this.i=this.g=this.l=null,this.a=r,this.h=this.f=null}function du(t){try{return e.default.app(t).auth().Ga()}catch(n){return[]}}function pu(t,e,n,i,r,o){this.s=t,this.g=e,this.b=n,this.f=o,this.c=i||null,this.i=r||null,this.l=this.u=this.C=null,this.h=[],this.m=this.a=null}function vu(t){var e=li();return function(t){return iu(t,Vs,{}).then(function(t){return t.authorizedDomains||[]})}(t).then(function(t){t:{var n=qn(e),i=n.c;n=n.a;for(var r=0;r<t.length;r++){var o=t[r],a=n,s=i;if(0==o.indexOf("chrome-extension://")?a=qn(o).a==a&&"chrome-extension"==s:"http"!=s&&"https"!=s?a=!1:mi.test(o)?a=a==o:(o=o.split(".").join("\\."),a=new RegExp("^(.+\\."+o+"|"+o+")$","i").test(a)),a){t=!0;break t}}t=!1}if(!t)throw new Wo(li())})}function mu(t){return t.m?t.m:(t.m=bi().then(function(){if(!t.u){var e=t.c,n=t.i,i=du(t.b),r=new lu(t.s,t.g,t.b,t.f);r.f=e,r.b=n,r.c=Q(i||[]),t.u=r.toString()}t.v=new au(t.u),function(t){if(!t.v)throw Error("IfcHandler must be initialized!");!function(t,e){t.sb.then(function(){t.a.register("authEvent",e,Ci("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"))})}(t.v,function(e){var n={};if(e&&e.authEvent){var i=!1;for(e=Ko(e.authEvent),n=0;n<t.h.length;n++)i=t.h[n](e)||i;return(n={}).status=i?"ACK":"ERROR",Ce(n)}return n.status="ERROR",Ce(n)})}(t)}),t.m)}function gu(t){return t.l||(t.C=t.c?_i(t.c,du(t.b)):null,t.l=new za(t.g,D(t.i),t.C),t.f&&rs(t.l,t.f)),t.l}function bu(t,e,n,i,r,o,a,s,u,c,h,l){return(t=new fu(t,e,n,i,r,l)).l=o,t.g=a,t.i=s,t.b=mt(u||null),t.f=c,t.zb(h).toString()}function yu(t){if(this.a=t||e.default.INTERNAL.reactNative&&e.default.INTERNAL.reactNative.AsyncStorage,!this.a)throw new N("internal-error","The React Native compatibility library was not found.");this.type="asyncStorage"}function wu(t){this.b=t,this.a={},this.f=T(this.c,this)}lu.prototype.toString=function(){return this.f?Vn(this.a,"v",this.f):ti(this.a.b,"v"),this.b?Vn(this.a,"eid",this.b):ti(this.a.b,"eid"),this.c.length?Vn(this.a,"fw",this.c.join(",")):ti(this.a.b,"fw"),this.a.toString()},fu.prototype.zb=function(t){return this.h=t,this},fu.prototype.toString=function(){if(this.v){var t=qn(this.v.url);t=Kn(t.c,t.a,t.g,"/emulator/auth/handler")}else t=Kn("https",this.u,null,"/__/auth/handler");if(Vn(t,"apiKey",this.s),Vn(t,"appName",this.c),Vn(t,"authType",this.m),this.a.isOAuthProvider){var n=this.a;try{var i=e.default.app(this.c).auth().la()}catch(u){i=null}for(var r in n.pb=i,Vn(t,"providerId",this.a.providerId),n=ji((i=this.a).Jb))n[r]=n[r].toString();r=i.Qc,n=mt(n);for(var o=0;o<r.length;o++){var a=r[o];a in n&&delete n[a]}i.qb&&i.pb&&!n[i.qb]&&(n[i.qb]=i.pb),vt(n)||Vn(t,"customParameters",Mi(n))}if("function"==typeof this.a.Rb&&((i=this.a.Rb()).length&&Vn(t,"scopes",i.join(","))),this.l?Vn(t,"redirectUrl",this.l):ti(t.b,"redirectUrl"),this.g?Vn(t,"eventId",this.g):ti(t.b,"eventId"),this.i?Vn(t,"v",this.i):ti(t.b,"v"),this.b)for(var s in this.b)this.b.hasOwnProperty(s)&&!Fn(t,s)&&Vn(t,s,this.b[s]);return this.h?Vn(t,"tid",this.h):ti(t.b,"tid"),this.f?Vn(t,"eid",this.f):ti(t.b,"eid"),(s=du(this.c)).length&&Vn(t,"fw",s.join(",")),t.toString()},(n=pu.prototype).Pb=function(t,e,n){var i=new N("popup-closed-by-user"),r=new N("web-storage-unsupported"),o=this,a=!1;return this.ma().then(function(){(function(t){var e={type:"webStorageSupport"};return mu(t).then(function(){return function(t,e){return t.sb.then(function(){return new Ee(function(n){t.a.send(e.type,e,n,Ci("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"))})})}(t.v,e)}).then(function(t){if(t&&t.length&&void 0!==t[0].webStorageSupport)return t[0].webStorageSupport;throw Error()})})(o).then(function(n){n||(t&&pi(t),e(r),a=!0)})}).o(function(){}).then(function(){if(!a)return function(t){return new Ee(function(e){return function n(){_n(2e3).then(function(){if(t&&!t.closed)return n();e()})}()})}(t)}).then(function(){if(!a)return _n(n).then(function(){e(i)})})},n.Yb=function(){var t=Oi();return!xi(t)&&!Fi(t)},n.Ub=function(){return!1},n.Nb=function(t,e,n,i,r,o,a,s){if(!t)return Re(new N("popup-blocked"));if(a&&!xi())return this.ma().o(function(e){pi(t),r(e)}),i(),Ce();this.a||(this.a=vu(gu(this)));var u=this;return this.a.then(function(){var e=u.ma().o(function(e){throw pi(t),r(e),e});return i(),e}).then(function(){(Fo(n),a)||fi(bu(u.s,u.g,u.b,e,n,null,o,u.c,void 0,u.i,s,u.f),t)}).o(function(t){throw"auth/network-request-failed"==t.code&&(u.a=null),t})},n.Ob=function(t,e,n,i){this.a||(this.a=vu(gu(this)));var r=this;return this.a.then(function(){Fo(e),fi(bu(r.s,r.g,r.b,t,e,li(),n,r.c,void 0,r.i,i,r.f))}).o(function(t){throw"auth/network-request-failed"==t.code&&(r.a=null),t})},n.ma=function(){var t=this;return mu(this).then(function(){return t.v.sb}).o(function(){throw t.a=null,new N("network-request-failed")})},n.ac=function(){return!0},n.Ea=function(t){this.h.push(t)},n.Ta=function(t){$(this.h,function(e){return e==t})},(n=yu.prototype).get=function(t){return Ce(this.a.getItem(t)).then(function(t){return t&&Ui(t)})},n.set=function(t,e){return Ce(this.a.setItem(t,Mi(e)))},n.U=function(t){return Ce(this.a.removeItem(t))},n.ca=function(){},n.ia=function(){};var Iu,Tu=[];function Eu(t,e,n){vt(t.a)&&t.b.addEventListener("message",t.f),void 0===t.a[e]&&(t.a[e]=[]),t.a[e].push(n)}function Au(t){this.a=t}function ku(t){this.c=t,this.b=!1,this.a=[]}function Su(t,e,n,i){var r,o,a,s,u=n||{},c=null;if(t.b)return Re(Error("connection_unavailable"));var h=i?800:50,l="undefined"!=typeof MessageChannel?new MessageChannel:null;return new Ee(function(n,i){l?(r=Math.floor(Math.random()*Math.pow(10,20)).toString(),l.port1.start(),a=setTimeout(function(){i(Error("unsupported_event"))},h),c={messageChannel:l,onMessage:o=function(t){t.data.eventId===r&&("ack"===t.data.status?(clearTimeout(a),s=setTimeout(function(){i(Error("timeout"))},3e3)):"done"===t.data.status?(clearTimeout(s),void 0!==t.data.response?n(t.data.response):i(Error("unknown_error"))):(clearTimeout(a),clearTimeout(s),i(Error("invalid_response"))))}},t.a.push(c),l.port1.addEventListener("message",o),t.c.postMessage({eventType:e,eventId:r,data:u},[l.port2])):i(Error("connection_unavailable"))}).then(function(e){return Nu(t,c),e}).o(function(e){throw Nu(t,c),e})}function Nu(t,e){if(e){var n=e.messageChannel,i=e.onMessage;n&&(n.port1.removeEventListener("message",i),n.port1.close()),$(t.a,function(t){return t==e})}}function _u(){if(!Pu())throw new N("web-storage-unsupported");this.c={},this.a=[],this.b=0,this.m=u.indexedDB,this.type="indexedDB",this.g=this.v=this.f=this.l=null,this.s=!1,this.h=null;var t=this;Ii()&&self?(this.v=function(){var t=Ii()?self:null;if(B(Tu,function(n){n.b==t&&(e=n)}),!e){var e=new wu(t);Tu.push(e)}return e}(),Eu(this.v,"keyChanged",function(e,n){return ju(t).then(function(e){return 0<e.length&&B(t.a,function(t){t(e)}),{keyProcessed:Y(e,n.key)}})}),Eu(this.v,"ping",function(){return Ce(["keyChanged"])})):function(){var t=u.navigator;return t&&t.serviceWorker?Ce().then(function(){return t.serviceWorker.ready}).then(function(t){return t.active||null}).o(function(){return null}):Ce(null)}().then(function(e){(t.h=e)&&(t.g=new ku(new Au(e)),Su(t.g,"ping",null,!0).then(function(e){e[0].fulfilled&&Y(e[0].value,"keyChanged")&&(t.s=!0)}).o(function(){}))})}function Ou(t){return new Ee(function(e,n){var i=t.m.open("firebaseLocalStorageDb",1);i.onerror=function(t){try{t.preventDefault()}catch(e){}n(Error(t.target.error))},i.onupgradeneeded=function(t){t=t.target.result;try{t.createObjectStore("firebaseLocalStorage",{keyPath:"fbase_key"})}catch(e){n(e)}},i.onsuccess=function(i){(i=i.target.result).objectStoreNames.contains("firebaseLocalStorage")?e(i):function(t){return new Ee(function(e,n){var i=t.m.deleteDatabase("firebaseLocalStorageDb");i.onsuccess=function(){e()},i.onerror=function(t){n(Error(t.target.error))}})}(t).then(function(){return Ou(t)}).then(function(t){e(t)}).o(function(t){n(t)})}})}function Cu(t){return t.i||(t.i=Ou(t)),t.i}function Ru(t,e){var n=0;return new Ee(function i(r,o){Cu(t).then(e).then(r).o(function(e){if(!(3<++n))return Cu(t).then(function(e){return e.close(),t.i=void 0,i(r,o)}).o(function(t){o(t)});o(e)})})}function Pu(){try{return!!u.indexedDB}catch(Jt){return!1}}function Du(t){return t.objectStore("firebaseLocalStorage")}function Lu(t,e){return t.transaction(["firebaseLocalStorage"],e?"readwrite":"readonly")}function xu(t){return new Ee(function(e,n){t.onsuccess=function(t){t&&t.target?e(t.target.result):e()},t.onerror=function(t){n(t.target.error)}})}function Mu(t,e){return t.g&&t.h&&function(){var t=u.navigator;return t&&t.serviceWorker&&t.serviceWorker.controller||null}()===t.h?Su(t.g,"keyChanged",{key:e},t.s).then(function(){}).o(function(){}):Ce()}function ju(t){return Cu(t).then(function(t){var e=Du(Lu(t,!1));return e.getAll?xu(e.getAll()):new Ee(function(t,n){var i=[],r=e.openCursor();r.onsuccess=function(e){(e=e.target.result)?(i.push(e.value),e.continue()):t(i)},r.onerror=function(t){n(t.target.error)}})}).then(function(e){var n={},i=[];if(0==t.b){for(i=0;i<e.length;i++)n[e[i].fbase_key]=e[i].value;i=function t(e,n){var i,r=[];for(i in e)i in n?typeof e[i]!=typeof n[i]?r.push(i):"object"==typeof e[i]&&null!=e[i]&&null!=n[i]?0<t(e[i],n[i]).length&&r.push(i):e[i]!==n[i]&&r.push(i):r.push(i);for(i in n)i in e||r.push(i);return r}(t.c,n),t.c=n}return i})}function Uu(t){t.l&&t.l.cancel("STOP_EVENT"),t.f&&(clearTimeout(t.f),t.f=null)}function Vu(t){var e=this,n=null;this.a=[],this.type="indexedDB",this.c=t,this.b=Ce().then(function(){if(Pu()){var t=Vi(),i="__sak"+t;return Iu||(Iu=new _u),(n=Iu).set(i,t).then(function(){return n.get(i)}).then(function(e){if(e!==t)throw Error("indexedDB not supported!");return n.U(i)}).then(function(){return n}).o(function(){return e.c})}return e.c}).then(function(t){return e.type=t.type,t.ca(function(t){B(e.a,function(e){e(t)})}),t})}function Fu(){this.a={},this.type="inMemory"}function qu(){if(!function(){var t="Node"==Ti();if(!(t=Ku()||t&&e.default.INTERNAL.node&&e.default.INTERNAL.node.localStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(n){return!1}}()){if("Node"==Ti())throw new N("internal-error","The LocalStorage compatibility library was not found.");throw new N("web-storage-unsupported")}this.a=Ku()||e.default.INTERNAL.node.localStorage,this.type="localStorage"}function Ku(){try{var t=u.localStorage,e=Vi();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(n){return null}}function Hu(){this.type="nullStorage"}function Gu(){if(!function(){var t="Node"==Ti();if(!(t=Bu()||t&&e.default.INTERNAL.node&&e.default.INTERNAL.node.sessionStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(n){return!1}}()){if("Node"==Ti())throw new N("internal-error","The SessionStorage compatibility library was not found.");throw new N("web-storage-unsupported")}this.a=Bu()||e.default.INTERNAL.node.sessionStorage,this.type="sessionStorage"}function Bu(){try{var t=u.sessionStorage,e=Vi();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(n){return null}}function Wu(){var t={};t.Browser=Yu,t.Node=zu,t.ReactNative=$u,t.Worker=Zu,this.a=t[Ti()]}wu.prototype.c=function(t){var e=t.data.eventType,n=t.data.eventId,i=this.a[e];if(i&&0<i.length){t.ports[0].postMessage({status:"ack",eventId:n,eventType:e,response:null});var r=[];B(i,function(e){r.push(Ce().then(function(){return e(t.origin,t.data.data)}))}),De(r).then(function(i){var r=[];B(i,function(t){r.push({fulfilled:t.Qb,value:t.value,reason:t.reason?t.reason.message:void 0})}),B(r,function(t){for(var e in t)void 0===t[e]&&delete t[e]}),t.ports[0].postMessage({status:"done",eventId:n,eventType:e,response:r})})}},Au.prototype.postMessage=function(t,e){this.a.postMessage(t,e)},ku.prototype.close=function(){for(;0<this.a.length;)Nu(this,this.a[0]);this.b=!0},(n=_u.prototype).set=function(t,e){var n=this,i=!1;return Ru(this,function(e){return xu((e=Du(Lu(e,!0))).get(t))}).then(function(r){return Ru(n,function(o){if(o=Du(Lu(o,!0)),r)return r.value=e,xu(o.put(r));n.b++,i=!0;var a={};return a.fbase_key=t,a.value=e,xu(o.add(a))})}).then(function(){return n.c[t]=e,Mu(n,t)}).oa(function(){i&&n.b--})},n.get=function(t){return Ru(this,function(e){return xu(Du(Lu(e,!1)).get(t))}).then(function(t){return t&&t.value})},n.U=function(t){var e=this,n=!1;return Ru(this,function(i){return n=!0,e.b++,xu(Du(Lu(i,!0)).delete(t))}).then(function(){return delete e.c[t],Mu(e,t)}).oa(function(){n&&e.b--})},n.ca=function(t){0==this.a.length&&function(t){Uu(t),function e(){t.f=setTimeout(function(){t.l=ju(t).then(function(e){0<e.length&&B(t.a,function(t){t(e)})}).then(function(){e()}).o(function(t){"STOP_EVENT"!=t.message&&e()})},800)}()}(this),this.a.push(t)},n.ia=function(t){$(this.a,function(e){return e==t}),0==this.a.length&&Uu(this)},(n=Vu.prototype).get=function(t){return this.b.then(function(e){return e.get(t)})},n.set=function(t,e){return this.b.then(function(n){return n.set(t,e)})},n.U=function(t){return this.b.then(function(e){return e.U(t)})},n.ca=function(t){this.a.push(t)},n.ia=function(t){$(this.a,function(e){return e==t})},(n=Fu.prototype).get=function(t){return Ce(this.a[t])},n.set=function(t,e){return this.a[t]=e,Ce()},n.U=function(t){return delete this.a[t],Ce()},n.ca=function(){},n.ia=function(){},(n=qu.prototype).get=function(t){var e=this;return Ce().then(function(){return Ui(e.a.getItem(t))})},n.set=function(t,e){var n=this;return Ce().then(function(){var i=Mi(e);null===i?n.U(t):n.a.setItem(t,i)})},n.U=function(t){var e=this;return Ce().then(function(){e.a.removeItem(t)})},n.ca=function(t){u.window&&ln(u.window,"storage",t)},n.ia=function(t){u.window&&pn(u.window,"storage",t)},(n=Hu.prototype).get=function(){return Ce(null)},n.set=function(){return Ce()},n.U=function(){return Ce()},n.ca=function(){},n.ia=function(){},(n=Gu.prototype).get=function(t){var e=this;return Ce().then(function(){return Ui(e.a.getItem(t))})},n.set=function(t,e){var n=this;return Ce().then(function(){var i=Mi(e);null===i?n.U(t):n.a.setItem(t,i)})},n.U=function(t){var e=this;return Ce().then(function(){e.a.removeItem(t)})},n.ca=function(){},n.ia=function(){};var Xu,Ju,Yu={F:qu,cb:Gu},zu={F:qu,cb:Gu},$u={F:yu,cb:Hu},Zu={F:qu,cb:Hu},Qu={rd:"local",NONE:"none",td:"session"};function tc(){var t=!(Fi(Oi())||!wi()),e=xi(),n=Ri();this.m=t,this.h=e,this.l=n,this.a={},Xu||(Xu=new Wu),t=Xu;try{this.g=!hi()&&Bi()||!u.indexedDB?new t.a.F:new Vu(Ii()?new Fu:new t.a.F)}catch(i){this.g=new Fu,this.h=!0}try{this.i=new t.a.cb}catch(i){this.i=new Fu}this.v=new Fu,this.f=T(this.Zb,this),this.b={}}function ec(){return Ju||(Ju=new tc),Ju}function nc(t,e){switch(e){case"session":return t.i;case"none":return t.v;default:return t.g}}function ic(t,e){return"firebase:"+t.name+(e?":"+e:"")}function rc(t,e,n){return n=ic(e,n),"local"==e.F&&(t.b[n]=null),nc(t,e.F).U(n)}function oc(t){t.c&&(clearInterval(t.c),t.c=null)}function ac(t){this.a=t,this.b=ec()}(n=tc.prototype).get=function(t,e){return nc(this,t.F).get(ic(t,e))},n.set=function(t,e,n){var i=ic(t,n),r=this,o=nc(this,t.F);return o.set(i,e).then(function(){return o.get(i)}).then(function(e){"local"==t.F&&(r.b[i]=e)})},n.addListener=function(t,e,n){t=ic(t,e),this.l&&(this.b[t]=u.localStorage.getItem(t)),vt(this.a)&&(nc(this,"local").ca(this.f),this.h||(hi()||!Bi())&&u.indexedDB||!this.l||function(t){oc(t),t.c=setInterval(function(){for(var e in t.a){var n=u.localStorage.getItem(e),i=t.b[e];n!=i&&(t.b[e]=n,n=new Qe({type:"storage",key:e,target:window,oldValue:i,newValue:n,a:!0}),t.Zb(n))}},1e3)}(this)),this.a[t]||(this.a[t]=[]),this.a[t].push(n)},n.removeListener=function(t,e,n){t=ic(t,e),this.a[t]&&($(this.a[t],function(t){return t==n}),0==this.a[t].length&&delete this.a[t]),vt(this.a)&&(nc(this,"local").ia(this.f),oc(this))},n.Zb=function(t){if(t&&t.g){var e=t.a.key;if(null==e)for(var n in this.a){var i=this.b[n];void 0===i&&(i=null);var r=u.localStorage.getItem(n);r!==i&&(this.b[n]=r,this.nb(n))}else if(0==e.indexOf("firebase:")&&this.a[e]){if(void 0!==t.a.a?nc(this,"local").ia(this.f):oc(this),this.m)if(n=u.localStorage.getItem(e),(i=t.a.newValue)!==n)null!==i?u.localStorage.setItem(e,i):u.localStorage.removeItem(e);else if(this.b[e]===i&&void 0===t.a.a)return;var o=this;n=function(){void 0===t.a.a&&o.b[e]===u.localStorage.getItem(e)||(o.b[e]=u.localStorage.getItem(e),o.nb(e))},zt&&ce&&10==ce&&u.localStorage.getItem(e)!==t.a.newValue&&t.a.newValue!==t.a.oldValue?setTimeout(n,10):n()}}else B(t,T(this.nb,this))},n.nb=function(t){this.a[t]&&B(this.a[t],function(t){t()})};var sc,uc={name:"authEvent",F:"local"};function cc(){this.a=ec()}function hc(t,e){this.b=lc,this.f=u.Uint8Array?new Uint8Array(this.b):Array(this.b),this.g=this.c=0,this.a=[],this.i=t,this.h=e,this.l=u.Int32Array?new Int32Array(64):Array(64),void 0===sc&&(sc=u.Int32Array?new Int32Array(bc):bc),this.reset()}k(hc,function(){this.b=-1});for(var lc=64,fc=lc-1,dc=[],pc=0;pc<fc;pc++)dc[pc]=0;var vc=Z(128,dc);function mc(t){for(var e=t.f,n=t.l,i=0,r=0;r<e.length;)n[i++]=e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3],r=4*i;for(e=16;64>e;e++){r=0|n[e-15],i=0|n[e-2];var o=(0|n[e-16])+((r>>>7|r<<25)^(r>>>18|r<<14)^r>>>3)|0,a=(0|n[e-7])+((i>>>17|i<<15)^(i>>>19|i<<13)^i>>>10)|0;n[e]=o+a|0}i=0|t.a[0],r=0|t.a[1];var s=0|t.a[2],u=0|t.a[3],c=0|t.a[4],h=0|t.a[5],l=0|t.a[6];for(o=0|t.a[7],e=0;64>e;e++){var f=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&r^i&s^r&s)|0;a=(o=o+((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))|0)+((a=(a=c&h^~c&l)+(0|sc[e])|0)+(0|n[e])|0)|0,o=l,l=h,h=c,c=u+a|0,u=s,s=r,r=i,i=a+f|0}t.a[0]=t.a[0]+i|0,t.a[1]=t.a[1]+r|0,t.a[2]=t.a[2]+s|0,t.a[3]=t.a[3]+u|0,t.a[4]=t.a[4]+c|0,t.a[5]=t.a[5]+h|0,t.a[6]=t.a[6]+l|0,t.a[7]=t.a[7]+o|0}function gc(t,e,n){void 0===n&&(n=e.length);var i=0,r=t.c;if("string"==typeof e)for(;i<n;)t.f[r++]=e.charCodeAt(i++),r==t.b&&(mc(t),r=0);else{if(!p(e))throw Error("message must be string or array");for(;i<n;){var o=e[i++];if(!("number"==typeof o&&0<=o&&255>=o&&o==(0|o)))throw Error("message must be a byte array");t.f[r++]=o,r==t.b&&(mc(t),r=0)}}t.c=r,t.g+=n}hc.prototype.reset=function(){this.g=this.c=0,this.a=u.Int32Array?new Int32Array(this.h):Q(this.h)};var bc=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function yc(){hc.call(this,8,wc)}k(yc,hc);var wc=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function Ic(t,e,n,i,r,o){this.v=t,this.i=e,this.l=n,this.m=i||null,this.u=r||null,this.s=o,this.h=e+":"+n,this.C=new cc,this.g=new ac(this.h),this.f=null,this.b=[],this.a=this.c=null}function Tc(t){return new N("invalid-cordova-configuration",t)}function Ec(t){var e=new yc;gc(e,t),t=[];var n=8*e.g;56>e.c?gc(e,vc,56-e.c):gc(e,vc,e.b-(e.c-56));for(var i=63;56<=i;i--)e.f[i]=255&n,n/=256;for(mc(e),i=n=0;i<e.i;i++)for(var r=24;0<=r;r-=8)t[n++]=e.a[i]>>r&255;return function(t){return X(t,function(t){return 1<(t=t.toString(16)).length?t:"0"+t}).join("")}(t)}function Ac(t,e){for(var n=0;n<t.b.length;n++)try{t.b[n](e)}catch(i){}}function kc(t){return t.f||(t.f=t.ma().then(function(){return new Ee(function(e){t.Ea(function n(i){return e(i),t.Ta(n),!1}),function(t){function e(e){i=!0,r&&r.cancel(),Sc(t).then(function(i){var r=n;if(i&&e&&e.url){var o=null;-1!=(r=oo(e.url)).indexOf("/__/auth/callback")&&(o=(o="object"==typeof(o=Ui(Fn(o=qn(r),"firebaseError")||null))?_(o):null)?new qo(i.c,i.b,null,null,o,null,i.T()):new qo(i.c,i.b,r,i.f,null,null,i.T())),r=o||n}Ac(t,r)})}var n=new qo("unknown",null,null,null,new N("no-auth-event")),i=!1,r=_n(500).then(function(){return Sc(t).then(function(){i||Ac(t,n)})}),o=u.handleOpenURL;u.handleOpenURL=function(t){if(0==t.toLowerCase().indexOf(Ci("BuildInfo.packageName",u).toLowerCase()+"://")&&e({url:t}),"function"==typeof o)try{o(t)}catch(n){console.error(n)}},Bo||(Bo=new Ho),function(t){var e=Bo;e.a.push(t),e.b||(e.b=function(t){for(var n=0;n<e.a.length;n++)e.a[n](t)},"function"==typeof(t=Ci("universalLinks.subscribe",u))&&t(null,e.b))}(e)}(t)})})),t.f}function Sc(t){var e=null;return function(t){return t.b.get(uc,t.a).then(function(t){return Ko(t)})}(t.g).then(function(n){return e=n,rc((n=t.g).b,uc,n.a)}).then(function(){return e})}function Nc(t){this.a=t,this.b=ec()}(n=Ic.prototype).ma=function(){return this.Ia?this.Ia:this.Ia=(yi(void 0)?bi().then(function(){return new Ee(function(t,e){var n=u.document,i=setTimeout(function(){e(Error("Cordova framework is not ready."))},1e3);n.addEventListener("deviceready",function(){clearTimeout(i),t()},!1)})}):Re(Error("Cordova must run in an Android or iOS file scheme."))).then(function(){if("function"!=typeof Ci("universalLinks.subscribe",u))throw Tc("cordova-universal-links-plugin-fix is not installed");if(void 0===Ci("BuildInfo.packageName",u))throw Tc("cordova-plugin-buildinfo is not installed");if("function"!=typeof Ci("cordova.plugins.browsertab.openUrl",u))throw Tc("cordova-plugin-browsertab is not installed");if("function"!=typeof Ci("cordova.InAppBrowser.open",u))throw Tc("cordova-plugin-inappbrowser is not installed")},function(){throw new N("cordova-not-ready")})},n.Pb=function(t,e){return e(new N("operation-not-supported-in-this-environment")),Ce()},n.Nb=function(){return Re(new N("operation-not-supported-in-this-environment"))},n.ac=function(){return!1},n.Yb=function(){return!0},n.Ub=function(){return!0},n.Ob=function(t,e,n,i){if(this.c)return Re(new N("redirect-operation-pending"));var r=this,o=u.document,a=null,s=null,c=null,h=null;return this.c=Ce().then(function(){return Fo(e),kc(r)}).then(function(){return function(t,e,n,i,r){var o=function(){for(var t=20,e=[];0<t;)e.push("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(62*Math.random()))),t--;return e.join("")}(),a=new qo(e,i,null,o,new N("no-auth-event"),null,r),s=Ci("BuildInfo.packageName",u);if("string"!=typeof s)throw new N("invalid-cordova-configuration");var c=Ci("BuildInfo.displayName",u),h={};if(Oi().toLowerCase().match(/iphone|ipad|ipod/))h.ibi=s;else{if(!Oi().toLowerCase().match(/android/))return Re(new N("operation-not-supported-in-this-environment"));h.apn=s}c&&(h.appDisplayName=c),o=Ec(o),h.sessionId=o;var l=bu(t.v,t.i,t.l,e,n,null,i,t.m,h,t.u,r,t.s);return t.ma().then(function(){var e=t.h;return t.C.a.set(uc,a.w(),e)}).then(function(){var e=Ci("cordova.plugins.browsertab.isAvailable",u);if("function"!=typeof e)throw new N("invalid-cordova-configuration");var n=null;e(function(e){if(e){if("function"!=typeof(n=Ci("cordova.plugins.browsertab.openUrl",u)))throw new N("invalid-cordova-configuration");n(l)}else{if("function"!=typeof(n=Ci("cordova.InAppBrowser.open",u)))throw new N("invalid-cordova-configuration");e=Oi(),t.a=n(l,e.match(/(iPad|iPhone|iPod).*OS 7_\d/i)||e.match(/(iPad|iPhone|iPod).*OS 8_\d/i)?"_blank":"_system","location=yes")}})})}(r,t,e,n,i)}).then(function(){return new Ee(function(t,e){s=function(){var e=Ci("cordova.plugins.browsertab.close",u);return t(),"function"==typeof e&&e(),r.a&&"function"==typeof r.a.close&&(r.a.close(),r.a=null),!1},r.Ea(s),c=function(){a||(a=_n(2e3).then(function(){e(new N("redirect-cancelled-by-user"))}))},h=function(){Hi()&&c()},o.addEventListener("resume",c,!1),Oi().toLowerCase().match(/android/)||o.addEventListener("visibilitychange",h,!1)}).o(function(t){return Sc(r).then(function(){throw t})})}).oa(function(){c&&o.removeEventListener("resume",c,!1),h&&o.removeEventListener("visibilitychange",h,!1),a&&a.cancel(),s&&r.Ta(s),r.c=null})},n.Ea=function(t){this.b.push(t),kc(this).o(function(e){"auth/invalid-cordova-configuration"===e.code&&(e=new qo("unknown",null,null,null,new N("no-auth-event")),t(e))})},n.Ta=function(t){$(this.b,function(e){return e==t})};var _c={name:"pendingRedirect",F:"session"};function Oc(t){return rc(t.b,_c,t.a)}function Cc(t,e,n,i){this.i={},this.u=0,this.D=t,this.v=e,this.m=n,this.J=i,this.h=[],this.f=!1,this.l=T(this.s,this),this.b=new Bc,this.C=new zc,this.g=new Nc(Hc(this.v,this.m)),this.c={},this.c.unknown=this.b,this.c.signInViaRedirect=this.b,this.c.linkViaRedirect=this.b,this.c.reauthViaRedirect=this.b,this.c.signInViaPopup=this.C,this.c.linkViaPopup=this.C,this.c.reauthViaPopup=this.C,this.a=Rc(this.D,this.v,this.m,O,this.J)}function Rc(t,n,i,r,o){var a=e.default.SDK_VERSION||null;return yi()?new Ic(t,n,i,a,r,o):new pu(t,n,i,a,r,o)}function Pc(t){t.f||(t.f=!0,t.a.Ea(t.l));var e=t.a;return t.a.ma().o(function(n){throw t.a==e&&t.reset(),n})}function Dc(t){t.a.Yb()&&Pc(t).o(function(e){var n=new qo("unknown",null,null,null,new N("operation-not-supported-in-this-environment"));Vc(e)&&t.s(n)}),t.a.Ub()||Wc(t.b)}function Lc(t,e){Y(t.h,e)||t.h.push(e),t.f||function(t){return t.b.get(_c,t.a).then(function(t){return"pending"==t})}(t.g).then(function(e){e?Oc(t.g).then(function(){Pc(t).o(function(e){var n=new qo("unknown",null,null,null,new N("operation-not-supported-in-this-environment"));Vc(e)&&t.s(n)})}):Dc(t)}).o(function(){Dc(t)})}function xc(t,e){$(t.h,function(t){return t==e})}Cc.prototype.reset=function(){this.f=!1,this.a.Ta(this.l),this.a=Rc(this.D,this.v,this.m,null,this.J),this.i={}},Cc.prototype.s=function(t){if(!t)throw new N("invalid-auth-event");if(6e5<=Date.now()-this.u&&(this.i={},this.u=0),t&&t.getUid()&&this.i.hasOwnProperty(t.getUid()))return!1;for(var e=!1,n=0;n<this.h.length;n++){var i=this.h[n];if(i.Gb(t.c,t.b)){(e=this.c[t.c])&&(e.h(t,i),t&&(t.f||t.b)&&(this.i[t.getUid()]=!0,this.u=Date.now())),e=!0;break}}return Wc(this.b),e};var Mc=new Ki(2e3,1e4),jc=new Ki(3e4,6e4);function Uc(t,e,n,i,r,o,a){return t.a.Nb(e,n,i,function(){t.f||(t.f=!0,t.a.Ea(t.l))},function(){t.reset()},r,o,a)}function Vc(t){return!(!t||"auth/cordova-not-ready"!=t.code)}function Fc(t,e,n,i,r){var o;return function(t){return t.b.set(_c,"pending",t.a)}(t.g).then(function(){return t.a.Ob(e,n,i,r).o(function(e){if(Vc(e))throw new N("operation-not-supported-in-this-environment");return o=e,Oc(t.g).then(function(){throw o})}).then(function(){return t.a.ac()?new Ee(function(){}):Oc(t.g).then(function(){return t.ra()}).then(function(){}).o(function(){})})})}function qc(t,e,n,i,r){return t.a.Pb(i,function(t){e.na(n,null,t,r)},Mc.get())}Cc.prototype.ra=function(){return this.b.ra()};var Kc={};function Hc(t,e,n){return t=t+":"+e,n&&(t=t+":"+n.url),t}function Gc(t,e,n,i){var r=Hc(e,n,i);return Kc[r]||(Kc[r]=new Cc(t,e,n,i)),Kc[r]}function Bc(){this.b=null,this.f=[],this.c=[],this.a=null,this.i=this.g=!1}function Wc(t){t.g||(t.g=!0,Yc(t,!1,null,null))}function Xc(t){t.g&&!t.i&&Yc(t,!1,null,null)}function Jc(t,e){if(t.b=function(){return Ce(e)},t.f.length)for(var n=0;n<t.f.length;n++)t.f[n](e)}function Yc(t,e,n,i){e?i?function(t,e){if(t.b=function(){return Re(e)},t.c.length)for(var n=0;n<t.c.length;n++)t.c[n](e)}(t,i):Jc(t,n):Jc(t,{user:null}),t.f=[],t.c=[]}function zc(){}function $c(){this.jb=!1,Object.defineProperty(this,"appVerificationDisabled",{get:function(){return this.jb},set:function(t){this.jb=t},enumerable:!1})}function Zc(t,e){this.a=e,zi(this,"verificationId",t)}function Qc(t,e,n,i){return new jo(t).gb(e,n).then(function(t){return new Zc(t,i)})}function th(t){var e=Br(t);if(!(e&&e.exp&&e.auth_time&&e.iat))throw new N("internal-error","An internal error occurred. The token obtained by Firebase appears to be malformed. Please retry the operation.");$i(this,{token:t,expirationTime:Gi(1e3*e.exp),authTime:Gi(1e3*e.auth_time),issuedAtTime:Gi(1e3*e.iat),signInProvider:e.firebase&&e.firebase.sign_in_provider?e.firebase.sign_in_provider:null,signInSecondFactor:e.firebase&&e.firebase.sign_in_second_factor?e.firebase.sign_in_second_factor:null,claims:e})}function eh(t,e,n){var i=e&&e[ih];if(!i)throw new N("argument-error","Internal assert: Invalid MultiFactorResolver");this.a=t,this.f=mt(e),this.g=n,this.c=new ao(null,i),this.b=[];var r=this;B(e[nh]||[],function(t){(t=er(t))&&r.b.push(t)}),zi(this,"auth",this.a),zi(this,"session",this.c),zi(this,"hints",this.b)}Bc.prototype.reset=function(){this.b=null,this.a&&(this.a.cancel(),this.a=null)},Bc.prototype.h=function(t,e){if(t){this.reset(),this.g=!0;var n=t.c,i=t.b,r=t.a&&"auth/web-storage-unsupported"==t.a.code,o=t.a&&"auth/operation-not-supported-in-this-environment"==t.a.code;this.i=!(!r&&!o),"unknown"!=n||r||o?t.a?(Yc(this,!0,null,t.a),Ce()):e.Fa(n,i)?function(t,e,n){n=n.Fa(e.c,e.b);var i=e.g,r=e.f,o=e.i,a=e.T(),s=!!e.c.match(/Redirect$/);n(i,r,a,o).then(function(e){Yc(t,s,e,null)}).o(function(e){Yc(t,s,null,e)})}(this,t,e):Re(new N("invalid-auth-event")):(Yc(this,!1,null,null),Ce())}else Re(new N("invalid-auth-event"))},Bc.prototype.ra=function(){var t=this;return new Ee(function(e,n){t.b?t.b().then(e,n):(t.f.push(e),t.c.push(n),function(t){var e=new N("timeout");t.a&&t.a.cancel(),t.a=_n(jc.get()).then(function(){t.b||(t.g=!0,Yc(t,!0,null,e))})}(t))})},zc.prototype.h=function(t,e){if(t){var n=t.c,i=t.b;t.a?(e.na(t.c,null,t.a,t.b),Ce()):e.Fa(n,i)?function(t,e){var n=t.b,i=t.c;e.Fa(i,n)(t.g,t.f,t.T(),t.i).then(function(t){e.na(i,t,null,n)}).o(function(t){e.na(i,null,t,n)})}(t,e):Re(new N("invalid-auth-event"))}else Re(new N("invalid-auth-event"))},Zc.prototype.confirm=function(t){return t=Uo(this.verificationId,t),this.a(t)};var nh="mfaInfo",ih="mfaPendingCredential";function rh(t,e,n,i){N.call(this,"multi-factor-auth-required",i,e),this.b=new eh(t,e,n),zi(this,"resolver",this.b)}function oh(t,e,n){if(t&&m(t.serverResponse)&&"auth/multi-factor-auth-required"===t.code)try{return new rh(e,t.serverResponse,n,t.message)}catch(i){}return null}function ah(){}function sh(t){zi(this,"factorId",t.fa),this.a=t}function uh(t){if(sh.call(this,t),this.a.fa!=jo.PROVIDER_ID)throw new N("argument-error","firebase.auth.PhoneMultiFactorAssertion requires a valid firebase.auth.PhoneAuthCredential")}function ch(t,e){for(var n in Ze.call(this,t),e)this[n]=e[n]}function hh(t,e){this.a=t,this.b=[],this.c=T(this.yc,this),ln(this.a,"userReloaded",this.c);var n=[];e&&e.multiFactor&&e.multiFactor.enrolledFactors&&B(e.multiFactor.enrolledFactors,function(t){var e=null,i={};if(t){t.uid&&(i[rr]=t.uid),t.displayName&&(i[nr]=t.displayName),t.enrollmentTime&&(i[ir]=new Date(t.enrollmentTime).toISOString()),t.phoneNumber&&(i[or]=t.phoneNumber);try{e=new ar(i)}catch(r){}t=e}else t=null;t&&n.push(t)}),lh(this,n)}function lh(t,e){t.b=e,zi(t,"enrolledFactors",e)}function fh(t,e,n){if(this.h=t,this.i=e,this.g=n,this.c=3e4,this.f=96e4,this.b=null,this.a=this.c,this.f<this.c)throw Error("Proactive refresh lower bound greater than upper bound!")}function dh(t){this.f=t,this.b=this.a=null,this.c=Date.now()}function ph(t,e){void 0===e&&(t.b?e=(e=t.b).a-e.g:e=0),t.c=Date.now()+1e3*e}function vh(t,e){t.b=Gr(e[Za]||""),t.a=e.refreshToken,ph(t,void 0!==(e=e.expiresIn)?Number(e):void 0)}function mh(t,e){return function(t,e){return new Ee(function(n,i){"refresh_token"==e.grant_type&&e.refresh_token||"authorization_code"==e.grant_type&&e.code?ss(t,t.l+"?key="+encodeURIComponent(t.c),function(t){t?t.error?i(ou(t)):t.access_token&&t.refresh_token?n(t):i(new N("internal-error")):i(new N("network-request-failed"))},"POST",Qn(e).toString(),t.g,t.m.get()):i(new N("internal-error"))})}(t.f,e).then(function(e){return t.b=Gr(e.access_token),t.a=e.refresh_token,ph(t,e.expires_in),{accessToken:t.b.toString(),refreshToken:t.a}}).o(function(e){throw"auth/user-token-expired"==e.code&&(t.a=null),e})}function gh(t,e){this.a=t||null,this.b=e||null,$i(this,{lastSignInTime:Gi(e||null),creationTime:Gi(t||null)})}function bh(t,e,n,i,r,o){$i(this,{uid:t,displayName:i||null,photoURL:r||null,email:n||null,phoneNumber:o||null,providerId:e})}function yh(t,n,i){this.N=[],this.l=t.apiKey,this.m=t.appName,this.s=t.authDomain||null;var r=e.default.SDK_VERSION?_i(e.default.SDK_VERSION):null;this.a=new za(this.l,D(O),r),(this.u=t.emulatorConfig||null)&&rs(this.a,this.u),this.h=new dh(this.a),_h(this,n[Za]),vh(this.h,n),zi(this,"refreshToken",this.h.a),Rh(this,i||{}),En.call(this),this.P=!1,this.s&&Pi()&&(this.b=Gc(this.s,this.l,this.m,this.u)),this.W=[],this.i=null,this.D=function(t){return new fh(function(){return t.I(!0)},function(t){return!(!t||"auth/network-request-failed"!=t.code)},function(){var e=t.h.c-Date.now()-3e5;return 0<e?e:0})}(this),this.ba=T(this.ib,this);var o=this;this.za=null,this.Pa=function(t){o.xa(t.h)},this.qa=null,this.Ba=function(t){wh(o,t.c)},this.$=null,this.aa=[],this.Oa=function(t){Eh(o,t.f)},this.ja=null,this.S=new hh(this,i),zi(this,"multiFactor",this.S)}function wh(t,e){t.u=e,rs(t.a,e),t.b&&(e=t.b,t.b=Gc(t.s,t.l,t.m,t.u),t.P&&(xc(e,t),Lc(t.b,t)))}function Ih(t,e){t.qa&&pn(t.qa,"languageCodeChanged",t.Pa),(t.qa=e)&&ln(e,"languageCodeChanged",t.Pa)}function Th(t,e){t.$&&pn(t.$,"emulatorConfigChanged",t.Ba),(t.$=e)&&ln(e,"emulatorConfigChanged",t.Ba)}function Eh(t,n){t.aa=n,as(t.a,e.default.SDK_VERSION?_i(e.default.SDK_VERSION,t.aa):null)}function Ah(t,e){t.ja&&pn(t.ja,"frameworkChanged",t.Oa),(t.ja=e)&&ln(e,"frameworkChanged",t.Oa)}function kh(t){try{return e.default.app(t.m).auth()}catch(n){throw new N("internal-error","No firebase.auth.Auth instance is available for the Firebase App '"+t.m+"'!")}}function Sh(t){t.J||t.D.b||(t.D.start(),pn(t,"tokenChanged",t.ba),ln(t,"tokenChanged",t.ba))}function Nh(t){pn(t,"tokenChanged",t.ba),t.D.stop()}function _h(t,e){t.Aa=e,zi(t,"_lat",e)}function Oh(t){for(var e=[],n=0;n<t.W.length;n++)e.push(t.W[n](t));return De(e).then(function(){return t})}function Ch(t){t.b&&!t.P&&(t.P=!0,Lc(t.b,t))}function Rh(t,e){$i(t,{uid:e.uid,displayName:e.displayName||null,photoURL:e.photoURL||null,email:e.email||null,emailVerified:e.emailVerified||!1,phoneNumber:e.phoneNumber||null,isAnonymous:e.isAnonymous||!1,tenantId:e.tenantId||null,metadata:new gh(e.createdAt,e.lastLoginAt),providerData:[]}),t.a.b=t.tenantId}function Ph(){}function Dh(t){return Ce().then(function(){if(t.J)throw new N("app-deleted")})}function Lh(t){return X(t.providerData,function(t){return t.providerId})}function xh(t,e){e&&(Mh(t,e.providerId),t.providerData.push(e))}function Mh(t,e){$(t.providerData,function(t){return t.providerId==e})}function jh(t,e,n){("uid"!=e||n)&&t.hasOwnProperty(e)&&zi(t,e,n)}function Uh(t,e){t!=e&&($i(t,{uid:e.uid,displayName:e.displayName,photoURL:e.photoURL,email:e.email,emailVerified:e.emailVerified,phoneNumber:e.phoneNumber,isAnonymous:e.isAnonymous,tenantId:e.tenantId,providerData:[]}),e.metadata?zi(t,"metadata",function(t){return new gh(t.a,t.b)}(e.metadata)):zi(t,"metadata",new gh),B(e.providerData,function(e){xh(t,e)}),function(t,e){t.b=e.b,t.a=e.a,t.c=e.c}(t.h,e.h),zi(t,"refreshToken",t.h.a),lh(t.S,e.S.b))}function Vh(t){return t.I().then(function(e){var n=t.isAnonymous;return function(t,e){return iu(t.a,Ls,{idToken:e}).then(T(t.Kc,t))}(t,e).then(function(){return n||jh(t,"isAnonymous",!1),e})})}function Fh(t,e){e[Za]&&t.Aa!=e[Za]&&(vh(t.h,e),t.dispatchEvent(new ch("tokenChanged")),_h(t,e[Za]),jh(t,"refreshToken",t.h.a))}function qh(t,e){return Vh(t).then(function(){if(Y(Lh(t),e))return Oh(t).then(function(){throw new N("provider-already-linked")})})}function Kh(t,e,n){return Zi({user:t,credential:Vo(e),additionalUserInfo:e=zr(e),operationType:n})}function Hh(t,e){return Fh(t,e),t.reload().then(function(){return t})}function Gh(t,n,i,r,o){if(!Pi())return Re(new N("operation-not-supported-in-this-environment"));if(t.i&&!o)return Re(t.i);var a=Yr(i.providerId),s=Vi(t.uid+":::"),u=null;(!xi()||wi())&&t.s&&i.isOAuthProvider&&(u=bu(t.s,t.l,t.m,n,i,null,s,e.default.SDK_VERSION||null,null,null,t.tenantId,t.u));var c=vi(u,a&&a.va,a&&a.ua);return r=r().then(function(){if(Wh(t),!o)return t.I().then(function(){})}).then(function(){return Uc(t.b,c,n,i,s,!!u,t.tenantId)}).then(function(){return new Ee(function(e,i){t.na(n,null,new N("cancelled-popup-request"),t.g||null),t.f=e,t.C=i,t.g=s,t.c=qc(t.b,t,n,c,s)})}).then(function(t){return c&&pi(c),t?Zi(t):null}).o(function(t){throw c&&pi(c),t}),Xh(t,r,o)}function Bh(t,e,n,i,r){if(!Pi())return Re(new N("operation-not-supported-in-this-environment"));if(t.i&&!r)return Re(t.i);var o=null,a=Vi(t.uid+":::");return i=i().then(function(){if(Wh(t),!r)return t.I().then(function(){})}).then(function(){return t.ga=a,Oh(t)}).then(function(e){return t.ha&&(e=(e=t.ha).b.set(zh,t.w(),e.a)),e}).then(function(){return Fc(t.b,e,n,a,t.tenantId)}).o(function(e){if(o=e,t.ha)return $h(t.ha);throw o}).then(function(){if(o)throw o}),Xh(t,i,r)}function Wh(t){if(!t.b||!t.P){if(t.b&&!t.P)throw new N("internal-error");throw new N("auth-domain-config-required")}}function Xh(t,e,n){var i=function(t,e,n){return t.i&&!n?(e.cancel(),Re(t.i)):e.o(function(e){throw!e||"auth/user-disabled"!=e.code&&"auth/user-token-expired"!=e.code||(t.i||t.dispatchEvent(new ch("userInvalidated")),t.i=e),e})}(t,e,n);return t.N.push(i),i.oa(function(){z(t.N,i)}),i.o(function(e){var n=null;throw e&&"auth/multi-factor-auth-required"===e.code&&(n=oh(e.w(),kh(t),T(t.jc,t))),n||e})}function Jh(t){if(!t.apiKey)return null;var e={apiKey:t.apiKey,authDomain:t.authDomain,appName:t.appName,emulatorConfig:t.emulatorConfig},n={};if(!t.stsTokenManager||!t.stsTokenManager.accessToken)return null;n[Za]=t.stsTokenManager.accessToken,n.refreshToken=t.stsTokenManager.refreshToken||null;var i=t.stsTokenManager.expirationTime;i&&(n.expiresIn=(i-Date.now())/1e3);var r=new yh(e,n,t);return t.providerData&&B(t.providerData,function(t){t&&xh(r,Zi(t))}),t.redirectEventId&&(r.ga=t.redirectEventId),r}function Yh(t){this.a=t,this.b=ec()}eh.prototype.Rc=function(t){var e=this;return t.tb(this.a.a,this.c).then(function(t){var n=mt(e.f);return delete n[nh],delete n[ih],bt(n,t),e.g(n)})},k(rh,N),ah.prototype.tb=function(t,e,n){return e.type==so?function(t,e,n,i){return n.Ha().then(function(n){return n={idToken:n},void 0!==i&&(n.displayName=i),bt(n,{phoneVerificationInfo:Mo(t.a)}),iu(e,Ps,n)})}(this,t,e,n):function(t,e,n){return n.Ha().then(function(n){return bt(n={mfaPendingCredential:n},{phoneVerificationInfo:Mo(t.a)}),iu(e,Ds,n)})}(this,t,e)},k(sh,ah),k(uh,sh),k(ch,Ze),(n=hh.prototype).yc=function(t){lh(this,function(t){var e=[];return B(t.mfaInfo||[],function(t){(t=er(t))&&e.push(t)}),e}(t.hd))},n.Sb=function(){return this.a.I().then(function(t){return new ao(t,null)})},n.fc=function(t,e){var n=this,i=this.a.a;return this.Sb().then(function(n){return t.tb(i,n,e)}).then(function(t){return Fh(n.a,t),n.a.reload()})},n.bd=function(t){var e=this,n="string"==typeof t?t:t.uid,i=this.a.a;return this.a.I().then(function(t){return iu(i,nu,{idToken:t,mfaEnrollmentId:n})}).then(function(t){var i=W(e.b,function(t){return t.uid!=n});return lh(e,i),Fh(e.a,t),e.a.reload().o(function(t){if("auth/user-token-expired"!=t.code)throw t})})},n.w=function(){return{multiFactor:{enrolledFactors:X(this.b,function(t){return t.w()})}}},fh.prototype.start=function(){this.a=this.c,function t(e,n){e.stop();e.b=_n(function(t,e){return e?(t.a=t.c,t.g()):(e=t.a,t.a*=2,t.a>t.f&&(t.a=t.f),e)}(e,n)).then(function(){return t=u.document,e=null,Hi()||!t?Ce():new Ee(function(n){e=function(){Hi()&&(t.removeEventListener("visibilitychange",e,!1),n())},t.addEventListener("visibilitychange",e,!1)}).o(function(n){throw t.removeEventListener("visibilitychange",e,!1),n});var t,e}).then(function(){return e.h()}).then(function(){t(e,!0)}).o(function(n){e.i(n)&&t(e,!1)})}(this,!0)},fh.prototype.stop=function(){this.b&&(this.b.cancel(),this.b=null)},dh.prototype.w=function(){return{apiKey:this.f.c,refreshToken:this.a,accessToken:this.b&&this.b.toString(),expirationTime:this.c}},dh.prototype.getToken=function(t){return t=!!t,this.b&&!this.a?Re(new N("user-token-expired")):t||!this.b||Date.now()>this.c-3e4?this.a?mh(this,{grant_type:"refresh_token",refresh_token:this.a}):Ce(null):Ce({accessToken:this.b.toString(),refreshToken:this.a})},gh.prototype.w=function(){return{lastLoginAt:this.b,createdAt:this.a}},k(yh,En),yh.prototype.xa=function(t){this.za=t,is(this.a,t)},yh.prototype.la=function(){return this.za},yh.prototype.Ga=function(){return Q(this.aa)},yh.prototype.ib=function(){this.D.b&&(this.D.stop(),this.D.start())},zi(yh.prototype,"providerId","firebase"),(n=yh.prototype).reload=function(){var t=this;return Xh(this,Dh(this).then(function(){return Vh(t).then(function(){return Oh(t)}).then(Ph)}))},n.oc=function(t){return this.I(t).then(function(t){return new th(t)})},n.I=function(t){var e=this;return Xh(this,Dh(this).then(function(){return e.h.getToken(t)}).then(function(t){if(!t)throw new N("internal-error");return t.accessToken!=e.Aa&&(_h(e,t.accessToken),e.dispatchEvent(new ch("tokenChanged"))),jh(e,"refreshToken",t.refreshToken),t.accessToken}))},n.Kc=function(t){if(!(t=t.users)||!t.length)throw new N("internal-error");Rh(this,{uid:(t=t[0]).localId,displayName:t.displayName,photoURL:t.photoUrl,email:t.email,emailVerified:!!t.emailVerified,phoneNumber:t.phoneNumber,lastLoginAt:t.lastLoginAt,createdAt:t.createdAt,tenantId:t.tenantId});for(var e=function(t){return(t=t.providerUserInfo)&&t.length?X(t,function(t){return new bh(t.rawId,t.providerId,t.email,t.displayName,t.photoUrl,t.phoneNumber)}):[]}(t),n=0;n<e.length;n++)xh(this,e[n]);jh(this,"isAnonymous",!(this.email&&t.passwordHash||this.providerData&&this.providerData.length)),this.dispatchEvent(new ch("userReloaded",{hd:t}))},n.Lc=function(t){return Ji("firebase.User.prototype.reauthenticateAndRetrieveDataWithCredential is deprecated. Please use firebase.User.prototype.reauthenticateWithCredential instead."),this.ub(t)},n.ub=function(t){var e=this,n=null;return Xh(this,t.c(this.a,this.uid).then(function(t){return Fh(e,t),n=Kh(e,t,"reauthenticate"),e.i=null,e.reload()}).then(function(){return n}),!0)},n.Cc=function(t){return Ji("firebase.User.prototype.linkAndRetrieveDataWithCredential is deprecated. Please use firebase.User.prototype.linkWithCredential instead."),this.rb(t)},n.rb=function(t){var e=this,n=null;return Xh(this,qh(this,t.providerId).then(function(){return e.I()}).then(function(n){return t.b(e.a,n)}).then(function(t){return n=Kh(e,t,"link"),Hh(e,t)}).then(function(){return n}))},n.Dc=function(t,e){var n=this;return Xh(this,qh(this,"phone").then(function(){return Qc(kh(n),t,e,T(n.rb,n))}))},n.Mc=function(t,e){var n=this;return Xh(this,Ce().then(function(){return Qc(kh(n),t,e,T(n.ub,n))}),!0)},n.Cb=function(t){var e=this;return Xh(this,this.I().then(function(n){return e.a.Cb(n,t)}).then(function(t){return Fh(e,t),e.reload()}))},n.ed=function(t){var e=this;return Xh(this,this.I().then(function(n){return t.b(e.a,n)}).then(function(t){return Fh(e,t),e.reload()}))},n.Db=function(t){var e=this;return Xh(this,this.I().then(function(n){return e.a.Db(n,t)}).then(function(t){return Fh(e,t),e.reload()}))},n.Eb=function(t){if(void 0===t.displayName&&void 0===t.photoURL)return Dh(this);var e=this;return Xh(this,this.I().then(function(n){return e.a.Eb(n,{displayName:t.displayName,photoUrl:t.photoURL})}).then(function(t){return Fh(e,t),jh(e,"displayName",t.displayName||null),jh(e,"photoURL",t.photoUrl||null),B(e.providerData,function(t){"password"===t.providerId&&(zi(t,"displayName",e.displayName),zi(t,"photoURL",e.photoURL))}),Oh(e)}).then(Ph))},n.cd=function(t){var e=this;return Xh(this,Vh(this).then(function(n){return Y(Lh(e),t)?function(t,e,n){return iu(t,Os,{idToken:e,deleteProvider:n})}(e.a,n,[t]).then(function(t){var n={};return B(t.providerUserInfo||[],function(t){n[t.providerId]=!0}),B(Lh(e),function(t){n[t]||Mh(e,t)}),n[jo.PROVIDER_ID]||zi(e,"phoneNumber",null),Oh(e)}):Oh(e).then(function(){throw new N("no-such-provider")})}))},n.delete=function(){var t=this;return Xh(this,this.I().then(function(e){return iu(t.a,_s,{idToken:e})}).then(function(){t.dispatchEvent(new ch("userDeleted"))})).then(function(){for(var e=0;e<t.N.length;e++)t.N[e].cancel("app-deleted");Ih(t,null),Th(t,null),Ah(t,null),t.N=[],t.J=!0,Nh(t),zi(t,"refreshToken",null),t.b&&xc(t.b,t)})},n.Gb=function(t,e){return!!("linkViaPopup"==t&&(this.g||null)==e&&this.f||"reauthViaPopup"==t&&(this.g||null)==e&&this.f||"linkViaRedirect"==t&&(this.ga||null)==e||"reauthViaRedirect"==t&&(this.ga||null)==e)},n.na=function(t,e,n,i){"linkViaPopup"!=t&&"reauthViaPopup"!=t||i!=(this.g||null)||(n&&this.C?this.C(n):e&&!n&&this.f&&this.f(e),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.C)},n.Fa=function(t,e){return"linkViaPopup"==t&&e==(this.g||null)?T(this.Lb,this):"reauthViaPopup"==t&&e==(this.g||null)?T(this.Mb,this):"linkViaRedirect"==t&&(this.ga||null)==e?T(this.Lb,this):"reauthViaRedirect"==t&&(this.ga||null)==e?T(this.Mb,this):null},n.Ec=function(t){var e=this;return Gh(this,"linkViaPopup",t,function(){return qh(e,t.providerId).then(function(){return Oh(e)})},!1)},n.Nc=function(t){return Gh(this,"reauthViaPopup",t,function(){return Ce()},!0)},n.Fc=function(t){var e=this;return Bh(this,"linkViaRedirect",t,function(){return qh(e,t.providerId)},!1)},n.Oc=function(t){return Bh(this,"reauthViaRedirect",t,function(){return Ce()},!0)},n.Lb=function(t,e,n,i){var r=this;this.c&&(this.c.cancel(),this.c=null);var o=null;return Xh(this,this.I().then(function(n){return Is(r.a,{requestUri:t,postBody:i,sessionId:e,idToken:n})}).then(function(t){return o=Kh(r,t,"link"),Hh(r,t)}).then(function(){return o}))},n.Mb=function(t,e,n,i){var r=this;this.c&&(this.c.cancel(),this.c=null);var o=null;return Xh(this,Ce().then(function(){return ho(Ts(r.a,{requestUri:t,sessionId:e,postBody:i,tenantId:n}),r.uid)}).then(function(t){return o=Kh(r,t,"reauthenticate"),Fh(r,t),r.i=null,r.reload()}).then(function(){return o}),!0)},n.vb=function(t){var e=this,n=null;return Xh(this,this.I().then(function(e){return n=e,void 0===t||vt(t)?{}:Fr(new Cr(t))}).then(function(t){return e.a.vb(n,t)}).then(function(t){if(e.email!=t)return e.reload()}).then(function(){}))},n.Fb=function(t,e){var n=this,i=null;return Xh(this,this.I().then(function(t){return i=t,void 0===e||vt(e)?{}:Fr(new Cr(e))}).then(function(e){return n.a.Fb(i,t,e)}).then(function(t){if(n.email!=t)return n.reload()}).then(function(){}))},n.jc=function(t){var e=null,n=this;return Xh(this,t=ho(Ce(t),n.uid).then(function(t){return e=Kh(n,t,"reauthenticate"),Fh(n,t),n.i=null,n.reload()}).then(function(){return e}),!0)},n.toJSON=function(){return this.w()},n.w=function(){var t={uid:this.uid,displayName:this.displayName,photoURL:this.photoURL,email:this.email,emailVerified:this.emailVerified,phoneNumber:this.phoneNumber,isAnonymous:this.isAnonymous,tenantId:this.tenantId,providerData:[],apiKey:this.l,appName:this.m,authDomain:this.s,stsTokenManager:this.h.w(),redirectEventId:this.ga||null};return this.metadata&&bt(t,this.metadata.w()),B(this.providerData,function(e){t.providerData.push(function(t){var e,n={};for(e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n}(e))}),bt(t,this.S.w()),t};var zh={name:"redirectUser",F:"session"};function $h(t){return rc(t.b,zh,t.a)}function Zh(t){this.a=t,this.b=ec(),this.c=null,this.f=function(t){var e=el("local"),n=el("session"),i=el("none");return function(t,e,n){var i=ic(e,n),r=nc(t,e.F);return t.get(e,n).then(function(o){var a=null;try{a=Ui(u.localStorage.getItem(i))}catch(s){}if(a&&!o)return u.localStorage.removeItem(i),t.set(e,a,n);a&&o&&"localStorage"!=r.type&&u.localStorage.removeItem(i)})}(t.b,e,t.a).then(function(){return t.b.get(n,t.a)}).then(function(r){return r?n:t.b.get(i,t.a).then(function(n){return n?i:t.b.get(e,t.a).then(function(n){return n?e:t.b.get(tl,t.a).then(function(t){return t?el(t):e})})})}).then(function(e){return t.c=e,Qh(t,e.F)}).o(function(){t.c||(t.c=e)})}(this),this.b.addListener(el("local"),this.a,T(this.g,this))}function Qh(t,e){var n,i=[];for(n in Qu)Qu[n]!==e&&i.push(rc(t.b,el(Qu[n]),t.a));return i.push(rc(t.b,tl,t.a)),function(t){return new Ee(function(e,n){var i=t.length,r=[];if(i)for(var o=function(t,n){i--,r[t]=n,0==i&&e(r)},a=function(t){n(t)},s=0;s<t.length;s++)Pe(t[s],E(o,s),a);else e(r)})}(i)}Zh.prototype.g=function(){var t=this,e=el("local");ol(this,function(){return Ce().then(function(){return t.c&&"local"!=t.c.F?t.b.get(e,t.a):null}).then(function(n){if(n)return Qh(t,"local").then(function(){t.c=e})})})};var tl={name:"persistence",F:"session"};function el(t){return{name:"authUser",F:t}}function nl(t,e){return ol(t,function(){return t.b.set(t.c,e.w(),t.a)})}function il(t){return ol(t,function(){return rc(t.b,t.c,t.a)})}function rl(t,e,n){return ol(t,function(){return t.b.get(t.c,t.a).then(function(t){return t&&e&&(t.authDomain=e),t&&n&&(t.emulatorConfig=n),Jh(t||{})})})}function ol(t,e){return t.f=t.f.then(e,e),t.f}function al(t){if(this.l=!1,zi(this,"settings",new $c),zi(this,"app",t),!vl(this).options||!vl(this).options.apiKey)throw new N("invalid-api-key");t=e.default.SDK_VERSION?_i(e.default.SDK_VERSION):null,this.a=new za(vl(this).options&&vl(this).options.apiKey,D(O),t),this.P=[],this.s=[],this.N=[],this.Pa=e.default.INTERNAL.createSubscribe(T(this.zc,this)),this.W=void 0,this.ib=e.default.INTERNAL.createSubscribe(T(this.Ac,this)),dl(this,null),this.i=new Zh(vl(this).options.apiKey+":"+vl(this).name),this.D=new Yh(vl(this).options.apiKey+":"+vl(this).name),this.$=yl(this,function(t){var e=vl(t).options.authDomain,n=function(t){var e=function(t,e){return t.b.get(zh,t.a).then(function(t){return t&&e&&(t.authDomain=e),Jh(t||{})})}(t.D,vl(t).options.authDomain).then(function(e){return(t.m=e)&&(e.ha=t.D),$h(t.D)});return yl(t,e)}(t).then(function(){return rl(t.i,e,t.R)}).then(function(e){return e?(e.ha=t.D,t.m&&(t.m.ga||null)==(e.ga||null)?e:e.reload().then(function(){return nl(t.i,e).then(function(){return e})}).o(function(n){return"auth/network-request-failed"==n.code?e:il(t.i)})):null}).then(function(e){dl(t,e||null)});return yl(t,n)}(this)),this.h=yl(this,function(t){return t.$.then(function(){return ll(t)}).o(function(){}).then(function(){if(!t.l)return t.ja()}).o(function(){}).then(function(){if(!t.l){t.ba=!0;var e=t.i;e.b.addListener(el("local"),e.a,t.ja)}})}(this)),this.ba=!1,this.ja=T(this.Zc,this),this.Ba=T(this.da,this),this.qa=T(this.mc,this),this.za=T(this.wc,this),this.Aa=T(this.xc,this),this.b=null,function(t){var e=vl(t).options.authDomain,n=vl(t).options.apiKey;e&&Pi()&&(t.Oa=t.$.then(function(){if(!t.l){if(t.b=Gc(e,n,vl(t).name,t.R),Lc(t.b,t),ml(t)&&Ch(ml(t)),t.m){Ch(t.m);var i=t.m;i.xa(t.la()),Ih(i,t),Eh(i=t.m,t.J),Ah(i,t),wh(i=t.m,t.R),Th(i,t),t.m=null}return t.b}}))}(this),this.INTERNAL={},this.INTERNAL.delete=T(this.delete,this),this.INTERNAL.logFramework=T(this.Gc,this),this.u=0,En.call(this),function(t){Object.defineProperty(t,"lc",{get:function(){return this.la()},set:function(t){this.xa(t)},enumerable:!1}),t.aa=null,Object.defineProperty(t,"ti",{get:function(){return this.T()},set:function(t){this.zb(t)},enumerable:!1}),t.S=null,Object.defineProperty(t,"emulatorConfig",{get:function(){if(this.R){var t=qn(this.R.url);t=Zi({protocol:t.c,host:t.a,port:t.g,options:Zi({disableWarnings:this.R.ec})})}else t=null;return t},enumerable:!1})}(this),this.J=[],this.R=null}function sl(t){Ze.call(this,"languageCodeChanged"),this.h=t}function ul(t){Ze.call(this,"emulatorConfigChanged"),this.c=t}function cl(t){Ze.call(this,"frameworkChanged"),this.f=t}function hl(t){return t.Oa||Re(new N("auth-domain-config-required"))}function ll(t){if(!Pi())return Re(new N("operation-not-supported-in-this-environment"));var e=hl(t).then(function(){return t.b.ra()}).then(function(t){return t?Zi(t):null});return yl(t,e)}function fl(t,e){var n={};return n.apiKey=vl(t).options.apiKey,n.authDomain=vl(t).options.authDomain,n.appName=vl(t).name,t.R&&(n.emulatorConfig=t.R),t.$.then(function(){return function(t,e,n,i){var r=new yh(t,e);return n&&(r.ha=n),i&&Eh(r,i),r.reload().then(function(){return r})}(n,e,t.D,t.Ga())}).then(function(e){return ml(t)&&e.uid==ml(t).uid?(Uh(ml(t),e),t.da(e)):(dl(t,e),Ch(e),t.da(e))}).then(function(){bl(t)})}function dl(t,e){ml(t)&&(function(t,e){$(t.W,function(t){return t==e})}(ml(t),t.Ba),pn(ml(t),"tokenChanged",t.qa),pn(ml(t),"userDeleted",t.za),pn(ml(t),"userInvalidated",t.Aa),Nh(ml(t))),e&&(e.W.push(t.Ba),ln(e,"tokenChanged",t.qa),ln(e,"userDeleted",t.za),ln(e,"userInvalidated",t.Aa),0<t.u&&Sh(e)),zi(t,"currentUser",e),e&&(e.xa(t.la()),Ih(e,t),Eh(e,t.J),Ah(e,t),wh(e,t.R),Th(e,t))}function pl(t,e){var n=null,i=null;return yl(t,e.then(function(e){return n=Vo(e),i=zr(e),fl(t,e)},function(e){var n=null;throw e&&"auth/multi-factor-auth-required"===e.code&&(n=oh(e.w(),t,T(t.kc,t))),n||e}).then(function(){return Zi({user:ml(t),credential:n,additionalUserInfo:i,operationType:"signIn"})}))}function vl(t){return t.app}function ml(t){return t.currentUser}function gl(t){return ml(t)&&ml(t)._lat||null}function bl(t){if(t.ba){for(var e=0;e<t.s.length;e++)t.s[e]&&t.s[e](gl(t));if(t.W!==t.getUid()&&t.N.length)for(t.W=t.getUid(),e=0;e<t.N.length;e++)t.N[e]&&t.N[e](gl(t))}}function yl(t,e){return t.P.push(e),e.oa(function(){z(t.P,e)}),e}function wl(){}function Il(){this.a={},this.b=1e12}Zh.prototype.yb=function(t){var e=null,n=this;return function(t){var e=new N("invalid-persistence-type"),n=new N("unsupported-persistence-type");t:{for(i in Qu)if(Qu[i]==t){var i=!0;break t}i=!1}if(!i||"string"!=typeof t)throw e;switch(Ti()){case"ReactNative":if("session"===t)throw n;break;case"Node":if("none"!==t)throw n;break;case"Worker":if("session"===t||!Pu()&&"none"!==t)throw n;break;default:if(!Ri()&&"none"!==t)throw n}}(t),ol(this,function(){return t!=n.c.F?n.b.get(n.c,n.a).then(function(i){return e=i,Qh(n,t)}).then(function(){if(n.c=el(t),e)return n.b.set(n.c,e,n.a)}):Ce()})},k(al,En),k(sl,Ze),k(ul,Ze),k(cl,Ze),(n=al.prototype).yb=function(t){return yl(this,t=this.i.yb(t))},n.xa=function(t){this.aa===t||this.l||(this.aa=t,is(this.a,this.aa),this.dispatchEvent(new sl(this.la())))},n.la=function(){return this.aa},n.fd=function(){var t=u.navigator;this.xa(t&&(t.languages&&t.languages[0]||t.language||t.userLanguage)||null)},n.gd=function(t,e){if(!this.R){if(!/^https?:\/\//.test(t))throw new N("argument-error","Emulator URL must start with a valid scheme (http:// or https://).");(function(t){"undefined"!=typeof console&&"function"==typeof console.info&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),u.document&&!t&&bi().then(function(){var t=u.document.createElement("div");t.innerText="Running in emulator mode. Do not use with production credentials.",t.style.position="fixed",t.style.width="100%",t.style.backgroundColor="#ffffff",t.style.border=".1em solid #000000",t.style.color="#b50000",t.style.bottom="0px",t.style.left="0px",t.style.margin="0px",t.style.zIndex=1e4,t.style.textAlign="center",t.classList.add("firebase-emulator-warning"),u.document.body.appendChild(t)})})(e=!!e&&!!e.disableWarnings),this.R={url:t,ec:e},this.settings.jb=!0,rs(this.a,this.R),this.dispatchEvent(new ul(this.R))}},n.Gc=function(t){this.J.push(t),as(this.a,e.default.SDK_VERSION?_i(e.default.SDK_VERSION,this.J):null),this.dispatchEvent(new cl(this.J))},n.Ga=function(){return Q(this.J)},n.zb=function(t){this.S===t||this.l||(this.S=t,this.a.b=this.S)},n.T=function(){return this.S},n.toJSON=function(){return{apiKey:vl(this).options.apiKey,authDomain:vl(this).options.authDomain,appName:vl(this).name,currentUser:ml(this)&&ml(this).w()}},n.Gb=function(t,e){switch(t){case"unknown":case"signInViaRedirect":return!0;case"signInViaPopup":return this.g==e&&!!this.f;default:return!1}},n.na=function(t,e,n,i){"signInViaPopup"==t&&this.g==i&&(n&&this.C?this.C(n):e&&!n&&this.f&&this.f(e),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.C)},n.Fa=function(t,e){return"signInViaRedirect"==t||"signInViaPopup"==t&&this.g==e&&this.f?T(this.ic,this):null},n.ic=function(t,e,n,i){var r=this,o={requestUri:t,postBody:i,sessionId:e,tenantId:n};return this.c&&(this.c.cancel(),this.c=null),r.$.then(function(){return pl(r,ws(r.a,o))})},n.Xc=function(t){if(!Pi())return Re(new N("operation-not-supported-in-this-environment"));var n=this,i=Yr(t.providerId),r=Vi(),o=null;(!xi()||wi())&&vl(this).options.authDomain&&t.isOAuthProvider&&(o=bu(vl(this).options.authDomain,vl(this).options.apiKey,vl(this).name,"signInViaPopup",t,null,r,e.default.SDK_VERSION||null,null,null,this.T(),this.R));var a=vi(o,i&&i.va,i&&i.ua);return yl(this,i=hl(this).then(function(e){return Uc(e,a,"signInViaPopup",t,r,!!o,n.T())}).then(function(){return new Ee(function(t,e){n.na("signInViaPopup",null,new N("cancelled-popup-request"),n.g),n.f=t,n.C=e,n.g=r,n.c=qc(n.b,n,"signInViaPopup",a,r)})}).then(function(t){return a&&pi(a),t?Zi(t):null}).o(function(t){throw a&&pi(a),t}))},n.Yc=function(t){if(!Pi())return Re(new N("operation-not-supported-in-this-environment"));var e=this;return yl(this,hl(this).then(function(){return ol(t=e.i,function(){return t.b.set(tl,t.c.F,t.a)});var t}).then(function(){return Fc(e.b,"signInViaRedirect",t,void 0,e.T())}))},n.ra=function(){var t=this;return ll(this).then(function(e){return t.b&&Xc(t.b.b),e}).o(function(e){throw t.b&&Xc(t.b.b),e})},n.dd=function(t){if(!t)return Re(new N("null-user"));if(this.S!=t.tenantId)return Re(new N("tenant-id-mismatch"));var e=this,n={};n.apiKey=vl(this).options.apiKey,n.authDomain=vl(this).options.authDomain,n.appName=vl(this).name;var i=function(t,e,n,i){var r=t.h,o={};return o[Za]=r.b&&r.b.toString(),o.refreshToken=r.a,e=new yh(e||{apiKey:t.l,authDomain:t.s,appName:t.m},o),n&&(e.ha=n),i&&Eh(e,i),Uh(e,t),e}(t,n,e.D,e.Ga());return yl(this,this.h.then(function(){if(vl(e).options.apiKey!=t.l)return i.reload()}).then(function(){return ml(e)&&t.uid==ml(e).uid?(Uh(ml(e),t),e.da(t)):(dl(e,i),Ch(i),e.da(i))}).then(function(){bl(e)}))},n.Bb=function(){var t=this;return yl(this,this.h.then(function(){return t.b&&Xc(t.b.b),ml(t)?(dl(t,null),il(t.i).then(function(){bl(t)})):Ce()}))},n.Zc=function(){var t=this;return rl(this.i,vl(this).options.authDomain).then(function(e){if(!t.l){var n;if(n=ml(t)&&e){n=ml(t).uid;var i=e.uid;n=null!=n&&""!==n&&null!=i&&""!==i&&n==i}if(n)return Uh(ml(t),e),ml(t).I();(ml(t)||e)&&(dl(t,e),e&&(Ch(e),e.ha=t.D),t.b&&Lc(t.b,t),bl(t))}})},n.da=function(t){return nl(this.i,t)},n.mc=function(){bl(this),this.da(ml(this))},n.wc=function(){this.Bb()},n.xc=function(){this.Bb()},n.kc=function(t){var e=this;return this.h.then(function(){return pl(e,Ce(t))})},n.zc=function(t){var e=this;this.addAuthTokenListener(function(){t.next(ml(e))})},n.Ac=function(t){var e=this;!function(t,e){t.N.push(e),yl(t,t.h.then(function(){!t.l&&Y(t.N,e)&&t.W!==t.getUid()&&(t.W=t.getUid(),e(gl(t)))}))}(this,function(){t.next(ml(e))})},n.Ic=function(t,e,n){var i=this;return this.ba&&Promise.resolve().then(function(){"function"==typeof t?t(ml(i)):"function"==typeof t.next&&t.next(ml(i))}),this.Pa(t,e,n)},n.Hc=function(t,e,n){var i=this;return this.ba&&Promise.resolve().then(function(){i.W=i.getUid(),"function"==typeof t?t(ml(i)):"function"==typeof t.next&&t.next(ml(i))}),this.ib(t,e,n)},n.nc=function(t){var e=this;return yl(this,this.h.then(function(){return ml(e)?ml(e).I(t).then(function(t){return{accessToken:t}}):null}))},n.Tc=function(t){var e=this;return this.h.then(function(){return pl(e,iu(e.a,$s,{token:t}))}).then(function(t){var n=t.user;return jh(n,"isAnonymous",!1),e.da(n),t})},n.Uc=function(t,e){var n=this;return this.h.then(function(){return pl(n,iu(n.a,Zs,{email:t,password:e}))})},n.dc=function(t,e){var n=this;return this.h.then(function(){return pl(n,iu(n.a,Ss,{email:t,password:e}))})},n.ab=function(t){var e=this;return this.h.then(function(){return pl(e,t.ka(e.a))})},n.Sc=function(t){return Ji("firebase.auth.Auth.prototype.signInAndRetrieveDataWithCredential is deprecated. Please use firebase.auth.Auth.prototype.signInWithCredential instead."),this.ab(t)},n.Ab=function(){var t=this;return this.h.then(function(){var e=ml(t);if(e&&e.isAnonymous){var n=Zi({providerId:null,isNewUser:!1});return Zi({user:e,credential:null,additionalUserInfo:n,operationType:"signIn"})}return pl(t,t.a.Ab()).then(function(e){var n=e.user;return jh(n,"isAnonymous",!0),t.da(n),e})})},n.getUid=function(){return ml(this)&&ml(this).uid||null},n.cc=function(t){this.addAuthTokenListener(t),this.u++,0<this.u&&ml(this)&&Sh(ml(this))},n.Pc=function(t){var e=this;B(this.s,function(n){n==t&&e.u--}),0>this.u&&(this.u=0),0==this.u&&ml(this)&&Nh(ml(this)),this.removeAuthTokenListener(t)},n.addAuthTokenListener=function(t){var e=this;this.s.push(t),yl(this,this.h.then(function(){e.l||Y(e.s,t)&&t(gl(e))}))},n.removeAuthTokenListener=function(t){$(this.s,function(e){return e==t})},n.delete=function(){this.l=!0;for(var t=0;t<this.P.length;t++)this.P[t].cancel("app-deleted");return this.P=[],this.i&&(t=this.i).b.removeListener(el("local"),t.a,this.ja),this.b&&(xc(this.b,this),Xc(this.b.b)),Promise.resolve()},n.hc=function(t){return yl(this,function(t,e){return iu(t,Ns,{identifier:e,continueUri:Di()?li():"http://localhost"}).then(function(t){return t.signinMethods||[]})}(this.a,t))},n.Bc=function(t){return!!Do(t)},n.xb=function(t,e){var n=this;return yl(this,Ce().then(function(){var t=new Cr(e);if(!t.c)throw new N("argument-error",Dr+" must be true when sending sign in link to email");return Fr(t)}).then(function(e){return n.a.xb(t,e)}).then(function(){}))},n.jd=function(t){return this.Sa(t).then(function(t){return t.data.email})},n.ob=function(t,e){return yl(this,this.a.ob(t,e).then(function(){}))},n.Sa=function(t){return yl(this,this.a.Sa(t).then(function(t){return new sr(t)}))},n.kb=function(t){return yl(this,this.a.kb(t).then(function(){}))},n.wb=function(t,e){var n=this;return yl(this,Ce().then(function(){return void 0===e||vt(e)?{}:Fr(new Cr(e))}).then(function(e){return n.a.wb(t,e)}).then(function(){}))},n.Wc=function(t,e){return yl(this,Qc(this,t,e,T(this.ab,this)))},n.Vc=function(t,e){var n=this;return yl(this,Ce().then(function(){var i=e||li(),r=Po(t,i);if(!(i=Do(i)))throw new N("argument-error","Invalid email link!");if(i.tenantId!==n.T())throw new N("tenant-id-mismatch");return n.ab(r)}))},wl.prototype.render=function(){},wl.prototype.reset=function(){},wl.prototype.getResponse=function(){},wl.prototype.execute=function(){};var Tl=null;function El(t,e){return(e=Al(e))&&t.a[e]||null}function Al(t){return(t=void 0===t?1e12:t)?t.toString():null}function kl(t,e){this.g=!1,this.c=e,this.a=this.b=null,this.h="invisible"!==this.c.size,this.f=le(t);var n=this;this.i=function(){n.execute()},this.h?this.execute():ln(this.f,"click",this.i)}function Sl(t){if(t.g)throw Error("reCAPTCHA mock was already deleted!")}function Nl(){}function _l(){}Il.prototype.render=function(t,e){return this.a[this.b.toString()]=new kl(t,e),this.b++},Il.prototype.reset=function(t){var e=El(this,t);t=Al(t),e&&t&&(e.delete(),delete this.a[t])},Il.prototype.getResponse=function(t){return(t=El(this,t))?t.getResponse():null},Il.prototype.execute=function(t){(t=El(this,t))&&t.execute()},kl.prototype.getResponse=function(){return Sl(this),this.b},kl.prototype.execute=function(){Sl(this);var t=this;this.a||(this.a=setTimeout(function(){t.b=function(){for(var t=50,e=[];0<t;)e.push("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(62*Math.random()))),t--;return e.join("")}();var e=t.c.callback,n=t.c["expired-callback"];if(e)try{e(t.b)}catch(i){}t.a=setTimeout(function(){if(t.a=null,t.b=null,n)try{n()}catch(i){}t.h&&t.execute()},6e4)},500))},kl.prototype.delete=function(){Sl(this),this.g=!0,clearTimeout(this.a),this.a=null,pn(this.f,"click",this.i)},zi(Nl,"FACTOR_ID","phone"),_l.prototype.g=function(){return Tl||(Tl=new Il),Ce(Tl)},_l.prototype.c=function(){};var Ol=null;function Cl(){this.b=u.grecaptcha?1/0:0,this.f=null,this.a="__rcb"+Math.floor(1e6*Math.random()).toString()}var Rl=new wt(At,"https://www.google.com/recaptcha/api.js?onload=%{onload}&render=explicit&hl=%{hl}"),Pl=new Ki(3e4,6e4);Cl.prototype.g=function(t){var e=this;return new Ee(function(n,i){var r=setTimeout(function(){i(new N("network-request-failed"))},Pl.get());!u.grecaptcha||t!==e.f&&!e.b?(u[e.a]=function(){if(u.grecaptcha){e.f=t;var o=u.grecaptcha.render;u.grecaptcha.render=function(t,n){return t=o(t,n),e.b++,t},clearTimeout(r),n(u.grecaptcha)}else clearTimeout(r),i(new N("internal-error"));delete u[e.a]},Ce(Ha(_t(Rl,{onload:e.a,hl:t||""}))).o(function(){clearTimeout(r),i(new N("internal-error","Unable to load external reCAPTCHA dependencies!"))})):(clearTimeout(r),n(u.grecaptcha))})},Cl.prototype.c=function(){this.b--};var Dl=null;function Ll(t,e,n,i,r,o,a){if(zi(this,"type","recaptcha"),this.c=this.f=null,this.J=!1,this.v=e,this.g=null,a?(Ol||(Ol=new _l),a=Ol):(Dl||(Dl=new Cl),a=Dl),this.m=a,this.a=n||{theme:"light",type:"image"},this.h=[],this.a[jl])throw new N("argument-error","sitekey should not be provided for reCAPTCHA as one is automatically provisioned for the current project.");if(this.i="invisible"===this.a[Ul],!u.document)throw new N("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment with DOM support.");if(!le(e)||!this.i&&le(e).hasChildNodes())throw new N("argument-error","reCAPTCHA container is either not found or already contains inner elements!");this.s=new za(t,o||null,r||null),this.u=i||function(){return null};var s=this;this.l=[];var c=this.a[xl];this.a[xl]=function(t){if(Vl(s,t),"function"==typeof c)c(t);else if("string"==typeof c){var e=Ci(c,u);"function"==typeof e&&e(t)}};var h=this.a[Ml];this.a[Ml]=function(){if(Vl(s,null),"function"==typeof h)h();else if("string"==typeof h){var t=Ci(h,u);"function"==typeof t&&t()}}}var xl="callback",Ml="expired-callback",jl="sitekey",Ul="size";function Vl(t,e){for(var n=0;n<t.l.length;n++)try{t.l[n](e)}catch(i){}}function Fl(t,e){return t.h.push(e),e.oa(function(){z(t.h,e)}),e}function ql(t){if(t.J)throw new N("internal-error","RecaptchaVerifier instance has been destroyed.")}function Kl(t,n,i){var r=!1;try{this.b=i||e.default.app()}catch(s){throw new N("argument-error","No firebase.app.App instance is currently initialized.")}if(!this.b.options||!this.b.options.apiKey)throw new N("invalid-api-key");i=this.b.options.apiKey;var o=this,a=null;try{a=this.b.auth().Ga()}catch(s){}try{r=this.b.auth().settings.appVerificationDisabledForTesting}catch(s){}a=e.default.SDK_VERSION?_i(e.default.SDK_VERSION,a):null,Ll.call(this,i,t,n,function(){try{var t=o.b.auth().la()}catch(e){t=null}return t},a,D(O),r)}function Hl(t,e,n,i){t:{n=Array.prototype.slice.call(n);for(var r=0,o=!1,a=0;a<e.length;a++)if(e[a].optional)o=!0;else{if(o)throw new N("internal-error","Argument validator encountered a required argument after an optional argument.");r++}if(o=e.length,n.length<r||o<n.length)i="Expected "+(r==o?1==r?"1 argument":r+" arguments":r+"-"+o+" arguments")+" but got "+n.length+".";else{for(r=0;r<n.length;r++)if(o=e[r].optional&&void 0===n[r],!e[r].M(n[r])&&!o){if(e=e[r],0>r||r>=Gl.length)throw new N("internal-error","Argument validator received an unsupported number of arguments.");n=Gl[r],i=(i?"":n+" argument ")+(e.name?'"'+e.name+'" ':"")+"must be "+e.K+".";break t}i=null}}if(i)throw new N("argument-error",t+" failed: "+i)}(n=Ll.prototype).Ia=function(){var t=this;return this.f?this.f:this.f=Fl(this,Ce().then(function(){if(Di()&&!Ii())return bi();throw new N("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment.")}).then(function(){return t.m.g(t.u())}).then(function(e){return t.g=e,iu(t.s,Fs,{})}).then(function(e){t.a[jl]=e.recaptchaSiteKey}).o(function(e){throw t.f=null,e}))},n.render=function(){ql(this);var t=this;return Fl(this,this.Ia().then(function(){if(null===t.c){var e=t.v;if(!t.i){var n=le(e);e=me("DIV"),n.appendChild(e)}t.c=t.g.render(e,t.a)}return t.c}))},n.verify=function(){ql(this);var t=this;return Fl(this,this.render().then(function(e){return new Ee(function(n){var i=t.g.getResponse(e);if(i)n(i);else{var r=function(e){e&&(function(t,e){$(t.l,function(t){return t==e})}(t,r),n(e))};t.l.push(r),t.i&&t.g.execute(t.c)}})}))},n.reset=function(){ql(this),null!==this.c&&this.g.reset(this.c)},n.clear=function(){ql(this),this.J=!0,this.m.c();for(var t=0;t<this.h.length;t++)this.h[t].cancel("RecaptchaVerifier instance has been destroyed.");if(!this.i){t=le(this.v);for(var e;e=t.firstChild;)t.removeChild(e)}},k(Kl,Ll);var Gl="First Second Third Fourth Fifth Sixth Seventh Eighth Ninth".split(" ");function Bl(t,e){return{name:t||"",K:"a valid string",optional:!!e,M:function(t){return"string"==typeof t}}}function Wl(t,e){return{name:t||"",K:"a boolean",optional:!!e,M:function(t){return"boolean"==typeof t}}}function Xl(t,e){return{name:t||"",K:"a valid object",optional:!!e,M:m}}function Jl(t,e){return{name:t||"",K:"a function",optional:!!e,M:function(t){return"function"==typeof t}}}function Yl(t,e){return{name:t||"",K:"null",optional:!!e,M:function(t){return null===t}}}function zl(t){return{name:t?t+"Credential":"credential",K:t?"a valid "+t+" credential":"a valid credential",optional:!1,M:function(e){if(!e)return!1;var n=!t||e.providerId===t;return!(!e.ka||!n)}}}function $l(t,e){return m(t)&&"string"==typeof t.type&&t.type===e&&"function"==typeof t.Ha}function Zl(t){return m(t)&&"string"==typeof t.uid}function Ql(t,e,n,i){return{name:n||"",K:t.K+" or "+e.K,optional:!!i,M:function(n){return t.M(n)||e.M(n)}}}function tf(t,e){for(var n in e){var i=e[n].name;t[i]=rf(i,t[n],e[n].j)}}function ef(t,e){for(var n in e){var i=e[n].name;i!==n&&Object.defineProperty(t,i,{get:E(function(t){return this[t]},n),set:E(function(t,e,n,i){Hl(t,[n],[i],!0),this[e]=i},i,n,e[n].lb),enumerable:!0})}}function nf(t,e,n,i){t[e]=rf(e,n,i)}function rf(t,e,n){function i(){var t=Array.prototype.slice.call(arguments);return Hl(o,n,t),e.apply(this,t)}if(!n)return e;var r,o=function(t){return(t=t.split("."))[t.length-1]}(t);for(r in e)i[r]=e[r];for(r in e.prototype)i.prototype[r]=e.prototype[r];return i}tf(al.prototype,{kb:{name:"applyActionCode",j:[Bl("code")]},Sa:{name:"checkActionCode",j:[Bl("code")]},ob:{name:"confirmPasswordReset",j:[Bl("code"),Bl("newPassword")]},dc:{name:"createUserWithEmailAndPassword",j:[Bl("email"),Bl("password")]},hc:{name:"fetchSignInMethodsForEmail",j:[Bl("email")]},ra:{name:"getRedirectResult",j:[]},Bc:{name:"isSignInWithEmailLink",j:[Bl("emailLink")]},Hc:{name:"onAuthStateChanged",j:[Ql(Xl(),Jl(),"nextOrObserver"),Jl("opt_error",!0),Jl("opt_completed",!0)]},Ic:{name:"onIdTokenChanged",j:[Ql(Xl(),Jl(),"nextOrObserver"),Jl("opt_error",!0),Jl("opt_completed",!0)]},wb:{name:"sendPasswordResetEmail",j:[Bl("email"),Ql(Xl("opt_actionCodeSettings",!0),Yl(null,!0),"opt_actionCodeSettings",!0)]},xb:{name:"sendSignInLinkToEmail",j:[Bl("email"),Xl("actionCodeSettings")]},yb:{name:"setPersistence",j:[Bl("persistence")]},Sc:{name:"signInAndRetrieveDataWithCredential",j:[zl()]},Ab:{name:"signInAnonymously",j:[]},ab:{name:"signInWithCredential",j:[zl()]},Tc:{name:"signInWithCustomToken",j:[Bl("token")]},Uc:{name:"signInWithEmailAndPassword",j:[Bl("email"),Bl("password")]},Vc:{name:"signInWithEmailLink",j:[Bl("email"),Bl("emailLink",!0)]},Wc:{name:"signInWithPhoneNumber",j:[Bl("phoneNumber"),{name:"applicationVerifier",K:"an implementation of firebase.auth.ApplicationVerifier",optional:!1,M:function(t){return!(!t||"string"!=typeof t.type||"function"!=typeof t.verify)}}]},Xc:{name:"signInWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Yc:{name:"signInWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},dd:{name:"updateCurrentUser",j:[Ql({name:"user",K:"an instance of Firebase User",optional:!1,M:function(t){return!!(t&&t instanceof yh)}},Yl(),"user")]},Bb:{name:"signOut",j:[]},toJSON:{name:"toJSON",j:[Bl(null,!0)]},fd:{name:"useDeviceLanguage",j:[]},gd:{name:"useEmulator",j:[Bl("url"),Xl("options",!0)]},jd:{name:"verifyPasswordResetCode",j:[Bl("code")]}}),ef(al.prototype,{lc:{name:"languageCode",lb:Ql(Bl(),Yl(),"languageCode")},ti:{name:"tenantId",lb:Ql(Bl(),Yl(),"tenantId")}}),al.Persistence=Qu,al.Persistence.LOCAL="local",al.Persistence.SESSION="session",al.Persistence.NONE="none",tf(yh.prototype,{delete:{name:"delete",j:[]},oc:{name:"getIdTokenResult",j:[Wl("opt_forceRefresh",!0)]},I:{name:"getIdToken",j:[Wl("opt_forceRefresh",!0)]},Cc:{name:"linkAndRetrieveDataWithCredential",j:[zl()]},rb:{name:"linkWithCredential",j:[zl()]},Dc:{name:"linkWithPhoneNumber",j:[Bl("phoneNumber"),{name:"applicationVerifier",K:"an implementation of firebase.auth.ApplicationVerifier",optional:!1,M:function(t){return!(!t||"string"!=typeof t.type||"function"!=typeof t.verify)}}]},Ec:{name:"linkWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Fc:{name:"linkWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Lc:{name:"reauthenticateAndRetrieveDataWithCredential",j:[zl()]},ub:{name:"reauthenticateWithCredential",j:[zl()]},Mc:{name:"reauthenticateWithPhoneNumber",j:[Bl("phoneNumber"),{name:"applicationVerifier",K:"an implementation of firebase.auth.ApplicationVerifier",optional:!1,M:function(t){return!(!t||"string"!=typeof t.type||"function"!=typeof t.verify)}}]},Nc:{name:"reauthenticateWithPopup",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Oc:{name:"reauthenticateWithRedirect",j:[{name:"authProvider",K:"a valid Auth provider",optional:!1,M:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},reload:{name:"reload",j:[]},vb:{name:"sendEmailVerification",j:[Ql(Xl("opt_actionCodeSettings",!0),Yl(null,!0),"opt_actionCodeSettings",!0)]},toJSON:{name:"toJSON",j:[Bl(null,!0)]},cd:{name:"unlink",j:[Bl("provider")]},Cb:{name:"updateEmail",j:[Bl("email")]},Db:{name:"updatePassword",j:[Bl("password")]},ed:{name:"updatePhoneNumber",j:[zl("phone")]},Eb:{name:"updateProfile",j:[Xl("profile")]},Fb:{name:"verifyBeforeUpdateEmail",j:[Bl("email"),Ql(Xl("opt_actionCodeSettings",!0),Yl(null,!0),"opt_actionCodeSettings",!0)]}}),tf(Il.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),tf(wl.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),tf(Ee.prototype,{oa:{name:"finally"},o:{name:"catch"},then:{name:"then"}}),ef($c.prototype,{appVerificationDisabled:{name:"appVerificationDisabledForTesting",lb:Wl("appVerificationDisabledForTesting")}}),tf(Zc.prototype,{confirm:{name:"confirm",j:[Bl("verificationCode")]}}),nf(co,"fromJSON",function(t){t="string"==typeof t?JSON.parse(t):t;for(var e,n=[go,Co,xo,po],i=0;i<n.length;i++)if(e=n[i](t))return e;return null},[Ql(Bl(),Xl(),"json")]),nf(Ro,"credential",function(t,e){return new Oo(t,e)},[Bl("email"),Bl("password")]),tf(Oo.prototype,{w:{name:"toJSON",j:[Bl(null,!0)]}}),tf(Io.prototype,{Ca:{name:"addScope",j:[Bl("scope")]},Ka:{name:"setCustomParameters",j:[Xl("customOAuthParameters")]}}),nf(Io,"credential",To,[Ql(Bl(),Xl(),"token")]),nf(Ro,"credentialWithLink",Po,[Bl("email"),Bl("emailLink")]),tf(Eo.prototype,{Ca:{name:"addScope",j:[Bl("scope")]},Ka:{name:"setCustomParameters",j:[Xl("customOAuthParameters")]}}),nf(Eo,"credential",Ao,[Ql(Bl(),Xl(),"token")]),tf(ko.prototype,{Ca:{name:"addScope",j:[Bl("scope")]},Ka:{name:"setCustomParameters",j:[Xl("customOAuthParameters")]}}),nf(ko,"credential",So,[Ql(Bl(),Ql(Xl(),Yl()),"idToken"),Ql(Bl(),Yl(),"accessToken",!0)]),tf(No.prototype,{Ka:{name:"setCustomParameters",j:[Xl("customOAuthParameters")]}}),nf(No,"credential",_o,[Ql(Bl(),Xl(),"token"),Bl("secret",!0)]),tf(wo.prototype,{Ca:{name:"addScope",j:[Bl("scope")]},credential:{name:"credential",j:[Ql(Bl(),Ql(Xl(),Yl()),"optionsOrIdToken"),Ql(Bl(),Yl(),"accessToken",!0)]},Ka:{name:"setCustomParameters",j:[Xl("customOAuthParameters")]}}),tf(vo.prototype,{w:{name:"toJSON",j:[Bl(null,!0)]}}),tf(lo.prototype,{w:{name:"toJSON",j:[Bl(null,!0)]}}),nf(jo,"credential",Uo,[Bl("verificationId"),Bl("verificationCode")]),tf(jo.prototype,{gb:{name:"verifyPhoneNumber",j:[Ql(Bl(),{name:"phoneInfoOptions",K:"valid phone info options",optional:!1,M:function(t){return!!t&&(t.session&&t.phoneNumber?$l(t.session,so)&&"string"==typeof t.phoneNumber:t.session&&t.multiFactorHint?$l(t.session,uo)&&Zl(t.multiFactorHint):t.session&&t.multiFactorUid?$l(t.session,uo)&&"string"==typeof t.multiFactorUid:!!t.phoneNumber&&"string"==typeof t.phoneNumber)}},"phoneInfoOptions"),{name:"applicationVerifier",K:"an implementation of firebase.auth.ApplicationVerifier",optional:!1,M:function(t){return!(!t||"string"!=typeof t.type||"function"!=typeof t.verify)}}]}}),tf(Lo.prototype,{w:{name:"toJSON",j:[Bl(null,!0)]}}),tf(N.prototype,{toJSON:{name:"toJSON",j:[Bl(null,!0)]}}),tf(Xo.prototype,{toJSON:{name:"toJSON",j:[Bl(null,!0)]}}),tf(Wo.prototype,{toJSON:{name:"toJSON",j:[Bl(null,!0)]}}),tf(rh.prototype,{toJSON:{name:"toJSON",j:[Bl(null,!0)]}}),tf(eh.prototype,{Rc:{name:"resolveSignIn",j:[{name:"multiFactorAssertion",K:"a valid multiFactorAssertion",optional:!1,M:function(t){return!!t&&!!t.tb}}]}}),tf(hh.prototype,{Sb:{name:"getSession",j:[]},fc:{name:"enroll",j:[{name:"multiFactorAssertion",K:"a valid multiFactorAssertion",optional:!1,M:function(t){return!!t&&!!t.tb}},Bl("displayName",!0)]},bd:{name:"unenroll",j:[Ql({name:"multiFactorInfo",K:"a valid multiFactorInfo",optional:!1,M:Zl},Bl(),"multiFactorInfoIdentifier")]}}),tf(Kl.prototype,{clear:{name:"clear",j:[]},render:{name:"render",j:[]},verify:{name:"verify",j:[]}}),nf(Ir,"parseLink",Or,[Bl("link")]),nf(Nl,"assertion",function(t){return new uh(t)},[zl("phone")]),function(){if(void 0===e.default||!e.default.INTERNAL||!e.default.INTERNAL.registerComponent)throw Error("Cannot find the firebase namespace; be sure to include firebase-app.js before this library.");var t={ActionCodeInfo:{Operation:{EMAIL_SIGNIN:cr,PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",REVERT_SECOND_FACTOR_ADDITION:ur,VERIFY_AND_CHANGE_EMAIL:hr,VERIFY_EMAIL:"VERIFY_EMAIL"}},Auth:al,AuthCredential:co,Error:N};nf(t,"EmailAuthProvider",Ro,[]),nf(t,"FacebookAuthProvider",Io,[]),nf(t,"GithubAuthProvider",Eo,[]),nf(t,"GoogleAuthProvider",ko,[]),nf(t,"TwitterAuthProvider",No,[]),nf(t,"OAuthProvider",wo,[Bl("providerId")]),nf(t,"SAMLAuthProvider",yo,[Bl("providerId")]),nf(t,"PhoneAuthProvider",jo,[{name:"auth",K:"an instance of Firebase Auth",optional:!0,M:function(t){return!!(t&&t instanceof al)}}]),nf(t,"RecaptchaVerifier",Kl,[Ql(Bl(),{name:"",K:"an HTML element",optional:!1,M:function(t){return!!(t&&t instanceof Element)}},"recaptchaContainer"),Xl("recaptchaParameters",!0),{name:"app",K:"an instance of Firebase App",optional:!0,M:function(t){return!!(t&&t instanceof e.default.app.App)}}]),nf(t,"ActionCodeURL",Ir,[]),nf(t,"PhoneMultiFactorGenerator",Nl,[]),e.default.INTERNAL.registerComponent({name:"auth",instanceFactory:function(t){return new al(t=t.getProvider("app").getImmediate())},multipleInstances:!1,serviceProps:t,instantiationMode:"LAZY",type:"PUBLIC",onInstanceCreated:function(t){t.getProvider("auth-internal").initialize()}}),e.default.INTERNAL.registerComponent({name:"auth-internal",instanceFactory:function(t){return{getUid:T((t=t.getProvider("auth").getImmediate()).getUid,t),getToken:T(t.nc,t),addAuthTokenListener:T(t.cc,t),removeAuthTokenListener:T(t.Pc,t)}},multipleInstances:!1,instantiationMode:"LAZY",type:"PRIVATE"}),e.default.registerVersion("@firebase/auth","0.16.8"),e.default.INTERNAL.extendNamespace({User:yh})}()}).apply(void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});
|
|
482
|
-
},{"@firebase/app":"
|
|
483
|
-
"use strict";require("@firebase/auth");
|
|
484
|
-
},{"@firebase/auth":"
|
|
485
|
-
"use strict";var e=
|
|
486
|
-
},{"@firebase/app":"
|
|
487
|
-
"use strict";require("@firebase/functions");
|
|
488
|
-
},{"@firebase/functions":"
|
|
492
|
+
var e=arguments[3],t=o(require("@firebase/app-compat")),r=a(require("@firebase/auth/internal")),n=require("@firebase/component"),i=require("@firebase/util");function s(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(s=function(e){return e?r:t})(e)}function a(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=s(t);if(r&&r.has(e))return r.get(e);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var o=i?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(n,a,o):n[a]=e[a]}return n.default=e,r&&r.set(e,n),n}function o(e){return e&&e.__esModule?e:{default:e}}var d="@firebase/auth-compat",u="0.3.5";const l=1e3;function h(){var e;return(null===(e=null===self||void 0===self?void 0:self.location)||void 0===e?void 0:e.protocol)||null}function c(){return"http:"===h()||"https:"===h()}function g(e=(0,i.getUA)()){return!("file:"!==h()&&"ionic:"!==h()&&"capacitor:"!==h()||!e.toLowerCase().match(/iphone|ipad|ipod|android/))}function p(){return(0,i.isReactNative)()||(0,i.isNode)()}function _(){return(0,i.isIE)()&&11===(null===document||void 0===document?void 0:document.documentMode)}function v(e=(0,i.getUA)()){return/Edge\/\d+/.test(e)}function f(e=(0,i.getUA)()){return _()||v(e)}function m(){try{const t=self.localStorage,n=r._generateEventId();if(t)return t.setItem(n,"1"),t.removeItem(n),!f()||(0,i.isIndexedDBAvailable)()}catch(e){return P()&&(0,i.isIndexedDBAvailable)()}return!1}function P(){return void 0!==e&&"WorkerGlobalScope"in e&&"importScripts"in e}function I(){return(c()||(0,i.isBrowserExtension)()||g())&&!p()&&m()&&!P()}function A(){return g()&&"undefined"!=typeof document}async function y(){return!!A()&&new Promise(e=>{const t=setTimeout(()=>{e(!1)},l);document.addEventListener("deviceready",()=>{clearTimeout(t),e(!0)})})}function R(){return"undefined"!=typeof window?window:null}const E={LOCAL:"local",NONE:"none",SESSION:"session"},w=r._assert,N="persistence";function b(e,t){w(Object.values(E).includes(t),e,"invalid-persistence-type"),(0,i.isReactNative)()?w(t!==E.SESSION,e,"unsupported-persistence-type"):(0,i.isNode)()?w(t===E.NONE,e,"unsupported-persistence-type"):P()?w(t===E.NONE||t===E.LOCAL&&(0,i.isIndexedDBAvailable)(),e,"unsupported-persistence-type"):w(t===E.NONE||m(),e,"unsupported-persistence-type")}async function k(e){await e._initializationPromise;const t=O(),n=r._persistenceKeyName(N,e.config.apiKey,e.name);t&&t.setItem(n,e._getPersistence())}function C(e,t){const n=O();if(!n)return[];const i=r._persistenceKeyName(N,e,t);switch(n.getItem(i)){case E.NONE:return[r.inMemoryPersistence];case E.LOCAL:return[r.indexedDBLocalPersistence,r.browserSessionPersistence];case E.SESSION:return[r.browserSessionPersistence];default:return[]}}function O(){var e;try{return(null===(e=R())||void 0===e?void 0:e.sessionStorage)||null}catch(t){return null}}const S=r._assert;class W{constructor(){this.browserResolver=r._getInstance(r.browserPopupRedirectResolver),this.cordovaResolver=r._getInstance(r.cordovaPopupRedirectResolver),this.underlyingResolver=null,this._redirectPersistence=r.browserSessionPersistence,this._completeRedirectFn=r._getRedirectResult,this._overrideRedirectResult=r._overrideRedirectResult}async _initialize(e){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._initialize(e)}async _openPopup(e,t,r,n){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openPopup(e,t,r,n)}async _openRedirect(e,t,r,n){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openRedirect(e,t,r,n)}_isIframeWebStorageSupported(e,t){this.assertedUnderlyingResolver._isIframeWebStorageSupported(e,t)}_originValidation(e){return this.assertedUnderlyingResolver._originValidation(e)}get _shouldInitProactively(){return A()||this.browserResolver._shouldInitProactively}get assertedUnderlyingResolver(){return S(this.underlyingResolver,"internal-error"),this.underlyingResolver}async selectUnderlyingResolver(){if(this.underlyingResolver)return;const e=await y();this.underlyingResolver=e?this.cordovaResolver:this.browserResolver}}function L(e){return e.unwrap()}function T(e){return e.wrapped()}function M(e){return U(e)}function D(e,t){var n;const i=null===(n=t.customData)||void 0===n?void 0:n._tokenResponse;if("auth/multi-factor-auth-required"===(null==t?void 0:t.code)){t.resolver=new G(e,r.getMultiFactorResolver(e,t))}else if(i){const e=U(t),r=t;e&&(r.credential=e,r.tenantId=i.tenantId||void 0,r.email=i.email||void 0,r.phoneNumber=i.phoneNumber||void 0)}}function U(e){const{_tokenResponse:t}=e instanceof i.FirebaseError?e.customData:e;if(!t)return null;if(!(e instanceof i.FirebaseError)&&"temporaryProof"in t&&"phoneNumber"in t)return r.PhoneAuthProvider.credentialFromResult(e);const n=t.providerId;if(!n||n===r.ProviderId.PASSWORD)return null;let s;switch(n){case r.ProviderId.GOOGLE:s=r.GoogleAuthProvider;break;case r.ProviderId.FACEBOOK:s=r.FacebookAuthProvider;break;case r.ProviderId.GITHUB:s=r.GithubAuthProvider;break;case r.ProviderId.TWITTER:s=r.TwitterAuthProvider;break;default:const{oauthIdToken:e,oauthAccessToken:i,oauthTokenSecret:a,pendingToken:o,nonce:d}=t;return i||a||e||o?o?n.startsWith("saml.")?r.SAMLAuthCredential._create(n,o):r.OAuthCredential._fromParams({providerId:n,signInMethod:n,pendingToken:o,idToken:e,accessToken:i}):new r.OAuthProvider(n).credential({idToken:e,accessToken:i,rawNonce:d}):null}return e instanceof i.FirebaseError?s.credentialFromError(e):s.credentialFromResult(e)}function F(e,t){return t.catch(t=>{throw t instanceof i.FirebaseError&&D(e,t),t}).then(e=>{const t=e.operationType,n=e.user;return{operationType:t,credential:M(e),additionalUserInfo:r.getAdditionalUserInfo(e),user:B.getOrCreate(n)}})}async function V(e,t){const r=await t;return{verificationId:r.verificationId,confirm:t=>F(e,r.confirm(t))}}class G{constructor(e,t){this.resolver=t,this.auth=T(e)}get session(){return this.resolver.session}get hints(){return this.resolver.hints}resolveSignIn(e){return F(L(this.auth),this.resolver.resolveSignIn(e))}}class B{constructor(e){this._delegate=e,this.multiFactor=r.multiFactor(e)}static getOrCreate(e){return B.USER_MAP.has(e)||B.USER_MAP.set(e,new B(e)),B.USER_MAP.get(e)}delete(){return this._delegate.delete()}reload(){return this._delegate.reload()}toJSON(){return this._delegate.toJSON()}getIdTokenResult(e){return this._delegate.getIdTokenResult(e)}getIdToken(e){return this._delegate.getIdToken(e)}linkAndRetrieveDataWithCredential(e){return this.linkWithCredential(e)}async linkWithCredential(e){return F(this.auth,r.linkWithCredential(this._delegate,e))}async linkWithPhoneNumber(e,t){return V(this.auth,r.linkWithPhoneNumber(this._delegate,e,t))}async linkWithPopup(e){return F(this.auth,r.linkWithPopup(this._delegate,e,W))}async linkWithRedirect(e){return await k(r._castAuth(this.auth)),r.linkWithRedirect(this._delegate,e,W)}reauthenticateAndRetrieveDataWithCredential(e){return this.reauthenticateWithCredential(e)}async reauthenticateWithCredential(e){return F(this.auth,r.reauthenticateWithCredential(this._delegate,e))}reauthenticateWithPhoneNumber(e,t){return V(this.auth,r.reauthenticateWithPhoneNumber(this._delegate,e,t))}reauthenticateWithPopup(e){return F(this.auth,r.reauthenticateWithPopup(this._delegate,e,W))}async reauthenticateWithRedirect(e){return await k(r._castAuth(this.auth)),r.reauthenticateWithRedirect(this._delegate,e,W)}sendEmailVerification(e){return r.sendEmailVerification(this._delegate,e)}async unlink(e){return await r.unlink(this._delegate,e),this}updateEmail(e){return r.updateEmail(this._delegate,e)}updatePassword(e){return r.updatePassword(this._delegate,e)}updatePhoneNumber(e){return r.updatePhoneNumber(this._delegate,e)}updateProfile(e){return r.updateProfile(this._delegate,e)}verifyBeforeUpdateEmail(e,t){return r.verifyBeforeUpdateEmail(this._delegate,e,t)}get emailVerified(){return this._delegate.emailVerified}get isAnonymous(){return this._delegate.isAnonymous}get metadata(){return this._delegate.metadata}get phoneNumber(){return this._delegate.phoneNumber}get providerData(){return this._delegate.providerData}get refreshToken(){return this._delegate.refreshToken}get tenantId(){return this._delegate.tenantId}get displayName(){return this._delegate.displayName}get email(){return this._delegate.email}get photoURL(){return this._delegate.photoURL}get providerId(){return this._delegate.providerId}get uid(){return this._delegate.uid}get auth(){return this._delegate.auth}}B.USER_MAP=new WeakMap;const x=r._assert;class j{constructor(e,t){if(this.app=e,t.isInitialized())return this._delegate=t.getImmediate(),void this.linkUnderlyingAuth();const{apiKey:n}=e.options;x(n,"invalid-api-key",{appName:e.name}),x(n,"invalid-api-key",{appName:e.name});const i="undefined"!=typeof window?W:void 0;this._delegate=t.initialize({options:{persistence:K(n,e.name),popupRedirectResolver:i}}),this._delegate._updateErrorMap(r.debugErrorMap),this.linkUnderlyingAuth()}get emulatorConfig(){return this._delegate.emulatorConfig}get currentUser(){return this._delegate.currentUser?B.getOrCreate(this._delegate.currentUser):null}get languageCode(){return this._delegate.languageCode}set languageCode(e){this._delegate.languageCode=e}get settings(){return this._delegate.settings}get tenantId(){return this._delegate.tenantId}set tenantId(e){this._delegate.tenantId=e}useDeviceLanguage(){this._delegate.useDeviceLanguage()}signOut(){return this._delegate.signOut()}useEmulator(e,t){r.connectAuthEmulator(this._delegate,e,t)}applyActionCode(e){return r.applyActionCode(this._delegate,e)}checkActionCode(e){return r.checkActionCode(this._delegate,e)}confirmPasswordReset(e,t){return r.confirmPasswordReset(this._delegate,e,t)}async createUserWithEmailAndPassword(e,t){return F(this._delegate,r.createUserWithEmailAndPassword(this._delegate,e,t))}fetchProvidersForEmail(e){return this.fetchSignInMethodsForEmail(e)}fetchSignInMethodsForEmail(e){return r.fetchSignInMethodsForEmail(this._delegate,e)}isSignInWithEmailLink(e){return r.isSignInWithEmailLink(this._delegate,e)}async getRedirectResult(){x(I(),this._delegate,"operation-not-supported-in-this-environment");const e=await r.getRedirectResult(this._delegate,W);return e?F(this._delegate,Promise.resolve(e)):{credential:null,user:null}}addFrameworkForLogging(e){r.addFrameworkForLogging(this._delegate,e)}onAuthStateChanged(e,t,r){const{next:n,error:i,complete:s}=H(e,t,r);return this._delegate.onAuthStateChanged(n,i,s)}onIdTokenChanged(e,t,r){const{next:n,error:i,complete:s}=H(e,t,r);return this._delegate.onIdTokenChanged(n,i,s)}sendSignInLinkToEmail(e,t){return r.sendSignInLinkToEmail(this._delegate,e,t)}sendPasswordResetEmail(e,t){return r.sendPasswordResetEmail(this._delegate,e,t||void 0)}async setPersistence(e){let t;switch(b(this._delegate,e),e){case E.SESSION:t=r.browserSessionPersistence;break;case E.LOCAL:t=await r._getInstance(r.indexedDBLocalPersistence)._isAvailable()?r.indexedDBLocalPersistence:r.browserLocalPersistence;break;case E.NONE:t=r.inMemoryPersistence;break;default:return r._fail("argument-error",{appName:this._delegate.name})}return this._delegate.setPersistence(t)}signInAndRetrieveDataWithCredential(e){return this.signInWithCredential(e)}signInAnonymously(){return F(this._delegate,r.signInAnonymously(this._delegate))}signInWithCredential(e){return F(this._delegate,r.signInWithCredential(this._delegate,e))}signInWithCustomToken(e){return F(this._delegate,r.signInWithCustomToken(this._delegate,e))}signInWithEmailAndPassword(e,t){return F(this._delegate,r.signInWithEmailAndPassword(this._delegate,e,t))}signInWithEmailLink(e,t){return F(this._delegate,r.signInWithEmailLink(this._delegate,e,t))}signInWithPhoneNumber(e,t){return V(this._delegate,r.signInWithPhoneNumber(this._delegate,e,t))}async signInWithPopup(e){return x(I(),this._delegate,"operation-not-supported-in-this-environment"),F(this._delegate,r.signInWithPopup(this._delegate,e,W))}async signInWithRedirect(e){return x(I(),this._delegate,"operation-not-supported-in-this-environment"),await k(this._delegate),r.signInWithRedirect(this._delegate,e,W)}updateCurrentUser(e){return this._delegate.updateCurrentUser(e)}verifyPasswordResetCode(e){return r.verifyPasswordResetCode(this._delegate,e)}unwrap(){return this._delegate}_delete(){return this._delegate._delete()}linkUnderlyingAuth(){this._delegate.wrapped=(()=>this)}}function H(e,t,r){let n=e;"function"!=typeof e&&({next:n,error:t,complete:r}=e);const i=n;return{next:e=>i(e&&B.getOrCreate(e)),error:t,complete:r}}function K(e,t){const n=C(e,t);if("undefined"==typeof self||n.includes(r.indexedDBLocalPersistence)||n.push(r.indexedDBLocalPersistence),"undefined"!=typeof window)for(const i of[r.browserLocalPersistence,r.browserSessionPersistence])n.includes(i)||n.push(i);return n.includes(r.inMemoryPersistence)||n.push(r.inMemoryPersistence),n}j.Persistence=E;class q{constructor(){this.providerId="phone",this._delegate=new r.PhoneAuthProvider(L(t.default.auth()))}static credential(e,t){return r.PhoneAuthProvider.credential(e,t)}verifyPhoneNumber(e,t){return this._delegate.verifyPhoneNumber(e,t)}unwrap(){return this._delegate}}q.PHONE_SIGN_IN_METHOD=r.PhoneAuthProvider.PHONE_SIGN_IN_METHOD,q.PROVIDER_ID=r.PhoneAuthProvider.PROVIDER_ID;const z=r._assert;class Y{constructor(e,n,i=t.default.app()){var s;z(null===(s=i.options)||void 0===s?void 0:s.apiKey,"invalid-api-key",{appName:i.name}),this._delegate=new r.RecaptchaVerifier(e,n,i.auth()),this.type=this._delegate.type}clear(){this._delegate.clear()}render(){return this._delegate.render()}verify(){return this._delegate.verify()}}const J="auth-compat";function Z(e){e.INTERNAL.registerComponent(new n.Component(J,e=>{const t=e.getProvider("app-compat").getImmediate(),r=e.getProvider("auth");return new j(t,r)},"PUBLIC").setServiceProps({ActionCodeInfo:{Operation:{EMAIL_SIGNIN:r.ActionCodeOperation.EMAIL_SIGNIN,PASSWORD_RESET:r.ActionCodeOperation.PASSWORD_RESET,RECOVER_EMAIL:r.ActionCodeOperation.RECOVER_EMAIL,REVERT_SECOND_FACTOR_ADDITION:r.ActionCodeOperation.REVERT_SECOND_FACTOR_ADDITION,VERIFY_AND_CHANGE_EMAIL:r.ActionCodeOperation.VERIFY_AND_CHANGE_EMAIL,VERIFY_EMAIL:r.ActionCodeOperation.VERIFY_EMAIL}},EmailAuthProvider:r.EmailAuthProvider,FacebookAuthProvider:r.FacebookAuthProvider,GithubAuthProvider:r.GithubAuthProvider,GoogleAuthProvider:r.GoogleAuthProvider,OAuthProvider:r.OAuthProvider,SAMLAuthProvider:r.SAMLAuthProvider,PhoneAuthProvider:q,PhoneMultiFactorGenerator:r.PhoneMultiFactorGenerator,RecaptchaVerifier:Y,TwitterAuthProvider:r.TwitterAuthProvider,Auth:j,AuthCredential:r.AuthCredential,Error:i.FirebaseError}).setInstantiationMode("LAZY").setMultipleInstances(!1)),e.registerVersion(d,u)}Z(t.default);
|
|
493
|
+
},{"@firebase/app-compat":"CMFQ","@firebase/auth/internal":"eL7N","@firebase/component":"vhY9","@firebase/util":"chA2"}],"hycF":[function(require,module,exports) {
|
|
494
|
+
"use strict";require("@firebase/auth-compat");
|
|
495
|
+
},{"@firebase/auth-compat":"h9Y9"}],"AvWE":[function(require,module,exports) {
|
|
496
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.connectFunctionsEmulator=S,exports.getFunctions=v,exports.httpsCallable=P,exports.httpsCallableFromURL=x;var e=require("@firebase/app"),t=require("@firebase/util"),n=require("@firebase/component");const r="type.googleapis.com/google.protobuf.Int64Value",i="type.googleapis.com/google.protobuf.UInt64Value";function o(e,t){const n={};for(const r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}function s(e){if(null==e)return null;if(e instanceof Number&&(e=e.valueOf()),"number"==typeof e&&isFinite(e))return e;if(!0===e||!1===e)return e;if("[object String]"===Object.prototype.toString.call(e))return e;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(e=>s(e));if("function"==typeof e||"object"==typeof e)return o(e,e=>s(e));throw new Error("Data cannot be encoded in JSON: "+e)}function a(e){if(null==e)return e;if(e["@type"])switch(e["@type"]){case r:case i:{const t=Number(e.value);if(isNaN(t))throw new Error("Data cannot be decoded from JSON: "+e);return t}default:throw new Error("Data cannot be decoded from JSON: "+e)}return Array.isArray(e)?e.map(e=>a(e)):"function"==typeof e||"object"==typeof e?o(e,e=>a(e)):e}const u="functions",c={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class l extends t.FirebaseError{constructor(e,t,n){super(`${u}/${e}`,t||""),this.details=n}}function h(e){if(e>=200&&e<300)return"ok";switch(e){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}function d(e,t){let n=h(e),r=n,i=void 0;try{const e=t&&t.error;if(e){const t=e.status;if("string"==typeof t){if(!c[t])return new l("internal","internal");n=c[t],r=t}const o=e.message;"string"==typeof o&&(r=o),void 0!==(i=e.details)&&(i=a(i))}}catch(o){}return"ok"===n?null:new l(n,r,i)}class p{constructor(e,t,n){this.auth=null,this.messaging=null,this.appCheck=null,this.auth=e.getImmediate({optional:!0}),this.messaging=t.getImmediate({optional:!0}),this.auth||e.get().then(e=>this.auth=e,()=>{}),this.messaging||t.get().then(e=>this.messaging=e,()=>{}),this.appCheck||n.get().then(e=>this.appCheck=e,()=>{})}async getAuthToken(){if(this.auth)try{const t=await this.auth.getToken();return null==t?void 0:t.accessToken}catch(e){return}}async getMessagingToken(){if(this.messaging&&"Notification"in self&&"granted"===Notification.permission)try{return await this.messaging.getToken()}catch(e){return}}async getAppCheckToken(){if(this.appCheck){const e=await this.appCheck.getToken();return e.error?null:e.token}return null}async getContext(){return{authToken:await this.getAuthToken(),messagingToken:await this.getMessagingToken(),appCheckToken:await this.getAppCheckToken()}}}const g="us-central1";function f(e){let t=null;return{promise:new Promise((n,r)=>{t=setTimeout(()=>{r(new l("deadline-exceeded","deadline-exceeded"))},e)}),cancel:()=>{t&&clearTimeout(t)}}}class m{constructor(e,t,n,r,i=g,o){this.app=e,this.fetchImpl=o,this.emulatorOrigin=null,this.contextProvider=new p(t,n,r),this.cancelAllRequests=new Promise(e=>{this.deleteService=(()=>Promise.resolve(e()))});try{const e=new URL(i);this.customDomain=e.origin,this.region=g}catch(s){this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){const t=this.app.options.projectId;if(null!==this.emulatorOrigin){return`${this.emulatorOrigin}/${t}/${this.region}/${e}`}return null!==this.customDomain?`${this.customDomain}/${e}`:`https://${this.region}-${t}.cloudfunctions.net/${e}`}}function k(e,t,n){e.emulatorOrigin=`http://${t}:${n}`}function w(e,t,n){return r=>y(e,t,r,n||{})}function T(e,t,n){return r=>I(e,t,r,n||{})}async function E(e,t,n,r){let i;n["Content-Type"]="application/json";try{i=await r(e,{method:"POST",body:JSON.stringify(t),headers:n})}catch(s){return{status:0,json:null}}let o=null;try{o=await i.json()}catch(s){}return{status:i.status,json:o}}function y(e,t,n,r){const i=e._url(t);return I(e,i,n,r)}async function I(e,t,n,r){const i={data:n=s(n)},o={},u=await e.contextProvider.getContext();u.authToken&&(o.Authorization="Bearer "+u.authToken),u.messagingToken&&(o["Firebase-Instance-ID-Token"]=u.messagingToken),null!==u.appCheckToken&&(o["X-Firebase-AppCheck"]=u.appCheckToken);const c=f(r.timeout||7e4),h=await Promise.race([E(t,i,o,e.fetchImpl),c.promise,e.cancelAllRequests]);if(c.cancel(),!h)throw new l("cancelled","Firebase Functions instance was deleted.");const p=d(h.status,h.json);if(p)throw p;if(!h.json)throw new l("internal","Response is not valid JSON object.");let g=h.json.data;if(void 0===g&&(g=h.json.result),void 0===g)throw new l("internal","Response is missing data field.");return{data:a(g)}}const A="@firebase/functions",N="0.9.4",b="auth-internal",D="app-check-internal",O="messaging-internal";function C(t,r){(0,e._registerComponent)(new n.Component(u,(e,{instanceIdentifier:n})=>{const r=e.getProvider("app").getImmediate(),i=e.getProvider(b),o=e.getProvider(O),s=e.getProvider(D);return new m(r,i,o,s,n,t)},"PUBLIC").setMultipleInstances(!0)),(0,e.registerVersion)(A,N,r),(0,e.registerVersion)(A,N,"esm2017")}function v(n=(0,e.getApp)(),r=g){const i=(0,e._getProvider)((0,t.getModularInstance)(n),u).getImmediate({identifier:r}),o=(0,t.getDefaultEmulatorHostnameAndPort)("functions");return o&&S(i,...o),i}function S(e,n,r){k((0,t.getModularInstance)(e),n,r)}function P(e,n,r){return w((0,t.getModularInstance)(e),n,r)}function x(e,n,r){return T((0,t.getModularInstance)(e),n,r)}C(fetch.bind(self));
|
|
497
|
+
},{"@firebase/app":"h2Mb","@firebase/util":"chA2","@firebase/component":"vhY9"}],"F0p3":[function(require,module,exports) {
|
|
498
|
+
"use strict";var e=i(require("@firebase/app-compat")),t=require("@firebase/functions"),n=require("@firebase/util"),r=require("@firebase/component");function i(e){return e&&e.__esModule?e:{default:e}}const o="@firebase/functions-compat",s="0.3.4";class a{constructor(e,t){this.app=e,this._delegate=t,this._region=this._delegate.region,this._customDomain=this._delegate.customDomain}httpsCallable(e,n){return(0,t.httpsCallable)(this._delegate,e,n)}httpsCallableFromURL(e,n){return(0,t.httpsCallableFromURL)(this._delegate,e,n)}useFunctionsEmulator(e){const r=e.match("[a-zA-Z]+://([a-zA-Z0-9.-]+)(?::([0-9]+))?");if(null==r)throw new n.FirebaseError("functions","No origin provided to useFunctionsEmulator()");if(null==r[2])throw new n.FirebaseError("functions","Port missing in origin provided to useFunctionsEmulator()");return(0,t.connectFunctionsEmulator)(this._delegate,r[1],Number(r[2]))}useEmulator(e,n){return(0,t.connectFunctionsEmulator)(this._delegate,e,n)}}const u="us-central1",l=(e,{instanceIdentifier:t})=>{const n=e.getProvider("app-compat").getImmediate(),r=e.getProvider("functions").getImmediate({identifier:null!=t?t:"us-central1"});return new a(n,r)};function c(){const t={Functions:a};e.default.INTERNAL.registerComponent(new r.Component("functions-compat",l,"PUBLIC").setServiceProps(t).setMultipleInstances(!0))}c(),e.default.registerVersion(o,"0.3.4");
|
|
499
|
+
},{"@firebase/app-compat":"CMFQ","@firebase/functions":"AvWE","@firebase/util":"chA2","@firebase/component":"vhY9"}],"O8Yj":[function(require,module,exports) {
|
|
500
|
+
"use strict";require("@firebase/functions-compat");
|
|
501
|
+
},{"@firebase/functions-compat":"F0p3"}],"qQDx":[function(require,module,exports) {
|
|
489
502
|
var global = arguments[3];
|
|
490
|
-
var t=arguments[3];Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStatEventTarget=exports.default=exports.createWebChannelTransport=exports.XhrIo=exports.WebChannel=exports.Stat=exports.FetchXmlHttpFactory=exports.EventType=exports.Event=exports.ErrorCode=void 0;var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])})(t,e)};function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function n(t){var i="function"==typeof Symbol&&Symbol.iterator,e=i&&t[i],n=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(i?"Object is not iterable.":"Symbol.iterator is not defined.")}var r,s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},o=o||{},h=s||self;function a(){}function l(t){var i=typeof t;return"array"==(i="object"!=i?i:t?Array.isArray(t)?"array":i:"null")||"object"==i&&"number"==typeof t.length}function u(t){var i=typeof t;return"object"==i&&null!=t||"function"==i}function c(t){return Object.prototype.hasOwnProperty.call(t,f)&&t[f]||(t[f]=++g)}var f="closure_uid_"+(1e9*Math.random()>>>0),g=0;function p(t,i,e){return t.call.apply(t.bind,arguments)}function v(t,i,e){if(!t)throw Error();if(2<arguments.length){var n=Array.prototype.slice.call(arguments,2);return function(){var e=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(e,n),t.apply(i,e)}}return function(){return t.apply(i,arguments)}}function d(t,i,e){return(d=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?p:v).apply(null,arguments)}function y(t,i){var e=Array.prototype.slice.call(arguments,1);return function(){var i=e.slice();return i.push.apply(i,arguments),t.apply(this,i)}}function m(t,i){function e(){}e.prototype=i.prototype,t.Z=i.prototype,t.prototype=new e,t.prototype.constructor=t,t.Vb=function(t,e,n){for(var r=Array(arguments.length-2),s=2;s<arguments.length;s++)r[s-2]=arguments[s];return i.prototype[e].apply(t,r)}}function b(){this.s=this.s,this.o=this.o}var w=0,T={};b.prototype.s=!1,b.prototype.na=function(){if(!this.s&&(this.s=!0,this.M(),0!=w)){var t=c(this);delete T[t]}},b.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};var E=Array.prototype.indexOf?function(t,i){return Array.prototype.indexOf.call(t,i,void 0)}:function(t,i){if("string"==typeof t)return"string"!=typeof i||1!=i.length?-1:t.indexOf(i,0);for(var e=0;e<t.length;e++)if(e in t&&t[e]===i)return e;return-1},S=Array.prototype.forEach?function(t,i,e){Array.prototype.forEach.call(t,i,e)}:function(t,i,e){for(var n=t.length,r="string"==typeof t?t.split(""):t,s=0;s<n;s++)s in r&&i.call(e,r[s],s,t)};function x(t){t:{for(var i=Ne,e=t.length,n="string"==typeof t?t.split(""):t,r=0;r<e;r++)if(r in n&&i.call(void 0,n[r],r,t)){i=r;break t}i=-1}return 0>i?null:"string"==typeof t?t.charAt(i):t[i]}function j(t){return Array.prototype.concat.apply([],arguments)}function C(t){var i=t.length;if(0<i){for(var e=Array(i),n=0;n<i;n++)e[n]=t[n];return e}return[]}function I(t){return/^[\s\xa0]*$/.test(t)}var A,R=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function O(t,i){return-1!=t.indexOf(i)}function P(t,i){return t<i?-1:t>i?1:0}t:{var D=h.navigator;if(D){var M=D.userAgent;if(M){A=M;break t}}A=""}function L(t,i,e){for(var n in t)i.call(e,t[n],n,t)}function X(t){var i={};for(var e in t)i[e]=t[e];return i}var H="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function _(t,i){for(var e,n,r=1;r<arguments.length;r++){for(e in n=arguments[r])t[e]=n[e];for(var s=0;s<H.length;s++)e=H[s],Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}}function k(t){return k[" "](t),t}function B(t){var i=Z;return Object.prototype.hasOwnProperty.call(i,9)?i[9]:i[9]=t(9)}k[" "]=a;var F,N=O(A,"Opera"),U=O(A,"Trident")||O(A,"MSIE"),K=O(A,"Edge"),Y=K||U,G=O(A,"Gecko")&&!(O(A.toLowerCase(),"webkit")&&!O(A,"Edge"))&&!(O(A,"Trident")||O(A,"MSIE"))&&!O(A,"Edge"),J=O(A.toLowerCase(),"webkit")&&!O(A,"Edge");function W(){var t=h.document;return t?t.documentMode:void 0}t:{var V="",$=function(){var t=A;return G?/rv:([^\);]+)(\)|;)/.exec(t):K?/Edge\/([\d\.]+)/.exec(t):U?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(t):J?/WebKit\/(\S+)/.exec(t):N?/(?:Version)[ \/]?(\S+)/.exec(t):void 0}();if($&&(V=$?$[1]:""),U){var q=W();if(null!=q&&q>parseFloat(V)){F=String(q);break t}}F=V}var z,Z={};function Q(){return B(function(){for(var t=0,i=R(String(F)).split("."),e=R("9").split("."),n=Math.max(i.length,e.length),r=0;0==t&&r<n;r++){var s=i[r]||"",o=e[r]||"";do{if(s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],o=/(\d*)(\D*)(.*)/.exec(o)||["","","",""],0==s[0].length&&0==o[0].length)break;t=P(0==s[1].length?0:parseInt(s[1],10),0==o[1].length?0:parseInt(o[1],10))||P(0==s[2].length,0==o[2].length)||P(s[2],o[2]),s=s[3],o=o[3]}while(0==t)}return 0<=t})}if(h.document&&U){var tt=W();z=tt||(parseInt(F,10)||void 0)}else z=void 0;var it=z,et=function(){if(!h.addEventListener||!Object.defineProperty)return!1;var t=!1,i=Object.defineProperty({},"passive",{get:function(){t=!0}});try{h.addEventListener("test",a,i),h.removeEventListener("test",a,i)}catch(e){}return t}();function nt(t,i){this.type=t,this.g=this.target=i,this.defaultPrevented=!1}function rt(t,i){if(nt.call(this,t?t.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,t){var e=this.type=t.type,n=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.g=i,i=t.relatedTarget){if(G){t:{try{k(i.nodeName);var r=!0;break t}catch(s){}r=!1}r||(i=null)}}else"mouseover"==e?i=t.fromElement:"mouseout"==e&&(i=t.toElement);this.relatedTarget=i,n?(this.clientX=void 0!==n.clientX?n.clientX:n.pageX,this.clientY=void 0!==n.clientY?n.clientY:n.pageY,this.screenX=n.screenX||0,this.screenY=n.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:st[t.pointerType]||"",this.state=t.state,this.i=t,t.defaultPrevented&&rt.Z.h.call(this)}}nt.prototype.h=function(){this.defaultPrevented=!0},m(rt,nt);var st={2:"touch",3:"pen",4:"mouse"};rt.prototype.h=function(){rt.Z.h.call(this);var t=this.i;t.preventDefault?t.preventDefault():t.returnValue=!1};var ot="closure_listenable_"+(1e6*Math.random()|0),ht=0;function at(t,i,e,n,r){this.listener=t,this.proxy=null,this.src=i,this.type=e,this.capture=!!n,this.ia=r,this.key=++ht,this.ca=this.fa=!1}function lt(t){t.ca=!0,t.listener=null,t.proxy=null,t.src=null,t.ia=null}function ut(t){this.src=t,this.g={},this.h=0}function ct(t,i){var e=i.type;if(e in t.g){var n,r=t.g[e],s=E(r,i);(n=0<=s)&&Array.prototype.splice.call(r,s,1),n&&(lt(i),0==t.g[e].length&&(delete t.g[e],t.h--))}}function ft(t,i,e,n){for(var r=0;r<t.length;++r){var s=t[r];if(!s.ca&&s.listener==i&&s.capture==!!e&&s.ia==n)return r}return-1}ut.prototype.add=function(t,i,e,n,r){var s=t.toString();(t=this.g[s])||(t=this.g[s]=[],this.h++);var o=ft(t,i,n,r);return-1<o?(i=t[o],e||(i.fa=!1)):((i=new at(i,this.src,s,!!n,r)).fa=e,t.push(i)),i};var gt="closure_lm_"+(1e6*Math.random()|0),pt={};function vt(t,i,e,n,r){if(n&&n.once)return mt(t,i,e,n,r);if(Array.isArray(i)){for(var s=0;s<i.length;s++)vt(t,i[s],e,n,r);return null}return e=jt(e),t&&t[ot]?t.N(i,e,u(n)?!!n.capture:!!n,r):dt(t,i,e,!1,n,r)}function dt(t,i,e,n,r,s){if(!i)throw Error("Invalid event type");var o=u(r)?!!r.capture:!!r,h=St(t);if(h||(t[gt]=h=new ut(t)),(e=h.add(i,e,n,o,s)).proxy)return e;if(n=yt(),e.proxy=n,n.src=t,n.listener=e,t.addEventListener)et||(r=o),void 0===r&&(r=!1),t.addEventListener(i.toString(),n,r);else if(t.attachEvent)t.attachEvent(Tt(i.toString()),n);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(n)}return e}function yt(){var t=Et;return function i(e){return t.call(i.src,i.listener,e)}}function mt(t,i,e,n,r){if(Array.isArray(i)){for(var s=0;s<i.length;s++)mt(t,i[s],e,n,r);return null}return e=jt(e),t&&t[ot]?t.O(i,e,u(n)?!!n.capture:!!n,r):dt(t,i,e,!0,n,r)}function bt(t,i,e,n,r){if(Array.isArray(i))for(var s=0;s<i.length;s++)bt(t,i[s],e,n,r);else n=u(n)?!!n.capture:!!n,e=jt(e),t&&t[ot]?(t=t.i,(i=String(i).toString())in t.g&&(-1<(e=ft(s=t.g[i],e,n,r))&&(lt(s[e]),Array.prototype.splice.call(s,e,1),0==s.length&&(delete t.g[i],t.h--)))):t&&(t=St(t))&&(i=t.g[i.toString()],t=-1,i&&(t=ft(i,e,n,r)),(e=-1<t?i[t]:null)&&wt(e))}function wt(t){if("number"!=typeof t&&t&&!t.ca){var i=t.src;if(i&&i[ot])ct(i.i,t);else{var e=t.type,n=t.proxy;i.removeEventListener?i.removeEventListener(e,n,t.capture):i.detachEvent?i.detachEvent(Tt(e),n):i.addListener&&i.removeListener&&i.removeListener(n),(e=St(i))?(ct(e,t),0==e.h&&(e.src=null,i[gt]=null)):lt(t)}}}function Tt(t){return t in pt?pt[t]:pt[t]="on"+t}function Et(t,i){if(t.ca)t=!0;else{i=new rt(i,this);var e=t.listener,n=t.ia||t.src;t.fa&&wt(t),t=e.call(n,i)}return t}function St(t){return(t=t[gt])instanceof ut?t:null}var xt="__closure_events_fn_"+(1e9*Math.random()>>>0);function jt(t){return"function"==typeof t?t:(t[xt]||(t[xt]=function(i){return t.handleEvent(i)}),t[xt])}function Ct(){b.call(this),this.i=new ut(this),this.P=this,this.I=null}function It(t,i){var e,n=t.I;if(n)for(e=[];n;n=n.I)e.push(n);if(t=t.P,n=i.type||i,"string"==typeof i)i=new nt(i,t);else if(i instanceof nt)i.target=i.target||t;else{var r=i;_(i=new nt(n,t),r)}if(r=!0,e)for(var s=e.length-1;0<=s;s--){var o=i.g=e[s];r=At(o,n,!0,i)&&r}if(r=At(o=i.g=t,n,!0,i)&&r,r=At(o,n,!1,i)&&r,e)for(s=0;s<e.length;s++)r=At(o=i.g=e[s],n,!1,i)&&r}function At(t,i,e,n){if(!(i=t.i.g[String(i)]))return!0;i=i.concat();for(var r=!0,s=0;s<i.length;++s){var o=i[s];if(o&&!o.ca&&o.capture==e){var h=o.listener,a=o.ia||o.src;o.fa&&ct(t.i,o),r=!1!==h.call(a,n)&&r}}return r&&!n.defaultPrevented}m(Ct,b),Ct.prototype[ot]=!0,Ct.prototype.removeEventListener=function(t,i,e,n){bt(this,t,i,e,n)},Ct.prototype.M=function(){if(Ct.Z.M.call(this),this.i){var t,i=this.i;for(t in i.g){for(var e=i.g[t],n=0;n<e.length;n++)lt(e[n]);delete i.g[t],i.h--}}this.I=null},Ct.prototype.N=function(t,i,e,n){return this.i.add(String(t),i,!1,e,n)},Ct.prototype.O=function(t,i,e,n){return this.i.add(String(t),i,!0,e,n)};var Rt=h.JSON.stringify;function Ot(){var t=Bt,i=null;return t.g&&(i=t.g,t.g=t.g.next,t.g||(t.h=null),i.next=null),i}var Pt,Dt=function(){function t(){this.h=this.g=null}return t.prototype.add=function(t,i){var e=Mt.get();e.set(t,i),this.h?this.h.next=e:this.g=e,this.h=e},t}(),Mt=new(function(){function t(t,i){this.i=t,this.j=i,this.h=0,this.g=null}return t.prototype.get=function(){var t;return 0<this.h?(this.h--,t=this.g,this.g=t.next,t.next=null):t=this.i(),t},t}())(function(){return new Lt},function(t){return t.reset()}),Lt=function(){function t(){this.next=this.g=this.h=null}return t.prototype.set=function(t,i){this.h=t,this.g=i,this.next=null},t.prototype.reset=function(){this.next=this.g=this.h=null},t}();function Xt(t){h.setTimeout(function(){throw t},0)}function Ht(t,i){Pt||_t(),kt||(Pt(),kt=!0),Bt.add(t,i)}function _t(){var t=h.Promise.resolve(void 0);Pt=function(){t.then(Ft)}}var kt=!1,Bt=new Dt;function Ft(){for(var t;t=Ot();){try{t.h.call(t.g)}catch(e){Xt(e)}var i=Mt;i.j(t),100>i.h&&(i.h++,t.next=i.g,i.g=t)}kt=!1}function Nt(t,i){Ct.call(this),this.h=t||1,this.g=i||h,this.j=d(this.kb,this),this.l=Date.now()}function Ut(t){t.da=!1,t.S&&(t.g.clearTimeout(t.S),t.S=null)}function Kt(t,i,e){if("function"==typeof t)e&&(t=d(t,e));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=d(t.handleEvent,t)}return 2147483647<Number(i)?-1:h.setTimeout(t,i||0)}function Yt(t){t.g=Kt(function(){t.g=null,t.i&&(t.i=!1,Yt(t))},t.j);var i=t.h;t.h=null,t.m.apply(null,i)}m(Nt,Ct),(r=Nt.prototype).da=!1,r.S=null,r.kb=function(){if(this.da){var t=Date.now()-this.l;0<t&&t<.8*this.h?this.S=this.g.setTimeout(this.j,this.h-t):(this.S&&(this.g.clearTimeout(this.S),this.S=null),It(this,"tick"),this.da&&(Ut(this),this.start()))}},r.start=function(){this.da=!0,this.S||(this.S=this.g.setTimeout(this.j,this.h),this.l=Date.now())},r.M=function(){Nt.Z.M.call(this),Ut(this),delete this.g};var Gt=function(t){function i(i,e){var n=t.call(this)||this;return n.m=i,n.j=e,n.h=null,n.i=!1,n.g=null,n}return e(i,t),i.prototype.l=function(t){this.h=arguments,this.g?this.i=!0:Yt(this)},i.prototype.M=function(){t.prototype.M.call(this),this.g&&(h.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)},i}(b);function Jt(t){b.call(this),this.h=t,this.g={}}m(Jt,b);var Wt=[];function Vt(t,i,e,n){Array.isArray(e)||(e&&(Wt[0]=e.toString()),e=Wt);for(var r=0;r<e.length;r++){var s=vt(i,e[r],n||t.handleEvent,!1,t.h||t);if(!s)break;t.g[s.key]=s}}function $t(t){L(t.g,function(t,i){this.g.hasOwnProperty(i)&&wt(t)},t),t.g={}}function qt(){this.g=!0}function zt(t,i,e,n,r,s){t.info(function(){if(t.g)if(s)for(var o="",h=s.split("&"),a=0;a<h.length;a++){var l=h[a].split("=");if(1<l.length){var u=l[0];l=l[1];var c=u.split("_");o=2<=c.length&&"type"==c[1]?o+(u+"=")+l+"&":o+(u+"=redacted&")}}else o=null;else o=s;return"XMLHTTP REQ ("+n+") [attempt "+r+"]: "+i+"\n"+e+"\n"+o})}function Zt(t,i,e,n,r,s,o){t.info(function(){return"XMLHTTP RESP ("+n+") [ attempt "+r+"]: "+i+"\n"+e+"\n"+s+" "+o})}function Qt(t,i,e,n){t.info(function(){return"XMLHTTP TEXT ("+i+"): "+ii(t,e)+(n?" "+n:"")})}function ti(t,i){t.info(function(){return"TIMEOUT: "+i})}function ii(t,i){if(!t.g)return i;if(!i)return null;try{var e=JSON.parse(i);if(e)for(t=0;t<e.length;t++)if(Array.isArray(e[t])){var n=e[t];if(!(2>n.length)){var r=n[1];if(Array.isArray(r)&&!(1>r.length)){var s=r[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<r.length;o++)r[o]=""}}}return Rt(e)}catch(h){return i}}Jt.prototype.M=function(){Jt.Z.M.call(this),$t(this)},Jt.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},qt.prototype.Aa=function(){this.g=!1},qt.prototype.info=function(){};var ei={},ni=null;function ri(){return ni=ni||new Ct}function si(t){nt.call(this,ei.Ma,t)}function oi(t){var i=ri();It(i,new si(i,t))}function hi(t,i){nt.call(this,ei.STAT_EVENT,t),this.stat=i}function ai(t){var i=ri();It(i,new hi(i,t))}function li(t,i){nt.call(this,ei.Na,t),this.size=i}function ui(t,i){if("function"!=typeof t)throw Error("Fn must not be null and must be a function");return h.setTimeout(function(){t()},i)}ei.Ma="serverreachability",m(si,nt),ei.STAT_EVENT="statevent",m(hi,nt),ei.Na="timingevent",m(li,nt);var ci={NO_ERROR:0,lb:1,yb:2,xb:3,sb:4,wb:5,zb:6,Ja:7,TIMEOUT:8,Cb:9},fi={qb:"complete",Mb:"success",Ka:"error",Ja:"abort",Eb:"ready",Fb:"readystatechange",TIMEOUT:"timeout",Ab:"incrementaldata",Db:"progress",tb:"downloadprogress",Ub:"uploadprogress"};function gi(){}function pi(t){return t.h||(t.h=t.i())}function vi(){}gi.prototype.h=null;var di,yi={OPEN:"a",pb:"b",Ka:"c",Bb:"d"};function mi(){nt.call(this,"d")}function bi(){nt.call(this,"c")}function wi(){}function Ti(t,i,e,n){this.l=t,this.j=i,this.m=e,this.X=n||1,this.V=new Jt(this),this.P=Si,t=Y?125:void 0,this.W=new Nt(t),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.Y=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.N=-1,this.I=!1,this.O=0,this.L=null,this.aa=this.J=this.$=this.U=!1,this.h=new Ei}function Ei(){this.i=null,this.g="",this.h=!1}m(mi,nt),m(bi,nt),m(wi,gi),wi.prototype.g=function(){return new XMLHttpRequest},wi.prototype.i=function(){return{}},di=new wi;var Si=45e3,xi={},ji={};function Ci(t,i,e){t.K=1,t.v=zi(Gi(i)),t.s=e,t.U=!0,Ii(t,null)}function Ii(t,i){t.F=Date.now(),Pi(t),t.A=Gi(t.v);var e=t.A,n=t.X;Array.isArray(n)||(n=[String(n)]),fe(e.h,"t",n),t.C=0,e=t.l.H,t.h=new Ei,t.g=bn(t.l,e?i:null,!t.s),0<t.O&&(t.L=new Gt(d(t.Ia,t,t.g),t.O)),Vt(t.V,t.g,"readystatechange",t.gb),i=t.H?X(t.H):{},t.s?(t.u||(t.u="POST"),i["Content-Type"]="application/x-www-form-urlencoded",t.g.ea(t.A,t.u,t.s,i)):(t.u="GET",t.g.ea(t.A,t.u,null,i)),oi(1),zt(t.j,t.u,t.A,t.m,t.X,t.s)}function Ai(t){return!!t.g&&("GET"==t.u&&2!=t.K&&t.l.Ba)}function Ri(t,i,e){for(var n,r=!0;!t.I&&t.C<e.length;){if((n=Oi(t,e))==ji){4==i&&(t.o=4,ai(14),r=!1),Qt(t.j,t.m,null,"[Incomplete Response]");break}if(n==xi){t.o=4,ai(15),Qt(t.j,t.m,e,"[Invalid Chunk]"),r=!1;break}Qt(t.j,t.m,n,null),Hi(t,n)}Ai(t)&&n!=ji&&n!=xi&&(t.h.g="",t.C=0),4!=i||0!=e.length||t.h.h||(t.o=1,ai(16),r=!1),t.i=t.i&&r,r?0<e.length&&!t.aa&&(t.aa=!0,(i=t.l).g==t&&i.$&&!i.L&&(i.h.info("Great, no buffering proxy detected. Bytes received: "+e.length),cn(i),i.L=!0,ai(11))):(Qt(t.j,t.m,e,"[Invalid Chunked Response]"),Xi(t),Li(t))}function Oi(t,i){var e=t.C,n=i.indexOf("\n",e);return-1==n?ji:(e=Number(i.substring(e,n)),isNaN(e)?xi:(n+=1)+e>i.length?ji:(i=i.substr(n,e),t.C=n+e,i))}function Pi(t){t.Y=Date.now()+t.P,Di(t,t.P)}function Di(t,i){if(null!=t.B)throw Error("WatchDog timer not null");t.B=ui(d(t.eb,t),i)}function Mi(t){t.B&&(h.clearTimeout(t.B),t.B=null)}function Li(t){0==t.l.G||t.I||pn(t.l,t)}function Xi(t){Mi(t);var i=t.L;i&&"function"==typeof i.na&&i.na(),t.L=null,Ut(t.W),$t(t.V),t.g&&(i=t.g,t.g=null,i.abort(),i.na())}function Hi(t,i){try{var e=t.l;if(0!=e.G&&(e.g==t||we(e.i,t)))if(e.I=t.N,!t.J&&we(e.i,t)&&3==e.G){try{var n=e.Ca.g.parse(i)}catch(s){n=null}if(Array.isArray(n)&&3==n.length){var r=n;if(0==r[0]){t:if(!e.u){if(e.g){if(!(e.g.F+3e3<t.F))break t;gn(e),tn(e)}un(e),ai(18)}}else e.ta=r[1],0<e.ta-e.U&&37500>r[2]&&e.N&&0==e.A&&!e.v&&(e.v=ui(d(e.ab,e),6e3));if(1>=be(e.i)&&e.ka){try{e.ka()}catch(s){}e.ka=void 0}}else dn(e,11)}else if((t.J||e.g==t)&&gn(e),!I(i))for(r=e.Ca.g.parse(i),i=0;i<r.length;i++){var s=r[i];if(e.U=s[0],s=s[1],2==e.G)if("c"==s[0]){e.J=s[1],e.la=s[2];var o=s[3];null!=o&&(e.ma=o,e.h.info("VER="+e.ma));var h=s[4];null!=h&&(e.za=h,e.h.info("SVER="+e.za));var a=s[5];null!=a&&"number"==typeof a&&0<a&&(n=1.5*a,e.K=n,e.h.info("backChannelRequestTimeoutMs_="+n)),n=e;var l=t.g;if(l){var u=l.g?l.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(u){var c=n.i;!c.g&&(O(u,"spdy")||O(u,"quic")||O(u,"h2"))&&(c.j=c.l,c.g=new Set,c.h&&(Te(c,c.h),c.h=null))}if(n.D){var f=l.g?l.g.getResponseHeader("X-HTTP-Session-Id"):null;f&&(n.sa=f,qi(n.F,n.D,f))}}e.G=3,e.j&&e.j.xa(),e.$&&(e.O=Date.now()-t.F,e.h.info("Handshake RTT: "+e.O+"ms"));var g=t;if((n=e).oa=mn(n,n.H?n.la:null,n.W),g.J){Ee(n.i,g);var p=g,v=n.K;v&&p.setTimeout(v),p.B&&(Mi(p),Pi(p)),n.g=g}else ln(n);0<e.l.length&&rn(e)}else"stop"!=s[0]&&"close"!=s[0]||dn(e,7);else 3==e.G&&("stop"==s[0]||"close"==s[0]?"stop"==s[0]?dn(e,7):Qe(e):"noop"!=s[0]&&e.j&&e.j.wa(s),e.A=0)}oi(4)}catch(s){}}function _i(t){if(t.R&&"function"==typeof t.R)return t.R();if("string"==typeof t)return t.split("");if(l(t)){for(var i=[],e=t.length,n=0;n<e;n++)i.push(t[n]);return i}for(n in i=[],e=0,t)i[e++]=t[n];return i}function ki(t,i){if(t.forEach&&"function"==typeof t.forEach)t.forEach(i,void 0);else if(l(t)||"string"==typeof t)S(t,i,void 0);else{if(t.T&&"function"==typeof t.T)var e=t.T();else if(t.R&&"function"==typeof t.R)e=void 0;else if(l(t)||"string"==typeof t){e=[];for(var n=t.length,r=0;r<n;r++)e.push(r)}else for(r in e=[],n=0,t)e[n++]=r;r=(n=_i(t)).length;for(var s=0;s<r;s++)i.call(void 0,n[s],e&&e[s],t)}}function Bi(t,i){this.h={},this.g=[],this.i=0;var e=arguments.length;if(1<e){if(e%2)throw Error("Uneven number of arguments");for(var n=0;n<e;n+=2)this.set(arguments[n],arguments[n+1])}else if(t)if(t instanceof Bi)for(e=t.T(),n=0;n<e.length;n++)this.set(e[n],t.get(e[n]));else for(n in t)this.set(n,t[n])}function Fi(t){if(t.i!=t.g.length){for(var i=0,e=0;i<t.g.length;){var n=t.g[i];Ni(t.h,n)&&(t.g[e++]=n),i++}t.g.length=e}if(t.i!=t.g.length){var r={};for(e=i=0;i<t.g.length;)Ni(r,n=t.g[i])||(t.g[e++]=n,r[n]=1),i++;t.g.length=e}}function Ni(t,i){return Object.prototype.hasOwnProperty.call(t,i)}(r=Ti.prototype).setTimeout=function(t){this.P=t},r.gb=function(t){t=t.target;var i=this.L;i&&3==We(t)?i.l():this.Ia(t)},r.Ia=function(t){try{if(t==this.g)t:{var i=We(this.g),e=this.g.Da(),n=this.g.ba();if(!(3>i)&&(3!=i||Y||this.g&&(this.h.h||this.g.ga()||Ve(this.g)))){this.I||4!=i||7==e||oi(8==e||0>=n?3:2),Mi(this);var r=this.g.ba();this.N=r;i:if(Ai(this)){var s=Ve(this.g);t="";var o=s.length,a=4==We(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Xi(this),Li(this);var l="";break i}this.h.i=new h.TextDecoder}for(e=0;e<o;e++)this.h.h=!0,t+=this.h.i.decode(s[e],{stream:a&&e==o-1});s.splice(0,o),this.h.g+=t,this.C=0,l=this.h.g}else l=this.g.ga();if(this.i=200==r,Zt(this.j,this.u,this.A,this.m,this.X,i,r),this.i){if(this.$&&!this.J){i:{if(this.g){var u,c=this.g;if((u=c.g?c.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!I(u)){var f=u;break i}}f=null}if(!(r=f)){this.i=!1,this.o=3,ai(12),Xi(this),Li(this);break t}Qt(this.j,this.m,r,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,Hi(this,r)}this.U?(Ri(this,i,l),Y&&this.i&&3==i&&(Vt(this.V,this.W,"tick",this.fb),this.W.start())):(Qt(this.j,this.m,l,null),Hi(this,l)),4==i&&Xi(this),this.i&&!this.I&&(4==i?pn(this.l,this):(this.i=!1,Pi(this)))}else 400==r&&0<l.indexOf("Unknown SID")?(this.o=3,ai(12)):(this.o=0,ai(13)),Xi(this),Li(this)}}}catch(i){}},r.fb=function(){if(this.g){var t=We(this.g),i=this.g.ga();this.C<i.length&&(Mi(this),Ri(this,t,i),this.i&&4!=t&&Pi(this))}},r.cancel=function(){this.I=!0,Xi(this)},r.eb=function(){this.B=null;var t=Date.now();0<=t-this.Y?(ti(this.j,this.A),2!=this.K&&(oi(3),ai(17)),Xi(this),this.o=2,Li(this)):Di(this,this.Y-t)},(r=Bi.prototype).R=function(){Fi(this);for(var t=[],i=0;i<this.g.length;i++)t.push(this.h[this.g[i]]);return t},r.T=function(){return Fi(this),this.g.concat()},r.get=function(t,i){return Ni(this.h,t)?this.h[t]:i},r.set=function(t,i){Ni(this.h,t)||(this.i++,this.g.push(t)),this.h[t]=i},r.forEach=function(t,i){for(var e=this.T(),n=0;n<e.length;n++){var r=e[n],s=this.get(r);t.call(i,s,r,this)}};var Ui=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Ki(t,i){if(t){t=t.split("&");for(var e=0;e<t.length;e++){var n=t[e].indexOf("="),r=null;if(0<=n){var s=t[e].substring(0,n);r=t[e].substring(n+1)}else s=t[e];i(s,r?decodeURIComponent(r.replace(/\+/g," ")):"")}}}function Yi(t,i){if(this.i=this.s=this.j="",this.m=null,this.o=this.l="",this.g=!1,t instanceof Yi){this.g=void 0!==i?i:t.g,Ji(this,t.j),this.s=t.s,Wi(this,t.i),Vi(this,t.m),this.l=t.l,i=t.h;var e=new ae;e.i=i.i,i.g&&(e.g=new Bi(i.g),e.h=i.h),$i(this,e),this.o=t.o}else t&&(e=String(t).match(Ui))?(this.g=!!i,Ji(this,e[1]||"",!0),this.s=te(e[2]||""),Wi(this,e[3]||"",!0),Vi(this,e[4]),this.l=te(e[5]||"",!0),$i(this,e[6]||"",!0),this.o=te(e[7]||"")):(this.g=!!i,this.h=new ae(null,this.g))}function Gi(t){return new Yi(t)}function Ji(t,i,e){t.j=e?te(i,!0):i,t.j&&(t.j=t.j.replace(/:$/,""))}function Wi(t,i,e){t.i=e?te(i,!0):i}function Vi(t,i){if(i){if(i=Number(i),isNaN(i)||0>i)throw Error("Bad port number "+i);t.m=i}else t.m=null}function $i(t,i,e){i instanceof ae?(t.h=i,pe(t.h,t.g)):(e||(i=ie(i,oe)),t.h=new ae(i,t.g))}function qi(t,i,e){t.h.set(i,e)}function zi(t){return qi(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),t}function Zi(t){return t instanceof Yi?Gi(t):new Yi(t,void 0)}function Qi(t,i,e,n){var r=new Yi(null,void 0);return t&&Ji(r,t),i&&Wi(r,i),e&&Vi(r,e),n&&(r.l=n),r}function te(t,i){return t?i?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function ie(t,i,e){return"string"==typeof t?(t=encodeURI(t).replace(i,ee),e&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function ee(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}Yi.prototype.toString=function(){var t=[],i=this.j;i&&t.push(ie(i,ne,!0),":");var e=this.i;return(e||"file"==i)&&(t.push("//"),(i=this.s)&&t.push(ie(i,ne,!0),"@"),t.push(encodeURIComponent(String(e)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(e=this.m)&&t.push(":",String(e))),(e=this.l)&&(this.i&&"/"!=e.charAt(0)&&t.push("/"),t.push(ie(e,"/"==e.charAt(0)?se:re,!0))),(e=this.h.toString())&&t.push("?",e),(e=this.o)&&t.push("#",ie(e,he)),t.join("")};var ne=/[#\/\?@]/g,re=/[#\?:]/g,se=/[#\?]/g,oe=/[#\?@]/g,he=/#/g;function ae(t,i){this.h=this.g=null,this.i=t||null,this.j=!!i}function le(t){t.g||(t.g=new Bi,t.h=0,t.i&&Ki(t.i,function(i,e){t.add(decodeURIComponent(i.replace(/\+/g," ")),e)}))}function ue(t,i){le(t),i=ge(t,i),Ni(t.g.h,i)&&(t.i=null,t.h-=t.g.get(i).length,Ni((t=t.g).h,i)&&(delete t.h[i],t.i--,t.g.length>2*t.i&&Fi(t)))}function ce(t,i){return le(t),i=ge(t,i),Ni(t.g.h,i)}function fe(t,i,e){ue(t,i),0<e.length&&(t.i=null,t.g.set(ge(t,i),C(e)),t.h+=e.length)}function ge(t,i){return i=String(i),t.j&&(i=i.toLowerCase()),i}function pe(t,i){i&&!t.j&&(le(t),t.i=null,t.g.forEach(function(t,i){var e=i.toLowerCase();i!=e&&(ue(this,i),fe(this,e,t))},t)),t.j=i}(r=ae.prototype).add=function(t,i){le(this),this.i=null,t=ge(this,t);var e=this.g.get(t);return e||this.g.set(t,e=[]),e.push(i),this.h+=1,this},r.forEach=function(t,i){le(this),this.g.forEach(function(e,n){S(e,function(e){t.call(i,e,n,this)},this)},this)},r.T=function(){le(this);for(var t=this.g.R(),i=this.g.T(),e=[],n=0;n<i.length;n++)for(var r=t[n],s=0;s<r.length;s++)e.push(i[n]);return e},r.R=function(t){le(this);var i=[];if("string"==typeof t)ce(this,t)&&(i=j(i,this.g.get(ge(this,t))));else{t=this.g.R();for(var e=0;e<t.length;e++)i=j(i,t[e])}return i},r.set=function(t,i){return le(this),this.i=null,ce(this,t=ge(this,t))&&(this.h-=this.g.get(t).length),this.g.set(t,[i]),this.h+=1,this},r.get=function(t,i){return t&&0<(t=this.R(t)).length?String(t[0]):i},r.toString=function(){if(this.i)return this.i;if(!this.g)return"";for(var t=[],i=this.g.T(),e=0;e<i.length;e++){var n=i[e],r=encodeURIComponent(String(n));n=this.R(n);for(var s=0;s<n.length;s++){var o=r;""!==n[s]&&(o+="="+encodeURIComponent(String(n[s]))),t.push(o)}}return this.i=t.join("&")};var ve=function(){return function(t,i){this.h=t,this.g=i}}();function de(t){this.l=t||ye,h.PerformanceNavigationTiming?t=0<(t=h.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):t=!!(h.g&&h.g.Ea&&h.g.Ea()&&h.g.Ea().Zb),this.j=t?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}var ye=10;function me(t){return!!t.h||!!t.g&&t.g.size>=t.j}function be(t){return t.h?1:t.g?t.g.size:0}function we(t,i){return t.h?t.h==i:!!t.g&&t.g.has(i)}function Te(t,i){t.g?t.g.add(i):t.h=i}function Ee(t,i){t.h&&t.h==i?t.h=null:t.g&&t.g.has(i)&&t.g.delete(i)}function Se(t){var i,e;if(null!=t.h)return t.i.concat(t.h.D);if(null!=t.g&&0!==t.g.size){var r=t.i;try{for(var s=n(t.g.values()),o=s.next();!o.done;o=s.next()){var h=o.value;r=r.concat(h.D)}}catch(a){i={error:a}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(i)throw i.error}}return r}return C(t.i)}function xe(){}function je(){this.g=new xe}function Ce(t,i,e){var n=e||"";try{ki(t,function(t,e){var r=t;u(t)&&(r=Rt(t)),i.push(n+e+"="+encodeURIComponent(r))})}catch(r){throw i.push(n+"type="+encodeURIComponent("_badmap")),r}}function Ie(t,i){var e=new qt;if(h.Image){var n=new Image;n.onload=y(Ae,e,n,"TestLoadImage: loaded",!0,i),n.onerror=y(Ae,e,n,"TestLoadImage: error",!1,i),n.onabort=y(Ae,e,n,"TestLoadImage: abort",!1,i),n.ontimeout=y(Ae,e,n,"TestLoadImage: timeout",!1,i),h.setTimeout(function(){n.ontimeout&&n.ontimeout()},1e4),n.src=t}else i(!1)}function Ae(t,i,e,n,r){try{i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null,r(n)}catch(s){}}function Re(t){this.l=t.$b||null,this.j=t.ib||!1}function Oe(t,i){Ct.call(this),this.D=t,this.u=i,this.m=void 0,this.readyState=Pe,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}de.prototype.cancel=function(){var t,i;if(this.i=Se(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){try{for(var e=n(this.g.values()),r=e.next();!r.done;r=e.next()){r.value.cancel()}}catch(s){t={error:s}}finally{try{r&&!r.done&&(i=e.return)&&i.call(e)}finally{if(t)throw t.error}}this.g.clear()}},xe.prototype.stringify=function(t){return h.JSON.stringify(t,void 0)},xe.prototype.parse=function(t){return h.JSON.parse(t,void 0)},m(Re,gi),Re.prototype.g=function(){return new Oe(this.l,this.j)},Re.prototype.i=function(t){return function(){return t}}({}),m(Oe,Ct);var Pe=0;function De(t){t.j.read().then(t.Sa.bind(t)).catch(t.ha.bind(t))}function Me(t){t.readyState=4,t.l=null,t.j=null,t.A=null,Le(t)}function Le(t){t.onreadystatechange&&t.onreadystatechange.call(t)}(r=Oe.prototype).open=function(t,i){if(this.readyState!=Pe)throw this.abort(),Error("Error reopening a connection");this.C=t,this.B=i,this.readyState=1,Le(this)},r.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;var i={headers:this.v,method:this.C,credentials:this.m,cache:void 0};t&&(i.body=t),(this.D||h).fetch(new Request(this.B,i)).then(this.Va.bind(this),this.ha.bind(this))},r.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted."),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,Me(this)),this.readyState=Pe},r.Va=function(t){if(this.g&&(this.l=t,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=t.headers,this.readyState=2,Le(this)),this.g&&(this.readyState=3,Le(this),this.g)))if("arraybuffer"===this.responseType)t.arrayBuffer().then(this.Ta.bind(this),this.ha.bind(this));else if(void 0!==h.ReadableStream&&"body"in t){if(this.j=t.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;De(this)}else t.text().then(this.Ua.bind(this),this.ha.bind(this))},r.Sa=function(t){if(this.g){if(this.u&&t.value)this.response.push(t.value);else if(!this.u){var i=t.value?t.value:new Uint8Array(0);(i=this.A.decode(i,{stream:!t.done}))&&(this.response=this.responseText+=i)}t.done?Me(this):Le(this),3==this.readyState&&De(this)}},r.Ua=function(t){this.g&&(this.response=this.responseText=t,Me(this))},r.Ta=function(t){this.g&&(this.response=t,Me(this))},r.ha=function(){this.g&&Me(this)},r.setRequestHeader=function(t,i){this.v.append(t,i)},r.getResponseHeader=function(t){return this.h&&this.h.get(t.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";for(var t=[],i=this.h.entries(),e=i.next();!e.done;)e=e.value,t.push(e[0]+": "+e[1]),e=i.next();return t.join("\r\n")},Object.defineProperty(Oe.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(t){this.m=t?"include":"same-origin"}});var Xe=h.JSON.parse;function He(t){Ct.call(this),this.headers=new Bi,this.u=t||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=_e,this.K=this.L=!1}m(He,Ct);var _e="",ke=/^https?$/i,Be=["POST","PUT"];function Fe(t){return U&&Q()&&"number"==typeof t.timeout&&void 0!==t.ontimeout}function Ne(t){return"content-type"==t.toLowerCase()}function Ue(t,i){t.h=!1,t.g&&(t.l=!0,t.g.abort(),t.l=!1),t.j=i,t.m=5,Ke(t),Ge(t)}function Ke(t){t.D||(t.D=!0,It(t,"complete"),It(t,"error"))}function Ye(t){if(t.h&&void 0!==o&&(!t.C[1]||4!=We(t)||2!=t.ba()))if(t.v&&4==We(t))Kt(t.Fa,0,t);else if(It(t,"readystatechange"),4==We(t)){t.h=!1;try{var i,e=t.ba();t:switch(e){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var n=!0;break t;default:n=!1}if(!(i=n)){var r;if(r=0===e){var s=String(t.H).match(Ui)[1]||null;if(!s&&h.self&&h.self.location){var a=h.self.location.protocol;s=a.substr(0,a.length-1)}r=!ke.test(s?s.toLowerCase():"")}i=r}if(i)It(t,"complete"),It(t,"success");else{t.m=6;try{var l=2<We(t)?t.g.statusText:""}catch(u){l=""}t.j=l+" ["+t.ba()+"]",Ke(t)}}finally{Ge(t)}}}function Ge(t,i){if(t.g){Je(t);var e=t.g,n=t.C[0]?a:null;t.g=null,t.C=null,i||It(t,"ready");try{e.onreadystatechange=n}catch(r){}}}function Je(t){t.g&&t.K&&(t.g.ontimeout=null),t.A&&(h.clearTimeout(t.A),t.A=null)}function We(t){return t.g?t.g.readyState:0}function Ve(t){try{if(!t.g)return null;if("response"in t.g)return t.g.response;switch(t.J){case _e:case"text":return t.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in t.g)return t.g.mozResponseArrayBuffer}return null}catch(i){return null}}function $e(t){var i="";return L(t,function(t,e){i+=e,i+=":",i+=t,i+="\r\n"}),i}function qe(t,i,e){t:{for(n in e){var n=!1;break t}n=!0}n||(e=$e(e),"string"==typeof t?null!=e&&encodeURIComponent(String(e)):qi(t,i,e))}function ze(t,i,e){return e&&e.internalChannelParams&&e.internalChannelParams[t]||i}function Ze(t){this.za=0,this.l=[],this.h=new qt,this.la=this.oa=this.F=this.W=this.g=this.sa=this.D=this.aa=this.o=this.P=this.s=null,this.Za=this.V=0,this.Xa=ze("failFast",!1,t),this.N=this.v=this.u=this.m=this.j=null,this.X=!0,this.I=this.ta=this.U=-1,this.Y=this.A=this.C=0,this.Pa=ze("baseRetryDelayMs",5e3,t),this.$a=ze("retryDelaySeedMs",1e4,t),this.Ya=ze("forwardChannelMaxRetries",2,t),this.ra=ze("forwardChannelRequestTimeoutMs",2e4,t),this.qa=t&&t.xmlHttpFactory||void 0,this.Ba=t&&t.Yb||!1,this.K=void 0,this.H=t&&t.supportsCrossDomainXhr||!1,this.J="",this.i=new de(t&&t.concurrentRequestLimit),this.Ca=new je,this.ja=t&&t.fastHandshake||!1,this.Ra=t&&t.Wb||!1,t&&t.Aa&&this.h.Aa(),t&&t.forceLongPolling&&(this.X=!1),this.$=!this.ja&&this.X&&t&&t.detectBufferingProxy||!1,this.ka=void 0,this.O=0,this.L=!1,this.B=null,this.Wa=!t||!1!==t.Xb}function Qe(t){if(en(t),3==t.G){var i=t.V++,e=Gi(t.F);qi(e,"SID",t.J),qi(e,"RID",i),qi(e,"TYPE","terminate"),hn(t,e),(i=new Ti(t,t.h,i,void 0)).K=2,i.v=zi(Gi(e)),e=!1,h.navigator&&h.navigator.sendBeacon&&(e=h.navigator.sendBeacon(i.v.toString(),"")),!e&&h.Image&&((new Image).src=i.v,e=!0),e||(i.g=bn(i.l,null),i.g.ea(i.v)),i.F=Date.now(),Pi(i)}yn(t)}function tn(t){t.g&&(cn(t),t.g.cancel(),t.g=null)}function en(t){tn(t),t.u&&(h.clearTimeout(t.u),t.u=null),gn(t),t.i.cancel(),t.m&&("number"==typeof t.m&&h.clearTimeout(t.m),t.m=null)}function nn(t,i){t.l.push(new ve(t.Za++,i)),3==t.G&&rn(t)}function rn(t){me(t.i)||t.m||(t.m=!0,Ht(t.Ha,t),t.C=0)}function sn(t,i){return!(be(t.i)>=t.i.j-(t.m?1:0))&&(t.m?(t.l=i.D.concat(t.l),!0):!(1==t.G||2==t.G||t.C>=(t.Xa?0:t.Ya))&&(t.m=ui(d(t.Ha,t,i),vn(t,t.C)),t.C++,!0))}function on(t,i){var e;e=i?i.m:t.V++;var n=Gi(t.F);qi(n,"SID",t.J),qi(n,"RID",e),qi(n,"AID",t.U),hn(t,n),t.o&&t.s&&qe(n,t.o,t.s),e=new Ti(t,t.h,e,t.C+1),null===t.o&&(e.H=t.s),i&&(t.l=i.D.concat(t.l)),i=an(t,e,1e3),e.setTimeout(Math.round(.5*t.ra)+Math.round(.5*t.ra*Math.random())),Te(t.i,e),Ci(e,n,i)}function hn(t,i){t.j&&ki({},function(t,e){qi(i,e,t)})}function an(t,i,e){e=Math.min(t.l.length,e);var n=t.j?d(t.j.Oa,t.j,t):null;t:for(var r=t.l,s=-1;;){var o=["count="+e];-1==s?0<e?(s=r[0].h,o.push("ofs="+s)):s=0:o.push("ofs="+s);for(var h=!0,a=0;a<e;a++){var l=r[a].h,u=r[a].g;if(0>(l-=s))s=Math.max(0,r[a].h-100),h=!1;else try{Ce(u,o,"req"+l+"_")}catch(c){n&&n(u)}}if(h){n=o.join("&");break t}}return t=t.l.splice(0,e),i.D=t,n}function ln(t){t.g||t.u||(t.Y=1,Ht(t.Ga,t),t.A=0)}function un(t){return!(t.g||t.u||3<=t.A)&&(t.Y++,t.u=ui(d(t.Ga,t),vn(t,t.A)),t.A++,!0)}function cn(t){null!=t.B&&(h.clearTimeout(t.B),t.B=null)}function fn(t){t.g=new Ti(t,t.h,"rpc",t.Y),null===t.o&&(t.g.H=t.s),t.g.O=0;var i=Gi(t.oa);qi(i,"RID","rpc"),qi(i,"SID",t.J),qi(i,"CI",t.N?"0":"1"),qi(i,"AID",t.U),hn(t,i),qi(i,"TYPE","xmlhttp"),t.o&&t.s&&qe(i,t.o,t.s),t.K&&t.g.setTimeout(t.K);var e=t.g;t=t.la,e.K=1,e.v=zi(Gi(i)),e.s=null,e.U=!0,Ii(e,t)}function gn(t){null!=t.v&&(h.clearTimeout(t.v),t.v=null)}function pn(t,i){var e=null;if(t.g==i){gn(t),cn(t),t.g=null;var n=2}else{if(!we(t.i,i))return;e=i.D,Ee(t.i,i),n=1}if(t.I=i.N,0!=t.G)if(i.i)if(1==n){e=i.s?i.s.length:0,i=Date.now()-i.F;var r=t.C;It(n=ri(),new li(n,e,i,r)),rn(t)}else ln(t);else if(3==(r=i.o)||0==r&&0<t.I||!(1==n&&sn(t,i)||2==n&&un(t)))switch(e&&0<e.length&&(i=t.i,i.i=i.i.concat(e)),r){case 1:dn(t,5);break;case 4:dn(t,10);break;case 3:dn(t,6);break;default:dn(t,2)}}function vn(t,i){var e=t.Pa+Math.floor(Math.random()*t.$a);return t.j||(e*=2),e*i}function dn(t,i){if(t.h.info("Error code "+i),2==i){var e=null;t.j&&(e=null);var n=d(t.jb,t);e||(e=new Yi("//www.google.com/images/cleardot.gif"),h.location&&"http"==h.location.protocol||Ji(e,"https"),zi(e)),Ie(e.toString(),n)}else ai(2);t.G=0,t.j&&t.j.va(i),yn(t),en(t)}function yn(t){t.G=0,t.I=-1,t.j&&(0==Se(t.i).length&&0==t.l.length||(t.i.i.length=0,C(t.l),t.l.length=0),t.j.ua())}function mn(t,i,e){var n=Zi(e);if(""!=n.i)i&&Wi(n,i+"."+n.i),Vi(n,n.m);else{var r=h.location;n=Qi(r.protocol,i?i+"."+r.hostname:r.hostname,+r.port,e)}return t.aa&&L(t.aa,function(t,i){qi(n,i,t)}),i=t.D,e=t.sa,i&&e&&qi(n,i,e),qi(n,"VER",t.ma),hn(t,n),n}function bn(t,i,e){if(i&&!t.H)throw Error("Can't create secondary domain capable XhrIo object.");return(i=e&&t.Ba&&!t.qa?new He(new Re({ib:!0})):new He(t.qa)).L=t.H,i}function wn(){}function Tn(){if(U&&!(10<=Number(it)))throw Error("Environmental error: no available transport.")}function En(t,i){Ct.call(this),this.g=new Ze(i),this.l=t,this.h=i&&i.messageUrlParams||null,t=i&&i.messageHeaders||null,i&&i.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.g.s=t,t=i&&i.initMessageHeaders||null,i&&i.messageContentType&&(t?t["X-WebChannel-Content-Type"]=i.messageContentType:t={"X-WebChannel-Content-Type":i.messageContentType}),i&&i.ya&&(t?t["X-WebChannel-Client-Profile"]=i.ya:t={"X-WebChannel-Client-Profile":i.ya}),this.g.P=t,(t=i&&i.httpHeadersOverwriteParam)&&!I(t)&&(this.g.o=t),this.A=i&&i.supportsCrossDomainXhr||!1,this.v=i&&i.sendRawJson||!1,(i=i&&i.httpSessionIdParam)&&!I(i)&&(this.g.D=i,null!==(t=this.h)&&i in t&&(i in(t=this.h)&&delete t[i])),this.j=new jn(this)}function Sn(t){mi.call(this);var i=t.__sm__;if(i){t:{for(var e in i){t=e;break t}t=void 0}(this.i=t)&&(t=this.i,i=null!==i&&t in i?i[t]:void 0),this.data=i}else this.data=t}function xn(){bi.call(this),this.status=1}function jn(t){this.g=t}(r=He.prototype).ea=function(t,i,e,n){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+t);i=i?i.toUpperCase():"GET",this.H=t,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=this.u?this.u.g():di.g(),this.C=this.u?pi(this.u):pi(di),this.g.onreadystatechange=d(this.Fa,this);try{this.F=!0,this.g.open(i,String(t),!0),this.F=!1}catch(s){return void Ue(this,s)}t=e||"";var r=new Bi(this.headers);n&&ki(n,function(t,i){r.set(i,t)}),n=x(r.T()),e=h.FormData&&t instanceof h.FormData,!(0<=E(Be,i))||n||e||r.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),r.forEach(function(t,i){this.g.setRequestHeader(i,t)},this),this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{Je(this),0<this.B&&((this.K=Fe(this.g))?(this.g.timeout=this.B,this.g.ontimeout=d(this.pa,this)):this.A=Kt(this.pa,this.B,this)),this.v=!0,this.g.send(t),this.v=!1}catch(s){Ue(this,s)}},r.pa=function(){void 0!==o&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,It(this,"timeout"),this.abort(8))},r.abort=function(t){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=t||7,It(this,"complete"),It(this,"abort"),Ge(this))},r.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),Ge(this,!0)),He.Z.M.call(this)},r.Fa=function(){this.s||(this.F||this.v||this.l?Ye(this):this.cb())},r.cb=function(){Ye(this)},r.ba=function(){try{return 2<We(this)?this.g.status:-1}catch(t){return-1}},r.ga=function(){try{return this.g?this.g.responseText:""}catch(t){return""}},r.Qa=function(t){if(this.g){var i=this.g.responseText;return t&&0==i.indexOf(t)&&(i=i.substring(t.length)),Xe(i)}},r.Da=function(){return this.m},r.La=function(){return"string"==typeof this.j?this.j:String(this.j)},(r=Ze.prototype).ma=8,r.G=1,r.hb=function(t){try{this.h.info("Origin Trials invoked: "+t)}catch(i){}},r.Ha=function(t){if(this.m)if(this.m=null,1==this.G){if(!t){this.V=Math.floor(1e5*Math.random()),t=this.V++;var i=new Ti(this,this.h,t,void 0),e=this.s;if(this.P&&(e?_(e=X(e),this.P):e=this.P),null===this.o&&(i.H=e),this.ja)t:{for(var n=0,r=0;r<this.l.length;r++){var s=this.l[r];if(void 0===(s="__data__"in s.g&&"string"==typeof(s=s.g.__data__)?s.length:void 0))break;if(4096<(n+=s)){n=r;break t}if(4096===n||r===this.l.length-1){n=r+1;break t}}n=1e3}else n=1e3;n=an(this,i,n),qi(r=Gi(this.F),"RID",t),qi(r,"CVER",22),this.D&&qi(r,"X-HTTP-Session-Id",this.D),hn(this,r),this.o&&e&&qe(r,this.o,e),Te(this.i,i),this.Ra&&qi(r,"TYPE","init"),this.ja?(qi(r,"$req",n),qi(r,"SID","null"),i.$=!0,Ci(i,r,null)):Ci(i,r,n),this.G=2}}else 3==this.G&&(t?on(this,t):0==this.l.length||me(this.i)||on(this))},r.Ga=function(){if(this.u=null,fn(this),this.$&&!(this.L||null==this.g||0>=this.O)){var t=2*this.O;this.h.info("BP detection timer enabled: "+t),this.B=ui(d(this.bb,this),t)}},r.bb=function(){this.B&&(this.B=null,this.h.info("BP detection timeout reached."),this.h.info("Buffering proxy detected and switch to long-polling!"),this.N=!1,this.L=!0,ai(10),tn(this),fn(this))},r.ab=function(){null!=this.v&&(this.v=null,tn(this),un(this),ai(19))},r.jb=function(t){t?(this.h.info("Successfully pinged google.com"),ai(2)):(this.h.info("Failed to ping google.com"),ai(1))},(r=wn.prototype).xa=function(){},r.wa=function(){},r.va=function(){},r.ua=function(){},r.Oa=function(){},Tn.prototype.g=function(t,i){return new En(t,i)},m(En,Ct),En.prototype.m=function(){this.g.j=this.j,this.A&&(this.g.H=!0);var t=this.g,i=this.l,e=this.h||void 0;t.Wa&&(t.h.info("Origin Trials enabled."),Ht(d(t.hb,t,i))),ai(0),t.W=i,t.aa=e||{},t.N=t.X,t.F=mn(t,null,t.W),rn(t)},En.prototype.close=function(){Qe(this.g)},En.prototype.u=function(t){if("string"==typeof t){var i={};i.__data__=t,nn(this.g,i)}else this.v?((i={}).__data__=Rt(t),nn(this.g,i)):nn(this.g,t)},En.prototype.M=function(){this.g.j=null,delete this.j,Qe(this.g),delete this.g,En.Z.M.call(this)},m(Sn,mi),m(xn,bi),m(jn,wn),jn.prototype.xa=function(){It(this.g,"a")},jn.prototype.wa=function(t){It(this.g,new Sn(t))},jn.prototype.va=function(t){It(this.g,new xn(t))},jn.prototype.ua=function(){It(this.g,"b")},Tn.prototype.createWebChannel=Tn.prototype.g,En.prototype.send=En.prototype.u,En.prototype.open=En.prototype.m,En.prototype.close=En.prototype.close,ci.NO_ERROR=0,ci.TIMEOUT=8,ci.HTTP_ERROR=6,fi.COMPLETE="complete",vi.EventType=yi,yi.OPEN="a",yi.CLOSE="b",yi.ERROR="c",yi.MESSAGE="d",Ct.prototype.listen=Ct.prototype.N,He.prototype.listenOnce=He.prototype.O,He.prototype.getLastError=He.prototype.La,He.prototype.getLastErrorCode=He.prototype.Da,He.prototype.getStatus=He.prototype.ba,He.prototype.getResponseJson=He.prototype.Qa,He.prototype.getResponseText=He.prototype.ga,He.prototype.send=He.prototype.ea;var Cn=function(){return new Tn};exports.createWebChannelTransport=Cn;var In=function(){return ri()};exports.getStatEventTarget=In;var An=ci;exports.ErrorCode=An;var Rn=fi;exports.EventType=Rn;var On=ei;exports.Event=On;var Pn={rb:0,ub:1,vb:2,Ob:3,Tb:4,Qb:5,Rb:6,Pb:7,Nb:8,Sb:9,PROXY:10,NOPROXY:11,Lb:12,Hb:13,Ib:14,Gb:15,Jb:16,Kb:17,nb:18,mb:19,ob:20};exports.Stat=Pn;var Dn=Re;exports.FetchXmlHttpFactory=Dn;var Mn=vi;exports.WebChannel=Mn;var Ln=He;exports.XhrIo=Ln;var Xn={createWebChannelTransport:Cn,getStatEventTarget:In,ErrorCode:An,EventType:Rn,Event:On,Stat:Pn,FetchXmlHttpFactory:Dn,WebChannel:Mn,XhrIo:Ln},Hn=Xn;exports.default=Hn;
|
|
491
|
-
},{}],"
|
|
503
|
+
var t=arguments[3];Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStatEventTarget=exports.default=exports.createWebChannelTransport=exports.XhrIo=exports.WebChannel=exports.Stat=exports.FetchXmlHttpFactory=exports.EventType=exports.Event=exports.ErrorCode=void 0;var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},i={};exports.default=i;var n,s=s||{},r=e||self;function o(){}function h(t){var e=typeof t;return"array"==(e="object"!=e?e:t?Array.isArray(t)?"array":e:"null")||"object"==e&&"number"==typeof t.length}function a(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}function l(t){return Object.prototype.hasOwnProperty.call(t,u)&&t[u]||(t[u]=++c)}var u="closure_uid_"+(1e9*Math.random()>>>0),c=0;function f(t,e,i){return t.call.apply(t.bind,arguments)}function g(t,e,i){if(!t)throw Error();if(2<arguments.length){var n=Array.prototype.slice.call(arguments,2);return function(){var i=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(i,n),t.apply(e,i)}}return function(){return t.apply(e,arguments)}}function p(t,e,i){return(p=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?f:g).apply(null,arguments)}function d(t,e){var i=Array.prototype.slice.call(arguments,1);return function(){var e=i.slice();return e.push.apply(e,arguments),t.apply(this,e)}}function y(t,e){function i(){}i.prototype=e.prototype,t.X=e.prototype,t.prototype=new i,t.prototype.constructor=t,t.Wb=function(t,i,n){for(var s=Array(arguments.length-2),r=2;r<arguments.length;r++)s[r-2]=arguments[r];return e.prototype[i].apply(t,s)}}function v(){this.s=this.s,this.o=this.o}var m=0;v.prototype.s=!1,v.prototype.na=function(){this.s||(this.s=!0,this.M(),0==m)||l(this)},v.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};const b=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if("string"==typeof t)return"string"!=typeof e||1!=e.length?-1:t.indexOf(e,0);for(let i=0;i<t.length;i++)if(i in t&&t[i]===e)return i;return-1};function w(t){const e=t.length;if(0<e){const i=Array(e);for(let n=0;n<e;n++)i[n]=t[n];return i}return[]}function T(t,e){for(let i=1;i<arguments.length;i++){const e=arguments[i];if(h(e)){const i=t.length||0,n=e.length||0;t.length=i+n;for(let s=0;s<n;s++)t[i+s]=e[s]}else t.push(e)}}function E(t,e){this.type=t,this.g=this.target=e,this.defaultPrevented=!1}E.prototype.h=function(){this.defaultPrevented=!0};var S=function(){if(!r.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{r.addEventListener("test",o,e),r.removeEventListener("test",o,e)}catch(i){}return t}();function x(t){return/^[\s\xa0]*$/.test(t)}var j=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function C(t,e){return t<e?-1:t>e?1:0}function I(){var t=r.navigator;return t&&(t=t.userAgent)?t:""}function A(t){return-1!=I().indexOf(t)}function R(t){return R[" "](t),t}function O(t){var e=K;return Object.prototype.hasOwnProperty.call(e,9)?e[9]:e[9]=t(9)}R[" "]=o;var P,M=A("Opera"),D=A("Trident")||A("MSIE"),L=A("Edge"),X=L||D,k=A("Gecko")&&!(-1!=I().toLowerCase().indexOf("webkit")&&!A("Edge"))&&!(A("Trident")||A("MSIE"))&&!A("Edge"),H=-1!=I().toLowerCase().indexOf("webkit")&&!A("Edge");function _(){var t=r.document;return t?t.documentMode:void 0}t:{var B="",F=function(){var t=I();return k?/rv:([^\);]+)(\)|;)/.exec(t):L?/Edge\/([\d\.]+)/.exec(t):D?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(t):H?/WebKit\/(\S+)/.exec(t):M?/(?:Version)[ \/]?(\S+)/.exec(t):void 0}();if(F&&(B=F?F[1]:""),D){var N=_();if(null!=N&&N>parseFloat(B)){P=String(N);break t}}P=B}var U,K={};function Y(){return O(function(){let t=0;const e=j(String(P)).split("."),i=j("9").split("."),n=Math.max(e.length,i.length);for(let o=0;0==t&&o<n;o++){var s=e[o]||"",r=i[o]||"";do{if(s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],r=/(\d*)(\D*)(.*)/.exec(r)||["","","",""],0==s[0].length&&0==r[0].length)break;t=C(0==s[1].length?0:parseInt(s[1],10),0==r[1].length?0:parseInt(r[1],10))||C(0==s[2].length,0==r[2].length)||C(s[2],r[2]),s=s[3],r=r[3]}while(0==t)}return 0<=t})}if(r.document&&D){var G=_();U=G||(parseInt(P,10)||void 0)}else U=void 0;var J=U;function W(t,e){if(E.call(this,t?t.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,t){var i=this.type=t.type,n=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.g=e,e=t.relatedTarget){if(k){t:{try{R(e.nodeName);var s=!0;break t}catch(r){}s=!1}s||(e=null)}}else"mouseover"==i?e=t.fromElement:"mouseout"==i&&(e=t.toElement);this.relatedTarget=e,n?(this.clientX=void 0!==n.clientX?n.clientX:n.pageX,this.clientY=void 0!==n.clientY?n.clientY:n.pageY,this.screenX=n.screenX||0,this.screenY=n.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:V[t.pointerType]||"",this.state=t.state,this.i=t,t.defaultPrevented&&W.X.h.call(this)}}y(W,E);var V={2:"touch",3:"pen",4:"mouse"};W.prototype.h=function(){W.X.h.call(this);var t=this.i;t.preventDefault?t.preventDefault():t.returnValue=!1};var $="closure_listenable_"+(1e6*Math.random()|0),q=0;function z(t,e,i,n,s){this.listener=t,this.proxy=null,this.src=e,this.type=i,this.capture=!!n,this.ha=s,this.key=++q,this.ba=this.ea=!1}function Z(t){t.ba=!0,t.listener=null,t.proxy=null,t.src=null,t.ha=null}function Q(t,e,i){for(const n in t)e.call(i,t[n],n,t)}function tt(t){const e={};for(const i in t)e[i]=t[i];return e}const et="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function it(t,e){let i,n;for(let s=1;s<arguments.length;s++){for(i in n=arguments[s])t[i]=n[i];for(let e=0;e<et.length;e++)i=et[e],Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}}function nt(t){this.src=t,this.g={},this.h=0}function st(t,e){var i=e.type;if(i in t.g){var n,s=t.g[i],r=b(s,e);(n=0<=r)&&Array.prototype.splice.call(s,r,1),n&&(Z(e),0==t.g[i].length&&(delete t.g[i],t.h--))}}function rt(t,e,i,n){for(var s=0;s<t.length;++s){var r=t[s];if(!r.ba&&r.listener==e&&r.capture==!!i&&r.ha==n)return s}return-1}nt.prototype.add=function(t,e,i,n,s){var r=t.toString();(t=this.g[r])||(t=this.g[r]=[],this.h++);var o=rt(t,e,n,s);return-1<o?(e=t[o],i||(e.ea=!1)):((e=new z(e,this.src,r,!!n,s)).ea=i,t.push(e)),e};var ot="closure_lm_"+(1e6*Math.random()|0),ht={};function at(t,e,i,n,s){if(n&&n.once)return ct(t,e,i,n,s);if(Array.isArray(e)){for(var r=0;r<e.length;r++)at(t,e[r],i,n,s);return null}return i=mt(i),t&&t[$]?t.N(e,i,a(n)?!!n.capture:!!n,s):lt(t,e,i,!1,n,s)}function lt(t,e,i,n,s,r){if(!e)throw Error("Invalid event type");var o=a(s)?!!s.capture:!!s,h=yt(t);if(h||(t[ot]=h=new nt(t)),(i=h.add(e,i,n,o,r)).proxy)return i;if(n=ut(),i.proxy=n,n.src=t,n.listener=i,t.addEventListener)S||(s=o),void 0===s&&(s=!1),t.addEventListener(e.toString(),n,s);else if(t.attachEvent)t.attachEvent(pt(e.toString()),n);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(n)}return i}function ut(){const t=dt;return function e(i){return t.call(e.src,e.listener,i)}}function ct(t,e,i,n,s){if(Array.isArray(e)){for(var r=0;r<e.length;r++)ct(t,e[r],i,n,s);return null}return i=mt(i),t&&t[$]?t.O(e,i,a(n)?!!n.capture:!!n,s):lt(t,e,i,!0,n,s)}function ft(t,e,i,n,s){if(Array.isArray(e))for(var r=0;r<e.length;r++)ft(t,e[r],i,n,s);else n=a(n)?!!n.capture:!!n,i=mt(i),t&&t[$]?(t=t.i,(e=String(e).toString())in t.g&&(-1<(i=rt(r=t.g[e],i,n,s))&&(Z(r[i]),Array.prototype.splice.call(r,i,1),0==r.length&&(delete t.g[e],t.h--)))):t&&(t=yt(t))&&(e=t.g[e.toString()],t=-1,e&&(t=rt(e,i,n,s)),(i=-1<t?e[t]:null)&>(i))}function gt(t){if("number"!=typeof t&&t&&!t.ba){var e=t.src;if(e&&e[$])st(e.i,t);else{var i=t.type,n=t.proxy;e.removeEventListener?e.removeEventListener(i,n,t.capture):e.detachEvent?e.detachEvent(pt(i),n):e.addListener&&e.removeListener&&e.removeListener(n),(i=yt(e))?(st(i,t),0==i.h&&(i.src=null,e[ot]=null)):Z(t)}}}function pt(t){return t in ht?ht[t]:ht[t]="on"+t}function dt(t,e){if(t.ba)t=!0;else{e=new W(e,this);var i=t.listener,n=t.ha||t.src;t.ea&>(t),t=i.call(n,e)}return t}function yt(t){return(t=t[ot])instanceof nt?t:null}var vt="__closure_events_fn_"+(1e9*Math.random()>>>0);function mt(t){return"function"==typeof t?t:(t[vt]||(t[vt]=function(e){return t.handleEvent(e)}),t[vt])}function bt(){v.call(this),this.i=new nt(this),this.P=this,this.I=null}function wt(t,e){var i,n=t.I;if(n)for(i=[];n;n=n.I)i.push(n);if(t=t.P,n=e.type||e,"string"==typeof e)e=new E(e,t);else if(e instanceof E)e.target=e.target||t;else{var s=e;it(e=new E(n,t),s)}if(s=!0,i)for(var r=i.length-1;0<=r;r--){var o=e.g=i[r];s=Tt(o,n,!0,e)&&s}if(s=Tt(o=e.g=t,n,!0,e)&&s,s=Tt(o,n,!1,e)&&s,i)for(r=0;r<i.length;r++)s=Tt(o=e.g=i[r],n,!1,e)&&s}function Tt(t,e,i,n){if(!(e=t.i.g[String(e)]))return!0;e=e.concat();for(var s=!0,r=0;r<e.length;++r){var o=e[r];if(o&&!o.ba&&o.capture==i){var h=o.listener,a=o.ha||o.src;o.ea&&st(t.i,o),s=!1!==h.call(a,n)&&s}}return s&&!n.defaultPrevented}y(bt,v),bt.prototype[$]=!0,bt.prototype.removeEventListener=function(t,e,i,n){ft(this,t,e,i,n)},bt.prototype.M=function(){if(bt.X.M.call(this),this.i){var t,e=this.i;for(t in e.g){for(var i=e.g[t],n=0;n<i.length;n++)Z(i[n]);delete e.g[t],e.h--}}this.I=null},bt.prototype.N=function(t,e,i,n){return this.i.add(String(t),e,!1,i,n)},bt.prototype.O=function(t,e,i,n){return this.i.add(String(t),e,!0,i,n)};var Et=r.JSON.stringify;function St(){var t=Mt;let e=null;return t.g&&(e=t.g,t.g=t.g.next,t.g||(t.h=null),e.next=null),e}class xt{constructor(){this.h=this.g=null}add(t,e){const i=Ct.get();i.set(t,e),this.h?this.h.next=i:this.g=i,this.h=i}}var jt,Ct=new class{constructor(t,e){this.i=t,this.j=e,this.h=0,this.g=null}get(){let t;return 0<this.h?(this.h--,t=this.g,this.g=t.next,t.next=null):t=this.i(),t}}(()=>new It,t=>t.reset());class It{constructor(){this.next=this.g=this.h=null}set(t,e){this.h=t,this.g=e,this.next=null}reset(){this.next=this.g=this.h=null}}function At(t){r.setTimeout(()=>{throw t},0)}function Rt(t,e){jt||Ot(),Pt||(jt(),Pt=!0),Mt.add(t,e)}function Ot(){var t=r.Promise.resolve(void 0);jt=function(){t.then(Dt)}}var Pt=!1,Mt=new xt;function Dt(){for(var t;t=St();){try{t.h.call(t.g)}catch(i){At(i)}var e=Ct;e.j(t),100>e.h&&(e.h++,t.next=e.g,e.g=t)}Pt=!1}function Lt(t,e){bt.call(this),this.h=t||1,this.g=e||r,this.j=p(this.lb,this),this.l=Date.now()}function Xt(t){t.ca=!1,t.R&&(t.g.clearTimeout(t.R),t.R=null)}function kt(t,e,i){if("function"==typeof t)i&&(t=p(t,i));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=p(t.handleEvent,t)}return 2147483647<Number(e)?-1:r.setTimeout(t,e||0)}function Ht(t){t.g=kt(()=>{t.g=null,t.i&&(t.i=!1,Ht(t))},t.j);const e=t.h;t.h=null,t.m.apply(null,e)}y(Lt,bt),(n=Lt.prototype).ca=!1,n.R=null,n.lb=function(){if(this.ca){var t=Date.now()-this.l;0<t&&t<.8*this.h?this.R=this.g.setTimeout(this.j,this.h-t):(this.R&&(this.g.clearTimeout(this.R),this.R=null),wt(this,"tick"),this.ca&&(Xt(this),this.start()))}},n.start=function(){this.ca=!0,this.R||(this.R=this.g.setTimeout(this.j,this.h),this.l=Date.now())},n.M=function(){Lt.X.M.call(this),Xt(this),delete this.g};class _t extends v{constructor(t,e){super(),this.m=t,this.j=e,this.h=null,this.i=!1,this.g=null}l(t){this.h=arguments,this.g?this.i=!0:Ht(this)}M(){super.M(),this.g&&(r.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Bt(t){v.call(this),this.h=t,this.g={}}y(Bt,v);var Ft=[];function Nt(t,e,i,n){Array.isArray(i)||(i&&(Ft[0]=i.toString()),i=Ft);for(var s=0;s<i.length;s++){var r=at(e,i[s],n||t.handleEvent,!1,t.h||t);if(!r)break;t.g[r.key]=r}}function Ut(t){Q(t.g,function(t,e){this.g.hasOwnProperty(e)&>(t)},t),t.g={}}function Kt(){this.g=!0}function Yt(t,e,i,n,s,r){t.info(function(){if(t.g)if(r)for(var o="",h=r.split("&"),a=0;a<h.length;a++){var l=h[a].split("=");if(1<l.length){var u=l[0];l=l[1];var c=u.split("_");o=2<=c.length&&"type"==c[1]?o+(u+"=")+l+"&":o+(u+"=redacted&")}}else o=null;else o=r;return"XMLHTTP REQ ("+n+") [attempt "+s+"]: "+e+"\n"+i+"\n"+o})}function Gt(t,e,i,n,s,r,o){t.info(function(){return"XMLHTTP RESP ("+n+") [ attempt "+s+"]: "+e+"\n"+i+"\n"+r+" "+o})}function Jt(t,e,i,n){t.info(function(){return"XMLHTTP TEXT ("+e+"): "+Vt(t,i)+(n?" "+n:"")})}function Wt(t,e){t.info(function(){return"TIMEOUT: "+e})}function Vt(t,e){if(!t.g)return e;if(!e)return null;try{var i=JSON.parse(e);if(i)for(t=0;t<i.length;t++)if(Array.isArray(i[t])){var n=i[t];if(!(2>n.length)){var s=n[1];if(Array.isArray(s)&&!(1>s.length)){var r=s[0];if("noop"!=r&&"stop"!=r&&"close"!=r)for(var o=1;o<s.length;o++)s[o]=""}}}return Et(i)}catch(h){return e}}Bt.prototype.M=function(){Bt.X.M.call(this),Ut(this)},Bt.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},Kt.prototype.Aa=function(){this.g=!1},Kt.prototype.info=function(){};var $t={},qt=null;function zt(){return qt=qt||new bt}function Zt(t){E.call(this,$t.Pa,t)}function Qt(t){const e=zt();wt(e,new Zt(e))}function te(t,e){E.call(this,$t.STAT_EVENT,t),this.stat=e}function ee(t){const e=zt();wt(e,new te(e,t))}function ie(t,e){E.call(this,$t.Qa,t),this.size=e}function ne(t,e){if("function"!=typeof t)throw Error("Fn must not be null and must be a function");return r.setTimeout(function(){t()},e)}$t.Pa="serverreachability",y(Zt,E),$t.STAT_EVENT="statevent",y(te,E),$t.Qa="timingevent",y(ie,E);var se={NO_ERROR:0,mb:1,zb:2,yb:3,tb:4,xb:5,Ab:6,Ma:7,TIMEOUT:8,Db:9},re={rb:"complete",Nb:"success",Na:"error",Ma:"abort",Fb:"ready",Gb:"readystatechange",TIMEOUT:"timeout",Bb:"incrementaldata",Eb:"progress",ub:"downloadprogress",Vb:"uploadprogress"};function oe(){}function he(t){return t.h||(t.h=t.i())}function ae(){}oe.prototype.h=null;var le,ue={OPEN:"a",qb:"b",Na:"c",Cb:"d"};function ce(){E.call(this,"d")}function fe(){E.call(this,"c")}function ge(){}function pe(t,e,i,n){this.l=t,this.j=e,this.m=i,this.U=n||1,this.S=new Bt(this),this.O=ye,t=X?125:void 0,this.T=new Lt(t),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.V=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.Y=-1,this.I=!1,this.N=0,this.L=null,this.$=this.J=this.Z=this.P=!1,this.h=new de}function de(){this.i=null,this.g="",this.h=!1}y(ce,E),y(fe,E),y(ge,oe),ge.prototype.g=function(){return new XMLHttpRequest},ge.prototype.i=function(){return{}},le=new ge;var ye=45e3,ve={},me={};function be(t,e,i){t.K=1,t.v=Ne(ke(e)),t.s=i,t.P=!0,we(t,null)}function we(t,e){t.F=Date.now(),xe(t),t.A=ke(t.v);var i=t.A,n=t.U;Array.isArray(n)||(n=[String(n)]),ti(i.i,"t",n),t.C=0,i=t.l.H,t.h=new de,t.g=rn(t.l,i?e:null,!t.s),0<t.N&&(t.L=new _t(p(t.La,t,t.g),t.N)),Nt(t.S,t.g,"readystatechange",t.ib),e=t.H?tt(t.H):{},t.s?(t.u||(t.u="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.g.da(t.A,t.u,t.s,e)):(t.u="GET",t.g.da(t.A,t.u,null,e)),Qt(),Yt(t.j,t.u,t.A,t.m,t.U,t.s)}function Te(t){return!!t.g&&("GET"==t.u&&2!=t.K&&t.l.Da)}function Ee(t,e,i){let n,s=!0;for(;!t.I&&t.C<i.length;){if((n=Se(t,i))==me){4==e&&(t.o=4,ee(14),s=!1),Jt(t.j,t.m,null,"[Incomplete Response]");break}if(n==ve){t.o=4,ee(15),Jt(t.j,t.m,i,"[Invalid Chunk]"),s=!1;break}Jt(t.j,t.m,n,null),Re(t,n)}Te(t)&&n!=me&&n!=ve&&(t.h.g="",t.C=0),4!=e||0!=i.length||t.h.h||(t.o=1,ee(16),s=!1),t.i=t.i&&s,s?0<i.length&&!t.$&&(t.$=!0,(e=t.l).g==t&&e.$&&!e.K&&(e.j.info("Great, no buffering proxy detected. Bytes received: "+i.length),qi(e),e.K=!0,ee(11))):(Jt(t.j,t.m,i,"[Invalid Chunked Response]"),Ae(t),Ie(t))}function Se(t,e){var i=t.C,n=e.indexOf("\n",i);return-1==n?me:(i=Number(e.substring(i,n)),isNaN(i)?ve:(n+=1)+i>e.length?me:(e=e.substr(n,i),t.C=n+i,e))}function xe(t){t.V=Date.now()+t.O,je(t,t.O)}function je(t,e){if(null!=t.B)throw Error("WatchDog timer not null");t.B=ne(p(t.gb,t),e)}function Ce(t){t.B&&(r.clearTimeout(t.B),t.B=null)}function Ie(t){0==t.l.G||t.I||Qi(t.l,t)}function Ae(t){Ce(t);var e=t.L;e&&"function"==typeof e.na&&e.na(),t.L=null,Xt(t.T),Ut(t.S),t.g&&(e=t.g,t.g=null,e.abort(),e.na())}function Re(t,e){try{var i=t.l;if(0!=i.G&&(i.g==t||ai(i.h,t)))if(!t.J&&ai(i.h,t)&&3==i.G){try{var n=i.Fa.g.parse(e)}catch(l){n=null}if(Array.isArray(n)&&3==n.length){var s=n;if(0==s[0]){t:if(!i.u){if(i.g){if(!(i.g.F+3e3<t.F))break t;Zi(i),Ni(i)}$i(i),ee(18)}}else i.Ba=s[1],0<i.Ba-i.T&&37500>s[2]&&i.L&&0==i.A&&!i.v&&(i.v=ne(p(i.cb,i),6e3));if(1>=hi(i.h)&&i.ja){try{i.ja()}catch(l){}i.ja=void 0}}else en(i,11)}else if((t.J||i.g==t)&&Zi(i),!x(e))for(s=i.Fa.g.parse(e),e=0;e<s.length;e++){let l=s[e];if(i.T=l[0],l=l[1],2==i.G)if("c"==l[0]){i.I=l[1],i.ka=l[2];const e=l[3];null!=e&&(i.ma=e,i.j.info("VER="+i.ma));const s=l[4];null!=s&&(i.Ca=s,i.j.info("SVER="+i.Ca));const u=l[5];null!=u&&"number"==typeof u&&0<u&&(n=1.5*u,i.J=n,i.j.info("backChannelRequestTimeoutMs_="+n)),n=i;const c=t.g;if(c){const t=c.g?c.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(t){var r=n.h;r.g||-1==t.indexOf("spdy")&&-1==t.indexOf("quic")&&-1==t.indexOf("h2")||(r.j=r.l,r.g=new Set,r.h&&(li(r,r.h),r.h=null))}if(n.D){const t=c.g?c.g.getResponseHeader("X-HTTP-Session-Id"):null;t&&(n.za=t,Fe(n.F,n.D,t))}}i.G=3,i.l&&i.l.xa(),i.$&&(i.P=Date.now()-t.F,i.j.info("Handshake RTT: "+i.P+"ms"));var o=t;if((n=i).sa=sn(n,n.H?n.ka:null,n.V),o.J){ui(n.h,o);var h=o,a=n.J;a&&h.setTimeout(a),h.B&&(Ce(h),xe(h)),n.g=o}else Vi(n);0<i.i.length&&Ki(i)}else"stop"!=l[0]&&"close"!=l[0]||en(i,7);else 3==i.G&&("stop"==l[0]||"close"==l[0]?"stop"==l[0]?en(i,7):Fi(i):"noop"!=l[0]&&i.l&&i.l.wa(l),i.A=0)}Qt(4)}catch(l){}}function Oe(t){if(t.W&&"function"==typeof t.W)return t.W();if("undefined"!=typeof Map&&t instanceof Map||"undefined"!=typeof Set&&t instanceof Set)return Array.from(t.values());if("string"==typeof t)return t.split("");if(h(t)){for(var e=[],i=t.length,n=0;n<i;n++)e.push(t[n]);return e}for(n in e=[],i=0,t)e[i++]=t[n];return e}function Pe(t){if(t.oa&&"function"==typeof t.oa)return t.oa();if(!t.W||"function"!=typeof t.W){if("undefined"!=typeof Map&&t instanceof Map)return Array.from(t.keys());if(!("undefined"!=typeof Set&&t instanceof Set)){if(h(t)||"string"==typeof t){var e=[];t=t.length;for(var i=0;i<t;i++)e.push(i);return e}e=[],i=0;for(const n in t)e[i++]=n;return e}}}function Me(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(h(t)||"string"==typeof t)Array.prototype.forEach.call(t,e,void 0);else for(var i=Pe(t),n=Oe(t),s=n.length,r=0;r<s;r++)e.call(void 0,n[r],i&&i[r],t)}(n=pe.prototype).setTimeout=function(t){this.O=t},n.ib=function(t){t=t.target;const e=this.L;e&&3==Li(t)?e.l():this.La(t)},n.La=function(t){try{if(t==this.g)t:{const c=Li(this.g);var e=this.g.Ea();const f=this.g.aa();if(!(3>c)&&(3!=c||X||this.g&&(this.h.h||this.g.fa()||Xi(this.g)))){this.I||4!=c||7==e||Qt(8==e||0>=f?3:2),Ce(this);var i=this.g.aa();this.Y=i;e:if(Te(this)){var n=Xi(this.g);t="";var s=n.length,o=4==Li(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Ae(this),Ie(this);var h="";break e}this.h.i=new r.TextDecoder}for(e=0;e<s;e++)this.h.h=!0,t+=this.h.i.decode(n[e],{stream:o&&e==s-1});n.splice(0,s),this.h.g+=t,this.C=0,h=this.h.g}else h=this.g.fa();if(this.i=200==i,Gt(this.j,this.u,this.A,this.m,this.U,c,i),this.i){if(this.Z&&!this.J){e:{if(this.g){var a,l=this.g;if((a=l.g?l.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!x(a)){var u=a;break e}}u=null}if(!(i=u)){this.i=!1,this.o=3,ee(12),Ae(this),Ie(this);break t}Jt(this.j,this.m,i,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,Re(this,i)}this.P?(Ee(this,c,h),X&&this.i&&3==c&&(Nt(this.S,this.T,"tick",this.hb),this.T.start())):(Jt(this.j,this.m,h,null),Re(this,h)),4==c&&Ae(this),this.i&&!this.I&&(4==c?Qi(this.l,this):(this.i=!1,xe(this)))}else 400==i&&0<h.indexOf("Unknown SID")?(this.o=3,ee(12)):(this.o=0,ee(13)),Ae(this),Ie(this)}}}catch(c){}},n.hb=function(){if(this.g){var t=Li(this.g),e=this.g.fa();this.C<e.length&&(Ce(this),Ee(this,t,e),this.i&&4!=t&&xe(this))}},n.cancel=function(){this.I=!0,Ae(this)},n.gb=function(){this.B=null;const t=Date.now();0<=t-this.V?(Wt(this.j,this.A),2!=this.K&&(Qt(),ee(17)),Ae(this),this.o=2,Ie(this)):je(this,this.V-t)};var De=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Le(t,e){if(t){t=t.split("&");for(var i=0;i<t.length;i++){var n=t[i].indexOf("="),s=null;if(0<=n){var r=t[i].substring(0,n);s=t[i].substring(n+1)}else r=t[i];e(r,s?decodeURIComponent(s.replace(/\+/g," ")):"")}}}function Xe(t,e){if(this.g=this.s=this.j="",this.m=null,this.o=this.l="",this.h=!1,t instanceof Xe){this.h=void 0!==e?e:t.h,He(this,t.j),this.s=t.s,this.g=t.g,_e(this,t.m),this.l=t.l,e=t.i;var i=new qe;i.i=e.i,e.g&&(i.g=new Map(e.g),i.h=e.h),Be(this,i),this.o=t.o}else t&&(i=String(t).match(De))?(this.h=!!e,He(this,i[1]||"",!0),this.s=Ue(i[2]||""),this.g=Ue(i[3]||"",!0),_e(this,i[4]),this.l=Ue(i[5]||"",!0),Be(this,i[6]||"",!0),this.o=Ue(i[7]||"")):(this.h=!!e,this.i=new qe(null,this.h))}function ke(t){return new Xe(t)}function He(t,e,i){t.j=i?Ue(e,!0):e,t.j&&(t.j=t.j.replace(/:$/,""))}function _e(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.m=e}else t.m=null}function Be(t,e,i){e instanceof qe?(t.i=e,ii(t.i,t.h)):(i||(e=Ke(e,Ve)),t.i=new qe(e,t.h))}function Fe(t,e,i){t.i.set(e,i)}function Ne(t){return Fe(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),t}function Ue(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Ke(t,e,i){return"string"==typeof t?(t=encodeURI(t).replace(e,Ye),i&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function Ye(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}Xe.prototype.toString=function(){var t=[],e=this.j;e&&t.push(Ke(e,Ge,!0),":");var i=this.g;return(i||"file"==e)&&(t.push("//"),(e=this.s)&&t.push(Ke(e,Ge,!0),"@"),t.push(encodeURIComponent(String(i)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(i=this.m)&&t.push(":",String(i))),(i=this.l)&&(this.g&&"/"!=i.charAt(0)&&t.push("/"),t.push(Ke(i,"/"==i.charAt(0)?We:Je,!0))),(i=this.i.toString())&&t.push("?",i),(i=this.o)&&t.push("#",Ke(i,$e)),t.join("")};var Ge=/[#\/\?@]/g,Je=/[#\?:]/g,We=/[#\?]/g,Ve=/[#\?@]/g,$e=/#/g;function qe(t,e){this.h=this.g=null,this.i=t||null,this.j=!!e}function ze(t){t.g||(t.g=new Map,t.h=0,t.i&&Le(t.i,function(e,i){t.add(decodeURIComponent(e.replace(/\+/g," ")),i)}))}function Ze(t,e){ze(t),e=ei(t,e),t.g.has(e)&&(t.i=null,t.h-=t.g.get(e).length,t.g.delete(e))}function Qe(t,e){return ze(t),e=ei(t,e),t.g.has(e)}function ti(t,e,i){Ze(t,e),0<i.length&&(t.i=null,t.g.set(ei(t,e),w(i)),t.h+=i.length)}function ei(t,e){return e=String(e),t.j&&(e=e.toLowerCase()),e}function ii(t,e){e&&!t.j&&(ze(t),t.i=null,t.g.forEach(function(t,e){var i=e.toLowerCase();e!=i&&(Ze(this,e),ti(this,i,t))},t)),t.j=e}(n=qe.prototype).add=function(t,e){ze(this),this.i=null,t=ei(this,t);var i=this.g.get(t);return i||this.g.set(t,i=[]),i.push(e),this.h+=1,this},n.forEach=function(t,e){ze(this),this.g.forEach(function(i,n){i.forEach(function(i){t.call(e,i,n,this)},this)},this)},n.oa=function(){ze(this);const t=Array.from(this.g.values()),e=Array.from(this.g.keys()),i=[];for(let n=0;n<e.length;n++){const s=t[n];for(let t=0;t<s.length;t++)i.push(e[n])}return i},n.W=function(t){ze(this);let e=[];if("string"==typeof t)Qe(this,t)&&(e=e.concat(this.g.get(ei(this,t))));else{t=Array.from(this.g.values());for(let i=0;i<t.length;i++)e=e.concat(t[i])}return e},n.set=function(t,e){return ze(this),this.i=null,Qe(this,t=ei(this,t))&&(this.h-=this.g.get(t).length),this.g.set(t,[e]),this.h+=1,this},n.get=function(t,e){return t&&0<(t=this.W(t)).length?String(t[0]):e},n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const t=[],e=Array.from(this.g.keys());for(var i=0;i<e.length;i++){var n=e[i];const r=encodeURIComponent(String(n)),o=this.W(n);for(n=0;n<o.length;n++){var s=r;""!==o[n]&&(s+="="+encodeURIComponent(String(o[n]))),t.push(s)}}return this.i=t.join("&")};var ni=class{constructor(t,e){this.h=t,this.g=e}};function si(t){this.l=t||ri,r.PerformanceNavigationTiming?t=0<(t=r.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):t=!!(r.g&&r.g.Ga&&r.g.Ga()&&r.g.Ga().$b),this.j=t?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}var ri=10;function oi(t){return!!t.h||!!t.g&&t.g.size>=t.j}function hi(t){return t.h?1:t.g?t.g.size:0}function ai(t,e){return t.h?t.h==e:!!t.g&&t.g.has(e)}function li(t,e){t.g?t.g.add(e):t.h=e}function ui(t,e){t.h&&t.h==e?t.h=null:t.g&&t.g.has(e)&&t.g.delete(e)}function ci(t){if(null!=t.h)return t.i.concat(t.h.D);if(null!=t.g&&0!==t.g.size){let e=t.i;for(const i of t.g.values())e=e.concat(i.D);return e}return w(t.i)}function fi(){}function gi(){this.g=new fi}function pi(t,e,i){const n=i||"";try{Me(t,function(t,i){let s=t;a(t)&&(s=Et(t)),e.push(n+i+"="+encodeURIComponent(s))})}catch(s){throw e.push(n+"type="+encodeURIComponent("_badmap")),s}}function di(t,e){const i=new Kt;if(r.Image){const n=new Image;n.onload=d(yi,i,n,"TestLoadImage: loaded",!0,e),n.onerror=d(yi,i,n,"TestLoadImage: error",!1,e),n.onabort=d(yi,i,n,"TestLoadImage: abort",!1,e),n.ontimeout=d(yi,i,n,"TestLoadImage: timeout",!1,e),r.setTimeout(function(){n.ontimeout&&n.ontimeout()},1e4),n.src=t}else e(!1)}function yi(t,e,i,n,s){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,s(n)}catch(r){}}function vi(t){this.l=t.ac||null,this.j=t.jb||!1}function mi(t,e){bt.call(this),this.D=t,this.u=e,this.m=void 0,this.readyState=bi,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}si.prototype.cancel=function(){if(this.i=ci(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(const t of this.g.values())t.cancel();this.g.clear()}},fi.prototype.stringify=function(t){return r.JSON.stringify(t,void 0)},fi.prototype.parse=function(t){return r.JSON.parse(t,void 0)},y(vi,oe),vi.prototype.g=function(){return new mi(this.l,this.j)},vi.prototype.i=function(t){return function(){return t}}({}),y(mi,bt);var bi=0;function wi(t){t.j.read().then(t.Ta.bind(t)).catch(t.ga.bind(t))}function Ti(t){t.readyState=4,t.l=null,t.j=null,t.A=null,Ei(t)}function Ei(t){t.onreadystatechange&&t.onreadystatechange.call(t)}(n=mi.prototype).open=function(t,e){if(this.readyState!=bi)throw this.abort(),Error("Error reopening a connection");this.C=t,this.B=e,this.readyState=1,Ei(this)},n.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const e={headers:this.v,method:this.C,credentials:this.m,cache:void 0};t&&(e.body=t),(this.D||r).fetch(new Request(this.B,e)).then(this.Wa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,Ti(this)),this.readyState=bi},n.Wa=function(t){if(this.g&&(this.l=t,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=t.headers,this.readyState=2,Ei(this)),this.g&&(this.readyState=3,Ei(this),this.g)))if("arraybuffer"===this.responseType)t.arrayBuffer().then(this.Ua.bind(this),this.ga.bind(this));else if(void 0!==r.ReadableStream&&"body"in t){if(this.j=t.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;wi(this)}else t.text().then(this.Va.bind(this),this.ga.bind(this))},n.Ta=function(t){if(this.g){if(this.u&&t.value)this.response.push(t.value);else if(!this.u){var e=t.value?t.value:new Uint8Array(0);(e=this.A.decode(e,{stream:!t.done}))&&(this.response=this.responseText+=e)}t.done?Ti(this):Ei(this),3==this.readyState&&wi(this)}},n.Va=function(t){this.g&&(this.response=this.responseText=t,Ti(this))},n.Ua=function(t){this.g&&(this.response=t,Ti(this))},n.ga=function(){this.g&&Ti(this)},n.setRequestHeader=function(t,e){this.v.append(t,e)},n.getResponseHeader=function(t){return this.h&&this.h.get(t.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const t=[],e=this.h.entries();for(var i=e.next();!i.done;)i=i.value,t.push(i[0]+": "+i[1]),i=e.next();return t.join("\r\n")},Object.defineProperty(mi.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(t){this.m=t?"include":"same-origin"}});var Si=r.JSON.parse;function xi(t){bt.call(this),this.headers=new Map,this.u=t||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=ji,this.K=this.L=!1}y(xi,bt);var ji="",Ci=/^https?$/i,Ii=["POST","PUT"];function Ai(t){return D&&Y()&&"number"==typeof t.timeout&&void 0!==t.ontimeout}function Ri(t,e){t.h=!1,t.g&&(t.l=!0,t.g.abort(),t.l=!1),t.j=e,t.m=5,Oi(t),Mi(t)}function Oi(t){t.D||(t.D=!0,wt(t,"complete"),wt(t,"error"))}function Pi(t){if(t.h&&void 0!==s&&(!t.C[1]||4!=Li(t)||2!=t.aa()))if(t.v&&4==Li(t))kt(t.Ha,0,t);else if(wt(t,"readystatechange"),4==Li(t)){t.h=!1;try{const s=t.aa();t:switch(s){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var e=!0;break t;default:e=!1}var i;if(!(i=e)){var n;if(n=0===s){var o=String(t.H).match(De)[1]||null;if(!o&&r.self&&r.self.location){var h=r.self.location.protocol;o=h.substr(0,h.length-1)}n=!Ci.test(o?o.toLowerCase():"")}i=n}if(i)wt(t,"complete"),wt(t,"success");else{t.m=6;try{var a=2<Li(t)?t.g.statusText:""}catch(l){a=""}t.j=a+" ["+t.aa()+"]",Oi(t)}}finally{Mi(t)}}}function Mi(t,e){if(t.g){Di(t);const n=t.g,s=t.C[0]?o:null;t.g=null,t.C=null,e||wt(t,"ready");try{n.onreadystatechange=s}catch(i){}}}function Di(t){t.g&&t.K&&(t.g.ontimeout=null),t.A&&(r.clearTimeout(t.A),t.A=null)}function Li(t){return t.g?t.g.readyState:0}function Xi(t){try{if(!t.g)return null;if("response"in t.g)return t.g.response;switch(t.J){case ji:case"text":return t.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in t.g)return t.g.mozResponseArrayBuffer}return null}catch(e){return null}}function ki(t){let e="";return Q(t,function(t,i){e+=i,e+=":",e+=t,e+="\r\n"}),e}function Hi(t,e,i){t:{for(n in i){var n=!1;break t}n=!0}n||(i=ki(i),"string"==typeof t?null!=i&&encodeURIComponent(String(i)):Fe(t,e,i))}function _i(t,e,i){return i&&i.internalChannelParams&&i.internalChannelParams[t]||e}function Bi(t){this.Ca=0,this.i=[],this.j=new Kt,this.ka=this.sa=this.F=this.V=this.g=this.za=this.D=this.ia=this.o=this.S=this.s=null,this.ab=this.U=0,this.Za=_i("failFast",!1,t),this.L=this.v=this.u=this.m=this.l=null,this.Y=!0,this.pa=this.Ba=this.T=-1,this.Z=this.A=this.C=0,this.Xa=_i("baseRetryDelayMs",5e3,t),this.bb=_i("retryDelaySeedMs",1e4,t),this.$a=_i("forwardChannelMaxRetries",2,t),this.ta=_i("forwardChannelRequestTimeoutMs",2e4,t),this.ra=t&&t.xmlHttpFactory||void 0,this.Da=t&&t.Zb||!1,this.J=void 0,this.H=t&&t.supportsCrossDomainXhr||!1,this.I="",this.h=new si(t&&t.concurrentRequestLimit),this.Fa=new gi,this.O=t&&t.fastHandshake||!1,this.N=t&&t.encodeInitMessageHeaders||!1,this.O&&this.N&&(this.N=!1),this.Ya=t&&t.Xb||!1,t&&t.Aa&&this.j.Aa(),t&&t.forceLongPolling&&(this.Y=!1),this.$=!this.O&&this.Y&&t&&t.detectBufferingProxy||!1,this.ja=void 0,this.P=0,this.K=!1,this.la=this.B=null}function Fi(t){if(Ui(t),3==t.G){var e=t.U++,i=ke(t.F);Fe(i,"SID",t.I),Fe(i,"RID",e),Fe(i,"TYPE","terminate"),Ji(t,i),(e=new pe(t,t.j,e,void 0)).K=2,e.v=Ne(ke(i)),i=!1,r.navigator&&r.navigator.sendBeacon&&(i=r.navigator.sendBeacon(e.v.toString(),"")),!i&&r.Image&&((new Image).src=e.v,i=!0),i||(e.g=rn(e.l,null),e.g.da(e.v)),e.F=Date.now(),xe(e)}nn(t)}function Ni(t){t.g&&(qi(t),t.g.cancel(),t.g=null)}function Ui(t){Ni(t),t.u&&(r.clearTimeout(t.u),t.u=null),Zi(t),t.h.cancel(),t.m&&("number"==typeof t.m&&r.clearTimeout(t.m),t.m=null)}function Ki(t){oi(t.h)||t.m||(t.m=!0,Rt(t.Ja,t),t.C=0)}function Yi(t,e){return!(hi(t.h)>=t.h.j-(t.m?1:0))&&(t.m?(t.i=e.D.concat(t.i),!0):!(1==t.G||2==t.G||t.C>=(t.Za?0:t.$a))&&(t.m=ne(p(t.Ja,t,e),tn(t,t.C)),t.C++,!0))}function Gi(t,e){var i;i=e?e.m:t.U++;const n=ke(t.F);Fe(n,"SID",t.I),Fe(n,"RID",i),Fe(n,"AID",t.T),Ji(t,n),t.o&&t.s&&Hi(n,t.o,t.s),i=new pe(t,t.j,i,t.C+1),null===t.o&&(i.H=t.s),e&&(t.i=e.D.concat(t.i)),e=Wi(t,i,1e3),i.setTimeout(Math.round(.5*t.ta)+Math.round(.5*t.ta*Math.random())),li(t.h,i),be(i,n,e)}function Ji(t,e){t.ia&&Q(t.ia,function(t,i){Fe(e,i,t)}),t.l&&Me({},function(t,i){Fe(e,i,t)})}function Wi(t,e,i){i=Math.min(t.i.length,i);var n=t.l?p(t.l.Ra,t.l,t):null;t:{var s=t.i;let e=-1;for(;;){const t=["count="+i];-1==e?0<i?(e=s[0].h,t.push("ofs="+e)):e=0:t.push("ofs="+e);let o=!0;for(let h=0;h<i;h++){let i=s[h].h;const a=s[h].g;if(0>(i-=e))e=Math.max(0,s[h].h-100),o=!1;else try{pi(a,t,"req"+i+"_")}catch(r){n&&n(a)}}if(o){n=t.join("&");break t}}}return t=t.i.splice(0,i),e.D=t,n}function Vi(t){t.g||t.u||(t.Z=1,Rt(t.Ia,t),t.A=0)}function $i(t){return!(t.g||t.u||3<=t.A)&&(t.Z++,t.u=ne(p(t.Ia,t),tn(t,t.A)),t.A++,!0)}function qi(t){null!=t.B&&(r.clearTimeout(t.B),t.B=null)}function zi(t){t.g=new pe(t,t.j,"rpc",t.Z),null===t.o&&(t.g.H=t.s),t.g.N=0;var e=ke(t.sa);Fe(e,"RID","rpc"),Fe(e,"SID",t.I),Fe(e,"CI",t.L?"0":"1"),Fe(e,"AID",t.T),Fe(e,"TYPE","xmlhttp"),Ji(t,e),t.o&&t.s&&Hi(e,t.o,t.s),t.J&&t.g.setTimeout(t.J);var i=t.g;t=t.ka,i.K=1,i.v=Ne(ke(e)),i.s=null,i.P=!0,we(i,t)}function Zi(t){null!=t.v&&(r.clearTimeout(t.v),t.v=null)}function Qi(t,e){var i=null;if(t.g==e){Zi(t),qi(t),t.g=null;var n=2}else{if(!ai(t.h,e))return;i=e.D,ui(t.h,e),n=1}if(0!=t.G)if(t.pa=e.Y,e.i)if(1==n){i=e.s?e.s.length:0,e=Date.now()-e.F;var s=t.C;wt(n=zt(),new ie(n,i)),Ki(t)}else Vi(t);else if(3==(s=e.o)||0==s&&0<t.pa||!(1==n&&Yi(t,e)||2==n&&$i(t)))switch(i&&0<i.length&&(e=t.h,e.i=e.i.concat(i)),s){case 1:en(t,5);break;case 4:en(t,10);break;case 3:en(t,6);break;default:en(t,2)}}function tn(t,e){let i=t.Xa+Math.floor(Math.random()*t.bb);return t.l||(i*=2),i*e}function en(t,e){if(t.j.info("Error code "+e),2==e){var i=null;t.l&&(i=null);var n=p(t.kb,t);i||(i=new Xe("//www.google.com/images/cleardot.gif"),r.location&&"http"==r.location.protocol||He(i,"https"),Ne(i)),di(i.toString(),n)}else ee(2);t.G=0,t.l&&t.l.va(e),nn(t),Ui(t)}function nn(t){if(t.G=0,t.la=[],t.l){const e=ci(t.h);0==e.length&&0==t.i.length||(T(t.la,e),T(t.la,t.i),t.h.i.length=0,w(t.i),t.i.length=0),t.l.ua()}}function sn(t,e,i){var n=i instanceof Xe?ke(i):new Xe(i,void 0);if(""!=n.g)e&&(n.g=e+"."+n.g),_e(n,n.m);else{var s=r.location;n=s.protocol,e=e?e+"."+s.hostname:s.hostname,s=+s.port;var o=new Xe(null,void 0);n&&He(o,n),e&&(o.g=e),s&&_e(o,s),i&&(o.l=i),n=o}return i=t.D,e=t.za,i&&e&&Fe(n,i,e),Fe(n,"VER",t.ma),Ji(t,n),n}function rn(t,e,i){if(e&&!t.H)throw Error("Can't create secondary domain capable XhrIo object.");return(e=i&&t.Da&&!t.ra?new xi(new vi({jb:!0})):new xi(t.ra)).Ka(t.H),e}function on(){}function hn(){if(D&&!(10<=Number(J)))throw Error("Environmental error: no available transport.")}function an(t,e){bt.call(this),this.g=new Bi(e),this.l=t,this.h=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.g.s=t,t=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(t?t["X-WebChannel-Content-Type"]=e.messageContentType:t={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.ya&&(t?t["X-WebChannel-Client-Profile"]=e.ya:t={"X-WebChannel-Client-Profile":e.ya}),this.g.S=t,(t=e&&e.Yb)&&!x(t)&&(this.g.o=t),this.A=e&&e.supportsCrossDomainXhr||!1,this.v=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!x(e)&&(this.g.D=e,null!==(t=this.h)&&e in t&&(e in(t=this.h)&&delete t[e])),this.j=new cn(this)}function ln(t){ce.call(this);var e=t.__sm__;if(e){t:{for(const i in e){t=i;break t}t=void 0}(this.i=t)&&(t=this.i,e=null!==e&&t in e?e[t]:void 0),this.data=e}else this.data=t}function un(){fe.call(this),this.status=1}function cn(t){this.g=t}(n=xi.prototype).Ka=function(t){this.L=t},n.da=function(t,e,i,n){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+t);e=e?e.toUpperCase():"GET",this.H=t,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=this.u?this.u.g():le.g(),this.C=this.u?he(this.u):he(le),this.g.onreadystatechange=p(this.Ha,this);try{this.F=!0,this.g.open(e,String(t),!0),this.F=!1}catch(o){return void Ri(this,o)}if(t=i||"",i=new Map(this.headers),n)if(Object.getPrototypeOf(n)===Object.prototype)for(var s in n)i.set(s,n[s]);else{if("function"!=typeof n.keys||"function"!=typeof n.get)throw Error("Unknown input type for opt_headers: "+String(n));for(const t of n.keys())i.set(t,n.get(t))}n=Array.from(i.keys()).find(t=>"content-type"==t.toLowerCase()),s=r.FormData&&t instanceof r.FormData,!(0<=b(Ii,e))||n||s||i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[r,h]of i)this.g.setRequestHeader(r,h);this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{Di(this),0<this.B&&((this.K=Ai(this.g))?(this.g.timeout=this.B,this.g.ontimeout=p(this.qa,this)):this.A=kt(this.qa,this.B,this)),this.v=!0,this.g.send(t),this.v=!1}catch(o){Ri(this,o)}},n.qa=function(){void 0!==s&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,wt(this,"timeout"),this.abort(8))},n.abort=function(t){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=t||7,wt(this,"complete"),wt(this,"abort"),Mi(this))},n.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),Mi(this,!0)),xi.X.M.call(this)},n.Ha=function(){this.s||(this.F||this.v||this.l?Pi(this):this.fb())},n.fb=function(){Pi(this)},n.aa=function(){try{return 2<Li(this)?this.g.status:-1}catch(t){return-1}},n.fa=function(){try{return this.g?this.g.responseText:""}catch(t){return""}},n.Sa=function(t){if(this.g){var e=this.g.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Si(e)}},n.Ea=function(){return this.m},n.Oa=function(){return"string"==typeof this.j?this.j:String(this.j)},(n=Bi.prototype).ma=8,n.G=1,n.Ja=function(t){if(this.m)if(this.m=null,1==this.G){if(!t){this.U=Math.floor(1e5*Math.random()),t=this.U++;const s=new pe(this,this.j,t,void 0);let r=this.s;if(this.S&&(r?it(r=tt(r),this.S):r=this.S),null!==this.o||this.N||(s.H=r,r=null),this.O)t:{for(var e=0,i=0;i<this.i.length;i++){var n=this.i[i];if(void 0===(n="__data__"in n.g&&"string"==typeof(n=n.g.__data__)?n.length:void 0))break;if(4096<(e+=n)){e=i;break t}if(4096===e||i===this.i.length-1){e=i+1;break t}}e=1e3}else e=1e3;e=Wi(this,s,e),Fe(i=ke(this.F),"RID",t),Fe(i,"CVER",22),this.D&&Fe(i,"X-HTTP-Session-Id",this.D),Ji(this,i),r&&(this.N?e="headers="+encodeURIComponent(String(ki(r)))+"&"+e:this.o&&Hi(i,this.o,r)),li(this.h,s),this.Ya&&Fe(i,"TYPE","init"),this.O?(Fe(i,"$req",e),Fe(i,"SID","null"),s.Z=!0,be(s,i,null)):be(s,i,e),this.G=2}}else 3==this.G&&(t?Gi(this,t):0==this.i.length||oi(this.h)||Gi(this))},n.Ia=function(){if(this.u=null,zi(this),this.$&&!(this.K||null==this.g||0>=this.P)){var t=2*this.P;this.j.info("BP detection timer enabled: "+t),this.B=ne(p(this.eb,this),t)}},n.eb=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.L=!1,this.K=!0,ee(10),Ni(this),zi(this))},n.cb=function(){null!=this.v&&(this.v=null,Ni(this),$i(this),ee(19))},n.kb=function(t){t?(this.j.info("Successfully pinged google.com"),ee(2)):(this.j.info("Failed to ping google.com"),ee(1))},(n=on.prototype).xa=function(){},n.wa=function(){},n.va=function(){},n.ua=function(){},n.Ra=function(){},hn.prototype.g=function(t,e){return new an(t,e)},y(an,bt),an.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.H=!0);var t=this.g,e=this.l,i=this.h||void 0;ee(0),t.V=e,t.ia=i||{},t.L=t.Y,t.F=sn(t,null,t.V),Ki(t)},an.prototype.close=function(){Fi(this.g)},an.prototype.u=function(t){var e=this.g;if("string"==typeof t){var i={};i.__data__=t,t=i}else this.v&&((i={}).__data__=Et(t),t=i);e.i.push(new ni(e.ab++,t)),3==e.G&&Ki(e)},an.prototype.M=function(){this.g.l=null,delete this.j,Fi(this.g),delete this.g,an.X.M.call(this)},y(ln,ce),y(un,fe),y(cn,on),cn.prototype.xa=function(){wt(this.g,"a")},cn.prototype.wa=function(t){wt(this.g,new ln(t))},cn.prototype.va=function(t){wt(this.g,new un)},cn.prototype.ua=function(){wt(this.g,"b")},hn.prototype.createWebChannel=hn.prototype.g,an.prototype.send=an.prototype.u,an.prototype.open=an.prototype.m,an.prototype.close=an.prototype.close,se.NO_ERROR=0,se.TIMEOUT=8,se.HTTP_ERROR=6,re.COMPLETE="complete",ae.EventType=ue,ue.OPEN="a",ue.CLOSE="b",ue.ERROR="c",ue.MESSAGE="d",bt.prototype.listen=bt.prototype.N,xi.prototype.listenOnce=xi.prototype.O,xi.prototype.getLastError=xi.prototype.Oa,xi.prototype.getLastErrorCode=xi.prototype.Ea,xi.prototype.getStatus=xi.prototype.aa,xi.prototype.getResponseJson=xi.prototype.Sa,xi.prototype.getResponseText=xi.prototype.fa,xi.prototype.send=xi.prototype.da,xi.prototype.setWithCredentials=xi.prototype.Ka;var fn=i.createWebChannelTransport=function(){return new hn};exports.createWebChannelTransport=fn;var gn=i.getStatEventTarget=function(){return zt()};exports.getStatEventTarget=gn;var pn=i.ErrorCode=se;exports.ErrorCode=pn;var dn=i.EventType=re;exports.EventType=dn;var yn=i.Event=$t;exports.Event=yn;var vn=i.Stat={sb:0,vb:1,wb:2,Pb:3,Ub:4,Rb:5,Sb:6,Qb:7,Ob:8,Tb:9,PROXY:10,NOPROXY:11,Mb:12,Ib:13,Jb:14,Hb:15,Kb:16,Lb:17,ob:18,nb:19,pb:20};exports.Stat=vn;var mn=i.FetchXmlHttpFactory=vi;exports.FetchXmlHttpFactory=mn;var bn=i.WebChannel=ae;exports.WebChannel=bn;var wn=i.XhrIo=xi;exports.XhrIo=wn;
|
|
504
|
+
},{}],"lBbe":[function(require,module,exports) {
|
|
505
|
+
var define;
|
|
492
506
|
var process = require("process");
|
|
493
|
-
var t=require("process");Object.defineProperty(exports,"__esModule",{value:!0}),exports.Z=exports.W=exports.U=exports.T=exports.M=exports.L=exports.K=exports.H=exports.G=exports.E=exports.C=void 0,exports.a=Nc,exports.i=exports.e=exports.c=void 0,exports.j=uc,exports.t=exports.s=exports.o=void 0,exports.u=Sc;var e=require("tslib"),n=require("@firebase/util"),r=require("@firebase/logger"),i=require("@firebase/webchannel-wrapper");function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var s=function(){function t(t,e){var n=this;this.previousValue=t,e&&(e.sequenceNumberHandler=function(t){return n.t(t)},this.i=function(t){return e.writeSequenceNumber(t)})}return t.prototype.t=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},t.prototype.next=function(){var t=++this.previousValue;return this.i&&this.i(t),t},t}();s.o=-1;var a={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},u=function(t){function n(e,n){var r=this;return(r=t.call(this,n)||this).code=e,r.message=n,r.name="FirebaseError",r.toString=function(){return r.name+": [code="+r.code+"]: "+r.message},r}return(0,e.__extends)(n,t),n}(Error),c=new r.Logger("@firebase/firestore");function h(){return c.logLevel}function f(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];if(c.logLevel<=r.LogLevel.DEBUG){var o=n.map(p);c.debug.apply(c,(0,e.__spreadArray)(["Firestore (8.10.1): "+t],o))}}function l(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];if(c.logLevel<=r.LogLevel.ERROR){var o=n.map(p);c.error.apply(c,(0,e.__spreadArray)(["Firestore (8.10.1): "+t],o))}}function d(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];if(c.logLevel<=r.LogLevel.WARN){var o=n.map(p);c.warn.apply(c,(0,e.__spreadArray)(["Firestore (8.10.1): "+t],o))}}function p(t){if("string"==typeof t)return t;try{return e=t,JSON.stringify(e)}catch(e){return t}var e}function y(t){void 0===t&&(t="Unexpected state");var e="FIRESTORE (8.10.1) INTERNAL ASSERTION FAILED: "+t;throw l(e),new Error(e)}function v(t,e){t||y()}function m(t,e){return t}function g(t){var e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(var r=0;r<t;r++)n[r]=Math.floor(256*Math.random());return n}var _=function(){function t(){}return t.u=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length,n="";n.length<20;)for(var r=g(40),i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%t.length));return n},t}();function w(t,e){return t<e?-1:t>e?1:0}function b(t,e,n){return t.length===e.length&&t.every(function(t,r){return n(t,e[r])})}function I(t){return t+"\0"}var E=function(){function t(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new u(a.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new u(a.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new u(a.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new u(a.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}return t.now=function(){return t.fromMillis(Date.now())},t.fromDate=function(e){return t.fromMillis(e.getTime())},t.fromMillis=function(e){var n=Math.floor(e/1e3);return new t(n,Math.floor(1e6*(e-1e3*n)))},t.prototype.toDate=function(){return new Date(this.toMillis())},t.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},t.prototype._compareTo=function(t){return this.seconds===t.seconds?w(this.nanoseconds,t.nanoseconds):w(this.seconds,t.seconds)},t.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},t.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},t.prototype.toJSON=function(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}},t.prototype.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")},t}(),T=function(){function t(t){this.timestamp=t}return t.fromTimestamp=function(e){return new t(e)},t.min=function(){return new t(new E(0,0))},t.prototype.compareTo=function(t){return this.timestamp._compareTo(t.timestamp)},t.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},t.prototype.toMicroseconds=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},t.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},t.prototype.toTimestamp=function(){return this.timestamp},t}();function S(t){var e=0;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function N(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function D(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}exports.M=E;var A=function(){function t(t,e,n){void 0===e?e=0:e>t.length&&y(),void 0===n?n=t.length-e:n>t.length-e&&y(),this.segments=t,this.offset=e,this.len=n}return Object.defineProperty(t.prototype,"length",{get:function(){return this.len},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){return 0===t.comparator(this,e)},t.prototype.child=function(e){var n=this.segments.slice(this.offset,this.limit());return e instanceof t?e.forEach(function(t){n.push(t)}):n.push(e),this.construct(n)},t.prototype.limit=function(){return this.offset+this.length},t.prototype.popFirst=function(t){return t=void 0===t?1:t,this.construct(this.segments,this.offset+t,this.length-t)},t.prototype.popLast=function(){return this.construct(this.segments,this.offset,this.length-1)},t.prototype.firstSegment=function(){return this.segments[this.offset]},t.prototype.lastSegment=function(){return this.get(this.length-1)},t.prototype.get=function(t){return this.segments[this.offset+t]},t.prototype.isEmpty=function(){return 0===this.length},t.prototype.isPrefixOf=function(t){if(t.length<this.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},t.prototype.isImmediateParentOf=function(t){if(this.length+1!==t.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},t.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},t.prototype.toArray=function(){return this.segments.slice(this.offset,this.limit())},t.comparator=function(t,e){for(var n=Math.min(t.length,e.length),r=0;r<n;r++){var i=t.get(r),o=e.get(r);if(i<o)return-1;if(i>o)return 1}return t.length<e.length?-1:t.length>e.length?1:0},t}(),x=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return(0,e.__extends)(n,t),n.prototype.construct=function(t,e,r){return new n(t,e,r)},n.prototype.canonicalString=function(){return this.toArray().join("/")},n.prototype.toString=function(){return this.canonicalString()},n.fromString=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=[],i=0,o=t;i<o.length;i++){var s=o[i];if(s.indexOf("//")>=0)throw new u(a.INVALID_ARGUMENT,"Invalid segment ("+s+"). Paths must not contain // in them.");r.push.apply(r,s.split("/").filter(function(t){return t.length>0}))}return new n(r)},n.emptyPath=function(){return new n([])},n}(A),k=/^[_a-zA-Z][_a-zA-Z0-9]*$/,C=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return(0,e.__extends)(n,t),n.prototype.construct=function(t,e,r){return new n(t,e,r)},n.isValidIdentifier=function(t){return k.test(t)},n.prototype.canonicalString=function(){return this.toArray().map(function(t){return t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),n.isValidIdentifier(t)||(t="`"+t+"`"),t}).join(".")},n.prototype.toString=function(){return this.canonicalString()},n.prototype.isKeyField=function(){return 1===this.length&&"__name__"===this.get(0)},n.keyField=function(){return new n(["__name__"])},n.fromServerFormat=function(t){for(var e=[],r="",i=0,o=function(){if(0===r.length)throw new u(a.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'");e.push(r),r=""},s=!1;i<t.length;){var c=t[i];if("\\"===c){if(i+1===t.length)throw new u(a.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var h=t[i+1];if("\\"!==h&&"."!==h&&"`"!==h)throw new u(a.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);r+=h,i+=2}else"`"===c?(s=!s,i++):"."!==c||s?(r+=c,i++):(o(),i++)}if(o(),s)throw new u(a.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new n(e)},n.emptyPath=function(){return new n([])},n}(A),R=function(){function t(t){this.fields=t,t.sort(C.comparator)}return t.prototype.covers=function(t){for(var e=0,n=this.fields;e<n.length;e++)if(n[e].isPrefixOf(t))return!0;return!1},t.prototype.isEqual=function(t){return b(this.fields,t.fields,function(t,e){return t.isEqual(e)})},t}(),L=function(){function t(t){this.binaryString=t}return t.fromBase64String=function(e){return new t(atob(e))},t.fromUint8Array=function(e){return new t(function(t){for(var e="",n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(e))},t.prototype.toBase64=function(){return t=this.binaryString,btoa(t);var t},t.prototype.toUint8Array=function(){return function(t){for(var e=new Uint8Array(t.length),n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.binaryString)},t.prototype.approximateByteSize=function(){return 2*this.binaryString.length},t.prototype.compareTo=function(t){return w(this.binaryString,t.binaryString)},t.prototype.isEqual=function(t){return this.binaryString===t.binaryString},t}();L.EMPTY_BYTE_STRING=new L("");var O=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function P(t){if(v(!!t),"string"==typeof t){var e=0,n=O.exec(t);if(v(!!n),n[1]){var r=n[1];r=(r+"000000000").substr(0,9),e=Number(r)}var i=new Date(t);return{seconds:Math.floor(i.getTime()/1e3),nanos:e}}return{seconds:F(t.seconds),nanos:F(t.nanos)}}function F(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function M(t){return"string"==typeof t?L.fromBase64String(t):L.fromUint8Array(t)}function V(t){var e,n;return"server_timestamp"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function q(t){var e=t.mapValue.fields.__previous_value__;return V(e)?q(e):e}function U(t){var e=P(t.mapValue.fields.__local_write_time__.timestampValue);return new E(e.seconds,e.nanos)}function B(t){return null==t}function j(t){return 0===t&&1/t==-1/0}function K(t){return"number"==typeof t&&Number.isInteger(t)&&!j(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}var G=function(){function t(t){this.path=t}return t.fromPath=function(e){return new t(x.fromString(e))},t.fromName=function(e){return new t(x.fromString(e).popFirst(5))},t.prototype.hasCollectionId=function(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t},t.prototype.isEqual=function(t){return null!==t&&0===x.comparator(this.path,t.path)},t.prototype.toString=function(){return this.path.toString()},t.comparator=function(t,e){return x.comparator(t.path,e.path)},t.isDocumentKey=function(t){return t.length%2==0},t.fromSegments=function(e){return new t(new x(e.slice()))},t}();function Q(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?V(t)?4:10:y()}function z(t,e){var n=Q(t);if(n!==Q(e))return!1;switch(n){case 0:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return U(t).isEqual(U(e));case 3:return function(t,e){if("string"==typeof t.timestampValue&&"string"==typeof e.timestampValue&&t.timestampValue.length===e.timestampValue.length)return t.timestampValue===e.timestampValue;var n=P(t.timestampValue),r=P(e.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(t,e){return M(t.bytesValue).isEqual(M(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return F(t.geoPointValue.latitude)===F(e.geoPointValue.latitude)&&F(t.geoPointValue.longitude)===F(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return F(t.integerValue)===F(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){var n=F(t.doubleValue),r=F(e.doubleValue);return n===r?j(n)===j(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return b(t.arrayValue.values||[],e.arrayValue.values||[],z);case 10:return function(t,e){var n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(S(n)!==S(r))return!1;for(var i in n)if(n.hasOwnProperty(i)&&(void 0===r[i]||!z(n[i],r[i])))return!1;return!0}(t,e);default:return y()}}function W(t,e){return void 0!==(t.values||[]).find(function(t){return z(t,e)})}function H(t,e){var n=Q(t),r=Q(e);if(n!==r)return w(n,r);switch(n){case 0:return 0;case 1:return w(t.booleanValue,e.booleanValue);case 2:return function(t,e){var n=F(t.integerValue||t.doubleValue),r=F(e.integerValue||e.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(t,e);case 3:return Y(t.timestampValue,e.timestampValue);case 4:return Y(U(t),U(e));case 5:return w(t.stringValue,e.stringValue);case 6:return function(t,e){var n=M(t),r=M(e);return n.compareTo(r)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){for(var n=t.split("/"),r=e.split("/"),i=0;i<n.length&&i<r.length;i++){var o=w(n[i],r[i]);if(0!==o)return o}return w(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){var n=w(F(t.latitude),F(e.latitude));return 0!==n?n:w(F(t.longitude),F(e.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return function(t,e){for(var n=t.values||[],r=e.values||[],i=0;i<n.length&&i<r.length;++i){var o=H(n[i],r[i]);if(o)return o}return w(n.length,r.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){var n=t.fields||{},r=Object.keys(n),i=e.fields||{},o=Object.keys(i);r.sort(),o.sort();for(var s=0;s<r.length&&s<o.length;++s){var a=w(r[s],o[s]);if(0!==a)return a;var u=H(n[r[s]],i[o[s]]);if(0!==u)return u}return w(r.length,o.length)}(t.mapValue,e.mapValue);default:throw y()}}function Y(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return w(t,e);var n=P(t),r=P(e),i=w(n.seconds,r.seconds);return 0!==i?i:w(n.nanos,r.nanos)}function $(t){return X(t)}function X(t){return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?function(t){var e=P(t);return"time("+e.seconds+","+e.nanos+")"}(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?M(t.bytesValue).toBase64():"referenceValue"in t?(n=t.referenceValue,G.fromName(n).toString()):"geoPointValue"in t?"geo("+(e=t.geoPointValue).latitude+","+e.longitude+")":"arrayValue"in t?function(t){for(var e="[",n=!0,r=0,i=t.values||[];r<i.length;r++)n?n=!1:e+=",",e+=X(i[r]);return e+"]"}(t.arrayValue):"mapValue"in t?function(t){for(var e="{",n=!0,r=0,i=Object.keys(t.fields||{}).sort();r<i.length;r++){var o=i[r];n?n=!1:e+=",",e+=o+":"+X(t.fields[o])}return e+"}"}(t.mapValue):y();var e,n}function J(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.canonicalString()}}function Z(t){return!!t&&"integerValue"in t}function tt(t){return!!t&&"arrayValue"in t}function et(t){return!!t&&"nullValue"in t}function nt(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function rt(t){return!!t&&"mapValue"in t}function it(t){if(t.geoPointValue)return{geoPointValue:Object.assign({},t.geoPointValue)};if(t.timestampValue&&"object"==o(t.timestampValue))return{timestampValue:Object.assign({},t.timestampValue)};if(t.mapValue){var e={mapValue:{fields:{}}};return N(t.mapValue.fields,function(t,n){return e.mapValue.fields[t]=it(n)}),e}if(t.arrayValue){for(var n={arrayValue:{values:[]}},r=0;r<(t.arrayValue.values||[]).length;++r)n.arrayValue.values[r]=it(t.arrayValue.values[r]);return n}return Object.assign({},t)}var ot=function(){function t(t){this.value=t}return t.empty=function(){return new t({mapValue:{}})},t.prototype.field=function(t){if(t.isEmpty())return this.value;for(var e=this.value,n=0;n<t.length-1;++n)if(!rt(e=(e.mapValue.fields||{})[t.get(n)]))return null;return(e=(e.mapValue.fields||{})[t.lastSegment()])||null},t.prototype.set=function(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=it(e)},t.prototype.setAll=function(t){var e=this,n=C.emptyPath(),r={},i=[];t.forEach(function(t,o){if(!n.isImmediateParentOf(o)){var s=e.getFieldsMap(n);e.applyChanges(s,r,i),r={},i=[],n=o.popLast()}t?r[o.lastSegment()]=it(t):i.push(o.lastSegment())});var o=this.getFieldsMap(n);this.applyChanges(o,r,i)},t.prototype.delete=function(t){var e=this.field(t.popLast());rt(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]},t.prototype.isEqual=function(t){return z(this.value,t.value)},t.prototype.getFieldsMap=function(t){var e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(var n=0;n<t.length;++n){var r=e.mapValue.fields[t.get(n)];rt(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=r),e=r}return e.mapValue.fields},t.prototype.applyChanges=function(t,e,n){N(e,function(e,n){return t[e]=n});for(var r=0,i=n;r<i.length;r++){var o=i[r];delete t[o]}},t.prototype.clone=function(){return new t(it(this.value))},t}();function st(t){var e=[];return N(t.fields,function(t,n){var r=new C([t]);if(rt(n)){var i=st(n.mapValue).fields;if(0===i.length)e.push(r);else for(var o=0,s=i;o<s.length;o++){var a=s[o];e.push(r.child(a))}}else e.push(r)}),new R(e)}var at=function(){function t(t,e,n,r,i){this.key=t,this.documentType=e,this.version=n,this.data=r,this.documentState=i}return t.newInvalidDocument=function(e){return new t(e,0,T.min(),ot.empty(),0)},t.newFoundDocument=function(e,n,r){return new t(e,1,n,r,0)},t.newNoDocument=function(e,n){return new t(e,2,n,ot.empty(),0)},t.newUnknownDocument=function(e,n){return new t(e,3,n,ot.empty(),2)},t.prototype.convertToFoundDocument=function(t,e){return this.version=t,this.documentType=1,this.data=e,this.documentState=0,this},t.prototype.convertToNoDocument=function(t){return this.version=t,this.documentType=2,this.data=ot.empty(),this.documentState=0,this},t.prototype.convertToUnknownDocument=function(t){return this.version=t,this.documentType=3,this.data=ot.empty(),this.documentState=2,this},t.prototype.setHasCommittedMutations=function(){return this.documentState=2,this},t.prototype.setHasLocalMutations=function(){return this.documentState=1,this},Object.defineProperty(t.prototype,"hasLocalMutations",{get:function(){return 1===this.documentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasCommittedMutations",{get:function(){return 2===this.documentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPendingWrites",{get:function(){return this.hasLocalMutations||this.hasCommittedMutations},enumerable:!1,configurable:!0}),t.prototype.isValidDocument=function(){return 0!==this.documentType},t.prototype.isFoundDocument=function(){return 1===this.documentType},t.prototype.isNoDocument=function(){return 2===this.documentType},t.prototype.isUnknownDocument=function(){return 3===this.documentType},t.prototype.isEqual=function(e){return e instanceof t&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)},t.prototype.clone=function(){return new t(this.key,this.documentType,this.version,this.data.clone(),this.documentState)},t.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+JSON.stringify(this.data.value)+", {documentType: "+this.documentType+"}), {documentState: "+this.documentState+"})"},t}(),ut=function(t,e,n,r,i,o,s){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=s,this.h=null};function ct(t,e,n,r,i,o,s){return void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),new ut(t,e,n,r,i,o,s)}function ht(t){var e=m(t);if(null===e.h){var n=e.path.canonicalString();null!==e.collectionGroup&&(n+="|cg:"+e.collectionGroup),n+="|f:",n+=e.filters.map(function(t){return function(t){return t.field.canonicalString()+t.op.toString()+$(t.value)}(t)}).join(","),n+="|ob:",n+=e.orderBy.map(function(t){return function(t){return t.field.canonicalString()+t.dir}(t)}).join(","),B(e.limit)||(n+="|l:",n+=e.limit),e.startAt&&(n+="|lb:",n+=Et(e.startAt)),e.endAt&&(n+="|ub:",n+=Et(e.endAt)),e.h=n}return e.h}function ft(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(var n=0;n<t.orderBy.length;n++)if(!St(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(var r=0;r<t.filters.length;r++)if(i=t.filters[r],o=e.filters[r],i.op!==o.op||!i.field.isEqual(o.field)||!z(i.value,o.value))return!1;var i,o;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!Dt(t.startAt,e.startAt)&&Dt(t.endAt,e.endAt)}function lt(t){return G.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}var dt=function(t){function n(e,n,r){var i=this;return(i=t.call(this)||this).field=e,i.op=n,i.value=r,i}return(0,e.__extends)(n,t),n.create=function(t,e,r){return t.isKeyField()?"in"===e||"not-in"===e?this.l(t,e,r):new pt(t,e,r):"array-contains"===e?new gt(t,r):"in"===e?new _t(t,r):"not-in"===e?new wt(t,r):"array-contains-any"===e?new bt(t,r):new n(t,e,r)},n.l=function(t,e,n){return"in"===e?new yt(t,n):new vt(t,n)},n.prototype.matches=function(t){var e=t.data.field(this.field);return"!="===this.op?null!==e&&this.m(H(e,this.value)):null!==e&&Q(this.value)===Q(e)&&this.m(H(e,this.value))},n.prototype.m=function(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return y()}},n.prototype.g=function(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0},n}(function(){}),pt=function(t){function n(e,n,r){var i=this;return(i=t.call(this,e,n,r)||this).key=G.fromName(r.referenceValue),i}return(0,e.__extends)(n,t),n.prototype.matches=function(t){var e=G.comparator(t.key,this.key);return this.m(e)},n}(dt),yt=function(t){function n(e,n){var r=this;return(r=t.call(this,e,"in",n)||this).keys=mt("in",n),r}return(0,e.__extends)(n,t),n.prototype.matches=function(t){return this.keys.some(function(e){return e.isEqual(t.key)})},n}(dt),vt=function(t){function n(e,n){var r=this;return(r=t.call(this,e,"not-in",n)||this).keys=mt("not-in",n),r}return(0,e.__extends)(n,t),n.prototype.matches=function(t){return!this.keys.some(function(e){return e.isEqual(t.key)})},n}(dt);function mt(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map(function(t){return G.fromName(t.referenceValue)})}var gt=function(t){function n(e,n){return t.call(this,e,"array-contains",n)||this}return(0,e.__extends)(n,t),n.prototype.matches=function(t){var e=t.data.field(this.field);return tt(e)&&W(e.arrayValue,this.value)},n}(dt),_t=function(t){function n(e,n){return t.call(this,e,"in",n)||this}return(0,e.__extends)(n,t),n.prototype.matches=function(t){var e=t.data.field(this.field);return null!==e&&W(this.value.arrayValue,e)},n}(dt),wt=function(t){function n(e,n){return t.call(this,e,"not-in",n)||this}return(0,e.__extends)(n,t),n.prototype.matches=function(t){if(W(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var e=t.data.field(this.field);return null!==e&&!W(this.value.arrayValue,e)},n}(dt),bt=function(t){function n(e,n){return t.call(this,e,"array-contains-any",n)||this}return(0,e.__extends)(n,t),n.prototype.matches=function(t){var e=this,n=t.data.field(this.field);return!(!tt(n)||!n.arrayValue.values)&&n.arrayValue.values.some(function(t){return W(e.value.arrayValue,t)})},n}(dt),It=function(t,e){this.position=t,this.before=e};function Et(t){return(t.before?"b":"a")+":"+t.position.map(function(t){return $(t)}).join(",")}var Tt=function(t,e){void 0===e&&(e="asc"),this.field=t,this.dir=e};function St(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}function Nt(t,e,n){for(var r=0,i=0;i<t.position.length;i++){var o=e[i],s=t.position[i];if(r=o.field.isKeyField()?G.comparator(G.fromName(s.referenceValue),n.key):H(s,n.data.field(o.field)),"desc"===o.dir&&(r*=-1),0!==r)break}return t.before?r<=0:r<0}function Dt(t,e){if(null===t)return null===e;if(null===e)return!1;if(t.before!==e.before||t.position.length!==e.position.length)return!1;for(var n=0;n<t.position.length;n++)if(!z(t.position[n],e.position[n]))return!1;return!0}var At=function(t,e,n,r,i,o,s,a){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o="F"),void 0===s&&(s=null),void 0===a&&(a=null),this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=o,this.startAt=s,this.endAt=a,this.p=null,this.T=null,this.startAt,this.endAt};function xt(t,e,n,r,i,o,s,a){return new At(t,e,n,r,i,o,s,a)}function kt(t){return new At(t)}function Ct(t){return!B(t.limit)&&"F"===t.limitType}function Rt(t){return!B(t.limit)&&"L"===t.limitType}function Lt(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function Ot(t){for(var e=0,n=t.filters;e<n.length;e++){var r=n[e];if(r.g())return r.field}return null}function Pt(t){return null!==t.collectionGroup}function Ft(t){var e=m(t);if(null===e.p){e.p=[];var n=Ot(e),r=Lt(e);if(null!==n&&null===r)n.isKeyField()||e.p.push(new Tt(n)),e.p.push(new Tt(C.keyField(),"asc"));else{for(var i=!1,o=0,s=e.explicitOrderBy;o<s.length;o++){var a=s[o];e.p.push(a),a.field.isKeyField()&&(i=!0)}if(!i){var u=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e.p.push(new Tt(C.keyField(),u))}}}return e.p}function Mt(t){var e=m(t);if(!e.T)if("F"===e.limitType)e.T=ct(e.path,e.collectionGroup,Ft(e),e.filters,e.limit,e.startAt,e.endAt);else{for(var n=[],r=0,i=Ft(e);r<i.length;r++){var o=i[r],s="desc"===o.dir?"asc":"desc";n.push(new Tt(o.field,s))}var a=e.endAt?new It(e.endAt.position,!e.endAt.before):null,u=e.startAt?new It(e.startAt.position,!e.startAt.before):null;e.T=ct(e.path,e.collectionGroup,n,e.filters,e.limit,a,u)}return e.T}function Vt(t,e,n){return new At(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function qt(t,e){return ft(Mt(t),Mt(e))&&t.limitType===e.limitType}function Ut(t){return ht(Mt(t))+"|lt:"+t.limitType}function Bt(t){return"Query(target="+function(t){var e=t.path.canonicalString();return null!==t.collectionGroup&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=", filters: ["+t.filters.map(function(t){return(e=t).field.canonicalString()+" "+e.op+" "+$(e.value);var e}).join(", ")+"]"),B(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=", orderBy: ["+t.orderBy.map(function(t){return function(t){return t.field.canonicalString()+" ("+t.dir+")"}(t)}).join(", ")+"]"),t.startAt&&(e+=", startAt: "+Et(t.startAt)),t.endAt&&(e+=", endAt: "+Et(t.endAt)),"Target("+e+")"}(Mt(t))+"; limitType="+t.limitType+")"}function jt(t,e){return e.isFoundDocument()&&function(t,e){var n=e.key.path;return null!==t.collectionGroup?e.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(n):G.isDocumentKey(t.path)?t.path.isEqual(n):t.path.isImmediateParentOf(n)}(t,e)&&function(t,e){for(var n=0,r=t.explicitOrderBy;n<r.length;n++){var i=r[n];if(!i.field.isKeyField()&&null===e.data.field(i.field))return!1}return!0}(t,e)&&function(t,e){for(var n=0,r=t.filters;n<r.length;n++)if(!r[n].matches(e))return!1;return!0}(t,e)&&function(t,e){return!(t.startAt&&!Nt(t.startAt,Ft(t),e)||t.endAt&&Nt(t.endAt,Ft(t),e))}(t,e)}function Kt(t){return function(e,n){for(var r=!1,i=0,o=Ft(t);i<o.length;i++){var s=o[i],a=Gt(s,e,n);if(0!==a)return a;r=r||s.field.isKeyField()}return 0}}function Gt(t,e,n){var r=t.field.isKeyField()?G.comparator(e.key,n.key):function(t,e,n){var r=e.data.field(t),i=n.data.field(t);return null!==r&&null!==i?H(r,i):y()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return y()}}function Qt(t,e){if(t.I){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:j(e)?"-0":e}}function zt(t){return{integerValue:""+t}}function Wt(t,e){return K(e)?zt(e):Qt(t,e)}var Ht=function(){this._=void 0};function Yt(t,e,n){return t instanceof Jt?function(t,e){var n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:t.seconds,nanos:t.nanoseconds}}}};return e&&(n.fields.__previous_value__=e),{mapValue:n}}(n,e):t instanceof Zt?te(t,e):t instanceof ee?ne(t,e):function(t,e){var n=Xt(t,e),r=ie(n)+ie(t.A);return Z(n)&&Z(t.A)?zt(r):Qt(t.R,r)}(t,e)}function $t(t,e,n){return t instanceof Zt?te(t,e):t instanceof ee?ne(t,e):n}function Xt(t,e){return t instanceof re?Z(n=e)||n&&"doubleValue"in n?e:{integerValue:0}:null;var n}var Jt=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return(0,e.__extends)(n,t),n}(Ht),Zt=function(t){function n(e){var n=this;return(n=t.call(this)||this).elements=e,n}return(0,e.__extends)(n,t),n}(Ht);function te(t,e){for(var n=oe(e),r=function(t){n.some(function(e){return z(e,t)})||n.push(t)},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var ee=function(t){function n(e){var n=this;return(n=t.call(this)||this).elements=e,n}return(0,e.__extends)(n,t),n}(Ht);function ne(t,e){for(var n=oe(e),r=function(t){n=n.filter(function(e){return!z(e,t)})},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var re=function(t){function n(e,n){var r=this;return(r=t.call(this)||this).R=e,r.A=n,r}return(0,e.__extends)(n,t),n}(Ht);function ie(t){return F(t.integerValue||t.doubleValue)}function oe(t){return tt(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}var se=function(t,e){this.field=t,this.transform=e},ae=function(t,e){this.version=t,this.transformResults=e},ue=function(){function t(t,e){this.updateTime=t,this.exists=e}return t.none=function(){return new t},t.exists=function(e){return new t(void 0,e)},t.updateTime=function(e){return new t(e)},Object.defineProperty(t.prototype,"isNone",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)},t}();function ce(t,e){return void 0!==t.updateTime?e.isFoundDocument()&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e.isFoundDocument()}var he=function(){};function fe(t,e,n){t instanceof ve?function(t,e,n){var r=t.value.clone(),i=_e(t.fieldTransforms,e,n.transformResults);r.setAll(i),e.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(t,e,n):t instanceof me?function(t,e,n){if(ce(t.precondition,e)){var r=_e(t.fieldTransforms,e,n.transformResults),i=e.data;i.setAll(ge(t)),i.setAll(r),e.convertToFoundDocument(n.version,i).setHasCommittedMutations()}else e.convertToUnknownDocument(n.version)}(t,e,n):function(t,e,n){e.convertToNoDocument(n.version).setHasCommittedMutations()}(0,e,n)}function le(t,e,n){t instanceof ve?function(t,e,n){if(ce(t.precondition,e)){var r=t.value.clone(),i=we(t.fieldTransforms,n,e);r.setAll(i),e.convertToFoundDocument(ye(e),r).setHasLocalMutations()}}(t,e,n):t instanceof me?function(t,e,n){if(ce(t.precondition,e)){var r=we(t.fieldTransforms,n,e),i=e.data;i.setAll(ge(t)),i.setAll(r),e.convertToFoundDocument(ye(e),i).setHasLocalMutations()}}(t,e,n):function(t,e){ce(t.precondition,e)&&e.convertToNoDocument(T.min())}(t,e)}function de(t,e){for(var n=null,r=0,i=t.fieldTransforms;r<i.length;r++){var o=i[r],s=e.data.field(o.field),a=Xt(o.transform,s||null);null!=a&&(null==n&&(n=ot.empty()),n.set(o.field,a))}return n||null}function pe(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!function(t,e){return void 0===t&&void 0===e||!(!t||!e)&&b(t,e,function(t,e){return function(t,e){return t.field.isEqual(e.field)&&function(t,e){return t instanceof Zt&&e instanceof Zt||t instanceof ee&&e instanceof ee?b(t.elements,e.elements,z):t instanceof re&&e instanceof re?z(t.A,e.A):t instanceof Jt&&e instanceof Jt}(t.transform,e.transform)}(t,e)})}(t.fieldTransforms,e.fieldTransforms)&&(0===t.type?t.value.isEqual(e.value):1!==t.type||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}function ye(t){return t.isFoundDocument()?t.version:T.min()}var ve=function(t){function n(e,n,r,i){void 0===i&&(i=[]);var o=this;return(o=t.call(this)||this).key=e,o.value=n,o.precondition=r,o.fieldTransforms=i,o.type=0,o}return(0,e.__extends)(n,t),n}(he),me=function(t){function n(e,n,r,i,o){void 0===o&&(o=[]);var s=this;return(s=t.call(this)||this).key=e,s.data=n,s.fieldMask=r,s.precondition=i,s.fieldTransforms=o,s.type=1,s}return(0,e.__extends)(n,t),n}(he);function ge(t){var e=new Map;return t.fieldMask.fields.forEach(function(n){if(!n.isEmpty()){var r=t.data.field(n);e.set(n,r)}}),e}function _e(t,e,n){var r=new Map;v(t.length===n.length);for(var i=0;i<n.length;i++){var o=t[i],s=o.transform,a=e.data.field(o.field);r.set(o.field,$t(s,a,n[i]))}return r}function we(t,e,n){for(var r=new Map,i=0,o=t;i<o.length;i++){var s=o[i],a=s.transform,u=n.data.field(s.field);r.set(s.field,Yt(a,u,e))}return r}var be,Ie,Ee=function(t){function n(e,n){var r=this;return(r=t.call(this)||this).key=e,r.precondition=n,r.type=2,r.fieldTransforms=[],r}return(0,e.__extends)(n,t),n}(he),Te=function(t){function n(e,n){var r=this;return(r=t.call(this)||this).key=e,r.precondition=n,r.type=3,r.fieldTransforms=[],r}return(0,e.__extends)(n,t),n}(he),Se=function(t){this.count=t};function Ne(t){switch(t){case a.OK:return y();case a.CANCELLED:case a.UNKNOWN:case a.DEADLINE_EXCEEDED:case a.RESOURCE_EXHAUSTED:case a.INTERNAL:case a.UNAVAILABLE:case a.UNAUTHENTICATED:return!1;case a.INVALID_ARGUMENT:case a.NOT_FOUND:case a.ALREADY_EXISTS:case a.PERMISSION_DENIED:case a.FAILED_PRECONDITION:case a.ABORTED:case a.OUT_OF_RANGE:case a.UNIMPLEMENTED:case a.DATA_LOSS:return!0;default:return y()}}function De(t){if(void 0===t)return l("GRPC error has no .code"),a.UNKNOWN;switch(t){case be.OK:return a.OK;case be.CANCELLED:return a.CANCELLED;case be.UNKNOWN:return a.UNKNOWN;case be.DEADLINE_EXCEEDED:return a.DEADLINE_EXCEEDED;case be.RESOURCE_EXHAUSTED:return a.RESOURCE_EXHAUSTED;case be.INTERNAL:return a.INTERNAL;case be.UNAVAILABLE:return a.UNAVAILABLE;case be.UNAUTHENTICATED:return a.UNAUTHENTICATED;case be.INVALID_ARGUMENT:return a.INVALID_ARGUMENT;case be.NOT_FOUND:return a.NOT_FOUND;case be.ALREADY_EXISTS:return a.ALREADY_EXISTS;case be.PERMISSION_DENIED:return a.PERMISSION_DENIED;case be.FAILED_PRECONDITION:return a.FAILED_PRECONDITION;case be.ABORTED:return a.ABORTED;case be.OUT_OF_RANGE:return a.OUT_OF_RANGE;case be.UNIMPLEMENTED:return a.UNIMPLEMENTED;case be.DATA_LOSS:return a.DATA_LOSS;default:return y()}}(Ie=be||(be={}))[Ie.OK=0]="OK",Ie[Ie.CANCELLED=1]="CANCELLED",Ie[Ie.UNKNOWN=2]="UNKNOWN",Ie[Ie.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Ie[Ie.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Ie[Ie.NOT_FOUND=5]="NOT_FOUND",Ie[Ie.ALREADY_EXISTS=6]="ALREADY_EXISTS",Ie[Ie.PERMISSION_DENIED=7]="PERMISSION_DENIED",Ie[Ie.UNAUTHENTICATED=16]="UNAUTHENTICATED",Ie[Ie.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Ie[Ie.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Ie[Ie.ABORTED=10]="ABORTED",Ie[Ie.OUT_OF_RANGE=11]="OUT_OF_RANGE",Ie[Ie.UNIMPLEMENTED=12]="UNIMPLEMENTED",Ie[Ie.INTERNAL=13]="INTERNAL",Ie[Ie.UNAVAILABLE=14]="UNAVAILABLE",Ie[Ie.DATA_LOSS=15]="DATA_LOSS";var Ae=function(){function t(t,e){this.comparator=t,this.root=e||ke.EMPTY}return t.prototype.insert=function(e,n){return new t(this.comparator,this.root.insert(e,n,this.comparator).copy(null,null,ke.BLACK,null,null))},t.prototype.remove=function(e){return new t(this.comparator,this.root.remove(e,this.comparator).copy(null,null,ke.BLACK,null,null))},t.prototype.get=function(t){for(var e=this.root;!e.isEmpty();){var n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null},t.prototype.indexOf=function(t){for(var e=0,n=this.root;!n.isEmpty();){var r=this.comparator(t,n.key);if(0===r)return e+n.left.size;r<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1},t.prototype.isEmpty=function(){return this.root.isEmpty()},Object.defineProperty(t.prototype,"size",{get:function(){return this.root.size},enumerable:!1,configurable:!0}),t.prototype.minKey=function(){return this.root.minKey()},t.prototype.maxKey=function(){return this.root.maxKey()},t.prototype.inorderTraversal=function(t){return this.root.inorderTraversal(t)},t.prototype.forEach=function(t){this.inorderTraversal(function(e,n){return t(e,n),!1})},t.prototype.toString=function(){var t=[];return this.inorderTraversal(function(e,n){return t.push(e+":"+n),!1}),"{"+t.join(", ")+"}"},t.prototype.reverseTraversal=function(t){return this.root.reverseTraversal(t)},t.prototype.getIterator=function(){return new xe(this.root,null,this.comparator,!1)},t.prototype.getIteratorFrom=function(t){return new xe(this.root,t,this.comparator,!1)},t.prototype.getReverseIterator=function(){return new xe(this.root,null,this.comparator,!0)},t.prototype.getReverseIteratorFrom=function(t){return new xe(this.root,t,this.comparator,!0)},t}(),xe=function(){function t(t,e,n,r){this.isReverse=r,this.nodeStack=[];for(var i=1;!t.isEmpty();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.isReverse?t.left:t.right;else{if(0===i){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}return t.prototype.getNext=function(){var t=this.nodeStack.pop(),e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e},t.prototype.hasNext=function(){return this.nodeStack.length>0},t.prototype.peek=function(){if(0===this.nodeStack.length)return null;var t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}},t}(),ke=function(){function t(e,n,r,i,o){this.key=e,this.value=n,this.color=null!=r?r:t.RED,this.left=null!=i?i:t.EMPTY,this.right=null!=o?o:t.EMPTY,this.size=this.left.size+1+this.right.size}return t.prototype.copy=function(e,n,r,i,o){return new t(null!=e?e:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},t.prototype.isEmpty=function(){return!1},t.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},t.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},t.prototype.min=function(){return this.left.isEmpty()?this:this.left.min()},t.prototype.minKey=function(){return this.min().key},t.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},t.prototype.insert=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n))).fixUp()},t.prototype.removeMin=function(){if(this.left.isEmpty())return t.EMPTY;var e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),(e=e.copy(null,null,null,e.left.removeMin(),null)).fixUp()},t.prototype.remove=function(e,n){var r,i=this;if(n(e,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(e,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),0===n(e,i.key)){if(i.right.isEmpty())return t.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(e,n))}return i.fixUp()},t.prototype.isRed=function(){return this.color},t.prototype.fixUp=function(){var t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t},t.prototype.moveRedLeft=function(){var t=this.colorFlip();return t.right.left.isRed()&&(t=(t=(t=t.copy(null,null,null,null,t.right.rotateRight())).rotateLeft()).colorFlip()),t},t.prototype.moveRedRight=function(){var t=this.colorFlip();return t.left.left.isRed()&&(t=(t=t.rotateRight()).colorFlip()),t},t.prototype.rotateLeft=function(){var e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)},t.prototype.rotateRight=function(){var e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)},t.prototype.colorFlip=function(){var t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)},t.prototype.checkMaxDepth=function(){var t=this.check();return Math.pow(2,t)<=this.size+1},t.prototype.check=function(){if(this.isRed()&&this.left.isRed())throw y();if(this.right.isRed())throw y();var t=this.left.check();if(t!==this.right.check())throw y();return t+(this.isRed()?0:1)},t}();ke.EMPTY=null,ke.RED=!0,ke.BLACK=!1,ke.EMPTY=new(function(){function t(){this.size=0}return Object.defineProperty(t.prototype,"key",{get:function(){throw y()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){throw y()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){throw y()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){throw y()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){throw y()},enumerable:!1,configurable:!0}),t.prototype.copy=function(t,e,n,r,i){return this},t.prototype.insert=function(t,e,n){return new ke(t,e)},t.prototype.remove=function(t,e){return this},t.prototype.isEmpty=function(){return!0},t.prototype.inorderTraversal=function(t){return!1},t.prototype.reverseTraversal=function(t){return!1},t.prototype.minKey=function(){return null},t.prototype.maxKey=function(){return null},t.prototype.isRed=function(){return!1},t.prototype.checkMaxDepth=function(){return!0},t.prototype.check=function(){return 0},t}());var Ce=function(){function t(t){this.comparator=t,this.data=new Ae(this.comparator)}return t.prototype.has=function(t){return null!==this.data.get(t)},t.prototype.first=function(){return this.data.minKey()},t.prototype.last=function(){return this.data.maxKey()},Object.defineProperty(t.prototype,"size",{get:function(){return this.data.size},enumerable:!1,configurable:!0}),t.prototype.indexOf=function(t){return this.data.indexOf(t)},t.prototype.forEach=function(t){this.data.inorderTraversal(function(e,n){return t(e),!1})},t.prototype.forEachInRange=function(t,e){for(var n=this.data.getIteratorFrom(t[0]);n.hasNext();){var r=n.getNext();if(this.comparator(r.key,t[1])>=0)return;e(r.key)}},t.prototype.forEachWhile=function(t,e){var n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return},t.prototype.firstAfterOrEqual=function(t){var e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null},t.prototype.getIterator=function(){return new Re(this.data.getIterator())},t.prototype.getIteratorFrom=function(t){return new Re(this.data.getIteratorFrom(t))},t.prototype.add=function(t){return this.copy(this.data.remove(t).insert(t,!0))},t.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},t.prototype.isEmpty=function(){return this.data.isEmpty()},t.prototype.unionWith=function(t){var e=this;return e.size<t.size&&(e=t,t=this),t.forEach(function(t){e=e.add(t)}),e},t.prototype.isEqual=function(e){if(!(e instanceof t))return!1;if(this.size!==e.size)return!1;for(var n=this.data.getIterator(),r=e.data.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(0!==this.comparator(i,o))return!1}return!0},t.prototype.toArray=function(){var t=[];return this.forEach(function(e){t.push(e)}),t},t.prototype.toString=function(){var t=[];return this.forEach(function(e){return t.push(e)}),"SortedSet("+t.toString()+")"},t.prototype.copy=function(e){var n=new t(this.comparator);return n.data=e,n},t}(),Re=function(){function t(t){this.iter=t}return t.prototype.getNext=function(){return this.iter.getNext().key},t.prototype.hasNext=function(){return this.iter.hasNext()},t}(),Le=new Ae(G.comparator);function Oe(){return Le}var Pe=new Ae(G.comparator);function Fe(){return Pe}var Me=new Ae(G.comparator);function Ve(){return Me}var qe=new Ce(G.comparator);function Ue(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=qe,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var Be=new Ce(w);function je(){return Be}var Ke=function(){function t(t,e,n,r,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}return t.createSynthesizedRemoteEventForCurrentChange=function(e,n){var r=new Map;return r.set(e,Ge.createSynthesizedTargetChangeForCurrentChange(e,n)),new t(T.min(),r,je(),Oe(),Ue())},t}(),Ge=function(){function t(t,e,n,r,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}return t.createSynthesizedTargetChangeForCurrentChange=function(e,n){return new t(L.EMPTY_BYTE_STRING,n,Ue(),Ue(),Ue())},t}(),Qe=function(t,e,n,r){this.v=t,this.removedTargetIds=e,this.key=n,this.P=r},ze=function(t,e){this.targetId=t,this.V=e},We=function(t,e,n,r){void 0===n&&(n=L.EMPTY_BYTE_STRING),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},He=function(){function t(){this.S=0,this.D=Xe(),this.C=L.EMPTY_BYTE_STRING,this.N=!1,this.k=!0}return Object.defineProperty(t.prototype,"current",{get:function(){return this.N},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resumeToken",{get:function(){return this.C},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"F",{get:function(){return 0!==this.S},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"$",{get:function(){return this.k},enumerable:!1,configurable:!0}),t.prototype.O=function(t){t.approximateByteSize()>0&&(this.k=!0,this.C=t)},t.prototype.M=function(){var t=Ue(),e=Ue(),n=Ue();return this.D.forEach(function(r,i){switch(i){case 0:t=t.add(r);break;case 2:e=e.add(r);break;case 1:n=n.add(r);break;default:y()}}),new Ge(this.C,this.N,t,e,n)},t.prototype.L=function(){this.k=!1,this.D=Xe()},t.prototype.B=function(t,e){this.k=!0,this.D=this.D.insert(t,e)},t.prototype.q=function(t){this.k=!0,this.D=this.D.remove(t)},t.prototype.U=function(){this.S+=1},t.prototype.K=function(){this.S-=1},t.prototype.j=function(){this.k=!0,this.N=!0},t}(),Ye=function(){function t(t){this.W=t,this.G=new Map,this.H=Oe(),this.J=$e(),this.Y=new Ce(w)}return t.prototype.X=function(t){for(var e=0,n=t.v;e<n.length;e++){var r=n[e];t.P&&t.P.isFoundDocument()?this.Z(r,t.P):this.tt(r,t.key,t.P)}for(var i=0,o=t.removedTargetIds;i<o.length;i++)r=o[i],this.tt(r,t.key,t.P)},t.prototype.et=function(t){var e=this;this.forEachTarget(t,function(n){var r=e.nt(n);switch(t.state){case 0:e.st(n)&&r.O(t.resumeToken);break;case 1:r.K(),r.F||r.L(),r.O(t.resumeToken);break;case 2:r.K(),r.F||e.removeTarget(n);break;case 3:e.st(n)&&(r.j(),r.O(t.resumeToken));break;case 4:e.st(n)&&(e.it(n),r.O(t.resumeToken));break;default:y()}})},t.prototype.forEachTarget=function(t,e){var n=this;t.targetIds.length>0?t.targetIds.forEach(e):this.G.forEach(function(t,r){n.st(r)&&e(r)})},t.prototype.rt=function(t){var e=t.targetId,n=t.V.count,r=this.ot(e);if(r){var i=r.target;if(lt(i))if(0===n){var o=new G(i.path);this.tt(e,o,at.newNoDocument(o,T.min()))}else v(1===n);else this.ct(e)!==n&&(this.it(e),this.Y=this.Y.add(e))}},t.prototype.ut=function(t){var e=this,n=new Map;this.G.forEach(function(r,i){var o=e.ot(i);if(o){if(r.current&<(o.target)){var s=new G(o.target.path);null!==e.H.get(s)||e.at(i,s)||e.tt(i,s,at.newNoDocument(s,t))}r.$&&(n.set(i,r.M()),r.L())}});var r=Ue();this.J.forEach(function(t,n){var i=!0;n.forEachWhile(function(t){var n=e.ot(t);return!n||2===n.purpose||(i=!1,!1)}),i&&(r=r.add(t))});var i=new Ke(t,n,this.Y,this.H,r);return this.H=Oe(),this.J=$e(),this.Y=new Ce(w),i},t.prototype.Z=function(t,e){if(this.st(t)){var n=this.at(t,e.key)?2:0;this.nt(t).B(e.key,n),this.H=this.H.insert(e.key,e),this.J=this.J.insert(e.key,this.ht(e.key).add(t))}},t.prototype.tt=function(t,e,n){if(this.st(t)){var r=this.nt(t);this.at(t,e)?r.B(e,1):r.q(e),this.J=this.J.insert(e,this.ht(e).delete(t)),n&&(this.H=this.H.insert(e,n))}},t.prototype.removeTarget=function(t){this.G.delete(t)},t.prototype.ct=function(t){var e=this.nt(t).M();return this.W.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size},t.prototype.U=function(t){this.nt(t).U()},t.prototype.nt=function(t){var e=this.G.get(t);return e||(e=new He,this.G.set(t,e)),e},t.prototype.ht=function(t){var e=this.J.get(t);return e||(e=new Ce(w),this.J=this.J.insert(t,e)),e},t.prototype.st=function(t){var e=null!==this.ot(t);return e||f("WatchChangeAggregator","Detected inactive target",t),e},t.prototype.ot=function(t){var e=this.G.get(t);return e&&e.F?null:this.W.lt(t)},t.prototype.it=function(t){var e=this;this.G.set(t,new He),this.W.getRemoteKeysForTarget(t).forEach(function(n){e.tt(t,n,null)})},t.prototype.at=function(t,e){return this.W.getRemoteKeysForTarget(t).has(e)},t}();function $e(){return new Ae(G.comparator)}function Xe(){return new Ae(G.comparator)}var Je={asc:"ASCENDING",desc:"DESCENDING"},Ze={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},tn=function(t,e){this.databaseId=t,this.I=e};function en(t,e){return t.I?new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+e.nanoseconds).slice(-9)+"Z":{seconds:""+e.seconds,nanos:e.nanoseconds}}function nn(t,e){return t.I?e.toBase64():e.toUint8Array()}function rn(t,e){return en(t,e.toTimestamp())}function on(t){return v(!!t),T.fromTimestamp(function(t){var e=P(t);return new E(e.seconds,e.nanos)}(t))}function sn(t,e){return function(t){return new x(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).canonicalString()}function an(t){var e=x.fromString(t);return v(Cn(e)),e}function un(t,e){return sn(t.databaseId,e.path)}function cn(t,e){var n=an(e);if(n.get(1)!==t.databaseId.projectId)throw new u(a.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new u(a.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new G(dn(n))}function hn(t,e){return sn(t.databaseId,e)}function fn(t){var e=an(t);return 4===e.length?x.emptyPath():dn(e)}function ln(t){return new x(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function dn(t){return v(t.length>4&&"documents"===t.get(4)),t.popFirst(5)}function pn(t,e,n){return{name:un(t,e),fields:n.value.mapValue.fields}}function yn(t,e,n){var r=cn(t,e.name),i=on(e.updateTime),o=new ot({mapValue:{fields:e.fields}}),s=at.newFoundDocument(r,i,o);return n&&s.setHasCommittedMutations(),n?s.setHasCommittedMutations():s}function vn(t,e){var n;if(e instanceof ve)n={update:pn(t,e.key,e.value)};else if(e instanceof Ee)n={delete:un(t,e.key)};else if(e instanceof me)n={update:pn(t,e.key,e.data),updateMask:kn(e.fieldMask)};else{if(!(e instanceof Te))return y();n={verify:un(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map(function(t){return function(t,e){var n=e.transform;if(n instanceof Jt)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof Zt)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof ee)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof re)return{fieldPath:e.field.canonicalString(),increment:n.A};throw y()}(0,t)})),e.precondition.isNone||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:rn(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:y()}(t,e.precondition)),n}function mn(t,e){var n=e.currentDocument?function(t){return void 0!==t.updateTime?ue.updateTime(on(t.updateTime)):void 0!==t.exists?ue.exists(t.exists):ue.none()}(e.currentDocument):ue.none(),r=e.updateTransforms?e.updateTransforms.map(function(e){return function(t,e){var n=null;if("setToServerValue"in e)v("REQUEST_TIME"===e.setToServerValue),n=new Jt;else if("appendMissingElements"in e){var r=e.appendMissingElements.values||[];n=new Zt(r)}else if("removeAllFromArray"in e){var i=e.removeAllFromArray.values||[];n=new ee(i)}else"increment"in e?n=new re(t,e.increment):y();var o=C.fromServerFormat(e.fieldPath);return new se(o,n)}(t,e)}):[];if(e.update){e.update.name;var i=cn(t,e.update.name),o=new ot({mapValue:{fields:e.update.fields}});if(e.updateMask){var s=function(t){var e=t.fieldPaths||[];return new R(e.map(function(t){return C.fromServerFormat(t)}))}(e.updateMask);return new me(i,o,s,n,r)}return new ve(i,o,n,r)}if(e.delete){var a=cn(t,e.delete);return new Ee(a,n)}if(e.verify){var u=cn(t,e.verify);return new Te(u,n)}return y()}function gn(t,e){return{documents:[hn(t,e.path)]}}function _n(t,e){var n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=hn(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=hn(t,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);var i=function(t){if(0!==t.length){var e=t.map(function(t){return function(t){if("=="===t.op){if(nt(t.value))return{unaryFilter:{field:Nn(t.field),op:"IS_NAN"}};if(et(t.value))return{unaryFilter:{field:Nn(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(nt(t.value))return{unaryFilter:{field:Nn(t.field),op:"IS_NOT_NAN"}};if(et(t.value))return{unaryFilter:{field:Nn(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Nn(t.field),op:Sn(t.op),value:t.value}}}(t)});return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}}(e.filters);i&&(n.structuredQuery.where=i);var o=function(t){if(0!==t.length)return t.map(function(t){return function(t){return{field:Nn(t.field),direction:Tn(t.dir)}}(t)})}(e.orderBy);o&&(n.structuredQuery.orderBy=o);var s=function(t,e){return t.I||B(e)?e:{value:e}}(t,e.limit);return null!==s&&(n.structuredQuery.limit=s),e.startAt&&(n.structuredQuery.startAt=In(e.startAt)),e.endAt&&(n.structuredQuery.endAt=In(e.endAt)),n}function wn(t){var e=fn(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){v(1===r);var s=n.from[0];s.allDescendants?i=s.collectionId:e=e.child(s.collectionId)}var a=[];n.where&&(a=bn(n.where));var u=[];n.orderBy&&(u=n.orderBy.map(function(t){return function(t){return new Tt(Dn(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))}(t)}));var c=null;n.limit&&(c=function(t){var e;return B(e="object"==o(t)?t.value:t)?null:e}(n.limit));var h=null;n.startAt&&(h=En(n.startAt));var f=null;return n.endAt&&(f=En(n.endAt)),xt(e,i,u,a,c,"F",h,f)}function bn(t){return t?void 0!==t.unaryFilter?[xn(t)]:void 0!==t.fieldFilter?[An(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map(function(t){return bn(t)}).reduce(function(t,e){return t.concat(e)}):y():[]}function In(t){return{before:t.before,values:t.position}}function En(t){var e=!!t.before,n=t.values||[];return new It(n,e)}function Tn(t){return Je[t]}function Sn(t){return Ze[t]}function Nn(t){return{fieldPath:t.canonicalString()}}function Dn(t){return C.fromServerFormat(t.fieldPath)}function An(t){return dt.create(Dn(t.fieldFilter.field),function(t){switch(t){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":default:return y()}}(t.fieldFilter.op),t.fieldFilter.value)}function xn(t){switch(t.unaryFilter.op){case"IS_NAN":var e=Dn(t.unaryFilter.field);return dt.create(e,"==",{doubleValue:NaN});case"IS_NULL":var n=Dn(t.unaryFilter.field);return dt.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var r=Dn(t.unaryFilter.field);return dt.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":var i=Dn(t.unaryFilter.field);return dt.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":default:return y()}}function kn(t){var e=[];return t.fields.forEach(function(t){return e.push(t.canonicalString())}),{fieldPaths:e}}function Cn(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}function Rn(t){for(var e="",n=0;n<t.length;n++)e.length>0&&(e=On(e)),e=Ln(t.get(n),e);return On(e)}function Ln(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+="";break;case"":n+="";break;default:n+=o}}return n}function On(t){return t+""}function Pn(t){var e=t.length;if(v(e>=2),2===e)return v(""===t.charAt(0)&&""===t.charAt(1)),x.emptyPath();for(var n=e-2,r=[],i="",o=0;o<e;){var s=t.indexOf("",o);switch((s<0||s>n)&&y(),t.charAt(s+1)){case"":var a=t.substring(o,s),u=void 0;0===i.length?u=a:(u=i+=a,i=""),r.push(u);break;case"":i+=t.substring(o,s),i+="\0";break;case"":i+=t.substring(o,s+1);break;default:y()}o=s+2}return new x(r)}var Fn=function(t,e){this.seconds=t,this.nanoseconds=e},Mn=function(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n};Mn.store="owner",Mn.key="owner";var Vn=function(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n};Vn.store="mutationQueues",Vn.keyPath="userId";var qn=function(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};qn.store="mutations",qn.keyPath="batchId",qn.userMutationsIndex="userMutationsIndex",qn.userMutationsKeyPath=["userId","batchId"];var Un=function(){function t(){}return t.prefixForUser=function(t){return[t]},t.prefixForPath=function(t,e){return[t,Rn(e)]},t.key=function(t,e,n){return[t,Rn(e),n]},t}();Un.store="documentMutations",Un.PLACEHOLDER=new Un;var Bn=function(t,e){this.path=t,this.readTime=e},jn=function(t,e){this.path=t,this.version=e},Kn=function(t,e,n,r,i,o){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o};Kn.store="remoteDocuments",Kn.readTimeIndex="readTimeIndex",Kn.readTimeIndexPath="readTime",Kn.collectionReadTimeIndex="collectionReadTimeIndex",Kn.collectionReadTimeIndexPath=["parentPath","readTime"];var Gn=function(t){this.byteSize=t};Gn.store="remoteDocumentGlobal",Gn.key="remoteDocumentGlobalKey";var Qn=function(t,e,n,r,i,o,s){this.targetId=t,this.canonicalId=e,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=o,this.query=s};Qn.store="targets",Qn.keyPath="targetId",Qn.queryTargetsIndexName="queryTargetsIndex",Qn.queryTargetsKeyPath=["canonicalId","targetId"];var zn=function(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n};zn.store="targetDocuments",zn.keyPath=["targetId","path"],zn.documentTargetsIndex="documentTargetsIndex",zn.documentTargetsKeyPath=["path","targetId"];var Wn=function(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r};Wn.key="targetGlobalKey",Wn.store="targetGlobal";var Hn=function(t,e){this.collectionId=t,this.parent=e};Hn.store="collectionParents",Hn.keyPath=["collectionId","parent"];var Yn=function(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r};Yn.store="clientMetadata",Yn.keyPath="clientId";var $n=function(t,e,n){this.bundleId=t,this.createTime=e,this.version=n};$n.store="bundles",$n.keyPath="bundleId";var Xn=function(t,e,n){this.name=t,this.readTime=e,this.bundledQuery=n};Xn.store="namedQueries",Xn.keyPath="name";var Jn=(0,e.__spreadArray)((0,e.__spreadArray)([],(0,e.__spreadArray)((0,e.__spreadArray)([],(0,e.__spreadArray)((0,e.__spreadArray)([],(0,e.__spreadArray)((0,e.__spreadArray)([],[Vn.store,qn.store,Un.store,Kn.store,Qn.store,Mn.store,Wn.store,zn.store]),[Yn.store])),[Gn.store])),[Hn.store])),[$n.store,Xn.store]),Zn="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",tr=function(){function t(){this.onCommittedListeners=[]}return t.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},t.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEach(function(t){return t()})},t}(),er=function(){var t=this;this.promise=new Promise(function(e,n){t.resolve=e,t.reject=n})},nr=function(){function t(t){var e=this;this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(function(t){e.isDone=!0,e.result=t,e.nextCallback&&e.nextCallback(t)},function(t){e.isDone=!0,e.error=t,e.catchCallback&&e.catchCallback(t)})}return t.prototype.catch=function(t){return this.next(void 0,t)},t.prototype.next=function(e,n){var r=this;return this.callbackAttached&&y(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(e,this.result):new t(function(t,i){r.nextCallback=function(n){r.wrapSuccess(e,n).next(t,i)},r.catchCallback=function(e){r.wrapFailure(n,e).next(t,i)}})},t.prototype.toPromise=function(){var t=this;return new Promise(function(e,n){t.next(e,n)})},t.prototype.wrapUserFunction=function(e){try{var n=e();return n instanceof t?n:t.resolve(n)}catch(e){return t.reject(e)}},t.prototype.wrapSuccess=function(e,n){return e?this.wrapUserFunction(function(){return e(n)}):t.resolve(n)},t.prototype.wrapFailure=function(e,n){return e?this.wrapUserFunction(function(){return e(n)}):t.reject(n)},t.resolve=function(e){return new t(function(t,n){t(e)})},t.reject=function(e){return new t(function(t,n){n(e)})},t.waitFor=function(e){return new t(function(t,n){var r=0,i=0,o=!1;e.forEach(function(e){++r,e.next(function(){++i,o&&i===r&&t()},function(t){return n(t)})}),o=!0,i===r&&t()})},t.or=function(e){for(var n=t.resolve(!1),r=function(e){n=n.next(function(n){return n?t.resolve(n):e()})},i=0,o=e;i<o.length;i++)r(o[i]);return n},t.forEach=function(t,e){var n=this,r=[];return t.forEach(function(t,i){r.push(e.call(n,t,i))}),this.waitFor(r)},t}(),rr=function(){function t(t,e){var n=this;this.action=t,this.transaction=e,this.aborted=!1,this.ft=new er,this.transaction.oncomplete=function(){n.ft.resolve()},this.transaction.onabort=function(){e.error?n.ft.reject(new sr(t,e.error)):n.ft.resolve()},this.transaction.onerror=function(e){var r=fr(e.target.error);n.ft.reject(new sr(t,r))}}return t.open=function(e,n,r,i){try{return new t(n,e.transaction(i,r))}catch(e){throw new sr(n,e)}},Object.defineProperty(t.prototype,"dt",{get:function(){return this.ft.promise},enumerable:!1,configurable:!0}),t.prototype.abort=function(t){t&&this.ft.reject(t),this.aborted||(f("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},t.prototype.store=function(t){var e=this.transaction.objectStore(t);return new ur(e)},t}(),ir=function(){function r(t,e,i){this.name=t,this.version=e,this.wt=i,12.2===r._t((0,n.getUA)())&&l("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}return r.delete=function(t){return f("SimpleDb","Removing database:",t),cr(window.indexedDB.deleteDatabase(t)).toPromise()},r.yt=function(){if("undefined"==typeof indexedDB)return!1;if(r.gt())return!0;var t=(0,n.getUA)(),e=r._t(t),i=0<e&&e<10,o=r.Et(t),s=0<o&&o<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||i||s)},r.gt=function(){var e;return void 0!==t&&"YES"===(null===(e=t.env)||void 0===e?void 0:e.Tt)},r.It=function(t,e){return t.store(e)},r._t=function(t){var e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)},r.Et=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},r.prototype.At=function(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n,r=this;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return this.db?[3,2]:(f("SimpleDb","Opening database:",this.name),n=this,[4,new Promise(function(e,n){var i=indexedDB.open(r.name,r.version);i.onsuccess=function(t){var n=t.target.result;e(n)},i.onblocked=function(){n(new sr(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=function(e){var r=e.target.error;"VersionError"===r.name?n(new u(a.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):n(new sr(t,r))},i.onupgradeneeded=function(t){f("SimpleDb",'Database "'+r.name+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;r.wt.Rt(e,i.transaction,t.oldVersion,r.version).next(function(){f("SimpleDb","Database upgrade to version "+r.version+" complete")})}})]);case 1:n.db=e.sent(),e.label=2;case 2:return[2,(this.bt&&(this.db.onversionchange=function(t){return r.bt(t)}),this.db)]}})})},r.prototype.vt=function(t){this.bt=t,this.db&&(this.db.onversionchange=function(e){return t(e)})},r.prototype.runTransaction=function(t,n,r,i){return(0,e.__awaiter)(this,void 0,void 0,function(){var s,a,u,c,h;return(0,e.__generator)(this,function(l){switch(l.label){case 0:s="readonly"===n,a=0,u=function(){var n,o,u,h,l;return(0,e.__generator)(this,function(e){switch(e.label){case 0:++a,e.label=1;case 1:return e.trys.push([1,4,,5]),[4,c.At(t)];case 2:return c.db=e.sent(),n=rr.open(c.db,t,s?"readonly":"readwrite",r),o=i(n).catch(function(t){return n.abort(t),nr.reject(t)}).toPromise(),u={},o.catch(function(){}),[4,n.dt];case 3:return[2,(u.value=(e.sent(),o),u)];case 4:return h=e.sent(),l="FirebaseError"!==h.name&&a<3,f("SimpleDb","Transaction failed with error:",h.message,"Retrying:",l),c.close(),l?[3,5]:[2,{value:Promise.reject(h)}];case 5:return[2]}})},c=this,l.label=1;case 1:return[5,u()];case 2:if("object"==o(h=l.sent()))return[2,h.value];l.label=3;case 3:return[3,1];case 4:return[2]}})})},r.prototype.close=function(){this.db&&this.db.close(),this.db=void 0},r}(),or=function(){function t(t){this.Pt=t,this.Vt=!1,this.St=null}return Object.defineProperty(t.prototype,"isDone",{get:function(){return this.Vt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Dt",{get:function(){return this.St},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cursor",{set:function(t){this.Pt=t},enumerable:!1,configurable:!0}),t.prototype.done=function(){this.Vt=!0},t.prototype.Ct=function(t){this.St=t},t.prototype.delete=function(){return cr(this.Pt.delete())},t}(),sr=function(t){function n(e,n){var r=this;return(r=t.call(this,a.UNAVAILABLE,"IndexedDB transaction '"+e+"' failed: "+n)||this).name="IndexedDbTransactionError",r}return(0,e.__extends)(n,t),n}(u);function ar(t){return"IndexedDbTransactionError"===t.name}var ur=function(){function t(t){this.store=t}return t.prototype.put=function(t,e){var n;return void 0!==e?(f("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(f("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),cr(n)},t.prototype.add=function(t){return f("SimpleDb","ADD",this.store.name,t,t),cr(this.store.add(t))},t.prototype.get=function(t){var e=this;return cr(this.store.get(t)).next(function(n){return void 0===n&&(n=null),f("SimpleDb","GET",e.store.name,t,n),n})},t.prototype.delete=function(t){return f("SimpleDb","DELETE",this.store.name,t),cr(this.store.delete(t))},t.prototype.count=function(){return f("SimpleDb","COUNT",this.store.name),cr(this.store.count())},t.prototype.Nt=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.xt(n,function(t,e){r.push(e)}).next(function(){return r})},t.prototype.kt=function(t,e){f("SimpleDb","DELETE ALL",this.store.name);var n=this.options(t,e);n.Ft=!1;var r=this.cursor(n);return this.xt(r,function(t,e,n){return n.delete()})},t.prototype.$t=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.xt(r,e)},t.prototype.Ot=function(t){var e=this.cursor({});return new nr(function(n,r){e.onerror=function(t){var e=fr(t.target.error);r(e)},e.onsuccess=function(e){var r=e.target.result;r?t(r.primaryKey,r.value).next(function(t){t?r.continue():n()}):n()}})},t.prototype.xt=function(t,e){var n=[];return new nr(function(r,i){t.onerror=function(t){i(t.target.error)},t.onsuccess=function(t){var i=t.target.result;if(i){var o=new or(i),s=e(i.primaryKey,i.value,o);if(s instanceof nr){var a=s.catch(function(t){return o.done(),nr.reject(t)});n.push(a)}o.isDone?r():null===o.Dt?i.continue():i.continue(o.Dt)}else r()}}).next(function(){return nr.waitFor(n)})},t.prototype.options=function(t,e){var n;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}},t.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.Ft?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},t}();function cr(t){return new nr(function(e,n){t.onsuccess=function(t){var n=t.target.result;e(n)},t.onerror=function(t){var e=fr(t.target.error);n(e)}})}var hr=!1;function fr(t){var e=ir._t((0,n.getUA)());if(e>=12.2&&e<13){var r="An internal error was encountered in the Indexed Database server";if(t.message.indexOf(r)>=0){var i=new u("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '"+r+"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");return hr||(hr=!0,setTimeout(function(){throw i},0)),i}}return t}var lr=function(t){function n(e,n){var r=this;return(r=t.call(this)||this).Mt=e,r.currentSequenceNumber=n,r}return(0,e.__extends)(n,t),n}(tr);function dr(t,e){var n=m(t);return ir.It(n.Mt,e)}var pr=function(){function t(t,e,n,r){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=r}return t.prototype.applyToRemoteDocument=function(t,e){for(var n=e.mutationResults,r=0;r<this.mutations.length;r++){var i=this.mutations[r];i.key.isEqual(t.key)&&fe(i,t,n[r])}},t.prototype.applyToLocalView=function(t){for(var e=0,n=this.baseMutations;e<n.length;e++)(o=n[e]).key.isEqual(t.key)&&le(o,t,this.localWriteTime);for(var r=0,i=this.mutations;r<i.length;r++){var o;(o=i[r]).key.isEqual(t.key)&&le(o,t,this.localWriteTime)}},t.prototype.applyToLocalDocumentSet=function(t){var e=this;this.mutations.forEach(function(n){var r=t.get(n.key),i=r;e.applyToLocalView(i),r.isValidDocument()||i.convertToNoDocument(T.min())})},t.prototype.keys=function(){return this.mutations.reduce(function(t,e){return t.add(e.key)},Ue())},t.prototype.isEqual=function(t){return this.batchId===t.batchId&&b(this.mutations,t.mutations,function(t,e){return pe(t,e)})&&b(this.baseMutations,t.baseMutations,function(t,e){return pe(t,e)})},t}(),yr=function(){function t(t,e,n,r){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=r}return t.from=function(e,n,r){v(e.mutations.length===r.length);for(var i=Ve(),o=e.mutations,s=0;s<o.length;s++)i=i.insert(o[s].key,r[s].version);return new t(e,n,r,i)},t}(),vr=function(){function t(t,e,n,r,i,o,s){void 0===i&&(i=T.min()),void 0===o&&(o=T.min()),void 0===s&&(s=L.EMPTY_BYTE_STRING),this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s}return t.prototype.withSequenceNumber=function(e){return new t(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)},t.prototype.withResumeToken=function(e,n){return new t(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e)},t.prototype.withLastLimboFreeSnapshotVersion=function(e){return new t(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken)},t}(),mr=function(t){this.Lt=t};function gr(t,e){if(e.document)return yn(t.Lt,e.document,!!e.hasCommittedMutations);if(e.noDocument){var n=G.fromSegments(e.noDocument.path),r=Er(e.noDocument.readTime),i=at.newNoDocument(n,r);return e.hasCommittedMutations?i.setHasCommittedMutations():i}if(e.unknownDocument){var o=G.fromSegments(e.unknownDocument.path);return r=Er(e.unknownDocument.version),at.newUnknownDocument(o,r)}return y()}function _r(t,e,n){var r=wr(n),i=e.key.path.popLast().toArray();if(e.isFoundDocument()){var o=function(t,e){return{name:un(t,e.key),fields:e.data.value.mapValue.fields,updateTime:en(t,e.version.toTimestamp())}}(t.Lt,e),s=e.hasCommittedMutations;return new Kn(null,null,o,s,r,i)}if(e.isNoDocument()){var a=e.key.path.toArray(),u=Ir(e.version);return s=e.hasCommittedMutations,new Kn(null,new Bn(a,u),null,s,r,i)}if(e.isUnknownDocument()){var c=e.key.path.toArray(),h=Ir(e.version);return new Kn(new jn(c,h),null,null,!0,r,i)}return y()}function wr(t){var e=t.toTimestamp();return[e.seconds,e.nanoseconds]}function br(t){var e=new E(t[0],t[1]);return T.fromTimestamp(e)}function Ir(t){var e=t.toTimestamp();return new Fn(e.seconds,e.nanoseconds)}function Er(t){var e=new E(t.seconds,t.nanoseconds);return T.fromTimestamp(e)}function Tr(t,e){for(var n=(e.baseMutations||[]).map(function(e){return mn(t.Lt,e)}),r=0;r<e.mutations.length-1;++r){var i=e.mutations[r];if(r+1<e.mutations.length&&void 0!==e.mutations[r+1].transform){var o=e.mutations[r+1];i.updateTransforms=o.transform.fieldTransforms,e.mutations.splice(r+1,1),++r}}var s=e.mutations.map(function(e){return mn(t.Lt,e)}),a=E.fromMillis(e.localWriteTimeMs);return new pr(e.batchId,a,n,s)}function Sr(t){var e,n,r=Er(t.readTime),i=void 0!==t.lastLimboFreeSnapshotVersion?Er(t.lastLimboFreeSnapshotVersion):T.min();return void 0!==t.query.documents?(v(1===(n=t.query).documents.length),e=Mt(kt(fn(n.documents[0])))):e=function(t){return Mt(wn(t))}(t.query),new vr(e,t.targetId,0,t.lastListenSequenceNumber,r,i,L.fromBase64String(t.resumeToken))}function Nr(t,e){var n,r=Ir(e.snapshotVersion),i=Ir(e.lastLimboFreeSnapshotVersion);n=lt(e.target)?gn(t.Lt,e.target):_n(t.Lt,e.target);var o=e.resumeToken.toBase64();return new Qn(e.targetId,ht(e.target),r,o,e.sequenceNumber,i,n)}function Dr(t){var e=wn({parent:t.parent,structuredQuery:t.structuredQuery});return"LAST"===t.limitType?Vt(e,e.limit,"L"):e}var Ar=function(){function t(){}return t.prototype.getBundleMetadata=function(t,e){return xr(t).get(e).next(function(t){if(t)return{id:(e=t).bundleId,createTime:Er(e.createTime),version:e.version};var e})},t.prototype.saveBundleMetadata=function(t,e){return xr(t).put({bundleId:(n=e).id,createTime:Ir(on(n.createTime)),version:n.version});var n},t.prototype.getNamedQuery=function(t,e){return kr(t).get(e).next(function(t){if(t)return{name:(e=t).name,query:Dr(e.bundledQuery),readTime:Er(e.readTime)};var e})},t.prototype.saveNamedQuery=function(t,e){return kr(t).put(function(t){return{name:t.name,readTime:Ir(on(t.readTime)),bundledQuery:t.bundledQuery}}(e))},t}();function xr(t){return dr(t,$n.store)}function kr(t){return dr(t,Xn.store)}var Cr=function(){function t(){this.Bt=new Rr}return t.prototype.addToCollectionParentIndex=function(t,e){return this.Bt.add(e),nr.resolve()},t.prototype.getCollectionParents=function(t,e){return nr.resolve(this.Bt.getEntries(e))},t}(),Rr=function(){function t(){this.index={}}return t.prototype.add=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new Ce(x.comparator),i=!r.has(n);return this.index[e]=r.add(n),i},t.prototype.has=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e];return r&&r.has(n)},t.prototype.getEntries=function(t){return(this.index[t]||new Ce(x.comparator)).toArray()},t}(),Lr=function(){function t(){this.qt=new Rr}return t.prototype.addToCollectionParentIndex=function(t,e){var n=this;if(!this.qt.has(e)){var r=e.lastSegment(),i=e.popLast();t.addOnCommittedListener(function(){n.qt.add(e)});var o={collectionId:r,parent:Rn(i)};return Or(t).put(o)}return nr.resolve()},t.prototype.getCollectionParents=function(t,e){var n=[],r=IDBKeyRange.bound([e,""],[I(e),""],!1,!0);return Or(t).Nt(r).next(function(t){for(var r=0,i=t;r<i.length;r++){var o=i[r];if(o.collectionId!==e)break;n.push(Pn(o.parent))}return n})},t}();function Or(t){return dr(t,Hn.store)}var Pr={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},Fr=function(){function t(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}return t.withCacheSize=function(e){return new t(e,t.DEFAULT_COLLECTION_PERCENTILE,t.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)},t}();function Mr(t,e,n){var r=t.store(qn.store),i=t.store(Un.store),o=[],s=IDBKeyRange.only(n.batchId),a=0,u=r.$t({range:s},function(t,e,n){return a++,n.delete()});o.push(u.next(function(){v(1===a)}));for(var c=[],h=0,f=n.mutations;h<f.length;h++){var l=f[h],d=Un.key(e,l.key.path,n.batchId);o.push(i.delete(d)),c.push(l.key)}return nr.waitFor(o).next(function(){return c})}function Vr(t){if(!t)return 0;var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw y();e=t.noDocument}return JSON.stringify(e).length}Fr.DEFAULT_COLLECTION_PERCENTILE=10,Fr.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Fr.DEFAULT=new Fr(41943040,Fr.DEFAULT_COLLECTION_PERCENTILE,Fr.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Fr.DISABLED=new Fr(-1,0,0);var qr=function(){function t(t,e,n,r){this.userId=t,this.R=e,this.Ut=n,this.referenceDelegate=r,this.Kt={}}return t.Qt=function(e,n,r,i){return v(""!==e.uid),new t(e.isAuthenticated()?e.uid:"",n,r,i)},t.prototype.checkEmpty=function(t){var e=!0,n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return Br(t).$t({index:qn.userMutationsIndex,range:n},function(t,n,r){e=!1,r.done()}).next(function(){return e})},t.prototype.addMutationBatch=function(t,e,n,r){var i=this,o=jr(t),s=Br(t);return s.add({}).next(function(a){v("number"==typeof a);for(var u=new pr(a,e,n,r),c=function(t,e,n){var r=n.baseMutations.map(function(e){return vn(t.Lt,e)}),i=n.mutations.map(function(e){return vn(t.Lt,e)});return new qn(e,n.batchId,n.localWriteTime.toMillis(),r,i)}(i.R,i.userId,u),h=[],f=new Ce(function(t,e){return w(t.canonicalString(),e.canonicalString())}),l=0,d=r;l<d.length;l++){var p=d[l],y=Un.key(i.userId,p.key.path,a);f=f.add(p.key.path.popLast()),h.push(s.put(c)),h.push(o.put(y,Un.PLACEHOLDER))}return f.forEach(function(e){h.push(i.Ut.addToCollectionParentIndex(t,e))}),t.addOnCommittedListener(function(){i.Kt[a]=u.keys()}),nr.waitFor(h).next(function(){return u})})},t.prototype.lookupMutationBatch=function(t,e){var n=this;return Br(t).get(e).next(function(t){return t?(v(t.userId===n.userId),Tr(n.R,t)):null})},t.prototype.jt=function(t,e){var n=this;return this.Kt[e]?nr.resolve(this.Kt[e]):this.lookupMutationBatch(t,e).next(function(t){if(t){var r=t.keys();return n.Kt[e]=r,r}return null})},t.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=this,r=e+1,i=IDBKeyRange.lowerBound([this.userId,r]),o=null;return Br(t).$t({index:qn.userMutationsIndex,range:i},function(t,e,i){e.userId===n.userId&&(v(e.batchId>=r),o=Tr(n.R,e)),i.done()}).next(function(){return o})},t.prototype.getHighestUnacknowledgedBatchId=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),n=-1;return Br(t).$t({index:qn.userMutationsIndex,range:e,reverse:!0},function(t,e,r){n=e.batchId,r.done()}).next(function(){return n})},t.prototype.getAllMutationBatches=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return Br(t).Nt(qn.userMutationsIndex,n).next(function(t){return t.map(function(t){return Tr(e.R,t)})})},t.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,e){var n=this,r=Un.prefixForPath(this.userId,e.path),i=IDBKeyRange.lowerBound(r),o=[];return jr(t).$t({range:i},function(r,i,s){var a=r[0],u=r[1],c=r[2],h=Pn(u);if(a===n.userId&&e.path.isEqual(h))return Br(t).get(c).next(function(t){if(!t)throw y();v(t.userId===n.userId),o.push(Tr(n.R,t))});s.done()}).next(function(){return o})},t.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var n=this,r=new Ce(w),i=[];return e.forEach(function(e){var o=Un.prefixForPath(n.userId,e.path),s=IDBKeyRange.lowerBound(o),a=jr(t).$t({range:s},function(t,i,o){var s=t[0],a=t[1],u=t[2],c=Pn(a);s===n.userId&&e.path.isEqual(c)?r=r.add(u):o.done()});i.push(a)}),nr.waitFor(i).next(function(){return n.Wt(t,r)})},t.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var n=this,r=e.path,i=r.length+1,o=Un.prefixForPath(this.userId,r),s=IDBKeyRange.lowerBound(o),a=new Ce(w);return jr(t).$t({range:s},function(t,e,o){var s=t[0],u=t[1],c=t[2],h=Pn(u);s===n.userId&&r.isPrefixOf(h)?h.length===i&&(a=a.add(c)):o.done()}).next(function(){return n.Wt(t,a)})},t.prototype.Wt=function(t,e){var n=this,r=[],i=[];return e.forEach(function(e){i.push(Br(t).get(e).next(function(t){if(null===t)throw y();v(t.userId===n.userId),r.push(Tr(n.R,t))}))}),nr.waitFor(i).next(function(){return r})},t.prototype.removeMutationBatch=function(t,e){var n=this;return Mr(t.Mt,this.userId,e).next(function(r){return t.addOnCommittedListener(function(){n.Gt(e.batchId)}),nr.forEach(r,function(e){return n.referenceDelegate.markPotentiallyOrphaned(t,e)})})},t.prototype.Gt=function(t){delete this.Kt[t]},t.prototype.performConsistencyCheck=function(t){var e=this;return this.checkEmpty(t).next(function(n){if(!n)return nr.resolve();var r=IDBKeyRange.lowerBound(Un.prefixForUser(e.userId)),i=[];return jr(t).$t({range:r},function(t,n,r){if(t[0]===e.userId){var o=Pn(t[1]);i.push(o)}else r.done()}).next(function(){v(0===i.length)})})},t.prototype.containsKey=function(t,e){return Ur(t,this.userId,e)},t.prototype.zt=function(t){var e=this;return Kr(t).get(this.userId).next(function(t){return t||new Vn(e.userId,-1,"")})},t}();function Ur(t,e,n){var r=Un.prefixForPath(e,n.path),i=r[1],o=IDBKeyRange.lowerBound(r),s=!1;return jr(t).$t({range:o,Ft:!0},function(t,n,r){var o=t[0],a=t[1];t[2],o===e&&a===i&&(s=!0),r.done()}).next(function(){return s})}function Br(t){return dr(t,qn.store)}function jr(t){return dr(t,Un.store)}function Kr(t){return dr(t,Vn.store)}var Gr=function(){function t(t){this.Ht=t}return t.prototype.next=function(){return this.Ht+=2,this.Ht},t.Jt=function(){return new t(0)},t.Yt=function(){return new t(-1)},t}(),Qr=function(){function t(t,e){this.referenceDelegate=t,this.R=e}return t.prototype.allocateTargetId=function(t){var e=this;return this.Xt(t).next(function(n){var r=new Gr(n.highestTargetId);return n.highestTargetId=r.next(),e.Zt(t,n).next(function(){return n.highestTargetId})})},t.prototype.getLastRemoteSnapshotVersion=function(t){return this.Xt(t).next(function(t){return T.fromTimestamp(new E(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))})},t.prototype.getHighestSequenceNumber=function(t){return this.Xt(t).next(function(t){return t.highestListenSequenceNumber})},t.prototype.setTargetsMetadata=function(t,e,n){var r=this;return this.Xt(t).next(function(i){return i.highestListenSequenceNumber=e,n&&(i.lastRemoteSnapshotVersion=n.toTimestamp()),e>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=e),r.Zt(t,i)})},t.prototype.addTargetData=function(t,e){var n=this;return this.te(t,e).next(function(){return n.Xt(t).next(function(r){return r.targetCount+=1,n.ee(e,r),n.Zt(t,r)})})},t.prototype.updateTargetData=function(t,e){return this.te(t,e)},t.prototype.removeTargetData=function(t,e){var n=this;return this.removeMatchingKeysForTargetId(t,e.targetId).next(function(){return zr(t).delete(e.targetId)}).next(function(){return n.Xt(t)}).next(function(e){return v(e.targetCount>0),e.targetCount-=1,n.Zt(t,e)})},t.prototype.removeTargets=function(t,e,n){var r=this,i=0,o=[];return zr(t).$t(function(s,a){var u=Sr(a);u.sequenceNumber<=e&&null===n.get(u.targetId)&&(i++,o.push(r.removeTargetData(t,u)))}).next(function(){return nr.waitFor(o)}).next(function(){return i})},t.prototype.forEachTarget=function(t,e){return zr(t).$t(function(t,n){var r=Sr(n);e(r)})},t.prototype.Xt=function(t){return Wr(t).get(Wn.key).next(function(t){return v(null!==t),t})},t.prototype.Zt=function(t,e){return Wr(t).put(Wn.key,e)},t.prototype.te=function(t,e){return zr(t).put(Nr(this.R,e))},t.prototype.ee=function(t,e){var n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},t.prototype.getTargetCount=function(t){return this.Xt(t).next(function(t){return t.targetCount})},t.prototype.getTargetData=function(t,e){var n=ht(e),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]),i=null;return zr(t).$t({range:r,index:Qn.queryTargetsIndexName},function(t,n,r){var o=Sr(n);ft(e,o.target)&&(i=o,r.done())}).next(function(){return i})},t.prototype.addMatchingKeys=function(t,e,n){var r=this,i=[],o=Hr(t);return e.forEach(function(e){var s=Rn(e.path);i.push(o.put(new zn(n,s))),i.push(r.referenceDelegate.addReference(t,n,e))}),nr.waitFor(i)},t.prototype.removeMatchingKeys=function(t,e,n){var r=this,i=Hr(t);return nr.forEach(e,function(e){var o=Rn(e.path);return nr.waitFor([i.delete([n,o]),r.referenceDelegate.removeReference(t,n,e)])})},t.prototype.removeMatchingKeysForTargetId=function(t,e){var n=Hr(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},t.prototype.getMatchingKeysForTargetId=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=Hr(t),i=Ue();return r.$t({range:n,Ft:!0},function(t,e,n){var r=Pn(t[1]),o=new G(r);i=i.add(o)}).next(function(){return i})},t.prototype.containsKey=function(t,e){var n=Rn(e.path),r=IDBKeyRange.bound([n],[I(n)],!1,!0),i=0;return Hr(t).$t({index:zn.documentTargetsIndex,Ft:!0,range:r},function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())}).next(function(){return i>0})},t.prototype.lt=function(t,e){return zr(t).get(e).next(function(t){return t?Sr(t):null})},t}();function zr(t){return dr(t,Qn.store)}function Wr(t){return dr(t,Wn.store)}function Hr(t){return dr(t,zn.store)}function Yr(t){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(e){if(t.code!==a.FAILED_PRECONDITION||t.message!==Zn)throw t;return f("LocalStore","Unexpectedly lost primary lease"),[2]})})}function $r(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],s=w(n,i);return 0===s?w(r,o):s}var Xr=function(){function t(t){this.ne=t,this.buffer=new Ce($r),this.se=0}return t.prototype.ie=function(){return++this.se},t.prototype.re=function(t){var e=[t,this.ie()];if(this.buffer.size<this.ne)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();$r(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(t.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!1,configurable:!0}),t}(),Jr=function(){function t(t,e){this.garbageCollector=t,this.asyncQueue=e,this.oe=!1,this.ce=null}return t.prototype.start=function(t){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.ue(t)},t.prototype.stop=function(){this.ce&&(this.ce.cancel(),this.ce=null)},Object.defineProperty(t.prototype,"started",{get:function(){return null!==this.ce},enumerable:!1,configurable:!0}),t.prototype.ue=function(t){var n=this,r=this.oe?3e5:6e4;f("LruGarbageCollector","Garbage collection scheduled in "+r+"ms"),this.ce=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",r,function(){return(0,e.__awaiter)(n,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:this.ce=null,this.oe=!0,e.label=1;case 1:return e.trys.push([1,3,,7]),[4,t.collectGarbage(this.garbageCollector)];case 2:return e.sent(),[3,7];case 3:return ar(n=e.sent())?(f("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",n),[3,6]):[3,4];case 4:return[4,Yr(n)];case 5:e.sent(),e.label=6;case 6:return[3,7];case 7:return[4,this.ue(t)];case 8:return e.sent(),[2]}})})})},t}(),Zr=function(){function t(t,e){this.ae=t,this.params=e}return t.prototype.calculateTargetCount=function(t,e){return this.ae.he(t).next(function(t){return Math.floor(e/100*t)})},t.prototype.nthSequenceNumber=function(t,e){var n=this;if(0===e)return nr.resolve(s.o);var r=new Xr(e);return this.ae.forEachTarget(t,function(t){return r.re(t.sequenceNumber)}).next(function(){return n.ae.le(t,function(t){return r.re(t)})}).next(function(){return r.maxValue})},t.prototype.removeTargets=function(t,e,n){return this.ae.removeTargets(t,e,n)},t.prototype.removeOrphanedDocuments=function(t,e){return this.ae.removeOrphanedDocuments(t,e)},t.prototype.collect=function(t,e){var n=this;return-1===this.params.cacheSizeCollectionThreshold?(f("LruGarbageCollector","Garbage collection skipped; disabled"),nr.resolve(Pr)):this.getCacheSize(t).next(function(r){return r<n.params.cacheSizeCollectionThreshold?(f("LruGarbageCollector","Garbage collection skipped; Cache size "+r+" is lower than threshold "+n.params.cacheSizeCollectionThreshold),Pr):n.fe(t,e)})},t.prototype.getCacheSize=function(t){return this.ae.getCacheSize(t)},t.prototype.fe=function(t,e){var n,i,o,s,a,u,c,l=this,d=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next(function(e){return e>l.params.maximumSequenceNumbersToCollect?(f("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+l.params.maximumSequenceNumbersToCollect+" from "+e),i=l.params.maximumSequenceNumbersToCollect):i=e,s=Date.now(),l.nthSequenceNumber(t,i)}).next(function(r){return n=r,a=Date.now(),l.removeTargets(t,n,e)}).next(function(e){return o=e,u=Date.now(),l.removeOrphanedDocuments(t,n)}).next(function(t){return c=Date.now(),h()<=r.LogLevel.DEBUG&&f("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(s-d)+"ms\n\tDetermined least recently used "+i+" in "+(a-s)+"ms\n\tRemoved "+o+" targets in "+(u-a)+"ms\n\tRemoved "+t+" documents in "+(c-u)+"ms\nTotal Duration: "+(c-d)+"ms"),nr.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:o,documentsRemoved:t})})},t}(),ti=function(){function t(t,e){this.db=t,this.garbageCollector=function(t,e){return new Zr(t,e)}(this,e)}return t.prototype.he=function(t){var e=this.de(t);return this.db.getTargetCache().getTargetCount(t).next(function(t){return e.next(function(e){return t+e})})},t.prototype.de=function(t){var e=0;return this.le(t,function(t){e++}).next(function(){return e})},t.prototype.forEachTarget=function(t,e){return this.db.getTargetCache().forEachTarget(t,e)},t.prototype.le=function(t,e){return this.we(t,function(t,n){return e(n)})},t.prototype.addReference=function(t,e,n){return ei(t,n)},t.prototype.removeReference=function(t,e,n){return ei(t,n)},t.prototype.removeTargets=function(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)},t.prototype.markPotentiallyOrphaned=function(t,e){return ei(t,e)},t.prototype._e=function(t,e){return function(t,e){var n=!1;return Kr(t).Ot(function(r){return Ur(t,r,e).next(function(t){return t&&(n=!0),nr.resolve(!t)})}).next(function(){return n})}(t,e)},t.prototype.removeOrphanedDocuments=function(t,e){var n=this,r=this.db.getRemoteDocumentCache().newChangeBuffer(),i=[],o=0;return this.we(t,function(s,a){if(a<=e){var u=n._e(t,s).next(function(e){if(!e)return o++,r.getEntry(t,s).next(function(){return r.removeEntry(s),Hr(t).delete([0,Rn(s.path)])})});i.push(u)}}).next(function(){return nr.waitFor(i)}).next(function(){return r.apply(t)}).next(function(){return o})},t.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)},t.prototype.updateLimboDocument=function(t,e){return ei(t,e)},t.prototype.we=function(t,e){var n,r=Hr(t),i=s.o;return r.$t({index:zn.documentTargetsIndex},function(t,r){var o=t[0];t[1];var a=r.path,u=r.sequenceNumber;0===o?(i!==s.o&&e(new G(Pn(n)),i),i=u,n=a):i=s.o}).next(function(){i!==s.o&&e(new G(Pn(n)),i)})},t.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},t}();function ei(t,e){return Hr(t).put(function(t,e){return new zn(0,Rn(t.path),e)}(e,t.currentSequenceNumber))}var ni=function(){function t(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={}}return t.prototype.get=function(t){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0!==n)for(var r=0,i=n;r<i.length;r++){var o=i[r],s=o[0],a=o[1];if(this.equalsFn(s,t))return a}},t.prototype.has=function(t){return void 0!==this.get(t)},t.prototype.set=function(t,e){var n=this.mapKeyFn(t),r=this.inner[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(this.equalsFn(r[i][0],t))return void(r[i]=[t,e]);r.push([t,e])}else this.inner[n]=[[t,e]]},t.prototype.delete=function(t){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(this.equalsFn(n[r][0],t))return 1===n.length?delete this.inner[e]:n.splice(r,1),!0;return!1},t.prototype.forEach=function(t){N(this.inner,function(e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r],s=o[0],a=o[1];t(s,a)}})},t.prototype.isEmpty=function(){return D(this.inner)},t}(),ri=function(){function t(){this.changes=new ni(function(t){return t.toString()},function(t,e){return t.isEqual(e)}),this.changesApplied=!1}return t.prototype.getReadTime=function(t){var e=this.changes.get(t);return e?e.readTime:T.min()},t.prototype.addEntry=function(t,e){this.assertNotApplied(),this.changes.set(t.key,{document:t,readTime:e})},t.prototype.removeEntry=function(t,e){void 0===e&&(e=null),this.assertNotApplied(),this.changes.set(t,{document:at.newInvalidDocument(t),readTime:e})},t.prototype.getEntry=function(t,e){this.assertNotApplied();var n=this.changes.get(e);return void 0!==n?nr.resolve(n.document):this.getFromCache(t,e)},t.prototype.getEntries=function(t,e){return this.getAllFromCache(t,e)},t.prototype.apply=function(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)},t.prototype.assertNotApplied=function(){},t}(),ii=function(){function t(t,e){this.R=t,this.Ut=e}return t.prototype.addEntry=function(t,e,n){return ai(t).put(ui(e),n)},t.prototype.removeEntry=function(t,e){var n=ai(t),r=ui(e);return n.delete(r)},t.prototype.updateMetadata=function(t,e){var n=this;return this.getMetadata(t).next(function(r){return r.byteSize+=e,n.me(t,r)})},t.prototype.getEntry=function(t,e){var n=this;return ai(t).get(ui(e)).next(function(t){return n.ye(e,t)})},t.prototype.ge=function(t,e){var n=this;return ai(t).get(ui(e)).next(function(t){return{document:n.ye(e,t),size:Vr(t)}})},t.prototype.getEntries=function(t,e){var n=this,r=Oe();return this.pe(t,e,function(t,e){var i=n.ye(t,e);r=r.insert(t,i)}).next(function(){return r})},t.prototype.Ee=function(t,e){var n=this,r=Oe(),i=new Ae(G.comparator);return this.pe(t,e,function(t,e){var o=n.ye(t,e);r=r.insert(t,o),i=i.insert(t,Vr(e))}).next(function(){return{documents:r,Te:i}})},t.prototype.pe=function(t,e,n){if(e.isEmpty())return nr.resolve();var r=IDBKeyRange.bound(e.first().path.toArray(),e.last().path.toArray()),i=e.getIterator(),o=i.getNext();return ai(t).$t({range:r},function(t,e,r){for(var s=G.fromSegments(t);o&&G.comparator(o,s)<0;)n(o,null),o=i.getNext();o&&o.isEqual(s)&&(n(o,e),o=i.hasNext()?i.getNext():null),o?r.Ct(o.path.toArray()):r.done()}).next(function(){for(;o;)n(o,null),o=i.hasNext()?i.getNext():null})},t.prototype.getDocumentsMatchingQuery=function(t,e,n){var r=this,i=Oe(),o=e.path.length+1,s={};if(n.isEqual(T.min())){var a=e.path.toArray();s.range=IDBKeyRange.lowerBound(a)}else{var u=e.path.toArray(),c=wr(n);s.range=IDBKeyRange.lowerBound([u,c],!0),s.index=Kn.collectionReadTimeIndex}return ai(t).$t(s,function(t,n,s){if(t.length===o){var a=gr(r.R,n);e.path.isPrefixOf(a.key.path)?jt(e,a)&&(i=i.insert(a.key,a)):s.done()}}).next(function(){return i})},t.prototype.newChangeBuffer=function(t){return new oi(this,!!t&&t.trackRemovals)},t.prototype.getSize=function(t){return this.getMetadata(t).next(function(t){return t.byteSize})},t.prototype.getMetadata=function(t){return si(t).get(Gn.key).next(function(t){return v(!!t),t})},t.prototype.me=function(t,e){return si(t).put(Gn.key,e)},t.prototype.ye=function(t,e){if(e){var n=gr(this.R,e);if(!n.isNoDocument()||!n.version.isEqual(T.min()))return n}return at.newInvalidDocument(t)},t}(),oi=function(t){function n(e,n){var r=this;return(r=t.call(this)||this).Ie=e,r.trackRemovals=n,r.Ae=new ni(function(t){return t.toString()},function(t,e){return t.isEqual(e)}),r}return(0,e.__extends)(n,t),n.prototype.applyChanges=function(t){var e=this,n=[],r=0,i=new Ce(function(t,e){return w(t.canonicalString(),e.canonicalString())});return this.changes.forEach(function(o,s){var a=e.Ae.get(o);if(s.document.isValidDocument()){var u=_r(e.Ie.R,s.document,e.getReadTime(o));i=i.add(o.path.popLast());var c=Vr(u);r+=c-a,n.push(e.Ie.addEntry(t,o,u))}else if(r-=a,e.trackRemovals){var h=_r(e.Ie.R,at.newNoDocument(o,T.min()),e.getReadTime(o));n.push(e.Ie.addEntry(t,o,h))}else n.push(e.Ie.removeEntry(t,o))}),i.forEach(function(r){n.push(e.Ie.Ut.addToCollectionParentIndex(t,r))}),n.push(this.Ie.updateMetadata(t,r)),nr.waitFor(n)},n.prototype.getFromCache=function(t,e){var n=this;return this.Ie.ge(t,e).next(function(t){return n.Ae.set(e,t.size),t.document})},n.prototype.getAllFromCache=function(t,e){var n=this;return this.Ie.Ee(t,e).next(function(t){var e=t.documents;return t.Te.forEach(function(t,e){n.Ae.set(t,e)}),e})},n}(ri);function si(t){return dr(t,Gn.store)}function ai(t){return dr(t,Kn.store)}function ui(t){return t.path.toArray()}var ci=function(){function t(t){this.R=t}return t.prototype.Rt=function(t,e,n,r){var i=this;v(n<r&&n>=0&&r<=11);var o=new rr("createOrUpgrade",e);n<1&&r>=1&&(function(t){t.createObjectStore(Mn.store)}(t),function(t){t.createObjectStore(Vn.store,{keyPath:Vn.keyPath}),t.createObjectStore(qn.store,{keyPath:qn.keyPath,autoIncrement:!0}).createIndex(qn.userMutationsIndex,qn.userMutationsKeyPath,{unique:!0}),t.createObjectStore(Un.store)}(t),hi(t),function(t){t.createObjectStore(Kn.store)}(t));var s=nr.resolve();return n<3&&r>=3&&(0!==n&&(function(t){t.deleteObjectStore(zn.store),t.deleteObjectStore(Qn.store),t.deleteObjectStore(Wn.store)}(t),hi(t)),s=s.next(function(){return t=o.store(Wn.store),e=new Wn(0,0,T.min().toTimestamp(),0),t.put(Wn.key,e);var t,e})),n<4&&r>=4&&(0!==n&&(s=s.next(function(){return function(t,e){return e.store(qn.store).Nt().next(function(n){t.deleteObjectStore(qn.store),t.createObjectStore(qn.store,{keyPath:qn.keyPath,autoIncrement:!0}).createIndex(qn.userMutationsIndex,qn.userMutationsKeyPath,{unique:!0});var r=e.store(qn.store),i=n.map(function(t){return r.put(t)});return nr.waitFor(i)})}(t,o)})),s=s.next(function(){!function(t){t.createObjectStore(Yn.store,{keyPath:Yn.keyPath})}(t)})),n<5&&r>=5&&(s=s.next(function(){return i.Re(o)})),n<6&&r>=6&&(s=s.next(function(){return function(t){t.createObjectStore(Gn.store)}(t),i.be(o)})),n<7&&r>=7&&(s=s.next(function(){return i.ve(o)})),n<8&&r>=8&&(s=s.next(function(){return i.Pe(t,o)})),n<9&&r>=9&&(s=s.next(function(){!function(t){t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges")}(t),function(t){var e=t.objectStore(Kn.store);e.createIndex(Kn.readTimeIndex,Kn.readTimeIndexPath,{unique:!1}),e.createIndex(Kn.collectionReadTimeIndex,Kn.collectionReadTimeIndexPath,{unique:!1})}(e)})),n<10&&r>=10&&(s=s.next(function(){return i.Ve(o)})),n<11&&r>=11&&(s=s.next(function(){!function(t){t.createObjectStore($n.store,{keyPath:$n.keyPath})}(t),function(t){t.createObjectStore(Xn.store,{keyPath:Xn.keyPath})}(t)})),s},t.prototype.be=function(t){var e=0;return t.store(Kn.store).$t(function(t,n){e+=Vr(n)}).next(function(){var n=new Gn(e);return t.store(Gn.store).put(Gn.key,n)})},t.prototype.Re=function(t){var e=this,n=t.store(Vn.store),r=t.store(qn.store);return n.Nt().next(function(n){return nr.forEach(n,function(n){var i=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return r.Nt(qn.userMutationsIndex,i).next(function(r){return nr.forEach(r,function(r){v(r.userId===n.userId);var i=Tr(e.R,r);return Mr(t,n.userId,i).next(function(){})})})})})},t.prototype.ve=function(t){var e=t.store(zn.store),n=t.store(Kn.store);return t.store(Wn.store).get(Wn.key).next(function(t){var r=[];return n.$t(function(n,i){var o=new x(n),s=[0,Rn(o)];r.push(e.get(s).next(function(n){return n?nr.resolve():function(n){return e.put(new zn(0,Rn(n),t.highestListenSequenceNumber))}(o)}))}).next(function(){return nr.waitFor(r)})})},t.prototype.Pe=function(t,e){t.createObjectStore(Hn.store,{keyPath:Hn.keyPath});var n=e.store(Hn.store),r=new Rr,i=function(t){if(r.add(t)){var e=t.lastSegment(),i=t.popLast();return n.put({collectionId:e,parent:Rn(i)})}};return e.store(Kn.store).$t({Ft:!0},function(t,e){var n=new x(t);return i(n.popLast())}).next(function(){return e.store(Un.store).$t({Ft:!0},function(t,e){t[0];var n=t[1];t[2];var r=Pn(n);return i(r.popLast())})})},t.prototype.Ve=function(t){var e=this,n=t.store(Qn.store);return n.$t(function(t,r){var i=Sr(r),o=Nr(e.R,i);return n.put(o)})},t}();function hi(t){t.createObjectStore(zn.store,{keyPath:zn.keyPath}).createIndex(zn.documentTargetsIndex,zn.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(Qn.store,{keyPath:Qn.keyPath}).createIndex(Qn.queryTargetsIndexName,Qn.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(Wn.store)}var fi="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",li=function(){function t(e,n,r,i,o,s,c,h,f,d){if(this.allowTabSynchronization=e,this.persistenceKey=n,this.clientId=r,this.Se=o,this.window=s,this.document=c,this.De=f,this.Ce=d,this.Ne=null,this.xe=!1,this.isPrimary=!1,this.networkEnabled=!0,this.ke=null,this.inForeground=!1,this.Fe=null,this.$e=null,this.Oe=Number.NEGATIVE_INFINITY,this.Me=function(t){return Promise.resolve()},!t.yt())throw new u(a.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new ti(this,i),this.Le=n+"main",this.R=new mr(h),this.Be=new ir(this.Le,11,new ci(this.R)),this.qe=new Qr(this.referenceDelegate,this.R),this.Ut=new Lr,this.Ue=function(t,e){return new ii(t,e)}(this.R,this.Ut),this.Ke=new Ar,this.window&&this.window.localStorage?this.Qe=this.window.localStorage:(this.Qe=null,!1===d&&l("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}return t.prototype.start=function(){var t=this;return this.je().then(function(){if(!t.isPrimary&&!t.allowTabSynchronization)throw new u(a.FAILED_PRECONDITION,fi);return t.We(),t.Ge(),t.ze(),t.runTransaction("getHighestListenSequenceNumber","readonly",function(e){return t.qe.getHighestSequenceNumber(e)})}).then(function(e){t.Ne=new s(e,t.De)}).then(function(){t.xe=!0}).catch(function(e){return t.Be&&t.Be.close(),Promise.reject(e)})},t.prototype.He=function(t){var n=this;return this.Me=function(r){return(0,e.__awaiter)(n,void 0,void 0,function(){return(0,e.__generator)(this,function(e){return this.started?[2,t(r)]:[2]})})},t(this.isPrimary)},t.prototype.setDatabaseDeletedListener=function(t){var n=this;this.Be.vt(function(r){return(0,e.__awaiter)(n,void 0,void 0,function(){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return null===r.newVersion?[4,t()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})})},t.prototype.setNetworkEnabled=function(t){var n=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.Se.enqueueAndForget(function(){return(0,e.__awaiter)(n,void 0,void 0,function(){return(0,e.__generator)(this,function(t){switch(t.label){case 0:return this.started?[4,this.je()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})}))},t.prototype.je=function(){var t=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",function(e){return pi(e).put(new Yn(t.clientId,Date.now(),t.networkEnabled,t.inForeground)).next(function(){if(t.isPrimary)return t.Je(e).next(function(e){e||(t.isPrimary=!1,t.Se.enqueueRetryable(function(){return t.Me(!1)}))})}).next(function(){return t.Ye(e)}).next(function(n){return t.isPrimary&&!n?t.Xe(e).next(function(){return!1}):!!n&&t.Ze(e).next(function(){return!0})})}).catch(function(e){if(ar(e))return f("IndexedDbPersistence","Failed to extend owner lease: ",e),t.isPrimary;if(!t.allowTabSynchronization)throw e;return f("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1}).then(function(e){t.isPrimary!==e&&t.Se.enqueueRetryable(function(){return t.Me(e)}),t.isPrimary=e})},t.prototype.Je=function(t){var e=this;return di(t).get(Mn.key).next(function(t){return nr.resolve(e.tn(t))})},t.prototype.en=function(t){return pi(t).delete(this.clientId)},t.prototype.nn=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o=this;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return!this.isPrimary||this.sn(this.Oe,18e5)?[3,2]:(this.Oe=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",function(t){var e=dr(t,Yn.store);return e.Nt().next(function(t){var n=o.rn(t,18e5),r=t.filter(function(t){return-1===n.indexOf(t)});return nr.forEach(r,function(t){return e.delete(t.clientId)}).next(function(){return r})})}).catch(function(){return[]})]);case 1:if(t=e.sent(),this.Qe)for(n=0,r=t;n<r.length;n++)i=r[n],this.Qe.removeItem(this.on(i.clientId));e.label=2;case 2:return[2]}})})},t.prototype.ze=function(){var t=this;this.$e=this.Se.enqueueAfterDelay("client_metadata_refresh",4e3,function(){return t.je().then(function(){return t.nn()}).then(function(){return t.ze()})})},t.prototype.tn=function(t){return!!t&&t.ownerId===this.clientId},t.prototype.Ye=function(t){var e=this;return this.Ce?nr.resolve(!0):di(t).get(Mn.key).next(function(n){if(null!==n&&e.sn(n.leaseTimestampMs,5e3)&&!e.cn(n.ownerId)){if(e.tn(n)&&e.networkEnabled)return!0;if(!e.tn(n)){if(!n.allowTabSynchronization)throw new u(a.FAILED_PRECONDITION,fi);return!1}}return!(!e.networkEnabled||!e.inForeground)||pi(t).Nt().next(function(t){return void 0===e.rn(t,5e3).find(function(t){if(e.clientId!==t.clientId){var n=!e.networkEnabled&&t.networkEnabled,r=!e.inForeground&&t.inForeground,i=e.networkEnabled===t.networkEnabled;if(n||r&&i)return!0}return!1})})}).next(function(t){return e.isPrimary!==t&&f("IndexedDbPersistence","Client "+(t?"is":"is not")+" eligible for a primary lease."),t})},t.prototype.shutdown=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){var t=this;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return this.xe=!1,this.un(),this.$e&&(this.$e.cancel(),this.$e=null),this.an(),this.hn(),[4,this.Be.runTransaction("shutdown","readwrite",[Mn.store,Yn.store],function(e){var n=new lr(e,s.o);return t.Xe(n).next(function(){return t.en(n)})})];case 1:return e.sent(),this.Be.close(),this.ln(),[2]}})})},t.prototype.rn=function(t,e){var n=this;return t.filter(function(t){return n.sn(t.updateTimeMs,e)&&!n.cn(t.clientId)})},t.prototype.fn=function(){var t=this;return this.runTransaction("getActiveClients","readonly",function(e){return pi(e).Nt().next(function(e){return t.rn(e,18e5).map(function(t){return t.clientId})})})},Object.defineProperty(t.prototype,"started",{get:function(){return this.xe},enumerable:!1,configurable:!0}),t.prototype.getMutationQueue=function(t){return qr.Qt(t,this.R,this.Ut,this.referenceDelegate)},t.prototype.getTargetCache=function(){return this.qe},t.prototype.getRemoteDocumentCache=function(){return this.Ue},t.prototype.getIndexManager=function(){return this.Ut},t.prototype.getBundleCache=function(){return this.Ke},t.prototype.runTransaction=function(t,e,n){var r=this;f("IndexedDbPersistence","Starting transaction:",t);var i,o="readonly"===e?"readonly":"readwrite";return this.Be.runTransaction(t,o,Jn,function(o){return i=new lr(o,r.Ne?r.Ne.next():s.o),"readwrite-primary"===e?r.Je(i).next(function(t){return!!t||r.Ye(i)}).next(function(e){if(!e)throw l("Failed to obtain primary lease for action '"+t+"'."),r.isPrimary=!1,r.Se.enqueueRetryable(function(){return r.Me(!1)}),new u(a.FAILED_PRECONDITION,Zn);return n(i)}).next(function(t){return r.Ze(i).next(function(){return t})}):r.dn(i).next(function(){return n(i)})}).then(function(t){return i.raiseOnCommittedEvent(),t})},t.prototype.dn=function(t){var e=this;return di(t).get(Mn.key).next(function(t){if(null!==t&&e.sn(t.leaseTimestampMs,5e3)&&!e.cn(t.ownerId)&&!e.tn(t)&&!(e.Ce||e.allowTabSynchronization&&t.allowTabSynchronization))throw new u(a.FAILED_PRECONDITION,fi)})},t.prototype.Ze=function(t){var e=new Mn(this.clientId,this.allowTabSynchronization,Date.now());return di(t).put(Mn.key,e)},t.yt=function(){return ir.yt()},t.prototype.Xe=function(t){var e=this,n=di(t);return n.get(Mn.key).next(function(t){return e.tn(t)?(f("IndexedDbPersistence","Releasing primary lease."),n.delete(Mn.key)):nr.resolve()})},t.prototype.sn=function(t,e){var n=Date.now();return!(t<n-e||t>n&&(l("Detected an update time that is in the future: "+t+" > "+n),1))},t.prototype.We=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Fe=function(){t.Se.enqueueAndForget(function(){return t.inForeground="visible"===t.document.visibilityState,t.je()})},this.document.addEventListener("visibilitychange",this.Fe),this.inForeground="visible"===this.document.visibilityState)},t.prototype.an=function(){this.Fe&&(this.document.removeEventListener("visibilitychange",this.Fe),this.Fe=null)},t.prototype.Ge=function(){var t,e=this;"function"==typeof(null===(t=this.window)||void 0===t?void 0:t.addEventListener)&&(this.ke=function(){e.un(),(0,n.isSafari)()&&navigator.appVersion.match("Version/14")&&e.Se.enterRestrictedMode(!0),e.Se.enqueueAndForget(function(){return e.shutdown()})},this.window.addEventListener("pagehide",this.ke))},t.prototype.hn=function(){this.ke&&(this.window.removeEventListener("pagehide",this.ke),this.ke=null)},t.prototype.cn=function(t){var e;try{var n=null!==(null===(e=this.Qe)||void 0===e?void 0:e.getItem(this.on(t)));return f("IndexedDbPersistence","Client '"+t+"' "+(n?"is":"is not")+" zombied in LocalStorage"),n}catch(t){return l("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},t.prototype.un=function(){if(this.Qe)try{this.Qe.setItem(this.on(this.clientId),String(Date.now()))}catch(t){l("Failed to set zombie client id.",t)}},t.prototype.ln=function(){if(this.Qe)try{this.Qe.removeItem(this.on(this.clientId))}catch(t){}},t.prototype.on=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},t}();function di(t){return dr(t,Mn.store)}function pi(t){return dr(t,Yn.store)}function yi(t,e){var n=t.projectId;return t.isDefaultDatabase||(n+="."+t.database),"firestore/"+e+"/"+n+"/"}var vi=function(t,e){this.progress=t,this.wn=e},mi=function(){function t(t,e,n){this.Ue=t,this._n=e,this.Ut=n}return t.prototype.mn=function(t,e){var n=this;return this._n.getAllMutationBatchesAffectingDocumentKey(t,e).next(function(r){return n.yn(t,e,r)})},t.prototype.yn=function(t,e,n){return this.Ue.getEntry(t,e).next(function(t){for(var e=0,r=n;e<r.length;e++)r[e].applyToLocalView(t);return t})},t.prototype.gn=function(t,e){t.forEach(function(t,n){for(var r=0,i=e;r<i.length;r++)i[r].applyToLocalView(n)})},t.prototype.pn=function(t,e){var n=this;return this.Ue.getEntries(t,e).next(function(e){return n.En(t,e).next(function(){return e})})},t.prototype.En=function(t,e){var n=this;return this._n.getAllMutationBatchesAffectingDocumentKeys(t,e).next(function(t){return n.gn(e,t)})},t.prototype.getDocumentsMatchingQuery=function(t,e,n){return function(t){return G.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}(e)?this.Tn(t,e.path):Pt(e)?this.In(t,e,n):this.An(t,e,n)},t.prototype.Tn=function(t,e){return this.mn(t,new G(e)).next(function(t){var e=Fe();return t.isFoundDocument()&&(e=e.insert(t.key,t)),e})},t.prototype.In=function(t,e,n){var r=this,i=e.collectionGroup,o=Fe();return this.Ut.getCollectionParents(t,i).next(function(s){return nr.forEach(s,function(s){var a=function(t,e){return new At(e,null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(e,s.child(i));return r.An(t,a,n).next(function(t){t.forEach(function(t,e){o=o.insert(t,e)})})}).next(function(){return o})})},t.prototype.An=function(t,e,n){var r,i,o=this;return this.Ue.getDocumentsMatchingQuery(t,e,n).next(function(n){return r=n,o._n.getAllMutationBatchesAffectingQuery(t,e)}).next(function(e){return i=e,o.Rn(t,i,r).next(function(t){r=t;for(var e=0,n=i;e<n.length;e++)for(var o=n[e],s=0,a=o.mutations;s<a.length;s++){var u=a[s],c=u.key,h=r.get(c);null==h&&(h=at.newInvalidDocument(c),r=r.insert(c,h)),le(u,h,o.localWriteTime),h.isFoundDocument()||(r=r.remove(c))}})}).next(function(){return r.forEach(function(t,n){jt(e,n)||(r=r.remove(t))}),r})},t.prototype.Rn=function(t,e,n){for(var r=Ue(),i=0,o=e;i<o.length;i++)for(var s=0,a=o[i].mutations;s<a.length;s++){var u=a[s];u instanceof me&&null===n.get(u.key)&&(r=r.add(u.key))}var c=n;return this.Ue.getEntries(t,r).next(function(t){return t.forEach(function(t,e){e.isFoundDocument()&&(c=c.insert(t,e))}),c})},t}(),gi=function(){function t(t,e,n,r){this.targetId=t,this.fromCache=e,this.bn=n,this.vn=r}return t.Pn=function(e,n){for(var r=Ue(),i=Ue(),o=0,s=n.docChanges;o<s.length;o++){var a=s[o];switch(a.type){case 0:r=r.add(a.doc.key);break;case 1:i=i.add(a.doc.key)}}return new t(e,n.fromCache,r,i)},t}(),_i=function(){function t(){}return t.prototype.Vn=function(t){this.Sn=t},t.prototype.getDocumentsMatchingQuery=function(t,e,n,i){var o=this;return function(t){return 0===t.filters.length&&null===t.limit&&null==t.startAt&&null==t.endAt&&(0===t.explicitOrderBy.length||1===t.explicitOrderBy.length&&t.explicitOrderBy[0].field.isKeyField())}(e)||n.isEqual(T.min())?this.Dn(t,e):this.Sn.pn(t,i).next(function(s){var a=o.Cn(e,s);return(Ct(e)||Rt(e))&&o.Nn(e.limitType,a,i,n)?o.Dn(t,e):(h()<=r.LogLevel.DEBUG&&f("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),Bt(e)),o.Sn.getDocumentsMatchingQuery(t,e,n).next(function(t){return a.forEach(function(e){t=t.insert(e.key,e)}),t}))})},t.prototype.Cn=function(t,e){var n=new Ce(Kt(t));return e.forEach(function(e,r){jt(t,r)&&(n=n.add(r))}),n},t.prototype.Nn=function(t,e,n,r){if(n.size!==e.size)return!0;var i="F"===t?e.last():e.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)},t.prototype.Dn=function(t,e){return h()<=r.LogLevel.DEBUG&&f("QueryEngine","Using full collection scan to execute query:",Bt(e)),this.Sn.getDocumentsMatchingQuery(t,e,T.min())},t}(),wi=function(){function t(t,e,n,r){this.persistence=t,this.xn=e,this.R=r,this.kn=new Ae(w),this.Fn=new ni(function(t){return ht(t)},ft),this.$n=T.min(),this._n=t.getMutationQueue(n),this.On=t.getRemoteDocumentCache(),this.qe=t.getTargetCache(),this.Mn=new mi(this.On,this._n,this.persistence.getIndexManager()),this.Ke=t.getBundleCache(),this.xn.Vn(this.Mn)}return t.prototype.collectGarbage=function(t){var e=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",function(n){return t.collect(n,e.kn)})},t}();function bi(t,e,n,r){return new wi(t,e,n,r)}function Ii(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o,s;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return r=m(t),i=r._n,o=r.Mn,[4,r.persistence.runTransaction("Handle user change","readonly",function(t){var e;return r._n.getAllMutationBatches(t).next(function(s){return e=s,i=r.persistence.getMutationQueue(n),o=new mi(r.On,i,r.persistence.getIndexManager()),i.getAllMutationBatches(t)}).next(function(n){for(var r=[],i=[],s=Ue(),a=0,u=e;a<u.length;a++){var c=u[a];r.push(c.batchId);for(var h=0,f=c.mutations;h<f.length;h++){var l=f[h];s=s.add(l.key)}}for(var d=0,p=n;d<p.length;d++){var y=p[d];i.push(y.batchId);for(var v=0,m=y.mutations;v<m.length;v++){var g=m[v];s=s.add(g.key)}}return o.pn(t,s).next(function(t){return{Ln:t,removedBatchIds:r,addedBatchIds:i}})})})];case 1:return s=e.sent(),[2,(r._n=i,r.Mn=o,r.xn.Vn(r.Mn),s)]}})})}function Ei(t,e){var n=m(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",function(t){var r=e.batch.keys(),i=n.On.newChangeBuffer({trackRemovals:!0});return function(t,e,n,r){var i=n.batch,o=i.keys(),s=nr.resolve();return o.forEach(function(t){s=s.next(function(){return r.getEntry(e,t)}).next(function(e){var o=n.docVersions.get(t);v(null!==o),e.version.compareTo(o)<0&&(i.applyToRemoteDocument(e,n),e.isValidDocument()&&r.addEntry(e,n.commitVersion))})}),s.next(function(){return t._n.removeMutationBatch(e,i)})}(n,t,e,i).next(function(){return i.apply(t)}).next(function(){return n._n.performConsistencyCheck(t)}).next(function(){return n.Mn.pn(t,r)})})}function Ti(t){var e=m(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",function(t){return e.qe.getLastRemoteSnapshotVersion(t)})}function Si(t,e){var n=m(t),r=e.snapshotVersion,i=n.kn;return n.persistence.runTransaction("Apply remote event","readwrite-primary",function(t){var o=n.On.newChangeBuffer({trackRemovals:!0});i=n.kn;var s=[];e.targetChanges.forEach(function(e,o){var a=i.get(o);if(a){s.push(n.qe.removeMatchingKeys(t,e.removedDocuments,o).next(function(){return n.qe.addMatchingKeys(t,e.addedDocuments,o)}));var u=e.resumeToken;if(u.approximateByteSize()>0){var c=a.withResumeToken(u,r).withSequenceNumber(t.currentSequenceNumber);i=i.insert(o,c),function(t,e,n){return v(e.resumeToken.approximateByteSize()>0),0===t.resumeToken.approximateByteSize()||e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(a,c,e)&&s.push(n.qe.updateTargetData(t,c))}}});var a=Oe();if(e.documentUpdates.forEach(function(r,i){e.resolvedLimboDocuments.has(r)&&s.push(n.persistence.referenceDelegate.updateLimboDocument(t,r))}),s.push(Ni(t,o,e.documentUpdates,r,void 0).next(function(t){a=t})),!r.isEqual(T.min())){var u=n.qe.getLastRemoteSnapshotVersion(t).next(function(e){return n.qe.setTargetsMetadata(t,t.currentSequenceNumber,r)});s.push(u)}return nr.waitFor(s).next(function(){return o.apply(t)}).next(function(){return n.Mn.En(t,a)}).next(function(){return a})}).then(function(t){return n.kn=i,t})}function Ni(t,e,n,r,i){var o=Ue();return n.forEach(function(t){return o=o.add(t)}),e.getEntries(t,o).next(function(t){var o=Oe();return n.forEach(function(n,s){var a=t.get(n),u=(null==i?void 0:i.get(n))||r;s.isNoDocument()&&s.version.isEqual(T.min())?(e.removeEntry(n,u),o=o.insert(n,s)):!a.isValidDocument()||s.version.compareTo(a.version)>0||0===s.version.compareTo(a.version)&&a.hasPendingWrites?(e.addEntry(s,u),o=o.insert(n,s)):f("LocalStore","Ignoring outdated watch update for ",n,". Current version:",a.version," Watch version:",s.version)}),o})}function Di(t,e){var n=m(t);return n.persistence.runTransaction("Get next mutation batch","readonly",function(t){return void 0===e&&(e=-1),n._n.getNextMutationBatchAfterBatchId(t,e)})}function Ai(t,e){var n=m(t);return n.persistence.runTransaction("Allocate target","readwrite",function(t){var r;return n.qe.getTargetData(t,e).next(function(i){return i?(r=i,nr.resolve(r)):n.qe.allocateTargetId(t).next(function(i){return r=new vr(e,i,0,t.currentSequenceNumber),n.qe.addTargetData(t,r).next(function(){return r})})})}).then(function(t){var r=n.kn.get(t.targetId);return(null===r||t.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.kn=n.kn.insert(t.targetId,t),n.Fn.set(e,t.targetId)),t})}function xi(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i,o,s,a;return(0,e.__generator)(this,function(e){switch(e.label){case 0:i=m(t),o=i.kn.get(n),s=r?"readwrite":"readwrite-primary",e.label=1;case 1:return e.trys.push([1,4,,5]),r?[3,3]:[4,i.persistence.runTransaction("Release target",s,function(t){return i.persistence.referenceDelegate.removeTarget(t,o)})];case 2:e.sent(),e.label=3;case 3:return[3,5];case 4:if(!ar(a=e.sent()))throw a;return f("LocalStore","Failed to update sequence numbers for target "+n+": "+a),[3,5];case 5:return i.kn=i.kn.remove(n),i.Fn.delete(o.target),[2]}})})}function ki(t,e,n){var r=m(t),i=T.min(),o=Ue();return r.persistence.runTransaction("Execute query","readonly",function(t){return function(t,e,n){var r=m(t),i=r.Fn.get(n);return void 0!==i?nr.resolve(r.kn.get(i)):r.qe.getTargetData(e,n)}(r,t,Mt(e)).next(function(e){if(e)return i=e.lastLimboFreeSnapshotVersion,r.qe.getMatchingKeysForTargetId(t,e.targetId).next(function(t){o=t})}).next(function(){return r.xn.getDocumentsMatchingQuery(t,e,n?i:T.min(),n?o:Ue())}).next(function(t){return{documents:t,Bn:o}})})}function Ci(t,e){var n=m(t),r=m(n.qe),i=n.kn.get(e);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",function(t){return r.lt(t,e).next(function(t){return t?t.target:null})})}function Ri(t){var e=m(t);return e.persistence.runTransaction("Get new document changes","readonly",function(t){return function(t,e,n){var r=m(t),i=Oe(),o=wr(n),s=ai(e),a=IDBKeyRange.lowerBound(o,!0);return s.$t({index:Kn.readTimeIndex,range:a},function(t,e){var n=gr(r.R,e);i=i.insert(n.key,n),o=e.readTime}).next(function(){return{wn:i,readTime:br(o)}})}(e.On,t,e.$n)}).then(function(t){var n=t.wn,r=t.readTime;return e.$n=r,n})}function Li(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){return[2,(n=m(t)).persistence.runTransaction("Synchronize last document change read time","readonly",function(t){return function(t){var e=ai(t),n=T.min();return e.$t({index:Kn.readTimeIndex,reverse:!0},function(t,e,r){e.readTime&&(n=br(e.readTime)),r.done()}).next(function(){return n})}(t)}).then(function(t){n.$n=t})]})})}function Oi(t,n,r,i){return(0,e.__awaiter)(this,void 0,void 0,function(){var o,s,a,u,c,h,f,l,d,p;return(0,e.__generator)(this,function(e){switch(e.label){case 0:for(o=m(t),s=Ue(),a=Oe(),u=Ve(),c=0,h=r;c<h.length;c++)f=h[c],l=n.qn(f.metadata.name),f.document&&(s=s.add(l)),a=a.insert(l,n.Un(f)),u=u.insert(l,n.Kn(f.metadata.readTime));return d=o.On.newChangeBuffer({trackRemovals:!0}),[4,Ai(o,function(t){return Mt(kt(x.fromString("__bundle__/docs/"+t)))}(i))];case 1:return p=e.sent(),[2,o.persistence.runTransaction("Apply bundle documents","readwrite",function(t){return Ni(t,d,a,T.min(),u).next(function(e){return d.apply(t),e}).next(function(e){return o.qe.removeMatchingKeysForTargetId(t,p.targetId).next(function(){return o.qe.addMatchingKeys(t,s,p.targetId)}).next(function(){return o.Mn.En(t,e)}).next(function(){return e})})})]}})})}function Pi(t,n,r){return void 0===r&&(r=Ue()),(0,e.__awaiter)(this,void 0,void 0,function(){var i,o;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,Ai(t,Mt(Dr(n.bundledQuery)))];case 1:return i=e.sent(),[2,(o=m(t)).persistence.runTransaction("Save named query","readwrite",function(t){var e=on(n.readTime);if(i.snapshotVersion.compareTo(e)>=0)return o.Ke.saveNamedQuery(t,n);var s=i.withResumeToken(L.EMPTY_BYTE_STRING,e);return o.kn=o.kn.insert(s.targetId,s),o.qe.updateTargetData(t,s).next(function(){return o.qe.removeMatchingKeysForTargetId(t,i.targetId)}).next(function(){return o.qe.addMatchingKeys(t,r,i.targetId)}).next(function(){return o.Ke.saveNamedQuery(t,n)})})]}})})}var Fi=function(){function t(t){this.R=t,this.Qn=new Map,this.jn=new Map}return t.prototype.getBundleMetadata=function(t,e){return nr.resolve(this.Qn.get(e))},t.prototype.saveBundleMetadata=function(t,e){var n;return this.Qn.set(e.id,{id:(n=e).id,version:n.version,createTime:on(n.createTime)}),nr.resolve()},t.prototype.getNamedQuery=function(t,e){return nr.resolve(this.jn.get(e))},t.prototype.saveNamedQuery=function(t,e){return this.jn.set(e.name,function(t){return{name:t.name,query:Dr(t.bundledQuery),readTime:on(t.readTime)}}(e)),nr.resolve()},t}(),Mi=function(){function t(){this.Wn=new Ce(Vi.Gn),this.zn=new Ce(Vi.Hn)}return t.prototype.isEmpty=function(){return this.Wn.isEmpty()},t.prototype.addReference=function(t,e){var n=new Vi(t,e);this.Wn=this.Wn.add(n),this.zn=this.zn.add(n)},t.prototype.Jn=function(t,e){var n=this;t.forEach(function(t){return n.addReference(t,e)})},t.prototype.removeReference=function(t,e){this.Yn(new Vi(t,e))},t.prototype.Xn=function(t,e){var n=this;t.forEach(function(t){return n.removeReference(t,e)})},t.prototype.Zn=function(t){var e=this,n=new G(new x([])),r=new Vi(n,t),i=new Vi(n,t+1),o=[];return this.zn.forEachInRange([r,i],function(t){e.Yn(t),o.push(t.key)}),o},t.prototype.ts=function(){var t=this;this.Wn.forEach(function(e){return t.Yn(e)})},t.prototype.Yn=function(t){this.Wn=this.Wn.delete(t),this.zn=this.zn.delete(t)},t.prototype.es=function(t){var e=new G(new x([])),n=new Vi(e,t),r=new Vi(e,t+1),i=Ue();return this.zn.forEachInRange([n,r],function(t){i=i.add(t.key)}),i},t.prototype.containsKey=function(t){var e=new Vi(t,0),n=this.Wn.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)},t}(),Vi=function(){function t(t,e){this.key=t,this.ns=e}return t.Gn=function(t,e){return G.comparator(t.key,e.key)||w(t.ns,e.ns)},t.Hn=function(t,e){return w(t.ns,e.ns)||G.comparator(t.key,e.key)},t}(),qi=function(){function t(t,e){this.Ut=t,this.referenceDelegate=e,this._n=[],this.ss=1,this.rs=new Ce(Vi.Gn)}return t.prototype.checkEmpty=function(t){return nr.resolve(0===this._n.length)},t.prototype.addMutationBatch=function(t,e,n,r){var i=this.ss;this.ss++,this._n.length>0&&this._n[this._n.length-1];var o=new pr(i,e,n,r);this._n.push(o);for(var s=0,a=r;s<a.length;s++){var u=a[s];this.rs=this.rs.add(new Vi(u.key,i)),this.Ut.addToCollectionParentIndex(t,u.key.path.popLast())}return nr.resolve(o)},t.prototype.lookupMutationBatch=function(t,e){return nr.resolve(this.os(e))},t.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=e+1,r=this.cs(n),i=r<0?0:r;return nr.resolve(this._n.length>i?this._n[i]:null)},t.prototype.getHighestUnacknowledgedBatchId=function(){return nr.resolve(0===this._n.length?-1:this.ss-1)},t.prototype.getAllMutationBatches=function(t){return nr.resolve(this._n.slice())},t.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,e){var n=this,r=new Vi(e,0),i=new Vi(e,Number.POSITIVE_INFINITY),o=[];return this.rs.forEachInRange([r,i],function(t){var e=n.os(t.ns);o.push(e)}),nr.resolve(o)},t.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var n=this,r=new Ce(w);return e.forEach(function(t){var e=new Vi(t,0),i=new Vi(t,Number.POSITIVE_INFINITY);n.rs.forEachInRange([e,i],function(t){r=r.add(t.ns)})}),nr.resolve(this.us(r))},t.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var n=e.path,r=n.length+1,i=n;G.isDocumentKey(i)||(i=i.child(""));var o=new Vi(new G(i),0),s=new Ce(w);return this.rs.forEachWhile(function(t){var e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===r&&(s=s.add(t.ns)),!0)},o),nr.resolve(this.us(s))},t.prototype.us=function(t){var e=this,n=[];return t.forEach(function(t){var r=e.os(t);null!==r&&n.push(r)}),n},t.prototype.removeMutationBatch=function(t,e){var n=this;v(0===this.hs(e.batchId,"removed")),this._n.shift();var r=this.rs;return nr.forEach(e.mutations,function(i){var o=new Vi(i.key,e.batchId);return r=r.delete(o),n.referenceDelegate.markPotentiallyOrphaned(t,i.key)}).next(function(){n.rs=r})},t.prototype.Gt=function(t){},t.prototype.containsKey=function(t,e){var n=new Vi(e,0),r=this.rs.firstAfterOrEqual(n);return nr.resolve(e.isEqual(r&&r.key))},t.prototype.performConsistencyCheck=function(t){return this._n.length,nr.resolve()},t.prototype.hs=function(t,e){return this.cs(t)},t.prototype.cs=function(t){return 0===this._n.length?0:t-this._n[0].batchId},t.prototype.os=function(t){var e=this.cs(t);return e<0||e>=this._n.length?null:this._n[e]},t}(),Ui=function(){function t(t,e){this.Ut=t,this.ls=e,this.docs=new Ae(G.comparator),this.size=0}return t.prototype.addEntry=function(t,e,n){var r=e.key,i=this.docs.get(r),o=i?i.size:0,s=this.ls(e);return this.docs=this.docs.insert(r,{document:e.clone(),size:s,readTime:n}),this.size+=s-o,this.Ut.addToCollectionParentIndex(t,r.path.popLast())},t.prototype.removeEntry=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},t.prototype.getEntry=function(t,e){var n=this.docs.get(e);return nr.resolve(n?n.document.clone():at.newInvalidDocument(e))},t.prototype.getEntries=function(t,e){var n=this,r=Oe();return e.forEach(function(t){var e=n.docs.get(t);r=r.insert(t,e?e.document.clone():at.newInvalidDocument(t))}),nr.resolve(r)},t.prototype.getDocumentsMatchingQuery=function(t,e,n){for(var r=Oe(),i=new G(e.path.child("")),o=this.docs.getIteratorFrom(i);o.hasNext();){var s=o.getNext(),a=s.key,u=s.value,c=u.document,h=u.readTime;if(!e.path.isPrefixOf(a.path))break;h.compareTo(n)<=0||jt(e,c)&&(r=r.insert(c.key,c.clone()))}return nr.resolve(r)},t.prototype.fs=function(t,e){return nr.forEach(this.docs,function(t){return e(t)})},t.prototype.newChangeBuffer=function(t){return new Bi(this)},t.prototype.getSize=function(t){return nr.resolve(this.size)},t}(),Bi=function(t){function n(e){var n=this;return(n=t.call(this)||this).Ie=e,n}return(0,e.__extends)(n,t),n.prototype.applyChanges=function(t){var e=this,n=[];return this.changes.forEach(function(r,i){i.document.isValidDocument()?n.push(e.Ie.addEntry(t,i.document,e.getReadTime(r))):e.Ie.removeEntry(r)}),nr.waitFor(n)},n.prototype.getFromCache=function(t,e){return this.Ie.getEntry(t,e)},n.prototype.getAllFromCache=function(t,e){return this.Ie.getEntries(t,e)},n}(ri),ji=function(){function t(t){this.persistence=t,this.ds=new ni(function(t){return ht(t)},ft),this.lastRemoteSnapshotVersion=T.min(),this.highestTargetId=0,this.ws=0,this._s=new Mi,this.targetCount=0,this.ys=Gr.Jt()}return t.prototype.forEachTarget=function(t,e){return this.ds.forEach(function(t,n){return e(n)}),nr.resolve()},t.prototype.getLastRemoteSnapshotVersion=function(t){return nr.resolve(this.lastRemoteSnapshotVersion)},t.prototype.getHighestSequenceNumber=function(t){return nr.resolve(this.ws)},t.prototype.allocateTargetId=function(t){return this.highestTargetId=this.ys.next(),nr.resolve(this.highestTargetId)},t.prototype.setTargetsMetadata=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.ws&&(this.ws=e),nr.resolve()},t.prototype.te=function(t){this.ds.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.ys=new Gr(e),this.highestTargetId=e),t.sequenceNumber>this.ws&&(this.ws=t.sequenceNumber)},t.prototype.addTargetData=function(t,e){return this.te(e),this.targetCount+=1,nr.resolve()},t.prototype.updateTargetData=function(t,e){return this.te(e),nr.resolve()},t.prototype.removeTargetData=function(t,e){return this.ds.delete(e.target),this._s.Zn(e.targetId),this.targetCount-=1,nr.resolve()},t.prototype.removeTargets=function(t,e,n){var r=this,i=0,o=[];return this.ds.forEach(function(s,a){a.sequenceNumber<=e&&null===n.get(a.targetId)&&(r.ds.delete(s),o.push(r.removeMatchingKeysForTargetId(t,a.targetId)),i++)}),nr.waitFor(o).next(function(){return i})},t.prototype.getTargetCount=function(t){return nr.resolve(this.targetCount)},t.prototype.getTargetData=function(t,e){var n=this.ds.get(e)||null;return nr.resolve(n)},t.prototype.addMatchingKeys=function(t,e,n){return this._s.Jn(e,n),nr.resolve()},t.prototype.removeMatchingKeys=function(t,e,n){this._s.Xn(e,n);var r=this.persistence.referenceDelegate,i=[];return r&&e.forEach(function(e){i.push(r.markPotentiallyOrphaned(t,e))}),nr.waitFor(i)},t.prototype.removeMatchingKeysForTargetId=function(t,e){return this._s.Zn(e),nr.resolve()},t.prototype.getMatchingKeysForTargetId=function(t,e){var n=this._s.es(e);return nr.resolve(n)},t.prototype.containsKey=function(t,e){return nr.resolve(this._s.containsKey(e))},t}(),Ki=function(){function t(t,e){var n=this;this.gs={},this.Ne=new s(0),this.xe=!1,this.xe=!0,this.referenceDelegate=t(this),this.qe=new ji(this),this.Ut=new Cr,this.Ue=function(t,e){return new Ui(t,function(t){return n.referenceDelegate.ps(t)})}(this.Ut),this.R=new mr(e),this.Ke=new Fi(this.R)}return t.prototype.start=function(){return Promise.resolve()},t.prototype.shutdown=function(){return this.xe=!1,Promise.resolve()},Object.defineProperty(t.prototype,"started",{get:function(){return this.xe},enumerable:!1,configurable:!0}),t.prototype.setDatabaseDeletedListener=function(){},t.prototype.setNetworkEnabled=function(){},t.prototype.getIndexManager=function(){return this.Ut},t.prototype.getMutationQueue=function(t){var e=this.gs[t.toKey()];return e||(e=new qi(this.Ut,this.referenceDelegate),this.gs[t.toKey()]=e),e},t.prototype.getTargetCache=function(){return this.qe},t.prototype.getRemoteDocumentCache=function(){return this.Ue},t.prototype.getBundleCache=function(){return this.Ke},t.prototype.runTransaction=function(t,e,n){var r=this;f("MemoryPersistence","Starting transaction:",t);var i=new Gi(this.Ne.next());return this.referenceDelegate.Es(),n(i).next(function(t){return r.referenceDelegate.Ts(i).next(function(){return t})}).toPromise().then(function(t){return i.raiseOnCommittedEvent(),t})},t.prototype.Is=function(t,e){return nr.or(Object.values(this.gs).map(function(n){return function(){return n.containsKey(t,e)}}))},t}(),Gi=function(t){function n(e){var n=this;return(n=t.call(this)||this).currentSequenceNumber=e,n}return(0,e.__extends)(n,t),n}(tr),Qi=function(){function t(t){this.persistence=t,this.As=new Mi,this.Rs=null}return t.bs=function(e){return new t(e)},Object.defineProperty(t.prototype,"vs",{get:function(){if(this.Rs)return this.Rs;throw y()},enumerable:!1,configurable:!0}),t.prototype.addReference=function(t,e,n){return this.As.addReference(n,e),this.vs.delete(n.toString()),nr.resolve()},t.prototype.removeReference=function(t,e,n){return this.As.removeReference(n,e),this.vs.add(n.toString()),nr.resolve()},t.prototype.markPotentiallyOrphaned=function(t,e){return this.vs.add(e.toString()),nr.resolve()},t.prototype.removeTarget=function(t,e){var n=this;this.As.Zn(e.targetId).forEach(function(t){return n.vs.add(t.toString())});var r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(t,e.targetId).next(function(t){t.forEach(function(t){return n.vs.add(t.toString())})}).next(function(){return r.removeTargetData(t,e)})},t.prototype.Es=function(){this.Rs=new Set},t.prototype.Ts=function(t){var e=this,n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return nr.forEach(this.vs,function(r){var i=G.fromPath(r);return e.Ps(t,i).next(function(t){t||n.removeEntry(i)})}).next(function(){return e.Rs=null,n.apply(t)})},t.prototype.updateLimboDocument=function(t,e){var n=this;return this.Ps(t,e).next(function(t){t?n.vs.delete(e.toString()):n.vs.add(e.toString())})},t.prototype.ps=function(t){return 0},t.prototype.Ps=function(t,e){var n=this;return nr.or([function(){return nr.resolve(n.As.containsKey(e))},function(){return n.persistence.getTargetCache().containsKey(t,e)},function(){return n.persistence.Is(t,e)}])},t}(),zi=function(){function t(t){this.uid=t}return t.prototype.isAuthenticated=function(){return null!=this.uid},t.prototype.toKey=function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"},t.prototype.isEqual=function(t){return t.uid===this.uid},t}();function Wi(t,e){return"firestore_clients_"+t+"_"+e}function Hi(t,e,n){var r="firestore_mutations_"+t+"_"+n;return e.isAuthenticated()&&(r+="_"+e.uid),r}function Yi(t,e){return"firestore_targets_"+t+"_"+e}zi.UNAUTHENTICATED=new zi(null),zi.GOOGLE_CREDENTIALS=new zi("google-credentials-uid"),zi.FIRST_PARTY=new zi("first-party-uid"),zi.MOCK_USER=new zi("mock-user");var $i=function(){function t(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}return t.Vs=function(e,n,r){var i,s=JSON.parse(r),a="object"==o(s)&&-1!==["pending","acknowledged","rejected"].indexOf(s.state)&&(void 0===s.error||"object"==o(s.error));return a&&s.error&&(a="string"==typeof s.error.message&&"string"==typeof s.error.code)&&(i=new u(s.error.code,s.error.message)),a?new t(e,n,s.state,i):(l("SharedClientState","Failed to parse mutation state for ID '"+n+"': "+r),null)},t.prototype.Ss=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},t}(),Xi=function(){function t(t,e,n){this.targetId=t,this.state=e,this.error=n}return t.Vs=function(e,n){var r,i=JSON.parse(n),s="object"==o(i)&&-1!==["not-current","current","rejected"].indexOf(i.state)&&(void 0===i.error||"object"==o(i.error));return s&&i.error&&(s="string"==typeof i.error.message&&"string"==typeof i.error.code)&&(r=new u(i.error.code,i.error.message)),s?new t(e,i.state,r):(l("SharedClientState","Failed to parse target state for ID '"+e+"': "+n),null)},t.prototype.Ss=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},t}(),Ji=function(){function t(t,e){this.clientId=t,this.activeTargetIds=e}return t.Vs=function(e,n){for(var r=JSON.parse(n),i="object"==o(r)&&r.activeTargetIds instanceof Array,s=je(),a=0;i&&a<r.activeTargetIds.length;++a)i=K(r.activeTargetIds[a]),s=s.add(r.activeTargetIds[a]);return i?new t(e,s):(l("SharedClientState","Failed to parse client data for instance '"+e+"': "+n),null)},t}(),Zi=function(){function t(t,e){this.clientId=t,this.onlineState=e}return t.Vs=function(e){var n=JSON.parse(e);return"object"==o(n)&&-1!==["Unknown","Online","Offline"].indexOf(n.onlineState)&&"string"==typeof n.clientId?new t(n.clientId,n.onlineState):(l("SharedClientState","Failed to parse online state: "+e),null)},t}(),to=function(){function t(){this.activeTargetIds=je()}return t.prototype.Ds=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},t.prototype.Cs=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},t.prototype.Ss=function(){var t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)},t}(),eo=function(){function t(t,e,n,r,i){this.window=t,this.Se=e,this.persistenceKey=n,this.Ns=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.xs=this.ks.bind(this),this.Fs=new Ae(w),this.started=!1,this.$s=[];var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Os=Wi(this.persistenceKey,this.Ns),this.Ms=function(t){return"firestore_sequence_number_"+t}(this.persistenceKey),this.Fs=this.Fs.insert(this.Ns,new to),this.Ls=new RegExp("^firestore_clients_"+o+"_([^_]*)$"),this.Bs=new RegExp("^firestore_mutations_"+o+"_(\\d+)(?:_(.*))?$"),this.qs=new RegExp("^firestore_targets_"+o+"_(\\d+)$"),this.Us=function(t){return"firestore_online_state_"+t}(this.persistenceKey),this.Ks=function(t){return"firestore_bundle_loaded_"+t}(this.persistenceKey),this.window.addEventListener("storage",this.xs)}return t.yt=function(t){return!(!t||!t.localStorage)},t.prototype.start=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o,s,a,u,c,h,f,l=this;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,this.syncEngine.fn()];case 1:for(t=e.sent(),n=0,r=t;n<r.length;n++)(i=r[n])!==this.Ns&&(o=this.getItem(Wi(this.persistenceKey,i)))&&(s=Ji.Vs(i,o))&&(this.Fs=this.Fs.insert(s.clientId,s));for(this.Qs(),(a=this.storage.getItem(this.Us))&&(u=this.js(a))&&this.Ws(u),c=0,h=this.$s;c<h.length;c++)f=h[c],this.ks(f);return this.$s=[],this.window.addEventListener("pagehide",function(){return l.shutdown()}),this.started=!0,[2]}})})},t.prototype.writeSequenceNumber=function(t){this.setItem(this.Ms,JSON.stringify(t))},t.prototype.getAllActiveQueryTargets=function(){return this.Gs(this.Fs)},t.prototype.isActiveQueryTarget=function(t){var e=!1;return this.Fs.forEach(function(n,r){r.activeTargetIds.has(t)&&(e=!0)}),e},t.prototype.addPendingMutation=function(t){this.zs(t,"pending")},t.prototype.updateMutationState=function(t,e,n){this.zs(t,e,n),this.Hs(t)},t.prototype.addLocalQueryTarget=function(t){var e="not-current";if(this.isActiveQueryTarget(t)){var n=this.storage.getItem(Yi(this.persistenceKey,t));if(n){var r=Xi.Vs(t,n);r&&(e=r.state)}}return this.Js.Ds(t),this.Qs(),e},t.prototype.removeLocalQueryTarget=function(t){this.Js.Cs(t),this.Qs()},t.prototype.isLocalQueryTarget=function(t){return this.Js.activeTargetIds.has(t)},t.prototype.clearQueryState=function(t){this.removeItem(Yi(this.persistenceKey,t))},t.prototype.updateQueryState=function(t,e,n){this.Ys(t,e,n)},t.prototype.handleUserChange=function(t,e,n){var r=this;e.forEach(function(t){r.Hs(t)}),this.currentUser=t,n.forEach(function(t){r.addPendingMutation(t)})},t.prototype.setOnlineState=function(t){this.Xs(t)},t.prototype.notifyBundleLoaded=function(){this.Zs()},t.prototype.shutdown=function(){this.started&&(this.window.removeEventListener("storage",this.xs),this.removeItem(this.Os),this.started=!1)},t.prototype.getItem=function(t){var e=this.storage.getItem(t);return f("SharedClientState","READ",t,e),e},t.prototype.setItem=function(t,e){f("SharedClientState","SET",t,e),this.storage.setItem(t,e)},t.prototype.removeItem=function(t){f("SharedClientState","REMOVE",t),this.storage.removeItem(t)},t.prototype.ks=function(t){var n=this,r=t;if(r.storageArea===this.storage){if(f("SharedClientState","EVENT",r.key,r.newValue),r.key===this.Os)return void l("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Se.enqueueRetryable(function(){return(0,e.__awaiter)(n,void 0,void 0,function(){var t,n,i,o,a,u;return(0,e.__generator)(this,function(e){if(this.started){if(null!==r.key)if(this.Ls.test(r.key)){if(null==r.newValue)return t=this.ti(r.key),[2,this.ei(t,null)];if(n=this.ni(r.key,r.newValue))return[2,this.ei(n.clientId,n)]}else if(this.Bs.test(r.key)){if(null!==r.newValue&&(i=this.si(r.key,r.newValue)))return[2,this.ii(i)]}else if(this.qs.test(r.key)){if(null!==r.newValue&&(o=this.ri(r.key,r.newValue)))return[2,this.oi(o)]}else if(r.key===this.Us){if(null!==r.newValue&&(a=this.js(r.newValue)))return[2,this.Ws(a)]}else if(r.key===this.Ms)(u=function(t){var e=s.o;if(null!=t)try{var n=JSON.parse(t);v("number"==typeof n),e=n}catch(t){l("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(r.newValue))!==s.o&&this.sequenceNumberHandler(u);else if(r.key===this.Ks)return[2,this.syncEngine.ci()]}else this.$s.push(r);return[2]})})})}},Object.defineProperty(t.prototype,"Js",{get:function(){return this.Fs.get(this.Ns)},enumerable:!1,configurable:!0}),t.prototype.Qs=function(){this.setItem(this.Os,this.Js.Ss())},t.prototype.zs=function(t,e,n){var r=new $i(this.currentUser,t,e,n),i=Hi(this.persistenceKey,this.currentUser,t);this.setItem(i,r.Ss())},t.prototype.Hs=function(t){var e=Hi(this.persistenceKey,this.currentUser,t);this.removeItem(e)},t.prototype.Xs=function(t){var e={clientId:this.Ns,onlineState:t};this.storage.setItem(this.Us,JSON.stringify(e))},t.prototype.Ys=function(t,e,n){var r=Yi(this.persistenceKey,t),i=new Xi(t,e,n);this.setItem(r,i.Ss())},t.prototype.Zs=function(){this.setItem(this.Ks,"value-not-used")},t.prototype.ti=function(t){var e=this.Ls.exec(t);return e?e[1]:null},t.prototype.ni=function(t,e){var n=this.ti(t);return Ji.Vs(n,e)},t.prototype.si=function(t,e){var n=this.Bs.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return $i.Vs(new zi(i),r,e)},t.prototype.ri=function(t,e){var n=this.qs.exec(t),r=Number(n[1]);return Xi.Vs(r,e)},t.prototype.js=function(t){return Zi.Vs(t)},t.prototype.ii=function(t){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(e){return t.user.uid===this.currentUser.uid?[2,this.syncEngine.ui(t.batchId,t.state,t.error)]:(f("SharedClientState","Ignoring mutation for non-active user "+t.user.uid),[2])})})},t.prototype.oi=function(t){return this.syncEngine.ai(t.targetId,t.state,t.error)},t.prototype.ei=function(t,e){var n=this,r=e?this.Fs.insert(t,e):this.Fs.remove(t),i=this.Gs(this.Fs),o=this.Gs(r),s=[],a=[];return o.forEach(function(t){i.has(t)||s.push(t)}),i.forEach(function(t){o.has(t)||a.push(t)}),this.syncEngine.hi(s,a).then(function(){n.Fs=r})},t.prototype.Ws=function(t){this.Fs.get(t.clientId)&&this.onlineStateHandler(t.onlineState)},t.prototype.Gs=function(t){var e=je();return t.forEach(function(t,n){e=e.unionWith(n.activeTargetIds)}),e},t}(),no=function(){function t(){this.li=new to,this.fi={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}return t.prototype.addPendingMutation=function(t){},t.prototype.updateMutationState=function(t,e,n){},t.prototype.addLocalQueryTarget=function(t){return this.li.Ds(t),this.fi[t]||"not-current"},t.prototype.updateQueryState=function(t,e,n){this.fi[t]=e},t.prototype.removeLocalQueryTarget=function(t){this.li.Cs(t)},t.prototype.isLocalQueryTarget=function(t){return this.li.activeTargetIds.has(t)},t.prototype.clearQueryState=function(t){delete this.fi[t]},t.prototype.getAllActiveQueryTargets=function(){return this.li.activeTargetIds},t.prototype.isActiveQueryTarget=function(t){return this.li.activeTargetIds.has(t)},t.prototype.start=function(){return this.li=new to,Promise.resolve()},t.prototype.handleUserChange=function(t,e,n){},t.prototype.setOnlineState=function(t){},t.prototype.shutdown=function(){},t.prototype.writeSequenceNumber=function(t){},t.prototype.notifyBundleLoaded=function(){},t}(),ro=function(){function t(){}return t.prototype.di=function(t){},t.prototype.shutdown=function(){},t}(),io=function(){function t(){var t=this;this.wi=function(){return t._i()},this.mi=function(){return t.yi()},this.gi=[],this.pi()}return t.prototype.di=function(t){this.gi.push(t)},t.prototype.shutdown=function(){window.removeEventListener("online",this.wi),window.removeEventListener("offline",this.mi)},t.prototype.pi=function(){window.addEventListener("online",this.wi),window.addEventListener("offline",this.mi)},t.prototype._i=function(){f("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.gi;t<e.length;t++)(0,e[t])(0)},t.prototype.yi=function(){f("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.gi;t<e.length;t++)(0,e[t])(1)},t.yt=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},t}(),oo={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"},so=function(){function t(t){this.Ei=t.Ei,this.Ti=t.Ti}return t.prototype.Ii=function(t){this.Ai=t},t.prototype.Ri=function(t){this.bi=t},t.prototype.onMessage=function(t){this.vi=t},t.prototype.close=function(){this.Ti()},t.prototype.send=function(t){this.Ei(t)},t.prototype.Pi=function(){this.Ai()},t.prototype.Vi=function(t){this.bi(t)},t.prototype.Si=function(t){this.vi(t)},t}(),ao=function(t){function r(e){var n=this;return(n=t.call(this,e)||this).forceLongPolling=e.forceLongPolling,n.autoDetectLongPolling=e.autoDetectLongPolling,n.useFetchStreams=e.useFetchStreams,n}return(0,e.__extends)(r,t),r.prototype.Fi=function(t,e,n,r){return new Promise(function(o,s){var c=new i.XhrIo;c.listenOnce(i.EventType.COMPLETE,function(){try{switch(c.getLastErrorCode()){case i.ErrorCode.NO_ERROR:var e=c.getResponseJson();f("Connection","XHR received:",JSON.stringify(e)),o(e);break;case i.ErrorCode.TIMEOUT:f("Connection",'RPC "'+t+'" timed out'),s(new u(a.DEADLINE_EXCEEDED,"Request time out"));break;case i.ErrorCode.HTTP_ERROR:var n=c.getStatus();if(f("Connection",'RPC "'+t+'" failed with status:',n,"response text:",c.getResponseText()),n>0){var r=c.getResponseJson().error;if(r&&r.status&&r.message){var h=function(t){var e=r.status.toLowerCase().replace(/_/g,"-");return Object.values(a).indexOf(e)>=0?e:a.UNKNOWN}();s(new u(h,r.message))}else s(new u(a.UNKNOWN,"Server responded with status "+c.getStatus()))}else s(new u(a.UNAVAILABLE,"Connection failed."));break;default:y()}}finally{f("Connection",'RPC "'+t+'" completed.')}});var h=JSON.stringify(r);c.send(e,"POST",h,n,15)})},r.prototype.Oi=function(t,e){var r=[this.Di,"/","google.firestore.v1.Firestore","/",t,"/channel"],o=(0,i.createWebChannelTransport)(),s=(0,i.getStatEventTarget)(),c={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.useFetchStreams&&(c.xmlHttpFactory=new i.FetchXmlHttpFactory({})),this.ki(c.initMessageHeaders,e),(0,n.isMobileCordova)()||(0,n.isReactNative)()||(0,n.isElectron)()||(0,n.isIE)()||(0,n.isUWP)()||(0,n.isBrowserExtension)()||(c.httpHeadersOverwriteParam="$httpHeaders");var h=r.join("");f("Connection","Creating WebChannel: "+h,c);var l=o.createWebChannel(h,c),p=!1,y=!1,m=new so({Ei:function(t){y?f("Connection","Not sending because WebChannel is closed:",t):(p||(f("Connection","Opening WebChannel transport."),l.open(),p=!0),f("Connection","WebChannel sending:",t),l.send(t))},Ti:function(){return l.close()}}),g=function(t,e,n){t.listen(e,function(t){try{n(t)}catch(t){setTimeout(function(){throw t},0)}})};return g(l,i.WebChannel.EventType.OPEN,function(){y||f("Connection","WebChannel transport opened.")}),g(l,i.WebChannel.EventType.CLOSE,function(){y||(y=!0,f("Connection","WebChannel transport closed"),m.Vi())}),g(l,i.WebChannel.EventType.ERROR,function(t){y||(y=!0,d("Connection","WebChannel transport errored:",t),m.Vi(new u(a.UNAVAILABLE,"The operation could not be completed")))}),g(l,i.WebChannel.EventType.MESSAGE,function(t){var e;if(!y){var n=t.data[0];v(!!n);var r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){f("Connection","WebChannel received error:",i);var o=i.status,s=function(t){var e=be[o];if(void 0!==e)return De(e)}(),c=i.message;void 0===s&&(s=a.INTERNAL,c="Unknown error status: "+o+" with message "+i.message),y=!0,m.Vi(new u(s,c)),l.close()}else f("Connection","WebChannel received:",n),m.Si(n)}}),g(s,i.Event.STAT_EVENT,function(t){t.stat===i.Stat.PROXY?f("Connection","Detected buffering proxy"):t.stat===i.Stat.NOPROXY&&f("Connection","Detected no buffering proxy")}),setTimeout(function(){m.Pi()},0),m},r}(function(){function t(t){this.databaseInfo=t,this.databaseId=t.databaseId;var e=t.ssl?"https":"http";this.Di=e+"://"+t.host,this.Ci="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}return t.prototype.Ni=function(t,e,n,r){var i=this.xi(t,e);f("RestConnection","Sending: ",i,n);var o={};return this.ki(o,r),this.Fi(t,i,o,n).then(function(t){return f("RestConnection","Received: ",t),t},function(e){throw d("RestConnection",t+" failed with error: ",e,"url: ",i,"request:",n),e})},t.prototype.$i=function(t,e,n,r){return this.Ni(t,e,n,r)},t.prototype.ki=function(t,e){if(t["X-Goog-Api-Client"]="gl-js/ fire/8.10.1",t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e)for(var n in e.authHeaders)e.authHeaders.hasOwnProperty(n)&&(t[n]=e.authHeaders[n])},t.prototype.xi=function(t,e){var n=oo[t];return this.Di+"/v1/"+e+":"+n},t}());function uo(){return"undefined"!=typeof window?window:null}function co(){return"undefined"!=typeof document?document:null}function ho(t){return new tn(t,!0)}var fo=function(){function t(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.Se=t,this.timerId=e,this.Mi=n,this.Li=r,this.Bi=i,this.qi=0,this.Ui=null,this.Ki=Date.now(),this.reset()}return t.prototype.reset=function(){this.qi=0},t.prototype.Qi=function(){this.qi=this.Bi},t.prototype.ji=function(t){var e=this;this.cancel();var n=Math.floor(this.qi+this.Wi()),r=Math.max(0,Date.now()-this.Ki),i=Math.max(0,n-r);i>0&&f("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.qi+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.Ui=this.Se.enqueueAfterDelay(this.timerId,i,function(){return e.Ki=Date.now(),t()}),this.qi*=this.Li,this.qi<this.Mi&&(this.qi=this.Mi),this.qi>this.Bi&&(this.qi=this.Bi)},t.prototype.Gi=function(){null!==this.Ui&&(this.Ui.skipDelay(),this.Ui=null)},t.prototype.cancel=function(){null!==this.Ui&&(this.Ui.cancel(),this.Ui=null)},t.prototype.Wi=function(){return(Math.random()-.5)*this.qi},t}(),lo=function(){function t(t,e,n,r,i,o){this.Se=t,this.zi=n,this.Hi=r,this.Ji=i,this.listener=o,this.state=0,this.Yi=0,this.Xi=null,this.stream=null,this.Zi=new fo(t,e)}return t.prototype.tr=function(){return 1===this.state||2===this.state||4===this.state},t.prototype.er=function(){return 2===this.state},t.prototype.start=function(){3!==this.state?this.auth():this.nr()},t.prototype.stop=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(t){switch(t.label){case 0:return this.tr()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},t.prototype.sr=function(){this.state=0,this.Zi.reset()},t.prototype.ir=function(){var t=this;this.er()&&null===this.Xi&&(this.Xi=this.Se.enqueueAfterDelay(this.zi,6e4,function(){return t.rr()}))},t.prototype.cr=function(t){this.ur(),this.stream.send(t)},t.prototype.rr=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(t){return this.er()?[2,this.close(0)]:[2]})})},t.prototype.ur=function(){this.Xi&&(this.Xi.cancel(),this.Xi=null)},t.prototype.close=function(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return this.ur(),this.Zi.cancel(),this.Yi++,3!==t?this.Zi.reset():n&&n.code===a.RESOURCE_EXHAUSTED?(l(n.toString()),l("Using maximum backoff delay to prevent overloading the backend."),this.Zi.Qi()):n&&n.code===a.UNAUTHENTICATED&&this.Ji.invalidateToken(),null!==this.stream&&(this.ar(),this.stream.close(),this.stream=null),this.state=t,[4,this.listener.Ri(n)];case 1:return e.sent(),[2]}})})},t.prototype.ar=function(){},t.prototype.auth=function(){var t=this;this.state=1;var e=this.hr(this.Yi),n=this.Yi;this.Ji.getToken().then(function(e){t.Yi===n&&t.lr(e)},function(n){e(function(){var e=new u(a.UNKNOWN,"Fetching auth token failed: "+n.message);return t.dr(e)})})},t.prototype.lr=function(t){var e=this,n=this.hr(this.Yi);this.stream=this.wr(t),this.stream.Ii(function(){n(function(){return e.state=2,e.listener.Ii()})}),this.stream.Ri(function(t){n(function(){return e.dr(t)})}),this.stream.onMessage(function(t){n(function(){return e.onMessage(t)})})},t.prototype.nr=function(){var t=this;this.state=4,this.Zi.ji(function(){return(0,e.__awaiter)(t,void 0,void 0,function(){return(0,e.__generator)(this,function(t){return this.state=0,this.start(),[2]})})})},t.prototype.dr=function(t){return f("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},t.prototype.hr=function(t){var e=this;return function(n){e.Se.enqueueAndForget(function(){return e.Yi===t?n():(f("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},t}(),po=function(t){function n(e,n,r,i,o){var s=this;return(s=t.call(this,e,"listen_stream_connection_backoff","listen_stream_idle",n,r,o)||this).R=i,s}return(0,e.__extends)(n,t),n.prototype.wr=function(t){return this.Hi.Oi("Listen",t)},n.prototype.onMessage=function(t){this.Zi.reset();var e=function(t,e){var n;if("targetChange"in e){e.targetChange;var r=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:y()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],o=function(t,e){return t.I?(v(void 0===e||"string"==typeof e),L.fromBase64String(e||"")):(v(void 0===e||e instanceof Uint8Array),L.fromUint8Array(e||new Uint8Array))}(t,e.targetChange.resumeToken),s=(c=e.targetChange.cause)&&function(t){var e=void 0===t.code?a.UNKNOWN:De(t.code);return new u(e,t.message||"")}(c);n=new We(r,i,o,s||null)}else if("documentChange"in e){e.documentChange,(r=e.documentChange).document,r.document.name,r.document.updateTime,i=cn(t,r.document.name),o=on(r.document.updateTime);var c=new ot({mapValue:{fields:r.document.fields}}),h=(s=at.newFoundDocument(i,o,c),r.targetIds||[]),f=r.removedTargetIds||[];n=new Qe(h,f,s.key,s)}else if("documentDelete"in e)e.documentDelete,(r=e.documentDelete).document,i=cn(t,r.document),o=r.readTime?on(r.readTime):T.min(),c=at.newNoDocument(i,o),s=r.removedTargetIds||[],n=new Qe([],s,c.key,c);else if("documentRemove"in e)e.documentRemove,(r=e.documentRemove).document,i=cn(t,r.document),o=r.removedTargetIds||[],n=new Qe([],o,i,null);else{if(!("filter"in e))return y();e.filter;var l=e.filter;l.targetId,r=l.count||0,i=new Se(r),o=l.targetId,n=new ze(o,i)}return n}(this.R,t),n=function(t){if(!("targetChange"in t))return T.min();var e=t.targetChange;return e.targetIds&&e.targetIds.length?T.min():e.readTime?on(e.readTime):T.min()}(t);return this.listener._r(e,n)},n.prototype.mr=function(t){var e={};e.database=ln(this.R),e.addTarget=function(t,e){var n,r=e.target;return(n=lt(r)?{documents:gn(t,r)}:{query:_n(t,r)}).targetId=e.targetId,e.resumeToken.approximateByteSize()>0?n.resumeToken=nn(t,e.resumeToken):e.snapshotVersion.compareTo(T.min())>0&&(n.readTime=en(t,e.snapshotVersion.toTimestamp())),n}(this.R,t);var n=function(t,e){var n=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return y()}}(0,e.purpose);return null==n?null:{"goog-listen-tags":n}}(this.R,t);n&&(e.labels=n),this.cr(e)},n.prototype.yr=function(t){var e={};e.database=ln(this.R),e.removeTarget=t,this.cr(e)},n}(lo),yo=function(t){function n(e,n,r,i,o){var s=this;return(s=t.call(this,e,"write_stream_connection_backoff","write_stream_idle",n,r,o)||this).R=i,s.gr=!1,s}return(0,e.__extends)(n,t),Object.defineProperty(n.prototype,"pr",{get:function(){return this.gr},enumerable:!1,configurable:!0}),n.prototype.start=function(){this.gr=!1,this.lastStreamToken=void 0,t.prototype.start.call(this)},n.prototype.ar=function(){this.gr&&this.Er([])},n.prototype.wr=function(t){return this.Hi.Oi("Write",t)},n.prototype.onMessage=function(t){if(v(!!t.streamToken),this.lastStreamToken=t.streamToken,this.gr){this.Zi.reset();var e=function(t,e){return t&&t.length>0?(v(void 0!==e),t.map(function(t){return function(t,e){var n=t.updateTime?on(t.updateTime):on(e);return n.isEqual(T.min())&&(n=on(e)),new ae(n,t.transformResults||[])}(t,e)})):[]}(t.writeResults,t.commitTime),n=on(t.commitTime);return this.listener.Tr(n,e)}return v(!t.writeResults||0===t.writeResults.length),this.gr=!0,this.listener.Ir()},n.prototype.Ar=function(){var t={};t.database=ln(this.R),this.cr(t)},n.prototype.Er=function(t){var e=this,n={streamToken:this.lastStreamToken,writes:t.map(function(t){return vn(e.R,t)})};this.cr(n)},n}(lo),vo=function(t){function n(e,n,r){var i=this;return(i=t.call(this)||this).credentials=e,i.Hi=n,i.R=r,i.Rr=!1,i}return(0,e.__extends)(n,t),n.prototype.br=function(){if(this.Rr)throw new u(a.FAILED_PRECONDITION,"The client has already been terminated.")},n.prototype.Ni=function(t,e,n){var r=this;return this.br(),this.credentials.getToken().then(function(i){return r.Hi.Ni(t,e,n,i)}).catch(function(t){throw"FirebaseError"===t.name?(t.code===a.UNAUTHENTICATED&&r.credentials.invalidateToken(),t):new u(a.UNKNOWN,t.toString())})},n.prototype.$i=function(t,e,n){var r=this;return this.br(),this.credentials.getToken().then(function(i){return r.Hi.$i(t,e,n,i)}).catch(function(t){throw"FirebaseError"===t.name?(t.code===a.UNAUTHENTICATED&&r.credentials.invalidateToken(),t):new u(a.UNKNOWN,t.toString())})},n.prototype.terminate=function(){this.Rr=!0},n}(function(){}),mo=function(){function t(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.vr=0,this.Pr=null,this.Vr=!0}return t.prototype.Sr=function(){var t=this;0===this.vr&&(this.Dr("Unknown"),this.Pr=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,function(){return t.Pr=null,t.Cr("Backend didn't respond within 10 seconds."),t.Dr("Offline"),Promise.resolve()}))},t.prototype.Nr=function(t){"Online"===this.state?this.Dr("Unknown"):(this.vr++,this.vr>=1&&(this.kr(),this.Cr("Connection failed 1 times. Most recent error: "+t.toString()),this.Dr("Offline")))},t.prototype.set=function(t){this.kr(),this.vr=0,"Online"===t&&(this.Vr=!1),this.Dr(t)},t.prototype.Dr=function(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))},t.prototype.Cr=function(t){var e="Could not reach Cloud Firestore backend. "+t+"\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.";this.Vr?(l(e),this.Vr=!1):f("OnlineStateTracker",e)},t.prototype.kr=function(){null!==this.Pr&&(this.Pr.cancel(),this.Pr=null)},t}(),go=function(t,n,r,i,o){var s=this;this.localStore=t,this.datastore=n,this.asyncQueue=r,this.remoteSyncer={},this.Fr=[],this.$r=new Map,this.Or=new Set,this.Mr=[],this.Lr=o,this.Lr.di(function(t){r.enqueueAndForget(function(){return(0,e.__awaiter)(s,void 0,void 0,function(){return(0,e.__generator)(this,function(t){switch(t.label){case 0:return Do(this)?(f("RemoteStore","Restarting streams for network reachability change."),[4,function(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return(n=m(t)).Or.add(4),[4,wo(n)];case 1:return e.sent(),n.Br.set("Unknown"),n.Or.delete(4),[4,_o(n)];case 2:return e.sent(),[2]}})})}(this)]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})})}),this.Br=new mo(r,i)};function _o(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n,r;return(0,e.__generator)(this,function(e){switch(e.label){case 0:if(!Do(t))return[3,4];n=0,r=t.Mr,e.label=1;case 1:return n<r.length?[4,(0,r[n])(!0)]:[3,4];case 2:e.sent(),e.label=3;case 3:return n++,[3,1];case 4:return[2]}})})}function wo(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n,r;return(0,e.__generator)(this,function(e){switch(e.label){case 0:n=0,r=t.Mr,e.label=1;case 1:return n<r.length?[4,(0,r[n])(!1)]:[3,4];case 2:e.sent(),e.label=3;case 3:return n++,[3,1];case 4:return[2]}})})}function bo(t,e){var n=m(t);n.$r.has(e.targetId)||(n.$r.set(e.targetId,e),No(n)?So(n):jo(n).er()&&Eo(n,e))}function Io(t,e){var n=m(t),r=jo(n);n.$r.delete(e),r.er()&&To(n,e),0===n.$r.size&&(r.er()?r.ir():Do(n)&&n.Br.set("Unknown"))}function Eo(t,e){t.qr.U(e.targetId),jo(t).mr(e)}function To(t,e){t.qr.U(e),jo(t).yr(e)}function So(t){t.qr=new Ye({getRemoteKeysForTarget:function(e){return t.remoteSyncer.getRemoteKeysForTarget(e)},lt:function(e){return t.$r.get(e)||null}}),jo(t).start(),t.Br.Sr()}function No(t){return Do(t)&&!jo(t).tr()&&t.$r.size>0}function Do(t){return 0===m(t).Or.size}function Ao(t){t.qr=void 0}function xo(t){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(e){return t.$r.forEach(function(e,n){Eo(t,e)}),[2]})})}function ko(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(e){return Ao(t),No(t)?(t.Br.Nr(n),So(t)):t.Br.set("Unknown"),[2]})})}function Co(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i,o,s;return(0,e.__generator)(this,function(a){switch(a.label){case 0:if(t.Br.set("Online"),!(n instanceof We&&2===n.state&&n.cause))return[3,6];a.label=1;case 1:return a.trys.push([1,3,,5]),[4,function(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o,s;return(0,e.__generator)(this,function(e){switch(e.label){case 0:r=n.cause,i=0,o=n.targetIds,e.label=1;case 1:return i<o.length?(s=o[i],t.$r.has(s)?[4,t.remoteSyncer.rejectListen(s,r)]:[3,3]):[3,5];case 2:e.sent(),t.$r.delete(s),t.qr.removeTarget(s),e.label=3;case 3:e.label=4;case 4:return i++,[3,1];case 5:return[2]}})})}(t,n)];case 2:return a.sent(),[3,5];case 3:return i=a.sent(),f("RemoteStore","Failed to remove targets %s: %s ",n.targetIds.join(","),i),[4,Ro(t,i)];case 4:return a.sent(),[3,5];case 5:return[3,13];case 6:if(n instanceof Qe?t.qr.X(n):n instanceof ze?t.qr.rt(n):t.qr.et(n),r.isEqual(T.min()))return[3,13];a.label=7;case 7:return a.trys.push([7,11,,13]),[4,Ti(t.localStore)];case 8:return o=a.sent(),r.compareTo(o)>=0?[4,function(t,e){var n=t.qr.ut(e);return n.targetChanges.forEach(function(n,r){if(n.resumeToken.approximateByteSize()>0){var i=t.$r.get(r);i&&t.$r.set(r,i.withResumeToken(n.resumeToken,e))}}),n.targetMismatches.forEach(function(e){var n=t.$r.get(e);if(n){t.$r.set(e,n.withResumeToken(L.EMPTY_BYTE_STRING,n.snapshotVersion)),To(t,e);var r=new vr(n.target,e,1,n.sequenceNumber);Eo(t,r)}}),t.remoteSyncer.applyRemoteEvent(n)}(t,r)]:[3,10];case 9:a.sent(),a.label=10;case 10:return[3,13];case 11:return f("RemoteStore","Failed to raise snapshot:",s=a.sent()),[4,Ro(t,s)];case 12:return a.sent(),[3,13];case 13:return[2]}})})}function Ro(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i=this;return(0,e.__generator)(this,function(o){switch(o.label){case 0:if(!ar(n))throw n;return t.Or.add(1),[4,wo(t)];case 1:return o.sent(),t.Br.set("Offline"),r||(r=function(){return Ti(t.localStore)}),t.asyncQueue.enqueueRetryable(function(){return(0,e.__awaiter)(i,void 0,void 0,function(){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return f("RemoteStore","Retrying IndexedDB access"),[4,r()];case 1:return e.sent(),t.Or.delete(1),[4,_o(t)];case 2:return e.sent(),[2]}})})}),[2]}})})}function Lo(t,e){return e().catch(function(n){return Ro(t,n,e)})}function Oo(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n,r,i,o,s;return(0,e.__generator)(this,function(e){switch(e.label){case 0:n=m(t),r=Ko(n),i=n.Fr.length>0?n.Fr[n.Fr.length-1].batchId:-1,e.label=1;case 1:if(!function(t){return Do(t)&&t.Fr.length<10}(n))return[3,7];e.label=2;case 2:return e.trys.push([2,4,,6]),[4,Di(n.localStore,i)];case 3:return null===(o=e.sent())?(0===n.Fr.length&&r.ir(),[3,7]):(i=o.batchId,function(t,e){t.Fr.push(e);var n=Ko(t);n.er()&&n.pr&&n.Er(e.mutations)}(n,o),[3,6]);case 4:return s=e.sent(),[4,Ro(n,s)];case 5:return e.sent(),[3,6];case 6:return[3,1];case 7:return Po(n)&&Fo(n),[2]}})})}function Po(t){return Do(t)&&!Ko(t).tr()&&t.Fr.length>0}function Fo(t){Ko(t).start()}function Mo(t){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(e){return Ko(t).Ar(),[2]})})}function Vo(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n,r,i,o;return(0,e.__generator)(this,function(e){for(n=Ko(t),r=0,i=t.Fr;r<i.length;r++)o=i[r],n.Er(o.mutations);return[2]})})}function qo(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i,o;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return i=t.Fr.shift(),o=yr.from(i,n,r),[4,Lo(t,function(){return t.remoteSyncer.applySuccessfulWrite(o)})];case 1:return e.sent(),[4,Oo(t)];case 2:return e.sent(),[2]}})})}function Uo(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(r){switch(r.label){case 0:return n&&Ko(t).pr?[4,function(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return Ne(i=n.code)&&i!==a.ABORTED?(r=t.Fr.shift(),Ko(t).sr(),[4,Lo(t,function(){return t.remoteSyncer.rejectFailedWrite(r.batchId,n)})]):[3,3];case 1:return e.sent(),[4,Oo(t)];case 2:e.sent(),e.label=3;case 3:return[2]}})})}(t,n)]:[3,2];case 1:r.sent(),r.label=2;case 2:return Po(t)&&Fo(t),[2]}})})}function Bo(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return r=m(t),n?(r.Or.delete(2),[4,_o(r)]):[3,2];case 1:return e.sent(),[3,5];case 2:return n?[3,4]:(r.Or.add(2),[4,wo(r)]);case 3:e.sent(),r.Br.set("Unknown"),e.label=4;case 4:e.label=5;case 5:return[2]}})})}function jo(t){var n=this;return t.Ur||(t.Ur=function(t,e,n){var r=m(t);return r.br(),new po(e,r.Hi,r.credentials,r.R,n)}(t.datastore,t.asyncQueue,{Ii:xo.bind(null,t),Ri:ko.bind(null,t),_r:Co.bind(null,t)}),t.Mr.push(function(r){return(0,e.__awaiter)(n,void 0,void 0,function(){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return r?(t.Ur.sr(),No(t)?So(t):t.Br.set("Unknown"),[3,3]):[3,1];case 1:return[4,t.Ur.stop()];case 2:e.sent(),Ao(t),e.label=3;case 3:return[2]}})})})),t.Ur}function Ko(t){var n=this;return t.Kr||(t.Kr=function(t,e,n){var r=m(t);return r.br(),new yo(e,r.Hi,r.credentials,r.R,n)}(t.datastore,t.asyncQueue,{Ii:Mo.bind(null,t),Ri:Uo.bind(null,t),Ir:Vo.bind(null,t),Tr:qo.bind(null,t)}),t.Mr.push(function(r){return(0,e.__awaiter)(n,void 0,void 0,function(){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return r?(t.Kr.sr(),[4,Oo(t)]):[3,2];case 1:return e.sent(),[3,4];case 2:return[4,t.Kr.stop()];case 3:e.sent(),t.Fr.length>0&&(f("RemoteStore","Stopping write stream with "+t.Fr.length+" pending writes"),t.Fr=[]),e.label=4;case 4:return[2]}})})})),t.Kr}var Go=function(){function t(t,e,n,r,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new er,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(function(t){})}return t.createAndSchedule=function(e,n,r,i,o){var s=new t(e,n,Date.now()+r,i,o);return s.start(r),s},t.prototype.start=function(t){var e=this;this.timerHandle=setTimeout(function(){return e.handleDelayElapsed()},t)},t.prototype.skipDelay=function(){return this.handleDelayElapsed()},t.prototype.cancel=function(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new u(a.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},t.prototype.handleDelayElapsed=function(){var t=this;this.asyncQueue.enqueueAndForget(function(){return null!==t.timerHandle?(t.clearTimeout(),t.op().then(function(e){return t.deferred.resolve(e)})):Promise.resolve()})},t.prototype.clearTimeout=function(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)},t}();function Qo(t,e){if(l("AsyncQueue",e+": "+t),ar(t))return new u(a.UNAVAILABLE,e+": "+t);throw t}var zo=function(){function t(t){this.comparator=t?function(e,n){return t(e,n)||G.comparator(e.key,n.key)}:function(t,e){return G.comparator(t.key,e.key)},this.keyedMap=Fe(),this.sortedSet=new Ae(this.comparator)}return t.emptySet=function(e){return new t(e.comparator)},t.prototype.has=function(t){return null!=this.keyedMap.get(t)},t.prototype.get=function(t){return this.keyedMap.get(t)},t.prototype.first=function(){return this.sortedSet.minKey()},t.prototype.last=function(){return this.sortedSet.maxKey()},t.prototype.isEmpty=function(){return this.sortedSet.isEmpty()},t.prototype.indexOf=function(t){var e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1},Object.defineProperty(t.prototype,"size",{get:function(){return this.sortedSet.size},enumerable:!1,configurable:!0}),t.prototype.forEach=function(t){this.sortedSet.inorderTraversal(function(e,n){return t(e),!1})},t.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))},t.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this},t.prototype.isEqual=function(e){if(!(e instanceof t))return!1;if(this.size!==e.size)return!1;for(var n=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(!i.isEqual(o))return!1}return!0},t.prototype.toString=function(){var t=[];return this.forEach(function(e){t.push(e.toString())}),0===t.length?"DocumentSet ()":"DocumentSet (\n "+t.join(" \n")+"\n)"},t.prototype.copy=function(e,n){var r=new t;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=n,r},t}(),Wo=function(){function t(){this.Qr=new Ae(G.comparator)}return t.prototype.track=function(t){var e=t.doc.key,n=this.Qr.get(e);n?0!==t.type&&3===n.type?this.Qr=this.Qr.insert(e,t):3===t.type&&1!==n.type?this.Qr=this.Qr.insert(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.Qr=this.Qr.insert(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.Qr=this.Qr.insert(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.Qr=this.Qr.remove(e):1===t.type&&2===n.type?this.Qr=this.Qr.insert(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.Qr=this.Qr.insert(e,{type:2,doc:t.doc}):y():this.Qr=this.Qr.insert(e,t)},t.prototype.jr=function(){var t=[];return this.Qr.inorderTraversal(function(e,n){t.push(n)}),t},t}(),Ho=function(){function t(t,e,n,r,i,o,s,a){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=s,this.excludesMetadataChanges=a}return t.fromInitialDocuments=function(e,n,r,i){var o=[];return n.forEach(function(t){o.push({type:0,doc:t})}),new t(e,n,zo.emptySet(n),o,r,i,!0,!1)},Object.defineProperty(t.prototype,"hasPendingWrites",{get:function(){return!this.mutatedKeys.isEmpty()},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&qt(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;var e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(e[r].type!==n[r].type||!e[r].doc.isEqual(n[r].doc))return!1;return!0},t}(),Yo=function(){this.Wr=void 0,this.listeners=[]},$o=function(){this.queries=new ni(function(t){return Ut(t)},qt),this.onlineState="Unknown",this.Gr=new Set};function Xo(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a,u,c;return(0,e.__generator)(this,function(e){switch(e.label){case 0:if(r=m(t),i=n.query,o=!1,(s=r.queries.get(i))||(o=!0,s=new Yo),!o)return[3,4];e.label=1;case 1:return e.trys.push([1,3,,4]),a=s,[4,r.onListen(i)];case 2:return a.Wr=e.sent(),[3,4];case 3:return u=e.sent(),c=Qo(u,"Initialization of query '"+Bt(n.query)+"' failed"),[2,void n.onError(c)];case 4:return r.queries.set(i,s),s.listeners.push(n),n.zr(r.onlineState),s.Wr&&n.Hr(s.Wr)&&es(r),[2]}})})}function Jo(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a;return(0,e.__generator)(this,function(e){return r=m(t),i=n.query,o=!1,(s=r.queries.get(i))&&(a=s.listeners.indexOf(n))>=0&&(s.listeners.splice(a,1),o=0===s.listeners.length),o?[2,(r.queries.delete(i),r.onUnlisten(i))]:[2]})})}function Zo(t,e){for(var n=m(t),r=!1,i=0,o=e;i<o.length;i++){var s=o[i],a=s.query,u=n.queries.get(a);if(u){for(var c=0,h=u.listeners;c<h.length;c++)h[c].Hr(s)&&(r=!0);u.Wr=s}}r&&es(n)}function ts(t,e,n){var r=m(t),i=r.queries.get(e);if(i)for(var o=0,s=i.listeners;o<s.length;o++)s[o].onError(n);r.queries.delete(e)}function es(t){t.Gr.forEach(function(t){t.next()})}var ns=function(){function t(t,e,n){this.query=t,this.Jr=e,this.Yr=!1,this.Xr=null,this.onlineState="Unknown",this.options=n||{}}return t.prototype.Hr=function(t){if(!this.options.includeMetadataChanges){for(var e=[],n=0,r=t.docChanges;n<r.length;n++){var i=r[n];3!==i.type&&e.push(i)}t=new Ho(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0)}var o=!1;return this.Yr?this.Zr(t)&&(this.Jr.next(t),o=!0):this.eo(t,this.onlineState)&&(this.no(t),o=!0),this.Xr=t,o},t.prototype.onError=function(t){this.Jr.error(t)},t.prototype.zr=function(t){this.onlineState=t;var e=!1;return this.Xr&&!this.Yr&&this.eo(this.Xr,t)&&(this.no(this.Xr),e=!0),e},t.prototype.eo=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.so&&n||t.docs.isEmpty()&&"Offline"!==e)},t.prototype.Zr=function(t){if(t.docChanges.length>0)return!0;var e=this.Xr&&this.Xr.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges},t.prototype.no=function(t){t=Ho.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.Yr=!0,this.Jr.next(t)},t}(),rs=function(){function t(t,e){this.payload=t,this.byteLength=e}return t.prototype.io=function(){return"metadata"in this.payload},t}(),is=function(){function t(t){this.R=t}return t.prototype.qn=function(t){return cn(this.R,t)},t.prototype.Un=function(t){return t.metadata.exists?yn(this.R,t.document,!1):at.newNoDocument(this.qn(t.metadata.name),this.Kn(t.metadata.readTime))},t.prototype.Kn=function(t){return on(t)},t}(),os=function(){function t(t,e,n){this.ro=t,this.localStore=e,this.R=n,this.queries=[],this.documents=[],this.progress=ss(t)}return t.prototype.oo=function(t){this.progress.bytesLoaded+=t.byteLength;var e=this.progress.documentsLoaded;return t.payload.namedQuery?this.queries.push(t.payload.namedQuery):t.payload.documentMetadata?(this.documents.push({metadata:t.payload.documentMetadata}),t.payload.documentMetadata.exists||++e):t.payload.document&&(this.documents[this.documents.length-1].document=t.payload.document,++e),e!==this.progress.documentsLoaded?(this.progress.documentsLoaded=e,Object.assign({},this.progress)):null},t.prototype.co=function(t){for(var e=new Map,n=new is(this.R),r=0,i=t;r<i.length;r++){var o=i[r];if(o.metadata.queries)for(var s=n.qn(o.metadata.name),a=0,u=o.metadata.queries;a<u.length;a++){var c=u[a],h=(e.get(c)||Ue()).add(s);e.set(c,h)}}return e},t.prototype.complete=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,Oi(this.localStore,new is(this.R),this.documents,this.ro.id)];case 1:t=e.sent(),n=this.co(this.documents),r=0,i=this.queries,e.label=2;case 2:return r<i.length?(o=i[r],[4,Pi(this.localStore,o,n.get(o.name))]):[3,5];case 3:e.sent(),e.label=4;case 4:return r++,[3,2];case 5:return[2,(this.progress.taskState="Success",new vi(Object.assign({},this.progress),t))]}})})},t}();function ss(t){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}var as=function(t){this.key=t},us=function(t){this.key=t},cs=function(){function t(t,e){this.query=t,this.uo=e,this.ao=null,this.current=!1,this.ho=Ue(),this.mutatedKeys=Ue(),this.lo=Kt(t),this.fo=new zo(this.lo)}return Object.defineProperty(t.prototype,"wo",{get:function(){return this.uo},enumerable:!1,configurable:!0}),t.prototype._o=function(t,e){var n=this,r=e?e.mo:new Wo,i=e?e.fo:this.fo,o=e?e.mutatedKeys:this.mutatedKeys,s=i,a=!1,u=Ct(this.query)&&i.size===this.query.limit?i.last():null,c=Rt(this.query)&&i.size===this.query.limit?i.first():null;if(t.inorderTraversal(function(t,e){var h=i.get(t),f=jt(n.query,e)?e:null,l=!!h&&n.mutatedKeys.has(h.key),d=!!f&&(f.hasLocalMutations||n.mutatedKeys.has(f.key)&&f.hasCommittedMutations),p=!1;h&&f?h.data.isEqual(f.data)?l!==d&&(r.track({type:3,doc:f}),p=!0):n.yo(h,f)||(r.track({type:2,doc:f}),p=!0,(u&&n.lo(f,u)>0||c&&n.lo(f,c)<0)&&(a=!0)):!h&&f?(r.track({type:0,doc:f}),p=!0):h&&!f&&(r.track({type:1,doc:h}),p=!0,(u||c)&&(a=!0)),p&&(f?(s=s.add(f),o=d?o.add(t):o.delete(t)):(s=s.delete(t),o=o.delete(t)))}),Ct(this.query)||Rt(this.query))for(;s.size>this.query.limit;){var h=Ct(this.query)?s.last():s.first();s=s.delete(h.key),o=o.delete(h.key),r.track({type:1,doc:h})}return{fo:s,mo:r,Nn:a,mutatedKeys:o}},t.prototype.yo=function(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations},t.prototype.applyChanges=function(t,e,n){var r=this,i=this.fo;this.fo=t.fo,this.mutatedKeys=t.mutatedKeys;var o=t.mo.jr();o.sort(function(t,e){return function(t,e){var n=function(t){switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return y()}};return n(t)-n(e)}(t.type,e.type)||r.lo(t.doc,e.doc)}),this.po(n);var s=e?this.Eo():[],a=0===this.ho.size&&this.current?1:0,u=a!==this.ao;return this.ao=a,0!==o.length||u?{snapshot:new Ho(this.query,t.fo,i,o,t.mutatedKeys,0===a,u,!1),To:s}:{To:s}},t.prototype.zr=function(t){return this.current&&"Offline"===t?(this.current=!1,this.applyChanges({fo:this.fo,mo:new Wo,mutatedKeys:this.mutatedKeys,Nn:!1},!1)):{To:[]}},t.prototype.Io=function(t){return!this.uo.has(t)&&!!this.fo.has(t)&&!this.fo.get(t).hasLocalMutations},t.prototype.po=function(t){var e=this;t&&(t.addedDocuments.forEach(function(t){return e.uo=e.uo.add(t)}),t.modifiedDocuments.forEach(function(t){}),t.removedDocuments.forEach(function(t){return e.uo=e.uo.delete(t)}),this.current=t.current)},t.prototype.Eo=function(){var t=this;if(!this.current)return[];var e=this.ho;this.ho=Ue(),this.fo.forEach(function(e){t.Io(e.key)&&(t.ho=t.ho.add(e.key))});var n=[];return e.forEach(function(e){t.ho.has(e)||n.push(new us(e))}),this.ho.forEach(function(t){e.has(t)||n.push(new as(t))}),n},t.prototype.Ao=function(t){this.uo=t.Bn,this.ho=Ue();var e=this._o(t.documents);return this.applyChanges(e,!0)},t.prototype.Ro=function(){return Ho.fromInitialDocuments(this.query,this.fo,this.mutatedKeys,0===this.ao)},t}(),hs=function(t,e,n){this.query=t,this.targetId=e,this.view=n},fs=function(t){this.key=t,this.bo=!1},ls=function(){function t(t,e,n,r,i,o){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=o,this.vo={},this.Po=new ni(function(t){return Ut(t)},qt),this.Vo=new Map,this.So=new Set,this.Do=new Ae(G.comparator),this.Co=new Map,this.No=new Mi,this.xo={},this.ko=new Map,this.Fo=Gr.Yt(),this.onlineState="Unknown",this.$o=void 0}return Object.defineProperty(t.prototype,"isPrimaryClient",{get:function(){return!0===this.$o},enumerable:!1,configurable:!0}),t}();function ds(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a,u;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return r=js(t),(s=r.Po.get(n))?(i=s.targetId,r.sharedClientState.addLocalQueryTarget(i),o=s.view.Ro(),[3,4]):[3,1];case 1:return[4,Ai(r.localStore,Mt(n))];case 2:return a=e.sent(),u=r.sharedClientState.addLocalQueryTarget(a.targetId),i=a.targetId,[4,ps(r,n,i,"current"===u)];case 3:o=e.sent(),r.isPrimaryClient&&bo(r.remoteStore,a),e.label=4;case 4:return[2,o]}})})}function ps(t,n,r,i){return(0,e.__awaiter)(this,void 0,void 0,function(){var o,s,a,u,c,h;return(0,e.__generator)(this,function(f){switch(f.label){case 0:return t.Oo=function(n,r,i){return function(t,n,r,i){return(0,e.__awaiter)(this,void 0,void 0,function(){var o,s,a;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return(o=n.view._o(r)).Nn?[4,ki(t.localStore,n.query,!1).then(function(t){var e=t.documents;return n.view._o(e,o)})]:[3,2];case 1:o=e.sent(),e.label=2;case 2:return s=i&&i.targetChanges.get(n.targetId),a=n.view.applyChanges(o,t.isPrimaryClient,s),[2,(Ds(t,n.targetId,a.To),a.snapshot)]}})})}(t,n,r,i)},[4,ki(t.localStore,n,!0)];case 1:return o=f.sent(),s=new cs(n,o.Bn),a=s._o(o.documents),u=Ge.createSynthesizedTargetChangeForCurrentChange(r,i&&"Offline"!==t.onlineState),c=s.applyChanges(a,t.isPrimaryClient,u),Ds(t,r,c.To),h=new hs(n,r,s),[2,(t.Po.set(n,h),t.Vo.has(r)?t.Vo.get(r).push(n):t.Vo.set(r,[n]),c.snapshot)]}})})}function ys(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return r=m(t),i=r.Po.get(n),(o=r.Vo.get(i.targetId)).length>1?[2,(r.Vo.set(i.targetId,o.filter(function(t){return!qt(t,n)})),void r.Po.delete(n))]:r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)?[3,2]:[4,xi(r.localStore,i.targetId,!1).then(function(){r.sharedClientState.clearQueryState(i.targetId),Io(r.remoteStore,i.targetId),Ss(r,i.targetId)}).catch(Yr)]):[3,3];case 1:e.sent(),e.label=2;case 2:return[3,5];case 3:return Ss(r,i.targetId),[4,xi(r.localStore,i.targetId,!0)];case 4:e.sent(),e.label=5;case 5:return[2]}})})}function vs(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i,o,s,a;return(0,e.__generator)(this,function(e){switch(e.label){case 0:i=Ks(t),e.label=1;case 1:return e.trys.push([1,5,,6]),[4,function(t,e){var n,r=m(t),i=E.now(),o=e.reduce(function(t,e){return t.add(e.key)},Ue());return r.persistence.runTransaction("Locally write mutations","readwrite",function(t){return r.Mn.pn(t,o).next(function(o){n=o;for(var s=[],a=0,u=e;a<u.length;a++){var c=u[a],h=de(c,n.get(c.key));null!=h&&s.push(new me(c.key,h,st(h.value.mapValue),ue.exists(!0)))}return r._n.addMutationBatch(t,i,s,e)})}).then(function(t){return t.applyToLocalDocumentSet(n),{batchId:t.batchId,changes:n}})}(i.localStore,n)];case 2:return o=e.sent(),i.sharedClientState.addPendingMutation(o.batchId),function(t,e,n){var r=t.xo[t.currentUser.toKey()];r||(r=new Ae(w)),r=r.insert(e,n),t.xo[t.currentUser.toKey()]=r}(i,o.batchId,r),[4,ks(i,o.changes)];case 3:return e.sent(),[4,Oo(i.remoteStore)];case 4:return e.sent(),[3,6];case 5:return s=e.sent(),a=Qo(s,"Failed to persist write"),r.reject(a),[3,6];case 6:return[2]}})})}function ms(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i;return(0,e.__generator)(this,function(e){switch(e.label){case 0:r=m(t),e.label=1;case 1:return e.trys.push([1,4,,6]),[4,Si(r.localStore,n)];case 2:return i=e.sent(),n.targetChanges.forEach(function(t,e){var n=r.Co.get(e);n&&(v(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1),t.addedDocuments.size>0?n.bo=!0:t.modifiedDocuments.size>0?v(n.bo):t.removedDocuments.size>0&&(v(n.bo),n.bo=!1))}),[4,ks(r,i,n)];case 3:return e.sent(),[3,6];case 4:return[4,Yr(e.sent())];case 5:return e.sent(),[3,6];case 6:return[2]}})})}function gs(t,e,n){var r=m(t);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){var i=[];r.Po.forEach(function(t,n){var r=n.view.zr(e);r.snapshot&&i.push(r.snapshot)}),function(t,e){var n=m(t);n.onlineState=e;var r=!1;n.queries.forEach(function(t,n){for(var i=0,o=n.listeners;i<o.length;i++)o[i].zr(e)&&(r=!0)}),r&&es(n)}(r.eventManager,e),i.length&&r.vo._r(i),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}function _s(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i,o,s,a,u,c;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return(i=m(t)).sharedClientState.updateQueryState(n,"rejected",r),o=i.Co.get(n),(s=o&&o.key)?(a=(a=new Ae(G.comparator)).insert(s,at.newNoDocument(s,T.min())),u=Ue().add(s),c=new Ke(T.min(),new Map,new Ce(w),a,u),[4,ms(i,c)]):[3,2];case 1:return e.sent(),i.Do=i.Do.remove(s),i.Co.delete(n),xs(i),[3,4];case 2:return[4,xi(i.localStore,n,!1).then(function(){return Ss(i,n,r)}).catch(Yr)];case 3:e.sent(),e.label=4;case 4:return[2]}})})}function ws(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o;return(0,e.__generator)(this,function(e){switch(e.label){case 0:r=m(t),i=n.batch.batchId,e.label=1;case 1:return e.trys.push([1,4,,6]),[4,Ei(r.localStore,n)];case 2:return o=e.sent(),Ts(r,i,null),Es(r,i),r.sharedClientState.updateMutationState(i,"acknowledged"),[4,ks(r,o)];case 3:return e.sent(),[3,6];case 4:return[4,Yr(e.sent())];case 5:return e.sent(),[3,6];case 6:return[2]}})})}function bs(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i,o;return(0,e.__generator)(this,function(e){switch(e.label){case 0:i=m(t),e.label=1;case 1:return e.trys.push([1,4,,6]),[4,function(t,e){var n=m(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",function(t){var r;return n._n.lookupMutationBatch(t,e).next(function(e){return v(null!==e),r=e.keys(),n._n.removeMutationBatch(t,e)}).next(function(){return n._n.performConsistencyCheck(t)}).next(function(){return n.Mn.pn(t,r)})})}(i.localStore,n)];case 2:return o=e.sent(),Ts(i,n,r),Es(i,n),i.sharedClientState.updateMutationState(n,"rejected",r),[4,ks(i,o)];case 3:return e.sent(),[3,6];case 4:return[4,Yr(e.sent())];case 5:return e.sent(),[3,6];case 6:return[2]}})})}function Is(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a;return(0,e.__generator)(this,function(e){switch(e.label){case 0:Do((r=m(t)).remoteStore)||f("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,function(t){var e=m(r.localStore);return e.persistence.runTransaction("Get highest unacknowledged batch id","readonly",function(t){return e._n.getHighestUnacknowledgedBatchId(t)})}()];case 2:return-1===(i=e.sent())?[2,void n.resolve()]:((o=r.ko.get(i)||[]).push(n),r.ko.set(i,o),[3,4]);case 3:return s=e.sent(),a=Qo(s,"Initialization of waitForPendingWrites() operation failed"),n.reject(a),[3,4];case 4:return[2]}})})}function Es(t,e){(t.ko.get(e)||[]).forEach(function(t){t.resolve()}),t.ko.delete(e)}function Ts(t,e,n){var r=m(t),i=r.xo[r.currentUser.toKey()];if(i){var o=i.get(e);o&&(n?o.reject(n):o.resolve(),i=i.remove(e)),r.xo[r.currentUser.toKey()]=i}}function Ss(t,e,n){void 0===n&&(n=null),t.sharedClientState.removeLocalQueryTarget(e);for(var r=0,i=t.Vo.get(e);r<i.length;r++){var o=i[r];t.Po.delete(o),n&&t.vo.Mo(o,n)}t.Vo.delete(e),t.isPrimaryClient&&t.No.Zn(e).forEach(function(e){t.No.containsKey(e)||Ns(t,e)})}function Ns(t,e){t.So.delete(e.path.canonicalString());var n=t.Do.get(e);null!==n&&(Io(t.remoteStore,n),t.Do=t.Do.remove(e),t.Co.delete(n),xs(t))}function Ds(t,e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r];o instanceof as?(t.No.addReference(o.key,e),As(t,o)):o instanceof us?(f("SyncEngine","Document no longer in limbo: "+o.key),t.No.removeReference(o.key,e),t.No.containsKey(o.key)||Ns(t,o.key)):y()}}function As(t,e){var n=e.key,r=n.path.canonicalString();t.Do.get(n)||t.So.has(r)||(f("SyncEngine","New document in limbo: "+n),t.So.add(r),xs(t))}function xs(t){for(;t.So.size>0&&t.Do.size<t.maxConcurrentLimboResolutions;){var e=t.So.values().next().value;t.So.delete(e);var n=new G(x.fromString(e)),r=t.Fo.next();t.Co.set(r,new fs(n)),t.Do=t.Do.insert(n,r),bo(t.remoteStore,new vr(Mt(kt(n.path)),r,2,s.o))}}function ks(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i,o,s,a;return(0,e.__generator)(this,function(u){switch(u.label){case 0:return i=m(t),o=[],s=[],a=[],i.Po.isEmpty()?[3,3]:(i.Po.forEach(function(t,e){a.push(i.Oo(e,n,r).then(function(t){if(t){i.isPrimaryClient&&i.sharedClientState.updateQueryState(e.targetId,t.fromCache?"not-current":"current"),o.push(t);var n=gi.Pn(e.targetId,t);s.push(n)}}))}),[4,Promise.all(a)]);case 1:return u.sent(),i.vo._r(o),[4,function(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a,u,c,h,l;return(0,e.__generator)(this,function(e){switch(e.label){case 0:r=m(t),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.persistence.runTransaction("notifyLocalViewChanges","readwrite",function(t){return nr.forEach(n,function(e){return nr.forEach(e.bn,function(n){return r.persistence.referenceDelegate.addReference(t,e.targetId,n)}).next(function(){return nr.forEach(e.vn,function(n){return r.persistence.referenceDelegate.removeReference(t,e.targetId,n)})})})})];case 2:return e.sent(),[3,4];case 3:if(!ar(i=e.sent()))throw i;return f("LocalStore","Failed to update sequence numbers: "+i),[3,4];case 4:for(o=0,s=n;o<s.length;o++)a=s[o],u=a.targetId,a.fromCache||(c=r.kn.get(u),h=c.snapshotVersion,l=c.withLastLimboFreeSnapshotVersion(h),r.kn=r.kn.insert(u,l));return[2]}})})}(i.localStore,s)];case 2:u.sent(),u.label=3;case 3:return[2]}})})}function Cs(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return(r=m(t)).currentUser.isEqual(n)?[3,3]:(f("SyncEngine","User change. New user:",n.toKey()),[4,Ii(r.localStore,n)]);case 1:return i=e.sent(),r.currentUser=n,function(t,e){t.ko.forEach(function(t){t.forEach(function(t){t.reject(new u(a.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),t.ko.clear()}(r),r.sharedClientState.handleUserChange(n,i.removedBatchIds,i.addedBatchIds),[4,ks(r,i.Ln)];case 2:e.sent(),e.label=3;case 3:return[2]}})})}function Rs(t,e){var n=m(t),r=n.Co.get(e);if(r&&r.bo)return Ue().add(r.key);var i=Ue(),o=n.Vo.get(e);if(!o)return i;for(var s=0,a=o;s<a.length;s++){var u=a[s],c=n.Po.get(u);i=i.unionWith(c.view.wo)}return i}function Ls(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,ki((r=m(t)).localStore,n.query,!0)];case 1:return i=e.sent(),o=n.view.Ao(i),[2,(r.isPrimaryClient&&Ds(r,n.targetId,o.To),o)]}})})}function Os(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){return[2,Ri((n=m(t)).localStore).then(function(t){return ks(n,t)})]})})}function Ps(t,n,r,i){return(0,e.__awaiter)(this,void 0,void 0,function(){var o,s;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,function(t,e){var n=m(t),r=m(n._n);return n.persistence.runTransaction("Lookup mutation documents","readonly",function(t){return r.jt(t,e).next(function(e){return e?n.Mn.pn(t,e):nr.resolve(null)})})}((o=m(t)).localStore,n)];case 1:return null===(s=e.sent())?[3,6]:"pending"!==r?[3,3]:[4,Oo(o.remoteStore)];case 2:return e.sent(),[3,4];case 3:"acknowledged"===r||"rejected"===r?(Ts(o,n,i||null),Es(o,n),function(t,e){m(m(t)._n).Gt(e)}(o.localStore,n)):y(),e.label=4;case 4:return[4,ks(o,s)];case 5:return e.sent(),[3,7];case 6:f("SyncEngine","Cannot apply mutation batch with id: "+n),e.label=7;case 7:return[2]}})})}function Fs(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a,u,c,h;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return js(r=m(t)),Ks(r),!0!==n||!0===r.$o?[3,3]:(i=r.sharedClientState.getAllActiveQueryTargets(),[4,Ms(r,i.toArray())]);case 1:return o=e.sent(),r.$o=!0,[4,Bo(r.remoteStore,!0)];case 2:for(e.sent(),s=0,a=o;s<a.length;s++)u=a[s],bo(r.remoteStore,u);return[3,7];case 3:return!1!==n||!1===r.$o?[3,7]:(c=[],h=Promise.resolve(),r.Vo.forEach(function(t,e){r.sharedClientState.isLocalQueryTarget(e)?c.push(e):h=h.then(function(){return Ss(r,e),xi(r.localStore,e,!0)}),Io(r.remoteStore,e)}),[4,h]);case 4:return e.sent(),[4,Ms(r,c)];case 5:return e.sent(),function(t){var e=m(r);e.Co.forEach(function(t,n){Io(e.remoteStore,n)}),e.No.ts(),e.Co=new Map,e.Do=new Ae(G.comparator)}(),r.$o=!1,[4,Bo(r.remoteStore,!1)];case 6:e.sent(),e.label=7;case 7:return[2]}})})}function Ms(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a,u,c,h,f,l,d,p,y,v;return(0,e.__generator)(this,function(e){switch(e.label){case 0:r=m(t),i=[],o=[],s=0,a=n,e.label=1;case 1:return s<a.length?(u=a[s],c=void 0,(h=r.Vo.get(u))&&0!==h.length?[4,Ai(r.localStore,Mt(h[0]))]:[3,7]):[3,13];case 2:c=e.sent(),f=0,l=h,e.label=3;case 3:return f<l.length?(d=l[f],p=r.Po.get(d),[4,Ls(r,p)]):[3,6];case 4:(y=e.sent()).snapshot&&o.push(y.snapshot),e.label=5;case 5:return f++,[3,3];case 6:return[3,11];case 7:return[4,Ci(r.localStore,u)];case 8:return v=e.sent(),[4,Ai(r.localStore,v)];case 9:return c=e.sent(),[4,ps(r,Vs(v),u,!1)];case 10:e.sent(),e.label=11;case 11:i.push(c),e.label=12;case 12:return s++,[3,1];case 13:return[2,(r.vo._r(o),i)]}})})}function Vs(t){return xt(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)}function qs(t){var e=m(t);return m(m(e.localStore).persistence).fn()}function Us(t,n,r,i){return(0,e.__awaiter)(this,void 0,void 0,function(){var o,s,a;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return(o=m(t)).$o?(f("SyncEngine","Ignoring unexpected query state notification."),[3,8]):[3,1];case 1:if(!o.Vo.has(n))return[3,8];switch(r){case"current":case"not-current":return[3,2];case"rejected":return[3,5]}return[3,7];case 2:return[4,Ri(o.localStore)];case 3:return s=e.sent(),a=Ke.createSynthesizedRemoteEventForCurrentChange(n,"current"===r),[4,ks(o,s,a)];case 4:return e.sent(),[3,8];case 5:return[4,xi(o.localStore,n,!0)];case 6:return e.sent(),Ss(o,n,i),[3,8];case 7:y(),e.label=8;case 8:return[2]}})})}function Bs(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i,o,s,a,u,c,h,l,d,p;return(0,e.__generator)(this,function(y){switch(y.label){case 0:if(!(i=js(t)).$o)return[3,10];o=0,s=n,y.label=1;case 1:return o<s.length?(a=s[o],i.Vo.has(a)?(f("SyncEngine","Adding an already active target "+a),[3,5]):[4,Ci(i.localStore,a)]):[3,6];case 2:return u=y.sent(),[4,Ai(i.localStore,u)];case 3:return c=y.sent(),[4,ps(i,Vs(u),c.targetId,!1)];case 4:y.sent(),bo(i.remoteStore,c),y.label=5;case 5:return o++,[3,1];case 6:h=function(t){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return i.Vo.has(t)?[4,xi(i.localStore,t,!1).then(function(){Io(i.remoteStore,t),Ss(i,t)}).catch(Yr)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})},l=0,d=r,y.label=7;case 7:return l<d.length?(p=d[l],[5,h(p)]):[3,10];case 8:y.sent(),y.label=9;case 9:return l++,[3,7];case 10:return[2]}})})}function js(t){var e=m(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=ms.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Rs.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=_s.bind(null,e),e.vo._r=Zo.bind(null,e.eventManager),e.vo.Mo=ts.bind(null,e.eventManager),e}function Ks(t){var e=m(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=ws.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=bs.bind(null,e),e}function Gs(t,n,r){var i=m(t);(function(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i,o,s,a,u,c;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return e.trys.push([0,14,,15]),[4,n.getMetadata()];case 1:return i=e.sent(),[4,function(t,e){var n=m(t),r=on(e.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",function(t){return n.Ke.getBundleMetadata(t,e.id)}).then(function(t){return!!t&&t.createTime.compareTo(r)>=0})}(t.localStore,i)];case 2:return e.sent()?[4,n.close()]:[3,4];case 3:return[2,(e.sent(),void r._completeWith(function(t){return{taskState:"Success",documentsLoaded:t.totalDocuments,bytesLoaded:t.totalBytes,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}(i)))];case 4:return r._updateProgress(ss(i)),o=new os(i,t.localStore,n.R),[4,n.Lo()];case 5:s=e.sent(),e.label=6;case 6:return s?[4,o.oo(s)]:[3,10];case 7:return(a=e.sent())&&r._updateProgress(a),[4,n.Lo()];case 8:s=e.sent(),e.label=9;case 9:return[3,6];case 10:return[4,o.complete()];case 11:return u=e.sent(),[4,ks(t,u.wn,void 0)];case 12:return e.sent(),[4,function(t,e){var n=m(t);return n.persistence.runTransaction("Save bundle","readwrite",function(t){return n.Ke.saveBundleMetadata(t,e)})}(t.localStore,i)];case 13:return e.sent(),r._completeWith(u.progress),[3,15];case 14:return d("SyncEngine","Loading bundle failed with "+(c=e.sent())),r._failWith(c),[3,15];case 15:return[2]}})})})(i,n,r).then(function(){i.sharedClientState.notifyBundleLoaded()})}var Qs=function(){function t(){this.synchronizeTabs=!1}return t.prototype.initialize=function(t){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return this.R=ho(t.databaseInfo.databaseId),this.sharedClientState=this.Bo(t),this.persistence=this.qo(t),[4,this.persistence.start()];case 1:return e.sent(),this.gcScheduler=this.Uo(t),this.localStore=this.Ko(t),[2]}})})},t.prototype.Uo=function(t){return null},t.prototype.Ko=function(t){return bi(this.persistence,new _i,t.initialUser,this.R)},t.prototype.qo=function(t){return new Ki(Qi.bs,this.R)},t.prototype.Bo=function(t){return new no},t.prototype.terminate=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(t){switch(t.label){case 0:return this.gcScheduler&&this.gcScheduler.stop(),[4,this.sharedClientState.shutdown()];case 1:return t.sent(),[4,this.persistence.shutdown()];case 2:return t.sent(),[2]}})})},t}(),zs=function(t){function n(e,n,r){var i=this;return(i=t.call(this)||this).Qo=e,i.cacheSizeBytes=n,i.forceOwnership=r,i.synchronizeTabs=!1,i}return(0,e.__extends)(n,t),n.prototype.initialize=function(n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r=this;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,t.prototype.initialize.call(this,n)];case 1:return e.sent(),[4,Li(this.localStore)];case 2:return e.sent(),[4,this.Qo.initialize(this,n)];case 3:return e.sent(),[4,Ks(this.Qo.syncEngine)];case 4:return e.sent(),[4,Oo(this.Qo.remoteStore)];case 5:return e.sent(),[4,this.persistence.He(function(){return r.gcScheduler&&!r.gcScheduler.started&&r.gcScheduler.start(r.localStore),Promise.resolve()})];case 6:return e.sent(),[2]}})})},n.prototype.Ko=function(t){return bi(this.persistence,new _i,t.initialUser,this.R)},n.prototype.Uo=function(t){var e=this.persistence.referenceDelegate.garbageCollector;return new Jr(e,t.asyncQueue)},n.prototype.qo=function(t){var e=yi(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?Fr.withCacheSize(this.cacheSizeBytes):Fr.DEFAULT;return new li(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,uo(),co(),this.R,this.sharedClientState,!!this.forceOwnership)},n.prototype.Bo=function(t){return new no},n}(Qs),Ws=function(t){function n(e,n){var r=this;return(r=t.call(this,e,n,!1)||this).Qo=e,r.cacheSizeBytes=n,r.synchronizeTabs=!0,r}return(0,e.__extends)(n,t),n.prototype.initialize=function(n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i=this;return(0,e.__generator)(this,function(o){switch(o.label){case 0:return[4,t.prototype.initialize.call(this,n)];case 1:return o.sent(),r=this.Qo.syncEngine,this.sharedClientState instanceof eo?(this.sharedClientState.syncEngine={ui:Ps.bind(null,r),ai:Us.bind(null,r),hi:Bs.bind(null,r),fn:qs.bind(null,r),ci:Os.bind(null,r)},[4,this.sharedClientState.start()]):[3,3];case 2:o.sent(),o.label=3;case 3:return[4,this.persistence.He(function(t){return(0,e.__awaiter)(i,void 0,void 0,function(){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,Fs(this.Qo.syncEngine,t)];case 1:return e.sent(),this.gcScheduler&&(t&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):t||this.gcScheduler.stop()),[2]}})})})];case 4:return o.sent(),[2]}})})},n.prototype.Bo=function(t){var e=uo();if(!eo.yt(e))throw new u(a.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=yi(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new eo(e,t.asyncQueue,n,t.clientId,t.initialUser)},n}(zs),Hs=function(){function t(){}return t.prototype.initialize=function(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r=this;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return this.localStore?[3,2]:(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(n),this.remoteStore=this.createRemoteStore(n),this.eventManager=this.createEventManager(n),this.syncEngine=this.createSyncEngine(n,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=function(t){return gs(r.syncEngine,t,1)},this.remoteStore.remoteSyncer.handleCredentialChange=Cs.bind(null,this.syncEngine),[4,Bo(this.remoteStore,this.syncEngine.isPrimaryClient)]);case 1:e.sent(),e.label=2;case 2:return[2]}})})},t.prototype.createEventManager=function(t){return new $o},t.prototype.createDatastore=function(t){var e,n=ho(t.databaseInfo.databaseId),r=(e=t.databaseInfo,new ao(e));return function(t,e,n){return new vo(t,r,n)}(t.credentials,0,n)},t.prototype.createRemoteStore=function(t){var e,n,r,i,o,s=this;return e=this.localStore,n=this.datastore,r=t.asyncQueue,i=function(t){return gs(s.syncEngine,t,0)},o=io.yt()?new io:new ro,new go(e,n,r,i,o)},t.prototype.createSyncEngine=function(t,e){return function(t,e,n,r,i,o,s){var a=new ls(t,e,n,r,i,o);return s&&(a.$o=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)},t.prototype.terminate=function(){return function(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return n=m(t),f("RemoteStore","RemoteStore shutting down."),n.Or.add(5),[4,wo(n)];case 1:return e.sent(),n.Lr.shutdown(),n.Br.set("Unknown"),[2]}})})}(this.remoteStore)},t}();function Ys(t,n){void 0===n&&(n=10240);var r=0;return{read:function(){return(0,e.__awaiter)(this,void 0,void 0,function(){var i;return(0,e.__generator)(this,function(e){return r<t.byteLength?(i={value:t.slice(r,r+n),done:!1},[2,(r+=n,i)]):[2,{done:!0}]})})},cancel:function(){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(t){return[2]})})},releaseLock:function(){},closed:Promise.reject("unimplemented")}}var $s=function(){function t(t){this.observer=t,this.muted=!1}return t.prototype.next=function(t){this.observer.next&&this.jo(this.observer.next,t)},t.prototype.error=function(t){this.observer.error?this.jo(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)},t.prototype.Wo=function(){this.muted=!0},t.prototype.jo=function(t,e){var n=this;this.muted||setTimeout(function(){n.muted||t(e)},0)},t}(),Xs=function(){function t(t,e){var n=this;this.Go=t,this.R=e,this.metadata=new er,this.buffer=new Uint8Array,this.zo=new TextDecoder("utf-8"),this.Ho().then(function(t){t&&t.io()?n.metadata.resolve(t.payload.metadata):n.metadata.reject(new Error("The first element of the bundle is not a metadata, it is\n "+JSON.stringify(null==t?void 0:t.payload)))},function(t){return n.metadata.reject(t)})}return t.prototype.close=function(){return this.Go.cancel()},t.prototype.getMetadata=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(t){return[2,this.metadata.promise]})})},t.prototype.Lo=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(t){switch(t.label){case 0:return[4,this.getMetadata()];case 1:return[2,(t.sent(),this.Ho())]}})})},t.prototype.Ho=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){var t,n,r,i;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,this.Jo()];case 1:return null===(t=e.sent())?[2,null]:(n=this.zo.decode(t),r=Number(n),isNaN(r)&&this.Yo("length string ("+n+") is not valid number"),[4,this.Xo(r)]);case 2:return i=e.sent(),[2,new rs(JSON.parse(i),t.length+r)]}})})},t.prototype.Zo=function(){return this.buffer.findIndex(function(t){return t==="{".charCodeAt(0)})},t.prototype.Jo=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){var t,n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return this.Zo()<0?[4,this.tc()]:[3,3];case 1:if(e.sent())return[3,3];e.label=2;case 2:return[3,0];case 3:return 0===this.buffer.length?[2,null]:((t=this.Zo())<0&&this.Yo("Reached the end of bundle when a length string is expected."),n=this.buffer.slice(0,t),[2,(this.buffer=this.buffer.slice(t),n)])}})})},t.prototype.Xo=function(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return this.buffer.length<t?[4,this.tc()]:[3,3];case 1:e.sent()&&this.Yo("Reached the end of bundle when more is expected."),e.label=2;case 2:return[3,0];case 3:return n=this.zo.decode(this.buffer.slice(0,t)),[2,(this.buffer=this.buffer.slice(t),n)]}})})},t.prototype.Yo=function(t){throw this.Go.cancel(),new Error("Invalid bundle format: "+t)},t.prototype.tc=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){var t,n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,this.Go.read()];case 1:return(t=e.sent()).done||((n=new Uint8Array(this.buffer.length+t.value.length)).set(this.buffer),n.set(t.value,this.buffer.length),this.buffer=n),[2,t.done]}})})},t}(),Js=function(){function t(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}return t.prototype.lookup=function(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n,r=this;return(0,e.__generator)(this,function(i){switch(i.label){case 0:if(this.ensureCommitNotCalled(),this.mutations.length>0)throw new u(a.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,function(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a,u;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return r=m(t),i=ln(r.R)+"/documents",o={documents:n.map(function(t){return un(r.R,t)})},[4,r.$i("BatchGetDocuments",i,o)];case 1:return s=e.sent(),a=new Map,s.forEach(function(t){var e=function(t,e){return"found"in e?function(t,e){v(!!e.found),e.found.name,e.found.updateTime;var n=cn(t,e.found.name),r=on(e.found.updateTime),i=new ot({mapValue:{fields:e.found.fields}});return at.newFoundDocument(n,r,i)}(t,e):"missing"in e?function(t,e){v(!!e.missing),v(!!e.readTime);var n=cn(t,e.missing),r=on(e.readTime);return at.newNoDocument(n,r)}(t,e):y()}(r.R,t);a.set(e.key.toString(),e)}),u=[],[2,(n.forEach(function(t){var e=a.get(t.toString());v(!!e),u.push(e)}),u)]}})})}(this.datastore,t)];case 1:return[2,((n=i.sent()).forEach(function(t){return r.recordVersion(t)}),n)]}})})},t.prototype.set=function(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())},t.prototype.update=function(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t.toString())},t.prototype.delete=function(t){this.write(new Ee(t,this.precondition(t))),this.writtenDocs.add(t.toString())},t.prototype.commit=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){var t,n=this;return(0,e.__generator)(this,function(r){switch(r.label){case 0:if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;return t=this.readVersions,this.mutations.forEach(function(e){t.delete(e.key.toString())}),t.forEach(function(t,e){var r=G.fromPath(e);n.mutations.push(new Te(r,n.precondition(r)))}),[4,function(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return r=m(t),i=ln(r.R)+"/documents",o={writes:n.map(function(t){return vn(r.R,t)})},[4,r.Ni("Commit",i,o)];case 1:return e.sent(),[2]}})})}(this.datastore,this.mutations)];case 1:return r.sent(),this.committed=!0,[2]}})})},t.prototype.recordVersion=function(t){var e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw y();e=T.min()}var n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new u(a.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)},t.prototype.precondition=function(t){var e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?ue.updateTime(e):ue.none()},t.prototype.preconditionForUpdate=function(t){var e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(T.min()))throw new u(a.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return ue.updateTime(e)}return ue.exists(!0)},t.prototype.write=function(t){this.ensureCommitNotCalled(),this.mutations.push(t)},t.prototype.ensureCommitNotCalled=function(){},t}(),Zs=function(){function t(t,e,n,r){this.asyncQueue=t,this.datastore=e,this.updateFunction=n,this.deferred=r,this.ec=5,this.Zi=new fo(this.asyncQueue,"transaction_retry")}return t.prototype.run=function(){this.ec-=1,this.nc()},t.prototype.nc=function(){var t=this;this.Zi.ji(function(){return(0,e.__awaiter)(t,void 0,void 0,function(){var t,n,r=this;return(0,e.__generator)(this,function(e){return t=new Js(this.datastore),(n=this.sc(t))&&n.then(function(e){r.asyncQueue.enqueueAndForget(function(){return t.commit().then(function(){r.deferred.resolve(e)}).catch(function(t){r.ic(t)})})}).catch(function(t){r.ic(t)}),[2]})})})},t.prototype.sc=function(t){try{var e=this.updateFunction(t);return!B(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}},t.prototype.ic=function(t){var e=this;this.ec>0&&this.rc(t)?(this.ec-=1,this.asyncQueue.enqueueAndForget(function(){return e.nc(),Promise.resolve()})):this.deferred.reject(t)},t.prototype.rc=function(t){if("FirebaseError"===t.name){var e=t.code;return"aborted"===e||"failed-precondition"===e||!Ne(e)}return!1},t}(),ta=function(){function t(t,n,r){var i=this;this.credentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=zi.UNAUTHENTICATED,this.clientId=_.u(),this.credentialListener=function(){return Promise.resolve()},this.credentials.setChangeListener(n,function(t){return(0,e.__awaiter)(i,void 0,void 0,function(){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return f("FirestoreClient","Received user=",t.uid),[4,this.credentialListener(t)];case 1:return e.sent(),this.user=t,[2]}})})})}return t.prototype.getConfiguration=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(t){return[2,{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,credentials:this.credentials,initialUser:this.user,maxConcurrentLimboResolutions:100}]})})},t.prototype.setCredentialChangeListener=function(t){this.credentialListener=t},t.prototype.verifyNotTerminated=function(){if(this.asyncQueue.isShuttingDown)throw new u(a.FAILED_PRECONDITION,"The client has already been terminated.")},t.prototype.terminate=function(){var t=this;this.asyncQueue.enterRestrictedMode();var n=new er;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(function(){return(0,e.__awaiter)(t,void 0,void 0,function(){var t,r;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),this.onlineComponents?[4,this.onlineComponents.terminate()]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.offlineComponents?[4,this.offlineComponents.terminate()]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.credentials.removeChangeListener(),n.resolve(),[3,6];case 5:return t=e.sent(),r=Qo(t,"Failed to shutdown persistence"),n.reject(r),[3,6];case 6:return[2]}})})}),n.promise},t}();function ea(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i,o=this;return(0,e.__generator)(this,function(s){switch(s.label){case 0:return t.asyncQueue.verifyOperationInProgress(),f("FirestoreClient","Initializing OfflineComponentProvider"),[4,t.getConfiguration()];case 1:return r=s.sent(),[4,n.initialize(r)];case 2:return s.sent(),i=r.initialUser,t.setCredentialChangeListener(function(t){return(0,e.__awaiter)(o,void 0,void 0,function(){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return i.isEqual(t)?[3,2]:[4,Ii(n.localStore,t)];case 1:e.sent(),i=t,e.label=2;case 2:return[2]}})})}),n.persistence.setDatabaseDeletedListener(function(){return t.terminate()}),t.offlineComponents=n,[2]}})})}function na(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i;return(0,e.__generator)(this,function(o){switch(o.label){case 0:return t.asyncQueue.verifyOperationInProgress(),[4,ra(t)];case 1:return r=o.sent(),f("FirestoreClient","Initializing OnlineComponentProvider"),[4,t.getConfiguration()];case 2:return i=o.sent(),[4,n.initialize(r,i)];case 3:return o.sent(),t.setCredentialChangeListener(function(t){return function(t,n){return(0,e.__awaiter)(this,void 0,void 0,function(){var r,i;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return(r=m(t)).asyncQueue.verifyOperationInProgress(),f("RemoteStore","RemoteStore received new credentials"),i=Do(r),r.Or.add(3),[4,wo(r)];case 1:return e.sent(),i&&r.Br.set("Unknown"),[4,r.remoteSyncer.handleCredentialChange(n)];case 2:return e.sent(),r.Or.delete(3),[4,_o(r)];case 3:return e.sent(),[2]}})})}(n.remoteStore,t)}),t.onlineComponents=n,[2]}})})}function ra(t){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return t.offlineComponents?[3,2]:(f("FirestoreClient","Using default OfflineComponentProvider"),[4,ea(t,new Qs)]);case 1:e.sent(),e.label=2;case 2:return[2,t.offlineComponents]}})})}function ia(t){return(0,e.__awaiter)(this,void 0,void 0,function(){return(0,e.__generator)(this,function(e){switch(e.label){case 0:return t.onlineComponents?[3,2]:(f("FirestoreClient","Using default OnlineComponentProvider"),[4,na(t,new Hs)]);case 1:e.sent(),e.label=2;case 2:return[2,t.onlineComponents]}})})}function oa(t){return ra(t).then(function(t){return t.persistence})}function sa(t){return ra(t).then(function(t){return t.localStore})}function aa(t){return ia(t).then(function(t){return t.remoteStore})}function ua(t){return ia(t).then(function(t){return t.syncEngine})}function ca(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n,r;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,ia(t)];case 1:return n=e.sent(),[2,((r=n.eventManager).onListen=ds.bind(null,n.syncEngine),r.onUnlisten=ys.bind(null,n.syncEngine),r)]}})})}function ha(t,n,r){var i=this;void 0===r&&(r={});var o=new er;return t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(i,void 0,void 0,function(){var i;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return i=function(t,e,n,r,i){var o=new $s({next:function(o){e.enqueueAndForget(function(){return Jo(t,s)});var c=o.docs.has(n);!c&&o.fromCache?i.reject(new u(a.UNAVAILABLE,"Failed to get document because the client is offline.")):c&&o.fromCache&&r&&"server"===r.source?i.reject(new u(a.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):i.resolve(o)},error:function(t){return i.reject(t)}}),s=new ns(kt(n.path),o,{includeMetadataChanges:!0,so:!0});return Xo(t,s)},[4,ca(t)];case 1:return[2,i.apply(void 0,[e.sent(),t.asyncQueue,n,r,o])]}})})}),o.promise}function fa(t,n,r){var i=this;void 0===r&&(r={});var o=new er;return t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(i,void 0,void 0,function(){var i;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return i=function(t,e,n,r,i){var o=new $s({next:function(n){e.enqueueAndForget(function(){return Jo(t,s)}),n.fromCache&&"server"===r.source?i.reject(new u(a.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):i.resolve(n)},error:function(t){return i.reject(t)}}),s=new ns(n,o,{includeMetadataChanges:!0,so:!0});return Xo(t,s)},[4,ca(t)];case 1:return[2,i.apply(void 0,[e.sent(),t.asyncQueue,n,r,o])]}})})}),o.promise}var la=function(t,e,n,r,i,o,s,a){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=o,this.autoDetectLongPolling=s,this.useFetchStreams=a},da=function(){function t(t,e){this.projectId=t,this.database=e||"(default)"}return Object.defineProperty(t.prototype,"isDefaultDatabase",{get:function(){return"(default)"===this.database},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){return e instanceof t&&e.projectId===this.projectId&&e.database===this.database},t}(),pa=new Map,ya=function(t,e){this.user=e,this.type="OAuth",this.authHeaders={},this.authHeaders.Authorization="Bearer "+t},va=function(){function t(){this.changeListener=null}return t.prototype.getToken=function(){return Promise.resolve(null)},t.prototype.invalidateToken=function(){},t.prototype.setChangeListener=function(t,e){this.changeListener=e,t.enqueueRetryable(function(){return e(zi.UNAUTHENTICATED)})},t.prototype.removeChangeListener=function(){this.changeListener=null},t}(),ma=function(){function t(t){this.token=t,this.changeListener=null}return t.prototype.getToken=function(){return Promise.resolve(this.token)},t.prototype.invalidateToken=function(){},t.prototype.setChangeListener=function(t,e){var n=this;this.changeListener=e,t.enqueueRetryable(function(){return e(n.token.user)})},t.prototype.removeChangeListener=function(){this.changeListener=null},t}(),ga=function(){function t(t){var e=this;this.currentUser=zi.UNAUTHENTICATED,this.oc=new er,this.cc=0,this.forceRefresh=!1,this.auth=null,this.asyncQueue=null,this.uc=function(){e.cc++,e.currentUser=e.ac(),e.oc.resolve(),e.changeListener&&e.asyncQueue.enqueueRetryable(function(){return e.changeListener(e.currentUser)})};var n=function(t){f("FirebaseCredentialsProvider","Auth detected"),e.auth=t,e.auth.addAuthTokenListener(e.uc)};t.onInit(function(t){return n(t)}),setTimeout(function(){if(!e.auth){var r=t.getImmediate({optional:!0});r?n(r):(f("FirebaseCredentialsProvider","Auth not yet detected"),e.oc.resolve())}},0)}return t.prototype.getToken=function(){var t=this,e=this.cc,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then(function(n){return t.cc!==e?(f("FirebaseCredentialsProvider","getToken aborted due to token change."),t.getToken()):n?(v("string"==typeof n.accessToken),new ya(n.accessToken,t.currentUser)):null}):Promise.resolve(null)},t.prototype.invalidateToken=function(){this.forceRefresh=!0},t.prototype.setChangeListener=function(t,n){var r=this;this.asyncQueue=t,this.asyncQueue.enqueueRetryable(function(){return(0,e.__awaiter)(r,void 0,void 0,function(){return(0,e.__generator)(this,function(t){switch(t.label){case 0:return[4,this.oc.promise];case 1:return t.sent(),[4,n(this.currentUser)];case 2:return t.sent(),this.changeListener=n,[2]}})})})},t.prototype.removeChangeListener=function(){this.auth&&this.auth.removeAuthTokenListener(this.uc),this.changeListener=function(){return Promise.resolve()}},t.prototype.ac=function(){var t=this.auth&&this.auth.getUid();return v(null===t||"string"==typeof t),new zi(t)},t}(),_a=function(){function t(t,e,n){this.hc=t,this.lc=e,this.fc=n,this.type="FirstParty",this.user=zi.FIRST_PARTY}return Object.defineProperty(t.prototype,"authHeaders",{get:function(){var t={"X-Goog-AuthUser":this.lc},e=this.hc.auth.getAuthHeaderValueForFirstParty([]);return e&&(t.Authorization=e),this.fc&&(t["X-Goog-Iam-Authorization-Token"]=this.fc),t},enumerable:!1,configurable:!0}),t}(),wa=function(){function t(t,e,n){this.hc=t,this.lc=e,this.fc=n}return t.prototype.getToken=function(){return Promise.resolve(new _a(this.hc,this.lc,this.fc))},t.prototype.setChangeListener=function(t,e){t.enqueueRetryable(function(){return e(zi.FIRST_PARTY)})},t.prototype.removeChangeListener=function(){},t.prototype.invalidateToken=function(){},t}();function ba(t,e,n){if(!n)throw new u(a.INVALID_ARGUMENT,"Function "+t+"() cannot be called with an empty "+e+".")}function Ia(t,e){if(void 0===e)return{merge:!1};if(void 0!==e.mergeFields&&void 0!==e.merge)throw new u(a.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function Ea(t,e,n,r){if(!0===e&&!0===r)throw new u(a.INVALID_ARGUMENT,t+" and "+n+" cannot be used together.")}function Ta(t){if(!G.isDocumentKey(t))throw new u(a.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t+" has "+t.length+".")}function Sa(t){if(G.isDocumentKey(t))throw new u(a.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t+" has "+t.length+".")}function Na(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=t.substring(0,20)+"..."),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==o(t)){if(t instanceof Array)return"an array";var e=function(t){if(t.constructor){var e=/function\s+([^\s(]+)\s*\(/.exec(t.constructor.toString());if(e&&e.length>1)return e[1]}return null}(t);return e?"a custom "+e+" object":"an object"}return"function"==typeof t?"a function":y()}function Da(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new u(a.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=Na(t);throw new u(a.INVALID_ARGUMENT,"Expected type '"+e.name+"', but it was: "+n)}return t}function Aa(t,e){if(e<=0)throw new u(a.INVALID_ARGUMENT,"Function "+t+"() requires a positive number, but it was: "+e+".")}var xa=function(){function t(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new u(a.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=null===(e=t.ssl)||void 0===e||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new u(a.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.useFetchStreams=!!t.useFetchStreams,Ea("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}return t.prototype.isEqual=function(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams},t}(),ka=function(){function t(t,e){this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new xa({}),this._settingsFrozen=!1,t instanceof da?(this._databaseId=t,this._credentials=new va):(this._app=t,this._databaseId=function(t){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new u(a.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new da(t.options.projectId)}(t),this._credentials=new ga(e))}return Object.defineProperty(t.prototype,"app",{get:function(){if(!this._app)throw new u(a.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_initialized",{get:function(){return this._settingsFrozen},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_terminated",{get:function(){return void 0!==this._terminateTask},enumerable:!1,configurable:!0}),t.prototype._setSettings=function(t){if(this._settingsFrozen)throw new u(a.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new xa(t),void 0!==t.credentials&&(this._credentials=function(t){if(!t)return new va;switch(t.type){case"gapi":var e=t.client;return v(!("object"!=o(e)||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new wa(e,t.sessionIndex||"0",t.iamToken||null);case"provider":return t.client;default:throw new u(a.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(t.credentials))},t.prototype._getSettings=function(){return this._settings},t.prototype._freezeSettings=function(){return this._settingsFrozen=!0,this._settings},t.prototype._delete=function(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask},t.prototype.toJSON=function(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}},t.prototype._terminate=function(){return this,(t=pa.get(this))&&(f("ComponentProvider","Removing Datastore"),pa.delete(this),t.terminate()),Promise.resolve();var t},t}(),Ca=function(){function t(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}return Object.defineProperty(t.prototype,"_path",{get:function(){return this._key.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this._key.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return new La(this.firestore,this.converter,this._key.path.popLast())},enumerable:!1,configurable:!0}),t.prototype.withConverter=function(e){return new t(this.firestore,e,this._key)},t}(),Ra=function(){function t(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}return t.prototype.withConverter=function(e){return new t(this.firestore,e,this._query)},t}(),La=function(t){function n(e,n,r){var i=this;return(i=t.call(this,e,n,kt(r))||this)._path=r,i.type="collection",i}return(0,e.__extends)(n,t),Object.defineProperty(n.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){var t=this._path.popLast();return t.isEmpty()?null:new Ca(this.firestore,null,new G(t))},enumerable:!1,configurable:!0}),n.prototype.withConverter=function(t){return new n(this.firestore,t,this._path)},n}(Ra);function Oa(t,r){for(var i,o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];if(t=(0,n.getModularInstance)(t),ba("collection","path",r),t instanceof ka)return Sa(i=x.fromString.apply(x,(0,e.__spreadArray)([r],o))),new La(t,null,i);if(!(t instanceof Ca||t instanceof La))throw new u(a.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return Sa(i=x.fromString.apply(x,(0,e.__spreadArray)([t.path],o)).child(x.fromString(r))),new La(t.firestore,null,i)}function Pa(t,r){for(var i,o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];if(t=(0,n.getModularInstance)(t),1===arguments.length&&(r=_.u()),ba("doc","path",r),t instanceof ka)return Ta(i=x.fromString.apply(x,(0,e.__spreadArray)([r],o))),new Ca(t,null,new G(i));if(!(t instanceof Ca||t instanceof La))throw new u(a.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return Ta(i=t._path.child(x.fromString.apply(x,(0,e.__spreadArray)([r],o)))),new Ca(t.firestore,t instanceof La?t.converter:null,new G(i))}function Fa(t,e){return t=(0,n.getModularInstance)(t),e=(0,n.getModularInstance)(e),(t instanceof Ca||t instanceof La)&&(e instanceof Ca||e instanceof La)&&t.firestore===e.firestore&&t.path===e.path&&t.converter===e.converter}function Ma(t,e){return t=(0,n.getModularInstance)(t),e=(0,n.getModularInstance)(e),t instanceof Ra&&e instanceof Ra&&t.firestore===e.firestore&&qt(t._query,e._query)&&t.converter===e.converter}var Va=function(){function t(){var t=this;this.dc=Promise.resolve(),this.wc=[],this._c=!1,this.mc=[],this.yc=null,this.gc=!1,this.Ec=!1,this.Tc=[],this.Zi=new fo(this,"async_queue_retry"),this.Ic=function(){var e=co();e&&f("AsyncQueue","Visibility state changed to "+e.visibilityState),t.Zi.Gi()};var e=co();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.Ic)}return Object.defineProperty(t.prototype,"isShuttingDown",{get:function(){return this._c},enumerable:!1,configurable:!0}),t.prototype.enqueueAndForget=function(t){this.enqueue(t)},t.prototype.enqueueAndForgetEvenWhileRestricted=function(t){this.Ac(),this.Rc(t)},t.prototype.enterRestrictedMode=function(t){if(!this._c){this._c=!0,this.Ec=t||!1;var e=co();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("visibilitychange",this.Ic)}},t.prototype.enqueue=function(t){var e=this;if(this.Ac(),this._c)return new Promise(function(){});var n=new er;return this.Rc(function(){return e._c&&e.Ec?Promise.resolve():(t().then(n.resolve,n.reject),n.promise)}).then(function(){return n.promise})},t.prototype.enqueueRetryable=function(t){var e=this;this.enqueueAndForget(function(){return e.wc.push(t),e.bc()})},t.prototype.bc=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){var t,n=this;return(0,e.__generator)(this,function(e){switch(e.label){case 0:if(0===this.wc.length)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.wc[0]()];case 2:return e.sent(),this.wc.shift(),this.Zi.reset(),[3,4];case 3:if(!ar(t=e.sent()))throw t;return f("AsyncQueue","Operation failed with retryable error: "+t),[3,4];case 4:this.wc.length>0&&this.Zi.ji(function(){return n.bc()}),e.label=5;case 5:return[2]}})})},t.prototype.Rc=function(t){var e=this,n=this.dc.then(function(){return e.gc=!0,t().catch(function(t){throw e.yc=t,e.gc=!1,l("INTERNAL UNHANDLED ERROR: ",function(t){var e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e}(t)),t}).then(function(t){return e.gc=!1,t})});return this.dc=n,n},t.prototype.enqueueAfterDelay=function(t,e,n){var r=this;this.Ac(),this.Tc.indexOf(t)>-1&&(e=0);var i=Go.createAndSchedule(this,t,e,n,function(t){return r.vc(t)});return this.mc.push(i),i},t.prototype.Ac=function(){this.yc&&y()},t.prototype.verifyOperationInProgress=function(){},t.prototype.Pc=function(){return(0,e.__awaiter)(this,void 0,void 0,function(){var t;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,t=this.dc];case 1:e.sent(),e.label=2;case 2:if(t!==this.dc)return[3,0];e.label=3;case 3:return[2]}})})},t.prototype.Vc=function(t){for(var e=0,n=this.mc;e<n.length;e++)if(n[e].timerId===t)return!0;return!1},t.prototype.Sc=function(t){var e=this;return this.Pc().then(function(){e.mc.sort(function(t,e){return t.targetTimeMs-e.targetTimeMs});for(var n=0,r=e.mc;n<r.length;n++){var i=r[n];if(i.skipDelay(),"all"!==t&&i.timerId===t)break}return e.Pc()})},t.prototype.Dc=function(t){this.Tc.push(t)},t.prototype.vc=function(t){var e=this.mc.indexOf(t);this.mc.splice(e,1)},t}();function qa(t){return function(t,e){if("object"!=o(t)||null===t)return!1;for(var n=t,r=0,i=["next","error","complete"];r<i.length;r++){var s=i[r];if(s in n&&"function"==typeof n[s])return!0}return!1}(t)}var Ua=function(){function t(){this._progressObserver={},this._taskCompletionResolver=new er,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}return t.prototype.onProgress=function(t,e,n){this._progressObserver={next:t,error:e,complete:n}},t.prototype.catch=function(t){return this._taskCompletionResolver.promise.catch(t)},t.prototype.then=function(t,e){return this._taskCompletionResolver.promise.then(t,e)},t.prototype._completeWith=function(t){this._updateProgress(t),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(t)},t.prototype._failWith=function(t){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(t),this._taskCompletionResolver.reject(t)},t.prototype._updateProgress=function(t){this._lastProgress=t,this._progressObserver.next&&this._progressObserver.next(t)},t}(),Ba=-1,ja=function(t){function n(e,n){var r=this;return(r=t.call(this,e,n)||this).type="firestore",r._queue=new Va,r._persistenceKey="name"in e?e.name:"[DEFAULT]",r}return(0,e.__extends)(n,t),n.prototype._terminate=function(){return this._firestoreClient||Ga(this),this._firestoreClient.terminate()},n}(ka);function Ka(t){return t._firestoreClient||Ga(t),t._firestoreClient.verifyNotTerminated(),t._firestoreClient}function Ga(t){var e,n=t._freezeSettings(),r=function(t,e,n,r){return new la(t,e,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,r.useFetchStreams)}(t._databaseId,(null===(e=t._app)||void 0===e?void 0:e.options.appId)||"",t._persistenceKey,n);t._firestoreClient=new ta(t._credentials,t._queue,r)}function Qa(t,n,r){var i=this,o=new er;return t.asyncQueue.enqueue(function(){return(0,e.__awaiter)(i,void 0,void 0,function(){var i;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,ea(t,r)];case 1:return e.sent(),[4,na(t,n)];case 2:return e.sent(),o.resolve(),[3,4];case 3:if(!function(t){return"FirebaseError"===t.name?t.code===a.FAILED_PRECONDITION||t.code===a.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code}(i=e.sent()))throw i;return console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+i),o.reject(i),[3,4];case 4:return[2]}})})}).then(function(){return o.promise})}function za(t){if(t._initialized||t._terminated)throw new u(a.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}exports.T=ja,exports.E=Ba;var Wa=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0;n<t.length;++n)if(0===t[n].length)throw new u(a.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new C(t)}return t.prototype.isEqual=function(t){return this._internalPath.isEqual(t._internalPath)},t}(),Ha=function(){function t(t){this._byteString=t}return t.fromBase64String=function(e){try{return new t(L.fromBase64String(e))}catch(e){throw new u(a.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}},t.fromUint8Array=function(e){return new t(L.fromUint8Array(e))},t.prototype.toBase64=function(){return this._byteString.toBase64()},t.prototype.toUint8Array=function(){return this._byteString.toUint8Array()},t.prototype.toString=function(){return"Bytes(base64: "+this.toBase64()+")"},t.prototype.isEqual=function(t){return this._byteString.isEqual(t._byteString)},t}(),Ya=function(t){this._methodName=t},$a=function(){function t(t,e){if(!isFinite(t)||t<-90||t>90)throw new u(a.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new u(a.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}return Object.defineProperty(t.prototype,"latitude",{get:function(){return this._lat},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"longitude",{get:function(){return this._long},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this._lat===t._lat&&this._long===t._long},t.prototype.toJSON=function(){return{latitude:this._lat,longitude:this._long}},t.prototype._compareTo=function(t){return w(this._lat,t._lat)||w(this._long,t._long)},t}(),Xa=/^__.*__$/,Ja=function(){function t(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}return t.prototype.toMutation=function(t,e){return null!==this.fieldMask?new me(t,this.data,this.fieldMask,e,this.fieldTransforms):new ve(t,this.data,e,this.fieldTransforms)},t}(),Za=function(){function t(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}return t.prototype.toMutation=function(t,e){return new me(t,this.data,this.fieldMask,e,this.fieldTransforms)},t}();function tu(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw y()}}exports.C=$a;var eu=function(){function t(t,e,n,r,i,o){this.settings=t,this.databaseId=e,this.R=n,this.ignoreUndefinedProperties=r,void 0===i&&this.Cc(),this.fieldTransforms=i||[],this.fieldMask=o||[]}return Object.defineProperty(t.prototype,"path",{get:function(){return this.settings.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Nc",{get:function(){return this.settings.Nc},enumerable:!1,configurable:!0}),t.prototype.xc=function(e){return new t(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.R,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)},t.prototype.kc=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.xc({path:n,Fc:!1});return r.$c(t),r},t.prototype.Oc=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.xc({path:n,Fc:!1});return r.Cc(),r},t.prototype.Mc=function(t){return this.xc({path:void 0,Fc:!0})},t.prototype.Lc=function(t){return bu(t,this.settings.methodName,this.settings.Bc||!1,this.path,this.settings.qc)},t.prototype.contains=function(t){return void 0!==this.fieldMask.find(function(e){return t.isPrefixOf(e)})||void 0!==this.fieldTransforms.find(function(e){return t.isPrefixOf(e.field)})},t.prototype.Cc=function(){if(this.path)for(var t=0;t<this.path.length;t++)this.$c(this.path.get(t))},t.prototype.$c=function(t){if(0===t.length)throw this.Lc("Document fields must not be empty");if(tu(this.Nc)&&Xa.test(t))throw this.Lc('Document fields cannot begin and end with "__"')},t}(),nu=function(){function t(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.R=n||ho(t)}return t.prototype.Uc=function(t,e,n,r){return void 0===r&&(r=!1),new eu({Nc:t,methodName:e,qc:n,path:C.emptyPath(),Fc:!1,Bc:r},this.databaseId,this.R,this.ignoreUndefinedProperties)},t}();function ru(t){var e=t._freezeSettings(),n=ho(t._databaseId);return new nu(t._databaseId,!!e.ignoreUndefinedProperties,n)}function iu(t,e,n,r,i,o){void 0===o&&(o={});var s=t.Uc(o.merge||o.mergeFields?2:0,e,n,i);mu("Data must be an object, but it was:",s,r);var c,h,f=yu(r,s);if(o.merge)c=new R(s.fieldMask),h=s.fieldTransforms;else if(o.mergeFields){for(var l=[],d=0,p=o.mergeFields;d<p.length;d++){var y=gu(e,p[d],n);if(!s.contains(y))throw new u(a.INVALID_ARGUMENT,"Field '"+y+"' is specified in your field mask but missing from your input data.");Iu(l,y)||l.push(y)}c=new R(l),h=s.fieldTransforms.filter(function(t){return c.covers(t.field)})}else c=null,h=s.fieldTransforms;return new Ja(new ot(f),c,h)}var ou=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return(0,e.__extends)(n,t),n.prototype._toFieldTransform=function(t){if(2!==t.Nc)throw 1===t.Nc?t.Lc(this._methodName+"() can only appear at the top level of your update data"):t.Lc(this._methodName+"() cannot be used with set() unless you pass {merge:true}");return t.fieldMask.push(t.path),null},n.prototype.isEqual=function(t){return t instanceof n},n}(Ya);function su(t,e,n){return new eu({Nc:3,qc:e.settings.qc,methodName:t._methodName,Fc:n},e.databaseId,e.R,e.ignoreUndefinedProperties)}var au=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return(0,e.__extends)(n,t),n.prototype._toFieldTransform=function(t){return new se(t.path,new Jt)},n.prototype.isEqual=function(t){return t instanceof n},n}(Ya),uu=function(t){function n(e,n){var r=this;return(r=t.call(this,e)||this).Kc=n,r}return(0,e.__extends)(n,t),n.prototype._toFieldTransform=function(t){var e=su(this,t,!0),n=this.Kc.map(function(t){return pu(t,e)}),r=new Zt(n);return new se(t.path,r)},n.prototype.isEqual=function(t){return this===t},n}(Ya),cu=function(t){function n(e,n){var r=this;return(r=t.call(this,e)||this).Kc=n,r}return(0,e.__extends)(n,t),n.prototype._toFieldTransform=function(t){var e=su(this,t,!0),n=this.Kc.map(function(t){return pu(t,e)}),r=new ee(n);return new se(t.path,r)},n.prototype.isEqual=function(t){return this===t},n}(Ya),hu=function(t){function n(e,n){var r=this;return(r=t.call(this,e)||this).Qc=n,r}return(0,e.__extends)(n,t),n.prototype._toFieldTransform=function(t){var e=new re(t.R,Wt(t.R,this.Qc));return new se(t.path,e)},n.prototype.isEqual=function(t){return this===t},n}(Ya);function fu(t,e,r,i){var o=t.Uc(1,e,r);mu("Data must be an object, but it was:",o,i);var s=[],a=ot.empty();N(i,function(t,i){var u=wu(e,t,r);i=(0,n.getModularInstance)(i);var c=o.Oc(u);if(i instanceof ou)s.push(u);else{var h=pu(i,c);null!=h&&(s.push(u),a.set(u,h))}});var u=new R(s);return new Za(a,u,o.fieldTransforms)}function lu(t,e,r,i,o,s){var c=t.Uc(1,e,r),h=[gu(e,i,r)],f=[o];if(s.length%2!=0)throw new u(a.INVALID_ARGUMENT,"Function "+e+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var l=0;l<s.length;l+=2)h.push(gu(e,s[l])),f.push(s[l+1]);for(var d=[],p=ot.empty(),y=h.length-1;y>=0;--y)if(!Iu(d,h[y])){var v=h[y],m=f[y];m=(0,n.getModularInstance)(m);var g=c.Oc(v);if(m instanceof ou)d.push(v);else{var _=pu(m,g);null!=_&&(d.push(v),p.set(v,_))}}var w=new R(d);return new Za(p,w,c.fieldTransforms)}function du(t,e,n,r){return void 0===r&&(r=!1),pu(n,t.Uc(r?4:3,e))}function pu(t,e){if(vu(t=(0,n.getModularInstance)(t)))return mu("Unsupported field value:",e,t),yu(t,e);if(t instanceof Ya)return function(t,e){if(!tu(e.Nc))throw e.Lc(t._methodName+"() can only be used with update() and set()");if(!e.path)throw e.Lc(t._methodName+"() is not currently supported inside arrays");var n=t._toFieldTransform(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.Fc&&4!==e.Nc)throw e.Lc("Nested arrays are not supported");return function(t,e){for(var n=[],r=0,i=0,o=t;i<o.length;i++){var s=pu(o[i],e.Mc(r));null==s&&(s={nullValue:"NULL_VALUE"}),n.push(s),r++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(null===(t=(0,n.getModularInstance)(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t)return Wt(e.R,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var r=E.fromDate(t);return{timestampValue:en(e.R,r)}}if(t instanceof E)return r=new E(t.seconds,1e3*Math.floor(t.nanoseconds/1e3)),{timestampValue:en(e.R,r)};if(t instanceof $a)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof Ha)return{bytesValue:nn(e.R,t._byteString)};if(t instanceof Ca){r=e.databaseId;var i=t.firestore._databaseId;if(!i.isEqual(r))throw e.Lc("Document reference is for database "+i.projectId+"/"+i.database+" but should be for database "+r.projectId+"/"+r.database);return{referenceValue:sn(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.Lc("Unsupported field value: "+Na(t))}(t,e)}function yu(t,e){var n={};return D(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):N(t,function(t,r){var i=pu(r,e.kc(t));null!=i&&(n[t]=i)}),{mapValue:{fields:n}}}function vu(t){return!("object"!=o(t)||null===t||t instanceof Array||t instanceof Date||t instanceof E||t instanceof $a||t instanceof Ha||t instanceof Ca||t instanceof Ya)}function mu(t,e,n){if(!vu(n)||!function(t){return"object"==o(t)&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(n)){var r=Na(n);throw"an object"===r?e.Lc(t+" a custom object"):e.Lc(t+" "+r)}}function gu(t,e,r){if((e=(0,n.getModularInstance)(e))instanceof Wa)return e._internalPath;if("string"==typeof e)return wu(t,e);throw bu("Field path arguments must be of type string or FieldPath.",t,!1,void 0,r)}var _u=new RegExp("[~\\*/\\[\\]]");function wu(t,n,r){if(n.search(_u)>=0)throw bu("Invalid field path ("+n+"). Paths must not contain '~', '*', '/', '[', or ']'",t,!1,void 0,r);try{return(new(Wa.bind.apply(Wa,(0,e.__spreadArray)([void 0],n.split(".")))))._internalPath}catch(i){throw bu("Invalid field path ("+n+"). Paths must not be empty, begin with '.', end with '.', or contain '..'",t,!1,void 0,r)}}function bu(t,e,n,r,i){var o=r&&!r.isEmpty(),s=void 0!==i,c="Function "+e+"() called with invalid data";n&&(c+=" (via `toFirestore()`)");var h="";return(o||s)&&(h+=" (found",o&&(h+=" in field "+r),s&&(h+=" in document "+i),h+=")"),new u(a.INVALID_ARGUMENT,(c+=". ")+t+h)}function Iu(t,e){return t.some(function(t){return t.isEqual(e)})}var Eu=function(){function t(t,e,n,r,i){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=r,this._converter=i}return Object.defineProperty(t.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ref",{get:function(){return new Ca(this._firestore,this._converter,this._key)},enumerable:!1,configurable:!0}),t.prototype.exists=function(){return null!==this._document},t.prototype.data=function(){if(this._document){if(this._converter){var t=new Tu(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}},t.prototype.get=function(t){if(this._document){var e=this._document.data.field(Su("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}},t}(),Tu=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return(0,e.__extends)(n,t),n.prototype.data=function(){return t.prototype.data.call(this)},n}(Eu);function Su(t,e){return"string"==typeof e?wu(t,e):e instanceof Wa?e._internalPath:e._delegate._internalPath}var Nu=function(){function t(t,e){this.hasPendingWrites=t,this.fromCache=e}return t.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},t}(),Du=function(t){function n(e,n,r,i,o,s){var a=this;return(a=t.call(this,e,n,r,i,s)||this)._firestore=e,a._firestoreImpl=e,a.metadata=o,a}return(0,e.__extends)(n,t),n.prototype.exists=function(){return t.prototype.exists.call(this)},n.prototype.data=function(t){if(void 0===t&&(t={}),this._document){if(this._converter){var e=new Au(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}},n.prototype.get=function(t,e){if(void 0===e&&(e={}),this._document){var n=this._document.data.field(Su("DocumentSnapshot.get",t));if(null!==n)return this._userDataWriter.convertValue(n,e.serverTimestamps)}},n}(Eu),Au=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return(0,e.__extends)(n,t),n.prototype.data=function(e){return void 0===e&&(e={}),t.prototype.data.call(this,e)},n}(Du),xu=function(){function t(t,e,n,r){this._firestore=t,this._userDataWriter=e,this._snapshot=r,this.metadata=new Nu(r.hasPendingWrites,r.fromCache),this.query=n}return Object.defineProperty(t.prototype,"docs",{get:function(){var t=[];return this.forEach(function(e){return t.push(e)}),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"empty",{get:function(){return 0===this.size},enumerable:!1,configurable:!0}),t.prototype.forEach=function(t,e){var n=this;this._snapshot.docs.forEach(function(r){t.call(e,new Au(n._firestore,n._userDataWriter,r.key,r,new Nu(n._snapshot.mutatedKeys.has(r.key),n._snapshot.fromCache),n.query.converter))})},t.prototype.docChanges=function(t){void 0===t&&(t={});var e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new u(a.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(t,e){if(t._snapshot.oldDocs.isEmpty()){var n=0;return t._snapshot.docChanges.map(function(e){return{type:"added",doc:new Au(t._firestore,t._userDataWriter,e.doc.key,e.doc,new Nu(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query.converter),oldIndex:-1,newIndex:n++}})}var r=t._snapshot.oldDocs;return t._snapshot.docChanges.filter(function(t){return e||3!==t.type}).map(function(e){var n=new Au(t._firestore,t._userDataWriter,e.doc.key,e.doc,new Nu(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query.converter),i=-1,o=-1;return 0!==e.type&&(i=r.indexOf(e.doc.key),r=r.delete(e.doc.key)),1!==e.type&&(o=(r=r.add(e.doc)).indexOf(e.doc.key)),{type:ku(e.type),doc:n,oldIndex:i,newIndex:o}})}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges},t}();function ku(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return y()}}function Cu(t,e){return t instanceof Du&&e instanceof Du?t._firestore===e._firestore&&t._key.isEqual(e._key)&&(null===t._document?null===e._document:t._document.isEqual(e._document))&&t._converter===e._converter:t instanceof xu&&e instanceof xu&&t._firestore===e._firestore&&Ma(t.query,e.query)&&t.metadata.isEqual(e.metadata)&&t._snapshot.isEqual(e._snapshot)}function Ru(t){if(Rt(t)&&0===t.explicitOrderBy.length)throw new u(a.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var Lu=function(){};function Ou(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0,i=e;r<i.length;r++){t=i[r]._apply(t)}return t}var Pu=function(t){function n(e,n,r){var i=this;return(i=t.call(this)||this).jc=e,i.Wc=n,i.Gc=r,i.type="where",i}return(0,e.__extends)(n,t),n.prototype._apply=function(t){var e=ru(t.firestore),n=function(t,e,n,r,i,o,s){var c;if(i.isKeyField()){if("array-contains"===o||"array-contains-any"===o)throw new u(a.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o+"' queries on FieldPath.documentId().");if("in"===o||"not-in"===o){ju(s,o);for(var h=[],f=0,l=s;f<l.length;f++){var d=l[f];h.push(Bu(r,t,d))}c={arrayValue:{values:h}}}else c=Bu(r,t,s)}else"in"!==o&&"not-in"!==o&&"array-contains-any"!==o||ju(s,o),c=du(n,"where",s,"in"===o||"not-in"===o);var p=dt.create(i,o,c);return function(t,e){if(e.g()){var n=Ot(t);if(null!==n&&!n.isEqual(e.field))throw new u(a.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '"+n.toString()+"' and '"+e.field.toString()+"'");var r=Lt(t);null!==r&&Ku(t,e.field,r)}var i=function(t,e){for(var n=0,r=t.filters;n<r.length;n++){var i=r[n];if(e.indexOf(i.op)>=0)return i.op}return null}(t,function(t){switch(e.op){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}());if(null!==i)throw i===e.op?new u(a.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+e.op.toString()+"' filter."):new u(a.INVALID_ARGUMENT,"Invalid query. You cannot use '"+e.op.toString()+"' filters with '"+i.toString()+"' filters.")}(t,p),p}(t._query,0,e,t.firestore._databaseId,this.jc,this.Wc,this.Gc);return new Ra(t.firestore,t.converter,function(t,e){var n=t.filters.concat([e]);return new At(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}(t._query,n))},n}(Lu),Fu=function(t){function n(e,n){var r=this;return(r=t.call(this)||this).jc=e,r.zc=n,r.type="orderBy",r}return(0,e.__extends)(n,t),n.prototype._apply=function(t){var e=function(t,e,n){if(null!==t.startAt)throw new u(a.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new u(a.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r=new Tt(e,n);return function(t,e){if(null===Lt(t)){var n=Ot(t);null!==n&&Ku(t,n,e.field)}}(t,r),r}(t._query,this.jc,this.zc);return new Ra(t.firestore,t.converter,function(t,e){var n=t.explicitOrderBy.concat([e]);return new At(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(t._query,e))},n}(Lu),Mu=function(t){function n(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.Hc=n,i.Jc=r,i}return(0,e.__extends)(n,t),n.prototype._apply=function(t){return new Ra(t.firestore,t.converter,Vt(t._query,this.Hc,this.Jc))},n}(Lu),Vu=function(t){function n(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.Yc=n,i.Xc=r,i}return(0,e.__extends)(n,t),n.prototype._apply=function(t){var e=Uu(t,this.type,this.Yc,this.Xc);return new Ra(t.firestore,t.converter,function(t,e){return new At(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)}(t._query,e))},n}(Lu),qu=function(t){function n(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.Yc=n,i.Xc=r,i}return(0,e.__extends)(n,t),n.prototype._apply=function(t){var e=Uu(t,this.type,this.Yc,this.Xc);return new Ra(t.firestore,t.converter,function(t,e){return new At(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)}(t._query,e))},n}(Lu);function Uu(t,e,r,i){if(r[0]=(0,n.getModularInstance)(r[0]),r[0]instanceof Eu)return function(t,e,n,r,i){if(!r)throw new u(a.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+n+"().");for(var o=[],s=0,c=Ft(t);s<c.length;s++){var h=c[s];if(h.field.isKeyField())o.push(J(e,r.key));else{var f=r.data.field(h.field);if(V(f))throw new u(a.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+h.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===f){var l=h.field.canonicalString();throw new u(a.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+l+"' (used as the orderBy) does not exist.")}o.push(f)}}return new It(o,i)}(t._query,t.firestore._databaseId,e,r[0]._document,i);var s=ru(t.firestore);return function(t,e,n,r,i,s){var c=t.explicitOrderBy;if(i.length>c.length)throw new u(a.INVALID_ARGUMENT,"Too many arguments provided to "+r+"(). The number of arguments must be less than or equal to the number of orderBy() clauses");for(var h=[],f=0;f<i.length;f++){var l=i[f];if(c[f].field.isKeyField()){if("string"!=typeof l)throw new u(a.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+r+"(), but got a "+o(l));if(!Pt(t)&&-1!==l.indexOf("/"))throw new u(a.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to "+r+"() must be a plain document ID, but '"+l+"' contains a slash.");var d=t.path.child(x.fromString(l));if(!G.isDocumentKey(d))throw new u(a.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to "+r+"() must result in a valid document path, but '"+d+"' is not because it contains an odd number of segments.");var p=new G(d);h.push(J(e,p))}else{var y=du(n,r,l);h.push(y)}}return new It(h,s)}(t._query,t.firestore._databaseId,s,e,r,i)}function Bu(t,e,r){if("string"==typeof(r=(0,n.getModularInstance)(r))){if(""===r)throw new u(a.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!Pt(e)&&-1!==r.indexOf("/"))throw new u(a.INVALID_ARGUMENT,"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '"+r+"' contains a '/' character.");var i=e.path.child(x.fromString(r));if(!G.isDocumentKey(i))throw new u(a.INVALID_ARGUMENT,"Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '"+i+"' is not because it has an odd number of segments ("+i.length+").");return J(t,new G(i))}if(r instanceof Ca)return J(t,r._key);throw new u(a.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+Na(r)+".")}function ju(t,e){if(!Array.isArray(t)||0===t.length)throw new u(a.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(t.length>10)throw new u(a.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.")}function Ku(t,e,n){if(!n.isEqual(e))throw new u(a.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '"+e.toString()+"' and so you must also use '"+e.toString()+"' as your first argument to orderBy(), but your first orderBy() is on field '"+n.toString()+"' instead.")}var Gu=function(){function t(){}return t.prototype.convertValue=function(t,e){switch(void 0===e&&(e="none"),Q(t)){case 0:return null;case 1:return t.booleanValue;case 2:return F(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(M(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw y()}},t.prototype.convertObject=function(t,e){var n=this,r={};return N(t.fields,function(t,i){r[t]=n.convertValue(i,e)}),r},t.prototype.convertGeoPoint=function(t){return new $a(F(t.latitude),F(t.longitude))},t.prototype.convertArray=function(t,e){var n=this;return(t.values||[]).map(function(t){return n.convertValue(t,e)})},t.prototype.convertServerTimestamp=function(t,e){switch(e){case"previous":var n=q(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(U(t));default:return null}},t.prototype.convertTimestamp=function(t){var e=P(t);return new E(e.seconds,e.nanos)},t.prototype.convertDocumentKey=function(t,e){var n=x.fromString(t);v(Cn(n));var r=new da(n.get(1),n.get(3)),i=new G(n.popFirst(5));return r.isEqual(e)||l("Document "+i+" contains a document reference within a different database ("+r.projectId+"/"+r.database+") which is not supported. It will be treated as a reference in the current database ("+e.projectId+"/"+e.database+") instead."),i},t}();function Qu(t,e,n){return t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e}var zu=function(t){function n(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return(0,e.__extends)(n,t),n.prototype.convertBytes=function(t){return new Ha(t)},n.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);return new Ca(this.firestore,null,e)},n}(Gu),Wu=function(){function t(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=ru(t)}return t.prototype.set=function(t,e,n){this._verifyNotCommitted();var r=Hu(t,this._firestore),i=Qu(r.converter,e,n),o=iu(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(o.toMutation(r._key,ue.none())),this},t.prototype.update=function(t,e,r){for(var i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];this._verifyNotCommitted();var s,a=Hu(t,this._firestore);return s="string"==typeof(e=(0,n.getModularInstance)(e))||e instanceof Wa?lu(this._dataReader,"WriteBatch.update",a._key,e,r,i):fu(this._dataReader,"WriteBatch.update",a._key,e),this._mutations.push(s.toMutation(a._key,ue.exists(!0))),this},t.prototype.delete=function(t){this._verifyNotCommitted();var e=Hu(t,this._firestore);return this._mutations=this._mutations.concat(new Ee(e._key,ue.none())),this},t.prototype.commit=function(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()},t.prototype._verifyNotCommitted=function(){if(this._committed)throw new u(a.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},t}();function Hu(t,e){if((t=(0,n.getModularInstance)(t)).firestore!==e)throw new u(a.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return t}var Yu=function(t){function n(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return(0,e.__extends)(n,t),n.prototype.convertBytes=function(t){return new Ha(t)},n.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);return new Ca(this.firestore,null,e)},n}(Gu);function $u(t,e,n){t=Da(t,Ca);var r=Da(t.firestore,ja),i=Qu(t.converter,e,n);return Zu(r,[iu(ru(r),"setDoc",t._key,i,null!==t.converter,n).toMutation(t._key,ue.none())])}function Xu(t,e,r){for(var i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];t=Da(t,Ca);var s=Da(t.firestore,ja),a=ru(s);return Zu(s,[("string"==typeof(e=(0,n.getModularInstance)(e))||e instanceof Wa?lu(a,"updateDoc",t._key,e,r,i):fu(a,"updateDoc",t._key,e)).toMutation(t._key,ue.exists(!0))])}function Ju(t){for(var r,i,s,a=[],u=1;u<arguments.length;u++)a[u-1]=arguments[u];t=(0,n.getModularInstance)(t);var c={includeMetadataChanges:!1},h=0;"object"!=o(a[h])||qa(a[h])||(c=a[h],h++);var f,l,d,p={includeMetadataChanges:c.includeMetadataChanges};if(qa(a[h])){var y=a[h];a[h]=null===(r=y.next)||void 0===r?void 0:r.bind(y),a[h+1]=null===(i=y.error)||void 0===i?void 0:i.bind(y),a[h+2]=null===(s=y.complete)||void 0===s?void 0:s.bind(y)}if(t instanceof Ca)l=Da(t.firestore,ja),d=kt(t._key.path),f={next:function(e){a[h]&&a[h](tc(l,t,e))},error:a[h+1],complete:a[h+2]};else{var v=Da(t,Ra);l=Da(v.firestore,ja),d=v._query;var m=new Yu(l);f={next:function(t){a[h]&&a[h](new xu(l,m,v,t))},error:a[h+1],complete:a[h+2]},Ru(t._query)}return function(t,n,r,i){var o=this,s=new $s(f),a=new ns(n,s,r);return t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(o,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return n=Xo,[4,ca(t)];case 1:return[2,n.apply(void 0,[e.sent(),a])]}})})}),function(){s.Wo(),t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(o,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return n=Jo,[4,ca(t)];case 1:return[2,n.apply(void 0,[e.sent(),a])]}})})})}}(Ka(l),d,p)}function Zu(t,n){return function(t,n){var r=this,i=new er;return t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(r,void 0,void 0,function(){var r;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return r=vs,[4,ua(t)];case 1:return[2,r.apply(void 0,[e.sent(),n,i])]}})})}),i.promise}(Ka(t),n)}function tc(t,e,n){var r=n.docs.get(e._key),i=new Yu(t);return new Du(t,i,e._key,r,new Nu(n.hasPendingWrites,n.fromCache),e.converter)}var ec=function(t){function n(e,n){var r=this;return(r=t.call(this,e,n)||this)._firestore=e,r}return(0,e.__extends)(n,t),n.prototype.get=function(e){var n=this,r=Hu(e,this._firestore),i=new Yu(this._firestore);return t.prototype.get.call(this,e).then(function(t){return new Du(n._firestore,i,r._key,t._document,new Nu(!1,!1),r.converter)})},n}(function(){function t(t,e){this._firestore=t,this._transaction=e,this._dataReader=ru(t)}return t.prototype.get=function(t){var e=this,n=Hu(t,this._firestore),r=new zu(this._firestore);return this._transaction.lookup([n._key]).then(function(t){if(!t||1!==t.length)return y();var i=t[0];if(i.isFoundDocument())return new Eu(e._firestore,r,i.key,i,n.converter);if(i.isNoDocument())return new Eu(e._firestore,r,n._key,null,n.converter);throw y()})},t.prototype.set=function(t,e,n){var r=Hu(t,this._firestore),i=Qu(r.converter,e,n),o=iu(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,o),this},t.prototype.update=function(t,e,r){for(var i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];var s,a=Hu(t,this._firestore);return s="string"==typeof(e=(0,n.getModularInstance)(e))||e instanceof Wa?lu(this._dataReader,"Transaction.update",a._key,e,r,i):fu(this._dataReader,"Transaction.update",a._key,e),this._transaction.update(a._key,s),this},t.prototype.delete=function(t){var e=Hu(t,this._firestore);return this._transaction.delete(e._key),this},t}());function nc(){if("undefined"==typeof Uint8Array)throw new u(a.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function rc(){if("undefined"==typeof atob)throw new u(a.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var ic=function(){function t(t){this._delegate=t}return t.fromBase64String=function(e){return rc(),new t(Ha.fromBase64String(e))},t.fromUint8Array=function(e){return nc(),new t(Ha.fromUint8Array(e))},t.prototype.toBase64=function(){return rc(),this._delegate.toBase64()},t.prototype.toUint8Array=function(){return nc(),this._delegate.toUint8Array()},t.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},t.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},t}(),oc=function(){function t(){}return t.prototype.enableIndexedDbPersistence=function(t,e){return function(t,e){za(t=Da(t,ja));var n=Ka(t),r=t._freezeSettings(),i=new Hs;return Qa(n,i,new zs(i,r.cacheSizeBytes,null==e?void 0:e.forceOwnership))}(t._delegate,{forceOwnership:e})},t.prototype.enableMultiTabIndexedDbPersistence=function(t){return function(t){za(t=Da(t,ja));var e=Ka(t),n=t._freezeSettings(),r=new Hs;return Qa(e,r,new Ws(r,n.cacheSizeBytes))}(t._delegate)},t.prototype.clearIndexedDbPersistence=function(t){return function(t){var n=this;if(t._initialized&&!t._terminated)throw new u(a.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");var r=new er;return t._queue.enqueueAndForgetEvenWhileRestricted(function(){return(0,e.__awaiter)(n,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,function(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return ir.yt()?(n=t+"main",[4,ir.delete(n)]):[2,Promise.resolve()];case 1:return e.sent(),[2]}})})}(yi(t._databaseId,t._persistenceKey))];case 1:return i.sent(),r.resolve(),[3,3];case 2:return n=i.sent(),r.reject(n),[3,3];case 3:return[2]}})})}),r.promise}(t._delegate)},t}(),sc=function(){function t(t,e,n){var r=this;this._delegate=e,this.Zc=n,this.INTERNAL={delete:function(){return r.terminate()}},t instanceof da||(this.tu=t)}return Object.defineProperty(t.prototype,"_databaseId",{get:function(){return this._delegate._databaseId},enumerable:!1,configurable:!0}),t.prototype.settings=function(t){var e=this._delegate._getSettings();t.merge||e.host===t.host||d("You are overriding the original host. If you did not intend to override your settings, use {merge: true}."),t.merge&&delete(t=Object.assign(Object.assign({},e),t)).merge,this._delegate._setSettings(t)},t.prototype.useEmulator=function(t,e,r){void 0===r&&(r={}),function(t,e,r,i){var o;void 0===i&&(i={});var s=(t=Da(t,ka))._getSettings();if("firestore.googleapis.com"!==s.host&&s.host!==e&&d("Host has been set in both settings() and useEmulator(), emulator host will be used"),t._setSettings(Object.assign(Object.assign({},s),{host:e+":"+r,ssl:!1})),i.mockUserToken){var c,h;if("string"==typeof i.mockUserToken)c=i.mockUserToken,h=zi.MOCK_USER;else{c=(0,n.createMockUserToken)(i.mockUserToken,null===(o=t._app)||void 0===o?void 0:o.options.projectId);var f=i.mockUserToken.sub||i.mockUserToken.user_id;if(!f)throw new u(a.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");h=new zi(f)}t._credentials=new ma(new ya(c,h))}}(this._delegate,t,e,r)},t.prototype.enableNetwork=function(){return function(t){var n=this;return t.asyncQueue.enqueue(function(){return(0,e.__awaiter)(n,void 0,void 0,function(){var n,r;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,oa(t)];case 1:return n=e.sent(),[4,aa(t)];case 2:return r=e.sent(),[2,(n.setNetworkEnabled(!0),function(t){var e=m(r);return e.Or.delete(0),_o(e)}())]}})})})}(Ka(Da(this._delegate,ja)))},t.prototype.disableNetwork=function(){return function(t){var n=this;return t.asyncQueue.enqueue(function(){return(0,e.__awaiter)(n,void 0,void 0,function(){var n,r;return(0,e.__generator)(this,function(i){switch(i.label){case 0:return[4,oa(t)];case 1:return n=i.sent(),[4,aa(t)];case 2:return r=i.sent(),[2,(n.setNetworkEnabled(!1),function(t){return(0,e.__awaiter)(this,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return(n=m(t)).Or.add(0),[4,wo(n)];case 1:return e.sent(),n.Br.set("Offline"),[2]}})})}(r))]}})})})}(Ka(Da(this._delegate,ja)))},t.prototype.enablePersistence=function(t){var e=!1,n=!1;return t&&Ea("synchronizeTabs",e=!!t.synchronizeTabs,"experimentalForceOwningTab",n=!!t.experimentalForceOwningTab),e?this.Zc.enableMultiTabIndexedDbPersistence(this):this.Zc.enableIndexedDbPersistence(this,n)},t.prototype.clearPersistence=function(){return this.Zc.clearIndexedDbPersistence(this)},t.prototype.terminate=function(){return this.tu&&(this.tu._removeServiceInstance("firestore"),this.tu._removeServiceInstance("firestore-exp")),this._delegate._delete()},t.prototype.waitForPendingWrites=function(){return function(t){var n=this,r=new er;return t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(n,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return n=Is,[4,ua(t)];case 1:return[2,n.apply(void 0,[e.sent(),r])]}})})}),r.promise}(Ka(Da(this._delegate,ja)))},t.prototype.onSnapshotsInSync=function(t){return function(t,n){return function(t,n){var r=this,i=new $s(n);return t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(r,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return n=function(t,e){m(t).Gr.add(e),e.next()},[4,ca(t)];case 1:return[2,n.apply(void 0,[e.sent(),i])]}})})}),function(){i.Wo(),t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(r,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return n=function(t,e){m(t).Gr.delete(e)},[4,ca(t)];case 1:return[2,n.apply(void 0,[e.sent(),i])]}})})})}}(Ka(t=Da(t,ja)),qa(n)?n:{next:n})}(this._delegate,t)},Object.defineProperty(t.prototype,"app",{get:function(){if(!this.tu)throw new u(a.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.tu},enumerable:!1,configurable:!0}),t.prototype.collection=function(t){try{return new bc(this,Oa(this._delegate,t))}catch(t){throw dc(t,"collection()","Firestore.collection()")}},t.prototype.doc=function(t){try{return new lc(this,Pa(this._delegate,t))}catch(t){throw dc(t,"doc()","Firestore.doc()")}},t.prototype.collectionGroup=function(t){try{return new gc(this,function(t,e){if(t=Da(t,ka),ba("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new u(a.INVALID_ARGUMENT,"Invalid collection ID '"+e+"' passed to function collectionGroup(). Collection IDs must not contain '/'.");return new Ra(t,null,function(t){return new At(x.emptyPath(),t)}(e))}(this._delegate,t))}catch(t){throw dc(t,"collectionGroup()","Firestore.collectionGroup()")}},t.prototype.runTransaction=function(t){var n=this;return function(t,n){return function(t,n){var r=this,i=new er;return t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(r,void 0,void 0,function(){var r;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return[4,function(t){return ia(t).then(function(t){return t.datastore})}(t)];case 1:return r=e.sent(),new Zs(t.asyncQueue,r,n,i).run(),[2]}})})}),i.promise}(Ka(t),function(e){return n(new ec(t,e))})}(this._delegate,function(e){return t(new cc(n,e))})},t.prototype.batch=function(){var t=this;return Ka(this._delegate),new hc(new Wu(this._delegate,function(e){return Zu(t._delegate,e)}))},t.prototype.loadBundle=function(t){throw new u(a.FAILED_PRECONDITION,'"loadBundle()" does not exist, have you imported "firebase/firestore/bundle"?')},t.prototype.namedQuery=function(t){throw new u(a.FAILED_PRECONDITION,'"namedQuery()" does not exist, have you imported "firebase/firestore/bundle"?')},t}(),ac=function(t){function n(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return(0,e.__extends)(n,t),n.prototype.convertBytes=function(t){return new ic(new Ha(t))},n.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);return lc.eu(e,this.firestore,null)},n}(Gu);function uc(t){var e;e=t,c.setLogLevel(e)}exports.K=sc,exports.U=oc,exports.L=ic;var cc=function(){function t(t,e){this._firestore=t,this._delegate=e,this._userDataWriter=new ac(t)}return t.prototype.get=function(t){var e=this,n=Ic(t);return this._delegate.get(n).then(function(t){return new vc(e._firestore,new Du(e._firestore._delegate,e._userDataWriter,t._key,t._document,t.metadata,n.converter))})},t.prototype.set=function(t,e,n){var r=Ic(t);return n?(Ia("Transaction.set",n),this._delegate.set(r,e,n)):this._delegate.set(r,e),this},t.prototype.update=function(t,n,r){for(var i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];var a=Ic(t);return 2===arguments.length?this._delegate.update(a,n):(i=this._delegate).update.apply(i,(0,e.__spreadArray)([a,n,r],o)),this},t.prototype.delete=function(t){var e=Ic(t);return this._delegate.delete(e),this},t}(),hc=function(){function t(t){this._delegate=t}return t.prototype.set=function(t,e,n){var r=Ic(t);return n?(Ia("WriteBatch.set",n),this._delegate.set(r,e,n)):this._delegate.set(r,e),this},t.prototype.update=function(t,n,r){for(var i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];var a=Ic(t);return 2===arguments.length?this._delegate.update(a,n):(i=this._delegate).update.apply(i,(0,e.__spreadArray)([a,n,r],o)),this},t.prototype.delete=function(t){var e=Ic(t);return this._delegate.delete(e),this},t.prototype.commit=function(){return this._delegate.commit()},t}(),fc=function(){function t(t,e,n){this._firestore=t,this._userDataWriter=e,this._delegate=n}return t.prototype.fromFirestore=function(t,e){var n=new Au(this._firestore._delegate,this._userDataWriter,t._key,t._document,t.metadata,null);return this._delegate.fromFirestore(new mc(this._firestore,n),null!=e?e:{})},t.prototype.toFirestore=function(t,e){return e?this._delegate.toFirestore(t,e):this._delegate.toFirestore(t)},t.nu=function(e,n){var r=t.su,i=r.get(e);i||(i=new WeakMap,r.set(e,i));var o=i.get(n);return o||(o=new t(e,new ac(e),n),i.set(n,o)),o},t}();exports.G=hc,exports.W=cc,fc.su=new WeakMap;var lc=function(){function t(t,e){this.firestore=t,this._delegate=e,this._userDataWriter=new ac(t)}return t.iu=function(e,n,r){if(e.length%2!=0)throw new u(a.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+e.canonicalString()+" has "+e.length);return new t(n,new Ca(n._delegate,r,new G(e)))},t.eu=function(e,n,r){return new t(n,new Ca(n._delegate,r,e))},Object.defineProperty(t.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return new bc(this.firestore,this._delegate.parent)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this._delegate.path},enumerable:!1,configurable:!0}),t.prototype.collection=function(t){try{return new bc(this.firestore,Oa(this._delegate,t))}catch(t){throw dc(t,"collection()","DocumentReference.collection()")}},t.prototype.isEqual=function(t){return(t=(0,n.getModularInstance)(t))instanceof Ca&&Fa(this._delegate,t)},t.prototype.set=function(t,e){e=Ia("DocumentReference.set",e);try{return e?$u(this._delegate,t,e):$u(this._delegate,t)}catch(t){throw dc(t,"setDoc()","DocumentReference.set()")}},t.prototype.update=function(t,n){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];try{return 1===arguments.length?Xu(this._delegate,t):Xu.apply(void 0,(0,e.__spreadArray)([this._delegate,t,n],r))}catch(t){throw dc(t,"updateDoc()","DocumentReference.update()")}},t.prototype.delete=function(){return Zu(Da((t=this._delegate).firestore,ja),[new Ee(t._key,ue.none())]);var t},t.prototype.onSnapshot=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=pc(e),i=yc(e,function(e){return new vc(t.firestore,new Du(t.firestore._delegate,t._userDataWriter,e._key,e._document,e.metadata,t._delegate.converter))});return Ju(this._delegate,r,i)},t.prototype.get=function(t){var n=this;return("cache"===(null==t?void 0:t.source)?function(t){t=Da(t,Ca);var n=Da(t.firestore,ja),r=Ka(n),i=new Yu(n);return function(t,n){var r=this,i=new er;return t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(r,void 0,void 0,function(){var r;return(0,e.__generator)(this,function(o){switch(o.label){case 0:return r=function(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i,o;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,function(t,e){var n=m(t);return n.persistence.runTransaction("read document","readonly",function(t){return n.Mn.mn(t,e)})}(t,n)];case 1:return(o=e.sent()).isFoundDocument()?r.resolve(o):o.isNoDocument()?r.resolve(null):r.reject(new u(a.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)")),[3,3];case 2:return i=e.sent(),o=Qo(i,"Failed to get document '"+n+" from cache"),r.reject(o),[3,3];case 3:return[2]}})})},[4,sa(t)];case 1:return[2,r.apply(void 0,[o.sent(),n,i])]}})})}),i.promise}(r,t._key).then(function(e){return new Du(n,i,t._key,e,new Nu(null!==e&&e.hasLocalMutations,!0),t.converter)})}(this._delegate):"server"===(null==t?void 0:t.source)?function(t){t=Da(t,Ca);var e=Da(t.firestore,ja);return ha(Ka(e),t._key,{source:"server"}).then(function(n){return tc(e,t,n)})}(this._delegate):function(t){t=Da(t,Ca);var e=Da(t.firestore,ja);return ha(Ka(e),t._key).then(function(n){return tc(e,t,n)})}(this._delegate)).then(function(t){return new vc(n.firestore,new Du(n.firestore._delegate,n._userDataWriter,t._key,t._document,t.metadata,n._delegate.converter))})},t.prototype.withConverter=function(e){return new t(this.firestore,e?this._delegate.withConverter(fc.nu(this.firestore,e)):this._delegate.withConverter(null))},t}();function dc(t,e,n){return t.message=t.message.replace(e,n),t}function pc(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];if("object"==o(r)&&!qa(r))return r}return{}}function yc(t,e){var n,r,i;return{next:function(t){i.next&&i.next(e(t))},error:null===(n=(i=qa(t[0])?t[0]:qa(t[1])?t[1]:"function"==typeof t[0]?{next:t[0],error:t[1],complete:t[2]}:{next:t[1],error:t[2],complete:t[3]}).error)||void 0===n?void 0:n.bind(i),complete:null===(r=i.complete)||void 0===r?void 0:r.bind(i)}}exports.H=lc;var vc=function(){function t(t,e){this._firestore=t,this._delegate=e}return Object.defineProperty(t.prototype,"ref",{get:function(){return new lc(this._firestore,this._delegate.ref)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metadata",{get:function(){return this._delegate.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"exists",{get:function(){return this._delegate.exists()},enumerable:!1,configurable:!0}),t.prototype.data=function(t){return this._delegate.data(t)},t.prototype.get=function(t,e){return this._delegate.get(t,e)},t.prototype.isEqual=function(t){return Cu(this._delegate,t._delegate)},t}(),mc=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return(0,e.__extends)(n,t),n.prototype.data=function(t){return this._delegate.data(t)},n}(vc),gc=function(){function t(t,e){this.firestore=t,this._delegate=e,this._userDataWriter=new ac(t)}return t.prototype.where=function(e,n,r){try{return new t(this.firestore,Ou(this._delegate,function(t,e,n){var r=e,i=Su("where",t);return new Pu(i,r,n)}(e,n,r)))}catch(e){throw dc(e,/(orderBy|where)\(\)/,"Query.$1()")}},t.prototype.orderBy=function(e,n){try{return new t(this.firestore,Ou(this._delegate,function(t,e){void 0===e&&(e="asc");var n=e,r=Su("orderBy",t);return new Fu(r,n)}(e,n)))}catch(e){throw dc(e,/(orderBy|where)\(\)/,"Query.$1()")}},t.prototype.limit=function(e){try{return new t(this.firestore,Ou(this._delegate,function(t){return Aa("limit",t),new Mu("limit",t,"F")}(e)))}catch(e){throw dc(e,"limit()","Query.limit()")}},t.prototype.limitToLast=function(e){try{return new t(this.firestore,Ou(this._delegate,function(t){return Aa("limitToLast",t),new Mu("limitToLast",t,"L")}(e)))}catch(e){throw dc(e,"limitToLast()","Query.limitToLast()")}},t.prototype.startAt=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Ou(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Vu("startAt",t,!0)}.apply(void 0,e)))}catch(e){throw dc(e,"startAt()","Query.startAt()")}},t.prototype.startAfter=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Ou(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Vu("startAfter",t,!1)}.apply(void 0,e)))}catch(e){throw dc(e,"startAfter()","Query.startAfter()")}},t.prototype.endBefore=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Ou(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new qu("endBefore",t,!0)}.apply(void 0,e)))}catch(e){throw dc(e,"endBefore()","Query.endBefore()")}},t.prototype.endAt=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Ou(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new qu("endAt",t,!1)}.apply(void 0,e)))}catch(e){throw dc(e,"endAt()","Query.endAt()")}},t.prototype.isEqual=function(t){return Ma(this._delegate,t._delegate)},t.prototype.get=function(t){var n=this;return("cache"===(null==t?void 0:t.source)?function(t){t=Da(t,Ra);var n=Da(t.firestore,ja),r=Ka(n),i=new Yu(n);return function(t,n){var r=this,i=new er;return t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(r,void 0,void 0,function(){var r;return(0,e.__generator)(this,function(o){switch(o.label){case 0:return r=function(t,n,r){return(0,e.__awaiter)(this,void 0,void 0,function(){var i,o,s,a,u;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,ki(t,n,!0)];case 1:return u=e.sent(),i=new cs(n,u.Bn),o=i._o(u.documents),s=i.applyChanges(o,!1),r.resolve(s.snapshot),[3,3];case 2:return a=e.sent(),u=Qo(a,"Failed to execute query '"+n+" against cache"),r.reject(u),[3,3];case 3:return[2]}})})},[4,sa(t)];case 1:return[2,r.apply(void 0,[o.sent(),n,i])]}})})}),i.promise}(r,t._query).then(function(e){return new xu(n,i,t,e)})}(this._delegate):"server"===(null==t?void 0:t.source)?function(t){t=Da(t,Ra);var e=Da(t.firestore,ja),n=Ka(e),r=new Yu(e);return fa(n,t._query,{source:"server"}).then(function(n){return new xu(e,r,t,n)})}(this._delegate):function(t){t=Da(t,Ra);var e=Da(t.firestore,ja),n=Ka(e),r=new Yu(e);return Ru(t._query),fa(n,t._query).then(function(n){return new xu(e,r,t,n)})}(this._delegate)).then(function(t){return new wc(n.firestore,new xu(n.firestore._delegate,n._userDataWriter,n._delegate,t._snapshot))})},t.prototype.onSnapshot=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=pc(e),i=yc(e,function(e){return new wc(t.firestore,new xu(t.firestore._delegate,t._userDataWriter,t._delegate,e._snapshot))});return Ju(this._delegate,r,i)},t.prototype.withConverter=function(e){return new t(this.firestore,e?this._delegate.withConverter(fc.nu(this.firestore,e)):this._delegate.withConverter(null))},t}(),_c=function(){function t(t,e){this._firestore=t,this._delegate=e}return Object.defineProperty(t.prototype,"type",{get:function(){return this._delegate.type},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"doc",{get:function(){return new mc(this._firestore,this._delegate.doc)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"oldIndex",{get:function(){return this._delegate.oldIndex},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"newIndex",{get:function(){return this._delegate.newIndex},enumerable:!1,configurable:!0}),t}(),wc=function(){function t(t,e){this._firestore=t,this._delegate=e}return Object.defineProperty(t.prototype,"query",{get:function(){return new gc(this._firestore,this._delegate.query)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metadata",{get:function(){return this._delegate.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this._delegate.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"empty",{get:function(){return this._delegate.empty},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"docs",{get:function(){var t=this;return this._delegate.docs.map(function(e){return new mc(t._firestore,e)})},enumerable:!1,configurable:!0}),t.prototype.docChanges=function(t){var e=this;return this._delegate.docChanges(t).map(function(t){return new _c(e._firestore,t)})},t.prototype.forEach=function(t,e){var n=this;this._delegate.forEach(function(r){t.call(e,new mc(n._firestore,r))})},t.prototype.isEqual=function(t){return Cu(this._delegate,t._delegate)},t}(),bc=function(t){function n(e,n){var r=this;return(r=t.call(this,e,n)||this).firestore=e,r._delegate=n,r}return(0,e.__extends)(n,t),Object.defineProperty(n.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"path",{get:function(){return this._delegate.path},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){var t=this._delegate.parent;return t?new lc(this.firestore,t):null},enumerable:!1,configurable:!0}),n.prototype.doc=function(t){try{return new lc(this.firestore,void 0===t?Pa(this._delegate):Pa(this._delegate,t))}catch(t){throw dc(t,"doc()","CollectionReference.doc()")}},n.prototype.add=function(t){var e=this;return function(t,e){var n=Da(t.firestore,ja),r=Pa(t),i=Qu(t.converter,e);return Zu(n,[iu(ru(t.firestore),"addDoc",r._key,i,null!==t.converter,{}).toMutation(r._key,ue.exists(!1))]).then(function(){return r})}(this._delegate,t).then(function(t){return new lc(e.firestore,t)})},n.prototype.isEqual=function(t){return Fa(this._delegate,t._delegate)},n.prototype.withConverter=function(t){return new n(this.firestore,t?this._delegate.withConverter(fc.nu(this.firestore,t)):this._delegate.withConverter(null))},n}(gc);function Ic(t){return Da(t,Ca)}exports.i=bc,exports.s=wc,exports.e=gc,exports.t=mc,exports.Z=vc;var Ec=function(){function t(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._delegate=new(Wa.bind.apply(Wa,(0,e.__spreadArray)([void 0],t)))}return t.documentId=function(){return new t(C.keyField().canonicalString())},t.prototype.isEqual=function(t){return(t=(0,n.getModularInstance)(t))instanceof Wa&&this._delegate._internalPath.isEqual(t._internalPath)},t}(),Tc=function(){function t(t){this._delegate=t}return t.serverTimestamp=function(){var e=new au("serverTimestamp");return e._methodName="FieldValue.serverTimestamp",new t(e)},t.delete=function(){var e=new ou("deleteField");return e._methodName="FieldValue.delete",new t(e)},t.arrayUnion=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new uu("arrayUnion",t)}.apply(void 0,e);return r._methodName="FieldValue.arrayUnion",new t(r)},t.arrayRemove=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new cu("arrayRemove",t)}.apply(void 0,e);return r._methodName="FieldValue.arrayRemove",new t(r)},t.increment=function(e){var n=new hu("increment",e);return n._methodName="FieldValue.increment",new t(n)},t.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},t}();function Sc(t){return function(t,n){var r=Ka(t=Da(t,ja)),i=new Ua;return function(t,n,r,i){var o=this,s=function(t,e){return function(t,e){return new Xs(t,e)}(function(t,e){if(t instanceof Uint8Array)return Ys(t,e);if(t instanceof ArrayBuffer)return Ys(new Uint8Array(t),e);if(t instanceof ReadableStream)return t.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}("string"==typeof t?(new TextEncoder).encode(t):t),e)}(r,ho(n));t.asyncQueue.enqueueAndForget(function(){return(0,e.__awaiter)(o,void 0,void 0,function(){var n;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return n=Gs,[4,ua(t)];case 1:return n.apply(void 0,[e.sent(),s,i]),[2]}})})})}(r,t._databaseId,n,i),i}(this._delegate,t)}function Nc(t){var n,r,i=this;return(n=this._delegate,r=t,function(t,n){var r=this;return t.asyncQueue.enqueue(function(){return(0,e.__awaiter)(r,void 0,void 0,function(){var r;return(0,e.__generator)(this,function(e){switch(e.label){case 0:return r=function(t,e){var n=m(t);return n.persistence.runTransaction("Get named query","readonly",function(t){return n.Ke.getNamedQuery(t,e)})},[4,sa(t)];case 1:return[2,r.apply(void 0,[e.sent(),n])]}})})})}(Ka(n=Da(n,ja)),r).then(function(t){return t?new Ra(n,null,t.query):null})).then(function(t){return t?new gc(i,t):null})}exports.c=Tc,exports.o=Ec;
|
|
494
|
-
},{"
|
|
495
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.registerFirestore=o;var e=i(require("@firebase/app")),r=require("./prebuilt-2d830653-6eee25bb.js"),t=require("@firebase/component");function i(e){return e&&e.__esModule?e:{default:e}}require("tslib"),require("@firebase/util"),require("@firebase/logger"),require("@firebase/webchannel-wrapper");var n={Firestore:r.K,GeoPoint:r.C,Timestamp:r.M,Blob:r.L,Transaction:r.W,WriteBatch:r.G,DocumentReference:r.H,DocumentSnapshot:r.Z,Query:r.e,QueryDocumentSnapshot:r.t,QuerySnapshot:r.s,CollectionReference:r.i,FieldPath:r.o,FieldValue:r.c,setLogLevel:r.j,CACHE_SIZE_UNLIMITED:r.E};function o(e){!function(e,i){e.INTERNAL.registerComponent(new t.Component("firestore",function(e){return function(e,t){return new r.K(e,new r.T(e,t),new r.U)}(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"))},"PUBLIC").setServiceProps(Object.assign({},n)))}(e),e.registerVersion("@firebase/firestore","2.4.1")}o(e.default);
|
|
496
|
-
},{"@firebase/app
|
|
497
|
-
"use strict";require("@firebase/firestore");
|
|
498
|
-
},{"@firebase/firestore":"
|
|
507
|
+
var e,t=require("process");Object.defineProperty(exports,"__esModule",{value:!0}),exports._FieldPath=exports._EmptyAuthCredentialsProvider=exports._EmptyAppCheckTokenProvider=exports._DocumentKey=exports._DatabaseId=exports.WriteBatch=exports.Transaction=exports.Timestamp=exports.SnapshotMetadata=exports.QueryStartAtConstraint=exports.QuerySnapshot=exports.QueryOrderByConstraint=exports.QueryLimitConstraint=exports.QueryFieldFilterConstraint=exports.QueryEndAtConstraint=exports.QueryDocumentSnapshot=exports.QueryConstraint=exports.QueryCompositeFilterConstraint=exports.Query=exports.LoadBundleTask=exports.GeoPoint=exports.FirestoreError=exports.Firestore=exports.FieldValue=exports.FieldPath=exports.DocumentSnapshot=exports.DocumentReference=exports.CollectionReference=exports.CACHE_SIZE_UNLIMITED=exports.Bytes=exports.AggregateQuerySnapshot=exports.AggregateField=exports.AbstractUserDataWriter=void 0,exports._cast=rl,exports._debugAssert=X,exports._isBase64Available=ut,exports._logWarn=j,exports._validateIsNotUsedTogether=$c,exports.addDoc=yh,exports.aggregateFieldEqual=Jf,exports.aggregateQuerySnapshotEqual=Zf,exports.and=_f,exports.arrayRemove=Nh,exports.arrayUnion=Dh,exports.average=Xf,exports.clearIndexedDbPersistence=Al,exports.collection=fl,exports.collectionGroup=hl,exports.connectFirestoreEmulator=ol,exports.count=Yf,exports.deleteDoc=vh,exports.deleteField=_h,exports.disableNetwork=Cl,exports.doc=dl,exports.documentId=Ul,exports.enableIndexedDbPersistence=El,exports.enableMultiTabIndexedDbPersistence=Sl,exports.enableNetwork=Nl,exports.endAt=Vf,exports.endBefore=Of,exports.ensureFirestoreConfigured=Il,exports.executeWrite=gh,exports.getAggregateFromServer=xh,exports.getCountFromServer=wh,exports.getDoc=ah,exports.getDocFromCache=oh,exports.getDocFromServer=sh,exports.getDocs=ch,exports.getDocsFromCache=lh,exports.getDocsFromServer=fh,exports.getFirestore=bl,exports.increment=Ch,exports.initializeFirestore=xl,exports.limit=Cf,exports.limitToLast=Pf,exports.loadBundle=Fl,exports.namedQuery=Ll,exports.onSnapshot=ph,exports.onSnapshotsInSync=mh,exports.or=Sf,exports.orderBy=Df,exports.query=bf,exports.queryEqual=yl,exports.refEqual=vl,exports.runTransaction=Sh,exports.serverTimestamp=Ah,exports.setDoc=hh,exports.setIndexConfiguration=Fh,exports.setLogLevel=K,exports.snapshotEqual=ih,exports.startAfter=Rf,exports.startAt=Lf,exports.sum=Hf,exports.terminate=Pl,exports.updateDoc=dh,exports.waitForPendingWrites=Dl,exports.where=Tf,exports.writeBatch=Ph;var n=require("@firebase/app"),r=require("@firebase/component"),i=require("@firebase/logger"),a=require("@firebase/util"),u=require("@firebase/webchannel-wrapper");function o(){return(o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=s(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}}).apply(this,arguments)}function s(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=T(e)););return e}function c(e,t){return h(e)||f(e,t)||_(e,t)||l()}function l(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,u,o=[],s=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=a.call(n)).done)&&(o.push(r.value),o.length!==t);s=!0);}catch(l){c=!0,i=l}finally{try{if(!s&&null!=n.return&&(u=n.return(),Object(u)!==u))return}finally{if(c)throw i}}return o}}function h(e){if(Array.isArray(e))return e}function d(e){var t="function"==typeof Map?new Map:void 0;return(d=function(e){if(null===e||!y(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return v(e,arguments,T(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),k(n,e)})(e)}function v(e,t,n){return(v=I()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&k(i,n.prototype),i}).apply(null,arguments)}function y(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function p(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=_(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return u=e.done,e},e:function(e){o=!0,a=e},f:function(){try{u||null==n.return||n.return()}finally{if(o)throw a}}}}function m(){"use strict";m=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",o=i.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(D){s=function(e,t,n){return e[t]=n}}function c(e,t,n,i){var a=t&&t.prototype instanceof h?t:h,u=Object.create(a.prototype),o=new S(i||[]);return r(u,"_invoke",{value:b(e,n,o)}),u}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(D){return{type:"throw",arg:D}}}e.wrap=c;var f={};function h(){}function d(){}function v(){}var y={};s(y,a,function(){return this});var p=Object.getPrototypeOf,g=p&&p(p(_([])));g&&g!==t&&n.call(g,a)&&(y=g);var k=v.prototype=h.prototype=Object.create(y);function w(e){["next","throw","return"].forEach(function(t){s(e,t,function(e){return this._invoke(t,e)})})}function x(e,t){var i;r(this,"_invoke",{value:function(r,a){function u(){return new t(function(i,u){!function r(i,a,u,o){var s=l(e[i],e,a);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==C(f)&&n.call(f,"__await")?t.resolve(f.__await).then(function(e){r("next",e,u,o)},function(e){r("throw",e,u,o)}):t.resolve(f).then(function(e){c.value=e,u(c)},function(e){return r("throw",e,u,o)})}o(s.arg)}(r,a,i,u)})}return i=i?i.then(u,u):u()}})}function b(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return A()}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var o=I(u,n);if(o){if(o===f)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=l(e,t,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}function I(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,I(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var i=l(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function _(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return d.prototype=v,r(k,"constructor",{value:v,configurable:!0}),r(v,"constructor",{value:d,configurable:!0}),d.displayName=s(v,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,s(e,o,"GeneratorFunction")),e.prototype=Object.create(k),e},e.awrap=function(e){return{__await:e}},w(x.prototype),s(x.prototype,u,function(){return this}),e.AsyncIterator=x,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var u=new x(c(t,n,r,i),a);return e.isGeneratorFunction(n)?u:u.next().then(function(e){return e.done?e.value:u.next()})},w(k),s(k,o,"Generator"),s(k,a,function(){return this}),s(k,"toString",function(){return"[object Generator]"}),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=_,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return u.type="throw",u.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var o=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(o&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var u=a?a.completion:{};return u.type=e,u.arg=t,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(u)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),E(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;E(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:_(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function g(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&k(e,t)}function k(e,t){return(k=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function w(e){var t=I();return function(){var n,r=T(e);if(t){var i=T(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return x(this,n)}}function x(e,t){if(t&&("object"===C(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return b(e)}function b(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function I(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function T(e){return(T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e){return D(e)||A(e)||_(e)||S()}function S(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _(e,t){if(e){if("string"==typeof e)return N(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?N(e,t):void 0}}function A(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function D(e){if(Array.isArray(e))return N(e)}function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function C(e){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function P(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function F(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,R(r.key),r)}}function L(e,t,n){return t&&F(e.prototype,t),n&&F(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function R(e){var t=M(e,"string");return"symbol"===C(t)?t:String(t)}function M(e,t){if("object"!==C(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==C(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var O="@firebase/firestore",V=function(){function e(t){P(this,e),this.uid=t}return L(e,[{key:"isAuthenticated",value:function(){return null!=this.uid}},{key:"toKey",value:function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}},{key:"isEqual",value:function(e){return e.uid===this.uid}}]),e}();V.UNAUTHENTICATED=new V(null),V.GOOGLE_CREDENTIALS=new V("google-credentials-uid"),V.FIRST_PARTY=new V("first-party-uid"),V.MOCK_USER=new V("mock-user");var q="9.18.0",U=new i.Logger("@firebase/firestore");function B(){return U.logLevel}function K(e){U.setLogLevel(e)}function G(e){if(U.logLevel<=i.LogLevel.DEBUG){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var a=n.map(z);U.debug.apply(U,["Firestore (".concat(q,"): ").concat(e)].concat(E(a)))}}function Q(e){if(U.logLevel<=i.LogLevel.ERROR){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var a=n.map(z);U.error.apply(U,["Firestore (".concat(q,"): ").concat(e)].concat(E(a)))}}function j(e){if(U.logLevel<=i.LogLevel.WARN){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var a=n.map(z);U.warn.apply(U,["Firestore (".concat(q,"): ").concat(e)].concat(E(a)))}}function z(e){if("string"==typeof e)return e;try{return t=e,JSON.stringify(t)}catch(t){return e}var t}function W(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unexpected state",t="FIRESTORE (".concat(q,") INTERNAL ASSERTION FAILED: ")+e;throw Q(t),new Error(t)}function H(e,t){e||W()}function X(e,t){e||W()}function Y(e,t){return e}var J={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},Z=function(e){g(n,a.FirebaseError);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this,e,r)).code=e,i.message=r,i.toString=function(){return"".concat(i.name,": [code=").concat(i.code,"]: ").concat(i.message)},i}return L(n)}();exports.FirestoreError=Z;var $=L(function e(){var t=this;P(this,e),this.promise=new Promise(function(e,n){t.resolve=e,t.reject=n})}),ee=L(function e(t,n){P(this,e),this.user=n,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization","Bearer ".concat(t))}),te=function(){function e(){P(this,e)}return L(e,[{key:"getToken",value:function(){return Promise.resolve(null)}},{key:"invalidateToken",value:function(){}},{key:"start",value:function(e,t){e.enqueueRetryable(function(){return t(V.UNAUTHENTICATED)})}},{key:"shutdown",value:function(){}}]),e}();exports._EmptyAuthCredentialsProvider=te;var ne=function(){function e(t){P(this,e),this.token=t,this.changeListener=null}return L(e,[{key:"getToken",value:function(){return Promise.resolve(this.token)}},{key:"invalidateToken",value:function(){}},{key:"start",value:function(e,t){var n=this;this.changeListener=t,e.enqueueRetryable(function(){return t(n.token.user)})}},{key:"shutdown",value:function(){this.changeListener=null}}]),e}(),re=function(){function e(t){P(this,e),this.t=t,this.currentUser=V.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}return L(e,[{key:"start",value:function(e,t){var n=this,r=this.i,i=function(e){return n.i!==r?(r=n.i,t(e)):Promise.resolve()},a=new $;this.o=function(){n.i++,n.currentUser=n.u(),a.resolve(),a=new $,e.enqueueRetryable(function(){return i(n.currentUser)})};var u=function(){var t=a;e.enqueueRetryable(function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m().awrap(t.promise);case 2:return e.next=4,m().awrap(i(n.currentUser));case 4:case"end":return e.stop()}},null,null,null,Promise)})},o=function(e){G("FirebaseAuthCredentialsProvider","Auth detected"),n.auth=e,n.auth.addAuthTokenListener(n.o),u()};this.t.onInit(function(e){return o(e)}),setTimeout(function(){if(!n.auth){var e=n.t.getImmediate({optional:!0});e?o(e):(G("FirebaseAuthCredentialsProvider","Auth not yet detected"),a.resolve(),a=new $)}},0),u()}},{key:"getToken",value:function(){var e=this,t=this.i,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then(function(n){return e.i!==t?(G("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),e.getToken()):n?(H("string"==typeof n.accessToken),new ee(n.accessToken,e.currentUser)):null}):Promise.resolve(null)}},{key:"invalidateToken",value:function(){this.forceRefresh=!0}},{key:"shutdown",value:function(){this.auth&&this.auth.removeAuthTokenListener(this.o)}},{key:"u",value:function(){var e=this.auth&&this.auth.getUid();return H(null===e||"string"==typeof e),new V(e)}}]),e}(),ie=function(){function e(t,n,r,i){P(this,e),this.h=t,this.l=n,this.m=r,this.g=i,this.type="FirstParty",this.user=V.FIRST_PARTY,this.p=new Map}return L(e,[{key:"I",value:function(){return this.g?this.g():(H(!("object"!=C(this.h)||null===this.h||!this.h.auth||!this.h.auth.getAuthHeaderValueForFirstParty)),this.h.auth.getAuthHeaderValueForFirstParty([]))}},{key:"headers",get:function(){this.p.set("X-Goog-AuthUser",this.l);var e=this.I();return e&&this.p.set("Authorization",e),this.m&&this.p.set("X-Goog-Iam-Authorization-Token",this.m),this.p}}]),e}(),ae=function(){function e(t,n,r,i){P(this,e),this.h=t,this.l=n,this.m=r,this.g=i}return L(e,[{key:"getToken",value:function(){return Promise.resolve(new ie(this.h,this.l,this.m,this.g))}},{key:"start",value:function(e,t){e.enqueueRetryable(function(){return t(V.FIRST_PARTY)})}},{key:"shutdown",value:function(){}},{key:"invalidateToken",value:function(){}}]),e}(),ue=L(function e(t){P(this,e),this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}),oe=function(){function e(t){P(this,e),this.T=t,this.forceRefresh=!1,this.appCheck=null,this.A=null}return L(e,[{key:"start",value:function(e,t){var n=this,r=function(e){null!=e.error&&G("FirebaseAppCheckTokenProvider","Error getting App Check token; using placeholder token instead. Error: ".concat(e.error.message));var r=e.token!==n.A;return n.A=e.token,G("FirebaseAppCheckTokenProvider","Received ".concat(r?"new":"existing"," token.")),r?t(e.token):Promise.resolve()};this.o=function(t){e.enqueueRetryable(function(){return r(t)})};var i=function(e){G("FirebaseAppCheckTokenProvider","AppCheck detected"),n.appCheck=e,n.appCheck.addTokenListener(n.o)};this.T.onInit(function(e){return i(e)}),setTimeout(function(){if(!n.appCheck){var e=n.T.getImmediate({optional:!0});e?i(e):G("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}},{key:"getToken",value:function(){var e=this,t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then(function(t){return t?(H("string"==typeof t.token),e.A=t.token,new ue(t.token)):null}):Promise.resolve(null)}},{key:"invalidateToken",value:function(){this.forceRefresh=!0}},{key:"shutdown",value:function(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}]),e}(),se=function(){function e(){P(this,e)}return L(e,[{key:"getToken",value:function(){return Promise.resolve(new ue(""))}},{key:"invalidateToken",value:function(){}},{key:"start",value:function(e,t){}},{key:"shutdown",value:function(){}}]),e}();function ce(e){var t="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&"function"==typeof t.getRandomValues)t.getRandomValues(n);else for(var r=0;r<e;r++)n[r]=Math.floor(256*Math.random());return n}exports._EmptyAppCheckTokenProvider=se;var le=function(){function e(){P(this,e)}return L(e,null,[{key:"R",value:function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=Math.floor(256/e.length)*e.length,n="";n.length<20;)for(var r=ce(40),i=0;i<r.length;++i)n.length<20&&r[i]<t&&(n+=e.charAt(r[i]%e.length));return n}}]),e}();function fe(e,t){return e<t?-1:e>t?1:0}function he(e,t,n){return e.length===t.length&&e.every(function(e,r){return n(e,t[r])})}function de(e){return e+"\0"}var ve=function(){function e(t,n){if(P(this,e),this.seconds=t,this.nanoseconds=n,n<0)throw new Z(J.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(n>=1e9)throw new Z(J.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+n);if(t<-62135596800)throw new Z(J.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new Z(J.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}return L(e,[{key:"toDate",value:function(){return new Date(this.toMillis())}},{key:"toMillis",value:function(){return 1e3*this.seconds+this.nanoseconds/1e6}},{key:"_compareTo",value:function(e){return this.seconds===e.seconds?fe(this.nanoseconds,e.nanoseconds):fe(this.seconds,e.seconds)}},{key:"isEqual",value:function(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}},{key:"toString",value:function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}},{key:"toJSON",value:function(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}},{key:"valueOf",value:function(){var e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}],[{key:"now",value:function(){return e.fromMillis(Date.now())}},{key:"fromDate",value:function(t){return e.fromMillis(t.getTime())}},{key:"fromMillis",value:function(t){var n=Math.floor(t/1e3);return new e(n,Math.floor(1e6*(t-1e3*n)))}}]),e}();exports.Timestamp=ve;var ye=function(){function e(t){P(this,e),this.timestamp=t}return L(e,[{key:"compareTo",value:function(e){return this.timestamp._compareTo(e.timestamp)}},{key:"isEqual",value:function(e){return this.timestamp.isEqual(e.timestamp)}},{key:"toMicroseconds",value:function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}},{key:"toString",value:function(){return"SnapshotVersion("+this.timestamp.toString()+")"}},{key:"toTimestamp",value:function(){return this.timestamp}}],[{key:"fromTimestamp",value:function(t){return new e(t)}},{key:"min",value:function(){return new e(new ve(0,0))}},{key:"max",value:function(){return new e(new ve(253402300799,999999999))}}]),e}(),pe=function(){function e(t,n,r){P(this,e),void 0===n?n=0:n>t.length&&W(),void 0===r?r=t.length-n:r>t.length-n&&W(),this.segments=t,this.offset=n,this.len=r}return L(e,[{key:"length",get:function(){return this.len}},{key:"isEqual",value:function(t){return 0===e.comparator(this,t)}},{key:"child",value:function(t){var n=this.segments.slice(this.offset,this.limit());return t instanceof e?t.forEach(function(e){n.push(e)}):n.push(t),this.construct(n)}},{key:"limit",value:function(){return this.offset+this.length}},{key:"popFirst",value:function(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}},{key:"popLast",value:function(){return this.construct(this.segments,this.offset,this.length-1)}},{key:"firstSegment",value:function(){return this.segments[this.offset]}},{key:"lastSegment",value:function(){return this.get(this.length-1)}},{key:"get",value:function(e){return this.segments[this.offset+e]}},{key:"isEmpty",value:function(){return 0===this.length}},{key:"isPrefixOf",value:function(e){if(e.length<this.length)return!1;for(var t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}},{key:"isImmediateParentOf",value:function(e){if(this.length+1!==e.length)return!1;for(var t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}},{key:"forEach",value:function(e){for(var t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}},{key:"toArray",value:function(){return this.segments.slice(this.offset,this.limit())}}],[{key:"comparator",value:function(e,t){for(var n=Math.min(e.length,t.length),r=0;r<n;r++){var i=e.get(r),a=t.get(r);if(i<a)return-1;if(i>a)return 1}return e.length<t.length?-1:e.length>t.length?1:0}}]),e}(),me=function(e){g(n,pe);var t=w(n);function n(){return P(this,n),t.apply(this,arguments)}return L(n,[{key:"construct",value:function(e,t,r){return new n(e,t,r)}},{key:"canonicalString",value:function(){return this.toArray().join("/")}},{key:"toString",value:function(){return this.canonicalString()}}],[{key:"fromString",value:function(){for(var e=[],t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];for(var a=0,u=r;a<u.length;a++){var o=u[a];if(o.indexOf("//")>=0)throw new Z(J.INVALID_ARGUMENT,"Invalid segment (".concat(o,"). Paths must not contain // in them."));e.push.apply(e,E(o.split("/").filter(function(e){return e.length>0})))}return new n(e)}},{key:"emptyPath",value:function(){return new n([])}}]),n}(),ge=/^[_a-zA-Z][_a-zA-Z0-9]*$/,ke=function(e){g(n,pe);var t=w(n);function n(){return P(this,n),t.apply(this,arguments)}return L(n,[{key:"construct",value:function(e,t,r){return new n(e,t,r)}},{key:"canonicalString",value:function(){return this.toArray().map(function(e){return e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),n.isValidIdentifier(e)||(e="`"+e+"`"),e}).join(".")}},{key:"toString",value:function(){return this.canonicalString()}},{key:"isKeyField",value:function(){return 1===this.length&&"__name__"===this.get(0)}}],[{key:"isValidIdentifier",value:function(e){return ge.test(e)}},{key:"keyField",value:function(){return new n(["__name__"])}},{key:"fromServerFormat",value:function(e){for(var t=[],r="",i=0,a=function(){if(0===r.length)throw new Z(J.INVALID_ARGUMENT,"Invalid field path (".concat(e,"). Paths must not be empty, begin with '.', end with '.', or contain '..'"));t.push(r),r=""},u=!1;i<e.length;){var o=e[i];if("\\"===o){if(i+1===e.length)throw new Z(J.INVALID_ARGUMENT,"Path has trailing escape character: "+e);var s=e[i+1];if("\\"!==s&&"."!==s&&"`"!==s)throw new Z(J.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=s,i+=2}else"`"===o?(u=!u,i++):"."!==o||u?(r+=o,i++):(a(),i++)}if(a(),u)throw new Z(J.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new n(t)}},{key:"emptyPath",value:function(){return new n([])}}]),n}();exports._FieldPath=ke;var we=function(){function e(t){P(this,e),this.path=t}return L(e,[{key:"collectionGroup",get:function(){return this.path.popLast().lastSegment()}},{key:"hasCollectionId",value:function(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}},{key:"getCollectionGroup",value:function(){return this.path.get(this.path.length-2)}},{key:"getCollectionPath",value:function(){return this.path.popLast()}},{key:"isEqual",value:function(e){return null!==e&&0===me.comparator(this.path,e.path)}},{key:"toString",value:function(){return this.path.toString()}}],[{key:"fromPath",value:function(t){return new e(me.fromString(t))}},{key:"fromName",value:function(t){return new e(me.fromString(t).popFirst(5))}},{key:"empty",value:function(){return new e(me.emptyPath())}},{key:"comparator",value:function(e,t){return me.comparator(e.path,t.path)}},{key:"isDocumentKey",value:function(e){return e.length%2==0}},{key:"fromSegments",value:function(t){return new e(new me(t.slice()))}}]),e}();exports._DocumentKey=we;var xe=L(function e(t,n,r,i){P(this,e),this.indexId=t,this.collectionGroup=n,this.fields=r,this.indexState=i});function be(e){return e.fields.find(function(e){return 2===e.kind})}function Ie(e){return e.fields.filter(function(e){return 2!==e.kind})}function Te(e,t){var n=fe(e.collectionGroup,t.collectionGroup);if(0!==n)return n;for(var r=0;r<Math.min(e.fields.length,t.fields.length);++r)if(0!==(n=Se(e.fields[r],t.fields[r])))return n;return fe(e.fields.length,t.fields.length)}xe.UNKNOWN_ID=-1;var Ee=L(function e(t,n){P(this,e),this.fieldPath=t,this.kind=n});function Se(e,t){var n=ke.comparator(e.fieldPath,t.fieldPath);return 0!==n?n:fe(e.kind,t.kind)}var _e=function(){function e(t,n){P(this,e),this.sequenceNumber=t,this.offset=n}return L(e,null,[{key:"empty",value:function(){return new e(0,Ne.min())}}]),e}();function Ae(e,t){var n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,i=ye.fromTimestamp(1e9===r?new ve(n+1,0):new ve(n,r));return new Ne(i,we.empty(),t)}function De(e){return new Ne(e.readTime,e.key,-1)}var Ne=function(){function e(t,n,r){P(this,e),this.readTime=t,this.documentKey=n,this.largestBatchId=r}return L(e,null,[{key:"min",value:function(){return new e(ye.min(),we.empty(),-1)}},{key:"max",value:function(){return new e(ye.max(),we.empty(),-1)}}]),e}();function Ce(e,t){var n=e.readTime.compareTo(t.readTime);return 0!==n?n:0!==(n=we.comparator(e.documentKey,t.documentKey))?n:fe(e.largestBatchId,t.largestBatchId)}var Pe="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",Fe=function(){function e(){P(this,e),this.onCommittedListeners=[]}return L(e,[{key:"addOnCommittedListener",value:function(e){this.onCommittedListeners.push(e)}},{key:"raiseOnCommittedEvent",value:function(){this.onCommittedListeners.forEach(function(e){return e()})}}]),e}();function Le(e){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.code===J.FAILED_PRECONDITION&&e.message===Pe){t.next=2;break}throw e;case 2:G("LocalStore","Unexpectedly lost primary lease");case 3:case"end":return t.stop()}},null,null,null,Promise)}var Re=function(){function e(t){var n=this;P(this,e),this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(function(e){n.isDone=!0,n.result=e,n.nextCallback&&n.nextCallback(e)},function(e){n.isDone=!0,n.error=e,n.catchCallback&&n.catchCallback(e)})}return L(e,[{key:"catch",value:function(e){return this.next(void 0,e)}},{key:"next",value:function(t,n){var r=this;return this.callbackAttached&&W(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(t,this.result):new e(function(e,i){r.nextCallback=function(n){r.wrapSuccess(t,n).next(e,i)},r.catchCallback=function(t){r.wrapFailure(n,t).next(e,i)}})}},{key:"toPromise",value:function(){var e=this;return new Promise(function(t,n){e.next(t,n)})}},{key:"wrapUserFunction",value:function(t){try{var n=t();return n instanceof e?n:e.resolve(n)}catch(t){return e.reject(t)}}},{key:"wrapSuccess",value:function(t,n){return t?this.wrapUserFunction(function(){return t(n)}):e.resolve(n)}},{key:"wrapFailure",value:function(t,n){return t?this.wrapUserFunction(function(){return t(n)}):e.reject(n)}}],[{key:"resolve",value:function(t){return new e(function(e,n){e(t)})}},{key:"reject",value:function(t){return new e(function(e,n){n(t)})}},{key:"waitFor",value:function(t){return new e(function(e,n){var r=0,i=0,a=!1;t.forEach(function(t){++r,t.next(function(){++i,a&&i===r&&e()},function(e){return n(e)})}),a=!0,i===r&&e()})}},{key:"or",value:function(t){var n,r=e.resolve(!1),i=p(t);try{var a=function(){var t=n.value;r=r.next(function(n){return n?e.resolve(n):t()})};for(i.s();!(n=i.n()).done;)a()}catch(u){i.e(u)}finally{i.f()}return r}},{key:"forEach",value:function(e,t){var n=this,r=[];return e.forEach(function(e,i){r.push(t.call(n,e,i))}),this.waitFor(r)}},{key:"mapArray",value:function(t,n){return new e(function(e,r){for(var i=t.length,a=new Array(i),u=0,o=function(){var o=s;n(t[o]).next(function(t){a[o]=t,++u===i&&e(a)},function(e){return r(e)})},s=0;s<i;s++)o()})}},{key:"doWhile",value:function(t,n){return new e(function(e,r){!function i(){!0===t()?n().next(function(){i()},r):e()}()})}}]),e}(),Me=function(){function e(t,n){var r=this;P(this,e),this.action=t,this.transaction=n,this.aborted=!1,this.P=new $,this.transaction.oncomplete=function(){r.P.resolve()},this.transaction.onabort=function(){n.error?r.P.reject(new qe(t,n.error)):r.P.resolve()},this.transaction.onerror=function(e){var n=Qe(e.target.error);r.P.reject(new qe(t,n))}}return L(e,[{key:"v",get:function(){return this.P.promise}},{key:"abort",value:function(e){e&&this.P.reject(e),this.aborted||(G("SimpleDb","Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}},{key:"V",value:function(){var e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}},{key:"store",value:function(e){var t=this.transaction.objectStore(e);return new Be(t)}}],[{key:"open",value:function(t,n,r,i){try{return new e(n,t.transaction(i,r))}catch(t){throw new qe(n,t)}}}]),e}(),Oe=function(){function e(t,n,r){P(this,e),this.name=t,this.version=n,this.S=r,12.2===e.D((0,a.getUA)())&&Q("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}return L(e,[{key:"O",value:function(e){var t=this;return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:if(n.t0=this.db,n.t0){n.next=6;break}return G("SimpleDb","Opening database:",this.name),n.next=5,m().awrap(new Promise(function(n,r){var i=indexedDB.open(t.name,t.version);i.onsuccess=function(e){var t=e.target.result;n(t)},i.onblocked=function(){r(new qe(e,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=function(t){var n=t.target.error;"VersionError"===n.name?r(new Z(J.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):"InvalidStateError"===n.name?r(new Z(J.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+n)):r(new qe(e,n))},i.onupgradeneeded=function(e){G("SimpleDb",'Database "'+t.name+'" requires upgrade from version:',e.oldVersion);var n=e.target.result;t.S.F(n,i.transaction,e.oldVersion,t.version).next(function(){G("SimpleDb","Database upgrade to version "+t.version+" complete")})}}));case 5:this.db=n.sent;case 6:return this.B&&(this.db.onversionchange=function(e){return t.B(e)}),n.abrupt("return",this.db);case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"L",value:function(e){this.B=e,this.db&&(this.db.onversionchange=function(t){return e(t)})}},{key:"runTransaction",value:function(e,t,n,r){var i,a,u,o,s=this;return m().async(function(c){for(;;)switch(c.prev=c.next){case 0:i="readonly"===t,a=0,u=function(){var t,u,o,c;return m().async(function(l){for(;;)switch(l.prev=l.next){case 0:return++a,l.prev=1,l.next=4,m().awrap(s.O(e));case 4:return s.db=l.sent,t=Me.open(s.db,e,i?"readonly":"readwrite",n),(u=r(t).next(function(e){return t.V(),e}).catch(function(e){return t.abort(e),Re.reject(e)}).toPromise()).catch(function(){}),l.next=9,m().awrap(t.v);case 9:return l.t0=u,l.abrupt("return",{v:l.t0});case 13:if(l.prev=13,l.t1=l.catch(1),o=l.t1,c="FirebaseError"!==o.name&&a<3,G("SimpleDb","Transaction failed with error:",o.message,"Retrying:",c),s.close(),c){l.next=18;break}return l.abrupt("return",{v:Promise.reject(o)});case 18:case"end":return l.stop()}},null,null,[[1,13]],Promise)};case 3:return c.next=5,m().awrap(u());case 5:if("object"!==C(o=c.sent)){c.next=8;break}return c.abrupt("return",o.v);case 8:c.next=3;break;case 10:case"end":return c.stop()}},null,null,null,Promise)}},{key:"close",value:function(){this.db&&this.db.close(),this.db=void 0}}],[{key:"delete",value:function(e){return G("SimpleDb","Removing database:",e),Ke(window.indexedDB.deleteDatabase(e)).toPromise()}},{key:"C",value:function(){if(!(0,a.isIndexedDBAvailable)())return!1;if(e.N())return!0;var t=(0,a.getUA)(),n=e.D(t),r=0<n&&n<10,i=e.k(t),u=0<i&&i<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||r||u)}},{key:"N",value:function(){var e;return void 0!==t&&"YES"===(null===(e=t.env)||void 0===e?void 0:e.$)}},{key:"M",value:function(e,t){return e.store(t)}},{key:"D",value:function(e){var t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=t?t[1].split("_").slice(0,2).join("."):"-1";return Number(n)}},{key:"k",value:function(e){var t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}}]),e}(),Ve=function(){function e(t){P(this,e),this.q=t,this.U=!1,this.K=null}return L(e,[{key:"isDone",get:function(){return this.U}},{key:"G",get:function(){return this.K}},{key:"cursor",set:function(e){this.q=e}},{key:"done",value:function(){this.U=!0}},{key:"j",value:function(e){this.K=e}},{key:"delete",value:function(){return Ke(this.q.delete())}}]),e}(),qe=function(e){g(n,Z);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this,J.UNAVAILABLE,"IndexedDB transaction '".concat(e,"' failed: ").concat(r))).name="IndexedDbTransactionError",i}return L(n)}();function Ue(e){return"IndexedDbTransactionError"===e.name}var Be=function(){function e(t){P(this,e),this.store=t}return L(e,[{key:"put",value:function(e,t){var n;return void 0!==t?(G("SimpleDb","PUT",this.store.name,e,t),n=this.store.put(t,e)):(G("SimpleDb","PUT",this.store.name,"<auto-key>",e),n=this.store.put(e)),Ke(n)}},{key:"add",value:function(e){return G("SimpleDb","ADD",this.store.name,e,e),Ke(this.store.add(e))}},{key:"get",value:function(e){var t=this;return Ke(this.store.get(e)).next(function(n){return void 0===n&&(n=null),G("SimpleDb","GET",t.store.name,e,n),n})}},{key:"delete",value:function(e){return G("SimpleDb","DELETE",this.store.name,e),Ke(this.store.delete(e))}},{key:"count",value:function(){return G("SimpleDb","COUNT",this.store.name),Ke(this.store.count())}},{key:"W",value:function(e,t){var n=this.options(e,t);if(n.index||"function"!=typeof this.store.getAll){var r=this.cursor(n),i=[];return this.H(r,function(e,t){i.push(t)}).next(function(){return i})}var a=this.store.getAll(n.range);return new Re(function(e,t){a.onerror=function(e){t(e.target.error)},a.onsuccess=function(t){e(t.target.result)}})}},{key:"J",value:function(e,t){var n=this.store.getAll(e,null===t?void 0:t);return new Re(function(e,t){n.onerror=function(e){t(e.target.error)},n.onsuccess=function(t){e(t.target.result)}})}},{key:"Y",value:function(e,t){G("SimpleDb","DELETE ALL",this.store.name);var n=this.options(e,t);n.Z=!1;var r=this.cursor(n);return this.H(r,function(e,t,n){return n.delete()})}},{key:"X",value:function(e,t){var n;t?n=e:(n={},t=e);var r=this.cursor(n);return this.H(r,t)}},{key:"tt",value:function(e){var t=this.cursor({});return new Re(function(n,r){t.onerror=function(e){var t=Qe(e.target.error);r(t)},t.onsuccess=function(t){var r=t.target.result;r?e(r.primaryKey,r.value).next(function(e){e?r.continue():n()}):n()}})}},{key:"H",value:function(e,t){var n=[];return new Re(function(r,i){e.onerror=function(e){i(e.target.error)},e.onsuccess=function(e){var i=e.target.result;if(i){var a=new Ve(i),u=t(i.primaryKey,i.value,a);if(u instanceof Re){var o=u.catch(function(e){return a.done(),Re.reject(e)});n.push(o)}a.isDone?r():null===a.G?i.continue():i.continue(a.G)}else r()}}).next(function(){return Re.waitFor(n)})}},{key:"options",value:function(e,t){var n;return void 0!==e&&("string"==typeof e?n=e:t=e),{index:n,range:t}}},{key:"cursor",value:function(e){var t="next";if(e.reverse&&(t="prev"),e.index){var n=this.store.index(e.index);return e.Z?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}]),e}();function Ke(e){return new Re(function(t,n){e.onsuccess=function(e){var n=e.target.result;t(n)},e.onerror=function(e){var t=Qe(e.target.error);n(t)}})}var Ge=!1;function Qe(e){var t=Oe.D((0,a.getUA)());if(t>=12.2&&t<13){var n="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(n)>=0){var r=new Z("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '".concat(n,"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround."));return Ge||(Ge=!0,setTimeout(function(){throw r},0)),r}}return e}var je=function(){function e(t,n){P(this,e),this.asyncQueue=t,this.et=n,this.task=null}return L(e,[{key:"start",value:function(){this.nt(15e3)}},{key:"stop",value:function(){this.task&&(this.task.cancel(),this.task=null)}},{key:"started",get:function(){return null!==this.task}},{key:"nt",value:function(e){var t=this;G("IndexBackiller","Scheduled in ".concat(e,"ms")),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:return t.task=null,e.prev=1,e.t0=G,e.t1="Documents written: ",e.next=6,m().awrap(t.et.st());case 6:e.t2=e.sent,e.t3=e.t1.concat.call(e.t1,e.t2),(0,e.t0)("IndexBackiller",e.t3),e.next=19;break;case 11:if(e.prev=11,e.t4=e.catch(1),!Ue(e.t4)){e.next=17;break}G("IndexBackiller","Ignoring IndexedDB error during index backfill: ",e.t4),e.next=19;break;case 17:return e.next=19,m().awrap(Le(e.t4));case 19:return e.next=21,m().awrap(t.nt(6e4));case 21:case"end":return e.stop()}},null,null,[[1,11]],Promise)})}}]),e}(),ze=function(){function e(t,n){P(this,e),this.localStore=t,this.persistence=n}return L(e,[{key:"st",value:function(){var e,t=this,n=arguments;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:50,r.abrupt("return",this.persistence.runTransaction("Backfill Indexes","readwrite-primary",function(n){return t.it(n,e)}));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"it",value:function(e,t){var n=this,r=new Set,i=t,a=!0;return Re.doWhile(function(){return!0===a&&i>0},function(){return n.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(function(t){if(null!==t&&!r.has(t))return G("IndexBackiller","Processing collection: ".concat(t)),n.rt(e,t,i).next(function(e){i-=e,r.add(t)});a=!1})}).next(function(){return t-i})}},{key:"rt",value:function(e,t,n){var r=this;return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next(function(i){return r.localStore.localDocuments.getNextDocuments(e,t,i,n).next(function(n){var a=n.changes;return r.localStore.indexManager.updateIndexEntries(e,a).next(function(){return r.ot(i,n)}).next(function(n){return G("IndexBackiller","Updating offset: ".concat(n)),r.localStore.indexManager.updateCollectionGroup(e,t,n)}).next(function(){return a.size})})})}},{key:"ot",value:function(e,t){var n=e;return t.changes.forEach(function(e,t){var r=De(t);Ce(r,n)>0&&(n=r)}),new Ne(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}}]),e}(),We=function(){function e(t,n){var r=this;P(this,e),this.previousValue=t,n&&(n.sequenceNumberHandler=function(e){return r.ut(e)},this.ct=function(e){return n.writeSequenceNumber(e)})}return L(e,[{key:"ut",value:function(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}},{key:"next",value:function(){var e=++this.previousValue;return this.ct&&this.ct(e),e}}]),e}();We.at=-1;var He=/^[_a-zA-Z][_a-zA-Z0-9]*(?:\.[_a-zA-Z][_a-zA-Z0-9]*)*$/,Xe=function(){function e(t){P(this,e),this.alias=t}return L(e,[{key:"canonicalString",value:function(){var t=this.alias.replace(/\\/g,"\\\\").replace(/`/g,"\\`");return e.ht(t)||(t="`"+t+"`"),t}}],[{key:"ht",value:function(e){return He.test(e)}}]),e}(),Ye=L(function e(t,n,r){P(this,e),this.alias=t,this.lt=n,this.fieldPath=r}),Je=L(function e(t,n,r,i,a,u,o,s){P(this,e),this.databaseId=t,this.appId=n,this.persistenceKey=r,this.host=i,this.ssl=a,this.forceLongPolling=u,this.autoDetectLongPolling=o,this.useFetchStreams=s}),Ze=function(){function e(t,n){P(this,e),this.projectId=t,this.database=n||"(default)"}return L(e,[{key:"isDefaultDatabase",get:function(){return"(default)"===this.database}},{key:"isEqual",value:function(t){return t instanceof e&&t.projectId===this.projectId&&t.database===this.database}}],[{key:"empty",value:function(){return new e("","")}}]),e}();function $e(e){var t=0;for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function et(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function tt(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function nt(e){return null==e}function rt(e){return 0===e&&1/e==-1/0}function it(e){return"number"==typeof e&&Number.isInteger(e)&&!rt(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}exports._DatabaseId=Ze;var at=function(e){g(n,d(Error));var t=w(n);function n(){var e;return P(this,n),(e=t.apply(this,arguments)).name="Base64DecodeError",e}return L(n)}();function ut(){return"undefined"!=typeof atob}var ot=function(e){function t(e){P(this,t),this.binaryString=e}return L(t,[{key:Symbol.iterator,value:function(){var e=this,t=0;return{next:function(){return t<e.binaryString.length?{value:e.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}}},{key:"toBase64",value:function(){return e=this.binaryString,btoa(e);var e}},{key:"toUint8Array",value:function(){return function(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(this.binaryString)}},{key:"approximateByteSize",value:function(){return 2*this.binaryString.length}},{key:"compareTo",value:function(e){return fe(this.binaryString,e.binaryString)}},{key:"isEqual",value:function(e){return this.binaryString===e.binaryString}}],[{key:"fromBase64String",value:function(e){return new t(function(e){try{return atob(e)}catch(e){throw e instanceof DOMException?new at("Invalid base64 string: "+e):e}}(e))}},{key:"fromUint8Array",value:function(e){return new t(function(e){for(var t="",n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(e))}}]),t}();ot.EMPTY_BYTE_STRING=new ot("");var st=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ct(e){if(H(!!e),"string"==typeof e){var t=0,n=st.exec(e);if(H(!!n),n[1]){var r=n[1];r=(r+"000000000").substr(0,9),t=Number(r)}var i=new Date(e);return{seconds:Math.floor(i.getTime()/1e3),nanos:t}}return{seconds:lt(e.seconds),nanos:lt(e.nanos)}}function lt(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function ft(e){return"string"==typeof e?ot.fromBase64String(e):ot.fromUint8Array(e)}function ht(e){var t,n;return"server_timestamp"===(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function dt(e){var t=e.mapValue.fields.__previous_value__;return ht(t)?dt(t):t}function vt(e){var t=ct(e.mapValue.fields.__local_write_time__.timestampValue);return new ve(t.seconds,t.nanos)}var yt={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},pt={nullValue:"NULL_VALUE"};function mt(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?ht(e)?4:Ct(e)?9007199254740991:10:W()}function gt(e,t){if(e===t)return!0;var n=mt(e);if(n!==mt(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return vt(e).isEqual(vt(t));case 3:return function(e,t){if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;var n=ct(e.timestampValue),r=ct(t.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(e,t){return ft(e.bytesValue).isEqual(ft(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return lt(e.geoPointValue.latitude)===lt(t.geoPointValue.latitude)&<(e.geoPointValue.longitude)===lt(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return lt(e.integerValue)===lt(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){var n=lt(e.doubleValue),r=lt(t.doubleValue);return n===r?rt(n)===rt(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return he(e.arrayValue.values||[],t.arrayValue.values||[],gt);case 10:return function(e,t){var n=e.mapValue.fields||{},r=t.mapValue.fields||{};if($e(n)!==$e(r))return!1;for(var i in n)if(n.hasOwnProperty(i)&&(void 0===r[i]||!gt(n[i],r[i])))return!1;return!0}(e,t);default:return W()}}function kt(e,t){return void 0!==(e.values||[]).find(function(e){return gt(e,t)})}function wt(e,t){if(e===t)return 0;var n=mt(e),r=mt(t);if(n!==r)return fe(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return fe(e.booleanValue,t.booleanValue);case 2:return function(e,t){var n=lt(e.integerValue||e.doubleValue),r=lt(t.integerValue||t.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(e,t);case 3:return xt(e.timestampValue,t.timestampValue);case 4:return xt(vt(e),vt(t));case 5:return fe(e.stringValue,t.stringValue);case 6:return function(e,t){var n=ft(e),r=ft(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){for(var n=e.split("/"),r=t.split("/"),i=0;i<n.length&&i<r.length;i++){var a=fe(n[i],r[i]);if(0!==a)return a}return fe(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){var n=fe(lt(e.latitude),lt(t.latitude));return 0!==n?n:fe(lt(e.longitude),lt(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return function(e,t){for(var n=e.values||[],r=t.values||[],i=0;i<n.length&&i<r.length;++i){var a=wt(n[i],r[i]);if(a)return a}return fe(n.length,r.length)}(e.arrayValue,t.arrayValue);case 10:return function(e,t){if(e===yt.mapValue&&t===yt.mapValue)return 0;if(e===yt.mapValue)return 1;if(t===yt.mapValue)return-1;var n=e.fields||{},r=Object.keys(n),i=t.fields||{},a=Object.keys(i);r.sort(),a.sort();for(var u=0;u<r.length&&u<a.length;++u){var o=fe(r[u],a[u]);if(0!==o)return o;var s=wt(n[r[u]],i[a[u]]);if(0!==s)return s}return fe(r.length,a.length)}(e.mapValue,t.mapValue);default:throw W()}}function xt(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return fe(e,t);var n=ct(e),r=ct(t),i=fe(n.seconds,r.seconds);return 0!==i?i:fe(n.nanos,r.nanos)}function bt(e){return It(e)}function It(e){return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(e){var t=ct(e);return"time(".concat(t.seconds,",").concat(t.nanos,")")}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?ft(e.bytesValue).toBase64():"referenceValue"in e?(n=e.referenceValue,we.fromName(n).toString()):"geoPointValue"in e?"geo(".concat((t=e.geoPointValue).latitude,",").concat(t.longitude,")"):"arrayValue"in e?function(e){var t,n="[",r=!0,i=p(e.values||[]);try{for(i.s();!(t=i.n()).done;){var a=t.value;r?r=!1:n+=",",n+=It(a)}}catch(u){i.e(u)}finally{i.f()}return n+"]"}(e.arrayValue):"mapValue"in e?function(e){var t,n="{",r=!0,i=p(Object.keys(e.fields||{}).sort());try{for(i.s();!(t=i.n()).done;){var a=t.value;r?r=!1:n+=",",n+="".concat(a,":").concat(It(e.fields[a]))}}catch(u){i.e(u)}finally{i.f()}return n+"}"}(e.mapValue):W();var t,n}function Tt(e,t){return{referenceValue:"projects/".concat(e.projectId,"/databases/").concat(e.database,"/documents/").concat(t.path.canonicalString())}}function Et(e){return!!e&&"integerValue"in e}function St(e){return!!e&&"arrayValue"in e}function _t(e){return!!e&&"nullValue"in e}function At(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function Dt(e){return!!e&&"mapValue"in e}function Nt(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&&"object"==C(e.timestampValue))return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){var t={mapValue:{fields:{}}};return et(e.mapValue.fields,function(e,n){return t.mapValue.fields[e]=Nt(n)}),t}if(e.arrayValue){for(var n={arrayValue:{values:[]}},r=0;r<(e.arrayValue.values||[]).length;++r)n.arrayValue.values[r]=Nt(e.arrayValue.values[r]);return n}return Object.assign({},e)}function Ct(e){return"__max__"===(((e.mapValue||{}).fields||{}).__type__||{}).stringValue}function Pt(e){return"nullValue"in e?pt:"booleanValue"in e?{booleanValue:!1}:"integerValue"in e||"doubleValue"in e?{doubleValue:NaN}:"timestampValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in e?{stringValue:""}:"bytesValue"in e?{bytesValue:""}:"referenceValue"in e?Tt(Ze.empty(),we.empty()):"geoPointValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in e?{arrayValue:{}}:"mapValue"in e?{mapValue:{}}:W()}function Ft(e){return"nullValue"in e?{booleanValue:!1}:"booleanValue"in e?{doubleValue:NaN}:"integerValue"in e||"doubleValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in e?{stringValue:""}:"stringValue"in e?{bytesValue:""}:"bytesValue"in e?Tt(Ze.empty(),we.empty()):"referenceValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in e?{arrayValue:{}}:"arrayValue"in e?{mapValue:{}}:"mapValue"in e?yt:W()}function Lt(e,t){var n=wt(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function Rt(e,t){var n=wt(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}var Mt=L(function e(t,n){P(this,e),this.position=t,this.inclusive=n});function Ot(e,t,n){for(var r=0,i=0;i<e.position.length;i++){var a=t[i],u=e.position[i];if(r=a.field.isKeyField()?we.comparator(we.fromName(u.referenceValue),n.key):wt(u,n.data.field(a.field)),"desc"===a.dir&&(r*=-1),0!==r)break}return r}function Vt(e,t){if(null===e)return null===t;if(null===t)return!1;if(e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(var n=0;n<e.position.length;n++)if(!gt(e.position[n],t.position[n]))return!1;return!0}var qt=L(function e(){P(this,e)}),Ut=function(e){g(n,qt);var t=w(n);function n(e,r,i){var a;return P(this,n),(a=t.call(this)).field=e,a.op=r,a.value=i,a}return L(n,[{key:"matches",value:function(e){var t=e.data.field(this.field);return"!="===this.op?null!==t&&this.matchesComparison(wt(t,this.value)):null!==t&&mt(this.value)===mt(t)&&this.matchesComparison(wt(t,this.value))}},{key:"matchesComparison",value:function(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return W()}}},{key:"isInequality",value:function(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}},{key:"getFlattenedFilters",value:function(){return[this]}},{key:"getFilters",value:function(){return[this]}},{key:"getFirstInequalityField",value:function(){return this.isInequality()?this.field:null}}],[{key:"create",value:function(e,t,r){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,r):new Yt(e,t,r):"array-contains"===t?new en(e,r):"in"===t?new tn(e,r):"not-in"===t?new nn(e,r):"array-contains-any"===t?new rn(e,r):new n(e,t,r)}},{key:"createKeyFieldInFilter",value:function(e,t,n){return"in"===t?new Jt(e,n):new Zt(e,n)}}]),n}(),Bt=function(e){g(n,qt);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this)).filters=e,i.op=r,i.ft=null,i}return L(n,[{key:"matches",value:function(e){return Kt(this)?void 0===this.filters.find(function(t){return!t.matches(e)}):void 0!==this.filters.find(function(t){return t.matches(e)})}},{key:"getFlattenedFilters",value:function(){return null!==this.ft||(this.ft=this.filters.reduce(function(e,t){return e.concat(t.getFlattenedFilters())},[])),this.ft}},{key:"getFilters",value:function(){return Object.assign([],this.filters)}},{key:"getFirstInequalityField",value:function(){var e=this.dt(function(e){return e.isInequality()});return null!==e?e.field:null}},{key:"dt",value:function(e){var t,n=p(this.getFlattenedFilters());try{for(n.s();!(t=n.n()).done;){var r=t.value;if(e(r))return r}}catch(i){n.e(i)}finally{n.f()}return null}}],[{key:"create",value:function(e,t){return new n(e,t)}}]),n}();function Kt(e){return"and"===e.op}function Gt(e){return"or"===e.op}function Qt(e){return jt(e)&&Kt(e)}function jt(e){var t,n=p(e.filters);try{for(n.s();!(t=n.n()).done;){if(t.value instanceof Bt)return!1}}catch(r){n.e(r)}finally{n.f()}return!0}function zt(e){if(e instanceof Ut)return e.field.canonicalString()+e.op.toString()+bt(e.value);if(Qt(e))return e.filters.map(function(e){return zt(e)}).join(",");var t=e.filters.map(function(e){return zt(e)}).join(",");return"".concat(e.op,"(").concat(t,")")}function Wt(e,t){return e instanceof Ut?function(e,t){return t instanceof Ut&&e.op===t.op&&e.field.isEqual(t.field)&>(e.value,t.value)}(e,t):e instanceof Bt?function(e,t){return t instanceof Bt&&e.op===t.op&&e.filters.length===t.filters.length&&e.filters.reduce(function(e,n,r){return e&&Wt(n,t.filters[r])},!0)}(e,t):void W()}function Ht(e,t){var n=e.filters.concat(t);return Bt.create(n,e.op)}function Xt(e){return e instanceof Ut?function(e){return"".concat(e.field.canonicalString()," ").concat(e.op," ").concat(bt(e.value))}(e):e instanceof Bt?function(e){return e.op.toString()+" {"+e.getFilters().map(Xt).join(" ,")+"}"}(e):"Filter"}var Yt=function(e){g(n,Ut);var t=w(n);function n(e,r,i){var a;return P(this,n),(a=t.call(this,e,r,i)).key=we.fromName(i.referenceValue),a}return L(n,[{key:"matches",value:function(e){var t=we.comparator(e.key,this.key);return this.matchesComparison(t)}}]),n}(),Jt=function(e){g(n,Ut);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this,e,"in",r)).keys=$t("in",r),i}return L(n,[{key:"matches",value:function(e){return this.keys.some(function(t){return t.isEqual(e.key)})}}]),n}(),Zt=function(e){g(n,Ut);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this,e,"not-in",r)).keys=$t("not-in",r),i}return L(n,[{key:"matches",value:function(e){return!this.keys.some(function(t){return t.isEqual(e.key)})}}]),n}();function $t(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map(function(e){return we.fromName(e.referenceValue)})}var en=function(e){g(n,Ut);var t=w(n);function n(e,r){return P(this,n),t.call(this,e,"array-contains",r)}return L(n,[{key:"matches",value:function(e){var t=e.data.field(this.field);return St(t)&&kt(t.arrayValue,this.value)}}]),n}(),tn=function(e){g(n,Ut);var t=w(n);function n(e,r){return P(this,n),t.call(this,e,"in",r)}return L(n,[{key:"matches",value:function(e){var t=e.data.field(this.field);return null!==t&&kt(this.value.arrayValue,t)}}]),n}(),nn=function(e){g(n,Ut);var t=w(n);function n(e,r){return P(this,n),t.call(this,e,"not-in",r)}return L(n,[{key:"matches",value:function(e){if(kt(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var t=e.data.field(this.field);return null!==t&&!kt(this.value.arrayValue,t)}}]),n}(),rn=function(e){g(n,Ut);var t=w(n);function n(e,r){return P(this,n),t.call(this,e,"array-contains-any",r)}return L(n,[{key:"matches",value:function(e){var t=this,n=e.data.field(this.field);return!(!St(n)||!n.arrayValue.values)&&n.arrayValue.values.some(function(e){return kt(t.value.arrayValue,e)})}}]),n}(),an=L(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"asc";P(this,e),this.field=t,this.dir=n});function un(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}var on=function(){function e(t,n){P(this,e),this.comparator=t,this.root=n||cn.EMPTY}return L(e,[{key:"insert",value:function(t,n){return new e(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,cn.BLACK,null,null))}},{key:"remove",value:function(t){return new e(this.comparator,this.root.remove(t,this.comparator).copy(null,null,cn.BLACK,null,null))}},{key:"get",value:function(e){for(var t=this.root;!t.isEmpty();){var n=this.comparator(e,t.key);if(0===n)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}},{key:"indexOf",value:function(e){for(var t=0,n=this.root;!n.isEmpty();){var r=this.comparator(e,n.key);if(0===r)return t+n.left.size;r<0?n=n.left:(t+=n.left.size+1,n=n.right)}return-1}},{key:"isEmpty",value:function(){return this.root.isEmpty()}},{key:"size",get:function(){return this.root.size}},{key:"minKey",value:function(){return this.root.minKey()}},{key:"maxKey",value:function(){return this.root.maxKey()}},{key:"inorderTraversal",value:function(e){return this.root.inorderTraversal(e)}},{key:"forEach",value:function(e){this.inorderTraversal(function(t,n){return e(t,n),!1})}},{key:"toString",value:function(){var e=[];return this.inorderTraversal(function(t,n){return e.push("".concat(t,":").concat(n)),!1}),"{".concat(e.join(", "),"}")}},{key:"reverseTraversal",value:function(e){return this.root.reverseTraversal(e)}},{key:"getIterator",value:function(){return new sn(this.root,null,this.comparator,!1)}},{key:"getIteratorFrom",value:function(e){return new sn(this.root,e,this.comparator,!1)}},{key:"getReverseIterator",value:function(){return new sn(this.root,null,this.comparator,!0)}},{key:"getReverseIteratorFrom",value:function(e){return new sn(this.root,e,this.comparator,!0)}}]),e}(),sn=function(){function e(t,n,r,i){P(this,e),this.isReverse=i,this.nodeStack=[];for(var a=1;!t.isEmpty();)if(a=n?r(t.key,n):1,n&&i&&(a*=-1),a<0)t=this.isReverse?t.left:t.right;else{if(0===a){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}return L(e,[{key:"getNext",value:function(){var e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}},{key:"hasNext",value:function(){return this.nodeStack.length>0}},{key:"peek",value:function(){if(0===this.nodeStack.length)return null;var e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}]),e}(),cn=function(){function e(t,n,r,i,a){P(this,e),this.key=t,this.value=n,this.color=null!=r?r:e.RED,this.left=null!=i?i:e.EMPTY,this.right=null!=a?a:e.EMPTY,this.size=this.left.size+1+this.right.size}return L(e,[{key:"copy",value:function(t,n,r,i,a){return new e(null!=t?t:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=a?a:this.right)}},{key:"isEmpty",value:function(){return!1}},{key:"inorderTraversal",value:function(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}},{key:"reverseTraversal",value:function(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}},{key:"min",value:function(){return this.left.isEmpty()?this:this.left.min()}},{key:"minKey",value:function(){return this.min().key}},{key:"maxKey",value:function(){return this.right.isEmpty()?this.key:this.right.maxKey()}},{key:"insert",value:function(e,t,n){var r=this,i=n(e,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n))).fixUp()}},{key:"removeMin",value:function(){if(this.left.isEmpty())return e.EMPTY;var t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),(t=t.copy(null,null,null,t.left.removeMin(),null)).fixUp()}},{key:"remove",value:function(t,n){var r,i=this;if(n(t,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),0===n(t,i.key)){if(i.right.isEmpty())return e.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,n))}return i.fixUp()}},{key:"isRed",value:function(){return this.color}},{key:"fixUp",value:function(){var e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}},{key:"moveRedLeft",value:function(){var e=this.colorFlip();return e.right.left.isRed()&&(e=(e=(e=e.copy(null,null,null,null,e.right.rotateRight())).rotateLeft()).colorFlip()),e}},{key:"moveRedRight",value:function(){var e=this.colorFlip();return e.left.left.isRed()&&(e=(e=e.rotateRight()).colorFlip()),e}},{key:"rotateLeft",value:function(){var t=this.copy(null,null,e.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}},{key:"rotateRight",value:function(){var t=this.copy(null,null,e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}},{key:"colorFlip",value:function(){var e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}},{key:"checkMaxDepth",value:function(){var e=this.check();return Math.pow(2,e)<=this.size+1}},{key:"check",value:function(){if(this.isRed()&&this.left.isRed())throw W();if(this.right.isRed())throw W();var e=this.left.check();if(e!==this.right.check())throw W();return e+(this.isRed()?0:1)}}]),e}();cn.EMPTY=null,cn.RED=!0,cn.BLACK=!1,cn.EMPTY=new(function(){function e(){P(this,e),this.size=0}return L(e,[{key:"key",get:function(){throw W()}},{key:"value",get:function(){throw W()}},{key:"color",get:function(){throw W()}},{key:"left",get:function(){throw W()}},{key:"right",get:function(){throw W()}},{key:"copy",value:function(e,t,n,r,i){return this}},{key:"insert",value:function(e,t,n){return new cn(e,t)}},{key:"remove",value:function(e,t){return this}},{key:"isEmpty",value:function(){return!0}},{key:"inorderTraversal",value:function(e){return!1}},{key:"reverseTraversal",value:function(e){return!1}},{key:"minKey",value:function(){return null}},{key:"maxKey",value:function(){return null}},{key:"isRed",value:function(){return!1}},{key:"checkMaxDepth",value:function(){return!0}},{key:"check",value:function(){return 0}}]),e}());var ln=function(){function e(t){P(this,e),this.comparator=t,this.data=new on(this.comparator)}return L(e,[{key:"has",value:function(e){return null!==this.data.get(e)}},{key:"first",value:function(){return this.data.minKey()}},{key:"last",value:function(){return this.data.maxKey()}},{key:"size",get:function(){return this.data.size}},{key:"indexOf",value:function(e){return this.data.indexOf(e)}},{key:"forEach",value:function(e){this.data.inorderTraversal(function(t,n){return e(t),!1})}},{key:"forEachInRange",value:function(e,t){for(var n=this.data.getIteratorFrom(e[0]);n.hasNext();){var r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}},{key:"forEachWhile",value:function(e,t){var n;for(n=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}},{key:"firstAfterOrEqual",value:function(e){var t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}},{key:"getIterator",value:function(){return new fn(this.data.getIterator())}},{key:"getIteratorFrom",value:function(e){return new fn(this.data.getIteratorFrom(e))}},{key:"add",value:function(e){return this.copy(this.data.remove(e).insert(e,!0))}},{key:"delete",value:function(e){return this.has(e)?this.copy(this.data.remove(e)):this}},{key:"isEmpty",value:function(){return this.data.isEmpty()}},{key:"unionWith",value:function(e){var t=this;return t.size<e.size&&(t=e,e=this),e.forEach(function(e){t=t.add(e)}),t}},{key:"isEqual",value:function(t){if(!(t instanceof e))return!1;if(this.size!==t.size)return!1;for(var n=this.data.getIterator(),r=t.data.getIterator();n.hasNext();){var i=n.getNext().key,a=r.getNext().key;if(0!==this.comparator(i,a))return!1}return!0}},{key:"toArray",value:function(){var e=[];return this.forEach(function(t){e.push(t)}),e}},{key:"toString",value:function(){var e=[];return this.forEach(function(t){return e.push(t)}),"SortedSet("+e.toString()+")"}},{key:"copy",value:function(t){var n=new e(this.comparator);return n.data=t,n}}]),e}(),fn=function(){function e(t){P(this,e),this.iter=t}return L(e,[{key:"getNext",value:function(){return this.iter.getNext().key}},{key:"hasNext",value:function(){return this.iter.hasNext()}}]),e}();function hn(e){return e.hasNext()?e.getNext():void 0}var dn=function(){function e(t){P(this,e),this.fields=t,t.sort(ke.comparator)}return L(e,[{key:"unionWith",value:function(t){var n,r=new ln(ke.comparator),i=p(this.fields);try{for(i.s();!(n=i.n()).done;){var a=n.value;r=r.add(a)}}catch(c){i.e(c)}finally{i.f()}var u,o=p(t);try{for(o.s();!(u=o.n()).done;){var s=u.value;r=r.add(s)}}catch(c){o.e(c)}finally{o.f()}return new e(r.toArray())}},{key:"covers",value:function(e){var t,n=p(this.fields);try{for(n.s();!(t=n.n()).done;){if(t.value.isPrefixOf(e))return!0}}catch(r){n.e(r)}finally{n.f()}return!1}},{key:"isEqual",value:function(e){return he(this.fields,e.fields,function(e,t){return e.isEqual(t)})}}],[{key:"empty",value:function(){return new e([])}}]),e}(),vn=function(){function e(t){P(this,e),this.value=t}return L(e,[{key:"field",value:function(e){if(e.isEmpty())return this.value;for(var t=this.value,n=0;n<e.length-1;++n)if(!Dt(t=(t.mapValue.fields||{})[e.get(n)]))return null;return(t=(t.mapValue.fields||{})[e.lastSegment()])||null}},{key:"set",value:function(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Nt(t)}},{key:"setAll",value:function(e){var t=this,n=ke.emptyPath(),r={},i=[];e.forEach(function(e,a){if(!n.isImmediateParentOf(a)){var u=t.getFieldsMap(n);t.applyChanges(u,r,i),r={},i=[],n=a.popLast()}e?r[a.lastSegment()]=Nt(e):i.push(a.lastSegment())});var a=this.getFieldsMap(n);this.applyChanges(a,r,i)}},{key:"delete",value:function(e){var t=this.field(e.popLast());Dt(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}},{key:"isEqual",value:function(e){return gt(this.value,e.value)}},{key:"getFieldsMap",value:function(e){var t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(var n=0;n<e.length;++n){var r=t.mapValue.fields[e.get(n)];Dt(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}},{key:"applyChanges",value:function(e,t,n){et(t,function(t,n){return e[t]=n});var r,i=p(n);try{for(i.s();!(r=i.n()).done;){var a=r.value;delete e[a]}}catch(u){i.e(u)}finally{i.f()}}},{key:"clone",value:function(){return new e(Nt(this.value))}}],[{key:"empty",value:function(){return new e({mapValue:{}})}}]),e}();function yn(e){var t=[];return et(e.fields,function(e,n){var r=new ke([e]);if(Dt(n)){var i=yn(n.mapValue).fields;if(0===i.length)t.push(r);else{var a,u=p(i);try{for(u.s();!(a=u.n()).done;){var o=a.value;t.push(r.child(o))}}catch(s){u.e(s)}finally{u.f()}}}else t.push(r)}),new dn(t)}var pn=function(){function e(t,n,r,i,a,u,o){P(this,e),this.key=t,this.documentType=n,this.version=r,this.readTime=i,this.createTime=a,this.data=u,this.documentState=o}return L(e,[{key:"convertToFoundDocument",value:function(e,t){return!this.createTime.isEqual(ye.min())||2!==this.documentType&&0!==this.documentType||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}},{key:"convertToNoDocument",value:function(e){return this.version=e,this.documentType=2,this.data=vn.empty(),this.documentState=0,this}},{key:"convertToUnknownDocument",value:function(e){return this.version=e,this.documentType=3,this.data=vn.empty(),this.documentState=2,this}},{key:"setHasCommittedMutations",value:function(){return this.documentState=2,this}},{key:"setHasLocalMutations",value:function(){return this.documentState=1,this.version=ye.min(),this}},{key:"setReadTime",value:function(e){return this.readTime=e,this}},{key:"hasLocalMutations",get:function(){return 1===this.documentState}},{key:"hasCommittedMutations",get:function(){return 2===this.documentState}},{key:"hasPendingWrites",get:function(){return this.hasLocalMutations||this.hasCommittedMutations}},{key:"isValidDocument",value:function(){return 0!==this.documentType}},{key:"isFoundDocument",value:function(){return 1===this.documentType}},{key:"isNoDocument",value:function(){return 2===this.documentType}},{key:"isUnknownDocument",value:function(){return 3===this.documentType}},{key:"isEqual",value:function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}},{key:"mutableCopy",value:function(){return new e(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}},{key:"toString",value:function(){return"Document(".concat(this.key,", ").concat(this.version,", ").concat(JSON.stringify(this.data.value),", {createTime: ").concat(this.createTime,"}), {documentType: ").concat(this.documentType,"}), {documentState: ").concat(this.documentState,"})")}}],[{key:"newInvalidDocument",value:function(t){return new e(t,0,ye.min(),ye.min(),ye.min(),vn.empty(),0)}},{key:"newFoundDocument",value:function(t,n,r,i){return new e(t,1,n,ye.min(),r,i,0)}},{key:"newNoDocument",value:function(t,n){return new e(t,2,n,ye.min(),ye.min(),vn.empty(),0)}},{key:"newUnknownDocument",value:function(t,n){return new e(t,3,n,ye.min(),ye.min(),vn.empty(),2)}}]),e}(),mn=L(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null;P(this,e),this.path=t,this.collectionGroup=n,this.orderBy=r,this.filters=i,this.limit=a,this.startAt=u,this.endAt=o,this._t=null});function gn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,u=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null;return new mn(e,t,n,r,i,a,u)}function kn(e){var t=Y(e);if(null===t._t){var n=t.path.canonicalString();null!==t.collectionGroup&&(n+="|cg:"+t.collectionGroup),n+="|f:",n+=t.filters.map(function(e){return zt(e)}).join(","),n+="|ob:",n+=t.orderBy.map(function(e){return function(e){return e.field.canonicalString()+e.dir}(e)}).join(","),nt(t.limit)||(n+="|l:",n+=t.limit),t.startAt&&(n+="|lb:",n+=t.startAt.inclusive?"b:":"a:",n+=t.startAt.position.map(function(e){return bt(e)}).join(",")),t.endAt&&(n+="|ub:",n+=t.endAt.inclusive?"a:":"b:",n+=t.endAt.position.map(function(e){return bt(e)}).join(",")),t._t=n}return t._t}function wn(e,t){if(e.limit!==t.limit)return!1;if(e.orderBy.length!==t.orderBy.length)return!1;for(var n=0;n<e.orderBy.length;n++)if(!un(e.orderBy[n],t.orderBy[n]))return!1;if(e.filters.length!==t.filters.length)return!1;for(var r=0;r<e.filters.length;r++)if(!Wt(e.filters[r],t.filters[r]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!Vt(e.startAt,t.startAt)&&Vt(e.endAt,t.endAt)}function xn(e){return we.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function bn(e,t){return e.filters.filter(function(e){return e instanceof Ut&&e.field.isEqual(t)})}function In(e,t,n){var r,i=pt,a=!0,u=p(bn(e,t));try{for(u.s();!(r=u.n()).done;){var o=r.value,s=pt,c=!0;switch(o.op){case"<":case"<=":s=Pt(o.value);break;case"==":case"in":case">=":s=o.value;break;case">":s=o.value,c=!1;break;case"!=":case"not-in":s=pt}Lt({value:i,inclusive:a},{value:s,inclusive:c})<0&&(i=s,a=c)}}catch(h){u.e(h)}finally{u.f()}if(null!==n)for(var l=0;l<e.orderBy.length;++l)if(e.orderBy[l].field.isEqual(t)){var f=n.position[l];Lt({value:i,inclusive:a},{value:f,inclusive:n.inclusive})<0&&(i=f,a=n.inclusive);break}return{value:i,inclusive:a}}function Tn(e,t,n){var r,i=yt,a=!0,u=p(bn(e,t));try{for(u.s();!(r=u.n()).done;){var o=r.value,s=yt,c=!0;switch(o.op){case">=":case">":s=Ft(o.value),c=!1;break;case"==":case"in":case"<=":s=o.value;break;case"<":s=o.value,c=!1;break;case"!=":case"not-in":s=yt}Rt({value:i,inclusive:a},{value:s,inclusive:c})>0&&(i=s,a=c)}}catch(h){u.e(h)}finally{u.f()}if(null!==n)for(var l=0;l<e.orderBy.length;++l)if(e.orderBy[l].field.isEqual(t)){var f=n.position[l];Rt({value:i,inclusive:a},{value:f,inclusive:n.inclusive})>0&&(i=f,a=n.inclusive);break}return{value:i,inclusive:a}}var En=L(function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"F",o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null;P(this,e),this.path=t,this.collectionGroup=n,this.explicitOrderBy=r,this.filters=i,this.limit=a,this.limitType=u,this.startAt=o,this.endAt=s,this.wt=null,this.gt=null,this.startAt,this.endAt});function Sn(e,t,n,r,i,a,u,o){return new En(e,t,n,r,i,a,u,o)}function _n(e){return new En(e)}function An(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function Dn(e){return e.explicitOrderBy.length>0?e.explicitOrderBy[0].field:null}function Nn(e){var t,n=p(e.filters);try{for(n.s();!(t=n.n()).done;){var r=t.value.getFirstInequalityField();if(null!==r)return r}}catch(i){n.e(i)}finally{n.f()}return null}function Cn(e){return null!==e.collectionGroup}function Pn(e){var t=Y(e);if(null===t.wt){t.wt=[];var n=Nn(t),r=Dn(t);if(null!==n&&null===r)n.isKeyField()||t.wt.push(new an(n)),t.wt.push(new an(ke.keyField(),"asc"));else{var i,a=!1,u=p(t.explicitOrderBy);try{for(u.s();!(i=u.n()).done;){var o=i.value;t.wt.push(o),o.field.isKeyField()&&(a=!0)}}catch(c){u.e(c)}finally{u.f()}if(!a){var s=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";t.wt.push(new an(ke.keyField(),s))}}}return t.wt}function Fn(e){var t=Y(e);if(!t.gt)if("F"===t.limitType)t.gt=gn(t.path,t.collectionGroup,Pn(t),t.filters,t.limit,t.startAt,t.endAt);else{var n,r=[],i=p(Pn(t));try{for(i.s();!(n=i.n()).done;){var a=n.value,u="desc"===a.dir?"asc":"desc";r.push(new an(a.field,u))}}catch(c){i.e(c)}finally{i.f()}var o=t.endAt?new Mt(t.endAt.position,t.endAt.inclusive):null,s=t.startAt?new Mt(t.startAt.position,t.startAt.inclusive):null;t.gt=gn(t.path,t.collectionGroup,r,t.filters,t.limit,o,s)}return t.gt}function Ln(e,t){t.getFirstInequalityField(),Nn(e);var n=e.filters.concat([t]);return new En(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function Rn(e,t,n){return new En(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function Mn(e,t){return wn(Fn(e),Fn(t))&&e.limitType===t.limitType}function On(e){return"".concat(kn(Fn(e)),"|lt:").concat(e.limitType)}function Vn(e){return"Query(target=".concat(function(e){var t=e.path.canonicalString();return null!==e.collectionGroup&&(t+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(t+=", filters: [".concat(e.filters.map(function(e){return Xt(e)}).join(", "),"]")),nt(e.limit)||(t+=", limit: "+e.limit),e.orderBy.length>0&&(t+=", orderBy: [".concat(e.orderBy.map(function(e){return function(e){return"".concat(e.field.canonicalString()," (").concat(e.dir,")")}(e)}).join(", "),"]")),e.startAt&&(t+=", startAt: ",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(function(e){return bt(e)}).join(",")),e.endAt&&(t+=", endAt: ",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(function(e){return bt(e)}).join(",")),"Target(".concat(t,")")}(Fn(e)),"; limitType=").concat(e.limitType,")")}function qn(e,t){return t.isFoundDocument()&&function(e,t){var n=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n):we.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n)}(e,t)&&function(e,t){var n,r=p(Pn(e));try{for(r.s();!(n=r.n()).done;){var i=n.value;if(!i.field.isKeyField()&&null===t.data.field(i.field))return!1}}catch(a){r.e(a)}finally{r.f()}return!0}(e,t)&&function(e,t){var n,r=p(e.filters);try{for(r.s();!(n=r.n()).done;){if(!n.value.matches(t))return!1}}catch(i){r.e(i)}finally{r.f()}return!0}(e,t)&&function(e,t){return!(e.startAt&&!function(e,t,n){var r=Ot(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,Pn(e),t))&&!(e.endAt&&!function(e,t,n){var r=Ot(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,Pn(e),t))}(e,t)}function Un(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function Bn(e){return function(t,n){var r,i=!1,a=p(Pn(e));try{for(a.s();!(r=a.n()).done;){var u=r.value,o=Kn(u,t,n);if(0!==o)return o;i=i||u.field.isKeyField()}}catch(s){a.e(s)}finally{a.f()}return 0}}function Kn(e,t,n){var r=e.field.isKeyField()?we.comparator(t.key,n.key):function(e,t,n){var r=t.data.field(e),i=n.data.field(e);return null!==r&&null!==i?wt(r,i):W()}(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return W()}}function Gn(e,t){if(e.yt){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:rt(t)?"-0":t}}function Qn(e){return{integerValue:""+e}}function jn(e,t){return it(t)?Qn(t):Gn(e,t)}var zn=L(function e(){P(this,e),this._=void 0});function Wn(e,t,n){return e instanceof Yn?function(e,t){var n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&(n.fields.__previous_value__=t),{mapValue:n}}(n,t):e instanceof Jn?Zn(e,t):e instanceof $n?er(e,t):function(e,t){var n=Xn(e,t),r=nr(n)+nr(e.It);return Et(n)&&Et(e.It)?Qn(r):Gn(e.Tt,r)}(e,t)}function Hn(e,t,n){return e instanceof Jn?Zn(e,t):e instanceof $n?er(e,t):n}function Xn(e,t){return e instanceof tr?Et(n=t)||n&&"doubleValue"in n?t:{integerValue:0}:null;var n}var Yn=function(e){g(n,zn);var t=w(n);function n(){return P(this,n),t.apply(this,arguments)}return L(n)}(),Jn=function(e){g(n,zn);var t=w(n);function n(e){var r;return P(this,n),(r=t.call(this)).elements=e,r}return L(n)}();function Zn(e,t){var n,r=rr(t),i=p(e.elements);try{var a=function(){var e=n.value;r.some(function(t){return gt(t,e)})||r.push(e)};for(i.s();!(n=i.n()).done;)a()}catch(u){i.e(u)}finally{i.f()}return{arrayValue:{values:r}}}var $n=function(e){g(n,zn);var t=w(n);function n(e){var r;return P(this,n),(r=t.call(this)).elements=e,r}return L(n)}();function er(e,t){var n,r=rr(t),i=p(e.elements);try{var a=function(){var e=n.value;r=r.filter(function(t){return!gt(t,e)})};for(i.s();!(n=i.n()).done;)a()}catch(u){i.e(u)}finally{i.f()}return{arrayValue:{values:r}}}var tr=function(e){g(n,zn);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this)).Tt=e,i.It=r,i}return L(n)}();function nr(e){return lt(e.integerValue||e.doubleValue)}function rr(e){return St(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}var ir=L(function e(t,n){P(this,e),this.field=t,this.transform=n});function ar(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof Jn&&t instanceof Jn||e instanceof $n&&t instanceof $n?he(e.elements,t.elements,gt):e instanceof tr&&t instanceof tr?gt(e.It,t.It):e instanceof Yn&&t instanceof Yn}(e.transform,t.transform)}var ur=L(function e(t,n){P(this,e),this.version=t,this.transformResults=n}),or=function(){function e(t,n){P(this,e),this.updateTime=t,this.exists=n}return L(e,[{key:"isNone",get:function(){return void 0===this.updateTime&&void 0===this.exists}},{key:"isEqual",value:function(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}],[{key:"none",value:function(){return new e}},{key:"exists",value:function(t){return new e(void 0,t)}},{key:"updateTime",value:function(t){return new e(t)}}]),e}();function sr(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}var cr=L(function e(){P(this,e)});function lr(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new br(e.key,or.none()):new yr(e.key,e.data,or.none());var n,r=e.data,i=vn.empty(),a=new ln(ke.comparator),u=p(t.fields);try{for(u.s();!(n=u.n()).done;){var o=n.value;if(!a.has(o)){var s=r.field(o);null===s&&o.length>1&&(o=o.popLast(),s=r.field(o)),null===s?i.delete(o):i.set(o,s),a=a.add(o)}}}catch(c){u.e(c)}finally{u.f()}return new pr(e.key,i,new dn(a.toArray()),or.none())}function fr(e,t,n){e instanceof yr?function(e,t,n){var r=e.value.clone(),i=gr(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof pr?function(e,t,n){if(sr(e.precondition,t)){var r=gr(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(mr(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}else t.convertToUnknownDocument(n.version)}(e,t,n):function(e,t,n){t.convertToNoDocument(n.version).setHasCommittedMutations()}(0,t,n)}function hr(e,t,n,r){return e instanceof yr?function(e,t,n,r){if(!sr(e.precondition,t))return n;var i=e.value.clone(),a=kr(e.fieldTransforms,r,t);return i.setAll(a),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof pr?function(e,t,n,r){if(!sr(e.precondition,t))return n;var i=kr(e.fieldTransforms,r,t),a=t.data;return a.setAll(mr(e)),a.setAll(i),t.convertToFoundDocument(t.version,a).setHasLocalMutations(),null===n?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(function(e){return e.field}))}(e,t,n,r):function(e,t,n){return sr(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function dr(e,t){var n,r=null,i=p(e.fieldTransforms);try{for(i.s();!(n=i.n()).done;){var a=n.value,u=t.data.field(a.field),o=Xn(a.transform,u||null);null!=o&&(null===r&&(r=vn.empty()),r.set(a.field,o))}}catch(s){i.e(s)}finally{i.f()}return r||null}function vr(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!function(e,t){return void 0===e&&void 0===t||!(!e||!t)&&he(e,t,function(e,t){return ar(e,t)})}(e.fieldTransforms,t.fieldTransforms)&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}var yr=function(e){g(n,cr);var t=w(n);function n(e,r,i){var a,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return P(this,n),(a=t.call(this)).key=e,a.value=r,a.precondition=i,a.fieldTransforms=u,a.type=0,a}return L(n,[{key:"getFieldMask",value:function(){return null}}]),n}(),pr=function(e){g(n,cr);var t=w(n);function n(e,r,i,a){var u,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];return P(this,n),(u=t.call(this)).key=e,u.data=r,u.fieldMask=i,u.precondition=a,u.fieldTransforms=o,u.type=1,u}return L(n,[{key:"getFieldMask",value:function(){return this.fieldMask}}]),n}();function mr(e){var t=new Map;return e.fieldMask.fields.forEach(function(n){if(!n.isEmpty()){var r=e.data.field(n);t.set(n,r)}}),t}function gr(e,t,n){var r=new Map;H(e.length===n.length);for(var i=0;i<n.length;i++){var a=e[i],u=a.transform,o=t.data.field(a.field);r.set(a.field,Hn(u,o,n[i]))}return r}function kr(e,t,n){var r,i=new Map,a=p(e);try{for(a.s();!(r=a.n()).done;){var u=r.value,o=u.transform,s=n.data.field(u.field);i.set(u.field,Wn(o,s,t))}}catch(c){a.e(c)}finally{a.f()}return i}var wr,xr,br=function(e){g(n,cr);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this)).key=e,i.precondition=r,i.type=2,i.fieldTransforms=[],i}return L(n,[{key:"getFieldMask",value:function(){return null}}]),n}(),Ir=function(e){g(n,cr);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this)).key=e,i.precondition=r,i.type=3,i.fieldTransforms=[],i}return L(n,[{key:"getFieldMask",value:function(){return null}}]),n}(),Tr=L(function e(t){P(this,e),this.count=t});function Er(e){switch(e){default:return W();case J.CANCELLED:case J.UNKNOWN:case J.DEADLINE_EXCEEDED:case J.RESOURCE_EXHAUSTED:case J.INTERNAL:case J.UNAVAILABLE:case J.UNAUTHENTICATED:return!1;case J.INVALID_ARGUMENT:case J.NOT_FOUND:case J.ALREADY_EXISTS:case J.PERMISSION_DENIED:case J.FAILED_PRECONDITION:case J.ABORTED:case J.OUT_OF_RANGE:case J.UNIMPLEMENTED:case J.DATA_LOSS:return!0}}function Sr(e){if(void 0===e)return Q("GRPC error has no .code"),J.UNKNOWN;switch(e){case wr.OK:return J.OK;case wr.CANCELLED:return J.CANCELLED;case wr.UNKNOWN:return J.UNKNOWN;case wr.DEADLINE_EXCEEDED:return J.DEADLINE_EXCEEDED;case wr.RESOURCE_EXHAUSTED:return J.RESOURCE_EXHAUSTED;case wr.INTERNAL:return J.INTERNAL;case wr.UNAVAILABLE:return J.UNAVAILABLE;case wr.UNAUTHENTICATED:return J.UNAUTHENTICATED;case wr.INVALID_ARGUMENT:return J.INVALID_ARGUMENT;case wr.NOT_FOUND:return J.NOT_FOUND;case wr.ALREADY_EXISTS:return J.ALREADY_EXISTS;case wr.PERMISSION_DENIED:return J.PERMISSION_DENIED;case wr.FAILED_PRECONDITION:return J.FAILED_PRECONDITION;case wr.ABORTED:return J.ABORTED;case wr.OUT_OF_RANGE:return J.OUT_OF_RANGE;case wr.UNIMPLEMENTED:return J.UNIMPLEMENTED;case wr.DATA_LOSS:return J.DATA_LOSS;default:return W()}}(xr=wr||(wr={}))[xr.OK=0]="OK",xr[xr.CANCELLED=1]="CANCELLED",xr[xr.UNKNOWN=2]="UNKNOWN",xr[xr.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",xr[xr.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",xr[xr.NOT_FOUND=5]="NOT_FOUND",xr[xr.ALREADY_EXISTS=6]="ALREADY_EXISTS",xr[xr.PERMISSION_DENIED=7]="PERMISSION_DENIED",xr[xr.UNAUTHENTICATED=16]="UNAUTHENTICATED",xr[xr.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",xr[xr.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",xr[xr.ABORTED=10]="ABORTED",xr[xr.OUT_OF_RANGE=11]="OUT_OF_RANGE",xr[xr.UNIMPLEMENTED=12]="UNIMPLEMENTED",xr[xr.INTERNAL=13]="INTERNAL",xr[xr.UNAVAILABLE=14]="UNAVAILABLE",xr[xr.DATA_LOSS=15]="DATA_LOSS";var _r=function(){function e(t,n){P(this,e),this.mapKeyFn=t,this.equalsFn=n,this.inner={},this.innerSize=0}return L(e,[{key:"get",value:function(e){var t=this.mapKeyFn(e),n=this.inner[t];if(void 0!==n){var r,i=p(n);try{for(i.s();!(r=i.n()).done;){var a=c(r.value,2),u=a[0],o=a[1];if(this.equalsFn(u,e))return o}}catch(s){i.e(s)}finally{i.f()}}}},{key:"has",value:function(e){return void 0!==this.get(e)}},{key:"set",value:function(e,t){var n=this.mapKeyFn(e),r=this.inner[n];if(void 0===r)return this.inner[n]=[[e,t]],void this.innerSize++;for(var i=0;i<r.length;i++)if(this.equalsFn(r[i][0],e))return void(r[i]=[e,t]);r.push([e,t]),this.innerSize++}},{key:"delete",value:function(e){var t=this.mapKeyFn(e),n=this.inner[t];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return 1===n.length?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}},{key:"forEach",value:function(e){et(this.inner,function(t,n){var r,i=p(n);try{for(i.s();!(r=i.n()).done;){var a=c(r.value,2),u=a[0],o=a[1];e(u,o)}}catch(s){i.e(s)}finally{i.f()}})}},{key:"isEmpty",value:function(){return tt(this.inner)}},{key:"size",value:function(){return this.innerSize}}]),e}(),Ar=new on(we.comparator);function Dr(){return Ar}var Nr=new on(we.comparator);function Cr(){for(var e=Nr,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var i=0,a=n;i<a.length;i++){var u=a[i];e=e.insert(u.key,u)}return e}function Pr(e){var t=Nr;return e.forEach(function(e,n){return t=t.insert(e,n.overlayedDocument)}),t}function Fr(){return Rr()}function Lr(){return Rr()}function Rr(){return new _r(function(e){return e.toString()},function(e,t){return e.isEqual(t)})}var Mr=new on(we.comparator),Or=new ln(we.comparator);function Vr(){for(var e=Or,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var i=0,a=n;i<a.length;i++){var u=a[i];e=e.add(u)}return e}var qr=new ln(fe);function Ur(){return qr}var Br=function(){function e(t,n,r,i,a){P(this,e),this.snapshotVersion=t,this.targetChanges=n,this.targetMismatches=r,this.documentUpdates=i,this.resolvedLimboDocuments=a}return L(e,null,[{key:"createSynthesizedRemoteEventForCurrentChange",value:function(t,n,r){var i=new Map;return i.set(t,Kr.createSynthesizedTargetChangeForCurrentChange(t,n,r)),new e(ye.min(),i,Ur(),Dr(),Vr())}}]),e}(),Kr=function(){function e(t,n,r,i,a){P(this,e),this.resumeToken=t,this.current=n,this.addedDocuments=r,this.modifiedDocuments=i,this.removedDocuments=a}return L(e,null,[{key:"createSynthesizedTargetChangeForCurrentChange",value:function(t,n,r){return new e(r,n,Vr(),Vr(),Vr())}}]),e}(),Gr=L(function e(t,n,r,i){P(this,e),this.Et=t,this.removedTargetIds=n,this.key=r,this.At=i}),Qr=L(function e(t,n){P(this,e),this.targetId=t,this.Rt=n}),jr=L(function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ot.EMPTY_BYTE_STRING,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;P(this,e),this.state=t,this.targetIds=n,this.resumeToken=r,this.cause=i}),zr=function(){function e(){P(this,e),this.Pt=0,this.vt=Xr(),this.bt=ot.EMPTY_BYTE_STRING,this.Vt=!1,this.St=!0}return L(e,[{key:"current",get:function(){return this.Vt}},{key:"resumeToken",get:function(){return this.bt}},{key:"Dt",get:function(){return 0!==this.Pt}},{key:"Ct",get:function(){return this.St}},{key:"xt",value:function(e){e.approximateByteSize()>0&&(this.St=!0,this.bt=e)}},{key:"Nt",value:function(){var e=Vr(),t=Vr(),n=Vr();return this.vt.forEach(function(r,i){switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:W()}}),new Kr(this.bt,this.Vt,e,t,n)}},{key:"kt",value:function(){this.St=!1,this.vt=Xr()}},{key:"$t",value:function(e,t){this.St=!0,this.vt=this.vt.insert(e,t)}},{key:"Mt",value:function(e){this.St=!0,this.vt=this.vt.remove(e)}},{key:"Ot",value:function(){this.Pt+=1}},{key:"Ft",value:function(){this.Pt-=1}},{key:"Bt",value:function(){this.St=!0,this.Vt=!0}}]),e}(),Wr=function(){function e(t){P(this,e),this.Lt=t,this.qt=new Map,this.Ut=Dr(),this.Kt=Hr(),this.Gt=new ln(fe)}return L(e,[{key:"Qt",value:function(e){var t,n=p(e.Et);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.At&&e.At.isFoundDocument()?this.jt(r,e.At):this.zt(r,e.key,e.At)}}catch(o){n.e(o)}finally{n.f()}var i,a=p(e.removedTargetIds);try{for(a.s();!(i=a.n()).done;){var u=i.value;this.zt(u,e.key,e.At)}}catch(o){a.e(o)}finally{a.f()}}},{key:"Wt",value:function(e){var t=this;this.forEachTarget(e,function(n){var r=t.Ht(n);switch(e.state){case 0:t.Jt(n)&&r.xt(e.resumeToken);break;case 1:r.Ft(),r.Dt||r.kt(),r.xt(e.resumeToken);break;case 2:r.Ft(),r.Dt||t.removeTarget(n);break;case 3:t.Jt(n)&&(r.Bt(),r.xt(e.resumeToken));break;case 4:t.Jt(n)&&(t.Yt(n),r.xt(e.resumeToken));break;default:W()}})}},{key:"forEachTarget",value:function(e,t){var n=this;e.targetIds.length>0?e.targetIds.forEach(t):this.qt.forEach(function(e,r){n.Jt(r)&&t(r)})}},{key:"Zt",value:function(e){var t=e.targetId,n=e.Rt.count,r=this.Xt(t);if(r){var i=r.target;if(xn(i))if(0===n){var a=new we(i.path);this.zt(t,a,pn.newNoDocument(a,ye.min()))}else H(1===n);else this.te(t)!==n&&(this.Yt(t),this.Gt=this.Gt.add(t))}}},{key:"ee",value:function(e){var t=this,n=new Map;this.qt.forEach(function(r,i){var a=t.Xt(i);if(a){if(r.current&&xn(a.target)){var u=new we(a.target.path);null!==t.Ut.get(u)||t.ne(i,u)||t.zt(i,u,pn.newNoDocument(u,e))}r.Ct&&(n.set(i,r.Nt()),r.kt())}});var r=Vr();this.Kt.forEach(function(e,n){var i=!0;n.forEachWhile(function(e){var n=t.Xt(e);return!n||2===n.purpose||(i=!1,!1)}),i&&(r=r.add(e))}),this.Ut.forEach(function(t,n){return n.setReadTime(e)});var i=new Br(e,n,this.Gt,this.Ut,r);return this.Ut=Dr(),this.Kt=Hr(),this.Gt=new ln(fe),i}},{key:"jt",value:function(e,t){if(this.Jt(e)){var n=this.ne(e,t.key)?2:0;this.Ht(e).$t(t.key,n),this.Ut=this.Ut.insert(t.key,t),this.Kt=this.Kt.insert(t.key,this.se(t.key).add(e))}}},{key:"zt",value:function(e,t,n){if(this.Jt(e)){var r=this.Ht(e);this.ne(e,t)?r.$t(t,1):r.Mt(t),this.Kt=this.Kt.insert(t,this.se(t).delete(e)),n&&(this.Ut=this.Ut.insert(t,n))}}},{key:"removeTarget",value:function(e){this.qt.delete(e)}},{key:"te",value:function(e){var t=this.Ht(e).Nt();return this.Lt.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}},{key:"Ot",value:function(e){this.Ht(e).Ot()}},{key:"Ht",value:function(e){var t=this.qt.get(e);return t||(t=new zr,this.qt.set(e,t)),t}},{key:"se",value:function(e){var t=this.Kt.get(e);return t||(t=new ln(fe),this.Kt=this.Kt.insert(e,t)),t}},{key:"Jt",value:function(e){var t=null!==this.Xt(e);return t||G("WatchChangeAggregator","Detected inactive target",e),t}},{key:"Xt",value:function(e){var t=this.qt.get(e);return t&&t.Dt?null:this.Lt.ie(e)}},{key:"Yt",value:function(e){var t=this;this.qt.set(e,new zr),this.Lt.getRemoteKeysForTarget(e).forEach(function(n){t.zt(e,n,null)})}},{key:"ne",value:function(e,t){return this.Lt.getRemoteKeysForTarget(e).has(t)}}]),e}();function Hr(){return new on(we.comparator)}function Xr(){return new on(we.comparator)}var Yr={asc:"ASCENDING",desc:"DESCENDING"},Jr={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},Zr={and:"AND",or:"OR"},$r=L(function e(t,n){P(this,e),this.databaseId=t,this.yt=n});function ei(e,t){return e.yt?"".concat(new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z",""),".").concat(("000000000"+t.nanoseconds).slice(-9),"Z"):{seconds:""+t.seconds,nanos:t.nanoseconds}}function ti(e,t){return e.yt?t.toBase64():t.toUint8Array()}function ni(e,t){return ei(e,t.toTimestamp())}function ri(e){return H(!!e),ye.fromTimestamp(function(e){var t=ct(e);return new ve(t.seconds,t.nanos)}(e))}function ii(e,t){return function(e){return new me(["projects",e.projectId,"databases",e.database])}(e).child("documents").child(t).canonicalString()}function ai(e){var t=me.fromString(e);return H(Ci(t)),t}function ui(e,t){return ii(e.databaseId,t.path)}function oi(e,t){var n=ai(t);if(n.get(1)!==e.databaseId.projectId)throw new Z(J.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new Z(J.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new we(fi(n))}function si(e,t){return ii(e.databaseId,t)}function ci(e){var t=ai(e);return 4===t.length?me.emptyPath():fi(t)}function li(e){return new me(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function fi(e){return H(e.length>4&&"documents"===e.get(4)),e.popFirst(5)}function hi(e,t,n){return{name:ui(e,t),fields:n.value.mapValue.fields}}function di(e,t,n){var r=oi(e,t.name),i=ri(t.updateTime),a=t.createTime?ri(t.createTime):ye.min(),u=new vn({mapValue:{fields:t.fields}}),o=pn.newFoundDocument(r,i,a,u);return n&&o.setHasCommittedMutations(),n?o.setHasCommittedMutations():o}function vi(e,t){return"found"in t?function(e,t){H(!!t.found),t.found.name,t.found.updateTime;var n=oi(e,t.found.name),r=ri(t.found.updateTime),i=t.found.createTime?ri(t.found.createTime):ye.min(),a=new vn({mapValue:{fields:t.found.fields}});return pn.newFoundDocument(n,r,i,a)}(e,t):"missing"in t?function(e,t){H(!!t.missing),H(!!t.readTime);var n=oi(e,t.missing),r=ri(t.readTime);return pn.newNoDocument(n,r)}(e,t):W()}function yi(e,t){var n;if("targetChange"in t){t.targetChange;var r=function(e){return"NO_CHANGE"===e?0:"ADD"===e?1:"REMOVE"===e?2:"CURRENT"===e?3:"RESET"===e?4:W()}(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],a=function(e,t){return e.yt?(H(void 0===t||"string"==typeof t),ot.fromBase64String(t||"")):(H(void 0===t||t instanceof Uint8Array),ot.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),u=t.targetChange.cause,o=u&&function(e){var t=void 0===e.code?J.UNKNOWN:Sr(e.code);return new Z(t,e.message||"")}(u);n=new jr(r,i,a,o||null)}else if("documentChange"in t){t.documentChange;var s=t.documentChange;s.document,s.document.name,s.document.updateTime;var c=oi(e,s.document.name),l=ri(s.document.updateTime),f=s.document.createTime?ri(s.document.createTime):ye.min(),h=new vn({mapValue:{fields:s.document.fields}}),d=pn.newFoundDocument(c,l,f,h),v=s.targetIds||[],y=s.removedTargetIds||[];n=new Gr(v,y,d.key,d)}else if("documentDelete"in t){t.documentDelete;var p=t.documentDelete;p.document;var m=oi(e,p.document),g=p.readTime?ri(p.readTime):ye.min(),k=pn.newNoDocument(m,g),w=p.removedTargetIds||[];n=new Gr([],w,k.key,k)}else if("documentRemove"in t){t.documentRemove;var x=t.documentRemove;x.document;var b=oi(e,x.document),I=x.removedTargetIds||[];n=new Gr([],I,b,null)}else{if(!("filter"in t))return W();t.filter;var T=t.filter;T.targetId;var E=T.count||0,S=new Tr(E),_=T.targetId;n=new Qr(_,S)}return n}function pi(e,t){var n;if(t instanceof yr)n={update:hi(e,t.key,t.value)};else if(t instanceof br)n={delete:ui(e,t.key)};else if(t instanceof pr)n={update:hi(e,t.key,t.data),updateMask:Ni(t.fieldMask)};else{if(!(t instanceof Ir))return W();n={verify:ui(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map(function(e){return function(e,t){var n=t.transform;if(n instanceof Yn)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof Jn)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof $n)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof tr)return{fieldPath:t.field.canonicalString(),increment:n.It};throw W()}(0,e)})),t.precondition.isNone||(n.currentDocument=function(e,t){return void 0!==t.updateTime?{updateTime:ni(e,t.updateTime)}:void 0!==t.exists?{exists:t.exists}:W()}(e,t.precondition)),n}function mi(e,t){var n=t.currentDocument?function(e){return void 0!==e.updateTime?or.updateTime(ri(e.updateTime)):void 0!==e.exists?or.exists(e.exists):or.none()}(t.currentDocument):or.none(),r=t.updateTransforms?t.updateTransforms.map(function(t){return function(e,t){var n=null;if("setToServerValue"in t)H("REQUEST_TIME"===t.setToServerValue),n=new Yn;else if("appendMissingElements"in t){var r=t.appendMissingElements.values||[];n=new Jn(r)}else if("removeAllFromArray"in t){var i=t.removeAllFromArray.values||[];n=new $n(i)}else"increment"in t?n=new tr(e,t.increment):W();var a=ke.fromServerFormat(t.fieldPath);return new ir(a,n)}(e,t)}):[];if(t.update){t.update.name;var i=oi(e,t.update.name),a=new vn({mapValue:{fields:t.update.fields}});if(t.updateMask){var u=function(e){var t=e.fieldPaths||[];return new dn(t.map(function(e){return ke.fromServerFormat(e)}))}(t.updateMask);return new pr(i,a,u,n,r)}return new yr(i,a,n,r)}if(t.delete){var o=oi(e,t.delete);return new br(o,n)}if(t.verify){var s=oi(e,t.verify);return new Ir(s,n)}return W()}function gi(e,t){return e&&e.length>0?(H(void 0!==t),e.map(function(e){return function(e,t){var n=e.updateTime?ri(e.updateTime):ri(t);return n.isEqual(ye.min())&&(n=ri(t)),new ur(n,e.transformResults||[])}(e,t)})):[]}function ki(e,t){return{documents:[si(e,t.path)]}}function wi(e,t){var n={structuredQuery:{}},r=t.path;null!==t.collectionGroup?(n.parent=si(e,r),n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(n.parent=si(e,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);var i=function(e){if(0!==e.length)return Di(Bt.create(e,"and"))}(t.filters);i&&(n.structuredQuery.where=i);var a=function(e){if(0!==e.length)return e.map(function(e){return function(e){return{field:_i(e.field),direction:Ti(e.dir)}}(e)})}(t.orderBy);a&&(n.structuredQuery.orderBy=a);var u,o=function(e,t){return e.yt||nt(t)?t:{value:t}}(e,t.limit);return null!==o&&(n.structuredQuery.limit=o),t.startAt&&(n.structuredQuery.startAt={before:(u=t.startAt).inclusive,values:u.position}),t.endAt&&(n.structuredQuery.endAt=function(e){return{before:!e.inclusive,values:e.position}}(t.endAt)),n}function xi(e){var t=ci(e.parent),n=e.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){H(1===r);var a=n.from[0];a.allDescendants?i=a.collectionId:t=t.child(a.collectionId)}var u=[];n.where&&(u=function(e){var t=Ii(n.where);return t instanceof Bt&&Qt(t)?t.getFilters():[t]}());var o=[];n.orderBy&&(o=n.orderBy.map(function(e){return function(e){return new an(Ai(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))}(e)}));var s=null;n.limit&&(s=function(e){var t;return nt(t="object"==C(e)?e.value:e)?null:t}(n.limit));var c=null;n.startAt&&(c=function(e){var t=!!e.before,n=e.values||[];return new Mt(n,t)}(n.startAt));var l=null;return n.endAt&&(l=function(e){var t=!e.before,n=e.values||[];return new Mt(n,t)}(n.endAt)),Sn(t,i,o,u,s,"F",c,l)}function bi(e,t){var n=function(e,t){switch(t){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return W()}}(0,t.purpose);return null==n?null:{"goog-listen-tags":n}}function Ii(e){return void 0!==e.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":var t=Ai(e.unaryFilter.field);return Ut.create(t,"==",{doubleValue:NaN});case"IS_NULL":var n=Ai(e.unaryFilter.field);return Ut.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var r=Ai(e.unaryFilter.field);return Ut.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":var i=Ai(e.unaryFilter.field);return Ut.create(i,"!=",{nullValue:"NULL_VALUE"});default:return W()}}(e):void 0!==e.fieldFilter?function(e){return Ut.create(Ai(e.fieldFilter.field),function(e){switch(e){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return W()}}(e.fieldFilter.op),e.fieldFilter.value)}(e):void 0!==e.compositeFilter?function(e){return Bt.create(e.compositeFilter.filters.map(function(e){return Ii(e)}),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return W()}}(e.compositeFilter.op))}(e):W()}function Ti(e){return Yr[e]}function Ei(e){return Jr[e]}function Si(e){return Zr[e]}function _i(e){return{fieldPath:e.canonicalString()}}function Ai(e){return ke.fromServerFormat(e.fieldPath)}function Di(e){return e instanceof Ut?function(e){if("=="===e.op){if(At(e.value))return{unaryFilter:{field:_i(e.field),op:"IS_NAN"}};if(_t(e.value))return{unaryFilter:{field:_i(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(At(e.value))return{unaryFilter:{field:_i(e.field),op:"IS_NOT_NAN"}};if(_t(e.value))return{unaryFilter:{field:_i(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:_i(e.field),op:Ei(e.op),value:e.value}}}(e):e instanceof Bt?function(e){var t=e.getFilters().map(function(e){return Di(e)});return 1===t.length?t[0]:{compositeFilter:{op:Si(e.op),filters:t}}}(e):W()}function Ni(e){var t=[];return e.fields.forEach(function(e){return t.push(e.canonicalString())}),{fieldPaths:t}}function Ci(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}function Pi(e){for(var t="",n=0;n<e.length;n++)t.length>0&&(t=Li(t)),t=Fi(e.get(n),t);return Li(t)}function Fi(e,t){for(var n=t,r=e.length,i=0;i<r;i++){var a=e.charAt(i);switch(a){case"\0":n+="";break;case"":n+="";break;default:n+=a}}return n}function Li(e){return e+""}function Ri(e){var t=e.length;if(H(t>=2),2===t)return H(""===e.charAt(0)&&""===e.charAt(1)),me.emptyPath();for(var n=t-2,r=[],i="",a=0;a<t;){var u=e.indexOf("",a);switch((u<0||u>n)&&W(),e.charAt(u+1)){case"":var o=e.substring(a,u),s=void 0;0===i.length?s=o:(s=i+=o,i=""),r.push(s);break;case"":i+=e.substring(a,u),i+="\0";break;case"":i+=e.substring(a,u+1);break;default:W()}a=u+2}return new me(r)}var Mi=["userId","batchId"];function Oi(e,t){return[e,Pi(t)]}function Vi(e,t,n){return[e,Pi(t),n]}var qi={},Ui=["prefixPath","collectionGroup","readTime","documentId"],Bi=["prefixPath","collectionGroup","documentId"],Ki=["collectionGroup","readTime","prefixPath","documentId"],Gi=["canonicalId","targetId"],Qi=["targetId","path"],ji=["path","targetId"],zi=["collectionId","parent"],Wi=["indexId","uid"],Hi=["uid","sequenceNumber"],Xi=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],Yi=["indexId","uid","orderedDocumentKey"],Ji=["userId","collectionPath","documentId"],Zi=["userId","collectionPath","largestBatchId"],$i=["userId","collectionGroup","largestBatchId"],ea=["mutationQueues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments"].concat(["clientMetadata"]).concat(["remoteDocumentGlobal"]).concat(["collectionParents"]).concat(["bundles","namedQueries"]),ta=[].concat(E(ea),["documentOverlays"]),na=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],ra=na,ia=[].concat(ra,["indexConfiguration","indexState","indexEntries"]),aa=function(e){g(n,Fe);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this)).re=e,i.currentSequenceNumber=r,i}return L(n)}();function ua(e,t){var n=Y(e);return Oe.M(n.re,t)}var oa=function(){function e(t,n,r,i){P(this,e),this.batchId=t,this.localWriteTime=n,this.baseMutations=r,this.mutations=i}return L(e,[{key:"applyToRemoteDocument",value:function(e,t){for(var n=t.mutationResults,r=0;r<this.mutations.length;r++){var i=this.mutations[r];i.key.isEqual(e.key)&&fr(i,e,n[r])}}},{key:"applyToLocalView",value:function(e,t){var n,r=p(this.baseMutations);try{for(r.s();!(n=r.n()).done;){var i=n.value;i.key.isEqual(e.key)&&(t=hr(i,e,t,this.localWriteTime))}}catch(s){r.e(s)}finally{r.f()}var a,u=p(this.mutations);try{for(u.s();!(a=u.n()).done;){var o=a.value;o.key.isEqual(e.key)&&(t=hr(o,e,t,this.localWriteTime))}}catch(s){u.e(s)}finally{u.f()}return t}},{key:"applyToLocalDocumentSet",value:function(e,t){var n=this,r=Lr();return this.mutations.forEach(function(i){var a=e.get(i.key),u=a.overlayedDocument,o=n.applyToLocalView(u,a.mutatedFields),s=lr(u,o=t.has(i.key)?null:o);null!==s&&r.set(i.key,s),u.isValidDocument()||u.convertToNoDocument(ye.min())}),r}},{key:"keys",value:function(){return this.mutations.reduce(function(e,t){return e.add(t.key)},Vr())}},{key:"isEqual",value:function(e){return this.batchId===e.batchId&&he(this.mutations,e.mutations,function(e,t){return vr(e,t)})&&he(this.baseMutations,e.baseMutations,function(e,t){return vr(e,t)})}}]),e}(),sa=function(){function e(t,n,r,i){P(this,e),this.batch=t,this.commitVersion=n,this.mutationResults=r,this.docVersions=i}return L(e,null,[{key:"from",value:function(t,n,r){H(t.mutations.length===r.length);for(var i=Mr,a=t.mutations,u=0;u<a.length;u++)i=i.insert(a[u].key,r[u].version);return new e(t,n,r,i)}}]),e}(),ca=function(){function e(t,n){P(this,e),this.largestBatchId=t,this.mutation=n}return L(e,[{key:"getKey",value:function(){return this.mutation.key}},{key:"isEqual",value:function(e){return null!==e&&this.mutation===e.mutation}},{key:"toString",value:function(){return"Overlay{\n largestBatchId: ".concat(this.largestBatchId,",\n mutation: ").concat(this.mutation.toString(),"\n }")}}]),e}(),la=function(){function e(t,n,r,i){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:ye.min(),u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:ye.min(),o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:ot.EMPTY_BYTE_STRING;P(this,e),this.target=t,this.targetId=n,this.purpose=r,this.sequenceNumber=i,this.snapshotVersion=a,this.lastLimboFreeSnapshotVersion=u,this.resumeToken=o}return L(e,[{key:"withSequenceNumber",value:function(t){return new e(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}},{key:"withResumeToken",value:function(t,n){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,t)}},{key:"withLastLimboFreeSnapshotVersion",value:function(t){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken)}}]),e}(),fa=L(function e(t){P(this,e),this.oe=t});function ha(e,t){var n;if(t.document)n=di(e.oe,t.document,!!t.hasCommittedMutations);else if(t.noDocument){var r=we.fromSegments(t.noDocument.path),i=pa(t.noDocument.readTime);n=pn.newNoDocument(r,i),t.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!t.unknownDocument)return W();var a=we.fromSegments(t.unknownDocument.path),u=pa(t.unknownDocument.version);n=pn.newUnknownDocument(a,u)}return t.readTime&&n.setReadTime(function(e){var t=new ve(e[0],e[1]);return ye.fromTimestamp(t)}(t.readTime)),n}function da(e,t){var n=t.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:va(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())r.document=function(e,t){return{name:ui(e,t.key),fields:t.data.value.mapValue.fields,updateTime:ei(e,t.version.toTimestamp()),createTime:ei(e,t.createTime.toTimestamp())}}(e.oe,t);else if(t.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:ya(t.version)};else{if(!t.isUnknownDocument())return W();r.unknownDocument={path:n.path.toArray(),version:ya(t.version)}}return r}function va(e){var t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function ya(e){var t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function pa(e){var t=new ve(e.seconds,e.nanoseconds);return ye.fromTimestamp(t)}function ma(e,t){for(var n=(t.baseMutations||[]).map(function(t){return mi(e.oe,t)}),r=0;r<t.mutations.length-1;++r){var i=t.mutations[r];if(r+1<t.mutations.length&&void 0!==t.mutations[r+1].transform){var a=t.mutations[r+1];i.updateTransforms=a.transform.fieldTransforms,t.mutations.splice(r+1,1),++r}}var u=t.mutations.map(function(t){return mi(e.oe,t)}),o=ve.fromMillis(t.localWriteTimeMs);return new oa(t.batchId,o,n,u)}function ga(e){var t,n,r=pa(e.readTime),i=void 0!==e.lastLimboFreeSnapshotVersion?pa(e.lastLimboFreeSnapshotVersion):ye.min();return void 0!==e.query.documents?(H(1===(n=e.query).documents.length),t=Fn(_n(ci(n.documents[0])))):t=function(e){return Fn(xi(e))}(e.query),new la(t,e.targetId,0,e.lastListenSequenceNumber,r,i,ot.fromBase64String(e.resumeToken))}function ka(e,t){var n,r=ya(t.snapshotVersion),i=ya(t.lastLimboFreeSnapshotVersion);n=xn(t.target)?ki(e.oe,t.target):wi(e.oe,t.target);var a=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:kn(t.target),readTime:r,resumeToken:a,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:i,query:n}}function wa(e){var t=xi({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?Rn(t,t.limit,"L"):t}function xa(e,t){return new ca(t.largestBatchId,mi(e.oe,t.overlayMutation))}function ba(e,t){var n=t.path.lastSegment();return[e,Pi(t.path.popLast()),n]}function Ia(e,t,n,r){return{indexId:e,uid:t.uid||"",sequenceNumber:n,readTime:ya(r.readTime),documentKey:Pi(r.documentKey.path),largestBatchId:r.largestBatchId}}var Ta=function(){function e(){P(this,e)}return L(e,[{key:"getBundleMetadata",value:function(e,t){return Ea(e).get(t).next(function(e){if(e)return{id:(t=e).bundleId,createTime:pa(t.createTime),version:t.version};var t})}},{key:"saveBundleMetadata",value:function(e,t){return Ea(e).put({bundleId:(n=t).id,createTime:ya(ri(n.createTime)),version:n.version});var n}},{key:"getNamedQuery",value:function(e,t){return Sa(e).get(t).next(function(e){if(e)return{name:(t=e).name,query:wa(t.bundledQuery),readTime:pa(t.readTime)};var t})}},{key:"saveNamedQuery",value:function(e,t){return Sa(e).put(function(e){return{name:e.name,readTime:ya(ri(e.readTime)),bundledQuery:e.bundledQuery}}(t))}}]),e}();function Ea(e){return ua(e,"bundles")}function Sa(e){return ua(e,"namedQueries")}var _a=function(){function e(t,n){P(this,e),this.Tt=t,this.userId=n}return L(e,[{key:"getOverlay",value:function(e,t){var n=this;return Aa(e).get(ba(this.userId,t)).next(function(e){return e?xa(n.Tt,e):null})}},{key:"getOverlays",value:function(e,t){var n=this,r=Fr();return Re.forEach(t,function(t){return n.getOverlay(e,t).next(function(e){null!==e&&r.set(t,e)})}).next(function(){return r})}},{key:"saveOverlays",value:function(e,t,n){var r=this,i=[];return n.forEach(function(n,a){var u=new ca(t,a);i.push(r.ce(e,u))}),Re.waitFor(i)}},{key:"removeOverlaysForBatchId",value:function(e,t,n){var r=this,i=new Set;t.forEach(function(e){return i.add(Pi(e.getCollectionPath()))});var a=[];return i.forEach(function(t){var i=IDBKeyRange.bound([r.userId,t,n],[r.userId,t,n+1],!1,!0);a.push(Aa(e).Y("collectionPathOverlayIndex",i))}),Re.waitFor(a)}},{key:"getOverlaysForCollection",value:function(e,t,n){var r=this,i=Fr(),a=Pi(t),u=IDBKeyRange.bound([this.userId,a,n],[this.userId,a,Number.POSITIVE_INFINITY],!0);return Aa(e).W("collectionPathOverlayIndex",u).next(function(e){var t,n=p(e);try{for(n.s();!(t=n.n()).done;){var a=t.value,u=xa(r.Tt,a);i.set(u.getKey(),u)}}catch(o){n.e(o)}finally{n.f()}return i})}},{key:"getOverlaysForCollectionGroup",value:function(e,t,n,r){var i,a=this,u=Fr(),o=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,Number.POSITIVE_INFINITY],!0);return Aa(e).X({index:"collectionGroupOverlayIndex",range:o},function(e,t,n){var o=xa(a.Tt,t);u.size()<r||o.largestBatchId===i?(u.set(o.getKey(),o),i=o.largestBatchId):n.done()}).next(function(){return u})}},{key:"ce",value:function(e,t){return Aa(e).put(function(e,t,n){var r=c(ba(t,n.mutation.key),3);r[0];return{userId:t,collectionPath:r[1],documentId:r[2],collectionGroup:n.mutation.key.getCollectionGroup(),largestBatchId:n.largestBatchId,overlayMutation:pi(e.oe,n.mutation)}}(this.Tt,this.userId,t))}}],[{key:"ue",value:function(t,n){return new e(t,n.uid||"")}}]),e}();function Aa(e){return ua(e,"documentOverlays")}var Da=function(){function e(){P(this,e)}return L(e,[{key:"ae",value:function(e,t){this.he(e,t),t.le()}},{key:"he",value:function(e,t){if("nullValue"in e)this.fe(t,5);else if("booleanValue"in e)this.fe(t,10),t.de(e.booleanValue?1:0);else if("integerValue"in e)this.fe(t,15),t.de(lt(e.integerValue));else if("doubleValue"in e){var n=lt(e.doubleValue);isNaN(n)?this.fe(t,13):(this.fe(t,15),rt(n)?t.de(0):t.de(n))}else if("timestampValue"in e){var r=e.timestampValue;this.fe(t,20),"string"==typeof r?t._e(r):(t._e("".concat(r.seconds||"")),t.de(r.nanos||0))}else if("stringValue"in e)this.we(e.stringValue,t),this.me(t);else if("bytesValue"in e)this.fe(t,30),t.ge(ft(e.bytesValue)),this.me(t);else if("referenceValue"in e)this.ye(e.referenceValue,t);else if("geoPointValue"in e){var i=e.geoPointValue;this.fe(t,45),t.de(i.latitude||0),t.de(i.longitude||0)}else"mapValue"in e?Ct(e)?this.fe(t,Number.MAX_SAFE_INTEGER):(this.pe(e.mapValue,t),this.me(t)):"arrayValue"in e?(this.Ie(e.arrayValue,t),this.me(t)):W()}},{key:"we",value:function(e,t){this.fe(t,25),this.Te(e,t)}},{key:"Te",value:function(e,t){t._e(e)}},{key:"pe",value:function(e,t){var n=e.fields||{};this.fe(t,55);for(var r=0,i=Object.keys(n);r<i.length;r++){var a=i[r];this.we(a,t),this.he(n[a],t)}}},{key:"Ie",value:function(e,t){var n=e.values||[];this.fe(t,50);var r,i=p(n);try{for(i.s();!(r=i.n()).done;){var a=r.value;this.he(a,t)}}catch(u){i.e(u)}finally{i.f()}}},{key:"ye",value:function(e,t){var n=this;this.fe(t,37),we.fromName(e).path.forEach(function(e){n.fe(t,60),n.Te(e,t)})}},{key:"fe",value:function(e,t){e.de(t)}},{key:"me",value:function(e){e.de(2)}}]),e}();function Na(e){if(0===e)return 8;var t=0;return e>>4==0&&(t+=4,e<<=4),e>>6==0&&(t+=2,e<<=2),e>>7==0&&(t+=1),t}function Ca(e){var t=64-function(e){for(var t=0,n=0;n<8;++n){var r=Na(255&e[n]);if(t+=r,8!==r)break}return t}(e);return Math.ceil(t/8)}Da.Ee=new Da;var Pa=function(){function e(){P(this,e),this.buffer=new Uint8Array(1024),this.position=0}return L(e,[{key:"Ae",value:function(e){for(var t=e[Symbol.iterator](),n=t.next();!n.done;)this.Re(n.value),n=t.next();this.Pe()}},{key:"ve",value:function(e){for(var t=e[Symbol.iterator](),n=t.next();!n.done;)this.be(n.value),n=t.next();this.Ve()}},{key:"Se",value:function(e){var t,n=p(e);try{for(n.s();!(t=n.n()).done;){var r=t.value,i=r.charCodeAt(0);if(i<128)this.Re(i);else if(i<2048)this.Re(960|i>>>6),this.Re(128|63&i);else if(r<"\ud800"||"\udbff"<r)this.Re(480|i>>>12),this.Re(128|63&i>>>6),this.Re(128|63&i);else{var a=r.codePointAt(0);this.Re(240|a>>>18),this.Re(128|63&a>>>12),this.Re(128|63&a>>>6),this.Re(128|63&a)}}}catch(u){n.e(u)}finally{n.f()}this.Pe()}},{key:"De",value:function(e){var t,n=p(e);try{for(n.s();!(t=n.n()).done;){var r=t.value,i=r.charCodeAt(0);if(i<128)this.be(i);else if(i<2048)this.be(960|i>>>6),this.be(128|63&i);else if(r<"\ud800"||"\udbff"<r)this.be(480|i>>>12),this.be(128|63&i>>>6),this.be(128|63&i);else{var a=r.codePointAt(0);this.be(240|a>>>18),this.be(128|63&a>>>12),this.be(128|63&a>>>6),this.be(128|63&a)}}}catch(u){n.e(u)}finally{n.f()}this.Ve()}},{key:"Ce",value:function(e){var t=this.xe(e),n=Ca(t);this.Ne(1+n),this.buffer[this.position++]=255&n;for(var r=t.length-n;r<t.length;++r)this.buffer[this.position++]=255&t[r]}},{key:"ke",value:function(e){var t=this.xe(e),n=Ca(t);this.Ne(1+n),this.buffer[this.position++]=~(255&n);for(var r=t.length-n;r<t.length;++r)this.buffer[this.position++]=~(255&t[r])}},{key:"$e",value:function(){this.Me(255),this.Me(255)}},{key:"Oe",value:function(){this.Fe(255),this.Fe(255)}},{key:"reset",value:function(){this.position=0}},{key:"seed",value:function(e){this.Ne(e.length),this.buffer.set(e,this.position),this.position+=e.length}},{key:"Be",value:function(){return this.buffer.slice(0,this.position)}},{key:"xe",value:function(e){var t=function(e){var t=new DataView(new ArrayBuffer(8));return t.setFloat64(0,e,!1),new Uint8Array(t.buffer)}(e),n=0!=(128&t[0]);t[0]^=n?255:128;for(var r=1;r<t.length;++r)t[r]^=n?255:0;return t}},{key:"Re",value:function(e){var t=255&e;0===t?(this.Me(0),this.Me(255)):255===t?(this.Me(255),this.Me(0)):this.Me(t)}},{key:"be",value:function(e){var t=255&e;0===t?(this.Fe(0),this.Fe(255)):255===t?(this.Fe(255),this.Fe(0)):this.Fe(e)}},{key:"Pe",value:function(){this.Me(0),this.Me(1)}},{key:"Ve",value:function(){this.Fe(0),this.Fe(1)}},{key:"Me",value:function(e){this.Ne(1),this.buffer[this.position++]=e}},{key:"Fe",value:function(e){this.Ne(1),this.buffer[this.position++]=~e}},{key:"Ne",value:function(e){var t=e+this.position;if(!(t<=this.buffer.length)){var n=2*this.buffer.length;n<t&&(n=t);var r=new Uint8Array(n);r.set(this.buffer),this.buffer=r}}}]),e}(),Fa=function(){function e(t){P(this,e),this.Le=t}return L(e,[{key:"ge",value:function(e){this.Le.Ae(e)}},{key:"_e",value:function(e){this.Le.Se(e)}},{key:"de",value:function(e){this.Le.Ce(e)}},{key:"le",value:function(){this.Le.$e()}}]),e}(),La=function(){function e(t){P(this,e),this.Le=t}return L(e,[{key:"ge",value:function(e){this.Le.ve(e)}},{key:"_e",value:function(e){this.Le.De(e)}},{key:"de",value:function(e){this.Le.ke(e)}},{key:"le",value:function(){this.Le.Oe()}}]),e}(),Ra=function(){function e(){P(this,e),this.Le=new Pa,this.qe=new Fa(this.Le),this.Ue=new La(this.Le)}return L(e,[{key:"seed",value:function(e){this.Le.seed(e)}},{key:"Ke",value:function(e){return 0===e?this.qe:this.Ue}},{key:"Be",value:function(){return this.Le.Be()}},{key:"reset",value:function(){this.Le.reset()}}]),e}(),Ma=function(){function e(t,n,r,i){P(this,e),this.indexId=t,this.documentKey=n,this.arrayValue=r,this.directionalValue=i}return L(e,[{key:"Ge",value:function(){var t=this.directionalValue.length,n=0===t||255===this.directionalValue[t-1]?t+1:t,r=new Uint8Array(n);return r.set(this.directionalValue,0),n!==t?r.set([0],this.directionalValue.length):++r[r.length-1],new e(this.indexId,this.documentKey,this.arrayValue,r)}}]),e}();function Oa(e,t){var n=e.indexId-t.indexId;return 0!==n?n:0!==(n=Va(e.arrayValue,t.arrayValue))?n:0!==(n=Va(e.directionalValue,t.directionalValue))?n:we.comparator(e.documentKey,t.documentKey)}function Va(e,t){for(var n=0;n<e.length&&n<t.length;++n){var r=e[n]-t[n];if(0!==r)return r}return e.length-t.length}var qa=function(){function e(t){P(this,e),this.collectionId=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment(),this.Qe=t.orderBy,this.je=[];var n,r=p(t.filters);try{for(r.s();!(n=r.n()).done;){var i=n.value;i.isInequality()?this.ze=i:this.je.push(i)}}catch(a){r.e(a)}finally{r.f()}}return L(e,[{key:"We",value:function(e){H(e.collectionGroup===this.collectionId);var t=be(e);if(void 0!==t&&!this.He(t))return!1;for(var n=Ie(e),r=0,i=0;r<n.length&&this.He(n[r]);++r);if(r===n.length)return!0;if(void 0!==this.ze){var a=n[r];if(!this.Je(this.ze,a)||!this.Ye(this.Qe[i++],a))return!1;++r}for(;r<n.length;++r){var u=n[r];if(i>=this.Qe.length||!this.Ye(this.Qe[i++],u))return!1}return!0}},{key:"He",value:function(e){var t,n=p(this.je);try{for(n.s();!(t=n.n()).done;){var r=t.value;if(this.Je(r,e))return!0}}catch(i){n.e(i)}finally{n.f()}return!1}},{key:"Je",value:function(e,t){if(void 0===e||!e.field.isEqual(t.fieldPath))return!1;var n="array-contains"===e.op||"array-contains-any"===e.op;return 2===t.kind===n}},{key:"Ye",value:function(e,t){return!!e.field.isEqual(t.fieldPath)&&(0===t.kind&&"asc"===e.dir||1===t.kind&&"desc"===e.dir)}}]),e}();function Ua(e){var t,n;if(H(e instanceof Ut||e instanceof Bt),e instanceof Ut){if(e instanceof tn){var r=(null===(n=null===(t=e.value.arrayValue)||void 0===t?void 0:t.values)||void 0===n?void 0:n.map(function(t){return Ut.create(e.field,"==",t)}))||[];return Bt.create(r,"or")}return e}var i=e.filters.map(function(e){return Ua(e)});return Bt.create(i,e.op)}function Ba(e){if(0===e.getFilters().length)return[];var t=ja(Ua(e));return H(Qa(t)),Ka(t)||Ga(t)?[t]:t.getFilters()}function Ka(e){return e instanceof Ut}function Ga(e){return e instanceof Bt&&Qt(e)}function Qa(e){return Ka(e)||Ga(e)||function(e){if(e instanceof Bt&&Gt(e)){var t,n=p(e.getFilters());try{for(n.s();!(t=n.n()).done;){var r=t.value;if(!Ka(r)&&!Ga(r))return!1}}catch(i){n.e(i)}finally{n.f()}return!0}return!1}(e)}function ja(e){if(H(e instanceof Ut||e instanceof Bt),e instanceof Ut)return e;if(1===e.filters.length)return ja(e.filters[0]);var t=e.filters.map(function(e){return ja(e)}),n=Bt.create(t,e.op);return Qa(n=Ha(n))?n:(H(n instanceof Bt),H(Kt(n)),H(n.filters.length>1),n.filters.reduce(function(e,t){return za(e,t)}))}function za(e,t){return H(e instanceof Ut||e instanceof Bt),H(t instanceof Ut||t instanceof Bt),Ha(e instanceof Ut?t instanceof Ut?function(e,t){return Bt.create([e,t],"and")}(e,t):Wa(e,t):t instanceof Ut?Wa(t,e):function(e,t){if(H(e.filters.length>0&&t.filters.length>0),Kt(e)&&Kt(t))return Ht(e,t.getFilters());var n=Gt(e)?e:t,r=Gt(e)?t:e,i=n.filters.map(function(e){return za(e,r)});return Bt.create(i,"or")}(e,t))}function Wa(e,t){if(Kt(t))return Ht(t,e.getFilters());var n=t.filters.map(function(t){return za(e,t)});return Bt.create(n,"or")}function Ha(e){if(H(e instanceof Ut||e instanceof Bt),e instanceof Ut)return e;var t=e.getFilters();if(1===t.length)return Ha(t[0]);if(jt(e))return e;var n=t.map(function(e){return Ha(e)}),r=[];return n.forEach(function(t){t instanceof Ut?r.push(t):t instanceof Bt&&(t.op===e.op?r.push.apply(r,E(t.filters)):r.push(t))}),1===r.length?r[0]:Bt.create(r,e.op)}var Xa=function(){function e(){P(this,e),this.Ze=new Ya}return L(e,[{key:"addToCollectionParentIndex",value:function(e,t){return this.Ze.add(t),Re.resolve()}},{key:"getCollectionParents",value:function(e,t){return Re.resolve(this.Ze.getEntries(t))}},{key:"addFieldIndex",value:function(e,t){return Re.resolve()}},{key:"deleteFieldIndex",value:function(e,t){return Re.resolve()}},{key:"getDocumentsMatchingTarget",value:function(e,t){return Re.resolve(null)}},{key:"getIndexType",value:function(e,t){return Re.resolve(0)}},{key:"getFieldIndexes",value:function(e,t){return Re.resolve([])}},{key:"getNextCollectionGroupToUpdate",value:function(e){return Re.resolve(null)}},{key:"getMinOffset",value:function(e,t){return Re.resolve(Ne.min())}},{key:"getMinOffsetFromCollectionGroup",value:function(e,t){return Re.resolve(Ne.min())}},{key:"updateCollectionGroup",value:function(e,t,n){return Re.resolve()}},{key:"updateIndexEntries",value:function(e,t){return Re.resolve()}}]),e}(),Ya=function(){function e(){P(this,e),this.index={}}return L(e,[{key:"add",value:function(e){var t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new ln(me.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}},{key:"has",value:function(e){var t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}},{key:"getEntries",value:function(e){return(this.index[e]||new ln(me.comparator)).toArray()}}]),e}(),Ja=new Uint8Array(0),Za=function(){function e(t,n){P(this,e),this.user=t,this.databaseId=n,this.Xe=new Ya,this.tn=new _r(function(e){return kn(e)},function(e,t){return wn(e,t)}),this.uid=t.uid||""}return L(e,[{key:"addToCollectionParentIndex",value:function(e,t){var n=this;if(!this.Xe.has(t)){var r=t.lastSegment(),i=t.popLast();e.addOnCommittedListener(function(){n.Xe.add(t)});var a={collectionId:r,parent:Pi(i)};return $a(e).put(a)}return Re.resolve()}},{key:"getCollectionParents",value:function(e,t){var n=[],r=IDBKeyRange.bound([t,""],[de(t),""],!1,!0);return $a(e).W(r).next(function(e){var r,i=p(e);try{for(i.s();!(r=i.n()).done;){var a=r.value;if(a.collectionId!==t)break;n.push(Ri(a.parent))}}catch(u){i.e(u)}finally{i.f()}return n})}},{key:"addFieldIndex",value:function(e,t){var n=this,r=tu(e),i=function(e){return{indexId:e.indexId,collectionGroup:e.collectionGroup,fields:e.fields.map(function(e){return[e.fieldPath.canonicalString(),e.kind]})}}(t);delete i.indexId;var a=r.add(i);if(t.indexState){var u=nu(e);return a.next(function(e){u.put(Ia(e,n.user,t.indexState.sequenceNumber,t.indexState.offset))})}return a.next()}},{key:"deleteFieldIndex",value:function(e,t){var n=tu(e),r=nu(e),i=eu(e);return n.delete(t.indexId).next(function(){return r.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))}).next(function(){return i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))})}},{key:"getDocumentsMatchingTarget",value:function(e,t){var n=this,r=eu(e),i=!0,a=new Map;return Re.forEach(this.en(t),function(t){return n.nn(e,t).next(function(e){i&&(i=!!e),a.set(t,e)})}).next(function(){if(i){var e=Vr(),u=[];return Re.forEach(a,function(i,a){var o;G("IndexedDbIndexManager","Using index ".concat((o=i,"id=".concat(o.indexId,"|cg=").concat(o.collectionGroup,"|f=").concat(o.fields.map(function(e){return"".concat(e.fieldPath,":").concat(e.kind)}).join(",")))," to execute ").concat(kn(t)));var s=function(e,t){var n=be(i);if(void 0===n)return null;var r,a=p(bn(e,n.fieldPath));try{for(a.s();!(r=a.n()).done;){var u=r.value;switch(u.op){case"array-contains-any":return u.value.arrayValue.values||[];case"array-contains":return[u.value]}}}catch(o){a.e(o)}finally{a.f()}return null}(a),c=function(e,t){var n,r=new Map,i=p(Ie(t));try{for(i.s();!(n=i.n()).done;){var a,u=n.value,o=p(bn(e,u.fieldPath));try{for(o.s();!(a=o.n()).done;){var s=a.value;switch(s.op){case"==":case"in":r.set(u.fieldPath.canonicalString(),s.value);break;case"not-in":case"!=":return r.set(u.fieldPath.canonicalString(),s.value),Array.from(r.values())}}}catch(c){o.e(c)}finally{o.f()}}}catch(c){i.e(c)}finally{i.f()}return null}(a,i),l=function(e,t){var n,r=[],a=!0,u=p(Ie(i));try{for(u.s();!(n=u.n()).done;){var o=n.value,s=0===o.kind?In(e,o.fieldPath,e.startAt):Tn(e,o.fieldPath,e.startAt);r.push(s.value),a&&(a=s.inclusive)}}catch(c){u.e(c)}finally{u.f()}return new Mt(r,a)}(a),f=function(e,t){var n,r=[],a=!0,u=p(Ie(i));try{for(u.s();!(n=u.n()).done;){var o=n.value,s=0===o.kind?Tn(e,o.fieldPath,e.endAt):In(e,o.fieldPath,e.endAt);r.push(s.value),a&&(a=s.inclusive)}}catch(c){u.e(c)}finally{u.f()}return new Mt(r,a)}(a),h=n.sn(i,a,l),d=n.sn(i,a,f),v=n.rn(i,a,c),y=n.on(i.indexId,s,h,l.inclusive,d,f.inclusive,v);return Re.forEach(y,function(n){return r.J(n,t.limit).next(function(t){t.forEach(function(t){var n=we.fromSegments(t.documentKey);e.has(n)||(e=e.add(n),u.push(n))})})})}).next(function(){return u})}return Re.resolve(null)})}},{key:"en",value:function(e){var t=this.tn.get(e);return t||(t=0===e.filters.length?[e]:Ba(Bt.create(e.filters,"and")).map(function(t){return gn(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt)}),this.tn.set(e,t),t)}},{key:"on",value:function(e,t,n,r,i,a,u){for(var o=this,s=(null!=t?t.length:1)*Math.max(n.length,i.length),c=s/(null!=t?t.length:1),l=[],f=function(){var s=t?o.un(t[h/c]):Ja,f=o.cn(e,s,n[h%c],r),d=o.an(e,s,i[h%c],a),v=u.map(function(t){return o.cn(e,s,t,!0)});l.push.apply(l,E(o.createRange(f,d,v)))},h=0;h<s;++h)f();return l}},{key:"cn",value:function(e,t,n,r){var i=new Ma(e,we.empty(),t,n);return r?i:i.Ge()}},{key:"an",value:function(e,t,n,r){var i=new Ma(e,we.empty(),t,n);return r?i.Ge():i}},{key:"nn",value:function(e,t){var n=new qa(t),r=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,r).next(function(e){var t,r=null,i=p(e);try{for(i.s();!(t=i.n()).done;){var a=t.value;n.We(a)&&(!r||a.fields.length>r.fields.length)&&(r=a)}}catch(u){i.e(u)}finally{i.f()}return r})}},{key:"getIndexType",value:function(e,t){var n=this,r=2,i=this.en(t);return Re.forEach(i,function(t){return n.nn(e,t).next(function(e){e?0!==r&&e.fields.length<function(e){var t,n=new ln(ke.comparator),r=!1,i=p(e.filters);try{for(i.s();!(t=i.n()).done;){var a,u=p(t.value.getFlattenedFilters());try{for(u.s();!(a=u.n()).done;){var o=a.value;o.field.isKeyField()||("array-contains"===o.op||"array-contains-any"===o.op?r=!0:n=n.add(o.field))}}catch(f){u.e(f)}finally{u.f()}}}catch(f){i.e(f)}finally{i.f()}var s,c=p(e.orderBy);try{for(c.s();!(s=c.n()).done;){var l=s.value;l.field.isKeyField()||(n=n.add(l.field))}}catch(f){c.e(f)}finally{c.f()}return n.size+(r?1:0)}(t)&&(r=1):r=0})}).next(function(){return null!==t.limit&&i.length>1&&2===r?1:r})}},{key:"hn",value:function(e,t){var n,r=new Ra,i=p(Ie(e));try{for(i.s();!(n=i.n()).done;){var a=n.value,u=t.data.field(a.fieldPath);if(null==u)return null;var o=r.Ke(a.kind);Da.Ee.ae(u,o)}}catch(s){i.e(s)}finally{i.f()}return r.Be()}},{key:"un",value:function(e){var t=new Ra;return Da.Ee.ae(e,t.Ke(0)),t.Be()}},{key:"ln",value:function(e,t){var n=new Ra;return Da.Ee.ae(Tt(this.databaseId,t),n.Ke(function(e){var t=Ie(e);return 0===t.length?0:t[t.length-1].kind}(e))),n.Be()}},{key:"rn",value:function(e,t,n){if(null===n)return[];var r=[];r.push(new Ra);var i,a=0,u=p(Ie(e));try{for(u.s();!(i=u.n()).done;){var o,s=i.value,c=n[a++],l=p(r);try{for(l.s();!(o=l.n()).done;){var f=o.value;if(this.fn(t,s.fieldPath)&&St(c))r=this.dn(r,s,c);else{var h=f.Ke(s.kind);Da.Ee.ae(c,h)}}}catch(d){l.e(d)}finally{l.f()}}}catch(d){u.e(d)}finally{u.f()}return this._n(r)}},{key:"sn",value:function(e,t,n){return this.rn(e,t,n.position)}},{key:"_n",value:function(e){for(var t=[],n=0;n<e.length;++n)t[n]=e[n].Be();return t}},{key:"dn",value:function(e,t,n){var r,i=E(e),a=[],u=p(n.arrayValue.values||[]);try{for(u.s();!(r=u.n()).done;){var o,s=r.value,c=p(i);try{for(c.s();!(o=c.n()).done;){var l=o.value,f=new Ra;f.seed(l.Be()),Da.Ee.ae(s,f.Ke(t.kind)),a.push(f)}}catch(h){c.e(h)}finally{c.f()}}}catch(h){u.e(h)}finally{u.f()}return a}},{key:"fn",value:function(e,t){return!!e.filters.find(function(e){return e instanceof Ut&&e.field.isEqual(t)&&("in"===e.op||"not-in"===e.op)})}},{key:"getFieldIndexes",value:function(e,t){var n=this,r=tu(e),i=nu(e);return(t?r.W("collectionGroupIndex",IDBKeyRange.bound(t,t)):r.W()).next(function(e){var t=[];return Re.forEach(e,function(e){return i.get([e.indexId,n.uid]).next(function(n){t.push(function(e,t){var n=t?new _e(t.sequenceNumber,new Ne(pa(t.readTime),new we(Ri(t.documentKey)),t.largestBatchId)):_e.empty(),r=e.fields.map(function(e){var t=c(e,2),n=t[0],r=t[1];return new Ee(ke.fromServerFormat(n),r)});return new xe(e.indexId,e.collectionGroup,r,n)}(e,n))})}).next(function(){return t})})}},{key:"getNextCollectionGroupToUpdate",value:function(e){return this.getFieldIndexes(e).next(function(e){return 0===e.length?null:(e.sort(function(e,t){var n=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return 0!==n?n:fe(e.collectionGroup,t.collectionGroup)}),e[0].collectionGroup)})}},{key:"updateCollectionGroup",value:function(e,t,n){var r=this,i=tu(e),a=nu(e);return this.wn(e).next(function(e){return i.W("collectionGroupIndex",IDBKeyRange.bound(t,t)).next(function(t){return Re.forEach(t,function(t){return a.put(Ia(t.indexId,r.user,e,n))})})})}},{key:"updateIndexEntries",value:function(e,t){var n=this,r=new Map;return Re.forEach(t,function(t,i){var a=r.get(t.collectionGroup);return(a?Re.resolve(a):n.getFieldIndexes(e,t.collectionGroup)).next(function(a){return r.set(t.collectionGroup,a),Re.forEach(a,function(r){return n.mn(e,t,r).next(function(t){var a=n.gn(i,r);return t.isEqual(a)?Re.resolve():n.yn(e,i,r,t,a)})})})})}},{key:"pn",value:function(e,t,n,r){return eu(e).put({indexId:r.indexId,uid:this.uid,arrayValue:r.arrayValue,directionalValue:r.directionalValue,orderedDocumentKey:this.ln(n,t.key),documentKey:t.key.path.toArray()})}},{key:"In",value:function(e,t,n,r){return eu(e).delete([r.indexId,this.uid,r.arrayValue,r.directionalValue,this.ln(n,t.key),t.key.path.toArray()])}},{key:"mn",value:function(e,t,n){var r=eu(e),i=new ln(Oa);return r.X({index:"documentKeyIndex",range:IDBKeyRange.only([n.indexId,this.uid,this.ln(n,t)])},function(e,r){i=i.add(new Ma(n.indexId,t,r.arrayValue,r.directionalValue))}).next(function(){return i})}},{key:"gn",value:function(e,t){var n=new ln(Oa),r=this.hn(t,e);if(null==r)return n;var i=be(t);if(null!=i){var a=e.data.field(i.fieldPath);if(St(a)){var u,o=p(a.arrayValue.values||[]);try{for(o.s();!(u=o.n()).done;){var s=u.value;n=n.add(new Ma(t.indexId,e.key,this.un(s),r))}}catch(c){o.e(c)}finally{o.f()}}}else n=n.add(new Ma(t.indexId,e.key,Ja,r));return n}},{key:"yn",value:function(e,t,n,r,i){var a=this;G("IndexedDbIndexManager","Updating index entries for document '%s'",t.key);var u=[];return function(e,t,n,r,i){for(var a=e.getIterator(),u=t.getIterator(),o=hn(a),s=hn(u);o||s;){var c=!1,l=!1;if(o&&s){var f=n(o,s);f<0?l=!0:f>0&&(c=!0)}else null!=o?l=!0:c=!0;c?(r(s),s=hn(u)):l?(i(o),o=hn(a)):(o=hn(a),s=hn(u))}}(r,i,Oa,function(r){u.push(a.pn(e,t,n,r))},function(r){u.push(a.In(e,t,n,r))}),Re.waitFor(u)}},{key:"wn",value:function(e){var t=1;return nu(e).X({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},function(e,n,r){r.done(),t=n.sequenceNumber+1}).next(function(){return t})}},{key:"createRange",value:function(e,t,n){n=n.sort(function(e,t){return Oa(e,t)}).filter(function(e,t,n){return!t||0!==Oa(e,n[t-1])});var r=[];r.push(e);var i,a=p(n);try{for(a.s();!(i=a.n()).done;){var u=i.value,o=Oa(u,e),s=Oa(u,t);if(0===o)r[0]=e.Ge();else if(o>0&&s<0)r.push(u),r.push(u.Ge());else if(s>0)break}}catch(d){a.e(d)}finally{a.f()}r.push(t);for(var c=[],l=0;l<r.length;l+=2){if(this.Tn(r[l],r[l+1]))return[];var f=[r[l].indexId,this.uid,r[l].arrayValue,r[l].directionalValue,Ja,[]],h=[r[l+1].indexId,this.uid,r[l+1].arrayValue,r[l+1].directionalValue,Ja,[]];c.push(IDBKeyRange.bound(f,h))}return c}},{key:"Tn",value:function(e,t){return Oa(e,t)>0}},{key:"getMinOffsetFromCollectionGroup",value:function(e,t){return this.getFieldIndexes(e,t).next(ru)}},{key:"getMinOffset",value:function(e,t){var n=this;return Re.mapArray(this.en(t),function(t){return n.nn(e,t).next(function(e){return e||W()})}).next(ru)}}]),e}();function $a(e){return ua(e,"collectionParents")}function eu(e){return ua(e,"indexEntries")}function tu(e){return ua(e,"indexConfiguration")}function nu(e){return ua(e,"indexState")}function ru(e){H(0!==e.length);for(var t=e[0].indexState.offset,n=t.largestBatchId,r=1;r<e.length;r++){var i=e[r].indexState.offset;Ce(i,t)<0&&(t=i),n<i.largestBatchId&&(n=i.largestBatchId)}return new Ne(t.readTime,t.documentKey,n)}var iu={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},au=function(){function e(t,n,r){P(this,e),this.cacheSizeCollectionThreshold=t,this.percentileToCollect=n,this.maximumSequenceNumbersToCollect=r}return L(e,null,[{key:"withCacheSize",value:function(t){return new e(t,e.DEFAULT_COLLECTION_PERCENTILE,e.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}]),e}();function uu(e,t,n){var r=e.store("mutations"),i=e.store("documentMutations"),a=[],u=IDBKeyRange.only(n.batchId),o=0,s=r.X({range:u},function(e,t,n){return o++,n.delete()});a.push(s.next(function(){H(1===o)}));var c,l=[],f=p(n.mutations);try{for(f.s();!(c=f.n()).done;){var h=c.value,d=Vi(t,h.key.path,n.batchId);a.push(i.delete(d)),l.push(h.key)}}catch(v){f.e(v)}finally{f.f()}return Re.waitFor(a).next(function(){return l})}function ou(e){if(!e)return 0;var t;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw W();t=e.noDocument}return JSON.stringify(t).length}au.DEFAULT_COLLECTION_PERCENTILE=10,au.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,au.DEFAULT=new au(41943040,au.DEFAULT_COLLECTION_PERCENTILE,au.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),au.DISABLED=new au(-1,0,0);var su=function(){function e(t,n,r,i){P(this,e),this.userId=t,this.Tt=n,this.indexManager=r,this.referenceDelegate=i,this.En={}}return L(e,[{key:"checkEmpty",value:function(e){var t=!0,n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return lu(e).X({index:"userMutationsIndex",range:n},function(e,n,r){t=!1,r.done()}).next(function(){return t})}},{key:"addMutationBatch",value:function(e,t,n,r){var i=this,a=fu(e),u=lu(e);return u.add({}).next(function(o){H("number"==typeof o);var s,c=new oa(o,t,n,r),l=function(e,t,n){var r=n.baseMutations.map(function(t){return pi(e.oe,t)}),i=n.mutations.map(function(t){return pi(e.oe,t)});return{userId:t,batchId:n.batchId,localWriteTimeMs:n.localWriteTime.toMillis(),baseMutations:r,mutations:i}}(i.Tt,i.userId,c),f=[],h=new ln(function(e,t){return fe(e.canonicalString(),t.canonicalString())}),d=p(r);try{for(d.s();!(s=d.n()).done;){var v=s.value,y=Vi(i.userId,v.key.path,o);h=h.add(v.key.path.popLast()),f.push(u.put(l)),f.push(a.put(y,qi))}}catch(m){d.e(m)}finally{d.f()}return h.forEach(function(t){f.push(i.indexManager.addToCollectionParentIndex(e,t))}),e.addOnCommittedListener(function(){i.En[o]=c.keys()}),Re.waitFor(f).next(function(){return c})})}},{key:"lookupMutationBatch",value:function(e,t){var n=this;return lu(e).get(t).next(function(e){return e?(H(e.userId===n.userId),ma(n.Tt,e)):null})}},{key:"An",value:function(e,t){var n=this;return this.En[t]?Re.resolve(this.En[t]):this.lookupMutationBatch(e,t).next(function(e){if(e){var r=e.keys();return n.En[t]=r,r}return null})}},{key:"getNextMutationBatchAfterBatchId",value:function(e,t){var n=this,r=t+1,i=IDBKeyRange.lowerBound([this.userId,r]),a=null;return lu(e).X({index:"userMutationsIndex",range:i},function(e,t,i){t.userId===n.userId&&(H(t.batchId>=r),a=ma(n.Tt,t)),i.done()}).next(function(){return a})}},{key:"getHighestUnacknowledgedBatchId",value:function(e){var t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),n=-1;return lu(e).X({index:"userMutationsIndex",range:t,reverse:!0},function(e,t,r){n=t.batchId,r.done()}).next(function(){return n})}},{key:"getAllMutationBatches",value:function(e){var t=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return lu(e).W("userMutationsIndex",n).next(function(e){return e.map(function(e){return ma(t.Tt,e)})})}},{key:"getAllMutationBatchesAffectingDocumentKey",value:function(e,t){var n=this,r=Oi(this.userId,t.path),i=IDBKeyRange.lowerBound(r),a=[];return fu(e).X({range:i},function(r,i,u){var o=c(r,3),s=o[0],l=o[1],f=o[2],h=Ri(l);if(s===n.userId&&t.path.isEqual(h))return lu(e).get(f).next(function(e){if(!e)throw W();H(e.userId===n.userId),a.push(ma(n.Tt,e))});u.done()}).next(function(){return a})}},{key:"getAllMutationBatchesAffectingDocumentKeys",value:function(e,t){var n=this,r=new ln(fe),i=[];return t.forEach(function(t){var a=Oi(n.userId,t.path),u=IDBKeyRange.lowerBound(a),o=fu(e).X({range:u},function(e,i,a){var u=c(e,3),o=u[0],s=u[1],l=u[2],f=Ri(s);o===n.userId&&t.path.isEqual(f)?r=r.add(l):a.done()});i.push(o)}),Re.waitFor(i).next(function(){return n.Rn(e,r)})}},{key:"getAllMutationBatchesAffectingQuery",value:function(e,t){var n=this,r=t.path,i=r.length+1,a=Oi(this.userId,r),u=IDBKeyRange.lowerBound(a),o=new ln(fe);return fu(e).X({range:u},function(e,t,a){var u=c(e,3),s=u[0],l=u[1],f=u[2],h=Ri(l);s===n.userId&&r.isPrefixOf(h)?h.length===i&&(o=o.add(f)):a.done()}).next(function(){return n.Rn(e,o)})}},{key:"Rn",value:function(e,t){var n=this,r=[],i=[];return t.forEach(function(t){i.push(lu(e).get(t).next(function(e){if(null===e)throw W();H(e.userId===n.userId),r.push(ma(n.Tt,e))}))}),Re.waitFor(i).next(function(){return r})}},{key:"removeMutationBatch",value:function(e,t){var n=this;return uu(e.re,this.userId,t).next(function(r){return e.addOnCommittedListener(function(){n.Pn(t.batchId)}),Re.forEach(r,function(t){return n.referenceDelegate.markPotentiallyOrphaned(e,t)})})}},{key:"Pn",value:function(e){delete this.En[e]}},{key:"performConsistencyCheck",value:function(e){var t=this;return this.checkEmpty(e).next(function(n){if(!n)return Re.resolve();var r=IDBKeyRange.lowerBound([t.userId]),i=[];return fu(e).X({range:r},function(e,n,r){if(e[0]===t.userId){var a=Ri(e[1]);i.push(a)}else r.done()}).next(function(){H(0===i.length)})})}},{key:"containsKey",value:function(e,t){return cu(e,this.userId,t)}},{key:"vn",value:function(e){var t=this;return hu(e).get(this.userId).next(function(e){return e||{userId:t.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""}})}}],[{key:"ue",value:function(t,n,r,i){return H(""!==t.uid),new e(t.isAuthenticated()?t.uid:"",n,r,i)}}]),e}();function cu(e,t,n){var r=Oi(t,n.path),i=r[1],a=IDBKeyRange.lowerBound(r),u=!1;return fu(e).X({range:a,Z:!0},function(e,n,r){var a=c(e,3),o=a[0],s=a[1];a[2];o===t&&s===i&&(u=!0),r.done()}).next(function(){return u})}function lu(e){return ua(e,"mutations")}function fu(e){return ua(e,"documentMutations")}function hu(e){return ua(e,"mutationQueues")}var du=function(){function e(t){P(this,e),this.bn=t}return L(e,[{key:"next",value:function(){return this.bn+=2,this.bn}}],[{key:"Vn",value:function(){return new e(0)}},{key:"Sn",value:function(){return new e(-1)}}]),e}(),vu=function(){function e(t,n){P(this,e),this.referenceDelegate=t,this.Tt=n}return L(e,[{key:"allocateTargetId",value:function(e){var t=this;return this.Dn(e).next(function(n){var r=new du(n.highestTargetId);return n.highestTargetId=r.next(),t.Cn(e,n).next(function(){return n.highestTargetId})})}},{key:"getLastRemoteSnapshotVersion",value:function(e){return this.Dn(e).next(function(e){return ye.fromTimestamp(new ve(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds))})}},{key:"getHighestSequenceNumber",value:function(e){return this.Dn(e).next(function(e){return e.highestListenSequenceNumber})}},{key:"setTargetsMetadata",value:function(e,t,n){var r=this;return this.Dn(e).next(function(i){return i.highestListenSequenceNumber=t,n&&(i.lastRemoteSnapshotVersion=n.toTimestamp()),t>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=t),r.Cn(e,i)})}},{key:"addTargetData",value:function(e,t){var n=this;return this.xn(e,t).next(function(){return n.Dn(e).next(function(r){return r.targetCount+=1,n.Nn(t,r),n.Cn(e,r)})})}},{key:"updateTargetData",value:function(e,t){return this.xn(e,t)}},{key:"removeTargetData",value:function(e,t){var n=this;return this.removeMatchingKeysForTargetId(e,t.targetId).next(function(){return yu(e).delete(t.targetId)}).next(function(){return n.Dn(e)}).next(function(t){return H(t.targetCount>0),t.targetCount-=1,n.Cn(e,t)})}},{key:"removeTargets",value:function(e,t,n){var r=this,i=0,a=[];return yu(e).X(function(u,o){var s=ga(o);s.sequenceNumber<=t&&null===n.get(s.targetId)&&(i++,a.push(r.removeTargetData(e,s)))}).next(function(){return Re.waitFor(a)}).next(function(){return i})}},{key:"forEachTarget",value:function(e,t){return yu(e).X(function(e,n){var r=ga(n);t(r)})}},{key:"Dn",value:function(e){return pu(e).get("targetGlobalKey").next(function(e){return H(null!==e),e})}},{key:"Cn",value:function(e,t){return pu(e).put("targetGlobalKey",t)}},{key:"xn",value:function(e,t){return yu(e).put(ka(this.Tt,t))}},{key:"Nn",value:function(e,t){var n=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,n=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,n=!0),n}},{key:"getTargetCount",value:function(e){return this.Dn(e).next(function(e){return e.targetCount})}},{key:"getTargetData",value:function(e,t){var n=kn(t),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]),i=null;return yu(e).X({range:r,index:"queryTargetsIndex"},function(e,n,r){var a=ga(n);wn(t,a.target)&&(i=a,r.done())}).next(function(){return i})}},{key:"addMatchingKeys",value:function(e,t,n){var r=this,i=[],a=mu(e);return t.forEach(function(t){var u=Pi(t.path);i.push(a.put({targetId:n,path:u})),i.push(r.referenceDelegate.addReference(e,n,t))}),Re.waitFor(i)}},{key:"removeMatchingKeys",value:function(e,t,n){var r=this,i=mu(e);return Re.forEach(t,function(t){var a=Pi(t.path);return Re.waitFor([i.delete([n,a]),r.referenceDelegate.removeReference(e,n,t)])})}},{key:"removeMatchingKeysForTargetId",value:function(e,t){var n=mu(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(r)}},{key:"getMatchingKeysForTargetId",value:function(e,t){var n=IDBKeyRange.bound([t],[t+1],!1,!0),r=mu(e),i=Vr();return r.X({range:n,Z:!0},function(e,t,n){var r=Ri(e[1]),a=new we(r);i=i.add(a)}).next(function(){return i})}},{key:"containsKey",value:function(e,t){var n=Pi(t.path),r=IDBKeyRange.bound([n],[de(n)],!1,!0),i=0;return mu(e).X({index:"documentTargetsIndex",Z:!0,range:r},function(e,t,n){var r=c(e,2),a=r[0];r[1];0!==a&&(i++,n.done())}).next(function(){return i>0})}},{key:"ie",value:function(e,t){return yu(e).get(t).next(function(e){return e?ga(e):null})}}]),e}();function yu(e){return ua(e,"targets")}function pu(e){return ua(e,"targetGlobal")}function mu(e){return ua(e,"targetDocuments")}function gu(e,t){var n=c(e,2),r=n[0],i=n[1],a=c(t,2),u=a[0],o=a[1],s=fe(r,u);return 0===s?fe(i,o):s}var ku=function(){function e(t){P(this,e),this.kn=t,this.buffer=new ln(gu),this.$n=0}return L(e,[{key:"Mn",value:function(){return++this.$n}},{key:"On",value:function(e){var t=[e,this.Mn()];if(this.buffer.size<this.kn)this.buffer=this.buffer.add(t);else{var n=this.buffer.last();gu(t,n)<0&&(this.buffer=this.buffer.delete(n).add(t))}}},{key:"maxValue",get:function(){return this.buffer.last()[0]}}]),e}(),wu=function(){function e(t,n,r){P(this,e),this.garbageCollector=t,this.asyncQueue=n,this.localStore=r,this.Fn=null}return L(e,[{key:"start",value:function(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Bn(6e4)}},{key:"stop",value:function(){this.Fn&&(this.Fn.cancel(),this.Fn=null)}},{key:"started",get:function(){return null!==this.Fn}},{key:"Bn",value:function(e){var t=this;G("LruGarbageCollector","Garbage collection scheduled in ".concat(e,"ms")),this.Fn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:return t.Fn=null,e.prev=1,e.next=4,m().awrap(t.localStore.collectGarbage(t.garbageCollector));case 4:e.next=14;break;case 6:if(e.prev=6,e.t0=e.catch(1),!Ue(e.t0)){e.next=12;break}G("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e.t0),e.next=14;break;case 12:return e.next=14,m().awrap(Le(e.t0));case 14:return e.next=16,m().awrap(t.Bn(3e5));case 16:case"end":return e.stop()}},null,null,[[1,6]],Promise)})}}]),e}(),xu=function(){function e(t,n){P(this,e),this.Ln=t,this.params=n}return L(e,[{key:"calculateTargetCount",value:function(e,t){return this.Ln.qn(e).next(function(e){return Math.floor(t/100*e)})}},{key:"nthSequenceNumber",value:function(e,t){var n=this;if(0===t)return Re.resolve(We.at);var r=new ku(t);return this.Ln.forEachTarget(e,function(e){return r.On(e.sequenceNumber)}).next(function(){return n.Ln.Un(e,function(e){return r.On(e)})}).next(function(){return r.maxValue})}},{key:"removeTargets",value:function(e,t,n){return this.Ln.removeTargets(e,t,n)}},{key:"removeOrphanedDocuments",value:function(e,t){return this.Ln.removeOrphanedDocuments(e,t)}},{key:"collect",value:function(e,t){var n=this;return-1===this.params.cacheSizeCollectionThreshold?(G("LruGarbageCollector","Garbage collection skipped; disabled"),Re.resolve(iu)):this.getCacheSize(e).next(function(r){return r<n.params.cacheSizeCollectionThreshold?(G("LruGarbageCollector","Garbage collection skipped; Cache size ".concat(r," is lower than threshold ").concat(n.params.cacheSizeCollectionThreshold)),iu):n.Kn(e,t)})}},{key:"getCacheSize",value:function(e){return this.Ln.getCacheSize(e)}},{key:"Kn",value:function(e,t){var n,r,a,u,o,s,c,l=this,f=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(function(t){return t>l.params.maximumSequenceNumbersToCollect?(G("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of ".concat(l.params.maximumSequenceNumbersToCollect," from ").concat(t)),r=l.params.maximumSequenceNumbersToCollect):r=t,u=Date.now(),l.nthSequenceNumber(e,r)}).next(function(r){return n=r,o=Date.now(),l.removeTargets(e,n,t)}).next(function(t){return a=t,s=Date.now(),l.removeOrphanedDocuments(e,n)}).next(function(e){return c=Date.now(),B()<=i.LogLevel.DEBUG&&G("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in ".concat(u-f,"ms\n\tDetermined least recently used ").concat(r," in ")+(o-u)+"ms\n"+"\tRemoved ".concat(a," targets in ")+(s-o)+"ms\n"+"\tRemoved ".concat(e," documents in ")+(c-s)+"ms\n"+"Total Duration: ".concat(c-f,"ms")),Re.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:a,documentsRemoved:e})})}}]),e}(),bu=function(){function e(t,n){P(this,e),this.db=t,this.garbageCollector=function(e,t){return new xu(e,t)}(this,n)}return L(e,[{key:"qn",value:function(e){var t=this.Gn(e);return this.db.getTargetCache().getTargetCount(e).next(function(e){return t.next(function(t){return e+t})})}},{key:"Gn",value:function(e){var t=0;return this.Un(e,function(e){t++}).next(function(){return t})}},{key:"forEachTarget",value:function(e,t){return this.db.getTargetCache().forEachTarget(e,t)}},{key:"Un",value:function(e,t){return this.Qn(e,function(e,n){return t(n)})}},{key:"addReference",value:function(e,t,n){return Iu(e,n)}},{key:"removeReference",value:function(e,t,n){return Iu(e,n)}},{key:"removeTargets",value:function(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}},{key:"markPotentiallyOrphaned",value:function(e,t){return Iu(e,t)}},{key:"jn",value:function(e,t){return function(e,t){var n=!1;return hu(e).tt(function(r){return cu(e,r,t).next(function(e){return e&&(n=!0),Re.resolve(!e)})}).next(function(){return n})}(e,t)}},{key:"removeOrphanedDocuments",value:function(e,t){var n=this,r=this.db.getRemoteDocumentCache().newChangeBuffer(),i=[],a=0;return this.Qn(e,function(u,o){if(o<=t){var s=n.jn(e,u).next(function(t){if(!t)return a++,r.getEntry(e,u).next(function(){return r.removeEntry(u,ye.min()),mu(e).delete([0,Pi(u.path)])})});i.push(s)}}).next(function(){return Re.waitFor(i)}).next(function(){return r.apply(e)}).next(function(){return a})}},{key:"removeTarget",value:function(e,t){var n=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,n)}},{key:"updateLimboDocument",value:function(e,t){return Iu(e,t)}},{key:"Qn",value:function(e,t){var n,r=mu(e),i=We.at;return r.X({index:"documentTargetsIndex"},function(e,r){var a=c(e,2),u=a[0],o=(a[1],r.path),s=r.sequenceNumber;0===u?(i!==We.at&&t(new we(Ri(n)),i),i=s,n=o):i=We.at}).next(function(){i!==We.at&&t(new we(Ri(n)),i)})}},{key:"getCacheSize",value:function(e){return this.db.getRemoteDocumentCache().getSize(e)}}]),e}();function Iu(e,t){return mu(e).put(function(e,t){return{targetId:0,path:Pi(e.path),sequenceNumber:t}}(t,e.currentSequenceNumber))}var Tu=function(){function e(){P(this,e),this.changes=new _r(function(e){return e.toString()},function(e,t){return e.isEqual(t)}),this.changesApplied=!1}return L(e,[{key:"addEntry",value:function(e){this.assertNotApplied(),this.changes.set(e.key,e)}},{key:"removeEntry",value:function(e,t){this.assertNotApplied(),this.changes.set(e,pn.newInvalidDocument(e).setReadTime(t))}},{key:"getEntry",value:function(e,t){this.assertNotApplied();var n=this.changes.get(t);return void 0!==n?Re.resolve(n):this.getFromCache(e,t)}},{key:"getEntries",value:function(e,t){return this.getAllFromCache(e,t)}},{key:"apply",value:function(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}},{key:"assertNotApplied",value:function(){}}]),e}(),Eu=function(){function e(t){P(this,e),this.Tt=t}return L(e,[{key:"setIndexManager",value:function(e){this.indexManager=e}},{key:"addEntry",value:function(e,t,n){return Du(e).put(n)}},{key:"removeEntry",value:function(e,t,n){return Du(e).delete(function(e,t){var n=e.path.toArray();return[n.slice(0,n.length-2),n[n.length-2],va(t),n[n.length-1]]}(t,n))}},{key:"updateMetadata",value:function(e,t){var n=this;return this.getMetadata(e).next(function(r){return r.byteSize+=t,n.zn(e,r)})}},{key:"getEntry",value:function(e,t){var n=this,r=pn.newInvalidDocument(t);return Du(e).X({index:"documentKeyIndex",range:IDBKeyRange.only(Nu(t))},function(e,i){r=n.Wn(t,i)}).next(function(){return r})}},{key:"Hn",value:function(e,t){var n=this,r={size:0,document:pn.newInvalidDocument(t)};return Du(e).X({index:"documentKeyIndex",range:IDBKeyRange.only(Nu(t))},function(e,i){r={document:n.Wn(t,i),size:ou(i)}}).next(function(){return r})}},{key:"getEntries",value:function(e,t){var n=this,r=Dr();return this.Jn(e,t,function(e,t){var i=n.Wn(e,t);r=r.insert(e,i)}).next(function(){return r})}},{key:"Yn",value:function(e,t){var n=this,r=Dr(),i=new on(we.comparator);return this.Jn(e,t,function(e,t){var a=n.Wn(e,t);r=r.insert(e,a),i=i.insert(e,ou(t))}).next(function(){return{documents:r,Zn:i}})}},{key:"Jn",value:function(e,t,n){if(t.isEmpty())return Re.resolve();var r=new ln(Pu);t.forEach(function(e){return r=r.add(e)});var i=IDBKeyRange.bound(Nu(r.first()),Nu(r.last())),a=r.getIterator(),u=a.getNext();return Du(e).X({index:"documentKeyIndex",range:i},function(e,t,r){for(var i=we.fromSegments([].concat(E(t.prefixPath),[t.collectionGroup,t.documentId]));u&&Pu(u,i)<0;)n(u,null),u=a.getNext();u&&u.isEqual(i)&&(n(u,t),u=a.hasNext()?a.getNext():null),u?r.j(Nu(u)):r.done()}).next(function(){for(;u;)n(u,null),u=a.hasNext()?a.getNext():null})}},{key:"getDocumentsMatchingQuery",value:function(e,t,n,r){var i=this,a=t.path,u=[a.popLast().toArray(),a.lastSegment(),va(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],o=[a.popLast().toArray(),a.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return Du(e).W(IDBKeyRange.bound(u,o,!0)).next(function(e){var n,a=Dr(),u=p(e);try{for(u.s();!(n=u.n()).done;){var o=n.value,s=i.Wn(we.fromSegments(o.prefixPath.concat(o.collectionGroup,o.documentId)),o);s.isFoundDocument()&&(qn(t,s)||r.has(s.key))&&(a=a.insert(s.key,s))}}catch(c){u.e(c)}finally{u.f()}return a})}},{key:"getAllFromCollectionGroup",value:function(e,t,n,r){var i=this,a=Dr(),u=Cu(t,n),o=Cu(t,Ne.max());return Du(e).X({index:"collectionGroupIndex",range:IDBKeyRange.bound(u,o,!0)},function(e,t,n){var u=i.Wn(we.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);(a=a.insert(u.key,u)).size===r&&n.done()}).next(function(){return a})}},{key:"newChangeBuffer",value:function(e){return new _u(this,!!e&&e.trackRemovals)}},{key:"getSize",value:function(e){return this.getMetadata(e).next(function(e){return e.byteSize})}},{key:"getMetadata",value:function(e){return Au(e).get("remoteDocumentGlobalKey").next(function(e){return H(!!e),e})}},{key:"zn",value:function(e,t){return Au(e).put("remoteDocumentGlobalKey",t)}},{key:"Wn",value:function(e,t){if(t){var n=ha(this.Tt,t);if(!n.isNoDocument()||!n.version.isEqual(ye.min()))return n}return pn.newInvalidDocument(e)}}]),e}();function Su(e){return new Eu(e)}var _u=function(e){g(n,Tu);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this)).Xn=e,i.trackRemovals=r,i.ts=new _r(function(e){return e.toString()},function(e,t){return e.isEqual(t)}),i}return L(n,[{key:"applyChanges",value:function(e){var t=this,n=[],r=0,i=new ln(function(e,t){return fe(e.canonicalString(),t.canonicalString())});return this.changes.forEach(function(a,u){var o=t.ts.get(a);if(n.push(t.Xn.removeEntry(e,a,o.readTime)),u.isValidDocument()){var s=da(t.Xn.Tt,u);i=i.add(a.path.popLast());var c=ou(s);r+=c-o.size,n.push(t.Xn.addEntry(e,a,s))}else if(r-=o.size,t.trackRemovals){var l=da(t.Xn.Tt,u.convertToNoDocument(ye.min()));n.push(t.Xn.addEntry(e,a,l))}}),i.forEach(function(r){n.push(t.Xn.indexManager.addToCollectionParentIndex(e,r))}),n.push(this.Xn.updateMetadata(e,r)),Re.waitFor(n)}},{key:"getFromCache",value:function(e,t){var n=this;return this.Xn.Hn(e,t).next(function(e){return n.ts.set(t,{size:e.size,readTime:e.document.readTime}),e.document})}},{key:"getAllFromCache",value:function(e,t){var n=this;return this.Xn.Yn(e,t).next(function(e){var t=e.documents;return e.Zn.forEach(function(e,r){n.ts.set(e,{size:r,readTime:t.get(e).readTime})}),t})}}]),n}();function Au(e){return ua(e,"remoteDocumentGlobal")}function Du(e){return ua(e,"remoteDocumentsV14")}function Nu(e){var t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function Cu(e,t){var n=t.documentKey.path.toArray();return[e,va(t.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function Pu(e,t){for(var n=e.path.toArray(),r=t.path.toArray(),i=0,a=0;a<n.length-2&&a<r.length-2;++a)if(i=fe(n[a],r[a]))return i;return(i=fe(n.length,r.length))||((i=fe(n[n.length-2],r[r.length-2]))||fe(n[n.length-1],r[r.length-1]))}var Fu=L(function e(t,n){P(this,e),this.overlayedDocument=t,this.mutatedFields=n}),Lu=function(){function e(t,n,r,i){P(this,e),this.remoteDocumentCache=t,this.mutationQueue=n,this.documentOverlayCache=r,this.indexManager=i}return L(e,[{key:"getDocument",value:function(e,t){var n=this,r=null;return this.documentOverlayCache.getOverlay(e,t).next(function(i){return r=i,n.remoteDocumentCache.getEntry(e,t)}).next(function(e){return null!==r&&hr(r.mutation,e,dn.empty(),ve.now()),e})}},{key:"getDocuments",value:function(e,t){var n=this;return this.remoteDocumentCache.getEntries(e,t).next(function(t){return n.getLocalViewOfDocuments(e,t,Vr()).next(function(){return t})})}},{key:"getLocalViewOfDocuments",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Vr(),i=Fr();return this.populateOverlays(e,i,t).next(function(){return n.computeViews(e,t,i,r).next(function(e){var t=Cr();return e.forEach(function(e,n){t=t.insert(e,n.overlayedDocument)}),t})})}},{key:"getOverlayedDocuments",value:function(e,t){var n=this,r=Fr();return this.populateOverlays(e,r,t).next(function(){return n.computeViews(e,t,r,Vr())})}},{key:"populateOverlays",value:function(e,t,n){var r=[];return n.forEach(function(e){t.has(e)||r.push(e)}),this.documentOverlayCache.getOverlays(e,r).next(function(e){e.forEach(function(e,n){t.set(e,n)})})}},{key:"computeViews",value:function(e,t,n,r){var i=Dr(),a=Rr(),u=Rr();return t.forEach(function(e,t){var u=n.get(t.key);r.has(t.key)&&(void 0===u||u.mutation instanceof pr)?i=i.insert(t.key,t):void 0!==u?(a.set(t.key,u.mutation.getFieldMask()),hr(u.mutation,t,u.mutation.getFieldMask(),ve.now())):a.set(t.key,dn.empty())}),this.recalculateAndSaveOverlays(e,i).next(function(e){return e.forEach(function(e,t){return a.set(e,t)}),t.forEach(function(e,t){var n;return u.set(e,new Fu(t,null!==(n=a.get(e))&&void 0!==n?n:null))}),u})}},{key:"recalculateAndSaveOverlays",value:function(e,t){var n=this,r=Rr(),i=new on(function(e,t){return e-t}),a=Vr();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(function(e){var n,a=p(e);try{var u=function(){var e=n.value;e.keys().forEach(function(n){var a=t.get(n);if(null!==a){var u=r.get(n)||dn.empty();u=e.applyToLocalView(a,u),r.set(n,u);var o=(i.get(e.batchId)||Vr()).add(n);i=i.insert(e.batchId,o)}})};for(a.s();!(n=a.n()).done;)u()}catch(o){a.e(o)}finally{a.f()}}).next(function(){for(var u=[],o=i.getReverseIterator(),s=function(){var i=o.getNext(),s=i.key,c=i.value,l=Lr();c.forEach(function(e){if(!a.has(e)){var n=lr(t.get(e),r.get(e));null!==n&&l.set(e,n),a=a.add(e)}}),u.push(n.documentOverlayCache.saveOverlays(e,s,l))};o.hasNext();)s();return Re.waitFor(u)}).next(function(){return r})}},{key:"recalculateAndSaveOverlaysForDocumentKeys",value:function(e,t){var n=this;return this.remoteDocumentCache.getEntries(e,t).next(function(t){return n.recalculateAndSaveOverlays(e,t)})}},{key:"getDocumentsMatchingQuery",value:function(e,t,n){return function(e){return we.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Cn(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n):this.getDocumentsMatchingCollectionQuery(e,t,n)}},{key:"getNextDocuments",value:function(e,t,n,r){var i=this;return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next(function(a){var u=r-a.size>0?i.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-a.size):Re.resolve(Fr()),o=-1,s=a;return u.next(function(t){return Re.forEach(t,function(t,n){return o<n.largestBatchId&&(o=n.largestBatchId),a.get(t)?Re.resolve():i.remoteDocumentCache.getEntry(e,t).next(function(e){s=s.insert(t,e)})}).next(function(){return i.populateOverlays(e,t,a)}).next(function(){return i.computeViews(e,s,t,Vr())}).next(function(e){return{batchId:o,changes:Pr(e)}})})})}},{key:"getDocumentsMatchingDocumentQuery",value:function(e,t){return this.getDocument(e,new we(t)).next(function(e){var t=Cr();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}},{key:"getDocumentsMatchingCollectionGroupQuery",value:function(e,t,n){var r=this,i=t.collectionGroup,a=Cr();return this.indexManager.getCollectionParents(e,i).next(function(u){return Re.forEach(u,function(u){var o=function(e,t){return new En(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,u.child(i));return r.getDocumentsMatchingCollectionQuery(e,o,n).next(function(e){e.forEach(function(e,t){a=a.insert(e,t)})})}).next(function(){return a})})}},{key:"getDocumentsMatchingCollectionQuery",value:function(e,t,n){var r,i=this;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next(function(a){return r=a,i.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,r)}).next(function(e){r.forEach(function(t,n){var r=n.getKey();null===e.get(r)&&(e=e.insert(r,pn.newInvalidDocument(r)))});var n=Cr();return e.forEach(function(e,i){var a=r.get(e);void 0!==a&&hr(a.mutation,i,dn.empty(),ve.now()),qn(t,i)&&(n=n.insert(e,i))}),n})}}]),e}(),Ru=function(){function e(t){P(this,e),this.Tt=t,this.es=new Map,this.ns=new Map}return L(e,[{key:"getBundleMetadata",value:function(e,t){return Re.resolve(this.es.get(t))}},{key:"saveBundleMetadata",value:function(e,t){var n;return this.es.set(t.id,{id:(n=t).id,version:n.version,createTime:ri(n.createTime)}),Re.resolve()}},{key:"getNamedQuery",value:function(e,t){return Re.resolve(this.ns.get(t))}},{key:"saveNamedQuery",value:function(e,t){return this.ns.set(t.name,function(e){return{name:e.name,query:wa(e.bundledQuery),readTime:ri(e.readTime)}}(t)),Re.resolve()}}]),e}(),Mu=function(){function e(){P(this,e),this.overlays=new on(we.comparator),this.ss=new Map}return L(e,[{key:"getOverlay",value:function(e,t){return Re.resolve(this.overlays.get(t))}},{key:"getOverlays",value:function(e,t){var n=this,r=Fr();return Re.forEach(t,function(t){return n.getOverlay(e,t).next(function(e){null!==e&&r.set(t,e)})}).next(function(){return r})}},{key:"saveOverlays",value:function(e,t,n){var r=this;return n.forEach(function(n,i){r.ce(e,t,i)}),Re.resolve()}},{key:"removeOverlaysForBatchId",value:function(e,t,n){var r=this,i=this.ss.get(n);return void 0!==i&&(i.forEach(function(e){return r.overlays=r.overlays.remove(e)}),this.ss.delete(n)),Re.resolve()}},{key:"getOverlaysForCollection",value:function(e,t,n){for(var r=Fr(),i=t.length+1,a=new we(t.child("")),u=this.overlays.getIteratorFrom(a);u.hasNext();){var o=u.getNext().value,s=o.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===i&&o.largestBatchId>n&&r.set(o.getKey(),o)}return Re.resolve(r)}},{key:"getOverlaysForCollectionGroup",value:function(e,t,n,r){for(var i=new on(function(e,t){return e-t}),a=this.overlays.getIterator();a.hasNext();){var u=a.getNext().value;if(u.getKey().getCollectionGroup()===t&&u.largestBatchId>n){var o=i.get(u.largestBatchId);null===o&&(o=Fr(),i=i.insert(u.largestBatchId,o)),o.set(u.getKey(),u)}}for(var s=Fr(),c=i.getIterator();c.hasNext()&&(c.getNext().value.forEach(function(e,t){return s.set(e,t)}),!(s.size()>=r)););return Re.resolve(s)}},{key:"ce",value:function(e,t,n){var r=this.overlays.get(n.key);if(null!==r){var i=this.ss.get(r.largestBatchId).delete(n.key);this.ss.set(r.largestBatchId,i)}this.overlays=this.overlays.insert(n.key,new ca(t,n));var a=this.ss.get(t);void 0===a&&(a=Vr(),this.ss.set(t,a)),this.ss.set(t,a.add(n.key))}}]),e}(),Ou=function(){function e(){P(this,e),this.rs=new ln(Vu.os),this.us=new ln(Vu.cs)}return L(e,[{key:"isEmpty",value:function(){return this.rs.isEmpty()}},{key:"addReference",value:function(e,t){var n=new Vu(e,t);this.rs=this.rs.add(n),this.us=this.us.add(n)}},{key:"hs",value:function(e,t){var n=this;e.forEach(function(e){return n.addReference(e,t)})}},{key:"removeReference",value:function(e,t){this.ls(new Vu(e,t))}},{key:"fs",value:function(e,t){var n=this;e.forEach(function(e){return n.removeReference(e,t)})}},{key:"ds",value:function(e){var t=this,n=new we(new me([])),r=new Vu(n,e),i=new Vu(n,e+1),a=[];return this.us.forEachInRange([r,i],function(e){t.ls(e),a.push(e.key)}),a}},{key:"_s",value:function(){var e=this;this.rs.forEach(function(t){return e.ls(t)})}},{key:"ls",value:function(e){this.rs=this.rs.delete(e),this.us=this.us.delete(e)}},{key:"ws",value:function(e){var t=new we(new me([])),n=new Vu(t,e),r=new Vu(t,e+1),i=Vr();return this.us.forEachInRange([n,r],function(e){i=i.add(e.key)}),i}},{key:"containsKey",value:function(e){var t=new Vu(e,0),n=this.rs.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}]),e}(),Vu=function(){function e(t,n){P(this,e),this.key=t,this.gs=n}return L(e,null,[{key:"os",value:function(e,t){return we.comparator(e.key,t.key)||fe(e.gs,t.gs)}},{key:"cs",value:function(e,t){return fe(e.gs,t.gs)||we.comparator(e.key,t.key)}}]),e}(),qu=function(){function e(t,n){P(this,e),this.indexManager=t,this.referenceDelegate=n,this.mutationQueue=[],this.ys=1,this.ps=new ln(Vu.os)}return L(e,[{key:"checkEmpty",value:function(e){return Re.resolve(0===this.mutationQueue.length)}},{key:"addMutationBatch",value:function(e,t,n,r){var i=this.ys;this.ys++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];var a=new oa(i,t,n,r);this.mutationQueue.push(a);var u,o=p(r);try{for(o.s();!(u=o.n()).done;){var s=u.value;this.ps=this.ps.add(new Vu(s.key,i)),this.indexManager.addToCollectionParentIndex(e,s.key.path.popLast())}}catch(c){o.e(c)}finally{o.f()}return Re.resolve(a)}},{key:"lookupMutationBatch",value:function(e,t){return Re.resolve(this.Is(t))}},{key:"getNextMutationBatchAfterBatchId",value:function(e,t){var n=t+1,r=this.Ts(n),i=r<0?0:r;return Re.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}},{key:"getHighestUnacknowledgedBatchId",value:function(){return Re.resolve(0===this.mutationQueue.length?-1:this.ys-1)}},{key:"getAllMutationBatches",value:function(e){return Re.resolve(this.mutationQueue.slice())}},{key:"getAllMutationBatchesAffectingDocumentKey",value:function(e,t){var n=this,r=new Vu(t,0),i=new Vu(t,Number.POSITIVE_INFINITY),a=[];return this.ps.forEachInRange([r,i],function(e){var t=n.Is(e.gs);a.push(t)}),Re.resolve(a)}},{key:"getAllMutationBatchesAffectingDocumentKeys",value:function(e,t){var n=this,r=new ln(fe);return t.forEach(function(e){var t=new Vu(e,0),i=new Vu(e,Number.POSITIVE_INFINITY);n.ps.forEachInRange([t,i],function(e){r=r.add(e.gs)})}),Re.resolve(this.Es(r))}},{key:"getAllMutationBatchesAffectingQuery",value:function(e,t){var n=t.path,r=n.length+1,i=n;we.isDocumentKey(i)||(i=i.child(""));var a=new Vu(new we(i),0),u=new ln(fe);return this.ps.forEachWhile(function(e){var t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(u=u.add(e.gs)),!0)},a),Re.resolve(this.Es(u))}},{key:"Es",value:function(e){var t=this,n=[];return e.forEach(function(e){var r=t.Is(e);null!==r&&n.push(r)}),n}},{key:"removeMutationBatch",value:function(e,t){var n=this;H(0===this.As(t.batchId,"removed")),this.mutationQueue.shift();var r=this.ps;return Re.forEach(t.mutations,function(i){var a=new Vu(i.key,t.batchId);return r=r.delete(a),n.referenceDelegate.markPotentiallyOrphaned(e,i.key)}).next(function(){n.ps=r})}},{key:"Pn",value:function(e){}},{key:"containsKey",value:function(e,t){var n=new Vu(t,0),r=this.ps.firstAfterOrEqual(n);return Re.resolve(t.isEqual(r&&r.key))}},{key:"performConsistencyCheck",value:function(e){return this.mutationQueue.length,Re.resolve()}},{key:"As",value:function(e,t){return this.Ts(e)}},{key:"Ts",value:function(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}},{key:"Is",value:function(e){var t=this.Ts(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}]),e}(),Uu=function(){function e(t){P(this,e),this.Rs=t,this.docs=new on(we.comparator),this.size=0}return L(e,[{key:"setIndexManager",value:function(e){this.indexManager=e}},{key:"addEntry",value:function(e,t){var n=t.key,r=this.docs.get(n),i=r?r.size:0,a=this.Rs(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}},{key:"removeEntry",value:function(e){var t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}},{key:"getEntry",value:function(e,t){var n=this.docs.get(t);return Re.resolve(n?n.document.mutableCopy():pn.newInvalidDocument(t))}},{key:"getEntries",value:function(e,t){var n=this,r=Dr();return t.forEach(function(e){var t=n.docs.get(e);r=r.insert(e,t?t.document.mutableCopy():pn.newInvalidDocument(e))}),Re.resolve(r)}},{key:"getDocumentsMatchingQuery",value:function(e,t,n,r){for(var i=Dr(),a=t.path,u=new we(a.child("")),o=this.docs.getIteratorFrom(u);o.hasNext();){var s=o.getNext(),c=s.key,l=s.value.document;if(!a.isPrefixOf(c.path))break;c.path.length>a.length+1||Ce(De(l),n)<=0||(r.has(l.key)||qn(t,l))&&(i=i.insert(l.key,l.mutableCopy()))}return Re.resolve(i)}},{key:"getAllFromCollectionGroup",value:function(e,t,n,r){W()}},{key:"Ps",value:function(e,t){return Re.forEach(this.docs,function(e){return t(e)})}},{key:"newChangeBuffer",value:function(e){return new Bu(this)}},{key:"getSize",value:function(e){return Re.resolve(this.size)}}]),e}(),Bu=function(e){g(n,Tu);var t=w(n);function n(e){var r;return P(this,n),(r=t.call(this)).Xn=e,r}return L(n,[{key:"applyChanges",value:function(e){var t=this,n=[];return this.changes.forEach(function(r,i){i.isValidDocument()?n.push(t.Xn.addEntry(e,i)):t.Xn.removeEntry(r)}),Re.waitFor(n)}},{key:"getFromCache",value:function(e,t){return this.Xn.getEntry(e,t)}},{key:"getAllFromCache",value:function(e,t){return this.Xn.getEntries(e,t)}}]),n}(),Ku=function(){function e(t){P(this,e),this.persistence=t,this.vs=new _r(function(e){return kn(e)},wn),this.lastRemoteSnapshotVersion=ye.min(),this.highestTargetId=0,this.bs=0,this.Vs=new Ou,this.targetCount=0,this.Ss=du.Vn()}return L(e,[{key:"forEachTarget",value:function(e,t){return this.vs.forEach(function(e,n){return t(n)}),Re.resolve()}},{key:"getLastRemoteSnapshotVersion",value:function(e){return Re.resolve(this.lastRemoteSnapshotVersion)}},{key:"getHighestSequenceNumber",value:function(e){return Re.resolve(this.bs)}},{key:"allocateTargetId",value:function(e){return this.highestTargetId=this.Ss.next(),Re.resolve(this.highestTargetId)}},{key:"setTargetsMetadata",value:function(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.bs&&(this.bs=t),Re.resolve()}},{key:"xn",value:function(e){this.vs.set(e.target,e);var t=e.targetId;t>this.highestTargetId&&(this.Ss=new du(t),this.highestTargetId=t),e.sequenceNumber>this.bs&&(this.bs=e.sequenceNumber)}},{key:"addTargetData",value:function(e,t){return this.xn(t),this.targetCount+=1,Re.resolve()}},{key:"updateTargetData",value:function(e,t){return this.xn(t),Re.resolve()}},{key:"removeTargetData",value:function(e,t){return this.vs.delete(t.target),this.Vs.ds(t.targetId),this.targetCount-=1,Re.resolve()}},{key:"removeTargets",value:function(e,t,n){var r=this,i=0,a=[];return this.vs.forEach(function(u,o){o.sequenceNumber<=t&&null===n.get(o.targetId)&&(r.vs.delete(u),a.push(r.removeMatchingKeysForTargetId(e,o.targetId)),i++)}),Re.waitFor(a).next(function(){return i})}},{key:"getTargetCount",value:function(e){return Re.resolve(this.targetCount)}},{key:"getTargetData",value:function(e,t){var n=this.vs.get(t)||null;return Re.resolve(n)}},{key:"addMatchingKeys",value:function(e,t,n){return this.Vs.hs(t,n),Re.resolve()}},{key:"removeMatchingKeys",value:function(e,t,n){this.Vs.fs(t,n);var r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(function(t){i.push(r.markPotentiallyOrphaned(e,t))}),Re.waitFor(i)}},{key:"removeMatchingKeysForTargetId",value:function(e,t){return this.Vs.ds(t),Re.resolve()}},{key:"getMatchingKeysForTargetId",value:function(e,t){var n=this.Vs.ws(t);return Re.resolve(n)}},{key:"containsKey",value:function(e,t){return Re.resolve(this.Vs.containsKey(t))}}]),e}(),Gu=function(){function e(t,n){var r=this;P(this,e),this.Ds={},this.overlays={},this.Cs=new We(0),this.xs=!1,this.xs=!0,this.referenceDelegate=t(this),this.Ns=new Ku(this),this.indexManager=new Xa,this.remoteDocumentCache=new Uu(function(e){return r.referenceDelegate.ks(e)}),this.Tt=new fa(n),this.$s=new Ru(this.Tt)}return L(e,[{key:"start",value:function(){return Promise.resolve()}},{key:"shutdown",value:function(){return this.xs=!1,Promise.resolve()}},{key:"started",get:function(){return this.xs}},{key:"setDatabaseDeletedListener",value:function(){}},{key:"setNetworkEnabled",value:function(){}},{key:"getIndexManager",value:function(e){return this.indexManager}},{key:"getDocumentOverlayCache",value:function(e){var t=this.overlays[e.toKey()];return t||(t=new Mu,this.overlays[e.toKey()]=t),t}},{key:"getMutationQueue",value:function(e,t){var n=this.Ds[e.toKey()];return n||(n=new qu(t,this.referenceDelegate),this.Ds[e.toKey()]=n),n}},{key:"getTargetCache",value:function(){return this.Ns}},{key:"getRemoteDocumentCache",value:function(){return this.remoteDocumentCache}},{key:"getBundleCache",value:function(){return this.$s}},{key:"runTransaction",value:function(e,t,n){var r=this;G("MemoryPersistence","Starting transaction:",e);var i=new Qu(this.Cs.next());return this.referenceDelegate.Ms(),n(i).next(function(e){return r.referenceDelegate.Os(i).next(function(){return e})}).toPromise().then(function(e){return i.raiseOnCommittedEvent(),e})}},{key:"Fs",value:function(e,t){return Re.or(Object.values(this.Ds).map(function(n){return function(){return n.containsKey(e,t)}}))}}]),e}(),Qu=function(e){g(n,Fe);var t=w(n);function n(e){var r;return P(this,n),(r=t.call(this)).currentSequenceNumber=e,r}return L(n)}(),ju=function(){function e(t){P(this,e),this.persistence=t,this.Bs=new Ou,this.Ls=null}return L(e,[{key:"Us",get:function(){if(this.Ls)return this.Ls;throw W()}},{key:"addReference",value:function(e,t,n){return this.Bs.addReference(n,t),this.Us.delete(n.toString()),Re.resolve()}},{key:"removeReference",value:function(e,t,n){return this.Bs.removeReference(n,t),this.Us.add(n.toString()),Re.resolve()}},{key:"markPotentiallyOrphaned",value:function(e,t){return this.Us.add(t.toString()),Re.resolve()}},{key:"removeTarget",value:function(e,t){var n=this;this.Bs.ds(t.targetId).forEach(function(e){return n.Us.add(e.toString())});var r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(function(e){e.forEach(function(e){return n.Us.add(e.toString())})}).next(function(){return r.removeTargetData(e,t)})}},{key:"Ms",value:function(){this.Ls=new Set}},{key:"Os",value:function(e){var t=this,n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return Re.forEach(this.Us,function(r){var i=we.fromPath(r);return t.Ks(e,i).next(function(e){e||n.removeEntry(i,ye.min())})}).next(function(){return t.Ls=null,n.apply(e)})}},{key:"updateLimboDocument",value:function(e,t){var n=this;return this.Ks(e,t).next(function(e){e?n.Us.delete(t.toString()):n.Us.add(t.toString())})}},{key:"ks",value:function(e){return 0}},{key:"Ks",value:function(e,t){var n=this;return Re.or([function(){return Re.resolve(n.Bs.containsKey(t))},function(){return n.persistence.getTargetCache().containsKey(e,t)},function(){return n.persistence.Fs(e,t)}])}}],[{key:"qs",value:function(t){return new e(t)}}]),e}(),zu=function(){function e(t){P(this,e),this.Tt=t}return L(e,[{key:"F",value:function(e,t,n,r){var i=this,a=new Me("createOrUpgrade",t);n<1&&r>=1&&(function(e){e.createObjectStore("owner")}(e),function(e){e.createObjectStore("mutationQueues",{keyPath:"userId"}),e.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Mi,{unique:!0}),e.createObjectStore("documentMutations")}(e),Wu(e),function(e){e.createObjectStore("remoteDocuments")}(e));var u=Re.resolve();return n<3&&r>=3&&(0!==n&&(function(e){e.deleteObjectStore("targetDocuments"),e.deleteObjectStore("targets"),e.deleteObjectStore("targetGlobal")}(e),Wu(e)),u=u.next(function(){return e=a.store("targetGlobal"),t={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:ye.min().toTimestamp(),targetCount:0},e.put("targetGlobalKey",t);var e,t})),n<4&&r>=4&&(0!==n&&(u=u.next(function(){return function(e,t){return t.store("mutations").W().next(function(n){e.deleteObjectStore("mutations"),e.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Mi,{unique:!0});var r=t.store("mutations"),i=n.map(function(e){return r.put(e)});return Re.waitFor(i)})}(e,a)})),u=u.next(function(){!function(e){e.createObjectStore("clientMetadata",{keyPath:"clientId"})}(e)})),n<5&&r>=5&&(u=u.next(function(){return i.Gs(a)})),n<6&&r>=6&&(u=u.next(function(){return function(e){e.createObjectStore("remoteDocumentGlobal")}(e),i.Qs(a)})),n<7&&r>=7&&(u=u.next(function(){return i.js(a)})),n<8&&r>=8&&(u=u.next(function(){return i.zs(e,a)})),n<9&&r>=9&&(u=u.next(function(){!function(e){e.objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges")}(e)})),n<10&&r>=10&&(u=u.next(function(){return i.Ws(a)})),n<11&&r>=11&&(u=u.next(function(){!function(e){e.createObjectStore("bundles",{keyPath:"bundleId"})}(e),function(e){e.createObjectStore("namedQueries",{keyPath:"name"})}(e)})),n<12&&r>=12&&(u=u.next(function(){!function(e){var t=e.createObjectStore("documentOverlays",{keyPath:Ji});t.createIndex("collectionPathOverlayIndex",Zi,{unique:!1}),t.createIndex("collectionGroupOverlayIndex",$i,{unique:!1})}(e)})),n<13&&r>=13&&(u=u.next(function(){return function(e){var t=e.createObjectStore("remoteDocumentsV14",{keyPath:Ui});t.createIndex("documentKeyIndex",Bi),t.createIndex("collectionGroupIndex",Ki)}(e)}).next(function(){return i.Hs(e,a)}).next(function(){return e.deleteObjectStore("remoteDocuments")})),n<14&&r>=14&&(u=u.next(function(){return i.Js(e,a)})),n<15&&r>=15&&(u=u.next(function(){return function(e){e.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),e.createObjectStore("indexState",{keyPath:Wi}).createIndex("sequenceNumberIndex",Hi,{unique:!1}),e.createObjectStore("indexEntries",{keyPath:Xi}).createIndex("documentKeyIndex",Yi,{unique:!1})}(e)})),u}},{key:"Qs",value:function(e){var t=0;return e.store("remoteDocuments").X(function(e,n){t+=ou(n)}).next(function(){var n={byteSize:t};return e.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",n)})}},{key:"Gs",value:function(e){var t=this,n=e.store("mutationQueues"),r=e.store("mutations");return n.W().next(function(n){return Re.forEach(n,function(n){var i=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return r.W("userMutationsIndex",i).next(function(r){return Re.forEach(r,function(r){H(r.userId===n.userId);var i=ma(t.Tt,r);return uu(e,n.userId,i).next(function(){})})})})})}},{key:"js",value:function(e){var t=e.store("targetDocuments"),n=e.store("remoteDocuments");return e.store("targetGlobal").get("targetGlobalKey").next(function(e){var r=[];return n.X(function(n,i){var a=new me(n),u=[0,Pi(a)];r.push(t.get(u).next(function(n){return n?Re.resolve():function(n){return t.put({targetId:0,path:Pi(n),sequenceNumber:e.highestListenSequenceNumber})}(a)}))}).next(function(){return Re.waitFor(r)})})}},{key:"zs",value:function(e,t){e.createObjectStore("collectionParents",{keyPath:zi});var n=t.store("collectionParents"),r=new Ya,i=function(e){if(r.add(e)){var t=e.lastSegment(),i=e.popLast();return n.put({collectionId:t,parent:Pi(i)})}};return t.store("remoteDocuments").X({Z:!0},function(e,t){var n=new me(e);return i(n.popLast())}).next(function(){return t.store("documentMutations").X({Z:!0},function(e,t){var n=c(e,3),r=(n[0],n[1]),a=(n[2],Ri(r));return i(a.popLast())})})}},{key:"Ws",value:function(e){var t=this,n=e.store("targets");return n.X(function(e,r){var i=ga(r),a=ka(t.Tt,i);return n.put(a)})}},{key:"Hs",value:function(e,t){var n=t.store("remoteDocuments"),r=[];return n.X(function(e,n){var i,a=t.store("remoteDocumentsV14"),u=(i=n,i.document?new we(me.fromString(i.document.name).popFirst(5)):i.noDocument?we.fromSegments(i.noDocument.path):i.unknownDocument?we.fromSegments(i.unknownDocument.path):W()).path.toArray(),o={prefixPath:u.slice(0,u.length-2),collectionGroup:u[u.length-2],documentId:u[u.length-1],readTime:n.readTime||[0,0],unknownDocument:n.unknownDocument,noDocument:n.noDocument,document:n.document,hasCommittedMutations:!!n.hasCommittedMutations};r.push(a.put(o))}).next(function(){return Re.waitFor(r)})}},{key:"Js",value:function(e,t){var n=this,r=t.store("mutations"),i=Su(this.Tt),a=new Gu(ju.qs,this.Tt.oe);return r.W().next(function(e){var r=new Map;return e.forEach(function(e){var t,i=null!==(t=r.get(e.userId))&&void 0!==t?t:Vr();ma(n.Tt,e).keys().forEach(function(e){return i=i.add(e)}),r.set(e.userId,i)}),Re.forEach(r,function(e,r){var u=new V(r),o=_a.ue(n.Tt,u),s=a.getIndexManager(u),c=su.ue(u,n.Tt,s,a.referenceDelegate);return new Lu(i,c,o,s).recalculateAndSaveOverlaysForDocumentKeys(new aa(t,We.at),e).next()})})}}]),e}();function Wu(e){e.createObjectStore("targetDocuments",{keyPath:Qi}).createIndex("documentTargetsIndex",ji,{unique:!0}),e.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",Gi,{unique:!0}),e.createObjectStore("targetGlobal")}var Hu="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",Xu=function(){function e(t,n,r,i,a,u,o,s,c,l){var f=arguments.length>10&&void 0!==arguments[10]?arguments[10]:15;if(P(this,e),this.allowTabSynchronization=t,this.persistenceKey=n,this.clientId=r,this.Ys=a,this.window=u,this.document=o,this.Zs=c,this.Xs=l,this.ti=f,this.Cs=null,this.xs=!1,this.isPrimary=!1,this.networkEnabled=!0,this.ei=null,this.inForeground=!1,this.ni=null,this.si=null,this.ii=Number.NEGATIVE_INFINITY,this.ri=function(e){return Promise.resolve()},!e.C())throw new Z(J.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new bu(this,i),this.oi=n+"main",this.Tt=new fa(s),this.ui=new Oe(this.oi,this.ti,new zu(this.Tt)),this.Ns=new vu(this.referenceDelegate,this.Tt),this.remoteDocumentCache=Su(this.Tt),this.$s=new Ta,this.window&&this.window.localStorage?this.ci=this.window.localStorage:(this.ci=null,!1===l&&Q("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}return L(e,[{key:"start",value:function(){var e=this;return this.ai().then(function(){if(!e.isPrimary&&!e.allowTabSynchronization)throw new Z(J.FAILED_PRECONDITION,Hu);return e.hi(),e.li(),e.fi(),e.runTransaction("getHighestListenSequenceNumber","readonly",function(t){return e.Ns.getHighestSequenceNumber(t)})}).then(function(t){e.Cs=new We(t,e.Zs)}).then(function(){e.xs=!0}).catch(function(t){return e.ui&&e.ui.close(),Promise.reject(t)})}},{key:"di",value:function(e){var t=this;return this.ri=function(n){return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!t.started){r.next=2;break}return r.abrupt("return",e(n));case 2:case"end":return r.stop()}},null,null,null,Promise)},e(this.isPrimary)}},{key:"setDatabaseDeletedListener",value:function(e){this.ui.L(function(t){return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:if(n.t0=null===t.newVersion,!n.t0){n.next=4;break}return n.next=4,m().awrap(e());case 4:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"setNetworkEnabled",value:function(e){var t=this;this.networkEnabled!==e&&(this.networkEnabled=e,this.Ys.enqueueAndForget(function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=t.started,!e.t0){e.next=4;break}return e.next=4,m().awrap(t.ai());case 4:case"end":return e.stop()}},null,null,null,Promise)}))}},{key:"ai",value:function(){var e=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",function(t){return Ju(t).put({clientId:e.clientId,updateTimeMs:Date.now(),networkEnabled:e.networkEnabled,inForeground:e.inForeground}).next(function(){if(e.isPrimary)return e._i(t).next(function(t){t||(e.isPrimary=!1,e.Ys.enqueueRetryable(function(){return e.ri(!1)}))})}).next(function(){return e.wi(t)}).next(function(n){return e.isPrimary&&!n?e.mi(t).next(function(){return!1}):!!n&&e.gi(t).next(function(){return!0})})}).catch(function(t){if(Ue(t))return G("IndexedDbPersistence","Failed to extend owner lease: ",t),e.isPrimary;if(!e.allowTabSynchronization)throw t;return G("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1}).then(function(t){e.isPrimary!==t&&e.Ys.enqueueRetryable(function(){return e.ri(t)}),e.isPrimary=t})}},{key:"_i",value:function(e){var t=this;return Yu(e).get("owner").next(function(e){return Re.resolve(t.yi(e))})}},{key:"pi",value:function(e){return Ju(e).delete(this.clientId)}},{key:"Ii",value:function(){var e,t,n,r,i=this;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!this.isPrimary||this.Ti(this.ii,18e5)){a.next=6;break}return this.ii=Date.now(),a.next=4,m().awrap(this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",function(e){var t=ua(e,"clientMetadata");return t.W().next(function(e){var n=i.Ei(e,18e5),r=e.filter(function(e){return-1===n.indexOf(e)});return Re.forEach(r,function(e){return t.delete(e.clientId)}).next(function(){return r})})}).catch(function(){return[]}));case 4:if(e=a.sent,this.ci){t=p(e);try{for(t.s();!(n=t.n()).done;)r=n.value,this.ci.removeItem(this.Ai(r.clientId))}catch(u){t.e(u)}finally{t.f()}}case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"fi",value:function(){var e=this;this.si=this.Ys.enqueueAfterDelay("client_metadata_refresh",4e3,function(){return e.ai().then(function(){return e.Ii()}).then(function(){return e.fi()})})}},{key:"yi",value:function(e){return!!e&&e.ownerId===this.clientId}},{key:"wi",value:function(e){var t=this;return this.Xs?Re.resolve(!0):Yu(e).get("owner").next(function(n){if(null!==n&&t.Ti(n.leaseTimestampMs,5e3)&&!t.Ri(n.ownerId)){if(t.yi(n)&&t.networkEnabled)return!0;if(!t.yi(n)){if(!n.allowTabSynchronization)throw new Z(J.FAILED_PRECONDITION,Hu);return!1}}return!(!t.networkEnabled||!t.inForeground)||Ju(e).W().next(function(e){return void 0===t.Ei(e,5e3).find(function(e){if(t.clientId!==e.clientId){var n=!t.networkEnabled&&e.networkEnabled,r=!t.inForeground&&e.inForeground,i=t.networkEnabled===e.networkEnabled;if(n||r&&i)return!0}return!1})})}).next(function(e){return t.isPrimary!==e&&G("IndexedDbPersistence","Client ".concat(e?"is":"is not"," eligible for a primary lease.")),e})}},{key:"shutdown",value:function(){var e=this;return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.xs=!1,this.Pi(),this.si&&(this.si.cancel(),this.si=null),this.vi(),this.bi(),t.next=7,m().awrap(this.ui.runTransaction("shutdown","readwrite",["owner","clientMetadata"],function(t){var n=new aa(t,We.at);return e.mi(n).next(function(){return e.pi(n)})}));case 7:this.ui.close(),this.Vi();case 9:case"end":return t.stop()}},null,this,null,Promise)}},{key:"Ei",value:function(e,t){var n=this;return e.filter(function(e){return n.Ti(e.updateTimeMs,t)&&!n.Ri(e.clientId)})}},{key:"Si",value:function(){var e=this;return this.runTransaction("getActiveClients","readonly",function(t){return Ju(t).W().next(function(t){return e.Ei(t,18e5).map(function(e){return e.clientId})})})}},{key:"started",get:function(){return this.xs}},{key:"getMutationQueue",value:function(e,t){return su.ue(e,this.Tt,t,this.referenceDelegate)}},{key:"getTargetCache",value:function(){return this.Ns}},{key:"getRemoteDocumentCache",value:function(){return this.remoteDocumentCache}},{key:"getIndexManager",value:function(e){return new Za(e,this.Tt.oe.databaseId)}},{key:"getDocumentOverlayCache",value:function(e){return _a.ue(this.Tt,e)}},{key:"getBundleCache",value:function(){return this.$s}},{key:"runTransaction",value:function(e,t,n){var r=this;G("IndexedDbPersistence","Starting transaction:",e);var i,a,u="readonly"===t?"readonly":"readwrite",o=15===(i=this.ti)?ia:14===i?ra:13===i?na:12===i?ta:11===i?ea:void W();return this.ui.runTransaction(e,u,o,function(i){return a=new aa(i,r.Cs?r.Cs.next():We.at),"readwrite-primary"===t?r._i(a).next(function(e){return!!e||r.wi(a)}).next(function(t){if(!t)throw Q("Failed to obtain primary lease for action '".concat(e,"'.")),r.isPrimary=!1,r.Ys.enqueueRetryable(function(){return r.ri(!1)}),new Z(J.FAILED_PRECONDITION,Pe);return n(a)}).next(function(e){return r.gi(a).next(function(){return e})}):r.Di(a).next(function(){return n(a)})}).then(function(e){return a.raiseOnCommittedEvent(),e})}},{key:"Di",value:function(e){var t=this;return Yu(e).get("owner").next(function(e){if(null!==e&&t.Ti(e.leaseTimestampMs,5e3)&&!t.Ri(e.ownerId)&&!t.yi(e)&&!(t.Xs||t.allowTabSynchronization&&e.allowTabSynchronization))throw new Z(J.FAILED_PRECONDITION,Hu)})}},{key:"gi",value:function(e){var t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return Yu(e).put("owner",t)}},{key:"mi",value:function(e){var t=this,n=Yu(e);return n.get("owner").next(function(e){return t.yi(e)?(G("IndexedDbPersistence","Releasing primary lease."),n.delete("owner")):Re.resolve()})}},{key:"Ti",value:function(e,t){var n=Date.now();return!(e<n-t||e>n&&(Q("Detected an update time that is in the future: ".concat(e," > ").concat(n)),1))}},{key:"hi",value:function(){var e=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.ni=function(){e.Ys.enqueueAndForget(function(){return e.inForeground="visible"===e.document.visibilityState,e.ai()})},this.document.addEventListener("visibilitychange",this.ni),this.inForeground="visible"===this.document.visibilityState)}},{key:"vi",value:function(){this.ni&&(this.document.removeEventListener("visibilitychange",this.ni),this.ni=null)}},{key:"li",value:function(){var e,t=this;"function"==typeof(null===(e=this.window)||void 0===e?void 0:e.addEventListener)&&(this.ei=function(){t.Pi();var e=/(?:Version|Mobile)\/1[456]/;(0,a.isSafari)()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&t.Ys.enterRestrictedMode(!0),t.Ys.enqueueAndForget(function(){return t.shutdown()})},this.window.addEventListener("pagehide",this.ei))}},{key:"bi",value:function(){this.ei&&(this.window.removeEventListener("pagehide",this.ei),this.ei=null)}},{key:"Ri",value:function(e){var t;try{var n=null!==(null===(t=this.ci)||void 0===t?void 0:t.getItem(this.Ai(e)));return G("IndexedDbPersistence","Client '".concat(e,"' ").concat(n?"is":"is not"," zombied in LocalStorage")),n}catch(e){return Q("IndexedDbPersistence","Failed to get zombied client id.",e),!1}}},{key:"Pi",value:function(){if(this.ci)try{this.ci.setItem(this.Ai(this.clientId),String(Date.now()))}catch(e){Q("Failed to set zombie client id.",e)}}},{key:"Vi",value:function(){if(this.ci)try{this.ci.removeItem(this.Ai(this.clientId))}catch(e){}}},{key:"Ai",value:function(e){return"firestore_zombie_".concat(this.persistenceKey,"_").concat(e)}}],[{key:"C",value:function(){return Oe.C()}}]),e}();function Yu(e){return ua(e,"owner")}function Ju(e){return ua(e,"clientMetadata")}function Zu(e,t){var n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}var $u=function(){function e(t,n,r,i){P(this,e),this.targetId=t,this.fromCache=n,this.Ci=r,this.xi=i}return L(e,null,[{key:"Ni",value:function(t,n){var r,i=Vr(),a=Vr(),u=p(n.docChanges);try{for(u.s();!(r=u.n()).done;){var o=r.value;switch(o.type){case 0:i=i.add(o.doc.key);break;case 1:a=a.add(o.doc.key)}}}catch(s){u.e(s)}finally{u.f()}return new e(t,n.fromCache,i,a)}}]),e}(),eo=function(){function e(){P(this,e),this.ki=!1}return L(e,[{key:"initialize",value:function(e,t){this.$i=e,this.indexManager=t,this.ki=!0}},{key:"getDocumentsMatchingQuery",value:function(e,t,n,r){var i=this;return this.Mi(e,t).next(function(a){return a||i.Oi(e,t,r,n)}).next(function(n){return n||i.Fi(e,t)})}},{key:"Mi",value:function(e,t){var n=this;if(An(t))return Re.resolve(null);var r=Fn(t);return this.indexManager.getIndexType(e,r).next(function(i){return 0===i?null:(null!==t.limit&&1===i&&(t=Rn(t,null,"F"),r=Fn(t)),n.indexManager.getDocumentsMatchingTarget(e,r).next(function(i){var a=Vr.apply(void 0,E(i));return n.$i.getDocuments(e,a).next(function(i){return n.indexManager.getMinOffset(e,r).next(function(r){var u=n.Bi(t,i);return n.Li(t,u,a,r.readTime)?n.Mi(e,Rn(t,null,"F")):n.qi(e,u,t,r)})})}))})}},{key:"Oi",value:function(e,t,n,r){var a=this;return An(t)||r.isEqual(ye.min())?this.Fi(e,t):this.$i.getDocuments(e,n).next(function(u){var o=a.Bi(t,u);return a.Li(t,o,n,r)?a.Fi(e,t):(B()<=i.LogLevel.DEBUG&&G("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),Vn(t)),a.qi(e,o,t,Ae(r,-1)))})}},{key:"Bi",value:function(e,t){var n=new ln(Bn(e));return t.forEach(function(t,r){qn(e,r)&&(n=n.add(r))}),n}},{key:"Li",value:function(e,t,n,r){if(null===e.limit)return!1;if(n.size!==t.size)return!0;var i="F"===e.limitType?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}},{key:"Fi",value:function(e,t){return B()<=i.LogLevel.DEBUG&&G("QueryEngine","Using full collection scan to execute query:",Vn(t)),this.$i.getDocumentsMatchingQuery(e,t,Ne.min())}},{key:"qi",value:function(e,t,n,r){return this.$i.getDocumentsMatchingQuery(e,n,r).next(function(e){return t.forEach(function(t){e=e.insert(t.key,t)}),e})}}]),e}(),to=function(){function e(t,n,r,i){P(this,e),this.persistence=t,this.Ui=n,this.Tt=i,this.Ki=new on(fe),this.Gi=new _r(function(e){return kn(e)},wn),this.Qi=new Map,this.ji=t.getRemoteDocumentCache(),this.Ns=t.getTargetCache(),this.$s=t.getBundleCache(),this.zi(r)}return L(e,[{key:"zi",value:function(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Lu(this.ji,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.ji.setIndexManager(this.indexManager),this.Ui.initialize(this.localDocuments,this.indexManager)}},{key:"collectGarbage",value:function(e){var t=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",function(n){return e.collect(n,t.Ki)})}}]),e}();function no(e,t,n,r){return new to(e,t,n,r)}function ro(e,t){var n;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:return n=Y(e),r.next=3,m().awrap(n.persistence.runTransaction("Handle user change","readonly",function(e){var r;return n.mutationQueue.getAllMutationBatches(e).next(function(i){return r=i,n.zi(t),n.mutationQueue.getAllMutationBatches(e)}).next(function(t){var i,a=[],u=[],o=Vr(),s=p(r);try{for(s.s();!(i=s.n()).done;){var c=i.value;a.push(c.batchId);var l,f=p(c.mutations);try{for(f.s();!(l=f.n()).done;){var h=l.value;o=o.add(h.key)}}catch(w){f.e(w)}finally{f.f()}}}catch(w){s.e(w)}finally{s.f()}var d,v=p(t);try{for(v.s();!(d=v.n()).done;){var y=d.value;u.push(y.batchId);var m,g=p(y.mutations);try{for(g.s();!(m=g.n()).done;){var k=m.value;o=o.add(k.key)}}catch(w){g.e(w)}finally{g.f()}}}catch(w){v.e(w)}finally{v.f()}return n.localDocuments.getDocuments(e,o).next(function(e){return{Wi:e,removedBatchIds:a,addedBatchIds:u}})})}));case 3:return r.abrupt("return",r.sent);case 4:case"end":return r.stop()}},null,null,null,Promise)}function io(e,t){var n=Y(e);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",function(e){var r=t.batch.keys(),i=n.ji.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){var i=n.batch,a=i.keys(),u=Re.resolve();return a.forEach(function(e){u=u.next(function(){return r.getEntry(t,e)}).next(function(t){var a=n.docVersions.get(e);H(null!==a),t.version.compareTo(a)<0&&(i.applyToRemoteDocument(t,n),t.isValidDocument()&&(t.setReadTime(n.commitVersion),r.addEntry(t)))})}),u.next(function(){return e.mutationQueue.removeMutationBatch(t,i)})}(n,e,t,i).next(function(){return i.apply(e)}).next(function(){return n.mutationQueue.performConsistencyCheck(e)}).next(function(){return n.documentOverlayCache.removeOverlaysForBatchId(e,r,t.batch.batchId)}).next(function(){return n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){for(var t=Vr(),n=0;n<e.mutationResults.length;++n)e.mutationResults[n].transformResults.length>0&&(t=t.add(e.batch.mutations[n].key));return t}(t))}).next(function(){return n.localDocuments.getDocuments(e,r)})})}function ao(e){var t=Y(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",function(e){return t.Ns.getLastRemoteSnapshotVersion(e)})}function uo(e,t){var n=Y(e),r=t.snapshotVersion,i=n.Ki;return n.persistence.runTransaction("Apply remote event","readwrite-primary",function(e){var a=n.ji.newChangeBuffer({trackRemovals:!0});i=n.Ki;var u=[];t.targetChanges.forEach(function(a,o){var s=i.get(o);if(s){u.push(n.Ns.removeMatchingKeys(e,a.removedDocuments,o).next(function(){return n.Ns.addMatchingKeys(e,a.addedDocuments,o)}));var c=s.withSequenceNumber(e.currentSequenceNumber);t.targetMismatches.has(o)?c=c.withResumeToken(ot.EMPTY_BYTE_STRING,ye.min()).withLastLimboFreeSnapshotVersion(ye.min()):a.resumeToken.approximateByteSize()>0&&(c=c.withResumeToken(a.resumeToken,r)),i=i.insert(o,c),function(e,t,n){return 0===e.resumeToken.approximateByteSize()||(t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0)}(s,c,a)&&u.push(n.Ns.updateTargetData(e,c))}});var o=Dr(),s=Vr();if(t.documentUpdates.forEach(function(r){t.resolvedLimboDocuments.has(r)&&u.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))}),u.push(oo(e,a,t.documentUpdates).next(function(e){o=e.Hi,s=e.Ji})),!r.isEqual(ye.min())){var c=n.Ns.getLastRemoteSnapshotVersion(e).next(function(t){return n.Ns.setTargetsMetadata(e,e.currentSequenceNumber,r)});u.push(c)}return Re.waitFor(u).next(function(){return a.apply(e)}).next(function(){return n.localDocuments.getLocalViewOfDocuments(e,o,s)}).next(function(){return o})}).then(function(e){return n.Ki=i,e})}function oo(e,t,n){var r=Vr(),i=Vr();return n.forEach(function(e){return r=r.add(e)}),t.getEntries(e,r).next(function(e){var r=Dr();return n.forEach(function(n,a){var u=e.get(n);a.isFoundDocument()!==u.isFoundDocument()&&(i=i.add(n)),a.isNoDocument()&&a.version.isEqual(ye.min())?(t.removeEntry(n,a.readTime),r=r.insert(n,a)):!u.isValidDocument()||a.version.compareTo(u.version)>0||0===a.version.compareTo(u.version)&&u.hasPendingWrites?(t.addEntry(a),r=r.insert(n,a)):G("LocalStore","Ignoring outdated watch update for ",n,". Current version:",u.version," Watch version:",a.version)}),{Hi:r,Ji:i}})}function so(e,t){var n=Y(e);return n.persistence.runTransaction("Get next mutation batch","readonly",function(e){return void 0===t&&(t=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t)})}function co(e,t){var n=Y(e);return n.persistence.runTransaction("Allocate target","readwrite",function(e){var r;return n.Ns.getTargetData(e,t).next(function(i){return i?(r=i,Re.resolve(r)):n.Ns.allocateTargetId(e).next(function(i){return r=new la(t,i,0,e.currentSequenceNumber),n.Ns.addTargetData(e,r).next(function(){return r})})})}).then(function(e){var r=n.Ki.get(e.targetId);return(null===r||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.Ki=n.Ki.insert(e.targetId,e),n.Gi.set(t,e.targetId)),e})}function lo(e,t,n){var r,i,a;return m().async(function(u){for(;;)switch(u.prev=u.next){case 0:if(r=Y(e),i=r.Ki.get(t),a=n?"readwrite":"readwrite-primary",u.prev=1,u.t0=n,u.t0){u.next=6;break}return u.next=6,m().awrap(r.persistence.runTransaction("Release target",a,function(e){return r.persistence.referenceDelegate.removeTarget(e,i)}));case 6:u.next=13;break;case 8:if(u.prev=8,u.t1=u.catch(1),Ue(u.t1)){u.next=12;break}throw u.t1;case 12:G("LocalStore","Failed to update sequence numbers for target ".concat(t,": ").concat(u.t1));case 13:r.Ki=r.Ki.remove(t),r.Gi.delete(i.target);case 14:case"end":return u.stop()}},null,null,[[1,8]],Promise)}function fo(e,t,n){var r=Y(e),i=ye.min(),a=Vr();return r.persistence.runTransaction("Execute query","readonly",function(e){return function(e,t,n){var r=Y(e),i=r.Gi.get(n);return void 0!==i?Re.resolve(r.Ki.get(i)):r.Ns.getTargetData(t,n)}(r,e,Fn(t)).next(function(t){if(t)return i=t.lastLimboFreeSnapshotVersion,r.Ns.getMatchingKeysForTargetId(e,t.targetId).next(function(e){a=e})}).next(function(){return r.Ui.getDocumentsMatchingQuery(e,t,n?i:ye.min(),n?a:Vr())}).next(function(e){return yo(r,Un(t),e),{documents:e,Yi:a}})})}function ho(e,t){var n=Y(e),r=Y(n.Ns),i=n.Ki.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",function(e){return r.ie(e,t).next(function(e){return e?e.target:null})})}function vo(e,t){var n=Y(e),r=n.Qi.get(t)||ye.min();return n.persistence.runTransaction("Get new document changes","readonly",function(e){return n.ji.getAllFromCollectionGroup(e,t,Ae(r,-1),Number.MAX_SAFE_INTEGER)}).then(function(e){return yo(n,t,e),e})}function yo(e,t,n){var r=e.Qi.get(t)||ye.min();n.forEach(function(e,t){t.readTime.compareTo(r)>0&&(r=t.readTime)}),e.Qi.set(t,r)}function po(e,t,n,r){var i,a,u,o,s,c,l,f,h,d;return m().async(function(v){for(;;)switch(v.prev=v.next){case 0:i=Y(e),a=Vr(),u=Dr(),o=p(n);try{for(o.s();!(s=o.n()).done;)c=s.value,l=t.Zi(c.metadata.name),c.document&&(a=a.add(l)),(f=t.Xi(c)).setReadTime(t.tr(c.metadata.readTime)),u=u.insert(l,f)}catch(y){o.e(y)}finally{o.f()}return h=i.ji.newChangeBuffer({trackRemovals:!0}),v.next=7,m().awrap(co(i,function(e){return Fn(_n(me.fromString("__bundle__/docs/".concat(e))))}(r)));case 7:return d=v.sent,v.abrupt("return",i.persistence.runTransaction("Apply bundle documents","readwrite",function(e){return oo(e,h,u).next(function(t){return h.apply(e),t}).next(function(t){return i.Ns.removeMatchingKeysForTargetId(e,d.targetId).next(function(){return i.Ns.addMatchingKeys(e,a,d.targetId)}).next(function(){return i.localDocuments.getLocalViewOfDocuments(e,t.Hi,t.Ji)}).next(function(){return t.Hi})})}));case 9:case"end":return v.stop()}},null,null,null,Promise)}function mo(e,t){var n,r,i,a=arguments;return m().async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=a.length>2&&void 0!==a[2]?a[2]:Vr(),u.next=3,m().awrap(co(e,Fn(wa(t.bundledQuery))));case 3:return r=u.sent,i=Y(e),u.abrupt("return",i.persistence.runTransaction("Save named query","readwrite",function(e){var a=ri(t.readTime);if(r.snapshotVersion.compareTo(a)>=0)return i.$s.saveNamedQuery(e,t);var u=r.withResumeToken(ot.EMPTY_BYTE_STRING,a);return i.Ki=i.Ki.insert(u.targetId,u),i.Ns.updateTargetData(e,u).next(function(){return i.Ns.removeMatchingKeysForTargetId(e,r.targetId)}).next(function(){return i.Ns.addMatchingKeys(e,n,r.targetId)}).next(function(){return i.$s.saveNamedQuery(e,t)})}));case 6:case"end":return u.stop()}},null,null,null,Promise)}function go(e,t){return"firestore_clients_".concat(e,"_").concat(t)}function ko(e,t,n){var r="firestore_mutations_".concat(e,"_").concat(n);return t.isAuthenticated()&&(r+="_".concat(t.uid)),r}function wo(e,t){return"firestore_targets_".concat(e,"_").concat(t)}var xo=function(){function e(t,n,r,i){P(this,e),this.user=t,this.batchId=n,this.state=r,this.error=i}return L(e,[{key:"nr",value:function(){var e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}],[{key:"er",value:function(t,n,r){var i,a=JSON.parse(r),u="object"==C(a)&&-1!==["pending","acknowledged","rejected"].indexOf(a.state)&&(void 0===a.error||"object"==C(a.error));return u&&a.error&&((u="string"==typeof a.error.message&&"string"==typeof a.error.code)&&(i=new Z(a.error.code,a.error.message))),u?new e(t,n,a.state,i):(Q("SharedClientState","Failed to parse mutation state for ID '".concat(n,"': ").concat(r)),null)}}]),e}(),bo=function(){function e(t,n,r){P(this,e),this.targetId=t,this.state=n,this.error=r}return L(e,[{key:"nr",value:function(){var e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}],[{key:"er",value:function(t,n){var r,i=JSON.parse(n),a="object"==C(i)&&-1!==["not-current","current","rejected"].indexOf(i.state)&&(void 0===i.error||"object"==C(i.error));return a&&i.error&&((a="string"==typeof i.error.message&&"string"==typeof i.error.code)&&(r=new Z(i.error.code,i.error.message))),a?new e(t,i.state,r):(Q("SharedClientState","Failed to parse target state for ID '".concat(t,"': ").concat(n)),null)}}]),e}(),Io=function(){function e(t,n){P(this,e),this.clientId=t,this.activeTargetIds=n}return L(e,null,[{key:"er",value:function(t,n){for(var r=JSON.parse(n),i="object"==C(r)&&r.activeTargetIds instanceof Array,a=Ur(),u=0;i&&u<r.activeTargetIds.length;++u)i=it(r.activeTargetIds[u]),a=a.add(r.activeTargetIds[u]);return i?new e(t,a):(Q("SharedClientState","Failed to parse client data for instance '".concat(t,"': ").concat(n)),null)}}]),e}(),To=function(){function e(t,n){P(this,e),this.clientId=t,this.onlineState=n}return L(e,null,[{key:"er",value:function(t){var n=JSON.parse(t);return"object"==C(n)&&-1!==["Unknown","Online","Offline"].indexOf(n.onlineState)&&"string"==typeof n.clientId?new e(n.clientId,n.onlineState):(Q("SharedClientState","Failed to parse online state: ".concat(t)),null)}}]),e}(),Eo=function(){function e(){P(this,e),this.activeTargetIds=Ur()}return L(e,[{key:"sr",value:function(e){this.activeTargetIds=this.activeTargetIds.add(e)}},{key:"ir",value:function(e){this.activeTargetIds=this.activeTargetIds.delete(e)}},{key:"nr",value:function(){var e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}]),e}(),So=function(){function e(t,n,r,i,a){P(this,e),this.window=t,this.Ys=n,this.persistenceKey=r,this.rr=i,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.ur=this.cr.bind(this),this.ar=new on(fe),this.started=!1,this.hr=[];var u=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=a,this.lr=go(this.persistenceKey,this.rr),this.dr=function(e){return"firestore_sequence_number_".concat(e)}(this.persistenceKey),this.ar=this.ar.insert(this.rr,new Eo),this._r=new RegExp("^firestore_clients_".concat(u,"_([^_]*)$")),this.wr=new RegExp("^firestore_mutations_".concat(u,"_(\\d+)(?:_(.*))?$")),this.mr=new RegExp("^firestore_targets_".concat(u,"_(\\d+)$")),this.gr=function(e){return"firestore_online_state_".concat(e)}(this.persistenceKey),this.yr=function(e){return"firestore_bundle_loaded_v2_".concat(e)}(this.persistenceKey),this.window.addEventListener("storage",this.ur)}return L(e,[{key:"start",value:function(){var e,t,n,r,i,a,u,o,s,c,l,f=this;return m().async(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,m().awrap(this.syncEngine.Si());case 2:e=h.sent,t=p(e),h.prev=4,t.s();case 6:if((n=t.n()).done){h.next=14;break}if((r=n.value)!==this.rr){h.next=10;break}return h.abrupt("continue",12);case 10:(i=this.getItem(go(this.persistenceKey,r)))&&(a=Io.er(r,i))&&(this.ar=this.ar.insert(a.clientId,a));case 12:h.next=6;break;case 14:h.next=19;break;case 16:h.prev=16,h.t0=h.catch(4),t.e(h.t0);case 19:return h.prev=19,t.f(),h.finish(19);case 22:this.pr(),(u=this.storage.getItem(this.gr))&&(o=this.Ir(u))&&this.Tr(o),s=p(this.hr);try{for(s.s();!(c=s.n()).done;)l=c.value,this.cr(l)}catch(d){s.e(d)}finally{s.f()}this.hr=[],this.window.addEventListener("pagehide",function(){return f.shutdown()}),this.started=!0;case 28:case"end":return h.stop()}},null,this,[[4,16,19,22]],Promise)}},{key:"writeSequenceNumber",value:function(e){this.setItem(this.dr,JSON.stringify(e))}},{key:"getAllActiveQueryTargets",value:function(){return this.Er(this.ar)}},{key:"isActiveQueryTarget",value:function(e){var t=!1;return this.ar.forEach(function(n,r){r.activeTargetIds.has(e)&&(t=!0)}),t}},{key:"addPendingMutation",value:function(e){this.Ar(e,"pending")}},{key:"updateMutationState",value:function(e,t,n){this.Ar(e,t,n),this.Rr(e)}},{key:"addLocalQueryTarget",value:function(e){var t="not-current";if(this.isActiveQueryTarget(e)){var n=this.storage.getItem(wo(this.persistenceKey,e));if(n){var r=bo.er(e,n);r&&(t=r.state)}}return this.Pr.sr(e),this.pr(),t}},{key:"removeLocalQueryTarget",value:function(e){this.Pr.ir(e),this.pr()}},{key:"isLocalQueryTarget",value:function(e){return this.Pr.activeTargetIds.has(e)}},{key:"clearQueryState",value:function(e){this.removeItem(wo(this.persistenceKey,e))}},{key:"updateQueryState",value:function(e,t,n){this.vr(e,t,n)}},{key:"handleUserChange",value:function(e,t,n){var r=this;t.forEach(function(e){r.Rr(e)}),this.currentUser=e,n.forEach(function(e){r.addPendingMutation(e)})}},{key:"setOnlineState",value:function(e){this.br(e)}},{key:"notifyBundleLoaded",value:function(e){this.Vr(e)}},{key:"shutdown",value:function(){this.started&&(this.window.removeEventListener("storage",this.ur),this.removeItem(this.lr),this.started=!1)}},{key:"getItem",value:function(e){var t=this.storage.getItem(e);return G("SharedClientState","READ",e,t),t}},{key:"setItem",value:function(e,t){G("SharedClientState","SET",e,t),this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){G("SharedClientState","REMOVE",e),this.storage.removeItem(e)}},{key:"cr",value:function(e){var t=this,n=e;if(n.storageArea===this.storage){if(G("SharedClientState","EVENT",n.key,n.newValue),n.key===this.lr)return void Q("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Ys.enqueueRetryable(function(){var e,r,i,a,u,o,s;return m().async(function(c){for(;;)switch(c.prev=c.next){case 0:if(!t.started){c.next=43;break}if(null===n.key){c.next=41;break}if(!t._r.test(n.key)){c.next=11;break}if(null!=n.newValue){c.next=6;break}return e=t.Sr(n.key),c.abrupt("return",t.Dr(e,null));case 6:if(!(r=t.Cr(n.key,n.newValue))){c.next=9;break}return c.abrupt("return",t.Dr(r.clientId,r));case 9:c.next=41;break;case 11:if(!t.wr.test(n.key)){c.next=18;break}if(null===n.newValue){c.next=16;break}if(!(i=t.Nr(n.key,n.newValue))){c.next=16;break}return c.abrupt("return",t.kr(i));case 16:c.next=41;break;case 18:if(!t.mr.test(n.key)){c.next=25;break}if(null===n.newValue){c.next=23;break}if(!(a=t.$r(n.key,n.newValue))){c.next=23;break}return c.abrupt("return",t.Mr(a));case 23:c.next=41;break;case 25:if(n.key!==t.gr){c.next=32;break}if(null===n.newValue){c.next=30;break}if(!(u=t.Ir(n.newValue))){c.next=30;break}return c.abrupt("return",t.Tr(u));case 30:c.next=41;break;case 32:if(n.key!==t.dr){c.next=37;break}(o=function(e){var t=We.at;if(null!=e)try{var n=JSON.parse(e);H("number"==typeof n),t=n}catch(e){Q("SharedClientState","Failed to read sequence number from WebStorage",e)}return t}(n.newValue))!==We.at&&t.sequenceNumberHandler(o),c.next=41;break;case 37:if(n.key!==t.yr){c.next=41;break}return s=t.Or(n.newValue),c.next=41,m().awrap(Promise.all(s.map(function(e){return t.syncEngine.Fr(e)})));case 41:c.next=44;break;case 43:t.hr.push(n);case 44:case"end":return c.stop()}},null,null,null,Promise)})}}},{key:"Pr",get:function(){return this.ar.get(this.rr)}},{key:"pr",value:function(){this.setItem(this.lr,this.Pr.nr())}},{key:"Ar",value:function(e,t,n){var r=new xo(this.currentUser,e,t,n),i=ko(this.persistenceKey,this.currentUser,e);this.setItem(i,r.nr())}},{key:"Rr",value:function(e){var t=ko(this.persistenceKey,this.currentUser,e);this.removeItem(t)}},{key:"br",value:function(e){var t={clientId:this.rr,onlineState:e};this.storage.setItem(this.gr,JSON.stringify(t))}},{key:"vr",value:function(e,t,n){var r=wo(this.persistenceKey,e),i=new bo(e,t,n);this.setItem(r,i.nr())}},{key:"Vr",value:function(e){var t=JSON.stringify(Array.from(e));this.setItem(this.yr,t)}},{key:"Sr",value:function(e){var t=this._r.exec(e);return t?t[1]:null}},{key:"Cr",value:function(e,t){var n=this.Sr(e);return Io.er(n,t)}},{key:"Nr",value:function(e,t){var n=this.wr.exec(e),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return xo.er(new V(i),r,t)}},{key:"$r",value:function(e,t){var n=this.mr.exec(e),r=Number(n[1]);return bo.er(r,t)}},{key:"Ir",value:function(e){return To.er(e)}},{key:"Or",value:function(e){return JSON.parse(e)}},{key:"kr",value:function(e){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.user.uid!==this.currentUser.uid){t.next=2;break}return t.abrupt("return",this.syncEngine.Br(e.batchId,e.state,e.error));case 2:G("SharedClientState","Ignoring mutation for non-active user ".concat(e.user.uid));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"Mr",value:function(e){return this.syncEngine.Lr(e.targetId,e.state,e.error)}},{key:"Dr",value:function(e,t){var n=this,r=t?this.ar.insert(e,t):this.ar.remove(e),i=this.Er(this.ar),a=this.Er(r),u=[],o=[];return a.forEach(function(e){i.has(e)||u.push(e)}),i.forEach(function(e){a.has(e)||o.push(e)}),this.syncEngine.qr(u,o).then(function(){n.ar=r})}},{key:"Tr",value:function(e){this.ar.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}},{key:"Er",value:function(e){var t=Ur();return e.forEach(function(e,n){t=t.unionWith(n.activeTargetIds)}),t}}],[{key:"C",value:function(e){return!(!e||!e.localStorage)}}]),e}(),_o=function(){function e(){P(this,e),this.Ur=new Eo,this.Kr={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}return L(e,[{key:"addPendingMutation",value:function(e){}},{key:"updateMutationState",value:function(e,t,n){}},{key:"addLocalQueryTarget",value:function(e){return this.Ur.sr(e),this.Kr[e]||"not-current"}},{key:"updateQueryState",value:function(e,t,n){this.Kr[e]=t}},{key:"removeLocalQueryTarget",value:function(e){this.Ur.ir(e)}},{key:"isLocalQueryTarget",value:function(e){return this.Ur.activeTargetIds.has(e)}},{key:"clearQueryState",value:function(e){delete this.Kr[e]}},{key:"getAllActiveQueryTargets",value:function(){return this.Ur.activeTargetIds}},{key:"isActiveQueryTarget",value:function(e){return this.Ur.activeTargetIds.has(e)}},{key:"start",value:function(){return this.Ur=new Eo,Promise.resolve()}},{key:"handleUserChange",value:function(e,t,n){}},{key:"setOnlineState",value:function(e){}},{key:"shutdown",value:function(){}},{key:"writeSequenceNumber",value:function(e){}},{key:"notifyBundleLoaded",value:function(e){}}]),e}(),Ao=function(){function e(){P(this,e)}return L(e,[{key:"Gr",value:function(e){}},{key:"shutdown",value:function(){}}]),e}(),Do=function(){function e(){var t=this;P(this,e),this.Qr=function(){return t.jr()},this.zr=function(){return t.Wr()},this.Hr=[],this.Jr()}return L(e,[{key:"Gr",value:function(e){this.Hr.push(e)}},{key:"shutdown",value:function(){window.removeEventListener("online",this.Qr),window.removeEventListener("offline",this.zr)}},{key:"Jr",value:function(){window.addEventListener("online",this.Qr),window.addEventListener("offline",this.zr)}},{key:"jr",value:function(){G("ConnectivityMonitor","Network connectivity changed: AVAILABLE");var e,t=p(this.Hr);try{for(t.s();!(e=t.n()).done;){(0,e.value)(0)}}catch(n){t.e(n)}finally{t.f()}}},{key:"Wr",value:function(){G("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");var e,t=p(this.Hr);try{for(t.s();!(e=t.n()).done;){(0,e.value)(1)}}catch(n){t.e(n)}finally{t.f()}}}],[{key:"C",value:function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}]),e}(),No=null;function Co(){return null===No?No=268435456+Math.round(2147483648*Math.random()):No++,"0x"+No.toString(16)}var Po={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"},Fo=function(){function e(t){P(this,e),this.Yr=t.Yr,this.Zr=t.Zr}return L(e,[{key:"Xr",value:function(e){this.eo=e}},{key:"no",value:function(e){this.so=e}},{key:"onMessage",value:function(e){this.io=e}},{key:"close",value:function(){this.Zr()}},{key:"send",value:function(e){this.Yr(e)}},{key:"ro",value:function(){this.eo()}},{key:"oo",value:function(e){this.so(e)}},{key:"uo",value:function(e){this.io(e)}}]),e}(),Lo="WebChannelConnection",Ro=function(e){g(n,function(){function e(t){P(this,e);this.databaseInfo=t,this.databaseId=t.databaseId;var n=t.ssl?"https":"http";this.co=n+"://"+t.host,this.ao="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}L(e,[{key:"ho",get:function e(){return!1}},{key:"lo",value:function e(t,n,r,i,a){var u=Co(),o=this.fo(t,n);G("RestConnection","Sending RPC '".concat(t,"' ").concat(u,":"),o,r);var s={};return this._o(s,i,a),this.wo(t,o,s,r).then(function(e){return G("RestConnection","Received RPC '".concat(t,"' ").concat(u,": "),e),e},function(e){throw j("RestConnection","RPC '".concat(t,"' ").concat(u," failed with error: "),e,"url: ",o,"request:",r),e})}},{key:"mo",value:function e(t,n,r,i,a,u){return this.lo(t,n,r,i,a)}},{key:"_o",value:function e(t,n,r){t["X-Goog-Api-Client"]="gl-js/ fire/"+q,t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),n&&n.headers.forEach(function(e,n){return t[n]=e}),r&&r.headers.forEach(function(e,n){return t[n]=e})}},{key:"fo",value:function e(t,n){var r=Po[t];return"".concat(this.co,"/v1/").concat(n,":").concat(r)}}]);return e}());var t=w(n);function n(e){var r;return P(this,n),(r=t.call(this,e)).forceLongPolling=e.forceLongPolling,r.autoDetectLongPolling=e.autoDetectLongPolling,r.useFetchStreams=e.useFetchStreams,r}return L(n,[{key:"wo",value:function(e,t,n,r){var i=Co();return new Promise(function(a,o){var s=new u.XhrIo;s.setWithCredentials(!0),s.listenOnce(u.EventType.COMPLETE,function(){try{switch(s.getLastErrorCode()){case u.ErrorCode.NO_ERROR:var t=s.getResponseJson();G(Lo,"XHR for RPC '".concat(e,"' ").concat(i," received:"),JSON.stringify(t)),a(t);break;case u.ErrorCode.TIMEOUT:G(Lo,"RPC '".concat(e,"' ").concat(i," timed out")),o(new Z(J.DEADLINE_EXCEEDED,"Request time out"));break;case u.ErrorCode.HTTP_ERROR:var n=s.getStatus();if(G(Lo,"RPC '".concat(e,"' ").concat(i," failed with status:"),n,"response text:",s.getResponseText()),n>0){var r=s.getResponseJson();Array.isArray(r)&&(r=r[0]);var c=null==r?void 0:r.error;if(c&&c.status&&c.message){var l=(f=c.status.toLowerCase().replace(/_/g,"-"),Object.values(J).indexOf(f)>=0?f:J.UNKNOWN);o(new Z(l,c.message))}else o(new Z(J.UNKNOWN,"Server responded with status "+s.getStatus()))}else o(new Z(J.UNAVAILABLE,"Connection failed."));break;default:W()}}finally{G(Lo,"RPC '".concat(e,"' ").concat(i," completed."))}var f});var c=JSON.stringify(r);G(Lo,"RPC '".concat(e,"' ").concat(i," sending request:"),r),s.send(t,"POST",c,n,15)})}},{key:"yo",value:function(e,t,n){var r=Co(),i=[this.co,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=(0,u.createWebChannelTransport)(),o=(0,u.getStatEventTarget)(),s={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/".concat(this.databaseId.projectId,"/databases/").concat(this.databaseId.database)},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.useFetchStreams&&(s.xmlHttpFactory=new u.FetchXmlHttpFactory({})),this._o(s.initMessageHeaders,t,n),s.encodeInitMessageHeaders=!0;var c=i.join("");G(Lo,"Creating RPC '".concat(e,"' stream ").concat(r,": ").concat(c),s);var l=a.createWebChannel(c,s),f=!1,h=!1,d=new Fo({Yr:function(t){h?G(Lo,"Not sending because RPC '".concat(e,"' stream ").concat(r," is closed:"),t):(f||(G(Lo,"Opening RPC '".concat(e,"' stream ").concat(r," transport.")),l.open(),f=!0),G(Lo,"RPC '".concat(e,"' stream ").concat(r," sending:"),t),l.send(t))},Zr:function(){return l.close()}}),v=function(e,t,n){e.listen(t,function(e){try{n(e)}catch(e){setTimeout(function(){throw e},0)}})};return v(l,u.WebChannel.EventType.OPEN,function(){h||G(Lo,"RPC '".concat(e,"' stream ").concat(r," transport opened."))}),v(l,u.WebChannel.EventType.CLOSE,function(){h||(h=!0,G(Lo,"RPC '".concat(e,"' stream ").concat(r," transport closed")),d.oo())}),v(l,u.WebChannel.EventType.ERROR,function(t){h||(h=!0,j(Lo,"RPC '".concat(e,"' stream ").concat(r," transport errored:"),t),d.oo(new Z(J.UNAVAILABLE,"The operation could not be completed")))}),v(l,u.WebChannel.EventType.MESSAGE,function(t){var n;if(!h){var i=t.data[0];H(!!i);var a=i,u=a.error||(null===(n=a[0])||void 0===n?void 0:n.error);if(u){G(Lo,"RPC '".concat(e,"' stream ").concat(r," received error:"),u);var o=u.status,s=function(e){var t=wr[o];if(void 0!==t)return Sr(t)}(),c=u.message;void 0===s&&(s=J.INTERNAL,c="Unknown error status: "+o+" with message "+u.message),h=!0,d.oo(new Z(s,c)),l.close()}else G(Lo,"RPC '".concat(e,"' stream ").concat(r," received:"),i),d.uo(i)}}),v(o,u.Event.STAT_EVENT,function(t){t.stat===u.Stat.PROXY?G(Lo,"RPC '".concat(e,"' stream ").concat(r," detected buffering proxy")):t.stat===u.Stat.NOPROXY&&G(Lo,"RPC '".concat(e,"' stream ").concat(r," detected no buffering proxy"))}),setTimeout(function(){d.ro()},0),d}}]),n}();function Mo(){return"undefined"!=typeof window?window:null}function Oo(){return"undefined"!=typeof document?document:null}function Vo(e){return new $r(e,!0)}var qo=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1.5,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:6e4;P(this,e),this.Ys=t,this.timerId=n,this.po=r,this.Io=i,this.To=a,this.Eo=0,this.Ao=null,this.Ro=Date.now(),this.reset()}return L(e,[{key:"reset",value:function(){this.Eo=0}},{key:"Po",value:function(){this.Eo=this.To}},{key:"vo",value:function(e){var t=this;this.cancel();var n=Math.floor(this.Eo+this.bo()),r=Math.max(0,Date.now()-this.Ro),i=Math.max(0,n-r);i>0&&G("ExponentialBackoff","Backing off for ".concat(i," ms (base delay: ").concat(this.Eo," ms, delay with jitter: ").concat(n," ms, last attempt: ").concat(r," ms ago)")),this.Ao=this.Ys.enqueueAfterDelay(this.timerId,i,function(){return t.Ro=Date.now(),e()}),this.Eo*=this.Io,this.Eo<this.po&&(this.Eo=this.po),this.Eo>this.To&&(this.Eo=this.To)}},{key:"Vo",value:function(){null!==this.Ao&&(this.Ao.skipDelay(),this.Ao=null)}},{key:"cancel",value:function(){null!==this.Ao&&(this.Ao.cancel(),this.Ao=null)}},{key:"bo",value:function(){return(Math.random()-.5)*this.Eo}}]),e}(),Uo=function(){function e(t,n,r,i,a,u,o,s){P(this,e),this.Ys=t,this.So=r,this.Do=i,this.connection=a,this.authCredentialsProvider=u,this.appCheckCredentialsProvider=o,this.listener=s,this.state=0,this.Co=0,this.xo=null,this.No=null,this.stream=null,this.ko=new qo(t,n)}return L(e,[{key:"$o",value:function(){return 1===this.state||5===this.state||this.Mo()}},{key:"Mo",value:function(){return 2===this.state||3===this.state}},{key:"start",value:function(){4!==this.state?this.auth():this.Oo()}},{key:"stop",value:function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.$o(),!e.t0){e.next=4;break}return e.next=4,m().awrap(this.close(0));case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"Fo",value:function(){this.state=0,this.ko.reset()}},{key:"Bo",value:function(){var e=this;this.Mo()&&null===this.xo&&(this.xo=this.Ys.enqueueAfterDelay(this.So,6e4,function(){return e.Lo()}))}},{key:"qo",value:function(e){this.Uo(),this.stream.send(e)}},{key:"Lo",value:function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.Mo()){e.next=2;break}return e.abrupt("return",this.close(0));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"Uo",value:function(){this.xo&&(this.xo.cancel(),this.xo=null)}},{key:"Ko",value:function(){this.No&&(this.No.cancel(),this.No=null)}},{key:"close",value:function(e,t){return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.Uo(),this.Ko(),this.ko.cancel(),this.Co++,4!==e?this.ko.reset():t&&t.code===J.RESOURCE_EXHAUSTED?(Q(t.toString()),Q("Using maximum backoff delay to prevent overloading the backend."),this.ko.Po()):t&&t.code===J.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.Go(),this.stream.close(),this.stream=null),this.state=e,n.next=9,m().awrap(this.listener.no(t));case 9:case"end":return n.stop()}},null,this,null,Promise)}},{key:"Go",value:function(){}},{key:"auth",value:function(){var e=this;this.state=1;var t=this.Qo(this.Co),n=this.Co;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(function(t){var r=c(t,2),i=r[0],a=r[1];e.Co===n&&e.jo(i,a)},function(n){t(function(){var t=new Z(J.UNKNOWN,"Fetching auth token failed: "+n.message);return e.zo(t)})})}},{key:"jo",value:function(e,t){var n=this,r=this.Qo(this.Co);this.stream=this.Wo(e,t),this.stream.Xr(function(){r(function(){return n.state=2,n.No=n.Ys.enqueueAfterDelay(n.Do,1e4,function(){return n.Mo()&&(n.state=3),Promise.resolve()}),n.listener.Xr()})}),this.stream.no(function(e){r(function(){return n.zo(e)})}),this.stream.onMessage(function(e){r(function(){return n.onMessage(e)})})}},{key:"Oo",value:function(){var e=this;this.state=5,this.ko.vo(function(){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:e.state=0,e.start();case 1:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"zo",value:function(e){return G("PersistentStream","close with error: ".concat(e)),this.stream=null,this.close(4,e)}},{key:"Qo",value:function(e){var t=this;return function(n){t.Ys.enqueueAndForget(function(){return t.Co===e?n():(G("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}}}]),e}(),Bo=function(e){g(n,Uo);var t=w(n);function n(e,r,i,a,u,o){var s;return P(this,n),(s=t.call(this,e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",r,i,a,o)).Tt=u,s}return L(n,[{key:"Wo",value:function(e,t){return this.connection.yo("Listen",e,t)}},{key:"onMessage",value:function(e){this.ko.reset();var t=yi(this.Tt,e),n=function(e){if(!("targetChange"in e))return ye.min();var t=e.targetChange;return t.targetIds&&t.targetIds.length?ye.min():t.readTime?ri(t.readTime):ye.min()}(e);return this.listener.Ho(t,n)}},{key:"Jo",value:function(e){var t={};t.database=li(this.Tt),t.addTarget=function(e,t){var n,r=t.target;return(n=xn(r)?{documents:ki(e,r)}:{query:wi(e,r)}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0?n.resumeToken=ti(e,t.resumeToken):t.snapshotVersion.compareTo(ye.min())>0&&(n.readTime=ei(e,t.snapshotVersion.toTimestamp())),n}(this.Tt,e);var n=bi(this.Tt,e);n&&(t.labels=n),this.qo(t)}},{key:"Yo",value:function(e){var t={};t.database=li(this.Tt),t.removeTarget=e,this.qo(t)}}]),n}(),Ko=function(e){g(n,Uo);var t=w(n);function n(e,r,i,a,u,o){var s;return P(this,n),(s=t.call(this,e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",r,i,a,o)).Tt=u,s.Zo=!1,s}return L(n,[{key:"Xo",get:function(){return this.Zo}},{key:"start",value:function(){this.Zo=!1,this.lastStreamToken=void 0,o(T(n.prototype),"start",this).call(this)}},{key:"Go",value:function(){this.Zo&&this.tu([])}},{key:"Wo",value:function(e,t){return this.connection.yo("Write",e,t)}},{key:"onMessage",value:function(e){if(H(!!e.streamToken),this.lastStreamToken=e.streamToken,this.Zo){this.ko.reset();var t=gi(e.writeResults,e.commitTime),n=ri(e.commitTime);return this.listener.eu(n,t)}return H(!e.writeResults||0===e.writeResults.length),this.Zo=!0,this.listener.nu()}},{key:"su",value:function(){var e={};e.database=li(this.Tt),this.qo(e)}},{key:"tu",value:function(e){var t=this,n={streamToken:this.lastStreamToken,writes:e.map(function(e){return pi(t.Tt,e)})};this.qo(n)}}]),n}(),Go=function(e){g(n,function(){function e(){P(this,e)}return L(e)}());var t=w(n);function n(e,r,i,a){var u;return P(this,n),(u=t.call(this)).authCredentials=e,u.appCheckCredentials=r,u.connection=i,u.Tt=a,u.iu=!1,u}return L(n,[{key:"ru",value:function(){if(this.iu)throw new Z(J.FAILED_PRECONDITION,"The client has already been terminated.")}},{key:"lo",value:function(e,t,n){var r=this;return this.ru(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(function(i){var a=c(i,2),u=a[0],o=a[1];return r.connection.lo(e,t,n,u,o)}).catch(function(e){throw"FirebaseError"===e.name?(e.code===J.UNAUTHENTICATED&&(r.authCredentials.invalidateToken(),r.appCheckCredentials.invalidateToken()),e):new Z(J.UNKNOWN,e.toString())})}},{key:"mo",value:function(e,t,n,r){var i=this;return this.ru(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(function(a){var u=c(a,2),o=u[0],s=u[1];return i.connection.mo(e,t,n,o,s,r)}).catch(function(e){throw"FirebaseError"===e.name?(e.code===J.UNAUTHENTICATED&&(i.authCredentials.invalidateToken(),i.appCheckCredentials.invalidateToken()),e):new Z(J.UNKNOWN,e.toString())})}},{key:"terminate",value:function(){this.iu=!0}}]),n}();function Qo(e,t,n){var r,i,a,u,o,s;return m().async(function(c){for(;;)switch(c.prev=c.next){case 0:return r=Y(e),i=function(e,t,n){var r=wi(e,t),i=[];return n.forEach(function(e){"count"===e.lt?i.push({alias:e.alias.canonicalString(),count:{}}):"avg"===e.lt?i.push({alias:e.alias.canonicalString(),avg:{field:_i(e.fieldPath)}}):"sum"===e.lt&&i.push({alias:e.alias.canonicalString(),sum:{field:_i(e.fieldPath)}})}),{structuredAggregationQuery:{aggregations:i,structuredQuery:r.structuredQuery},parent:r.parent}}(r.Tt,Fn(t),n),a=i.parent,r.connection.ho||delete i.parent,c.next=4,m().awrap(r.mo("RunAggregationQuery",a,i,1));case 4:return u=c.sent.filter(function(e){return!!e.result}),c.abrupt("return",(H(1===u.length),(o=u[0]).result,o.result.aggregateFields,new vn({mapValue:{fields:null===(s=o.result)||void 0===s?void 0:s.aggregateFields}})));case 6:case"end":return c.stop()}},null,null,null,Promise)}var jo=function(){function e(t,n){P(this,e),this.asyncQueue=t,this.onlineStateHandler=n,this.state="Unknown",this.ou=0,this.uu=null,this.cu=!0}return L(e,[{key:"au",value:function(){var e=this;0===this.ou&&(this.hu("Unknown"),this.uu=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,function(){return e.uu=null,e.lu("Backend didn't respond within 10 seconds."),e.hu("Offline"),Promise.resolve()}))}},{key:"fu",value:function(e){"Online"===this.state?this.hu("Unknown"):(this.ou++,this.ou>=1&&(this.du(),this.lu("Connection failed 1 times. Most recent error: ".concat(e.toString())),this.hu("Offline")))}},{key:"set",value:function(e){this.du(),this.ou=0,"Online"===e&&(this.cu=!1),this.hu(e)}},{key:"hu",value:function(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}},{key:"lu",value:function(e){var t="Could not reach Cloud Firestore backend. ".concat(e,"\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.");this.cu?(Q(t),this.cu=!1):G("OnlineStateTracker",t)}},{key:"du",value:function(){null!==this.uu&&(this.uu.cancel(),this.uu=null)}}]),e}(),zo=L(function e(t,n,r,i,a){var u=this;P(this,e),this.localStore=t,this.datastore=n,this.asyncQueue=r,this.remoteSyncer={},this._u=[],this.wu=new Map,this.mu=new Set,this.gu=[],this.yu=a,this.yu.Gr(function(e){r.enqueueAndForget(function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=ts(u),!e.t0){e.next=5;break}return G("RemoteStore","Restarting streams for network reachability change."),e.next=5,m().awrap(function(e){var t;return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=Y(e)).mu.add(4),n.next=4,m().awrap(Ho(t));case 4:return t.pu.set("Unknown"),t.mu.delete(4),n.next=8,m().awrap(Wo(t));case 8:case"end":return n.stop()}},null,null,null,Promise)}(u));case 5:case"end":return e.stop()}},null,null,null,Promise)})}),this.pu=new jo(r,i)});function Wo(e){var t,n,r;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!ts(e)){i.next=18;break}t=p(e.gu),i.prev=2,t.s();case 4:if((n=t.n()).done){i.next=10;break}return r=n.value,i.next=8,m().awrap(r(!0));case 8:i.next=4;break;case 10:i.next=15;break;case 12:i.prev=12,i.t0=i.catch(2),t.e(i.t0);case 15:return i.prev=15,t.f(),i.finish(15);case 18:case"end":return i.stop()}},null,null,[[2,12,15,18]],Promise)}function Ho(e){var t,n,r;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:t=p(e.gu),i.prev=1,t.s();case 3:if((n=t.n()).done){i.next=9;break}return r=n.value,i.next=7,m().awrap(r(!1));case 7:i.next=3;break;case 9:i.next=14;break;case 11:i.prev=11,i.t0=i.catch(1),t.e(i.t0);case 14:return i.prev=14,t.f(),i.finish(14);case 17:case"end":return i.stop()}},null,null,[[1,11,14,17]],Promise)}function Xo(e,t){var n=Y(e);n.wu.has(t.targetId)||(n.wu.set(t.targetId,t),es(n)?$o(n):ks(n).Mo()&&Jo(n,t))}function Yo(e,t){var n=Y(e),r=ks(n);n.wu.delete(t),r.Mo()&&Zo(n,t),0===n.wu.size&&(r.Mo()?r.Bo():ts(n)&&n.pu.set("Unknown"))}function Jo(e,t){e.Iu.Ot(t.targetId),ks(e).Jo(t)}function Zo(e,t){e.Iu.Ot(t),ks(e).Yo(t)}function $o(e){e.Iu=new Wr({getRemoteKeysForTarget:function(t){return e.remoteSyncer.getRemoteKeysForTarget(t)},ie:function(t){return e.wu.get(t)||null}}),ks(e).start(),e.pu.au()}function es(e){return ts(e)&&!ks(e).$o()&&e.wu.size>0}function ts(e){return 0===Y(e).mu.size}function ns(e){e.Iu=void 0}function rs(e){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:e.wu.forEach(function(t,n){Jo(e,t)});case 1:case"end":return t.stop()}},null,null,null,Promise)}function is(e,t){return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:ns(e),es(e)?(e.pu.fu(t),$o(e)):e.pu.set("Unknown");case 1:case"end":return n.stop()}},null,null,null,Promise)}function as(e,t,n){var r;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:if(e.pu.set("Online"),!(t instanceof jr&&2===t.state&&t.cause)){i.next=13;break}return i.prev=1,i.next=4,m().awrap(function(e,t){var n,r,i,a;return m().async(function(u){for(;;)switch(u.prev=u.next){case 0:n=t.cause,r=p(t.targetIds),u.prev=2,r.s();case 4:if((i=r.n()).done){u.next=14;break}if(a=i.value,u.t0=e.wu.has(a),!u.t0){u.next=12;break}return u.next=10,m().awrap(e.remoteSyncer.rejectListen(a,n));case 10:e.wu.delete(a),e.Iu.removeTarget(a);case 12:u.next=4;break;case 14:u.next=19;break;case 16:u.prev=16,u.t1=u.catch(2),r.e(u.t1);case 19:return u.prev=19,r.f(),u.finish(19);case 22:case"end":return u.stop()}},null,null,[[2,16,19,22]],Promise)}(e,t));case 4:i.next=11;break;case 6:return i.prev=6,i.t0=i.catch(1),G("RemoteStore","Failed to remove targets %s: %s ",t.targetIds.join(","),i.t0),i.next=11,m().awrap(us(e,i.t0));case 11:i.next=29;break;case 13:if(t instanceof Gr?e.Iu.Qt(t):t instanceof Qr?e.Iu.Zt(t):e.Iu.Wt(t),n.isEqual(ye.min())){i.next=29;break}return i.prev=14,i.next=17,m().awrap(ao(e.localStore));case 17:if(r=i.sent,i.t1=n.compareTo(r)>=0,!i.t1){i.next=22;break}return i.next=22,m().awrap(function(e,t){var n=e.Iu.ee(t);return n.targetChanges.forEach(function(n,r){if(n.resumeToken.approximateByteSize()>0){var i=e.wu.get(r);i&&e.wu.set(r,i.withResumeToken(n.resumeToken,t))}}),n.targetMismatches.forEach(function(t){var n=e.wu.get(t);if(n){e.wu.set(t,n.withResumeToken(ot.EMPTY_BYTE_STRING,n.snapshotVersion)),Zo(e,t);var r=new la(n.target,t,1,n.sequenceNumber);Jo(e,r)}}),e.remoteSyncer.applyRemoteEvent(n)}(e,n));case 22:i.next=29;break;case 24:return i.prev=24,i.t2=i.catch(14),G("RemoteStore","Failed to raise snapshot:",i.t2),i.next=29,m().awrap(us(e,i.t2));case 29:case"end":return i.stop()}},null,null,[[1,6],[14,24]],Promise)}function us(e,t,n){return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:if(Ue(t)){r.next=2;break}throw t;case 2:return e.mu.add(1),r.next=5,m().awrap(Ho(e));case 5:e.pu.set("Offline"),n||(n=function(){return ao(e.localStore)}),e.asyncQueue.enqueueRetryable(function(){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:return G("RemoteStore","Retrying IndexedDB access"),t.next=3,m().awrap(n());case 3:return e.mu.delete(1),t.next=6,m().awrap(Wo(e));case 6:case"end":return t.stop()}},null,null,null,Promise)});case 8:case"end":return r.stop()}},null,null,null,Promise)}function os(e,t){return t().catch(function(n){return us(e,n,t)})}function ss(e){var t,n,r,i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:t=Y(e),n=ws(t),r=t._u.length>0?t._u[t._u.length-1].batchId:-1;case 2:if(!cs(t)){a.next=19;break}return a.prev=3,a.next=6,m().awrap(so(t.localStore,r));case 6:if(null!==(i=a.sent)){a.next=10;break}return 0===t._u.length&&n.Bo(),a.abrupt("break",19);case 10:r=i.batchId,ls(t,i),a.next=17;break;case 13:return a.prev=13,a.t0=a.catch(3),a.next=17,m().awrap(us(t,a.t0));case 17:a.next=2;break;case 19:fs(t)&&hs(t);case 20:case"end":return a.stop()}},null,null,[[3,13]],Promise)}function cs(e){return ts(e)&&e._u.length<10}function ls(e,t){e._u.push(t);var n=ws(e);n.Mo()&&n.Xo&&n.tu(t.mutations)}function fs(e){return ts(e)&&!ws(e).$o()&&e._u.length>0}function hs(e){ws(e).start()}function ds(e){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:ws(e).su();case 1:case"end":return t.stop()}},null,null,null,Promise)}function vs(e){var t,n,r,i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:t=ws(e),n=p(e._u);try{for(n.s();!(r=n.n()).done;)i=r.value,t.tu(i.mutations)}catch(u){n.e(u)}finally{n.f()}case 3:case"end":return a.stop()}},null,null,null,Promise)}function ys(e,t,n){var r,i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:return r=e._u.shift(),i=sa.from(r,t,n),a.next=3,m().awrap(os(e,function(){return e.remoteSyncer.applySuccessfulWrite(i)}));case 3:return a.next=5,m().awrap(ss(e));case 5:case"end":return a.stop()}},null,null,null,Promise)}function ps(e,t){return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:if(n.t0=t&&ws(e).Xo,!n.t0){n.next=4;break}return n.next=4,m().awrap(function(e,t){var n,r;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!Er(r=t.code)||r===J.ABORTED){i.next=7;break}return n=e._u.shift(),ws(e).Fo(),i.next=5,m().awrap(os(e,function(){return e.remoteSyncer.rejectFailedWrite(n.batchId,t)}));case 5:return i.next=7,m().awrap(ss(e));case 7:case"end":return i.stop()}},null,null,null,Promise)}(e,t));case 4:fs(e)&&hs(e);case 5:case"end":return n.stop()}},null,null,null,Promise)}function ms(e,t){var n,r;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:return(n=Y(e)).asyncQueue.verifyOperationInProgress(),G("RemoteStore","RemoteStore received new credentials"),r=ts(n),n.mu.add(3),i.next=6,m().awrap(Ho(n));case 6:return r&&n.pu.set("Unknown"),i.next=9,m().awrap(n.remoteSyncer.handleCredentialChange(t));case 9:return n.mu.delete(3),i.next=12,m().awrap(Wo(n));case 12:case"end":return i.stop()}},null,null,null,Promise)}function gs(e,t){var n;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:if(n=Y(e),!t){r.next=7;break}return n.mu.delete(2),r.next=5,m().awrap(Wo(n));case 5:r.next=13;break;case 7:if(r.t0=t,r.t0){r.next=13;break}return n.mu.add(2),r.next=12,m().awrap(Ho(n));case 12:n.pu.set("Unknown");case 13:case"end":return r.stop()}},null,null,null,Promise)}function ks(e){return e.Tu||(e.Tu=function(e,t,n){var r=Y(e);return r.ru(),new Bo(t,r.connection,r.authCredentials,r.appCheckCredentials,r.Tt,n)}(e.datastore,e.asyncQueue,{Xr:rs.bind(null,e),no:is.bind(null,e),Ho:as.bind(null,e)}),e.gu.push(function(t){return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!t){n.next=4;break}e.Tu.Fo(),es(e)?$o(e):e.pu.set("Unknown"),n.next=7;break;case 4:return n.next=6,m().awrap(e.Tu.stop());case 6:ns(e);case 7:case"end":return n.stop()}},null,null,null,Promise)})),e.Tu}function ws(e){return e.Eu||(e.Eu=function(e,t,n){var r=Y(e);return r.ru(),new Ko(t,r.connection,r.authCredentials,r.appCheckCredentials,r.Tt,n)}(e.datastore,e.asyncQueue,{Xr:ds.bind(null,e),no:ps.bind(null,e),nu:vs.bind(null,e),eu:ys.bind(null,e)}),e.gu.push(function(t){return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!t){n.next=6;break}return e.Eu.Fo(),n.next=4,m().awrap(ss(e));case 4:n.next=9;break;case 6:return n.next=8,m().awrap(e.Eu.stop());case 8:e._u.length>0&&(G("RemoteStore","Stopping write stream with ".concat(e._u.length," pending writes")),e._u=[]);case 9:case"end":return n.stop()}},null,null,null,Promise)})),e.Eu}var xs=function(){function e(t,n,r,i,a){P(this,e),this.asyncQueue=t,this.timerId=n,this.targetTimeMs=r,this.op=i,this.removalCallback=a,this.deferred=new $,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(function(e){})}return L(e,[{key:"start",value:function(e){var t=this;this.timerHandle=setTimeout(function(){return t.handleDelayElapsed()},e)}},{key:"skipDelay",value:function(){return this.handleDelayElapsed()}},{key:"cancel",value:function(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new Z(J.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}},{key:"handleDelayElapsed",value:function(){var e=this;this.asyncQueue.enqueueAndForget(function(){return null!==e.timerHandle?(e.clearTimeout(),e.op().then(function(t){return e.deferred.resolve(t)})):Promise.resolve()})}},{key:"clearTimeout",value:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)})}],[{key:"createAndSchedule",value:function(t,n,r,i,a){var u=new e(t,n,Date.now()+r,i,a);return u.start(r),u}}]),e}();function bs(e,t){if(Q("AsyncQueue","".concat(t,": ").concat(e)),Ue(e))return new Z(J.UNAVAILABLE,"".concat(t,": ").concat(e));throw e}var Is=function(){function e(t){P(this,e),this.comparator=t?function(e,n){return t(e,n)||we.comparator(e.key,n.key)}:function(e,t){return we.comparator(e.key,t.key)},this.keyedMap=Cr(),this.sortedSet=new on(this.comparator)}return L(e,[{key:"has",value:function(e){return null!=this.keyedMap.get(e)}},{key:"get",value:function(e){return this.keyedMap.get(e)}},{key:"first",value:function(){return this.sortedSet.minKey()}},{key:"last",value:function(){return this.sortedSet.maxKey()}},{key:"isEmpty",value:function(){return this.sortedSet.isEmpty()}},{key:"indexOf",value:function(e){var t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}},{key:"size",get:function(){return this.sortedSet.size}},{key:"forEach",value:function(e){this.sortedSet.inorderTraversal(function(t,n){return e(t),!1})}},{key:"add",value:function(e){var t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}},{key:"delete",value:function(e){var t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}},{key:"isEqual",value:function(t){if(!(t instanceof e))return!1;if(this.size!==t.size)return!1;for(var n=this.sortedSet.getIterator(),r=t.sortedSet.getIterator();n.hasNext();){var i=n.getNext().key,a=r.getNext().key;if(!i.isEqual(a))return!1}return!0}},{key:"toString",value:function(){var e=[];return this.forEach(function(t){e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"}},{key:"copy",value:function(t,n){var r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r}}],[{key:"emptySet",value:function(t){return new e(t.comparator)}}]),e}(),Ts=function(){function e(){P(this,e),this.Au=new on(we.comparator)}return L(e,[{key:"track",value:function(e){var t=e.doc.key,n=this.Au.get(t);n?0!==e.type&&3===n.type?this.Au=this.Au.insert(t,e):3===e.type&&1!==n.type?this.Au=this.Au.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.Au=this.Au.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.Au=this.Au.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.Au=this.Au.remove(t):1===e.type&&2===n.type?this.Au=this.Au.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.Au=this.Au.insert(t,{type:2,doc:e.doc}):W():this.Au=this.Au.insert(t,e)}},{key:"Ru",value:function(){var e=[];return this.Au.inorderTraversal(function(t,n){e.push(n)}),e}}]),e}(),Es=function(){function e(t,n,r,i,a,u,o,s,c){P(this,e),this.query=t,this.docs=n,this.oldDocs=r,this.docChanges=i,this.mutatedKeys=a,this.fromCache=u,this.syncStateChanged=o,this.excludesMetadataChanges=s,this.hasCachedResults=c}return L(e,[{key:"hasPendingWrites",get:function(){return!this.mutatedKeys.isEmpty()}},{key:"isEqual",value:function(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Mn(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;var t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(var r=0;r<t.length;r++)if(t[r].type!==n[r].type||!t[r].doc.isEqual(n[r].doc))return!1;return!0}}],[{key:"fromInitialDocuments",value:function(t,n,r,i,a){var u=[];return n.forEach(function(e){u.push({type:0,doc:e})}),new e(t,n,Is.emptySet(n),u,r,i,!0,!1,a)}}]),e}(),Ss=L(function e(){P(this,e),this.Pu=void 0,this.listeners=[]}),_s=L(function e(){P(this,e),this.queries=new _r(function(e){return On(e)},Mn),this.onlineState="Unknown",this.vu=new Set});function As(e,t){var n,r,i,a,u;return m().async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n=Y(e),r=t.query,i=!1,(a=n.queries.get(r))||(i=!0,a=new Ss),!i){o.next=13;break}return o.prev=3,o.next=6,m().awrap(n.onListen(r));case 6:a.Pu=o.sent,o.next=13;break;case 9:return o.prev=9,o.t0=o.catch(3),u=bs(o.t0,"Initialization of query '".concat(Vn(t.query),"' failed")),o.abrupt("return",void t.onError(u));case 13:n.queries.set(r,a),a.listeners.push(t),t.bu(n.onlineState),a.Pu&&t.Vu(a.Pu)&&Ps(n);case 14:case"end":return o.stop()}},null,null,[[3,9]],Promise)}function Ds(e,t){var n,r,i,a,u;return m().async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n=Y(e),r=t.query,i=!1,(a=n.queries.get(r))&&(u=a.listeners.indexOf(t))>=0&&(a.listeners.splice(u,1),i=0===a.listeners.length),!i){o.next=6;break}return o.abrupt("return",(n.queries.delete(r),n.onUnlisten(r)));case 6:case"end":return o.stop()}},null,null,null,Promise)}function Ns(e,t){var n,r=Y(e),i=!1,a=p(t);try{for(a.s();!(n=a.n()).done;){var u=n.value,o=u.query,s=r.queries.get(o);if(s){var c,l=p(s.listeners);try{for(l.s();!(c=l.n()).done;){c.value.Vu(u)&&(i=!0)}}catch(f){l.e(f)}finally{l.f()}s.Pu=u}}}catch(f){a.e(f)}finally{a.f()}i&&Ps(r)}function Cs(e,t,n){var r=Y(e),i=r.queries.get(t);if(i){var a,u=p(i.listeners);try{for(u.s();!(a=u.n()).done;){a.value.onError(n)}}catch(o){u.e(o)}finally{u.f()}}r.queries.delete(t)}function Ps(e){e.vu.forEach(function(e){e.next()})}var Fs=function(){function e(t,n,r){P(this,e),this.query=t,this.Su=n,this.Du=!1,this.Cu=null,this.onlineState="Unknown",this.options=r||{}}return L(e,[{key:"Vu",value:function(e){if(!this.options.includeMetadataChanges){var t,n=[],r=p(e.docChanges);try{for(r.s();!(t=r.n()).done;){var i=t.value;3!==i.type&&n.push(i)}}catch(u){r.e(u)}finally{r.f()}e=new Es(e.query,e.docs,e.oldDocs,n,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}var a=!1;return this.Du?this.xu(e)&&(this.Su.next(e),a=!0):this.Nu(e,this.onlineState)&&(this.ku(e),a=!0),this.Cu=e,a}},{key:"onError",value:function(e){this.Su.error(e)}},{key:"bu",value:function(e){this.onlineState=e;var t=!1;return this.Cu&&!this.Du&&this.Nu(this.Cu,e)&&(this.ku(this.Cu),t=!0),t}},{key:"Nu",value:function(e,t){if(!e.fromCache)return!0;var n="Offline"!==t;return(!this.options.$u||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}},{key:"xu",value:function(e){if(e.docChanges.length>0)return!0;var t=this.Cu&&this.Cu.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}},{key:"ku",value:function(e){e=Es.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Du=!0,this.Su.next(e)}}]),e}(),Ls=function(){function e(t,n){P(this,e),this.Mu=t,this.byteLength=n}return L(e,[{key:"Ou",value:function(){return"metadata"in this.Mu}}]),e}(),Rs=function(){function e(t){P(this,e),this.Tt=t}return L(e,[{key:"Zi",value:function(e){return oi(this.Tt,e)}},{key:"Xi",value:function(e){return e.metadata.exists?di(this.Tt,e.document,!1):pn.newNoDocument(this.Zi(e.metadata.name),this.tr(e.metadata.readTime))}},{key:"tr",value:function(e){return ri(e)}}]),e}(),Ms=function(){function e(t,n,r){P(this,e),this.Fu=t,this.localStore=n,this.Tt=r,this.queries=[],this.documents=[],this.collectionGroups=new Set,this.progress=Os(t)}return L(e,[{key:"Bu",value:function(e){this.progress.bytesLoaded+=e.byteLength;var t=this.progress.documentsLoaded;if(e.Mu.namedQuery)this.queries.push(e.Mu.namedQuery);else if(e.Mu.documentMetadata){this.documents.push({metadata:e.Mu.documentMetadata}),e.Mu.documentMetadata.exists||++t;var n=me.fromString(e.Mu.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else e.Mu.document&&(this.documents[this.documents.length-1].document=e.Mu.document,++t);return t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,Object.assign({},this.progress)):null}},{key:"Lu",value:function(e){var t,n=new Map,r=new Rs(this.Tt),i=p(e);try{for(i.s();!(t=i.n()).done;){var a=t.value;if(a.metadata.queries){var u,o=r.Zi(a.metadata.name),s=p(a.metadata.queries);try{for(s.s();!(u=s.n()).done;){var c=u.value,l=(n.get(c)||Vr()).add(o);n.set(c,l)}}catch(f){s.e(f)}finally{s.f()}}}}catch(f){i.e(f)}finally{i.f()}return n}},{key:"complete",value:function(){var e,t,n,r,i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,m().awrap(po(this.localStore,new Rs(this.Tt),this.documents,this.Fu.id));case 2:e=a.sent,t=this.Lu(this.documents),n=p(this.queries),a.prev=5,n.s();case 7:if((r=n.n()).done){a.next=13;break}return i=r.value,a.next=11,m().awrap(mo(this.localStore,i,t.get(i.name)));case 11:a.next=7;break;case 13:a.next=18;break;case 15:a.prev=15,a.t0=a.catch(5),n.e(a.t0);case 18:return a.prev=18,n.f(),a.finish(18);case 21:return a.abrupt("return",(this.progress.taskState="Success",{progress:this.progress,qu:this.collectionGroups,Uu:e}));case 22:case"end":return a.stop()}},null,this,[[5,15,18,21]],Promise)}}]),e}();function Os(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}var Vs=L(function e(t){P(this,e),this.key=t}),qs=L(function e(t){P(this,e),this.key=t}),Us=function(){function e(t,n){P(this,e),this.query=t,this.Ku=n,this.Gu=null,this.hasCachedResults=!1,this.current=!1,this.Qu=Vr(),this.mutatedKeys=Vr(),this.ju=Bn(t),this.zu=new Is(this.ju)}return L(e,[{key:"Wu",get:function(){return this.Ku}},{key:"Hu",value:function(e,t){var n=this,r=t?t.Ju:new Ts,i=t?t.zu:this.zu,a=t?t.mutatedKeys:this.mutatedKeys,u=i,o=!1,s="F"===this.query.limitType&&i.size===this.query.limit?i.last():null,c="L"===this.query.limitType&&i.size===this.query.limit?i.first():null;if(e.inorderTraversal(function(e,t){var l=i.get(e),f=qn(n.query,t)?t:null,h=!!l&&n.mutatedKeys.has(l.key),d=!!f&&(f.hasLocalMutations||n.mutatedKeys.has(f.key)&&f.hasCommittedMutations),v=!1;l&&f?l.data.isEqual(f.data)?h!==d&&(r.track({type:3,doc:f}),v=!0):n.Yu(l,f)||(r.track({type:2,doc:f}),v=!0,(s&&n.ju(f,s)>0||c&&n.ju(f,c)<0)&&(o=!0)):!l&&f?(r.track({type:0,doc:f}),v=!0):l&&!f&&(r.track({type:1,doc:l}),v=!0,(s||c)&&(o=!0)),v&&(f?(u=u.add(f),a=d?a.add(e):a.delete(e)):(u=u.delete(e),a=a.delete(e)))}),null!==this.query.limit)for(;u.size>this.query.limit;){var l="F"===this.query.limitType?u.last():u.first();u=u.delete(l.key),a=a.delete(l.key),r.track({type:1,doc:l})}return{zu:u,Ju:r,Li:o,mutatedKeys:a}}},{key:"Yu",value:function(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}},{key:"applyChanges",value:function(e,t,n){var r=this,i=this.zu;this.zu=e.zu,this.mutatedKeys=e.mutatedKeys;var a=e.Ju.Ru();a.sort(function(e,t){return function(e,t){var n=function(e){switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return W()}};return n(e)-n(t)}(e.type,t.type)||r.ju(e.doc,t.doc)}),this.Zu(n);var u=t?this.Xu():[],o=0===this.Qu.size&&this.current?1:0,s=o!==this.Gu;return this.Gu=o,0!==a.length||s?{snapshot:new Es(this.query,e.zu,i,a,e.mutatedKeys,0===o,s,!1,!!n&&n.resumeToken.approximateByteSize()>0),tc:u}:{tc:u}}},{key:"bu",value:function(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({zu:this.zu,Ju:new Ts,mutatedKeys:this.mutatedKeys,Li:!1},!1)):{tc:[]}}},{key:"ec",value:function(e){return!this.Ku.has(e)&&!!this.zu.has(e)&&!this.zu.get(e).hasLocalMutations}},{key:"Zu",value:function(e){var t=this;e&&(e.addedDocuments.forEach(function(e){return t.Ku=t.Ku.add(e)}),e.modifiedDocuments.forEach(function(e){}),e.removedDocuments.forEach(function(e){return t.Ku=t.Ku.delete(e)}),this.current=e.current)}},{key:"Xu",value:function(){var e=this;if(!this.current)return[];var t=this.Qu;this.Qu=Vr(),this.zu.forEach(function(t){e.ec(t.key)&&(e.Qu=e.Qu.add(t.key))});var n=[];return t.forEach(function(t){e.Qu.has(t)||n.push(new qs(t))}),this.Qu.forEach(function(e){t.has(e)||n.push(new Vs(e))}),n}},{key:"nc",value:function(e){this.Ku=e.Yi,this.Qu=Vr();var t=this.Hu(e.documents);return this.applyChanges(t,!0)}},{key:"sc",value:function(){return Es.fromInitialDocuments(this.query,this.zu,this.mutatedKeys,0===this.Gu,this.hasCachedResults)}}]),e}(),Bs=L(function e(t,n,r){P(this,e),this.query=t,this.targetId=n,this.view=r}),Ks=L(function e(t){P(this,e),this.key=t,this.ic=!1}),Gs=function(){function e(t,n,r,i,a,u){P(this,e),this.localStore=t,this.remoteStore=n,this.eventManager=r,this.sharedClientState=i,this.currentUser=a,this.maxConcurrentLimboResolutions=u,this.rc={},this.oc=new _r(function(e){return On(e)},Mn),this.uc=new Map,this.cc=new Set,this.ac=new on(we.comparator),this.hc=new Map,this.lc=new Ou,this.fc={},this.dc=new Map,this._c=du.Sn(),this.onlineState="Unknown",this.wc=void 0}return L(e,[{key:"isPrimaryClient",get:function(){return!0===this.wc}}]),e}();function Qs(e,t){var n,r,i,a,u,o;return m().async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=kc(e),!(a=n.oc.get(t))){s.next=6;break}r=a.targetId,n.sharedClientState.addLocalQueryTarget(r),i=a.view.sc(),s.next=15;break;case 6:return s.next=8,m().awrap(co(n.localStore,Fn(t)));case 8:return u=s.sent,n.isPrimaryClient&&Xo(n.remoteStore,u),o=n.sharedClientState.addLocalQueryTarget(u.targetId),r=u.targetId,s.next=14,m().awrap(js(n,t,r,"current"===o,u.resumeToken));case 14:i=s.sent;case 15:return s.abrupt("return",i);case 16:case"end":return s.stop()}},null,null,null,Promise)}function js(e,t,n,r,i){var a,u,o,s,c,l;return m().async(function(f){for(;;)switch(f.prev=f.next){case 0:return e.mc=function(t,n,r){return function(e,t,n,r){var i,a,u;return m().async(function(o){for(;;)switch(o.prev=o.next){case 0:if(i=t.view.Hu(n),o.t0=i.Li,!o.t0){o.next=6;break}return o.next=5,m().awrap(fo(e.localStore,t.query,!1).then(function(e){var n=e.documents;return t.view.Hu(n,i)}));case 5:i=o.sent;case 6:return a=r&&r.targetChanges.get(t.targetId),u=t.view.applyChanges(i,e.isPrimaryClient,a),o.abrupt("return",(ic(e,t.targetId,u.tc),u.snapshot));case 8:case"end":return o.stop()}},null,null,null,Promise)}(e,t,n,r)},f.next=3,m().awrap(fo(e.localStore,t,!0));case 3:return a=f.sent,u=new Us(t,a.Yi),o=u.Hu(a.documents),s=Kr.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,i),c=u.applyChanges(o,e.isPrimaryClient,s),ic(e,n,c.tc),l=new Bs(t,n,u),f.abrupt("return",(e.oc.set(t,l),e.uc.has(n)?e.uc.get(n).push(t):e.uc.set(n,[t]),c.snapshot));case 11:case"end":return f.stop()}},null,null,null,Promise)}function zs(e,t){var n,r,i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=Y(e),r=n.oc.get(t),!((i=n.uc.get(r.targetId)).length>1)){a.next=3;break}return a.abrupt("return",(n.uc.set(r.targetId,i.filter(function(e){return!Mn(e,t)})),void n.oc.delete(t)));case 3:if(!n.isPrimaryClient){a.next=11;break}if(n.sharedClientState.removeLocalQueryTarget(r.targetId),a.t0=n.sharedClientState.isActiveQueryTarget(r.targetId),a.t0){a.next=9;break}return a.next=9,m().awrap(lo(n.localStore,r.targetId,!1).then(function(){n.sharedClientState.clearQueryState(r.targetId),Yo(n.remoteStore,r.targetId),nc(n,r.targetId)}).catch(Le));case 9:a.next=14;break;case 11:return nc(n,r.targetId),a.next=14,m().awrap(lo(n.localStore,r.targetId,!0));case 14:case"end":return a.stop()}},null,null,null,Promise)}function Ws(e,t,n){var r,i,a;return m().async(function(u){for(;;)switch(u.prev=u.next){case 0:return r=wc(e),u.prev=1,u.next=4,m().awrap(function(e,t){var n,r,i=Y(e),a=ve.now(),u=t.reduce(function(e,t){return e.add(t.key)},Vr());return i.persistence.runTransaction("Locally write mutations","readwrite",function(e){var o=Dr(),s=Vr();return i.ji.getEntries(e,u).next(function(e){(o=e).forEach(function(e,t){t.isValidDocument()||(s=s.add(e))})}).next(function(){return i.localDocuments.getOverlayedDocuments(e,o)}).next(function(r){n=r;var u,o=[],s=p(t);try{for(s.s();!(u=s.n()).done;){var c=u.value,l=dr(c,n.get(c.key).overlayedDocument);null!=l&&o.push(new pr(c.key,l,yn(l.value.mapValue),or.exists(!0)))}}catch(f){s.e(f)}finally{s.f()}return i.mutationQueue.addMutationBatch(e,a,o,t)}).next(function(t){r=t;var a=t.applyToLocalDocumentSet(n,s);return i.documentOverlayCache.saveOverlays(e,t.batchId,a)})}).then(function(){return{batchId:r.batchId,changes:Pr(n)}})}(r.localStore,t));case 4:return i=u.sent,r.sharedClientState.addPendingMutation(i.batchId),function(e,t,n){var r=e.fc[e.currentUser.toKey()];r||(r=new on(fe)),r=r.insert(t,n),e.fc[e.currentUser.toKey()]=r}(r,i.batchId,n),u.next=9,m().awrap(oc(r,i.changes));case 9:return u.next=11,m().awrap(ss(r.remoteStore));case 11:u.next=17;break;case 13:u.prev=13,u.t0=u.catch(1),a=bs(u.t0,"Failed to persist write"),n.reject(a);case 17:case"end":return u.stop()}},null,null,[[1,13]],Promise)}function Hs(e,t){var n,r;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=Y(e),i.prev=1,i.next=4,m().awrap(uo(n.localStore,t));case 4:return r=i.sent,t.targetChanges.forEach(function(e,t){var r=n.hc.get(t);r&&(H(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1),e.addedDocuments.size>0?r.ic=!0:e.modifiedDocuments.size>0?H(r.ic):e.removedDocuments.size>0&&(H(r.ic),r.ic=!1))}),i.next=8,m().awrap(oc(n,r,t));case 8:i.next=14;break;case 10:return i.prev=10,i.t0=i.catch(1),i.next=14,m().awrap(Le(i.t0));case 14:case"end":return i.stop()}},null,null,[[1,10]],Promise)}function Xs(e,t,n){var r=Y(e);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){var i=[];r.oc.forEach(function(e,n){var r=n.view.bu(t);r.snapshot&&i.push(r.snapshot)}),function(e,t){var n=Y(e);n.onlineState=t;var r=!1;n.queries.forEach(function(e,n){var i,a=p(n.listeners);try{for(a.s();!(i=a.n()).done;){i.value.bu(t)&&(r=!0)}}catch(u){a.e(u)}finally{a.f()}}),r&&Ps(n)}(r.eventManager,t),i.length&&r.rc.Ho(i),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}function Ys(e,t,n){var r,i,a,u,o,s;return m().async(function(c){for(;;)switch(c.prev=c.next){case 0:if((r=Y(e)).sharedClientState.updateQueryState(t,"rejected",n),i=r.hc.get(t),!(a=i&&i.key)){c.next=14;break}return u=(u=new on(we.comparator)).insert(a,pn.newNoDocument(a,ye.min())),o=Vr().add(a),s=new Br(ye.min(),new Map,new ln(fe),u,o),c.next=9,m().awrap(Hs(r,s));case 9:r.ac=r.ac.remove(a),r.hc.delete(t),uc(r),c.next=16;break;case 14:return c.next=16,m().awrap(lo(r.localStore,t,!1).then(function(){return nc(r,t,n)}).catch(Le));case 16:case"end":return c.stop()}},null,null,null,Promise)}function Js(e,t){var n,r,i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Y(e),r=t.batch.batchId,a.prev=1,a.next=4,m().awrap(io(n.localStore,t));case 4:return i=a.sent,tc(n,r,null),ec(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),a.next=10,m().awrap(oc(n,i));case 10:a.next=16;break;case 12:return a.prev=12,a.t0=a.catch(1),a.next=16,m().awrap(Le(a.t0));case 16:case"end":return a.stop()}},null,null,[[1,12]],Promise)}function Zs(e,t,n){var r,i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:return r=Y(e),a.prev=1,a.next=4,m().awrap(function(e,t){var n=Y(e);return n.persistence.runTransaction("Reject batch","readwrite-primary",function(e){var r;return n.mutationQueue.lookupMutationBatch(e,t).next(function(t){return H(null!==t),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t)}).next(function(){return n.mutationQueue.performConsistencyCheck(e)}).next(function(){return n.documentOverlayCache.removeOverlaysForBatchId(e,r,t)}).next(function(){return n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r)}).next(function(){return n.localDocuments.getDocuments(e,r)})})}(r.localStore,t));case 4:return i=a.sent,tc(r,t,n),ec(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),a.next=10,m().awrap(oc(r,i));case 10:a.next=16;break;case 12:return a.prev=12,a.t0=a.catch(1),a.next=16,m().awrap(Le(a.t0));case 16:case"end":return a.stop()}},null,null,[[1,12]],Promise)}function $s(e,t){var n,r,i,a;return m().async(function(u){for(;;)switch(u.prev=u.next){case 0:return ts((n=Y(e)).remoteStore)||G("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),u.prev=2,u.next=5,m().awrap(function(e){var t=Y(n.localStore);return t.persistence.runTransaction("Get highest unacknowledged batch id","readonly",function(e){return t.mutationQueue.getHighestUnacknowledgedBatchId(e)})}());case 5:if(-1!==(r=u.sent)){u.next=8;break}return u.abrupt("return",void t.resolve());case 8:(i=n.dc.get(r)||[]).push(t),n.dc.set(r,i),u.next=16;break;case 12:u.prev=12,u.t0=u.catch(2),a=bs(u.t0,"Initialization of waitForPendingWrites() operation failed"),t.reject(a);case 16:case"end":return u.stop()}},null,null,[[2,12]],Promise)}function ec(e,t){(e.dc.get(t)||[]).forEach(function(e){e.resolve()}),e.dc.delete(t)}function tc(e,t,n){var r=Y(e),i=r.fc[r.currentUser.toKey()];if(i){var a=i.get(t);a&&(n?a.reject(n):a.resolve(),i=i.remove(t)),r.fc[r.currentUser.toKey()]=i}}function nc(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;e.sharedClientState.removeLocalQueryTarget(t);var r,i=p(e.uc.get(t));try{for(i.s();!(r=i.n()).done;){var a=r.value;e.oc.delete(a),n&&e.rc.gc(a,n)}}catch(u){i.e(u)}finally{i.f()}e.uc.delete(t),e.isPrimaryClient&&e.lc.ds(t).forEach(function(t){e.lc.containsKey(t)||rc(e,t)})}function rc(e,t){e.cc.delete(t.path.canonicalString());var n=e.ac.get(t);null!==n&&(Yo(e.remoteStore,n),e.ac=e.ac.remove(t),e.hc.delete(n),uc(e))}function ic(e,t,n){var r,i=p(n);try{for(i.s();!(r=i.n()).done;){var a=r.value;a instanceof Vs?(e.lc.addReference(a.key,t),ac(e,a)):a instanceof qs?(G("SyncEngine","Document no longer in limbo: "+a.key),e.lc.removeReference(a.key,t),e.lc.containsKey(a.key)||rc(e,a.key)):W()}}catch(u){i.e(u)}finally{i.f()}}function ac(e,t){var n=t.key,r=n.path.canonicalString();e.ac.get(n)||e.cc.has(r)||(G("SyncEngine","New document in limbo: "+n),e.cc.add(r),uc(e))}function uc(e){for(;e.cc.size>0&&e.ac.size<e.maxConcurrentLimboResolutions;){var t=e.cc.values().next().value;e.cc.delete(t);var n=new we(me.fromString(t)),r=e._c.next();e.hc.set(r,new Ks(n)),e.ac=e.ac.insert(n,r),Xo(e.remoteStore,new la(Fn(_n(n.path)),r,2,We.at))}}function oc(e,t,n){var r,i,a,u;return m().async(function(o){for(;;)switch(o.prev=o.next){case 0:if(r=Y(e),i=[],a=[],u=[],o.t0=r.oc.isEmpty(),o.t0){o.next=9;break}return r.oc.forEach(function(e,o){u.push(r.mc(o,t,n).then(function(e){if((e||n)&&r.isPrimaryClient&&r.sharedClientState.updateQueryState(o.targetId,(null==e?void 0:e.fromCache)?"not-current":"current"),e){i.push(e);var t=$u.Ni(o.targetId,e);a.push(t)}}))}),o.next=6,m().awrap(Promise.all(u));case 6:return r.rc.Ho(i),o.next=9,m().awrap(function(e,t){var n,r,i,a,u,o,s,c;return m().async(function(l){for(;;)switch(l.prev=l.next){case 0:return n=Y(e),l.prev=1,l.next=4,m().awrap(n.persistence.runTransaction("notifyLocalViewChanges","readwrite",function(e){return Re.forEach(t,function(t){return Re.forEach(t.Ci,function(r){return n.persistence.referenceDelegate.addReference(e,t.targetId,r)}).next(function(){return Re.forEach(t.xi,function(r){return n.persistence.referenceDelegate.removeReference(e,t.targetId,r)})})})}));case 4:l.next=11;break;case 6:if(l.prev=6,l.t0=l.catch(1),Ue(l.t0)){l.next=10;break}throw l.t0;case 10:G("LocalStore","Failed to update sequence numbers: "+l.t0);case 11:r=p(t);try{for(r.s();!(i=r.n()).done;)a=i.value,u=a.targetId,a.fromCache||(o=n.Ki.get(u),s=o.snapshotVersion,c=o.withLastLimboFreeSnapshotVersion(s),n.Ki=n.Ki.insert(u,c))}catch(f){r.e(f)}finally{r.f()}case 13:case"end":return l.stop()}},null,null,[[1,6]],Promise)}(r.localStore,a));case 9:case"end":return o.stop()}},null,null,null,Promise)}function sc(e,t){var n,r;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:if((n=Y(e)).currentUser.isEqual(t)){i.next=11;break}return G("SyncEngine","User change. New user:",t.toKey()),i.next=5,m().awrap(ro(n.localStore,t));case 5:return r=i.sent,n.currentUser=t,function(e,t){e.dc.forEach(function(e){e.forEach(function(e){e.reject(new Z(J.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.dc.clear()}(n),n.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),i.next=11,m().awrap(oc(n,r.Wi));case 11:case"end":return i.stop()}},null,null,null,Promise)}function cc(e,t){var n=Y(e),r=n.hc.get(t);if(r&&r.ic)return Vr().add(r.key);var i=Vr(),a=n.uc.get(t);if(!a)return i;var u,o=p(a);try{for(o.s();!(u=o.n()).done;){var s=u.value,c=n.oc.get(s);i=i.unionWith(c.view.Wu)}}catch(l){o.e(l)}finally{o.f()}return i}function lc(e,t){var n,r,i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Y(e),a.next=3,m().awrap(fo(n.localStore,t.query,!0));case 3:return r=a.sent,i=t.view.nc(r),a.abrupt("return",(n.isPrimaryClient&&ic(n,t.targetId,i.tc),i));case 6:case"end":return a.stop()}},null,null,null,Promise)}function fc(e,t){var n;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:return n=Y(e),r.abrupt("return",vo(n.localStore,t).then(function(e){return oc(n,e)}));case 2:case"end":return r.stop()}},null,null,null,Promise)}function hc(e,t,n,r){var i,a;return m().async(function(u){for(;;)switch(u.prev=u.next){case 0:return i=Y(e),u.next=3,m().awrap(function(e,t){var n=Y(e),r=Y(n.mutationQueue);return n.persistence.runTransaction("Lookup mutation documents","readonly",function(e){return r.An(e,t).next(function(t){return t?n.localDocuments.getDocuments(e,t):Re.resolve(null)})})}(i.localStore,t));case 3:if(null===(a=u.sent)){u.next=15;break}if("pending"!==n){u.next=10;break}return u.next=8,m().awrap(ss(i.remoteStore));case 8:u.next=11;break;case 10:"acknowledged"===n||"rejected"===n?(tc(i,t,r||null),ec(i,t),function(e,t){Y(Y(e).mutationQueue).Pn(t)}(i.localStore,t)):W();case 11:return u.next=13,m().awrap(oc(i,a));case 13:u.next=16;break;case 15:G("SyncEngine","Cannot apply mutation batch with id: "+t);case 16:case"end":return u.stop()}},null,null,null,Promise)}function dc(e,t){var n,r,i,a,u,o,s,c;return m().async(function(l){for(;;)switch(l.prev=l.next){case 0:if(kc(n=Y(e)),wc(n),!0!==t||!0===n.wc){l.next=13;break}return r=n.sharedClientState.getAllActiveQueryTargets(),l.next=5,m().awrap(vc(n,r.toArray()));case 5:return i=l.sent,n.wc=!0,l.next=9,m().awrap(gs(n.remoteStore,!0));case 9:a=p(i);try{for(a.s();!(u=a.n()).done;)o=u.value,Xo(n.remoteStore,o)}catch(f){a.e(f)}finally{a.f()}l.next=25;break;case 13:if(!1!==t||!1===n.wc){l.next=25;break}return s=[],c=Promise.resolve(),n.uc.forEach(function(e,t){n.sharedClientState.isLocalQueryTarget(t)?s.push(t):c=c.then(function(){return nc(n,t),lo(n.localStore,t,!0)}),Yo(n.remoteStore,t)}),l.next=19,m().awrap(c);case 19:return l.next=21,m().awrap(vc(n,s));case 21:return function(e){var t=Y(n);t.hc.forEach(function(e,n){Yo(t.remoteStore,n)}),t.lc._s(),t.hc=new Map,t.ac=new on(we.comparator)}(),n.wc=!1,l.next=25,m().awrap(gs(n.remoteStore,!1));case 25:case"end":return l.stop()}},null,null,null,Promise)}function vc(e,t,n){var r,i,a,u,o,s,c,l,f,h,d,v,y,g;return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:r=Y(e),i=[],a=[],u=p(t),n.prev=2,u.s();case 4:if((o=u.n()).done){n.next=45;break}if(s=o.value,c=void 0,!(l=r.uc.get(s))||0===l.length){n.next=34;break}return n.next=11,m().awrap(co(r.localStore,Fn(l[0])));case 11:c=n.sent,f=p(l),n.prev=13,f.s();case 15:if((h=f.n()).done){n.next=24;break}return d=h.value,v=r.oc.get(d),n.next=20,m().awrap(lc(r,v));case 20:(y=n.sent).snapshot&&a.push(y.snapshot);case 22:n.next=15;break;case 24:n.next=29;break;case 26:n.prev=26,n.t0=n.catch(13),f.e(n.t0);case 29:return n.prev=29,f.f(),n.finish(29);case 32:n.next=42;break;case 34:return n.next=36,m().awrap(ho(r.localStore,s));case 36:return g=n.sent,n.next=39,m().awrap(co(r.localStore,g));case 39:return c=n.sent,n.next=42,m().awrap(js(r,yc(g),s,!1,c.resumeToken));case 42:i.push(c);case 43:n.next=4;break;case 45:n.next=50;break;case 47:n.prev=47,n.t1=n.catch(2),u.e(n.t1);case 50:return n.prev=50,u.f(),n.finish(50);case 53:return n.abrupt("return",(r.rc.Ho(a),i));case 54:case"end":return n.stop()}},null,null,[[2,47,50,53],[13,26,29,32]],Promise)}function yc(e){return Sn(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function pc(e){var t=Y(e);return Y(Y(t.localStore).persistence).Si()}function mc(e,t,n,r){var i,a,u,o;return m().async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(i=Y(e)).wc){s.next=3;break}return s.abrupt("return",void G("SyncEngine","Ignoring unexpected query state notification."));case 3:if(!((a=i.uc.get(t))&&a.length>0)){s.next=20;break}s.t0=n,s.next="current"===s.t0?8:"not-current"===s.t0?8:"rejected"===s.t0?15:19;break;case 8:return s.next=10,m().awrap(vo(i.localStore,Un(a[0])));case 10:return u=s.sent,o=Br.createSynthesizedRemoteEventForCurrentChange(t,"current"===n,ot.EMPTY_BYTE_STRING),s.next=14,m().awrap(oc(i,u,o));case 14:return s.abrupt("break",20);case 15:return s.next=17,m().awrap(lo(i.localStore,t,!0));case 17:return nc(i,t,r),s.abrupt("break",20);case 19:W();case 20:case"end":return s.stop()}},null,null,null,Promise)}function gc(e,t,n){var r,i,a,u,o,s,c,l,f;return m().async(function(h){for(;;)switch(h.prev=h.next){case 0:if(!(r=kc(e)).wc){h.next=46;break}i=p(t),h.prev=3,i.s();case 5:if((a=i.n()).done){h.next=21;break}if(u=a.value,!r.uc.has(u)){h.next=10;break}return G("SyncEngine","Adding an already active target "+u),h.abrupt("continue",19);case 10:return h.next=12,m().awrap(ho(r.localStore,u));case 12:return o=h.sent,h.next=15,m().awrap(co(r.localStore,o));case 15:return s=h.sent,h.next=18,m().awrap(js(r,yc(o),s.targetId,!1,s.resumeToken));case 18:Xo(r.remoteStore,s);case 19:h.next=5;break;case 21:h.next=26;break;case 23:h.prev=23,h.t0=h.catch(3),i.e(h.t0);case 26:return h.prev=26,i.f(),h.finish(26);case 29:c=p(n),h.prev=30,f=function(){var e;return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e=l.value,t.t0=r.uc.has(e),!t.t0){t.next=5;break}return t.next=5,m().awrap(lo(r.localStore,e,!1).then(function(){Yo(r.remoteStore,e),nc(r,e)}).catch(Le));case 5:case"end":return t.stop()}},null,null,null,Promise)},c.s();case 33:if((l=c.n()).done){h.next=38;break}return h.next=36,m().awrap(f());case 36:h.next=33;break;case 38:h.next=43;break;case 40:h.prev=40,h.t1=h.catch(30),c.e(h.t1);case 43:return h.prev=43,c.f(),h.finish(43);case 46:case"end":return h.stop()}},null,null,[[3,23,26,29],[30,40,43,46]],Promise)}function kc(e){var t=Y(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=Hs.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=cc.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Ys.bind(null,t),t.rc.Ho=Ns.bind(null,t.eventManager),t.rc.gc=Cs.bind(null,t.eventManager),t}function wc(e){var t=Y(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=Js.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Zs.bind(null,t),t}function xc(e,t,n){var r=Y(e);(function(e,t,n){var r,i,a,u,o;return m().async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.prev=0,s.next=3,m().awrap(t.getMetadata());case 3:return r=s.sent,s.next=6,m().awrap(function(e,t){var n=Y(e),r=ri(t.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",function(e){return n.$s.getBundleMetadata(e,t.id)}).then(function(e){return!!e&&e.createTime.compareTo(r)>=0})}(e.localStore,r));case 6:if(!s.sent){s.next=11;break}return s.next=9,m().awrap(t.close());case 9:return n._completeWith(function(e){return{taskState:"Success",documentsLoaded:e.totalDocuments,bytesLoaded:e.totalBytes,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}(r)),s.abrupt("return",Promise.resolve(new Set));case 11:return n._updateProgress(Os(r)),i=new Ms(r,e.localStore,t.Tt),s.next=15,m().awrap(t.yc());case 15:a=s.sent;case 16:if(!a){s.next=26;break}return s.next=19,m().awrap(i.Bu(a));case 19:return(u=s.sent)&&n._updateProgress(u),s.next=23,m().awrap(t.yc());case 23:a=s.sent;case 24:s.next=16;break;case 26:return s.next=28,m().awrap(i.complete());case 28:return o=s.sent,s.next=31,m().awrap(oc(e,o.Uu,void 0));case 31:return s.next=33,m().awrap(function(e,t){var n=Y(e);return n.persistence.runTransaction("Save bundle","readwrite",function(e){return n.$s.saveBundleMetadata(e,t)})}(e.localStore,r));case 33:return n._completeWith(o.progress),s.abrupt("return",Promise.resolve(o.qu));case 37:return s.prev=37,s.t0=s.catch(0),s.abrupt("return",(j("SyncEngine","Loading bundle failed with ".concat(s.t0)),n._failWith(s.t0),Promise.resolve(new Set)));case 40:case"end":return s.stop()}},null,null,[[0,37]],Promise)})(r,t,n).then(function(e){r.sharedClientState.notifyBundleLoaded(e)})}var bc=function(){function e(){P(this,e),this.synchronizeTabs=!1}return L(e,[{key:"initialize",value:function(e){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.Tt=Vo(e.databaseInfo.databaseId),this.sharedClientState=this.Ic(e),this.persistence=this.Tc(e),t.next=5,m().awrap(this.persistence.start());case 5:this.localStore=this.Ec(e),this.gcScheduler=this.Ac(e,this.localStore),this.indexBackfillerScheduler=this.Rc(e,this.localStore);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"Ac",value:function(e,t){return null}},{key:"Rc",value:function(e,t){return null}},{key:"Ec",value:function(e){return no(this.persistence,new eo,e.initialUser,this.Tt)}},{key:"Tc",value:function(e){return new Gu(ju.qs,this.Tt)}},{key:"Ic",value:function(e){return new _o}},{key:"terminate",value:function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.gcScheduler&&this.gcScheduler.stop(),e.next=3,m().awrap(this.sharedClientState.shutdown());case 3:return e.next=5,m().awrap(this.persistence.shutdown());case 5:case"end":return e.stop()}},null,this,null,Promise)}}]),e}(),Ic=function(e){g(n,bc);var t=w(n);function n(e,r,i){var a;return P(this,n),(a=t.call(this)).Pc=e,a.cacheSizeBytes=r,a.forceOwnership=i,a.synchronizeTabs=!1,a}return L(n,[{key:"initialize",value:function(e){var t=this;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,m().awrap(o(T(n.prototype),"initialize",this).call(this,e));case 2:return r.next=4,m().awrap(this.Pc.initialize(this,e));case 4:return r.next=6,m().awrap(wc(this.Pc.syncEngine));case 6:return r.next=8,m().awrap(ss(this.Pc.remoteStore));case 8:return r.next=10,m().awrap(this.persistence.di(function(){return t.gcScheduler&&!t.gcScheduler.started&&t.gcScheduler.start(),t.indexBackfillerScheduler&&!t.indexBackfillerScheduler.started&&t.indexBackfillerScheduler.start(),Promise.resolve()}));case 10:case"end":return r.stop()}},null,this,null,Promise)}},{key:"Ec",value:function(e){return no(this.persistence,new eo,e.initialUser,this.Tt)}},{key:"Ac",value:function(e,t){var n=this.persistence.referenceDelegate.garbageCollector;return new wu(n,e.asyncQueue,t)}},{key:"Rc",value:function(e,t){var n=new ze(t,this.persistence);return new je(e.asyncQueue,n)}},{key:"Tc",value:function(e){var t=Zu(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?au.withCacheSize(this.cacheSizeBytes):au.DEFAULT;return new Xu(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,Mo(),Oo(),this.Tt,this.sharedClientState,!!this.forceOwnership)}},{key:"Ic",value:function(e){return new _o}}]),n}(),Tc=function(e){g(n,Ic);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this,e,r,!1)).Pc=e,i.cacheSizeBytes=r,i.synchronizeTabs=!0,i}return L(n,[{key:"initialize",value:function(e){var t,r=this;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,m().awrap(o(T(n.prototype),"initialize",this).call(this,e));case 2:if(t=this.Pc.syncEngine,i.t0=this.sharedClientState instanceof So,!i.t0){i.next=8;break}return this.sharedClientState.syncEngine={Br:hc.bind(null,t),Lr:mc.bind(null,t),qr:gc.bind(null,t),Si:pc.bind(null,t),Fr:fc.bind(null,t)},i.next=8,m().awrap(this.sharedClientState.start());case 8:return i.next=10,m().awrap(this.persistence.di(function(e){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,m().awrap(dc(r.Pc.syncEngine,e));case 2:r.gcScheduler&&(e&&!r.gcScheduler.started?r.gcScheduler.start():e||r.gcScheduler.stop()),r.indexBackfillerScheduler&&(e&&!r.indexBackfillerScheduler.started?r.indexBackfillerScheduler.start():e||r.indexBackfillerScheduler.stop());case 4:case"end":return t.stop()}},null,null,null,Promise)}));case 10:case"end":return i.stop()}},null,this,null,Promise)}},{key:"Ic",value:function(e){var t=Mo();if(!So.C(t))throw new Z(J.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=Zu(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new So(t,e.asyncQueue,n,e.clientId,e.initialUser)}}]),n}(),Ec=function(){function e(){P(this,e)}return L(e,[{key:"initialize",value:function(e,t){var n=this;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:if(r.t0=this.localStore,r.t0){r.next=12;break}return this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=function(e){return Xs(n.syncEngine,e,1)},this.remoteStore.remoteSyncer.handleCredentialChange=sc.bind(null,this.syncEngine),r.next=12,m().awrap(gs(this.remoteStore,this.syncEngine.isPrimaryClient));case 12:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createEventManager",value:function(e){return new _s}},{key:"createDatastore",value:function(e){var t,n=Vo(e.databaseInfo.databaseId),r=(t=e.databaseInfo,new Ro(t));return function(e,t,n,r){return new Go(e,t,n,r)}(e.authCredentials,e.appCheckCredentials,r,n)}},{key:"createRemoteStore",value:function(e){var t,n,r,i,a,u=this;return t=this.localStore,n=this.datastore,r=e.asyncQueue,i=function(e){return Xs(u.syncEngine,e,0)},a=Do.C()?new Do:new Ao,new zo(t,n,r,i,a)}},{key:"createSyncEngine",value:function(e,t){return function(e,t,n,r,i,a,u){var o=new Gs(e,t,n,r,i,a);return u&&(o.wc=!0),o}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}},{key:"terminate",value:function(){return e=this.remoteStore,m().async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=Y(e),G("RemoteStore","RemoteStore shutting down."),t.mu.add(5),n.next=5,m().awrap(Ho(t));case 5:t.yu.shutdown(),t.pu.set("Unknown");case 7:case"end":return n.stop()}},null,null,null,Promise);var e,t}}]),e}();function Sc(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10240,n=0;return{read:function(){var r;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(n<e.byteLength)){i.next=3;break}return r={value:e.slice(n,n+t),done:!1},i.abrupt("return",(n+=t,r));case 3:return i.abrupt("return",{done:!0});case 4:case"end":return i.stop()}},null,null,null,Promise)},cancel:function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)},releaseLock:function(){},closed:Promise.resolve()}}var _c=function(){function e(t){P(this,e),this.observer=t,this.muted=!1}return L(e,[{key:"next",value:function(e){this.observer.next&&this.vc(this.observer.next,e)}},{key:"error",value:function(e){this.observer.error?this.vc(this.observer.error,e):Q("Uncaught Error in snapshot listener:",e.toString())}},{key:"bc",value:function(){this.muted=!0}},{key:"vc",value:function(e,t){var n=this;this.muted||setTimeout(function(){n.muted||e(t)},0)}}]),e}(),Ac=function(){function e(t,n){var r=this;P(this,e),this.Vc=t,this.Tt=n,this.metadata=new $,this.buffer=new Uint8Array,this.Sc=new TextDecoder("utf-8"),this.Dc().then(function(e){e&&e.Ou()?r.metadata.resolve(e.Mu.metadata):r.metadata.reject(new Error("The first element of the bundle is not a metadata, it is\n ".concat(JSON.stringify(null==e?void 0:e.Mu))))},function(e){return r.metadata.reject(e)})}return L(e,[{key:"close",value:function(){return this.Vc.cancel()}},{key:"getMetadata",value:function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.metadata.promise);case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"yc",value:function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m().awrap(this.getMetadata());case 2:return e.abrupt("return",this.Dc());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"Dc",value:function(){var e,t,n,r;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,m().awrap(this.Cc());case 2:if(null!==(e=i.sent)){i.next=5;break}return i.abrupt("return",null);case 5:return t=this.Sc.decode(e),n=Number(t),isNaN(n)&&this.xc("length string (".concat(t,") is not valid number")),i.next=9,m().awrap(this.Nc(n));case 9:return r=i.sent,i.abrupt("return",new Ls(JSON.parse(r),e.length+n));case 11:case"end":return i.stop()}},null,this,null,Promise)}},{key:"kc",value:function(){return this.buffer.findIndex(function(e){return e==="{".charCodeAt(0)})}},{key:"Cc",value:function(){var e,t;return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(this.kc()<0)){n.next=7;break}return n.next=3,m().awrap(this.$c());case 3:if(!n.sent){n.next=5;break}return n.abrupt("break",7);case 5:n.next=0;break;case 7:if(0!==this.buffer.length){n.next=9;break}return n.abrupt("return",null);case 9:return(e=this.kc())<0&&this.xc("Reached the end of bundle when a length string is expected."),t=this.buffer.slice(0,e),n.abrupt("return",(this.buffer=this.buffer.slice(e),t));case 13:case"end":return n.stop()}},null,this,null,Promise)}},{key:"Nc",value:function(e){var t;return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(this.buffer.length<e)){n.next=8;break}return n.next=3,m().awrap(this.$c());case 3:if(n.t0=n.sent,!n.t0){n.next=6;break}this.xc("Reached the end of bundle when more is expected.");case 6:n.next=0;break;case 8:return t=this.Sc.decode(this.buffer.slice(0,e)),n.abrupt("return",(this.buffer=this.buffer.slice(e),t));case 10:case"end":return n.stop()}},null,this,null,Promise)}},{key:"xc",value:function(e){throw this.Vc.cancel(),new Error("Invalid bundle format: ".concat(e))}},{key:"$c",value:function(){var e,t;return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,m().awrap(this.Vc.read());case 2:return(e=n.sent).done||((t=new Uint8Array(this.buffer.length+e.value.length)).set(this.buffer),t.set(e.value,this.buffer.length),this.buffer=t),n.abrupt("return",e.done);case 5:case"end":return n.stop()}},null,this,null,Promise)}}]),e}(),Dc=function(){function e(t){P(this,e),this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}return L(e,[{key:"lookup",value:function(e){var t,n=this;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:if(this.ensureCommitNotCalled(),!(this.mutations.length>0)){r.next=2;break}throw new Z(J.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");case 2:return r.next=4,m().awrap(function(e,t){var n,r,i,a,u,o;return m().async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=Y(e),r=li(n.Tt)+"/documents",i={documents:t.map(function(e){return ui(n.Tt,e)})},s.next=5,m().awrap(n.mo("BatchGetDocuments",r,i,t.length));case 5:return a=s.sent,u=new Map,a.forEach(function(e){var t=vi(n.Tt,e);u.set(t.key.toString(),t)}),o=[],s.abrupt("return",(t.forEach(function(e){var t=u.get(e.toString());H(!!t),o.push(t)}),o));case 10:case"end":return s.stop()}},null,null,null,Promise)}(this.datastore,e));case 4:return t=r.sent,r.abrupt("return",(t.forEach(function(e){return n.recordVersion(e)}),t));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"set",value:function(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}},{key:"update",value:function(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastWriteError=e}this.writtenDocs.add(e.toString())}},{key:"delete",value:function(e){this.write(new br(e,this.precondition(e))),this.writtenDocs.add(e.toString())}},{key:"commit",value:function(){var e,t=this;return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.ensureCommitNotCalled(),!this.lastWriteError){n.next=2;break}throw this.lastWriteError;case 2:return e=this.readVersions,this.mutations.forEach(function(t){e.delete(t.key.toString())}),e.forEach(function(e,n){var r=we.fromPath(n);t.mutations.push(new Ir(r,t.precondition(r)))}),n.next=7,m().awrap(function(e,t){var n,r,i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Y(e),r=li(n.Tt)+"/documents",i={writes:t.map(function(e){return pi(n.Tt,e)})},a.next=3,m().awrap(n.lo("Commit",r,i));case 3:case"end":return a.stop()}},null,null,null,Promise)}(this.datastore,this.mutations));case 7:this.committed=!0;case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"recordVersion",value:function(e){var t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw W();t=ye.min()}var n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new Z(J.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}},{key:"precondition",value:function(e){var t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(ye.min())?or.exists(!1):or.updateTime(t):or.none()}},{key:"preconditionForUpdate",value:function(e){var t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(ye.min()))throw new Z(J.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return or.updateTime(t)}return or.exists(!0)}},{key:"write",value:function(e){this.ensureCommitNotCalled(),this.mutations.push(e)}},{key:"ensureCommitNotCalled",value:function(){}}]),e}(),Nc=function(){function e(t,n,r,i,a){P(this,e),this.asyncQueue=t,this.datastore=n,this.options=r,this.updateFunction=i,this.deferred=a,this.Mc=r.maxAttempts,this.ko=new qo(this.asyncQueue,"transaction_retry")}return L(e,[{key:"run",value:function(){this.Mc-=1,this.Oc()}},{key:"Oc",value:function(){var e=this;this.ko.vo(function(){var t,n;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:t=new Dc(e.datastore),(n=e.Fc(t))&&n.then(function(n){e.asyncQueue.enqueueAndForget(function(){return t.commit().then(function(){e.deferred.resolve(n)}).catch(function(t){e.Bc(t)})})}).catch(function(t){e.Bc(t)});case 2:case"end":return r.stop()}},null,null,null,Promise)})}},{key:"Fc",value:function(e){try{var t=this.updateFunction(e);return!nt(t)&&t.catch&&t.then?t:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}},{key:"Bc",value:function(e){var t=this;this.Mc>0&&this.Lc(e)?(this.Mc-=1,this.asyncQueue.enqueueAndForget(function(){return t.Oc(),Promise.resolve()})):this.deferred.reject(e)}},{key:"Lc",value:function(e){if("FirebaseError"===e.name){var t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!Er(t)}return!1}}]),e}(),Cc=function(){function e(t,n,r,i){var a=this;P(this,e),this.authCredentials=t,this.appCheckCredentials=n,this.asyncQueue=r,this.databaseInfo=i,this.user=V.UNAUTHENTICATED,this.clientId=le.R(),this.authCredentialListener=function(){return Promise.resolve()},this.appCheckCredentialListener=function(){return Promise.resolve()},this.authCredentials.start(r,function(e){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:return G("FirestoreClient","Received user=",e.uid),t.next=3,m().awrap(a.authCredentialListener(e));case 3:a.user=e;case 4:case"end":return t.stop()}},null,null,null,Promise)}),this.appCheckCredentials.start(r,function(e){return G("FirestoreClient","Received new app check token=",e),a.appCheckCredentialListener(e,a.user)})}return L(e,[{key:"getConfiguration",value:function(){return m().async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100});case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setCredentialChangeListener",value:function(e){this.authCredentialListener=e}},{key:"setAppCheckTokenChangeListener",value:function(e){this.appCheckCredentialListener=e}},{key:"verifyNotTerminated",value:function(){if(this.asyncQueue.isShuttingDown)throw new Z(J.FAILED_PRECONDITION,"The client has already been terminated.")}},{key:"terminate",value:function(){var e=this;this.asyncQueue.enterRestrictedMode();var t=new $;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(function(){var n;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,r.t0=e.onlineComponents,!r.t0){r.next=5;break}return r.next=5,m().awrap(e.onlineComponents.terminate());case 5:if(r.t1=e.offlineComponents,!r.t1){r.next=9;break}return r.next=9,m().awrap(e.offlineComponents.terminate());case 9:e.authCredentials.shutdown(),e.appCheckCredentials.shutdown(),t.resolve(),r.next=18;break;case 14:r.prev=14,r.t2=r.catch(0),n=bs(r.t2,"Failed to shutdown persistence"),t.reject(n);case 18:case"end":return r.stop()}},null,null,[[0,14]],Promise)}),t.promise}}]),e}();function Pc(e,t){var n,r;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:return e.asyncQueue.verifyOperationInProgress(),G("FirestoreClient","Initializing OfflineComponentProvider"),i.next=3,m().awrap(e.getConfiguration());case 3:return n=i.sent,i.next=6,m().awrap(t.initialize(n));case 6:r=n.initialUser,e.setCredentialChangeListener(function(e){return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:if(n.t0=r.isEqual(e),n.t0){n.next=5;break}return n.next=4,m().awrap(ro(t.localStore,e));case 4:r=e;case 5:case"end":return n.stop()}},null,null,null,Promise)}),t.persistence.setDatabaseDeletedListener(function(){return e.terminate()}),e.offlineComponents=t;case 8:case"end":return i.stop()}},null,null,null,Promise)}function Fc(e,t){var n,r;return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:return e.asyncQueue.verifyOperationInProgress(),i.next=3,m().awrap(Lc(e));case 3:return n=i.sent,G("FirestoreClient","Initializing OnlineComponentProvider"),i.next=7,m().awrap(e.getConfiguration());case 7:return r=i.sent,i.next=10,m().awrap(t.initialize(n,r));case 10:e.setCredentialChangeListener(function(e){return ms(t.remoteStore,e)}),e.setAppCheckTokenChangeListener(function(e,n){return ms(t.remoteStore,n)}),e.onlineComponents=t;case 13:case"end":return i.stop()}},null,null,null,Promise)}function Lc(e){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=e.offlineComponents,t.t0){t.next=5;break}return G("FirestoreClient","Using default OfflineComponentProvider"),t.next=5,m().awrap(Pc(e,new bc));case 5:return t.abrupt("return",e.offlineComponents);case 6:case"end":return t.stop()}},null,null,null,Promise)}function Rc(e){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=e.onlineComponents,t.t0){t.next=5;break}return G("FirestoreClient","Using default OnlineComponentProvider"),t.next=5,m().awrap(Fc(e,new Ec));case 5:return t.abrupt("return",e.onlineComponents);case 6:case"end":return t.stop()}},null,null,null,Promise)}function Mc(e){return Lc(e).then(function(e){return e.persistence})}function Oc(e){return Lc(e).then(function(e){return e.localStore})}function Vc(e){return Rc(e).then(function(e){return e.remoteStore})}function qc(e){return Rc(e).then(function(e){return e.syncEngine})}function Uc(e){return Rc(e).then(function(e){return e.datastore})}function Bc(e){var t,n;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,m().awrap(Rc(e));case 2:return t=r.sent,n=t.eventManager,r.abrupt("return",(n.onListen=Qs.bind(null,t.syncEngine),n.onUnlisten=zs.bind(null,t.syncEngine),n));case 5:case"end":return r.stop()}},null,null,null,Promise)}function Kc(e){return e.asyncQueue.enqueue(function(){var t,n;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,m().awrap(Mc(e));case 2:return t=r.sent,r.next=5,m().awrap(Vc(e));case 5:return n=r.sent,r.abrupt("return",(t.setNetworkEnabled(!0),function(e){var t=Y(n);return t.mu.delete(0),Wo(t)}()));case 7:case"end":return r.stop()}},null,null,null,Promise)})}function Gc(e){return e.asyncQueue.enqueue(function(){var t,n;return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,m().awrap(Mc(e));case 2:return t=r.sent,r.next=5,m().awrap(Vc(e));case 5:return n=r.sent,r.abrupt("return",(t.setNetworkEnabled(!1),function(e){var t;return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=Y(e)).mu.add(0),n.next=4,m().awrap(Ho(t));case 4:t.pu.set("Offline");case 5:case"end":return n.stop()}},null,null,null,Promise)}(n)));case 7:case"end":return r.stop()}},null,null,null,Promise)})}function Qc(e,t){var n=new $;return e.asyncQueue.enqueueAndForget(function(){return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=function(e,t,n){var r,i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,m().awrap(function(e,t){var n=Y(e);return n.persistence.runTransaction("read document","readonly",function(e){return n.localDocuments.getDocument(e,t)})}(e,t));case 3:(r=a.sent).isFoundDocument()?n.resolve(r):r.isNoDocument()?n.resolve(null):n.reject(new Z(J.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)")),a.next=11;break;case 7:a.prev=7,a.t0=a.catch(0),i=bs(a.t0,"Failed to get document '".concat(t," from cache")),n.reject(i);case 11:case"end":return a.stop()}},null,null,[[0,7]],Promise)},r.next=3,m().awrap(Oc(e));case 3:return r.t1=r.sent,r.t2=t,r.t3=n,r.abrupt("return",(0,r.t0)(r.t1,r.t2,r.t3));case 7:case"end":return r.stop()}},null,null,null,Promise)}),n.promise}function jc(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=new $;return e.asyncQueue.enqueueAndForget(function(){return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.t0=function(e,t,n,r,i){var a=new _c({next:function(a){t.enqueueAndForget(function(){return Ds(e,u)});var o=a.docs.has(n);!o&&a.fromCache?i.reject(new Z(J.UNAVAILABLE,"Failed to get document because the client is offline.")):o&&a.fromCache&&r&&"server"===r.source?i.reject(new Z(J.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):i.resolve(a)},error:function(e){return i.reject(e)}}),u=new Fs(_n(n.path),a,{includeMetadataChanges:!0,$u:!0});return As(e,u)},i.next=3,m().awrap(Bc(e));case 3:return i.t1=i.sent,i.t2=e.asyncQueue,i.t3=t,i.t4=n,i.t5=r,i.abrupt("return",(0,i.t0)(i.t1,i.t2,i.t3,i.t4,i.t5));case 9:case"end":return i.stop()}},null,null,null,Promise)}),r.promise}function zc(e,t){var n=new $;return e.asyncQueue.enqueueAndForget(function(){return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=function(e,t,n){var r,i,a,u,o;return m().async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.prev=0,s.next=3,m().awrap(fo(e,t,!0));case 3:r=s.sent,i=new Us(t,r.Yi),a=i.Hu(r.documents),u=i.applyChanges(a,!1),n.resolve(u.snapshot),s.next=14;break;case 10:s.prev=10,s.t0=s.catch(0),o=bs(s.t0,"Failed to execute query '".concat(t," against cache")),n.reject(o);case 14:case"end":return s.stop()}},null,null,[[0,10]],Promise)},r.next=3,m().awrap(Oc(e));case 3:return r.t1=r.sent,r.t2=t,r.t3=n,r.abrupt("return",(0,r.t0)(r.t1,r.t2,r.t3));case 7:case"end":return r.stop()}},null,null,null,Promise)}),n.promise}function Wc(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=new $;return e.asyncQueue.enqueueAndForget(function(){return m().async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.t0=function(e,t,n,r,i){var a=new _c({next:function(n){t.enqueueAndForget(function(){return Ds(e,u)}),n.fromCache&&"server"===r.source?i.reject(new Z(J.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):i.resolve(n)},error:function(e){return i.reject(e)}}),u=new Fs(n,a,{includeMetadataChanges:!0,$u:!0});return As(e,u)},i.next=3,m().awrap(Bc(e));case 3:return i.t1=i.sent,i.t2=e.asyncQueue,i.t3=t,i.t4=n,i.t5=r,i.abrupt("return",(0,i.t0)(i.t1,i.t2,i.t3,i.t4,i.t5));case 9:case"end":return i.stop()}},null,null,null,Promise)}),r.promise}function Hc(e,t){var n=new _c(t);return e.asyncQueue.enqueueAndForget(function(){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=function(e,t){Y(e).vu.add(t),t.next()},t.next=3,m().awrap(Bc(e));case 3:return t.t1=t.sent,t.t2=n,t.abrupt("return",(0,t.t0)(t.t1,t.t2));case 6:case"end":return t.stop()}},null,null,null,Promise)}),function(){n.bc(),e.asyncQueue.enqueueAndForget(function(){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=function(e,t){Y(e).vu.delete(t)},t.next=3,m().awrap(Bc(e));case 3:return t.t1=t.sent,t.t2=n,t.abrupt("return",(0,t.t0)(t.t1,t.t2));case 6:case"end":return t.stop()}},null,null,null,Promise)})}}function Xc(e,t,n,r){var i=function(e,t){return function(e,t){return new Ac(e,t)}(function(e,t){if(e instanceof Uint8Array)return Sc(e,t);if(e instanceof ArrayBuffer)return Sc(new Uint8Array(e),t);if(e instanceof ReadableStream)return e.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}("string"==typeof e?(new TextEncoder).encode(e):e),t)}(n,Vo(t));e.asyncQueue.enqueueAndForget(function(){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=xc,t.next=3,m().awrap(qc(e));case 3:t.t1=t.sent,t.t2=i,t.t3=r,(0,t.t0)(t.t1,t.t2,t.t3);case 7:case"end":return t.stop()}},null,null,null,Promise)})}function Yc(e,t){return e.asyncQueue.enqueue(function(){return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.t0=function(e,t){var n=Y(e);return n.persistence.runTransaction("Get named query","readonly",function(e){return n.$s.getNamedQuery(e,t)})},n.next=3,m().awrap(Oc(e));case 3:return n.t1=n.sent,n.t2=t,n.abrupt("return",(0,n.t0)(n.t1,n.t2));case 6:case"end":return n.stop()}},null,null,null,Promise)})}var Jc=new Map;function Zc(e,t,n){if(!n)throw new Z(J.INVALID_ARGUMENT,"Function ".concat(e,"() cannot be called with an empty ").concat(t,"."))}function $c(e,t,n,r){if(!0===t&&!0===r)throw new Z(J.INVALID_ARGUMENT,"".concat(e," and ").concat(n," cannot be used together."))}function el(e){if(!we.isDocumentKey(e))throw new Z(J.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but ".concat(e," has ").concat(e.length,"."))}function tl(e){if(we.isDocumentKey(e))throw new Z(J.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but ".concat(e," has ").concat(e.length,"."))}function nl(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e="".concat(e.substring(0,20),"...")),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==C(e)){if(e instanceof Array)return"an array";var t=function(e){return e.constructor?e.constructor.name:null}(e);return t?"a custom ".concat(t," object"):"an object"}return"function"==typeof e?"a function":W()}function rl(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new Z(J.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=nl(e);throw new Z(J.INVALID_ARGUMENT,"Expected type '".concat(t.name,"', but it was: ").concat(n))}return e}function il(e,t){if(t<=0)throw new Z(J.INVALID_ARGUMENT,"Function ".concat(e,"() requires a positive number, but it was: ").concat(t,"."))}var al=function(){function e(t){var n;if(P(this,e),void 0===t.host){if(void 0!==t.ssl)throw new Z(J.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=null===(n=t.ssl)||void 0===n||n;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new Z(J.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.useFetchStreams=!!t.useFetchStreams,$c("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}return L(e,[{key:"isEqual",value:function(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}]),e}(),ul=function(){function e(t,n,r,i){P(this,e),this._authCredentials=t,this._appCheckCredentials=n,this._databaseId=r,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new al({}),this._settingsFrozen=!1}return L(e,[{key:"app",get:function(){if(!this._app)throw new Z(J.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}},{key:"_initialized",get:function(){return this._settingsFrozen}},{key:"_terminated",get:function(){return void 0!==this._terminateTask}},{key:"_setSettings",value:function(e){if(this._settingsFrozen)throw new Z(J.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new al(e),void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new te;switch(e.type){case"gapi":var t=e.client;return new ae(t,e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new Z(J.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}},{key:"_getSettings",value:function(){return this._settings}},{key:"_freezeSettings",value:function(){return this._settingsFrozen=!0,this._settings}},{key:"_delete",value:function(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}},{key:"toJSON",value:function(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}},{key:"_terminate",value:function(){return e=this,(t=Jc.get(e))&&(G("ComponentProvider","Removing Datastore"),Jc.delete(e),t.terminate()),Promise.resolve();var e,t}}]),e}();function ol(e,t,n){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=(e=rl(e,ul))._getSettings();if("firestore.googleapis.com"!==u.host&&u.host!==t&&j("Host has been set in both settings() and useEmulator(), emulator host will be used"),e._setSettings(Object.assign(Object.assign({},u),{host:"".concat(t,":").concat(n),ssl:!1})),i.mockUserToken){var o,s;if("string"==typeof i.mockUserToken)o=i.mockUserToken,s=V.MOCK_USER;else{o=(0,a.createMockUserToken)(i.mockUserToken,null===(r=e._app)||void 0===r?void 0:r.options.projectId);var c=i.mockUserToken.sub||i.mockUserToken.user_id;if(!c)throw new Z(J.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");s=new V(c)}e._authCredentials=new ne(new ee(o,s))}}var sl=function(){function e(t,n,r){P(this,e),this.converter=n,this._key=r,this.type="document",this.firestore=t}return L(e,[{key:"_path",get:function(){return this._key.path}},{key:"id",get:function(){return this._key.path.lastSegment()}},{key:"path",get:function(){return this._key.path.canonicalString()}},{key:"parent",get:function(){return new ll(this.firestore,this.converter,this._key.path.popLast())}},{key:"withConverter",value:function(t){return new e(this.firestore,t,this._key)}}]),e}();exports.DocumentReference=sl;var cl=function(){function e(t,n,r){P(this,e),this.converter=n,this._query=r,this.type="query",this.firestore=t}return L(e,[{key:"withConverter",value:function(t){return new e(this.firestore,t,this._query)}}]),e}();exports.Query=cl;var ll=function(e){g(n,cl);var t=w(n);function n(e,r,i){var a;return P(this,n),(a=t.call(this,e,r,_n(i)))._path=i,a.type="collection",a}return L(n,[{key:"id",get:function(){return this._query.path.lastSegment()}},{key:"path",get:function(){return this._query.path.canonicalString()}},{key:"parent",get:function(){var e=this._path.popLast();return e.isEmpty()?null:new sl(this.firestore,null,new we(e))}},{key:"withConverter",value:function(e){return new n(this.firestore,e,this._path)}}]),n}();function fl(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];if(e=(0,a.getModularInstance)(e),Zc("collection","path",t),e instanceof ul){var u=me.fromString.apply(me,[t].concat(r));return tl(u),new ll(e,null,u)}if(!(e instanceof sl||e instanceof ll))throw new Z(J.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");var o=e._path.child(me.fromString.apply(me,[t].concat(r)));return tl(o),new ll(e.firestore,null,o)}function hl(e,t){if(e=rl(e,ul),Zc("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new Z(J.INVALID_ARGUMENT,"Invalid collection ID '".concat(t,"' passed to function collectionGroup(). Collection IDs must not contain '/'."));return new cl(e,null,function(e){return new En(me.emptyPath(),e)}(t))}function dl(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];if(e=(0,a.getModularInstance)(e),1===arguments.length&&(t=le.R()),Zc("doc","path",t),e instanceof ul){var u=me.fromString.apply(me,[t].concat(r));return el(u),new sl(e,null,new we(u))}if(!(e instanceof sl||e instanceof ll))throw new Z(J.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");var o=e._path.child(me.fromString.apply(me,[t].concat(r)));return el(o),new sl(e.firestore,e instanceof ll?e.converter:null,new we(o))}function vl(e,t){return e=(0,a.getModularInstance)(e),t=(0,a.getModularInstance)(t),(e instanceof sl||e instanceof ll)&&(t instanceof sl||t instanceof ll)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter}function yl(e,t){return e=(0,a.getModularInstance)(e),t=(0,a.getModularInstance)(t),e instanceof cl&&t instanceof cl&&e.firestore===t.firestore&&Mn(e._query,t._query)&&e.converter===t.converter}exports.CollectionReference=ll;var pl=function(){function e(){var t=this;P(this,e),this.qc=Promise.resolve(),this.Uc=[],this.Kc=!1,this.Gc=[],this.Qc=null,this.jc=!1,this.zc=!1,this.Wc=[],this.ko=new qo(this,"async_queue_retry"),this.Hc=function(){var e=Oo();e&&G("AsyncQueue","Visibility state changed to "+e.visibilityState),t.ko.Vo()};var n=Oo();n&&"function"==typeof n.addEventListener&&n.addEventListener("visibilitychange",this.Hc)}return L(e,[{key:"isShuttingDown",get:function(){return this.Kc}},{key:"enqueueAndForget",value:function(e){this.enqueue(e)}},{key:"enqueueAndForgetEvenWhileRestricted",value:function(e){this.Jc(),this.Yc(e)}},{key:"enterRestrictedMode",value:function(e){if(!this.Kc){this.Kc=!0,this.zc=e||!1;var t=Oo();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Hc)}}},{key:"enqueue",value:function(e){var t=this;if(this.Jc(),this.Kc)return new Promise(function(){});var n=new $;return this.Yc(function(){return t.Kc&&t.zc?Promise.resolve():(e().then(n.resolve,n.reject),n.promise)}).then(function(){return n.promise})}},{key:"enqueueRetryable",value:function(e){var t=this;this.enqueueAndForget(function(){return t.Uc.push(e),t.Zc()})}},{key:"Zc",value:function(){var e=this;return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:if(0===this.Uc.length){t.next=14;break}return t.prev=1,t.next=4,m().awrap(this.Uc[0]());case 4:this.Uc.shift(),this.ko.reset(),t.next=13;break;case 8:if(t.prev=8,t.t0=t.catch(1),Ue(t.t0)){t.next=12;break}throw t.t0;case 12:G("AsyncQueue","Operation failed with retryable error: "+t.t0);case 13:this.Uc.length>0&&this.ko.vo(function(){return e.Zc()});case 14:case"end":return t.stop()}},null,this,[[1,8]],Promise)}},{key:"Yc",value:function(e){var t=this,n=this.qc.then(function(){return t.jc=!0,e().catch(function(e){throw t.Qc=e,t.jc=!1,Q("INTERNAL UNHANDLED ERROR: ",function(e){var t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}(e)),e}).then(function(e){return t.jc=!1,e})});return this.qc=n,n}},{key:"enqueueAfterDelay",value:function(e,t,n){var r=this;this.Jc(),this.Wc.indexOf(e)>-1&&(t=0);var i=xs.createAndSchedule(this,e,t,n,function(e){return r.Xc(e)});return this.Gc.push(i),i}},{key:"Jc",value:function(){this.Qc&&W()}},{key:"verifyOperationInProgress",value:function(){}},{key:"ta",value:function(){var e;return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.qc,t.next=3,m().awrap(e);case 3:if(e!==this.qc){t.next=0;break}case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"ea",value:function(e){var t,n=p(this.Gc);try{for(n.s();!(t=n.n()).done;){if(t.value.timerId===e)return!0}}catch(r){n.e(r)}finally{n.f()}return!1}},{key:"na",value:function(e){var t=this;return this.ta().then(function(){t.Gc.sort(function(e,t){return e.targetTimeMs-t.targetTimeMs});var n,r=p(t.Gc);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.skipDelay(),"all"!==e&&i.timerId===e)break}}catch(a){r.e(a)}finally{r.f()}return t.ta()})}},{key:"sa",value:function(e){this.Wc.push(e)}},{key:"Xc",value:function(e){var t=this.Gc.indexOf(e);this.Gc.splice(t,1)}}]),e}();function ml(e){return function(e,t){if("object"!=C(e)||null===e)return!1;var n,r=e,i=p(["next","error","complete"]);try{for(i.s();!(n=i.n()).done;){var a=n.value;if(a in r&&"function"==typeof r[a])return!0}}catch(u){i.e(u)}finally{i.f()}return!1}(e)}var gl=function(){function e(){P(this,e),this._progressObserver={},this._taskCompletionResolver=new $,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}return L(e,[{key:"onProgress",value:function(e,t,n){this._progressObserver={next:e,error:t,complete:n}}},{key:"catch",value:function(e){return this._taskCompletionResolver.promise.catch(e)}},{key:"then",value:function(e,t){return this._taskCompletionResolver.promise.then(e,t)}},{key:"_completeWith",value:function(e){this._updateProgress(e),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(e)}},{key:"_failWith",value:function(e){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(e),this._taskCompletionResolver.reject(e)}},{key:"_updateProgress",value:function(e){this._lastProgress=e,this._progressObserver.next&&this._progressObserver.next(e)}}]),e}();exports.LoadBundleTask=gl;var kl=-1;exports.CACHE_SIZE_UNLIMITED=kl;var wl=function(e){g(n,ul);var t=w(n);function n(e,r,i,a){var u;return P(this,n),(u=t.call(this,e,r,i,a)).type="firestore",u._queue=new pl,u._persistenceKey=(null==a?void 0:a.name)||"[DEFAULT]",u}return L(n,[{key:"_terminate",value:function(){return this._firestoreClient||Tl(this),this._firestoreClient.terminate()}}]),n}();function xl(e,t,r){r||(r="(default)");var i=(0,n._getProvider)(e,"firestore");if(i.isInitialized(r)){var u=i.getImmediate({identifier:r}),o=i.getOptions(r);if((0,a.deepEqual)(o,t))return u;throw new Z(J.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(void 0!==t.cacheSizeBytes&&-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new Z(J.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return i.initialize({options:t,instanceIdentifier:r})}function bl(e,t){var r="object"==C(e)?e:(0,n.getApp)(),i="string"==typeof e?e:t||"(default)",u=(0,n._getProvider)(r,"firestore").getImmediate({identifier:i});if(!u._initialized){var o=(0,a.getDefaultEmulatorHostnameAndPort)("firestore");o&&ol.apply(void 0,[u].concat(E(o)))}return u}function Il(e){return e._firestoreClient||Tl(e),e._firestoreClient.verifyNotTerminated(),e._firestoreClient}function Tl(e){var t,n=e._freezeSettings(),r=function(e,t,n,r){return new Je(e,t,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,r.useFetchStreams)}(e._databaseId,(null===(t=e._app)||void 0===t?void 0:t.options.appId)||"",e._persistenceKey,n);e._firestoreClient=new Cc(e._authCredentials,e._appCheckCredentials,e._queue,r)}function El(e,t){Rl(e=rl(e,wl));var n=Il(e),r=e._freezeSettings(),i=new Ec;return _l(n,i,new Ic(i,r.cacheSizeBytes,null==t?void 0:t.forceOwnership))}function Sl(e){Rl(e=rl(e,wl));var t=Il(e),n=e._freezeSettings(),r=new Ec;return _l(t,r,new Tc(r,n.cacheSizeBytes))}function _l(e,t,n){var r=new $;return e.asyncQueue.enqueue(function(){var i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,m().awrap(Pc(e,n));case 3:return a.next=5,m().awrap(Fc(e,t));case 5:r.resolve(),a.next=14;break;case 8:if(a.prev=8,a.t0=a.catch(0),function(e){return"FirebaseError"===e.name?e.code===J.FAILED_PRECONDITION||e.code===J.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&e instanceof DOMException)||(22===e.code||20===e.code||11===e.code)}(i=a.t0)){a.next=13;break}throw i;case 13:j("Error enabling offline persistence. Falling back to persistence disabled: "+i),r.reject(i);case 14:case"end":return a.stop()}},null,null,[[0,8]],Promise)}).then(function(){return r.promise})}function Al(e){if(e._initialized&&!e._terminated)throw new Z(J.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");var t=new $;return e._queue.enqueueAndForgetEvenWhileRestricted(function(){return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,m().awrap(function(e){var t;return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:if(Oe.C()){n.next=2;break}return n.abrupt("return",Promise.resolve());case 2:return t=e+"main",n.next=5,m().awrap(Oe.delete(t));case 5:case"end":return n.stop()}},null,null,null,Promise)}(Zu(e._databaseId,e._persistenceKey)));case 3:t.resolve(),n.next=9;break;case 6:n.prev=6,n.t0=n.catch(0),t.reject(n.t0);case 9:case"end":return n.stop()}},null,null,[[0,6]],Promise)}),t.promise}function Dl(e){return function(e){var t=new $;return e.asyncQueue.enqueueAndForget(function(){return m().async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.t0=$s,n.next=3,m().awrap(qc(e));case 3:return n.t1=n.sent,n.t2=t,n.abrupt("return",(0,n.t0)(n.t1,n.t2));case 6:case"end":return n.stop()}},null,null,null,Promise)}),t.promise}(Il(e=rl(e,wl)))}function Nl(e){return Kc(Il(e=rl(e,wl)))}function Cl(e){return Gc(Il(e=rl(e,wl)))}function Pl(e){return(0,n._removeServiceInstance)(e.app,"firestore",e._databaseId.database),e._delete()}function Fl(e,t){var n=Il(e=rl(e,wl)),r=new gl;return Xc(n,e._databaseId,t,r),r}function Ll(e,t){return Yc(Il(e=rl(e,wl)),t).then(function(t){return t?new cl(e,null,t.query):null})}function Rl(e){if(e._initialized||e._terminated)throw new Z(J.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}exports.Firestore=wl;var Ml=L(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"count",n=arguments.length>1?arguments[1]:void 0;P(this,e),this._aggregateType=t,this._internalFieldPath=n,this.type="AggregateField"});exports.AggregateField=Ml;var Ol=function(){function e(t,n,r){P(this,e),this._userDataWriter=n,this._data=r,this.type="AggregateQuerySnapshot",this.query=t}return L(e,[{key:"data",value:function(){return this._userDataWriter.convertValue(this._data.value)}}]),e}();exports.AggregateQuerySnapshot=Ol;var Vl=function(){function e(t){P(this,e),this._byteString=t}return L(e,[{key:"toBase64",value:function(){return this._byteString.toBase64()}},{key:"toUint8Array",value:function(){return this._byteString.toUint8Array()}},{key:"toString",value:function(){return"Bytes(base64: "+this.toBase64()+")"}},{key:"isEqual",value:function(e){return this._byteString.isEqual(e._byteString)}}],[{key:"fromBase64String",value:function(t){try{return new e(ot.fromBase64String(t))}catch(t){throw new Z(J.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}},{key:"fromUint8Array",value:function(t){return new e(ot.fromUint8Array(t))}}]),e}();exports.Bytes=Vl;var ql=function(){function e(){P(this,e);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var i=0;i<n.length;++i)if(0===n[i].length)throw new Z(J.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ke(n)}return L(e,[{key:"isEqual",value:function(e){return this._internalPath.isEqual(e._internalPath)}}]),e}();function Ul(){return new ql("__name__")}exports.FieldPath=ql;var Bl=L(function e(t){P(this,e),this._methodName=t});exports.FieldValue=Bl;var Kl=function(){function e(t,n){if(P(this,e),!isFinite(t)||t<-90||t>90)throw new Z(J.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(n)||n<-180||n>180)throw new Z(J.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+n);this._lat=t,this._long=n}return L(e,[{key:"latitude",get:function(){return this._lat}},{key:"longitude",get:function(){return this._long}},{key:"isEqual",value:function(e){return this._lat===e._lat&&this._long===e._long}},{key:"toJSON",value:function(){return{latitude:this._lat,longitude:this._long}}},{key:"_compareTo",value:function(e){return fe(this._lat,e._lat)||fe(this._long,e._long)}}]),e}();exports.GeoPoint=Kl;var Gl=/^__.*__$/,Ql=function(){function e(t,n,r){P(this,e),this.data=t,this.fieldMask=n,this.fieldTransforms=r}return L(e,[{key:"toMutation",value:function(e,t){return null!==this.fieldMask?new pr(e,this.data,this.fieldMask,t,this.fieldTransforms):new yr(e,this.data,t,this.fieldTransforms)}}]),e}(),jl=function(){function e(t,n,r){P(this,e),this.data=t,this.fieldMask=n,this.fieldTransforms=r}return L(e,[{key:"toMutation",value:function(e,t){return new pr(e,this.data,this.fieldMask,t,this.fieldTransforms)}}]),e}();function zl(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw W()}}var Wl=function(){function e(t,n,r,i,a,u){P(this,e),this.settings=t,this.databaseId=n,this.Tt=r,this.ignoreUndefinedProperties=i,void 0===a&&this.ia(),this.fieldTransforms=a||[],this.fieldMask=u||[]}return L(e,[{key:"path",get:function(){return this.settings.path}},{key:"ra",get:function(){return this.settings.ra}},{key:"oa",value:function(t){return new e(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.Tt,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}},{key:"ua",value:function(e){var t,n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.oa({path:n,ca:!1});return r.aa(e),r}},{key:"ha",value:function(e){var t,n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.oa({path:n,ca:!1});return r.ia(),r}},{key:"la",value:function(e){return this.oa({path:void 0,ca:!0})}},{key:"fa",value:function(e){return vf(e,this.settings.methodName,this.settings.da||!1,this.path,this.settings._a)}},{key:"contains",value:function(e){return void 0!==this.fieldMask.find(function(t){return e.isPrefixOf(t)})||void 0!==this.fieldTransforms.find(function(t){return e.isPrefixOf(t.field)})}},{key:"ia",value:function(){if(this.path)for(var e=0;e<this.path.length;e++)this.aa(this.path.get(e))}},{key:"aa",value:function(e){if(0===e.length)throw this.fa("Document fields must not be empty");if(zl(this.ra)&&Gl.test(e))throw this.fa('Document fields cannot begin and end with "__"')}}]),e}(),Hl=function(){function e(t,n,r){P(this,e),this.databaseId=t,this.ignoreUndefinedProperties=n,this.Tt=r||Vo(t)}return L(e,[{key:"wa",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return new Wl({ra:e,methodName:t,_a:n,path:ke.emptyPath(),ca:!1,da:r},this.databaseId,this.Tt,this.ignoreUndefinedProperties)}}]),e}();function Xl(e){var t=e._freezeSettings(),n=Vo(e._databaseId);return new Hl(e._databaseId,!!t.ignoreUndefinedProperties,n)}function Yl(e,t,n,r,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},u=e.wa(a.merge||a.mergeFields?2:0,t,n,i);lf("Data must be an object, but it was:",u,r);var o,s,c=sf(r,u);if(a.merge)o=new dn(u.fieldMask),s=u.fieldTransforms;else if(a.mergeFields){var l,f=[],h=p(a.mergeFields);try{for(h.s();!(l=h.n()).done;){var d=ff(t,l.value,n);if(!u.contains(d))throw new Z(J.INVALID_ARGUMENT,"Field '".concat(d,"' is specified in your field mask but missing from your input data."));yf(f,d)||f.push(d)}}catch(v){h.e(v)}finally{h.f()}o=new dn(f),s=u.fieldTransforms.filter(function(e){return o.covers(e.field)})}else o=null,s=u.fieldTransforms;return new Ql(new vn(c),o,s)}var Jl=function(e){g(n,Bl);var t=w(n);function n(){return P(this,n),t.apply(this,arguments)}return L(n,[{key:"_toFieldTransform",value:function(e){if(2!==e.ra)throw 1===e.ra?e.fa("".concat(this._methodName,"() can only appear at the top level of your update data")):e.fa("".concat(this._methodName,"() cannot be used with set() unless you pass {merge:true}"));return e.fieldMask.push(e.path),null}},{key:"isEqual",value:function(e){return e instanceof n}}]),n}();function Zl(e,t,n){return new Wl({ra:3,_a:t.settings._a,methodName:e._methodName,ca:n},t.databaseId,t.Tt,t.ignoreUndefinedProperties)}var $l=function(e){g(n,Bl);var t=w(n);function n(){return P(this,n),t.apply(this,arguments)}return L(n,[{key:"_toFieldTransform",value:function(e){return new ir(e.path,new Yn)}},{key:"isEqual",value:function(e){return e instanceof n}}]),n}(),ef=function(e){g(n,Bl);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this,e)).ma=r,i}return L(n,[{key:"_toFieldTransform",value:function(e){var t=Zl(this,e,!0),n=this.ma.map(function(e){return of(e,t)}),r=new Jn(n);return new ir(e.path,r)}},{key:"isEqual",value:function(e){return this===e}}]),n}(),tf=function(e){g(n,Bl);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this,e)).ma=r,i}return L(n,[{key:"_toFieldTransform",value:function(e){var t=Zl(this,e,!0),n=this.ma.map(function(e){return of(e,t)}),r=new $n(n);return new ir(e.path,r)}},{key:"isEqual",value:function(e){return this===e}}]),n}(),nf=function(e){g(n,Bl);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this,e)).ga=r,i}return L(n,[{key:"_toFieldTransform",value:function(e){var t=new tr(e.Tt,jn(e.Tt,this.ga));return new ir(e.path,t)}},{key:"isEqual",value:function(e){return this===e}}]),n}();function rf(e,t,n,r){var i=e.wa(1,t,n);lf("Data must be an object, but it was:",i,r);var u=[],o=vn.empty();et(r,function(e,r){var s=df(t,e,n);r=(0,a.getModularInstance)(r);var c=i.ha(s);if(r instanceof Jl)u.push(s);else{var l=of(r,c);null!=l&&(u.push(s),o.set(s,l))}});var s=new dn(u);return new jl(o,s,i.fieldTransforms)}function af(e,t,n,r,i,u){var o=e.wa(1,t,n),s=[ff(t,r,n)],c=[i];if(u.length%2!=0)throw new Z(J.INVALID_ARGUMENT,"Function ".concat(t,"() needs to be called with an even number of arguments that alternate between field names and values."));for(var l=0;l<u.length;l+=2)s.push(ff(t,u[l])),c.push(u[l+1]);for(var f=[],h=vn.empty(),d=s.length-1;d>=0;--d)if(!yf(f,s[d])){var v=s[d],y=c[d];y=(0,a.getModularInstance)(y);var p=o.ha(v);if(y instanceof Jl)f.push(v);else{var m=of(y,p);null!=m&&(f.push(v),h.set(v,m))}}var g=new dn(f);return new jl(h,g,o.fieldTransforms)}function uf(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return of(n,e.wa(r?4:3,t))}function of(e,t){if(cf(e=(0,a.getModularInstance)(e)))return lf("Unsupported field value:",t,e),sf(e,t);if(e instanceof Bl)return function(e,t){if(!zl(t.ra))throw t.fa("".concat(e._methodName,"() can only be used with update() and set()"));if(!t.path)throw t.fa("".concat(e._methodName,"() is not currently supported inside arrays"));var n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.ca&&4!==t.ra)throw t.fa("Nested arrays are not supported");return function(e,t){var n,r=[],i=0,a=p(e);try{for(a.s();!(n=a.n()).done;){var u=of(n.value,t.la(i));null==u&&(u={nullValue:"NULL_VALUE"}),r.push(u),i++}}catch(o){a.e(o)}finally{a.f()}return{arrayValue:{values:r}}}(e,t)}return function(e,t){if(null===(e=(0,a.getModularInstance)(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return jn(t.Tt,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){var n=ve.fromDate(e);return{timestampValue:ei(t.Tt,n)}}if(e instanceof ve){var r=new ve(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:ei(t.Tt,r)}}if(e instanceof Kl)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Vl)return{bytesValue:ti(t.Tt,e._byteString)};if(e instanceof sl){var i=t.databaseId,u=e.firestore._databaseId;if(!u.isEqual(i))throw t.fa("Document reference is for database ".concat(u.projectId,"/").concat(u.database," but should be for database ").concat(i.projectId,"/").concat(i.database));return{referenceValue:ii(e.firestore._databaseId||t.databaseId,e._key.path)}}throw t.fa("Unsupported field value: ".concat(nl(e)))}(e,t)}function sf(e,t){var n={};return tt(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):et(e,function(e,r){var i=of(r,t.ua(e));null!=i&&(n[e]=i)}),{mapValue:{fields:n}}}function cf(e){return!("object"!=C(e)||null===e||e instanceof Array||e instanceof Date||e instanceof ve||e instanceof Kl||e instanceof Vl||e instanceof sl||e instanceof Bl)}function lf(e,t,n){if(!cf(n)||!function(e){return"object"==C(e)&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}(n)){var r=nl(n);throw"an object"===r?t.fa(e+" a custom object"):t.fa(e+" "+r)}}function ff(e,t,n){if((t=(0,a.getModularInstance)(t))instanceof ql)return t._internalPath;if("string"==typeof t)return df(e,t);throw vf("Field path arguments must be of type string or ",e,!1,void 0,n)}var hf=new RegExp("[~\\*/\\[\\]]");function df(e,t,n){if(t.search(hf)>=0)throw vf("Invalid field path (".concat(t,"). Paths must not contain '~', '*', '/', '[', or ']'"),e,!1,void 0,n);try{return v(ql,E(t.split(".")))._internalPath}catch(r){throw vf("Invalid field path (".concat(t,"). Paths must not be empty, begin with '.', end with '.', or contain '..'"),e,!1,void 0,n)}}function vf(e,t,n,r,i){var a=r&&!r.isEmpty(),u=void 0!==i,o="Function ".concat(t,"() called with invalid data");n&&(o+=" (via `toFirestore()`)"),o+=". ";var s="";return(a||u)&&(s+=" (found",a&&(s+=" in field ".concat(r)),u&&(s+=" in document ".concat(i)),s+=")"),new Z(J.INVALID_ARGUMENT,o+e+s)}function yf(e,t){return e.some(function(e){return e.isEqual(t)})}var pf=function(){function e(t,n,r,i,a){P(this,e),this._firestore=t,this._userDataWriter=n,this._key=r,this._document=i,this._converter=a}return L(e,[{key:"id",get:function(){return this._key.path.lastSegment()}},{key:"ref",get:function(){return new sl(this._firestore,this._converter,this._key)}},{key:"exists",value:function(){return null!==this._document}},{key:"data",value:function(){if(this._document){if(this._converter){var e=new mf(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}},{key:"get",value:function(e){if(this._document){var t=this._document.data.field(gf("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}]),e}(),mf=function(e){g(n,pf);var t=w(n);function n(){return P(this,n),t.apply(this,arguments)}return L(n,[{key:"data",value:function(){return o(T(n.prototype),"data",this).call(this)}}]),n}();function gf(e,t){return"string"==typeof t?df(e,t):t instanceof ql?t._internalPath:t._delegate._internalPath}function kf(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new Z(J.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var wf=L(function e(){P(this,e)}),xf=function(e){g(n,wf);var t=w(n);function n(){return P(this,n),t.apply(this,arguments)}return L(n)}();function bf(e,t){for(var n=[],r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];t instanceof wf&&n.push(t),function(e){var t=e.filter(function(e){return e instanceof Ef}).length,n=e.filter(function(e){return e instanceof If}).length;if(t>1||t>0&&n>0)throw new Z(J.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(n=n.concat(i));var u,o=p(n);try{for(o.s();!(u=o.n()).done;){e=u.value._apply(e)}}catch(s){o.e(s)}finally{o.f()}return e}exports.QueryConstraint=xf;var If=function(e){g(n,xf);var t=w(n);function n(e,r,i){var a;return P(this,n),(a=t.call(this))._field=e,a._op=r,a._value=i,a.type="where",a}return L(n,[{key:"_apply",value:function(e){var t=this._parse(e);return Kf(e._query,t),new cl(e.firestore,e.converter,Ln(e._query,t))}},{key:"_parse",value:function(e){var t=Xl(e.firestore);return function(e,t,n,r,i,a,u){var o;if(i.isKeyField()){if("array-contains"===a||"array-contains-any"===a)throw new Z(J.INVALID_ARGUMENT,"Invalid Query. You can't perform '".concat(a,"' queries on documentId()."));if("in"===a||"not-in"===a){Bf(u,a);var s,c=[],l=p(u);try{for(l.s();!(s=l.n()).done;){var f=s.value;c.push(Uf(r,e,f))}}catch(h){l.e(h)}finally{l.f()}o={arrayValue:{values:c}}}else o=Uf(r,e,u)}else"in"!==a&&"not-in"!==a&&"array-contains-any"!==a||Bf(u,a),o=uf(n,"where",u,"in"===a||"not-in"===a);return Ut.create(i,a,o)}(e._query,0,t,e.firestore._databaseId,this._field,this._op,this._value)}}],[{key:"_create",value:function(e,t,r){return new n(e,t,r)}}]),n}();function Tf(e,t,n){var r=t,i=gf("where",e);return If._create(i,r,n)}exports.QueryFieldFilterConstraint=If;var Ef=function(e){g(n,wf);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this)).type=e,i._queryConstraints=r,i}return L(n,[{key:"_parse",value:function(e){var t=this._queryConstraints.map(function(t){return t._parse(e)}).filter(function(e){return e.getFilters().length>0});return 1===t.length?t[0]:Bt.create(t,this._getOperator())}},{key:"_apply",value:function(e){var t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){var n,r=e,i=p(t.getFlattenedFilters());try{for(i.s();!(n=i.n()).done;){var a=n.value;Kf(r,a),r=Ln(r,a)}}catch(u){i.e(u)}finally{i.f()}}(e._query,t),new cl(e.firestore,e.converter,Ln(e._query,t)))}},{key:"_getQueryConstraints",value:function(){return this._queryConstraints}},{key:"_getOperator",value:function(){return"and"===this.type?"and":"or"}}],[{key:"_create",value:function(e,t){return new n(e,t)}}]),n}();function Sf(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.forEach(function(e){return Qf("or",e)}),Ef._create("or",t)}function _f(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.forEach(function(e){return Qf("and",e)}),Ef._create("and",t)}exports.QueryCompositeFilterConstraint=Ef;var Af=function(e){g(n,xf);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this))._field=e,i._direction=r,i.type="orderBy",i}return L(n,[{key:"_apply",value:function(e){var t=function(e,t,n){if(null!==e.startAt)throw new Z(J.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new Z(J.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r=new an(t,n);return function(e,t){if(null===Dn(e)){var n=Nn(e);null!==n&&Gf(e,n,t.field)}}(e,r),r}(e._query,this._field,this._direction);return new cl(e.firestore,e.converter,function(e,t){var n=e.explicitOrderBy.concat([t]);return new En(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(e._query,t))}}],[{key:"_create",value:function(e,t){return new n(e,t)}}]),n}();function Df(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"asc",n=gf("orderBy",e);return Af._create(n,t)}exports.QueryOrderByConstraint=Af;var Nf=function(e){g(n,xf);var t=w(n);function n(e,r,i){var a;return P(this,n),(a=t.call(this)).type=e,a._limit=r,a._limitType=i,a}return L(n,[{key:"_apply",value:function(e){return new cl(e.firestore,e.converter,Rn(e._query,this._limit,this._limitType))}}],[{key:"_create",value:function(e,t,r){return new n(e,t,r)}}]),n}();function Cf(e){return il("limit",e),Nf._create("limit",e,"F")}function Pf(e){return il("limitToLast",e),Nf._create("limitToLast",e,"L")}exports.QueryLimitConstraint=Nf;var Ff=function(e){g(n,xf);var t=w(n);function n(e,r,i){var a;return P(this,n),(a=t.call(this)).type=e,a._docOrFields=r,a._inclusive=i,a}return L(n,[{key:"_apply",value:function(e){var t=qf(e,this.type,this._docOrFields,this._inclusive);return new cl(e.firestore,e.converter,function(e,t){return new En(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)}(e._query,t))}}],[{key:"_create",value:function(e,t,r){return new n(e,t,r)}}]),n}();function Lf(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ff._create("startAt",t,!0)}function Rf(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ff._create("startAfter",t,!1)}exports.QueryStartAtConstraint=Ff;var Mf=function(e){g(n,xf);var t=w(n);function n(e,r,i){var a;return P(this,n),(a=t.call(this)).type=e,a._docOrFields=r,a._inclusive=i,a}return L(n,[{key:"_apply",value:function(e){var t=qf(e,this.type,this._docOrFields,this._inclusive);return new cl(e.firestore,e.converter,function(e,t){return new En(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,t)}(e._query,t))}}],[{key:"_create",value:function(e,t,r){return new n(e,t,r)}}]),n}();function Of(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Mf._create("endBefore",t,!1)}function Vf(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Mf._create("endAt",t,!0)}function qf(e,t,n,r){if(n[0]=(0,a.getModularInstance)(n[0]),n[0]instanceof pf)return function(e,t,n,r,i){if(!r)throw new Z(J.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for ".concat(n,"()."));var a,u=[],o=p(Pn(e));try{for(o.s();!(a=o.n()).done;){var s=a.value;if(s.field.isKeyField())u.push(Tt(t,r.key));else{var c=r.data.field(s.field);if(ht(c))throw new Z(J.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+s.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===c){var l=s.field.canonicalString();throw new Z(J.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '".concat(l,"' (used as the orderBy) does not exist."))}u.push(c)}}}catch(f){o.e(f)}finally{o.f()}return new Mt(u,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);var i=Xl(e.firestore);return function(e,t,n,r,i,a){var u=e.explicitOrderBy;if(i.length>u.length)throw new Z(J.INVALID_ARGUMENT,"Too many arguments provided to ".concat(r,"(). The number of arguments must be less than or equal to the number of orderBy() clauses"));for(var o=[],s=0;s<i.length;s++){var c=i[s];if(u[s].field.isKeyField()){if("string"!=typeof c)throw new Z(J.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in ".concat(r,"(), but got a ").concat(C(c)));if(!Cn(e)&&-1!==c.indexOf("/"))throw new Z(J.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by documentId(), the value passed to ".concat(r,"() must be a plain document ID, but '").concat(c,"' contains a slash."));var l=e.path.child(me.fromString(c));if(!we.isDocumentKey(l))throw new Z(J.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by documentId(), the value passed to ".concat(r,"() must result in a valid document path, but '").concat(l,"' is not because it contains an odd number of segments."));var f=new we(l);o.push(Tt(t,f))}else{var h=uf(n,r,c);o.push(h)}}return new Mt(o,a)}(e._query,e.firestore._databaseId,i,t,n,r)}function Uf(e,t,n){if("string"==typeof(n=(0,a.getModularInstance)(n))){if(""===n)throw new Z(J.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Cn(t)&&-1!==n.indexOf("/"))throw new Z(J.INVALID_ARGUMENT,"Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '".concat(n,"' contains a '/' character."));var r=t.path.child(me.fromString(n));if(!we.isDocumentKey(r))throw new Z(J.INVALID_ARGUMENT,"Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '".concat(r,"' is not because it has an odd number of segments (").concat(r.length,")."));return Tt(e,new we(r))}if(n instanceof sl)return Tt(e,n._key);throw new Z(J.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ".concat(nl(n),"."))}function Bf(e,t){if(!Array.isArray(e)||0===e.length)throw new Z(J.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '".concat(t.toString(),"' filters."))}function Kf(e,t){if(t.isInequality()){var n=Nn(e),r=t.field;if(null!==n&&!n.isEqual(r))throw new Z(J.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '".concat(n.toString(),"' and '").concat(r.toString(),"'"));var i=Dn(e);null!==i&&Gf(e,r,i)}var a=function(e,t){var n,r=p(e);try{for(r.s();!(n=r.n()).done;){var i,a=p(n.value.getFlattenedFilters());try{for(a.s();!(i=a.n()).done;){var u=i.value;if(t.indexOf(u.op)>=0)return u.op}}catch(o){a.e(o)}finally{a.f()}}}catch(o){r.e(o)}finally{r.f()}return null}(e.filters,function(e){switch(t.op){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}());if(null!==a)throw a===t.op?new Z(J.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '".concat(t.op.toString(),"' filter.")):new Z(J.INVALID_ARGUMENT,"Invalid query. You cannot use '".concat(t.op.toString(),"' filters with '").concat(a.toString(),"' filters."))}function Gf(e,t,n){if(!n.isEqual(t))throw new Z(J.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '".concat(t.toString(),"' and so you must also use '").concat(t.toString(),"' as your first argument to orderBy(), but your first orderBy() is on field '").concat(n.toString(),"' instead."))}function Qf(e,t){if(!(t instanceof If||t instanceof Ef))throw new Z(J.INVALID_ARGUMENT,"Function ".concat(e,"() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'."))}exports.QueryEndAtConstraint=Mf;var jf=function(){function e(){P(this,e)}return L(e,[{key:"convertValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none";switch(mt(e)){case 0:return null;case 1:return e.booleanValue;case 2:return lt(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(ft(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 10:return this.convertObject(e.mapValue,t);default:throw W()}}},{key:"convertObject",value:function(e,t){var n=this,r={};return et(e.fields,function(e,i){r[e]=n.convertValue(i,t)}),r}},{key:"convertGeoPoint",value:function(e){return new Kl(lt(e.latitude),lt(e.longitude))}},{key:"convertArray",value:function(e,t){var n=this;return(e.values||[]).map(function(e){return n.convertValue(e,t)})}},{key:"convertServerTimestamp",value:function(e,t){switch(t){case"previous":var n=dt(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(vt(e));default:return null}}},{key:"convertTimestamp",value:function(e){var t=ct(e);return new ve(t.seconds,t.nanos)}},{key:"convertDocumentKey",value:function(e,t){var n=me.fromString(e);H(Ci(n));var r=new Ze(n.get(1),n.get(3)),i=new we(n.popFirst(5));return r.isEqual(t)||Q("Document ".concat(i," contains a document reference within a different database (").concat(r.projectId,"/").concat(r.database,") which is not supported. It will be treated as a reference in the current database (").concat(t.projectId,"/").concat(t.database,") instead.")),i}}]),e}();function zf(e,t,n){return e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t}exports.AbstractUserDataWriter=jf;var Wf=function(e){g(n,jf);var t=w(n);function n(e){var r;return P(this,n),(r=t.call(this)).firestore=e,r}return L(n,[{key:"convertBytes",value:function(e){return new Vl(e)}},{key:"convertReference",value:function(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new sl(this.firestore,null,t)}}]),n}();function Hf(e){return new Ml("sum",ff("sum",e))}function Xf(e){return new Ml("avg",ff("average",e))}function Yf(){return new Ml("count")}function Jf(e,t){var n,r;return e instanceof Ml&&t instanceof Ml&&e._aggregateType===t._aggregateType&&(null===(n=e._internalFieldPath)||void 0===n?void 0:n.canonicalString())===(null===(r=t._internalFieldPath)||void 0===r?void 0:r.canonicalString())}function Zf(e,t){return yl(e.query,t.query)&&(0,a.deepEqual)(e.data(),t.data())}var $f=function(){function e(t,n){P(this,e),this.hasPendingWrites=t,this.fromCache=n}return L(e,[{key:"isEqual",value:function(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}]),e}();exports.SnapshotMetadata=$f;var eh=function(e){g(n,pf);var t=w(n);function n(e,r,i,a,u,o){var s;return P(this,n),(s=t.call(this,e,r,i,a,o))._firestore=e,s._firestoreImpl=e,s.metadata=u,s}return L(n,[{key:"exists",value:function(){return o(T(n.prototype),"exists",this).call(this)}},{key:"data",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._document){if(this._converter){var t=new th(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._document){var n=this._document.data.field(gf("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}]),n}();exports.DocumentSnapshot=eh;var th=function(e){g(n,eh);var t=w(n);function n(){return P(this,n),t.apply(this,arguments)}return L(n,[{key:"data",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return o(T(n.prototype),"data",this).call(this,e)}}]),n}();exports.QueryDocumentSnapshot=th;var nh=function(){function e(t,n,r,i){P(this,e),this._firestore=t,this._userDataWriter=n,this._snapshot=i,this.metadata=new $f(i.hasPendingWrites,i.fromCache),this.query=r}return L(e,[{key:"docs",get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e}},{key:"size",get:function(){return this._snapshot.docs.size}},{key:"empty",get:function(){return 0===this.size}},{key:"forEach",value:function(e,t){var n=this;this._snapshot.docs.forEach(function(r){e.call(t,new th(n._firestore,n._userDataWriter,r.key,r,new $f(n._snapshot.mutatedKeys.has(r.key),n._snapshot.fromCache),n.query.converter))})}},{key:"docChanges",value:function(){var e=!!(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new Z(J.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){var n=0;return e._snapshot.docChanges.map(function(t){var r=new th(e._firestore,e._userDataWriter,t.doc.key,t.doc,new $f(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter);return t.doc,{type:"added",doc:r,oldIndex:-1,newIndex:n++}})}var r=e._snapshot.oldDocs;return e._snapshot.docChanges.filter(function(e){return t||3!==e.type}).map(function(t){var n=new th(e._firestore,e._userDataWriter,t.doc.key,t.doc,new $f(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,a=-1;return 0!==t.type&&(i=r.indexOf(t.doc.key),r=r.delete(t.doc.key)),1!==t.type&&(a=(r=r.add(t.doc)).indexOf(t.doc.key)),{type:rh(t.type),doc:n,oldIndex:i,newIndex:a}})}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}}]),e}();function rh(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return W()}}function ih(e,t){return e instanceof eh&&t instanceof eh?e._firestore===t._firestore&&e._key.isEqual(t._key)&&(null===e._document?null===t._document:e._document.isEqual(t._document))&&e._converter===t._converter:e instanceof nh&&t instanceof nh&&e._firestore===t._firestore&&yl(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)}function ah(e){e=rl(e,sl);var t=rl(e.firestore,wl);return jc(Il(t),e._key).then(function(n){return kh(t,e,n)})}exports.QuerySnapshot=nh;var uh=function(e){g(n,jf);var t=w(n);function n(e){var r;return P(this,n),(r=t.call(this)).firestore=e,r}return L(n,[{key:"convertBytes",value:function(e){return new Vl(e)}},{key:"convertReference",value:function(e){var t=this.convertDocumentKey(e,this.firestore._databaseId);return new sl(this.firestore,null,t)}}]),n}();function oh(e){e=rl(e,sl);var t=rl(e.firestore,wl),n=Il(t),r=new uh(t);return Qc(n,e._key).then(function(n){return new eh(t,r,e._key,n,new $f(null!==n&&n.hasLocalMutations,!0),e.converter)})}function sh(e){e=rl(e,sl);var t=rl(e.firestore,wl);return jc(Il(t),e._key,{source:"server"}).then(function(n){return kh(t,e,n)})}function ch(e){e=rl(e,cl);var t=rl(e.firestore,wl),n=Il(t),r=new uh(t);return kf(e._query),Wc(n,e._query).then(function(n){return new nh(t,r,e,n)})}function lh(e){e=rl(e,cl);var t=rl(e.firestore,wl),n=Il(t),r=new uh(t);return zc(n,e._query).then(function(n){return new nh(t,r,e,n)})}function fh(e){e=rl(e,cl);var t=rl(e.firestore,wl),n=Il(t),r=new uh(t);return Wc(n,e._query,{source:"server"}).then(function(n){return new nh(t,r,e,n)})}function hh(e,t,n){e=rl(e,sl);var r=rl(e.firestore,wl),i=zf(e.converter,t,n);return gh(r,[Yl(Xl(r),"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,or.none())])}function dh(e,t,n){e=rl(e,sl);for(var r=rl(e.firestore,wl),i=Xl(r),u=arguments.length,o=new Array(u>3?u-3:0),s=3;s<u;s++)o[s-3]=arguments[s];return gh(r,[("string"==typeof(t=(0,a.getModularInstance)(t))||t instanceof ql?af(i,"updateDoc",e._key,t,n,o):rf(i,"updateDoc",e._key,t)).toMutation(e._key,or.exists(!0))])}function vh(e){return gh(rl(e.firestore,wl),[new br(e._key,or.none())])}function yh(e,t){var n=rl(e.firestore,wl),r=dl(e),i=zf(e.converter,t);return gh(n,[Yl(Xl(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,or.exists(!1))]).then(function(){return r})}function ph(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i,u,o;e=(0,a.getModularInstance)(e);var s={includeMetadataChanges:!1},c=0;"object"!=C(n[c])||ml(n[c])||(s=n[c],c++);var l,f,h,d={includeMetadataChanges:s.includeMetadataChanges};if(ml(n[c])){var v=n[c];n[c]=null===(i=v.next)||void 0===i?void 0:i.bind(v),n[c+1]=null===(u=v.error)||void 0===u?void 0:u.bind(v),n[c+2]=null===(o=v.complete)||void 0===o?void 0:o.bind(v)}if(e instanceof sl)f=rl(e.firestore,wl),h=_n(e._key.path),l={next:function(t){n[c]&&n[c](kh(f,e,t))},error:n[c+1],complete:n[c+2]};else{var y=rl(e,cl);f=rl(y.firestore,wl),h=y._query;var p=new uh(f);l={next:function(e){n[c]&&n[c](new nh(f,p,y,e))},error:n[c+1],complete:n[c+2]},kf(e._query)}return function(e,t,n,r){var i=new _c(l),a=new Fs(t,i,n);return e.asyncQueue.enqueueAndForget(function(){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=As,t.next=3,m().awrap(Bc(e));case 3:return t.t1=t.sent,t.t2=a,t.abrupt("return",(0,t.t0)(t.t1,t.t2));case 6:case"end":return t.stop()}},null,null,null,Promise)}),function(){i.bc(),e.asyncQueue.enqueueAndForget(function(){return m().async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=Ds,t.next=3,m().awrap(Bc(e));case 3:return t.t1=t.sent,t.t2=a,t.abrupt("return",(0,t.t0)(t.t1,t.t2));case 6:case"end":return t.stop()}},null,null,null,Promise)})}}(Il(f),h,d)}function mh(e,t){return Hc(Il(e=rl(e,wl)),ml(t)?t:{next:t})}function gh(e,t){return function(e,t){var n=new $;return e.asyncQueue.enqueueAndForget(function(){return m().async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=Ws,r.next=3,m().awrap(qc(e));case 3:return r.t1=r.sent,r.t2=t,r.t3=n,r.abrupt("return",(0,r.t0)(r.t1,r.t2,r.t3));case 7:case"end":return r.stop()}},null,null,null,Promise)}),n.promise}(Il(e),t)}function kh(e,t,n){var r=n.docs.get(t._key),i=new uh(e);return new eh(e,i,t._key,r,new $f(n.hasPendingWrites,n.fromCache),t.converter)}function wh(e){return xh(e,{count:Yf()})}function xh(e,t){var n=rl(e.firestore,wl),r=Il(n),i=function(e,t){var n=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t(e[r],r));return n}(t,function(e,t){return new Ye(new Xe(t),e._aggregateType,e._internalFieldPath)});return function(e,t,n){var r=new $;return e.asyncQueue.enqueueAndForget(function(){var i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.t0=ts,a.next=4,m().awrap(Vc(e));case 4:if(a.t1=a.sent,!(0,a.t0)(a.t1)){a.next=12;break}return a.next=8,m().awrap(Uc(e));case 8:i=a.sent,r.resolve(Qo(i,t,n)),a.next=13;break;case 12:r.reject(new Z(J.UNAVAILABLE,"Failed to get aggregate result because the client is offline."));case 13:a.next=18;break;case 15:a.prev=15,a.t2=a.catch(0),r.reject(a.t2);case 18:case"end":return a.stop()}},null,null,[[0,15]],Promise)}),r.promise}(r,e._query,i).then(function(t){return function(e,t,n){var r=new uh(e);return new Ol(t,r,n)}(n,e,t)})}var bh={maxAttempts:5},Ih=function(){function e(t,n){P(this,e),this._firestore=t,this._commitHandler=n,this._mutations=[],this._committed=!1,this._dataReader=Xl(t)}return L(e,[{key:"set",value:function(e,t,n){this._verifyNotCommitted();var r=Th(e,this._firestore),i=zf(r.converter,t,n),a=Yl(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(a.toMutation(r._key,or.none())),this}},{key:"update",value:function(e,t,n){this._verifyNotCommitted();for(var r,i=Th(e,this._firestore),u=arguments.length,o=new Array(u>3?u-3:0),s=3;s<u;s++)o[s-3]=arguments[s];return r="string"==typeof(t=(0,a.getModularInstance)(t))||t instanceof ql?af(this._dataReader,"WriteBatch.update",i._key,t,n,o):rf(this._dataReader,"WriteBatch.update",i._key,t),this._mutations.push(r.toMutation(i._key,or.exists(!0))),this}},{key:"delete",value:function(e){this._verifyNotCommitted();var t=Th(e,this._firestore);return this._mutations=this._mutations.concat(new br(t._key,or.none())),this}},{key:"commit",value:function(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}},{key:"_verifyNotCommitted",value:function(){if(this._committed)throw new Z(J.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}]),e}();function Th(e,t){if((e=(0,a.getModularInstance)(e)).firestore!==t)throw new Z(J.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}exports.WriteBatch=Ih;var Eh=function(e){g(n,e);var t=w(n);function n(e,r){var i;return P(this,n),(i=t.call(this,e,r))._firestore=e,i}return L(n,[{key:"get",value:function(e){var t=this,r=Th(e,this._firestore),i=new uh(this._firestore);return o(T(n.prototype),"get",this).call(this,e).then(function(e){return new eh(t._firestore,i,r._key,e._document,new $f(!1,!1),r.converter)})}}]),n}(function(){function e(t,n){P(this,e),this._firestore=t,this._transaction=n,this._dataReader=Xl(t)}return L(e,[{key:"get",value:function(e){var t=this,n=Th(e,this._firestore),r=new Wf(this._firestore);return this._transaction.lookup([n._key]).then(function(e){if(!e||1!==e.length)return W();var i=e[0];if(i.isFoundDocument())return new pf(t._firestore,r,i.key,i,n.converter);if(i.isNoDocument())return new pf(t._firestore,r,n._key,null,n.converter);throw W()})}},{key:"set",value:function(e,t,n){var r=Th(e,this._firestore),i=zf(r.converter,t,n),a=Yl(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,a),this}},{key:"update",value:function(e,t,n){for(var r,i=Th(e,this._firestore),u=arguments.length,o=new Array(u>3?u-3:0),s=3;s<u;s++)o[s-3]=arguments[s];return r="string"==typeof(t=(0,a.getModularInstance)(t))||t instanceof ql?af(this._dataReader,"Transaction.update",i._key,t,n,o):rf(this._dataReader,"Transaction.update",i._key,t),this._transaction.update(i._key,r),this}},{key:"delete",value:function(e){var t=Th(e,this._firestore);return this._transaction.delete(t._key),this}}]),e}());function Sh(e,t,n){e=rl(e,wl);var r=Object.assign(Object.assign({},bh),n);return function(e){if(r.maxAttempts<1)throw new Z(J.INVALID_ARGUMENT,"Max attempts must be at least 1")}(),function(e,t,n){var r=new $;return e.asyncQueue.enqueueAndForget(function(){var i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,m().awrap(Uc(e));case 2:i=a.sent,new Nc(e.asyncQueue,i,n,t,r).run();case 4:case"end":return a.stop()}},null,null,null,Promise)}),r.promise}(Il(e),function(n){return t(new Eh(e,n))},r)}function _h(){return new Jl("deleteField")}function Ah(){return new $l("serverTimestamp")}function Dh(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return new ef("arrayUnion",t)}function Nh(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return new tf("arrayRemove",t)}function Ch(e){return new nf("increment",e)}function Ph(e){return Il(e=rl(e,wl)),new Ih(e,function(t){return gh(e,t)})}function Fh(e,t){var n,r=Il(e=rl(e,wl));if(!(null===(n=r.offlineComponents)||void 0===n?void 0:n.indexBackfillerScheduler))return j("Cannot enable indexes when persistence is disabled"),Promise.resolve();var i=function(e){var t="string"==typeof e?function(e){try{return JSON.parse(e)}catch(e){throw new Z(J.INVALID_ARGUMENT,"Failed to parse JSON: "+(null==e?void 0:e.message))}}(e):e,n=[];if(Array.isArray(t.indexes)){var r,i=p(t.indexes);try{for(i.s();!(r=i.n()).done;){var a=r.value,u=Lh(a,"collectionGroup"),o=[];if(Array.isArray(a.fields)){var s,c=p(a.fields);try{for(c.s();!(s=c.n()).done;){var l=s.value,f=df("setIndexConfiguration",Lh(l,"fieldPath"));"CONTAINS"===l.arrayConfig?o.push(new Ee(f,2)):"ASCENDING"===l.order?o.push(new Ee(f,0)):"DESCENDING"===l.order&&o.push(new Ee(f,1))}}catch(h){c.e(h)}finally{c.f()}}n.push(new xe(xe.UNKNOWN_ID,u,o,_e.empty()))}}catch(h){i.e(h)}finally{i.f()}}return n}(t);return Oc(r).then(function(e){return function(e,t){var n,r,i;return m().async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Y(e),r=n.indexManager,i=[],a.abrupt("return",n.persistence.runTransaction("Configure indexes","readwrite",function(e){return r.getFieldIndexes(e).next(function(n){return function(e,t,n,r,i){e=E(e),t=E(t),e.sort(n),t.sort(n);for(var a=e.length,u=t.length,o=0,s=0;o<u&&s<a;){var c=n(e[s],t[o]);c<0?i(e[s++]):c>0?r(t[o++]):(o++,s++)}for(;o<u;)r(t[o++]);for(;s<a;)i(e[s++])}(n,t,Te,function(t){i.push(r.addFieldIndex(e,t))},function(t){i.push(r.deleteFieldIndex(e,t))})}).next(function(){return Re.waitFor(i)})}));case 2:case"end":return a.stop()}},null,null,null,Promise)}(e,i)})}function Lh(e,t){if("string"!=typeof e[t])throw new Z(J.INVALID_ARGUMENT,"Missing string value for: "+t);return e[t]}exports.Transaction=Eh,function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];!function(e){q=e}(n.SDK_VERSION),(0,n._registerComponent)(new r.Component("firestore",function(e,n){var r=n.instanceIdentifier,i=n.options,a=e.getProvider("app").getImmediate(),u=new wl(new re(e.getProvider("auth-internal")),new oe(e.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new Z(J.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Ze(e.options.projectId,t)}(a,r),a);return i=Object.assign({useFetchStreams:t},i),u._setSettings(i),u},"PUBLIC").setMultipleInstances(!0)),(0,n.registerVersion)(O,"3.9.0",e),(0,n.registerVersion)(O,"3.9.0","esm2017")}();
|
|
508
|
+
},{"@firebase/app":"h2Mb","@firebase/component":"vhY9","@firebase/logger":"JJem","@firebase/util":"chA2","@firebase/webchannel-wrapper":"qQDx","process":"pBGv"}],"LeU4":[function(require,module,exports) {
|
|
509
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.registerFirestore=W;var e=n(require("@firebase/app-compat")),t=require("@firebase/firestore"),r=require("@firebase/util"),s=require("@firebase/component");function n(e){return e&&e.__esModule?e:{default:e}}const i="@firebase/firestore-compat",a="0.3.5";function o(e,r){if(void 0===r)return{merge:!1};if(void 0!==r.mergeFields&&void 0!==r.merge)throw new t.FirestoreError("invalid-argument",`Invalid options passed to function ${e}(): You cannot `+'specify both "merge" and "mergeFields".');return r}function l(){if("undefined"==typeof Uint8Array)throw new t.FirestoreError("unimplemented","Uint8Arrays are not available in this environment.")}function d(){if(!(0,t._isBase64Available)())throw new t.FirestoreError("unimplemented","Blobs are unavailable in Firestore in this environment.")}class c{constructor(e){this._delegate=e}static fromBase64String(e){return d(),new c(t.Bytes.fromBase64String(e))}static fromUint8Array(e){return l(),new c(t.Bytes.fromUint8Array(e))}toBase64(){return d(),this._delegate.toBase64()}toUint8Array(){return l(),this._delegate.toUint8Array()}isEqual(e){return this._delegate.isEqual(e._delegate)}toString(){return"Blob(base64: "+this.toBase64()+")"}}function h(e){return u(e,["next","error","complete"])}function u(e,t){if("object"!=typeof e||null===e)return!1;const r=e;for(const s of t)if(s in r&&"function"==typeof r[s])return!0;return!1}class g{enableIndexedDbPersistence(e,r){return(0,t.enableIndexedDbPersistence)(e._delegate,{forceOwnership:r})}enableMultiTabIndexedDbPersistence(e){return(0,t.enableMultiTabIndexedDbPersistence)(e._delegate)}clearIndexedDbPersistence(e){return(0,t.clearIndexedDbPersistence)(e._delegate)}}class _{constructor(e,r,s){this._delegate=r,this._persistenceProvider=s,this.INTERNAL={delete:()=>this.terminate()},e instanceof t._DatabaseId||(this._appCompat=e)}get _databaseId(){return this._delegate._databaseId}settings(e){const r=this._delegate._getSettings();e.merge||r.host===e.host||(0,t._logWarn)("You are overriding the original host. If you did not intend to override your settings, use {merge: true}."),e.merge&&delete(e=Object.assign(Object.assign({},r),e)).merge,this._delegate._setSettings(e)}useEmulator(e,r,s={}){(0,t.connectFirestoreEmulator)(this._delegate,e,r,s)}enableNetwork(){return(0,t.enableNetwork)(this._delegate)}disableNetwork(){return(0,t.disableNetwork)(this._delegate)}enablePersistence(e){let r=!1,s=!1;return e&&(r=!!e.synchronizeTabs,s=!!e.experimentalForceOwningTab,(0,t._validateIsNotUsedTogether)("synchronizeTabs",r,"experimentalForceOwningTab",s)),r?this._persistenceProvider.enableMultiTabIndexedDbPersistence(this):this._persistenceProvider.enableIndexedDbPersistence(this,s)}clearPersistence(){return this._persistenceProvider.clearIndexedDbPersistence(this)}terminate(){return this._appCompat&&(this._appCompat._removeServiceInstance("firestore-compat"),this._appCompat._removeServiceInstance("firestore")),this._delegate._delete()}waitForPendingWrites(){return(0,t.waitForPendingWrites)(this._delegate)}onSnapshotsInSync(e){return(0,t.onSnapshotsInSync)(this._delegate,e)}get app(){if(!this._appCompat)throw new t.FirestoreError("failed-precondition","Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._appCompat}collection(e){try{return new P(this,(0,t.collection)(this._delegate,e))}catch(r){throw b(r,"collection()","Firestore.collection()")}}doc(e){try{return new v(this,(0,t.doc)(this._delegate,e))}catch(r){throw b(r,"doc()","Firestore.doc()")}}collectionGroup(e){try{return new E(this,(0,t.collectionGroup)(this._delegate,e))}catch(r){throw b(r,"collectionGroup()","Firestore.collectionGroup()")}}runTransaction(e){return(0,t.runTransaction)(this._delegate,t=>e(new p(this,t)))}batch(){return(0,t.ensureFirestoreConfigured)(this._delegate),new w(new t.WriteBatch(this._delegate,e=>(0,t.executeWrite)(this._delegate,e)))}loadBundle(e){return(0,t.loadBundle)(this._delegate,e)}namedQuery(e){return(0,t.namedQuery)(this._delegate,e).then(e=>e?new E(this,e):null)}}class f extends t.AbstractUserDataWriter{constructor(e){super(),this.firestore=e}convertBytes(e){return new c(new t.Bytes(e))}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return v.forKey(t,this.firestore,null)}}function m(e){(0,t.setLogLevel)(e)}class p{constructor(e,t){this._firestore=e,this._delegate=t,this._userDataWriter=new f(e)}get(e){const r=x(e);return this._delegate.get(r).then(e=>new F(this._firestore,new t.DocumentSnapshot(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,r.converter)))}set(e,t,r){const s=x(e);return r?(o("Transaction.set",r),this._delegate.set(s,t,r)):this._delegate.set(s,t),this}update(e,t,r,...s){const n=x(e);return 2===arguments.length?this._delegate.update(n,t):this._delegate.update(n,t,r,...s),this}delete(e){const t=x(e);return this._delegate.delete(t),this}}class w{constructor(e){this._delegate=e}set(e,t,r){const s=x(e);return r?(o("WriteBatch.set",r),this._delegate.set(s,t,r)):this._delegate.set(s,t),this}update(e,t,r,...s){const n=x(e);return 2===arguments.length?this._delegate.update(n,t):this._delegate.update(n,t,r,...s),this}delete(e){const t=x(e);return this._delegate.delete(t),this}commit(){return this._delegate.commit()}}class y{constructor(e,t,r){this._firestore=e,this._userDataWriter=t,this._delegate=r}fromFirestore(e,r){const s=new t.QueryDocumentSnapshot(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,null);return this._delegate.fromFirestore(new S(this._firestore,s),null!=r?r:{})}toFirestore(e,t){return t?this._delegate.toFirestore(e,t):this._delegate.toFirestore(e)}static getInstance(e,t){const r=y.INSTANCES;let s=r.get(e);s||(s=new WeakMap,r.set(e,s));let n=s.get(t);return n||(n=new y(e,new f(e),t),s.set(t,n)),n}}y.INSTANCES=new WeakMap;class v{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new f(e)}static forPath(e,r,s){if(e.length%2!=0)throw new t.FirestoreError("invalid-argument","Invalid document reference. Document references must have an even number of segments, but "+`${e.canonicalString()} has ${e.length}`);return new v(r,new t.DocumentReference(r._delegate,s,new t._DocumentKey(e)))}static forKey(e,r,s){return new v(r,new t.DocumentReference(r._delegate,s,e))}get id(){return this._delegate.id}get parent(){return new P(this.firestore,this._delegate.parent)}get path(){return this._delegate.path}collection(e){try{return new P(this.firestore,(0,t.collection)(this._delegate,e))}catch(r){throw b(r,"collection()","DocumentReference.collection()")}}isEqual(e){return(e=(0,r.getModularInstance)(e))instanceof t.DocumentReference&&(0,t.refEqual)(this._delegate,e)}set(e,r){r=o("DocumentReference.set",r);try{return r?(0,t.setDoc)(this._delegate,e,r):(0,t.setDoc)(this._delegate,e)}catch(s){throw b(s,"setDoc()","DocumentReference.set()")}}update(e,r,...s){try{return 1===arguments.length?(0,t.updateDoc)(this._delegate,e):(0,t.updateDoc)(this._delegate,e,r,...s)}catch(n){throw b(n,"updateDoc()","DocumentReference.update()")}}delete(){return(0,t.deleteDoc)(this._delegate)}onSnapshot(...e){const r=D(e),s=I(e,e=>new F(this.firestore,new t.DocumentSnapshot(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)));return(0,t.onSnapshot)(this._delegate,r,s)}get(e){let r;return(r="cache"===(null==e?void 0:e.source)?(0,t.getDocFromCache)(this._delegate):"server"===(null==e?void 0:e.source)?(0,t.getDocFromServer)(this._delegate):(0,t.getDoc)(this._delegate)).then(e=>new F(this.firestore,new t.DocumentSnapshot(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)))}withConverter(e){return new v(this.firestore,e?this._delegate.withConverter(y.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function b(e,t,r){return e.message=e.message.replace(t,r),e}function D(e){for(const t of e)if("object"==typeof t&&!h(t))return t;return{}}function I(e,t){var r,s;let n;return{next:e=>{n.next&&n.next(t(e))},error:null===(r=(n=h(e[0])?e[0]:h(e[1])?e[1]:"function"==typeof e[0]?{next:e[0],error:e[1],complete:e[2]}:{next:e[1],error:e[2],complete:e[3]}).error)||void 0===r?void 0:r.bind(n),complete:null===(s=n.complete)||void 0===s?void 0:s.bind(n)}}class F{constructor(e,t){this._firestore=e,this._delegate=t}get ref(){return new v(this._firestore,this._delegate.ref)}get id(){return this._delegate.id}get metadata(){return this._delegate.metadata}get exists(){return this._delegate.exists()}data(e){return this._delegate.data(e)}get(e,t){return this._delegate.get(e,t)}isEqual(e){return(0,t.snapshotEqual)(this._delegate,e._delegate)}}class S extends F{data(e){const r=this._delegate.data(e);return(0,t._debugAssert)(void 0!==r,"Document in a QueryDocumentSnapshot should exist"),r}}class E{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new f(e)}where(e,r,s){try{return new E(this.firestore,(0,t.query)(this._delegate,(0,t.where)(e,r,s)))}catch(n){throw b(n,/(orderBy|where)\(\)/,"Query.$1()")}}orderBy(e,r){try{return new E(this.firestore,(0,t.query)(this._delegate,(0,t.orderBy)(e,r)))}catch(s){throw b(s,/(orderBy|where)\(\)/,"Query.$1()")}}limit(e){try{return new E(this.firestore,(0,t.query)(this._delegate,(0,t.limit)(e)))}catch(r){throw b(r,"limit()","Query.limit()")}}limitToLast(e){try{return new E(this.firestore,(0,t.query)(this._delegate,(0,t.limitToLast)(e)))}catch(r){throw b(r,"limitToLast()","Query.limitToLast()")}}startAt(...e){try{return new E(this.firestore,(0,t.query)(this._delegate,(0,t.startAt)(...e)))}catch(r){throw b(r,"startAt()","Query.startAt()")}}startAfter(...e){try{return new E(this.firestore,(0,t.query)(this._delegate,(0,t.startAfter)(...e)))}catch(r){throw b(r,"startAfter()","Query.startAfter()")}}endBefore(...e){try{return new E(this.firestore,(0,t.query)(this._delegate,(0,t.endBefore)(...e)))}catch(r){throw b(r,"endBefore()","Query.endBefore()")}}endAt(...e){try{return new E(this.firestore,(0,t.query)(this._delegate,(0,t.endAt)(...e)))}catch(r){throw b(r,"endAt()","Query.endAt()")}}isEqual(e){return(0,t.queryEqual)(this._delegate,e._delegate)}get(e){let r;return(r="cache"===(null==e?void 0:e.source)?(0,t.getDocsFromCache)(this._delegate):"server"===(null==e?void 0:e.source)?(0,t.getDocsFromServer)(this._delegate):(0,t.getDocs)(this._delegate)).then(e=>new C(this.firestore,new t.QuerySnapshot(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)))}onSnapshot(...e){const r=D(e),s=I(e,e=>new C(this.firestore,new t.QuerySnapshot(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)));return(0,t.onSnapshot)(this._delegate,r,s)}withConverter(e){return new E(this.firestore,e?this._delegate.withConverter(y.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}class q{constructor(e,t){this._firestore=e,this._delegate=t}get type(){return this._delegate.type}get doc(){return new S(this._firestore,this._delegate.doc)}get oldIndex(){return this._delegate.oldIndex}get newIndex(){return this._delegate.newIndex}}class C{constructor(e,t){this._firestore=e,this._delegate=t}get query(){return new E(this._firestore,this._delegate.query)}get metadata(){return this._delegate.metadata}get size(){return this._delegate.size}get empty(){return this._delegate.empty}get docs(){return this._delegate.docs.map(e=>new S(this._firestore,e))}docChanges(e){return this._delegate.docChanges(e).map(e=>new q(this._firestore,e))}forEach(e,t){this._delegate.forEach(r=>{e.call(t,new S(this._firestore,r))})}isEqual(e){return(0,t.snapshotEqual)(this._delegate,e._delegate)}}class P extends E{constructor(e,t){super(e,t),this.firestore=e,this._delegate=t}get id(){return this._delegate.id}get path(){return this._delegate.path}get parent(){const e=this._delegate.parent;return e?new v(this.firestore,e):null}doc(e){try{return new v(this.firestore,void 0===e?(0,t.doc)(this._delegate):(0,t.doc)(this._delegate,e))}catch(r){throw b(r,"doc()","CollectionReference.doc()")}}add(e){return(0,t.addDoc)(this._delegate,e).then(e=>new v(this.firestore,e))}isEqual(e){return(0,t.refEqual)(this._delegate,e._delegate)}withConverter(e){return new P(this.firestore,e?this._delegate.withConverter(y.getInstance(this.firestore,e)):this._delegate.withConverter(null))}}function x(e){return(0,t._cast)(e,t.DocumentReference)}class A{constructor(...e){this._delegate=new t.FieldPath(...e)}static documentId(){return new A(t._FieldPath.keyField().canonicalString())}isEqual(e){return(e=(0,r.getModularInstance)(e))instanceof t.FieldPath&&this._delegate._internalPath.isEqual(e._internalPath)}}class B{constructor(e){this._delegate=e}static serverTimestamp(){const e=(0,t.serverTimestamp)();return e._methodName="FieldValue.serverTimestamp",new B(e)}static delete(){const e=(0,t.deleteField)();return e._methodName="FieldValue.delete",new B(e)}static arrayUnion(...e){const r=(0,t.arrayUnion)(...e);return r._methodName="FieldValue.arrayUnion",new B(r)}static arrayRemove(...e){const r=(0,t.arrayRemove)(...e);return r._methodName="FieldValue.arrayRemove",new B(r)}static increment(e){const r=(0,t.increment)(e);return r._methodName="FieldValue.increment",new B(r)}isEqual(e){return this._delegate.isEqual(e._delegate)}}const T={Firestore:_,GeoPoint:t.GeoPoint,Timestamp:t.Timestamp,Blob:c,Transaction:p,WriteBatch:w,DocumentReference:v,DocumentSnapshot:F,Query:E,QueryDocumentSnapshot:S,QuerySnapshot:C,CollectionReference:P,FieldPath:A,FieldValue:B,setLogLevel:m,CACHE_SIZE_UNLIMITED:t.CACHE_SIZE_UNLIMITED};function N(e,t){e.INTERNAL.registerComponent(new s.Component("firestore-compat",e=>{const r=e.getProvider("app-compat").getImmediate(),s=e.getProvider("firestore").getImmediate();return t(r,s)},"PUBLIC").setServiceProps(Object.assign({},T)))}function W(e){N(e,(e,t)=>new _(e,t,new g)),e.registerVersion(i,a)}W(e.default);
|
|
510
|
+
},{"@firebase/app-compat":"CMFQ","@firebase/firestore":"lBbe","@firebase/util":"chA2","@firebase/component":"vhY9"}],"oDOu":[function(require,module,exports) {
|
|
511
|
+
"use strict";require("@firebase/firestore-compat");
|
|
512
|
+
},{"@firebase/firestore-compat":"LeU4"}],"TX5A":[function(require,module,exports) {
|
|
499
513
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.config=void 0,exports.config={apiKey:"AIzaSyB0TkZ83Fj0CIzn8AAmE-Osc92s3ER8hy8",authDomain:"neurosity-device.firebaseapp.com",databaseURL:"https://neurosity-device.firebaseio.com",projectId:"neurosity-device",storageBucket:"neurosity-device.appspot.com",messagingSenderId:"212595049674"};
|
|
500
514
|
},{}],"OERo":[function(require,module,exports) {
|
|
501
|
-
"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e){return
|
|
502
|
-
},{"firebase/app":"
|
|
503
|
-
"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t,r){return(t=h(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(){r=function(){return t};var t={},n=Object.prototype,i=n.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},u=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(L){f=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=t&&t.prototype instanceof v?t:v,o=Object.create(i.prototype),u=new T(n||[]);return a(o,"_invoke",{value:P(e,r,u)}),o}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(L){return{type:"throw",arg:L}}}t.wrap=l;var p={};function v(){}function d(){}function m(){}var y={};f(y,u,function(){return this});var b=Object.getPrototypeOf,g=b&&b(b(D([])));g&&g!==n&&i.call(g,u)&&(y=g);var w=m.prototype=v.prototype=Object.create(y);function x(e){["next","throw","return"].forEach(function(t){f(e,t,function(e){return this._invoke(t,e)})})}function k(t,r){var n;a(this,"_invoke",{value:function(a,o){function u(){return new r(function(n,u){!function n(a,o,u,c){var s=h(t[a],t,o);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==e(l)&&i.call(l,"__await")?r.resolve(l.__await).then(function(e){n("next",e,u,c)},function(e){n("throw",e,u,c)}):r.resolve(l).then(function(e){f.value=e,u(f)},function(e){return n("throw",e,u,c)})}c(s.arg)}(a,o,n,u)})}return n=n?n.then(u,u):u()}})}function P(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return I()}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var u=j(o,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=h(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function j(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,j(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var i=h(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,p;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function D(e){if(e){var t=e[u];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:I}}function I(){return{value:void 0,done:!0}}return d.prototype=m,a(w,"constructor",{value:m,configurable:!0}),a(m,"constructor",{value:d,configurable:!0}),d.displayName=f(m,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,f(e,s,"GeneratorFunction")),e.prototype=Object.create(w),e},t.awrap=function(e){return{__await:e}},x(k.prototype),f(k.prototype,c,function(){return this}),t.AsyncIterator=k,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new k(l(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then(function(e){return e.done?e.value:o.next()})},x(w),f(w,s,"Generator"),f(w,u,function(){return this}),f(w,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=D,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,p):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:D(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function n(e,t){return c(e)||u(e,t)||a(e,t)||i()}function i(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,u=[],c=!0,s=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(f){s=!0,i=f}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw i}}return u}}function c(e){if(Array.isArray(e))return e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,h(n.key),n)}}function l(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(t){var r=p(t,"string");return"symbol"===e(r)?r:String(r)}function p(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function v(e,t,r){return(v=d()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&m(i,r.prototype),i}).apply(null,arguments)}function d(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function m(e,t){return(m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var y=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{c(n.next(e))}catch(t){a(t)}}function u(e){try{c(n.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,u)}c((n=n.apply(e,t||[])).next())})},b=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FirebaseUser=exports.createUser=exports.credentialWithLink=void 0;var g=require("rxjs"),w=require("rxjs/operators"),x=b(require("firebase/app")),k=x.default.database.ServerValue.TIMESTAMP;function P(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return v(x.default.User,t)}exports.credentialWithLink=x.default.auth.EmailAuthProvider.credentialWithLink,exports.createUser=P;var j=function(){function e(t){var r=this;s(this,e),this.app=t.app,this.app.auth().onAuthStateChanged(function(e){r.user=e})}return l(e,[{key:"auth",value:function(){return this.app.auth()}},{key:"createAccount",value:function(e){return y(this,void 0,void 0,r().mark(function t(){var i,a,o,u,c,s;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return i=e.email,a=e.password,t.next=3,this.app.auth().createUserWithEmailAndPassword(i,a).then(function(e){return[null,e]}).catch(function(e){return[e,null]});case 3:if(o=t.sent,u=n(o,2),c=u[0],s=u[1],!c){t.next=9;break}return t.abrupt("return",Promise.reject(c));case 9:return t.abrupt("return",s);case 10:case"end":return t.stop()}},t,this)}))}},{key:"deleteAccount",value:function(){return y(this,void 0,void 0,r().mark(function e(){var t,i,a,o,u,c,s=this;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.app.auth().currentUser){e.next=3;break}return e.abrupt("return",Promise.reject(new Error("You are trying to delete an account that is not authenticated. To delete an account, the account must have signed in recently.")));case 3:return e.next=5,this.getDevices().then(function(e){return[null,e]}).catch(function(e){return[e,null]});case 5:if(i=e.sent,a=n(i,2),o=a[0],u=a[1],!o){e.next=11;break}return e.abrupt("return",Promise.reject(o));case 11:if(!u.length){e.next=17;break}return e.next=14,Promise.all(u.map(function(e){return s.removeDevice(e.deviceId)})).then(function(){return null}).catch(function(e){return e});case 14:if(!(c=e.sent)){e.next=17;break}return e.abrupt("return",Promise.reject(c));case 17:return e.abrupt("return",t.delete());case 18:case"end":return e.stop()}},e,this)}))}},{key:"onAuthStateChanged",value:function(){var e=this;return new g.Observable(function(t){try{e.app.auth().onAuthStateChanged(function(e){t.next(e)},function(e){t.error(e)})}catch(r){t.error(r)}})}},{key:"onLogin",value:function(){var e=this;return new g.Observable(function(t){var r=e.app.auth().onAuthStateChanged(function(e){e&&(t.next(e),t.complete())});return function(){return r()}})}},{key:"login",value:function(e){if("customToken"in e){var t=e.customToken;return this.app.auth().signInWithCustomToken(t)}if("idToken"in e&&"providerId"in e){var r=new x.default.auth.OAuthProvider(e.providerId).credential(e.idToken);return this.app.auth().signInWithCredential(r)}if("email"in e&&"password"in e){var n=e.email,i=e.password;return this.app.auth().signInWithEmailAndPassword(n,i)}throw new Error("Either {email,password}, {customToken}, or {idToken,providerId} is required")}},{key:"logout",value:function(){return this.app.auth().signOut()}},{key:"createCustomToken",value:function(){return y(this,void 0,void 0,r().mark(function e(){var t,i,a,o;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.app.functions().httpsCallable("createCustomToken")().then(function(e){return[null,e.data]}).catch(function(e){return[e,null]});case 2:if(t=e.sent,i=n(t,2),a=i[0],o=i[1],!a){e.next=8;break}return e.abrupt("return",Promise.reject(a));case 8:return e.abrupt("return",o);case 9:case"end":return e.stop()}},e,this)}))}},{key:"removeOAuthAccess",value:function(){var e;return y(this,void 0,void 0,r().mark(function t(){var i,a,o,u,c;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(null===(e=this.user)||void 0===e?void 0:e.uid){t.next=3;break}return t.abrupt("return",Promise.reject("OAuth access can only be removed while logged in via OAuth."));case 3:return t.next=5,this.app.functions().httpsCallable("removeAccessOAuthApp")().then(function(e){return[null,e.data]}).catch(function(e){return[e,null]});case 5:if(i=t.sent,a=n(i,2),o=a[0],u=a[1],!o){t.next=11;break}return t.abrupt("return",Promise.reject(o));case 11:return t.next=13,this.logout().then(function(){return!1}).catch(function(e){return e});case 13:if(!(c=t.sent)){t.next=16;break}return t.abrupt("return",Promise.reject(c));case 16:return t.abrupt("return",u);case 17:case"end":return t.stop()}},t,this)}))}},{key:"getDevices",value:function(){var e;return y(this,void 0,void 0,r().mark(function t(){var n,i;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(null===(e=this.user)||void 0===e?void 0:e.uid){t.next=3;break}return t.abrupt("return",Promise.reject("Please login."));case 3:return t.next=5,this.app.database().ref(this.getUserDevicesPath()).once("value");case 5:return n=t.sent,i=n.val(),t.abrupt("return",this.userDevicesToDeviceInfoList(i));case 8:case"end":return t.stop()}},t,this)}))}},{key:"addDevice",value:function(e){var i;return y(this,void 0,void 0,r().mark(function a(){var o,u,c,s,f,l,h,p,v,d,m,y,b;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(u=null===(i=this.user)||void 0===i?void 0:i.uid){r.next=3;break}return r.abrupt("return",Promise.reject("Please login."));case 3:return r.next=5,this.getDevices().catch(function(e){console.log(e)});case 5:if(c=r.sent,!(c&&c.length&&c.map(function(e){return e.deviceId}).includes(e))){r.next=9;break}return r.abrupt("return",Promise.reject("The device is already added to this account."));case 9:return r.next=11,this.isDeviceIdValid(e).then(function(e){return[e]}).catch(function(e){return[!1,e]});case 11:if(s=r.sent,f=n(s,2),l=f[0],h=f[1],l){r.next=17;break}return r.abrupt("return",Promise.reject(h));case 17:return p=this.getDeviceClaimedByPath(e),v=this.getUserClaimedDevicePath(e),r.next=21,this.app.database().ref().update((o={},t(o,p,u),t(o,v,{claimedOn:k}),o)).then(function(){return[!1]}).catch(function(e){return[!0,e]});case 21:if(d=r.sent,m=n(d,2),y=m[0],b=m[1],!y){r.next=27;break}return r.abrupt("return",Promise.reject(b));case 27:case"end":return r.stop()}},a,this)}))}},{key:"removeDevice",value:function(e){var t;return y(this,void 0,void 0,r().mark(function i(){var a,o,u,c,s,f,l,h;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(null===(t=this.user)||void 0===t?void 0:t.uid){r.next=3;break}return r.abrupt("return",Promise.reject("Please login."));case 3:return a=this.getDeviceClaimedByPath(e),o=this.getUserClaimedDevicePath(e),u=this.app.database().ref(a),c=this.app.database().ref(o),r.next=9,Promise.all([u.remove(),c.remove()]).then(function(){return[!1]}).catch(function(e){return[!0,e]});case 9:if(s=r.sent,f=n(s,2),l=f[0],h=f[1],!l){r.next=15;break}return r.abrupt("return",Promise.reject(h));case 15:case"end":return r.stop()}},i,this)}))}},{key:"transferDevice",value:function(e){var t;return y(this,void 0,void 0,r().mark(function i(){var a,o,u;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(null===(t=this.user)||void 0===t?void 0:t.uid){r.next=3;break}return r.abrupt("return",Promise.reject(new Error("transferDevice: auth is required.")));case 3:if("recipientsEmail"in e||"recipientsUserId"in e){r.next=5;break}return r.abrupt("return",Promise.reject(new Error("transferDevice: either 'recipientsEmail' or 'recipientsUserId' key is required.")));case 5:if(null==e?void 0:e.deviceId){r.next=7;break}return r.abrupt("return",Promise.reject(new Error("transferDevice: a deviceId is required.")));case 7:return r.next=9,this.app.functions().httpsCallable("transferDeviceOwnership")(e).then(function(e){return[null,e.data]}).catch(function(e){return[e,null]});case 9:if(a=r.sent,o=n(a,2),u=o[0],o[1],!u){r.next=15;break}return r.abrupt("return",Promise.reject(u));case 15:case"end":return r.stop()}},i,this)}))}},{key:"isDeviceIdValid",value:function(e){return y(this,void 0,void 0,r().mark(function t(){var n,i,a,o;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=/[0-9A-Fa-f]{32}/g,e&&32===e.length&&n.test(e)){t.next=3;break}return t.abrupt("return",Promise.reject("The device id is incorrectly formatted."));case 3:return i=this.getDeviceClaimedByPath(e),a=this.app.database().ref(i),t.next=7,a.once("value").catch(function(){return null});case 7:if((o=t.sent)&&!o.exists()){t.next=10;break}return t.abrupt("return",Promise.reject("The device has already been claimed."));case 10:return t.abrupt("return",!0);case 11:case"end":return t.stop()}},t,this)}))}},{key:"onUserDevicesChange",value:function(){var e=this;return this.onAuthStateChanged().pipe((0,w.switchMap)(function(t){if(!t)return g.EMPTY;var r=e.getUserDevicesPath(),i=e.app.database().ref(r);return(0,g.fromEventPattern)(function(e){return i.on("value",e)},function(e){return i.off("value",e)}).pipe((0,w.map)(function(e){return n(e,1)[0].val()}),(0,w.switchMap)(function(t){return(0,g.from)(e.userDevicesToDeviceInfoList(t))}))}))}},{key:"onUserClaimsChange",value:function(){var e=this;return this.onAuthStateChanged().pipe((0,w.switchMap)(function(t){if(!t)return g.EMPTY;var r=e.getUserClaimsUpdatedOnPath(),i=e.app.database().ref(r);return(0,g.fromEventPattern)(function(e){return i.on("value",e)},function(e){return i.off("value",e)}).pipe((0,w.map)(function(e){return n(e,1)[0].val()}),(0,w.switchMap)(function(){return(0,g.from)(e.getIdToken(!0)).pipe((0,w.switchMap)(function(){return(0,g.from)(e.getClaims())}))}))}))}},{key:"getIdToken",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return y(this,void 0,void 0,r().mark(function n(){var i;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(i=null===(e=this.app.auth())||void 0===e?void 0:e.currentUser){r.next=3;break}return r.abrupt("return",Promise.reject("getUserIdToken: unable to get currentUser"));case 3:return r.next=5,i.getIdToken(t).catch(function(e){console.error(e)});case 5:case"end":return r.stop()}},n,this)}))}},{key:"getClaims",value:function(){var e,t=null===(e=this.app.auth())||void 0===e?void 0:e.currentUser;return t?t.getIdTokenResult().then(function(e){return e.claims}).catch(function(e){return console.error(e),null}):Promise.reject("getUserClaims: unable to get currentUser")}},{key:"userDevicesToDeviceInfoList",value:function(e){return y(this,void 0,void 0,r().mark(function t(){var n,i,a,o=this;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.keys(null!=e?e:{}).map(function(e){return o.app.database().ref(o.getDeviceInfoPath(e)).once("value")}),t.next=3,Promise.all(n).then(function(e){return e.map(function(e){return e.val()})});case 3:return i=t.sent,(a=i.filter(function(e){return!!e})).sort(function(t,r){return e[t.deviceId].claimedOn-e[r.deviceId].claimedOn}),t.abrupt("return",a);case 7:case"end":return t.stop()}},t)}))}},{key:"hasDevicePermission",value:function(e){return y(this,void 0,void 0,r().mark(function t(){var n,i;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.getDeviceInfoPath(e),t.next=3,this.app.database().ref(n).once("value").then(function(){return!0}).catch(function(){return!1});case 3:return i=t.sent,t.abrupt("return",i);case 5:case"end":return t.stop()}},t,this)}))}},{key:"getDeviceClaimedByPath",value:function(e){return"devices/".concat(e,"/status/claimedBy")}},{key:"getUserClaimedDevicePath",value:function(e){var t=this.user.uid;return"users/".concat(t,"/devices/").concat(e)}},{key:"getUserDevicesPath",value:function(){var e=this.user.uid;return"users/".concat(e,"/devices")}},{key:"getUserClaimsUpdatedOnPath",value:function(){var e=this.user.uid;return"users/".concat(e,"/claimsUpdatedOn")}},{key:"getDeviceInfoPath",value:function(e){return"devices/".concat(e,"/info")}},{key:"onUserExperiments",value:function(){var e=this;return this.onAuthStateChanged().pipe((0,w.switchMap)(function(t){if(!t)return g.EMPTY;var r=e.user.uid,i=e.app.database().ref("experiments").orderByChild("userId").equalTo(r).limitToFirst(100);return(0,g.fromEventPattern)(function(e){return i.on("value",e)},function(e){return i.off("value",e)}).pipe((0,w.map)(function(e){return n(e,1)[0].val()}),(0,w.map)(function(e){return Object.entries(null!=e?e:{}).map(function(e){var t,r=n(e,2),i=r[0],a=r[1];return Object.assign({id:null!==(t=null==a?void 0:a.id)&&void 0!==t?t:i},a)}).sort(function(e,t){return new Date(null==t?void 0:t.timestamp).getTime()-new Date(null==e?void 0:e.timestamp).getTime()})}))}))}},{key:"deleteUserExperiment",value:function(e){return y(this,void 0,void 0,r().mark(function t(){var n,i,a=this;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return",Promise.reject("deleteUserExperiment: please provide an experiment id"));case 2:return n=function(e){return a.app.database().ref("experiments").child(e).remove()},i=function(e){return a.app.functions().httpsCallable("removeRelations")({experimentId:e})},t.next=6,Promise.all([n(e),i(e)]).catch(function(){});case 6:case"end":return t.stop()}},t)}))}}]),e}();exports.FirebaseUser=j;
|
|
504
|
-
},{"rxjs":"Zr8e","rxjs/operators":"v3iE","firebase/app":"
|
|
505
|
-
"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){return c(t)||i(t,e)||n(t,e)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,c,a=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(f){s=!0,o=f}finally{try{if(!u&&null!=r.return&&(c=r.return(),Object(c)!==c))return}finally{if(s)throw o}}return a}}function c(t){if(Array.isArray(t))return t}function a(){a=function(){return e};var e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(P){f=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof p?e:p,c=Object.create(i.prototype),a=new S(n||[]);return o(c,"_invoke",{value:E(t,r,a)}),c}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(P){return{type:"throw",arg:P}}}e.wrap=l;var v={};function p(){}function d(){}function y(){}var m={};f(m,c,function(){return this});var g=Object.getPrototypeOf,b=g&&g(g(k([])));b&&b!==r&&n.call(b,c)&&(m=b);var w=y.prototype=p.prototype=Object.create(m);function x(t){["next","throw","return"].forEach(function(e){f(t,e,function(t){return this._invoke(e,t)})})}function L(e,r){var i;o(this,"_invoke",{value:function(o,c){function a(){return new r(function(i,a){!function o(i,c,a,u){var s=h(e[i],e,c);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==t(l)&&n.call(l,"__await")?r.resolve(l.__await).then(function(t){o("next",t,a,u)},function(t){o("throw",t,a,u)}):r.resolve(l).then(function(t){f.value=t,a(f)},function(t){return o("throw",t,a,u)})}u(s.arg)}(o,c,i,a)})}return i=i?i.then(a,a):a()}})}function E(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return T()}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var a=_(c,r);if(a){if(a===v)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=h(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function _(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function k(t){if(t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return d.prototype=y,o(w,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:d,configurable:!0}),d.displayName=f(y,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,f(t,s,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},x(L.prototype),f(L.prototype,u,function(){return this}),e.AsyncIterator=L,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var c=new L(l(t,r,n,o),i);return e.isGeneratorFunction(r)?c:c.next().then(function(t){return t.done?t.value:c.next()})},x(w),f(w,s,"Generator"),f(w,c,function(){return this}),f(w,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=k,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return c.type="throw",c.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var a=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var c=i?i.completion:{};return c.type=t,c.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(c)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),v}},e}var u=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function c(t){try{u(n.next(t))}catch(e){i(e)}}function a(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(c,a)}u((n=n.apply(t,e||[])).next())})},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.createDeviceStore=void 0;var f=s(require("firebase/app")),l=f.default.database.ServerValue.TIMESTAMP,h=function(t,r,n){var o=t.database().ref("devices/".concat(r)),i=o.child("subscriptions").push().key,c=o.child("clients/".concat(i)),s=[],f=function(t,e){return o.child(t).set(e)},h=function(t,e){return o.child(t).update(e)},v=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"value",e=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,n=o.child(e).on(t,function(t){r(t.val(),t)});return s.push(function(){o.child(e).off(t,n)}),n},p=function(t,e,r){r?o.child(t).off(e,r):o.child(t).off(e)},d=t.database().ref(".info/connected").on("value",function(t){t.val()&&c.onDisconnect().remove().then(function(){c.set(l),h("subscriptions",n.get()).then(function(){n.toList().forEach(function(t){var e="subscriptions/".concat(t.id);o.child(e).onDisconnect().remove()})})})});return s.push(function(){t.database().ref(".info/connected").off("value",d)}),{set:f,once:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"value";return u(void 0,void 0,void 0,a().mark(function r(){var n;return a().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,o.child(t).once(e);case 2:return n=r.sent,r.abrupt("return",n.val());case 4:case"end":return r.stop()}},r)}))},update:h,lastOfChildValue:function(t,r,n){return u(void 0,void 0,void 0,a().mark(function i(){var c,u,s,f,l;return a().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,o.child(t).orderByChild(r).equalTo(n).limitToLast(1).once("value");case 2:return c=i.sent,u=c.val(),s=Object.values(u||{}),f=e(s,1),l=f[0],i.abrupt("return",l||null);case 6:case"end":return i.stop()}},i)}))},onNamespace:function(t,e){return v("value",t,function(t){e(t)})},offNamespace:function(t,e){p(t,"value",e)},dispatchAction:function(t){return u(void 0,void 0,void 0,a().mark(function e(){var r,n,i,c,u,s;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a="actions",f=t,o.child(a).push(f);case 2:if(r=e.sent,n=r.key,i="actions/".concat(n),r.onDisconnect().remove(),!t.responseRequired){e.next=11;break}return c=t.responseTimeout||6e5,u=new Promise(function(t,e){var n=setTimeout(function(){clearTimeout(n),r.remove(),e("Action response timed out in ".concat(c,"ms."))},c)}),s=new Promise(function(t){var e,r,n,o;e="value",r="".concat(i,"/response"),n=t,v(e,r,function(t){null!==t&&(p(r,e),n(o||t))})}),e.abrupt("return",Promise.race([s,u]));case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}var a,f},e)}))},nextMetric:function(t,e){return u(void 0,void 0,void 0,a().mark(function r(){return a().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:f("metrics/".concat(t),e);case 1:case"end":return r.stop()}},r)}))},onMetric:function(t,e){var r=t.atomic,n=t.metric,o=t.labels,i=r?"metrics/".concat(n):"metrics/".concat(n,"/").concat(o[0]);return v("value",i,function(t){null!==t&&e(t)})},subscribeToMetric:function(t){var e=o.child("subscriptions").push().key,r="subscriptions/".concat(e),n=Object.assign({id:e,clientId:i},t);return f(r,n),o.child(r).onDisconnect().remove(),n},unsubscribeFromMetric:function(t){var e;e="subscriptions/".concat(t.id),o.child(e).remove()},removeMetricListener:function(t,e){var r=t.atomic,n=t.metric,o=t.labels,i=r?"metrics/".concat(n):"metrics/".concat(n,"/").concat(o[0]);p(i,"value",e)},disconnect:function(){c.remove(),s.forEach(function(t){t()}),n.toList().filter(function(t){return t.clientId===i}).forEach(function(t){var e="subscriptions/".concat(t.id);o.child(e).remove()})}}};exports.createDeviceStore=h;
|
|
506
|
-
},{"firebase/app":"
|
|
507
|
-
"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){return a(t)||i(t,e)||n(t,e)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(f){s=!0,o=f}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}function a(t){if(Array.isArray(t))return t}function c(){c=function(){return e};var e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(M){f=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof p?e:p,a=Object.create(i.prototype),c=new O(n||[]);return o(a,"_invoke",{value:k(t,r,c)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(M){return{type:"throw",arg:M}}}e.wrap=l;var v={};function p(){}function d(){}function y(){}var m={};f(m,a,function(){return this});var b=Object.getPrototypeOf,g=b&&b(b(_([])));g&&g!==r&&n.call(g,a)&&(m=g);var w=y.prototype=p.prototype=Object.create(m);function x(t){["next","throw","return"].forEach(function(e){f(t,e,function(t){return this._invoke(e,t)})})}function S(e,r){var i;o(this,"_invoke",{value:function(o,a){function c(){return new r(function(i,c){!function o(i,a,c,u){var s=h(e[i],e,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==t(l)&&n.call(l,"__await")?r.resolve(l.__await).then(function(t){o("next",t,c,u)},function(t){o("throw",t,c,u)}):r.resolve(l).then(function(t){f.value=t,c(f)},function(t){return o("throw",t,c,u)})}u(s.arg)}(o,a,i,c)})}return i=i?i.then(c,c):c()}})}function k(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return T()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=L(a,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=h(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function L(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,L(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function _(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return d.prototype=y,o(w,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:d,configurable:!0}),d.displayName=f(y,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,f(t,s,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},x(S.prototype),f(S.prototype,u,function(){return this}),e.AsyncIterator=S,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new S(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},x(w),f(w,s,"Generator"),f(w,a,function(){return this}),f(w,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=_,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:_(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),v}},e}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function f(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(e){var r=h(e,"string");return"symbol"===t(r)?r:String(r)}function h(e,r){if("object"!==t(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,r||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}var v=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function a(t){try{u(n.next(t))}catch(e){i(e)}}function c(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,c)}u((n=n.apply(t,e||[])).next())})},p=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FirebaseDevice=void 0;var d=p(require("firebase/app")),y=require("./deviceStore"),m=d.default.database.ServerValue.TIMESTAMP,b=function(){function t(e){var r=e.deviceId,n=e.firebaseApp,o=e.dependencies;if(u(this,t),!r)throw new Error("No Device ID provided.");this.deviceId=r,this.app=n.app,this.deviceStore=(0,y.createDeviceStore)(this.app,r,o.subscriptionManager)}return f(t,[{key:"timestamp",get:function(){return m}},{key:"dispatchAction",value:function(t){return this.deviceStore.dispatchAction(t)}},{key:"getInfo",value:function(){return v(this,void 0,void 0,c().mark(function t(){return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.deviceStore.once("info");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t,this)}))}},{key:"onNamespace",value:function(t,e){return this.deviceStore.onNamespace(t,e)}},{key:"onceNamespace",value:function(t){return v(this,void 0,void 0,c().mark(function e(){return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deviceStore.once(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)}))}},{key:"offNamespace",value:function(t,e){this.deviceStore.offNamespace(t,e)}},{key:"getTimesync",value:function(){return v(this,void 0,void 0,c().mark(function t(){var e;return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dispatchAction({command:"timesync",action:"get",responseRequired:!0,responseTimeout:250});case 2:return e=t.sent,t.abrupt("return",e.timestamp);case 4:case"end":return t.stop()}},t,this)}))}},{key:"nextMetric",value:function(t,e){this.deviceStore.nextMetric(t,e)}},{key:"onMetric",value:function(t,e){return this.deviceStore.onMetric(t,e)}},{key:"subscribeToMetric",value:function(e){return this.deviceStore.subscribeToMetric(Object.assign(Object.assign({},e),{serverType:t.serverType}))}},{key:"unsubscribeFromMetric",value:function(t){this.deviceStore.unsubscribeFromMetric(t)}},{key:"removeMetricListener",value:function(t,e){this.deviceStore.removeMetricListener(t,e)}},{key:"changeSettings",value:function(t){return v(this,void 0,void 0,c().mark(function e(){return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceStore.update("settings",t));case 1:case"end":return e.stop()}},e,this)}))}},{key:"getSkill",value:function(t){return v(this,void 0,void 0,c().mark(function e(){return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deviceStore.lastOfChildValue("skills","bundleId",t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)}))}},{key:"createBluetoothToken",value:function(){var t;return v(this,void 0,void 0,c().mark(function r(){var n,o,i,a;return c().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.app.functions().httpsCallable("createBluetoothToken")({deviceId:this.deviceId}).then(function(t){var e=t.data;return[null,null==e?void 0:e.token]}).catch(function(t){return[t,null]});case 2:if(n=r.sent,o=e(n,2),i=o[0],a=o[1],!i){r.next=8;break}return r.abrupt("return",Promise.reject(null!==(t=null==i?void 0:i.message)&&void 0!==t?t:i));case 8:if(a){r.next=10;break}return r.abrupt("return",Promise.reject("Failed to create Bluetooth token."));case 10:return r.abrupt("return",a);case 11:case"end":return r.stop()}},r,this)}))}},{key:"disconnect",value:function(){this.deviceStore.disconnect()}}]),t}();exports.FirebaseDevice=b,b.serverType="firebase";
|
|
508
|
-
},{"firebase/app":"
|
|
515
|
+
"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e){return a(e)||o(e)||n(e)||r()}function r(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}function o(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function a(e){if(Array.isArray(e))return i(e)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,l(n.key),n)}}function f(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(t){var r=p(t,"string");return"symbol"===e(r)?r:String(r)}function p(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,r||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}var c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FirebaseApp=exports.SERVER_TIMESTAMP=void 0;var m=c(require("firebase/compat/app"));require("firebase/compat/database"),require("firebase/compat/auth"),require("firebase/compat/functions"),require("firebase/compat/firestore");var b=require("./config");exports.SERVER_TIMESTAMP=m.default.database.ServerValue.TIMESTAMP;var d=function(){function e(t){u(this,e),this.app=this.getApp(t.deviceId),this.standalone=this.app.name===t.deviceId,t.emulator&&this.connectEmulators(t)}return f(e,[{key:"getApp",value:function(e){var r=m.default.apps,n="undefined"!=typeof window&&"firebase"in window&&"apps"in window.firebase?window.firebase.apps:[],o=[].concat(t(r),t(n)).find(function(e){return"[DEFAULT]"===e.name&&e.options.databaseURL===b.config.databaseURL});if(o)return o;if(e){var a=e,i=r.find(function(e){return e.name===a});return i||m.default.initializeApp(b.config,a)}return m.default.initializeApp(b.config)}},{key:"connectEmulators",value:function(e){var t=e.emulatorHost,r=e.emulatorAuthPort,n=e.emulatorDatabasePort,o=e.emulatorFunctionsPort,a=e.emulatorFirestorePort,i=e.emulatorOptions;this.app.auth().useEmulator("http://".concat(t,":").concat(r)),this.app.database().useEmulator(t,n,i),this.app.functions().useEmulator(t,o),this.app.firestore().useEmulator(t,a,i)}},{key:"goOnline",value:function(){this.app.database().goOnline()}},{key:"goOffline",value:function(){this.app.database().goOffline()}},{key:"disconnect",value:function(){return this.standalone?this.app.delete():Promise.resolve()}}]),e}();exports.FirebaseApp=d;
|
|
516
|
+
},{"firebase/compat/app":"tq2Y","firebase/compat/database":"h3PO","firebase/compat/auth":"hycF","firebase/compat/functions":"O8Yj","firebase/compat/firestore":"oDOu","./config":"TX5A"}],"Cc51":[function(require,module,exports) {
|
|
517
|
+
"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t,r){return(t=h(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(){r=function(){return t};var t={},n=Object.prototype,i=n.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},u=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(L){f=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=t&&t.prototype instanceof v?t:v,o=Object.create(i.prototype),u=new T(n||[]);return a(o,"_invoke",{value:P(e,r,u)}),o}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(L){return{type:"throw",arg:L}}}t.wrap=l;var p={};function v(){}function d(){}function m(){}var y={};f(y,u,function(){return this});var b=Object.getPrototypeOf,g=b&&b(b(D([])));g&&g!==n&&i.call(g,u)&&(y=g);var w=m.prototype=v.prototype=Object.create(y);function x(e){["next","throw","return"].forEach(function(t){f(e,t,function(e){return this._invoke(t,e)})})}function k(t,r){var n;a(this,"_invoke",{value:function(a,o){function u(){return new r(function(n,u){!function n(a,o,u,c){var s=h(t[a],t,o);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==e(l)&&i.call(l,"__await")?r.resolve(l.__await).then(function(e){n("next",e,u,c)},function(e){n("throw",e,u,c)}):r.resolve(l).then(function(e){f.value=e,u(f)},function(e){return n("throw",e,u,c)})}c(s.arg)}(a,o,n,u)})}return n=n?n.then(u,u):u()}})}function P(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return I()}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var u=j(o,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=h(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function j(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,j(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var i=h(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,p;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function D(e){if(e){var t=e[u];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:I}}function I(){return{value:void 0,done:!0}}return d.prototype=m,a(w,"constructor",{value:m,configurable:!0}),a(m,"constructor",{value:d,configurable:!0}),d.displayName=f(m,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,f(e,s,"GeneratorFunction")),e.prototype=Object.create(w),e},t.awrap=function(e){return{__await:e}},x(k.prototype),f(k.prototype,c,function(){return this}),t.AsyncIterator=k,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new k(l(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then(function(e){return e.done?e.value:o.next()})},x(w),f(w,s,"Generator"),f(w,u,function(){return this}),f(w,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=D,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,p):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:D(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function n(e,t){return c(e)||u(e,t)||a(e,t)||i()}function i(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,u=[],c=!0,s=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(f){s=!0,i=f}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw i}}return u}}function c(e){if(Array.isArray(e))return e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,h(n.key),n)}}function l(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(t){var r=p(t,"string");return"symbol"===e(r)?r:String(r)}function p(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function v(e,t,r){return(v=d()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&m(i,r.prototype),i}).apply(null,arguments)}function d(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function m(e,t){return(m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var y=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{c(n.next(e))}catch(t){a(t)}}function u(e){try{c(n.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,u)}c((n=n.apply(e,t||[])).next())})},b=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FirebaseUser=exports.createUser=exports.credentialWithLink=void 0;var g=require("rxjs"),w=require("rxjs/operators"),x=b(require("firebase/compat/app")),k=x.default.database.ServerValue.TIMESTAMP;function P(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return v(x.default.User,t)}exports.credentialWithLink=x.default.auth.EmailAuthProvider.credentialWithLink,exports.createUser=P;var j=function(){function e(t){var r=this;s(this,e),this.app=t.app,this.app.auth().onAuthStateChanged(function(e){r.user=e})}return l(e,[{key:"auth",value:function(){return this.app.auth()}},{key:"createAccount",value:function(e){return y(this,void 0,void 0,r().mark(function t(){var i,a,o,u,c,s;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return i=e.email,a=e.password,t.next=3,this.app.auth().createUserWithEmailAndPassword(i,a).then(function(e){return[null,e]}).catch(function(e){return[e,null]});case 3:if(o=t.sent,u=n(o,2),c=u[0],s=u[1],!c){t.next=9;break}return t.abrupt("return",Promise.reject(c));case 9:return t.abrupt("return",s);case 10:case"end":return t.stop()}},t,this)}))}},{key:"deleteAccount",value:function(){return y(this,void 0,void 0,r().mark(function e(){var t,i,a,o,u,c,s=this;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.app.auth().currentUser){e.next=3;break}return e.abrupt("return",Promise.reject(new Error("You are trying to delete an account that is not authenticated. To delete an account, the account must have signed in recently.")));case 3:return e.next=5,this.getDevices().then(function(e){return[null,e]}).catch(function(e){return[e,null]});case 5:if(i=e.sent,a=n(i,2),o=a[0],u=a[1],!o){e.next=11;break}return e.abrupt("return",Promise.reject(o));case 11:if(!u.length){e.next=17;break}return e.next=14,Promise.all(u.map(function(e){return s.removeDevice(e.deviceId)})).then(function(){return null}).catch(function(e){return e});case 14:if(!(c=e.sent)){e.next=17;break}return e.abrupt("return",Promise.reject(c));case 17:return e.abrupt("return",t.delete());case 18:case"end":return e.stop()}},e,this)}))}},{key:"onAuthStateChanged",value:function(){var e=this;return new g.Observable(function(t){try{e.app.auth().onAuthStateChanged(function(e){t.next(e)},function(e){t.error(e)})}catch(r){t.error(r)}})}},{key:"onLogin",value:function(){var e=this;return new g.Observable(function(t){var r=e.app.auth().onAuthStateChanged(function(e){e&&(t.next(e),t.complete())});return function(){return r()}})}},{key:"login",value:function(e){if("customToken"in e){var t=e.customToken;return this.app.auth().signInWithCustomToken(t)}if("idToken"in e&&"providerId"in e){var r=new x.default.auth.OAuthProvider(e.providerId).credential(e.idToken);return this.app.auth().signInWithCredential(r)}if("email"in e&&"password"in e){var n=e.email,i=e.password;return this.app.auth().signInWithEmailAndPassword(n,i)}throw new Error("Either {email,password}, {customToken}, or {idToken,providerId} is required")}},{key:"logout",value:function(){return this.app.auth().signOut()}},{key:"createCustomToken",value:function(){return y(this,void 0,void 0,r().mark(function e(){var t,i,a,o;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.app.functions().httpsCallable("createCustomToken")().then(function(e){return[null,e.data]}).catch(function(e){return[e,null]});case 2:if(t=e.sent,i=n(t,2),a=i[0],o=i[1],!a){e.next=8;break}return e.abrupt("return",Promise.reject(a));case 8:return e.abrupt("return",o);case 9:case"end":return e.stop()}},e,this)}))}},{key:"removeOAuthAccess",value:function(){var e;return y(this,void 0,void 0,r().mark(function t(){var i,a,o,u,c;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(null===(e=this.user)||void 0===e?void 0:e.uid){t.next=3;break}return t.abrupt("return",Promise.reject("OAuth access can only be removed while logged in via OAuth."));case 3:return t.next=5,this.app.functions().httpsCallable("removeAccessOAuthApp")().then(function(e){return[null,e.data]}).catch(function(e){return[e,null]});case 5:if(i=t.sent,a=n(i,2),o=a[0],u=a[1],!o){t.next=11;break}return t.abrupt("return",Promise.reject(o));case 11:return t.next=13,this.logout().then(function(){return!1}).catch(function(e){return e});case 13:if(!(c=t.sent)){t.next=16;break}return t.abrupt("return",Promise.reject(c));case 16:return t.abrupt("return",u);case 17:case"end":return t.stop()}},t,this)}))}},{key:"getDevices",value:function(){var e;return y(this,void 0,void 0,r().mark(function t(){var n,i;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(null===(e=this.user)||void 0===e?void 0:e.uid){t.next=3;break}return t.abrupt("return",Promise.reject("Please login."));case 3:return t.next=5,this.app.database().ref(this.getUserDevicesPath()).once("value");case 5:return n=t.sent,i=n.val(),t.abrupt("return",this.userDevicesToDeviceInfoList(i));case 8:case"end":return t.stop()}},t,this)}))}},{key:"addDevice",value:function(e){var i;return y(this,void 0,void 0,r().mark(function a(){var o,u,c,s,f,l,h,p,v,d,m,y,b;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(u=null===(i=this.user)||void 0===i?void 0:i.uid){r.next=3;break}return r.abrupt("return",Promise.reject("Please login."));case 3:return r.next=5,this.getDevices().catch(function(e){console.log(e)});case 5:if(c=r.sent,!(c&&c.length&&c.map(function(e){return e.deviceId}).includes(e))){r.next=9;break}return r.abrupt("return",Promise.reject("The device is already added to this account."));case 9:return r.next=11,this.isDeviceIdValid(e).then(function(e){return[e]}).catch(function(e){return[!1,e]});case 11:if(s=r.sent,f=n(s,2),l=f[0],h=f[1],l){r.next=17;break}return r.abrupt("return",Promise.reject(h));case 17:return p=this.getDeviceClaimedByPath(e),v=this.getUserClaimedDevicePath(e),r.next=21,this.app.database().ref().update((o={},t(o,p,u),t(o,v,{claimedOn:k}),o)).then(function(){return[!1]}).catch(function(e){return[!0,e]});case 21:if(d=r.sent,m=n(d,2),y=m[0],b=m[1],!y){r.next=27;break}return r.abrupt("return",Promise.reject(b));case 27:case"end":return r.stop()}},a,this)}))}},{key:"removeDevice",value:function(e){var t;return y(this,void 0,void 0,r().mark(function i(){var a,o,u,c,s,f,l,h;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(null===(t=this.user)||void 0===t?void 0:t.uid){r.next=3;break}return r.abrupt("return",Promise.reject("Please login."));case 3:return a=this.getDeviceClaimedByPath(e),o=this.getUserClaimedDevicePath(e),u=this.app.database().ref(a),c=this.app.database().ref(o),r.next=9,Promise.all([u.remove(),c.remove()]).then(function(){return[!1]}).catch(function(e){return[!0,e]});case 9:if(s=r.sent,f=n(s,2),l=f[0],h=f[1],!l){r.next=15;break}return r.abrupt("return",Promise.reject(h));case 15:case"end":return r.stop()}},i,this)}))}},{key:"transferDevice",value:function(e){var t;return y(this,void 0,void 0,r().mark(function i(){var a,o,u;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(null===(t=this.user)||void 0===t?void 0:t.uid){r.next=3;break}return r.abrupt("return",Promise.reject(new Error("transferDevice: auth is required.")));case 3:if("recipientsEmail"in e||"recipientsUserId"in e){r.next=5;break}return r.abrupt("return",Promise.reject(new Error("transferDevice: either 'recipientsEmail' or 'recipientsUserId' key is required.")));case 5:if(null==e?void 0:e.deviceId){r.next=7;break}return r.abrupt("return",Promise.reject(new Error("transferDevice: a deviceId is required.")));case 7:return r.next=9,this.app.functions().httpsCallable("transferDeviceOwnership")(e).then(function(e){return[null,e.data]}).catch(function(e){return[e,null]});case 9:if(a=r.sent,o=n(a,2),u=o[0],o[1],!u){r.next=15;break}return r.abrupt("return",Promise.reject(u));case 15:case"end":return r.stop()}},i,this)}))}},{key:"isDeviceIdValid",value:function(e){return y(this,void 0,void 0,r().mark(function t(){var n,i,a,o;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=/[0-9A-Fa-f]{32}/g,e&&32===e.length&&n.test(e)){t.next=3;break}return t.abrupt("return",Promise.reject("The device id is incorrectly formatted."));case 3:return i=this.getDeviceClaimedByPath(e),a=this.app.database().ref(i),t.next=7,a.once("value").catch(function(){return null});case 7:if((o=t.sent)&&!o.exists()){t.next=10;break}return t.abrupt("return",Promise.reject("The device has already been claimed."));case 10:return t.abrupt("return",!0);case 11:case"end":return t.stop()}},t,this)}))}},{key:"onUserDevicesChange",value:function(){var e=this;return this.onAuthStateChanged().pipe((0,w.switchMap)(function(t){if(!t)return g.EMPTY;var r=e.getUserDevicesPath(),i=e.app.database().ref(r);return(0,g.fromEventPattern)(function(e){return i.on("value",e)},function(e){return i.off("value",e)}).pipe((0,w.map)(function(e){return n(e,1)[0].val()}),(0,w.switchMap)(function(t){return(0,g.from)(e.userDevicesToDeviceInfoList(t))}))}))}},{key:"onUserClaimsChange",value:function(){var e=this;return this.onAuthStateChanged().pipe((0,w.switchMap)(function(t){if(!t)return g.EMPTY;var r=e.getUserClaimsUpdatedOnPath(),i=e.app.database().ref(r);return(0,g.fromEventPattern)(function(e){return i.on("value",e)},function(e){return i.off("value",e)}).pipe((0,w.map)(function(e){return n(e,1)[0].val()}),(0,w.switchMap)(function(){return(0,g.from)(e.getIdToken(!0)).pipe((0,w.switchMap)(function(){return(0,g.from)(e.getClaims())}))}))}))}},{key:"getIdToken",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return y(this,void 0,void 0,r().mark(function n(){var i;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(i=null===(e=this.app.auth())||void 0===e?void 0:e.currentUser){r.next=3;break}return r.abrupt("return",Promise.reject("getUserIdToken: unable to get currentUser"));case 3:return r.next=5,i.getIdToken(t).catch(function(e){console.error(e)});case 5:case"end":return r.stop()}},n,this)}))}},{key:"getClaims",value:function(){var e,t=null===(e=this.app.auth())||void 0===e?void 0:e.currentUser;return t?t.getIdTokenResult().then(function(e){return e.claims}).catch(function(e){return console.error(e),null}):Promise.reject("getUserClaims: unable to get currentUser")}},{key:"userDevicesToDeviceInfoList",value:function(e){return y(this,void 0,void 0,r().mark(function t(){var n,i,a,o=this;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=Object.keys(null!=e?e:{}).map(function(e){return o.app.database().ref(o.getDeviceInfoPath(e)).once("value")}),t.next=3,Promise.all(n).then(function(e){return e.map(function(e){return e.val()})});case 3:return i=t.sent,(a=i.filter(function(e){return!!e})).sort(function(t,r){return e[t.deviceId].claimedOn-e[r.deviceId].claimedOn}),t.abrupt("return",a);case 7:case"end":return t.stop()}},t)}))}},{key:"hasDevicePermission",value:function(e){return y(this,void 0,void 0,r().mark(function t(){var n,i;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.getDeviceInfoPath(e),t.next=3,this.app.database().ref(n).once("value").then(function(){return!0}).catch(function(){return!1});case 3:return i=t.sent,t.abrupt("return",i);case 5:case"end":return t.stop()}},t,this)}))}},{key:"getDeviceClaimedByPath",value:function(e){return"devices/".concat(e,"/status/claimedBy")}},{key:"getUserClaimedDevicePath",value:function(e){var t=this.user.uid;return"users/".concat(t,"/devices/").concat(e)}},{key:"getUserDevicesPath",value:function(){var e=this.user.uid;return"users/".concat(e,"/devices")}},{key:"getUserClaimsUpdatedOnPath",value:function(){var e=this.user.uid;return"users/".concat(e,"/claimsUpdatedOn")}},{key:"getDeviceInfoPath",value:function(e){return"devices/".concat(e,"/info")}},{key:"onUserExperiments",value:function(){var e=this;return this.onAuthStateChanged().pipe((0,w.switchMap)(function(t){if(!t)return g.EMPTY;var r=e.user.uid,i=e.app.database().ref("experiments").orderByChild("userId").equalTo(r).limitToFirst(100);return(0,g.fromEventPattern)(function(e){return i.on("value",e)},function(e){return i.off("value",e)}).pipe((0,w.map)(function(e){return n(e,1)[0].val()}),(0,w.map)(function(e){return Object.entries(null!=e?e:{}).map(function(e){var t,r=n(e,2),i=r[0],a=r[1];return Object.assign({id:null!==(t=null==a?void 0:a.id)&&void 0!==t?t:i},a)}).sort(function(e,t){return new Date(null==t?void 0:t.timestamp).getTime()-new Date(null==e?void 0:e.timestamp).getTime()})}))}))}},{key:"deleteUserExperiment",value:function(e){return y(this,void 0,void 0,r().mark(function t(){var n,i,a=this;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return",Promise.reject("deleteUserExperiment: please provide an experiment id"));case 2:return n=function(e){return a.app.database().ref("experiments").child(e).remove()},i=function(e){return a.app.functions().httpsCallable("removeRelations")({experimentId:e})},t.next=6,Promise.all([n(e),i(e)]).catch(function(){});case 6:case"end":return t.stop()}},t)}))}}]),e}();exports.FirebaseUser=j;
|
|
518
|
+
},{"rxjs":"Zr8e","rxjs/operators":"v3iE","firebase/compat/app":"tq2Y"}],"mSvX":[function(require,module,exports) {
|
|
519
|
+
"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){return c(t)||i(t,e)||n(t,e)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,c,a=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(f){s=!0,o=f}finally{try{if(!u&&null!=r.return&&(c=r.return(),Object(c)!==c))return}finally{if(s)throw o}}return a}}function c(t){if(Array.isArray(t))return t}function a(){a=function(){return e};var e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(P){f=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof p?e:p,c=Object.create(i.prototype),a=new S(n||[]);return o(c,"_invoke",{value:E(t,r,a)}),c}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(P){return{type:"throw",arg:P}}}e.wrap=l;var v={};function p(){}function d(){}function y(){}var m={};f(m,c,function(){return this});var g=Object.getPrototypeOf,b=g&&g(g(k([])));b&&b!==r&&n.call(b,c)&&(m=b);var w=y.prototype=p.prototype=Object.create(m);function x(t){["next","throw","return"].forEach(function(e){f(t,e,function(t){return this._invoke(e,t)})})}function L(e,r){var i;o(this,"_invoke",{value:function(o,c){function a(){return new r(function(i,a){!function o(i,c,a,u){var s=h(e[i],e,c);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==t(l)&&n.call(l,"__await")?r.resolve(l.__await).then(function(t){o("next",t,a,u)},function(t){o("throw",t,a,u)}):r.resolve(l).then(function(t){f.value=t,a(f)},function(t){return o("throw",t,a,u)})}u(s.arg)}(o,c,i,a)})}return i=i?i.then(a,a):a()}})}function E(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return T()}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var a=_(c,r);if(a){if(a===v)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=h(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function _(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function k(t){if(t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return d.prototype=y,o(w,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:d,configurable:!0}),d.displayName=f(y,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,f(t,s,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},x(L.prototype),f(L.prototype,u,function(){return this}),e.AsyncIterator=L,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var c=new L(l(t,r,n,o),i);return e.isGeneratorFunction(r)?c:c.next().then(function(t){return t.done?t.value:c.next()})},x(w),f(w,s,"Generator"),f(w,c,function(){return this}),f(w,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=k,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return c.type="throw",c.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var a=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var c=i?i.completion:{};return c.type=t,c.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(c)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),v}},e}var u=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function c(t){try{u(n.next(t))}catch(e){i(e)}}function a(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(c,a)}u((n=n.apply(t,e||[])).next())})},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.createDeviceStore=void 0;var f=s(require("firebase/compat/app")),l=f.default.database.ServerValue.TIMESTAMP,h=function(t,r,n){var o=t.database().ref("devices/".concat(r)),i=o.child("subscriptions").push().key,c=o.child("clients/".concat(i)),s=[],f=function(t,e){return o.child(t).set(e)},h=function(t,e){return o.child(t).update(e)},v=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"value",e=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,n=o.child(e).on(t,function(t){r(t.val(),t)});return s.push(function(){o.child(e).off(t,n)}),n},p=function(t,e,r){r?o.child(t).off(e,r):o.child(t).off(e)},d=t.database().ref(".info/connected").on("value",function(t){t.val()&&c.onDisconnect().remove().then(function(){c.set(l),h("subscriptions",n.get()).then(function(){n.toList().forEach(function(t){var e="subscriptions/".concat(t.id);o.child(e).onDisconnect().remove()})})})});return s.push(function(){t.database().ref(".info/connected").off("value",d)}),{set:f,once:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"value";return u(void 0,void 0,void 0,a().mark(function r(){var n;return a().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,o.child(t).once(e);case 2:return n=r.sent,r.abrupt("return",n.val());case 4:case"end":return r.stop()}},r)}))},update:h,lastOfChildValue:function(t,r,n){return u(void 0,void 0,void 0,a().mark(function i(){var c,u,s,f,l;return a().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,o.child(t).orderByChild(r).equalTo(n).limitToLast(1).once("value");case 2:return c=i.sent,u=c.val(),s=Object.values(u||{}),f=e(s,1),l=f[0],i.abrupt("return",l||null);case 6:case"end":return i.stop()}},i)}))},onNamespace:function(t,e){return v("value",t,function(t){e(t)})},offNamespace:function(t,e){p(t,"value",e)},dispatchAction:function(t){return u(void 0,void 0,void 0,a().mark(function e(){var r,n,i,c,u,s;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a="actions",f=t,o.child(a).push(f);case 2:if(r=e.sent,n=r.key,i="actions/".concat(n),r.onDisconnect().remove(),!t.responseRequired){e.next=11;break}return c=t.responseTimeout||6e5,u=new Promise(function(t,e){var n=setTimeout(function(){clearTimeout(n),r.remove(),e("Action response timed out in ".concat(c,"ms."))},c)}),s=new Promise(function(t){var e,r,n,o;e="value",r="".concat(i,"/response"),n=t,v(e,r,function(t){null!==t&&(p(r,e),n(o||t))})}),e.abrupt("return",Promise.race([s,u]));case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}var a,f},e)}))},nextMetric:function(t,e){return u(void 0,void 0,void 0,a().mark(function r(){return a().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:f("metrics/".concat(t),e);case 1:case"end":return r.stop()}},r)}))},onMetric:function(t,e){var r=t.atomic,n=t.metric,o=t.labels,i=r?"metrics/".concat(n):"metrics/".concat(n,"/").concat(o[0]);return v("value",i,function(t){null!==t&&e(t)})},subscribeToMetric:function(t){var e=o.child("subscriptions").push().key,r="subscriptions/".concat(e),n=Object.assign({id:e,clientId:i},t);return f(r,n),o.child(r).onDisconnect().remove(),n},unsubscribeFromMetric:function(t){var e;e="subscriptions/".concat(t.id),o.child(e).remove()},removeMetricListener:function(t,e){var r=t.atomic,n=t.metric,o=t.labels,i=r?"metrics/".concat(n):"metrics/".concat(n,"/").concat(o[0]);p(i,"value",e)},disconnect:function(){c.remove(),s.forEach(function(t){t()}),n.toList().filter(function(t){return t.clientId===i}).forEach(function(t){var e="subscriptions/".concat(t.id);o.child(e).remove()})}}};exports.createDeviceStore=h;
|
|
520
|
+
},{"firebase/compat/app":"tq2Y"}],"KzOJ":[function(require,module,exports) {
|
|
521
|
+
"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){return a(t)||i(t,e)||n(t,e)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(f){s=!0,o=f}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}function a(t){if(Array.isArray(t))return t}function c(){c=function(){return e};var e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(M){f=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof p?e:p,a=Object.create(i.prototype),c=new O(n||[]);return o(a,"_invoke",{value:k(t,r,c)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(M){return{type:"throw",arg:M}}}e.wrap=l;var v={};function p(){}function d(){}function y(){}var m={};f(m,a,function(){return this});var b=Object.getPrototypeOf,g=b&&b(b(_([])));g&&g!==r&&n.call(g,a)&&(m=g);var w=y.prototype=p.prototype=Object.create(m);function x(t){["next","throw","return"].forEach(function(e){f(t,e,function(t){return this._invoke(e,t)})})}function S(e,r){var i;o(this,"_invoke",{value:function(o,a){function c(){return new r(function(i,c){!function o(i,a,c,u){var s=h(e[i],e,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==t(l)&&n.call(l,"__await")?r.resolve(l.__await).then(function(t){o("next",t,c,u)},function(t){o("throw",t,c,u)}):r.resolve(l).then(function(t){f.value=t,c(f)},function(t){return o("throw",t,c,u)})}u(s.arg)}(o,a,i,c)})}return i=i?i.then(c,c):c()}})}function k(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return T()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=L(a,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=h(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function L(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,L(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function _(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return d.prototype=y,o(w,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:d,configurable:!0}),d.displayName=f(y,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,f(t,s,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},x(S.prototype),f(S.prototype,u,function(){return this}),e.AsyncIterator=S,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new S(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},x(w),f(w,s,"Generator"),f(w,a,function(){return this}),f(w,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=_,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:_(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),v}},e}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function f(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(e){var r=h(e,"string");return"symbol"===t(r)?r:String(r)}function h(e,r){if("object"!==t(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,r||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}var v=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function a(t){try{u(n.next(t))}catch(e){i(e)}}function c(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,c)}u((n=n.apply(t,e||[])).next())})},p=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FirebaseDevice=void 0;var d=p(require("firebase/compat/app")),y=require("./deviceStore"),m=d.default.database.ServerValue.TIMESTAMP,b=function(){function t(e){var r=e.deviceId,n=e.firebaseApp,o=e.dependencies;if(u(this,t),!r)throw new Error("No Device ID provided.");this.deviceId=r,this.app=n.app,this.deviceStore=(0,y.createDeviceStore)(this.app,r,o.subscriptionManager)}return f(t,[{key:"timestamp",get:function(){return m}},{key:"dispatchAction",value:function(t){return this.deviceStore.dispatchAction(t)}},{key:"getInfo",value:function(){return v(this,void 0,void 0,c().mark(function t(){return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.deviceStore.once("info");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t,this)}))}},{key:"onNamespace",value:function(t,e){return this.deviceStore.onNamespace(t,e)}},{key:"onceNamespace",value:function(t){return v(this,void 0,void 0,c().mark(function e(){return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deviceStore.once(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)}))}},{key:"offNamespace",value:function(t,e){this.deviceStore.offNamespace(t,e)}},{key:"getTimesync",value:function(){return v(this,void 0,void 0,c().mark(function t(){var e;return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dispatchAction({command:"timesync",action:"get",responseRequired:!0,responseTimeout:250});case 2:return e=t.sent,t.abrupt("return",e.timestamp);case 4:case"end":return t.stop()}},t,this)}))}},{key:"nextMetric",value:function(t,e){this.deviceStore.nextMetric(t,e)}},{key:"onMetric",value:function(t,e){return this.deviceStore.onMetric(t,e)}},{key:"subscribeToMetric",value:function(e){return this.deviceStore.subscribeToMetric(Object.assign(Object.assign({},e),{serverType:t.serverType}))}},{key:"unsubscribeFromMetric",value:function(t){this.deviceStore.unsubscribeFromMetric(t)}},{key:"removeMetricListener",value:function(t,e){this.deviceStore.removeMetricListener(t,e)}},{key:"changeSettings",value:function(t){return v(this,void 0,void 0,c().mark(function e(){return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceStore.update("settings",t));case 1:case"end":return e.stop()}},e,this)}))}},{key:"getSkill",value:function(t){return v(this,void 0,void 0,c().mark(function e(){return c().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.deviceStore.lastOfChildValue("skills","bundleId",t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)}))}},{key:"createBluetoothToken",value:function(){var t;return v(this,void 0,void 0,c().mark(function r(){var n,o,i,a;return c().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.app.functions().httpsCallable("createBluetoothToken")({deviceId:this.deviceId}).then(function(t){var e=t.data;return[null,null==e?void 0:e.token]}).catch(function(t){return[t,null]});case 2:if(n=r.sent,o=e(n,2),i=o[0],a=o[1],!i){r.next=8;break}return r.abrupt("return",Promise.reject(null!==(t=null==i?void 0:i.message)&&void 0!==t?t:i));case 8:if(a){r.next=10;break}return r.abrupt("return",Promise.reject("Failed to create Bluetooth token."));case 10:return r.abrupt("return",a);case 11:case"end":return r.stop()}},r,this)}))}},{key:"disconnect",value:function(){this.deviceStore.disconnect()}}]),t}();exports.FirebaseDevice=b,b.serverType="firebase";
|
|
522
|
+
},{"firebase/compat/app":"tq2Y","./deviceStore":"mSvX"}],"kM30":[function(require,module,exports) {
|
|
509
523
|
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,r,t,i){void 0===i&&(i=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&("get"in o?r.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,i,o)}:function(e,r,t,i){void 0===i&&(i=t),e[i]=r[t]}),r=this&&this.__exportStar||function(r,t){for(var i in r)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||e(t,r,i)};Object.defineProperty(exports,"__esModule",{value:!0}),r(require("./FirebaseApp"),exports),r(require("./FirebaseUser"),exports),r(require("./FirebaseDevice"),exports);
|
|
510
524
|
},{"./FirebaseApp":"OERo","./FirebaseUser":"Cc51","./FirebaseDevice":"KzOJ"}],"c6Wx":[function(require,module,exports) {
|
|
511
525
|
var r=Array.isArray;function n(n){if(r(n))return t(n);var e=null,u="string"==typeof n&&n;return function(r,n,i){return e||(e=t(i,u)),r=u?r[u]:r,!~e.indexOf(r)}}function t(r,n){r=r.slice(0),n&&(r=r.map(function(r){return r[n]}));for(var t=(r=r.sort(function(r,n){return r-n})).length,i=e(r),o=u(r),a=[],c=0;c<t;c++)Math.abs(r[c]-i)>o&&a.push(r[c]);return a}function e(r){var n=r.length,t=~~(n/2);return n%2?r[t]:(r[t-1]+r[t])/2}function u(r){var n=r.length,t=e(r.slice(0,~~(n/2)));return 1.5*(e(r.slice(Math.ceil(n/2)))-t)}module.exports=n;
|