"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.PurposePersistence = void 0;
const __1 = require("..");
const internal_1 = require("../../internal");
const copyDataUtils = require("../../Utilities/CopyDataUtils");
const utils = require("./utils");
class PurposePersistence {
    static fromData(ctx, object) {
        const purpose = ctx.corpus.MakeObject(internal_1.cdmObjectType.purposeDef, object.purposeName);
        purpose.extendsPurpose = __1.CdmFolder.PurposeReferencePersistence.fromData(ctx, object.extendsPurpose);
        if (object.explanation) {
            purpose.explanation = object.explanation;
        }
        utils.addArrayToCdmCollection(purpose.exhibitsTraits, utils.createTraitReferenceArray(ctx, object.exhibitsTraits));
        return purpose;
    }
    static toData(instance, resOpt, options) {
        return {
            explanation: instance.explanation,
            purposeName: instance.purposeName,
            extendsPurpose: instance.extendsPurpose
                ? instance.extendsPurpose.copyData(resOpt, options) : undefined,
            exhibitsTraits: copyDataUtils.arrayCopyData(resOpt, instance.exhibitsTraits.allItems, options)
        };
    }
}
exports.PurposePersistence = PurposePersistence;
//# sourceMappingURL=PurposePersistence.js.map