;
{
  try {
    let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
    n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "ae8d757e-be7e-4539-9806-67302ab15640", e._sentryDebugIdIdentifier = "sentry-dbid-ae8d757e-be7e-4539-9806-67302ab15640");
  } catch (e) {
  }
}
;
import { jsx } from "preact/jsx-runtime";
import { useMemo } from "preact/hooks";
import { F as Field } from "./Field-BL3Mh7gm.js";
import { S as Select } from "./Select-DbIpx8xz.js";
import { u as useDataset } from "./useDataset-DgIHjoGg.js";
import { d as datasetIdentifier } from "./datasetUtil-BHQp0-xL.js";
import { u as useTranslation } from "./StoreProvider-CqQrndhS.js";
const COUNTRY_FIELD = ["country"];
function CountryField({
  name = "country",
  data,
  valid,
  errors,
  labels,
  readonly,
  handleChangeFor,
  helperText,
  allowedCountries,
  handleBlur
}) {
  const { t } = useTranslation("common");
  const { dataset: countriesFromApi } = useDataset(datasetIdentifier.country);
  const countries = useMemo(
    () => countriesFromApi.filter(
      (country) => allowedCountries ? allowedCountries.includes(country.id) : true
    ),
    [allowedCountries, countriesFromApi]
  );
  return /* @__PURE__ */ jsx(
    Field,
    {
      name,
      label: labels?.country || t(($) => $["country"]),
      errorMessage: errors.country,
      isValid: valid.country,
      helper: helperText,
      dataTestId: "country",
      children: (childProps) => /* @__PURE__ */ jsx(
        Select,
        {
          ...childProps,
          name,
          placeholder: t(($) => $["selectCountryRegion"]),
          selected: data.country,
          items: countries,
          readonly: (countries.length === 1 || readonly) && !!data,
          onChange: handleChangeFor("country"),
          onBlur: handleBlur
        }
      )
    }
  );
}
export {
  CountryField as C,
  COUNTRY_FIELD as a
};
