export type RiftPageProfileId =
  | "home"
  | "program"
  | "speakers"
  | "partners"
  | "pitch"
  | "exhibit"
  | "sponsor"
  | "contact"
  | "payment"
  | "payment-success"
  | "privacy";

export type ChannelBias = "center" | "left" | "right";
export type ContourDensity = "low" | "medium" | "high";
export type AccentMode = "green" | "gold" | "mixed";

export type RiftPageProfile = {
  id: RiftPageProfileId;
  ambientOpacity: number;
  contourDensity: ContourDensity;
  channelBias: ChannelBias;
  accentMode: AccentMode;
  enablePulse: boolean;
  enableIntro: boolean;
  /** CSS class modifier on ambient layer */
  profileClass: string;
};

const PROFILES: Record<RiftPageProfileId, RiftPageProfile> = {
  home: {
    id: "home",
    ambientOpacity: 0.55,
    contourDensity: "high",
    channelBias: "center",
    accentMode: "mixed",
    enablePulse: true,
    enableIntro: true,
    profileClass: "rift-profile-home",
  },
  program: {
    id: "program",
    ambientOpacity: 0.7,
    contourDensity: "medium",
    channelBias: "center",
    accentMode: "green",
    enablePulse: true,
    enableIntro: false,
    profileClass: "rift-profile-program",
  },
  speakers: {
    id: "speakers",
    ambientOpacity: 0.75,
    contourDensity: "medium",
    channelBias: "right",
    accentMode: "green",
    enablePulse: true,
    enableIntro: false,
    profileClass: "rift-profile-speakers",
  },
  partners: {
    id: "partners",
    ambientOpacity: 0.8,
    contourDensity: "high",
    channelBias: "right",
    accentMode: "green",
    enablePulse: true,
    enableIntro: false,
    profileClass: "rift-profile-partners",
  },
  pitch: {
    id: "pitch",
    ambientOpacity: 0.75,
    contourDensity: "medium",
    channelBias: "center",
    accentMode: "gold",
    enablePulse: true,
    enableIntro: false,
    profileClass: "rift-profile-pitch",
  },
  exhibit: {
    id: "exhibit",
    ambientOpacity: 0.72,
    contourDensity: "medium",
    channelBias: "center",
    accentMode: "mixed",
    enablePulse: true,
    enableIntro: false,
    profileClass: "rift-profile-exhibit",
  },
  sponsor: {
    id: "sponsor",
    ambientOpacity: 0.65,
    contourDensity: "medium",
    channelBias: "center",
    accentMode: "green",
    enablePulse: false,
    enableIntro: false,
    profileClass: "rift-profile-sponsor",
  },
  contact: {
    id: "contact",
    ambientOpacity: 0.4,
    contourDensity: "low",
    channelBias: "center",
    accentMode: "green",
    enablePulse: false,
    enableIntro: false,
    profileClass: "rift-profile-contact",
  },
  payment: {
    id: "payment",
    ambientOpacity: 0.7,
    contourDensity: "medium",
    channelBias: "center",
    accentMode: "gold",
    enablePulse: true,
    enableIntro: false,
    profileClass: "rift-profile-payment",
  },
  "payment-success": {
    id: "payment-success",
    ambientOpacity: 0.45,
    contourDensity: "low",
    channelBias: "center",
    accentMode: "green",
    enablePulse: false,
    enableIntro: false,
    profileClass: "rift-profile-payment-success",
  },
  privacy: {
    id: "privacy",
    ambientOpacity: 0.35,
    contourDensity: "low",
    channelBias: "center",
    accentMode: "green",
    enablePulse: false,
    enableIntro: false,
    profileClass: "rift-profile-privacy",
  },
};

export const HOME_PROFILE = PROFILES.home;

export function pathnameToProfileId(pathname: string): RiftPageProfileId {
  if (pathname === "/") return "home";
  if (pathname.startsWith("/program")) return "program";
  if (pathname.startsWith("/speakers")) return "speakers";
  if (pathname.startsWith("/partners")) return "partners";
  if (pathname.startsWith("/pitch-competition")) return "pitch";
  if (pathname.startsWith("/exhibit")) return "exhibit";
  if (pathname.startsWith("/sponsor")) return "sponsor";
  if (pathname.startsWith("/contact")) return "contact";
  if (pathname === "/payment/success") return "payment-success";
  if (pathname.startsWith("/payment")) return "payment";
  if (pathname.startsWith("/privacy")) return "privacy";
  return "home";
}

export function getRiftProfile(pathname: string): RiftPageProfile {
  return PROFILES[pathnameToProfileId(pathname)];
}
