"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VodControls = VodControls;
const jsx_runtime_1 = require("react/jsx-runtime");
const lucide_react_native_1 = require("lucide-react-native");
const react_native_1 = require("react-native");
const __1 = require("../../..");
const livestream_store_1 = require("../../../livestream-store");
const player_store_1 = require("../../../player-store");
const ui_1 = require("../../ui");
function formatTime(seconds) {
    const s = Math.floor(seconds);
    const h = Math.floor(s / 3600);
    const m = Math.floor((s % 3600) / 60);
    const sec = s % 60;
    const pad = (n) => String(n).padStart(2, "0");
    if (h > 0)
        return `${h}:${pad(m)}:${pad(sec)}`;
    return `${m}:${pad(sec)}`;
}
function VodControls() {
    const mode = (0, player_store_1.usePlayerStore)((x) => x.mode);
    const status = (0, player_store_1.usePlayerStore)((x) => x.status);
    const togglePlayPause = (0, player_store_1.usePlayerStore)((x) => x.togglePlayPause);
    const quality = (0, player_store_1.usePlayerStore)((x) => x.selectedRendition);
    const setQuality = (0, player_store_1.usePlayerStore)((x) => x.setSelectedRendition);
    const liveRenditions = (0, livestream_store_1.useLivestreamStore)((x) => x.renditions);
    const vodLevels = (0, player_store_1.usePlayerStore)((x) => x.vodLevels);
    const renditions = mode === "vod" ? vodLevels : liveRenditions;
    const th = (0, ui_1.useTheme)();
    const playTime = (0, player_store_1.usePlayerStore)((x) => x.playTime);
    const duration = (0, player_store_1.usePlayerStore)((x) => x.duration);
    if (mode !== "vod")
        return null;
    const isPlaying = status === player_store_1.PlayerStatus.PLAYING;
    return ((0, jsx_runtime_1.jsxs)(ui_1.View, { style: {
            flexDirection: "row",
            alignItems: "center",
            paddingHorizontal: 16,
            paddingVertical: 10,
            gap: 12,
        }, children: [(0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onPress: togglePlayPause, children: isPlaying ? ((0, jsx_runtime_1.jsx)(lucide_react_native_1.Pause, { size: 22, color: th.theme.colors.foreground, fill: th.theme.colors.foreground })) : ((0, jsx_runtime_1.jsx)(lucide_react_native_1.Play, { size: 22, color: th.theme.colors.foreground, fill: th.theme.colors.foreground })) }), (0, jsx_runtime_1.jsxs)(ui_1.View, { style: [__1.zero.layout.flex.row, __1.zero.gap.all[1]], children: [(0, jsx_runtime_1.jsx)(ui_1.Text, { children: formatTime(playTime) }), (0, jsx_runtime_1.jsx)(ui_1.Text, { children: "/" }), (0, jsx_runtime_1.jsx)(ui_1.Text, { children: formatTime(duration) })] }), (0, jsx_runtime_1.jsx)(ui_1.View, { style: { flex: 1 } }), renditions.length > 0 && ((0, jsx_runtime_1.jsxs)(ui_1.DropdownMenu, { children: [(0, jsx_runtime_1.jsx)(ui_1.DropdownMenuTrigger, { children: (0, jsx_runtime_1.jsx)(lucide_react_native_1.Gauge, { size: 20, color: th.theme.colors.foreground }) }), (0, jsx_runtime_1.jsx)(ui_1.ResponsiveDropdownMenuContent, { side: "top", align: "end", children: (0, jsx_runtime_1.jsx)(ui_1.DropdownMenuGroup, { title: "Quality", children: (0, jsx_runtime_1.jsxs)(ui_1.DropdownMenuRadioGroup, { value: quality, onValueChange: setQuality, children: [(0, jsx_runtime_1.jsx)(ui_1.DropdownMenuRadioItem, { value: "source", children: (0, jsx_runtime_1.jsx)(ui_1.Text, { children: mode === "vod" ? "Auto" : "Source" }) }), renditions.map((r) => ((0, jsx_runtime_1.jsx)(ui_1.DropdownMenuRadioItem, { value: r.name, children: (0, jsx_runtime_1.jsx)(ui_1.Text, { children: r.name === "audio" ? "Audio Only" : r.name }) }, r.name)))] }) }) })] }))] }));
}
//# sourceMappingURL=vod-controls.js.map