export interface GentleConfig {
  maxPerDay: number;
  quietHoursStart: number;
  quietHoursEnd: number;
  minIntervalMinutes: number;
  dismissCount?: number;
}

const FORBIDDEN_PHRASES = [
  "you failed",
  "you broke",
  "you gave up",
  "disappointed",
  "shame",
  "guilt",
  "lazy",
  "weak",
  "cheat",
] as const;

export function createGentleNotificationEngine() {
  return {
    containsForbiddenPhrase(text: string): boolean {
      const lower = text.toLowerCase();
      return FORBIDDEN_PHRASES.some((phrase) => lower.includes(phrase));
    },

    getDefaultConfig(): GentleConfig {
      return {
        maxPerDay: 8,
        quietHoursStart: 22,
        quietHoursEnd: 7,
        minIntervalMinutes: 30,
      };
    },

    recordDismissal(config: GentleConfig): GentleConfig {
      return {
        ...config,
        dismissCount: (config.dismissCount ?? 0) + 1,
      };
    },
  };
}
