'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../../theme/index.cjs');
var internal = require('../../../../theme/token/internal.cjs');

function useTheme(theme, parentTheme) {
  const themeConfig = vue.computed(() => (theme == null ? void 0 : theme.value) || {});
  const parentThemeConfig = vue.computed(
    () => themeConfig.value.inherit === false || !(parentTheme == null ? void 0 : parentTheme.value) ? internal.defaultConfig : parentTheme.value
  );
  const mergedTheme = vue.computed(() => {
    if (!(theme == null ? void 0 : theme.value))
      return parentTheme == null ? void 0 : parentTheme.value;
    const mergedComponents = {
      ...parentThemeConfig.value.components
    };
    Object.keys(theme.value.components || {}).forEach((componentName) => {
      mergedComponents[componentName] = {
        ...mergedComponents[componentName],
        ...theme.value.components[componentName]
      };
    });
    return {
      ...parentThemeConfig.value,
      ...themeConfig.value,
      token: {
        ...parentThemeConfig.value.token,
        ...themeConfig.value.token
      },
      components: mergedComponents
    };
  });
  return mergedTheme;
}

exports.default = useTheme;
//# sourceMappingURL=useTheme.cjs.map
