function seatIsTaken(circuitState, qbit, step) {
  if (Object.prototype.hasOwnProperty.call(circuitState, "steps")) {
    for (let i = 0; i < circuitState.steps.length; i++) {
      if (circuitState.steps[i].index == step) {
        if (Object.prototype.hasOwnProperty.call(circuitState.steps[i], "gates")) {
          let gates = circuitState.steps[i]["gates"];
          for (let j = 0; j < gates.length; j++) {

            let gate = gates[j];
            let targets = [];
            let controls = [];

            if (Object.prototype.hasOwnProperty.call(gate, "targets")) {
              targets = [...gate.targets];
            }
            if (Object.prototype.hasOwnProperty.call(gate, "controls")) {
              for (let i = 0; i < gate["controls"].length; i++) {
                let controlInfo = gate["controls"][i];
                let target = controlInfo["target"];
                controls.push(target);
              }
            }

            // get range of qbits affected when displaying this gate
            let qbits = [...targets, ...controls];

            let qmin = Math.min(...qbits);
            let qmax = Math.max(...qbits);

            if ((qmin <= qbit) && (qbit <= qmax)) {
              return true;
            }
          }
        }
        return false;
      }
    }
  }
  return false;
}
// other control gate or between target qbits for a two qubit gate. 
other control gate or between target qbits for a two qubit gate.
other control gate or between target qbits for a two qubit gate .
function seatIsTaken(circuitState, qbit, step) {
  if (Object.prototype.hasOwnProperty.call(circuitState, "steps")) {
    for (let i = 0; i < circuitState.steps.length; i++) {
      if (circuitState.steps[i].index == step) {
        if (Object.prototype.hasOwnProperty.call(circuitState.steps[i], "gates")) {
          let gates = circuitState.steps[i]["gates"];
          for (let j = 0; j < gates.length; j++) {
            let gate = gates[j];
            let targets = [];
            let controls = [];
            if (Object.prototype.hasOwnProperty.call(gate, "targets")) {
              targets = [...gate.targets];
            }
            if (Object.prototype.hasOwnProperty.call(gate, "controls")) {
              for (let i = 0; i < gate["controls"].length; i++) {
                let controlInfo = gate["controls"][i];
                let target = controlInfo["target"];
                controls.push(target);
              }
            }
            let qbits = [...targets, ...controls];
            let qmin = Math.min(...qbits);
            let qmax = Math.max(...qbits);
            if ((qmin <= qbit) && (qbit <= qmax)) {
              return true;
            }
          }
        }
        return false;
      }
    }
  }
  return false;
}
function seatIsTaken ( circuitState , qbit , step ) { if ( Object . prototype . hasOwnProperty . call ( circuitState , "steps" ) ) { for ( let i = 0 ; i < circuitState . steps . length ; i ++ ) { if ( circuitState . steps [ i ] . index == step ) { if ( Object . prototype . hasOwnProperty . call ( circuitState . steps [ i ] , "gates" ) ) { let gates = circuitState . steps [ i ] [ "gates" ] ; for ( let j = 0 ; j < gates . length ; j ++ ) { let gate = gates [ j ] ; let targets = [ ] ; let controls = [ ] ; if ( Object . prototype . hasOwnProperty . call ( gate , "targets" ) ) { targets = [ ... gate . targets ] ; } if ( Object . prototype . hasOwnProperty . call ( gate , "controls" ) ) { for ( let i = 0 ; i < gate [ "controls" ] . length ; i ++ ) { let controlInfo = gate [ "controls" ] [ i ] ; let target = controlInfo [ "target" ] ; controls . push ( target ) ; } } let qbits = [ ... targets , ... controls ] ; let qmin = Math . min ( ... qbits ) ; let qmax = Math . max ( ... qbits ) ; if ( ( qmin <= qbit ) && ( qbit <= qmax ) ) { return true ; } } } return false ; } } } return false ; }
other control gate or between target qbits for a two qubit gate.
other control gate or between target qbits for a two qubit gate .
// get range of qbits affected when displaying this gate