processQueryResults_(entries) {
    const eventQueue = [];

    if (entries.length == 0) {
      return eventQueue;
    }

    this.lastSync = entries[entries.length - 1].serverId;

    // No local changes.
    if (this.notSent.length == 0 && this.inProgress.length == 0) {
      entries.forEach((entry) => {
        eventQueue.push.apply(
          eventQueue,
          this.createWorkspaceActions_(entry.events, true),
        );
      });
      return eventQueue;
    }

    // Common root, remove common events from server events.
    if (
      this.inProgress.length > 0 &&
      entries[0].workspaceId == this.workspaceId &&
      entries[0].entryNumber == this.inProgress[0].entryNumber
    ) {
      entries.shift();
      this.inProgress = [];
    }

    if (entries.length > 0) {
      // Undo local events.
      eventQueue.push.apply(
        eventQueue,
        this.createWorkspaceActions_(this.notSent.slice().reverse(), false),
      );
      if (this.inProgress.length > 0) {
        this.inProgress
          .slice()
          .reverse()
          .forEach((entry) => {
            eventQueue.push.apply(
              eventQueue,
              this.createWorkspaceActions_(
                entry.events.slice().reverse(),
                false,
              ),
            );
          });
      }
      // Apply server events.
      entries.forEach((entry) => {
        if (
          this.inProgress.length > 0 &&
          entry.workspaceId == this.inProgress[0].workspaceId &&
          entry.entryNumber == this.inProgress[0].entryNumber
        ) {
          eventQueue.push.apply(
            eventQueue,
            this.createWorkspaceActions_(this.inProgress[0].events, true),
          );
          this.inProgress.shift();
        } else {
          eventQueue.push.apply(
            eventQueue,
            this.createWorkspaceActions_(entry.events, true),
          );
        }
      });
      // Reapply remaining local changes.
      if (this.inProgress.length > 0) {
        eventQueue.push.apply(
          eventQueue,
          this.createWorkspaceActions_(this.inProgress[0].events, true),
        );
      }
      eventQueue.push.apply(
        eventQueue,
        this.createWorkspaceActions_(this.notSent, true),
      );
    }
    return eventQueue;
  }
Compare the order of events in the entries retrieved from the database to
the stacks of local-only changes and provide a series of steps that
will allow the server and local workspace to converge.
@param {<!Array.<!Entry>>} entries Entries retrieved from the database.
@returns {!Array.<!WorkspaceAction>>} eventQueue An array of events and the
direction they should be run.
@private