"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const BaseCommand_1 = require("../../BaseCommand");
const core_1 = require("@oclif/core");
class CardChecklists extends BaseCommand_1.BaseCommand {
    constructor() {
        super(...arguments);
        this.defaultOutput = "fancy";
    }
    async run() {
        const checklists = await this.client.cards.getCardChecklists({
            id: this.lookups.card,
        });
        this.output(checklists);
    }
    toData(data) {
        return data.map((cl) => ({
            id: cl.id,
            name: cl.name,
            items: cl.checkItems.map((i) => ({
                name: i.name,
                state: i.state,
            })),
        }));
    }
    async format(data) {
        if (data.length === 0) {
            return "No checklists";
        }
        return data
            .map((cl) => {
            const items = cl.items
                .map((i) => `  [${i.state === "complete" ? "x" : " "}] ${i.name}`)
                .join("\n");
            return `${cl.name}\n${items}`;
        })
            .join("\n\n");
    }
}
CardChecklists.description = "List checklists on a card";
CardChecklists.flags = {
    board: core_1.Flags.string({ required: true }),
    list: core_1.Flags.string({ required: true }),
    card: core_1.Flags.string({ required: true }),
};
exports.default = CardChecklists;
