/** 常见局域网段，供手机/其他设备通过 IP 访问 dev 时 HMR WebSocket 放行 */
const DEFAULT_LAN_DEV_ORIGINS = ["192.168.*.*", "10.*.*.*"];

/** 解析 `ALLOWED_DEV_ORIGINS`（逗号分隔），供 next.config `allowedDevOrigins` 使用 */
export function parseAllowedDevOrigins(envValue: string | undefined): string[] {
  const fromEnv =
    envValue === undefined || envValue.trim() === ""
      ? []
      : envValue
          .split(",")
          .map((origin) => origin.trim())
          .filter((origin) => origin !== "");

  return [...DEFAULT_LAN_DEV_ORIGINS, ...fromEnv];
}
