<?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
 */
?>
<?php
$tooltipAltTextDisabled = __(
    "Image alt text can’t run alone due to a technical limit. "
    . 'Please include another text type.'
);
?>

<div class="wtai-bulk-generate-form-container"
    data-bind="scope: 'wtaiPrompt'"
    data-mage-init='{"WriteTextAI_WriteTextAI/js/grid/massactions/prompt": {
        "getSettingsUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl(
                'wtai/settings/prompt',
                ['entity_type' => $block->getData('entity_type') ?: 'product']
            )) ?>",
        "getAiModelsUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/grid/getAiModels')) ?>",
        "saveConfigUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/settings/saveconfig')) ?>",
        "saveUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/settings/save')) ?>",
        "restoreUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/grid/restore')) ?>",
        "templateSelectionUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/settings/templateselection')) ?>",
        "templateScope": "product_grid_generate",
        "getCustomOptionsUrl":
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/grid/getCustomizableOptionsWithValues')) ?>",
        "brandVoiceSelectionUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/settings/brandvoiceselection')) ?>",
        "brandVoiceScope": "product_grid_generate"
    }}'
>
    <div class="wtai-bulk-prompt-header">
        <span class="wtai-bulk-prompt-title">
            <?= /* @noEscape */ __('Bulk generate') ?>
        </span>
            <span class="wtai-global-settings-wrapper">
                <?php if ($block->isModifyDefaultsAllowed()): ?>
                    <a href="#" data-bind="click: save">
                        <?= $escaper->escapeHtml(__('Save to global settings')) ?>
                    </a>
                    <span class="wtai-separator"> | </span>
                <?php endif; ?>
                <a href="#" data-bind="click: restore">
                    <?= $escaper->escapeHtml(__('Restore global settings')) ?>
                </a>
            </span>
    </div>
    <p class="wtai-subtitle"><?= /* @noEscape */ sprintf(
        __('Configure how you want your text to be generated.'
        . ' For Attributes, note that selecting a product attribute does not guarantee that'
        . ' it will appear in the text itself, but'
        . ' it will help guide WriteText.ai in generating more relevant text.'
        . ' You will receive an email once bulk processing is done.'
        . ' Email notification settings can be configured in your account at'
        . ' <a href="%s" target="_blank">platform.writetext.ai</a>'),
        'https://platform.writetext.ai/email-notifications/'
    ) ?>
    </p>
    <div class="wtai-tabs-error-message"></div>
    <form method="post" id="wtaiBulkGenerateForm" class="wtai-bulk-generate-form">
        <div class="wtai-form-fields">
            <div class="wtai-col wtai-col-0" id="wtaiPrompt">
                <fieldset class="wtai-fieldset">
                    <div class="wtai-fieldset-title"><?= $escaper->escapeHtml(__('Generate')) ?></div>
                    <div class="wtai-field">
                        <input type="checkbox"
                            class="admin__control-checkbox"
                            value="all"
                            id="wtaiFieldGenerateAll"
                            name="fields[]"
                            data-bind="checked: allFieldsSelected" />
                        <label class="wtai-label admin__field-label wtai-strong" for="wtaiFieldGenerateAll">
                            <?= $escaper->escapeHtml(__('Select all')) ?>
                        </label>
                    </div>
                    <!-- ko foreach: fields -->
                        <div class="wtai-field">
                            <input type="checkbox"
                                class="admin__control-checkbox wtai-generate-text-fields"
                                name="fields[]"
                                data-bind="
                                    checked: $parent.selectedFields,
                                    attr: {
                                        id: 'wtaiField' + $data.value,
                                    },
                                    value: $data.value,
                                " />
                            <label class="wtai-label admin__field-label" data-bind="
                                attr: {
                                    for: 'wtaiField' + $data.value,
                                },
                                text: $data.label
                            "></label>
                        </div>
                    <!-- /ko -->
                    <div class="wtai-field" data-bind="attr: { title: isAltTextDisabled()
                        ? '<?= $escaper->escapeHtmlAttr($tooltipAltTextDisabled) ?>' : ''},
                        css: {'wtai-not-allowed': isAltTextDisabled}">
                        <input type="checkbox"
                            class="admin__control-checkbox wtai-generate-text-fields"
                            value="alt_text"
                            id="wtaiFieldAltText"
                            name="fields[]"
                            data-bind="checked: selectedFields,
                                disable: isAltTextDisabled"
                        />
                        <label class="wtai-label admin__field-label" for="wtaiFieldAltText">
                            <?= $escaper->escapeHtml(__("Image alt text")) ?>
                        </label>
                    </div>
                    <div class="wtai-error-message"></div>
                </fieldset>
            </div>
            <hr class="wtai-mobile-divider wtai-tablet-hidden">
            <div class="data items wtai-tabs">
                <div class="item title wtai-tab-title" data-role="collapsible">
                    <a class="data switch" data-toggle="trigger" href="#wtaiTemplatesTab">
                        <?= $escaper->escapeHtml(__('Templates')) ?>
                    </a>
                </div>
                <div class="item content wtai-tab-content wtai-templates-tab"
                    data-role="content"
                    id="wtaiTemplatesTab"
                >
                    <?= /* @noEscape */ $block->createBlockContent(
                        'WriteTextAI_WriteTextAI::grid/massactions/tabs/templates.phtml',
                        \WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\Prompt::class
                    ); ?>
                </div>
                <div class="item title wtai-tab-title" data-role="collapsible">
                    <a class="data switch" data-toggle="trigger" href="#wtaiTonesStyleAudienceTab">
                        <?= $escaper->escapeHtml(__('Voice & Style')) ?>
                    </a>
                </div>
                <div class="item content wtai-tab-content" data-role="content" id="wtaiTonesStyleAudienceTab">
                    <?= /* @noEscape */ $block->createBlockContent(
                        'WriteTextAI_WriteTextAI::grid/massactions/tabs/tones_styles_audience.phtml',
                        \WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\Prompt::class,
                        true
                    ); ?>
                </div>
                <div class="item title wtai-tab-title" data-role="collapsible">
                    <a class="data switch" data-toggle="trigger" href="#wtaiAttributesTab">
                        <?= $escaper->escapeHtml(__('Product data')) ?>
                    </a>
                </div>
                <div class="item content wtai-tab-content" data-role="content" id="wtaiAttributesTab">
                    <?= /* @noEscape */ $block->createBlockContent(
                        'WriteTextAI_WriteTextAI::grid/massactions/tabs/attributes.phtml',
                        \WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\Prompt::class
                    ); ?>
                </div>
                <div class="item title wtai-tab-title" data-role="collapsible">
                    <a class="data switch" data-toggle="trigger" href="#wtaiTextLengthTab">
                        <?= $escaper->escapeHtml(__('Text length')) ?>
                    </a>
                </div>
                <div class="item content wtai-tab-content wtai-text-length-tab"
                    data-role="content"
                    id="wtaiTextLengthTab"
                >
                    <?= /* @noEscape */ $block->createBlockContent(
                        'WriteTextAI_WriteTextAI::grid/massactions/tabs/text_length.phtml',
                        \WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\Prompt::class
                    ); ?>
                </div>
            </div>
        </div>
    </form>
    <div class="wtai-loading-mask" data-bind="visible: isLoading"></div>
    <div class="wtai-restore-global-mask" data-bind="visible: isRestoreGlobalLoading"></div>
    <div class="wtai-save-global-mask" data-bind="visible: isSaveGlobalLoading "></div>

</div>
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/block-loader":
                "<?= $escaper->escapeJs($block->getViewFileUrl('images/loader-1.gif')) ?>"
        }
    }
</script>