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

<?php
/**
 * @var WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\Prompt $block
 */
$credits = $block->getCredits();
$rules = $block->getRules();
?>

<span id="wtaiGenerateButton" data-bind="scope: 'wtaiGenerateButton'"
    data-mage-init='{"WriteTextAI_WriteTextAI/js/grid/massactions/prompt/generate-button": {
        "credits": <?= $escaper->escapeHtmlAttr(json_encode($credits)) ?>,
        "maxReferenceTextLength": <?= /* @noEscape */ $rules['maxReferenceTextLength'] ?? '' ?>,
        "additionalReferenceTextLength": <?= /* @noEscape */ $rules['additionalReferenceTextLength'] ?? '' ?>,
        "maxOutputWords": <?= /* @noEscape */ $rules['maxOutputWords'] ?? '' ?>,
        "maxImageAltTextPerRequest": <?= /* @noEscape */ $rules['maxImageAltTextPerRequest'] ?? '' ?>
    }}'>
    <span data-bind="visible: isGenerating"><?= $escaper->escapeHtml(__('Generate selected')) ?></span>
</span>
<script>
    require([
        "jquery"
    ], function($) {
        $("#wtaiGenerateButton").trigger('contentUpdated');
    });
</script>
