{"version":3,"file":"notifications-v2-5d23a751104dc877.js","sources":["app/assets/modules/github/notifications/v2/update-notification-states.ts","app/assets/modules/github/notifications/v2/bulk-action-dropdowns.ts","app/assets/modules/github/notifications/v2/notification-list-focus.ts","app/assets/modules/github/notifications/v2/update-notifications.ts","app/assets/modules/github/notifications-v2.ts","app/assets/modules/github/notifications/preheat-issues.ts","app/assets/modules/github/notifications/v2/search-input-providers.ts","packages/fetch-utils/fetch-utils.ts","packages/html-safe-nonce/html-safe-nonce.ts"],"sourcesContent":["/*\n * Applies state updates from a form (e.g. Mark as read/archive/unsubscribe/star) to the element\n * that represents the notification (e.g. The notification item in the list view, or the\n * notification shelf on an Issue page).\n */\nexport function updateNotificationStates(element: HTMLElement, form: HTMLFormElement) {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const notification = element.closest<HTMLElement>('[data-notification-id]')!\n\n  // Toggles read/unread/archive status\n  if (form.hasAttribute('data-status')) {\n    /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n    toggleNotificationStatus(notification, form.getAttribute('data-status')!)\n  }\n\n  // Toggles subscribed/unsubscribed status\n  if (form.hasAttribute('data-subscription-status')) {\n    /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n    toggleNotificationSubscriptionStatus(notification, form.getAttribute('data-subscription-status')!)\n  }\n\n  // Toggles starred/unstarred status\n  if (form.hasAttribute('data-starred-status')) {\n    /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n    toggleNotificationStarredStatus(notification, form.getAttribute('data-starred-status')!)\n  }\n}\n\nfunction toggleNotificationStatus(notification: HTMLElement, status: string) {\n  notification.classList.toggle('notification-archived', status === 'archived')\n  notification.classList.toggle('notification-unread', status === 'unread')\n  notification.classList.toggle('notification-read', status === 'read')\n}\n\nfunction toggleNotificationSubscriptionStatus(notification: HTMLElement, status: string) {\n  notification.classList.toggle('notification-unsubscribed', status === 'unsubscribed')\n}\n\nfunction toggleNotificationStarredStatus(notification: HTMLElement, status: string) {\n  notification.classList.toggle('notification-starred', status === 'starred')\n}\n","// Show/hide an action dropdown, and disable all buttons in it to avoid hotkey submission.\nfunction toggleBulkActionMenu(menu: HTMLElement | null, enabled: boolean) {\n  if (!menu) return\n  menu.hidden = !enabled\n\n  for (const button of menu.querySelectorAll<HTMLButtonElement>('button')) {\n    button.disabled = !enabled\n  }\n}\n\n// Toggle which `mark as...` dropdown is visible based on the current mode.\nexport function toggleBulkActionMenus({markSelected, markAll}: Options) {\n  toggleSelectAll({markSelected, markAll})\n\n  toggleBulkActionMenu(document.querySelector('.js-notifications-mark-selected-actions'), markSelected)\n  toggleBulkActionMenu(document.querySelector('.js-notifications-mark-all-actions'), markAll)\n}\n\n// Toggle which \"select ...\" text is visible based on the current mode.\nfunction toggleSelectAll({markSelected, markAll}: Options) {\n  const selectedText = document.querySelector<HTMLElement>('.js-select-all-text')\n  // Blank slate without toolbar.\n  if (!selectedText) return\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const selectedTextWithCount = document.querySelector<HTMLElement>('.js-count-selected-text')!\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const selectedTextWithAllCount = document.querySelector<HTMLElement>('.js-all-count-selected-text')!\n\n  selectedText.hidden = markSelected || markAll\n  selectedTextWithCount.hidden = !markSelected\n  selectedTextWithAllCount.hidden = !markAll\n}\n\ntype Options = {markSelected: boolean; markAll: boolean}\n\n// Add a hidden input to form element and return the input.\nfunction addHiddenInputToForm(form: HTMLFormElement, name: string, value: string): HTMLInputElement {\n  const input = document.createElement('input')\n  input.setAttribute('type', 'hidden')\n  input.setAttribute('name', name)\n  input.setAttribute('value', value)\n  return form.appendChild(input)\n}\n\nexport function updateSelectedNotificationsInBulkActionForms() {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const container = document.querySelector<HTMLElement>('.js-notifications-container .js-check-all-container')!\n\n  // Add selected notifications to bulk action forms as hidden inputs\n  for (const form of container.querySelectorAll<HTMLFormElement>(\n    '.js-notifications-mark-selected-actions .js-notification-bulk-action form',\n  )) {\n    addCheckedNotificationsToForm(form)\n  }\n\n  // Show/hide the bulk action menu depending on whether there is 1+ selected\n  if (getCheckedElements().length === 0) {\n    toggleBulkActionMenus({markSelected: false, markAll: false})\n  } else {\n    toggleBulkActionMenus({markSelected: true, markAll: false})\n  }\n}\n\n// Add the checked notification items to the bulk action form.\nfunction addCheckedNotificationsToForm(form: HTMLFormElement) {\n  // Remove any previous notification id input elements from the form\n  for (const input of form.querySelectorAll('[data-bulk-notification]')) {\n    input.remove()\n  }\n\n  // Add all checked notification ids as input elements to the form\n  for (const checked of getCheckedElements()) {\n    const input = addHiddenInputToForm(form, checked.name, checked.value)\n    input.setAttribute('data-bulk-notification', '')\n  }\n}\n\nexport function getCheckedElements() {\n  return document.querySelectorAll<HTMLInputElement>(\n    '.js-notifications-container .js-check-all-container [data-check-all-item]:checked',\n  )\n}\n","import {focus as navigationFocus} from '@github-ui/input-navigation-behavior'\nimport visible from '@github-ui/visible'\n\ninterface FocusPosition {\n  id?: string | null\n  position?: number\n}\n\n/*\n * Returns the currently focussed notification id, and it's position in the\n * notification list This should be saved before the list is modified, and then\n * the result can be passed to restoreFocus() to restore the notification list\n * focus to (roughly) the same place.\n *\n * By default it works with the container and selector used on\n * `/notifications`, but they can be overridden by the `notificationsList` and\n * `keyboardFocusedSelector` optional parameters.\n */\nexport function getCurrentFocus(notificationsList?: HTMLElement, keyboardFocusedSelector?: string): FocusPosition {\n  const container = notificationsList || getNotificationsList()\n  if (!container) return {}\n\n  const keyboardFocused = container.querySelector(\n    keyboardFocusedSelector || '.js-notifications-list-item.navigation-focus',\n  )\n  if (!(keyboardFocused instanceof HTMLElement)) return {}\n\n  return {\n    id: keyboardFocused.getAttribute('data-notification-id'),\n    position: getItems(container).indexOf(keyboardFocused),\n  }\n}\n\n/*\n * Restores the focussed notification list focus, based on the previously\n * focused id/position If `id` is not null, and the notification with that id\n * is still in the notification list, that element will be focussed.\n * Otherwise, the element at the matching position (or the last one if the\n * position exceeds the new list length) will be focussed.\n *\n * Be aware that when notifications are loaded from the server, a notification\n * can jump from anywhere in the list to the top if they are updated with a new\n * notification. So if restoring focus after loading new data from the server,\n * restoring by id may be confusing to users.\n *\n * By default it works with the container on `/notifications` but it can be\n * overridden by the `notificationsList` optional parameter.\n */\nexport function restoreFocus({id, position}: FocusPosition, notificationsList?: HTMLElement) {\n  const container = notificationsList || getNotificationsList()\n  if (!(container instanceof HTMLElement)) return\n\n  const items = getItems(container)\n  let target\n\n  // Try to find target by id if it was passed\n  if (id) {\n    target = items.find(el => el.getAttribute('data-notification-id') === id)\n  }\n\n  // If we didn't find target, and position is passed, find by position\n  // falls back to last item if position > length\n  if (!target && position != null) {\n    target = items[Math.min(position, items.length - 1)]\n  }\n\n  if (target instanceof HTMLElement) {\n    navigationFocus(container, target)\n  }\n}\n\nexport function restoreFocusAfterCheckboxClick(checkbox: HTMLInputElement, clickCount: number) {\n  if (clickCount === 0) return\n\n  const item = checkbox.closest<HTMLElement>('.js-notifications-list-item')\n  const container = item?.closest<HTMLElement>('.js-navigation-container')\n  if (!item || !container) return\n\n  navigationFocus(container, item)\n  // Pointer activation intentionally returns focus to the document so list shortcuts remain active.\n  // Keyboard activation keeps focus on the checkbox and returns before this point.\n  // eslint-disable-next-line github/no-blur\n  checkbox.blur()\n}\n\nfunction getNotificationsList() {\n  return document.querySelector('.js-notifications-list .js-navigation-container')\n}\n\n// Returns the visible, navigatable items in the notifications list.\nfunction getItems(container: Element): Element[] {\n  return Array.from(container.querySelectorAll<HTMLElement>('.js-navigation-item')).filter(visible)\n}\n","import {getCurrentFocus, restoreFocus} from './notification-list-focus'\nimport {fetchSafeDocumentFragment} from '@github-ui/fetch-utils'\nimport {hasInteractions} from '@github-ui/has-interactions'\nimport {updateSelectedNotificationsInBulkActionForms} from './bulk-action-dropdowns'\n\nconst DEBOUNCE_DELAY = 500\nlet currentUpdateId = 1\n\n// Creates and returns a unique update id\nexport function getUpdateId(): number {\n  currentUpdateId = (currentUpdateId + 1) % 10000\n  return currentUpdateId\n}\n\nfunction isValidUpdateId(updateId: number): boolean {\n  return currentUpdateId === updateId\n}\n\n// Immediately invalidates any other update sequences\nexport function invalidateUpdates() {\n  getUpdateId()\n}\n\nfunction getUpdateUrl(document: Document | DocumentFragment): string {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const container = document.querySelector<HTMLElement>('.js-notifications-container')!\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  return container.getAttribute('data-url')!\n}\n\n/*\n * As the user navigates with PJAX, the current update url can change\n * this function validates that the one we have is still correct against\n * the document currently.\n */\nfunction isValidUpdateUrl(updateUrl: string): boolean {\n  return updateUrl === getUpdateUrl(document)\n}\n\n// Refetch the index page and update the current page with the latest content\n//\n// Before fetching and rendering updates, this function will validate that\n// no other code has requested an update, and that the current notification\n// list url has not changed. This prevents rendering stale content from an old\n// server response into the UI.\n//\n// Additionally, fetches will be debounced by the DEBOUNCE_DELAY to prevent lots of\n// server requests if the user performs many actions quickly.\n//\n// Arguments:\n//   * updateId [optional]\n//     - pass an updateId from getUpdateId() if you need to do some async work between\n//       invalidating existing updates and actually triggering the update\nexport async function updateNotifications(updateId: number = getUpdateId()) {\n  const url = getUpdateUrl(document)\n  let fragment\n\n  // Verify that the updateId passed is still valid\n  if (!isValidUpdateId(updateId)) return\n\n  // Timeout to allow for other requests to come in for a short period of time\n  await new Promise(resolve => setTimeout(resolve, DEBOUNCE_DELAY))\n  // If another update request happened in the meantime, cancel this one\n  if (!isValidUpdateId(updateId)) return\n\n  try {\n    // Verify that the url we want to update from is still the valid url we are showing\n    if (!isValidUpdateUrl(url)) return\n    fragment = await fetchSafeDocumentFragment(document, url)\n  } catch {\n    return\n  }\n\n  // If another update request happened in the meantime, cancel this one\n  if (!isValidUpdateId(updateId)) return\n  const currentFocus = getCurrentFocus()\n  updateContent(fragment)\n  // Only restore the keyboard focus based on position, as the previously\n  // selected notification may have jumped around\n  restoreFocus({position: currentFocus.position})\n\n  updateSelectedNotificationsInBulkActionForms()\n}\n\n/*\n * Update the current document with the elements from the new server-rendered html.\n *\n * We do this in small chunks to reduce the impact of a user interacting with a sub-set of\n * the UI.\n */\nfunction updateContent(fragment: DocumentFragment) {\n  // Don't render results if the page has changed via pjax\n  if (!isValidUpdateUrl(getUpdateUrl(fragment))) {\n    return\n  }\n\n  replaceContent('.js-notification-inboxes', fragment)\n\n  replaceContent('.js-notification-new-filters', fragment)\n  replaceContent('.js-notification-mobile-filters', fragment)\n\n  replaceContent('.js-notification-sidebar-repositories', fragment)\n  replaceContent('.js-notifications-list', fragment)\n  replaceContent('.js-notifications-mark-selected-actions', fragment)\n  replaceContent('.js-notifications-mark-all-actions', fragment)\n\n  replaceContent('.js-notifications-list-paginator-counts', fragment)\n  replaceContent('.js-notifications-list-paginator-buttons', fragment)\n  replaceContent('.js-notifications-list-protip', fragment, (newContent, oldContent) => {\n    // don't update the protip if it has just _changed_ (i.e. both old and new are not empty)\n    if (newContent.children.length > 0 && oldContent.children.length > 0) return false\n\n    return true\n  })\n}\n\n/*\n * Replace the contents of the specific selector from the incoming fragment\n * into the document.\n *\n * If the user is currently interacting with the contents of the selector, it will not\n * be replaced.\n */\nfunction replaceContent(\n  selector: string,\n  fragment: DocumentFragment,\n  filterUpdate?: (newContent: Element, oldContent: Element) => boolean,\n) {\n  const newContent = fragment.querySelector(selector)\n  if (!newContent) return\n\n  const toBeReplaced = document.querySelector(selector)\n  if (!toBeReplaced) return\n  // Do not replace if user is currently interacting with content\n  if (hasInteractions(toBeReplaced, true)) return\n  // Do not replace if content hasn't changed\n  if (newContent.outerHTML === toBeReplaced.outerHTML) return\n\n  // If filterUpdate returns false, skip update\n  if (filterUpdate && !filterUpdate(newContent, toBeReplaced)) return\n\n  toBeReplaced.replaceWith(newContent)\n}\n","import {fetchPoll, fetchSafeDocumentFragment} from '@github-ui/fetch-utils'\nimport {\n  getCheckedElements,\n  toggleBulkActionMenus,\n  updateSelectedNotificationsInBulkActionForms,\n} from './notifications/v2/bulk-action-dropdowns'\nimport {getCurrentFocus, restoreFocus, restoreFocusAfterCheckboxClick} from './notifications/v2/notification-list-focus'\nimport {getUpdateId, invalidateUpdates, updateNotifications} from './notifications/v2/update-notifications'\nimport type {Kicker} from '@github-ui/remote-form'\nimport {changeValue} from '@github-ui/form-utils'\n\nimport {announce} from '@github-ui/aria-live'\nimport {fromEvent} from '@github-ui/subscription'\nimport {isShortcutAllowed} from '@github-ui/hotkey/keyboard-shortcuts-helper'\nimport {observe} from '@github-ui/selector-observer'\nimport {on} from 'delegated-events'\nimport {remoteForm} from '@github-ui/remote-form'\nimport {updateNotificationStates} from './notifications/v2/update-notification-states'\nimport {SOFT_NAV_STATE} from '@github-ui/soft-nav/states'\nimport type {QueryBuilderElement} from '@github-ui/query-builder-element'\nimport {getBaseFetchHeaders} from '@github-ui/fetch-headers'\n\n// When true, per-checkbox change handlers should avoid running the expensive\n// updateSelectedNotificationsInBulkActionForms() and let the mark-all handler\n// trigger a single batched update instead.\nlet isSuppressingIndividualHandlers = false\n\nobserve('.js-bulk-action-toasts[data-job-in-progress]', () => {\n  displayBulkProcessingToast()\n})\n\nasync function displayBulkProcessingToast(alreadyProcessing = false) {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const jobUrl = document.querySelector<HTMLElement>('.js-bulk-action-toasts')!.getAttribute('data-job-url')\n  if (!jobUrl) throw new Error('could not get job url')\n\n  // We will display an alternative message if the user tries to submit a request\n  // when they already have a pending or running job.\n  if (alreadyProcessing) {\n    showBulkActionToast('.js-bulk-actions-already-processing-toast')\n  } else {\n    showBulkActionToast('.js-bulk-actions-processing-toast')\n  }\n\n  try {\n    const pollResponse = await fetchPoll(jobUrl, {headers: {accept: 'application/json'}})\n    if (pollResponse.status === 200) {\n      showBulkActionToast('.js-bulk-actions-succeeded-toast')\n      updateNotifications()\n    }\n  } catch {\n    showBulkActionToast('.js-bulk-actions-failed-toast')\n  }\n}\n\nfunction textBannersAnnounce(classname: string) {\n  const messages = {\n    'already-processing': `We're still processing your last request. Please wait for that to complete before submitting a new request`,\n    'actions-processing': `Bulk actions currently being processed`,\n    succeeded: `Bulk action processing complete`,\n    failed: `Bulk action processing failed, please try again`,\n    unsupported: `Bulk actions are not currently supported for this query`,\n  }\n\n  const bannerKey = Object.keys(messages).find(k => classname.includes(k))\n  return bannerKey ? messages[bannerKey as keyof typeof messages] : ''\n}\n\nfunction showBulkActionToast(classname: string) {\n  const target = document.querySelector<HTMLElement>('.js-notifications-banners-target')\n  const template = document.querySelector<HTMLTemplateElement>(classname)\n  const text = textBannersAnnounce(classname)\n\n  if (target && template) {\n    // eslint-disable-next-line @github-ui/github-monorepo/require-set-sanitized-inner-html -- pre-existing innerHTML sink grandfathered when enabling the rule; not migrated in this rollout\n    target.innerHTML = template.innerHTML\n    if (text) {\n      announce(text)\n    }\n  }\n}\n\n// Show the prompt to select _everything_ if all the things on the current\n// page are selected\non('change', '.js-notifications-mark-all-prompt', function (event) {\n  const checked = (event.currentTarget as HTMLInputElement).checked\n\n  // Suppress individual checkbox change handlers while performing a bulk select/unselect.\n  isSuppressingIndividualHandlers = true\n\n  // defer to stop flash if it changes before hiding\n  setTimeout(function () {\n    // Re-assert suppression inside the callback to be defensive against other\n    // code that might mutate the flag between scheduling and execution.\n    isSuppressingIndividualHandlers = true\n\n    try {\n      const elements = document.querySelectorAll<HTMLElement>('.js-notifications-mark-all')\n\n      for (const markAllText of elements) {\n        if (markAllText) {\n          markAllText.hidden = !checked\n        }\n      }\n\n      // After bulk operation completes, perform the expensive update once and\n      // stop suppressing individual change handlers.\n      updateSelectedNotificationsInBulkActionForms()\n    } finally {\n      isSuppressingIndividualHandlers = false\n    }\n  }, 0)\n})\n\n// Show the mark all dropdown when the \"Select all...\" text is clicked\non('click', '.js-notifications-mark-all', function () {\n  toggleBulkActionMenus({markSelected: false, markAll: true})\n})\n\n// Clear the selection when the \"Clear selection\" text is clicked\non('click', '.js-notifications-unmark-all', function () {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  changeValue(document.querySelector<HTMLInputElement>('.js-notifications-mark-all-prompt')!, false)\n})\n\n// Replace blank slate with notification list.\nobserve('.js-notifications-blankslate', {\n  subscribe: el =>\n    fromEvent(el, 'socket:message', async function (event: Event) {\n      const url = (event.currentTarget as Element).getAttribute('data-url')\n      if (!url) throw new Error('could not get url')\n      const response = await fetch(url, {headers: {Accept: 'application/json', ...getBaseFetchHeaders()}})\n      if (!response.ok) {\n        return\n      }\n      const json: {notifications_exist: boolean} = await response.json()\n      if (json.notifications_exist) {\n        updateNotifications()\n      }\n    }),\n})\n\n// If the user navigates with turbo, immediately invalidate any updateNotification tasks\n// that may be happening, as they will definitely be incorrect\ndocument.addEventListener(SOFT_NAV_STATE.SUCCESS, function () {\n  invalidateUpdates()\n})\n\nasync function performRequest(wants: Kicker) {\n  try {\n    await wants.text()\n  } catch {\n    // TODO show error message\n  }\n}\n\n// Perform an action, change the notification status, and optionally update the page\nremoteForm('.js-notification-action form', async function (form: HTMLFormElement, wants) {\n  const shouldUpdate = form.hasAttribute('data-update')\n  const bulkAction = form.closest('.js-notification-bulk-action') != null\n  const shouldRedirect = form.hasAttribute('data-redirect-to-inbox-on-submit')\n  const shouldCloseOnboardingElement = form.hasAttribute('data-close-onboarding-element')\n\n  if (shouldRedirect) {\n    await performRequest(wants)\n    /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n    const inboxButton = document.querySelector<HTMLAnchorElement>('.js-notifications-back-to-inbox')!\n\n    if (inboxButton) {\n      inboxButton.click()\n    }\n\n    return\n  }\n\n  // Generate a unique update ID so that we correctly invalidate existing updates that might\n  // happen during performRequest\n  const updateId = getUpdateId()\n\n  if (bulkAction) {\n    const currentFocus = getCurrentFocus()\n\n    // When performing a bulk action we may programmatically uncheck many items.\n    // Suppress per-checkbox change handlers while we do this so that\n    // updateSelectedNotificationsInBulkActionForms() is only called once.\n    isSuppressingIndividualHandlers = true\n\n    try {\n      for (const checked of getCheckedElements()) {\n        updateNotificationStates(checked, form)\n\n        // Uncheck items if we are going to perform an update so the hidden items\n        // can be replaced successfully on update. hasInteractions will return\n        // true if the checked state does not match the default value which\n        // will prevent the replacement.\n        if (shouldUpdate) {\n          changeValue(checked, false)\n        }\n      }\n    } finally {\n      // End suppressing per-checkbox handlers.\n      isSuppressingIndividualHandlers = false\n    }\n\n    restoreFocus(currentFocus)\n\n    try {\n      const response = await wants.text()\n      if (response.status === 202) {\n        displayBulkProcessingToast()\n        if (shouldCloseOnboardingElement) {\n          /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n          document.querySelector<HTMLElement>('.js-onboarding-dialog')!.removeAttribute('open')\n          /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n          document.querySelector<HTMLElement>('.js-dismiss-notification-onboarding-notice')!.click()\n        }\n      }\n    } catch (error) {\n      // @ts-expect-error catch blocks are bound to `unknown` so we need to validate the type before using it\n      if (error.response.status === 403) {\n        showBulkActionToast('.js-bulk-actions-unsupported-query-toast')\n        // @ts-expect-error catch blocks are bound to `unknown` so we need to validate the type before using it\n      } else if (error.response.status === 409) {\n        displayBulkProcessingToast(true)\n      }\n    }\n  } else {\n    const currentFocus = getCurrentFocus()\n    updateNotificationStates(form, form)\n    restoreFocus(currentFocus)\n    await performRequest(wants)\n  }\n\n  if (shouldUpdate) {\n    updateNotifications(updateId)\n  }\n})\n\n// Remove notification items when snooze action is submitted\nremoteForm('.notification-action-snooze form', async function (form: HTMLFormElement, wants) {\n  await performRequest(wants)\n\n  const notification = form.closest<HTMLElement>('[data-notification-id]')\n  if (notification) {\n    notification.classList.add('notification-archived')\n  }\n})\n\n// Show bulk actions when an item checked, hide when all items are unchecked\non('change', '.js-notification-bulk-action-check-item', function () {\n  // If we're currently performing a bulk select/unselect, skip per-checkbox\n  // updates to avoid executing expensive work multiple times. The mark-all\n  // handler will call updateSelectedNotificationsInBulkActionForms() once.\n  if (isSuppressingIndividualHandlers) return\n\n  updateSelectedNotificationsInBulkActionForms()\n})\n\non('click', '.js-notification-bulk-action-check-item', function (event) {\n  restoreFocusAfterCheckboxClick(event.currentTarget as HTMLInputElement, event.detail)\n})\n\n// Toggle the notification item checkbox when 'x' is pressed\non('navigation:keydown', '.js-notifications-list-item', function (event) {\n  if (!isShortcutAllowed(event.detail.originalEvent)) return\n\n  if (event.detail.hotkey === 'x') {\n    /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n    const checkbox = event.currentTarget.querySelector<HTMLInputElement>('.js-notification-bulk-action-check-item')!\n    changeValue(checkbox, !checkbox.checked)\n    event.preventDefault()\n    event.stopPropagation()\n  }\n})\n\n// Show form that allows you to create a new inbox.\non('click', '.js-custom-inbox-create-button', event => {\n  const el = event.currentTarget as HTMLButtonElement\n\n  const detailsDialog = detailsDialogFromElement(el)\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const details = detailsDialog.closest<HTMLElement>('.js-custom-inbox-details')!\n\n  let searchTerm = ''\n  if (details.classList.contains('js-save-search-details')) {\n    // The user loaded the dialog using the \"Save\" button next to the search\n    // input, so always use the search input value as the default query for\n    // which the user is creating a filter. This helps provide a good default\n    // query after the user deletes a filter in response to the max filters flash.\n    searchTerm = readSearchInput()\n  }\n\n  displayCreateNewInbox(detailsDialog, searchTerm)\n})\n\n// Submit forms for bulk actions in grouped view  asynchronously and update the view accordingly\nremoteForm('.js-grouped-notifications-mark-all-read-button', async function (form: HTMLFormElement, wants) {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const submitButton = form.querySelector<HTMLButtonElement>('button')!\n  submitButton.disabled = true\n\n  showBulkActionToast('.js-bulk-actions-processing-toast')\n\n  try {\n    const response = await wants.text()\n    if (response.status === 200) {\n      showBulkActionToast('.js-bulk-actions-succeeded-toast')\n\n      // Add notification-archived class to notifications in group\n      /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n      const notificationItems = form\n        .closest<HTMLElement>('.js-notifications-group')!\n        .querySelectorAll('.js-notifications-list-item')\n      for (const notification of notificationItems) {\n        notification.classList.add('notification-archived')\n      }\n    }\n  } catch (error) {\n    submitButton.disabled = false\n    // @ts-expect-error catch blocks are bound to `unknown` so we need to validate the type before using it\n    if (error.response.status === 503) {\n      showBulkActionToast('.js-bulk-actions-failed-toast')\n    }\n  }\n})\n\n// Submit forms in the custom inbox dialog asynchronously and update the dialog contents and custom inboxes in the sidebar\nremoteForm('.js-custom-inbox-form', async function (form: HTMLFormElement, wants) {\n  try {\n    await wants.json()\n  } catch {\n    return\n  }\n\n  const detailsDialog = detailsDialogFromElement(form)\n  updateNotifications()\n  updateDialogContent(detailsDialog)\n})\n\nobserve('.js-custom-inbox-details', details => {\n  details.addEventListener('toggle', () => {\n    /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n    const detailsDialog = details.querySelector<HTMLElement>('.js-custom-inbox-dialog')!\n\n    if (!details.hasAttribute('open')) {\n      resetDialogContent(detailsDialog)\n      return\n    }\n\n    // if it's not the save a new search button, don't pass a query string\n    if (!details.classList.contains('js-save-search-details')) {\n      updateDialogContent(detailsDialog)\n      return\n    }\n\n    const searchInput = readSearchInput()\n    updateDialogContent(detailsDialog, searchInput)\n  })\n})\n\nfunction readSearchInput(): string {\n  const queryInput = document.querySelector<HTMLInputElement>('#notifications-search-input')\n\n  if (queryInput) {\n    return queryInput.value\n  }\n  return ''\n}\n\nasync function updateDialogContent(detailsDialog: Element, newInboxQueryString = '') {\n  const url = detailsDialog.getAttribute('src')\n  if (!url) throw new Error('could not get src')\n\n  let html\n  try {\n    html = await fetchSafeDocumentFragment(document, url)\n  } catch {\n    return\n  }\n\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const dialogContent = detailsDialog.querySelector<HTMLElement>('.js-custom-inbox-dialog-content')!\n\n  // Hide the spinner\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  detailsDialog.querySelector<HTMLElement>('.js-custom-inbox-dialog-spinner')!.hidden = true\n  // Replace dialog content with response\n  dialogContent.textContent = ''\n  dialogContent.appendChild(html)\n\n  const maxFiltersFlash = document.querySelector<HTMLElement>('.js-custom-inbox-max-filters-flash')\n\n  if (newInboxQueryString.length > 0 && maxFiltersFlash) {\n    // If the user is trying to save via the \"save search\" button\n    // but already has the max amount of filters, display the max filters flash.\n    maxFiltersFlash.hidden = false\n  } else if (newInboxQueryString.length > 0) {\n    // If the user is trying to save via the \"save search\" button and does not\n    // already have the max filters, display the create inbox fields.\n    displayCreateNewInbox(detailsDialog, newInboxQueryString)\n  }\n}\n\nfunction displayCreateNewInbox(detailsDialog: Element, newInboxQueryString = '') {\n  // Set the new query string input value to the search input value\n  if (newInboxQueryString.length > 0) {\n    /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n    const queryInput = detailsDialog.querySelector<HTMLInputElement>('.js-custom-inbox-query-string-input')!\n    queryInput.value = newInboxQueryString\n  }\n\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const container = detailsDialog.querySelector<HTMLElement>('.js-custom-inbox-create-form-container')!\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const nameInput = container.querySelector<HTMLElement>('.js-custom-inbox-name-input')!\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const createButton = detailsDialog.querySelector<HTMLButtonElement>('.js-custom-inbox-create-button')!\n\n  createButton.disabled = true\n  container.hidden = false\n  nameInput.focus()\n}\n\nfunction resetDialogContent(detailsDialog: Element) {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  detailsDialog.querySelector<HTMLElement>('.js-custom-inbox-dialog-spinner')!.hidden = false\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  detailsDialog.querySelector<HTMLElement>('.js-custom-inbox-dialog-content')!.textContent = ''\n}\n\nfunction detailsDialogFromElement(el: Element) {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const details = el.closest<HTMLElement>('.js-custom-inbox-details')!\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  return details.querySelector<HTMLElement>('.js-custom-inbox-dialog')!\n}\n\nobserve('.js-notifications-group .notification-archived', {\n  constructor: HTMLElement,\n  add: updateGroupDisplay,\n})\n\nfunction updateGroupDisplay(notification: HTMLElement) {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const group = notification.closest<HTMLElement>('.js-notifications-group')!\n\n  const notificationElements = notification.parentElement?.children\n  if (!notificationElements) return\n\n  const allNotificationsArchived = Array.from(notificationElements).every(el =>\n    el.classList.contains('notification-archived'),\n  )\n  const groupDoesNotHaveViewMoreLink = group.querySelector('.js-notifications-group-view-all') == null\n\n  // Only remove the group if all notifications are archived AND the group does not have a link to view more notifications\n  if (allNotificationsArchived && groupDoesNotHaveViewMoreLink) group.remove()\n}\n\non('query-builder:clear', '#query-builder-notifications-search-input', function (event) {\n  const query = new URLSearchParams(window.location.search).get('query')\n\n  // Default query builder behaviour\n  if (!query) {\n    return true\n  }\n\n  // Override query builder and submit the cleared form\n  event.preventDefault()\n\n  const queryBuilder = event.target as QueryBuilderElement\n  const searchInput = queryBuilder.input\n\n  queryBuilder.clearInput({focusInput: false}) // prevent the autocomplete panel from opening\n\n  const form = searchInput.closest('form')\n  form?.submit()\n\n  return false\n})\n","import {isFeatureEnabled} from '@github-ui/feature-flags'\nimport {PreheatIssuesManager} from '@github-ui/preheat-issues-manager'\nimport {observe} from '@github-ui/selector-observer'\nimport {isLoggedIn} from '@github-ui/client-env'\n\nconst manager = new PreheatIssuesManager({\n  isEnabled: () => !isFeatureEnabled('disable_preheating_for_issues') && isLoggedIn(),\n  source: 'notifications',\n})\n\nmanager.start()\n\n// Buffer preheat event data on window so that events fired before the\n// React listener registers are not lost.  The consumer replays\n// this buffer when it mounts.\ntype PreheatEventDetail = {href: string | null}\ndeclare global {\n  interface Window {\n    __preheatEventBuffer?: PreheatEventDetail[]\n  }\n}\nwindow.__preheatEventBuffer = window.__preheatEventBuffer ?? []\n\nobserve('.notification-list-item-link', {\n  initialize: el => {\n    const detail: PreheatEventDetail = {href: el.getAttribute('href')}\n\n    // Always push to the buffer so late-mounting listeners can replay.\n    /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n    window.__preheatEventBuffer!.push(detail)\n\n    // Also dispatch the live event for listeners that are already registered.\n    window.dispatchEvent(new CustomEvent('issue-link-to-preheat', {detail}))\n  },\n})\n","import memoize from '@github/memoize'\nimport {hasMatch} from 'fzy.js'\nimport {\n  type SearchProvider,\n  type FilterProvider,\n  FilterItem,\n  type QueryEvent,\n  type QueryFilterElement,\n  SearchItem,\n  Octicon,\n} from '@github-ui/query-builder-element/query-builder-api'\nimport type {QueryBuilderElement} from '@github-ui/query-builder-element'\n\ninterface Suggestion {\n  value: string\n}\n\nconst memoizeCache = new Map()\nconst memoizeFetchJSON = memoize(fetchJSON, {cache: memoizeCache})\n\nasync function fetchJSON(url: string) {\n  const response = await fetch(url, {headers: {Accept: 'application/json'}})\n\n  if (response.ok) {\n    return await response.json()\n  } else {\n    return undefined\n  }\n}\n\nconst getSearchUrl =\n  document.querySelector<HTMLFormElement>('#notifications-search-input-form')?.getAttribute('action') || ''\n\nconst filterSuggestions = (suggestions: string[], query: string) =>\n  suggestions.filter(suggestion => {\n    if ((query && hasMatch(query, suggestion)) || query === '') return suggestion\n  })\n\nconst searchInputId = 'query-builder-notifications-search-input'\n\nfunction getSearchInput(): HTMLElement {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  return document.querySelector<HTMLElement>(`query-builder#${searchInputId}`)!\n}\n\nasync function fetchAuthorSuggestions(): Promise<Suggestion[]> {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const url = getSearchInput().getAttribute('data-suggestable-authors')!\n  return memoizeFetchJSON(url)\n}\n\nasync function fetchRepositoriesSuggestions(): Promise<Suggestion[]> {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const url = getSearchInput().getAttribute('data-suggestable-repositories')!\n  return memoizeFetchJSON(url)\n}\n\nasync function fetchOwnersSuggestions(): Promise<Suggestion[]> {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  const url = getSearchInput().getAttribute('data-suggestable-owners')!\n  return memoizeFetchJSON(url)\n}\n\nasync function fetchTypesSuggestions(): Promise<Suggestion[]> {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  return JSON.parse(getSearchInput().getAttribute('data-suggestable-types')!)\n}\n\nasync function fetchReasonsSuggestions(): Promise<Suggestion[]> {\n  /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n  return JSON.parse(getSearchInput().getAttribute('data-suggestable-reasons')!)\n}\n\nconst authors = async (): Promise<Suggestion[]> => await fetchAuthorSuggestions()\nconst repositories = async (): Promise<Suggestion[]> => await fetchRepositoriesSuggestions()\nconst types = async (): Promise<Suggestion[]> => await fetchTypesSuggestions()\nconst reasons = async (): Promise<Suggestion[]> => await fetchReasonsSuggestions()\nconst owners = async (): Promise<Suggestion[]> => await fetchOwnersSuggestions()\n\nclass SearchItemProvider extends EventTarget implements SearchProvider {\n  priority = 1\n  name = 'Search'\n  singularItemName = 'search item'\n  value = 'search'\n  type = 'search' as const\n\n  queryBuilder: QueryBuilderElement\n\n  constructor(queryBuilder: QueryBuilderElement) {\n    super()\n\n    this.queryBuilder = queryBuilder\n    this.queryBuilder.addEventListener('query', this)\n    this.queryBuilder.attachProvider(this)\n  }\n\n  handleEvent(event: QueryEvent) {\n    if (String(event) === '') return\n    this.dispatchEvent(\n      new SearchItem({\n        priority: 1,\n        value: event.toString(),\n        icon: Octicon.Search,\n        scope: 'GENERAL',\n        action: {\n          url: `${getSearchUrl}?query=${event.toString()}`,\n        },\n      }),\n    )\n  }\n}\n\nclass AuthorProvider extends EventTarget implements FilterProvider {\n  name = 'Authors'\n  singularItemName = 'author'\n  value = 'author'\n  description = 'filter by notification author'\n  priority = 2\n  type = 'filter' as const\n\n  queryBuilder: QueryBuilderElement\n\n  constructor(queryBuilder: QueryBuilderElement) {\n    super()\n\n    this.queryBuilder = queryBuilder\n    this.queryBuilder.addEventListener('query', this)\n    this.queryBuilder.attachProvider(this)\n  }\n\n  async handleEvent(event: QueryEvent) {\n    const lastQuery = event.parsedQuery.at(-1)\n    const lastQueryValue = lastQuery?.value || ''\n    const lastQueryType = lastQuery?.type\n    const lastQueryFilter = (lastQuery as QueryFilterElement)?.filter || ''\n\n    if (lastQueryType !== 'filter' && (hasMatch(lastQueryValue, this.value) || lastQueryValue === '')) {\n      this.dispatchEvent(new Event('show'))\n    }\n\n    // Prevents the author filters from being fetched if the author filter was not chosen\n    if (lastQueryType !== 'filter' || lastQueryFilter !== this.value) return\n\n    const getAuthorData = await authors()\n    const authorValues = getAuthorData.map(author => author.value)\n    const filteredAuthors = filterSuggestions(authorValues, lastQueryValue)\n\n    // Only show the top 5 results to avoid overwhelming the browser,\n    // fixes https://github.com/github/discussions/issues/2816\n    const limitedFilteredAuthors = filteredAuthors.slice(0, 5)\n\n    for (const author of limitedFilteredAuthors) {\n      this.dispatchEvent(new FilterItem({filter: 'author', value: author}))\n    }\n  }\n}\n\nclass RepositoryProvider extends EventTarget implements FilterProvider {\n  name = 'Repositories'\n  singularItemName = 'repo'\n  value = 'repo'\n  description = 'filter by repository'\n  priority = 2\n  type = 'filter' as const\n\n  queryBuilder: QueryBuilderElement\n\n  constructor(queryBuilder: QueryBuilderElement) {\n    super()\n\n    this.queryBuilder = queryBuilder\n    this.queryBuilder.addEventListener('query', this)\n    this.queryBuilder.attachProvider(this)\n  }\n\n  async handleEvent(event: QueryEvent) {\n    const lastQuery = event.parsedQuery.at(-1)\n    const lastQueryValue = lastQuery?.value || ''\n    const lastQueryType = lastQuery?.type\n    const lastQueryFilter = (lastQuery as QueryFilterElement)?.filter || ''\n\n    if (lastQueryType !== 'filter' && (hasMatch(lastQueryValue, this.value) || lastQueryValue === '')) {\n      this.dispatchEvent(new Event('show'))\n    }\n\n    if (lastQueryType !== 'filter' || lastQueryFilter !== this.value) return\n\n    const getRepoData = await repositories()\n    const repoValues = getRepoData.map(repo => repo.value)\n    const filteredRepos = filterSuggestions(repoValues, lastQueryValue)\n\n    // Only show the top 5 results to avoid overwhelming the browser,\n    // fixes https://github.com/github/discussions/issues/2816\n    const limitedFilteredRepos = filteredRepos.slice(0, 5)\n\n    for (const repo of limitedFilteredRepos) {\n      this.dispatchEvent(new FilterItem({filter: 'repo', value: repo}))\n    }\n  }\n}\n\nclass OwnersProvider extends EventTarget implements FilterProvider {\n  name = 'Organizations'\n  singularItemName = 'org'\n  value = 'org'\n  description = 'filter by organization'\n  priority = 2\n  type = 'filter' as const\n\n  queryBuilder: QueryBuilderElement\n\n  constructor(queryBuilder: QueryBuilderElement) {\n    super()\n\n    this.queryBuilder = queryBuilder\n    this.queryBuilder.addEventListener('query', this)\n    this.queryBuilder.attachProvider(this)\n  }\n\n  async handleEvent(event: QueryEvent) {\n    const lastQuery = event.parsedQuery.at(-1)\n    const lastQueryValue = lastQuery?.value || ''\n    const lastQueryType = lastQuery?.type\n    const lastQueryFilter = (lastQuery as QueryFilterElement)?.filter || ''\n\n    if (lastQueryType !== 'filter' && (hasMatch(lastQueryValue, this.value) || lastQueryValue === '')) {\n      this.dispatchEvent(new Event('show'))\n    }\n\n    if (lastQueryType !== 'filter' || lastQueryFilter !== this.value) return\n\n    const getOwnerData = await owners()\n    const ownerValues = getOwnerData.map(owner => owner.value)\n    const filteredOwners = filterSuggestions(ownerValues, lastQueryValue)\n\n    // Only show the top 5 results to avoid overwhelming the browser,\n    // fixes https://github.com/github/discussions/issues/2816\n    const limitedFilteredOwners = filteredOwners.slice(0, 5)\n\n    for (const org of limitedFilteredOwners) {\n      this.dispatchEvent(new FilterItem({filter: 'org', value: org}))\n    }\n  }\n}\n\nclass TypeProvider extends EventTarget implements FilterProvider {\n  name = 'Types'\n  singularItemName = 'type'\n  value = 'is'\n  description = 'filter by status or discussion type'\n  priority = 2\n  type = 'filter' as const\n\n  queryBuilder: QueryBuilderElement\n\n  constructor(queryBuilder: QueryBuilderElement) {\n    super()\n\n    this.queryBuilder = queryBuilder\n    this.queryBuilder.addEventListener('query', this)\n    this.queryBuilder.attachProvider(this)\n  }\n\n  async handleEvent(event: QueryEvent) {\n    const lastQuery = event.parsedQuery.at(-1)\n    const lastQueryValue = lastQuery?.value || ''\n    const lastQueryType = lastQuery?.type\n    const lastQueryFilter = (lastQuery as QueryFilterElement)?.filter || ''\n\n    if (lastQueryType !== 'filter' && (hasMatch(lastQueryValue, this.value) || lastQueryValue === '')) {\n      this.dispatchEvent(new Event('show'))\n    }\n\n    if (lastQueryType !== 'filter' || lastQueryFilter !== this.value) return\n\n    const getTypeData = await types()\n    const typeValues = getTypeData.map(role => role.value)\n\n    const filteredTypes = filterSuggestions(typeValues, lastQueryValue)\n\n    for (const typeValue of filteredTypes) {\n      this.dispatchEvent(new FilterItem({filter: 'is', value: typeValue}))\n    }\n  }\n}\n\nclass ReasonProvider extends EventTarget implements FilterProvider {\n  name = 'Reasons'\n  singularItemName = 'reason'\n  value = 'reason'\n  description = 'filter by notification reason'\n  priority = 2\n  type = 'filter' as const\n\n  queryBuilder: QueryBuilderElement\n\n  constructor(queryBuilder: QueryBuilderElement) {\n    super()\n\n    this.queryBuilder = queryBuilder\n    this.queryBuilder.addEventListener('query', this)\n    this.queryBuilder.attachProvider(this)\n  }\n\n  async handleEvent(event: QueryEvent) {\n    const lastQuery = event.parsedQuery.at(-1)\n    const lastQueryValue = lastQuery?.value || ''\n    const lastQueryType = lastQuery?.type\n    const lastQueryFilter = (lastQuery as QueryFilterElement)?.filter || ''\n\n    if (lastQueryType !== 'filter' && (hasMatch(lastQueryValue, this.value) || lastQueryValue === '')) {\n      this.dispatchEvent(new Event('show'))\n    }\n\n    if (lastQueryType !== 'filter' || lastQueryFilter !== this.value) return\n\n    const getTypeData = await reasons()\n    const reasonValues = getTypeData.map(reason => reason.value)\n\n    const filteredReasons = filterSuggestions(reasonValues, lastQueryValue)\n\n    for (const reason of filteredReasons) {\n      this.dispatchEvent(new FilterItem({filter: 'reason', value: reason}))\n    }\n  }\n}\n\ndocument.addEventListener('query-builder:request-provider', (event: Event) => {\n  const target: QueryBuilderElement | null = event.target as QueryBuilderElement\n  if (!target || target.id !== searchInputId) return\n\n  new SearchItemProvider(event.target as QueryBuilderElement)\n  new RepositoryProvider(event.target as QueryBuilderElement)\n  new TypeProvider(event.target as QueryBuilderElement)\n  new ReasonProvider(event.target as QueryBuilderElement)\n  new AuthorProvider(event.target as QueryBuilderElement)\n  new OwnersProvider(event.target as QueryBuilderElement)\n})\n","import {getDocumentHtmlSafeNonces, verifyResponseHtmlSafeNonce} from '@github-ui/html-safe-nonce'\nimport {parseHTML} from '@github-ui/parse-html'\nimport {addBaseFetchHeaders} from '@github-ui/fetch-headers'\n\nexport async function fetchSafeDocumentFragment(\n  document: Document,\n  url: RequestInfo,\n  options?: RequestInit,\n): Promise<DocumentFragment> {\n  const request = new Request(url, options)\n  addBaseFetchHeaders(request.headers)\n  const response = await self.fetch(request)\n  if (response.status < 200 || response.status >= 300) {\n    throw new Error(`HTTP ${response.status}${response.statusText || ''}`)\n  }\n\n  verifyResponseHtmlSafeNonce(getDocumentHtmlSafeNonces(document), response)\n  return parseHTML(document, await response.text())\n}\n\nexport interface FetchPollOptions extends RequestInit {\n  onPoll?: (response: Response) => void | Promise<void>\n}\n\nfunction waitForNextPoll(wait: number, signal?: AbortSignal | null): Promise<void> {\n  if (signal?.aborted) return Promise.reject(signal.reason)\n\n  return new Promise((resolve, reject) => {\n    const timeout = setTimeout(() => {\n      signal?.removeEventListener('abort', handleAbort)\n      resolve()\n    }, wait)\n    const handleAbort = () => {\n      clearTimeout(timeout)\n      reject(signal?.reason)\n    }\n    signal?.addEventListener('abort', handleAbort, {once: true})\n  })\n}\n\nexport function fetchPoll(\n  url: RequestInfo,\n  options?: FetchPollOptions,\n  timeBetweenRequests = 1000,\n  acceptedStatusCodes = [200],\n  pollStatusCodes = [202],\n): Promise<Response> {\n  return (async function poll(wait: number): Promise<Response> {\n    const {onPoll, ...requestOptions} = options ?? {}\n    const request = new Request(url, requestOptions)\n    addBaseFetchHeaders(request.headers)\n    const response = await self.fetch(request)\n\n    if (pollStatusCodes.includes(response.status)) {\n      await onPoll?.(response.clone())\n      await waitForNextPoll(wait, requestOptions.signal)\n      return poll(wait * 1.5)\n    }\n    if (acceptedStatusCodes.includes(response.status)) {\n      return response\n    }\n    if (response.status < 200 || response.status >= 300) {\n      throw new Error(`HTTP ${response.status}${response.statusText || ''}`)\n    }\n    throw new Error(`Unexpected ${response.status} response status from poll endpoint`)\n  })(timeBetweenRequests)\n}\n\ntype RetryResult = Response | 'retry'\ntype FetchRetryOptions = {\n  // Base wait time between retries\n  // this will be multiplied with the current attempt to perform a backoff strategy\n  // Defaults to 500ms\n  wait?: number\n  // List of accepted status codes that should not be retried. Defaults to [200]\n  acceptedStatusCodes?: number[]\n  // Max number of attempts. Defaults to 3\n  max?: number\n  // Current retry attempt. Starts at 0\n  attempt?: number\n}\n\n// Execute a fetch call in a callback and retry it up to `options.max` times\n// Each retry will be delayed `options.wait` * `options.attempt`\nexport async function fetchRetry(\n  url: RequestInfo,\n  fetchOptions?: RequestInit,\n  options?: FetchRetryOptions,\n): Promise<Response> {\n  const {wait = 500, acceptedStatusCodes = [200], max = 3, attempt = 0} = options || {}\n\n  const retry: () => Promise<RetryResult> = async () => {\n    return new Promise((resolve, reject) => {\n      setTimeout(async () => {\n        try {\n          const request = new Request(url, fetchOptions)\n          addBaseFetchHeaders(request.headers)\n          const response = await self.fetch(request)\n          if (acceptedStatusCodes.includes(response.status) || attempt + 1 === max) {\n            return resolve(response)\n          }\n\n          // The response failed, we indicate that it must be retried\n          resolve('retry')\n        } catch (err) {\n          // Only non successful HTTP status codes are controlled by this retry mechanism\n          // Any other error is propagated\n          reject(err)\n        }\n      }, wait * attempt)\n    })\n  }\n\n  const result = await retry()\n  if (result !== 'retry') {\n    return result\n  }\n\n  return fetchRetry(url, fetchOptions, {wait, acceptedStatusCodes, max, attempt: attempt + 1})\n}\n","//  Get document's HTML Safe nonce.\n//\n// Example:\n//\n//   <meta name=\"html-safe-nonce\" content=\"de43a1f355c711f7f705e4f971964391ac0c8e13\">\nexport function getDocumentHtmlSafeNonces(document: Document): string[] {\n  const nonces = [...document.querySelectorAll<HTMLMetaElement>('meta[name=html-safe-nonce]')].map(meta => meta.content)\n\n  if (nonces.length < 1) {\n    throw new Error('could not find html-safe-nonce on document')\n  }\n  return nonces\n}\n\ninterface Response {\n  headers: Headers\n  status: number\n}\n\nclass ResponseError extends Error {\n  response: Response\n\n  constructor(message: string, response: Response) {\n    super(`${message} for HTTP ${response.status}`)\n    this.response = response\n    this.name = 'ResponseError'\n  }\n}\n\nexport function verifyResponseHtmlSafeNonce(nonces: string[], response: Response, allowJson = false) {\n  const contentType = response.headers.get('content-type') || ''\n  if (!allowJson && !contentType.startsWith('text/html')) {\n    throw new ResponseError(`expected response with text/html, but was ${contentType}`, response)\n  }\n\n  if (allowJson && !(contentType.startsWith('text/html') || contentType.startsWith('application/json'))) {\n    throw new ResponseError(`expected response with text/html or application/json, but was ${contentType}`, response)\n  }\n\n  const responseNonce = response.headers.get('x-html-safe')\n  if (!responseNonce) {\n    throw new ResponseError(`missing X-HTML-Safe nonce`, response)\n  } else if (!nonces.includes(responseNonce)) {\n    throw new ResponseError(`response X-HTML-Safe nonce did not match`, response)\n  }\n}\n"],"names":["updateNotificationStates","element","form","notification","status","toggleBulkActionMenu","menu","enabled","button","toggleBulkActionMenus","markSelected","markAll","toggleSelectAll","selectedText","document","selectedTextWithCount","selectedTextWithAllCount","updateSelectedNotificationsInBulkActionForms","container","addCheckedNotificationsToForm","input","checked","getCheckedElements","addHiddenInputToForm","name","value","getCurrentFocus","notificationsList","keyboardFocusedSelector","getNotificationsList","keyboardFocused","HTMLElement","getItems","restoreFocus","id","position","target","items","el","Math","navigationFocus","Array","visible","currentUpdateId","getUpdateId","getUpdateUrl","document1","isValidUpdateUrl","updateUrl","updateNotifications","updateId","fragment","url","Promise","resolve","setTimeout","fetchSafeDocumentFragment","currentFocus","replaceContent","newContent","oldContent","selector","filterUpdate","toBeReplaced","hasInteractions","isSuppressingIndividualHandlers","displayBulkProcessingToast","alreadyProcessing","jobUrl","Error","showBulkActionToast","pollResponse","fetchPoll","classname","messages","bannerKey","template","text","Object","k","announce","performRequest","wants","readSearchInput","queryInput","updateDialogContent","detailsDialog","newInboxQueryString","html","dialogContent","maxFiltersFlash","displayCreateNewInbox","nameInput","createButton","detailsDialogFromElement","details","observe","on","event","markAllText","changeValue","fromEvent","response","fetch","getBaseFetchHeaders","json","SOFT_NAV_STATE","remoteForm","shouldUpdate","bulkAction","shouldRedirect","shouldCloseOnboardingElement","inboxButton","error","restoreFocusAfterCheckboxClick","checkbox","clickCount","item","isShortcutAllowed","searchTerm","submitButton","group","notificationElements","allNotificationsArchived","groupDoesNotHaveViewMoreLink","URLSearchParams","window","queryBuilder","searchInput","manager","PreheatIssuesManager","isFeatureEnabled","isLoggedIn","detail","CustomEvent","memoizeCache","Map","memoizeFetchJSON","memoize","fetchJSON","getSearchUrl","filterSuggestions","suggestions","query","suggestion","hasMatch","searchInputId","getSearchInput","fetchAuthorSuggestions","fetchRepositoriesSuggestions","fetchOwnersSuggestions","fetchTypesSuggestions","JSON","fetchReasonsSuggestions","authors","repositories","types","reasons","owners","SearchItemProvider","EventTarget","String","SearchItem","Octicon","AuthorProvider","lastQuery","lastQueryValue","lastQueryType","lastQueryFilter","Event","author","filteredAuthors","getAuthorData","FilterItem","RepositoryProvider","repo","filteredRepos","getRepoData","OwnersProvider","org","filteredOwners","getOwnerData","owner","TypeProvider","typeValue","getTypeData","role","ReasonProvider","reason","options","request","Request","addBaseFetchHeaders","self","verifyResponseHtmlSafeNonce","getDocumentHtmlSafeNonces","parseHTML","timeBetweenRequests","acceptedStatusCodes","pollStatusCodes","poll","wait","onPoll","requestOptions","signal","reject","timeout","handleAbort","clearTimeout","fetchRetry","fetchOptions","max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