"""Maps internal entity names to in-game display names."""

# Auto-generated from loadout.asr_en localization file
# and manual mappings for entities not in the localization file.

DISPLAY_NAMES: dict[str, str] = {
    # Shared ammo types (Ammo Types browser)
    'SoftPoint': 'Soft Point',
    'Match': 'Match',
    'ArmourPiercing': 'Armour Piercing',
    'Normal': 'Normal',
    'SubSonic': 'Subsonic',
    'NonLethal': 'Non-Lethal',
    'Slug': 'Slug',
    '24Buckshot': '24 Buckshot',
    '36Buckshot': '36 Buckshot',
    'Proof Rounds': 'Proof Rounds',
    'Ammo': 'Ammo (generic)',
    '1903_Trench': '1903 Trench Magazine',
    'A1_Optical': 'A1 Optical Scope',
    'A2_Optical': 'A2 Optical Scope',
    'A5_Winchester_Scope': 'A5 Win & Co Scope',
    'Adapted_Higins_Full_Choke': 'Higins Range Full Choke',
    'Adapted_Higins_Full_Choke_Drilling': 'Higins Range Full Choke',
    'Adapted_Higins_Full_Choke_Sjogren': 'Higins Range Full Choke',
    'Austen_Foregrip': 'Austen Control Foregrip',
    'Auto_Burglar': 'Auto Burglar',
    'Auto_Burglar_DefaultIronsight': 'Auto Burglar',
    'Auto_Burglar_DefaultMagazine': 'Auto Burglar',
    'Axis_mk2_MuzzleBrake': 'MK2 Recoil Brake',
    'B4_Scope': 'B4 Win & Co Scope',
    'Blued_Lightened_Barrel': 'Lightened and Blued Barrel Liner',
    'Bramit_Suppressor': 'Bramit Suppressor',
    'Colt_M1911_DefaultIronsight': 'M1911 Iron Sights',
    'Colt_M1911_DefaultMagazine': 'M1911 Standard Magazine',
    'Colt_Stealth_DefaultMagazine': 'M1911 Stealth Magazine',
    'Cuts_Full_Choke': 'Cuts Full Accuracy Choke',
    'Cuts_Full_Choke_Drilling': 'Cuts Full Accuracy Choke',
    'Cuts_Full_Choke_Sjogren': 'Cuts Full Accuracy Choke',
    'Cuts_Modified_Choke': 'Cuts Modified Choke',
    'Cuts_Modified_Choke_Drilling': 'Cuts Modified Choke',
    'DLC_Mosin': 'Mosin-Nagant M91/30 (DLC)',
    'Default_Barrel': 'Default Barrel',
    'Delisle': 'D.L. Carbine',
    'Delisle_DefaultBarrel': 'D.L. Carbine',
    'Delisle_DefaultIronsight': 'D.L. Carbine',
    'Delisle_DefaultMagazine': 'D.L. Carbine',
    'Delisle_LongBarrel': 'D.L. Carbine',
    'Delisle_ShortBarrel': 'D.L. Carbine',
    'Derringer': 'Double 1866',
    'Derringer_DefaultIronsight': 'Double 1866',
    'Drilling_DefaultIronsight': 'Drilling Iron Sights',
    'Drilling_DefaultMagazine': 'Drilling Standard Magazine',
    'EMP_DefaultIronsight': 'ERMA.36 Iron Sights',
    'EMP_Default_Barrel': 'ERMA.36 Standard Suppressed Barrel',
    'EMP_Foregrip': 'Modified ERMA.36 Foregrip',
    'EMP_LongBarrel': 'ERMA.36 Extended Suppressed Barrel',
    'EMP_UnSuppressedBarrel': 'ERMA.36 Muzzle Brake Barrel',
    'Extended_Artillery_Barrel': 'Extended Artillery Barrel',
    'Extended_Carbine_Barrel': 'Extended Carbine Barrel',
    'Featherweight_Stock': 'Featherweight Frame Stock',
    'G43': 'Gewehr 43',
    'G43_DefaultBarrel': 'Gewehr 1943',
    'G43_DefaultIronsight': 'Gewehr 1943',
    'G43_DefaultMagazine': 'Gewehr 1943',
    'G43_Kurz_Silenced': 'Gewehr 1943 Kurz Silenced',
    'G43_LongBarrel': 'Extended Marksmen Barrel',
    'GEW_98_Overpressure': 'Gew98 Overpressure Magazine',
    'Small_Overpressure': 'Small Overpressure Magazine',
    'Small_Overpressure_M712': 'M712 Small Overpressure Magazine',
    'PPlus_Overpressure': 'P+ Overpressure Magazine',
    'Kurz_Conversion': 'Kurz Conversion',
    'Mg13_trench': 'MG13 Trench Magazine',
    'Magazine_pouch': 'Magazine Pouch',
    'Geret_06_Experimental_P_Plus': 'Geret 06 Overpressure Magazine',
    'GreaseGun': 'M3 Grease Gun',
    'GreaseGun_DefaultIronsight': 'M3 Grease Gun',
    'GreaseGun_DefaultMagazine': 'M3 Grease Gun',
    'GreaseGun_DefaultStock': 'M3 Grease Gun',
    'GreaseGun_FlashHiderBarrel': 'M3 Grease Gun',
    'GreaseGun_LongBarrel': 'M3 Grease Gun',
    'Gustaf': 'Carl Gustav M/1945',
    'Gustaf_DefaultBarrel': 'Carl Gustav M/1945',
    'Gustaf_DefaultMagazine': 'Carl Gustav M/1945',
    'Gustaf_DefaultStock': 'Carl Gustav M/1945',
    'Gustaf_SuppressedBarrel': 'Carl Gustav M/1945',
    'Gustaf_UnshroudedBarrel': 'Carl Gustav M/1945',
    'Gustav_DefaultIronsight': 'Carl Gustav Iron Sights',
    'HDM_DefaultIronsight': 'High Standard .22 (HS.22)',
    'Heat_Sink_Barrel': 'Hi-Rate Heat Sink Barrel',
    # In-game short name is "Overpressure Power" (loc hash via entity tags).
    # Must NOT share the Parkerized label — that caused duplicate barrel entries.
    'Heavy_Barrel_Bands': 'Overpressure Power',
    'Reinforced_Barrel': 'Overpressure Power',
    'Parkerized_Heavy_Barrel': 'Heavy Parkerized',
    'Blued_Lightened_Barrel': 'Lightened and Blued',
    'Lightened_Barrel': 'Lightened and Stripped',
    'Lightened_Blued_Shotgun_Barrel': 'Lightened and Blued',
    'Heavy_Mp44_Stock': 'Walnut Stability Stock',
    'Heavy_Wooden_Stock': 'Heavy Walnut Construction',
    'Hub_23_Suppressor': 'Hub 23 Suppressor',
    'Improved_Cylinder_Choke': 'Improved Cylinder Choke',
    'Improved_Cylinder_Choke_Sjogren': 'Improved Cylinder Choke',
    'Kar98K': 'Karabiner 98',
    'Kar98K_DefaultBarrel': 'Karabiner 98',
    'Kar98K_LongBarrel': 'Karabiner 98',
    'Kar98k_DefaultIronsight': 'Karabiner 98 Iron Sights',
    'Kar98k_DefaultMagazine': 'Karabiner 98 Standard Magazine',
    'Lee_Enfield': 'Lee No.4',
    'Lightened_Elm_Construction': 'Light Elm Construction',
    'Lightened_Firing_Mechanism': 'Lightened Receiver Mechanism',
    'Lightweight_712s': 'Lightweight 712S Stock',
    'Lightweight_Frame_Stock': 'Tactical Frame Stock',
    'Luger': 'Pistole 08',
    'Luger_DefaultIronsight': 'Pistole 08',
    'Luger_DefaultMagazine': 'Pistole 08',
    'Luger_Suppressed': 'Pistole 08 Suppressed',
    'M12_DefaultIronsight': 'Model 1912 Iron Sights',
    'M1903': 'M.1903',
    'M1903_DefaultBarrel': 'M.1903',
    'M1903_ShortBarrel': 'M.1903',
    'M1911': 'M1911',
    'M1911_Plus': 'M1911 (Extended)',
    'M1913_Scope': 'W&S M1913 Scope',
    'M1Carbine': 'M1a Carbine',
    'M1Carbine_DefaultBarrel': 'M1a Carbine',
    'M1Carbine_DefaultIronsight': 'M1a Carbine',
    'M1Carbine_LongBarrel': 'M1a Carbine',
    'M1_Carbine_DefaultMagazine': 'M1a Carbine Standard Magazine',
    'M1_Enfield': 'M1 Enfield',
    'M12': 'Model 1912',
    'M712': 'Mod.712',
    'EMP': 'ERMA.36',
    'HDM': 'High Standard .22 (HS.22)',
    'P38': 'Walther P38',
    'M81_Scope': 'M81 Scope',
    'M84_Scope': 'M84 Telescopic Scope',
    'MG42': 'MG42',
    'MG42_DefaultMagazine': 'MG42',
    'MP.40': 'Machine Pist.40',
    'MP.44': 'Machine Pist.44',
    'MP40_DefaultIronsight': 'Machine Pist.40 Iron Sights',
    'MP40_DefaultMagazine': 'Machine Pist.40 Standard Magazine',
    'MP44_DefaultIronsight': 'Machine Pist.44 Iron Sights',
    'MP44_DefaultMagazine': 'Machine Pist.44 Standard Magazine',
    'Mauser_M712_DefaultIronsight': 'Mod.712 Iron Sights',
    'Mauser_M712_DefaultMagazine': 'Mod.712 Standard Magazine',
    'Maxin_1910_Suppressor': 'Maxin 1910 Suppressor',
    'Maxin_30_Suppressor': 'Maxin 30 Suppressor',
    'Mclean_Muzzlebrake': 'Mcleen Control Muzzle Brake',
    'Mk1_Boys_MuzzleBreak': 'Mk1 Boys Brake',
    'Mk1_Welrod': 'Mk1 Welrod Conversion',
    'Mk2_Boys_MuzzleBreak': 'Mk2 Boys Brake',
    'Mk2_Welrod': 'Mk2 Welrod',
    'ModelD': 'Model D',
    'ModelD_DefaultIronsight': 'Model D',
    'ModelD_DefaultMagazine': 'Model D',
    'Moore_Suppressor': 'Moore-1 Suppressor',
    'Mosin_DefaultMagazine': 'Mosin-Nagant Standard Magazine',
    'Mosin_Nagant': 'Mosin-Nagant M91/30',
    'Mosin_Nagant_DefaultBarrel': 'Mosin-Nagant M91/30',
    'Mosin_Nagant_DefaultMagazine': 'Mosin-Nagant M91/30',
    'Mosin_Nagant_LongBarrel': 'Mosin-Nagant M91/30',
    'Nambu': 'Type 14 Nambu',
    'Nambu_DefaultIronsight': 'Type 14 Nambu',
    'Nambu_DefaultMagazine': 'Type 14 Nambu',
    'No32_Mk1_Scope': 'No.32 Mk1 Scope',
    'No32_Mk2_Scope': 'No.32 Mk2 Scope',
    'OSS_Rifled_Barrel': 'OSS Rifled Barrel',
    'OSS_Suppressor': 'OSS III Suppressor',
    'Owen_Foregrip': 'Tactical Owen Foregrip',
    'PPSH': 'PPSh',
    'PPSH_DefaultIronsight': 'PPSh',
    'PPSh_DefaultMagazine': 'PPSh Standard Magazine',
    'PU_scope': 'PU Scope',
    'Panzerfaust': 'Panzerfaust',
    'Pzb39Ammo': 'PzB 39 Anti-Tank Rounds',
    'MG42(HalfAmmo)': 'MG42 (Half Ammo)',

    'Pedersen': 'Pedersen Rifle',
    'Pedersen_LongBarrel': 'Pedersen Rifle',
    'Pedersen_ShortBarrel': 'Pedersen Rifle',
    'Pederson_DefaultBarrel': 'Pedersen Standard Barrel',
    'Pederson_DefaultMagazine': 'Pedersen Standard Magazine',
    'Power_Hyrbid_Choke': 'Power Hybrid Choke',
    'Precision_Rifled_Barrel': 'Precision Rifled Barrel',
    'Pzb39': 'PzB 39 Anti Tank',
    'Quad_M31_Magazine': 'Quad M31 Magazine',
    'Quad_M31_Magazine_Carl_Gustaf': 'Quad M31 Magazine (Gustav)',
    'Quad_M31_Magazine_Sten': 'Quad M31 Magazine (Sten)',
    'Quad_M31_Magazine_Sten_EMP': 'Quad M31 Magazine (ERMA.36)',
    'RSC1918': 'RSC 1918',
    'RSC1918_DefaultBarrel': 'RSC 1918',
    'RSC1918_DefaultIronsight': 'RSC 1918',
    'RSC1918_DefaultMagazine': 'RSC 1918',
    'RSC1918_LongBarrel': 'RSC 1918',
    'RSC1918_ShortBarrel': 'RSC 1918',
    'Reinforced Foregrip Bands': 'Reinforced Foregrip Band',
    'Reinforced_Barrel': 'Overpressure Power Barrel',
    'Remove_Foregrip': 'Remove Foregrip',
    'Rifle_Bayonet_1': 'Rifle Bayonet',
    'Rifled_Barrel_and_Sight': 'Rifled & Improved Iron Sight Barrel',
    'SMG_Lightened_Bolt': 'Lightened Bolt and Receiver',
    'SREM': 'SREM-1',
    'SREM_DefaultBarrel': 'SREM-1',
    'SREM_DefaultIronsight': 'SREM-1',
    'SREM_DefaultMagazine': 'SREM-1',
    'SREM_LongBarrel': 'SREM-1',
    'SREM_ShortBarrel': 'SREM-1',
    'Sjogren': 'Sjögren Inertia',
    'Sjogren_DefaultIronsight': 'Sjögren Iron Sights',
    'Sjogren_DefaultMagazine': 'Sjögren Standard Magazine',
    # Shotgun stock / receiver (match in-game customization labels)
    'Heavy_Steel_Buttplate': 'Heavy Buttplate',
    'Rubber_Buttplate': 'Rubber Buttplate',
    'Leather_cheek_pad': 'Leather Pad',
    'Wooden_Cheek_Pad': 'Wooden Pad',
    'Shotgun_Shell_Loops': 'Shell Loops',
    'Bullet_Loops': 'Shell Loops',
    'Heavy_Steel_Assembly': 'Heavy Steel Assembly',
    'Lightened_Firing_Mechanism': 'Lightened Assembly',
    'Quick_Load_Mod': 'Quick Load Mod',
    'Quick_Load_Mod_Sjogren': 'Quick Load Mod',
    'Quick_Load_Mod_M12': 'Quick Load Mod',
    'Shotgun_12G_Compensator': '12G Compensator',
    'Shotgun_12G_Compensator_Sjogren': '12G Compensator',
    'Cuts_Modified_Choke': 'Cuts Choke',
    'Cuts_Modified_Choke_Sjogren': 'Cuts Choke',
    'Cuts_Modified_Choke_Drilling': 'Cuts Choke',
    'Cuts_Full_Choke': 'Cuts Full Choke',
    'Cuts_Full_Choke_Sjogren': 'Cuts Full Choke',
    'Cuts_Full_Choke_Drilling': 'Cuts Full Choke',
    'Adapted_Higins_Full_Choke': 'Higins Range Choke',
    'Adapted_Higins_Full_Choke_Sjogren': 'Higins Range Choke',
    'Adapted_Higins_Full_Choke_Drilling': 'Higins Range Choke',
    'Improved_Cylinder_Choke': 'Improved Cylinder',
    'Improved_Cylinder_Choke_Sjogren': 'Improved Cylinder',
    'Lightened_Blued_Shotgun_Barrel': 'Lightened and Blued Barrel',
    'Smoothbore_Barrel': 'Polished Smoothbore Barrel',
    'Smoothbore_Barrel': 'Polished Smoothbore Barrel',
    'Snail_Magazine': 'Extended Snail Magazine',
    'Springfield_DefaultMagazine': 'M.1903 Standard Magazine',
    'Standard_Sten_Stock': 'Simple Shoulder Stock',
    'Starguage_Barrel': 'Specialised Stargauge Sniper Barrel',
    'StenMKII_DefaultIronsight': 'Sten Mk2 Iron Sights',
    'StenMkII': 'Sten Mk2',
    'StenMkII_DefaultMagazine': 'Sten Mk2 Standard Magazine',
    'StenMkV_DefaultIronsight': 'Sten Mk5 Iron Sights',
    'StenMkV_DefaultMagazine': 'Sten Mk5 Standard Magazine',
    'Sten_Mk5_Grip': 'MK5 Recoil Aid Foregrip',
    'Stock_Removal': 'Stock Removal',
    'SuperTommy': 'Super Thompson',
    'T97_Scope': 'Arisaka T-97 Scope',
    'T99_Scope': 'Arisaka T-99 Scope',
    'Thompson': 'M1A1 Gov.',
    'Thompson_DefaultIronsight': 'M1A1 Gov. Iron Sights',
    'Thompson_DefaultMagazine': 'M1A1 Gov. Standard Magazine',
    'Thompson_Plus': 'M1A1 Gov. (Extended)',
    'Type1': 'Type TERA 1',
    'Type100': 'Type 100',
    'Type100_DefaultIronsight': 'Type 100 Iron Sights',
    'Type100_DefaultMagazine': 'Type 100 Standard Magazine',
    'Type1_DefaultIronsight': 'Type TERA 1 Iron Sights',
    'Type1_LongBarrel': 'Type TERA 1 Long Barrel',
    'Type1_ShortBarrel': 'Type TERA 1 Short Barrel',
    'Model2_Night_Vision_Scope': 'Model 2 Night Vision Scope',
    'PK_Berlin_Scope': 'PK Berlin Scope',
    'PPCo_Scope': 'PPCo Scope',
    'Zf39_Scope': 'ZF39 Scope',
    'Type99_LMG_Scope': 'Type 99 LMG Scope',
    'PU_scope_Mosin': 'PU Scope (Mosin)',
    'Sten_Mk2_Special_Silencer': 'Sten Mk2 Special Silencer',
    'Cuts_Modified_Choke_Sjogren': 'Cuts Modified Choke',
    'Ridged_Pistol_Handgrip': 'Ridged Pistol Handgrip',
    'Ridged_SMG_Handgrip': 'Ridged SMG Handgrip',
    'Tactical_Pistol_Handgrip': 'Tactical Pistol Handgrip',
    'Tactical_SMG_Handgrip': 'Tactical SMG Handgrip',
    'Tanned_draw_grip': 'Tanned Draw Grip',
    'Reduced_load_magazine': 'Reduced Load Magazine',
    'FG_Compensator': 'FG Compensator',
    'Halcon_Compensator': 'Halcon Compensator',
    'Shotgun_12G_Compensator': '12G Compensator',
    'Shotgun_12G_Compensator_Sjogren': '12G Compensator',
    'Modified_12G_Compensator': 'Modified 12G Compensator',
    'SS_Flash_Hider': 'SS Flash Hider',
    'Heavy_Walnut_Construction': 'Heavy Walnut Construction',
    'Heavy_Oak': 'Heavy Oak Construction',
    'Heavy_Steel_Assembly': 'Heavy Steel Assembly',
    'Laminated_Beech_Construction': 'Laminated Beech Construction',
    'Fixed_Frame': 'Fixed Frame',
    'Large_9mm_Stick': 'Large 9mm Stick Magazine',
    'Large_Extended_Single_Stack': 'Large Extended Single Stack',
    'Medium_Extended_Single_Stack': 'Medium Extended Single Stack',
    'Small_Stick': 'Small Stick Magazine',
    'PPlus_Stick': 'P+ Stick Magazine',
    '30rd_Thompson_Stick': '30rd Thompson Stick',
    '25Rd_Marksmen_Mp44_Mag': '25rd Marksmen MP44 Magazine',
    'PPSH_50d_Drum': 'PPSh 50rd Drum',
    '100rd_Drum': '100rd Drum',
    '11rd_Delisle': '11rd D.L. Magazine',
    '20rd_delisle': '20rd D.L. Magazine',
    'M1_10rd': 'M1 10rd Magazine',
    'Quick_Load_Mod': 'Quick Load Mod',
    'Quick_Load_Mod_M12': 'Quick Load Mod',
    'Quick_Load_Mod_Sjogren': 'Quick Load Mod',
    'USGI_MuzzleBreak': 'USGI Muzzle Brake',
    'US_1911_Foregrip': 'OSS 1911 Recoil Foregrip',
    'Webley': 'Mk VI Revolver',
    'Webley_DefaultIronsight': 'Mk VI Revolver',
    'Webley_DefaultMagazine': 'Mk VI Revolver',
    'Welgun': 'Welgun SMG',
    'Welgun_DefaultMagazine': 'Welgun SMG Standard Magazine',
    'Welrod': 'Welrod',
    'Welrod_DefaultIronsight': 'Welrod',
    'Welrod_DefaultMagazine': 'Welrod',
    'Welrod_Variant_DefaultMagazine': 'Welrod Variant Magazine',
    'Winchester_1885': 'Win & Co 1885',
    'Winchester_1885_DefaultBarrel': 'Win & Co 1885',
    'Winchester_1885_DefaultMagazine': 'Win & Co 1885',
    'Winchester_1885_Ironsight': 'Win & Co 1885 Iron Sights',
    'X3_Grip_Tape': 'Aim Grip Tape X3',
    'X6_Grip_Tape': 'Aim Grip Tape X6',
    'ZF41_Scope': 'ZF41 CQB Scope',
    'Zf4_scope': 'ZF4 Advanced',
    'kar98K_CarbineBarrel': 'Karabiner 98 Kriegsmodell Carbine Barrel',
    'm12_DefaultMagazine': 'Model 1912 Standard Magazine',
    'welgun_DefaultIronsight': 'Welgun SMG Iron Sights',
}


# Runtime overrides from loadout HTXT + entity loc hashes (set on game open)
_GAME_LOC_NAMES: dict[str, str] = {}


def set_game_loc_names(names: dict[str, str]) -> None:
    """Install in-game short names decoded from loadout.asr_en (entity loc hashes)."""
    global _GAME_LOC_NAMES
    _GAME_LOC_NAMES = dict(names)


def get_display_name(entity_name: str) -> str:
    """Return the in-game display name for an entity, or the raw name if unknown.

    Prefer names decoded from the game's loadout HTXT (via attachment loc
    hashes) over the static table — that is what the customization UI shows.
    """
    if entity_name in _GAME_LOC_NAMES:
        return _GAME_LOC_NAMES[entity_name]
    # Default slot placeholders match in-game "Standard" / "Iron Sights"
    low = entity_name.lower()
    if low.endswith("defaultironsight") or low.endswith("_defaultironsight"):
        return "Iron Sights"
    if low.endswith("defaultbarrel") or low.endswith("_defaultbarrel"):
        return "Standard"
    if low.endswith("defaultmagazine") or low.endswith("_defaultmagazine"):
        return "Standard Issue"
    return DISPLAY_NAMES.get(entity_name, entity_name)


def format_entity_label(entity_name: str) -> str:
    """Return the in-game display name for an entity, or the raw name if unknown."""
    return get_display_name(entity_name)
