import { SELECTIONS_VAR } from "../../../utils/cel-context.js";
const SELECTION_REF_RE = new RegExp(
  `(?<![\\w$.])${SELECTIONS_VAR}\\[("(?:[^"\\\\]|\\\\.)*")\\]`,
  "g"
);
export function scanSelectionRefs(text) {
  const out = [];
  SELECTION_REF_RE.lastIndex = 0;
  let match;
  while ((match = SELECTION_REF_RE.exec(text)) !== null) {
    let id;
    try {
      id = JSON.parse(match[1]);
    } catch {
      continue;
    }
    out.push({
      from: match.index,
      to: match.index + match[0].length,
      id
    });
  }
  return out;
}
export function buildSelectionLookup(roster) {
  const lookup = /* @__PURE__ */ new Map();
  for (const field of roster) lookup.set(field.id, field.name);
  return lookup;
}
