<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

if (!defined('ABSPATH')) exit; // Exit if accessed directly


class Categorycarouseleleventhkaveh extends Widget_Base{

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

  public function get_title(){
    return esc_html__( 'Category Carousel Style Eleven', 'kavehTheme' );
  }

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

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentcategorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'showticategorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Show Title?', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SWITCHER,
          'yes' => esc_html__( 'Yes', 'kavehTheme' ),
          'no' => esc_html__( 'No', 'kavehTheme' ),
          'return_value' => 'yes',
          'default' => 'yes',
        ]
      );
      $this->add_control(
        'tagti1categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Title Tag', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => 'H2',
          'condition' => [
            'showticategorycarouseleleventhkaveh' => 'yes',
          ],
          'options' => [
            'H1'  => esc_html__( 'H1', 'kavehTheme' ),
            'H2' => esc_html__( 'H2', 'kavehTheme' ),
            'H3' => esc_html__( 'H3', 'kavehTheme' ),
            'H4' => esc_html__( 'H4', 'kavehTheme' ),
            'H5' => esc_html__( 'H5', 'kavehTheme' ),
            'H6' => esc_html__( 'H6', 'kavehTheme' ),
            'p' => esc_html__( 'p', 'kavehTheme' ),
            'div' => esc_html__( 'div', 'kavehTheme' ),
            'span' => esc_html__( 'span', 'kavehTheme' ),
          ],
        ]
      );
      $this->add_control(
        'widgticategorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Bold Title', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'condition' => [
            'showticategorycarouseleleventhkaveh' => 'yes',
          ],
          'default' => 'Categories',
  
        ]
      );
      $this->add_control(
        'wigti2categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Title', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'condition' => [
            'showticategorycarouseleleventhkaveh' => 'yes',
          ],
          'default' => 'Best Selling',
        ]
      );
      $this->add_control(
        'wigp2categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Description', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXTAREA,
          'condition' => [
            'showticategorycarouseleleventhkaveh' => 'yes',
          ],
          'default' => 'Always, being in a situation that we experience for the first time creates stress and anxiety in us; therefore, if we try to prepare ourselves for the situation we want to be in',
  
        ]
      );
      $repeater = new \Elementor\Repeater();
      $repeater->add_control(
        'img1categorycarouselkaveh',
        [
          'label' => esc_html__( 'Category Image', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::MEDIA,
          'default' => [
            'url' => \Elementor\Utils::get_placeholder_image_src(),
          ],
        ]
      );
      $repeater->add_control(
      'title1categorycarouseleleventhkaveh',
      [
        'label' => esc_html__( 'Title', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => 'iPhone Products',

      ]
    );
    $repeater->add_control(
      'tagheading1categorycarouseleleventhkaveh',
      [
        'label' => esc_html__( 'Title Tag', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'H2',
        'options' => [
          'H1'  => esc_html__( 'H1', 'kavehTheme' ),
          'H2' => esc_html__( 'H2', 'kavehTheme' ),
          'H3' => esc_html__( 'H3', 'kavehTheme' ),
          'H4' => esc_html__( 'H4', 'kavehTheme' ),
          'H5' => esc_html__( 'H5', 'kavehTheme' ),
          'H6' => esc_html__( 'H6', 'kavehTheme' ),
          'p' => esc_html__( 'p', 'kavehTheme' ),
          'div' => esc_html__( 'div', 'kavehTheme' ),
          'span' => esc_html__( 'span', 'kavehTheme' ),
        ],
      ]
    );
    $repeater->add_control(
      'linkcategorycarouseleleventhkaveh',
      [
        'label' => esc_html__( 'Link', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => '#',
      ]
    );
    $repeater->add_control(
      'imgbgcategorycarouseleleventhkaveh',
      [
        'label' => esc_html__( 'Box Background Image', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::MEDIA,
      ]
    );
    $repeater->add_control(
      'boxcolor1categorycarouseleleventhkaveh',
      [
        'label' => esc_html__( 'Box Background Color', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::COLOR,
      ]
    );
    $this->add_control(
      'listcategorycarouseleleventhkaveh',
      [
        'label' => esc_html__( 'Categories', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::REPEATER,
        'fields' => $repeater->get_controls(),
        'default' => [
          [
            'title1categorycarouseleleventhkaveh' => esc_html__( 'Title', 'kavehTheme' ),
            'linkcategorycarouseleleventhkaveh' => esc_html__( '#', 'kavehTheme' ),
          ],
      ]
      ]
    
    );

    
       $this->end_controls_section();
       $this->start_controls_section(
        'content3categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Carousel Settings', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'showarrowcategorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Show Arrows?', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SWITCHER,
          'yes' => esc_html__( 'Yes', 'kavehTheme' ),
          'no' => esc_html__( 'No', 'kavehTheme' ),
          'return_value' => 'yes',
          'default' => 'yes',
        ]
      );
      $this->add_control(
        'productcolumncategorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Number of Category Columns on Desktop', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::NUMBER,
          'min' => 0,
          'max' => 8,
          'step' => 1,
          'default' => 4,
      
        ]
      );
      $this->add_control(
        'productcolumn2categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Number of Category Columns on Tablet', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::NUMBER,
          'min' => 0,
          'max' => 5,
          'step' => 1,
          'default' => 3,
      
        ]
      );
      $this->add_control(
        'productcolumn3categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Number of Category Columns on Mobile', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::NUMBER,
          'min' => 0,
          'max' => 5,
          'step' => 1,
          'default' => 1,
      
        ]
      );
       $this->end_controls_section();
       $this->start_controls_section(
        'stylet_categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Title Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
          'condition' => [
            'showticategorycarouseleleventhkaveh' => 'yes',
          ],
        ]
      );
      $this->add_control(
        'textcolortbolcategorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Bold Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-three-heading .title b' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_control(
        'textcolortcategorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-three-heading .title' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titletyt_categorycarouseleleventhkaveh',
          'label' => esc_html__( 'Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-selling-products-three-heading .title',
        ]
      );
      $this->add_control(
        'textcolortpcategorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Description Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-three-heading .sub-title' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titletytp_categorycarouseleleventhkaveh',
          'label' => esc_html__( 'Description Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-selling-products-three-heading .sub-title',
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style2_categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Category Title Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'textcolor1categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Category Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-three-item .title' => 'color: {{VALUE}} !important;',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titlety1_categorycarouseleleventhkaveh',
          'label' => esc_html__( 'Category Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-selling-products-three-item .title',
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style3_categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Category Box Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'borderradiustcategorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-three-item::before' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'styleimag_categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Category Image Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'catimg1widthcategorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Category Image Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 300,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-three-item img' => 'width: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'catimg1height2categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Category Image Height', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 300,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-three-item img' => 'height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style3arr_categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Arrows Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'arrowcolor1categorycarouseleleventhkaveh',
        [
          'label' => esc_html__( 'Arrows Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'condition' => [
            'showarrowcategorycarouseleleventhkaveh' => 'yes',
          ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-three .swiper-button-next::after' => 'color: {{VALUE}} !important;',
            '{{WRAPPER}} .top-selling-products-three .swiper-button-prev::after' => 'color: {{VALUE}} !important;',

          ],
        ]
      );
      $this->end_controls_section();

        }
 

  protected function render(){
    $settings = $this->get_settings_for_display();
    $clsid = $this->get_id();
    ?>
    <section class="top-selling-products-three">
      <div class="container position-relative">
        <?php if("yes"===$settings['showticategorycarouseleleventhkaveh']){?>
        <!-- Start Heading -->
        <div class="top-selling-products-three-heading text-center w-100 mx-auto">
          <<?php echo  esc_attr($settings['tagti1categorycarouseleleventhkaveh']); ?> class="title">
            <b> <?php echo  esc_html($settings['widgticategorycarouseleleventhkaveh']); ?></b>
            <?php echo  esc_html($settings['wigti2categorycarouseleleventhkaveh']); ?>
          </<?php echo  esc_attr($settings['tagti1categorycarouseleleventhkaveh']); ?>>
          <div class="sub-title mb-0"> <?php echo  esc_html($settings['wigp2categorycarouseleleventhkaveh']); ?></div>
        </div>
        <!-- End Heading -->
        <?php } ?>
        <!-- Start Carousel -->
        <div class="swiper swiper-top-selling-products-three position-relative" data-swiper='{"watchSlidesProgress":true,"navigation":{"nextEl":".swiper-button-next","prevEl":".swiper-button-prev"},"breakpoints":{"320":{"slidesPerView":<?php echo  esc_html($settings['productcolumn3categorycarouseleleventhkaveh']); ?>,"spaceBetween":12},"400":{"slidesPerView":<?php echo  esc_html($settings['productcolumn3categorycarouseleleventhkaveh']); ?>,"spaceBetween":12},"500":{"slidesPerView":<?php echo  esc_html($settings['productcolumn2categorycarouseleleventhkaveh']); ?>,"spaceBetween":12},"768":{"slidesPerView":<?php echo  esc_html($settings['productcolumn2categorycarouseleleventhkaveh']); ?>,"spaceBetween":12},"992":{"slidesPerView":<?php echo  esc_html($settings['productcolumncategorycarouseleleventhkaveh']); ?>,"spaceBetween":16},"1200":{"slidesPerView":<?php echo  esc_html($settings['productcolumncategorycarouseleleventhkaveh']); ?>,"spaceBetween":40}}}'>
          <div class="swiper-wrapper">
            <?php
            $e=1;
            if ( $settings['listcategorycarouseleleventhkaveh'] ) {
            foreach (  $settings['listcategorycarouseleleventhkaveh'] as $item ) {
            ?>
            <!-- Start Slide -->
            <div class="swiper-slide">
              <div class="top-selling-products-three-item position-relative cate<?php echo $e;?>">
                <a href="<?php echo esc_html($item['linkcategorycarouseleleventhkaveh']); ?>" class="stretched-link" aria-label="category"></a>
                <img src="<?php echo esc_url($item['img1categorycarouselkaveh']['url']); ?>" alt="<?php echo esc_attr(\Elementor\Control_Media::get_image_alt( $item['img1categorycarouselkaveh'] )); ?>" width="223" height="291"
                  class="d-block ms-auto">
                <<?php echo  esc_attr($item['tagheading1categorycarouseleleventhkaveh']); ?> class="title mb-0 text-white"><?php echo  esc_html($item['title1categorycarouseleleventhkaveh']); ?></<?php echo  esc_attr($item['tagheading1categorycarouseleleventhkaveh']); ?>>
              </div>
            </div>
            <!-- End Slide -->
            <style>
              <?php echo '.cate'. $e ?>.top-selling-products-three-item::before  {
              background: url("<?php echo esc_url($item['imgbgcategorycarouseleleventhkaveh']['url']); ?>") 0 0 no-repeat;
              background-size: cover !important;
              background-color: <?php echo esc_attr($item['boxcolor1categorycarouseleleventhkaveh']); ?>;
              }
            </style>
            <?php 
            $e++;
            }
              }
            ?>
          </div>
          <?php if("yes"===$settings['showarrowcategorycarouseleleventhkaveh']){?>
          <!-- Start Button -->
          <div class="swiper-button-next w-auto h-auto top-0"></div>
          <div class="swiper-button-prev w-auto h-auto top-0"></div>
          <!-- End Button -->
          <?php } ?>
        </div>
        <!-- End Carousel -->
      </div>
    </section>
    
    <?php
  }


}
