import { ConfigKeyNotSupportedByFirmwareVersion, TapConfiguratorError, } from './errors';
import { READ_CONFIGURATOR_CONFIG as READ_CONFIGURATOR_GENERATED_CONFIG, } from './generated/read-configurator-config';
import { isTapFirmwareVersionGreaterThanOrEqual } from './util';
const ɵ0 = (context) => {
    var _a, _b, _c, _d, _e;
    const protocolType = ((_b = (_a = context.config) === null || _a === void 0 ? void 0 : _a.target) === null || _b === void 0 ? void 0 : _b.type) === 'MCU'
        ? (_e = (_d = (_c = context.config) === null || _c === void 0 ? void 0 : _c.target) === null || _d === void 0 ? void 0 : _d.protocol) === null || _e === void 0 ? void 0 : _e.type
        : 'MODBUS';
    switch (protocolType) {
        case undefined:
        case 'NONE':
        case 'SWD':
        //   case 'JTAG':
        case 'GPIO':
        case 'CUSTOM':
            // Nothing more to read
            return undefined;
        case 'S3P':
            return context.service.target.getS3PConfigurationCall();
        case 'MODBUS':
        case 'SERIAL':
            return context.service.target.getSerialModbusConfigurationCall();
        case 'CAN':
            if (context.firmwareVersion) {
                if (!isTapFirmwareVersionGreaterThanOrEqual(context.firmwareVersion, '2.6')) {
                    return new ConfigKeyNotSupportedByFirmwareVersion('target.protocol.config', context.firmwareVersion, {
                        minApiVersion: '2.6',
                        maxApiVersion: undefined,
                    });
                }
            }
            return context.service.target.getCanConfigurationCall();
        default:
            return TapConfiguratorError.invalidConfiguration(`Target protocol "${protocolType}" is not supported by this version of the configurator`);
    }
};
const READ_CONFIGURATOR_CUSTOM_CONFIG = {
    'target.protocol.config': ɵ0,
};
export const READ_CONFIGURATOR_CONFIG = Object.assign(Object.assign({}, READ_CONFIGURATOR_GENERATED_CONFIG), READ_CONFIGURATOR_CUSTOM_CONFIG);
export { ɵ0 };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVhZC1jb25maWd1cmF0b3ItY29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vY29uZm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