<?php

/**
 * HappyFenceNG Total Enterprise Security Plugin
 * HAPPYWPRESS is a RazorVue Trademark.
 *
 * @package     HappyFenceNG
 * @developer   Simonluca Scillitani
 * @copyright   2025 RazorVue di Scillitani Simonluca
 * @link        https://razorvue.it
 * @author      RazorVue di Scillitani Simonluca
 * @brand       HappyWPress
 * @uri         https://happywpress.com
 * @set all
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
/**PHPCS -> code compliance: we put useful comments where needed.. */
class HappyFenceNGVRLIC extends HappyFenceNGAVRoute {
    /**PHPCS -> code compliance: we put useful comments where needed.. */
    public function doRoute() {
        try {
            $nonce_save_settings = wp_create_nonce( 'happyfenceng_LIC_save_settings' );
            $burn = HappyFenceNGFailFast::setup();
            $badge = esc_html__( 'Free', 'happyfenceng-total-enterprise-security' );
            $color = 'hfng-plan-color-free';
            $upgrade = esc_html__( 'You are currently using the PRO version of HappyFenceNG. Upgrade to unlock additional features and receive PREMIUM 5 NBD support.', 'happyfenceng-total-enterprise-security' );
            $can_upgrade = true;
            try {
                if ( htes_fs()->is_trial() ) {
                    if ( htes_fs()->is_trial_expired() ) {
                        $badge = esc_html__( 'Trial Expired', 'happyfenceng-total-enterprise-security' );
                        $color = 'hfng-plan-color-trial-expired';
                    } else {
                        $badge = esc_html__( 'Trial Active', 'happyfenceng-total-enterprise-security' );
                        $color = 'hfng-plan-color-trial-active';
                    }
                } else {
                    if ( HappyFenceNGTR::is_in( static::class, array(HappyFenceNGTR::FUNNEL), true ) ) {
                        $badge = esc_html__( 'Free', 'happyfenceng-total-enterprise-security' );
                        $color = 'hfng-plan-color-free';
                        $upgrade = esc_html__( 'You are currently using the free version of HappyFenceNG. Upgrade to unlock additional features and receive priority support.', 'happyfenceng-total-enterprise-security' );
                        $can_upgrade = true;
                    }
                }
            } catch ( Throwable $t ) {
                return;
            }
            $params = array(
                'texts'  => array(
                    'title'                 => esc_html__( 'License & Upgrade', 'happyfenceng-total-enterprise-security' ),
                    'plan_title'            => 'Your current plan:',
                    'plan'                  => $badge,
                    'upgrade_now'           => esc_html__( 'Upgrade now', 'happyfenceng-total-enterprise-security' ),
                    'compare_editions'      => esc_html__( 'Compare editions', 'happyfenceng-total-enterprise-security' ),
                    'edition'               => esc_html__( 'EDITION', 'happyfenceng-total-enterprise-security' ),
                    'free_edition'          => esc_html__( 'FREE', 'happyfenceng-total-enterprise-security' ),
                    'pro_edition'           => esc_html__( 'PRO', 'happyfenceng-total-enterprise-security' ),
                    'agency_edition'        => esc_html__( 'AGENCY', 'happyfenceng-total-enterprise-security' ),
                    'enterprise_edition'    => esc_html__( 'ENTERPRISE', 'happyfenceng-total-enterprise-security' ),
                    'dashboard'             => esc_html__( 'Dashboard', 'happyfenceng-total-enterprise-security' ),
                    'integrity_check'       => esc_html__( 'Integrity check w/.htaccess guard', 'happyfenceng-total-enterprise-security' ),
                    'option_1'              => esc_html__( 'FailFast™ Anti Hijacking protection', 'happyfenceng-total-enterprise-security' ),
                    'option_2'              => esc_html__( 'Basic Protection', 'happyfenceng-total-enterprise-security' ),
                    'option_3'              => esc_html__( 'API & Frontend', 'happyfenceng-total-enterprise-security' ),
                    'option_4'              => esc_html__( 'RP/Cloudflare Guard', 'happyfenceng-total-enterprise-security' ),
                    'option_5'              => esc_html__( 'HF WP Cli Shell', 'happyfenceng-total-enterprise-security' ),
                    'option_6'              => esc_html__( 'IP Blacklist', 'happyfenceng-total-enterprise-security' ),
                    'option_7'              => esc_html__( 'Data Security', 'happyfenceng-total-enterprise-security' ),
                    'option_8'              => esc_html__( 'Deep Filtering', 'happyfenceng-total-enterprise-security' ),
                    'option_9'              => esc_html__( 'GeoIP Blocking', 'happyfenceng-total-enterprise-security' ),
                    'option_10'             => esc_html__( 'Loggers', 'happyfenceng-total-enterprise-security' ),
                    'option_10_free'        => esc_html__( 'FILE', 'happyfenceng-total-enterprise-security' ),
                    'option_10_pro'         => esc_html__( 'FILE — 8 Severity levels', 'happyfenceng-total-enterprise-security' ),
                    'option_10_agency'      => esc_html__( 'FILE/DB — 8 Severity levels', 'happyfenceng-total-enterprise-security' ),
                    'option_10_enterprise'  => esc_html__( 'FILE/DB/SIEM — 8 Severity levels · 20 Facility Levels', 'happyfenceng-total-enterprise-security' ),
                    'option_11'             => esc_html__( 'Severity Levels', 'happyfenceng-total-enterprise-security' ),
                    'option_12'             => esc_html__( 'Facility Levels', 'happyfenceng-total-enterprise-security' ),
                    'option_13'             => esc_html__( 'Multifactor Authentication', 'happyfenceng-total-enterprise-security' ),
                    'option_14'             => esc_html__( 'Privacy', 'happyfenceng-total-enterprise-security' ),
                    'option_15'             => esc_html__( 'RT Remote Shell Scanner + Quarantine', 'happyfenceng-total-enterprise-security' ),
                    'option_16'             => esc_html__( 'RT System Shields', 'happyfenceng-total-enterprise-security' ),
                    'option_17'             => esc_html__( 'RT Suspicious Query Scanner', 'happyfenceng-total-enterprise-security' ),
                    'option_17_ent'         => esc_html__( '80+ fine grained pattends', 'happyfenceng-total-enterprise-security' ),
                    'option_18'             => esc_html__( 'Upload Guard', 'happyfenceng-total-enterprise-security' ),
                    'option_19'             => esc_html__( 'Runtime Anti-Tampering Mode', 'happyfenceng-total-enterprise-security' ),
                    'need_help'             => esc_html__( 'Need help?', 'happyfenceng-total-enterprise-security' ),
                    'visit_happywpress'     => esc_html__( 'Visit HappyWPress', 'happyfenceng-total-enterprise-security' ),
                    'support'               => esc_html__( 'Support', 'happyfenceng-total-enterprise-security' ),
                    'free_support'          => esc_html__( 'Community/FAQ', 'happyfenceng-total-enterprise-security' ),
                    'pro_support'           => esc_html__( 'Best Effort priority support', 'happyfenceng-total-enterprise-security' ),
                    'agency_support'        => esc_html__( '5 Business Days Premium Support', 'happyfenceng-total-enterprise-security' ),
                    'enterprise_support'    => esc_html__( '3 Business Days Premium Support', 'happyfenceng-total-enterprise-security' ),
                    'feature_requires'      => esc_html__( 'THIS FEATURE IS FREE', 'happyfenceng-total-enterprise-security' ),
                    'save_settings'         => esc_html__( 'Save Settings', 'happyfenceng-total-enterprise-security' ),
                    'settings_saved'        => esc_html__( 'Settings Saved', 'happyfenceng-total-enterprise-security' ),
                    'error_saving_settings' => esc_html__( 'Error saving settings', 'happyfenceng-total-enterprise-security' ),
                ),
                'links'  => array(
                    'happyfenceng_logo_url' => esc_url( HAPPYFENCENG_PLUGIN_URL . 'assets/images/happyfenceng-small.png' ),
                    'upgrade_url'           => esc_url( htes_fs()->get_upgrade_url() ?? '' ),
                ),
                'values' => array(
                    'can_upgrade'     => $can_upgrade,
                    'plan_class'      => $color,
                    'upgrade_text'    => $upgrade,
                    'checkbox_on'     => HappyFenceNGPlaceholder::CHECKBOX_ON,
                    'checkbox_off'    => HappyFenceNGPlaceholder::CHECKBOX_OFF,
                    'nonce'           => $nonce_save_settings,
                    'burnNonce'       => $burn,
                    'feature_enabled' => true,
                ),
            );
            ob_start();
            HappyFenceNGVControl::renderView( $params, 'lic' );
            // phpcs:ignore WordPress.Security.EscapeOutput
            echo ob_get_clean();
        } catch ( Throwable $e ) {
            HappyFenceNGLOGCORE::logcore( 'HappyFenceNGVRLIC - cannot render UI ' . $e->getMessage(), HappyFenceNGSyslogFacility::UI, HappyFenceNGSyslogSeverity::ERROR );
            ob_end_clean();
            HappyFenceNGCleaner::cleaner_oops();
        }
    }

}
