# config/services.yaml
parameters:
  app.uploads_dir: "%kernel.project_dir%/public/uploads"
  app.public_url: "%env(APP_PUBLIC_URL)%"
  app.commission.default: "%env(DEFAULT_COMMISSION)%"
  app.payout.min_amount: "%env(MIN_PAYOUT_AMOUNT)%"
  app.session.lifetime: 86400

services:
  _defaults:
    autowire: true
    autoconfigure: true
    bind:
      string $uploadsDir: "%app.uploads_dir%"
      string $publicUrl: "%app.public_url%"
      float $defaultCommission: "%app.commission.default%"
      float $minPayoutAmount: "%app.payout.min_amount%"
      string $adminEmail: "%env(ADMIN_EMAIL)%"

  App\:
    resource: "../src/"
    exclude:
      - "../src/DependencyInjection/"
      - "../src/Kernel.php"
      - "../src/Tests/"

  App\Controller\:
    resource: "../src/Controller/"
    tags: ["controller.service_arguments"]

  # Session Service
  App\Security\SessionService:
    arguments:
      $requestStack: "@request_stack"
      $logger: "@logger"

  # Session Authenticator
  App\Security\SessionAuthenticator:
    arguments:
      $userRepository: '@App\Repository\UserRepository'
      $sessionService: '@App\Security\SessionService'
      $logger: "@logger"

  # Services explicites
  App\Service\EmailService:
    arguments:
      $adminEmail: "%env(ADMIN_EMAIL)%"

  App\Service\NotificationService:
    arguments:
      $adminEmail: "%env(ADMIN_EMAIL)%"

  # CORRECTION: FileUploadService avec les bons arguments
  App\Service\FileUploadService:
    arguments:
      $logger: "@logger"
      $uploadDirectory: "%app.uploads_dir%/products"
    autowire: true
    autoconfigure: true

  App\Service\SKUGenerator:
    autowire: true
    autoconfigure: true

  App\Service\VendorService:
    arguments:
      $minPayoutAmount: "%app.payout.min_amount%"

  App\Service\CommissionService:
    arguments:
      $defaultCommission: "%app.commission.default%"

  # Auth Service
  App\Service\AuthService:
    arguments:
      $em: "@doctrine.orm.entity_manager"
      $passwordHasher: "@security.user_password_hasher"
      $jwtManager: "@lexik_jwt_authentication.jwt_manager"
      $sessionService: '@App\Security\SessionService'
      $logger: "@logger"

  # Session Manager Service
  App\Service\SessionManagerService:
    arguments:
      $em: "@doctrine.orm.entity_manager"
      $requestStack: "@request_stack"

  # Repositories
  App\Repository\UserRepository:
    arguments:
      - '@Doctrine\Persistence\ManagerRegistry'

  App\Repository\VendorRepository:
    arguments:
      - '@Doctrine\Persistence\ManagerRegistry'

  App\Repository\ProductRepository:
    arguments:
      - '@Doctrine\Persistence\ManagerRegistry'

  App\Repository\OrderRepository:
    arguments:
      - '@Doctrine\Persistence\ManagerRegistry'

  App\Repository\CategoryRepository:
    arguments:
      - '@Doctrine\Persistence\ManagerRegistry'

  App\Repository\SessionRepository:
    arguments:
      - '@Doctrine\Persistence\ManagerRegistry'

  App\Repository\OrderItemRepository:
    arguments:
      - '@Doctrine\Persistence\ManagerRegistry'

  App\Repository\ProductReviewRepository:
    arguments:
      - '@Doctrine\Persistence\ManagerRegistry'

  App\Repository\VendorPayoutRepository:
    arguments:
      - '@Doctrine\Persistence\ManagerRegistry'

  App\Repository\RefreshTokenRepository:
    arguments:
      - '@Doctrine\Persistence\ManagerRegistry'

  # Event listeners
  App\EventListener\JWTCreatedListener:
    tags:
      - {
          name: kernel.event_listener,
          event: lexik_jwt_authentication.on_jwt_created,
          method: onJWTCreated,
        }

  App\Twig\:
    resource: "../src/Twig/"
    tags: ["twig.extension"]

  App\EventSubscriber\AccessDeniedSubscriber:
    arguments:
      - "@router"
    tags:
      - { name: kernel.event_subscriber }

  App\Twig\SlugifyExtension:
    tags: ["twig.extension"]