#ifndef DECK_READING_IO_H
#define DECK_READING_IO_H

#include <stdbool.h>
#include <stddef.h>

/* Header-only dependency on the engine, same policy as significance.h -
 * see its comment for why. */
#include "../../engine/src/reading.h"

/* Parses deck-engine's `--format json` output (text, null-terminated at
 * text[length]) and fills *out with just enough of a DailyReading for
 * interpret_daily_reading() to work on, for reporting sign/house context
 * around each significant event, and for guidance_print()'s tarot
 * framing: out->transits.aspects[]/aspect_count (used for scoring - see
 * significance.c), out->natal.bodies[]/out->transits.bodies[] (sign +
 * house per body, used only for display), and out->spread.positions[]
 * (card + reversed per Celtic Cross position, used only by
 * guidance.c). out->natal.ascendant_longitude/houses[] are left zeroed -
 * nothing reads them yet.
 *
 * Returns false on malformed JSON, or if "transits"."aspects" isn't
 * present as an array (an empty array is fine - that's a real "no
 * aspects today" reading, not an error). A missing/unrecognized entry in
 * "natal"."bodies"/"transits"."bodies"/"spread"."positions", or a
 * missing "spread" key entirely, is not an error - see parse_bodies()/
 * parse_spread() in reading_io.c. */
bool reading_load_json(const char *text, size_t length, DailyReading *out);

#endif
