<?php

namespace App\Providers;

use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;

class ThemeServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        // Register @theme Blade directive
        Blade::directive('theme', function ($expression) {
            return "<?php echo theme({$expression}); ?>";
        });

        // Register @themeId Blade directive
        Blade::directive('themeId', function () {
            return "<?php echo theme_id(); ?>";
        });

        // Register @themeName Blade directive
        Blade::directive('themeName', function () {
            return "<?php echo theme_name(); ?>";
        });

        // Register @themeColor Blade directive
        Blade::directive('themeColor', function ($expression) {
            return "<?php echo theme_color({$expression}); ?>";
        });

        // Register @themeFont Blade directive
        Blade::directive('themeFont', function ($expression) {
            return "<?php echo theme_font({$expression}); ?>";
        });

        // Register @isTheme Blade directive
        Blade::directive('isTheme', function ($expression) {
            return "<?php if (is_theme({$expression})): ?>";
        });

        // Register @endIsTheme Blade directive
        Blade::directive('endIsTheme', function () {
            return "<?php endif; ?>";
        });

        // Register @themeCssVars Blade directive
        Blade::directive('themeCssVars', function () {
            return "<?php echo theme_css_vars(); ?>";
        });
    }
}