"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.App = App;
const jsx_runtime_1 = require("react/jsx-runtime");
const ink_1 = require("ink");
const TrelloContext_1 = require("./state/TrelloContext");
const NavigationContext_1 = require("./state/NavigationContext");
const Header_1 = require("./components/Header");
const Footer_1 = require("./components/Footer");
const HomeView_1 = require("./views/HomeView");
const BoardView_1 = require("./views/BoardView");
const CardDetailView_1 = require("./views/CardDetailView");
const MyCardsView_1 = require("./views/MyCardsView");
const usePeriodicSync_1 = require("./hooks/usePeriodicSync");
const useTerminalSize_1 = require("./hooks/useTerminalSize");
function ViewRouter() {
    const { state, config } = (0, NavigationContext_1.useNavigation)();
    const { rows: termHeight } = (0, useTerminalSize_1.useTerminalSize)();
    // Set up periodic sync
    (0, usePeriodicSync_1.usePeriodicSync)(config.syncIntervalMs);
    return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", height: termHeight, children: [state.view !== "card-detail" && (0, jsx_runtime_1.jsx)(Header_1.Header, {}), (0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", flexGrow: 1, paddingY: 1, children: [state.view === "home" && (0, jsx_runtime_1.jsx)(HomeView_1.HomeView, {}), state.view === "board" && (0, jsx_runtime_1.jsx)(BoardView_1.BoardView, {}), state.view === "card-detail" && (0, jsx_runtime_1.jsx)(CardDetailView_1.CardDetailView, {}), state.view === "my-cards" && (0, jsx_runtime_1.jsx)(MyCardsView_1.MyCardsView, {})] }), (0, jsx_runtime_1.jsx)(Footer_1.Footer, {})] }));
}
function App({ client, cache, config }) {
    return ((0, jsx_runtime_1.jsx)(TrelloContext_1.TrelloProvider, { client: client, cache: cache, children: (0, jsx_runtime_1.jsx)(NavigationContext_1.NavigationProvider, { config: config, children: (0, jsx_runtime_1.jsx)(ViewRouter, {}) }) }));
}
