<?php
header('Content-Type: application/json');

$cacheFile = __DIR__ . "/cache_jadwal.json";

// fallback default
$default = [
    "subuh" => 296,
    "dzuhur" => 712,
    "ashar" => 913,
    "maghrib" => 1071,
    "isya" => 1129
];

// ================= CEK FILE =================
if (!file_exists($cacheFile)) {
    echo json_encode($default);
    exit;
}

// ================= BACA FILE =================
$data = json_decode(file_get_contents($cacheFile), true);

// ================= VALIDASI =================
if (!$data || !isset($data['data'])) {
    echo json_encode($default);
    exit;
}

// ================= OUTPUT =================
echo json_encode($data['data']);