"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.statusCommand = statusCommand;
const picocolors_1 = __importDefault(require("picocolors"));
const client_1 = require("../client");
const auth_1 = require("../auth");
async function statusCommand() {
    const server = (0, auth_1.getServerUrl)();
    console.log(`\n  ${picocolors_1.default.bold('Long Tail')} ${picocolors_1.default.dim(server || 'unknown')}\n`);
    const [settings, escalations, workflows, pipelines] = await Promise.all([
        (0, client_1.apiFetch)('/settings').catch(() => null),
        (0, client_1.apiFetch)('/escalations?status=pending&limit=1').catch(() => null),
        (0, client_1.apiFetch)('/workflows/discovered?include_system=false').catch(() => null),
        (0, client_1.apiFetch)('/yaml-workflows?status=active&limit=1').catch(() => null),
    ]);
    const pending = escalations?.total ?? '?';
    const workerCount = workflows?.workflows?.length ?? '?';
    const pipelineCount = pipelines?.total ?? pipelines?.workflows?.length ?? '?';
    const transport = settings?.events?.transport ?? '?';
    console.log(`  ${picocolors_1.default.yellow('●')} Pending escalations  ${picocolors_1.default.bold(String(pending))}`);
    console.log(`  ${picocolors_1.default.green('●')} Active workers        ${picocolors_1.default.bold(String(workerCount))}`);
    console.log(`  ${picocolors_1.default.cyan('●')} Pipeline tools        ${picocolors_1.default.bold(String(pipelineCount))}`);
    console.log(`  ${picocolors_1.default.dim('●')} Event transport       ${transport}`);
    console.log();
}
