"""中控 iframe 内软导航:服务端跳过重型同步,避免切 tab 等待数秒."""

from __future__ import annotations

from flask import Request


def request_is_hub_soft_nav(req: Request | None = None) -> bool:
    """embed=1 且带 X-Instance-Soft-Nav 头:实例页内 fetch 换页,非整页刷新."""
    try:
        from flask import request as flask_request

        r = req or flask_request
        if str(r.args.get("embed") or "").strip() != "1":
            return False
        flag = (r.headers.get("X-Instance-Soft-Nav") or "").strip().lower()
        return flag in ("1", "true", "yes")
    except Exception:
        return False
