<?php

return [
    'data_path' => env('DEWEMOJI_DATA_PATH') ?: base_path('data/emojis.json'),

    'pagination' => [
        'default_limit' => (int) env('DEWEMOJI_DEFAULT_LIMIT', 20),
        'max_limit' => (int) env('DEWEMOJI_MAX_LIMIT', 50),
        'free_max_limit' => (int) env('DEWEMOJI_FREE_MAX_LIMIT', 20),
        'pro_max_limit' => (int) env('DEWEMOJI_PRO_MAX_LIMIT', 50),
    ],

    'billing' => [
        'mode' => env('DEWEMOJI_BILLING_MODE', 'sandbox'),
        'pending_cooldown_seconds' => (int) env('DEWEMOJI_CHECKOUT_PENDING_COOLDOWN', 120),
        'providers' => [
            'paypal' => [
                'enabled' => filter_var(env('DEWEMOJI_PAYPAL_ENABLED', false), FILTER_VALIDATE_BOOL),
                'timeout' => (int) env('DEWEMOJI_PAYPAL_TIMEOUT', 10),
                'webhook_ids' => [
                    'sandbox' => env('DEWEMOJI_PAYPAL_SANDBOX_WEBHOOK_ID', ''),
                    'live' => env('DEWEMOJI_PAYPAL_LIVE_WEBHOOK_ID', ''),
                ],
                'plan_ids' => [
                    'sandbox' => [
                        'personal_monthly' => env('DEWEMOJI_PAYPAL_SANDBOX_PLAN_PERSONAL_MONTHLY', ''),
                        'personal_annual' => env('DEWEMOJI_PAYPAL_SANDBOX_PLAN_PERSONAL_ANNUAL', ''),
                    ],
                    'live' => [
                        'personal_monthly' => env('DEWEMOJI_PAYPAL_LIVE_PLAN_PERSONAL_MONTHLY', ''),
                        'personal_annual' => env('DEWEMOJI_PAYPAL_LIVE_PLAN_PERSONAL_ANNUAL', ''),
                    ],
                ],
                'sandbox' => [
                    'api_base' => env('DEWEMOJI_PAYPAL_SANDBOX_API_BASE', 'https://api-m.sandbox.paypal.com'),
                    'web_base' => env('DEWEMOJI_PAYPAL_SANDBOX_WEB_BASE', 'https://www.sandbox.paypal.com'),
                    'client_id' => env('DEWEMOJI_PAYPAL_SANDBOX_CLIENT_ID', ''),
                    'client_secret' => env('DEWEMOJI_PAYPAL_SANDBOX_CLIENT_SECRET', ''),
                ],
                'live' => [
                    'api_base' => env('DEWEMOJI_PAYPAL_LIVE_API_BASE', 'https://api-m.paypal.com'),
                    'web_base' => env('DEWEMOJI_PAYPAL_LIVE_WEB_BASE', 'https://www.paypal.com'),
                    'client_id' => env('DEWEMOJI_PAYPAL_LIVE_CLIENT_ID', ''),
                    'client_secret' => env('DEWEMOJI_PAYPAL_LIVE_CLIENT_SECRET', ''),
                ],
            ],
            'pakasir' => [
                'enabled' => filter_var(env('DEWEMOJI_PAKASIR_ENABLED', false), FILTER_VALIDATE_BOOL),
                'api_base' => env('DEWEMOJI_PAKASIR_API_BASE', ''),
                'api_key' => env('DEWEMOJI_PAKASIR_API_KEY', ''),
                'project' => env('DEWEMOJI_PAKASIR_PROJECT', ''),
                'timeout' => (int) env('DEWEMOJI_PAKASIR_TIMEOUT', 10),
            ],
        ],
    ],

    'cors' => [
        'allowed_origins' => array_values(array_filter(array_map('trim', explode(',', (string) env('DEWEMOJI_ALLOWED_ORIGINS', 'http://127.0.0.1:8000,http://localhost:8000,https://dewemoji.com,https://www.dewemoji.com'))))),
        'allow_all_public' => filter_var(env('DEWEMOJI_CORS_ALLOW_ALL_PUBLIC', true), FILTER_VALIDATE_BOOL),
        'allow_methods' => 'GET, POST, OPTIONS',
        'allow_headers' => 'Content-Type, Authorization, X-Api-Key, X-Admin-Token, X-Account-Id, X-Dewemoji-Frontend, X-Extension-Token',
    ],

    'admin' => [
        'token' => env('DEWEMOJI_ADMIN_TOKEN', ''),
    ],

    'pricing' => [
        'usd_rate' => (int) env('DEWEMOJI_USD_RATE', 15000),
        'defaults' => [
            [
                'code' => 'personal_monthly',
                'name' => 'Personal Monthly',
                'currency' => 'IDR',
                'amount' => 30000,
                'period' => 'month',
                'status' => 'active',
            ],
            [
                'code' => 'personal_annual',
                'name' => 'Personal Annual',
                'currency' => 'IDR',
                'amount' => 300000,
                'period' => 'year',
                'status' => 'active',
            ],
            [
                'code' => 'personal_lifetime',
                'name' => 'Personal Lifetime',
                'currency' => 'IDR',
                'amount' => 900000,
                'period' => null,
                'status' => 'active',
            ],
        ],
    ],

    'payments' => [
        'qris_url' => env('DEWEMOJI_QRIS_URL', ''),
        'paypal_url' => env('DEWEMOJI_PAYPAL_URL', ''),
    ],

    'frontend' => [
        'header_token' => env('DEWEMOJI_FRONTEND_HEADER', 'web-v1'),
    ],

    'public_access' => [
        'enforce_whitelist' => filter_var(env('DEWEMOJI_PUBLIC_ENFORCE', true), FILTER_VALIDATE_BOOL),
        'allowed_origins' => array_values(array_filter(array_map('trim', explode(',', (string) env('DEWEMOJI_PUBLIC_ORIGINS', 'http://127.0.0.1:8000,http://localhost:8000,https://dewemoji.com,https://www.dewemoji.com'))))),
        'extension_ids' => array_values(array_filter(array_map('trim', explode(',', (string) env('DEWEMOJI_EXTENSION_IDS', ''))))),
        'hourly_limit' => (int) env('DEWEMOJI_PUBLIC_HOURLY_LIMIT', 5000),
    ],

    'extension_verification' => [
        'enabled' => filter_var(env('DEWEMOJI_EXTENSION_VERIFY_ENABLED', true), FILTER_VALIDATE_BOOL),
        'project_id' => env('DEWEMOJI_GOOGLE_PROJECT_ID', ''),
        'server_key' => env('DEWEMOJI_GOOGLE_SERVER_KEY', ''),
        'cache_ttl' => (int) env('DEWEMOJI_EXTENSION_VERIFY_CACHE_TTL', 3600),
    ],

    'metrics' => [
        'enabled' => filter_var(env('DEWEMOJI_METRICS_ENABLED', true), FILTER_VALIDATE_BOOL),
        'token' => (string) env('DEWEMOJI_METRICS_TOKEN', ''),
        'allow_ips' => array_values(array_filter(array_map('trim', explode(',', (string) env('DEWEMOJI_METRICS_ALLOW_IPS', '127.0.0.1,::1'))))),
    ],

    'apk_release' => [
        'enabled' => filter_var(env('DEWEMOJI_APK_RELEASE_ENABLED', false), FILTER_VALIDATE_BOOL),
        'app_id' => (string) env('DEWEMOJI_APK_APP_ID', 'com.dewemoji.app'),
        'channel' => (string) env('DEWEMOJI_APK_CHANNEL', 'stable'),
        'min_supported_version_code' => (int) env('DEWEMOJI_APK_MIN_SUPPORTED_VERSION_CODE', 1),
        'public_base_url' => (string) env('DEWEMOJI_APK_PUBLIC_BASE_URL', 'https://dewemoji.com/downloads'),
        'r2_public_base_url' => (string) env('DEWEMOJI_R2_PUBLIC_BASE_URL', ''),
        'r2_keys' => [
            'latest_apk' => (string) env('DEWEMOJI_R2_APK_LATEST_KEY', 'apk/dewemoji-latest.apk'),
            'version_json' => (string) env('DEWEMOJI_R2_APK_VERSION_KEY', 'apk/version.json'),
        ],
        'assetlinks' => [
            'fingerprints' => array_values(array_filter(array_map('trim', explode(',', (string) env('DEWEMOJI_APK_ASSETLINKS_SHA256', ''))))),
        ],
    ],
];
