<?php
/**
 * Design System Addon bootstrap.
 *
 * @package Polanger_Dashboard_Tools
 */

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

require_once __DIR__ . '/includes/class-design-themes.php';
require_once __DIR__ . '/includes/class-design-settings.php';
require_once __DIR__ . '/includes/class-design-generator.php';
require_once __DIR__ . '/includes/class-design-enqueue.php';
require_once __DIR__ . '/includes/class-design-preview.php';

/**
 * Main addon orchestrator.
 */
class PDT_Design_System {

  /**
   * Settings service.
   *
   * @var PDT_Design_Settings
   */
  private $settings;

  /**
   * Generator service.
   *
   * @var PDT_Design_Generator
   */
  private $generator;

  /**
   * Enqueue service.
   *
   * @var PDT_Design_Enqueue
   */
  private $enqueue;

  /**
   * Preview/controller service.
   *
   * @var PDT_Design_Preview
   */
  private $preview;

  /**
   * Constructor.
   */
  public function __construct() {
    $this->settings  = new PDT_Design_Settings();
    $this->generator = new PDT_Design_Generator( $this->settings );
    $this->enqueue   = new PDT_Design_Enqueue( $this->settings, $this->generator );
    $this->preview   = new PDT_Design_Preview( $this->settings, $this->generator );

    add_action( 'pdt_admin_menu_after_dashboard_center', array( $this->preview, 'register_menu' ) );
    add_action( 'admin_enqueue_scripts', array( $this->preview, 'enqueue_page_assets' ) );
    add_action( 'admin_enqueue_scripts', array( $this->enqueue, 'enqueue_for_admin' ), 999, 1 );
    add_action( 'wp_enqueue_scripts', array( $this->enqueue, 'enqueue_for_frontend' ), 999 );
  }
}
