System.register(['active-expression', 'src/client/reactive/active-expression-convention/active-expression-ticking.js', 'utils'], function (_export, _context) {
  "use strict";

  var BaseActiveExpression, check, PausableLoop;
  return {
    setters: [function (_activeExpression) {
      BaseActiveExpression = _activeExpression.BaseActiveExpression;
    }, function (_srcClientReactiveActiveExpressionConventionActiveExpressionTickingJs) {
      check = _srcClientReactiveActiveExpressionConventionActiveExpressionTickingJs.check;
    }, function (_utils) {
      PausableLoop = _utils.PausableLoop;
    }],
    execute: function () {
      _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js = _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js || {};
      _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.__unload__ = __unload__;
      _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.aexpr = aexpr;
      _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.BaseActiveExpression = BaseActiveExpression;
      _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.check = check;
      _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.PausableLoop = PausableLoop;
      class FrameBasedActiveExpression extends _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.BaseActiveExpression {
        constructor(func, ...args) {
          super(func, ...args);
          this.meta({ strategy: 'Frame-based' });

          // needed for check function for aexpr-ticking
          this.enabled = true;

          if (new.target === _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.FrameBasedActiveExpression) {
            this.addToRegistry();
          }
        }

        onChange(...args) {
          super.onChange(...args);

          if (!this._isDisposed) {
            _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.FRAME_BASED_AEXPRS.add(this);
            _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.checkLoop.ensureRunning();
          }
        }

        offChange(...args) {
          super.offChange(...args);

          if (!this.hasCallbacks()) {
            this.revoke();
          }
        }

        dispose() {
          super.dispose();
          this.revoke();
        }

        // #TODO: unused!
        revoke() {
          _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.FRAME_BASED_AEXPRS.delete(this);
          if (_recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.FRAME_BASED_AEXPRS.size === 0) {
            _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.checkLoop.pause();
          }
        }
      }

      _export('FrameBasedActiveExpression', FrameBasedActiveExpression);

      _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.FrameBasedActiveExpression = FrameBasedActiveExpression;
      function aexpr(func, ...args) {
        return new _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.FrameBasedActiveExpression(func, ...args);
      }

      _export('aexpr', aexpr);

      const FRAME_BASED_AEXPRS = new Set();

      // update Active Expressions once per frame
      _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.FRAME_BASED_AEXPRS = FRAME_BASED_AEXPRS;
      const checkLoop = new _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.PausableLoop(() => _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.check(_recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.FRAME_BASED_AEXPRS));

      _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.checkLoop = checkLoop;
      function __unload__() {
        _recorder_._src_client_reactive_active_expression_convention_active_expression_frame_based_js.checkLoop.pause();
      }

      _export('__unload__', __unload__);
    }
  };
});