<?php

namespace Fotogenic_AI;

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

/**
 * Fallback product query adapter when no compat implementation is active (e.g. WooCommerce inactive).
 * Returns empty list and WP_Error with woocommerce_not_active / 503 for product lookups.
 */
final class Product_Query_Adapter_Fallback implements ProductQueryAdapter {

	public function scan_products( array $args ): array {
		$after_id     = max( 0, (int) ( $args['after_id'] ?? 0 ) );
		$high_water_id = max( 0, (int) ( $args['high_water_id'] ?? 0 ) );

		return [
			'items'       => [],
			'total'       => 0,
			'nextAfterId' => $after_id,
			'done'        => true,
			'highWaterId' => $high_water_id,
			'available'   => false,
		];
	}

	public function list_products( array $args ): array {
		return [
			'items'      => [],
			'totalItems' => 0,
			'totalPages' => 1,
		];
	}

	/** @return array|\WP_Error */
	public function list_product_variations( int $parent_product_id, array $args ) {
		return new \WP_Error( 'woocommerce_not_active', __( 'WooCommerce is not active.', 'fotogenic-ai' ), [ 'status' => 503 ] );
	}

	/** @return array|null|\WP_Error */
	public function get_product_summary( int $product_id ) {
		return new \WP_Error( 'woocommerce_not_active', __( 'WooCommerce is not active.', 'fotogenic-ai' ), [ 'status' => 503 ] );
	}

	/** @return array|\WP_Error */
	public function get_product_context( int $product_id ) {
		return new \WP_Error( 'woocommerce_not_active', __( 'WooCommerce is not active.', 'fotogenic-ai' ), [ 'status' => 503 ] );
	}
}
