code: function fitPositionIntoSafeArea(position, layouts) {
      var windowLayout = layouts.windowLayout,
          safeAreaLayout = layouts.safeAreaLayout,
          optionsLayout = layouts.optionsLayout;
  
      if (!safeAreaLayout) {
        return position;
      }
  
      var saX = safeAreaLayout.x,
          saY = safeAreaLayout.y,
          saHeight = safeAreaLayout.height,
          saWidth = safeAreaLayout.width;
      var oHeight = optionsLayout.height,
          oWidth = optionsLayout.width;
      var wWidth = windowLayout.width;
      var top = position.top,
          left = position.left,
          right = position.right;
      top = fit(top, oHeight, saY, saY + saHeight);
      left = fit(left, oWidth, saX, saX + saWidth);
      right = fit(right, oWidth, wWidth - saX - saWidth, saX);
      return {
        top: top,
        left: left,
        right: right
      };
    }
docs: fits options (position) into safeArea