;
{
  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] = "abcb10c7-031c-44c4-9ac6-35feae0965f9", e._sentryDebugIdIdentifier = "sentry-dbid-abcb10c7-031c-44c4-9ac6-35feae0965f9");
  } catch (e) {
  }
}
;
import { s as summaryItem } from "./summaryItem-CAQCQSkt.js";
import { a0 as CountryCodes } from "./StoreProvider-CqQrndhS.js";
const addressFields = [
  "address",
  "otherAddressInformation",
  "postalCode",
  "city",
  "stateOrProvince",
  "country"
];
const [ADDRESS, OTHER_ADDRESS_INFORMATION, POSTAL_CODE, CITY, STATE, COUNTRY] = addressFields;
const COUNTRIES_WITH_STATES_DATASET = [
  CountryCodes.Australia,
  CountryCodes.Brazil,
  CountryCodes.Canada,
  CountryCodes.NewZealand,
  CountryCodes.UnitedStates,
  CountryCodes.Japan
];
const COUNTRIES_WITH_HOUSE_NUMBER_FIRST = [
  CountryCodes.Australia,
  CountryCodes.Canada,
  CountryCodes.NewZealand,
  CountryCodes.PuertoRico,
  CountryCodes.UnitedStates,
  CountryCodes.UnitedKingdom,
  CountryCodes.France
];
const ADDRESS_SCHEMAS = {
  [CountryCodes.Australia]: [COUNTRY, ADDRESS, OTHER_ADDRESS_INFORMATION, CITY, STATE, POSTAL_CODE],
  [CountryCodes.Canada]: [COUNTRY, ADDRESS, OTHER_ADDRESS_INFORMATION, CITY, POSTAL_CODE, STATE],
  [CountryCodes.UnitedKingdom]: [COUNTRY, ADDRESS, OTHER_ADDRESS_INFORMATION, CITY, POSTAL_CODE],
  [CountryCodes.UnitedStates]: [
    COUNTRY,
    ADDRESS,
    OTHER_ADDRESS_INFORMATION,
    CITY,
    STATE,
    POSTAL_CODE
  ],
  [CountryCodes.PuertoRico]: [
    // should exactly match CountryCodes.UnitedStates
    COUNTRY,
    ADDRESS,
    OTHER_ADDRESS_INFORMATION,
    CITY,
    POSTAL_CODE
  ],
  [CountryCodes.HongKong]: [COUNTRY, ADDRESS, OTHER_ADDRESS_INFORMATION, CITY, STATE],
  [CountryCodes.NewZealand]: [
    COUNTRY,
    ADDRESS,
    OTHER_ADDRESS_INFORMATION,
    POSTAL_CODE,
    CITY,
    STATE
  ],
  [CountryCodes.UnitedArabEmirates]: [COUNTRY, ADDRESS, OTHER_ADDRESS_INFORMATION, CITY],
  [CountryCodes.Japan]: [COUNTRY, OTHER_ADDRESS_INFORMATION, POSTAL_CODE, CITY, STATE],
  default: [COUNTRY, ADDRESS, OTHER_ADDRESS_INFORMATION, POSTAL_CODE, CITY, STATE]
};
const CONDENSED_ADDRESS_FIELDS = {
  [CountryCodes.UnitedStates]: [CITY, STATE, POSTAL_CODE]
};
const LABELS = {
  city: {
    default: CITY,
    [CountryCodes.UnitedKingdom]: "cityTown"
  },
  country: {
    default: COUNTRY
  },
  otherAddressInformation: {
    default: OTHER_ADDRESS_INFORMATION,
    [CountryCodes.Canada]: "apartmentSuiteOther",
    [CountryCodes.PuertoRico]: "apartmentSuiteOther",
    // should exactly match CountryCodes.UnitedStates
    [CountryCodes.UnitedStates]: "apartmentSuiteOther"
  },
  postalCode: {
    default: POSTAL_CODE,
    [CountryCodes.PuertoRico]: "zipCode",
    // should exactly match CountryCodes.UnitedStates
    [CountryCodes.UnitedStates]: "zipCode"
  },
  stateOrProvince: {
    default: STATE,
    [CountryCodes.Australia]: "state",
    [CountryCodes.Brazil]: "state",
    [CountryCodes.Canada]: "provinceOrTerritory",
    [CountryCodes.NewZealand]: "region",
    [CountryCodes.UnitedStates]: "state"
  },
  address: {
    default: ADDRESS
  }
};
const getKeyForField = (fieldName, country) => country ? LABELS[fieldName][country] || LABELS[fieldName].default : LABELS[fieldName].default;
const getAddressSchemaForCountry = (country) => country && ADDRESS_SCHEMAS[country] ? ADDRESS_SCHEMAS[country] : ADDRESS_SCHEMAS.default;
const getAddressSchemaLabelsByCountry = (country) => {
  const schema = getAddressSchemaForCountry(country);
  return schema.reduce(
    (labels, field) => ({
      ...labels,
      [field]: getKeyForField(field, country)
    }),
    {}
  );
};
const mapAddressLabels = (data, datasetUtils) => {
  if (data?.country) {
    const addressSchema = getAddressSchemaForCountry(data.country);
    return addressSchema.reduce((mappedAddress, field) => {
      const labelKey = getKeyForField(field, data.country);
      const value = data?.[field];
      if (!value) return mappedAddress;
      switch (field) {
        case "country":
          return {
            ...mappedAddress,
            [field]: summaryItem(
              labelKey,
              datasetUtils.getCountryName(value) ?? value
            )
          };
        case "stateOrProvince":
          return {
            ...mappedAddress,
            [field]: summaryItem(
              labelKey,
              datasetUtils.getStateName(value, data.country) ?? value
            )
          };
        default:
          return { ...mappedAddress, [field]: summaryItem(labelKey, value) };
      }
    }, {});
  }
  return data;
};
export {
  COUNTRIES_WITH_STATES_DATASET as C,
  getAddressSchemaLabelsByCountry as a,
  addressFields as b,
  getKeyForField as c,
  COUNTRIES_WITH_HOUSE_NUMBER_FIRST as d,
  CONDENSED_ADDRESS_FIELDS as e,
  getAddressSchemaForCountry as g,
  mapAddressLabels as m
};
