import { jsx as l } from "react/jsx-runtime";
import { createSlotRecipeContext as f } from "@chakra-ui/react";
import { n, u as T } from "./normalize-messages-D5T4I93D.es.js";
const { withProvider: I, withContext: M } = /* @__PURE__ */ f({
  key: "fieldErrors"
}), V = /* @__PURE__ */ I("div", "root"), o = /* @__PURE__ */ M("div", "message"), r = {
  MISSING: "missing",
  INVALID: "invalid",
  EMPTY: "empty",
  MIN_LENGTH: "min",
  MAX_LENGTH: "max",
  FORMAT: "format",
  DUPLICATE: "duplicate",
  NEGATIVE: "negative",
  FRACTIONS: "fractions",
  BELOW_MIN: "belowMin",
  ABOVE_MAX: "aboveMax",
  OUT_OF_RANGE: "outOfRange",
  INVALID_FROM_SERVER: "invalidFromServer",
  NOT_FOUND: "notFound",
  BLOCKED: "blocked"
}, A = {
  duplicateValue: "This value is already in use. It must be unique.",
  emptyValue: "This field cannot be empty.",
  invalidFormat: "Please enter a valid format.",
  invalidFractionalNumber: "A whole number is required.",
  invalidFromServer: "Server validation failed. Please check your input.",
  invalidNegativeNumber: "Negative number is not supported.",
  invalidValue: "The provided value is invalid.",
  missingRequiredField: "This field is required. Provide a value.",
  resourceNotFound: "The requested resource was not found.",
  valueAboveMaximum: "Value must be less than or equal to the maximum.",
  valueBelowMinimum: "Value must be greater than or equal to the minimum.",
  valueBlocked: "This value is not allowed.",
  valueOutOfRange: "Value must be within the acceptable range.",
  valueTooLong: "This value is too long.",
  valueTooShort: "This value is too short."
}, R = {
  duplicateValue: "Dieser Wert wird bereits verwendet. Er muss eindeutig sein.",
  emptyValue: "Dieses Feld darf nicht leer sein.",
  invalidFormat: "Bitte geben Sie ein gültiges Format ein.",
  invalidFractionalNumber: "Eine ganze Zahl ist erforderlich.",
  invalidFromServer: "Die Servervalidierung ist fehlgeschlagen. Bitte überprüfen Sie Ihre Eingabe.",
  invalidNegativeNumber: "Negative Zahlen werden nicht unterstützt.",
  invalidValue: "Der angegebene Wert ist ungültig.",
  missingRequiredField: "Dies ist ein Pflichtfeld. Bitte geben Sie einen Wert ein.",
  resourceNotFound: "Die angeforderte Ressource wurde nicht gefunden.",
  valueAboveMaximum: "Der Wert muss kleiner oder gleich dem Höchstwert sein.",
  valueBelowMinimum: "Der Wert muss größer oder gleich dem Mindestwert sein.",
  valueBlocked: "Dieser Wert ist nicht erlaubt.",
  valueOutOfRange: "Der Wert muss im akzeptablen Bereich liegen.",
  valueTooLong: "Der Wert ist zu lang.",
  valueTooShort: "Der Wert ist zu kurz."
}, S = {
  duplicateValue: "Este valor ya está en uso. Debe ser único.",
  emptyValue: "Este campo no puede estar vacío.",
  invalidFormat: "Introduce un valor válido.",
  invalidFractionalNumber: "Se requiere un número entero.",
  invalidFromServer: "Ha fallado la validación del servidor. Comprueba tus entradas.",
  invalidNegativeNumber: "Los números negativos no están permitidos.",
  invalidValue: "El valor proporcionado no es válido.",
  missingRequiredField: "Este campo es obligatorio. Proporciona un valor.",
  resourceNotFound: "No se ha encontrado el recurso solicitado.",
  valueAboveMaximum: "El valor debe ser igual o inferior al máximo.",
  valueBelowMinimum: "El valor debe ser igual o superior al mínimo.",
  valueBlocked: "Este valor no está permitido.",
  valueOutOfRange: "El valor debe estar en un rango aceptable.",
  valueTooLong: "Este valor es demasiado largo.",
  valueTooShort: "Este valor es demasiado corto."
}, L = {
  duplicateValue: "Cette clé est déjà utilisée. Elle doit être unique.",
  emptyValue: "Ce champ ne peut pas être vide.",
  invalidFormat: "Veuillez entrer un format valide.",
  invalidFractionalNumber: "Un nombre entier est requis.",
  invalidFromServer: "Échec de la validation du serveur. Veuillez vérifier votre saisie.",
  invalidNegativeNumber: "Nombre négatif non pris en charge.",
  invalidValue: "La valeur fournie n'est pas valide",
  missingRequiredField: "Ce champ est requis. Veuillez indiquer une valeur.",
  resourceNotFound: "Impossible de trouver la ressource demandée.",
  valueAboveMaximum: "La valeur doit être égale ou inférieure au maximum.",
  valueBelowMinimum: "La valeur doit être supérieure ou égale au minimum.",
  valueBlocked: "Cette valeur n'est pas autorisée.",
  valueOutOfRange: "La valeur doit être dans la plage acceptable.",
  valueTooLong: "Cette valeur est trop longue.",
  valueTooShort: "Cette valeur est trop courte."
}, _ = {
  duplicateValue: "O valor já está em uso. Use um valor único.",
  emptyValue: "O campo não pode estar vazio.",
  invalidFormat: "Insira um formato válido.",
  invalidFractionalNumber: "É necessário um número inteiro.",
  invalidFromServer: "A validação do servidor falhou. Verifique os dados inseridos.",
  invalidNegativeNumber: "Números negativos não podem ser usados.",
  invalidValue: "O valor fornecido é inválido.",
  missingRequiredField: "Este campo é obrigatório. Informe um valor.",
  resourceNotFound: "O recurso solicitado não foi encontrado.",
  valueAboveMaximum: "O valor deve ser menor ou igual ao máximo.",
  valueBelowMinimum: "O valor deve ser maior ou igual ao mínimo.",
  valueBlocked: "O valor não é permitido.",
  valueOutOfRange: "O valor deve estar dentro do intervalo aceitável.",
  valueTooLong: "O valor é muito longo.",
  valueTooShort: "O valor é muito curto."
}, B = {
  en: /* @__PURE__ */ n(A),
  de: /* @__PURE__ */ n(R),
  es: /* @__PURE__ */ n(S),
  "fr-FR": /* @__PURE__ */ n(L),
  "pt-BR": /* @__PURE__ */ n(_)
}, D = (a) => typeof a == "object", g = (a, e) => {
  if (!e) return null;
  switch (a) {
    case r.MISSING:
      return e.missing || null;
    case r.INVALID:
      return e.invalid || null;
    case r.EMPTY:
      return e.empty || null;
    case r.MIN_LENGTH:
      return e.min || null;
    case r.MAX_LENGTH:
      return e.max || null;
    case r.FORMAT:
      return e.format || null;
    case r.DUPLICATE:
      return e.duplicate || null;
    case r.NEGATIVE:
      return e.negative || null;
    case r.FRACTIONS:
      return e.fractions || null;
    case r.BELOW_MIN:
      return e.belowMin || null;
    case r.ABOVE_MAX:
      return e.aboveMax || null;
    case r.OUT_OF_RANGE:
      return e.outOfRange || null;
    case r.INVALID_FROM_SERVER:
      return e.invalidFromServer || null;
    case r.NOT_FOUND:
      return e.notFound || null;
    case r.BLOCKED:
      return e.blocked || null;
    default:
      return null;
  }
}, E = (a, e) => {
  switch (a) {
    // Basic validation
    case r.MISSING:
      return e("missingRequiredField");
    case r.INVALID:
      return e("invalidValue");
    case r.EMPTY:
      return e("emptyValue");
    // Length validation
    case r.MIN_LENGTH:
      return e("valueTooShort");
    case r.MAX_LENGTH:
      return e("valueTooLong");
    // Format validation
    case r.FORMAT:
      return e("invalidFormat");
    case r.DUPLICATE:
      return e("duplicateValue");
    // Numeric validation
    case r.NEGATIVE:
      return e("invalidNegativeNumber");
    case r.FRACTIONS:
      return e("invalidFractionalNumber");
    case r.BELOW_MIN:
      return e("valueBelowMinimum");
    case r.ABOVE_MAX:
      return e("valueAboveMaximum");
    case r.OUT_OF_RANGE:
      return e("valueOutOfRange");
    // Server/async validation
    case r.INVALID_FROM_SERVER:
      return e("invalidFromServer");
    case r.NOT_FOUND:
      return e("resourceNotFound");
    case r.BLOCKED:
      return e("valueBlocked");
    default:
      return null;
  }
}, t = ({
  id: a,
  errors: e,
  isVisible: N = !0,
  // Default to true for backwards compatibility, but will be auto-handled in future
  renderError: p,
  renderDefaultError: F,
  customMessages: b,
  ...O
}) => {
  const h = T(B);
  if (!N || !e || !D(e)) return null;
  const u = Object.entries(e).filter(([, i]) => i);
  return u.length === 0 ? null : /* @__PURE__ */ l(V, { id: a, role: "alert", ...O, children: u.map(([i, s]) => {
    const d = p?.(i, s);
    if (d)
      return /* @__PURE__ */ l(o, { children: d }, i);
    const v = F?.(i, s);
    if (v)
      return /* @__PURE__ */ l(o, { children: v }, i);
    const c = g(i, b);
    if (c)
      return /* @__PURE__ */ l(o, { children: c }, i);
    const m = E(i, h.format);
    return m ? /* @__PURE__ */ l(o, { children: m }, i) : null;
  }) });
};
t.displayName = "FieldErrors";
t.errorTypes = r;
t.getBuiltInMessage = E;
t.getCustomMessage = g;
export {
  t as F,
  r as a
};
//# sourceMappingURL=field-errors-D1BQvoYg.es.js.map
