<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Free Gift Base for Magento 2
 */-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Sales\Block\Adminhtml\Order\Create\Billing\Method\Form">
        <plugin name="Amasty_Promo::OrderCreatePromoAddButton" type="Amasty\Promo\Plugin\Sales\Block\Adminhtml\Order\Create\Billing\Method\FormPlugin"/>
    </type>

    <type name="Magento\Sales\Model\AdminOrder\Create">
        <plugin name="Amasty_Promo::OrderCreatePromoAddOptions" type="Amasty\Promo\Plugin\Sales\Model\AdminOrder\CreatePlugin"/>
    </type>

    <type name="Magento\Sales\Controller\Adminhtml\Order\Create\LoadBlock">
        <plugin name="Amasty_Promo::OrderCreatePromoAddChangeRequest" type="Amasty\Promo\Plugin\Sales\Controller\Order\Create\LoadBlockPlugin"/>
    </type>

    <type name="Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid">
        <plugin name="Amasty_Promo::OrderDisableDefaultConfigurationButton" type="Amasty\Promo\Plugin\Sales\Block\Adminhtml\Order\Create\Items\DisableConfigureButton"/>
    </type>

    <type name="Amasty\Promo\Model\Registry">
        <arguments>
            <argument name="resourceSession" xsi:type="object">Magento\Backend\Model\Session\Quote</argument>
        </arguments>
    </type>

    <type name="Amasty\Promo\Ui\Component\Grid\Promo\DataProvider">
        <arguments>
            <argument name="collectionFactory"
                      xsi:type="object">\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory
            </argument>
            <argument name="addFilterStrategies" xsi:type="array">
                <item name="min_price"
                      xsi:type="object">Amasty\Promo\Ui\Component\Grid\Promo\Filters\FilterMinPrice</item>
            </argument>
            <argument name="modifiersPool" xsi:type="object">Amasty\Promo\Ui\Component\Grid\Promo\Modifier\Pool</argument>
        </arguments>
    </type>

    <type name="Magento\Framework\View\Element\Message\MessageConfigurationsPool">
        <arguments>
            <argument name="configurationsMap" xsi:type="array">
                <item name="amastyPromoMessagesInfo" xsi:type="array">
                    <item name="renderer"
                          xsi:type="const">Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE
                    </item>
                    <item name="data" xsi:type="array">
                        <item name="template" xsi:type="string">Amasty_Promo::messages/amastyPromoMessagesInfo.phtml
                        </item>
                    </item>
                </item>
            </argument>
        </arguments>
    </type>

    <virtualType name="Amasty\Promo\Ui\Component\Grid\Promo\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool">
        <arguments>
            <argument name="modifiers" xsi:type="array">
                <item name="modify_qty" xsi:type="array">
                    <item name="class" xsi:type="string">Amasty\Promo\Ui\Component\Grid\Promo\Modifiers\ModifyQty</item>
                    <item name="sortOrder" xsi:type="number">10</item>
                </item>
                <item name="modify_promo_price" xsi:type="array">
                    <item name="class" xsi:type="string">Amasty\Promo\Ui\Component\Grid\Promo\Modifiers\ModifyPromoPrice</item>
                    <item name="sortOrder" xsi:type="number">20</item>
                </item>
                <item name="modify_items_left" xsi:type="array">
                    <item name="class" xsi:type="string">Amasty\Promo\Ui\Component\Grid\Promo\Modifiers\ModifyItemsLeft</item>
                    <item name="sortOrder" xsi:type="number">30</item>
                </item>
            </argument>
        </arguments>
    </virtualType>

    <type name="Amasty\Promo\Model\ItemRegistry\PromoItemData">
        <plugin name="Amasty_Promo::TrackChangeAllowedQty"
                type="Amasty\Promo\Plugin\Promo\Model\ItemRegistry\PromoItemData\TrackChangeAllowedQty"/>
    </type>
    <type name="Magento\Quote\Model\Quote">
        <plugin name="Amasty_Promo::TriggerRecollectTotals"
                type="Amasty\Promo\Plugin\Quote\Model\Quote\TriggerRecollectTotals"/>
    </type>

    <type name="Amasty\Promo\Block\Adminhtml\System\Config\Information">
        <arguments>
            <argument name="suggestModules" xsi:type="array">
                <item name="free-gift-hyva" xsi:type="string">Amasty_PromoHyvaCompatibility</item>
                <item name="free-gift-graphql" xsi:type="string">Amasty_PromoGraphql</item>
                <item name="free-bar-promo" xsi:type="string">Amasty_FreeBarPromo</item>
                <item name="free-gift-timer" xsi:type="string">Amasty_FreeGiftTimer</item>
                <item name="free-gift-extended-view" xsi:type="string">Amasty_FreeGiftExtendedView</item>
            </argument>
        </arguments>
    </type>

    <virtualType name="Amasty\Promo\HeaderIcon" type="Amasty\Base\Block\Adminhtml\System\Config\Form\Field\Promo\PromoField">
        <arguments>
            <argument name="moduleName" xsi:type="string">Amasty_FreeGiftHeaderIcon</argument>
            <argument name="promoConfig" xsi:type="array">
                <item name="promoLink" xsi:type="string"><![CDATA[https://amasty.com/amcustomer/account/products/?utm_source=extension&utm_medium=backend&utm_campaign=subscribe_freegift]]></item>
                <item name="comment" xsi:type="string"><![CDATA[Select a child or parent product identifier to be tracked on the cart, checkout, and success pages. The functionality is available as part of an active product subscription or support subscription for the Free Gift Pro version. To upgrade and obtain functionality please follow the <a href='https://amasty.com/amcustomer/account/products/?utm_source=extension&utm_medium=backend&utm_campaign=subscribe_freegift' target='_blank'>link</a>. Then you can find the 'amasty/module-free-gift-header-icon' package for installation in composer suggest.]]></item>
            </argument>
        </arguments>
    </virtualType>
</config>
