"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.Project = void 0;
const linq_1 = require("@azure-tools/linq");
const state_1 = require("./state");
const codegen_csharp_1 = require("@azure-tools/codegen-csharp");
const codegen_1 = require("@azure-tools/codegen");
const utility_1 = require("./utility");
class Project extends codegen_csharp_1.Project {
    get model() { return this.state.model; }
    needsTransformationConverter() {
        for (const object of (0, linq_1.values)(this.model.schemas.objects)) {
            for (const property of (0, linq_1.values)(object.properties)) {
                if (property.extensions && property.extensions['x-ms-client-flatten']) {
                    return true;
                }
            }
        }
        return false;
    }
    constructor(service, objectInitializer) {
        super();
        this.service = service;
        this.apply(objectInitializer);
    }
    async init() {
        var _a;
        await super.init();
        this.state = await new state_1.State(this.service).init();
        this.projectNamespace = ((_a = this.state.model.language.csharp) === null || _a === void 0 ? void 0 : _a.namespace) || '';
        this.overrides = {};
        this.license = await this.state.getValue('header-text', '');
        this.namespace = await this.state.getValue('namespace', 'Microsoft.Azure.Sample');
        this.commentHeader = (0, codegen_1.comment)(this.license, '//');
        // Flags
        this.azure = this.model.language.default.isAzure;
        // Names
        this.serviceName = this.model.language.default.serviceName;
        // Folders
        this.baseFolder = await this.state.getValue('current-folder');
        // File paths
        this.gitIgnore = `${this.baseFolder}/.gitignore`;
        this.gitAttributes = `${this.baseFolder}/.gitattributes`;
        this.readme = `${this.baseFolder}/README.md`;
        const useDateTimeOffset = await this.state.getValue('useDateTimeOffset', false);
        this.helper = new utility_1.Helper(useDateTimeOffset);
        // abort now if we have any errors.
        this.state.checkpoint();
        return this;
    }
}
exports.Project = Project;
//# sourceMappingURL=project.js.map