#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = []
# ///

# ─── How to run ───
# 1. Install uv: curl -LsSf https://astral.sh/uv/install.sh | sh
# 2. Use through: uv run python scripts/run_nutricoach_v140_golden_path.py --help
# ──────────────────

"""Actual owner-lifecycle prerequisite for the Monday production draft."""

from __future__ import annotations

from scripts.nutricoach_v140_golden_path_models import CliError

from gateway.platforms.nutrition_coaching import (
    CallbackInput, IncomingAddress, NutritionCoachingCoordinator,
)
CUSTOMER = "client_001"


def seed_owner_snapshot(coordinator: NutritionCoachingCoordinator) -> None:
    """Finalize one real current-day check-in through coordinator handlers."""
    address = IncomingAddress("client", "customer-chat", "41")
    opening = coordinator.open_launcher(CUSTOMER)
    if opening.callback_data is None:
        raise CliError(f"owner seed launcher is unavailable: {opening}")
    _ = coordinator.bind_launcher(CUSTOMER, opening.callback_data, "440")
    _ = coordinator.handle_callback(CallbackInput(opening.callback_data, address, "440"))
    resolved = coordinator.resolve(address)
    if resolved is None:
        raise CliError("owner seed customer is unavailable")
    actions = (
        "value", "value", "value", "value", "value", "value",
        "select", "select", "select", "value", "value", "select",
    )
    answers = (
        "70", "2300", "150 280 65", "계획대로 3식", "2.5", "7",
        "4", "normal", "4", "식욕 3/5, 스트레스 2/5", "하체 70분", "skip",
    )
    reply = resolved.bridge.apply_model_action(actions[0], answers[0])
    for action, value in zip(actions[1:], answers[1:], strict=True):
        reply = resolved.bridge.apply_model_action(action, value)
    if reply.prompt is None:
        raise CliError("owner seed save prompt is unavailable")
    save = next(callback for label, callback in reply.prompt.buttons if label == "저장")
    completed = coordinator.handle_callback(CallbackInput(save, address, "440"))
    if completed.completion is None:
        raise CliError("owner seed did not finalize")
