export type SeoLandingKey =
  | 'property-price-map'
  | 'postcode-property-search'
  | 'commute-property-search'
  | 'school-property-search'
  | 'postcode-checker';

export type SeoContentKey =
  | 'birmingham-property-search'
  | 'manchester-property-search'
  | 'bristol-property-search'
  | 'data-sources'
  | 'methodology'
  | 'privacy-security';

export type SeoPageKey = SeoLandingKey | SeoContentKey;

export const SEO_LANDING_PATHS: Record<SeoLandingKey, string> = {
  'property-price-map': '/property-price-map',
  'postcode-property-search': '/postcode-property-search',
  'commute-property-search': '/commute-property-search',
  'school-property-search': '/school-property-search',
  'postcode-checker': '/postcode-checker',
};

export const SEO_CONTENT_PATHS: Record<SeoContentKey, string> = {
  'birmingham-property-search': '/property-search/birmingham',
  'manchester-property-search': '/property-search/manchester',
  'bristol-property-search': '/property-search/bristol',
  'data-sources': '/data-sources',
  methodology: '/methodology',
  'privacy-security': '/privacy-security',
};

export function getSeoLandingPage(pathname: string): SeoLandingKey | null {
  const match = Object.entries(SEO_LANDING_PATHS).find(([, path]) => path === pathname);
  return (match?.[0] as SeoLandingKey | undefined) ?? null;
}

export function getSeoContentPage(pathname: string): SeoContentKey | null {
  const match = Object.entries(SEO_CONTENT_PATHS).find(([, path]) => path === pathname);
  return (match?.[0] as SeoContentKey | undefined) ?? null;
}

export function isSeoLandingKey(page: string): page is SeoLandingKey {
  return Object.prototype.hasOwnProperty.call(SEO_LANDING_PATHS, page);
}

export function isSeoContentKey(page: string): page is SeoContentKey {
  return Object.prototype.hasOwnProperty.call(SEO_CONTENT_PATHS, page);
}
