/**
 * Vanilla JS global setup — eagerly injects all public API modules into `globalThis`.
 *
 * This file is ONLY loaded by the full browser entry (`vega.esm.js`) for backward
 * compatibility with vanilla JS consumers who access modules via `window.VegaThemeManager`,
 * `window.ValidCreditCardNumberRule`, etc.
 *
 * Framework consumers (React, Angular, Vue) use loaders that do NOT import this file,
 * resulting in a smaller bundle.
 *
 * Vanilla JS consumers who prefer lazy loading can use `vega-lean.esm.js` instead,
 * which does NOT import this file and instead provides `VegaModuleLoader` for
 * on-demand module loading via `await VegaModuleLoader.load('VegaThemeManager')`.
 */
import { VegaLoader } from '../../helpers/loading-indicator/vega-loader-controller';
import { VegaNotify } from '../../helpers/notify/vega-notify-controller';
import { VegaThemeManager } from '../../helpers/theme/theme-manager';
import { setVegaLogLevel } from '../../utils/log';
import { VegaDialog } from '../../helpers/dialog/vega-dialog-controller';
import VegaEventManager from '../../helpers/event-manager/vega-event-manager';
import { VegaIconManager } from '../../helpers/icon/icon-manager';
import { default as VegaTranslationResourceEN } from '../../helpers/translation/locales/en';
import VegaZIndexManager from '../../helpers/zindex/vega-z-index-manager';
import { ValidCreditCardNumberRule } from '../../helpers/validator/rules/valid-credit-card-number-rule';
import { waitForVega } from '../../helpers/common/wait-for-vega-handler';
import { VegaSkeletonLoader } from '../../helpers/skeleton-loader/vega-skeleton-loader-controller';
import { VegaTranslation } from '../../helpers/translation/translation';
import { VegaRTEContent } from '../../components/vega-rich-text-editor/dto/content-state';
import { setVegaNonce } from '../../helpers/csp/vega-nonce-manager';
import { VegaRTETokenExtension } from '../../components/vega-rich-text-editor/extensions/tokens/token-extension';
import { VegaRTELanguageExtension } from '../../components/vega-rich-text-editor/extensions/languages/language-extension';
import { VegaRTEPresetToolbarItems } from '../../components/vega-rich-text-editor/constants/constant';
import { VegaRTEFunctionExtension } from '../../components/vega-rich-text-editor/extensions/functions/function-extension';
import { VegaRTETableExtension } from '../../components/vega-rich-text-editor/extensions/table/table-extension';
/**
 * Eagerly inject all public API modules into globalThis.
 * Called from the browser entry when VegaLazyLoad is not set (default behavior).
 */
export default function vanillaJsGlobalSetup() {
  injectVegaLoaderIntoGlobal();
  injectVegaNotifyIntoGlobal();
  injectVegaThemeManagerIntoGlobal();
  injectVegaLogLevelIntoGlobal();
  injectVegaDialogIntoGlobal();
  injectSetEventSemanticsIntoGlobal();
  injectVegaIconManager();
  injectVegaZIndexManagerIntoGlobal();
  injectValidCreditCardNumberRuleIntoGlobal();
  injectWaitForVegaIntoGlobal();
  injectVegaSkeletonLoaderIntoGlobal();
  injectVegaTranslationIntoGlobal();
  injectVegaRichTextEditorClassIntoGlobal();
  injectVegaPublicValidationRules();
  injectSetNonceIntoGlobal();
}
/**
 * Inject VegaLoader to global as a public api
 */
function injectVegaLoaderIntoGlobal() {
  globalThis['VegaLoader'] = VegaLoader;
}
/**
 * Inject VegaNotify to global as a public api
 */
function injectVegaNotifyIntoGlobal() {
  globalThis.VegaNotify = VegaNotify;
}
/**
 * Inject VegaThemeManager to global as a public api
 */
function injectVegaThemeManagerIntoGlobal() {
  globalThis.VegaThemeManager = VegaThemeManager;
}
/**
 * Inject VegaLogLevel to global as a public api
 */
function injectVegaLogLevelIntoGlobal() {
  globalThis.setVegaLogLevel = setVegaLogLevel;
}
/**
 * Inject VegaDialog to global as a public api
 */
function injectVegaDialogIntoGlobal() {
  globalThis.VegaDialog = VegaDialog;
}
/**
 * Inject setEventSemantics to global as a public api
 */
function injectSetEventSemanticsIntoGlobal() {
  globalThis.VegaEventManager = VegaEventManager;
}
/**
 * Inject VegaIconManager to global as a public api
 */
function injectVegaIconManager() {
  globalThis.VegaIconManager = VegaIconManager;
}
/**
 * Inject VegaZIndexManager to global as a public api
 */
function injectVegaZIndexManagerIntoGlobal() {
  globalThis.VegaZIndexManager = VegaZIndexManager;
}
/**
 * Inject ValidCreditCardNumberRule to global as a public api.
 */
function injectValidCreditCardNumberRuleIntoGlobal() {
  globalThis.ValidCreditCardNumberRule = ValidCreditCardNumberRule;
}
/**
 * Inject waitForVega to global as a public api
 */
function injectWaitForVegaIntoGlobal() {
  globalThis['waitForVega'] = waitForVega;
}
/**
 * Inject VegaSkeletonLoader to global as a public api
 */
function injectVegaSkeletonLoaderIntoGlobal() {
  globalThis.VegaSkeletonLoader = VegaSkeletonLoader;
}
/**
 * Inject VegaTranslation to global as a public api
 */
function injectVegaTranslationIntoGlobal() {
  globalThis.VegaTranslation = VegaTranslation;
  globalThis.VegaTranslationResourceEN = VegaTranslationResourceEN;
}
/**
 * Inject VegaRTEContent to global as a public api
 * Inject VegaRTETokenExtension to global as a public api
 * Inject VegaRTELanguageExtension to global as a public api
 * Inject VegaRTEPresetToolbarItems to global as a variable
 * Inject VegaRTETableExtension to global as a public api
 */
function injectVegaRichTextEditorClassIntoGlobal() {
  globalThis.VegaRTEContent = VegaRTEContent;
  globalThis.VegaRTETokenExtension = VegaRTETokenExtension;
  globalThis.VegaRTELanguageExtension = VegaRTELanguageExtension;
  globalThis.VegaRTEPresetToolbarItems = VegaRTEPresetToolbarItems;
  globalThis.VegaRTEFunctionExtension = VegaRTEFunctionExtension;
  globalThis.VegaRTETableExtension = VegaRTETableExtension;
}
/**
 * Inject VegaPublicValidationRules to global as a public api
 */
function injectVegaPublicValidationRules() {
  void import('../../helpers/validator/public-rules').then((module) => {
    Object.entries(module).forEach(([name, value]) => {
      globalThis[name] = value;
    });
  });
}
/**
 * Injects the `setVegaNonce` function into the global scope as `setVegaNonce`.
 */
function injectSetNonceIntoGlobal() {
  globalThis.setVegaNonce = setVegaNonce;
}
