<commit_before>define(
  'ephox.alloy.api.Gui',

  [
    'ephox.alloy.api.GuiEvents',
    'ephox.alloy.api.GuiFactory',
    'ephox.alloy.api.SystemApi',
    'ephox.alloy.api.SystemEvents',
    'ephox.alloy.events.Triggers',
    'ephox.alloy.registry.Registry',
    'ephox.alloy.registry.Tagger',
    'ephox.compass.Arr',
    'ephox.peanut.Fun',
    'ephox.perhaps.Result',
    'ephox.sugar.api.Compare',
    'ephox.sugar.api.Element',
    'ephox.sugar.api.Insert',
    'ephox.sugar.api.Node',
    'ephox.sugar.api.Remove',
    'global!Error'
  ],

  function (GuiEvents, GuiFactory, SystemApi, SystemEvents, Triggers, Registry, Tagger, Arr, Fun, Result, Compare, Element, Insert, Node, Remove, Error) {
    var create = function ( ) {
      var container = Element.fromTag('div');
      return takeover(container);
    };

    var takeover = function (container) {
      var isRoot = Fun.curry(Compare.eq, container);

      var registry = Registry();

      var lookup = function (eventName, target) {
        return registry.find(isRoot, eventName, target);
      };

      var domEvents = GuiEvents.setup(container, {
        triggerEvent: function (eventName, event) {
          return Triggers.triggerUntilStopped(lookup, eventName, event);
        }
      });

      var systemApi = SystemApi({
        // This is a real system
        debugInfo: Fun.constant('real'),
        triggerEvent: function (customType, target, data) {
          // The return value is not used because this is a fake event.
          Triggers.triggerOnUntilStopped(lookup, customType, data, target);
        },
        triggerFocus: function (target, originator) {
          Triggers.triggerHandler(lookup, SystemEvents.focus(), {
            // originator is used by the default events to ensure that focus doesn't
            // get called infinitely
            originator: Fun.constant(originator),
            target: Fun.constant(target)
          }, target);
        },
        getByUid: function (uid) {
          return getByUid(uid);<commit_msg>VAN-44-wheel-hackery: alloy focus to be dispatched outside of an alloy component<commit_after>define(
  'ephox.alloy.api.Gui',

  [
    'ephox.alloy.api.GuiEvents',
    'ephox.alloy.api.GuiFactory',
    'ephox.alloy.api.SystemApi',
    'ephox.alloy.api.SystemEvents',
    'ephox.alloy.events.Triggers',
    'ephox.alloy.registry.Registry',
    'ephox.alloy.registry.Tagger',
    'ephox.compass.Arr',
    'ephox.peanut.Fun',
    'ephox.perhaps.Result',
    'ephox.sugar.api.Compare',
    'ephox.sugar.api.Element',
    'ephox.sugar.api.Focus',
    'ephox.sugar.api.Insert',
    'ephox.sugar.api.Node',
    'ephox.sugar.api.Remove',
    'global!Error'
  ],

  function (GuiEvents, GuiFactory, SystemApi, SystemEvents, Triggers, Registry, Tagger, Arr, Fun, Result, Compare, Element, Focus, Insert, Node, Remove, Error) {
    var create = function ( ) {
      var container = Element.fromTag('div');
      return takeover(container);
    };

    var takeover = function (container) {
      var isRoot = Fun.curry(Compare.eq, container);

      var registry = Registry();

      var lookup = function (eventName, target) {
        return registry.find(isRoot, eventName, target);
      };

      var domEvents = GuiEvents.setup(container, {
        triggerEvent: function (eventName, event) {
          return Triggers.triggerUntilStopped(lookup, eventName, event);
        }
      });

      var systemApi = SystemApi({
        // This is a real system
        debugInfo: Fun.constant('real'),
        triggerEvent: function (customType, target, data) {
          // The return value is not used because this is a fake event.
          Triggers.triggerOnUntilStopped(lookup, customType, data, target);
        },
        triggerFocus: function (target, originator) {
          Tagger.read(target).fold(function () {
            // When the target is not within the alloy system, dispatch a normal focus event.
            Focus.focus(target);
          }, function (_alloyId) {
            Triggers.triggerHandler(lookup, SystemEvents.focus(), {
              // originator is used by the default events to ensure that focus doesn't
              // get called infinitely
              originator: Fun.constant(originator),
              target: Fun.constant(target)
            }, target);
          });
        },
        getByUid: function (uid) {
          return getByUid(uid);
{'fraction_non_alphanumeric': 0.12341485507246377, 'fraction_numerical': 0.0004528985507246377, 'mean_word_length': 2.525139664804469, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7130900', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1348, 'n_words': 301}