<?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() !== ''
            "></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/signalr",
                        "pageTitle": "<?= $block->escapeJs($block->getPageTitle()) ?>",
                        "pageDescription": "<?= $block->escapeJs($block->getPageDescription()) ?>",
                        "productDescription": "<?= $block->escapeJs($block->getProductDescription()) ?>",
                        "excerpt": "<?= $block->escapeJs($block->getExcerpt()) ?>",
                        "openGraph": "<?= $block->escapeJs($block->getOpenGraph()) ?>",
                        "accessToken": "<?= $block->escapeJs($block->getAccessToken()) ?>",
                        "signalRUrl": "<?= $block->escapeJs($block->getSignalrUrl()) ?>",
                        "getGeneratedUrl": "<?= $block->escapeJs($block->getUrl('wtai/edit/textfields_get')) ?>",
                        "getNewAccessTokenUrl": "<?= $block->escapeJs($block->getUrl('wtai/grid/token')) ?>",
                        "getImagesUrl": "<?= $block->escapeJs($block->getUrl('wtai/image/get')) ?>",
                        "getOptimizationUrl":
                            "<?= $block->escapeJs($block->getUrl('wtai/edit/keywordsOptimization_get')) ?>",
                        "getCreditsUrl": "<?= $block->escapeJs($block->getUrl('wtai/grid/getCredits')) ?>",
                        "getOptimizationListUrl":
                            "<?= $block->escapeJs($block->getUrl('wtai/edit/keywordsOptimization_getList')) ?>",
                        "isSingleRequestUrl": "<?= $block->escapeJs($block->getUrl('wtai/edit/isSingleRequest')) ?>",
                        "removeSingleRequestUrl":
                            "<?= $block->escapeJs($block->getUrl('wtai/edit/removeSingleRequest')) ?>",
                        "getBulkRequestsUrl": "<?= $block->escapeJs($block->getUrl('wtai/grid/getBulkRequests')) ?>",
                        "entityType": "<?= $block->escapeJs($block->getEntityType()) ?>",
                        "audienceGetUrl": "<?= $block->escapeJs($block->getUrl('wtai/edit/audience_get')) ?>"
                    }
                }
            }
        }
    }
</script>
