import { __exports as d } from "../../../../../../../../_virtual/required.js";
import { __require as $ } from "../code.js";
import { __require as v } from "../../compile/codegen/index.js";
import { __require as b } from "../../compile/util.js";
var q;
function S() {
  if (q) return d;
  q = 1, Object.defineProperty(d, "__esModule", { value: !0 });
  const t = $(), n = v(), h = b(), _ = {
    keyword: "required",
    type: "object",
    schemaType: "array",
    $data: !0,
    error: {
      message: ({ params: { missingProperty: e } }) => (0, n.str)`must have required property '${e}'`,
      params: ({ params: { missingProperty: e } }) => (0, n._)`{missingProperty: ${e}}`
    },
    code(e) {
      const { gen: o, schema: a, schemaCode: f, data: l, $data: u, it: s } = e, { opts: p } = s;
      if (!u && a.length === 0)
        return;
      const m = a.length >= p.loopRequired;
      if (s.allErrors ? g() : P(), p.strictRequired) {
        const r = e.parentSchema.properties, { definedProperties: i } = e.it;
        for (const c of a)
          if (r?.[c] === void 0 && !i.has(c)) {
            const k = s.schemaEnv.baseId + s.errSchemaPath, M = `required property "${c}" is not defined at "${k}" (strictRequired)`;
            (0, h.checkStrictMode)(s, M, s.opts.strictRequired);
          }
      }
      function g() {
        if (m || u)
          e.block$data(n.nil, y);
        else
          for (const r of a)
            (0, t.checkReportMissingProp)(e, r);
      }
      function P() {
        const r = o.let("missing");
        if (m || u) {
          const i = o.let("valid", !0);
          e.block$data(i, () => R(r, i)), e.ok(i);
        } else
          o.if((0, t.checkMissingProp)(e, a, r)), (0, t.reportMissingProp)(e, r), o.else();
      }
      function y() {
        o.forOf("prop", f, (r) => {
          e.setParams({ missingProperty: r }), o.if((0, t.noPropertyInData)(o, l, r, p.ownProperties), () => e.error());
        });
      }
      function R(r, i) {
        e.setParams({ missingProperty: r }), o.forOf(r, f, () => {
          o.assign(i, (0, t.propertyInData)(o, l, r, p.ownProperties)), o.if((0, n.not)(i), () => {
            e.error(), o.break();
          });
        }, n.nil);
      }
    }
  };
  return d.default = _, d;
}
export {
  S as __require
};
//# sourceMappingURL=required.js.map
