<?php

if (!function_exists('calla_elated_sidearea_options_map')) {
    function calla_elated_sidearea_options_map() {

        calla_elated_add_admin_page(
            array(
                'slug'  => '_side_area_page',
                'title' => esc_html__('Side Area', 'calla'),
                'icon'  => 'fa fa-indent'
            )
        );

        $side_area_panel = calla_elated_add_admin_panel(
            array(
                'title' => esc_html__('Side Area', 'calla'),
                'name'  => 'side_area',
                'page'  => '_side_area_page'
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'        => $side_area_panel,
                'type'          => 'select',
                'name'          => 'side_area_type',
                'default_value' => 'side-menu-slide-from-right',
                'label'         => esc_html__('Side Area Type', 'calla'),
                'description'   => esc_html__('Choose a type of Side Area', 'calla'),
                'options'       => array(
                    'side-menu-slide-from-right'       => esc_html__('Slide from Right Over Content', 'calla'),
                    'side-menu-slide-with-content'     => esc_html__('Slide from Right With Content', 'calla'),
                    'side-area-uncovered-from-content' => esc_html__('Side Area Uncovered from Content', 'calla'),
                ),
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'        => $side_area_panel,
                'type'          => 'text',
                'name'          => 'side_area_width',
                'default_value' => '',
                'label'         => esc_html__('Side Area Width', 'calla'),
                'description'   => esc_html__('Enter a width for Side Area (px or %). Default width: 405px.', 'calla'),
                'args'          => array(
                    'col_width' => 3,
                )
            )
        );

        $side_area_width_container = calla_elated_add_admin_container(
            array(
                'parent'     => $side_area_panel,
                'name'       => 'side_area_width_container',
                'dependency' => array(
                    'show' => array(
                        'side_area_type' => 'side-menu-slide-from-right',
                    )
                )
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'        => $side_area_width_container,
                'type'          => 'yesno',
                'name'          => 'side_area_fixed_content',
                'default_value' => 'no',
                'label'         => esc_html__('Side Area Fixed Content', 'calla'),
                'description'   => esc_html__('Make Content Fixed when Side Area is opened (not pushed aside by the Side Area)', 'calla'),
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'        => $side_area_width_container,
                'type'          => 'color',
                'name'          => 'side_area_content_overlay_color',
                'default_value' => '',
                'label'         => esc_html__('Content Overlay Background Color', 'calla'),
                'description'   => esc_html__('Choose a background color for a content overlay', 'calla'),
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'        => $side_area_width_container,
                'type'          => 'text',
                'name'          => 'side_area_content_overlay_opacity',
                'default_value' => '',
                'label'         => esc_html__('Content Overlay Background Transparency', 'calla'),
                'description'   => esc_html__('Choose a transparency for the content overlay background color (0 = fully transparent, 1 = opaque)', 'calla'),
                'args'          => array(
                    'col_width' => 3
                )
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'        => $side_area_panel,
                'type'          => 'select',
                'name'          => 'side_area_icon_source',
                'default_value' => 'icon_pack',
                'label'         => esc_html__('Select Side Area Icon Source', 'calla'),
                'description'   => esc_html__('Choose whether you would like to use icons from an icon pack or SVG icons', 'calla'),
                'options'       => calla_elated_get_icon_sources_array()
            )
        );

        $side_area_icon_pack_container = calla_elated_add_admin_container(
            array(
                'parent'     => $side_area_panel,
                'name'       => 'side_area_icon_pack_container',
                'dependency' => array(
                    'show' => array(
                        'side_area_icon_source' => 'icon_pack'
                    )
                )
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'        => $side_area_icon_pack_container,
                'type'          => 'select',
                'name'          => 'side_area_icon_pack',
                'default_value' => 'font_elegant',
                'label'         => esc_html__('Side Area Icon Pack', 'calla'),
                'description'   => esc_html__('Choose icon pack for Side Area icon', 'calla'),
                'options'       => calla_elated_icon_collections()->getIconCollectionsExclude(array('linea_icons', 'dripicons', 'simple_line_icons'))
            )
        );

        $side_area_svg_icons_container = calla_elated_add_admin_container(
            array(
                'parent'     => $side_area_panel,
                'name'       => 'side_area_svg_icons_container',
                'dependency' => array(
                    'show' => array(
                        'side_area_icon_source' => 'svg_path'
                    )
                )
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'      => $side_area_svg_icons_container,
                'type'        => 'textarea',
                'name'        => 'side_area_icon_svg_path',
                'label'       => esc_html__('Side Area Icon SVG Path', 'calla'),
                'description' => esc_html__('Enter your Side Area icon SVG path here. Please remove version and id attributes from your SVG path because of HTML validation', 'calla'),
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'      => $side_area_svg_icons_container,
                'type'        => 'textarea',
                'name'        => 'side_area_close_icon_svg_path',
                'label'       => esc_html__('Side Area Close Icon SVG Path', 'calla'),
                'description' => esc_html__('Enter your Side Area close icon SVG path here. Please remove version and id attributes from your SVG path because of HTML validation', 'calla'),
            )
        );

        $side_area_icon_style_group = calla_elated_add_admin_group(
            array(
                'parent'      => $side_area_panel,
                'name'        => 'side_area_icon_style_group',
                'title'       => esc_html__('Side Area Icon Style', 'calla'),
                'description' => esc_html__('Define styles for Side Area icon', 'calla')
            )
        );

        $side_area_icon_style_row1 = calla_elated_add_admin_row(
            array(
                'parent' => $side_area_icon_style_group,
                'name'   => 'side_area_icon_style_row1'
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent' => $side_area_icon_style_row1,
                'type'   => 'colorsimple',
                'name'   => 'side_area_icon_color',
                'label'  => esc_html__('Color', 'calla')
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent' => $side_area_icon_style_row1,
                'type'   => 'colorsimple',
                'name'   => 'side_area_icon_hover_color',
                'label'  => esc_html__('Hover Color', 'calla')
            )
        );

        $side_area_icon_style_row2 = calla_elated_add_admin_row(
            array(
                'parent' => $side_area_icon_style_group,
                'name'   => 'side_area_icon_style_row2',
                'next'   => true
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent' => $side_area_icon_style_row2,
                'type'   => 'colorsimple',
                'name'   => 'side_area_close_icon_color',
                'label'  => esc_html__('Close Icon Color', 'calla')
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent' => $side_area_icon_style_row2,
                'type'   => 'colorsimple',
                'name'   => 'side_area_close_icon_hover_color',
                'label'  => esc_html__('Close Icon Hover Color', 'calla')
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'      => $side_area_panel,
                'type'        => 'color',
                'name'        => 'side_area_background_color',
                'label'       => esc_html__('Background Color', 'calla'),
                'description' => esc_html__('Choose a background color for Side Area', 'calla')
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'      => $side_area_panel,
                'type'        => 'text',
                'name'        => 'side_area_padding',
                'label'       => esc_html__('Padding', 'calla'),
                'description' => esc_html__('Define padding for Side Area in format top right bottom left', 'calla'),
                'args'        => array(
                    'col_width' => 3
                )
            )
        );

        calla_elated_add_admin_field(
            array(
                'parent'        => $side_area_panel,
                'type'          => 'selectblank',
                'name'          => 'side_area_aligment',
                'default_value' => '',
                'label'         => esc_html__('Text Alignment', 'calla'),
                'description'   => esc_html__('Choose text alignment for side area', 'calla'),
                'options'       => array(
                    ''       => esc_html__('Default', 'calla'),
                    'left'   => esc_html__('Left', 'calla'),
                    'center' => esc_html__('Center', 'calla'),
                    'right'  => esc_html__('Right', 'calla')
                )
            )
        );
    }

    add_action('calla_elated_options_map', 'calla_elated_sidearea_options_map', 8);
}