<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\MediaStreamController;


Route::get('/', function () { return redirect()->route('login'); });

Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
Route::post('/login', [AuthController::class, 'login']);
Route::post('/logout', [AuthController::class, 'logout'])->name('logout');

// Web App Dashboards under Auth Guard
Route::middleware(['auth'])->group(function () {
    Route::get('/console/user', [DashboardController::class, 'userDashboard'])->name('user.dashboard');
    Route::get('/console/admin', [DashboardController::class, 'adminDashboard'])->name('admin.dashboard');
    Route::get('/console/agency', [DashboardController::class, 'agencyDashboard'])->name('agency.dashboard');
});

// Explicit endpoint API for Hybrid App interactions
Route::post('/api/external/signal', [DashboardController::class, 'receiveAlertApi']);

Route::middleware('auth:sanctum')->group(function () {
    // Call this route first from the Android client to obtain a signed playback token link
    Route::get('/alerts/{id}/stream-access', [MediaStreamController::class, 'getAuthenticatedStreamUrl']);
});

// Protected streaming execution access path route endpoint signature verification block channel
Route::get('/stream/evidence', [MediaStreamController::class, 'streamEvidenceFile'])->name('secure.media.serve');
