<?php
$templates_df = ['0' => esc_html__('None', 'kaitex')];
$templates = $templates_df + kaitex_get_templates_option('page') ;
pxl_add_custom_widget(
    array(
        'name' => 'pxl_button',
        'title' => esc_html__('BR Button', 'kaitex' ),
        'icon' => 'eicon-button',
        'categories' => array('pxltheme-core'),
        'params' => array(
            'sections' => array(
                array(
                    'name' => 'section_content',
                    'label' => esc_html__('Content', 'kaitex' ),
                    'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
                    'controls' => array(
                        array(
                            'name' => 'pxl_icon',
                            'label' => esc_html__('Icon', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::ICONS,
                            'fa4compatibility' => 'icon',
                            'condition' => [
                                'btn_style' => 'button-icon btn-default',
                            ],
                        ),
                        array(
                            'name' => 'text',
                            'label' => esc_html__('Text', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::TEXT,
                            'default' => esc_html__('Click Here', 'kaitex'),
                        ),
                        array(
                            'name' => 'btn_action',
                            'label' => esc_html__('Action', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'default' => 'pxl-atc-link',
                            'options' => [
                                'pxl-atc-link' => esc_html__('Link', 'kaitex' ),
                                'pxl-atc-popup' => esc_html__('Popup', 'kaitex' ),
                            ],
                        ),
                        array(
                            'name' => 'link',
                            'label' => esc_html__('Link', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::URL,
                            'default' => [
                                'url' => '#',
                            ],
                            'condition' => [
                                'btn_action' => ['pxl-atc-link'],
                            ],
                        ),
                        array(
                            'name' => 'popup_template',
                            'label' => esc_html__('Select Popup Template', 'kaitex'),
                            'type' => 'select',
                            'options' => $templates,
                            'default' => 'df',
                            'description' => '<div>' . sprintf(esc_html__('Add new tab template: %sClick Here%s','kaitex'),'<a target="_blank" href="' . esc_url( admin_url( 'edit.php?post_type=pxl-template' ) ) . '">','</a>') . '</div>',
                            'condition' => [
                                'btn_action' => ['pxl-atc-popup'],
                            ],
                        ),
                        array(
                            'name' => 'align',
                            'label' => esc_html__('Alignment', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::CHOOSE,
                            'control_type' => 'responsive',
                            'options' => [
                                'left'    => [
                                    'title' => esc_html__('Left', 'kaitex' ),
                                    'icon' => 'fa fa-align-left',
                                ],
                                'center' => [
                                    'title' => esc_html__('Center', 'kaitex' ),
                                    'icon' => 'fa fa-align-center',
                                ],
                                'right' => [
                                    'title' => esc_html__('Right', 'kaitex' ),
                                    'icon' => 'fa fa-align-right',
                                ],
                                'justify' => [
                                    'title' => esc_html__('Justified', 'kaitex' ),
                                    'icon' => 'fa fa-align-justify',
                                ],
                            ],
                            'prefix_class' => 'elementor-align-',
                            'default' => '',
                            'selectors'         => [
                                '{{WRAPPER}} .pxl-button' => 'text-align: {{VALUE}}',
                            ],
                        ),
                        array(
                            'name' => 'btn_style',
                            'label' => esc_html__('Style', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'options' => [
                                'btn btn-default' => esc_html__('Default', 'kaitex' ),
                                'button-icon btn-default' => esc_html__('Icon', 'kaitex' ),
                            ],
                            'default' => 'btn btn-default',
                        ),
                    ),
                ),
                array(
                    'name' => 'section_style_button',
                    'label' => esc_html__('Button Normal', 'kaitex' ),
                    'tab' => \Elementor\Controls_Manager::TAB_STYLE,
                    'controls' => array(
                        array(
                            'name'  => 'icon_size',
                            'label' => esc_html__( 'Icon Size', 'kaitex' ),
                            'type'  => 'slider',
                            'size_units' => [ 'px', '%', 'vw', 'vh' ],
                            'range' => [
                                '%' => [
                                    'min' => 0,
                                    'max' => 100,
                                ],
                                'px' => [
                                    'min' => 0,
                                    'max' => 3000,
                                ],
                                'vw' => [
                                    'min' => 0,
                                    'max' => 3000,
                                ],
                                'vh' => [
                                    'min' => 0,
                                    'max' => 3000,
                                ],
                            ],
                            'control_type' => 'responsive',
                            'condition' => ['btn_style' => 'button-icon btn-default'],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button i' => 'font-size: {{SIZE}}{{UNIT}};',
                                '{{WRAPPER}} .pxl-button svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
                            ],
                        ),
                        array(
                            'name' => 'icon_color',
                            'label' => esc_html__('Icon Color', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::COLOR,
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button i' => 'color: {{VALUE}};',
                                '{{WRAPPER}} .pxl-button svg path' => 'fill: {{VALUE}};',
                            ],
                            'condition' => ['btn_style' => 'button-icon btn-default'],
                        ),
                        array(
                            'name' => 'text_padding',
                            'label' => esc_html__('Text Padding', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::DIMENSIONS,
                            'size_units' => [ 'px', '%', 'vw', 'vh' ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                            'control_type' => 'responsive',
                            'condition' => ['btn_style' => 'button-icon btn-default'],
                        ),
                        array(
                            'name' => 'btn_typography',
                            'label' => esc_html__( 'Typography', 'kaitex' ),
                            'type' => \Elementor\Group_Control_Typography::get_type(),
                            'control_type' => 'group',
                            'selector' => '{{WRAPPER}} .pxl-button a',
                        ),
                        array(
                            'name'         => 'btn_box_shadow',
                            'label' => esc_html__( 'Box Shadow', 'kaitex' ),
                            'type'         => \Elementor\Group_Control_Box_Shadow::get_type(),
                            'control_type' => 'group',
                            'selector'     => '{{WRAPPER}} .pxl-button a'
                        ),
                        array(
                            'name' => 'btn_padding',
                            'label' => esc_html__('Padding', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::DIMENSIONS,
                            'size_units' => [ 'px', '%', 'vw', 'vh' ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                            'control_type' => 'responsive',
                        ),
                        array(
                            'name' => 'btn_margin',
                            'label' => esc_html__('Margin', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::DIMENSIONS,
                            'size_units' => [ 'px', '%', 'vw', 'vh' ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                            'control_type' => 'responsive',
                        ),
                        array(
                            'name' => 'button_min_width',
                            'label' => esc_html__( 'Min Width', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::SLIDER,
                            'control_type' => 'responsive',
                            'size_units' => [ 'px', '%' ],
                            'default' => [
                                'unit' => 'px',
                            ],
                            'range' => [
                                '%' => [
                                    'min' => 0,
                                    'max' => 100,
                                ],
                                'px' => [
                                    'min' => 0,
                                    'max' => 3000,
                                ],
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a' => 'min-width: {{SIZE}}{{UNIT}};',
                            ],
                            'condition' => ['btn_style' => 'btn btn-default'],
                        ),
                        array(
                            'name' => 'btn_width',
                            'label' => esc_html__('Button Width', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::CHOOSE,
                            'control_type' => 'responsive',
                            'options' => [
                                '100%' => [
                                    'title' => esc_html__('100%', 'kaitex' ),
                                    'icon' => 'eicon-text-align-justify',
                                ],
                                'auto' => [
                                    'title' => esc_html__('Auto', 'kaitex' ),
                                    'icon' => 'eicon-h-align-stretch',
                                ],
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a' => 'width: {{VALUE}};',
                            ],
                            'condition' => ['btn_style' => 'btn btn-default'],
                        ),
                        array(
                            'name' => 'button_border_type',
                            'label' => esc_html__( 'Border Type', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'options' => [
                                '' => esc_html__( 'Default', 'kaitex' ),
                                'solid' => esc_html__( 'Solid', 'kaitex' ),
                                'double' => esc_html__( 'Double', 'kaitex' ),
                                'dotted' => esc_html__( 'Dotted', 'kaitex' ),
                                'dashed' => esc_html__( 'Dashed', 'kaitex' ),
                                'groove' => esc_html__( 'Groove', 'kaitex' ),
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a' => 'border-style: {{VALUE}};',
                            ],
                        ),
                        array(
                            'name' => 'button_border_width',
                            'label' => esc_html__( 'Border Width', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                            'condition' => [
                                'button_border_type!' => '',
                            ],
                            'responsive' => true,
                        ),
                        array(
                            'name' => 'button_border_color',
                            'label' => esc_html__('Border Color', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::COLOR,
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a' => 'border-color: {{VALUE}};',
                            ],
                            'condition' => [
                                'button_border_type!' => '',
                            ],
                        ),
                        array(
                            'name' => 'button_border_radius',
                            'label' => esc_html__('Border Radius', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::DIMENSIONS,
                            'control_type' => 'responsive',
                            'size_units' => [ 'px', '%' ],
                            'default' => [
                                'unit' => '%',
                            ],
                            'range' => [
                                '%' => [
                                    'min' => 0,
                                    'max' => 100,
                                ],
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                        ),
                        array(
                            'name' => 'color',
                            'label' => esc_html__('Color', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::COLOR,
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a' => 'color: {{VALUE}};',
                            ],
                            'separator' => 'before',
                        ),
                        array(
                            'name' => 'btn_bg_color',
                            'label' => esc_html__('Background Color', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::COLOR,
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a' => 'background-color: {{VALUE}};',
                            ],
                        ),
                        array(
                            'name' => 'dot_color',
                            'label' => esc_html__('Dot Color', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::COLOR,
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a:before' => 'background-color: {{VALUE}};',
                            ],
                            'condition' => ['btn_style' => 'btn btn-default'],
                        ),
                    ),
                ),
                array(
                    'name' => 'section_style_button_hover',
                    'label' => esc_html__('Button Hover', 'kaitex' ),
                    'tab' => \Elementor\Controls_Manager::TAB_STYLE,
                    'controls' => array(
                        array(
                            'name' => 'button_effect',
                            'label' => esc_html__('Effect', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'options' => [
                                '' => esc_html__('None', 'kaitex' ),
                                'pxl-jump' => esc_html__('Jump', 'kaitex' ),
                                'pxl-upscale' => esc_html__('Upscale', 'kaitex' ),
                                'pxl-spin' => esc_html__('Spin', 'kaitex' ),
                                'pxl-skew' => esc_html__('Skew', 'kaitex' ),
                                'pxl-squash' => esc_html__('Squash', 'kaitex' ),
                                'pxl-leap' => esc_html__('Leap', 'kaitex' ),
                                'pxl-fade' => esc_html__('Fade', 'kaitex' ),
                                'pxl-sheen' => esc_html__('Sheen', 'kaitex' ),
                                'pxl-xspin' => esc_html__('Xspin', 'kaitex' ),
                                'pxl-pop' => esc_html__('Pop', 'kaitex' ),
                            ],
                            'default' => '',
                        ),
                        array(
                            'name' => 'icon_color_hover',
                            'label' => esc_html__('Icon Color', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::COLOR,
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a:hover i' => 'color: {{VALUE}};',
                                '{{WRAPPER}} .pxl-button a:hover svg path' => 'fill: {{VALUE}};',
                            ],
                            'condition' => ['btn_style' => 'button-icon btn-default'],
                        ),
                        array(
                            'name' => 'color_hover',
                            'label' => esc_html__('Color', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::COLOR,
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a:hover' => 'color: {{VALUE}};',
                            ],
                            'separator' => 'before',
                        ),
                        array(
                            'name' => 'btn_bg_color_hover',
                            'label' => esc_html__('Background Color', 'kaitex' ),
                            'type' => \Elementor\Controls_Manager::COLOR,
                            'selectors' => [
                                '{{WRAPPER}} .pxl-button a:hover' => 'background-color: {{VALUE}};',
                            ],
                        ),
                        array(
                            'name'         => 'btn_box_shadow_hover',
                            'label'        => esc_html__( 'Box Shadow', 'kaitex' ),
                            'type'         => \Elementor\Group_Control_Box_Shadow::get_type(),
                            'control_type' => 'group',
                            'selector'     => '{{WRAPPER}} .pxl-button a:hover',
                        ),
                    ),
                ),
                kaitex_widget_animation_settings()
            ),
        ),
    ),
    kaitex_get_class_widget_path()
);