"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StickyProcesor = exports.STICKY_STORAGE_KEY = void 0;
const cookie_1 = require("./edge-decider/utils/cookie");
exports.STICKY_STORAGE_KEY = {
    VISITOR_PROFILE: 'VPROF',
    VARIATION_MAP: 'VMAP',
};
const SEPARATOR = '$$';
class StickyProcesor {
    constructor(visitorId, namespace, cookies) {
        this.visitorId = visitorId;
        this.namespace = namespace;
        this.cookies = cookies || {};
    }
    getKey(keyName) {
        return ['OPTY', this.visitorId, this.namespace, keyName].join(SEPARATOR);
    }
    getStringValue(cookieName) {
        return this.cookies[cookieName] || '{}';
    }
    getValue(storage_key) {
        const cookieKey = this.getKey(storage_key);
        const value = this.getStringValue(cookieKey);
        return value ? JSON.parse(value) : null;
    }
    getCookieOptions() {
        return {};
    }
    createCookieString(storage_key, value) {
        const cookieKey = this.getKey(storage_key);
        const cookieValue = JSON.stringify(value);
        return (0, cookie_1.getCookieString)(cookieKey, cookieValue, this.getCookieOptions());
    }
}
exports.StickyProcesor = StickyProcesor;
