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

<?php
/** @var \WriteTextAI\WriteTextAI\ViewModel\Tooltip $tooltip */
/** @var \WriteTextAI\WriteTextAI\ViewModel\Permissions $permissions */
/** @var \WriteTextAI\WriteTextAI\ViewModel\Fields $fields */

$tooltip = $block->getTooltip();
$permissions = $block->getPermissions();
$fields = $block->getFields();
?>
<div class="wtai-mark-reviewed page-actions-buttons wtai-input-wrapper" data-bind="scope: 'wtaiMarkReviewed'">
    <?php if ($permissions->isReviewAllowed()): ?>
        <input type="checkbox"
            class="admin__control-checkbox"
            name="reviewed"
            id="wtaiReviewed"
            data-bind="checked: reviewed, disable: !canReview(), css: { 'wtai-disabled': !canReview() }"
        />
        <label class="action-default action" for="wtaiReviewed" data-bind="css: { 'wtai-disabled': !canReview() }">
            <span><?= $escaper->escapeHtml(__('Mark as reviewed')) ?></span>
        </label>
        <div class="wtai-tooltip-wrapper">
            <div class="admin__field-tooltip wtai-small">
                <a class="admin__field-tooltip-action" href="#" data-toggle="dropdown"></a>
                <div class="admin__field-tooltip-content" data-target="dropdown">
                    <div class="wtai-content-wrapper"><?= /* @noEscape */ $tooltip->getReviewedTooltip() ?></div>
                </div>
            </div>
        </div>
    <?php endif; ?>
</div>
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "wtaiMarkReviewed": {
                        "component": "WriteTextAI_WriteTextAI/js/edit/mark-reviewed",
                        "markReviewUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/edit/mark_reviewed')) ?>",
                        "isReviewAllowed": <?= $escaper->escapeJs(
                            $permissions->isReviewAllowed() ? 'true' : 'false'
                        ) ?>,
                        "customOpenGraph": <?= $escaper->escapeJs($fields->getCustomOpenGraph() ? 'true' : 'false') ?>
                    }
                }
            }
        }
    }
</script>
