import { DialogProxyTools } from "./DialogProxyTools";
/**
 *
 */
export class SessionVisitor {
    constructor(value) {
        if (!value) {
            throw new Error('SessionVisitor -- null value exception');
        }
        if (typeof value === 'string') {
            this._enclosedJsonObject = JSON.parse(value);
        }
        else {
            this._enclosedJsonObject = value;
        }
        if (!DialogProxyTools.isSessionModel(this._enclosedJsonObject)) {
            throw new Error("Object passed to SessionVisitor is not a Session");
        }
    }
    // --- State Management Helpers --- //
    static visitUserId(session) {
        return (new SessionVisitor(session)).visitUserId();
    }
    // --- State Import/Export --- //
    copyAsJsonObject() {
        return JSON.parse(this.copyAsJsonString());
    }
    copyAsJsonString() {
        return JSON.stringify(this.enclosedJsonObject());
    }
    enclosedJsonObject() {
        return this._enclosedJsonObject;
    }
    // --- State Management --- //
    propagateSessionId(sessionId) {
        this.enclosedJsonObject()['id'] = sessionId;
    }
    visitId() {
        return this.enclosedJsonObject().id;
    }
    visitTenantId() {
        return this.enclosedJsonObject().tenantId;
    }
    visitUserId() {
        return this.enclosedJsonObject().userId;
    }
}
