import { __exports as l } from "../../../../../../../../_virtual/enum.js";
import { __require as w } from "../../compile/codegen/index.js";
import { __require as E } from "../../compile/util.js";
import { __require as b } from "../../runtime/equal.js";
var f;
function S() {
  if (f) return l;
  f = 1, Object.defineProperty(l, "__esModule", { value: !0 });
  const o = w(), p = E(), q = b(), h = {
    keyword: "enum",
    schemaType: "array",
    $data: !0,
    error: {
      message: "must be equal to one of the allowed values",
      params: ({ schemaCode: t }) => (0, o._)`{allowedValues: ${t}}`
    },
    code(t) {
      const { gen: e, data: i, $data: c, schema: a, schemaCode: _, it: $ } = t;
      if (!c && a.length === 0)
        throw new Error("enum must have non-empty array");
      const v = a.length >= $.opts.loopEnum;
      let s;
      const d = () => s ?? (s = (0, p.useFunc)(e, q.default));
      let r;
      if (v || c)
        r = e.let("valid"), t.block$data(r, g);
      else {
        if (!Array.isArray(a))
          throw new Error("ajv implementation error");
        const n = e.const("vSchema", _);
        r = (0, o.or)(...a.map((m, u) => y(n, u)));
      }
      t.pass(r);
      function g() {
        e.assign(r, !1), e.forOf("v", _, (n) => e.if((0, o._)`${d()}(${i}, ${n})`, () => e.assign(r, !0).break()));
      }
      function y(n, m) {
        const u = a[m];
        return typeof u == "object" && u !== null ? (0, o._)`${d()}(${i}, ${n}[${m}])` : (0, o._)`${i} === ${u}`;
      }
    }
  };
  return l.default = h, l;
}
export {
  S as __require
};
//# sourceMappingURL=enum.js.map
