# This file is the entry point to configure your own services and load the default configuration.
# If you want to remove a service, deprecate it, or change its class, you can apply the changes
# here.
#
# If you are *not* using the default services.yaml file in your package, you *must* pass an
# absolute path to this file's location to the `imports` key in your package's services.yaml (e.g.
# imports: ['%kernel.project_dir%/config/services.yaml'])
#
# See https://symfony.com/doc/current/configuration.html#applying-configuration-to-services

# 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:
    env(MAIL_SEND_GAP_MICROS): '0'
    env(PARTNER_CONTACT_INBOUND_EMAIL): 'contact@sherlook.fr'
    # Optimisation images upload (UploadController) — défauts si absent du .env local
    env(UPLOAD_IMAGE_OPTIMIZE): '1'
    env(UPLOAD_IMAGE_MAX_LONG_EDGE): '1920'
    env(UPLOAD_IMAGE_JPEG_QUALITY): '82'
    env(UPLOAD_IMAGE_WEBP_QUALITY): '80'
    env(UPLOAD_IMAGE_PNG_COMPRESSION): '8'
    env(COLISSIMO_DELIVERY_FLAT_AMOUNT_CENTS): '1800'
    env(COLISSIMO_PICKUP_POINTS_URL): 'https://ws.colissimo.fr/pointretrait-ws-cxf/PointRetraitServiceWS/2.0/findRDVPointRetraitAcheminement'
    env(COLISSIMO_GENERATE_LABEL_URL): 'https://ws.colissimo.fr/sls-ws/SlsServiceWSRest/2.0/generateLabel'
    env(COLISSIMO_TRACKING_URL): 'https://ws.colissimo.fr/tracking-timeline-ws/rest/tracking/timelineCompany'
    env(COLISSIMO_ID): ''
    env(COLISSIMO_PASSWORD): ''
    env(COLISSIMO_COMPANY): ''
    env(COLISSIMO_ADDRESS): ''
    env(COLISSIMO_ZIPCODE): ''
    env(COLISSIMO_CITY): ''
    env(COLISSIMO_COUNTRYCODE): 'FR'
    env(COLISSIMO_PHONE): ''
    env(COLISSIMO_EMAIL): ''
    env(STRIPE_PUBLIC_KEY): ''
    env(STRIPE_SECRET_KEY): ''
    env(STRIPE_WEBHOOK_SECRET): ''
    env(STRIPE_TEST_PUBLIC_KEY): ''
    env(STRIPE_TEST_SECRET_KEY): ''
    env(STRIPE_TEST_WEBHOOK_SECRET): ''
    env(STRIPE_LIVE_PUBLIC_KEY): ''
    env(STRIPE_LIVE_SECRET_KEY): ''
    env(STRIPE_LIVE_WEBHOOK_SECRET): ''
    env(FRONTEND_APP_URL): ''
    env(GA4_PROPERTY_ID): ''
    env(GA4_SERVICE_ACCOUNT_JSON): ''
    env(CHRONOPOST_ACCOUNT): ''
    env(CHRONOPOST_PASSWORD): ''
    env(CHRONOPOST_HOME_ACCOUNT): ''
    env(CHRONOPOST_HOME_PASSWORD): ''
    env(CHRONOPOST_COMPANY): ''
    env(CHRONOPOST_ADDRESS): ''
    env(CHRONOPOST_ZIPCODE): ''
    env(CHRONOPOST_CITY): ''
    env(CHRONOPOST_COUNTRYCODE): 'FR'
    env(CHRONOPOST_PHONE): ''
    env(CHRONOPOST_EMAIL): ''
    env(CHRONOPOST_SHIPPING_WSDL): 'https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl'
    env(CHRONOPOST_TRACKING_WSDL): 'https://ws.chronopost.fr/tracking-cxf/TrackingServiceWS?wsdl'
    env(CHRONOPOST_RELAY_WSDL): 'https://ws.chronopost.fr/recherchebt-ws-cxf/PointRelaisServiceWS?wsdl'
    env(MONDIAL_RELAY_LOGIN): ''
    env(MONDIAL_RELAY_PASSWORD): ''
    env(MONDIAL_RELAY_CUSTOMER_ID): ''
    env(MONDIAL_RELAY_BRAND_CODE): ''
    env(MONDIAL_RELAY_PRIVATE_KEY): ''
    env(MONDIAL_RELAY_API_URL): 'https://connect-api.mondialrelay.com/api/Shipment'
    env(MONDIAL_RELAY_SOAP_WSDL): 'https://api.mondialrelay.com/Web_Services.asmx?WSDL'
    env(MONDIAL_RELAY_COMPANY): ''
    env(MONDIAL_RELAY_ADDRESS): ''
    env(MONDIAL_RELAY_ZIPCODE): ''
    env(MONDIAL_RELAY_CITY): ''
    env(MONDIAL_RELAY_COUNTRYCODE): 'FR'
    env(MONDIAL_RELAY_PHONE): ''
    env(MONDIAL_RELAY_EMAIL): ''
    env(UPS_CLIENT_ID): ''
    env(UPS_CLIENT_SECRET): ''
    env(UPS_SHIPPER_NUMBER): ''
    env(UPS_API_BASE): 'https://wwwcie.ups.com'
    env(UPS_ENABLED): '0'
    env(UPS_COMPANY): 'Sherlook'
    env(UPS_ADDRESS): ''
    env(UPS_ZIPCODE): ''
    env(UPS_CITY): ''
    env(UPS_COUNTRYCODE): 'FR'
    env(UPS_PHONE): ''
    env(UPS_EMAIL): ''
    env(HIBP_PASSWORD_CHECK_ENABLED): '0'
    env(INDEXNOW_KEY): ''
    env(INDEXNOW_ENABLED): 'false'
    env(MATCH_RECALC_ON_TERMINATE_ENABLED): 'false'
    env(SITE_PUBLIC_URL): 'https://sherlook.fr'
    env(MONITORING_ENABLED): 'false'
    env(MONITORING_RETENTION_DAYS): '30'
    env(MONITORING_THRESHOLD_DURATION_MS): '1000'
    env(MONITORING_THRESHOLD_MEMORY_MB): '256'
    env(MONITORING_THRESHOLD_SQL_QUERIES): '30'
    env(MONITORING_THRESHOLD_HTTP_CALLS): '5'
    env(MONITORING_THRESHOLD_IMAGE_MS): '1000'
    env(SHERLOOK_RUNTIME_PROFILER): '0'
    env(SHERLOOK_RUNTIME_ROTATION_RATIO_ALERT): '100'
    env(SHERLOOK_RUNTIME_WORKER_LONG_REQUEST_MS): '5000'
    env(SHERLOOK_RUNTIME_WORKER_MEMORY_MB): '128'
    env(SHERLOOK_RUNTIME_WORKER_NORMAL_MIN_REQUESTS): '50'
    env(SHERLOOK_RUNTIME_WORKER_NORMAL_MIN_LIFETIME_S): '300'

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

    # Configuration des services de watermarking
    App\Service\WatermarkConfigService: ~

    App\Service\ImageWatermarkService:
        arguments:
            $logger: '@logger'
            $configService: '@App\Service\WatermarkConfigService'

    # Configuration du service d'upload de logos
    App\Service\LogoUploadService:
        arguments:
            $targetDirectory: '%kernel.project_dir%/public/uploads/logos'
            $slugger: '@Symfony\Component\String\Slugger\SluggerInterface'

    App\Service\IndexNowService:
        arguments:
            $indexNowKey: '%env(INDEXNOW_KEY)%'
            $sitePublicUrl: '%env(SITE_PUBLIC_URL)%'
            $enabled: '%env(bool:INDEXNOW_ENABLED)%'

    App\EventSubscriber\MatchRecalculationSubscriber:
        arguments:
            $onTerminateEnabled: '%env(bool:MATCH_RECALC_ON_TERMINATE_ENABLED)%'

    App\Controller\AdminMatchingController:
        arguments:
            $matchRecalcOnTerminateEnabled: '%env(bool:MATCH_RECALC_ON_TERMINATE_ENABLED)%'

    App\Service\IndexNowImportantUrlsBuilder:
        arguments:
            $sitePublicUrl: '%env(SITE_PUBLIC_URL)%'

    app.provider_type_picto_upload:
        class: App\Service\LogoUploadService
        arguments:
            $targetDirectory: '%kernel.project_dir%/public/uploads/pictos'
            $slugger: '@Symfony\Component\String\Slugger\SluggerInterface'
            $allowedExtensions: ['svg']

    app.delivery_carrier_logo_upload:
        class: App\Service\LogoUploadService
        arguments:
            $targetDirectory: '%kernel.project_dir%/public/uploads/delivery-carriers'
            $slugger: '@Symfony\Component\String\Slugger\SluggerInterface'
            $allowedExtensions: ['svg', 'png', 'jpg', 'jpeg']

    App\Service\UploadedImageOptimizerService:
        arguments:
            $enabled: '%env(bool:UPLOAD_IMAGE_OPTIMIZE)%'
            $maxLongEdge: '%env(int:UPLOAD_IMAGE_MAX_LONG_EDGE)%'
            $jpegQuality: '%env(int:UPLOAD_IMAGE_JPEG_QUALITY)%'
            $webpQuality: '%env(int:UPLOAD_IMAGE_WEBP_QUALITY)%'
            $pngCompression: '%env(int:UPLOAD_IMAGE_PNG_COMPRESSION)%'

    App\Service\PublicImageThumbService:
        arguments:
            $projectDir: '%kernel.project_dir%'
            $jpegQuality: '%env(int:UPLOAD_IMAGE_JPEG_QUALITY)%'
            $webpQuality: '%env(int:UPLOAD_IMAGE_WEBP_QUALITY)%'

    App\Service\PasswordPolicyService:
        arguments:
            $hibpCheckEnabled: '%env(bool:HIBP_PASSWORD_CHECK_ENABLED)%'

    # Monitoring & Performance (production OVH — écriture en kernel.terminate)
    App\Monitoring\Config\PerformanceMonitoringConfig:
        arguments:
            $enabled: '%env(bool:MONITORING_ENABLED)%'
            $retentionDays: '%env(int:MONITORING_RETENTION_DAYS)%'
            $thresholdDurationMs: '%env(int:MONITORING_THRESHOLD_DURATION_MS)%'
            $thresholdMemoryMb: '%env(int:MONITORING_THRESHOLD_MEMORY_MB)%'
            $thresholdSqlQueries: '%env(int:MONITORING_THRESHOLD_SQL_QUERIES)%'
            $thresholdHttpCalls: '%env(int:MONITORING_THRESHOLD_HTTP_CALLS)%'
            $thresholdImageMs: '%env(int:MONITORING_THRESHOLD_IMAGE_MS)%'

    App\Monitoring\Http\MonitoredHttpClient:
        decorates: 'http_client'
        arguments:
            $client: '@.inner'

    # Profiler runtime léger (var/log/runtime.log) — SHERLOOK_RUNTIME_PROFILER=1
    App\Monitoring\Runtime\RuntimeProfilerConfig:
        arguments:
            $enabled: '%env(bool:SHERLOOK_RUNTIME_PROFILER)%'
            $logPath: '%kernel.project_dir%/var/log/runtime.log'
            $workersRegistryPath: '%kernel.project_dir%/var/log/runtime_workers.json'
            $workersHistoryPath: '%kernel.project_dir%/var/log/runtime_workers_history.jsonl'
            $restartDetectorPath: '%kernel.project_dir%/var/log/runtime_restart_window.json'
            $workerLongRequestMs: '%env(int:SHERLOOK_RUNTIME_WORKER_LONG_REQUEST_MS)%'
            $workerMemoryThresholdMb: '%env(int:SHERLOOK_RUNTIME_WORKER_MEMORY_MB)%'
            $workerNormalMinRequests: '%env(int:SHERLOOK_RUNTIME_WORKER_NORMAL_MIN_REQUESTS)%'
            $workerNormalMinLifetimeSeconds: '%env(int:SHERLOOK_RUNTIME_WORKER_NORMAL_MIN_LIFETIME_S)%'
            $rotationRatioAlertThreshold: '%env(float:SHERLOOK_RUNTIME_ROTATION_RATIO_ALERT)%'

    App\Monitoring\Runtime\Http\RuntimeHttpClientDecorator:
        decorates: 'http_client'
        decoration_priority: -30
        arguments:
            $client: '@.inner'