import { ref, h, reactive, onBeforeUnmount } from 'vue';
import { defineVxeComponent } from '../../ui/src/comp';
import XEUtils from 'xe-utils';
import { getConfig, createEvent } from '../../ui';
function createReactData() {
    return {};
}
function createInternalData() {
    return {};
}
export default defineVxeComponent({
    name: 'VxeTableTransfer',
    props: {
        modelValue: Array,
        options: Array,
        size: {
            type: String,
            default: () => getConfig().tableTransfer.size || getConfig().size
        }
    },
    emits: [],
    setup(props, context) {
        const { emit } = context;
        const xID = XEUtils.uniqueId();
        const refElem = ref();
        const reactData = reactive(createReactData());
        const internalData = createInternalData();
        const refMaps = {
            refElem
        };
        const computeMaps = {};
        const $xeTableTransfer = {
            xID,
            props,
            context,
            reactData,
            internalData,
            getRefMaps: () => refMaps,
            getComputeMaps: () => computeMaps
        };
        const dispatchEvent = (type, params, evnt) => {
            emit(type, createEvent(evnt, { $tableTransfer: $xeTableTransfer }, params));
        };
        const tableTransferMethods = {
            dispatchEvent
        };
        const tableTransferPrivateMethods = {};
        Object.assign($xeTableTransfer, tableTransferMethods, tableTransferPrivateMethods);
        const renderVN = () => {
            return h('div', {
                ref: refElem,
                class: 'vxe-table-transfer'
            }, []);
        };
        onBeforeUnmount(() => {
            XEUtils.assign(reactData, createReactData());
            XEUtils.assign(internalData, createInternalData());
        });
        $xeTableTransfer.renderVN = renderVN;
        return $xeTableTransfer;
    },
    render() {
        return this.renderVN();
    }
});
