import _extends from "@babel/runtime/helpers/extends";
import ButtonMeta from "./button/meta";
import CardMeta from "./card/meta";
import CarouselBoxMeta from "./carousel-box/meta";
import CarouselMeta from "./carousel/meta";
import ChatMeta from "./chat/meta";
import CollapsepaneMeta from "./collapse.pane/meta";
import CollapseMeta from "./collapse/meta";
import ConnectorProMeta from "./connector-pro/meta";
import DrawerMeta from "./drawer/meta";
import EngineRuleProMeta from "./engine-rule-pro/meta";
import EngineRuleUltraMeta from "./engine-rule-ultra/meta";
import FormitemMeta from "./form.item/meta";
import FormlistMeta from "./form.list/meta";
import FromProMeta from "./from-pro/meta";
import GovernanceMeta from "./governance/meta";
import GridcolMeta from "./grid.col/meta";
import GridrowMeta from "./grid.row/meta";
import HiddenBoxMeta from "./hidden-box/meta";
import ImageMeta from "./image/meta";
import InputNumberMeta from "./input-number/meta";
import InputgroupMeta from "./input.group/meta";
import InputpasswordMeta from "./input.password/meta";
import InputsearchMeta from "./input.search/meta";
import InputtextAreaMeta from "./input.text-area/meta";
import InputMeta from "./input/meta";
import LangProMeta from "./lang-pro/meta";
import LangMeta from "./lang/meta";
import LoopBoxMeta from "./loop-box/meta";
import MarketMeta from "./market/meta";
import ModalDefaultMeta from "./modal-default/meta";
import ModalMeta from "./modal/meta";
import NewsMeta from "./news/meta";
import NoticeMeta from "./notice/meta";
import PageProMeta from "./page-pro/meta";
import PaginationMeta from "./pagination/meta";
import PostMeta from "./post/meta";
import ProfileMeta from "./profile/meta";
import ProgressMeta from "./progress/meta";
import RelationTreeMeta from "./relation-tree/meta";
import RemarkMeta from "./remark/meta";
import RoadmapMeta from "./roadmap/meta";
import RotationWheelMeta from "./rotation-wheel/meta";
import SelectMeta from "./select/meta";
import SlotMeta from "./slot/meta";
import SwapMeta from "./swap/meta";
import SwitchMeta from "./switch/meta";
import TokenPoolMeta from "./token-pool/meta";
import TokenStatMeta from "./token-stat/meta";
import ToolIframeMeta from "./tool-iframe/meta";
import ToolVideoMeta from "./tool-video/meta";
import TypographytextMeta from "./typography.text/meta";
import WebRenderderMeta from "./web-renderder/meta";
var componentCategorySort = {};
["基础元素", "布局容器类", "表格类", "表单详情类", "帮助类", "对话框类", "业务类", "通用", "引导", "信息输入", "信息展示", "信息反馈"].reverse().forEach(function (item, index) {
  componentCategorySort[item] = ++index;
});
function generateComponentList(components) {
  var componentList = [{
    title: '常用',
    icon: '',
    children: []
  }, {
    title: '容器',
    icon: '',
    children: []
  }, {
    title: '导航',
    icon: '',
    children: []
  }, {
    title: '内容',
    icon: '',
    children: []
  }, {
    title: 'Feedback 反馈',
    icon: '',
    children: []
  }];
  var groupMap = {
    原子组件: true
  };
  var compGroup = {};
  components.forEach(function (comp) {
    var category = comp.category || '其他';
    if (comp.group && !compGroup[comp.componentName]) {
      compGroup[comp.componentName] = comp.group;
    }
    if (comp.group && !groupMap[comp.group]) {
      groupMap[comp.group] = true;
    }
    var target = componentList.find(function (item) {
      return item.title === category;
    });
    if (!target) {
      target = {
        title: category,
        icon: '',
        children: []
      };
      componentList.push(target);
    }
    if (comp.snippets && comp.snippets.length) {
      target.children.push({
        componentName: comp.componentName,
        title: comp.title || comp.componentName,
        sort: {
          category: target.title,
          group: compGroup[comp.componentName] || '原子组件',
          priority: componentCategorySort[target.title] || 0
        },
        icon: '',
        "package": comp.npm.pkg,
        snippets: comp.snippets || []
      });
    }
  });
  return componentList;
}
function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
  if (packageName === void 0) {
    packageName = '@cverse/core-ide-plugin-pro-beta';
  }
  if (version === void 0) {
    version = '0.0.1';
  }
  if (basicLibraryVersion === void 0) {
    basicLibraryVersion = {
      "@alifd/next": "1.25.23",
      "@alifd/meet": "2.6.3",
      "antd": "4.17.3"
    };
  }
  if (!meta || !version) {
    return meta;
  }
  var npm = meta.npm;
  if (!npm) {
    return meta;
  }
  if (typeof basicLibraryVersion === 'object' && basicLibraryVersion[npm["package"]]) {
    meta.npm = _extends({}, npm, {
      version: basicLibraryVersion[npm["package"]]
    });
  } else if (npm["package"] === packageName) {
    meta.npm = _extends({}, npm, {
      version: version
    });
  }
  return meta;
}
var componentMetas = [ButtonMeta, CardMeta, CarouselBoxMeta, CarouselMeta, ChatMeta, CollapsepaneMeta, CollapseMeta, ConnectorProMeta, DrawerMeta, EngineRuleProMeta, EngineRuleUltraMeta, FormitemMeta, FormlistMeta, FromProMeta, GovernanceMeta, GridcolMeta, GridrowMeta, HiddenBoxMeta, ImageMeta, InputNumberMeta, InputgroupMeta, InputpasswordMeta, InputsearchMeta, InputtextAreaMeta, InputMeta, LangProMeta, LangMeta, LoopBoxMeta, MarketMeta, ModalDefaultMeta, ModalMeta, NewsMeta, NoticeMeta, PageProMeta, PaginationMeta, PostMeta, ProfileMeta, ProgressMeta, RelationTreeMeta, RemarkMeta, RoadmapMeta, RotationWheelMeta, SelectMeta, SlotMeta, SwapMeta, SwitchMeta, TokenPoolMeta, TokenStatMeta, ToolIframeMeta, ToolVideoMeta, TypographytextMeta, WebRenderderMeta];
var components = [];
var npmInfo = {
  "package": "@cverse/core-ide-plugin-pro-beta",
  "version": "0.0.1"
};
componentMetas.forEach(function (meta) {
  if (Array.isArray(meta)) {
    components.push.apply(components, meta.map(function (item) {
      if (!item.npm) {
        var componentName = item.componentName;
        var names = componentName.split('.');
        var exportName = names[0],
          subName = names[1];
        item.npm = {
          exportName: exportName,
          main: '',
          destructuring: true,
          subName: names.length > 1 ? componentName.slice(componentName.indexOf('.') + 1) : subName
        };
      }
      item.npm = _extends({}, npmInfo, item.npm || {});
      return fillRealVersion(item);
    }));
  } else if (meta.components) {
    components.push.apply(components, meta.components.map(function (item) {
      if (!item.npm) {
        var componentName = item.componentName;
        var names = componentName.split('.');
        var exportName = names[0],
          subName = names[1];
        item.npm = {
          exportName: exportName,
          main: '',
          destructuring: true,
          subName: names.length > 1 ? componentName.slice(componentName.indexOf('.') + 1) : subName
        };
      }
      item.npm = _extends({}, npmInfo, item.npm || {});
      return fillRealVersion(item);
    }));
  } else {
    if (!meta.npm) {
      var componentName = meta.componentName;
      var names = componentName.split('.');
      var exportName = names[0],
        subName = names[1];
      meta.npm = {
        exportName: exportName,
        main: '',
        destructuring: true,
        subName: names.length > 1 ? componentName.slice(componentName.indexOf('.') + 1) : subName
      };
    }
    meta.npm = _extends({}, npmInfo, meta.npm || {});
    components.push(fillRealVersion(meta));
  }
});
var componentList = generateComponentList(components);
export { components, componentList };
var execCompile = !!true;
if (!execCompile) {
  window.CverseCoreIdePluginProBetaMeta = {
    components: components,
    componentList: componentList
  };
}