<?php
/**
 * Support Copilot — bundle entry point.
 *
 * The Support Copilot is a versioned module vendored VERBATIM inside adopting
 * plugins (the PK Core / Action Scheduler pattern). It is NOT a plugin. At
 * runtime the newest vendored copy across all active plugins wins and its class
 * definition boots every host's widget instance.
 *
 * Each vendoring host does exactly two things (typically inside its own
 * plugins_loaded callback for registration, and on init for the config, since
 * the config carries translated strings):
 *
 *     require_once __DIR__ . '/support-copilot/support-copilot.php';
 *     \BlackWhiteDigital\SupportCopilot\Loader::queue( array( ...host config... ) );
 *
 * Do NOT require class-copilot.php directly — that degrades the whole install
 * to first-wins for every adopter.
 *
 * 2.0.0 moved the module into the BlackWhiteDigital\SupportCopilot namespace.
 * A 1.x copy cannot negotiate with a 2.x copy, so every bundling plugin must
 * move to 2.x together; no BWD_* alias is provided by design.
 *
 * @package BlackWhiteDigital\SupportCopilot
 * @version 2.1.1
 */

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

/**
 * Version of the Support Copilot module vendored in THIS plugin.
 *
 * Bump together with Copilot::MODULE_VERSION on any module change. The loader
 * compares this across all vendored copies with version_compare(); the highest
 * wins. A variable, not a constant: constants collide across copies, variables
 * do not.
 */
$bwdsc_this_version = '2.1.1';

// The loader is a tiny, FROZEN registry shared by all vendored copies. The
// first copy to load defines it; later copies reuse it (class_exists guard
// inside). Versioned behaviour lives in the class file it loads, never here.
require_once __DIR__ . '/class-loader.php';

\BlackWhiteDigital\SupportCopilot\Loader::register( $bwdsc_this_version, __DIR__ );

// Don't leak into the next copy's require of its own entry file.
unset( $bwdsc_this_version );

// Negotiate once every host has had a chance to register. Hosts commonly
// register inside their own plugins_loaded callbacks (adding a later priority
// of the currently-running hook still fires), with an early-init safety net
// for anyone later still; boot() is idempotent and WP dedupes identical
// callbacks, so repeated requires of entry copies are harmless. A queue()
// arriving after boot boots that instance immediately (see the loader).
if ( function_exists( 'add_action' ) ) {
	add_action( 'plugins_loaded', array( '\BlackWhiteDigital\SupportCopilot\Loader', 'boot' ), 99 );
	add_action( 'init', array( '\BlackWhiteDigital\SupportCopilot\Loader', 'boot' ), 0 );
}
