import { error } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';

const onboardingHosts = new Set(['onboarding.goodwalk.co.nz']);

export const load: PageServerLoad = async ({ url }) => {
  const hostname = url.hostname.toLowerCase();
  const isOnboardingHost =
    onboardingHosts.has(hostname) || url.searchParams.get('preview') === 'contract';

  if (!isOnboardingHost) {
    throw error(404, 'Not found');
  }

  return {
    isPreview: url.searchParams.get('preview') === 'contract',
  };
};
