<?php
/**
 * Factory bootstrap for Quick Variable Products. The ONLY place that wires the
 * shared core to this plugin — Strauss rewrites these core references at build
 * time to the plugin-prefixed Vendor namespace.
 *
 * The product itself still lives in includes/ (ERENQVP_* free classes + ERENQVPP_*
 * premium classes, plainly required): the live wp-cli + Chrome suites proved
 * that engine, so the factory migration deliberately changes the wiring, not
 * the engine.
 *
 * @package ErenLabs\QuickVariableProducts
 */

namespace ErenLabs\QuickVariableProducts;

use ErenLabs\QuickVariableProducts\Vendor\Hakki\WooCore\Core;

defined( 'ABSPATH' ) || exit;

final class Bootstrap {

	private const SLUG = 'quick-variable-products';

	/** @var Core|null */
	private static $core = null;

	/**
	 * Build (or fetch) the shared core for this plugin. Core::boot() also
	 * declares HPOS + checkout-blocks compatibility.
	 */
	public static function core(): Core {
		if ( null === self::$core ) {
			self::$core = Core::boot(
				array(
					'slug'         => self::SLUG,
					'file'         => defined( 'ERENQVP_FILE' ) ? ERENQVP_FILE : __FILE__,
					'version'      => defined( 'ERENQVP_VER' ) ? ERENQVP_VER : '0.0.0',
					'group'        => 'b2c',
					'requires_woo' => true,
					'min_woo'      => '6.0',
					// Freemius later supplies the 'can' resolver (licence check).
				)
			);
		}
		return self::$core;
	}

	/**
	 * Free-yields-to-pro guard (Core::should_boot): when the pro artifact is
	 * co-installed it defines QUICK_VARIABLE_PRODUCTS_PRO_ACTIVE with its own
	 * file path, and any OTHER instance of this plugin steps aside.
	 */
	public static function should_boot(): bool {
		return self::core()->should_boot();
	}
}
