prreviewbuddy 0.46.0 → 0.49.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 +87 -0
- package/dist/{delete_review-lmVdoybL.js → delete_review-BBjXPfMV.js} +183 -32
- package/dist/main.js +1 -3
- package/dist/server.js +596 -184
- package/package.json +1 -1
- package/static/chunk-BeqgAIrQ.js +1 -1
- package/static/chunk-vvGSmhmc.js +1 -0
- package/static/reviews.js +1 -1
- package/static/settings.js +1 -1
- package/static/shell.css +259 -157
- package/static/workspace.js +62 -62
- package/static/chunk-CmPWaXhU.js +0 -1
package/static/workspace.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunk-BeqgAIrQ.js","chunk-DsF7k-Jl.js","chunk-BWjKdrB5.js","chunk-hePW80VL.js","chunk-CN9Gw02i.js","chunk-DJ4Pz6CG.js","chunk-B2kMZj3m.js","chunk-DN473Oml.js","chunk-DwZ_OKDV.js","chunk-CFLfawWY.js","chunk-Wc3Sd0cy.js","chunk-Dy-Kn_BL.js","chunk-CUxm3YXF.js","chunk-tz4nb_gp.js","chunk-BsaS8BTP.js","chunk-fybaL0A-.js","chunk-BifhSqXX.js","chunk-DS17s2tU.js","chunk-nU5620mN.js","chunk-CAnKkQXq.js","chunk-LbU1hoFO.js","chunk-BzbQS41l.js","chunk-BsjqnLg3.js","chunk-BtIQNnN0.js","chunk-D3KKoC5L.js","chunk-CP0rg-5b.js","chunk-j_1H8WHN.js","chunk-BOvsFOI6.js","chunk-CqHdAlCp.js","chunk-DijMHRDA.js","chunk-D2pwppYQ.js","chunk-Cjc271yU.js","chunk-B2PgDgse.js","chunk-D95j_xjm.js","chunk-Cv3JjNkX.js","chunk-EIJEcyW-.js","chunk-C3nvJp0N.js","chunk-D2NZorQR.js","chunk-NzFayA7r.js","chunk-AdYjtsZU.js","chunk-pNSm1SyV.js","chunk-c-cg1wCO.js","chunk-CBrdyqSx.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as e,i as t,t as n}from"./chunk-BeL0x-wt.js";import{
|
|
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(`${
|
|
2
|
+
import{c as e,i as t,t as n}from"./chunk-BeL0x-wt.js";import{C as r,S as i,_ as a,f as o,i as s,m as c,n as l,r as u,w as d,x as f}from"./chunk-vvGSmhmc.js";function p(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function m(e){return p(e).replace(/`([^`\n]+)`/g,`<code>$1</code>`)}var h=`pr-helper-code-block`,g=`pr-helper-code-copy`,_=`\0`,v=``,ee=/\u0000(\d+)\u0000/g,te=/^\u0000\d+\u0000$/,y=/\u0001(\d+)\u0001/g,ne=/^(?:https?:\/\/|#)/i;function re(e){let{text:t,blocks:n}=ie(e.replace(/[\u0000\u0001]/g,``));return ae(oe(t),n)}function ie(e){let t=[],n=e.split(`
|
|
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(`${_}${t.length}${_}`),t.push(o.join(`
|
|
4
4
|
`))}return{text:r.join(`
|
|
5
|
-
`),blocks:t}}function
|
|
6
|
-
`)){let e=o.trim();if(!e){a();continue}if(
|
|
5
|
+
`),blocks:t}}function ae(e,t){return e.replace(ee,(e,n)=>`<div class="${h}"><pre><code>${p(t[Number(n)])}</code></pre><button type="button" class="${g}" aria-label="Copy code">Copy</button></div>`)}function oe(e){let t=[],n=[],r=[],i=null,a=()=>{n.length&&t.push(`<p>${se(n.join(` `))}</p>`),r.length&&t.push(`<blockquote>${se(r.join(` `))}</blockquote>`),i&&t.push(`<${i.tag}>${i.items.map(e=>`<li>${se(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(te.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}>${se(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 se(e){let t=[];return p(e).replace(/`([^`\n]+)`/g,(e,n)=>(t.push(n),`${v}${t.length-1}${v}`)).replace(/(?<!!)\[([^\]\n]+)\]\(([^)\s]+)\)/g,(e,t,n)=>ne.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(y,(e,n)=>`<code>${t[Number(n)]}</code>`)}async function ce(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){return console.warn(`PR Helper: clipboard write failed, falling back to execCommand`,t),le(e)}}function le(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 b=`pr-helper-msg-copy`,ue=`pr-helper-chat-actions`,de=`data-message-id`,fe=`data-copy-source`,pe={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 me(e){return ve(`${fe}="${p(e)}"`)}var he=`pr-helper-finding-copy`,ge=`data-copy-idle-label`,_e=`data-copy-idle-aria`;function ve(e,t){let{icon:n}=pe.idle,r=t?.label??pe.idle.label,i=t?.aria??pe.idle.aria,a=t?` ${ge}="${p(r)}" ${_e}="${p(i)}"`:``,o=`<button type="button" class="${t?`${b} ${he}`:b}" ${e}${a}${t?` data-tip="${p(t.tip)}"`:``} aria-label="${p(i)}"><span class="${b}-icon" aria-hidden="true">${be(n)}</span><span class="${b}-label"${r?``:` hidden`}>${p(r)}</span></button>`;return t?o:`<div class="${ue}">${o}</div>`}function ye(e,t){let n=pe[t],r=t===`idle`?{...n,label:e.getAttribute(ge)??n.label,aria:e.getAttribute(_e)??n.aria}:n,i=e.querySelector(`.${b}-icon`),a=e.querySelector(`.${b}-label`);i&&(i.innerHTML=be(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 be(e){return`<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">${e}</svg>`}var xe=1400,Se=`Copy`,Ce=`Copied`,we=/Mac|iPhone|iPad/.test(navigator.userAgent)?`Press ⌘C`:`Press Ctrl C`,x=new WeakMap;function Te(e,t={}){let n=e=>{let n=e.target;if(!(n instanceof Element))return;let r=n.closest(`.${g}`),i=r?null:n.closest(`.${b}`);!r&&!i||(e.preventDefault(),e.stopPropagation(),r?Oe(r):i&&Ee(i,t.messageSource))};return e.addEventListener(`click`,n,!0),()=>e.removeEventListener(`click`,n,!0)}async function Ee(e,t){let n=De(e,t);Ae(e,n!==null&&await ce(n)?`copied`:`failed`)}function De(e,t){let n=e.getAttribute(fe);if(n!==null)return n;let r=e.getAttribute(de);return r&&t?t(r):null}async function Oe(e){let t=e.parentElement?.querySelector(`pre code`),n=t?await ce(t.textContent??``):!1;!n&&t&&ke(t),je(e,n?Ce:we,n)}function ke(e){let t=window.getSelection();if(!t)return;let n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}function Ae(e,t){let n=x.get(e);n&&window.clearTimeout(n),ye(e,t),x.set(e,window.setTimeout(()=>{ye(e,`idle`),x.delete(e)},xe))}function je(e,t,n){let r=x.get(e);r&&window.clearTimeout(r),e.textContent=t,e.classList.toggle(`copied`,n),x.set(e,window.setTimeout(()=>{e.textContent=Se,e.classList.remove(`copied`),x.delete(e)},xe))}var Me=`pr-helper-selection-popover`,Ne=`pr-helper-selection-popover-expanded`,Pe=`pr-helper-selection-copy-done`,Fe=8,Ie=8,Le=1e3,Re=`Copy selected text`,ze=`Copy`,Be=`Copied`,Ve=`pr-helper-selection-popover-flat`,S=null;function He(e){return`<button type="button" class="pr-helper-selection-menu-item" data-selection-action="${p(e.id)}">${p(e.label)}</button>`}function Ue(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
|
-
<div class="pr-helper-selection-menu-heading">${
|
|
9
|
-
<div class="pr-helper-selection-menu-group-items">${t.map(
|
|
10
|
-
</div>`).join(``)}`}function
|
|
8
|
+
<div class="pr-helper-selection-menu-heading">${p(e)}</div>
|
|
9
|
+
<div class="pr-helper-selection-menu-group-items">${t.map(He).join(``)}</div>
|
|
10
|
+
</div>`).join(``)}`}function We(e){if(e.layout===`flat`)return Ge(e);let t=Ue(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">
|
|
14
14
|
<path d="M1.75 1h12.5A1.75 1.75 0 0 1 16 2.75v8.5A1.75 1.75 0 0 1 14.25 13H8.06l-3.5 2.63A.75.75 0 0 1 3.36 15v-2H1.75A1.75 1.75 0 0 1 0 11.25v-8.5A1.75 1.75 0 0 1 1.75 1Z"/>
|
|
15
15
|
</svg>
|
|
16
|
-
<span>${
|
|
16
|
+
<span>${p(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="${Re}" 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,120 +24,120 @@ 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">${Re}</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 Ge(e){return`<div class="pr-helper-selection-menu">
|
|
31
|
+
${Ue(e.actions)}
|
|
32
|
+
<button type="button" class="pr-helper-selection-menu-item pr-helper-selection-copy-item" data-selection-copy>${ze}</button>
|
|
33
|
+
</div>`}function Ke(e,t){let{width:n,height:r}=e.getBoundingClientRect(),i=t.top-r-Fe,a=i>=Ie?i:Math.min(t.bottom+Fe,window.innerHeight-r-Ie),o=Math.max(Ie,Math.min(t.left,window.innerWidth-n-Ie));e.style.top=`${Math.max(Ie,a)}px`,e.style.left=`${o}px`}function C(){w&&=(window.clearTimeout(w),0),S?.popover.remove(),S=null}var w=0;function qe(e){let t=e.querySelector(`.pr-helper-selection-tip`),n=e.querySelector(`.pr-helper-selection-copy-item`);e.classList.add(Pe),t&&(t.textContent=Be),n&&(n.textContent=Be),w&&window.clearTimeout(w),w=window.setTimeout(()=>Je(e),Le)}function Je(e){w&&=(window.clearTimeout(w),0),e.classList.remove(Pe);let t=e.querySelector(`.pr-helper-selection-tip`);t&&(t.textContent=Re);let n=e.querySelector(`.pr-helper-selection-copy-item`);n&&(n.textContent=ze)}async function Ye(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}qe(e)}function Xe(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 Ze(e,t){let n={},r=()=>{let r=Xe(e,t);if(!r){(!S||S.owner===n)&&C();return}if(S&&S.owner!==n&&C(),S)S.popover.classList.remove(Ne),Je(S.popover),S.text=r.text;else{let i=document.createElement(`div`);i.className=t.layout===`flat`?`${Me} ${Ve}`:Me,i.innerHTML=We(t),i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,n=>{let r=n.target;if(r.closest(`[data-selection-copy]`)){S?.text&&Ye(i,S.text);return}if(r.closest(`[data-selection-open]`)){i.classList.add(Ne);let n=Xe(e,t);Ke(i,n?.rect??i.getBoundingClientRect());return}let a=r.closest(`[data-selection-action]`)?.dataset.selectionAction;if(!a||!S)return;let o=S.text;C(),t.onChoose(a,o)}),document.body.appendChild(i),S={popover:i,text:r.text,owner:n}}Ke(S.popover,r.rect)},i=e=>{S&&e.target instanceof Node&&S.popover.contains(e.target)||window.setTimeout(r,0)},a=e=>{(e.shiftKey||e.key===`Shift`)&&r()},o=()=>{if(!S)return;let e=window.getSelection();(!e||e.isCollapsed)&&C()},s=e=>{e.key===`Escape`&&C()},c=()=>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),C()}}var T=[{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`}],Qe=[{id:`explain-detail`,label:`Explain`,instruction:`Explain this, keeping the technical detail.`},{id:`explain`,label:`Explain simply`,instruction:`Explain this in simpler terms.`},T.find(e=>e.id===`is-problem`),{id:`why-matters`,label:`Why does this matter?`,instruction:`Why does this matter? Say who or what it affects, and when.`},T.find(e=>e.id===`better-implementation`),T.find(e=>e.id===`author-question`),T.find(e=>e.id===`custom`)];function $e(e){return![...T,...Qe,...et].find(t=>t.id===e)?.instruction}var et=[{id:`add-to-chat`,label:`Add to chat`}],tt=800;function nt(e,t={}){let n=t.maxChars??tt,r=e.replace(/\r\n/g,`
|
|
34
34
|
`).split(`
|
|
35
35
|
`).map(e=>e.replace(/\s+$/,``));for(;r.length&&!r[0].trim();)r.shift();for(;r.length&&!r[r.length-1].trim();)r.pop();let i=r.filter(e=>e.trim()).map(e=>e.match(/^[ \t]*/)[0].length),a=i.length?Math.min(...i):0,o=r.map(e=>e.slice(a)).join(`
|
|
36
36
|
`).replace(/\n{3,}/g,`
|
|
37
37
|
|
|
38
38
|
`);return o.trim()?(o.length>n?`${o.slice(0,n).trimEnd()}…`:o).split(`
|
|
39
39
|
`).map(e=>`> ${e}`.trimEnd()).join(`
|
|
40
|
-
`):``}function
|
|
40
|
+
`):``}function rt(e,t,n={}){let r=nt(e,n);if(!r)return null;let i=[...Qe,...T,...et].find(e=>e.id===t);return i?i.instruction?`${r}\n\n${i.instruction}`:`${r}\n\n`:null}Object.freeze([{id:`default-assumptions`,name:`What does it assume?`,prompt:`What assumptions does this change make? Say which are stated, which are implied, and what happens if one turns out to be wrong.`},{id:`default-explain-educational`,name:`Teach me this`,prompt:`Explain this in an educational way: the concepts it relies on, why it is built this way, and what I should take away from it.`},{id:`default-what-could-go-wrong`,name:`What could go wrong?`,prompt:`What could go wrong here? Think about edge cases, failure modes and the existing callers this could break.`},{id:`default-walkthrough`,name:`Walk me through it`,prompt:`Walk me through the implementation step by step, in the order the code runs.`},{id:`default-verify-manually`,name:`What should I verify?`,prompt:`What should I verify manually before approving this, and how would I check each one?`}].map(e=>Object.freeze(e)));var it=`saved:`,at=`Your prompts`;function ot(e){return`${it}${e}`}function st(e){return e.startsWith(`saved:`)?e.slice(6):null}var ct=[`progress`,`overview`,`guide`,`issues`,`questions`,`files`,`prcontext`,`map`,`diagram`,`kiss`,`kissrecs`],lt=`#theme-`,ut=[`buddy`,`overview`,`guide`,`map`,`diagram`,`issues`,`questions`,`files`,`prcontext`,`kiss`,`kissrecs`,`progress`],dt=`&focus=`;function ft(e){return`#${e}`}function pt(e){return`${lt}${encodeURIComponent(e)}`}function mt(e){let t=e.kind===`view`?ft(e.view):pt(e.sectionId);return e.focus?`${t}${dt}${e.focus}`:t}function ht(e){let{focus:t,...n}=e;return n}function gt(e,t){return e.kind!==`view`||e.view!==`guide`||!t?e:{kind:`section`,sectionId:t,...e.focus?{focus:e.focus}:{}}}function _t(e){return ut.includes(e)}function vt(e){let t=e.indexOf(dt);if(t===-1)return yt(e);let n=yt(e.slice(0,t));if(!n)return null;let r=e.slice(t+7);return _t(r)?{...n,focus:r}:n}function yt(e){if(e.startsWith(lt)){let t=e.slice(7);if(!t)return null;try{return{kind:`section`,sectionId:decodeURIComponent(t)}}catch{return null}}let t=e.replace(/^#/,``);return ct.includes(t)?{kind:`view`,view:t}:null}var bt=`pushedFocus`;function xt(e){let{[bt]:t,...n}=e;return n}function St(e,t){return e.kind===`view`&&t.kind===`view`?e.view===t.view:e.kind===`section`&&t.kind===`section`&&e.sectionId===t.sectionId}function Ct(e,t,n){if(e.focus===t)return;let r={...ht(xt(e)),focus:t};e.focus&&n.history.state?.[bt]?n.history.replaceState({...r,[bt]:!0},``,mt(r)):n.history.pushState({...r,[bt]:!0},``,mt(r)),n.apply(r)}function wt(e,t){if(!e.focus)return;if(t.history.state?.[bt]){t.history.back();return}let n=ht(xt(e));t.history.replaceState(n,``,mt(n)),t.apply(n)}function Tt(e,t,n){if(!n||e.key!==`Escape`||e.defaultPrevented||t.querySelector(`dialog[open], [data-menu-panel]:not([hidden]), [data-analysis-details][open], .pr-helper-selection-popover`))return!1;let r=e.target;return!(r?.closest?.(`[data-ask-resize]`)||r instanceof HTMLInputElement&&r.value!==``)}function Et(e,t,n){e&&(n?e.dataset.focus=n:delete e.dataset.focus);for(let e of t.querySelectorAll(`[data-focus-toggle]`)){let t=e.dataset.focusToggle===n,r=e.dataset.focusName??`this`,i=t?`Exit focus on ${r}`:`Expand ${r}`;e.setAttribute(`aria-pressed`,String(t)),e.setAttribute(`aria-label`,i),e.setAttribute(`title`,t?`${i} (Esc)`:i)}}function Dt(e,t,n,r){let i=n===`finding`?{maxChars:1/0}:{},a=st(e);if(a===null)return rt(t,e,i);let o=r(a);if(!o)return null;let s=nt(t,i);return s?`${s}\n\n${o}`:null}function Ot(e,t,n){let r=Dt(e,t.text,t.context,n.savedPrompt);if(!r)return null;let i=$e(e)||st(e)!==null;return t.context===`selection`||i?(n.stage(r),`staged`):(n.send(r),`sent`)}var kt=`button:not([disabled])`;function At(e){return e.querySelector(`[data-menu-panel]`)}function jt(e){return e.querySelector(`[data-menu-trigger]`)}function Mt(e){let t=At(e);return t?[...t.querySelectorAll(kt)].filter(e=>!e.closest(`[hidden]`)):[]}function Nt(e,t={}){let n=null,r=(e,r={})=>{let i=At(e);if(!i||i.hidden)return;i.hidden=!0;let a=jt(e);a?.setAttribute(`aria-expanded`,`false`),n===e&&(n=null),t.onClose?.(e),r.returnFocus&&a?.focus()},i=()=>{for(let t of e.querySelectorAll(`[data-menu]`))r(t)},a=(e,r)=>{let a=At(e);a&&(i(),t.onOpen?.(e),a.hidden=!1,jt(e)?.setAttribute(`aria-expanded`,`true`),n=e,r&&Mt(e)[0]?.focus())};return e.addEventListener(`click`,e=>{let t=e.target,o=t?.closest?.(`[data-menu]`)??null;if(!o){i();return}if(t?.closest(`[data-menu-trigger]`)){let t=e.detail===0;At(o)?.hidden?a(o,t):r(o);return}n&&n!==o&&r(n)}),e.addEventListener(`keydown`,e=>{if(!n)return;let t=n;if(e.key===`Escape`){e.preventDefault(),r(t,{returnFocus:!0});return}if(!t.contains(e.target))return;if(e.key===`Tab`){r(t);return}let i=Mt(t);if(i.length===0)return;let a=i.indexOf(e.target),o=e.key===`ArrowDown`?i[(a+1)%i.length]:e.key===`ArrowUp`?i[(a-1+i.length)%i.length]:e.key===`Home`?i[0]:e.key===`End`?i[i.length-1]:null;o&&(e.preventDefault(),o.focus())}),{close:r,closeAll:i}}function Pt(e){return e.reviewerClosed>0?`dealt with`:`resolved`}({claude:`Claude Code`,codex:`Codex`,gemini:`Gemini CLI`}).claude;function E(e,t=``){return typeof e==`string`?e:t}var Ft=`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 It(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 Lt(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 Rt(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 zt(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 Bt(e){return e instanceof Element&&e.closest(`[data-guide-jump]`)?.dataset.guideJump||null}function Vt(e){for(let t of document.querySelectorAll(`[data-goto-section]`))t.setAttribute(`aria-current`,String(t.dataset.gotoSection===e))}function Ht(){for(let e of document.querySelectorAll(`.prb-rail [data-goto-section]`))e.setAttribute(`aria-current`,`false`)}function Ut(e,t){let n=e.trim();return n?`${n}\n\n${t}`:t}function Wt(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 Gt(){return`<button type="button" class="prb-update-btn" data-review-update>Update review</button>`}var Kt=`Updating this review checks the latest commits and refreshes the PR conversation. Your progress and Buddy AI history will be kept.`;function qt(e){return`<details class="prb-update-alt">
|
|
41
41
|
<summary>Start a new review</summary>
|
|
42
|
-
<span>A brand new review, with its own findings and its own path through the change. Run <code>${
|
|
43
|
-
</details>`}var
|
|
42
|
+
<span>A brand new review, with its own findings and its own path through the change. Run <code>${p(e)}</code> in your session.<button type="button" class="prb-fresh-quiet" data-copy-command="${p(e)}">Copy</button></span>
|
|
43
|
+
</details>`}var Jt=`prreviewbuddy review --fresh`;function Yt(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 Xt(e,t={}){let n=e??(t.remote?nn(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`,s=r?.sha??n.code.latestSha,c=t.dismissedSha!==void 0&&t.dismissedSha===s;if(!t.open&&!o&&(!(i||a)||c))return``;let l=r?rn(n.code,r):tn(n.code,t.availability??null),u=e?[...l.facts,`checked ${p(Wt(n.checkedAt))}`]:l.facts;return`<div class="prb-fresh" data-state="${i||a?`changed`:`quiet`}" role="status">
|
|
44
44
|
<div class="prb-fresh-head">
|
|
45
|
-
<span class="prb-fresh-dot" data-freshness="${
|
|
46
|
-
<strong class="prb-fresh-title">${
|
|
47
|
-
<span class="prb-fresh-facts">${
|
|
45
|
+
<span class="prb-fresh-dot" data-freshness="${l.state}" aria-hidden="true"></span>
|
|
46
|
+
<strong class="prb-fresh-title">${p(l.title)}</strong>
|
|
47
|
+
<span class="prb-fresh-facts">${u.join(` · `)}</span>
|
|
48
48
|
</div>
|
|
49
|
-
${
|
|
50
|
-
${
|
|
51
|
-
</div>`}function
|
|
52
|
-
${r?
|
|
53
|
-
${r?
|
|
49
|
+
${l.consequence?`<p class="prb-fresh-say">${l.consequence}</p>`:``}
|
|
50
|
+
${Zt(n,t,i||a)}
|
|
51
|
+
</div>`}function Zt(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?Gt():``}
|
|
53
|
+
${r?qt(Jt):``}
|
|
54
54
|
${i}
|
|
55
|
-
${
|
|
56
|
-
</div>`}function
|
|
55
|
+
${Qt(e,t,n,r===!0)}
|
|
56
|
+
</div>`}function Qt(e,t,n,r){let i=[r?p(Kt):``,t.remote?an(e.code):on(e.code,e.checkout.reason!==`no-pull-request`),sn(e,t.actions===!0),n?`<button type="button" class="prb-fresh-quiet" data-fresh-dismiss="${p(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
|
|
60
|
-
<h3 class="prb-doc-title">${
|
|
59
|
+
</details>`:a}function $t(e,t){return e===null?[]:[`${e} file${e===1?``:`s`} ${t}`]}function en(e){return e?`<code title="${p(e)}">${p(e.slice(0,7))}</code>`:``}function D(e){return e?[`reviewed ${en(e)}`]:[]}function tn(e,t){if(e.state===`fixed`)return{state:`fixed`,title:`Freshness: Fixed`,facts:D(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:D(e.reviewedSha),consequence:``};if(e.state===`changed`){if(e.rewritten)return{state:`changed`,title:`Code rewritten`,facts:[...D(e.reviewedSha),...$t(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:[...D(e.reviewedSha),...t,...$t(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:D(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:D(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:D(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 nn(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 rn(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:[...D(e.reviewedSha),...i,...n?$t(n.changedFiles,n.rewritten?`differ`:`changed`):[],`seen ${p(Wt(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 an(e){return`This review is based on ${en(e.reviewedSha)}. The pull request has newer commits. <strong>Update review</strong> fetches them first.`}function on(e,t){if(!e.comparison)return``;let n=`<code>${p(e.comparison.ref)}</code>`;return e.state===`current`?t?`This review is based on the latest PR commit ${en(e.reviewedSha)}.`:`This review is based on ${en(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 sn(e,t){if(!e.conversation.attached)return``;let n=p(Wt(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 cn(e){return e===`done`||e===`failed`}function ln(e,t){let n=e=>e.toLowerCase().replace(/\bthe\b/g,``).replace(/[^a-z]/g,``);return n(e)===n(t)}function un(e,t=``){return`<div class="prb-doc-head">
|
|
60
|
+
<h3 class="prb-doc-title">${p(e)}</h3>
|
|
61
61
|
${t}
|
|
62
|
-
</div>`}var
|
|
63
|
-
<p><strong>This KISS review describes commit ${
|
|
62
|
+
</div>`}var dn=`<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>`,fn=`<path d="M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7"/>`;function pn(e,t){return`<svg class="${t}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`}function mn(e,t){let n=`Expand ${t}`;return`<button type="button" class="prb-focus-toggle" data-focus-toggle="${e}" data-focus-name="${p(t)}" aria-pressed="false" aria-label="${p(n)}" title="${p(n)}">${pn(dn,`prb-focus-expand`)}${pn(fn,`prb-focus-collapse`)}</button>`}mn(`kiss`,`KISS review`),un(`Recommendations`,mn(`kissrecs`,`Recommendations`));function hn(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">
|
|
63
|
+
<p><strong>This KISS review describes commit ${p(e.slice(0,7))}.</strong> ${p(r)}</p>
|
|
64
64
|
<p class="prb-kiss-fresh-note">Running KISS again analyses the branch as it is now. The report below is kept either way.</p>
|
|
65
|
-
${n.actions&&t.latestSha?`<button type="button" class="prb-kiss-fresh-dismiss" data-kiss-freshness-dismiss="${
|
|
66
|
-
</div>`}function
|
|
65
|
+
${n.actions&&t.latestSha?`<button type="button" class="prb-kiss-fresh-dismiss" data-kiss-freshness-dismiss="${p(t.latestSha)}">Not now</button>`:``}
|
|
66
|
+
</div>`}function gn(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 _n(e,t){t.complete!==void 0&&bn(e,t.complete),t.activity!==void 0&&vn(e,t.activity??void 0),t.lifecycle===void 0?t.activity!==void 0&&xn(e,yn(e)):xn(e,t.lifecycle??void 0),t.queued!==void 0&&Sn(e,t.queued)}function vn(e,t){let n=e.querySelector(`[data-review-menu]`);n&&(t?(n.dataset.activityAt=String(t.at),n.dataset.activityKind=t.kind):(delete n.dataset.activityAt,delete n.dataset.activityKind))}function yn(e){let t=e.querySelector(`[data-review-menu]`);return s(t?{state:t.dataset.lifecycleState,at:Number(t.dataset.lifecycleAt)}:void 0)}function bn(e,t){let n=t?`complete`:`in-progress`,r=e.querySelector(`[data-page-status]`);r&&(r.dataset.status=n,r.textContent=f(n));let i=e.querySelector(`[data-review-menu] [data-mark-status]`);if(i){let e=t?`in-progress`:`complete`;i.dataset.markStatus=e,i.textContent=o(e)}}function xn(e,t){let n=e.querySelector(`[data-review-menu]`);n&&(t?(n.dataset.lifecycleState=t.state,n.dataset.lifecycleAt=String(t.at)):(delete n.dataset.lifecycleState,delete n.dataset.lifecycleAt));let r=n?Cn(n):void 0,i=e.querySelector(`[data-page-lifecycle]`);if(i){let e=l(t,r);i.hidden=e===void 0,i.textContent=e?.text??``,i.toggleAttribute(`data-changed`,e?.changed===!0)}for(let n of e.querySelectorAll(`[data-review-menu] [data-lifecycle-set]`))n.hidden=!u(n.dataset.lifecycleSet,t,r)}function Sn(e,t){let n=e.querySelector(`[data-review-menu] [data-queue-action]`);n&&(n.dataset.queueAction=t?`remove`:`add`,n.textContent=c(t))}function Cn(e){let t=Number(e.dataset.activityAt),n=e.dataset.activityKind;return Number.isFinite(t)&&n?{at:t,kind:n}:void 0}function wn(e){return s(e)??null}var Tn=[`created`,`updated`,`merged`,`closed`,`reopened`];function En(e){if(typeof e!=`object`||!e)return null;let{complete:t,lifecycle:n,queued:r,activity:i}=e,a={lifecycle:wn(n)};if(typeof t==`boolean`&&(a.complete=t),typeof r==`boolean`&&(a.queued=r),i===null)a.activity=null;else if(typeof i==`object`){let{at:e,kind:t}=i;typeof e==`number`&&Number.isFinite(e)&&Tn.includes(t)&&(a.activity={at:e,kind:t})}return a}function Dn(){let e=0,t=0;return{snapshot:()=>e,current:n=>t===0&&n===e,begin:()=>{e+=1,t+=1;let n=!1;return()=>{n||(n=!0,e+=1,--t)}}}}function On(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`}`}mn(`progress`,`Review progress`);var kn={job:`data-job-phase`,kiss:`data-kiss-phase`,update:`data-update-phase`};function An(e){let t=new Map;for(let n of Object.keys(kn)){let r=kn[n],i=e.querySelector(`[${r}]`);i&&!cn(i.getAttribute(r)??void 0)&&t.set(n,i)}return t}function jn(e,t,n){return t.failed?!0:e===`update`?t.phase===`none`||cn(t.phase):Mn(t.phase,n)}function Mn(e,t){return cn(e)?!0:(e===`conversation`||e===`analysing`)&&!t.querySelector(`[data-view="files"]`)}function Nn(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||ln(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 Pn(e){let t=e.querySelector(`[data-started-at]`),n=Number(t?.dataset.startedAt);!t||!Number.isFinite(n)||(t.textContent=`Running for ${On(n)}.`)}function Fn(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-${p(e.scope)}" data-diagram-card="${p(e.scope)}">
|
|
67
67
|
<header class="prb-diagram-head">
|
|
68
68
|
<div class="prb-diagram-heading">
|
|
69
69
|
<h4 class="prb-diagram-title">
|
|
70
70
|
<button type="button" class="prb-diagram-toggle" data-diagram-toggle aria-expanded="true">
|
|
71
71
|
<span class="prb-diagram-disclosure" aria-hidden="true">▼</span>
|
|
72
|
-
<span>${
|
|
72
|
+
<span>${p(e.title)}</span>
|
|
73
73
|
</button>
|
|
74
74
|
</h4>
|
|
75
|
-
<p class="prb-diagram-scope">${
|
|
75
|
+
<p class="prb-diagram-scope">${p(r)}</p>
|
|
76
76
|
</div>
|
|
77
77
|
<div class="prb-diagram-tools">
|
|
78
78
|
<button type="button" class="prb-diagram-zoom" data-diagram-zoom="out" aria-label="Zoom out">−</button>
|
|
79
79
|
<button type="button" class="prb-diagram-zoom" data-diagram-zoom="reset">Fit</button>
|
|
80
80
|
<button type="button" class="prb-diagram-zoom" data-diagram-zoom="in" aria-label="Zoom in">+</button>
|
|
81
|
-
<button type="button" class="prb-diagram-redraw" data-diagram-request="${
|
|
81
|
+
<button type="button" class="prb-diagram-redraw" data-diagram-request="${p(i)}">Regenerate</button>
|
|
82
82
|
</div>
|
|
83
83
|
</header>
|
|
84
|
-
${e.caption?`<p class="prb-diagram-caption">${
|
|
85
|
-
${
|
|
84
|
+
${e.caption?`<p class="prb-diagram-caption">${p(e.caption)}</p>`:``}
|
|
85
|
+
${In(e,n)}
|
|
86
86
|
<div class="prb-diagram-canvas" data-diagram-canvas></div>
|
|
87
87
|
<details class="prb-diagram-source">
|
|
88
88
|
<summary>Diagram source</summary>
|
|
89
|
-
<div class="${
|
|
89
|
+
<div class="${h}"><pre><code data-mermaid-source>${p(e.mermaid)}</code></pre><button type="button" class="${g}" aria-label="Copy code">Copy</button></div>
|
|
90
90
|
</details>
|
|
91
|
-
</article>`}function
|
|
91
|
+
</article>`}function In(e,t){return!e.commitSha||!t||e.commitSha===t?``:`<p class="prb-diagram-stale">Drawn from <code>${p(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 Ln=`modulepreload`,Rn=function(e){return`/`+e},zn={},O=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=Rn(t,n),t=s(t),t in zn)return;zn[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`:Ln,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)})},Bn=.5,Vn=3,Hn=1.25,Un=null;function Wn(){return Un??=O(()=>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])),Un}var Gn=new WeakSet,Kn=new WeakMap,qn=new WeakMap,k=null;function Jn(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(()=>{k?.abort()});return}let i=n.closest(`[data-diagram-toggle]`);if(i){sr(i.closest(`[data-diagram-card]`),i.getAttribute(`aria-expanded`)===`true`);return}let a=n.closest(`[data-diagram-zoom]`);if(a){ur(a.closest(`[data-diagram-card]`),a.dataset.diagramZoom??`reset`);return}let o=n.closest(`[data-diagram-request]`);o?.dataset.diagramKind===`map`?Xn(e):o&&Yn(e,o.dataset.diagramRequest||null)}),er(),Zn(),{drawPane:cr}}async function Yn(e,t){if(k)return;let n=t??`change`,r=document.querySelector(`[data-diagram-pane]`),i=r?.querySelector(`[data-diagram-card="${_r(n)}"]`)??null??rr(r,n,t);if(!i)return;tr(),e.showDiagrams();let a=ir(i);k=new AbortController,A(!1);try{let n=await fetch(e.endpoint(`/diagram`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sectionId:t}),signal:k.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 ar(i,a,r?.error??`Buddy AI did not return a diagram. Check the terminal running PR Review Buddy.`);or(i,r.diagram,t)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`){i.hasAttribute(`data-diagram-pending`)?(i.remove(),tr()):a.remove();return}ar(i,a,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{k=null,A(!0)}}async function Xn(e){if(k)return;let t=document.querySelector(`[data-map-body]`);if(!t)return;e.showMap();let n=Qn(t),r=t.closest(`[data-map-pane]`);r?.setAttribute(`data-map-running`,``),k=new AbortController,A(!1);try{let t=await fetch(e.endpoint(`/diagram`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`map`}),signal:k.signal}),r=await t.json().catch(()=>null);if(t.status===409&&r?.running){window.location.reload();return}if(r?.stopped)throw new DOMException(`Stopped`,`AbortError`);if(!t.ok||!r?.changeMap){$n(n,r?.error??`Buddy AI did not return a change map. Check the terminal running PR Review Buddy.`);return}n.remove(),e.showChangeMap(r.changeMap),tr()}catch(e){if(e instanceof DOMException&&e.name===`AbortError`){n.remove();return}$n(n,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{r?.removeAttribute(`data-map-running`),k=null,A(!0)}}function Zn(){let e=document.querySelector(`[data-map-pane][data-map-running] [data-map-body]`);e&&(Qn(e),A(!1))}function Qn(e){e.parentElement?.querySelector(`[data-map-status]`)?.remove();let t=document.createElement(`p`);t.className=`prb-diagram-status`,t.setAttribute(`data-map-status`,``),t.innerHTML=`<span class="prb-thinking"><i></i><i></i><i></i></span><span>Reading the review and the change…</span>`;let n=document.createElement(`button`);return n.type=`button`,n.className=`prb-diagram-redraw`,n.setAttribute(`data-diagram-stop`,``),n.textContent=`Stop`,t.appendChild(n),e.before(t),t}function $n(e,t){e.className=`prb-diagram-failed`,e.textContent=t}function er(){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="${_r(n)}"]`)??rr(e,n,t);r&&(tr(),ir(r,{scroll:!1}),A(!1))}function tr(){let e=document.querySelectorAll(`[data-diagram-pane] [data-diagram-card]:not([data-diagram-pending])`).length,t=document.querySelectorAll(`[data-map-body] [data-change-map]`).length;nr(`map`,t>0),nr(`diagram`,e>0);let n=e+t,r=document.querySelector(`.prb-rail [data-view-nav="map"]`);if(!r)return;let i=r.querySelector(`.prb-rail-count`);if(n===0){i?.remove();return}i||(i=document.createElement(`span`),i.className=`prb-rail-count`,r.appendChild(i)),i.textContent=String(n),i.setAttribute(`aria-label`,n===1?`1 diagram`:`${n} diagrams`)}function nr(e,t){for(let n of document.querySelectorAll(`[data-diagram-mode="${e}"]`)){n.toggleAttribute(`data-ready`,t);let e=n.querySelector(`[data-mode-ready]`);e&&(e.hidden=!t)}}function rr(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">
|
|
92
92
|
<div class="prb-diagram-heading">
|
|
93
93
|
<h4 class="prb-diagram-title">Drawing…</h4>
|
|
94
|
-
<p class="prb-diagram-scope">${t===`change`?`Whole change
|
|
94
|
+
<p class="prb-diagram-scope">${t===`change`?`Whole change`:gr(pr(n))}</p>
|
|
95
95
|
</div>
|
|
96
|
-
</header>`,
|
|
96
|
+
</header>`,mr(e,r,n),r}function ir(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:vr()?`auto`:`smooth`,block:`start`}),n}function ar(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 or(e,t,n){let r=Fn(t,new Map(n?[[n,pr(n)]]:[]),t.commitSha),i=document.createElement(`div`);i.innerHTML=r;let a=i.firstElementChild;a&&(e.replaceWith(a),tr(),lr(a))}function sr(e,t){e&&(e.toggleAttribute(`data-diagram-collapsed`,t),e.querySelector(`[data-diagram-toggle]`)?.setAttribute(`aria-expanded`,String(!t)),t||lr(e))}function cr(){for(let e of document.querySelectorAll(`[data-diagram-pane] [data-diagram-card]`))lr(e)}async function lr(e){let t=e.querySelector(`[data-diagram-canvas]`),n=e.querySelector(`[data-mermaid-source]`)?.textContent??``;if(!(!t||!n||Gn.has(e)||e.hasAttribute(`data-diagram-collapsed`))){Gn.add(e);try{let e=await Wn();await e.parse(n);let{svg:r}=await e.render(`prb-mermaid-${Math.random().toString(36).slice(2)}`,n);t.innerHTML=r}catch{Gn.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 ur(e,t){let n=e?.querySelector(`[data-diagram-canvas] svg`),r=e?.querySelector(`[data-diagram-canvas]`);if(!e||!n||!r)return;if(t===`reset`){qn.delete(e),r.removeAttribute(`data-zoomed`),n.style.removeProperty(`width`);return}let i=dr(e,n);if(i<=0)return;let a=fr((qn.get(e)??1)*(t===`in`?Hn:1/Hn));qn.set(e,a),r.setAttribute(`data-zoomed`,``),n.style.width=`${Math.round(i*a)}px`}function dr(e,t){let n=Kn.get(e);if(n)return n;let r=t.getBoundingClientRect().width;if(r>0)return Kn.set(e,r),r;let i=t.getAttribute(`viewBox`)?.split(/[\s,]+/),a=Number(i?.[2]??0);return Number.isFinite(a)?a:0}function fr(e){return Math.min(Vn,Math.max(Bn,e))}function A(e){for(let t of document.querySelectorAll(`[data-diagram-request]`))t.disabled=!e}function pr(e){return e?document.querySelector(`[data-goto-section="${_r(e)}"]`)?.querySelector(`.prb-rail-title`)?.textContent?.trim()||`A theme of this change`:`Whole change`}function mr(e,t,n){let r=hr(n);for(let n of e.querySelectorAll(`[data-diagram-card]`)){let e=n.dataset.diagramCard??``;if(hr(e===`change`?null:e)>r){n.before(t);return}}e.appendChild(t)}function hr(e){if(!e)return-1;let t=document.querySelector(`[data-goto-section="${_r(e)}"]`);return Number(t?.dataset.themeIndex??0)}function gr(e){let t=document.createElement(`span`);return t.textContent=e,t.innerHTML}function _r(e){return CSS.escape(e)}function vr(){return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var yr=[`intent`,`actor`,`concept`,`state`,`constraint`,`risk`,`outcome`],br=[`Intent`,`Behaviour`,`Shared state`,`Risks & constraints`,`Outcome`],j={mapTitle:100,intent:320,title:80,body:220,why:160,anchor:80,label:48,note:200},xr={intent:0,concept:1,actor:2,state:2,constraint:3,risk:3,outcome:4};function Sr(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`The change map was not a JSON object.`);let t=e;if(!Array.isArray(t.nodes)||t.nodes.length===0)throw Error(`The change map had no nodes. This usually means the model ignored the requested shape.`);let{nodes:n,ids:r}=Cr(t.nodes);return{schemaVersion:1,title:Or(E(t.title).trim(),j.mapTitle)||`Change map`,intent:M(t.intent,j.intent)??{simple:``,technical:``},nodes:n,edges:wr(t.edges,r)}}function Cr(e){let t=new Map,n=new Set,r=[];for(let i of e){if(typeof i!=`object`||!i)continue;let e=i,a=M(e.title,j.title);if(!a)continue;let o=E(e.id).trim()||a.technical;if(t.has(o))continue;let s=Dr(Er(o)||`n${r.length+1}`,n);t.set(o,s),n.add(s);let c=yr.includes(e.role)?e.role:`concept`,l=M(e.why,j.why),u=Or(E(e.anchor).trim(),j.anchor),d=E(e.sectionId).trim();r.push({id:s,role:c,stage:Tr(e.stage,c),weight:e.weight===`primary`?`primary`:`supporting`,title:a,body:M(e.body,j.body)??{simple:``,technical:``},...l?{why:l}:{},...u?{anchor:u}:{},...d?{sectionId:d}:{}})}return{nodes:r,ids:t}}function wr(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e){if(typeof r!=`object`||!r)continue;let e=r,i=M(e.label,j.label),a=t.get(E(e.from).trim())??E(e.from).trim(),o=t.get(E(e.to).trim())??E(e.to).trim();if(!i||!a||!o)continue;let s=M(e.note,j.note);n.push({from:a,to:o,label:i,...s?{note:s}:{}})}return n}function M(e,t){if(typeof e==`string`){let n=Or(e.trim(),t);return n?{simple:n,technical:n}:null}if(typeof e!=`object`||!e)return null;let n=e,r=Or(E(n.simple).trim(),t),i=Or(E(n.technical).trim(),t);return!r&&!i?null:{simple:r||i,technical:i||r}}function Tr(e,t){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=4?e:xr[t]}function Er(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)}function Dr(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`}function Or(e,t){if(e.length<=t)return e;let n=e.slice(0,t-1),r=n.lastIndexOf(` `);return`${(r>t/2?n.slice(0,r):n).trimEnd()}…`}function kr(e,t){try{return Ar(Sr(e),t).map}catch{return null}}function Ar(e,t){let n={droppedNodes:0,droppedEdges:0,withdrawnSections:0,demotedPrimaries:0},r=Nr(jr(e.nodes,n).map(e=>Mr(e,t,n)),n),i=new Set(r.map(e=>e.id)),a=new Set,o=[];for(let t of e.edges){let e=`${t.from}\u0000${t.to}`;if(!i.has(t.from)||!i.has(t.to)||t.from===t.to||a.has(e)||o.length>=16){n.droppedEdges+=1;continue}a.add(e),o.push(t)}if(r.length<2||o.length===0)throw Error(`The change map had too little in it to draw: it needs at least two ideas and one relationship.`);return{map:{...e,nodes:Pr(r),edges:o},audit:n}}function jr(e,t){if(e.length<=12)return e;let n=e.filter(e=>e.weight===`primary`).slice(0,3),r=e.filter(e=>!n.includes(e)).slice(0,12-n.length),i=new Set([...n,...r]);return t.droppedNodes+=e.length-i.size,e.filter(e=>i.has(e))}function Mr(e,t,n){if(e.sectionId===void 0||t.includes(e.sectionId))return e;n.withdrawnSections+=1;let{sectionId:r,...i}=e;return i}function Nr(e,t){let n=0;return e.map(e=>e.weight!==`primary`||(n+=1,n<=3)?e:(t.demotedPrimaries+=1,{...e,weight:`supporting`}))}function Pr(e){return[...e].sort((e,t)=>e.stage-t.stage)}function Fr(e){let{stored:t,sections:n,reviewedSha:r,register:i}=e,a=t?kr(t,n.map(e=>e.id)):null,o=!!(a&&t?.commitSha&&r&&t.commitSha!==r);if(!a||!t||o)return Ir(o);let s=new Map(n.map(e=>[e.id,e.title]));return`<div class="prb-map" data-change-map data-register="${i}">
|
|
97
97
|
<header class="prb-map-head">
|
|
98
98
|
<div class="prb-map-heading">
|
|
99
|
-
<h4 class="prb-map-title">${
|
|
99
|
+
<h4 class="prb-map-title">${p(a.title)}</h4>
|
|
100
100
|
${a.intent.simple||a.intent.technical?`<p class="prb-map-intent">${N(a.intent)}</p>`:``}
|
|
101
101
|
</div>
|
|
102
102
|
<div class="prb-map-tools">
|
|
103
|
-
${
|
|
103
|
+
${Lr(i)}
|
|
104
104
|
<button type="button" class="prb-diagram-redraw" data-diagram-request="" data-diagram-kind="map">Regenerate</button>
|
|
105
105
|
</div>
|
|
106
106
|
</header>
|
|
107
107
|
<p class="prb-map-hint">Read from the goal to the outcome. Select an idea to see what it connects to.</p>
|
|
108
|
-
${
|
|
109
|
-
${
|
|
110
|
-
</div>`}function
|
|
108
|
+
${Rr(a,s)}
|
|
109
|
+
${Hr(a)}
|
|
110
|
+
</div>`}function Ir(e){return`<div class="prb-map-empty" data-change-map-empty>
|
|
111
111
|
${e?`<p class="prb-map-stale">The review has moved on since the last map was drawn.</p>`:``}
|
|
112
112
|
<h4 class="prb-map-empty-title">See the change as a map</h4>
|
|
113
113
|
<p>See how the main ideas in this change connect, what depends on what, and where the important risks are. Each idea links back to its theme in the Review Path.</p>
|
|
114
114
|
<p class="prb-map-empty-note">Buddy AI builds it from this review, in plain words and technical ones. It takes a minute or two.</p>
|
|
115
115
|
<button type="button" class="prb-map-generate" data-diagram-request="" data-diagram-kind="map">Generate change map</button>
|
|
116
|
-
</div>`}function
|
|
117
|
-
<h5 class="prb-map-stage-title">${
|
|
118
|
-
${e.nodes.filter(e=>e.stage===n).sort((e,t)=>Number(t.weight===`primary`)-Number(e.weight===`primary`)).map(n=>
|
|
119
|
-
</div>`).join(``),i=e.edges.map((e,t)=>
|
|
116
|
+
</div>`}function Lr(e){let t=(t,n)=>`<button type="button" class="prb-map-register" data-map-register-option="${t}" aria-pressed="${e===t}">${n}</button>`;return`<div class="prb-map-registers" role="group" aria-label="Wording">${t(`simple`,`Simple`)}${t(`technical`,`Technical`)}</div>`}function Rr(e,t){let n=[...new Set(e.nodes.map(e=>e.stage))].sort((e,t)=>e-t),r=n.map(n=>`<div class="prb-map-stage" data-map-stage="${n}">
|
|
117
|
+
<h5 class="prb-map-stage-title">${p(br[n]??``)}</h5>
|
|
118
|
+
${e.nodes.filter(e=>e.stage===n).sort((e,t)=>Number(t.weight===`primary`)-Number(e.weight===`primary`)).map(n=>Br(n,t,e)).join(``)}
|
|
119
|
+
</div>`).join(``),i=e.edges.map((e,t)=>Vr(e,t)).join(``);return`<div class="prb-map-board" data-map-board style="--prb-map-stages: ${n.length}">
|
|
120
120
|
<svg class="prb-map-edges" data-map-edges aria-hidden="true" focusable="false"></svg>
|
|
121
121
|
${r}
|
|
122
122
|
<div class="prb-map-labels" aria-hidden="true">${i}</div>
|
|
123
|
-
</div>`}var
|
|
124
|
-
<p class="prb-map-role">${
|
|
123
|
+
</div>`}var zr={intent:`Goal`,actor:`Actor`,concept:`Idea`,state:`Shared state`,constraint:`Rule`,risk:`Risk`,outcome:`Outcome`};function Br(e,t,n){let r=p(e.id),i=e.sectionId?t.get(e.sectionId):void 0,a=new Map(n.nodes.map(e=>[e.id,e.title])),o=n.edges.map((e,t)=>({edge:e,index:t})).filter(({edge:t})=>t.from===e.id&&a.has(t.to)).map(({edge:e,index:t})=>`<li data-inline-edge="${t}" hidden><em>${N(e.label)}</em> <span aria-hidden="true">→</span> ${N(a.get(e.to))}</li>`).join(``);return`<article class="prb-map-node" data-map-node="${r}" data-role="${e.role}" data-weight="${e.weight}" tabindex="0" aria-labelledby="prb-map-node-${r}">
|
|
124
|
+
<p class="prb-map-role">${zr[e.role]}${e.weight===`primary`?`<span class="prb-map-core"> · Core idea</span>`:``}</p>
|
|
125
125
|
<h5 class="prb-map-node-title" id="prb-map-node-${r}">${N(e.title)}</h5>
|
|
126
126
|
${e.body.simple||e.body.technical?`<p class="prb-map-node-body">${N(e.body)}</p>`:``}
|
|
127
127
|
${e.why?`<p class="prb-map-why"><span class="prb-map-why-lead">Why it matters:</span> ${N(e.why)}</p>`:``}
|
|
128
|
-
${e.anchor?`<code class="prb-map-anchor">${
|
|
128
|
+
${e.anchor?`<code class="prb-map-anchor">${p(e.anchor)}</code>`:``}
|
|
129
129
|
${o?`<ul class="prb-map-inline" aria-hidden="true">${o}</ul>`:``}
|
|
130
|
-
${e.sectionId&&i?`<button type="button" class="prb-map-goto" data-goto-section="${
|
|
131
|
-
</article>`}function
|
|
130
|
+
${e.sectionId&&i?`<button type="button" class="prb-map-goto" data-goto-section="${p(e.sectionId)}" aria-label="Open ${p(i)} in the Review Path">Review Path: ${p(i)} <span aria-hidden="true">→</span></button>`:``}
|
|
131
|
+
</article>`}function Vr(e,t){return`<span class="prb-map-label" data-map-edge="${t}" data-from="${p(e.from)}" data-to="${p(e.to)}">${N(e.label)}</span>`}function Hr(e){let t=new Map(e.nodes.map(e=>[e.id,e.title]));return`<details class="prb-map-list">
|
|
132
132
|
<summary>Read as a list</summary>
|
|
133
133
|
<ol>${e.edges.map(e=>{let n=t.get(e.from),r=t.get(e.to);return!n||!r?``:`<li><strong>${N(n)}</strong> <em>${N(e.label)}</em> <strong>${N(r)}</strong>${e.note?`<span class="prb-map-note"> — ${N(e.note)}</span>`:``}</li>`}).join(``)}</ol>
|
|
134
|
-
</details>`}function N(e){return e.simple===e.technical?
|
|
134
|
+
</details>`}function N(e){return e.simple===e.technical?m(e.simple):`<span data-reg="simple">${m(e.simple)}</span><span data-reg="technical">${m(e.technical)}</span>`}var Ur=`http://www.w3.org/2000/svg`,Wr=new WeakSet,Gr=new WeakMap;function Kr(e){return document.addEventListener(`click`,t=>{let n=t.target;if(!(n instanceof Element))return;let r=n.closest(`[data-map-register-option]`);if(r){ai(r.dataset.mapRegisterOption===`technical`?`technical`:`simple`,e);return}if(n.closest(`[data-goto-section]`))return;let i=n.closest(`[data-map-node]`),a=n.closest(`[data-map-board]`);a&&ii(a,i&&i.classList.contains(`prb-map-node`)?i.dataset.mapNode??null:null)}),document.addEventListener(`focusin`,e=>{let t=e.target instanceof Element?e.target.closest(`.prb-map-node`):null,n=t?.closest(`[data-map-board]`);t&&n&&ii(n,t.dataset.mapNode??null)}),document.addEventListener(`keydown`,t=>{let n=t.target;if(n instanceof HTMLElement){if(t.key===`Escape`&&n.closest(`[data-map-board]`)){let e=n.closest(`[data-map-board]`);e?.hasAttribute(`data-selecting`)&&(ii(e,null),t.stopPropagation());return}if((t.key===`ArrowLeft`||t.key===`ArrowRight`)&&n.matches(`[role="tab"][data-diagram-mode]`)){t.preventDefault();let r=n.dataset.diagramMode===`map`?`diagram`:`map`;e.showView(r),document.querySelector(`.prb-view[data-view="${r}"] [data-diagram-mode="${r}"]`)?.focus()}}}),{layout:qr,show:Jr}}function qr(){for(let e of document.querySelectorAll(`[data-map-board]`))Yr(e),Xr(e)}function Jr(e){let t=document.querySelector(`[data-map-body]`);t&&(t.innerHTML=Fr({stored:e,sections:si(),reviewedSha:e.commitSha,register:oi()}),qr())}function Yr(e){if(Wr.has(e)||typeof ResizeObserver>`u`)return;Wr.add(e);let t=!1;new ResizeObserver(()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1,Xr(e)}))}).observe(e)}function Xr(e){let t=e.querySelector(`[data-map-edges]`);if(!t||e.offsetWidth===0)return;let n=e.getBoundingClientRect(),r=t=>{let r=t.getBoundingClientRect(),i=r.left-n.left+e.scrollLeft,a=r.top-n.top+e.scrollTop;return{left:i,top:a,right:i+r.width,bottom:a+r.height,cx:i+r.width/2,cy:a+r.height/2}},i=e.scrollWidth,a=e.scrollHeight;t.setAttribute(`width`,String(i)),t.setAttribute(`height`,String(a)),t.setAttribute(`viewBox`,`0 0 ${i} ${a}`),t.replaceChildren(ri());let o=new Map;for(let t of e.querySelectorAll(`.prb-map-node`))o.set(t.dataset.mapNode??``,r(t));let s=getComputedStyle(e).gridTemplateColumns.trim().split(/\s+/).length>1,c=[...e.querySelectorAll(`.prb-map-label[data-map-edge]`)].map(e=>{let t=o.get(e.dataset.from??``),n=o.get(e.dataset.to??``);return{label:e,from:t,to:n,ends:t&&n?Zr(t,n,s):null}}),l=new Map,u=(e,t,n,r)=>{let i=`${e}\u0000${t}`;l.set(i,[...l.get(i)??[],{edge:n,other:r}])};c.forEach(({label:e,from:t,to:n,ends:r},i)=>{!t||!n||!r||(u(e.dataset.from??``,r.from,i,n),u(e.dataset.to??``,r.to,i,t))});let d=(e,t,n,r)=>{let i=[...l.get(`${e}\u0000${t}`)??[]],a=t===`top`||t===`bottom`;i.sort((e,t)=>a?e.other.cx-t.other.cx:e.other.cy-t.other.cy);let o=i.findIndex(e=>e.edge===n),s=a?r.right-r.left:r.bottom-r.top,c=Math.min(18,s*.6/Math.max(1,i.length));return(o-(i.length-1)/2)*c},f=[],p=[...e.querySelectorAll(`.prb-map-stage-title`)].map(r),m=[...o.values()],h=e.clientWidth,g=Gr.get(e),_=g&&g.width===h?g.edges:new Set;Gr.set(e,{width:h,edges:_});let v=(t,n)=>{n&&_.add(t);let r=e.querySelector(`[data-inline-edge="${t}"]`);r&&(r.hidden=!n)};c.forEach(({label:e,from:n,to:r,ends:i},a)=>{let o=Number(e.dataset.mapEdge);if(!n||!r||!i){e.hidden=!0;return}if(_.has(o)){e.hidden=!0,v(o,!0);return}let s=Qr(n,i.from,d(e.dataset.from??``,i.from,a,n)),c=Qr(r,i.to,d(e.dataset.to??``,i.to,a,r)),l=ei(s,i.from,c,i.to),[u,h,g,ee]=l,te=m.filter(e=>e!==n&&e!==r);if(Array.from({length:19},(e,t)=>ti(l,.05+t*.05)).some(e=>te.some(t=>e.x>t.left&&e.x<t.right&&e.y>t.top&&e.y<t.bottom))){e.hidden=!0,v(o,!0);return}let y=document.createElementNS(Ur,`path`);y.setAttribute(`d`,`M${P(u.x)},${P(u.y)} C${P(h.x)},${P(h.y)} ${P(g.x)},${P(g.y)} ${P(ee.x)},${P(ee.y)}`),y.setAttribute(`class`,`prb-map-edge`),y.setAttribute(`marker-end`,`url(#prb-map-arrow)`),y.dataset.mapEdge=e.dataset.mapEdge??``,y.dataset.from=e.dataset.from??``,y.dataset.to=e.dataset.to??``,t.appendChild(y),e.hidden=!1;let ne=e.offsetWidth,re=e.offsetHeight,ie=[.5,.4,.6,.3,.7,.22,.78].map(e=>{let t=ti(l,e);return{left:t.x-ne/2,top:t.y-re/2,right:t.x+ne/2,bottom:t.y+re/2}}).find(e=>![...m,...p,...f].some(t=>ni(e,t,2)));if(!ie){y.remove(),e.hidden=!0,v(o,!0);return}v(o,!1),f.push(ie),e.style.left=`${Math.round(ie.left)}px`,e.style.top=`${Math.round(ie.top)}px`}),e.setAttribute(`data-laid-out`,``)}function Zr(e,t,n){let r=t.left-e.right,i=e.left-t.right,a=t.top-e.bottom,o=e.top-t.bottom,s=Math.max(r,i),c=Math.max(a,o);return s>0&&(n||c<=0)?r>=i?{from:`right`,to:`left`}:{from:`left`,to:`right`}:c>0?a>=o?{from:`bottom`,to:`top`}:{from:`top`,to:`bottom`}:{from:`right`,to:`right`}}function Qr(e,t,n){switch(t){case`top`:return{x:e.cx+n,y:e.top};case`bottom`:return{x:e.cx+n,y:e.bottom};case`left`:return{x:e.left,y:e.cy+n};case`right`:return{x:e.right,y:e.cy+n}}}var $r={top:{x:0,y:-1},bottom:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0}};function ei(e,t,n,r){let i=Math.abs(t===`left`||t===`right`?n.x-e.x:n.y-e.y),a=Math.max(24,i/2),o=$r[t],s=$r[r];return[e,{x:e.x+o.x*a,y:e.y+o.y*a},{x:n.x+s.x*a,y:n.y+s.y*a},n]}function ti([e,t,n,r],i){let a=1-i;return{x:a*a*a*e.x+3*a*a*i*t.x+3*a*i*i*n.x+i*i*i*r.x,y:a*a*a*e.y+3*a*a*i*t.y+3*a*i*i*n.y+i*i*i*r.y}}function ni(e,t,n){return e.left<t.right+n&&e.right>t.left-n&&e.top<t.bottom+n&&e.bottom>t.top-n}function P(e){return Math.round(e*10)/10}function ri(){let e=document.createElementNS(Ur,`defs`),t=document.createElementNS(Ur,`marker`);t.setAttribute(`id`,`prb-map-arrow`),t.setAttribute(`viewBox`,`0 0 10 10`),t.setAttribute(`refX`,`9`),t.setAttribute(`refY`,`5`),t.setAttribute(`markerWidth`,`7`),t.setAttribute(`markerHeight`,`7`),t.setAttribute(`orient`,`auto-start-reverse`);let n=document.createElementNS(Ur,`path`);return n.setAttribute(`d`,`M0,0 L10,5 L0,10 z`),n.setAttribute(`class`,`prb-map-arrow`),t.appendChild(n),e.appendChild(t),e}function ii(e,t){for(let t of e.querySelectorAll(`[data-active], [data-near]`))t.removeAttribute(`data-active`),t.removeAttribute(`data-near`);if(e.toggleAttribute(`data-selecting`,t!==null),t!==null){e.querySelector(`.prb-map-node[data-map-node="${CSS.escape(t)}"]`)?.setAttribute(`data-active`,``);for(let n of e.querySelectorAll(`[data-map-edge]`)){let r=n.getAttribute(`data-from`),i=n.getAttribute(`data-to`);if(r!==t&&i!==t)continue;n.setAttribute(`data-active`,``);let a=r===t?i:r;a&&e.querySelector(`.prb-map-node[data-map-node="${CSS.escape(a)}"]`)?.setAttribute(`data-near`,``)}}}function ai(e,t){document.querySelector(`[data-map-pane]`)?.setAttribute(`data-map-register`,e);for(let t of document.querySelectorAll(`[data-change-map]`))t.dataset.register=e;for(let t of document.querySelectorAll(`[data-map-register-option]`))t.setAttribute(`aria-pressed`,String(t.dataset.mapRegisterOption===e));qr(),fetch(t.endpoint(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({changeMapRegister:e})}).catch(()=>{})}function oi(){return document.querySelector(`[data-map-pane]`)?.dataset.mapRegister===`technical`?`technical`:`simple`}function si(){return[...document.querySelectorAll(`[data-goto-section][data-theme-index]`)].map(e=>({id:e.dataset.gotoSection??``,title:e.querySelector(`.prb-rail-title`)?.textContent?.trim()??``}))}function ci(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var li=1e3,ui=new WeakMap;function di(e,t){return e.length<=1e3?ci(e)||` `:`${ci(e.slice(0,li))}\u2026 <button type="button" class="prb-code-long-toggle" data-full-line="${t}">Show full line</button>`}function fi(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">${di(e.text,`old:${e.oldLine}`)}</td></tr>`).join(``)}function pi(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?fi(c):``}<tr class="${s}" data-line="${o}"><td class="prb-code-num">${o}</td><td class="prb-code-line">${di(i,`new:${o}`)}</td></tr>`}),a=r.get(e.totalLines+1);return a&&e.to===e.totalLines&&i.push(fi(a)),i.join(``)}function mi(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 hi(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&&ui.set(r,o)}}function gi(e){let t=ui.get(e),n=e.closest(`td`);return t===void 0||!n?null:(n.textContent=t,n)}function _i(e){return e.deletion?2*e.line-1:2*e.line}function vi(e){return e%2==1?{line:(e+1)/2,deletion:!0}:{line:e/2,deletion:!1}}function yi(e,t){if(e.length===0)return``;let n=e.map(_i),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}">
|
|
135
135
|
<button type="button" class="prb-code-nav-step" data-change-step="previous"${i?``:` disabled`}>\u2191 Previous</button>
|
|
136
136
|
<span class="prb-code-nav-count" aria-live="polite">${s}</span>
|
|
137
137
|
<button type="button" class="prb-code-nav-step" data-change-step="next"${a?``:` disabled`}>Next \u2193</button>
|
|
138
|
-
</span>`}function
|
|
139
|
-
`),r);if(a()){o&&t.lines.forEach((e,n)=>{
|
|
140
|
-
`),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;
|
|
138
|
+
</span>`}function bi(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:vi(i)}}function xi(e,t){return e.querySelector(t.deletion?`tr[data-before-line="${t.line}"]`:`tr[data-line="${t.line}"]`)}function Si(e){return(e.dataset.changeKeys??``).split(`,`).filter(Boolean).map(Number).map(vi)}function Ci(e){if(!e)return;let t=Number(e.dataset.changePosition)||0;return(e.dataset.changeKeys??``).split(`,`).filter(Boolean).map(Number).includes(t)?vi(t):void 0}function wi(e,t){return Math.max(e,+!t)+1}var Ti=8;function Ei(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 Di(e){let t=e.panel-e.scroller;return Math.max(340,Math.floor(e.pane-t-16))}function Oi(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 ki(e,t){let n=t.row.getBoundingClientRect().top-e.getBoundingClientRect().top-t.offset;e.scrollTop+=n}function Ai(e){if(!e.hasAttribute(`data-expanded`))return;let t=Ei(e),n=e.querySelector(`.prb-code-scroll`);if(!t||!n)return;let r=Di({pane:t.clientHeight,panel:e.offsetHeight,scroller:n.offsetHeight});e.style.setProperty(`--prb-code-expanded`,`${r}px`)}function ji(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 Mi=!1;function Ni(){Mi||(Mi=!0,window.addEventListener(`resize`,()=>{for(let e of document.querySelectorAll(`.prb-code[data-expanded]`))Ai(e)}))}function Pi(e,t){let n=e.querySelector(`.prb-code-scroll`),r=n?Oi(n):null;t?(e.setAttribute(`data-expanded`,``),Ai(e),Ni()):(e.removeAttribute(`data-expanded`),e.style.removeProperty(`--prb-code-expanded`)),ji(e),n&&r&&ki(n,r);let i=t?Ei(e):null;i&&(i.scrollTop+=e.getBoundingClientRect().top-i.getBoundingClientRect().top-Ti)}var Fi={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 Ii(e){let t=e.slice(e.lastIndexOf(`/`)+1);if(t===`Dockerfile`||t.startsWith(`Dockerfile.`))return`docker`;let n=t.lastIndexOf(`.`);return n<=0?null:Fi[t.slice(n+1).toLowerCase()]??null}function Li(e){let t=new Set;for(let n of e){let e=Ii(n);e&&t.add(e)}return[...t]}var Ri={ruby:()=>O(()=>import(`./chunk-CAnKkQXq.js`),__vite__mapDeps([19,20,21,22,23,24,25,26,27,28,29])),javascript:()=>O(()=>import(`./chunk-D2pwppYQ.js`),__vite__mapDeps([30,21])),typescript:()=>O(()=>import(`./chunk-Cjc271yU.js`),__vite__mapDeps([31,26])),jsx:()=>O(()=>import(`./chunk-B2PgDgse.js`),__vite__mapDeps([32,24])),tsx:()=>O(()=>import(`./chunk-D95j_xjm.js`),__vite__mapDeps([33,27])),json:()=>O(()=>import(`./chunk-qhed-kSA.js`),[]),yaml:()=>O(()=>import(`./chunk-Cv3JjNkX.js`),__vite__mapDeps([34,29])),markdown:()=>O(()=>import(`./chunk-BYOwaDjH.js`),[]),html:()=>O(()=>import(`./chunk-EIJEcyW-.js`),__vite__mapDeps([35,22,20,21])),css:()=>O(()=>import(`./chunk-C3nvJp0N.js`),__vite__mapDeps([36,20])),scss:()=>O(()=>import(`./chunk-D2NZorQR.js`),__vite__mapDeps([37,20])),sql:()=>O(()=>import(`./chunk-NzFayA7r.js`),__vite__mapDeps([38,25])),python:()=>O(()=>import(`./chunk-gzcpVVnB.js`),[]),java:()=>O(()=>import(`./chunk-AdYjtsZU.js`),__vite__mapDeps([39,23])),kotlin:()=>O(()=>import(`./chunk-DhhofPvG.js`),[]),go:()=>O(()=>import(`./chunk-rLFTqkRN.js`),[]),rust:()=>O(()=>import(`./chunk-Cfkwpbl8.js`),[]),shellscript:()=>O(()=>import(`./chunk-pNSm1SyV.js`),__vite__mapDeps([40,28])),docker:()=>O(()=>import(`./chunk-IyjqRm3v.js`),[]),terraform:()=>O(()=>import(`./chunk-DswuEJGm.js`),[])},zi=`github-light-default`,Bi=null,Vi=new Map;function Hi(){return Bi??=Promise.all([O(()=>import(`./chunk-c-cg1wCO.js`),__vite__mapDeps([41,3])),O(()=>import(`./chunk-CBrdyqSx.js`),__vite__mapDeps([42,3])),O(()=>import(`./chunk-BXViO-2h.js`),[])]).then(([{createHighlighterCore:e},{createOnigurumaEngine:t},n])=>e({themes:[n.default],langs:[],engine:t(O(()=>import(`./chunk-BnjxR4X6.js`),[]))})).catch(()=>null),Bi}function Ui(e){let t=Vi.get(e);return t||(t=Hi().then(async t=>t?(await t.loadLanguage(Ri[e]),!0):!1).catch(()=>!1),Vi.set(e,t)),t.then(e=>e?Hi():null)}var Wi={async preload(e){await Ui(e)},async tokenize(e,t){let n=await Ui(t);if(!n)return null;try{let{tokens:r,fg:i}=n.codeToTokens(e,{lang:t,theme:zi}),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 Gi(e,t=Wi){return Promise.all(e.map(e=>t.preload(e))).then(()=>void 0)}var Ki=/^#[0-9a-f]{3,8}$/i;function qi(e,t){return!t||t.map(e=>e.content).join(``)!==e?null:t.map(e=>e.color&&Ki.test(e.color)?`<span style="color:${e.color}">${ci(e.content)}</span>`:ci(e.content)).join(``)}function Ji(e){return e.length>1e3?e.slice(0,li):e}function Yi(e,t,n){if(!e||t===``)return;let r=qi(Ji(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 Xi(e,t,n=Wi){let r=Ii(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(Ji).join(`
|
|
139
|
+
`),r);if(a()){o&&t.lines.forEach((e,n)=>{Yi(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=>Ji(e.text)).join(`
|
|
140
|
+
`),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;Yi(o.querySelector(`.prb-code-line`),r.text,t[n]),o=o.nextElementSibling}}}}async function Zi(e,t=Wi){let n=e.closest(`.prb-code`)?.dataset.syntax,r=e.textContent??``;if(!n||!(n in Ri)||r===``)return;let i=await t.tokenize(r,n);if(!e.isConnected||e.childElementCount!==0||e.textContent!==r)return;let a=qi(r,i?.[0]);a!==null&&i?.length===1&&(e.innerHTML=a)}var F=document.body,Qi=F.dataset.apiBase??``,$i=F.dataset.token??``,ea=F.dataset.editorLabel??``,ta=F.dataset.editorTemplate??``,na=F.dataset.repoPath??``,ra=F.dataset.explainPrompt??``,ia=F.dataset.sessionId??``;function I(e){return`${Qi}${e}?t=${encodeURIComponent($i)}`}function L(e){fetch(I(`/event`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})}var aa=Jn({endpoint:I,showDiagrams:()=>_a(`diagram`),showMap:()=>_a(`map`),showChangeMap:e=>oa.show(e)}),oa=Kr({endpoint:I,showView:e=>_a(e)}),sa=null,ca=`whole change`;function la(e){let t=gt(e,ua),n=mt(t);window.location.hash!==n&&history.pushState(t,``,n),da(t)}var R=null,ua=document.querySelector(`[data-guide-start]`)?.dataset.guideStart??null;function da(e){let t=gt(e,ua);if(t!==e){let{kind:e,view:n,focus:r,...i}=history.state??{};history.replaceState({...i,...t},``,mt(t))}let n=!R||!St(R,t);R=t,n&&(t.kind===`view`?ya(t.view):Ca(t.sectionId)),ma(t.focus??null)}var fa={history,apply:da},pa=Nt(document,{onOpen:e=>e.hasAttribute(`data-ask-buddy-menu`)?Wo(e):Go(e),onClose:Go});function ma(e){Et(document.querySelector(`.prb-body`),document,e),pa.closeAll(),e===`buddy`&&lo()}function ha(e){R&&(R.focus===e?wt(R,fa):Ct(R,e,fa))}window.addEventListener(`keydown`,e=>{!R||!Tt(e,document,!!R.focus)||(e.preventDefault(),wt(R,fa))},!0);var ga=[`map`,`diagram`];function _a(e){la({kind:`view`,view:e,...ga.includes(e)&&ga.includes(R?.focus??``)?{focus:e}:{}})}function va(e){la({kind:`section`,sectionId:e,...R?.focus===`guide`?{focus:`guide`}:{}})}function ya(e){for(let t of document.querySelectorAll(`.prb-view`))t.hidden=t.dataset.view!==e;for(let t of document.querySelectorAll(`[data-view-nav]:not([role="tab"])`))t.setAttribute(`aria-current`,String(t.dataset.viewNav===e||t.dataset.viewAlso===e));L({event:`view_opened`,view:e}),e===`diagram`&&aa.drawPane(),e===`map`&&oa.layout(),ba(),document.querySelector(`.prb-doc`)?.scrollTo({top:0})}function ba(){Ht(),sa=null,ca=`whole change`,wa()}function xa(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 Sa(){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`)&&xa(e,!0)}}function Ca(e){ya(`guide`),Sa(),Vt(e);let t=zt(e);if(!t)return;let n=document.querySelector(`[data-goto-section="${CSS.escape(e)}"]`);L({event:`theme_opened`,themeIndex:Number(n?.dataset.themeIndex??-1),attention:n?.querySelector(`.prb-attention`)?.dataset.attention??`medium`,isRecommendedStart:n?.dataset.recommendedStart===`true`}),sa=e,ca=t.querySelector(`.pr-helper-guide-section-title`)?.textContent?.trim()??`this theme`,wa()}function wa(){let e=document.querySelector(`[data-ask-scope]`);e&&(e.textContent=ca,e.title=sa?`Questions are answered about "${ca}"`:`Questions cover the whole change`)}function z(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function Ta(e){return e.tagName===`LI`?{parent:e,position:`beforeend`}:{parent:e,position:`afterend`}}async function Ea(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}=Ta(e);o.insertAdjacentElement(s,a),e.setAttribute(`aria-expanded`,`true`),L({event:`file_opened`,fromFinding:i,targeted:r>0}),await Da(a,n,{cited:r,centre:r,expand:0,position:r?2*r:0})}async function Da(e,t,n){try{let{centre:r,expand:i}=n,a=`&path=${encodeURIComponent(t)}${r?`&line=${r}`:``}${i?`&expand=${i}`:``}`,o=await fetch(`${I(`/file`)}${a}`),s=await o.json();if(!o.ok){e.innerHTML=`<p class="prb-code-status">${z(s?.error??`Could not read that file.`)}</p>`;return}Oa(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 Oa(e,t,n){let{cited:r,centre:i,expand:a}=n,o=pi(t,r),s=ta&&na?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="${z(t.path)}" data-open-line="${r||t.from}">${z(`Open in ${ea||`editor`}`)}</button>`:``,c=t.pullRequest&&t.pullRequest.precise?`<a class="prb-code-open prb-code-pr" href="${z(t.pullRequest.href)}" target="_blank" rel="noopener noreferrer">${z(t.pullRequest.label)}</a>`:``,l=t.truncated?`<button type="button" class="prb-code-more" data-expand-file="${z(t.path)}" data-expand-line="${i||0}" data-expand-cited="${r||0}" data-expand-step="${wi(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`:``,f=`<div class="prb-code-source"><span>${t.source===`commit`?`Viewing reviewed version${t.sourceSha?` <code>${z(t.sourceSha.slice(0,7))}</code>`:``}${u}${d}`:`Viewing your working folder${d}`}</span>${yi(t.changeAnchors??[],n.position)}</div>`,p=e.hasAttribute(`data-expanded`),m=`<button type="button" class="prb-code-open" data-code-expand aria-expanded="${p}">${p?`Collapse`:`Expand`}</button>`;e.innerHTML=`<div class="prb-code-header">
|
|
141
141
|
<span class="prb-code-range">lines ${t.from}\u2013${t.to} of ${t.totalLines}</span>
|
|
142
142
|
${c}
|
|
143
143
|
${s}
|
|
@@ -145,7 +145,7 @@ import{c as e,i as t,t as n}from"./chunk-BeL0x-wt.js";import{_ as r,d as i,g as
|
|
|
145
145
|
</div>
|
|
146
146
|
${f}
|
|
147
147
|
<div class="prb-code-scroll"><table class="prb-code-table"><tbody>${o}</tbody></table></div>
|
|
148
|
-
${l}`,Qr(e,t),pi(e),mi(e),(n.focus?ii(e,n.focus):e.querySelector(`.prb-code-target`))?.scrollIntoView({block:`center`}),Ni(e,t)}async function fa(e,t,n){let r=ri(t,n);if(!r)return;let i=ii(e,r.anchor);if(i)t.outerHTML=ni(ai(t),r.key),i.scrollIntoView({block:`center`});else{let t=e.querySelector(`[data-expand-file]`);if(!t?.dataset.expandFile)return;await ua(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 pa(e,t,n){let r=`${zi.replace(/\/$/,``)}/${e}`,i=Ri.replace(`{path}`,r).replace(`{line}`,String(Math.max(1,t)));L({event:`editor_opened`,fromFinding:n}),window.location.href=i}var B=document.querySelector(`[data-ask-log]`);B&&B.querySelector(`.prb-msg`)&&B.scrollTo({top:B.scrollHeight});var ma=document.querySelector(`[data-ask-form]`),V=ma?.querySelector(`textarea`);function ha(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=_(t)+ce(t)):n.textContent=t,B?.appendChild(n),B?.scrollTo({top:B.scrollHeight}),n}function ga(){let e=document.createElement(`div`);return e.className=`prb-thinking`,e.innerHTML=`<i></i><i></i><i></i><span>Reading the change…</span>`,B?.appendChild(e),B?.scrollTo({top:B.scrollHeight}),e}var H=null,U=!!B?.querySelector(`[data-ask-pending]`);function _a(){let e=document.createElement(`div`);e.className=`prb-stopped`,e.textContent=`Stopped.`,B?.appendChild(e),B?.scrollTo({top:B.scrollHeight})}async function va(e,t=`free_text`){let n=e.trim();if(!n||H||U)return;document.querySelector(`.prb-ask-empty`)?.remove(),ha(`user`,n);let r=ga();H=new AbortController,ya(!0);try{let e=await fetch(I(`/ask`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({question:n,sectionId:Wi,source:t}),signal:H.signal}),i=await e.json().catch(()=>null);if(e.status===409&&(i?.running||i?.updating)){window.location.reload();return}if(r.remove(),i?.stopped){_a();return}if(!e.ok||!i?.answer){ha(`error`,i?.error??`Buddy AI did not answer. Check the terminal running PR Review Buddy.`);return}ha(`assistant`,i.answer)}catch(e){r.remove(),e instanceof DOMException&&e.name===`AbortError`?(_a(),V&&!V.value&&(V.value=n)):ha(`error`,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{H=null,ya(!1)}}function ya(e){let t=ma?.querySelector(`button`);t&&(t.textContent=e?`Stop`:`Ask`,t.toggleAttribute(`data-stop`,e),t.disabled=!1),V&&(V.disabled=e);for(let t of document.querySelectorAll(ba))t.disabled=e;e&&Xi.closeAll(),e||V?.focus()}var ba=`[data-suggestion], .pr-helper-explain-simply-button`;function xa(){let e=ma?.querySelector(`button`);e&&(e.textContent=`Stopping…`,e.disabled=!0),fetch(I(`/stop`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`ask`})}).catch(()=>{}).finally(()=>{H?.abort()})}ma?.addEventListener(`submit`,e=>{if(e.preventDefault(),H||U)return xa();let t=V?.value??``;V&&(V.value=``),va(t,Ca(t))}),U&&ya(!0);var Sa=null;function Ca(e){return Sa&&e.includes(Sa.text)?Sa.source:`free_text`}V?.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ma?.requestSubmit())}),V?.addEventListener(`input`,()=>{V&&(V.style.height=`auto`,V.style.height=`${Math.min(V.scrollHeight,140)}px`)});async function wa(e){try{await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answeredQuestionIds:e})})}catch{}}function Ta(){return[...document.querySelectorAll(`[data-question-answered][data-answered="true"]`)].map(e=>e.dataset.questionAnswered??``).filter(Boolean)}function Ea(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&&Ma(n,t,`questions`),Ra()}function Da(){return[...document.querySelectorAll(`[data-issue-dismissed][data-dismissed="true"]`)].map(e=>({id:e.dataset.issueDismissed??``,sessionId:e.dataset.dismissedIn||Vi})).filter(e=>e.id)}async function Oa(e){try{await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissedIssues:e})})}catch{}}function ka(e,t){e.dataset.dismissed=String(t),e.textContent=t?`Reopen`:`Dismiss`,delete e.dataset.stale,t?e.dataset.dismissedIn=Vi: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(Aa()),Ma(n,t||e.dataset.settled===`true`,`issues`),Ba())}function Aa(){let e=document.createElement(`span`);return e.className=`pr-helper-finding-status pr-helper-finding-status-dismissed pr-helper-tip`,e.dataset.tip=kt,e.textContent=`Dismissed by you`,e}var ja=new WeakMap;function Ma(e,t,n){let r=e.closest(`.pr-helper-closed-findings-list`);if(t!==!!r){if(t){let t=e.parentElement;t&&ja.set(e,{parent:t,before:e.nextElementSibling}),Ia(n).append(e),t&&Fa(t)}else Na(e,n),(r?.children.length===0?r.closest(`.pr-helper-closed-findings`):null)?.remove();La(n)}}function Na(e,t){let n=ja.get(e);if(n?.parent.isConnected)n.parent.insertBefore(e,n.before);else{let n=Pa(e)??document.querySelector(`[data-view="${t}"]`);n?.insertBefore(e,n.querySelector(`.pr-helper-closed-findings`))}e.closest(`.pr-helper-question-group`)?.removeAttribute(`hidden`)}function Pa(e){let t=e.dataset.sectionId;return t?document.querySelector(`[data-question-group="${CSS.escape(t)}"]`):null}function Fa(e){let t=e.closest(`.pr-helper-question-group`);t&&!t.querySelector(`[data-finding-card]`)&&(t.hidden=!0)}function Ia(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 La(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=jt(za())}function Ra(){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=Mt(e.length,t)),Va(`questions`,e.length,t,`question`,`answered`)}function za(){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 Ba(){let e=za();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,Ot(e))),Va(`issues`,e.total,e.open,`issue`,Ot(e))}function Va(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){ia(n,n.getAttribute(`aria-expanded`)!==`true`);return}let r=t.closest(`[data-view-nav]`);if(r?.dataset.viewNav){ea(r.dataset.viewNav);return}let i=t.closest(`[data-overview-nav]`);if(i?.dataset.overviewNav){ea(i.dataset.overviewNav===`guide`?`guide`:i.dataset.overviewNav);return}let a=t.closest(`[data-goto-section]`);if(a?.dataset.gotoSection){ta(a.dataset.gotoSection);return}let o=t.closest(`[data-open-editor]`);if(o?.dataset.openEditor){pa(o.dataset.openEditor,Number(o.dataset.openLine)||1,!0);return}let s=t.closest(`[data-deletion-toggle]`);if(s){Zr(s);return}let c=t.closest(`[data-code-expand]`);if(c){let e=c.closest(`.prb-code`);e&&_i(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&&fa(t,e,l.dataset.changeStep===`previous`?`previous`:`next`);return}let u=t.closest(`[data-full-line]`);if(u){let e=$r(u);e&&Pi(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]`);ua(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:oi(t)})}return}let f=t.closest(`[data-focus-toggle]`);if(f?.dataset.focusToggle){Qi(f.dataset.focusToggle);return}let p=t.closest(`[data-prompt-toggle]`);if(p){ho(p.getAttribute(`aria-expanded`)===`true`);return}if(t.closest(`[data-ask-buddy-menu]`))return;let m=t.closest(`[data-file]`);if(m?.dataset.file){la(m);return}let h=Pt(t);if(h){ta(h);return}let g=t.closest(`[data-question-answered]`);if(g?.dataset.questionAnswered){Ea(g,g.dataset.answered!==`true`);let e=Ta();wa(e),L({event:`question_marked_answered`,answered:e.length,total:document.querySelectorAll(`[data-question-answered]`).length});return}let _=t.closest(`[data-issue-dismissed]`);if(_?.dataset.issueDismissed){ka(_,_.dataset.stale===`true`||_.dataset.dismissed!==`true`);let e=Da();Oa(e),L({event:`issue_dismissed`,dismissed:e.length,total:document.querySelectorAll(`[data-issue-dismissed]`).length});return}let v=t.closest(`[data-suggestion]`);if(v){va(v.textContent??``,`suggestion`);return}if(t.closest(`.pr-helper-explain-simply-button`)){Ga(),va(Bi,`explain_simply`);return}let ee=t.closest(`[data-prompt-use]`);if(ee?.dataset.promptUse){go(ee.dataset.promptUse);return}let te=t.closest(`[data-prompt-edit]`);if(te?.dataset.promptEdit){Po(te.dataset.promptEdit);return}if(t.closest(`[data-prompt-add]`)){Po(``);return}if(t.closest(`[data-ask-toggle]`)){let e=R?.focus;e?(vt(R,Yi),Wa(e!==`buddy`)):Wa(!Ua())}});var W=document.querySelector(`.prb-body`),Ha=document.querySelector(`.prb-ask`);function Ua(){return!!Ha&&getComputedStyle(Ha).display!==`none`}function Wa(e){W&&(W.dataset.ask=e?`open`:`closed`),document.querySelector(`[data-ask-toggle]`)?.setAttribute(`aria-expanded`,String(e))}function Ga(){R?.focus&&R.focus!==`buddy`&&vt(R,Yi),Wa(!0)}function Ka(){document.querySelector(`[data-ask-toggle]`)?.setAttribute(`aria-expanded`,String(Ua()))}window.addEventListener(`resize`,Ka),n(I(`/restart`));var qa=document.querySelector(`[data-file-filter]`),Ja=document.querySelector(`[data-file-count]`),Ya=document.querySelector(`[data-file-none]`);function Xa(){let e=(qa?.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}`}Ya&&(Ya.hidden=n>0),Ja&&(Ja.textContent=e?`${t} of ${Za} file${Za===1?``:`s`}`:`${Za} file${Za===1?``:`s`}`)}var Za=document.querySelectorAll(`[data-view="files"] .prb-file:not(.prb-file-referenced)`).length;qa?.addEventListener(`input`,Xa),qa?.addEventListener(`keydown`,e=>{e.key===`Escape`&&qa.value!==``&&(e.preventDefault(),qa.value=``,Xa())}),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(),la(n))});var Qa=320,$a=()=>Math.round(window.innerWidth/2),eo=e=>Math.round(Math.min($a(),Math.max(Qa,e)));function to(e){W&&(e===null?W.style.removeProperty(`--ask-width`):W.style.setProperty(`--ask-width`,`${e}px`))}function no(){return Ha?Math.round(Ha.getBoundingClientRect().width):Qa}function ro(e){fetch(I(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({askWidth:e})}).catch(()=>{})}var G=document.querySelector(`[data-ask-resize]`);G?.addEventListener(`pointerdown`,e=>{if(e.button!==0||!W||!Ha)return;e.preventDefault(),G.setPointerCapture(e.pointerId),W.dataset.resizing=`true`;let t=e.clientX,n=no(),r=e=>{to(eo(n+(t-e.clientX)))},i=()=>{G.removeEventListener(`pointermove`,r),G.removeEventListener(`pointerup`,i),G.removeEventListener(`pointercancel`,i),delete W.dataset.resizing,ro(no())};G.addEventListener(`pointermove`,r),G.addEventListener(`pointerup`,i),G.addEventListener(`pointercancel`,i)}),G?.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=eo(no()+n);to(r),ro(r);return}(e.key===`Home`||e.key===`Escape`)&&(e.preventDefault(),to(null),ro(null))}),G?.addEventListener(`dblclick`,()=>{to(null),ro(null)}),window.addEventListener(`resize`,()=>{Ua()&&W?.style.getPropertyValue(`--ask-width`)&&to(eo(no()))});var io=3e4,ao=document.visibilityState===`visible`?Date.now():null,oo=0;function so(){ao!==null&&(oo+=Date.now()-ao,ao=Date.now())}function co(){so();let e=Math.round(oo/1e3);return oo-=e*1e3,e}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`?ao=Date.now():(so(),ao=null)}),setInterval(()=>{let e=co();e>0&&L({event:`workspace_heartbeat`,visibleSeconds:e})},io),window.addEventListener(`pagehide`,()=>{let e=I(`/event`),t=JSON.stringify({event:`review_completed`,trailingSeconds:co()});navigator.sendBeacon?.(e,new Blob([t],{type:`application/json`}))||fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:t,keepalive:!0}).catch(()=>{})});var lo=document.querySelector(`[data-prompt-bank]`),uo=document.querySelector(`[data-prompt-list]`),K=fo();function fo(){try{let e=JSON.parse(lo?.dataset.prompts??`[]`);return Array.isArray(e)?e:[]}catch{return[]}}function po(){if(!uo)return;uo.innerHTML=K.map(e=>`<span class="prb-bank-item">
|
|
148
|
+
${l}`,hi(e,t),Ai(e),ji(e),(n.focus?xi(e,n.focus):e.querySelector(`.prb-code-target`))?.scrollIntoView({block:`center`}),Xi(e,t)}async function ka(e,t,n){let r=bi(t,n);if(!r)return;let i=xi(e,r.anchor);if(i)t.outerHTML=yi(Si(t),r.key),i.scrollIntoView({block:`center`});else{let t=e.querySelector(`[data-expand-file]`);if(!t?.dataset.expandFile)return;await Da(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 Aa(e,t,n){let r=`${na.replace(/\/$/,``)}/${e}`,i=ta.replace(`{path}`,r).replace(`{line}`,String(Math.max(1,t)));L({event:`editor_opened`,fromFinding:n}),window.location.href=i}var B=document.querySelector(`[data-ask-log]`);B&&B.querySelector(`.prb-msg`)&&B.scrollTo({top:B.scrollHeight});var ja=document.querySelector(`[data-ask-form]`),V=ja?.querySelector(`textarea`);function Ma(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=re(t)+me(t)):n.textContent=t,B?.appendChild(n),B?.scrollTo({top:B.scrollHeight}),n}function Na(){let e=document.createElement(`div`);return e.className=`prb-thinking`,e.innerHTML=`<i></i><i></i><i></i><span>Reading the change…</span>`,B?.appendChild(e),B?.scrollTo({top:B.scrollHeight}),e}var H=null,U=!!B?.querySelector(`[data-ask-pending]`);function Pa(){let e=document.createElement(`div`);e.className=`prb-stopped`,e.textContent=`Stopped.`,B?.appendChild(e),B?.scrollTo({top:B.scrollHeight})}async function Fa(e,t=`free_text`){let n=e.trim();if(!n||H||U)return;document.querySelector(`.prb-ask-empty`)?.remove(),Ma(`user`,n);let r=Na();H=new AbortController,Ia(!0);try{let e=await fetch(I(`/ask`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({question:n,sectionId:sa,source:t}),signal:H.signal}),i=await e.json().catch(()=>null);if(e.status===409&&(i?.running||i?.updating)){window.location.reload();return}if(r.remove(),i?.stopped){Pa();return}if(!e.ok||!i?.answer){Ma(`error`,i?.error??`Buddy AI did not answer. Check the terminal running PR Review Buddy.`);return}Ma(`assistant`,i.answer)}catch(e){r.remove(),e instanceof DOMException&&e.name===`AbortError`?(Pa(),V&&!V.value&&(V.value=n)):Ma(`error`,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{H=null,Ia(!1)}}function Ia(e){let t=ja?.querySelector(`button`);t&&(t.textContent=e?`Stop`:`Ask`,t.toggleAttribute(`data-stop`,e),t.disabled=!1),V&&(V.disabled=e);for(let t of document.querySelectorAll(La))t.disabled=e;e&&pa.closeAll(),e||V?.focus()}var La=`[data-suggestion], .pr-helper-explain-simply-button`;function Ra(){let e=ja?.querySelector(`button`);e&&(e.textContent=`Stopping…`,e.disabled=!0),fetch(I(`/stop`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`ask`})}).catch(()=>{}).finally(()=>{H?.abort()})}ja?.addEventListener(`submit`,e=>{if(e.preventDefault(),H||U)return Ra();let t=V?.value??``;V&&(V.value=``),Fa(t,Ba(t))}),U&&Ia(!0);var za=null;function Ba(e){return za&&e.includes(za.text)?za.source:`free_text`}V?.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ja?.requestSubmit())}),V?.addEventListener(`input`,()=>{V&&(V.style.height=`auto`,V.style.height=`${Math.min(V.scrollHeight,140)}px`)});async function Va(e){try{await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answeredQuestionIds:e})})}catch{}}function Ha(){return[...document.querySelectorAll(`[data-question-answered][data-answered="true"]`)].map(e=>e.dataset.questionAnswered??``).filter(Boolean)}function Ua(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&&Ya(n,t,`questions`),to()}function Wa(){return[...document.querySelectorAll(`[data-issue-dismissed][data-dismissed="true"]`)].map(e=>({id:e.dataset.issueDismissed??``,sessionId:e.dataset.dismissedIn||ia})).filter(e=>e.id)}async function Ga(e){try{await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissedIssues:e})})}catch{}}function Ka(e,t){e.dataset.dismissed=String(t),e.textContent=t?`Reopen`:`Dismiss`,delete e.dataset.stale,t?e.dataset.dismissedIn=ia: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(qa()),Ya(n,t||e.dataset.settled===`true`,`issues`),ro())}function qa(){let e=document.createElement(`span`);return e.className=`pr-helper-finding-status pr-helper-finding-status-dismissed pr-helper-tip`,e.dataset.tip=Ft,e.textContent=`Dismissed by you`,e}var Ja=new WeakMap;function Ya(e,t,n){let r=e.closest(`.pr-helper-closed-findings-list`);if(t!==!!r){if(t){let t=e.parentElement;t&&Ja.set(e,{parent:t,before:e.nextElementSibling}),$a(n).append(e),t&&Qa(t)}else Xa(e,n),(r?.children.length===0?r.closest(`.pr-helper-closed-findings`):null)?.remove();eo(n)}}function Xa(e,t){let n=Ja.get(e);if(n?.parent.isConnected)n.parent.insertBefore(e,n.before);else{let n=Za(e)??document.querySelector(`[data-view="${t}"]`);n?.insertBefore(e,n.querySelector(`.pr-helper-closed-findings`))}e.closest(`.pr-helper-question-group`)?.removeAttribute(`hidden`)}function Za(e){let t=e.dataset.sectionId;return t?document.querySelector(`[data-question-group="${CSS.escape(t)}"]`):null}function Qa(e){let t=e.closest(`.pr-helper-question-group`);t&&!t.querySelector(`[data-finding-card]`)&&(t.hidden=!0)}function $a(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 eo(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=Lt(no())}function to(){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=Rt(e.length,t)),io(`questions`,e.length,t,`question`,`answered`)}function no(){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 ro(){let e=no();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,Pt(e))),io(`issues`,e.total,e.open,`issue`,Pt(e))}function io(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){xa(n,n.getAttribute(`aria-expanded`)!==`true`);return}let r=t.closest(`[data-view-nav]`);if(r?.dataset.viewNav){_a(r.dataset.viewNav);return}let i=t.closest(`[data-overview-nav]`);if(i?.dataset.overviewNav){_a(i.dataset.overviewNav===`guide`?`guide`:i.dataset.overviewNav);return}let a=t.closest(`[data-goto-section]`);if(a?.dataset.gotoSection){va(a.dataset.gotoSection);return}let o=t.closest(`[data-open-editor]`);if(o?.dataset.openEditor){Aa(o.dataset.openEditor,Number(o.dataset.openLine)||1,!0);return}let s=t.closest(`[data-deletion-toggle]`);if(s){mi(s);return}let c=t.closest(`[data-code-expand]`);if(c){let e=c.closest(`.prb-code`);e&&Pi(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&&ka(t,e,l.dataset.changeStep===`previous`?`previous`:`next`);return}let u=t.closest(`[data-full-line]`);if(u){let e=gi(u);e&&Zi(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]`);Da(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:Ci(t)})}return}let f=t.closest(`[data-focus-toggle]`);if(f?.dataset.focusToggle){ha(f.dataset.focusToggle);return}let p=t.closest(`[data-prompt-toggle]`);if(p){No(p.getAttribute(`aria-expanded`)===`true`);return}if(t.closest(`[data-ask-buddy-menu]`))return;let m=t.closest(`[data-file]`);if(m?.dataset.file){Ea(m);return}let h=Bt(t);if(h){va(h);return}let g=t.closest(`[data-question-answered]`);if(g?.dataset.questionAnswered){Ua(g,g.dataset.answered!==`true`);let e=Ha();Va(e),L({event:`question_marked_answered`,answered:e.length,total:document.querySelectorAll(`[data-question-answered]`).length});return}let _=t.closest(`[data-issue-dismissed]`);if(_?.dataset.issueDismissed){Ka(_,_.dataset.stale===`true`||_.dataset.dismissed!==`true`);let e=Wa();Ga(e),L({event:`issue_dismissed`,dismissed:e.length,total:document.querySelectorAll(`[data-issue-dismissed]`).length});return}let v=t.closest(`[data-suggestion]`);if(v){Fa(v.textContent??``,`suggestion`);return}if(t.closest(`.pr-helper-explain-simply-button`)){lo(),Fa(ra,`explain_simply`);return}let ee=t.closest(`[data-prompt-use]`);if(ee?.dataset.promptUse){Po(ee.dataset.promptUse);return}let te=t.closest(`[data-prompt-edit]`);if(te?.dataset.promptEdit){Qo(te.dataset.promptEdit);return}if(t.closest(`[data-prompt-add]`)){Qo(``);return}if(t.closest(`[data-ask-toggle]`)){let e=R?.focus;e?(wt(R,fa),so(e!==`buddy`)):so(!oo())}});var W=document.querySelector(`.prb-body`),ao=document.querySelector(`.prb-ask`);function oo(){return!!ao&&getComputedStyle(ao).display!==`none`}function so(e){W&&(W.dataset.ask=e?`open`:`closed`),co(e)}function co(e){for(let t of document.querySelectorAll(`[data-ask-toggle]`))t.setAttribute(`aria-expanded`,String(e))}function lo(){R?.focus&&R.focus!==`buddy`&&wt(R,fa),so(!0)}function uo(){co(oo())}window.addEventListener(`resize`,uo),n(I(`/restart`));var fo=document.querySelector(`[data-file-filter]`),po=document.querySelector(`[data-file-count]`),mo=document.querySelector(`[data-file-none]`);function ho(){let e=(fo?.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}`}mo&&(mo.hidden=n>0),po&&(po.textContent=e?`${t} of ${go} file${go===1?``:`s`}`:`${go} file${go===1?``:`s`}`)}var go=document.querySelectorAll(`[data-view="files"] .prb-file:not(.prb-file-referenced)`).length;fo?.addEventListener(`input`,ho),fo?.addEventListener(`keydown`,e=>{e.key===`Escape`&&fo.value!==``&&(e.preventDefault(),fo.value=``,ho())}),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(),Ea(n))});var _o=320,vo=()=>Math.round(window.innerWidth/2),yo=e=>Math.round(Math.min(vo(),Math.max(_o,e)));function bo(e){W&&(e===null?W.style.removeProperty(`--ask-width`):W.style.setProperty(`--ask-width`,`${e}px`))}function xo(){return ao?Math.round(ao.getBoundingClientRect().width):_o}function So(e){fetch(I(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({askWidth:e})}).catch(()=>{})}var G=document.querySelector(`[data-ask-resize]`);G?.addEventListener(`pointerdown`,e=>{if(e.button!==0||!W||!ao)return;e.preventDefault(),G.setPointerCapture(e.pointerId),W.dataset.resizing=`true`;let t=e.clientX,n=xo(),r=e=>{bo(yo(n+(t-e.clientX)))},i=()=>{G.removeEventListener(`pointermove`,r),G.removeEventListener(`pointerup`,i),G.removeEventListener(`pointercancel`,i),delete W.dataset.resizing,So(xo())};G.addEventListener(`pointermove`,r),G.addEventListener(`pointerup`,i),G.addEventListener(`pointercancel`,i)}),G?.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=yo(xo()+n);bo(r),So(r);return}(e.key===`Home`||e.key===`Escape`)&&(e.preventDefault(),bo(null),So(null))}),G?.addEventListener(`dblclick`,()=>{bo(null),So(null)}),window.addEventListener(`resize`,()=>{oo()&&W?.style.getPropertyValue(`--ask-width`)&&bo(yo(xo()))});var Co=3e4,wo=document.visibilityState===`visible`?Date.now():null,To=0;function Eo(){wo!==null&&(To+=Date.now()-wo,wo=Date.now())}function Do(){Eo();let e=Math.round(To/1e3);return To-=e*1e3,e}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`?wo=Date.now():(Eo(),wo=null)}),setInterval(()=>{let e=Do();e>0&&L({event:`workspace_heartbeat`,visibleSeconds:e})},Co),window.addEventListener(`pagehide`,()=>{let e=I(`/event`),t=JSON.stringify({event:`review_completed`,trailingSeconds:Do()});navigator.sendBeacon?.(e,new Blob([t],{type:`application/json`}))||fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:t,keepalive:!0}).catch(()=>{})});var Oo=document.querySelector(`[data-prompt-bank]`),ko=document.querySelector(`[data-prompt-list]`),K=Ao();function Ao(){try{let e=JSON.parse(Oo?.dataset.prompts??`[]`);return Array.isArray(e)?e:[]}catch{return[]}}function jo(){if(!ko)return;ko.innerHTML=K.map(e=>`<span class="prb-bank-item">
|
|
149
149
|
<button type="button" class="prb-bank-use" data-prompt-use="${z(e.id)}" title="${z(e.prompt)}">${z(e.name)}</button>
|
|
150
150
|
<button type="button" class="prb-bank-edit" data-prompt-edit="${z(e.id)}" aria-label="Edit ${z(e.name)}">✎</button>
|
|
151
|
-
</span>`).join(``);let e=document.querySelector(`[data-prompt-count]`);e&&(e.textContent=String(K.length)),So()}async function mo(e){try{let t=await(await fetch(I(`/prompts`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({prompts:e})})).json().catch(()=>null);K=Array.isArray(t?.prompts)?t.prompts:K}catch{}po()}function ho(e){document.querySelector(`[data-prompt-toggle]`)?.setAttribute(`aria-expanded`,String(!e)),lo?.toggleAttribute(`data-collapsed`,e),uo&&(uo.hidden=e),fetch(I(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({promptsCollapsed:e})}).catch(()=>{})}function go(e){let t=K.find(t=>t.id===e);!t||!V||(V.value=Lt(V.value,t.prompt),Ga(),V.focus(),V.setSelectionRange(V.value.length,V.value.length),V.dispatchEvent(new Event(`input`)))}var _o=document.querySelector(`.prb-doc`),vo=null,yo=null;function bo(){B&&(yo?.(),yo=Ge(B,{layout:`flat`,actions:Je.map(e=>({id:e.id,label:e.label})),onChoose:(e,t)=>Co(e,`selection`,t)}))}function xo(){return[...Ke.map(e=>({id:e.id,label:e.label})),...K.map(e=>({id:et(e.id),label:e.name,section:$e}))]}function So(){_o&&(vo?.(),vo=Ge(_o,{triggerLabel:`Ask Buddy AI`,actions:xo(),ignoreWithin:`[data-ask-buddy-menu]`,onChoose:(e,t)=>Co(e,`selection`,t)}))}function Co(e,t,n){St(e,{context:t,text:n},{savedPrompt:e=>K.find(t=>t.id===e)?.prompt??null,stage:e=>wo(e,t),send:e=>{Ga(),va(e,`finding`)}})}function wo(e,t){V&&(Sa={text:e,source:t},V.value=Lt(V.value,e),Ga(),V.focus(),V.setSelectionRange(V.value.length,V.value.length),V.dispatchEvent(new Event(`input`)))}function To(e){return e.closest(`[data-finding-card]`)?.querySelector(`[data-copy-source]`)?.getAttribute(`data-copy-source`)??``}function Eo(e){let t=e.querySelector(`[data-menu-panel]`);if(t){t.innerHTML=Le(xo());for(let e of t.querySelectorAll(`[data-selection-action]`))e.setAttribute(`role`,`menuitem`);if(H||U)for(let e of t.querySelectorAll(`button`))e.disabled=!0}}function Do(e){let t=e.querySelector(`[data-menu-items]`),n=e.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!1),n&&(n.hidden=!0),e.querySelector(`[data-menu-error]`)?.remove()}document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-ask-buddy-menu] [data-selection-action]`),n=t?.closest(`[data-ask-buddy-menu]`),r=t?.dataset.selectionAction;if(!n||!r)return;let i=To(n);Xi.close(n),i&&Co(r,`finding`,i)}),So(),bo(),ye(document);var Oo=document.querySelector(`[data-prompt-dialog]`),ko=document.querySelector(`[data-prompt-name]`),Ao=document.querySelector(`[data-prompt-text]`),jo=document.querySelector(`[data-prompt-delete]`),Mo=document.getElementById(`prb-prompt-title`),No=``;function Po(e){let t=K.find(t=>t.id===e);No=t?.id??``,Mo&&(Mo.textContent=t?`Edit prompt`:`Save a prompt`),ko&&(ko.value=t?.name??``),Ao&&(Ao.value=t?.prompt??``),jo&&(jo.hidden=!t),Oo?.showModal(),ko?.focus()}async function Fo(){let e=ko?.value.trim()??``,t=Ao?.value.trim()??``;if(!e||!t){(e?Ao:ko)?.focus();return}let n=No?K.map(n=>n.id===No?{...n,name:e,prompt:t}:n):[...K,{id:crypto.randomUUID(),name:e,prompt:t}];Oo?.close(),await mo(n)}async function Io(){if(!No)return;let e=K.filter(e=>e.id!==No);Oo?.close(),await mo(e)}document.querySelector(`[data-prompt-cancel]`)?.addEventListener(`click`,()=>Oo?.close()),jo?.addEventListener(`click`,()=>void Io()),document.querySelector(`[data-prompt-save]`)?.addEventListener(`click`,()=>void Fo());var Lo=document.querySelector(`[data-complete]`);Lo?.addEventListener(`click`,()=>{let e=Lo.getAttribute(`aria-pressed`)!==`true`;Ro(e),fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({complete:e})}).then(async e=>{let t=await e.json().catch(()=>null);t&&Ro(t.completedAt!==null)}).catch(()=>Ro(!e))});function Ro(e){Lo&&(Lo.setAttribute(`aria-pressed`,String(e)),Lo.textContent=e?`Reviewed`:`Mark reviewed`)}var q=document.querySelector(`[data-fresh-region]`),J=document.querySelector(`[data-fresh-status]`),zo=document.querySelector(`[data-fresh-check]`),Y=Jo(q?.dataset.report),Bo=`prb-fresh-reopen`,Vo=Ko(),Ho=q?.dataset.dismissedSha,Uo=Go(q?.dataset.availability),X=Wo(q?.dataset.remote);function Wo(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Go(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Ko(){try{return sessionStorage.getItem(Bo)!==null&&(sessionStorage.removeItem(Bo),!0)}catch{return!1}}Vo&&os(),zo?.addEventListener(`click`,()=>void Yo()),q?.addEventListener(`click`,e=>{let t=e.target;if(t.closest(`[data-fresh-close]`))return Vo=!1,os();let n=t.closest(`[data-fresh-dismiss]`);n&&(Ho=n.dataset.freshDismiss||void 0,Vo=!1,os(),qo())});function qo(){fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissFreshnessSha:Ho??null})}).catch(()=>{})}function Jo(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}var Z=!1;async function Yo(){if(Z)return;Z=!0,es(!0);let e=ts(Y,X),t=await Xo(!1);t&&as(),Z=!1,t&&(Y?.code.state===`changed`||X!==null)&&Ho!==void 0&&(Ho=void 0,qo()),os();let n=t?ts(Y,X)===e?`No change`:`Updated`:`Could not check`;zo&&cs(zo,n,2600)}async function Xo(e){try{let t=await(await fetch(`${I(`/freshness`)}${e?`&quiet=1`:``}`)).json();return Y=t.report??null,Uo=t.availability??null,X=t.remote??null,ns=t.kiss??null,t.kissDismissedSha!==void 0&&(rs=t.kissDismissedSha??void 0),t.prState!==void 0&&$o(t.prState),!0}catch{return!1}}async function Zo(){if(Z||!q)return;Z=!0;let e=ts(Y,X),t=JSON.stringify(ns),n=await Xo(!0);Z=!1,Qo=Date.now(),n&&(ts(Y,X)!==e&&os(),JSON.stringify(ns)!==t&&as())}var Qo=Date.now();function $o(e){let t=document.querySelector(`[data-pr-state-slot]`);if(!t)return;let n=un(e,t.hasAttribute(`data-beside-number`));t.innerHTML!==n&&(t.innerHTML=n)}function es(e){zo&&(zo.disabled=e),J&&e&&(J.textContent=`Checking…`,J.dataset.state=`checking`)}function ts(e,t){if(!e)return JSON.stringify({report:`none`,remote:t});let{checkedAt:n,...r}=e;return JSON.stringify({...r,remote:t})}var Q=document.querySelector(`[data-kiss-fresh-region]`),ns=is(Q?.dataset.freshness),rs=Q?.dataset.dismissedSha;function is(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function as(){Q&&(Q.innerHTML=ln(Q.dataset.reviewedSha??``,ns,{dismissedSha:rs,actions:Ii!==``}))}Q?.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-freshness-dismiss]`);t&&(rs=t.dataset.kissFreshnessDismiss||void 0,as(),fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissKissFreshnessSha:rs??null})}).catch(()=>{}))});function os(){if(q&&(q.innerHTML=Wt(Y,{dismissedSha:Ho,open:Vo,actions:Ii!==``,availability:Uo,remote:X}),J&&(Y||X))){let{label:e,state:t}=Ut(Y,X);J.textContent=e,J.dataset.state=t}}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-copy-command]`);if(n)return ss(n);let r=t.closest(`[data-notice-dismiss]`);if(r){r.closest(`[data-notice]`)?.remove(),fetch(I(`/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 ls(i);let a=t.closest(`[data-review-update]`);if(a)return void fs(a);t.closest(`[data-update-close]`)&&document.querySelector(`[data-update-result]`)?.remove()});function ss(e){let t=e.dataset.copyCommand??``;navigator.clipboard?.writeText(t).then(()=>cs(e,`Copied`),()=>cs(e,`Select it`))}function cs(e,t,n=1400){let r=e.textContent;e.textContent=t,setTimeout(()=>{e.textContent=r},n)}async function ls(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=us(n);t?t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Re-checking the conversation, ${e}s. ${ps}`:n.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Checking… ${e}s`}};r();let i=window.setInterval(r,1e3),a=us(e)?null:ms(e);try{await fetch(I(`/refresh`),{method:`POST`})}catch{}finally{window.clearInterval(i),a?.remove()}us(e)&&ds(),window.location.reload()}function us(e){return e.closest(`.prb-fresh-notes p`)}function ds(){try{sessionStorage.setItem(Bo,`1`)}catch{}}async function fs(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(I(`/job`))).json();e.update&&e.update.phase!==`none`&&!tn(e.update.phase)&&r()}catch{}},500);try{await fetch(I(`/update`),{method:`POST`})}catch{}r()}var ps=`Fetching the latest threads from your pull request. This usually takes under a minute.`;function ms(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=ps,t.appendChild(n),n}var hs=pn(document),gs=null,_s=Date.now();function vs(){gs===null&&(gs=window.setTimeout(()=>{gs=null,ys()},o(Date.now()-_s)))}async function ys(){try{let e=await(await fetch(I(`/job`))).json();if(U&&!e.ask||xs&&!e.diagram){window.location.reload();return}let t={job:e,kiss:e.kiss,update:e.update};for(let[e,n]of hs){let r=t[e];if(r){if(mn(e,r,document)){window.location.reload();return}e===`update`||n.matches(`[data-progress-pane]`)?(gn(n,r.phase,r.progress),_n(n)):bs(n,r.progress)}}}catch{}vs()}function bs(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 xs=document.querySelector(`[data-diagram-running]`)!==null;(hs.size>0||U||xs)&&(_s=Date.now(),vs());function Ss(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 Cs(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…`,Cs(t),fetch(I(`/retry`),{method:`POST`}).then(e=>{if(!e.ok)throw Error(`refused`);_s=Date.now(),vs()}).catch(()=>{t.disabled=!1,t.textContent=`Retry`,Ss(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(I(`/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 ws=document.body.dataset.defaultView||`overview`;window.addEventListener(`popstate`,e=>{Ji(e.state??ft(window.location.hash)??{kind:`view`,view:ws})});var Ts=ft(window.location.hash);Ts?Ji(Ts):(R={kind:`view`,view:ws},history.replaceState(R,``,window.location.pathname+window.location.search)),Ka(),sa();var Es=e=>{for(let t of document.querySelectorAll(`[data-analysis-details][open]`))(!e||!t.contains(e))&&(t.open=!1)};document.addEventListener(`click`,e=>{Es(e.target)}),document.addEventListener(`keydown`,e=>{if(e.key!==`Escape`)return;let t=document.querySelector(`[data-analysis-details][open]`);t&&(Es(),t.querySelector(`summary`)?.focus())});var $=document.querySelector(`.prb-header [data-menu]`);if($){let e=$.querySelector(`[data-menu-panel]`),t=$.querySelector(`[data-menu-items]`),n=$.querySelector(`[data-menu-confirm]`),r=$.querySelector(`[data-confirm-delete]`),o=()=>Do($);$.addEventListener(`click`,e=>{let r=e.target,i=r?.closest(`[data-copy-id]`);if(i?.dataset.copyId){e.stopPropagation(),a(i,i.dataset.copyId);return}let l=r?.closest(`[data-save-toggle]`);if(l){e.stopPropagation(),s(l);return}if(r?.closest(`[data-delete]`)){e.stopPropagation(),t&&(t.hidden=!0),n&&(n.hidden=!1);return}if(r?.closest(`[data-cancel-delete]`)){e.stopPropagation(),o();return}r?.closest(`[data-confirm-delete]`)&&(e.stopPropagation(),c())});let s=async e=>{let t=e.getAttribute(`aria-pressed`)!==`true`;e.disabled=!0;let n=null;try{let e=await fetch(I(`/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)},c=async()=>{r&&(r.disabled=!0,r.textContent=`Deleting`);let t;try{let e=await fetch(I(`/delete`),{method:`POST`});if(e.ok)return void window.location.replace(`/`);t=(await e.json().catch(()=>null))?.error??`That could not be deleted.`}catch{t=`The workspace server did not answer. It may have stopped.`}r&&(r.disabled=!1,r.textContent=`Delete`),o();let n=document.createElement(`p`);n.className=`prb-menu-error`,n.setAttribute(`data-menu-error`,``),n.textContent=t,e?.append(n)}}t(),setTimeout(()=>{Oi(bi([...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 Ds=15e3,Os=6e4;function ks(){return Ii!==``&&document.visibilityState===`visible`&&!hs.has(`update`)}document.addEventListener(`visibilitychange`,()=>{ks()&&Date.now()-Qo>=Ds&&Zo()}),window.setInterval(()=>{ks()&&Zo()},Os);export{O as t};
|
|
151
|
+
</span>`).join(``);let e=document.querySelector(`[data-prompt-count]`);e&&(e.textContent=String(K.length)),Bo()}async function Mo(e){try{let t=await(await fetch(I(`/prompts`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({prompts:e})})).json().catch(()=>null);K=Array.isArray(t?.prompts)?t.prompts:K}catch{}jo()}function No(e){document.querySelector(`[data-prompt-toggle]`)?.setAttribute(`aria-expanded`,String(!e)),Oo?.toggleAttribute(`data-collapsed`,e),ko&&(ko.hidden=e),fetch(I(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({promptsCollapsed:e})}).catch(()=>{})}function Po(e){let t=K.find(t=>t.id===e);!t||!V||(V.value=Ut(V.value,t.prompt),lo(),V.focus(),V.setSelectionRange(V.value.length,V.value.length),V.dispatchEvent(new Event(`input`)))}var Fo=document.querySelector(`.prb-doc`),Io=null,Lo=null;function Ro(){B&&(Lo?.(),Lo=Ze(B,{layout:`flat`,actions:et.map(e=>({id:e.id,label:e.label})),onChoose:(e,t)=>Vo(e,`selection`,t)}))}function zo(){return[...Qe.map(e=>({id:e.id,label:e.label})),...K.map(e=>({id:ot(e.id),label:e.name,section:at}))]}function Bo(){Fo&&(Io?.(),Io=Ze(Fo,{triggerLabel:`Ask Buddy AI`,actions:zo(),ignoreWithin:`[data-ask-buddy-menu]`,onChoose:(e,t)=>Vo(e,`selection`,t)}))}function Vo(e,t,n){Ot(e,{context:t,text:n},{savedPrompt:e=>K.find(t=>t.id===e)?.prompt??null,stage:e=>Ho(e,t),send:e=>{lo(),Fa(e,`finding`)}})}function Ho(e,t){V&&(za={text:e,source:t},V.value=Ut(V.value,e),lo(),V.focus(),V.setSelectionRange(V.value.length,V.value.length),V.dispatchEvent(new Event(`input`)))}function Uo(e){return e.closest(`[data-finding-card]`)?.querySelector(`[data-copy-source]`)?.getAttribute(`data-copy-source`)??``}function Wo(e){let t=e.querySelector(`[data-menu-panel]`);if(t){t.innerHTML=Ue(zo());for(let e of t.querySelectorAll(`[data-selection-action]`))e.setAttribute(`role`,`menuitem`);if(H||U)for(let e of t.querySelectorAll(`button`))e.disabled=!0}}function Go(e){let t=e.querySelector(`[data-menu-items]`),n=e.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!1),n&&(n.hidden=!0),e.querySelector(`[data-menu-error]`)?.remove()}document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-ask-buddy-menu] [data-selection-action]`),n=t?.closest(`[data-ask-buddy-menu]`),r=t?.dataset.selectionAction;if(!n||!r)return;let i=Uo(n);pa.close(n),i&&Vo(r,`finding`,i)}),Bo(),Ro(),Te(document);var Ko=document.querySelector(`[data-prompt-dialog]`),qo=document.querySelector(`[data-prompt-name]`),Jo=document.querySelector(`[data-prompt-text]`),Yo=document.querySelector(`[data-prompt-delete]`),Xo=document.getElementById(`prb-prompt-title`),Zo=``;function Qo(e){let t=K.find(t=>t.id===e);Zo=t?.id??``,Xo&&(Xo.textContent=t?`Edit prompt`:`Save a prompt`),qo&&(qo.value=t?.name??``),Jo&&(Jo.value=t?.prompt??``),Yo&&(Yo.hidden=!t),Ko?.showModal(),qo?.focus()}async function $o(){let e=qo?.value.trim()??``,t=Jo?.value.trim()??``;if(!e||!t){(e?Jo:qo)?.focus();return}let n=Zo?K.map(n=>n.id===Zo?{...n,name:e,prompt:t}:n):[...K,{id:crypto.randomUUID(),name:e,prompt:t}];Ko?.close(),await Mo(n)}async function es(){if(!Zo)return;let e=K.filter(e=>e.id!==Zo);Ko?.close(),await Mo(e)}document.querySelector(`[data-prompt-cancel]`)?.addEventListener(`click`,()=>Ko?.close()),Yo?.addEventListener(`click`,()=>void es()),document.querySelector(`[data-prompt-save]`)?.addEventListener(`click`,()=>void $o());var q=document.querySelector(`[data-fresh-region]`),J=document.querySelector(`[data-fresh-status]`),ts=document.querySelector(`[data-fresh-check]`),Y=us(q?.dataset.report),ns=`prb-fresh-reopen`,rs=cs(),is=q?.dataset.dismissedSha,as=ss(q?.dataset.availability),X=os(q?.dataset.remote);function os(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function ss(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function cs(){try{return sessionStorage.getItem(ns)!==null&&(sessionStorage.removeItem(ns),!0)}catch{return!1}}rs&&Ts(),ts?.addEventListener(`click`,()=>void ps()),q?.addEventListener(`click`,e=>{let t=e.target;if(t.closest(`[data-fresh-close]`))return rs=!1,Ts();let n=t.closest(`[data-fresh-dismiss]`);n&&(is=n.dataset.freshDismiss||void 0,rs=!1,Ts(),ls())});function ls(){fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissFreshnessSha:is??null})}).catch(()=>{})}function us(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}var ds=Dn(),fs=!1,Z=null;async function ps(){if(fs)return;fs=!0,ys(!0),Z&&await Z;let e=bs(Y,X),t=await hs(!1);ys(!1),t&&ws(),fs=!1,t&&(Y?.code.state===`changed`||X!==null)&&is!==void 0&&(is=void 0,ls()),Ts(),ms(t?bs(Y,X)===e?`No change`:`Updated`:`Could not check`)}function ms(e){J&&(J.textContent=e,window.setTimeout(Es,2600))}async function hs(e){let t=ds.snapshot();try{let n=await(await fetch(`${I(`/freshness`)}${e?`&quiet=1`:``}`)).json();Y=n.report??null,as=n.availability??null,X=n.remote??null,xs=n.kiss??null,n.kissDismissedSha!==void 0&&(Ss=n.kissDismissedSha??void 0),n.prState!==void 0&&vs(n.prState);let r=En(n.standing);return r&&ds.current(t)&&_n(document,r),!0}catch{return!1}}async function gs(){if(fs||Z||!q)return;let e=bs(Y,X),t=JSON.stringify(xs);Z=hs(!0);let n=await Z;Z=null,_s=Date.now(),n&&(bs(Y,X)!==e&&Ts(),JSON.stringify(xs)!==t&&ws())}var _s=Date.now();function vs(e){let t=document.querySelector(`[data-pr-state-slot]`);if(!t)return;let n=gn(e,t.hasAttribute(`data-beside-number`));t.innerHTML!==n&&(t.innerHTML=n)}function ys(e){ts&&(ts.disabled=e),J&&e&&(J.textContent=`Checking…`,J.dataset.state=`checking`)}function bs(e,t){if(!e)return JSON.stringify({report:`none`,remote:t});let{checkedAt:n,...r}=e;return JSON.stringify({...r,remote:t})}var Q=document.querySelector(`[data-kiss-fresh-region]`),xs=Cs(Q?.dataset.freshness),Ss=Q?.dataset.dismissedSha;function Cs(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function ws(){Q&&(Q.innerHTML=hn(Q.dataset.reviewedSha??``,xs,{dismissedSha:Ss,actions:$i!==``}))}Q?.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-freshness-dismiss]`);t&&(Ss=t.dataset.kissFreshnessDismiss||void 0,ws(),fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissKissFreshnessSha:Ss??null})}).catch(()=>{}))});function Ts(){q&&(q.innerHTML=Xt(Y,{dismissedSha:is,open:rs,actions:$i!==``,availability:as,remote:X}),Es())}function Es(){if(J&&(Y||X)){let{label:e,state:t}=Yt(Y,X);J.textContent=e,J.dataset.state=t}}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-copy-command]`);if(n)return Ds(n);let r=t.closest(`[data-notice-dismiss]`);if(r){r.closest(`[data-notice]`)?.remove(),fetch(I(`/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 ks(i);let a=t.closest(`[data-review-update]`);if(a)return void Ms(a);t.closest(`[data-update-close]`)&&document.querySelector(`[data-update-result]`)?.remove()});function Ds(e){let t=e.dataset.copyCommand??``;navigator.clipboard?.writeText(t).then(()=>Os(e,`Copied`),()=>Os(e,`Select it`))}function Os(e,t,n=1400){let r=e.textContent;e.textContent=t,setTimeout(()=>{e.textContent=r},n)}async function ks(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=As(n);t?t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Re-checking the conversation, ${e}s. ${Ns}`:n.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Checking… ${e}s`}};r();let i=window.setInterval(r,1e3),a=As(e)?null:Ps(e);try{await fetch(I(`/refresh`),{method:`POST`})}catch{}finally{window.clearInterval(i),a?.remove()}As(e)&&js(),window.location.reload()}function As(e){return e.closest(`.prb-fresh-notes p`)}function js(){try{sessionStorage.setItem(ns,`1`)}catch{}}async function Ms(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(I(`/job`))).json();e.update&&e.update.phase!==`none`&&!cn(e.update.phase)&&r()}catch{}},500);try{await fetch(I(`/update`),{method:`POST`})}catch{}r()}var Ns=`Fetching the latest threads from your pull request. This usually takes under a minute.`;function Ps(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=Ns,t.appendChild(n),n}var Fs=An(document),Is=null,Ls=Date.now();function Rs(){Is===null&&(Is=window.setTimeout(()=>{Is=null,zs()},i(Date.now()-Ls)))}async function zs(){try{let e=await(await fetch(I(`/job`))).json();if(U&&!e.ask||Vs&&!e.diagram){window.location.reload();return}let t={job:e,kiss:e.kiss,update:e.update};for(let[e,n]of Fs){let r=t[e];if(r){if(jn(e,r,document)){window.location.reload();return}e===`update`||n.matches(`[data-progress-pane]`)?(Nn(n,r.phase,r.progress),Pn(n)):Bs(n,r.progress)}}}catch{}Rs()}function Bs(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 Vs=document.querySelector(`[data-diagram-running]`)!==null;(Fs.size>0||U||Vs)&&(Ls=Date.now(),Rs());function Hs(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 Us(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…`,Us(t),fetch(I(`/retry`),{method:`POST`}).then(e=>{if(!e.ok)throw Error(`refused`);Ls=Date.now(),Rs()}).catch(()=>{t.disabled=!1,t.textContent=`Retry`,Hs(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(I(`/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 Ws=document.body.dataset.defaultView||`overview`;window.addEventListener(`popstate`,e=>{da(e.state??vt(window.location.hash)??{kind:`view`,view:Ws})});var Gs=vt(window.location.hash);Gs?da(Gs):(R={kind:`view`,view:Ws},history.replaceState(R,``,window.location.pathname+window.location.search)),uo(),wa();var Ks=e=>{for(let t of document.querySelectorAll(`[data-analysis-details][open]`))(!e||!t.contains(e))&&(t.open=!1)};document.addEventListener(`click`,e=>{Ks(e.target)}),document.addEventListener(`keydown`,e=>{if(e.key!==`Escape`)return;let t=document.querySelector(`[data-analysis-details][open]`);t&&(Ks(),t.querySelector(`summary`)?.focus())});var $=document.querySelector(`.prb-header [data-menu]`);if($){let e=$.querySelector(`[data-menu-panel]`),t=$.querySelector(`[data-menu-items]`),n=$.querySelector(`[data-menu-confirm]`),i=$.querySelector(`[data-confirm-delete]`),o=()=>Go($);$.addEventListener(`click`,e=>{let i=e.target,a=i?.closest(`[data-copy-id]`);if(a?.dataset.copyId){e.stopPropagation(),r(a,a.dataset.copyId);return}let u=i?.closest(`[data-save-toggle]`);if(u){e.stopPropagation(),c(u);return}if(i?.closest(`[data-fresh-check]`)){pa.closeAll();return}let d=i?.closest(`[data-mark-status]`);if(d){e.stopPropagation(),s(d,`/state`,{complete:d.dataset.markStatus===`complete`},e=>({complete:typeof e.completedAt==`number`,queued:e.queued===!0}));return}let f=i?.closest(`[data-lifecycle-set]`);if(f){e.stopPropagation(),s(f,`/lifecycle`,{state:f.dataset.lifecycleSet},e=>({lifecycle:wn(e.lifecycle),queued:e.queued===!0}));return}let p=i?.closest(`[data-queue-action]`);if(p){e.stopPropagation(),s(p,`/queue`,{action:p.dataset.queueAction},e=>({lifecycle:wn(e.lifecycle),queued:e.queued===!0}));return}if(i?.closest(`[data-delete]`)){e.stopPropagation(),t&&(t.hidden=!0),n&&(n.hidden=!1);return}if(i?.closest(`[data-cancel-delete]`)){e.stopPropagation(),o();return}i?.closest(`[data-confirm-delete]`)&&(e.stopPropagation(),l())});let s=async(t,n,r,i)=>{$.querySelector(`[data-menu-error]`)?.remove(),t.disabled=!0;let a=ds.begin(),o=null;try{let e=await fetch(I(n),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(r)}),t=await e.json().catch(()=>null);e.ok&&t?_n(document,i(t)):o=typeof t?.error==`string`?t.error:`That could not be changed.`}catch{o=`The workspace server did not answer. It may have stopped.`}finally{a()}if(t.disabled=!1,o===null)return void pa.closeAll();let s=document.createElement(`p`);s.className=`prb-menu-error`,s.setAttribute(`data-menu-error`,``),s.textContent=o,e?.append(s)},c=async e=>{let t=e.getAttribute(`aria-pressed`)!==`true`;e.disabled=!0;let n=null;try{let e=await fetch(I(`/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=a(e.getAttribute(`aria-pressed`)===`true`)},1600);return}e.setAttribute(`aria-pressed`,String(n)),e.textContent=a(n)},l=async()=>{i&&(i.disabled=!0,i.textContent=`Deleting`);let t;try{let e=await fetch(I(`/delete`),{method:`POST`});if(e.ok)return void window.location.replace(`/`);t=(await e.json().catch(()=>null))?.error??`That could not be deleted.`}catch{t=`The workspace server did not answer. It may have stopped.`}i&&(i.disabled=!1,i.textContent=`Delete`),o();let n=document.createElement(`p`);n.className=`prb-menu-error`,n.setAttribute(`data-menu-error`,``),n.textContent=t,e?.append(n)}}t(),setTimeout(()=>{Gi(Li([...document.querySelectorAll(`[data-view="files"] [data-file]`)].map(e=>e.dataset.file??``)))},0),e(window,()=>window.location.reload()),d(window,document.querySelector(`main.prb-doc`));var qs=15e3,Js=6e4;function Ys(){return $i!==``&&document.visibilityState===`visible`&&!Fs.has(`update`)}document.addEventListener(`visibilitychange`,()=>{Ys()&&Date.now()-_s>=qs&&gs()}),window.setInterval(()=>{Ys()&&gs()},Js);export{O as t};
|