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

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

$transferSettings = $block->getTransferSettings();
$tooltip = $block->getTooltip();
$permissions = $block->getPermissions();
$fields = $block->getFields();

$customOpenGraph = $fields->getCustomOpenGraph();
?>
<div class="wtai-buttons page-actions" data-bind="scope: 'wtaiEditButtons'" >
    <div class="page-actions-buttons">
        <div class="wtai-step-wrapper">
            <span class="wtai-step" data-bind="hidden: guideSteps">
                <?= $block->escapeHtml(__('Step 5')) ?>
            </span>
        </div>
        <?= /* @noEscape */ $block->getChildHtml(); ?>
        <hr class="wtai-line-break"/>
        <?php if ($permissions->isEditAllowed()): ?>
            <button type="button"
                class="action-default scalable wtai-save action-secondary"
                data-bind="click: save, disable: !canSave()"
            >
                <span><?= $block->escapeHtml(__("Save")) ?></span>
            </button>
        <?php endif; ?>
        <?php if ($permissions->isTransferAllowed()): ?>
            <div class="wtai-transfer-action">
                <button type="button"
                    class="action-default scalable wtai-transfer primary"
                    data-bind="
                        click: transfer,
                        disable: !canTransfer()
                    "
                >
                    <span><?= $block->escapeHtml(__("Transfer selected to Magento")) ?></span>
                </button>
                <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 wtai-upper-right" data-target="dropdown">
                            <div class="wtai-content-wrapper">
                                <?= /* @noEscape */ $tooltip->getTooltip('wtai.transfer') ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <?php endif; ?>
        <div class="wtai-edit-loading-mask"></div>
    </div>
</div>
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "wtaiEditButtons": {
                        "component": "WriteTextAI_WriteTextAI/js/edit/buttons",
                        "confirmContent": "<?= $block->escapeJs($transferSettings->getConfirmContent()) ?>",
                        "saveUrl": "<?= $block->escapeJs($block->getUrl('wtai/edit/save')) ?>",
                        "transferUrl": "<?= $block->escapeJs($block->getUrl('wtai/edit/transfer')) ?>",
                        "customOpenGraph": "<?= /* @noEscape */ $customOpenGraph ?>"
                    }
                }
            }
        }
    }
</script>
