<?php
/**
 * Account page settings meta box
 * @var array $system_roles
 * @var array $meta_roles
 */

use HulkPlugins\Woo\AccountPages\Admin\Services\AccountPagesService;
use function HulkPlugins\Woo\AccountPages\hulk_woo_ap_fs;
use function HulkPlugins\Woo\AccountPages\hulk_woo_ap_fs_notice;

defined( 'ABSPATH' ) || exit;

$can_use_premium_code = hulk_woo_ap_fs()->can_use_premium_code();

$inlineStyle = /** @lang text */'
	.hulk-woo-ap-metabox.premium_false fieldset {
		filter: grayscale(1);
		user-select: none;
		pointer-events: none;
	}
';
$accountService = AccountPagesService::getInstance();
$accountService->addInlineStyle( $inlineStyle );
?>
<div class="hulk-woo-ap-metabox <?php echo $can_use_premium_code ? 'premium_true' : 'premium_false'; ?>">
	<fieldset style="margin-top: 15px;">
		<legend><?php esc_html_e( 'Show this page for the following selected user roles:', 'hulk-account-pages-for-woocommerce' ); ?></legend>
		<ul>
			<?php
			foreach ( $system_roles as $key => $system_role ) {
				$selected_role = in_array( $key, $meta_roles, true );
				printf(
                    /** @lang text */                    '<li><label><input type="checkbox" name="hulk_woo_ap_user_roles[]" value="%s" %s> %s</label></li>',
					esc_attr( $key ),
					checked( 1, $selected_role, false ),
					esc_attr( $system_role )
				);
			}
			?>
		</ul>
	</fieldset>
	<?php echo wp_kses_post( hulk_woo_ap_fs_notice() ); ?>
</div>
