<?php

class Author_Kit_Load_Kirki_Pro {

	public function __construct() {
		$this->load_kirki_pro_dependencies();
	}

	public function load_kirki_pro_dependencies() {

		// 1. Check 'Kirki' is active or not.
		if ( is_plugin_active( 'kirki/kirki.php' ) ) {

			// 2. Base path to Kirki Pro modules inside the Kirki plugin.
			$base_path = plugin_dir_path( AUTHOR_KIT_PLUGIN_PATH ) . 'kirki/pro-src/packages/';

			// 3. List of modules to load.
			$modules = array(
				'kirki-pro-headline-divider' => '\Kirki\Pro\HeadlineDivider\Init',
				'kirki-pro-margin-padding'   => '\Kirki\Pro\MarginPadding\Init',
				'kirki-pro-responsive'       => '\Kirki\Pro\Responsive\Init',
				'kirki-pro-input-slider'     => '\Kirki\Pro\InputSlider\Init',
			);

			// 4. Loop through each and safely include if possible
			foreach ( $modules as $slug => $class ) {
				if ( ! class_exists( $class ) ) {
					$autoload = $base_path . "{$slug}/vendor/autoload.php";
					if ( file_exists( $autoload ) ) {
						require_once $autoload;
						if ( class_exists( $class ) ) {
							new $class();
						}
					}
				}
			}
		}
	}
}

new Author_Kit_Load_Kirki_Pro();
