import '@babel/polyfill'
import fireflyTable from './fireflyTable';
import fireflyPagination from './fireflyPagination';
import fireflyDialog from './fireflyDialog';
import fireflyMenu from './fireflyMenu';
import fireflyRow from './fireflyRow';
import fireflyHeaderRight from './fireflyHeaderRight';
import fireflyUserInfo from './fireflyUserInfo';
import fireflyWaterMark from './fireflyWaterMark';
import fireflyLogin from './fireflyLogin';
import fireflyResetPassword from './fireflyResetPassword';
import fireflyEdit from './fireflyEdit';
import fireflySearchBar from './fireflySearchBar';
import fireflyDictionary from './fireflyDictionary';

const components = {
  fireflyPagination,
  fireflyTable,
  fireflyDialog,
  fireflyMenu,
  fireflyRow,
  fireflyHeaderRight,
  fireflyUserInfo,
  fireflyWaterMark,
  fireflyLogin,
  fireflyResetPassword,
  fireflyEdit,
  fireflySearchBar,
  fireflyDictionary
};

const install = function (Vue) {
  if (install.installed) return;
  Object.keys(components).forEach(key => {
    Vue.component(components[key].name, components[key]);
  })
};

if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue);
}

const API = {
  install,
  ...components
};

export default API;