"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get createCellHeadersRange () {
        return createCellHeadersRange;
    },
    get extendNotExistingKeys () {
        return extendNotExistingKeys;
    },
    get normalizeLanguageCode () {
        return normalizeLanguageCode;
    },
    get warnUserAboutLanguageRegistration () {
        return warnUserAboutLanguageRegistration;
    }
});
const _mixed = require("./../helpers/mixed");
const _object = require("./../helpers/object");
const _console = require("./../helpers/console");
const _templateLiteralTag = require("./../helpers/templateLiteralTag");
function extendNotExistingKeys(target, extension) {
    (0, _object.objectEach)(extension, (value, key)=>{
        if ((0, _mixed.isUndefined)(target[key])) {
            target[key] = value;
        }
    });
    return target;
}
function createCellHeadersRange(firstRowIndex, nextRowIndex, fromValue = firstRowIndex, toValue = nextRowIndex) {
    // Will swap `fromValue` with `toValue` if it's necessary.
    let [from, to] = [
        fromValue,
        toValue
    ];
    if (firstRowIndex > nextRowIndex) {
        [from, to] = [
            to,
            from
        ];
    }
    return `${from}-${to}`;
}
function normalizeLanguageCode(languageCode) {
    const languageCodePattern = /^([a-zA-Z]{2})-([a-zA-Z]{2})$/;
    const partsOfLanguageCode = languageCodePattern.exec(languageCode);
    if (partsOfLanguageCode) {
        return `${partsOfLanguageCode[1].toLowerCase()}-${partsOfLanguageCode[2].toUpperCase()}`;
    }
    return languageCode;
}
function warnUserAboutLanguageRegistration(languageCode) {
    if ((0, _mixed.isDefined)(languageCode)) {
        (0, _console.error)((0, _templateLiteralTag.toSingleLine)`Language with code "${languageCode}" was not found. You should register particular language\x20
    before using it. Read more about this issue at: https://docs.handsontable.com/i18n/missing-language-code.`);
    }
}
