prreviewbuddy 0.64.2 → 0.69.1

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.
@@ -1,16 +1,16 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunk-D6oLtkSC.js","chunk-CvSN2dS5.js","chunk-DsF7k-Jl.js","chunk-BWjKdrB5.js","chunk-hePW80VL.js","chunk-DIEkEPeW.js","chunk-D7hFEgee.js","chunk-B2kMZj3m.js","chunk-BXful7fw.js","chunk-9OYdRhXM.js","chunk-DyBGMc4d.js","chunk-D71XVZIg.js","chunk-Dy-Kn_BL.js","chunk-B-Up-Dum.js","chunk-CCkeMk9N.js","chunk-DwHSAwhM.js","chunk-fybaL0A-.js","chunk-BifhSqXX.js","chunk-DS17s2tU.js","chunk-Baon_ihZ.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{B as e,D as t,E as n,F as r,G as i,H as a,I as o,K as s,L as c,N as l,P as u,R as d,V as f,W as ee,Y as te,a as p,i as m,o as ne,q as h,t as re,u as ie,w as g,z as ae}from"./chunk-CXf6hwXL.js";import{i as oe,o as _,s as se}from"./chunk-CndkgJPh.js";import{t as v}from"./chunk-CvSN2dS5.js";function y(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function ce(e){return y(e).replace(/`([^`\n]+)`/g,`<code>$1</code>`)}var le=`pr-helper-code-block`,ue=`pr-helper-code-copy`,de=/^\u0002(\d+)\u0002/,fe=/^(?:https?:\/\/|#)/i,pe=/^https:\/\//i,me=/^(?:image|img|screenshot|screen ?shot|picture|photo|pic)$/i,he=/\.(?:png|jpe?g|gif|webp|svg|bmp|heic|avif|tiff?)$/i;function ge(e){let t=(e??``).trim();return!t||me.test(t)||he.test(t)?`View attached image`:`View image: ${t}`}function _e(e,t){return pe.test(e)?`<a href="${e}" target="_blank" rel="noopener noreferrer">${t}</a>`:null}function ve(e,t){return _e(y((e??``).trim()),y(t))}var b=e=>/^(?:left|right|center|justify)$/i.test(e)?e.toLowerCase():null,ye=e=>/^[1-9]\d{0,2}$/.test(e)?e:null,be=e=>/^\d{1,9}$/.test(e)?e:null,xe=e=>e.slice(0,300),Se=new Map(Object.entries({a:{href:e=>{let t=e.trim();return fe.test(t)?t:null},title:xe},abbr:{title:xe},b:{},blockquote:{},br:{},caption:{align:b},cite:{},code:{},dd:{},del:{},details:{},div:{align:b},dl:{},dt:{},em:{},hr:{},i:{},ins:{},kbd:{},li:{},mark:{},ol:{start:be},p:{align:b},q:{},s:{},samp:{},small:{},span:{},strike:{},strong:{},sub:{},summary:{},sup:{},table:{align:b},tbody:{},td:{align:b,colspan:ye,rowspan:ye},tfoot:{},th:{align:b,colspan:ye,rowspan:ye},thead:{},tr:{align:b},u:{},ul:{},var:{},h1:{align:b},h2:{align:b},h3:{align:b},h4:{align:b},h5:{align:b},h6:{align:b}}).map(([e,t])=>[e,new Map(Object.entries({title:xe,...t}))])),Ce=new Set([`br`,`hr`,`img`,`input`,`source`,`meta`,`link`,`base`,`wbr`,`col`,`area`,`track`,`param`,`embed`]),we=new Set([`script`,`style`,`iframe`,`object`,`embed`,`svg`,`math`,`template`,`noscript`,`textarea`,`frame`,`frameset`,`applet`,`head`,`title`,`select`]),Te=new Set(`picture.pre.source.track.input.form.label.button.option.optgroup.font.center.section.article.header.footer.nav.figure.figcaption.main.aside.html.body.meta.link.base.wbr.col.colgroup.area.map.param.fieldset.legend.dialog`.split(`.`)),Ee=new Set(`address.article.aside.blockquote.caption.center.dd.details.dialog.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.nav.ol.p.pre.section.summary.table.tbody.td.tfoot.th.thead.tr.ul`.split(`.`)),De=new RegExp(["`[^`\\n]+`",`<(\\/?)([A-Za-z][A-Za-z0-9-]*)((?:\\s+[^\\s"'<>\\/=]+(?:\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s"'=<>\`]+))?)*)\\s*(\\/?)>`,`&(?:#\\d{1,7}|#[xX][0-9a-fA-F]{1,6}|[A-Za-z][A-Za-z0-9]{1,31});`].join(`|`),`g`),Oe=/([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;function ke(e){return e.replace(/&(#\d{1,7}|#[xX][0-9a-fA-F]{1,6}|amp|lt|gt|quot|apos|nbsp);/g,(e,t)=>{if(t[0]===`#`){let e=t[1]===`x`||t[1]===`X`?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return e>0&&e<=1114111?String.fromCodePoint(e):``}return{amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`,nbsp:`\xA0`}[t]??``})}function Ae(e){let t=new Map;for(let n of e.matchAll(Oe)){let e=n[1].toLowerCase();t.has(e)||t.set(e,ke(n[2]??n[3]??n[4]??``))}return t}function je(e){let t=e.match(/^h([1-6])$/);return t?`h${Math.min(Number(t[1]),3)+3}`:e}function Me(e,t){let n=je(e),r=Se.get(e),i=[];for(let[e,n]of Ae(t)){let t=r.get(e),a=t?t(n):null;a!==null&&i.push(` ${e}="${y(a)}"`)}return e===`a`&&i.some(e=>e.startsWith(` href=`))&&i.push(` target="_blank" rel="noopener noreferrer"`),`<${n}${i.join(``)}>`}function Ne(e){let t=[],n=e=>`${t.push(e)-1}`,r=``,i=0;De.lastIndex=0;for(let t;t=De.exec(e);){let[a,o,s,c,l]=t,u=null;if(a[0]===`&`)u=n({kind:`entity`,name:``,tag:``,markup:a});else if(s){let t=s.toLowerCase();if(t===`img`){let e=Ae(c),r=e.get(`alt`);u=n({kind:`text`,name:t,tag:``,markup:o?``:ve(e.get(`src`),ge(r))??y(r??``)})}else if(t===`video`||t===`audio`){let r=o?void 0:Ae(c).get(`src`);if(!o&&!l){let n=e.slice(De.lastIndex),i=n.match(RegExp(`</${t}\\s*>`,`i`)),a=i?n.slice(0,i.index):``;r??=Ae(a.match(/<source\b([^<>]*)>/i)?.[1]??``).get(`src`),i&&(De.lastIndex+=i.index+i[0].length)}u=n({kind:`text`,name:t,tag:``,markup:(o?null:ve(r,t===`video`?`Open attached video`:`Open attached audio`))??``})}else if(we.has(t)){if(!o&&!l&&!Ce.has(t)){let n=RegExp(`</${t}\\s*>`,`i`),r=e.slice(De.lastIndex),i=r.search(n);i!==-1&&(De.lastIndex+=i+r.slice(i).match(n)[0].length)}u=``}else if(Te.has(t))u=n({kind:`text`,name:t,tag:``,markup:``});else if(Se.has(t)){let e=je(t);u=o?n({kind:`close`,name:t,tag:e,markup:``}):Ce.has(t)?n({kind:`void`,name:t,tag:e,markup:Me(t,c)}):n({kind:`open`,name:t,tag:e,markup:Me(t,c)})}}u!==null&&(r+=e.slice(i,t.index)+u,i=De.lastIndex)}return{text:r+e.slice(i),tokens:t}}function Pe(e,t){for(let n of e.matchAll(/\u0002(\d+)\u0002/g))if(t.tokens[Number(n[1])].kind!==`entity`)return!0;return!1}function Fe(e,t){let n=e.match(de);return!!(n&&Ee.has(t.tokens[Number(n[1])].name))}function Ie(e){let t=[];return e.replace(/<a\b[^>]*>|<\/a>/g,e=>{if(e===`</a>`)return t.pop()?``:e;let n=t.length>0;return t.push(n),n?``:e})}function Le(e,t){let n=[],r=e=>{let r=t.tokens[e];if(r.kind===`open`)return n.push(r.tag),r.markup;if(r.kind===`close`){let e=n.lastIndexOf(r.tag);return e===-1?``:n.splice(e).reverse().map(e=>`</${e}>`).join(``)}return r.markup},i=``,a=0,o=!1;for(let n=0;n<e.length;n++){let s=e[n];if(s===`<`)o=!0;else if(s===`>`)o=!1;else if(s===``){let s=e.indexOf(``,n+1);if(s===-1)break;let c=Number(e.slice(n+1,s));i+=e.slice(a,n)+(o&&t.tokens[c].kind!==`entity`?``:r(c)),n=s,a=s+1}}return i+e.slice(a)+n.reverse().map(e=>`</${e}>`).join(``)}var Re=`\0`,ze=``,Be=/\u0000(\d+)\u0000/g,Ve=/^\u0000\d+\u0000$/,He=/\u0001(\d+)\u0001/g;function Ue(e,t={}){let{text:n,blocks:r}=Ye(Je(e.replace(/[\u0000\u0001\u0002]/g,``),t),t);if(!t.safeHtml)return $e(ot(n),r);let i=Ne(n);return Ie(Le($e(ot(i.text,i),r),i))}function We(e){return e.match(/^\s*(`{3,}|~{3,})\s*[\w+#.-]*\s*$/)?.[1][0]??null}function Ge(e,t){return RegExp(`^\\s*${t}{3,}\\s*$`).test(e)}var Ke=/`[^`\n]+`|<!--/g;function qe(e,t){Ke.lastIndex=t;for(let t;t=Ke.exec(e);)if(t[0]===`<!--`)return t.index;return-1}function Je(e,t={}){let n=[],r=null,i=!1,a=null,o=0;for(let s of e.split(`
3
- `)){let c=o;if(o+=s.length+1,r){let e=Ge(s,r);e&&(r=null),n.push({raw:s,visible:s,code:e?`close`:`body`});continue}if(!i&&(r=We(s),r)){n.push({raw:s,visible:s,code:`open`});continue}if(!t.hideHtmlComments){n.push({raw:s,visible:s});continue}let l=i?a:null,u=``,d=0;for(;d<s.length;){if(i){let e=s.indexOf(`-->`,d);if(e===-1)break;d=e+3,i=!1;continue}let t=qe(s,d);if(t===-1||e.indexOf(`-->`,c+t+4)===-1){u+=s.slice(d);break}u+=s.slice(d,t),d=t+4,i=!0}if(l){l.visible+=u,n.push({raw:s,visible:``,absent:!0});continue}let f={raw:s,visible:u};i&&(a=u.trim()===``?null:f),n.push(f)}return n}function Ye(e,t={}){let n=[],r=[],i=null,a,o=()=>{r.push(`${Re}${n.length}${Re}`);let e=i.join(`
4
- `);n.push(a===void 0?{code:e}:{code:e,diagram:{label:`Mermaid diagram: ${a??Qe(e)}`}}),i=null};for(let n of e)n.absent||(n.code===`open`?(i=[],a=t.mermaid&&Xe(n.raw).toLowerCase()===`mermaid`?Ze(r):void 0):n.code===`body`?i.push(n.raw):n.code===`close`?o():r.push(n.visible));return i&&o(),{text:r.join(`
5
- `),blocks:n}}function Xe(e){return e.match(/^\s*(?:`{3,}|~{3,})\s*([\w+#.-]*)/)?.[1]??``}function Ze(e){for(let t=e.length-1;t>=0;t--){let n=e[t].trim();if(!n)continue;let r=n.match(/^#{1,6}\s+(.+?)\s*#*$/)?.[1]??n.match(/^(\*\*|__)(.+)\1$/)?.[2];return r&&r.replace(/[`*_]/g,``).trim()||null}return null}function Qe(e){let t=e.split(`
6
- `).map(e=>e.trim()),n=0;if(t.find(e=>e)===`---`){let e=t.indexOf(`---`),r=t.indexOf(`---`,e+1);n=r===-1?t.length:r+1}return t.slice(n).find(e=>e&&!e.startsWith(`%%`))?.split(/\s+/)[0]||`diagram`}function $e(e,t){return e.replace(Be,(e,n)=>{let r=t[Number(n)];return r.diagram?nt(r.code,r.diagram.label):et(r.code,`Copy`,`Copy code`)})}function et(e,t,n,r=``){return`<div class="${le}"${r}><pre><code>${y(e)}</code></pre><button type="button" class="${ue}" aria-label="${n}">${t}</button></div>`}var tt=0;function nt(e,t){let n=`prb-md-mermaid-source-${++tt}`;return`<figure class="prb-md-mermaid" data-md-mermaid data-state="source"><div class="prb-md-mermaid-canvas" data-md-mermaid-canvas role="img" aria-label="${y(t)}" hidden></div><p class="prb-md-mermaid-error" data-md-mermaid-error hidden>This diagram couldn\u2019t be displayed.</p><button type="button" class="prb-md-mermaid-toggle" data-md-mermaid-toggle aria-expanded="true" aria-controls="${n}" hidden>Hide source</button>`+et(e,`Copy source`,`Copy source`,` id="${n}" data-md-mermaid-source`)+`</figure>`}function rt(e,t=0){let n=t;for(let t of e)n=t===` `?n+4-n%4:n+1;return n}function it(e){return rt(e.match(/^[ \t]*/)[0])}function at(e){let t=e.match(/^([ \t]*)(?:([-*+])|(\d{1,9})[.)])([ \t]+)(\S.*)$/);if(!t)return null;let[,n,r,i,a,o]=t,s=rt(n)+(r?1:i.length+1),c=rt(a,s);return{tag:r?`ul`:`ol`,start:r?1:Number(i),text:o.trim(),content:c-s>4?s+1:c}}function ot(e,t){let n=[],r=[],i=[],a=null,o=e=>e.tag===`ol`&&e.start!==1?` start="${e.start}"`:``,s=null,c=()=>{if(r.length&&n.push(`<p>${x(r.join(` `),t)}</p>`),i.length&&n.push(`<blockquote>${x(i.join(` `),t)}</blockquote>`),a){let e=e=>e.length===1?x(e[0],t):e.map(e=>`<p>${x(e,t)}</p>`).join(``),r=t=>`<${t.tag}${o(t)}>${t.items.map(t=>`<li>${e(t.paras)}</li>`).join(``)}</${t.tag}>`,i=({blocks:e})=>{let n=e.filter(e=>typeof e==`string`).length===1;return e.map(e=>typeof e==`string`?n?x(e,t):`<p>${x(e,t)}</p>`:r(e)).join(``)};n.push(`<${a.tag}${o(a)}>${a.items.map(e=>`<li>${i(e)}</li>`).join(``)}</${a.tag}>`)}r=[],i=[],a=null};for(let o of e.split(`
2
+ import{B as e,D as t,E as n,F as r,G as i,H as a,I as o,J as s,K as c,L as l,N as u,P as d,R as f,U as p,V as ee,X as m,a as h,i as te,o as g,q as ne,t as re,u as _,w as ie,z as ae}from"./chunk-2P5KTb9d.js";import{i as oe,o as se,s as ce}from"./chunk-CndkgJPh.js";import{t as v}from"./chunk-CvSN2dS5.js";import{t as le}from"./chunk-C8kkSv38.js";function y(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function ue(e){return y(e).replace(/`([^`\n]+)`/g,`<code>$1</code>`)}var de=`pr-helper-code-block`,fe=`pr-helper-code-copy`,pe=/^\u0002(\d+)\u0002/,me=/^(?:https?:\/\/|#)/i,he=/^https:\/\//i,ge=/^(?:image|img|screenshot|screen ?shot|picture|photo|pic)$/i,_e=/\.(?:png|jpe?g|gif|webp|svg|bmp|heic|avif|tiff?)$/i;function ve(e){let t=(e??``).trim();return!t||ge.test(t)||_e.test(t)?`View attached image`:`View image: ${t}`}function ye(e,t){return he.test(e)?`<a href="${e}" target="_blank" rel="noopener noreferrer">${t}</a>`:null}function be(e,t){return ye(y((e??``).trim()),y(t))}var b=e=>/^(?:left|right|center|justify)$/i.test(e)?e.toLowerCase():null,xe=e=>/^[1-9]\d{0,2}$/.test(e)?e:null,Se=e=>/^\d{1,9}$/.test(e)?e:null,Ce=e=>e.slice(0,300),we=new Map(Object.entries({a:{href:e=>{let t=e.trim();return me.test(t)?t:null},title:Ce},abbr:{title:Ce},b:{},blockquote:{},br:{},caption:{align:b},cite:{},code:{},dd:{},del:{},details:{},div:{align:b},dl:{},dt:{},em:{},hr:{},i:{},ins:{},kbd:{},li:{},mark:{},ol:{start:Se},p:{align:b},q:{},s:{},samp:{},small:{},span:{},strike:{},strong:{},sub:{},summary:{},sup:{},table:{align:b},tbody:{},td:{align:b,colspan:xe,rowspan:xe},tfoot:{},th:{align:b,colspan:xe,rowspan:xe},thead:{},tr:{align:b},u:{},ul:{},var:{},h1:{align:b},h2:{align:b},h3:{align:b},h4:{align:b},h5:{align:b},h6:{align:b}}).map(([e,t])=>[e,new Map(Object.entries({title:Ce,...t}))])),Te=new Set([`br`,`hr`,`img`,`input`,`source`,`meta`,`link`,`base`,`wbr`,`col`,`area`,`track`,`param`,`embed`]),Ee=new Set([`script`,`style`,`iframe`,`object`,`embed`,`svg`,`math`,`template`,`noscript`,`textarea`,`frame`,`frameset`,`applet`,`head`,`title`,`select`]),De=new Set(`picture.pre.source.track.input.form.label.button.option.optgroup.font.center.section.article.header.footer.nav.figure.figcaption.main.aside.html.body.meta.link.base.wbr.col.colgroup.area.map.param.fieldset.legend.dialog`.split(`.`)),Oe=new Set(`address.article.aside.blockquote.caption.center.dd.details.dialog.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.nav.ol.p.pre.section.summary.table.tbody.td.tfoot.th.thead.tr.ul`.split(`.`)),x=new RegExp(["`[^`\\n]+`",`<(\\/?)([A-Za-z][A-Za-z0-9-]*)((?:\\s+[^\\s"'<>\\/=]+(?:\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s"'=<>\`]+))?)*)\\s*(\\/?)>`,`&(?:#\\d{1,7}|#[xX][0-9a-fA-F]{1,6}|[A-Za-z][A-Za-z0-9]{1,31});`].join(`|`),`g`),ke=/([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;function Ae(e){return e.replace(/&(#\d{1,7}|#[xX][0-9a-fA-F]{1,6}|amp|lt|gt|quot|apos|nbsp);/g,(e,t)=>{if(t[0]===`#`){let e=t[1]===`x`||t[1]===`X`?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return e>0&&e<=1114111?String.fromCodePoint(e):``}return{amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`,nbsp:`\xA0`}[t]??``})}function je(e){let t=new Map;for(let n of e.matchAll(ke)){let e=n[1].toLowerCase();t.has(e)||t.set(e,Ae(n[2]??n[3]??n[4]??``))}return t}function Me(e){let t=e.match(/^h([1-6])$/);return t?`h${Math.min(Number(t[1]),3)+3}`:e}function Ne(e,t){let n=Me(e),r=we.get(e),i=[];for(let[e,n]of je(t)){let t=r.get(e),a=t?t(n):null;a!==null&&i.push(` ${e}="${y(a)}"`)}return e===`a`&&i.some(e=>e.startsWith(` href=`))&&i.push(` target="_blank" rel="noopener noreferrer"`),`<${n}${i.join(``)}>`}function Pe(e){let t=[],n=e=>`${t.push(e)-1}`,r=``,i=0;x.lastIndex=0;for(let t;t=x.exec(e);){let[a,o,s,c,l]=t,u=null;if(a[0]===`&`)u=n({kind:`entity`,name:``,tag:``,markup:a});else if(s){let t=s.toLowerCase();if(t===`img`){let e=je(c),r=e.get(`alt`);u=n({kind:`text`,name:t,tag:``,markup:o?``:be(e.get(`src`),ve(r))??y(r??``)})}else if(t===`video`||t===`audio`){let r=o?void 0:je(c).get(`src`);if(!o&&!l){let n=e.slice(x.lastIndex),i=n.match(RegExp(`</${t}\\s*>`,`i`)),a=i?n.slice(0,i.index):``;r??=je(a.match(/<source\b([^<>]*)>/i)?.[1]??``).get(`src`),i&&(x.lastIndex+=i.index+i[0].length)}u=n({kind:`text`,name:t,tag:``,markup:(o?null:be(r,t===`video`?`Open attached video`:`Open attached audio`))??``})}else if(Ee.has(t)){if(!o&&!l&&!Te.has(t)){let n=RegExp(`</${t}\\s*>`,`i`),r=e.slice(x.lastIndex),i=r.search(n);i!==-1&&(x.lastIndex+=i+r.slice(i).match(n)[0].length)}u=``}else if(De.has(t))u=n({kind:`text`,name:t,tag:``,markup:``});else if(we.has(t)){let e=Me(t);u=o?n({kind:`close`,name:t,tag:e,markup:``}):Te.has(t)?n({kind:`void`,name:t,tag:e,markup:Ne(t,c)}):n({kind:`open`,name:t,tag:e,markup:Ne(t,c)})}}u!==null&&(r+=e.slice(i,t.index)+u,i=x.lastIndex)}return{text:r+e.slice(i),tokens:t}}function Fe(e,t){for(let n of e.matchAll(/\u0002(\d+)\u0002/g))if(t.tokens[Number(n[1])].kind!==`entity`)return!0;return!1}function Ie(e,t){let n=e.match(pe);return!!(n&&Oe.has(t.tokens[Number(n[1])].name))}function Le(e){let t=[];return e.replace(/<a\b[^>]*>|<\/a>/g,e=>{if(e===`</a>`)return t.pop()?``:e;let n=t.length>0;return t.push(n),n?``:e})}function Re(e,t){let n=[],r=e=>{let r=t.tokens[e];if(r.kind===`open`)return n.push(r.tag),r.markup;if(r.kind===`close`){let e=n.lastIndexOf(r.tag);return e===-1?``:n.splice(e).reverse().map(e=>`</${e}>`).join(``)}return r.markup},i=``,a=0,o=!1;for(let n=0;n<e.length;n++){let s=e[n];if(s===`<`)o=!0;else if(s===`>`)o=!1;else if(s===``){let s=e.indexOf(``,n+1);if(s===-1)break;let c=Number(e.slice(n+1,s));i+=e.slice(a,n)+(o&&t.tokens[c].kind!==`entity`?``:r(c)),n=s,a=s+1}}return i+e.slice(a)+n.reverse().map(e=>`</${e}>`).join(``)}var ze=`\0`,Be=``,Ve=/\u0000(\d+)\u0000/g,He=/^\u0000\d+\u0000$/,Ue=/\u0001(\d+)\u0001/g;function We(e,t={}){let{text:n,blocks:r}=Xe(Ye(e.replace(/[\u0000\u0001\u0002]/g,``),t),t);if(!t.safeHtml)return et(st(n),r);let i=Pe(n);return Le(Re(et(st(i.text,i),r),i))}function Ge(e){return e.match(/^\s*(`{3,}|~{3,})\s*[\w+#.-]*\s*$/)?.[1][0]??null}function Ke(e,t){return RegExp(`^\\s*${t}{3,}\\s*$`).test(e)}var qe=/`[^`\n]+`|<!--/g;function Je(e,t){qe.lastIndex=t;for(let t;t=qe.exec(e);)if(t[0]===`<!--`)return t.index;return-1}function Ye(e,t={}){let n=[],r=null,i=!1,a=null,o=0;for(let s of e.split(`
3
+ `)){let c=o;if(o+=s.length+1,r){let e=Ke(s,r);e&&(r=null),n.push({raw:s,visible:s,code:e?`close`:`body`});continue}if(!i&&(r=Ge(s),r)){n.push({raw:s,visible:s,code:`open`});continue}if(!t.hideHtmlComments){n.push({raw:s,visible:s});continue}let l=i?a:null,u=``,d=0;for(;d<s.length;){if(i){let e=s.indexOf(`-->`,d);if(e===-1)break;d=e+3,i=!1;continue}let t=Je(s,d);if(t===-1||e.indexOf(`-->`,c+t+4)===-1){u+=s.slice(d);break}u+=s.slice(d,t),d=t+4,i=!0}if(l){l.visible+=u,n.push({raw:s,visible:``,absent:!0});continue}let f={raw:s,visible:u};i&&(a=u.trim()===``?null:f),n.push(f)}return n}function Xe(e,t={}){let n=[],r=[],i=null,a,o=()=>{r.push(`${ze}${n.length}${ze}`);let e=i.join(`
4
+ `);n.push(a===void 0?{code:e}:{code:e,diagram:{label:`Mermaid diagram: ${a??$e(e)}`}}),i=null};for(let n of e)n.absent||(n.code===`open`?(i=[],a=t.mermaid&&Ze(n.raw).toLowerCase()===`mermaid`?Qe(r):void 0):n.code===`body`?i.push(n.raw):n.code===`close`?o():r.push(n.visible));return i&&o(),{text:r.join(`
5
+ `),blocks:n}}function Ze(e){return e.match(/^\s*(?:`{3,}|~{3,})\s*([\w+#.-]*)/)?.[1]??``}function Qe(e){for(let t=e.length-1;t>=0;t--){let n=e[t].trim();if(!n)continue;let r=n.match(/^#{1,6}\s+(.+?)\s*#*$/)?.[1]??n.match(/^(\*\*|__)(.+)\1$/)?.[2];return r&&r.replace(/[`*_]/g,``).trim()||null}return null}function $e(e){let t=e.split(`
6
+ `).map(e=>e.trim()),n=0;if(t.find(e=>e)===`---`){let e=t.indexOf(`---`),r=t.indexOf(`---`,e+1);n=r===-1?t.length:r+1}return t.slice(n).find(e=>e&&!e.startsWith(`%%`))?.split(/\s+/)[0]||`diagram`}function et(e,t){return e.replace(Ve,(e,n)=>{let r=t[Number(n)];return r.diagram?rt(r.code,r.diagram.label):tt(r.code,`Copy`,`Copy code`)})}function tt(e,t,n,r=``){return`<div class="${de}"${r}><pre><code>${y(e)}</code></pre><button type="button" class="${fe}" aria-label="${n}">${t}</button></div>`}var nt=0;function rt(e,t){let n=`prb-md-mermaid-source-${++nt}`;return`<figure class="prb-md-mermaid" data-md-mermaid data-state="source"><div class="prb-md-mermaid-canvas" data-md-mermaid-canvas role="img" aria-label="${y(t)}" hidden></div><p class="prb-md-mermaid-error" data-md-mermaid-error hidden>This diagram couldn\u2019t be displayed.</p><button type="button" class="prb-md-mermaid-toggle" data-md-mermaid-toggle aria-expanded="true" aria-controls="${n}" hidden>Hide source</button>`+tt(e,`Copy source`,`Copy source`,` id="${n}" data-md-mermaid-source`)+`</figure>`}function it(e,t=0){let n=t;for(let t of e)n=t===` `?n+4-n%4:n+1;return n}function at(e){return it(e.match(/^[ \t]*/)[0])}function ot(e){let t=e.match(/^([ \t]*)(?:([-*+])|(\d{1,9})[.)])([ \t]+)(\S.*)$/);if(!t)return null;let[,n,r,i,a,o]=t,s=it(n)+(r?1:i.length+1),c=it(a,s);return{tag:r?`ul`:`ol`,start:r?1:Number(i),text:o.trim(),content:c-s>4?s+1:c}}function st(e,t){let n=[],r=[],i=[],a=null,o=e=>e.tag===`ol`&&e.start!==1?` start="${e.start}"`:``,s=null,c=()=>{if(r.length&&n.push(`<p>${ct(r.join(` `),t)}</p>`),i.length&&n.push(`<blockquote>${ct(i.join(` `),t)}</blockquote>`),a){let e=e=>e.length===1?ct(e[0],t):e.map(e=>`<p>${ct(e,t)}</p>`).join(``),r=t=>`<${t.tag}${o(t)}>${t.items.map(t=>`<li>${e(t.paras)}</li>`).join(``)}</${t.tag}>`,i=({blocks:e})=>{let n=e.filter(e=>typeof e==`string`).length===1;return e.map(e=>typeof e==`string`?n?ct(e,t):`<p>${ct(e,t)}</p>`:r(e)).join(``)};n.push(`<${a.tag}${o(a)}>${a.items.map(e=>`<li>${i(e)}</li>`).join(``)}</${a.tag}>`)}r=[],i=[],a=null};for(let o of e.split(`
7
7
  `)){let e=o.trim();if(s){if(e){s.push(y(e));continue}n.push(s.join(`
8
- `)),s=null}if(!e){a&&!r.length&&!i.length?a.gap=!0:c();continue}if(a?.items.length){let t=a.items[a.items.length-1],n=t.blocks[t.blocks.length-1],r=typeof n==`string`?null:n,i=r?.items[r.items.length-1]??null,s=it(o),l=at(o),u=a.gap;if(a.gap=!1,l&&s>=t.content){let e=r&&i&&(s>=i.content||r.tag===l.tag),n={paras:[l.text],content:l.content};e?r.items.push(n):t.blocks.push({tag:l.tag,start:l.start,items:[n]});continue}if(!l&&u){if(i&&s>=i.content){i.paras.push(e);continue}if(s>=t.content){t.blocks.push(e);continue}c()}else l&&u&&l.tag!==a.tag&&c()}if(t&&Fe(e,t)){c(),s=[y(e)];continue}if(Ve.test(e)){c(),n.push(e);continue}if(/^(?:-{3,}|\*{3,}|_{3,})$/.test(e)){c(),n.push(`<hr>`);continue}let l=e.match(/^(#{1,6})\s+(.+)$/);if(l){c();let e=Math.min(l[1].length,3)+3;n.push(`<h${e}>${x(l[2],t)}</h${e}>`);continue}let u=at(o);if(u){let e=a;e?.tag!==u.tag&&(c(),e=a={tag:u.tag,start:u.start,items:[],gap:!1}),e.items.push({blocks:[u.text],content:u.content});continue}let d=e.match(/^>\s?(.*)$/);if(d){i.length||c(),i.push(d[1]);continue}if(a&&a.items.length){let{blocks:t}=a.items[a.items.length-1],n=t[t.length-1];if(typeof n==`string`)t[t.length-1]=`${n} ${e}`;else{let t=n.items[n.items.length-1].paras;t[t.length-1]+=` ${e}`}continue}if(i.length){i[i.length-1]+=` ${e}`;continue}r.push(e)}return c(),s&&n.push(s.join(`
9
- `)),n.join(``)}function x(e,t){let n=[];return y(e).replace(/`([^`\n]+)`/g,(e,t)=>(n.push(t),`${ze}${n.length-1}${ze}`)).replace(/!\[([^\]\n]*)\]\(([^)\s]+)\)/g,(e,n,r)=>t&&!Pe(r,t)?_e(r,ge(n))??e:e).replace(/(?<!!)\[([^\]\n]+)\]\(([^)\s]+)\)/g,(e,n,r)=>fe.test(r)&&!(t&&Pe(r,t))?`<a href="${r}" target="_blank" rel="noopener noreferrer">${n}</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(He,(e,t)=>`<code>${n[Number(t)]}</code>`)}async function st(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){return console.warn(`PR Helper: clipboard write failed, falling back to execCommand`,t),ct(e)}}function ct(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 lt=`pr-helper-msg-copy`,ut=`pr-helper-chat-actions`,dt=`data-message-id`,ft=`data-copy-source`,pt={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 mt(e){return yt(`${ft}="${y(e)}"`)}var ht=`pr-helper-finding-copy`,gt=`data-copy-idle-label`,_t=`data-copy-idle-aria`,vt=`data-copy-idle-tip`;function yt(e,t){let{icon:n}=pt.idle,r=t?.label??pt.idle.label,i=t?.aria??pt.idle.aria,a=t?` ${gt}="${y(r)}" ${_t}="${y(i)}" ${vt}="${y(t.tip)}"`:``,o=`<button type="button" class="${t?`${lt} ${ht}`:lt}" ${e}${a}${t?` data-tip="${y(t.tip)}"`:``} aria-label="${y(i)}"><span class="${lt}-icon" aria-hidden="true">${xt(n)}</span><span class="${lt}-label"${r?``:` hidden`}>${y(r)}</span></button>`;return t?o:`<div class="${ut}">${o}</div>`}function bt(e,t){let n=pt[t],r=t===`idle`?{...n,label:e.getAttribute(gt)??n.label,aria:e.getAttribute(_t)??n.aria}:n,i=e.querySelector(`.${lt}-icon`),a=e.querySelector(`.${lt}-label`);i&&(i.innerHTML=xt(r.icon));let o=(e.getAttribute(gt)??``)!==``,s=e.classList.contains(`pr-helper-finding-copy`)&&!o;a instanceof HTMLElement&&(a.textContent=s?``:r.label,a.hidden=s||r.label===``),s&&e.setAttribute(`data-tip`,t===`idle`?e.getAttribute(vt)??``:r.label),e.setAttribute(`aria-label`,r.aria),e.classList.toggle(`copied`,t===`copied`),e.classList.toggle(`failed`,t===`failed`)}function xt(e){return`<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">${e}</svg>`}var St=1400,Ct=`Copy`,wt=`Copied`,Tt=/Mac|iPhone|iPad/.test(navigator.userAgent)?`Press ⌘C`:`Press Ctrl C`,Et=new WeakMap;function Dt(e,t={}){let n=e=>{let n=e.target;if(!(n instanceof Element))return;let r=n.closest(`.${ue}`),i=r?null:n.closest(`.${lt}`);!r&&!i||(e.preventDefault(),e.stopPropagation(),r?At(r):i&&Ot(i,t.messageSource))};return e.addEventListener(`click`,n,!0),()=>e.removeEventListener(`click`,n,!0)}async function Ot(e,t){let n=kt(e,t);Mt(e,n!==null&&await st(n)?`copied`:`failed`)}function kt(e,t){let n=e.getAttribute(ft);if(n!==null)return n;let r=e.getAttribute(dt);return r&&t?t(r):null}async function At(e){let t=e.parentElement?.querySelector(`pre code`),n=t?await st(t.textContent??``):!1;!n&&t&&jt(t),Nt(e,n?wt:Tt,n)}function jt(e){let t=window.getSelection();if(!t)return;let n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}function Mt(e,t){let n=Et.get(e);n&&window.clearTimeout(n),bt(e,t),Et.set(e,window.setTimeout(()=>{bt(e,`idle`),Et.delete(e)},St))}function Nt(e,t,n){let r=Et.get(e);r&&window.clearTimeout(r);let i=e.dataset.idleLabel??=e.textContent||Ct;e.textContent=t,e.classList.toggle(`copied`,n),Et.set(e,window.setTimeout(()=>{e.textContent=i,e.classList.remove(`copied`),Et.delete(e)},St))}var Pt={startOnLoad:!1,securityLevel:`strict`,htmlLabels:!1,flowchart:{htmlLabels:!1},theme:`neutral`,fontFamily:`inherit`,suppressErrorRendering:!0,secure:[`secure`,`securityLevel`,`startOnLoad`,`maxTextSize`,`suppressErrorRendering`,`maxEdges`,`htmlLabels`,`flowchart`,`themeCSS`,`themeVariables`,`theme`,`darkMode`,`fontFamily`,`dompurifyConfig`,`arrowMarkerAbsolute`,`deterministicIds`,`deterministicIDSeed`]},Ft=null;function It(){return Ft??=v(()=>import(`./chunk-D6oLtkSC.js`).then(e=>(e.default.initialize(Pt),e.default)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])),Ft}async function Lt(e,t,n,r=It){let i=await r();await i.parse(n);let{svg:a}=await i.render(t,n);e.innerHTML=a,zt(e)}var Rt=`http://www.w3.org/2000/svg`;function zt(e){for(let t of[...e.querySelectorAll(`a`)]){let n=e.ownerDocument.createElementNS(Rt,`g`);for(let e of[...t.attributes])/^(?:xlink:)?href$|^target$|^rel$/i.test(e.name)||n.setAttribute(e.name,e.value);n.append(...t.childNodes),t.replaceWith(n)}for(let t of e.querySelectorAll(`.clickable`))t.classList.remove(`clickable`)}var Bt=0;function Vt(e,t={}){let n=t.engine??It,r=t.observe??Ht,i=new WeakSet;for(let t of e.querySelectorAll(`figure[data-md-mermaid]`))r(t,()=>{i.has(t)||(i.add(t),Ut(t,n))});let a=e=>{let t=e.target?.closest?.(`[data-md-mermaid-toggle]`);t&&Gt(t)};return e.addEventListener(`click`,a),()=>e.removeEventListener(`click`,a)}function Ht(e,t){let n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(n.disconnect(),t())},{rootMargin:`200px`});n.observe(e)}async function Ut(e,t){let n=t=>e.querySelector(`[data-md-mermaid-${t}]`),r=n(`canvas`),i=n(`source`),a=n(`toggle`),o=i?.querySelector(`pre code`)?.textContent??``;if(!(!r||!i||!a))try{await Lt(r,`prb-md-mermaid-${++Bt}`,o,t),Wt(r.querySelector(`svg`)),r.hidden=!1,i.hidden=!0,a.hidden=!1,a.textContent=`View source`,a.setAttribute(`aria-expanded`,`false`),e.dataset.state=`diagram`}catch{e.dataset.state=`failed`;let t=n(`error`);t&&(t.hidden=!1)}}function Wt(e){let t=parseFloat(e?.style.maxWidth??``);!e||!Number.isFinite(t)||t<=0||(e.setAttribute(`width`,String(t)),e.style.maxWidth=`none`)}function Gt(e){let t=e.closest(`figure`)?.querySelector(`[data-md-mermaid-source]`);if(!t)return;let n=t.hidden;t.hidden=!n,e.textContent=n?`Hide source`:`View source`,e.setAttribute(`aria-expanded`,String(n))}var Kt=`pr-helper-selection-popover`,qt=`pr-helper-selection-popover-expanded`,Jt=`pr-helper-selection-copy-done`,Yt=8,Xt=8,Zt=1e3,Qt=`Copy selected text`,$t=`Copy`,en=`Copied`,tn=`pr-helper-selection-popover-flat`,S=null;function nn(e){return`<button type="button" class="pr-helper-selection-menu-item" data-selection-action="${y(e.id)}">${y(e.label)}</button>`}function rn(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(nn).join(``)}${[...t].map(([e,t])=>`
8
+ `)),s=null}if(!e){a&&!r.length&&!i.length?a.gap=!0:c();continue}if(a?.items.length){let t=a.items[a.items.length-1],n=t.blocks[t.blocks.length-1],r=typeof n==`string`?null:n,i=r?.items[r.items.length-1]??null,s=at(o),l=ot(o),u=a.gap;if(a.gap=!1,l&&s>=t.content){let e=r&&i&&(s>=i.content||r.tag===l.tag),n={paras:[l.text],content:l.content};e?r.items.push(n):t.blocks.push({tag:l.tag,start:l.start,items:[n]});continue}if(!l&&u){if(i&&s>=i.content){i.paras.push(e);continue}if(s>=t.content){t.blocks.push(e);continue}c()}else l&&u&&l.tag!==a.tag&&c()}if(t&&Ie(e,t)){c(),s=[y(e)];continue}if(He.test(e)){c(),n.push(e);continue}if(/^(?:-{3,}|\*{3,}|_{3,})$/.test(e)){c(),n.push(`<hr>`);continue}let l=e.match(/^(#{1,6})\s+(.+)$/);if(l){c();let e=Math.min(l[1].length,3)+3;n.push(`<h${e}>${ct(l[2],t)}</h${e}>`);continue}let u=ot(o);if(u){let e=a;e?.tag!==u.tag&&(c(),e=a={tag:u.tag,start:u.start,items:[],gap:!1}),e.items.push({blocks:[u.text],content:u.content});continue}let d=e.match(/^>\s?(.*)$/);if(d){i.length||c(),i.push(d[1]);continue}if(a&&a.items.length){let{blocks:t}=a.items[a.items.length-1],n=t[t.length-1];if(typeof n==`string`)t[t.length-1]=`${n} ${e}`;else{let t=n.items[n.items.length-1].paras;t[t.length-1]+=` ${e}`}continue}if(i.length){i[i.length-1]+=` ${e}`;continue}r.push(e)}return c(),s&&n.push(s.join(`
9
+ `)),n.join(``)}function ct(e,t){let n=[];return y(e).replace(/`([^`\n]+)`/g,(e,t)=>(n.push(t),`${Be}${n.length-1}${Be}`)).replace(/!\[([^\]\n]*)\]\(([^)\s]+)\)/g,(e,n,r)=>t&&!Fe(r,t)?ye(r,ve(n))??e:e).replace(/(?<!!)\[([^\]\n]+)\]\(([^)\s]+)\)/g,(e,n,r)=>me.test(r)&&!(t&&Fe(r,t))?`<a href="${r}" target="_blank" rel="noopener noreferrer">${n}</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(Ue,(e,t)=>`<code>${n[Number(t)]}</code>`)}async function lt(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){return console.warn(`PR Helper: clipboard write failed, falling back to execCommand`,t),ut(e)}}function ut(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 dt=`pr-helper-msg-copy`,ft=`pr-helper-chat-actions`,pt=`data-message-id`,mt=`data-copy-source`,ht={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 gt(e){return xt(`${mt}="${y(e)}"`)}var _t=`pr-helper-finding-copy`,vt=`data-copy-idle-label`,yt=`data-copy-idle-aria`,bt=`data-copy-idle-tip`;function xt(e,t){let{icon:n}=ht.idle,r=t?.label??ht.idle.label,i=t?.aria??ht.idle.aria,a=t?` ${vt}="${y(r)}" ${yt}="${y(i)}" ${bt}="${y(t.tip)}"`:``,o=`<button type="button" class="${t?`${dt} ${_t}`:dt}" ${e}${a}${t?` data-tip="${y(t.tip)}"`:``} aria-label="${y(i)}"><span class="${dt}-icon" aria-hidden="true">${Ct(n)}</span><span class="${dt}-label"${r?``:` hidden`}>${y(r)}</span></button>`;return t?o:`<div class="${ft}">${o}</div>`}function St(e,t){let n=ht[t],r=t===`idle`?{...n,label:e.getAttribute(vt)??n.label,aria:e.getAttribute(yt)??n.aria}:n,i=e.querySelector(`.${dt}-icon`),a=e.querySelector(`.${dt}-label`);i&&(i.innerHTML=Ct(r.icon));let o=(e.getAttribute(vt)??``)!==``,s=e.classList.contains(`pr-helper-finding-copy`)&&!o;a instanceof HTMLElement&&(a.textContent=s?``:r.label,a.hidden=s||r.label===``),s&&e.setAttribute(`data-tip`,t===`idle`?e.getAttribute(bt)??``:r.label),e.setAttribute(`aria-label`,r.aria),e.classList.toggle(`copied`,t===`copied`),e.classList.toggle(`failed`,t===`failed`)}function Ct(e){return`<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">${e}</svg>`}var wt=1400,Tt=`Copy`,Et=`Copied`,Dt=/Mac|iPhone|iPad/.test(navigator.userAgent)?`Press ⌘C`:`Press Ctrl C`,Ot=new WeakMap;function kt(e,t={}){let n=e=>{let n=e.target;if(!(n instanceof Element))return;let r=n.closest(`.${fe}`),i=r?null:n.closest(`.${dt}`);!r&&!i||(e.preventDefault(),e.stopPropagation(),r?Mt(r):i&&At(i,t.messageSource))};return e.addEventListener(`click`,n,!0),()=>e.removeEventListener(`click`,n,!0)}async function At(e,t){let n=jt(e,t);Pt(e,n!==null&&await lt(n)?`copied`:`failed`)}function jt(e,t){let n=e.getAttribute(mt);if(n!==null)return n;let r=e.getAttribute(pt);return r&&t?t(r):null}async function Mt(e){let t=e.parentElement?.querySelector(`pre code`),n=t?await lt(t.textContent??``):!1;!n&&t&&Nt(t),Ft(e,n?Et:Dt,n)}function Nt(e){let t=window.getSelection();if(!t)return;let n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}function Pt(e,t){let n=Ot.get(e);n&&window.clearTimeout(n),St(e,t),Ot.set(e,window.setTimeout(()=>{St(e,`idle`),Ot.delete(e)},wt))}function Ft(e,t,n){let r=Ot.get(e);r&&window.clearTimeout(r);let i=e.dataset.idleLabel??=e.textContent||Tt;e.textContent=t,e.classList.toggle(`copied`,n),Ot.set(e,window.setTimeout(()=>{e.textContent=i,e.classList.remove(`copied`),Ot.delete(e)},wt))}var It={startOnLoad:!1,securityLevel:`strict`,htmlLabels:!1,flowchart:{htmlLabels:!1},theme:`neutral`,fontFamily:`inherit`,suppressErrorRendering:!0,secure:[`secure`,`securityLevel`,`startOnLoad`,`maxTextSize`,`suppressErrorRendering`,`maxEdges`,`htmlLabels`,`flowchart`,`themeCSS`,`themeVariables`,`theme`,`darkMode`,`fontFamily`,`dompurifyConfig`,`arrowMarkerAbsolute`,`deterministicIds`,`deterministicIDSeed`]},Lt=null;function Rt(){return Lt??=v(()=>import(`./chunk-D6oLtkSC.js`).then(e=>(e.default.initialize(It),e.default)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])),Lt}async function zt(e,t,n,r=Rt){let i=await r();await i.parse(n);let{svg:a}=await i.render(t,n);e.innerHTML=a,Vt(e)}var Bt=`http://www.w3.org/2000/svg`;function Vt(e){for(let t of[...e.querySelectorAll(`a`)]){let n=e.ownerDocument.createElementNS(Bt,`g`);for(let e of[...t.attributes])/^(?:xlink:)?href$|^target$|^rel$/i.test(e.name)||n.setAttribute(e.name,e.value);n.append(...t.childNodes),t.replaceWith(n)}for(let t of e.querySelectorAll(`.clickable`))t.classList.remove(`clickable`)}var Ht=0;function Ut(e,t={}){let n=t.engine??Rt,r=t.observe??Wt,i=new WeakSet;for(let t of e.querySelectorAll(`figure[data-md-mermaid]`))r(t,()=>{i.has(t)||(i.add(t),Gt(t,n))});let a=e=>{let t=e.target?.closest?.(`[data-md-mermaid-toggle]`);t&&qt(t)};return e.addEventListener(`click`,a),()=>e.removeEventListener(`click`,a)}function Wt(e,t){let n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(n.disconnect(),t())},{rootMargin:`200px`});n.observe(e)}async function Gt(e,t){let n=t=>e.querySelector(`[data-md-mermaid-${t}]`),r=n(`canvas`),i=n(`source`),a=n(`toggle`),o=i?.querySelector(`pre code`)?.textContent??``;if(!(!r||!i||!a))try{await zt(r,`prb-md-mermaid-${++Ht}`,o,t),Kt(r.querySelector(`svg`)),r.hidden=!1,i.hidden=!0,a.hidden=!1,a.textContent=`View source`,a.setAttribute(`aria-expanded`,`false`),e.dataset.state=`diagram`}catch{e.dataset.state=`failed`;let t=n(`error`);t&&(t.hidden=!1)}}function Kt(e){let t=parseFloat(e?.style.maxWidth??``);!e||!Number.isFinite(t)||t<=0||(e.setAttribute(`width`,String(t)),e.style.maxWidth=`none`)}function qt(e){let t=e.closest(`figure`)?.querySelector(`[data-md-mermaid-source]`);if(!t)return;let n=t.hidden;t.hidden=!n,e.textContent=n?`Hide source`:`View source`,e.setAttribute(`aria-expanded`,String(n))}var Jt=`pr-helper-selection-popover`,Yt=`pr-helper-selection-popover-expanded`,Xt=`pr-helper-selection-copy-done`,Zt=8,Qt=8,$t=1e3,en=`Copy selected text`,tn=`Copy`,nn=`Copied`,rn=`pr-helper-selection-popover-flat`,S=null;function an(e){return`<button type="button" class="pr-helper-selection-menu-item" data-selection-action="${y(e.id)}">${y(e.label)}</button>`}function on(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(an).join(``)}${[...t].map(([e,t])=>`
10
10
  <div class="pr-helper-selection-menu-group">
11
11
  <div class="pr-helper-selection-menu-heading">${y(e)}</div>
12
- <div class="pr-helper-selection-menu-group-items">${t.map(nn).join(``)}</div>
13
- </div>`).join(``)}`}function an(e){if(e.layout===`flat`)return on(e);let t=rn(e.actions);return`
12
+ <div class="pr-helper-selection-menu-group-items">${t.map(an).join(``)}</div>
13
+ </div>`).join(``)}`}function sn(e){if(e.layout===`flat`)return cn(e);let t=on(e.actions);return`
14
14
  <div class="pr-helper-selection-bar">
15
15
  <button type="button" class="pr-helper-selection-trigger" data-selection-open>
16
16
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="12" height="12" fill="currentColor" aria-hidden="true">
@@ -18,7 +18,7 @@ import{B as e,D as t,E as n,F as r,G as i,H as a,I as o,K as s,L as c,N as l,P a
18
18
  </svg>
19
19
  <span>${y(e.triggerLabel??`Ask`)}</span>
20
20
  </button>
21
- <button type="button" class="pr-helper-selection-copy" data-selection-copy aria-label="${Qt}" aria-describedby="pr-helper-selection-tip">
21
+ <button type="button" class="pr-helper-selection-copy" data-selection-copy aria-label="${en}" aria-describedby="pr-helper-selection-tip">
22
22
  <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">
23
23
  <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"/>
24
24
  <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"/>
@@ -27,60 +27,60 @@ import{B as e,D as t,E as n,F as r,G as i,H as a,I as o,K as s,L as c,N as l,P a
27
27
  <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"/>
28
28
  </svg>
29
29
  </button>
30
- <span class="pr-helper-selection-tip" id="pr-helper-selection-tip" role="tooltip">${Qt}</span>
30
+ <span class="pr-helper-selection-tip" id="pr-helper-selection-tip" role="tooltip">${en}</span>
31
31
  </div>
32
32
  <div class="pr-helper-selection-menu">${t}</div>
33
- `}function on(e){return`<div class="pr-helper-selection-menu">
34
- ${rn(e.actions)}
35
- <button type="button" class="pr-helper-selection-menu-item pr-helper-selection-copy-item" data-selection-copy>${$t}</button>
36
- </div>`}function sn(e,t){let{width:n,height:r}=e.getBoundingClientRect(),i=t.top-r-Yt,a=i>=Xt?i:Math.min(t.bottom+Yt,window.innerHeight-r-Xt),o=Math.max(Xt,Math.min(t.left,window.innerWidth-n-Xt));e.style.top=`${Math.max(Xt,a)}px`,e.style.left=`${o}px`}function cn(){ln&&=(window.clearTimeout(ln),0),S?.popover.remove(),S=null}var ln=0;function un(e){let t=e.querySelector(`.pr-helper-selection-tip`),n=e.querySelector(`.pr-helper-selection-copy-item`);e.classList.add(Jt),t&&(t.textContent=en),n&&(n.textContent=en),ln&&window.clearTimeout(ln),ln=window.setTimeout(()=>dn(e),Zt)}function dn(e){ln&&=(window.clearTimeout(ln),0),e.classList.remove(Jt);let t=e.querySelector(`.pr-helper-selection-tip`);t&&(t.textContent=Qt);let n=e.querySelector(`.pr-helper-selection-copy-item`);n&&(n.textContent=$t)}async function fn(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}un(e)}function pn(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 mn(e,t){let n={},r=()=>{let r=pn(e,t);if(!r){(!S||S.owner===n)&&cn();return}if(S&&S.owner!==n&&cn(),S)S.popover.classList.remove(qt),dn(S.popover),S.text=r.text;else{let i=document.createElement(`div`);i.className=t.layout===`flat`?`${Kt} ${tn}`:Kt,i.innerHTML=an(t),i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,n=>{let r=n.target;if(r.closest(`[data-selection-copy]`)){S?.text&&fn(i,S.text);return}if(r.closest(`[data-selection-open]`)){i.classList.add(qt);let n=pn(e,t);sn(i,n?.rect??i.getBoundingClientRect());return}let a=r.closest(`[data-selection-action]`)?.dataset.selectionAction;if(!a||!S)return;let o=S.text;cn(),t.onChoose(a,o)}),document.body.appendChild(i),S={popover:i,text:r.text,owner:n}}sn(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)&&cn()},s=e=>{e.key===`Escape`&&cn()},c=()=>cn();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),cn()}}var hn=[{id:`explain-detail`,label:`Explain`,instruction:`Explain this, keeping the technical detail.`},{id:`explain`,label:`Explain simply`,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:`why-matters`,label:`Why does this matter?`,instruction:`Why does this matter? Say who or what it affects, and when.`},{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`}];function gn(e){return![...hn,..._n].find(t=>t.id===e)?.instruction}var _n=[{id:`add-to-chat`,label:`Add to chat`}],vn=800;function yn(e,t={}){let n=t.maxChars??vn,r=e.replace(/\r\n/g,`
33
+ `}function cn(e){return`<div class="pr-helper-selection-menu">
34
+ ${on(e.actions)}
35
+ <button type="button" class="pr-helper-selection-menu-item pr-helper-selection-copy-item" data-selection-copy>${tn}</button>
36
+ </div>`}function ln(e,t){let{width:n,height:r}=e.getBoundingClientRect(),i=t.top-r-Zt,a=i>=Qt?i:Math.min(t.bottom+Zt,window.innerHeight-r-Qt),o=Math.max(Qt,Math.min(t.left,window.innerWidth-n-Qt));e.style.top=`${Math.max(Qt,a)}px`,e.style.left=`${o}px`}function un(){dn&&=(window.clearTimeout(dn),0),S?.popover.remove(),S=null}var dn=0;function fn(e){let t=e.querySelector(`.pr-helper-selection-tip`),n=e.querySelector(`.pr-helper-selection-copy-item`);e.classList.add(Xt),t&&(t.textContent=nn),n&&(n.textContent=nn),dn&&window.clearTimeout(dn),dn=window.setTimeout(()=>pn(e),$t)}function pn(e){dn&&=(window.clearTimeout(dn),0),e.classList.remove(Xt);let t=e.querySelector(`.pr-helper-selection-tip`);t&&(t.textContent=en);let n=e.querySelector(`.pr-helper-selection-copy-item`);n&&(n.textContent=tn)}async function mn(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}fn(e)}function hn(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 gn(e,t){let n={},r=()=>{let r=hn(e,t);if(!r){(!S||S.owner===n)&&un();return}if(S&&S.owner!==n&&un(),S)S.popover.classList.remove(Yt),pn(S.popover),S.text=r.text;else{let i=document.createElement(`div`);i.className=t.layout===`flat`?`${Jt} ${rn}`:Jt,i.innerHTML=sn(t),i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,n=>{let r=n.target;if(r.closest(`[data-selection-copy]`)){S?.text&&mn(i,S.text);return}if(r.closest(`[data-selection-open]`)){i.classList.add(Yt);let n=hn(e,t);ln(i,n?.rect??i.getBoundingClientRect());return}let a=r.closest(`[data-selection-action]`)?.dataset.selectionAction;if(!a||!S)return;let o=S.text;un(),t.onChoose(a,o)}),document.body.appendChild(i),S={popover:i,text:r.text,owner:n}}ln(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)&&un()},s=e=>{e.key===`Escape`&&un()},c=()=>un();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),un()}}var _n=[{id:`explain-detail`,label:`Explain`,instruction:`Explain this, keeping the technical detail.`},{id:`explain`,label:`Explain simply`,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:`why-matters`,label:`Why does this matter?`,instruction:`Why does this matter? Say who or what it affects, and when.`},{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`}];function vn(e){return![..._n,...yn].find(t=>t.id===e)?.instruction}var yn=[{id:`add-to-chat`,label:`Add to chat`}],bn=800;function xn(e,t={}){let n=t.maxChars??bn,r=e.replace(/\r\n/g,`
37
37
  `).split(`
38
38
  `).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(`
39
39
  `).replace(/\n{3,}/g,`
40
40
 
41
41
  `);return o.trim()?(o.length>n?`${o.slice(0,n).trimEnd()}…`:o).split(`
42
42
  `).map(e=>`> ${e}`.trimEnd()).join(`
43
- `):``}function bn(e,t,n={}){let r=yn(e,n);if(!r)return null;let i=[...hn,..._n].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 xn=`saved:`,Sn=`Your prompts`;function Cn(e){return`${xn}${e}`}function wn(e){return e.startsWith(`saved:`)?e.slice(6):null}function Tn(e){return e.closest(`[data-finding-card]`)?.querySelector(`[data-copy-source]`)?.getAttribute(`data-copy-source`)??``}var En=[`progress`,`overview`,`guide`,`issues`,`questions`,`files`,`prcontext`,`architecture`,`map`,`diagram`,`kiss`,`kissrecs`],Dn=`#theme-`,On=[`buddy`,`overview`,`guide`,`architecture`,`map`,`diagram`,`issues`,`questions`,`files`,`prcontext`,`kiss`,`kissrecs`,`progress`],kn=`&focus=`;function An(e){return`#${e}`}function jn(e){return`${Dn}${encodeURIComponent(e)}`}function Mn(e){let t=e.kind===`view`?An(e.view):jn(e.sectionId);return e.focus?`${t}${kn}${e.focus}`:t}var Nn=[`architecture`,`map`,`diagram`];function Pn(e,t){return Nn.includes(e)&&Nn.includes(t??``)?e:void 0}function Fn(e,t){let n=Bn(e),r=n?.kind===`view`&&n.view===t?n.focus:Pn(t,n?.focus);return Mn({kind:`view`,view:t,...r?{focus:r}:{}})}function In(e){let{focus:t,...n}=e;return n}function Ln(e,t){return e.kind!==`view`||e.view!==`guide`||!t?e:{kind:`section`,sectionId:t,...e.focus?{focus:e.focus}:{}}}function Rn(e){return On.includes(e)}function zn(e){if(!e||typeof e!=`object`)return null;let{kind:t,view:n,sectionId:r,focus:i}=e,a=typeof i==`string`&&Rn(i)?{focus:i}:{};return t===`view`&&typeof n==`string`&&En.includes(n)?{kind:t,view:n,...a}:t===`section`&&typeof r==`string`&&r!==``?{kind:t,sectionId:r,...a}:null}function Bn(e){let t=e.indexOf(kn);if(t===-1)return Vn(e);let n=Vn(e.slice(0,t));if(!n)return null;let r=e.slice(t+7);return Rn(r)?{...n,focus:r}:n}function Vn(e){if(e.startsWith(Dn)){let t=e.slice(7);if(!t)return null;try{return{kind:`section`,sectionId:decodeURIComponent(t)}}catch{return null}}let t=e.replace(/^#/,``);return En.includes(t)?{kind:`view`,view:t}:null}var Hn=`pushedFocus`;function Un(e){let{[Hn]:t,...n}=e;return n}function Wn(e,t){return e.kind===`view`&&t.kind===`view`?e.view===t.view:e.kind===`section`&&t.kind===`section`&&e.sectionId===t.sectionId}function Gn(e,t,n){if(e.focus===t)return;let r={...In(Un(e)),focus:t};e.focus&&n.history.state?.[Hn]?n.history.replaceState({...r,[Hn]:!0},``,Mn(r)):n.history.pushState({...r,[Hn]:!0},``,Mn(r)),n.apply(r)}function Kn(e,t){if(!e.focus)return;if(t.history.state?.[Hn]){t.history.back();return}let n=In(Un(e));t.history.replaceState(n,``,Mn(n)),t.apply(n)}function qn(e,t,n){if(!n||e.key!==`Escape`||e.defaultPrevented||t.querySelector(`dialog[open], [data-menu-panel]:not([hidden]), [data-analysis-details][open], [data-range-details][open], .pr-helper-selection-popover`))return!1;let r=e.target;return!(r?.closest?.(`[data-ask-resize]`)||r instanceof HTMLInputElement&&r.value!==``)}function Jn(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 Yn(e,t,n,r){let i=n===`finding`?{maxChars:1/0}:{},a=wn(e);if(a===null)return bn(t,e,i);let o=r(a);if(!o)return null;let s=yn(t,i);return s?`${s}\n\n${o}`:null}function Xn(e,t,n){if(n.busy?.())return null;let r=Yn(e,t.text,t.context,n.savedPrompt);if(!r)return null;let i=gn(e)||wn(e)!==null;return t.context===`selection`||i?(n.stage(r),`staged`):(n.send(r),`sent`)}var Zn=`button:not([disabled])`;function Qn(e){return e.querySelector(`[data-menu-panel]`)}function $n(e){return e.querySelector(`[data-menu-trigger]`)}function er(e){let t=Qn(e);return t?[...t.querySelectorAll(Zn)].filter(e=>!e.closest(`[hidden]`)):[]}function tr(e,t={}){let n=null,r=t.within?`${t.within} [data-menu]`:`[data-menu]`,i=e=>e&&(!t.within||e.closest(t.within))?e:null,a=(e,r={})=>{let i=Qn(e);if(!i||i.hidden)return;i.hidden=!0;let a=$n(e);a?.setAttribute(`aria-expanded`,`false`),n===e&&(n=null),t.onClose?.(e),r.returnFocus&&a?.focus()},o=()=>{for(let t of e.querySelectorAll(r))a(t)},s=(e,r)=>{let i=Qn(e);i&&(o(),t.onOpen?.(e),i.hidden=!1,$n(e)?.setAttribute(`aria-expanded`,`true`),n=e,r&&er(e)[0]?.focus())};return e.addEventListener(`click`,e=>{let t=e.target,r=i(t?.closest?.(`[data-menu]`)??null);if(!r){o();return}if(t?.closest(`[data-menu-trigger]`)){let t=e.detail===0;Qn(r)?.hidden?s(r,t):a(r);return}n&&n!==r&&a(n)}),e.addEventListener(`keydown`,e=>{if(n&&!n.isConnected&&(n=null),!n)return;let t=n;if(e.key===`Escape`){e.preventDefault(),a(t,{returnFocus:!0});return}if(!t.contains(e.target))return;if(e.key===`Tab`){a(t);return}let r=er(t);if(r.length===0)return;let i=r.indexOf(e.target),o=e.key===`ArrowDown`?r[(i+1)%r.length]:e.key===`ArrowUp`?r[(i-1+r.length)%r.length]:e.key===`Home`?r[0]:e.key===`End`?r[r.length-1]:null;o&&(e.preventDefault(),o.focus())}),{open:e=>s(e,!1),close:a,closeAll:o}}function nr(e){return e.reviewerClosed>0?`dealt with`:`resolved`}var rr=`Run review again`;function ir(e,t,n){for(let r of e.querySelectorAll(`[data-intent-question]`))if(r.dataset.intentQuestion===t){for(let e of r.querySelectorAll(`[data-intent-open]`))e.hidden=n;for(let e of r.querySelectorAll(`[data-intent-answered]`))e.hidden=!n}}function ar(e){let t=e.dataset.questionAnswered;t&&ir(e.ownerDocument,t,e.dataset.answered===`true`||e.dataset.settled===`true`)}var or=`pr-helper-author-context-preview`,sr=`View full PR description`,cr=`Show less`;function lr(e){let t=e.ownerDocument,n=t.getElementById(e.getAttribute(`aria-controls`)??``),r=t.getElementById(or);if(!n)return;let i=n.closest(`#${pr}`),a=i?[...i.querySelectorAll(`[data-author-context-toggle]`)]:[e],o=e.getAttribute(`aria-expanded`)!==`true`,s=ur(n);if(!o){let e=-dr(n,s);e>0?n.dataset.readingOffset=String(e):delete n.dataset.readingOffset}n.hidden=!o,r&&(r.hidden=o),i?.toggleAttribute(`data-expanded`,o);for(let e of a)e.setAttribute(`aria-expanded`,String(o)),e.textContent=o?cr:sr,e.hasAttribute(`data-author-context-head`)&&(e.hidden=!o);if(o){let e=Number(n.dataset.readingOffset??0);e>0&&fr(n,s,dr(n,s)+e);return}i&&dr(i,s)<0&&i.scrollIntoView({block:`start`}),e.hidden&&a.find(e=>!e.hidden)?.focus({preventScroll:!0})}function ur(e){let t=e.ownerDocument.defaultView;for(let n=e.parentElement;n;n=n.parentElement)if(/^(?:auto|scroll|overlay)$/.test(t?.getComputedStyle(n).overflowY??``))return n;return null}function dr(e,t){return e.getBoundingClientRect().top-(t?t.getBoundingClientRect().top:0)}function fr(e,t,n){(t??e.ownerDocument.defaultView)?.scrollBy(0,n)}var pr=`pr-helper-author-context`;function mr(e){let t=e.ownerDocument.getElementById(pr);if(!t)return;let n=t.querySelector(`[data-author-context-toggle]`);n?.getAttribute(`aria-expanded`)===`false`&&lr(n),t.scrollIntoView?.({block:`start`,behavior:`smooth`}),t.querySelector(`h4`)?.focus({preventScroll:!0})}({claude:`Claude Code`,codex:`Codex`,gemini:`Gemini CLI`}).claude;function C(e,t=``){return typeof e==`string`?e:t}var hr=`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 gr(e){return e?`View current PR description on GitHub ↗`:`View PR description on GitHub ↗`}function _r(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 vr(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 yr(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 br(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 xr(e){return e instanceof Element&&e.closest(`[data-guide-jump]`)?.dataset.guideJump||null}function Sr(e){for(let t of document.querySelectorAll(`[data-goto-section]`))t.setAttribute(`aria-current`,String(t.dataset.gotoSection===e))}function Cr(){for(let e of document.querySelectorAll(`.prb-rail [data-goto-section]`))e.setAttribute(`aria-current`,`false`)}function wr(e,t){let n=e.trim();return n?`${n}\n\n${t}`:t}var Tr=50;function Er(e){let t=e.tagName===`LI`?e.querySelector(`:scope > .prb-code`):e.nextElementSibling;return t?.classList.contains(`prb-code`)?t:null}function w(e,t=2**53-1){let n=Number(e);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),t):0}function Dr(e){if(!e||typeof e!=`object`)return;let t=e,n=w(t.top);return{cited:w(t.cited),centre:w(t.centre),expand:w(t.expand,Tr),position:w(t.position),tall:t.tall===!0,top:n>0?n:null,offset:Number.isFinite(Number(t.offset))?Math.round(Number(t.offset)):0}}function Or(e){let t=e.getBoundingClientRect().top;for(let n of e.querySelectorAll(`tr[data-line]`)){let e=n.getBoundingClientRect();if(e.bottom>t)return{top:Number(n.dataset.line)||null,offset:Math.round(e.top-t)}}return{top:null,offset:0}}function kr(e){let t=e.querySelector(`[data-change-navigator]`),n=e.querySelector(`.prb-code-scroll`),r=n&&n.scrollTop>0?Or(n):{top:null,offset:0};return{cited:w(e.dataset.cited),centre:w(e.dataset.centre),expand:w(e.dataset.expand,Tr),position:w(t?.dataset.changePosition??e.dataset.position),tall:e.hasAttribute(`data-expanded`),...r}}function Ar(e,t,n){let r=e.querySelector(`.prb-code-scroll`);if(!r)return;if(t===null){r.scrollTop=0;return}let i=null,a=1/0;for(let e of r.querySelectorAll(`tr[data-line]`)){let n=Math.abs((Number(e.dataset.line)||0)-t);n<a&&(i=e,a=n)}i&&(r.scrollTop+=i.getBoundingClientRect().top-r.getBoundingClientRect().top-n)}function jr(e,t){return e.cited===t.cited&&e.centre===t.centre&&e.expand===t.expand&&e.position===t.position}function Mr(){let e=new WeakMap,t=0;return{run(n,r,i){let a=++t,o=i().then(t=>e.get(n)?.ticket===a&&(e.delete(n),t(),!0),()=>(e.get(n)?.ticket===a&&e.delete(n),!1));return e.set(n,{ticket:a,request:r,done:o}),o},pending(t){return e.get(t)}}}function Nr(e){let t=e.closest(`[data-finding-card]`);if(t)return`card:${t.getAttribute(`data-finding-card`)??``}`;let n=e.closest(`[data-guide-section]`);return n?`theme:${n.getAttribute(`data-guide-section`)??``}`:`view:${e.closest(`[data-view]`)?.getAttribute(`data-view`)??``}`}function Pr(e){return[...e.querySelectorAll(`[data-file][aria-expanded="true"]`)].map(e=>{let t=Er(e);return{host:Nr(e),file:e.getAttribute(`data-file`)??``,line:e.getAttribute(`data-line`)??``,...t?{state:kr(t)}:{}}})}function Fr(e,t){return e.host===t.host&&e.file===t.file&&e.line===t.line}function Ir(e,t){for(let n of e.querySelectorAll(`[data-file]`))if(n.getAttribute(`data-file`)===t.file&&(n.getAttribute(`data-line`)??``)===t.line&&Nr(n)===t.host)return n;return null}function Lr(e){if(!e||typeof e!=`object`)return!1;let{host:t,file:n,line:r}=e;return typeof t==`string`&&typeof n==`string`&&n!==``&&typeof r==`string`}function Rr(e){let{doc:t,main:n,rail:r,log:i,panes:o}=e,s={};for(let e of t.querySelectorAll(`[data-rail-toggle][aria-controls]`))s[e.getAttribute(`aria-controls`)]=e.getAttribute(`aria-expanded`)===`true`;let c=o?.dataset.ask;return{main:n?.scrollTop??0,rail:r?.scrollTop??0,ask:c===`open`||c===`closed`?c:null,log:i?.scrollTop??0,folds:s,panels:Pr(t),focus:a(t.activeElement,t.body)}}async function zr(e,t,n){if(!t)return!1;let{doc:r,main:a,rail:o,log:c}=e,l=t.folds&&typeof t.folds==`object`?t.folds:{};for(let e of r.querySelectorAll(`[data-rail-toggle][aria-controls]`)){let t=l[e.getAttribute(`aria-controls`)];typeof t==`boolean`&&n.setFold(e,t)}if((t.ask===`open`||t.ask===`closed`)&&n.setAsk(t.ask===`open`),Array.isArray(t.panels)){let e=t.panels.filter(Lr).map(e=>({...e,state:Dr(e.state)}));for(let t of Pr(r))if(!e.some(e=>Fr(e,t))){let e=Ir(r,t);e&&n.closePanel(e)}let i=[];for(let t of e){let e=Ir(r,t);e&&i.push(n.openPanel(e,t.state).catch(()=>{}))}await Promise.all(i)}if(!n.stillCurrent())return!1;let u=i(t,`main`);a&&u!==null&&(a.scrollTop=u);let d=i(t,`rail`);o&&d!==null&&(o.scrollTop=d);let f=i(t,`log`);return c&&f!==null&&(c.scrollTop=f),s(r,t.focus),!0}var Br=`prb-ask-draft:`,Vr=300;function Hr(e){return`${Br}${e}`}function Ur(e,t){let{storage:n,win:r}=t,i=Hr(t.path),a=null,o=e=>{try{e.trim()===``?n?.removeItem(i):n?.setItem(i,e)}catch{}};if(t.restore&&e.value===``)try{let t=n?.getItem(i);t&&(e.value=t)}catch{}let s={save(){a!==null&&r.clearTimeout(a),a=null,o(e.value)},saveSoon(){a!==null&&r.clearTimeout(a),a=r.setTimeout(()=>s.save(),Vr)},clear(){a!==null&&r.clearTimeout(a),a=null,o(``)}};return e.addEventListener(`input`,()=>s.saveSoon()),r.addEventListener(`pagehide`,()=>s.save()),s}function Wr(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 Gr(){return`<button type="button" class="prb-update-btn" data-review-update>Update review</button>`}var Kr=`Updating this review checks the latest commits and refreshes the PR conversation. Your progress and Buddy AI history will be kept.`;function qr(e){return`<details class="prb-update-alt">
43
+ `):``}function Sn(e,t,n={}){let r=xn(e,n);if(!r)return null;let i=[..._n,...yn].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 Cn=`saved:`,wn=`Your prompts`;function Tn(e){return`${Cn}${e}`}function En(e){return e.startsWith(`saved:`)?e.slice(6):null}function Dn(e){return e.closest(`[data-finding-card]`)?.querySelector(`[data-copy-source]`)?.getAttribute(`data-copy-source`)??``}var On=[`progress`,`overview`,`guide`,`issues`,`questions`,`files`,`prcontext`,`architecture`,`map`,`diagram`,`kiss`,`kissrecs`],kn=`#theme-`,An=[`buddy`,`overview`,`guide`,`architecture`,`map`,`diagram`,`issues`,`questions`,`files`,`prcontext`,`kiss`,`kissrecs`,`progress`],jn=`&focus=`;function Mn(e){return`#${e}`}function Nn(e){return`${kn}${encodeURIComponent(e)}`}function Pn(e){let t=e.kind===`view`?Mn(e.view):Nn(e.sectionId);return e.focus?`${t}${jn}${e.focus}`:t}var Fn=[`architecture`,`map`,`diagram`];function In(e,t){return Fn.includes(e)&&Fn.includes(t??``)?e:void 0}function Ln(e,t){let n=Hn(e),r=n?.kind===`view`&&n.view===t?n.focus:In(t,n?.focus);return Pn({kind:`view`,view:t,...r?{focus:r}:{}})}function Rn(e){let{focus:t,...n}=e;return n}function zn(e,t){return e.kind!==`view`||e.view!==`guide`||!t?e:{kind:`section`,sectionId:t,...e.focus?{focus:e.focus}:{}}}function Bn(e){return An.includes(e)}function Vn(e){if(!e||typeof e!=`object`)return null;let{kind:t,view:n,sectionId:r,focus:i}=e,a=typeof i==`string`&&Bn(i)?{focus:i}:{};return t===`view`&&typeof n==`string`&&On.includes(n)?{kind:t,view:n,...a}:t===`section`&&typeof r==`string`&&r!==``?{kind:t,sectionId:r,...a}:null}function Hn(e){let t=e.indexOf(jn);if(t===-1)return Un(e);let n=Un(e.slice(0,t));if(!n)return null;let r=e.slice(t+7);return Bn(r)?{...n,focus:r}:n}function Un(e){if(e.startsWith(kn)){let t=e.slice(7);if(!t)return null;try{return{kind:`section`,sectionId:decodeURIComponent(t)}}catch{return null}}let t=e.replace(/^#/,``);return On.includes(t)?{kind:`view`,view:t}:null}var Wn=`pushedFocus`;function Gn(e){let{[Wn]:t,...n}=e;return n}function Kn(e,t){return e.kind===`view`&&t.kind===`view`?e.view===t.view:e.kind===`section`&&t.kind===`section`&&e.sectionId===t.sectionId}function qn(e,t,n){if(e.focus===t)return;let r={...Rn(Gn(e)),focus:t};e.focus&&n.history.state?.[Wn]?n.history.replaceState({...r,[Wn]:!0},``,Pn(r)):n.history.pushState({...r,[Wn]:!0},``,Pn(r)),n.apply(r)}function Jn(e,t){if(!e.focus)return;if(t.history.state?.[Wn]){t.history.back();return}let n=Rn(Gn(e));t.history.replaceState(n,``,Pn(n)),t.apply(n)}function Yn(e,t,n){if(!n||e.key!==`Escape`||e.defaultPrevented||t.querySelector(`dialog[open], [data-menu-panel]:not([hidden]), [data-analysis-details][open], [data-range-details][open], .pr-helper-selection-popover`))return!1;let r=e.target;return!(r?.closest?.(`[data-ask-resize]`)||r instanceof HTMLInputElement&&p(r)&&r.value!==``)}function Xn(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 Zn(e,t,n,r){let i=n===`finding`?{maxChars:1/0}:{},a=En(e);if(a===null)return Sn(t,e,i);let o=r(a);if(!o)return null;let s=xn(t,i);return s?`${s}\n\n${o}`:null}function Qn(e,t,n){if(n.busy?.())return null;let r=Zn(e,t.text,t.context,n.savedPrompt);if(!r)return null;let i=vn(e)||En(e)!==null;return t.context===`selection`||i?(n.stage(r),`staged`):(n.send(r),`sent`)}var $n=`button:not([disabled])`;function er(e){return e.querySelector(`[data-menu-panel]`)}function tr(e){return e.querySelector(`[data-menu-trigger]`)}function nr(e){let t=er(e);return t?[...t.querySelectorAll($n)].filter(e=>!e.closest(`[hidden]`)):[]}var rr=`data-menu-placement`;function ir(e){let t=e.ownerDocument.defaultView,n=0,r=t?.innerHeight??1/0;for(let i=e.parentElement;i&&t;i=i.parentElement){let e=t.getComputedStyle(i).overflowY;if(e===`visible`||e===``)continue;let a=i.getBoundingClientRect();n=Math.max(n,a.top),r=Math.min(r,a.bottom)}return{top:n,bottom:r}}var ar=8,or=120;function sr(e){let t=er(e),n=tr(e);if(!t||!n)return;t.removeAttribute(rr),t.style.removeProperty(`max-height`),t.style.removeProperty(`overflow-y`),t.style.removeProperty(`box-sizing`),t.scrollTop=0;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=ir(e),o=Math.max(0,r.top-i.bottom),s=a.bottom-i.bottom-o-ar,c=i.top-a.top-o-ar,l=r.height,u=l<=s?`below`:l<=c||c>s?`above`:`below`;u===`above`&&t.setAttribute(rr,`above`);let d=u===`above`?c:s;l<=d||(t.style.boxSizing=`border-box`,t.style.maxHeight=`${Math.max(Math.floor(d),or)}px`,t.style.overflowY=`auto`)}function cr(e,t={}){let n=null,r=null,i=t.within?`${t.within} [data-menu]`:`[data-menu]`,a=e=>e&&(!t.within||e.closest(t.within))?e:null,o=(e,i={})=>{let a=er(e);if(!a||a.hidden)return;a.hidden=!0;let o=tr(e);o?.setAttribute(`aria-expanded`,`false`);let s=n===e?r:null;n===e&&(n=null,r=null),t.onClose?.(e),i.returnFocus&&(s??(()=>o?.focus()))()},s=()=>{for(let t of e.querySelectorAll(i))o(t)},c=(e,i,a=null)=>{let o=er(e);o&&(s(),r=a,t.onOpen?.(e),o.hidden=!1,sr(e),tr(e)?.setAttribute(`aria-expanded`,`true`),n=e,i&&nr(e)[0]?.focus())};return e.addEventListener(`click`,e=>{let t=e.target,r=a(t?.closest?.(`[data-menu]`)??null);if(!r){s();return}if(t?.closest(`[data-menu-trigger]`)){let t=e.detail===0;er(r)?.hidden?c(r,t):o(r);return}n&&n!==r&&o(n)}),e.addEventListener(`keydown`,e=>{if(n&&!n.isConnected&&(n=null),!n)return;let t=n;if(e.key===`Escape`){e.preventDefault(),o(t,{returnFocus:!0});return}if(!t.contains(e.target))return;if(e.key===`Tab`){o(t);return}let r=nr(t);if(r.length===0)return;let i=r.indexOf(e.target),a=e.key===`ArrowDown`?r[(i+1)%r.length]:e.key===`ArrowUp`?r[(i-1+r.length)%r.length]:e.key===`Home`?r[0]:e.key===`End`?r[r.length-1]:null;a&&(e.preventDefault(),a.focus(),a.scrollIntoView({block:`nearest`}))}),{open:(e,t={})=>c(e,t.focusFirst===!0,t.returnFocus??null),close:o,closeAll:s}}function lr(e){return e.reviewerClosed>0?`dealt with`:`resolved`}var ur=`Run review again`;function dr(e,t,n){for(let r of e.querySelectorAll(`[data-intent-question]`))if(r.dataset.intentQuestion===t){for(let e of r.querySelectorAll(`[data-intent-open]`))e.hidden=n;for(let e of r.querySelectorAll(`[data-intent-answered]`))e.hidden=!n}}function fr(e){let t=e.dataset.questionAnswered;t&&dr(e.ownerDocument,t,e.dataset.answered===`true`||e.dataset.settled===`true`)}var pr=`pr-helper-author-context-preview`,mr=`View full PR description`,hr=`Show less`;function gr(e){let t=e.ownerDocument,n=t.getElementById(e.getAttribute(`aria-controls`)??``),r=t.getElementById(pr);if(!n)return;let i=n.closest(`#${br}`),a=i?[...i.querySelectorAll(`[data-author-context-toggle]`)]:[e],o=e.getAttribute(`aria-expanded`)!==`true`,s=_r(n);if(!o){let e=-vr(n,s);e>0?n.dataset.readingOffset=String(e):delete n.dataset.readingOffset}n.hidden=!o,r&&(r.hidden=o),i?.toggleAttribute(`data-expanded`,o);for(let e of a)e.setAttribute(`aria-expanded`,String(o)),e.textContent=o?hr:mr,e.hasAttribute(`data-author-context-head`)&&(e.hidden=!o);if(o){let e=Number(n.dataset.readingOffset??0);e>0&&yr(n,s,vr(n,s)+e);return}i&&vr(i,s)<0&&i.scrollIntoView({block:`start`}),e.hidden&&a.find(e=>!e.hidden)?.focus({preventScroll:!0})}function _r(e){let t=e.ownerDocument.defaultView;for(let n=e.parentElement;n;n=n.parentElement)if(/^(?:auto|scroll|overlay)$/.test(t?.getComputedStyle(n).overflowY??``))return n;return null}function vr(e,t){return e.getBoundingClientRect().top-(t?t.getBoundingClientRect().top:0)}function yr(e,t,n){(t??e.ownerDocument.defaultView)?.scrollBy(0,n)}var br=`pr-helper-author-context`;function xr(e){let t=e.ownerDocument.getElementById(br);if(!t)return;let n=t.querySelector(`[data-author-context-toggle]`);n?.getAttribute(`aria-expanded`)===`false`&&gr(n),t.scrollIntoView?.({block:`start`,behavior:`smooth`}),t.querySelector(`h4`)?.focus({preventScroll:!0})}({claude:`Claude Code`,codex:`Codex`,gemini:`Gemini CLI`}).claude;function C(e,t=``){return typeof e==`string`?e:t}var Sr=`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 Cr(e){return e?`View current PR description on GitHub ↗`:`View PR description on GitHub ↗`}function wr(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 Tr(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 Er(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 Dr(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 Or(e){return e instanceof Element&&e.closest(`[data-guide-jump]`)?.dataset.guideJump||null}function kr(e){for(let t of document.querySelectorAll(`[data-goto-section]`))t.setAttribute(`aria-current`,String(t.dataset.gotoSection===e))}function Ar(){for(let e of document.querySelectorAll(`.prb-rail [data-goto-section]`))e.setAttribute(`aria-current`,`false`)}function jr(e,t){let n=e.trim();return n?`${n}\n\n${t}`:t}var Mr=50;function Nr(e){let t=e.tagName===`LI`?e.querySelector(`:scope > .prb-code`):e.nextElementSibling;return t?.classList.contains(`prb-code`)?t:null}function w(e,t=2**53-1){let n=Number(e);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),t):0}function Pr(e){if(!e||typeof e!=`object`)return;let t=e,n=w(t.top);return{cited:w(t.cited),centre:w(t.centre),expand:w(t.expand,Mr),position:w(t.position),tall:t.tall===!0,top:n>0?n:null,offset:Number.isFinite(Number(t.offset))?Math.round(Number(t.offset)):0}}function Fr(e){let t=e.getBoundingClientRect().top;for(let n of e.querySelectorAll(`tr[data-line]`)){let e=n.getBoundingClientRect();if(e.bottom>t)return{top:Number(n.dataset.line)||null,offset:Math.round(e.top-t)}}return{top:null,offset:0}}function Ir(e){let t=e.querySelector(`[data-change-navigator]`),n=e.querySelector(`.prb-code-scroll`),r=n&&n.scrollTop>0?Fr(n):{top:null,offset:0};return{cited:w(e.dataset.cited),centre:w(e.dataset.centre),expand:w(e.dataset.expand,Mr),position:w(t?.dataset.changePosition??e.dataset.position),tall:e.hasAttribute(`data-expanded`),...r}}function Lr(e,t,n){let r=e.querySelector(`.prb-code-scroll`);if(!r)return;if(t===null){r.scrollTop=0;return}let i=null,a=1/0;for(let e of r.querySelectorAll(`tr[data-line]`)){let n=Math.abs((Number(e.dataset.line)||0)-t);n<a&&(i=e,a=n)}i&&(r.scrollTop+=i.getBoundingClientRect().top-r.getBoundingClientRect().top-n)}function Rr(e,t){return e.cited===t.cited&&e.centre===t.centre&&e.expand===t.expand&&e.position===t.position}function zr(){let e=new WeakMap,t=0;return{run(n,r,i){let a=++t,o=i().then(t=>e.get(n)?.ticket===a&&(e.delete(n),t(),!0),()=>(e.get(n)?.ticket===a&&e.delete(n),!1));return e.set(n,{ticket:a,request:r,done:o}),o},pending(t){return e.get(t)}}}function Br(e){let t=e.closest(`[data-finding-card]`);if(t)return`card:${t.getAttribute(`data-finding-card`)??``}`;let n=e.closest(`[data-guide-section]`);return n?`theme:${n.getAttribute(`data-guide-section`)??``}`:`view:${e.closest(`[data-view]`)?.getAttribute(`data-view`)??``}`}function Vr(e){return[...e.querySelectorAll(`[data-file][aria-expanded="true"]`)].map(e=>{let t=Nr(e);return{host:Br(e),file:e.getAttribute(`data-file`)??``,line:e.getAttribute(`data-line`)??``,...t?{state:Ir(t)}:{}}})}function Hr(e,t){return e.host===t.host&&e.file===t.file&&e.line===t.line}function Ur(e,t){for(let n of e.querySelectorAll(`[data-file]`))if(n.getAttribute(`data-file`)===t.file&&(n.getAttribute(`data-line`)??``)===t.line&&Br(n)===t.host)return n;return null}function Wr(e){if(!e||typeof e!=`object`)return!1;let{host:t,file:n,line:r}=e;return typeof t==`string`&&typeof n==`string`&&n!==``&&typeof r==`string`}function Gr(e){let{doc:t,main:n,rail:r,log:i,panes:o}=e,s={};for(let e of t.querySelectorAll(`[data-rail-toggle][aria-controls]`))s[e.getAttribute(`aria-controls`)]=e.getAttribute(`aria-expanded`)===`true`;let c=o?.dataset.ask;return{main:n?.scrollTop??0,rail:r?.scrollTop??0,ask:c===`open`||c===`closed`?c:null,log:i?.scrollTop??0,folds:s,panels:Vr(t),focus:a(t.activeElement,t.body)}}async function Kr(e,t,n){if(!t)return!1;let{doc:r,main:i,rail:a,log:o}=e,s=t.folds&&typeof t.folds==`object`?t.folds:{};for(let e of r.querySelectorAll(`[data-rail-toggle][aria-controls]`)){let t=s[e.getAttribute(`aria-controls`)];typeof t==`boolean`&&n.setFold(e,t)}if((t.ask===`open`||t.ask===`closed`)&&n.setAsk(t.ask===`open`),Array.isArray(t.panels)){let e=t.panels.filter(Wr).map(e=>({...e,state:Pr(e.state)}));for(let t of Vr(r))if(!e.some(e=>Hr(e,t))){let e=Ur(r,t);e&&n.closePanel(e)}let i=[];for(let t of e){let e=Ur(r,t);e&&i.push(n.openPanel(e,t.state).catch(()=>{}))}await Promise.all(i)}if(!n.stillCurrent())return!1;let l=c(t,`main`);i&&l!==null&&(i.scrollTop=l);let u=c(t,`rail`);a&&u!==null&&(a.scrollTop=u);let d=c(t,`log`);return o&&d!==null&&(o.scrollTop=d),ne(r,t.focus),!0}var qr=`prb-ask-draft:`,Jr=300;function Yr(e){return`${qr}${e}`}function Xr(e,t){let{storage:n,win:r}=t,i=Yr(t.path),a=null,o=e=>{try{e.trim()===``?n?.removeItem(i):n?.setItem(i,e)}catch{}};if(t.restore&&e.value===``)try{let t=n?.getItem(i);t&&(e.value=t)}catch{}let s={save(){a!==null&&r.clearTimeout(a),a=null,o(e.value)},saveSoon(){a!==null&&r.clearTimeout(a),a=r.setTimeout(()=>s.save(),Jr)},clear(){a!==null&&r.clearTimeout(a),a=null,o(``)}};return e.addEventListener(`input`,()=>s.saveSoon()),r.addEventListener(`pagehide`,()=>s.save()),s}function Zr(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 Qr(){return`<button type="button" class="prb-update-btn" data-review-update>Update review</button>`}var $r=`Updating this review checks the latest commits and refreshes the PR conversation. Your progress and Buddy AI history will be kept.`;function ei(e){return`<details class="prb-update-alt">
44
44
  <summary>Start a new review</summary>
45
45
  <span>A brand new review, with its own findings and its own path through the change. Run <code>${y(e)}</code> in your session.<button type="button" class="prb-fresh-quiet" data-copy-command="${y(e)}">Copy</button></span>
46
- </details>`}var Jr=`prreviewbuddy review --fresh`;function Yr(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 Xr(e,t){if(!t.actions)return!1;let n=e??(t.remote?ri(t.remote):null);if(!n)return!1;let r=n.code.state===`fixed`?null:t.remote??null;return n.code.state===`changed`||r!==null||n.code.reason===`missing-commit`}function Zr(e,t={}){let n=e??(t.remote?ri(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?ii(n.code,r):ni(n.code,t.availability??null),u=e?[...l.facts,`checked ${y(Wr(n.checkedAt))}`]:l.facts;return`<div class="prb-fresh" data-state="${i||a?`changed`:`quiet`}" role="status">
46
+ </details>`}var ti=`prreviewbuddy review --fresh`;function ni(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 ri(e,t){if(!t.actions)return!1;let n=e??(t.remote?ui(t.remote):null);if(!n)return!1;let r=n.code.state===`fixed`?null:t.remote??null;return n.code.state===`changed`||r!==null||n.code.reason===`missing-commit`}function ii(e,t={}){let n=e??(t.remote?ui(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?di(n.code,r):li(n.code,t.availability??null),u=e?[...l.facts,`checked ${y(Zr(n.checkedAt))}`]:l.facts;return`<div class="prb-fresh" data-state="${i||a?`changed`:`quiet`}" role="status">
47
47
  <div class="prb-fresh-head">
48
48
  <span class="prb-fresh-dot" data-freshness="${l.state}" aria-hidden="true"></span>
49
49
  <strong class="prb-fresh-title">${y(l.title)}</strong>
50
50
  <span class="prb-fresh-facts">${u.join(` &middot; `)}</span>
51
51
  </div>
52
52
  ${l.consequence?`<p class="prb-fresh-say">${l.consequence}</p>`:``}
53
- ${Qr(n,t,i||a,Xr(e,t))}
54
- </div>`}function Qr(e,t,n,r){let i=n?``:`<button type="button" class="prb-fresh-close" data-fresh-close aria-label="Close">×</button>`;return`<div class="prb-fresh-actions">
55
- ${r?Gr():``}
56
- ${r?qr(Jr):``}
53
+ ${ai(n,t,i||a,ri(e,t))}
54
+ </div>`}function ai(e,t,n,r){let i=n?``:`<button type="button" class="prb-fresh-close" data-fresh-close aria-label="Close">×</button>`;return`<div class="prb-fresh-actions">
55
+ ${r?Qr():``}
56
+ ${r?ei(ti):``}
57
57
  ${i}
58
- ${$r(e,t,n,r===!0)}
59
- </div>`}function $r(e,t,n,r){let i=[r?y(Kr):``,t.remote?ai(e.code):oi(e.code,e.checkout.reason!==`no-pull-request`),si(e,t.actions===!0),n?`<button type="button" class="prb-fresh-quiet" data-fresh-dismiss="${y(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">
58
+ ${oi(e,t,n,r===!0)}
59
+ </div>`}function oi(e,t,n,r){let i=[r?y($r):``,t.remote?fi(e.code):pi(e.code,e.checkout.reason!==`no-pull-request`),mi(e,t.actions===!0),n?`<button type="button" class="prb-fresh-quiet" data-fresh-dismiss="${y(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">
60
60
  <summary>More details</summary>
61
61
  ${a}
62
- </details>`:a}function ei(e,t){return e===null?[]:[`${e} file${e===1?``:`s`} ${t}`]}function ti(e){return e?`<code title="${y(e)}">${y(e.slice(0,7))}</code>`:``}function T(e){return e?[`reviewed ${ti(e)}`]:[]}function ni(e,t){if(e.state===`fixed`)return{state:`fixed`,title:`Freshness: Fixed`,facts:T(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:T(e.reviewedSha),consequence:``};if(e.state===`changed`){if(e.rewritten)return{state:`changed`,title:`Code rewritten`,facts:[...T(e.reviewedSha),...ei(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:[...T(e.reviewedSha),...t,...ei(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:T(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:T(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:T(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 ri(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 ii(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:[...T(e.reviewedSha),...i,...n?ei(n.changedFiles,n.rewritten?`differ`:`changed`):[],`seen ${y(Wr(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 ai(e){return`This review is based on ${ti(e.reviewedSha)}. The pull request has newer commits. <strong>Update review</strong> fetches them first.`}function oi(e,t){if(!e.comparison)return``;let n=`<code>${y(e.comparison.ref)}</code>`;return e.state===`current`?t?`This review is based on the latest PR commit ${ti(e.reviewedSha)}.`:`This review is based on ${ti(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 si(e,t){if(!e.conversation.attached)return``;let n=y(Wr(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 ci(e,t){let n=gr(t===`changed`);for(let t of e.querySelectorAll(`[data-github-description]`))t.textContent!==n&&(t.textContent=n)}function li(e){let t=e.gist||e.whyNotJustified,n=e.locations.find(e=>e.primary)??e.locations[0];return[`### ${e.title.trim()}`,t?`**Why it matters:** ${t.trim()}`:``,`**Simpler approach:** ${e.simplerDirection.trim()}`,n?`**Start here:** \`${n.line?`${n.path}:${n.line}`:n.path}\``:``,e.draftComment?.trim()?`**Draft comment:**\n\n${di(e.draftComment.trim())}`:``].filter(e=>e!==``).join(`
62
+ </details>`:a}function si(e,t){return e===null?[]:[`${e} file${e===1?``:`s`} ${t}`]}function ci(e){return e?`<code title="${y(e)}">${y(e.slice(0,7))}</code>`:``}function T(e){return e?[`reviewed ${ci(e)}`]:[]}function li(e,t){if(e.state===`fixed`)return{state:`fixed`,title:`Freshness: Fixed`,facts:T(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:T(e.reviewedSha),consequence:``};if(e.state===`changed`){if(e.rewritten)return{state:`changed`,title:`Code rewritten`,facts:[...T(e.reviewedSha),...si(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:[...T(e.reviewedSha),...t,...si(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:T(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:T(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:T(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 ui(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 di(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:[...T(e.reviewedSha),...i,...n?si(n.changedFiles,n.rewritten?`differ`:`changed`):[],`seen ${y(Zr(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 fi(e){return`This review is based on ${ci(e.reviewedSha)}. The pull request has newer commits. <strong>Update review</strong> fetches them first.`}function pi(e,t){if(!e.comparison)return``;let n=`<code>${y(e.comparison.ref)}</code>`;return e.state===`current`?t?`This review is based on the latest PR commit ${ci(e.reviewedSha)}.`:`This review is based on ${ci(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 mi(e,t){if(!e.conversation.attached)return``;let n=y(Zr(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 hi(e,t){let n=Cr(t===`changed`);for(let t of e.querySelectorAll(`[data-github-description]`))t.textContent!==n&&(t.textContent=n)}function gi(e){let t=e.gist||e.whyNotJustified,n=e.locations.find(e=>e.primary)??e.locations[0];return[`### ${e.title.trim()}`,t?`**Why it matters:** ${t.trim()}`:``,`**Simpler approach:** ${e.simplerDirection.trim()}`,n?`**Start here:** \`${n.line?`${n.path}:${n.line}`:n.path}\``:``,e.draftComment?.trim()?`**Draft comment:**\n\n${vi(e.draftComment.trim())}`:``].filter(e=>e!==``).join(`
63
63
 
64
- `)}function ui(e){return e.length===0?``:[`## Simplification suggestions (${e.length})`,...e.map(li)].join(`
64
+ `)}function _i(e){return e.length===0?``:[`## Simplification suggestions (${e.length})`,...e.map(gi)].join(`
65
65
 
66
- `)}function di(e){return e.split(`
66
+ `)}function vi(e){return e.split(`
67
67
  `).map(e=>e===``?`>`:`> ${e}`).join(`
68
- `)}function fi(e){return e===`done`||e===`failed`}function pi(e,t){let n=e=>e.toLowerCase().replace(/\bthe\b/g,``).replace(/[^a-z]/g,``);return n(e)===n(t)}function mi(e,t=``){return`<div class="prb-doc-head">
68
+ `)}function yi(e){return e===`done`||e===`failed`}function bi(e,t){let n=e=>e.toLowerCase().replace(/\bthe\b/g,``).replace(/[^a-z]/g,``);return n(e)===n(t)}function xi(e,t=``){return`<div class="prb-doc-head">
69
69
  <h3 class="prb-doc-title">${y(e)}</h3>
70
70
  ${t}
71
- </div>`}var hi=`<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>`,gi=`<path d="M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7"/>`;function _i(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 vi(e,t){let n=`Expand ${t}`;return`<button type="button" class="prb-focus-toggle" data-focus-toggle="${e}" data-focus-name="${y(t)}" aria-pressed="false" aria-label="${y(n)}" title="${y(n)}">${_i(hi,`prb-focus-expand`)}${_i(gi,`prb-focus-collapse`)}</button>`}vi(`kiss`,`KISS review`),mi(`Recommendations`,vi(`kissrecs`,`Recommendations`));var yi={author:{accepted:`Plan to simplify`,declined:`Keep as implemented`},reviewer:{accepted:`Raise with author`,declined:`Leave it`}};function bi(e,t){return t===`undecided`?`Open`:yi[e][t]}function xi(e,t){return t===0?`<span class="pr-helper-questions-progress-check" aria-hidden="true">\u2713</span><span class="pr-helper-questions-progress-count">All ${e} decided</span>`:`<span class="pr-helper-questions-progress-count">${t} of ${e} undecided</span>`}function Si(e){return`Decided (${e})`}function Ci(e,t,n=!1){return n?{enabled:!1,note:`Saving your decision. You can copy once it is saved.`}:t?{enabled:!1,note:`Run KISS again before handing these recommendations off.`}:e===0?{enabled:!1,note:`Choose Raise with author on the recommendations you want to hand off.`}:{enabled:!0,note:`${e===1?`1 recommendation`:`${e} recommendations`} to raise with the author.`}}function wi(e,t,n={}){if(!t||t.state!==`changed`)return``;let r=n.actions?`<button type="button" class="prb-kiss-fresh-run" data-kiss-run-open>Run again</button>`:``;if(n.dismissedSha&&n.dismissedSha===t.latestSha)return`<div class="prb-kiss-fresh" data-kiss-freshness="changed" data-collapsed role="status">
71
+ </div>`}var Si=`<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>`,Ci=`<path d="M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7"/>`;function wi(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 Ti(e,t){let n=`Expand ${t}`;return`<button type="button" class="prb-focus-toggle" data-focus-toggle="${e}" data-focus-name="${y(t)}" aria-pressed="false" aria-label="${y(n)}" title="${y(n)}">${wi(Si,`prb-focus-expand`)}${wi(Ci,`prb-focus-collapse`)}</button>`}Ti(`kiss`,`KISS review`),xi(`Recommendations`,Ti(`kissrecs`,`Recommendations`));var Ei={author:{accepted:`Plan to simplify`,declined:`Keep as implemented`},reviewer:{accepted:`Raise with author`,declined:`Leave it`}};function Di(e,t){return t===`undecided`?`Open`:Ei[e][t]}function Oi(e,t){return t===0?`<span class="pr-helper-questions-progress-check" aria-hidden="true">\u2713</span><span class="pr-helper-questions-progress-count">All ${e} decided</span>`:`<span class="pr-helper-questions-progress-count">${t} of ${e} undecided</span>`}function ki(e){return`Decided (${e})`}function Ai(e,t,n=!1){return n?{enabled:!1,note:`Saving your decision. You can copy once it is saved.`}:t?{enabled:!1,note:`Run KISS again before handing these recommendations off.`}:e===0?{enabled:!1,note:`Choose Raise with author on the recommendations you want to hand off.`}:{enabled:!0,note:`${e===1?`1 recommendation`:`${e} recommendations`} to raise with the author.`}}function ji(e,t,n={}){if(!t||t.state!==`changed`)return``;let r=n.actions?`<button type="button" class="prb-kiss-fresh-run" data-kiss-run-open>Run again</button>`:``;if(n.dismissedSha&&n.dismissedSha===t.latestSha)return`<div class="prb-kiss-fresh" data-kiss-freshness="changed" data-collapsed role="status">
72
72
  <p><strong>This KISS review describes commit ${y(e.slice(0,7))}.</strong> The branch has moved on since. ${r}</p>
73
73
  </div>`;let i=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">
74
74
  <p><strong>This KISS review describes commit ${y(e.slice(0,7))}.</strong> ${y(i)}</p>
75
75
  <p class="prb-kiss-fresh-note">Running KISS again analyses the branch as it is now. The report below and your decisions about it are kept either way.</p>
76
76
  <p class="prb-kiss-fresh-actions">${r}${n.actions&&t.latestSha?`<button type="button" class="prb-kiss-fresh-dismiss" data-kiss-freshness-dismiss="${y(t.latestSha)}">Not now</button>`:``}</p>
77
- </div>`}var Ti=new WeakMap;function Ei(e){let t=e.dataset.kissDecide;return e.getAttribute(`aria-pressed`)===`true`?`undecided`:t}function Di(e,t,n){let r=e.dataset.decision??`undecided`,i=async()=>{Li(e);let i=e.contains(document.activeElement);Oi(e,t),Fi(e,!0),Ai(n),i&&Ii(e);let a=await n.send({runId:e.dataset.kissRunId??``,recommendationId:e.dataset.kissRec??``,decision:t}).catch(()=>!1);if(Fi(e,!1),a){Ai(n);return}Oi(e,r),Ai(n),Ri(e,t,n)},a=(Ti.get(e)??Promise.resolve()).then(i,i);return Ti.set(e,a),a}function Oi(e,t){e.dataset.decision=t;let n=Pi(e),r=e.querySelector(`[data-kiss-status]`);r&&(r.dataset.kissStatus=t,r.textContent=bi(n,t));for(let r of e.querySelectorAll(`[data-kiss-decide]`))r.setAttribute(`aria-pressed`,String(r.dataset.kissDecide===t)),r.textContent=yi[n][r.dataset.kissDecide];ki(e,t!==`undecided`)}function ki(e,t){let n=(e.closest(`[data-view="kissrecs"]`)??document).querySelector(t?`[data-kiss-decided-list]`:`[data-kiss-open-list]`);if(!n||e.parentElement===n)return;let r=Number(e.dataset.rank),i=[...n.querySelectorAll(`:scope > [data-kiss-rec]`)].find(e=>Number(e.dataset.rank)>r);n.insertBefore(e,i??null)}function Ai(e,t=document){let n=[...t.querySelectorAll(`[data-kiss-rec]`)];if(n.length===0)return;let r=n.filter(e=>e.dataset.decision&&e.dataset.decision!==`undecided`).length,i=n.length-r,a=t.querySelector(`[data-kiss-progress]`);a&&(a.innerHTML=xi(n.length,i));let o=t.querySelector(`[data-kiss-decided]`);if(o){o.hidden=r===0,o.toggleAttribute(`data-nothing-open`,i===0);let e=o.querySelector(`[data-kiss-decided-summary]`);e&&(e.textContent=Si(r))}e.paintRail(n.length,i),ji(t)}function ji(e=document){let t=e.querySelector(`[data-kiss-handoff]`);if(!t)return;let n=new Set([...e.querySelectorAll(`[data-kiss-rec][data-decision="accepted"]`)].map(e=>e.dataset.kissRec)),r=Ni(t).filter(e=>n.has(e.id)),i=e.querySelector(`[data-kiss-rec][aria-busy]`)!==null,a=Ci(r.length,t.hasAttribute(`data-stale`),i),o=t.querySelector(`[data-kiss-handoff-copy]`);o&&(o.disabled=!a.enabled,o.setAttribute(`data-copy-source`,a.enabled?ui(r):``));let s=t.querySelector(`[data-kiss-handoff-note]`);s&&(s.textContent=a.note)}function Mi(e,t=document){for(let n of t.querySelectorAll(`[data-kiss-stale]`))n.hidden=!e;let n=t.querySelector(`[data-kiss-handoff]`);n&&(n.toggleAttribute(`data-stale`,e),ji(t))}function Ni(e){try{let t=JSON.parse(e.querySelector(`script[data-kiss-handoff-source]`)?.textContent??`[]`);return Array.isArray(t)?t:[]}catch{return[]}}function Pi(e){return e.dataset.audience===`author`?`author`:`reviewer`}function Fi(e,t){e.toggleAttribute(`aria-busy`,t);for(let n of e.querySelectorAll(`[data-kiss-decide]`))n.disabled=t}function Ii(e){if(!e.closest(`[data-kiss-decided-list]`)){e.querySelector(`[data-kiss-decide][aria-pressed="true"], [data-kiss-decide]`)?.focus();return}let t=e.closest(`[data-view="kissrecs"]`)??document;(t.querySelector(`[data-kiss-open-list] > [data-kiss-rec] .prb-kiss-rec-title`)??t.querySelector(`[data-kiss-decided-summary]`))?.focus()}function Li(e){e.querySelector(`[data-kiss-decision-error]`)?.remove()}function Ri(e,t,n){let r=document.createElement(`p`);r.className=`prb-kiss-decision-error`,r.dataset.kissDecisionError=``,r.setAttribute(`role`,`alert`),r.append(`Couldn't save that decision. `);let i=document.createElement(`button`);i.type=`button`,i.className=`prb-kiss-decision-retry`,i.textContent=`Try again`,i.addEventListener(`click`,()=>void Di(e,t,n)),r.append(i),(e.querySelector(`[data-kiss-actions]`)??e).append(r);let a=e.closest(`[data-kiss-decided]`);a&&(a.open=!0),i.focus()}function zi(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 Bi(e,t){t.complete!==void 0&&Ui(e,t.complete),t.activity!==void 0&&Vi(e,t.activity??void 0),t.lifecycle===void 0?t.activity!==void 0&&Wi(e,Hi(e)):Wi(e,t.lifecycle??void 0),t.queued!==void 0&&Gi(e,t.queued)}function Vi(e,t){let n=e.querySelector(`[data-review-menu]`);n&&(delete n.dataset.activityAt,delete n.dataset.activityKind,delete n.dataset.activityMovedAt,t&&(n.dataset.activityAt=String(t.at),n.dataset.activityKind=t.kind,t.movedAt!==void 0&&(n.dataset.activityMovedAt=String(t.movedAt))))}function Hi(e){let t=e.querySelector(`[data-review-menu]`);return ae(t?{state:t.dataset.lifecycleState,at:Number(t.dataset.lifecycleAt)}:void 0)}function Ui(e,t){let n=t?`complete`:`in-progress`,r=e.querySelector(`[data-page-status]`);r&&(r.dataset.status=n,r.textContent=l(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=g(e)}}function Wi(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 i=n?Ki(n):void 0,a=e.querySelector(`[data-page-lifecycle]`);if(a){let e=o(t,i);a.hidden=e===void 0,a.textContent=e?.text??``,a.toggleAttribute(`data-changed`,e?.changed===!0)}for(let n of e.querySelectorAll(`[data-review-menu] [data-lifecycle-set]`)){let e=n.dataset.lifecycleSet;n.hidden=!c(e,t,i),n.textContent=r(e,t,i)}}function Gi(e,n){e.querySelector(`[data-review-menu]`)?.toggleAttribute(`data-queued`,n);let r=e.querySelector(`[data-review-menu] [data-queue-action]`);r&&(r.dataset.queueAction=n?`remove`:`add`,r.textContent=t(n))}function Ki(e){return u(e.dataset)}function qi(e){return ae(e)??null}function Ji(e){if(typeof e!=`object`||!e)return null;let{complete:t,lifecycle:n,queued:r,activity:i}=e,a={lifecycle:qi(n)};if(typeof t==`boolean`&&(a.complete=t),typeof r==`boolean`&&(a.queued=r),i===null)a.activity=null;else{let e=d(i);e&&(a.activity=e)}return a}function Yi(){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)}}}}var Xi=`The workspace server did not answer. It may have stopped.`;function Zi(e){let t=()=>e.root.querySelector(`[data-review-menu]`),n=!1,r=async(t,r,i)=>{if(n)return{error:null,busy:!0};n=!0;let a=e.gate.begin();try{let n=await e.post(t,r),a=await n.json().catch(()=>null);return n.ok&&a?(Bi(e.root,i(a)),{error:null}):{error:typeof a?.error==`string`?a.error:`That could not be changed.`}}catch{return{error:Xi}}finally{n=!1,a()}},i=e=>r(`/queue`,{action:e},e=>({lifecycle:qi(e.lifecycle),queued:e.queued===!0}));return{setComplete:e=>r(`/state`,{complete:e},e=>({complete:typeof e.completedAt==`number`,queued:e.queued===!0})),setLifecycle:e=>r(`/lifecycle`,{state:e},e=>({lifecycle:qi(e.lifecycle),queued:e.queued===!0})),setQueued:i,toggleQueued:()=>i(t()?.hasAttribute(`data-queued`)?`remove`:`add`),checkForUpdates:async()=>{await e.checkForUpdates()},deleteReview:async()=>{try{let t=await e.post(`/delete`);return t.ok?{error:null}:{error:(await t.json().catch(()=>null))?.error??`That could not be deleted.`}}catch{return{error:Xi}}},offer:()=>{let r=t(),i=r?.hasAttribute(`data-can-write`)===!0,a=i&&r?.hasAttribute(`data-branch-actions`)===!0,o=r?ae({state:r.dataset.lifecycleState,at:Number(r.dataset.lifecycleAt)}):void 0,s=r?u(r.dataset):void 0,l=e.root.querySelector(`[data-page-status]`)?.dataset.status===`complete`,d=!n;return{reviewed:d&&i&&!l,waiting:d&&a&&c(`waiting`,o,s),done:d&&a&&c(`done`,o,s),queue:d&&a,checkForUpdates:i&&r?.hasAttribute(`data-checkable`)===!0,delete:i}},busy:()=>n}}function Qi(e,t){return`${e} ${t}${e===1?``:`s`}`}function $i(e,t){let n=e+t;return{total:n===0?`Nothing chosen`:`${n} chosen`,issues:e?Qi(e,`issue`):``,questions:t?Qi(t,`question`):``}}function ea(e,t){let n=$i(e,t);return[n.total,n.issues,n.questions].filter(Boolean).join(` · `)}function ta(e){return e===0?``:`${e} chosen`}function na(e){let t=(e,t)=>{let n=t.map(e=>e.trim()).filter(Boolean);return n.length===0?null:`## ${e}\n\n${n.map((e,t)=>{let n=`${t+1}. `;return n+e.replace(/\n/g,`\n${` `.repeat(n.length)}`).replace(/\n +\n/g,`
77
+ </div>`}var Mi=new WeakMap;function Ni(e){let t=e.dataset.kissDecide;return e.getAttribute(`aria-pressed`)===`true`?`undecided`:t}function Pi(e,t,n){let r=e.dataset.decision??`undecided`,i=async()=>{Wi(e);let i=e.contains(document.activeElement);Fi(e,t),Hi(e,!0),Li(n),i&&Ui(e);let a=await n.send({runId:e.dataset.kissRunId??``,recommendationId:e.dataset.kissRec??``,decision:t}).catch(()=>!1);if(Hi(e,!1),a){Li(n);return}Fi(e,r),Li(n),Gi(e,t,n)},a=(Mi.get(e)??Promise.resolve()).then(i,i);return Mi.set(e,a),a}function Fi(e,t){e.dataset.decision=t;let n=Vi(e),r=e.querySelector(`[data-kiss-status]`);r&&(r.dataset.kissStatus=t,r.textContent=Di(n,t));for(let r of e.querySelectorAll(`[data-kiss-decide]`))r.setAttribute(`aria-pressed`,String(r.dataset.kissDecide===t)),r.textContent=Ei[n][r.dataset.kissDecide];Ii(e,t!==`undecided`)}function Ii(e,t){let n=(e.closest(`[data-view="kissrecs"]`)??document).querySelector(t?`[data-kiss-decided-list]`:`[data-kiss-open-list]`);if(!n||e.parentElement===n)return;let r=Number(e.dataset.rank),i=[...n.querySelectorAll(`:scope > [data-kiss-rec]`)].find(e=>Number(e.dataset.rank)>r);n.insertBefore(e,i??null)}function Li(e,t=document){let n=[...t.querySelectorAll(`[data-kiss-rec]`)];if(n.length===0)return;let r=n.filter(e=>e.dataset.decision&&e.dataset.decision!==`undecided`).length,i=n.length-r,a=t.querySelector(`[data-kiss-progress]`);a&&(a.innerHTML=Oi(n.length,i));let o=t.querySelector(`[data-kiss-decided]`);if(o){o.hidden=r===0,o.toggleAttribute(`data-nothing-open`,i===0);let e=o.querySelector(`[data-kiss-decided-summary]`);e&&(e.textContent=ki(r))}e.paintRail(n.length,i),Ri(t)}function Ri(e=document){let t=e.querySelector(`[data-kiss-handoff]`);if(!t)return;let n=new Set([...e.querySelectorAll(`[data-kiss-rec][data-decision="accepted"]`)].map(e=>e.dataset.kissRec)),r=Bi(t).filter(e=>n.has(e.id)),i=e.querySelector(`[data-kiss-rec][aria-busy]`)!==null,a=Ai(r.length,t.hasAttribute(`data-stale`),i),o=t.querySelector(`[data-kiss-handoff-copy]`);o&&(o.disabled=!a.enabled,o.setAttribute(`data-copy-source`,a.enabled?_i(r):``));let s=t.querySelector(`[data-kiss-handoff-note]`);s&&(s.textContent=a.note)}function zi(e,t=document){for(let n of t.querySelectorAll(`[data-kiss-stale]`))n.hidden=!e;let n=t.querySelector(`[data-kiss-handoff]`);n&&(n.toggleAttribute(`data-stale`,e),Ri(t))}function Bi(e){try{let t=JSON.parse(e.querySelector(`script[data-kiss-handoff-source]`)?.textContent??`[]`);return Array.isArray(t)?t:[]}catch{return[]}}function Vi(e){return e.dataset.audience===`author`?`author`:`reviewer`}function Hi(e,t){e.toggleAttribute(`aria-busy`,t);for(let n of e.querySelectorAll(`[data-kiss-decide]`))n.disabled=t}function Ui(e){if(!e.closest(`[data-kiss-decided-list]`)){e.querySelector(`[data-kiss-decide][aria-pressed="true"], [data-kiss-decide]`)?.focus();return}let t=e.closest(`[data-view="kissrecs"]`)??document;(t.querySelector(`[data-kiss-open-list] > [data-kiss-rec] .prb-kiss-rec-title`)??t.querySelector(`[data-kiss-decided-summary]`))?.focus()}function Wi(e){e.querySelector(`[data-kiss-decision-error]`)?.remove()}function Gi(e,t,n){let r=document.createElement(`p`);r.className=`prb-kiss-decision-error`,r.dataset.kissDecisionError=``,r.setAttribute(`role`,`alert`),r.append(`Couldn't save that decision. `);let i=document.createElement(`button`);i.type=`button`,i.className=`prb-kiss-decision-retry`,i.textContent=`Try again`,i.addEventListener(`click`,()=>void Pi(e,t,n)),r.append(i),(e.querySelector(`[data-kiss-actions]`)??e).append(r);let a=e.closest(`[data-kiss-decided]`);a&&(a.open=!0),i.focus()}function Ki(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 qi(e,t){t.complete!==void 0&&Xi(e,t.complete),t.activity!==void 0&&Ji(e,t.activity??void 0),t.lifecycle===void 0?t.activity!==void 0&&Zi(e,Yi(e)):Zi(e,t.lifecycle??void 0),t.queued!==void 0&&Qi(e,t.queued)}function Ji(e,t){let n=e.querySelector(`[data-review-menu]`);n&&(delete n.dataset.activityAt,delete n.dataset.activityKind,delete n.dataset.activityMovedAt,t&&(n.dataset.activityAt=String(t.at),n.dataset.activityKind=t.kind,t.movedAt!==void 0&&(n.dataset.activityMovedAt=String(t.movedAt))))}function Yi(e){let t=e.querySelector(`[data-review-menu]`);return ae(t?{state:t.dataset.lifecycleState,at:Number(t.dataset.lifecycleAt)}:void 0)}function Xi(e,t){let n=t?`complete`:`in-progress`,r=e.querySelector(`[data-page-status]`);r&&(r.dataset.status=n,r.textContent=u(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=ie(e)}}function Zi(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 i=n?$i(n):void 0,a=e.querySelector(`[data-page-lifecycle]`);if(a){let e=o(t,i);a.hidden=e===void 0,a.textContent=e?.text??``,a.toggleAttribute(`data-changed`,e?.changed===!0)}for(let n of e.querySelectorAll(`[data-review-menu] [data-lifecycle-set]`)){let e=n.dataset.lifecycleSet;n.hidden=!l(e,t,i),n.textContent=r(e,t,i)}}function Qi(e,n){e.querySelector(`[data-review-menu]`)?.toggleAttribute(`data-queued`,n);let r=e.querySelector(`[data-review-menu] [data-queue-action]`);r&&(r.dataset.queueAction=n?`remove`:`add`,r.textContent=t(n))}function $i(e){return d(e.dataset)}function ea(e){return ae(e)??null}function ta(e){if(typeof e!=`object`||!e)return null;let{complete:t,lifecycle:n,queued:r,activity:i}=e,a={lifecycle:ea(n)};if(typeof t==`boolean`&&(a.complete=t),typeof r==`boolean`&&(a.queued=r),i===null)a.activity=null;else{let e=f(i);e&&(a.activity=e)}return a}function na(){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)}}}}var ra=`The workspace server did not answer. It may have stopped.`;function ia(e){let t=()=>e.root.querySelector(`[data-review-menu]`),n=!1,r=async(t,r,i)=>{if(n)return{error:null,busy:!0};n=!0;let a=e.gate.begin();try{let n=await e.post(t,r),a=await n.json().catch(()=>null);return n.ok&&a?(qi(e.root,i(a)),{error:null}):{error:typeof a?.error==`string`?a.error:`That could not be changed.`}}catch{return{error:ra}}finally{n=!1,a()}},i=e=>r(`/queue`,{action:e},e=>({lifecycle:ea(e.lifecycle),queued:e.queued===!0}));return{setComplete:e=>r(`/state`,{complete:e},e=>({complete:typeof e.completedAt==`number`,queued:e.queued===!0})),setLifecycle:e=>r(`/lifecycle`,{state:e},e=>({lifecycle:ea(e.lifecycle),queued:e.queued===!0})),setQueued:i,toggleQueued:()=>i(t()?.hasAttribute(`data-queued`)?`remove`:`add`),checkForUpdates:async()=>{await e.checkForUpdates()},deleteReview:async()=>{try{let t=await e.post(`/delete`);return t.ok?{error:null}:{error:(await t.json().catch(()=>null))?.error??`That could not be deleted.`}}catch{return{error:ra}}},offer:()=>{let r=t(),i=r?.hasAttribute(`data-can-write`)===!0,a=i&&r?.hasAttribute(`data-branch-actions`)===!0,o=r?ae({state:r.dataset.lifecycleState,at:Number(r.dataset.lifecycleAt)}):void 0,s=r?d(r.dataset):void 0,c=e.root.querySelector(`[data-page-status]`)?.dataset.status===`complete`,u=!n;return{reviewed:u&&i&&!c,waiting:u&&a&&l(`waiting`,o,s),done:u&&a&&l(`done`,o,s),queue:u&&a,checkForUpdates:i&&r?.hasAttribute(`data-checkable`)===!0,delete:i}},busy:()=>n}}function aa(e,t){return`${e} ${t}${e===1?``:`s`}`}function oa(e,t){let n=e+t;return{total:n===0?`Nothing chosen`:`${n} chosen`,issues:e?aa(e,`issue`):``,questions:t?aa(t,`question`):``}}function sa(e,t){let n=oa(e,t);return[n.total,n.issues,n.questions].filter(Boolean).join(` · `)}function ca(e){return e===0?``:`${e} chosen`}function la(e){let t=(e,t)=>{let n=t.map(e=>e.trim()).filter(Boolean);return n.length===0?null:`## ${e}\n\n${n.map((e,t)=>{let n=`${t+1}. `;return n+e.replace(/\n/g,`\n${` `.repeat(n.length)}`).replace(/\n +\n/g,`
78
78
 
79
79
  `)}).join(`
80
80
 
81
81
  `)}`};return[t(`Issues`,e.issues),t(`Questions`,e.questions)].filter(Boolean).join(`
82
82
 
83
- `)}var ra=e=>`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`;ra(`<path d="m3 17 2 2 4-4M3 7l2 2 4-4M13 6h8M13 12h8M13 18h8"/>`),ra(`<path d="M20 6 9 17l-5-5"/>`);var E=[`preview`,`markdown`],ia={issue:`issues`,question:`questions`};function aa({root:e,showView:t}){let n=!1,r={issue:new Set,question:new Set},i=null,a=e=>e.closest(`[data-finding-card]`)?.getAttribute(`data-finding-card`)??``,o=e=>e.dataset.feedbackPick===`issue`||e.dataset.feedbackPick===`question`?e.dataset.feedbackPick:null;function s(t){return[...e.querySelectorAll(`[data-view="${ia[t]}"] [data-finding-card]`)].filter(e=>r[t].has(e.getAttribute(`data-finding-card`)??``)).map(e=>e.querySelector(`[data-copy-source]`)?.getAttribute(`data-copy-source`)??``)}function c(){let t=r.issue.size,i=r.question.size;e.querySelector(`.prb-body`)?.toggleAttribute(`data-feedback-selecting`,n);for(let t of e.querySelectorAll(`[data-feedback-select]`))t.setAttribute(`aria-pressed`,String(n));for(let t of e.querySelectorAll(`[data-feedback-pick]`)){let e=o(t);t.checked=e!==null&&r[e].has(a(t))}let s=e.querySelector(`[data-feedback-tray]`);if(s){s.hidden=!n;let e=$i(t,i),r=s.querySelector(`[data-feedback-total]`);r&&(r.textContent=e.total);for(let t of[`issues`,`questions`]){let n=s.querySelector(`[data-feedback-goto="${t}"]`);if(!n)continue;let r=n.querySelector(`[data-feedback-goto-label]`);r&&(r.textContent=e[t]),n.hidden=e[t]===``}let a=s.querySelector(`[data-feedback-prepare]`);a&&(a.disabled=t+i===0)}for(let[r,a]of[[`issues`,t],[`questions`,i]]){let t=e.querySelector(`[data-rail-selected="${r}"]`);t&&(t.textContent=ta(a),t.hidden=!n||a===0)}}function l(){let t=e.querySelector(`[data-feedback-preview]`),n=e.querySelector(`[data-feedback-text]`)?.value??``;t&&(t.innerHTML=n.trim()?Ue(n):`<p class="prb-draft-empty">The draft is empty.</p>`,t.scrollTop=0)}function u(t){let n=e.querySelector(`[data-feedback-text]`);n&&(n.value=t),e.querySelector(`[data-feedback-copy]`)?.setAttribute(ft,t)}let d={enter(){n=!0,c()},exit(){n=!1,r.issue.clear(),r.question.clear(),c()},clear(){r.issue.clear(),r.question.clear(),c()},toggle(e,t,n){!t||r[e].has(t)===n||(n?r[e].add(t):r[e].delete(t),i=null,c())},compose(){return na({issues:s(`issue`),questions:s(`question`)})},prepare(){if(r.issue.size+r.question.size===0)return;i??=d.compose(),u(i);let t=e.querySelector(`[data-feedback-dialog-count]`);t&&(t.textContent=ea(r.issue.size,r.question.size));let n=e.querySelector(`[data-feedback-dialog]`);n&&!n.open&&n.showModal(),d.showDraftTab(`preview`),e.querySelector(`[data-draft-tab="preview"]`)?.focus()},showDraftTab(t){for(let n of E){let r=e.querySelector(`[data-draft-tab="${n}"]`);r?.setAttribute(`aria-selected`,String(n===t)),r?.setAttribute(`tabindex`,n===t?`0`:`-1`);let i=e.getElementById(`prb-draft-${n}`);i&&(i.hidden=n!==t)}if(t===`preview`)return l();let n=e.querySelector(`[data-feedback-text]`);n?.setSelectionRange(0,0),n&&(n.scrollTop=0)},state(){return{selecting:n,issues:[...r.issue],questions:[...r.question]}}};return e.addEventListener(`change`,e=>{let t=e.target.closest(`[data-feedback-pick]`),n=t?o(t):null;t&&n&&d.toggle(n,a(t),t.checked)}),e.addEventListener(`input`,t=>{let n=t.target.closest(`[data-feedback-text]`);n&&(i!==null&&(i=n.value),e.querySelector(`[data-feedback-copy]`)?.setAttribute(ft,n.value))}),e.addEventListener(`click`,r=>{let i=r.target;if(i.closest(`[data-feedback-select]`))return n?d.exit():d.enter();if(i.closest(`[data-feedback-clear]`))return d.clear();if(i.closest(`[data-feedback-done]`))return d.exit();if(i.closest(`[data-feedback-prepare]`))return d.prepare();if(i.closest(`[data-feedback-close]`))return e.querySelector(`[data-feedback-dialog]`)?.close();let a=i.closest(`[data-draft-tab]`)?.dataset.draftTab;if(a===`preview`||a===`markdown`)return d.showDraftTab(a);let o=i.closest(`[data-feedback-goto]`)?.dataset.feedbackGoto;(o===`issues`||o===`questions`)&&t(o)}),e.addEventListener(`keydown`,t=>{let n=t.target.closest(`[data-draft-tab]`)?.dataset.draftTab;if(!n)return;let r=E.indexOf(n),i=t.key===`ArrowRight`?E[(r+1)%E.length]:t.key===`ArrowLeft`?E[(r+E.length-1)%E.length]:t.key===`Home`?E[0]:t.key===`End`?E[E.length-1]:null;i&&(t.preventDefault(),d.showDraftTab(i),e.querySelector(`[data-draft-tab="${i}"]`)?.focus())}),c(),d}function oa(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[...e]:e.filter(e=>{let t=`${e.name}\n${e.prompt}`.toLowerCase();return n.every(e=>t.includes(e))})}function sa(e){return e<0||e>=10?null:e===9?`0`:String(e+1)}function ca(e){return/^[0-9]$/.test(e)?e===`0`?9:Number(e)-1:null}function la(e){return{title:`Choose a prompt`,mount(t,n){let r=t.ownerDocument,i=e.prompts(),a=r.createElement(`input`);a.type=`search`,a.className=`prb-palette-input`,a.placeholder=`Filter prompts`,a.setAttribute(`aria-label`,`Filter prompts`),a.spellcheck=!1;let o=r.createElement(`p`);o.className=`prb-palette-summary`,o.setAttribute(`aria-live`,`polite`);let s=r.createElement(`div`);s.className=`prb-palette-results`,s.setAttribute(`role`,`group`),s.setAttribute(`aria-label`,`Prompts`);let c=[],l=()=>[...s.querySelectorAll(`[data-prompt-choice]`)],u=()=>{let e=r.activeElement===a;for(let[t,n]of l().entries())n.toggleAttribute(`data-enter-target`,e&&t===0)},d=()=>{c=oa(i,a.value),s.replaceChildren(...c.map((e,t)=>{let n=r.createElement(`button`);n.type=`button`,n.className=`prb-palette-result prb-palette-prompt`,n.dataset.promptChoice=e.id;let i=r.createElement(`kbd`);i.className=`prb-kbd prb-palette-num`;let a=sa(t);a?i.textContent=a:i.setAttribute(`aria-hidden`,`true`);let o=r.createElement(`span`);o.className=`prb-palette-prompt-text`;let s=r.createElement(`span`);s.className=`prb-palette-result-title`,s.textContent=e.name;let c=r.createElement(`span`);return c.className=`prb-palette-prompt-said`,c.textContent=e.prompt,o.append(s,c),n.append(i,o),n})),o.textContent=i.length===0?`No saved prompts yet. Add one under Your prompts in Buddy AI.`:c.length===0?`No prompts match.`:c.length===i.length?`${i.length} ${i.length===1?`prompt`:`prompts`}`:`${c.length} of ${i.length} prompts`,u()},f=t=>{!t||!c.some(e=>e.id===t)||(n(),e.choose(t))},ee=e=>{a.value=e===`Backspace`?a.value.slice(0,-1):a.value+e,a.focus(),a.dispatchEvent(new Event(`input`,{bubbles:!0}))};a.addEventListener(`input`,d),a.addEventListener(`focus`,u),a.addEventListener(`blur`,u),s.addEventListener(`click`,e=>{f(e.target.closest(`[data-prompt-choice]`)?.dataset.promptChoice)}),t.addEventListener(`keydown`,e=>{if(e.isComposing||e.metaKey||e.ctrlKey||e.altKey)return;let t=l(),n=e.target===a,r=t.indexOf(e.target),i=ca(e.key);if(i!==null)return e.preventDefault(),f(t[i]?.dataset.promptChoice);if(e.key===`Enter`)return e.preventDefault(),f((n?t[0]:t[r])?.dataset.promptChoice);let o=e.key===`ArrowDown`||!n&&e.key===`j`,s=e.key===`ArrowUp`||!n&&e.key===`k`;if(o||s){let n=o?r<0?t[0]:t[r+1]:r<=0?a:t[r-1];e.preventDefault(),n?.focus();return}!n&&(e.key.length===1||e.key===`Backspace`)&&(e.preventDefault(),ee(e.key))}),t.append(a,o,s),d(),a.focus()}}}function ua(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`}`}vi(`progress`,`Review progress`);var da={job:`data-job-phase`,kiss:`data-kiss-phase`,update:`data-update-phase`};function fa(e){let t=new Map;for(let n of Object.keys(da)){let r=da[n],i=e.querySelector(`[${r}]`);i&&!fi(i.getAttribute(r)??void 0)&&t.set(n,i)}return t}function pa(e,t,n){return t.failed?!0:e===`update`?t.phase===`none`||fi(t.phase):ma(t.phase,n)}function ma(e,t){return fi(e)?!0:(e===`conversation`||e===`analysing`)&&!t.querySelector(`[data-view="files"]`)}function ha(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||pi(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 ga(e){let t=e.querySelector(`[data-started-at]`),n=Number(t?.dataset.startedAt);!t||!Number.isFinite(n)||(t.textContent=`Running for ${ua(n)}.`)}async function _a({look:e,reload:t,giveUpMs:n=2e4,pauseMs:r=400}){let i=!1,a=()=>{i||(i=!0,t())};for(setTimeout(a,n);!i;){try{let t=await e();if(!t||t===`none`||fi(t))return a()}catch{}await new Promise(e=>setTimeout(e,r))}}function va(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-${y(e.scope)}" data-diagram-card="${y(e.scope)}">
83
+ `)}var ua=e=>`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`;ua(`<path d="m3 17 2 2 4-4M3 7l2 2 4-4M13 6h8M13 12h8M13 18h8"/>`),ua(`<path d="M20 6 9 17l-5-5"/>`);var E=[`preview`,`markdown`],da={issue:`issues`,question:`questions`},fa=`a, button, input, select, textarea, label, summary, [data-menu], [role="button"], [contenteditable], [data-file], .prb-code`;function pa({root:e,showView:t}){let n=!1,r={issue:new Set,question:new Set},i=null,a=e=>e.closest(`[data-finding-card]`)?.getAttribute(`data-finding-card`)??``,o=e=>e.dataset.feedbackPick===`issue`||e.dataset.feedbackPick===`question`?e.dataset.feedbackPick:null;function s(t){return[...e.querySelectorAll(`[data-view="${da[t]}"] [data-finding-card]`)].filter(e=>r[t].has(e.getAttribute(`data-finding-card`)??``)).map(e=>e.querySelector(`[data-copy-source]`)?.getAttribute(`data-copy-source`)??``)}function c(){let t=r.issue.size,i=r.question.size;e.querySelector(`.prb-body`)?.toggleAttribute(`data-feedback-selecting`,n);for(let t of e.querySelectorAll(`[data-feedback-select]`))t.setAttribute(`aria-pressed`,String(n));for(let t of e.querySelectorAll(`[data-feedback-pick]`)){let e=o(t);t.checked=e!==null&&r[e].has(a(t))}let s=e.querySelector(`[data-feedback-tray]`);if(s){s.hidden=!n;let e=oa(t,i),r=s.querySelector(`[data-feedback-total]`);r&&(r.textContent=e.total);for(let t of[`issues`,`questions`]){let n=s.querySelector(`[data-feedback-goto="${t}"]`);if(!n)continue;let r=n.querySelector(`[data-feedback-goto-label]`);r&&(r.textContent=e[t]),n.hidden=e[t]===``}let a=s.querySelector(`[data-feedback-prepare]`);a&&(a.disabled=t+i===0)}for(let[r,a]of[[`issues`,t],[`questions`,i]]){let t=e.querySelector(`[data-rail-selected="${r}"]`);t&&(t.textContent=ca(a),t.hidden=!n||a===0)}}function l(){let t=e.querySelector(`[data-feedback-preview]`),n=e.querySelector(`[data-feedback-text]`)?.value??``;t&&(t.innerHTML=n.trim()?We(n):`<p class="prb-draft-empty">The draft is empty.</p>`,t.scrollTop=0)}function u(t){let n=e.querySelector(`[data-feedback-text]`);n&&(n.value=t),e.querySelector(`[data-feedback-copy]`)?.setAttribute(mt,t)}let d={enter(){n=!0,c()},exit(){n=!1,r.issue.clear(),r.question.clear(),c()},clear(){r.issue.clear(),r.question.clear(),c()},toggle(e,t,n){!t||r[e].has(t)===n||(n?r[e].add(t):r[e].delete(t),i=null,c())},flip(e){let t=e.querySelector(`[data-feedback-pick]`),i=t?o(t):null,a=e.getAttribute(`data-finding-card`)??``;return!n||!i||!a?!1:(d.toggle(i,a,!r[i].has(a)),!0)},compose(){return la({issues:s(`issue`),questions:s(`question`)})},prepare(){if(r.issue.size+r.question.size===0)return;i??=d.compose(),u(i);let t=e.querySelector(`[data-feedback-dialog-count]`);t&&(t.textContent=sa(r.issue.size,r.question.size));let n=e.querySelector(`[data-feedback-dialog]`);n&&!n.open&&n.showModal(),d.showDraftTab(`preview`),e.querySelector(`[data-draft-tab="preview"]`)?.focus()},showDraftTab(t){for(let n of E){let r=e.querySelector(`[data-draft-tab="${n}"]`);r?.setAttribute(`aria-selected`,String(n===t)),r?.setAttribute(`tabindex`,n===t?`0`:`-1`);let i=e.getElementById(`prb-draft-${n}`);i&&(i.hidden=n!==t)}if(t===`preview`)return l();let n=e.querySelector(`[data-feedback-text]`);n?.setSelectionRange(0,0),n&&(n.scrollTop=0)},state(){return{selecting:n,issues:[...r.issue],questions:[...r.question]}}};return e.addEventListener(`change`,e=>{let t=e.target.closest(`[data-feedback-pick]`),n=t?o(t):null;t&&n&&d.toggle(n,a(t),t.checked)}),e.addEventListener(`input`,t=>{let n=t.target.closest(`[data-feedback-text]`);n&&(i!==null&&(i=n.value),e.querySelector(`[data-feedback-copy]`)?.setAttribute(mt,n.value))}),e.addEventListener(`click`,r=>{let i=r.target;if(i.closest(`[data-feedback-select]`))return n?d.exit():d.enter();if(i.closest(`[data-feedback-clear]`))return d.clear();if(i.closest(`[data-feedback-done]`))return d.exit();if(i.closest(`[data-feedback-prepare]`))return d.prepare();if(i.closest(`[data-feedback-close]`))return e.querySelector(`[data-feedback-dialog]`)?.close();let a=i.closest(`[data-draft-tab]`)?.dataset.draftTab;if(a===`preview`||a===`markdown`)return d.showDraftTab(a);let o=i.closest(`[data-feedback-goto]`)?.dataset.feedbackGoto;if(o===`issues`||o===`questions`)return t(o);let s=i.closest(`[data-finding-card]`);!s||i.closest(fa)||(e.getSelection()?.isCollapsed??!0)&&d.flip(s)}),e.addEventListener(`keydown`,t=>{let n=t.target.closest(`[data-draft-tab]`)?.dataset.draftTab;if(!n)return;let r=E.indexOf(n),i=t.key===`ArrowRight`?E[(r+1)%E.length]:t.key===`ArrowLeft`?E[(r+E.length-1)%E.length]:t.key===`Home`?E[0]:t.key===`End`?E[E.length-1]:null;i&&(t.preventDefault(),d.showDraftTab(i),e.querySelector(`[data-draft-tab="${i}"]`)?.focus())}),c(),d}function ma(e){let t=e.querySelector(`[data-feedback-text]`);if(t&&e.activeElement===t&&t.selectionStart!==t.selectionEnd)return!0;let n=e.getSelection();return!!(n&&!n.isCollapsed&&n.toString()!==``)}function ha(e,t){let n=()=>t.querySelector(`[data-feedback-dialog] [data-feedback-copy]`);return{"review.feedback.prepare":{available:()=>{let{issues:t,questions:n}=e.state();return t.length+n.length>0},run:()=>e.prepare()},"review.feedback.copyDraft":{available:()=>n()!==null&&!ma(t),run:()=>n()?.click()}}}function ga(e){let t=e.querySelector(`.prb-view:is([data-view="issues"], [data-view="questions"]):not([hidden])`);return t?[...t.querySelectorAll(`[data-finding-card]`)].filter(e=>e.checkVisibility()&&!e.parentElement?.closest(`details:not([open])`)):[]}function _a(e){let t=e.getSelection();return!!(t&&!t.isCollapsed&&t.toString()!==``)}function va(e){let{doc:t}=e,n=le({doc:t,item:`[data-finding-card]`,walk:()=>ga(t),background:e.pane}),r=()=>n.holdsKeys()?n.current():null,i=e=>e?.querySelector(`[data-ask-buddy-menu]`)??null,a=e=>e?.querySelector(`[data-copy-source]`)??null,o=e=>e?.querySelector(`[data-feedback-pick]`)!=null;return{cursor:n,commands:{"review.findings.next":{available:()=>ga(t).length>0,run:()=>n.move(1)},"review.findings.previous":{available:()=>ga(t).length>0,run:()=>n.move(-1)},"review.findings.askBuddy":{available:()=>i(r())!==null,run:()=>{let t=i(r());t&&e.openMenu(t,()=>n.refocus())}},"review.findings.copy":{available:()=>!_a(t)&&a(r())!==null,run:()=>a(r())?.click()},"review.findings.choose":{available:()=>e.selecting()&&o(r()),run:()=>{let t=r();t&&e.flip(t)}}}}}var ya=`prb-rail-review`;function ba(e){return(e.getElementById(ya)?.closest(`.prb-rail-group`)?.querySelector(`a.prb-rail-group-title`))?.dataset.viewNav??null}function xa(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[...e]:e.filter(e=>{let t=`${e.name}\n${e.prompt}`.toLowerCase();return n.every(e=>t.includes(e))})}function Sa(e){return e<0||e>=10?null:e===9?`0`:String(e+1)}function Ca(e){return/^[0-9]$/.test(e)?e===`0`?9:Number(e)-1:null}function wa(e){return{title:`Choose a prompt`,mount(t,n){let r=t.ownerDocument,i=e.prompts(),a=r.createElement(`input`);a.type=`search`,a.className=`prb-palette-input`,a.placeholder=`Filter prompts`,a.setAttribute(`aria-label`,`Filter prompts`),a.spellcheck=!1;let o=r.createElement(`p`);o.className=`prb-palette-summary`,o.setAttribute(`aria-live`,`polite`);let s=r.createElement(`div`);s.className=`prb-palette-results`,s.setAttribute(`role`,`group`),s.setAttribute(`aria-label`,`Prompts`);let c=[],l=()=>[...s.querySelectorAll(`[data-prompt-choice]`)],u=()=>{let e=r.activeElement===a;for(let[t,n]of l().entries())n.toggleAttribute(`data-enter-target`,e&&t===0)},d=()=>{c=xa(i,a.value),s.replaceChildren(...c.map((e,t)=>{let n=r.createElement(`button`);n.type=`button`,n.className=`prb-palette-result prb-palette-prompt`,n.dataset.promptChoice=e.id;let i=r.createElement(`kbd`);i.className=`prb-kbd prb-palette-num`;let a=Sa(t);a?i.textContent=a:i.setAttribute(`aria-hidden`,`true`);let o=r.createElement(`span`);o.className=`prb-palette-prompt-text`;let s=r.createElement(`span`);s.className=`prb-palette-result-title`,s.textContent=e.name;let c=r.createElement(`span`);return c.className=`prb-palette-prompt-said`,c.textContent=e.prompt,o.append(s,c),n.append(i,o),n})),o.textContent=i.length===0?`No saved prompts yet. Add one under Your prompts in Buddy AI.`:c.length===0?`No prompts match.`:c.length===i.length?`${i.length} ${i.length===1?`prompt`:`prompts`}`:`${c.length} of ${i.length} prompts`,u()},f=t=>{!t||!c.some(e=>e.id===t)||(n(),e.choose(t))},p=e=>{a.value=e===`Backspace`?a.value.slice(0,-1):a.value+e,a.focus(),a.dispatchEvent(new Event(`input`,{bubbles:!0}))};a.addEventListener(`input`,d),a.addEventListener(`focus`,u),a.addEventListener(`blur`,u),s.addEventListener(`click`,e=>{f(e.target.closest(`[data-prompt-choice]`)?.dataset.promptChoice)}),t.addEventListener(`keydown`,e=>{if(e.isComposing||e.metaKey||e.ctrlKey||e.altKey)return;let t=l(),n=e.target===a,r=t.indexOf(e.target),i=Ca(e.key);if(i!==null)return e.preventDefault(),f(t[i]?.dataset.promptChoice);if(e.key===`Enter`)return e.preventDefault(),f((n?t[0]:t[r])?.dataset.promptChoice);let o=e.key===`ArrowDown`||!n&&e.key===`j`,s=e.key===`ArrowUp`||!n&&e.key===`k`;if(o||s){let n=o?r<0?t[0]:t[r+1]:r<=0?a:t[r-1];e.preventDefault(),n?.focus();return}!n&&(e.key.length===1||e.key===`Backspace`)&&(e.preventDefault(),p(e.key))}),t.append(a,o,s),d(),a.focus()}}}function Ta(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`}`}Ti(`progress`,`Review progress`);var Ea={job:`data-job-phase`,kiss:`data-kiss-phase`,update:`data-update-phase`};function Da(e){let t=new Map;for(let n of Object.keys(Ea)){let r=Ea[n],i=e.querySelector(`[${r}]`);i&&!yi(i.getAttribute(r)??void 0)&&t.set(n,i)}return t}function Oa(e,t,n){return t.failed?!0:e===`update`?t.phase===`none`||yi(t.phase):ka(t.phase,n)}function ka(e,t){return yi(e)?!0:(e===`conversation`||e===`analysing`)&&!t.querySelector(`[data-view="files"]`)}function Aa(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||bi(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 ja(e){let t=e.querySelector(`[data-started-at]`),n=Number(t?.dataset.startedAt);!t||!Number.isFinite(n)||(t.textContent=`Running for ${Ta(n)}.`)}async function Ma({look:e,reload:t,giveUpMs:n=2e4,pauseMs:r=400}){let i=!1,a=()=>{i||(i=!0,t())};for(setTimeout(a,n);!i;){try{let t=await e();if(!t||t===`none`||yi(t))return a()}catch{}await new Promise(e=>setTimeout(e,r))}}function Na(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-${y(e.scope)}" data-diagram-card="${y(e.scope)}">
84
84
  <header class="prb-diagram-head">
85
85
  <div class="prb-diagram-heading">
86
86
  <h4 class="prb-diagram-title">
@@ -99,78 +99,78 @@ import{B as e,D as t,E as n,F as r,G as i,H as a,I as o,K as s,L as c,N as l,P a
99
99
  </div>
100
100
  </header>
101
101
  ${e.caption?`<p class="prb-diagram-caption">${y(e.caption)}</p>`:``}
102
- ${ya(e,n)}
102
+ ${Pa(e,n)}
103
103
  <div class="prb-diagram-canvas" data-diagram-canvas></div>
104
104
  <details class="prb-diagram-source">
105
105
  <summary>Diagram source</summary>
106
- <div class="${le}"><pre><code data-mermaid-source>${y(e.mermaid)}</code></pre><button type="button" class="${ue}" aria-label="Copy code">Copy</button></div>
106
+ <div class="${de}"><pre><code data-mermaid-source>${y(e.mermaid)}</code></pre><button type="button" class="${fe}" aria-label="Copy code">Copy</button></div>
107
107
  </details>
108
- </article>`}function ya(e,t){return!e.commitSha||!t||e.commitSha===t?``:`<p class="prb-diagram-stale">Drawn from <code>${y(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 ba=.5,xa=3,Sa=1.25,Ca=new WeakSet,wa=new WeakMap,Ta=new WeakMap,D=null;function Ea(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(()=>{D?.abort()});return}let i=n.closest(`[data-diagram-toggle]`);if(i){za(i.closest(`[data-diagram-card]`),i.getAttribute(`aria-expanded`)===`true`);return}let a=n.closest(`[data-diagram-zoom]`);if(a){Ha(a.closest(`[data-diagram-card]`),a.dataset.diagramZoom??`reset`);return}let o=n.closest(`[data-diagram-request]`);o?.dataset.diagramKind===`map`?Oa(e):o&&Da(e,o.dataset.diagramRequest||null)}),Ma(),ka(),{drawPane:Ba}}async function Da(e,t){if(D)return;let n=t??`change`,r=document.querySelector(`[data-diagram-pane]`),i=r?.querySelector(`[data-diagram-card="${Xa(n)}"]`)??null??Fa(r,n,t);if(!i)return;Na(),e.showDiagrams();let a=Ia(i);D=new AbortController,Ga(!1);try{let n=await fetch(e.endpoint(`/diagram`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sectionId:t}),signal:D.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 La(i,a,r?.error??`Buddy AI did not return a diagram. Check the terminal running PR Review Buddy.`);Ra(i,r.diagram,t)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`){i.hasAttribute(`data-diagram-pending`)?(i.remove(),Na()):a.remove();return}La(i,a,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{D=null,Ga(!0)}}async function Oa(e){if(D)return;let t=document.querySelector(`[data-map-body]`);if(!t)return;e.showMap();let n=Aa(t),r=t.closest(`[data-map-pane]`);r?.setAttribute(`data-map-running`,``),D=new AbortController,Ga(!1);try{let t=await fetch(e.endpoint(`/diagram`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`map`}),signal:D.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){ja(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),Na()}catch(e){if(e instanceof DOMException&&e.name===`AbortError`){n.remove();return}ja(n,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{r?.removeAttribute(`data-map-running`),D=null,Ga(!0)}}function ka(){let e=document.querySelector(`[data-map-pane][data-map-running] [data-map-body]`);e&&(Aa(e),Ga(!1))}function Aa(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 ja(e,t){e.className=`prb-diagram-failed`,e.textContent=t}function Ma(){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="${Xa(n)}"]`)??Fa(e,n,t);r&&(Na(),Ia(r,{scroll:!1}),Ga(!1))}function Na(){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;Pa(`map`,t>0),Pa(`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 Pa(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 Fa(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">
108
+ </article>`}function Pa(e,t){return!e.commitSha||!t||e.commitSha===t?``:`<p class="prb-diagram-stale">Drawn from <code>${y(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 Fa=.5,Ia=3,La=1.25,Ra=new WeakSet,za=new WeakMap,Ba=new WeakMap,D=null;function Va(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(()=>{D?.abort()});return}let i=n.closest(`[data-diagram-toggle]`);if(i){eo(i.closest(`[data-diagram-card]`),i.getAttribute(`aria-expanded`)===`true`);return}let a=n.closest(`[data-diagram-zoom]`);if(a){ro(a.closest(`[data-diagram-card]`),a.dataset.diagramZoom??`reset`);return}let o=n.closest(`[data-diagram-request]`);o?.dataset.diagramKind===`map`?Ua(e):o&&Ha(e,o.dataset.diagramRequest||null)}),qa(),Wa(),{drawPane:to}}async function Ha(e,t){if(D)return;let n=t??`change`,r=document.querySelector(`[data-diagram-pane]`),i=r?.querySelector(`[data-diagram-card="${fo(n)}"]`)??null??Xa(r,n,t);if(!i)return;Ja(),e.showDiagrams();let a=Za(i);D=new AbortController,oo(!1);try{let n=await fetch(e.endpoint(`/diagram`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sectionId:t}),signal:D.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 Qa(i,a,r?.error??`Buddy AI did not return a diagram. Check the terminal running PR Review Buddy.`);$a(i,r.diagram,t)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`){i.hasAttribute(`data-diagram-pending`)?(i.remove(),Ja()):a.remove();return}Qa(i,a,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{D=null,oo(!0)}}async function Ua(e){if(D)return;let t=document.querySelector(`[data-map-body]`);if(!t)return;e.showMap();let n=Ga(t),r=t.closest(`[data-map-pane]`);r?.setAttribute(`data-map-running`,``),D=new AbortController,oo(!1);try{let t=await fetch(e.endpoint(`/diagram`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`map`}),signal:D.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){Ka(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),Ja()}catch(e){if(e instanceof DOMException&&e.name===`AbortError`){n.remove();return}Ka(n,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{r?.removeAttribute(`data-map-running`),D=null,oo(!0)}}function Wa(){let e=document.querySelector(`[data-map-pane][data-map-running] [data-map-body]`);e&&(Ga(e),oo(!1))}function Ga(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 Ka(e,t){e.className=`prb-diagram-failed`,e.textContent=t}function qa(){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="${fo(n)}"]`)??Xa(e,n,t);r&&(Ja(),Za(r,{scroll:!1}),oo(!1))}function Ja(){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;Ya(`map`,t>0),Ya(`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 Ya(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 Xa(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">
109
109
  <div class="prb-diagram-heading">
110
110
  <h4 class="prb-diagram-title">Drawing…</h4>
111
- <p class="prb-diagram-scope">${t===`change`?`Whole change`:Ya(Ka(n))}</p>
111
+ <p class="prb-diagram-scope">${t===`change`?`Whole change`:uo(so(n))}</p>
112
112
  </div>
113
- </header>`,qa(e,r,n),r}function Ia(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:Za()?`auto`:`smooth`,block:`start`}),n}function La(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 Ra(e,t,n){let r=va(t,new Map(n?[[n,Ka(n)]]:[]),t.commitSha),i=document.createElement(`div`);i.innerHTML=r;let a=i.firstElementChild;a&&(e.replaceWith(a),Na(),Va(a))}function za(e,t){e&&(e.toggleAttribute(`data-diagram-collapsed`,t),e.querySelector(`[data-diagram-toggle]`)?.setAttribute(`aria-expanded`,String(!t)),t||Va(e))}function Ba(){for(let e of document.querySelectorAll(`[data-diagram-pane] [data-diagram-card]`))Va(e)}async function Va(e){let t=e.querySelector(`[data-diagram-canvas]`),n=e.querySelector(`[data-mermaid-source]`)?.textContent??``;if(!(!t||!n||Ca.has(e)||e.hasAttribute(`data-diagram-collapsed`))){Ca.add(e);try{await Lt(t,`prb-mermaid-${Math.random().toString(36).slice(2)}`,n)}catch{Ca.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 Ha(e,t){let n=e?.querySelector(`[data-diagram-canvas] svg`),r=e?.querySelector(`[data-diagram-canvas]`);if(!e||!n||!r)return;if(t===`reset`){Ta.delete(e),r.removeAttribute(`data-zoomed`),n.style.removeProperty(`width`);return}let i=Ua(e,n);if(i<=0)return;let a=Wa((Ta.get(e)??1)*(t===`in`?Sa:1/Sa));Ta.set(e,a),r.setAttribute(`data-zoomed`,``),n.style.width=`${Math.round(i*a)}px`}function Ua(e,t){let n=wa.get(e);if(n)return n;let r=t.getBoundingClientRect().width;if(r>0)return wa.set(e,r),r;let i=t.getAttribute(`viewBox`)?.split(/[\s,]+/),a=Number(i?.[2]??0);return Number.isFinite(a)?a:0}function Wa(e){return Math.min(xa,Math.max(ba,e))}function Ga(e){for(let t of document.querySelectorAll(`[data-diagram-request]`))t.disabled=!e}function Ka(e){return e?document.querySelector(`[data-goto-section="${Xa(e)}"]`)?.querySelector(`.prb-rail-title`)?.textContent?.trim()||`A theme of this change`:`Whole change`}function qa(e,t,n){let r=Ja(n);for(let n of e.querySelectorAll(`[data-diagram-card]`)){let e=n.dataset.diagramCard??``;if(Ja(e===`change`?null:e)>r){n.before(t);return}}e.appendChild(t)}function Ja(e){if(!e)return-1;let t=document.querySelector(`[data-goto-section="${Xa(e)}"]`);return Number(t?.dataset.themeIndex??0)}function Ya(e){let t=document.createElement(`span`);return t.textContent=e,t.innerHTML}function Xa(e){return CSS.escape(e)}function Za(){return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Qa=[`intent`,`actor`,`concept`,`state`,`constraint`,`risk`,`outcome`],$a=[`Intent`,`Behaviour`,`Shared state`,`Risks & constraints`,`Outcome`],O={mapTitle:100,intent:320,title:80,body:220,why:160,anchor:80,label:48,note:200},eo={intent:0,concept:1,actor:2,state:2,constraint:3,risk:3,outcome:4};function to(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}=no(t.nodes);return{schemaVersion:1,title:co(C(t.title).trim(),O.mapTitle)||`Change map`,intent:io(t.intent,O.intent)??{simple:``,technical:``},nodes:n,edges:ro(t.edges,r)}}function no(e){let t=new Map,n=new Set,r=[];for(let i of e){if(typeof i!=`object`||!i)continue;let e=i,a=io(e.title,O.title);if(!a)continue;let o=C(e.id).trim()||a.technical;if(t.has(o))continue;let s=so(oo(o)||`n${r.length+1}`,n);t.set(o,s),n.add(s);let c=Qa.includes(e.role)?e.role:`concept`,l=io(e.why,O.why),u=co(C(e.anchor).trim(),O.anchor),d=C(e.sectionId).trim();r.push({id:s,role:c,stage:ao(e.stage,c),weight:e.weight===`primary`?`primary`:`supporting`,title:a,body:io(e.body,O.body)??{simple:``,technical:``},...l?{why:l}:{},...u?{anchor:u}:{},...d?{sectionId:d}:{}})}return{nodes:r,ids:t}}function ro(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e){if(typeof r!=`object`||!r)continue;let e=r,i=io(e.label,O.label),a=t.get(C(e.from).trim())??C(e.from).trim(),o=t.get(C(e.to).trim())??C(e.to).trim();if(!i||!a||!o)continue;let s=io(e.note,O.note);n.push({from:a,to:o,label:i,...s?{note:s}:{}})}return n}function io(e,t){if(typeof e==`string`){let n=co(e.trim(),t);return n?{simple:n,technical:n}:null}if(typeof e!=`object`||!e)return null;let n=e,r=co(C(n.simple).trim(),t),i=co(C(n.technical).trim(),t);return!r&&!i?null:{simple:r||i,technical:i||r}}function ao(e,t){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=4?e:eo[t]}function oo(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)}function so(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`}function co(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 lo(e,t){try{return uo(to(e),t).map}catch{return null}}function uo(e,t){let n={droppedNodes:0,droppedEdges:0,withdrawnSections:0,demotedPrimaries:0},r=mo(fo(e.nodes,n).map(e=>po(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:ho(r),edges:o},audit:n}}function fo(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 po(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 mo(e,t){let n=0;return e.map(e=>e.weight!==`primary`||(n+=1,n<=3)?e:(t.demotedPrimaries+=1,{...e,weight:`supporting`}))}function ho(e){return[...e].sort((e,t)=>e.stage-t.stage)}function go(e){let{stored:t,sections:n,reviewedSha:r,register:i}=e,a=t?lo(t,n.map(e=>e.id)):null,o=!!(a&&t?.commitSha&&r&&t.commitSha!==r);if(!a||!t||o)return _o(o);let s=new Map(n.map(e=>[e.id,e.title]));return`<div class="prb-map" data-change-map data-register="${i}">
113
+ </header>`,co(e,r,n),r}function Za(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:po()?`auto`:`smooth`,block:`start`}),n}function Qa(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 $a(e,t,n){let r=Na(t,new Map(n?[[n,so(n)]]:[]),t.commitSha),i=document.createElement(`div`);i.innerHTML=r;let a=i.firstElementChild;a&&(e.replaceWith(a),Ja(),no(a))}function eo(e,t){e&&(e.toggleAttribute(`data-diagram-collapsed`,t),e.querySelector(`[data-diagram-toggle]`)?.setAttribute(`aria-expanded`,String(!t)),t||no(e))}function to(){for(let e of document.querySelectorAll(`[data-diagram-pane] [data-diagram-card]`))no(e)}async function no(e){let t=e.querySelector(`[data-diagram-canvas]`),n=e.querySelector(`[data-mermaid-source]`)?.textContent??``;if(!(!t||!n||Ra.has(e)||e.hasAttribute(`data-diagram-collapsed`))){Ra.add(e);try{await zt(t,`prb-mermaid-${Math.random().toString(36).slice(2)}`,n)}catch{Ra.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 ro(e,t){let n=e?.querySelector(`[data-diagram-canvas] svg`),r=e?.querySelector(`[data-diagram-canvas]`);if(!e||!n||!r)return;if(t===`reset`){Ba.delete(e),r.removeAttribute(`data-zoomed`),n.style.removeProperty(`width`);return}let i=io(e,n);if(i<=0)return;let a=ao((Ba.get(e)??1)*(t===`in`?La:1/La));Ba.set(e,a),r.setAttribute(`data-zoomed`,``),n.style.width=`${Math.round(i*a)}px`}function io(e,t){let n=za.get(e);if(n)return n;let r=t.getBoundingClientRect().width;if(r>0)return za.set(e,r),r;let i=t.getAttribute(`viewBox`)?.split(/[\s,]+/),a=Number(i?.[2]??0);return Number.isFinite(a)?a:0}function ao(e){return Math.min(Ia,Math.max(Fa,e))}function oo(e){for(let t of document.querySelectorAll(`[data-diagram-request]`))t.disabled=!e}function so(e){return e?document.querySelector(`[data-goto-section="${fo(e)}"]`)?.querySelector(`.prb-rail-title`)?.textContent?.trim()||`A theme of this change`:`Whole change`}function co(e,t,n){let r=lo(n);for(let n of e.querySelectorAll(`[data-diagram-card]`)){let e=n.dataset.diagramCard??``;if(lo(e===`change`?null:e)>r){n.before(t);return}}e.appendChild(t)}function lo(e){if(!e)return-1;let t=document.querySelector(`[data-goto-section="${fo(e)}"]`);return Number(t?.dataset.themeIndex??0)}function uo(e){let t=document.createElement(`span`);return t.textContent=e,t.innerHTML}function fo(e){return CSS.escape(e)}function po(){return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var mo=[`intent`,`actor`,`concept`,`state`,`constraint`,`risk`,`outcome`],ho=[`Intent`,`Behaviour`,`Shared state`,`Risks & constraints`,`Outcome`],O={mapTitle:100,intent:320,title:80,body:220,why:160,anchor:80,label:48,note:200},go={intent:0,concept:1,actor:2,state:2,constraint:3,risk:3,outcome:4};function _o(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}=vo(t.nodes);return{schemaVersion:1,title:wo(C(t.title).trim(),O.mapTitle)||`Change map`,intent:bo(t.intent,O.intent)??{simple:``,technical:``},nodes:n,edges:yo(t.edges,r)}}function vo(e){let t=new Map,n=new Set,r=[];for(let i of e){if(typeof i!=`object`||!i)continue;let e=i,a=bo(e.title,O.title);if(!a)continue;let o=C(e.id).trim()||a.technical;if(t.has(o))continue;let s=Co(So(o)||`n${r.length+1}`,n);t.set(o,s),n.add(s);let c=mo.includes(e.role)?e.role:`concept`,l=bo(e.why,O.why),u=wo(C(e.anchor).trim(),O.anchor),d=C(e.sectionId).trim();r.push({id:s,role:c,stage:xo(e.stage,c),weight:e.weight===`primary`?`primary`:`supporting`,title:a,body:bo(e.body,O.body)??{simple:``,technical:``},...l?{why:l}:{},...u?{anchor:u}:{},...d?{sectionId:d}:{}})}return{nodes:r,ids:t}}function yo(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e){if(typeof r!=`object`||!r)continue;let e=r,i=bo(e.label,O.label),a=t.get(C(e.from).trim())??C(e.from).trim(),o=t.get(C(e.to).trim())??C(e.to).trim();if(!i||!a||!o)continue;let s=bo(e.note,O.note);n.push({from:a,to:o,label:i,...s?{note:s}:{}})}return n}function bo(e,t){if(typeof e==`string`){let n=wo(e.trim(),t);return n?{simple:n,technical:n}:null}if(typeof e!=`object`||!e)return null;let n=e,r=wo(C(n.simple).trim(),t),i=wo(C(n.technical).trim(),t);return!r&&!i?null:{simple:r||i,technical:i||r}}function xo(e,t){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=4?e:go[t]}function So(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)}function Co(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`}function wo(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 To(e,t){try{return Eo(_o(e),t).map}catch{return null}}function Eo(e,t){let n={droppedNodes:0,droppedEdges:0,withdrawnSections:0,demotedPrimaries:0},r=ko(Do(e.nodes,n).map(e=>Oo(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:Ao(r),edges:o},audit:n}}function Do(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 Oo(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 ko(e,t){let n=0;return e.map(e=>e.weight!==`primary`||(n+=1,n<=3)?e:(t.demotedPrimaries+=1,{...e,weight:`supporting`}))}function Ao(e){return[...e].sort((e,t)=>e.stage-t.stage)}function jo(e){let{stored:t,sections:n,reviewedSha:r,register:i}=e,a=t?To(t,n.map(e=>e.id)):null,o=!!(a&&t?.commitSha&&r&&t.commitSha!==r);if(!a||!t||o)return Mo(o);let s=new Map(n.map(e=>[e.id,e.title]));return`<div class="prb-map" data-change-map data-register="${i}">
114
114
  <header class="prb-map-head">
115
115
  <div class="prb-map-heading">
116
116
  <h4 class="prb-map-title">${y(a.title)}</h4>
117
117
  ${a.intent.simple||a.intent.technical?`<p class="prb-map-intent">${k(a.intent)}</p>`:``}
118
118
  </div>
119
119
  <div class="prb-map-tools">
120
- ${vo(i)}
120
+ ${No(i)}
121
121
  <button type="button" class="prb-diagram-redraw" data-diagram-request="" data-diagram-kind="map">Regenerate</button>
122
122
  </div>
123
123
  </header>
124
124
  <p class="prb-map-hint">Read from the goal to the outcome. Select an idea to see what it connects to.</p>
125
- ${yo(a,s)}
126
- ${Co(a)}
127
- </div>`}function _o(e){return`<div class="prb-map-empty" data-change-map-empty>
125
+ ${Po(a,s)}
126
+ ${Ro(a)}
127
+ </div>`}function Mo(e){return`<div class="prb-map-empty" data-change-map-empty>
128
128
  ${e?`<p class="prb-map-stale">The review has moved on since the last map was drawn.</p>`:``}
129
129
  <h4 class="prb-map-empty-title">See the change as a map</h4>
130
130
  <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>
131
131
  <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>
132
132
  <button type="button" class="prb-map-generate" data-diagram-request="" data-diagram-kind="map">Generate change map</button>
133
- </div>`}function vo(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 yo(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}">
134
- <h5 class="prb-map-stage-title">${y($a[n]??``)}</h5>
135
- ${e.nodes.filter(e=>e.stage===n).sort((e,t)=>Number(t.weight===`primary`)-Number(e.weight===`primary`)).map(n=>xo(n,t,e)).join(``)}
136
- </div>`).join(``),i=e.edges.map((e,t)=>So(e,t)).join(``);return`<div class="prb-map-board" data-map-board style="--prb-map-stages: ${n.length}">
133
+ </div>`}function No(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 Po(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}">
134
+ <h5 class="prb-map-stage-title">${y(ho[n]??``)}</h5>
135
+ ${e.nodes.filter(e=>e.stage===n).sort((e,t)=>Number(t.weight===`primary`)-Number(e.weight===`primary`)).map(n=>Io(n,t,e)).join(``)}
136
+ </div>`).join(``),i=e.edges.map((e,t)=>Lo(e,t)).join(``);return`<div class="prb-map-board" data-map-board style="--prb-map-stages: ${n.length}">
137
137
  <svg class="prb-map-edges" data-map-edges aria-hidden="true" focusable="false"></svg>
138
138
  ${r}
139
139
  <div class="prb-map-labels" aria-hidden="true">${i}</div>
140
- </div>`}var bo={intent:`Goal`,actor:`Actor`,concept:`Idea`,state:`Shared state`,constraint:`Rule`,risk:`Risk`,outcome:`Outcome`};function xo(e,t,n){let r=y(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>${k(e.label)}</em> <span aria-hidden="true">→</span> ${k(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}">
141
- <p class="prb-map-role">${bo[e.role]}${e.weight===`primary`?`<span class="prb-map-core"> · Core idea</span>`:``}</p>
140
+ </div>`}var Fo={intent:`Goal`,actor:`Actor`,concept:`Idea`,state:`Shared state`,constraint:`Rule`,risk:`Risk`,outcome:`Outcome`};function Io(e,t,n){let r=y(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>${k(e.label)}</em> <span aria-hidden="true">→</span> ${k(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}">
141
+ <p class="prb-map-role">${Fo[e.role]}${e.weight===`primary`?`<span class="prb-map-core"> · Core idea</span>`:``}</p>
142
142
  <h5 class="prb-map-node-title" id="prb-map-node-${r}">${k(e.title)}</h5>
143
143
  ${e.body.simple||e.body.technical?`<p class="prb-map-node-body">${k(e.body)}</p>`:``}
144
144
  ${e.why?`<p class="prb-map-why"><span class="prb-map-why-lead">Why it matters:</span> ${k(e.why)}</p>`:``}
145
145
  ${e.anchor?`<code class="prb-map-anchor">${y(e.anchor)}</code>`:``}
146
146
  ${o?`<ul class="prb-map-inline" aria-hidden="true">${o}</ul>`:``}
147
147
  ${e.sectionId&&i?`<button type="button" class="prb-map-goto" data-goto-section="${y(e.sectionId)}" aria-label="Open ${y(i)} in the Review Path">Review Path: ${y(i)} <span aria-hidden="true">→</span></button>`:``}
148
- </article>`}function So(e,t){return`<span class="prb-map-label" data-map-edge="${t}" data-from="${y(e.from)}" data-to="${y(e.to)}">${k(e.label)}</span>`}function Co(e){let t=new Map(e.nodes.map(e=>[e.id,e.title]));return`<details class="prb-map-list">
148
+ </article>`}function Lo(e,t){return`<span class="prb-map-label" data-map-edge="${t}" data-from="${y(e.from)}" data-to="${y(e.to)}">${k(e.label)}</span>`}function Ro(e){let t=new Map(e.nodes.map(e=>[e.id,e.title]));return`<details class="prb-map-list">
149
149
  <summary>Read as a list</summary>
150
150
  <ol>${e.edges.map(e=>{let n=t.get(e.from),r=t.get(e.to);return!n||!r?``:`<li><strong>${k(n)}</strong> <em>${k(e.label)}</em> <strong>${k(r)}</strong>${e.note?`<span class="prb-map-note"> — ${k(e.note)}</span>`:``}</li>`}).join(``)}</ol>
151
- </details>`}function k(e){return e.simple===e.technical?ce(e.simple):`<span data-reg="simple">${ce(e.simple)}</span><span data-reg="technical">${ce(e.technical)}</span>`}var wo=`http://www.w3.org/2000/svg`,To=new WeakSet,Eo=new WeakMap;function Do(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){Bo(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&&zo(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&&zo(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`)&&(zo(e,null),t.stopPropagation());return}if((t.key===`ArrowLeft`||t.key===`ArrowRight`)&&n.matches(`[role="tab"][data-diagram-mode]`)){t.preventDefault();let r=[...n.closest(`[role="tablist"]`)?.querySelectorAll(`[data-diagram-mode]`)??[]].map(e=>e.dataset.diagramMode??``),i=t.key===`ArrowRight`?1:-1,a=r[(r.indexOf(n.dataset.diagramMode??``)+i+r.length)%r.length];e.showView(a),document.querySelector(`.prb-view[data-view="${a}"] [data-diagram-mode="${a}"]`)?.focus()}}}),{layout:Oo,show:ko}}function Oo(){for(let e of document.querySelectorAll(`[data-map-board]`))Ao(e),jo(e)}function ko(e){let t=document.querySelector(`[data-map-body]`);t&&(t.innerHTML=go({stored:e,sections:Ho(),reviewedSha:e.commitSha,register:Vo()}),Oo())}function Ao(e){if(To.has(e)||typeof ResizeObserver>`u`)return;To.add(e);let t=!1;new ResizeObserver(()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1,jo(e)}))}).observe(e)}function jo(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(Ro());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?Mo(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=[],ee=[...e.querySelectorAll(`.prb-map-stage-title`)].map(r),te=[...o.values()],p=e.clientWidth,m=Eo.get(e),ne=m&&m.width===p?m.edges:new Set;Eo.set(e,{width:p,edges:ne});let h=(t,n)=>{n&&ne.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(ne.has(o)){e.hidden=!0,h(o,!0);return}let s=No(n,i.from,d(e.dataset.from??``,i.from,a,n)),c=No(r,i.to,d(e.dataset.to??``,i.to,a,r)),l=Fo(s,i.from,c,i.to),[u,p,m,re]=l,ie=te.filter(e=>e!==n&&e!==r);if(Array.from({length:19},(e,t)=>Io(l,.05+t*.05)).some(e=>ie.some(t=>e.x>t.left&&e.x<t.right&&e.y>t.top&&e.y<t.bottom))){e.hidden=!0,h(o,!0);return}let g=document.createElementNS(wo,`path`);g.setAttribute(`d`,`M${A(u.x)},${A(u.y)} C${A(p.x)},${A(p.y)} ${A(m.x)},${A(m.y)} ${A(re.x)},${A(re.y)}`),g.setAttribute(`class`,`prb-map-edge`),g.setAttribute(`marker-end`,`url(#prb-map-arrow)`),g.dataset.mapEdge=e.dataset.mapEdge??``,g.dataset.from=e.dataset.from??``,g.dataset.to=e.dataset.to??``,t.appendChild(g),e.hidden=!1;let ae=e.offsetWidth,oe=e.offsetHeight,_=[.5,.4,.6,.3,.7,.22,.78].map(e=>{let t=Io(l,e);return{left:t.x-ae/2,top:t.y-oe/2,right:t.x+ae/2,bottom:t.y+oe/2}}).find(e=>![...te,...ee,...f].some(t=>Lo(e,t,2)));if(!_){g.remove(),e.hidden=!0,h(o,!0);return}h(o,!1),f.push(_),e.style.left=`${Math.round(_.left)}px`,e.style.top=`${Math.round(_.top)}px`}),e.setAttribute(`data-laid-out`,``)}function Mo(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 No(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 Po={top:{x:0,y:-1},bottom:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0}};function Fo(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=Po[t],s=Po[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 Io([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 Lo(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 A(e){return Math.round(e*10)/10}function Ro(){let e=document.createElementNS(wo,`defs`),t=document.createElementNS(wo,`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(wo,`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 zo(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 Bo(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));Oo(),fetch(t.endpoint(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({changeMapRegister:e})}).catch(()=>{})}function Vo(){return document.querySelector(`[data-map-pane]`)?.dataset.mapRegister===`technical`?`technical`:`simple`}function Ho(){return[...document.querySelectorAll(`[data-goto-section][data-theme-index]`)].map(e=>({id:e.dataset.gotoSection??``,title:e.querySelector(`.prb-rail-title`)?.textContent?.trim()??``}))}var Uo=`repository`,j={minCharacters:8,maxLines:3,maxCharacters:400},Wo=[`app`,`service`,`component`,`store`,`external`,`group`],Go=/^[a-z][a-z0-9-]*$/;function Ko(e){let t=[];if(!es(e))return{ok:!1,errors:[`The architecture must be a JSON object.`]};ns(e,[`schema`,`title`,`summary`,`nodes`,`relationships`],`architecture`,t);let n=ts(e,[`summary`],`architecture`,t);n.schema!==2&&t.push(`architecture.schema must be 2.`);let r=rs(n.title,`architecture.title`,t),i=is(n.summary,`architecture.summary`,t),a=[],o=new Set;!Array.isArray(n.nodes)||n.nodes.length===0?t.push(`architecture.nodes must be a non-empty array.`):n.nodes.forEach((e,n)=>{let r=qo(e,`nodes[${n}]`,t);r&&(o.has(r.id)&&t.push(`nodes[${n}].id "${r.id}" is used twice.`),o.add(r.id),a.push(r))});let s=new Set(Array.isArray(n.nodes)?n.nodes.flatMap(e=>es(e)&&typeof e.id==`string`&&Go.test(e.id)?[e.id]:[]):[]),c=new Map(a.map(e=>[e.id,e]));for(let e of a){if(e.parent===void 0)continue;let n=c.get(e.parent);n?n.kind!==`group`&&t.push(`Node "${e.id}" names parent "${e.parent}", which is not a group.`):s.has(e.parent)||t.push(`Node "${e.id}" names parent "${e.parent}", which is not a node.`)}for(let e of a)M(e.id,c).includes(e.id)&&t.push(`Node "${e.id}" is its own ancestor.`),e.kind===`external`&&e.owns&&t.push(`Node "${e.id}" is external, so it cannot own files in this repository.`);let l=[],u=new Set;return Array.isArray(n.relationships)?n.relationships.forEach((e,n)=>{let r=`relationships[${n}]`,i=Jo(e,r,t);if(!i)return;(u.has(i.id)||o.has(i.id))&&t.push(`${r}.id "${i.id}" is already used.`),u.add(i.id);let{source:a,target:d}=i;for(let[e,n]of[[`source`,a],[`target`,d]])s.has(n)||t.push(`${r}.${e} "${n}" is not a node.`);a===d?t.push(`${r} relates "${a}" to itself.`):c.has(a)&&c.has(d)&&(M(a,c).includes(d)||M(d,c).includes(a))&&t.push(`${r} relates "${a}" and "${d}", and one contains the other.`),l.push(i)}):t.push(`architecture.relationships must be an array.`),t.length>0||r===null?{ok:!1,errors:t}:{ok:!0,architecture:{schema:2,title:r,...i===void 0?{}:{summary:i},nodes:a,relationships:l}}}function M(e,t){let n=[],r=t.get(e)?.parent;for(;r!==void 0&&!n.includes(r);)n.push(r),r=t.get(r)?.parent;return r!==void 0&&n.push(r),n}function qo(e,t,n){if(!es(e))return n.push(`${t} must be an object.`),null;ns(e,[`id`,`name`,`kind`,`parent`,`description`,`owns`,`evidence`],t,n);let r=ts(e,[`parent`,`description`,`owns`],t,n),i=as(r.id,`${t}.id`,n);i===`repository`&&n.push(`${t}.id must not be "${Uo}": that name is kept for the whole repository. Choose another id.`);let a=rs(r.name,`${t}.name`,n),o=Wo.find(e=>e===r.kind);o||n.push(`${t}.kind must be one of ${Wo.join(`, `)}.`);let s=r.parent===void 0?void 0:as(r.parent,`${t}.parent`,n),c=is(r.description,`${t}.description`,n),l=r.owns===void 0?void 0:Yo(r.owns,`${t}.owns`,n),u=Xo(r.evidence,`${t}.evidence`,n);return i===null||a===null||!o||s===null||l===null||u===null?null:{id:i,name:a,kind:o,...s===void 0?{}:{parent:s},...c===void 0?{}:{description:c},...l===void 0?{}:{owns:l},evidence:u}}function Jo(e,t,n){if(!es(e))return n.push(`${t} must be an object.`),null;ns(e,[`id`,`source`,`target`,`label`,`description`,`evidence`,`confidence`],t,n);let r=ts(e,[`description`,`confidence`],t,n),i=as(r.id,`${t}.id`,n),a=as(r.source,`${t}.source`,n),o=as(r.target,`${t}.target`,n),s=rs(r.label,`${t}.label`,n),c=is(r.description,`${t}.description`,n),l=Xo(r.evidence,`${t}.evidence`,n),u;return r.confidence!==void 0&&(typeof r.confidence==`number`&&r.confidence>=0&&r.confidence<=1?u=r.confidence:n.push(`${t}.confidence must be a number from 0 to 1.`)),i===null||a===null||o===null||s===null||l===null?null:{id:i,source:a,target:o,label:s,...c===void 0?{}:{description:c},evidence:l,...u===void 0?{}:{confidence:u}}}function Yo(e,t,n){if(!Array.isArray(e)||e.length===0)return n.push(`${t} must be a non-empty array of globs, or left out.`),null;let r=[];return e.forEach((e,i)=>{let a=rs(e,`${t}[${i}]`,n);a!==null&&(!$o(a)||a.startsWith(`./`)||a.startsWith(`!`)?n.push(`${t}[${i}] must be a glob relative to the repository, with forward slashes, no "..", no "./" and no "!".`):r.includes(a)?n.push(`${t}[${i}] "${a}" is listed twice.`):r.push(a))}),r.length===e.length?r:null}function Xo(e,t,n){if(!Array.isArray(e)||e.length===0)return n.push(`${t} must list at least one location in the repository.`),null;let r=[];return e.forEach((e,i)=>{let a=`${t}[${i}]`;if(!es(e)){n.push(`${a} must be an object.`);return}ns(e,[`path`,`quote`,`symbol`,`line`,`note`],a,n),e=ts(e,[`symbol`,`line`,`note`],a,n);let o=rs(e.path,`${a}.path`,n);o!==null&&!$o(o)&&n.push(`${a}.path must be relative to the repository, with forward slashes and no "..".`);let s=Zo(e.quote,`${a}.quote`,n),c;e.symbol!==void 0&&(typeof e.symbol==`string`&&/^\S{1,120}$/.test(e.symbol)?c=e.symbol:n.push(`${a}.symbol must be a name with no spaces, at most 120 characters.`));let l=os(e.line,`${a}.line`,n),u=is(e.note,`${a}.note`,n);o!==null&&s!==null&&r.push({path:o,quote:s,...c===void 0?{}:{symbol:c},...l===void 0?{}:{line:l},...u===void 0?{}:{note:u}})}),r.length===e.length?r:null}function Zo(e,t,n){if(typeof e!=`string`||!e.trim())return n.push(`${t} must be one to ${j.maxLines} lines copied from the file.`),null;let r=e.replace(/^\s*\n|\n\s*$/g,``),i=Qo(r);return r.split(`
152
- `).length>j.maxLines||r.length>j.maxCharacters?(n.push(`${t} must be at most ${j.maxLines} lines and ${j.maxCharacters} characters.`),null):i.length<j.minCharacters?(n.push(`${t} "${i}" is too short to find again; quote at least ${j.minCharacters} characters.`),null):r}function Qo(e){return e.replace(/\s+/g,` `).trim()}function $o(e){return!e.startsWith(`/`)&&!e.includes(`\\`)&&!e.split(`/`).includes(`..`)}function es(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ts(e,t,n,r){let i=t.filter(t=>e[t]===null);if(i.length===0)return e;let a={...e};for(let e of i)r.push(e===`parent`?`${n}.parent must be omitted when the node has no parent; null is not allowed.`:`${n}.${e} must be omitted when there is nothing to give; null is not allowed.`),delete a[e];return a}function ns(e,t,n,r){for(let i of Object.keys(e))t.includes(i)||r.push(`${n} has an unknown field "${i}".`)}function rs(e,t,n){return typeof e==`string`&&e.trim()?e.trim():(n.push(`${t} must be a non-empty string.`),null)}function is(e,t,n){if(e!==void 0)return rs(e,t,n)??void 0}function as(e,t,n){if(typeof e==`string`&&Go.test(e))return e;let r=typeof e==`string`?[...new Set([...e].filter(e=>e>``))]:[],i=r.map(e=>`"${e}" (U+${e.codePointAt(0).toString(16).toUpperCase().padStart(4,`0`)})`).join(`, `);return n.push(`${t} must be lowercase ASCII letters, digits and hyphens, starting with a letter${r.length>0?`; "${e}" contains ${i}, which ${r.length===1?`is`:`are`} not ASCII`:``}.`),null}function os(e,t,n){if(e!==void 0){if(Number.isInteger(e)&&e>=1)return e;n.push(`${t} must be a whole number from 1.`)}}function ss(e,t){let n=new Map(e.nodes.map(e=>[e.id,e]));if(t!==null&&!e.nodes.some(e=>e.parent===t))throw Error(`"${t}" is not a group with members.`);let r=t===null?[]:[t,...M(t,n)],i=e=>t!==null&&M(e,n).includes(t),a=e=>{let a=[e,...M(e,n)];if(t===null)return a[a.length-1];if(i(e))return a[a.indexOf(t)-1];let o=e,s=n.get(o)?.parent;for(;s!==void 0&&!r.includes(s);)o=s,s=n.get(o)?.parent;return o},o=e.nodes.filter(e=>t===null?e.parent===void 0:e.parent===t),s=new Set(o.map(e=>e.id)),c=new Map;for(let n of e.relationships){let e=a(n.source),r=a(n.target);if(e===r)continue;let i=e=>s.has(e)||e===t;if(!i(e)&&!i(r))continue;let o=`${e}>${r}`,l=c.get(o)??{id:o,source:e,target:r,relationships:[],label:``};l.relationships.push(n.id),c.set(o,l)}let l=new Set;for(let e of c.values())for(let n of[e.source,e.target])!s.has(n)&&n!==t&&l.add(n);let u=new Map(e.relationships.map(e=>[e.id,e.label]));for(let e of c.values())e.label=e.relationships.length===1?u.get(e.relationships[0]):`${e.relationships.length} relationships`;let d=t=>e.nodes.filter(e=>e.parent===t.id).length,f=(e,t)=>{let n=e.kind===`group`?d(e):0;return{id:e.id,name:e.name,kind:e.kind,member:t,opens:n,...n>0?{detail:n===1?`1 part`:`${n} parts`}:{}}};return{scope:t,title:t===null?e.title:n.get(t).name,nodes:[...o.map(e=>f(e,!0)),...e.nodes.filter(e=>l.has(e.id)).map(e=>f(e,!1))],edges:[...c.values()]}}var cs={app:[`(["`,`"])`],service:[`["`,`"]`],component:[`("`,`")`],store:[`[("`,`")]`],external:[`["`,`"]`],group:[`[["`,`"]]`]};function ls(e){return e.replace(/\s+/g,` `).replace(/#/g,`#35;`).replace(/"/g,`#quot;`).replace(/</g,`#lt;`).replace(/>/g,`#gt;`).replace(/%/g,`#37;`).replace(/`/g,`#96;`).trim()}function us(e,t={}){let n=t.edgeIds??!0,r=new Map,i=new Map;e.nodes.forEach((e,t)=>{r.set(`n${t}`,e.id),i.set(e.id,`n${t}`)});let a=e=>{let[t,n]=cs[e.kind],r=e.detail?`${ls(e.name)}<br>${ls(e.detail)}`:ls(e.name),a=e.opens>0?`group`:e.member?e.kind===`external`?`external`:e.kind===`store`?`store`:`part`:`context`;return` ${i.get(e.id)}${t}${r}${n}:::${a}`},o=[`flowchart LR`],s=e.nodes.filter(e=>e.member),c=e.nodes.filter(e=>!e.member);e.scope===null?o.push(...s.map(a)):o.push(` subgraph scope["${ls(e.title)}"]`,...s.map(a),` end`),o.push(...c.map(a));let l=t=>t===e.scope?`scope`:i.get(t),u=new Map;return e.edges.forEach((e,t)=>{let r=`e${t}`;u.set(r,e);let i=e.relationships.length>1?`==>`:`-->`;o.push(` ${l(e.source)} ${n?`${r}@`:``}${i}|"${ls(e.label)}"| ${l(e.target)}`)}),o.push(` classDef part fill:#ffffff,stroke:#8c959f,color:#1f2328`,` classDef store fill:#fff8e6,stroke:#b08800,color:#1f2328`,` classDef external fill:#f6f8fa,stroke:#8c959f,stroke-dasharray:4 3,color:#424a53`,` classDef context fill:#f6f8fa,stroke:#d0d7de,stroke-dasharray:4 3,color:#57606a`,` classDef group fill:#f3e8ff,stroke:#9333ea,stroke-width:2px,color:#3b0764`),e.scope!==null&&o.push(` style scope fill:#faf5ff,stroke:#c4a5f5,color:#6b21a8`),{source:o.join(`
153
- `),nodes:r,edges:u}}function ds(e,t=[null]){let n=new Map(e.nodes.map(e=>[e.id,e]));return`${t.map((t,r)=>{let i=ss(e,t),a=r===0&&t===null?`# ${fs(e.title)}`:`## ${fs(i.title)}`,o=t===null?e.summary:n.get(t)?.description,s=us(i,{edgeIds:!1}).source;return[a,...o?[fs(o)]:[],["```mermaid",s,"```"].join(`
151
+ </details>`}function k(e){return e.simple===e.technical?ue(e.simple):`<span data-reg="simple">${ue(e.simple)}</span><span data-reg="technical">${ue(e.technical)}</span>`}var zo=`http://www.w3.org/2000/svg`,Bo=new WeakSet,Vo=new WeakMap;function Ho(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){ts(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&&es(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&&es(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`)&&(es(e,null),t.stopPropagation());return}if((t.key===`ArrowLeft`||t.key===`ArrowRight`)&&n.matches(`[role="tab"][data-diagram-mode]`)){t.preventDefault();let r=[...n.closest(`[role="tablist"]`)?.querySelectorAll(`[data-diagram-mode]`)??[]].map(e=>e.dataset.diagramMode??``),i=t.key===`ArrowRight`?1:-1,a=r[(r.indexOf(n.dataset.diagramMode??``)+i+r.length)%r.length];e.showView(a),document.querySelector(`.prb-view[data-view="${a}"] [data-diagram-mode="${a}"]`)?.focus()}}}),{layout:Uo,show:Wo}}function Uo(){for(let e of document.querySelectorAll(`[data-map-board]`))Go(e),Ko(e)}function Wo(e){let t=document.querySelector(`[data-map-body]`);t&&(t.innerHTML=jo({stored:e,sections:rs(),reviewedSha:e.commitSha,register:ns()}),Uo())}function Go(e){if(Bo.has(e)||typeof ResizeObserver>`u`)return;Bo.add(e);let t=!1;new ResizeObserver(()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1,Ko(e)}))}).observe(e)}function Ko(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($o());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?qo(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),ee=[...o.values()],m=e.clientWidth,h=Vo.get(e),te=h&&h.width===m?h.edges:new Set;Vo.set(e,{width:m,edges:te});let g=(t,n)=>{n&&te.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(te.has(o)){e.hidden=!0,g(o,!0);return}let s=Jo(n,i.from,d(e.dataset.from??``,i.from,a,n)),c=Jo(r,i.to,d(e.dataset.to??``,i.to,a,r)),l=Xo(s,i.from,c,i.to),[u,m,h,ne]=l,re=ee.filter(e=>e!==n&&e!==r);if(Array.from({length:19},(e,t)=>Zo(l,.05+t*.05)).some(e=>re.some(t=>e.x>t.left&&e.x<t.right&&e.y>t.top&&e.y<t.bottom))){e.hidden=!0,g(o,!0);return}let _=document.createElementNS(zo,`path`);_.setAttribute(`d`,`M${A(u.x)},${A(u.y)} C${A(m.x)},${A(m.y)} ${A(h.x)},${A(h.y)} ${A(ne.x)},${A(ne.y)}`),_.setAttribute(`class`,`prb-map-edge`),_.setAttribute(`marker-end`,`url(#prb-map-arrow)`),_.dataset.mapEdge=e.dataset.mapEdge??``,_.dataset.from=e.dataset.from??``,_.dataset.to=e.dataset.to??``,t.appendChild(_),e.hidden=!1;let ie=e.offsetWidth,ae=e.offsetHeight,oe=[.5,.4,.6,.3,.7,.22,.78].map(e=>{let t=Zo(l,e);return{left:t.x-ie/2,top:t.y-ae/2,right:t.x+ie/2,bottom:t.y+ae/2}}).find(e=>![...ee,...p,...f].some(t=>Qo(e,t,2)));if(!oe){_.remove(),e.hidden=!0,g(o,!0);return}g(o,!1),f.push(oe),e.style.left=`${Math.round(oe.left)}px`,e.style.top=`${Math.round(oe.top)}px`}),e.setAttribute(`data-laid-out`,``)}function qo(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 Jo(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 Yo={top:{x:0,y:-1},bottom:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0}};function Xo(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=Yo[t],s=Yo[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 Zo([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 Qo(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 A(e){return Math.round(e*10)/10}function $o(){let e=document.createElementNS(zo,`defs`),t=document.createElementNS(zo,`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(zo,`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 es(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 ts(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));Uo(),fetch(t.endpoint(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({changeMapRegister:e})}).catch(()=>{})}function ns(){return document.querySelector(`[data-map-pane]`)?.dataset.mapRegister===`technical`?`technical`:`simple`}function rs(){return[...document.querySelectorAll(`[data-goto-section][data-theme-index]`)].map(e=>({id:e.dataset.gotoSection??``,title:e.querySelector(`.prb-rail-title`)?.textContent?.trim()??``}))}var is=`repository`,j={minCharacters:8,maxLines:3,maxCharacters:400},as=[`app`,`service`,`component`,`store`,`external`,`group`],os=/^[a-z][a-z0-9-]*$/;function ss(e){let t=[];if(!hs(e))return{ok:!1,errors:[`The architecture must be a JSON object.`]};_s(e,[`schema`,`title`,`summary`,`nodes`,`relationships`],`architecture`,t);let n=gs(e,[`summary`],`architecture`,t);n.schema!==2&&t.push(`architecture.schema must be 2.`);let r=vs(n.title,`architecture.title`,t),i=ys(n.summary,`architecture.summary`,t),a=[],o=new Set;!Array.isArray(n.nodes)||n.nodes.length===0?t.push(`architecture.nodes must be a non-empty array.`):n.nodes.forEach((e,n)=>{let r=cs(e,`nodes[${n}]`,t);r&&(o.has(r.id)&&t.push(`nodes[${n}].id "${r.id}" is used twice.`),o.add(r.id),a.push(r))});let s=new Set(Array.isArray(n.nodes)?n.nodes.flatMap(e=>hs(e)&&typeof e.id==`string`&&os.test(e.id)?[e.id]:[]):[]),c=new Map(a.map(e=>[e.id,e]));for(let e of a){if(e.parent===void 0)continue;let n=c.get(e.parent);n?n.kind!==`group`&&t.push(`Node "${e.id}" names parent "${e.parent}", which is not a group.`):s.has(e.parent)||t.push(`Node "${e.id}" names parent "${e.parent}", which is not a node.`)}for(let e of a)M(e.id,c).includes(e.id)&&t.push(`Node "${e.id}" is its own ancestor.`),e.kind===`external`&&e.owns&&t.push(`Node "${e.id}" is external, so it cannot own files in this repository.`);let l=[],u=new Set;return Array.isArray(n.relationships)?n.relationships.forEach((e,n)=>{let r=`relationships[${n}]`,i=ls(e,r,t);if(!i)return;(u.has(i.id)||o.has(i.id))&&t.push(`${r}.id "${i.id}" is already used.`),u.add(i.id);let{source:a,target:d}=i;for(let[e,n]of[[`source`,a],[`target`,d]])s.has(n)||t.push(`${r}.${e} "${n}" is not a node.`);a===d?t.push(`${r} relates "${a}" to itself.`):c.has(a)&&c.has(d)&&(M(a,c).includes(d)||M(d,c).includes(a))&&t.push(`${r} relates "${a}" and "${d}", and one contains the other.`),l.push(i)}):t.push(`architecture.relationships must be an array.`),t.length>0||r===null?{ok:!1,errors:t}:{ok:!0,architecture:{schema:2,title:r,...i===void 0?{}:{summary:i},nodes:a,relationships:l}}}function M(e,t){let n=[],r=t.get(e)?.parent;for(;r!==void 0&&!n.includes(r);)n.push(r),r=t.get(r)?.parent;return r!==void 0&&n.push(r),n}function cs(e,t,n){if(!hs(e))return n.push(`${t} must be an object.`),null;_s(e,[`id`,`name`,`kind`,`parent`,`description`,`owns`,`evidence`],t,n);let r=gs(e,[`parent`,`description`,`owns`],t,n),i=bs(r.id,`${t}.id`,n);i===`repository`&&n.push(`${t}.id must not be "${is}": that name is kept for the whole repository. Choose another id.`);let a=vs(r.name,`${t}.name`,n),o=as.find(e=>e===r.kind);o||n.push(`${t}.kind must be one of ${as.join(`, `)}.`);let s=r.parent===void 0?void 0:bs(r.parent,`${t}.parent`,n),c=ys(r.description,`${t}.description`,n),l=r.owns===void 0?void 0:us(r.owns,`${t}.owns`,n),u=ds(r.evidence,`${t}.evidence`,n);return i===null||a===null||!o||s===null||l===null||u===null?null:{id:i,name:a,kind:o,...s===void 0?{}:{parent:s},...c===void 0?{}:{description:c},...l===void 0?{}:{owns:l},evidence:u}}function ls(e,t,n){if(!hs(e))return n.push(`${t} must be an object.`),null;_s(e,[`id`,`source`,`target`,`label`,`description`,`evidence`,`confidence`],t,n);let r=gs(e,[`description`,`confidence`],t,n),i=bs(r.id,`${t}.id`,n),a=bs(r.source,`${t}.source`,n),o=bs(r.target,`${t}.target`,n),s=vs(r.label,`${t}.label`,n),c=ys(r.description,`${t}.description`,n),l=ds(r.evidence,`${t}.evidence`,n),u;return r.confidence!==void 0&&(typeof r.confidence==`number`&&r.confidence>=0&&r.confidence<=1?u=r.confidence:n.push(`${t}.confidence must be a number from 0 to 1.`)),i===null||a===null||o===null||s===null||l===null?null:{id:i,source:a,target:o,label:s,...c===void 0?{}:{description:c},evidence:l,...u===void 0?{}:{confidence:u}}}function us(e,t,n){if(!Array.isArray(e)||e.length===0)return n.push(`${t} must be a non-empty array of globs, or left out.`),null;let r=[];return e.forEach((e,i)=>{let a=vs(e,`${t}[${i}]`,n);a!==null&&(!ms(a)||a.startsWith(`./`)||a.startsWith(`!`)?n.push(`${t}[${i}] must be a glob relative to the repository, with forward slashes, no "..", no "./" and no "!".`):r.includes(a)?n.push(`${t}[${i}] "${a}" is listed twice.`):r.push(a))}),r.length===e.length?r:null}function ds(e,t,n){if(!Array.isArray(e)||e.length===0)return n.push(`${t} must list at least one location in the repository.`),null;let r=[];return e.forEach((e,i)=>{let a=`${t}[${i}]`;if(!hs(e)){n.push(`${a} must be an object.`);return}_s(e,[`path`,`quote`,`symbol`,`line`,`note`],a,n),e=gs(e,[`symbol`,`line`,`note`],a,n);let o=vs(e.path,`${a}.path`,n);o!==null&&!ms(o)&&n.push(`${a}.path must be relative to the repository, with forward slashes and no "..".`);let s=fs(e.quote,`${a}.quote`,n),c;e.symbol!==void 0&&(typeof e.symbol==`string`&&/^\S{1,120}$/.test(e.symbol)?c=e.symbol:n.push(`${a}.symbol must be a name with no spaces, at most 120 characters.`));let l=xs(e.line,`${a}.line`,n),u=ys(e.note,`${a}.note`,n);o!==null&&s!==null&&r.push({path:o,quote:s,...c===void 0?{}:{symbol:c},...l===void 0?{}:{line:l},...u===void 0?{}:{note:u}})}),r.length===e.length?r:null}function fs(e,t,n){if(typeof e!=`string`||!e.trim())return n.push(`${t} must be one to ${j.maxLines} lines copied from the file.`),null;let r=e.replace(/^\s*\n|\n\s*$/g,``),i=ps(r);return r.split(`
152
+ `).length>j.maxLines||r.length>j.maxCharacters?(n.push(`${t} must be at most ${j.maxLines} lines and ${j.maxCharacters} characters.`),null):i.length<j.minCharacters?(n.push(`${t} "${i}" is too short to find again; quote at least ${j.minCharacters} characters.`),null):r}function ps(e){return e.replace(/\s+/g,` `).trim()}function ms(e){return!e.startsWith(`/`)&&!e.includes(`\\`)&&!e.split(`/`).includes(`..`)}function hs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function gs(e,t,n,r){let i=t.filter(t=>e[t]===null);if(i.length===0)return e;let a={...e};for(let e of i)r.push(e===`parent`?`${n}.parent must be omitted when the node has no parent; null is not allowed.`:`${n}.${e} must be omitted when there is nothing to give; null is not allowed.`),delete a[e];return a}function _s(e,t,n,r){for(let i of Object.keys(e))t.includes(i)||r.push(`${n} has an unknown field "${i}".`)}function vs(e,t,n){return typeof e==`string`&&e.trim()?e.trim():(n.push(`${t} must be a non-empty string.`),null)}function ys(e,t,n){if(e!==void 0)return vs(e,t,n)??void 0}function bs(e,t,n){if(typeof e==`string`&&os.test(e))return e;let r=typeof e==`string`?[...new Set([...e].filter(e=>e>``))]:[],i=r.map(e=>`"${e}" (U+${e.codePointAt(0).toString(16).toUpperCase().padStart(4,`0`)})`).join(`, `);return n.push(`${t} must be lowercase ASCII letters, digits and hyphens, starting with a letter${r.length>0?`; "${e}" contains ${i}, which ${r.length===1?`is`:`are`} not ASCII`:``}.`),null}function xs(e,t,n){if(e!==void 0){if(Number.isInteger(e)&&e>=1)return e;n.push(`${t} must be a whole number from 1.`)}}function Ss(e,t){let n=new Map(e.nodes.map(e=>[e.id,e]));if(t!==null&&!e.nodes.some(e=>e.parent===t))throw Error(`"${t}" is not a group with members.`);let r=t===null?[]:[t,...M(t,n)],i=e=>t!==null&&M(e,n).includes(t),a=e=>{let a=[e,...M(e,n)];if(t===null)return a[a.length-1];if(i(e))return a[a.indexOf(t)-1];let o=e,s=n.get(o)?.parent;for(;s!==void 0&&!r.includes(s);)o=s,s=n.get(o)?.parent;return o},o=e.nodes.filter(e=>t===null?e.parent===void 0:e.parent===t),s=new Set(o.map(e=>e.id)),c=new Map;for(let n of e.relationships){let e=a(n.source),r=a(n.target);if(e===r)continue;let i=e=>s.has(e)||e===t;if(!i(e)&&!i(r))continue;let o=`${e}>${r}`,l=c.get(o)??{id:o,source:e,target:r,relationships:[],label:``};l.relationships.push(n.id),c.set(o,l)}let l=new Set;for(let e of c.values())for(let n of[e.source,e.target])!s.has(n)&&n!==t&&l.add(n);let u=new Map(e.relationships.map(e=>[e.id,e.label]));for(let e of c.values())e.label=e.relationships.length===1?u.get(e.relationships[0]):`${e.relationships.length} relationships`;let d=t=>e.nodes.filter(e=>e.parent===t.id).length,f=(e,t)=>{let n=e.kind===`group`?d(e):0;return{id:e.id,name:e.name,kind:e.kind,member:t,opens:n,...n>0?{detail:n===1?`1 part`:`${n} parts`}:{}}};return{scope:t,title:t===null?e.title:n.get(t).name,nodes:[...o.map(e=>f(e,!0)),...e.nodes.filter(e=>l.has(e.id)).map(e=>f(e,!1))],edges:[...c.values()]}}var Cs={app:[`(["`,`"])`],service:[`["`,`"]`],component:[`("`,`")`],store:[`[("`,`")]`],external:[`["`,`"]`],group:[`[["`,`"]]`]};function ws(e){return e.replace(/\s+/g,` `).replace(/#/g,`#35;`).replace(/"/g,`#quot;`).replace(/</g,`#lt;`).replace(/>/g,`#gt;`).replace(/%/g,`#37;`).replace(/`/g,`#96;`).trim()}function Ts(e,t={}){let n=t.edgeIds??!0,r=new Map,i=new Map;e.nodes.forEach((e,t)=>{r.set(`n${t}`,e.id),i.set(e.id,`n${t}`)});let a=e=>{let[t,n]=Cs[e.kind],r=e.detail?`${ws(e.name)}<br>${ws(e.detail)}`:ws(e.name),a=e.opens>0?`group`:e.member?e.kind===`external`?`external`:e.kind===`store`?`store`:`part`:`context`;return` ${i.get(e.id)}${t}${r}${n}:::${a}`},o=[`flowchart LR`],s=e.nodes.filter(e=>e.member),c=e.nodes.filter(e=>!e.member);e.scope===null?o.push(...s.map(a)):o.push(` subgraph scope["${ws(e.title)}"]`,...s.map(a),` end`),o.push(...c.map(a));let l=t=>t===e.scope?`scope`:i.get(t),u=new Map;return e.edges.forEach((e,t)=>{let r=`e${t}`;u.set(r,e);let i=e.relationships.length>1?`==>`:`-->`;o.push(` ${l(e.source)} ${n?`${r}@`:``}${i}|"${ws(e.label)}"| ${l(e.target)}`)}),o.push(` classDef part fill:#ffffff,stroke:#8c959f,color:#1f2328`,` classDef store fill:#fff8e6,stroke:#b08800,color:#1f2328`,` classDef external fill:#f6f8fa,stroke:#8c959f,stroke-dasharray:4 3,color:#424a53`,` classDef context fill:#f6f8fa,stroke:#d0d7de,stroke-dasharray:4 3,color:#57606a`,` classDef group fill:#f3e8ff,stroke:#9333ea,stroke-width:2px,color:#3b0764`),e.scope!==null&&o.push(` style scope fill:#faf5ff,stroke:#c4a5f5,color:#6b21a8`),{source:o.join(`
153
+ `),nodes:r,edges:u}}function Es(e,t=[null]){let n=new Map(e.nodes.map(e=>[e.id,e]));return`${t.map((t,r)=>{let i=Ss(e,t),a=r===0&&t===null?`# ${Ds(e.title)}`:`## ${Ds(i.title)}`,o=t===null?e.summary:n.get(t)?.description,s=Ts(i,{edgeIds:!1}).source;return[a,...o?[Ds(o)]:[],["```mermaid",s,"```"].join(`
154
154
  `)].join(`
155
155
 
156
156
  `)}).join(`
157
157
 
158
- `)}\n`}function fs(e){return e.replace(/\s+/g,` `).trim().replace(/[\\`*_[\]<>#|]/g,`\\$&`)}var ps={exploring:{title:`Exploring the code…`,detail:`Reading the repository and identifying its main parts.`},checking:{title:`Checking the evidence…`,detail:`Making sure every piece of code the map cites is really there.`},correcting:{title:`Correcting the map…`,detail:`Fixing what the checks found.`}};function ms(e){return ps[e.stage]}var hs={app:`Application`,service:`Service`,component:`Component`,store:`Store`,external:`External system`,group:`Group`},gs=5e3;function _s(e){let t=!1,n=!1,r=()=>document.querySelector(`[data-architecture-pane]`)?.hidden===!1;document.addEventListener(`click`,t=>{let n=t.target.closest(`[data-architecture-map]`);n&&ys(e,n,n.dataset.architectureMap||`repository`);let r=t.target.closest(`[data-architecture-stop]`);r&&bs(e,r,r.dataset.architectureStop||`repository`)}),Ss(e,()=>{r()?vs():n=!0});async function i(){if(n)return vs();if(t)return;let e=document.querySelector(`[data-architecture]`),r=e?.querySelector(`[data-architecture-canvas]`),i=e?.querySelector(`[data-architecture-inspector]`),a=e?.querySelector(`[data-architecture-model]`)?.textContent;if(!e||!r||!i||!a)return;t=!0;let o;try{o=JSON.parse(a)}catch{return Ds(r,`The architecture could not be read.`)}let s=Ko(o.architecture);if(!s.ok)return Ds(r,`The architecture could not be read.`);let c={scope:Uo,architecture:s.architecture,evidence:o.evidence??{}},l=new Map;for(let[e,t]of Object.entries(o.deeper??{})){let n=Ko(t.architecture);n.ok&&l.set(e,{scope:e,architecture:n.architecture,evidence:t.evidence,...t.changed?{changed:t.changed}:{}})}let u=new ws({canvas:r,inspector:i,trail:e.querySelector(`[data-architecture-trail]`),repository:c,deeper:l,embedded:o}),d=u.draw(c);return e.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-architecture-select]`);n?.dataset.architectureSelect&&u.reveal(n.dataset.architectureSelect);let r=t.closest(`[data-architecture-copy]`);r&&Cs(r,c,l)}),d}return{show:i}}function vs(){let e=Fn(window.location.hash,`architecture`);window.location.hash!==e&&window.history.replaceState(window.history.state,``,e),window.location.reload()}async function ys(e,t,n){if(!t.disabled){t.disabled=!0,t.parentElement?.querySelector(`[data-architecture-error]`)?.remove();try{let r=await fetch(e.endpoint(`/architecture`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({scope:n})});if(r.status===202||r.status===409)return vs();xs(t,(await r.json().catch(()=>null))?.error??`Mapping could not start.`)}catch{xs(t,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}t.disabled=!1}}async function bs(e,t,n){if(!t.disabled){t.disabled=!0,t.parentElement?.querySelector(`[data-architecture-error]`)?.remove();try{if((await fetch(e.endpoint(`/architecture`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({scope:n,stop:!0})})).ok)return vs();xs(t,`Mapping could not be stopped.`)}catch{xs(t,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}t.disabled=!1}}function xs(e,t){let n=N(`p`,`prb-arch-error`,t);n.setAttribute(`data-architecture-error`,``),n.setAttribute(`role`,`alert`),e.after(n)}function Ss(e,t){let n=[];try{n=JSON.parse(document.querySelector(`[data-architecture-runs]`)?.textContent??`[]`)}catch{return}if(n.length===0)return;let r=async()=>{try{let r=(await(await fetch(e.endpoint(`/job`))).json()).architecture??[];for(let e of r){let t=document.querySelector(`[data-architecture-running="${CSS.escape(e.scope)}"]`),{title:n,detail:r}=ms(e),i=t?.querySelector(`[data-architecture-stage]`),a=t?.querySelector(`[data-architecture-stage-detail]`);i&&(i.textContent=n),a&&(a.textContent=r)}if(n.some(e=>!r.some(t=>t.scope===e)))return t()}catch{}window.setTimeout(()=>void r(),gs)};window.setTimeout(()=>void r(),gs)}async function Cs(e,t,n){let r=e=>e.nodes.filter(t=>e.nodes.some(e=>e.parent===t.id)).map(e=>e.id),i=[t,...n.values()].map(e=>ds(e.architecture,[null,...r(e.architecture)])).join(`
159
- `),a=e.textContent;try{await navigator.clipboard.writeText(i),e.textContent=`Copied`}catch{e.textContent=`Couldn't copy`}window.setTimeout(()=>e.textContent=a,2e3)}var ws=class{parts;drawing=null;shown;constructor(e){this.parts=e,this.shown=e.repository}async draw(e,t=null){let{canvas:n,inspector:r,trail:i,embedded:a}=this.parts,o;try{o=await v(()=>import(`./chunk-CMZKCXl2.js`),[])}catch{return Ds(n,`The architecture drawing could not be loaded. Reload the page to try again.`)}this.drawing?.dispose(),this.shown=e;let s=document.createElement(`div`);s.className=`prb-arch-host`,n.replaceChildren(s);let c=e=>void this.drawing?.showScope(e);try{this.drawing=await o.renderArchitectureWithMermaid(s,e.architecture,{onSelect:e=>this.inspect(e),onScopeChange:t=>{i&&Es(i,e.architecture,t,c,this.base()),this.hint()},affected:new Set(a.touched?.[e.scope]??[])}),t===null?i&&Es(i,e.architecture,null,c,this.base()):await this.drawing.showScope(t),e!==this.parts.repository&&this.hint()}catch(e){console.error(`[prb architecture]`,e),Ds(n,`The architecture could not be drawn.`)}}async reveal(e){let t=this.parts.repository.architecture.nodes.find(t=>t.id===e);t&&(this.shown!==this.parts.repository&&await this.draw(this.parts.repository),await this.drawing?.showScope(t.parent??null),this.drawing?.select(e),this.parts.canvas.scrollIntoView({block:`nearest`,behavior:`smooth`}))}base(){if(this.shown===this.parts.repository)return[];let{repository:e}=this.parts,t=e.architecture.nodes.find(e=>e.id===this.shown.scope);return[{label:e.architecture.title,go:()=>void this.draw(e,t?.parent??null)},{label:`${t?.name??this.shown.scope} in depth`,go:()=>void this.drawing?.showScope(null)}]}hint(){let{inspector:e}=this.parts,t=[];this.shown!==this.parts.repository&&t.push(...Ts(this.shown.scope,this.shown.changed,this.parts.embedded)),t.push(N(`p`,`prb-arch-hint`,`Select a part or an arrow to see what it is and the code it rests on.`)),e.replaceChildren(...t)}inspect(e){let{inspector:t,embedded:n,deeper:r}=this.parts,i=this.shown===this.parts.repository;Os(t,this.shown,e,e=>void this.drawing?.showScope(e),e=>{let t=[];if(n.touched?.[this.shown.scope]?.includes(e.id)&&t.push(N(`p`,`prb-arch-meta prb-arch-touched`,`This change touches files in this part.`)),!i)return t;let a=r.get(e.id);if(a){let r=N(`button`,`prb-arch-open`,`Open ${e.name} in depth`);r.type=`button`,r.addEventListener(`click`,()=>void this.draw(a));let i=Ts(e.id,a.changed,n),o=i.at(-1)?.tagName===`BUTTON`?i.pop():void 0;t.push(...i,r,...o?[o]:[])}else if(n.running?.includes(e.id))t.push(N(`p`,`prb-arch-meta`,`Mapping this part in depth…`));else if(n.mappable?.includes(e.id)){let r=n.failures?.[e.id];r&&t.push(N(`p`,`prb-arch-error`,`Mapping this part in depth failed. ${r.message}`));let i=N(`button`,`prb-diagram-redraw`,r?`Retry mapping this part in depth`:`Map this part in depth`);if(i.type=`button`,i.dataset.architectureMap=e.id,t.push(i),r&&r.errors.length>0){let e=N(`details`,`prb-arch-failure-details`,``),n=N(`ul`,``,``);for(let e of r.errors)n.append(N(`li`,``,e));e.append(N(`summary`,``,`What the checks found`),n),t.push(e)}}return t})}};function Ts(e,t,n){let r=t?[N(`p`,`prb-arch-meta prb-arch-changed`,t)]:[];if(n.running?.includes(e))return[...r,N(`p`,`prb-arch-meta`,`Mapping this part in depth again…`)];let i=n.failures?.[e],a=N(`button`,`prb-diagram-redraw`,`Remap this part`);return a.type=`button`,a.dataset.architectureMap=e,[...r,...i?[N(`p`,`prb-arch-error`,`Remapping this part failed. ${i.message}`)]:[],a]}function Es(e,t,n,r,i=[]){let a=new Map(t.nodes.map(e=>[e.id,e])),o=[...i.length>0?i:[{label:t.title,go:()=>r(null)}],...(n===null?[]:[...M(n,a).reverse(),n]).map(e=>({label:a.get(e)?.name??e,go:()=>r(e)}))];e.replaceChildren(...o.flatMap((e,t)=>{let n=t===o.length-1,r=N(n?`span`:`button`,`prb-arch-crumb`,e.label);return n?r.setAttribute(`aria-current`,`location`):(r.type=`button`,r.addEventListener(`click`,e.go)),t===0?[r]:[N(`span`,`prb-arch-crumb-sep`,`›`),r]}))}function Ds(e,t){let n=document.createElement(`p`);n.className=`prb-arch-status`,n.textContent=t,e.replaceChildren(n)}function Os(e,t,n,r,i){let{architecture:a}=t,o=new Map(a.nodes.map(e=>[e.id,e])),s=e=>o.get(e)?.name??e;if(n.kind===`none`){let t=N(`p`,`prb-arch-hint`,`Select a part or an arrow to see what it is and the code it rests on.`);e.replaceChildren(t);return}if(n.kind===`node`){let c=o.get(n.id);if(!c)return;let l=[N(`p`,`prb-arch-kind`,`${hs[c.kind]??c.kind}${c.parent?` in ${s(c.parent)}`:``}`),N(`h4`,`prb-arch-title`,c.name)];c.description&&l.push(N(`p`,`prb-arch-text`,c.description));let u=a.nodes.filter(e=>e.parent===c.id).length;if(u>0&&r){let e=N(`button`,`prb-arch-open`,`Show the ${u} parts inside ${c.name}`);e.type=`button`,e.addEventListener(`click`,()=>r(c.id)),l.push(e)}i&&l.push(...i(c)),l.push(ks(c.evidence,t.evidence[c.id]));let d=a.relationships.filter(e=>e.source===c.id||e.target===c.id);if(d.length>0){l.push(N(`h5`,`prb-arch-subhead`,`Relationships`));let e=N(`ul`,`prb-arch-related`,``);for(let t of d)e.append(N(`li`,``,`${s(t.source)} ${t.label} ${s(t.target)}`));l.push(e)}e.replaceChildren(...l);return}let c=[],l=n.ids.flatMap(e=>a.relationships.find(t=>t.id===e)??[]);l.length>1&&c.push(N(`p`,`prb-arch-kind`,`${l.length} relationships behind this arrow`));for(let e of l){let n=N(`section`,`prb-arch-relationship`,``);n.append(N(`p`,`prb-arch-kind`,`Relationship`),N(`h4`,`prb-arch-title`,`${s(e.source)} ${e.label} ${s(e.target)}`)),e.description&&n.append(N(`p`,`prb-arch-text`,e.description)),e.confidence!==void 0&&n.append(N(`p`,`prb-arch-meta`,`Inferred, with ${Math.round(e.confidence*100)}% confidence`)),n.append(ks(e.evidence,t.evidence[e.id])),c.push(n)}e.replaceChildren(...c)}function ks(e,t=[]){let n=N(`div`,`prb-arch-evidence`,``);n.append(N(`h5`,`prb-arch-subhead`,`Evidence`));let r=N(`ul`,`prb-arch-evidence-list`,``);return e.forEach((e,n)=>{let i=N(`li`,``,``),a=t[n];if(a&&a.state!==`missing`){let t=N(`button`,`prb-arch-location`,`${e.path}:${a.line}${a.endLine===a.line?``:`–${a.endLine}`}`);t.type=`button`,t.dataset.openEditor=e.path,t.dataset.openLine=String(a.line),i.append(t),a.via===`symbol`&&i.append(N(`span`,`prb-arch-gone`,`The quoted code has changed; this opens ${e.symbol}`))}else i.append(N(`span`,`prb-arch-location`,e.path),N(`span`,`prb-arch-gone`,`No longer found in this checkout`));i.append(N(`code`,`prb-arch-quote`,e.quote)),e.note&&i.append(N(`span`,`prb-arch-note`,e.note)),r.append(i)}),n.append(r),n}function N(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n&&(r.textContent=n),r}function As(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}var js=1e3,Ms=new WeakMap;function Ns(e,t){return e.length<=1e3?As(e)||`&nbsp;`:`${As(e.slice(0,js))}\u2026 <button type="button" class="prb-code-long-toggle" data-full-line="${t}">Show full line</button>`}function Ps(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">${Ns(e.text,`old:${e.oldLine}`)}</td></tr>`).join(``)}function Fs(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?Ps(c):``}<tr class="${s}" data-line="${o}"><td class="prb-code-num">${o}</td><td class="prb-code-line">${Ns(i,`new:${o}`)}</td></tr>`}),a=r.get(e.totalLines+1);return a&&e.to===e.totalLines&&i.push(Ps(a)),i.join(``)}function Is(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 Ls(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&&Ms.set(r,o)}}function Rs(e){let t=Ms.get(e),n=e.closest(`td`);return t===void 0||!n?null:(n.textContent=t,n)}function zs(e){return e.deletion?2*e.line-1:2*e.line}function Bs(e){return e%2==1?{line:(e+1)/2,deletion:!0}:{line:e/2,deletion:!1}}function Vs(e,t){if(e.length===0)return``;let n=e.map(zs),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}">
158
+ `)}\n`}function Ds(e){return e.replace(/\s+/g,` `).trim().replace(/[\\`*_[\]<>#|]/g,`\\$&`)}var Os={exploring:{title:`Exploring the code…`,detail:`Reading the repository and identifying its main parts.`},checking:{title:`Checking the evidence…`,detail:`Making sure every piece of code the map cites is really there.`},correcting:{title:`Correcting the map…`,detail:`Fixing what the checks found.`}};function ks(e){return Os[e.stage]}var As={app:`Application`,service:`Service`,component:`Component`,store:`Store`,external:`External system`,group:`Group`},js=5e3;function Ms(e){let t=!1,n=!1,r=()=>document.querySelector(`[data-architecture-pane]`)?.hidden===!1;document.addEventListener(`click`,t=>{let n=t.target.closest(`[data-architecture-map]`);n&&Ps(e,n,n.dataset.architectureMap||`repository`);let r=t.target.closest(`[data-architecture-stop]`);r&&Fs(e,r,r.dataset.architectureStop||`repository`)}),Ls(e,()=>{r()?Ns():n=!0});async function i(){if(n)return Ns();if(t)return;let e=document.querySelector(`[data-architecture]`),r=e?.querySelector(`[data-architecture-canvas]`),i=e?.querySelector(`[data-architecture-inspector]`),a=e?.querySelector(`[data-architecture-model]`)?.textContent;if(!e||!r||!i||!a)return;t=!0;let o;try{o=JSON.parse(a)}catch{return Hs(r,`The architecture could not be read.`)}let s=ss(o.architecture);if(!s.ok)return Hs(r,`The architecture could not be read.`);let c={scope:is,architecture:s.architecture,evidence:o.evidence??{}},l=new Map;for(let[e,t]of Object.entries(o.deeper??{})){let n=ss(t.architecture);n.ok&&l.set(e,{scope:e,architecture:n.architecture,evidence:t.evidence,...t.changed?{changed:t.changed}:{}})}let u=new zs({canvas:r,inspector:i,trail:e.querySelector(`[data-architecture-trail]`),repository:c,deeper:l,embedded:o}),d=u.draw(c);return e.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-architecture-select]`);n?.dataset.architectureSelect&&u.reveal(n.dataset.architectureSelect);let r=t.closest(`[data-architecture-copy]`);r&&Rs(r,c,l)}),d}return{show:i}}function Ns(){let e=Ln(window.location.hash,`architecture`);window.location.hash!==e&&window.history.replaceState(window.history.state,``,e),window.location.reload()}async function Ps(e,t,n){if(!t.disabled){t.disabled=!0,t.parentElement?.querySelector(`[data-architecture-error]`)?.remove();try{let r=await fetch(e.endpoint(`/architecture`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({scope:n})});if(r.status===202||r.status===409)return Ns();Is(t,(await r.json().catch(()=>null))?.error??`Mapping could not start.`)}catch{Is(t,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}t.disabled=!1}}async function Fs(e,t,n){if(!t.disabled){t.disabled=!0,t.parentElement?.querySelector(`[data-architecture-error]`)?.remove();try{if((await fetch(e.endpoint(`/architecture`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({scope:n,stop:!0})})).ok)return Ns();Is(t,`Mapping could not be stopped.`)}catch{Is(t,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}t.disabled=!1}}function Is(e,t){let n=N(`p`,`prb-arch-error`,t);n.setAttribute(`data-architecture-error`,``),n.setAttribute(`role`,`alert`),e.after(n)}function Ls(e,t){let n=[];try{n=JSON.parse(document.querySelector(`[data-architecture-runs]`)?.textContent??`[]`)}catch{return}if(n.length===0)return;let r=async()=>{try{let r=(await(await fetch(e.endpoint(`/job`))).json()).architecture??[];for(let e of r){let t=document.querySelector(`[data-architecture-running="${CSS.escape(e.scope)}"]`),{title:n,detail:r}=ks(e),i=t?.querySelector(`[data-architecture-stage]`),a=t?.querySelector(`[data-architecture-stage-detail]`);i&&(i.textContent=n),a&&(a.textContent=r)}if(n.some(e=>!r.some(t=>t.scope===e)))return t()}catch{}window.setTimeout(()=>void r(),js)};window.setTimeout(()=>void r(),js)}async function Rs(e,t,n){let r=e=>e.nodes.filter(t=>e.nodes.some(e=>e.parent===t.id)).map(e=>e.id),i=[t,...n.values()].map(e=>Es(e.architecture,[null,...r(e.architecture)])).join(`
159
+ `),a=e.textContent;try{await navigator.clipboard.writeText(i),e.textContent=`Copied`}catch{e.textContent=`Couldn't copy`}window.setTimeout(()=>e.textContent=a,2e3)}var zs=class{parts;drawing=null;shown;constructor(e){this.parts=e,this.shown=e.repository}async draw(e,t=null){let{canvas:n,inspector:r,trail:i,embedded:a}=this.parts,o;try{o=await v(()=>import(`./chunk-CMZKCXl2.js`),[])}catch{return Hs(n,`The architecture drawing could not be loaded. Reload the page to try again.`)}this.drawing?.dispose(),this.shown=e;let s=document.createElement(`div`);s.className=`prb-arch-host`,n.replaceChildren(s);let c=e=>void this.drawing?.showScope(e);try{this.drawing=await o.renderArchitectureWithMermaid(s,e.architecture,{onSelect:e=>this.inspect(e),onScopeChange:t=>{i&&Vs(i,e.architecture,t,c,this.base()),this.hint()},affected:new Set(a.touched?.[e.scope]??[])}),t===null?i&&Vs(i,e.architecture,null,c,this.base()):await this.drawing.showScope(t),e!==this.parts.repository&&this.hint()}catch(e){console.error(`[prb architecture]`,e),Hs(n,`The architecture could not be drawn.`)}}async reveal(e){let t=this.parts.repository.architecture.nodes.find(t=>t.id===e);t&&(this.shown!==this.parts.repository&&await this.draw(this.parts.repository),await this.drawing?.showScope(t.parent??null),this.drawing?.select(e),this.parts.canvas.scrollIntoView({block:`nearest`,behavior:`smooth`}))}base(){if(this.shown===this.parts.repository)return[];let{repository:e}=this.parts,t=e.architecture.nodes.find(e=>e.id===this.shown.scope);return[{label:e.architecture.title,go:()=>void this.draw(e,t?.parent??null)},{label:`${t?.name??this.shown.scope} in depth`,go:()=>void this.drawing?.showScope(null)}]}hint(){let{inspector:e}=this.parts,t=[];this.shown!==this.parts.repository&&t.push(...Bs(this.shown.scope,this.shown.changed,this.parts.embedded)),t.push(N(`p`,`prb-arch-hint`,`Select a part or an arrow to see what it is and the code it rests on.`)),e.replaceChildren(...t)}inspect(e){let{inspector:t,embedded:n,deeper:r}=this.parts,i=this.shown===this.parts.repository;Us(t,this.shown,e,e=>void this.drawing?.showScope(e),e=>{let t=[];if(n.touched?.[this.shown.scope]?.includes(e.id)&&t.push(N(`p`,`prb-arch-meta prb-arch-touched`,`This change touches files in this part.`)),!i)return t;let a=r.get(e.id);if(a){let r=N(`button`,`prb-arch-open`,`Open ${e.name} in depth`);r.type=`button`,r.addEventListener(`click`,()=>void this.draw(a));let i=Bs(e.id,a.changed,n),o=i.at(-1)?.tagName===`BUTTON`?i.pop():void 0;t.push(...i,r,...o?[o]:[])}else if(n.running?.includes(e.id))t.push(N(`p`,`prb-arch-meta`,`Mapping this part in depth…`));else if(n.mappable?.includes(e.id)){let r=n.failures?.[e.id];r&&t.push(N(`p`,`prb-arch-error`,`Mapping this part in depth failed. ${r.message}`));let i=N(`button`,`prb-diagram-redraw`,r?`Retry mapping this part in depth`:`Map this part in depth`);if(i.type=`button`,i.dataset.architectureMap=e.id,t.push(i),r&&r.errors.length>0){let e=N(`details`,`prb-arch-failure-details`,``),n=N(`ul`,``,``);for(let e of r.errors)n.append(N(`li`,``,e));e.append(N(`summary`,``,`What the checks found`),n),t.push(e)}}return t})}};function Bs(e,t,n){let r=t?[N(`p`,`prb-arch-meta prb-arch-changed`,t)]:[];if(n.running?.includes(e))return[...r,N(`p`,`prb-arch-meta`,`Mapping this part in depth again…`)];let i=n.failures?.[e],a=N(`button`,`prb-diagram-redraw`,`Remap this part`);return a.type=`button`,a.dataset.architectureMap=e,[...r,...i?[N(`p`,`prb-arch-error`,`Remapping this part failed. ${i.message}`)]:[],a]}function Vs(e,t,n,r,i=[]){let a=new Map(t.nodes.map(e=>[e.id,e])),o=[...i.length>0?i:[{label:t.title,go:()=>r(null)}],...(n===null?[]:[...M(n,a).reverse(),n]).map(e=>({label:a.get(e)?.name??e,go:()=>r(e)}))];e.replaceChildren(...o.flatMap((e,t)=>{let n=t===o.length-1,r=N(n?`span`:`button`,`prb-arch-crumb`,e.label);return n?r.setAttribute(`aria-current`,`location`):(r.type=`button`,r.addEventListener(`click`,e.go)),t===0?[r]:[N(`span`,`prb-arch-crumb-sep`,`›`),r]}))}function Hs(e,t){let n=document.createElement(`p`);n.className=`prb-arch-status`,n.textContent=t,e.replaceChildren(n)}function Us(e,t,n,r,i){let{architecture:a}=t,o=new Map(a.nodes.map(e=>[e.id,e])),s=e=>o.get(e)?.name??e;if(n.kind===`none`){let t=N(`p`,`prb-arch-hint`,`Select a part or an arrow to see what it is and the code it rests on.`);e.replaceChildren(t);return}if(n.kind===`node`){let c=o.get(n.id);if(!c)return;let l=[N(`p`,`prb-arch-kind`,`${As[c.kind]??c.kind}${c.parent?` in ${s(c.parent)}`:``}`),N(`h4`,`prb-arch-title`,c.name)];c.description&&l.push(N(`p`,`prb-arch-text`,c.description));let u=a.nodes.filter(e=>e.parent===c.id).length;if(u>0&&r){let e=N(`button`,`prb-arch-open`,`Show the ${u} parts inside ${c.name}`);e.type=`button`,e.addEventListener(`click`,()=>r(c.id)),l.push(e)}i&&l.push(...i(c)),l.push(Ws(c.evidence,t.evidence[c.id]));let d=a.relationships.filter(e=>e.source===c.id||e.target===c.id);if(d.length>0){l.push(N(`h5`,`prb-arch-subhead`,`Relationships`));let e=N(`ul`,`prb-arch-related`,``);for(let t of d)e.append(N(`li`,``,`${s(t.source)} ${t.label} ${s(t.target)}`));l.push(e)}e.replaceChildren(...l);return}let c=[],l=n.ids.flatMap(e=>a.relationships.find(t=>t.id===e)??[]);l.length>1&&c.push(N(`p`,`prb-arch-kind`,`${l.length} relationships behind this arrow`));for(let e of l){let n=N(`section`,`prb-arch-relationship`,``);n.append(N(`p`,`prb-arch-kind`,`Relationship`),N(`h4`,`prb-arch-title`,`${s(e.source)} ${e.label} ${s(e.target)}`)),e.description&&n.append(N(`p`,`prb-arch-text`,e.description)),e.confidence!==void 0&&n.append(N(`p`,`prb-arch-meta`,`Inferred, with ${Math.round(e.confidence*100)}% confidence`)),n.append(Ws(e.evidence,t.evidence[e.id])),c.push(n)}e.replaceChildren(...c)}function Ws(e,t=[]){let n=N(`div`,`prb-arch-evidence`,``);n.append(N(`h5`,`prb-arch-subhead`,`Evidence`));let r=N(`ul`,`prb-arch-evidence-list`,``);return e.forEach((e,n)=>{let i=N(`li`,``,``),a=t[n];if(a&&a.state!==`missing`){let t=N(`button`,`prb-arch-location`,`${e.path}:${a.line}${a.endLine===a.line?``:`–${a.endLine}`}`);t.type=`button`,t.dataset.openEditor=e.path,t.dataset.openLine=String(a.line),i.append(t),a.via===`symbol`&&i.append(N(`span`,`prb-arch-gone`,`The quoted code has changed; this opens ${e.symbol}`))}else i.append(N(`span`,`prb-arch-location`,e.path),N(`span`,`prb-arch-gone`,`No longer found in this checkout`));i.append(N(`code`,`prb-arch-quote`,e.quote)),e.note&&i.append(N(`span`,`prb-arch-note`,e.note)),r.append(i)}),n.append(r),n}function N(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n&&(r.textContent=n),r}function Gs(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}var Ks=1e3,qs=new WeakMap;function Js(e,t){return e.length<=1e3?Gs(e)||`&nbsp;`:`${Gs(e.slice(0,Ks))}\u2026 <button type="button" class="prb-code-long-toggle" data-full-line="${t}">Show full line</button>`}function Ys(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">${Js(e.text,`old:${e.oldLine}`)}</td></tr>`).join(``)}function Xs(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?Ys(c):``}<tr class="${s}" data-line="${o}"><td class="prb-code-num">${o}</td><td class="prb-code-line">${Js(i,`new:${o}`)}</td></tr>`}),a=r.get(e.totalLines+1);return a&&e.to===e.totalLines&&i.push(Ys(a)),i.join(``)}function Zs(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 Qs(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&&qs.set(r,o)}}function $s(e){let t=qs.get(e),n=e.closest(`td`);return t===void 0||!n?null:(n.textContent=t,n)}function ec(e){return e.deletion?2*e.line-1:2*e.line}function tc(e){return e%2==1?{line:(e+1)/2,deletion:!0}:{line:e/2,deletion:!1}}function nc(e,t){if(e.length===0)return``;let n=e.map(ec),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}">
160
160
  <button type="button" class="prb-code-nav-step" data-change-step="previous"${i?``:` disabled`}>\u2191 Previous</button>
161
161
  <span class="prb-code-nav-count" aria-live="polite">${s}</span>
162
162
  <button type="button" class="prb-code-nav-step" data-change-step="next"${a?``:` disabled`}>Next \u2193</button>
163
- </span>`}function Hs(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:Bs(i)}}function Us(e,t){return e.querySelector(t.deletion?`tr[data-before-line="${t.line}"]`:`tr[data-line="${t.line}"]`)}function Ws(e){return(e.dataset.changeKeys??``).split(`,`).filter(Boolean).map(Number).map(Bs)}function Gs(e){if(!e)return;let t=Number(e.dataset.changePosition)||0;return(e.dataset.changeKeys??``).split(`,`).filter(Boolean).map(Number).includes(t)?Bs(t):void 0}function Ks(e,t){return Math.max(e,+!t)+1}var qs=8;function Js(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 Ys(e){let t=e.panel-e.scroller;return Math.max(340,Math.floor(e.pane-t-16))}function Xs(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 Zs(e,t){let n=t.row.getBoundingClientRect().top-e.getBoundingClientRect().top-t.offset;e.scrollTop+=n}function Qs(e){if(!e.hasAttribute(`data-expanded`))return;let t=Js(e),n=e.querySelector(`.prb-code-scroll`);if(!t||!n)return;let r=Ys({pane:t.clientHeight,panel:e.offsetHeight,scroller:n.offsetHeight});e.style.setProperty(`--prb-code-expanded`,`${r}px`)}function $s(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 ec=!1;function tc(){ec||(ec=!0,window.addEventListener(`resize`,()=>{for(let e of document.querySelectorAll(`.prb-code[data-expanded]`))Qs(e)}))}function nc(e,t){let n=e.querySelector(`.prb-code-scroll`),r=n?Xs(n):null;t?(e.setAttribute(`data-expanded`,``),Qs(e),tc()):(e.removeAttribute(`data-expanded`),e.style.removeProperty(`--prb-code-expanded`)),$s(e),n&&r&&Zs(n,r);let i=t?Js(e):null;i&&(i.scrollTop+=e.getBoundingClientRect().top-i.getBoundingClientRect().top-qs)}var rc={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 ic(e){let t=e.slice(e.lastIndexOf(`/`)+1);if(t===`Dockerfile`||t.startsWith(`Dockerfile.`))return`docker`;let n=t.lastIndexOf(`.`);return n<=0?null:rc[t.slice(n+1).toLowerCase()]??null}function ac(e){let t=new Set;for(let n of e){let e=ic(n);e&&t.add(e)}return[...t]}var oc={ruby:()=>v(()=>import(`./chunk-CAnKkQXq.js`),__vite__mapDeps([20,21,22,23,24,25,26,27,28,29,30])),javascript:()=>v(()=>import(`./chunk-D2pwppYQ.js`),__vite__mapDeps([31,22])),typescript:()=>v(()=>import(`./chunk-Cjc271yU.js`),__vite__mapDeps([32,27])),jsx:()=>v(()=>import(`./chunk-B2PgDgse.js`),__vite__mapDeps([33,25])),tsx:()=>v(()=>import(`./chunk-D95j_xjm.js`),__vite__mapDeps([34,28])),json:()=>v(()=>import(`./chunk-qhed-kSA.js`),[]),yaml:()=>v(()=>import(`./chunk-Cv3JjNkX.js`),__vite__mapDeps([35,30])),markdown:()=>v(()=>import(`./chunk-BYOwaDjH.js`),[]),html:()=>v(()=>import(`./chunk-EIJEcyW-.js`),__vite__mapDeps([36,23,21,22])),css:()=>v(()=>import(`./chunk-C3nvJp0N.js`),__vite__mapDeps([37,21])),scss:()=>v(()=>import(`./chunk-D2NZorQR.js`),__vite__mapDeps([38,21])),sql:()=>v(()=>import(`./chunk-NzFayA7r.js`),__vite__mapDeps([39,26])),python:()=>v(()=>import(`./chunk-gzcpVVnB.js`),[]),java:()=>v(()=>import(`./chunk-AdYjtsZU.js`),__vite__mapDeps([40,24])),kotlin:()=>v(()=>import(`./chunk-DhhofPvG.js`),[]),go:()=>v(()=>import(`./chunk-rLFTqkRN.js`),[]),rust:()=>v(()=>import(`./chunk-Cfkwpbl8.js`),[]),shellscript:()=>v(()=>import(`./chunk-pNSm1SyV.js`),__vite__mapDeps([41,29])),docker:()=>v(()=>import(`./chunk-IyjqRm3v.js`),[]),terraform:()=>v(()=>import(`./chunk-DswuEJGm.js`),[])},sc=`github-light-default`,cc=null,lc=new Map;function uc(){return cc??=Promise.all([v(()=>import(`./chunk-c-cg1wCO.js`),__vite__mapDeps([42,4])),v(()=>import(`./chunk-CBrdyqSx.js`),__vite__mapDeps([43,4])),v(()=>import(`./chunk-BXViO-2h.js`),[])]).then(([{createHighlighterCore:e},{createOnigurumaEngine:t},n])=>e({themes:[n.default],langs:[],engine:t(v(()=>import(`./chunk-BnjxR4X6.js`),[]))})).catch(()=>null),cc}function dc(e){let t=lc.get(e);return t||(t=uc().then(async t=>t?(await t.loadLanguage(oc[e]),!0):!1).catch(()=>!1),lc.set(e,t)),t.then(e=>e?uc():null)}var fc={async preload(e){await dc(e)},async tokenize(e,t){let n=await dc(t);if(!n)return null;try{let{tokens:r,fg:i}=n.codeToTokens(e,{lang:t,theme:sc}),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 pc(e,t=fc){return Promise.all(e.map(e=>t.preload(e))).then(()=>void 0)}var mc=/^#[0-9a-f]{3,8}$/i;function hc(e,t){return!t||t.map(e=>e.content).join(``)!==e?null:t.map(e=>e.color&&mc.test(e.color)?`<span style="color:${e.color}">${As(e.content)}</span>`:As(e.content)).join(``)}function gc(e){return e.length>1e3?e.slice(0,js):e}function _c(e,t,n){if(!e||t===``)return;let r=hc(gc(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 vc(e,t,n=fc){let r=ic(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(gc).join(`
164
- `),r);if(a()){o&&t.lines.forEach((e,n)=>{_c(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=>gc(e.text)).join(`
165
- `),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;_c(o.querySelector(`.prb-code-line`),r.text,t[n]),o=o.nextElementSibling}}}}async function yc(e,t=fc){let n=e.closest(`.prb-code`)?.dataset.syntax,r=e.textContent??``;if(!n||!(n in oc)||r===``)return;let i=await t.tokenize(r,n);if(!e.isConnected||e.childElementCount!==0||e.textContent!==r)return;let a=hc(r,i?.[0]);a!==null&&i?.length===1&&(e.innerHTML=a)}var P=f({ownsRestore:!0}),F=document.body,bc=F.dataset.apiBase??``,xc=F.dataset.token??``,Sc=F.dataset.editorLabel??``,Cc=F.dataset.editorTemplate??``,wc=F.dataset.repoPath??``,Tc=F.dataset.explainPrompt??``,Ec=F.dataset.sessionId??``;function I(e){return`${bc}${e}?t=${encodeURIComponent(xc)}`}function L(e){fetch(I(`/event`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})}var Dc=Ea({endpoint:I,showDiagrams:()=>B(`diagram`),showMap:()=>B(`map`),showChangeMap:e=>Oc.show(e)}),Oc=Do({endpoint:I,showView:e=>B(e)}),kc=_s({endpoint:I}),Ac=null,jc=`the whole change`;function Mc(e){let t=Ln(e,Fc),n=P.push(Mn(t),t);Nc++,Ic(t),n&&Pc(t)}var Nc=0;function Pc(t){let n=(t.kind===`section`?document.querySelector(`.prb-rail [data-goto-section="${CSS.escape(t.sectionId)}"] .prb-rail-title`):document.querySelector(`.prb-rail [data-view-nav="${CSS.escape(t.view)}"] .prb-rail-title`))?.textContent?.trim();n&&e(document,n)}var R=null,Fc=document.querySelector(`[data-guide-start]`)?.dataset.guideStart??null;function Ic(e){let t=Ln(e,Fc);if(t!==e){let{kind:e,view:n,focus:r,...i}=h(history.state);P.replace(Mn(t),{...i,...t})}let n=!R||!Wn(R,t);R=t,n&&(t.kind===`view`?Vc(t.view):Gc(t.sectionId)),Rc(t.focus??null)}var Lc={history:{get state(){return history.state},pushState:(e,t,n)=>{Nc++,P.push(n,h(e))},replaceState:(e,t,n)=>P.replace(n,h(e)),back:()=>history.back()},apply:Ic},z=tr(document,{onOpen:e=>e.hasAttribute(`data-ask-buddy-menu`)?pu(e):mu(e),onClose:mu});function Rc(e){Jn(document.querySelector(`.prb-body`),document,e),z.closeAll(),e===`buddy`&&Pl()}function zc(e){R&&(R.focus===e?Kn(R,Lc):Gn(R,e,Lc))}function B(e,t={}){let n=t.keepFocus&&R?.focus?e:Pn(e,R?.focus);Mc({kind:`view`,view:e,...n?{focus:n}:{}})}function Bc(e){Mc({kind:`section`,sectionId:e,...R?.focus===`guide`?{focus:`guide`}:{}})}function Vc(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??``).split(` `).includes(e)));e!==`architecture`&&L({event:`view_opened`,view:e}),e===`diagram`&&Dc.drawPane(),e===`map`&&Oc.layout(),e===`architecture`&&kc.show(),Hc(),document.querySelector(`.prb-doc`)?.scrollTo({top:0})}function Hc(){Cr(),Ac=null,jc=`the whole change`,Kc()}function Uc(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 Wc(){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`)&&Uc(e,!0)}}function Gc(e){Vc(`guide`),Wc(),Sr(e);let t=br(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`}),Ac=e,jc=t.querySelector(`.pr-helper-guide-section-title`)?.textContent?.trim()??`this theme`,Kc()}function Kc(){let e=document.querySelector(`[data-ask-scope]`);e&&(e.textContent=jc)}function V(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function qc(e){return e.tagName===`LI`?{parent:e,position:`beforeend`}:{parent:e,position:`afterend`}}async function Jc(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}=qc(e);o.insertAdjacentElement(s,a),e.setAttribute(`aria-expanded`,`true`),L({event:`file_opened`,fromFinding:i,targeted:r>0}),await Xc(a,n,{cited:r,centre:r,expand:0,position:r?2*r:0})}var Yc=Mr();function Xc(e,t,n){return Yc.run(e,n,async()=>{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();return o.ok?()=>Zc(e,s,n):()=>{e.innerHTML=`<p class="prb-code-status">${V(s?.error??`Could not read that file.`)}</p>`}}catch{return()=>{e.innerHTML=`<p class="prb-code-status">Could not reach PR Review Buddy. The workspace server may have stopped.</p>`}}})}function Zc(e,t,n){let{cited:r,centre:i,expand:a}=n;e.dataset.cited=String(r),e.dataset.centre=String(i),e.dataset.expand=String(a),e.dataset.position=String(n.position);let o=Fs(t,r),s=Cc&&wc?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="${V(t.path)}" data-open-line="${r||t.from}">${V(`Open in ${Sc||`editor`}`)}</button>`:``,c=t.pullRequest&&t.pullRequest.precise?`<a class="prb-code-open prb-code-pr" href="${V(t.pullRequest.href)}" target="_blank" rel="noopener noreferrer">${V(t.pullRequest.label)}</a>`:``,l=t.truncated?`<button type="button" class="prb-code-more" data-expand-file="${V(t.path)}" data-expand-line="${i||0}" data-expand-cited="${r||0}" data-expand-step="${Ks(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>${V(t.sourceSha.slice(0,7))}</code>`:``}${u}${d}`:`Viewing your working folder${d}`}</span>${Vs(t.changeAnchors??[],n.position)}</div>`,ee=e.hasAttribute(`data-expanded`),te=`<button type="button" class="prb-code-open" data-code-expand aria-expanded="${ee}">${ee?`Collapse`:`Expand`}</button>`;e.innerHTML=`<div class="prb-code-header">
163
+ </span>`}function rc(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:tc(i)}}function ic(e,t){return e.querySelector(t.deletion?`tr[data-before-line="${t.line}"]`:`tr[data-line="${t.line}"]`)}function ac(e){return(e.dataset.changeKeys??``).split(`,`).filter(Boolean).map(Number).map(tc)}function oc(e){if(!e)return;let t=Number(e.dataset.changePosition)||0;return(e.dataset.changeKeys??``).split(`,`).filter(Boolean).map(Number).includes(t)?tc(t):void 0}function sc(e,t){return Math.max(e,+!t)+1}var cc=8;function lc(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 uc(e){let t=e.panel-e.scroller;return Math.max(340,Math.floor(e.pane-t-16))}function dc(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 fc(e,t){let n=t.row.getBoundingClientRect().top-e.getBoundingClientRect().top-t.offset;e.scrollTop+=n}function pc(e){if(!e.hasAttribute(`data-expanded`))return;let t=lc(e),n=e.querySelector(`.prb-code-scroll`);if(!t||!n)return;let r=uc({pane:t.clientHeight,panel:e.offsetHeight,scroller:n.offsetHeight});e.style.setProperty(`--prb-code-expanded`,`${r}px`)}function mc(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 hc=!1;function gc(){hc||(hc=!0,window.addEventListener(`resize`,()=>{for(let e of document.querySelectorAll(`.prb-code[data-expanded]`))pc(e)}))}function _c(e,t){let n=e.querySelector(`.prb-code-scroll`),r=n?dc(n):null;t?(e.setAttribute(`data-expanded`,``),pc(e),gc()):(e.removeAttribute(`data-expanded`),e.style.removeProperty(`--prb-code-expanded`)),mc(e),n&&r&&fc(n,r);let i=t?lc(e):null;i&&(i.scrollTop+=e.getBoundingClientRect().top-i.getBoundingClientRect().top-cc)}var vc={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 yc(e){let t=e.slice(e.lastIndexOf(`/`)+1);if(t===`Dockerfile`||t.startsWith(`Dockerfile.`))return`docker`;let n=t.lastIndexOf(`.`);return n<=0?null:vc[t.slice(n+1).toLowerCase()]??null}function bc(e){let t=new Set;for(let n of e){let e=yc(n);e&&t.add(e)}return[...t]}var xc={ruby:()=>v(()=>import(`./chunk-CAnKkQXq.js`),__vite__mapDeps([20,21,22,23,24,25,26,27,28,29,30])),javascript:()=>v(()=>import(`./chunk-D2pwppYQ.js`),__vite__mapDeps([31,22])),typescript:()=>v(()=>import(`./chunk-Cjc271yU.js`),__vite__mapDeps([32,27])),jsx:()=>v(()=>import(`./chunk-B2PgDgse.js`),__vite__mapDeps([33,25])),tsx:()=>v(()=>import(`./chunk-D95j_xjm.js`),__vite__mapDeps([34,28])),json:()=>v(()=>import(`./chunk-qhed-kSA.js`),[]),yaml:()=>v(()=>import(`./chunk-Cv3JjNkX.js`),__vite__mapDeps([35,30])),markdown:()=>v(()=>import(`./chunk-BYOwaDjH.js`),[]),html:()=>v(()=>import(`./chunk-EIJEcyW-.js`),__vite__mapDeps([36,23,21,22])),css:()=>v(()=>import(`./chunk-C3nvJp0N.js`),__vite__mapDeps([37,21])),scss:()=>v(()=>import(`./chunk-D2NZorQR.js`),__vite__mapDeps([38,21])),sql:()=>v(()=>import(`./chunk-NzFayA7r.js`),__vite__mapDeps([39,26])),python:()=>v(()=>import(`./chunk-gzcpVVnB.js`),[]),java:()=>v(()=>import(`./chunk-AdYjtsZU.js`),__vite__mapDeps([40,24])),kotlin:()=>v(()=>import(`./chunk-DhhofPvG.js`),[]),go:()=>v(()=>import(`./chunk-rLFTqkRN.js`),[]),rust:()=>v(()=>import(`./chunk-Cfkwpbl8.js`),[]),shellscript:()=>v(()=>import(`./chunk-pNSm1SyV.js`),__vite__mapDeps([41,29])),docker:()=>v(()=>import(`./chunk-IyjqRm3v.js`),[]),terraform:()=>v(()=>import(`./chunk-DswuEJGm.js`),[])},Sc=`github-light-default`,Cc=null,wc=new Map;function Tc(){return Cc??=Promise.all([v(()=>import(`./chunk-c-cg1wCO.js`),__vite__mapDeps([42,4])),v(()=>import(`./chunk-CBrdyqSx.js`),__vite__mapDeps([43,4])),v(()=>import(`./chunk-BXViO-2h.js`),[])]).then(([{createHighlighterCore:e},{createOnigurumaEngine:t},n])=>e({themes:[n.default],langs:[],engine:t(v(()=>import(`./chunk-BnjxR4X6.js`),[]))})).catch(()=>null),Cc}function Ec(e){let t=wc.get(e);return t||(t=Tc().then(async t=>t?(await t.loadLanguage(xc[e]),!0):!1).catch(()=>!1),wc.set(e,t)),t.then(e=>e?Tc():null)}var Dc={async preload(e){await Ec(e)},async tokenize(e,t){let n=await Ec(t);if(!n)return null;try{let{tokens:r,fg:i}=n.codeToTokens(e,{lang:t,theme:Sc}),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 Oc(e,t=Dc){return Promise.all(e.map(e=>t.preload(e))).then(()=>void 0)}var kc=/^#[0-9a-f]{3,8}$/i;function Ac(e,t){return!t||t.map(e=>e.content).join(``)!==e?null:t.map(e=>e.color&&kc.test(e.color)?`<span style="color:${e.color}">${Gs(e.content)}</span>`:Gs(e.content)).join(``)}function jc(e){return e.length>1e3?e.slice(0,Ks):e}function Mc(e,t,n){if(!e||t===``)return;let r=Ac(jc(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 Nc(e,t,n=Dc){let r=yc(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(jc).join(`
164
+ `),r);if(a()){o&&t.lines.forEach((e,n)=>{Mc(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=>jc(e.text)).join(`
165
+ `),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;Mc(o.querySelector(`.prb-code-line`),r.text,t[n]),o=o.nextElementSibling}}}}async function Pc(e,t=Dc){let n=e.closest(`.prb-code`)?.dataset.syntax,r=e.textContent??``;if(!n||!(n in xc)||r===``)return;let i=await t.tokenize(r,n);if(!e.isConnected||e.childElementCount!==0||e.textContent!==r)return;let a=Ac(r,i?.[0]);a!==null&&i?.length===1&&(e.innerHTML=a)}var P=ee({ownsRestore:!0}),F=document.body,Fc=F.dataset.apiBase??``,Ic=F.dataset.token??``,Lc=F.dataset.editorLabel??``,Rc=F.dataset.editorTemplate??``,zc=F.dataset.repoPath??``,Bc=F.dataset.explainPrompt??``,Vc=F.dataset.sessionId??``;function I(e){return`${Fc}${e}?t=${encodeURIComponent(Ic)}`}function Hc(e){fetch(I(`/event`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})}var Uc=Va({endpoint:I,showDiagrams:()=>z(`diagram`),showMap:()=>z(`map`),showChangeMap:e=>Wc.show(e)}),Wc=Ho({endpoint:I,showView:e=>z(e)}),Gc=Ms({endpoint:I}),Kc=null,qc=`the whole change`;function Jc(e){let t=zn(e,Zc),n=P.push(Pn(t),t);Yc++,Qc(t),n&&Xc(t)}var Yc=0;function Xc(t){let n=(t.kind===`section`?document.querySelector(`.prb-rail [data-goto-section="${CSS.escape(t.sectionId)}"] .prb-rail-title`):document.querySelector(`.prb-rail [data-view-nav="${CSS.escape(t.view)}"] .prb-rail-title`))?.textContent?.trim();n&&e(document,n)}var L=null,Zc=document.querySelector(`[data-guide-start]`)?.dataset.guideStart??null;function Qc(e){let t=zn(e,Zc);if(t!==e){let{kind:e,view:n,focus:r,...i}=s(history.state);P.replace(Pn(t),{...i,...t})}let n=!L||!Kn(L,t);L=t,n&&(t.kind===`view`?rl(t.view):sl(t.sectionId)),el(t.focus??null)}var $c={history:{get state(){return history.state},pushState:(e,t,n)=>{Yc++,P.push(n,s(e))},replaceState:(e,t,n)=>P.replace(n,s(e)),back:()=>history.back()},apply:Qc},R=cr(document,{onOpen:e=>e.hasAttribute(`data-ask-buddy-menu`)?ku(e):Au(e),onClose:Au});function el(e){Xn(document.querySelector(`.prb-body`),document,e),R.closeAll(),e===`buddy`&&Xl()}function tl(e){L&&(L.focus===e?Jn(L,$c):qn(L,e,$c))}function z(e,t={}){let n=t.keepFocus&&L?.focus?e:In(e,L?.focus);Jc({kind:`view`,view:e,...n?{focus:n}:{}})}function nl(e){Jc({kind:`section`,sectionId:e,...L?.focus===`guide`?{focus:`guide`}:{}})}function rl(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??``).split(` `).includes(e)));e!==`architecture`&&Hc({event:`view_opened`,view:e}),e===`diagram`&&Uc.drawPane(),e===`map`&&Wc.layout(),e===`architecture`&&Gc.show(),il(),document.querySelector(`.prb-doc`)?.scrollTo({top:0})}function il(){Ar(),Kc=null,qc=`the whole change`,cl()}function al(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 ol(){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`)&&al(e,!0)}}function sl(e){rl(`guide`),ol(),kr(e);let t=Dr(e);if(!t)return;let n=document.querySelector(`[data-goto-section="${CSS.escape(e)}"]`);Hc({event:`theme_opened`,themeIndex:Number(n?.dataset.themeIndex??-1),attention:n?.querySelector(`.prb-attention`)?.dataset.attention??`medium`,isRecommendedStart:n?.dataset.recommendedStart===`true`}),Kc=e,qc=t.querySelector(`.pr-helper-guide-section-title`)?.textContent?.trim()??`this theme`,cl()}function cl(){let e=document.querySelector(`[data-ask-scope]`);e&&(e.textContent=qc)}function B(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function ll(e){return e.tagName===`LI`?{parent:e,position:`beforeend`}:{parent:e,position:`afterend`}}async function ul(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}=ll(e);o.insertAdjacentElement(s,a),e.setAttribute(`aria-expanded`,`true`),Hc({event:`file_opened`,fromFinding:i,targeted:r>0}),await fl(a,n,{cited:r,centre:r,expand:0,position:r?2*r:0})}var dl=zr();function fl(e,t,n){return dl.run(e,n,async()=>{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();return o.ok?()=>pl(e,s,n):()=>{e.innerHTML=`<p class="prb-code-status">${B(s?.error??`Could not read that file.`)}</p>`}}catch{return()=>{e.innerHTML=`<p class="prb-code-status">Could not reach PR Review Buddy. The workspace server may have stopped.</p>`}}})}function pl(e,t,n){let{cited:r,centre:i,expand:a}=n;e.dataset.cited=String(r),e.dataset.centre=String(i),e.dataset.expand=String(a),e.dataset.position=String(n.position);let o=Xs(t,r),s=Rc&&zc?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="${B(t.path)}" data-open-line="${r||t.from}">${B(`Open in ${Lc||`editor`}`)}</button>`:``,c=t.pullRequest&&t.pullRequest.precise?`<a class="prb-code-open prb-code-pr" href="${B(t.pullRequest.href)}" target="_blank" rel="noopener noreferrer">${B(t.pullRequest.label)}</a>`:``,l=t.truncated?`<button type="button" class="prb-code-more" data-expand-file="${B(t.path)}" data-expand-line="${i||0}" data-expand-cited="${r||0}" data-expand-step="${sc(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>${B(t.sourceSha.slice(0,7))}</code>`:``}${u}${d}`:`Viewing your working folder${d}`}</span>${nc(t.changeAnchors??[],n.position)}</div>`,p=e.hasAttribute(`data-expanded`),ee=`<button type="button" class="prb-code-open" data-code-expand aria-expanded="${p}">${p?`Collapse`:`Expand`}</button>`;e.innerHTML=`<div class="prb-code-header">
166
166
  <span class="prb-code-range">lines ${t.from}\u2013${t.to} of ${t.totalLines}</span>
167
167
  ${c}
168
168
  ${s}
169
- ${te}
169
+ ${ee}
170
170
  </div>
171
171
  ${f}
172
172
  <div class="prb-code-scroll"><table class="prb-code-table"><tbody>${o}</tbody></table></div>
173
- ${l}`,Ls(e,t),Qs(e),$s(e),(n.focus?Us(e,n.focus):e.querySelector(`.prb-code-target`))?.scrollIntoView({block:`center`}),vc(e,t)}async function Qc(e,t,n){let r=Hs(t,n);if(!r)return;let i=Us(e,r.anchor);if(i)t.outerHTML=Vs(Ws(t),r.key),i.scrollIntoView({block:`center`});else{let t=e.querySelector(`[data-expand-file]`);if(!t?.dataset.expandFile)return;await Xc(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 $c(e,t,n){let r=`${wc.replace(/\/$/,``)}/${e}`,i=Cc.replace(`{path}`,r).replace(`{line}`,String(Math.max(1,t)));n!==null&&L({event:`editor_opened`,fromFinding:n}),window.location.href=i}var H=document.querySelector(`[data-ask-log]`);H&&H.querySelector(`.prb-msg`)&&H.scrollTo({top:H.scrollHeight});var el=document.querySelector(`[data-ask-form]`),U=el?.querySelector(`textarea`);function tl(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=Ue(t)+mt(t)):n.textContent=t,H?.appendChild(n),H?.scrollTo({top:H.scrollHeight}),n}function nl(){let e=document.createElement(`div`);return e.className=`prb-thinking`,e.innerHTML=`<i></i><i></i><i></i><span>Reading the change…</span>`,H?.appendChild(e),H?.scrollTo({top:H.scrollHeight}),e}var W=null,rl=!!H?.querySelector(`[data-ask-pending]`);function il(){let e=document.createElement(`div`);e.className=`prb-stopped`,e.textContent=`Stopped.`,H?.appendChild(e),H?.scrollTo({top:H.scrollHeight})}async function al(e,t=`free_text`){let n=e.trim();if(!n||W||rl)return;document.querySelector(`.prb-ask-empty`)?.remove(),tl(`user`,n);let r=nl();W=new AbortController,sl(!0);try{let e=await fetch(I(`/ask`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({question:n,sectionId:Ac,source:t}),signal:W.signal}),i=await e.json().catch(()=>null);if(e.status===409&&(i?.running||i?.updating)){ol(n),window.location.reload();return}if(r.remove(),i?.stopped){il();return}if(!e.ok||!i?.answer){tl(`error`,i?.error??`Buddy AI did not answer. Check the terminal running PR Review Buddy.`);return}tl(`assistant`,i.answer)}catch(e){r.remove(),e instanceof DOMException&&e.name===`AbortError`?(il(),ol(n)):(tl(`error`,`Could not reach PR Review Buddy. The workspace server may have stopped.`),ol(n))}finally{W=null,sl(!1)}}function ol(e){!U||U.value||(U.value=e,kd?.save())}function sl(e){let t=el?.querySelector(`button`);t&&(t.textContent=e?`Stop`:`Ask`,t.toggleAttribute(`data-stop`,e),t.disabled=!1);for(let t of document.querySelectorAll(cl))t.disabled=e;e&&z.closeAll(),e||U?.focus()}var cl=`[data-suggestion], .pr-helper-explain-simply-button`;function ll(){let e=el?.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(()=>{W?.abort()})}el?.addEventListener(`submit`,e=>{if(e.preventDefault(),W||rl)return ll();let t=U?.value??``;U&&(U.value=``),kd?.clear(),al(t,dl(t))}),rl&&sl(!0);var ul=null;function dl(e){return ul&&e.includes(ul.text)?ul.source:`free_text`}U?.addEventListener(`keydown`,e=>{if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),W||rl)return;el?.requestSubmit()}}),U?.addEventListener(`input`,()=>{U&&(U.style.height=`auto`,U.style.height=`${Math.min(U.scrollHeight,140)}px`)});async function fl(e){try{await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answeredQuestionIds:e})})}catch{}}function pl(){return[...document.querySelectorAll(`[data-question-answered][data-answered="true"]`)].map(e=>e.dataset.questionAnswered??``).filter(Boolean)}function ml(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&&bl(n,t,`questions`),El()}function hl(){return[...document.querySelectorAll(`[data-issue-dismissed][data-dismissed="true"]`)].map(e=>({id:e.dataset.issueDismissed??``,sessionId:e.dataset.dismissedIn||Ec})).filter(e=>e.id)}async function gl(e){try{await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissedIssues:e})})}catch{}}function _l(e,t){e.dataset.dismissed=String(t),e.textContent=t?`Reopen`:`Dismiss`,delete e.dataset.stale,t?e.dataset.dismissedIn=Ec: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(vl()),bl(n,t||e.dataset.settled===`true`,`issues`),Ol())}function vl(){let e=document.createElement(`span`);return e.className=`pr-helper-finding-status pr-helper-finding-status-dismissed pr-helper-tip`,e.dataset.tip=hr,e.textContent=`Dismissed by you`,e}var yl=new WeakMap;function bl(e,t,n){let r=e.closest(`.pr-helper-closed-findings-list`);if(t!==!!r){if(t){let t=e.parentElement;t&&yl.set(e,{parent:t,before:e.nextElementSibling}),wl(n).append(e),t&&Cl(t)}else xl(e,n),(r?.children.length===0?r.closest(`.pr-helper-closed-findings`):null)?.remove();Tl(n)}}function xl(e,t){let n=yl.get(e);if(n?.parent.isConnected)n.parent.insertBefore(e,n.before);else{let n=Sl(e)??document.querySelector(`[data-view="${t}"]`);n?.insertBefore(e,n.querySelector(`.pr-helper-closed-findings`))}e.closest(`.pr-helper-question-group`)?.removeAttribute(`hidden`)}function Sl(e){let t=e.dataset.sectionId;return t?document.querySelector(`[data-question-group="${CSS.escape(t)}"]`):null}function Cl(e){let t=e.closest(`.pr-helper-question-group`);t&&!t.querySelector(`[data-finding-card]`)&&(t.hidden=!0)}function wl(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 Tl(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=vr(Dl())}function El(){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=yr(e.length,t)),kl(`questions`,e.length,t,`question`,`answered`)}function Dl(){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 Ol(){let e=Dl();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=_r(e.total,e.open,nr(e))),kl(`issues`,e.total,e.open,`issue`,nr(e))}function kl(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){Uc(n,n.getAttribute(`aria-expanded`)!==`true`);return}let r=t.closest(`a[data-view-nav], a[data-goto-section]`);if(r&&!ee(e))return;r&&e.preventDefault();let i=t.closest(`[data-view-nav]`);if(i?.dataset.viewNav){B(i.dataset.viewNav);return}let a=t.closest(`[data-author-context-toggle]`);if(a){lr(a);return}let o=t.closest(`[data-author-context-reveal]`);if(o){mr(o);return}let s=t.closest(`[data-overview-nav]`);if(s?.dataset.overviewNav){B(s.dataset.overviewNav===`guide`?`guide`:s.dataset.overviewNav);return}let c=t.closest(`[data-goto-section]`);if(c?.dataset.gotoSection){Bc(c.dataset.gotoSection);return}let l=t.closest(`[data-open-editor]`);if(l?.dataset.openEditor){$c(l.dataset.openEditor,Number(l.dataset.openLine)||1,!l.closest(`[data-architecture]`)||null);return}let u=t.closest(`[data-deletion-toggle]`);if(u){Is(u);return}let d=t.closest(`[data-code-expand]`);if(d){let e=d.closest(`.prb-code`);e&&nc(e,!e.hasAttribute(`data-expanded`));return}let f=t.closest(`[data-change-step]`);if(f){let e=f.closest(`[data-change-navigator]`),t=f.closest(`.prb-code`);e&&t&&!f.disabled&&Qc(t,e,f.dataset.changeStep===`previous`?`previous`:`next`);return}let te=t.closest(`[data-full-line]`);if(te){let e=Rs(te);e&&yc(e);return}let p=t.closest(`[data-expand-file]`);if(p?.dataset.expandFile){let e=p.closest(`.prb-code`);if(e){let t=e.querySelector(`[data-change-navigator]`);Xc(e,p.dataset.expandFile,{cited:Number(p.dataset.expandCited)||0,centre:Number(p.dataset.expandLine)||0,expand:Number(p.dataset.expandStep)||1,position:Number(t?.dataset.changePosition)||0,focus:Gs(t)})}return}let m=t.closest(`[data-focus-toggle]`);if(m?.dataset.focusToggle){zc(m.dataset.focusToggle);return}let ne=t.closest(`[data-prompt-toggle]`);if(ne){ru(ne.getAttribute(`aria-expanded`)===`true`);return}if(t.closest(`[data-ask-buddy-menu]`))return;let h=t.closest(`[data-file]`);if(h?.dataset.file){Jc(h);return}let re=xr(t);if(re){Bc(re);return}let ie=t.closest(`[data-question-answered]`);if(ie?.dataset.questionAnswered){ml(ie,ie.dataset.answered!==`true`),ar(ie);let e=pl();fl(e),L({event:`question_marked_answered`,answered:e.length,total:document.querySelectorAll(`[data-question-answered]`).length});return}let g=t.closest(`[data-issue-dismissed]`);if(g?.dataset.issueDismissed){_l(g,g.dataset.stale===`true`||g.dataset.dismissed!==`true`);let e=hl();gl(e),L({event:`issue_dismissed`,dismissed:e.length,total:document.querySelectorAll(`[data-issue-dismissed]`).length});return}let ae=t.closest(`[data-suggestion]`);if(ae){al(ae.textContent??``,`suggestion`);return}if(t.closest(`.pr-helper-explain-simply-button`)){Pl(),al(Tc,`explain_simply`);return}let oe=t.closest(`[data-prompt-use]`);if(oe?.dataset.promptUse){iu(oe.dataset.promptUse);return}let _=t.closest(`[data-prompt-edit]`);if(_?.dataset.promptEdit){xu(_.dataset.promptEdit);return}if(t.closest(`[data-prompt-add]`)){xu(``);return}if(t.closest(`[data-ask-toggle]`)){let e=R?.focus;e?(Kn(R,Lc),Ml(e!==`buddy`)):Ml(!jl())}});var G=document.querySelector(`.prb-body`),Al=document.querySelector(`.prb-ask`);function jl(){return!!Al&&getComputedStyle(Al).display!==`none`}function Ml(e){G&&(G.dataset.ask=e?`open`:`closed`),Nl(e)}function Nl(e){for(let t of document.querySelectorAll(`[data-ask-toggle]`))t.setAttribute(`aria-expanded`,String(e))}function Pl(){R?.focus&&R.focus!==`buddy`&&Kn(R,Lc),Ml(!0)}function Fl(){Nl(jl())}window.addEventListener(`resize`,Fl),re(I(`/restart`));var Il=document.querySelector(`[data-file-filter]`),Ll=document.querySelector(`[data-file-count]`),Rl=document.querySelector(`[data-file-none]`);function zl(){let e=(Il?.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}`}Rl&&(Rl.hidden=n>0),Ll&&(Ll.textContent=e?`${t} of ${Bl} file${Bl===1?``:`s`}`:`${Bl} file${Bl===1?``:`s`}`)}var Bl=document.querySelectorAll(`[data-view="files"] .prb-file:not(.prb-file-referenced)`).length;Il?.addEventListener(`input`,zl),Il?.addEventListener(`keydown`,e=>{e.key===`Escape`&&Il.value!==``&&(e.preventDefault(),Il.value=``,zl())}),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(),Jc(n))});var Vl=320,Hl=()=>Math.round(window.innerWidth/2),Ul=e=>Math.round(Math.min(Hl(),Math.max(Vl,e)));function Wl(e){G&&(e===null?G.style.removeProperty(`--ask-width`):G.style.setProperty(`--ask-width`,`${e}px`))}function Gl(){return Al?Math.round(Al.getBoundingClientRect().width):Vl}function Kl(e){fetch(I(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({askWidth:e})}).catch(()=>{})}var K=document.querySelector(`[data-ask-resize]`);K?.addEventListener(`pointerdown`,e=>{if(e.button!==0||!G||!Al)return;e.preventDefault(),K.setPointerCapture(e.pointerId),G.dataset.resizing=`true`;let t=e.clientX,n=Gl(),r=e=>{Wl(Ul(n+(t-e.clientX)))},i=()=>{K.removeEventListener(`pointermove`,r),K.removeEventListener(`pointerup`,i),K.removeEventListener(`pointercancel`,i),delete G.dataset.resizing,Kl(Gl())};K.addEventListener(`pointermove`,r),K.addEventListener(`pointerup`,i),K.addEventListener(`pointercancel`,i)}),K?.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=Ul(Gl()+n);Wl(r),Kl(r);return}(e.key===`Home`||e.key===`Escape`)&&(e.preventDefault(),Wl(null),Kl(null))}),K?.addEventListener(`dblclick`,()=>{Wl(null),Kl(null)}),window.addEventListener(`resize`,()=>{jl()&&G?.style.getPropertyValue(`--ask-width`)&&Wl(Ul(Gl()))});var ql=3e4,Jl=document.visibilityState===`visible`?Date.now():null,Yl=0;function Xl(){Jl!==null&&(Yl+=Date.now()-Jl,Jl=Date.now())}function Zl(){Xl();let e=Math.round(Yl/1e3);return Yl-=e*1e3,e}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`?Jl=Date.now():(Xl(),Jl=null)}),setInterval(()=>{let e=Zl();e>0&&L({event:`workspace_heartbeat`,visibleSeconds:e})},ql),window.addEventListener(`pagehide`,()=>{let e=I(`/event`),t=JSON.stringify({event:`review_completed`,trailingSeconds:Zl()});navigator.sendBeacon?.(e,new Blob([t],{type:`application/json`}))||fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:t,keepalive:!0}).catch(()=>{})});var Ql=document.querySelector(`[data-prompt-bank]`),$l=document.querySelector(`[data-prompt-list]`),q=eu();function eu(){try{let e=JSON.parse(Ql?.dataset.prompts??`[]`);return Array.isArray(e)?e:[]}catch{return[]}}function tu(){if(!$l)return;$l.innerHTML=q.map(e=>`<span class="prb-bank-item">
174
- <button type="button" class="prb-bank-use" data-prompt-use="${V(e.id)}" title="${V(e.prompt)}">${V(e.name)}</button>
175
- <button type="button" class="prb-bank-edit" data-prompt-edit="${V(e.id)}" aria-label="Edit ${V(e.name)}">&#9998;</button>
176
- </span>`).join(``);let e=document.querySelector(`[data-prompt-count]`);e&&(e.textContent=String(q.length)),uu()}async function nu(e){try{let t=await(await fetch(I(`/prompts`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({prompts:e})})).json().catch(()=>null);q=Array.isArray(t?.prompts)?t.prompts:q}catch{}tu()}function ru(e){document.querySelector(`[data-prompt-toggle]`)?.setAttribute(`aria-expanded`,String(!e)),Ql?.toggleAttribute(`data-collapsed`,e),$l&&($l.hidden=e),fetch(I(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({promptsCollapsed:e})}).catch(()=>{})}function iu(e){let t=q.find(t=>t.id===e);!t||!U||(U.value=wr(U.value,t.prompt),Pl(),U.focus(),U.setSelectionRange(U.value.length,U.value.length),U.dispatchEvent(new Event(`input`)))}var au=document.querySelector(`.prb-doc`),ou=null,su=null;function cu(){H&&(su?.(),su=mn(H,{layout:`flat`,actions:_n.map(e=>({id:e.id,label:e.label})),onChoose:(e,t)=>du(e,`selection`,t)}))}function lu(){return[...hn.map(e=>({id:e.id,label:e.label})),...q.map(e=>({id:Cn(e.id),label:e.name,section:Sn}))]}function uu(){au&&(ou?.(),ou=mn(au,{triggerLabel:`Ask Buddy AI`,actions:lu(),ignoreWithin:`[data-ask-buddy-menu]`,onChoose:(e,t)=>du(e,`selection`,t)}))}function du(e,t,n){Xn(e,{context:t,text:n},{savedPrompt:e=>q.find(t=>t.id===e)?.prompt??null,stage:e=>fu(e,t),send:e=>{Pl(),al(e,`finding`)}})}function fu(e,t){U&&(ul={text:e,source:t},U.value=wr(U.value,e),Pl(),U.focus(),U.setSelectionRange(U.value.length,U.value.length),U.dispatchEvent(new Event(`input`)))}function pu(e){let t=e.querySelector(`[data-menu-panel]`);if(t){t.innerHTML=rn(lu());for(let e of t.querySelectorAll(`[data-selection-action]`))e.setAttribute(`role`,`menuitem`);if(W||rl)for(let e of t.querySelectorAll(`button`))e.disabled=!0}}function mu(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=Tn(n);z.close(n),i&&du(r,`finding`,i)}),uu(),cu(),aa({root:document,showView:e=>B(e)}),Dt(document),Vt(document);var hu=document.querySelector(`[data-prompt-dialog]`),gu=document.querySelector(`[data-prompt-name]`),_u=document.querySelector(`[data-prompt-text]`),vu=document.querySelector(`[data-prompt-delete]`),yu=document.getElementById(`prb-prompt-title`),bu=``;function xu(e){let t=q.find(t=>t.id===e);bu=t?.id??``,yu&&(yu.textContent=t?`Edit prompt`:`Save a prompt`),gu&&(gu.value=t?.name??``),_u&&(_u.value=t?.prompt??``),vu&&(vu.hidden=!t),hu?.showModal(),gu?.focus()}async function Su(){let e=gu?.value.trim()??``,t=_u?.value.trim()??``;if(!e||!t){(e?_u:gu)?.focus();return}let n=bu?q.map(n=>n.id===bu?{...n,name:e,prompt:t}:n):[...q,{id:crypto.randomUUID(),name:e,prompt:t}];hu?.close(),await nu(n)}async function Cu(){if(!bu)return;let e=q.filter(e=>e.id!==bu);hu?.close(),await nu(e)}document.querySelector(`[data-prompt-cancel]`)?.addEventListener(`click`,()=>hu?.close()),vu?.addEventListener(`click`,()=>void Cu()),document.querySelector(`[data-prompt-save]`)?.addEventListener(`click`,()=>void Su());var J=document.querySelector(`[data-fresh-region]`),Y=document.querySelector(`[data-fresh-status]`),wu=document.querySelector(`[data-fresh-check]`),X=Fu(J?.dataset.report),Tu=`prb-fresh-reopen`,Eu=ju(),Du=J?.dataset.dismissedSha,Ou=Au(J?.dataset.availability),Z=ku(J?.dataset.remote);function ku(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Au(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function ju(){try{return sessionStorage.getItem(Tu)!==null&&(sessionStorage.removeItem(Tu),!0)}catch{return!1}}Eu&&Qu(),wu?.addEventListener(`click`,()=>void zu());var Mu=document.querySelector(`[data-fetch-remote]`);Mu&&(fetch(I(`/fetch`)).then(e=>e.ok?e.json():null).then(e=>{e?.fetchable===!0&&(Mu.hidden=!1)}).catch(()=>{}),Mu.addEventListener(`click`,()=>void Nu(Mu)));async function Nu(e){if(e.disabled)return;e.disabled=!0;let t=null;try{let e=await fetch(I(`/fetch`),{method:`POST`});e.ok&&(t=await e.json())}catch{}e.disabled=!1;let n=t??{repositories:1,fetched:0,failed:[],moved:0};m(ne(),{kind:n.fetched<n.repositories?`failed`:`ready`,text:oe(n)}),n.fetched>0&&await zu()}J?.addEventListener(`click`,e=>{let t=e.target;if(t.closest(`[data-fresh-close]`))return Eu=!1,Qu();let n=t.closest(`[data-fresh-dismiss]`);n&&(Du=n.dataset.freshDismiss||void 0,Eu=!1,Qu(),Pu())});function Pu(){fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissFreshnessSha:Du??null})}).catch(()=>{})}function Fu(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}var Iu=Yi(),Lu=!1,Ru=null;async function zu(){if(Lu)return;Lu=!0,Gu(!0),Ru&&await Ru;let e=Ku(X,Z),t=await Vu(!1);Gu(!1),t&&Zu(),Lu=!1,t&&(X?.code.state===`changed`||Z!==null)&&Du!==void 0&&(Du=void 0,Pu()),Qu(),Bu(t?Ku(X,Z)===e?`No change`:`Updated`:`Could not check`)}function Bu(e){Y&&(Y.textContent=e,window.setTimeout($u,2600))}async function Vu(e){let t=Iu.snapshot();try{let n=await(await fetch(`${I(`/freshness`)}${e?`&quiet=1`:``}`)).json();X=n.report??null,Ou=n.availability??null,Z=n.remote??null,Ju=n.kiss??null,n.kissDismissedSha!==void 0&&(Yu=n.kissDismissedSha??void 0),n.prState!==void 0&&Wu(n.prState);let r=Ji(n.standing);return r&&Iu.current(t)&&Bi(document,r),!0}catch{return!1}}async function Hu(){if(Lu||Ru||!J)return;let e=Ku(X,Z),t=JSON.stringify(Ju);Ru=Vu(!0);let n=await Ru;Ru=null,Uu=Date.now(),n&&(Ku(X,Z)!==e&&Qu(),JSON.stringify(Ju)!==t&&Zu())}var Uu=Date.now();function Wu(e){let t=document.querySelector(`[data-pr-state-slot]`);if(!t)return;let n=zi(e,t.hasAttribute(`data-beside-number`));t.innerHTML!==n&&(t.innerHTML=n)}function Gu(e){wu&&(wu.disabled=e),Y&&e&&(Y.textContent=`Checking…`,Y.dataset.state=`checking`)}function Ku(e,t){if(!e)return JSON.stringify({report:`none`,remote:t});let{checkedAt:n,...r}=e;return JSON.stringify({...r,remote:t})}var qu=document.querySelector(`[data-kiss-fresh-region]`),Ju=Xu(qu?.dataset.freshness),Yu=qu?.dataset.dismissedSha;function Xu(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Zu(){Mi(Ju?.state===`changed`),qu&&(qu.innerHTML=wi(qu.dataset.reviewedSha??``,Ju,{dismissedSha:Yu,actions:xc!==``}))}qu?.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-freshness-dismiss]`);t&&(Yu=t.dataset.kissFreshnessDismiss||void 0,Zu(),fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissKissFreshnessSha:Yu??null})}).catch(()=>{}))});function Qu(){J&&(J.innerHTML=Zr(X,{dismissedSha:Du,open:Eu,actions:xc!==``,availability:Ou,remote:Z}),$u())}function $u(){if(Y&&(X||Z)){let{label:e,state:t}=Yr(X,Z);Y.textContent=e,Y.dataset.state=t,ci(document,t)}}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-copy-command]`);if(n)return ed(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 nd(i);if(t.closest(`[data-review-update]`))return void od();let a=t.closest(`[data-update-cancel]`);if(a)return void cd(a,`update`);let o=t.closest(`[data-review-cancel]`);if(o)return void cd(o,`review`);t.closest(`[data-update-close]`)&&document.querySelector(`[data-update-result]`)?.remove()});function ed(e){let t=e.dataset.copyCommand??``;navigator.clipboard?.writeText(t).then(()=>td(e,`Copied`),()=>td(e,`Select it`))}function td(e,t,n=1400){let r=e.textContent;e.textContent=t,setTimeout(()=>{e.textContent=r},n)}async function nd(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=rd(n);t?t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Re-checking the conversation, ${e}s. ${dd}`:n.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Checking… ${e}s`}};r();let i=window.setInterval(r,1e3),a=rd(e)?null:fd(e);try{await fetch(I(`/refresh`),{method:`POST`})}catch{}finally{window.clearInterval(i),a?.remove()}rd(e)&&id(),window.location.reload()}function rd(e){return e.closest(`.prb-fresh-notes p`)}function id(){try{sessionStorage.setItem(Tu,`1`)}catch{}}var ad=!1;async function od(){if(ad)return;ad=!0;let e=[...document.querySelectorAll(`[data-review-update]`)];for(let t of e)t.disabled=!0,t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Updating…`;let t=!1,n=()=>{t||(t=!0,window.clearInterval(r),window.location.reload())},r=window.setInterval(async()=>{try{let e=await(await fetch(I(`/job`))).json();e.update&&e.update.phase!==`none`&&!fi(e.update.phase)&&n()}catch{}},500);try{await fetch(I(`/update`),{method:`POST`})}catch{}n()}var sd={review:{path:`/job`,body:e=>({stop:e}),took:e=>e.stopped===!0,label:`Cancel review`,tooLate:`Too late to cancel: the review had already finished and was being saved.`,running:e=>e.phase},update:{path:`/update`,body:e=>({cancel:e}),took:e=>e.cancelled===!0,label:`Cancel update`,tooLate:`Too late to cancel: the update had already started saving its result.`,running:e=>e.update?.phase}};async function cd(e,t){let n=sd[t],r=(t===`review`?e.dataset.reviewCancel:e.dataset.updateCancel)??``;e.disabled=!0,e.textContent=`Cancelling…`;let i;try{let e=await fetch(I(n.path),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n.body(r))});if(!e.ok)throw Error(`refused`);i=n.took(await e.json())}catch{e.disabled=!1,e.textContent=n.label,ud(e,`The workspace server did not answer, so nothing was cancelled. Try again.`);return}i||ud(e,n.tooLate),await _a({look:async()=>{let e=await fetch(I(`/job`),{signal:AbortSignal.timeout(ld)});return n.running(await e.json())},reload:()=>window.location.reload()})}var ld=3e3;function ud(e,t){let n=e.parentElement;if(!n)return;let r=n.querySelector(`.prb-progress-cancel-status`);r||(r=document.createElement(`p`),r.className=`prb-progress-cancel-status`,r.setAttribute(`role`,`status`),n.appendChild(r)),r.textContent=t}var dd=`Fetching the latest threads from your pull request. This usually takes under a minute.`;function fd(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=dd,t.appendChild(n),n}var pd=fa(document),md=null,hd=Date.now();function gd(){md===null&&(md=window.setTimeout(()=>{md=null,_d()},_(Date.now()-hd)))}async function _d(){try{let e=await(await fetch(I(`/job`))).json();if(rl&&!e.ask||yd&&!e.diagram){window.location.reload();return}let t={job:e,kiss:e.kiss,update:e.update};for(let[e,n]of pd){let r=t[e];if(r){if(pa(e,r,document)){window.location.reload();return}e===`update`||n.matches(`[data-progress-pane]`)?(ha(n,r.phase,r.progress),ga(n)):vd(n,r.progress)}}}catch{}gd()}function vd(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 yd=document.querySelector(`[data-diagram-running]`)!==null;(pd.size>0||rl||yd)&&(hd=Date.now(),gd());function bd(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 xd(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…`,xd(t),fetch(I(`/retry`),{method:`POST`}).then(e=>{if(!e.ok)throw Error(`refused`);hd=Date.now(),gd()}).catch(()=>{t.disabled=!1,t.textContent=`Retry`,bd(t)}))}),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-run-review-again]`);t&&(t.disabled=!0,t.textContent=`Starting…`,fetch(I(`/reanalyse`),{method:`POST`}).then(e=>{if(!e.ok)throw Error(`refused`);location.reload()}).catch(()=>{t.disabled=!1,t.textContent=rr,td(t,`Could not start. Try again`,2500)}))});var Sd={send:async e=>{let t=await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kissDecision:e})});return t.ok?(await t.json().catch(()=>null))?.decision===e.decision:!1},paintRail:(e,t)=>{kl(`kiss`,e,t,`recommendation`,`decided`),kl(`kissrecs`,e,t,`recommendation`,`decided`)}};document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-kiss-decide]`),r=n?.closest(`[data-kiss-rec]`);if(n&&r&&!n.disabled){Di(r,Ei(n),Sd);return}let i=t.closest(`[data-kiss-open-primary]`);i&&i.closest(`[data-kiss-rec]`)?.querySelector(`.prb-kiss-locations [data-primary]`)?.click()}),document.addEventListener(`click`,e=>{let t=e.target;if(t.closest(`[data-kiss-run-open]`)){let e=document.querySelector(`[data-kiss-run-dialog]`);e&&!e.open&&e.showModal();return}t.closest(`[data-kiss-run-cancel]`)&&t.closest(`dialog`)?.close()}),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;if(!r)return;let i=t.textContent??`Run KISS review`;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=i;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 Cd=document.body.dataset.defaultView||`overview`;window.addEventListener(`popstate`,e=>{let t=zn(e.state)??Bn(window.location.hash)??{kind:`view`,view:Cd},n=!R||!Wn(R,t);Ic(t),n&&Pc(t),Od()});var wd=Bn(window.location.hash);wd?Ic(wd):(R={kind:`view`,view:Cd},P.replace(``,R));var Td={doc:document,main:document.querySelector(`main.prb-doc`),rail:document.querySelector(`.prb-rail`),log:H,panes:G};P.setCapturer(()=>Rr(Td));async function Ed(e,t,n){let r=e.dataset.file;if(!r)return;let i=Number(e.dataset.line)||0,a=t??{cited:i,centre:i,expand:0,position:i?2*i:0,tall:!1,top:null,offset:0},o=Er(e),s=o?Yc.pending(o):void 0;if(!o||!jr(s?s.request:kr(o),a)){if(!o){o=document.createElement(`div`),o.className=`prb-code`,o.innerHTML=`<p class="prb-code-status">Reading…</p>`;let{parent:t,position:n}=qc(e);t.insertAdjacentElement(n,o),e.setAttribute(`aria-expanded`,`true`)}if(!await Xc(o,r,{cited:a.cited,centre:a.centre,expand:a.expand,position:a.position}))return}else if(s&&!await s.done)return;n()&&(a.tall!==o.hasAttribute(`data-expanded`)&&nc(o,a.tall),t&&Ar(o,t.top,t.offset))}function Dd(e){Er(e)?.remove(),e.setAttribute(`aria-expanded`,`false`)}async function Od(){let e=++Nc,t=()=>Nc===e;await zr(Td,P.current().ui,{setFold:Uc,setAsk:Ml,openPanel:(e,n)=>Ed(e,n,t),closePanel:Dd,stillCurrent:t})}Od();var kd=U?Ur(U,{storage:(()=>{try{return window.sessionStorage}catch{return null}})(),path:window.location.pathname,restore:!0,win:window}):null;Fl(),Kc();var Ad=e=>{for(let t of document.querySelectorAll(`[data-analysis-details][open], [data-range-details][open]`))(!e||!t.contains(e))&&(t.open=!1)};document.addEventListener(`click`,e=>{Ad(e.target)}),document.addEventListener(`keydown`,e=>{if(e.key!==`Escape`)return;let t=document.querySelector(`[data-analysis-details][open], [data-range-details][open]`);t&&(Ad(),t.querySelector(`summary`)?.focus())});var Q=document.querySelector(`.prb-header [data-menu]`),$=Zi({root:document,post:(e,t)=>fetch(I(e),t===void 0?{method:`POST`}:{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),gate:Iu,checkForUpdates:()=>zu()});function jd(e){if(!Q)return;let t=Q.querySelector(`[data-menu-panel]`);t?.hidden&&z.open(Q),Q.querySelector(`[data-menu-error]`)?.remove();let n=document.createElement(`p`);n.className=`prb-menu-error`,n.setAttribute(`data-menu-error`,``),n.textContent=e,t?.append(n)}async function Md(e,t){if($.busy())return;Q?.querySelector(`[data-menu-error]`)?.remove(),t&&(t.disabled=!0);let n=await e();if(t&&(t.disabled=!1),!n.busy){if(n.error===null)return void z.closeAll();jd(n.error)}}function Nd(e){return Q?.querySelector(`[data-menu-items] ${e}`)??null}function Pd(e={}){if(!Q)return;Q.querySelector(`[data-menu-panel]`)?.hidden&&z.open(Q);let t=Q.querySelector(`[data-menu-items]`),n=Q.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!0),n&&(n.hidden=!1),e.focusCancel&&Q.querySelector(`[data-cancel-delete]`)?.focus()}if(Q){let e=Q.querySelector(`[data-confirm-delete]`),t=()=>mu(Q);Q.addEventListener(`click`,e=>{let n=e.target,a=n?.closest(`[data-copy-id]`);if(a?.dataset.copyId){e.stopPropagation(),se(a,a.dataset.copyId);return}let o=n?.closest(`[data-pin-toggle]`);if(o){e.stopPropagation(),r(o);return}if(n?.closest(`[data-fresh-check], [data-fetch-remote]`)){z.closeAll();return}let s=n?.closest(`[data-mark-status]`);if(s){e.stopPropagation(),Md(()=>$.setComplete(s.dataset.markStatus===`complete`),s);return}let c=n?.closest(`[data-lifecycle-set]`);if(c){e.stopPropagation(),Md(()=>$.setLifecycle(c.dataset.lifecycleSet),c);return}let l=n?.closest(`[data-queue-action]`);if(l){e.stopPropagation(),Md(()=>$.setQueued(l.dataset.queueAction===`remove`?`remove`:`add`),l);return}if(n?.closest(`[data-delete]`)){e.stopPropagation(),Pd();return}if(n?.closest(`[data-cancel-delete]`)){e.stopPropagation(),t();return}n?.closest(`[data-confirm-delete]`)&&(e.stopPropagation(),i())});let r=async e=>{let t=e.getAttribute(`aria-pressed`)!==`true`;e.disabled=!0;let r=null;try{let e=await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({pinned:t})});e.ok&&(r=(await e.json()).pinned===!0)}catch{}if(e.disabled=!1,r===null){e.textContent=t?`Could not pin`:`Could not unpin`,window.setTimeout(()=>{e.textContent=n(e.getAttribute(`aria-pressed`)===`true`)},1600);return}e.setAttribute(`aria-pressed`,String(r)),e.textContent=n(r)},i=async()=>{e&&(e.disabled=!0,e.textContent=`Deleting`);let{error:n}=await $.deleteReview();if(n===null)return void window.location.replace(`/`);e&&(e.disabled=!1,e.textContent=`Delete`),t(),jd(n)}}function Fd(e){return{available:()=>document.querySelector(`.prb-rail a[data-view-nav="${e}"]`)!==null,run:()=>B(e,{keepFocus:!0})}}function Id(){if(!R)return null;let e=R.focus??(R.kind===`section`?`guide`:R.view);return On.includes(e)&&document.querySelector(`[data-focus-toggle="${e}"]`)?e:null}ie(`review`,{"review.section.kiss":Fd(`kiss`),"review.section.issues":Fd(`issues`),"review.section.diagrams":Fd(`map`),"review.section.questions":Fd(`questions`),"review.section.files":Fd(`files`),"review.buddy.open":{available:()=>Al!==null,run:()=>{R?.focus?Gn(R,`buddy`,Lc):Ml(!0),document.querySelector(`[data-ask-form] textarea`)?.focus()}},"review.buddy.prompt":{available:()=>Al!==null&&U!==null,panel:la({prompts:()=>q,choose:iu})},"review.focus.toggle":{available:()=>Id()!==null,run:()=>{let e=Id();e&&zc(e)}},"review.focus.exit":{available:e=>!!(R&&e&&qn(e,document,!!R.focus)),run:()=>{R&&Kn(R,Lc)}},"review.mark.reviewed":{available:()=>$.offer().reviewed,run:()=>void Md(()=>$.setComplete(!0),Nd(`[data-mark-status]`))},"review.mark.waiting":{available:()=>$.offer().waiting,run:()=>void Md(()=>$.setLifecycle(`waiting`),Nd(`[data-lifecycle-set="waiting"]`))},"review.mark.done":{available:()=>$.offer().done,run:()=>void Md(()=>$.setLifecycle(`done`),Nd(`[data-lifecycle-set="done"]`))},"review.queue.toggle":{available:()=>$.offer().queue,run:()=>void Md(()=>$.toggleQueued(),Nd(`[data-queue-action]`))},"review.checkUpdates":{available:()=>$.offer().checkForUpdates,run:()=>void $.checkForUpdates()},"review.update":{available:()=>Xr(X,{actions:xc!==``&&!pd.has(`update`)&&!ad,remote:Z}),run:()=>void od()},"review.delete":{available:()=>$.offer().delete,run:()=>Pd({focusCancel:!0})}},{onOpen:()=>z.closeAll()}),p(),setTimeout(()=>{pc(ac([...document.querySelectorAll(`[data-view="files"] [data-file]`)].map(e=>e.dataset.file??``)))},0),te(window,()=>window.location.reload());var Ld=15e3,Rd=6e4;function zd(){return xc!==``&&document.visibilityState===`visible`&&!pd.has(`update`)}document.addEventListener(`visibilitychange`,()=>{zd()&&Date.now()-Uu>=Ld&&Hu()}),window.setInterval(()=>{zd()&&Hu()},Rd);export{ss as n,Lt as r,us as t};
173
+ ${l}`,Qs(e,t),pc(e),mc(e),(n.focus?ic(e,n.focus):e.querySelector(`.prb-code-target`))?.scrollIntoView({block:`center`}),Nc(e,t)}async function ml(e,t,n){let r=rc(t,n);if(!r)return;let i=ic(e,r.anchor);if(i)t.outerHTML=nc(ac(t),r.key),i.scrollIntoView({block:`center`});else{let t=e.querySelector(`[data-expand-file]`);if(!t?.dataset.expandFile)return;await fl(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 hl(e,t,n){let r=`${zc.replace(/\/$/,``)}/${e}`,i=Rc.replace(`{path}`,r).replace(`{line}`,String(Math.max(1,t)));n!==null&&Hc({event:`editor_opened`,fromFinding:n}),window.location.href=i}var V=document.querySelector(`[data-ask-log]`);V&&V.querySelector(`.prb-msg`)&&V.scrollTo({top:V.scrollHeight});var gl=document.querySelector(`[data-ask-form]`),H=gl?.querySelector(`textarea`);function _l(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=We(t)+gt(t)):n.textContent=t,V?.appendChild(n),V?.scrollTo({top:V.scrollHeight}),n}function vl(){let e=document.createElement(`div`);return e.className=`prb-thinking`,e.innerHTML=`<i></i><i></i><i></i><span>Reading the change…</span>`,V?.appendChild(e),V?.scrollTo({top:V.scrollHeight}),e}var U=null,yl=!!V?.querySelector(`[data-ask-pending]`);function bl(){let e=document.createElement(`div`);e.className=`prb-stopped`,e.textContent=`Stopped.`,V?.appendChild(e),V?.scrollTo({top:V.scrollHeight})}async function xl(e,t=`free_text`){let n=e.trim();if(!n||U||yl)return;document.querySelector(`.prb-ask-empty`)?.remove(),_l(`user`,n);let r=vl();U=new AbortController,Cl(!0);try{let e=await fetch(I(`/ask`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({question:n,sectionId:Kc,source:t}),signal:U.signal}),i=await e.json().catch(()=>null);if(e.status===409&&(i?.running||i?.updating)){Sl(n),window.location.reload();return}if(r.remove(),i?.stopped){bl();return}if(!e.ok||!i?.answer){_l(`error`,i?.error??`Buddy AI did not answer. Check the terminal running PR Review Buddy.`);return}_l(`assistant`,i.answer)}catch(e){r.remove(),e instanceof DOMException&&e.name===`AbortError`?(bl(),Sl(n)):(_l(`error`,`Could not reach PR Review Buddy. The workspace server may have stopped.`),Sl(n))}finally{U=null,Cl(!1)}}function Sl(e){!H||H.value||(H.value=e,Kd?.save())}function Cl(e){let t=gl?.querySelector(`button`);t&&(t.textContent=e?`Stop`:`Ask`,t.toggleAttribute(`data-stop`,e),t.disabled=!1);for(let t of document.querySelectorAll(wl))t.disabled=e;e&&R.closeAll(),e||H?.focus()}var wl=`[data-suggestion], .pr-helper-explain-simply-button`;function Tl(){let e=gl?.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(()=>{U?.abort()})}gl?.addEventListener(`submit`,e=>{if(e.preventDefault(),U||yl)return Tl();let t=H?.value??``;H&&(H.value=``),Kd?.clear(),xl(t,Dl(t))}),yl&&Cl(!0);var El=null;function Dl(e){return El&&e.includes(El.text)?El.source:`free_text`}H?.addEventListener(`keydown`,e=>{if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),U||yl)return;gl?.requestSubmit()}}),H?.addEventListener(`input`,()=>{H&&(H.style.height=`auto`,H.style.height=`${Math.min(H.scrollHeight,140)}px`)});async function Ol(e){try{await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answeredQuestionIds:e})})}catch{}}function kl(){return[...document.querySelectorAll(`[data-question-answered][data-answered="true"]`)].map(e=>e.dataset.questionAnswered??``).filter(Boolean)}function Al(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&&Il(n,t,`questions`),Hl()}function jl(){return[...document.querySelectorAll(`[data-issue-dismissed][data-dismissed="true"]`)].map(e=>({id:e.dataset.issueDismissed??``,sessionId:e.dataset.dismissedIn||Vc})).filter(e=>e.id)}async function Ml(e){try{await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissedIssues:e})})}catch{}}function Nl(e,t){e.dataset.dismissed=String(t),e.textContent=t?`Reopen`:`Dismiss`,delete e.dataset.stale,t?e.dataset.dismissedIn=Vc: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(Pl()),Il(n,t||e.dataset.settled===`true`,`issues`),Wl())}function Pl(){let e=document.createElement(`span`);return e.className=`pr-helper-finding-status pr-helper-finding-status-dismissed pr-helper-tip`,e.dataset.tip=Sr,e.textContent=`Dismissed by you`,e}var Fl=new WeakMap;function Il(e,t,n){let r=e.closest(`.pr-helper-closed-findings-list`);if(t!==!!r){if(t){let t=e.parentElement;t&&Fl.set(e,{parent:t,before:e.nextElementSibling}),Bl(n).append(e),t&&zl(t)}else Ll(e,n),(r?.children.length===0?r.closest(`.pr-helper-closed-findings`):null)?.remove();Vl(n)}}function Ll(e,t){let n=Fl.get(e);if(n?.parent.isConnected)n.parent.insertBefore(e,n.before);else{let n=Rl(e)??document.querySelector(`[data-view="${t}"]`);n?.insertBefore(e,n.querySelector(`.pr-helper-closed-findings`))}e.closest(`.pr-helper-question-group`)?.removeAttribute(`hidden`)}function Rl(e){let t=e.dataset.sectionId;return t?document.querySelector(`[data-question-group="${CSS.escape(t)}"]`):null}function zl(e){let t=e.closest(`.pr-helper-question-group`);t&&!t.querySelector(`[data-finding-card]`)&&(t.hidden=!0)}function Bl(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 Vl(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=Tr(Ul())}function Hl(){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=Er(e.length,t)),Gl(`questions`,e.length,t,`question`,`answered`)}function Ul(){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 Wl(){let e=Ul();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=wr(e.total,e.open,lr(e))),Gl(`issues`,e.total,e.open,`issue`,lr(e))}function Gl(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){al(n,n.getAttribute(`aria-expanded`)!==`true`);return}let r=t.closest(`a[data-view-nav], a[data-goto-section]`);if(r&&!i(e))return;r&&e.preventDefault();let a=t.closest(`[data-view-nav]`);if(a?.dataset.viewNav){z(a.dataset.viewNav);return}let o=t.closest(`[data-author-context-toggle]`);if(o){gr(o);return}let s=t.closest(`[data-author-context-reveal]`);if(s){xr(s);return}let c=t.closest(`[data-overview-nav]`);if(c?.dataset.overviewNav){z(c.dataset.overviewNav===`guide`?`guide`:c.dataset.overviewNav);return}let l=t.closest(`[data-goto-section]`);if(l?.dataset.gotoSection){nl(l.dataset.gotoSection);return}let u=t.closest(`[data-open-editor]`);if(u?.dataset.openEditor){hl(u.dataset.openEditor,Number(u.dataset.openLine)||1,!u.closest(`[data-architecture]`)||null);return}let d=t.closest(`[data-deletion-toggle]`);if(d){Zs(d);return}let f=t.closest(`[data-code-expand]`);if(f){let e=f.closest(`.prb-code`);e&&_c(e,!e.hasAttribute(`data-expanded`));return}let p=t.closest(`[data-change-step]`);if(p){let e=p.closest(`[data-change-navigator]`),t=p.closest(`.prb-code`);e&&t&&!p.disabled&&ml(t,e,p.dataset.changeStep===`previous`?`previous`:`next`);return}let ee=t.closest(`[data-full-line]`);if(ee){let e=$s(ee);e&&Pc(e);return}let m=t.closest(`[data-expand-file]`);if(m?.dataset.expandFile){let e=m.closest(`.prb-code`);if(e){let t=e.querySelector(`[data-change-navigator]`);fl(e,m.dataset.expandFile,{cited:Number(m.dataset.expandCited)||0,centre:Number(m.dataset.expandLine)||0,expand:Number(m.dataset.expandStep)||1,position:Number(t?.dataset.changePosition)||0,focus:oc(t)})}return}let h=t.closest(`[data-focus-toggle]`);if(h?.dataset.focusToggle){tl(h.dataset.focusToggle);return}let te=t.closest(`[data-prompt-toggle]`);if(te){yu(te.getAttribute(`aria-expanded`)===`true`);return}if(t.closest(`[data-ask-buddy-menu]`))return;let g=t.closest(`[data-file]`);if(g?.dataset.file){ul(g);return}let ne=Or(t);if(ne){nl(ne);return}let re=t.closest(`[data-question-answered]`);if(re?.dataset.questionAnswered){Al(re,re.dataset.answered!==`true`),fr(re);let e=kl();Ol(e),Hc({event:`question_marked_answered`,answered:e.length,total:document.querySelectorAll(`[data-question-answered]`).length});return}let _=t.closest(`[data-issue-dismissed]`);if(_?.dataset.issueDismissed){Nl(_,_.dataset.stale===`true`||_.dataset.dismissed!==`true`);let e=jl();Ml(e),Hc({event:`issue_dismissed`,dismissed:e.length,total:document.querySelectorAll(`[data-issue-dismissed]`).length});return}let ie=t.closest(`[data-suggestion]`);if(ie){xl(ie.textContent??``,`suggestion`);return}if(t.closest(`.pr-helper-explain-simply-button`)){Xl(),xl(Bc,`explain_simply`);return}let ae=t.closest(`[data-prompt-use]`);if(ae?.dataset.promptUse){bu(ae.dataset.promptUse);return}let oe=t.closest(`[data-prompt-edit]`);if(oe?.dataset.promptEdit){Ru(oe.dataset.promptEdit);return}if(t.closest(`[data-prompt-add]`)){Ru(``);return}if(t.closest(`[data-ask-toggle]`)){let e=L?.focus;e?(Jn(L,$c),Jl(e!==`buddy`)):Jl(!ql())}});var W=document.querySelector(`.prb-body`),Kl=document.querySelector(`.prb-ask`);function ql(){return!!Kl&&getComputedStyle(Kl).display!==`none`}function Jl(e){W&&(W.dataset.ask=e?`open`:`closed`),Yl(e)}function Yl(e){for(let t of document.querySelectorAll(`[data-ask-toggle]`))t.setAttribute(`aria-expanded`,String(e))}function Xl(){L?.focus&&L.focus!==`buddy`&&Jn(L,$c),Jl(!0)}function Zl(){Yl(ql())}window.addEventListener(`resize`,Zl),re(I(`/restart`));var Ql=document.querySelector(`[data-file-filter]`),$l=document.querySelector(`[data-file-count]`),eu=document.querySelector(`[data-file-none]`);function tu(){let e=(Ql?.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}`}eu&&(eu.hidden=n>0),$l&&($l.textContent=e?`${t} of ${nu} file${nu===1?``:`s`}`:`${nu} file${nu===1?``:`s`}`)}var nu=document.querySelectorAll(`[data-view="files"] .prb-file:not(.prb-file-referenced)`).length;Ql?.addEventListener(`input`,tu),Ql?.addEventListener(`keydown`,e=>{e.key===`Escape`&&Ql.value!==``&&(e.preventDefault(),Ql.value=``,tu())}),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(),ul(n))});var ru=320,iu=()=>Math.round(window.innerWidth/2),au=e=>Math.round(Math.min(iu(),Math.max(ru,e)));function ou(e){W&&(e===null?W.style.removeProperty(`--ask-width`):W.style.setProperty(`--ask-width`,`${e}px`))}function su(){return Kl?Math.round(Kl.getBoundingClientRect().width):ru}function cu(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||!Kl)return;e.preventDefault(),G.setPointerCapture(e.pointerId),W.dataset.resizing=`true`;let t=e.clientX,n=su(),r=e=>{ou(au(n+(t-e.clientX)))},i=()=>{G.removeEventListener(`pointermove`,r),G.removeEventListener(`pointerup`,i),G.removeEventListener(`pointercancel`,i),delete W.dataset.resizing,cu(su())};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=au(su()+n);ou(r),cu(r);return}(e.key===`Home`||e.key===`Escape`)&&(e.preventDefault(),ou(null),cu(null))}),G?.addEventListener(`dblclick`,()=>{ou(null),cu(null)}),window.addEventListener(`resize`,()=>{ql()&&W?.style.getPropertyValue(`--ask-width`)&&ou(au(su()))});var lu=3e4,uu=document.visibilityState===`visible`?Date.now():null,du=0;function fu(){uu!==null&&(du+=Date.now()-uu,uu=Date.now())}function pu(){fu();let e=Math.round(du/1e3);return du-=e*1e3,e}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`?uu=Date.now():(fu(),uu=null)}),setInterval(()=>{let e=pu();e>0&&Hc({event:`workspace_heartbeat`,visibleSeconds:e})},lu),window.addEventListener(`pagehide`,()=>{let e=I(`/event`),t=JSON.stringify({event:`review_completed`,trailingSeconds:pu()});navigator.sendBeacon?.(e,new Blob([t],{type:`application/json`}))||fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:t,keepalive:!0}).catch(()=>{})});var mu=document.querySelector(`[data-prompt-bank]`),hu=document.querySelector(`[data-prompt-list]`),K=gu();function gu(){try{let e=JSON.parse(mu?.dataset.prompts??`[]`);return Array.isArray(e)?e:[]}catch{return[]}}function _u(){if(!hu)return;hu.innerHTML=K.map(e=>`<span class="prb-bank-item">
174
+ <button type="button" class="prb-bank-use" data-prompt-use="${B(e.id)}" title="${B(e.prompt)}">${B(e.name)}</button>
175
+ <button type="button" class="prb-bank-edit" data-prompt-edit="${B(e.id)}" aria-label="Edit ${B(e.name)}">&#9998;</button>
176
+ </span>`).join(``);let e=document.querySelector(`[data-prompt-count]`);e&&(e.textContent=String(K.length)),Eu()}async function vu(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{}_u()}function yu(e){document.querySelector(`[data-prompt-toggle]`)?.setAttribute(`aria-expanded`,String(!e)),mu?.toggleAttribute(`data-collapsed`,e),hu&&(hu.hidden=e),fetch(I(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({promptsCollapsed:e})}).catch(()=>{})}function bu(e){let t=K.find(t=>t.id===e);!t||!H||(H.value=jr(H.value,t.prompt),Xl(),H.focus(),H.setSelectionRange(H.value.length,H.value.length),H.dispatchEvent(new Event(`input`)))}var xu=document.querySelector(`.prb-doc`),Su=null,Cu=null;function wu(){V&&(Cu?.(),Cu=gn(V,{layout:`flat`,actions:yn.map(e=>({id:e.id,label:e.label})),onChoose:(e,t)=>Du(e,`selection`,t)}))}function Tu(){return[..._n.map(e=>({id:e.id,label:e.label})),...K.map(e=>({id:Tn(e.id),label:e.name,section:wn}))]}function Eu(){xu&&(Su?.(),Su=gn(xu,{triggerLabel:`Ask Buddy AI`,actions:Tu(),ignoreWithin:`[data-ask-buddy-menu]`,onChoose:(e,t)=>Du(e,`selection`,t)}))}function Du(e,t,n){Qn(e,{context:t,text:n},{savedPrompt:e=>K.find(t=>t.id===e)?.prompt??null,stage:e=>Ou(e,t),send:e=>{Xl(),xl(e,`finding`)}})}function Ou(e,t){H&&(El={text:e,source:t},H.value=jr(H.value,e),Xl(),H.focus(),H.setSelectionRange(H.value.length,H.value.length),H.dispatchEvent(new Event(`input`)))}function ku(e){let t=e.querySelector(`[data-menu-panel]`);if(t){t.innerHTML=on(Tu());for(let e of t.querySelectorAll(`[data-selection-action]`))e.setAttribute(`role`,`menuitem`);if(U||yl)for(let e of t.querySelectorAll(`button`))e.disabled=!0}}function Au(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=Dn(n);R.close(n),i&&Du(r,`finding`,i)}),Eu(),wu();var q=pa({root:document,showView:e=>z(e)}),ju=va({doc:document,pane:()=>document.querySelector(`.prb-doc`),openMenu:(e,t)=>R.open(e,{focusFirst:!0,returnFocus:t}),selecting:()=>q.state().selecting,flip:e=>void q.flip(e)});kt(document),Ut(document);var Mu=document.querySelector(`[data-prompt-dialog]`),Nu=document.querySelector(`[data-prompt-name]`),Pu=document.querySelector(`[data-prompt-text]`),Fu=document.querySelector(`[data-prompt-delete]`),Iu=document.getElementById(`prb-prompt-title`),Lu=``;function Ru(e){let t=K.find(t=>t.id===e);Lu=t?.id??``,Iu&&(Iu.textContent=t?`Edit prompt`:`Save a prompt`),Nu&&(Nu.value=t?.name??``),Pu&&(Pu.value=t?.prompt??``),Fu&&(Fu.hidden=!t),Mu?.showModal(),Nu?.focus()}async function zu(){let e=Nu?.value.trim()??``,t=Pu?.value.trim()??``;if(!e||!t){(e?Pu:Nu)?.focus();return}let n=Lu?K.map(n=>n.id===Lu?{...n,name:e,prompt:t}:n):[...K,{id:crypto.randomUUID(),name:e,prompt:t}];Mu?.close(),await vu(n)}async function Bu(){if(!Lu)return;let e=K.filter(e=>e.id!==Lu);Mu?.close(),await vu(e)}document.querySelector(`[data-prompt-cancel]`)?.addEventListener(`click`,()=>Mu?.close()),Fu?.addEventListener(`click`,()=>void Bu()),document.querySelector(`[data-prompt-save]`)?.addEventListener(`click`,()=>void zu());var J=document.querySelector(`[data-fresh-region]`),Y=document.querySelector(`[data-fresh-status]`),Vu=document.querySelector(`[data-fresh-check]`),X=Qu(J?.dataset.report),Hu=`prb-fresh-reopen`,Uu=Ju(),Wu=J?.dataset.dismissedSha,Gu=qu(J?.dataset.availability),Z=Ku(J?.dataset.remote);function Ku(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function qu(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Ju(){try{return sessionStorage.getItem(Hu)!==null&&(sessionStorage.removeItem(Hu),!0)}catch{return!1}}Uu&&hd(),Vu?.addEventListener(`click`,()=>void nd());var Yu=document.querySelector(`[data-fetch-remote]`);Yu&&(fetch(I(`/fetch`)).then(e=>e.ok?e.json():null).then(e=>{e?.fetchable===!0&&(Yu.hidden=!1)}).catch(()=>{}),Yu.addEventListener(`click`,()=>void Xu(Yu)));async function Xu(e){if(e.disabled)return;e.disabled=!0;let t=null;try{let e=await fetch(I(`/fetch`),{method:`POST`});e.ok&&(t=await e.json())}catch{}e.disabled=!1;let n=t??{repositories:1,fetched:0,failed:[],moved:0};te(g(),{kind:n.fetched<n.repositories?`failed`:`ready`,text:oe(n)}),n.fetched>0&&await nd()}J?.addEventListener(`click`,e=>{let t=e.target;if(t.closest(`[data-fresh-close]`))return Uu=!1,hd();let n=t.closest(`[data-fresh-dismiss]`);n&&(Wu=n.dataset.freshDismiss||void 0,Uu=!1,hd(),Zu())});function Zu(){fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissFreshnessSha:Wu??null})}).catch(()=>{})}function Qu(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}var $u=na(),ed=!1,td=null;async function nd(){if(ed)return;ed=!0,cd(!0),td&&await td;let e=ld(X,Z),t=await id(!1);cd(!1),t&&md(),ed=!1,t&&(X?.code.state===`changed`||Z!==null)&&Wu!==void 0&&(Wu=void 0,Zu()),hd(),rd(t?ld(X,Z)===e?`No change`:`Updated`:`Could not check`)}function rd(e){Y&&(Y.textContent=e,window.setTimeout(gd,2600))}async function id(e){let t=$u.snapshot();try{let n=await(await fetch(`${I(`/freshness`)}${e?`&quiet=1`:``}`)).json();X=n.report??null,Gu=n.availability??null,Z=n.remote??null,dd=n.kiss??null,n.kissDismissedSha!==void 0&&(fd=n.kissDismissedSha??void 0),n.prState!==void 0&&sd(n.prState);let r=ta(n.standing);return r&&$u.current(t)&&qi(document,r),!0}catch{return!1}}async function ad(){if(ed||td||!J)return;let e=ld(X,Z),t=JSON.stringify(dd);td=id(!0);let n=await td;td=null,od=Date.now(),n&&(ld(X,Z)!==e&&hd(),JSON.stringify(dd)!==t&&md())}var od=Date.now();function sd(e){let t=document.querySelector(`[data-pr-state-slot]`);if(!t)return;let n=Ki(e,t.hasAttribute(`data-beside-number`));t.innerHTML!==n&&(t.innerHTML=n)}function cd(e){Vu&&(Vu.disabled=e),Y&&e&&(Y.textContent=`Checking…`,Y.dataset.state=`checking`)}function ld(e,t){if(!e)return JSON.stringify({report:`none`,remote:t});let{checkedAt:n,...r}=e;return JSON.stringify({...r,remote:t})}var ud=document.querySelector(`[data-kiss-fresh-region]`),dd=pd(ud?.dataset.freshness),fd=ud?.dataset.dismissedSha;function pd(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function md(){zi(dd?.state===`changed`),ud&&(ud.innerHTML=ji(ud.dataset.reviewedSha??``,dd,{dismissedSha:fd,actions:Ic!==``}))}ud?.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-freshness-dismiss]`);t&&(fd=t.dataset.kissFreshnessDismiss||void 0,md(),fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissKissFreshnessSha:fd??null})}).catch(()=>{}))});function hd(){J&&(J.innerHTML=ii(X,{dismissedSha:Wu,open:Uu,actions:Ic!==``,availability:Gu,remote:Z}),gd())}function gd(){if(Y&&(X||Z)){let{label:e,state:t}=ni(X,Z);Y.textContent=e,Y.dataset.state=t,hi(document,t)}}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-copy-command]`);if(n)return _d(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 yd(i);if(t.closest(`[data-review-update]`))return void Cd();let a=t.closest(`[data-update-cancel]`);if(a)return void Td(a,`update`);let o=t.closest(`[data-review-cancel]`);if(o)return void Td(o,`review`);t.closest(`[data-update-close]`)&&document.querySelector(`[data-update-result]`)?.remove()});function _d(e){let t=e.dataset.copyCommand??``;navigator.clipboard?.writeText(t).then(()=>vd(e,`Copied`),()=>vd(e,`Select it`))}function vd(e,t,n=1400){let r=e.textContent;e.textContent=t,setTimeout(()=>{e.textContent=r},n)}async function yd(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=bd(n);t?t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Re-checking the conversation, ${e}s. ${Od}`:n.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Checking… ${e}s`}};r();let i=window.setInterval(r,1e3),a=bd(e)?null:kd(e);try{await fetch(I(`/refresh`),{method:`POST`})}catch{}finally{window.clearInterval(i),a?.remove()}bd(e)&&xd(),window.location.reload()}function bd(e){return e.closest(`.prb-fresh-notes p`)}function xd(){try{sessionStorage.setItem(Hu,`1`)}catch{}}var Sd=!1;async function Cd(){if(Sd)return;Sd=!0;let e=[...document.querySelectorAll(`[data-review-update]`)];for(let t of e)t.disabled=!0,t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Updating…`;let t=!1,n=()=>{t||(t=!0,window.clearInterval(r),window.location.reload())},r=window.setInterval(async()=>{try{let e=await(await fetch(I(`/job`))).json();e.update&&e.update.phase!==`none`&&!yi(e.update.phase)&&n()}catch{}},500);try{await fetch(I(`/update`),{method:`POST`})}catch{}n()}var wd={review:{path:`/job`,body:e=>({stop:e}),took:e=>e.stopped===!0,label:`Cancel review`,tooLate:`Too late to cancel: the review had already finished and was being saved.`,running:e=>e.phase},update:{path:`/update`,body:e=>({cancel:e}),took:e=>e.cancelled===!0,label:`Cancel update`,tooLate:`Too late to cancel: the update had already started saving its result.`,running:e=>e.update?.phase}};async function Td(e,t){let n=wd[t],r=(t===`review`?e.dataset.reviewCancel:e.dataset.updateCancel)??``;e.disabled=!0,e.textContent=`Cancelling…`;let i;try{let e=await fetch(I(n.path),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n.body(r))});if(!e.ok)throw Error(`refused`);i=n.took(await e.json())}catch{e.disabled=!1,e.textContent=n.label,Dd(e,`The workspace server did not answer, so nothing was cancelled. Try again.`);return}i||Dd(e,n.tooLate),await Ma({look:async()=>{let e=await fetch(I(`/job`),{signal:AbortSignal.timeout(Ed)});return n.running(await e.json())},reload:()=>window.location.reload()})}var Ed=3e3;function Dd(e,t){let n=e.parentElement;if(!n)return;let r=n.querySelector(`.prb-progress-cancel-status`);r||(r=document.createElement(`p`),r.className=`prb-progress-cancel-status`,r.setAttribute(`role`,`status`),n.appendChild(r)),r.textContent=t}var Od=`Fetching the latest threads from your pull request. This usually takes under a minute.`;function kd(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=Od,t.appendChild(n),n}var Ad=Da(document),jd=null,Md=Date.now();function Nd(){jd===null&&(jd=window.setTimeout(()=>{jd=null,Pd()},se(Date.now()-Md)))}async function Pd(){try{let e=await(await fetch(I(`/job`))).json();if(yl&&!e.ask||Id&&!e.diagram){window.location.reload();return}let t={job:e,kiss:e.kiss,update:e.update};for(let[e,n]of Ad){let r=t[e];if(r){if(Oa(e,r,document)){window.location.reload();return}e===`update`||n.matches(`[data-progress-pane]`)?(Aa(n,r.phase,r.progress),ja(n)):Fd(n,r.progress)}}}catch{}Nd()}function Fd(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 Id=document.querySelector(`[data-diagram-running]`)!==null;(Ad.size>0||yl||Id)&&(Md=Date.now(),Nd());function Ld(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 Rd(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…`,Rd(t),fetch(I(`/retry`),{method:`POST`}).then(e=>{if(!e.ok)throw Error(`refused`);Md=Date.now(),Nd()}).catch(()=>{t.disabled=!1,t.textContent=`Retry`,Ld(t)}))}),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-run-review-again]`);t&&(t.disabled=!0,t.textContent=`Starting…`,fetch(I(`/reanalyse`),{method:`POST`}).then(e=>{if(!e.ok)throw Error(`refused`);location.reload()}).catch(()=>{t.disabled=!1,t.textContent=ur,vd(t,`Could not start. Try again`,2500)}))});var zd={send:async e=>{let t=await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kissDecision:e})});return t.ok?(await t.json().catch(()=>null))?.decision===e.decision:!1},paintRail:(e,t)=>{Gl(`kiss`,e,t,`recommendation`,`decided`),Gl(`kissrecs`,e,t,`recommendation`,`decided`)}};document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-kiss-decide]`),r=n?.closest(`[data-kiss-rec]`);if(n&&r&&!n.disabled){Pi(r,Ni(n),zd);return}let i=t.closest(`[data-kiss-open-primary]`);i&&i.closest(`[data-kiss-rec]`)?.querySelector(`.prb-kiss-locations [data-primary]`)?.click()}),document.addEventListener(`click`,e=>{let t=e.target;if(t.closest(`[data-kiss-run-open]`)){let e=document.querySelector(`[data-kiss-run-dialog]`);e&&!e.open&&e.showModal();return}t.closest(`[data-kiss-run-cancel]`)&&t.closest(`dialog`)?.close()}),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;if(!r)return;let i=t.textContent??`Run KISS review`;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=i;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 Bd=document.body.dataset.defaultView||`overview`;window.addEventListener(`popstate`,e=>{let t=Vn(e.state)??Hn(window.location.hash)??{kind:`view`,view:Bd},n=!L||!Kn(L,t);Qc(t),n&&Xc(t),Gd()});var Vd=Hn(window.location.hash);Vd?Qc(Vd):(L={kind:`view`,view:Bd},P.replace(``,L));var Hd={doc:document,main:document.querySelector(`main.prb-doc`),rail:document.querySelector(`.prb-rail`),log:V,panes:W};P.setCapturer(()=>Gr(Hd));async function Ud(e,t,n){let r=e.dataset.file;if(!r)return;let i=Number(e.dataset.line)||0,a=t??{cited:i,centre:i,expand:0,position:i?2*i:0,tall:!1,top:null,offset:0},o=Nr(e),s=o?dl.pending(o):void 0;if(!o||!Rr(s?s.request:Ir(o),a)){if(!o){o=document.createElement(`div`),o.className=`prb-code`,o.innerHTML=`<p class="prb-code-status">Reading…</p>`;let{parent:t,position:n}=ll(e);t.insertAdjacentElement(n,o),e.setAttribute(`aria-expanded`,`true`)}if(!await fl(o,r,{cited:a.cited,centre:a.centre,expand:a.expand,position:a.position}))return}else if(s&&!await s.done)return;n()&&(a.tall!==o.hasAttribute(`data-expanded`)&&_c(o,a.tall),t&&Lr(o,t.top,t.offset))}function Wd(e){Nr(e)?.remove(),e.setAttribute(`aria-expanded`,`false`)}async function Gd(){let e=++Yc,t=()=>Yc===e;await Kr(Hd,P.current().ui,{setFold:al,setAsk:Jl,openPanel:(e,n)=>Ud(e,n,t),closePanel:Wd,stillCurrent:t})}Gd();var Kd=H?Xr(H,{storage:(()=>{try{return window.sessionStorage}catch{return null}})(),path:window.location.pathname,restore:!0,win:window}):null;Zl(),cl();var qd=e=>{for(let t of document.querySelectorAll(`[data-analysis-details][open], [data-range-details][open]`))(!e||!t.contains(e))&&(t.open=!1)};document.addEventListener(`click`,e=>{qd(e.target)}),document.addEventListener(`keydown`,e=>{if(e.key!==`Escape`)return;let t=document.querySelector(`[data-analysis-details][open], [data-range-details][open]`);t&&(qd(),t.querySelector(`summary`)?.focus())});var Q=document.querySelector(`.prb-header [data-menu]`),$=ia({root:document,post:(e,t)=>fetch(I(e),t===void 0?{method:`POST`}:{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),gate:$u,checkForUpdates:()=>nd()});function Jd(e){if(!Q)return;let t=Q.querySelector(`[data-menu-panel]`);t?.hidden&&R.open(Q),Q.querySelector(`[data-menu-error]`)?.remove();let n=document.createElement(`p`);n.className=`prb-menu-error`,n.setAttribute(`data-menu-error`,``),n.textContent=e,t?.append(n)}async function Yd(e,t){if($.busy())return;Q?.querySelector(`[data-menu-error]`)?.remove(),t&&(t.disabled=!0);let n=await e();if(t&&(t.disabled=!1),!n.busy){if(n.error===null)return void R.closeAll();Jd(n.error)}}function Xd(e){return Q?.querySelector(`[data-menu-items] ${e}`)??null}function Zd(e={}){if(!Q)return;Q.querySelector(`[data-menu-panel]`)?.hidden&&R.open(Q);let t=Q.querySelector(`[data-menu-items]`),n=Q.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!0),n&&(n.hidden=!1),e.focusCancel&&Q.querySelector(`[data-cancel-delete]`)?.focus()}if(Q){let e=Q.querySelector(`[data-confirm-delete]`),t=()=>Au(Q);Q.addEventListener(`click`,e=>{let n=e.target,a=n?.closest(`[data-copy-id]`);if(a?.dataset.copyId){e.stopPropagation(),ce(a,a.dataset.copyId);return}let o=n?.closest(`[data-pin-toggle]`);if(o){e.stopPropagation(),r(o);return}if(n?.closest(`[data-fresh-check], [data-fetch-remote]`)){R.closeAll();return}let s=n?.closest(`[data-mark-status]`);if(s){e.stopPropagation(),Yd(()=>$.setComplete(s.dataset.markStatus===`complete`),s);return}let c=n?.closest(`[data-lifecycle-set]`);if(c){e.stopPropagation(),Yd(()=>$.setLifecycle(c.dataset.lifecycleSet),c);return}let l=n?.closest(`[data-queue-action]`);if(l){e.stopPropagation(),Yd(()=>$.setQueued(l.dataset.queueAction===`remove`?`remove`:`add`),l);return}if(n?.closest(`[data-delete]`)){e.stopPropagation(),Zd();return}if(n?.closest(`[data-cancel-delete]`)){e.stopPropagation(),t();return}n?.closest(`[data-confirm-delete]`)&&(e.stopPropagation(),i())});let r=async e=>{let t=e.getAttribute(`aria-pressed`)!==`true`;e.disabled=!0;let r=null;try{let e=await fetch(I(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({pinned:t})});e.ok&&(r=(await e.json()).pinned===!0)}catch{}if(e.disabled=!1,r===null){e.textContent=t?`Could not pin`:`Could not unpin`,window.setTimeout(()=>{e.textContent=n(e.getAttribute(`aria-pressed`)===`true`)},1600);return}e.setAttribute(`aria-pressed`,String(r)),e.textContent=n(r)},i=async()=>{e&&(e.disabled=!0,e.textContent=`Deleting`);let{error:n}=await $.deleteReview();if(n===null)return void window.location.replace(`/`);e&&(e.disabled=!1,e.textContent=`Delete`),t(),Jd(n)}}function Qd(e){return{available:()=>document.querySelector(`.prb-rail a[data-view-nav="${e}"]`)!==null,run:()=>z(e,{keepFocus:!0})}}function $d(){if(!L)return null;let e=L.focus??(L.kind===`section`?`guide`:L.view);return An.includes(e)&&document.querySelector(`[data-focus-toggle="${e}"]`)?e:null}function ef(){return[...document.querySelectorAll(`.prb-view:not([hidden]) [data-feedback-select]`)].some(e=>e.checkVisibility())}_(`review`,{...ju.commands,...ha(q,document),"review.section.review":{available:()=>ba(document)!==null,run:()=>{let e=ba(document);e&&z(e,{keepFocus:!0})}},"review.section.kiss":Qd(`kiss`),"review.section.issues":Qd(`issues`),"review.section.diagrams":Qd(`map`),"review.section.questions":Qd(`questions`),"review.section.files":Qd(`files`),"review.buddy.open":{available:()=>Kl!==null,run:()=>{L?.focus?qn(L,`buddy`,$c):Jl(!0),document.querySelector(`[data-ask-form] textarea`)?.focus()}},"review.buddy.prompt":{available:()=>Kl!==null&&H!==null,panel:wa({prompts:()=>K,choose:bu})},"review.focus.toggle":{available:()=>$d()!==null,run:()=>{let e=$d();e&&tl(e)}},"review.leave":{available:e=>!!(e&&Yn(e,document,e.target===H||q.state().selecting||!!L?.focus)),run:e=>{H&&e?.target===H?H.blur():q.state().selecting?q.exit():L?.focus&&Jn(L,$c)}},"review.feedback.toggle":{available:()=>q.state().selecting||ef(),label:()=>q.state().selecting?`Exit Prepare feedback`:`Start Prepare feedback`,run:()=>q.state().selecting?q.exit():q.enter()},"review.mark.reviewed":{available:()=>$.offer().reviewed,run:()=>void Yd(()=>$.setComplete(!0),Xd(`[data-mark-status]`))},"review.mark.waiting":{available:()=>$.offer().waiting,run:()=>void Yd(()=>$.setLifecycle(`waiting`),Xd(`[data-lifecycle-set="waiting"]`))},"review.mark.done":{available:()=>$.offer().done,run:()=>void Yd(()=>$.setLifecycle(`done`),Xd(`[data-lifecycle-set="done"]`))},"review.queue.toggle":{available:()=>$.offer().queue,run:()=>void Yd(()=>$.toggleQueued(),Xd(`[data-queue-action]`))},"review.checkUpdates":{available:()=>$.offer().checkForUpdates,run:()=>void $.checkForUpdates()},"review.update":{available:()=>ri(X,{actions:Ic!==``&&!Ad.has(`update`)&&!Sd,remote:Z}),run:()=>void Cd()},"review.delete":{available:()=>$.offer().delete,run:()=>Zd({focusCancel:!0})}},{onOpen:()=>R.closeAll()}),h(),setTimeout(()=>{Oc(bc([...document.querySelectorAll(`[data-view="files"] [data-file]`)].map(e=>e.dataset.file??``)))},0),m(window,()=>window.location.reload());var tf=15e3,nf=6e4;function rf(){return Ic!==``&&document.visibilityState===`visible`&&!Ad.has(`update`)}document.addEventListener(`visibilitychange`,()=>{rf()&&Date.now()-od>=tf&&ad()}),window.setInterval(()=>{rf()&&ad()},nf);export{Ss as n,zt as r,Ts as t};