{
  "version": 3,
  "sources": ["../dist-src/index.js", "../dist-src/version.js", "../dist-src/wrap-request.js", "../dist-src/generated/triggers-notification-paths.js", "../dist-src/route-matcher.js"],
  "sourcesContent": ["import BottleneckLight from \"bottleneck/light\";\nimport { Octokit } from \"@octokit/core\";\nimport { VERSION } from \"./version\";\nimport { wrapRequest } from \"./wrap-request\";\nimport triggersNotificationPaths from \"./generated/triggers-notification-paths\";\nimport { routeMatcher } from \"./route-matcher\";\nconst regex = routeMatcher(triggersNotificationPaths);\nconst triggersNotification = regex.test.bind(regex);\nconst groups = {};\nconst createGroups = function(Bottleneck, common) {\n  groups.global = new Bottleneck.Group({\n    id: \"octokit-global\",\n    maxConcurrent: 10,\n    ...common\n  });\n  groups.search = new Bottleneck.Group({\n    id: \"octokit-search\",\n    maxConcurrent: 1,\n    minTime: 2e3,\n    ...common\n  });\n  groups.write = new Bottleneck.Group({\n    id: \"octokit-write\",\n    maxConcurrent: 1,\n    minTime: 1e3,\n    ...common\n  });\n  groups.notifications = new Bottleneck.Group({\n    id: \"octokit-notifications\",\n    maxConcurrent: 1,\n    minTime: 3e3,\n    ...common\n  });\n};\nfunction throttling(octokit, octokitOptions) {\n  const {\n    enabled = true,\n    Bottleneck = BottleneckLight,\n    id = \"no-id\",\n    timeout = 1e3 * 60 * 2,\n    // Redis TTL: 2 minutes\n    connection\n  } = octokitOptions.throttle || {};\n  if (!enabled) {\n    return {};\n  }\n  const common = { connection, timeout };\n  if (groups.global == null) {\n    createGroups(Bottleneck, common);\n  }\n  const state = Object.assign(\n    {\n      clustering: connection != null,\n      triggersNotification,\n      fallbackSecondaryRateRetryAfter: 60,\n      retryAfterBaseValue: 1e3,\n      retryLimiter: new Bottleneck(),\n      id,\n      ...groups\n    },\n    octokitOptions.throttle\n  );\n  if (typeof state.onSecondaryRateLimit !== \"function\" || typeof state.onRateLimit !== \"function\") {\n    throw new Error(`octokit/plugin-throttling error:\n        You must pass the onSecondaryRateLimit and onRateLimit error handlers.\n        See https://octokit.github.io/rest.js/#throttling\n\n        const octokit = new Octokit({\n          throttle: {\n            onSecondaryRateLimit: (retryAfter, options) => {/* ... */},\n            onRateLimit: (retryAfter, options) => {/* ... */}\n          }\n        })\n    `);\n  }\n  const events = {};\n  const emitter = new Bottleneck.Events(events);\n  events.on(\"secondary-limit\", state.onSecondaryRateLimit);\n  events.on(\"rate-limit\", state.onRateLimit);\n  events.on(\n    \"error\",\n    (e) => octokit.log.warn(\"Error in throttling-plugin limit handler\", e)\n  );\n  state.retryLimiter.on(\"failed\", async function(error, info) {\n    const [state2, request, options] = info.args;\n    const { pathname } = new URL(options.url, \"http://github.test\");\n    const shouldRetryGraphQL = pathname.startsWith(\"/graphql\") && error.status !== 401;\n    if (!(shouldRetryGraphQL || error.status === 403)) {\n      return;\n    }\n    const retryCount = ~~request.retryCount;\n    request.retryCount = retryCount;\n    options.request.retryCount = retryCount;\n    const { wantRetry, retryAfter = 0 } = await async function() {\n      if (/\\bsecondary rate\\b/i.test(error.message)) {\n        const retryAfter2 = Number(error.response.headers[\"retry-after\"]) || state2.fallbackSecondaryRateRetryAfter;\n        const wantRetry2 = await emitter.trigger(\n          \"secondary-limit\",\n          retryAfter2,\n          options,\n          octokit,\n          retryCount\n        );\n        return { wantRetry: wantRetry2, retryAfter: retryAfter2 };\n      }\n      if (error.response.headers != null && error.response.headers[\"x-ratelimit-remaining\"] === \"0\" || (error.response.data?.errors ?? []).some(\n        (error2) => error2.type === \"RATE_LIMITED\"\n      )) {\n        const rateLimitReset = new Date(\n          ~~error.response.headers[\"x-ratelimit-reset\"] * 1e3\n        ).getTime();\n        const retryAfter2 = Math.max(\n          // Add one second so we retry _after_ the reset time\n          // https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#exceeding-the-rate-limit\n          Math.ceil((rateLimitReset - Date.now()) / 1e3) + 1,\n          0\n        );\n        const wantRetry2 = await emitter.trigger(\n          \"rate-limit\",\n          retryAfter2,\n          options,\n          octokit,\n          retryCount\n        );\n        return { wantRetry: wantRetry2, retryAfter: retryAfter2 };\n      }\n      return {};\n    }();\n    if (wantRetry) {\n      request.retryCount++;\n      return retryAfter * state2.retryAfterBaseValue;\n    }\n  });\n  octokit.hook.wrap(\"request\", wrapRequest.bind(null, state));\n  return {};\n}\nthrottling.VERSION = VERSION;\nthrottling.triggersNotification = triggersNotification;\nexport {\n  throttling\n};\n", "const VERSION = \"8.1.3\";\nexport {\n  VERSION\n};\n", "const noop = () => Promise.resolve();\nfunction wrapRequest(state, request, options) {\n  return state.retryLimiter.schedule(doRequest, state, request, options);\n}\nasync function doRequest(state, request, options) {\n  const isWrite = options.method !== \"GET\" && options.method !== \"HEAD\";\n  const { pathname } = new URL(options.url, \"http://github.test\");\n  const isSearch = options.method === \"GET\" && pathname.startsWith(\"/search/\");\n  const isGraphQL = pathname.startsWith(\"/graphql\");\n  const retryCount = ~~request.retryCount;\n  const jobOptions = retryCount > 0 ? { priority: 0, weight: 0 } : {};\n  if (state.clustering) {\n    jobOptions.expiration = 1e3 * 60;\n  }\n  if (isWrite || isGraphQL) {\n    await state.write.key(state.id).schedule(jobOptions, noop);\n  }\n  if (isWrite && state.triggersNotification(pathname)) {\n    await state.notifications.key(state.id).schedule(jobOptions, noop);\n  }\n  if (isSearch) {\n    await state.search.key(state.id).schedule(jobOptions, noop);\n  }\n  const req = state.global.key(state.id).schedule(\n    jobOptions,\n    request,\n    options\n  );\n  if (isGraphQL) {\n    const res = await req;\n    if (res.data.errors != null && res.data.errors.some((error) => error.type === \"RATE_LIMITED\")) {\n      const error = Object.assign(new Error(\"GraphQL Rate Limit Exceeded\"), {\n        response: res,\n        data: res.data\n      });\n      throw error;\n    }\n  }\n  return req;\n}\nexport {\n  wrapRequest\n};\n", "var triggers_notification_paths_default = [\n  \"/orgs/{org}/invitations\",\n  \"/orgs/{org}/invitations/{invitation_id}\",\n  \"/orgs/{org}/teams/{team_slug}/discussions\",\n  \"/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments\",\n  \"/repos/{owner}/{repo}/collaborators/{username}\",\n  \"/repos/{owner}/{repo}/commits/{commit_sha}/comments\",\n  \"/repos/{owner}/{repo}/issues\",\n  \"/repos/{owner}/{repo}/issues/{issue_number}/comments\",\n  \"/repos/{owner}/{repo}/pulls\",\n  \"/repos/{owner}/{repo}/pulls/{pull_number}/comments\",\n  \"/repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies\",\n  \"/repos/{owner}/{repo}/pulls/{pull_number}/merge\",\n  \"/repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers\",\n  \"/repos/{owner}/{repo}/pulls/{pull_number}/reviews\",\n  \"/repos/{owner}/{repo}/releases\",\n  \"/teams/{team_id}/discussions\",\n  \"/teams/{team_id}/discussions/{discussion_number}/comments\"\n];\nexport {\n  triggers_notification_paths_default as default\n};\n", "function routeMatcher(paths) {\n  const regexes = paths.map(\n    (path) => path.split(\"/\").map((c) => c.startsWith(\"{\") ? \"(?:.+?)\" : c).join(\"/\")\n  );\n  const regex = `^(?:${regexes.map((r) => `(?:${r})`).join(\"|\")})[^/]*$`;\n  return new RegExp(regex, \"i\");\n}\nexport {\n  routeMatcher\n};\n"],
  "mappings": ";AAAA,OAAO,qBAAqB;AAC5B,SAAS,eAAe;;;ACDxB,IAAM,UAAU;;;ACAhB,IAAM,OAAO,MAAM,QAAQ,QAAQ;AACnC,SAAS,YAAY,OAAO,SAAS,SAAS;AAC5C,SAAO,MAAM,aAAa,SAAS,WAAW,OAAO,SAAS,OAAO;AACvE;AACA,eAAe,UAAU,OAAO,SAAS,SAAS;AAChD,QAAM,UAAU,QAAQ,WAAW,SAAS,QAAQ,WAAW;AAC/D,QAAM,EAAE,SAAS,IAAI,IAAI,IAAI,QAAQ,KAAK,oBAAoB;AAC9D,QAAM,WAAW,QAAQ,WAAW,SAAS,SAAS,WAAW,UAAU;AAC3E,QAAM,YAAY,SAAS,WAAW,UAAU;AAChD,QAAM,aAAa,CAAC,CAAC,QAAQ;AAC7B,Q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