<?php
/**
 * @author 1902 Software
 * @copyright Copyright © 2023 1902 Software (https://1902software.com/magento/)
 * @package WriteTextAI_WriteTextAI
 */
?>

<?php
    use WriteTextAI\WriteTextAI\ViewModel\Premium;
?>

<?php
    /** @var Premium $premium */
    $premium = $block->getPremium();
    $getUnlockedProfessional = $premium->getUnlockedProfessional();
    $hasProAccess = $premium->getHasProAccess();
    $membershipType = $premium->getMembershipType();
    $showByApi = $getUnlockedProfessional && $hasProAccess && $membershipType === Premium::MEMBERSHIP_TYPE_PROFESSIONAL;

    $showPopup = $showByApi;
?>

<div class="wtai-welcome-pro-popup-modal" data-bind="scope: 'wtaiWelcomeProPopup'" style="display: none;">
    <div class="wtai-popup-content">
        <div class="wtai-popup-image">
            <img src="<?= $block->getViewFileUrl('WriteTextAI_WriteTextAI/images/welcome_banner.png') ?>" alt="Welcome to Pro">
        </div>
        <div class="wtai-popup-text">
            <div class="wtai-popup-title">
                <?= /* @noEscape */ __("You’re now on Pro!") ?>
            </div>
            <div>
                <p>
                    <?= /* @noEscape */ __("Enjoy enhanced features and more powerful tools to make your content shine.") ?>
                </p>
                <p class="wtai-check-item">
                    <span class="wtai-check-icon"></span>
                    <span>
                        <?= /* @noEscape */ __("Keyword optimization pipeline") ?>
                    </span>
                </p>
                <p class="wtai-check-item">
                    <span class="wtai-check-icon"></span>
                    <span>
                        <?= /* @noEscape */ __("Ability to do full automation") ?>
                    </span>
                </p>
                <p class="wtai-check-item">
                    <span class="wtai-check-icon"></span>
                    <span>
                        <?= /* @noEscape */ __("Automated monthly content updates") ?>
                    </span>
                </p>
                <p class="wtai-check-item">
                    <span class="wtai-check-icon"></span>
                    <span>
                        <?= /* @noEscape */ __("Custom prompts in Templates") ?>
                    </span>
                </p>
                <p>
                    <?= /* @noEscape */ __("Start generating text by clicking on a product.") ?>
                </p>
            </div>
            <div class="wtai-popup-buttons">
                <button type="button" class="action-primary primary" data-bind="click: closeProPopup">
                    <?= $block->escapeHtml(__('Got it')) ?>
                </button>
            </div>
        </div>
    </div>
</div>
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "wtaiWelcomeProPopup": {
                        "component": "WriteTextAI_WriteTextAI/js/popups/welcome-pro",
                        "saveUrl": "<?= $block->escapeJs($block->getUrl('wtai/settings/popups')) ?>",
                        "showPopupOnLoad": <?= /* @noEscape */ $showPopup ? 'true' : 'false' ?>
                    }
                }
            }
        }
    }
</script>