export interface UserMessage {
	role: "user"
	message: string
	bubbleLayoutId?: string
}

export interface SystemMessage {
	role: "system"
	message: string
}

export type Message = UserMessage | SystemMessage

function timeOfDay() {
	const hours = new Date().getHours()
	if (hours >= 5 && hours < 12) {
		return "morning"
	} else if (hours >= 12 && hours < 18) {
		return "afternoon"
	} else if (hours >= 18 && hours < 22) {
		return "evening"
	}
	return "night"
}

export const INITIAL_MESSAGES: Message[] = [
	{
		role: "user",
		message: "Who are you?",
	},
	{
		role: "system",
		message: `Hey! I'm **Freya** — your personal assistant that brings you the right thing, at the right time, in the right place.

- Jubilee line down? I've already found you an alternative route.
- Dinner reservation at 8? I'll have the restaurant, directions, and the menu ready before you head out.

I learn your routines, anticipate what's next, and surface what matters before you even think to look for it.

I'm not ready yet — [@kennethnym](https://x.com/kennethnym) is still building me. **Drop your email below** and I'll let you know when I'm available.`,
	},
]

export function waitListJoinedMessage(email: string): SystemMessage {
	return {
		role: "system",
		message: `Thanks for joining the waitlist! I've sent you a confirmation email.
I'll send an email to **${email}** when I'm ready.

Have a good ${timeOfDay()}!`,
	}
}

export function duplicateEmailMessage(): SystemMessage {
	return {
		role: "system",
		message: `I appreciate your excitement! You are already on the waitlist. When I am ready, I will reach out again. Have a good ${timeOfDay()} :)`,
	}
}

export function troubleMessage(): SystemMessage {
	return {
		role: "system",
		message: `I apologize, but I am having trouble adding you to the waitlist. Could you refresh the page and try again please in a moment?`,
	}
}
