<?php
/**
 * Frontend Settings Section
 *
 * This file renders the "Frontend settings" section for the Pixelio Cart Abandon Recovery More plugin.
 * It includes exit popups, stock messages, cart timer, recent purchase popups, email capture popups,
 * and Google ReCaptcha settings.
 *
 * @package PixelioCartAbandonRecoveryMore\Admin\Views
 */

use PixelioCartAbandonRecoveryMore\Admin\Views\Reusable\Pixelio_Cart_Abandon_Recovery_More_Radio_Button;
use PixelioCartAbandonRecoveryMore\Includes\Utils\Pixelio_Cart_Abandon_Recovery_More_Util;
use PixelioCartAbandonRecoveryMore\Admin\Views\Reusable\Pixelio_Cart_Abandon_Recovery_More_Checkbox;
use PixelioCartAbandonRecoveryMore\Admin\Views\Reusable\Pixelio_Cart_Abandon_Recovery_More_Input_Text;
use PixelioCartAbandonRecoveryMore\Admin\Views\Reusable\Pixelio_Cart_Abandon_Recovery_More_Section_Title;

if ( ! defined( 'ABSPATH' ) ) exit; ?>
<div class="pixelio-cart-abandon-recovery-more-page-section">
	<?php
	$pixelio_cart_abandon_recovery_more_frontend_title_section = new Pixelio_Cart_Abandon_Recovery_More_Section_Title( esc_html( __( 'Frontend settings', 'rivio-ai-cart-recovery-marketing-email-automation' ) ) );
	$pixelio_cart_abandon_recovery_more_frontend_title_section->pixelio_cart_abandon_recovery_more_get_views();


	?>

	<?php

	$pixelio_cart_abandon_recovery_more_exit_popup_checkbox = new Pixelio_Cart_Abandon_Recovery_More_Checkbox(
		esc_html( __( 'Activate Exit Pop-up', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
		esc_html( __( 'Show a pop-up with a promo code and countdown timer when a user is about to leave the website. This pop-up is designed to capture the user’s email address, allowing you to follow up later if they add items to their cart, and to encourage them to subscribe to your newsletter.', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
		'pixelio-cart-abandon-recovery-more-exit-popup-checkbox',
		false,
		true,
		true,
		Pixelio_Cart_Abandon_Recovery_More_Util::$pixelio_plugin_class_slug . '-exit-popup',
		Pixelio_Cart_Abandon_Recovery_More_Util::$pixelio_plugin_class_slug . '-exit-popup',
		'',
		false,
		'',
		'',
		'pixelio-cart-abandon-recovery-more-exit-popup-discount'
	);
	$pixelio_cart_abandon_recovery_more_exit_popup_checkbox->pixelio_cart_abandon_recovery_more_get_views();
	$pixelio_cart_abandon_recovery_more_saved_settings[]    = $pixelio_cart_abandon_recovery_more_exit_popup_checkbox->get_saved_value();
	$pixelio_cart_abandon_recovery_more_exit_popup_discount = new Pixelio_Cart_Abandon_Recovery_More_Input_Text(
		esc_html( __( 'Maximum Discount Allowed', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
		esc_html( __( 'Set the highest discount percentage you allow for cart recovery pop-ups. If left blank, the algorithm will optimize it automatically.', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
		esc_html( __( 'Please provide an discount between 1% and 99%', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
		'pixelio-cart-abandon-recovery-more-exit-popup-discount',
		'pixelio-cart-abandon-recovery-more-exit-popup-checkbox',
		0,
	);
	$pixelio_cart_abandon_recovery_more_exit_popup_discount->pixelio_cart_abandon_recovery_more_get_views();
	$pixelio_cart_abandon_recovery_more_first_two_checkbox_array = array(
		'capture' => array(
			'label'         => esc_html( __( 'Activate the Abandoned cart Pop-Up', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
			'description'   => esc_html( __( 'Display a popup to collect emails from non-registered users and obtain their consent to track and save their cart, in compliance with GDPR (if enabled), before they leave the website.', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
			'name'          => 'pixelio-cart-abandon-recovery-more-capture-email-checkbox',
			'onshow'      => 'pixelio-cart-abandon-recovery-more-use-promo-code-checkbox',
			'pro'           => false,
			'preview'       => true,
			'edit'          => false,
			'preview_class' => Pixelio_Cart_Abandon_Recovery_More_Util::$pixelio_plugin_class_slug . '-capture-users-mail-popup',
			'edit_class'    => '',
			'dependency'    => '',
		),
		'first'   => array(
			'label'       => __( 'Allow Promo Code Generation in the Abandoned cart Pop-up','rivio-ai-cart-recovery-marketing-email-automation' ),
			'description' => __( 'Activate and set a promo code in the abandoned cart Pop-up.','rivio-ai-cart-recovery-marketing-email-automation'),
			'name'        => 'pixelio-cart-abandon-recovery-more-use-promo-code-checkbox',
			'dependency'  => 'pixelio-cart-abandon-recovery-more-capture-email-checkbox',
			'onshow'      => 'pixelio-cart-abandon-recovery-more-use-promo-code-percent',
			'pro'           => false,
			'preview'       => false,
			'edit'          => false,
			'preview_class' => '',
			'edit_class'    => '',
		),
		'inputDelivery'   => array(
			'label'       => __( 'Display an input to estimate delivery fees' ,'rivio-ai-cart-recovery-marketing-email-automation'),
			'description' => __( 'Enable this option to allow users to calculate delivery costs directly from the product page.' ,'rivio-ai-cart-recovery-marketing-email-automation'),
			'name'        => 'pixelio-cart-abandon-recovery-more-delivery-fee-checkbox',
			'dependency'  => '',
			'onshow'      => '',
			'pro'           => false,
			'preview'       => false,
			'edit'          => false,
			'preview_class' => '',
			'edit_class'    => '',
		),
		'wishList' => array(
			'label'       => __( 'Enable wishlist on the product page' ,'rivio-ai-cart-recovery-marketing-email-automation'),
			'description' => __( 'Allow visitors to save products to a wishlist without creating an account. This helps increase retention, reduce abandonment, and capture emails from anonymous users more effectively.','rivio-ai-cart-recovery-marketing-email-automation' ),
			'name'        => 'pixelio-cart-abandon-recovery-more-wishlist-checkbox',
			'dependency'  => '',
			'onshow'      => '',
			'pro'         => false,
			'preview'     => false,
			'edit'        => false,
			'preview_class' => '',
			'edit_class'    => '',
		),
	);
	foreach ( $pixelio_cart_abandon_recovery_more_first_two_checkbox_array as $pixelio_cart_abandon_recovery_more_key => $pixelio_cart_abandon_recovery_more_value ) {
		$pixelio_cart_abandon_recovery_more_checkbox = new Pixelio_Cart_Abandon_Recovery_More_Checkbox( $pixelio_cart_abandon_recovery_more_value['label'], $pixelio_cart_abandon_recovery_more_value['description'], $pixelio_cart_abandon_recovery_more_value['name'], $pixelio_cart_abandon_recovery_more_value['pro'], $pixelio_cart_abandon_recovery_more_value['preview'], $pixelio_cart_abandon_recovery_more_value['edit'], $pixelio_cart_abandon_recovery_more_value['preview_class'], $pixelio_cart_abandon_recovery_more_value['edit_class'], $pixelio_cart_abandon_recovery_more_value['dependency'], false, '', '', $pixelio_cart_abandon_recovery_more_value['onshow'] );
		$pixelio_cart_abandon_recovery_more_checkbox->pixelio_cart_abandon_recovery_more_get_views();
		$pixelio_cart_abandon_recovery_more_saved_settings[] = $pixelio_cart_abandon_recovery_more_checkbox->get_saved_value();
	}
	$pixelio_cart_abandon_recovery_more_discount_percent_for_promo_code = new Pixelio_Cart_Abandon_Recovery_More_Input_Text(
		esc_html( __( 'Maximum Discount Allowed', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
		esc_html( __( 'Set the discount you allow for cart recovery. If left empty, our algorithm will optimize it automatically. (Only used in abandon pop-up)', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
		esc_html( __( 'Please provide an discount value between 1 and 99 followed by the percent or by €', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
		'pixelio-cart-abandon-recovery-more-use-promo-code-percent',
		'pixelio-cart-abandon-recovery-more-use-promo-code-checkbox',
		0
	);
	$pixelio_cart_abandon_recovery_more_discount_percent_for_promo_code->pixelio_cart_abandon_recovery_more_get_views();
	$pixelio_cart_abandon_recovery_more_saved_settings[]         = $pixelio_cart_abandon_recovery_more_exit_popup_discount->get_saved_value();
	$pixelio_cart_abandon_recovery_more_first_two_checkbox_array = array(
		'stock' => array(
			'label'         => esc_html( __( 'Show Stock on Product Page', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
			'description'   => wp_kses_post( __( 'Display the available stock on the product page with a subtle urgency message to encourage purchases.', 'rivio-ai-cart-recovery-marketing-email-automation' )."<b>".__( '(Managing stock should be activated as prerequisite on the product)', 'rivio-ai-cart-recovery-marketing-email-automation' )."</b>" ),
			'name'          => 'pixelio-cart-abandon-recovery-more-show-stock-hurry-up-checkbox',
			'pro'           => true,
			'onshow'        => '',
			'preview'       => false,
			'edit'          => false,
			'preview_class' => '',
			'edit_class'    => '',
			'dependency'    => '',
		),
		'timer' => array(
			'label' => esc_html__(
				'Enable Cart Countdown Timer',
				'rivio-ai-cart-recovery-marketing-email-automation'
			),

			'description' => esc_html__(
				'Display a countdown timer on the cart page to create urgency and encourage customers to complete their purchase before the offer expires.',
				'rivio-ai-cart-recovery-marketing-email-automation'
			),
			'onshow'        => 'pixelio-cart-abandon-recovery-more-show-timer-in-cart-hurry-up-checkbox-position',
			'name'          => 'pixelio-cart-abandon-recovery-more-show-timer-in-cart-hurry-up-checkbox',
			'pro'           => true,
			'preview'       => false,
			'edit'          => false,
			'preview_class' => '',
			'edit_class'    => '',
			'dependency'    => '',
		),
	);
	foreach ( $pixelio_cart_abandon_recovery_more_first_two_checkbox_array as $pixelio_cart_abandon_recovery_more_key => $pixelio_cart_abandon_recovery_more_value ) {
		$pixelio_cart_abandon_recovery_more_checkbox = new Pixelio_Cart_Abandon_Recovery_More_Checkbox(
			$pixelio_cart_abandon_recovery_more_value['label'],
			$pixelio_cart_abandon_recovery_more_value['description'],
			$pixelio_cart_abandon_recovery_more_value['name'],
			$pixelio_cart_abandon_recovery_more_value['pro'],
			$pixelio_cart_abandon_recovery_more_value['preview'],
			$pixelio_cart_abandon_recovery_more_value['edit'],
			$pixelio_cart_abandon_recovery_more_value['preview_class'],
			$pixelio_cart_abandon_recovery_more_value['edit_class'],
			$pixelio_cart_abandon_recovery_more_value['dependency'],
			false,
			'',
			'',
			$pixelio_cart_abandon_recovery_more_value['onshow']
		);
		$pixelio_cart_abandon_recovery_more_checkbox->pixelio_cart_abandon_recovery_more_get_views();
		$pixelio_cart_abandon_recovery_more_saved_settings[] = $pixelio_cart_abandon_recovery_more_checkbox->get_saved_value();
	}
	$pixelio_cart_abandon_recovery_more_radio_button =
		new Pixelio_Cart_Abandon_Recovery_More_Radio_Button(
			__( 'Cart Timer Position', 'rivio-ai-cart-recovery-marketing-email-automation' ),
			__( 'Choose where the countdown timer should be displayed on the cart page.', 'rivio-ai-cart-recovery-marketing-email-automation' ),
			'pixelio-cart-abandon-recovery-more-show-timer-in-cart-hurry-up-checkbox-position',
			false,
			array(
				__( 'Top', 'rivio-ai-cart-recovery-marketing-email-automation' ),
				__( 'Bottom', 'rivio-ai-cart-recovery-marketing-email-automation' )
			),
			'pixelio-cart-abandon-recovery-more-show-timer-in-cart-hurry-up-checkbox'
		);
	$pixelio_cart_abandon_recovery_more_radio_button->pixelio_cart_abandon_recovery_more_get_views();
	$pixelio_cart_abandon_recovery_more_saved_settings[] = $pixelio_cart_abandon_recovery_more_radio_button->get_saved_value();
	?>

	<?php
	$pixelio_cart_abandon_recovery_more_first_two_checkbox_array = array(
		'buy'            => array(
			'label'       => esc_html__(
				'Show Recent Purchase Notifications',
				'rivio-ai-cart-recovery-marketing-email-automation'
			),
			'description' => esc_html__(
				'Display subtle real-time notifications when customers purchase products from your store. Build trust, create social proof, and encourage hesitant visitors to complete their purchase.',
				'rivio-ai-cart-recovery-marketing-email-automation'
			),
			'name'          => 'pixelio-cart-abandon-recovery-more-show-others-buy-checkbox',
			'pro'           => true,
			'preview'       => true,
			'edit'          => false,
			'preview_class' => Pixelio_Cart_Abandon_Recovery_More_Util::$pixelio_plugin_class_slug . '-bought-message-popup',
			'edit_class'    => '',
			'dependency'    => '',
			'onshow'        => 'pixelio-cart-abandon-recovery-more-show-others-buy-only-product-checkbox',
		),
		'buy_on_product' => array(
			'label'         => esc_html( __( 'Display on Product Page Only', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
			'description' => esc_html__(
				'Show real-time purchase notifications on product pages only. Increase buyer confidence with social proof and create urgency by highlighting recent customer purchases.',
				'rivio-ai-cart-recovery-marketing-email-automation'
			),
			'name'          => 'pixelio-cart-abandon-recovery-more-show-others-buy-only-product-checkbox',
			'pro'           => true,
			'preview'       => false,
			'edit'          => false,
			'preview_class' => '',
			'edit_class'    => '',
			'dependency'    => 'pixelio-cart-abandon-recovery-more-show-others-buy-checkbox',
			'onshow'        => '',
		),
	);
	foreach ( $pixelio_cart_abandon_recovery_more_first_two_checkbox_array as $pixelio_cart_abandon_recovery_more_key => $pixelio_cart_abandon_recovery_more_value ) {
		$pixelio_cart_abandon_recovery_more_checkbox = new Pixelio_Cart_Abandon_Recovery_More_Checkbox( $pixelio_cart_abandon_recovery_more_value['label'], $pixelio_cart_abandon_recovery_more_value['description'], $pixelio_cart_abandon_recovery_more_value['name'], $pixelio_cart_abandon_recovery_more_value['pro'], $pixelio_cart_abandon_recovery_more_value['preview'], $pixelio_cart_abandon_recovery_more_value['edit'], $pixelio_cart_abandon_recovery_more_value['preview_class'], $pixelio_cart_abandon_recovery_more_value['edit_class'], $pixelio_cart_abandon_recovery_more_value['dependency'], false, '', '', $pixelio_cart_abandon_recovery_more_value['onshow'] );
		$pixelio_cart_abandon_recovery_more_checkbox->pixelio_cart_abandon_recovery_more_get_views();
		$pixelio_cart_abandon_recovery_more_saved_settings[] = $pixelio_cart_abandon_recovery_more_checkbox->get_saved_value();
	}
	$pixelio_cart_abandon_recovery_more_radio_button = new Pixelio_Cart_Abandon_Recovery_More_Radio_Button( __( 'Position of the popup', 'rivio-ai-cart-recovery-marketing-email-automation' ), __( 'Do you want it to fix in the left or right', 'rivio-ai-cart-recovery-marketing-email-automation' ), 'pixelio-cart-abandon-recovery-more-show-others-buy-checkbox-position', false, array( 'Right', 'Left' ), 'pixelio-cart-abandon-recovery-more-show-others-buy-checkbox' );
	$pixelio_cart_abandon_recovery_more_radio_button->pixelio_cart_abandon_recovery_more_get_views();
	$pixelio_cart_abandon_recovery_more_saved_settings[]         = $pixelio_cart_abandon_recovery_more_radio_button->get_saved_value();

	$pixelio_cart_abandon_recovery_more_google_recaptcha = new Pixelio_Cart_Abandon_Recovery_More_Input_Text(
		esc_html( __( 'Google ReCaptcha API key', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
		esc_html( __( 'You can find your own licence key on Google Recaptcha website', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
		esc_html( __( 'Please provide your Google Recaptcha API key', 'rivio-ai-cart-recovery-marketing-email-automation' ) ),
		'pixelio-cart-abandon-recovery-more-google-recaptcha',
		'pixelio-cart-abandon-recovery-more-google-recaptcha-checkbox',
		1,
		true
	);
	$pixelio_cart_abandon_recovery_more_google_recaptcha->pixelio_cart_abandon_recovery_more_get_views();

	$pixelio_cart_abandon_recovery_more_saved_settings[] = $pixelio_cart_abandon_recovery_more_discount_percent_for_promo_code->get_saved_value();

	$pixelio_cart_abandon_recovery_more_saved_settings[] = $pixelio_cart_abandon_recovery_more_google_recaptcha->get_saved_value();
	?>

</div>
