<?php

namespace ThemesflatAddons\Widgets;

use  Elementor\Widget_Base;
use  Elementor\Controls_Manager;
use  Elementor\Utils;
use  Elementor\Scheme_Color;
use  Elementor\Group_Control_Typography;
use  Elementor\Scheme_Typography;

if (!defined('ABSPATH')) {
    exit;
}

// Exit if accessed directly
class TFL_Button_Widget extends TFL_Widget_Base
{
    public function get_name()
    {
        return 'tfl-button';
    }

    public function get_title()
    {
        return __('Button', 'themesflat');
    }

    public function get_icon()
    {
        return 'tfl-icon-buttons';
    }

    public function get_categories()
    {
        return array('themesflat-addons');
    }

    public function get_custom_help_url()
    {
        return 'https://themesflatelementor.com/docs/themesflat-addons/core-addons/button-addon/';
    }

    public function get_script_depends()
    {
        return ['tfl-waypoints', 'tfl-frontend-scripts'];
    }

    public function get_style_depends()
    {
        return ['tfl-animate-styles', 'tfl-frontend-styles', 'tfl-button-styles'];
    }

    protected function register_controls()
    {
        $this->start_controls_section('section_button', [
            'label' => __('Button', 'themesflat'),
        ]);
        $this->add_control('style', [
            'type' => Controls_Manager::SELECT,
            'label' => __('Choose Style', 'themesflat'),
            'default' => 'style1',
            'options' => [
                'style1' => __('Style 1', 'themesflat'),
            ],
        ]);

        $this->add_control('button_text', [
            'type' => Controls_Manager::TEXT,
            'label' => __('Button Text', 'themesflat'),
            'label_block' => true,
            'separator' => 'before',
            'default' => __('Button Text', 'themesflat'),
            'dynamic' => [
                'active' => true,
            ],
        ]);

        $this->add_control('link', [
            'label' => __('Link', 'elementor'),
            'type' => Controls_Manager::URL,
            'dynamic' => [
                'active' => true,
            ],
            'placeholder' => __('https://your-link.com', 'elementor'),
            'default' => [
                'url' => '#',
            ],
        ]);

        $this->add_control('widget_animation', [
            "type" => Controls_Manager::SELECT,
            "label" => __("Animation Type", "themesflat"),
            'options' => tfl_get_animation_options(),
            'default' => 'none',
        ]);
        $this->end_controls_section();
    }

    protected function render()
    {
        $settings = $this->get_settings_for_display();
        $settings = apply_filters('tfl_button_' . $this->get_id() . '_settings', $settings);
        $args['settings'] = $settings;
        $args['widget_instance'] = $this;
        tfl_get_template_part("addons/button/{$settings['style']}", $args);
    }

    protected function content_template()
    {
    }

}