import sys
import base64

path = "/home/guru/gururmm/dashboard/src/pages/Alerts.tsx"
with open(path, "r", encoding="utf-8") as f:
    content = f.read()

# Component encoded as base64 to avoid any quoting issues in this script
# Decoded content is the WatchdogAlertsSection TSX component
COMPONENT_B64 = (
    "Cgov"
    "LyBXYXRjaGRvZ0FsZXJ0c1NlY3Rpb24KCnR5cGUgV2RvZ1N0YXR1cyA9ICJhY3RpdmUiIHwg"
    "ImFja25vd2xlZGdlZCIgfCAicmVzb2x2ZWQiOwoKZnVuY3Rpb24gd2RvZ1N0YXR1cyhhbGVy"
    "dDogV2F0Y2hkb2dBbGVydCk6IFdkb2dTdGF0dXMgewogIGlmIChhbGVydC5yZXNvbHZlZF9h"
    "dCkgcmV0dXJuICJyZXNvbHZlZCI7CiAgaWYgKGFsZXJ0LmFja25vd2xlZGdlZF9hdCkgcmV0"
    "dXJuICJhY2tub3dsZWRnZWQiOwogIHJldHVybiAiYWN0aXZlIjsKfQoKZnVuY3Rpb24gV2F0"
    "Y2hkb2dBbGVydHNTZWN0aW9uKCkgewogIGNvbnN0IHF1ZXJ5Q2xpZW50ID0gdXNlUXVlcnlD"
    "bGllbnQoKTsKICBjb25zdCB7IHRvYXN0IH0gPSB1c2VUb2FzdCgpOwogIGNvbnN0IFtzaG93"
    "QWxsLCBzZXRTaG93QWxsXSA9IHVzZVN0YXRlKGZhbHNlKTsKICBjb25zdCBbZXhwYW5kZWRM"
    "b2dJZCwgc2V0RXhwYW5kZWRMb2dJZF0gPSB1c2VTdGF0ZTxzdHJpbmcgfCBudWxsPihudWxs"
    "KTsKCiAgY29uc3QgeyBkYXRhOiBhbGxBbGVydHMgPSBbXSwgaXNMb2FkaW5nIH0gPSB1c2VR"
    "dWVyeSh7CiAgICBxdWVyeUtleTogWyJ3YXRjaGRvZy1hbGVydHMiXSwKICAgIHF1ZXJ5Rm46"
    "ICgpID0+IHdhdGNoZG9nQWxlcnRzQXBpLmxpc3QoKS50aGVuKChyKSA9PiByLmRhdGEpLAog"
    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gICAgPGRpdiBjbGFzc05hbWU9ImZsZXggaXRlbXMtY2VudGVyIGp1c3Rp"
    "ZnktYmV0d2VlbiBnYXAtMyI+CiAgICAgICAgICA8Q2FyZFRpdGxlIGNsYXNzTmFtZT0iZmxl"
    "eCBpdGVtcy1jZW50ZXIgZ2FwLTIiPgogICAgICAgICAgICA8QWxlcnRUcmlhbmdsZSBjbGFz"
    "c05hbWU9Img0IHctNCB0ZXh0LWFtYmVyLTUwMCIgLz4KICAgICAgICAgICAgV2F0Y2hkb2cg"
    "QWxlcnRzCiAgICAgICAgICAgIHthY3RpdmVDb3VudCA+IDAgJiYgKAogICAgICAgICAgICAg"
    "IDxzcGFuIGNsYXNzTmFtZT0ibWwtMSByb3VuZGVkLWZ1bGwgYmctYW1iZXItNTAwLzE1IHB4"
    "LTIgcHktMC41IHRleHQteHMgZm9udC1tZWRpdW0gdGV4dC1hbWJlci02MDAgZGFyazp0ZXh0"
    "LWFtYmVyLTQwMCI+CiAgICAgICAgICAgICAgICB7YWN0aXZlQ291bnR9IGFjdGl2ZQogICAg"
    "ICAgICAgICAgIDwvc3Bhbj4KICAgICAgICAgICAgKX0KICAgICAgICAgIDwvQ2FyZFRpdGxlPgog"
    "ICAgICAgICAgPGJ1dHRvbgogICAgICAgICAgICBjbGFzc05hbWU9InRleHQteHMgdGV4dC1baHNs"
    "KHZhcigtLW11dGVkLWZvcmVncm91bmQpKV0gaG92ZXI6dGV4dC1baHNsKHZhcigtLWZvcmVn"
    "cm91bmQpKV0gdW5kZXJsaW5lLW9mZnNldC0yIGhvdmVyOnVuZGVybGluZSIKICAgICAgICAg"
    "ICAgb25DbGljaz17KCkgPT4gc2V0U2hvd0FsbCgodikgPT4gIXYpfQogICAgICAgICAgPgog"
    "ICAgICAgICAgICB7c2hvd0FsbCA/ICJBY3RpdmUgb25seSIgOiAiU2hvdyBhbGwifQogICAg"
    "ICAgICAgPC9idXR0b24+CiAgICAgICAgPC9kaXY+CiAgICAgIDwvQ2FyZEhlYWRlcj4KICAg"
    "ICAgPENhcmRDb250ZW50PgogICAgICAgIHtpc0xvYWRpbmcgJiYgKAogICAgICAgICAgPHAg"
    "Y2xhc3NOYW1lPSJweS02IHRleHQtY2VudGVyIHRleHQtc20gdGV4dC1baHNsKHZhcigtLW11"
    "dGVkLWZvcmVncm91bmQpKV0iPkxvYWRpbmcuLi48L3A+CiAgICAgICAgKX0KICAgICAgICB7"
    "IWlzTG9hZGluZyAmJiBhbGVydHMubGVuZ3RoID09PSAwICYmICgKICAgICAgICAgIDxwIGNs"
    "YXNzTmFtZT0icHktNiB0ZXh0LWNlbnRlciB0ZXh0LXNtIHRleHQtW2hzbCh2YXIoLS1tdXRl"
    "ZC1mb3JlZ3JvdW5kKSldIj4KICAgICAgICAgICAge3Nob3dBbGwgPyAiTm8gd2F0Y2hkb2cg"
    "YWxlcnRzIHJlY29yZGVkLiIgOiAiTm8gYWN0aXZlIHdhdGNoZG9nIGFsZXJ0cy4ifQogICAg"
    "ICAgICAgPC9wPgogICAgICAgICl9CiAgICAgICAgPGRpdiBjbGFzc05hbWU9InNwYWNlLXktMyI+"
    "CiAgICAgICAgICB7YWxlcnRzLm1hcCgoYWxlcnQpID0+IHsKICAgICAgICAgICAgY29uc3Qg"
    "c3RhdHVzID0gd2RvZ1N0YXR1cyhhbGVydCk7CiAgICAgICAgICAgIGNvbnN0IGxvZ0V4cGFu"
    "ZGVkID0gZXhwYW5kZWRMb2dJZCA9PT0gYWxlcnQuaWQ7CiAgICAgICAgICAgIGNvbnN0IHN0"
    "YXR1c0NvbG9yID0KICAgICAgICAgICAgICBzdGF0dXMgPT09ICJhY3RpdmUiCiAgICAgICAg"
    "ICAgICAgICA/ICJ0ZXh0LXJlZC02MDAgZGFyazp0ZXh0LXJlZC00MDAiCiAgICAgICAgICAg"
    "ICAgICAgIDogc3RhdHVzID09PSAiYWNrbm93bGVkZ2VkIgogICAgICAgICAgICAgICAgPyAi"
    "dGV4dC1hbWJlci02MDAgZGFyazp0ZXh0LWFtYmVyLTQwMCIKICAgICAgICAgICAgICAgIDog"
    "InRleHQtW2hzbCh2YXIoLS1tdXRlZC1mb3JlZ3JvdW5kKSldIjsKCiAgICAgICAgICAgIHJl"
    "dHVybiAoCiAgICAgICAgICAgICAgPGRpdgogICAgICAgICAgICAgICAga2V5PXthbGVydC5pZH0K"
    "ICAgICAgICAgICAgICAgIGNsYXNzTmFtZT0icm91bmRlZC1sZyBib3JkZXIgYm9yZGVyLVto"
    "c2wodmFyKC0tYm9yZGVyKSldIHA0IHNwYWNlLXktMiIKICAgICAgICAgICAgICA+CiAgICAg"
    "ICAgICAgICAgICA8ZGl2IGNsYXNzTmFtZT0iZmxleCBpdGVtcy1zdGFydCBqdXN0aWZ5LWJl"
    "dHdlZW4gZ2FwLTQiPgogICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzTmFtZT0ic3BhY2Ut"
    "eS0wLjUiPgogICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3NOYW1lPSJmbGV4IGl0ZW1z"
    "LWNlbnRlciBnYXAtMiI+CiAgICAgICAgICAgICAgICAgICAgICA8c3BhbiBjbGFzc05hbWU9"
    "e2B0ZXh0LXhzIGZvbnQtc2VtaWJvbGQgdXBwZXJjYXNlIHRyYWNraW5nLXdpZGVyICR7c3Rh"
    "dHVzQ29sb3J9YH0+CiAgICAgICAgICAgICAgICAgICAgICAgIHtzdGF0dXN9CiAgICAgICAg"
    "ICAgICAgICAgICAgICA8L3NwYW4+CiAgICAgICAgICAgICAgICAgICAgICA8c3BhbiBjbGFz"
    "c05hbWU9InRleHQteHMgdGV4dC1baHNsKHZhcigtLW11dGVkLWZvcmVncm91bmQpKV0iPgog"
    "ICAgICAgICAgICAgICAgICAgICAgICAgwrcge2FsZXJ0LnJlc3RhcnRfYXR0ZW1wdHN9IHJl"
    "c3RhcnQgYXR0ZW1wdAogICAgICAgICAgICAgICAgICAgICAgICB7YWxlcnQucmVzdGFydF9h"
    "dHRlbXB0cyAhPT0gMSA/ICJzIiA6ICIifQogICAgICAgICAgICAgICAgICAgICAgPC9zcGFu"
    "PgogICAgICAgICAgICAgICAgICAgIDwvZGl2PgogICAgICAgICAgICAgICAgICAgIDxwIGNs"
    "YXNzTmFtZT0idGV4dC14cyB0ZXh0LVtoc2wodmFyKC0tbXV0ZWQtZm9yZWdyb3VuZCkpXSI+"
    "CiAgICAgICAgICAgICAgICAgICAgICBBZ2VudCBJRDp7IiAifQogICAgICAgICAgICAgICAg"
    "ICAgICAgPHNwYW4gY2xhc3NOYW1lPSJmb250LW1vbm8iIHRpdGxlPXthbGVydC5hZ2VudF9p"
    "ZH0+CiAgICAgICAgICAgICAgICAgICAgICAgIHthbGVydC5hZ2VudF9pZC5zbGljZSgwLCA4"
    "KX0mIzgyMzA7CiAgICAgICAgICAgICAgICAgICAgICA8L3NwYW4+CiAgICAgICAgICAgICAg"
    "ICAgICAgICB7IiAifcK3eyIgIn0KICAgICAgICAgICAgICAgICAgICAgIFRyaWdnZXJlZDoge"
    "2Zvcm1hdFJlbGF0aXZlKGFsZXJ0LnRyaWdnZXJlZF9hdCl9CiAgICAgICAgICAgICAgICAg"
    "ICAgICB7YWxlcnQuYWNrbm93bGVkZ2VkX2F0ICYmICgKICAgICAgICAgICAgICAgICAgICAg"
    "ICAgPD57IiAifcK3eyIgIn1BY2s6IHtmb3JtYXRSZWxhdGl2ZShhbGVydC5hY2tub3dsZWRn"
    "ZWRfYXQpfTwvPgogICAgICAgICAgICAgICAgICAgICAgKX0KICAgICAgICAgICAgICAgICAg"
    "ICAgIHthbGVydC5yZXNvbHZlZF9hdCAmJiAoCiAgICAgICAgICAgICAgICAgICAgICAgIDw+"
    "eyIgIn3CtyB7IiAifVJlc29sdmVkOiB7Zm9ybWF0UmVsYXRpdmUoYWxlcnQucmVzb2x2ZWRf"
    "YXQpfTwvPgogICAgICAgICAgICAgICAgICAgICAgKX0KICAgICAgICAgICAgICAgICAgICA8"
    "L3A+CiAgICAgICAgICAgICAgICAgICAge2FsZXJ0Lmxhc3RfZXJyb3IgJiYgKAogICAgICAg"
    "ICAgICAgICAgICAgICAgPHAgY2xhc3NOYW1lPSJ0ZXh0LXNtIHRleHQtW2hzbCh2YXIoLS1m"
    "b3JlZ3JvdW5kKSldIj4KICAgICAgICAgICAgICAgICAgICAgICAgPHNwYW4gY2xhc3NOYW1l"
    "PSJmb250LW1lZGl1bSI+RXJyb3I6PC9zcGFuPiB7YWxlcnQubGFzdF9lcnJvcn0KICAgICAg"
    "ICAgICAgICAgICAgICAgIDwvcD4KICAgICAgICAgICAgICAgICAgICApfQogICAgICAgICAg"
    "ICAgICAgICA8L2Rpdj4KCiAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3NOYW1lPSJmbGV4"
    "IHNocmluay0wIGl0ZW1zLWNlbnRlciBnYXAtMS41Ij4KICAgICAgICAgICAgICAgICAgICB7"
    "c3RhdHVzID09PSAiYWN0aXZlIiAmJiAoCiAgICAgICAgICAgICAgICAgICAgICA8QnV0dG9u"
    "IHNpemU9InNtIiB2YXJpYW50PSJzZWNvbmRhcnkiIGRpc2FibGVkPXtpc011dGF0aW5nfQog"
    "ICAgICAgICAgICAgICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiBhY2tub3dsZWRnZU11dGF0"
    "aW9uLm11dGF0ZShhbGVydC5pZCl9PgogICAgICAgICAgICAgICAgICAgICAgICBBY2tub3ds"
    "ZWRnZQogICAgICAgICAgICAgICAgICAgICAgPC9CdXR0b24+CiAgICAgICAgICAgICAgICAg"
    "ICAgKX0KICAgICAgICAgICAgICAgICAgICB7c3RhdHVzICE9PSAicmVzb2x2ZWQiICYmICgK"
    "ICAgICAgICAgICAgICAgICAgICAgIDxCdXR0b24gc2l6ZT0ic20iIHZhcmlhbnQ9InNlY29u"
    "ZGFyeSIgZGlzYWJsZWQ9e2lzTXV0YXRpbmd9CiAgICAgICAgICAgICAgICAgICAgICAgIG9u"
    "Q2xpY2s9eygpID0+IHJlc29sdmVNdXRhdGlvbi5tdXRhdGUoYWxlcnQuaWQpfT4KICAgICAg"
    "ICAgICAgICAgICAgICAgICAgUmVzb2x2ZQogICAgICAgICAgICAgICAgICAgICAgPC9CdXR0"
    "b24+CiAgICAgICAgICAgICAgICAgICAgKX0KICAgICAgICAgICAgICAgICAgICA8QnV0dG9u"
    "IHNpemU9InNtIiB2YXJpYW50PSJnaG9zdCIgZGlzYWJsZWQ9e2lzTXV0YXRpbmd9CiAgICAg"
    "ICAgICAgICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiBkZWxldGVNdXRhdGlvbi5tdXRhdGUo"
    "YWxlcnQuaWQpfT4KICAgICAgICAgICAgICAgICAgICAgIERlbGV0ZQogICAgICAgICAgICAg"
    "ICAgICAgIDwvQnV0dG9uPgogICAgICAgICAgICAgICAgICA8L2Rpdj4KICAgICAgICAgICAg"
    "ICAgIDwvZGl2PgoKICAgICAgICAgICAgICAgIHthbGVydC5sb2dfdGFpbCAmJiAoCiAgICAg"
    "ICAgICAgICAgICAgIDxkaXY+CiAgICAgICAgICAgICAgICAgICAgPGJ1dHRvbgogICAgICAg"
    "ICAgICAgICAgICAgICAgY2xhc3NOYW1lPSJmbGV4IGl0ZW1zLWNlbnRlciBnYXAtMSB0ZXh0"
    "LXhzIHRleHQtW2hzbCh2YXIoLS1tdXRlZC1mb3JlZ3JvdW5kKSldIGhvdmVyOnRleHQtW2hz"
    "bCh2YXIoLS1mb3JlZ3JvdW5kKSldIgogICAgICAgICAgICAgICAgICAgICAgb25DbGljaz17"
    "KCkgPT4gc2V0RXhwYW5kZWRMb2dJZChsb2dFeHBhbmRlZCA/IG51bGwgOiBhbGVydC5pZCl9"
    "CiAgICAgICAgICAgICAgICAgICAgPgogICAgICAgICAgICAgICAgICAgICAge2xvZ0V4cGFuZGVk"
    "ID8gPENoZXZyb25Eb3duIGNsYXNzTmFtZT0iaDMgdzMiIC8+IDogPENoZXZyb25SaWdodCBj"
    "bGFzc05hbWU9ImgzIHczIiAvPn0KICAgICAgICAgICAgICAgICAgICAgIEFnZW50IGxvZyB0"
    "YWlsCiAgICAgICAgICAgICAgICAgICAgPC9idXR0b24+CiAgICAgICAgICAgICAgICAgICAg"
    "e2xvZ0V4cGFuZGVkICYmICgKICAgICAgICAgICAgICAgICAgICAgIDxwcmUgY2xhc3NOYW1l"
    "PSJtdC0xIG1heC1oLTQ4IG92ZXJmbG93LWF1dG8gcm91bmRlZCBiZy1baHNsKHZhcigtLW11"
    "dGVkKSldLzUwIHAtMiB0ZXh0LXhzIGZvbnQtbW9ubyB0ZXh0LVtoc2wodmFyKC0tZm9yZWdy"
    "b3VuZCkpXSI+CiAgICAgICAgICAgICAgICAgICAgICAgIHthbGVydC5sb2dfdGFpbH0KICAg"
    "ICAgICAgICAgICAgICAgICAgIDwvcHJlPgogICAgICAgICAgICAgICAgICAgICl9CiAgICAg"
    "ICAgICAgICAgICAgIDwvZGl2PgogICAgICAgICAgICAgICAgKX0KICAgICAgICAgICAgICA8"
    "L2Rpdj4KICAgICAgICAgICAgKTsKICAgICAgICAgIH0pfQogICAgICAgIDwvZGl2PgogICAg"
    "ICA8L0NhcmRDb250ZW50PgogICAgPC9DYXJkPgogICk7Cn0K"
)

component = base64.b64decode(COMPONENT_B64).decode("utf-8")
print(f"Component decoded: {len(component)} chars")

insert_before = "export function Alerts() {"
if insert_before in content:
    content = content.replace(insert_before, component + insert_before, 1)
    print("OK: WatchdogAlertsSection inserted")
else:
    print("ERROR: insert anchor not found")
    sys.exit(1)

old_end = "    </div>\n  );\n}\n\n// Re-export types"
new_end = "      <WatchdogAlertsSection />\n    </div>\n  );\n}\n\n// Re-export types"
if old_end in content:
    content = content.replace(old_end, new_end, 1)
    print("OK: WatchdogAlertsSection rendered in Alerts()")
else:
    print("ERROR: closing div anchor not found")
    idx = content.find("// Re-export types")
    if idx >= 0:
        print("Context:", repr(content[max(0, idx-200):idx+30]))

with open(path, "w", encoding="utf-8") as f:
    f.write(content)
print(f"Done. Lines: {len(content.splitlines())}")
