import { K as y, R as x, L as E, N as I, O as w, P as A, T as C, V as r, W as R, X as L, Y as P, Z as T, _ as g, $ as v } from "./684d2f28.js";
import { useRef as H, useMemo as O, useEffect as u } from "react";
import "react-dom";
const D = y();
function b(p) {
  const {
    dsl: h,
    moduleDsl: m,
    appId: o,
    moduleInputs: n,
    onCompChange: s,
    onModuleEventTriggered: c
  } = p, a = H(c);
  a.current = c;
  const f = O(
    () => ({
      Comp: x,
      initialValue: h,
      reduceContext: {
        readOnly: !0,
        applicationId: o,
        parentApplicationPath: [],
        moduleDSL: m || {}
      },
      initHandler: (t) => t.preload(`app-${o}`),
      actionPreInterceptor: (t) => {
        var i;
        return t.type === E.TRIGGER_MODULE_EVENT ? ((i = a.current) == null || i.call(a, t.name), !1) : !0;
      }
    }),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [o]
  ), [e] = I(f);
  return u(() => {
    s == null || s(e);
  }, [e]), u(() => {
    const t = e == null ? void 0 : e.children.ui.getModuleLayoutComp();
    if (!t || !n)
      return;
    t.children.io.children.inputs.getView().forEach((l) => {
      const {
        name: V
      } = l.getView(), d = n[V];
      d !== void 0 && l.children.defaultValue.children.comp.dispatch(w(l.children.defaultValue.children.comp.changeValueAction(d)));
    });
  }, [n]), /* @__PURE__ */ A(C, {
    children: [/* @__PURE__ */ r(R, {}), /* @__PURE__ */ r(L, {
      store: P,
      children: /* @__PURE__ */ r(T.Provider, {
        value: {
          applicationId: o,
          appType: 1,
          readOnly: !0,
          hideHeader: !0
        },
        children: /* @__PURE__ */ r(g, {
          history: D,
          children: /* @__PURE__ */ r(v, {
            path: "/",
            render: () => e == null ? void 0 : e.getView()
          })
        })
      })
    })]
  });
}
export {
  b as AppView
};
