"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDummyStaticIpInfo = exports.getDummyInfraEnvField = exports.isDummyYaml = exports.isDummyInterface = exports.getDummyMacInterfaceMap = exports.getDummyInterfaces = exports.DUMMY_NMSTATE_ADDRESSES = exports.getDummyMacAddress = exports.getDummyNicName = void 0;
const dataTypes_1 = require("./dataTypes");
const nmstateTypes_1 = require("./nmstateTypes");
const nmstateYaml_1 = require("./nmstateYaml");
const protocolVersion_1 = require("./protocolVersion");
const DUMMY_MAC_4 = '01:23:45:67:89:AB';
const DUMMY_MAC_6 = '01:23:45:67:89:AC';
const DUMMY_NIC_PREFIX = 'DUMMY';
const getDummyNicName = (protocolVersion) => {
    const protocolNumber = protocolVersion === dataTypes_1.ProtocolVersion.ipv4 ? 4 : 6;
    return `${DUMMY_NIC_PREFIX}${protocolNumber}`;
};
exports.getDummyNicName = getDummyNicName;
const getDummyMacAddress = (protocolVersion) => {
    if (protocolVersion === dataTypes_1.ProtocolVersion.ipv4) {
        return DUMMY_MAC_4;
    }
    else {
        return DUMMY_MAC_6;
    }
};
exports.getDummyMacAddress = getDummyMacAddress;
exports.DUMMY_NMSTATE_ADDRESSES = {
    ipv4: {
        prefixLength: 24,
        ip: '0.0.0.0',
    },
    ipv6: {
        prefixLength: 64,
        ip: '0::0',
    },
};
const getDummyInterfaces = () => {
    return [
        {
            name: (0, exports.getDummyNicName)(dataTypes_1.ProtocolVersion.ipv4),
            type: nmstateTypes_1.NmstateInterfaceType.ETHERNET,
            state: 'up',
            ipv4: (0, nmstateYaml_1.getNmstateProtocolConfig)(exports.DUMMY_NMSTATE_ADDRESSES.ipv4.ip, exports.DUMMY_NMSTATE_ADDRESSES.ipv4.prefixLength),
        },
    ];
};
exports.getDummyInterfaces = getDummyInterfaces;
const getDummyMacInterfaceMap = (networkWideConfiguration) => {
    const macInterfaceMap = [];
    if (networkWideConfiguration) {
        for (const protocolVersion of (0, protocolVersion_1.getShownProtocolVersions)(networkWideConfiguration.protocolType)) {
            macInterfaceMap.push({
                macAddress: (0, exports.getDummyMacAddress)(protocolVersion),
                logicalNicName: (0, exports.getDummyNicName)(protocolVersion),
            });
        }
        return macInterfaceMap;
    }
    else {
        return [{ macAddress: DUMMY_MAC_4, logicalNicName: (0, exports.getDummyNicName)(dataTypes_1.ProtocolVersion.ipv4) }];
    }
};
exports.getDummyMacInterfaceMap = getDummyMacInterfaceMap;
const isDummyInterface = (nicName) => {
    return nicName.startsWith(DUMMY_NIC_PREFIX);
};
exports.isDummyInterface = isDummyInterface;
const isDummyYaml = (yaml) => {
    return yaml.includes(DUMMY_NIC_PREFIX);
};
exports.isDummyYaml = isDummyYaml;
const getDummyInfraEnvField = () => {
    const json = { interfaces: (0, exports.getDummyInterfaces)() };
    const comments = [nmstateYaml_1.FORM_VIEW_PREFIX];
    const dummyYaml = (0, nmstateYaml_1.toYamlWithComments)(json, comments);
    return [{ networkYaml: dummyYaml, macInterfaceMap: (0, exports.getDummyMacInterfaceMap)() }];
};
exports.getDummyInfraEnvField = getDummyInfraEnvField;
const getDummyStaticIpInfo = () => ({
    isDataComplete: false,
    view: dataTypes_1.StaticIpView.FORM,
    formViewProtocolType: null,
});
exports.getDummyStaticIpInfo = getDummyStaticIpInfo;
//# sourceMappingURL=dummyData.js.map