/**
 * DailyNotificationConstants.kt
 * 
 * Centralized constants for Daily Notification Plugin
 * Eliminates magic numbers and string duplication across the codebase
 * 
 * @author Matthew Raymer
 * @version 1.0.0
 */

package org.timesafari.dailynotification

/**
 * Centralized constants for Daily Notification Plugin
 * 
 * All request codes, channel IDs, action strings, and extra keys
 * should be defined here and imported where needed.
 */
object DailyNotificationConstants {
    
    // ============================================================
    // Permission Request Codes
    // ============================================================
    
    /**
     * Maximum number of distinct JWT strings allowed in [configureNativeFetcher] `jwtTokens` / pool.
     * Host apps (e.g. TimeSafari) use a pool for background prefetch; cap avoids oversized bridge payloads.
     */
    const val JWT_TOKEN_POOL_MAX = 128

    /**
     * Request code for notification permission requests
     * Used by ActivityCompat.requestPermissions()
     */
    const val PERMISSION_REQUEST_CODE = 1001
    
    // ============================================================
    // Notification Channel Constants
    // ============================================================
    
    /**
     * Default notification channel ID
     * Must match across ChannelManager and NotifyReceiver
     */
    const val DEFAULT_CHANNEL_ID = "timesafari.daily"
    
    /**
     * Default notification channel name (user-visible)
     */
    const val DEFAULT_CHANNEL_NAME = "Daily Notifications"
    
    /**
     * Default notification channel description
     */
    const val DEFAULT_CHANNEL_DESCRIPTION = "Daily notifications from TimeSafari"
    
    // ============================================================
    // Intent Actions
    // ============================================================
    
    /**
     * Action string for notification broadcast intents
     * Used by AlarmManager PendingIntents
     */
    const val ACTION_NOTIFICATION = "org.timesafari.daily.NOTIFICATION"
    
    // ============================================================
    // Intent Extras Keys
    // ============================================================
    
    /**
     * Extra key for notification ID in broadcast intents
     */
    const val EXTRA_NOTIFICATION_ID = "notification_id"
    
    /**
     * Extra key for schedule ID in broadcast intents
     */
    const val EXTRA_SCHEDULE_ID = "schedule_id"
    
    // ============================================================
    // Notification IDs
    // ============================================================
    
    /**
     * Default notification ID for daily notifications
     * Used by NotificationManager.notify()
     */
    const val DEFAULT_NOTIFICATION_ID = 1001
    
    // ============================================================
    // SharedPreferences Keys
    // ============================================================
    
    /**
     * SharedPreferences file name for plugin storage
     */
    const val PREFS_NAME = "daily_notification_timesafari"
    
    /**
     * SharedPreferences key for starred plan IDs
     * Used by updateStarredPlans() and TimeSafariIntegrationManager
     */
    const val PREFS_KEY_STARRED_PLAN_IDS = "starredPlanIds"
    
    // ============================================================
    // WorkManager Tags
    // ============================================================
    
    /**
     * WorkManager tag for prefetch jobs
     */
    const val WORK_TAG_PREFETCH = "prefetch"
    
    /**
     * WorkManager tag for fetch jobs
     */
    const val WORK_TAG_FETCH = "daily_notification_fetch"
    
    /**
     * WorkManager tag for maintenance jobs
     */
    const val WORK_TAG_MAINTENANCE = "daily_notification_maintenance"
    
    /**
     * WorkManager tag for soft refetch jobs
     */
    const val WORK_TAG_SOFT_REFETCH = "soft_refetch"
    
    /**
     * WorkManager tag for display jobs
     */
    const val WORK_TAG_DISPLAY = "daily_notification_display"
    
    /**
     * WorkManager tag for dismiss jobs
     */
    const val WORK_TAG_DISMISS = "daily_notification_dismiss"
    
    // ============================================================
    // Schedule IDs
    // ============================================================
    
    /**
     * Default schedule ID for daily notifications
     * Used when user doesn't provide a custom ID
     */
    const val DEFAULT_SCHEDULE_ID = "daily_notification"

    /**
     * SharedPreferences name for dual (New Activity) schedule config.
     * Used by plugin to persist config and by Worker to resolve relationship (contentTimeout/fallbackBehavior).
     */
    const val DUAL_SCHEDULE_PREFS = "daily_notification_dual"

    /**
     * Key for persisted dual schedule config JSON (userNotification + relationship).
     */
    const val DUAL_SCHEDULE_CONFIG_KEY = "dual_schedule_config"

    /**
     * Stable dual notify [Schedule.id] persisted when [ScheduleHelper.scheduleDualNotification] runs.
     * The user-visible alarm is scheduled after prefetch completes ([DualScheduleNotifyScheduler]).
     */
    const val DUAL_NOTIFY_SCHEDULE_ID_KEY = "dual_notify_schedule_id"

    /**
     * Prefix for dual notify schedule IDs. Receiver uses this to apply relationship at fire time.
     */
    const val DUAL_NOTIFY_SCHEDULE_ID_PREFIX = "dual_notify_"

    /**
     * Prefix for API-managed batch notification schedule IDs (`api_<epochMillis>`).
     * Matches iOS [apiNotificationPrefix]; must not overlap daily reminders or dual schedules.
     */
    const val API_SCHEDULE_ID_PREFIX = "api_"
    
    // ============================================================
    // Request Code Versioning
    // ============================================================
    
    /**
     * Version for request code derivation algorithm
     * Increment if request code generation logic changes
     */
    const val REQUEST_CODE_VERSION = 1
}

