import { jsx as _jsx } from "react/jsx-runtime";
import { FieldAggregateOperation } from '@data-wrangling-components/core';
import { memo, useMemo } from 'react';
import { useSimpleDropdownOptions } from '../hooks/index.js';
import { FormInputType, VerbForm } from '../verbForm/VerbForm.js';
import { enumDropdown } from '../verbForm/VerbFormFactories.js';
/**
 * Just the group/column/op inputs for an aggregation.
 * Input table is expected to be edited elsewhere and configured as the step input.
 */ export const PivotBase = /*#__PURE__*/ memo(function PivotBase({ step , onChange , columns  }) {
    const options = useSimpleDropdownOptions(columns);
    const inputs = useMemo(()=>[
            {
                label: 'Column used as key',
                placeholder: 'Choose column',
                required: true,
                type: FormInputType.SingleChoice,
                current: step.args.key,
                options,
                onChange: (s, val)=>s.args.key = val
            },
            {
                label: 'Column used as value',
                placeholder: 'Choose column',
                required: true,
                type: FormInputType.SingleChoice,
                current: step.args.value,
                options,
                onChange: (s, val)=>s.args.value = val
            },
            enumDropdown('Function', FieldAggregateOperation, step.args.operation, (s, val)=>s.args.operation = val), 
        ], [
        step,
        options
    ]);
    return /*#__PURE__*/ _jsx(VerbForm, {
        inputs: inputs,
        step: step,
        onChange: onChange
    });
});
