"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.CdmArgumentDefinition = void 0;
const internal_1 = require("../internal");
class CdmArgumentDefinition extends internal_1.cdmObjectSimple {
    constructor(ctx, name) {
        super(ctx);
        this.TAG = CdmArgumentDefinition.name;
        // let bodyCode = () =>
        {
            this.objectType = internal_1.cdmObjectType.argumentDef;
            this.name = name;
        }
        // return p.measure(bodyCode);
    }
    static get objectType() {
        return internal_1.cdmObjectType.argumentDef;
    }
    getObjectType() {
        // let bodyCode = () =>
        {
            return internal_1.cdmObjectType.argumentDef;
        }
        // return p.measure(bodyCode);
    }
    copy(resOpt, host) {
        // let bodyCode = () =>
        {
            if (!resOpt) {
                resOpt = new internal_1.resolveOptions(this, this.ctx.corpus.defaultResolutionDirectives);
            }
            let copy;
            if (!host) {
                copy = new CdmArgumentDefinition(this.ctx, this.name);
            }
            else {
                copy = host;
                copy.ctx = this.ctx;
                copy.name = this.name;
            }
            if (this.value) {
                if (this.value instanceof internal_1.CdmObjectBase) {
                    copy.value = this.value.copy(resOpt);
                }
                else {
                    // Value is a string or object
                    copy.value = this.value;
                }
            }
            copy.resolvedParameter = this.resolvedParameter;
            copy.explanation = this.explanation;
            return copy;
        }
        // return p.measure(bodyCode);
    }
    validate() {
        // let bodyCode = () =>
        {
            if (!this.value) {
                let missingFields = ['value'];
                internal_1.Logger.error(this.ctx, this.TAG, this.validate.name, this.atCorpusPath, internal_1.cdmLogCode.ErrValdnIntegrityCheckFailure, missingFields.map((s) => `'${s}'`).join(', '), this.atCorpusPath);
                return false;
            }
            return true;
        }
        // return p.measure(bodyCode);
    }
    getExplanation() {
        // let bodyCode = () =>
        {
            return this.explanation;
        }
        // return p.measure(bodyCode);
    }
    setExplanation(explanation) {
        // let bodyCode = () =>
        {
            this.explanation = explanation;
            return this.explanation;
        }
        // return p.measure(bodyCode);
    }
    getValue() {
        // let bodyCode = () =>
        {
            return this.value;
        }
        // return p.measure(bodyCode);
    }
    setValue(value) {
        // let bodyCode = () =>
        {
            this.value = value;
        }
        // return p.measure(bodyCode);
    }
    getName() {
        // let bodyCode = () =>
        {
            return this.name;
        }
        // return p.measure(bodyCode);
    }
    /**
     * @internal
     */
    getParameterDef() {
        // let bodyCode = () =>
        {
            return this.resolvedParameter;
        }
        // return p.measure(bodyCode);
    }
    visit(pathFrom, preChildren, postChildren) {
        // let bodyCode = () =>
        {
            const path = pathFrom; // name of arg is forced down from trait ref. you get what you get and you don't throw a fit.
            if (preChildren && preChildren(this, path)) {
                return false;
            }
            if (this.value !== undefined) {
                if (typeof (this.value) === 'object' && 'visit' in this.value && typeof (this.value.visit) === 'function') {
                    if (this.value.visit(`${path}/value/`, preChildren, postChildren)) {
                        return true;
                    }
                }
            }
            if (postChildren && postChildren(this, path)) {
                return true;
            }
            return false;
        }
        // return p.measure(bodyCode);
    }
}
exports.CdmArgumentDefinition = CdmArgumentDefinition;
//# sourceMappingURL=CdmArgumentDefinition.js.map