<?php

namespace Planaday\Config\OptionGroups\Course\Overview;

use Planaday\Config\OptionGroups\Course\CourseOptions;
use Planaday\Config\OptionGroups\OptionCluster;
use Planaday\Config\OptionGroups\OptionGroup;
use Planaday\Config\OptionTypes\BoolOption;
use Planaday\Config\OptionTypes\IntOption;
use Planaday\Config\OptionTypes\StringOption;
use Planaday\Utility\DependencyInjection\ComponentRegistry;
use Planaday\Utility\DependencyInjection\ComponentRegistryShortCut;

class OverviewOptions extends OptionGroup implements ComponentRegistryShortCut {
	private const NAME = 'Overzicht';

	private const DESCRIPTION = 'Instellingen voor de overzichten';

	/** @var BoolOption<bool> */
	private $showCode95Icon;

	/** @var BoolOption<bool> */
	private $showSoobIcon;

	/** @var BoolOption<bool> */
	private $showELearningIcon;

	/** @var BoolOption<bool> */
	private $showMoneyBackNotice;

	/** @var BoolOption<bool> */
	private $showStartGuaranteeNotice;

	/** @var BoolOption<bool> */
	private $showFinancialInfo;

	/** @var BoolOption<bool> */
	private $showPrice;

	/** @var BoolOption<bool> */
	private $showDayPartCount;

	/** @var BoolOption<bool> */
	private $showLabels;

	/** @var BoolOption<bool> */
	private $showFirstLocation;
	
	/** @var BoolOption<bool> */
	private $showCourseButton;
	
	/** @var StringOption<string> */
	private $courseButtonText;
	
	/** @var BoolOption<bool> */
	private $showDayPartList;
	
	/** @var BoolOption<bool> */
	private $includeELearningDayParts;
	
	/** @var BoolOption<bool> */
	private $showLocationDayPart;
	
	/** @var BoolOption<bool> */
	private $showLabelsDayPart;
	
	/** @var StringOption<string> */
	private $noCourseText;
	
	/** @var BoolOption<bool> */
	private $includeFullCourses;
	
	/** @var BoolOption<bool> */
	private $includePartiallyPassedCourses;

	/** @var BoolOption<bool> */
	private $showDescription;

	/** @var IntOption<int> */
	private $maxLengthDescription;

	/** @var BoolOption<bool> */
	private $showAvailability;

	/** @var BoolOption<bool> */
	private $countsELearningAsStart;

	public function __construct( string $index, array $data ) {
		$this->showCode95Icon = new BoolOption(
			OverviewOptionsEnum::SHOW_CODE_95_ICON,
			'Code 95 icoon',
			"Moet er een icoon worden getoond voor de code 95?",
			$data[ OverviewOptionsEnum::SHOW_CODE_95_ICON ] ?? null,
			false
		);

		$this->showSoobIcon = new BoolOption(
			OverviewOptionsEnum::SHOW_SOOB_ICON,
			'Soob icoon',
			"Moet er een icoon worden getoond voor Soob?",
			$data[ OverviewOptionsEnum::SHOW_SOOB_ICON ] ?? null,
			false
		);

		$this->showELearningIcon = new BoolOption(
			OverviewOptionsEnum::SHOW_E_LEARNING_ICON,
			'E-learning icoon',
			"Moet er een icoon worden getoond voor e-learning?",
			$data[ OverviewOptionsEnum::SHOW_E_LEARNING_ICON ] ?? null,
			false
		);

		$this->showMoneyBackNotice = new BoolOption(
			OverviewOptionsEnum::SHOW_MONEY_BACK_NOTICE,
			'Terugbetaling notitie',
			"Moet er een notitie worden getoond voor terugbetaling?",
			$data[ OverviewOptionsEnum::SHOW_MONEY_BACK_NOTICE ] ?? null,
			false
		);

		$this->showStartGuaranteeNotice = new BoolOption(
			OverviewOptionsEnum::SHOW_START_GUARANTEE_NOTICE,
			'Start garantie notitie',
			"Moet er een notitie worden getoond voor start garantie?",
			$data[ OverviewOptionsEnum::SHOW_START_GUARANTEE_NOTICE ] ?? null,
			false
		);

		$this->showFinancialInfo = new BoolOption(
			OverviewOptionsEnum::SHOW_FINANCIAL_INFO,
			'Financiële informatie',
			"Moet er financiële informatie worden getoond?",
			$data[ OverviewOptionsEnum::SHOW_FINANCIAL_INFO ] ?? null,
			false
		);

		$this->showPrice = new BoolOption(
			OverviewOptionsEnum::SHOW_PRICE,
			'Prijs',
			"Moet er een prijs worden getoond?",
			$data[ OverviewOptionsEnum::SHOW_PRICE ] ?? null,
			false
		);

		$this->showDayPartCount = new BoolOption(
			OverviewOptionsEnum::SHOW_DAY_PART_COUNT,
			'Aantal dagdelen',
			"Moet er een aantal dagdelen worden getoond?",
			$data[ OverviewOptionsEnum::SHOW_DAY_PART_COUNT ] ?? null,
			false
		);

		$this->showLabels = new BoolOption(
			OverviewOptionsEnum::SHOW_LABELS,
			'Labels',
			"Moeten er labels worden getoond?",
			$data[ OverviewOptionsEnum::SHOW_LABELS ] ?? null,
			false
		);

		$this->showFirstLocation = new BoolOption(
			OverviewOptionsEnum::SHOW_FIRST_LOCATION,
			'Eerste locatie',
			"Moet er een eerste locatie worden getoond?",
			$data[ OverviewOptionsEnum::SHOW_FIRST_LOCATION ] ?? null,
			false
		);

		$this->showAvailability = new BoolOption(
			OverviewOptionsEnum::SHOW_AVAILABILITY,
			'Toon beschikbaarheid',
			'Toon de beschikbaarheid bij de cursus',
			$data[ OverviewOptionsEnum::SHOW_AVAILABILITY ] ?? null,
			false
		);

		$showInfoCluster = new OptionCluster(
			'Overzicht Eigenschappen',
			'Welke eigenschappen moeten worden getoond?',
			[
				'Code 95 icoon' => $this->showCode95Icon,
				'Soob icoon' => $this->showSoobIcon,
				'E-learning icoon' => $this->showELearningIcon,
				'Terugbetaling notitie' => $this->showMoneyBackNotice,
				'Start garantie notitie' => $this->showStartGuaranteeNotice,
				'Financiële toelichting (Betalings instellingen)' => $this->showFinancialInfo,
				'Prijs' => $this->showPrice,
				'Aantal dagdelen' => $this->showDayPartCount,
				'Beschikbare plaatsen'                            => $this->showAvailability,
				'Labels' => $this->showLabels,
				'Eerste locatie' => $this->showFirstLocation,
			]
		);
		
		$this->showCourseButton = new BoolOption(
			OverviewOptionsEnum::SHOW_COURSE_BUTTON,
			'Cursus knop',
			"Moet er een knop voor de cursus worden getoond?",
			$data[ OverviewOptionsEnum::SHOW_COURSE_BUTTON ] ?? null,
			true
		);
		
		$this->courseButtonText = new StringOption(
			OverviewOptionsEnum::COURSE_BUTTON_TEXT,
			'Course knop tekst',
			"Welke tekst moet er op de knop voor het course worden getoond?",
			$data[ OverviewOptionsEnum::COURSE_BUTTON_TEXT ] ?? null,
			"Bekijk cursus"
		);

		$this->showDescription = new BoolOption(
			OverviewOptionsEnum::SHOW_DESCRIPTION,
			'Omschrijving',
			"Moet er een omschrijving worden getoond?",
			$data[ OverviewOptionsEnum::SHOW_DESCRIPTION ] ?? null,
			true
		);

		$this->maxLengthDescription = new IntOption(
			OverviewOptionsEnum::MAX_LENGTH_DESCRIPTION,
			'Maximale lengte omschrijving',
			"Hoeveel karakters moet de omschrijving worden afgekapt?",
			$data[ OverviewOptionsEnum::MAX_LENGTH_DESCRIPTION ] ?? null,
			200
		);
		
		$this->showDayPartList = new BoolOption(
			OverviewOptionsEnum::SHOW_DAY_PART_LIST,
			'Dagdelen lijst',
			"Moet er een lijst met dagdelen worden getoond?",
			$data[ OverviewOptionsEnum::SHOW_DAY_PART_LIST ] ?? null,
			false
		);
		
		$this->includeELearningDayParts = new BoolOption(
			OverviewOptionsEnum::INCLUDE_E_LEARNING_DAY_PARTS,
			'Inclusief e-learning dagdelen',
			"Moeten er dagdelen met e-learning worden getoond?",
			$data[ OverviewOptionsEnum::INCLUDE_E_LEARNING_DAY_PARTS ] ?? null,
			false
		);
		
		$this->showLocationDayPart = new BoolOption(
			OverviewOptionsEnum::SHOW_LOCATION_DAY_PART,
			'Locatie dagdelen',
			"Moet de locatie van dagdelen worden getoond?",
			$data[ OverviewOptionsEnum::SHOW_LOCATION_DAY_PART ] ?? null,
			false
		);
		
		$this->showLabelsDayPart = new BoolOption(
			OverviewOptionsEnum::SHOW_LABELS_DAY_PART,
			'Labels dagdelen',
			"Moeten er labels van dagdelen worden getoond?",
			$data[ OverviewOptionsEnum::SHOW_LABELS_DAY_PART ] ?? null,
			false
		);
		
		$this->noCourseText = new StringOption(
			OverviewOptionsEnum::NO_COURSE_TEXT,
			'Geen cursussen text',
			"Deze text word getoond als er geen cursussen kunnen worden getoond.",
			$data[OverviewOptionsEnum::NO_COURSE_TEXT] ?? null,
			'Momenteel zijn er geen cursussen gevonden, bel naar ons voor meer informatie.'
		);
		
		$this->includeFullCourses = new BoolOption(
			OverviewOptionsEnum::INCLUDE_FULL_COURSES,
			'Inclusief volle cursussen',
			"Moeten volle cursussen worden weergeven?",
			$data[ OverviewOptionsEnum::INCLUDE_FULL_COURSES ] ?? null,
			false
		);
		
		$this->includePartiallyPassedCourses = new BoolOption(
			OverviewOptionsEnum::INCLUDE_PARTIALLY_PASSED_COURSES,
			'Gestart in verleden tonen',
			"Toon cursussen die al gestart zijn? (voor de ingestelde periode)",
			$data[ OverviewOptionsEnum::INCLUDE_PARTIALLY_PASSED_COURSES ] ?? null,
			false
		);

		$this->countsELearningAsStart = new BoolOption(
			OverviewOptionsEnum::E_LEARNING_COUNTS_AS_START,
			'E-learning als start',
			"Tellen e-learning dagdelen als start?",
			$data[ OverviewOptionsEnum::E_LEARNING_COUNTS_AS_START ] ?? null,
			true
		);

		$layout = [
			$showInfoCluster,
			new OptionGroup(
				null,
				'Cursus knop',
				'Instellingen voor de knop naar de detail pagina van de cursus.',
				[
					$this->showCourseButton,
					$this->courseButtonText
				]
			),
			new OptionGroup(
				null,
				'Cursus omschrijving',
				'Instellingen voor de omschrijving van de cursus.',
				[
					$this->showDescription,
					$this->maxLengthDescription
				]
			),
			new OptionGroup(
				null,
				'Dagdelen lijst',
				'Instellingen voor de lijst met dagdelen bij een cursus in de overzichten.',
				[
					$this->showDayPartList,
					$this->includeELearningDayParts,
					$this->showLocationDayPart,
					$this->showLabelsDayPart
				]
			),
			$this->noCourseText,
			$this->includeFullCourses,
			$this->includePartiallyPassedCourses,
			$this->countsELearningAsStart,
		];

		parent::__construct( $index, self::NAME, self::DESCRIPTION, $layout );
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showCode95Icon(): BoolOption {
		return $this->showCode95Icon;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showSoobIcon(): BoolOption {
		return $this->showSoobIcon;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showELearningIcon(): BoolOption {
		return $this->showELearningIcon;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showMoneyBackNotice(): BoolOption {
		return $this->showMoneyBackNotice;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showStartGuaranteeNotice(): BoolOption {
		return $this->showStartGuaranteeNotice;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showFinancialInfo(): BoolOption {
		return $this->showFinancialInfo;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showPrice(): BoolOption {
		return $this->showPrice;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showDayPartCount(): BoolOption {
		return $this->showDayPartCount;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showLabels(): BoolOption {
		return $this->showLabels;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showFirstLocation(): BoolOption {
		return $this->showFirstLocation;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showCourseButton(): BoolOption {
		return $this->showCourseButton;
	}

	/**
	 * @return StringOption<string>
	 */
	public function courseButtonText(): StringOption {
		return $this->courseButtonText;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showDescription(): BoolOption {
		return $this->showDescription;
	}

	/**
	 * @return IntOption<int>
	 */
	public function maxLengthDescription(): IntOption {
		return $this->maxLengthDescription;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showDayPartList(): BoolOption {
		return $this->showDayPartList;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function includeELearningDayParts(): BoolOption {
		return $this->includeELearningDayParts;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showLocationDayPart(): BoolOption {
		return $this->showLocationDayPart;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showLabelsDayPart(): BoolOption {
		return $this->showLabelsDayPart;
	}

	/**
	 * @return StringOption<string>
	 */
	public function noCourseText(): StringOption {
		return $this->noCourseText;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function includeFullCourses(): BoolOption {
		return $this->includeFullCourses;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function includePartiallyPassedCourses(): BoolOption {
		return $this->includePartiallyPassedCourses;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showAvailability(): BoolOption {
		return $this->showAvailability;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function countsELearningAsStart(): BoolOption {
		return $this->countsELearningAsStart;
	}

	public static function componentRegistryConstruct( ComponentRegistry $registry ) {
		return $registry->getComponent(CourseOptions::class)->overviewOptions();
	}
}