@sourcegraph/code-host-integration 0.0.76 → 0.0.77
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.
package/package.json
CHANGED
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
alwaysNil
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
`,variables:{...e,source:Ci.CODEHOSTINTEGRATION,argument:e.argument&&JSON.stringify(e.argument),publicArgument:e.publicArgument&&JSON.stringify(e.publicArgument)},mightContainPrivateInfo:!1}).subscribe({error:e=>{}})})({name:e,userCookieID:o,url:this.sourcegraphURL,argument:{platform:this.platform,version:this.version,...t},publicArgument:{platform:this.platform,version:this.version,...n}},this.requestGraphQL)}async log(e,t,n){switch(e){case"findReferences":await this.logEvent(e,t,n,Ui.CODEINTELINTEGRATIONREFS);break;case"goToDefinition":case"goToDefinition.preloaded":case"hover":await this.logEvent(e,t,n,Ui.CODEINTELINTEGRATION);break;default:await this.logEvent(e,t,n)}}async logViewEvent(e,t){await this.logEvent(`View${e}`,t)}async logPageView(e,t,n){await this.logEvent(`${e}Viewed`,t,n)}}const ql={allowErrorReporting:!1,sendTelemetry:!0,experimentalLinkPreviews:!1,experimentalTextFieldCompletion:!1,clickToGoToDefinition:!1},Vl=({get:e,set:t})=>({set:t,enable:e=>t(e,!0),disable:e=>t(e,!1),async isEnabled(t){const n=await e(t);return"boolean"==typeof n?n:ql[t]},async toggle(n){const r=await e(n);return await t(n,!r),!r}});const $l=Vl({get:async function(e){const{featureFlags:t={}}=await qc.sync.get();return t[e]},set:async function(e,t){const{featureFlags:n}=await qc.sync.get("featureFlags");await qc.sync.set({featureFlags:{...n,[e]:t}})}}),zl=Vl({get:async e=>{const t=localStorage.getItem(e);return null===t?void 0:"true"===t},set:async(e,t)=>{localStorage.setItem(e,String(t))}}),Hl=Pc?zl:$l,Gl={sendTelemetry:!1,allowErrorReporting:!1,experimentalLinkPreviews:!1,experimentalTextFieldCompletion:!1,clickToGoToDefinition:!1},Ql=e=>({...Gl,...e}),Wl=()=>(Ic?Vc("sync","featureFlags"):z(void 0)).pipe(H(Ql));function Kl(e){return Wl().pipe(H((t=>t[e])),Qe())}const Zl=e=>jc(e).pipe(H((t=>!(Lc()&&e)||!Uc(t)))),Yl=e=>Oe([Zl(e),Kl("sendTelemetry")]).pipe(H((([e,t])=>!!e||t)));function Jl(){const{host:e,pathname:t}=location,[n,r]=t.slice(1).split("/");if(!n||!r)throw new ll(`Could not parse repoName from Bitbucket Cloud url: ${location.href}`);return`${e}/${n}/${r}`}const Xl={getCodeElementFromTarget:e=>e.closest(".view-line > span"),getLineNumberFromCodeElement:e=>{if(!document.querySelector(".line-number"))throw new Error("No line number elements found on the currently viewed page");const t=e.closest(".react-monaco-editor-container");if(!t)throw new Error("No editor found");const n=e.closest(".view-line"),r=[...t.querySelectorAll(".view-line")].findIndex((e=>e===n)),o=t.querySelectorAll(".line-number")[r];if(o){var i,a,s;let e=parseInt(null!==(i=o.dataset.lineNum)&&void 0!==i?i:"",10);if(!isNaN(e))return e;if(e=parseInt(null!==(a=null===(s=o.textContent)||void 0===s?void 0:s.trim())&&void 0!==a?a:"",10),!isNaN(e))return e}throw new Error("Could not find line number")},getLineElementFromLineNumber:eu,getCodeElementFromLineNumber:(e,t)=>{const n=eu(e,t);if(!n)return null;const r=n.querySelector(":scope > span");return r||console.error(`Could not find code element inside .view-line container for line #${t}`),r}};function eu(e,t){let n=e.querySelector(`[data-line-num="${t}"]`);if(!n)for(const o of e.querySelectorAll(".line-number")){var r;if(parseInt(null!==(r=o.textContent)&&void 0!==r?r:"",10)===t){n=o;break}}if(!n)return console.error(`Could not find line number element for line #${t}`),null;const o=[...e.querySelectorAll(".line-number")].findIndex((e=>e===n)),i=e.querySelectorAll(".view-line")[o];return i||console.error(`Could not find line element for line #${t}`),i}function tu(e,t,n){var r,o;const i=null===(r=e.querySelector(`[aria-label="${"base"===n?"From":"To"} line ${t}"]`))||void 0===r||null===(o=r.closest(".line-wrapper"))||void 0===o?void 0:o.querySelector(".code-component");if(!i)throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`);return i}const nu={getCodeElementFromTarget:e=>e.closest(".code-diff"),getLineNumberFromCodeElement:e=>{var t;const n=e.closest(".line-wrapper"),r=null==n?void 0:n.querySelectorAll(".line-number-permalink");if(!r||0===r.length)throw new Error("Could not find line number permalink(s) for code element");const o=r[r.length-1],i=parseInt(null!==(t=o.textContent)&&void 0!==t?t:"",10);if(!isNaN(i))return i;throw new Error("Could not find line number for code element")},getLineElementFromLineNumber:tu,getCodeElementFromLineNumber:(e,t,n)=>{var r;return null===(r=tu(e,t,n))||void 0===r?void 0:r.querySelector(".code-diff")},getDiffCodePart:e=>{var t,n,r;const o=e.closest(".code-component"),i=null==o?void 0:o.querySelector(".line-type");if(null!=i&&null!==(t=i.textContent)&&void 0!==t&&t.includes("+"))return"head";if(null!=i&&null!==(n=i.textContent)&&void 0!==n&&n.includes("+"))return"base";if(!e.closest(".side-by-side"))return"head";const a=e.closest(".line-wrapper");if(null!=a&&a.id)return null!=a&&a.id.includes("oldline")?"base":"head";return 0===[...(null==a||null===(r=a.parentElement)||void 0===r?void 0:r.childNodes)||[]].findIndex((e=>e===a))?"base":"head"},isFirstCharacterDiffIndicator:()=>!1};function ru(e,t,n){var r;const o=null===(r=e.querySelector(`[data-${"base"===n?"f":"t"}num="${t}"]`))||void 0===r?void 0:r.closest(".udiff-line");if(!o)throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`);return o}const ou={getCodeElementFromTarget:e=>e.closest(".source"),getLineNumberFromCodeElement:e=>{const t=e.closest(".udiff-line");if(!t)throw new Error("Could not find line element");const n=t.querySelector(".line-numbers");if(!n)throw new Error("Could not find line numbers element");const r=null==n?void 0:n.dataset.tnum;if(r){const e=parseInt(r,10);if(!isNaN(e))return e}const o=null==n?void 0:n.dataset.fnum;if(o){const e=parseInt(o,10);if(!isNaN(e))return e}throw new Error("Could not find line number for code element")},getLineElementFromLineNumber:ru,getCodeElementFromLineNumber:(e,t,n)=>{var r;return null===(r=ru(e,t,n))||void 0===r?void 0:r.querySelector(".source")},getDiffCodePart:e=>{const t=e.closest(".udiff-line");if(!t)throw new Error("Could not find line element for code element");return t.classList.contains("deletion")?"base":"head"},isFirstCharacterDiffIndicator:()=>!0},iu=e=>e.replace("//","/"),au=["modified","renamed","removed","added"];function su(){const e=Jl(),t=location.pathname.match(/src\/(.*?)\/(.*)/);if(!t)throw new Error("Unable to determine revision or file path");const n=decodeURIComponent(t[1]),r=decodeURIComponent(t[2]),o=function(){const e=['a[type="button"]',"a"];for(const t of e){const e=document.querySelectorAll(t);for(const t of e){const e=t.href.match(/full-commit\/([\da-f]{40})\//);if(e)return e[1]}}return null}();return{blob:{rawRepoName:e,revision:n,filePath:r,commitID:null!=o?o:n}}}function cu(e){const t=Jl(),n=function(e){const t=[...e.querySelectorAll('[data-qa="bk-file__header"] span')];for(const e of t)for(const t of au){var n;if(null!==(n=e.textContent)&&void 0!==n&&n.toLowerCase().includes(t))return t}return"modified"}(e),{base:r,head:o}=function(e,t){var n;const r=null===(n=e.querySelector('[data-qa="bk-filepath"]'))||void 0===n?void 0:n.cloneNode(!0),o=null==r?void 0:r.textContent;if(!(r instanceof HTMLElement&&o))throw new Error("Could not find breadcrumbs component for code view");if("added"===t)return{head:o};if("removed"===t)return{base:o};if("modified"===t)return{base:o,head:o};const i="<>SEPARATOR<>",a=r.querySelectorAll('[aria-label="arrow"]');for(const e of a)e.textContent=i;const[s,c,l]=r.textContent.split(/[{}]/),[u,f]=c.split(i);return{base:iu(s+u+l),head:iu(s+f+l)}}(e,n),{baseRevision:i,headRevision:a}=function(){var e,t;const n=document.querySelector('[data-qa="pr-branches-and-state-styles"]');if(!n)throw new Error("Could not find branches element");const r=[...n.querySelectorAll('[aria-hidden="true"]')];if(2!==r.length)throw new Error("Expected source and destination branch elements");const o=null!==(e=r[0].textContent)&&void 0!==e?e:"";return{baseRevision:null!==(t=r[1].textContent)&&void 0!==t?t:"",headRevision:o}}();return"added"===n?{head:{rawRepoName:t,filePath:o,commitID:a,revision:a}}:"removed"===n?{base:{rawRepoName:t,filePath:r,commitID:i,revision:i}}:{head:{rawRepoName:t,filePath:o,commitID:a,revision:a},base:{rawRepoName:t,filePath:r,commitID:i,revision:i}}}function lu(e){const t=Jl(),n=function(e){const t=e.querySelector(".diff-entry-lozenge");for(const e of au){var n;if(null!=t&&null!==(n=t.textContent)&&void 0!==n&&n.toLowerCase().includes(e))return e}return"modified"}(e),{head:r,base:o}=function(e,t){var n;const r=null===(n=e.querySelector(".filename"))||void 0===n?void 0:n.cloneNode(!0);if(!r)throw new Error("Could not find breadcrumbs component for code view");for(const e of r.childNodes)e instanceof HTMLSpanElement&&(e.textContent=null);const o=r.textContent.trim();if("added"===t)return{head:o};if("removed"===t)return{base:o};if("modified"===t)return{base:o,head:o};const[i,a,s]=o.split(/[{}]/).map((e=>e.trim())),[c,l]=a.split("\u2192").map((e=>e.trim()));return{base:iu(i+c+s),head:iu(i+l+s)}}(e,n),{baseCommitID:i,headCommitID:a}=function(){var e;const t=null===(e=document.querySelector('[title="Parent commit"]'))||void 0===e?void 0:e.href.match(/\/commits\/(.*)/);if(!t)throw new Error("Could not determine base commit ID");const n=t[1],r=window.location.href.match(/\/commits\/(.*)/);if(!r)throw new Error("Could not determine head commit ID");return{baseCommitID:n,headCommitID:r[1]}}();return"added"===n?{head:{rawRepoName:t,filePath:r,commitID:a}}:"removed"===n?{base:{rawRepoName:t,filePath:o,commitID:i}}:{head:{rawRepoName:t,filePath:r,commitID:a},base:{rawRepoName:t,filePath:o,commitID:i}}}const uu="codeHost-module__icon_3KtzB",fu="codeHost-module__commit-container_8Jft-";function pu(e){const t=e.querySelector(".sg-toolbar-mount");if(t)return t;const n=e.querySelector('[data-testid="file-actions"');if(!n)throw new Error("Unable to find mount location");const r=document.createElement("div");return r.classList.add("sg-toolbar-mount"),n.prepend(r),r}function du(e){const t=e.querySelector(".sg-toolbar-mount");if(t)return t;const n=e.querySelector(".diff-actions");if(!n)throw new Error("Unable to find mount location");n.classList.add(fu);const r=document.createElement("div");return r.classList.add("sg-toolbar-mount"),n.prepend(r),r}const hu={type:"bitbucket-cloud",name:"Bitbucket Cloud",codeViewResolvers:[{selector:e=>{const t=e.querySelector('[data-qa="bk-file__header"]'),n=e.querySelector('[data-qa="bk-file__content"]');if(!t||!n)return null;let r=t;for(;!r.contains(n);){if(!r.parentElement)return null;r=r.parentElement}return[r]},resolveView:e=>function({pathname:e}){return/\/pull-requests\/\d+/.test(e)}(window.location)?{element:e,getToolbarMount:pu,dom:nu,resolveFileInfo:cu}:{element:e,getToolbarMount:pu,dom:Xl,resolveFileInfo:su}},{selector:".bb-udiff",resolveView:e=>({element:e,getToolbarMount:du,dom:ou,resolveFileInfo:lu})}],getContext:async function(){const e=Jl();return Promise.resolve({rawRepoName:e,revision:"",privateRepository:!1})},getViewContextOnSourcegraphMount:function(e){var t;const n="open-on-sourcegraph",r=he(e,'[data-qa="page-header-wrapper"] > div > div');if(!r)return null;let o=r.querySelector("#open-on-sourcegraph");if(o)return o;o=document.createElement("span"),o.id=n;const i=null===(t=r.childNodes[1])||void 0===t?void 0:t.childNodes[1].firstChild;return i instanceof HTMLElement?i.append(o):r.append(o),o},check:function(){return"bitbucket.org"===location.hostname},viewOnSourcegraphButtonClassProps:{className:"codeHost-module__open-on-sourcegraph_10lR9",iconClassName:uu},codeViewToolbarClassProps:{className:"codeHost-module__code-view-toolbar_N0wZ1",listItemClass:"codeHost-module__list-item_370zl",actionItemClass:"codeHost-module__code-view-toolbar-action-item_2p6Pr",actionItemPressedClass:"codeHost-module__pressed_1ksxF",actionItemIconClass:uu},hoverOverlayClassProps:{className:"codeHost-module__hover-overlay_2e1lQ",badgeClassName:"codeHost-module__badge_16Tsk",actionItemClassName:"codeHost-module__hover-overlay-action-item_39z-G",iconClassName:uu,contentClassName:"codeHost-module__content_eSBN7"},notificationClassNames:{1:"",2:"",3:"",4:"",5:""},codeViewsRequireTokenization:!0},mu=(e,t)=>n=>i()(e[n],t),gu=/\/projects\/([^/]+)\/repos\/([^/]+)\//;const vu=(e,t)=>{const n=e.querySelector(`[data-line-number="${t}"]`);if(!n)throw new Error(`Line ${t} not found in code view`);const r=n.closest(".line");if(!r)throw new Error("Could not find line elem for line element");return r},bu={getCodeElementFromTarget:e=>{const t=e.closest(".CodeMirror-line");return t?t.querySelector('span[role="presentation"]'):null},getLineNumberFromCodeElement:e=>{const t=e.closest(".line");if(!t)throw new Error("Could not find line containing code element");const n=t.querySelector(".line-locator");if(!n)throw new Error("Could not find the line number in a line container");const r=parseInt(n.dataset.lineNumber||"",10);if(isNaN(r))throw new TypeError("data-line-number not set on line number element");return r},getLineElementFromLineNumber:vu,getCodeElementFromLineNumber:(e,t)=>vu(e,t).querySelector('.CodeMirror-line span[role="presentation"]')},yu=(e,t,n)=>{for(const r of e.querySelectorAll(".line-number-"+("head"===n?"to":"from"))){const e=parseInt((r.textContent||"").trim(),10);if(!isNaN(e)&&e===t){const e=r.closest(".line");if(!e)throw new Error("Could not find lineElem from lineNumElem");return e}}throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`)},wu={getCodeElementFromTarget:bu.getCodeElementFromTarget,getLineNumberFromCodeElement:e=>{const t=e.closest(".line");if(!t)throw new Error("Could not find line containing code element");const n=t.querySelector(".line-number-to");if(n){const e=parseInt((n.textContent||"").trim(),10);if(!isNaN(e))return e}const r=t.querySelector(".line-number-from");if(r){const e=parseInt((r.textContent||"").trim(),10);if(!isNaN(e))return e}throw new Error("Could not find line number element for code element")},getLineElementFromLineNumber:yu,getCodeElementFromLineNumber:(e,t,n)=>yu(e,t,n).querySelector('.CodeMirror-line span[role="presentation"]'),getDiffCodePart:e=>{var t;if(!document.querySelector(".side-by-side-diff"))return e.closest(".line").classList.contains("removed")?"base":"head";return null!==(t=e.closest(".diff-editor").previousElementSibling)&&void 0!==t&&t.classList.contains("segment-connector-column")?"head":"base"},isFirstCharacterDiffIndicator:()=>!1},Eu=(e,t,n)=>{for(const i of e.querySelectorAll(".diff-line-number")){var r;const e=null===(r=i.textContent)||void 0===r?void 0:r.trim().split(" ")[0];if(!e)continue;const a=parseInt(e,10);if(!isNaN(a)&&a===t){var o;const e=null===(o=i.closest("tr"))||void 0===o?void 0:o.querySelector(`.diff-line[data-diff-line="${"head"===n?"TO":"FROM"}"]`);if(!e)throw new Error("Could not find lineElem from lineNumElem");return e}}throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`)},_u={getCodeElementFromTarget:e=>e.closest(".diff-line"),getLineNumberFromCodeElement:e=>{var t;const n=null===(t=e.closest("tr"))||void 0===t?void 0:t.querySelector(".diff-gutter .diff-line-number");if(n){const e=parseInt((n.textContent||"").trim(),10);if(!isNaN(e))return e}throw new Error("Could not find line number element for code element")},getDiffCodePart:e=>{var t;const n=null===(t=e.closest("tr"))||void 0===t?void 0:t.querySelectorAll(".diff-line");if(!n||0===n.length)throw new Error("Could not find diff lines for code element");if(1===n.length)return e.classList.contains("added-line")?"head":"base";const[r,o]=n;return e===r?"base":e===o?"head":e.classList.contains("removed-line")?"base":"head"},getLineElementFromLineNumber:Eu,getCodeElementFromLineNumber:Eu};var xu=n(11570),Su=n.n(xu);const Ou=(e,t,n)=>`${window.AJS?window.AJS.contextPath():window.location.origin}/rest/api/1.0/projects/${encodeURIComponent(e)}/repos/${t}${n}`,Tu=e=>ar(e,{selector:e=>ur(e).json()}),Cu=jo((({project:e,repoSlug:t,prID:n})=>Tu(Ou(e,t,`/pull-requests/${n}`)).pipe(H((({fromRef:e,toRef:t})=>({baseCommitID:t.latestCommit,headCommitID:e.latestCommit}))))),(({prID:e})=>e.toString())),ku=jo((({project:e,repoSlug:t,commitID:n})=>Tu(Ou(e,t,`/commits/${n}`)).pipe(H((({parents:e})=>Su()(e))),qe(Kn),H((({id:e})=>e)))),(({project:e,repoSlug:t,commitID:n})=>`${e}:${t}:${n}`)),Nu=["a.raw-view-link","a.source-view-link","a.mode-source"],Au=({repoSlug:e,project:t})=>[window.location.hostname,t,e].join("/"),Iu=e=>{const t=[];for(const n of Nu)try{const t=e.querySelector(n);if(!t)throw new Error(`Could not find selector ${n} in code view`);const r=new URL(t.href),o=r.pathname,i=o.match(/\/projects\/(.*?)\/repos\/(.*?)\/(?:browse|raw)\/(.*)$/);if(!i)throw new Error(`Path of link matching selector ${n} did not match path regex: ${o}`);const[,a,s,c]=i,l=r.searchParams.get("at");if(!l)throw new Error(`href of link matching selector ${n} did not have 'at' search param: ${r.href}`);const u=l.match(/refs\/heads\/(.*?)$/),f=u?u[1]:l;return{rawRepoName:Au({repoSlug:s,project:a}),filePath:decodeURIComponent(c),revision:f,project:a,repoSlug:s}}catch(e){t.push(e);continue}throw un(t)},Pu=(e="a.commitid")=>{const t=document.querySelector(e);if(!t)throw new Error("No element found matching a.commitid");const n=t.dataset.commitid;if(!n)throw new Error("Element matching a.commitid has no data-commitid");return n},Ru=e=>{const{rawRepoName:t,filePath:n,revision:r,project:o,repoSlug:i}=Iu(e);return{rawRepoName:t,filePath:n,revision:r,commitID:(()=>{const e=document.querySelector("span[data-revision-ref]");if(!e)throw new Error("Could not find span[data-revision-ref] element");try{const{latestCommit:t}=JSON.parse(e.dataset.revisionRef);return t}catch{throw new Error("Could not parse JSON from revision selector")}})(),project:o,repoSlug:i}},Du=({codeViewElement:e})=>e.querySelector(".change-type-lozenge"),Lu=({changeTypeElement:e})=>{if(!e)return"MODIFY";const t=[...e.classList].find((e=>/^change-type-[A-Z]+/.test(e)));if(!t)throw new Error("Could not detect change type from change type element");return t.replace(/^change-type-/,"")},Mu=({filePath:e,changeType:t,changeTypeElement:n})=>{if("ADD"!==t){if("MODIFY"===t||"DELETE"===t)return e;if("MOVE"===t||"RENAME"===t||"COPY"===t){if(!n)throw new Error(`Change type is ${t} but no change type indicator found`);const r=n.getAttribute("original-title");if(!r)throw new Error("Moved change type badge did not have original-title attribute");const o=document.createElement("span");o.innerHTML=r;const i=o.textContent;if("MOVE"===t||"COPY"===t){const e=i.split("\u2192")[0].trim();if(!e)throw new Error(`Unexpected move change type badge content "${i}"`);return e}if("RENAME"===t){const t=/Renamed from '(.+)'/,n=i.match(t);if(!n)throw new Error(`Rename change type badge content did not match ${t.toString()}: "${i}"`);return Aa.join(Aa.dirname(e),n[1])}}throw new Error(`Unexpected change type "${t}"`)}},ju=e=>{var t;const n=null!==(t=e.querySelector(".breadcrumbs"))&&void 0!==t?t:e.querySelector(".file-breadcrumbs");if(!n)throw new Error("Could not find diff code view breadcrumbs element through selector .breadcrumbs");const r=n.textContent;if(!r)throw new Error("Unexpected empty file path in breadcrumbs");const o=location.pathname.match(/\/projects\/(.*?)\/repos\/(.*?)\//);if(!o)throw new Error("Location did not match regexp");const[,i,a]=o,s=Au({project:i,repoSlug:a}),c=Du({codeViewElement:e}),l=Lu({changeTypeElement:c});return{changeType:l,rawRepoName:s,filePath:r,baseFilePath:Mu({changeTypeElement:c,changeType:l,filePath:r})||r,project:i,repoSlug:a}};const Fu=e=>{const t=ju(e),{rawRepoName:n,filePath:r,baseFilePath:o}=t,i=function(){const e=window.location.pathname.match(/pull-requests\/(\d*?)\/(diff|overview|commits)/);if(!e)throw new Error(`Could not parse PR ID from pathname: ${window.location.pathname}`);return parseInt(e[1],10)}();return Cu({...t,prID:i}).pipe(H((({headCommitID:e,baseCommitID:t})=>({head:{rawRepoName:n,filePath:r,commitID:e},base:{rawRepoName:n,filePath:o,commitID:t}}))))},Bu="codeHost-module__command-palette-button_1LPsz",Uu="codeHost-module__command-palette-popover_wqnFp",qu="codeHost-module__no-results_3Di26",Vu="codeHost-module__open-on-sourcegraph_i9J2G",$u="codeHost-module__sg-toolbar-mount_2Fbz5",zu="codeHost-module__code-view-toolbar_IVqgq",Hu="codeHost-module__action-nav-item_223JV",Gu="codeHost-module__action-nav-item-new-diff_23eTl",Qu="codeHost-module__action-item-new-diff_3Tuv4",Wu="codeHost-module__hover-action-item_9CC-W",Ku="codeHost-module__command-list-popover-button_3eptU",Zu=(e,t=".file-toolbar .secondary")=>{const n=e.querySelector(".sg-toolbar-mount");if(n)return n;const r=e.querySelector(t);if(!r)throw new Error("Unable to find mount location");const o=document.createElement("div");return o.classList.add("btn-group"),o.classList.add("sg-toolbar-mount"),o.classList.add($u),r.prepend(o),o},Yu=e=>({direction:t,codeView:n,position:r})=>{const o=e.getCodeElementFromLineNumber(n,r.line,r.part);if(!o)throw new Error("(adjustPosition) could not find code element for line provided");let i=0;for(const e of o.querySelectorAll("[cm-text]")){const t=e.getAttribute("cm-text")||"",n=e.textContent||"";i+=t.length-n.length}const a=t===Fn.ActualToCodeView?-1:1;return z({line:r.line,character:r.character+a*i})},Ju={getToolbarMount:Zu,dom:bu,resolveFileInfo:e=>({blob:Ru(e)}),getPositionAdjuster:()=>Yu(bu)},Xu={getToolbarMount:Zu,dom:wu,getPositionAdjuster:()=>Yu(wu),overrideTokenize:!0},ef={...Xu,resolveFileInfo:e=>{const{changeType:t,rawRepoName:n,filePath:r,commitID:o,baseFilePath:i,revision:a,...s}=(e=>{const{rawRepoName:t,project:n,repoSlug:r,filePath:o}=Iu(e),i=Pu(),a=Du({codeViewElement:e}),s=Lu({changeTypeElement:a});return{changeType:s,rawRepoName:t,filePath:o,baseFilePath:Mu({changeTypeElement:a,changeType:s,filePath:o})||o,commitID:i,project:n,repoSlug:r}})(e);return"ADD"===t?z({head:{rawRepoName:n,filePath:r,commitID:o}}):ku({commitID:o,...s}).pipe(H((e=>"DELETE"===t?{base:{rawRepoName:n,filePath:i,commitID:e}}:{base:{rawRepoName:n,filePath:i,commitID:e},head:{rawRepoName:n,filePath:r,commitID:o}})))}},tf={...Xu,resolveFileInfo:Fu},nf={...Xu,resolveFileInfo:e=>{const{rawRepoName:t,filePath:n,baseFilePath:r}=ju(e),{baseCommitID:o,headCommitID:i}=function(){const e=document.querySelector("#branch-compare .source-selector a.commitid[data-commitid]"),t=document.querySelector("#branch-compare .target-selector a.commitid[data-commitid]");if(!e||!t)throw new Error("Could not resolve Bitbucket compare diff spec");return{headCommitID:e.getAttribute("data-commitid"),baseCommitID:t.getAttribute("data-commitid")}}();return{base:{rawRepoName:t,filePath:r,commitID:i},head:{rawRepoName:t,filePath:n,commitID:o}}}},rf={...Xu,resolveFileInfo:e=>(e=>{const t=Pu(".commit-badge-oneline .commitid"),n=Pu(".commit-parents .commitid"),{rawRepoName:r,filePath:o,baseFilePath:i}=ju(e);return{head:{rawRepoName:r,filePath:o,commitID:t},base:{rawRepoName:r,filePath:i,commitID:n}}})(e)},of={selector:".change-view",resolveView:e=>({element:e,...af})},af={resolveFileInfo:Fu,getToolbarMount:e=>Zu(e,".change-header .diff-actions"),toolbarButtonProps:{listItemClass:Gu,actionItemClass:Qu},dom:_u};const sf="aui-icon",cf={[Qa]:"aui-message aui-message-info",[Wa]:"aui-message aui-message-success",[Ga]:"aui-message aui-message-info",[Ha]:"aui-message aui-message-warning",[za]:"aui-message aui-message-error"},lf={type:"bitbucket-server",name:"Bitbucket Server",check:()=>!!document.querySelector(".bitbucket-header-logo")||!!document.querySelector(".aui-header-logo.aui-header-logo-bitbucket"),codeViewResolvers:[{selector:".file-content",resolveView:e=>{const t=e.querySelector(".content-view");if(!t)return null;if(document.querySelector("#branch-compare"))return{element:e,...nf};if((({pathname:e})=>/\/projects\/[^/]+\/repos\/[^/]+\/commits\/\w+$/.test(e))(window.location))return{element:e,...rf};if(e.querySelector(".mode-toggle")){return t.classList.contains("diff-view")?{element:e,...ef}:{element:e,...Ju}}return(({pathname:e})=>/\/projects\/[^/]+\/repos\/[^/]+\/pull-requests\/\d+/.test(e))(window.location)?{element:e,...tf}:(console.error("Unknown code view",e),null)}},of],getCommandPaletteMount:e=>{const t=he(e,".aui-header-primary .aui-nav");if(!t)return null;const n=["command-palette-button",Bu];return t.querySelector(n.map((e=>`.${e}`)).join(""))||(()=>{const e=document.createElement("li");return e.className=n.join(" "),t.append(e),e})()},notificationClassNames:cf,commandPaletteClassProps:{buttonClassName:i()(Ku,"aui-alignment-target aui-alignment-abutted aui-alignment-abutted-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left"),buttonElement:"a",buttonOpenClassName:"aui-dropdown2-active active aui-alignment-enabled",showCaret:!1,popoverClassName:i()(Uu,"aui-dropdown2 aui-style-default aui-layer aui-dropdown2-in-header aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-enabled aui-alignment-abutted aui-alignment-abutted-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left"),popoverInnerClassName:"aui-dropdown2-section",formClassName:"aui",inputClassName:"text",resultsContainerClassName:"results",listClassName:"results-list",listItemClassName:"result",selectedListItemClassName:"focused",noResultsClassName:qu,iconClassName:sf},codeViewToolbarClassProps:{className:i()(zu,"aui-buttons"),actionItemClass:"aui-button",actionItemIconClass:"aui-icon",listItemClass:Hu},hoverOverlayClassProps:{className:"aui-dialog",actionItemClassName:i()("aui-button",Wu),getAlertClassName:mu(cf),iconClassName:sf},getViewContextOnSourcegraphMount:function(e){const t=he(e,".branch-selector-toolbar .aui-buttons");if(!t)return null;const n=t.querySelector("#open-on-sourcegraph");if(n)return n;const r=document.createElement("span");return r.id="open-on-sourcegraph",r.className=Vu,t.append(r),r},getContext:async function(){const e=function(e){const{hostname:t,pathname:n}=e,r=n.match(gu);if(!r)throw new Error(`location pathname does not match path regex: ${n}`);const[,o,i]=r;return{rawRepoName:`${t}/${o}/${i}`}}(window.location);let t={};try{t=function(){var e;const t=document.querySelector("#repository-layout-revision-selector .name[data-revision-ref]");if(!t)throw new Error("branchNameElement not found");const n=t.getAttribute("data-revision-ref");let r=null;if(n)try{r=JSON.parse(n)}catch{throw new Error(`Could not parse revisionRefStr: ${n}`)}if(null!==(e=r)&&void 0!==e&&e.latestCommit)return{revision:r.latestCommit};throw new Error(`revisionRefInfo is empty or has no latestCommit (revisionRefStr: ${String(n)})`)}()}catch{}return Promise.resolve({...e,...t,privateRepository:"bitbucket.org"!==window.location.hostname})},viewOnSourcegraphButtonClassProps:{className:"aui-button",iconClassName:sf},codeViewsRequireTokenization:!1};var uf=n(65291),ff=n.n(uf),pf=n(92674),df=n.n(pf),hf=n(26416),mf=n.n(hf);function gf(e){return new B((function(t){var n;try{n=e()}catch(e){return void t.error(e)}return(n?ee(n):Ne()).subscribe(t)}))}function vf(e){return t=>gf((()=>{const n=new Map;return t.pipe(wt(Me),ce(),tt((({removedNodes:e})=>{for(const t of e){if(!(t instanceof HTMLElement))continue;const e=n.get(t);if(e)e.subscriptions.unsubscribe(),n.delete(t);else for(const[e,r]of n.entries())t.contains(e)&&(r.subscriptions.unsubscribe(),n.delete(e))}})),oe((t=>ee(t.addedNodes).pipe(qe(Wn(HTMLElement)),oe((t=>ee(e).pipe(oe((({selector:e,resolveView:n})=>[...bf(t,e)].map((e=>{const t=n(e);return t&&{...t,subscriptions:new g}})))),qe(Kn),qe((e=>!n.has(e.element))),tt((e=>{n.set(e.element,e)})))))))))}))}function bf(e,t){if("string"==typeof t)return de(e,t);return t(e)||[]}const yf=/patchset (\d+)/i;function wf(e,t){return`refs/changes/${e.slice(-2).padStart(2,"0")}/${e}/${t}`}function Ef(e){var t,n;return null!==(t=null===(n=If(document.body,e))||void 0===n?void 0:n.textContent)&&void 0!==t?t:void 0}function _f(e){const t=yf.exec(e);if(null!=t&&t[1])return t[1]}function xf(){const e=new URL(window.location.href).pathname.split("/"),t=e.indexOf("c"),n=e.indexOf("+"),r=e.slice(t+1,n).join("/"),o=e[n+1],i=e[n+2],a=e.slice(n+3).join("/"),s=window.location.hostname+"/"+r,{basePatchsetId:c,headPatchsetId:l}=function(){var e,t;const n=null!==(e=Ef("#app >> #app-element >> gr-change-view >> #fileListHeader >> #rangeSelect >> #basePatchDropdown >> #triggerText"))&&void 0!==e?e:Ef("#app >> #app-element >> gr-diff-view >> #rangeSelect >> #basePatchDropdown >> #triggerText"),r=null!==(t=Ef("#app >> #app-element >> gr-change-view >> #fileListHeader >> #rangeSelect >> #patchNumDropdown >> #triggerText"))&&void 0!==t?t:Ef("#app >> #app-element >> gr-diff-view >> #rangeSelect >> #patchNumDropdown >> #triggerText");return{basePatchsetId:n&&_f(n),headPatchsetId:r&&_f(r)}}();return{repoName:s,changeId:o,patchsetId:l||i,filePath:a,basePatchsetId:c}}const Sf={selector(e){var t;if(e.matches("#diffTable"))return[e];const n=If(document,"#app >> #app-element >> gr-change-view >> #fileList"),r=[...(null==n||null===(t=n.shadowRoot)||void 0===t?void 0:t.querySelectorAll(".file-row.expanded"))||[]].map((e=>{const t=e.parentElement;if(t)return If(t,"gr-diff-host >> gr-diff >> #diffTable")}));return mf()(r)},resolveView(e){const t=Pf(e,".stickyArea");if(!t)return null;const n=t.querySelector(".file-row"),r=null==n?void 0:n.getAttribute("data-path");if(!r)return null;const o=xf();if(!o.patchsetId)return console.error("Sourcegraph: Cannot get Gerrit patchset ID"),null;const i=wf(o.changeId,o.patchsetId);let a;return a=o.basePatchsetId?wf(o.changeId,o.basePatchsetId):function(){var e,t,n;const r=If(document.body,"#app >> #app-element >> gr-change-view >> #metadata >> gr-commit-info");if(!r)return null;return null==r||null===(e=r.shadowRoot)||void 0===e||null===(t=e.querySelector(".container"))||void 0===t||null===(n=t.textContent)||void 0===n?void 0:n.trim()}()||i+"^",Df(e),{element:e,dom:Tf,resolveFileInfo(){const e={base:{filePath:r||"",rawRepoName:o.repoName,commitID:a},head:{filePath:r||"",rawRepoName:o.repoName,commitID:i}};return console.log("resolveFileListCodeView: fileInfo",e),e}}}},Of=(e,t,n)=>{const r="head"===n?"right":"left",o=e.querySelector(`td.lineNum.${r}[data-value="${t}"]`);if(!o)return null;const i=function(e,t){var n;const r=[...(null===(n=e.parentElement)||void 0===n?void 0:n.childNodes)||[]],o=r.slice(r.indexOf(e)+1);for(const e of o)if(e instanceof HTMLElement&&e.matches(t))return e;return null}(o,"td.content");return null==i?void 0:i.querySelector(".contentText")},Tf={getLineElementFromLineNumber:Of,getCodeElementFromLineNumber:Of,getCodeElementFromTarget:e=>{var t;const n=e.closest("td.content"),r=null==n||null===(t=n.closest("tr"))||void 0===t?void 0:t.querySelector("[data-line-number]");if(r){if("FILE"===r.getAttribute("data-line-number"))return null}return n},getLineNumberFromCodeElement:e=>{var t;const n=Af(e);if(!n)throw console.error(e),new TypeError("Could not find line number (no side)");const r=e.closest("td"),o=null==r||null===(t=r.parentElement)||void 0===t?void 0:t.querySelector(`.lineNum.${n}`),i=null==o?void 0:o.getAttribute("data-value");if(!i)throw new TypeError(`Could not find line number (${n})`);return parseInt(i,10)},getDiffCodePart:e=>{const t=Af(e);return"left"===t?"base":"right"===t?"head":(console.error("Cannot tell: base or head"),"base")}},Cf=[{selector(e){const t=If(document.body,"#app >> #app-element >> gr-diff-view >> #diffHost >> #diff >> #diffTable");return t?[t]:[]},resolveView(e){const t=xf();if(!t.patchsetId)return console.error("Sourcegraph: cannot find patchset ID"),null;const n=wf(t.changeId,t.patchsetId);let r=n+"^";return t.basePatchsetId&&(r=wf(t.changeId,t.basePatchsetId)),Df(e),{element:e,dom:Tf,getToolbarMount(e){var t;const n=null===(t=function(e){var t;const n=Pf(e,"gr-diff-view");return null==n||null===(t=n.shadowRoot)||void 0===t?void 0:t.querySelector("gr-fixed-panel .subHeader")}(e))||void 0===t?void 0:t.querySelector(".patchRangeLeft");if(!n)throw new Error("Could not find subheader");const r=n.querySelector(".sourcegraph-toolbar-mount");if(r)return r;const o=document.createElement("div");return o.classList.add("sourcegraph-toolbar-mount"),n.append(o),n.append(Rf(Lf)),o},resolveFileInfo(){const e={base:{filePath:t.filePath||"",rawRepoName:t.repoName,commitID:r},head:{filePath:t.filePath||"",rawRepoName:t.repoName,commitID:n}};return console.log("resolveFilePageCodeView: fileInfo",e),e}}}},Sf],kf={type:"gerrit",name:"Gerrit",codeViewResolvers:Cf,contentViewResolvers:[],nativeTooltipResolvers:[],codeViewsRequireTokenization:!0,observeMutations:(e,t,n)=>{let r=[];return Xc(1500).pipe(H((()=>{const{filePath:e=""}=xf(),t=[...Cf.map((e=>e.selector)),Nf].map((e=>[...bf(document.body,e)])).flat(),n=t.filter((t=>!df()(r,{element:t,filePath:e}))),o=r.filter((n=>!(n.filePath===e&&t.find((e=>e===n.element)))));for(const t of n)r.push({element:t,filePath:e});return r=r.filter((e=>!df()(o,e))),{addedNodes:n,removedNodes:o.map((e=>e.element))}})),qe((({addedNodes:e,removedNodes:t})=>!!e.length||!!t.length)),H((e=>[e])),Lo(),Bt())},getContext:async()=>{const{repoName:e,changeId:t,patchsetId:n}=xf();return Promise.resolve({privateRepository:!0,rawRepoName:e,revision:n&&wf(t,n)})},check:function(){return!!document.querySelector("gr-app#app")},notificationClassNames:{1:"",2:"",3:"",4:"",5:""},hoverOverlayClassProps:{className:"codeHost-module__hover-overlay_1jwSd"},codeViewToolbarClassProps:{className:"code-view-toolbar--gerrit",actionItemIconClass:"icon--gerrit"},viewOnSourcegraphButtonClassProps:{className:"open-on-sourcegraph--gerrit",iconClassName:"open-on-sourcegraph-icon--gerrit"},getViewContextOnSourcegraphMount:e=>{const t=ff()(Nf(e));if(!t)return null;const n=t.querySelector(".open-in-sourcegraph-mount");if(n)return n;const r=document.createElement("gr-button");return r.setAttribute("link","link"),r.classList.add("open-in-sourcegraph-mount"),t.prepend(r),t.append(Rf(Lf)),r}},Nf=()=>{const e=If(document.body,"#app >> #app-element >> gr-change-view >> #actions >> #secondaryActions");return e?[e]:null};function Af(e){var t,n;if("unified"===function(e){const t=e.closest("tr");return null!=t&&t.matches(".unified")?"unified":"side-by-side"}(e)){var r,o;return(null===(r=e.closest("tr"))||void 0===r||null===(o=r.querySelector("td.right"))||void 0===o?void 0:o.getAttribute("data-value"))?"right":"left"}return null!==(t=e.closest("td"))&&void 0!==t&&null!==(n=t.previousElementSibling)&&void 0!==n&&n.matches(".right")?"right":"left"}function If(e,t){var n;"string"==typeof t&&(t=t.split(">>"));let r=e;const o=t.slice(0,-1),i=t[t.length-1];for(const e of o){var a;if(!r)return null;r=(null===(a=r.querySelector(e))||void 0===a?void 0:a.shadowRoot)||null}return null===(n=r)||void 0===n?void 0:n.querySelector(i)}function Pf(e,t){for(;;){var n;const r=e.closest(t);if(r)return r;if(!(e=null===(n=e.getRootNode())||void 0===n?void 0:n.host)||e===document.getRootNode())return null}}function Rf(e){const t=document.createElement("style");return t.textContent=e,t}function Df(e){if(!e.querySelector("style.sourcegraph-injected-style")){const t=Rf(Mf);t.classList.add("sourcegraph-injected-style"),e.append(t)}}const Lf="\n.icon--gerrit {\n height: 1.3rem;\n width: 1.3rem;\n padding: 5px 4px;\n}\n.open-on-sourcegraph-icon--gerrit {\n height: 1rem;\n width: 1rem;\n}\n.open-on-sourcegraph--gerrit {\n text-decoration: none;\n}\n",Mf="\n.sourcegraph-document-highlight {\n background-color: var(--secondary);\n}\n.selection-highlight {\n background-color: var(--mark-bg);\n}\n";var jf,Ff,Bf=n(36021),Uf=n.n(Bf);!function(e){e.Ok="ok",e.Exited="exited",e.Crashed="crashed",e.Abnormal="abnormal"}(jf||(jf={})),function(e){e.Ok="ok",e.Errored="errored",e.Crashed="crashed"}(Ff||(Ff={}));var qf=n(97753),Vf=n(91698),$f=(0,qf.Rf)(),zf="Sentry Logger ",Hf=function(){function e(){this._enabled=!1}return e.prototype.disable=function(){this._enabled=!1},e.prototype.enable=function(){this._enabled=!0},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._enabled&&(0,qf.Cf)((function(){$f.console.log(zf+"[Log]: "+e.join(" "))}))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._enabled&&(0,qf.Cf)((function(){$f.console.warn(zf+"[Warn]: "+e.join(" "))}))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._enabled&&(0,qf.Cf)((function(){$f.console.error(zf+"[Error]: "+e.join(" "))}))},e}();$f.__SENTRY__=$f.__SENTRY__||{};var Gf,Qf=$f.__SENTRY__.logger||($f.__SENTRY__.logger=new Hf),Wf=n(59212);function Kf(e){return"[object Object]"===Object.prototype.toString.call(e)}function Zf(e){return Boolean(e&&e.then&&"function"==typeof e.then)}!function(e){e.PENDING="PENDING",e.RESOLVED="RESOLVED",e.REJECTED="REJECTED"}(Gf||(Gf={}));var Yf=function(){function e(e){var t=this;this._state=Gf.PENDING,this._handlers=[],this._resolve=function(e){t._setResult(Gf.RESOLVED,e)},this._reject=function(e){t._setResult(Gf.REJECTED,e)},this._setResult=function(e,n){t._state===Gf.PENDING&&(Zf(n)?n.then(t._resolve,t._reject):(t._state=e,t._value=n,t._executeHandlers()))},this._attachHandler=function(e){t._handlers=t._handlers.concat(e),t._executeHandlers()},this._executeHandlers=function(){if(t._state!==Gf.PENDING){var e=t._handlers.slice();t._handlers=[],e.forEach((function(e){e.done||(t._state===Gf.RESOLVED&&e.onfulfilled&&e.onfulfilled(t._value),t._state===Gf.REJECTED&&e.onrejected&&e.onrejected(t._value),e.done=!0)}))}};try{e(this._resolve,this._reject)}catch(e){this._reject(e)}}return e.resolve=function(t){return new e((function(e){e(t)}))},e.reject=function(t){return new e((function(e,n){n(t)}))},e.all=function(t){return new e((function(n,r){if(Array.isArray(t))if(0!==t.length){var o=t.length,i=[];t.forEach((function(t,a){e.resolve(t).then((function(e){i[a]=e,0===(o-=1)&&n(i)})).then(null,r)}))}else n([]);else r(new TypeError("Promise.all requires an array as input."))}))},e.prototype.then=function(t,n){var r=this;return new e((function(e,o){r._attachHandler({done:!1,onfulfilled:function(n){if(t)try{return void e(t(n))}catch(e){return void o(e)}else e(n)},onrejected:function(t){if(n)try{return void e(n(t))}catch(e){return void o(e)}else o(t)}})}))},e.prototype.catch=function(e){return this.then((function(e){return e}),e)},e.prototype.finally=function(t){var n=this;return new e((function(e,r){var o,i;return n.then((function(e){i=!1,o=e,t&&t()}),(function(e){i=!0,o=e,t&&t()})).then((function(){i?r(o):e(o)}))}))},e.prototype.toString=function(){return"[object SyncPromise]"},e}(),Jf=function(){function e(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._user={},this._tags={},this._extra={},this._contexts={}}return e.clone=function(t){var n=new e;return t&&(n._breadcrumbs=C(t._breadcrumbs),n._tags=E({},t._tags),n._extra=E({},t._extra),n._contexts=E({},t._contexts),n._user=t._user,n._level=t._level,n._span=t._span,n._session=t._session,n._transactionName=t._transactionName,n._fingerprint=t._fingerprint,n._eventProcessors=C(t._eventProcessors),n._requestSession=t._requestSession),n},e.prototype.addScopeListener=function(e){this._scopeListeners.push(e)},e.prototype.addEventProcessor=function(e){return this._eventProcessors.push(e),this},e.prototype.setUser=function(e){return this._user=e||{},this._session&&this._session.update({user:e}),this._notifyScopeListeners(),this},e.prototype.getUser=function(){return this._user},e.prototype.getRequestSession=function(){return this._requestSession},e.prototype.setRequestSession=function(e){return this._requestSession=e,this},e.prototype.setTags=function(e){return this._tags=E(E({},this._tags),e),this._notifyScopeListeners(),this},e.prototype.setTag=function(e,t){var n;return this._tags=E(E({},this._tags),((n={})[e]=t,n)),this._notifyScopeListeners(),this},e.prototype.setExtras=function(e){return this._extra=E(E({},this._extra),e),this._notifyScopeListeners(),this},e.prototype.setExtra=function(e,t){var n;return this._extra=E(E({},this._extra),((n={})[e]=t,n)),this._notifyScopeListeners(),this},e.prototype.setFingerprint=function(e){return this._fingerprint=e,this._notifyScopeListeners(),this},e.prototype.setLevel=function(e){return this._level=e,this._notifyScopeListeners(),this},e.prototype.setTransactionName=function(e){return this._transactionName=e,this._notifyScopeListeners(),this},e.prototype.setTransaction=function(e){return this.setTransactionName(e)},e.prototype.setContext=function(e,t){var n;return null===t?delete this._contexts[e]:this._contexts=E(E({},this._contexts),((n={})[e]=t,n)),this._notifyScopeListeners(),this},e.prototype.setSpan=function(e){return this._span=e,this._notifyScopeListeners(),this},e.prototype.getSpan=function(){return this._span},e.prototype.getTransaction=function(){var e,t,n,r,o=this.getSpan();return(null===(e=o)||void 0===e?void 0:e.transaction)?null===(t=o)||void 0===t?void 0:t.transaction:(null===(r=null===(n=o)||void 0===n?void 0:n.spanRecorder)||void 0===r?void 0:r.spans[0])?o.spanRecorder.spans[0]:void 0},e.prototype.setSession=function(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this},e.prototype.getSession=function(){return this._session},e.prototype.update=function(t){if(!t)return this;if("function"==typeof t){var n=t(this);return n instanceof e?n:this}return t instanceof e?(this._tags=E(E({},this._tags),t._tags),this._extra=E(E({},this._extra),t._extra),this._contexts=E(E({},this._contexts),t._contexts),t._user&&Object.keys(t._user).length&&(this._user=t._user),t._level&&(this._level=t._level),t._fingerprint&&(this._fingerprint=t._fingerprint),t._requestSession&&(this._requestSession=t._requestSession)):Kf(t)&&(t=t,this._tags=E(E({},this._tags),t.tags),this._extra=E(E({},this._extra),t.extra),this._contexts=E(E({},this._contexts),t.contexts),t.user&&(this._user=t.user),t.level&&(this._level=t.level),t.fingerprint&&(this._fingerprint=t.fingerprint),t.requestSession&&(this._requestSession=t.requestSession)),this},e.prototype.clear=function(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this},e.prototype.addBreadcrumb=function(e,t){var n="number"==typeof t?Math.min(t,100):100;if(n<=0)return this;var r=E({timestamp:(0,Vf.yW)()},e);return this._breadcrumbs=C(this._breadcrumbs,[r]).slice(-n),this._notifyScopeListeners(),this},e.prototype.clearBreadcrumbs=function(){return this._breadcrumbs=[],this._notifyScopeListeners(),this},e.prototype.applyToEvent=function(e,t){var n;if(this._extra&&Object.keys(this._extra).length&&(e.extra=E(E({},this._extra),e.extra)),this._tags&&Object.keys(this._tags).length&&(e.tags=E(E({},this._tags),e.tags)),this._user&&Object.keys(this._user).length&&(e.user=E(E({},this._user),e.user)),this._contexts&&Object.keys(this._contexts).length&&(e.contexts=E(E({},this._contexts),e.contexts)),this._level&&(e.level=this._level),this._transactionName&&(e.transaction=this._transactionName),this._span){e.contexts=E({trace:this._span.getTraceContext()},e.contexts);var r=null===(n=this._span.transaction)||void 0===n?void 0:n.name;r&&(e.tags=E({transaction:r},e.tags))}return this._applyFingerprint(e),e.breadcrumbs=C(e.breadcrumbs||[],this._breadcrumbs),e.breadcrumbs=e.breadcrumbs.length>0?e.breadcrumbs:void 0,this._notifyEventProcessors(C(Xf(),this._eventProcessors),e,t)},e.prototype._notifyEventProcessors=function(e,t,n,r){var o=this;return void 0===r&&(r=0),new Yf((function(i,a){var s=e[r];if(null===t||"function"!=typeof s)i(t);else{var c=s(E({},t),n);Zf(c)?c.then((function(t){return o._notifyEventProcessors(e,t,n,r+1).then(i)})).then(null,a):o._notifyEventProcessors(e,c,n,r+1).then(i).then(null,a)}}))},e.prototype._notifyScopeListeners=function(){var e=this;this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((function(t){t(e)})),this._notifyingListeners=!1)},e.prototype._applyFingerprint=function(e){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],this._fingerprint&&(e.fingerprint=e.fingerprint.concat(this._fingerprint)),e.fingerprint&&!e.fingerprint.length&&delete e.fingerprint},e}();function Xf(){var e=(0,qf.Rf)();return e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.globalEventProcessors=e.__SENTRY__.globalEventProcessors||[],e.__SENTRY__.globalEventProcessors}function ep(e){var t,n;if(Kf(e)){var r=e,o={};try{for(var i=O(Object.keys(r)),a=i.next();!a.done;a=i.next()){var s=a.value;void 0!==r[s]&&(o[s]=ep(r[s]))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return o}return Array.isArray(e)?e.map(ep):e}var tp=function(){function e(e){this.errors=0,this.sid=(0,qf.DM)(),this.duration=0,this.status=jf.Ok,this.init=!0,this.ignoreDuration=!1;var t=(0,Vf.ph)();this.timestamp=t,this.started=t,e&&this.update(e)}return e.prototype.update=function(e){if(void 0===e&&(e={}),e.user&&(!this.ipAddress&&e.user.ip_address&&(this.ipAddress=e.user.ip_address),this.did||e.did||(this.did=e.user.id||e.user.email||e.user.username)),this.timestamp=e.timestamp||(0,Vf.ph)(),e.ignoreDuration&&(this.ignoreDuration=e.ignoreDuration),e.sid&&(this.sid=32===e.sid.length?e.sid:(0,qf.DM)()),void 0!==e.init&&(this.init=e.init),!this.did&&e.did&&(this.did=""+e.did),"number"==typeof e.started&&(this.started=e.started),this.ignoreDuration)this.duration=void 0;else if("number"==typeof e.duration)this.duration=e.duration;else{var t=this.timestamp-this.started;this.duration=t>=0?t:0}e.release&&(this.release=e.release),e.environment&&(this.environment=e.environment),!this.ipAddress&&e.ipAddress&&(this.ipAddress=e.ipAddress),!this.userAgent&&e.userAgent&&(this.userAgent=e.userAgent),"number"==typeof e.errors&&(this.errors=e.errors),e.status&&(this.status=e.status)},e.prototype.close=function(e){e?this.update({status:e}):this.status===jf.Ok?this.update({status:jf.Exited}):this.update()},e.prototype.toJSON=function(){return ep({sid:""+this.sid,init:this.init,started:new Date(1e3*this.started).toISOString(),timestamp:new Date(1e3*this.timestamp).toISOString(),status:this.status,errors:this.errors,did:"number"==typeof this.did||"string"==typeof this.did?""+this.did:void 0,duration:this.duration,attrs:ep({release:this.release,environment:this.environment,ip_address:this.ipAddress,user_agent:this.userAgent})})},e}(),np=function(){function e(e,t,n){void 0===t&&(t=new Jf),void 0===n&&(n=4),this._version=n,this._stack=[{}],this.getStackTop().scope=t,e&&this.bindClient(e)}return e.prototype.isOlderThan=function(e){return this._version<e},e.prototype.bindClient=function(e){this.getStackTop().client=e,e&&e.setupIntegrations&&e.setupIntegrations()},e.prototype.pushScope=function(){var e=Jf.clone(this.getScope());return this.getStack().push({client:this.getClient(),scope:e}),e},e.prototype.popScope=function(){return!(this.getStack().length<=1)&&!!this.getStack().pop()},e.prototype.withScope=function(e){var t=this.pushScope();try{e(t)}finally{this.popScope()}},e.prototype.getClient=function(){return this.getStackTop().client},e.prototype.getScope=function(){return this.getStackTop().scope},e.prototype.getStack=function(){return this._stack},e.prototype.getStackTop=function(){return this._stack[this._stack.length-1]},e.prototype.captureException=function(e,t){var n=this._lastEventId=(0,qf.DM)(),r=t;if(!t){var o=void 0;try{throw new Error("Sentry syntheticException")}catch(e){o=e}r={originalException:e,syntheticException:o}}return this._invokeClient("captureException",e,E(E({},r),{event_id:n})),n},e.prototype.captureMessage=function(e,t,n){var r=this._lastEventId=(0,qf.DM)(),o=n;if(!n){var i=void 0;try{throw new Error(e)}catch(e){i=e}o={originalException:e,syntheticException:i}}return this._invokeClient("captureMessage",e,t,E(E({},o),{event_id:r})),r},e.prototype.captureEvent=function(e,t){var n=(0,qf.DM)();return"transaction"!==e.type&&(this._lastEventId=n),this._invokeClient("captureEvent",e,E(E({},t),{event_id:n})),n},e.prototype.lastEventId=function(){return this._lastEventId},e.prototype.addBreadcrumb=function(e,t){var n=this.getStackTop(),r=n.scope,o=n.client;if(r&&o){var i=o.getOptions&&o.getOptions()||{},a=i.beforeBreadcrumb,s=void 0===a?null:a,c=i.maxBreadcrumbs,l=void 0===c?100:c;if(!(l<=0)){var u=(0,Vf.yW)(),f=E({timestamp:u},e),p=s?(0,qf.Cf)((function(){return s(f,t)})):f;null!==p&&r.addBreadcrumb(p,l)}}},e.prototype.setUser=function(e){var t=this.getScope();t&&t.setUser(e)},e.prototype.setTags=function(e){var t=this.getScope();t&&t.setTags(e)},e.prototype.setExtras=function(e){var t=this.getScope();t&&t.setExtras(e)},e.prototype.setTag=function(e,t){var n=this.getScope();n&&n.setTag(e,t)},e.prototype.setExtra=function(e,t){var n=this.getScope();n&&n.setExtra(e,t)},e.prototype.setContext=function(e,t){var n=this.getScope();n&&n.setContext(e,t)},e.prototype.configureScope=function(e){var t=this.getStackTop(),n=t.scope,r=t.client;n&&r&&e(n)},e.prototype.run=function(e){var t=op(this);try{e(this)}finally{op(t)}},e.prototype.getIntegration=function(e){var t=this.getClient();if(!t)return null;try{return t.getIntegration(e)}catch(t){return Qf.warn("Cannot retrieve integration "+e.id+" from the current Hub"),null}},e.prototype.startSpan=function(e){return this._callExtensionMethod("startSpan",e)},e.prototype.startTransaction=function(e,t){return this._callExtensionMethod("startTransaction",e,t)},e.prototype.traceHeaders=function(){return this._callExtensionMethod("traceHeaders")},e.prototype.captureSession=function(e){if(void 0===e&&(e=!1),e)return this.endSession();this._sendSessionUpdate()},e.prototype.endSession=function(){var e,t,n,r,o;null===(n=null===(t=null===(e=this.getStackTop())||void 0===e?void 0:e.scope)||void 0===t?void 0:t.getSession())||void 0===n||n.close(),this._sendSessionUpdate(),null===(o=null===(r=this.getStackTop())||void 0===r?void 0:r.scope)||void 0===o||o.setSession()},e.prototype.startSession=function(e){var t=this.getStackTop(),n=t.scope,r=t.client,o=r&&r.getOptions()||{},i=o.release,a=o.environment,s=((0,qf.Rf)().navigator||{}).userAgent,c=new tp(E(E(E({release:i,environment:a},n&&{user:n.getUser()}),s&&{userAgent:s}),e));if(n){var l=n.getSession&&n.getSession();l&&l.status===jf.Ok&&l.update({status:jf.Exited}),this.endSession(),n.setSession(c)}return c},e.prototype._sendSessionUpdate=function(){var e=this.getStackTop(),t=e.scope,n=e.client;if(t){var r=t.getSession&&t.getSession();r&&n&&n.captureSession&&n.captureSession(r)}},e.prototype._invokeClient=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var o=this.getStackTop(),i=o.scope,a=o.client;a&&a[e]&&(t=a)[e].apply(t,C(n,[i]))},e.prototype._callExtensionMethod=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=rp(),o=r.__SENTRY__;if(o&&o.extensions&&"function"==typeof o.extensions[e])return o.extensions[e].apply(this,t);Qf.warn("Extension method "+e+" couldn't be found, doing nothing.")},e}();function rp(){var e=(0,qf.Rf)();return e.__SENTRY__=e.__SENTRY__||{extensions:{},hub:void 0},e}function op(e){var t=rp(),n=sp(t);return cp(t,e),n}function ip(){var e=rp();return ap(e)&&!sp(e).isOlderThan(4)||cp(e,new np),(0,Wf.KV)()?function(e){var t,n,r;try{var o=null===(r=null===(n=null===(t=rp().__SENTRY__)||void 0===t?void 0:t.extensions)||void 0===n?void 0:n.domain)||void 0===r?void 0:r.active;if(!o)return sp(e);if(!ap(o)||sp(o).isOlderThan(4)){var i=sp(e).getStackTop();cp(o,new np(i.client,Jf.clone(i.scope)))}return sp(o)}catch(t){return sp(e)}}(e):sp(e)}function ap(e){return!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)}function sp(e){return e&&e.__SENTRY__&&e.__SENTRY__.hub||(e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.hub=new np),e.__SENTRY__.hub}function cp(e,t){return!!e&&(e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.hub=t,!0)}function lp(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=ip();if(r&&r[e])return r[e].apply(r,C(t));throw new Error("No hub defined or "+e+" was not found on the hub, please open a bug report.")}function up(e,t){var n;try{throw new Error("Sentry syntheticException")}catch(e){n=e}return lp("captureException",e,{captureContext:t,originalException:e,syntheticException:n})}var fp=n(76727);const pp=(e,t)=>({selector:e,resolveView:e=>({...t,element:e})}),dp=(e,t,n)=>((e,t)=>{const{repoName:n,commitID:r}=e;return dl({repoName:n,revision:r,requestGraphQL:t}).pipe(hl())})(e,n).pipe(ze((()=>ml({repoName:e.repoName,filePath:e.filePath,commitID:e.commitID,requestGraphQL:n}))),H((t=>t?{...e,content:t.join("\n")}:{...e})),st((n=>ee(t(n)).pipe(ze((t=>{if(t)return z(e);throw n}))))));function hp(){return function(e){const t=function(e){if(void 0!==e.line)return{start:{line:e.line,character:e.character||0},end:{line:e.endLine||e.line,character:e.endCharacter||e.character||0}}}(e);if(void 0===t)return[];const n={line:t.start.line-1,character:Yn(t.start.character)},r={line:t.end.line-1,character:Yn(t.end.character)};return[{start:n,end:r,anchor:n,active:r,isReversed:!1}]}(ua(window.location.hash))}function mp(){return Ae(window,"hashchange").pipe(H(hp),Qe(((e,t)=>Ot()(e,t))))}function gp(e){const t=e.title.split(" \u2192 ");return t.length>1?{headFilePath:t[1],baseFilePath:t[0]}:{headFilePath:t[0],baseFilePath:t[0]}}function vp(e){const{pageType:t}=_p();if(!Ep(t))return null;let n="",r="";if("pull"===t){var o;const t=null===(o=document.querySelector("details-menu[src*='sha1='][src*='sha2=']"))||void 0===o?void 0:o.getAttribute("src"),i=e.classList.contains("js-comment-container");if(t){const e=new URLSearchParams(t),n=e.get("sha1"),r=e.get("sha2");if(n&&r)return{baseCommitID:n,headCommitID:r}}else if(i){const t=function(e){const t=e.querySelector(`summary a[href^="${location.pathname}"`);if(!t)return null;const n=t.href.match(bp);if(!n)return null;const r=n[3],o=yp(document.documentElement.innerHTML,!0);return r&&o?{...o,headCommitID:r}:null}(e);if(t)return t}else{const e=document.querySelector('input[name="comparison_start_oid"]');e&&(n=e.value);const t=document.querySelector('input[name="comparison_end_oid"]');t&&(r=t.value)}}else if("commit"===t){const e=document.querySelectorAll(".sha-block:not(.patch-diff-links)");if(e&&2===e.length){const t=e[0].querySelector("a");t&&(n=t.href.split("/").slice(-1)[0]);const o=e[1].querySelector("span.sha");o&&(r=o.innerHTML)}}else if("compare"===t){const e=function(){const[e,t]=document.querySelectorAll(".commitish-suggester .select-menu-button span");if(e&&t&&e.textContent&&t.textContent)return{baseCommitID:e.textContent,headCommitID:t.textContent};return}();if(e)return e}return""===n||""===r?yp(document.documentElement.innerHTML,"pull"===t):{baseCommitID:n,headCommitID:r}}const bp=/\/files\/((\w+)\.\.)?(\w+)#diff-\w+$/;function yp(e,t){if(!t)return null;const n="\x3c!-- base sha1: "",r=e.indexOf(n);if(-1===r)return null;const o="\x3c!-- head sha1: "",i=e.indexOf(o,r);if(-1===i)return null;return{baseCommitID:e.slice(r+n.length,40),headCommitID:e.slice(i+o.length,40)}}function wp(){const e=document.querySelector("a.js-permalink-shortcut");if(!e)throw new Error("Unable to determine the file path because no a.js-permalink-shortcut element was found.");const t=new URL(e.href),[,,,n,,...r]=t.pathname.split("/");if("tree"!==n&&0===r.length)throw new Error(`Unable to determine the file path because the a.js-permalink-shortcut element's href's path was ${t.pathname} (it is expected to be of the form /<user>/<repo>/blob/<commitID>/<path/to/file>).`);return decodeURIComponent(r.join("/"))}function Ep(e){switch(e){case"commit":case"pull":case"compare":return!0;default:return!1}}function _p(e=window.location){const{host:t,pathname:n}=e,[r,o,i,...a]=n.slice(1).split("/");if(!r||!o)throw new ll(`Could not parse repoName from GitHub url: ${e.href}`);const s=`${r}/${o}`,c=`${t}/${s}`;switch(i){case"blob":case"tree":return{pageType:i,rawRepoName:c,revisionAndFilePath:decodeURIComponent(a.join("/")),repoName:s};case"pull":case"commit":case"compare":return{pageType:i,rawRepoName:c,repoName:s};default:return{pageType:"other",rawRepoName:c,repoName:s}}}const xp=e=>{let t=e.closest("td").previousElementSibling;for(;t;){if(t.dataset.lineNumber)return parseInt(t.dataset.lineNumber,10);t=t.previousElementSibling}throw new Error("Could not find a line number in any cell")},Sp=e=>{var t;const n=e.closest("td.blob-code");return!n||null!==(t=n.parentElement)&&void 0!==t&&t.classList.contains("js-expandable-line")?null:n},Op=(e,t,n)=>{const r=Pp(e),o=((e,t)=>"base"===e?0:t?2:1)(n,r)+1,i=e.querySelector(`td:nth-child(${o})[data-line-number="${t}"]`);if(!i)return null;if(!r&&"base"===n&&!i.classList.contains("blob-num-addition")&&!i.classList.contains("blob-num-deletion"))return null;let a;if(r)a=i.nextElementSibling;else{a=i.parentElement.lastElementChild}return a},Tp=e=>e.classList.contains("blob-code-inner")?e:e.querySelector(".blob-code-inner"),Cp={getCodeElementFromTarget:e=>{const t=Sp(e);return t&&Tp(t)},getLineElementFromLineNumber:Op,getCodeElementFromLineNumber:(e,t,n)=>{const r=Op(e,t,n);return r&&Tp(r)},getLineNumberFromCodeElement:xp,getDiffCodePart:e=>{const t=e.closest("td");return t.classList.contains("blob-code-addition")?"head":t.classList.contains("blob-code-deletion")||Pp(e)&&t.nextElementSibling?"base":"head"},isFirstCharacterDiffIndicator:e=>{const t=e.closest(".blob-code-inner"),n=t&&["deletion","context","addition"].some((e=>t.classList.contains("blob-code-marker-"+e))),r=e.closest("tr"),o=null==r?void 0:r.querySelector("td[data-code-marker]"),i=null==t?void 0:t.hasAttribute("data-code-marker"),a=o||i,s=e.closest(".refined-github-diff-signs");return!n&&!a&&!s}},kp=(e,t)=>{const n=e.querySelector(`td[data-line-number="${t}"]`);return n&&n.nextElementSibling},Np={getCodeElementFromTarget:Sp,getCodeElementFromLineNumber:kp,getLineElementFromLineNumber:kp,getLineNumberFromCodeElement:xp},Ap=(e,t)=>{const n=((e,t)=>{const n=e.querySelectorAll("td.blob-num");let r=null;for(const e of n)if(e.querySelector("a").href.endsWith(`#L${t}`)){r=e;break}return r})(e,t);return n&&n.nextElementSibling},Ip={getCodeElementFromTarget:Sp,getCodeElementFromLineNumber:Ap,getLineElementFromLineNumber:Ap,getLineNumberFromCodeElement:e=>{const t=e.closest("td").previousElementSibling;return parseInt(t.firstElementChild.textContent,10)}};function Pp(e){const{pageType:t}=_p();if(!Ep(t))return!1;const n=e.classList.contains("file")?e:e.closest(".file");if(!n)throw new Error("Could not resolve code view element");if(n.classList.contains("js-comment-container"))return!1;const r=n.querySelector("table");if(!r)throw new Error("Could not find code view table");return r.classList.contains("js-file-diff-split")||r.classList.contains("file-diff-split")}const Rp=()=>{const e=_p();if("blob"!==e.pageType&&"tree"!==e.pageType)throw new Error(`Current URL does not match a blob or tree url: ${window.location.href}`);const{revisionAndFilePath:t,rawRepoName:n}=e,r=wp(),o=r&&!r.startsWith("/")?`/${r}`:r,i=o?t.slice(0,-o.length):t;if(!t.endsWith(o))throw new Error(`The file path ${o} should always be a suffix of revAndFilePath ${t}, but isn't in this case.`);return{blob:{rawRepoName:n,filePath:r,revision:i,commitID:fe({selector:".js-permalink-shortcut",hrefRegex:/^\/.*?\/.*?\/(?:blob|tree)\/([\da-f]{40})/})}}},Dp=/\/([\da-f]{40})$/i,Lp=e=>{const t=e.querySelector("a.commit-tease-sha");if(!t)throw new Error("Could not find commit link in snippet code view");const n=t.href.match(Dp);if(null==n||!n[1])throw new Error(`Could not parse commitID from snippet commit link href: ${t.href}`);const r=n[1],o=e.querySelectorAll("a:not(.commit-tease-sha)"),i=new URL(o[0].href),a=_p(i);if("blob"!==a.pageType)throw new Error(`Snippet URL does not match a blob url: ${i.href}`);const{revisionAndFilePath:s,rawRepoName:c}=a;if(!s.startsWith(r))throw new Error(`Could not parse filePath: revAndFilePath ${s} does not start with commitID ${r}`);return{blob:{rawRepoName:c,filePath:s.slice(r.length+1),commitID:r,revision:r}}},Mp=["tooltipped","tooltipped-n"];const jp="codeHost-module__command-palette-action-item_16BFG",Fp="codeHost-module__action-item_7QWb2",Bp="codeHost-module__icon_3PdA7",Up="codeHost-module__code-view-toolbar_gOzAp",qp="codeHost-module__code-view-toolbar-item_2fTzz",Vp="codeHost-module__hover-overlay-badge_3wpZt";function $p(e){const t="github-file-actions-toolbar-mount",n=e.querySelector("."+t);if(n)return n;const r=document.createElement("div");r.className=t;const o=e.querySelector(".file-actions");if(!o)throw new Error("Could not find GitHub file actions with selector .file-actions");o.classList.add("sg-github-file-actions");const i=e.querySelector(".show-file-notes");return i?i.after(r):o.prepend(r),r}const zp={dom:Cp,getToolbarMount:$p,resolveFileInfo:e=>{const{rawRepoName:t}=_p(),{headFilePath:n,baseFilePath:r}=function(e){const t=e.querySelector(".file-info");if(t){if("A"===t.tagName)return gp(t);const e=t.querySelector(".diffstat + a");if(e)return gp(e)}const n=e.querySelector(".file-header a");if(n)return gp(n);throw new Error("Could not determine diff file name")}(e);if(!n)throw new Error("cannot determine file path");const o=vp(e);if(!o)throw new Error("cannot determine delta info");const{headCommitID:i,baseCommitID:a}=o;return{head:{rawRepoName:t,filePath:n,commitID:i,revision:i},base:{rawRepoName:t,filePath:r||n,commitID:a,revision:a}}},getScrollBoundaries:e=>{const t=e.querySelector(".file-header");if(!t)throw new Error("Could not find .file-header element in GitHub PR code view");return[t]}},Hp={...zp,getToolbarMount:void 0},Gp={dom:Np,getToolbarMount:$p,resolveFileInfo:Rp,getSelections:hp,observeSelections:mp},Qp=e=>({direction:t,codeView:n,position:r})=>ml({...r,requestGraphQL:e}).pipe(H((e=>{const o=Np.getCodeElementFromLineNumber(n,r.line,r.part);if(!o)throw new Error("(adjustPosition) could not find code element for line provided");const i=e[r.line-1],a=o.textContent||"",s=i.length-Uf()(i).length,c=a.length-Uf()(a).length,l=t===Fn.ActualToCodeView?-1:1,u=Math.abs(s-c)*l;return{line:r.line,character:r.character+u}}))),Wp=pp(".code-list-item",{dom:Ip,getPositionAdjuster:Qp,resolveFileInfo:Lp}),Kp={dom:Np,resolveFileInfo:Lp,getPositionAdjuster:Qp},Zp=e=>{const t="sourcegraph-github-file-code-view-toolbar-mount",n=e.querySelector(`.${t}`);if(n)return n;const r=document.createElement("div");r.style.display="inline-flex",r.style.verticalAlign="middle",r.style.alignItems="center",r.className=t;const o=e.querySelector("#raw-url"),i=null==o?void 0:o.closest(".BtnGroup");if(null==i||!i.parentNode)throw new Error("File actions not found");return i.parentNode.insertBefore(r,i),r},Yp={selector:".js-file-line-container",resolveView:e=>{const t=e.closest(".blob-wrapper-embedded");if(t){return{element:t.parentElement,...Kp}}const{pageType:n}=_p();if("blob"!==n)return null;const r=e.closest(".repository-content");if(!r)throw new Error("Could not find repository content element");return{element:r,...Gp,getToolbarMount:Zp}}},Jp={selector:e=>{const t=new Set;for(const n of de(e,".file"))0===n.querySelectorAll(".js-diff-load-container").length&&t.add(n);for(const n of de(e,".js-blob-wrapper")){const e=n.closest(".file");e instanceof HTMLElement&&t.add(e)}return[...t]},resolveView:e=>{if(e.querySelector("article.markdown-body"))return null;if(e.closest(".js-suggested-changes-blob"))return null;const{pageType:t}=_p();return"blob"===t&&1===document.querySelectorAll(".file").length&&0===document.querySelectorAll(".diff-view").length?{element:e,...Gp}:e.closest(".discussion-item-body")||e.classList.contains("js-comment-container")?{element:e,...Hp}:{element:e,...zp}}};function Xp(){const e=document.head.querySelector('meta[property="og:site_name"]');return!!e&&("GitHub Enterprise"===e.content||"GitHub"===e.content)&&document.body.classList.contains("enterprise")}const ed="open-on-sourcegraph",td=i()(Bp,"v-align-text-bottom"),nd={[Qa]:"flash",[Wa]:"flash flash-success",[Ga]:"flash",[Ha]:"flash flash-warn",[za]:"flash flash-error"},rd={searchViewResolver:{selector:'.js-site-search-form input[type="text"][aria-controls="jump-to-results"]',resolveView:e=>({element:e})},resultViewResolver:{selector:"#jump-to-suggestion-search-global",resolveView:e=>({element:e})},onChange:({value:e,searchURL:t,resultElement:n})=>{var r;const o="#jump-to-sourcegraph-search-global";(n=>{const r=n.querySelector(".jump-to-suggestion-name");r.textContent=e,r.setAttribute("aria-label",e);const o=n.querySelector("a"),i=new URL(t);i.searchParams.append("q",e),o.setAttribute("href",i.href),o.setAttribute("target","_blank"),n.setAttribute("style","display: "+(e?"initial":"none !important"))})(null!==(r=document.querySelector(o))&&void 0!==r?r:(()=>{var e,t;const r=n.cloneNode(!0);r.id=o.replace("#",""),r.classList.remove("navigation-focus"),r.setAttribute("aria-selected","false");const i=document.createElement("img");i.src=fp,i.setAttribute("style","width: 16px; height: 20px; float: left; margin-right: 2px;"),i.setAttribute("alt","Sourcegraph Logo Image");const a=r.querySelector(".js-jump-to-badge-search-text-global");return a.textContent="Sourcegraph",null===(e=a.parentNode)||void 0===e||e.insertBefore(i,a),null===(t=n.parentNode)||void 0===t||t.insertBefore(r,n.nextElementSibling),r})())}},od=(e,t=Dc.fetchCache,n="#repository-container-header h1 span.Label")=>"github.com"!==window.location.hostname?Promise.resolve(!0):t({url:`https://api.github.com/repos/${e}`,credentials:"omit",cacheMaxAge:36e5}).then((e=>{const t=e.headers["x-ratelimit-remaining"];if(Number(t)<=0){const e=new Error("Github rate limit exceeded.");throw up(e),e}return e})).then((({data:e})=>"boolean"!=typeof e.private||e.private)).catch((e=>{var t,r;return console.warn("Failed to fetch if the repository is private.",e),"public"!==(null===(t=document.querySelector(n))||void 0===t||null===(r=t.textContent)||void 0===r?void 0:r.toLowerCase().trim())})),id=()=>"/search"===window.location.pathname,ad=()=>"/search/advanced"===window.location.pathname,sd=()=>!id()&&window.location.pathname.endsWith("/search"),cd=()=>Boolean(new URLSearchParams(window.location.search).get("q"))&&!ad(),ld=()=>{const e=new URLSearchParams(window.location.search).get("type");return e?e.toLowerCase():""},ud=e=>{const t=e.filter(Boolean).map((e=>e.trim())),n=(()=>{switch(ld()){case"repositories":return"repo";case"commits":return"commit";case"code":return"";default:return id()||ad()?"repo":""}})(),r=new URLSearchParams(window.location.search).get("l");if(n&&t.push(`type:${n}`),r&&t.push(`lang:${encodeURIComponent(r)}`),sd()){const[e,n]=window.location.pathname.split("/").filter(Boolean);t.push(`repo:${e}/${n}$`)}for(const e of["org","user"]){const n=t.findIndex((t=>t.startsWith(`${e}:`)));if(n>=0){const r=t[n].replace(`${e}:`,"");r&&(t[n]=`repo:${r}/*`)}}return t.join("+")},fd=(e,t="")=>{let n=document.querySelector(`#${e}`);return n||(n=document.createElement("div"),n.setAttribute("id",e),n.classList.add(...t.split(/\s/gi)),n)};const pd={type:"github",name:Xp()?"GitHub Enterprise":"GitHub",searchEnhancement:rd,enhanceSearchPage:function(e){if(!(id()||ad()||sd()||cd()))return;const n=({container:n,className:r="",getSearchQuery:o,utmCampaign:a})=>{const s=Tc(new URL("/search",e),{utm_source:Fc(),utm_campaign:a});(0,me.render)(t.createElement(tl,{label:"Search on Sourcegraph",title:"Search on Sourcegraph to get hover tooltips, go to definition and more",ariaLabel:"Search on Sourcegraph to get hover tooltips, go to definition and more",className:i()("btn","m-auto",r),iconClassName:i()("mr-1","v-align-middle",Bp),href:s.href,dataTestId:"search-on-sourcegraph",onClick:e=>{const t=ud(o());e.target.href=`${s.href}${t?`&q=${t}`:""}`}}),n)};if(cd()){const e=ld();if(["repositories","commits","code"].includes(e)||""===e&&(id()||sd())){var r,o;const e=document.querySelector(".application-main form.js-site-search-form"),t=null==e?void 0:e.querySelector("input.form-control[name='q']"),i=null==e||null===(r=e.parentElement)||void 0===r||null===(o=r.parentElement)||void 0===o?void 0:o.querySelector("button[type='submit']");if(t&&i){const e=fd("pageSearchFormSourcegraphButton","ml-2 d-none d-md-block");i.after(e),n({container:e,utmCampaign:"github-search-results-page",getSearchQuery:()=>t.value.split(" ")})}const a=document.querySelector("header form.js-site-search-form input.form-control[name='q']"),s=document.querySelector(".codesearch-results"),c=null==s?void 0:s.querySelector(".blankslate"),l=null==s?void 0:s.querySelector("div > div > h3");if(a&&(c||l)){const e=fd("headerSearchInputSourcegraphButton","ml-auto d-none d-lg-block");c?(e.classList.add("mt-2"),c.append(e)):l&&(e.classList.add("mr-2"),l.after(e)),n({container:e,className:c?"":"btn-sm",utmCampaign:"github-search-results-page",getSearchQuery:()=>a.value.split(" ")})}}return}const a=document.querySelector("#search_form"),s=null==a?void 0:a.querySelector(".search-form-fluid"),c=null==a?void 0:a.querySelector("input");if(s&&c){const e=fd("searchInputSourcegraphButton","ml-0 ml-md-2 mt-2 mt-md-0");null==s||s.append(e),n({container:e,utmCampaign:`github-${ad()?"advanced":"simple"}-search-page`,getSearchQuery:()=>c.value.split(" ")})}},codeViewResolvers:[Jp,Yp,Wp],contentViewResolvers:[{selector:".markdown-body",resolveView:e=>({element:e})}],nativeTooltipResolvers:[{selector:".js-tagsearch-popover",resolveView:e=>({element:e})}],routeChange:e=>e.pipe(H((()=>{const{pathname:e}=window.location,t=e.slice(1).split("/")[2];return"blob"===t||"tree"===t?e.endsWith(wp())?e:void 0:cd()?null===(n=document.querySelector(".codesearch-results h3"))||void 0===n||null===(r=n.textContent)||void 0===r?void 0:r.trim():e;var n,r})),qe(Boolean),Qe()),getContext:async()=>{const{repoName:e,rawRepoName:t,pageType:n}=_p();return{rawRepoName:t,revision:"blob"===n||"tree"===n?Rp().blob.revision:void 0,privateRepository:await od(e)}},isLightTheme:gf((()=>{const e=document.documentElement.dataset.colorMode;return"auto"===e?((e=window)=>{const t=e.matchMedia("(prefers-color-scheme: dark)");return{observable:le(z(!t.matches),Ae(t,"change").pipe(H((e=>!e.matches)))),initialValue:!t.matches}})().observable:z("dark"!==e)})),getViewContextOnSourcegraphMount:e=>{const t=he(e,".pagehead-actions");if(!t||0===t.children.length)return null;let n=t.querySelector("#open-on-sourcegraph");return n||(n=document.createElement("li"),n.id=ed,t.prepend(n),n)},viewOnSourcegraphButtonClassProps:{className:"btn btn-sm tooltipped tooltipped-s",iconClassName:td},check:()=>((e=window.location.href)=>/^https?:\/\/(www\.)?github\.com/.test(e))()||Xp(),getCommandPaletteMount:e=>{const t="command-palette-button",n=e.querySelector(`.Header .${t}`);if(n)return n;const r=he(e,".HeaderMenu > :last-child");if(r){const e=document.createElement("div");return e.classList.add(t),r.prepend(e),e}let o=he(e,".Header-item:nth-last-child(2)");if(o){0!==o.previousElementSibling.children.length&&(o=o.previousElementSibling);const e=document.createElement("div");return e.classList.add("Header-item","mr-0","mr-lg-3",t),o.before(e),e}return null},notificationClassNames:nd,commandPaletteClassProps:{buttonClassName:"Header-link d-flex flex-items-baseline",popoverClassName:"Box",formClassName:"p-1",inputClassName:"form-control input-sm header-search-input jump-to-field",listClassName:"p-0 m-0 js-navigation-container jump-to-suggestions-results-container",selectedListItemClassName:"navigation-focus",listItemClassName:"d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-scoped-search",actionItemClassName:i()(jp,"no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path p-2"),noResultsClassName:"d-flex flex-auto flex-items-center jump-to-suggestions-path p-2",iconClassName:td},codeViewToolbarClassProps:{className:Up,listItemClass:i()(qp,"BtnGroup"),actionItemClass:i()("btn btn-sm tooltipped tooltipped-s BtnGroup-item",Fp),actionItemPressedClass:"selected",actionItemIconClass:i()(Bp,"v-align-text-bottom")},hoverOverlayClassProps:{className:"Box",actionItemClassName:"btn btn-sm btn-secondary",actionItemPressedClassName:"active",badgeClassName:i()("label",Vp),getAlertClassName:mu(nd,"flash-full"),iconClassName:td},setElementTooltip:function(e,t){"string"==typeof t?(e.classList.add(...Mp),e.setAttribute("aria-label",t)):(e.classList.remove(...Mp),e.removeAttribute("aria-label"))},linkPreviewContentClass:"text-small text-gray p-1 mx-1 border rounded-1 bg-gray text-gray-dark",urlToFile:(e,t,n)=>{if(t.viewState)return ga(e,t);if(!t.rawRepoName.startsWith(window.location.hostname))return ga(e,t);const r=t.revision||"HEAD",{rawRepoName:o}=_p();if(o===t.rawRepoName&&void 0!==n.part){const e=document.querySelectorAll(".file");for(const r of e){const e=r.querySelector(".file-header[data-path][data-anchor]");if(!e)continue;if(e.dataset.path===t.filePath){const r=e.dataset.anchor,o=new URL(window.location.href);if(o.hash=r,t.position&&(o.hash+=`${"base"===n.part?"L":"R"}${t.position.line}`),!document.querySelector(o.hash))break;return o.href}}}const i=t.position?`#L${t.position.line}${t.position.character?`:${t.position.character}`:""}`:"";return`https://${t.rawRepoName}/blob/${r}/${t.filePath}${i}`},codeViewsRequireTokenization:!0},dd=(e,t,n)=>e.querySelector(`#LC${t}`),hd={getCodeElementFromTarget:e=>e.closest("span.line"),getLineNumberFromCodeElement:e=>{const t=e.id.replace(/^LC/,"");return parseInt(t,10)},getCodeElementFromLineNumber:dd,getLineElementFromLineNumber:dd},md=e=>{const t=e.closest("[data-interop-type]");return t?"old"===t.dataset.interopType?"base":"head":(e=>{let t="old";const n=e.closest(".diff-td,td");return n.classList.contains("parallel")&&(t="left-side"),n.classList.contains(t)?"base":"head"})(e)},gd=(e,t,n)=>{const r="base"===n?"old":"new",o=e.querySelector(`[data-interop-${r}-line="${t}"]`);return o?o.querySelector("span.line"):((e,t,n)=>{const r=e.querySelector(`.${"base"===n?"old_line":"new_line"} [data-linenumber="${t}"]`);if(!r)return null;const o=r.closest(".diff-tr,tr");if(!o)return null;let i="span.line";return o.classList.contains("parallel")&&(i=`.${"base"===n?"left-side":"right-side"} ${i}`),o.querySelector(i)})(e,t,n)},vd={getCodeElementFromTarget:hd.getCodeElementFromTarget,getLineNumberFromCodeElement:e=>{const t=e.closest("[data-interop-line]");return t?parseInt(t.dataset.interopLine||"",10):(e=>{const t=md(e);let n=e.closest(".diff-td,td");for(;n&&(!n.matches(".diff-line-num."+("base"===t?"old_line":"new_line"))||!n.querySelector("a"))&&n.previousElementSibling;)n=n.previousElementSibling;if(n){const e=n.querySelector("a");return parseInt(e.dataset.linenumber||"",10)}throw new Error("Unable to determine line number for diff code element")})(e)},getCodeElementFromLineNumber:gd,getLineElementFromLineNumber:(e,t,n)=>{const r=gd(e,t,n);return r&&r.parentElement},getDiffCodePart:md},bd=(e,t,n)=>`${window.location.origin}/api/v4/projects/${encodeURIComponent(e)}%2f${t}${n}`,yd=e=>ar(e,{selector:e=>ur(e).json()}),wd=jo((e=>yd(`${window.location.origin}/api/v4/projects/${e}`).pipe(H((({web_url:e})=>{const{hostname:t,pathname:n}=new URL(e);return`${t}${n}`})))),Na()),Ed=jo((({owner:e,projectName:t,mergeRequestID:n,diffID:r})=>r?yd(bd(e,t,`/merge_requests/${n}/versions/${r}`)).pipe(H((({base_commit_sha:e})=>e))):z(void 0)),(({owner:e,projectName:t,mergeRequestID:n,diffID:r})=>`${e}:${t}:${n}:${String(r)}`)),_d=jo((({owner:e,projectName:t,mergeRequestID:n,rawRepoName:r,diffID:o})=>rl(yd(bd(e,t,`/merge_requests/${n}`)),Ed({owner:e,projectName:t,mergeRequestID:n,diffID:o})).pipe(ze((([{diff_refs:e,source_project_id:t},n])=>wd(t).pipe(H((t=>({baseCommitID:n||e.base_sha,commitID:e.head_sha,rawRepoName:r,baseRawRepoName:t})))))))),(({owner:e,projectName:t,mergeRequestID:n,rawRepoName:r,diffID:o})=>`${e}:${t}:${n}:${r}:${String(o)}`)),xd=jo((({owner:e,projectName:t,commitID:n})=>yd(bd(e,t,`/repository/commits/${n}`)).pipe(H((({parent_ids:e})=>Su()(e))))),(({owner:e,projectName:t,commitID:n})=>`${e}:${t}:${n}`));var Sd=n(68642),Od=n.n(Sd),Td=n(90006),Cd=n.n(Td);let kd;!function(e){e[e.File=0]="File",e[e.Commit=1]="Commit",e[e.MergeRequest=2]="MergeRequest",e[e.Other=3]="Other"}(kd||(kd={}));function Nd(){const e=document.querySelector(".context-header a");if(!e)throw new Error("Unable to determine project name");const t=new URL(e.href).pathname.slice(1),n=t.split("/"),r=Od()(n,n.length-1).join("/"),o=Cd()(n),i=((e,t,n)=>{const r=n.match(new RegExp(`^/${e}/${t}(/-)?/(commit|merge_requests|blob)/`));if(!r)return kd.Other;switch(r[2]){case"commit":return kd.Commit;case"merge_requests":return kd.MergeRequest;case"blob":return kd.File;default:return kd.Other}})(r,o,window.location.pathname);return{owner:r,projectName:o,rawRepoName:[Ic?window.location.hostname:new URL(gon.gitlab_url).hostname,r,o].join("/"),repoName:t,pageKind:i}}const Ad=()=>{let e=window.location.pathname.match(/merge_requests\/(.*?)\/diffs/);if(!e&&document.querySelector(".diffs-tab.active")&&(e=window.location.pathname.match(/merge_requests\/(.*?)((\/)|$)/)),!e)throw new Error("Unable to determine merge request ID");return e[1]},Id=e=>{const t=e.dataset.originalTitle||e.dataset.title||e.title;if(!t)throw new Error("Unable to get file paths from code view: no file title");return t.endsWith(" deleted")?t.slice(0,-8):t};function Pd(e){const t=e.querySelectorAll(".file-title-name");if(0===t.length)throw new Error("Unable to get file paths from code view: no .file-title.name");const n=t.length>1,r=Id(t.item(n?1:0));return{headFilePath:r,baseFilePath:n?Id(t.item(0)):r}}function Rd(){const{rawRepoName:e,owner:t,projectName:n}=Nd();return{rawRepoName:e,owner:t,projectName:n,commitID:Cd()(window.location.pathname.split("/"))}}const Dd="codeHost-module__command-list-popover_hwImg",Ld="codeHost-module__hover-overlay_3Cize";const Md=(e,t)=>{const n=e.querySelector(".sg-toolbar-mount-gitlab");if(n)return n;const r=e.querySelector(".file-actions");if(!r)throw new Error("Unable to find mount location");const o=document.createElement("div");return o.classList.add("sg-toolbar-mount","sg-toolbar-mount-gitlab"),t===kd.Commit&&o.classList.add("gl-mr-3"),r.prepend(o),o},jd={dom:hd,getToolbarMount:e=>Md(e,kd.File),resolveFileInfo:()=>{const{rawRepoName:e,filePath:t,revision:n}=function(){const{rawRepoName:e}=Nd(),t=window.location.pathname.match(/\/blob\/(.*?)\/(.*)/);if(!t)throw new Error("Unable to determine revision or file path");const n=decodeURIComponent(t[1]);return{rawRepoName:e,filePath:decodeURIComponent(t[2]),revision:n}}();if(!t)throw new Error(`Unable to determine the file path of the current file because the current URL (window.location ${window.location.href}) does not have a file path.`);return{blob:{rawRepoName:e,filePath:t,commitID:fe({selector:".js-data-file-blob-permalink-url",hrefRegex:new RegExp("^/.*?/.*?/blob/([0-9a-f]{40})/")}),revision:n}}},getSelections:hp,observeSelections:mp},Fd=e=>{const t=e.querySelector(".js-file-title");if(!t)throw new Error("Could not find .file-title element");return[t]},Bd={dom:vd,getToolbarMount:e=>Md(e,kd.MergeRequest),resolveFileInfo:e=>{return ee(_d({...Nd(),mergeRequestID:Ad(),diffID:null!==(t=new URLSearchParams(window.location.search).get("diff_id"))&&void 0!==t?t:void 0})).pipe(H((t=>{const{rawRepoName:n,baseRawRepoName:r,commitID:o,baseCommitID:i}=t,{headFilePath:a,baseFilePath:s}=Pd(e);return{head:{rawRepoName:n,filePath:a,commitID:o},base:{rawRepoName:r,filePath:s,commitID:i}}})));var t},getScrollBoundaries:Fd},Ud={dom:vd,getToolbarMount:e=>Md(e,kd.Commit),resolveFileInfo:e=>rr(Rd).pipe(ze((({owner:e,projectName:t,commitID:n,rawRepoName:r})=>xd({owner:e,projectName:t,commitID:n}).pipe(H((e=>({commitID:n,baseCommitID:e,rawRepoName:r})))))),H((({commitID:t,baseCommitID:n,rawRepoName:r})=>{const{headFilePath:o,baseFilePath:i}=Pd(e);return{head:{rawRepoName:r,filePath:o,commitID:t},base:{rawRepoName:r,filePath:i,commitID:n}}}))),getScrollBoundaries:Fd},qd={selector:".file-holder",resolveView:e=>{if(e.classList.contains("discussion-wrapper"))return null;const{pageKind:t}=Nd();return t===kd.Other?null:t===kd.File?{element:e,...jd}:t===kd.MergeRequest?e.querySelector(".file-actions")?{element:e,...Bd}:null:{element:e,...Ud}}},Vd={[Qa]:"alert alert-secondary",[Wa]:"alert alert-success",[Ga]:"alert alert-info",[Ha]:"alert alert-warning",[za]:"alert alert-danger"},$d=(e,t=Dc.fetchCache)=>"gitlab.com"===window.location.hostname&&e?t({url:`https://gitlab.com/api/v4/projects/${encodeURIComponent(e)}`,credentials:"omit",cacheMaxAge:36e5}).then((e=>{const t=e.headers["ratelimit-remaining"];if(Number(t)<=0){const e=new Error("Gitlab rate limit exceeded.");throw up(e),e}return e})).then((({status:e})=>200!==e)).catch((e=>(console.warn("Failed to fetch repository visibility info.",e),!0))):Promise.resolve(!0),zd={type:"gitlab",name:"GitLab",check:function(){return!!document.head.querySelector('meta[content="GitLab"]')},codeViewResolvers:[qd],adjustOverlayPosition:({top:e,left:t})=>{const n=document.querySelector("header");n&&(e+=n.getBoundingClientRect().height);const r=document.querySelector("#js-peek.development");return r&&(e+=r.getBoundingClientRect().height),{top:e,left:t}},getCommandPaletteMount:e=>{const t=he(e,".navbar-collapse");if(!t)return null;const n="command-palette-button";return t.querySelector("."+n)||(()=>{const e=document.createElement("div");return e.className=n,t.prepend(e),e})()},getContext:async()=>{const{repoName:e,...t}=Nd();return{...t,privateRepository:await $d(e)}},urlToFile:(e,t,n)=>{if(t.viewState||!t.rawRepoName.startsWith(window.location.hostname))return ga(e,t);if(Nd().rawRepoName===t.rawRepoName&&void 0!==n.part){const e=bf(document.body,qd.selector);for(const r of e){const{headFilePath:e,baseFilePath:o}=Pd(r);if(e!==t.filePath&&o!==t.filePath)continue;if(!t.position){const e=new URL(window.location.href);return e.hash=r.id,e.href}const i=null!==n.part?{head:".new_line",base:".old_line"}[n.part]:"",a=r.querySelector(`${i} a[data-linenumber="${t.position.line}"]`);if(!a)break;return new URL(a.href).href}}const r=new URL(`https://${t.rawRepoName}/blob/${t.revision}/${t.filePath}`);if(t.position){const{line:e}=t.position;r.hash=`#L${e}`}return r.href},notificationClassNames:Vd,commandPaletteClassProps:{popoverClassName:i()("dropdown-menu",Dd),formClassName:"dropdown-input",inputClassName:"dropdown-input-field",resultsContainerClassName:"dropdown-content",selectedActionItemClassName:"is-focused",noResultsClassName:"px-3",iconClassName:"s16 align-bottom"},codeViewToolbarClassProps:{className:"pl-0",actionItemClass:"btn btn-md gl-button btn-icon",actionItemPressedClass:"active",actionItemIconClass:"gl-button-icon gl-icon s16"},hoverOverlayClassProps:{className:i()("card",Ld),actionItemClassName:"btn btn-secondary",actionItemPressedClassName:"active",iconClassName:"square s16",getAlertClassName:mu(Vd)},codeViewsRequireTokenization:!0,getHoverOverlayMountLocation:()=>{const{pageKind:e}=Nd();return e===kd.MergeRequest?"div.tab-pane.diffs":null}},Hd=e=>Boolean("TH"===e.tagName&&e.textContent||e.dataset.n),Gd=e=>parseInt(("TH"===e.tagName?e.textContent:e.dataset.n)||"",10),Qd=e=>{let t=e;for(;t;){if(Hd(t))return t;t=t.previousElementSibling}return null},Wd=(e,t,n)=>{let r=((e,t,n)=>{const r=e.querySelector("td[data-n]")?"td[data-n]":`th:nth-of-type(${"base"===n?1:2})`;for(const o of e.querySelectorAll(r))if(Gd(o)===t){if("head"===n&&null===o.previousElementSibling)continue;return o}return null})(e,t,n);for(;r&&("TD"!==r.tagName||r.classList.contains("n")||Hd(r)||r.classList.contains("copy"));)r=r.nextElementSibling;return r},Kd={getCodeElementFromTarget:e=>{if("TH"===e.tagName||e.classList.contains("copy"))return null;const t=e.closest("td");return t?t.classList.contains("show-more")||t.classList.contains("show-context")?null:Qd(t)?t:null:null},getCodeElementFromLineNumber:Wd,getLineElementFromLineNumber:Wd,getLineNumberFromCodeElement:e=>{const t=Qd(e);if(!t)throw new Error("Could not find line number cell from code element");return Gd(t)},getDiffCodePart:e=>{if(e.classList.contains("old"))return"base";if(e.classList.contains("new"))return"head";const t=Qd(e);if(!t)throw new Error("Could not find line number cell from code element");return t.classList.contains("left")?"base":t.classList.contains("right")||t.previousElementSibling?"head":"base"},isFirstCharacterDiffIndicator:e=>{const t=e.firstElementChild;return!(null==t||!t.classList.contains("aural-only"))}},Zd=(e,t,n)=>{const r=e.querySelector(`tr:nth-of-type(${t})`);if(!r)throw new Error(`unable to find row ${t} from code view`);return r.querySelector("td")},Yd={getCodeElementFromTarget:e=>e.closest("td"),getCodeElementFromLineNumber:Zd,getLineElementFromLineNumber:Zd,getLineNumberFromCodeElement:e=>{let t=e;for(;null!==t&&"TH"!==t.tagName&&!t.classList.contains("phabricator-source-line");)t=t.previousElementSibling;if(!t)throw new Error("could not find line number cell from code element");const n=t.querySelector("a");if(!n)throw new Error("could not find line number anchor from code element");if(void 0!==n.dataset.n){const e=parseInt(n.dataset.n,10);if(isNaN(e))throw new TypeError(`Could not parse lineNumber from data-n attribute: ${n.dataset.n}`);return e}const r=parseInt(n.textContent||"",10);if(isNaN(r))throw new TypeError(`Could not parse lineNumber from lineAnchor.textContent: ${String(n.textContent)}`);return r},isFirstCharacterDiffIndicator:()=>!1};let Jd;!function(e){e[e.Diffusion=1]="Diffusion",e[e.Differential=2]="Differential",e[e.Revision=3]="Revision",e[e.Change=4]="Change"}(Jd||(Jd={}));const Xd=/r([\dA-z]+)([\da-f]{40})/;function eh(){const e=document.querySelectorAll(".phui-tag-core").item(0);if(!e)throw new Error("Could not find Phabricator page tag");return Xd.exec(e.children[0].getAttribute("href"))}function th(){const e=eh();if(!e)throw new Error("Could not determine callsign from page tag");return e[1]}function nh(){const e=eh();if(!e)throw new Error("Could not determine commitID from page tag");return e[2]}const rh=/Diff (\d+)/;const oh=/^\/?(source|diffusion)\/([\w-]+)\/browse\/([\w-]+\/)?([^$;]+)(;[\da-f]{40})?(?:\$\d+)?/i,ih=/^\/?(d\d+)(?:\?(?:(?:id=(\d+))|(vs=(?:\d+|on)&id=\d+)))?/i,ah=/^\/?r([\dA-z]+)([\da-f]{40})/i,sh=/^\/?(source|diffusion)\/([\da-z]+)\/change\/([\w-]+)\/([^;]+)(;[\da-f]{40})?/i,ch=/^\/?\/differential\/changeset.*/i,lh=/^vs=((?:\d+|on))&id=(\d+)/i;function uh(e,t,n){try{const r=e.href.replace(e.origin,""),o=oh.exec(r);if(o){const e=o[4];if(!e)throw new Error(`Could not determine file path from diffusionMatch, stateUrl: ${r}`);return vh(th(),t,n).pipe(H((({rawRepoName:t})=>({mode:Jd.Diffusion,rawRepoName:t,filePath:e,commitID:nh()}))))}const i=ih.exec(r);if(i){const e=i[1],r=i[3],o=parseInt(e.split("D")[1],10);let a,s=i[2]?parseInt(i[2],10):void 0;if(s||(s=function(){const e=document.querySelector("#differential-review-stage");if(!e)throw new Error("no element with id differential-review-stage found on page.");const t=e.parentElement;if(!t)throw new Error("parent container of diff container not found.");const n=t.children[0].querySelectorAll(".phui-header-header").item(0);if(!n||!n.textContent)throw new Error("Could not find diffTitle element, or it had no text content");const r=rh.exec(n.textContent);if(!r)throw new Error(`diffTitle element does not match pattern. Content: '${n.textContent}'`);return parseInt(r[1],10)}()),r){const e=lh.exec(r),t=null==e?void 0:e[1];t&&"on"!==t&&(a=parseInt(t,10),console.log(`comparison diffID ${s} baseDiffID ${a}`))}return yh(o,t,n).pipe(H((({rawRepoName:e})=>({baseRawRepoName:e,headRawRepoName:e,revisionID:o,diffID:s,baseDiffID:a,mode:Jd.Differential}))))}const a=ah.exec(r);if(a){const e=a[1],r=a[2],o=function(){const e=document.querySelectorAll(".phui-property-list-key");for(const t of e)if("Parents "===t.textContent){const e=t.nextSibling.children[0].children[0].href,n=new URL(e),r=ah.exec(n.pathname);if(r)return r[2]}throw new Error("Could not determine base commit ID from revision page")}();return vh(e,t,n).pipe(H((({rawRepoName:e})=>({mode:Jd.Revision,rawRepoName:e,baseCommitID:o,headCommitID:r}))))}const s=sh.exec(r);if(s){const e=s[8],r=th(),o=nh();return vh(r,t,n).pipe(H((({rawRepoName:t})=>({mode:Jd.Change,filePath:e,rawRepoName:t,commitID:o}))))}if(ch.exec(r)){const e=document.querySelector(".phui-crumbs-view");if(!e)throw new Error("failed parsing changeset dom");const[,r,o]=e.querySelectorAll("a"),i=r.getAttribute("href").match(/D(\d+)/);if(!i)throw new Error("failed parsing differentialID");const a=parseInt(i[1],10),s=o.getAttribute("href").match(/\/differential\/diff\/(\d+)/);if(!s)throw new Error("failed parsing diffID");const c=parseInt(s[1],10);return yh(a,t,n).pipe(H((({rawRepoName:e})=>({baseRawRepoName:e,headRawRepoName:e,revisionID:a,diffID:c,mode:Jd.Differential}))))}throw new Error(`Could not determine Phabricator state from stateUrl ${r}`)}catch(e){return vt(e)}}function fh(e){let t=e;if(t=t.replace("\\",""),e.startsWith("git@"))t=e.slice("git@".length),t=t.replace(":","/");else if(e.startsWith("git://"))t=e.slice("git://".length);else if(e.startsWith("https://"))t=e.slice("https://".length);else if(e.includes("@")){t=e.split("@")[1],t=t.replace(":","/")}return t.replace(/.git$/,"")}function ph(e,t){const n=function(){const e=document.querySelector(".phabricator-search-menu form");if(!e)throw new Error("cannot create conduit request form");const t=new FormData;return t.set("__csrf__",e.querySelector("input[name=__csrf__]").value),t.set("__form__",e.querySelector("input[name=__form__]").value),t}();for(const[e,r]of Object.entries(t))n.set(`params[${e}]`,JSON.stringify(r));return ar(window.location.origin+e,{method:"POST",body:n,credentials:"include",headers:{Accept:"application/json"},selector:e=>ur(e).json()}).pipe(H((e=>{if(null!==e.error_code)throw new Error(`error ${e.error_code}: ${e.error_info}`);return e.result})))}const dh=jo((({diffID:e,revisionID:t,queryConduit:n=ph})=>n("/api/differential.querydiffs",{ids:[e],revisionIDs:[t]}).pipe(H((t=>t[String(e)])))),(({diffID:e,revisionID:t})=>`${e}-${t}`)),hh=jo((({diffID:e,queryConduit:t=ph})=>t("/api/differential.getrawdiff",{diffID:e})),(({diffID:e})=>e.toString())),mh=jo((({revisionID:e,queryConduit:t=ph})=>t("/api/differential.query",{ids:[e]}).pipe(H((t=>{const n=t[0].repositoryPHID;if(!n)throw new Error(`no repositoryPHID for revision ${e}`);return n})))),(({revisionID:e})=>e.toString())),gh=jo((({requestGraphQL:e,...t})=>e({request:fr`
|
|
102
|
+
`,variables:{...e,source:Ci.CODEHOSTINTEGRATION,argument:e.argument&&JSON.stringify(e.argument),publicArgument:e.publicArgument&&JSON.stringify(e.publicArgument)},mightContainPrivateInfo:!1}).subscribe({error:e=>{}})})({name:e,userCookieID:o,url:this.sourcegraphURL,argument:{platform:this.platform,version:this.version,...t},publicArgument:{platform:this.platform,version:this.version,...n}},this.requestGraphQL)}async log(e,t,n){switch(e){case"findReferences":await this.logEvent(e,t,n,Ui.CODEINTELINTEGRATIONREFS);break;case"goToDefinition":case"goToDefinition.preloaded":case"hover":await this.logEvent(e,t,n,Ui.CODEINTELINTEGRATION);break;default:await this.logEvent(e,t,n)}}async logViewEvent(e,t){await this.logEvent(`View${e}`,t)}async logPageView(e,t,n){await this.logEvent(`${e}Viewed`,t,n)}}const ql={allowErrorReporting:!1,sendTelemetry:!0,experimentalLinkPreviews:!1,experimentalTextFieldCompletion:!1,clickToGoToDefinition:!1},Vl=({get:e,set:t})=>({set:t,enable:e=>t(e,!0),disable:e=>t(e,!1),async isEnabled(t){const n=await e(t);return"boolean"==typeof n?n:ql[t]},async toggle(n){const r=await e(n);return await t(n,!r),!r}});const $l=Vl({get:async function(e){const{featureFlags:t={}}=await qc.sync.get();return t[e]},set:async function(e,t){const{featureFlags:n}=await qc.sync.get("featureFlags");await qc.sync.set({featureFlags:{...n,[e]:t}})}}),zl=Vl({get:async e=>{const t=localStorage.getItem(e);return null===t?void 0:"true"===t},set:async(e,t)=>{localStorage.setItem(e,String(t))}}),Hl=Pc?zl:$l,Gl={sendTelemetry:!1,allowErrorReporting:!1,experimentalLinkPreviews:!1,experimentalTextFieldCompletion:!1,clickToGoToDefinition:!1},Ql=e=>({...Gl,...e}),Wl=()=>(Ic?Vc("sync","featureFlags"):z(void 0)).pipe(H(Ql));function Kl(e){return Wl().pipe(H((t=>t[e])),Qe())}const Zl=e=>jc(e).pipe(H((t=>!(Lc()&&e)||!Uc(t)))),Yl=e=>Oe([Zl(e),Kl("sendTelemetry")]).pipe(H((([e,t])=>!!e||t)));function Jl(){const{host:e,pathname:t}=location,[n,r]=t.slice(1).split("/");if(!n||!r)throw new ll(`Could not parse repoName from Bitbucket Cloud url: ${location.href}`);return`${e}/${n}/${r}`}const Xl={getCodeElementFromTarget:e=>e.closest(".view-line > span"),getLineNumberFromCodeElement:e=>{if(!document.querySelector(".line-number"))throw new Error("No line number elements found on the currently viewed page");const t=e.closest(".react-monaco-editor-container");if(!t)throw new Error("No editor found");const n=e.closest(".view-line"),r=[...t.querySelectorAll(".view-line")].findIndex((e=>e===n)),o=t.querySelectorAll(".line-number")[r];if(o){var i,a,s;let e=parseInt(null!==(i=o.dataset.lineNum)&&void 0!==i?i:"",10);if(!isNaN(e))return e;if(e=parseInt(null!==(a=null===(s=o.textContent)||void 0===s?void 0:s.trim())&&void 0!==a?a:"",10),!isNaN(e))return e}throw new Error("Could not find line number")},getLineElementFromLineNumber:eu,getCodeElementFromLineNumber:(e,t)=>{const n=eu(e,t);if(!n)return null;const r=n.querySelector(":scope > span");return r||console.error(`Could not find code element inside .view-line container for line #${t}`),r}};function eu(e,t){let n=e.querySelector(`[data-line-num="${t}"]`);if(!n)for(const o of e.querySelectorAll(".line-number")){var r;if(parseInt(null!==(r=o.textContent)&&void 0!==r?r:"",10)===t){n=o;break}}if(!n)return console.error(`Could not find line number element for line #${t}`),null;const o=[...e.querySelectorAll(".line-number")].findIndex((e=>e===n)),i=e.querySelectorAll(".view-line")[o];return i||console.error(`Could not find line element for line #${t}`),i}function tu(e,t,n){var r,o;const i=null===(r=e.querySelector(`[aria-label="${"base"===n?"From":"To"} line ${t}"]`))||void 0===r||null===(o=r.closest(".line-wrapper"))||void 0===o?void 0:o.querySelector(".code-component");if(!i)throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`);return i}const nu={getCodeElementFromTarget:e=>e.closest(".code-diff"),getLineNumberFromCodeElement:e=>{var t;const n=e.closest(".line-wrapper"),r=null==n?void 0:n.querySelectorAll(".line-number-permalink");if(!r||0===r.length)throw new Error("Could not find line number permalink(s) for code element");const o=r[r.length-1],i=parseInt(null!==(t=o.textContent)&&void 0!==t?t:"",10);if(!isNaN(i))return i;throw new Error("Could not find line number for code element")},getLineElementFromLineNumber:tu,getCodeElementFromLineNumber:(e,t,n)=>{var r;return null===(r=tu(e,t,n))||void 0===r?void 0:r.querySelector(".code-diff")},getDiffCodePart:e=>{var t,n,r;const o=e.closest(".code-component"),i=null==o?void 0:o.querySelector(".line-type");if(null!=i&&null!==(t=i.textContent)&&void 0!==t&&t.includes("+"))return"head";if(null!=i&&null!==(n=i.textContent)&&void 0!==n&&n.includes("+"))return"base";if(!e.closest(".side-by-side"))return"head";const a=e.closest(".line-wrapper");if(null!=a&&a.id)return null!=a&&a.id.includes("oldline")?"base":"head";return 0===[...(null==a||null===(r=a.parentElement)||void 0===r?void 0:r.childNodes)||[]].findIndex((e=>e===a))?"base":"head"},isFirstCharacterDiffIndicator:()=>!1};function ru(e,t,n){var r;const o=null===(r=e.querySelector(`[data-${"base"===n?"f":"t"}num="${t}"]`))||void 0===r?void 0:r.closest(".udiff-line");if(!o)throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`);return o}const ou={getCodeElementFromTarget:e=>e.closest(".source"),getLineNumberFromCodeElement:e=>{const t=e.closest(".udiff-line");if(!t)throw new Error("Could not find line element");const n=t.querySelector(".line-numbers");if(!n)throw new Error("Could not find line numbers element");const r=null==n?void 0:n.dataset.tnum;if(r){const e=parseInt(r,10);if(!isNaN(e))return e}const o=null==n?void 0:n.dataset.fnum;if(o){const e=parseInt(o,10);if(!isNaN(e))return e}throw new Error("Could not find line number for code element")},getLineElementFromLineNumber:ru,getCodeElementFromLineNumber:(e,t,n)=>{var r;return null===(r=ru(e,t,n))||void 0===r?void 0:r.querySelector(".source")},getDiffCodePart:e=>{const t=e.closest(".udiff-line");if(!t)throw new Error("Could not find line element for code element");return t.classList.contains("deletion")?"base":"head"},isFirstCharacterDiffIndicator:()=>!0},iu=e=>e.replace("//","/"),au=["modified","renamed","removed","added"];function su(){const e=Jl(),t=location.pathname.match(/src\/(.*?)\/(.*)/);if(!t)throw new Error("Unable to determine revision or file path");const n=decodeURIComponent(t[1]),r=decodeURIComponent(t[2]),o=function(){const e=['a[type="button"]',"a"];for(const t of e){const e=document.querySelectorAll(t);for(const t of e){const e=t.href.match(/full-commit\/([\da-f]{40})\//);if(e)return e[1]}}return null}();return{blob:{rawRepoName:e,revision:n,filePath:r,commitID:null!=o?o:n}}}function cu(e){const t=Jl(),n=function(e){const t=[...e.querySelectorAll('[data-qa="bk-file__header"] span')];for(const e of t)for(const t of au){var n;if(null!==(n=e.textContent)&&void 0!==n&&n.toLowerCase().includes(t))return t}return"modified"}(e),{base:r,head:o}=function(e,t){var n;const r=null===(n=e.querySelector('[data-qa="bk-filepath"]'))||void 0===n?void 0:n.cloneNode(!0),o=null==r?void 0:r.textContent;if(!(r instanceof HTMLElement&&o))throw new Error("Could not find breadcrumbs component for code view");if("added"===t)return{head:o};if("removed"===t)return{base:o};if("modified"===t)return{base:o,head:o};const i="<>SEPARATOR<>",a=r.querySelectorAll('[aria-label="arrow"]');for(const e of a)e.textContent=i;const[s,c,l]=r.textContent.split(/[{}]/),[u,f]=c.split(i);return{base:iu(s+u+l),head:iu(s+f+l)}}(e,n),{baseRevision:i,headRevision:a}=function(){var e,t;const n=document.querySelector('[data-qa="pr-branches-and-state-styles"]');if(!n)throw new Error("Could not find branches element");const r=[...n.querySelectorAll('[aria-hidden="true"]')];if(2!==r.length)throw new Error("Expected source and destination branch elements");const o=null!==(e=r[0].textContent)&&void 0!==e?e:"";return{baseRevision:null!==(t=r[1].textContent)&&void 0!==t?t:"",headRevision:o}}();return"added"===n?{head:{rawRepoName:t,filePath:o,commitID:a,revision:a}}:"removed"===n?{base:{rawRepoName:t,filePath:r,commitID:i,revision:i}}:{head:{rawRepoName:t,filePath:o,commitID:a,revision:a},base:{rawRepoName:t,filePath:r,commitID:i,revision:i}}}function lu(e){const t=Jl(),n=function(e){const t=e.querySelector(".diff-entry-lozenge");for(const e of au){var n;if(null!=t&&null!==(n=t.textContent)&&void 0!==n&&n.toLowerCase().includes(e))return e}return"modified"}(e),{head:r,base:o}=function(e,t){var n;const r=null===(n=e.querySelector(".filename"))||void 0===n?void 0:n.cloneNode(!0);if(!r)throw new Error("Could not find breadcrumbs component for code view");for(const e of r.childNodes)e instanceof HTMLSpanElement&&(e.textContent=null);const o=r.textContent.trim();if("added"===t)return{head:o};if("removed"===t)return{base:o};if("modified"===t)return{base:o,head:o};const[i,a,s]=o.split(/[{}]/).map((e=>e.trim())),[c,l]=a.split("\u2192").map((e=>e.trim()));return{base:iu(i+c+s),head:iu(i+l+s)}}(e,n),{baseCommitID:i,headCommitID:a}=function(){var e;const t=null===(e=document.querySelector('[title="Parent commit"]'))||void 0===e?void 0:e.href.match(/\/commits\/(.*)/);if(!t)throw new Error("Could not determine base commit ID");const n=t[1],r=window.location.href.match(/\/commits\/(.*)/);if(!r)throw new Error("Could not determine head commit ID");return{baseCommitID:n,headCommitID:r[1]}}();return"added"===n?{head:{rawRepoName:t,filePath:r,commitID:a}}:"removed"===n?{base:{rawRepoName:t,filePath:o,commitID:i}}:{head:{rawRepoName:t,filePath:r,commitID:a},base:{rawRepoName:t,filePath:o,commitID:i}}}const uu="codeHost-module__icon_3KtzB",fu="codeHost-module__commit-container_8Jft-";function pu(e){const t=e.querySelector(".sg-toolbar-mount");if(t)return t;const n=e.querySelector('[data-testid="file-actions"');if(!n)throw new Error("Unable to find mount location");const r=document.createElement("div");return r.classList.add("sg-toolbar-mount"),n.prepend(r),r}function du(e){const t=e.querySelector(".sg-toolbar-mount");if(t)return t;const n=e.querySelector(".diff-actions");if(!n)throw new Error("Unable to find mount location");n.classList.add(fu);const r=document.createElement("div");return r.classList.add("sg-toolbar-mount"),n.prepend(r),r}const hu={type:"bitbucket-cloud",name:"Bitbucket Cloud",codeViewResolvers:[{selector:e=>{const t=e.querySelector('[data-qa="bk-file__header"]'),n=e.querySelector('[data-qa="bk-file__content"]');if(!t||!n)return null;let r=t;for(;!r.contains(n);){if(!r.parentElement)return null;r=r.parentElement}return[r]},resolveView:e=>function({pathname:e}){return/\/pull-requests\/\d+/.test(e)}(window.location)?{element:e,getToolbarMount:pu,dom:nu,resolveFileInfo:cu}:{element:e,getToolbarMount:pu,dom:Xl,resolveFileInfo:su}},{selector:".bb-udiff",resolveView:e=>({element:e,getToolbarMount:du,dom:ou,resolveFileInfo:lu})}],getContext:async function(){const e=Jl();return Promise.resolve({rawRepoName:e,revision:"",privateRepository:!1})},getViewContextOnSourcegraphMount:function(e){var t;const n="open-on-sourcegraph",r=he(e,'[data-qa="page-header-wrapper"] > div > div');if(!r)return null;let o=r.querySelector("#open-on-sourcegraph");if(o)return o;o=document.createElement("span"),o.id=n;const i=null===(t=r.childNodes[1])||void 0===t?void 0:t.childNodes[1].firstChild;return i instanceof HTMLElement?i.append(o):r.append(o),o},check:function(){return"bitbucket.org"===location.hostname},viewOnSourcegraphButtonClassProps:{className:"codeHost-module__open-on-sourcegraph_10lR9",iconClassName:uu},codeViewToolbarClassProps:{className:"codeHost-module__code-view-toolbar_N0wZ1",listItemClass:"codeHost-module__list-item_370zl",actionItemClass:"codeHost-module__code-view-toolbar-action-item_2p6Pr",actionItemPressedClass:"codeHost-module__pressed_1ksxF",actionItemIconClass:uu},hoverOverlayClassProps:{className:"codeHost-module__hover-overlay_2e1lQ",badgeClassName:"codeHost-module__badge_16Tsk",actionItemClassName:"codeHost-module__hover-overlay-action-item_39z-G",iconClassName:uu,contentClassName:"codeHost-module__content_eSBN7"},notificationClassNames:{1:"",2:"",3:"",4:"",5:""},codeViewsRequireTokenization:!0},mu=(e,t)=>n=>i()(e[n],t),gu=/\/projects\/([^/]+)\/repos\/([^/]+)\//;const vu=(e,t)=>{const n=e.querySelector(`[data-line-number="${t}"]`);if(!n)throw new Error(`Line ${t} not found in code view`);const r=n.closest(".line");if(!r)throw new Error("Could not find line elem for line element");return r},bu={getCodeElementFromTarget:e=>{const t=e.closest(".CodeMirror-line");return t?t.querySelector('span[role="presentation"]'):null},getLineNumberFromCodeElement:e=>{const t=e.closest(".line");if(!t)throw new Error("Could not find line containing code element");const n=t.querySelector(".line-locator");if(!n)throw new Error("Could not find the line number in a line container");const r=parseInt(n.dataset.lineNumber||"",10);if(isNaN(r))throw new TypeError("data-line-number not set on line number element");return r},getLineElementFromLineNumber:vu,getCodeElementFromLineNumber:(e,t)=>vu(e,t).querySelector('.CodeMirror-line span[role="presentation"]')},yu=(e,t,n)=>{for(const r of e.querySelectorAll(".line-number-"+("head"===n?"to":"from"))){const e=parseInt((r.textContent||"").trim(),10);if(!isNaN(e)&&e===t){const e=r.closest(".line");if(!e)throw new Error("Could not find lineElem from lineNumElem");return e}}throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`)},wu={getCodeElementFromTarget:bu.getCodeElementFromTarget,getLineNumberFromCodeElement:e=>{const t=e.closest(".line");if(!t)throw new Error("Could not find line containing code element");const n=t.querySelector(".line-number-to");if(n){const e=parseInt((n.textContent||"").trim(),10);if(!isNaN(e))return e}const r=t.querySelector(".line-number-from");if(r){const e=parseInt((r.textContent||"").trim(),10);if(!isNaN(e))return e}throw new Error("Could not find line number element for code element")},getLineElementFromLineNumber:yu,getCodeElementFromLineNumber:(e,t,n)=>yu(e,t,n).querySelector('.CodeMirror-line span[role="presentation"]'),getDiffCodePart:e=>{var t;if(!document.querySelector(".side-by-side-diff"))return e.closest(".line").classList.contains("removed")?"base":"head";return null!==(t=e.closest(".diff-editor").previousElementSibling)&&void 0!==t&&t.classList.contains("segment-connector-column")?"head":"base"},isFirstCharacterDiffIndicator:()=>!1},Eu=(e,t,n)=>{for(const i of e.querySelectorAll(".diff-line-number")){var r;const e=null===(r=i.textContent)||void 0===r?void 0:r.trim().split(" ")[0];if(!e)continue;const a=parseInt(e,10);if(!isNaN(a)&&a===t){var o;const e=null===(o=i.closest("tr"))||void 0===o?void 0:o.querySelector(`.diff-line[data-diff-line="${"head"===n?"TO":"FROM"}"]`);if(!e)throw new Error("Could not find lineElem from lineNumElem");return e}}throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`)},_u={getCodeElementFromTarget:e=>e.closest(".diff-line"),getLineNumberFromCodeElement:e=>{var t;const n=null===(t=e.closest("tr"))||void 0===t?void 0:t.querySelector(".diff-gutter .diff-line-number");if(n){const e=parseInt((n.textContent||"").trim(),10);if(!isNaN(e))return e}throw new Error("Could not find line number element for code element")},getDiffCodePart:e=>{var t;const n=null===(t=e.closest("tr"))||void 0===t?void 0:t.querySelectorAll(".diff-line");if(!n||0===n.length)throw new Error("Could not find diff lines for code element");if(1===n.length)return e.classList.contains("added-line")?"head":"base";const[r,o]=n;return e===r?"base":e===o?"head":e.classList.contains("removed-line")?"base":"head"},getLineElementFromLineNumber:Eu,getCodeElementFromLineNumber:Eu};var xu=n(11570),Su=n.n(xu);const Ou=(e,t,n)=>`${window.AJS?window.AJS.contextPath():window.location.origin}/rest/api/1.0/projects/${encodeURIComponent(e)}/repos/${t}${n}`,Tu=e=>ar(e,{selector:e=>ur(e).json()}),Cu=jo((({project:e,repoSlug:t,prID:n})=>Tu(Ou(e,t,`/pull-requests/${n}`)).pipe(H((({fromRef:e,toRef:t})=>({baseCommitID:t.latestCommit,headCommitID:e.latestCommit}))))),(({prID:e})=>e.toString())),ku=jo((({project:e,repoSlug:t,commitID:n})=>Tu(Ou(e,t,`/commits/${n}`)).pipe(H((({parents:e})=>Su()(e))),qe(Kn),H((({id:e})=>e)))),(({project:e,repoSlug:t,commitID:n})=>`${e}:${t}:${n}`)),Nu=["a.raw-view-link","a.source-view-link","a.mode-source"],Au=({repoSlug:e,project:t})=>[window.location.hostname,t,e].join("/"),Iu=e=>{const t=[];for(const n of Nu)try{const t=e.querySelector(n);if(!t)throw new Error(`Could not find selector ${n} in code view`);const r=new URL(t.href),o=r.pathname,i=o.match(/\/projects\/(.*?)\/repos\/(.*?)\/(?:browse|raw)\/(.*)$/);if(!i)throw new Error(`Path of link matching selector ${n} did not match path regex: ${o}`);const[,a,s,c]=i,l=r.searchParams.get("at");if(!l)throw new Error(`href of link matching selector ${n} did not have 'at' search param: ${r.href}`);const u=l.match(/refs\/heads\/(.*?)$/),f=u?u[1]:l;return{rawRepoName:Au({repoSlug:s,project:a}),filePath:decodeURIComponent(c),revision:f,project:a,repoSlug:s}}catch(e){t.push(e);continue}throw un(t)},Pu=(e="a.commitid")=>{const t=document.querySelector(e);if(!t)throw new Error("No element found matching a.commitid");const n=t.dataset.commitid;if(!n)throw new Error("Element matching a.commitid has no data-commitid");return n},Ru=e=>{const{rawRepoName:t,filePath:n,revision:r,project:o,repoSlug:i}=Iu(e);return{rawRepoName:t,filePath:n,revision:r,commitID:(()=>{const e=document.querySelector("span[data-revision-ref]");if(!e)throw new Error("Could not find span[data-revision-ref] element");try{const{latestCommit:t}=JSON.parse(e.dataset.revisionRef);return t}catch{throw new Error("Could not parse JSON from revision selector")}})(),project:o,repoSlug:i}},Du=({codeViewElement:e})=>e.querySelector(".change-type-lozenge"),Lu=({changeTypeElement:e})=>{if(!e)return"MODIFY";const t=[...e.classList].find((e=>/^change-type-[A-Z]+/.test(e)));if(!t)throw new Error("Could not detect change type from change type element");return t.replace(/^change-type-/,"")},Mu=({filePath:e,changeType:t,changeTypeElement:n})=>{if("ADD"!==t){if("MODIFY"===t||"DELETE"===t)return e;if("MOVE"===t||"RENAME"===t||"COPY"===t){if(!n)throw new Error(`Change type is ${t} but no change type indicator found`);const r=n.getAttribute("original-title");if(!r)throw new Error("Moved change type badge did not have original-title attribute");const o=document.createElement("span");o.innerHTML=r;const i=o.textContent;if("MOVE"===t||"COPY"===t){const e=i.split("\u2192")[0].trim();if(!e)throw new Error(`Unexpected move change type badge content "${i}"`);return e}if("RENAME"===t){const t=/Renamed from '(.+)'/,n=i.match(t);if(!n)throw new Error(`Rename change type badge content did not match ${t.toString()}: "${i}"`);return Aa.join(Aa.dirname(e),n[1])}}throw new Error(`Unexpected change type "${t}"`)}},ju=e=>{var t;const n=null!==(t=e.querySelector(".breadcrumbs"))&&void 0!==t?t:e.querySelector(".file-breadcrumbs");if(!n)throw new Error("Could not find diff code view breadcrumbs element through selector .breadcrumbs");const r=n.textContent;if(!r)throw new Error("Unexpected empty file path in breadcrumbs");const o=location.pathname.match(/\/projects\/(.*?)\/repos\/(.*?)\//);if(!o)throw new Error("Location did not match regexp");const[,i,a]=o,s=Au({project:i,repoSlug:a}),c=Du({codeViewElement:e}),l=Lu({changeTypeElement:c});return{changeType:l,rawRepoName:s,filePath:r,baseFilePath:Mu({changeTypeElement:c,changeType:l,filePath:r})||r,project:i,repoSlug:a}};const Fu=e=>{const t=ju(e),{rawRepoName:n,filePath:r,baseFilePath:o}=t,i=function(){const e=window.location.pathname.match(/pull-requests\/(\d*?)\/(diff|overview|commits)/);if(!e)throw new Error(`Could not parse PR ID from pathname: ${window.location.pathname}`);return parseInt(e[1],10)}();return Cu({...t,prID:i}).pipe(H((({headCommitID:e,baseCommitID:t})=>({head:{rawRepoName:n,filePath:r,commitID:e},base:{rawRepoName:n,filePath:o,commitID:t}}))))},Bu="codeHost-module__command-palette-button_1LPsz",Uu="codeHost-module__command-palette-popover_wqnFp",qu="codeHost-module__no-results_3Di26",Vu="codeHost-module__open-on-sourcegraph_i9J2G",$u="codeHost-module__sg-toolbar-mount_2Fbz5",zu="codeHost-module__code-view-toolbar_IVqgq",Hu="codeHost-module__action-nav-item_223JV",Gu="codeHost-module__action-nav-item-new-diff_23eTl",Qu="codeHost-module__action-item-new-diff_3Tuv4",Wu="codeHost-module__hover-action-item_9CC-W",Ku="codeHost-module__command-list-popover-button_3eptU",Zu=(e,t=".file-toolbar .secondary")=>{const n=e.querySelector(".sg-toolbar-mount");if(n)return n;const r=e.querySelector(t);if(!r)throw new Error("Unable to find mount location");const o=document.createElement("div");return o.classList.add("btn-group"),o.classList.add("sg-toolbar-mount"),o.classList.add($u),r.prepend(o),o},Yu=e=>({direction:t,codeView:n,position:r})=>{const o=e.getCodeElementFromLineNumber(n,r.line,r.part);if(!o)throw new Error("(adjustPosition) could not find code element for line provided");let i=0;for(const e of o.querySelectorAll("[cm-text]")){const t=e.getAttribute("cm-text")||"",n=e.textContent||"";i+=t.length-n.length}const a=t===Fn.ActualToCodeView?-1:1;return z({line:r.line,character:r.character+a*i})},Ju={getToolbarMount:Zu,dom:bu,resolveFileInfo:e=>({blob:Ru(e)}),getPositionAdjuster:()=>Yu(bu)},Xu={getToolbarMount:Zu,dom:wu,getPositionAdjuster:()=>Yu(wu),overrideTokenize:!0},ef={...Xu,resolveFileInfo:e=>{const{changeType:t,rawRepoName:n,filePath:r,commitID:o,baseFilePath:i,revision:a,...s}=(e=>{const{rawRepoName:t,project:n,repoSlug:r,filePath:o}=Iu(e),i=Pu(),a=Du({codeViewElement:e}),s=Lu({changeTypeElement:a});return{changeType:s,rawRepoName:t,filePath:o,baseFilePath:Mu({changeTypeElement:a,changeType:s,filePath:o})||o,commitID:i,project:n,repoSlug:r}})(e);return"ADD"===t?z({head:{rawRepoName:n,filePath:r,commitID:o}}):ku({commitID:o,...s}).pipe(H((e=>"DELETE"===t?{base:{rawRepoName:n,filePath:i,commitID:e}}:{base:{rawRepoName:n,filePath:i,commitID:e},head:{rawRepoName:n,filePath:r,commitID:o}})))}},tf={...Xu,resolveFileInfo:Fu},nf={...Xu,resolveFileInfo:e=>{const{rawRepoName:t,filePath:n,baseFilePath:r}=ju(e),{baseCommitID:o,headCommitID:i}=function(){const e=document.querySelector("#branch-compare .source-selector a.commitid[data-commitid]"),t=document.querySelector("#branch-compare .target-selector a.commitid[data-commitid]");if(!e||!t)throw new Error("Could not resolve Bitbucket compare diff spec");return{headCommitID:e.getAttribute("data-commitid"),baseCommitID:t.getAttribute("data-commitid")}}();return{base:{rawRepoName:t,filePath:r,commitID:i},head:{rawRepoName:t,filePath:n,commitID:o}}}},rf={...Xu,resolveFileInfo:e=>(e=>{const t=Pu(".commit-badge-oneline .commitid"),n=Pu(".commit-parents .commitid"),{rawRepoName:r,filePath:o,baseFilePath:i}=ju(e);return{head:{rawRepoName:r,filePath:o,commitID:t},base:{rawRepoName:r,filePath:i,commitID:n}}})(e)},of={selector:".change-view",resolveView:e=>({element:e,...af})},af={resolveFileInfo:Fu,getToolbarMount:e=>Zu(e,".change-header .diff-actions"),toolbarButtonProps:{listItemClass:Gu,actionItemClass:Qu},dom:_u};const sf="aui-icon",cf={[Qa]:"aui-message aui-message-info",[Wa]:"aui-message aui-message-success",[Ga]:"aui-message aui-message-info",[Ha]:"aui-message aui-message-warning",[za]:"aui-message aui-message-error"},lf={type:"bitbucket-server",name:"Bitbucket Server",check:()=>!!document.querySelector(".bitbucket-header-logo")||!!document.querySelector(".aui-header-logo.aui-header-logo-bitbucket"),codeViewResolvers:[{selector:".file-content",resolveView:e=>{const t=e.querySelector(".content-view");if(!t)return null;if(document.querySelector("#branch-compare"))return{element:e,...nf};if((({pathname:e})=>/\/projects\/[^/]+\/repos\/[^/]+\/commits\/\w+$/.test(e))(window.location))return{element:e,...rf};if(e.querySelector(".mode-toggle")){return t.classList.contains("diff-view")?{element:e,...ef}:{element:e,...Ju}}return(({pathname:e})=>/\/projects\/[^/]+\/repos\/[^/]+\/pull-requests\/\d+/.test(e))(window.location)?{element:e,...tf}:(console.error("Unknown code view",e),null)}},of],getCommandPaletteMount:e=>{const t=he(e,".aui-header-primary .aui-nav");if(!t)return null;const n=["command-palette-button",Bu];return t.querySelector(n.map((e=>`.${e}`)).join(""))||(()=>{const e=document.createElement("li");return e.className=n.join(" "),t.append(e),e})()},notificationClassNames:cf,commandPaletteClassProps:{buttonClassName:i()(Ku,"aui-alignment-target aui-alignment-abutted aui-alignment-abutted-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left"),buttonElement:"a",buttonOpenClassName:"aui-dropdown2-active active aui-alignment-enabled",showCaret:!1,popoverClassName:i()(Uu,"aui-dropdown2 aui-style-default aui-layer aui-dropdown2-in-header aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-enabled aui-alignment-abutted aui-alignment-abutted-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left"),popoverInnerClassName:"aui-dropdown2-section",formClassName:"aui",inputClassName:"text",resultsContainerClassName:"results",listClassName:"results-list",listItemClassName:"result",selectedListItemClassName:"focused",noResultsClassName:qu,iconClassName:sf},codeViewToolbarClassProps:{className:i()(zu,"aui-buttons"),actionItemClass:"aui-button",actionItemIconClass:"aui-icon",listItemClass:Hu},hoverOverlayClassProps:{className:"aui-dialog",actionItemClassName:i()("aui-button",Wu),getAlertClassName:mu(cf),iconClassName:sf},getViewContextOnSourcegraphMount:function(e){const t=he(e,".branch-selector-toolbar .aui-buttons");if(!t)return null;const n=t.querySelector("#open-on-sourcegraph");if(n)return n;const r=document.createElement("span");return r.id="open-on-sourcegraph",r.className=Vu,t.append(r),r},getContext:async function(){const e=function(e){const{hostname:t,pathname:n}=e,r=n.match(gu);if(!r)throw new Error(`location pathname does not match path regex: ${n}`);const[,o,i]=r;return{rawRepoName:`${t}/${o}/${i}`}}(window.location);let t={};try{t=function(){var e;const t=document.querySelector("#repository-layout-revision-selector .name[data-revision-ref]");if(!t)throw new Error("branchNameElement not found");const n=t.getAttribute("data-revision-ref");let r=null;if(n)try{r=JSON.parse(n)}catch{throw new Error(`Could not parse revisionRefStr: ${n}`)}if(null!==(e=r)&&void 0!==e&&e.latestCommit)return{revision:r.latestCommit};throw new Error(`revisionRefInfo is empty or has no latestCommit (revisionRefStr: ${String(n)})`)}()}catch{}return Promise.resolve({...e,...t,privateRepository:"bitbucket.org"!==window.location.hostname})},viewOnSourcegraphButtonClassProps:{className:"aui-button",iconClassName:sf},codeViewsRequireTokenization:!1};var uf=n(65291),ff=n.n(uf),pf=n(92674),df=n.n(pf),hf=n(26416),mf=n.n(hf);function gf(e){return new B((function(t){var n;try{n=e()}catch(e){return void t.error(e)}return(n?ee(n):Ne()).subscribe(t)}))}function vf(e){return t=>gf((()=>{const n=new Map;return t.pipe(wt(Me),ce(),tt((({removedNodes:e})=>{for(const t of e){if(!(t instanceof HTMLElement))continue;const e=n.get(t);if(e)e.subscriptions.unsubscribe(),n.delete(t);else for(const[e,r]of n.entries())t.contains(e)&&(r.subscriptions.unsubscribe(),n.delete(e))}})),oe((t=>ee(t.addedNodes).pipe(qe(Wn(HTMLElement)),oe((t=>ee(e).pipe(oe((({selector:e,resolveView:n})=>[...bf(t,e)].map((e=>{const t=n(e);return t&&{...t,subscriptions:new g}})))),qe(Kn),qe((e=>!n.has(e.element))),tt((e=>{n.set(e.element,e)})))))))))}))}function bf(e,t){if("string"==typeof t)return de(e,t);return t(e)||[]}const yf=/patchset (\d+)/i;function wf(e,t){return`refs/changes/${e.slice(-2).padStart(2,"0")}/${e}/${t}`}function Ef(e){var t,n;return null!==(t=null===(n=If(document.body,e))||void 0===n?void 0:n.textContent)&&void 0!==t?t:void 0}function _f(e){const t=yf.exec(e);if(null!=t&&t[1])return t[1]}function xf(){const e=new URL(window.location.href).pathname.split("/"),t=e.indexOf("c"),n=e.indexOf("+"),r=e.slice(t+1,n).join("/"),o=e[n+1],i=e[n+2],a=e.slice(n+3).join("/"),s=window.location.hostname+"/"+r,{basePatchsetId:c,headPatchsetId:l}=function(){var e,t;const n=null!==(e=Ef("#app >> #app-element >> gr-change-view >> #fileListHeader >> #rangeSelect >> #basePatchDropdown >> #triggerText"))&&void 0!==e?e:Ef("#app >> #app-element >> gr-diff-view >> #rangeSelect >> #basePatchDropdown >> #triggerText"),r=null!==(t=Ef("#app >> #app-element >> gr-change-view >> #fileListHeader >> #rangeSelect >> #patchNumDropdown >> #triggerText"))&&void 0!==t?t:Ef("#app >> #app-element >> gr-diff-view >> #rangeSelect >> #patchNumDropdown >> #triggerText");return{basePatchsetId:n&&_f(n),headPatchsetId:r&&_f(r)}}();return{repoName:s,changeId:o,patchsetId:l||i,filePath:a,basePatchsetId:c}}const Sf={selector(e){var t;if(e.matches("#diffTable"))return[e];const n=If(document,"#app >> #app-element >> gr-change-view >> #fileList"),r=[...(null==n||null===(t=n.shadowRoot)||void 0===t?void 0:t.querySelectorAll(".file-row.expanded"))||[]].map((e=>{const t=e.parentElement;if(t)return If(t,"gr-diff-host >> gr-diff >> #diffTable")}));return mf()(r)},resolveView(e){const t=Pf(e,".stickyArea");if(!t)return null;const n=t.querySelector(".file-row"),r=null==n?void 0:n.getAttribute("data-path");if(!r)return null;const o=xf();if(!o.patchsetId)return console.error("Sourcegraph: Cannot get Gerrit patchset ID"),null;const i=wf(o.changeId,o.patchsetId);let a;return a=o.basePatchsetId?wf(o.changeId,o.basePatchsetId):function(){var e,t,n;const r=If(document.body,"#app >> #app-element >> gr-change-view >> #metadata >> gr-commit-info");if(!r)return null;return null==r||null===(e=r.shadowRoot)||void 0===e||null===(t=e.querySelector(".container"))||void 0===t||null===(n=t.textContent)||void 0===n?void 0:n.trim()}()||i+"^",Df(e),{element:e,dom:Tf,resolveFileInfo(){const e={base:{filePath:r||"",rawRepoName:o.repoName,commitID:a},head:{filePath:r||"",rawRepoName:o.repoName,commitID:i}};return console.log("resolveFileListCodeView: fileInfo",e),e}}}},Of=(e,t,n)=>{const r="head"===n?"right":"left",o=e.querySelector(`td.lineNum.${r}[data-value="${t}"]`);if(!o)return null;const i=function(e,t){var n;const r=[...(null===(n=e.parentElement)||void 0===n?void 0:n.childNodes)||[]],o=r.slice(r.indexOf(e)+1);for(const e of o)if(e instanceof HTMLElement&&e.matches(t))return e;return null}(o,"td.content");return null==i?void 0:i.querySelector(".contentText")},Tf={getLineElementFromLineNumber:Of,getCodeElementFromLineNumber:Of,getCodeElementFromTarget:e=>{var t;const n=e.closest("td.content"),r=null==n||null===(t=n.closest("tr"))||void 0===t?void 0:t.querySelector("[data-line-number]");if(r){if("FILE"===r.getAttribute("data-line-number"))return null}return n},getLineNumberFromCodeElement:e=>{var t;const n=Af(e);if(!n)throw console.error(e),new TypeError("Could not find line number (no side)");const r=e.closest("td"),o=null==r||null===(t=r.parentElement)||void 0===t?void 0:t.querySelector(`.lineNum.${n}`),i=null==o?void 0:o.getAttribute("data-value");if(!i)throw new TypeError(`Could not find line number (${n})`);return parseInt(i,10)},getDiffCodePart:e=>{const t=Af(e);return"left"===t?"base":"right"===t?"head":(console.error("Cannot tell: base or head"),"base")}},Cf=[{selector(e){const t=If(document.body,"#app >> #app-element >> gr-diff-view >> #diffHost >> #diff >> #diffTable");return t?[t]:[]},resolveView(e){const t=xf();if(!t.patchsetId)return console.error("Sourcegraph: cannot find patchset ID"),null;const n=wf(t.changeId,t.patchsetId);let r=n+"^";return t.basePatchsetId&&(r=wf(t.changeId,t.basePatchsetId)),Df(e),{element:e,dom:Tf,getToolbarMount(e){var t;const n=null===(t=function(e){var t;const n=Pf(e,"gr-diff-view");return null==n||null===(t=n.shadowRoot)||void 0===t?void 0:t.querySelector("gr-fixed-panel .subHeader")}(e))||void 0===t?void 0:t.querySelector(".patchRangeLeft");if(!n)throw new Error("Could not find subheader");const r=n.querySelector(".sourcegraph-toolbar-mount");if(r)return r;const o=document.createElement("div");return o.classList.add("sourcegraph-toolbar-mount"),n.append(o),n.append(Rf(Lf)),o},resolveFileInfo(){const e={base:{filePath:t.filePath||"",rawRepoName:t.repoName,commitID:r},head:{filePath:t.filePath||"",rawRepoName:t.repoName,commitID:n}};return console.log("resolveFilePageCodeView: fileInfo",e),e}}}},Sf],kf={type:"gerrit",name:"Gerrit",codeViewResolvers:Cf,contentViewResolvers:[],nativeTooltipResolvers:[],codeViewsRequireTokenization:!0,observeMutations:(e,t,n)=>{let r=[];return Xc(1500).pipe(H((()=>{const{filePath:e=""}=xf(),t=[...Cf.map((e=>e.selector)),Nf].map((e=>[...bf(document.body,e)])).flat(),n=t.filter((t=>!df()(r,{element:t,filePath:e}))),o=r.filter((n=>!(n.filePath===e&&t.find((e=>e===n.element)))));for(const t of n)r.push({element:t,filePath:e});return r=r.filter((e=>!df()(o,e))),{addedNodes:n,removedNodes:o.map((e=>e.element))}})),qe((({addedNodes:e,removedNodes:t})=>!!e.length||!!t.length)),H((e=>[e])),Lo(),Bt())},getContext:async()=>{const{repoName:e,changeId:t,patchsetId:n}=xf();return Promise.resolve({privateRepository:!0,rawRepoName:e,revision:n&&wf(t,n)})},check:function(){return!!document.querySelector("gr-app#app")},notificationClassNames:{1:"",2:"",3:"",4:"",5:""},hoverOverlayClassProps:{className:"codeHost-module__hover-overlay_1jwSd"},codeViewToolbarClassProps:{className:"code-view-toolbar--gerrit",actionItemIconClass:"icon--gerrit"},viewOnSourcegraphButtonClassProps:{className:"open-on-sourcegraph--gerrit",iconClassName:"open-on-sourcegraph-icon--gerrit"},getViewContextOnSourcegraphMount:e=>{const t=ff()(Nf(e));if(!t)return null;const n=t.querySelector(".open-in-sourcegraph-mount");if(n)return n;const r=document.createElement("gr-button");return r.setAttribute("link","link"),r.classList.add("open-in-sourcegraph-mount"),t.prepend(r),t.append(Rf(Lf)),r}},Nf=()=>{const e=If(document.body,"#app >> #app-element >> gr-change-view >> #actions >> #secondaryActions");return e?[e]:null};function Af(e){var t,n;if("unified"===function(e){const t=e.closest("tr");return null!=t&&t.matches(".unified")?"unified":"side-by-side"}(e)){var r,o;return(null===(r=e.closest("tr"))||void 0===r||null===(o=r.querySelector("td.right"))||void 0===o?void 0:o.getAttribute("data-value"))?"right":"left"}return null!==(t=e.closest("td"))&&void 0!==t&&null!==(n=t.previousElementSibling)&&void 0!==n&&n.matches(".right")?"right":"left"}function If(e,t){var n;"string"==typeof t&&(t=t.split(">>"));let r=e;const o=t.slice(0,-1),i=t[t.length-1];for(const e of o){var a;if(!r)return null;r=(null===(a=r.querySelector(e))||void 0===a?void 0:a.shadowRoot)||null}return null===(n=r)||void 0===n?void 0:n.querySelector(i)}function Pf(e,t){for(;;){var n;const r=e.closest(t);if(r)return r;if(!(e=null===(n=e.getRootNode())||void 0===n?void 0:n.host)||e===document.getRootNode())return null}}function Rf(e){const t=document.createElement("style");return t.textContent=e,t}function Df(e){if(!e.querySelector("style.sourcegraph-injected-style")){const t=Rf(Mf);t.classList.add("sourcegraph-injected-style"),e.append(t)}}const Lf="\n.icon--gerrit {\n height: 1.3rem;\n width: 1.3rem;\n padding: 5px 4px;\n}\n.open-on-sourcegraph-icon--gerrit {\n height: 1rem;\n width: 1rem;\n}\n.open-on-sourcegraph--gerrit {\n text-decoration: none;\n}\n",Mf="\n.sourcegraph-document-highlight {\n background-color: var(--secondary);\n}\n.selection-highlight {\n background-color: var(--mark-bg);\n}\n";var jf,Ff,Bf=n(36021),Uf=n.n(Bf);!function(e){e.Ok="ok",e.Exited="exited",e.Crashed="crashed",e.Abnormal="abnormal"}(jf||(jf={})),function(e){e.Ok="ok",e.Errored="errored",e.Crashed="crashed"}(Ff||(Ff={}));var qf=n(97753),Vf=n(91698),$f=(0,qf.Rf)(),zf="Sentry Logger ",Hf=function(){function e(){this._enabled=!1}return e.prototype.disable=function(){this._enabled=!1},e.prototype.enable=function(){this._enabled=!0},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._enabled&&(0,qf.Cf)((function(){$f.console.log(zf+"[Log]: "+e.join(" "))}))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._enabled&&(0,qf.Cf)((function(){$f.console.warn(zf+"[Warn]: "+e.join(" "))}))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._enabled&&(0,qf.Cf)((function(){$f.console.error(zf+"[Error]: "+e.join(" "))}))},e}();$f.__SENTRY__=$f.__SENTRY__||{};var Gf,Qf=$f.__SENTRY__.logger||($f.__SENTRY__.logger=new Hf),Wf=n(59212);function Kf(e){return"[object Object]"===Object.prototype.toString.call(e)}function Zf(e){return Boolean(e&&e.then&&"function"==typeof e.then)}!function(e){e.PENDING="PENDING",e.RESOLVED="RESOLVED",e.REJECTED="REJECTED"}(Gf||(Gf={}));var Yf=function(){function e(e){var t=this;this._state=Gf.PENDING,this._handlers=[],this._resolve=function(e){t._setResult(Gf.RESOLVED,e)},this._reject=function(e){t._setResult(Gf.REJECTED,e)},this._setResult=function(e,n){t._state===Gf.PENDING&&(Zf(n)?n.then(t._resolve,t._reject):(t._state=e,t._value=n,t._executeHandlers()))},this._attachHandler=function(e){t._handlers=t._handlers.concat(e),t._executeHandlers()},this._executeHandlers=function(){if(t._state!==Gf.PENDING){var e=t._handlers.slice();t._handlers=[],e.forEach((function(e){e.done||(t._state===Gf.RESOLVED&&e.onfulfilled&&e.onfulfilled(t._value),t._state===Gf.REJECTED&&e.onrejected&&e.onrejected(t._value),e.done=!0)}))}};try{e(this._resolve,this._reject)}catch(e){this._reject(e)}}return e.resolve=function(t){return new e((function(e){e(t)}))},e.reject=function(t){return new e((function(e,n){n(t)}))},e.all=function(t){return new e((function(n,r){if(Array.isArray(t))if(0!==t.length){var o=t.length,i=[];t.forEach((function(t,a){e.resolve(t).then((function(e){i[a]=e,0===(o-=1)&&n(i)})).then(null,r)}))}else n([]);else r(new TypeError("Promise.all requires an array as input."))}))},e.prototype.then=function(t,n){var r=this;return new e((function(e,o){r._attachHandler({done:!1,onfulfilled:function(n){if(t)try{return void e(t(n))}catch(e){return void o(e)}else e(n)},onrejected:function(t){if(n)try{return void e(n(t))}catch(e){return void o(e)}else o(t)}})}))},e.prototype.catch=function(e){return this.then((function(e){return e}),e)},e.prototype.finally=function(t){var n=this;return new e((function(e,r){var o,i;return n.then((function(e){i=!1,o=e,t&&t()}),(function(e){i=!0,o=e,t&&t()})).then((function(){i?r(o):e(o)}))}))},e.prototype.toString=function(){return"[object SyncPromise]"},e}(),Jf=function(){function e(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._user={},this._tags={},this._extra={},this._contexts={}}return e.clone=function(t){var n=new e;return t&&(n._breadcrumbs=C(t._breadcrumbs),n._tags=E({},t._tags),n._extra=E({},t._extra),n._contexts=E({},t._contexts),n._user=t._user,n._level=t._level,n._span=t._span,n._session=t._session,n._transactionName=t._transactionName,n._fingerprint=t._fingerprint,n._eventProcessors=C(t._eventProcessors),n._requestSession=t._requestSession),n},e.prototype.addScopeListener=function(e){this._scopeListeners.push(e)},e.prototype.addEventProcessor=function(e){return this._eventProcessors.push(e),this},e.prototype.setUser=function(e){return this._user=e||{},this._session&&this._session.update({user:e}),this._notifyScopeListeners(),this},e.prototype.getUser=function(){return this._user},e.prototype.getRequestSession=function(){return this._requestSession},e.prototype.setRequestSession=function(e){return this._requestSession=e,this},e.prototype.setTags=function(e){return this._tags=E(E({},this._tags),e),this._notifyScopeListeners(),this},e.prototype.setTag=function(e,t){var n;return this._tags=E(E({},this._tags),((n={})[e]=t,n)),this._notifyScopeListeners(),this},e.prototype.setExtras=function(e){return this._extra=E(E({},this._extra),e),this._notifyScopeListeners(),this},e.prototype.setExtra=function(e,t){var n;return this._extra=E(E({},this._extra),((n={})[e]=t,n)),this._notifyScopeListeners(),this},e.prototype.setFingerprint=function(e){return this._fingerprint=e,this._notifyScopeListeners(),this},e.prototype.setLevel=function(e){return this._level=e,this._notifyScopeListeners(),this},e.prototype.setTransactionName=function(e){return this._transactionName=e,this._notifyScopeListeners(),this},e.prototype.setTransaction=function(e){return this.setTransactionName(e)},e.prototype.setContext=function(e,t){var n;return null===t?delete this._contexts[e]:this._contexts=E(E({},this._contexts),((n={})[e]=t,n)),this._notifyScopeListeners(),this},e.prototype.setSpan=function(e){return this._span=e,this._notifyScopeListeners(),this},e.prototype.getSpan=function(){return this._span},e.prototype.getTransaction=function(){var e,t,n,r,o=this.getSpan();return(null===(e=o)||void 0===e?void 0:e.transaction)?null===(t=o)||void 0===t?void 0:t.transaction:(null===(r=null===(n=o)||void 0===n?void 0:n.spanRecorder)||void 0===r?void 0:r.spans[0])?o.spanRecorder.spans[0]:void 0},e.prototype.setSession=function(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this},e.prototype.getSession=function(){return this._session},e.prototype.update=function(t){if(!t)return this;if("function"==typeof t){var n=t(this);return n instanceof e?n:this}return t instanceof e?(this._tags=E(E({},this._tags),t._tags),this._extra=E(E({},this._extra),t._extra),this._contexts=E(E({},this._contexts),t._contexts),t._user&&Object.keys(t._user).length&&(this._user=t._user),t._level&&(this._level=t._level),t._fingerprint&&(this._fingerprint=t._fingerprint),t._requestSession&&(this._requestSession=t._requestSession)):Kf(t)&&(t=t,this._tags=E(E({},this._tags),t.tags),this._extra=E(E({},this._extra),t.extra),this._contexts=E(E({},this._contexts),t.contexts),t.user&&(this._user=t.user),t.level&&(this._level=t.level),t.fingerprint&&(this._fingerprint=t.fingerprint),t.requestSession&&(this._requestSession=t.requestSession)),this},e.prototype.clear=function(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this},e.prototype.addBreadcrumb=function(e,t){var n="number"==typeof t?Math.min(t,100):100;if(n<=0)return this;var r=E({timestamp:(0,Vf.yW)()},e);return this._breadcrumbs=C(this._breadcrumbs,[r]).slice(-n),this._notifyScopeListeners(),this},e.prototype.clearBreadcrumbs=function(){return this._breadcrumbs=[],this._notifyScopeListeners(),this},e.prototype.applyToEvent=function(e,t){var n;if(this._extra&&Object.keys(this._extra).length&&(e.extra=E(E({},this._extra),e.extra)),this._tags&&Object.keys(this._tags).length&&(e.tags=E(E({},this._tags),e.tags)),this._user&&Object.keys(this._user).length&&(e.user=E(E({},this._user),e.user)),this._contexts&&Object.keys(this._contexts).length&&(e.contexts=E(E({},this._contexts),e.contexts)),this._level&&(e.level=this._level),this._transactionName&&(e.transaction=this._transactionName),this._span){e.contexts=E({trace:this._span.getTraceContext()},e.contexts);var r=null===(n=this._span.transaction)||void 0===n?void 0:n.name;r&&(e.tags=E({transaction:r},e.tags))}return this._applyFingerprint(e),e.breadcrumbs=C(e.breadcrumbs||[],this._breadcrumbs),e.breadcrumbs=e.breadcrumbs.length>0?e.breadcrumbs:void 0,this._notifyEventProcessors(C(Xf(),this._eventProcessors),e,t)},e.prototype._notifyEventProcessors=function(e,t,n,r){var o=this;return void 0===r&&(r=0),new Yf((function(i,a){var s=e[r];if(null===t||"function"!=typeof s)i(t);else{var c=s(E({},t),n);Zf(c)?c.then((function(t){return o._notifyEventProcessors(e,t,n,r+1).then(i)})).then(null,a):o._notifyEventProcessors(e,c,n,r+1).then(i).then(null,a)}}))},e.prototype._notifyScopeListeners=function(){var e=this;this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((function(t){t(e)})),this._notifyingListeners=!1)},e.prototype._applyFingerprint=function(e){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],this._fingerprint&&(e.fingerprint=e.fingerprint.concat(this._fingerprint)),e.fingerprint&&!e.fingerprint.length&&delete e.fingerprint},e}();function Xf(){var e=(0,qf.Rf)();return e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.globalEventProcessors=e.__SENTRY__.globalEventProcessors||[],e.__SENTRY__.globalEventProcessors}function ep(e){var t,n;if(Kf(e)){var r=e,o={};try{for(var i=O(Object.keys(r)),a=i.next();!a.done;a=i.next()){var s=a.value;void 0!==r[s]&&(o[s]=ep(r[s]))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return o}return Array.isArray(e)?e.map(ep):e}var tp=function(){function e(e){this.errors=0,this.sid=(0,qf.DM)(),this.duration=0,this.status=jf.Ok,this.init=!0,this.ignoreDuration=!1;var t=(0,Vf.ph)();this.timestamp=t,this.started=t,e&&this.update(e)}return e.prototype.update=function(e){if(void 0===e&&(e={}),e.user&&(!this.ipAddress&&e.user.ip_address&&(this.ipAddress=e.user.ip_address),this.did||e.did||(this.did=e.user.id||e.user.email||e.user.username)),this.timestamp=e.timestamp||(0,Vf.ph)(),e.ignoreDuration&&(this.ignoreDuration=e.ignoreDuration),e.sid&&(this.sid=32===e.sid.length?e.sid:(0,qf.DM)()),void 0!==e.init&&(this.init=e.init),!this.did&&e.did&&(this.did=""+e.did),"number"==typeof e.started&&(this.started=e.started),this.ignoreDuration)this.duration=void 0;else if("number"==typeof e.duration)this.duration=e.duration;else{var t=this.timestamp-this.started;this.duration=t>=0?t:0}e.release&&(this.release=e.release),e.environment&&(this.environment=e.environment),!this.ipAddress&&e.ipAddress&&(this.ipAddress=e.ipAddress),!this.userAgent&&e.userAgent&&(this.userAgent=e.userAgent),"number"==typeof e.errors&&(this.errors=e.errors),e.status&&(this.status=e.status)},e.prototype.close=function(e){e?this.update({status:e}):this.status===jf.Ok?this.update({status:jf.Exited}):this.update()},e.prototype.toJSON=function(){return ep({sid:""+this.sid,init:this.init,started:new Date(1e3*this.started).toISOString(),timestamp:new Date(1e3*this.timestamp).toISOString(),status:this.status,errors:this.errors,did:"number"==typeof this.did||"string"==typeof this.did?""+this.did:void 0,duration:this.duration,attrs:ep({release:this.release,environment:this.environment,ip_address:this.ipAddress,user_agent:this.userAgent})})},e}(),np=function(){function e(e,t,n){void 0===t&&(t=new Jf),void 0===n&&(n=4),this._version=n,this._stack=[{}],this.getStackTop().scope=t,e&&this.bindClient(e)}return e.prototype.isOlderThan=function(e){return this._version<e},e.prototype.bindClient=function(e){this.getStackTop().client=e,e&&e.setupIntegrations&&e.setupIntegrations()},e.prototype.pushScope=function(){var e=Jf.clone(this.getScope());return this.getStack().push({client:this.getClient(),scope:e}),e},e.prototype.popScope=function(){return!(this.getStack().length<=1)&&!!this.getStack().pop()},e.prototype.withScope=function(e){var t=this.pushScope();try{e(t)}finally{this.popScope()}},e.prototype.getClient=function(){return this.getStackTop().client},e.prototype.getScope=function(){return this.getStackTop().scope},e.prototype.getStack=function(){return this._stack},e.prototype.getStackTop=function(){return this._stack[this._stack.length-1]},e.prototype.captureException=function(e,t){var n=this._lastEventId=(0,qf.DM)(),r=t;if(!t){var o=void 0;try{throw new Error("Sentry syntheticException")}catch(e){o=e}r={originalException:e,syntheticException:o}}return this._invokeClient("captureException",e,E(E({},r),{event_id:n})),n},e.prototype.captureMessage=function(e,t,n){var r=this._lastEventId=(0,qf.DM)(),o=n;if(!n){var i=void 0;try{throw new Error(e)}catch(e){i=e}o={originalException:e,syntheticException:i}}return this._invokeClient("captureMessage",e,t,E(E({},o),{event_id:r})),r},e.prototype.captureEvent=function(e,t){var n=(0,qf.DM)();return"transaction"!==e.type&&(this._lastEventId=n),this._invokeClient("captureEvent",e,E(E({},t),{event_id:n})),n},e.prototype.lastEventId=function(){return this._lastEventId},e.prototype.addBreadcrumb=function(e,t){var n=this.getStackTop(),r=n.scope,o=n.client;if(r&&o){var i=o.getOptions&&o.getOptions()||{},a=i.beforeBreadcrumb,s=void 0===a?null:a,c=i.maxBreadcrumbs,l=void 0===c?100:c;if(!(l<=0)){var u=(0,Vf.yW)(),f=E({timestamp:u},e),p=s?(0,qf.Cf)((function(){return s(f,t)})):f;null!==p&&r.addBreadcrumb(p,l)}}},e.prototype.setUser=function(e){var t=this.getScope();t&&t.setUser(e)},e.prototype.setTags=function(e){var t=this.getScope();t&&t.setTags(e)},e.prototype.setExtras=function(e){var t=this.getScope();t&&t.setExtras(e)},e.prototype.setTag=function(e,t){var n=this.getScope();n&&n.setTag(e,t)},e.prototype.setExtra=function(e,t){var n=this.getScope();n&&n.setExtra(e,t)},e.prototype.setContext=function(e,t){var n=this.getScope();n&&n.setContext(e,t)},e.prototype.configureScope=function(e){var t=this.getStackTop(),n=t.scope,r=t.client;n&&r&&e(n)},e.prototype.run=function(e){var t=op(this);try{e(this)}finally{op(t)}},e.prototype.getIntegration=function(e){var t=this.getClient();if(!t)return null;try{return t.getIntegration(e)}catch(t){return Qf.warn("Cannot retrieve integration "+e.id+" from the current Hub"),null}},e.prototype.startSpan=function(e){return this._callExtensionMethod("startSpan",e)},e.prototype.startTransaction=function(e,t){return this._callExtensionMethod("startTransaction",e,t)},e.prototype.traceHeaders=function(){return this._callExtensionMethod("traceHeaders")},e.prototype.captureSession=function(e){if(void 0===e&&(e=!1),e)return this.endSession();this._sendSessionUpdate()},e.prototype.endSession=function(){var e,t,n,r,o;null===(n=null===(t=null===(e=this.getStackTop())||void 0===e?void 0:e.scope)||void 0===t?void 0:t.getSession())||void 0===n||n.close(),this._sendSessionUpdate(),null===(o=null===(r=this.getStackTop())||void 0===r?void 0:r.scope)||void 0===o||o.setSession()},e.prototype.startSession=function(e){var t=this.getStackTop(),n=t.scope,r=t.client,o=r&&r.getOptions()||{},i=o.release,a=o.environment,s=((0,qf.Rf)().navigator||{}).userAgent,c=new tp(E(E(E({release:i,environment:a},n&&{user:n.getUser()}),s&&{userAgent:s}),e));if(n){var l=n.getSession&&n.getSession();l&&l.status===jf.Ok&&l.update({status:jf.Exited}),this.endSession(),n.setSession(c)}return c},e.prototype._sendSessionUpdate=function(){var e=this.getStackTop(),t=e.scope,n=e.client;if(t){var r=t.getSession&&t.getSession();r&&n&&n.captureSession&&n.captureSession(r)}},e.prototype._invokeClient=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var o=this.getStackTop(),i=o.scope,a=o.client;a&&a[e]&&(t=a)[e].apply(t,C(n,[i]))},e.prototype._callExtensionMethod=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=rp(),o=r.__SENTRY__;if(o&&o.extensions&&"function"==typeof o.extensions[e])return o.extensions[e].apply(this,t);Qf.warn("Extension method "+e+" couldn't be found, doing nothing.")},e}();function rp(){var e=(0,qf.Rf)();return e.__SENTRY__=e.__SENTRY__||{extensions:{},hub:void 0},e}function op(e){var t=rp(),n=sp(t);return cp(t,e),n}function ip(){var e=rp();return ap(e)&&!sp(e).isOlderThan(4)||cp(e,new np),(0,Wf.KV)()?function(e){var t,n,r;try{var o=null===(r=null===(n=null===(t=rp().__SENTRY__)||void 0===t?void 0:t.extensions)||void 0===n?void 0:n.domain)||void 0===r?void 0:r.active;if(!o)return sp(e);if(!ap(o)||sp(o).isOlderThan(4)){var i=sp(e).getStackTop();cp(o,new np(i.client,Jf.clone(i.scope)))}return sp(o)}catch(t){return sp(e)}}(e):sp(e)}function ap(e){return!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)}function sp(e){return e&&e.__SENTRY__&&e.__SENTRY__.hub||(e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.hub=new np),e.__SENTRY__.hub}function cp(e,t){return!!e&&(e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.hub=t,!0)}function lp(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=ip();if(r&&r[e])return r[e].apply(r,C(t));throw new Error("No hub defined or "+e+" was not found on the hub, please open a bug report.")}function up(e,t){var n;try{throw new Error("Sentry syntheticException")}catch(e){n=e}return lp("captureException",e,{captureContext:t,originalException:e,syntheticException:n})}var fp=n(76727);const pp=(e,t)=>({selector:e,resolveView:e=>({...t,element:e})}),dp=(e,t,n)=>((e,t)=>{const{repoName:n,commitID:r}=e;return dl({repoName:n,revision:r,requestGraphQL:t}).pipe(hl())})(e,n).pipe(ze((()=>ml({repoName:e.repoName,filePath:e.filePath,commitID:e.commitID,requestGraphQL:n}))),H((t=>t?{...e,content:t.join("\n")}:{...e})),st((n=>ee(t(n)).pipe(ze((t=>{if(t)return z(e);throw n}))))));function hp(){return function(e){const t=function(e){if(void 0!==e.line)return{start:{line:e.line,character:e.character||0},end:{line:e.endLine||e.line,character:e.endCharacter||e.character||0}}}(e);if(void 0===t)return[];const n={line:t.start.line-1,character:Yn(t.start.character)},r={line:t.end.line-1,character:Yn(t.end.character)};return[{start:n,end:r,anchor:n,active:r,isReversed:!1}]}(ua(window.location.hash))}function mp(){return Ae(window,"hashchange").pipe(H(hp),Qe(((e,t)=>Ot()(e,t))))}function gp(e){const t=e.title.split(" \u2192 ");return t.length>1?{headFilePath:t[1],baseFilePath:t[0]}:{headFilePath:t[0],baseFilePath:t[0]}}function vp(e){const{pageType:t}=_p();if(!Ep(t))return null;let n="",r="";if("pull"===t){var o;const t=null===(o=document.querySelector("details-menu[src*='sha1='][src*='sha2=']"))||void 0===o?void 0:o.getAttribute("src"),i=e.classList.contains("js-comment-container");if(t){const e=new URLSearchParams(t),n=e.get("sha1"),r=e.get("sha2");if(n&&r)return{baseCommitID:n,headCommitID:r}}else if(i){const t=function(e){const t=e.querySelector(`summary a[href^="${location.pathname}"`);if(!t)return null;const n=t.href.match(bp);if(!n)return null;const r=n[3],o=yp(document.documentElement.innerHTML,!0);return r&&o?{...o,headCommitID:r}:null}(e);if(t)return t}else{const e=document.querySelector('input[name="comparison_start_oid"]');e&&(n=e.value);const t=document.querySelector('input[name="comparison_end_oid"]');t&&(r=t.value)}}else if("commit"===t){const e=document.querySelectorAll(".sha-block:not(.patch-diff-links)");if(e&&2===e.length){const t=e[0].querySelector("a");t&&(n=t.href.split("/").slice(-1)[0]);const o=e[1].querySelector("span.sha");o&&(r=o.innerHTML)}}else if("compare"===t){const e=function(){const[e,t]=document.querySelectorAll(".commitish-suggester .select-menu-button span");if(e&&t&&e.textContent&&t.textContent)return{baseCommitID:e.textContent,headCommitID:t.textContent};return}();if(e)return e}return""===n||""===r?yp(document.documentElement.innerHTML,"pull"===t):{baseCommitID:n,headCommitID:r}}const bp=/\/files\/((\w+)\.\.)?(\w+)#diff-\w+$/;function yp(e,t){if(!t)return null;const n="\x3c!-- base sha1: "",r=e.indexOf(n);if(-1===r)return null;const o="\x3c!-- head sha1: "",i=e.indexOf(o,r);if(-1===i)return null;return{baseCommitID:e.slice(r+n.length,40),headCommitID:e.slice(i+o.length,40)}}function wp(){const e=document.querySelector("a.js-permalink-shortcut");if(!e)throw new Error("Unable to determine the file path because no a.js-permalink-shortcut element was found.");const t=new URL(e.href),[,,,n,,...r]=t.pathname.split("/");if("tree"!==n&&0===r.length)throw new Error(`Unable to determine the file path because the a.js-permalink-shortcut element's href's path was ${t.pathname} (it is expected to be of the form /<user>/<repo>/blob/<commitID>/<path/to/file>).`);return decodeURIComponent(r.join("/"))}function Ep(e){switch(e){case"commit":case"pull":case"compare":return!0;default:return!1}}function _p(e=window.location){const{host:t,pathname:n}=e,[r,o,i,...a]=n.slice(1).split("/");if(!r||!o)throw new ll(`Could not parse repoName from GitHub url: ${e.href}`);const s=`${r}/${o}`,c=`${t}/${s}`;switch(i){case"blob":case"tree":return{pageType:i,rawRepoName:c,revisionAndFilePath:decodeURIComponent(a.join("/")),repoName:s};case"pull":case"commit":case"compare":return{pageType:i,rawRepoName:c,repoName:s};default:return{pageType:"other",rawRepoName:c,repoName:s}}}const xp=e=>{let t=e.closest("td").previousElementSibling;for(;t;){if(t.dataset.lineNumber)return parseInt(t.dataset.lineNumber,10);t=t.previousElementSibling}throw new Error("Could not find a line number in any cell")},Sp=e=>{var t;const n=e.closest("td.blob-code");return!n||null!==(t=n.parentElement)&&void 0!==t&&t.classList.contains("js-expandable-line")?null:n},Op=(e,t,n)=>{const r=Pp(e),o=((e,t)=>"base"===e?0:t?2:1)(n,r)+1,i=e.querySelector(`td:nth-child(${o})[data-line-number="${t}"]`);if(!i)return null;if(!r&&"base"===n&&!i.classList.contains("blob-num-addition")&&!i.classList.contains("blob-num-deletion"))return null;let a;if(r)a=i.nextElementSibling;else{a=i.parentElement.lastElementChild}return a},Tp=e=>e.classList.contains("blob-code-inner")?e:e.querySelector(".blob-code-inner"),Cp={getCodeElementFromTarget:e=>{const t=Sp(e);return t&&Tp(t)},getLineElementFromLineNumber:Op,getCodeElementFromLineNumber:(e,t,n)=>{const r=Op(e,t,n);return r&&Tp(r)},getLineNumberFromCodeElement:xp,getDiffCodePart:e=>{const t=e.closest("td");return t.classList.contains("blob-code-addition")?"head":t.classList.contains("blob-code-deletion")||Pp(e)&&t.nextElementSibling?"base":"head"},isFirstCharacterDiffIndicator:e=>{const t=e.closest(".blob-code-inner"),n=t&&["deletion","context","addition"].some((e=>t.classList.contains("blob-code-marker-"+e))),r=e.closest("tr"),o=null==r?void 0:r.querySelector("td[data-code-marker]"),i=null==t?void 0:t.hasAttribute("data-code-marker"),a=o||i,s=e.closest(".refined-github-diff-signs");return!n&&!a&&!s}},kp=(e,t)=>{const n=e.querySelector(`td[data-line-number="${t}"]`);return n&&n.nextElementSibling},Np={getCodeElementFromTarget:Sp,getCodeElementFromLineNumber:kp,getLineElementFromLineNumber:kp,getLineNumberFromCodeElement:xp},Ap=(e,t)=>{const n=((e,t)=>{const n=e.querySelectorAll("td.blob-num");let r=null;for(const e of n)if(e.querySelector("a").href.endsWith(`#L${t}`)){r=e;break}return r})(e,t);return n&&n.nextElementSibling},Ip={getCodeElementFromTarget:Sp,getCodeElementFromLineNumber:Ap,getLineElementFromLineNumber:Ap,getLineNumberFromCodeElement:e=>{const t=e.closest("td").previousElementSibling;return parseInt(t.firstElementChild.textContent,10)}};function Pp(e){const{pageType:t}=_p();if(!Ep(t))return!1;const n=e.classList.contains("file")?e:e.closest(".file");if(!n)throw new Error("Could not resolve code view element");if(n.classList.contains("js-comment-container"))return!1;const r=n.querySelector("table");if(!r)throw new Error("Could not find code view table");return r.classList.contains("js-file-diff-split")||r.classList.contains("file-diff-split")}const Rp=()=>{const e=_p();if("blob"!==e.pageType&&"tree"!==e.pageType)throw new Error(`Current URL does not match a blob or tree url: ${window.location.href}`);const{revisionAndFilePath:t,rawRepoName:n}=e,r=wp(),o=r&&!r.startsWith("/")?`/${r}`:r,i=o?t.slice(0,-o.length):t;if(!t.endsWith(o))throw new Error(`The file path ${o} should always be a suffix of revAndFilePath ${t}, but isn't in this case.`);return{blob:{rawRepoName:n,filePath:r,revision:i,commitID:fe({selector:".js-permalink-shortcut",hrefRegex:/^\/.*?\/.*?\/(?:blob|tree)\/([\da-f]{40})/})}}},Dp=/\/([\da-f]{40})$/i,Lp=e=>{const t=e.querySelector("a.commit-tease-sha");if(!t)throw new Error("Could not find commit link in snippet code view");const n=t.href.match(Dp);if(null==n||!n[1])throw new Error(`Could not parse commitID from snippet commit link href: ${t.href}`);const r=n[1],o=e.querySelectorAll("a:not(.commit-tease-sha)"),i=new URL(o[0].href),a=_p(i);if("blob"!==a.pageType)throw new Error(`Snippet URL does not match a blob url: ${i.href}`);const{revisionAndFilePath:s,rawRepoName:c}=a;if(!s.startsWith(r))throw new Error(`Could not parse filePath: revAndFilePath ${s} does not start with commitID ${r}`);return{blob:{rawRepoName:c,filePath:s.slice(r.length+1),commitID:r,revision:r}}},Mp=["tooltipped","tooltipped-n"];const jp="codeHost-module__command-palette-action-item_16BFG",Fp="codeHost-module__action-item_7QWb2",Bp="codeHost-module__icon_3PdA7",Up="codeHost-module__code-view-toolbar_gOzAp",qp="codeHost-module__code-view-toolbar-item_2fTzz",Vp="codeHost-module__hover-overlay-badge_3wpZt";function $p(e){const t="github-file-actions-toolbar-mount",n=e.querySelector("."+t);if(n)return n;const r=document.createElement("div");r.className=t;const o=e.querySelector(".file-actions");if(!o)throw new Error("Could not find GitHub file actions with selector .file-actions");o.classList.add("sg-github-file-actions");const i=e.querySelector(".show-file-notes");return i?i.after(r):o.prepend(r),r}const zp={dom:Cp,getToolbarMount:$p,resolveFileInfo:e=>{const{rawRepoName:t}=_p(),{headFilePath:n,baseFilePath:r}=function(e){const t=e.querySelector(".file-info");if(t){if("A"===t.tagName)return gp(t);const e=t.querySelector(".diffstat + a");if(e)return gp(e)}const n=e.querySelector(".file-header a");if(n)return gp(n);throw new Error("Could not determine diff file name")}(e);if(!n)throw new Error("cannot determine file path");const o=vp(e);if(!o)throw new Error("cannot determine delta info");const{headCommitID:i,baseCommitID:a}=o;return{head:{rawRepoName:t,filePath:n,commitID:i,revision:i},base:{rawRepoName:t,filePath:r||n,commitID:a,revision:a}}},getScrollBoundaries:e=>{const t=e.querySelector(".file-header");if(!t)throw new Error("Could not find .file-header element in GitHub PR code view");return[t]}},Hp={...zp,getToolbarMount:void 0},Gp={dom:Np,getToolbarMount:$p,resolveFileInfo:Rp,getSelections:hp,observeSelections:mp},Qp=e=>({direction:t,codeView:n,position:r})=>ml({...r,requestGraphQL:e}).pipe(H((e=>{const o=Np.getCodeElementFromLineNumber(n,r.line,r.part);if(!o)throw new Error("(adjustPosition) could not find code element for line provided");const i=e[r.line-1],a=o.textContent||"",s=i.length-Uf()(i).length,c=a.length-Uf()(a).length,l=t===Fn.ActualToCodeView?-1:1,u=Math.abs(s-c)*l;return{line:r.line,character:r.character+u}}))),Wp=pp(".code-list-item",{dom:Ip,getPositionAdjuster:Qp,resolveFileInfo:Lp}),Kp={dom:Np,resolveFileInfo:Lp,getPositionAdjuster:Qp},Zp=e=>{const t="sourcegraph-github-file-code-view-toolbar-mount",n=e.querySelector(`.${t}`);if(n)return n;const r=document.createElement("div");r.style.display="inline-flex",r.style.verticalAlign="middle",r.style.alignItems="center",r.className=t;const o=e.querySelector("#raw-url"),i=null==o?void 0:o.closest(".BtnGroup");if(null==i||!i.parentNode)throw new Error("File actions not found");return i.parentNode.insertBefore(r,i),r},Yp={selector:".js-file-line-container",resolveView:e=>{const t=e.closest(".blob-wrapper-embedded");if(t){return{element:t.parentElement,...Kp}}const{pageType:n}=_p();if("blob"!==n)return null;const r=e.closest(".repository-content");if(!r)throw new Error("Could not find repository content element");return{element:r,...Gp,getToolbarMount:Zp}}},Jp={selector:e=>{const t=new Set;for(const n of de(e,".file"))0===n.querySelectorAll(".js-diff-load-container").length&&t.add(n);for(const n of de(e,".js-blob-wrapper")){const e=n.closest(".file");e instanceof HTMLElement&&t.add(e)}return[...t]},resolveView:e=>{if(e.querySelector("article.markdown-body"))return null;if(e.closest(".js-suggested-changes-blob"))return null;const{pageType:t}=_p();return"blob"===t&&1===document.querySelectorAll(".file").length&&0===document.querySelectorAll(".diff-view").length?{element:e,...Gp}:e.closest(".discussion-item-body")||e.classList.contains("js-comment-container")?{element:e,...Hp}:{element:e,...zp}}};function Xp(){const e=document.head.querySelector('meta[property="og:site_name"]');return!!e&&("GitHub Enterprise"===e.content||"GitHub"===e.content)&&document.body.classList.contains("enterprise")}const ed="open-on-sourcegraph",td=i()(Bp,"v-align-text-bottom"),nd={[Qa]:"flash",[Wa]:"flash flash-success",[Ga]:"flash",[Ha]:"flash flash-warn",[za]:"flash flash-error"},rd={searchViewResolver:{selector:'.js-site-search-form input[type="text"][aria-controls="jump-to-results"]',resolveView:e=>({element:e})},resultViewResolver:{selector:"#jump-to-suggestion-search-global",resolveView:e=>({element:e})},onChange:({value:e,searchURL:t,resultElement:n})=>{var r;const o="#jump-to-sourcegraph-search-global";(n=>{const r=n.querySelector(".jump-to-suggestion-name");r.textContent=e,r.setAttribute("aria-label",e);const o=n.querySelector("a"),i=new URL(t);i.searchParams.append("q",e),o.setAttribute("href",i.href),o.setAttribute("target","_blank"),n.setAttribute("style","display: "+(e?"initial":"none !important"))})(null!==(r=document.querySelector(o))&&void 0!==r?r:(()=>{var e,t;const r=n.cloneNode(!0);r.id=o.replace("#",""),r.classList.remove("navigation-focus"),r.setAttribute("aria-selected","false");const i=document.createElement("img");i.src=fp,i.setAttribute("style","width: 16px; height: 20px; float: left; margin-right: 2px;"),i.setAttribute("alt","Sourcegraph Logo Image");const a=r.querySelector(".js-jump-to-badge-search-text-global");return a.textContent="Sourcegraph",null===(e=a.parentNode)||void 0===e||e.insertBefore(i,a),null===(t=n.parentNode)||void 0===t||t.insertBefore(r,n.nextElementSibling),r})())}},od=(e,t=Dc.fetchCache,n="#repository-container-header h1 span.Label")=>"github.com"!==window.location.hostname?Promise.resolve(!0):t({url:`https://api.github.com/repos/${e}`,credentials:"omit",cacheMaxAge:36e5}).then((e=>{const t=e.headers["x-ratelimit-remaining"];if(Number(t)<=0){const e=new Error("Github rate limit exceeded.");throw up(e),e}return e})).then((({data:e})=>"boolean"!=typeof e.private||e.private)).catch((e=>{var t,r;return console.warn("Failed to fetch if the repository is private.",e),"public"!==(null===(t=document.querySelector(n))||void 0===t||null===(r=t.textContent)||void 0===r?void 0:r.toLowerCase().trim())})),id=()=>"/search"===window.location.pathname,ad=()=>"/search/advanced"===window.location.pathname,sd=()=>!id()&&window.location.pathname.endsWith("/search"),cd=()=>Boolean(new URLSearchParams(window.location.search).get("q"))&&!ad(),ld=()=>{const e=new URLSearchParams(window.location.search).get("type");return e?e.toLowerCase():""},ud=e=>{const t=e.filter(Boolean).map((e=>e.trim())),n=(()=>{switch(ld()){case"repositories":return"repo";case"commits":return"commit";case"code":return"";default:return id()||ad()?"repo":""}})(),r=new URLSearchParams(window.location.search).get("l");if(n&&t.push(`type:${n}`),r&&t.push(`lang:${encodeURIComponent(r)}`),sd()){const[e,n]=window.location.pathname.split("/").filter(Boolean);t.push(`repo:${e}/${n}$`)}for(const e of["org","user"]){const n=t.findIndex((t=>t.startsWith(`${e}:`)));if(n>=0){const r=t[n].replace(`${e}:`,"");r&&(t[n]=`repo:${r}/*`)}}return t.join("+")},fd=(e,t="")=>{let n=document.querySelector(`#${e}`);return n||(n=document.createElement("div"),n.setAttribute("id",e),n.classList.add(...t.split(/\s/gi)),n)};const pd={type:"github",name:Xp()?"GitHub Enterprise":"GitHub",searchEnhancement:rd,enhanceSearchPage:function(e){if(!(id()||ad()||sd()||cd()))return;const n=({container:n,className:r="",getSearchQuery:o,utmCampaign:a})=>{const s=Tc(new URL("/search",e),{utm_source:Fc(),utm_campaign:a});(0,me.render)(t.createElement(tl,{label:"Search on Sourcegraph",title:"Search on Sourcegraph to get hover tooltips, go to definition and more",ariaLabel:"Search on Sourcegraph to get hover tooltips, go to definition and more",className:i()("btn","m-auto",r),iconClassName:i()("mr-1","v-align-middle",Bp),href:s.href,dataTestId:"search-on-sourcegraph",onClick:e=>{const t=ud(o());e.target.href=`${s.href}${t?`&q=${t}`:""}`}}),n)};if(cd()){const e=ld();if(["repositories","commits","code"].includes(e)||""===e&&(id()||sd())){var r,o;const e=document.querySelector(".application-main form.js-site-search-form"),t=null==e?void 0:e.querySelector("input.form-control[name='q']"),i=null==e||null===(r=e.parentElement)||void 0===r||null===(o=r.parentElement)||void 0===o?void 0:o.querySelector("button[type='submit']");if(t&&i){const e=fd("pageSearchFormSourcegraphButton","ml-2 d-none d-md-block");i.after(e),n({container:e,utmCampaign:"github-search-results-page",getSearchQuery:()=>t.value.split(" ")})}const a=document.querySelector("header form.js-site-search-form input.form-control[name='q']"),s=document.querySelector(".codesearch-results"),c=null==s?void 0:s.querySelector(".blankslate"),l=null==s?void 0:s.querySelector("div > div > h3");if(a&&(c||l)){const e=fd("headerSearchInputSourcegraphButton","ml-auto d-none d-lg-block");c?(e.classList.add("mt-2"),c.append(e)):l&&(e.classList.add("mr-2"),l.after(e)),n({container:e,className:c?"":"btn-sm",utmCampaign:"github-search-results-page",getSearchQuery:()=>a.value.split(" ")})}}return}const a=document.querySelector("#search_form"),s=null==a?void 0:a.querySelector(".search-form-fluid"),c=null==a?void 0:a.querySelector("input");if(s&&c){const e=fd("searchInputSourcegraphButton","ml-0 ml-md-2 mt-2 mt-md-0");null==s||s.append(e),n({container:e,utmCampaign:`github-${ad()?"advanced":"simple"}-search-page`,getSearchQuery:()=>c.value.split(" ")})}},codeViewResolvers:[Jp,Yp,Wp],contentViewResolvers:[{selector:".markdown-body",resolveView:e=>({element:e})}],nativeTooltipResolvers:[{selector:".js-tagsearch-popover",resolveView:e=>({element:e})}],routeChange:e=>e.pipe(H((()=>{const{pathname:e}=window.location,t=e.slice(1).split("/")[2];return"blob"===t||"tree"===t?e.endsWith(wp())?e:void 0:cd()?null===(n=document.querySelector(".codesearch-results h3"))||void 0===n||null===(r=n.textContent)||void 0===r?void 0:r.trim():e;var n,r})),qe(Boolean),Qe()),getContext:async()=>{const{repoName:e,rawRepoName:t,pageType:n}=_p();return{rawRepoName:t,revision:"blob"===n||"tree"===n?Rp().blob.revision:void 0,privateRepository:await od(e)}},isLightTheme:gf((()=>{const e=document.documentElement.dataset.colorMode;return"auto"===e?((e=window)=>{const t=e.matchMedia("(prefers-color-scheme: dark)");return{observable:le(z(!t.matches),Ae(t,"change").pipe(H((e=>!e.matches)))),initialValue:!t.matches}})().observable:z("dark"!==e)})),getViewContextOnSourcegraphMount:e=>{const t=he(e,".pagehead-actions");if(!t||0===t.children.length)return null;let n=t.querySelector("#open-on-sourcegraph");return n||(n=document.createElement("li"),n.id=ed,t.prepend(n),n)},viewOnSourcegraphButtonClassProps:{className:"btn btn-sm tooltipped tooltipped-s",iconClassName:td},check:()=>((e=window.location.href)=>/^https?:\/\/(www\.)?github\.com/.test(e))()||Xp(),getCommandPaletteMount:e=>{const t="command-palette-button",n=e.querySelector(`.Header .${t}`)||e.querySelector(`.Header-old .${t}`);if(n)return n;const r=he(e,".HeaderMenu > :last-child");if(r){const e=document.createElement("div");return e.classList.add(t),r.prepend(e),e}let o=he(e,".Header-item:nth-last-child(2)");if(o){0!==o.previousElementSibling.children.length&&(o=o.previousElementSibling);const e=document.createElement("div");return e.classList.add("Header-item","mr-0","mr-lg-3",t),o.before(e),e}return null},notificationClassNames:nd,commandPaletteClassProps:{buttonClassName:"Header-link d-flex flex-items-baseline",popoverClassName:"Box",formClassName:"p-1",inputClassName:"form-control input-sm header-search-input jump-to-field",listClassName:"p-0 m-0 js-navigation-container jump-to-suggestions-results-container",selectedListItemClassName:"navigation-focus",listItemClassName:"d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-scoped-search",actionItemClassName:i()(jp,"no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path p-2"),noResultsClassName:"d-flex flex-auto flex-items-center jump-to-suggestions-path p-2",iconClassName:td},codeViewToolbarClassProps:{className:Up,listItemClass:i()(qp,"BtnGroup"),actionItemClass:i()("btn btn-sm tooltipped tooltipped-s BtnGroup-item",Fp),actionItemPressedClass:"selected",actionItemIconClass:i()(Bp,"v-align-text-bottom")},hoverOverlayClassProps:{className:"Box",actionItemClassName:"btn btn-sm btn-secondary",actionItemPressedClassName:"active",badgeClassName:i()("label",Vp),getAlertClassName:mu(nd,"flash-full"),iconClassName:td},setElementTooltip:function(e,t){"string"==typeof t?(e.classList.add(...Mp),e.setAttribute("aria-label",t)):(e.classList.remove(...Mp),e.removeAttribute("aria-label"))},linkPreviewContentClass:"text-small text-gray p-1 mx-1 border rounded-1 bg-gray text-gray-dark",urlToFile:(e,t,n)=>{if(t.viewState)return ga(e,t);if(!t.rawRepoName.startsWith(window.location.hostname))return ga(e,t);const r=t.revision||"HEAD",{rawRepoName:o}=_p();if(o===t.rawRepoName&&void 0!==n.part){const e=document.querySelectorAll(".file");for(const r of e){const e=r.querySelector(".file-header[data-path][data-anchor]");if(!e)continue;if(e.dataset.path===t.filePath){const r=e.dataset.anchor,o=new URL(window.location.href);if(o.hash=r,t.position&&(o.hash+=`${"base"===n.part?"L":"R"}${t.position.line}`),!document.querySelector(o.hash))break;return o.href}}}const i=t.position?`#L${t.position.line}${t.position.character?`:${t.position.character}`:""}`:"";return`https://${t.rawRepoName}/blob/${r}/${t.filePath}${i}`},codeViewsRequireTokenization:!0},dd=(e,t,n)=>e.querySelector(`#LC${t}`),hd={getCodeElementFromTarget:e=>e.closest("span.line"),getLineNumberFromCodeElement:e=>{const t=e.id.replace(/^LC/,"");return parseInt(t,10)},getCodeElementFromLineNumber:dd,getLineElementFromLineNumber:dd},md=e=>{const t=e.closest("[data-interop-type]");return t?"old"===t.dataset.interopType?"base":"head":(e=>{let t="old";const n=e.closest(".diff-td,td");return n.classList.contains("parallel")&&(t="left-side"),n.classList.contains(t)?"base":"head"})(e)},gd=(e,t,n)=>{const r="base"===n?"old":"new",o=e.querySelector(`[data-interop-${r}-line="${t}"]`);return o?o.querySelector("span.line"):((e,t,n)=>{const r=e.querySelector(`.${"base"===n?"old_line":"new_line"} [data-linenumber="${t}"]`);if(!r)return null;const o=r.closest(".diff-tr,tr");if(!o)return null;let i="span.line";return o.classList.contains("parallel")&&(i=`.${"base"===n?"left-side":"right-side"} ${i}`),o.querySelector(i)})(e,t,n)},vd={getCodeElementFromTarget:hd.getCodeElementFromTarget,getLineNumberFromCodeElement:e=>{const t=e.closest("[data-interop-line]");return t?parseInt(t.dataset.interopLine||"",10):(e=>{const t=md(e);let n=e.closest(".diff-td,td");for(;n&&(!n.matches(".diff-line-num."+("base"===t?"old_line":"new_line"))||!n.querySelector("a"))&&n.previousElementSibling;)n=n.previousElementSibling;if(n){const e=n.querySelector("a");return parseInt(e.dataset.linenumber||"",10)}throw new Error("Unable to determine line number for diff code element")})(e)},getCodeElementFromLineNumber:gd,getLineElementFromLineNumber:(e,t,n)=>{const r=gd(e,t,n);return r&&r.parentElement},getDiffCodePart:md},bd=(e,t,n)=>`${window.location.origin}/api/v4/projects/${encodeURIComponent(e)}%2f${t}${n}`,yd=e=>ar(e,{selector:e=>ur(e).json()}),wd=jo((e=>yd(`${window.location.origin}/api/v4/projects/${e}`).pipe(H((({web_url:e})=>{const{hostname:t,pathname:n}=new URL(e);return`${t}${n}`})))),Na()),Ed=jo((({owner:e,projectName:t,mergeRequestID:n,diffID:r})=>r?yd(bd(e,t,`/merge_requests/${n}/versions/${r}`)).pipe(H((({base_commit_sha:e})=>e))):z(void 0)),(({owner:e,projectName:t,mergeRequestID:n,diffID:r})=>`${e}:${t}:${n}:${String(r)}`)),_d=jo((({owner:e,projectName:t,mergeRequestID:n,rawRepoName:r,diffID:o})=>rl(yd(bd(e,t,`/merge_requests/${n}`)),Ed({owner:e,projectName:t,mergeRequestID:n,diffID:o})).pipe(ze((([{diff_refs:e,source_project_id:t},n])=>wd(t).pipe(H((t=>({baseCommitID:n||e.base_sha,commitID:e.head_sha,rawRepoName:r,baseRawRepoName:t})))))))),(({owner:e,projectName:t,mergeRequestID:n,rawRepoName:r,diffID:o})=>`${e}:${t}:${n}:${r}:${String(o)}`)),xd=jo((({owner:e,projectName:t,commitID:n})=>yd(bd(e,t,`/repository/commits/${n}`)).pipe(H((({parent_ids:e})=>Su()(e))))),(({owner:e,projectName:t,commitID:n})=>`${e}:${t}:${n}`));var Sd=n(68642),Od=n.n(Sd),Td=n(90006),Cd=n.n(Td);let kd;!function(e){e[e.File=0]="File",e[e.Commit=1]="Commit",e[e.MergeRequest=2]="MergeRequest",e[e.Other=3]="Other"}(kd||(kd={}));function Nd(){const e=document.querySelector(".context-header a");if(!e)throw new Error("Unable to determine project name");const t=new URL(e.href).pathname.slice(1),n=t.split("/"),r=Od()(n,n.length-1).join("/"),o=Cd()(n),i=((e,t,n)=>{const r=n.match(new RegExp(`^/${e}/${t}(/-)?/(commit|merge_requests|blob)/`));if(!r)return kd.Other;switch(r[2]){case"commit":return kd.Commit;case"merge_requests":return kd.MergeRequest;case"blob":return kd.File;default:return kd.Other}})(r,o,window.location.pathname);return{owner:r,projectName:o,rawRepoName:[Ic?window.location.hostname:new URL(gon.gitlab_url).hostname,r,o].join("/"),repoName:t,pageKind:i}}const Ad=()=>{let e=window.location.pathname.match(/merge_requests\/(.*?)\/diffs/);if(!e&&document.querySelector(".diffs-tab.active")&&(e=window.location.pathname.match(/merge_requests\/(.*?)((\/)|$)/)),!e)throw new Error("Unable to determine merge request ID");return e[1]},Id=e=>{const t=e.dataset.originalTitle||e.dataset.title||e.title;if(!t)throw new Error("Unable to get file paths from code view: no file title");return t.endsWith(" deleted")?t.slice(0,-8):t};function Pd(e){const t=e.querySelectorAll(".file-title-name");if(0===t.length)throw new Error("Unable to get file paths from code view: no .file-title.name");const n=t.length>1,r=Id(t.item(n?1:0));return{headFilePath:r,baseFilePath:n?Id(t.item(0)):r}}function Rd(){const{rawRepoName:e,owner:t,projectName:n}=Nd();return{rawRepoName:e,owner:t,projectName:n,commitID:Cd()(window.location.pathname.split("/"))}}const Dd="codeHost-module__command-list-popover_hwImg",Ld="codeHost-module__hover-overlay_3Cize";const Md=(e,t)=>{const n=e.querySelector(".sg-toolbar-mount-gitlab");if(n)return n;const r=e.querySelector(".file-actions");if(!r)throw new Error("Unable to find mount location");const o=document.createElement("div");return o.classList.add("sg-toolbar-mount","sg-toolbar-mount-gitlab"),t===kd.Commit&&o.classList.add("gl-mr-3"),r.prepend(o),o},jd={dom:hd,getToolbarMount:e=>Md(e,kd.File),resolveFileInfo:()=>{const{rawRepoName:e,filePath:t,revision:n}=function(){const{rawRepoName:e}=Nd(),t=window.location.pathname.match(/\/blob\/(.*?)\/(.*)/);if(!t)throw new Error("Unable to determine revision or file path");const n=decodeURIComponent(t[1]);return{rawRepoName:e,filePath:decodeURIComponent(t[2]),revision:n}}();if(!t)throw new Error(`Unable to determine the file path of the current file because the current URL (window.location ${window.location.href}) does not have a file path.`);return{blob:{rawRepoName:e,filePath:t,commitID:fe({selector:".js-data-file-blob-permalink-url",hrefRegex:new RegExp("^/.*?/.*?/blob/([0-9a-f]{40})/")}),revision:n}}},getSelections:hp,observeSelections:mp},Fd=e=>{const t=e.querySelector(".js-file-title");if(!t)throw new Error("Could not find .file-title element");return[t]},Bd={dom:vd,getToolbarMount:e=>Md(e,kd.MergeRequest),resolveFileInfo:e=>{return ee(_d({...Nd(),mergeRequestID:Ad(),diffID:null!==(t=new URLSearchParams(window.location.search).get("diff_id"))&&void 0!==t?t:void 0})).pipe(H((t=>{const{rawRepoName:n,baseRawRepoName:r,commitID:o,baseCommitID:i}=t,{headFilePath:a,baseFilePath:s}=Pd(e);return{head:{rawRepoName:n,filePath:a,commitID:o},base:{rawRepoName:r,filePath:s,commitID:i}}})));var t},getScrollBoundaries:Fd},Ud={dom:vd,getToolbarMount:e=>Md(e,kd.Commit),resolveFileInfo:e=>rr(Rd).pipe(ze((({owner:e,projectName:t,commitID:n,rawRepoName:r})=>xd({owner:e,projectName:t,commitID:n}).pipe(H((e=>({commitID:n,baseCommitID:e,rawRepoName:r})))))),H((({commitID:t,baseCommitID:n,rawRepoName:r})=>{const{headFilePath:o,baseFilePath:i}=Pd(e);return{head:{rawRepoName:r,filePath:o,commitID:t},base:{rawRepoName:r,filePath:i,commitID:n}}}))),getScrollBoundaries:Fd},qd={selector:".file-holder",resolveView:e=>{if(e.classList.contains("discussion-wrapper"))return null;const{pageKind:t}=Nd();return t===kd.Other?null:t===kd.File?{element:e,...jd}:t===kd.MergeRequest?e.querySelector(".file-actions")?{element:e,...Bd}:null:{element:e,...Ud}}},Vd={[Qa]:"alert alert-secondary",[Wa]:"alert alert-success",[Ga]:"alert alert-info",[Ha]:"alert alert-warning",[za]:"alert alert-danger"},$d=(e,t=Dc.fetchCache)=>"gitlab.com"===window.location.hostname&&e?t({url:`https://gitlab.com/api/v4/projects/${encodeURIComponent(e)}`,credentials:"omit",cacheMaxAge:36e5}).then((e=>{const t=e.headers["ratelimit-remaining"];if(Number(t)<=0){const e=new Error("Gitlab rate limit exceeded.");throw up(e),e}return e})).then((({status:e})=>200!==e)).catch((e=>(console.warn("Failed to fetch repository visibility info.",e),!0))):Promise.resolve(!0),zd={type:"gitlab",name:"GitLab",check:function(){return!!document.head.querySelector('meta[content="GitLab"]')},codeViewResolvers:[qd],adjustOverlayPosition:({top:e,left:t})=>{const n=document.querySelector("header");n&&(e+=n.getBoundingClientRect().height);const r=document.querySelector("#js-peek.development");return r&&(e+=r.getBoundingClientRect().height),{top:e,left:t}},getCommandPaletteMount:e=>{const t=he(e,".navbar-collapse");if(!t)return null;const n="command-palette-button";return t.querySelector("."+n)||(()=>{const e=document.createElement("div");return e.className=n,t.prepend(e),e})()},getContext:async()=>{const{repoName:e,...t}=Nd();return{...t,privateRepository:await $d(e)}},urlToFile:(e,t,n)=>{if(t.viewState||!t.rawRepoName.startsWith(window.location.hostname))return ga(e,t);if(Nd().rawRepoName===t.rawRepoName&&void 0!==n.part){const e=bf(document.body,qd.selector);for(const r of e){const{headFilePath:e,baseFilePath:o}=Pd(r);if(e!==t.filePath&&o!==t.filePath)continue;if(!t.position){const e=new URL(window.location.href);return e.hash=r.id,e.href}const i=null!==n.part?{head:".new_line",base:".old_line"}[n.part]:"",a=r.querySelector(`${i} a[data-linenumber="${t.position.line}"]`);if(!a)break;return new URL(a.href).href}}const r=new URL(`https://${t.rawRepoName}/blob/${t.revision}/${t.filePath}`);if(t.position){const{line:e}=t.position;r.hash=`#L${e}`}return r.href},notificationClassNames:Vd,commandPaletteClassProps:{popoverClassName:i()("dropdown-menu",Dd),formClassName:"dropdown-input",inputClassName:"dropdown-input-field",resultsContainerClassName:"dropdown-content",selectedActionItemClassName:"is-focused",noResultsClassName:"px-3",iconClassName:"s16 align-bottom"},codeViewToolbarClassProps:{className:"pl-0",actionItemClass:"btn btn-md gl-button btn-icon",actionItemPressedClass:"active",actionItemIconClass:"gl-button-icon gl-icon s16"},hoverOverlayClassProps:{className:i()("card",Ld),actionItemClassName:"btn btn-secondary",actionItemPressedClassName:"active",iconClassName:"square s16",getAlertClassName:mu(Vd)},codeViewsRequireTokenization:!0,getHoverOverlayMountLocation:()=>{const{pageKind:e}=Nd();return e===kd.MergeRequest?"div.tab-pane.diffs":null}},Hd=e=>Boolean("TH"===e.tagName&&e.textContent||e.dataset.n),Gd=e=>parseInt(("TH"===e.tagName?e.textContent:e.dataset.n)||"",10),Qd=e=>{let t=e;for(;t;){if(Hd(t))return t;t=t.previousElementSibling}return null},Wd=(e,t,n)=>{let r=((e,t,n)=>{const r=e.querySelector("td[data-n]")?"td[data-n]":`th:nth-of-type(${"base"===n?1:2})`;for(const o of e.querySelectorAll(r))if(Gd(o)===t){if("head"===n&&null===o.previousElementSibling)continue;return o}return null})(e,t,n);for(;r&&("TD"!==r.tagName||r.classList.contains("n")||Hd(r)||r.classList.contains("copy"));)r=r.nextElementSibling;return r},Kd={getCodeElementFromTarget:e=>{if("TH"===e.tagName||e.classList.contains("copy"))return null;const t=e.closest("td");return t?t.classList.contains("show-more")||t.classList.contains("show-context")?null:Qd(t)?t:null:null},getCodeElementFromLineNumber:Wd,getLineElementFromLineNumber:Wd,getLineNumberFromCodeElement:e=>{const t=Qd(e);if(!t)throw new Error("Could not find line number cell from code element");return Gd(t)},getDiffCodePart:e=>{if(e.classList.contains("old"))return"base";if(e.classList.contains("new"))return"head";const t=Qd(e);if(!t)throw new Error("Could not find line number cell from code element");return t.classList.contains("left")?"base":t.classList.contains("right")||t.previousElementSibling?"head":"base"},isFirstCharacterDiffIndicator:e=>{const t=e.firstElementChild;return!(null==t||!t.classList.contains("aural-only"))}},Zd=(e,t,n)=>{const r=e.querySelector(`tr:nth-of-type(${t})`);if(!r)throw new Error(`unable to find row ${t} from code view`);return r.querySelector("td")},Yd={getCodeElementFromTarget:e=>e.closest("td"),getCodeElementFromLineNumber:Zd,getLineElementFromLineNumber:Zd,getLineNumberFromCodeElement:e=>{let t=e;for(;null!==t&&"TH"!==t.tagName&&!t.classList.contains("phabricator-source-line");)t=t.previousElementSibling;if(!t)throw new Error("could not find line number cell from code element");const n=t.querySelector("a");if(!n)throw new Error("could not find line number anchor from code element");if(void 0!==n.dataset.n){const e=parseInt(n.dataset.n,10);if(isNaN(e))throw new TypeError(`Could not parse lineNumber from data-n attribute: ${n.dataset.n}`);return e}const r=parseInt(n.textContent||"",10);if(isNaN(r))throw new TypeError(`Could not parse lineNumber from lineAnchor.textContent: ${String(n.textContent)}`);return r},isFirstCharacterDiffIndicator:()=>!1};let Jd;!function(e){e[e.Diffusion=1]="Diffusion",e[e.Differential=2]="Differential",e[e.Revision=3]="Revision",e[e.Change=4]="Change"}(Jd||(Jd={}));const Xd=/r([\dA-z]+)([\da-f]{40})/;function eh(){const e=document.querySelectorAll(".phui-tag-core").item(0);if(!e)throw new Error("Could not find Phabricator page tag");return Xd.exec(e.children[0].getAttribute("href"))}function th(){const e=eh();if(!e)throw new Error("Could not determine callsign from page tag");return e[1]}function nh(){const e=eh();if(!e)throw new Error("Could not determine commitID from page tag");return e[2]}const rh=/Diff (\d+)/;const oh=/^\/?(source|diffusion)\/([\w-]+)\/browse\/([\w-]+\/)?([^$;]+)(;[\da-f]{40})?(?:\$\d+)?/i,ih=/^\/?(d\d+)(?:\?(?:(?:id=(\d+))|(vs=(?:\d+|on)&id=\d+)))?/i,ah=/^\/?r([\dA-z]+)([\da-f]{40})/i,sh=/^\/?(source|diffusion)\/([\da-z]+)\/change\/([\w-]+)\/([^;]+)(;[\da-f]{40})?/i,ch=/^\/?\/differential\/changeset.*/i,lh=/^vs=((?:\d+|on))&id=(\d+)/i;function uh(e,t,n){try{const r=e.href.replace(e.origin,""),o=oh.exec(r);if(o){const e=o[4];if(!e)throw new Error(`Could not determine file path from diffusionMatch, stateUrl: ${r}`);return vh(th(),t,n).pipe(H((({rawRepoName:t})=>({mode:Jd.Diffusion,rawRepoName:t,filePath:e,commitID:nh()}))))}const i=ih.exec(r);if(i){const e=i[1],r=i[3],o=parseInt(e.split("D")[1],10);let a,s=i[2]?parseInt(i[2],10):void 0;if(s||(s=function(){const e=document.querySelector("#differential-review-stage");if(!e)throw new Error("no element with id differential-review-stage found on page.");const t=e.parentElement;if(!t)throw new Error("parent container of diff container not found.");const n=t.children[0].querySelectorAll(".phui-header-header").item(0);if(!n||!n.textContent)throw new Error("Could not find diffTitle element, or it had no text content");const r=rh.exec(n.textContent);if(!r)throw new Error(`diffTitle element does not match pattern. Content: '${n.textContent}'`);return parseInt(r[1],10)}()),r){const e=lh.exec(r),t=null==e?void 0:e[1];t&&"on"!==t&&(a=parseInt(t,10),console.log(`comparison diffID ${s} baseDiffID ${a}`))}return yh(o,t,n).pipe(H((({rawRepoName:e})=>({baseRawRepoName:e,headRawRepoName:e,revisionID:o,diffID:s,baseDiffID:a,mode:Jd.Differential}))))}const a=ah.exec(r);if(a){const e=a[1],r=a[2],o=function(){const e=document.querySelectorAll(".phui-property-list-key");for(const t of e)if("Parents "===t.textContent){const e=t.nextSibling.children[0].children[0].href,n=new URL(e),r=ah.exec(n.pathname);if(r)return r[2]}throw new Error("Could not determine base commit ID from revision page")}();return vh(e,t,n).pipe(H((({rawRepoName:e})=>({mode:Jd.Revision,rawRepoName:e,baseCommitID:o,headCommitID:r}))))}const s=sh.exec(r);if(s){const e=s[8],r=th(),o=nh();return vh(r,t,n).pipe(H((({rawRepoName:t})=>({mode:Jd.Change,filePath:e,rawRepoName:t,commitID:o}))))}if(ch.exec(r)){const e=document.querySelector(".phui-crumbs-view");if(!e)throw new Error("failed parsing changeset dom");const[,r,o]=e.querySelectorAll("a"),i=r.getAttribute("href").match(/D(\d+)/);if(!i)throw new Error("failed parsing differentialID");const a=parseInt(i[1],10),s=o.getAttribute("href").match(/\/differential\/diff\/(\d+)/);if(!s)throw new Error("failed parsing diffID");const c=parseInt(s[1],10);return yh(a,t,n).pipe(H((({rawRepoName:e})=>({baseRawRepoName:e,headRawRepoName:e,revisionID:a,diffID:c,mode:Jd.Differential}))))}throw new Error(`Could not determine Phabricator state from stateUrl ${r}`)}catch(e){return vt(e)}}function fh(e){let t=e;if(t=t.replace("\\",""),e.startsWith("git@"))t=e.slice("git@".length),t=t.replace(":","/");else if(e.startsWith("git://"))t=e.slice("git://".length);else if(e.startsWith("https://"))t=e.slice("https://".length);else if(e.includes("@")){t=e.split("@")[1],t=t.replace(":","/")}return t.replace(/.git$/,"")}function ph(e,t){const n=function(){const e=document.querySelector(".phabricator-search-menu form");if(!e)throw new Error("cannot create conduit request form");const t=new FormData;return t.set("__csrf__",e.querySelector("input[name=__csrf__]").value),t.set("__form__",e.querySelector("input[name=__form__]").value),t}();for(const[e,r]of Object.entries(t))n.set(`params[${e}]`,JSON.stringify(r));return ar(window.location.origin+e,{method:"POST",body:n,credentials:"include",headers:{Accept:"application/json"},selector:e=>ur(e).json()}).pipe(H((e=>{if(null!==e.error_code)throw new Error(`error ${e.error_code}: ${e.error_info}`);return e.result})))}const dh=jo((({diffID:e,revisionID:t,queryConduit:n=ph})=>n("/api/differential.querydiffs",{ids:[e],revisionIDs:[t]}).pipe(H((t=>t[String(e)])))),(({diffID:e,revisionID:t})=>`${e}-${t}`)),hh=jo((({diffID:e,queryConduit:t=ph})=>t("/api/differential.getrawdiff",{diffID:e})),(({diffID:e})=>e.toString())),mh=jo((({revisionID:e,queryConduit:t=ph})=>t("/api/differential.query",{ids:[e]}).pipe(H((t=>{const n=t[0].repositoryPHID;if(!n)throw new Error(`no repositoryPHID for revision ${e}`);return n})))),(({revisionID:e})=>e.toString())),gh=jo((({requestGraphQL:e,...t})=>e({request:fr`
|
|
103
103
|
mutation addPhabricatorRepo($callsign: String!, $repoName: String!, $phabricatorURL: String!) {
|
|
104
104
|
addPhabricatorRepo(callsign: $callsign, uri: $repoName, url: $phabricatorURL) {
|
|
105
105
|
alwaysNil
|