/**
 * ldesign v0.2.2
 * (c) 2022年9月20日 swimly
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, computed } from '@vue/composition-api';
import props from './props.js';
import { usePrefixClass } from '../../hooks/use-config.js';
import '../config-provider/useConfig.js';
import '../config-provider/context.js';
import 'lodash';
import '../../_chunks/dep-a0f2090c.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _Space = defineComponent({
  name: "LSpace",
  props: _objectSpread({}, props),
  setup: function setup(props2, _ref) {
    var slots = _ref.slots;
    var COMPONENT_NAME = usePrefixClass("space");
    var renderStyle = computed(function () {
      var sizeMap = {
        small: "8px",
        medium: "16px",
        large: "24px"
      };
      var renderGap = "";

      if (Array.isArray(props2.size)) {
        renderGap = props2.size.map(function (s) {
          if (typeof s === "number") return "".concat(s, "px");
          if (typeof s === "string") return sizeMap[s] || s;
          return s;
        }).join(" ");
      } else if (typeof props2.size === "string") {
        renderGap = sizeMap[props2.size] || props2.size;
      } else if (typeof props2.size === "number") {
        renderGap = "".concat(props2.size, "px");
      }

      return _objectSpread({
        gap: renderGap
      }, props2.breakLine ? {
        "flex-wrap": "wrap"
      } : {});
    });
    var spaceClassNames = computed(function () {
      var _ref2;

      return ["".concat(COMPONENT_NAME.value), (_ref2 = {}, _defineProperty(_ref2, "".concat(COMPONENT_NAME.value, "-align-").concat(props2.align), props2.align), _defineProperty(_ref2, "".concat(COMPONENT_NAME.value, "-").concat(props2.direction), props2.direction), _ref2)];
    });
    return {
      COMPONENT_NAME: COMPONENT_NAME,
      spaceClassNames: spaceClassNames,
      renderStyle: renderStyle,
      slots: slots
    };
  },
  render: function render(h) {
    var COMPONENT_NAME = this.COMPONENT_NAME,
        spaceClassNames = this.spaceClassNames,
        renderStyle = this.renderStyle,
        slots = this.slots,
        separator = this.separator;
    var children = slots["default"]().filter(function (child) {
      return child.tag !== void 0;
    });
    var childCount = children.length;

    var renderChildren = function renderChildren() {
      return children.map(function (child, index) {
        var renderSeparator = separator;
        if (typeof separator === "function") renderSeparator = separator(h);
        if (slots.separator) renderSeparator = slots.separator();
        var showSeparator = index + 1 !== childCount && renderSeparator;
        return [h("div", {
          "class": "".concat(COMPONENT_NAME, "-item")
        }, [child]), showSeparator ? h("div", {
          "class": "".concat(COMPONENT_NAME, "-item-separator")
        }, [renderSeparator]) : null];
      });
    };

    return h("div", {
      "class": spaceClassNames,
      "style": renderStyle
    }, [renderChildren()]);
  }
});

export { _Space as default };
//# sourceMappingURL=space.js.map
