<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Categorycarouseltwentyninethstkaveh extends Widget_Base{

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

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

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

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );



      $repeater = new \Elementor\Repeater();
      $repeater->add_control(
        'img1categorycarouselninekaveh',
        [
          'label' => esc_html__( 'Category Image', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::MEDIA,
        ]
      );

      $repeater->add_control(
        'beftitle1categorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Pre Title', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'default' => esc_html__( 'Let\'s Go', 'kavehTheme' ),
  
        ]
      );
      $repeater->add_control(
        'beftagheading1categorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Pre Title Tag', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => 'div',
          '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(
      'title1categorycarouseltwentyninethstkaveh',
      [
        'label' => esc_html__( 'Title', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => esc_html__( 'Historical Books', 'kavehTheme' ),

      ]
    );
    $repeater->add_control(
      'tagheading1categorycarouseltwentyninethstkaveh',
      [
        'label' => esc_html__( 'Title Tag', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'div',
        '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(
      'numboxcategorycarouseltwentyninethstkaveh',
      [
        'label' => esc_html__( 'Number Inside Box', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => ' 243 ',

      ]
    );

    $repeater->add_control(
      'iconboxcategorycarouseltwentyninethstkaveh',
      [
        'label' => esc_html__('Icon', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::ICONS,
        'skin' => 'inline',
        'exclude_inline_options' => ['svg'],
        'default' => [
          'value' => 'iconly-Arrow-Left-2',
        ],
      ]
    );

    $repeater->add_control(
      'linkcategorycarouseltwentyninethstkaveh',
      [
        'label' => esc_html__( 'Link', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => '#',
      ]
    );

    $repeater->add_control(
      'bgcolorcategorycarouseltwentyninethstkaveh',
      [
        'label' => esc_html__( 'First Background Color of Image', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
          '{{WRAPPER}} {{CURRENT_ITEM}} .image' => 'background-color: {{VALUE}};',
        ],
      ]
    );
    
    $repeater->add_control(
      'bgcolor2categorycarouseltwentyninethstkaveh',
      [
        'label' => esc_html__( 'Second Background Color of Image', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
          '{{WRAPPER}} {{CURRENT_ITEM}} .image::before' => 'background-color: {{VALUE}};',
        ],
      ]
    );

    $this->add_control(
      'listcategorycarouseltwentyninethstkaveh',
      [
        'label' => esc_html__( 'Categories', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::REPEATER,
        'fields' => $repeater->get_controls(),
        'default' => [
          [
            'title1categorycarouseltwentyninethstkaveh' => esc_html__( 'Title', 'kavehTheme' ),
            'title2categorycarouseltwentyninethstkaveh' => esc_html__( 'Subtitle', 'kavehTheme' ),
            'linkcategorycarouseltwentyninethstkaveh' => esc_html__( '#', 'kavehTheme' ),
          ],
      ]
      ]
    
    );
    $this->end_controls_section();




//////////////////////////// style ///////////////////////////////


      $this->start_controls_section(
        'styleo_categorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Category Title Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'befhead1tcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Category Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .category-book .title' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'befhead1_categorycarouseltwentyninethstkaveh',
          'label' => esc_html__( 'Category Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .category-book .title',
        ]
      );
      $this->add_control(
        'befhead2tcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Second Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .category-book .btn-count .text-view' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'befhead2_categorycarouseltwentyninethstkaveh',
          'label' => esc_html__( 'Second Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .category-book .btn-count .text-view',
        ]
      );
      $this->add_control(
        'befheadptcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Number Box Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .category-book .btn-count .count' => 'color: {{VALUE}}',
          ],
        ]
      );

      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'befheadp_categorycarouseltwentyninethstkaveh',
          'label' => esc_html__( 'Number Box Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .category-book .btn-count .count',
        ]
      );

      $this->add_control(
        'backcolornumheadptcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Number Box Background', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .category-book .btn-count .count' => 'background-color: {{VALUE}}',
          ],
        ]
      );

      $this->add_control(
        'backnumheadpt_width_categorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Number Box Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px'],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 200,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .category-book .btn-count .count' => 'width: {{SIZE}}{{UNIT}};',
          ],
        ]
      );

      $this->add_control(
        'backnumheadpt_height_categorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Number Box Height', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px'],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 200,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .category-book .btn-count .count' => 'height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );

      $this->add_responsive_control(
        'backnumheadpt_padding_categorycarouseltwentyninethstkaveh',
        [
            'label' => esc_html__('Number Box Padding', 'kavehTheme'),
            'type' => \Elementor\Controls_Manager::DIMENSIONS,
            'size_units' => ['px'],
            'selectors' => [
                '{{WRAPPER}} .category-book .btn-count .count' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
            ],
        ]
      );

      $this->add_responsive_control(
        'backnumheadpt_borderradius_categorycarouseltwentyninethstkaveh',
        [
            'label' => esc_html__('Number Box Border Radius', 'kavehTheme'),
            'type' => \Elementor\Controls_Manager::DIMENSIONS,
            'size_units' => ['px'],
            'selectors' => [
                '{{WRAPPER}} .category-book .btn-count .count' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
            ],
        ]
      );

      $this->end_controls_section();

      $this->start_controls_section(
        'style6_categorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Category Icon Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );

      $this->add_control(
        'iconcolorcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Icon Box Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .icononlyone' => 'color: {{VALUE}}',
          ],
        ]
      );

      $this->add_control(
        'iconsizecategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Icon Size', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 100,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .icononlyone' => 'font-size: {{SIZE}}{{UNIT}};',
          ],
        ]
      );

      $this->add_control(
        'iconbgcolorcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Icon Box Background', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .icononlyone' => 'background-color: {{VALUE}}',
          ],
        ]
      );

      $this->add_group_control(
        \Elementor\Group_Control_Border::get_type(),
        [
          'name' => 'iconbgbordercategorycarouseltwentyninethstkaveh',
          'label' => esc_html__( 'Border', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .icononlyone',
        ]
      );

      $this->add_responsive_control(
        'iconbgpaddingcategorycarouseltwentyninethstkaveh',
        [
            'label' => esc_html__('Number Box Padding', 'kavehTheme'),
            'type' => \Elementor\Controls_Manager::DIMENSIONS,
            'size_units' => ['px'],
            'selectors' => [
                '{{WRAPPER}} .icononlyone' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
            ],
        ]
      );

      $this->add_responsive_control(
        'iconbgborderradiuscategorycarouseltwentyninethstkaveh',
        [
            'label' => esc_html__('Number Box Border Radius', 'kavehTheme'),
            'type' => \Elementor\Controls_Manager::DIMENSIONS,
            'size_units' => ['px'],
            'selectors' => [
                '{{WRAPPER}} .icononlyone' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
            ],
        ]
      );

      $this->add_group_control(
        \Elementor\Group_Control_Box_Shadow::get_type(),
        [
          'name' => 'iconbgshadowcategorycarouseltwentyninethstkaveh',
          'label' => esc_html__( 'Number Box Shadow', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .icononlyone',
        ]
      );

      $this->end_controls_section();

      $this->start_controls_section(
        'style3_categorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Category Image Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'borderradiustcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [ 
            '{{WRAPPER}} .mx-auto' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'catimg1height2categorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Category Image Height', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 1000,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .mx-auto' => 'height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );

      $this->add_control(
        'backcoloroneimgcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Category Image First Background', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .category-book .image::before' => 'background-color: {{VALUE}}',
          ],
        ]
      );

      $this->add_control(
        'backcolortwoimgcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Category Image Second Background', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .category-book .image' => 'background-color: {{VALUE}}',
          ],
        ]
      );
      $this->end_controls_section();

      $this->start_controls_section(
        'styleBoxall_categorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'General Box Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );

      $this->add_control(
        'backcolorboxallcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Main Box Background', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .category-book::before' => 'background-color: {{VALUE}}',
   
          ],
        ]
      );

      $this->add_group_control(
        \Elementor\Group_Control_Border::get_type(),
        [
          'name' => 'backborderboxallcategorycarouseltwentyninethstkaveh',
          'label' => esc_html__( 'Border', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .category-book::before',
        ]
      );

      $this->add_responsive_control(
        'backborderradiusboxallcategorycarouseltwentyninethstkaveh',
        [
            'label' => esc_html__('Number Box Border Radius', 'kavehTheme'),
            'type' => \Elementor\Controls_Manager::DIMENSIONS,
            'size_units' => ['px'],
            'selectors' => [
                '{{WRAPPER}} .category-book::before' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
            ],
        ]
      );

      $this->add_group_control(
        \Elementor\Group_Control_Box_Shadow::get_type(),
        [
          'name' => 'backshadowboxallcategorycarouseltwentyninethstkaveh',
          'label' => esc_html__( 'Number Box Shadow', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .category-book::before',
        ]
      );

      $this->add_control(
        'shpebackcolorboxallcategorycarouseltwentyninethstkaveh',
        [
          'label' => esc_html__( 'Box Corner Shape Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .category-book::after' => 'background-color: {{VALUE}}',
   
          ],
        ]
      );

      $this->end_controls_section();

        }
 

  protected function render(){
    $settings = $this->get_settings_for_display();
    $clsid = $this->get_id();
    ?>
      <div class="container">
      <!-- Start Carousel -->
      <div class="swiper swiper-categories-books swiper-visible swiper-visibled-mobile swiper-initialized swiper-horizontal swiper-pointer-events swiper-autoheight swiper-rtl swiper-watch-progress swiper-backface-hidden">
        <div class="swiper-wrapper" id="swiper-wrapper-9b723ec593470285" aria-live="polite" style="height: 118px; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;">
        <?php
                              if (!empty($settings['listcategorycarouseltwentyninethstkaveh'])) {
                                  foreach ($settings['listcategorycarouseltwentyninethstkaveh'] as $item) {
                                      ?>
          <!-- Start Slide -->
          <div class="swiper-slide swiper-slide-visible" role="group" aria-label="4 / 4" style="width: 315px; margin-left: 12px;">
            <div class="category-book d-flex align-items-center position-relative elementor-repeater-item-<?php echo esc_attr($item['_id']); ?>">
              <a href="<?php echo esc_attr($item['linkcategorycarouseltwentyninethstkaveh']);?>" class="stretched-link position-absolute top-0 end-0 w-100 h-100" aria-label="name category"></a>
              <div class="layer position-absolute top-0 end-0 w-100 h-100"></div>
              <div class="image d-flex align-items-center justify-content-center position-relative flex-fill flex-grow-0 flex-shrink-0">
                <img src="<?php echo esc_url($item['img1categorycarouselninekaveh']['url']); ?>" alt="category" width="96" height="96" class="d-block mx-auto w-auto">
              </div>
              <div class="detail">
              <<?php echo $item['tagheading1categorycarouseltwentyninethstkaveh']; ?> class="title">
                          <?php echo esc_html($item['title1categorycarouseltwentyninethstkaveh']); ?>
                        </<?php echo $item['tagheading1categorycarouseltwentyninethstkaveh']; ?>>
                <div class="btn-count d-flex align-items-center flex-wrap">
                  <div class="text-view d-flex align-items-center gap-2">
                  <<?php echo $item['beftagheading1categorycarouseltwentyninethstkaveh']; ?> class="text-view">
                          <?php echo esc_html($item['beftitle1categorycarouseltwentyninethstkaveh']); ?>
                        </<?php echo $item['beftagheading1categorycarouseltwentyninethstkaveh']; ?>>
                        <i class="<?php echo esc_html($item['iconboxcategorycarouseltwentyninethstkaveh']['value']); ?> icononlyone"></i>                 
                  </div>
                  <div class="count"><?php echo esc_attr($item['numboxcategorycarouseltwentyninethstkaveh']);?></div>
                </div>
              </div>
            </div>
          </div>
          <?php
                                  }
                                }
                                ?>
          <!-- End Slide -->

        </div>
      <span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span></div>
      <!-- End Carousel -->
    </div>

<style>
  .categories-products-item .image img {
    object-fit: contain !important;
}
.categories-products-item .btn::before {
    background-size: contain !important;
}
</style>

    <?php
  }


}
