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