import { useCallback } from 'react';
import useEngineContext from "../../../hooks/useEngineContext";
var useNativeScanner = function useNativeScanner(onChange) {
  var _context$appHelper, _interaction$utils2, _interaction$utils2$i;
  var context = useEngineContext();
  var _ref = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {},
    interaction = _ref.interaction,
    isTerminal = _ref.isTerminal;
  var activeNativeScanner = useCallback(function () {
    var _interaction$utils, _interaction$utils$po;
    interaction === null || interaction === void 0 || (_interaction$utils = interaction.utils) === null || _interaction$utils === void 0 || (_interaction$utils$po = _interaction$utils.postMessageToApp) === null || _interaction$utils$po === void 0 || _interaction$utils$po.call(_interaction$utils, {
      module: 'global',
      key: 'active_native_scanner',
      data: {
        source: 'comprehensiveSearch'
      }
    });
  }, []);
  return {
    activeNativeScanner: activeNativeScanner,
    isTerminal: isTerminal && isTerminal() || (interaction === null || interaction === void 0 || (_interaction$utils2 = interaction.utils) === null || _interaction$utils2 === void 0 || (_interaction$utils2$i = _interaction$utils2.isAppEnv) === null || _interaction$utils2$i === void 0 ? void 0 : _interaction$utils2$i.call(_interaction$utils2))
  };
};
export default useNativeScanner;