import Foundation

/// Shared profile for widget templates and visual styling (host/name rules stay in sync).
enum WidgetAppProfile: Hashable, Sendable {
    case photos
    case gmail
    case drive
    case docs
    case sheets
    case slides
    case forms
    case calendar
    case maps
    case youtube
    case translate
    case search
    case earth
    case shopping
    case keep
    case travel
    case meet
    case contacts
    case blogger
    case play
    case news
    case chat
    case finance
    case jamboard
    case classroom
    case artsCulture
    case voice
    case chromeWebStore
    case fi
    case ads
    case remoteDesktop
    case gemini
    case books
    case unknown

    static func from(app: LauncherApp) -> WidgetAppProfile {
        let host = app.webURL?.host?.lowercased() ?? ""
        let name = app.name.lowercased()
        if host.contains("photos.google.com") || name.contains("photos") { return .photos }
        if host.contains("mail.google.com") || name == "gmail" { return .gmail }
        if host.contains("drive.google.com") { return .drive }
        if host.contains("docs.google.com") { return .docs }
        if host.contains("sheets.google.com") { return .sheets }
        if host.contains("slides.google.com") { return .slides }
        if host.contains("forms.google.com") { return .forms }
        if host.contains("calendar.google.com") { return .calendar }
        if host.contains("maps.google.com") { return .maps }
        if host.contains("youtube.com") { return .youtube }
        if host.contains("translate.google.com") { return .translate }
        if host == "www.google.com" || host == "google.com" { return .search }
        if host.contains("earth.google.com") { return .earth }
        if host.contains("shopping.google.com") { return .shopping }
        if host.contains("keep.google.com") { return .keep }
        if host.contains("travel.google.com") { return .travel }
        if host.contains("meet.google.com") { return .meet }
        if host.contains("contacts.google.com") { return .contacts }
        if host.contains("blogger.com") { return .blogger }
        if host.contains("play.google.com") { return .play }
        if host.contains("news.google.com") { return .news }
        if host.contains("chat.google.com") { return .chat }
        if host.contains("/finance") || name.contains("finance") { return .finance }
        if host.contains("jamboard.google.com") { return .jamboard }
        if host.contains("classroom.google.com") { return .classroom }
        if host.contains("artsandculture.google.com") { return .artsCulture }
        if host.contains("voice.google.com") { return .voice }
        if host.contains("chrome.google.com") { return .chromeWebStore }
        if host.contains("fi.google.com") { return .fi }
        if host.contains("ads.google.com") { return .ads }
        if host.contains("remotedesktop.google.com") { return .remoteDesktop }
        if host.contains("gemini.google.com") { return .gemini }
        if host.contains("books.google.com") { return .books }
        return .unknown
    }
}
