// src/analyst/types.ts
import { createHash } from "crypto";
function computeFindingId(input) {
  const basis = JSON.stringify({
    a: input.analyst_id,
    r: input.area,
    s: input.subject ?? "",
    c: normalizeClaim(input.id_basis ?? input.claim)
  });
  return `f_${createHash("sha256").update(basis).digest("hex").slice(0, 20)}`;
}
function normalizeClaim(c) {
  return c.toLowerCase().replace(/\s+/g, " ").replace(/[.!?;:,]+$/g, "").trim();
}
function makeFinding(init) {
  const { id_basis, produced_at, ...rest } = init;
  return {
    schema_version: "1.0.0",
    finding_id: computeFindingId({
      analyst_id: rest.analyst_id,
      area: rest.area,
      subject: rest.subject,
      claim: rest.claim,
      id_basis
    }),
    produced_at: produced_at ?? (/* @__PURE__ */ new Date()).toISOString(),
    ...rest
  };
}

export {
  computeFindingId,
  makeFinding
};
//# sourceMappingURL=chunk-45EEMHTC.js.map