<?php
/**
 * Core Service Provider
 *
 * Registers core services in the container
 *
 * @package NemtlyBooking
 * @since   PBOOKING_SINCE
 */

namespace NemtlyBooking\Providers;

use NemtlyBooking\Core\Service_Provider;
use NemtlyBooking\Core\Container;
use NemtlyBooking\Core\Event_Manager;
use NemtlyBooking\Core\Shortcodes;

/**
 * Core Service Provider class
 *
 * @since PBOOKING_SINCE
 */
class Core_Service_Provider extends Service_Provider {
    /**
     * Register core services
     *
     * @since PBOOKING_SINCE
     *
     * @param Container $container The dependency injection container.
     */
    public function register( Container $container ) {
        // Event Manager (singleton)
        $container->register(
            'event_manager',
            function () {
                static $instance = null;
                if ( null === $instance ) {
                    $instance = new Event_Manager();
                }
                return $instance;
            }
        );
        // Shortcodes
        $container->register(
            'shortcodes',
            function () {
                return new Shortcodes();
            }
        );
        // Token Service
        $container->register(
            'token_service',
            function () {
                return new \NemtlyBooking\Services\Token_Service();
            }
        );
        // Dashboard Shortcode
        $container->register(
            'dashboard_shortcode',
            function ( $c ) {
                return new \NemtlyBooking\Shortcodes\Dashboard_Shortcode(
                    $c->get( 'token_service' ),
                    $c->get( 'booking_repository' )
                );
            }
        );
        // Single Event Shortcode — server-rendered hero + booking-wizard mount.
        $container->register(
            'single_event_shortcode',
            function ( $c ) {
                return new \NemtlyBooking\Shortcodes\Single_Event_Shortcode(
                    $c->get( 'event_repository' ),
                    $c->get( 'settings_service' )
                );
            }
        );
        $this->mark_registered();
    }
}
