import { ref } from 'vue';
import themes from './themes.js';
import '../lib/echarts.js';
import * as echarts from 'echarts/core';

var theme = ref('default');
function useEChartsThemes() {
  var registerTheme = function registerTheme(name, themeJSON) {
    if (!name || !themeJSON) return null;
    echarts.registerTheme(name, themeJSON);
  };
  var getAllThemes = function getAllThemes() {
    return Object.keys(themes);
  };
  var setTheme = function setTheme(t) {
    theme.value = t;
  };
  var loadTheme = function loadTheme(ts) {
    ts.forEach(function (t) {
      var _themes$t;
      if (!checkTheme(theme.value)) {
        console.log('没有这个默认主题');
        return;
      }
      themes === null || themes === void 0 || (_themes$t = themes[t]) === null || _themes$t === void 0 || _themes$t.call(themes);
    });
  };
  var checkTheme = function checkTheme(t) {
    return !!getAllThemes().includes(t);
  };
  return {
    theme: theme,
    setTheme: setTheme,
    loadTheme: loadTheme,
    getAllThemes: getAllThemes,
    checkTheme: checkTheme,
    registerTheme: registerTheme
  };
}

export { useEChartsThemes };
