<?xml version="1.0" encoding="UTF-8"?>

<!--

 This file is part of the Sylius package.

 (c) Sylius Sp. z o.o.

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
    <imports>
        <import resource="services/**.xml"/>
    </imports>

    <parameters>
        <parameter key="sylius.shipping_methods_resolver.interface">Sylius\Component\Shipping\Resolver\ShippingMethodsResolverInterface</parameter>
    </parameters>

    <services>
        <defaults public="true"/>

        <service id="sylius.registry.shipping_methods_resolver"
                 class="Sylius\Component\Registry\PrioritizedServiceRegistry">
            <argument>%sylius.shipping_methods_resolver.interface%</argument>
            <argument>Shipping methods resolver</argument>
        </service>

        <service id="sylius.shipping_methods_resolver"
                 class="Sylius\Component\Shipping\Resolver\CompositeMethodsResolver">
            <argument type="service" id="sylius.registry.shipping_methods_resolver"/>
        </service>
        <service id="Sylius\Component\Shipping\Resolver\ShippingMethodsResolverInterface"
                 alias="sylius.shipping_methods_resolver"/>

        <service id="sylius.shipping_methods_resolver.default"
                 class="Sylius\Component\Shipping\Resolver\ShippingMethodsResolver">
            <argument type="service" id="sylius.repository.shipping_method"/>
            <argument type="service" id="sylius.shipping_method_eligibility_checker"/>
            <tag name="sylius.shipping_method_resolver" type="default" label="Default"/>
        </service>

        <service id="sylius.shipping_method_resolver.default"
                 class="Sylius\Component\Shipping\Resolver\DefaultShippingMethodResolver">
            <argument type="service" id="sylius.repository.shipping_method"/>
        </service>
        <service id="Sylius\Component\Shipping\Resolver\DefaultShippingMethodResolverInterface"
                 alias="sylius.shipping_method_resolver.default"/>

        <service id="sylius.shipping_calculator" class="Sylius\Component\Shipping\Calculator\DelegatingCalculator">
            <argument type="service" id="sylius.registry.shipping_calculator"/>
        </service>
        <service id="Sylius\Component\Shipping\Calculator\DelegatingCalculatorInterface"
                 alias="sylius.shipping_calculator"/>

        <service id="sylius.shipping_calculator.flat_rate"
                 class="Sylius\Component\Shipping\Calculator\FlatRateCalculator">
            <tag name="sylius.shipping_calculator" calculator="flat_rate"
                 form-type="Sylius\Bundle\ShippingBundle\Form\Type\Calculator\FlatRateConfigurationType"
                 label="sylius.form.shipping_calculator.flat_rate_configuration.label"/>
        </service>

        <service id="sylius.shipping_calculator.per_unit_rate"
                 class="Sylius\Component\Shipping\Calculator\PerUnitRateCalculator">
            <tag name="sylius.shipping_calculator" calculator="per_unit_rate"
                 form-type="Sylius\Bundle\ShippingBundle\Form\Type\Calculator\PerUnitRateConfigurationType"
                 label="sylius.form.shipping_calculator.per_unit_rate_configuration.label"/>
        </service>

        <service id="sylius.calendar" class="Sylius\Bundle\ShippingBundle\Provider\Calendar"/>

        <service id="sylius.shipping_date_assigner" class="Sylius\Bundle\ShippingBundle\Assigner\ShippingDateAssigner">
            <argument type="service" id="Sylius\Calendar\Provider\DateTimeProviderInterface"/>
        </service>

        <service id="sylius.shipping_method_rule_checker.total_weight_greater_than_or_equal"
                 class="Sylius\Component\Shipping\Checker\Rule\TotalWeightGreaterThanOrEqualRuleChecker">
            <tag name="sylius.shipping_method_rule_checker" type="total_weight_greater_than_or_equal"
                 label="sylius.form.shipping_method_rule.total_weight_greater_than_or_equal"
                 form-type="Sylius\Bundle\ShippingBundle\Form\Type\Rule\TotalWeightGreaterThanOrEqualConfigurationType"/>
        </service>

        <service id="sylius.shipping_method_rule_checker.total_weight_less_than_or_equal"
                 class="Sylius\Component\Shipping\Checker\Rule\TotalWeightLessThanOrEqualRuleChecker">
            <tag name="sylius.shipping_method_rule_checker" type="total_weight_less_than_or_equal"
                 label="sylius.form.shipping_method_rule.total_weight_less_than_or_equal"
                 form-type="Sylius\Bundle\ShippingBundle\Form\Type\Rule\TotalWeightLessThanOrEqualConfigurationType"/>
        </service>
    </services>
</container>
