<?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('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');

        // Styles are already registered and enqueued by parent::registerStyles()
        // (hooked to the same event). Nothing more to do here.
    }

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