export const APP_DOMAIN =
  process.env.NEXT_PUBLIC_APP_DOMAIN || "testbed.mk";

export const APP_URL = process.env.NEXT_PUBLIC_APP_URL || `https://${APP_DOMAIN}`;

export const SUBDOMAIN_REGEX = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;

export const SUBDOMAIN_MIN_LENGTH = 3;
export const SUBDOMAIN_MAX_LENGTH = 32;

export const TITLE_MAX_LENGTH = 100;
export const DESCRIPTION_MAX_LENGTH = 2000;

export const ADMIN_PASSWORD_MIN_LENGTH = 12;

export const IMAGE_KEY_REGEX =
  /^uploads\/[a-zA-Z0-9_-]+\/[a-f0-9-]+\.(jpe?g|png|webp)$/i;

export function isAllowedImageKey(key: string): boolean {
  return IMAGE_KEY_REGEX.test(key);
}

export const SUPER_ADMIN_USERNAME = process.env.SUPER_ADMIN_USERNAME || "super";
export const SUPER_ADMIN_PASSWORD_HASH = process.env.SUPER_ADMIN_PASSWORD_HASH || "";

export function getAppOrigin(): string {
  return APP_URL;
}
