<?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><?= $escaper->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()
            "><?= $escaper->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": "<?= $escaper->escapeJs($block->getCategoryPageTitle()) ?>",
                        "pageDescription": "<?= $escaper->escapeJs($block->getCategoryPageDescription()) ?>",
                        "categoryDescription": "<?= $escaper->escapeJs($block->getCategoryDescription()) ?>",
                        "invalidImagePopupDoNotShowAgain":
                            <?= /* @noEscape */ $block->isInvalidImagePopupDoNotShowAgain() ? 'true' : 'false' ?>,
                        "accessToken": "<?= $escaper->escapeJs($block->getAccessToken()) ?>",
                        "signalRUrl": "<?= $escaper->escapeJs($block->getSignalrUrl()) ?>",
                        "getGeneratedUrl":
                            "<?= $escaper->escapeJs($block->getUrl('wtai/categories/edit_textfields_get')) ?>",
                        "getNewAccessTokenUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/grid/token')) ?>",
                        "getOptimizationUrl":
                            "<?= $escaper->escapeJs($block->getUrl('wtai/edit/keywordsOptimization_get')) ?>",
                        "getCreditsUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/grid/getCredits')) ?>",
                        "entityType": "<?= $escaper->escapeJs($block->getEntityType()) ?>",
                        "audienceGetUrl": "<?= $escaper->escapeJs(
                            $block->getUrl('wtai/categories/edit_audience_get')
                        ) ?>"
                    }
                }
            }
        }
    }
</script>
