var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [0, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
/*! Built with http://stenciljs.com */
webcomponents.loadBundle("chunk-c8b7cc84.js", ["exports", "./chunk-6409091d.js", "./chunk-31baaa34.js"], function (t, e, r) { window.webcomponents.h; var n = function (t, e) { return (n = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (t, e) { t.__proto__ = e; } || function (t, e) { for (var r in e)
    e.hasOwnProperty(r) && (t[r] = e[r]); })(t, e); }; function o(t, e) { function r() { this.constructor = t; } n(t, e), t.prototype = null === e ? Object.create(e) : (r.prototype = e.prototype, new r); } var i, s = { e: {} }; function u() { try {
    return i.apply(this, arguments);
}
catch (t) {
    return s.e = t, s;
} } function c(t) { return i = t, u; } function a(t) { return "function" == typeof t; } var h = !1, p = { Promise: void 0, set useDeprecatedSynchronousErrorHandling(t) { t && (new Error).stack, h = t; }, get useDeprecatedSynchronousErrorHandling() { return h; } }; function l(t) { setTimeout(function () { throw t; }); } var f = { closed: !0, next: function (t) { }, error: function (t) { if (p.useDeprecatedSynchronousErrorHandling)
        throw t; l(t); }, complete: function () { } }, d = Array.isArray || function (t) { return t && "number" == typeof t.length; }; function b(t) { return null != t && "object" == typeof t; } var y = function (t) { function e(r) { var n = t.call(this, r ? r.length + " errors occurred during unsubscription:\n  " + r.map(function (t, e) { return e + 1 + ") " + t.toString(); }).join("\n  ") : "") || this; return n.errors = r, n.name = "UnsubscriptionError", Object.setPrototypeOf(n, e.prototype), n; } return o(e, t), e; }(Error), v = function () { function t(t) { this.closed = !1, this._parent = null, this._parents = null, this._subscriptions = null, t && (this._unsubscribe = t); } var e; return t.prototype.unsubscribe = function () { var t, e = !1; if (!this.closed) {
    var r = this._parent, n = this._parents, o = this._unsubscribe, i = this._subscriptions;
    this.closed = !0, this._parent = null, this._parents = null, this._subscriptions = null;
    for (var u = -1, h = n ? n.length : 0; r;)
        r.remove(this), r = ++u < h && n[u] || null;
    if (a(o) && c(o).call(this) === s && (e = !0, t = t || (s.e instanceof y ? w(s.e.errors) : [s.e])), d(i))
        for (u = -1, h = i.length; ++u < h;) {
            var p = i[u];
            if (b(p) && c(p.unsubscribe).call(p) === s) {
                e = !0, t = t || [];
                var l = s.e;
                l instanceof y ? t = t.concat(w(l.errors)) : t.push(l);
            }
        }
    if (e)
        throw new y(t);
} }, t.prototype.add = function (e) { if (!e || e === t.EMPTY)
    return t.EMPTY; if (e === this)
    return this; var r = e; switch (typeof e) {
    case "function": r = new t(e);
    case "object":
        if (r.closed || "function" != typeof r.unsubscribe)
            return r;
        if (this.closed)
            return r.unsubscribe(), r;
        if ("function" != typeof r._addParent) {
            var n = r;
            (r = new t)._subscriptions = [n];
        }
        break;
    default: throw new Error("unrecognized teardown " + e + " added to Subscription.");
} return (this._subscriptions || (this._subscriptions = [])).push(r), r._addParent(this), r; }, t.prototype.remove = function (t) { var e = this._subscriptions; if (e) {
    var r = e.indexOf(t);
    -1 !== r && e.splice(r, 1);
} }, t.prototype._addParent = function (t) { var e = this._parent, r = this._parents; e && e !== t ? r ? -1 === r.indexOf(t) && r.push(t) : this._parents = [t] : this._parent = t; }, t.EMPTY = ((e = new t).closed = !0, e), t; }(); function w(t) { return t.reduce(function (t, e) { return t.concat(e instanceof y ? e.errors : e); }, []); } var m = "function" == typeof Symbol && "function" == typeof Symbol.for ? Symbol.for("rxSubscriber") : "@@rxSubscriber", _ = function (t) { function e(e, r, n) { var o = t.call(this) || this; switch ((o.syncErrorValue = null, o.syncErrorThrown = !1, o.syncErrorThrowable = !1, o.isStopped = !1, arguments.length)) {
    case 0:
        o.destination = f;
        break;
    case 1:
        if (!e) {
            o.destination = f;
            break;
        }
        if ("object" == typeof e) {
            if (E(e)) {
                var i = e[m]();
                o.syncErrorThrowable = i.syncErrorThrowable, o.destination = i, i.add(o);
            }
            else
                o.syncErrorThrowable = !0, o.destination = new g(o, e);
            break;
        }
    default: o.syncErrorThrowable = !0, o.destination = new g(o, e, r, n);
} return o; } return o(e, t), e.prototype[m] = function () { return this; }, e.create = function (t, r, n) { var o = new e(t, r, n); return o.syncErrorThrowable = !1, o; }, e.prototype.next = function (t) { this.isStopped || this._next(t); }, e.prototype.error = function (t) { this.isStopped || (this.isStopped = !0, this._error(t)); }, e.prototype.complete = function () { this.isStopped || (this.isStopped = !0, this._complete()); }, e.prototype.unsubscribe = function () { this.closed || (this.isStopped = !0, t.prototype.unsubscribe.call(this)); }, e.prototype._next = function (t) { this.destination.next(t); }, e.prototype._error = function (t) { this.destination.error(t), this.unsubscribe(); }, e.prototype._complete = function () { this.destination.complete(), this.unsubscribe(); }, e.prototype._unsubscribeAndRecycle = function () { var t = this._parent, e = this._parents; return this._parent = null, this._parents = null, this.unsubscribe(), this.closed = !1, this.isStopped = !1, this._parent = t, this._parents = e, this; }, e; }(v), g = function (t) { function e(e, r, n, o) { var i, s = t.call(this) || this; s._parentSubscriber = e; var u = s; return a(r) ? i = r : r && (i = r.next, n = r.error, o = r.complete, r !== f && (a((u = Object.create(r)).unsubscribe) && s.add(u.unsubscribe.bind(u)), u.unsubscribe = s.unsubscribe.bind(s))), s._context = u, s._next = i, s._error = n, s._complete = o, s; } return o(e, t), e.prototype.next = function (t) { if (!this.isStopped && this._next) {
    var e = this._parentSubscriber;
    p.useDeprecatedSynchronousErrorHandling && e.syncErrorThrowable ? this.__tryOrSetError(e, this._next, t) && this.unsubscribe() : this.__tryOrUnsub(this._next, t);
} }, e.prototype.error = function (t) { if (!this.isStopped) {
    var e = this._parentSubscriber, r = p.useDeprecatedSynchronousErrorHandling;
    if (this._error)
        r && e.syncErrorThrowable ? (this.__tryOrSetError(e, this._error, t), this.unsubscribe()) : (this.__tryOrUnsub(this._error, t), this.unsubscribe());
    else if (e.syncErrorThrowable)
        r ? (e.syncErrorValue = t, e.syncErrorThrown = !0) : l(t), this.unsubscribe();
    else {
        if (this.unsubscribe(), r)
            throw t;
        l(t);
    }
} }, e.prototype.complete = function () { var t = this; if (!this.isStopped) {
    var e = this._parentSubscriber;
    if (this._complete) {
        var r = function () { return t._complete.call(t._context); };
        p.useDeprecatedSynchronousErrorHandling && e.syncErrorThrowable ? (this.__tryOrSetError(e, r), this.unsubscribe()) : (this.__tryOrUnsub(r), this.unsubscribe());
    }
    else
        this.unsubscribe();
} }, e.prototype.__tryOrUnsub = function (t, e) { try {
    t.call(this._context, e);
}
catch (t) {
    if (this.unsubscribe(), p.useDeprecatedSynchronousErrorHandling)
        throw t;
    l(t);
} }, e.prototype.__tryOrSetError = function (t, e, r) { if (!p.useDeprecatedSynchronousErrorHandling)
    throw new Error("bad call"); try {
    e.call(this._context, r);
}
catch (e) {
    return p.useDeprecatedSynchronousErrorHandling ? (t.syncErrorValue = e, t.syncErrorThrown = !0, !0) : (l(e), !0);
} return !1; }, e.prototype._unsubscribe = function () { var t = this._parentSubscriber; this._context = null, this._parentSubscriber = null, t.unsubscribe(); }, e; }(_); function E(t) { return t instanceof _ || "syncErrorThrowable" in t && t[m]; } var x = function (t) { function e() { return null !== t && t.apply(this, arguments) || this; } return o(e, t), e.prototype.notifyNext = function (t, e, r, n, o) { this.destination.next(e); }, e.prototype.notifyError = function (t, e) { this.destination.error(t); }, e.prototype.notifyComplete = function (t) { this.destination.complete(); }, e; }(_), S = function (t) { function e(e, r, n) { var o = t.call(this) || this; return o.parent = e, o.outerValue = r, o.outerIndex = n, o.index = 0, o; } return o(e, t), e.prototype._next = function (t) { this.parent.notifyNext(this.outerValue, t, this.outerIndex, this.index++, this); }, e.prototype._error = function (t) { this.parent.notifyError(t, this), this.unsubscribe(); }, e.prototype._complete = function () { this.parent.notifyComplete(this), this.unsubscribe(); }, e; }(_), T = "function" == typeof Symbol && Symbol.observable || "@@observable"; function O() { } var j = function () { function t(t) { this._isScalar = !1, t && (this._subscribe = t); } return t.prototype.lift = function (e) { var r = new t; return r.source = this, r.operator = e, r; }, t.prototype.subscribe = function (t, e, r) { var n = this.operator, o = function (t, e, r) { if (t) {
    if (t instanceof _)
        return t;
    if (t[m])
        return t[m]();
} return t || e || r ? new _(t, e, r) : new _(f); }(t, e, r); if (n ? n.call(o, this.source) : o.add(this.source || p.useDeprecatedSynchronousErrorHandling && !o.syncErrorThrowable ? this._subscribe(o) : this._trySubscribe(o)), p.useDeprecatedSynchronousErrorHandling && o.syncErrorThrowable && (o.syncErrorThrowable = !1, o.syncErrorThrown))
    throw o.syncErrorValue; return o; }, t.prototype._trySubscribe = function (t) { try {
    return this._subscribe(t);
}
catch (e) {
    p.useDeprecatedSynchronousErrorHandling && (t.syncErrorThrown = !0, t.syncErrorValue = e), t.error(e);
} }, t.prototype.forEach = function (t, e) { var r = this; return new (e = D(e))(function (e, n) { var o; o = r.subscribe(function (e) { try {
    t(e);
}
catch (t) {
    n(t), o && o.unsubscribe();
} }, n, e); }); }, t.prototype._subscribe = function (t) { var e = this.source; return e && e.subscribe(t); }, t.prototype[T] = function () { return this; }, t.prototype.pipe = function () { for (var t, e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r]; return 0 === e.length ? this : ((t = e) ? 1 === t.length ? t[0] : function (e) { return t.reduce(function (t, e) { return e(t); }, e); } : O)(this); }, t.prototype.toPromise = function (t) { var e = this; return new (t = D(t))(function (t, r) { var n; e.subscribe(function (t) { return n = t; }, function (t) { return r(t); }, function () { return t(n); }); }); }, t.create = function (e) { return new t(e); }, t; }(); function D(t) { if (t || (t = p.Promise || Promise), !t)
    throw new Error("no Promise impl found"); return t; } var I = function (t) { return function (e) { for (var r = 0, n = t.length; r < n && !e.closed; r++)
    e.next(t[r]); e.closed || e.complete(); }; }, A = function (t) { return function (e) { return t.then(function (t) { e.closed || (e.next(t), e.complete()); }, function (t) { return e.error(t); }).then(null, l), e; }; }, N = function () { return "function" == typeof Symbol && Symbol.iterator ? Symbol.iterator : "@@iterator"; }(), C = function (t) { return function (e) { for (var r = t[N]();;) {
    var n = r.next();
    if (n.done) {
        e.complete();
        break;
    }
    if (e.next(n.value), e.closed)
        break;
} return "function" == typeof r.return && e.add(function () { r.return && r.return(); }), e; }; }, P = function (t) { return function (e) { var r = t[T](); if ("function" != typeof r.subscribe)
    throw new TypeError("Provided object does not correctly implement Symbol.observable"); return r.subscribe(e); }; }, H = function (t) { return t && "number" == typeof t.length && "function" != typeof t; }; function U(t) { return t && "function" != typeof t.subscribe && "function" == typeof t.then; } var L = function (t) { if (t instanceof j)
    return function (e) { return t._isScalar ? (e.next(t.value), void e.complete()) : t.subscribe(e); }; if (t && "function" == typeof t[T])
    return P(t); if (H(t))
    return I(t); if (U(t))
    return A(t); if (t && "function" == typeof t[N])
    return C(t); var e = b(t) ? "an invalid object" : "'" + t + "'"; throw new TypeError("You provided " + e + " where a stream was expected. You can provide an Observable, Promise, Array, or Iterable."); }; var R = function (t) { function e(e, r) { var n = t.call(this, e, r) || this; return n.scheduler = e, n.work = r, n.pending = !1, n; } return o(e, t), e.prototype.schedule = function (t, e) { if (void 0 === e && (e = 0), this.closed)
    return this; this.state = t; var r = this.id, n = this.scheduler; return null != r && (this.id = this.recycleAsyncId(n, r, e)), this.pending = !0, this.delay = e, this.id = this.id || this.requestAsyncId(n, this.id, e), this; }, e.prototype.requestAsyncId = function (t, e, r) { return void 0 === r && (r = 0), setInterval(t.flush.bind(t, this), r); }, e.prototype.recycleAsyncId = function (t, e, r) { if (void 0 === r && (r = 0), null !== r && this.delay === r && !1 === this.pending)
    return e; clearInterval(e); }, e.prototype.execute = function (t, e) { if (this.closed)
    return new Error("executing a cancelled action"); this.pending = !1; var r = this._execute(t, e); if (r)
    return r; !1 === this.pending && null != this.id && (this.id = this.recycleAsyncId(this.scheduler, this.id, null)); }, e.prototype._execute = function (t, e) { var r = !1, n = void 0; try {
    this.work(t);
}
catch (t) {
    r = !0, n = !!t && t || new Error(t);
} if (r)
    return this.unsubscribe(), n; }, e.prototype._unsubscribe = function () { var t = this.id, e = this.scheduler, r = e.actions, n = r.indexOf(this); this.work = null, this.state = null, this.pending = !1, this.scheduler = null, -1 !== n && r.splice(n, 1), null != t && (this.id = this.recycleAsyncId(e, t, null)), this.delay = null; }, e; }(function (t) { function e(e, r) { return t.call(this) || this; } return o(e, t), e.prototype.schedule = function (t, e) { return void 0 === e && (e = 0), this; }, e; }(v)), q = function () { function t(e, r) { void 0 === r && (r = t.now), this.SchedulerAction = e, this.now = r; } return t.prototype.schedule = function (t, e, r) { return void 0 === e && (e = 0), new this.SchedulerAction(this, t).schedule(r, e); }, t.now = function () { return Date.now(); }, t; }(), k = new (function (t) { function e(r, n) { void 0 === n && (n = q.now); var o = t.call(this, r, function () { return e.delegate && e.delegate !== o ? e.delegate.now() : n(); }) || this; return o.actions = [], o.active = !1, o.scheduled = void 0, o; } return o(e, t), e.prototype.schedule = function (r, n, o) { return void 0 === n && (n = 0), e.delegate && e.delegate !== this ? e.delegate.schedule(r, n, o) : t.prototype.schedule.call(this, r, n, o); }, e.prototype.flush = function (t) { var e = this.actions; if (this.active)
    e.push(t);
else {
    var r;
    this.active = !0;
    do {
        if (r = t.execute(t.state, t.delay))
            break;
    } while (t = e.shift());
    if (this.active = !1, r) {
        for (; t = e.shift();)
            t.unsubscribe();
        throw r;
    }
} }, e; }(q))(R); function F(t) { return t && "function" == typeof t.schedule; } function G(t, e) { return new j(e ? function (r) { var n = new v, o = 0; return n.add(e.schedule(function () { o !== t.length ? (r.next(t[o++]), r.closed || n.add(this.schedule())) : r.complete(); })), n; } : I(t)); } function M(t, e) { if (!e)
    return t instanceof j ? t : new j(L(t)); if (null != t) {
    if (function (t) { return t && "function" == typeof t[T]; }(t))
        return function (t, e) { return new j(e ? function (r) { var n = new v; return n.add(e.schedule(function () { var o = t[T](); n.add(o.subscribe({ next: function (t) { n.add(e.schedule(function () { return r.next(t); })); }, error: function (t) { n.add(e.schedule(function () { return r.error(t); })); }, complete: function () { n.add(e.schedule(function () { return r.complete(); })); } })); })), n; } : P(t)); }(t, e);
    if (U(t))
        return function (t, e) { return new j(e ? function (r) { var n = new v; return n.add(e.schedule(function () { return t.then(function (t) { n.add(e.schedule(function () { r.next(t), n.add(e.schedule(function () { return r.complete(); })); })); }, function (t) { n.add(e.schedule(function () { return r.error(t); })); }); })), n; } : A(t)); }(t, e);
    if (H(t))
        return G(t, e);
    if (function (t) { return t && "function" == typeof t[N]; }(t) || "string" == typeof t)
        return function (t, e) { if (!t)
            throw new Error("Iterable cannot be null"); return new j(e ? function (r) { var n, o = new v; return o.add(function () { n && "function" == typeof n.return && n.return(); }), o.add(e.schedule(function () { n = t[N](), o.add(e.schedule(function () { if (!r.closed) {
            var t, e;
            try {
                var o = n.next();
                t = o.value, e = o.done;
            }
            catch (t) {
                return void r.error(t);
            }
            e ? r.complete() : (r.next(t), this.schedule());
        } })); })), o; } : C(t)); }(t, e);
} throw new TypeError((null !== t && typeof t || t) + " is not observable"); } var X = new j(function (t) { return t.complete(); }); function V(t) { return t ? function (t) { return new j(function (e) { return t.schedule(function () { return e.complete(); }); }); }(t) : X; } function Y(t) { var e = new j(function (e) { e.next(t), e.complete(); }); return e._isScalar = !0, e.value = t, e; } function B(t, e) { return function (r) { if ("function" != typeof t)
    throw new TypeError("argument is not a function. Are you looking for `mapTo()`?"); return r.lift(new J(t, e)); }; } var J = function () { function t(t, e) { this.project = t, this.thisArg = e; } return t.prototype.call = function (t, e) { return e.subscribe(new W(t, this.project, this.thisArg)); }, t; }(), W = function (t) { function e(e, r, n) { var o = t.call(this, e) || this; return o.project = r, o.count = 0, o.thisArg = n || o, o; } return o(e, t), e.prototype._next = function (t) { var e; try {
    e = this.project.call(this.thisArg, t, this.count++);
}
catch (t) {
    return void this.destination.error(t);
} this.destination.next(e); }, e; }(_); function $(t, e, r) { return void 0 === r && (r = Number.POSITIVE_INFINITY), "function" == typeof e ? function (n) { return n.pipe($(function (r, n) { return M(t(r, n)).pipe(B(function (t, o) { return e(r, t, n, o); })); }, r)); } : ("number" == typeof e && (r = e), function (e) { return e.lift(new z(t, r)); }); } var z = function () { function t(t, e) { void 0 === e && (e = Number.POSITIVE_INFINITY), this.project = t, this.concurrent = e; } return t.prototype.call = function (t, e) { return e.subscribe(new K(t, this.project, this.concurrent)); }, t; }(), K = function (t) { function e(e, r, n) { void 0 === n && (n = Number.POSITIVE_INFINITY); var o = t.call(this, e) || this; return o.project = r, o.concurrent = n, o.hasCompleted = !1, o.buffer = [], o.active = 0, o.index = 0, o; } return o(e, t), e.prototype._next = function (t) { this.active < this.concurrent ? this._tryNext(t) : this.buffer.push(t); }, e.prototype._tryNext = function (t) { var e, r = this.index++; try {
    e = this.project(t, r);
}
catch (t) {
    return void this.destination.error(t);
} this.active++, this._innerSub(e, t, r); }, e.prototype._innerSub = function (t, e, r) { var n, o; this.add((n = t, o = new S(this, e, r), L(n)(o))); }, e.prototype._complete = function () { this.hasCompleted = !0, 0 === this.active && 0 === this.buffer.length && this.destination.complete(); }, e.prototype.notifyNext = function (t, e, r, n, o) { this.destination.next(e); }, e.prototype.notifyComplete = function (t) { var e = this.buffer; this.remove(t), this.active--, e.length > 0 ? this._next(e.shift()) : 0 === this.active && this.hasCompleted && this.destination.complete(); }, e; }(x); function Q(t) { return t; } function Z() { return void 0 === (t = 1) && (t = Number.POSITIVE_INFINITY), $(Q, t); var t; } function tt() { for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e]; return 1 === t.length || 2 === t.length && F(t[1]) ? M(t[0]) : Z()(function () { for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e]; var r = t[t.length - 1]; switch (F(r) ? t.pop() : r = void 0, t.length) {
    case 0: return V(r);
    case 1: return r ? G(t, r) : Y(t[0]);
    default: return G(t, r);
} }.apply(void 0, t)); } Error; var et = function () { function t(t, e, r) { this.nextOrObserver = t, this.error = e, this.complete = r; } return t.prototype.call = function (t, e) { return e.subscribe(new rt(t, this.nextOrObserver, this.error, this.complete)); }, t; }(), rt = function (t) { function e(e, r, n, o) { var i = t.call(this, e) || this; return i._tapNext = O, i._tapError = O, i._tapComplete = O, i._tapError = n || O, i._tapComplete = o || O, a(r) ? (i._context = i, i._tapNext = r) : r && (i._context = r, i._tapNext = r.next || O, i._tapError = r.error || O, i._tapComplete = r.complete || O), i; } return o(e, t), e.prototype._next = function (t) { try {
    this._tapNext.call(this._context, t);
}
catch (t) {
    return void this.destination.error(t);
} this.destination.next(t); }, e.prototype._error = function (t) { try {
    this._tapError.call(this._context, t);
}
catch (t) {
    return void this.destination.error(t);
} this.destination.error(t); }, e.prototype._complete = function () { try {
    this._tapComplete.call(this._context);
}
catch (t) {
    return void this.destination.error(t);
} return this.destination.complete(); }, e; }(_), nt = (Error, function (t) { function e() { var r = t.call(this, "object unsubscribed") || this; return r.name = "ObjectUnsubscribedError", Object.setPrototypeOf(r, e.prototype), r; } return o(e, t), e; }(Error)), ot = function (t) { function e(e, r) { var n = t.call(this) || this; return n.subject = e, n.subscriber = r, n.closed = !1, n; } return o(e, t), e.prototype.unsubscribe = function () { if (!this.closed) {
    this.closed = !0;
    var t = this.subject, e = t.observers;
    if (this.subject = null, e && 0 !== e.length && !t.isStopped && !t.closed) {
        var r = e.indexOf(this.subscriber);
        -1 !== r && e.splice(r, 1);
    }
} }, e; }(v), it = function (t) { function e(e) { var r = t.call(this, e) || this; return r.destination = e, r; } return o(e, t), e; }(_), st = function (t) { function e() { var e = t.call(this) || this; return e.observers = [], e.closed = !1, e.isStopped = !1, e.hasError = !1, e.thrownError = null, e; } return o(e, t), e.prototype[m] = function () { return new it(this); }, e.prototype.lift = function (t) { var e = new ut(this, this); return e.operator = t, e; }, e.prototype.next = function (t) { if (this.closed)
    throw new nt; if (!this.isStopped)
    for (var e = this.observers, r = e.length, n = e.slice(), o = 0; o < r; o++)
        n[o].next(t); }, e.prototype.error = function (t) { if (this.closed)
    throw new nt; this.hasError = !0, this.thrownError = t, this.isStopped = !0; for (var e = this.observers, r = e.length, n = e.slice(), o = 0; o < r; o++)
    n[o].error(t); this.observers.length = 0; }, e.prototype.complete = function () { if (this.closed)
    throw new nt; this.isStopped = !0; for (var t = this.observers, e = t.length, r = t.slice(), n = 0; n < e; n++)
    r[n].complete(); this.observers.length = 0; }, e.prototype.unsubscribe = function () { this.isStopped = !0, this.closed = !0, this.observers = null; }, e.prototype._trySubscribe = function (e) { if (this.closed)
    throw new nt; return t.prototype._trySubscribe.call(this, e); }, e.prototype._subscribe = function (t) { if (this.closed)
    throw new nt; return this.hasError ? (t.error(this.thrownError), v.EMPTY) : this.isStopped ? (t.complete(), v.EMPTY) : (this.observers.push(t), new ot(this, t)); }, e.prototype.asObservable = function () { var t = new j; return t.source = this, t; }, e.create = function (t, e) { return new ut(t, e); }, e; }(j), ut = function (t) { function e(e, r) { var n = t.call(this) || this; return n.destination = e, n.source = r, n; } return o(e, t), e.prototype.next = function (t) { var e = this.destination; e && e.next && e.next(t); }, e.prototype.error = function (t) { var e = this.destination; e && e.error && this.destination.error(t); }, e.prototype.complete = function () { var t = this.destination; t && t.complete && this.destination.complete(); }, e.prototype._subscribe = function (t) { return this.source ? this.source.subscribe(t) : v.EMPTY; }, e; }(st), ct = function () { function t(t, e, r) { void 0 === r && (r = !1), this.accumulator = t, this.seed = e, this.hasSeed = r; } return t.prototype.call = function (t, e) { return e.subscribe(new at(t, this.accumulator, this.seed, this.hasSeed)); }, t; }(), at = function (t) { function e(e, r, n, o) { var i = t.call(this, e) || this; return i.accumulator = r, i._seed = n, i.hasSeed = o, i.index = 0, i; } return o(e, t), Object.defineProperty(e.prototype, "seed", { get: function () { return this._seed; }, set: function (t) { this.hasSeed = !0, this._seed = t; }, enumerable: !0, configurable: !0 }), e.prototype._next = function (t) { if (this.hasSeed)
    return this._tryNext(t); this.seed = t, this.destination.next(t); }, e.prototype._tryNext = function (t) { var e, r = this.index++; try {
    e = this.accumulator(this.seed, t, r);
}
catch (t) {
    this.destination.error(t);
} this.seed = e, this.destination.next(e); }, e; }(_); function ht(t) { var e = t.subscriber, r = t.counter, n = t.period; e.next(r), this.schedule({ subscriber: e, counter: r + 1, period: n }, n); } Error;
    var pt = /** @class */ (function () {
        function pt() {
        }
        pt.isObservable = function (t) { return t instanceof j; };
        pt.log = function () { return console.log.bind(console); };
        return pt;
    }());  var lt = new st, ft = function (t, r) {
    if (r === void 0) { r = { timestamp: e.Util.getTimeStamp() }; }
    return lt.pipe($(function (t) { return pt.isObservable(t) ? t : M([t]); }), function () { for (var t = [], e = 0; e < arguments.length; e++)
        t[e] = arguments[e]; return function (e) { var r = t[t.length - 1]; F(r) ? t.pop() : r = null; var n = t.length; return tt(1 !== n || r ? n > 0 ? G(t, r) : V(r) : Y(t[0]), e); }; }(r), function (t, e) { var r = !1; return arguments.length >= 2 && (r = !0), function (n) { return n.lift(new ct(t, e, r)); }; }(t));
}, dt = function (t) { return function () {
    var e = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        e[_i] = arguments[_i];
    }
    var r = t.call.apply(t, [null].concat(e));
    return lt.next(r), pt.isObservable(r.payload) && lt.next(r.payload), r;
}; }; function bt(t, r) { switch (r.type) {
    case "CONFIG_LOADING": return Object.assign({}, t, { isLoading: !0, timestamp: e.Util.getTimeStamp() });
    case "CONFIG_LOADED":
        var n_1 = Object.assign({}, t, { isLoading: !1 });
        return Object.keys(r.payload).forEach(function (t) { n_1[t] = r.payload[t]; }), n_1.timestamp = e.Util.getTimeStamp(), n_1;
    case "ADD_CONFIG":
        var o_1 = Object.assign({}, t);
        return Object.keys(r.payload).forEach(function (t) { o_1[t] = r.payload[t]; }), o_1.timestamp = e.Util.getTimeStamp(), o_1;
    default: return t;
} } var yt = "undefined" != typeof window && window, vt = "undefined" != typeof self && "undefined" != typeof WorkerGlobalScope && self instanceof WorkerGlobalScope && self, wt = void 0 !== e.global && e.global, mt = yt || wt || vt; function _t(t, e) { return void 0 === e && (e = null), new jt({ method: "GET", url: t, headers: e }); } function gt(t, e, r) { return new jt({ method: "POST", url: t, body: e, headers: r }); } function Et(t, e) { return new jt({ method: "DELETE", url: t, headers: e }); } function xt(t, e, r) { return new jt({ method: "PUT", url: t, body: e, headers: r }); } function St(t, e, r) { return new jt({ method: "PATCH", url: t, body: e, headers: r }); } var Tt = B(function (t, e) { return t.response; }); function Ot(t, e) { return Tt(new jt({ method: "GET", url: t, responseType: "json", headers: e })); } var jt = function (t) { function e(e) { var r = t.call(this) || this, n = { async: !0, createXHR: function () { return this.crossDomain ? function () { if (mt.XMLHttpRequest)
        return new mt.XMLHttpRequest; if (mt.XDomainRequest)
        return new mt.XDomainRequest; throw new Error("CORS is not supported by your browser"); }() : function () { if (mt.XMLHttpRequest)
        return new mt.XMLHttpRequest; var t = void 0; try {
        for (var e = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.4.0"], r = 0; r < 3; r++)
            try {
                if (t = e[r], new mt.ActiveXObject(t))
                    break;
            }
            catch (t) { }
        return new mt.ActiveXObject(t);
    }
    catch (t) {
        throw new Error("XMLHttpRequest is not supported by your browser");
    } }(); }, crossDomain: !0, withCredentials: !1, headers: {}, method: "GET", responseType: "json", timeout: 0 }; if ("string" == typeof e)
    n.url = e;
else
    for (var o in e)
        e.hasOwnProperty(o) && (n[o] = e[o]); return r.request = n, r; } var r; return o(e, t), e.prototype._subscribe = function (t) { return new Dt(t, this.request); }, e.create = ((r = function (t) { return new e(t); }).get = _t, r.post = gt, r.delete = Et, r.put = xt, r.patch = St, r.getJSON = Ot, r), e; }(j), Dt = function (t) { function e(e, r) { var n = t.call(this, e) || this; n.request = r, n.done = !1; var o = r.headers = r.headers || {}; return r.crossDomain || o["X-Requested-With"] || (o["X-Requested-With"] = "XMLHttpRequest"), "Content-Type" in o || mt.FormData && r.body instanceof mt.FormData || void 0 === r.body || (o["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8"), r.body = n.serializeBody(r.body, r.headers["Content-Type"]), n.send(), n; } return o(e, t), e.prototype.next = function (t) { this.done = !0; var e = this.xhr, r = this.request, n = this.destination, o = new It(t, e, r); n.next(o); }, e.prototype.send = function () { var t = this.request, e = this.request, r = e.user, n = e.method, o = e.url, i = e.async, u = e.password, a = e.headers, h = e.body, p = c(t.createXHR).call(t); if (p === s)
    this.error(s.e);
else {
    if (this.xhr = p, this.setupEvents(p, t), (r ? c(p.open).call(p, n, o, i, r, u) : c(p.open).call(p, n, o, i)) === s)
        return this.error(s.e), null;
    if (i && (p.timeout = t.timeout, p.responseType = t.responseType), "withCredentials" in p && (p.withCredentials = !!t.withCredentials), this.setHeaders(p, a), (h ? c(p.send).call(p, h) : c(p.send).call(p)) === s)
        return this.error(s.e), null;
} return p; }, e.prototype.serializeBody = function (t, e) { if (!t || "string" == typeof t)
    return t; if (mt.FormData && t instanceof mt.FormData)
    return t; if (e) {
    var r = e.indexOf(";");
    -1 !== r && (e = e.substring(0, r));
} switch (e) {
    case "application/x-www-form-urlencoded": return Object.keys(t).map(function (e) { return encodeURIComponent(e) + "=" + encodeURIComponent(t[e]); }).join("&");
    case "application/json": return JSON.stringify(t);
    default: return t;
} }, e.prototype.setHeaders = function (t, e) { for (var r in e)
    e.hasOwnProperty(r) && t.setRequestHeader(r, e[r]); }, e.prototype.setupEvents = function (t, e) { var r, n, o = e.progressSubscriber; function i(t) { var e = i, r = e.subscriber, n = e.progressSubscriber, o = e.request; n && n.error(t), r.error(new Ct(this, o)); } (t.ontimeout = i, i.request = e, i.subscriber = this, i.progressSubscriber = o, t.upload && "withCredentials" in t) && (o && (r = function (t) { r.progressSubscriber.next(t); }, mt.XDomainRequest ? t.onprogress = r : t.upload.onprogress = r, r.progressSubscriber = o), n = function (t) { var e = n, r = e.progressSubscriber, o = e.subscriber, i = e.request; r && r.error(t), o.error(new At("ajax error", this, i)); }, t.onerror = n, n.request = e, n.subscriber = this, n.progressSubscriber = o); function s(t) { } function u(t) { var e = u, r = e.subscriber, n = e.progressSubscriber, o = e.request; if (4 === this.readyState) {
    var i = 1223 === this.status ? 204 : this.status, s = "text" === this.responseType ? this.response || this.responseText : this.response;
    0 === i && (i = s ? 200 : 0), i < 400 ? (n && n.complete(), r.next(t), r.complete()) : (n && n.error(t), r.error(new At("ajax error " + i, this, o)));
} } t.onreadystatechange = s, s.subscriber = this, s.progressSubscriber = o, s.request = e, t.onload = u, u.subscriber = this, u.progressSubscriber = o, u.request = e; }, e.prototype.unsubscribe = function () { var e = this.done, r = this.xhr; !e && r && 4 !== r.readyState && "function" == typeof r.abort && r.abort(), t.prototype.unsubscribe.call(this); }, e; }(_), It = function () { return function (t, e, r) { this.originalEvent = t, this.xhr = e, this.request = r, this.status = e.status, this.responseType = e.responseType || r.responseType, this.response = Nt(this.responseType, e); }; }(), At = function (t) { function e(r, n, o) { var i = t.call(this, r) || this; return i.name = "AjaxError", i.message = r, i.xhr = n, i.request = o, i.status = n.status, i.responseType = n.responseType || o.responseType, i.response = Nt(i.responseType, n), Object.setPrototypeOf(i, e.prototype), i; } return o(e, t), e; }(Error); function Nt(t, e) { switch (t) {
    case "json": return "response" in e ? e.responseType ? e.response : JSON.parse(e.response || e.responseText || "null") : JSON.parse(e.responseText || "null");
    case "xml": return e.responseXML;
    case "text":
    default: return "response" in e ? e.response : e.responseText;
} } var Ct = function (t) { function e(r, n) { var o = t.call(this, "ajax timeout", r, n) || this; return o.name = "AjaxTimeoutError", Object.setPrototypeOf(o, e.prototype), o; } return o(e, t), e; }(At), Pt = jt.create; var Ht = { loadConfig: dt(function (t) { return "string" == typeof t ? { type: "CONFIG_LOADING", payload: Pt(t).pipe(B(function (t) { return { type: "CONFIG_LOADED", payload: t.response }; })) } : { type: "CONFIG_LOADED", payload: t }; }), addConfig: dt(function (t) { return { type: "ADD_CONFIG", payload: t }; }), setConfig: dt(function (t, e) { var r = {}; return r[t] = e, { type: "ADD_CONFIG", payload: r }; }) }; function Ut(t, r) { switch (r.type) {
    case "GITHUB_FOLLOWERS_LOADING": return Object.assign({}, t, { isLoading: !0 });
    case "GITHUB_FOLLOWERS_LOADED": return Object.assign({}, t, { isLoading: !1, users: r.payload });
    case "NAME_CHANGED": return Object.assign({}, t, { isLoading: !1, timestamp: e.Util.getTimeStamp(), name: r.payload });
    default: return t;
} } var Lt = { changeName: dt(function (t) { return ({ type: "NAME_CHANGED", payload: t }); }), loadGithubFollowers: dt(function (t) { var e = "https://api.github.com/users/" + t.username + "/followers"; return { type: "GITHUB_FOLLOWERS_LOADING", payload: Pt(e).pipe(B(function (t) { return B(t.response, "login"); }), B(function (t) { return ({ type: "GITHUB_FOLLOWERS_LOADED", payload: t }); })) }; }) }; var Rt = function (t, e, r, n) { return new (r || (r = Promise))(function (o, i) { function s(t) { try {
    c(n.next(t));
}
catch (t) {
    i(t);
} } function u(t) { try {
    c(n.throw(t));
}
catch (t) {
    i(t);
} } function c(t) { t.done ? o(t.value) : new r(function (e) { e(t.value); }).then(s, u); } c((n = n.apply(t, e || [])).next()); }); }; var qt = Symbol(), kt = Symbol();
    var Ft = /** @class */ (function () {
        function Ft(t) {
            if (this.actions = Lt, this.baseUrl = "", this.loading = !0, this.authenticated = !1, this.errorMessage = "", t !== kt)
                throw new Error("Cannot construct singleton");
            this.base = r.BaseService.instance, this.permissions = r.PermissionsService.instance, this.config = this.base.config, this.user = new r.User("visitor"), this.initStores();
        }
        Ft.prototype.init = function (t, r) {
            if (r === void 0) { r = ""; }
            return Rt(this, void 0, void 0, function () { var _a, _b, _c, _d; return __generator(this, function (_e) {
                switch (_e.label) {
                    case 0:
                        "" !== r && (this.baseUrl = r), this.appRoot = t;
                        return [4 /*yield*/, this.base.initApp(this.baseUrl + "/assets/config.json", !0, "_emaApp")];
                    case 1:
                        _e.sent();
                        return [4 /*yield*/, this.permissions.loadRules(this.baseUrl + "/assets/permissions.json", !0, "rules")];
                    case 2:
                        _e.sent(), this.baseUrl = r, this.base.translation.use(this.config.get("language")), this.data = {};
                        _a = this.data;
                        return [4 /*yield*/, e.Util.fetchJson(this.baseUrl + "/assets/collection-manifest.json")];
                    case 3:
                        _a.manifest = _e.sent();
                        _b = this.data;
                        return [4 /*yield*/, e.Util.fetchJson(this.baseUrl + "/assets/data/mock-data.json")];
                    case 4:
                        _b.mockData = _e.sent();
                        _c = this.data;
                        return [4 /*yield*/, e.Util.fetchJson(this.baseUrl + "/assets/data/mock-dwp.json")];
                    case 5:
                        _c.dwpData = _e.sent();
                        _d = this.data;
                        return [4 /*yield*/, e.Util.fetchJson(this.baseUrl + "/assets/data/apiSwagger.json")];
                    case 6: return [2 /*return*/, (_d.swaggerData = _e.sent(), this.collectionManifest = this.data.manifest, this.parseComponents(), this.initHistory(), window.document.location.hostname.match("localhost") && this.config.set("dev", !0), this.data)];
                }
            }); });
        };
        Ft.prototype.initStores = function () { return Rt(this, void 0, void 0, function () {
            var t;
            var _this = this;
            return __generator(this, function (_a) {
                this.store$ = ft(Ut, {}), this.config$ = ft(bt), this.store$.pipe((t = pt.log(), function (e) { return e.lift(new et(t, void 0, void 0)); })).subscribe(function (t) { }), this.config$.pipe().subscribe(function (t) { _this.base.config.add(t, !0); });
                return [2 /*return*/];
            });
        }); };
        Ft.prototype.test = function () { this.actions.changeName("Bob"), Ht.loadConfig(this.baseUrl + "/assets/config.json"), Ht.setConfig("foo", "bar"), console.log(this.user.roles), this.user.addRole("AUTHENTICATED"), this.user.addRole("DEVELOPER"), console.log(this.user.roles), this.user.removeRole("AUTHENTICATED"), console.log(this.user.roles), console.log(this.user.hasRole("DEVELOPER")), console.log(this.user.hasRole("AUTHENTICATED")), console.log(this.config.all()); };
        Ft.prototype.initHistory = function () { "undefined" != typeof window && window.history; };
        Ft.prototype.parseComponents = function () {
            var _this = this;
            var t = [];
            e.Util.copy(this.data.manifest.components).map(function (e) { var r = e.tag, n = !1; _this.config.get("componentsIgnorePatterns").forEach(function (t) { r.match(t) && (n = !0); }), n || t.push(e); }), this.components = t;
        };
        Ft.prototype.showFlashMessage = function (t, e, r) {
            if (r === void 0) { r = 2e3; }
            document.querySelector("ema-flash-message").show(t, e, r);
        };
        Object.defineProperty(Ft, "instance", {
            get: function () { return this[qt] || (this[qt] = new Ft(kt)), this[qt]; },
            enumerable: true,
            configurable: true
        });
        return Ft;
    }());  t.AppService = Ft, t.interval = function (t, e) { return void 0 === t && (t = 0), void 0 === e && (e = k), (!(!d(r = t) && r - parseFloat(r) + 1 >= 0) || t < 0) && (t = 0), e && "function" == typeof e.schedule || (e = k), new j(function (r) { return r.add(e.schedule(ht, t, { subscriber: r, counter: 0, period: t })), r; }); var r; }, t.concatAll = Z, t.map = B, t.pluck = function () { for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e]; var r = t.length; if (0 === r)
    throw new Error("list of properties cannot be empty."); return function (e) { return B(function (t, e) { return function (r) { for (var n = r, o = 0; o < e; o++) {
    var i = n[t[o]];
    if (void 0 === i)
        return;
    n = i;
} return n; }; }(t, r))(e); }; }; });
