<div class="wcpdf-cloud-service-connection">

	<div class="wcpdf-cloud-service-connection__header">
		<div class="service-logo">
			<?php echo $service_logo; ?>
			<span class="service-name"><?php echo esc_html( $service_name ); ?></span>
		</div>

		<?php if ( ! empty( $service_api_settings['account_info'] ) ) : ?>
			<span class="connected-badge">
				<?php esc_html_e( 'Connected', 'wpo_wcpdf_pro' ); ?>
			</span>
		<?php endif; ?>
	</div>

	<div class="wcpdf-cloud-service-connection__body">
		<?php if ( ! empty( $service_api_settings['account_info'] ) ) : ?>
			<div class="wcpdf-cloud-service-connection__row">
				<div class="wcpdf-cloud-service-connection__label">
					<?php esc_html_e( 'Account', 'wpo_wcpdf_pro' ); ?>
				</div>
				<div class="wcpdf-cloud-service-connection__value">
					<span class="account"><?php echo $service_api_settings['account_info']; ?></span>
				</div>
			</div>
			<div class="wcpdf-cloud-service-connection__row">
				<div class="wcpdf-cloud-service-connection__label">
					<?php esc_html_e( 'Destination', 'wpo_wcpdf_pro' ); ?>
				</div>
				<div class="wcpdf-cloud-service-connection__value">
					<span class="destination"><code><?php echo $destination_prefix; ?><?php echo $destination_folder; ?></code></span>
				</div>
			</div>
		<?php endif; ?>
		
		<?php if ( isset( $service_api_settings['expires_in'] ) && isset( WPO_WCPDF()->settings->debug_settings['manually_refresh_tokens'] ) ) : ?>
			<div class="wcpdf-cloud-service-connection__row">
				<div class="wcpdf-cloud-service-connection__label">
					<?php esc_html_e( 'Token', 'wpo_wcpdf_pro' ); ?>
				</div>
				<div class="wcpdf-cloud-service-connection__value">
					<?php esc_html_e( 'Expires on', 'wpo_wcpdf_pro' ); ?> <?php echo date_i18n( 'Y-m-d H:i:s', $service_api_settings['expires_in'] ); ?>
				</div>
			</div>
		<?php endif; ?>

		<div class="wcpdf-cloud-service-connection__row">
			<div class="wcpdf-cloud-service-connection__label">
				<?php esc_html_e( 'Actions', 'wpo_wcpdf_pro' ); ?>
			</div>

			<div class="wcpdf-cloud-service-connection__value">
				<div id="unlink">
					<input type="checkbox" id="delete_refresh_token" name="delete_refresh_token" value="1">
					<span><?php esc_html_e( 'Delete refresh token on unlinking', 'wpo_wcpdf_pro' ); ?></span>
					<?php
						echo wc_help_tip(
							sprintf(
								/* translators: service name */
								__( 'Do this only if you intend to authenticate with a different %s account or if you no longer plan to use this feature.', 'wpo_wcpdf_pro' ),
								$service_name
							),
							true
						);
					?>
				</div>

				<?php wp_nonce_field( 'generate_wpo_wcpdf', '_wpnonce' ); ?>

				<a href="<?php echo esc_url( $unlink_url ); ?>" class="button">
					<?php
						printf(
							/* translators: service name */
							esc_html__( 'Unlink %s account', 'wpo_wcpdf_pro' ),
							$service_name
						);
					?>
				</a>

				<?php if ( isset( $service_api_settings['expires_in'] ) && isset( WPO_WCPDF()->settings->debug_settings['manually_refresh_tokens'] ) ) : ?>
					<a href="<?php echo esc_url( $refresh_token_ajax_url ); ?>" class="button">
						<?php esc_html_e( 'Refresh token', 'wpo_wcpdf_pro' ); ?>
					</a>
				<?php endif; ?>
			</div>
		</div>
	</div>
</div>
