"""InFinBot storage defaults with explicit compatibility for pre-rename files.

No files are renamed, copied, created or opened by this module. Existing legacy
files remain the automatic default even if both names exist. Callers may supply
an explicit path to choose a different ledger; explicit paths are not remapped.
"""
from pathlib import Path

LEGACY_DB_PREFIX = "qzotic_"
LEGACY_NOTIFICATION_KIND = "QZOTIC_GATEKEEPER_NOTIFICATION_STATE"
NOTIFICATION_KIND = "INFINBOT_GATEKEEPER_NOTIFICATION_STATE"


def default_db_path(preferred):
    path = Path(preferred)
    if not path.name.startswith("foresixa_"):
        return path
    legacy = path.with_name(LEGACY_DB_PREFIX + path.name[len("foresixa_"):])
    return legacy if legacy.exists() else path


def is_protected_simulation_ledger(path):
    return Path(path).name in {"foresixa_pure_sandbox.db", LEGACY_DB_PREFIX + "pure_sandbox.db"}


def notification_kind_supported(kind):
    return kind in {NOTIFICATION_KIND, LEGACY_NOTIFICATION_KIND, "FORESIXA_GATEKEEPER_NOTIFICATION_STATE"}
