<?php

// Load .env file directly if needed
if (!function_exists('env') || env('TRELLO_API_KEY') === null) {
    $envFile = __DIR__ . '/../.env';
    if (file_exists($envFile)) {
        $lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        $env = [];
        foreach ($lines as $line) {
            if (strpos($line, '=') !== false && strpos($line, '#') !== 0) {
                [$key, $value] = explode('=', $line, 2);
                $env[trim($key)] = trim($value);
            }
        }
    }
}

return [
    'api_key' => env('TRELLO_API_KEY') ?: ($env['TRELLO_API_KEY'] ?? null),
    'api_token' => env('TRELLO_API_TOKEN') ?: ($env['TRELLO_API_TOKEN'] ?? null),
    'board_id' => env('TRELLO_BOARD_ID') ?: ($env['TRELLO_BOARD_ID'] ?? null),
    'webhook_secret' => env('TRELLO_WEBHOOK_SECRET') ?: ($env['TRELLO_WEBHOOK_SECRET'] ?? null),

    'custom_fields' => [
        'order_id'      => '695792226064b67fb4bd46f0',
        'design_name'   => '69579233dbdfa1de96beef7f',
        'customer_name' => '6957924221e31eb4a7a271b0',
        'print_size'    => '6957926dab26ae511aaf17e9',
        'print_stock'   => '6957d40c8ad150b886b978e4',
        'ship_w'        => '6957929435cdaf8b318b16d5',
        'ship_h'        => '695792a3c5ef01fd66d9bb66',
        'ship_l'        => '695792bdba79b9499f0f5f59',
        'weight'        => '695792c98bc7955d6bd796c0',

        'date_created'  => '695792ef2545efa98ef8dce7',
    ],

    'lists' => [
        'standard' => [
            'new_order' => env('TRELLO_LIST_ID_NEW_ORDER') ?: ($env['TRELLO_LIST_ID_NEW_ORDER'] ?? null),
            'prep' => env('TRELLO_LIST_ID_PREP') ?: ($env['TRELLO_LIST_ID_PREP'] ?? null),
            'printing' => env('TRELLO_LIST_ID_PRINTING') ?: ($env['TRELLO_LIST_ID_PRINTING'] ?? null),
            'inspection' => env('TRELLO_LIST_ID_INSPECTION') ?: ($env['TRELLO_LIST_ID_INSPECTION'] ?? null),
            'packing' => env('TRELLO_LIST_ID_PACKING') ?: ($env['TRELLO_LIST_ID_PACKING'] ?? null),
            'ready_to_ship' => env('TRELLO_LIST_ID_READY_TO_SHIP') ?: ($env['TRELLO_LIST_ID_READY_TO_SHIP'] ?? null),
            'awaiting_collection' => env('TRELLO_LIST_ID_AWAITING_COLLECTION') ?: ($env['TRELLO_LIST_ID_AWAITING_COLLECTION'] ?? null),
            'in_transit' => env('TRELLO_LIST_ID_IN_TRANSIT') ?: ($env['TRELLO_LIST_ID_IN_TRANSIT'] ?? null),
            'done' => env('TRELLO_LIST_ID_DONE') ?: ($env['TRELLO_LIST_ID_DONE'] ?? null),
        ],
        'custom' => [
            'new_custom_order' => env('TRELLO_LIST_ID_NEW_CUSTOM_ORDER') ?: ($env['TRELLO_LIST_ID_NEW_CUSTOM_ORDER'] ?? null),
            'design' => env('TRELLO_LIST_ID_DESIGN') ?: ($env['TRELLO_LIST_ID_DESIGN'] ?? null),
            'awaiting_approval' => env('TRELLO_LIST_ID_AWAITING_APPROVAL') ?: ($env['TRELLO_LIST_ID_AWAITING_APPROVAL'] ?? null),
            'awaiting_balance' => env('TRELLO_LIST_ID_AWAITING_BALANCE') ?: ($env['TRELLO_LIST_ID_AWAITING_BALANCE'] ?? null),
            'ready_for_print' => env('TRELLO_LIST_ID_READY_FOR_PRINT') ?: ($env['TRELLO_LIST_ID_READY_FOR_PRINT'] ?? null),
            'printing' => env('TRELLO_LIST_ID_PRINTING') ?: ($env['TRELLO_LIST_ID_PRINTING'] ?? null),
            'inspection' => env('TRELLO_LIST_ID_INSPECTION') ?: ($env['TRELLO_LIST_ID_INSPECTION'] ?? null),
            'packing' => env('TRELLO_LIST_ID_PACKING') ?: ($env['TRELLO_LIST_ID_PACKING'] ?? null),
            'ready_to_ship' => env('TRELLO_LIST_ID_READY_TO_SHIP') ?: ($env['TRELLO_LIST_ID_READY_TO_SHIP'] ?? null),
            'awaiting_collection' => env('TRELLO_LIST_ID_AWAITING_COLLECTION') ?: ($env['TRELLO_LIST_ID_AWAITING_COLLECTION'] ?? null),
            'in_transit' => env('TRELLO_LIST_ID_IN_TRANSIT') ?: ($env['TRELLO_LIST_ID_IN_TRANSIT'] ?? null),
            'done' => env('TRELLO_LIST_ID_DONE') ?: ($env['TRELLO_LIST_ID_DONE'] ?? null),
        ],
    ],
];
