var g = Object.defineProperty;
var m = (e, t, c) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writable: !0, value: c }) : e[t] = c;
var i = (e, t, c) => (m(e, typeof t != "symbol" ? t + "" : t, c), c);
import { M as u, fd as V, cO as E, cP as q, aA as f, L as a, gm as h, e5 as C, e2 as X, X as v, w as b, V as w, H as A, v as p } from "./56c67d3b.js";
import "react";
import "react-dom";
const l = (e) => /* @__PURE__ */ A("div", {}), d = function() {
  const e = {
    v1: p("abc")
  };
  return new u(e, (t) => t.v1).setPropertyViewFn(l).build();
}();
function o(e) {
  return JSON.stringify(e.toJsonValue());
}
test("test object create", () => {
  class e {
    constructor() {
      i(this, "a", 1);
      i(this, "b", "abc");
    }
    getValue() {
      return this.a + 10;
    }
  }
  const t = new e();
  expect(t.a).toEqual(1), expect(t.getValue()).toEqual(11);
  const c = Object.create(t);
  c.a = 2, expect(c.a).toEqual(2), expect(c.getValue()).toEqual(12), expect(t.a).toEqual(1), expect(t.getValue()).toEqual(11);
});
test("test action and reduce", () => {
  let e = new d({});
  expect(o(e)).toEqual('{"v1":"abc"}'), e = e.reduce(e.changeChildAction("v1", "changed")), expect(o(e)).toEqual('{"v1":"changed"}'), e = e.reduce(e.changeChildAction("v1", "changedXXXX")), expect(o(e)).toEqual('{"v1":"changedXXXX"}');
});
test("test value constructor", () => {
  let e = new d({
    value: {
      v1: "changed"
    }
  });
  expect(o(e)).toEqual('{"v1":"changed"}');
});
const r = function() {
  const e = {
    v1: p("abc"),
    v2: d
  };
  return new u(e, (t) => t).setPropertyViewFn(l).build();
}();
test("test multi2 toJson", () => {
  let e = new r({});
  const t = JSON.stringify(e.toJsonValue());
  expect(t).toEqual('{"v1":"abc","v2":{"v1":"abc"}}'), e = e.reduce(V("v2", e.children.v2.changeChildAction("v1", "changed"))), expect(o(e)).toEqual('{"v1":"abc","v2":{"v1":"changed"}}');
  let c = new r({
    value: JSON.parse(o(e))
  });
  expect(o(c)).toEqual(o(e));
});
test("test multi change action", () => {
  let e = new r({});
  expect(e.getView().v1).toEqual("abc"), expect(e.getView().v2).toEqual("abc");
  const t = E({
    v1: q("v1_value", !0),
    v2: f("v1", "xxxy", !0)
  });
  e = e.reduce(t), expect(e.getView().v1).toEqual("v1_value"), expect(e.getView().v2).toEqual("xxxy");
});
const x = function() {
  const e = {
    v1: p("abc"),
    v2: r,
    v3: v
  };
  return new u(e, (t) => t.v3).setPropertyViewFn(l).build();
}();
test("test multi toNode", () => {
  const e = new x({}).node().evaluate();
  expect(e.v3.value).toEqual("");
});
test("test comp don't change if no value change", () => {
  let e = new x({});
  expect(a(e)).toBe(e);
});
test("test cache", () => {
  let e = a(new x({}));
  const t = e.children.v1, c = e.children.v2;
  e = e.reduce(e.changeChildAction("v1", "XXX")), expect(e.children.v1.getView()).toEqual("XXX"), expect(e.children.v1).not.toBe(t), expect(e.children.v2).toBe(c), e = a(e), expect(e.node()).toBe(e.node());
  const n = e.node().evaluate();
  e = e.reduce(h(n));
  const s = e.reduce(h(n));
  expect(s).toBe(e), expect(e.node().evaluate()).toBe(e.node().evaluate()), expect(a(e)).toBe(e);
});
test("test code", () => {
  const e = function() {
    const n = {
      v1: b(v, "{{a.b}}")
    };
    return new u(n, (s) => s.v1).setPropertyViewFn(l).build();
  }();
  let t = new e({});
  const c = {
    a: C({
      b: X("abc")
    })
  };
  t = a(t, c), expect(t.getView()).toEqual("abc");
});
test("removeDefault", () => {
  const e = function() {
    const t = {
      v0: v,
      v1: b(v, "{{a.b}}"),
      v2: w,
      v3: w.DEFAULT_TRUE
    };
    return new u(t, (c) => c).setPropertyViewFn(l).build();
  }();
  expect(a(new e({})).toJsonValue()).toEqual({
    v1: "{{a.b}}",
    v3: !0
  }), expect(a(new e({
    value: {
      v0: "",
      v1: "{{a.b}}",
      v2: !1,
      v3: !0
    }
  })).toJsonValue()).toEqual({
    v1: "{{a.b}}",
    v3: !0
  }), expect(a(new e({
    value: {
      v0: "bc",
      v1: "",
      v2: !0,
      v3: !1
    }
  })).toJsonValue()).toEqual({
    v0: "bc",
    v1: "",
    v2: !0,
    v3: !1
  }), expect(a(new e({
    value: {
      v0: "bc",
      v1: "{{a.b}}",
      v2: !0,
      v3: !0
    }
  })).toJsonValue()).toEqual({
    v0: "bc",
    v1: "{{a.b}}",
    v2: !0,
    v3: !0
  });
});
