<?php
namespace Prodigy\Includes\Frontend\Mappers;

use Prodigy\Includes\Frontend\Shortcodes\Prodigy_Short_Code_My_Account;
use Prodigy\Includes\Helpers\Prodigy_Cookies;
use Prodigy\Includes\Helpers\Prodigy_Platform_Settings;
use Prodigy\Includes\Helpers\Prodigy_Url_Helper;
use Prodigy\Includes\Prodigy_Elementor_Template_Loader;
use Prodigy\Includes\Prodigy_User;

/**
 * Prodigy my account data mapper
 *
 * @version    3.2.4
 * @package    Prodigy
 * @subpackage Prodigy/includes
 */
class Prodigy_My_Account_Data_Mapper extends Prodigy_Main_Data_Mapper {


	/** @var Prodigy_Cookies  */
	public Prodigy_Cookies $cookie_helper;

	/**
	 * @param Prodigy_Cookies $cookie_helper
	 */
	public function __construct( Prodigy_Cookies $cookie_helper ) {
		parent::__construct();
		$this->cookie_helper = $cookie_helper;
	}

	/**
	 * @param array $options
	 *
	 * @return array
	 * @throws \Exception
	 */
	public function get_default_parameters( array $options ): array {
		if ( ! empty( $options['my_account_icon_url'] ) ) {
			$options['icon_type'] = 'svg';
		}
		$options['icon_class']                        = $options['icon_class'] ?? '';
		$options['get_customer_login_url']            = esc_url( Prodigy_Url_Helper::get_url_customer_login() );
		$options['get_customer_account_url']          = esc_url( Prodigy_Url_Helper::get_url_customer_account() );
		$options['get_customer_orders_url']           = esc_url( Prodigy_Url_Helper::get_url_customer_orders() );
		$options['get_customer_addresses_url']        = esc_url( Prodigy_Url_Helper::get_url_customer_addresses() );
		$options['get_customer_payment_methods_url']  = esc_url( Prodigy_Url_Helper::get_url_customer_payments() );
		$options['get_customer_profile_settings_url'] = esc_url( Prodigy_Url_Helper::get_url_customer_profile_settings() );
		$options['get_customer_subscriptions_url']    = esc_url( Prodigy_Url_Helper::get_url_customer_subscription_settings() );
		$options['get_customer_giftcards_url']        = esc_url( Prodigy_Url_Helper::get_url_customer_balance() );
		$options['is_dropdown']                       = $options['is_dropdown'] ?? false;
		$options['container_class']                   = $options['container_class'] ?? '';
		$options['subscriptions']                     = Prodigy_Platform_Settings::is_enable_subscription_app();
		$options['customer_balance']                  = get_option( Prodigy_User::CUSTOMER_BALANCE_OPTION );
		$options['heading_text']                      = $options['heading_text'] ?? Prodigy_Short_Code_My_Account::DEFAULT_TITLE;
		$options['impersonation']                     = Prodigy_Cookies::has_cookie( Prodigy_User::IMPERSONATION_COOKIE_ID );
		$options['is_elementor_header']               = Prodigy_Elementor_Template_Loader::is_include_header_template();
		$options['is_redemption_store']               = Prodigy_Platform_Settings::is_redemption_store_status();

		return $options;
	}
}
