import { DEFAULT_MARKET_TYPES } from './market-catalog';
/** 第一版仅足球；字段预留其他 sportType */
export const SPORT_TYPE_FOOTBALL = 'FOOTBALL';
/** 常规赛事发布时生成的赛前盘口（手动维护，不含冠军盘） */
export const STANDARD_PREMATCH_MARKET_TYPES = DEFAULT_MARKET_TYPES;
export const HANDICAP_TOTAL_MARKET_TYPES = [
    'FT_HANDICAP',
    'HT_HANDICAP',
    'FT_OVER_UNDER',
    'HT_OVER_UNDER',
    'FT_TEAM_TOTAL_HOME',
    'FT_TEAM_TOTAL_AWAY',
    'FT_CORNERS_HANDICAP',
    'FT_CORNERS_OVER_UNDER',
    'FT_CARDS_OVER_UNDER',
];
export function isQuarterLine(line) {
    if (line == null || Number.isNaN(line))
        return false;
    const frac = Math.abs(line % 1);
    return Math.abs(frac - 0.25) < 0.001 || Math.abs(frac - 0.75) < 0.001;
}
export function isQuarterHandicapOrTotal(line) {
    return isQuarterLine(line);
}
export function canSelectForParlay(params) {
    if (params.marketType === 'OUTRIGHT_WINNER' || params.isOutright) {
        return { ok: false, reason: 'OUTRIGHT' };
    }
    if (params.allowParlay === false) {
        return { ok: false, reason: 'NOT_ALLOWED' };
    }
    if (HANDICAP_TOTAL_MARKET_TYPES.includes(params.marketType) &&
        isQuarterHandicapOrTotal(params.lineValue ?? null)) {
        return { ok: false, reason: 'QUARTER_LINE' };
    }
    return { ok: true };
}
export function isPreMatchKickoff(startTime) {
    return new Date() < new Date(startTime);
}
export function isSupportedSport(sportType) {
    return (sportType ?? SPORT_TYPE_FOOTBALL) === SPORT_TYPE_FOOTBALL;
}
