#!/usr/bin/env python3
"""
Demo: Show what happens when you click Load Test Data
"""

from registration_gui import DummyDataGenerator, RegistrationKeyGenerator

print("╔" + "═" * 78 + "╗")
print("║" + " " * 20 + "REGISTRATION GUI - LOAD TEST DATA DEMO" + " " * 20 + "║")
print("╚" + "═" * 78 + "╝")
print()

# Simulate clicking "Load Test Data" on 5-Parameter tab
print("┌─ Tab: 5-Parameter Standard ────────────────────────────────────────────┐")
print("│                                                                         │")
print("│  [BEFORE]  All fields are empty                                        │")
print("│                                                                         │")
print("│    First Name:     [                    ]                              │")
print("│    Last Name:      [                    ]                              │")
print("│    Product Name:   [                    ]                              │")
print("│    Secret Key:     [                    ]                              │")
print("│    Email:          [                    ]                              │")
print("│                                                                         │")
print("└─────────────────────────────────────────────────────────────────────────┘")
print()
print("         ↓ User clicks 'Load Test Data' button ↓")
print()

# Generate data
data = DummyDataGenerator.generate()

print("┌─ Popup Message ─────────────────────────────────────────────────────────┐")
print("│                                                                         │")
print("│  ℹ Test Data Loaded                                                    │")
print("│                                                                         │")
print(f"│  Dummy test data loaded:                                                │")
print(f"│                                                                         │")
print(f"│  Name:    {data['first_name']} {data['last_name']:<30}│")
print(f"│  Email:   {data['email']:<48}│")
print(f"│  Product: {data['product']:<48}│")
print(f"│  Secret:  {data['secret']:<48}│")
print(f"│  Serial:  {data['serial']:<48}│")
print("│                                                                         │")
print("│  Click 'Generate Registration Key' to create a valid key for this      │")
print("│  data.                                                                  │")
print("│                                                                         │")
print("│                               [ OK ]                                    │")
print("└─────────────────────────────────────────────────────────────────────────┘")
print()

print("┌─ Tab: 5-Parameter Standard ────────────────────────────────────────────┐")
print("│                                                                         │")
print("│  [AFTER]  All fields are filled with test data                         │")
print("│                                                                         │")
print(f"│    First Name:     [ {data['first_name']:<15} ]                              │")
print(f"│    Last Name:      [ {data['last_name']:<15} ]                              │")
print(f"│    Product Name:   [ {data['product']:<15} ]                              │")
print(f"│    Secret Key:     [ {data['secret']:<15} ]                              │")
print(f"│    Email:          [ {data['email']:<40} ] │")
print("│                                                                         │")
print("│         [Load Test Data] [Generate Registration Key] [Validate Key]    │")
print("│                                                                         │")
print("└─────────────────────────────────────────────────────────────────────────┘")
print()
print("         ↓ User clicks 'Generate Registration Key' ↓")
print()

# Generate valid key
key = RegistrationKeyGenerator.generate_key_5param(
    data['first_name'],
    data['last_name'],
    data['product'],
    data['secret'],
    data['email']
)

print("┌─ Generated Registration Key ────────────────────────────────────────────┐")
print("│                                                                         │")
print("│  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓  │")
print(f"│  ┃  {key:^64}  ┃  │")
print("│  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛  │")
print("│                                                                         │")
print("│                       [Copy to Clipboard]                               │")
print("│                                                                         │")
print("└─────────────────────────────────────────────────────────────────────────┘")
print()
print("         ↓ User clicks 'Validate Key' ↓")
print()
print("┌─ Popup Message ─────────────────────────────────────────────────────────┐")
print("│                                                                         │")
print("│  ✓ Valid Registration                                                  │")
print("│                                                                         │")
print("│  Registration key is VALID!                                            │")
print("│                                                                         │")
print(f"│  Registered to:                                                         │")
print(f"│    Name:    {data['first_name']} {data['last_name']:<40}│")
print(f"│    Email:   {data['email']:<48}│")
print(f"│    Product: {data['product']:<48}│")
print("│                                                                         │")
print("│                               [ OK ]                                    │")
print("└─────────────────────────────────────────────────────────────────────────┘")
print()
print()

# Now show Email Parser tab
print("╔" + "═" * 78 + "╗")
print("║" + " " * 25 + "EMAIL PARSER TAB DEMO" + " " * 32 + "║")
print("╚" + "═" * 78 + "╝")
print()

data2 = DummyDataGenerator.generate()
key2 = RegistrationKeyGenerator.generate_key_5param(
    data2['first_name'],
    data2['last_name'],
    data2['product'],
    data2['secret'],
    data2['email']
)

print("┌─ Tab: Email Parser ─────────────────────────────────────────────────────┐")
print("│                                                                         │")
print("│  Parse or Generate Registration Emails:                                │")
print("│  • PARSE: Paste email → Extract fields                                 │")
print("│  • GENERATE: Fill fields → Create formatted text                       │")
print("│                                                                         │")
print("│         [Load Test Data] [Parse Email] [Generate Email Format]         │")
print("│                                                                         │")
print("└─────────────────────────────────────────────────────────────────────────┘")
print()
print("         ↓ User clicks purple 'Load Test Data' button ↓")
print()
print("┌─ Popup Message ─────────────────────────────────────────────────────────┐")
print("│                                                                         │")
print("│  ℹ Test Data Loaded                                                    │")
print("│                                                                         │")
print(f"│  Dummy test data with VALID key loaded:                                │")
print(f"│                                                                         │")
print(f"│  Name:      {data2['first_name']} {data2['last_name']:<45}│")
print(f"│  Email:     {data2['email']:<46}│")
print(f"│  Product:   {data2['product']:<46}│")
print(f"│  Secret:    {data2['secret']:<46}│")
print(f"│  Serial:    {data2['serial']:<46}│")
print(f"│  Algorithm: 5-parameter (Standard)                                      │")
print("│                                                                         │")
print("│  You can now:                                                           │")
print("│  • Click 'Generate Email Format' to create formatted text               │")
print(f"│  • Click 'Validate Key' (use product={data2['product']}, " + " " * (16 - len(data2['product'])) + "│")
print(f"│    secret={data2['secret']})" + " " * (51 - len(data2['secret'])) + "│")
print("│                                                                         │")
print("│                               [ OK ]                                    │")
print("└─────────────────────────────────────────────────────────────────────────┘")
print()
print("┌─ Tab: Email Parser (After Load) ────────────────────────────────────────┐")
print("│                                                                         │")
print("│  Extracted Information:                                                 │")
print(f"│    First Name:        [ {data2['first_name']:<15} ]                           │")
print(f"│    Last Name:         [ {data2['last_name']:<15} ]                           │")
print(f"│    Email:             [ {data2['email']:<36} ] │")
print(f"│    Serial Number:     [ {data2['serial']:<15} ]                           │")
print(f"│    Registration Key:  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓                    │")
print(f"│                       ┃ {key2:^25} ┃                    │")
print(f"│                       ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛                    │")
print("│                                                                         │")
print("│  [Load Test Data] [Parse] [Generate Email] [Copy Key] [Validate Key]   │")
print("│                                                                         │")
print("└─────────────────────────────────────────────────────────────────────────┘")
print()
print()
print("=" * 80)
print("KEY FEATURES:")
print("=" * 80)
print()
print("✓ Automatic population of all fields")
print("✓ Valid registration keys generated (not random gibberish!)")
print("✓ Keys pass validation tests")
print("✓ Works on all 5 tabs (Basic, 5-param, 7-param, 8-param, Email Parser)")
print("✓ Realistic names and emails")
print("✓ Saves time during testing and development")
print("✓ Product/Secret shown in popup for easy validation testing")
print()
