// src/recall-disclosure-escalation.ts
var DISCLOSURE_ESCALATION_MODES = [
  "manual",
  "auto"
];
function isDisclosureEscalationMode(value) {
  return typeof value === "string" && DISCLOSURE_ESCALATION_MODES.includes(value);
}
var DEFAULT_DISCLOSURE_ESCALATION_THRESHOLD = 0.5;
function decideDisclosureEscalation(input) {
  if (input.mode === "manual") {
    return {
      effective: input.originalDisclosure,
      escalated: false,
      reason: "escalation-mode=manual"
    };
  }
  if (input.callerProvidedDisclosure) {
    return {
      effective: input.originalDisclosure,
      escalated: false,
      reason: "caller-explicit-disclosure"
    };
  }
  if (input.originalDisclosure !== "chunk") {
    return {
      effective: input.originalDisclosure,
      escalated: false,
      reason: `original-disclosure=${input.originalDisclosure}-not-eligible-for-auto`
    };
  }
  if (input.topKConfidence === void 0 || !Number.isFinite(input.topKConfidence)) {
    return {
      effective: input.originalDisclosure,
      escalated: false,
      reason: "no-top-k-confidence"
    };
  }
  const threshold = Number.isFinite(input.threshold) && input.threshold >= 0 && input.threshold <= 1 ? input.threshold : DEFAULT_DISCLOSURE_ESCALATION_THRESHOLD;
  if (input.topKConfidence < threshold) {
    return {
      effective: "section",
      escalated: true,
      reason: `top-k-confidence=${input.topKConfidence.toFixed(3)}<${threshold}`
    };
  }
  return {
    effective: input.originalDisclosure,
    escalated: false,
    reason: `top-k-confidence=${input.topKConfidence.toFixed(3)}>=${threshold}`
  };
}

export {
  DISCLOSURE_ESCALATION_MODES,
  isDisclosureEscalationMode,
  DEFAULT_DISCLOSURE_ESCALATION_THRESHOLD,
  decideDisclosureEscalation
};
//# sourceMappingURL=chunk-H7XKCNR6.js.map