Skip to content

Automate browser based workflows with AI

630 B
Raw Blame
// Chat items are immutable in position: a repeat of the credential already bound keeps the
// receipt on its original message, while null (no receipt here) is transparent, not a reset.
export function selectAutoBoundReceiptIndexes(
  credentialIds: ReadonlyArray<string | null>,
): ReadonlySet<number> {
  const indexes = new Set<number>();
  let previousCredentialId: string | null = null;

  credentialIds.forEach((credentialId, index) => {
    if (credentialId === null || credentialId === previousCredentialId) {
      return;
    }
    indexes.add(index);
    previousCredentialId = credentialId;
  });

  return indexes;
}