import NavHeader from "./components/nav-header/components/NavHeader.vue";
import MyApps from "./components/my-apps/components/MyApps.vue";
import UserInfo from "./components/user-info/components/UserInfo.vue";
import LeftMenu from "./components/left-menu/components/LeftMenu.vue";
import Vue from "vue";
import "core-js/stable/array/includes";
import "whatwg-fetch";
import { authService } from "@dhccmobile/etbc-auth-api";

const components: any = {
  NavHeader: NavHeader,
  MyApps: MyApps,
  UserInfo: UserInfo,
  LeftMenu: LeftMenu
};
const install: any = function(vue: typeof Vue, options: any = {}) {
  if (install.installed) return;
  install.installed = true;
  Object.keys(components).forEach(key => {
    vue.component(key, components[key]);
  });

  vue.prototype.$ec = {
    sysId: options.sysId || "",
    baseApi: options.baseApi || ""
  };
  authService.authConfig = {
    apiBaseUrl: options.authApiBaseUrl || options.baseApi || ""
  };
};

const VueEc: any = {
  version: process.env.VERSION,
  install
};
export default VueEc;
