<?php
pxl_add_custom_widget(
    array(
        'name' => 'pxl_image',
        'title' => esc_html__('Case Image', 'solarva' ),
        'icon' => 'eicon-image',
        'categories' => array('pxltheme-core'),
        'scripts' => array(
            'tilt',
            'pxl-tweenmax',
        ),
        'params' => array(
            'sections' => array(
                array(
                    'name' => 'tab_content',
                    'label' => esc_html__('Content', 'solarva' ),
                    'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
                    'controls' => array(
                        array(
                            'name' => 'source_type',
                            'label' => esc_html__('Source Type', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'options' => [
                                's_img' => 'Select Image',
                                'f_img' => 'Featured Image',
                            ],
                            'default' => 's_img',
                        ),
                        array(
                            'name' => 'image_type',
                            'label' => esc_html__('Image Type', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'options' => [
                                'img' => 'Image',
                                'bg' => 'Background',
                            ],
                            'default' => 'img',
                        ),
                        array(
                            'name' => 'img_size',
                            'label' => esc_html__('Image Size', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::TEXT,
                            'placeholder' => 'Ex: 200x100(WxH), thumbnail, medium...',
                            'condition' => [
                                'image_type' => ['img'],
                            ],
                        ),
                        array(
                            'name' => 'image',
                            'label' => esc_html__('Upload', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::MEDIA,
                            'condition' => [
                                'source_type' => ['s_img'],
                            ],
                        ),
                        array(
                            'name' => 'image_link',
                            'label' => esc_html__('Link', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::URL,
                        ),
                    ),
                ),


                array(
                    'name' => 'tab_content_overlay',
                    'label' => esc_html__('Overlay', 'solarva' ),
                    'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
                    'controls' => array(
                        array(
                            'name' => 'overlay',
                            'label' => esc_html__('Overlay', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SWITCHER,
                            'default' => '',
                        ),
                        array(
                            'name' => 'overlay_color',
                            'label' => esc_html__('Overlay Color', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::COLOR,
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--overlay' => 'background-color: {{VALUE}};'
                            ],
                            'condition' => [
                                'overlay!' => ''
                            ]
                        ),
                        array(
                            'name' => 'overlay_z_index',
                            'label' => esc_html__('Overlay Z Index', 'solarva'),
                            'type' => \Elementor\Controls_Manager::NUMBER,
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--overlay' => 'z-index: {{VALUE}};'
                            ],
                            'condition' => [
                                'overlay!' => ''
                            ]
                        ),
                    ),
                ),

                
                array(
                    'name' => 'tab_style_img',
                    'label' => esc_html__('General', 'solarva' ),
                    'tab' => \Elementor\Controls_Manager::TAB_STYLE,
                    'controls' => array(
                        array(
                            'name' => 'bg_option',
                            'label' => esc_html__('BACKGROUND', 'solarva'),
                            'type' => Elementor\Controls_Manager::HEADING,
                            'separator' => 'after',
                        ),
                        array(
                            'name' => 'background_position',
                            'label' => esc_html__('Background Position', 'solarva'),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'control_type' => 'responsive',
                            'options' => [
                                'left top' => esc_html__('Left Top', 'solarva'),
                                'left center' => esc_html__('Left Center', 'solarva'),
                                'left bottom' => esc_html__('Left Bottom', 'solarva'),
                                'center top' => esc_html__('Center Top', 'solarva'),
                                'center center' => esc_html__('Center Center', 'solarva'),
                                'center bottom' => esc_html__('Center Bottom', 'solarva'),
                                'right top' => esc_html__('Right Top', 'solarva'),
                                'right center' => esc_html__('Right Center', 'solarva'),
                                'right bottom' => esc_html__('Right Bottom', 'solarva'),
                            ],
                            'default' => 'center center',
                            'condition' => [
                                'image_type' => 'bg',
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'background-position: {{VALUE}}',
                            ],
                        ),
                        array(
                            'name' => 'background_repeat',
                            'label' => esc_html__('Background Repeat', 'solarva'),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'control_type' => 'responsive',
                            'options' => [
                                'no-repeat' => esc_html__('No Repeat', 'solarva'),
                                'repeat' => esc_html__('Repeat', 'solarva'),
                                'repeat-x' => esc_html__('Repeat-X', 'solarva'),
                                'repeat-y' => esc_html__('Repeat-Y', 'solarva'),
                            ],
                            'default' => 'no-repeat',
                            'condition' => [
                                'image_type' => 'bg',
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'background-repeat: {{VALUE}}',
                            ],
                        ),
                        array(
                            'name' => 'background_size',
                            'label' => esc_html__('Background Size', 'solarva'),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'control_type' => 'responsive',
                            'options' => [
                                'auto' => esc_html__('Auto', 'solarva'),
                                'cover' => esc_html__('Cover', 'solarva'),
                                'contain' => esc_html__('Contain', 'solarva'),
                            ],
                            'default' => 'cover',
                            'condition' => [
                                'image_type' => 'bg',
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'background-size: {{VALUE}}',
                            ],
                        ),
                        array(
                            'name' => 'background_attachment',
                            'label' => esc_html__('Background Attachment', 'solarva'),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'control_type' => 'responsive',
                            'options' => [
                                'scroll' => esc_html__('Scroll', 'solarva'),
                                'fixed' => esc_html__('Fixed', 'solarva'),
                                'local' => esc_html__('Local', 'solarva'),
                            ],
                            'default' => 'scroll',
                            'condition' => [
                                'image_type' => 'bg',
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'background-attachment: {{VALUE}}',
                            ],
                        ),
                        array(
                            'name' => 'divider5',
                            'type' => Elementor\Controls_Manager::DIVIDER,
                            'condition' => [
                                'image_type' => 'bg',
                            ],
                        ),
                        array(
                            'name' => 'normal',
                            'label' => esc_html__('NORMAL', 'solarva'),
                            'type' => Elementor\Controls_Manager::HEADING,
                            'separator' => 'after',
                        ),
                        array(
                            'name' => 'image_align',
                            'label' => esc_html__('Alignment', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::CHOOSE,
                            'control_type' => 'responsive',
                            'options' => [
                                'left' => [
                                    'title' => esc_html__('Left', 'solarva' ),
                                    'icon' => 'fa fa-align-left',
                                ],
                                'center' => [
                                    'title' => esc_html__('Center', 'solarva' ),
                                    'icon' => 'fa fa-align-center',
                                ],
                                'right' => [
                                    'title' => esc_html__('Right', 'solarva' ),
                                    'icon' => 'fa fa-align-right',
                                ],
                            ],
                            'condition' => [
                                'image_type' => 'img',
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--container' => 'text-align: {{VALUE}};',
                            ],
                        ),
                        array(
                            'name' => 'filters',
                            'label' => esc_html__('Filters', 'solarva'),
                            'type' => \Elementor\Group_Control_Css_Filter::get_type(),
                            'control_type' => 'group',
                            'selector' => '{{WRAPPER}} .pxl-image-single .pxl-item--image img, {{WRAPPER}} .pxl-image-single .pxl-item--bg' 
                        ),
                        array(
                            'name'         => 'box_shadow',
                            'label' => esc_html__( 'Box Shadow', 'solarva' ),
                            'type'         => \Elementor\Group_Control_Box_Shadow::get_type(),
                            'control_type' => 'group',
                            'selector'     => '{{WRAPPER}} .pxl-image-single img, {{WRAPPER}} .pxl-image-single .pxl-item--bg'
                        ),
                        array(
                            'name' => 'opacity',
                            'label' => esc_html__('Opacity', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SLIDER,
                            'control_type' => 'responsive',
                            'size_units' => [ '%' ],
                            'description' => esc_html__('Min: 0% and max: 100%', 'solarva'), 
                            'default'    => [
                                'unit' => '%'
                            ],
                            'range' => [
                                '%' => [
                                    'min' => 0,
                                    'max' => 100,
                                ],
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--image img,
                                {{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'opacity: {{SIZE}}{{UNIT}};',
                            ],
                        ),
                        array(
                            'name' => 'divider',
                            'type' => Elementor\Controls_Manager::DIVIDER,
                        ),
                        array(
                            'name' => 'dimension',
                            'label' => esc_html__('DIMENSION', 'solarva'),
                            'type' => Elementor\Controls_Manager::HEADING,
                            'separator' => 'after',
                        ),
                        array(
                            'name' => 'type_width',
                            'label' => esc_html__('Type Width', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::CHOOSE,
                            'control_type' => 'responsive',
                            'default' => 'auto',
                            'options' => [
                                'auto' =>  [
                                    'title' => esc_html__('Auto', 'solarva'),
                                    'icon' => 'eicon-shrink',
                                ],
                                '100%' =>  [
                                    'title' => esc_html__('100%', 'solarva'),
                                    'icon' => 'eicon-grow',
                                ],
                                '' =>  [
                                    'title' => esc_html__('Custom', 'solarva'),
                                    'icon' => 'eicon-grow',
                                ],
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--image img,
                                {{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'width: {{VALUE}}'
                            ],
                        ),
                        array(
                            'name' => 'btn_custom_width',
                            'label' => esc_html__('Width', 'solarva'),
                            'type' => \Elementor\Controls_Manager::SLIDER,
                            'size_units' => ['px', '%', 'rem', 'em', 'custom'],
                            'control_type' => 'responsive',
                            'range' => [
                                'px' => [
                                    'min' => 0,
                                    'max' => 1000,
                                ],
                            ],
                            'condition' => [
                                'type_width' => '',
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--image img,
                                {{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'width: {{SIZE}}{{UNIT}};',
                            ],
                        ),
                        array(
                            'name' => 'image_min_width',
                            'label' => esc_html__('Min Width', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SLIDER,
                            'size_units' => ['px', '%', 'rem', 'em', 'custom'],
                            'range' => [
                                'px' => [
                                    'min' => 0,
                                    'max' => 3000,
                                ],
                            ],
                            'control_type' => 'responsive',
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--image img,
                                {{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'min-width: {{SIZE}}{{UNIT}};',
                            ],
                        ),
                        array(
                            'name' => 'image_max_width',
                            'label' => esc_html__('Max Width', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SLIDER,
                            'size_units' => ['px', '%', 'rem', 'em', 'custom'],
                            'range' => [
                                'px' => [
                                    'min' => 0,
                                    'max' => 3000,
                                ],
                            ],
                            'control_type' => 'responsive',
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--image img,
                                {{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'max-width: {{SIZE}}{{UNIT}};',
                            ],
                        ),
                        array(
                            'name' => 'image_height',
                            'label' => esc_html__('Height', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SLIDER,
                            'unit' => ['px', '%'],  
                            'range' => [
                                'px' => [
                                    'min' => 0,
                                    'max' => 3000,
                                ],
                            ],
                            'separator' => 'before',
                            'control_type' => 'responsive',
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--image img,
                                {{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'height: {{SIZE}}{{UNIT}};',
                            ],
                        ),
                        array(
                            'name' => 'image_min_height',
                            'label' => esc_html__('Min Height', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SLIDER,
                            'size_units' => ['px', '%', 'rem', 'em', 'custom'],
                            'range' => [
                                'px' => [
                                    'min' => 0,
                                    'max' => 3000,
                                ],
                            ],
                            'control_type' => 'responsive',
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--image img,
                                {{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'min-height: {{SIZE}}{{UNIT}};',
                            ],
                        ),
                        array(
                            'name' => 'image_max_height',
                            'label' => esc_html__('Max Height', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SLIDER,
                            'size_units' => ['px', '%', 'rem', 'em', 'custom'],
                            'range' => [
                                'px' => [
                                    'min' => 0,
                                    'max' => 3000,
                                ],
                            ],
                            'control_type' => 'responsive',
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--image img,
                                {{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'max-height: {{SIZE}}{{UNIT}};',
                            ],
                        ),
                        array(
                            'name' => 'divider1',
                            'type' => Elementor\Controls_Manager::DIVIDER,
                        ),
                        array(
                            'name' => 'border_h',
                            'label' => esc_html__('BORDER', 'solarva'),
                            'type' => Elementor\Controls_Manager::HEADING,
                            'separator' => 'after',
                        ),
                        array(
                            'name' => 'border',
                            'label' => esc_html__( 'Border', 'solarva' ),
                            'type' => \Elementor\Group_Control_Border::get_type(),
                            'control_type' => 'group',
                            'selector' => '{{WRAPPER}} .pxl-image-single .pxl-item--image img,
                                {{WRAPPER}} .pxl-image-single .pxl-item--bg',
                        ),
                        array(
                            'name' => 'border_radius',
                            'label' => esc_html__('Border Radius', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::DIMENSIONS,
                            'size_units' => [ 'px' ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single .pxl-item--image img,
                                {{WRAPPER}} .pxl-image-single .pxl-item--bg' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                        ),
                        array(
                            'name' => 'divider2',
                            'type' => Elementor\Controls_Manager::DIVIDER,
                        ),
                        array(
                            'name' => 'animate_custom',
                            'label' => esc_html__('ANIMATION', 'solarva'),
                            'type' => Elementor\Controls_Manager::HEADING,
                            'separator' => 'after',
                        ),
                        array(
                            'name' => 'animation_custom',
                            'label' => esc_html__('Animation', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'options' => [
                                '' => esc_html__('None', 'solarva'),
                                'pxl-dynamic-resizing' => esc_html__('Dynamic Resizing', 'solarva'),
                            ],
                            'default' => '',
                            'description' => esc_html__('When using "Dynamic Resizing", there must be 2 image in the same section and on the same row.', 'solarva'),
                        ),
                    ),
                ),
                array(
                    'name' => 'tab_style_effect',
                    'label' => esc_html__('Effect', 'solarva' ),
                    'tab' => \Elementor\Controls_Manager::TAB_STYLE,
                    'controls' => array(
                        array(
                            'name' => 'img_effect',
                            'label' => esc_html__('Effect', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'options' => [
                                '' => 'None',
                                'pxl-image-effect1' => 'Zigzag',
                                'pxl-image-tilt' => 'Tilt',
                                'pxl-image-spin' => 'Spin',
                                'pxl-image-zoom' => 'Zoom 1',
                                'pxl-image-zoom2' => 'Zoom 2',
                                'pxl-image-bounce' => 'Bounce',
                                'slide-up-down' => 'Slide Up Down',
                                'slide-in-tr'    => 'Slide Top Right To Bottom Left' ,
                                'slide-in-bl'   => 'Slide Bottom Left To Top Right',
                                'slide-top-to-bottom' => 'Slide Top To Bottom ',
                                'pxl-image-effect2' => 'Slide Bottom To Top ',
                                'slide-right-to-left' => 'Slide Right To Left ',
                                'slide-left-to-right' => 'Slide Left To Right ',
                                'pxl-hover1' => 'ZoomIn',
                                'pxl-hover2' => 'ZoomOut',
                                'pxl-animation-round' => 'Round',
                                'pxl-parallax-hover' => 'Parallax Hover',
                                'pxl-parallax-scroll' => 'Parallax Scroll',
                                'pxl-parallax-background' => 'Parallax Background',
                                'pxl-dynamic-resizing' => 'Dynamic Resizing'
                            ],
                            'default' => '',
                        ),
                        array(
                            'name' => 'parallax_scroll_type',
                            'label' => esc_html__('Parallax Scroll Type', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SELECT,
                            'options' => [
                                'y' => 'Effect Y',
                                'x' => 'Effect X',
                                'z' => 'Effect Z',
                            ],
                            'default' => 'y',
                            'condition' => [
                                'img_effect' => 'pxl-parallax-scroll',
                            ],
                        ),
                        array(
                            'name' => 'parallax_scroll_value_x',
                            'label' => esc_html__('Parallax Value', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::TEXT,
                            'condition' => [
                                'img_effect' => 'pxl-parallax-scroll',
                            ],
                            'default' => '80',
                        ),
                        array(
                            'name' => 'parallax_value',
                            'label' => esc_html__('Parallax Value', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::TEXT,
                            'condition' => [
                                'img_effect' => 'pxl-parallax-hover',
                            ],
                            'default' => '40',
                        ),
                        array(
                            'name' => 'max_tilt',
                            'label' => esc_html__('Max Tilt', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::TEXT,
                            'condition' => [
                                'img_effect' => 'pxl-image-tilt',
                            ],
                            'default' => '10',
                        ),
                        array(
                            'name' => 'speed_tilt',
                            'label' => esc_html__('Speed Tilt', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::TEXT,
                            'condition' => [
                                'img_effect' => 'pxl-image-tilt',
                            ],
                            'default' => '400',
                        ),
                        array(
                            'name' => 'perspective_tilt',
                            'label' => esc_html__('Perspective Tilt', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::TEXT,
                            'condition' => [
                                'img_effect' => 'pxl-image-tilt',
                            ],
                            'default' => '1000',
                        ),
                        array(
                            'name' => 'speed_effect',
                            'label' => esc_html__('Speed', 'solarva' ),
                            'type' => \Elementor\Controls_Manager::SLIDER,
                            'control_type' => 'responsive',
                            'size_units' => [ 'px' ],
                            'range' => [
                                'px' => [
                                    'min' => 0,
                                    'max' => 100000,
                                ],
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .pxl-image-single, {{WRAPPER}} .pxl-image-single img' => 'animation-duration: {{SIZE}}ms;',
                            ],
                            'condition' => [
                                'img_effect!' => ['pxl-image-tilt','pxl-hover1','pxl-parallax-scroll'],
                            ],
                            'description' => 'Enter number, unit is ms.',
                        ),
                        array(
                            'name' => 'hide_parallax_sm',
                            'label' => esc_html__('Disable Parallax on Mobile <= 767px', 'solarva'),
                            'type' => \Elementor\Controls_Manager::SWITCHER,
                            'default' => 'false',
                            'condition' => [
                                'img_effect' => ['pxl-parallax-scroll'],
                            ], 
                        ),
                    ),
                ),
                solarva_widget_animation_settings(),
            ),
        ),
    ),
    solarva_get_class_widget_path()
);