import { ht as d, R as h, dG as u, bH as y, bI as n, bJ as c, hu as g, hv as x } from "./684d2f28.js";
import { loadComps as v } from "./5109818b.js";
import "react";
import "react-dom";
import "./b48e07b2.js";
import "./926d8ea1.js";
import "./d6402597.js";
import "./a9d5fc48.js";
import "./7d9beead.js";
import "./65bec866.js";
import "./30970d5d.js";
import "./080f0b61.js";
import "./00dac55d.js";
import "./f2000b8a.js";
import "./9a0dfa2c.js";
import "./6aa2c0e1.js";
import "./fe1e08e9.js";
import "./26cf185f.js";
import "./dc198a78.js";
import "./a28c071f.js";
import "./504a2424.js";
import "./5e53cba5.js";
import "./55f8e851.js";
import "./ed41324b.js";
import "./717d41b5.js";
import "./b7901950.js";
import "./72df4a4a.js";
import "./af88f495.js";
import "./d44efa59.js";
import "./9b571cc4.js";
import "./2f0a7648.js";
import "./5dad11bf.js";
import "./7707b653.js";
import "./c39df120.js";
import "./1b2a449a.js";
import "./b9ae9222.js";
import "./ecf3338c.js";
import "./06cb5dd8.js";
import "./2257b685.js";
import "./aa209e91.js";
import "./92218434.js";
import "./75ab4cfb.js";
import "./c36e15a2.js";
import "./b01a259f.js";
import "./cc5e902d.js";
import "./4e46406c.js";
import "./6b3a2a38.js";
import "./ee7974cc.js";
import "./eff05d5b.js";
import "./173af4c3.js";
import "./e99a277f.js";
import "./3adcf8ec.js";
import "./9d82a469.js";
import "./36c51d98.js";
import "./5c01c295.js";
import "./6a1a7a3c.js";
import "./71eb9a50.js";
import "./0c4ef413.js";
import "./bd1e7458.js";
import "./e77bcf96.js";
import "./6cc07769.js";
import "./4eb7c139.js";
import "./8e06f4ed.js";
import "./2e2d54fb.js";
import "./ddb02558.js";
import "./ebfe5919.js";
import "./e242548f.js";
import "./0f3d7a1a.js";
import "./2d5fc5ff.js";
import "./f9c25fbe.js";
import "./1312a48b.js";
import "./6be5dc74.js";
import "./622ce240.js";
import "./d846af82.js";
import "./62f4fb4c.js";
import "./c81b1773.js";
import "./5b108d7e.js";
import "./99633d26.js";
import "./621469b1.js";
import "./9639b54b.js";
import "./bdf03194.js";
import "./0667825e.js";
import "./49a8125c.js";
import "./7281819e.js";
import "./9869e60a.js";
import "./b1144c16.js";
import "./d404aae1.js";
import "./7a630f06.js";
import "./d883a28b.js";
import "./b8f8370b.js";
import "./ca17ca0f.js";
import "./d9d1e856.js";
import "./6538ec2e.js";
import "./226f78bd.js";
import "./a014bc57.js";
import "./6cf5f7c0.js";
import "./7f2964c3.js";
import "./602ac28f.js";
import "./698a4355.js";
import "./cf2c1864.js";
import "./fcd1d96f.js";
import "./6cb1f6af.js";
import "./ff81ee95.js";
import "./6b18b908.js";
import "./36711569.js";
import "./392e04da.js";
import "./619fbfe2.js";
import "./e3ea3031.js";
import "./913682de.js";
import "./777c4344.js";
import "./b2489790.js";
import "./7e941143.js";
import "./27d5e862.js";
import "./bc58e86f.js";
import "./a4fcbc4b.js";
import "./5cbbee2b.js";
import "./fe6a83c2.js";
import "./dd20fe37.js";
import "./0b7a6b02.js";
import "./f52ee168.js";
import "./de2e4e92.js";
import "./bf2ffa97.js";
import "./90e6d3f7.js";
import "./3eacf14a.js";
import "./a353f3e4.js";
import "./a6ed71f1.js";
import "./6fc647e5.js";
import "./931b084f.js";
import "./879337f2.js";
import "./5d871440.js";
import "./8e08bc47.js";
import "./7a0eefbc.js";
import "./b47bf655.js";
import "./b14e1437.js";
import "./a5d4e13b.js";
import "./0fa6c839.js";
import "./0a417d48.js";
import "./b608c1d8.js";
import "./94fb0922.js";
import "./6478e58a.js";
import "./05092d58.js";
import "./639bcad1.js";
import "./7ca8657c.js";
import "./b507875d.js";
import "./48992676.js";
import "./62fcc7e8.js";
import "./7b305a1a.js";
import "./c5fefc78.js";
import "./d42b1918.js";
import "./707ddeb2.js";
import "./1e25eb55.js";
import "./b35600bb.js";
import "./6ef7667f.js";
import "./2722072c.js";
import "./7ec02a7f.js";
import "./946d7135.js";
import "./eaaab0c1.js";
import "./01ef8ab3.js";
import "./e4ccb648.js";
import "./0f54d801.js";
import "./a9a04a18.js";
import "./cf1795b0.js";
import "./cf3dc0fe.js";
import "./9f282d74.js";
import "./79901bb2.js";
import "./c453d6ff.js";
const T = {
  ui: {
    items: {
      "2e2d4bf2": {
        compType: "module",
        comp: {
          appId: "123",
          events: [{
            name: "event1",
            handler: {
              compType: "executeComp",
              comp: {
                name: "outerInput",
                methodName: "setValue",
                params: [{
                  compType: "string",
                  comp: "event1_triggered",
                  name: "value"
                }]
              }
            }
          }]
        },
        name: "module1"
      },
      "2bb084bf": {
        compType: "input",
        comp: {
          value: ""
        },
        name: "outerInput"
      }
    }
  },
  queries: [{
    compType: "js",
    comp: {
      script: "return 3;"
    },
    id: "dievziawwqy72gszoa42i6m8",
    name: "jsQuery3",
    triggerType: "manual"
  }, {
    compType: "js",
    comp: {
      script: "return 3 + a;"
    },
    id: "dievziawwqy72gszoa42i6m9",
    name: "jsQuery4",
    triggerType: "manual"
  }]
}, f = {
  ui: {
    compType: "module",
    comp: {
      methods: [{
        name: "method1",
        action: {
          compType: "executeComp",
          comp: {
            name: "input1",
            methodName: "setValue",
            params: [{
              compType: "string",
              comp: "hello method1",
              name: "value"
            }]
          }
        }
      }, {
        name: "method2",
        params: [{
          name: "param1",
          type: "string"
        }],
        action: {
          compType: "executeComp",
          comp: {
            name: "input1",
            methodName: "setValue",
            params: [{
              compType: "string",
              comp: "hello {{param1}}",
              name: "value"
            }]
          }
        }
      }],
      events: {
        list: [{
          name: "event1",
          description: ""
        }, {
          name: "event2",
          description: ""
        }],
        onEvent: [{
          name: "event1",
          handler: {
            compType: "executeComp",
            comp: {
              name: "input1",
              methodName: "setValue",
              params: [{
                compType: "string",
                comp: "from_event1",
                name: "value"
              }]
            }
          }
        }]
      },
      io: {
        inputs: [{
          name: "inQuery",
          description: "",
          type: "query"
        }, {
          name: "inNum",
          description: "",
          type: "number"
        }, {
          name: "inString",
          description: "",
          type: "string",
          defaultValue: {
            compType: "string",
            comp: "default_value"
          },
          test: {
            compType: "string",
            comp: "test_value"
          }
        }],
        outputs: [{
          description: "",
          value: "{{input1.value}}",
          name: "out"
        }]
      },
      containerSize: {
        height: 20,
        width: 24
      },
      container: {
        items: {
          "2010af2a": {
            compType: "input",
            comp: {
              value: "hello"
            },
            name: "input1"
          },
          e97d3df7: {
            compType: "text",
            comp: {
              text: "inNum:{{inNum.value}}"
            },
            name: "text1"
          },
          e97d3df8: {
            compType: "text",
            comp: {
              text: "inString:{{inString.value}}"
            },
            name: "text2"
          },
          e97d3df9: {
            compType: "text",
            comp: {
              text: "inQueryData:{{inQuery.data}}"
            },
            name: "text3"
          }
        }
      }
    }
  },
  queries: [{
    compType: "js",
    comp: {
      script: "return 1 + 1"
    },
    id: "dievziawwqy72gszoa42i6m7",
    name: "jsQuery",
    triggerType: "manual",
    onEvent: [{
      name: "success",
      handler: {
        compType: "executeComp",
        comp: {
          name: "input1",
          methodName: "setValue",
          params: [{
            compType: "string",
            comp: "hello success",
            name: "value"
          }]
        }
      }
    }]
  }, {
    compType: "js",
    comp: {
      script: `inQuery.run({a: 10}); 
input1.setValue('hello input query'); return 'ok'`
    },
    id: "dievziawwqy72gszoa42i6m8",
    name: "jsQuery2",
    triggerType: "manual"
  }, {
    compType: "js",
    comp: {
      script: "event1.trigger();"
    },
    id: "dievziawwqy72gszoa42i6m9",
    name: "jsQuery3",
    triggerType: "manual"
  }]
};
function r(o) {
  const e = d({
    Comp: h,
    initialValue: T,
    reduceContext: {
      readOnly: !1,
      applicationId: "123",
      moduleDSL: {
        123: f
      },
      parentApplicationPath: []
    }
  });
  if (!e)
    throw new Error();
  const t = (a, s) => a.children.ui.getAllCompItems()[s].children.comp, i = (a) => t(e.comp, a), p = () => i("2e2d4bf2"), m = (a) => {
    const l = p().moduleRootComp;
    return t(l, a);
  };
  e.init().then(() => {
    p().dispatch(u({
      type: "init"
    }, !1)), setTimeout(() => {
      o({
        root: () => e.comp,
        moduleRoot: () => p().moduleRootComp,
        module: p,
        moduleOutputNodes: () => p().getOutputNodes(),
        input: () => m("2010af2a"),
        inputValue: () => m("2010af2a").children.value.getView().value,
        text1: () => m("e97d3df7"),
        text2: () => m("e97d3df8"),
        text3: () => m("e97d3df9"),
        outerInputValue: () => i("2bb084bf").children.value.getView().value
      });
    });
  });
}
beforeAll(async () => {
  await v();
});
describe("module comp", () => {
  test("init module to ready", (o) => {
    r(({
      module: e,
      text1: t,
      text2: i
    }) => {
      expect(Object.keys(e().getOutputNodes())).toStrictEqual(["out"]), expect(e().exposingValues.out).toBe("hello"), expect(Object.keys(e().children.inputs.getInputNodes())).toStrictEqual([]), expect(t().children.text.getView().value).toBe("inNum:"), e().children.inputs.children.inNum.dispatchChangeValueAction(1), expect(t().children.text.getView().value).toBe("inNum:1"), expect(Object.keys(e().children.inputs.getInputNodes())).toStrictEqual(["inNum"]), expect(i().children.text.getView().value).toBe("inString:default_value"), e().children.inputs.children.inString.dispatchChangeValueAction("hello"), expect(i().children.text.getView().value).toBe("inString:hello"), expect(Object.keys(e().children.inputs.getInputNodes())).toStrictEqual(["inNum", "inString"]), o();
    });
  }), test("change value in module", (o) => {
    r(({
      input: e,
      inputValue: t
    }) => {
      expect(t()).toBe("hello"), e().children.value.dispatchChangeValueAction("world"), expect(t()).toBe("world"), y(e().children.value.dispatch, e().children.value.changeValueAction("hello world"), {
        autoHandleAfterReduce: !0
      }).then(() => {
        expect(t()).toBe("hello world"), o();
      });
    });
  }), test("exec query in module", (o) => {
    r(({
      moduleRoot: e,
      module: t,
      inputValue: i
    }) => {
      expect(t().exposingValues.out).toBe("hello"), e().dispatch(n("jsQuery", c({}))), setTimeout(() => {
        expect(i()).toBe("hello success"), expect(t().exposingValues.out).toBe("hello success"), o();
      }, 300);
    });
  }), test("input query data", (o) => {
    r(({
      text3: e,
      module: t,
      root: i,
      inputValue: p
    }) => {
      expect(e().children.text.getView().value).toBe("inQueryData:"), t().children.inputs.children.inQuery.dispatchChangeValueAction({
        value: "jsQuery3"
      }), expect(Object.keys(t().children.inputs.getInputNodes())).toStrictEqual(["inQuery"]), expect(e().children.text.getView().value).toBe("inQueryData:"), i().dispatch(n("jsQuery3", c({}))), setTimeout(() => {
        expect(e().children.text.getView().value).toBe("inQueryData:3"), o();
      }, 1e3);
    });
  }), test("exec input query", (o) => {
    r(({
      text3: e,
      module: t,
      moduleRoot: i,
      inputValue: p
    }) => {
      expect(e().children.text.getView().value).toBe("inQueryData:"), t().children.inputs.children.inQuery.dispatchChangeValueAction({
        value: "jsQuery4"
      }), expect(Object.keys(t().children.inputs.getInputNodes())).toStrictEqual(["inQuery"]), expect(e().children.text.getView().value).toBe("inQueryData:"), i().dispatch(n("jsQuery2", c({}))), setTimeout(() => {
        expect(p()).toBe("hello input query"), expect(e().children.text.getView().value).toBe("inQueryData:13"), o();
      }, 1e3);
    });
  }), test("exec methods", (o) => {
    r(({
      root: e,
      inputValue: t
    }) => {
      const i = e().nameAndExposingInfo();
      expect(Object.keys(i.module1.methods)).toStrictEqual(["method1", "method2"]), e().dispatch(n("module1", u({
        type: "execute",
        methodName: "method1",
        params: []
      }, !1))), setTimeout(() => {
        expect(t()).toBe("hello method1"), o();
      }, 2e3);
    });
  }), test("exec methods with params", (o) => {
    r(({
      root: e,
      inputValue: t
    }) => {
      const i = e().nameAndExposingInfo();
      expect(Object.keys(i.module1.methods)).toStrictEqual(["method1", "method2"]), e().dispatch(n("module1", u({
        type: "execute",
        methodName: "method2",
        params: ["Lucy"]
      }, !1))), setTimeout(() => {
        expect(t()).toBe("hello Lucy"), o();
      }, 2e3);
    });
  }), test("trigger events by event", (o) => {
    r(({
      root: e,
      text3: t,
      module: i,
      moduleRoot: p,
      outerInputValue: m
    }) => {
      expect(m()).toBe(""), p().dispatch(n(x, g("event1"))), setTimeout(() => {
        expect(m()).toBe("event1_triggered"), o();
      });
    });
  }), test("trigger events by js query", (o) => {
    r(({
      root: e,
      text3: t,
      module: i,
      moduleRoot: p,
      outerInputValue: m
    }) => {
      expect(m()).toBe(""), p().dispatch(n("jsQuery3", c({}))), setTimeout(() => {
        expect(m()).toBe("event1_triggered"), o();
      }, 1e3);
    });
  });
});
