//
//  NotificationTitles.swift
//  Reflect (iOS)
//
//  Created by Trey Tartt on 2/19/22.
//

import Foundation

protocol PersonalityPackable {
    static var notificationTitles: [String] { get }
    static var notificationBodyToday: [String] { get }
    static var notificationBodyYesterday: [String] { get }
    
    static var title: String { get }
}

enum PersonalityPack: Int, CaseIterable {
    case Default = 0
//    case Rude = 1
    case MotivationalCoach = 1
    case ZenMaster = 2
    case BestFriend = 3
    case DataAnalyst = 4

    func randomPushNotificationStrings() -> (title: String, body: String) {
        let onboarding = UserDefaultsStore.getOnboarding()

        switch (self, onboarding.inputDay) {
        case (.Default, .Today):
            return (DefaultTitles.notificationTitles.randomElement()!,
                    DefaultTitles.notificationBodyToday.randomElement()!)
        case (.Default, .Previous):
            return (DefaultTitles.notificationTitles.randomElement()!,
                    DefaultTitles.notificationBodyYesterday.randomElement()!)
//        case (.Rude, .Today):
//            return (RudeTitles.notificationTitles.randomElement()!,
//                    RudeTitles.notificationBodyToday.randomElement()!)
//        case (.Rude, .Previous):
//            return (RudeTitles.notificationTitles.randomElement()!,
//                    RudeTitles.notificationBodyYesterday.randomElement()!)
        case (.MotivationalCoach, .Today):
            return (MotivationalCoachTitles.notificationTitles.randomElement()!,
                    MotivationalCoachTitles.notificationBodyToday.randomElement()!)
        case (.MotivationalCoach, .Previous):
            return (MotivationalCoachTitles.notificationTitles.randomElement()!,
                    MotivationalCoachTitles.notificationBodyYesterday.randomElement()!)
        case (.ZenMaster, .Today):
            return (ZenMasterTitles.notificationTitles.randomElement()!,
                    ZenMasterTitles.notificationBodyToday.randomElement()!)
        case (.ZenMaster, .Previous):
            return (ZenMasterTitles.notificationTitles.randomElement()!,
                    ZenMasterTitles.notificationBodyYesterday.randomElement()!)
        case (.BestFriend, .Today):
            return (BestFriendTitles.notificationTitles.randomElement()!,
                    BestFriendTitles.notificationBodyToday.randomElement()!)
        case (.BestFriend, .Previous):
            return (BestFriendTitles.notificationTitles.randomElement()!,
                    BestFriendTitles.notificationBodyYesterday.randomElement()!)
        case (.DataAnalyst, .Today):
            return (DataAnalystTitles.notificationTitles.randomElement()!,
                    DataAnalystTitles.notificationBodyToday.randomElement()!)
        case (.DataAnalyst, .Previous):
            return (DataAnalystTitles.notificationTitles.randomElement()!,
                    DataAnalystTitles.notificationBodyYesterday.randomElement()!)
        }
    }

    func title() -> String {
        switch self {
        case .Default:
            return DefaultTitles.title
//        case .Rude:
//            return RudeTitles.title
        case .MotivationalCoach:
            return MotivationalCoachTitles.title
        case .ZenMaster:
            return ZenMasterTitles.title
        case .BestFriend:
            return BestFriendTitles.title
        case .DataAnalyst:
            return DataAnalystTitles.title
        }
    }

    var icon: String {
        switch self {
        case .Default: return "face.smiling"
//        case .Rude: return "flame"
        case .MotivationalCoach: return "figure.run"
        case .ZenMaster: return "leaf"
        case .BestFriend: return "heart"
        case .DataAnalyst: return "chart.bar"
        }
    }

    var description: String {
        switch self {
        case .Default: return "Friendly and supportive"
//        case .Rude: return "Snarky with attitude"
        case .MotivationalCoach: return "High energy pump-up vibes"
        case .ZenMaster: return "Calm and mindful"
        case .BestFriend: return "Casual and supportive"
        case .DataAnalyst: return "Stats-focused and objective"
        }
    }
}

final class DefaultTitles: PersonalityPackable {
    static var title = String(localized: "nice")
    
    static var notificationTitles: [String] {
        [
            String(localized: "default_notif_title_one"),
            String(localized: "default_notif_title_two"),
            String(localized: "default_notif_title_three")
        ]
    }
    
    static var notificationBodyToday: [String] {
        [
            String(localized: "default_notif_body_today_one"),
            String(localized: "default_notif_body_today_two"),
            String(localized: "default_notif_body_today_three"),
            String(localized: "default_notif_body_today_four")
        ]
    }
    
    static var notificationBodyYesterday: [String] {
        [
            String(localized: "default_notif_body_yesterday_one"),
            String(localized: "default_notif_body_yesterday_two"),
            String(localized: "default_notif_body_yesterday_three"),
            String(localized: "default_notif_body_yesterday_four")
        ]
    }
}

final class RudeTitles: PersonalityPackable {
    static var title = String(localized: "rude")

    static var notificationTitles: [String] {
        [
            String(localized: "rude_notif_title_one"),
            String(localized: "rude_notif_title_two"),
            String(localized: "rude_notif_title_three"),
            String(localized: "rude_notif_title_four")
        ]
    }

    static var notificationBodyToday: [String] {
        [
            String(localized: "rude_notif_body_today_one"),
            String(localized: "rude_notif_body_today_two"),
            String(localized: "rude_notif_body_today_three")
        ]
    }

    static var notificationBodyYesterday: [String] {
        [
            String(localized: "rude_notif_body_yesterday_one"),
            String(localized: "rude_notif_body_yesterday_two"),
            String(localized: "rude_notif_body_yesterday_three")
        ]
    }
}

// MARK: - Motivational Coach

final class MotivationalCoachTitles: PersonalityPackable {
    static var title = "Coach"

    static var notificationTitles: [String] {
        [
            "LET'S GO!",
            "Champion Check-In",
            "Time to Shine!",
            "You've Got This!"
        ]
    }

    static var notificationBodyToday: [String] {
        [
            "Every day is a chance to be AMAZING! How are you feeling today?",
            "Winners track their progress! Log your mood and keep crushing it!",
            "Your mental game matters! Take 10 seconds to check in with yourself.",
            "Champions know their emotions! How's your energy right now?"
        ]
    }

    static var notificationBodyYesterday: [String] {
        [
            "Yesterday's reflection builds tomorrow's success! How did you feel?",
            "Great athletes review their game tape! Log yesterday's mood!",
            "No day is wasted when you learn from it! How was yesterday?",
            "Every experience counts! Tell me about yesterday!"
        ]
    }
}

// MARK: - Zen Master

final class ZenMasterTitles: PersonalityPackable {
    static var title = "Zen"

    static var notificationTitles: [String] {
        [
            "A Gentle Reminder",
            "Mindful Moment",
            "Inner Peace",
            "Present Awareness"
        ]
    }

    static var notificationBodyToday: [String] {
        [
            "Breathe. Notice. How does this moment find you?",
            "The river of feelings flows through us all. What flows through you now?",
            "Like clouds passing, emotions come and go. What passes through you today?",
            "In stillness, we find clarity. Take a moment to notice your inner weather."
        ]
    }

    static var notificationBodyYesterday: [String] {
        [
            "Yesterday has passed like a leaf on the stream. How did it feel?",
            "Reflecting on the past with compassion... How was yesterday's journey?",
            "Each day is a teacher. What did yesterday's emotions teach you?",
            "With gentle awareness, recall yesterday. What arose within you?"
        ]
    }
}

// MARK: - Best Friend

final class BestFriendTitles: PersonalityPackable {
    static var title = "Bestie"

    static var notificationTitles: [String] {
        [
            "Hey you!",
            "Quick check-in!",
            "Thinking of you!",
            "Got a sec?"
        ]
    }

    static var notificationBodyToday: [String] {
        [
            "Just checking in on my favorite person! How's it going today?",
            "Hey! Tell me everything - how are you feeling right now?",
            "You know I always want to hear about your day! What's the vibe?",
            "Sending good vibes your way! How are you doing today?"
        ]
    }

    static var notificationBodyYesterday: [String] {
        [
            "Wait, we didn't catch up yesterday! How did it go?",
            "I realized I didn't hear about yesterday - fill me in!",
            "Oops, missed you yesterday! How was your day?",
            "Tell me about yesterday! I want to hear all about it!"
        ]
    }
}

// MARK: - Data Analyst

final class DataAnalystTitles: PersonalityPackable {
    static var title = "Analyst"

    static var notificationTitles: [String] {
        [
            "Data Point Required",
            "Daily Metric Input",
            "Mood Tracking Alert",
            "Status Update Needed"
        ]
    }

    static var notificationBodyToday: [String] {
        [
            "Today's emotional data point is pending. Please log your current mood state.",
            "Incomplete dataset detected. Input today's mood to maintain tracking accuracy.",
            "Daily mood metric collection: What is your current emotional status (1-5)?",
            "Recording today's baseline. Please submit your mood data for analysis."
        ]
    }

    static var notificationBodyYesterday: [String] {
        [
            "Gap in historical data: Yesterday's mood entry is missing. Please backfill.",
            "Data integrity alert: Yesterday's emotional metric was not captured.",
            "Historical data request: Submit yesterday's mood for trend analysis.",
            "Missing data point from previous day. Please log for complete dataset."
        ]
    }
}
