<?php

namespace AutoAdmin\Bundle\BrickBuilder\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ColumnPatternType extends AbstractType
{
    const PATTERN_COL1_100 = '100';

    const PATTERN_COL2_50_50 = '50_50';
    const PATTERN_COL2_33_66 = '33_66';
    const PATTERN_COL2_25_75 = '25_75';
    const PATTERN_COL2_66_33 = '66_33';
    const PATTERN_COL2_75_25 = '75_25';

    const PATTERN_COL3_33_33_33 = '33_33_33';
    const PATTERN_COL3_50_25_25 = '50_25_25';
    const PATTERN_COL3_25_50_25 = '25_50_25';
    const PATTERN_COL3_25_25_50 = '25_25_50';
    const PATTERN_COL3_20_60_20 = '20_60_20';

    const PATTERN_COL4_25_25_25_25 = '25_25_25_25';

    const PATTERN_COL5_20_20_20_20_20 = '20_20_20_20_20';

    const PATTERN_COL6_16_16_16_16_16_16 = '16_16_16_16_16_16';

    public static function getChoices(): array
    {
        return [
            '1 col. (1/1)' => self::PATTERN_COL1_100,
            '2 col. (1/2 + 1/2)' => self::PATTERN_COL2_50_50,
            '2 col. (1/3 + 2/3)' => self::PATTERN_COL2_33_66,
            '2 col. (1/4 + 3/4)' => self::PATTERN_COL2_25_75,
            '2 col. (2/3 + 1/3)' => self::PATTERN_COL2_66_33,
            '2 col. (3/4 + 1/4)' => self::PATTERN_COL2_75_25,
            '3 col. (1/3 + 1/3 + 1/3)' => self::PATTERN_COL3_33_33_33,
            '3 col. (1/2 + 1/4 + 1/4)' => self::PATTERN_COL3_50_25_25,
            '3 col. (1/4 + 1/2 + 1/4)' => self::PATTERN_COL3_25_50_25,
            '3 col. (1/4 + 1/4 + 1/2)' => self::PATTERN_COL3_25_25_50,
            '3 col. (1/6 + 4/6 + 1/6)' => self::PATTERN_COL3_20_60_20,
            '4 col. (1/4 + 1/4 + 1/4 + 1/4)' => self::PATTERN_COL4_25_25_25_25,
            '5 col. (1/5 + 1/5 + 1/5 + 1/5 + 1/5)' => self::PATTERN_COL5_20_20_20_20_20,
            '6 col. (1/6 + 1/6 + 1/6 + 1/6 + 1/6 + 1/6)' => self::PATTERN_COL6_16_16_16_16_16_16,
        ];
    }

    public static function getImages(): array
    {
        return [
            self::PATTERN_COL1_100 => '/bundles/autoadmin/back/images/builder/column_pattern/col1_100.png',
            self::PATTERN_COL2_50_50 => '/bundles/autoadmin/back/images/builder/column_pattern/col2_50_50.png',
            self::PATTERN_COL2_33_66 => '/bundles/autoadmin/back/images/builder/column_pattern/col2_33_66.png',
            self::PATTERN_COL2_25_75 => '/bundles/autoadmin/back/images/builder/column_pattern/col2_25_75.png',
            self::PATTERN_COL2_66_33 => '/bundles/autoadmin/back/images/builder/column_pattern/col2_66_33.png',
            self::PATTERN_COL2_75_25 => '/bundles/autoadmin/back/images/builder/column_pattern/col2_75_25.png',
            self::PATTERN_COL3_33_33_33 => '/bundles/autoadmin/back/images/builder/column_pattern/col3_33_33_33.png',
            self::PATTERN_COL3_50_25_25 => '/bundles/autoadmin/back/images/builder/column_pattern/col3_50_25_25.png',
            self::PATTERN_COL3_25_50_25 => '/bundles/autoadmin/back/images/builder/column_pattern/col3_25_50_25.png',
            self::PATTERN_COL3_25_25_50 => '/bundles/autoadmin/back/images/builder/column_pattern/col3_25_25_50.png',
            self::PATTERN_COL3_20_60_20 => '/bundles/autoadmin/back/images/builder/column_pattern/col3_20_60_20.png',
            self::PATTERN_COL4_25_25_25_25 => '/bundles/autoadmin/back/images/builder/column_pattern/col4_25_25_25_25.png',
            self::PATTERN_COL5_20_20_20_20_20 => '/bundles/autoadmin/back/images/builder/column_pattern/col5_20_20_20_20_20.png',
            self::PATTERN_COL6_16_16_16_16_16_16 => '/bundles/autoadmin/back/images/builder/column_pattern/col6_16_16_16_16_16_16.png',
        ];
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        parent::configureOptions($resolver);

        $resolver->setDefault('placeholder', 'auto');
        $resolver->setDefault('empty_value', null);
        $resolver->setDefault('choices', self::getChoices());
    }

    public function getParent(): string
    {
        return ChoiceType::class;
    }
}
