<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }

require_once dirname( __DIR__, 3 ) . '/widgets/premium/widget-product-comparison/elementor-render.php';

/**
 * Render callback for ggmc/product-comparison block.
 */
function render_ggmc_product_comparison_block( $attributes ) {
    // Premium license check
    if ( class_exists( 'GGM_Commerce_License' ) && ! GGM_Commerce_License::instance()->is_widget_activated( 'product-comparison' ) ) {
        if ( ggmc_is_editor_mode() ) {
            return '<div style="padding:20px;background:#fff3cd;border:1px solid #ffc107;border-radius:4px;color:#856404;text-align:center;"><strong>Premium Feature</strong><br>This block requires an active Goose Commerce license.</div>';
        }
        return '';
    }

    $product_data = ggmc_block_get_product_data( $attributes );
    $adapter      = new GGMC_Block_Adapter( $attributes, $product_data );

    ob_start();
    ggmc_product_comparison_render_premium_content( $adapter );
    return ob_get_clean();
}
