import { getBasename } from "../../util/index.js";
import { BaseContextProvider } from "../index.js";
class OpenFilesContextProvider extends BaseContextProvider {
    static description = {
        title: "open",
        displayTitle: "Open Files",
        description: "Reference the current open files",
        type: "normal",
    };
    async getContextItems(query, extras) {
        const ide = extras.ide;
        const openFiles = this.options?.onlyPinned
            ? await ide.getPinnedFiles()
            : await ide.getOpenFiles();
        return await Promise.all(openFiles.map(async (filepath) => {
            return {
                description: filepath,
                content: `\`\`\`${getBasename(filepath)}\n${await ide.readFile(filepath)}\n\`\`\``,
                name: (filepath.split("/").pop() ?? "").split("\\").pop() ?? "",
            };
        }));
    }
}
export default OpenFilesContextProvider;
