# ── Generated by Nexa Transpiler ──────────────────────────────
# This file was auto-generated from a .nexa source file.
# Do not edit directly — regenerate with: nexa compile <file>
# ─────────────────────────────────────────────────────────────
from __future__ import annotations
import asyncio, math, json, os, random, time as _time

# ── Nexa runtime stubs ───────────────────────────────────────
_nexa_modules = {}

print('=== Nexa v7 Showcase ===\n')
print('--- 1. Enums ---')
from enum import Enum as _Enum
class Status(_Enum):
    IDLE = 1
    RUNNING = 2
    COMPLETED = 3
    FAILED = 4
current_status = Status.RUNNING
print(f"Current Status: {current_status}")
print('\n--- 2. Decorators & Web Framework ---')
def auth_required(fn):
    def wrapper(req):
        token = req['query'].get('token', None)
        if (token != 'secret123'):
            return {'error': 'Unauthorized', 'status': 401}
        return fn(req)
    return wrapper
@serve.get('/api/health')
def health_check(req):
    return {'status': 'ok', 'service': 'Nexa API v7'}
@serve.get('/api/secure')
@auth_required
def secure_data(req):
    return {'data': 'This is highly classified AI data.'}
print('Starting Nexa web server on port 8282...')
serve.start(8282, True)
time.sleep(1)
h_res = http.get('http://localhost:8282/api/health')
print(f"Health API Response: {h_res['body']}")
s_res1 = http.get('http://localhost:8282/api/secure')
print(f"Secure API (No Token): {s_res1['body']}")
s_res2 = http.get('http://localhost:8282/api/secure?token=secret123')
print(f"Secure API (With Token): {s_res2['body']}")
print('\n--- 3. Environment Module (env) ---')
env.set('NEXA_ENV', 'production')
print(f"NEXA_ENV is set to: {env.get('NEXA_ENV')}")
print('\n--- 4. Tensor Module (Numpy) ---')
t1 = tensor.ones([2, 2])
t2 = tensor.create([[1, 2], [3, 4]])
print(('Tensor 1 (ones):\n' + str(t1)))
print(('Tensor 2 (custom):\n' + str(t2)))
dot_product = tensor.dot(t1, t2)
print(('Dot Product:\n' + str(dot_product)))
print('\n✅ All Nexa v7 features successfully verified!')
