/*!
 * Built by ShiftSoftware
 * Copyright (c)
 */
import { y } from "../../../components/forms/defaults/validation";
import { getNestedValue } from "../../../global/lib/get-nested-value";
export const getInputLocalization = (context, meta, errorMessage) => {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
    const [locale, language] = (_a = context === null || context === void 0 ? void 0 : context.form) === null || _a === void 0 ? void 0 : _a.getFormLocale();
    const label = ((_c = (_b = context === null || context === void 0 ? void 0 : context.localization) === null || _b === void 0 ? void 0 : _b[language]) === null || _c === void 0 ? void 0 : _c.label) || getNestedValue(locale, meta === null || meta === void 0 ? void 0 : meta.label) || (meta === null || meta === void 0 ? void 0 : meta.label);
    const placeholder = ((_e = (_d = context === null || context === void 0 ? void 0 : context.localization) === null || _d === void 0 ? void 0 : _d[language]) === null || _e === void 0 ? void 0 : _e.placeholder) || getNestedValue(locale, meta === null || meta === void 0 ? void 0 : meta.placeholder) || (meta === null || meta === void 0 ? void 0 : meta.placeholder);
    let localizationErrorMessage = '';
    if (errorMessage === null || errorMessage === void 0 ? void 0 : errorMessage.endsWith(y.format('')))
        localizationErrorMessage = (_g = (_f = context === null || context === void 0 ? void 0 : context.localization) === null || _f === void 0 ? void 0 : _f[language]) === null || _g === void 0 ? void 0 : _g.format;
    if (errorMessage === null || errorMessage === void 0 ? void 0 : errorMessage.endsWith(y.size('')))
        localizationErrorMessage = (_j = (_h = context === null || context === void 0 ? void 0 : context.localization) === null || _h === void 0 ? void 0 : _h[language]) === null || _j === void 0 ? void 0 : _j.size;
    else if (errorMessage === null || errorMessage === void 0 ? void 0 : errorMessage.endsWith(y.require('')))
        localizationErrorMessage = (_l = (_k = context === null || context === void 0 ? void 0 : context.localization) === null || _k === void 0 ? void 0 : _k[language]) === null || _l === void 0 ? void 0 : _l.require;
    else if (errorMessage === 'minMessage')
        localizationErrorMessage = context === null || context === void 0 ? void 0 : context.withSlots(((_o = (_m = context === null || context === void 0 ? void 0 : context.localization) === null || _m === void 0 ? void 0 : _m[language]) === null || _o === void 0 ? void 0 : _o.minMessage) || 'Min date is $minDate$');
    else if (errorMessage === 'maxMessage')
        localizationErrorMessage = context === null || context === void 0 ? void 0 : context.withSlots(((_q = (_p = context === null || context === void 0 ? void 0 : context.localization) === null || _p === void 0 ? void 0 : _p[language]) === null || _q === void 0 ? void 0 : _q.maxMessage) || 'Max date is $maxDate$');
    else if (errorMessage === 'betweenMessage')
        localizationErrorMessage = context === null || context === void 0 ? void 0 : context.withSlots(((_s = (_r = context === null || context === void 0 ? void 0 : context.localization) === null || _r === void 0 ? void 0 : _r[language]) === null || _s === void 0 ? void 0 : _s.betweenMessage) || 'Must be between $minDate$ and $maxDate$');
    const errorTextMessage = localizationErrorMessage || locale[errorMessage] || errorMessage;
    return { label, placeholder, errorTextMessage };
};
