import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart' as intl;

import 'app_localizations_ar.dart';
import 'app_localizations_de.dart';
import 'app_localizations_en.dart';
import 'app_localizations_es.dart';
import 'app_localizations_fr.dart';
import 'app_localizations_hi.dart';
import 'app_localizations_id.dart';
import 'app_localizations_it.dart';
import 'app_localizations_ja.dart';
import 'app_localizations_ko.dart';
import 'app_localizations_pt.dart';
import 'app_localizations_ru.dart';
import 'app_localizations_zh.dart';

// ignore_for_file: type=lint

/// Callers can lookup localized strings with an instance of AppLocalizations
/// returned by `AppLocalizations.of(context)`.
///
/// Applications need to include `AppLocalizations.delegate()` in their app's
/// `localizationDelegates` list, and the locales they support in the app's
/// `supportedLocales` list. For example:
///
/// ```dart
/// import 'l10n/app_localizations.dart';
///
/// return MaterialApp(
///   localizationsDelegates: AppLocalizations.localizationsDelegates,
///   supportedLocales: AppLocalizations.supportedLocales,
///   home: MyApplicationHome(),
/// );
/// ```
///
/// ## Update pubspec.yaml
///
/// Please make sure to update your pubspec.yaml to include the following
/// packages:
///
/// ```yaml
/// dependencies:
///   # Internationalization support.
///   flutter_localizations:
///     sdk: flutter
///   intl: any # Use the pinned version from flutter_localizations
///
///   # Rest of dependencies
/// ```
///
/// ## iOS Applications
///
/// iOS applications define key application metadata, including supported
/// locales, in an Info.plist file that is built into the application bundle.
/// To configure the locales supported by your app, you’ll need to edit this
/// file.
///
/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file.
/// Then, in the Project Navigator, open the Info.plist file under the Runner
/// project’s Runner folder.
///
/// Next, select the Information Property List item, select Add Item from the
/// Editor menu, then select Localizations from the pop-up menu.
///
/// Select and expand the newly-created Localizations item then, for each
/// locale your application supports, add a new item and select the locale
/// you wish to add from the pop-up menu in the Value field. This list should
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
  AppLocalizations(String locale)
    : localeName = intl.Intl.canonicalizedLocale(locale.toString());

  final String localeName;

  static AppLocalizations? of(BuildContext context) {
    return Localizations.of<AppLocalizations>(context, AppLocalizations);
  }

  static const LocalizationsDelegate<AppLocalizations> delegate =
      _AppLocalizationsDelegate();

  /// A list of this localizations delegate along with the default localizations
  /// delegates.
  ///
  /// Returns a list of localizations delegates containing this delegate along with
  /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
  /// and GlobalWidgetsLocalizations.delegate.
  ///
  /// Additional delegates can be added by appending to this list in
  /// MaterialApp. This list does not have to be used at all if a custom list
  /// of delegates is preferred or required.
  static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
      <LocalizationsDelegate<dynamic>>[
        delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ];

  /// A list of this localizations delegate's supported locales.
  static const List<Locale> supportedLocales = <Locale>[
    Locale('ar'),
    Locale('de'),
    Locale('en'),
    Locale('es'),
    Locale('fr'),
    Locale('hi'),
    Locale('id'),
    Locale('it'),
    Locale('ja'),
    Locale('ko'),
    Locale('pt'),
    Locale('ru'),
    Locale('zh'),
  ];

  /// The application title
  ///
  /// In en, this message translates to:
  /// **'FocusBuddy'**
  String get appTitle;

  /// Button text to start a focus session
  ///
  /// In en, this message translates to:
  /// **'Start Focusing'**
  String get startFocusing;

  /// Minutes plural form
  ///
  /// In en, this message translates to:
  /// **'{count, plural, =1{minute} other{minutes}}'**
  String minutes(int count);

  /// Minutes with value
  ///
  /// In en, this message translates to:
  /// **'{count} {minutes}'**
  String minutesValue(int count, Object minutes);

  /// Helper text on home screen
  ///
  /// In en, this message translates to:
  /// **'Tap \'I got distracted\'\nanytime — no guilt.'**
  String get tapDistractionAnytime;

  /// History navigation button
  ///
  /// In en, this message translates to:
  /// **'History'**
  String get history;

  /// Settings navigation button
  ///
  /// In en, this message translates to:
  /// **'Settings'**
  String get settings;

  /// Main distraction button text
  ///
  /// In en, this message translates to:
  /// **'I got distracted'**
  String get iGotDistracted;

  /// No description provided for @pause.
  ///
  /// In en, this message translates to:
  /// **'Pause'**
  String get pause;

  /// No description provided for @resume.
  ///
  /// In en, this message translates to:
  /// **'Resume'**
  String get resume;

  /// No description provided for @stopSession.
  ///
  /// In en, this message translates to:
  /// **'Stop session'**
  String get stopSession;

  /// Distraction sheet title
  ///
  /// In en, this message translates to:
  /// **'What pulled you away?'**
  String get whatPulledYouAway;

  /// No description provided for @skipThisTime.
  ///
  /// In en, this message translates to:
  /// **'Skip this time'**
  String get skipThisTime;

  /// No description provided for @stopEarly.
  ///
  /// In en, this message translates to:
  /// **'Stop early?'**
  String get stopEarly;

  /// No description provided for @stopEarlyMessage.
  ///
  /// In en, this message translates to:
  /// **'That\'s totally fine — you still focused for {minutes} {minuteText}!'**
  String stopEarlyMessage(int minutes, Object minuteText);

  /// No description provided for @keepGoing.
  ///
  /// In en, this message translates to:
  /// **'Keep going'**
  String get keepGoing;

  /// No description provided for @yesStop.
  ///
  /// In en, this message translates to:
  /// **'Yes, stop'**
  String get yesStop;

  /// Encouragement message when distracted
  ///
  /// In en, this message translates to:
  /// **'It happens. Let\'s gently come back.'**
  String get distractionEncouragement;

  /// No description provided for @focusComplete.
  ///
  /// In en, this message translates to:
  /// **'Focus session complete!'**
  String get focusComplete;

  /// No description provided for @youFocusedFor.
  ///
  /// In en, this message translates to:
  /// **'You focused for'**
  String get youFocusedFor;

  /// No description provided for @totalToday.
  ///
  /// In en, this message translates to:
  /// **'Total today: {minutes} mins'**
  String totalToday(int minutes);

  /// No description provided for @distractionsCount.
  ///
  /// In en, this message translates to:
  /// **'Distractions: {count} {times}'**
  String distractionsCount(int count, Object times);

  /// No description provided for @times.
  ///
  /// In en, this message translates to:
  /// **'{count, plural, =1{time} other{times}}'**
  String times(int count);

  /// No description provided for @startAnother.
  ///
  /// In en, this message translates to:
  /// **'Start Another'**
  String get startAnother;

  /// No description provided for @viewHistory.
  ///
  /// In en, this message translates to:
  /// **'View History'**
  String get viewHistory;

  /// No description provided for @yourFocusJourney.
  ///
  /// In en, this message translates to:
  /// **'Your Focus Journey'**
  String get yourFocusJourney;

  /// No description provided for @noFocusSessionsYet.
  ///
  /// In en, this message translates to:
  /// **'No focus sessions yet'**
  String get noFocusSessionsYet;

  /// No description provided for @startFirstSession.
  ///
  /// In en, this message translates to:
  /// **'Start your first session\nto see your progress here!'**
  String get startFirstSession;

  /// No description provided for @today.
  ///
  /// In en, this message translates to:
  /// **'Today'**
  String get today;

  /// No description provided for @sessions.
  ///
  /// In en, this message translates to:
  /// **'{count, plural, =1{{count} session} other{{count} sessions}}'**
  String sessions(int count);

  /// No description provided for @completed.
  ///
  /// In en, this message translates to:
  /// **'Completed'**
  String get completed;

  /// No description provided for @stoppedEarly.
  ///
  /// In en, this message translates to:
  /// **'Stopped early'**
  String get stoppedEarly;

  /// No description provided for @distractions.
  ///
  /// In en, this message translates to:
  /// **'{count, plural, =1{distraction} other{distractions}}'**
  String distractions(int count);

  /// No description provided for @focusSettings.
  ///
  /// In en, this message translates to:
  /// **'Focus Settings'**
  String get focusSettings;

  /// No description provided for @defaultFocusDuration.
  ///
  /// In en, this message translates to:
  /// **'Default Focus Duration'**
  String get defaultFocusDuration;

  /// No description provided for @defaultLabel.
  ///
  /// In en, this message translates to:
  /// **'Default'**
  String get defaultLabel;

  /// No description provided for @about.
  ///
  /// In en, this message translates to:
  /// **'About'**
  String get about;

  /// No description provided for @privacyPolicy.
  ///
  /// In en, this message translates to:
  /// **'Privacy Policy'**
  String get privacyPolicy;

  /// No description provided for @termsOfService.
  ///
  /// In en, this message translates to:
  /// **'Terms of Service'**
  String get termsOfService;

  /// No description provided for @aboutFocusBuddy.
  ///
  /// In en, this message translates to:
  /// **'About FocusBuddy'**
  String get aboutFocusBuddy;

  /// No description provided for @resetOnboarding.
  ///
  /// In en, this message translates to:
  /// **'Reset Onboarding'**
  String get resetOnboarding;

  /// No description provided for @version.
  ///
  /// In en, this message translates to:
  /// **'Version 1.0.0 (MVP)'**
  String get version;

  /// No description provided for @privacyPolicyTitle.
  ///
  /// In en, this message translates to:
  /// **'Privacy Policy'**
  String get privacyPolicyTitle;

  /// No description provided for @privacyPolicyContent.
  ///
  /// In en, this message translates to:
  /// **'FocusBuddy is 100% offline. We do not collect your name, email, location, or usage data. All sessions stay on your device.\n\nThere is no cloud sync, no account system, and no analytics tracking.\n\nFor the full privacy policy, visit:\nhttps://ytc1012.github.io/focusbuddy-site/privacy-policy.html'**
  String get privacyPolicyContent;

  /// No description provided for @termsOfServiceTitle.
  ///
  /// In en, this message translates to:
  /// **'Terms of Service'**
  String get termsOfServiceTitle;

  /// No description provided for @termsOfServiceContent.
  ///
  /// In en, this message translates to:
  /// **'FocusBuddy is provided \"as is\" without warranties. By using this app, you agree to use it at your own risk.\n\nThis app is designed as a focus timer tool and does not guarantee specific results. All data is stored locally on your device.\n\nFor the full terms of service, visit:\nhttps://ytc1012.github.io/focusbuddy-site/terms-of-service.html'**
  String get termsOfServiceContent;

  /// No description provided for @close.
  ///
  /// In en, this message translates to:
  /// **'Close'**
  String get close;

  /// No description provided for @aboutTitle.
  ///
  /// In en, this message translates to:
  /// **'About FocusBuddy'**
  String get aboutTitle;

  /// No description provided for @aboutSubtitle.
  ///
  /// In en, this message translates to:
  /// **'A gentle focus timer for neurodivergent minds'**
  String get aboutSubtitle;

  /// No description provided for @aboutQuote.
  ///
  /// In en, this message translates to:
  /// **'\"Focus is not about never getting distracted — it\'s about gently coming back every time you do.\"'**
  String get aboutQuote;

  /// No description provided for @aboutFeatures.
  ///
  /// In en, this message translates to:
  /// **'✨ No punishment for distractions\n💚 Encouragement over criticism\n🔒 100% offline and private\n🌱 Made with care'**
  String get aboutFeatures;

  /// No description provided for @resetOnboardingTitle.
  ///
  /// In en, this message translates to:
  /// **'Reset Onboarding?'**
  String get resetOnboardingTitle;

  /// No description provided for @resetOnboardingMessage.
  ///
  /// In en, this message translates to:
  /// **'This will show the onboarding screens again when you restart the app.'**
  String get resetOnboardingMessage;

  /// No description provided for @cancel.
  ///
  /// In en, this message translates to:
  /// **'Cancel'**
  String get cancel;

  /// No description provided for @reset.
  ///
  /// In en, this message translates to:
  /// **'Reset'**
  String get reset;

  /// No description provided for @onboardingReset.
  ///
  /// In en, this message translates to:
  /// **'Onboarding reset. Restart the app to see it again.'**
  String get onboardingReset;

  /// No description provided for @onboarding1Title.
  ///
  /// In en, this message translates to:
  /// **'Focus without guilt'**
  String get onboarding1Title;

  /// No description provided for @onboarding1Description.
  ///
  /// In en, this message translates to:
  /// **'This app is different — it won\'t punish you for losing focus.\n\nPerfect for ADHD, anxiety, or anyone who finds traditional timers too harsh.'**
  String get onboarding1Description;

  /// No description provided for @onboarding2Title.
  ///
  /// In en, this message translates to:
  /// **'Tap when you get distracted'**
  String get onboarding2Title;

  /// No description provided for @onboarding2Description.
  ///
  /// In en, this message translates to:
  /// **'We\'ll gently remind you to come back.\n\nNo shame. No stress. Just a friendly nudge.'**
  String get onboarding2Description;

  /// No description provided for @onboarding3Title.
  ///
  /// In en, this message translates to:
  /// **'Track your progress'**
  String get onboarding3Title;

  /// No description provided for @onboarding3Description.
  ///
  /// In en, this message translates to:
  /// **'See how you\'re improving, one session at a time.\n\nEvery distraction is just data — not failure.'**
  String get onboarding3Description;

  /// No description provided for @skip.
  ///
  /// In en, this message translates to:
  /// **'Skip'**
  String get skip;

  /// No description provided for @next.
  ///
  /// In en, this message translates to:
  /// **'Next'**
  String get next;

  /// No description provided for @getStarted.
  ///
  /// In en, this message translates to:
  /// **'Get Started'**
  String get getStarted;

  /// No description provided for @notificationFocusInProgress.
  ///
  /// In en, this message translates to:
  /// **'Focus session in progress'**
  String get notificationFocusInProgress;

  /// No description provided for @notificationRemaining.
  ///
  /// In en, this message translates to:
  /// **'{time} remaining'**
  String notificationRemaining(String time);

  /// No description provided for @notificationFocusCompleteTitle.
  ///
  /// In en, this message translates to:
  /// **'🎉 Focus session complete!'**
  String get notificationFocusCompleteTitle;

  /// No description provided for @notificationFocusCompleteBodyNoDistractions.
  ///
  /// In en, this message translates to:
  /// **'You focused for {minutes} {minuteText} without distractions!'**
  String notificationFocusCompleteBodyNoDistractions(
    int minutes,
    Object minuteText,
  );

  /// No description provided for @notificationFocusCompleteBody.
  ///
  /// In en, this message translates to:
  /// **'You focused for {minutes} {minuteText}. Great effort!'**
  String notificationFocusCompleteBody(int minutes, Object minuteText);

  /// No description provided for @distractionPhoneNotification.
  ///
  /// In en, this message translates to:
  /// **'Phone / Notification'**
  String get distractionPhoneNotification;

  /// No description provided for @distractionSocialMedia.
  ///
  /// In en, this message translates to:
  /// **'Social Media'**
  String get distractionSocialMedia;

  /// No description provided for @distractionThoughts.
  ///
  /// In en, this message translates to:
  /// **'Thoughts / Daydream'**
  String get distractionThoughts;

  /// No description provided for @distractionOther.
  ///
  /// In en, this message translates to:
  /// **'Other'**
  String get distractionOther;

  /// No description provided for @language.
  ///
  /// In en, this message translates to:
  /// **'Language'**
  String get language;

  /// No description provided for @selectLanguage.
  ///
  /// In en, this message translates to:
  /// **'Select Language'**
  String get selectLanguage;

  /// No description provided for @english.
  ///
  /// In en, this message translates to:
  /// **'English'**
  String get english;

  /// No description provided for @chinese.
  ///
  /// In en, this message translates to:
  /// **'中文 (Chinese)'**
  String get chinese;

  /// No description provided for @japanese.
  ///
  /// In en, this message translates to:
  /// **'日本語 (Japanese)'**
  String get japanese;

  /// No description provided for @korean.
  ///
  /// In en, this message translates to:
  /// **'한국어 (Korean)'**
  String get korean;

  /// No description provided for @spanish.
  ///
  /// In en, this message translates to:
  /// **'Español (Spanish)'**
  String get spanish;

  /// No description provided for @german.
  ///
  /// In en, this message translates to:
  /// **'Deutsch (German)'**
  String get german;

  /// No description provided for @french.
  ///
  /// In en, this message translates to:
  /// **'Français (French)'**
  String get french;

  /// No description provided for @portuguese.
  ///
  /// In en, this message translates to:
  /// **'Português (Portuguese)'**
  String get portuguese;

  /// No description provided for @russian.
  ///
  /// In en, this message translates to:
  /// **'Русский (Russian)'**
  String get russian;

  /// No description provided for @hindi.
  ///
  /// In en, this message translates to:
  /// **'हिन्दी (Hindi)'**
  String get hindi;

  /// No description provided for @indonesian.
  ///
  /// In en, this message translates to:
  /// **'Bahasa Indonesia (Indonesian)'**
  String get indonesian;

  /// No description provided for @italian.
  ///
  /// In en, this message translates to:
  /// **'Italiano (Italian)'**
  String get italian;

  /// No description provided for @arabic.
  ///
  /// In en, this message translates to:
  /// **'العربية (Arabic)'**
  String get arabic;
}

class _AppLocalizationsDelegate
    extends LocalizationsDelegate<AppLocalizations> {
  const _AppLocalizationsDelegate();

  @override
  Future<AppLocalizations> load(Locale locale) {
    return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
  }

  @override
  bool isSupported(Locale locale) => <String>[
    'ar',
    'de',
    'en',
    'es',
    'fr',
    'hi',
    'id',
    'it',
    'ja',
    'ko',
    'pt',
    'ru',
    'zh',
  ].contains(locale.languageCode);

  @override
  bool shouldReload(_AppLocalizationsDelegate old) => false;
}

AppLocalizations lookupAppLocalizations(Locale locale) {
  // Lookup logic when only language code is specified.
  switch (locale.languageCode) {
    case 'ar':
      return AppLocalizationsAr();
    case 'de':
      return AppLocalizationsDe();
    case 'en':
      return AppLocalizationsEn();
    case 'es':
      return AppLocalizationsEs();
    case 'fr':
      return AppLocalizationsFr();
    case 'hi':
      return AppLocalizationsHi();
    case 'id':
      return AppLocalizationsId();
    case 'it':
      return AppLocalizationsIt();
    case 'ja':
      return AppLocalizationsJa();
    case 'ko':
      return AppLocalizationsKo();
    case 'pt':
      return AppLocalizationsPt();
    case 'ru':
      return AppLocalizationsRu();
    case 'zh':
      return AppLocalizationsZh();
  }

  throw FlutterError(
    'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
    'an issue with the localizations generation tool. Please file an issue '
    'on GitHub with a reproducible sample app and the gen-l10n configuration '
    'that was used.',
  );
}
