// Import Libs and Handlers
import React from 'react';
import { AppRender } from '../handlers/render';
import { ComponentActionHandler, HotAreaActionHandler } from '../handlers/actionHandler';
import { on, emitPage, emitComponent, emitHotArea } from '../handlers/eventListener';
import { emitCustomEvent } from '../handlers/customEventTrigger';
import { injectStyle } from '../handlers/injectStyle';
import { initComponentInstanceIndexMap } from '../handlers/instanceMap';

// Import Components
<%= componentImports %>

// Import Plugins
<%= pluginImports %>

// Import Actions
<%= actionImports %>

// Global Style
injectStyle(`<%= globalStyle %>`, '__impage_injected-global-styles');

// Auto Inject Style
injectStyle(`<%= injectedStyle %>`, '__impage_injected-component-styles');

// Global Data
const meta = <%= meta %>;

const global = <%= global %>;

// Inject JIMU_Vars
Object.defineProperty(window, 'JIMU_VARS', {
  value: <%= jimuVars %>,
  writable: false,
  configurable: false,
});

// Inject Global
Object.defineProperty(window, 'VISION', {
  value: { meta, global },
  writable: false,
  configurable: false,
});

// Actions
const actions = <%= actions %>;

// Components
const components = <%= components %>;

const componentInstances = <%= componentInstances %>;

// Plugin
const plugins = <%= plugins %>;

const pluginInstances = <%= pluginInstances %>;

// Init
initComponentInstanceIndexMap(componentInstances);

export default function App() {
  return (
    <AppRender
      componentInstances={componentInstances}
      pluginInstances={pluginInstances}
      global={global}
      meta={meta}
    />
  );
}
