import { createVNode as _createVNode } from "vue";
import { arrayType, funcType, isUrl, stringType } from "@antdv/pro-utils";
import { defineComponent } from "vue";
function renderLogo(logo, title) {
  if (logo && typeof logo === "string" && isUrl(logo)) {
    return _createVNode("img", {
      "src": logo,
      "alt": "logo"
    }, null);
  }
  if (typeof logo === "function") {
    return logo();
  }
  if (logo && typeof logo === "string") {
    return _createVNode("div", {
      "id": "avatarLogo"
    }, [logo]);
  }
  if (!logo && title && typeof title === "string") {
    const symbol = title.substring(0, 1);
    return _createVNode("div", {
      "id": "avatarLogo"
    }, [symbol]);
  }
  return logo;
}
const simpleContentProps = {
  appList: arrayType(),
  itemClick: funcType(),
  baseClassName: stringType(),
  hashId: stringType()
};
const SimpleContent = defineComponent({
  name: "SimpleContent",
  inheritAttrs: false,
  props: simpleContentProps,
  setup(props) {
    return () => {
      const {
        appList,
        baseClassName,
        hashId,
        itemClick
      } = props;
      return _createVNode("div", {
        "class": `${baseClassName}-content ${hashId}`.trim()
      }, [_createVNode("ul", {
        "class": `${baseClassName}-content-list ${hashId}`.trim()
      }, [appList == null ? void 0 : appList.map((app, index) => {
        var _a;
        if ((_a = app == null ? void 0 : app.children) == null ? void 0 : _a.length) {
          return _createVNode("div", {
            "key": index,
            "class": `${baseClassName}-content-list-item-group ${hashId}`.trim()
          }, [_createVNode("div", {
            "class": `${baseClassName}-content-list-item-group-title ${hashId}`.trim()
          }, [app.title]), _createVNode(SimpleContent, {
            "hashId": hashId,
            "itemClick": itemClick,
            "appList": app == null ? void 0 : app.children,
            "baseClassName": baseClassName
          }, null)]);
        }
        return _createVNode("li", {
          "key": index,
          "class": `${baseClassName}-content-list-item ${hashId}`.trim(),
          "onClick": (e) => {
            e.stopPropagation();
            itemClick == null ? void 0 : itemClick(app);
          }
        }, [_createVNode("a", {
          "href": itemClick ? "javascript:;" : app.url,
          "target": app.target,
          "rel": "noreferrer"
        }, [renderLogo(app.icon, app.title), _createVNode("div", null, [_createVNode("div", null, [app.title])])])]);
      })])]);
    };
  }
});
export {
  SimpleContent,
  renderLogo
};
