<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Categorycarouseleighthkaveh extends Widget_Base{

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

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

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

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentcategorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'showticategorycarouseleighthkaveh',
        [
          '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(
        'showbeforetiategorycarouselsixthkaveh',
        [
          'label' => esc_html__( 'Show Image Before Title?', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SWITCHER,
          'yes' => esc_html__( 'Yes', 'kavehTheme' ),
          'no' => esc_html__( 'No', 'kavehTheme' ),
          'condition' => [
            'showticategorycarouseleighthkaveh' => 'yes',
          ],
          'return_value' => 'yes',
          'default' => 'yes',
        ]
      );
      $this->add_control(
        'imgbeforeticategorycarouselkaveh',
        [
          'label' => esc_html__( 'Image Before Title', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::MEDIA,
          'condition' => [
            'showbeforetiategorycarouselsixthkaveh' => 'yes',
            'showticategorycarouseleighthkaveh' => 'yes',
          ],
        ]
      );
      $this->add_control(
        'tagti1categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Title Tag', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => 'H2',
          'condition' => [
            'showticategorycarouseleighthkaveh' => '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(
        'widgticategorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Bold Title', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'condition' => [
            'showticategorycarouseleighthkaveh' => 'yes',
          ],
          'default' => 'Categories',
  
        ]
      );
      $this->add_control(
        'wigti2categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Title', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'condition' => [
            'showticategorycarouseleighthkaveh' => 'yes',
          ],
          'default' => 'Bestseller',
        ]
      );
      $this->add_control(
        'wigp2categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Description', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXTAREA,
          'condition' => [
            'showticategorycarouseleighthkaveh' => 'yes',
          ],
          'default' => 'Being in situations we experience for the first time always causes us stress and anxiety; therefore, if we try to prepare for the situations we want to be in beforehand,',
  
        ]
      );
      $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(
        'title2categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Subtitle', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'default' => 'Apple Iphone',
  
        ]
      );
      $repeater->add_control(
        'tagheading2categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Subtitle Tag', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => 'H4',
          '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(
      'title1categorycarouseleighthkaveh',
      [
        'label' => esc_html__( 'Title', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => 'iPhone Products',

      ]
    );
    $repeater->add_control(
      'tagheading1categorycarouseleighthkaveh',
      [
        '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(
      'linkcategorycarouseleighthkaveh',
      [
        'label' => esc_html__( 'Link', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => '#',
      ]
    );
    $repeater->add_control(
      'bgcolortbolcategorycarouseleighthkaveh',
      [
        'label' => esc_html__( 'Background Color', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::COLOR,
      ]
    );
    $this->add_control(
      'listcategorycarouseleighthkaveh',
      [
        'label' => esc_html__( 'Categories', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::REPEATER,
        'fields' => $repeater->get_controls(),
        'default' => [
          [
            'title1categorycarouseleighthkaveh' => esc_html__( 'Title', 'kavehTheme' ),
            'title2categorycarouseleighthkaveh' => esc_html__( 'Subtitle', 'kavehTheme' ),
            'linkcategorycarouseleighthkaveh' => esc_html__( '#', 'kavehTheme' ),
          ],
      ]
      ]
    
    );

    
       $this->end_controls_section();
       $this->start_controls_section(
        'content3categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Carousel Settings', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'showarrowcategorycarouseleighthkaveh',
        [
          '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(
        'productcolumncategorycarouseleighthkaveh',
        [
          '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(
        'productcolumn2categorycarouseleighthkaveh',
        [
          '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(
        'productcolumn3categorycarouseleighthkaveh',
        [
          '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_categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Title Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
          'condition' => [
            'showticategorycarouseleighthkaveh' => 'yes',
          ],
        ]
      );
      $this->add_control(
        'textcolortbolcategorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Bold Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-five-title b' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_control(
        'textcolortcategorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-five-title' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titletyt_categorycarouseleighthkaveh',
          'label' => esc_html__( 'Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .section-heading-five-title',
        ]
      );
      $this->add_control(
        'textcolortpcategorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Description Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-five p' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titletytp_categorycarouseleighthkaveh',
          'label' => esc_html__( 'Description Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .section-heading-five p',
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style2_categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Category Title Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'textcolor21categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Category Subtitle Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .our-characters-item .sup-title' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titlety2_categorycarouseleighthkaveh',
          'label' => esc_html__( 'Category Subtitle Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .our-characters-item .sup-title',
        ]
      );
      $this->add_control(
        'textcolor1categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Category Main Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .our-characters-item .title' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titlety1_categorycarouseleighthkaveh',
          'label' => esc_html__( 'Category Main Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .our-characters-item .title',
        ]
      );
      $this->add_control(
        'mgtop1categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Title Top Margin', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'selectors' => [ 
            '{{WRAPPER}} .our-characters-item .sup-title' => 'margin-top: {{SIZE}}{{UNIT}};',

          ],
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style3_categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Category Box Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'borderradiustcategorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [ 
            '{{WRAPPER}} .our-characters-item::before' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
            '{{WRAPPER}} .our-characters-item::after' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',

          ],
        ]
      );

      $this->end_controls_section();
      $this->start_controls_section(
        'style3arr_categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Arrow Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'arrowcolor1categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Arrow Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'condition' => [
            'showarrowcategorycarouseleighthkaveh' => 'yes',
          ],
          'selectors' => [
            '{{WRAPPER}} .swiper-button-fill .swiper-button-next::after' => 'color: {{VALUE}} !important;',
            '{{WRAPPER}}  .swiper-button-fill .swiper-button-prev::after' => 'color: {{VALUE}} !important;',

          ],
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'styleimag_categorycarouseleighthkaveh',
        [
          'label' => esc_html__( 'Category Image Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'catimg1widthcategorycarouseleighthkaveh',
        [
          '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}} .our-characters-item img' => 'width: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'catimg1height2categorycarouseleighthkaveh',
        [
          
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 300,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .our-characters-item img' => 'height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->end_controls_section();

        }
 

  protected function render(){
    $settings = $this->get_settings_for_display();
    $clsid = $this->get_id();
    ?>
<section class="our-characters my-100">
      <div class="container">
      <?php if("yes"===$settings['showticategorycarouseleighthkaveh']){?>
        <!-- Start Heading -->
        <div class="section-heading-five position-relative">
          <<?php echo  esc_attr($settings['tagti1categorycarouseleighthkaveh']); ?> class="section-heading-five-title">
            <b> <?php echo esc_html($settings['widgticategorycarouseleighthkaveh']); ?></b>
            <?php echo esc_html($settings['wigti2categorycarouseleighthkaveh']); ?>
          </<?php echo  esc_attr($settings['tagti1categorycarouseleighthkaveh']); ?>>
          <p class="mb-0"><?php echo esc_html($settings['wigp2categorycarouseleighthkaveh']); ?></p>
        </div>
        <!-- End Heading -->
        <?php } ?>   
        <div class="position-relative">
          <!-- Start Carousel -->
          <div class="swiper swiper-our-characters swiper-button-fill" data-swiper='{"watchSlidesProgress":true,"navigation":{"nextEl":".swiper-button-next","prevEl":".swiper-button-prev"},"breakpoints":{"320":{"slidesPerView":<?php echo  esc_html($settings['productcolumn3categorycarouseleighthkaveh']); ?>,"spaceBetween":20},"400":{"slidesPerView":<?php echo  esc_html($settings['productcolumn3categorycarouseleighthkaveh']); ?>,"spaceBetween":20},"576":{"slidesPerView":<?php echo  esc_html($settings['productcolumn2categorycarouseleighthkaveh']); ?>,"spaceBetween":20},"768":{"slidesPerView":<?php echo  esc_html($settings['productcolumn2categorycarouseleighthkaveh']); ?>,"spaceBetween":20},"992":{"slidesPerView":<?php echo  esc_html($settings['productcolumncategorycarouseleighthkaveh']); ?>,"spaceBetween":30}}}'>
            <div class="swiper-wrapper">
              <?php
              $e=1;
              if ( $settings['listcategorycarouseleighthkaveh'] ) {
              foreach (  $settings['listcategorycarouseleighthkaveh'] as $item ) {
              ?>
              <!-- Start Slide -->
              <div class="swiper-slide">
                <div class="our-characters-item position-relative text-center rg<?php echo $e;?>">
                  <a href="<?php echo esc_html($item['linkcategorycarouseleighthkaveh']); ?>" class="stretched-link" aria-label="our characters"></a>
                  <img src="<?php echo esc_url($item['img1categorycarouselkaveh']['url']); ?>" alt="<?php echo esc_attr(\Elementor\Control_Media::get_image_alt( $item['img1categorycarouselkaveh'] )); ?>" width="200" height="200" class="d-block mx-auto">
                  <<?php echo  esc_attr($item['tagheading2categorycarouseleighthkaveh']); ?> class="sup-title"><?php echo  esc_html($item['title2categorycarouseleighthkaveh']); ?></<?php echo  esc_attr($item['tagheading2categorycarouseleighthkaveh']); ?>>
                  <<?php echo  esc_attr($item['tagheading1categorycarouseleighthkaveh']); ?> class="title mb-0"><?php echo  esc_html($item['title1categorycarouseleighthkaveh']); ?></<?php echo  esc_attr($item['tagheading1categorycarouseleighthkaveh']); ?>>
                </div>
              </div>
              <!-- End Slide -->
              <style>
              <?php echo '.rg'. $e ?>.our-characters-item::before{
              background-image: -webkit-linear-gradient(top, <?php echo esc_attr($item['bgcolortbolcategorycarouseleighthkaveh']); ?> -71.81%, rgba(71, 79, 99, 0) 68.19%);
              background-image: -moz-linear-gradient(top, <?php echo esc_attr($item['bgcolortbolcategorycarouseleighthkaveh']); ?> -71.81%, rgba(71, 79, 99, 0) 68.19%);
              background-image: -o-linear-gradient(top, <?php echo esc_attr($item['bgcolortbolcategorycarouseleighthkaveh']); ?> -71.81%, rgba(71, 79, 99, 0) 68.19%);
              background-image: linear-gradient(180deg, <?php echo esc_attr($item['bgcolortbolcategorycarouseleighthkaveh']); ?> -71.81%, rgba(71, 79, 99, 0) 68.19%);
              } 
              </style>
              <?php 
              $e++;
              }
                }
              ?>
            </div>
            <?php if("yes"===$settings['showarrowcategorycarouseleighthkaveh']){?>
            <div class="swiper-button-next"></div>
            <div class="swiper-button-prev"></div>
            <?php } ?>
          </div>
          <!-- End Carousel -->
        </div>
      </div>
    </section>
  <style>
 <?php if("yes"===$settings['showbeforetiategorycarouselsixthkaveh']){?>
.section-heading-five::before, .section-heading-five::after {
    background: url("<?php echo esc_url($settings['imgbeforeticategorycarouselkaveh']['url']); ?>") 0 0 no-repeat;
    -webkit-background-size: contain !important;
    -moz-background-size: contain !important;
    -o-background-size: contain !important;
    background-size: contain !important;
}
<?php }else{?>
  .section-heading-five::before, .section-heading-five::after {
display: none !important;
}
.section-heading-five {
    padding-right: 25px;
}
<?php
} ?>
@media only screen and (max-width: 575px){
.best-category-item img {
    width: 123px !important;
}
}
  </style>
  
    <?php
  }


}
