import { computed } from 'vue';
import '../../../../theme/index.mjs';
import { defaultConfig } from '../../../../theme/token/internal.mjs';

function useTheme(theme, parentTheme) {
  const themeConfig = computed(() => (theme == null ? void 0 : theme.value) || {});
  const parentThemeConfig = computed(
    () => themeConfig.value.inherit === false || !(parentTheme == null ? void 0 : parentTheme.value) ? defaultConfig : parentTheme.value
  );
  const mergedTheme = 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;
}

export { useTheme as default };
//# sourceMappingURL=useTheme.mjs.map
