Replace variables with general arguments with functions of the arguments

Hello, I am manipulating lists of pairs of elements like {x[i][t] y[j][1],y[j][1]y[k][t1]…}. Each element has two indices and I would like to replace each pair by a function as follows:

when there are two x’s: x[i][t] x[j][t1] → A[i,j,t,t1] ;
when there is one x and one: x[i][t] y[j][t1] → B[i,j,t,t1] ;
when there are any 2 y’s: y[j][t1] y[k][t1] → 0.

where A,B are functions of 4 arguments that I have defined elsewhere. I would like to do this without having to give explicit values to the i,j,t,t1 and loop over them. How could this be done?
Thank you in advance and best wishes,

Stefano

You can try with a replacement rule:

repl = {x[i_][t_] x[j_][t1_] :> A[i, j, t, t1],
   x[i_][t_] y[j_][t1_] :> B[i, j, t, t1],
   y[i_][t_] y[j_][t1_] -> 0};
{x[i][t] y[j][1], y[j][1] y[k][t1]} /. repl

This works, thank you!