<?php
declare(strict_types=1);

require_once __DIR__ . '/../config/helpers.php';
require_once __DIR__ . '/../config/tarifas_helpers.php';

try {
    $lat = isset($_GET['lat']) ? (float) $_GET['lat'] : null;
    $lng = isset($_GET['lng']) ? (float) $_GET['lng'] : null;
    $resultado = tarifas_resolver_por_ponto(db(), $lat, $lng, false);

    json_ok($resultado);
} catch (Throwable $e) {
    json_fail('Erro ao buscar configuracoes.', 500, ['error' => $e->getMessage()]);
}
