"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generatePattern = void 0;
const generateEndIndices_1 = require("./generateEndIndices");
const generateStartIndices_1 = require("./generateStartIndices");
const generatePattern = ({ board, cells, config, PatternModel, }) => {
    const startIndices = (0, generateStartIndices_1.generateStartIndices)(cells);
    return startIndices.flatMap((startIndex) => {
        const endIndices = (0, generateEndIndices_1.generateEndIndices)(cells, startIndex);
        const patterns = [];
        for (const endIndex of endIndices) {
            const pattern = new PatternModel(board, cells.slice(startIndex, endIndex + 1));
            if (pattern.canBePlaced(config)) {
                patterns.push(pattern);
            }
        }
        return patterns;
    });
};
exports.generatePattern = generatePattern;
