function $AdfServerEventQueue$$() {
  this.Init()
}
$goog$exportSymbol$$("AdfServerEventQueue", $AdfServerEventQueue$$);
$AdfObject$$.$createSubclass$($AdfServerEventQueue$$);
$AdfServerEventQueue$$.prototype.Init = function $$AdfServerEventQueue$$$$Init$() {
  $AdfServerEventQueue$$.$superclass$.Init.call(this);
  this.$_serverEventQueue$ = []
};
$AdfObject$$.$exportPrototypeSymbol$("AdfServerEventQueue.prototype.Init", {Init:$AdfServerEventQueue$$.prototype.Init});
$AdfServerEventQueue$$.prototype.push = function $$AdfServerEventQueue$$$$push$($event$$270$$) {
  var $timeout$$11$$ = $event$$270$$.$getMaxTimeBeforePropagation$(), $targetTime$$1$$ = 0 > $timeout$$11$$ ? -1 : (new Date).getTime() + $timeout$$11$$;
  0 < $timeout$$11$$ && $AdfPage$$.$PAGE$.$__queueEventTimerIfNeeded$($timeout$$11$$);
  this.$_serverEventQueue$.push({event:$event$$270$$, $targetTime$:$targetTime$$1$$})
};
$AdfObject$$.$exportPrototypeSymbol$("AdfServerEventQueue.prototype.push", {push:$AdfServerEventQueue$$.prototype.push});
$AdfServerEventQueue$$.prototype.$hasEventsToDeliver$ = function $$AdfServerEventQueue$$$$$hasEventsToDeliver$$() {
  return 0 == this.$getWaitingTimeout$()
};
$AdfObject$$.$exportPrototypeSymbol$("AdfServerEventQueue.prototype.hasEventsToDeliver", {$hasEventsToDeliver$:$AdfServerEventQueue$$.prototype.$hasEventsToDeliver$});
$AdfServerEventQueue$$.prototype.$shiftEvents$ = function $$AdfServerEventQueue$$$$$shiftEvents$$($hasNonEventPayload$$1$$, $hasDeltas$$) {
  for(var $events$$7$$ = [];0 < this.$_serverEventQueue$.length;) {
    var $event$$271$$ = this.$_serverEventQueue$[0].event, $noResponse$$ = !$event$$271$$.$isResponseExpected$(), $discrete$$3$$ = $noResponse$$ || $event$$271$$.$isDeliveryDiscrete$();
    if($discrete$$3$$ && (0 < $events$$7$$.length || $hasNonEventPayload$$1$$)) {
      break
    }
    if($noResponse$$ && $hasDeltas$$) {
      break
    }
    this.$_serverEventQueue$.shift();
    $events$$7$$.push($event$$271$$);
    if($discrete$$3$$) {
      break
    }
  }
  return $events$$7$$
};
$AdfObject$$.$exportPrototypeSymbol$("AdfServerEventQueue.prototype.shiftEvents", {$shiftEvents$:$AdfServerEventQueue$$.prototype.$shiftEvents$});
$AdfServerEventQueue$$.prototype.$getWaitingTimeout$ = function $$AdfServerEventQueue$$$$$getWaitingTimeout$$() {
  var $timeout$$12$$ = -1, $len$$13$$ = this.$_serverEventQueue$.length;
  if(0 < $len$$13$$) {
    for(var $currentTime$$3$$ = (new Date).getTime(), $i$$619$$ = 0;$i$$619$$ < $len$$13$$;$i$$619$$++) {
      var $newTimeout_targetTime$$2$$ = this.$_serverEventQueue$[$i$$619$$].$targetTime$;
      0 <= $newTimeout_targetTime$$2$$ && ($newTimeout_targetTime$$2$$ -= $currentTime$$3$$, $timeout$$12$$ = 0 > $timeout$$12$$ ? $newTimeout_targetTime$$2$$ : Math.min($timeout$$12$$, $newTimeout_targetTime$$2$$), $timeout$$12$$ = Math.max(0, $timeout$$12$$))
    }
  }
  return $timeout$$12$$
};
$AdfObject$$.$exportPrototypeSymbol$("AdfServerEventQueue.prototype.getWaitingTimeout", {$getWaitingTimeout$:$AdfServerEventQueue$$.prototype.$getWaitingTimeout$});
$AdfServerEventQueue$$.prototype.$validate$ = function $$AdfServerEventQueue$$$$$validate$$() {
  $AdfServerEventQueue$$.$_scrubEvents$(this.$_serverEventQueue$)
};
$AdfObject$$.$exportPrototypeSymbol$("AdfServerEventQueue.prototype.validate", {$validate$:$AdfServerEventQueue$$.prototype.$validate$});
$AdfServerEventQueue$$.$_scrubEvents$ = function $$AdfServerEventQueue$$$$_scrubEvents$$($eventQueue$$2$$) {
  for(var $page$$218$$ = $AdfPage$$.$PAGE$, $i$$620$$ = 0;$i$$620$$ < $eventQueue$$2$$.length;$i$$620$$++) {
    var $event$$272$$ = $eventQueue$$2$$[$i$$620$$].event, $component$$1777$$ = $event$$272$$.getSource();
    $component$$1777$$.$getPeer$() || (($component$$1777$$ = $page$$218$$.$findComponent$($component$$1777$$.$getClientId$())) ? $event$$272$$.setSource($component$$1777$$) : $eventQueue$$2$$.splice($i$$620$$--, 1))
  }
};
