"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _vue = require("vue");
var _comp = require("../../ui/src/comp");
var _xeUtils = _interopRequireDefault(require("xe-utils"));
var _ui = require("../../ui");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function createReactData() {
  return {};
}
function createInternalData() {
  return {};
}
var _default = exports.default = (0, _comp.defineVxeComponent)({
  name: 'VxeTransfer',
  props: {
    modelValue: Array,
    options: Array,
    size: {
      type: String,
      default: () => (0, _ui.getConfig)().transfer.size || (0, _ui.getConfig)().size
    }
  },
  emits: [],
  setup(props, context) {
    const {
      emit,
      slots
    } = context;
    const xID = _xeUtils.default.uniqueId();
    const refElem = (0, _vue.ref)();
    const reactData = (0, _vue.reactive)(createReactData());
    const internalData = createInternalData();
    const refMaps = {
      refElem
    };
    const computeMaps = {};
    const $xeTransfer = {
      xID,
      props,
      context,
      reactData,
      internalData,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const dispatchEvent = (type, params, evnt) => {
      emit(type, (0, _ui.createEvent)(evnt, {
        $transfer: $xeTransfer
      }, params));
    };
    const transferMethods = {
      dispatchEvent
    };
    const transferPrivateMethods = {};
    Object.assign($xeTransfer, transferMethods, transferPrivateMethods);
    const renderVN = () => {
      const headerSlot = slots.header;
      const footerSlot = slots.footer;
      return (0, _vue.h)('div', {
        ref: refElem,
        class: 'vxe-transfer'
      }, [headerSlot ? (0, _vue.h)('div', {
        class: 'vxe-transfer--header'
      }, headerSlot({
        $transfer: $xeTransfer
      })) : (0, _ui.renderEmptyElement)($xeTransfer), (0, _vue.h)('div', {
        class: 'vxe-transfer--body'
      }, [(0, _vue.h)('div', {
        class: 'vxe-transfer--left-wrapper'
      }), (0, _vue.h)('div', {
        class: 'vxe-transfer--buttons-wrapper'
      }), (0, _vue.h)('div', {
        class: 'vxe-transfer--right-wrapper'
      })]), footerSlot ? (0, _vue.h)('div', {
        class: 'vxe-transfer--footer'
      }, footerSlot({
        $transfer: $xeTransfer
      })) : (0, _ui.renderEmptyElement)($xeTransfer)]);
    };
    (0, _vue.onBeforeUnmount)(() => {
      _xeUtils.default.assign(reactData, createReactData());
      _xeUtils.default.assign(internalData, createInternalData());
    });
    $xeTransfer.renderVN = renderVN;
    return $xeTransfer;
  },
  render() {
    return this.renderVN();
  }
});