"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = useSelectValues;

var _valueUtil = require("../utils/valueUtil");

var _strategyUtil = require("../utils/strategyUtil");

var _vue = require("vue");

/** Return  */
function useSelectValues(rawValues, _ref) {
  var value = _ref.value,
      getEntityByValue = _ref.getEntityByValue,
      getEntityByKey = _ref.getEntityByKey,
      treeConduction = _ref.treeConduction,
      showCheckedStrategy = _ref.showCheckedStrategy,
      conductKeyEntities = _ref.conductKeyEntities,
      getLabelProp = _ref.getLabelProp;
  var rawValueLabeled = (0, _vue.ref)([]);
  (0, _vue.watchEffect)(function () {
    var mergedRawValues = rawValues.value;

    if (treeConduction.value) {
      var rawKeys = (0, _strategyUtil.formatStrategyKeys)(rawValues.value.map(function (val) {
        var entity = getEntityByValue(val);
        return entity ? entity.key : val;
      }), showCheckedStrategy.value, conductKeyEntities.value);
      mergedRawValues = rawKeys.map(function (key) {
        var entity = getEntityByKey(key);
        return entity ? entity.data.value : key;
      });
    }

    rawValueLabeled.value = (0, _valueUtil.getRawValueLabeled)(mergedRawValues, value.value, getEntityByValue, getLabelProp);
  });
  return rawValueLabeled;
}