import { ConfigType } from '../config.js';
import GridData from '../grid.js';
import { State } from '../primitives.js';
import Rule from './rule.js';
class CustomRule extends Rule {
    /**
     * A custom rule with a description and thumbnail grid.
     *
     * This rule validates answers based on the provided solution.
     *
     * @param description - The description of the rule.
     * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
     */
    constructor(description, grid) {
        super();
        Object.defineProperty(this, "description", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: description
        });
        Object.defineProperty(this, "grid", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: grid
        });
        this.description = description;
        this.grid = grid;
    }
    get id() {
        return `custom`;
    }
    get explanation() {
        return this.description;
    }
    get configs() {
        return CustomRule.configs;
    }
    createExampleGrid() {
        return this.grid;
    }
    get searchVariants() {
        return CustomRule.SEARCH_VARIANTS;
    }
    validateGrid(_grid) {
        return { state: State.Incomplete };
    }
    copyWith({ description, grid, }) {
        return new CustomRule(description ?? this.description, grid ?? this.grid);
    }
    get validateWithSolution() {
        return true;
    }
}
Object.defineProperty(CustomRule, "EXAMPLE_GRID", {
    enumerable: true,
    configurable: true,
    writable: true,
    value: Object.freeze(new GridData(5, 4))
});
Object.defineProperty(CustomRule, "configs", {
    enumerable: true,
    configurable: true,
    writable: true,
    value: Object.freeze([
        {
            type: ConfigType.String,
            default: 'A *custom* rule',
            field: 'description',
            description: 'Description',
            configurable: true,
        },
        {
            type: ConfigType.Grid,
            default: CustomRule.EXAMPLE_GRID,
            field: 'grid',
            description: 'Thumbnail Grid',
            configurable: true,
        },
    ])
});
Object.defineProperty(CustomRule, "SEARCH_VARIANTS", {
    enumerable: true,
    configurable: true,
    writable: true,
    value: [
        new CustomRule('A *custom* rule', CustomRule.EXAMPLE_GRID).searchVariant(),
    ]
});
export default CustomRule;
export const instance = new CustomRule('', GridData.create([]));
