#!/usr/bin/env python3
"""
Setup script to generate admin password hash for MySQL database
"""
from passlib.context import CryptContext
import getpass

pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")

def main():
    print("=" * 60)
    print("Epic Travel & Expeditions - Admin Password Setup")
    print("=" * 60)
    print()
    
    password = input("Enter admin password (or press Enter for default 'Joker1974!!!'): ").strip()
    
    if not password:
        password = "Joker1974!!!"
        print(f"Using default password: {password}")
    
    print("\nGenerating bcrypt hash...")
    password_hash = pwd_context.hash(password)
    
    print("\n" + "=" * 60)
    print("PASSWORD HASH GENERATED")
    print("=" * 60)
    print(f"\nPassword: {password}")
    print(f"\nHash: {password_hash}")
    print("\n" + "=" * 60)
    print("\nSQL UPDATE COMMAND:")
    print("=" * 60)
    print(f"""
UPDATE admin_users 
SET password_hash = '{password_hash}' 
WHERE email = 'admin@epictravel.com';
""")
    print("\nCopy the hash above and update your database.")
    print("Or run the SQL UPDATE command in phpMyAdmin.")
    print()

if __name__ == "__main__":
    try:
        main()
    except KeyboardInterrupt:
        print("\n\nOperation cancelled.")
    except Exception as e:
        print(f"\nError: {e}")
