(function (root, factory) {
  const api = factory();
  if (typeof module === 'object' && module.exports) module.exports = api;
  else root.mobileLaunch = api;
})(typeof globalThis !== 'undefined' ? globalThis : this, function () {
  const allowedFilters = new Set([
    'all', 'today', 'attention', 'agenda', 'issue', 'pull', 'review', 'update', 'later', 'draft',
  ]);

  function chooseFilter({ saved, today = 0, attention = 0, agenda = 0 } = {}) {
    if (allowedFilters.has(saved)) return saved;
    if (today > 0) return 'today';
    if (attention > 0) return 'attention';
    if (agenda > 0) return 'agenda';
    return 'all';
  }

  function createDisclosure({ disclosure, launcher }) {
    function onKeydown(event) {
      if (event.key !== 'Escape' || !disclosure.open) return;
      event.preventDefault();
      disclosure.open = false;
      launcher.focus();
    }
    return {
      start() {
        disclosure.addEventListener('keydown', onKeydown);
      },
    };
  }

  return { chooseFilter, createDisclosure };
});
