var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/PisellTabbar2/utils/index.ts
var utils_exports = {};
__export(utils_exports, {
  addDataSourceItemsByKey: () => addDataSourceItemsByKey,
  getDefaultActiveKey: () => getDefaultActiveKey
});
module.exports = __toCommonJS(utils_exports);
var import_locales = require("../../../locales");
var defaultItems = {
  all: {
    id: 0,
    shop_id: 9,
    parent_id: 0,
    name: "pisell-tabbar-all",
    slug: "All",
    icon: ""
  },
  search: {
    id: -1,
    shop_id: 9,
    parent_id: 0,
    name: "pisell-tabbar-search",
    slug: "Search",
    key: "search",
    icon: "",
    customClick: true
  },
  expand: {
    id: -2,
    shop_id: 9,
    parent_id: 0,
    key: "expand",
    icon: "pisell2-expand-01",
    name: "pisell-tabbar-expand",
    slug: "expand",
    customClick: true
  }
};
var addDataSourceItemsByKey = (dataSource, keys) => {
  return [...keys.map((key) => ({ ...defaultItems[key], name: (0, import_locales.getText)(defaultItems[key].name) })), ...dataSource];
};
var getDefaultActiveKey = (dataSource, rowKey) => {
  var _a, _b;
  const _activeKey = [];
  if (dataSource.length) {
    const level1Item = dataSource[0];
    _activeKey.push(String(level1Item[rowKey]));
    if ((_a = level1Item.children) == null ? void 0 : _a.length) {
      if (level1Item.childrenMaxLevel !== void 0 && level1Item.childrenMaxLevel < 2) {
        _activeKey.push(String(0));
      } else {
        const level2Item = level1Item.children[0];
        _activeKey.push(String(level2Item[rowKey]));
        if ((_b = level2Item.children) == null ? void 0 : _b.length) {
          _activeKey.push(String(0));
        }
      }
    }
  }
  return _activeKey;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  addDataSourceItemsByKey,
  getDefaultActiveKey
});
