#ifndef DEFAULT_CONFIG_EVENT_H
#define DEFAULT_CONFIG_EVENT_H

#include <cjson/cJSON.h>
#include "config.h"  // For cli_options_t definition
#include "main.h"    // For relay metadata constants

/*
 * Default Configuration Event Template
 * 
 * This header contains the default configuration values for the C Nostr Relay.
 * These values are used to populate the config table during first-time startup.
 * 
 * IMPORTANT: These values should never be accessed directly by other parts
 * of the program. They are only used during initial configuration event creation.
 */

// Default configuration key-value pairs
static const struct {
    const char* key;
    const char* value;
} DEFAULT_CONFIG_VALUES[] = {
    // Authentication
    {"auth_enabled", "false"},

    // NIP-42 Authentication Settings
    {"nip42_auth_required_events", "false"},
    {"nip42_auth_required_subscriptions", "false"},
    {"nip42_auth_required_kinds", "4,14"},  // Default: DM kinds require auth
    {"nip42_challenge_expiration", "600"},  // 10 minutes
    {"nip42_challenge_timeout", "600"},     // Challenge timeout (seconds)
    {"nip42_time_tolerance", "300"},        // Time tolerance (seconds)

    // NIP-70 Protected Events
    {"nip70_protected_events_enabled", "false"},
    
    // Server Core Settings
    {"relay_port", "8888"},
    {"max_connections", "100"},
    
    // NIP-11 Relay Information (relay keys will be populated at runtime)
    {"relay_name", RELAY_NAME},
    {"relay_description", RELAY_DESCRIPTION},
    {"relay_contact", RELAY_CONTACT},
    {"relay_software", RELAY_SOFTWARE},
    {"relay_version", RELAY_VERSION},
    {"supported_nips", SUPPORTED_NIPS},
    {"language_tags", LANGUAGE_TAGS},
    {"relay_countries", RELAY_COUNTRIES},
    {"posting_policy", POSTING_POLICY},
    {"payments_url", PAYMENTS_URL},
    
    // NIP-13 Proof of Work (pow_min_difficulty = 0 means PoW disabled)
    {"pow_min_difficulty", "0"},
    {"pow_mode", "basic"},
    
    // NIP-40 Expiration Timestamp
    {"nip40_expiration_enabled", "true"},
    {"nip40_expiration_strict", "true"},
    {"nip40_expiration_filter", "true"},
    {"nip40_expiration_grace_period", "300"},
    
    // Subscription Limits
    {"max_subscriptions_per_client", "25"},
    {"max_total_subscriptions", "5000"},
    {"max_filters_per_subscription", "10"},
    
    // Connection Management
    {"max_connection_seconds", "86400"},  // 24 hours (0 = disabled)
    
    // Event Processing Limits
    {"max_event_tags", "100"},
    {"max_content_length", "8196"},
    {"max_message_length", "16384"},
    
    // Performance Settings
    {"default_limit", "500"},
    {"max_limit", "5000"},
    
    // Proxy Settings
    // Trust proxy headers (X-Forwarded-For, X-Real-IP) for accurate client IP detection
    // Safe for informational/debugging use. Only becomes a security concern if you implement
    // IP-based rate limiting or access control (which would require firewall protection anyway)
    {"trust_proxy_headers", "true"},

    // NIP-59 Gift Wrap Timestamp Configuration
    {"nip59_timestamp_max_delay_sec", "0"},

    // Kind 1 Status Posts
    {"kind_1_status_posts_hours", "1"}
};

// Number of default configuration values
#define DEFAULT_CONFIG_COUNT (sizeof(DEFAULT_CONFIG_VALUES) / sizeof(DEFAULT_CONFIG_VALUES[0]))

// Function to create default configuration event
cJSON* create_default_config_event(const unsigned char* admin_privkey_bytes,
                                   const char* relay_privkey_hex,
                                   const char* relay_pubkey_hex,
                                   const cli_options_t* cli_options);

#endif /* DEFAULT_CONFIG_EVENT_H */