<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**@var \Magento\Backend\Block\Widget\Form\Renderer\Fieldset $block */
?>
<?php $_element = $block->getElement() ?>
<?php $_jsObjectName = $block->getFieldSetId() != null ? $block->getFieldSetId() : $_element->getHtmlId() ?>
<div class="rule-tree">
    <fieldset id="<?= $block->escapeHtmlAttr($_jsObjectName) ?>" <?= /* @noEscape */ $_element->serialize(['class']) ?> class="fieldset">
        <legend class="legend"><span><?= $block->escapeHtml($_element->getLegend()) ?></span></legend>
        <br>
    <?php if ($_element->getComment()) : ?>
        <div class="messages">
            <div class="message message-notice"><?= $block->escapeHtml($_element->getComment()) ?></div>
        </div>
    <?php endif; ?>
    <div class="rule-tree-wrapper">
        <?= $_element->getChildrenHtml() ?>
    </div>
    </fieldset>
</div>
<script>
require([
    "Magento_Rule/rules",
    "prototype"
], function(VarienRulesForm){

window.<?= /* @noEscape */ $_jsObjectName ?> = new VarienRulesForm('<?= /* @noEscape */ $_jsObjectName ?>', '<?= /* @noEscape */ $block->getNewChildUrl() ?>');
<?php if ($_element->getReadonly()) : ?>
    <?= /* @noEscape */ $_element->getHtmlId() ?>.setReadonly(true);
<?php endif; ?>

});
</script>
