/*
 * Copyright (C) 2016-2020 Kano Computing Ltd.
 * License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 */
import { StampsField } from '../../blockly/fields/stamps-field.js';
import { _ } from '../../i18n/index.js';
export function random(editor) {
    const stickers = editor.output.resources.get('stickers');
    let stickerEnum = [];
    if (stickers) {
        stickerEnum = stickers.categoryEnum;
    }
    stickerEnum.unshift([_('ALL', 'All'), 'all']);
    return {
        type: 'function',
        name: 'random',
        verbose: _('PART_STICKER_RANDOM_FROM', 'random from'),
        returnType: 'Sticker',
        parameters: [{
                type: 'parameter',
                name: 'set',
                verbose: '',
                returnType: 'Enum',
                enum: stickerEnum,
            }]
    };
}
export function stampChoice(editor) {
    return {
        type: 'function',
        name: 'stampChoice',
        verbose: '',
        returnType: 'Sticker',
        parameters: [{
                type: 'parameter',
                name: 'name',
                verbose: '',
                returnType: 'Sticker',
                blockly: { customField() {
                        const stickers = editor.output.resources.get('stickers');
                        if (!stickers) {
                            throw new Error('Could not create StampsField: stickers resource is not defined');
                        }
                        const defaultSticker = stickers.default ? stickers.default : '';
                        return new StampsField(defaultSticker, stickers.categorisedResource, () => { }, stickers.legacyIdMap);
                    }, }
            }]
    };
}
//# sourceMappingURL=common.js.map