import { BriefcaseVisitor } from "./BriefcaseVisitor";
import { MobileCommentsRecordSetVisitor } from "./MobileCommentsRecordSetVisitor";
import { WorkPackagesRecordSetVisitor } from "./WorkPackagesRecordSetVisitor";
/**
 *
 */
export class SdaDialogDelegateStateVisitor {
    constructor(state) {
        if (typeof state === 'string') {
            this._enclosedJsonObject = JSON.parse(state);
        }
        else {
            this._enclosedJsonObject = state;
        }
    }
    // --- State Management Helpers --- //
    // --- State Import/Export --- //
    enclosedJsonObject() {
        return this._enclosedJsonObject;
    }
    copyAsJsonObject() {
        return JSON.parse(this.copyAsJsonString());
    }
    copyAsJsonString() {
        return JSON.stringify(this.enclosedJsonObject());
    }
    // --- State Management --- //
    addSelectedWorkPackageId(id) {
        const index = this.enclosedJsonObject().selectedWorkPackageIds.indexOf(id);
        if (index === -1) {
            this.enclosedJsonObject().selectedWorkPackageIds.push(id);
        }
    }
    removeSelectedWorkPackageId(id) {
        const index = this.enclosedJsonObject().selectedWorkPackageIds.indexOf(id);
        if (index > -1) {
            this.enclosedJsonObject().selectedWorkPackageIds.splice(index, 1);
        }
    }
    visitBaseUrl() {
        return this.enclosedJsonObject().baseUrl;
    }
    visitAndSetBaseUrl(baseUrl) {
        this.enclosedJsonObject().baseUrl = baseUrl;
    }
    visitBriefcase() {
        return new BriefcaseVisitor(this.enclosedJsonObject().briefcase);
    }
    visitLoginHash() {
        return this.enclosedJsonObject().loginHash;
    }
    visitAndSetLoginHash(loginHash) {
        this.enclosedJsonObject().loginHash = loginHash;
    }
    visitSelectedWorkPackageIds() {
        return this.enclosedJsonObject().selectedWorkPackageIds;
    }
    visitAndClearSelectedWorkPackageIds() {
        return this.enclosedJsonObject().selectedWorkPackageIds = [];
    }
    visitSessionId() {
        return this.enclosedJsonObject().sessionId;
    }
    visitAndSetSessionId(sessionId) {
        this.enclosedJsonObject().sessionId = sessionId;
    }
    visitTenantId() {
        return this.enclosedJsonObject().tenantId;
    }
    visitAndSetTenantId(tenantId) {
        this.enclosedJsonObject().tenantId = tenantId;
    }
    visitUserId() {
        return this.enclosedJsonObject().userId;
    }
    visitAndSetUserId(userId) {
        this.enclosedJsonObject().userId = userId;
    }
    visitMobileCommentsRecordSet() {
        return new MobileCommentsRecordSetVisitor(this.enclosedJsonObject().mobileComments);
    }
    visitWorkPackagesRecordSet() {
        return new WorkPackagesRecordSetVisitor(this.enclosedJsonObject().workPackages);
    }
}
