export const CENSUS_HEADER_DISPLAY_FIELDS = [
  { fieldLabel: "Page Number", fieldName: "SourcePageNumber", defaultSelected: true },
  { fieldLabel: "Residence Day", fieldName: "SelfResidenceDay", defaultSelected: true },
  { fieldLabel: "Residence Month", fieldName: "SelfResidenceMonth", defaultSelected: true },
  { fieldLabel: "Residence Year", fieldName: "SelfResidenceYear", defaultSelected: true },
  { fieldLabel: "Commune", fieldName: "SelfResidenceCity", defaultSelected: true },
  { fieldLabel: "Département", fieldName: "SelfResidenceState", defaultSelected: true },
  { fieldLabel: "Township", fieldName: "SelfResidenceTownship", defaultSelected: true },
  { fieldLabel: "Street Address", fieldName: "SelfResidenceStreetAddress", defaultSelected: true },
];

export const BDM_HEADER_DISPLAY_FIELDS = [
  { fieldLabel: "Département", fieldName: "SelfVitalState", defaultSelected: true },
  { fieldLabel: "Header Year", fieldName: "HeaderYear", defaultSelected: true },
  { fieldLabel: "Header Canton", fieldName: "SelfVitalTownship", defaultSelected: true },
  { fieldLabel: "Header Commune", fieldName: "SelfVitalCity1", defaultSelected: true },
  { fieldLabel: "Title Keyed", fieldName: "SourceTitle", defaultSelected: true },
  { fieldLabel: "Item Number", fieldName: "SourceItemNumber", defaultSelected: true },
  { fieldLabel: "Header Language", fieldName: "HeaderLanguage", defaultSelected: true },
];

/** Census vs BDM for built-in header templates (sub-project tab names map via root_kind). */

export const fieldsByKindConfig = {
  Census: {
    __HEADER__: CENSUS_HEADER_DISPLAY_FIELDS,
    Census: [
      { fieldLabel: "Given Name", fieldName: "SelfGivenName", defaultSelected: true },
      { fieldLabel: "Surname", fieldName: "SelfSurname", defaultSelected: true },
      { fieldLabel: "Relationship", fieldName: "SelfRelationToHead", defaultSelected: true },
      { fieldLabel: "Gender", fieldName: "SelfGender", defaultSelected: true },
      { fieldLabel: "Marital Status", fieldName: "SelfMaritalStatus", defaultSelected: true },
      { fieldLabel: "Age", fieldName: "SelfResidenceAge", defaultSelected: true },
      { fieldLabel: "Birth Day", fieldName: "SelfBirthDay" },
      { fieldLabel: "Birth Month", fieldName: "SelfBirthMonth" },
      { fieldLabel: "Birth Year", fieldName: "SelfBirthYear" },
      { fieldLabel: "Ménage Number", fieldName: "Famnum", defaultSelected: true },
      { fieldLabel: "Maison Number", fieldName: "HouseNumber", defaultSelected: true },
      { fieldLabel: "Page Number", fieldName: "SourcePageNumber", defaultSelected: true },
      { fieldLabel: "Individual Number", fieldName: "LineNumber", defaultSelected: true },
      { fieldLabel: "Nationality", fieldName: "SelfNationality" },
      { fieldLabel: "Birth Place", fieldName: "SelfBirthPlace", defaultSelected: true },
      { fieldLabel: "Residence Day", fieldName: "SelfResidenceDay" },
      { fieldLabel: "Residence Month", fieldName: "SelfResidenceMonth" },
      { fieldLabel: "Residence Year", fieldName: "SelfResidenceYear" },
    ],
    Coverage: [
      { fieldLabel: "Residence Day", fieldName: "SelfResidenceDay" },
      { fieldLabel: "Residence Month", fieldName: "SelfResidenceMonth" },
      { fieldLabel: "Residence Year", fieldName: "SelfResidenceYear" },
      { fieldLabel: "Commune", fieldName: "SelfResidenceCity" },
      { fieldLabel: "Township", fieldName: "SelfResidenceTownship" },
      { fieldLabel: "Street Address", fieldName: "SelfResidenceStreetAddress" },
      { fieldLabel: "Département", fieldName: "SelfResidenceState" },
    ],
  },
  BDM: {
    __HEADER__: BDM_HEADER_DISPLAY_FIELDS,
    __GENERAL__: [
      { fieldLabel: "Event Type", fieldName: "RecordType", defaultSelected: true },
      { fieldLabel: "Département", fieldName: "SelfVitalState" },
      { fieldLabel: "Header Year", fieldName: "HeaderYear" },
      { fieldLabel: "Header Canton", fieldName: "SelfVitalTownship" },
      { fieldLabel: "Header Commune", fieldName: "SelfVitalCity1" },
      { fieldLabel: "Entry Number", fieldName: "EntryNumber", defaultSelected: true },
      { fieldLabel: "Event Commune", fieldName: "SelfVitalCity", defaultSelected: true },
      { fieldLabel: "Prefix", fieldName: "SelfNamePrefix" },
      { fieldLabel: "Given Name", fieldName: "SelfGivenName", defaultSelected: true },
      { fieldLabel: "Surname", fieldName: "SelfSurname", defaultSelected: true },
      { fieldLabel: "Suffix", fieldName: "SelfNameSuffix" },
      { fieldLabel: "Gender", fieldName: "SelfGender", defaultSelected: true },
      { fieldLabel: "Registration Day", fieldName: "SelfVitalDay", defaultSelected: true },
      { fieldLabel: "Registration Month", fieldName: "SelfVitalMonth", defaultSelected: true },
      { fieldLabel: "Registration Year", fieldName: "SelfVitalYear", defaultSelected: true },
      { fieldLabel: "Birth Day", fieldName: "SelfBirthDay", defaultSelected: true },
      { fieldLabel: "Birth Month", fieldName: "SelfBirthMonth" },
      { fieldLabel: "Birth Year", fieldName: "SelfBirthYear" },
      { fieldLabel: "Birth Place", fieldName: "SelfBirthPlace", defaultSelected: true },
      { fieldLabel: "Republican Birth Day", fieldName: "SelfBirthFrenchRepublicanDay" },
      { fieldLabel: "Republican Birth Month", fieldName: "SelfBirthFrenchRepublicanMonth" },
      { fieldLabel: "Republican Birth Year", fieldName: "SelfBirthFrenchRepublicanYear" },
    ],
    Birth: [
      { fieldLabel: "Baptism Day", fieldName: "SelfBaptismDay" },
      { fieldLabel: "Baptism Month", fieldName: "SelfBaptismMonth" },
      { fieldLabel: "Baptism Year", fieldName: "SelfBaptismYear" },
      { fieldLabel: "Baptism Place", fieldName: "SelfBaptismPlace" },
      { fieldLabel: "Father Prefix", fieldName: "FatherNamePrefix" },
      { fieldLabel: "Father Given Name", fieldName: "FatherGivenName", defaultSelected: true },
      { fieldLabel: "Father Surname", fieldName: "FatherSurname", defaultSelected: true },
      { fieldLabel: "Father Suffix", fieldName: "FatherNameSuffix" },
      { fieldLabel: "Father Age", fieldName: "FatherResidenceAge", defaultSelected: true },
      { fieldLabel: "Father Birth Place", fieldName: "FatherBirthPlace" },
      { fieldLabel: "Father Death Day", fieldName: "FatherDeathDay" },
      { fieldLabel: "Father Death Month", fieldName: "FatherDeathMonth" },
      { fieldLabel: "Father Death Year", fieldName: "FatherDeathYear" },
      { fieldLabel: "Father Death Place", fieldName: "FatherDeathPlace" },
      { fieldLabel: "Deceased Father", fieldName: "FatherIsDeceased" },
      { fieldLabel: "Mother Prefix", fieldName: "MotherNamePrefix" },
      { fieldLabel: "Mother Given Name", fieldName: "MotherGivenName", defaultSelected: true },
      { fieldLabel: "Mother Surname", fieldName: "MotherSurname", defaultSelected: true },
      { fieldLabel: "Mother Suffix", fieldName: "MotherNameSuffix" },
      { fieldLabel: "Mother Age", fieldName: "MotherResidenceAge", defaultSelected: true },
      { fieldLabel: "Mother Birth Place", fieldName: "MotherBirthPlace" },
      { fieldLabel: "Mother Death Day", fieldName: "MotherDeathDay" },
      { fieldLabel: "Mother Death Month", fieldName: "MotherDeathMonth" },
      { fieldLabel: "Mother Death Year", fieldName: "MotherDeathYear" },
      { fieldLabel: "Mother Death Place", fieldName: "MotherDeathPlace" },
      { fieldLabel: "Deceased Mother", fieldName: "MotherIsDeceased" },
      { fieldLabel: "Header Language", fieldName: "HeaderLanguage" },
    ],
    Baptism: [
      { fieldLabel: "Baptism Day", fieldName: "SelfBaptismDay" },
      { fieldLabel: "Baptism Month", fieldName: "SelfBaptismMonth" },
      { fieldLabel: "Baptism Year", fieldName: "SelfBaptismYear" },
      { fieldLabel: "Baptism Place", fieldName: "SelfBaptismPlace" },
      { fieldLabel: "Father Prefix", fieldName: "FatherNamePrefix" },
      { fieldLabel: "Father Given Name", fieldName: "FatherGivenName", defaultSelected: true },
      { fieldLabel: "Father Surname", fieldName: "FatherSurname", defaultSelected: true },
      { fieldLabel: "Father Suffix", fieldName: "FatherNameSuffix" },
      { fieldLabel: "Father Age", fieldName: "FatherResidenceAge", defaultSelected: true },
      { fieldLabel: "Father Birth Place", fieldName: "FatherBirthPlace" },
      { fieldLabel: "Father Death Day", fieldName: "FatherDeathDay" },
      { fieldLabel: "Father Death Month", fieldName: "FatherDeathMonth" },
      { fieldLabel: "Father Death Year", fieldName: "FatherDeathYear" },
      { fieldLabel: "Father Death Place", fieldName: "FatherDeathPlace" },
      { fieldLabel: "Deceased Father", fieldName: "FatherIsDeceased" },
      { fieldLabel: "Mother Prefix", fieldName: "MotherNamePrefix" },
      { fieldLabel: "Mother Given Name", fieldName: "MotherGivenName", defaultSelected: true },
      { fieldLabel: "Mother Surname", fieldName: "MotherSurname", defaultSelected: true },
      { fieldLabel: "Mother Suffix", fieldName: "MotherNameSuffix" },
      { fieldLabel: "Mother Age", fieldName: "MotherResidenceAge", defaultSelected: true },
      { fieldLabel: "Mother Birth Place", fieldName: "MotherBirthPlace" },
      { fieldLabel: "Mother Death Day", fieldName: "MotherDeathDay" },
      { fieldLabel: "Mother Death Month", fieldName: "MotherDeathMonth" },
      { fieldLabel: "Mother Death Year", fieldName: "MotherDeathYear" },
      { fieldLabel: "Mother Death Place", fieldName: "MotherDeathPlace" },
      { fieldLabel: "Deceased Mother", fieldName: "MotherIsDeceased" },
      { fieldLabel: "Header Language", fieldName: "HeaderLanguage" },
    ],
    Marriage: [
      { fieldLabel: "Marriage Day", fieldName: "SelfMarriageDay", defaultSelected: true },
      { fieldLabel: "Marriage Month", fieldName: "SelfMarriageMonth", defaultSelected: true },
      { fieldLabel: "Marriage Year", fieldName: "SelfMarriageYear", defaultSelected: true },
      { fieldLabel: "Marriage Age", fieldName: "SelfMarriageAge", defaultSelected: true },
      { fieldLabel: "Banns Day", fieldName: "SelfMarriageBannsDay" },
      { fieldLabel: "Banns Month", fieldName: "SelfMarriageBannsMonth" },
      { fieldLabel: "Banns Year", fieldName: "SelfMarriageBannsYear" },
      { fieldLabel: "Banns Age", fieldName: "SelfMarriageBannsAge" },
      { fieldLabel: "Banns Place", fieldName: "SelfMarriageBannsPlace" },
      { fieldLabel: "Father Prefix", fieldName: "FatherNamePrefix" },
      { fieldLabel: "Father Given Name", fieldName: "FatherGivenName", defaultSelected: true },
      { fieldLabel: "Father Surname", fieldName: "FatherSurname" },
      { fieldLabel: "Father Suffix", fieldName: "FatherNameSuffix" },
      { fieldLabel: "Father Birth Place", fieldName: "FatherBirthPlace" },
      { fieldLabel: "Father Age", fieldName: "FatherResidenceAge" },
      { fieldLabel: "Father Death Day", fieldName: "FatherDeathDay" },
      { fieldLabel: "Father Death Month", fieldName: "FatherDeathMonth" },
      { fieldLabel: "Father Death Year", fieldName: "FatherDeathYear" },
      { fieldLabel: "Father Death Place", fieldName: "FatherDeathPlace" },
      { fieldLabel: "Deceased Father", fieldName: "FatherIsDeceased" },
      { fieldLabel: "Mother Prefix", fieldName: "MotherNamePrefix" },
      { fieldLabel: "Mother Given Name", fieldName: "MotherGivenName", defaultSelected: true },
      { fieldLabel: "Mother Surname", fieldName: "MotherSurname", defaultSelected: true },
      { fieldLabel: "Mother Suffix", fieldName: "MotherNameSuffix" },
      { fieldLabel: "Mother Birth Place", fieldName: "MotherBirthPlace" },
      { fieldLabel: "Mother Age", fieldName: "MotherResidenceAge" },
      { fieldLabel: "Mother Death Day", fieldName: "MotherDeathDay" },
      { fieldLabel: "Mother Death Month", fieldName: "MotherDeathMonth" },
      { fieldLabel: "Mother Death Year", fieldName: "MotherDeathYear" },
      { fieldLabel: "Mother Death Place", fieldName: "MotherDeathPlace" },
      { fieldLabel: "Deceased Mother", fieldName: "MotherIsDeceased", defaultSelected: true },
      { fieldLabel: "Spouse Prefix", fieldName: "SpouseNamePrefix" },
      { fieldLabel: "Spouse Given Name", fieldName: "SpouseGivenName", defaultSelected: true },
      { fieldLabel: "Spouse Surname", fieldName: "SpouseSurname", defaultSelected: true },
      { fieldLabel: "Spouse Suffix", fieldName: "SpouseNameSuffix" },
      { fieldLabel: "Spouse Gender", fieldName: "SpouseGender", defaultSelected: true },
      { fieldLabel: "Spouse Birth Day", fieldName: "SpouseBirthDay" },
      { fieldLabel: "Spouse Birth Month", fieldName: "SpouseBirthMonth" },
      { fieldLabel: "Spouse Birth Year", fieldName: "SpouseBirthYear" },
      { fieldLabel: "Spouse Birth Place", fieldName: "SpouseBirthPlace" },
      { fieldLabel: "Spouse Marriage Age", fieldName: "SpouseMarriageAge", defaultSelected: true },
      { fieldLabel: "Spouse Banns Age", fieldName: "SpouseMarriageBannsAge" },
      { fieldLabel: "Spouse Father Prefix", fieldName: "FatherInLawNamePrefix" },
      { fieldLabel: "Spouse Father Given Name", fieldName: "FatherInLawGivenName", defaultSelected: true },
      { fieldLabel: "Spouse Father Surname", fieldName: "FatherInLawSurname", defaultSelected: true },
      { fieldLabel: "Spouse Father Suffix", fieldName: "FatherInLawNameSuffix" },
      { fieldLabel: "Spouse Father Birth Place", fieldName: "FatherInLawBirthPlace" },
      { fieldLabel: "Spouse Father Age", fieldName: "FatherInLawResidenceAge" },
      { fieldLabel: "Spouse Father Death Day", fieldName: "FatherInLawDeathDay" },
      { fieldLabel: "Spouse Father Death Month", fieldName: "FatherInLawDeathMonth" },
      { fieldLabel: "Spouse Father Death Year", fieldName: "FatherInLawDeathYear" },
      { fieldLabel: "Spouse Father Death Place", fieldName: "FatherInLawDeathPlace" },
      { fieldLabel: "Deceased Spouse Father", fieldName: "FatherInLawIsDeceased" },
      { fieldLabel: "Spouse Mother Prefix", fieldName: "MotherInLawNamePrefix" },
      { fieldLabel: "Spouse Mother Given Name", fieldName: "MotherInLawGivenName", defaultSelected: true },
      { fieldLabel: "Spouse Mother Surname", fieldName: "MotherInLawSurname", defaultSelected: true },
      { fieldLabel: "Spouse Mother Suffix", fieldName: "MotherInLawNameSuffix" },
      { fieldLabel: "Spouse Mother Birth Place", fieldName: "MotherInLawBirthPlace" },
      { fieldLabel: "Spouse Mother Age", fieldName: "MotherInLawResidenceAge" },
      { fieldLabel: "Spouse Mother Death Day", fieldName: "MotherInLawDeathDay" },
      { fieldLabel: "Spouse Mother Death Month", fieldName: "MotherInLawDeathMonth" },
      { fieldLabel: "Spouse Mother Death Year", fieldName: "MotherInLawDeathYear" },
      { fieldLabel: "Spouse Mother Death Place", fieldName: "MotherInLawDeathPlace" },
      { fieldLabel: "Deceased Spouse Mother", fieldName: "MotherInLawIsDeceased", defaultSelected: true },
      { fieldLabel: "Header Language", fieldName: "HeaderLanguage" },
    ],
    Banns: [
      { fieldLabel: "Marriage Day", fieldName: "SelfMarriageDay", defaultSelected: true },
      { fieldLabel: "Marriage Month", fieldName: "SelfMarriageMonth", defaultSelected: true },
      { fieldLabel: "Marriage Year", fieldName: "SelfMarriageYear", defaultSelected: true },
      { fieldLabel: "Marriage Age", fieldName: "SelfMarriageAge", defaultSelected: true },
      { fieldLabel: "Banns Day", fieldName: "SelfMarriageBannsDay" },
      { fieldLabel: "Banns Month", fieldName: "SelfMarriageBannsMonth" },
      { fieldLabel: "Banns Year", fieldName: "SelfMarriageBannsYear" },
      { fieldLabel: "Banns Age", fieldName: "SelfMarriageBannsAge" },
      { fieldLabel: "Banns Place", fieldName: "SelfMarriageBannsPlace" },
      { fieldLabel: "Father Prefix", fieldName: "FatherNamePrefix" },
      { fieldLabel: "Father Given Name", fieldName: "FatherGivenName", defaultSelected: true },
      { fieldLabel: "Father Surname", fieldName: "FatherSurname" },
      { fieldLabel: "Father Suffix", fieldName: "FatherNameSuffix" },
      { fieldLabel: "Father Birth Place", fieldName: "FatherBirthPlace" },
      { fieldLabel: "Father Age", fieldName: "FatherResidenceAge" },
      { fieldLabel: "Father Death Day", fieldName: "FatherDeathDay" },
      { fieldLabel: "Father Death Month", fieldName: "FatherDeathMonth" },
      { fieldLabel: "Father Death Year", fieldName: "FatherDeathYear" },
      { fieldLabel: "Father Death Place", fieldName: "FatherDeathPlace" },
      { fieldLabel: "Deceased Father", fieldName: "FatherIsDeceased" },
      { fieldLabel: "Mother Prefix", fieldName: "MotherNamePrefix" },
      { fieldLabel: "Mother Given Name", fieldName: "MotherGivenName", defaultSelected: true },
      { fieldLabel: "Mother Surname", fieldName: "MotherSurname", defaultSelected: true },
      { fieldLabel: "Mother Suffix", fieldName: "MotherNameSuffix" },
      { fieldLabel: "Mother Birth Place", fieldName: "MotherBirthPlace" },
      { fieldLabel: "Mother Age", fieldName: "MotherResidenceAge" },
      { fieldLabel: "Mother Death Day", fieldName: "MotherDeathDay" },
      { fieldLabel: "Mother Death Month", fieldName: "MotherDeathMonth" },
      { fieldLabel: "Mother Death Year", fieldName: "MotherDeathYear" },
      { fieldLabel: "Mother Death Place", fieldName: "MotherDeathPlace" },
      { fieldLabel: "Deceased Mother", fieldName: "MotherIsDeceased", defaultSelected: true },
      { fieldLabel: "Spouse Prefix", fieldName: "SpouseNamePrefix" },
      { fieldLabel: "Spouse Given Name", fieldName: "SpouseGivenName", defaultSelected: true },
      { fieldLabel: "Spouse Surname", fieldName: "SpouseSurname", defaultSelected: true },
      { fieldLabel: "Spouse Suffix", fieldName: "SpouseNameSuffix" },
      { fieldLabel: "Spouse Gender", fieldName: "SpouseGender", defaultSelected: true },
      { fieldLabel: "Spouse Birth Day", fieldName: "SpouseBirthDay" },
      { fieldLabel: "Spouse Birth Month", fieldName: "SpouseBirthMonth" },
      { fieldLabel: "Spouse Birth Year", fieldName: "SpouseBirthYear" },
      { fieldLabel: "Spouse Birth Place", fieldName: "SpouseBirthPlace" },
      { fieldLabel: "Spouse Marriage Age", fieldName: "SpouseMarriageAge", defaultSelected: true },
      { fieldLabel: "Spouse Banns Age", fieldName: "SpouseMarriageBannsAge" },
      { fieldLabel: "Spouse Father Prefix", fieldName: "FatherInLawNamePrefix" },
      { fieldLabel: "Spouse Father Given Name", fieldName: "FatherInLawGivenName", defaultSelected: true },
      { fieldLabel: "Spouse Father Surname", fieldName: "FatherInLawSurname", defaultSelected: true },
      { fieldLabel: "Spouse Father Suffix", fieldName: "FatherInLawNameSuffix" },
      { fieldLabel: "Spouse Father Birth Place", fieldName: "FatherInLawBirthPlace" },
      { fieldLabel: "Spouse Father Age", fieldName: "FatherInLawResidenceAge" },
      { fieldLabel: "Spouse Father Death Day", fieldName: "FatherInLawDeathDay" },
      { fieldLabel: "Spouse Father Death Month", fieldName: "FatherInLawDeathMonth" },
      { fieldLabel: "Spouse Father Death Year", fieldName: "FatherInLawDeathYear" },
      { fieldLabel: "Spouse Father Death Place", fieldName: "FatherInLawDeathPlace" },
      { fieldLabel: "Deceased Spouse Father", fieldName: "FatherInLawIsDeceased" },
      { fieldLabel: "Spouse Mother Prefix", fieldName: "MotherInLawNamePrefix" },
      { fieldLabel: "Spouse Mother Given Name", fieldName: "MotherInLawGivenName", defaultSelected: true },
      { fieldLabel: "Spouse Mother Surname", fieldName: "MotherInLawSurname", defaultSelected: true },
      { fieldLabel: "Spouse Mother Suffix", fieldName: "MotherInLawNameSuffix" },
      { fieldLabel: "Spouse Mother Birth Place", fieldName: "MotherInLawBirthPlace" },
      { fieldLabel: "Spouse Mother Age", fieldName: "MotherInLawResidenceAge" },
      { fieldLabel: "Spouse Mother Death Day", fieldName: "MotherInLawDeathDay" },
      { fieldLabel: "Spouse Mother Death Month", fieldName: "MotherInLawDeathMonth" },
      { fieldLabel: "Spouse Mother Death Year", fieldName: "MotherInLawDeathYear" },
      { fieldLabel: "Spouse Mother Death Place", fieldName: "MotherInLawDeathPlace" },
      { fieldLabel: "Deceased Spouse Mother", fieldName: "MotherInLawIsDeceased", defaultSelected: true },
      { fieldLabel: "Header Language", fieldName: "HeaderLanguage" },
    ],
    Death: [
      { fieldLabel: "Death Day", fieldName: "SelfDeathDay", defaultSelected: true },
      { fieldLabel: "Death Month", fieldName: "SelfDeathMonth" },
      { fieldLabel: "Death Year", fieldName: "SelfDeathYear" },
      { fieldLabel: "Republican Death Day", fieldName: "SelfDeathFrenchRepublicanDay" },
      { fieldLabel: "Republican Death Month", fieldName: "SelfDeathFrenchRepublicanMonth" },
      { fieldLabel: "Republican Death Year", fieldName: "SelfDeathFrenchRepublicanYear", defaultSelected: true },
      { fieldLabel: "Death Age", fieldName: "SelfDeathAge" },
      { fieldLabel: "Burial Day", fieldName: "SelfBurialDay" },
      { fieldLabel: "Burial Month", fieldName: "SelfBurialMonth" },
      { fieldLabel: "Burial Year", fieldName: "SelfBurialYear" },
      { fieldLabel: "Burial Age", fieldName: "SelfBurialAge" },
      { fieldLabel: "Father Prefix", fieldName: "FatherNamePrefix" },
      { fieldLabel: "Father Given Name", fieldName: "FatherGivenName" },
      { fieldLabel: "Father Surname", fieldName: "FatherSurname" },
      { fieldLabel: "Father Suffix", fieldName: "FatherNameSuffix" },
      { fieldLabel: "Father Birth Place", fieldName: "FatherBirthPlace" },
      { fieldLabel: "Father Age", fieldName: "FatherResidenceAge" },
      { fieldLabel: "Father Death Day", fieldName: "FatherDeathDay" },
      { fieldLabel: "Father Death Month", fieldName: "FatherDeathMonth" },
      { fieldLabel: "Father Death Year", fieldName: "FatherDeathYear" },
      { fieldLabel: "Father Death Place", fieldName: "FatherDeathPlace" },
      { fieldLabel: "Deceased Father", fieldName: "FatherIsDeceased" },
      { fieldLabel: "Mother Prefix", fieldName: "MotherNamePrefix" },
      { fieldLabel: "Mother Given Name", fieldName: "MotherGivenName" },
      { fieldLabel: "Mother Surname", fieldName: "MotherSurname" },
      { fieldLabel: "Mother Suffix", fieldName: "MotherNameSuffix" },
      { fieldLabel: "Mother Birth Place", fieldName: "MotherBirthPlace" },
      { fieldLabel: "Mother Age", fieldName: "MotherResidenceAge" },
      { fieldLabel: "Mother Death Day", fieldName: "MotherDeathDay" },
      { fieldLabel: "Mother Death Month", fieldName: "MotherDeathMonth" },
      { fieldLabel: "Mother Death Year", fieldName: "MotherDeathYear" },
      { fieldLabel: "Mother Death Place", fieldName: "MotherDeathPlace" },
      { fieldLabel: "Deceased Mother", fieldName: "MotherIsDeceased" },
      { fieldLabel: "Spouse Prefix", fieldName: "SpouseNamePrefix" },
      { fieldLabel: "Spouse Given Name", fieldName: "SpouseGivenName" },
      { fieldLabel: "Spouse Surname", fieldName: "SpouseSurname" },
      { fieldLabel: "Spouse Suffix", fieldName: "SpouseNameSuffix" },
      { fieldLabel: "Spouse Death Age", fieldName: "SpouseDeathAge" },
      { fieldLabel: "Spouse Gender", fieldName: "SpouseGender" },
      { fieldLabel: "Spouse Birth Day", fieldName: "SpouseBirthDay" },
      { fieldLabel: "Spouse Birth Month", fieldName: "SpouseBirthMonth" },
      { fieldLabel: "Spouse Birth Year", fieldName: "SpouseBirthYear" },
      { fieldLabel: "Spouse Birth Place", fieldName: "SpouseBirthPlace" },
      { fieldLabel: "Spouse Death Day", fieldName: "SpouseDeathDay" },
      { fieldLabel: "Spouse Death Month", fieldName: "SpouseDeathMonth" },
      { fieldLabel: "Spouse Death Year", fieldName: "SpouseDeathYear" },
      { fieldLabel: "Spouse Death Place", fieldName: "SpouseDeathPlace" },
      { fieldLabel: "Deceased Spouse", fieldName: "SpouseIsDeceased" },
      { fieldLabel: "Header Language", fieldName: "HeaderLanguage" },
    ],
    Burial: [
      { fieldLabel: "Death Day", fieldName: "SelfDeathDay", defaultSelected: true },
      { fieldLabel: "Death Month", fieldName: "SelfDeathMonth" },
      { fieldLabel: "Death Year", fieldName: "SelfDeathYear" },
      { fieldLabel: "Republican Death Day", fieldName: "SelfDeathFrenchRepublicanDay" },
      { fieldLabel: "Republican Death Month", fieldName: "SelfDeathFrenchRepublicanMonth" },
      { fieldLabel: "Republican Death Year", fieldName: "SelfDeathFrenchRepublicanYear", defaultSelected: true },
      { fieldLabel: "Death Age", fieldName: "SelfDeathAge" },
      { fieldLabel: "Burial Day", fieldName: "SelfBurialDay" },
      { fieldLabel: "Burial Month", fieldName: "SelfBurialMonth" },
      { fieldLabel: "Burial Year", fieldName: "SelfBurialYear" },
      { fieldLabel: "Burial Age", fieldName: "SelfBurialAge" },
      { fieldLabel: "Father Prefix", fieldName: "FatherNamePrefix" },
      { fieldLabel: "Father Given Name", fieldName: "FatherGivenName" },
      { fieldLabel: "Father Surname", fieldName: "FatherSurname" },
      { fieldLabel: "Father Suffix", fieldName: "FatherNameSuffix" },
      { fieldLabel: "Father Birth Place", fieldName: "FatherBirthPlace" },
      { fieldLabel: "Father Age", fieldName: "FatherResidenceAge" },
      { fieldLabel: "Father Death Day", fieldName: "FatherDeathDay" },
      { fieldLabel: "Father Death Month", fieldName: "FatherDeathMonth" },
      { fieldLabel: "Father Death Year", fieldName: "FatherDeathYear" },
      { fieldLabel: "Father Death Place", fieldName: "FatherDeathPlace" },
      { fieldLabel: "Deceased Father", fieldName: "FatherIsDeceased" },
      { fieldLabel: "Mother Prefix", fieldName: "MotherNamePrefix" },
      { fieldLabel: "Mother Given Name", fieldName: "MotherGivenName" },
      { fieldLabel: "Mother Surname", fieldName: "MotherSurname" },
      { fieldLabel: "Mother Suffix", fieldName: "MotherNameSuffix" },
      { fieldLabel: "Mother Birth Place", fieldName: "MotherBirthPlace" },
      { fieldLabel: "Mother Age", fieldName: "MotherResidenceAge" },
      { fieldLabel: "Mother Death Day", fieldName: "MotherDeathDay" },
      { fieldLabel: "Mother Death Month", fieldName: "MotherDeathMonth" },
      { fieldLabel: "Mother Death Year", fieldName: "MotherDeathYear" },
      { fieldLabel: "Mother Death Place", fieldName: "MotherDeathPlace" },
      { fieldLabel: "Deceased Mother", fieldName: "MotherIsDeceased" },
      { fieldLabel: "Spouse Prefix", fieldName: "SpouseNamePrefix" },
      { fieldLabel: "Spouse Given Name", fieldName: "SpouseGivenName" },
      { fieldLabel: "Spouse Surname", fieldName: "SpouseSurname" },
      { fieldLabel: "Spouse Suffix", fieldName: "SpouseNameSuffix" },
      { fieldLabel: "Spouse Death Age", fieldName: "SpouseDeathAge" },
      { fieldLabel: "Spouse Gender", fieldName: "SpouseGender" },
      { fieldLabel: "Spouse Birth Day", fieldName: "SpouseBirthDay" },
      { fieldLabel: "Spouse Birth Month", fieldName: "SpouseBirthMonth" },
      { fieldLabel: "Spouse Birth Year", fieldName: "SpouseBirthYear" },
      { fieldLabel: "Spouse Birth Place", fieldName: "SpouseBirthPlace" },
      { fieldLabel: "Spouse Death Day", fieldName: "SpouseDeathDay" },
      { fieldLabel: "Spouse Death Month", fieldName: "SpouseDeathMonth" },
      { fieldLabel: "Spouse Death Year", fieldName: "SpouseDeathYear" },
      { fieldLabel: "Spouse Death Place", fieldName: "SpouseDeathPlace" },
      { fieldLabel: "Deceased Spouse", fieldName: "SpouseIsDeceased" },
      { fieldLabel: "Header Language", fieldName: "HeaderLanguage" },
    ],
    Coverpage: [
      { fieldLabel: "Département", fieldName: "SelfVitalState" },
      { fieldLabel: "Header Canton", fieldName: "SelfVitalTownship" },
      { fieldLabel: "Header Commune", fieldName: "SelfVitalCity1" },
      { fieldLabel: "Header Year", fieldName: "HeaderYear" },
      { fieldLabel: "Header Language", fieldName: "HeaderLanguage" },
      { fieldLabel: "Title Keyed", fieldName: "SourceTitle" },
    ],
    "Title Board": [
      { fieldLabel: "Département", fieldName: "SelfVitalState" },
      { fieldLabel: "Header Commune", fieldName: "SelfVitalCity1" },
      { fieldLabel: "Header Year", fieldName: "HeaderYear" },
      { fieldLabel: "Header Language", fieldName: "HeaderLanguage" },
      { fieldLabel: "Title Keyed", fieldName: "SourceTitle" },
      { fieldLabel: "Item Number", fieldName: "SourceItemNumber" },
    ],
  },
};


export function syncBdmGeneralFieldsFromEventTypes() {
  const bdmConfig = fieldsByKindConfig.BDM;
  if (!bdmConfig || !Array.isArray(bdmConfig.__GENERAL__)) return;

  const excludedDocTypes = new Set(["__GENERAL__", "__HEADER__", "Coverpage", "Title Board"]);
  const eventTypeEntries = Object.entries(bdmConfig).filter(
    ([docTypeName, fields]) => !excludedDocTypes.has(docTypeName) && Array.isArray(fields)
  );
  if (!eventTypeEntries.length) return;

  const docTypeFieldSets = eventTypeEntries.map(([, fields]) => {
    const names = fields
      .map((f) => String((f && f.fieldName) || "").trim())
      .filter(Boolean);
    return new Set(names);
  });

  const commonFieldNames = new Set();
  docTypeFieldSets[0].forEach((name) => {
    if (docTypeFieldSets.every((s) => s.has(name))) {
      commonFieldNames.add(name);
    }
  });

  const existingGeneral = Array.isArray(bdmConfig.__GENERAL__) ? bdmConfig.__GENERAL__ : [];
  const nextGeneral = [];
  const seen = new Set();
  const addField = (field) => {
    const name = String((field && field.fieldName) || "").trim();
    if (!name || seen.has(name) || !commonFieldNames.has(name)) return;
    nextGeneral.push(field);
    seen.add(name);
  };

  existingGeneral.forEach(addField);
  eventTypeEntries.forEach(([, fields]) => fields.forEach(addField));
  bdmConfig.__GENERAL__ = nextGeneral;
}
syncBdmGeneralFieldsFromEventTypes();
