@gitkraken/core-gitlens 0.41.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/dist/git/models/issue.d.ts +2 -0
  3. package/dist/git/models/issue.js.map +1 -1
  4. package/dist/git/models/issueOrPullRequest.d.ts +4 -0
  5. package/dist/git/models/pullRequest.d.ts +2 -0
  6. package/dist/git/models/pullRequest.js.map +1 -1
  7. package/dist/plus/git-github/api/github.d.ts +2 -4
  8. package/dist/plus/git-github/api/github.js +12 -2
  9. package/dist/plus/git-github/api/github.js.map +1 -1
  10. package/dist/plus/git-github/api/issueWrites.d.ts +3 -2
  11. package/dist/plus/git-github/api/issueWrites.js +10 -5
  12. package/dist/plus/git-github/api/issueWrites.js.map +1 -1
  13. package/dist/plus/git-github/models.js +7 -3
  14. package/dist/plus/git-github/models.js.map +1 -1
  15. package/dist/plus/integrations/index.d.ts +2 -2
  16. package/dist/plus/integrations/index.js.map +1 -1
  17. package/dist/plus/integrations/integrationService.d.ts +2 -1
  18. package/dist/plus/integrations/integrationService.js +14 -0
  19. package/dist/plus/integrations/integrationService.js.map +1 -1
  20. package/dist/plus/integrations/manager.d.ts +9 -1
  21. package/dist/plus/integrations/providers/azure/azure.js +20 -14
  22. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  23. package/dist/plus/integrations/providers/azure/models.js +7 -3
  24. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  25. package/dist/plus/integrations/providers/bitbucket/bitbucket.js +18 -13
  26. package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
  27. package/dist/plus/integrations/providers/bitbucket/models.js +5 -2
  28. package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
  29. package/dist/plus/integrations/providers/bitbucket-server/models.js +3 -1
  30. package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
  31. package/dist/plus/integrations/providers/github.d.ts +2 -4
  32. package/dist/plus/integrations/providers/github.js.map +1 -1
  33. package/dist/plus/integrations/providers/gitlab/gitlab.js +12 -6
  34. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  35. package/dist/plus/integrations/providers/gitlab/models.js +5 -2
  36. package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
  37. package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
  38. package/dist/plus/integrations/providers/jiraIssueByKey.js +3 -1
  39. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  40. package/dist/plus/integrations/providers/models.js +9 -4
  41. package/dist/plus/integrations/providers/models.js.map +1 -1
  42. package/dist/plus/integrations/providers/providerApiClient.js +10 -7
  43. package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
  44. package/dist/plus/integrations/providers/providersApi.js +3 -1
  45. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  46. package/dist/plus/integrations/reads/drains.d.ts +0 -1
  47. package/docs/integrations.md +15 -9
  48. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","names":["Issue","GitPullRequestState","GitPullRequestMergeableState","GitPullRequestReviewState"],"sources":["../../../../../../plus/integrations/src/providers/azure/models.ts"],"sourcesContent":["import type { AzureWorkItemHtmlField } from '@gitkraken/provider-apis';\nimport { getAzureWorkItemDescription } from '@gitkraken/provider-apis';\nimport type { IssueIteration, IssueMember, IssueProjection, IssueProviderState } from '@gitlens/git/models/issue.js';\nimport { Issue } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequestState } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequestMember, PullRequestProjection, PullRequestReviewer } from '@gitlens/git/models/pullRequest.js';\nimport {\n\tPullRequest,\n\tPullRequestMergeableState,\n\tPullRequestReviewDecision,\n\tPullRequestReviewState,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { isTerminalIssueStateCategory } from '@gitlens/git/utils/issue.utils.js';\nimport { trimTrailingSlashes } from '@gitlens/utils/path.js';\nimport type { IssueEtagFields, PullRequestEtagFields, PullRequestEtagInclude } from '../../models/integration.js';\nimport {\n\tazureWorkItemDescriptionRule,\n\tazureWorkItemViewerRule,\n\tpullRequestRevision,\n} from '../../models/integration.js';\nimport type { ProviderAccount, ProviderIssue } from '../models.js';\nimport {\n\tfromProviderPullRequestMergeableState,\n\tfromProviderPullRequestState,\n\tGitPullRequestMergeableState,\n\tGitPullRequestReviewState,\n\tGitPullRequestState,\n\ttoIssueBodyField,\n\ttoIssueViewer,\n} from '../models.js';\nimport type { ProviderPullRequestReview } from '../pullRequestReviews.js';\nimport {\n\tdecideProviderReviewDecision,\n\tfromPullRequestReviewDecision,\n\ttoCompletedReviews,\n\ttoReviewRequests,\n} from '../pullRequestReviews.js';\n\nexport const vstsHostnameSuffix = '.visualstudio.com';\n\nexport interface AzureRepositoryDescriptor extends ResourceDescriptor {\n\towner: string;\n\tname: string;\n\tproject?: string;\n\tvirtualDirectory?: string;\n}\n\nexport interface AzureOrganizationDescriptor extends ResourceDescriptor {\n\tid: string;\n\tname: string;\n}\n\nexport interface AzureProjectDescriptor extends ResourceDescriptor {\n\tid: string;\n\tname: string;\n\tresourceId: string;\n\tresourceName: string;\n}\n\nexport interface AzureRemoteRepositoryDescriptor extends ResourceDescriptor {\n\tid: string;\n\tnodeId?: string;\n\tresourceName: string;\n\tname: string;\n\tprojectName?: string;\n\turl?: string;\n\tcloneUrlHttps?: string;\n\tcloneUrlSsh?: string;\n}\n\nexport interface AzureProjectInputDescriptor extends ResourceDescriptor {\n\towner: string;\n\tname: string;\n}\n\nexport type AzureWorkItemStateCategory = 'Proposed' | 'InProgress' | 'Resolved' | 'Completed' | 'Removed';\n\n/**\n * The workflow category of an Azure DevOps state category, as a work item type's states endpoint reports it:\n * `Removed` is abandoned work, so `CANCELED`, kept apart from the `DONE` of `Completed` and `Resolved`.\n * `undefined` for a category Azure doesn't document, which then neither opens nor closes the work item.\n */\nexport function azureIssueStateCategory(\n\tcategory: AzureWorkItemStateCategory | undefined,\n): IssueProviderState['category'] {\n\tswitch (category) {\n\t\tcase 'Removed':\n\t\t\treturn 'CANCELED';\n\t\tcase 'Completed':\n\t\tcase 'Resolved':\n\t\t\treturn 'DONE';\n\t\tcase 'InProgress':\n\t\t\treturn 'IN_PROGRESS';\n\t\tcase 'Proposed':\n\t\t\treturn 'TO_DO';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function isClosedAzureWorkItemStateCategory(category: AzureWorkItemStateCategory | undefined): boolean {\n\treturn isTerminalIssueStateCategory(azureIssueStateCategory(category));\n}\n\nexport function azureWorkItemsStateCategoryToState(\n\tcategory: AzureWorkItemStateCategory | undefined,\n\tclosedDate?: Date,\n): IssueOrPullRequestState | undefined {\n\tif (azureIssueStateCategory(category) != null) {\n\t\treturn isClosedAzureWorkItemStateCategory(category) ? 'closed' : 'opened';\n\t}\n\n\treturn closedDate != null ? 'closed' : undefined;\n}\n\nexport interface AzureLink {\n\thref: string;\n}\n\nexport interface AzureUser {\n\tdisplayName: string;\n\turl: string;\n\t_links: {\n\t\tavatar: AzureLink;\n\t};\n\tid: string;\n\tuniqueName: string;\n\timageUrl: string;\n\tdescriptor?: string;\n}\n\nexport interface AzureUserWithVote extends AzureUser {\n\tisFlagged?: boolean;\n\thasDeclined?: boolean;\n\tisReapprove?: boolean;\n\tisRequired?: boolean;\n\tvote?: AzurePullRequestVote;\n}\n\nexport type AzurePullRequestVote =\n\t| 10 // approved\n\t| 5 // approved with suggestions\n\t| 0 // no vote\n\t| -5 // waiting for author\n\t| -10; // rejected\n\nexport interface AzureWorkItemCommentVersionRef {\n\tcommentId: number;\n\tcreatedInRevision: number;\n\tisDeleted: boolean;\n\ttext: string;\n\turl: string;\n\tversion: number;\n}\n\nexport interface AzureWorkItemRelation {\n\tattributes: {\n\t\t[key: string]: string;\n\t};\n\trelation: string;\n\turl: string;\n}\n\nexport interface WorkItem {\n\t_links: {\n\t\tfields: AzureLink;\n\t\thtml: AzureLink;\n\t\tself: AzureLink;\n\t\tworkItemComments: AzureLink;\n\t\tworkItemRevisions: AzureLink;\n\t\tworkItemType: AzureLink;\n\t\tworkItemUpdates: AzureLink;\n\t};\n\tfields: {\n\t\t//'System.AreaPath': string;\n\t\t'System.TeamProject': string;\n\t\t'System.IterationPath'?: string;\n\t\t'System.WorkItemType': string;\n\t\t'System.State': string;\n\t\t// 'System.Reason': string;\n\t\t'System.AssignedTo': AzureUser | string;\n\t\t'System.CreatedDate': string;\n\t\t'System.CreatedBy': AzureUser | string;\n\t\t'System.ChangedDate': string;\n\t\t'System.ChangedBy': AzureUser;\n\t\t'System.CommentCount': number;\n\t\t'System.Description': string;\n\t\t'System.Title': string;\n\t\t'Microsoft.VSTS.Common.ClosedDate': string;\n\t\t// 'Microsoft.VSTS.Common.StateChangeDate': string;\n\t\t// 'Microsoft.VSTS.Common.Priority': number;\n\t\t// 'Microsoft.VSTS.Common.Severity': string;\n\t\t// 'Microsoft.VSTS.Common.ValueArea': string;\n\t};\n\tid: number;\n\trev: number;\n\turl: string;\n\tcommentVersionRef?: AzureWorkItemCommentVersionRef;\n\trelations?: AzureWorkItemRelation[];\n}\n\nexport interface AzureWorkItemState {\n\tname: string;\n\tcolor: string;\n\tcategory: AzureWorkItemStateCategory;\n}\n\nexport type AzurePullRequestStatus = 'abandoned' | 'active' | 'completed' | 'notSet';\nexport function azurePullRequestStatusToState(status: AzurePullRequestStatus): IssueOrPullRequestState {\n\tswitch (status) {\n\t\tcase 'abandoned':\n\t\t\treturn 'closed';\n\t\tcase 'completed':\n\t\t\treturn 'merged';\n\t\tcase 'active':\n\t\tcase 'notSet':\n\t\tdefault:\n\t\t\treturn 'opened';\n\t}\n}\nexport function isClosedAzurePullRequestStatus(status: AzurePullRequestStatus): boolean {\n\treturn azurePullRequestStatusToState(status) !== 'opened';\n}\n\nexport type AzureProjectState = 'createPending' | 'deleted' | 'deleting' | 'new' | 'unchanged' | 'wellFormed';\nexport type AzureProjectVisibility = 'private' | 'public';\n\nexport interface AzureProject {\n\tid: string;\n\tname: string;\n\turl: string;\n\tstate: AzureProjectState;\n\trevision: number;\n\tvisibility: AzureProjectVisibility;\n\tlastUpdateTime: string;\n}\n\nexport interface AzureRepositoryReference {\n\tid: string;\n\tname: string;\n\turl: string;\n\tremoteUrl?: string;\n}\n\nexport interface AzureRepository extends AzureRepositoryReference {\n\tproject: AzureProject;\n\tsize: number;\n\tremoteUrl: string;\n\tsshUrl: string;\n\twebUrl: string;\n\tisDisabled: boolean;\n\tisInMaintenance: boolean;\n}\n\nexport interface AzurePullRequestRepository extends AzureRepositoryReference {\n\tproject: Pick<AzureProject, 'id' | 'name'>;\n}\n\n/** The URL fields of a repository response — all the fork lookup reads, and all an older `api-version` promises. */\nexport type AzureRepositoryUrls = Partial<Pick<AzureRepository, 'webUrl' | 'remoteUrl'>>;\n\n/** The `GET .../_apis/git/repositories/{repositoryId or name}` response, adding fork/default-branch fields to {@link AzureRepository}. */\nexport interface AzureRepositoryWithMetadata extends AzureRepository {\n\t/** Fully-qualified ref, e.g. `refs/heads/main`. */\n\tdefaultBranch?: string;\n\tisFork?: boolean;\n\tparentRepository?: {\n\t\tid: string;\n\t\tname?: string;\n\t\tproject?: { id: string; name: string };\n\t};\n}\n\nexport interface AzureGitUser {\n\tdate?: string;\n\temail?: string;\n\timageUrl?: string;\n\tname: string;\n}\n\nexport interface AzureGitCommitRef {\n\tcommitId: string;\n\turl: string;\n}\n\nexport interface AzureGitCommit {\n\t_links: {\n\t\tchanges: AzureLink;\n\t\trepository: AzureLink;\n\t\tself: AzureLink;\n\t\tweb: AzureLink;\n\t};\n\tauthor: AzureGitUser;\n\tcomment: string;\n\tcommentTruncated?: boolean;\n\tcommitId: string;\n\tcommitTooManyChanges?: boolean;\n\tcommitter: AzureGitUser;\n\tparents: string[];\n\tpush: {\n\t\tdate: string;\n\t\tpushedBy: AzureUser;\n\t\tpushId: number;\n\t};\n\tremoteUrl: string;\n\tstatuses?: AzureGitStatus[];\n\ttreeId: string;\n\turl: string;\n\tworkItems?: AzureResourceRef[];\n}\n\nexport interface AzureResourceRef {\n\tid: string;\n\turl: string;\n}\n\nexport interface AzurePullRequestCompletionOptions {\n\tautoCompleteIgnoreConflicts: number[];\n\tbypassPolicy: boolean;\n\tbypassReason: string;\n\tdeleteSourceBranch: boolean;\n\tmergeCommitMessage: string;\n\tmergeStrategy: 'noFastForward' | 'rebase' | 'rebaseMerge' | 'squash';\n\tsquashMerge: boolean;\n\ttransitionWorkItems: boolean;\n\ttriggeredByAutoComplete: boolean;\n}\n\nexport interface AzureGitStatus {\n\tcontext: {\n\t\tname: string;\n\t\tgenre: string;\n\t};\n\tcreatedBy: AzureUser;\n\tcreateDate: string;\n\tdescription: string;\n\tstate: 'error' | 'failed' | 'notApplicable' | 'notSet' | 'pending' | 'succeeded';\n\ttargetUrl: string;\n\tupdateDate: string;\n}\n\nexport interface AzureGitForkRef {\n\tcreator: AzureUser;\n\tisLocked: boolean;\n\tisLockedBy: AzureUser;\n\tname: string;\n\tobjectId: string;\n\tpeeledObjectId: string;\n\trepository: AzureRepositoryReference;\n\tstatuses: AzureGitStatus[];\n\turl: string;\n}\n\nexport interface AzureWebApiTagDefinition {\n\tactive: boolean;\n\tid: string;\n\tname: string;\n\turl: string;\n}\n\nexport interface AzureGitPullRequestMergeOptions {\n\tconflictAuthorshipCommits: boolean;\n\tdetectRenameFalsePositives: boolean;\n\tdisableRenames: boolean;\n}\n\nexport type AzurePullRequestAsyncStatus =\n\t| 'conflicts'\n\t| 'failure'\n\t| 'notSet'\n\t| 'queued'\n\t| 'rejectedByPolicy'\n\t| 'succeeded';\n\nexport interface AzurePullRequest {\n\trepository: AzurePullRequestRepository;\n\tpullRequestId: number;\n\tcodeReviewId: number;\n\tstatus: AzurePullRequestStatus;\n\tcreatedBy: AzureUser;\n\tcreationDate: string;\n\tclosedDate?: string;\n\tclosedBy?: AzureUser; // Can be missed even if closedDate is presented.\n\ttitle: string;\n\tdescription: string;\n\tforkSource?: AzureGitForkRef;\n\tsourceRefName: string;\n\ttargetRefName: string;\n\tisDraft: boolean;\n\tmergeId: string;\n\tmergeStatus?: AzurePullRequestAsyncStatus;\n\tlastMergeCommit?: AzureGitCommitRef;\n\tlastMergeSourceCommit: AzureGitCommitRef;\n\tlastMergeTargetCommit: AzureGitCommitRef;\n\treviewers: AzureUserWithVote[];\n\turl: string;\n\tsupportsIterations: boolean;\n}\n\nexport interface AzurePullRequestWithLinks extends AzurePullRequest {\n\t_links: {\n\t\tself: AzureLink;\n\t\trepository: AzureLink;\n\t\tworkItems: AzureLink;\n\t\tsourceBranch: AzureLink;\n\t\ttargetBranch: AzureLink;\n\t\tstatuses: AzureLink;\n\t\tsourceCommit: AzureLink;\n\t\ttargetCommit: AzureLink;\n\t\tcreatedBy: AzureLink;\n\t\titerations: AzureLink;\n\t};\n\tartifactId: string;\n\tautoCompleteSetBy?: AzureUser;\n\tcommits?: AzureGitCommitRef[];\n\tcompletionOptions?: AzurePullRequestCompletionOptions;\n\tcompletionQueueTime?: string;\n\thasMultipleMergeBases?: boolean;\n\tlabels?: AzureWebApiTagDefinition[];\n\tmergeFailureMessage?: string;\n\tmergeFailureType?: 'caseSensitive' | 'none' | 'objectTooLarge' | 'unknown';\n\tmergeOptions?: AzureGitPullRequestMergeOptions;\n\tremoteUrl?: string;\n\tworkItemRefs?: AzureResourceRef[];\n}\n\nexport function getAzureDevOpsOwner(url: URL): string {\n\treturn url.pathname.split('/')[1];\n}\nexport function isVsts(domain: string): boolean {\n\treturn domain.toLowerCase().endsWith(vstsHostnameSuffix);\n}\n\n/**\n * Encodes one route segment of an Azure DevOps request (#5878): `encodeURIComponent` leaves a dot segment as is, and\n * the URL would resolve it away, re-scoping the request instead of failing it.\n */\nexport function encodeAzurePathSegment(value: string): string {\n\tif (value === '.' || value === '..') throw new Error(`Invalid Azure path segment '${value}'.`);\n\n\treturn encodeURIComponent(value);\n}\n\n/**\n * `baseUrl` and `owner` are the authoritative prefix used for the API request. The payload URL cannot supply that\n * prefix safely because it may address the repository by id or name an untrusted host.\n */\nfunction getAzureRepositoryWebUrl(baseUrl: string, owner: string, projectName: string, repoName: string): string {\n\tconst repoPath = `${encodeURIComponent(owner)}/${encodeURIComponent(projectName)}/_git/${encodeURIComponent(repoName)}`;\n\treturn `${trimTrailingSlashes(baseUrl)}/${repoPath}`;\n}\n\nexport function getAzurePullRequestWebUrl(pr: AzurePullRequest, baseUrl: string, owner: string): string {\n\tconst repoUrl = getAzureRepositoryWebUrl(baseUrl, owner, pr.repository.project.name, pr.repository.name);\n\treturn `${repoUrl}/pullrequest/${pr.pullRequestId}`;\n}\n\n/**\n * Whether `url` and `expected` are the two cloud spellings of one organization: a cloud organization answers on both\n * `dev.azure.com/{owner}` and the legacy `{owner}.visualstudio.com`, so those name the same host. Anything else is\n * somewhere we didn't ask.\n */\nfunction isSameAzureCloudOrganization(url: URL, expected: URL, expectedOwner: string): boolean {\n\tif (url.protocol !== expected.protocol) return false;\n\n\tconst owner = expectedOwner.toLowerCase();\n\tif (expected.hostname !== 'dev.azure.com' && !isVsts(expected.hostname)) return false;\n\n\tif (url.hostname === 'dev.azure.com') return getAzureDevOpsOwner(url).toLowerCase() === owner;\n\n\treturn url.hostname === `${owner}${vstsHostnameSuffix}`;\n}\n\n/**\n * Whether `url` sits under the collection the integration is configured to talk to — `{expectedUrl}/{expectedOwner}`.\n * A matching origin says nothing on its own: Azure organizations and self-hosted collections are path segments.\n */\nfunction isUnderAzureCollection(url: URL, expected: URL, expectedOwner: string): boolean {\n\tconst base = trimTrailingSlashes(expected.pathname);\n\tconst prefix = `${base}/${encodeURIComponent(expectedOwner)}/`.toLowerCase();\n\treturn `${url.pathname}/`.toLowerCase().startsWith(prefix);\n}\n\n/**\n * Restricts a provider-supplied repository URL to the integration's collection and removes credentials, query, and\n * fragment before a consumer can use it as a git remote. Takes the value as the payloads carry it — every one of\n * these URLs is optional — so a caller never has to spell the absent case itself.\n */\nexport function sanitizeAzureRepositoryUrl(\n\tvalue: string | undefined,\n\texpectedUrl: string,\n\texpectedOwner: string,\n): string | undefined {\n\tif (value == null) return undefined;\n\n\tlet expected: URL;\n\tlet url: URL;\n\ttry {\n\t\texpected = new URL(expectedUrl);\n\t\turl = new URL(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n\n\tif (expected.protocol !== 'https:' && expected.protocol !== 'http:') return undefined;\n\tif (!expectedOwner) return undefined;\n\n\tif (url.origin === expected.origin) {\n\t\tif (!isUnderAzureCollection(url, expected, expectedOwner)) return undefined;\n\t} else if (!isSameAzureCloudOrganization(url, expected, expectedOwner)) {\n\t\treturn undefined;\n\t}\n\n\turl.username = '';\n\turl.password = '';\n\turl.search = '';\n\turl.hash = '';\n\treturn url.toString();\n}\n\n/**\n * The clone URL the payload carries for a repository, restricted to the integration's collection and then\n * cross-checked against the repository that payload names.\n *\n * The collection check alone is not enough for a URL that is READ rather than built. Every other repository URL the\n * model reports is built from the authoritative prefix, so the payload cannot move it; this one cannot be built,\n * because Azure spells a repository for git the same way it spells it for the web only by convention. A URL under\n * the right collection may still name a DIFFERENT repository in it, which would leave `cloneHttps` describing one\n * repository while `url` describes another.\n *\n * Azure ends a clone URL with `_git/{repo}` on every host style — including the short `{owner}/_git/{repo}` form it\n * uses when a repository carries its project's name, and the legacy `{owner}.visualstudio.com` spelling that has no\n * organization segment at all — so the repository name is the one part comparable across all of them. A same-named\n * repository in another project of the same organization is the single substitution this cannot catch.\n */\nfunction getAzureRepositoryCloneUrl(\n\trepository: AzureRepositoryReference,\n\tbaseUrl: string,\n\towner: string,\n): string | undefined {\n\tconst sanitized = sanitizeAzureRepositoryUrl(repository.remoteUrl, baseUrl, owner);\n\tif (sanitized == null) return undefined;\n\n\t// Safe to parse: `sanitizeAzureRepositoryUrl` returns what it already parsed.\n\tconst segments = new URL(sanitized).pathname.split('/').filter(s => s.length > 0);\n\tconst name = segments.pop();\n\tif (name == null || segments.pop() !== '_git') return undefined;\n\n\tlet decoded: string;\n\ttry {\n\t\tdecoded = decodeURIComponent(name);\n\t} catch {\n\t\treturn undefined;\n\t}\n\n\t// Azure resolves project and repository names case-insensitively, so comparing them any other way would refuse a\n\t// URL the provider considers the same one.\n\treturn decoded.toLowerCase() === repository.name.toLowerCase() ? sanitized : undefined;\n}\n\nexport function fromAzurePullRequestMergeStatusToMergeableState(\n\tmergeStatus: AzurePullRequestAsyncStatus,\n): PullRequestMergeableState {\n\tswitch (mergeStatus) {\n\t\tcase 'conflicts':\n\t\t\treturn PullRequestMergeableState.Conflicting;\n\t\tcase 'failure':\n\t\t\treturn PullRequestMergeableState.FailingChecks;\n\t\tcase 'rejectedByPolicy':\n\t\t\treturn PullRequestMergeableState.BlockedByPolicy;\n\t\tcase 'succeeded':\n\t\t\treturn PullRequestMergeableState.Mergeable;\n\t\tcase 'notSet':\n\t\tcase 'queued':\n\t\tdefault:\n\t\t\treturn PullRequestMergeableState.Unknown;\n\t}\n}\n\nexport function fromAzurePullRequestVoteToReviewState(vote: AzurePullRequestVote): PullRequestReviewState {\n\tswitch (vote) {\n\t\tcase 10:\n\t\tcase 5:\n\t\t\treturn PullRequestReviewState.Approved;\n\t\tcase 0:\n\t\t\treturn PullRequestReviewState.ReviewRequested;\n\t\tcase -5:\n\t\tcase -10:\n\t\t\treturn PullRequestReviewState.ChangesRequested;\n\t\tdefault:\n\t\t\treturn PullRequestReviewState.ReviewRequested;\n\t}\n}\n\nexport function fromAzureUserWithVoteToReviewer(reviewer: AzureUserWithVote): PullRequestReviewer {\n\treturn {\n\t\tisCodeOwner: undefined,\n\t\treviewer: {\n\t\t\tavatarUrl: reviewer.imageUrl,\n\t\t\tid: reviewer.id,\n\t\t\tname: reviewer.displayName,\n\t\t\tusername: reviewer.uniqueName,\n\t\t\turl: reviewer.url,\n\t\t},\n\t\tstate: fromAzurePullRequestVoteToReviewState(reviewer.vote ?? 0),\n\t};\n}\n\nexport function getAzurePullRequestReviewDecision(\n\tvotes: AzurePullRequestVote[],\n): PullRequestReviewDecision | undefined {\n\tconst reviewStates = votes.map(vote => fromAzurePullRequestVoteToReviewState(vote));\n\tif (reviewStates.includes(PullRequestReviewState.ChangesRequested)) {\n\t\treturn PullRequestReviewDecision.ChangesRequested;\n\t}\n\n\tif (reviewStates.includes(PullRequestReviewState.ReviewRequested)) {\n\t\treturn PullRequestReviewDecision.ReviewRequired;\n\t}\n\n\tif (reviewStates.includes(PullRequestReviewState.Approved)) {\n\t\treturn PullRequestReviewDecision.Approved;\n\t}\n\n\treturn undefined;\n}\n\nexport function fromAzureReviewerToPullRequestMember(reviewer: AzureUser): PullRequestMember {\n\treturn {\n\t\tavatarUrl: reviewer.imageUrl,\n\t\tid: reviewer.id,\n\t\tname: reviewer.displayName,\n\t\tusername: reviewer.uniqueName,\n\t\turl: reviewer.url,\n\t};\n}\n\nexport function normalizeAzureBranchName(branchName: string): string {\n\treturn branchName.startsWith('refs/heads/') ? branchName.replace('refs/heads/', '') : branchName;\n}\n\nfunction fromAzureUserToMember(user: AzureUser, type: 'issue'): IssueMember;\nfunction fromAzureUserToMember(user: AzureUser, type: 'pullRequest'): PullRequestMember;\nfunction fromAzureUserToMember(user: AzureUser, _type: 'issue' | 'pullRequest'): PullRequestMember | IssueMember {\n\treturn {\n\t\tavatarUrl: user.imageUrl,\n\t\tid: user.id,\n\t\tname: user.displayName,\n\t\tusername: user.uniqueName,\n\t\turl: user.url,\n\t};\n}\n\n/**\n * The URLs of a cross-repository pull request's fork, resolved by a lookup because the pull request payload embeds\n * only an abbreviated reference to it: `url` is the URL the head ref reports — the fork's web URL, or its clone URL\n * when the response carries no web URL — and `cloneHttps` its HTTPS clone URL.\n *\n * A fork that resolves neither is reported as no fork at all rather than as an object with nothing in it, so `url`\n * is always present here; `cloneHttps` alone is best-effort, and is absent when the response omits it or its URL\n * sits outside the integration's collection.\n */\nexport interface AzureForkRepositoryUrls {\n\turl: string;\n\tcloneHttps: string | undefined;\n}\n\n/**\n * `baseUrl` and `owner` are the prefix the pull request was read through; every URL the model reports is built from\n * them. The required `forkRepositoryUrls` argument makes each call site resolve the best-effort fork URLs explicitly.\n */\nexport function fromAzurePullRequest(\n\tpr: AzurePullRequest,\n\tprovider: Provider,\n\towner: string,\n\tbaseUrl: string,\n\tforkRepositoryUrls: AzureForkRepositoryUrls | undefined,\n\tprojection?: PullRequestProjection,\n): PullRequest {\n\tconst baseRepositoryUrl = getAzureRepositoryWebUrl(baseUrl, owner, pr.repository.project.name, pr.repository.name);\n\tconst baseCloneHttps = getAzureRepositoryCloneUrl(pr.repository, baseUrl, owner);\n\n\tconst forkRepository = pr.forkSource?.repository;\n\tconst headRepositoryUrl = forkRepository == null ? baseRepositoryUrl : forkRepositoryUrls?.url;\n\tconst headCloneHttps = forkRepository == null ? baseCloneHttps : forkRepositoryUrls?.cloneHttps;\n\n\treturn new PullRequest(\n\t\tprovider,\n\t\tfromAzureUserToMember(pr.createdBy, 'pullRequest'),\n\t\tpr.pullRequestId.toString(),\n\t\tpr.pullRequestId.toString(),\n\t\tpr.title,\n\t\tgetAzurePullRequestWebUrl(pr, baseUrl, owner),\n\t\t{\n\t\t\towner: owner,\n\t\t\trepo: pr.repository.name,\n\t\t\tid: pr.repository.id,\n\t\t},\n\t\tazurePullRequestStatusToState(pr.status),\n\t\tnew Date(pr.creationDate),\n\t\tnew Date(pr.closedDate || pr.creationDate),\n\t\tpr.closedDate ? new Date(pr.closedDate) : undefined,\n\t\tpr.closedDate && pr.status === 'completed' ? new Date(pr.closedDate) : undefined,\n\t\t// The read selects the merge status, so an absent one is Azure's own \"not set\", as provider-apis maps it.\n\t\tfromAzurePullRequestMergeStatusToMergeableState(pr.mergeStatus ?? 'notSet'),\n\t\tundefined,\n\t\t{\n\t\t\tbase: {\n\t\t\t\tbranch: pr.targetRefName ? normalizeAzureBranchName(pr.targetRefName) : '',\n\t\t\t\tsha: pr.lastMergeTargetCommit?.commitId ?? '',\n\t\t\t\trepo: pr.repository.name,\n\t\t\t\towner: owner,\n\t\t\t\texists: pr.targetRefName != null,\n\t\t\t\turl: baseRepositoryUrl,\n\t\t\t\tcloneHttps: baseCloneHttps,\n\t\t\t},\n\t\t\thead: {\n\t\t\t\tbranch: pr.sourceRefName ? normalizeAzureBranchName(pr.sourceRefName) : '',\n\t\t\t\tsha: pr.lastMergeSourceCommit?.commitId ?? '',\n\t\t\t\trepo: forkRepository?.name ?? pr.repository.name,\n\t\t\t\towner: owner,\n\t\t\t\texists: pr.sourceRefName != null,\n\t\t\t\turl: headRepositoryUrl,\n\t\t\t\tcloneHttps: headCloneHttps,\n\t\t\t},\n\t\t\tisCrossRepository: pr.forkSource != null,\n\t\t},\n\t\tpr.isDraft,\n\t\tundefined,\n\t\tundefined,\n\t\tundefined,\n\t\tundefined,\n\t\tgetAzurePullRequestReviewDecision(pr.reviewers?.filter(r => r.isRequired).map(r => r.vote ?? 0) ?? []),\n\t\tpr.reviewers.filter(r => r.vote == null || r.vote === 0).map(r => fromAzureUserWithVoteToReviewer(r)),\n\t\tpr.reviewers.filter(r => r.vote != null && r.vote !== 0).map(r => fromAzureUserWithVoteToReviewer(r)),\n\t\tpr.reviewers.map(r => fromAzureReviewerToPullRequestMember(r)),\n\t\tundefined,\n\t\t{\n\t\t\tid: pr.repository?.project?.id,\n\t\t\tname: pr.repository.project.name,\n\t\t\tresourceId: '', // TODO: This is a workaround until we can get the org id here.\n\t\t\tresourceName: owner,\n\t\t},\n\t\tundefined, // version\n\t\tundefined, // commitCount\n\t\tundefined, // stack\n\t\tundefined, // filesChanged\n\t\tundefined, // body\n\t\tundefined, // number\n\t\tundefined, // authoredByMe\n\t\tprojection,\n\t);\n}\n\nfunction fromAzureWorkItemUserToMember(user: AzureUser | string | undefined): IssueMember | undefined {\n\tif (user == null || (typeof user === 'string' && !user.trim())) return undefined;\n\n\treturn typeof user === 'string' ? { id: user, name: user, username: user } : fromAzureUserToMember(user, 'issue');\n}\n\nexport function fromAzureWorkItem(\n\tworkItem: WorkItem,\n\tprovider: Provider,\n\tproject: AzureProjectDescriptor,\n\tstateCategory?: AzureWorkItemStateCategory,\n\tprojection?: IssueProjection,\n\thtmlFields?: readonly AzureWorkItemHtmlField[],\n\t/** As `toIssueShape` takes it: `null` where the read couldn't resolve it. */\n\tviewer?: { id: string } | null,\n): Issue {\n\tconst state = workItem.fields['System.State'];\n\tconst description = getAzureWorkItemDescription(workItem.fields, htmlFields);\n\tconst closedDate = parseAzureWorkItemDate(workItem.fields['Microsoft.VSTS.Common.ClosedDate']) ?? undefined;\n\tconst normalizedState = azureWorkItemsStateCategoryToState(stateCategory, closedDate);\n\tconst author = fromAzureWorkItemUserToMember(workItem.fields['System.CreatedBy']);\n\tconst assignee = fromAzureWorkItemUserToMember(workItem.fields['System.AssignedTo']);\n\tconst assignees = assignee != null ? [assignee] : [];\n\tconst viewerFields = toIssueViewer({ author: author, assignees: assignees }, viewer);\n\treturn new Issue(\n\t\tprovider,\n\t\tworkItem.id.toString(),\n\t\tworkItem.id.toString(),\n\t\tworkItem.fields['System.Title'],\n\t\tworkItem._links.html.href,\n\t\tnew Date(workItem.fields['System.CreatedDate']),\n\t\tnew Date(workItem.fields['System.ChangedDate']),\n\t\tnormalizedState === 'closed',\n\t\tnormalizedState,\n\t\tauthor,\n\t\tassignees,\n\t\tundefined,\n\t\tclosedDate,\n\t\tundefined,\n\t\tworkItem.fields['System.CommentCount'],\n\t\tundefined,\n\t\tdescription?.value,\n\t\tproject,\n\t\tundefined,\n\t\tworkItem.fields['System.WorkItemType'],\n\t\ttypeof state === 'string' && state\n\t\t\t? { name: state, category: azureIssueStateCategory(stateCategory) }\n\t\t\t: undefined,\n\t\tundefined,\n\t\ttoWorkItemIterations(workItem.fields['System.IterationPath']),\n\t\tprojection,\n\t\tdescription != null ? toIssueBodyField(description.field) : undefined,\n\t\tviewerFields?.viewer,\n\t\tviewerFields?.viewerUnresolved,\n\t);\n}\n\n/**\n * Azure reports the iteration as a backslash-delimited path rooted at the project. The project root is its default\n * for a work item with no sprint, so only a nested path names one; the path is the identity because Azure supplies\n * no iteration id here.\n *\n * Mirrors `normalizeIteration` in provider-apis so the same work item yields the same identity whether it is read\n * here or through the SDK. That contract keeps the path **verbatim** — it is what the iteration is matched back by,\n * so it is deliberately not trimmed — and trims only the display name.\n */\nfunction toWorkItemIterations(path: string | undefined): IssueIteration[] | undefined {\n\tif (!path) return undefined;\n\n\tconst segments = path.split('\\\\');\n\tif (segments.length < 2) return undefined;\n\n\tconst name = segments.at(-1)?.trim();\n\treturn name ? [{ id: path, name: name }] : undefined;\n}\n\n/**\n * A work item as `GET …/_apis/wit/workitems/{id}?$expand=Links` returns it. Loosely typed because\n * {@link fromAzureWorkItemToProviderIssue} checks every field it reads, as provider-apis does.\n */\nexport interface AzureWorkItemResponse {\n\tid?: unknown;\n\tfields?: Record<string, unknown>;\n\t_links?: { html?: { href?: unknown } };\n}\n\n/**\n * A cheap read's work item with the workflow category its state classifies to (see\n * {@link toAzureWorkItemEtagFields}). Beside the work item rather than on it, so the wire type stays what Azure sends.\n */\nexport interface AzureWorkItemEtagRead {\n\treadonly workItem: AzureWorkItemResponse;\n\treadonly category: IssueProviderState['category'];\n}\n\n/**\n * Converts a work item as provider-apis' `getIssuesForAzureProject` converts each row it reads, so a work item read\n * by id reaches `toIssueShape` identical to the list read's row for it. provider-apis exports neither that converter\n * nor a single work item read, so this mirrors it field for field; the batch issue tests compare the two, so a\n * provider-apis change that this misses fails there.\n *\n * `undefined` for a work item the SDK would skip: no positive integer id, no title, or no valid created date.\n * `state.name` is the raw `System.State`, as on every list read here, which passes the SDK no state-name map. Like\n * the SDK's row, the state carries no workflow category: `ProvidersApi` classifies both reads' rows the same way\n * afterwards, from the work item type's states.\n */\nexport function fromAzureWorkItemToProviderIssue(\n\tworkItem: AzureWorkItemResponse,\n\tnamespace: string,\n\tproject: string,\n\thtmlFields?: readonly AzureWorkItemHtmlField[],\n): ProviderIssue | undefined {\n\tconst fields = workItem.fields;\n\tconst id = workItem.id;\n\tconst title = fields?.['System.Title'];\n\tconst createdDate = parseAzureWorkItemDate(fields?.['System.CreatedDate']);\n\tif (\n\t\tfields == null ||\n\t\ttypeof id !== 'number' ||\n\t\t!Number.isSafeInteger(id) ||\n\t\tid <= 0 ||\n\t\ttypeof title !== 'string' ||\n\t\t!title.trim() ||\n\t\tcreatedDate == null\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst assignee = fromAzureWorkItemIdentity(fields['System.AssignedTo']);\n\tconst commentCount = fields['System.CommentCount'];\n\tconst url = workItem._links?.html?.href;\n\tconst tags = fields['System.Tags'];\n\tconst state = fields['System.State'];\n\tconst type = fields['System.WorkItemType'];\n\treturn {\n\t\tid: id.toString(),\n\t\tnumber: id.toString(),\n\t\ttitle: title,\n\t\tcommentCount: typeof commentCount === 'number' && Number.isFinite(commentCount) ? commentCount : null,\n\t\tauthor: fromAzureWorkItemIdentity(fields['System.CreatedBy']),\n\t\tclosedDate: parseAzureWorkItemDate(fields['Microsoft.VSTS.Common.ClosedDate']),\n\t\tcreatedDate: createdDate,\n\t\tupdatedDate: parseAzureWorkItemDate(fields['System.ChangedDate']),\n\t\turl: typeof url === 'string' ? url : null,\n\t\tassignees: assignee != null ? [assignee] : [],\n\t\t...toAzureWorkItemDescriptionFields(fields, htmlFields),\n\t\tstate: typeof state === 'string' && state ? { name: state, color: null } : null,\n\t\ttype: typeof type === 'string' ? type : null,\n\t\titeration: toAzureWorkItemIteration(fields['System.IterationPath']),\n\t\trepository: null,\n\t\tproject: { namespace: namespace, name: project, resourceId: null, key: null, id: null },\n\t\t// provider-apis fills 0, but work items have no reactions.\n\t\tupvoteCount: null,\n\t\tlabels: (typeof tags === 'string' ? tags.split(';') : []).map(tag => ({\n\t\t\tcolor: null,\n\t\t\tdescription: null,\n\t\t\tid: null,\n\t\t\tname: tag.trim(),\n\t\t})),\n\t};\n}\n\nexport function toAzureWorkItemDescriptionFields(\n\tfields: Readonly<Record<string, unknown>> | null | undefined,\n\thtmlFields?: readonly AzureWorkItemHtmlField[],\n): Pick<ProviderIssue, 'description' | 'descriptionField'> {\n\tconst description = getAzureWorkItemDescription(fields, htmlFields);\n\treturn {\n\t\tdescription: description?.value ?? null,\n\t\t...(description != null ? { descriptionField: description.field } : {}),\n\t};\n}\n\n/** An identity field, as provider-apis maps it: `name` from `uniqueName`, `username` from `displayName`. */\nfunction fromAzureWorkItemIdentity(value: unknown): ProviderAccount | null {\n\tif (typeof value === 'string') {\n\t\tif (!value.trim()) return null;\n\n\t\treturn { id: value, name: value, username: value, email: null, avatarUrl: null, url: null };\n\t}\n\n\tconst identity = value as\n\t\t| { id?: unknown; uniqueName?: unknown; displayName?: unknown; _links?: { avatar?: { href?: unknown } } }\n\t\t| null\n\t\t| undefined;\n\tif (typeof identity?.id !== 'string' || !identity.id.trim()) return null;\n\n\tconst avatarUrl = identity._links?.avatar?.href;\n\treturn {\n\t\tavatarUrl: typeof avatarUrl === 'string' ? avatarUrl : null,\n\t\temail: null,\n\t\tid: identity.id,\n\t\tname: typeof identity.uniqueName === 'string' ? identity.uniqueName : null,\n\t\tusername: typeof identity.displayName === 'string' ? identity.displayName : null,\n\t\turl: null,\n\t};\n}\n\n/** Only a UTC ISO timestamp naming a real calendar date and time, as provider-apis accepts; anything else is `null`. */\nexport function parseAzureWorkItemDate(value: unknown): Date | null {\n\tif (typeof value !== 'string') return null;\n\n\tconst match = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.\\d{1,7})?Z$/.exec(value);\n\tif (match == null) return null;\n\n\tconst [year, month, day, hour, minute, second] = match.slice(1).map(Number);\n\tconst isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n\tconst daysInMonth = [31, isLeapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\tif (month < 1 || month > 12 || day < 1 || day > daysInMonth[month - 1] || hour > 23 || minute > 59 || second > 59) {\n\t\treturn null;\n\t}\n\n\tconst date = new Date(value);\n\treturn Number.isNaN(date.getTime()) ? null : date;\n}\n\n/** The SDK's `iteration`, by the same path rule as {@link toWorkItemIterations}. */\nfunction toAzureWorkItemIteration(path: unknown): ProviderIssue['iteration'] {\n\tconst [iteration] = toWorkItemIterations(typeof path === 'string' ? path : undefined) ?? [];\n\treturn iteration != null ? { path: iteration.id, name: iteration.name } : undefined;\n}\n\n/**\n * The most ids one cheap work item read asks for: the most Azure DevOps' work item list (`GET …/_apis/wit/workitems`)\n * takes.\n */\nexport const azureWorkItemsEtagFieldsMaxIds = 200;\n\n/**\n * The fields the cheap work item read selects: only the ones a full row's etag reads, and the project the full read\n * checks the work item against. The state and type let the cheap read resolve the same workflow category as the full\n * read, from the same work item type states.\n */\nexport const azureWorkItemEtagFieldNames: readonly string[] = [\n\t'System.TeamProject',\n\t'System.State',\n\t'System.WorkItemType',\n\t'System.ChangedDate',\n\t'Microsoft.VSTS.Common.ClosedDate',\n];\n\n/**\n * A cheap read's work item, as the fields its full batch row's etag reads: `toIssueShape` closes the row the full\n * read builds (see {@link fromAzureWorkItemToProviderIssue}) from its known workflow category, falling back to a\n * closed date only when the category is unavailable. A historical date must not close a reopened work item.\n * Throws where the full read fails the work item: on one in another project than `project` (compared as Azure\n * compares names), and on a missing or unparseable change date, so the target falls through to the full read.\n */\nexport function toAzureWorkItemEtagFields(\n\tworkItem: AzureWorkItemResponse,\n\tproject: string,\n\tcategory: IssueProviderState['category'],\n): IssueEtagFields {\n\tconst fields = workItem.fields;\n\tconst teamProject = fields?.['System.TeamProject'];\n\tif (typeof teamProject !== 'string' || !teamProject.trim()) {\n\t\tthrow new Error(`Azure DevOps work item ${String(workItem.id)} has no project`);\n\t}\n\n\tif (teamProject.toLowerCase() !== project.toLowerCase()) {\n\t\tthrow new Error(\n\t\t\t`Azure DevOps work item ${String(workItem.id)} is in project '${teamProject}', not '${project}'`,\n\t\t);\n\t}\n\n\tconst updatedDate = parseAzureWorkItemDate(fields?.['System.ChangedDate']);\n\tif (updatedDate == null) {\n\t\tthrow new Error(`Azure DevOps returned work item ${String(workItem.id)} without a change date`);\n\t}\n\n\tconst state =\n\t\tcategory != null\n\t\t\t? isTerminalIssueStateCategory(category)\n\t\t\t\t? 'closed'\n\t\t\t\t: 'opened'\n\t\t\t: parseAzureWorkItemDate(fields?.['Microsoft.VSTS.Common.ClosedDate']) != null\n\t\t\t\t? 'closed'\n\t\t\t\t: undefined;\n\treturn {\n\t\tstate: state,\n\t\tupdatedDate: updatedDate,\n\t\tdescriptionRule: azureWorkItemDescriptionRule,\n\t\tviewerRule: azureWorkItemViewerRule,\n\t};\n}\n\ntype ProviderPullRequestState = Parameters<typeof fromProviderPullRequestState>[0];\ntype ProviderMergeableState = keyof typeof fromProviderPullRequestMergeableState;\ntype ProviderReviewState = keyof typeof fromPullRequestReviewDecision;\n\n// The tables below mirror provider-apis' (0.61.0) Azure DevOps pull request mapping behind `getPullRequestForRepo` (`Xe`\n// and its helpers in the bundle), which it doesn't export. A full batch row takes these values on through\n// `fromProviderPullRequest`, so the cheap check composes the same steps to compute the same etag.\n\n/** provider-apis' pull request `status` map (`bi`). It has no `notSet`, which therefore maps to `undefined`. */\nconst azurePullRequestProviderStates: Partial<Record<string, ProviderPullRequestState>> = {\n\tactive: GitPullRequestState.Open,\n\tcompleted: GitPullRequestState.Merged,\n\tabandoned: GitPullRequestState.Closed,\n};\n\n/** provider-apis' `mergeStatus` map (`Ti`); any other status, or none, is unknown. */\nconst azureMergeStatusProviderStates: Partial<Record<string, ProviderMergeableState>> = {\n\tconflicts: GitPullRequestMergeableState.Conflicts,\n\tfailure: GitPullRequestMergeableState.FailingChecks,\n\trejectedByPolicy: GitPullRequestMergeableState.Blocked,\n\tsucceeded: GitPullRequestMergeableState.Mergeable,\n};\n\n/** provider-apis' reviewer `vote` map (`Di`); any other vote reads as review requested. */\nconst azureVoteProviderReviewStates: Partial<Record<number, ProviderReviewState>> = {\n\t10: GitPullRequestReviewState.Approved,\n\t5: GitPullRequestReviewState.Approved,\n\t0: GitPullRequestReviewState.ReviewRequested,\n\t[-5]: GitPullRequestReviewState.ChangesRequested,\n\t[-10]: GitPullRequestReviewState.ChangesRequested,\n};\n\n/** provider-apis' reviewer mapping (`ve`), with the state its vote maps to: every reviewer, required or optional. */\nfunction toAzureProviderReview(reviewer: AzureUserWithVote): ProviderPullRequestReview {\n\treturn {\n\t\treviewer: {\n\t\t\tid: reviewer.id,\n\t\t\tname: reviewer.displayName ?? null,\n\t\t\tusername: (reviewer.uniqueName || reviewer.displayName) ?? null,\n\t\t\temail: null,\n\t\t\tavatarUrl: reviewer.imageUrl ?? null,\n\t\t\turl: null,\n\t\t},\n\t\tstate: toAzureProviderReviewState(reviewer),\n\t};\n}\n\nfunction toAzureProviderReviewState(reviewer: AzureUserWithVote): ProviderReviewState {\n\treturn azureVoteProviderReviewStates[reviewer.vote ?? 0] ?? GitPullRequestReviewState.ReviewRequested;\n}\n\n/**\n * A cheap read's pull request (the same `GET …/pullrequests/{id}` provider-apis sends), as the fields its full batch\n * row's etag reads: provider-apis' mapping (see the tables above), then `fromProviderPullRequest`'s. Azure DevOps\n * reports no update time, so provider-apis' `updatedDate` is the close time, else the creation time, which is why\n * the fields Azure changes without one are fingerprinted into the `revision`, from the values the full row ends up\n * with: provider-apis' title, description (`?? null`, which the row reads `?? undefined`) and target branch, and its\n * reviews, split into requests and completed reviews by `fromProviderPullRequest`'s own helpers.\n *\n * Throws where provider-apis' mapping throws, on a field it reads without a guard, so a pull request the full read\n * fails on falls through to it rather than matching an etag. A full row never carries a check rollup (provider-apis\n * maps none for Azure DevOps), so the `checks` include always reads `undefined`, as there.\n */\nexport function toAzurePullRequestEtagFields(\n\tpr: AzurePullRequest,\n\tetagIncludes: readonly PullRequestEtagInclude[],\n): PullRequestEtagFields {\n\tif (\n\t\tpr.pullRequestId == null ||\n\t\tpr.createdBy == null ||\n\t\tpr.repository?.project == null ||\n\t\tpr.lastMergeSourceCommit == null ||\n\t\tpr.lastMergeTargetCommit == null ||\n\t\t!Array.isArray(pr.reviewers) ||\n\t\tpr.reviewers.some(r => r == null) ||\n\t\ttypeof pr.url !== 'string' ||\n\t\ttypeof pr.sourceRefName !== 'string' ||\n\t\ttypeof pr.targetRefName !== 'string'\n\t) {\n\t\tthrow new Error(`Azure DevOps returned pull request ${String(pr.pullRequestId)} without a field it maps`);\n\t}\n\n\tconst reviews = pr.reviewers.map(toAzureProviderReview);\n\tconst fields: PullRequestEtagFields = {\n\t\t// `notSet` passes `undefined` here, as its full row does.\n\t\tstate: fromProviderPullRequestState(azurePullRequestProviderStates[pr.status] as ProviderPullRequestState),\n\t\tisDraft: pr.isDraft,\n\t\tupdatedDate: new Date(pr.closedDate || pr.creationDate),\n\t\theadSha: pr.lastMergeSourceCommit.commitId ?? '',\n\t\trevision: pullRequestRevision({\n\t\t\ttitle: pr.title,\n\t\t\tbody: pr.description ?? undefined,\n\t\t\trefs: { base: { branch: normalizeAzureBranchName(pr.targetRefName) } },\n\t\t\treviewRequests: toReviewRequests(reviews),\n\t\t\tlatestReviews: toCompletedReviews(reviews),\n\t\t}),\n\t};\n\n\tif (etagIncludes.includes('mergeable')) {\n\t\tconst mergeable =\n\t\t\t(pr.mergeStatus != null ? azureMergeStatusProviderStates[pr.mergeStatus] : undefined) ??\n\t\t\tGitPullRequestMergeableState.Unknown;\n\t\tfields.mergeableState = fromProviderPullRequestMergeableState[mergeable];\n\t}\n\n\tif (etagIncludes.includes('reviewDecision')) {\n\t\t// Only the required reviewers decide.\n\t\tconst decision = decideProviderReviewDecision(\n\t\t\tpr.reviewers.filter(r => r.isRequired).map(toAzureProviderReviewState),\n\t\t);\n\t\tfields.reviewDecision = decision ? fromPullRequestReviewDecision[decision] : undefined;\n\t}\n\n\treturn fields;\n}\n"],"mappings":";;;;;;;;;AAwCA,MAAa,qBAAqB;;;;;;AA4ClC,SAAgB,wBACf,UACiC;CACjC,QAAQ,UAAR;EACC,KAAK,WACJ,OAAO;EACR,KAAK;EACL,KAAK,YACJ,O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E5C,MAAM,WAAW,6BAChB,GAAG,UAAU,QAAO,MAAK,EAAE,UAAU,CAAC,CAAC,IAAI,0BAA0B,CACtE;EACA,OAAO,iBAAiB,WAAW,8BAA8B,YAAY,KAAA;CAC9E;CAEA,OAAO;AACR"}
1
+ {"version":3,"file":"models.js","names":["Issue","GitPullRequestState","GitPullRequestMergeableState","GitPullRequestReviewState"],"sources":["../../../../../../plus/integrations/src/providers/azure/models.ts"],"sourcesContent":["import type { AzureWorkItemHtmlField } from '@gitkraken/provider-apis';\nimport { getAzureWorkItemDescription } from '@gitkraken/provider-apis';\nimport { copyReadProvenance } from '@gitkraken/provider-apis/read-provenance';\nimport type { IssueIteration, IssueMember, IssueProjection, IssueProviderState } from '@gitlens/git/models/issue.js';\nimport { Issue } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequestState } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequestMember, PullRequestProjection, PullRequestReviewer } from '@gitlens/git/models/pullRequest.js';\nimport {\n\tPullRequest,\n\tPullRequestMergeableState,\n\tPullRequestReviewDecision,\n\tPullRequestReviewState,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { isTerminalIssueStateCategory } from '@gitlens/git/utils/issue.utils.js';\nimport { trimTrailingSlashes } from '@gitlens/utils/path.js';\nimport type { IssueEtagFields, PullRequestEtagFields, PullRequestEtagInclude } from '../../models/integration.js';\nimport {\n\tazureWorkItemDescriptionRule,\n\tazureWorkItemViewerRule,\n\tpullRequestRevision,\n} from '../../models/integration.js';\nimport type { ProviderAccount, ProviderIssue } from '../models.js';\nimport {\n\tfromProviderPullRequestMergeableState,\n\tfromProviderPullRequestState,\n\tGitPullRequestMergeableState,\n\tGitPullRequestReviewState,\n\tGitPullRequestState,\n\ttoIssueBodyField,\n\ttoIssueViewer,\n} from '../models.js';\nimport type { ProviderPullRequestReview } from '../pullRequestReviews.js';\nimport {\n\tdecideProviderReviewDecision,\n\tfromPullRequestReviewDecision,\n\ttoCompletedReviews,\n\ttoReviewRequests,\n} from '../pullRequestReviews.js';\n\nexport const vstsHostnameSuffix = '.visualstudio.com';\n\nexport interface AzureRepositoryDescriptor extends ResourceDescriptor {\n\towner: string;\n\tname: string;\n\tproject?: string;\n\tvirtualDirectory?: string;\n}\n\nexport interface AzureOrganizationDescriptor extends ResourceDescriptor {\n\tid: string;\n\tname: string;\n}\n\nexport interface AzureProjectDescriptor extends ResourceDescriptor {\n\tid: string;\n\tname: string;\n\tresourceId: string;\n\tresourceName: string;\n}\n\nexport interface AzureRemoteRepositoryDescriptor extends ResourceDescriptor {\n\tid: string;\n\tnodeId?: string;\n\tresourceName: string;\n\tname: string;\n\tprojectName?: string;\n\turl?: string;\n\tcloneUrlHttps?: string;\n\tcloneUrlSsh?: string;\n}\n\nexport interface AzureProjectInputDescriptor extends ResourceDescriptor {\n\towner: string;\n\tname: string;\n}\n\nexport type AzureWorkItemStateCategory = 'Proposed' | 'InProgress' | 'Resolved' | 'Completed' | 'Removed';\n\n/**\n * The workflow category of an Azure DevOps state category, as a work item type's states endpoint reports it:\n * `Removed` is abandoned work, so `CANCELED`, kept apart from the `DONE` of `Completed` and `Resolved`.\n * `undefined` for a category Azure doesn't document, which then neither opens nor closes the work item.\n */\nexport function azureIssueStateCategory(\n\tcategory: AzureWorkItemStateCategory | undefined,\n): IssueProviderState['category'] {\n\tswitch (category) {\n\t\tcase 'Removed':\n\t\t\treturn 'CANCELED';\n\t\tcase 'Completed':\n\t\tcase 'Resolved':\n\t\t\treturn 'DONE';\n\t\tcase 'InProgress':\n\t\t\treturn 'IN_PROGRESS';\n\t\tcase 'Proposed':\n\t\t\treturn 'TO_DO';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function isClosedAzureWorkItemStateCategory(category: AzureWorkItemStateCategory | undefined): boolean {\n\treturn isTerminalIssueStateCategory(azureIssueStateCategory(category));\n}\n\nexport function azureWorkItemsStateCategoryToState(\n\tcategory: AzureWorkItemStateCategory | undefined,\n\tclosedDate?: Date,\n): IssueOrPullRequestState | undefined {\n\tif (azureIssueStateCategory(category) != null) {\n\t\treturn isClosedAzureWorkItemStateCategory(category) ? 'closed' : 'opened';\n\t}\n\n\treturn closedDate != null ? 'closed' : undefined;\n}\n\nexport interface AzureLink {\n\thref: string;\n}\n\nexport interface AzureUser {\n\tdisplayName: string;\n\turl: string;\n\t_links: {\n\t\tavatar: AzureLink;\n\t};\n\tid: string;\n\tuniqueName: string;\n\timageUrl: string;\n\tdescriptor?: string;\n}\n\nexport interface AzureUserWithVote extends AzureUser {\n\tisFlagged?: boolean;\n\thasDeclined?: boolean;\n\tisReapprove?: boolean;\n\tisRequired?: boolean;\n\tvote?: AzurePullRequestVote;\n}\n\nexport type AzurePullRequestVote =\n\t| 10 // approved\n\t| 5 // approved with suggestions\n\t| 0 // no vote\n\t| -5 // waiting for author\n\t| -10; // rejected\n\nexport interface AzureWorkItemCommentVersionRef {\n\tcommentId: number;\n\tcreatedInRevision: number;\n\tisDeleted: boolean;\n\ttext: string;\n\turl: string;\n\tversion: number;\n}\n\nexport interface AzureWorkItemRelation {\n\tattributes: {\n\t\t[key: string]: string;\n\t};\n\trelation: string;\n\turl: string;\n}\n\nexport interface WorkItem {\n\t_links: {\n\t\tfields: AzureLink;\n\t\thtml: AzureLink;\n\t\tself: AzureLink;\n\t\tworkItemComments: AzureLink;\n\t\tworkItemRevisions: AzureLink;\n\t\tworkItemType: AzureLink;\n\t\tworkItemUpdates: AzureLink;\n\t};\n\tfields: {\n\t\t//'System.AreaPath': string;\n\t\t'System.TeamProject': string;\n\t\t'System.IterationPath'?: string;\n\t\t'System.WorkItemType': string;\n\t\t'System.State': string;\n\t\t// 'System.Reason': string;\n\t\t'System.AssignedTo': AzureUser | string;\n\t\t'System.CreatedDate': string;\n\t\t'System.CreatedBy': AzureUser | string;\n\t\t'System.ChangedDate': string;\n\t\t'System.ChangedBy': AzureUser;\n\t\t'System.CommentCount': number;\n\t\t'System.Description': string;\n\t\t'System.Title': string;\n\t\t'Microsoft.VSTS.Common.ClosedDate': string;\n\t\t// 'Microsoft.VSTS.Common.StateChangeDate': string;\n\t\t// 'Microsoft.VSTS.Common.Priority': number;\n\t\t// 'Microsoft.VSTS.Common.Severity': string;\n\t\t// 'Microsoft.VSTS.Common.ValueArea': string;\n\t};\n\tid: number;\n\trev: number;\n\turl: string;\n\tcommentVersionRef?: AzureWorkItemCommentVersionRef;\n\trelations?: AzureWorkItemRelation[];\n}\n\nexport interface AzureWorkItemState {\n\tname: string;\n\tcolor: string;\n\tcategory: AzureWorkItemStateCategory;\n}\n\nexport type AzurePullRequestStatus = 'abandoned' | 'active' | 'completed' | 'notSet';\nexport function azurePullRequestStatusToState(status: AzurePullRequestStatus): IssueOrPullRequestState {\n\tswitch (status) {\n\t\tcase 'abandoned':\n\t\t\treturn 'closed';\n\t\tcase 'completed':\n\t\t\treturn 'merged';\n\t\tcase 'active':\n\t\tcase 'notSet':\n\t\tdefault:\n\t\t\treturn 'opened';\n\t}\n}\nexport function isClosedAzurePullRequestStatus(status: AzurePullRequestStatus): boolean {\n\treturn azurePullRequestStatusToState(status) !== 'opened';\n}\n\nexport type AzureProjectState = 'createPending' | 'deleted' | 'deleting' | 'new' | 'unchanged' | 'wellFormed';\nexport type AzureProjectVisibility = 'private' | 'public';\n\nexport interface AzureProject {\n\tid: string;\n\tname: string;\n\turl: string;\n\tstate: AzureProjectState;\n\trevision: number;\n\tvisibility: AzureProjectVisibility;\n\tlastUpdateTime: string;\n}\n\nexport interface AzureRepositoryReference {\n\tid: string;\n\tname: string;\n\turl: string;\n\tremoteUrl?: string;\n}\n\nexport interface AzureRepository extends AzureRepositoryReference {\n\tproject: AzureProject;\n\tsize: number;\n\tremoteUrl: string;\n\tsshUrl: string;\n\twebUrl: string;\n\tisDisabled: boolean;\n\tisInMaintenance: boolean;\n}\n\nexport interface AzurePullRequestRepository extends AzureRepositoryReference {\n\tproject: Pick<AzureProject, 'id' | 'name'>;\n}\n\n/** The URL fields of a repository response — all the fork lookup reads, and all an older `api-version` promises. */\nexport type AzureRepositoryUrls = Partial<Pick<AzureRepository, 'webUrl' | 'remoteUrl'>>;\n\n/** The `GET .../_apis/git/repositories/{repositoryId or name}` response, adding fork/default-branch fields to {@link AzureRepository}. */\nexport interface AzureRepositoryWithMetadata extends AzureRepository {\n\t/** Fully-qualified ref, e.g. `refs/heads/main`. */\n\tdefaultBranch?: string;\n\tisFork?: boolean;\n\tparentRepository?: {\n\t\tid: string;\n\t\tname?: string;\n\t\tproject?: { id: string; name: string };\n\t};\n}\n\nexport interface AzureGitUser {\n\tdate?: string;\n\temail?: string;\n\timageUrl?: string;\n\tname: string;\n}\n\nexport interface AzureGitCommitRef {\n\tcommitId: string;\n\turl: string;\n}\n\nexport interface AzureGitCommit {\n\t_links: {\n\t\tchanges: AzureLink;\n\t\trepository: AzureLink;\n\t\tself: AzureLink;\n\t\tweb: AzureLink;\n\t};\n\tauthor: AzureGitUser;\n\tcomment: string;\n\tcommentTruncated?: boolean;\n\tcommitId: string;\n\tcommitTooManyChanges?: boolean;\n\tcommitter: AzureGitUser;\n\tparents: string[];\n\tpush: {\n\t\tdate: string;\n\t\tpushedBy: AzureUser;\n\t\tpushId: number;\n\t};\n\tremoteUrl: string;\n\tstatuses?: AzureGitStatus[];\n\ttreeId: string;\n\turl: string;\n\tworkItems?: AzureResourceRef[];\n}\n\nexport interface AzureResourceRef {\n\tid: string;\n\turl: string;\n}\n\nexport interface AzurePullRequestCompletionOptions {\n\tautoCompleteIgnoreConflicts: number[];\n\tbypassPolicy: boolean;\n\tbypassReason: string;\n\tdeleteSourceBranch: boolean;\n\tmergeCommitMessage: string;\n\tmergeStrategy: 'noFastForward' | 'rebase' | 'rebaseMerge' | 'squash';\n\tsquashMerge: boolean;\n\ttransitionWorkItems: boolean;\n\ttriggeredByAutoComplete: boolean;\n}\n\nexport interface AzureGitStatus {\n\tcontext: {\n\t\tname: string;\n\t\tgenre: string;\n\t};\n\tcreatedBy: AzureUser;\n\tcreateDate: string;\n\tdescription: string;\n\tstate: 'error' | 'failed' | 'notApplicable' | 'notSet' | 'pending' | 'succeeded';\n\ttargetUrl: string;\n\tupdateDate: string;\n}\n\nexport interface AzureGitForkRef {\n\tcreator: AzureUser;\n\tisLocked: boolean;\n\tisLockedBy: AzureUser;\n\tname: string;\n\tobjectId: string;\n\tpeeledObjectId: string;\n\trepository: AzureRepositoryReference;\n\tstatuses: AzureGitStatus[];\n\turl: string;\n}\n\nexport interface AzureWebApiTagDefinition {\n\tactive: boolean;\n\tid: string;\n\tname: string;\n\turl: string;\n}\n\nexport interface AzureGitPullRequestMergeOptions {\n\tconflictAuthorshipCommits: boolean;\n\tdetectRenameFalsePositives: boolean;\n\tdisableRenames: boolean;\n}\n\nexport type AzurePullRequestAsyncStatus =\n\t| 'conflicts'\n\t| 'failure'\n\t| 'notSet'\n\t| 'queued'\n\t| 'rejectedByPolicy'\n\t| 'succeeded';\n\nexport interface AzurePullRequest {\n\trepository: AzurePullRequestRepository;\n\tpullRequestId: number;\n\tcodeReviewId: number;\n\tstatus: AzurePullRequestStatus;\n\tcreatedBy: AzureUser;\n\tcreationDate: string;\n\tclosedDate?: string;\n\tclosedBy?: AzureUser; // Can be missed even if closedDate is presented.\n\ttitle: string;\n\tdescription: string;\n\tforkSource?: AzureGitForkRef;\n\tsourceRefName: string;\n\ttargetRefName: string;\n\tisDraft: boolean;\n\tmergeId: string;\n\tmergeStatus?: AzurePullRequestAsyncStatus;\n\tlastMergeCommit?: AzureGitCommitRef;\n\tlastMergeSourceCommit: AzureGitCommitRef;\n\tlastMergeTargetCommit: AzureGitCommitRef;\n\treviewers: AzureUserWithVote[];\n\turl: string;\n\tsupportsIterations: boolean;\n}\n\nexport interface AzurePullRequestWithLinks extends AzurePullRequest {\n\t_links: {\n\t\tself: AzureLink;\n\t\trepository: AzureLink;\n\t\tworkItems: AzureLink;\n\t\tsourceBranch: AzureLink;\n\t\ttargetBranch: AzureLink;\n\t\tstatuses: AzureLink;\n\t\tsourceCommit: AzureLink;\n\t\ttargetCommit: AzureLink;\n\t\tcreatedBy: AzureLink;\n\t\titerations: AzureLink;\n\t};\n\tartifactId: string;\n\tautoCompleteSetBy?: AzureUser;\n\tcommits?: AzureGitCommitRef[];\n\tcompletionOptions?: AzurePullRequestCompletionOptions;\n\tcompletionQueueTime?: string;\n\thasMultipleMergeBases?: boolean;\n\tlabels?: AzureWebApiTagDefinition[];\n\tmergeFailureMessage?: string;\n\tmergeFailureType?: 'caseSensitive' | 'none' | 'objectTooLarge' | 'unknown';\n\tmergeOptions?: AzureGitPullRequestMergeOptions;\n\tremoteUrl?: string;\n\tworkItemRefs?: AzureResourceRef[];\n}\n\nexport function getAzureDevOpsOwner(url: URL): string {\n\treturn url.pathname.split('/')[1];\n}\nexport function isVsts(domain: string): boolean {\n\treturn domain.toLowerCase().endsWith(vstsHostnameSuffix);\n}\n\n/**\n * Encodes one route segment of an Azure DevOps request (#5878): `encodeURIComponent` leaves a dot segment as is, and\n * the URL would resolve it away, re-scoping the request instead of failing it.\n */\nexport function encodeAzurePathSegment(value: string): string {\n\tif (value === '.' || value === '..') throw new Error(`Invalid Azure path segment '${value}'.`);\n\n\treturn encodeURIComponent(value);\n}\n\n/**\n * `baseUrl` and `owner` are the authoritative prefix used for the API request. The payload URL cannot supply that\n * prefix safely because it may address the repository by id or name an untrusted host.\n */\nfunction getAzureRepositoryWebUrl(baseUrl: string, owner: string, projectName: string, repoName: string): string {\n\tconst repoPath = `${encodeURIComponent(owner)}/${encodeURIComponent(projectName)}/_git/${encodeURIComponent(repoName)}`;\n\treturn `${trimTrailingSlashes(baseUrl)}/${repoPath}`;\n}\n\nexport function getAzurePullRequestWebUrl(pr: AzurePullRequest, baseUrl: string, owner: string): string {\n\tconst repoUrl = getAzureRepositoryWebUrl(baseUrl, owner, pr.repository.project.name, pr.repository.name);\n\treturn `${repoUrl}/pullrequest/${pr.pullRequestId}`;\n}\n\n/**\n * Whether `url` and `expected` are the two cloud spellings of one organization: a cloud organization answers on both\n * `dev.azure.com/{owner}` and the legacy `{owner}.visualstudio.com`, so those name the same host. Anything else is\n * somewhere we didn't ask.\n */\nfunction isSameAzureCloudOrganization(url: URL, expected: URL, expectedOwner: string): boolean {\n\tif (url.protocol !== expected.protocol) return false;\n\n\tconst owner = expectedOwner.toLowerCase();\n\tif (expected.hostname !== 'dev.azure.com' && !isVsts(expected.hostname)) return false;\n\n\tif (url.hostname === 'dev.azure.com') return getAzureDevOpsOwner(url).toLowerCase() === owner;\n\n\treturn url.hostname === `${owner}${vstsHostnameSuffix}`;\n}\n\n/**\n * Whether `url` sits under the collection the integration is configured to talk to — `{expectedUrl}/{expectedOwner}`.\n * A matching origin says nothing on its own: Azure organizations and self-hosted collections are path segments.\n */\nfunction isUnderAzureCollection(url: URL, expected: URL, expectedOwner: string): boolean {\n\tconst base = trimTrailingSlashes(expected.pathname);\n\tconst prefix = `${base}/${encodeURIComponent(expectedOwner)}/`.toLowerCase();\n\treturn `${url.pathname}/`.toLowerCase().startsWith(prefix);\n}\n\n/**\n * Restricts a provider-supplied repository URL to the integration's collection and removes credentials, query, and\n * fragment before a consumer can use it as a git remote. Takes the value as the payloads carry it — every one of\n * these URLs is optional — so a caller never has to spell the absent case itself.\n */\nexport function sanitizeAzureRepositoryUrl(\n\tvalue: string | undefined,\n\texpectedUrl: string,\n\texpectedOwner: string,\n): string | undefined {\n\tif (value == null) return undefined;\n\n\tlet expected: URL;\n\tlet url: URL;\n\ttry {\n\t\texpected = new URL(expectedUrl);\n\t\turl = new URL(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n\n\tif (expected.protocol !== 'https:' && expected.protocol !== 'http:') return undefined;\n\tif (!expectedOwner) return undefined;\n\n\tif (url.origin === expected.origin) {\n\t\tif (!isUnderAzureCollection(url, expected, expectedOwner)) return undefined;\n\t} else if (!isSameAzureCloudOrganization(url, expected, expectedOwner)) {\n\t\treturn undefined;\n\t}\n\n\turl.username = '';\n\turl.password = '';\n\turl.search = '';\n\turl.hash = '';\n\treturn url.toString();\n}\n\n/**\n * The clone URL the payload carries for a repository, restricted to the integration's collection and then\n * cross-checked against the repository that payload names.\n *\n * The collection check alone is not enough for a URL that is READ rather than built. Every other repository URL the\n * model reports is built from the authoritative prefix, so the payload cannot move it; this one cannot be built,\n * because Azure spells a repository for git the same way it spells it for the web only by convention. A URL under\n * the right collection may still name a DIFFERENT repository in it, which would leave `cloneHttps` describing one\n * repository while `url` describes another.\n *\n * Azure ends a clone URL with `_git/{repo}` on every host style — including the short `{owner}/_git/{repo}` form it\n * uses when a repository carries its project's name, and the legacy `{owner}.visualstudio.com` spelling that has no\n * organization segment at all — so the repository name is the one part comparable across all of them. A same-named\n * repository in another project of the same organization is the single substitution this cannot catch.\n */\nfunction getAzureRepositoryCloneUrl(\n\trepository: AzureRepositoryReference,\n\tbaseUrl: string,\n\towner: string,\n): string | undefined {\n\tconst sanitized = sanitizeAzureRepositoryUrl(repository.remoteUrl, baseUrl, owner);\n\tif (sanitized == null) return undefined;\n\n\t// Safe to parse: `sanitizeAzureRepositoryUrl` returns what it already parsed.\n\tconst segments = new URL(sanitized).pathname.split('/').filter(s => s.length > 0);\n\tconst name = segments.pop();\n\tif (name == null || segments.pop() !== '_git') return undefined;\n\n\tlet decoded: string;\n\ttry {\n\t\tdecoded = decodeURIComponent(name);\n\t} catch {\n\t\treturn undefined;\n\t}\n\n\t// Azure resolves project and repository names case-insensitively, so comparing them any other way would refuse a\n\t// URL the provider considers the same one.\n\treturn decoded.toLowerCase() === repository.name.toLowerCase() ? sanitized : undefined;\n}\n\nexport function fromAzurePullRequestMergeStatusToMergeableState(\n\tmergeStatus: AzurePullRequestAsyncStatus,\n): PullRequestMergeableState {\n\tswitch (mergeStatus) {\n\t\tcase 'conflicts':\n\t\t\treturn PullRequestMergeableState.Conflicting;\n\t\tcase 'failure':\n\t\t\treturn PullRequestMergeableState.FailingChecks;\n\t\tcase 'rejectedByPolicy':\n\t\t\treturn PullRequestMergeableState.BlockedByPolicy;\n\t\tcase 'succeeded':\n\t\t\treturn PullRequestMergeableState.Mergeable;\n\t\tcase 'notSet':\n\t\tcase 'queued':\n\t\tdefault:\n\t\t\treturn PullRequestMergeableState.Unknown;\n\t}\n}\n\nexport function fromAzurePullRequestVoteToReviewState(vote: AzurePullRequestVote): PullRequestReviewState {\n\tswitch (vote) {\n\t\tcase 10:\n\t\tcase 5:\n\t\t\treturn PullRequestReviewState.Approved;\n\t\tcase 0:\n\t\t\treturn PullRequestReviewState.ReviewRequested;\n\t\tcase -5:\n\t\tcase -10:\n\t\t\treturn PullRequestReviewState.ChangesRequested;\n\t\tdefault:\n\t\t\treturn PullRequestReviewState.ReviewRequested;\n\t}\n}\n\nexport function fromAzureUserWithVoteToReviewer(reviewer: AzureUserWithVote): PullRequestReviewer {\n\treturn {\n\t\tisCodeOwner: undefined,\n\t\treviewer: {\n\t\t\tavatarUrl: reviewer.imageUrl,\n\t\t\tid: reviewer.id,\n\t\t\tname: reviewer.displayName,\n\t\t\tusername: reviewer.uniqueName,\n\t\t\turl: reviewer.url,\n\t\t},\n\t\tstate: fromAzurePullRequestVoteToReviewState(reviewer.vote ?? 0),\n\t};\n}\n\nexport function getAzurePullRequestReviewDecision(\n\tvotes: AzurePullRequestVote[],\n): PullRequestReviewDecision | undefined {\n\tconst reviewStates = votes.map(vote => fromAzurePullRequestVoteToReviewState(vote));\n\tif (reviewStates.includes(PullRequestReviewState.ChangesRequested)) {\n\t\treturn PullRequestReviewDecision.ChangesRequested;\n\t}\n\n\tif (reviewStates.includes(PullRequestReviewState.ReviewRequested)) {\n\t\treturn PullRequestReviewDecision.ReviewRequired;\n\t}\n\n\tif (reviewStates.includes(PullRequestReviewState.Approved)) {\n\t\treturn PullRequestReviewDecision.Approved;\n\t}\n\n\treturn undefined;\n}\n\nexport function fromAzureReviewerToPullRequestMember(reviewer: AzureUser): PullRequestMember {\n\treturn {\n\t\tavatarUrl: reviewer.imageUrl,\n\t\tid: reviewer.id,\n\t\tname: reviewer.displayName,\n\t\tusername: reviewer.uniqueName,\n\t\turl: reviewer.url,\n\t};\n}\n\nexport function normalizeAzureBranchName(branchName: string): string {\n\treturn branchName.startsWith('refs/heads/') ? branchName.replace('refs/heads/', '') : branchName;\n}\n\nfunction fromAzureUserToMember(user: AzureUser, type: 'issue'): IssueMember;\nfunction fromAzureUserToMember(user: AzureUser, type: 'pullRequest'): PullRequestMember;\nfunction fromAzureUserToMember(user: AzureUser, _type: 'issue' | 'pullRequest'): PullRequestMember | IssueMember {\n\treturn {\n\t\tavatarUrl: user.imageUrl,\n\t\tid: user.id,\n\t\tname: user.displayName,\n\t\tusername: user.uniqueName,\n\t\turl: user.url,\n\t};\n}\n\n/**\n * The URLs of a cross-repository pull request's fork, resolved by a lookup because the pull request payload embeds\n * only an abbreviated reference to it: `url` is the URL the head ref reports — the fork's web URL, or its clone URL\n * when the response carries no web URL — and `cloneHttps` its HTTPS clone URL.\n *\n * A fork that resolves neither is reported as no fork at all rather than as an object with nothing in it, so `url`\n * is always present here; `cloneHttps` alone is best-effort, and is absent when the response omits it or its URL\n * sits outside the integration's collection.\n */\nexport interface AzureForkRepositoryUrls {\n\turl: string;\n\tcloneHttps: string | undefined;\n}\n\n/**\n * `baseUrl` and `owner` are the prefix the pull request was read through; every URL the model reports is built from\n * them. The required `forkRepositoryUrls` argument makes each call site resolve the best-effort fork URLs explicitly.\n */\nexport function fromAzurePullRequest(\n\tpr: AzurePullRequest,\n\tprovider: Provider,\n\towner: string,\n\tbaseUrl: string,\n\tforkRepositoryUrls: AzureForkRepositoryUrls | undefined,\n\tprojection?: PullRequestProjection,\n): PullRequest {\n\tconst baseRepositoryUrl = getAzureRepositoryWebUrl(baseUrl, owner, pr.repository.project.name, pr.repository.name);\n\tconst baseCloneHttps = getAzureRepositoryCloneUrl(pr.repository, baseUrl, owner);\n\n\tconst forkRepository = pr.forkSource?.repository;\n\tconst headRepositoryUrl = forkRepository == null ? baseRepositoryUrl : forkRepositoryUrls?.url;\n\tconst headCloneHttps = forkRepository == null ? baseCloneHttps : forkRepositoryUrls?.cloneHttps;\n\n\tconst result = new PullRequest(\n\t\tprovider,\n\t\tfromAzureUserToMember(pr.createdBy, 'pullRequest'),\n\t\tpr.pullRequestId.toString(),\n\t\tpr.pullRequestId.toString(),\n\t\tpr.title,\n\t\tgetAzurePullRequestWebUrl(pr, baseUrl, owner),\n\t\t{\n\t\t\towner: owner,\n\t\t\trepo: pr.repository.name,\n\t\t\tid: pr.repository.id,\n\t\t},\n\t\tazurePullRequestStatusToState(pr.status),\n\t\tnew Date(pr.creationDate),\n\t\tnew Date(pr.closedDate || pr.creationDate),\n\t\tpr.closedDate ? new Date(pr.closedDate) : undefined,\n\t\tpr.closedDate && pr.status === 'completed' ? new Date(pr.closedDate) : undefined,\n\t\t// The read selects the merge status, so an absent one is Azure's own \"not set\", as provider-apis maps it.\n\t\tfromAzurePullRequestMergeStatusToMergeableState(pr.mergeStatus ?? 'notSet'),\n\t\tundefined,\n\t\t{\n\t\t\tbase: {\n\t\t\t\tbranch: pr.targetRefName ? normalizeAzureBranchName(pr.targetRefName) : '',\n\t\t\t\tsha: pr.lastMergeTargetCommit?.commitId ?? '',\n\t\t\t\trepo: pr.repository.name,\n\t\t\t\towner: owner,\n\t\t\t\texists: pr.targetRefName != null,\n\t\t\t\turl: baseRepositoryUrl,\n\t\t\t\tcloneHttps: baseCloneHttps,\n\t\t\t},\n\t\t\thead: {\n\t\t\t\tbranch: pr.sourceRefName ? normalizeAzureBranchName(pr.sourceRefName) : '',\n\t\t\t\tsha: pr.lastMergeSourceCommit?.commitId ?? '',\n\t\t\t\trepo: forkRepository?.name ?? pr.repository.name,\n\t\t\t\towner: owner,\n\t\t\t\texists: pr.sourceRefName != null,\n\t\t\t\turl: headRepositoryUrl,\n\t\t\t\tcloneHttps: headCloneHttps,\n\t\t\t},\n\t\t\tisCrossRepository: pr.forkSource != null,\n\t\t},\n\t\tpr.isDraft,\n\t\tundefined,\n\t\tundefined,\n\t\tundefined,\n\t\tundefined,\n\t\tgetAzurePullRequestReviewDecision(pr.reviewers?.filter(r => r.isRequired).map(r => r.vote ?? 0) ?? []),\n\t\tpr.reviewers.filter(r => r.vote == null || r.vote === 0).map(r => fromAzureUserWithVoteToReviewer(r)),\n\t\tpr.reviewers.filter(r => r.vote != null && r.vote !== 0).map(r => fromAzureUserWithVoteToReviewer(r)),\n\t\tpr.reviewers.map(r => fromAzureReviewerToPullRequestMember(r)),\n\t\tundefined,\n\t\t{\n\t\t\tid: pr.repository?.project?.id,\n\t\t\tname: pr.repository.project.name,\n\t\t\tresourceId: '', // TODO: This is a workaround until we can get the org id here.\n\t\t\tresourceName: owner,\n\t\t},\n\t\tundefined, // version\n\t\tundefined, // commitCount\n\t\tundefined, // stack\n\t\tundefined, // filesChanged\n\t\tundefined, // body\n\t\tundefined, // number\n\t\tundefined, // authoredByMe\n\t\tprojection,\n\t);\n\treturn copyReadProvenance(result, pr);\n}\n\nfunction fromAzureWorkItemUserToMember(user: AzureUser | string | undefined): IssueMember | undefined {\n\tif (user == null || (typeof user === 'string' && !user.trim())) return undefined;\n\n\treturn typeof user === 'string' ? { id: user, name: user, username: user } : fromAzureUserToMember(user, 'issue');\n}\n\nexport function fromAzureWorkItem(\n\tworkItem: WorkItem,\n\tprovider: Provider,\n\tproject: AzureProjectDescriptor,\n\tstateCategory?: AzureWorkItemStateCategory,\n\tprojection?: IssueProjection,\n\thtmlFields?: readonly AzureWorkItemHtmlField[],\n\t/** As `toIssueShape` takes it: `null` where the read couldn't resolve it. */\n\tviewer?: { id: string } | null,\n): Issue {\n\tconst state = workItem.fields['System.State'];\n\tconst description = getAzureWorkItemDescription(workItem.fields, htmlFields);\n\tconst closedDate = parseAzureWorkItemDate(workItem.fields['Microsoft.VSTS.Common.ClosedDate']) ?? undefined;\n\tconst normalizedState = azureWorkItemsStateCategoryToState(stateCategory, closedDate);\n\tconst author = fromAzureWorkItemUserToMember(workItem.fields['System.CreatedBy']);\n\tconst assignee = fromAzureWorkItemUserToMember(workItem.fields['System.AssignedTo']);\n\tconst assignees = assignee != null ? [assignee] : [];\n\tconst viewerFields = toIssueViewer({ author: author, assignees: assignees }, viewer);\n\tconst result = new Issue(\n\t\tprovider,\n\t\tworkItem.id.toString(),\n\t\tworkItem.id.toString(),\n\t\tworkItem.fields['System.Title'],\n\t\tworkItem._links.html.href,\n\t\tnew Date(workItem.fields['System.CreatedDate']),\n\t\tnew Date(workItem.fields['System.ChangedDate']),\n\t\tnormalizedState === 'closed',\n\t\tnormalizedState,\n\t\tauthor,\n\t\tassignees,\n\t\tundefined,\n\t\tclosedDate,\n\t\tundefined,\n\t\tworkItem.fields['System.CommentCount'],\n\t\tundefined,\n\t\tdescription?.value,\n\t\tproject,\n\t\tundefined,\n\t\tworkItem.fields['System.WorkItemType'],\n\t\ttypeof state === 'string' && state\n\t\t\t? { name: state, category: azureIssueStateCategory(stateCategory) }\n\t\t\t: undefined,\n\t\tundefined,\n\t\ttoWorkItemIterations(workItem.fields['System.IterationPath']),\n\t\tprojection,\n\t\tdescription != null ? toIssueBodyField(description.field) : undefined,\n\t\tviewerFields?.viewer,\n\t\tviewerFields?.viewerUnresolved,\n\t);\n\treturn copyReadProvenance(result, workItem);\n}\n\n/**\n * Azure reports the iteration as a backslash-delimited path rooted at the project. The project root is its default\n * for a work item with no sprint, so only a nested path names one; the path is the identity because Azure supplies\n * no iteration id here.\n *\n * Mirrors `normalizeIteration` in provider-apis so the same work item yields the same identity whether it is read\n * here or through the SDK. That contract keeps the path **verbatim** — it is what the iteration is matched back by,\n * so it is deliberately not trimmed — and trims only the display name.\n */\nfunction toWorkItemIterations(path: string | undefined): IssueIteration[] | undefined {\n\tif (!path) return undefined;\n\n\tconst segments = path.split('\\\\');\n\tif (segments.length < 2) return undefined;\n\n\tconst name = segments.at(-1)?.trim();\n\treturn name ? [{ id: path, name: name }] : undefined;\n}\n\n/**\n * A work item as `GET …/_apis/wit/workitems/{id}?$expand=Links` returns it. Loosely typed because\n * {@link fromAzureWorkItemToProviderIssue} checks every field it reads, as provider-apis does.\n */\nexport interface AzureWorkItemResponse {\n\tid?: unknown;\n\tfields?: Record<string, unknown>;\n\t_links?: { html?: { href?: unknown } };\n}\n\n/**\n * A cheap read's work item with the workflow category its state classifies to (see\n * {@link toAzureWorkItemEtagFields}). Beside the work item rather than on it, so the wire type stays what Azure sends.\n */\nexport interface AzureWorkItemEtagRead {\n\treadonly workItem: AzureWorkItemResponse;\n\treadonly category: IssueProviderState['category'];\n}\n\n/**\n * Converts a work item as provider-apis' `getIssuesForAzureProject` converts each row it reads, so a work item read\n * by id reaches `toIssueShape` identical to the list read's row for it. provider-apis exports neither that converter\n * nor a single work item read, so this mirrors it field for field; the batch issue tests compare the two, so a\n * provider-apis change that this misses fails there.\n *\n * `undefined` for a work item the SDK would skip: no positive integer id, no title, or no valid created date.\n * `state.name` is the raw `System.State`, as on every list read here, which passes the SDK no state-name map. Like\n * the SDK's row, the state carries no workflow category: `ProvidersApi` classifies both reads' rows the same way\n * afterwards, from the work item type's states.\n */\nexport function fromAzureWorkItemToProviderIssue(\n\tworkItem: AzureWorkItemResponse,\n\tnamespace: string,\n\tproject: string,\n\thtmlFields?: readonly AzureWorkItemHtmlField[],\n): ProviderIssue | undefined {\n\tconst fields = workItem.fields;\n\tconst id = workItem.id;\n\tconst title = fields?.['System.Title'];\n\tconst createdDate = parseAzureWorkItemDate(fields?.['System.CreatedDate']);\n\tif (\n\t\tfields == null ||\n\t\ttypeof id !== 'number' ||\n\t\t!Number.isSafeInteger(id) ||\n\t\tid <= 0 ||\n\t\ttypeof title !== 'string' ||\n\t\t!title.trim() ||\n\t\tcreatedDate == null\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst assignee = fromAzureWorkItemIdentity(fields['System.AssignedTo']);\n\tconst commentCount = fields['System.CommentCount'];\n\tconst url = workItem._links?.html?.href;\n\tconst tags = fields['System.Tags'];\n\tconst state = fields['System.State'];\n\tconst type = fields['System.WorkItemType'];\n\tconst result: ProviderIssue = {\n\t\tid: id.toString(),\n\t\tnumber: id.toString(),\n\t\ttitle: title,\n\t\tcommentCount: typeof commentCount === 'number' && Number.isFinite(commentCount) ? commentCount : null,\n\t\tauthor: fromAzureWorkItemIdentity(fields['System.CreatedBy']),\n\t\tclosedDate: parseAzureWorkItemDate(fields['Microsoft.VSTS.Common.ClosedDate']),\n\t\tcreatedDate: createdDate,\n\t\tupdatedDate: parseAzureWorkItemDate(fields['System.ChangedDate']),\n\t\turl: typeof url === 'string' ? url : null,\n\t\tassignees: assignee != null ? [assignee] : [],\n\t\t...toAzureWorkItemDescriptionFields(fields, htmlFields),\n\t\tstate: typeof state === 'string' && state ? { name: state, color: null } : null,\n\t\ttype: typeof type === 'string' ? type : null,\n\t\titeration: toAzureWorkItemIteration(fields['System.IterationPath']),\n\t\trepository: null,\n\t\tproject: { namespace: namespace, name: project, resourceId: null, key: null, id: null },\n\t\t// provider-apis fills 0, but work items have no reactions.\n\t\tupvoteCount: null,\n\t\tlabels: (typeof tags === 'string' ? tags.split(';') : []).map(tag => ({\n\t\t\tcolor: null,\n\t\t\tdescription: null,\n\t\t\tid: null,\n\t\t\tname: tag.trim(),\n\t\t})),\n\t};\n\treturn copyReadProvenance(result, workItem);\n}\n\nexport function toAzureWorkItemDescriptionFields(\n\tfields: Readonly<Record<string, unknown>> | null | undefined,\n\thtmlFields?: readonly AzureWorkItemHtmlField[],\n): Pick<ProviderIssue, 'description' | 'descriptionField'> {\n\tconst description = getAzureWorkItemDescription(fields, htmlFields);\n\treturn {\n\t\tdescription: description?.value ?? null,\n\t\t...(description != null ? { descriptionField: description.field } : {}),\n\t};\n}\n\n/** An identity field, as provider-apis maps it: `name` from `uniqueName`, `username` from `displayName`. */\nfunction fromAzureWorkItemIdentity(value: unknown): ProviderAccount | null {\n\tif (typeof value === 'string') {\n\t\tif (!value.trim()) return null;\n\n\t\treturn { id: value, name: value, username: value, email: null, avatarUrl: null, url: null };\n\t}\n\n\tconst identity = value as\n\t\t| { id?: unknown; uniqueName?: unknown; displayName?: unknown; _links?: { avatar?: { href?: unknown } } }\n\t\t| null\n\t\t| undefined;\n\tif (typeof identity?.id !== 'string' || !identity.id.trim()) return null;\n\n\tconst avatarUrl = identity._links?.avatar?.href;\n\treturn {\n\t\tavatarUrl: typeof avatarUrl === 'string' ? avatarUrl : null,\n\t\temail: null,\n\t\tid: identity.id,\n\t\tname: typeof identity.uniqueName === 'string' ? identity.uniqueName : null,\n\t\tusername: typeof identity.displayName === 'string' ? identity.displayName : null,\n\t\turl: null,\n\t};\n}\n\n/** Only a UTC ISO timestamp naming a real calendar date and time, as provider-apis accepts; anything else is `null`. */\nexport function parseAzureWorkItemDate(value: unknown): Date | null {\n\tif (typeof value !== 'string') return null;\n\n\tconst match = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.\\d{1,7})?Z$/.exec(value);\n\tif (match == null) return null;\n\n\tconst [year, month, day, hour, minute, second] = match.slice(1).map(Number);\n\tconst isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n\tconst daysInMonth = [31, isLeapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\tif (month < 1 || month > 12 || day < 1 || day > daysInMonth[month - 1] || hour > 23 || minute > 59 || second > 59) {\n\t\treturn null;\n\t}\n\n\tconst date = new Date(value);\n\treturn Number.isNaN(date.getTime()) ? null : date;\n}\n\n/** The SDK's `iteration`, by the same path rule as {@link toWorkItemIterations}. */\nfunction toAzureWorkItemIteration(path: unknown): ProviderIssue['iteration'] {\n\tconst [iteration] = toWorkItemIterations(typeof path === 'string' ? path : undefined) ?? [];\n\treturn iteration != null ? { path: iteration.id, name: iteration.name } : undefined;\n}\n\n/**\n * The most ids one cheap work item read asks for: the most Azure DevOps' work item list (`GET …/_apis/wit/workitems`)\n * takes.\n */\nexport const azureWorkItemsEtagFieldsMaxIds = 200;\n\n/**\n * The fields the cheap work item read selects: only the ones a full row's etag reads, and the project the full read\n * checks the work item against. The state and type let the cheap read resolve the same workflow category as the full\n * read, from the same work item type states.\n */\nexport const azureWorkItemEtagFieldNames: readonly string[] = [\n\t'System.TeamProject',\n\t'System.State',\n\t'System.WorkItemType',\n\t'System.ChangedDate',\n\t'Microsoft.VSTS.Common.ClosedDate',\n];\n\n/**\n * A cheap read's work item, as the fields its full batch row's etag reads: `toIssueShape` closes the row the full\n * read builds (see {@link fromAzureWorkItemToProviderIssue}) from its known workflow category, falling back to a\n * closed date only when the category is unavailable. A historical date must not close a reopened work item.\n * Throws where the full read fails the work item: on one in another project than `project` (compared as Azure\n * compares names), and on a missing or unparseable change date, so the target falls through to the full read.\n */\nexport function toAzureWorkItemEtagFields(\n\tworkItem: AzureWorkItemResponse,\n\tproject: string,\n\tcategory: IssueProviderState['category'],\n): IssueEtagFields {\n\tconst fields = workItem.fields;\n\tconst teamProject = fields?.['System.TeamProject'];\n\tif (typeof teamProject !== 'string' || !teamProject.trim()) {\n\t\tthrow new Error(`Azure DevOps work item ${String(workItem.id)} has no project`);\n\t}\n\n\tif (teamProject.toLowerCase() !== project.toLowerCase()) {\n\t\tthrow new Error(\n\t\t\t`Azure DevOps work item ${String(workItem.id)} is in project '${teamProject}', not '${project}'`,\n\t\t);\n\t}\n\n\tconst updatedDate = parseAzureWorkItemDate(fields?.['System.ChangedDate']);\n\tif (updatedDate == null) {\n\t\tthrow new Error(`Azure DevOps returned work item ${String(workItem.id)} without a change date`);\n\t}\n\n\tconst state =\n\t\tcategory != null\n\t\t\t? isTerminalIssueStateCategory(category)\n\t\t\t\t? 'closed'\n\t\t\t\t: 'opened'\n\t\t\t: parseAzureWorkItemDate(fields?.['Microsoft.VSTS.Common.ClosedDate']) != null\n\t\t\t\t? 'closed'\n\t\t\t\t: undefined;\n\treturn {\n\t\tstate: state,\n\t\tupdatedDate: updatedDate,\n\t\tdescriptionRule: azureWorkItemDescriptionRule,\n\t\tviewerRule: azureWorkItemViewerRule,\n\t};\n}\n\ntype ProviderPullRequestState = Parameters<typeof fromProviderPullRequestState>[0];\ntype ProviderMergeableState = keyof typeof fromProviderPullRequestMergeableState;\ntype ProviderReviewState = keyof typeof fromPullRequestReviewDecision;\n\n// The tables below mirror provider-apis' (0.61.0) Azure DevOps pull request mapping behind `getPullRequestForRepo` (`Xe`\n// and its helpers in the bundle), which it doesn't export. A full batch row takes these values on through\n// `fromProviderPullRequest`, so the cheap check composes the same steps to compute the same etag.\n\n/** provider-apis' pull request `status` map (`bi`). It has no `notSet`, which therefore maps to `undefined`. */\nconst azurePullRequestProviderStates: Partial<Record<string, ProviderPullRequestState>> = {\n\tactive: GitPullRequestState.Open,\n\tcompleted: GitPullRequestState.Merged,\n\tabandoned: GitPullRequestState.Closed,\n};\n\n/** provider-apis' `mergeStatus` map (`Ti`); any other status, or none, is unknown. */\nconst azureMergeStatusProviderStates: Partial<Record<string, ProviderMergeableState>> = {\n\tconflicts: GitPullRequestMergeableState.Conflicts,\n\tfailure: GitPullRequestMergeableState.FailingChecks,\n\trejectedByPolicy: GitPullRequestMergeableState.Blocked,\n\tsucceeded: GitPullRequestMergeableState.Mergeable,\n};\n\n/** provider-apis' reviewer `vote` map (`Di`); any other vote reads as review requested. */\nconst azureVoteProviderReviewStates: Partial<Record<number, ProviderReviewState>> = {\n\t10: GitPullRequestReviewState.Approved,\n\t5: GitPullRequestReviewState.Approved,\n\t0: GitPullRequestReviewState.ReviewRequested,\n\t[-5]: GitPullRequestReviewState.ChangesRequested,\n\t[-10]: GitPullRequestReviewState.ChangesRequested,\n};\n\n/** provider-apis' reviewer mapping (`ve`), with the state its vote maps to: every reviewer, required or optional. */\nfunction toAzureProviderReview(reviewer: AzureUserWithVote): ProviderPullRequestReview {\n\treturn {\n\t\treviewer: {\n\t\t\tid: reviewer.id,\n\t\t\tname: reviewer.displayName ?? null,\n\t\t\tusername: (reviewer.uniqueName || reviewer.displayName) ?? null,\n\t\t\temail: null,\n\t\t\tavatarUrl: reviewer.imageUrl ?? null,\n\t\t\turl: null,\n\t\t},\n\t\tstate: toAzureProviderReviewState(reviewer),\n\t};\n}\n\nfunction toAzureProviderReviewState(reviewer: AzureUserWithVote): ProviderReviewState {\n\treturn azureVoteProviderReviewStates[reviewer.vote ?? 0] ?? GitPullRequestReviewState.ReviewRequested;\n}\n\n/**\n * A cheap read's pull request (the same `GET …/pullrequests/{id}` provider-apis sends), as the fields its full batch\n * row's etag reads: provider-apis' mapping (see the tables above), then `fromProviderPullRequest`'s. Azure DevOps\n * reports no update time, so provider-apis' `updatedDate` is the close time, else the creation time, which is why\n * the fields Azure changes without one are fingerprinted into the `revision`, from the values the full row ends up\n * with: provider-apis' title, description (`?? null`, which the row reads `?? undefined`) and target branch, and its\n * reviews, split into requests and completed reviews by `fromProviderPullRequest`'s own helpers.\n *\n * Throws where provider-apis' mapping throws, on a field it reads without a guard, so a pull request the full read\n * fails on falls through to it rather than matching an etag. A full row never carries a check rollup (provider-apis\n * maps none for Azure DevOps), so the `checks` include always reads `undefined`, as there.\n */\nexport function toAzurePullRequestEtagFields(\n\tpr: AzurePullRequest,\n\tetagIncludes: readonly PullRequestEtagInclude[],\n): PullRequestEtagFields {\n\tif (\n\t\tpr.pullRequestId == null ||\n\t\tpr.createdBy == null ||\n\t\tpr.repository?.project == null ||\n\t\tpr.lastMergeSourceCommit == null ||\n\t\tpr.lastMergeTargetCommit == null ||\n\t\t!Array.isArray(pr.reviewers) ||\n\t\tpr.reviewers.some(r => r == null) ||\n\t\ttypeof pr.url !== 'string' ||\n\t\ttypeof pr.sourceRefName !== 'string' ||\n\t\ttypeof pr.targetRefName !== 'string'\n\t) {\n\t\tthrow new Error(`Azure DevOps returned pull request ${String(pr.pullRequestId)} without a field it maps`);\n\t}\n\n\tconst reviews = pr.reviewers.map(toAzureProviderReview);\n\tconst fields: PullRequestEtagFields = {\n\t\t// `notSet` passes `undefined` here, as its full row does.\n\t\tstate: fromProviderPullRequestState(azurePullRequestProviderStates[pr.status] as ProviderPullRequestState),\n\t\tisDraft: pr.isDraft,\n\t\tupdatedDate: new Date(pr.closedDate || pr.creationDate),\n\t\theadSha: pr.lastMergeSourceCommit.commitId ?? '',\n\t\trevision: pullRequestRevision({\n\t\t\ttitle: pr.title,\n\t\t\tbody: pr.description ?? undefined,\n\t\t\trefs: { base: { branch: normalizeAzureBranchName(pr.targetRefName) } },\n\t\t\treviewRequests: toReviewRequests(reviews),\n\t\t\tlatestReviews: toCompletedReviews(reviews),\n\t\t}),\n\t};\n\n\tif (etagIncludes.includes('mergeable')) {\n\t\tconst mergeable =\n\t\t\t(pr.mergeStatus != null ? azureMergeStatusProviderStates[pr.mergeStatus] : undefined) ??\n\t\t\tGitPullRequestMergeableState.Unknown;\n\t\tfields.mergeableState = fromProviderPullRequestMergeableState[mergeable];\n\t}\n\n\tif (etagIncludes.includes('reviewDecision')) {\n\t\t// Only the required reviewers decide.\n\t\tconst decision = decideProviderReviewDecision(\n\t\t\tpr.reviewers.filter(r => r.isRequired).map(toAzureProviderReviewState),\n\t\t);\n\t\tfields.reviewDecision = decision ? fromPullRequestReviewDecision[decision] : undefined;\n\t}\n\n\treturn fields;\n}\n"],"mappings":";;;;;;;;;;AAyCA,MAAa,qBAAqB;;;;;;AA4ClC,SAAgB,wBACf,UACiC;CACjC,QAAQ,UAAR;EACC,KAAK,WACJ,OAAO;EACR,KAAK;EACL,KAAK,YACJ,OAAO;EACR,KAAK,cACJ,OAAO;EACR,KAAK,YACJ,OAAO;EACR,SACC;CACF;AACD;AAEA,SAAgB,mCAAmC,UAA2D;CAC7G,OAAO,6BAA6B,wBAAwB,QAAQ,CAAC;AACtE;AAEA,SAAgB,mCACf,UACA,YACsC;CACtC,IAAI,wBAAwB,QAAQ,KAAK,MACxC,OAAO,mCAAmC,QAAQ,IAAI,WAAW;CAGlE,OAAO,cAAc,OAAO,WAAW,KAAA;AACxC;AA+FA,SAAgB,8BAA8B,QAAyD;CACtG,QAAQ,QAAR;EACC,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  import { normalizeBitbucketServerPullRequest } from "../bitbucket-server/models.js";
14
14
  import { bitbucketIssueStateToState, fromBitbucketIssue, fromBitbucketPullRequest, parseRawBitbucketAuthor } from "./models.js";
15
15
  import * as l10n from "@vscode/l10n";
16
+ import { captureReadNodes, copyReadProvenance, createReadCapture } from "@gitkraken/provider-apis/read-provenance";
16
17
  //#region ../plus/integrations/src/providers/bitbucket/bitbucket.ts
17
18
  /** `handleRequestError` maps 410 and 422 to the same error as a 404, but only a 404 proves the resource absent. */
18
19
  function isNotFoundResponse(ex) {
@@ -71,18 +72,21 @@ var BitbucketApi = class {
71
72
  }
72
73
  if (options?.type === void 0 || options?.type === "issue") try {
73
74
  const issueResponse = await this.request(provider, token, baseUrl, `repositories/${owner}/${repo}/issues/${id}`, { method: "GET" }, scope);
74
- if (issueResponse) return {
75
- id: issueResponse.id.toString(),
76
- type: "issue",
77
- nodeId: issueResponse.id.toString(),
78
- provider,
79
- createdDate: new Date(issueResponse.created_on),
80
- updatedDate: new Date(issueResponse.updated_on),
81
- state: bitbucketIssueStateToState(issueResponse.state),
82
- closed: issueResponse.state === "closed",
83
- title: issueResponse.title,
84
- url: issueResponse.links.html.href
85
- };
75
+ if (issueResponse) {
76
+ const result = {
77
+ id: issueResponse.id.toString(),
78
+ type: "issue",
79
+ nodeId: issueResponse.id.toString(),
80
+ provider,
81
+ createdDate: new Date(issueResponse.created_on),
82
+ updatedDate: new Date(issueResponse.updated_on),
83
+ state: bitbucketIssueStateToState(issueResponse.state),
84
+ closed: issueResponse.state === "closed",
85
+ title: issueResponse.title,
86
+ url: issueResponse.links.html.href
87
+ };
88
+ return copyReadProvenance(result, issueResponse);
89
+ }
86
90
  } catch (ex) {
87
91
  scope?.error(ex);
88
92
  return;
@@ -434,6 +438,7 @@ var BitbucketApi = class {
434
438
  const sw = maybeStopWatch(`[BITBUCKET] ${options?.method ?? "GET"} ${url}`, { log: { onlyExit: true } });
435
439
  try {
436
440
  if (cancellation?.aborted) throw new CancellationError();
441
+ const capture = createReadCapture();
437
442
  rsp = await this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () => this.config.fetch(url, {
438
443
  headers: {
439
444
  Authorization: `Bearer ${accessToken}`,
@@ -442,7 +447,7 @@ var BitbucketApi = class {
442
447
  signal: cancellation,
443
448
  ...options
444
449
  }));
445
- if (rsp.ok) return await rsp.json();
450
+ if (rsp.ok) return captureReadNodes(await rsp.json(), capture);
446
451
  throw await ProviderFetchError.fromResponse("Bitbucket", rsp);
447
452
  } finally {
448
453
  sw?.stop();
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucket.js","names":["Logger"],"sources":["../../../../../../plus/integrations/src/providers/bitbucket/bitbucket.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport { reportRequestFailure } from '@gitlens/git/errors.js';\nimport type { Account, CommitAuthor, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequest, PullRequestProjection } from '@gitlens/git/models/pullRequest.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { trace } from '@gitlens/utils/decorators/log.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { ScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { equalsIgnoreCase } from '@gitlens/utils/string.js';\nimport type { TokenWithInfo } from '../../authentication/models.js';\nimport type { IntegrationServiceContext } from '../../context.js';\nimport {\n\tAuthenticationError,\n\tAuthenticationErrorReason,\n\tisRateLimitResponse,\n\tProviderFetchError,\n\tRequestClientError,\n\tRequestNotFoundError,\n\ttoRateLimitError,\n} from '../../errors.js';\nimport type { PullRequestEtagInclude } from '../../models/integration.js';\nimport type { ProviderApiConfig } from '../apiConfig.js';\nimport { baseProviderApiConfig } from '../apiConfig.js';\nimport type { BitbucketServerCommit, BitbucketServerPullRequest } from '../bitbucket-server/models.js';\nimport { normalizeBitbucketServerPullRequest } from '../bitbucket-server/models.js';\nimport { fromProviderPullRequest } from '../models.js';\nimport { selectBranchPullRequests } from '../utils/providerPaging.js';\nimport type {\n\tBitbucketCommit,\n\tBitbucketIssue,\n\tBitbucketPullRequest,\n\tBitbucketPullRequestEtagNode,\n\tBitbucketPullRequestState,\n\tBitbucketRepository,\n} from './models.js';\nimport {\n\tbitbucketEtagFieldsMaxIds,\n\tbitbucketIssueStateToState,\n\tfromBitbucketIssue,\n\tfromBitbucketPullRequest,\n\tparseRawBitbucketAuthor,\n} from './models.js';\n\n/** `handleRequestError` maps 410 and 422 to the same error as a 404, but only a 404 proves the resource absent. */\nfunction isNotFoundResponse(ex: unknown): boolean {\n\treturn RequestNotFoundError.is(ex) && ex.original instanceof ProviderFetchError && ex.original.status === 404;\n}\n\nexport class BitbucketApi implements Disposable {\n\tprivate readonly _disposable: Disposable | undefined;\n\n\tconstructor(private readonly config: ProviderApiConfig) {\n\t\tthis._disposable = config.onConfigChanged?.(() => this.resetCaches());\n\t}\n\n\tdispose(): void {\n\t\tthis._disposable?.dispose();\n\t}\n\n\tprivate resetCaches(): void {}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequestForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketPullRequest[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}/pullrequests?q=source.branch.name=\"${branch}\"&fields=%2Bvalues.reviewers,%2Bvalues.participants`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn fromBitbucketPullRequest(response.values[0], provider, { projection: 'point' });\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketServerPullRequest[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`projects/${owner}/repos/${repo}/pull-requests?at=refs/heads/${branch}&direction=OUTGOING&state=ALL`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst providersPr = normalizeBitbucketServerPullRequest(response.values[0]);\n\t\tconst gitlensPr = fromProviderPullRequest(providersPr, provider, { projection: 'point' });\n\t\treturn gitlensPr;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, userUuid, owner, repo, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tuserUuid: userUuid,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getUsersIssuesForRepo(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tuserUuid: string,\n\t\towner: string,\n\t\trepo: string,\n\t\tbaseUrl: string,\n\t): Promise<Issue[] | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst query = encodeURIComponent(`assignee.uuid=\"${userUuid}\" OR reporter.uuid=\"${userUuid}\"`);\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketIssue[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}/issues?q=${query}`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn response.values.map(issue => fromBitbucketIssue(issue, provider, 'account'));\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getIssue(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t): Promise<Issue | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.request<BitbucketIssue>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/issues/${id}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\tif (response) {\n\t\t\t\treturn fromBitbucketIssue(response, provider, 'point');\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getIssueOrPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\ttype?: IssueOrPullRequestType;\n\t\t},\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (options?.type === undefined || options?.type === 'pullrequest') {\n\t\t\ttry {\n\t\t\t\tconst pr = await this.getPullRequest(provider, token, owner, repo, id, baseUrl);\n\t\t\t\tif (pr != null) return pr;\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tif (options?.type === undefined || options?.type === 'issue') {\n\t\t\ttry {\n\t\t\t\tconst issueResponse = await this.request<BitbucketIssue>(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\t`repositories/${owner}/${repo}/issues/${id}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t},\n\t\t\t\t\tscope,\n\t\t\t\t);\n\n\t\t\t\tif (issueResponse) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: issueResponse.id.toString(),\n\t\t\t\t\t\ttype: 'issue',\n\t\t\t\t\t\tnodeId: issueResponse.id.toString(),\n\t\t\t\t\t\tprovider: provider,\n\t\t\t\t\t\tcreatedDate: new Date(issueResponse.created_on),\n\t\t\t\t\t\tupdatedDate: new Date(issueResponse.updated_on),\n\t\t\t\t\t\tstate: bitbucketIssueStateToState(issueResponse.state),\n\t\t\t\t\t\tclosed: issueResponse.state === 'closed',\n\t\t\t\t\t\ttitle: issueResponse.title,\n\t\t\t\t\t\turl: issueResponse.links.html.href,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestById(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\treturn await this.getServerPullRequest(provider, token, owner, repo, id, baseUrl);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * A Bitbucket Cloud pull request by id. Strict, unlike {@link getIssueOrPullRequest}: `undefined` means a 404,\n\t * and every other failure throws, so the answer can be cached as a proven absence.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t\t/** The calling read, stamped on the row. */\n\t\t\tprojection?: PullRequestProjection;\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst pr = await this.request<BitbucketPullRequest>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/pullrequests/${id}?fields=%2Bvalues.reviewers,%2Bvalues.participants`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions?.deferFailure,\n\t\t\t);\n\t\t\tif (pr == null) throw new Error(`Bitbucket returned no pull request for ${owner}/${repo}#${id}`);\n\n\t\t\treturn fromBitbucketPullRequest(pr, provider, {\n\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\tprojection: options?.projection,\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return undefined;\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * The change state of pull requests `ids` in `owner/repo` — the cheap check behind the batch read's etags — in ONE\n\t * request for up to {@link bitbucketEtagFieldsMaxIds} ids, selecting only what {@link getPullRequest}'s row reads\n\t * into its etag (plus the participants and reviewers for the `reviewDecision` include). One entry per input id, in\n\t * order.\n\t *\n\t * Strict like {@link getPullRequest}: `undefined` is a PROVEN ABSENCE, for an id missing from a complete page, or\n\t * for every id when the repository is a 404, as each id's own read would be. A page with more (`next`) and every\n\t * other failure throw. Every state is asked for, since the list answers only open pull requests by default.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, ids) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tids: ids.length,\n\t\t}),\n\t})\n\tpublic async getPullRequestsEtagFields(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tids: readonly number[],\n\t\tbaseUrl: string,\n\t\toptions: { etagIncludes: readonly PullRequestEtagInclude[]; deferFailure?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<(BitbucketPullRequestEtagNode | undefined)[]> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (!ids.length) return [];\n\t\tif (ids.length > bitbucketEtagFieldsMaxIds) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot read more than ${bitbucketEtagFieldsMaxIds} Bitbucket pull requests in one request`,\n\t\t\t);\n\t\t}\n\n\t\tconst fields = [\n\t\t\t'values.id',\n\t\t\t'values.state',\n\t\t\t'values.draft',\n\t\t\t'values.updated_on',\n\t\t\t'values.source.commit.hash',\n\t\t\t'next',\n\t\t];\n\t\tif (options.etagIncludes.includes('reviewDecision')) {\n\t\t\tfields.push(\n\t\t\t\t'values.participants.approved',\n\t\t\t\t'values.participants.state',\n\t\t\t\t'values.participants.participated_on',\n\t\t\t\t'values.reviewers.uuid',\n\t\t\t);\n\t\t}\n\n\t\tconst params = new URLSearchParams({\n\t\t\tq: `id IN (${ids.join(',')})`,\n\t\t\tfields: fields.join(','),\n\t\t\tpagelen: String(ids.length),\n\t\t});\n\t\tfor (const state of ['OPEN', 'MERGED', 'DECLINED', 'SUPERSEDED'] satisfies BitbucketPullRequestState[]) {\n\t\t\tparams.append('state', state);\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values?: BitbucketPullRequestEtagNode[]; next?: string }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/pullrequests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}`);\n\t\t\t}\n\t\t\tif (response.next != null) throw new Error(`Bitbucket returned a partial page of ${owner}/${repo}`);\n\n\t\t\tconst byId = new Map(response.values.map(pr => [pr.id, pr]));\n\t\t\treturn ids.map(id => byId.get(id));\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return ids.map(() => undefined);\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * A Bitbucket Data Center pull request by id. Strict, unlike {@link getServerPullRequestById}: `undefined` means\n\t * a 404, and every other failure throws, so the answer can be cached as a proven absence.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t\t/** The calling read, stamped on the row. */\n\t\t\tprojection?: PullRequestProjection;\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst pr = await this.request<BitbucketServerPullRequest>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${owner}/repos/${repo}/pull-requests/${id}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions?.deferFailure,\n\t\t\t);\n\t\t\tif (pr == null) throw new Error(`Bitbucket returned no pull request for ${owner}/${repo}#${id}`);\n\n\t\t\treturn fromProviderPullRequest(normalizeBitbucketServerPullRequest(pr), provider, {\n\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\tprojection: options?.projection,\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return undefined;\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * Every Bitbucket Cloud pull request into `owner/repo` whose source is `branch`, in any state, newest first, at\n\t * most `limit`: from the repository itself when `headOwner` is omitted, otherwise from a fork in the `headOwner`\n\t * workspace. Keyed on the source branch NAME, so a merged pull request whose branch was deleted still matches.\n\t *\n\t * Strict like {@link getPullRequest}: a 404 (a missing repository) is an empty list, and every other failure\n\t * throws.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequestsForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t\toptions: {\n\t\t\theadOwner?: string;\n\t\t\tlimit: number;\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t},\n\t): Promise<{ pullRequests: PullRequest[]; truncated: boolean }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst escapedBranch = branch.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n\t\tconst params = new URLSearchParams({\n\t\t\t// Every state named: Bitbucket answers only OPEN pull requests unless asked for the others.\n\t\t\tq: `source.branch.name=\"${escapedBranch}\" AND (state=\"OPEN\" OR state=\"MERGED\" OR state=\"DECLINED\" OR state=\"SUPERSEDED\")`,\n\t\t\tsort: '-updated_on',\n\t\t\tpagelen: String(options.limit),\n\t\t\tfields: '+values.reviewers,+values.participants',\n\t\t});\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketPullRequest[]; next?: string }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/pullrequests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}:${branch}`);\n\t\t\t}\n\n\t\t\tconst headOwner = options.headOwner;\n\t\t\tconst { values, truncated } = selectBranchPullRequests(response.values, {\n\t\t\t\tmatchesHead: pr => {\n\t\t\t\t\tconst source = pr.source.repository;\n\t\t\t\t\tif (pr.source.branch.name !== branch || source == null) return false;\n\t\t\t\t\tif (headOwner == null) return source.uuid === pr.destination.repository.uuid;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\tsource.uuid !== pr.destination.repository.uuid &&\n\t\t\t\t\t\tequalsIgnoreCase(source.full_name.split('/')[0], headOwner)\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tupdatedAt: pr => Date.parse(pr.updated_on),\n\t\t\t\tmap: pr =>\n\t\t\t\t\tfromBitbucketPullRequest(pr, provider, {\n\t\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\t\tprojection: 'batch',\n\t\t\t\t\t}),\n\t\t\t\tlimit: options.limit,\n\t\t\t\tmore: response.next != null,\n\t\t\t});\n\t\t\treturn { pullRequests: values, truncated: truncated };\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return { pullRequests: [], truncated: false };\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * Every Bitbucket Data Center pull request whose source is `branch` in `owner/repo` and whose target is that same\n\t * repository, in any state, newest first, at most `limit`. Asked of the repository the branch lives in\n\t * (`direction=OUTGOING`), which is why a fork's pull requests can't be found through the repository they target.\n\t *\n\t * Strict like {@link getServerPullRequest}: a 404 (a missing repository) is an empty list, and every other\n\t * failure throws.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestsForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t\toptions: { limit: number; currentAccount?: { id: string; username?: string }; deferFailure?: boolean },\n\t): Promise<{ pullRequests: PullRequest[]; truncated: boolean }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst ref = `refs/heads/${branch}`;\n\t\tconst params = new URLSearchParams({\n\t\t\tat: ref,\n\t\t\tdirection: 'OUTGOING',\n\t\t\tstate: 'ALL',\n\t\t\torder: 'NEWEST',\n\t\t\tlimit: String(options.limit),\n\t\t});\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketServerPullRequest[]; isLastPage?: boolean }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${encodeURIComponent(owner)}/repos/${encodeURIComponent(repo)}/pull-requests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}:${branch}`);\n\t\t\t}\n\n\t\t\tconst { values, truncated } = selectBranchPullRequests(response.values, {\n\t\t\t\t// `OUTGOING` also lists this branch's pull requests into other repositories, e.g. the upstream of a\n\t\t\t\t// repository that is itself a fork.\n\t\t\t\tmatchesHead: pr => pr.fromRef.id === ref && pr.fromRef.repository.id === pr.toRef.repository.id,\n\t\t\t\tupdatedAt: pr => pr.updatedDate,\n\t\t\t\tmap: pr =>\n\t\t\t\t\tfromProviderPullRequest(normalizeBitbucketServerPullRequest(pr), provider, {\n\t\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\t\tprojection: 'batch',\n\t\t\t\t\t}),\n\t\t\t\tlimit: options.limit,\n\t\t\t\tmore: response.isLastPage !== true,\n\t\t\t});\n\t\t\treturn { pullRequests: values, truncated: truncated };\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return { pullRequests: [], truncated: false };\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, workspace) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tworkspace: workspace,\n\t\t}),\n\t})\n\tasync getRepositoriesForWorkspace(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tworkspace: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t): Promise<RepositoryMetadata[] | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tinterface BitbucketRepositoriesResponse {\n\t\t\t\tsize: number;\n\t\t\t\tpage: number;\n\t\t\t\tpagelen: number;\n\t\t\t\tnext?: string;\n\t\t\t\tprevious?: string;\n\t\t\t\tvalues: BitbucketRepository[];\n\t\t\t}\n\n\t\t\tconst response = await this.request<BitbucketRepositoriesResponse>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t`repositories/${workspace}?role=contributor&fields=%2Bvalues.parent.workspace`, // field=+<field> must be encoded as field=%2B<field>\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\tif (response) {\n\t\t\t\treturn response.values.map(repo => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tprovider: provider,\n\t\t\t\t\t\towner: repo.workspace.slug,\n\t\t\t\t\t\tname: repo.slug,\n\t\t\t\t\t\tisFork: Boolean(repo.parent),\n\t\t\t\t\t\tparent: repo.parent\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\towner: repo.parent.workspace.slug,\n\t\t\t\t\t\t\t\t\tname: repo.parent.slug,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getRepositoryMetadata(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (response == null) return undefined;\n\n\t\t\tlet parent: RepositoryMetadata['parent'];\n\t\t\tif (response.parent != null) {\n\t\t\t\t// Derive the parent from `full_name` (\"owner/repo\") rather than `parent.workspace`, which is a\n\t\t\t\t// requested field expansion Bitbucket doesn't always honor (an unexpanded parent would otherwise\n\t\t\t\t// throw and null out the whole result).\n\t\t\t\t// `full_name` is \"owner/repo\"; only report a parent when both parts are present so a malformed\n\t\t\t\t// value doesn't produce a parent with an undefined owner/name while `isFork` stays true.\n\t\t\t\tconst [parentOwner, parentName] = response.parent.full_name.split('/');\n\t\t\t\tif (parentOwner && parentName) {\n\t\t\t\t\tparent = { owner: parentOwner, name: parentName };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\towner: response.workspace.slug,\n\t\t\t\tname: response.slug,\n\t\t\t\tisFork: response.parent != null,\n\t\t\t\tparent: parent,\n\t\t\t} satisfies RepositoryMetadata;\n\t\t} catch (ex) {\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getDefaultBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<DefaultBranch | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst name = response?.mainbranch?.name;\n\t\t\tif (name == null) return undefined;\n\n\t\t\treturn { provider: provider, name: name } satisfies DefaultBranch;\n\t\t} catch (ex) {\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate getRepository(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbaseUrl: string,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<BitbucketRepository | undefined> {\n\t\treturn this.request<BitbucketRepository>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}`,\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getServerPullRequestForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketServerPullRequest[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${owner}/repos/${repo}/commits/${rev}/pull-requests`, //?fields=${fieldsParam}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst prResponse = response?.values?.reduce<BitbucketServerPullRequest | undefined>(\n\t\t\t\t(acc, pr) => (!acc || pr.updatedDate > acc.updatedDate ? pr : acc),\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tif (!prResponse) return undefined;\n\n\t\t\tconst providersPr = normalizeBitbucketServerPullRequest(prResponse);\n\t\t\tconst gitlensPr = fromProviderPullRequest(providersPr, provider, { projection: 'point' });\n\t\t\treturn gitlensPr;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getPullRequestForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst fields = [\n\t\t\t\t'+values.*',\n\t\t\t\t'+values.destination.repository',\n\t\t\t\t'+values.destination.branch.*',\n\t\t\t\t'+values.destination.commit.*',\n\t\t\t\t'+values.source.repository.*',\n\t\t\t\t'+values.source.branch.*',\n\t\t\t\t'+values.source.commit.*',\n\t\t\t];\n\t\t\tconst fieldsParam = encodeURIComponent(fields.join(','));\n\t\t\tconst response = await this.request<{ values: BitbucketPullRequest[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/commit/${rev}/pullrequests?fields=${fieldsParam}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst pr = response?.values?.reduce<BitbucketPullRequest | undefined>(\n\t\t\t\t(acc, pr) => (!acc || pr.updated_on > acc.updated_on ? pr : acc),\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tif (!pr) return undefined;\n\t\t\treturn fromBitbucketPullRequest(pr, provider, { projection: 'point' });\n\t\t} catch (ex) {\n\t\t\tif (ex.original instanceof ProviderFetchError) {\n\t\t\t\tconst json = await ex.original.response.json();\n\t\t\t\tif (json?.error === 'Invalid or unknown installation') {\n\t\t\t\t\t// TODO: In future get it on to home as an warning on the integration itself \"this integration has issues\"\n\t\t\t\t\t// even user suppresses the message it's still visible with some capacity. It's a broader thing to get other errors.\n\t\t\t\t\tconst commitWebUrl = `https://bitbucket.org/${owner}/${repo}/commits/${rev}`;\n\t\t\t\t\tthis.config.onBitbucketCommitLinksAppMissing?.(commitWebUrl);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getAccountForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst commit = await this.request<BitbucketCommit>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/commit/${rev}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!commit) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { name, email } = parseRawBitbucketAuthor(commit.author.raw);\n\t\t\tconst commitAuthor: CommitAuthor = {\n\t\t\t\tprovider: provider,\n\t\t\t\tid: commit.author.user?.account_id,\n\t\t\t\tusername: commit.author.user?.nickname,\n\t\t\t\tname: commit.author.user?.display_name || name,\n\t\t\t\temail: email,\n\t\t\t\tavatarUrl: commit.author.user?.links?.avatar?.href,\n\t\t\t};\n\t\t\tif (commitAuthor.id != null && commitAuthor.username != null) {\n\t\t\t\treturn {\n\t\t\t\t\t...commitAuthor,\n\t\t\t\t\tid: commitAuthor.id,\n\t\t\t\t} satisfies Account;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...commitAuthor,\n\t\t\t\tid: undefined,\n\t\t\t\tusername: undefined,\n\t\t\t} satisfies UnidentifiedAuthor;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getServerAccountForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst commit = await this.request<BitbucketServerCommit>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${owner}/repos/${repo}/commits/${rev}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!commit?.author) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (commit.author.id != null) {\n\t\t\t\treturn {\n\t\t\t\t\tprovider: provider,\n\t\t\t\t\tid: commit.author.id.toString(),\n\t\t\t\t\tusername: commit.author.name,\n\t\t\t\t\tname: commit.author.name,\n\t\t\t\t\temail: commit.author.emailAddress,\n\t\t\t\t\tavatarUrl: commit.author?.avatarUrl,\n\t\t\t\t} satisfies Account;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\tid: undefined,\n\t\t\t\tusername: undefined,\n\t\t\t\tname: commit.author.name,\n\t\t\t\temail: commit.author.emailAddress,\n\t\t\t\tavatarUrl: undefined,\n\t\t\t} satisfies UnidentifiedAuthor;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async request<T>(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tbaseUrl: string,\n\t\troute: string,\n\t\toptions?: { method: RequestInit['method'] } & Record<string, unknown>,\n\t\tscope?: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal | undefined,\n\t\tdeferFailure?: boolean,\n\t): Promise<T | undefined> {\n\t\tconst { accessToken } = token;\n\t\tconst url = `${baseUrl}/${route}`;\n\n\t\tlet rsp: Response;\n\t\ttry {\n\t\t\tconst sw = maybeStopWatch(`[BITBUCKET] ${options?.method ?? 'GET'} ${url}`, { log: { onlyExit: true } });\n\n\t\t\ttry {\n\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\trsp = await this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () =>\n\t\t\t\t\tthis.config.fetch(url, {\n\t\t\t\t\t\theaders: { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json' },\n\t\t\t\t\t\tsignal: cancellation,\n\t\t\t\t\t\t...options,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tif (rsp.ok) {\n\t\t\t\t\treturn (await rsp.json()) as T;\n\t\t\t\t}\n\n\t\t\t\t// Reads the body so the 403 branch below can tell a throttled request from a permission failure.\n\t\t\t\tthrow await ProviderFetchError.fromResponse('Bitbucket', rsp);\n\t\t\t} finally {\n\t\t\t\tsw?.stop();\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof ProviderFetchError || ex.name === 'AbortError') {\n\t\t\t\tthis.handleRequestError(provider, token, ex, scope, deferFailure);\n\t\t\t} else if (Logger.isDebugging) {\n\t\t\t\tthis.config.onError?.(`Bitbucket request failed: ${ex.message}`);\n\t\t\t}\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tprivate handleRequestError(\n\t\tprovider: Provider | undefined,\n\t\ttoken: TokenWithInfo,\n\t\tex: ProviderFetchError | (Error & { name: 'AbortError' }),\n\t\tscope: ScopedLogger | undefined,\n\t\tdeferFailure: boolean | undefined,\n\t): void {\n\t\tif (ex.name === 'AbortError' || !(ex instanceof ProviderFetchError)) throw new CancellationError(ex);\n\n\t\tconst { accessToken, ...tokenInfo } = token;\n\t\tswitch (ex.status) {\n\t\t\tcase 404: // Not found\n\t\t\tcase 410: // Gone\n\t\t\tcase 422: // Unprocessable Entity\n\t\t\t\tthrow new RequestNotFoundError(ex);\n\t\t\tcase 401: // Unauthorized\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Unauthorized, ex);\n\t\t\tcase 429: // Too Many Requests\n\t\t\t\tthrow toRateLimitError(ex, accessToken);\n\t\t\tcase 403: // Forbidden\n\t\t\t\t// Bitbucket returns 403 for both a permission failure and a throttled request (\"API rate limit\n\t\t\t\t// exceeded\"), so the message is the discriminant. Reporting a throttle as `auth` would prompt the\n\t\t\t\t// user to re-authenticate a healthy connection instead of retrying (see `isRateLimitResponse`).\n\t\t\t\tif (isRateLimitResponse(ex)) throw toRateLimitError(ex, accessToken);\n\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Forbidden, ex);\n\t\t\tcase 500: // Internal Server Error\n\t\t\t\tscope?.error(ex);\n\t\t\t\tif (ex.response != null) {\n\t\t\t\t\treportRequestFailure(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tex,\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tthis.config.onRequestFailed?.(\n\t\t\t\t\t\t\t\tprovider == null || provider.id === 'bitbucket'\n\t\t\t\t\t\t\t\t\t? l10n.t(\n\t\t\t\t\t\t\t\t\t\t\t'{0} failed to respond and might be experiencing issues. Please visit the [Bitbucket status page](https://bitbucket.status.atlassian.com/) for more information.',\n\t\t\t\t\t\t\t\t\t\t\tprovider?.name ?? 'Bitbucket',\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t: l10n.t('{0} failed to respond and might be experiencing issues.', provider.name),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tdeferFailure,\n\t\t\t\t\t\ttoken.connectionId,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase 502: // Bad Gateway\n\t\t\t\tscope?.error(ex);\n\t\t\t\t// TODO: Learn the Bitbucket API docs and put it in order:\n\t\t\t\t// if (ex.message.includes('timeout')) {\n\t\t\t\t// \tprovider?.trackRequestException();\n\t\t\t\t// \tvoid showIntegrationRequestTimedOutWarningMessage(provider?.name ?? 'Bitbucket');\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (ex.status >= 400 && ex.status < 500) throw new RequestClientError(ex);\n\t\t\t\tbreak;\n\t\t}\n\n\t\tscope?.error(ex);\n\t\tif (Logger.isDebugging) {\n\t\t\tthis.config.onError?.(\n\t\t\t\t`Bitbucket request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Wires a {@link BitbucketApi} from the full runtime context, mapping `ctx` down to the narrow config. */\nexport function createBitbucketApi(ctx: IntegrationServiceContext): BitbucketApi {\n\tconst config: ProviderApiConfig = {\n\t\t...baseProviderApiConfig(ctx),\n\t\tonBitbucketCommitLinksAppMissing: revLink => ctx.hooks?.ui?.onBitbucketCommitLinksAppMissing?.(revLink),\n\t};\n\n\treturn new BitbucketApi(config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoDA,SAAS,mBAAmB,IAAsB;CACjD,OAAO,qBAAqB,GAAG,EAAE,KAAK,GAAG,oBAAoB,sBAAsB,GAAG,SAAS,WAAW;AAC3G;AAEA,IAAa,eAAb,MAAgD;CAGlB;CAF7B;CAEA,YAAY,QAA4C;EAA3B,KAAA,SAAA;EAC5B,KAAK,cAAc,OAAO,wBAAwB,KAAK,YAAY,CAAC;CACrE;CAEA,UAAgB;EACf,KAAK,aAAa,QAAQ;CAC3B;CAEA,cAA4B,CAAC;CAE7B,MAUa,wBACZ,UACA,OACA,OACA,MACA,QACA,SACmC;EACnC,MAAM,QAAQ,gBAAgB;EAE9B,MAAM,WAAW,MAAM,KAAK,QAM3B,UACA,OACA,SACA,gBAAgB,MAAM,GAAG,KAAK,sCAAsC,OAAO,sDAC3E,EACC,QAAQ,MACT,GACA,KACD;EAEA,IAAI,CAAC,UAAU,QAAQ,QACtB;EAED,OAAO,yBAAyB,SAAS,OAAO,IAAI,UAAU,EAAE,YAAY,QAAQ,CAAC;CACtF;CAEA,MAUa,8BACZ,UACA,OACA,OACA,MACA,QACA,SACmC;EACnC,MAAM,QAAQ,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us/integrations/src/providers/bitbucket/bitbucket.ts"],"sourcesContent":["import { captureReadNodes, copyReadProvenance, createReadCapture } from '@gitkraken/provider-apis/read-provenance';\nimport * as l10n from '@vscode/l10n';\nimport { reportRequestFailure } from '@gitlens/git/errors.js';\nimport type { Account, CommitAuthor, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequest, PullRequestProjection } from '@gitlens/git/models/pullRequest.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { trace } from '@gitlens/utils/decorators/log.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { ScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { equalsIgnoreCase } from '@gitlens/utils/string.js';\nimport type { TokenWithInfo } from '../../authentication/models.js';\nimport type { IntegrationServiceContext } from '../../context.js';\nimport {\n\tAuthenticationError,\n\tAuthenticationErrorReason,\n\tisRateLimitResponse,\n\tProviderFetchError,\n\tRequestClientError,\n\tRequestNotFoundError,\n\ttoRateLimitError,\n} from '../../errors.js';\nimport type { PullRequestEtagInclude } from '../../models/integration.js';\nimport type { ProviderApiConfig } from '../apiConfig.js';\nimport { baseProviderApiConfig } from '../apiConfig.js';\nimport type { BitbucketServerCommit, BitbucketServerPullRequest } from '../bitbucket-server/models.js';\nimport { normalizeBitbucketServerPullRequest } from '../bitbucket-server/models.js';\nimport { fromProviderPullRequest } from '../models.js';\nimport { selectBranchPullRequests } from '../utils/providerPaging.js';\nimport type {\n\tBitbucketCommit,\n\tBitbucketIssue,\n\tBitbucketPullRequest,\n\tBitbucketPullRequestEtagNode,\n\tBitbucketPullRequestState,\n\tBitbucketRepository,\n} from './models.js';\nimport {\n\tbitbucketEtagFieldsMaxIds,\n\tbitbucketIssueStateToState,\n\tfromBitbucketIssue,\n\tfromBitbucketPullRequest,\n\tparseRawBitbucketAuthor,\n} from './models.js';\n\n/** `handleRequestError` maps 410 and 422 to the same error as a 404, but only a 404 proves the resource absent. */\nfunction isNotFoundResponse(ex: unknown): boolean {\n\treturn RequestNotFoundError.is(ex) && ex.original instanceof ProviderFetchError && ex.original.status === 404;\n}\n\nexport class BitbucketApi implements Disposable {\n\tprivate readonly _disposable: Disposable | undefined;\n\n\tconstructor(private readonly config: ProviderApiConfig) {\n\t\tthis._disposable = config.onConfigChanged?.(() => this.resetCaches());\n\t}\n\n\tdispose(): void {\n\t\tthis._disposable?.dispose();\n\t}\n\n\tprivate resetCaches(): void {}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequestForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketPullRequest[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}/pullrequests?q=source.branch.name=\"${branch}\"&fields=%2Bvalues.reviewers,%2Bvalues.participants`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn fromBitbucketPullRequest(response.values[0], provider, { projection: 'point' });\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketServerPullRequest[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`projects/${owner}/repos/${repo}/pull-requests?at=refs/heads/${branch}&direction=OUTGOING&state=ALL`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst providersPr = normalizeBitbucketServerPullRequest(response.values[0]);\n\t\tconst gitlensPr = fromProviderPullRequest(providersPr, provider, { projection: 'point' });\n\t\treturn gitlensPr;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, userUuid, owner, repo, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tuserUuid: userUuid,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getUsersIssuesForRepo(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tuserUuid: string,\n\t\towner: string,\n\t\trepo: string,\n\t\tbaseUrl: string,\n\t): Promise<Issue[] | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst query = encodeURIComponent(`assignee.uuid=\"${userUuid}\" OR reporter.uuid=\"${userUuid}\"`);\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketIssue[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}/issues?q=${query}`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn response.values.map(issue => fromBitbucketIssue(issue, provider, 'account'));\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getIssue(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t): Promise<Issue | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.request<BitbucketIssue>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/issues/${id}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\tif (response) {\n\t\t\t\treturn fromBitbucketIssue(response, provider, 'point');\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getIssueOrPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\ttype?: IssueOrPullRequestType;\n\t\t},\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (options?.type === undefined || options?.type === 'pullrequest') {\n\t\t\ttry {\n\t\t\t\tconst pr = await this.getPullRequest(provider, token, owner, repo, id, baseUrl);\n\t\t\t\tif (pr != null) return pr;\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tif (options?.type === undefined || options?.type === 'issue') {\n\t\t\ttry {\n\t\t\t\tconst issueResponse = await this.request<BitbucketIssue>(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\t`repositories/${owner}/${repo}/issues/${id}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t},\n\t\t\t\t\tscope,\n\t\t\t\t);\n\n\t\t\t\tif (issueResponse) {\n\t\t\t\t\tconst result: IssueOrPullRequest = {\n\t\t\t\t\t\tid: issueResponse.id.toString(),\n\t\t\t\t\t\ttype: 'issue',\n\t\t\t\t\t\tnodeId: issueResponse.id.toString(),\n\t\t\t\t\t\tprovider: provider,\n\t\t\t\t\t\tcreatedDate: new Date(issueResponse.created_on),\n\t\t\t\t\t\tupdatedDate: new Date(issueResponse.updated_on),\n\t\t\t\t\t\tstate: bitbucketIssueStateToState(issueResponse.state),\n\t\t\t\t\t\tclosed: issueResponse.state === 'closed',\n\t\t\t\t\t\ttitle: issueResponse.title,\n\t\t\t\t\t\turl: issueResponse.links.html.href,\n\t\t\t\t\t};\n\t\t\t\t\treturn copyReadProvenance(result, issueResponse);\n\t\t\t\t}\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestById(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\treturn await this.getServerPullRequest(provider, token, owner, repo, id, baseUrl);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * A Bitbucket Cloud pull request by id. Strict, unlike {@link getIssueOrPullRequest}: `undefined` means a 404,\n\t * and every other failure throws, so the answer can be cached as a proven absence.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t\t/** The calling read, stamped on the row. */\n\t\t\tprojection?: PullRequestProjection;\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst pr = await this.request<BitbucketPullRequest>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/pullrequests/${id}?fields=%2Bvalues.reviewers,%2Bvalues.participants`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions?.deferFailure,\n\t\t\t);\n\t\t\tif (pr == null) throw new Error(`Bitbucket returned no pull request for ${owner}/${repo}#${id}`);\n\n\t\t\treturn fromBitbucketPullRequest(pr, provider, {\n\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\tprojection: options?.projection,\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return undefined;\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * The change state of pull requests `ids` in `owner/repo` — the cheap check behind the batch read's etags — in ONE\n\t * request for up to {@link bitbucketEtagFieldsMaxIds} ids, selecting only what {@link getPullRequest}'s row reads\n\t * into its etag (plus the participants and reviewers for the `reviewDecision` include). One entry per input id, in\n\t * order.\n\t *\n\t * Strict like {@link getPullRequest}: `undefined` is a PROVEN ABSENCE, for an id missing from a complete page, or\n\t * for every id when the repository is a 404, as each id's own read would be. A page with more (`next`) and every\n\t * other failure throw. Every state is asked for, since the list answers only open pull requests by default.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, ids) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tids: ids.length,\n\t\t}),\n\t})\n\tpublic async getPullRequestsEtagFields(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tids: readonly number[],\n\t\tbaseUrl: string,\n\t\toptions: { etagIncludes: readonly PullRequestEtagInclude[]; deferFailure?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<(BitbucketPullRequestEtagNode | undefined)[]> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (!ids.length) return [];\n\t\tif (ids.length > bitbucketEtagFieldsMaxIds) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot read more than ${bitbucketEtagFieldsMaxIds} Bitbucket pull requests in one request`,\n\t\t\t);\n\t\t}\n\n\t\tconst fields = [\n\t\t\t'values.id',\n\t\t\t'values.state',\n\t\t\t'values.draft',\n\t\t\t'values.updated_on',\n\t\t\t'values.source.commit.hash',\n\t\t\t'next',\n\t\t];\n\t\tif (options.etagIncludes.includes('reviewDecision')) {\n\t\t\tfields.push(\n\t\t\t\t'values.participants.approved',\n\t\t\t\t'values.participants.state',\n\t\t\t\t'values.participants.participated_on',\n\t\t\t\t'values.reviewers.uuid',\n\t\t\t);\n\t\t}\n\n\t\tconst params = new URLSearchParams({\n\t\t\tq: `id IN (${ids.join(',')})`,\n\t\t\tfields: fields.join(','),\n\t\t\tpagelen: String(ids.length),\n\t\t});\n\t\tfor (const state of ['OPEN', 'MERGED', 'DECLINED', 'SUPERSEDED'] satisfies BitbucketPullRequestState[]) {\n\t\t\tparams.append('state', state);\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values?: BitbucketPullRequestEtagNode[]; next?: string }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/pullrequests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}`);\n\t\t\t}\n\t\t\tif (response.next != null) throw new Error(`Bitbucket returned a partial page of ${owner}/${repo}`);\n\n\t\t\tconst byId = new Map(response.values.map(pr => [pr.id, pr]));\n\t\t\treturn ids.map(id => byId.get(id));\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return ids.map(() => undefined);\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * A Bitbucket Data Center pull request by id. Strict, unlike {@link getServerPullRequestById}: `undefined` means\n\t * a 404, and every other failure throws, so the answer can be cached as a proven absence.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t\t/** The calling read, stamped on the row. */\n\t\t\tprojection?: PullRequestProjection;\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst pr = await this.request<BitbucketServerPullRequest>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${owner}/repos/${repo}/pull-requests/${id}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions?.deferFailure,\n\t\t\t);\n\t\t\tif (pr == null) throw new Error(`Bitbucket returned no pull request for ${owner}/${repo}#${id}`);\n\n\t\t\treturn fromProviderPullRequest(normalizeBitbucketServerPullRequest(pr), provider, {\n\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\tprojection: options?.projection,\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return undefined;\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * Every Bitbucket Cloud pull request into `owner/repo` whose source is `branch`, in any state, newest first, at\n\t * most `limit`: from the repository itself when `headOwner` is omitted, otherwise from a fork in the `headOwner`\n\t * workspace. Keyed on the source branch NAME, so a merged pull request whose branch was deleted still matches.\n\t *\n\t * Strict like {@link getPullRequest}: a 404 (a missing repository) is an empty list, and every other failure\n\t * throws.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequestsForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t\toptions: {\n\t\t\theadOwner?: string;\n\t\t\tlimit: number;\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t},\n\t): Promise<{ pullRequests: PullRequest[]; truncated: boolean }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst escapedBranch = branch.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n\t\tconst params = new URLSearchParams({\n\t\t\t// Every state named: Bitbucket answers only OPEN pull requests unless asked for the others.\n\t\t\tq: `source.branch.name=\"${escapedBranch}\" AND (state=\"OPEN\" OR state=\"MERGED\" OR state=\"DECLINED\" OR state=\"SUPERSEDED\")`,\n\t\t\tsort: '-updated_on',\n\t\t\tpagelen: String(options.limit),\n\t\t\tfields: '+values.reviewers,+values.participants',\n\t\t});\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketPullRequest[]; next?: string }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/pullrequests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}:${branch}`);\n\t\t\t}\n\n\t\t\tconst headOwner = options.headOwner;\n\t\t\tconst { values, truncated } = selectBranchPullRequests(response.values, {\n\t\t\t\tmatchesHead: pr => {\n\t\t\t\t\tconst source = pr.source.repository;\n\t\t\t\t\tif (pr.source.branch.name !== branch || source == null) return false;\n\t\t\t\t\tif (headOwner == null) return source.uuid === pr.destination.repository.uuid;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\tsource.uuid !== pr.destination.repository.uuid &&\n\t\t\t\t\t\tequalsIgnoreCase(source.full_name.split('/')[0], headOwner)\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tupdatedAt: pr => Date.parse(pr.updated_on),\n\t\t\t\tmap: pr =>\n\t\t\t\t\tfromBitbucketPullRequest(pr, provider, {\n\t\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\t\tprojection: 'batch',\n\t\t\t\t\t}),\n\t\t\t\tlimit: options.limit,\n\t\t\t\tmore: response.next != null,\n\t\t\t});\n\t\t\treturn { pullRequests: values, truncated: truncated };\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return { pullRequests: [], truncated: false };\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * Every Bitbucket Data Center pull request whose source is `branch` in `owner/repo` and whose target is that same\n\t * repository, in any state, newest first, at most `limit`. Asked of the repository the branch lives in\n\t * (`direction=OUTGOING`), which is why a fork's pull requests can't be found through the repository they target.\n\t *\n\t * Strict like {@link getServerPullRequest}: a 404 (a missing repository) is an empty list, and every other\n\t * failure throws.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestsForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t\toptions: { limit: number; currentAccount?: { id: string; username?: string }; deferFailure?: boolean },\n\t): Promise<{ pullRequests: PullRequest[]; truncated: boolean }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst ref = `refs/heads/${branch}`;\n\t\tconst params = new URLSearchParams({\n\t\t\tat: ref,\n\t\t\tdirection: 'OUTGOING',\n\t\t\tstate: 'ALL',\n\t\t\torder: 'NEWEST',\n\t\t\tlimit: String(options.limit),\n\t\t});\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketServerPullRequest[]; isLastPage?: boolean }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${encodeURIComponent(owner)}/repos/${encodeURIComponent(repo)}/pull-requests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}:${branch}`);\n\t\t\t}\n\n\t\t\tconst { values, truncated } = selectBranchPullRequests(response.values, {\n\t\t\t\t// `OUTGOING` also lists this branch's pull requests into other repositories, e.g. the upstream of a\n\t\t\t\t// repository that is itself a fork.\n\t\t\t\tmatchesHead: pr => pr.fromRef.id === ref && pr.fromRef.repository.id === pr.toRef.repository.id,\n\t\t\t\tupdatedAt: pr => pr.updatedDate,\n\t\t\t\tmap: pr =>\n\t\t\t\t\tfromProviderPullRequest(normalizeBitbucketServerPullRequest(pr), provider, {\n\t\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\t\tprojection: 'batch',\n\t\t\t\t\t}),\n\t\t\t\tlimit: options.limit,\n\t\t\t\tmore: response.isLastPage !== true,\n\t\t\t});\n\t\t\treturn { pullRequests: values, truncated: truncated };\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return { pullRequests: [], truncated: false };\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, workspace) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tworkspace: workspace,\n\t\t}),\n\t})\n\tasync getRepositoriesForWorkspace(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tworkspace: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t): Promise<RepositoryMetadata[] | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tinterface BitbucketRepositoriesResponse {\n\t\t\t\tsize: number;\n\t\t\t\tpage: number;\n\t\t\t\tpagelen: number;\n\t\t\t\tnext?: string;\n\t\t\t\tprevious?: string;\n\t\t\t\tvalues: BitbucketRepository[];\n\t\t\t}\n\n\t\t\tconst response = await this.request<BitbucketRepositoriesResponse>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t`repositories/${workspace}?role=contributor&fields=%2Bvalues.parent.workspace`, // field=+<field> must be encoded as field=%2B<field>\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\tif (response) {\n\t\t\t\treturn response.values.map(repo => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tprovider: provider,\n\t\t\t\t\t\towner: repo.workspace.slug,\n\t\t\t\t\t\tname: repo.slug,\n\t\t\t\t\t\tisFork: Boolean(repo.parent),\n\t\t\t\t\t\tparent: repo.parent\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\towner: repo.parent.workspace.slug,\n\t\t\t\t\t\t\t\t\tname: repo.parent.slug,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getRepositoryMetadata(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (response == null) return undefined;\n\n\t\t\tlet parent: RepositoryMetadata['parent'];\n\t\t\tif (response.parent != null) {\n\t\t\t\t// Derive the parent from `full_name` (\"owner/repo\") rather than `parent.workspace`, which is a\n\t\t\t\t// requested field expansion Bitbucket doesn't always honor (an unexpanded parent would otherwise\n\t\t\t\t// throw and null out the whole result).\n\t\t\t\t// `full_name` is \"owner/repo\"; only report a parent when both parts are present so a malformed\n\t\t\t\t// value doesn't produce a parent with an undefined owner/name while `isFork` stays true.\n\t\t\t\tconst [parentOwner, parentName] = response.parent.full_name.split('/');\n\t\t\t\tif (parentOwner && parentName) {\n\t\t\t\t\tparent = { owner: parentOwner, name: parentName };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\towner: response.workspace.slug,\n\t\t\t\tname: response.slug,\n\t\t\t\tisFork: response.parent != null,\n\t\t\t\tparent: parent,\n\t\t\t} satisfies RepositoryMetadata;\n\t\t} catch (ex) {\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getDefaultBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<DefaultBranch | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst name = response?.mainbranch?.name;\n\t\t\tif (name == null) return undefined;\n\n\t\t\treturn { provider: provider, name: name } satisfies DefaultBranch;\n\t\t} catch (ex) {\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate getRepository(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbaseUrl: string,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<BitbucketRepository | undefined> {\n\t\treturn this.request<BitbucketRepository>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}`,\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getServerPullRequestForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketServerPullRequest[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${owner}/repos/${repo}/commits/${rev}/pull-requests`, //?fields=${fieldsParam}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst prResponse = response?.values?.reduce<BitbucketServerPullRequest | undefined>(\n\t\t\t\t(acc, pr) => (!acc || pr.updatedDate > acc.updatedDate ? pr : acc),\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tif (!prResponse) return undefined;\n\n\t\t\tconst providersPr = normalizeBitbucketServerPullRequest(prResponse);\n\t\t\tconst gitlensPr = fromProviderPullRequest(providersPr, provider, { projection: 'point' });\n\t\t\treturn gitlensPr;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getPullRequestForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst fields = [\n\t\t\t\t'+values.*',\n\t\t\t\t'+values.destination.repository',\n\t\t\t\t'+values.destination.branch.*',\n\t\t\t\t'+values.destination.commit.*',\n\t\t\t\t'+values.source.repository.*',\n\t\t\t\t'+values.source.branch.*',\n\t\t\t\t'+values.source.commit.*',\n\t\t\t];\n\t\t\tconst fieldsParam = encodeURIComponent(fields.join(','));\n\t\t\tconst response = await this.request<{ values: BitbucketPullRequest[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/commit/${rev}/pullrequests?fields=${fieldsParam}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst pr = response?.values?.reduce<BitbucketPullRequest | undefined>(\n\t\t\t\t(acc, pr) => (!acc || pr.updated_on > acc.updated_on ? pr : acc),\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tif (!pr) return undefined;\n\t\t\treturn fromBitbucketPullRequest(pr, provider, { projection: 'point' });\n\t\t} catch (ex) {\n\t\t\tif (ex.original instanceof ProviderFetchError) {\n\t\t\t\tconst json = await ex.original.response.json();\n\t\t\t\tif (json?.error === 'Invalid or unknown installation') {\n\t\t\t\t\t// TODO: In future get it on to home as an warning on the integration itself \"this integration has issues\"\n\t\t\t\t\t// even user suppresses the message it's still visible with some capacity. It's a broader thing to get other errors.\n\t\t\t\t\tconst commitWebUrl = `https://bitbucket.org/${owner}/${repo}/commits/${rev}`;\n\t\t\t\t\tthis.config.onBitbucketCommitLinksAppMissing?.(commitWebUrl);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getAccountForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst commit = await this.request<BitbucketCommit>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/commit/${rev}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!commit) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { name, email } = parseRawBitbucketAuthor(commit.author.raw);\n\t\t\tconst commitAuthor: CommitAuthor = {\n\t\t\t\tprovider: provider,\n\t\t\t\tid: commit.author.user?.account_id,\n\t\t\t\tusername: commit.author.user?.nickname,\n\t\t\t\tname: commit.author.user?.display_name || name,\n\t\t\t\temail: email,\n\t\t\t\tavatarUrl: commit.author.user?.links?.avatar?.href,\n\t\t\t};\n\t\t\tif (commitAuthor.id != null && commitAuthor.username != null) {\n\t\t\t\treturn {\n\t\t\t\t\t...commitAuthor,\n\t\t\t\t\tid: commitAuthor.id,\n\t\t\t\t} satisfies Account;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...commitAuthor,\n\t\t\t\tid: undefined,\n\t\t\t\tusername: undefined,\n\t\t\t} satisfies UnidentifiedAuthor;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getServerAccountForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst commit = await this.request<BitbucketServerCommit>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${owner}/repos/${repo}/commits/${rev}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!commit?.author) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (commit.author.id != null) {\n\t\t\t\treturn {\n\t\t\t\t\tprovider: provider,\n\t\t\t\t\tid: commit.author.id.toString(),\n\t\t\t\t\tusername: commit.author.name,\n\t\t\t\t\tname: commit.author.name,\n\t\t\t\t\temail: commit.author.emailAddress,\n\t\t\t\t\tavatarUrl: commit.author?.avatarUrl,\n\t\t\t\t} satisfies Account;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\tid: undefined,\n\t\t\t\tusername: undefined,\n\t\t\t\tname: commit.author.name,\n\t\t\t\temail: commit.author.emailAddress,\n\t\t\t\tavatarUrl: undefined,\n\t\t\t} satisfies UnidentifiedAuthor;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async request<T>(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tbaseUrl: string,\n\t\troute: string,\n\t\toptions?: { method: RequestInit['method'] } & Record<string, unknown>,\n\t\tscope?: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal | undefined,\n\t\tdeferFailure?: boolean,\n\t): Promise<T | undefined> {\n\t\tconst { accessToken } = token;\n\t\tconst url = `${baseUrl}/${route}`;\n\n\t\tlet rsp: Response;\n\t\ttry {\n\t\t\tconst sw = maybeStopWatch(`[BITBUCKET] ${options?.method ?? 'GET'} ${url}`, { log: { onlyExit: true } });\n\n\t\t\ttry {\n\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\tconst capture = createReadCapture();\n\t\t\t\trsp = await this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () =>\n\t\t\t\t\tthis.config.fetch(url, {\n\t\t\t\t\t\theaders: { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json' },\n\t\t\t\t\t\tsignal: cancellation,\n\t\t\t\t\t\t...options,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tif (rsp.ok) {\n\t\t\t\t\treturn captureReadNodes(await rsp.json(), capture) as T;\n\t\t\t\t}\n\n\t\t\t\t// Reads the body so the 403 branch below can tell a throttled request from a permission failure.\n\t\t\t\tthrow await ProviderFetchError.fromResponse('Bitbucket', rsp);\n\t\t\t} finally {\n\t\t\t\tsw?.stop();\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof ProviderFetchError || ex.name === 'AbortError') {\n\t\t\t\tthis.handleRequestError(provider, token, ex, scope, deferFailure);\n\t\t\t} else if (Logger.isDebugging) {\n\t\t\t\tthis.config.onError?.(`Bitbucket request failed: ${ex.message}`);\n\t\t\t}\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tprivate handleRequestError(\n\t\tprovider: Provider | undefined,\n\t\ttoken: TokenWithInfo,\n\t\tex: ProviderFetchError | (Error & { name: 'AbortError' }),\n\t\tscope: ScopedLogger | undefined,\n\t\tdeferFailure: boolean | undefined,\n\t): void {\n\t\tif (ex.name === 'AbortError' || !(ex instanceof ProviderFetchError)) throw new CancellationError(ex);\n\n\t\tconst { accessToken, ...tokenInfo } = token;\n\t\tswitch (ex.status) {\n\t\t\tcase 404: // Not found\n\t\t\tcase 410: // Gone\n\t\t\tcase 422: // Unprocessable Entity\n\t\t\t\tthrow new RequestNotFoundError(ex);\n\t\t\tcase 401: // Unauthorized\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Unauthorized, ex);\n\t\t\tcase 429: // Too Many Requests\n\t\t\t\tthrow toRateLimitError(ex, accessToken);\n\t\t\tcase 403: // Forbidden\n\t\t\t\t// Bitbucket returns 403 for both a permission failure and a throttled request (\"API rate limit\n\t\t\t\t// exceeded\"), so the message is the discriminant. Reporting a throttle as `auth` would prompt the\n\t\t\t\t// user to re-authenticate a healthy connection instead of retrying (see `isRateLimitResponse`).\n\t\t\t\tif (isRateLimitResponse(ex)) throw toRateLimitError(ex, accessToken);\n\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Forbidden, ex);\n\t\t\tcase 500: // Internal Server Error\n\t\t\t\tscope?.error(ex);\n\t\t\t\tif (ex.response != null) {\n\t\t\t\t\treportRequestFailure(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tex,\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tthis.config.onRequestFailed?.(\n\t\t\t\t\t\t\t\tprovider == null || provider.id === 'bitbucket'\n\t\t\t\t\t\t\t\t\t? l10n.t(\n\t\t\t\t\t\t\t\t\t\t\t'{0} failed to respond and might be experiencing issues. Please visit the [Bitbucket status page](https://bitbucket.status.atlassian.com/) for more information.',\n\t\t\t\t\t\t\t\t\t\t\tprovider?.name ?? 'Bitbucket',\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t: l10n.t('{0} failed to respond and might be experiencing issues.', provider.name),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tdeferFailure,\n\t\t\t\t\t\ttoken.connectionId,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase 502: // Bad Gateway\n\t\t\t\tscope?.error(ex);\n\t\t\t\t// TODO: Learn the Bitbucket API docs and put it in order:\n\t\t\t\t// if (ex.message.includes('timeout')) {\n\t\t\t\t// \tprovider?.trackRequestException();\n\t\t\t\t// \tvoid showIntegrationRequestTimedOutWarningMessage(provider?.name ?? 'Bitbucket');\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (ex.status >= 400 && ex.status < 500) throw new RequestClientError(ex);\n\t\t\t\tbreak;\n\t\t}\n\n\t\tscope?.error(ex);\n\t\tif (Logger.isDebugging) {\n\t\t\tthis.config.onError?.(\n\t\t\t\t`Bitbucket request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Wires a {@link BitbucketApi} from the full runtime context, mapping `ctx` down to the narrow config. */\nexport function createBitbucketApi(ctx: IntegrationServiceContext): BitbucketApi {\n\tconst config: ProviderApiConfig = {\n\t\t...baseProviderApiConfig(ctx),\n\t\tonBitbucketCommitLinksAppMissing: revLink => ctx.hooks?.ui?.onBitbucketCommitLinksAppMissing?.(revLink),\n\t};\n\n\treturn new BitbucketApi(config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqDA,SAAS,mBAAmB,IAAsB;CACjD,OAAO,qBAAqB,GAAG,EAAE,KAAK,GAAG,oBAAoB,sBAAsB,GAAG,SAAS,WAAW;AAC3G;AAEA,IAAa,eAAb,MAAgD;CAGlB;CAF7B;CAEA,YAAY,QAA4C;EAA3B,KAAA,SAAA;EAC5B,KAAK,cAAc,OAAO,wBAAwB,KAAK,YAAY,CAAC;CACrE;CAEA,UAAgB;EACf,KAAK,aAAa,QAAQ;CAC3B;CAEA,cAA4B,CAAC;CAE7B,MAUa,wBACZ,UACA,OACA,OACA,MACA,QACA,SACmC;EACnC,MAAM,QAAQ,gBAAgB;EAE9B,MAAM,WAAW,MAAM,KAAK,QAM3B,UACA,OACA,SACA,gBAAgB,MAAM,GAAG,KAAK,sCAAsC,OAAO,sDAC3E,EACC,QAAQ,MACT,GACA,KACD;EAEA,IAAI,CAAC,UAAU,QAAQ,QACtB;EAED,OAAO,yBAAyB,SAAS,OAAO,IAAI,UAAU,EAAE,YAAY,QAAQ,CAAC;CACtF;CAEA,MAUa,8BACZ,UACA,OACA,OACA,MACA,QACA,SACmC;EACnC,MAAM,QAAQ,gBAAgB;EAE9B,MAAM,WAAW,MAAM,KAAK,QAM3B,UACA,OACA,SACA,YAAY,MAAM,SAAS,KAAK,+BAA+B,OAAO,gCACtE,EACC,QAAQ,MACT,GACA,KACD;EAEA,IAAI,CAAC,UAAU,QAAQ,QACtB;EAGD,MAAM,cAAc,oCAAoC,SAAS,OAAO,EAAE;EAE1E,OADkB,wBAAwB,aAAa,UAAU,E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