<?php
/**
 * @author 1902 Software
 * @copyright Copyright © 2023 1902 Software (https://1902software.com/magento/)
 * @package WriteTextAI_WriteTextAI
 */
?>
<div class="wtai-signalr" data-bind="scope: 'wtaiSignalr'">
    <div class="wtai-generate-message wtai-no-display" data-bind="css: {
        'wtai-no-display': !showMessage(),
        'wtai-success': messageSuccess,
        'wtai-error': !messageSuccess()
    }">
        <div class="wtai-content">
            <span class="wtai-message" data-bind="html: message"></span>
            <div class="wtai-action">
                <button class="wtai-close" data-bind="click: hideMessage">
                    <span><?= $block->escapeHtml(__('Ok')) ?></span>
                </button>
            </div>
        </div>
        <div class="wtai-footer">
            <span class="wtai-error-message" data-bind="
                html: errorMessage,
                visible: errorMessage() !== '' && !(invalidImagePopupDoNotShowAgain || window.wtaiInvalidImagePopupDoNotShowAgain)
            "></span>
            <span data-bind="
                visible: messageSuccess()
            "><?= $block->escapeHtml(__("Please remember to check the output for any factual mistakes"
                . " or inaccuracies before you publish the text to your live site.")) ?></span>
        </div>
    </div>
</div>
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "wtaiSignalr": {
                        "component": "WriteTextAI_WriteTextAI/js/categories/signalr",
                        "pageTitle": "<?= $block->escapeJs($block->getCategoryPageTitle()) ?>",
                        "pageDescription": "<?= $block->escapeJs($block->getCategoryPageDescription()) ?>",
                        "categoryDescription": "<?= $block->escapeJs($block->getCategoryDescription()) ?>",
                        "invalidImagePopupDoNotShowAgain": <?= /* @noEscape */ $block->isInvalidImagePopupDoNotShowAgain() ? 'true' : 'false' ?>,
                        "accessToken": "<?= $block->escapeJs($block->getAccessToken()) ?>",
                        "signalRUrl": "<?= $block->escapeJs($block->getSignalrUrl()) ?>",
                        "getGeneratedUrl":
                            "<?= $block->escapeJs($block->getUrl('wtai/categories/edit_textfields_get')) ?>",
                        "getNewAccessTokenUrl": "<?= $block->escapeJs($block->getUrl('wtai/grid/token')) ?>",
                        "getOptimizationUrl":
                            "<?= $block->escapeJs($block->getUrl('wtai/edit/keywordsOptimization_get')) ?>",
                        "getCreditsUrl": "<?= $block->escapeJs($block->getUrl('wtai/grid/getCredits')) ?>",
                        "entityType": "<?= $block->escapeJs($block->getEntityType()) ?>",
                        "audienceGetUrl": "<?= $block->escapeJs($block->getUrl('wtai/categories/edit_audience_get')) ?>"
                    }
                }
            }
        }
    }
</script>
