import re

with open('_get_instance_details.php', 'r', encoding='utf-8') as f:
    content = f.read()

content = content.replace('name="<?= htmlspecialchars($fieldName) ?>" name="<?= htmlspecialchars($fieldName) ?>"', 'name="<?= htmlspecialchars($fieldName) ?>"')

# Also fix the trailing slash from my earlier mistake `<input ... />` just to make it clean `>`
content = content.replace('<?= (!empty($currentValue) || (!isset($instanceData[$fieldName]) && !empty($field["default"])) ? "checked" : "" ?>/>', '<?= (!empty($currentValue) || (!isset($instanceData[$fieldName]) && !empty($field["default"])) ? "checked" : "" ?>>')

with open('_get_instance_details.php', 'w', encoding='utf-8') as f:
    f.write(content)
print("Cleaned up duplicates.")
