"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const builder_1 = __importDefault(require("../../../utils/builder"));
const lodash_1 = __importDefault(require("lodash"));
exports.default = [
    {
        key: 'multiple',
        ignore: true,
    },
    {
        key: 'dataSrc',
        data: {
            values: [
                { label: 'Values', value: 'values' },
                { label: 'URL', value: 'url' },
            ],
        },
        validate: {
            required: true,
        },
        onChange(context) {
            if (context && context.flags && context.flags && context.flags.modified) {
                context.data.values = [
                    { label: '', value: '' },
                ];
            }
        },
    },
    {
        type: 'datagrid',
        input: true,
        label: 'Values',
        key: 'values',
        tooltip: 'The radio button values that can be picked for this field. Values are text submitted with the form data. Labels are text that appears next to the radio buttons on the form.',
        weight: 10,
        reorder: true,
        defaultValue: [
            { label: '', value: '' },
        ],
        components: [
            {
                label: 'Label',
                key: 'label',
                input: true,
                type: 'textfield',
            },
            {
                label: 'Value',
                key: 'value',
                input: true,
                type: 'textfield',
                allowCalculateOverride: true,
                calculateValue: 'value = _.camelCase(row.label);',
                validate: {
                    required: true,
                },
            },
            {
                type: 'select',
                input: true,
                weight: 180,
                label: 'Shortcut',
                key: 'shortcut',
                tooltip: 'The shortcut key for this option.',
                dataSrc: 'custom',
                valueProperty: 'value',
                customDefaultValue: () => '',
                template: '{{ item.label }}',
                data: {
                    custom(context) {
                        return builder_1.default.getAvailableShortcuts(lodash_1.default.get(context, 'instance.options.editForm', {}), lodash_1.default.get(context, 'instance.options.editComponent', {}));
                    },
                },
            },
        ],
        conditional: {
            json: {
                '===': [
                    { var: 'data.dataSrc' },
                    'values',
                ],
            },
        },
    },
    {
        type: 'select',
        input: true,
        label: 'Storage Type',
        key: 'dataType',
        clearOnHide: true,
        tooltip: 'The type to store the data. If you select something other than autotype, it will force it to that type.',
        weight: 12,
        template: '<span>{{ item.label }}</span>',
        dataSrc: 'values',
        data: {
            values: [
                { label: 'Autotype', value: 'auto' },
                { label: 'String', value: 'string' },
                { label: 'Number', value: 'number' },
                { label: 'Boolean', value: 'boolean' },
                { label: 'Object', value: 'object' },
            ],
        },
    },
    {
        key: 'template',
        conditional: {
            json: {
                '===': [
                    { var: 'data.dataSrc' },
                    'url',
                ],
            },
        },
    },
];
