<?php
/**
 * File Path: includes/admin/tabs/class-mbs-tab-catalog.php
 *
 * Catalog Tab -- Settings IA Hub (UX-NAV-002)
 *
 * FREE+. Renders a persistent pill subnav (Authors / Series / Collections /
 * Universes) as a hub entry point. Each entity section is managed on its own
 * tab URL (tab=authors, tab=series, etc.) rather than inline here.
 *
 * Phase 2 (backlog): hook into WordPress taxonomy list screens. Child refs
 * on the constructor are retained for that integration; remove when scoped.
 *
 * Enqueue strategy: no entity-specific assets required for the hub view.
 * Entity scripts load via each child tab's own enqueue() when active.
 *
 * @package    My_Book_Showroom
 * @subpackage Includes/Admin/Tabs
 * @since      1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class MBS_Tab_Catalog {

	/** @var MBS_Tab_Authors */
	private MBS_Tab_Authors $authors;

	/** @var MBS_Tab_Series */
	private MBS_Tab_Series $series;

	/** @var MBS_Tab_Collections */
	private MBS_Tab_Collections $collections;

	/** @var MBS_Tab_Universes */
	private MBS_Tab_Universes $universes;

	/**
	 * @param MBS_Tab_Authors     $authors     Authors child instance.
	 * @param MBS_Tab_Series      $series      Series child instance.
	 * @param MBS_Tab_Collections $collections Collections child instance.
	 * @param MBS_Tab_Universes   $universes   Universes child instance.
	 *
	 * Child refs retained for Phase 2 (taxonomy list-screen integration).
	 * At that point, consolidate with MBS_Tab_Catalog::ENTITY_SLUGS constant.
	 * Remove constructor parameters and typed members when Phase 2 is scoped.
	 * @since 1.0.0
	 */
	public function __construct(
		MBS_Tab_Authors $authors,
		MBS_Tab_Series $series,
		MBS_Tab_Collections $collections,
		MBS_Tab_Universes $universes
	) {
		$this->authors     = $authors;
		$this->series      = $series;
		$this->collections = $collections;
		$this->universes   = $universes;
	}

	/**
	 * Enqueue Catalog tab assets when this tab is active.
	 *
	 * Hub view requires no entity-specific assets. Global scripts
	 * (mbs-admin-utils, mbs-sortable-list) are loaded unconditionally
	 * by class-mbs-settings.php (BUG-SOC-001 fix, Session 175).
	 *
	 * @param string $current_tab The active tab slug.
	 * @return void
	 * @since 1.0.0
	 */
	public function enqueue( string $current_tab ): void {
		if ( 'catalog' !== $current_tab ) {
			return;
		}
		// Hub view: no entity-specific assets required.
	}

	/**
	 * Render the Catalog hub.
	 *
	 * Outputs the pill subnav entry point only. No entity content is rendered
	 * here; each entity section lives on its own tab URL (tab=authors etc.).
	 *
	 * Passing 'catalog' to MBS_Tab_Catalog_Subnav::render() produces a neutral
	 * hub state -- no pill receives --active because 'catalog' intentionally
	 * does not match any key in the subnav's $items array. Do not add 'catalog'
	 * as a subnav item key; its non-match is the mechanism for neutral rendering.
	 *
	 * @return void
	 * @since 1.0.0
	 */
	public function render(): void {
		?>
		<div class="mbs-catalog-tab mbs-catalog-hub">
			<p class="mbs-catalog-hub__intro">
				<?php esc_html_e( 'Select a section to manage:', 'my-book-showroom' ); ?>
			</p>
			<?php MBS_Tab_Catalog_Subnav::render( 'catalog' ); ?>
		</div>
		<?php
	}

}
