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

<?php
/** @var \Magento\Backend\Block\Template $block */

$permissions = $block->getPermissions();
?>

<div class="wtai-wtai-additional-prompt" data-bind="scope: 'wtaiAdditionalPrompt'">
    <div class="wtai-additional-prompt-container"
        data-bind="css: { 'wtai-disabled': !isGenerateAllowed }">
        <p class="wtai-header-details">
            <?= $escaper->escapeHtml(__('Use a comma to separate details.')) ?>
        </p>
        <textarea name="additional_prompt" id="additional_prompt" class="wtai-textarea"
            data-bind="
                textInput: promptValue,
                event: { blur: handleInputAdditionalPrompt },
                attr: { maxlength: promptMaxLength },
                disable: !isGenerateAllowed
            "
        ></textarea>
        <div class="wtai-footer-details">
            <p class="wtai-text-length" data-bind="text: getAdditionalPromptLength()"></p>
        </div>
    </div>
</div>

<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "wtaiAdditionalPrompt": {
                        "component": "WriteTextAI_WriteTextAI/js/edit/additional-prompt",
                        "saveAdditionalPromptUrl":
                            "<?= $escaper->escapeJs($block->getUrl('wtai/settings/saveAdditionalPrompt')) ?>",
                        "entityType": "Category",
                        "isGenerateAllowed":
                            <?= /* @noEscape */ $permissions->isGenerateAllowed() ? 'true' : 'false' ?>
                    }
                }
            }
        }
    }
</script>