<?php
/** Marquee Elementor widget. */
defined( 'ABSPATH' ) || exit;

class Shabnam_Elementor_Marquee extends Shabnam_Elementor_Widget_Base {
	public function get_name() { return 'shabnam-muchwow-marquee'; }
	public function get_title() { return __( 'نوار متحرک MuchWOW', 'shabnam-muchwow' ); }
	public function get_icon() { return 'eicon-animation-text'; }

	protected function register_controls() {
		$this->start_controls_section( 'content', array( 'label' => __( 'محتوا', 'shabnam-muchwow' ) ) );
		$r = new \Elementor\Repeater();
		$r->add_control( 'text', array( 'label' => __( 'متن', 'shabnam-muchwow' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => 'اقتصاد توکن' ) );
		$this->add_control( 'items', array(
			'label' => __( 'آیتم‌ها', 'shabnam-muchwow' ),
			'type' => \Elementor\Controls_Manager::REPEATER,
			'fields' => $r->get_controls(),
			'default' => array( array( 'text' => 'اقتصاد توکن' ), array( 'text' => 'میم‌کوین‌ها' ), array( 'text' => 'اقتصاد توکن' ), array( 'text' => 'رمزارز' ) ),
			'title_field' => '{{{ text }}}',
		) );
		$this->add_control( 'symbol', array( 'label' => __( 'جداکننده', 'shabnam-muchwow' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '¥' ) );
		$this->add_control( 'variant', array(
			'label' => __( 'رنگ نوار', 'shabnam-muchwow' ),
			'type' => \Elementor\Controls_Manager::SELECT,
			'default' => 'secondary',
			'options' => array( 'secondary' => __( 'زرد', 'shabnam-muchwow' ), 'primary' => __( 'بنفش', 'shabnam-muchwow' ) ),
		) );
		$this->end_controls_section();
		$this->shabnam_register_common_style_controls();
	}

	protected function render() {
		$s = $this->get_settings_for_display();
		$classes = 'primary' === $s['variant'] ? 'bg-primary rotate-2 text-secondary' : 'bg-secondary -rotate-2 text-black';
		?>
		<div class="h3 xl:h2 fw-medium py-4 xl:py-6 my-3 reverse <?php echo esc_attr( $classes ); ?> text-uppercase ls-0 shabnam-elementor-section" data-uc-marquee="clone: 3; gap: 64; reverse: true;" style="--gap: 32px">
		<div>
		<?php for ( $copy = 0; $copy < 4; $copy++ ) : ?>
		<div class="hstack gap-8">
			<?php foreach ( $s['items'] as $item ) : ?><div><?php echo esc_html( $s['symbol'] ); ?></div><span><?php echo esc_html( $item['text'] ); ?></span><?php endforeach; ?>
		</div>
		<?php endfor; ?>
		</div></div>
		<?php
	}
}
