<?php

namespace Elementor;


include get_template_directory() . '/elementor/' . 'contracts.php';


if (!defined('ABSPATH')) exit;


class TeamSwiper extends Widget_Base
{

    public function get_name()
    {
        return 'banta_team_swiper';
    }

    public function get_title()
    {
        return __('Team Carousel', TEXT_DOMAIN);
    }

    public function get_icon()
    {
        return 'eicon-carousel';
    }

    public function get_categories()
    {
        return ['jiawaz_theme'];
    }

    public function get_keywords()
    {
        return ['card', 'box', 'list', 'carousel', 'slider', 'team','swiper','member'];
    }


    protected function _register_controls()
    {
        // content tab
        $this->register_content_tab_query();
        $this->register_content_tab_carousel_controls();

        // style tab
        $this->register_style_tab_card_controls();
        $this->register_style_tab_carousel_controls();
    }


    // query
    protected function register_content_tab_query(){
        $this->start_controls_section(
            'query_section',
            [
                'label' => esc_html__('Query', TEXT_DOMAIN),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'count',
            [
                'label' => esc_html__( 'number', TEXT_DOMAIN ),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'default' => 9,
                'placeholder' => esc_html__( 'enter the number', TEXT_DOMAIN ),
            ]
        );

        $this->add_control(
            'orderby',
            [
                'type' => \Elementor\Controls_Manager::SELECT,
                'label' => esc_html__( 'order by', TEXT_DOMAIN ),
                'options' => [
                    'modified' => [
                        'title' => esc_html__( 'last update', TEXT_DOMAIN ),
                    ],
                    'newest' => [
                        'title' => esc_html__( 'newest', TEXT_DOMAIN ),
                    ],
                    'oldest' => [
                        'title' => esc_html__( 'oldest', TEXT_DOMAIN ),
                    ],
                    'rand' => [
                        'title' => esc_html__( 'random', TEXT_DOMAIN ),
                    ],
                ],
                'default' => 'newest',
            ]
        );
        $taxonomies = get_object_taxonomies('team', 'objects');
        unset($taxonomies['post_translations'], $taxonomies['post_format'], $taxonomies['language']);
        foreach ($taxonomies as $object) {
            if ($object !== 'post_translations' && $object !== 'post_format' && $object !== 'language'){
                $taxonomy = is_string($object) ? $object : $object->name;
                $categories = get_terms(array(
                    'taxonomy' => $taxonomy,
                    'hide_empty' => 0,
                ));
                $cat_array = array();
                foreach ($categories as $cat_id => $cat_name) {
                    $cat_array[$cat_name->term_id] = $cat_name->name;
                }
                @$this->add_control(
                    $taxonomy,
                    [
                        'label' => $taxonomy,
                        'type' => Controls_Manager::SELECT2,
                        'label_block' => true,
                        'multiple' => true,
                        'options' => $cat_array,
                    ]
                );
            }
        }

        $this->end_controls_section();
    }

    // carousel
    protected function register_content_tab_carousel_controls()
    {
        $this->start_controls_section(
            'section_swiper',
            [
                'label' => esc_html__('Carousel', TEXT_DOMAIN),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );

        // items
        $this->add_control(
            'carousel_items_heading',
            [
                'label' => esc_html__('Slides per view', TEXT_DOMAIN),
                'type' => Controls_Manager::HEADING,
                'separator' => 'before',

            ]
        );
        $this->add_control(
            'carousel_items',
            [
                'label' => esc_html__('desktop', TEXT_DOMAIN),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'default' => '3.5',
                'placeholder' => esc_html__('enter the number', TEXT_DOMAIN),

            ]
        );
        $this->add_control(
            'carousel_items_tablet',
            [
                'label' => esc_html__('tablet', TEXT_DOMAIN),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'default' => '2.5',
                'placeholder' => esc_html__('enter the number', TEXT_DOMAIN),

            ]
        );
        $this->add_control(
            'carousel_items_mobile',
            [
                'label' => esc_html__('mobile', TEXT_DOMAIN),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'default' => '1.2',
                'placeholder' => esc_html__('enter the number', TEXT_DOMAIN),

            ]
        );


        $this->add_control(
            'carousel_autoplay',
            [
                'label' => esc_html__('autoplay', TEXT_DOMAIN),
                'type' => \Elementor\Controls_Manager::SWITCHER,
                'label_on' => esc_html__('active', TEXT_DOMAIN),
                'label_off' => esc_html__('off', TEXT_DOMAIN),
                'return_value' => 'yes',
                'default' => 'no',
                'separator' => 'before',

            ]
        );

        $this->add_control(
            'carousel_autoplay_delay',
            [
                'label' => __('animation delay', TEXT_DOMAIN),
                'type' => Controls_Manager::NUMBER,
                'default' => 4000,
                'condition' => [
                    'carousel_autoplay' => 'yes'
                ]

            ]
        );

        $this->add_control(
            'carousel_smart_speed',
            [
                'label' => __('animation speed', TEXT_DOMAIN),
                'type' => Controls_Manager::NUMBER,
                'default' => 400,

            ]
        );

        $this->add_control(
            'carousel_center',
            [
                'label' => esc_html__('center mode', TEXT_DOMAIN),
                'type' => Controls_Manager::SWITCHER,
                'label_on' => esc_html__('active', TEXT_DOMAIN),
                'label_off' => esc_html__('off', TEXT_DOMAIN),
                'return_value' => 'yes',
                'default' => 'no',

            ]
        );

        $this->add_control(
            'carousel_loop',
            [
                'label' => esc_html__('infinite loop', TEXT_DOMAIN),
                'type' => Controls_Manager::SWITCHER,
                'label_on' => esc_html__('active', TEXT_DOMAIN),
                'label_off' => esc_html__('off', TEXT_DOMAIN),
                'return_value' => 'yes',
                'default' => 'no',
            ]
        );

        $this->add_control(
            'carousel_margin',
            [
                'label' => esc_html__('items margin', TEXT_DOMAIN),
                'type' => Controls_Manager::NUMBER,
                'default' => 16,
                'placeholder' => esc_html__('enter the value', TEXT_DOMAIN),

            ]
        );

        $this->add_control(
            'carousel_items_per_group',
            [
                'label' => esc_html__('Item to change', TEXT_DOMAIN),
                'type' => \Elementor\Controls_Manager::NUMBER,
                'default' => 1,
                'placeholder' => esc_html__('enter the number', TEXT_DOMAIN),

            ]
        );

        $this->end_controls_section();
    }



    // style box
    protected function register_style_tab_card_controls()
    {
        $this->start_controls_section(
            'section_card_style',
            [
                'label' => esc_html__('Card', TEXT_DOMAIN),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'card_style_heading',
            [
                'label' => esc_html__('Card', TEXT_DOMAIN),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $this->add_responsive_control(
            'card_padding',
            [
                'label' => esc_html__('padding', TEXT_DOMAIN),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors' => [
                    '{{WRAPPER}} .team-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
                ],
            ]
        );

        $this->start_controls_tabs(
            'card_style_tabs', [
                'separator' => 'before'
            ]
        );
        $this->start_controls_tab(
            'card_style_normal_tab',
            [
                'label' => esc_html__('normal', TEXT_DOMAIN),
            ]
        );
        $this->add_group_control(
            Group_Control_Border::get_type(),
            [
                'name' => 'card_border_type',
                'label' => esc_html__('border', TEXT_DOMAIN),
                'selector' => '{{WRAPPER}} .team-item',
            ]
        );
        $this->add_responsive_control(
            'card_border_radius',
            [
                'label' => esc_html__('border radius', TEXT_DOMAIN),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors' => [
                    '{{WRAPPER}} .team-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
                ],
            ]
        );


        $this->add_group_control(
            Group_Control_Background::get_type(),
            [
                'name' => 'card_bg',
                'types' => ['classic', 'gradient'],
                'selector' => '{{WRAPPER}} .team-item',
                'separator' => 'after'
            ]
        );
        $this->add_group_control(
            Group_Control_Box_Shadow::get_type(),
            [
                'name' => 'card_shadow',
                'selector' => '{{WRAPPER}} .team-item',
            ]
        );
        $this->end_controls_tab();

        $this->start_controls_tab(
            'card_style_hover_tab',
            [
                'label' => esc_html__('hover', TEXT_DOMAIN),
            ]
        );
        $this->add_group_control(
            Group_Control_Border::get_type(),
            [
                'name' => 'card_border_type_hover',
                'label' => esc_html__('border', TEXT_DOMAIN),
                'selector' => '{{WRAPPER}} .team-item:hover',
            ]
        );
        $this->add_responsive_control(
            'card_border_radius_hover',
            [
                'label' => esc_html__('border radius', TEXT_DOMAIN),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors' => [
                    '{{WRAPPER}} .team-item:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Background::get_type(),
            [
                'name' => 'card_bg_hover',
                'types' => ['classic', 'gradient'],
                'selector' => '{{WRAPPER}} .team-item:hover',
                'separator' => 'after'
            ]
        );
        $this->add_group_control(
            Group_Control_Box_Shadow::get_type(),
            [
                'name' => 'card_shadow_hover',
                'selector' => '{{WRAPPER}} .team-item:hover',
            ]
        );
        $this->end_controls_tab();
        $this->end_controls_tabs();



        $this->add_control(
            'divider_card_style',
            [
                'type' => \Elementor\Controls_Manager::DIVIDER,
            ]
        ); // divider
        $this->add_control(
            'card_style_image_heading',
            [
                'label' => esc_html__('Image', TEXT_DOMAIN),
                'type' => Controls_Manager::HEADING,
            ]
        );
        $this->add_responsive_control(
            'card_image_border_radius',
            [
                'label' => esc_html__('border radius', TEXT_DOMAIN),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors' => [
                    '{{WRAPPER}} .team-item img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Box_Shadow::get_type(),
            [
                'name' => 'card_image_shadow',
                'selector' => '{{WRAPPER}} .team-item img',
            ]
        );


        // content
        $this->add_control(
            'divider_image_style',
            [
                'type' => \Elementor\Controls_Manager::DIVIDER,
            ]
        ); // divider
        $this->add_control(
            'card_style_content_heading',
            [
                'label' => esc_html__('Content', TEXT_DOMAIN),
                'type' => Controls_Manager::HEADING,
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'card_name_typography',
                'label' => esc_html__( 'Name typography', TEXT_DOMAIN ),
                'selector' => '{{WRAPPER}} .team-item .name',
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'card_title_typography',
                'label' => esc_html__( 'Title typography', TEXT_DOMAIN ),
                'selector' => '{{WRAPPER}} .team-item .specialty',
            ]
        );

        $this->start_controls_tabs(
            'card_content_style_tabs', [
                'separator' => 'before'
            ]
        );
        $this->start_controls_tab(
            'card_content_style_normal_tabs',
            [
                'label' => esc_html__('normal', TEXT_DOMAIN),
            ]
        );
        $this->add_control(
            'card_content_bg_color',
            [
                'label' => esc_html__('content background color', TEXT_DOMAIN),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .team-item-overly' => 'background: {{VALUE}};',
                ],
            ]
        );
        $this->add_responsive_control(
            'card_content_padding',
            [
                'label' => esc_html__('padding', TEXT_DOMAIN),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors' => [
                    '{{WRAPPER}} .team-item-overly' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
                ],
            ]
        );
        $this->add_responsive_control(
            'card_content_radius',
            [
                'label' => esc_html__('border radius', TEXT_DOMAIN),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors' => [
                    '{{WRAPPER}} .team-item-overly' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
                ],
            ]
        );
        $this->add_control(
            'card_name_color',
            [
                'label' => esc_html__('Name color', TEXT_DOMAIN),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .team-item .name' => 'color: {{VALUE}};',
                ],
            ]
        );
        $this->add_control(
            'card_title_color',
            [
                'label' => esc_html__('Title color', TEXT_DOMAIN),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .team-item .specialty' => 'color: {{VALUE}};',
                ],
            ]
        );
        $this->end_controls_tab();

        $this->start_controls_tab(
            'card_content_style_hover_tabs',
            [
                'label' => esc_html__('normal', TEXT_DOMAIN),
            ]
        );
        $this->add_control(
            'card_content_bg_color_hover',
            [
                'label' => esc_html__('content background color', TEXT_DOMAIN),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .team-item:hover .team-item-overly' => 'background: {{VALUE}};',
                ],
            ]
        );
        $this->add_responsive_control(
            'card_content_padding_hover',
            [
                'label' => esc_html__('padding', TEXT_DOMAIN),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors' => [
                    '{{WRAPPER}} .team-item:hover .team-item-overly' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
                ],
            ]
        );
        $this->add_responsive_control(
            'card_content_radius_hover',
            [
                'label' => esc_html__('border radius', TEXT_DOMAIN),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors' => [
                    '{{WRAPPER}} .team-item:hover .team-item-overly' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
                ],
            ]
        );
        $this->add_control(
            'card_name_color_hover',
            [
                'label' => esc_html__('Name color', TEXT_DOMAIN),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .team-item:hover .name' => 'color: {{VALUE}};',
                ],
            ]
        );
        $this->add_control(
            'card_title_color_hover',
            [
                'label' => esc_html__('Title color', TEXT_DOMAIN),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .team-item:hover .specialty' => 'color: {{VALUE}};',
                ],
            ]
        );
        $this->end_controls_tab();
        $this->end_controls_tabs();








        $this->end_controls_section();
    }

    // style carousel
    protected function register_style_tab_carousel_controls()
    {
        $this->start_controls_section(
            'section_carousel_style',
            [
                'label' => esc_html__('Carousel', TEXT_DOMAIN),
                'tab' => Controls_Manager::TAB_STYLE,

            ]
        );

        // buttons backdrop
        $this->add_control(
            'carousel_arrows_backdrop_style_heading',
            [
                'label' => esc_html__('Arrows backdrop', TEXT_DOMAIN),
                'type' => Controls_Manager::HEADING,
            ]
        );

        $this->add_control(
            'carousel_arrows_backdrop_color',
            [
                'label' => esc_html__('color', TEXT_DOMAIN),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .swiper-backdrop-button.prev' => 'background: linear-gradient(to left, transparent,{{VALUE}});',
                    '{{WRAPPER}} .swiper-backdrop-button.next' => 'background: linear-gradient(to right, transparent,{{VALUE}});',
                ],
            ]
        );




        // nav
        $this->add_control(
            'carousel_nav_style_heading',
            [
                'label' => esc_html__('arrows', TEXT_DOMAIN),
                'type' => Controls_Manager::HEADING,
            ]
        );
        $this->add_responsive_control(
            'carousel_nav_width',
            [
                'label' => __('width', TEXT_DOMAIN),
                'type' => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem'],
                'range' => [
                    'px' => [
                        'min' => 1,
                        'max' => 200,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .custom-swiper-button-prev,{{WRAPPER}} .custom-swiper-button-next' => 'width: {{SIZE}}{{UNIT}}!important;',
                ],
            ]
        );
        $this->add_responsive_control(
            'carousel_nav_height',
            [
                'label' => __('height', TEXT_DOMAIN),
                'type' => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem'],
                'range' => [
                    'px' => [
                        'min' => 1,
                        'max' => 200,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .custom-swiper-button-prev,{{WRAPPER}} .custom-swiper-button-next' => 'height: {{SIZE}}{{UNIT}}!important;line-height: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_responsive_control(
            'carousel_nav_offset',
            [
                'label' => __('margin', TEXT_DOMAIN),
                'type' => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem'],
                'range' => [
                    'px' => [
                        'min' => -100,
                        'max' => 100,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .custom-swiper-button-next' => 'left: {{SIZE}}{{UNIT}}!important;',
                    '{{WRAPPER}} .custom-swiper-button-prev' => 'right: {{SIZE}}{{UNIT}}!important;',
                ],
            ]
        );
        $this->add_responsive_control(
            'carousel_arrow_size',
            [
                'label' => __('icon size', TEXT_DOMAIN),
                'type' => Controls_Manager::SLIDER,
                'size_units' => ['px', 'em', 'rem'],
                'range' => [
                    'px' => [
                        'min' => 0,
                        'max' => 100,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .custom-swiper-button-next,{{WRAPPER}} .custom-swiper-button-prev' => 'font-size: {{SIZE}}{{UNIT}}!important;',
                ],
            ]
        );



        $this->start_controls_tabs(
            'carousel_nav_style_tabs', [
                'separator' => 'before'
            ]
        );

        // nav normal tab
        $this->start_controls_tab(
            'carousel_nav_style_normal_tab',
            [
                'label' => esc_html__('normal', TEXT_DOMAIN),
            ]
        );
        $this->add_control(
            'carousel_nav_icon_color',
            [
                'label' => esc_html__('Icon color', TEXT_DOMAIN),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .custom-swiper-button-next,{{WRAPPER}} .custom-swiper-button-prev' => 'color: {{VALUE}};',
                ],
            ]
        );
        $this->add_control(
            'carousel_nav_bg_color',
            [
                'label' => esc_html__('background color', TEXT_DOMAIN),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .custom-swiper-button-prev,{{WRAPPER}} .custom-swiper-button-next' => 'background-color: {{VALUE}};',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Border::get_type(),
            [
                'name' => 'carousel_nav_border_type',
                'label' => esc_html__('border', TEXT_DOMAIN),
                'selector' => '{{WRAPPER}} .custom-swiper-button-prev.swiper-button-primary,{{WRAPPER}} .custom-swiper-button-next.swiper-button-primary',
            ]
        );
        $this->add_responsive_control(
            'carousel_nav_border_radius',
            [
                'label' => esc_html__('border radius', TEXT_DOMAIN),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors' => [
                    '{{WRAPPER}} .custom-swiper-button-prev,{{WRAPPER}} .custom-swiper-button-next' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Box_Shadow::get_type(),
            [
                'name' => 'carousel_nav_shadow',
                'selector' => '{{WRAPPER}} .custom-swiper-button-prev,{{WRAPPER}} .custom-swiper-button-next',
            ]
        );
        $this->end_controls_tab();

        // nav hover tab
        $this->start_controls_tab(
            'carousel_nav_style_hover_tab',
            [
                'label' => esc_html__('hover', TEXT_DOMAIN),
            ]
        );
        $this->add_control(
            'carousel_nav_icon_color_hover',
            [
                'label' => esc_html__('Icon color', TEXT_DOMAIN),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .custom-swiper-button-prev:hover,{{WRAPPER}} .custom-swiper-button-next:hover' => 'color: {{VALUE}};',
                ],
            ]
        );
        $this->add_control(
            'carousel_nav_bg_color_hover',
            [
                'label' => esc_html__('background color', TEXT_DOMAIN),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .custom-swiper-button-prev:hover,{{WRAPPER}} .custom-swiper-button-next:hover' => 'background-color: {{VALUE}};',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Border::get_type(),
            [
                'name' => 'carousel_nav_border_type_hover',
                'label' => esc_html__('border', TEXT_DOMAIN),
                'selector' => '{{WRAPPER}} .custom-swiper-button-prev.swiper-button-primary:hover,{{WRAPPER}} .custom-swiper-button-next.swiper-button-primary:hover',
            ]
        );
        $this->add_responsive_control(
            'carousel_nav_border_radius_hover',
            [
                'label' => esc_html__('border radius', TEXT_DOMAIN),
                'type' => Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors' => [
                    '{{WRAPPER}} .custom-swiper-button-prev:hover,{{WRAPPER}} .custom-swiper-button-next:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Box_Shadow::get_type(),
            [
                'name' => 'carousel_nav_shadow_hover',
                'selector' => '{{WRAPPER}} .custom-swiper-button-prev:hover,{{WRAPPER}} .custom-swiper-button-next:hover',
            ]
        );
        $this->end_controls_tab();
        $this->end_controls_tabs();


        $this->end_controls_tabs();
        $this->end_controls_section();
    }



    protected function renderQuery($settings):array{
        $order = "DESC";
        $orderBy = $settings['orderby'];
        if($orderBy == 'newest'){
            $orderBy = 'date';
        }
        if($orderBy == 'oldest'){
            $orderBy = 'date';
            $order = "ASC";
        }

        $args = array(
            'posts_per_page' => $settings['count'],
            'post_status' => 'publish',
            'post_type' => 'team',
            'orderby' => $orderBy,
            'order' => $order,
        );
        $taxonomies = get_object_taxonomies('team', 'objects');
        foreach ( $taxonomies as $object ) {
            if (! empty($settings[$object->name])) {
                $args['tax_query'] = array(
                    array(
                        'taxonomy' => $object->name,
                        'terms' => $settings[$object->name],
                    )
                );
            }
        }


        return $args;
    }

    protected function render()
    {

        $settings = $this->get_settings_for_display();
        $args = $this->renderQuery($settings);

        // swiper
        $itemsPerGroup = $settings['carousel_items_per_group'];
        $items = $settings['carousel_items'];
        $itemsTablet = $settings['carousel_items_tablet'];
        $itemsMobile = $settings['carousel_items_mobile'];
        $autoplay = $settings['carousel_autoplay'];
        $center = $settings['carousel_center'];
        $loop = $settings['carousel_loop'];
        $margin = $settings['carousel_margin'];
        $smartSpeed = $settings['carousel_smart_speed'];
        $autoplayDelay = $settings['carousel_autoplay_delay'];

        echo "<div class='swiper swiper-before-init products-swiper elementor-swiper buttons-backdrop-desktop' swiper-items-per-group='".$itemsPerGroup."' swiper-items='" . $items . "' swiper-items-tablet='" . $itemsTablet . "' swiper-items-mobile='" . $itemsMobile . "' swiper-autoplay='" . $autoplay . "' swiper-speed='" . $smartSpeed . "' swiper-autoplay-delay='" . $autoplayDelay . "' swiper-center='" . $center . "' swiper-loop='" . $loop . "' swiper-margin='" . $margin . "'>";

        // main swiper wrapper
        echo "<div class='swiper-wrapper'>";
        $query = new \WP_Query($args);
        while ($query->have_posts()): $query->the_post(); global $post;?>
            <div class="swiper-slide">
                <div class="team-item">
                    <?php if (has_post_thumbnail()): the_post_thumbnail('medium'); else:
                        echo "<img src='".esc_url( get_template_directory_uri() . '/images/person.webp' )."' alt='image'>"; endif;?>
                    <div class="team-item-overly">
                        <span class="name"><?php echo get_post_meta( get_the_ID(), TEXT_DOMAIN. '_name', true );?></span>
                        <span class="specialty"><?php echo get_post_meta( get_the_ID(), TEXT_DOMAIN. '_specialty', true );?></span>
                    </div>
                </div>
            </div>
        <?php endwhile; ?>
        <?php wp_reset_postdata();
        echo "</div>";

        // button navigations
        echo "<div class='swiper-backdrop-button prev'></div>";
        echo "<div class='swiper-backdrop-button next'></div>";
        echo "<div class='custom-swiper-button-prev swiper-button-primary'><i class='iconly-Arrow-Right'></i></div>";
        echo "<div class='custom-swiper-button-next swiper-button-primary'><i class='iconly-Arrow-Left'></i></div>";

        echo "<div class='swiper-spinner'></div>";

        echo "</div>";
    }


}

Plugin::instance()->widgets_manager->register_widget_type(new TeamSwiper());