reactfire
Version:
Firebase library for React
2,107 lines • 62.6 kB
JavaScript
import * as e from "react";
import { onIdTokenChanged as t } from "firebase/auth";
import * as n from "firebase/app";
import { getApps as r, initializeApp as i, registerVersion as a } from "firebase/app";
import { get as o, off as s, onChildAdded as c, onChildChanged as l, onChildMoved as u, onChildRemoved as d, onValue as f } from "firebase/database";
import { onSnapshot as p, queryEqual as m } from "firebase/firestore";
import { useSyncExternalStore as h } from "use-sync-external-store/shim";
import { httpsCallable as ee } from "firebase/functions";
import { ensureInitialized as te, getAll as ne, getBoolean as re, getNumber as ie, getString as ae, getValue as oe } from "firebase/remote-config";
import { getDownloadURL as se, ref as ce } from "firebase/storage";
// node_modules/tslib/tslib.es6.mjs
var le = function(e, t) {
return le = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
}, le(e, t);
};
function g(e, t) {
if (typeof t != "function" && t !== null) throw TypeError("Class extends value " + String(t) + " is not a constructor or null");
le(e, t);
function n() {
this.constructor = e;
}
e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
}
function ue(e, t) {
var n = {};
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var i = 0, r = Object.getOwnPropertySymbols(e); i < r.length; i++) t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (n[r[i]] = e[r[i]]);
return n;
}
function de(e, t, n, r) {
function i(e) {
return e instanceof n ? e : new n(function(t) {
t(e);
});
}
return new (n ||= Promise)(function(n, a) {
function o(e) {
try {
c(r.next(e));
} catch (e) {
a(e);
}
}
function s(e) {
try {
c(r.throw(e));
} catch (e) {
a(e);
}
}
function c(e) {
e.done ? n(e.value) : i(e.value).then(o, s);
}
c((r = r.apply(e, t || [])).next());
});
}
function fe(e, t) {
var n = {
label: 0,
sent: function() {
if (a[0] & 1) throw a[1];
return a[1];
},
trys: [],
ops: []
}, r, i, a, o = {
next: s(0),
throw: s(1),
return: s(2)
};
return typeof Symbol == "function" && (o[Symbol.iterator] = function() {
return this;
}), o;
function s(e) {
return function(t) {
return c([e, t]);
};
}
function c(s) {
if (r) throw TypeError("Generator is already executing.");
for (; o && (o = 0, s[0] && (n = 0)), n;) try {
if (r = 1, i && (a = s[0] & 2 ? i.return : s[0] ? i.throw || ((a = i.return) && a.call(i), 0) : i.next) && !(a = a.call(i, s[1])).done) return a;
switch (i = 0, a && (s = [s[0] & 2, a.value]), s[0]) {
case 0:
case 1:
a = s;
break;
case 4: return n.label++, {
value: s[1],
done: !1
};
case 5:
n.label++, i = s[1], s = [0];
continue;
case 7:
s = n.ops.pop(), n.trys.pop();
continue;
default:
if (a = n.trys, !(a = a.length > 0 && a[a.length - 1]) && (s[0] === 6 || s[0] === 2)) {
n = 0;
continue;
}
if (s[0] === 3 && (!a || s[1] > a[0] && s[1] < a[3])) {
n.label = s[1];
break;
}
if (s[0] === 6 && n.label < a[1]) {
n.label = a[1], a = s;
break;
}
if (a && n.label < a[2]) {
n.label = a[2], n.ops.push(s);
break;
}
a[2] && n.ops.pop(), n.trys.pop();
continue;
}
s = t.call(e, n);
} catch (e) {
s = [6, e], i = 0;
} finally {
r = a = 0;
}
if (s[0] & 5) throw s[1];
return {
value: s[0] ? s[1] : void 0,
done: !0
};
}
}
function _(e) {
var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], r = 0;
if (n) return n.call(e);
if (e && typeof e.length == "number") return { next: function() {
return e && r >= e.length && (e = void 0), {
value: e && e[r++],
done: !e
};
} };
throw TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function v(e, t) {
var n = typeof Symbol == "function" && e[Symbol.iterator];
if (!n) return e;
var r = n.call(e), i, a = [], o;
try {
for (; (t === void 0 || t-- > 0) && !(i = r.next()).done;) a.push(i.value);
} catch (e) {
o = { error: e };
} finally {
try {
i && !i.done && (n = r.return) && n.call(r);
} finally {
if (o) throw o.error;
}
}
return a;
}
function y(e, t, n) {
if (n || arguments.length === 2) for (var r = 0, i = t.length, a; r < i; r++) (a || !(r in t)) && (a ||= Array.prototype.slice.call(t, 0, r), a[r] = t[r]);
return e.concat(a || Array.prototype.slice.call(t));
}
function b(e) {
return this instanceof b ? (this.v = e, this) : new b(e);
}
function pe(e, t, n) {
if (!Symbol.asyncIterator) throw TypeError("Symbol.asyncIterator is not defined.");
var r = n.apply(e, t || []), i, a = [];
return i = {}, o("next"), o("throw"), o("return"), i[Symbol.asyncIterator] = function() {
return this;
}, i;
function o(e) {
r[e] && (i[e] = function(t) {
return new Promise(function(n, r) {
a.push([
e,
t,
n,
r
]) > 1 || s(e, t);
});
});
}
function s(e, t) {
try {
c(r[e](t));
} catch (e) {
d(a[0][3], e);
}
}
function c(e) {
e.value instanceof b ? Promise.resolve(e.value.v).then(l, u) : d(a[0][2], e);
}
function l(e) {
s("next", e);
}
function u(e) {
s("throw", e);
}
function d(e, t) {
e(t), a.shift(), a.length && s(a[0][0], a[0][1]);
}
}
function me(e) {
if (!Symbol.asyncIterator) throw TypeError("Symbol.asyncIterator is not defined.");
var t = e[Symbol.asyncIterator], n;
return t ? t.call(e) : (e = typeof _ == "function" ? _(e) : e[Symbol.iterator](), n = {}, r("next"), r("throw"), r("return"), n[Symbol.asyncIterator] = function() {
return this;
}, n);
function r(t) {
n[t] = e[t] && function(n) {
return new Promise(function(r, a) {
n = e[t](n), i(r, a, n.done, n.value);
});
};
}
function i(e, t, n, r) {
Promise.resolve(r).then(function(t) {
e({
value: t,
done: n
});
}, t);
}
}
// node_modules/rxjs/dist/esm5/internal/util/isFunction.js
function x(e) {
return typeof e == "function";
}
// node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js
function he(e) {
var t = e(function(e) {
Error.call(e), e.stack = (/* @__PURE__ */ Error()).stack;
});
return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
}
// node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js
var ge = he(function(e) {
return function(t) {
e(this), this.message = t ? t.length + " errors occurred during unsubscription:\n" + t.map(function(e, t) {
return t + 1 + ") " + e.toString();
}).join("\n ") : "", this.name = "UnsubscriptionError", this.errors = t;
};
});
// node_modules/rxjs/dist/esm5/internal/util/arrRemove.js
function S(e, t) {
if (e) {
var n = e.indexOf(t);
0 <= n && e.splice(n, 1);
}
}
// node_modules/rxjs/dist/esm5/internal/Subscription.js
var C = function() {
function e(e) {
this.initialTeardown = e, this.closed = !1, this._parentage = null, this._finalizers = null;
}
return e.prototype.unsubscribe = function() {
var e, t, n, r, i;
if (!this.closed) {
this.closed = !0;
var a = this._parentage;
if (a) {
if (this._parentage = null, Array.isArray(a)) try {
for (var o = _(a), s = o.next(); !s.done; s = o.next()) s.value.remove(this);
} catch (t) {
e = { error: t };
} finally {
try {
s && !s.done && (t = o.return) && t.call(o);
} finally {
if (e) throw e.error;
}
}
else a.remove(this);
}
var c = this.initialTeardown;
if (x(c)) try {
c();
} catch (e) {
i = e instanceof ge ? e.errors : [e];
}
var l = this._finalizers;
if (l) {
this._finalizers = null;
try {
for (var u = _(l), d = u.next(); !d.done; d = u.next()) {
var f = d.value;
try {
ye(f);
} catch (e) {
i ??= [], e instanceof ge ? i = y(y([], v(i)), v(e.errors)) : i.push(e);
}
}
} catch (e) {
n = { error: e };
} finally {
try {
d && !d.done && (r = u.return) && r.call(u);
} finally {
if (n) throw n.error;
}
}
}
if (i) throw new ge(i);
}
}, e.prototype.add = function(t) {
if (t && t !== this) {
if (this.closed) ye(t);
else {
if (t instanceof e) {
if (t.closed || t._hasParent(this)) return;
t._addParent(this);
}
(this._finalizers = this._finalizers ?? []).push(t);
}
}
}, e.prototype._hasParent = function(e) {
var t = this._parentage;
return t === e || Array.isArray(t) && t.includes(e);
}, e.prototype._addParent = function(e) {
var t = this._parentage;
this._parentage = Array.isArray(t) ? (t.push(e), t) : t ? [t, e] : e;
}, e.prototype._removeParent = function(e) {
var t = this._parentage;
t === e ? this._parentage = null : Array.isArray(t) && S(t, e);
}, e.prototype.remove = function(t) {
var n = this._finalizers;
n && S(n, t), t instanceof e && t._removeParent(this);
}, e.EMPTY = (function() {
var t = new e();
return t.closed = !0, t;
})(), e;
}(), _e = C.EMPTY;
function ve(e) {
return e instanceof C || e && "closed" in e && x(e.remove) && x(e.add) && x(e.unsubscribe);
}
function ye(e) {
x(e) ? e() : e.unsubscribe();
}
// node_modules/rxjs/dist/esm5/internal/config.js
var w = {
onUnhandledError: null,
onStoppedNotification: null,
Promise: void 0,
useDeprecatedSynchronousErrorHandling: !1,
useDeprecatedNextContext: !1
}, be = {
setTimeout: function(e, t) {
var n = [...arguments].slice(2), r = be.delegate;
return r?.setTimeout ? r.setTimeout.apply(r, y([e, t], v(n))) : setTimeout.apply(void 0, y([e, t], v(n)));
},
clearTimeout: function(e) {
return (be.delegate?.clearTimeout || clearTimeout)(e);
},
delegate: void 0
};
// node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js
function xe(e) {
be.setTimeout(function() {
var t = w.onUnhandledError;
if (t) t(e);
else throw e;
});
}
// node_modules/rxjs/dist/esm5/internal/util/noop.js
function Se() {}
// node_modules/rxjs/dist/esm5/internal/NotificationFactories.js
var Ce = (function() {
return Ee("C", void 0, void 0);
})();
function we(e) {
return Ee("E", void 0, e);
}
function Te(e) {
return Ee("N", e, void 0);
}
function Ee(e, t, n) {
return {
kind: e,
value: t,
error: n
};
}
// node_modules/rxjs/dist/esm5/internal/util/errorContext.js
var T = null;
function E(e) {
if (w.useDeprecatedSynchronousErrorHandling) {
var t = !T;
if (t && (T = {
errorThrown: !1,
error: null
}), e(), t) {
var n = T, r = n.errorThrown, i = n.error;
if (T = null, r) throw i;
}
} else e();
}
function De(e) {
w.useDeprecatedSynchronousErrorHandling && T && (T.errorThrown = !0, T.error = e);
}
// node_modules/rxjs/dist/esm5/internal/Subscriber.js
var Oe = function(e) {
g(t, e);
function t(t) {
var n = e.call(this) || this;
return n.isStopped = !1, t ? (n.destination = t, ve(t) && t.add(n)) : n.destination = Pe, n;
}
return t.create = function(e, t, n) {
return new D(e, t, n);
}, t.prototype.next = function(e) {
this.isStopped ? Ne(Te(e), this) : this._next(e);
}, t.prototype.error = function(e) {
this.isStopped ? Ne(we(e), this) : (this.isStopped = !0, this._error(e));
}, t.prototype.complete = function() {
this.isStopped ? Ne(Ce, this) : (this.isStopped = !0, this._complete());
}, t.prototype.unsubscribe = function() {
this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
}, t.prototype._next = function(e) {
this.destination.next(e);
}, t.prototype._error = function(e) {
try {
this.destination.error(e);
} finally {
this.unsubscribe();
}
}, t.prototype._complete = function() {
try {
this.destination.complete();
} finally {
this.unsubscribe();
}
}, t;
}(C), ke = Function.prototype.bind;
function Ae(e, t) {
return ke.call(e, t);
}
var je = function() {
function e(e) {
this.partialObserver = e;
}
return e.prototype.next = function(e) {
var t = this.partialObserver;
if (t.next) try {
t.next(e);
} catch (e) {
O(e);
}
}, e.prototype.error = function(e) {
var t = this.partialObserver;
if (t.error) try {
t.error(e);
} catch (e) {
O(e);
}
else O(e);
}, e.prototype.complete = function() {
var e = this.partialObserver;
if (e.complete) try {
e.complete();
} catch (e) {
O(e);
}
}, e;
}(), D = function(e) {
g(t, e);
function t(t, n, r) {
var i = e.call(this) || this, a;
if (x(t) || !t) a = {
next: t ?? void 0,
error: n ?? void 0,
complete: r ?? void 0
};
else {
var o;
i && w.useDeprecatedNextContext ? (o = Object.create(t), o.unsubscribe = function() {
return i.unsubscribe();
}, a = {
next: t.next && Ae(t.next, o),
error: t.error && Ae(t.error, o),
complete: t.complete && Ae(t.complete, o)
}) : a = t;
}
return i.destination = new je(a), i;
}
return t;
}(Oe);
function O(e) {
w.useDeprecatedSynchronousErrorHandling ? De(e) : xe(e);
}
function Me(e) {
throw e;
}
function Ne(e, t) {
var n = w.onStoppedNotification;
n && be.setTimeout(function() {
return n(e, t);
});
}
var Pe = {
closed: !0,
next: Se,
error: Me,
complete: Se
}, Fe = (function() {
return typeof Symbol == "function" && Symbol.observable || "@@observable";
})();
// node_modules/rxjs/dist/esm5/internal/util/identity.js
function k(e) {
return e;
}
// node_modules/rxjs/dist/esm5/internal/util/pipe.js
function Ie(e) {
return e.length === 0 ? k : e.length === 1 ? e[0] : function(t) {
return e.reduce(function(e, t) {
return t(e);
}, t);
};
}
// node_modules/rxjs/dist/esm5/internal/Observable.js
var A = function() {
function e(e) {
e && (this._subscribe = e);
}
return e.prototype.lift = function(t) {
var n = new e();
return n.source = this, n.operator = t, n;
}, e.prototype.subscribe = function(e, t, n) {
var r = this, i = ze(e) ? e : new D(e, t, n);
return E(function() {
var e = r, t = e.operator, n = e.source;
i.add(t ? t.call(i, n) : n ? r._subscribe(i) : r._trySubscribe(i));
}), i;
}, e.prototype._trySubscribe = function(e) {
try {
return this._subscribe(e);
} catch (t) {
e.error(t);
}
}, e.prototype.forEach = function(e, t) {
var n = this;
return t = Le(t), new t(function(t, r) {
var i = new D({
next: function(t) {
try {
e(t);
} catch (e) {
r(e), i.unsubscribe();
}
},
error: r,
complete: t
});
n.subscribe(i);
});
}, e.prototype._subscribe = function(e) {
return this.source?.subscribe(e);
}, e.prototype[Fe] = function() {
return this;
}, e.prototype.pipe = function() {
return Ie([...arguments])(this);
}, e.prototype.toPromise = function(e) {
var t = this;
return e = Le(e), new e(function(e, n) {
var r;
t.subscribe(function(e) {
return r = e;
}, function(e) {
return n(e);
}, function() {
return e(r);
});
});
}, e.create = function(t) {
return new e(t);
}, e;
}();
function Le(e) {
return e ?? w.Promise ?? Promise;
}
function Re(e) {
return e && x(e.next) && x(e.error) && x(e.complete);
}
function ze(e) {
return e && e instanceof Oe || Re(e) && ve(e);
}
// node_modules/rxjs/dist/esm5/internal/util/lift.js
function Be(e) {
return x(e?.lift);
}
function j(e) {
return function(t) {
if (Be(t)) return t.lift(function(t) {
try {
return e(t, this);
} catch (e) {
this.error(e);
}
});
throw TypeError("Unable to lift unknown Observable type");
};
}
// node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js
function M(e, t, n, r, i) {
return new Ve(e, t, n, r, i);
}
var Ve = function(e) {
g(t, e);
function t(t, n, r, i, a, o) {
var s = e.call(this, t) || this;
return s.onFinalize = a, s.shouldUnsubscribe = o, s._next = n ? function(e) {
try {
n(e);
} catch (e) {
t.error(e);
}
} : e.prototype._next, s._error = i ? function(e) {
try {
i(e);
} catch (e) {
t.error(e);
} finally {
this.unsubscribe();
}
} : e.prototype._error, s._complete = r ? function() {
try {
r();
} catch (e) {
t.error(e);
} finally {
this.unsubscribe();
}
} : e.prototype._complete, s;
}
return t.prototype.unsubscribe = function() {
var t;
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
var n = this.closed;
e.prototype.unsubscribe.call(this), n || (t = this.onFinalize) == null || t.call(this);
}
}, t;
}(Oe), He = he(function(e) {
return function() {
e(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
};
}), Ue = function(e) {
g(t, e);
function t() {
var t = e.call(this) || this;
return t.closed = !1, t.currentObservers = null, t.observers = [], t.isStopped = !1, t.hasError = !1, t.thrownError = null, t;
}
return t.prototype.lift = function(e) {
var t = new We(this, this);
return t.operator = e, t;
}, t.prototype._throwIfClosed = function() {
if (this.closed) throw new He();
}, t.prototype.next = function(e) {
var t = this;
E(function() {
var n, r;
if (t._throwIfClosed(), !t.isStopped) {
t.currentObservers ||= Array.from(t.observers);
try {
for (var i = _(t.currentObservers), a = i.next(); !a.done; a = i.next()) a.value.next(e);
} catch (e) {
n = { error: e };
} finally {
try {
a && !a.done && (r = i.return) && r.call(i);
} finally {
if (n) throw n.error;
}
}
}
});
}, t.prototype.error = function(e) {
var t = this;
E(function() {
if (t._throwIfClosed(), !t.isStopped) {
t.hasError = t.isStopped = !0, t.thrownError = e;
for (var n = t.observers; n.length;) n.shift().error(e);
}
});
}, t.prototype.complete = function() {
var e = this;
E(function() {
if (e._throwIfClosed(), !e.isStopped) {
e.isStopped = !0;
for (var t = e.observers; t.length;) t.shift().complete();
}
});
}, t.prototype.unsubscribe = function() {
this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
}, Object.defineProperty(t.prototype, "observed", {
get: function() {
return this.observers?.length > 0;
},
enumerable: !1,
configurable: !0
}), t.prototype._trySubscribe = function(t) {
return this._throwIfClosed(), e.prototype._trySubscribe.call(this, t);
}, t.prototype._subscribe = function(e) {
return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
}, t.prototype._innerSubscribe = function(e) {
var t = this, n = this, r = n.hasError, i = n.isStopped, a = n.observers;
return r || i ? _e : (this.currentObservers = null, a.push(e), new C(function() {
t.currentObservers = null, S(a, e);
}));
}, t.prototype._checkFinalizedStatuses = function(e) {
var t = this, n = t.hasError, r = t.thrownError, i = t.isStopped;
n ? e.error(r) : i && e.complete();
}, t.prototype.asObservable = function() {
var e = new A();
return e.source = this, e;
}, t.create = function(e, t) {
return new We(e, t);
}, t;
}(A), We = function(e) {
g(t, e);
function t(t, n) {
var r = e.call(this) || this;
return r.destination = t, r.source = n, r;
}
return t.prototype.next = function(e) {
var t, n;
(n = (t = this.destination)?.next) == null || n.call(t, e);
}, t.prototype.error = function(e) {
var t, n;
(n = (t = this.destination)?.error) == null || n.call(t, e);
}, t.prototype.complete = function() {
var e, t;
(t = (e = this.destination)?.complete) == null || t.call(e);
}, t.prototype._subscribe = function(e) {
return this.source?.subscribe(e) ?? _e;
}, t;
}(Ue), Ge = {
now: function() {
return (Ge.delegate || Date).now();
},
delegate: void 0
}, Ke = function(e) {
g(t, e);
function t(t, n, r) {
t === void 0 && (t = Infinity), n === void 0 && (n = Infinity), r === void 0 && (r = Ge);
var i = e.call(this) || this;
return i._bufferSize = t, i._windowTime = n, i._timestampProvider = r, i._buffer = [], i._infiniteTimeWindow = !0, i._infiniteTimeWindow = n === Infinity, i._bufferSize = Math.max(1, t), i._windowTime = Math.max(1, n), i;
}
return t.prototype.next = function(t) {
var n = this, r = n.isStopped, i = n._buffer, a = n._infiniteTimeWindow, o = n._timestampProvider, s = n._windowTime;
r || (i.push(t), !a && i.push(o.now() + s)), this._trimBuffer(), e.prototype.next.call(this, t);
}, t.prototype._subscribe = function(e) {
this._throwIfClosed(), this._trimBuffer();
for (var t = this._innerSubscribe(e), n = this, r = n._infiniteTimeWindow, i = n._buffer.slice(), a = 0; a < i.length && !e.closed; a += r ? 1 : 2) e.next(i[a]);
return this._checkFinalizedStatuses(e), t;
}, t.prototype._trimBuffer = function() {
var e = this, t = e._bufferSize, n = e._timestampProvider, r = e._buffer, i = e._infiniteTimeWindow, a = (i ? 1 : 2) * t;
if (t < Infinity && a < r.length && r.splice(0, r.length - a), !i) {
for (var o = n.now(), s = 0, c = 1; c < r.length && r[c] <= o; c += 2) s = c;
s && r.splice(0, s + 1);
}
}, t;
}(Ue), qe = function(e) {
g(t, e);
function t(t, n) {
return e.call(this) || this;
}
return t.prototype.schedule = function(e, t) {
return t === void 0 && (t = 0), this;
}, t;
}(C), Je = {
setInterval: function(e, t) {
var n = [...arguments].slice(2), r = Je.delegate;
return r?.setInterval ? r.setInterval.apply(r, y([e, t], v(n))) : setInterval.apply(void 0, y([e, t], v(n)));
},
clearInterval: function(e) {
return (Je.delegate?.clearInterval || clearInterval)(e);
},
delegate: void 0
}, Ye = function(e) {
g(t, e);
function t(t, n) {
var r = e.call(this, t, n) || this;
return r.scheduler = t, r.work = n, r.pending = !1, r;
}
return t.prototype.schedule = function(e, t) {
if (t === void 0 && (t = 0), this.closed) return this;
this.state = e;
var n = this.id, r = this.scheduler;
return n != null && (this.id = this.recycleAsyncId(r, n, t)), this.pending = !0, this.delay = t, this.id = this.id ?? this.requestAsyncId(r, this.id, t), this;
}, t.prototype.requestAsyncId = function(e, t, n) {
return n === void 0 && (n = 0), Je.setInterval(e.flush.bind(e, this), n);
}, t.prototype.recycleAsyncId = function(e, t, n) {
if (n === void 0 && (n = 0), n != null && this.delay === n && this.pending === !1) return t;
t != null && Je.clearInterval(t);
}, t.prototype.execute = function(e, t) {
if (this.closed) return /* @__PURE__ */ Error("executing a cancelled action");
this.pending = !1;
var n = this._execute(e, t);
if (n) return n;
this.pending === !1 && this.id != null && (this.id = this.recycleAsyncId(this.scheduler, this.id, null));
}, t.prototype._execute = function(e, t) {
var n = !1, r;
try {
this.work(e);
} catch (e) {
n = !0, r = e || /* @__PURE__ */ Error("Scheduled action threw falsy error");
}
if (n) return this.unsubscribe(), r;
}, t.prototype.unsubscribe = function() {
if (!this.closed) {
var t = this, n = t.id, r = t.scheduler, i = r.actions;
this.work = this.state = this.scheduler = null, this.pending = !1, S(i, this), n != null && (this.id = this.recycleAsyncId(r, n, null)), this.delay = null, e.prototype.unsubscribe.call(this);
}
}, t;
}(qe), Xe = function() {
function e(t, n) {
n === void 0 && (n = e.now), this.schedulerActionCtor = t, this.now = n;
}
return e.prototype.schedule = function(e, t, n) {
return t === void 0 && (t = 0), new this.schedulerActionCtor(this, e).schedule(n, t);
}, e.now = Ge.now, e;
}(), Ze = new (function(e) {
g(t, e);
function t(t, n) {
n === void 0 && (n = Xe.now);
var r = e.call(this, t, n) || this;
return r.actions = [], r._active = !1, r;
}
return t.prototype.flush = function(e) {
var t = this.actions;
if (this._active) t.push(e);
else {
var n;
this._active = !0;
do
if (n = e.execute(e.state, e.delay)) break;
while (e = t.shift());
if (this._active = !1, n) {
for (; e = t.shift();) e.unsubscribe();
throw n;
}
}
}, t;
}(Xe))(Ye), Qe = Ze, $e = new A(function(e) {
return e.complete();
});
function et(e) {
return e ? tt(e) : $e;
}
function tt(e) {
return new A(function(t) {
return e.schedule(function() {
return t.complete();
});
});
}
// node_modules/rxjs/dist/esm5/internal/util/isScheduler.js
function nt(e) {
return e && x(e.schedule);
}
// node_modules/rxjs/dist/esm5/internal/util/args.js
function rt(e) {
return e[e.length - 1];
}
function it(e) {
return nt(rt(e)) ? e.pop() : void 0;
}
function at(e, t) {
return typeof rt(e) == "number" ? e.pop() : t;
}
// node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js
var ot = (function(e) {
return e && typeof e.length == "number" && typeof e != "function";
});
// node_modules/rxjs/dist/esm5/internal/util/isPromise.js
function st(e) {
return x(e?.then);
}
// node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js
function ct(e) {
return x(e[Fe]);
}
// node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js
function lt(e) {
return Symbol.asyncIterator && x(e?.[Symbol.asyncIterator]);
}
// node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js
function ut(e) {
return /* @__PURE__ */ TypeError("You provided " + (typeof e == "object" && e ? "an invalid object" : "'" + e + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
}
// node_modules/rxjs/dist/esm5/internal/symbol/iterator.js
function dt() {
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
}
var ft = dt();
// node_modules/rxjs/dist/esm5/internal/util/isIterable.js
function pt(e) {
return x(e?.[ft]);
}
// node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js
function mt(e) {
return pe(this, arguments, function() {
var t, n, r, i;
return fe(this, function(a) {
switch (a.label) {
case 0: t = e.getReader(), a.label = 1;
case 1: a.trys.push([
1,
,
9,
10
]), a.label = 2;
case 2: return [4, b(t.read())];
case 3: return n = a.sent(), r = n.value, i = n.done, i ? [4, b(void 0)] : [3, 5];
case 4: return [2, a.sent()];
case 5: return [4, b(r)];
case 6: return [4, a.sent()];
case 7: return a.sent(), [3, 2];
case 8: return [3, 10];
case 9: return t.releaseLock(), [7];
case 10: return [2];
}
});
});
}
function ht(e) {
return x(e?.getReader);
}
// node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js
function N(e) {
if (e instanceof A) return e;
if (e != null) {
if (ct(e)) return gt(e);
if (ot(e)) return _t(e);
if (st(e)) return vt(e);
if (lt(e)) return bt(e);
if (pt(e)) return yt(e);
if (ht(e)) return xt(e);
}
throw ut(e);
}
function gt(e) {
return new A(function(t) {
var n = e[Fe]();
if (x(n.subscribe)) return n.subscribe(t);
throw TypeError("Provided object does not correctly implement Symbol.observable");
});
}
function _t(e) {
return new A(function(t) {
for (var n = 0; n < e.length && !t.closed; n++) t.next(e[n]);
t.complete();
});
}
function vt(e) {
return new A(function(t) {
e.then(function(e) {
t.closed || (t.next(e), t.complete());
}, function(e) {
return t.error(e);
}).then(null, xe);
});
}
function yt(e) {
return new A(function(t) {
var n, r;
try {
for (var i = _(e), a = i.next(); !a.done; a = i.next()) {
var o = a.value;
if (t.next(o), t.closed) return;
}
} catch (e) {
n = { error: e };
} finally {
try {
a && !a.done && (r = i.return) && r.call(i);
} finally {
if (n) throw n.error;
}
}
t.complete();
});
}
function bt(e) {
return new A(function(t) {
St(e, t).catch(function(e) {
return t.error(e);
});
});
}
function xt(e) {
return bt(mt(e));
}
function St(e, t) {
var n, r, i, a;
return de(this, void 0, void 0, function() {
var o, s;
return fe(this, function(c) {
switch (c.label) {
case 0: c.trys.push([
0,
5,
6,
11
]), n = me(e), c.label = 1;
case 1: return [4, n.next()];
case 2:
if (r = c.sent(), r.done) return [3, 4];
if (o = r.value, t.next(o), t.closed) return [2];
c.label = 3;
case 3: return [3, 1];
case 4: return [3, 11];
case 5: return s = c.sent(), i = { error: s }, [3, 11];
case 6: return c.trys.push([
6,
,
9,
10
]), r && !r.done && (a = n.return) ? [4, a.call(n)] : [3, 8];
case 7: c.sent(), c.label = 8;
case 8: return [3, 10];
case 9:
if (i) throw i.error;
return [7];
case 10: return [7];
case 11: return t.complete(), [2];
}
});
});
}
// node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js
function P(e, t, n, r, i) {
r === void 0 && (r = 0), i === void 0 && (i = !1);
var a = t.schedule(function() {
n(), i ? e.add(this.schedule(null, r)) : this.unsubscribe();
}, r);
if (e.add(a), !i) return a;
}
// node_modules/rxjs/dist/esm5/internal/operators/observeOn.js
function Ct(e, t) {
return t === void 0 && (t = 0), j(function(n, r) {
n.subscribe(M(r, function(n) {
return P(r, e, function() {
return r.next(n);
}, t);
}, function() {
return P(r, e, function() {
return r.complete();
}, t);
}, function(n) {
return P(r, e, function() {
return r.error(n);
}, t);
}));
});
}
// node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js
function wt(e, t) {
return t === void 0 && (t = 0), j(function(n, r) {
r.add(e.schedule(function() {
return n.subscribe(r);
}, t));
});
}
// node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js
function Tt(e, t) {
return N(e).pipe(wt(t), Ct(t));
}
// node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js
function Et(e, t) {
return N(e).pipe(wt(t), Ct(t));
}
// node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js
function Dt(e, t) {
return new A(function(n) {
var r = 0;
return t.schedule(function() {
r === e.length ? n.complete() : (n.next(e[r++]), n.closed || this.schedule());
});
});
}
// node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js
function Ot(e, t) {
return new A(function(n) {
var r;
return P(n, t, function() {
r = e[ft](), P(n, t, function() {
var e, t, i;
try {
e = r.next(), t = e.value, i = e.done;
} catch (e) {
n.error(e);
return;
}
i ? n.complete() : n.next(t);
}, 0, !0);
}), function() {
return x(r?.return) && r.return();
};
});
}
// node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js
function kt(e, t) {
if (!e) throw Error("Iterable cannot be null");
return new A(function(n) {
P(n, t, function() {
var r = e[Symbol.asyncIterator]();
P(n, t, function() {
r.next().then(function(e) {
e.done ? n.complete() : n.next(e.value);
});
}, 0, !0);
});
});
}
// node_modules/rxjs/dist/esm5/internal/scheduled/scheduleReadableStreamLike.js
function At(e, t) {
return kt(mt(e), t);
}
// node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js
function jt(e, t) {
if (e != null) {
if (ct(e)) return Tt(e, t);
if (ot(e)) return Dt(e, t);
if (st(e)) return Et(e, t);
if (lt(e)) return kt(e, t);
if (pt(e)) return Ot(e, t);
if (ht(e)) return At(e, t);
}
throw ut(e);
}
// node_modules/rxjs/dist/esm5/internal/observable/from.js
function F(e, t) {
return t ? jt(e, t) : N(e);
}
// node_modules/rxjs/dist/esm5/internal/observable/of.js
function Mt() {
var e = [...arguments];
return F(e, it(e));
}
// node_modules/rxjs/dist/esm5/internal/util/EmptyError.js
var Nt = he(function(e) {
return function() {
e(this), this.name = "EmptyError", this.message = "no elements in sequence";
};
});
// node_modules/rxjs/dist/esm5/internal/util/isDate.js
function Pt(e) {
return e instanceof Date && !isNaN(e);
}
// node_modules/rxjs/dist/esm5/internal/operators/map.js
function I(e, t) {
return j(function(n, r) {
var i = 0;
n.subscribe(M(r, function(n) {
r.next(e.call(t, n, i++));
}));
});
}
// node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js
function Ft(e, t, n, r, i, a, o, s) {
var c = [], l = 0, u = 0, d = !1, f = function() {
d && !c.length && !l && t.complete();
}, p = function(e) {
return l < r ? m(e) : c.push(e);
}, m = function(e) {
a && t.next(e), l++;
var s = !1;
N(n(e, u++)).subscribe(M(t, function(e) {
i?.(e), a ? p(e) : t.next(e);
}, function() {
s = !0;
}, void 0, function() {
if (s) try {
l--;
for (var e = function() {
var e = c.shift();
o ? P(t, o, function() {
return m(e);
}) : m(e);
}; c.length && l < r;) e();
f();
} catch (e) {
t.error(e);
}
}));
};
return e.subscribe(M(t, p, function() {
d = !0, f();
})), function() {
s?.();
};
}
// node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js
function It(e, t, n) {
return n === void 0 && (n = Infinity), x(t) ? It(function(n, r) {
return I(function(e, i) {
return t(n, e, r, i);
})(N(e(n, r)));
}, n) : (typeof t == "number" && (n = t), j(function(t, r) {
return Ft(t, r, e, n);
}));
}
// node_modules/rxjs/dist/esm5/internal/operators/mergeAll.js
function Lt(e) {
return e === void 0 && (e = Infinity), It(k, e);
}
// node_modules/rxjs/dist/esm5/internal/operators/concatAll.js
function Rt() {
return Lt(1);
}
// node_modules/rxjs/dist/esm5/internal/observable/concat.js
function zt() {
var e = [...arguments];
return Rt()(F(e, it(e)));
}
// node_modules/rxjs/dist/esm5/internal/observable/defer.js
function Bt(e) {
return new A(function(t) {
N(e()).subscribe(t);
});
}
// node_modules/rxjs/dist/esm5/internal/observable/timer.js
function Vt(e, t, n) {
e === void 0 && (e = 0), n === void 0 && (n = Qe);
var r = -1;
return t != null && (nt(t) ? n = t : r = t), new A(function(t) {
var i = Pt(e) ? +e - n.now() : e;
i < 0 && (i = 0);
var a = 0;
return n.schedule(function() {
t.closed || (t.next(a++), 0 <= r ? this.schedule(void 0, r) : t.complete());
}, i);
});
}
// node_modules/rxjs/dist/esm5/internal/observable/merge.js
function Ht() {
var e = [...arguments], t = it(e), n = at(e, Infinity), r = e;
return r.length ? r.length === 1 ? N(r[0]) : Lt(n)(F(r, t)) : $e;
}
// node_modules/rxjs/dist/esm5/internal/operators/filter.js
function Ut(e, t) {
return j(function(n, r) {
var i = 0;
n.subscribe(M(r, function(n) {
return e.call(t, n, i++) && r.next(n);
}));
});
}
// node_modules/rxjs/dist/esm5/internal/operators/catchError.js
function Wt(e) {
return j(function(t, n) {
var r = null, i = !1, a;
r = t.subscribe(M(n, void 0, void 0, function(o) {
a = N(e(o, Wt(e)(t))), r ? (r.unsubscribe(), r = null, a.subscribe(n)) : i = !0;
})), i && (r.unsubscribe(), r = null, a.subscribe(n));
});
}
// node_modules/rxjs/dist/esm5/internal/operators/scanInternals.js
function Gt(e, t, n, r, i) {
return function(a, o) {
var s = n, c = t, l = 0;
a.subscribe(M(o, function(t) {
var n = l++;
c = s ? e(c, t, n) : (s = !0, t), r && o.next(c);
}, i && (function() {
s && o.next(c), o.complete();
})));
};
}
// node_modules/rxjs/dist/esm5/internal/operators/defaultIfEmpty.js
function Kt(e) {
return j(function(t, n) {
var r = !1;
t.subscribe(M(n, function(e) {
r = !0, n.next(e);
}, function() {
r || n.next(e), n.complete();
}));
});
}
// node_modules/rxjs/dist/esm5/internal/operators/take.js
function qt(e) {
return e <= 0 ? function() {
return $e;
} : j(function(t, n) {
var r = 0;
t.subscribe(M(n, function(t) {
++r <= e && (n.next(t), e <= r && n.complete());
}));
});
}
// node_modules/rxjs/dist/esm5/internal/operators/ignoreElements.js
function Jt() {
return j(function(e, t) {
e.subscribe(M(t, Se));
});
}
// node_modules/rxjs/dist/esm5/internal/operators/mapTo.js
function Yt(e) {
return I(function() {
return e;
});
}
// node_modules/rxjs/dist/esm5/internal/operators/delayWhen.js
function Xt(e, t) {
return t ? function(n) {
return zt(t.pipe(qt(1), Jt()), n.pipe(Xt(e)));
} : It(function(t, n) {
return N(e(t, n)).pipe(qt(1), Yt(t));
});
}
// node_modules/rxjs/dist/esm5/internal/operators/delay.js
function Zt(e, t) {
t === void 0 && (t = Ze);
var n = Vt(e, t);
return Xt(function() {
return n;
});
}
// node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js
function Qt(e, t) {
return t === void 0 && (t = k), e ??= $t, j(function(n, r) {
var i, a = !0;
n.subscribe(M(r, function(n) {
var o = t(n);
(a || !e(i, o)) && (a = !1, i = o, r.next(n));
}));
});
}
function $t(e, t) {
return e === t;
}
// node_modules/rxjs/dist/esm5/internal/operators/throwIfEmpty.js
function en(e) {
return e === void 0 && (e = tn), j(function(t, n) {
var r = !1;
t.subscribe(M(n, function(e) {
r = !0, n.next(e);
}, function() {
return r ? n.complete() : n.error(e());
}));
});
}
function tn() {
return new Nt();
}
// node_modules/rxjs/dist/esm5/internal/operators/first.js
function nn(e, t) {
var n = arguments.length >= 2;
return function(r) {
return r.pipe(e ? Ut(function(t, n) {
return e(t, n, r);
}) : k, qt(1), n ? Kt(t) : en(function() {
return new Nt();
}));
};
}
// node_modules/rxjs/dist/esm5/internal/operators/scan.js
function rn(e, t) {
return j(Gt(e, t, arguments.length >= 2, !0));
}
// node_modules/rxjs/dist/esm5/internal/operators/share.js
function an(e) {
e === void 0 && (e = {});
var t = e.connector, n = t === void 0 ? function() {
return new Ue();
} : t, r = e.resetOnError, i = r === void 0 || r, a = e.resetOnComplete, o = a === void 0 || a, s = e.resetOnRefCountZero, c = s === void 0 || s;
return function(e) {
var t, r, a, s = 0, l = !1, u = !1, d = function() {
r?.unsubscribe(), r = void 0;
}, f = function() {
d(), t = a = void 0, l = u = !1;
}, p = function() {
var e = t;
f(), e?.unsubscribe();
};
return j(function(e, m) {
s++, !u && !l && d();
var h = a ??= n();
m.add(function() {
s--, s === 0 && !u && !l && (r = on(p, c));
}), h.subscribe(m), !t && s > 0 && (t = new D({
next: function(e) {
return h.next(e);
},
error: function(e) {
u = !0, d(), r = on(f, i, e), h.error(e);
},
complete: function() {
l = !0, d(), r = on(f, o), h.complete();
}
}), N(e).subscribe(t));
})(e);
};
}
function on(e, t) {
var n = [...arguments].slice(2);
if (t === !0) e();
else if (t !== !1) {
var r = new D({ next: function() {
r.unsubscribe(), e();
} });
return N(t.apply(void 0, y([], v(n)))).subscribe(r);
}
}
// node_modules/rxjs/dist/esm5/internal/operators/shareReplay.js
function sn(e, t, n) {
var r, i, a, o, s = !1;
return e && typeof e == "object" ? (r = e.bufferSize, o = r === void 0 ? Infinity : r, i = e.windowTime, t = i === void 0 ? Infinity : i, a = e.refCount, s = a !== void 0 && a, n = e.scheduler) : o = e ?? Infinity, an({
connector: function() {
return new Ke(o, t, n);
},
resetOnError: !0,
resetOnComplete: !1,
resetOnRefCountZero: s
});
}
// node_modules/rxjs/dist/esm5/internal/operators/switchMap.js
function cn(e, t) {
return j(function(n, r) {
var i = null, a = 0, o = !1, s = function() {
return o && !i && r.complete();
};
n.subscribe(M(r, function(n) {
i?.unsubscribe();
var o = 0, c = a++;
N(e(n, c)).subscribe(i = M(r, function(e) {
return r.next(t ? t(n, e, c, o++) : e);
}, function() {
i = null, s();
}));
}, function() {
o = !0, s();
}));
});
}
// node_modules/rxjs/dist/esm5/internal/operators/tap.js
function ln(e, t, n) {
var r = x(e) || t || n ? {
next: e,
error: t,
complete: n
} : e;
return r ? j(function(e, t) {
var n;
(n = r.subscribe) == null || n.call(r);
var i = !0;
e.subscribe(M(t, function(e) {
var n;
(n = r.next) == null || n.call(r, e), t.next(e);
}, function() {
var e;
i = !1, (e = r.complete) == null || e.call(r), t.complete();
}, function(e) {
var n;
i = !1, (n = r.error) == null || n.call(r, e), t.error(e);
}, function() {
var e, t;
i && ((e = r.unsubscribe) == null || e.call(r)), (t = r.finalize) == null || t.call(r);
}));
}) : k;
}
// node_modules/rxfire/auth/index.esm.js
function un(e) {
return new A(function(n) {
return { unsubscribe: t(e, n.next.bind(n), n.error.bind(n), n.complete.bind(n)) };
});
}
// src/telemetry.ts
var dn = "4.3.0", fn = !1;
function pn() {
try {
let t = n._components, r = e.version || "unknown";
if (t instanceof Map) {
t.has("react-version") || a("react", r), t.has("reactfire-version") || a("reactfire", dn);
return;
}
fn || (fn = !0, a("react", r), a("reactfire", dn));
} catch {}
}
pn();
// src/firebaseApp.tsx
var mn = "[DEFAULT]", hn = e.createContext(void 0), gn = e.createContext(!1), _n = (e, t) => e === t || [...Object.keys(e), ...Object.keys(t)].every((n) => e[n] === t[n]);
function vn(t) {
let { firebaseConfig: n, appName: a, suspense: o } = t, s = e.useMemo(() => {
if (pn(), t.firebaseApp) return t.firebaseApp;
let e = r().find((e) => e.name === (a || mn));
if (e) {
if (n && _n(e.options, n)) return e;
throw Error(`Does not match the options already provided to the ${a || "default"} firebase app instance, give this new instance a different appName.`);
}
if (!n) throw Error("No firebaseConfig provided");
return i(n, a);
}, [
t.firebaseApp,
n,
a
]);
return e.createElement(hn.Provider, { value: s }, e.createElement(gn.Provider, Object.assign({ value: o ?? !1 }, t)));
}
function yn() {
return e.useContext(gn) ?? !1;
}
function L(t) {
let n = e.useContext(gn);
return t === void 0 ? n : t;
}
function bn() {
let t = e.useContext(hn);
if (!t) throw Error("Cannot call useFirebaseApp unless your component is within a FirebaseAppProvider");
return t;
}
// src/auth.tsx
function xn(e) {
return de(this, void 0, void 0, function* () {
let t = yield e();
return U(un(t), `auth:user:${t.name}`).toPromise();
});
}
function Sn(e) {
let t = qr(), n = `auth:user:${t.name}`, r = un(t), i = Object.assign({}, e);
return t.currentUser && !("initialData" in i) && !("startWithValue" in i) && (i.initialData = t.currentUser), W(n, r, i);
}
function Cn(e, t = !1, n) {
if (!e) throw Error("you must provide a user");
return W(`auth:idTokenResult:${e.uid}:forceRefresh=${t}`, Bt(() => F(e.getIdTokenResult(t))), n);
}
function wn(e) {
if (e?.hasOwnProperty("requiredClaims") && e?.hasOwnProperty("validateCustomClaims")) throw Error("Cannot have both \"requiredClaims\" and \"validateCustomClaims\". Use one or the other.");
let t = qr(), n = `auth:signInCheck:${t.name}::forceRefresh:${!!e?.forceRefresh}`;
e?.forceRefresh && (n = `${n}:forceRefresh:${e.forceRefresh}`), e?.hasOwnProperty("requiredClaims") ? n = `${n}:requiredClaims:${JSON.stringify(e.requiredClaims)}` : e?.hasOwnProperty("validateCustomClaims") && (n = `${n}:validateCustomClaims:${JSON.stringify(e.validateCustomClaims)}`);
let r = un(t).pipe(cn((t) => t ? e && (e.hasOwnProperty("requiredClaims") || e.hasOwnProperty("validateCustomClaims")) ? F(t.getIdTokenResult(e?.forceRefresh ?? !1)).pipe(I((n) => {
let r;
r = e.hasOwnProperty("requiredClaims") ? Tn(e.requiredClaims) : e.validateCustomClaims;
let { hasRequiredClaims: i, errors: a } = r(n.claims);
return {
signedIn: !0,
hasRequiredClaims: i,
errors: a,
user: t
};
})) : Mt({
signedIn: !0,
hasRequiredClaims: !0,
errors: {},
user: t
}) : Mt({
signedIn: !1,
hasRequiredClaims: !1,
errors: {},
user: null
})));
return W(n, r, e);
}
function Tn(e) {
return function(t) {
let n = {};
return Object.keys(e).forEach((r) => {
e[r] !== t[r] && (n[r] = [new ui("auth/missing-claim", `Expected "${e[r]}", but user has "${t[r]}" instead`)]);
}), {
hasRequiredClaims: Object.keys(n).length === 0,
errors: n
};
};
}
function En({ user: t, fallback: n, children: r, requiredClaims: i }) {
let { data: a, status: o, error: s } = Cn(t, !1);
if (o === "loading") throw Error("ClaimsCheck must be run in Suspense mode");
if (o === "error") throw s;
let { claims: c } = a, l = {};
return L() || console.warn("ClaimsCheck is deprecated and only works when ReactFire is in experimental Suspense Mode. Use useSigninCheck or set suspense={true} in FirebaseAppProvider if you want to use this component."), i && Object.keys(i).forEach((e) => {
i[e] !== c[e] && (l[e] = {
expected: i[e],
actual: c[e]?.toString()
});
}), Object.keys(l).length === 0 ? e.createElement(e.Fragment, null, r) : e.createElement(e.Fragment, null, n);
}
function Dn({ fallback: t, children: n, requiredClaims: r }) {
let { data: i } = Sn();
return L() || console.warn("AuthCheck is deprecated and only works when ReactFire is in experimental Suspense Mode. Use useSigninCheck or set suspense={true} in FirebaseAppProvider if you want to use this component."), i ? r ? e.createElement(En, {
user: i,
fallback: t,
requiredClaims: r
}, n) : e.createElement(e.Fragment, null, n) : e.createElement(e.Fragment, null, t);
}
// node_modules/rxfire/database/index.esm.js
var R, z;
(function(e) {
e.added = "child_added", e.removed = "child_removed", e.changed = "child_changed", e.moved = "child_moved", e.value = "value";
})(z ||= {});
var On = Object.freeze((R = {}, R[z.added] = c, R[z.removed] = d, R[z.changed] = l, R[z.moved] = u, R[z.value] = f, R));
function kn(e, t) {
return new A(function(n) {
var r = On[t](e, function(e, r) {
n.next({
snapshot: e,
prevKey: r,
event: t
});
}, n.error.bind(n));
return { unsubscribe: function() {
s(e, t, r);
} };
}).pipe(Zt(0));
}
var B = function() {
return B = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n], t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}, B.apply(this, arguments);
};
function An(e, t, n) {
if (n || arguments.length === 2) for (var r = 0, i = t.length, a; r < i; r++) (a || !(r in t)) && (a ||= Array.prototype.slice.call(t, 0, r), a[r] = t[r]);
return e.concat(a || Array.prototype.slice.call(t));
}
function jn(e) {
return (e == null || e.length === 0) && (e = [
z.added,
z.removed,
z.changed,
z.moved
]), e;
}
function Mn(e) {
return kn(e, z.value);
}
function Nn(e, t) {
return t === void 0 && (t = {}), kn(e, z.value).pipe(I(function(e) {
return Pn(e, t);
}));
}
function Pn(e, t) {
var n;
t === void 0 && (t = {});
var r = e.snapshot.val();
return !e.snapshot.exists() || typeof r != "object" ? r : B(B({}, r), t.keyField ? (n = {}, n[t.keyField] = e.snapshot.key, n) : null);
}
function Fn(e) {
return F(o(e)).pipe(I(function(e) {
return {
snapshot: e,
prevKey: null,
event: z.value
};
}));
}
function In(e, t) {
t === void 0 && (t = {});
var n = jn(t.events);
return Fn(e).pipe(cn(function(t) {
var r = [Mt(t)];
return n.forEach(function(t) {
r.push(kn(e, t));
}), Ht.apply(void 0, r).pipe(rn(Bn, []));
}), Qt());
}
function Ln(e, t) {
return t === void 0 && (t = {}), In(e).pipe(I(function(e) {
return e.map(function(e) {
return Pn(e, t);
});
}));
}
function Rn(e, t) {
for (var n = e.length, r = 0; r < n; r++) if (e[r].snapshot.key === t) return r;
return -1;
}
function zn(e, t) {
if (t == null) return 0;
var n = Rn(e, t);
return n === -1 ? e.length : n + 1;
}
function Bn(e, t) {
var n = t.snapshot, r = t.prevKey, i = t.event, a = n.key, o = Rn(e, a), s = zn(e, r || void 0);
switch (i) {
case z.value:
if (t.snapshot && t.snapshot.exists()) {
var c = null;
t.snapshot.forEach(function(t) {
var n = {
snapshot: t,
event: z.value,
prevKey: c
};
return c = t.key, e = An(An([], e, !0), [n], !1), !1;
});
}
return e;
case z.added:
if (o > -1) {
var l = e[o - 1];
(l && l.snapshot.key || null) !== r && (e = e.filter(function(e) {
return e.snapshot.key !== n.key;
}), e.splice(s, 0, t));
} else if (r == null) return An([t], e, !0);
else e = e.slice(), e.splice(s, 0, t);
return e;
case z.removed: return e.filter(function(e) {
return e.snapshot.key !== n.key;
});
case z.changed: return e.map(function(e) {
return e.snapshot.key === a ? t : e;
});
case z.moved:
if (o > -1) {
var u = e.splice(o, 1)[0];
return e = e.slice(), e.splice(s, 0, u), e;
}
return e;
default: return e;
}
}
// src/database.tsx
var Vn = globalThis._reactFireDatabaseCachedQueries || [];
globalThis._reactFireDatabaseCachedQueries || (globalThis._reactFireDatabaseCachedQueries = Vn);
function Hn(e) {
let t = Vn.findIndex((t) => t.isEqual(e));
return t > -1 ? t : Vn.push(e) - 1;
}
function Un(e, t) {
return W(`database:object:${e.toString()}`, Mn(e), t);
}
function Wn(e, t) {
let n = t ? $(t) : void 0;
return W(`database:objectVal:${e.toString()}:idField=${JSON.stringify(n)}`, Nn(e, { keyField: n }), t);
}
function Gn(e, t) {
return W(`database:list:${Hn(e)}`, In(e), t);
}
function Kn(e, t) {
let n = t ? $(t) : void 0;
return W(`database:listVal:${Hn(e)}:idField=${JSON.stringify(n)}`, Ln(e, { keyField: n }), t);
}
// node_modules/rxfire/firestore/index.esm.js
var qn = { includeMetadataChanges: !1 };
function Jn(e, t) {
return t === void 0 && (t = qn), new A(function(n) {
return { unsubscribe: p(e, t, {
next: n.next.bind(n),
error: n.error.bind(n),
complete: n.complete.bind(n)
}) };
});
}
function V(e) {
return Jn(e, { includeMetadataChanges: !0 });
}
function Yn(e, t) {
return t === void 0 && (t = {}), V(e).pipe(I(function(e) {
return Xn(e, t);
}));
}
function Xn(e, t) {
var n;
t === void 0 && (t = {});
var r = e.data(t);
return e.exists() && typeof r == "object" && r && t.idField && Object.assign(r, (n = {}, n[t.idField] = e.id, n)), r;
}
function Zn(e) {
return Jn(e, { includeMetadataChanges: !0 }).pipe(I(function(e) {
return e.docs;
}));
}
function Qn(e, t) {
return t === void 0 && (t = {}), Zn(e).pipe(I(function(e) {
return e.map(function(e) {
return Xn(e, t);
});
}));
}
// src/SuspenseSubject.ts
var $n = class extends Ue {
constructor(e, t, n) {
super(), this._timeoutWindow = t, this._suspenseEnabled = n, this._hasValue = !1, this._error = void 0, this._isComplete = !1, this._firstEmission = new Promise((e) => this._resolveFirstEmission = e), this._immutableStatus = {
status: "loading",
hasEmitted: !1,
isComplete: !1,
data: void 0,
error: void 0,
firstValuePromise: this._firstEmission
}, this._innerObservable = e.pipe(ln({
next: (e) => {
this._next(e);
},
error: (e) => {
this._error = e, this._resolveFirstEmission(), this._updateImmutableStatus();
},
complete: () => {
this._isComplete = !0, this._updateImmutableStatus();
}
}), Wt(() => et()), sn(1)), this._warmupSubscription = this._innerObservable.subscribe(), this._timeoutHandler = this._suspenseEnabled ? setTimeout(() => {}, this._timeoutWindow) : setTimeout(this._reset.bind(this), this._timeoutWindow);
}
get hasValue() {
return this._hasValue || !!this._error;
}
get value() {
if (this._error) throw this._error;
if (!this.hasValue) throw Error("Can only get value if SuspenseSubject has a value");
return this._value;
}
get firstEmission() {
return this._firstEmission;
}
_updateImmutableStatus() {
this._immutableStatus = {
status: this._error ? "error" : this._hasValue ? "success" : "loading",
hasEmitted: this._hasValue,
isComplete: this._isComplete,
data: this._value,
error: this._error,
firstValuePromise: this._firstEmission
};
}
_next(e) {
this._hasValue = !0, this._value = e, this._resolveFirstEmission(), this._updateImmutableStatus();
}
_reset() {
this._warmupSubscription && this._warmupSubscription.unsubscribe(), this._hasValue = !1, this._value = void 0, this._error = void 0, this._firstEmission = new Promise((e) => this._resolveFirstEmission = e), this._updateImmutableStatus();
}
_subscribe(e) {
return this._timeoutHandler && clearTimeout(this._timeoutHandler), this._innerSubscriber = this._innerObservable.subscribe(e), this._innerSubscriber;
}
get ourError() {
return this._error;
}
get immutableStatus() {
return this._immutableStatus;
}
}, er = 3e4, H = globalThis._reactFirePreloadedObservables || /* @__PURE__ */ new Map();
globalThis._reactFirePreloadedObservables || (globalThis._reactFirePreloadedObservables = H);
function U(e, t, n = !1) {
if (H.has(t)) return H.get(t);
{
let r = new $n(e, er, n);
return H.set(t, r), r;
}
}
function W(t, n, r = {}) {
if (!t) throw Error("cannot call useObservable without an observableId");
pn();
let i = L(r.suspense), a = U(n, t, i), o = r.hasOwnProperty("initialData") || r.hasOwnProperty("startWithValue"), s = a.hasValue || o;
if (i === !0 && !s) throw a.firstEmission;
let c = e.useCallback((e) => {
let t = a.subscribe({
next: () => {
e();
},
error: (t) => {
throw e(), t;
},
complete: () => {
e();
}
});
return () => {
t.unsubscribe();
};
}, [a]), l = e.useCallback(() => a.immutableStatus, [a]), u = e.useRef(void 0), d = e.useCallback(() => {
if (u.current === void 0) {
let e = r?.initialData ?? r?.startWithValue;
u.current = {
status: o ? "success" : "loading",
hasEmitted: o,
isComplete: !1,
data: e,
error: void 0,
firstValuePromise: a.firstEmission
};
}
return u.current;
}, [a, o]), f = h(c, l, d);
if (!a.hasValue && s) {
let e = r?.initialData ?? r?.startWithValue;
if (i && f.error) throw f.error;
return Object.assign(Object.assign({}, f), {
data: e,
status: "success",
hasEmitted: !0
});
}
if (f.error) throw f.error;
return f;
}
// src/firestore.tsx
var tr = globalThis._reactFireFirestoreQueryCache || [];
globalThis._reactFireFirestoreQueryCache || (globalThis._reactFireFirestoreQueryCache = tr);
function nr(e) {
let t = tr.findIndex((t) => m(t, e));
return t > -1 ? t : tr.push(e) - 1;
}
function rr(e) {
return de(this, void 0, void 0, function* () {
let t = yield e();
return U(V(t), ir(t));
});
}
function ir(e) {
return `firestore:doc:${e.firestore.app.name}:${e.path}`;
}
function ar(e, t) {
return W(ir(e), V(e), t);
}
function or(e, t) {
return W(`firestore:docOnce:${e.firestore.app.name}:${e.path}`, V(e).pipe(nn()), t);
}
function sr(e, t) {
let n = t ? $(t) : void 0;
return W(`firestore:docData:${e.firestore.app.name}:${e.path}:idField=${JSON.stringify(n)}`, Yn(e, { idField: n }), t);
}
function cr(e, t) {
let n = t ? $(t) : void 0;
return W(`firestore:docDataOnce:${e.firestore.app.name}:${e.path}:idField=${JSON.stringify(n)}`, Yn(e, { idField: n }).pipe(nn()), t);
}
function lr(e, t) {
return W(`firestore:collection:${nr(e)}`, Jn(e), t);
}
function ur(e, t) {
let n = t ? $(t) : void 0;
return W(`firestore:collectionData:${nr(e)}:idField=${JSON.stringify(n)}`, Qn(e, { idField: n }), t);
}
// node_modules/rxfire/functions/index.esm.js
function dr(e, t, n) {
var r = ee(e, t, n);
return function(e) {
return F(r(e)).pipe(I(function(e) {
return e.data;
}));
};
}
// src/functions.tsx
function fr(e, t) {
let n = Zr(), r = `functions:callableResponse:${e}:${JSON.stringify(t?.data)}:${JSON.stringify(t?.httpsCallableOptions)}`, i = dr(n, e, t?.httpsCallableOptions);
return W(r, Bt(() => i(t?.data)), t);
}
// src/performance.tsx
function pr({ children: t, traceId: n, fallback: r }) {
let i = typeof globalThis < "u" ? globalThis.performance : void 0, a = (i?.getEntriesByName)?.call(i, n, "measure") || [], o = `_${n}Start[${a.length}]`, s = `_${n}End[${a.length}]`;
return e.createElement(e.Suspense, { fallback: e.createElement(() => (e.useEffect(() => {
var e;
return (e = i?.mark) == null || e.call(i, o), () => {
var e, t;
(e = i?.mark) == null || e.call(i, s), (t = i?.measure) == null || t.call(i, n, o, s);
};
}, []), e.createElement(e.Fragment, null, r)), null) }, t);
}
// node_modules/rxfire/remote-config/index.esm.js
function G(e) {
var t = e.remoteConfig, n = e.key, r = e.getter;
return new A(function(e) {
te(t).then(function() {
var i = r.bind(t);
e.next(i(t, n));
});
});
}
function mr(e, t) {
return G({
remoteConfig: e,
key: t,
getter: oe
});
}
function hr(e, t) {
return G({
remoteConfig: e,
key: t,
getter: ae
});
}
function gr(e, t) {
return G({
remoteConfig: e,
key: t,
getter: ie
});
}
function _r(e, t) {
return G({
remoteConfig: e,
key: t,
getter: re
});
}
function vr(e) {
return G({
remoteConfig: e,
key: "",
getter: ne
});
}
// src/remote-config.tsx
function K(e, t) {
let n = ei(), r = n.app.name, i = t(n, e);
return W(`remoteConfig:${e}:${t.name}:${r}`, i);
}
function yr(e) {
return K(e, mr);
}
function br(e) {
return K(e, hr);
}
function xr(e) {
return K(e, gr);
}
function Sr(e) {
return K(e, _r);
}
function Cr(e) {
return K(e, vr);
}
// node_modules/rxfire/storage/index.esm.js
function wr(e) {
return new A(function(t) {
var n = null, r = !1, i = !1, a = null, o = function(e) {
n = e, c();
}, s = null, c = function() {
s ||= setTimeout(function() {
s = null, n && t.next(n), r && t.complete(), i && t.error(a);
});
};
t.add(function() {
s && clearTimeout(s);
}), o(e.snapshot), t.add(e.on("state_changed", o)), t.add(F(e).subscribe({
next: o,
error: function(e) {
i = !0, a = e, c();
},
complete: function() {
r = !0, c();
}
}));
});
}
function Tr(e) {
return F(se(e));
}
// src/storage.tsx
function Er(e, t, n) {
return W(`storage:task:${t.toString()}`, wr(e), n);
}
function Dr(e, t) {
return W(`storage:downloadUrl:${e.toString()}`, Bt(() => Tr(e)), t);
}
function Or(t) {
let n = $r();
return t = Object.assign(Object.assign({}, t), { storage: n }), e.createElement(kr, Object.assign({}, t));
}
function kr(t) {
let { storage: n, storagePath: r, suspense: i, placeHolder: a } = t, o = ue(t, [
"storage",
"storagePath",
"suspense",
"placeHolder"
]), s = { suspense: L(i) };
if (!n) throw Error("Storage was not passed to component INTERNALStorageImage. This should not be possible");
let { status: c, data: l } = Dr(ce(n, r), s);
return c === "success" ? (o.alt || o.alt === "" || console.warn(`No alt prop provided for StorageImage with storagePath "${r}"`, "img elements must have an alt prop, either with meaningful text, or an empty string for decorative images"), e.createElement("img", Object.assign({
src: l,
alt: o.alt
}, o))) : a ?? e.createElement(e.Fragment, null, "''");
}
function Ar(t) {
let { storage: n } = t;
return n ? e.createElement(kr, Object.assign({}, t)) : e.createElement(Or, Object.assign({}, t));
}
// src/sdk.tsx
var q = e.createContext(void 0), J = e.createContext(void 0), Y = e.createContext(void 0), jr = e.createContext(void 0), Mr = e.createContext(void 0), Nr = e.createContext(void 0), Pr = e.createContext(void 0), Fr = e.createContext(void 0), Ir = e.createContext(void 0);
function X(t) {
return function(n) {
if (!n.sdk) throw Error("no sdk provided");
let r = bn().name;
if (n?.sdk?.app?.name !== r) throw Error("sdk was initialized with a different firebase app");
return e.createElement(t.Provider, Object.assign({ value: n.sdk }, n));
};
}
function Z(t) {
let n = e.useContext(t);
if (!n) throw Error("SDK not found. useSdk must be called from within a provider");
return n;
}
function Q(t, n, r, i) {
let a = bn();
if (e.useContext(n)) throw Error(`Cannot initialize SDK ${t} because it already exists in Context`);
let o = e.useMemo(() => r(a), [a]);
return W(`firebase-sdk:${t}:${a.name}`, F(o), i);
}
var Lr = X(q), Rr = X(J), zr = X(Y), Br = X(jr), Vr = X(Mr), Hr = X(Nr), Ur = X(Fr), Wr = X(Pr), Gr = X(Ir), Kr = () => Z(q), qr = () => Z(J), Jr = () => Z(Y), Yr = () => Z(jr), Xr = () => Z(Mr), Zr = () => Z(Nr), Qr = () => Z(Fr), $r = () => Z(Pr), ei = () => Z(Ir), ti = (e, t) => Q("appcheck", q, e, t), ni = (e, t) => Q("auth", J, e, t), ri = (e, t) => Q("analytics", Y, e, t), ii = (e, t) => Q("database", jr, e, t), ai = (e, t) => Q("firestore", Mr, e, t), oi = (e, t) => Q("functions", Nr, e, t), si = (e, t) => Q("performance", Fr, e, t), ci = (e, t) => Q("remoteconfig", Ir, e, t), li = (e, t) => Q("storage", Pr, e, t), ui = class e extends Error {
constructor(t, n, r) {
super(n), this.code = t, this.customData = r, this.name = "ReactFireError", Object.setPrototypeOf(this, e.prototype);
}
};
function di(e, t) {
if (t === "idField" || t === "initialData" || t === "suspense") return e ? e[t] : void 0;
throw Error(`Field "${t}" is not a valid key in ReactFireOptions`);
}
function fi(e) {
return di(e, "initialData");
}
function $(e) {
return di(e, "idField");
}
export { zr as AnalyticsProvider, Y as AnalyticsSdkContext, Lr as AppCheckProvider, q as AppCheckSdkContext, Dn as AuthCheck, Rr as AuthProvider, J as AuthSdkContext, En as ClaimsCheck, Br as DatabaseProvider, jr as DatabaseSdkContext, vn as FirebaseAppProvider, Vr as FirestoreProvider, Mr as FirestoreSdkContext, Hr as FunctionsProvider, Nr as FunctionsSdkContext, Ur as PerformanceProvider, Fr as PerformanceSdkContext, ui as ReactFireError, Gr as RemoteConfigProvider, Ir as RemoteConfigSdkContext, Ar as StorageImage, Wr as StorageProvider, Pr as StorageSdkContext, pr as SuspenseWithPerf, $ as checkIdField, di as checkOptions, fi as checkinitialData, rr as preloadFirestoreDoc, U as preloadObservable, xn as preloadUser, Jr as useAnalytics, Kr as useAppCheck, qr as useAuth, fr as useCallableFunctionResponse, Yr as useDatabase, Gn as useDatabaseList, Kn as useDatabaseListData, Un as useDatabaseObject, Wn as useDatabaseObjectData, bn as useFirebaseApp, Xr as useFirestore, lr as useFirestoreCollection, ur as useFirestoreCollectionData, ar as useFirestoreDoc, sr as useFirestoreDocData, cr as useFirestoreDocDataOnce, or as useFirestoreDocOnce, Zr as useFunctions, Cn as useIdTokenResult, ri as useInitAnalytics, ti as useInitAppCheck, ni as useInitAuth, ii as useInitDatabase, ai as useInitFirestore, oi as useInitFunctions, si as useInitPerformance, ci as useInitRemoteConfig, li as useInitStorage, yn as useIsSuspenseEnabled, W as useObservable, Qr as usePerformance, ei as useRemoteConfig, Cr as useRemoteConfigAll, Sr as useRemoteConfigBoolean, xr as useRemoteConfigNumber, br as useRemoteConfigString, yr as useRemoteConfigValue, wn as useSigninCheck, $r as useStorage, Dr as useStorageDownloadURL, Er as useStorageTask, L as useSuspenseEnabledFromConfigAndContext, Sn as useUser, dn as version };
//# sourceMappingURL=index.js.map