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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var lodash = require('lodash');

const getSingleContent = (value, options) => {
  for (const option of options) {
    if (option.value === value) {
      return (option === null || option === void 0 ? void 0 : option.label) || String(option.value);
    }
  }

  return value !== void 0 ? String(value) : void 0;
};
const getMultipleContent = (value, options) => {
  const res = [];

  for (const iterator of value) {
    const resLabel = getSingleContent(iterator, options);

    if (resLabel) {
      res.push(resLabel);
    }
  }

  return res;
};
const getNewMultipleValue = (innerValue, optionValue) => {
  const value = lodash.cloneDeep(innerValue);
  const valueIndex = value.indexOf(optionValue);

  if (valueIndex < 0) {
    value.push(optionValue);
  } else {
    value.splice(valueIndex, 1);
  }

  return {
    value,
    isCheck: valueIndex < 0
  };
};

exports.getMultipleContent = getMultipleContent;
exports.getNewMultipleValue = getNewMultipleValue;
exports.getSingleContent = getSingleContent;
//# sourceMappingURL=utils.js.map
