<?php

use Prodigy\Includes\Prodigy_User as User;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<input type="hidden" id="my-account-widget-options-js" value='<?php echo esc_attr( wp_json_encode( $args ?? array() ) ); ?>' >
	<?php if ( $is_redemption_store || $impersonation ) : ?>
		<?php if ( $is_elementor_header ) : ?>
	<div class="prodigy-navbar-account__wrap prodigy-custom-template <?php echo esc_attr( $container_class ); ?>"
		id="my-account">
		<?php else : ?>
		<li class="prodigy-navbar-account__wrap prodigy-custom-template <?php echo esc_attr( $container_class ); ?>"
			id="my-account">
			<?php endif; ?>
			<div class="prodigy-navbar-account__wrap-inner prodigy-dropdown-account__inner-wrap">
				<?php if ( User::is_logged_in() ) : ?>
					<?php if ( $impersonation ) : ?>
						<?php do_action( 'prodigy_product_get_impersonation' ); ?>
					<?php endif; ?>
					<button class="prodigy-navbar-account d-flex p-0"
							type="button"
							aria-haspopup="dialog"
							aria-expanded="false"
							id="my-account-toggle"
							aria-controls="prodigy-account-menu"
							aria-label="<?php esc_attr_e( 'Open account menu', 'prodigy-commerce' ); ?>">
					<span class="prodigy-navbar-user">
						<?php if ( ! empty( $args['icon_utf'] ) ) : ?>
							<span class="divi-icon-output prodigy-navbar-account__icon"
									data-icon-type="<?php echo esc_attr( $args['icon_type'] ); ?>"
									data-icon-utf="<?php echo esc_url( $args['icon_utf'] ); ?>"
									data-icon-font-weight="<?php echo esc_attr( $args['icon_weight'] ); ?>"
									data-icon="<?php echo esc_attr( $args['icon_utf'] ); ?>">
							</span>
						<?php elseif ( empty( $args['icon_type'] ) ) : ?>
							<i class="<?php echo esc_attr( $args['icon_class'] ?? 'icon icon-user' ); ?> icon icon-user prodigy-navbar-account__icon" aria-hidden="true" role="presentation"></i>
						<?php endif; ?>
						<?php if ( isset( $args['icon_type'] ) && $args['icon_type'] === 'icon' ) : ?>
							<i class="<?php echo esc_attr( $args['icon_class'] ?? '' ); ?> " aria-hidden="true" role="presentation"></i>
						<?php elseif ( isset( $args['icon_type'] ) && $args['icon_type'] === 'svg' ) : ?>
							<img class="<?php echo esc_attr( $args['icon_svg_class'] ); ?>"
								src="<?php echo esc_attr( $args['my_account_icon_url'] ); ?>" aria-hidden="true" role="presentation" alt="<?php esc_attr_e( 'Account Icon', 'prodigy-commerce' ); ?>">
						<?php endif; ?>
					</span>
						<span class="prodigy-navbar-user__status">
						<?php echo esc_html( $args['heading_text'] ?? '' ); ?>
					</span>
					</button>
				<?php else : ?>
					<button aria-label="<?php esc_attr_e( 'Login in order to open account menu', 'prodigy-commerce' ); ?>"
							class="prodigy-navbar-account d-flex p-0 user-login-js"
							type="button">
					<span class="prodigy-navbar-user">
						<?php if ( isset( $args['icon_type'] ) && $args['icon_type'] === 'icon' ) : ?>
							<i class="<?php echo esc_attr( $args['icon_class']['value'] ?? '' ); ?> " aria-hidden="true" role="presentation"></i>
						<?php elseif ( isset( $args['icon_type'] ) && $args['icon_type'] === 'svg' ) : ?>
							<img class="<?php echo esc_attr( $args['icon_svg_class'] ); ?>"
								src="<?php echo esc_attr( $args['my_account_icon_url'] ); ?>" aria-hidden="true" role="presentation" alt="<?php esc_attr_e( 'Account Icon', 'prodigy-commerce' ); ?>">
						<?php endif; ?>

						<?php if ( empty( $args['icon_class']['value'] ) ) : ?>
							<i class="icon icon-user prodigy-navbar-account__icon" aria-hidden="true" role="presentation"></i>
						<?php endif; ?>
					</span>
						<span class="prodigy-navbar-user__status"><?php esc_html_e( 'Login', 'prodigy-commerce' ); ?></span>
					</button>
				<?php endif; ?>

				<div id="my-account-widget-js"><?php do_action( 'prodigy_shortcode_template_my_account_main_content', $args ); ?></div>
				
			</div>
		<?php if ( $is_elementor_header ) : ?>
			</div>
		<?php else : ?>
			</li>
		<?php endif; ?>
	<?php endif; ?>
