<?php
/**
 * Chairman Production Helper v3.1
 * Future analysis.php safe entry.
 */
require_once dirname(__DIR__) . '/bootstrap/chairman_production_core_bootstrap.php';

function chairman_production_payload($raceDate, $venue='', $raceNum=0, $mode='BALANCED', $autoBuild=true) {
    global $ChairmanProductionCore;
    try {
        return $ChairmanProductionCore->payload($raceDate,$venue,$raceNum,$mode,$autoBuild);
    } catch (Exception $e) {
        return array('status'=>'ERROR','message'=>$e->getMessage(),'summary'=>array(),'ranking'=>array());
    } catch (Throwable $e) {
        return array('status'=>'ERROR','message'=>$e->getMessage(),'summary'=>array(),'ranking'=>array());
    }
}

function chairman_production_ranking($raceDate, $venue='', $raceNum=0) {
    $p = chairman_production_payload($raceDate,$venue,$raceNum,'BALANCED',false);
    return isset($p['ranking']) && is_array($p['ranking']) ? $p['ranking'] : array();
}

function chairman_production_summary($raceDate, $venue='', $raceNum=0) {
    $p = chairman_production_payload($raceDate,$venue,$raceNum,'BALANCED',false);
    return isset($p['summary']) && is_array($p['summary']) ? $p['summary'] : array();
}
