import { __exports as o } from "../../../../../../../../_virtual/if.js";
import { __require as C } from "../../compile/codegen/index.js";
import { __require as q } from "../../compile/util.js";
var _;
function w() {
  if (_) return o;
  _ = 1, Object.defineProperty(o, "__esModule", { value: !0 });
  const i = C(), c = q(), p = {
    keyword: "if",
    schemaType: ["object", "boolean"],
    trackErrors: !0,
    error: {
      message: ({ params: e }) => (0, i.str)`must match "${e.ifClause}" schema`,
      params: ({ params: e }) => (0, i._)`{failingKeyword: ${e.ifClause}}`
    },
    code(e) {
      const { gen: s, parentSchema: t, it: u } = e;
      t.then === void 0 && t.else === void 0 && (0, c.checkStrictMode)(u, '"if" without "then" and "else" is ignored');
      const l = d(u, "then"), h = d(u, "else");
      if (!l && !h)
        return;
      const f = s.let("valid", !0), a = s.name("_valid");
      if (g(), e.reset(), l && h) {
        const r = s.let("ifClause");
        e.setParams({ ifClause: r }), s.if(a, n("then", r), n("else", r));
      } else l ? s.if(a, n("then")) : s.if((0, i.not)(a), n("else"));
      e.pass(f, () => e.error(!0));
      function g() {
        const r = e.subschema({
          keyword: "if",
          compositeRule: !0,
          createErrors: !1,
          allErrors: !1
        }, a);
        e.mergeEvaluated(r);
      }
      function n(r, m) {
        return () => {
          const v = e.subschema({ keyword: r }, a);
          s.assign(f, a), e.mergeValidEvaluated(v, f), m ? s.assign(m, (0, i._)`${r}`) : e.setParams({ ifClause: r });
        };
      }
    }
  };
  function d(e, s) {
    const t = e.schema[s];
    return t !== void 0 && !(0, c.alwaysValidSchema)(e, t);
  }
  return o.default = p, o;
}
export {
  w as __require
};
//# sourceMappingURL=if.js.map
