export const PRIVATE_REEL_PRODUCTION_ORIGIN = "https://private-reel.royeradames.com";
export const PRIVATE_REEL_LEGACY_ORIGIN = "https://gallery.royeradames.com";
export const PRIVATE_REEL_VERCEL_ORIGIN = "https://private-reel.vercel.app";

export function isPrivateReelPreviewOrigin(origin) {
  try {
    const url = new URL(origin);
    if (url.protocol !== "https:") return false;
    return /^private-reel-git-[a-z0-9-]+-royer-adames-projects\.vercel\.app$/i.test(url.hostname);
  } catch {
    return false;
  }
}

export function isPrivateReelProductionOrigin(origin) {
  return [
    PRIVATE_REEL_PRODUCTION_ORIGIN,
    PRIVATE_REEL_LEGACY_ORIGIN,
    PRIVATE_REEL_VERCEL_ORIGIN,
  ].includes(origin);
}

export function isAllowedGalleryOrigin(origin, configuredOrigins = []) {
  return configuredOrigins.includes(origin)
    || isPrivateReelProductionOrigin(origin)
    || isPrivateReelPreviewOrigin(origin);
}
