import { GrowthRecipes } from '../recipes/recipes.js';
import { BaseGrowthProcessor, SaplingGrowthProcessor, TwoByTwoSaplingGrowthProcessor } from '../recipes/types/growth.js';
import { sieves as U } from '../ftb_bedrock_bedrock_utils_dist_bedrock_utils.js';

class APIListener {
    constructor(id) {
        this.id = id;
    }
    parseMessage(message) {
        try {
            return JSON.parse(message);
        }
        catch (e) {
            throw e;
        }
    }
}
class BasicGrowthRecipeListener extends APIListener {
    constructor() {
        super(U("recipes/growth/basic"));
    }
    callback(recipe) {
        if (!recipe || !recipe.state || !recipe.maxState) {
            throw "Invalid basic growth recipe: " + JSON.stringify(recipe);
        }
        GrowthRecipes.PROCESSORS.push(new BaseGrowthProcessor(recipe.state, recipe.maxState, recipe.blockIds));
    }
}
class SaplingGrowthRecipeListener extends APIListener {
    constructor() {
        super(U("recipes/growth/sapling"));
    }
    callback(recipe) {
        if (!recipe || !recipe.blockId || !recipe.featureId) {
            throw "Invalid sapling growth recipe: " + JSON.stringify(recipe);
        }
        GrowthRecipes.PROCESSORS.push(new SaplingGrowthProcessor(recipe.blockId, recipe.featureId));
    }
}
class TwoByTwoSaplingGrowthRecipeListener extends APIListener {
    constructor() {
        super(U("recipes/growth/two_by_two_sapling"));
    }
    callback(recipe) {
        if (!recipe || !recipe.blockId || !recipe.featureId) {
            throw "Invalid two by two sapling growth recipe: " + JSON.stringify(recipe);
        }
        GrowthRecipes.PROCESSORS.push(new TwoByTwoSaplingGrowthProcessor(recipe.blockId, recipe.featureId));
    }
}

export { APIListener, BasicGrowthRecipeListener, SaplingGrowthRecipeListener, TwoByTwoSaplingGrowthRecipeListener };
