'use strict';

var react = require('@linaria/react');
var index$1 = require('../Link/index.js');
var components = require('./components.js');
var index = require('../Tag/index.js');
var constants = require('../../utils/constants.js');
var React = require('react');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
  enumerable: true,
  configurable: true,
  writable: true,
  value
}) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
    if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
  }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) {
    if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop];
  }
  return target;
};
const titleAreaStyle = "E_4100_0_7_t1gvlxt5";
const _exp2 = /*#__PURE__*/() => props => props.gap;
const AreaWrapper = /*#__PURE__*/react.styled('div')({
  name: "AreaWrapper",
  class: "E_4100_0_7_a1ji6r68",
  propsAsIs: false,
  vars: {
    "a1ji6r68-0": [_exp2(), "px"]
  }
});
const Area = ({
  items,
  gap = 6,
  split,
  className
}) => {
  const splitNode = typeof split === "string" ? constants.splitMap[split] || split : split;
  return /* @__PURE__ */React__default.default.createElement(AreaWrapper, {
    className,
    gap
  }, items.map((item, idx) => {
    const _a = item,
      {
        type
      } = _a,
      props = __objRest(_a, ["type"]);
    return /* @__PURE__ */React__default.default.createElement(React__default.default.Fragment, {
      key: idx
    }, getComponent(type, props), split && idx < items.length - 1 && splitNode);
  }));
};
const TitleArea = ({
  title,
  tag,
  subtitle
}) => {
  const items = [];
  if (tag) {
    items.push(__spreadValues({
      type: "tag"
    }, tag));
  }
  items.push({
    type: "title",
    children: title
  });
  if (subtitle) {
    items.push({
      type: "description",
      children: subtitle
    });
  }
  return /* @__PURE__ */React__default.default.createElement(Area, {
    gap: 6,
    className: titleAreaStyle,
    items
  });
};
function getComponent(type, props) {
  switch (type) {
    case "description":
    case "title":
      return /* @__PURE__ */React__default.default.createElement(components.Info, __spreadProps(__spreadValues({}, props), {
        type
      }));
    case "iconField":
      return /* @__PURE__ */React__default.default.createElement(components.IconField, __spreadValues({}, props));
    case "link":
      const _a = props,
        {
          linkType
        } = _a,
        restLinkProps = __objRest(_a, ["linkType"]);
      const defaultLinkType = restLinkProps.prefixIcon ? "secondary" : "default";
      return /* @__PURE__ */React__default.default.createElement(index$1, __spreadProps(__spreadValues({}, restLinkProps), {
        type: linkType || defaultLinkType
      }));
    case "tag":
      const _b = props,
        {
          color
        } = _b,
        restTagProps = __objRest(_b, ["color"]);
      return /* @__PURE__ */React__default.default.createElement(index.default, __spreadProps(__spreadValues({}, restTagProps), {
        color: color || "blue"
      }));
    default:
      return /* @__PURE__ */React__default.default.createElement(React__default.default.Fragment, null);
  }
}

exports.Area = Area;
exports.TitleArea = TitleArea;
