function getNg1Hooks(selector, injectorPlease) {
  function tryEl(el) {
    try {
      if (!injectorPlease && angular.getTestability) {
        var $$testability = angular.getTestability(el);
        if ($$testability) {
          return {$$testability: $$testability};
        }
      } else {
        var $injector = angular.element(el).injector();
        if ($injector) {
          return {$injector: $injector};
        }
      }
    } catch(err) {}
  }
  function trySelector(selector) {
    var els = document.querySelectorAll(selector);
    for (var i = 0; i < els.length; i++) {
      var elHooks = tryEl(els[i]);
      if (elHooks) {
        return elHooks;
      }
    }
  }

  if (selector) {
    return trySelector(selector);
  } else if (window.__TESTABILITY__NG1_APP_ROOT_INJECTOR__) {
    var $injector = window.__TESTABILITY__NG1_APP_ROOT_INJECTOR__;
    var $$testability = null;
    try {
      $$testability = $injector.get('$$testability');
    } catch (e) {}
    return {$injector: $injector, $$testability: $$testability};
  } else {
    return tryEl(document.body) ||
        trySelector('[ng-app]') || trySelector('[ng\\:app]') ||
        trySelector('[ng-controller]') || trySelector('[ng\\:controller]');
  }
}
function getNg1Hooks(selector, injectorPlease) {
  function tryEl(el) {
    try {
      if (!injectorPlease && angular.getTestability) {
        var $$testability = angular.getTestability(el);
        if ($$testability) {
          return {$$testability: $$testability};
        }
      } else {
        var $injector = angular.element(el).injector();
        if ($injector) {
          return {$injector: $injector};
        }
      }
    } catch(err) {}
  }
  function trySelector(selector) {
    var els = document.querySelectorAll(selector);
    for (var i = 0; i < els.length; i++) {
      var elHooks = tryEl(els[i]);
      if (elHooks) {
        return elHooks;
      }
    }
  }

  if (selector) {
    return trySelector(selector);
  } else if (window.__TESTABILITY__NG1_APP_ROOT_INJECTOR__) {
    var $injector = window.__TESTABILITY__NG1_APP_ROOT_INJECTOR__;
    var $$testability = null;
    try {
      $$testability = $injector.get('$$testability');
    } catch (e) {}
    return {$injector: $injector, $$testability: $$testability};
  } else {
    return tryEl(document.body) ||
        trySelector('[ng-app]') || trySelector('[ng\\:app]') ||
        trySelector('[ng-controller]') || trySelector('[ng\\:controller]');
  }
}
function getNg1Hooks ( selector , injectorPlease ) { function tryEl ( el ) { try { if ( ! injectorPlease && angular . getTestability ) { var $$testability = angular . getTestability ( el ) ; if ( $$testability ) { return { $$testability : $$testability } ; } } else { var $injector = angular . element ( el ) . injector ( ) ; if ( $injector ) { return { $injector : $injector } ; } } } catch ( err ) { } } function trySelector ( selector ) { var els = document . querySelectorAll ( selector ) ; for ( var i = 0 ; i < els . length ; i ++ ) { var elHooks = tryEl ( els [ i ] ) ; if ( elHooks ) { return elHooks ; } } } if ( selector ) { return trySelector ( selector ) ; } else if ( window . __TESTABILITY__NG1_APP_ROOT_INJECTOR__ ) { var $injector = window . __TESTABILITY__NG1_APP_ROOT_INJECTOR__ ; var $$testability = null ; try { $$testability = $injector . get ( '$$testability' ) ; } catch ( e ) { } return { $injector : $injector , $$testability : $$testability } ; } else { return tryEl ( document . body ) || trySelector ( '[ng-app]' ) || trySelector ( '[ng\\:app]' ) || trySelector ( '[ng-controller]' ) || trySelector ( '[ng\\:controller]' ) ; } }
/* Tries to find $$testability and possibly $injector for an ng1 app

By default, doesn't care about $injector if it finds $$testability.  However,
these priorities can be reversed.

@param {string=} selector The selector for the element with the injector.  If
falsy, tries a variety of methods to find an injector
@param {boolean=} injectorPlease Prioritize finding an injector
@return {$$testability?: Testability, $injector?: Injector} Returns whatever
ng1 app hooks it finds
/ * Tries to find $$testability and possibly $injector for an ng1 app
Returns the first hook element that matches the selector