<?php
declare(strict_types=1);

namespace Ekesto\CacheInvalidator\Core\Elementor;

use Ekesto\CacheInvalidator\Integrations\Structural\Providers\Contracts\StructuralContainerProviderInterface;

/**
 * Lite-safe no-op Elementor provider.
 */
final class NullElementorIntegration implements ElementorIntegrationInterface
{
    /**
     * Determine whether Elementor implementation services are available.
     *
     * @return bool Always false for the null provider.
     */
    public function isAvailable(): bool
    {
        return false;
    }

    /**
     * Classify one Elementor library post ID.
     *
     * @param int $postId Elementor library post ID.
     * @return string Neutral unknown classification.
     */
    public function classifyLibraryPost(int $postId): string
    {
        unset($postId);

        return ElementorDocumentClassification::UNKNOWN;
    }

    /**
     * Return Elementor structural providers.
     *
     * @return StructuralContainerProviderInterface[] Always empty for the null provider.
     */
    public function structuralProviders(): array
    {
        return [];
    }

    /**
     * Resolve stored Elementor conditions for one template.
     *
     * @param int $postId Elementor library post ID.
     * @return array{post_ids:int[],urls:string[],certain:bool,resolution:string,fallback_reason:string}
     */
    public function resolveElementorConditions(int $postId): array
    {
        unset($postId);

        return $this->emptyResult();
    }

    /**
     * Resolve an explicit effective Elementor condition set for one template.
     *
     * @param int              $postId Elementor library post ID.
     * @param array<int,mixed> $conditions Effective condition strings.
     * @return array{post_ids:int[],urls:string[],certain:bool,resolution:string,fallback_reason:string}
     */
    public function resolveEffectiveConditions(int $postId, array $conditions): array
    {
        unset($postId, $conditions);

        return $this->emptyResult();
    }

    /**
     * Build a safe empty targeted result.
     *
     * @return array{post_ids:int[],urls:string[],certain:bool,resolution:string,fallback_reason:string}
     */
    private function emptyResult(): array
    {
        return [
            'post_ids' => [],
            'urls' => [],
            'certain' => true,
            'resolution' => 'ELEMENTOR_CONDITIONS',
            'fallback_reason' => '',
        ];
    }
}
