<?php
use Banana_Addons\Elementor\Helper;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Background;
use Elementor\Utils;

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

class Banae_Stamp_Photo_Controls {

	/**
	 * The main widget controls registration method
	 * 
	 * @param mixed $widget
	 * 
	 * @return void
	 */
	public static function add_register_controls( $widget ) {
		$widget->start_controls_section(
			'stamp_photo_content_section',
			[
				'label' => esc_html__( 'Content', 'banana-addons-for-elementor' ),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
		);

		$widget->add_control(
			'stamp_image',
			[
				'label' => esc_html__( 'Choose Image', 'banana-addons-for-elementor' ),
				'type' => Controls_Manager::MEDIA,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				],
			]
		);

		$widget->add_control(
			'stamp_width',
			[
				'label' => esc_html__( 'Width', 'banana-addons-for-elementor' ),
				'type' => Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 5000,
						'step' => 5,
					],
					'%' => [
						'min' => 0,
						'max' => 100,
					],
				],
				'default' => [
					'unit' => 'px',
					'size' => 200,
				],
				'selectors' => [
					'{{WRAPPER}} .banae-stamp-photo' => 'width: {{SIZE}}{{UNIT}};',
				],
			]
		);

		$widget->add_control(
			'stamp_height',
			[
				'label' => esc_html__( 'Height', 'banana-addons-for-elementor' ),
				'type' => Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 5000,
						'step' => 5,
					],
					'%' => [
						'min' => 0,
						'max' => 100,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .banae-stamp-photo' => 'height: {{SIZE}}{{UNIT}};',
				],
			]
		);

		$widget->end_controls_section();

		// Stamp Photo Style Section
		$widget->start_controls_section(
			'stamp_photo_style_section',
			[
				'label' => esc_html__( 'Stamp Photo', 'banana-addons-for-elementor' ),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);

		$widget->add_control(
			'stamp_border_size',
			[
				'label' => esc_html__( 'Border Size', 'banana-addons-for-elementor' ),
				'type' => Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%', 'em', 'rem' ],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 1000,
						'step' => 2,
					],
					'%' => [
						'min' => 0,
						'max' => 100,
					],
				],
				'default' => [
					'unit' => 'px',
					'size' => 10,
				],
				'selectors' => [
					'{{WRAPPER}} .banae-stamp-photo' => '--r: {{SIZE}}{{UNIT}};',
				],
			]
		);

		$widget->add_control(
			'stamp_border_color',
			[
				'label' => esc_html__( 'Border Color', 'banana-addons-for-elementor' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .banae-stamp-photo' => 'background: radial-gradient(50% 50%, #0000 65%, {{VALUE}} 67%) round var(--r) var(--r)/calc(2*var(--r)) calc(2*var(--r));',
				],
				'default' => '#ffffff',
			]
		);

		$widget->add_control(
			'stamp_drop_shadow',
			[
				'label' => esc_html__( 'Drop Shadow', 'banana-addons-for-elementor' ),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .banae-stamp-photo' => 'filter: grayscale(.4) drop-shadow(0 0 1px {{VALUE}}) drop-shadow(0 0 1px {{VALUE}});',
				],
				'default' => '#0005',
			]
		);

		$widget->end_controls_section();
	}
}