"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.CdmArgumentCollection = void 0;
const internal_1 = require("../internal");
// tslint:disable: no-any
// tslint:disable: no-unsafe-any
class CdmArgumentCollection extends internal_1.CdmCollection {
    get owner() {
        return super.owner;
    }
    set owner(value) {
        super.owner = value;
    }
    constructor(ctx, owner) {
        super(ctx, owner, internal_1.cdmObjectType.argumentDef);
    }
    push(arg, value) {
        this.owner.resolvedArguments = false;
        const argument = super.push(arg);
        if (value !== undefined) {
            argument.value = value;
        }
        return argument;
    }
    insert(index, arg) {
        this.owner.resolvedArguments = false;
        super.insert(index, arg);
    }
    fetchValue(name) {
        for (const argument of this.allItems) {
            if (argument.name === name) {
                return argument.value;
            }
        }
        // special case with only one argument and no name give, make a big assumption that this is the one they want
        // right way is to look up parameter def and check name, but this public interface is for working on an unresolved def
        if (this.allItems.length === 1 && this.allItems[0].name === undefined) {
            return this.allItems[0].value;
        }
        return undefined;
    }
    updateArgument(name, value) {
        this.makeDocumentDirty();
        for (const argument of this.allItems) {
            if (argument.name === name) {
                argument.value = value;
                return;
            }
        }
        this.push(name, value);
    }
}
exports.CdmArgumentCollection = CdmArgumentCollection;
//# sourceMappingURL=CdmArgumentCollection.js.map