import { StampsField } from '../../blockly/fields/stamps-field.js';
import { random, randomFrom } from './common.js';
function getImage(editor) {
    return {
        type: 'function',
        name: 'getImage',
        verbose: '',
        parameters: [{
                type: 'parameter',
                name: 'sticker',
                verbose: '',
                returnType: 'Sticker',
                blockly: {
                    customField() {
                        const stickers = editor.output.resources.get('stickers');
                        if (stickers) {
                            const defaultSticker = stickers.default ? stickers.default : '';
                            return new StampsField(defaultSticker, stickers.categorisedResource);
                        }
                    },
                },
            }],
        returnType: 'Sticker',
        blockly: {
            toolbox: false,
            javascript(Blockly, block) {
                const value = block.getFieldValue('STICKER');
                return [`'${value || ""}'`, Blockly.JavaScript.ORDER_ATOMIC];
            },
        }
    };
}
;
function hideBlock(block) {
    const newBlock = Object.assign({}, block);
    newBlock.blockly = { toolbox: false };
    return newBlock;
}
export function StampAPI(editor) {
    return {
        type: 'module',
        name: 'stamp',
        verbose: 'Stamp',
        color: '#00c7b6',
        symbols: [
            getImage(editor),
            hideBlock(random),
            hideBlock(randomFrom(editor))
        ]
    };
}
export default StampAPI;
//# sourceMappingURL=api.js.map