<?php
namespace Dreamfox\DeliveryDate\Site;

use Dreamfox\DeliveryDate\Abstracts\AbstractAssets;

class AssetsManager extends AbstractAssets
{
    /**
     * Frontend enqueue hook
     */
    protected function _getEventName() {
        return 'wp_enqueue_scripts';
    }

    /**
     * Register styles that the AbstractAssets parent can handle.
     * Keep your existing frontend.css and add local jQuery UI theme CSS.
     */
    protected function _buildStyles() {
        return [
            'frontend' => [
                'src'  => $this->getAssetUrl('frontend.css'),
                'deps' => [],
                'ver'  => defined('WP_DEBUG') && WP_DEBUG ? time() : '1.0.0',
            ],
            // Local copy of the jQuery UI 1.12.1 "Smoothness" theme CSS
            'jquery-ui-theme' => [
                'src'  => $this->getAssetUrl('assets/jquery-ui/themes/smoothness/jquery-ui.min.css'),
                'deps' => [],
                'ver'  => '1.12.1',
            ],
        ];
    }

    /**
     * No additional script files from your plugin right now.
     */
    protected function _buildScripts() {
        return [];
    }

    /**
     * Enqueue WordPress-bundled jQuery UI and our local theme CSS.
     */
    public function registerScripts() {
        parent::registerScripts();

        // WordPress already bundles the JS parts of jQuery UI; just enqueue what you use.
        wp_enqueue_script('jquery-ui-core');
        wp_enqueue_script('jquery-ui-datepicker');

        // Enqueue our local theme CSS (registered via _buildStyles()).
        // Use a unique handle to avoid collisions with other plugins/themes.
        wp_enqueue_style('dreamfox-deliverydate-jquery-ui-theme');

        // Ensure your frontend CSS still loads.
        wp_enqueue_style('dreamfox-deliverydate-frontend');
    }

    /**
     * Build type identifier unchanged.
     */
    protected function _getBuildType() {
        return 'free';
    }
}
