import os
import re
import time


def project_context(request):
    """
    Adds project-specific environment variables to the template context globally.
    """
    store_phone_display = os.getenv("STORE_PHONE", "0214 41243")
    store_phone_link = re.sub(r"[^\d+]", "", store_phone_display)

    return {
        "project_description": os.getenv("PROJECT_DESCRIPTION", ""),
        "project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
        "store_name": os.getenv("STORE_NAME", "Juwelier Thelen"),
        "store_phone_display": store_phone_display,
        "store_phone_link": store_phone_link,
        "store_email": os.getenv("STORE_EMAIL", "info@juwelierthelen.de"),
        "store_address": os.getenv("STORE_ADDRESS", "Wiesdorfer Platz 59, 51373 Leverkusen"),
        "deployment_timestamp": int(time.time()),
    }
