/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import { u as upperFirst_1 } from '../../_chunks/dep-1fe0ad42.mjs';
import { i as isArray_1 } from '../../_chunks/dep-e3b14d70.mjs';
import { getNode } from '../util.mjs';
import '../../_chunks/dep-a0b4a044.mjs';
import '../../_chunks/dep-d54f2690.mjs';
import '../../_chunks/dep-59c8420d.mjs';
import '../../_chunks/dep-37ba476d.mjs';
import '../../_chunks/dep-c959a6fb.mjs';
import '../../_chunks/dep-b4041200.mjs';
import '../../_chunks/dep-66d6733b.mjs';
import '../../_chunks/dep-be27d184.mjs';
import '../../_chunks/dep-c31e1d9e.mjs';
import '../../_chunks/dep-eb20e23f.mjs';
import 'vue';
import '../../_chunks/dep-e9bfe96d.mjs';
import '../../_chunks/dep-7acc11cb.mjs';
import '../../_chunks/dep-0bfbf721.mjs';
import '../../_chunks/dep-39cc276d.mjs';
import '../../_chunks/dep-6b22dd27.mjs';
import '../../_chunks/dep-0f0c89ff.mjs';
import '../../_chunks/dep-8f777748.mjs';
import '../../_chunks/dep-ae357f26.mjs';
import '../../_chunks/dep-ea5448a5.mjs';
import '../../_chunks/dep-352691c2.mjs';
import '../../_chunks/dep-2cfd5b3a.mjs';
import '../../_chunks/dep-c852a61a.mjs';
import '../../_chunks/dep-05fa17c9.mjs';
import '../../_chunks/dep-10085c61.mjs';
import '../../_chunks/dep-774ac2d0.mjs';
import '../../_chunks/dep-23a0f453.mjs';
import '../../_chunks/dep-3afa94cf.mjs';
import '../../_chunks/dep-1cf2b129.mjs';
import '../../_chunks/dep-6eea369f.mjs';

function useExposeFunc(treeStore, expose) {
  var setItem = function setItem(value, options) {
    var node = treeStore.value.getNode(value);
    var spec = options;
    var keys = Object.keys(spec);
    if (node && spec) {
      ["expanded", "actived", "checked"].forEach(function (name) {
        if (keys.includes(name)) node["set".concat(upperFirst_1(name))](spec[name], {
          directly: true
        });
      });
    }
  };
  var getItem = function getItem(value) {
    var node = treeStore.value.getNode(value);
    return node === null || node === void 0 ? void 0 : node.getModel();
  };
  var getItems = function getItems(value) {
    var nodes = treeStore.value.getNodes(value);
    return nodes.map(function (node) {
      return node.getModel();
    });
  };
  var appendTo = function appendTo(para, item) {
    var list = [];
    if (isArray_1(item)) list = item;else list = [item];
    list.forEach(function (item2) {
      var val = (item2 === null || item2 === void 0 ? void 0 : item2.value) || "";
      var node = getNode(treeStore.value, val);
      if (node) treeStore.value.appendNodes(para, node);else treeStore.value.appendNodes(para, item2);
    });
  };
  var insertBefore = function insertBefore(value, item) {
    var val = (item === null || item === void 0 ? void 0 : item.value) || "";
    var node = getNode(treeStore.value, val);
    if (node) {
      treeStore.value.insertBefore(value, node);
    } else {
      treeStore.value.insertBefore(value, item);
    }
  };
  var insertAfter = function insertAfter(value, item) {
    var val = (item === null || item === void 0 ? void 0 : item.value) || "";
    var node = getNode(treeStore.value, val);
    if (node) {
      treeStore.value.insertAfter(value, node);
    } else {
      treeStore.value.insertAfter(value, item);
    }
  };
  var remove = function remove(value) {
    return treeStore.value.remove(value);
  };
  var getIndex = function getIndex(value) {
    return treeStore.value.getNodeIndex(value);
  };
  var getParent = function getParent(value) {
    var node = treeStore.value.getParent(value);
    return node === null || node === void 0 ? void 0 : node.getModel();
  };
  var getParents = function getParents(value) {
    var nodes = treeStore.value.getParents(value);
    return nodes.map(function (node) {
      return node.getModel();
    });
  };
  var getPath = function getPath(value) {
    var node = treeStore.value.getNode(value);
    var pathNodes = [];
    if (node) pathNodes = node.getPath().map(function (node2) {
      return node2.getModel();
    });
    return pathNodes;
  };
  expose({
    setItem: setItem,
    getItem: getItem,
    getItems: getItems,
    appendTo: appendTo,
    insertBefore: insertBefore,
    insertAfter: insertAfter,
    remove: remove,
    getIndex: getIndex,
    getParent: getParent,
    getParents: getParents,
    getPath: getPath
  });
}

export { useExposeFunc as default };
//# sourceMappingURL=useExposeFunc.mjs.map
