'use strict';

const index_esm_min = require('./index.esm.min-1101deb1.js');

class VehicleVinService {
    static isValidVin(vin) {
        vin = (vin || '').toLowerCase();
        const { regex, tables, positions } = index_esm_min.tt;
        if (!regex.test(vin)) {
            return false;
        }
        let sum = 0;
        for (let i = 0; i < vin.length; ++i) {
            sum += tables.translation[vin.charAt(i)] * tables.weights[i];
        }
        const mod = sum % positions.mod;
        return mod === 10 ? vin.charAt(positions.checksum) === 'x' : vin.charAt(positions.checksum) === mod.toString();
    }
    static hasValidLength(vin) {
        return (vin === null || vin === void 0 ? void 0 : vin.length) === 17;
    }
    static getValidationErrorMessage(vin) {
        return this.isValidVin(vin) ? undefined : index_esm_min.tt.messages.invalid;
    }
}
VehicleVinService.VALID_VIN_LENGTH = 17;

exports.VehicleVinService = VehicleVinService;
