"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findScope = exports.findChoice = void 0;
const fuzzy_1 = __importDefault(require("fuzzy"));
const choiceToListItem = (choices, choice, _value) => {
    const { description, emoji } = choices[choice];
    const value = choices[choice][_value];
    const prefix = `${emoji}  `;
    return {
        name: prefix + (value + ':').padEnd(18, ' ') + description,
        value,
    };
};
const findChoice = function (substring, choices, value) {
    const keys = Object.keys(choices).map((choice) => choices[choice][value]);
    return Promise.resolve(fuzzy_1.default
        .filter(substring || '', keys)
        .map(({ original: choice }) => choiceToListItem(choices, choice, value)));
};
exports.findChoice = findChoice;
const findScope = function (substring, scopes) {
    return Promise.resolve(fuzzy_1.default.filter(substring || '', scopes).map(({ original: scope }) => scope));
};
exports.findScope = findScope;
//# sourceMappingURL=findSource.js.map