<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Third Party Services
    |--------------------------------------------------------------------------
    |
    | This file is for storing the credentials for third party services such
    | as Mailgun, Postmark, AWS and more. This file provides the de facto
    | location for this type of information, allowing packages to have
    | a conventional file to locate the various service credentials.
    |
    */

    'postmark' => [
        'token' => env('POSTMARK_TOKEN'),
    ],

    'ses' => [
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    ],

    'resend' => [
        'key' => env('RESEND_KEY'),
    ],

    'slack' => [
        'notifications' => [
            'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
            'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Razorpay Configuration
    |--------------------------------------------------------------------------
    */

    'razorpay' => [
        'key' => env('RZP_KEY') ?: env('RAZORPAY_KEY') ?: env('RAZORPAY_KEY_ID'),
        'secret' => env('RZP_SECRET') ?: env('RAZORPAY_SECRET') ?: env('RAZORPAY_KEY_SECRET') ?: env('RAZORPAY_SECRET_KEY'),
        'webhook_secret' => env('RAZORPAY_WEBHOOK_SECRET'),
        // Grace period before releasing stock after payment.failed (UPI can capture minutes later).
        'failed_webhook_grace_seconds' => (int) env('RAZORPAY_FAILED_WEBHOOK_GRACE_SECONDS', 300),
    ],

    /*
    |--------------------------------------------------------------------------
    | Fast2SMS Configuration
    |--------------------------------------------------------------------------
    */

    'fast2sms' => [
        // Note: These are now read from Settings table in OtpService
        // Kept here for backward compatibility only
        'api_key' => env('FAST2SMS_API_KEY'),
        'sender' => env('FAST2SMS_SENDER', 'KIYO'),
        'route' => env('FAST2SMS_ROUTE', 'q'),
        'entity_id' => env('FAST2SMS_ENTITY_ID'),
        'template_id_login' => env('FAST2SMS_TEMPLATE_ID_LOGIN'),
        'template_id_pos' => env('FAST2SMS_TEMPLATE_ID_POS'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Delhivery Configuration
    |--------------------------------------------------------------------------
    */

    'delhivery' => [
        'api_url' => env('DELHIVERY_API_URL', 'https://track.delhivery.com'),
        'api_token' => env('DELHIVERY_API_TOKEN','538caac48c8d5d1834a94765bb3be2c683b03150'),
        'warehouse_pin' => env('DELHIVERY_WAREHOUSE_PIN', '521002'),
        'pickup_name' => env('DELHIVERY_PICKUP_NAME', 'Sudheer kt one gram gold'),
        'phone' => env('DELHIVERY_PHONE', '7013370982'),
        'address_line1' => env('DELHIVERY_ADDRESS_LINE1', 'sudheer kt one gram gold , kobbarithota, machilipatnam andhra pradesh'),
        'city' => env('DELHIVERY_CITY', 'Machilipatnam'),
        'state' => env('DELHIVERY_STATE', 'Andhra Pradesh'),
        'pin' => env('DELHIVERY_PIN', '521002'),
    ],

    'xpressbees' => [
        'consigner_name' => env('XPRESSBEES_CONSIGNER_NAME', 'Kiyo Solutions Pvt Ltd'),
        'consigner_phone' => env('XPRESSBEES_CONSIGNER_PHONE', '9966337448'),
        'consigner_city' => env('XPRESSBEES_CONSIGNER_CITY', 'HYDERABAD'),
        'consigner_state' => env('XPRESSBEES_CONSIGNER_STATE', 'telangana'),
        'consigner_address' => env('XPRESSBEES_CONSIGNER_ADDRESS', 'House no 101,1st Floor, Latha Residency, 2, Prashanthi Hills, Madhura Nagar, Nizampet'),
        'consigner_pincode' => env('XPRESSBEES_CONSIGNER_PINCODE', '500090'),
        'pickup_location' => env('XPRESSBEES_PICKUP_LOCATION', 'franchise'),
        'gstin' => env('XPRESSBEES_GSTIN', '36AAICK1529M1Z8'),
    ],

    'ekart' => [
        'pickup_name' => env('EKART_PICKUP_NAME', 'Shiva Jewellers'),
        'consigner_address' => env('EKART_CONSIGNER_ADDRESS', 'first floor, New City fabric centre, beside Madhuri bar & restaurant, Badrakali Housing Society Colony, Old Beet Bazaar, Warangal, Telangana'),
        'consigner_city' => env('EKART_CONSIGNER_CITY', 'Warangal'),
        'consigner_state' => env('EKART_CONSIGNER_STATE', 'Telangana'),
        'consigner_phone' => env('EKART_CONSIGNER_PHONE', '9966337448'),
        'consigner_pincode' => env('EKART_CONSIGNER_PINCODE', '506002'),
    ],

    'admin_ui' => [
        /*
         * Supports both formats in .env:
         * 1) #2563EB,#10B981,#F59E0B
         * 2) ["#2563EB","#10B981","#F59E0B"]
         */
        'customer_avatar_colors' => (static function (): array {
            $raw = (string) env('ADMIN_CUSTOMER_AVATAR_COLORS', '#6366F1,#8B5CF6,#EC4899,#F43F5E,#F97316,#F59E0B,#10B981,#14B8A6,#0EA5E9,#64748B');
            $parts = preg_split('/\s*,\s*/', trim($raw)) ?: [];
            $normalized = [];

            foreach ($parts as $part) {
                $color = trim($part, " \t\n\r\0\x0B\"'[];");
                if ($color === '') {
                    continue;
                }

                if ($color[0] !== '#') {
                    $color = '#' . $color;
                }

                if (preg_match('/^#[0-9A-Fa-f]{6}$/', $color)) {
                    $normalized[] = strtoupper($color);
                }
            }

            return $normalized !== []
                ? array_values(array_unique($normalized))
                : ["#6366F1","#8B5CF6","#EC4899","#F43F5E","#F97316","#F59E0B","#10B981","#14B8A6","#0EA5E9","#64748B"];;
        })(),
    ],
];
