// src/toolbox/common/types.ts
var identityAdapter = { fromRow: (d) => d };
function nfkc(s) {
  return s.normalize("NFKC");
}
function clamp(n, lo, hi) {
  return Math.max(lo, Math.min(hi, n));
}
function combine(kind, scores, weights) {
  if (typeof kind === "function") return kind(scores, weights);
  const ids = Object.keys(scores);
  if (kind === "product") {
    let p = 1;
    for (const id of ids) {
      const w = weights[id] ?? 1;
      p *= Math.pow(Math.max(0, scores[id] ?? 0), w);
    }
    return p;
  }
  if (kind === "log_sum") {
    let s2 = 0;
    for (const id of ids) {
      const w = weights[id] ?? 1;
      s2 += w * Math.log(Math.max(1e-9, scores[id] ?? 0));
    }
    return Math.exp(s2);
  }
  let s = 0;
  for (const id of ids) {
    const w = weights[id] ?? 1;
    s += w * (scores[id] ?? 0);
  }
  return s;
}
export {
  clamp,
  combine,
  identityAdapter,
  nfkc
};
