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-4381ee16.js", ["exports", "./chunk-2f6d8e71.js", "./chunk-47f66c02.js", "./chunk-f85f75a4.js", "./chunk-4bc80c3c.js"], function (t, e, n, r, i) { window.webcomponents.h; var o = { 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" }], 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" }, 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" } }, language: "en", languages: [{ key: "nl", value: "Nederlands" }, { key: "en", value: "English" }], i18n: e.i18n, 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 s = 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 u = Symbol(), c = Symbol();
    var a = /** @class */ (function () {
        function a(t) {
            if (this._environment = { type: "node" }, t !== c)
                throw new Error("Cannot construct singleton");
            this._configService = r.ConfigService.instance, this._translateService = e.TranslateService.instance, this._global = this.getGlobal(), this._type = "BaseService";
        }
        a.prototype.initApp = function (t, e, n) {
            if (e === void 0) { e = !1; }
            return s(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(o);
                        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];
                }
            }); });
        };
        a.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"));
        };
        a.prototype.fetchJson = function (t) { return s(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(a.prototype, "config", {
            get: function () { return this._configService; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(a.prototype, "environment", {
            get: function () { return this._environment; },
            enumerable: true,
            configurable: true
        });
        a.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(a.prototype, "translation", {
            get: function () { return this._translateService; },
            enumerable: true,
            configurable: true
        });
        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;
    }());  var h = function (t, e) { return (h = 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 l(t, e) { function n() { this.constructor = t; } h(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, new n); } function p(t) { return "function" == typeof t; } var f = !1, d = { Promise: void 0, set useDeprecatedSynchronousErrorHandling(t) { t && (new Error).stack, f = t; }, get useDeprecatedSynchronousErrorHandling() { return f; } }; function b(t) { setTimeout(function () { throw t; }); } var y = { closed: !0, next: function (t) { }, error: function (t) { if (d.useDeprecatedSynchronousErrorHandling)
        throw t; b(t); }, complete: function () { } }, v = Array.isArray || function (t) { return t && "number" == typeof t.length; }; function m(t) { return null != t && "object" == typeof t; } var w, _ = { e: {} }; function g() { try {
    return w.apply(this, arguments);
}
catch (t) {
    return _.e = t, _;
} } function E(t) { return w = t, g; } var S = 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 l(e, t), e; }(Error), x = 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 (p(i) && E(i).call(this) === _ && (e = !0, t = t || (_.e instanceof S ? T(_.e.errors) : [_.e])), v(o))
        for (s = -1, u = o.length; ++s < u;) {
            var c = o[s];
            if (m(c) && E(c.unsubscribe).call(c) === _) {
                e = !0, t = t || [];
                var a = _.e;
                a instanceof S ? t = t.concat(T(a.errors)) : t.push(a);
            }
        }
    if (e)
        throw new S(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 T(t) { return t.reduce(function (t, e) { return t.concat(e instanceof S ? e.errors : e); }, []); } var I = "function" == typeof Symbol && "function" == typeof Symbol.for ? Symbol.for("rxSubscriber") : "@@rxSubscriber", P = 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 = y;
        break;
    case 1:
        if (!e) {
            i.destination = y;
            break;
        }
        if ("object" == typeof e) {
            if (N(e)) {
                var o = e[I]();
                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 l(e, t), e.prototype[I] = 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; }(x), j = function (t) { function e(e, n, r, i) { var o, s = t.call(this) || this; s._parentSubscriber = e; var u = s; return p(n) ? o = n : n && (o = n.next, r = n.error, i = n.complete, n !== y && (p((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 l(e, t), e.prototype.next = function (t) { if (!this.isStopped && this._next) {
    var e = this._parentSubscriber;
    d.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 = d.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) : b(t), this.unsubscribe();
    else {
        if (this.unsubscribe(), n)
            throw t;
        b(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); };
        d.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(), d.useDeprecatedSynchronousErrorHandling)
        throw t;
    b(t);
} }, e.prototype.__tryOrSetError = function (t, e, n) { if (!d.useDeprecatedSynchronousErrorHandling)
    throw new Error("bad call"); try {
    e.call(this._context, n);
}
catch (e) {
    return d.useDeprecatedSynchronousErrorHandling ? (t.syncErrorValue = e, t.syncErrorThrown = !0, !0) : (b(e), !0);
} return !1; }, e.prototype._unsubscribe = function () { var t = this._parentSubscriber; this._context = null, this._parentSubscriber = null, t.unsubscribe(); }, e; }(P); function N(t) { return t instanceof P || "syncErrorThrowable" in t && t[I]; } var O = "function" == typeof Symbol && Symbol.observable || "@@observable"; function A() { } var C = 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 P)
        return t;
    if (t[I])
        return t[I]();
} return t || e || n ? new P(t, e, n) : new P(y); }(t, e, n); if (r ? r.call(i, this.source) : i.add(this.source || d.useDeprecatedSynchronousErrorHandling && !i.syncErrorThrowable ? this._subscribe(i) : this._trySubscribe(i)), d.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) {
    d.useDeprecatedSynchronousErrorHandling && (t.syncErrorThrown = !0, t.syncErrorValue = e), t.error(e);
} }, t.prototype.forEach = function (t, e) { var n = this; return new (e = k(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[O] = 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); } : A)(this); }, t.prototype.toPromise = function (t) { var e = this; return new (t = k(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 k(t) { if (t || (t = d.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 l(e, t), e; }(Error), D = function (t) { function e(e, n) { var r = t.call(this) || this; return r.subject = e, r.subscriber = n, r.closed = !1, r; } return l(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; }(x), M = function (t) { function e(e) { var n = t.call(this, e) || this; return n.destination = e, n; } return l(e, t), e; }(P), R = 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 l(e, t), e.prototype[I] = function () { return new M(this); }, e.prototype.lift = function (t) { var e = new Y(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), x.EMPTY) : this.isStopped ? (t.complete(), x.EMPTY) : (this.observers.push(t), new D(this, t)); }, e.prototype.asObservable = function () { var t = new C; return t.source = this, t; }, e.create = function (t, e) { return new Y(t, e); }, e; }(C), Y = function (t) { function e(e, n) { var r = t.call(this) || this; return r.destination = e, r.source = n, r; } return l(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) : x.EMPTY; }, e; }(R); var W = function () { function t(t) { this.connectable = t; } return t.prototype.call = function (t, e) { var n = this.connectable; n._refCount++; var r = new H(t, n), i = e.subscribe(r); return r.closed || (r.connection = n.connect()), i; }, t; }(), H = function (t) { function e(e, n) { var r = t.call(this, e) || this; return r.connectable = n, r; } return l(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; }(P), U = function (t) { function e(e) { var n = t.call(this) || this; return n._value = e, n; } return l(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; }(R), G = 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 l(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 l(e, t), e.prototype.schedule = function (t, e) { return void 0 === e && (e = 0), this; }, e; }(x)), B = function (t) { function e(e, n) { var r = t.call(this, e, n) || this; return r.scheduler = e, r.work = n, r; } return l(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; }(G), F = 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; }(), L = function (t) { function e(n, r) { void 0 === r && (r = F.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 l(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; }(F), q = new (function (t) { function e() { return null !== t && t.apply(this, arguments) || this; } return l(e, t), e; }(L))(B), z = new C(function (t) { return t.complete(); }); function J(t) { return t ? function (t) { return new C(function (e) { return t.schedule(function () { return e.complete(); }); }); }(t) : z; } function K(t) { return t && "function" == typeof t.schedule; } var Q = 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 X(t, e) { return new C(e ? function (n) { var r = new x, i = 0; return r.add(e.schedule(function () { i !== t.length ? (n.next(t[i++]), n.closed || r.add(this.schedule())) : n.complete(); })), r; } : Q(t)); } function Z(t) { var e = new C(function (e) { e.next(t), e.complete(); }); return e._isScalar = !0, e.value = t, e; } function $() { for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e]; var n = t[t.length - 1]; switch (K(n) ? t.pop() : n = void 0, t.length) {
    case 0: return J(n);
    case 1: return n ? X(t, n) : Z(t[0]);
    default: return X(t, n);
} } function tt(t, e) { return new C(e ? function (n) { return e.schedule(et, 0, { error: t, subscriber: n }); } : function (e) { return e.error(t); }); } function et(t) { var e = t.error; t.subscriber.error(e); } var nt = 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 $(this.value);
    case "E": return tt(this.error);
    case "C": return J();
} 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; }(), rt = 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 l(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 it(t, this.destination))); }, e.prototype._next = function (t) { this.scheduleMessage(nt.createNext(t)); }, e.prototype._error = function (t) { this.scheduleMessage(nt.createError(t)); }, e.prototype._complete = function () { this.scheduleMessage(nt.createComplete()); }, e; }(P), it = function (t, e) { this.notification = t, this.destination = e; }, ot = 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 l(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 st(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 = x.EMPTY : (this.observers.push(t), e = new D(this, t)), i && t.add(t = new rt(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 || q).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; }(R), st = function (t, e) { this.time = t, this.value = e; }, ut = 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 l(e, t), e.prototype._subscribe = function (e) { return this.hasError ? (e.error(this.thrownError), x.EMPTY) : this.hasCompleted && this.hasNext ? (e.next(this.value), e.complete(), x.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; }(R), ct = 1, at = {}, ht = function (t) { function e(e, n) { var r = t.call(this, e, n) || this; return r.scheduler = e, r.work = n, r; } return l(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 = ct++, at[o] = i, Promise.resolve().then(function () { return function (t) { var e = at[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 at[n], e.scheduled = void 0); }, e; }(G), lt = new (function (t) { function e() { return null !== t && t.apply(this, arguments) || this; } return l(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; }(L))(ht), pt = new L(G); function ft(t) { return t; } var dt = 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 l(e, t), e; }(Error), bt = 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 l(e, t), e; }(Error), yt = function (t) { function e() { var n = t.call(this, "Timeout has occurred") || this; return n.name = "TimeoutError", Object.setPrototypeOf(n, e.prototype), n; } return l(e, t), e; }(Error); function vt(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 mt(t, e)); }; } var mt = function () { function t(t, e) { this.project = t, this.thisArg = e; } return t.prototype.call = function (t, e) { return e.subscribe(new wt(t, this.project, this.thisArg)); }, t; }(), wt = 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 l(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; }(P), _t = function (t) { function e() { return null !== t && t.apply(this, arguments) || this; } return l(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; }(P), gt = 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 l(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; }(P), Et = 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, b), e; }; }, St = function () { return "function" == typeof Symbol && Symbol.iterator ? Symbol.iterator : "@@iterator"; }(), xt = function (t) { return function (e) { for (var n = t[St]();;) {
    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; }; }, Tt = function (t) { return function (e) { var n = t[O](); if ("function" != typeof n.subscribe)
    throw new TypeError("Provided object does not correctly implement Symbol.observable"); return n.subscribe(e); }; }, It = function (t) { return t && "number" == typeof t.length && "function" != typeof t; }; function Pt(t) { return t && "function" != typeof t.subscribe && "function" == typeof t.then; } var jt = function (t) { if (t instanceof C)
    return function (e) { return t._isScalar ? (e.next(t.value), void e.complete()) : t.subscribe(e); }; if (t && "function" == typeof t[O])
    return Tt(t); if (It(t))
    return Q(t); if (Pt(t))
    return Et(t); if (t && "function" == typeof t[St])
    return xt(t); var e = m(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 Nt(t, e, n, r) { var i = new gt(t, n, r); return jt(e)(i); } function Ot(t, e) { if (!e)
    return t instanceof C ? t : new C(jt(t)); if (null != t) {
    if (function (t) { return t && "function" == typeof t[O]; }(t))
        return function (t, e) { return new C(e ? function (n) { var r = new x; return r.add(e.schedule(function () { var i = t[O](); 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; } : Tt(t)); }(t, e);
    if (Pt(t))
        return function (t, e) { return new C(e ? function (n) { var r = new x; 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; } : Et(t)); }(t, e);
    if (It(t))
        return X(t, e);
    if (function (t) { return t && "function" == typeof t[St]; }(t) || "string" == typeof t)
        return function (t, e) { if (!t)
            throw new Error("Iterable cannot be null"); return new C(e ? function (n) { var r, i = new x; return i.add(function () { r && "function" == typeof r.return && r.return(); }), i.add(e.schedule(function () { r = t[St](), 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; } : xt(t)); }(t, e);
} throw new TypeError((null !== t && typeof t || t) + " is not observable"); } function At(t, e, n) { return void 0 === n && (n = Number.POSITIVE_INFINITY), "function" == typeof e ? function (r) { return r.pipe(At(function (n, r) { return Ot(t(n, r)).pipe(vt(function (t, i) { return e(n, t, r, i); })); }, n)); } : ("number" == typeof e && (n = e), function (e) { return e.lift(new Ct(t, n)); }); } var Ct = 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 kt(t, this.project, this.concurrent)); }, t; }(), kt = 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 l(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(Nt(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; }(_t); var Vt = Symbol(), Dt = Symbol();
    var Mt = /** @class */ (function () {
        function Mt(t) {
            if (this.optionDefaults = { cache: "no-cache", credentials: "same-origin", headers: {}, mode: "same-origin", method: "GET" }, t !== Dt)
                throw new Error("Cannot construct singleton");
            this._type = "HttpService";
        }
        Mt.prototype.get = function (t, e) {
            if (e === void 0) { e = this.optionDefaults; }
            return C.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); }); });
        };
        Mt.prototype.put = function (t, e, n) { };
        Mt.prototype.post = function (t, e, n) { };
        Mt.prototype.delete = function (t, e, n) { };
        Object.defineProperty(Mt, "instance", {
            get: function () { return this[Vt] || (this[Vt] = new Mt(Dt)), this[Vt]; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Mt.prototype, "type", {
            get: function () { return this._type; },
            set: function (t) { this._type = t; },
            enumerable: true,
            configurable: true
        });
        return Mt;
    }()); 
    var Rt = /** @class */ (function () {
        function Rt() {
        }
        Rt.getStyle = function (t, e) {
            if (e === void 0) { e = document.documentElement; }
            return window.getComputedStyle(e).getPropertyValue(t);
        };
        Rt.setStyle = function (t, e, n) {
            if (n === void 0) { n = document.documentElement; }
            n.style.setProperty(t, e);
        };
        Rt.getVar = function (t, e) {
            if (e === void 0) { e = document.documentElement; }
            return "-" !== t[0] && "-" !== t[1] && (t = "--" + t), Rt.getStyle(t, e);
        };
        Rt.setVar = function (t, e, n) {
            if (n === void 0) { n = document.documentElement; }
            "-" !== t[0] && "-" !== t[1] && (t = "--" + t), Rt.setStyle(t, e, n);
        };
        return Rt;
    }());  t.__extends = l, t.tryCatch = E, t.errorObject = _, t.OuterSubscriber = _t, t.subscribeToResult = Nt, t.async = pt, t.Subscriber = P, t.isScheduler = K, t.Subscription = x, t.isArray = v, t.from = Ot, t.concat = function () { for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e]; return 1 === t.length || 2 === t.length && K(t[1]) ? Ot(t[0]) : (void 0 === (n = 1) && (n = Number.POSITIVE_INFINITY), At(ft, n))($.apply(void 0, t)); var n; }, t.mergeMap = At, t.Notification = nt, t.Observable = C, t.noop = A, t.isFunction = p, t.EmptyError = bt, t.ArgumentOutOfRangeError = dt, t.empty = J, t.fromArray = X, t.scalar = Z, t.map = vt, t.identity = ft, t.Subject = R, t.BehaviorSubject = U, t.AsyncSubject = ut, t.ReplaySubject = ot, t.refCount = function () { return function (t) { return t.lift(new W(t)); }; }, t.asap = lt, t.isNumeric = function (t) { return !v(t) && t - parseFloat(t) + 1 >= 0; }, t.TimeoutError = yt, t.throwError = tt, t.BaseService = a, t.HttpService = Mt, 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 () { i.Storage.saveLocalModel(this.model, this.model.params.baseUrl); };
    Wordpress.prototype.restoreLocal = function () { this.model = i.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.Css = Rt; });
