"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const shared_esmBundler = require("../../../../../@vue/shared/dist/shared.esm-bundler.js");
const token = require("./token.js");
const vue = require("vue");
const isEqual = require("../../../../../lodash-es/isEqual.js");
var options_default = vue.defineComponent({
  name: "ElOptions",
  setup(_, { slots }) {
    const select = vue.inject(token.selectKey);
    let cachedValueList = [];
    return () => {
      var _a, _b;
      const children = (_a = slots.default) == null ? void 0 : _a.call(slots);
      const valueList = [];
      function filterOptions(children2) {
        if (!shared_esmBundler.isArray(children2)) return;
        children2.forEach((item) => {
          var _a2, _b2, _c, _d;
          const name = (_a2 = (item == null ? void 0 : item.type) || {}) == null ? void 0 : _a2.name;
          if (name === "ElOptionGroup") filterOptions(!shared_esmBundler.isString(item.children) && !shared_esmBundler.isArray(item.children) && shared_esmBundler.isFunction((_b2 = item.children) == null ? void 0 : _b2.default) ? (_c = item.children) == null ? void 0 : _c.default() : item.children);
          else if (name === "ElOption") valueList.push((_d = item.props) == null ? void 0 : _d.value);
          else if (shared_esmBundler.isArray(item.children)) filterOptions(item.children);
        });
      }
      if (children.length) filterOptions((_b = children[0]) == null ? void 0 : _b.children);
      if (!isEqual.default(valueList, cachedValueList)) {
        cachedValueList = valueList;
        if (select) select.states.optionValues = valueList;
      }
      return children;
    };
  }
});
exports.default = options_default;
