# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration

parameters:
  app.flag_dir: "web/flags"
  # QuickBooks Configuration
  quickbooks_client_id: '%env(QUICKBOOKS_CLIENT_ID)%'
  quickbooks_client_secret: '%env(QUICKBOOKS_CLIENT_SECRET)%'
  quickbooks_redirect_uri: '%env(QUICKBOOKS_REDIRECT_URI)%'
  quickbooks_env: '%env(QUICKBOOKS_ENV)%'
  quickbooks_environment: '%env(QUICKBOOKS_ENVIRONMENT)%'
  # Reports Server Configuration
  reports_url: '%env(REPORTS_URL)%'
  reports_token: '%env(REPORTS_TOKEN)%'
  # Twilio PDF Temp Path
  twillio_pdf_temp: '%env(TWILLIO_PDF_TEMP)%'
  # Google reCAPTCHA Configuration
  google_recaptcha_site_key: '%env(GOOGLE_RECAPTCHA_SITE_KEY)%'
  google_recaptcha_secret: '%env(GOOGLE_RECAPTCHA_SECRET)%'

services:
  # Default configuration for services in *this* file
  _defaults:
    autowire: true  # Automatically injects dependencies in your services.
    autoconfigure: true  # Automatically registers your services as commands, event subscribers, etc.

  # Makes classes in src/ available to be used as services
  # This creates a service per class whose ID is the fully-qualified class name
  App\:
    resource: "../src/"
    exclude:
      - "../src/DependencyInjection/"
      - "../src/Entity/"
      - "../src/Kernel.php"

  api.event.jwt_created_listener:
    class: App\EventListener\JWTCreatedListener
    arguments: ["@request_stack"]
    tags:
      - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_created, method: onJWTCreated }

  app.custom_authenticator:
    class: App\Security\CustomAuthenticator
    parent: lexik_jwt_authentication.security.jwt_authenticator

  app.listener.authentication_success_response:
    class: App\EventListener\AuthenticationSuccessListener
    arguments: ["@lexik_jwt_authentication.jwt_manager"]
    tags:
      - { name: kernel.event_listener, event: lexik_jwt_authentication.handler.authentication_success, method: onAuthenticationSuccessResponse }

  App\EventSubscriber\ExceptionSubscriber:
    tags:
      - { name: kernel.event_subscriber }

  # Definición de servicios
  App\Service\DTOMapperService: ~
  App\Service\MaincompanyService: ~
  App\Service\UserService: ~
  App\Service\CarrierService: ~
  App\Service\CountryService: ~
  
  # QuickBooks Library Services
  App\Library\QuickBooksConfig: ~
  App\Library\QuickBooksClient: ~
  

  App\Service\ReceiptService:
    arguments:
      $serviceLocator: '@service_locator.guide_warehouse'
      $whrecRepository: '@App\Repository\WHrecRepository'
      $imagepackRepository: '@App\Repository\ImagepackRepository'
      
  App\Service\ReempackService:
    arguments:
        $serviceLocator: '@service_locator.guide_warehouse'

  # Service Locator para GuideService y WarehouseReceiptService
  service_locator.guide_warehouse:
    class: Symfony\Component\DependencyInjection\ServiceLocator
    arguments:
      -
        App\Service\GuideService: '@App\Service\GuideService'
        App\Service\WarehouseReceiptService: '@App\Service\WarehouseReceiptService'
        App\Service\ConsolidatedService: '@App\Service\ConsolidatedService'
        App\Service\BillService: '@App\Service\BillService'

  App\Service\WarehouseReceiptService:
    calls:
      - method: setConsolidatedService
        arguments: ['@App\Service\ConsolidatedService']
  
  App\Service\AlertService:
    calls:
      - method: setServices
        arguments: ['@App\Service\ReceiptService', '@App\Service\GuideService', '@App\Service\WarehouseReceiptService']

  App\Service\GuideService:
    calls:
      - method: setConsolidatedService
        arguments: ['@App\Service\ConsolidatedService']

  App\Service\TwilioService:
    arguments:
      $pdfTempPath: '%twillio_pdf_temp%'
  App\Service\ReportService:
    arguments:
      $pdfTempPath: '%twillio_pdf_temp%'

  # Voters
  App\Security\Voter\:
    resource: "../src/Security/Voter/*"
    tags: ["security.voter"]

  # Add the LocaleListener service
  App\EventListener\LocaleListener:
    arguments:
      $security: '@security.helper'  # Inject the security service (use '@security.token_storage' if needed)
      $translator: '@translator'
      $defaultLocale: 'en'  # Set the default locale (you can adjust this if necessary)
    tags:
      - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

  # reCAPTCHA Service
  App\Service\RecaptchaService:
    arguments:
      $secretKey: '%google_recaptcha_secret%'

  # Add more service definitions when explicit configuration is needed
  # Please note that last definitions always *replace* previous ones
