"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/**
 * penguins-eggs
 * components: summary.tsx
 * author: Piero Proietti
 * email: piero.proietti@gmail.com
 * license: MIT
 */
const react_1 = tslib_1.__importDefault(require("react"));
const ink_1 = require("ink");
const title_1 = tslib_1.__importDefault(require("./elements/title"));
const steps_1 = tslib_1.__importDefault(require("./elements/steps"));
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
const fs_1 = tslib_1.__importDefault(require("fs"));
function Summary({ name, password, rootPassword, hostname, region, zone, language, keyboardModel, keyboardLayout, installationDevice, message }) {
    let productName = 'unknown';
    let version = 'x.x.x';
    let configRoot = '/etc/penguins-eggs.d/krill/';
    if (fs_1.default.existsSync('/etc/calamares/settings.conf')) {
        configRoot = '/etc/calamares/';
    }
    const settings = js_yaml_1.default.load(fs_1.default.readFileSync(configRoot + 'settings.conf', 'utf-8'));
    const branding = settings.branding;
    const calamares = js_yaml_1.default.load(fs_1.default.readFileSync(configRoot + 'branding/' + branding + '/branding.desc', 'utf-8'));
    productName = calamares.strings.productName;
    version = calamares.strings.version;
    /**
    * totale width=74
    * step width=15
    * finestra with=59
    */
    return (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement(title_1.default, { title: productName }),
        react_1.default.createElement(ink_1.Box, { width: 74, height: 11, borderStyle: "round", flexDirection: "column" },
            react_1.default.createElement(ink_1.Box, { flexDirection: "column" },
                react_1.default.createElement(ink_1.Box, { flexDirection: "row" },
                    react_1.default.createElement(steps_1.default, { step: 7 }),
                    react_1.default.createElement(ink_1.Box, { flexDirection: "column" },
                        react_1.default.createElement(ink_1.Box, null,
                            react_1.default.createElement(ink_1.Text, null, "Installing "),
                            react_1.default.createElement(ink_1.Text, { color: "green" }, productName)),
                        react_1.default.createElement(ink_1.Box, null,
                            react_1.default.createElement(ink_1.Text, null),
                            react_1.default.createElement(ink_1.Text, { color: "green" }, name),
                            react_1.default.createElement(ink_1.Text, null, "/"),
                            react_1.default.createElement(ink_1.Text, { color: "green" },
                                password,
                                " "),
                            react_1.default.createElement(ink_1.Text, null, "pwd root "),
                            react_1.default.createElement(ink_1.Text, { color: "green" },
                                rootPassword,
                                " "),
                            react_1.default.createElement(ink_1.Text, null, "hostname "),
                            react_1.default.createElement(ink_1.Text, { color: "green" }, hostname)),
                        react_1.default.createElement(ink_1.Box, null,
                            react_1.default.createElement(ink_1.Text, null, "Set timezone to "),
                            react_1.default.createElement(ink_1.Text, { color: "green" },
                                region,
                                "/",
                                zone)),
                        react_1.default.createElement(ink_1.Box, null,
                            react_1.default.createElement(ink_1.Text, null, "The system language will be set to "),
                            react_1.default.createElement(ink_1.Text, { color: "green" }, language)),
                        react_1.default.createElement(ink_1.Box, null,
                            react_1.default.createElement(ink_1.Text, null, "Numbers and date locale will be set to "),
                            react_1.default.createElement(ink_1.Text, { color: "green" }, language)),
                        react_1.default.createElement(ink_1.Box, null,
                            react_1.default.createElement(ink_1.Text, null, "Set keyboard model to "),
                            react_1.default.createElement(ink_1.Text, { color: "green" },
                                keyboardModel,
                                " "),
                            react_1.default.createElement(ink_1.Text, null, "layout "),
                            react_1.default.createElement(ink_1.Text, { color: "green" }, keyboardLayout)),
                        react_1.default.createElement(ink_1.Box, null,
                            react_1.default.createElement(ink_1.Text, { bold: true }, "Erase disk "),
                            react_1.default.createElement(ink_1.Text, { color: "green" }, installationDevice)),
                        react_1.default.createElement(ink_1.Box, null,
                            react_1.default.createElement(ink_1.Text, { color: "red" }, message))))))));
}
exports.default = Summary;
