import { __exports as c } from "../../../../../../../../_virtual/additionalProperties.js";
import { __require as j } from "../code.js";
import { __require as E } from "../../compile/codegen/index.js";
import { __require as O } from "../../compile/names.js";
import { __require as C } from "../../compile/util.js";
var A;
function M() {
  if (A) return c;
  A = 1, Object.defineProperty(c, "__esModule", { value: !0 });
  const l = j(), o = E(), y = O(), d = C(), $ = {
    keyword: "additionalProperties",
    type: ["object"],
    schemaType: ["boolean", "object"],
    allowUndefined: !0,
    trackErrors: !0,
    error: {
      message: "must NOT have additional properties",
      params: ({ params: t }) => (0, o._)`{additionalProperty: ${t.additionalProperty}}`
    },
    code(t) {
      const { gen: i, schema: s, parentSchema: u, data: _, errsCount: h, it: n } = t;
      if (!h)
        throw new Error("ajv implementation error");
      const { allErrors: P, opts: p } = n;
      if (n.props = !0, p.removeAdditional !== "all" && (0, d.alwaysValidSchema)(n, s))
        return;
      const f = (0, l.allSchemaProperties)(u.properties), m = (0, l.allSchemaProperties)(u.patternProperties);
      w(), t.ok((0, o._)`${h} === ${y.default.errors}`);
      function w() {
        i.forIn("key", _, (e) => {
          !f.length && !m.length ? q(e) : i.if(S(e), () => q(e));
        });
      }
      function S(e) {
        let r;
        if (f.length > 8) {
          const a = (0, d.schemaRefOrVal)(n, u.properties, "properties");
          r = (0, l.isOwnProperty)(i, a, e);
        } else f.length ? r = (0, o.or)(...f.map((a) => (0, o._)`${e} === ${a}`)) : r = o.nil;
        return m.length && (r = (0, o.or)(r, ...m.map((a) => (0, o._)`${(0, l.usePattern)(t, a)}.test(${e})`))), (0, o.not)(r);
      }
      function g(e) {
        i.code((0, o._)`delete ${_}[${e}]`);
      }
      function q(e) {
        if (p.removeAdditional === "all" || p.removeAdditional && s === !1) {
          g(e);
          return;
        }
        if (s === !1) {
          t.setParams({ additionalProperty: e }), t.error(), P || i.break();
          return;
        }
        if (typeof s == "object" && !(0, d.alwaysValidSchema)(n, s)) {
          const r = i.name("valid");
          p.removeAdditional === "failing" ? (b(e, r, !1), i.if((0, o.not)(r), () => {
            t.reset(), g(e);
          })) : (b(e, r), P || i.if((0, o.not)(r), () => i.break()));
        }
      }
      function b(e, r, a) {
        const v = {
          keyword: "additionalProperties",
          dataProp: e,
          dataPropType: d.Type.Str
        };
        a === !1 && Object.assign(v, {
          compositeRule: !0,
          createErrors: !1,
          allErrors: !1
        }), t.subschema(v, r);
      }
    }
  };
  return c.default = $, c;
}
export {
  M as __require
};
//# sourceMappingURL=additionalProperties.js.map
