/**
 * aviation_extension_events.h — Adapter-layer extension event vocabulary.
 *
 * FEATURE TELEMETRY, NOT DOMAIN TRUTH. The state machine never includes
 * this file and never interprets these codes; they ride the bus inside
 * AVIATION_EVT_EXTENSION / AviationExtensionEvent (see aviation_types.h).
 *
 * The code table is the cross-platform contract between the iOS bridge,
 * the Android bridge (generated ExtCodes.kt), and the JS payload shapes
 * both decode into. It is pinned by src/__tests__/crossLanguageParity.test.ts —
 * regenerate the Kotlin side after any change:
 *
 *   node scripts/generate-domain-events.mjs
 */
#ifndef AVIATION_EXTENSION_EVENTS_H
#define AVIATION_EXTENSION_EVENTS_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
    /* Ads (emitted by IMA adapters) */
    AVIATION_EXT_AD_BREAK_STARTED = 0,
    AVIATION_EXT_AD_BREAK_ENDED = 1,
    AVIATION_EXT_AD_STARTED = 2,
    AVIATION_EXT_AD_COMPLETED = 3,
    AVIATION_EXT_AD_PROGRESS = 4,
    AVIATION_EXT_AD_SKIPPED = 5,
    AVIATION_EXT_AD_TAPPED = 6,
    AVIATION_EXT_AD_ERROR = 7,
    AVIATION_EXT_AD_BUFFERING = 8,
    AVIATION_EXT_ALL_ADS_COMPLETED = 9,

    /* Cache observability (emitted by CacheAdapter) */
    AVIATION_EXT_CACHE_HIT = 10,
    AVIATION_EXT_CACHE_MISS = 11,

    /* Preload lifecycle (emitted by PreloadAdapter; layer 1 = cache
     * pre-download, 2 = warm pool) */
    AVIATION_EXT_PRELOAD_STARTED = 12,
    AVIATION_EXT_PRELOAD_COMPLETED = 13,

    /* Time-to-first-frame metric (emitted by the engine bridge) */
    AVIATION_EXT_TTFF = 14,
} AviationExtensionCode;

/* flags bits */
#define AVIATION_EXT_FLAG_AD_SKIPPABLE (1 << 0)

/*
 * Payload slot conventions per code (doubles travel as bit patterns):
 *
 *   AD_*             values[0] breakIndex        text   adId
 *                    values[1] breakTimeMs       detail title
 *                    values[2] totalAdsInBreak   aux    errorMessage (AD_ERROR)
 *                    values[3] durationMs
 *                    values[4] currentMs
 *                    values[5] adIndexInBreak
 *                    values[6] skipOffsetMs
 *                    flags   AVIATION_EXT_FLAG_AD_SKIPPABLE
 *
 *   CACHE_HIT/MISS   values[0] bytes cached      text   uri
 *
 *   PRELOAD_*        values[0] layer (1|2)       text   uri
 *                    values[1] durationMs        aux    error message
 *                            (COMPLETED only)
 *
 *   TTFF             values[0] ttffMs            text   uri
 *                                                detail "cold" | "cache_hit"
 *                                                       | "warm_pool"
 */

#ifdef __cplusplus
}
#endif

#endif /* AVIATION_EXTENSION_EVENTS_H */
