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

/** @var \Magento\Catalog\Block\Adminhtml\Category\AssignProducts $block */
/** @var \Magento\Catalog\Block\Adminhtml\Category\Tab\Product $blockGrid */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */

$blockGrid = $block->getBlockGrid();
$gridJsObjectName = $blockGrid->getJsObjectName();
?>
<?= $block->getGridHtml() ?>
<input type="hidden" name="category_products" id="in_category_products" data-form-part="category_form" value="" />
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Catalog/catalog/category/assign-products": {
                "selectedProducts": <?= /* @noEscape */ $block->getProductsJson() ?>,
                "gridJsObjectName": <?= /* @noEscape */ '"' . $gridJsObjectName . '"' ?: '{}' ?>
            }
        }
    }
</script>
<!-- @todo remove when "UI components" will support such initialization -->
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], "require('mage/apply/main').apply();", false) ?>
