<?php

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound -- APD is the established namespace shared with the Pro add-on and retained for backward compatibility.
namespace APD\Front;

use APD\Admin\AdminSettings;
use APD\Container;
use APD\Contracts\ServiceProviderInterface;

defined('ABSPATH') || exit;

class FrontServiceProvider implements ServiceProviderInterface
{
    public function __construct(protected Container $container)
    {
    }

    public function register() : void
    {
        $this->container->set(Renderer::class, fn($c) => new Renderer($c->get(FrontContextBuilder::class)));
        $this->container->set(FrontContextBuilder::class, fn() => new FrontContextBuilder());
        $this->container->set(ShortcodeController::class, fn($c) => new ShortcodeController(
            $c->get(Renderer::class),
            $c->get(AdminSettings::class)
        ));
        $this->container->set(FrontAssets::class, fn() => new FrontAssets());
    }

    public function boot() : void
    {
        add_action('wp_enqueue_scripts', [$this->container->get(FrontAssets::class), 'register']);
        add_shortcode('asuka_designer', [$this->container->get(ShortcodeController::class), 'render']);
    }
}
