prreviewbuddy 0.42.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/server.js +33 -9
- package/package.json +1 -1
- package/static/shell.css +4 -0
- package/static/workspace.js +30 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.43.0
|
|
4
|
+
|
|
5
|
+
**A review page shows when its pull request has merged or closed.** The **Merged** and **PR closed**
|
|
6
|
+
labels used to appear only on the Reviews page. A review page now shows the same label in its header,
|
|
7
|
+
right after the pull request number: **#39609 Merged**, or **#39609 Closed**. The number is still the
|
|
8
|
+
link to the pull request. Nothing shows while the pull request is open. This is the latest state the
|
|
9
|
+
workspace server has seen, not a live read of GitHub: the server checks your pull requests every few
|
|
10
|
+
minutes, and a page left open picks up what it learns within a minute, without reloading. The server
|
|
11
|
+
only checks the pull requests of reviews that are queued, saved, or not yet marked reviewed, so a
|
|
12
|
+
review you marked reviewed before its pull request merged won't show the change.
|
|
13
|
+
|
|
3
14
|
## 0.42.0
|
|
4
15
|
|
|
5
16
|
**A review page no longer says "Review up to date" when it isn't.** The status beside **Check for
|
package/dist/server.js
CHANGED
|
@@ -4015,6 +4015,20 @@ function renderUpdateProgress(job) {
|
|
|
4015
4015
|
</div>`;
|
|
4016
4016
|
}
|
|
4017
4017
|
//#endregion
|
|
4018
|
+
//#region ../../packages/review-harness/src/workspace/pr_state_view.ts
|
|
4019
|
+
/**
|
|
4020
|
+
* The pull request's state, beside the review's status and never instead of it: `Reviewed` is the
|
|
4021
|
+
* reviewer's decision, `Merged` is the upstream's. Open says nothing, because it is what a review
|
|
4022
|
+
* of a pull request usually is, and a label that never varies teaches nothing.
|
|
4023
|
+
*
|
|
4024
|
+
* `besideNumber` is whether the pull request's number sits right before the pill. There, "Closed"
|
|
4025
|
+
* is enough; anywhere else it would read as the branch closing, so the pill names the PR itself.
|
|
4026
|
+
*/
|
|
4027
|
+
function renderPrState(state, besideNumber = false) {
|
|
4028
|
+
if (state !== "merged" && state !== "closed") return "";
|
|
4029
|
+
return `<span class="prb-card-pr-state" data-pr-state="${state}">${state === "merged" ? "Merged" : besideNumber ? "Closed" : "PR closed"}</span>`;
|
|
4030
|
+
}
|
|
4031
|
+
//#endregion
|
|
4018
4032
|
//#region ../../packages/review-harness/src/workspace/page.ts
|
|
4019
4033
|
function renderWorkspace(view) {
|
|
4020
4034
|
const { session, changeSet } = view;
|
|
@@ -4394,6 +4408,7 @@ function renderReviewBar(view, freshness) {
|
|
|
4394
4408
|
<span class="prb-change-ref" title="${escapeHtml$1(changeSet.repoPath)}">
|
|
4395
4409
|
${changeSet.isLinkedWorktree ? `<span class="prb-checkout">${escapeHtml$1(changeSet.checkoutName)}</span>` : ""}
|
|
4396
4410
|
${view.prContext ? `<a class="prb-pr-chip" href="${escapeHtml$1(view.prContext.prContext.pullRequest.url)}" target="_blank" rel="noopener noreferrer" title="${escapeHtml$1(view.prContext.prContext.pullRequest.title ?? "")}">#${view.prContext.prContext.pullRequest.number}</a>` : ""}
|
|
4411
|
+
${view.prState ? `<span class="prb-pr-state-slot" data-pr-state-slot${view.prContext ? " data-beside-number" : ""}>${renderPrState(view.prState.state, view.prContext !== void 0)}</span>` : ""}
|
|
4397
4412
|
${renderSubject(changeSet)}
|
|
4398
4413
|
${changeSet.includesUncommitted ? "<span class=\"prb-file-status\">+ working tree</span>" : ""}
|
|
4399
4414
|
${renderAuthor(view)}
|
|
@@ -5912,6 +5927,20 @@ function storedRequestKeys() {
|
|
|
5912
5927
|
function prStatesByRequest(states = readPrStates()) {
|
|
5913
5928
|
return new Map(Object.entries(states).map(([key, entry]) => [key, entry.state]));
|
|
5914
5929
|
}
|
|
5930
|
+
/**
|
|
5931
|
+
* One review's pull request state, for its page, filed under the same key the list looks up. Null
|
|
5932
|
+
* for a review with no request or one never observed: unknown, not open. Only ever what the watcher
|
|
5933
|
+
* last saw; nothing here reaches the forge.
|
|
5934
|
+
*/
|
|
5935
|
+
function prStateOf$1(workspace, states = readPrStates()) {
|
|
5936
|
+
const request = requestOf(workspace);
|
|
5937
|
+
if (!request) return null;
|
|
5938
|
+
return states[requestKey(workspace.repoPath, request.number)]?.state ?? null;
|
|
5939
|
+
}
|
|
5940
|
+
/** Whether a review is of a pull request at all, whatever its state. See `requestOf`. */
|
|
5941
|
+
function hasRequest(workspace) {
|
|
5942
|
+
return requestOf(workspace) !== null;
|
|
5943
|
+
}
|
|
5915
5944
|
function defaultDeps() {
|
|
5916
5945
|
return {
|
|
5917
5946
|
candidates: watchedCandidates,
|
|
@@ -6417,15 +6446,6 @@ function statusOf(review) {
|
|
|
6417
6446
|
if (review.completedAt) return "complete";
|
|
6418
6447
|
return review.lastViewedAt ? "in-progress" : "new";
|
|
6419
6448
|
}
|
|
6420
|
-
/**
|
|
6421
|
-
* The pull request's state, beside the review's status and never instead of it: `Reviewed` is the
|
|
6422
|
-
* reviewer's decision, `Merged` is the upstream's. Open says nothing, because it is what a review
|
|
6423
|
-
* of a pull request usually is, and a label that never varies teaches nothing.
|
|
6424
|
-
*/
|
|
6425
|
-
function renderPrState(state) {
|
|
6426
|
-
if (state !== "merged" && state !== "closed") return "";
|
|
6427
|
-
return `<span class="prb-card-pr-state" data-pr-state="${state}">${state === "merged" ? "Merged" : "PR closed"}</span>`;
|
|
6428
|
-
}
|
|
6429
6449
|
function renderStatus(status) {
|
|
6430
6450
|
return `<span class="prb-card-status" data-status="${status}">${statusLabel(status)}</span>`;
|
|
6431
6451
|
}
|
|
@@ -8881,6 +8901,7 @@ async function sendWorkspacePage(res, workspace) {
|
|
|
8881
8901
|
freshness: freshness ?? void 0,
|
|
8882
8902
|
availability: standing?.availability ?? null,
|
|
8883
8903
|
remote: await remoteOrNull(workspace),
|
|
8904
|
+
...hasRequest(workspace) ? { prState: { state: prStateOf$1(workspace) } } : {},
|
|
8884
8905
|
dismissedFreshnessSha: workspace.dismissedFreshnessSha,
|
|
8885
8906
|
lastPrRefresh: workspace.lastPrRefresh,
|
|
8886
8907
|
lastUpdate: notice,
|
|
@@ -8999,10 +9020,12 @@ async function handleFreshness(res, workspace, quiet) {
|
|
|
8999
9020
|
const standing = await standingOrNull(workspace);
|
|
9000
9021
|
const report = standing?.freshness ?? null;
|
|
9001
9022
|
const remote = await remoteOrNull(workspace);
|
|
9023
|
+
const prState = prStateOf$1(workspace);
|
|
9002
9024
|
const revision = workspaceRevision(workspace) ?? null;
|
|
9003
9025
|
if (!report) return send(res, 200, {
|
|
9004
9026
|
report: null,
|
|
9005
9027
|
remote,
|
|
9028
|
+
prState,
|
|
9006
9029
|
kiss,
|
|
9007
9030
|
kissDismissedSha: workspace.dismissedKissFreshnessSha ?? null,
|
|
9008
9031
|
revision
|
|
@@ -9018,6 +9041,7 @@ async function handleFreshness(res, workspace, quiet) {
|
|
|
9018
9041
|
report,
|
|
9019
9042
|
availability: standing?.availability ?? null,
|
|
9020
9043
|
remote,
|
|
9044
|
+
prState,
|
|
9021
9045
|
dismissedSha: workspace.dismissedFreshnessSha ?? null,
|
|
9022
9046
|
kiss,
|
|
9023
9047
|
kissDismissedSha: workspace.dismissedKissFreshnessSha ?? null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prreviewbuddy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "Review a branch or pull request in an isolated checkout, from your terminal, with the coding agent you already have installed.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://prreviewbuddy.com",
|
package/static/shell.css
CHANGED
|
@@ -562,6 +562,10 @@ body[data-server-stopped] .prb-shell { opacity: 0.55; pointer-events: none; }
|
|
|
562
562
|
text-decoration: none;
|
|
563
563
|
}
|
|
564
564
|
.prb-pr-chip:hover { background: var(--brand); color: #fff; }
|
|
565
|
+
/* Where the pull request's Merged or Closed pill goes, right after the chip. No box of its own, so an
|
|
566
|
+
open pull request's empty slot leaves no extra gap in the row and a filled one lays the pill out
|
|
567
|
+
as the chip's sibling. The pill is the Reviews card's, `.prb-card-pr-state`. */
|
|
568
|
+
.prb-pr-state-slot { display: contents; }
|
|
565
569
|
|
|
566
570
|
/* Beside the branch, after it, because the branch is what the reviewer came for and this is who
|
|
567
571
|
it belongs to. One line, ellipsed rather than wrapped: the header is a single row and a long
|
package/static/workspace.js
CHANGED
|
@@ -2,12 +2,12 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunk-BeqgAIrQ.js","ch
|
|
|
2
2
|
import{c as e,i as t,t as n}from"./chunk-BeL0x-wt.js";import{_ as r,d as i,g as a,h as o}from"./chunk-CmPWaXhU.js";function s(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var c=`pr-helper-code-block`,l=`pr-helper-code-copy`,u=`\0`,d=``,ee=/\u0000(\d+)\u0000/g,f=/^\u0000\d+\u0000$/,p=/\u0001(\d+)\u0001/g,m=/^(?:https?:\/\/|#)/i;function te(e){let{text:t,blocks:n}=ne(e.replace(/[\u0000\u0001]/g,``));return re(ie(t),n)}function ne(e){let t=[],n=e.split(`
|
|
3
3
|
`),r=[],i=0;for(;i<n.length;){let e=n[i].match(/^\s*(`{3,}|~{3,})\s*[\w+#.-]*\s*$/);if(!e){r.push(n[i]),i+=1;continue}let a=RegExp(`^\\s*${e[1][0]}{3,}\\s*$`),o=[];for(i+=1;i<n.length&&!a.test(n[i]);)o.push(n[i]),i+=1;i+=1,r.push(`${u}${t.length}${u}`),t.push(o.join(`
|
|
4
4
|
`))}return{text:r.join(`
|
|
5
|
-
`),blocks:t}}function re(e,t){return e.replace(ee,(e,n)=>`<div class="${c}"><pre><code>${s(t[Number(n)])}</code></pre><button type="button" class="${l}" aria-label="Copy code">Copy</button></div>`)}function ie(e){let t=[],n=[],r=[],i=null,a=()=>{n.length&&t.push(`<p>${
|
|
6
|
-
`)){let e=o.trim();if(!e){a();continue}if(f.test(e)){a(),t.push(e);continue}if(/^(?:-{3,}|\*{3,}|_{3,})$/.test(e)){a(),t.push(`<hr>`);continue}let s=e.match(/^(#{1,6})\s+(.+)$/);if(s){a();let e=Math.min(s[1].length,3)+3;t.push(`<h${e}>${
|
|
5
|
+
`),blocks:t}}function re(e,t){return e.replace(ee,(e,n)=>`<div class="${c}"><pre><code>${s(t[Number(n)])}</code></pre><button type="button" class="${l}" aria-label="Copy code">Copy</button></div>`)}function ie(e){let t=[],n=[],r=[],i=null,a=()=>{n.length&&t.push(`<p>${ae(n.join(` `))}</p>`),r.length&&t.push(`<blockquote>${ae(r.join(` `))}</blockquote>`),i&&t.push(`<${i.tag}>${i.items.map(e=>`<li>${ae(e)}</li>`).join(``)}</${i.tag}>`),n=[],r=[],i=null};for(let o of e.split(`
|
|
6
|
+
`)){let e=o.trim();if(!e){a();continue}if(f.test(e)){a(),t.push(e);continue}if(/^(?:-{3,}|\*{3,}|_{3,})$/.test(e)){a(),t.push(`<hr>`);continue}let s=e.match(/^(#{1,6})\s+(.+)$/);if(s){a();let e=Math.min(s[1].length,3)+3;t.push(`<h${e}>${ae(s[2])}</h${e}>`);continue}let c=e.match(/^[-*+]\s+(.+)$/);if(c){i?.tag!==`ul`&&(a(),i={tag:`ul`,items:[]}),i.items.push(c[1]);continue}let l=e.match(/^\d{1,9}[.)]\s+(.+)$/);if(l){i?.tag!==`ol`&&(a(),i={tag:`ol`,items:[]}),i.items.push(l[1]);continue}let u=e.match(/^>\s?(.*)$/);if(u){r.length||a(),r.push(u[1]);continue}if(i&&i.items.length){i.items[i.items.length-1]+=` ${e}`;continue}if(r.length){r[r.length-1]+=` ${e}`;continue}n.push(e)}return a(),t.join(``)}function ae(e){let t=[];return s(e).replace(/`([^`\n]+)`/g,(e,n)=>(t.push(n),`${d}${t.length-1}${d}`)).replace(/(?<!!)\[([^\]\n]+)\]\(([^)\s]+)\)/g,(e,t,n)=>m.test(n)?`<a href="${n}" target="_blank" rel="noopener noreferrer">${t}</a>`:e).replace(/\*\*([^*\n]+)\*\*/g,`<strong>$1</strong>`).replace(/__([^_\n]+)__/g,`<strong>$1</strong>`).replace(/(^|[^*\w])\*([^*\n]+)\*/g,`$1<em>$2</em>`).replace(/(^|[^_\w])_([^_\n]+)_(?![\w_])/g,`$1<em>$2</em>`).replace(p,(e,n)=>`<code>${t[Number(n)]}</code>`)}var oe=`pr-helper-selection-popover`,se=`pr-helper-selection-popover-expanded`,ce=`pr-helper-selection-copy-done`,le=8,h=8,ue=1e3,de=`Copy selected text`,fe=`Copy`,pe=`Copied`,me=`pr-helper-selection-popover-flat`,g=null;function he(e){return`<button type="button" class="pr-helper-selection-menu-item" data-selection-action="${s(e.id)}">${s(e.label)}</button>`}function ge(e){let t=new Map;for(let n of e){if(!n.section)continue;let e=t.get(n.section);e?e.push(n):t.set(n.section,[n])}return`${e.filter(e=>!e.section).map(he).join(``)}${[...t].map(([e,t])=>`
|
|
7
7
|
<div class="pr-helper-selection-menu-group">
|
|
8
8
|
<div class="pr-helper-selection-menu-heading">${s(e)}</div>
|
|
9
|
-
<div class="pr-helper-selection-menu-group-items">${t.map(
|
|
10
|
-
</div>`).join(``)}`}function
|
|
9
|
+
<div class="pr-helper-selection-menu-group-items">${t.map(he).join(``)}</div>
|
|
10
|
+
</div>`).join(``)}`}function _e(e){if(e.layout===`flat`)return ve(e);let t=ge(e.actions);return`
|
|
11
11
|
<div class="pr-helper-selection-bar">
|
|
12
12
|
<button type="button" class="pr-helper-selection-trigger" data-selection-open>
|
|
13
13
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="12" height="12" fill="currentColor" aria-hidden="true">
|
|
@@ -15,7 +15,7 @@ import{c as e,i as t,t as n}from"./chunk-BeL0x-wt.js";import{_ as r,d as i,g as
|
|
|
15
15
|
</svg>
|
|
16
16
|
<span>${s(e.triggerLabel??`Ask`)}</span>
|
|
17
17
|
</button>
|
|
18
|
-
<button type="button" class="pr-helper-selection-copy" data-selection-copy aria-label="${
|
|
18
|
+
<button type="button" class="pr-helper-selection-copy" data-selection-copy aria-label="${de}" aria-describedby="pr-helper-selection-tip">
|
|
19
19
|
<svg class="pr-helper-selection-copy-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true">
|
|
20
20
|
<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"/>
|
|
21
21
|
<path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"/>
|
|
@@ -24,43 +24,43 @@ import{c as e,i as t,t as n}from"./chunk-BeL0x-wt.js";import{_ as r,d as i,g as
|
|
|
24
24
|
<path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L1.22 8.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"/>
|
|
25
25
|
</svg>
|
|
26
26
|
</button>
|
|
27
|
-
<span class="pr-helper-selection-tip" id="pr-helper-selection-tip" role="tooltip">${
|
|
27
|
+
<span class="pr-helper-selection-tip" id="pr-helper-selection-tip" role="tooltip">${de}</span>
|
|
28
28
|
</div>
|
|
29
29
|
<div class="pr-helper-selection-menu">${t}</div>
|
|
30
|
-
`}function
|
|
31
|
-
${
|
|
32
|
-
<button type="button" class="pr-helper-selection-menu-item pr-helper-selection-copy-item" data-selection-copy>${
|
|
33
|
-
</div>`}function
|
|
30
|
+
`}function ve(e){return`<div class="pr-helper-selection-menu">
|
|
31
|
+
${ge(e.actions)}
|
|
32
|
+
<button type="button" class="pr-helper-selection-menu-item pr-helper-selection-copy-item" data-selection-copy>${fe}</button>
|
|
33
|
+
</div>`}function ye(e,t){let{width:n,height:r}=e.getBoundingClientRect(),i=t.top-r-le,a=i>=h?i:Math.min(t.bottom+le,window.innerHeight-r-h),o=Math.max(h,Math.min(t.left,window.innerWidth-n-h));e.style.top=`${Math.max(h,a)}px`,e.style.left=`${o}px`}function _(){v&&=(window.clearTimeout(v),0),g?.popover.remove(),g=null}var v=0;function be(e){let t=e.querySelector(`.pr-helper-selection-tip`),n=e.querySelector(`.pr-helper-selection-copy-item`);e.classList.add(ce),t&&(t.textContent=pe),n&&(n.textContent=pe),v&&window.clearTimeout(v),v=window.setTimeout(()=>xe(e),ue)}function xe(e){v&&=(window.clearTimeout(v),0),e.classList.remove(ce);let t=e.querySelector(`.pr-helper-selection-tip`);t&&(t.textContent=de);let n=e.querySelector(`.pr-helper-selection-copy-item`);n&&(n.textContent=fe)}async function Se(e,t){try{await navigator.clipboard.writeText(t)}catch(e){console.warn(`PR Helper: clipboard write failed, falling back to execCommand`,e);let t=!1;try{t=document.execCommand(`copy`)}catch(e){console.warn(`PR Helper: clipboard fallback failed`,e)}if(!t)return}be(e)}function Ce(e,t){let n=window.getSelection();if(!n||n.isCollapsed||n.rangeCount===0)return null;let r=n.toString().trim();if(!r)return null;let i=n.getRangeAt(0);if(!e.contains(i.commonAncestorContainer))return null;if(t.onlyWithin||t.ignoreWithin){let e=i.commonAncestorContainer,n=e instanceof HTMLElement?e:e.parentElement;if(t.onlyWithin&&!n?.closest(t.onlyWithin)||t.ignoreWithin&&n?.closest(t.ignoreWithin))return null}let a=i.getBoundingClientRect();return a.width===0&&a.height===0?null:{text:r,rect:a}}function we(e,t){let n={},r=()=>{let r=Ce(e,t);if(!r){(!g||g.owner===n)&&_();return}if(g&&g.owner!==n&&_(),g)g.popover.classList.remove(se),xe(g.popover),g.text=r.text;else{let i=document.createElement(`div`);i.className=t.layout===`flat`?`${oe} ${me}`:oe,i.innerHTML=_e(t),i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,n=>{let r=n.target;if(r.closest(`[data-selection-copy]`)){g?.text&&Se(i,g.text);return}if(r.closest(`[data-selection-open]`)){i.classList.add(se);let n=Ce(e,t);ye(i,n?.rect??i.getBoundingClientRect());return}let a=r.closest(`[data-selection-action]`)?.dataset.selectionAction;if(!a||!g)return;let o=g.text;_(),t.onChoose(a,o)}),document.body.appendChild(i),g={popover:i,text:r.text,owner:n}}ye(g.popover,r.rect)},i=e=>{g&&e.target instanceof Node&&g.popover.contains(e.target)||window.setTimeout(r,0)},a=e=>{(e.shiftKey||e.key===`Shift`)&&r()},o=()=>{if(!g)return;let e=window.getSelection();(!e||e.isCollapsed)&&_()},s=e=>{e.key===`Escape`&&_()},c=()=>_();return document.addEventListener(`mouseup`,i,!0),document.addEventListener(`keyup`,a,!0),e.addEventListener(`scroll`,c,!0),document.addEventListener(`selectionchange`,o),document.addEventListener(`keydown`,s),window.addEventListener(`scroll`,c,!0),()=>{document.removeEventListener(`mouseup`,i,!0),document.removeEventListener(`keyup`,a,!0),e.removeEventListener(`scroll`,c,!0),document.removeEventListener(`selectionchange`,o),document.removeEventListener(`keydown`,s),window.removeEventListener(`scroll`,c,!0),_()}}async function Te(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){return console.warn(`PR Helper: clipboard write failed, falling back to execCommand`,t),Ee(e)}}function Ee(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:fixed;top:-9999px;left:-9999px;opacity:0;`,document.body.appendChild(t);try{return t.select(),document.execCommand(`copy`)}catch(e){return console.warn(`PR Helper: clipboard fallback failed`,e),!1}finally{t.remove()}}var y=`pr-helper-msg-copy`,De=`pr-helper-chat-actions`,Oe=`data-message-id`,ke=`data-copy-source`,Ae={idle:{icon:`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path>`,label:``,aria:`Copy message`},copied:{icon:`<path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path>`,label:`Copied`,aria:`Copied`},failed:{icon:`<path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>`,label:`Copy failed`,aria:`Copy failed`}};function je(e){return Pe(`${ke}="${s(e)}"`)}var Me=`data-copy-idle-label`,Ne=`data-copy-idle-aria`;function Pe(e,t){let{icon:n}=Ae.idle,r=t?.label??Ae.idle.label,i=t?.aria??Ae.idle.aria,a=`<button type="button" class="${y}" ${e}${t?` ${Me}="${s(r)}" ${Ne}="${s(i)}"`:``} aria-label="${s(i)}"><span class="${y}-icon" aria-hidden="true">${Ie(n)}</span><span class="${y}-label"${r?``:` hidden`}>${s(r)}</span></button>`;return t?a:`<div class="${De}">${a}</div>`}function Fe(e,t){let n=Ae[t],r=t===`idle`?{...n,label:e.getAttribute(Me)??n.label,aria:e.getAttribute(Ne)??n.aria}:n,i=e.querySelector(`.${y}-icon`),a=e.querySelector(`.${y}-label`);i&&(i.innerHTML=Ie(r.icon)),a instanceof HTMLElement&&(a.textContent=r.label,a.hidden=r.label===``),e.setAttribute(`aria-label`,r.aria),e.classList.toggle(`copied`,t===`copied`),e.classList.toggle(`failed`,t===`failed`)}function Ie(e){return`<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">${e}</svg>`}var Le=1400,Re=`Copy`,ze=`Copied`,Be=/Mac|iPhone|iPad/.test(navigator.userAgent)?`Press ⌘C`:`Press Ctrl C`,b=new WeakMap;function Ve(e,t={}){let n=e=>{let n=e.target;if(!(n instanceof Element))return;let r=n.closest(`.${l}`),i=r?null:n.closest(`.${y}`);!r&&!i||(e.preventDefault(),e.stopPropagation(),r?We(r):i&&He(i,t.messageSource))};return e.addEventListener(`click`,n,!0),()=>e.removeEventListener(`click`,n,!0)}async function He(e,t){let n=Ue(e,t);Ke(e,n!==null&&await Te(n)?`copied`:`failed`)}function Ue(e,t){let n=e.getAttribute(ke);if(n!==null)return n;let r=e.getAttribute(Oe);return r&&t?t(r):null}async function We(e){let t=e.parentElement?.querySelector(`pre code`),n=t?await Te(t.textContent??``):!1;!n&&t&&Ge(t),qe(e,n?ze:Be,n)}function Ge(e){let t=window.getSelection();if(!t)return;let n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}function Ke(e,t){let n=b.get(e);n&&window.clearTimeout(n),Fe(e,t),b.set(e,window.setTimeout(()=>{Fe(e,`idle`),b.delete(e)},Le))}function qe(e,t,n){let r=b.get(e);r&&window.clearTimeout(r),e.textContent=t,e.classList.toggle(`copied`,n),b.set(e,window.setTimeout(()=>{e.textContent=Re,e.classList.remove(`copied`),b.delete(e)},Le))}var Je=[{id:`explain`,label:`Explain`,instruction:`Explain this in simpler terms.`},{id:`is-problem`,label:`Is this actually a problem?`,instruction:`Is this actually a problem? Be specific about when it would and would not matter.`},{id:`better-implementation`,label:`Suggest a better implementation`,instruction:`Suggest a better implementation for this.`},{id:`author-question`,label:`Generate a question for the author`,instruction:`Generate a question I could ask the author about this.`},{id:`custom`,label:`Ask a question`}],Ye=[{id:`add-to-chat`,label:`Add to chat`}],Xe=800;function Ze(e){let t=e.replace(/\r\n/g,`
|
|
34
34
|
`).split(`
|
|
35
35
|
`).map(e=>e.replace(/\s+$/,``));for(;t.length&&!t[0].trim();)t.shift();for(;t.length&&!t[t.length-1].trim();)t.pop();let n=t.filter(e=>e.trim()).map(e=>e.match(/^[ \t]*/)[0].length),r=n.length?Math.min(...n):0,i=t.map(e=>e.slice(r)).join(`
|
|
36
36
|
`).replace(/\n{3,}/g,`
|
|
37
37
|
|
|
38
|
-
`);return i.trim()?(i.length>
|
|
38
|
+
`);return i.trim()?(i.length>Xe?`${i.slice(0,Xe).trimEnd()}…`:i).split(`
|
|
39
39
|
`).map(e=>`> ${e}`.trimEnd()).join(`
|
|
40
|
-
`):``}function
|
|
40
|
+
`):``}function Qe(e,t){let n=Ze(e);if(!n)return null;let r=[...Je,...Ye].find(e=>e.id===t);return r?r.instruction?`${n}\n\n${r.instruction}`:`${n}\n\n`:null}var $e=`saved:`,et=`Your prompts`;function tt(e){return`${$e}${e}`}function nt(e){return e.startsWith(`saved:`)?e.slice(6):null}function rt(e){return e.reviewerClosed>0?`dealt with`:`resolved`}({claude:`Claude Code`,codex:`Codex`,gemini:`Gemini CLI`}).claude;var it=`Dismissed by you — you decided this finding needs no action. It stops counting towards what is left, and stays here so the decision is visible rather than lost.`;function at(e,t,n=`resolved`){return t===0?`<span class="pr-helper-questions-progress-check" aria-hidden="true">\u2713</span><span class="pr-helper-questions-progress-count">All ${e} issues ${n}</span>`:`<span class="pr-helper-questions-progress-count">${t} of ${e} still open</span>`}function ot(e){let t=e.done-e.reviewerClosed;return e.reviewerClosed===0?`Resolved by the new commits (${e.done})`:t===0?`Dismissed by you (${e.done})`:`Dealt with (${e.done})`}function st(e,t){return t===0?`<span class="pr-helper-questions-progress-check" aria-hidden="true">✓</span><span class="pr-helper-questions-progress-count">All ${e} questions answered</span>`:`<span class="pr-helper-questions-progress-count">${t} of ${e} unanswered</span>`}function ct(e){let t=[...document.querySelectorAll(`[data-guide-detail]`)],n=t.find(t=>t.dataset.guideDetail===e);if(!n)return null;for(let e of t)e.hidden=e!==n;return n}function lt(e){return e instanceof Element&&e.closest(`[data-guide-jump]`)?.dataset.guideJump||null}function ut(e){for(let t of document.querySelectorAll(`[data-goto-section]`))t.setAttribute(`aria-current`,String(t.dataset.gotoSection===e))}function dt(){for(let e of document.querySelectorAll(`.prb-rail [data-goto-section]`))e.setAttribute(`aria-current`,`false`)}function ft(e,t){let n=e.trim();return n?`${n}\n\n${t}`:t}var pt=[`progress`,`overview`,`guide`,`issues`,`questions`,`files`,`prcontext`,`diagram`,`kiss`,`kissrecs`],mt=`#theme-`;function ht(e){return`#${e}`}function gt(e){return`${mt}${encodeURIComponent(e)}`}function _t(e){return e.kind===`view`?ht(e.view):gt(e.sectionId)}function vt(e){if(e.startsWith(mt)){let t=e.slice(7);if(!t)return null;try{return{kind:`section`,sectionId:decodeURIComponent(t)}}catch{return null}}let t=e.replace(/^#/,``);return pt.includes(t)?{kind:`view`,view:t}:null}function yt(e){if(!Number.isFinite(e))return``;let t=Math.round((Date.now()-e)/6e4);if(t<1)return`just now`;if(t<60)return`${t} minute${t===1?``:`s`} ago`;let n=Math.round(t/60);if(n<24)return`${n} hour${n===1?``:`s`} ago`;let r=Math.round(n/24);return`${r} day${r===1?``:`s`} ago`}function bt(){return`<button type="button" class="prb-update-btn" data-review-update>Update review</button>`}var xt=`Updating this review checks the latest commits and refreshes the PR conversation. Your progress and Buddy AI history will be kept.`;function St(e){return`<details class="prb-update-alt">
|
|
41
41
|
<summary>Start a new review</summary>
|
|
42
42
|
<span>A brand new review, with its own findings and its own path through the change. Run <code>${s(e)}</code> in your session.<button type="button" class="prb-fresh-quiet" data-copy-command="${s(e)}">Copy</button></span>
|
|
43
|
-
</details>`}var
|
|
43
|
+
</details>`}var Ct=`prreviewbuddy review --fresh`;function wt(e,t){return e?e.code.state===`fixed`?{label:`Freshness: Fixed`,state:`fixed`}:t?{label:`PR updated`,state:`changed`}:e.code.state===`changed`?{label:e.code.rewritten?`Code rewritten`:`Code changed`,state:`changed`}:e.code.state===`current`?{label:`Review up to date`,state:`current`}:{label:`Freshness unknown`,state:`unknown`}:t?{label:`PR updated`,state:`changed`}:{label:`Check for updates`,state:`unknown`}}function Tt(e,t={}){let n=e??(t.remote?jt(t.remote):null);if(!n)return``;let r=n.code.state===`fixed`?null:t.remote??null,i=n.code.state===`changed`||r!==null,a=n.code.reason===`missing-commit`,o=t.availability?.state===`missing`,c=r?.sha??n.code.latestSha,l=t.dismissedSha!==void 0&&t.dismissedSha===c;if(!t.open&&!o&&(!(i||a)||l))return``;let u=r?Mt(n.code,r):At(n.code,t.availability??null),d=e?[...u.facts,`checked ${s(yt(n.checkedAt))}`]:u.facts;return`<div class="prb-fresh" data-state="${i||a?`changed`:`quiet`}" role="status">
|
|
44
44
|
<div class="prb-fresh-head">
|
|
45
45
|
<span class="prb-fresh-dot" data-freshness="${u.state}" aria-hidden="true"></span>
|
|
46
46
|
<strong class="prb-fresh-title">${s(u.title)}</strong>
|
|
47
47
|
<span class="prb-fresh-facts">${d.join(` · `)}</span>
|
|
48
48
|
</div>
|
|
49
49
|
${u.consequence?`<p class="prb-fresh-say">${u.consequence}</p>`:``}
|
|
50
|
-
${
|
|
51
|
-
</div>`}function
|
|
52
|
-
${r?
|
|
53
|
-
${r?
|
|
50
|
+
${Et(n,t,i||a)}
|
|
51
|
+
</div>`}function Et(e,t,n){let r=t.actions&&n,i=n?``:`<button type="button" class="prb-fresh-close" data-fresh-close aria-label="Close">×</button>`;return`<div class="prb-fresh-actions">
|
|
52
|
+
${r?bt():``}
|
|
53
|
+
${r?St(Ct):``}
|
|
54
54
|
${i}
|
|
55
|
-
${
|
|
56
|
-
</div>`}function
|
|
55
|
+
${Dt(e,t,n,r===!0)}
|
|
56
|
+
</div>`}function Dt(e,t,n,r){let i=[r?s(xt):``,t.remote?Nt(e.code):Pt(e.code,e.checkout.reason!==`no-pull-request`),Ft(e,t.actions===!0),n?`<button type="button" class="prb-fresh-quiet" data-fresh-dismiss="${s(t.remote?.sha??e.code.latestSha??``)}">Dismiss this warning</button>`:``].filter(e=>e!==``);if(i.length===0)return``;let a=`<div class="prb-fresh-notes">${i.map(e=>`<p>${e}</p>`).join(``)}</div>`;return n?`<details class="prb-fresh-more">
|
|
57
57
|
<summary>More details</summary>
|
|
58
58
|
${a}
|
|
59
|
-
</details>`:a}function
|
|
59
|
+
</details>`:a}function Ot(e,t){return e===null?[]:[`${e} file${e===1?``:`s`} ${t}`]}function kt(e){return e?`<code title="${s(e)}">${s(e.slice(0,7))}</code>`:``}function x(e){return e?[`reviewed ${kt(e)}`]:[]}function At(e,t){if(e.state===`fixed`)return{state:`fixed`,title:`Freshness: Fixed`,facts:x(e.reviewedSha),consequence:t?.state===`missing`?`That commit is no longer in this repository. The review still reads in full, but it cannot be analysed again until the commit is back.`:`This review is of one commit, and a commit does not change, so these findings keep describing it.`};if(e.state===`current`)return{state:`current`,title:`Review up to date`,facts:x(e.reviewedSha),consequence:``};if(e.state===`changed`){if(e.rewritten)return{state:`changed`,title:`Code rewritten`,facts:[...x(e.reviewedSha),...Ot(e.changedFiles,`differ`)],consequence:`The branch was rebased or amended, so this review describes older code.`};let t=e.newCommits===null?[]:[`${e.newCommits} new commit${e.newCommits===1?``:`s`}`];return{state:`changed`,title:`Code changed`,facts:[...x(e.reviewedSha),...t,...Ot(e.changedFiles,`changed`)],consequence:`New commits landed, so the lines these findings cite may have moved.`}}switch(e.reason){case`uncommitted`:return{state:`unknown`,title:`Cannot be compared`,facts:x(e.reviewedSha),consequence:`This review read uncommitted work and nothing recorded what the working tree held, so whether the files still match cannot be told from here.`};case`missing-commit`:return{state:`unknown`,title:`Reviewed commit is gone`,facts:x(e.reviewedSha),consequence:`It is not in this repository any more, after a force-push or a branch rebuilt from scratch, so nothing can be measured against it.`};case`no-branch`:return{state:`unknown`,title:`Cannot be compared`,facts:x(e.reviewedSha),consequence:`This review’s branch is not in this repository, which is what a pull request from a fork or a branch deleted after merging looks like, so whether the findings still describe it cannot be told from here.`};default:return{state:`unknown`,title:`Cannot be compared`,facts:[],consequence:`Git could not be read in this checkout.`}}}function jt(e){return{checkedAt:0,code:{state:`unknown`,reviewedSha:e.reviewedSha,latestSha:null,comparison:null,newCommits:null,changedFiles:null,rewritten:!1,reason:null},checkout:{state:`unknown`,relation:`unknown`,prHeadSha:null,presentLocally:!1,reason:null},conversation:{attached:!1}}}function Mt(e,t){let n=e.state===`changed`&&e.latestSha===t.sha?e:null,r=t.newCommits??n?.newCommits??null,i=n?.rewritten?[]:[r===null?`new commits on the pull request`:`${r} new commit${r===1?``:`s`}`];return{state:`changed`,title:`PR updated`,facts:[...x(e.reviewedSha),...i,...n?Ot(n.changedFiles,n.rewritten?`differ`:`changed`):[],`seen ${s(yt(t.observedAt))}`],consequence:n?.rewritten?`The branch was rebased or amended, so this review describes older code.`:`New commits landed, so the lines these findings cite may have moved.`}}function Nt(e){return`This review is based on ${kt(e.reviewedSha)}. The pull request has newer commits. <strong>Update review</strong> fetches them first.`}function Pt(e,t){if(!e.comparison)return``;let n=`<code>${s(e.comparison.ref)}</code>`;return e.state===`current`?t?`This review is based on the latest PR commit ${kt(e.reviewedSha)}.`:`This review is based on ${kt(e.reviewedSha)}, the latest commit on ${n}.`:e.comparison.remote?`This review is currently based on ${n}. <strong>Check for updates</strong> compares against the latest version you already have locally. <strong>Update review</strong> fetches the newest version first.`:`This review is currently based on ${n}, the branch it is of.`}function Ft(e,t){if(!e.conversation.attached)return``;let n=s(yt(e.conversation.importedAt));return t?`<button type="button" class="prb-fresh-quiet" data-pr-recheck>Re-check the conversation</button> to refresh comments and resolved threads without re-running the code review. Last checked ${n}.`:`The PR conversation was last checked ${n}.`}function It(e){return e===`done`||e===`failed`}function Lt(e,t){let n=e=>e.toLowerCase().replace(/\bthe\b/g,``).replace(/[^a-z]/g,``);return n(e)===n(t)}function Rt(e,t,n={}){if(!t||t.state!==`changed`||n.dismissedSha&&n.dismissedSha===t.latestSha)return``;let r=t.rewritten?`The branch has been rewritten since, so this report describes commits that are no longer on it.`:t.newCommits===null?`The branch has moved on since.`:`There ${t.newCommits===1?`has been 1 commit`:`have been ${t.newCommits} commits`} on the branch since.`;return`<div class="prb-kiss-fresh" data-kiss-freshness="changed" role="status">
|
|
60
60
|
<p><strong>This KISS review describes commit ${s(e.slice(0,7))}.</strong> ${s(r)}</p>
|
|
61
61
|
<p class="prb-kiss-fresh-note">Running KISS again analyses the branch as it is now. The report below is kept either way.</p>
|
|
62
62
|
${n.actions&&t.latestSha?`<button type="button" class="prb-kiss-fresh-dismiss" data-kiss-freshness-dismiss="${s(t.latestSha)}">Not now</button>`:``}
|
|
63
|
-
</div>`}function
|
|
63
|
+
</div>`}function zt(e,t=!1){return e!==`merged`&&e!==`closed`?``:`<span class="prb-card-pr-state" data-pr-state="${e}">${e===`merged`?`Merged`:t?`Closed`:`PR closed`}</span>`}function Bt(e,t=Date.now()){let n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return`${n} second${n===1?``:`s`}`;let r=Math.round(n/60);return`${r} minute${r===1?``:`s`}`}var Vt={job:`data-job-phase`,kiss:`data-kiss-phase`,update:`data-update-phase`};function Ht(e){let t=new Map;for(let n of Object.keys(Vt)){let r=Vt[n],i=e.querySelector(`[${r}]`);i&&!It(i.getAttribute(r)??void 0)&&t.set(n,i)}return t}function Ut(e,t,n){return t.failed?!0:e===`update`?t.phase===`none`||It(t.phase):Wt(t.phase,n)}function Wt(e,t){return It(e)?!0:(e===`conversation`||e===`analysing`)&&!t.querySelector(`[data-view="files"]`)}function Gt(e,t,n){let r=[...e.querySelectorAll(`.prb-progress-step`)],i=r.findIndex(e=>e.dataset.phase===t);if(i===-1)return;r.forEach((e,t)=>{let n=t<i?`complete`:t===i?`active`:`pending`;e.dataset.state=n;let r=e.querySelector(`.prb-progress-label`),a=n===`complete`?e.dataset.labelDone:e.dataset.labelDoing;r&&a&&(r.textContent=a),t!==i&&e.querySelector(`[data-step-note]`)?.remove()});let a=r[i];if(!n||Lt(n,a.querySelector(`.prb-progress-label`)?.textContent??``))return;let o=a.querySelector(`[data-step-note]`);o||(o=document.createElement(`p`),o.className=`prb-progress-note`,o.setAttribute(`data-step-note`,``),a.appendChild(o)),o.textContent=n}function Kt(e){let t=e.querySelector(`[data-started-at]`),n=Number(t?.dataset.startedAt);!t||!Number.isFinite(n)||(t.textContent=`Running for ${Bt(n)}.`)}function qt(e,t,n){let r=e.scope===`change`?`Whole change`:t.get(e.scope)??`A theme of this change`,i=e.scope===`change`?``:e.scope;return`<article class="prb-diagram" id="prb-diagram-${s(e.scope)}" data-diagram-card="${s(e.scope)}">
|
|
64
64
|
<header class="prb-diagram-head">
|
|
65
65
|
<div class="prb-diagram-heading">
|
|
66
66
|
<h4 class="prb-diagram-title">
|
|
@@ -79,24 +79,24 @@ import{c as e,i as t,t as n}from"./chunk-BeL0x-wt.js";import{_ as r,d as i,g as
|
|
|
79
79
|
</div>
|
|
80
80
|
</header>
|
|
81
81
|
${e.caption?`<p class="prb-diagram-caption">${s(e.caption)}</p>`:``}
|
|
82
|
-
${
|
|
82
|
+
${Jt(e,n)}
|
|
83
83
|
<div class="prb-diagram-canvas" data-diagram-canvas></div>
|
|
84
84
|
<details class="prb-diagram-source">
|
|
85
85
|
<summary>Diagram source</summary>
|
|
86
86
|
<div class="${c}"><pre><code data-mermaid-source>${s(e.mermaid)}</code></pre><button type="button" class="${l}" aria-label="Copy code">Copy</button></div>
|
|
87
87
|
</details>
|
|
88
|
-
</article>`}function
|
|
88
|
+
</article>`}function Jt(e,t){return!e.commitSha||!t||e.commitSha===t?``:`<p class="prb-diagram-stale">Drawn from <code>${s(e.commitSha.slice(0,7))}</code>, before this review was brought up to date. Regenerate to draw it from the commit the review now describes.</p>`}var Yt={review:`<path d="M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2"/><rect x="9" y="3" width="6" height="4" rx="1"/><path d="m9 14 2 2 4-4"/>`,kiss:`<path d="M12 3v4M12 17v4M3 12h4M17 12h4"/><circle cx="12" cy="12" r="2"/>`,diagrams:`<rect x="3" y="3" width="7" height="6" rx="1"/><rect x="14" y="15" width="7" height="6" rx="1"/><path d="M6.5 9v3a2 2 0 0 0 2 2h7a2 2 0 0 1 2 2v-1"/>`,issues:`<circle cx="12" cy="12" r="9"/><path d="M12 8v4M12 16h.01"/>`,questions:`<circle cx="12" cy="12" r="9"/><path d="M9.1 9a3 3 0 0 1 5.8 1c0 2-3 3-3 3M12 17h.01"/>`,files:`<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5M9 13h6M9 17h6"/>`,prcontext:`<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>`,recommendations:`<path d="M9 18h6M10 22h4"/><path d="M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.2 1 2V17h6v-.3c0-.8.4-1.5 1-2A7 7 0 0 0 12 2z"/>`,reviews:`<path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"/>`,notifications:`<path d="M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.7 21a2 2 0 0 1-3.4 0"/>`,settings:`<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>`,feedback:`<path d="m22 2-7 20-4-9-9-4z"/><path d="M22 2 11 13"/>`,stop:`<path d="M12 2v10"/><path d="M18.4 6.6a9 9 0 1 1-12.8 0"/>`,restart:`<path d="M21 12a9 9 0 1 1-2.64-6.36"/><path d="M21 3v6h-6"/>`};function Xt(e){return`<span class="prb-rail-icon" aria-hidden="true">${Zt(e)}</span>`}function Zt(e){return`<svg viewBox="0 0 24 24" focusable="false" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">${Yt[e]}</svg>`}var Qt=`modulepreload`,$t=function(e){return`/`+e},en={},S=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=$t(t,n),t=s(t),t in en)return;en[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Qt,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},tn=.5,nn=3,rn=1.25,an=null;function on(){return an??=S(()=>import(`./chunk-BeqgAIrQ.js`).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:`strict`,htmlLabels:!1,flowchart:{htmlLabels:!1},theme:`neutral`,fontFamily:`inherit`}),e.default)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])),an}var sn=new WeakSet,cn=new WeakMap,ln=new WeakMap,C=null;function un(e){return document.addEventListener(`click`,t=>{let n=t.target;if(!(n instanceof Element))return;let r=n.closest(`[data-diagram-stop]`);if(r){r.setAttribute(`disabled`,``),r.textContent=`Stopping…`,fetch(e.endpoint(`/stop`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`diagram`})}).catch(()=>{}).finally(()=>{C?.abort()});return}let i=n.closest(`[data-diagram-toggle]`);if(i){_n(i.closest(`[data-diagram-card]`),i.getAttribute(`aria-expanded`)===`true`);return}let a=n.closest(`[data-diagram-zoom]`);if(a){bn(a.closest(`[data-diagram-card]`),a.dataset.diagramZoom??`reset`);return}let o=n.closest(`[data-diagram-request]`);o&&dn(e,o.dataset.diagramRequest||null)}),fn(),{drawPane:vn}}async function dn(e,t){if(C)return;let n=t??`change`,r=document.querySelector(`[data-diagram-pane]`),i=r?.querySelector(`[data-diagram-card="${On(n)}"]`)??null??pn(r,n,t);if(!i)return;w(),e.showDiagrams();let a=mn(i);C=new AbortController,Cn(!1);try{let n=await fetch(e.endpoint(`/diagram`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sectionId:t}),signal:C.signal}),r=await n.json().catch(()=>null);if(n.status===409&&r?.running){window.location.reload();return}if(r?.stopped)throw new DOMException(`Stopped`,`AbortError`);if(!n.ok||!r?.diagram)return hn(i,a,r?.error??`Buddy AI did not return a diagram. Check the terminal running PR Review Buddy.`);gn(i,r.diagram,t)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`){i.hasAttribute(`data-diagram-pending`)?(i.remove(),w()):a.remove();return}hn(i,a,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{C=null,Cn(!0)}}function fn(){let e=document.querySelector(`[data-diagram-pane][data-diagram-running]`);if(!e)return;let t=e.dataset.diagramRunning||null,n=t??`change`,r=e.querySelector(`[data-diagram-card="${On(n)}"]`)??pn(e,n,t);r&&(w(),mn(r,{scroll:!1}),Cn(!1))}function w(){let e=document.querySelectorAll(`[data-diagram-pane] [data-diagram-card]`).length,t=document.querySelector(`[data-view-nav="diagram"]`);if(e===0){t?.remove();return}if(!t){let e=document.querySelector(`[data-view-nav="issues"]`);if(!e)return;t=document.createElement(`button`),t.setAttribute(`type`,`button`),t.className=`prb-rail-item prb-rail-link`,t.dataset.viewNav=`diagram`,t.innerHTML=`${Xt(`diagrams`)}<span class="prb-rail-label"><span class="prb-rail-title">Diagrams</span></span><span class="prb-rail-count"></span>`,e.before(t)}let n=t.querySelector(`.prb-rail-count`);n&&(n.textContent=String(e),n.setAttribute(`aria-label`,e===1?`1 diagram`:`${e} diagrams`))}function pn(e,t,n){if(!e)return null;let r=document.createElement(`article`);return r.className=`prb-diagram`,r.dataset.diagramCard=t,r.setAttribute(`data-diagram-pending`,``),r.innerHTML=`<header class="prb-diagram-head">
|
|
89
89
|
<div class="prb-diagram-heading">
|
|
90
90
|
<h4 class="prb-diagram-title">Drawing…</h4>
|
|
91
|
-
<p class="prb-diagram-scope">${t===`change`?`Whole change`:
|
|
91
|
+
<p class="prb-diagram-scope">${t===`change`?`Whole change`:Dn(wn(n))}</p>
|
|
92
92
|
</div>
|
|
93
|
-
</header>`,
|
|
93
|
+
</header>`,Tn(e,r,n),r}function mn(e,{scroll:t=!0}={}){e.querySelector(`[data-diagram-status]`)?.remove();let n=document.createElement(`p`);n.className=`prb-diagram-status`,n.setAttribute(`data-diagram-status`,``),n.innerHTML=`<span class="prb-thinking"><i></i><i></i><i></i></span><span>Reading the change…</span>`;let r=document.createElement(`button`);return r.type=`button`,r.className=`prb-diagram-redraw`,r.setAttribute(`data-diagram-stop`,``),r.textContent=`Stop`,n.appendChild(r),e.querySelector(`.prb-diagram-head`)?.insertAdjacentElement(`afterend`,n),t&&e.scrollIntoView({behavior:kn()?`auto`:`smooth`,block:`start`}),n}function hn(e,t,n){if(t.className=`prb-diagram-failed`,t.textContent=n,e.hasAttribute(`data-diagram-pending`)){let n=document.createElement(`button`);n.type=`button`,n.className=`prb-diagram-redraw`,n.dataset.diagramRequest=e.dataset.diagramCard===`change`?``:e.dataset.diagramCard??``,n.textContent=`Try again`,t.appendChild(document.createTextNode(` `)),t.appendChild(n)}}function gn(e,t,n){let r=qt(t,new Map(n?[[n,wn(n)]]:[]),t.commitSha),i=document.createElement(`div`);i.innerHTML=r;let a=i.firstElementChild;a&&(e.replaceWith(a),w(),yn(a))}function _n(e,t){e&&(e.toggleAttribute(`data-diagram-collapsed`,t),e.querySelector(`[data-diagram-toggle]`)?.setAttribute(`aria-expanded`,String(!t)),t||yn(e))}function vn(){for(let e of document.querySelectorAll(`[data-diagram-pane] [data-diagram-card]`))yn(e)}async function yn(e){let t=e.querySelector(`[data-diagram-canvas]`),n=e.querySelector(`[data-mermaid-source]`)?.textContent??``;if(!(!t||!n||sn.has(e)||e.hasAttribute(`data-diagram-collapsed`))){sn.add(e);try{let e=await on();await e.parse(n);let{svg:r}=await e.render(`prb-mermaid-${Math.random().toString(36).slice(2)}`,n);t.innerHTML=r}catch{sn.delete(e),t.innerHTML=``;let n=document.createElement(`p`);n.className=`prb-diagram-failed`,n.textContent=`This diagram could not be drawn. Its source is below, and Regenerate will ask for another.`,t.replaceWith(n),e.querySelector(`details`)?.setAttribute(`open`,``)}}}function bn(e,t){let n=e?.querySelector(`[data-diagram-canvas] svg`),r=e?.querySelector(`[data-diagram-canvas]`);if(!e||!n||!r)return;if(t===`reset`){ln.delete(e),r.removeAttribute(`data-zoomed`),n.style.removeProperty(`width`);return}let i=xn(e,n);if(i<=0)return;let a=Sn((ln.get(e)??1)*(t===`in`?rn:1/rn));ln.set(e,a),r.setAttribute(`data-zoomed`,``),n.style.width=`${Math.round(i*a)}px`}function xn(e,t){let n=cn.get(e);if(n)return n;let r=t.getBoundingClientRect().width;if(r>0)return cn.set(e,r),r;let i=t.getAttribute(`viewBox`)?.split(/[\s,]+/),a=Number(i?.[2]??0);return Number.isFinite(a)?a:0}function Sn(e){return Math.min(nn,Math.max(tn,e))}function Cn(e){for(let t of document.querySelectorAll(`[data-diagram-request]`))t.disabled=!e}function wn(e){return e?document.querySelector(`[data-goto-section="${On(e)}"]`)?.querySelector(`.prb-rail-title`)?.textContent?.trim()||`A theme of this change`:`Whole change`}function Tn(e,t,n){let r=En(n);for(let n of e.querySelectorAll(`[data-diagram-card]`)){let e=n.dataset.diagramCard??``;if(En(e===`change`?null:e)>r){n.before(t);return}}e.appendChild(t)}function En(e){if(!e)return-1;let t=document.querySelector(`[data-goto-section="${On(e)}"]`);return Number(t?.dataset.themeIndex??0)}function Dn(e){let t=document.createElement(`span`);return t.textContent=e,t.innerHTML}function On(e){return CSS.escape(e)}function kn(){return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function An(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var jn=1e3,Mn=new WeakMap;function Nn(e,t){return e.length<=1e3?An(e)||` `:`${An(e.slice(0,jn))}\u2026 <button type="button" class="prb-code-long-toggle" data-full-line="${t}">Show full line</button>`}function Pn(e){let t=e.lines.length;return`<tr class="prb-code-deletion" data-before-line="${e.beforeLine}"><td class="prb-code-num"></td><td class="prb-code-line"><button type="button" class="prb-code-deletion-toggle" data-deletion-toggle aria-expanded="false">− ${t} deleted ${t===1?`line`:`lines`}</button></td></tr>`+e.lines.map(e=>`<tr class="prb-code-deleted" hidden><td class="prb-code-num">− ${e.oldLine}</td><td class="prb-code-line">${Nn(e.text,`old:${e.oldLine}`)}</td></tr>`).join(``)}function Fn(e,t){let n=new Set(e.addedLines),r=new Map;for(let t of e.deletions??[])r.set(t.beforeLine,t);let i=e.lines.map((i,a)=>{let o=e.from+a,s=[n.has(o)?`prb-code-added`:``,o===t?`prb-code-target`:``].filter(Boolean).join(` `),c=r.get(o);return`${c?Pn(c):``}<tr class="${s}" data-line="${o}"><td class="prb-code-num">${o}</td><td class="prb-code-line">${Nn(i,`new:${o}`)}</td></tr>`}),a=r.get(e.totalLines+1);return a&&e.to===e.totalLines&&i.push(Pn(a)),i.join(``)}function In(e){let t=e.getAttribute(`aria-expanded`)!==`true`;e.setAttribute(`aria-expanded`,String(t));let n=e.closest(`tr`)?.nextElementSibling;for(;n?.classList.contains(`prb-code-deleted`);)n.hidden=!t,n=n.nextElementSibling}function Ln(e,t){let n=new Map;for(let e of t.deletions??[])for(let t of e.lines)n.set(t.oldLine,t.text);for(let r of e.querySelectorAll(`[data-full-line]`)){let[e,i]=(r.dataset.fullLine??``).split(`:`),a=Number(i),o=e===`old`?n.get(a):t.lines[a-t.from];o!==void 0&&Mn.set(r,o)}}function Rn(e){let t=Mn.get(e),n=e.closest(`td`);return t===void 0||!n?null:(n.textContent=t,n)}function zn(e){return e.deletion?2*e.line-1:2*e.line}function Bn(e){return e%2==1?{line:(e+1)/2,deletion:!0}:{line:e/2,deletion:!1}}function Vn(e,t){if(e.length===0)return``;let n=e.map(zn),r=n.indexOf(t),i=n.some(e=>e<t),a=n.some(e=>e>t),o=e.length,s=r===-1?`${o} ${o===1?`change`:`changes`}`:`${r+1} of ${o}`;return`<span class="prb-code-nav" data-change-navigator data-change-keys="${n.join(`,`)}" data-change-position="${t}">
|
|
94
94
|
<button type="button" class="prb-code-nav-step" data-change-step="previous"${i?``:` disabled`}>\u2191 Previous</button>
|
|
95
95
|
<span class="prb-code-nav-count" aria-live="polite">${s}</span>
|
|
96
96
|
<button type="button" class="prb-code-nav-step" data-change-step="next"${a?``:` disabled`}>Next \u2193</button>
|
|
97
|
-
</span>`}function
|
|
98
|
-
`),r);if(a()){o&&t.lines.forEach((e,n)=>{
|
|
99
|
-
`),r);if(!a())return;if(!t)continue;let o=i.querySelector(`tr[data-before-line="${e.beforeLine}"]`)?.nextElementSibling;for(let[n,r]of e.lines.entries()){if(!o?.classList.contains(`prb-code-deleted`))break;
|
|
97
|
+
</span>`}function Hn(e,t){let n=(e.dataset.changeKeys??``).split(`,`).filter(Boolean).map(Number),r=Number(e.dataset.changePosition)||0,i=t===`next`?n.find(e=>e>r):[...n].reverse().find(e=>e<r);return i===void 0?null:{key:i,anchor:Bn(i)}}function Un(e,t){return e.querySelector(t.deletion?`tr[data-before-line="${t.line}"]`:`tr[data-line="${t.line}"]`)}function Wn(e){return(e.dataset.changeKeys??``).split(`,`).filter(Boolean).map(Number).map(Bn)}function Gn(e){if(!e)return;let t=Number(e.dataset.changePosition)||0;return(e.dataset.changeKeys??``).split(`,`).filter(Boolean).map(Number).includes(t)?Bn(t):void 0}function Kn(e,t){return Math.max(e,+!t)+1}var qn=8;function Jn(e){for(let t=e.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t}return null}function Yn(e){let t=e.panel-e.scroller;return Math.max(340,Math.floor(e.pane-t-16))}function Xn(e){let t=e.getBoundingClientRect().top;for(let n of e.querySelectorAll(`tr`)){let e=n.getBoundingClientRect();if(e.bottom>t)return{row:n,offset:e.top-t}}return null}function Zn(e,t){let n=t.row.getBoundingClientRect().top-e.getBoundingClientRect().top-t.offset;e.scrollTop+=n}function Qn(e){if(!e.hasAttribute(`data-expanded`))return;let t=Jn(e),n=e.querySelector(`.prb-code-scroll`);if(!t||!n)return;let r=Yn({pane:t.clientHeight,panel:e.offsetHeight,scroller:n.offsetHeight});e.style.setProperty(`--prb-code-expanded`,`${r}px`)}function $n(e){let t=e.querySelector(`[data-code-expand]`),n=e.querySelector(`.prb-code-scroll`);if(!t||!n)return;let r=e.hasAttribute(`data-expanded`);t.hidden=!r&&n.scrollHeight<=n.clientHeight,t.textContent=r?`Collapse`:`Expand`,t.setAttribute(`aria-expanded`,String(r))}var er=!1;function tr(){er||(er=!0,window.addEventListener(`resize`,()=>{for(let e of document.querySelectorAll(`.prb-code[data-expanded]`))Qn(e)}))}function nr(e,t){let n=e.querySelector(`.prb-code-scroll`),r=n?Xn(n):null;t?(e.setAttribute(`data-expanded`,``),Qn(e),tr()):(e.removeAttribute(`data-expanded`),e.style.removeProperty(`--prb-code-expanded`)),$n(e),n&&r&&Zn(n,r);let i=t?Jn(e):null;i&&(i.scrollTop+=e.getBoundingClientRect().top-i.getBoundingClientRect().top-qn)}var rr={rb:`ruby`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,ts:`typescript`,mts:`typescript`,cts:`typescript`,jsx:`jsx`,tsx:`tsx`,json:`json`,yml:`yaml`,yaml:`yaml`,md:`markdown`,html:`html`,css:`css`,scss:`scss`,sql:`sql`,py:`python`,java:`java`,kt:`kotlin`,kts:`kotlin`,go:`go`,rs:`rust`,sh:`shellscript`,bash:`shellscript`,zsh:`shellscript`,tf:`terraform`,tfvars:`terraform`};function ir(e){let t=e.slice(e.lastIndexOf(`/`)+1);if(t===`Dockerfile`||t.startsWith(`Dockerfile.`))return`docker`;let n=t.lastIndexOf(`.`);return n<=0?null:rr[t.slice(n+1).toLowerCase()]??null}function ar(e){let t=new Set;for(let n of e){let e=ir(n);e&&t.add(e)}return[...t]}var or={ruby:()=>S(()=>import(`./chunk-CAnKkQXq.js`),__vite__mapDeps([19,20,21,22,23,24,25,26,27,28,29])),javascript:()=>S(()=>import(`./chunk-D2pwppYQ.js`),__vite__mapDeps([30,21])),typescript:()=>S(()=>import(`./chunk-Cjc271yU.js`),__vite__mapDeps([31,26])),jsx:()=>S(()=>import(`./chunk-B2PgDgse.js`),__vite__mapDeps([32,24])),tsx:()=>S(()=>import(`./chunk-D95j_xjm.js`),__vite__mapDeps([33,27])),json:()=>S(()=>import(`./chunk-qhed-kSA.js`),[]),yaml:()=>S(()=>import(`./chunk-Cv3JjNkX.js`),__vite__mapDeps([34,29])),markdown:()=>S(()=>import(`./chunk-BYOwaDjH.js`),[]),html:()=>S(()=>import(`./chunk-EIJEcyW-.js`),__vite__mapDeps([35,22,20,21])),css:()=>S(()=>import(`./chunk-C3nvJp0N.js`),__vite__mapDeps([36,20])),scss:()=>S(()=>import(`./chunk-D2NZorQR.js`),__vite__mapDeps([37,20])),sql:()=>S(()=>import(`./chunk-NzFayA7r.js`),__vite__mapDeps([38,25])),python:()=>S(()=>import(`./chunk-gzcpVVnB.js`),[]),java:()=>S(()=>import(`./chunk-AdYjtsZU.js`),__vite__mapDeps([39,23])),kotlin:()=>S(()=>import(`./chunk-DhhofPvG.js`),[]),go:()=>S(()=>import(`./chunk-rLFTqkRN.js`),[]),rust:()=>S(()=>import(`./chunk-Cfkwpbl8.js`),[]),shellscript:()=>S(()=>import(`./chunk-pNSm1SyV.js`),__vite__mapDeps([40,28])),docker:()=>S(()=>import(`./chunk-IyjqRm3v.js`),[]),terraform:()=>S(()=>import(`./chunk-DswuEJGm.js`),[])},sr=`github-light-default`,cr=null,lr=new Map;function ur(){return cr??=Promise.all([S(()=>import(`./chunk-c-cg1wCO.js`),__vite__mapDeps([41,3])),S(()=>import(`./chunk-CBrdyqSx.js`),__vite__mapDeps([42,3])),S(()=>import(`./chunk-BXViO-2h.js`),[])]).then(([{createHighlighterCore:e},{createOnigurumaEngine:t},n])=>e({themes:[n.default],langs:[],engine:t(S(()=>import(`./chunk-BnjxR4X6.js`),[]))})).catch(()=>null),cr}function dr(e){let t=lr.get(e);return t||(t=ur().then(async t=>t?(await t.loadLanguage(or[e]),!0):!1).catch(()=>!1),lr.set(e,t)),t.then(e=>e?ur():null)}var fr={async preload(e){await dr(e)},async tokenize(e,t){let n=await dr(t);if(!n)return null;try{let{tokens:r,fg:i}=n.codeToTokens(e,{lang:t,theme:sr}),a=i?.toLowerCase();return r.map(e=>e.map(e=>({content:e.content,...e.color&&e.color.toLowerCase()!==a?{color:e.color}:{}})))}catch{return null}}};function pr(e,t=fr){return Promise.all(e.map(e=>t.preload(e))).then(()=>void 0)}var mr=/^#[0-9a-f]{3,8}$/i;function hr(e,t){return!t||t.map(e=>e.content).join(``)!==e?null:t.map(e=>e.color&&mr.test(e.color)?`<span style="color:${e.color}">${An(e.content)}</span>`:An(e.content)).join(``)}function gr(e){return e.length>1e3?e.slice(0,jn):e}function _r(e,t,n){if(!e||t===``)return;let r=hr(gr(t),n);if(r===null)return;if(t.length<=1e3){if(e.childElementCount!==0||e.textContent!==t)return;e.innerHTML=r;return}let i=e.querySelector(`[data-full-line]`);i&&(e.innerHTML=`${r}… `,e.append(i))}async function vr(e,t,n=fr){let r=ir(t.path);if(!r){delete e.dataset.syntax;return}e.dataset.syntax=r;let i=e.querySelector(`tbody`);if(!i)return;let a=()=>i.isConnected&&e.querySelector(`tbody`)===i,o=await n.tokenize(t.lines.map(gr).join(`
|
|
98
|
+
`),r);if(a()){o&&t.lines.forEach((e,n)=>{_r(i.querySelector(`tr[data-line="${t.from+n}"] .prb-code-line`),e,o[n])});for(let e of t.deletions??[]){if(!i.querySelector(`tr[data-before-line="${e.beforeLine}"]`))continue;let t=await n.tokenize(e.lines.map(e=>gr(e.text)).join(`
|
|
99
|
+
`),r);if(!a())return;if(!t)continue;let o=i.querySelector(`tr[data-before-line="${e.beforeLine}"]`)?.nextElementSibling;for(let[n,r]of e.lines.entries()){if(!o?.classList.contains(`prb-code-deleted`))break;_r(o.querySelector(`.prb-code-line`),r.text,t[n]),o=o.nextElementSibling}}}}async function yr(e,t=fr){let n=e.closest(`.prb-code`)?.dataset.syntax,r=e.textContent??``;if(!n||!(n in or)||r===``)return;let i=await t.tokenize(r,n);if(!e.isConnected||e.childElementCount!==0||e.textContent!==r)return;let a=hr(r,i?.[0]);a!==null&&i?.length===1&&(e.innerHTML=a)}var T=document.body,br=T.dataset.apiBase??``,xr=T.dataset.token??``,Sr=T.dataset.editorLabel??``,Cr=T.dataset.editorTemplate??``,wr=T.dataset.repoPath??``,Tr=T.dataset.explainPrompt??``,Er=T.dataset.sessionId??``;function E(e){return`${br}${e}?t=${encodeURIComponent(xr)}`}function D(e){fetch(E(`/event`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})}var Dr=un({endpoint:E,showDiagrams:()=>Mr(`diagram`)}),Or=null,kr=`whole change`;function Ar(e){let t=_t(e);window.location.hash!==t&&history.pushState(e,``,t),jr(e)}function jr(e){e.kind===`view`?Pr(e.view):Rr(e.sectionId)}function Mr(e){Ar({kind:`view`,view:e})}function Nr(e){Ar({kind:`section`,sectionId:e})}function Pr(e){for(let t of document.querySelectorAll(`.prb-view`))t.hidden=t.dataset.view!==e;for(let t of document.querySelectorAll(`[data-view-nav]`))t.setAttribute(`aria-current`,String(t.dataset.viewNav===e));D({event:`view_opened`,view:e}),e===`diagram`&&Dr.drawPane(),Fr(),document.querySelector(`.prb-doc`)?.scrollTo({top:0})}function Fr(){dt(),Or=null,kr=`whole change`,zr()}function Ir(e,t){let n=document.getElementById(e.getAttribute(`aria-controls`)??``);n&&(e.setAttribute(`aria-expanded`,String(t)),e.setAttribute(`aria-label`,`${t?`Collapse`:`Expand`} ${e.dataset.railToggle??`this section`}`),n.hidden=!t)}function Lr(){for(let e of document.querySelectorAll(`[data-rail-toggle]`)){let t=document.getElementById(e.getAttribute(`aria-controls`)??``);(t?.contains(document.getElementById(`prb-rail-path`))||t?.id===`prb-rail-path`)&&Ir(e,!0)}}function Rr(e){Pr(`guide`),Lr(),ut(e);let t=ct(e);if(!t)return;let n=document.querySelector(`[data-goto-section="${CSS.escape(e)}"]`);D({event:`theme_opened`,themeIndex:Number(n?.dataset.themeIndex??-1),attention:n?.querySelector(`.prb-attention`)?.dataset.attention??`medium`,isRecommendedStart:n?.dataset.recommendedStart===`true`}),Or=e,kr=t.querySelector(`.pr-helper-guide-section-title`)?.textContent?.trim()??`this theme`,zr()}function zr(){let e=document.querySelector(`[data-ask-scope]`);e&&(e.textContent=kr,e.title=Or?`Questions are answered about "${kr}"`:`Questions cover the whole change`)}function O(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function Br(e){return e.tagName===`LI`?{parent:e,position:`beforeend`}:{parent:e,position:`afterend`}}async function Vr(e){let t=e.tagName===`LI`?e.querySelector(`:scope > .prb-code`):e.nextElementSibling;if(t?.classList.contains(`prb-code`)){t.remove(),e.setAttribute(`aria-expanded`,`false`);return}let n=e.dataset.file;if(!n)return;let r=Number(e.dataset.line)||0,i=e.tagName!==`LI`,a=document.createElement(`div`);a.className=`prb-code`,a.innerHTML=`<p class="prb-code-status">Reading…</p>`;let{parent:o,position:s}=Br(e);o.insertAdjacentElement(s,a),e.setAttribute(`aria-expanded`,`true`),D({event:`file_opened`,fromFinding:i,targeted:r>0}),await Hr(a,n,{cited:r,centre:r,expand:0,position:r?2*r:0})}async function Hr(e,t,n){try{let{centre:r,expand:i}=n,a=`&path=${encodeURIComponent(t)}${r?`&line=${r}`:``}${i?`&expand=${i}`:``}`,o=await fetch(`${E(`/file`)}${a}`),s=await o.json();if(!o.ok){e.innerHTML=`<p class="prb-code-status">${O(s?.error??`Could not read that file.`)}</p>`;return}Ur(e,s,n)}catch{e.innerHTML=`<p class="prb-code-status">Could not reach PR Review Buddy. The workspace server may have stopped.</p>`}}function Ur(e,t,n){let{cited:r,centre:i,expand:a}=n,o=Fn(t,r),s=Cr&&wr?t.checkout===`absent`?`<button type="button" class="prb-code-open" disabled>Not in your working folder</button>`:`<button type="button" class="prb-code-open" data-open-editor="${O(t.path)}" data-open-line="${r||t.from}">${O(`Open in ${Sr||`editor`}`)}</button>`:``,c=t.pullRequest&&t.pullRequest.precise?`<a class="prb-code-open prb-code-pr" href="${O(t.pullRequest.href)}" target="_blank" rel="noopener noreferrer">${O(t.pullRequest.label)}</a>`:``,l=t.truncated?`<button type="button" class="prb-code-more" data-expand-file="${O(t.path)}" data-expand-line="${i||0}" data-expand-cited="${r||0}" data-expand-step="${Kn(a,i)}">Show more of this file</button>`:``,u=t.checkout===`differs`?` · your editor will show a different version`:t.checkout===`absent`?` · not in your working folder`:``,d=t.changes===`unavailable`?` · change details unavailable`:``,ee=`<div class="prb-code-source"><span>${t.source===`commit`?`Viewing reviewed version${t.sourceSha?` <code>${O(t.sourceSha.slice(0,7))}</code>`:``}${u}${d}`:`Viewing your working folder${d}`}</span>${Vn(t.changeAnchors??[],n.position)}</div>`,f=e.hasAttribute(`data-expanded`),p=`<button type="button" class="prb-code-open" data-code-expand aria-expanded="${f}">${f?`Collapse`:`Expand`}</button>`;e.innerHTML=`<div class="prb-code-header">
|
|
100
100
|
<span class="prb-code-range">lines ${t.from}\u2013${t.to} of ${t.totalLines}</span>
|
|
101
101
|
${c}
|
|
102
102
|
${s}
|
|
@@ -104,7 +104,7 @@ import{c as e,i as t,t as n}from"./chunk-BeL0x-wt.js";import{_ as r,d as i,g as
|
|
|
104
104
|
</div>
|
|
105
105
|
${ee}
|
|
106
106
|
<div class="prb-code-scroll"><table class="prb-code-table"><tbody>${o}</tbody></table></div>
|
|
107
|
-
${l}`,In(e,t),Zn(e),Qn(e),(n.focus?Hn(e,n.focus):e.querySelector(`.prb-code-target`))?.scrollIntoView({block:`center`}),_r(e,t)}async function Ur(e,t,n){let r=Vn(t,n);if(!r)return;let i=Hn(e,r.anchor);if(i)t.outerHTML=Bn(Un(t),r.key),i.scrollIntoView({block:`center`});else{let t=e.querySelector(`[data-expand-file]`);if(!t?.dataset.expandFile)return;await Vr(e,t.dataset.expandFile,{cited:Number(t.dataset.expandCited)||0,centre:r.anchor.line,expand:Math.max(1,(Number(t.dataset.expandStep)||1)-1),position:r.key,focus:r.anchor})}let a=e.querySelector(`[data-change-step="${n}"]`),o=e.querySelector(`[data-change-step="${n===`next`?`previous`:`next`}"]`);(a&&!a.disabled?a:o)?.focus({preventScroll:!0})}function Wr(e,t,n){let r=`${Cr.replace(/\/$/,``)}/${e}`,i=Sr.replace(`{path}`,r).replace(`{line}`,String(Math.max(1,t)));D({event:`editor_opened`,fromFinding:n}),window.location.href=i}var k=document.querySelector(`[data-ask-log]`);k&&k.querySelector(`.prb-msg`)&&k.scrollTo({top:k.scrollHeight});var A=document.querySelector(`[data-ask-form]`),j=A?.querySelector(`textarea`);function Gr(e,t){let n=document.createElement(`div`);return n.className=e===`user`?`prb-msg prb-msg-user`:`prb-msg prb-msg-${e===`error`?`error`:`assistant`}`,e===`assistant`?(n.classList.add(`prb-md`),n.innerHTML=te(t)+Ae(t)):n.textContent=t,k?.appendChild(n),k?.scrollTo({top:k.scrollHeight}),n}function Kr(){let e=document.createElement(`div`);return e.className=`prb-thinking`,e.innerHTML=`<i></i><i></i><i></i><span>Reading the change…</span>`,k?.appendChild(e),k?.scrollTo({top:k.scrollHeight}),e}var M=null,N=!!k?.querySelector(`[data-ask-pending]`);function qr(){let e=document.createElement(`div`);e.className=`prb-stopped`,e.textContent=`Stopped.`,k?.appendChild(e),k?.scrollTo({top:k.scrollHeight})}async function Jr(e,t=`free_text`){let n=e.trim();if(!n||M||N)return;document.querySelector(`.prb-ask-empty`)?.remove(),Gr(`user`,n);let r=Kr();M=new AbortController,Yr(!0);try{let e=await fetch(E(`/ask`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({question:n,sectionId:Dr,source:t}),signal:M.signal}),i=await e.json().catch(()=>null);if(e.status===409&&(i?.running||i?.updating)){window.location.reload();return}if(r.remove(),i?.stopped){qr();return}if(!e.ok||!i?.answer){Gr(`error`,i?.error??`Buddy AI did not answer. Check the terminal running PR Review Buddy.`);return}Gr(`assistant`,i.answer)}catch(e){r.remove(),e instanceof DOMException&&e.name===`AbortError`?(qr(),j&&!j.value&&(j.value=n)):Gr(`error`,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{M=null,Yr(!1)}}function Yr(e){let t=A?.querySelector(`button`);t&&(t.textContent=e?`Stop`:`Ask`,t.toggleAttribute(`data-stop`,e),t.disabled=!1),j&&(j.disabled=e);for(let t of document.querySelectorAll(Xr))t.disabled=e;e||j?.focus()}var Xr=`[data-suggestion], .pr-helper-explain-simply-button`;function Zr(){let e=A?.querySelector(`button`);e&&(e.textContent=`Stopping…`,e.disabled=!0),fetch(E(`/stop`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`ask`})}).catch(()=>{}).finally(()=>{M?.abort()})}A?.addEventListener(`submit`,e=>{if(e.preventDefault(),M||N)return Zr();let t=j?.value??``;j&&(j.value=``),Jr(t,$r(t))}),N&&Yr(!0);var Qr=null;function $r(e){return Qr&&e.includes(Qr)?`selection`:`free_text`}j?.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),A?.requestSubmit())}),j?.addEventListener(`input`,()=>{j&&(j.style.height=`auto`,j.style.height=`${Math.min(j.scrollHeight,140)}px`)});async function ei(e){try{await fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answeredQuestionIds:e})})}catch{}}function ti(){return[...document.querySelectorAll(`[data-question-answered][data-answered="true"]`)].map(e=>e.dataset.questionAnswered??``).filter(Boolean)}function ni(e,t){e.dataset.answered=String(t),e.textContent=t?`Mark as unanswered`:`Mark answered`;let n=e.closest(`[data-finding-card]`);n?.classList.toggle(`pr-helper-question-card-answered`,t),n&&ci(n,t,`questions`),mi()}function ri(){return[...document.querySelectorAll(`[data-issue-dismissed][data-dismissed="true"]`)].map(e=>({id:e.dataset.issueDismissed??``,sessionId:e.dataset.dismissedIn||Tr})).filter(e=>e.id)}async function ii(e){try{await fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissedIssues:e})})}catch{}}function ai(e,t){e.dataset.dismissed=String(t),e.textContent=t?`Reopen`:`Dismiss`,delete e.dataset.stale,t?e.dataset.dismissedIn=Tr:delete e.dataset.dismissedIn;let n=e.closest(`[data-finding-card]`);n&&(n.classList.toggle(`pr-helper-issue-card-dismissed`,t),n.querySelector(`.pr-helper-dismissal-stale`)?.remove(),n.querySelector(`.pr-helper-finding-status-dismissed`)?.remove(),t&&n.querySelector(`.pr-helper-issue-badges`)?.prepend(oi()),ci(n,t||e.dataset.settled===`true`,`issues`),gi())}function oi(){let e=document.createElement(`span`);return e.className=`pr-helper-finding-status pr-helper-finding-status-dismissed pr-helper-tip`,e.dataset.tip=rt,e.textContent=`Dismissed by you`,e}var si=new WeakMap;function ci(e,t,n){let r=e.closest(`.pr-helper-closed-findings-list`);if(t!==!!r){if(t){let t=e.parentElement;t&&si.set(e,{parent:t,before:e.nextElementSibling}),fi(n).append(e),t&&di(t)}else li(e,n),(r?.children.length===0?r.closest(`.pr-helper-closed-findings`):null)?.remove();pi(n)}}function li(e,t){let n=si.get(e);if(n?.parent.isConnected)n.parent.insertBefore(e,n.before);else{let n=ui(e)??document.querySelector(`[data-view="${t}"]`);n?.insertBefore(e,n.querySelector(`.pr-helper-closed-findings`))}e.closest(`.pr-helper-question-group`)?.removeAttribute(`hidden`)}function ui(e){let t=e.dataset.sectionId;return t?document.querySelector(`[data-question-group="${CSS.escape(t)}"]`):null}function di(e){let t=e.closest(`.pr-helper-question-group`);t&&!t.querySelector(`[data-finding-card]`)&&(t.hidden=!0)}function fi(e){let t=document.querySelector(`[data-view="${e}"]`),n=t?.querySelector(`[data-closed-findings="${e}"] .pr-helper-closed-findings-list`);if(n)return n;let r=document.createElement(`details`);r.className=`pr-helper-closed-findings`,r.dataset.closedFindings=e;let i=document.createElement(`summary`);i.className=`pr-helper-closed-findings-summary`,i.setAttribute(`data-closed-findings-summary`,``);let a=document.createElement(`div`);return a.className=`pr-helper-closed-findings-list`,r.append(i,a),t?.append(r),a}function pi(e){let t=document.querySelector(`[data-closed-findings="${e}"]`),n=t?.querySelector(`[data-closed-findings-summary]`);if(!t||!n)return;let r=document.querySelectorAll(`[data-view="${e}"] [data-finding-card]`).length,i=t.querySelectorAll(`[data-finding-card]`).length;if(t.toggleAttribute(`data-nothing-open`,r===i),e===`questions`){n.textContent=`Answered (${i})`;return}n.textContent=at(hi())}function mi(){let e=[...document.querySelectorAll(`[data-question-answered]`)];if(e.length===0)return;let t=e.filter(e=>e.dataset.answered!==`true`&&e.dataset.settled!==`true`).length,n=document.querySelector(`.pr-helper-questions-progress`);n&&(n.innerHTML=ot(e.length,t)),_i(`questions`,e.length,t,`question`,`answered`)}function hi(){let e=[...document.querySelectorAll(`[data-issue-dismissed]`)],t=0,n=0;for(let r of e){let e=r.dataset.settled===`true`,i=r.dataset.dismissed===`true`&&r.dataset.stale!==`true`;!e&&!i?t+=1:!e&&i&&(n+=1)}return{total:e.length,open:t,done:e.length-t,reviewerClosed:n}}function gi(){let e=hi();if(e.total===0)return;let t=document.querySelector(`[data-view="issues"]`),n=t?.querySelector(`.pr-helper-findings-progress`);!n&&t&&e.done>0&&(n=document.createElement(`div`),n.className=`pr-helper-findings-progress`,n.setAttribute(`role`,`status`),t.querySelector(`.prb-doc-title`)?.after(n)),n&&(n.innerHTML=it(e.total,e.open,nt(e))),_i(`issues`,e.total,e.open,`issue`,nt(e))}function _i(e,t,n,r,i){let a=document.querySelector(`[data-view-nav="${e}"] .prb-rail-count`);if(!a)return;let o=e=>`${e} ${r}${e===1?``:`s`}`,s=t-n;a.classList.toggle(`prb-rail-count-done`,t>0&&n===0),t===0?(a.textContent=`0`,a.setAttribute(`aria-label`,`No ${r}s`)):n===0?(a.textContent=`✓`,a.setAttribute(`aria-label`,`All ${o(t)} ${i}`)):(a.textContent=String(n),a.setAttribute(`aria-label`,s===0?o(t):`${n} of ${o(t)} left, ${s} ${i}`))}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-rail-toggle]`);if(n){Fr(n,n.getAttribute(`aria-expanded`)!==`true`);return}let r=t.closest(`[data-view-nav]`);if(r?.dataset.viewNav){jr(r.dataset.viewNav);return}let i=t.closest(`[data-overview-nav]`);if(i?.dataset.overviewNav){jr(i.dataset.overviewNav===`guide`?`guide`:i.dataset.overviewNav);return}let a=t.closest(`[data-goto-section]`);if(a?.dataset.gotoSection){Mr(a.dataset.gotoSection);return}let o=t.closest(`[data-open-editor]`);if(o?.dataset.openEditor){Wr(o.dataset.openEditor,Number(o.dataset.openLine)||1,!0);return}let s=t.closest(`[data-deletion-toggle]`);if(s){Fn(s);return}let c=t.closest(`[data-code-expand]`);if(c){let e=c.closest(`.prb-code`);e&&tr(e,!e.hasAttribute(`data-expanded`));return}let l=t.closest(`[data-change-step]`);if(l){let e=l.closest(`[data-change-navigator]`),t=l.closest(`.prb-code`);e&&t&&!l.disabled&&Ur(t,e,l.dataset.changeStep===`previous`?`previous`:`next`);return}let u=t.closest(`[data-full-line]`);if(u){let e=Ln(u);e&&vr(e);return}let d=t.closest(`[data-expand-file]`);if(d?.dataset.expandFile){let e=d.closest(`.prb-code`);if(e){let t=e.querySelector(`[data-change-navigator]`);Vr(e,d.dataset.expandFile,{cited:Number(d.dataset.expandCited)||0,centre:Number(d.dataset.expandLine)||0,expand:Number(d.dataset.expandStep)||1,position:Number(t?.dataset.changePosition)||0,focus:Wn(t)})}return}let ee=t.closest(`[data-file]`);if(ee?.dataset.file){Br(ee);return}let f=ct(t);if(f){Lr(f);return}let p=t.closest(`[data-question-answered]`);if(p?.dataset.questionAnswered){ni(p,p.dataset.answered!==`true`);let e=ti();ei(e),D({event:`question_marked_answered`,answered:e.length,total:document.querySelectorAll(`[data-question-answered]`).length});return}let m=t.closest(`[data-issue-dismissed]`);if(m?.dataset.issueDismissed){ai(m,m.dataset.stale===`true`||m.dataset.dismissed!==`true`);let e=ri();ii(e),D({event:`issue_dismissed`,dismissed:e.length,total:document.querySelectorAll(`[data-issue-dismissed]`).length});return}let te=t.closest(`[data-suggestion]`);if(te){Jr(te.textContent??``,`suggestion`);return}if(t.closest(`.pr-helper-explain-simply-button`)){bi(),Jr(wr,`explain_simply`);return}let ne=t.closest(`[data-prompt-use]`);if(ne?.dataset.promptUse){Bi(ne.dataset.promptUse);return}let re=t.closest(`[data-prompt-edit]`);if(re?.dataset.promptEdit){Qi(re.dataset.promptEdit);return}if(t.closest(`[data-prompt-add]`)){Qi(``);return}t.closest(`[data-ask-toggle]`)&&yi(!vi())});var P=document.querySelector(`.prb-body`),F=document.querySelector(`.prb-ask`);function vi(){return!!F&&getComputedStyle(F).display!==`none`}function yi(e){P&&(P.dataset.ask=e?`open`:`closed`),document.querySelector(`[data-ask-toggle]`)?.setAttribute(`aria-expanded`,String(e))}function bi(){yi(!0)}function xi(){document.querySelector(`[data-ask-toggle]`)?.setAttribute(`aria-expanded`,String(vi()))}window.addEventListener(`resize`,xi),n(E(`/restart`));var I=document.querySelector(`[data-file-filter]`),Si=document.querySelector(`[data-file-count]`),Ci=document.querySelector(`[data-file-none]`);function wi(){let e=(I?.value??``).trim().toLowerCase(),t=0,n=0;for(let r of document.querySelectorAll(`[data-view="files"] .prb-file`)){let i=e===``||(r.dataset.search??``).includes(e);r.hidden=!i,i&&(n+=1,r.classList.contains(`prb-file-referenced`)||(t+=1));let a=r.nextElementSibling;a?.classList.contains(`prb-code`)&&(a.hidden=!i)}for(let t of document.querySelectorAll(`[data-file-group]`)){let n=t.querySelectorAll(`.prb-file:not([hidden])`).length;t.hidden=n===0;let r=t.querySelector(`[data-group-heading]`);if(!r)continue;let i=Number(r.dataset.groupTotal)||0;r.textContent=e&&n!==i?`${r.dataset.groupHeading} · ${n} of ${i}`:`${r.dataset.groupHeading} · ${i}`}Ci&&(Ci.hidden=n>0),Si&&(Si.textContent=e?`${t} of ${Ti} file${Ti===1?``:`s`}`:`${Ti} file${Ti===1?``:`s`}`)}var Ti=document.querySelectorAll(`[data-view="files"] .prb-file:not(.prb-file-referenced)`).length;I?.addEventListener(`input`,wi),I?.addEventListener(`keydown`,e=>{e.key===`Escape`&&I.value!==``&&(e.preventDefault(),I.value=``,wi())}),document.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target,n=t.closest(`.prb-file[data-file][role="button"]`);!n||n!==t||(e.preventDefault(),Br(n))});var Ei=320,Di=()=>Math.round(window.innerWidth/2),Oi=e=>Math.round(Math.min(Di(),Math.max(Ei,e)));function L(e){P&&(e===null?P.style.removeProperty(`--ask-width`):P.style.setProperty(`--ask-width`,`${e}px`))}function ki(){return F?Math.round(F.getBoundingClientRect().width):Ei}function Ai(e){fetch(E(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({askWidth:e})}).catch(()=>{})}var R=document.querySelector(`[data-ask-resize]`);R?.addEventListener(`pointerdown`,e=>{if(e.button!==0||!P||!F)return;e.preventDefault(),R.setPointerCapture(e.pointerId),P.dataset.resizing=`true`;let t=e.clientX,n=ki(),r=e=>{L(Oi(n+(t-e.clientX)))},i=()=>{R.removeEventListener(`pointermove`,r),R.removeEventListener(`pointerup`,i),R.removeEventListener(`pointercancel`,i),delete P.dataset.resizing,Ai(ki())};R.addEventListener(`pointermove`,r),R.addEventListener(`pointerup`,i),R.addEventListener(`pointercancel`,i)}),R?.addEventListener(`keydown`,e=>{let t=e.shiftKey?64:16;if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let n=e.key===`ArrowLeft`?t:-t,r=Oi(ki()+n);L(r),Ai(r);return}(e.key===`Home`||e.key===`Escape`)&&(e.preventDefault(),L(null),Ai(null))}),R?.addEventListener(`dblclick`,()=>{L(null),Ai(null)}),window.addEventListener(`resize`,()=>{vi()&&P?.style.getPropertyValue(`--ask-width`)&&L(Oi(ki()))});var ji=3e4,z=document.visibilityState===`visible`?Date.now():null,Mi=0;function Ni(){z!==null&&(Mi+=Date.now()-z,z=Date.now())}function Pi(){Ni();let e=Math.round(Mi/1e3);return Mi-=e*1e3,e}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`?z=Date.now():(Ni(),z=null)}),setInterval(()=>{let e=Pi();e>0&&D({event:`workspace_heartbeat`,visibleSeconds:e})},ji),window.addEventListener(`pagehide`,()=>{let e=E(`/event`),t=JSON.stringify({event:`review_completed`,trailingSeconds:Pi()});navigator.sendBeacon?.(e,new Blob([t],{type:`application/json`}))||fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:t,keepalive:!0}).catch(()=>{})});var Fi=document.querySelector(`[data-prompt-bank]`),Ii=document.querySelector(`[data-prompt-list]`),B=Li();function Li(){try{let e=JSON.parse(Fi?.dataset.prompts??`[]`);return Array.isArray(e)?e:[]}catch{return[]}}function Ri(){Ii&&(Ii.innerHTML=B.map(e=>`<span class="prb-bank-item">
|
|
107
|
+
${l}`,Ln(e,t),Qn(e),$n(e),(n.focus?Un(e,n.focus):e.querySelector(`.prb-code-target`))?.scrollIntoView({block:`center`}),vr(e,t)}async function Wr(e,t,n){let r=Hn(t,n);if(!r)return;let i=Un(e,r.anchor);if(i)t.outerHTML=Vn(Wn(t),r.key),i.scrollIntoView({block:`center`});else{let t=e.querySelector(`[data-expand-file]`);if(!t?.dataset.expandFile)return;await Hr(e,t.dataset.expandFile,{cited:Number(t.dataset.expandCited)||0,centre:r.anchor.line,expand:Math.max(1,(Number(t.dataset.expandStep)||1)-1),position:r.key,focus:r.anchor})}let a=e.querySelector(`[data-change-step="${n}"]`),o=e.querySelector(`[data-change-step="${n===`next`?`previous`:`next`}"]`);(a&&!a.disabled?a:o)?.focus({preventScroll:!0})}function Gr(e,t,n){let r=`${wr.replace(/\/$/,``)}/${e}`,i=Cr.replace(`{path}`,r).replace(`{line}`,String(Math.max(1,t)));D({event:`editor_opened`,fromFinding:n}),window.location.href=i}var k=document.querySelector(`[data-ask-log]`);k&&k.querySelector(`.prb-msg`)&&k.scrollTo({top:k.scrollHeight});var A=document.querySelector(`[data-ask-form]`),j=A?.querySelector(`textarea`);function Kr(e,t){let n=document.createElement(`div`);return n.className=e===`user`?`prb-msg prb-msg-user`:`prb-msg prb-msg-${e===`error`?`error`:`assistant`}`,e===`assistant`?(n.classList.add(`prb-md`),n.innerHTML=te(t)+je(t)):n.textContent=t,k?.appendChild(n),k?.scrollTo({top:k.scrollHeight}),n}function qr(){let e=document.createElement(`div`);return e.className=`prb-thinking`,e.innerHTML=`<i></i><i></i><i></i><span>Reading the change…</span>`,k?.appendChild(e),k?.scrollTo({top:k.scrollHeight}),e}var M=null,N=!!k?.querySelector(`[data-ask-pending]`);function Jr(){let e=document.createElement(`div`);e.className=`prb-stopped`,e.textContent=`Stopped.`,k?.appendChild(e),k?.scrollTo({top:k.scrollHeight})}async function Yr(e,t=`free_text`){let n=e.trim();if(!n||M||N)return;document.querySelector(`.prb-ask-empty`)?.remove(),Kr(`user`,n);let r=qr();M=new AbortController,Xr(!0);try{let e=await fetch(E(`/ask`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({question:n,sectionId:Or,source:t}),signal:M.signal}),i=await e.json().catch(()=>null);if(e.status===409&&(i?.running||i?.updating)){window.location.reload();return}if(r.remove(),i?.stopped){Jr();return}if(!e.ok||!i?.answer){Kr(`error`,i?.error??`Buddy AI did not answer. Check the terminal running PR Review Buddy.`);return}Kr(`assistant`,i.answer)}catch(e){r.remove(),e instanceof DOMException&&e.name===`AbortError`?(Jr(),j&&!j.value&&(j.value=n)):Kr(`error`,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{M=null,Xr(!1)}}function Xr(e){let t=A?.querySelector(`button`);t&&(t.textContent=e?`Stop`:`Ask`,t.toggleAttribute(`data-stop`,e),t.disabled=!1),j&&(j.disabled=e);for(let t of document.querySelectorAll(Zr))t.disabled=e;e||j?.focus()}var Zr=`[data-suggestion], .pr-helper-explain-simply-button`;function Qr(){let e=A?.querySelector(`button`);e&&(e.textContent=`Stopping…`,e.disabled=!0),fetch(E(`/stop`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`ask`})}).catch(()=>{}).finally(()=>{M?.abort()})}A?.addEventListener(`submit`,e=>{if(e.preventDefault(),M||N)return Qr();let t=j?.value??``;j&&(j.value=``),Yr(t,ei(t))}),N&&Xr(!0);var $r=null;function ei(e){return $r&&e.includes($r)?`selection`:`free_text`}j?.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),A?.requestSubmit())}),j?.addEventListener(`input`,()=>{j&&(j.style.height=`auto`,j.style.height=`${Math.min(j.scrollHeight,140)}px`)});async function ti(e){try{await fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answeredQuestionIds:e})})}catch{}}function ni(){return[...document.querySelectorAll(`[data-question-answered][data-answered="true"]`)].map(e=>e.dataset.questionAnswered??``).filter(Boolean)}function ri(e,t){e.dataset.answered=String(t),e.textContent=t?`Mark as unanswered`:`Mark answered`;let n=e.closest(`[data-finding-card]`);n?.classList.toggle(`pr-helper-question-card-answered`,t),n&&li(n,t,`questions`),hi()}function ii(){return[...document.querySelectorAll(`[data-issue-dismissed][data-dismissed="true"]`)].map(e=>({id:e.dataset.issueDismissed??``,sessionId:e.dataset.dismissedIn||Er})).filter(e=>e.id)}async function ai(e){try{await fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissedIssues:e})})}catch{}}function oi(e,t){e.dataset.dismissed=String(t),e.textContent=t?`Reopen`:`Dismiss`,delete e.dataset.stale,t?e.dataset.dismissedIn=Er:delete e.dataset.dismissedIn;let n=e.closest(`[data-finding-card]`);n&&(n.classList.toggle(`pr-helper-issue-card-dismissed`,t),n.querySelector(`.pr-helper-dismissal-stale`)?.remove(),n.querySelector(`.pr-helper-finding-status-dismissed`)?.remove(),t&&n.querySelector(`.pr-helper-issue-badges`)?.prepend(si()),li(n,t||e.dataset.settled===`true`,`issues`),_i())}function si(){let e=document.createElement(`span`);return e.className=`pr-helper-finding-status pr-helper-finding-status-dismissed pr-helper-tip`,e.dataset.tip=it,e.textContent=`Dismissed by you`,e}var ci=new WeakMap;function li(e,t,n){let r=e.closest(`.pr-helper-closed-findings-list`);if(t!==!!r){if(t){let t=e.parentElement;t&&ci.set(e,{parent:t,before:e.nextElementSibling}),pi(n).append(e),t&&fi(t)}else ui(e,n),(r?.children.length===0?r.closest(`.pr-helper-closed-findings`):null)?.remove();mi(n)}}function ui(e,t){let n=ci.get(e);if(n?.parent.isConnected)n.parent.insertBefore(e,n.before);else{let n=di(e)??document.querySelector(`[data-view="${t}"]`);n?.insertBefore(e,n.querySelector(`.pr-helper-closed-findings`))}e.closest(`.pr-helper-question-group`)?.removeAttribute(`hidden`)}function di(e){let t=e.dataset.sectionId;return t?document.querySelector(`[data-question-group="${CSS.escape(t)}"]`):null}function fi(e){let t=e.closest(`.pr-helper-question-group`);t&&!t.querySelector(`[data-finding-card]`)&&(t.hidden=!0)}function pi(e){let t=document.querySelector(`[data-view="${e}"]`),n=t?.querySelector(`[data-closed-findings="${e}"] .pr-helper-closed-findings-list`);if(n)return n;let r=document.createElement(`details`);r.className=`pr-helper-closed-findings`,r.dataset.closedFindings=e;let i=document.createElement(`summary`);i.className=`pr-helper-closed-findings-summary`,i.setAttribute(`data-closed-findings-summary`,``);let a=document.createElement(`div`);return a.className=`pr-helper-closed-findings-list`,r.append(i,a),t?.append(r),a}function mi(e){let t=document.querySelector(`[data-closed-findings="${e}"]`),n=t?.querySelector(`[data-closed-findings-summary]`);if(!t||!n)return;let r=document.querySelectorAll(`[data-view="${e}"] [data-finding-card]`).length,i=t.querySelectorAll(`[data-finding-card]`).length;if(t.toggleAttribute(`data-nothing-open`,r===i),e===`questions`){n.textContent=`Answered (${i})`;return}n.textContent=ot(gi())}function hi(){let e=[...document.querySelectorAll(`[data-question-answered]`)];if(e.length===0)return;let t=e.filter(e=>e.dataset.answered!==`true`&&e.dataset.settled!==`true`).length,n=document.querySelector(`.pr-helper-questions-progress`);n&&(n.innerHTML=st(e.length,t)),vi(`questions`,e.length,t,`question`,`answered`)}function gi(){let e=[...document.querySelectorAll(`[data-issue-dismissed]`)],t=0,n=0;for(let r of e){let e=r.dataset.settled===`true`,i=r.dataset.dismissed===`true`&&r.dataset.stale!==`true`;!e&&!i?t+=1:!e&&i&&(n+=1)}return{total:e.length,open:t,done:e.length-t,reviewerClosed:n}}function _i(){let e=gi();if(e.total===0)return;let t=document.querySelector(`[data-view="issues"]`),n=t?.querySelector(`.pr-helper-findings-progress`);!n&&t&&e.done>0&&(n=document.createElement(`div`),n.className=`pr-helper-findings-progress`,n.setAttribute(`role`,`status`),t.querySelector(`.prb-doc-title`)?.after(n)),n&&(n.innerHTML=at(e.total,e.open,rt(e))),vi(`issues`,e.total,e.open,`issue`,rt(e))}function vi(e,t,n,r,i){let a=document.querySelector(`[data-view-nav="${e}"] .prb-rail-count`);if(!a)return;let o=e=>`${e} ${r}${e===1?``:`s`}`,s=t-n;a.classList.toggle(`prb-rail-count-done`,t>0&&n===0),t===0?(a.textContent=`0`,a.setAttribute(`aria-label`,`No ${r}s`)):n===0?(a.textContent=`✓`,a.setAttribute(`aria-label`,`All ${o(t)} ${i}`)):(a.textContent=String(n),a.setAttribute(`aria-label`,s===0?o(t):`${n} of ${o(t)} left, ${s} ${i}`))}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-rail-toggle]`);if(n){Ir(n,n.getAttribute(`aria-expanded`)!==`true`);return}let r=t.closest(`[data-view-nav]`);if(r?.dataset.viewNav){Mr(r.dataset.viewNav);return}let i=t.closest(`[data-overview-nav]`);if(i?.dataset.overviewNav){Mr(i.dataset.overviewNav===`guide`?`guide`:i.dataset.overviewNav);return}let a=t.closest(`[data-goto-section]`);if(a?.dataset.gotoSection){Nr(a.dataset.gotoSection);return}let o=t.closest(`[data-open-editor]`);if(o?.dataset.openEditor){Gr(o.dataset.openEditor,Number(o.dataset.openLine)||1,!0);return}let s=t.closest(`[data-deletion-toggle]`);if(s){In(s);return}let c=t.closest(`[data-code-expand]`);if(c){let e=c.closest(`.prb-code`);e&&nr(e,!e.hasAttribute(`data-expanded`));return}let l=t.closest(`[data-change-step]`);if(l){let e=l.closest(`[data-change-navigator]`),t=l.closest(`.prb-code`);e&&t&&!l.disabled&&Wr(t,e,l.dataset.changeStep===`previous`?`previous`:`next`);return}let u=t.closest(`[data-full-line]`);if(u){let e=Rn(u);e&&yr(e);return}let d=t.closest(`[data-expand-file]`);if(d?.dataset.expandFile){let e=d.closest(`.prb-code`);if(e){let t=e.querySelector(`[data-change-navigator]`);Hr(e,d.dataset.expandFile,{cited:Number(d.dataset.expandCited)||0,centre:Number(d.dataset.expandLine)||0,expand:Number(d.dataset.expandStep)||1,position:Number(t?.dataset.changePosition)||0,focus:Gn(t)})}return}let ee=t.closest(`[data-file]`);if(ee?.dataset.file){Vr(ee);return}let f=lt(t);if(f){Rr(f);return}let p=t.closest(`[data-question-answered]`);if(p?.dataset.questionAnswered){ri(p,p.dataset.answered!==`true`);let e=ni();ti(e),D({event:`question_marked_answered`,answered:e.length,total:document.querySelectorAll(`[data-question-answered]`).length});return}let m=t.closest(`[data-issue-dismissed]`);if(m?.dataset.issueDismissed){oi(m,m.dataset.stale===`true`||m.dataset.dismissed!==`true`);let e=ii();ai(e),D({event:`issue_dismissed`,dismissed:e.length,total:document.querySelectorAll(`[data-issue-dismissed]`).length});return}let te=t.closest(`[data-suggestion]`);if(te){Yr(te.textContent??``,`suggestion`);return}if(t.closest(`.pr-helper-explain-simply-button`)){xi(),Yr(Tr,`explain_simply`);return}let ne=t.closest(`[data-prompt-use]`);if(ne?.dataset.promptUse){Vi(ne.dataset.promptUse);return}let re=t.closest(`[data-prompt-edit]`);if(re?.dataset.promptEdit){$i(re.dataset.promptEdit);return}if(t.closest(`[data-prompt-add]`)){$i(``);return}t.closest(`[data-ask-toggle]`)&&bi(!yi())});var P=document.querySelector(`.prb-body`),F=document.querySelector(`.prb-ask`);function yi(){return!!F&&getComputedStyle(F).display!==`none`}function bi(e){P&&(P.dataset.ask=e?`open`:`closed`),document.querySelector(`[data-ask-toggle]`)?.setAttribute(`aria-expanded`,String(e))}function xi(){bi(!0)}function Si(){document.querySelector(`[data-ask-toggle]`)?.setAttribute(`aria-expanded`,String(yi()))}window.addEventListener(`resize`,Si),n(E(`/restart`));var I=document.querySelector(`[data-file-filter]`),Ci=document.querySelector(`[data-file-count]`),wi=document.querySelector(`[data-file-none]`);function Ti(){let e=(I?.value??``).trim().toLowerCase(),t=0,n=0;for(let r of document.querySelectorAll(`[data-view="files"] .prb-file`)){let i=e===``||(r.dataset.search??``).includes(e);r.hidden=!i,i&&(n+=1,r.classList.contains(`prb-file-referenced`)||(t+=1));let a=r.nextElementSibling;a?.classList.contains(`prb-code`)&&(a.hidden=!i)}for(let t of document.querySelectorAll(`[data-file-group]`)){let n=t.querySelectorAll(`.prb-file:not([hidden])`).length;t.hidden=n===0;let r=t.querySelector(`[data-group-heading]`);if(!r)continue;let i=Number(r.dataset.groupTotal)||0;r.textContent=e&&n!==i?`${r.dataset.groupHeading} · ${n} of ${i}`:`${r.dataset.groupHeading} · ${i}`}wi&&(wi.hidden=n>0),Ci&&(Ci.textContent=e?`${t} of ${Ei} file${Ei===1?``:`s`}`:`${Ei} file${Ei===1?``:`s`}`)}var Ei=document.querySelectorAll(`[data-view="files"] .prb-file:not(.prb-file-referenced)`).length;I?.addEventListener(`input`,Ti),I?.addEventListener(`keydown`,e=>{e.key===`Escape`&&I.value!==``&&(e.preventDefault(),I.value=``,Ti())}),document.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target,n=t.closest(`.prb-file[data-file][role="button"]`);!n||n!==t||(e.preventDefault(),Vr(n))});var Di=320,Oi=()=>Math.round(window.innerWidth/2),ki=e=>Math.round(Math.min(Oi(),Math.max(Di,e)));function L(e){P&&(e===null?P.style.removeProperty(`--ask-width`):P.style.setProperty(`--ask-width`,`${e}px`))}function Ai(){return F?Math.round(F.getBoundingClientRect().width):Di}function ji(e){fetch(E(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({askWidth:e})}).catch(()=>{})}var R=document.querySelector(`[data-ask-resize]`);R?.addEventListener(`pointerdown`,e=>{if(e.button!==0||!P||!F)return;e.preventDefault(),R.setPointerCapture(e.pointerId),P.dataset.resizing=`true`;let t=e.clientX,n=Ai(),r=e=>{L(ki(n+(t-e.clientX)))},i=()=>{R.removeEventListener(`pointermove`,r),R.removeEventListener(`pointerup`,i),R.removeEventListener(`pointercancel`,i),delete P.dataset.resizing,ji(Ai())};R.addEventListener(`pointermove`,r),R.addEventListener(`pointerup`,i),R.addEventListener(`pointercancel`,i)}),R?.addEventListener(`keydown`,e=>{let t=e.shiftKey?64:16;if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let n=e.key===`ArrowLeft`?t:-t,r=ki(Ai()+n);L(r),ji(r);return}(e.key===`Home`||e.key===`Escape`)&&(e.preventDefault(),L(null),ji(null))}),R?.addEventListener(`dblclick`,()=>{L(null),ji(null)}),window.addEventListener(`resize`,()=>{yi()&&P?.style.getPropertyValue(`--ask-width`)&&L(ki(Ai()))});var Mi=3e4,z=document.visibilityState===`visible`?Date.now():null,Ni=0;function Pi(){z!==null&&(Ni+=Date.now()-z,z=Date.now())}function Fi(){Pi();let e=Math.round(Ni/1e3);return Ni-=e*1e3,e}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`?z=Date.now():(Pi(),z=null)}),setInterval(()=>{let e=Fi();e>0&&D({event:`workspace_heartbeat`,visibleSeconds:e})},Mi),window.addEventListener(`pagehide`,()=>{let e=E(`/event`),t=JSON.stringify({event:`review_completed`,trailingSeconds:Fi()});navigator.sendBeacon?.(e,new Blob([t],{type:`application/json`}))||fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:t,keepalive:!0}).catch(()=>{})});var Ii=document.querySelector(`[data-prompt-bank]`),Li=document.querySelector(`[data-prompt-list]`),B=Ri();function Ri(){try{let e=JSON.parse(Ii?.dataset.prompts??`[]`);return Array.isArray(e)?e:[]}catch{return[]}}function zi(){Li&&(Li.innerHTML=B.map(e=>`<span class="prb-bank-item">
|
|
108
108
|
<button type="button" class="prb-bank-use" data-prompt-use="${O(e.id)}" title="${O(e.prompt)}">${O(e.name)}</button>
|
|
109
109
|
<button type="button" class="prb-bank-edit" data-prompt-edit="${O(e.id)}" aria-label="Edit ${O(e.name)}">✎</button>
|
|
110
|
-
</span>`).join(``),Gi())}async function zi(e){try{let t=await(await fetch(E(`/prompts`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({prompts:e})})).json().catch(()=>null);B=Array.isArray(t?.prompts)?t.prompts:B}catch{}Ri()}function Bi(e){let t=B.find(t=>t.id===e);!t||!j||(j.value=dt(j.value,t.prompt),bi(),j.focus(),j.setSelectionRange(j.value.length,j.value.length),j.dispatchEvent(new Event(`input`)))}var Vi=document.querySelector(`.prb-doc`),Hi=null,Ui=null;function Wi(){k&&(Ui?.(),Ui=Ce(k,{layout:`flat`,actions:Je.map(e=>({id:e.id,label:e.label})),onChoose:(e,t)=>Ki(e,t)}))}function Gi(){Vi&&(Hi?.(),Hi=Ce(Vi,{triggerLabel:`Ask Buddy AI`,actions:[...qe.map(e=>({id:e.id,label:e.label})),...B.map(e=>({id:et(e.id),label:e.name,section:$e}))],onChoose:(e,t)=>Ki(e,t)}))}function Ki(e,t){let n=qi(e,t);!n||!j||(Qr=n,j.value=dt(j.value,n),bi(),j.focus(),j.setSelectionRange(j.value.length,j.value.length),j.dispatchEvent(new Event(`input`)))}function qi(e,t){let n=tt(e);if(n===null)return Ze(t,e);let r=B.find(e=>e.id===n);if(!r)return null;let i=Xe(t);return i?`${i}\n\n${r.prompt}`:null}Gi(),Wi(),Be(document);var Ji=document.querySelector(`[data-prompt-dialog]`),V=document.querySelector(`[data-prompt-name]`),Yi=document.querySelector(`[data-prompt-text]`),Xi=document.querySelector(`[data-prompt-delete]`),Zi=document.getElementById(`prb-prompt-title`),H=``;function Qi(e){let t=B.find(t=>t.id===e);H=t?.id??``,Zi&&(Zi.textContent=t?`Edit prompt`:`Save a prompt`),V&&(V.value=t?.name??``),Yi&&(Yi.value=t?.prompt??``),Xi&&(Xi.hidden=!t),Ji?.showModal(),V?.focus()}async function $i(){let e=V?.value.trim()??``,t=Yi?.value.trim()??``;if(!e||!t){(e?Yi:V)?.focus();return}let n=H?B.map(n=>n.id===H?{...n,name:e,prompt:t}:n):[...B,{id:crypto.randomUUID(),name:e,prompt:t}];Ji?.close(),await zi(n)}async function ea(){if(!H)return;let e=B.filter(e=>e.id!==H);Ji?.close(),await zi(e)}document.querySelector(`[data-prompt-cancel]`)?.addEventListener(`click`,()=>Ji?.close()),Xi?.addEventListener(`click`,()=>void ea()),document.querySelector(`[data-prompt-save]`)?.addEventListener(`click`,()=>void $i());var U=document.querySelector(`[data-complete]`);U?.addEventListener(`click`,()=>{let e=U.getAttribute(`aria-pressed`)!==`true`;ta(e),fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({complete:e})}).then(async e=>{let t=await e.json().catch(()=>null);t&&ta(t.completedAt!==null)}).catch(()=>ta(!e))});function ta(e){U&&(U.setAttribute(`aria-pressed`,String(e)),U.textContent=e?`Reviewed`:`Mark reviewed`)}var W=document.querySelector(`[data-fresh-region]`),G=document.querySelector(`[data-fresh-status]`),K=document.querySelector(`[data-fresh-check]`),q=la(W?.dataset.report),na=`prb-fresh-reopen`,ra=sa(),J=W?.dataset.dismissedSha,ia=oa(W?.dataset.availability),Y=aa(W?.dataset.remote);function aa(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function oa(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function sa(){try{return sessionStorage.getItem(na)!==null&&(sessionStorage.removeItem(na),!0)}catch{return!1}}ra&&Q(),K?.addEventListener(`click`,()=>void ua()),W?.addEventListener(`click`,e=>{let t=e.target;if(t.closest(`[data-fresh-close]`))return ra=!1,Q();let n=t.closest(`[data-fresh-dismiss]`);n&&(J=n.dataset.freshDismiss||void 0,ra=!1,Q(),ca())});function ca(){fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissFreshnessSha:J??null})}).catch(()=>{})}function la(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}var X=!1;async function ua(){if(X)return;X=!0,ma(!0);let e=ha(q,Y),t=await da(!1);t&&ya(),X=!1,t&&(q?.code.state===`changed`||Y!==null)&&J!==void 0&&(J=void 0,ca()),Q();let n=t?ha(q,Y)===e?`No change`:`Updated`:`Could not check`;K&&xa(K,n,2600)}async function da(e){try{let t=await(await fetch(`${E(`/freshness`)}${e?`&quiet=1`:``}`)).json();return q=t.report??null,ia=t.availability??null,Y=t.remote??null,ga=t.kiss??null,t.kissDismissedSha!==void 0&&(_a=t.kissDismissedSha??void 0),!0}catch{return!1}}async function fa(){if(X||!W)return;X=!0;let e=ha(q,Y),t=JSON.stringify(ga),n=await da(!0);X=!1,pa=Date.now(),n&&(ha(q,Y)!==e&&Q(),JSON.stringify(ga)!==t&&ya())}var pa=Date.now();function ma(e){K&&(K.disabled=e),G&&e&&(G.textContent=`Checking…`,G.dataset.state=`checking`)}function ha(e,t){if(!e)return JSON.stringify({report:`none`,remote:t});let{checkedAt:n,...r}=e;return JSON.stringify({...r,remote:t})}var Z=document.querySelector(`[data-kiss-fresh-region]`),ga=va(Z?.dataset.freshness),_a=Z?.dataset.dismissedSha;function va(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function ya(){Z&&(Z.innerHTML=Lt(Z.dataset.reviewedSha??``,ga,{dismissedSha:_a,actions:br!==``}))}Z?.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-freshness-dismiss]`);t&&(_a=t.dataset.kissFreshnessDismiss||void 0,ya(),fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissKissFreshnessSha:_a??null})}).catch(()=>{}))});function Q(){if(W&&(W.innerHTML=wt(q,{dismissedSha:J,open:ra,actions:br!==``,availability:ia,remote:Y}),G&&(q||Y))){let{label:e,state:t}=Ct(q,Y);G.textContent=e,G.dataset.state=t}}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-copy-command]`);if(n)return ba(n);let r=t.closest(`[data-notice-dismiss]`);if(r){r.closest(`[data-notice]`)?.remove(),fetch(E(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissNotice:r.dataset.noticeDismiss})}).catch(()=>{});return}let i=t.closest(`[data-pr-recheck]`);if(i)return void Sa(i);let a=t.closest(`[data-review-update]`);if(a)return void Ta(a);t.closest(`[data-update-close]`)&&document.querySelector(`[data-update-result]`)?.remove()});function ba(e){let t=e.dataset.copyCommand??``;navigator.clipboard?.writeText(t).then(()=>xa(e,`Copied`),()=>xa(e,`Select it`))}function xa(e,t,n=1400){let r=e.textContent;e.textContent=t,setTimeout(()=>{e.textContent=r},n)}async function Sa(e){let t=[...document.querySelectorAll(`[data-pr-recheck]`)];for(let e of t)e.disabled=!0;let n=Date.now(),r=()=>{let e=Math.max(1,Math.round((Date.now()-n)/1e3));for(let n of t){let t=Ca(n);t?t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Re-checking the conversation, ${e}s. ${Ea}`:n.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Checking… ${e}s`}};r();let i=window.setInterval(r,1e3),a=Ca(e)?null:Da(e);try{await fetch(E(`/refresh`),{method:`POST`})}catch{}finally{window.clearInterval(i),a?.remove()}Ca(e)&&wa(),window.location.reload()}function Ca(e){return e.closest(`.prb-fresh-notes p`)}function wa(){try{sessionStorage.setItem(na,`1`)}catch{}}async function Ta(e){let t=[...document.querySelectorAll(`[data-review-update]`)];for(let e of t)e.disabled=!0,e.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Updating…`;let n=!1,r=()=>{n||(n=!0,window.clearInterval(i),window.location.reload())},i=window.setInterval(async()=>{try{let e=await(await fetch(E(`/job`))).json();e.update&&e.update.phase!==`none`&&!Ft(e.update.phase)&&r()}catch{}},500);try{await fetch(E(`/update`),{method:`POST`})}catch{}r()}var Ea=`Fetching the latest threads from your pull request. This usually takes under a minute.`;function Da(e){let t=e.parentElement;if(!t)return null;let n=document.createElement(`span`);return n.className=`prb-recheck-status`,n.setAttribute(`role`,`status`),n.textContent=Ea,t.appendChild(n),n}var Oa=Bt(document),ka=null,Aa=Date.now();function ja(){ka===null&&(ka=window.setTimeout(()=>{ka=null,Ma()},o(Date.now()-Aa)))}async function Ma(){try{let e=await(await fetch(E(`/job`))).json();if(N&&!e.ask||Pa&&!e.diagram){window.location.reload();return}let t={job:e,kiss:e.kiss,update:e.update};for(let[e,n]of Oa){let r=t[e];if(r){if(Vt(e,r,document)){window.location.reload();return}e===`update`||n.matches(`[data-progress-pane]`)?(Ut(n,r.phase,r.progress),Wt(n)):Na(n,r.progress)}}}catch{}ja()}function Na(e,t){if(!t)return;let n=e.querySelector(`.prb-job-progress`);n||(n=document.createElement(`span`),n.className=`prb-job-progress`,e.querySelector(`p`)?.appendChild(n)),n.textContent=` ${t}`}var Pa=document.querySelector(`[data-diagram-running]`)!==null;(Oa.size>0||N||Pa)&&(Aa=Date.now(),ja());function Fa(e){let t=e.parentElement;if(!t)return;let n=t.querySelector(`.prb-job-retry-status`);n||(n=document.createElement(`p`),n.className=`prb-job-retry-status`,n.setAttribute(`role`,`status`),t.insertBefore(n,e.nextSibling)),n.textContent=`The retry could not be started. You can try again.`}function Ia(e){e.parentElement?.querySelector(`.prb-job-retry-status`)?.remove()}document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-job-retry]`);t&&(t.disabled=!0,t.textContent=`Retrying…`,Ia(t),fetch(E(`/retry`),{method:`POST`}).then(e=>{if(!e.ok)throw Error(`refused`);Aa=Date.now(),ja()}).catch(()=>{t.disabled=!1,t.textContent=`Retry`,Fa(t)}))}),document.addEventListener(`change`,e=>{let t=e.target.closest(`[data-kiss-audience]`);if(!t)return;let n=t.closest(`[data-kiss-run-control]`)?.querySelector(`[data-kiss-run]`);n&&(n.disabled=!1)}),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-run]`);if(!t||t.disabled)return;let n=t.closest(`[data-kiss-run-control]`),r=n?.querySelector(`[data-kiss-audience]:checked`)?.value;r&&(t.disabled=!0,t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Starting…`,fetch(E(`/kiss`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({audience:r})}).then(e=>{if(e.ok)window.location.reload();else throw Error(`refused`)}).catch(()=>{t.disabled=!1,t.textContent=`Run KISS review`;let e=document.createElement(`p`);e.className=`prb-kiss-refused`,e.setAttribute(`role`,`status`),e.textContent=`The KISS review could not be started. You can try again.`,n?.querySelector(`.prb-kiss-refused`)?.remove(),n?.appendChild(e)}))});var La=document.body.dataset.defaultView||`overview`;window.addEventListener(`popstate`,e=>{Ar(e.state??_t(window.location.hash)??{kind:`view`,view:La})});var Ra=_t(window.location.hash);Ra?Ar(Ra):history.replaceState({kind:`view`,view:La},``,window.location.pathname+window.location.search),xi(),Rr();var za=e=>{for(let t of document.querySelectorAll(`[data-analysis-details][open]`))(!e||!t.contains(e))&&(t.open=!1)};document.addEventListener(`click`,e=>{za(e.target)}),document.addEventListener(`keydown`,e=>{if(e.key!==`Escape`)return;let t=document.querySelector(`[data-analysis-details][open]`);t&&(za(),t.querySelector(`summary`)?.focus())});var $=document.querySelector(`.prb-header [data-menu]`);if($){let e=$.querySelector(`[data-menu-trigger]`),t=$.querySelector(`[data-menu-panel]`),n=$.querySelector(`[data-menu-items]`),r=$.querySelector(`[data-menu-confirm]`),o=$.querySelector(`[data-confirm-delete]`),s=()=>{n&&(n.hidden=!1),r&&(r.hidden=!0),$.querySelector(`[data-menu-error]`)?.remove()},c=()=>{t&&(t.hidden=!0),e?.setAttribute(`aria-expanded`,`false`),s()};e?.addEventListener(`click`,n=>{if(n.stopPropagation(),!t)return;let r=t.hidden;s(),t.hidden=!r,e.setAttribute(`aria-expanded`,String(r))}),$.addEventListener(`click`,e=>{let t=e.target,i=t?.closest(`[data-copy-id]`);if(i?.dataset.copyId){e.stopPropagation(),a(i,i.dataset.copyId);return}let o=t?.closest(`[data-save-toggle]`);if(o){e.stopPropagation(),l(o);return}if(t?.closest(`[data-delete]`)){e.stopPropagation(),n&&(n.hidden=!0),r&&(r.hidden=!1);return}if(t?.closest(`[data-cancel-delete]`)){e.stopPropagation(),s();return}t?.closest(`[data-confirm-delete]`)&&(e.stopPropagation(),u())});let l=async e=>{let t=e.getAttribute(`aria-pressed`)!==`true`;e.disabled=!0;let n=null;try{let e=await fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({pinned:t})});e.ok&&(n=(await e.json()).pinned===!0)}catch{}if(e.disabled=!1,n===null){e.textContent=`Could not save`,window.setTimeout(()=>{e.textContent=i(e.getAttribute(`aria-pressed`)===`true`)},1600);return}e.setAttribute(`aria-pressed`,String(n)),e.textContent=i(n)},u=async()=>{o&&(o.disabled=!0,o.textContent=`Deleting`);let e;try{let t=await fetch(E(`/delete`),{method:`POST`});if(t.ok)return void window.location.replace(`/`);e=(await t.json().catch(()=>null))?.error??`That could not be deleted.`}catch{e=`The workspace server did not answer. It may have stopped.`}o&&(o.disabled=!1,o.textContent=`Delete`),s();let n=document.createElement(`p`);n.className=`prb-menu-error`,n.setAttribute(`data-menu-error`,``),n.textContent=e,t?.append(n)};document.addEventListener(`click`,e=>{$.contains(e.target)||c()}),document.addEventListener(`keydown`,n=>{n.key===`Escape`&&t&&!t.hidden&&(c(),e?.focus())})}t(),setTimeout(()=>{fr(ir([...document.querySelectorAll(`[data-view="files"] [data-file]`)].map(e=>e.dataset.file??``)))},0),e(window,()=>window.location.reload()),r(window,document.querySelector(`main.prb-doc`));var Ba=15e3,Va=6e4;function Ha(){return br!==``&&document.visibilityState===`visible`&&!Oa.has(`update`)}document.addEventListener(`visibilitychange`,()=>{Ha()&&Date.now()-pa>=Ba&&fa()}),window.setInterval(()=>{Ha()&&fa()},Va);export{C as t};
|
|
110
|
+
</span>`).join(``),Ki())}async function Bi(e){try{let t=await(await fetch(E(`/prompts`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({prompts:e})})).json().catch(()=>null);B=Array.isArray(t?.prompts)?t.prompts:B}catch{}zi()}function Vi(e){let t=B.find(t=>t.id===e);!t||!j||(j.value=ft(j.value,t.prompt),xi(),j.focus(),j.setSelectionRange(j.value.length,j.value.length),j.dispatchEvent(new Event(`input`)))}var Hi=document.querySelector(`.prb-doc`),Ui=null,Wi=null;function Gi(){k&&(Wi?.(),Wi=we(k,{layout:`flat`,actions:Ye.map(e=>({id:e.id,label:e.label})),onChoose:(e,t)=>qi(e,t)}))}function Ki(){Hi&&(Ui?.(),Ui=we(Hi,{triggerLabel:`Ask Buddy AI`,actions:[...Je.map(e=>({id:e.id,label:e.label})),...B.map(e=>({id:tt(e.id),label:e.name,section:et}))],onChoose:(e,t)=>qi(e,t)}))}function qi(e,t){let n=Ji(e,t);!n||!j||($r=n,j.value=ft(j.value,n),xi(),j.focus(),j.setSelectionRange(j.value.length,j.value.length),j.dispatchEvent(new Event(`input`)))}function Ji(e,t){let n=nt(e);if(n===null)return Qe(t,e);let r=B.find(e=>e.id===n);if(!r)return null;let i=Ze(t);return i?`${i}\n\n${r.prompt}`:null}Ki(),Gi(),Ve(document);var Yi=document.querySelector(`[data-prompt-dialog]`),V=document.querySelector(`[data-prompt-name]`),Xi=document.querySelector(`[data-prompt-text]`),Zi=document.querySelector(`[data-prompt-delete]`),Qi=document.getElementById(`prb-prompt-title`),H=``;function $i(e){let t=B.find(t=>t.id===e);H=t?.id??``,Qi&&(Qi.textContent=t?`Edit prompt`:`Save a prompt`),V&&(V.value=t?.name??``),Xi&&(Xi.value=t?.prompt??``),Zi&&(Zi.hidden=!t),Yi?.showModal(),V?.focus()}async function ea(){let e=V?.value.trim()??``,t=Xi?.value.trim()??``;if(!e||!t){(e?Xi:V)?.focus();return}let n=H?B.map(n=>n.id===H?{...n,name:e,prompt:t}:n):[...B,{id:crypto.randomUUID(),name:e,prompt:t}];Yi?.close(),await Bi(n)}async function ta(){if(!H)return;let e=B.filter(e=>e.id!==H);Yi?.close(),await Bi(e)}document.querySelector(`[data-prompt-cancel]`)?.addEventListener(`click`,()=>Yi?.close()),Zi?.addEventListener(`click`,()=>void ta()),document.querySelector(`[data-prompt-save]`)?.addEventListener(`click`,()=>void ea());var U=document.querySelector(`[data-complete]`);U?.addEventListener(`click`,()=>{let e=U.getAttribute(`aria-pressed`)!==`true`;na(e),fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({complete:e})}).then(async e=>{let t=await e.json().catch(()=>null);t&&na(t.completedAt!==null)}).catch(()=>na(!e))});function na(e){U&&(U.setAttribute(`aria-pressed`,String(e)),U.textContent=e?`Reviewed`:`Mark reviewed`)}var W=document.querySelector(`[data-fresh-region]`),G=document.querySelector(`[data-fresh-status]`),K=document.querySelector(`[data-fresh-check]`),q=ua(W?.dataset.report),ra=`prb-fresh-reopen`,ia=ca(),J=W?.dataset.dismissedSha,aa=sa(W?.dataset.availability),Y=oa(W?.dataset.remote);function oa(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function sa(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function ca(){try{return sessionStorage.getItem(ra)!==null&&(sessionStorage.removeItem(ra),!0)}catch{return!1}}ia&&Q(),K?.addEventListener(`click`,()=>void da()),W?.addEventListener(`click`,e=>{let t=e.target;if(t.closest(`[data-fresh-close]`))return ia=!1,Q();let n=t.closest(`[data-fresh-dismiss]`);n&&(J=n.dataset.freshDismiss||void 0,ia=!1,Q(),la())});function la(){fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissFreshnessSha:J??null})}).catch(()=>{})}function ua(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}var X=!1;async function da(){if(X)return;X=!0,ga(!0);let e=_a(q,Y),t=await fa(!1);t&&xa(),X=!1,t&&(q?.code.state===`changed`||Y!==null)&&J!==void 0&&(J=void 0,la()),Q();let n=t?_a(q,Y)===e?`No change`:`Updated`:`Could not check`;K&&Ca(K,n,2600)}async function fa(e){try{let t=await(await fetch(`${E(`/freshness`)}${e?`&quiet=1`:``}`)).json();return q=t.report??null,aa=t.availability??null,Y=t.remote??null,va=t.kiss??null,t.kissDismissedSha!==void 0&&(ya=t.kissDismissedSha??void 0),t.prState!==void 0&&ha(t.prState),!0}catch{return!1}}async function pa(){if(X||!W)return;X=!0;let e=_a(q,Y),t=JSON.stringify(va),n=await fa(!0);X=!1,ma=Date.now(),n&&(_a(q,Y)!==e&&Q(),JSON.stringify(va)!==t&&xa())}var ma=Date.now();function ha(e){let t=document.querySelector(`[data-pr-state-slot]`);if(!t)return;let n=zt(e,t.hasAttribute(`data-beside-number`));t.innerHTML!==n&&(t.innerHTML=n)}function ga(e){K&&(K.disabled=e),G&&e&&(G.textContent=`Checking…`,G.dataset.state=`checking`)}function _a(e,t){if(!e)return JSON.stringify({report:`none`,remote:t});let{checkedAt:n,...r}=e;return JSON.stringify({...r,remote:t})}var Z=document.querySelector(`[data-kiss-fresh-region]`),va=ba(Z?.dataset.freshness),ya=Z?.dataset.dismissedSha;function ba(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function xa(){Z&&(Z.innerHTML=Rt(Z.dataset.reviewedSha??``,va,{dismissedSha:ya,actions:xr!==``}))}Z?.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-freshness-dismiss]`);t&&(ya=t.dataset.kissFreshnessDismiss||void 0,xa(),fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissKissFreshnessSha:ya??null})}).catch(()=>{}))});function Q(){if(W&&(W.innerHTML=Tt(q,{dismissedSha:J,open:ia,actions:xr!==``,availability:aa,remote:Y}),G&&(q||Y))){let{label:e,state:t}=wt(q,Y);G.textContent=e,G.dataset.state=t}}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-copy-command]`);if(n)return Sa(n);let r=t.closest(`[data-notice-dismiss]`);if(r){r.closest(`[data-notice]`)?.remove(),fetch(E(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissNotice:r.dataset.noticeDismiss})}).catch(()=>{});return}let i=t.closest(`[data-pr-recheck]`);if(i)return void wa(i);let a=t.closest(`[data-review-update]`);if(a)return void Da(a);t.closest(`[data-update-close]`)&&document.querySelector(`[data-update-result]`)?.remove()});function Sa(e){let t=e.dataset.copyCommand??``;navigator.clipboard?.writeText(t).then(()=>Ca(e,`Copied`),()=>Ca(e,`Select it`))}function Ca(e,t,n=1400){let r=e.textContent;e.textContent=t,setTimeout(()=>{e.textContent=r},n)}async function wa(e){let t=[...document.querySelectorAll(`[data-pr-recheck]`)];for(let e of t)e.disabled=!0;let n=Date.now(),r=()=>{let e=Math.max(1,Math.round((Date.now()-n)/1e3));for(let n of t){let t=Ta(n);t?t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Re-checking the conversation, ${e}s. ${Oa}`:n.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Checking… ${e}s`}};r();let i=window.setInterval(r,1e3),a=Ta(e)?null:ka(e);try{await fetch(E(`/refresh`),{method:`POST`})}catch{}finally{window.clearInterval(i),a?.remove()}Ta(e)&&Ea(),window.location.reload()}function Ta(e){return e.closest(`.prb-fresh-notes p`)}function Ea(){try{sessionStorage.setItem(ra,`1`)}catch{}}async function Da(e){let t=[...document.querySelectorAll(`[data-review-update]`)];for(let e of t)e.disabled=!0,e.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Updating…`;let n=!1,r=()=>{n||(n=!0,window.clearInterval(i),window.location.reload())},i=window.setInterval(async()=>{try{let e=await(await fetch(E(`/job`))).json();e.update&&e.update.phase!==`none`&&!It(e.update.phase)&&r()}catch{}},500);try{await fetch(E(`/update`),{method:`POST`})}catch{}r()}var Oa=`Fetching the latest threads from your pull request. This usually takes under a minute.`;function ka(e){let t=e.parentElement;if(!t)return null;let n=document.createElement(`span`);return n.className=`prb-recheck-status`,n.setAttribute(`role`,`status`),n.textContent=Oa,t.appendChild(n),n}var Aa=Ht(document),ja=null,Ma=Date.now();function Na(){ja===null&&(ja=window.setTimeout(()=>{ja=null,Pa()},o(Date.now()-Ma)))}async function Pa(){try{let e=await(await fetch(E(`/job`))).json();if(N&&!e.ask||Ia&&!e.diagram){window.location.reload();return}let t={job:e,kiss:e.kiss,update:e.update};for(let[e,n]of Aa){let r=t[e];if(r){if(Ut(e,r,document)){window.location.reload();return}e===`update`||n.matches(`[data-progress-pane]`)?(Gt(n,r.phase,r.progress),Kt(n)):Fa(n,r.progress)}}}catch{}Na()}function Fa(e,t){if(!t)return;let n=e.querySelector(`.prb-job-progress`);n||(n=document.createElement(`span`),n.className=`prb-job-progress`,e.querySelector(`p`)?.appendChild(n)),n.textContent=` ${t}`}var Ia=document.querySelector(`[data-diagram-running]`)!==null;(Aa.size>0||N||Ia)&&(Ma=Date.now(),Na());function La(e){let t=e.parentElement;if(!t)return;let n=t.querySelector(`.prb-job-retry-status`);n||(n=document.createElement(`p`),n.className=`prb-job-retry-status`,n.setAttribute(`role`,`status`),t.insertBefore(n,e.nextSibling)),n.textContent=`The retry could not be started. You can try again.`}function Ra(e){e.parentElement?.querySelector(`.prb-job-retry-status`)?.remove()}document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-job-retry]`);t&&(t.disabled=!0,t.textContent=`Retrying…`,Ra(t),fetch(E(`/retry`),{method:`POST`}).then(e=>{if(!e.ok)throw Error(`refused`);Ma=Date.now(),Na()}).catch(()=>{t.disabled=!1,t.textContent=`Retry`,La(t)}))}),document.addEventListener(`change`,e=>{let t=e.target.closest(`[data-kiss-audience]`);if(!t)return;let n=t.closest(`[data-kiss-run-control]`)?.querySelector(`[data-kiss-run]`);n&&(n.disabled=!1)}),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-run]`);if(!t||t.disabled)return;let n=t.closest(`[data-kiss-run-control]`),r=n?.querySelector(`[data-kiss-audience]:checked`)?.value;r&&(t.disabled=!0,t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Starting…`,fetch(E(`/kiss`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({audience:r})}).then(e=>{if(e.ok)window.location.reload();else throw Error(`refused`)}).catch(()=>{t.disabled=!1,t.textContent=`Run KISS review`;let e=document.createElement(`p`);e.className=`prb-kiss-refused`,e.setAttribute(`role`,`status`),e.textContent=`The KISS review could not be started. You can try again.`,n?.querySelector(`.prb-kiss-refused`)?.remove(),n?.appendChild(e)}))});var za=document.body.dataset.defaultView||`overview`;window.addEventListener(`popstate`,e=>{jr(e.state??vt(window.location.hash)??{kind:`view`,view:za})});var Ba=vt(window.location.hash);Ba?jr(Ba):history.replaceState({kind:`view`,view:za},``,window.location.pathname+window.location.search),Si(),zr();var Va=e=>{for(let t of document.querySelectorAll(`[data-analysis-details][open]`))(!e||!t.contains(e))&&(t.open=!1)};document.addEventListener(`click`,e=>{Va(e.target)}),document.addEventListener(`keydown`,e=>{if(e.key!==`Escape`)return;let t=document.querySelector(`[data-analysis-details][open]`);t&&(Va(),t.querySelector(`summary`)?.focus())});var $=document.querySelector(`.prb-header [data-menu]`);if($){let e=$.querySelector(`[data-menu-trigger]`),t=$.querySelector(`[data-menu-panel]`),n=$.querySelector(`[data-menu-items]`),r=$.querySelector(`[data-menu-confirm]`),o=$.querySelector(`[data-confirm-delete]`),s=()=>{n&&(n.hidden=!1),r&&(r.hidden=!0),$.querySelector(`[data-menu-error]`)?.remove()},c=()=>{t&&(t.hidden=!0),e?.setAttribute(`aria-expanded`,`false`),s()};e?.addEventListener(`click`,n=>{if(n.stopPropagation(),!t)return;let r=t.hidden;s(),t.hidden=!r,e.setAttribute(`aria-expanded`,String(r))}),$.addEventListener(`click`,e=>{let t=e.target,i=t?.closest(`[data-copy-id]`);if(i?.dataset.copyId){e.stopPropagation(),a(i,i.dataset.copyId);return}let o=t?.closest(`[data-save-toggle]`);if(o){e.stopPropagation(),l(o);return}if(t?.closest(`[data-delete]`)){e.stopPropagation(),n&&(n.hidden=!0),r&&(r.hidden=!1);return}if(t?.closest(`[data-cancel-delete]`)){e.stopPropagation(),s();return}t?.closest(`[data-confirm-delete]`)&&(e.stopPropagation(),u())});let l=async e=>{let t=e.getAttribute(`aria-pressed`)!==`true`;e.disabled=!0;let n=null;try{let e=await fetch(E(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({pinned:t})});e.ok&&(n=(await e.json()).pinned===!0)}catch{}if(e.disabled=!1,n===null){e.textContent=`Could not save`,window.setTimeout(()=>{e.textContent=i(e.getAttribute(`aria-pressed`)===`true`)},1600);return}e.setAttribute(`aria-pressed`,String(n)),e.textContent=i(n)},u=async()=>{o&&(o.disabled=!0,o.textContent=`Deleting`);let e;try{let t=await fetch(E(`/delete`),{method:`POST`});if(t.ok)return void window.location.replace(`/`);e=(await t.json().catch(()=>null))?.error??`That could not be deleted.`}catch{e=`The workspace server did not answer. It may have stopped.`}o&&(o.disabled=!1,o.textContent=`Delete`),s();let n=document.createElement(`p`);n.className=`prb-menu-error`,n.setAttribute(`data-menu-error`,``),n.textContent=e,t?.append(n)};document.addEventListener(`click`,e=>{$.contains(e.target)||c()}),document.addEventListener(`keydown`,n=>{n.key===`Escape`&&t&&!t.hidden&&(c(),e?.focus())})}t(),setTimeout(()=>{pr(ar([...document.querySelectorAll(`[data-view="files"] [data-file]`)].map(e=>e.dataset.file??``)))},0),e(window,()=>window.location.reload()),r(window,document.querySelector(`main.prb-doc`));var Ha=15e3,Ua=6e4;function Wa(){return xr!==``&&document.visibilityState===`visible`&&!Aa.has(`update`)}document.addEventListener(`visibilitychange`,()=>{Wa()&&Date.now()-ma>=Ha&&pa()}),window.setInterval(()=>{Wa()&&pa()},Ua);export{S as t};
|