var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
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-3da2b85b.js", ["exports", "./chunk-c0bc660a.js", "./chunk-58852bd6.js"], function (t, e, n) { window.webcomponents.h; var r = { en: { ADD: "Add", ADDRESS: "Address", ADMIN: "Administration", CANCEL: "Cancel", "CHANGE LANGUAGE": "Change language", CLOSE: "Close", CONFIRM: "Confirm", "CONFIRM WARNING": "This action cannot be undone", CONTACT: "Contact", COUNTRY: "Country", CREATE: "Create", CURRENT: "Current", DATA: "Data", DATE: "Date", DATE_NTH: { 1: "{day} January {year}", 2: "{day} February {year}", 3: "{day} March {year}", 4: "{day} April {year}", 5: "{day} May {year}", 6: "{day} June {year}", 7: "{day} July {year}", 8: "{day} August {year}", 9: "{day} September {year}", 10: "{day} October {year}", 11: "{day} November {year}", 12: "{day} December {year}" }, DATE_MONTH_NTH: { 1: "January", 2: "February", 3: "March", 4: "April", 5: "May", 6: "June", 7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December" }, DELETE: "Delete", "DELETE CONFIRM": "Are you sure you want to delete this item", "DELETE CONFIRM MULTIPLE": "Are you sure you want to delete these items", DETAIL: "Detail", DETAILS: "Details", EDIT: "Edit", EMAIL: "E-mail", "EMAIL ADDRESS": "E-mail address", "EMAIL ERROR": "This is not a valid email address", ERROR: "Error", FIELD: "Field", "FIELD REQUIRED": "This field is required", "FORM INVALID": "The form can not be submitted yet. Please fill in the required fields", "FORM SUCCESS": "The data have been stored", LANGUAGE: "Language", LOGIN: "Login", "LOGIN ERROR": "The credentials you provided are not valid", "LOGIN EXPIRED": "Your authorization has expired. Please login again", LOGOUT: "Log out", NAME: "Name", "NETWORK ERROR": "There is no internet connection", PASSWORD: "Password", "PASSWORD ERROR": "Password is required", "PASSWORD MATCH ERROR": "The passwords don't match", REMARKS: "Remarks", REMEMBER: "Remember", REQUIRED: "Required", RESET: "Wissen", RESULT: "Result", RESULTS: "Results", RESULTS_NTH: { 0: "No results", 1: "{n} result", 2: "{n} results", n: "{n} results", gt99: "99+ results" }, SAVE: "Save", SEARCH: "Search", SUBMIT: "Submit", TITLE: "Title", USER: "User", USERS: "Users", USERNAME: "Username", counter: "The count is {n}" }, nl: { ADD: "Toevoegen", ADDRESS: "Adres", ADMIN: "Beheer", CANCEL: "Annuleren", "CHANGE LANGUAGE": "Taal wijzigen", CLOSE: "Sluiten", CONFIRM: "Bevestigen", "CONFIRM WARNING": "Deze handeling kan niet ongedaan worden gemaakt", CONTACT: "Contact", COUNTRY: "Land", CREATE: "Aanmaken", CURRENT: "Huidige", DATA: "Gegevens", DATE: "Datum", DATE_NTH: { 1: "{day} Januari {year}", 2: "{day} Februari {year}", 3: "{day} Maart {year}", 4: "{day} April {year}", 5: "{day} Mei {year}", 6: "{day} Juni {year}", 7: "{day} Juli {year}", 8: "{day} Augustus {year}", 9: "{day} September {year}", 10: "{day} Oktober {year}", 11: "{day} November {year}", 12: "{day} December {year}" }, DATE_MONTH_NTH: { 1: "Januari", 2: "Februari", 3: "Maart", 4: "April", 5: "Mei", 6: "Juni", 7: "Juli", 8: "Augustus", 9: "September", 10: "Oktober", 11: "November", 12: "December" }, DELETE: "Verwijderen", "DELETE CONFIRM": "Weet u zeker dat u dit onderdeel wilt verwijderen", "DELETE CONFIRM MULTIPLE": "Weet u zeker dat u deze onderdelen wilt verwijderen", DETAIL: "Detail", DETAILS: "Details", EDIT: "Bewerken", EMAIL: "E-mail", "EMAIL ADDRESS": "E-mailadres", "EMAIL ERROR": "Er is geen geldige e-mail ingevoerd", ERROR: "Fout", FIELD: "Veld", "FIELD REQUIRED": "Dit veld is verplicht", "FORM INVALID": "Het formulier kan niet worden verstuurd. Vul eerst de ontbrekende velden in", "FORM SUCCESS": "De gegevens zijn opgeslagen", LANGUAGE: "Taal", LOGIN: "Inloggen", "LOGIN ERROR": "De ingevoerde login combinatie is niet geldig", "LOGIN EXPIRED": "Uw autorisatie is verlopen. Log opnieuw in a.u.b", LOGOUT: "Uitloggen", NAME: "Naam", "NETWORK ERROR": "De internetverbinding is verbroken", PASSWORD: "Wachtwoord", "PASSWORD ERROR": "Er is geen geldig wachtwoord ingevoerd", "PASSWORD MATCH ERROR": "De ingevoerde wachtwoorden komen niet overeen", REMARKS: "Opmerkingen", REMEMBER: "Onthouden", REQUIRED: "Verplicht", RESET: "Reset", RESULT: "Resultaat", RESULTS: "Resultaten", RESULTS_NTH: { 0: "Geen resultaten", 1: "{n} resultaat", 2: "{n} resultaten", n: "{n} resultaten", gt99: "99+ resultaten" }, SAVE: "Opslaan", SEARCH: "Zoeken", SUBMIT: "Indienen", TITLE: "Titel", USER: "Gebruiker", USERS: "Gebruikers", USERNAME: "Gebruikersnaam", counter: "Het aantal is {n}" } }, i = { id: "ema-js-base", name: "ema-js-base", authenticated: !1, version: "0.0.1", domain: "ema-js-base.firebaseapp.com", baseUrl: "https://ema-js-base.firebaseapp.com/", baseRoot: "https://ema-js-base.firebaseapp.com", api_headers: [{ "Content-Type": "application/json;charset=utf-8" }], firebaseApps: { "ema-js-base": { apiKey: "AIzaSyDQuSusOA5HNwIUoyViVOPwEWbGXWt91p4", authDomain: "ema-js-base.firebaseapp.com", databaseURL: "https://ema-js-base.firebaseio.com", projectId: "ema-js-base", storageBucket: "ema-js-base.appspot.com", messagingSenderId: "419979785648" } }, firebase: { apiKey: "AIzaSyDQuSusOA5HNwIUoyViVOPwEWbGXWt91p4", authDomain: "ema-js-base.firebaseapp.com", databaseURL: "https://ema-js-base.firebaseio.com", projectId: "ema-js-base", storageBucket: "ema-js-base.appspot.com", messagingSenderId: "419979785648" }, language: "en", languages: [{ key: "nl", value: "Nederlands" }, { key: "en", value: "English" }], i18n: r, permissions: ["read"], roles: { ANONYMOUS: ["read"], AUTHENTICATED: ["read", "create", "update", "logout"], EDITOR: ["create", "read", "update", "delete", "logout"], DEVELOPER: ["create", "read", "update", "delete", "logout", "debug"], ADMINISTRATOR: ["create", "read", "update", "delete", "administrate", "logout", "create-user", "delete-user"], OWNER: ["create", "read", "update", "delete", "administrate", "logout", "create-user", "delete-user", "debug", "autoLogin", "fetchCredentials"] } }; var o = function (t, e, n, r) { return new (n || (n = Promise))(function (i, o) { function s(t) { try {
    c(r.next(t));
}
catch (t) {
    o(t);
} } function u(t) { try {
    c(r.throw(t));
}
catch (t) {
    o(t);
} } function c(t) { t.done ? i(t.value) : new n(function (e) { e(t.value); }).then(s, u); } c((r = r.apply(t, e || [])).next()); }); };
    var s = /** @class */ (function () {
        function s() {
            var _this = this;
            this.i18n = r, this.defaultLanguage = "en-US", this.supportedLanguages = ["en-US", "nl-NL"], this.translations = {}, this.translationsLocation = "assets/translations", this.options = { debug: !1, namespaceSplitter: "::" }, this.initTranslateJs(), this.libTranslate = n.Util.getGlobal().libTranslate, Object.keys(r).forEach(function (t) { _this.supportedLanguages.push(t); }), this.translations = n.Util.copy(r), this.translations["nl-NL"] = n.Util.copy(this.translations.nl), this.translations["en-US"] = n.Util.copy(this.translations.en), this.translations["en-BE"] = n.Util.copy(this.translations.en), this.use(this.defaultLanguage);
        }
        s.prototype.get = function (t) {
            var e = [];
            for (var _i = 1; _i < arguments.length; _i++) {
                e[_i - 1] = arguments[_i];
            }
            return this.t.apply(this, [t].concat(e));
        };
        s.prototype.set = function (t, e) { this.translations[this.language][t] = e; };
        s.prototype.add = function (t) {
            var _this = this;
            Object.keys(t).forEach(function (e) { _this.set(e, t[e]); });
        };
        s.prototype.use = function (t, e) {
            if (e === void 0) { e = !1; }
            return o(this, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        this.language = t;
                        _a = this.translations[t] && !e;
                        if (_a) return [3 /*break*/, 2];
                        return [4 /*yield*/, this.loadTranslation(t)];
                    case 1:
                        _a = (_b.sent());
                        _b.label = 2;
                    case 2:
                        _a, this.t = this.libTranslate.getTranslationFunction(this.translations[t], [this.options]);
                        return [2 /*return*/];
                }
            }); });
        };
        s.prototype.loadTranslation = function (t) { return o(this, void 0, void 0, function () {
            var e;
            var _this = this;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        this.translations[t] || (this.translations[t] = {});
                        return [4 /*yield*/, n.Util.fetchJson(this.translationsLocation + "/" + t + ".json")];
                    case 1:
                        e = _a.sent();
                        Object.keys(e).forEach(function (n) { _this.translations[t][n] = e[n]; });
                        return [2 /*return*/];
                }
            });
        }); };
        s.prototype.initTranslateJs = function () { var t, e, r; t = function (t) { return !isNaN(parseFloat(t)) && isFinite(t); }, e = function (t) { return "object" == typeof t && null !== t; }, r = function (t) { return "[object String]" === Object.prototype.toString.call(t); }, n.Util.getGlobal().libTranslate = { getTranslationFunction: function (n, i) { function o(t) { if (n[t])
                return n[t]; var e = t.split(c), r = e[0], i = e[1]; return n[r] && n[r][i] ? n[r][i] : null; } function s(t, e) { return r(t) ? t.replace(/\{(\w*)\}/g, function (t, n) { return e.hasOwnProperty(n) ? e.hasOwnProperty(n) ? e[n] : n : (u && console.log('Could not find replacement "' + n + '" in provided replacements object:', e), "{" + n + "}"); }) : t; } var u = (i = e(i) ? i : {}).debug, c = i.namespaceSplitter || "::"; return function (n) { var r = e(arguments[1]) ? arguments[1] : e(arguments[2]) ? arguments[2] : {}, i = t(arguments[1]) ? arguments[1] : t(arguments[2]) ? arguments[2] : null, c = o(n); return null !== i && (r.n = r.n ? r.n : i, c = function (t, n) { if (e(t)) {
                var r, i = Object.keys(t);
                if (0 === i.length)
                    return u && console.log("[Translation] No plural forms found."), null;
                for (var o = 0; o < i.length; o++)
                    0 === i[o].indexOf("gt") && (r = parseInt(i[o].replace("gt", ""), 10));
                t[n] ? t = t[n] : n > r ? t = t["gt" + r] : t.n ? t = t.n : (u && console.log('[Translation] No plural forms found for count:"' + n + '" in', t), t = t[Object.keys(t).reverse()[0]]);
            } return t; }(c, i)), null === (c = s(c, r)) && (c = u ? "@@" + n + "@@" : n, u && console.log('Translation for "' + n + '" not found.')), c; }; } }; };
        return s;
    }());  var u = Symbol(), c = Symbol();
    var a = /** @class */ (function (_super) {
        __extends(a, _super);
        function a(t) {
            var _this = this;
            if (_this = _super.call(this) || this, t !== c)
                throw new Error("Cannot construct singleton");
            _this._type = "TranslateService";
            return _this;
        }
        Object.defineProperty(a, "instance", {
            get: function () { return this[u] || (this[u] = new a(c)), this[u]; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(a.prototype, "type", {
            get: function () { return this._type; },
            set: function (t) { this._type = t; },
            enumerable: true,
            configurable: true
        });
        return a;
    }(s));  var l = function (t, e, n, r) { return new (n || (n = Promise))(function (i, o) { function s(t) { try {
    c(r.next(t));
}
catch (t) {
    o(t);
} } function u(t) { try {
    c(r.throw(t));
}
catch (t) {
    o(t);
} } function c(t) { t.done ? i(t.value) : new n(function (e) { e(t.value); }).then(s, u); } c((r = r.apply(t, e || [])).next()); }); }; var h = Symbol(), p = Symbol();
    var d = /** @class */ (function () {
        function d(t) {
            if (this._environment = { type: "node" }, t !== p)
                throw new Error("Cannot construct singleton");
            this._configService = e.ConfigService.instance, this._translateService = a.instance, this._global = this.getGlobal(), this._type = "BaseService";
        }
        d.prototype.initApp = function (t, e, n) {
            if (e === void 0) { e = !1; }
            return l(this, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        n && this.initGlobalNameSpace(n), e && this.config.setDefaults(i);
                        if (!("string" == typeof t)) return [3 /*break*/, 2];
                        return [4 /*yield*/, this.config.fetch(t, !0)];
                    case 1:
                        _a = _b.sent();
                        return [3 /*break*/, 3];
                    case 2:
                        _a = "object" == typeof t ? (this.config.add(t), t) : void 0;
                        _b.label = 3;
                    case 3: return [2 /*return*/, _a];
                }
            }); });
        };
        d.prototype.initGlobalNameSpace = function (t) {
            if (t === void 0) { t = "_ema"; }
            this.config.set("globalNameSpace", t), this._environment.namespace = t, this._environment.date = new Date, this._environment.started = Math.round(+new Date / 1e3), this._environment.framework = "js", this.getGlobal()[t] = this, "undefined" != typeof window && (this._environment.type = "browser", window.angular && (this._environment.framework = "angularJs"));
        };
        d.prototype.fetchJson = function (t) { return l(this, void 0, void 0, function () { return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, fetch(t)];
                case 1: return [4 /*yield*/, (_a.sent()).json()];
                case 2: return [2 /*return*/, _a.sent()];
            }
        }); }); };
        Object.defineProperty(d.prototype, "config", {
            get: function () { return this._configService; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(d.prototype, "environment", {
            get: function () { return this._environment; },
            enumerable: true,
            configurable: true
        });
        d.prototype.getGlobal = function () { if ("undefined" != typeof self)
            return self; if ("undefined" != typeof window)
            return window; if (void 0 !== n.global)
            return n.global; throw new Error("unable to locate global object"); };
        Object.defineProperty(d.prototype, "translation", {
            get: function () { return this._translateService; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(d, "instance", {
            get: function () { return this[h] || (this[h] = new d(p)), this[h]; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(d.prototype, "type", {
            get: function () { return this._type; },
            set: function (t) { this._type = t; },
            enumerable: true,
            configurable: true
        });
        return d;
    }());  var f = Symbol(), y = Symbol();
    var b = /** @class */ (function () {
        function b(t) {
            if (this._permissions = ["read"], this._roles = { ANONYMOUS: ["read"] }, t !== y)
                throw new Error("Cannot construct singleton");
            this._type = "PermissionsService";
        }
        Object.defineProperty(b, "instance", {
            get: function () { return this[f] || (this[f] = new b(y)), this[f]; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(b.prototype, "permissions", {
            get: function () { return this._permissions; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(b.prototype, "roles", {
            get: function () { return this._roles; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(b.prototype, "user", {
            get: function () { return this._user; },
            set: function (t) { this._user = t; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(b.prototype, "type", {
            get: function () { return this._type; },
            set: function (t) { this._type = t; },
            enumerable: true,
            configurable: true
        });
        return b;
    }()); 
    var m = /** @class */ (function () {
        function m() {
        }
        m.getStyle = function (t, e) {
            if (e === void 0) { e = document.documentElement; }
            return window.getComputedStyle(e).getPropertyValue(t);
        };
        m.setStyle = function (t, e, n) {
            if (n === void 0) { n = document.documentElement; }
            n.style.setProperty(t, e);
        };
        m.getVar = function (t, e) {
            if (e === void 0) { e = document.documentElement; }
            return "-" !== t[0] && "-" !== t[1] && (t = "--" + t), m.getStyle(t, e);
        };
        m.setVar = function (t, e, n) {
            if (n === void 0) { n = document.documentElement; }
            "-" !== t[0] && "-" !== t[1] && (t = "--" + t), m.setStyle(t, e, n);
        };
        return m;
    }());  var v = function (t, e) { return (v = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (t, e) { t.__proto__ = e; } || function (t, e) { for (var n in e)
    e.hasOwnProperty(n) && (t[n] = e[n]); })(t, e); }; function g(t, e) { function n() { this.constructor = t; } v(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, new n); } function E(t) { return "function" == typeof t; } var w = !1, S = { Promise: void 0, set useDeprecatedSynchronousErrorHandling(t) { t && (new Error).stack, w = t; }, get useDeprecatedSynchronousErrorHandling() { return w; } }; function _(t) { setTimeout(function () { throw t; }); } var T = { closed: !0, next: function (t) { }, error: function (t) { if (S.useDeprecatedSynchronousErrorHandling)
        throw t; _(t); }, complete: function () { } }, R = Array.isArray || function (t) { return t && "number" == typeof t.length; }; function A(t) { return null != t && "object" == typeof t; } var N, O = { e: {} }; function I() { try {
    return N.apply(this, arguments);
}
catch (t) {
    return O.e = t, O;
} } function x(t) { return N = t, I; } var D = function (t) { function e(n) { var r = t.call(this, n ? n.length + " errors occurred during unsubscription:\n  " + n.map(function (t, e) { return e + 1 + ") " + t.toString(); }).join("\n  ") : "") || this; return r.errors = n, r.name = "UnsubscriptionError", Object.setPrototypeOf(r, e.prototype), r; } return g(e, t), e; }(Error), C = 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 n = this._parent, r = this._parents, i = this._unsubscribe, o = this._subscriptions;
    this.closed = !0, this._parent = null, this._parents = null, this._subscriptions = null;
    for (var s = -1, u = r ? r.length : 0; n;)
        n.remove(this), n = ++s < u && r[s] || null;
    if (E(i) && x(i).call(this) === O && (e = !0, t = t || (O.e instanceof D ? P(O.e.errors) : [O.e])), R(o))
        for (s = -1, u = o.length; ++s < u;) {
            var c = o[s];
            if (A(c) && x(c.unsubscribe).call(c) === O) {
                e = !0, t = t || [];
                var a = O.e;
                a instanceof D ? t = t.concat(P(a.errors)) : t.push(a);
            }
        }
    if (e)
        throw new D(t);
} }, t.prototype.add = function (e) { if (!e || e === t.EMPTY)
    return t.EMPTY; if (e === this)
    return this; var n = e; switch (typeof e) {
    case "function": n = new t(e);
    case "object":
        if (n.closed || "function" != typeof n.unsubscribe)
            return n;
        if (this.closed)
            return n.unsubscribe(), n;
        if ("function" != typeof n._addParent) {
            var r = n;
            (n = new t)._subscriptions = [r];
        }
        break;
    default: throw new Error("unrecognized teardown " + e + " added to Subscription.");
} return (this._subscriptions || (this._subscriptions = [])).push(n), n._addParent(this), n; }, t.prototype.remove = function (t) { var e = this._subscriptions; if (e) {
    var n = e.indexOf(t);
    -1 !== n && e.splice(n, 1);
} }, t.prototype._addParent = function (t) { var e = this._parent, n = this._parents; e && e !== t ? n ? -1 === n.indexOf(t) && n.push(t) : this._parents = [t] : this._parent = t; }, t.EMPTY = ((e = new t).closed = !0, e), t; }(); function P(t) { return t.reduce(function (t, e) { return t.concat(e instanceof D ? e.errors : e); }, []); } var L = "function" == typeof Symbol && "function" == typeof Symbol.for ? Symbol.for("rxSubscriber") : "@@rxSubscriber", U = function (t) { function e(e, n, r) { var i = t.call(this) || this; switch ((i.syncErrorValue = null, i.syncErrorThrown = !1, i.syncErrorThrowable = !1, i.isStopped = !1, arguments.length)) {
    case 0:
        i.destination = T;
        break;
    case 1:
        if (!e) {
            i.destination = T;
            break;
        }
        if ("object" == typeof e) {
            if (M(e)) {
                var o = e[L]();
                i.syncErrorThrowable = o.syncErrorThrowable, i.destination = o, o.add(i);
            }
            else
                i.syncErrorThrowable = !0, i.destination = new j(i, e);
            break;
        }
    default: i.syncErrorThrowable = !0, i.destination = new j(i, e, n, r);
} return i; } return g(e, t), e.prototype[L] = function () { return this; }, e.create = function (t, n, r) { var i = new e(t, n, r); return i.syncErrorThrowable = !1, i; }, 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; }(C), j = function (t) { function e(e, n, r, i) { var o, s = t.call(this) || this; s._parentSubscriber = e; var u = s; return E(n) ? o = n : n && (o = n.next, r = n.error, i = n.complete, n !== T && (E((u = Object.create(n)).unsubscribe) && s.add(u.unsubscribe.bind(u)), u.unsubscribe = s.unsubscribe.bind(s))), s._context = u, s._next = o, s._error = r, s._complete = i, s; } return g(e, t), e.prototype.next = function (t) { if (!this.isStopped && this._next) {
    var e = this._parentSubscriber;
    S.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, n = S.useDeprecatedSynchronousErrorHandling;
    if (this._error)
        n && e.syncErrorThrowable ? (this.__tryOrSetError(e, this._error, t), this.unsubscribe()) : (this.__tryOrUnsub(this._error, t), this.unsubscribe());
    else if (e.syncErrorThrowable)
        n ? (e.syncErrorValue = t, e.syncErrorThrown = !0) : _(t), this.unsubscribe();
    else {
        if (this.unsubscribe(), n)
            throw t;
        _(t);
    }
} }, e.prototype.complete = function () { var t = this; if (!this.isStopped) {
    var e = this._parentSubscriber;
    if (this._complete) {
        var n = function () { return t._complete.call(t._context); };
        S.useDeprecatedSynchronousErrorHandling && e.syncErrorThrowable ? (this.__tryOrSetError(e, n), this.unsubscribe()) : (this.__tryOrUnsub(n), this.unsubscribe());
    }
    else
        this.unsubscribe();
} }, e.prototype.__tryOrUnsub = function (t, e) { try {
    t.call(this._context, e);
}
catch (t) {
    if (this.unsubscribe(), S.useDeprecatedSynchronousErrorHandling)
        throw t;
    _(t);
} }, e.prototype.__tryOrSetError = function (t, e, n) { if (!S.useDeprecatedSynchronousErrorHandling)
    throw new Error("bad call"); try {
    e.call(this._context, n);
}
catch (e) {
    return S.useDeprecatedSynchronousErrorHandling ? (t.syncErrorValue = e, t.syncErrorThrown = !0, !0) : (_(e), !0);
} return !1; }, e.prototype._unsubscribe = function () { var t = this._parentSubscriber; this._context = null, this._parentSubscriber = null, t.unsubscribe(); }, e; }(U); function M(t) { return t instanceof U || "syncErrorThrowable" in t && t[L]; } var k = "function" == typeof Symbol && Symbol.observable || "@@observable"; function F() { } var G = function () { function t(t) { this._isScalar = !1, t && (this._subscribe = t); } return t.prototype.lift = function (e) { var n = new t; return n.source = this, n.operator = e, n; }, t.prototype.subscribe = function (t, e, n) { var r = this.operator, i = function (t, e, n) { if (t) {
    if (t instanceof U)
        return t;
    if (t[L])
        return t[L]();
} return t || e || n ? new U(t, e, n) : new U(T); }(t, e, n); if (r ? r.call(i, this.source) : i.add(this.source || S.useDeprecatedSynchronousErrorHandling && !i.syncErrorThrowable ? this._subscribe(i) : this._trySubscribe(i)), S.useDeprecatedSynchronousErrorHandling && i.syncErrorThrowable && (i.syncErrorThrowable = !1, i.syncErrorThrown))
    throw i.syncErrorValue; return i; }, t.prototype._trySubscribe = function (t) { try {
    return this._subscribe(t);
}
catch (e) {
    S.useDeprecatedSynchronousErrorHandling && (t.syncErrorThrown = !0, t.syncErrorValue = e), t.error(e);
} }, t.prototype.forEach = function (t, e) { var n = this; return new (e = H(e))(function (e, r) { var i; i = n.subscribe(function (e) { try {
    t(e);
}
catch (t) {
    r(t), i && i.unsubscribe();
} }, r, e); }); }, t.prototype._subscribe = function (t) { var e = this.source; return e && e.subscribe(t); }, t.prototype[k] = function () { return this; }, t.prototype.pipe = function () { for (var t, e = [], n = 0; n < arguments.length; n++)
    e[n] = arguments[n]; return 0 === e.length ? this : ((t = e) ? 1 === t.length ? t[0] : function (e) { return t.reduce(function (t, e) { return e(t); }, e); } : F)(this); }, t.prototype.toPromise = function (t) { var e = this; return new (t = H(t))(function (t, n) { var r; e.subscribe(function (t) { return r = t; }, function (t) { return n(t); }, function () { return t(r); }); }); }, t.create = function (e) { return new t(e); }, t; }(); function H(t) { if (t || (t = S.Promise || Promise), !t)
    throw new Error("no Promise impl found"); return t; } var V = function (t) { function e() { var n = t.call(this, "object unsubscribed") || this; return n.name = "ObjectUnsubscribedError", Object.setPrototypeOf(n, e.prototype), n; } return g(e, t), e; }(Error), W = function (t) { function e(e, n) { var r = t.call(this) || this; return r.subject = e, r.subscriber = n, r.closed = !1, r; } return g(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 n = e.indexOf(this.subscriber);
        -1 !== n && e.splice(n, 1);
    }
} }, e; }(C), Y = function (t) { function e(e) { var n = t.call(this, e) || this; return n.destination = e, n; } return g(e, t), e; }(U), B = 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 g(e, t), e.prototype[L] = function () { return new Y(this); }, e.prototype.lift = function (t) { var e = new J(this, this); return e.operator = t, e; }, e.prototype.next = function (t) { if (this.closed)
    throw new V; if (!this.isStopped)
    for (var e = this.observers, n = e.length, r = e.slice(), i = 0; i < n; i++)
        r[i].next(t); }, e.prototype.error = function (t) { if (this.closed)
    throw new V; this.hasError = !0, this.thrownError = t, this.isStopped = !0; for (var e = this.observers, n = e.length, r = e.slice(), i = 0; i < n; i++)
    r[i].error(t); this.observers.length = 0; }, e.prototype.complete = function () { if (this.closed)
    throw new V; this.isStopped = !0; for (var t = this.observers, e = t.length, n = t.slice(), r = 0; r < e; r++)
    n[r].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 V; return t.prototype._trySubscribe.call(this, e); }, e.prototype._subscribe = function (t) { if (this.closed)
    throw new V; return this.hasError ? (t.error(this.thrownError), C.EMPTY) : this.isStopped ? (t.complete(), C.EMPTY) : (this.observers.push(t), new W(this, t)); }, e.prototype.asObservable = function () { var t = new G; return t.source = this, t; }, e.create = function (t, e) { return new J(t, e); }, e; }(G), J = function (t) { function e(e, n) { var r = t.call(this) || this; return r.destination = e, r.source = n, r; } return g(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) : C.EMPTY; }, e; }(B); var z = function () { function t(t) { this.connectable = t; } return t.prototype.call = function (t, e) { var n = this.connectable; n._refCount++; var r = new q(t, n), i = e.subscribe(r); return r.closed || (r.connection = n.connect()), i; }, t; }(), q = function (t) { function e(e, n) { var r = t.call(this, e) || this; return r.connectable = n, r; } return g(e, t), e.prototype._unsubscribe = function () { var t = this.connectable; if (t) {
    this.connectable = null;
    var e = t._refCount;
    if (e <= 0)
        this.connection = null;
    else if (t._refCount = e - 1, e > 1)
        this.connection = null;
    else {
        var n = this.connection, r = t._connection;
        this.connection = null, !r || n && r !== n || r.unsubscribe();
    }
}
else
    this.connection = null; }, e; }(U), $ = function (t) { function e(e) { var n = t.call(this) || this; return n._value = e, n; } return g(e, t), Object.defineProperty(e.prototype, "value", { get: function () { return this.getValue(); }, enumerable: !0, configurable: !0 }), e.prototype._subscribe = function (e) { var n = t.prototype._subscribe.call(this, e); return n && !n.closed && e.next(this._value), n; }, e.prototype.getValue = function () { if (this.hasError)
    throw this.thrownError; if (this.closed)
    throw new V; return this._value; }, e.prototype.next = function (e) { t.prototype.next.call(this, this._value = e); }, e; }(B), K = function (t) { function e(e, n) { var r = t.call(this, e, n) || this; return r.scheduler = e, r.work = n, r.pending = !1, r; } return g(e, t), e.prototype.schedule = function (t, e) { if (void 0 === e && (e = 0), this.closed)
    return this; this.state = t; var n = this.id, r = this.scheduler; return null != n && (this.id = this.recycleAsyncId(r, n, e)), this.pending = !0, this.delay = e, this.id = this.id || this.requestAsyncId(r, this.id, e), this; }, e.prototype.requestAsyncId = function (t, e, n) { return void 0 === n && (n = 0), setInterval(t.flush.bind(t, this), n); }, e.prototype.recycleAsyncId = function (t, e, n) { if (void 0 === n && (n = 0), null !== n && this.delay === n && !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 n = this._execute(t, e); if (n)
    return n; !1 === this.pending && null != this.id && (this.id = this.recycleAsyncId(this.scheduler, this.id, null)); }, e.prototype._execute = function (t, e) { var n = !1, r = void 0; try {
    this.work(t);
}
catch (t) {
    n = !0, r = !!t && t || new Error(t);
} if (n)
    return this.unsubscribe(), r; }, e.prototype._unsubscribe = function () { var t = this.id, e = this.scheduler, n = e.actions, r = n.indexOf(this); this.work = null, this.state = null, this.pending = !1, this.scheduler = null, -1 !== r && n.splice(r, 1), null != t && (this.id = this.recycleAsyncId(e, t, null)), this.delay = null; }, e; }(function (t) { function e(e, n) { return t.call(this) || this; } return g(e, t), e.prototype.schedule = function (t, e) { return void 0 === e && (e = 0), this; }, e; }(C)), Q = function (t) { function e(e, n) { var r = t.call(this, e, n) || this; return r.scheduler = e, r.work = n, r; } return g(e, t), e.prototype.schedule = function (e, n) { return void 0 === n && (n = 0), n > 0 ? t.prototype.schedule.call(this, e, n) : (this.delay = n, this.state = e, this.scheduler.flush(this), this); }, e.prototype.execute = function (e, n) { return n > 0 || this.closed ? t.prototype.execute.call(this, e, n) : this._execute(e, n); }, e.prototype.requestAsyncId = function (e, n, r) { return void 0 === r && (r = 0), null !== r && r > 0 || null === r && this.delay > 0 ? t.prototype.requestAsyncId.call(this, e, n, r) : e.flush(this); }, e; }(K), X = function () { function t(e, n) { void 0 === n && (n = t.now), this.SchedulerAction = e, this.now = n; } return t.prototype.schedule = function (t, e, n) { return void 0 === e && (e = 0), new this.SchedulerAction(this, t).schedule(n, e); }, t.now = function () { return Date.now(); }, t; }(), Z = function (t) { function e(n, r) { void 0 === r && (r = X.now); var i = t.call(this, n, function () { return e.delegate && e.delegate !== i ? e.delegate.now() : r(); }) || this; return i.actions = [], i.active = !1, i.scheduled = void 0, i; } return g(e, t), e.prototype.schedule = function (n, r, i) { return void 0 === r && (r = 0), e.delegate && e.delegate !== this ? e.delegate.schedule(n, r, i) : t.prototype.schedule.call(this, n, r, i); }, e.prototype.flush = function (t) { var e = this.actions; if (this.active)
    e.push(t);
else {
    var n;
    this.active = !0;
    do {
        if (n = t.execute(t.state, t.delay))
            break;
    } while (t = e.shift());
    if (this.active = !1, n) {
        for (; t = e.shift();)
            t.unsubscribe();
        throw n;
    }
} }, e; }(X), tt = new (function (t) { function e() { return null !== t && t.apply(this, arguments) || this; } return g(e, t), e; }(Z))(Q), et = new G(function (t) { return t.complete(); }); function nt(t) { return t ? function (t) { return new G(function (e) { return t.schedule(function () { return e.complete(); }); }); }(t) : et; } function rt(t) { return t && "function" == typeof t.schedule; } var it = function (t) { return function (e) { for (var n = 0, r = t.length; n < r && !e.closed; n++)
    e.next(t[n]); e.closed || e.complete(); }; }; function ot(t, e) { return new G(e ? function (n) { var r = new C, i = 0; return r.add(e.schedule(function () { i !== t.length ? (n.next(t[i++]), n.closed || r.add(this.schedule())) : n.complete(); })), r; } : it(t)); } function st(t) { var e = new G(function (e) { e.next(t), e.complete(); }); return e._isScalar = !0, e.value = t, e; } function ut() { for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e]; var n = t[t.length - 1]; switch (rt(n) ? t.pop() : n = void 0, t.length) {
    case 0: return nt(n);
    case 1: return n ? ot(t, n) : st(t[0]);
    default: return ot(t, n);
} } function ct(t, e) { return new G(e ? function (n) { return e.schedule(at, 0, { error: t, subscriber: n }); } : function (e) { return e.error(t); }); } function at(t) { var e = t.error; t.subscriber.error(e); } var lt = function () { function t(t, e, n) { this.kind = t, this.value = e, this.error = n, this.hasValue = "N" === t; } return t.prototype.observe = function (t) { switch (this.kind) {
    case "N": return t.next && t.next(this.value);
    case "E": return t.error && t.error(this.error);
    case "C": return t.complete && t.complete();
} }, t.prototype.do = function (t, e, n) { switch (this.kind) {
    case "N": return t && t(this.value);
    case "E": return e && e(this.error);
    case "C": return n && n();
} }, t.prototype.accept = function (t, e, n) { return t && "function" == typeof t.next ? this.observe(t) : this.do(t, e, n); }, t.prototype.toObservable = function () { switch (this.kind) {
    case "N": return ut(this.value);
    case "E": return ct(this.error);
    case "C": return nt();
} throw new Error("unexpected notification kind value"); }, t.createNext = function (e) { return void 0 !== e ? new t("N", e) : t.undefinedValueNotification; }, t.createError = function (e) { return new t("E", void 0, e); }, t.createComplete = function () { return t.completeNotification; }, t.completeNotification = new t("C"), t.undefinedValueNotification = new t("N", void 0), t; }(), ht = function (t) { function e(e, n, r) { void 0 === r && (r = 0); var i = t.call(this, e) || this; return i.scheduler = n, i.delay = r, i; } return g(e, t), e.dispatch = function (t) { var e = t.notification, n = t.destination; e.observe(n), this.unsubscribe(); }, e.prototype.scheduleMessage = function (t) { this.add(this.scheduler.schedule(e.dispatch, this.delay, new pt(t, this.destination))); }, e.prototype._next = function (t) { this.scheduleMessage(lt.createNext(t)); }, e.prototype._error = function (t) { this.scheduleMessage(lt.createError(t)); }, e.prototype._complete = function () { this.scheduleMessage(lt.createComplete()); }, e; }(U), pt = function (t, e) { this.notification = t, this.destination = e; }, dt = function (t) { function e(e, n, r) { void 0 === e && (e = Number.POSITIVE_INFINITY), void 0 === n && (n = Number.POSITIVE_INFINITY); var i = t.call(this) || this; return i.scheduler = r, i._events = [], i._infiniteTimeWindow = !1, i._bufferSize = e < 1 ? 1 : e, i._windowTime = n < 1 ? 1 : n, n === Number.POSITIVE_INFINITY ? (i._infiniteTimeWindow = !0, i.next = i.nextInfiniteTimeWindow) : i.next = i.nextTimeWindow, i; } return g(e, t), e.prototype.nextInfiniteTimeWindow = function (e) { var n = this._events; n.push(e), n.length > this._bufferSize && n.shift(), t.prototype.next.call(this, e); }, e.prototype.nextTimeWindow = function (e) { this._events.push(new ft(this._getNow(), e)), this._trimBufferThenGetEvents(), t.prototype.next.call(this, e); }, e.prototype._subscribe = function (t) { var e, n = this._infiniteTimeWindow, r = n ? this._events : this._trimBufferThenGetEvents(), i = this.scheduler, o = r.length; if (this.closed)
    throw new V; if (this.isStopped || this.hasError ? e = C.EMPTY : (this.observers.push(t), e = new W(this, t)), i && t.add(t = new ht(t, i)), n)
    for (var s = 0; s < o && !t.closed; s++)
        t.next(r[s]);
else
    for (s = 0; s < o && !t.closed; s++)
        t.next(r[s].value); return this.hasError ? t.error(this.thrownError) : this.isStopped && t.complete(), e; }, e.prototype._getNow = function () { return (this.scheduler || tt).now(); }, e.prototype._trimBufferThenGetEvents = function () { for (var t = this._getNow(), e = this._bufferSize, n = this._windowTime, r = this._events, i = r.length, o = 0; o < i && !(t - r[o].time < n);)
    o++; return i > e && (o = Math.max(o, i - e)), o > 0 && r.splice(0, o), r; }, e; }(B), ft = function (t, e) { this.time = t, this.value = e; }, yt = function (t) { function e() { var e = null !== t && t.apply(this, arguments) || this; return e.value = null, e.hasNext = !1, e.hasCompleted = !1, e; } return g(e, t), e.prototype._subscribe = function (e) { return this.hasError ? (e.error(this.thrownError), C.EMPTY) : this.hasCompleted && this.hasNext ? (e.next(this.value), e.complete(), C.EMPTY) : t.prototype._subscribe.call(this, e); }, e.prototype.next = function (t) { this.hasCompleted || (this.value = t, this.hasNext = !0); }, e.prototype.error = function (e) { this.hasCompleted || t.prototype.error.call(this, e); }, e.prototype.complete = function () { this.hasCompleted = !0, this.hasNext && t.prototype.next.call(this, this.value), t.prototype.complete.call(this); }, e; }(B), bt = 1, mt = {}, vt = function (t) { function e(e, n) { var r = t.call(this, e, n) || this; return r.scheduler = e, r.work = n, r; } return g(e, t), e.prototype.requestAsyncId = function (e, n, r) { return void 0 === r && (r = 0), null !== r && r > 0 ? t.prototype.requestAsyncId.call(this, e, n, r) : (e.actions.push(this), e.scheduled || (e.scheduled = (i = e.flush.bind(e, null), o = bt++, mt[o] = i, Promise.resolve().then(function () { return function (t) { var e = mt[t]; e && e(); }(o); }), o))); var i, o; }, e.prototype.recycleAsyncId = function (e, n, r) { if (void 0 === r && (r = 0), null !== r && r > 0 || null === r && this.delay > 0)
    return t.prototype.recycleAsyncId.call(this, e, n, r); 0 === e.actions.length && (delete mt[n], e.scheduled = void 0); }, e; }(K), gt = new (function (t) { function e() { return null !== t && t.apply(this, arguments) || this; } return g(e, t), e.prototype.flush = function (t) { this.active = !0, this.scheduled = void 0; var e, n = this.actions, r = -1, i = n.length; t = t || n.shift(); do {
    if (e = t.execute(t.state, t.delay))
        break;
} while (++r < i && (t = n.shift())); if (this.active = !1, e) {
    for (; ++r < i && (t = n.shift());)
        t.unsubscribe();
    throw e;
} }, e; }(Z))(vt), Et = new Z(K); function wt(t) { return t; } var St = function (t) { function e() { var n = t.call(this, "argument out of range") || this; return n.name = "ArgumentOutOfRangeError", Object.setPrototypeOf(n, e.prototype), n; } return g(e, t), e; }(Error), _t = function (t) { function e() { var n = t.call(this, "no elements in sequence") || this; return n.name = "EmptyError", Object.setPrototypeOf(n, e.prototype), n; } return g(e, t), e; }(Error), Tt = function (t) { function e() { var n = t.call(this, "Timeout has occurred") || this; return n.name = "TimeoutError", Object.setPrototypeOf(n, e.prototype), n; } return g(e, t), e; }(Error); function Rt(t, e) { return function (n) { if ("function" != typeof t)
    throw new TypeError("argument is not a function. Are you looking for `mapTo()`?"); return n.lift(new At(t, e)); }; } var At = function () { function t(t, e) { this.project = t, this.thisArg = e; } return t.prototype.call = function (t, e) { return e.subscribe(new Nt(t, this.project, this.thisArg)); }, t; }(), Nt = function (t) { function e(e, n, r) { var i = t.call(this, e) || this; return i.project = n, i.count = 0, i.thisArg = r || i, i; } return g(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; }(U), Ot = function (t) { function e() { return null !== t && t.apply(this, arguments) || this; } return g(e, t), e.prototype.notifyNext = function (t, e, n, r, i) { this.destination.next(e); }, e.prototype.notifyError = function (t, e) { this.destination.error(t); }, e.prototype.notifyComplete = function (t) { this.destination.complete(); }, e; }(U), It = function (t) { function e(e, n, r) { var i = t.call(this) || this; return i.parent = e, i.outerValue = n, i.outerIndex = r, i.index = 0, i; } return g(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; }(U), xt = 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, _), e; }; }, Dt = function () { return "function" == typeof Symbol && Symbol.iterator ? Symbol.iterator : "@@iterator"; }(), Ct = function (t) { return function (e) { for (var n = t[Dt]();;) {
    var r = n.next();
    if (r.done) {
        e.complete();
        break;
    }
    if (e.next(r.value), e.closed)
        break;
} return "function" == typeof n.return && e.add(function () { n.return && n.return(); }), e; }; }, Pt = function (t) { return function (e) { var n = t[k](); if ("function" != typeof n.subscribe)
    throw new TypeError("Provided object does not correctly implement Symbol.observable"); return n.subscribe(e); }; }, Lt = function (t) { return t && "number" == typeof t.length && "function" != typeof t; }; function Ut(t) { return t && "function" != typeof t.subscribe && "function" == typeof t.then; } var jt = function (t) { if (t instanceof G)
    return function (e) { return t._isScalar ? (e.next(t.value), void e.complete()) : t.subscribe(e); }; if (t && "function" == typeof t[k])
    return Pt(t); if (Lt(t))
    return it(t); if (Ut(t))
    return xt(t); if (t && "function" == typeof t[Dt])
    return Ct(t); var e = A(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."); }; function Mt(t, e, n, r) { var i = new It(t, n, r); return jt(e)(i); } function kt(t, e) { if (!e)
    return t instanceof G ? t : new G(jt(t)); if (null != t) {
    if (function (t) { return t && "function" == typeof t[k]; }(t))
        return function (t, e) { return new G(e ? function (n) { var r = new C; return r.add(e.schedule(function () { var i = t[k](); r.add(i.subscribe({ next: function (t) { r.add(e.schedule(function () { return n.next(t); })); }, error: function (t) { r.add(e.schedule(function () { return n.error(t); })); }, complete: function () { r.add(e.schedule(function () { return n.complete(); })); } })); })), r; } : Pt(t)); }(t, e);
    if (Ut(t))
        return function (t, e) { return new G(e ? function (n) { var r = new C; return r.add(e.schedule(function () { return t.then(function (t) { r.add(e.schedule(function () { n.next(t), r.add(e.schedule(function () { return n.complete(); })); })); }, function (t) { r.add(e.schedule(function () { return n.error(t); })); }); })), r; } : xt(t)); }(t, e);
    if (Lt(t))
        return ot(t, e);
    if (function (t) { return t && "function" == typeof t[Dt]; }(t) || "string" == typeof t)
        return function (t, e) { if (!t)
            throw new Error("Iterable cannot be null"); return new G(e ? function (n) { var r, i = new C; return i.add(function () { r && "function" == typeof r.return && r.return(); }), i.add(e.schedule(function () { r = t[Dt](), i.add(e.schedule(function () { if (!n.closed) {
            var t, e;
            try {
                var i = r.next();
                t = i.value, e = i.done;
            }
            catch (t) {
                return void n.error(t);
            }
            e ? n.complete() : (n.next(t), this.schedule());
        } })); })), i; } : Ct(t)); }(t, e);
} throw new TypeError((null !== t && typeof t || t) + " is not observable"); } function Ft(t, e, n) { return void 0 === n && (n = Number.POSITIVE_INFINITY), "function" == typeof e ? function (r) { return r.pipe(Ft(function (n, r) { return kt(t(n, r)).pipe(Rt(function (t, i) { return e(n, t, r, i); })); }, n)); } : ("number" == typeof e && (n = e), function (e) { return e.lift(new Gt(t, n)); }); } var Gt = 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 Ht(t, this.project, this.concurrent)); }, t; }(), Ht = function (t) { function e(e, n, r) { void 0 === r && (r = Number.POSITIVE_INFINITY); var i = t.call(this, e) || this; return i.project = n, i.concurrent = r, i.hasCompleted = !1, i.buffer = [], i.active = 0, i.index = 0, i; } return g(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, n = this.index++; try {
    e = this.project(t, n);
}
catch (t) {
    return void this.destination.error(t);
} this.active++, this._innerSub(e, t, n); }, e.prototype._innerSub = function (t, e, n) { this.add(Mt(this, t, e, n)); }, e.prototype._complete = function () { this.hasCompleted = !0, 0 === this.active && 0 === this.buffer.length && this.destination.complete(); }, e.prototype.notifyNext = function (t, e, n, r, i) { 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; }(Ot); function Vt() { return void 0 === (t = 1) && (t = Number.POSITIVE_INFINITY), Ft(wt, t); var t; } function Wt(t) { return !R(t) && t - parseFloat(t) + 1 >= 0; } function Yt(t) { var e = t.subscriber, n = t.counter, r = t.period; e.next(n), this.schedule({ subscriber: e, counter: n + 1, period: r }, r); } var Bt = Symbol(), Jt = Symbol();
    var zt = /** @class */ (function () {
        function zt(t) {
            if (this.optionDefaults = { cache: "no-cache", credentials: "same-origin", headers: {}, mode: "same-origin", method: "GET" }, t !== Jt)
                throw new Error("Cannot construct singleton");
            this._type = "HttpService";
        }
        zt.prototype.get = function (t, e) {
            if (e === void 0) { e = this.optionDefaults; }
            return G.create(function (n) { fetch(t, e).then(function (t) { return t.json(); }).then(function (t) { n.next(t), n.complete(); }).catch(function (t) { console.error("http.get error:", t), n.error(t); }); });
        };
        zt.prototype.put = function (t, e, n) { };
        zt.prototype.post = function (t, e, n) { };
        zt.prototype.delete = function (t, e, n) { };
        Object.defineProperty(zt, "instance", {
            get: function () { return this[Bt] || (this[Bt] = new zt(Jt)), this[Bt]; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(zt.prototype, "type", {
            get: function () { return this._type; },
            set: function (t) { this._type = t; },
            enumerable: true,
            configurable: true
        });
        return zt;
    }());  t.__extends = g, t.tryCatch = x, t.errorObject = O, t.OuterSubscriber = Ot, t.subscribeToResult = Mt, t.async = Et, t.Subscriber = U, t.isScheduler = rt, t.Subscription = C, t.isArray = R, t.from = kt, t.concat = function () { for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e]; return 1 === t.length || 2 === t.length && rt(t[1]) ? kt(t[0]) : Vt()(ut.apply(void 0, t)); }, t.mergeMap = Ft, t.Notification = lt, t.Observable = G, t.noop = F, t.isFunction = E, t.EmptyError = _t, t.ArgumentOutOfRangeError = St, t.empty = nt, t.fromArray = ot, t.scalar = st, t.map = Rt, t.identity = wt, t.Subject = B, t.BehaviorSubject = $, t.AsyncSubject = yt, t.ReplaySubject = dt, t.refCount = function () { return function (t) { return t.lift(new z(t)); }; }, t.asap = gt, t.isNumeric = Wt, t.TimeoutError = Tt, t.throwError = ct, t.User = /** @class */ (function () {
    function User(t, e, r, i) {
        if (t === void 0) { t = "visitor"; }
        if (e === void 0) { e = ["ANONYMOUS"]; }
        this.roles = [], this.permissions = b.instance, this.name = t, this.roles = e, r || (this.id = n.Util.getUUID()), i || (this.created = n.Util.getTimeStamp());
    }
    User.prototype.addRole = function (t) { this.roles.push(t), this.roles = n.Util.arraySetUnique(this.roles); };
    User.prototype.removeRole = function (t) { var e = this.roles.filter(function (e, n, r) { return e !== t; }); this.roles = e; };
    User.prototype.hasRole = function (t) { var e = !1; return this.roles.forEach(function (n) { n === t && (e = !0); }), e; };
    return User;
}()), t.BaseService = d, t.DomUtil = /** @class */ (function () {
    function DomUtil() {
    }
    DomUtil.addClass = function (t, e) { t.classList ? t.classList.add(e) : t.className += " " + e; };
    DomUtil.hasClass = function (t, e) { t.classList ? t.classList.contains(e) : new RegExp("(^| )" + e + "( |$)", "gi").test(t.className); };
    DomUtil.removeClass = function (t, e) { t.classList ? t.classList.remove(e) : t.className = t.className.replace(new RegExp("(^|\\b)" + e.split(" ").join("|") + "(\\b|$)", "gi"), " "); };
    DomUtil.toggleClass = function (t, e) { if (t.classList)
        t.classList.toggle(e);
    else {
        var n_1 = t.className.split(" "), r_1 = n_1.indexOf(e);
        r_1 >= 0 ? n_1.splice(r_1, 1) : n_1.push(e), t.className = n_1.join(" ");
    } };
    DomUtil.remove = function (t) { t.parentNode.removeChild(t); };
    DomUtil.getAttributes = function (t) { var e = t.attributes, n = {}, r = 0; for (; r < e.length; r++)
        n[e[r].name] = e[r].value; return n; };
    DomUtil.setAttributes = function (t, e) { Object.keys(e).forEach(function (n) { t.setAttribute(n, e[n]); }); };
    DomUtil.getStyle = function (t, e) { var n; var r = t.ownerDocument.defaultView; return r && r.getComputedStyle ? (e = e.replace(/([A-Z])/g, "-$1").toLowerCase(), r.getComputedStyle(t, null).getPropertyValue(e)) : t.currentStyle ? (e = e.replace(/\-(\w)/g, function (t, e) { return e.toUpperCase(); }), n = t.currentStyle[e], /^\d+(em|pt|%|ex)?$/i.test(n) ? function (e) { var n = t.style.left, r = t.runtimeStyle.left; return t.runtimeStyle.left = t.currentStyle.left, t.style.left = e || 0, e = t.style.pixelLeft + "px", t.style.left = n, t.runtimeStyle.left = r, e; }(n) : n) : void 0; };
    DomUtil.viewportSize = function () { var t = { width: void 0, height: void 0 }; return "undefined" != typeof window && (window.innerHeight ? (t.width = window.innerWidth, t.height = window.innerHeight) : (t.width = document.documentElement.clientWidth, t.height = document.documentElement.clientHeight)), t; };
    DomUtil.copyToClipboard = function (t) { var e = document.createElement("textarea"); e.value = t, e.setAttribute("readonly", ""), e.style.position = "absolute", e.style.left = "-9999px", document.body.appendChild(e); var n = document.getSelection().rangeCount > 0 && document.getSelection().getRangeAt(0); e.select(), document.execCommand("copy"), document.body.removeChild(e), n && (document.getSelection().removeAllRanges(), document.getSelection().addRange(n)); };
    DomUtil.fadeIn = function (t, e, n, r) {
        if (e === void 0) { e = 300; }
        if (n === void 0) { n = 0; }
        if (r === void 0) { r = "block"; }
        var i = 1 / e * 10;
        t.style.opacity = "0", t.style.display = r, setTimeout(function () { !function e() { var n = parseFloat(t.style.opacity); (n += i) > 1 || (t.style.opacity = n.toString(), requestAnimationFrame(e)); }(); }, n);
    };
    DomUtil.fadeOut = function (t, e, n, r) {
        if (e === void 0) { e = 300; }
        if (n === void 0) { n = 0; }
        if (r === void 0) { r = !1; }
        var i = 1 / e * 10;
        t.style.opacity = "1", setTimeout(function () { !function e() { var n = Number(t.style.opacity); n -= i, t.style.opacity = n.toString(), n < 0 ? !1 === r && (t.style.display = "none", t.style.opacity = "1") : requestAnimationFrame(e); }(); }, n);
    };
    DomUtil.getUrlParameterByName = function (t) { var e = RegExp("[?&]" + t + "=([^&]*)").exec(window.location.search); return e && decodeURIComponent(e[1].replace(/\+/g, " ")); };
    return DomUtil;
}()), t.interval = function (t, e) { return void 0 === t && (t = 0), void 0 === e && (e = Et), (!Wt(t) || t < 0) && (t = 0), e && "function" == typeof e.schedule || (e = Et), new G(function (n) { return n.add(e.schedule(Yt, t, { subscriber: n, counter: 0, period: t })), n; }); }, t.HttpService = zt, t.concatAll = Vt, t.TranslateService = a, t.Wordpress = /** @class */ (function () {
    function Wordpress() {
        this.authenticated = !1, this.model = { menus: {}, params: {}, collections: { post: {} } };
    }
    Wordpress.prototype.init = function (t) { var e = this; return "undefined" != typeof window && (window.wp = window.wp || {}), new Promise(function (n, r) { e.initApi(t).then(function () { t.app_server ? e.getParams().then(function () { e.getMenus().then(function () { e.ready = !0, n(); }); }) : n(); }); }); };
    Wordpress.prototype.initApi = function (t) { var e = this; return this.settings = t, this.endpoint = this.settings.protocol + "//" + this.settings.host + "/index.php/wp-json/", new Promise(function (t, n) { "undefined" == typeof window || window.WPAPI || (console.error("ERROR: WPAPI is not defined as global"), n()), location && location.origin === e.settings.protocol + "//" + e.settings.host ? e.discover().then(function () { e.api = new WPAPI({ endpoint: e.endpoint }), e.initCustomRoutes(), t(); }) : (e.api = new WPAPI({ endpoint: e.endpoint }), e.initCustomRoutes(), t()); }); };
    Wordpress.prototype.initCustomRoutes = function () { this.api.params = this.api.registerRoute("app-server/v1", "/params"), this.api.menus = this.api.registerRoute("app-server/v1", "/menus/(?P<id>[a-zA-Z(-]+)"), this.api.apps = this.api.registerRoute("wp/v2", "/apps/(?P<id>\\d+)"), this.api.iframes = this.api.registerRoute("wp/v2", "/iframes/(?P<id>\\d+)"); };
    Wordpress.prototype.getPosts = function () { var t = this; return new Promise(function (e, n) { t.api.posts().then(function (n) { var r = []; n.forEach(function (e) { e.id && (t.model.collections.post[e.id] = e, r.push(e)); }), e(r); }); }); };
    Wordpress.prototype.getParams = function () { var t = this; return new Promise(function (e, n) { t.api.params().then(function (n) { t.model.params = n, e(n); }); }); };
    Wordpress.prototype.getPost = function (t, e) { var n = this; return this.model.collections[e] || (this.model.collections[e] = {}), new Promise(function (r, i) { function o(t, e, i) { n.model.collections[e][t] = i, r(i); } !0 === n.settings.cache && n.model.collections[e][t] ? r(n.model.collections[e][t]) : ("post" === e && n.api.posts().id(t).then(function (n) { return o(t, e, n); }), "page" === e && n.api.pages().id(t).then(function (n) { return o(t, e, n); }), "app" === e && n.api.apps().id(t).then(function (n) { return o(t, e, n); }), "iframe" === e && n.api.iframes().id(t).then(function (n) { return o(t, e, n); })); }); };
    Wordpress.prototype.getMenu = function (t) { var e = this; return new Promise(function (n, r) { e.api.menus().id(t).then(function (r) { e.model.menus[t] = r, n(e.model.menus[t]); }); }); };
    Wordpress.prototype.getMenus = function () { var t = this; return new Promise(function (e, n) { var r = []; var i = 0; t.model.params.menus.length ? (t.model.params.menus.forEach(function (t) { r.push(t.slug); }), r.forEach(function (n) { t.getMenu(n).then(function (o) { t.model.menus[n] = o, ++i === r.length && e(t.model.menus); }); })) : e(t.model.menus); }); };
    Wordpress.prototype.saveLocal = function () { e.Storage.saveLocalModel(this.model, this.model.params.baseUrl); };
    Wordpress.prototype.restoreLocal = function () { this.model = e.Storage.restoreLocalModel(this.model.params.baseUrl); };
    Wordpress.prototype.discover = function () { var t = this, e = WPAPI.discover(this.settings.protocol + "//" + this.settings.host); return new Promise(function (n, r) { e.then(function (e) { t.site = e, n(); }); }); };
    return Wordpress;
}()), t.StringUtil = /** @class */ (function () {
    function StringUtil() {
    }
    StringUtil.lowercaseFirst = function (t) { return t.charAt(0).toLowerCase() + t.slice(1); };
    StringUtil.uppercaseFirst = function (t) { return t.charAt(0).toUpperCase() + t.slice(1); };
    StringUtil.replaceAll = function (t, e, n, r) {
        if (r === void 0) { r = !1; }
        return t ? (i = e, o = n, s = r, String(t).replace(new RegExp(i.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"), s ? "gi" : "g"), "string" == typeof o ? o.replace(/\$/g, "$$$$") : o)) : t;
        var i, o, s;
    };
    StringUtil.between = function (t, e, n, r) {
        if (r === void 0) { r = !1; }
        return t ? function (t, e, n) { var r = t.indexOf(e); if (!(r >= 0))
            return ""; if (t = t.substring(r + e.length), n) {
            if (!((r = t.indexOf(n)) >= 0))
                return "";
            t = t.substring(0, r);
        } return t; }(t, e, n) : t;
    };
    return StringUtil;
}()), t.Css = m, t.PermissionsService = b; });
