import { AnalyticsQueue } from './analytics-queue';
import { editorAnalyticsChannel } from './editorAnalyticsChannel';
export var fireAnalyticsEvent = function fireAnalyticsEvent(createAnalyticsEvent, options) {
  return function (_ref) {
    var payload = _ref.payload,
      _ref$channel = _ref.channel,
      channel = _ref$channel === void 0 ? editorAnalyticsChannel : _ref$channel;
    if (!createAnalyticsEvent) {
      return;
    }
    if (options !== null && options !== void 0 && options.immediate) {
      var _createAnalyticsEvent;
      (_createAnalyticsEvent = createAnalyticsEvent(payload)) === null || _createAnalyticsEvent === void 0 || _createAnalyticsEvent.fire(channel);
      return;
    }
    var queue = AnalyticsQueue.get();
    queue.schedule(function () {
      var _createAnalyticsEvent2;
      return (_createAnalyticsEvent2 = createAnalyticsEvent(payload)) === null || _createAnalyticsEvent2 === void 0 ? void 0 : _createAnalyticsEvent2.fire(channel);
    });
  };
};
// eslint-disable-next-line @atlaskit/editor/no-re-export
export { editorAnalyticsChannel } from './editorAnalyticsChannel';