import { ROUTES } from "./routes";

export type RouteAccess =
  | "public"
  | "guestEntry"
  | "session"
  | "realUser"
  | "authOnly";

const STATIC_ROUTE_ACCESS: Partial<Record<string, RouteAccess>> = {
  [ROUTES.root]: "public",
  [ROUTES.splash]: "authOnly",
  [ROUTES.auth]: "authOnly",
  [ROUTES.chat]: "guestEntry",
  [ROUTES.privateRoom]: "guestEntry",
  [ROUTES.tip]: "public",
  [ROUTES.externalEntry]: "public",
  [ROUTES.sidebar]: "session",
  [ROUTES.subscription]: "realUser",
  [ROUTES.coinsRules]: "public",
};

export function getRouteAccess(pathname: string): RouteAccess {
  return STATIC_ROUTE_ACCESS[pathname] ?? "public";
}

export function isInternalRoute(value: string | null | undefined): boolean {
  return Boolean(value && value.startsWith("/") && !value.startsWith("//"));
}
