<?php
namespace Sifency_Addons\Includes;

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

class Sifency_Addons_Elementor_Widgets_Asset_Manager {
	public function __construct() {
		add_action( 'wp_enqueue_scripts', [ $this, 'register_assets' ] );
		add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_assets' ] );
		add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue_editor_assets' ] );
	}

	public function register_assets() {
		$base_url = SIFENCY_ADDONS_URL . 'assets/';
		$elementor_url = SIFENCY_ADDONS_URL . 'includes/elementor/assets/';
		$version  = SIFENCY_ADDONS_VERSION;
		$deps_el  = [ 'elementor-frontend' ];
		$deps_jq  = [ 'jquery' ];

		/** -------------------------------
		 *  Elementor Widget Styles
		 *--------------------------------*/
		wp_register_style( 'sifency-theme-builder-style', $base_url . 'css/elementor/theme-builder/theme-builder.css', $deps_el, $version );
		wp_register_style( 'sifency-theme-builder-service-style', $base_url . 'css/elementor/theme-builder/service.css', $deps_el, $version );
		wp_register_style( 'sifency-typo-style', $base_url . 'css/elementor/typography.css', $deps_el, $version );
		wp_register_style( 'sifency-component-style', $base_url . 'css/elementor/component.css', $deps_el, $version );
		wp_register_style( 'sifency-marquee-style', $base_url . 'css/elementor/marquee.css', $deps_el, $version );
		wp_register_style( 'sifency-blog-style', $base_url . 'css/elementor/blog.css', $deps_el, $version );
		wp_register_style( 'sifency-testimonials-style', $base_url . 'css/elementor/testimonials.css', $deps_el, $version );
		wp_register_style( 'sifency-clients-style', $base_url . 'css/elementor/clients.css', $deps_el, $version );
		wp_register_style( 'sifency-awards-style', $base_url . 'css/elementor/awards.css', $deps_el, $version );
		wp_register_style( 'sifency-services-style', $base_url . 'css/elementor/services.css', $deps_el, $version );
		wp_register_style( 'sifency-events-style', $base_url . 'css/elementor/events.css', $deps_el, $version );
		wp_register_style( 'sifency-portfolio-style', $base_url . 'css/elementor/portfolio.css', $deps_el, $version );
		wp_register_style( 'sifency-products-style', $base_url . 'css/elementor/products.css', $deps_el, $version );
		wp_register_style( 'sifency-accordion-style', $base_url . 'css/elementor/accordion.css', $deps_el, $version );
		wp_register_style( 'sifency-post-single-style', $base_url . 'css/elementor/post-single.css', $deps_el, $version );
		wp_register_style( 'sifency-career-style', $base_url . 'css/elementor/career.css', $deps_el, $version );
		wp_register_style( 'sifency-team-style', $base_url . 'css/elementor/team.css', $deps_el, $version );
		wp_register_style( 'sifency-products-slider-style', $base_url . 'css/elementor/products-slider.css', $deps_el, $version );
		wp_register_style( 'sifency-iconbox-style', $base_url . 'css/elementor/iconbox.css', $deps_el, $version );
		wp_register_style( 'sifency-button-style', $base_url . 'css/elementor/button.css', $deps_el, $version );
		wp_register_style( 'sifency-text-circle-style', $base_url . 'css/elementor/text-circle.css', $deps_el, $version );
		wp_register_style( 'sifency-offcanvas-trigger-style', $base_url . 'css/elementor/offcanvas.css', $deps_el, $version );
		wp_register_style( 'sifency-product-single-style', $base_url . 'css/elementor/product-single.css', $deps_el, $version );
		wp_register_style( 'sifency-nav-menu-style', $elementor_url . 'css/menu.css', $deps_el, $version );
		wp_register_style( 'sifency-digital-style', $elementor_url . 'css/digital.css', $deps_el, $version );
		wp_register_style( 'sifency-video-style', $elementor_url . 'css/video.css', $deps_el, $version );
		wp_register_style( 'sifency-modal-style', $elementor_url . 'css/modal.css', $deps_el, $version );
		wp_register_style( 'sifency-popup-style', $elementor_url . 'css/popup.css', $deps_el, $version );
		wp_register_style( 'sifency-pricing-style', $elementor_url . 'css/pricing.css', $deps_el, $version );
		wp_register_style( 'sifency-pricing-list-style', $elementor_url . 'css/pricing-list.css', $deps_el, $version );
		wp_register_style( 'sifency-typeout-style', $elementor_url . 'css/typeout.css', $deps_el, $version );
		wp_register_style( 'sifency-dropcap-style', $elementor_url . 'css/dropcap.css', $deps_el, $version );
		wp_register_style( 'sifency-working-hours-style', $elementor_url . 'css/working-hour.css', $deps_el, $version );
		wp_register_style( 'sifency-cta-style', $elementor_url . 'css/cta.css', $deps_el, $version );
		wp_register_style( 'sifency-vertical-tab-style', $elementor_url . 'css/vertical-tab.css', $deps_el, $version );
		wp_register_style( 'sifency-process-style', $elementor_url . 'css/process.css', $deps_el, $version );
		wp_register_style( 'sifency-vprog-style', $elementor_url . 'css/vertical-progressbar.css', $deps_el, $version );

		/** -------------------------------
		 *  Global Frontend Styles
		 *--------------------------------*/
		wp_register_style( 'sifency-frontend-style', $base_url . 'css/frontend.css', [ 'elementor-frontend' ], $version );
		wp_register_style( 'sifency-icon', $base_url . 'icons/css/fontello.css', [], $version );

		/** -------------------------------
		 *  Animation Styles
		 *--------------------------------*/
		wp_register_style( 'sifency-aos-style', $base_url . 'css/plugins/aos.css', [], $version );

		/** -------------------------------
		 *  Animation Scripts
		 *--------------------------------*/
		wp_register_script( 'sifency-aos-script', $base_url . 'js/plugins/aos.js', $deps_jq, $version, true );

		/** -------------------------------
		 *  Swiper Carousel
		 *--------------------------------*/
		wp_register_style( 'sifency-swiper-style', $base_url . 'css/plugins/swiper-min.css', [], '8.4.5' );
		wp_register_script( 'sifency-swiper-script', $base_url . 'js/plugins/swiper.min.js', [], '8.4.5', true );

		/** -------------------------------
		 *  Elementor JS Handlers
		 *--------------------------------*/
		wp_register_script( 'sifency-typed-lib-script', $elementor_url . 'js/vendor/typed.min.js', $version, true );
		wp_register_script( 'sifency-carousel-handler', $base_url . 'js/elementor/carousel-handler.js', [ 'elementor-frontend', 'sifency-swiper-script' ], $version, true );
		wp_register_script( 'sifency-counter-script', $base_url . 'js/elementor/sifency-counter.js', $deps_el, $version, true );
		wp_register_script( 'sifency-accordion-script', $base_url . 'js/elementor/accordion.js', $deps_el, $version, true );
		wp_register_script( 'sifency-progressbar-script', $base_url . 'js/elementor/progressbar.js', $deps_el, $version, true );
		wp_register_script( 'sifency-marquee-script', $base_url . 'js/elementor/marquee.js', $deps_el, $version, true );
		wp_register_script( 'sifency-nav-menu-script', $elementor_url . 'js/menu.js', $deps_el, $version, true );
		wp_register_script( 'sifency-digital-script', $elementor_url . 'js/digital.js', $deps_el, $version, true );
		wp_register_script( 'sifency-video-script', $elementor_url . 'js/video.js', $deps_el, $version, true );
		wp_register_script( 'sifency-modal-script', $elementor_url . 'js/modal.js', $deps_el, $version, true );
		wp_register_script( 'sifency-popup-script', $elementor_url . 'js/popup.js', $deps_el, $version, true );
		wp_register_script( 'sifency-pricing-script', $elementor_url . 'js/pricing.js', $deps_el, $version, true );
		wp_register_script( 'sifency-typeout-script', $elementor_url . 'js/typeout.js', $deps_el, $version, true );
		wp_register_script( 'sifency-vertical-tab-script', $elementor_url . 'js/vertical-tab.js', $deps_el, $version, true );
		wp_register_script( 'sifency-vertical-progressbar-script', $elementor_url . 'js/vertical-progressbar.js', $deps_el, $version, true );

		/** -------------------------------
		 *  Main Frontend Script
		 *--------------------------------*/
		wp_register_script( 'sifency-frontend-script', $base_url . 'js/frontend.js', array_merge( $deps_jq, [ 'elementor-frontend' ] ), $version, true );
	}


	public function enqueue_admin_assets() {
		wp_enqueue_style( 'sifency-addons-admin-style', SIFENCY_ADDONS_URL . 'assets/css/admin/admin.css', [], SIFENCY_ADDONS_VERSION );
		wp_enqueue_style( 'sifency-addons-admin-component', SIFENCY_ADDONS_URL . 'assets/css/admin/component.css', [], SIFENCY_ADDONS_VERSION );
		wp_enqueue_style( 'sifency-addons-features-style', SIFENCY_ADDONS_URL . 'assets/css/admin/features.css', [], SIFENCY_ADDONS_VERSION );
		wp_enqueue_script( 'sifency-addon-admin-script', SIFENCY_ADDONS_URL . 'assets/js/admin/admin.js', [ 'jquery' ], SIFENCY_ADDONS_VERSION, true );
	}

	public function enqueue_editor_assets() {
		wp_enqueue_style( 'sifency-editor-style', SIFENCY_ADDONS_URL . 'assets/css/editor/editor.css', [], SIFENCY_ADDONS_VERSION );
		wp_enqueue_style( 'sifency-editor-icons', SIFENCY_ADDONS_URL . 'assets/icons/css/fontello.css', [], SIFENCY_ADDONS_VERSION );
		wp_enqueue_script( 'sifency-editor', SIFENCY_ADDONS_URL . 'assets/js/editor/editor.js', [ 'jquery', 'elementor-editor' ], SIFENCY_ADDONS_VERSION, true );
	}
}