services:
  # From PS 1.7.0 to PS 1.7.3, the bundled version of Symfony is 2.x on which the _defaults
  # key is invalid. To prevent error on these versions, each service has to be specifically
  # declared as public.
  #  _defaults:
  #   public: true

  ps_checkout.module:
    class: 'Ps_checkout'
    factory: ['Module', 'getInstanceByName']
    public: true
    arguments:
      - 'ps_checkout'

  ps_checkout.context.prestashop:
    class: 'PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext'
    public: true

  ps_checkout.context.shop:
    class: 'PrestaShop\Module\PrestashopCheckout\ShopContext'
    public: true

  ps_checkout.shop.provider:
    class: 'PrestaShop\Module\PrestashopCheckout\Shop\ShopProvider'
    public: true

  ps_checkout.configuration.options.resolver:
    class: 'PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfigurationOptionsResolver'
    public: true
    arguments:
      - '@=service("ps_checkout.shop.provider").getIdentifier()'

  ps_checkout.configuration:
    class: 'PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration'
    public: true
    arguments:
      - '@ps_checkout.configuration.options.resolver'

  ps_checkout.logger.directory:
    class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerDirectory'
    public: true
    arguments:
      - !php/const _PS_VERSION_
      - !php/const _PS_ROOT_DIR_

  ps_checkout.logger.filename:
    class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerFilename'
    public: true
    arguments:
      - '@=service("ps_checkout.module").name'
      - '@=service("ps_checkout.shop.provider").getIdentifier()'

  ps_checkout.logger.configuration:
    class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerConfiguration'
    public: true
    arguments:
      - '@ps_checkout.configuration'

  ps_checkout.env.sentry:
    class: 'PrestaShop\Module\PrestashopCheckout\Environment\SentryEnv'
    public: true

  ps_checkout.logger.handler.factory:
    class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerHandlerFactory'
    public: true
    arguments:
      - '@=service("ps_checkout.logger.directory").getPath()'
      - '@=service("ps_checkout.logger.filename").get()'
      - '@=service("ps_checkout.logger.configuration").getMaxFiles()'
      - '@=service("ps_checkout.logger.configuration").getLevel()'

  ps_checkout.logger.handler:
    class: 'Monolog\Handler\HandlerInterface'
    public: true
    factory: ['@ps_checkout.logger.handler.factory', 'build']

  ps_checkout.logger.factory:
    class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerFactory'
    public: true
    arguments:
      - '@=service("ps_checkout.module").name'
      - '@ps_checkout.logger.handler'

  ps_checkout.logger:
    class: 'Psr\Log\LoggerInterface'
    public: true
    factory: ['@ps_checkout.logger.factory', 'build']
    arguments:
      - '@ps_checkout.logger.directory'

  ps_checkout.paypal.configuration:
    class: 'PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration'
    public: true
    arguments:
      - '@ps_checkout.configuration'
      - '@ps_checkout.repository.paypal.code'

  ps_checkout.persistent.configuration:
    class: 'PrestaShop\Module\PrestashopCheckout\PersistentConfiguration'
    public: true
    arguments:
      - '@ps_checkout.configuration'

  ps_checkout.express_checkout.configuration:
    class: 'PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration'
    public: true
    arguments:
      - '@ps_checkout.configuration'

  ps_checkout.pay_later.configuration:
    class: 'PrestaShop\Module\PrestashopCheckout\PayPal\PayPalPayLaterConfiguration'
    public: true
    arguments:
      - '@ps_checkout.configuration'
      - '@ps_checkout.customer'
      - '@ps_checkout.merchant'

  ps_checkout.api.firebase.auth:
    class: 'PrestaShop\Module\PrestashopCheckout\Api\Firebase\Auth'
    public: true

  ps_checkout.api.firebase.auth.factory:
    class: 'PrestaShop\Module\PrestashopCheckout\Api\Firebase\AuthFactory'
    public: true
    arguments:
      - '@ps_checkout.api.firebase.auth'
      - '@ps_checkout.persistent.configuration'

  ps_checkout.repository.paypal.account:
    class: 'PrestaShop\Module\PrestashopCheckout\Repository\PaypalAccountRepository'
    public: true
    arguments:
      - '@ps_checkout.configuration'

  ps_checkout.sdk.paypal.linkbuilder:
    class: 'PrestaShop\Module\PrestashopCheckout\Builder\PayPalSdkLink\PayPalSdkLinkBuilder'
    public: true
    arguments:
      - '@ps_checkout.repository.paypal.account'
      - '@ps_checkout.paypal.configuration'
      - '@ps_checkout.pay_later.configuration'
      - '@ps_checkout.funding_source.configuration.repository'
      - '@ps_checkout.express_checkout.configuration'

  ps_checkout.repository.prestashop.account:
    class: 'PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository'
    public: true
    arguments:
      - '@ps_checkout.configuration'

  ps_checkout.store.module.psx:
    class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\PsxModule'
    public: true
    arguments:
      - '@ps_checkout.context.prestashop'
      - '@ps_checkout.repository.prestashop.account'

  ps_checkout.store.module.paypal:
    class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\PaypalModule'
    public: true
    arguments:
      - '@ps_checkout.repository.paypal.account'

  ps_checkout.store.module.firebase:
    class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\FirebaseModule'
    public: true
    arguments:
      - '@ps_checkout.configuration'

  ps_checkout.store.module.configuration:
    class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\ConfigurationModule'
    public: true
    arguments:
      - '@ps_checkout.pay_later.configuration'
      - '@ps_checkout.express_checkout.configuration'
      - '@ps_checkout.paypal.configuration'
      - '@ps_checkout.funding_source.provider'
      - '@ps_checkout.module'

  ps_checkout.builder.payload.onboarding:
    class: 'PrestaShop\Module\PrestashopCheckout\Builder\Payload\OnboardingPayloadBuilder'
    public: true
    arguments:
      - '@ps_checkout.repository.prestashop.account'
      - '@ps_checkout.adapter.language'

  ps_checkout.updater.paypal.account:
    class: 'PrestaShop\Module\PrestashopCheckout\Updater\PaypalAccountUpdater'
    public: true
    arguments:
      - '@ps_checkout.persistent.configuration'
      - '@ps_checkout.paypal.provider.merchant_integration'

  ps_checkout.step.live:
    class: 'PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\LiveStep'
    public: true
    arguments:
      - '@ps_checkout.configuration'

  ps_checkout.step.value:
    class: 'PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\ValueBanner'
    public: true
    arguments:
      - '@ps_checkout.configuration'

  ps_checkout.translations.translations:
    class: 'PrestaShop\Module\PrestashopCheckout\Translations\Translations'
    public: true
    arguments:
      - '@ps_checkout.module'

  ps_checkout.store.module.context:
    class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\ContextModule'
    public: true
    arguments:
      - '@=service("ps_checkout.module").name'
      - '@=service("ps_checkout.module").module_key'
      - '@ps_checkout.context.prestashop'
      - '@ps_checkout.paypal.configuration'
      - '@ps_checkout.step.live'
      - '@ps_checkout.step.value'
      - '@ps_checkout.translations.translations'
      - '@ps_checkout.context.shop'
      - '@ps_checkout.shop.provider'

  ps_checkout.adapter.language:
    class: 'PrestaShop\Module\PrestashopCheckout\Adapter\LanguageAdapter'
    public: true
    arguments:
      - '@ps_checkout.context.shop'

  ps_checkout.store.store:
    class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Store\StorePresenter'
    public: true
    arguments:
      - ['@ps_checkout.store.module.context', '@ps_checkout.store.module.firebase', '@ps_checkout.store.module.paypal', '@ps_checkout.store.module.psx', '@ps_checkout.store.module.configuration']

  ps_checkout.repository.pscheckoutcart:
    class: 'PrestaShop\Module\PrestashopCheckout\Repository\PsCheckoutCartRepository'
    public: true

  ps_checkout.funding_source.configuration.repository:
    class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfigurationRepository'
    public: true
    arguments:
      - '@ps_checkout.context.prestashop'

  ps_checkout.funding_source.configuration:
    class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfiguration'
    public: true
    arguments:
      - '@ps_checkout.funding_source.configuration.repository'

  ps_checkout.funding_source.eligibility_constraint:
    class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceEligibilityConstraint'
    public: true

  ps_checkout.funding_source.collection.builder:
    class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceCollectionBuilder'
    public: true
    arguments:
      - '@ps_checkout.funding_source.configuration'
      - '@ps_checkout.funding_source.eligibility_constraint'

  ps_checkout.funding_source.translation:
    class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceTranslationProvider'
    public: true
    arguments:
      - '@ps_checkout.module'

  ps_checkout.funding_source.entity:
    class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceEntity'
    public: true

  ps_checkout.repository.country:
    class: 'PrestaShop\Module\PrestashopCheckout\Repository\CountryRepository'
    public: true

  ps_checkout.funding_source.presenter:
    class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourcePresenter'
    public: true
    arguments:
      - '@ps_checkout.funding_source.translation'
      - '@ps_checkout.repository.country'

  ps_checkout.funding_source.collection:
    class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceCollection'
    public: true
    arguments:
      - '@=service("ps_checkout.funding_source.collection.builder").create()'

  ps_checkout.funding_source.provider:
    class: 'PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceProvider'
    public: true
    arguments:
      - '@ps_checkout.funding_source.collection.builder'
      - '@ps_checkout.funding_source.presenter'

  ps_checkout.repository.paypal.code:
    class: 'PrestaShop\Module\PrestashopCheckout\Repository\PayPalCodeRepository'
    public: true

  ps_checkout.handler.exception:
    class: 'PrestaShop\Module\PrestashopCheckout\Handler\ExceptionHandler'
    public: true
    arguments:
      - '@ps_checkout.module'
      - '@ps_checkout.env.sentry'
      - '@ps_checkout.repository.prestashop.account'

  ps_checkout.customer:
    class: 'PrestaShop\Module\PrestashopCheckout\Customer'
    public: true
    arguments:
      - '@ps_checkout.context.prestashop'

  ps_checkout.merchant:
    class: 'PrestaShop\Module\PrestashopCheckout\Merchant'
    public: true

  ps_checkout.env_loader:
    class: 'PrestaShop\Module\PrestashopCheckout\Environment\EnvLoader'
    public: true

  ps_checkout.manager.shopuuid:
    class: 'PrestaShop\Module\PrestashopCheckout\ShopUuidManager'
    public: true

  ps_checkout.validator.merchant:
    class: 'PrestaShop\Module\PrestashopCheckout\Validator\MerchantValidator'
    public: true
    arguments:
      - '@ps_checkout.repository.paypal.account'
      - '@ps_checkout.repository.prestashop.account'
      - '@ps_checkout.context.prestashop'
      - '@ps_checkout.manager.shopuuid'

  ps_checkout.validator.front_controller:
    class: 'PrestaShop\Module\PrestashopCheckout\Validator\FrontControllerValidator'
    public: true
    arguments:
      - '@ps_checkout.validator.merchant'
      - '@ps_checkout.express_checkout.configuration'
      - '@ps_checkout.pay_later.configuration'

  ps_checkout.cache.directory:
    class: 'PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider'
    public: true
    arguments:
      - !php/const _PS_VERSION_
      - !php/const _PS_ROOT_DIR_
      - !php/const _PS_MODE_DEV_

  ps_checkout.cache.paypal.order:
    class: 'Symfony\Component\Cache\Simple\FilesystemCache'
    public: true
    arguments:
      - 'paypal-orders'
      - 3600
      - '@=service("ps_checkout.cache.directory").getPath()'

  ps_checkout.paypal.provider.order:
    class: 'PrestaShop\Module\PrestashopCheckout\PayPal\PayPalOrderProvider'
    public: true
    arguments:
      - '@ps_checkout.cache.paypal.order'

  ps_checkout.cache.paypal.merchant_integration:
    class: 'Symfony\Component\Cache\Simple\FilesystemCache'
    public: true
    arguments:
      - 'merchant-integration'
      - 86400
      - '@=service("ps_checkout.cache.directory").getPath()'

  ps_checkout.paypal.provider.merchant_integration:
    class: 'PrestaShop\Module\PrestashopCheckout\PayPal\PayPalMerchantIntegrationProvider'
    public: true
    arguments:
      - '@ps_checkout.cache.paypal.merchant_integration'

  ps_checkout.paypal.provider.client_token:
    class: 'PrestaShop\Module\PrestashopCheckout\PayPal\PayPalClientTokenProvider'
    public: true
