'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var schematics = require('@angular-devkit/schematics');
var utility = require('@schematics/angular/utility');
var utils_packageConfig = require('../utils/package-config.js');
require('../utils/messages.js');

function noProject(project) {
    return `Unable to find project '${project}' in the workspace`;
}

/**
 * This is executed when `ng add @koobiq/components` is run.
 * It installs all dependencies in the 'package.json' and runs 'ng-add-setup-project' schematic.
 */
function ngAdd(options) {
    return async (tree) => {
        const { project } = options;
        if (project) {
            const workspace = await utility.readWorkspace(tree);
            const projectWorkspace = workspace.projects.get(project);
            if (!projectWorkspace) {
                throw new schematics.SchematicsException(noProject(project));
            }
        }
        // Installing dependencies
        utils_packageConfig.addPackageToPackageJson(tree, '@angular/cdk', "^18.2.14");
        utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/cdk', "^18.37.0");
        utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/angular-luxon-adapter', "^18.37.0");
        utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/date-formatter', "^3.4.0");
        utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/date-adapter', "^3.4.0");
        utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/icons', "^10.10.0");
        utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/tokens-builder', "^3.14.0");
        utils_packageConfig.addPackageToPackageJson(tree, '@koobiq/design-tokens', "^3.14.0");
        utils_packageConfig.addPackageToPackageJson(tree, '@messageformat/core', "^3.4.0");
        utils_packageConfig.addPackageToPackageJson(tree, '@radix-ng/primitives', "^0.23.0");
        utils_packageConfig.addPackageToPackageJson(tree, 'luxon', "^3.7.2");
    };
}

exports.default = ngAdd;
