# 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:
    encryption_key: '%env(ENCRYPTION_KEY)%'
    upload_directory: '%kernel.project_dir%/var/uploads'
    app.frontend_url: '%env(FRONTEND_URL)%'
    app.sender_email: '%env(SENDER_EMAIL)%'
    app.sender_name: '%env(SENDER_NAME)%'
    # Google Auth désactivé temporairement
    # google.client_id: '%env(GOOGLE_CLIENT_ID)%'
    # google.client_secret: '%env(GOOGLE_CLIENT_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'

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

    App\Service\EncryptionService:
        arguments:
            $encryptionKey: '%encryption_key%'

    App\Service\MistralService:
        arguments:
            $apiKey: '%env(MISTRAL_API_KEY)%'
            $modelSmall: '%env(MISTRAL_MODEL_SMALL)%'
            $modelLarge: '%env(MISTRAL_MODEL_LARGE)%'
            $modelCodestral: '%env(MISTRAL_MODEL_CODESTRAL)%'
            $modelPixtral: '%env(MISTRAL_MODEL_PIXTRAL)%'

    App\Service\FileService:
        arguments:
            $uploadDirectory: '%upload_directory%'
        calls:
            - setMistralService: ['@App\Service\MistralService']

    App\Service\StripeService:
        arguments:
            $stripeSecretKey: '%env(STRIPE_SECRET_KEY)%'
            $stripeWebhookSecret: '%env(STRIPE_WEBHOOK_SECRET)%'
            $appUrl: '%env(APP_URL)%'
            $invoiceEmailService: '@App\Service\InvoiceEmailService'

    App\Controller\Api\SubscriptionController:
        arguments:
            $appUrl: '%env(APP_URL)%'

    # WebSearchService (Brave) - DÉSACTIVÉ, remplacé par L'dicO (SearXNG)
    # App\Service\WebSearchService:
    #     arguments:
    #         $braveSearchApiKey: '%env(BRAVE_SEARCH_API_KEY)%'
    #         $webSearchEnabled: '%env(bool:WEB_SEARCH_ENABLED)%'

    App\EventListener\ApiExceptionListener:
        arguments:
            $environment: '%kernel.environment%'

    App\Service\ErrorAlertEmailService:
        arguments:
            $adminEmail: '%env(ADMIN_ALERT_EMAIL)%'
            $senderEmail: '%env(SENDER_EMAIL)%'
            $adminUrl: '%env(APP_URL)%'

    App\Service\WelcomeEmailService:
        arguments:
            $senderEmail: '%env(SENDER_EMAIL)%'
            $senderName: '%env(SENDER_NAME)%'
            $appUrl: '%env(APP_URL)%'

    App\Service\InvoiceEmailService:
        arguments:
            $senderEmail: '%env(SENDER_EMAIL)%'
            $senderName: '%env(SENDER_NAME)%'
            $appUrl: '%env(APP_URL)%'

    # Export strategies - auto-tagged for MessageExportService
    _instanceof:
        App\Service\Export\ExportStrategyInterface:
            tags: ['app.export_strategy']

    App\Service\Export\MessageExportService:
        arguments:
            $strategies: !tagged_iterator app.export_strategy

    # L'dicO - Search Services
    App\Service\Search\SearxngClient:
        arguments:
            $searxngUrl: '%env(SEARXNG_URL)%'
            $searxngApiKey: '%env(SEARXNG_API_KEY)%'

    App\Service\Search\SearchService:
        arguments:
            $ldicoEnabled: '%env(bool:LDICO_ENABLED)%'
            $searchEntityManager: '@doctrine.orm.search_entity_manager'

    # EasyAdmin - Connexion PostgreSQL L'dicO
    App\Controller\Admin\SearchQueryCrudController:
        arguments:
            $searchEntityManager: '@doctrine.orm.search_entity_manager'

    App\Controller\Admin\SearchResultCrudController:
        arguments:
            $searchEntityManager: '@doctrine.orm.search_entity_manager'

    # RGPD PDF Export Service
    App\Service\Export\Rgpd\RgpdPdfExportService:
        arguments:
            $projectDir: '%kernel.project_dir%'
