/**
 * @fileoverview added by tsickle
 * Generated from: shared/storage/paginator-storage.service.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { user } from "@seniorsistemas/senior-platform-data";
var PaginatorStorageService = /** @class */ (function () {
    function PaginatorStorageService() {
        this.GET_USER_ID = user.getUserData().then((/**
         * @param {?} user
         * @return {?}
         */
        function (user) { return user.id; }));
        this.PAGINATOR_KEY = "SENIOR_PAGINATOR";
    }
    /**
     * @param {?} key
     * @param {?} value
     * @return {?}
     */
    PaginatorStorageService.prototype.store = /**
     * @param {?} key
     * @param {?} value
     * @return {?}
     */
    function (key, value) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var _a, _b;
            return tslib_1.__generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        _b = (_a = sessionStorage).setItem;
                        return [4 /*yield*/, this.GET_USER_ID];
                    case 1:
                        _b.apply(_a, [(_c.sent()) + "_" + key, JSON.stringify(value)]);
                        return [2 /*return*/];
                }
            });
        });
    };
    /**
     * @param {?} key
     * @return {?}
     */
    PaginatorStorageService.prototype.get = /**
     * @param {?} key
     * @return {?}
     */
    function (key) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var _a, _b, _c, _d;
            return tslib_1.__generator(this, function (_e) {
                switch (_e.label) {
                    case 0:
                        _b = (_a = JSON).parse;
                        _d = (_c = sessionStorage).getItem;
                        return [4 /*yield*/, this.GET_USER_ID];
                    case 1: return [2 /*return*/, _b.apply(_a, [_d.apply(_c, [(_e.sent()) + "_" + key])]) || {}];
                }
            });
        });
    };
    /**
     * @param {?} key
     * @param {?=} listParams
     * @return {?}
     */
    PaginatorStorageService.prototype.storePaginator = /**
     * @param {?} key
     * @param {?=} listParams
     * @return {?}
     */
    function (key, listParams) {
        if (listParams === void 0) { listParams = {}; }
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var store;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.get(this.PAGINATOR_KEY)];
                    case 1:
                        store = (_a.sent()) || {};
                        store[key] = listParams;
                        return [4 /*yield*/, this.store(this.PAGINATOR_KEY, store)];
                    case 2:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    /**
     * @param {?} key
     * @return {?}
     */
    PaginatorStorageService.prototype.getPaginator = /**
     * @param {?} key
     * @return {?}
     */
    function (key) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var store;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.get(this.PAGINATOR_KEY)];
                    case 1:
                        store = (_a.sent()) || {};
                        return [2 /*return*/, store[key] || {}];
                }
            });
        });
    };
    return PaginatorStorageService;
}());
export { PaginatorStorageService };
if (false) {
    /**
     * @type {?}
     * @private
     */
    PaginatorStorageService.prototype.GET_USER_ID;
    /**
     * @type {?}
     * @private
     */
    PaginatorStorageService.prototype.PAGINATOR_KEY;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFnaW5hdG9yLXN0b3JhZ2Uuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BzZW5pb3ItZ2VzdGFvLXBlc3NvYXMvaGNtLWNsb2NraW5nLWV2ZW50LWZvdW5kYXRpb24tc2NoZWR1bGVzLWhpc3Rvcmllcy8iLCJzb3VyY2VzIjpbInNoYXJlZC9zdG9yYWdlL3BhZ2luYXRvci1zdG9yYWdlLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsT0FBTyxFQUFFLElBQUksRUFBRSxNQUFNLHNDQUFzQyxDQUFDO0FBRzVEO0lBQUE7UUFDWSxnQkFBVyxHQUFHLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQyxJQUFJOzs7O1FBQUMsVUFBQSxJQUFJLElBQUksT0FBQSxJQUFJLENBQUMsR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