System.register(["active-expression"], function (_export, _context) {
  "use strict";

  var BaseActiveExpression, TickingActiveExpression, __SystemJSRewritingHack, TICKING_INSTANCES;
  function setExpressionOptionsForConventionStrategies(func, options = {}, ...rest) {
    return [func, Object.assign({
      checkImmediately: false
    }, options), ...rest];
  }
  function aexpr(func, ...args) {
    return new TickingActiveExpression(func, ...args);
  }

  // TODO: the concrete semantic of enabled and disabled aexprs are not clear yet.
  // Instead, they are related to this concrete implementation.
  // For example, what happens if a disabled aexpr is re-enabled AND the value of the aexpr
  // has already changed? Should the callback be invoked with the new value and the lastValue
  // before the disabling? or with the actual last value? Or should it not be invoked until
  // something changes? If so, what is the last value? Or should aexprs simply not be able to be
  // re-enabled again? Or should they not even be disable-able; then, it would be the duty of
  // the callback/a built-upon concept to implement thiese functionalities appropriately
  function check(iterable = TICKING_INSTANCES) {
    iterable.forEach(aexpr => aexpr.checkAndNotify());
  }

  // Remove all active expressions of this type from the system
  // afterward active expressions are only reachable by providing them explicitly in an iterable to `check`
  // Caution: Do not use this function unless you know what you are doing!
  function clearDefaultActiveExpressions() {
    TICKING_INSTANCES.clear();
  }
  _export({
    setExpressionOptionsForConventionStrategies: setExpressionOptionsForConventionStrategies,
    TickingActiveExpression: void 0,
    aexpr: aexpr,
    check: check,
    clearDefaultActiveExpressions: clearDefaultActiveExpressions
  });
  return {
    setters: [function (_activeExpression) {
      BaseActiveExpression = _activeExpression.BaseActiveExpression;
    }],
    execute: function () {
      __SystemJSRewritingHack = {};
      _recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_client_reactive_active_expression_convention_active_expression_ticking_js = _recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_client_reactive_active_expression_convention_active_expression_ticking_js || {};
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_client_reactive_active_expression_convention_active_expression_ticking_js, "clearDefaultActiveExpressions", {
        get() {
          return clearDefaultActiveExpressions;
        },
        set(thisIsVererySecretVariableName) {
          _export("clearDefaultActiveExpressions", clearDefaultActiveExpressions = thisIsVererySecretVariableName);
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_client_reactive_active_expression_convention_active_expression_ticking_js, "check", {
        get() {
          return check;
        },
        set(thisIsVererySecretVariableName) {
          _export("check", check = thisIsVererySecretVariableName);
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_client_reactive_active_expression_convention_active_expression_ticking_js, "aexpr", {
        get() {
          return aexpr;
        },
        set(thisIsVererySecretVariableName) {
          _export("aexpr", aexpr = thisIsVererySecretVariableName);
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_client_reactive_active_expression_convention_active_expression_ticking_js, "setExpressionOptionsForConventionStrategies", {
        get() {
          return setExpressionOptionsForConventionStrategies;
        },
        set(thisIsVererySecretVariableName) {
          _export("setExpressionOptionsForConventionStrategies", setExpressionOptionsForConventionStrategies = thisIsVererySecretVariableName);
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_client_reactive_active_expression_convention_active_expression_ticking_js, "BaseActiveExpression", {
        get() {
          return BaseActiveExpression;
        },
        set(thisIsVererySecretVariableName) {
          BaseActiveExpression = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      TICKING_INSTANCES = new Set();
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_client_reactive_active_expression_convention_active_expression_ticking_js, "TICKING_INSTANCES", {
        get() {
          return TICKING_INSTANCES;
        },
        set(thisIsVererySecretVariableName) {
          TICKING_INSTANCES = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      _export("TickingActiveExpression", TickingActiveExpression = class TickingActiveExpression extends BaseActiveExpression {
        // each implementation strategy ensures to track changes of the given expression
        // in the case of ticking, we add the aexpr to a collection of tracked aexpr
        // which enables them to recognize changes (here, explicitly through the `check` method)
        constructor(func, ...args) {
          super(func, ...args);
          TICKING_INSTANCES.add(this);
          if (new.target === TickingActiveExpression) {
            this.addToRegistry();
          }
        }

        // TODO: refactor/extractMethod with InterpreterActiveExpression
        revoke() {
          this.removeListeners();
        }
        dispose() {
          TICKING_INSTANCES.delete(this);
          super.dispose();
        }
        disable2(...args) {
          return super.disable(...args);
        }
        enable2(...args) {
          return super.enable(...args);
        }
        disable(...args) {
          super.disable(...args);
          return this;
        }
        enable(...args) {
          super.enable(...args);
          return this;
        }

        /** the parameter `checkImmediately` is by default false for convention strategies */
        setExpression(...params) {
          return super.setExpression(...setExpressionOptionsForConventionStrategies(...params));
        }
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_client_reactive_active_expression_convention_active_expression_ticking_js, "TickingActiveExpression", {
        get() {
          return TickingActiveExpression;
        },
        set(thisIsVererySecretVariableName) {
          _export("TickingActiveExpression", TickingActiveExpression = thisIsVererySecretVariableName);
          return true;
        },
        enumerable: true,
        configurable: true
      });
    }
  };
});