"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getThumbsScreenshoter = void 0;
const content_types_1 = require("@ewizardjs/content-types");
const thumbnails_1 = require("../../Api/thumbnails");
const WizError_1 = require("../../modules/WizError");
function getThumbsScreenshoter(options, contentType) {
    return __awaiter(this, void 0, void 0, function* () {
        const { root, disableLogs } = options;
        const { getThumbScreener } = yield thumbnails_1.getScreenshoter(root);
        const thumbScreener = yield getThumbScreener({
            root,
            disableLogs,
        });
        const contentWalker = yield getContentWalkerByType(contentType, options);
        return contentWalker.walk.bind(contentWalker, [thumbScreener]);
    });
}
exports.getThumbsScreenshoter = getThumbsScreenshoter;
function getContentWalkerByType(contentType, options) {
    return __awaiter(this, void 0, void 0, function* () {
        const { SlidesWalker, PagesWalker } = yield thumbnails_1.getScreenshoter(options.root);
        switch (contentType) {
            case content_types_1.ContentTypes.SITE:
                return new PagesWalker(options);
            case content_types_1.ContentTypes.EDETAILER:
                return new SlidesWalker(options);
            default:
                throw new WizError_1.WizError('THUMBNAILS_CREATION_IMPOSSIBLE', contentType);
        }
    });
}
//# sourceMappingURL=getThumbsScreenshoter.js.map