prreviewbuddy 0.87.2 → 0.88.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 +1 @@
1
- import{a as e,c as t,f as n,l as r,lt as i,m as a,p as o,s,t as c,vt as l}from"./chunk-CMC5F4_t.js";import{t as u}from"./chunk-C8kkSv38.js";var d=5e3;function f(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i).length+1;n.length>0&&r+e>4e3&&(t.push(n),n=[],r=0),n.push(i),r+=e}return n.length>0&&t.push(n),t}var p=`Unread. `;function m(e,t){if(e.dataset.rowState===t||t===`unread`)return;e.dataset.rowState=t,e.dataset.read=`true`;let r=e.querySelector(`.prb-notification-open`),i=r?.getAttribute(`aria-label`)??``;if(i.startsWith(p)&&(i=i.slice(8)),t===`moved-again`||t===`caught-up`){let r=n(t);i=`${i}, ${r}`;let a=e.querySelector(`.prb-notification-meta`);if(a&&!a.querySelector(`[data-notification-replaced]`)){let t=e.ownerDocument.createElement(`span`);t.className=`prb-notification-replaced`,t.dataset.notificationReplaced=``,t.textContent=` · ${r}`,a.append(t)}}r?.setAttribute(`aria-label`,i)}function h(e,t){let n=e.querySelector(`[data-notifications-count]`);n&&(n.textContent=o(t));let i=e.querySelector(`[data-notifications-read-all]`);i&&(i.disabled=t===0),r(e,t)}function g(e,t){let n=Number(e.dataset.createdAt),r=Number(t.dataset.createdAt);return n>r||n===r&&(e.dataset.notificationId??``)<(t.dataset.notificationId??``)}function _(e,t){let n=[...e.querySelectorAll(`[data-notification-id]`)].find(e=>g(t,e));n?n.before(t):e.append(t)}function v(e,t){let n=new Set([...e.querySelectorAll(`[data-notification-id]`)].map(e=>e.dataset.notificationId));return Object.keys(t).filter(e=>!n.has(e))}function y(e,n,r=()=>{}){let i=Array.isArray(n.rows)?n.rows.filter(e=>typeof e==`string`):[],a=e.querySelector(`[data-notifications]`);if(i.length>0&&!a)return!1;let o=!1;if(a){for(let t of i){let n=e.createElement(`template`);n.innerHTML=t.trim();let r=n.content.firstElementChild,i=r?.dataset.notificationId;!r||!i||[...a.querySelectorAll(`[data-notification-id]`)].some(e=>e.dataset.notificationId===i)||(_(a,r),o=!0)}o&&r()}let s=n.states&&typeof n.states==`object`?n.states:{};for(let t of e.querySelectorAll(`[data-notification-id]`)){let e=s[t.dataset.notificationId??``];e&&m(t,e)}return typeof n.unread==`number`&&h(e,n.unread),t(e,n.running),!0}function b(e=document,t=window,n=e=>t.fetch(`/notifications/live${e.length>0?`?ids=${e.map(encodeURIComponent).join(`,`)}`:``}`),r=()=>{}){if(!e.querySelector(`[data-notifications], [data-notifications-empty]`))return;let i,a=!1,o=()=>e.visibilityState===`visible`,s=async e=>{let t=await n(e);return t.ok?await t.json():null},c=async()=>{if(!(a||!o())){a=!0;try{let n=await s([]);if(n){if(!y(e,{...n,rows:[]},r)){t.location.reload();return}let i=n.states?v(e,n.states):[];for(let n of f(i)){let i=null;try{i=await s(n)}catch{continue}if(i&&!y(e,i,r)){t.location.reload();return}}}}catch{}finally{a=!1}t.clearTimeout(i),i=t.setTimeout(()=>void c(),d)}};e.addEventListener(`visibilitychange`,()=>{o()&&(t.clearTimeout(i),c())}),i=t.setTimeout(()=>void c(),d)}function x(e,t,n){let r=[...e.querySelectorAll(`[data-notification-id]`)];r.forEach((e,t)=>{e.hidden=t>=n}),t&&(t.hidden=r.length<=n)}function S(e){let t=e.querySelector(`[data-notifications-more]`),n=15;return x(e,t,n),t?.addEventListener(`click`,()=>{n+=15,x(e,t,n)}),{refresh:()=>x(e,e.querySelector(`[data-notifications-more]`),n)}}i(),c(`/restart`);var C=S(document),w=u({doc:document,item:`[data-notification-id]`,link:`a.prb-notification-open`,walk:()=>[...document.querySelectorAll(`[data-notification-id]:not([hidden])`)].filter(e=>e.querySelector(`a.prb-notification-open`)),background:()=>document.querySelector(`.prb-shell > main`)});a(`notifications`,{"notifications.next":{run:()=>w.move(1)},"notifications.previous":{run:()=>w.move(-1)},"notifications.open":{available:()=>w.enterOpens(),run:()=>w.open()},"notifications.openInNewTab":{available:()=>w.enterOpens(),run:()=>w.openInNewTab()}});var T=document.querySelector(`[data-notifications-read-all]`);async function E(){try{let e=await fetch(`/notifications`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`read-all`})}),t=await e.json().catch(()=>null);return e.ok&&typeof t?.unread==`number`?t.unread:typeof t?.error==`string`?t.error:`Nothing was marked read. The workspace server refused it.`}catch{return`Nothing was marked read. The workspace server did not answer. It may have stopped.`}}T?.addEventListener(`click`,()=>{T.disabled=!0,E().then(t=>{if(typeof t==`string`){T.disabled=!1,e(s(),{kind:`failed`,text:t});return}document.querySelectorAll(`[data-notification-id][data-row-state="unread"]`).forEach(e=>m(e,`seen`)),h(document,t)})}),b(document,window,void 0,()=>C.refresh()),l(window,()=>window.location.reload());
1
+ import{a as e,c as t,f as n,ft as r,l as i,m as a,p as o,s,t as c,xt as l}from"./chunk-DRtin0n-.js";import{t as u}from"./chunk-C8kkSv38.js";var d=5e3;function f(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i).length+1;n.length>0&&r+e>4e3&&(t.push(n),n=[],r=0),n.push(i),r+=e}return n.length>0&&t.push(n),t}var p=`Unread. `;function m(e,t){if(e.dataset.rowState===t||t===`unread`)return;e.dataset.rowState=t,e.dataset.read=`true`;let r=e.querySelector(`.prb-notification-open`),i=r?.getAttribute(`aria-label`)??``;if(i.startsWith(p)&&(i=i.slice(8)),t===`moved-again`||t===`caught-up`){let r=n(t);i=`${i}, ${r}`;let a=e.querySelector(`.prb-notification-meta`);if(a&&!a.querySelector(`[data-notification-replaced]`)){let t=e.ownerDocument.createElement(`span`);t.className=`prb-notification-replaced`,t.dataset.notificationReplaced=``,t.textContent=` · ${r}`,a.append(t)}}r?.setAttribute(`aria-label`,i)}function h(e,t){let n=e.querySelector(`[data-notifications-count]`);n&&(n.textContent=o(t));let r=e.querySelector(`[data-notifications-read-all]`);r&&(r.disabled=t===0),i(e,t)}function g(e,t){let n=Number(e.dataset.createdAt),r=Number(t.dataset.createdAt);return n>r||n===r&&(e.dataset.notificationId??``)<(t.dataset.notificationId??``)}function _(e,t){let n=[...e.querySelectorAll(`[data-notification-id]`)].find(e=>g(t,e));n?n.before(t):e.append(t)}function v(e,t){let n=new Set([...e.querySelectorAll(`[data-notification-id]`)].map(e=>e.dataset.notificationId));return Object.keys(t).filter(e=>!n.has(e))}function y(e,n,r=()=>{}){let i=Array.isArray(n.rows)?n.rows.filter(e=>typeof e==`string`):[],a=e.querySelector(`[data-notifications]`);if(i.length>0&&!a)return!1;let o=!1;if(a){for(let t of i){let n=e.createElement(`template`);n.innerHTML=t.trim();let r=n.content.firstElementChild,i=r?.dataset.notificationId;!r||!i||[...a.querySelectorAll(`[data-notification-id]`)].some(e=>e.dataset.notificationId===i)||(_(a,r),o=!0)}o&&r()}let s=n.states&&typeof n.states==`object`?n.states:{};for(let t of e.querySelectorAll(`[data-notification-id]`)){let e=s[t.dataset.notificationId??``];e&&m(t,e)}return typeof n.unread==`number`&&h(e,n.unread),t(e,n.running),!0}function b(e=document,t=window,n=e=>t.fetch(`/notifications/live${e.length>0?`?ids=${e.map(encodeURIComponent).join(`,`)}`:``}`),r=()=>{}){if(!e.querySelector(`[data-notifications], [data-notifications-empty]`))return;let i,a=!1,o=()=>e.visibilityState===`visible`,s=async e=>{let t=await n(e);return t.ok?await t.json():null},c=async()=>{if(!(a||!o())){a=!0;try{let n=await s([]);if(n){if(!y(e,{...n,rows:[]},r)){t.location.reload();return}let i=n.states?v(e,n.states):[];for(let n of f(i)){let i=null;try{i=await s(n)}catch{continue}if(i&&!y(e,i,r)){t.location.reload();return}}}}catch{}finally{a=!1}t.clearTimeout(i),i=t.setTimeout(()=>void c(),d)}};e.addEventListener(`visibilitychange`,()=>{o()&&(t.clearTimeout(i),c())}),i=t.setTimeout(()=>void c(),d)}function x(e,t,n){let r=[...e.querySelectorAll(`[data-notification-id]`)];r.forEach((e,t)=>{e.hidden=t>=n}),t&&(t.hidden=r.length<=n)}function S(e){let t=e.querySelector(`[data-notifications-more]`),n=15;return x(e,t,n),t?.addEventListener(`click`,()=>{n+=15,x(e,t,n)}),{refresh:()=>x(e,e.querySelector(`[data-notifications-more]`),n)}}r(),c(`/restart`);var C=S(document),w=u({doc:document,item:`[data-notification-id]`,link:`a.prb-notification-open`,walk:()=>[...document.querySelectorAll(`[data-notification-id]:not([hidden])`)].filter(e=>e.querySelector(`a.prb-notification-open`)),background:()=>document.querySelector(`.prb-shell > main`)});a(`notifications`,{"notifications.next":{run:()=>w.move(1)},"notifications.previous":{run:()=>w.move(-1)},"notifications.open":{available:()=>w.enterOpens(),run:()=>w.open()},"notifications.openInNewTab":{available:()=>w.enterOpens(),run:()=>w.openInNewTab()}});var T=document.querySelector(`[data-notifications-read-all]`);async function E(){try{let e=await fetch(`/notifications`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`read-all`})}),t=await e.json().catch(()=>null);return e.ok&&typeof t?.unread==`number`?t.unread:typeof t?.error==`string`?t.error:`Nothing was marked read. The workspace server refused it.`}catch{return`Nothing was marked read. The workspace server did not answer. It may have stopped.`}}T?.addEventListener(`click`,()=>{T.disabled=!0,E().then(t=>{if(typeof t==`string`){T.disabled=!1,e(s(),{kind:`failed`,text:t});return}document.querySelectorAll(`[data-notification-id][data-row-state="unread"]`).forEach(e=>m(e,`seen`)),h(document,t)})}),b(document,window,void 0,()=>C.refresh()),l(window,()=>window.location.reload());
package/static/reviews.js CHANGED
@@ -1 +1 @@
1
- import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as ee,J as te,K as ne,L as re,M as ie,N as ae,O as oe,P as se,Q as ce,R as l,S as u,T as le,U as ue,V as de,W as fe,X as pe,Y as me,Z as he,a as ge,at as _e,et as ve,g as ye,gt as be,h as xe,i as Se,j as Ce,k as we,lt as Te,m as Ee,mt as De,n as Oe,nt as ke,o as Ae,pt as je,r as Me,rt as Ne,s as Pe,st as Fe,t as Ie,tt as Le,u as Re,ut as ze,vt as Be,w as Ve,x as He,z as Ue}from"./chunk-CMC5F4_t.js";import{a as We,c as Ge,i as Ke,n as qe,r as Je,s as Ye,t as Xe,u as Ze,x as Qe}from"./chunk-BmIk8Mrb.js";import{n as $e,t as et}from"./chunk-DDm8oQLU.js";import{t as tt}from"./chunk-C8kkSv38.js";import{n as nt,r as rt}from"./chunk-BKBTVY9X.js";function it(e,t){t.forEach((t,n)=>{e.children[n]!==t&&e.insertBefore(t,e.children[n]??null)})}async function at(e,t,n){if(e.disabled)return;let r=e.getAttribute(`aria-pressed`)!==`true`;ot(e,r),e.disabled=!0;let i=await t(r).catch(()=>!1);if(e.disabled=!1,!i)return ot(e,!r);n(r)}function ot(e,t){e.setAttribute(`aria-pressed`,String(t)),e.innerHTML=t?`&#9733;`:`&#9734;`,e.setAttribute(`aria-label`,`${t?`Unpin`:`Pin`} this review`)}function st(e){let t=e.querySelector(`[data-collections-registry]`)?.textContent??`[]`;try{let e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>!!e&&typeof e.id==`string`&&typeof e.name==`string`):[]}catch{return[]}}function ct(e){return(e.dataset.collections??``).split(` `).filter(Boolean)}async function lt(e,t,n){try{let r=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...t,snapshot:n})}),i=await r.json().catch(()=>null);return r.ok&&i&&(typeof i.area==`string`||i.stale===!0)?{ok:!0,answer:i}:{ok:!1,error:i?.error??`That could not be saved. The workspace server refused it.`}}catch{return{ok:!1,error:`The workspace server did not answer. It may have stopped.`}}}var ut=`prb-reviews-selection`;function dt(e,t){let n=new Set(e);return t.filter(e=>(e.dataset.lineage??e.dataset.id??``).split(` `).some(e=>n.has(e))).map(e=>e.dataset.id??``).filter(Boolean)}function ft(e,t){return t===``||e.name.toLowerCase().includes(t.trim().toLowerCase())}function pt(e,t){let n=e.trim().replace(/\s+/g,` `);if(n!==``)return t.some(e=>e.name.localeCompare(n,void 0,{sensitivity:`base`})===0)?void 0:n}function mt(e,t,n,r){let i=e.ownerDocument,a=(e,t)=>{let r=i.createElement(`label`);r.className=`prb-collections-option`;let a=i.createElement(`input`);return a.type=`checkbox`,a.value=e,a.checked=n.includes(e),a.setAttribute(`data-collections-filter-option`,``),r.append(a,i.createTextNode(` ${t}`)),r},o=t.filter(e=>ft(e,r)).map(e=>a(e.id,e.name));ft({id:`none`,name:`Uncollected`},r)&&o.unshift(a(Ve,`Uncollected`)),e.replaceChildren(...o)}function ht(e,t,n,r){let i=e.ownerDocument,a=t.filter(e=>ft(e,r)).map(e=>{let t=fe(n,e.id),r=i.createElement(`label`);r.className=`prb-collections-option`;let a=i.createElement(`input`);a.type=`checkbox`,a.value=e.id,a.checked=t===`all`,a.indeterminate=t===`some`,a.dataset.membership=t,a.setAttribute(`data-collections-dialog-option`,``);let o=i.createElement(`span`);if(o.textContent=e.name,r.append(a,o),t===`some`){let t=i.createElement(`span`);t.className=`prb-collections-some`,t.textContent=`${n.filter(t=>t.includes(e.id)).length} of ${n.length}`,r.append(t)}return r});if(a.length===0&&t.length===0){let e=i.createElement(`p`);e.className=`prb-collections-none`,e.textContent=`No collections yet. Type a name to make one.`,a.push(e)}e.replaceChildren(...a)}function gt(e,t){return t?`For ${t}. Tick a collection to add it, untick to remove it.`:e===1?`For 1 selected review. Tick a collection to add it, untick to remove it.`:`For ${e} selected reviews. A part-filled box adds the rest; it never removes anything.`}function _t(e){return{title:`Expand or collapse a collection`,mount(t,n){let r=t.ownerDocument,i=r.createElement(`div`);i.className=`prb-palette-results`,i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,`Collections`);let a=e.collections().map((e,t)=>{let n=r.createElement(`button`);n.type=`button`,n.className=`prb-palette-result prb-palette-collection`,n.dataset.collectionChoice=e.id;let i=r.createElement(`kbd`);i.className=`prb-kbd prb-palette-num`;let a=Ge(t);a?i.textContent=a:i.setAttribute(`aria-hidden`,`true`);let o=r.createElement(`span`);o.className=`prb-palette-result-title`,o.textContent=e.name;let s=r.createElement(`span`);s.className=`prb-palette-collection-count`,s.textContent=e.count;let c=r.createElement(`span`);return c.className=`prb-palette-state`,c.textContent=e.open?`Expanded`:`Collapsed`,n.append(i,o,s,c),n});i.replaceChildren(...a);let o=t=>{t&&(n(),e.toggle(t))};i.addEventListener(`click`,e=>{o(e.target.closest(`[data-collection-choice]`)?.dataset.collectionChoice)}),t.addEventListener(`keydown`,e=>{if(e.isComposing||e.metaKey||e.ctrlKey||e.altKey)return;let t=Ye(e.key);if(t!==null)return e.preventDefault(),o(a[t]?.dataset.collectionChoice);let n=a.indexOf(e.target),r=e.key===`ArrowDown`||e.key===`j`?a[Math.min(n+1,a.length-1)]:e.key===`ArrowUp`||e.key===`k`?a[Math.max(n-1,0)]:e.key===`Home`?a[0]:e.key===`End`?a[a.length-1]:void 0;r&&(e.preventDefault(),r.focus())}),t.append(i),a[0]?.focus()}}}function vt(e){let t=e.dataset.id??``,n=e.dataset.placement;return n===void 0||n===`home`?t:`${t}|${n}`}function yt(e,t){let n=e.parentElement?.querySelector(`[data-history-list]`);n&&(n.hidden=!t,e.setAttribute(`aria-expanded`,String(t)))}function bt(e,t,n,r,i=new Map){return{limits:n,...i.size===0?{}:{collectionLimits:Object.fromEntries(i)},expanded:t.filter(e=>e.dataset.id&&e.querySelector(`[data-history-list]:not([hidden])`)).map(vt),main:r?.scrollTop??0,...ze(e)}}function xt(e,t){let n=e?.limits;if(!n||typeof n!=`object`)return t;let r={...t};for(let e of u){let t=n[e];typeof t==`number`&&Number.isInteger(t)&&t>r[e]&&(r[e]=t)}return r}function St(e){let t=e?.collectionLimits,r=new Map;if(!t||typeof t!=`object`||Array.isArray(t))return r;for(let[e,i]of Object.entries(t))e.startsWith(`collection`)&&n(e)&&typeof i==`number`&&Number.isInteger(i)&&i>15&&r.set(e,i);return r}function Ct(e,t,n){if(!t)return;n.reveal(xt(t,n.limits),St(t));let r=new Set(be(t,`expanded`));for(let e of n.cards){let t=e.querySelector(`[data-history-toggle]`);t&&r.has(vt(e))&&yt(t,!0)}let i=je(t,`main`);n.pane&&i!==null&&(n.pane.scrollTop=i),De(e,t.focus,t.focusVisible)}var wt=Te({ownsRestore:!0});Ie(`/restart`);var d=[...document.querySelectorAll(`[data-card][data-placement="home"]`)].sort((e,t)=>Number(e.dataset.rank)-Number(t.dataset.rank)),f=new Map;function Tt(){f=new Map;for(let e of document.querySelectorAll(`[data-card]`)){let t=e.dataset.id??``;f.set(t,[...f.get(t)??[],e])}}Tt();function Et(e,t){for(let n of f.get(e)??[])t(n)}function p(){return[...f.values()].flat()}var m=st(document),Dt=[...document.querySelectorAll(`[data-operation]`)],Ot=document.querySelector(`[data-section="in-progress"]`),kt=e=>e.dataset.inProgressOnly!==void 0,At=Object.fromEntries(u.map(e=>[e,document.querySelector(`[data-cards="${e}"]`)])),jt=document.querySelector(`.prb-index`);function Mt(e){return{id:e.dataset.id??``,collections:ct(e),queue:e.dataset.queue===void 0?void 0:Number(e.dataset.queue),status:e.dataset.status??`new`,prState:e.dataset.prState}}var h=document.querySelector(`[data-search]`),g=document.querySelector(`[data-status-filter]`),_=document.querySelector(`[data-author-filter]`),v=document.querySelector(`[data-pr-filter]`),Nt=document.querySelector(`[data-no-matches]`),y=document.querySelector(`[data-count]`),Pt=document.querySelector(`[data-clear-filters]`),b=document.querySelector(`[data-collections-filter]`),Ft=document.querySelector(`[data-collections-filter-search]`);function It(){if(!b)return;b.hidden=m.length===0;let e=b.querySelector(`[data-collections-filter-label]`);e&&(e.textContent=we(E.collections,m)),E.collections.length===0?delete b.dataset.active:b.dataset.active=``;let t=b.querySelector(`[data-collections-filter-options]`);t&&mt(t,m,E.collections,Ft?.value??``)}var x=l();function Lt(e){return{stored:Fe({state:e.dataset.lifecycle,at:Number(e.dataset.lifecycleAt)}),activity:ke(e.dataset)??{at:0,kind:`created`}}}function Rt(e){return e.dataset.pinned===`true`}function zt(e){let{stored:t,activity:n}=Lt(e);return re(Rt(e),t,n,ct(e).length>0,E.filter)}function Bt(e){let t=zt(e);return t===void 0?.5:u.indexOf(t)}function Vt(e){return[...e].sort((e,t)=>Bt(e)-Bt(t))}var S=new Map,C=document.querySelector(`[data-bulk]`),Ht=document.querySelector(`[data-bulk-count]`),Ut=document.querySelector(`[data-bulk-detail]`),Wt=document.querySelector(`[data-bulk-delete]`),Gt=document.querySelector(`[data-bulk-delete-label]`),Kt=document.querySelector(`[data-bulk-exit]`),qt=document.querySelector(`[data-bulk-more]`),Jt=document.querySelector(`[data-bulk-question]`),w=document.querySelector(`[data-bulk-confirm]`),Yt=document.querySelector(`[data-bulk-actions]`),T=document.querySelector(`[data-bulk-error]`),Xt=document.querySelector(`[data-bulk-select-all]`),E=ne(window.location.hash),D=new Set,O=!1,k=document.querySelector(`[data-bulk-fetch]`),Zt={},A=[],Qt=!1;function j(){let e=E.query.trim().toLowerCase();E.author!==``&&![..._?.options??[]].some(e=>e.value===E.author)&&(E.author=``),E.collections=E.collections.filter(e=>e===`none`||m.some(t=>t.id===e)),m.length===0&&(E.collections=[]);let t=Vt(o(d.map(e=>({...Mt(e),searchText:e.dataset.searchText??``,author:e.dataset.author,card:e})),{...E,query:e}).map(e=>e.card)),n=t.filter(e=>!kt(e));A=n;let r=new Set(o(Dt.map(e=>({...Mt(e),searchText:e.dataset.searchText??``,author:e.dataset.author,entry:e})),{...E,query:e}).map(e=>e.entry));for(let e of Dt)e.hidden=!r.has(e);if(Ot){Ot.hidden=r.size===0;let e=Ot.querySelector(`[data-section-count]`);e&&(e.textContent=String(r.size))}let i=n.filter(e=>zt(e)!==void 0),a=he(i,e=>zt(e),x),s=new Set(u.flatMap(e=>a[e].shown));for(let e of u){let t=At[e];t&&it(t,a[e].shown);let n=document.querySelector(`[data-load-more="${e}"]`);n&&(n.hidden=a[e].total<=a[e].shown.length);let r=document.querySelector(`[data-section="${e}"]`);r&&(r.hidden=a[e].total===0);let i=r?.querySelector(`[data-section-count]`);i&&(i.textContent=String(a[e].total))}for(let e of $t(n))s.add(e);for(let e of p())e.hidden=!s.has(e);if(h&&h.value!==E.query&&(h.value=E.query),_&&(_.value=E.author,E.author===``?delete _.dataset.active:_.dataset.active=``),v||(E.pr=`any`),v&&(v.value=E.pr,E.pr===`any`?delete v.dataset.active:v.dataset.active=``),g&&(g.value=E.filter,E.filter===`all`?delete g.dataset.active:g.dataset.active=``),It(),Pt&&(Pt.hidden=!Ue(E)),y){let e=e=>e.reduce((e,t)=>e+Number(t.dataset.reviews??1),0);y.textContent=ie(e(t),t.length,Ue(E)?e(d):void 0)}Nt&&(Nt.hidden=t.length>0||r.size>0||d.length===0),hn(n)}function $t(e){let t=document.querySelector(`[data-collections-area]`);if(!t)return[];let n=s(E.filter),r=Ue(E),o=e.flatMap(e=>ct(e).map(t=>({card:e,collection:t}))),c=e=>{let{stored:t,activity:n}=Lt(e);return oe(Rt(e),t,n,E.filter)},ee=de(o,({card:e,collection:t})=>{let n=c(e);return n===void 0?void 0:`${n===`completed`?`collection-done`:`collection`}:${t}`},e=>S.get(e)??15),te=(e,t)=>(f.get(e)??[]).find(e=>e.dataset.placement===`collection:${t}`),ne=[],re=!1;for(let e of t.querySelectorAll(`[data-collection]`)){let t=e.dataset.collection??``,s=ee.get(`collection:${t}`)??{shown:[],total:0},c=ee.get(`collection-done:${t}`)??{shown:[],total:0},ie=o.filter(e=>e.collection===t),ae=ie.filter(e=>Rt(e.card)).length,oe=E.collections.length>0&&!E.collections.includes(t),se=!n&&!oe&&(!r||ie.length>0);if(e.hidden=!se,!se)continue;re=!0;for(let[n,r]of[[`collection:${t}`,s],[`collection-done:${t}`,c]]){let i=r.shown.map(e=>te(e.card.dataset.id??``,t)).filter(e=>e!==void 0),a=e.querySelector(`[data-cards="${n}"]`);a&&it(a,i),ne.push(...i);let o=e.querySelector(`[data-load-more="${n}"]`);o&&(o.hidden=r.total<=r.shown.length)}let ce=e.querySelector(`[data-section="collection:${t}"] > summary [data-section-count]`);ce&&(ce.textContent=a(s.total,ae));let l=e.querySelector(`[data-collection-empty]`),u=i({active:s.total,completed:c.total,pinned:ae,members:ie.length},r);l&&(l.hidden=u===void 0,l.textContent=u??``);let le=e.querySelector(`[data-section="collection-done:${t}"]`);le&&(le.hidden=c.total===0);let ue=e.querySelector(`[data-completed-label]`);ue&&(ue.textContent=Ce(c.total))}return t.hidden=n||!re,ne}var en=300,M=null;function N(){M!==null&&window.clearTimeout(M),M=null,wt.replace(ee(E),{})}function P(e,t){if(E={...E,...e},x=l(),S=new Map,j(),t===`now`)return N();M!==null&&window.clearTimeout(M),M=window.setTimeout(N,en)}window.addEventListener(`pagehide`,()=>{M!==null&&N()}),document.addEventListener(`click`,e=>{M!==null&&e.target?.closest?.(`a[href]`)&&N()},!0),h?.addEventListener(`input`,()=>P({query:h.value},`settled`)),h?.addEventListener(`keydown`,e=>{e.key===`Escape`&&h.value!==``&&(e.preventDefault(),P({query:``},`now`))}),g?.addEventListener(`change`,()=>{P({filter:g.value},`now`)}),_?.addEventListener(`change`,()=>{P({author:_.value},`now`)}),v?.addEventListener(`change`,()=>{P({pr:v.value},`now`)}),Pt?.addEventListener(`click`,()=>{P({query:He.query,filter:He.filter,author:He.author,pr:He.pr,collections:He.collections},`now`),h?.focus()}),rt(),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-load-more]`)?.dataset.loadMore;if(t&&t.startsWith(`collection`)&&n(t))return S.set(t,(S.get(t)??15)+15),j();!t||!u.includes(t)||(x={...x,[t]:x[t]+15},j())});for(let e of[`popstate`,`hashchange`])window.addEventListener(e,()=>{E=ne(window.location.hash),x=l(),S=new Map,j(),cn()});document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-pin]`);if(!t?.dataset.pin)return;e.preventDefault(),e.stopPropagation();let n=t.dataset.pin;at(t,e=>fetch(`/pin`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:n,pinned:e})}).then(e=>e.ok),e=>{Et(n,n=>{n.dataset.pinned=String(e);let r=n.querySelector(`[data-pin]`);r&&r!==t&&ot(r,e),Pn(n)}),j()})});async function tn(e,t){let n;try{let r=await fetch(`/queue`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:e,action:t})});if(!r.ok)return F(await an(r));n=(await r.json()).queue}catch{return F(rn)}on(n),j()}var nn=`That could not be saved. The workspace server refused it.`,rn=`The workspace server did not answer. It may have stopped.`;function F(e){ge(Pe(),{kind:`failed`,text:e})}async function an(e){let t=await e.json().catch(()=>null);return typeof t?.error==`string`?t.error:nn}function on(e){let t=new Map(e.map((e,t)=>[e,t]));for(let e of p()){let n=t.get(e.dataset.id??``);n===void 0?delete e.dataset.queue:e.dataset.queue=String(n),n!==void 0&&e.dataset.lifecycle!==`active`&&(e.dataset.lifecycle=`active`,delete e.dataset.lifecycleAt,Pn(e))}for(let e of document.querySelectorAll(`[data-queue-action][data-queue-id]`)){let n=t.has(e.dataset.queueId??``);e.dataset.queueAction=n?`remove`:`add`,e.textContent=te(n)}let n=document.querySelector(`[data-queue-option]`);n&&(n.textContent=me(e.length))}document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-history-toggle]`);if(!t)return;e.preventDefault(),e.stopPropagation();let n=t.parentElement?.querySelector(`[data-history-list]`);n&&yt(t,n.hidden!==!1)});var sn=document.querySelector(`.prb-shell > main`);function cn(){Ct(document,wt.current().ui,{cards:p(),pane:sn,limits:x,reveal:(e,t)=>{x=e,S=t,j()}})}wt.setCapturer(()=>bt(document,p(),x,sn,S)),j(),cn();var I=$e(document,{onOpen:fn,onClose:e=>{fn(e),window.setTimeout($,0)}});function ln(){return document.querySelector(`[data-menu-trigger][aria-expanded="true"]`)!==null}var un=0;async function dn(e){un+=1;try{await e()}finally{--un,$()}}function fn(e){let t=e.querySelector(`[data-menu-items]`),n=e.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!1),n&&(n.hidden=!0);let r=e.querySelector(`[data-collection-rename-form]`);r&&(r.hidden=!0,J(r,void 0)),e.querySelector(`[data-menu-error]`)?.remove(),e.querySelector(`[data-id-field]`)?.remove()}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-menu]`);if(!n||n.closest(`[data-bulk]`)||n.matches(`[data-collections-filter]`))return;if(n.matches(`.prb-collection-menu`))return Zn(e,t,n);let r=t.closest(`[data-collections-for]`);if(r?.dataset.collectionsFor){e.preventDefault(),e.stopPropagation(),I.closeAll();let t=r.closest(`[data-card]`)?.querySelector(`[data-select]`)?.getAttribute(`aria-label`)?.replace(/^Select /,``);Qn([r.dataset.collectionsFor],{card:t??`this review`});return}let i=t.closest(`[data-copy-id]`);if(i?.dataset.copyId){e.preventDefault(),e.stopPropagation(),Qe(i,i.dataset.copyId);return}let a=t.closest(`[data-fetch-review]`);if(a?.dataset.fetchReview){e.preventDefault(),e.stopPropagation(),I.closeAll();let t=a.closest(`[data-card]`);t&&sr([t]);return}let o=t.closest(`[data-mark-status]`);if(o?.dataset.markId){e.preventDefault(),e.stopPropagation(),I.closeAll();let t=o.dataset.markId;dn(()=>Mn(t,o.dataset.markStatus===`complete`));return}let s=t.closest(`[data-lifecycle-set]`);if(s?.dataset.lifecycleId){e.preventDefault(),e.stopPropagation(),I.closeAll();let t=s.dataset.lifecycleId;dn(async()=>{await Nn([t],s.dataset.lifecycleSet)||F(`That could not be saved. The workspace server refused it or did not answer.`)});return}let c=t.closest(`[data-queue-action]`);if(c?.dataset.queueId){e.preventDefault(),e.stopPropagation(),I.closeAll();let t=c.dataset.queueId;dn(()=>tn(t,c.dataset.queueAction===`remove`?`remove`:`add`));return}if(t.closest(`[data-delete]`)){e.preventDefault(),e.stopPropagation();let t=n.querySelector(`[data-menu-items]`),r=n.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!0),r&&(r.hidden=!1),e.detail===0&&n.querySelector(`[data-cancel-delete]`)?.focus();return}if(t.closest(`[data-cancel-delete]`)){e.preventDefault(),e.stopPropagation(),fn(n),e.detail===0&&n.querySelector(`[data-delete]`)?.focus();return}if(t.closest(`[data-confirm-delete]`)){e.preventDefault(),e.stopPropagation(),pn(n);return}e.preventDefault(),e.stopPropagation()});async function pn(e){let t=e.querySelector(`[data-delete]`),n=t?.dataset.delete;if(!n)return;let r=e.querySelector(`[data-menu-confirm]`),i=e.querySelector(`[data-confirm-delete]`);i&&(i.disabled=!0,i.textContent=`Deleting`);try{let r=await fetch(`/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:n,scope:t?.dataset.scope??`review`})});if(r.ok)return void window.location.reload();mn(e,(await r.json().catch(()=>null))?.error??`That could not be deleted.`)}catch{mn(e,`The workspace server did not answer. It may have stopped.`)}i&&(i.disabled=!1,i.textContent=`Delete`),r&&(r.hidden=!0);let a=e.querySelector(`[data-menu-items]`);a&&(a.hidden=!1)}function mn(e,t){e.querySelector(`[data-menu-error]`)?.remove();let n=document.createElement(`p`);n.className=`prb-menu-error`,n.setAttribute(`data-menu-error`,``),n.textContent=t,e.querySelector(`[data-menu-panel]`)?.append(n)}function L(e){O=e,e||D.clear(),jt&&(e?jt.dataset.selecting=``:delete jt.dataset.selecting),document.querySelector(`[data-select-mode]`)?.setAttribute(`aria-pressed`,String(e)),!e&&qt&&I.close(qt);for(let t of document.querySelectorAll(`.prb-card-link`))e?t.setAttribute(`aria-disabled`,`true`):t.removeAttribute(`aria-disabled`);R(),j()}function R(){w&&(w.hidden=!0),Yt&&(Yt.hidden=!1),T&&(T.hidden=!0,T.textContent=``)}function hn(t){for(let e of p()){let t=D.has(e.dataset.id??``),n=e.querySelector(`[data-select]`);n&&(n.checked=t),t?e.dataset.selected=``:delete e.dataset.selected}if(!C||(C.hidden=!O,!O))return;let n=new Set(p().filter(gn).map(e=>e.dataset.id)),r=[...D].filter(e=>!n.has(e)).length,i=new Set(t.map(e=>e.dataset.id)),a=[...D].every(e=>i.has(e))?i.size:null;D.size===0?C.dataset.empty=``:delete C.dataset.empty,Ht&&(Ht.textContent=ve(D.size)),Ut&&(Ut.textContent=e(D.size,a,r)),Xt&&(Xt.textContent=ce(t.length,D.size>0&&a!==null),Xt.disabled=t.every(e=>D.has(e.dataset.id??``))),Gt&&(Gt.textContent=ae(kn()));for(let e of C.querySelectorAll(`[data-bulk-mark], [data-bulk-lifecycle], [data-bulk-queue], [data-bulk-collections], [data-bulk-delete]`))e.disabled=D.size===0;k&&(k.hidden=!qe(Zt,rr(V())))}function gn(e){return!e.hidden&&e.closest(`details:not([open]), [hidden]`)===null}function _n(e){let t=[...e.querySelectorAll(`details[data-section]`)];for(let e of t)e.addEventListener(`toggle`,()=>hn(A));nt(t,(e,t)=>fetch(`/sections`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({section:e,collapsed:t})}))}_n(document),document.querySelector(`[data-select-mode]`)?.addEventListener(`click`,()=>{L(!O)}),Xt?.addEventListener(`click`,()=>{for(let e of A)e.dataset.id&&D.add(e.dataset.id);R(),j()});function vn(e){D.has(e)?D.delete(e):D.add(e),R(),j()}document.addEventListener(`change`,e=>{let t=e.target.closest(`[data-select]`);t?.dataset.select&&vn(t.dataset.select)}),document.addEventListener(`click`,e=>{if(!O)return;let t=e.target,n=t.closest(`[data-card]`);n?.dataset.id&&(t.closest(`[data-select], [data-pin], [data-menu], [data-history-toggle]`)||(e.preventDefault(),vn(n.dataset.id)))}),document.addEventListener(`keydown`,e=>{if(!O||e.key!==`Enter`)return;let t=e.target.closest(`.prb-card-link`)?.closest(`[data-card]`);t?.dataset.id&&(e.preventDefault(),vn(t.dataset.id))});var z=tt({doc:document,item:`[data-card]`,link:`.prb-card-link`,walk:()=>[...document.querySelectorAll(`[data-card]`)].filter(gn),enterAllowed:()=>!O,background:()=>sn,leadIn:e=>[...e.closest(`[data-cards]`)?.querySelectorAll(`[data-card]:not([hidden])`)??[]][0]===e?e.closest(`details[data-section]`)?.querySelector(`summary`)??null:null});function yn(){return z.holdsKeys()?z.current()?.querySelector(`:scope > [data-menu]`)??null:null}var bn=8;function xn(e){let t=e.querySelector(`.prb-card-link`);t&&(t.focus({preventScroll:!0}),document.activeElement!==t&&document.activeElement?.blur(),M!==null&&N(),wt.leaving(),Sn=!0,window.location.assign(t.href))}var Sn=!1,Cn={title:`Search reviews`,mount(e,t){let n=document.createElement(`input`);n.type=`search`,n.className=`prb-palette-input`,n.placeholder=h?.placeholder??``,n.setAttribute(`aria-label`,`Search reviews`),n.spellcheck=!1,n.value=h?.value??``;let r=document.createElement(`p`);r.className=`prb-palette-summary`,r.setAttribute(`aria-live`,`polite`);let i=document.createElement(`div`);i.className=`prb-palette-results`,i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,`Matching reviews`);let a=()=>{let e=A.slice(0,bn);i.replaceChildren(...e.map(e=>{let t=document.createElement(`button`);t.type=`button`,t.className=`prb-palette-result`,t.dataset.resultId=e.dataset.id??``;let n=document.createElement(`span`);n.className=`prb-palette-result-title`,n.textContent=e.querySelector(`.prb-card-head h2`)?.textContent??``;let r=document.createElement(`span`);return r.className=`prb-palette-result-where`,r.textContent=[e.querySelector(`.prb-card-repo`)?.textContent,e.querySelector(`.prb-card-branch`)?.textContent].filter(Boolean).join(` · `),t.append(n,r),t})),r.textContent=A.length===0?`No reviews match.`:A.length>e.length?`The first ${e.length} of ${y?.textContent??A.length}`:y?.textContent??``},o=()=>[...i.querySelectorAll(`.prb-palette-result`)],s=e=>{let n=d.find(t=>t.dataset.id===e?.dataset.resultId);n&&(t(),xn(n))};n.addEventListener(`input`,()=>{h&&(h.value=n.value,h.dispatchEvent(new Event(`input`,{bubbles:!0})),a())}),i.addEventListener(`click`,e=>s(e.target.closest(`.prb-palette-result`)??void 0)),e.addEventListener(`keydown`,e=>{if(e.isComposing)return;let t=o(),r=t.indexOf(e.target);if(e.key===`Enter`&&e.target===n)return e.preventDefault(),s(t[0]);let i=e.key===`ArrowDown`?r<0?t[0]:t[r+1]:e.key===`ArrowUp`?r<=0?n:t[r-1]:null;i&&(e.preventDefault(),i.focus())}),e.append(n,r,i),a(),n.focus(),n.select()}},wn={title:`Filters`,mount(e){let t=document.createElement(`p`);t.className=`prb-palette-summary`,t.setAttribute(`aria-live`,`polite`);let n=()=>{t.textContent=y?.textContent??``},r=[g,_,v].flatMap(e=>{if(!e)return[];let t=document.createElement(`label`);t.className=`prb-palette-field`;let r=document.createElement(`span`),i=(e.getAttribute(`aria-label`)??``).replace(/^Filter by /,``);r.textContent=i.charAt(0).toUpperCase()+i.slice(1);let a=document.createElement(`select`);for(let t of e.options)a.append(new Option(t.text,t.value));return a.value=e.value,a.addEventListener(`change`,()=>{e.value=a.value,e.dispatchEvent(new Event(`change`,{bubbles:!0})),n()}),t.append(r,a),[t]});e.append(...r,t),n(),r[0]?.querySelector(`select`)?.focus()}};function Tn(e){let t=()=>document.querySelector(`details[data-section="${e}"]`);return{available:()=>!!(t()&&!t().hidden),state:()=>{let e=t();return e&&!e.hidden?e.open?`Expanded`:`Collapsed`:null},run:()=>{let e=t();e&&(e.open=!e.open)}}}var En=Object.fromEntries(r.map(e=>[`reviews.section.${e}`,Tn(e)]));function Dn(){return[...document.querySelectorAll(`[data-collections-area]:not([hidden]) [data-collection]:not([hidden])`)].flatMap(e=>{let t=e.querySelector(`:scope > details[data-section]`);if(!t)return[];let n=t.querySelector(`[data-collection-name]`)?.textContent??``,r=t.querySelector(`:scope > summary [data-section-count]`)?.textContent??``;return[{id:e.dataset.collection??``,name:n,count:r,open:t.open}]})}var B=document.querySelector(`[data-collection-new]`),On=Ee(`reviews`,{...En,"reviews.search":{available:()=>h!==null,panel:Cn},"reviews.filters":{available:()=>g!==null,panel:wn},"reviews.collection.new":{available:()=>B!==null&&!B.disabled,run:()=>B?.click()},"reviews.collection.fold":{available:()=>Dn().length>0,panel:_t({collections:Dn,toggle:e=>{let t=document.querySelector(`[data-collection="${CSS.escape(e)}"] > details[data-section]`);t&&(t.open=!t.open)}})},"reviews.next":{run:()=>z.move(1)},"reviews.previous":{run:()=>z.move(-1)},"reviews.open":{available:()=>z.enterOpens(),run:()=>z.open()},"reviews.openInNewTab":{available:()=>z.enterOpens(),run:()=>z.openInNewTab()},"reviews.selection.exit":{available:Bn,run:()=>w&&!w.hidden?Rn(C?.contains(document.activeElement)??!1):zn()},"reviews.menu":{available:()=>yn()!==null,run:()=>{let e=yn();e&&I.open(e,{focusFirst:!0,returnFocus:()=>z.refocus()})}}},{onOpen:()=>I.closeAll(),onSettle:()=>$()});function V(){return Vt(d.filter(e=>D.has(e.dataset.id??``)))}function kn(){return V().reduce((e,t)=>e+Number(t.dataset.reviews??1),0)}function H(e){T&&(T.textContent=e,T.hidden=!1)}function U(e){for(let t of C?.querySelectorAll(`button`)??[])t.disabled=e}async function An(e){let t=[...D];if(t.length!==0){U(!0);try{if(!(await fetch(`/status`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:t,complete:e})})).ok)return U(!1),H(`That could not be saved. The workspace server refused it.`)}catch{return U(!1),H(`The workspace server did not answer. It may have stopped.`)}jn(V(),e),U(!1),L(!1)}}function jn(e,t){let n=t?`complete`:`in-progress`,r=t?`in-progress`:`complete`;for(let t of e.flatMap(e=>f.get(e.dataset.id??``)??[e])){t.dataset.status=n;let e=t.querySelector(`.prb-card-status`);e&&(e.dataset.status=n,e.textContent=Le(n));let i=t.querySelector(`[data-mark-status]`);i&&(i.dataset.markStatus=r,i.textContent=c(r))}}async function Mn(e,t){try{let n=await fetch(`/status`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:[e],complete:t})});if(!n.ok)return F(await an(n))}catch{return F(rn)}jn(d.filter(t=>t.dataset.id===e),t),j()}async function Nn(e,t){let n;try{let r=await fetch(`/lifecycle`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:e,state:t})});n=r.ok?await r.json().catch(()=>null):null}catch{n=null}if(!n)return!1;let r=new Set(e);for(let e of p())r.has(e.dataset.id??``)&&(e.dataset.lifecycle=t,t===`active`?delete e.dataset.lifecycleAt:e.dataset.lifecycleAt=String(n.at),Pn(e));return on(n.queue),j(),!0}function Pn(e){let{stored:t,activity:n}=Lt(e),r=e.querySelector(`[data-lifecycle-chip]`);if(r){let i=le(Rt(e),t,n);r.textContent=i??``,r.hidden=i===void 0}for(let r of e.querySelectorAll(`[data-lifecycle-set]`)){let e=r.dataset.lifecycleSet;r.hidden=!_e(e,t,n),r.textContent=Ne(e,t,n)}}async function Fn(e){let t=[...D];if(t.length===0)return;U(!0);let n=await Nn(t,e);if(U(!1),!n)return H(`That could not be saved. The workspace server refused it or did not answer.`);L(!1)}async function In(){let e=[...D];if(e.length===0)return;U(!0);let t=null;try{let n=await fetch(`/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:e})});if(t=n.ok?await n.json().catch(()=>null):null,!t)return U(!1),R(),H(`Nothing was deleted. The workspace server refused it.`)}catch{return U(!1),R(),H(`The workspace server did not answer. It may have stopped.`)}let n=t.blocked??[],r=new Set(n.map(e=>e.id));for(let e of V()){let t=e.dataset.id??``;r.has(t)||Et(t,e=>e.remove())}d=d.filter(e=>e.isConnected),Tt(),D.clear();for(let e of r)D.add(e);if(U(!1),R(),n.length===0)return L(!1);j(),H([...new Set(n.map(e=>e.error))].join(` `))}async function Ln(){let e=V().map(e=>e.dataset.id??``).filter(Boolean);if(e.length===0)return;U(!0);let t=null;try{let n=await fetch(`/queue`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:e,action:`add`})});t=n.ok?await n.json().catch(()=>null):null}catch{return U(!1),R(),H(`The workspace server did not answer. It may have stopped.`)}if(!t?.queue)return U(!1),R(),H(`Nothing was added. The workspace server refused it.`);on(t.queue);let n=t.refused??[];D.clear();for(let e of n)D.add(e.id);if(U(!1),R(),n.length===0)return L(!1);j(),H([...new Set(n.map(e=>e.error))].join(` `))}C?.addEventListener(`click`,e=>{let t=e.target;if(qt&&t.closest(`[data-bulk-more] [data-menu-panel] button`)&&I.close(qt),t.closest(`[data-bulk-queue]`))return void Ln();if(t.closest(`[data-bulk-collections]`))return Qn(V().map(e=>e.dataset.id??``).filter(Boolean),{selection:!0});let n=t.closest(`[data-bulk-mark]`);if(n)return void An(n.dataset.bulkMark===`complete`);let r=t.closest(`[data-bulk-lifecycle]`);if(r)return void Fn(r.dataset.bulkLifecycle);if(t.closest(`[data-bulk-delete]`)){Jt&&(Jt.textContent=se(kn())),Yt&&(Yt.hidden=!0),w&&(w.hidden=!1),e.detail===0&&C.querySelector(`[data-bulk-cancel-delete]`)?.focus();return}if(t.closest(`[data-bulk-confirm-delete]`))return void In();if(t.closest(`[data-bulk-cancel-delete]`))return Rn(e.detail===0);if(t.closest(`[data-bulk-exit]`))return zn()});function Rn(e){R(),e&&Wt?.focus()}function zn(){let e=C?.contains(document.activeElement)??!1;L(!1),e&&document.querySelector(`[data-select-mode]`)?.focus()}function Bn(e){return!O||Kt?.disabled?!1:e===void 0||Ze(e,document,!0)}var W=document.querySelector(`[data-collections-dialog]`),Vn=document.querySelector(`[data-collections-dialog-list]`),G=document.querySelector(`[data-collections-dialog-search]`),K=document.querySelector(`[data-collections-dialog-create]`),Hn=document.querySelector(`[data-collections-dialog-error]`),Un=document.querySelector(`[data-collections-dialog-for]`),q=[],Wn=!1,Gn=!1,Kn=document.body.dataset.cardsSnapshot??``;function qn(e,t){return lt(e,t,Kn)}function Jn(e){if(e.stale||e.area===void 0){try{let e={ids:[...D],selecting:O};window.sessionStorage.setItem(ut,JSON.stringify(e))}catch{}W?.close(),window.location.reload();return}let n=e.area,r=document.querySelector(`[data-collections-area]`);if(r){let e=r.contains(document.activeElement)?ze(document):null,t=document.createElement(`template`);t.innerHTML=n.trim();let i=t.content.firstElementChild;if(i){if(r.replaceWith(i),_n(i),O)for(let e of i.querySelectorAll(`.prb-card-link`))e.setAttribute(`aria-disabled`,`true`);e&&De(document,e.focus,e.focusVisible)}}m=e.collections;for(let n of d){let r=e.memberOf[n.dataset.id??``]??[];n.dataset.collections=r.join(` `);let i=n.querySelector(`[data-collections-line]`),a=t(r,m);i&&(i.textContent=a??``,i.hidden=a===void 0)}for(let t of Dt){let n=e.operations?.[t.dataset.key??``];n&&(t.dataset.collections=n.join(` `))}Tt(),ar(),j()}function J(e,t){let n=e.querySelector(`[data-collection-error]`);n&&(n.textContent=t??``,n.hidden=t===void 0)}Ft?.addEventListener(`input`,()=>It()),b?.addEventListener(`change`,e=>{let t=e.target.closest(`[data-collections-filter-option]`);if(!t)return;let n=t.checked?[...E.collections,t.value]:E.collections.filter(e=>e!==t.value);P({collections:[...new Set(n)]},`now`),b.querySelector(`[data-collections-filter-option][value="${CSS.escape(t.value)}"]`)?.focus()});var Y=document.querySelector(`[data-collection-new-dialog]`),X=Y?.querySelector(`[data-collection-name-input]`)??null,Yn=Y?.querySelector(`[data-collection-create]`)??null,Z=!1;function Xn(){B&&(B.disabled=Z),X&&(X.readOnly=Z),Yn&&(Yn.disabled=Z||(X?.value.trim()??``)===``)}B?.addEventListener(`click`,()=>{Y&&(I.closeAll(),X&&(X.value=``),Xn(),J(Y,void 0),Y.showModal(),X?.focus())}),X?.addEventListener(`input`,()=>{Xn(),Y&&J(Y,void 0)}),Y?.querySelector(`[data-collection-cancel]`)?.addEventListener(`click`,()=>Y.close()),Y?.addEventListener(`close`,()=>$()),document.addEventListener(`submit`,e=>{let t=e.target;if(t.matches(`[data-collection-new-form]`)){e.preventDefault();let n=X?.value??``;if(n.trim()===``)return;Z=!0,Xn(),qn(`/collections`,{action:`create`,name:n}).then(e=>{Z=!1,Xn();let n=Y?.open===!0;if(!e.ok)return J(t,e.error);Y?.close(),Jn(e.answer),n&&document.querySelector(`[data-collection="${CSS.escape(e.answer.id??``)}"] summary`)?.focus({focusVisible:!1})});return}let n=t.closest(`[data-collection-rename-form]`);if(n){e.preventDefault();let t=n.querySelector(`[data-collection-name-input]`)?.value??``,r=n.dataset.collectionRenameForm??``;qn(`/collections`,{action:`rename`,id:r,name:t}).then(e=>{if(!e.ok)return J(n,e.error);I.closeAll(),Jn(e.answer),document.querySelector(`[data-collection="${CSS.escape(r)}"] summary`)?.focus({focusVisible:!1})})}});function Zn(e,t,n){let r=n.querySelector(`[data-menu-items]`),i=n.querySelector(`[data-collection-rename-form]`),a=n.querySelector(`[data-menu-confirm]`);if(t.closest(`[data-collection-rename]`)&&i){e.preventDefault(),r&&(r.hidden=!0),i.hidden=!1;let t=i.querySelector(`[data-collection-name-input]`);t?.focus(),t?.select();return}if(t.closest(`[data-collection-delete]`)&&a){e.preventDefault(),r&&(r.hidden=!0),a.hidden=!1,e.detail===0&&n.querySelector(`[data-cancel-delete]`)?.focus();return}if(t.closest(`[data-collection-cancel], [data-cancel-delete]`)){e.preventDefault(),fn(n);return}let o=t.closest(`[data-collection-confirm-delete]`);if(o?.dataset.collectionConfirmDelete){e.preventDefault(),o.disabled=!0;let t=o.dataset.collectionConfirmDelete;qn(`/collections`,{action:`delete`,id:t}).then(e=>{if(o.disabled=!1,!e.ok)return mn(n,e.error);I.closeAll(),Jn(e.answer),E.collections.includes(t)&&N(),document.querySelector(`[data-collection-new]`)?.focus()})}}function Qn(e,t){!W||e.length===0||(I.closeAll(),q=[...e],Wn=!1,Gn=`selection`in t,Un&&(Un.textContent=gt(e.length,`card`in t?t.card:void 0)),G&&(G.value=``),er(void 0),Q(),W.showModal(),G?.focus())}function $n(){return q.map(e=>ct(d.find(t=>t.dataset.id===e)??document.createElement(`div`)))}function Q(){let e=G?.value??``;Vn&&ht(Vn,m,$n(),e);let t=pt(e,m);K&&(K.hidden=t===void 0,K.textContent=t===void 0?``:`Create “${t}” and add ${q.length===1?`this review`:`these ${q.length}`}`)}function er(e){Hn&&(Hn.textContent=e??``,Hn.hidden=e===void 0)}async function tr(e){er(void 0);let t=await qn(`/collections/members`,{ids:q,...e});if(!t.ok)return er(t.error),Q();Wn=!0,Jn(t.answer);let n=t.answer.refused??[];n.length>0&&(q=q.filter(e=>!n.some(t=>t.id===e)),er([...new Set(n.map(e=>e.error))].join(` `))),Q()}G?.addEventListener(`input`,()=>Q()),G?.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),K&&!K.hidden&&K.click())}),K?.addEventListener(`click`,()=>{let e=pt(G?.value??``,m);e!==void 0&&tr({action:`add`,create:e}).then(()=>{G&&(G.value=``),Q(),G?.focus()})}),Vn?.addEventListener(`change`,e=>{let t=e.target.closest(`[data-collections-dialog-option]`);if(!t)return;let n=ue(t.dataset.membership??`none`),r=t.value;tr({action:n,collection:r}).then(()=>{Vn.querySelector(`[data-collections-dialog-option][value="${CSS.escape(r)}"]`)?.focus()})}),document.querySelector(`[data-collections-dialog-close]`)?.addEventListener(`click`,()=>W?.close());try{let e=window.sessionStorage.getItem(ut);if(e){window.sessionStorage.removeItem(ut);let t=JSON.parse(e),n=Array.isArray(t.ids)?t.ids.filter(e=>typeof e==`string`):[];if(t.selecting===!0||n.length>0){L(!0);for(let e of dt(n,d))D.add(e);j()}}}catch{}W?.addEventListener(`close`,()=>{Wn&&O&&Gn&&L(!1),q=[],$()}),Be(window,()=>window.location.reload());var nr=`prb-fetch-summary`;function rr(e){return e.map(e=>({lineage:(e.dataset.lineage??e.dataset.id??``).split(` `).filter(Boolean)}))}function ir(e){return Je(rr(e),Zt)}function ar(){for(let e of p()){let t=e.querySelector(`[data-fetch-review]`);t&&(t.hidden=!qe(Zt,rr([e])))}}async function or(){try{let e=await fetch(`/fetch-updates`);if(!e.ok)return;Zt=(await e.json()).targets??{}}catch{return}ar(),j()}async function sr(e,t){let n=ir(e);if(Qt||n.repositories===0)return;Qt=!0;let r=[k,...document.querySelectorAll(`[data-fetch-review]`)];for(let e of r)e&&(e.disabled=!0);t&&(t.textContent=We(n.repositories));let i=null;try{let e=await fetch(`/fetch-updates`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:n.ids})});e.ok&&(i=await e.json())}catch{}Qt=!1;for(let e of r)e&&(e.disabled=!1);t&&(t.textContent=Xe),j();let a=i??{repositories:n.repositories,fetched:0,failed:[],moved:0},o={kind:a.fetched<a.repositories?`failed`:`ready`,text:Ke(a)};if(a.moved>0||ur){try{window.sessionStorage.setItem(nr,JSON.stringify(o))}catch{}if(!dr())return void window.location.reload();ur=!0}ge(Pe(),o)}try{let e=window.sessionStorage.getItem(nr);if(e){window.sessionStorage.removeItem(nr);let t=JSON.parse(e);typeof t.kind==`string`&&typeof t.text==`string`&&ge(Pe(),{kind:t.kind,text:t.text})}}catch{}k?.addEventListener(`click`,()=>void sr(V(),k)),Se(),or();var cr=document.body.dataset.indexRevision??``,lr=document.body.dataset.live===`true`?Date.now():0,ur=!1;function dr(){let e=W?.open===!0||Y?.open===!0||document.activeElement?.closest(`[data-collections-area], [data-collections-filter]`)!=null;return D.size>0||document.activeElement===h||Qt||On.isOpen()||Sn||e||ln()||un>0}function $(){ur&&!dr()&&Me()}async function fr(){try{let e=await fetch(`/revision`);if(e.ok){Re(document,!0);let t=await e.json();Oe(document,t),t.live&&lr===0&&(lr=Date.now()),t.live||(lr=0);let n=pe(cr,t.revision??``,dr());if(n===`reload`)return Me(),null;n===`hold`&&(ur=!0)}}catch{Re(document,!1)}return et(lr===0?2**53-1:Date.now()-lr)}var pr=ye(window,fr);xe(document,()=>pr.now()),h?.addEventListener(`blur`,$),document.addEventListener(`click`,()=>window.setTimeout($,0)),Ae();
1
+ import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as ee,L as te,M as ne,N as re,O as ie,P as ae,Q as oe,R as u,S as d,T as se,U as ce,V as le,W as ue,X as de,Y as fe,Z as pe,_t as me,a as he,ct as ge,ft as _e,g as ve,gt as ye,h as be,i as xe,it as Se,j as Ce,k as we,m as Te,n as Ee,nt as De,o as Oe,pt as ke,q as Ae,r as je,rt as Me,s as Ne,t as Pe,u as Fe,ut as Ie,w as Le,x as Re,xt as ze,yt as Be,z as Ve}from"./chunk-DRtin0n-.js";import{T as He,a as Ue,c as We,f as Ge,i as Ke,l as qe,m as Je,n as Ye,r as Xe,s as Ze,t as Qe,u as $e}from"./chunk-CIJm20ER.js";import{n as et,t as tt}from"./chunk-DMxtqzNj.js";import{t as nt}from"./chunk-C8kkSv38.js";import{n as rt,r as it}from"./chunk-Ahis0VaG.js";function at(e,t){t.forEach((t,n)=>{e.children[n]!==t&&e.insertBefore(t,e.children[n]??null)})}async function ot(e,t,n){if(e.disabled)return;let r=e.getAttribute(`aria-pressed`)!==`true`;st(e,r),e.disabled=!0;let i=await t(r).catch(()=>!1);if(e.disabled=!1,!i)return st(e,!r);n(r)}function st(e,t){e.setAttribute(`aria-pressed`,String(t)),e.innerHTML=t?`&#9733;`:`&#9734;`,e.setAttribute(`aria-label`,`${t?`Unpin`:`Pin`} this review`)}function ct(e){let t=e.querySelector(`[data-collections-registry]`)?.textContent??`[]`;try{let e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>!!e&&typeof e.id==`string`&&typeof e.name==`string`):[]}catch{return[]}}function lt(e){return(e.dataset.collections??``).split(` `).filter(Boolean)}async function ut(e,t,n){try{let r=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...t,snapshot:n})}),i=await r.json().catch(()=>null);return r.ok&&i&&(typeof i.area==`string`||i.stale===!0)?{ok:!0,answer:i}:{ok:!1,error:i?.error??`That could not be saved. The workspace server refused it.`}}catch{return{ok:!1,error:`The workspace server did not answer. It may have stopped.`}}}var dt=`prb-reviews-selection`;function ft(e,t){let n=new Set(e);return t.filter(e=>(e.dataset.lineage??e.dataset.id??``).split(` `).some(e=>n.has(e))).map(e=>e.dataset.id??``).filter(Boolean)}function pt(e,t){return t===``||e.name.toLowerCase().includes(t.trim().toLowerCase())}function mt(e,t){let n=e.trim().replace(/\s+/g,` `);if(n!==``)return t.some(e=>e.name.localeCompare(n,void 0,{sensitivity:`base`})===0)?void 0:n}function ht(e,t,n,r){let i=e.ownerDocument,a=(e,t)=>{let r=i.createElement(`label`);r.className=`prb-collections-option`;let a=i.createElement(`input`);return a.type=`checkbox`,a.value=e,a.checked=n.includes(e),a.setAttribute(`data-collections-filter-option`,``),r.append(a,i.createTextNode(` ${t}`)),r},o=t.filter(e=>pt(e,r)).map(e=>a(e.id,e.name));pt({id:`none`,name:`Uncollected`},r)&&o.unshift(a(Le,`Uncollected`)),e.replaceChildren(...o)}function gt(e,t,n,r){let i=e.ownerDocument,a=t.filter(e=>pt(e,r)).map(e=>{let t=ce(n,e.id),r=i.createElement(`label`);r.className=`prb-collections-option`;let a=i.createElement(`input`);a.type=`checkbox`,a.value=e.id,a.checked=t===`all`,a.indeterminate=t===`some`,a.dataset.membership=t,a.setAttribute(`data-collections-dialog-option`,``);let o=i.createElement(`span`);if(o.textContent=e.name,r.append(a,o),t===`some`){let t=i.createElement(`span`);t.className=`prb-collections-some`,t.textContent=`${n.filter(t=>t.includes(e.id)).length} of ${n.length}`,r.append(t)}return r});if(a.length===0&&t.length===0){let e=i.createElement(`p`);e.className=`prb-collections-none`,e.textContent=`No collections yet. Type a name to make one.`,a.push(e)}e.replaceChildren(...a)}function _t(e,t){return t?`For ${t}. Tick a collection to add it, untick to remove it.`:e===1?`For 1 selected review. Tick a collection to add it, untick to remove it.`:`For ${e} selected reviews. A part-filled box adds the rest; it never removes anything.`}function vt(e){return{title:`Expand or collapse a collection`,mount(t,n){let r=t.ownerDocument,i=r.createElement(`div`);i.className=`prb-palette-results`,i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,`Collections`);let a=e.collections().map((e,t)=>{let n=r.createElement(`button`);n.type=`button`,n.className=`prb-palette-result prb-palette-collection`,n.dataset.collectionChoice=e.id;let i=r.createElement(`kbd`);i.className=`prb-kbd prb-palette-num`;let a=We(t);a?i.textContent=a:i.setAttribute(`aria-hidden`,`true`);let o=r.createElement(`span`);o.className=`prb-palette-result-title`,o.textContent=e.name;let s=r.createElement(`span`);s.className=`prb-palette-collection-count`,s.textContent=e.count;let c=r.createElement(`span`);return c.className=`prb-palette-state`,c.textContent=e.open?`Expanded`:`Collapsed`,n.append(i,o,s,c),n});i.replaceChildren(...a);let o=t=>{t&&(n(),e.toggle(t))};i.addEventListener(`click`,e=>{o(e.target.closest(`[data-collection-choice]`)?.dataset.collectionChoice)}),t.addEventListener(`keydown`,e=>{if(e.isComposing||e.metaKey||e.ctrlKey||e.altKey)return;let t=Ze(e.key);if(t!==null)return e.preventDefault(),o(a[t]?.dataset.collectionChoice);let n=a.indexOf(e.target),r=e.key===`ArrowDown`||e.key===`j`?a[Math.min(n+1,a.length-1)]:e.key===`ArrowUp`||e.key===`k`?a[Math.max(n-1,0)]:e.key===`Home`?a[0]:e.key===`End`?a[a.length-1]:void 0;r&&(e.preventDefault(),r.focus())}),t.append(i),a[0]?.focus()}}}function yt(e){let t=e.dataset.id??``,n=e.dataset.placement;return n===void 0||n===`home`?t:`${t}|${n}`}function bt(e,t){let n=e.parentElement?.querySelector(`[data-history-list]`);n&&(n.hidden=!t,e.setAttribute(`aria-expanded`,String(t)))}function xt(e,t,n,r,i=new Map){return{limits:n,...i.size===0?{}:{collectionLimits:Object.fromEntries(i)},expanded:t.filter(e=>e.dataset.id&&e.querySelector(`[data-history-list]:not([hidden])`)).map(yt),main:r?.scrollTop??0,...ke(e)}}function St(e,t){let n=e?.limits;if(!n||typeof n!=`object`)return t;let r={...t};for(let e of d){let t=n[e];typeof t==`number`&&Number.isInteger(t)&&t>r[e]&&(r[e]=t)}return r}function Ct(e){let t=e?.collectionLimits,n=new Map;if(!t||typeof t!=`object`||Array.isArray(t))return n;for(let[e,r]of Object.entries(t))e.startsWith(`collection`)&&Ve(e)&&typeof r==`number`&&Number.isInteger(r)&&r>15&&n.set(e,r);return n}function wt(e,t,n){if(!t)return;n.reveal(St(t,n.limits),Ct(t));let r=new Set(Be(t,`expanded`));for(let e of n.cards){let t=e.querySelector(`[data-history-toggle]`);t&&r.has(yt(e))&&bt(t,!0)}let i=ye(t,`main`);n.pane&&i!==null&&(n.pane.scrollTop=i),me(e,t.focus,t.focusVisible)}var Tt=_e({ownsRestore:!0});Pe(`/restart`);var f=[...document.querySelectorAll(`[data-card][data-placement="home"]`)].sort((e,t)=>Number(e.dataset.rank)-Number(t.dataset.rank)),p=new Map;function Et(){p=new Map;for(let e of document.querySelectorAll(`[data-card]`)){let t=e.dataset.id??``;p.set(t,[...p.get(t)??[],e])}}Et();function Dt(e,t){for(let n of p.get(e)??[])t(n)}function m(){return[...p.values()].flat()}var h=ct(document),Ot=[...document.querySelectorAll(`[data-operation]`)],kt=document.querySelector(`[data-section="in-progress"]`),At=e=>e.dataset.inProgressOnly!==void 0,jt=Object.fromEntries(d.map(e=>[e,document.querySelector(`[data-cards="${e}"]`)])),Mt=document.querySelector(`.prb-index`);function Nt(e){return{id:e.dataset.id??``,collections:lt(e),queue:e.dataset.queue===void 0?void 0:Number(e.dataset.queue),status:e.dataset.status??`new`,prState:e.dataset.prState}}var g=document.querySelector(`[data-search]`),_=document.querySelector(`[data-status-filter]`),v=document.querySelector(`[data-author-filter]`),y=document.querySelector(`[data-pr-filter]`),Pt=document.querySelector(`[data-no-matches]`),b=document.querySelector(`[data-count]`),Ft=document.querySelector(`[data-clear-filters]`),x=document.querySelector(`[data-collections-filter]`),It=document.querySelector(`[data-collections-filter-search]`);function Lt(){if(!x)return;x.hidden=h.length===0;let e=x.querySelector(`[data-collections-filter-label]`);e&&(e.textContent=ie(D.collections,h)),D.collections.length===0?delete x.dataset.active:x.dataset.active=``;let t=x.querySelector(`[data-collections-filter-options]`);t&&ht(t,h,D.collections,It?.value??``)}var S=te();function Rt(e){return{stored:Ie({state:e.dataset.lifecycle,at:Number(e.dataset.lifecycleAt)}),activity:De(e.dataset)??{at:0,kind:`created`}}}function zt(e){return e.dataset.pinned===`true`}function Bt(e){let{stored:t,activity:n}=Rt(e);return l(zt(e),t,n,lt(e).length>0,D.filter)}function Vt(e){let t=Bt(e);return t===void 0?.5:d.indexOf(t)}function Ht(e){return[...e].sort((e,t)=>Vt(e)-Vt(t))}var C=new Map,w=document.querySelector(`[data-bulk]`),Ut=document.querySelector(`[data-bulk-count]`),Wt=document.querySelector(`[data-bulk-detail]`),Gt=document.querySelector(`[data-bulk-delete]`),Kt=document.querySelector(`[data-bulk-delete-label]`),qt=document.querySelector(`[data-bulk-exit]`),Jt=document.querySelector(`[data-bulk-more]`),Yt=document.querySelector(`[data-bulk-question]`),T=document.querySelector(`[data-bulk-confirm]`),Xt=document.querySelector(`[data-bulk-actions]`),E=document.querySelector(`[data-bulk-error]`),Zt=document.querySelector(`[data-bulk-select-all]`),D=s(window.location.hash),O=new Set,k=!1,A=document.querySelector(`[data-bulk-fetch]`),Qt={},j=[],$t=!1;function M(){let e=D.query.trim().toLowerCase();D.author!==``&&![...v?.options??[]].some(e=>e.value===D.author)&&(D.author=``),D.collections=D.collections.filter(e=>e===`none`||h.some(t=>t.id===e)),h.length===0&&(D.collections=[]);let t=Ht(ae(f.map(e=>({...Nt(e),searchText:e.dataset.searchText??``,author:e.dataset.author,card:e})),{...D,query:e}).map(e=>e.card)),n=t.filter(e=>!At(e));j=n;let r=new Set(ae(Ot.map(e=>({...Nt(e),searchText:e.dataset.searchText??``,author:e.dataset.author,entry:e})),{...D,query:e}).map(e=>e.entry));for(let e of Ot)e.hidden=!r.has(e);if(kt){kt.hidden=r.size===0;let e=kt.querySelector(`[data-section-count]`);e&&(e.textContent=String(r.size))}let i=n.filter(e=>Bt(e)!==void 0),a=de(i,e=>Bt(e),S),o=new Set(d.flatMap(e=>a[e].shown));for(let e of d){let t=jt[e];t&&at(t,a[e].shown);let n=document.querySelector(`[data-load-more="${e}"]`);n&&(n.hidden=a[e].total<=a[e].shown.length);let r=document.querySelector(`[data-section="${e}"]`);r&&(r.hidden=a[e].total===0);let i=r?.querySelector(`[data-section-count]`);i&&(i.textContent=String(a[e].total))}for(let e of en(n))o.add(e);for(let e of m())e.hidden=!o.has(e);if(g&&g.value!==D.query&&(g.value=D.query),v&&(v.value=D.author,D.author===``?delete v.dataset.active:v.dataset.active=``),y||(D.pr=`any`),y&&(y.value=D.pr,D.pr===`any`?delete y.dataset.active:y.dataset.active=``),_&&(_.value=D.filter,D.filter===`all`?delete _.dataset.active:_.dataset.active=``),Lt(),Ft&&(Ft.hidden=!u(D)),b){let e=e=>e.reduce((e,t)=>e+Number(t.dataset.reviews??1),0);b.textContent=Ce(e(t),t.length,u(D)?e(f):void 0)}Pt&&(Pt.hidden=t.length>0||r.size>0||f.length===0),xn(n)}function en(e){let r=document.querySelector(`[data-collections-area]`);if(!r)return[];let o=ue(D.filter),s=u(D),c=e.flatMap(e=>lt(e).map(t=>({card:e,collection:t}))),l=e=>{let{stored:t,activity:n}=Rt(e);return i(zt(e),t,n,D.filter)},ee=n(c,({card:e,collection:t})=>{let n=l(e);return n===void 0?void 0:`${n===`completed`?`collection-done`:`collection`}:${t}`},e=>C.get(e)??15),te=(e,t)=>(p.get(e)??[]).find(e=>e.dataset.placement===`collection:${t}`),ne=[],re=!1;for(let e of r.querySelectorAll(`[data-collection]`)){let n=e.dataset.collection??``,r=ee.get(`collection:${n}`)??{shown:[],total:0},i=ee.get(`collection-done:${n}`)??{shown:[],total:0},l=c.filter(e=>e.collection===n),ie=l.filter(e=>zt(e.card)).length,ae=D.collections.length>0&&!D.collections.includes(n),oe=!o&&!ae&&(!s||l.length>0);if(e.hidden=!oe,!oe)continue;re=!0;for(let[t,a]of[[`collection:${n}`,r],[`collection-done:${n}`,i]]){let r=a.shown.map(e=>te(e.card.dataset.id??``,n)).filter(e=>e!==void 0),i=e.querySelector(`[data-cards="${t}"]`);i&&at(i,r),ne.push(...r);let o=e.querySelector(`[data-load-more="${t}"]`);o&&(o.hidden=a.total<=a.shown.length)}let u=e.querySelector(`[data-section="collection:${n}"] > summary [data-section-count]`);u&&(u.textContent=se(r.total,ie));let d=e.querySelector(`[data-collection-empty]`),ce=a({active:r.total,completed:i.total,pinned:ie,members:l.length},s);d&&(d.hidden=ce===void 0,d.textContent=ce??``);let le=e.querySelector(`[data-section="collection-done:${n}"]`);le&&(le.hidden=i.total===0);let ue=e.querySelector(`[data-completed-label]`);ue&&(ue.textContent=t(i.total))}return r.hidden=o||!re,ne}var tn=300,N=null;function P(){N!==null&&window.clearTimeout(N),N=null,Tt.replace(o(D),{})}function F(e,t){if(D={...D,...e},S=te(),C=new Map,M(),t===`now`)return P();N!==null&&window.clearTimeout(N),N=window.setTimeout(P,tn)}window.addEventListener(`pagehide`,()=>{N!==null&&P()}),document.addEventListener(`click`,e=>{N!==null&&e.target?.closest?.(`a[href]`)&&P()},!0),g?.addEventListener(`input`,()=>F({query:g.value},`settled`)),g?.addEventListener(`keydown`,e=>{e.key===`Escape`&&g.value!==``&&(e.preventDefault(),F({query:``},`now`))}),_?.addEventListener(`change`,()=>{F({filter:_.value},`now`)}),v?.addEventListener(`change`,()=>{F({author:v.value},`now`)}),y?.addEventListener(`change`,()=>{F({pr:y.value},`now`)}),Ft?.addEventListener(`click`,()=>{F({query:Re.query,filter:Re.filter,author:Re.author,pr:Re.pr,collections:Re.collections},`now`),g?.focus()}),it(),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-load-more]`)?.dataset.loadMore;if(t&&t.startsWith(`collection`)&&Ve(t))return C.set(t,(C.get(t)??15)+15),M();!t||!d.includes(t)||(S={...S,[t]:S[t]+15},M())});for(let e of[`popstate`,`hashchange`])window.addEventListener(e,()=>{D=s(window.location.hash),S=te(),C=new Map,M(),ln()});document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-pin]`);if(!t?.dataset.pin)return;e.preventDefault(),e.stopPropagation();let n=t.dataset.pin;ot(t,e=>fetch(`/pin`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:n,pinned:e})}).then(e=>e.ok),e=>{Dt(n,n=>{n.dataset.pinned=String(e);let r=n.querySelector(`[data-pin]`);r&&r!==t&&st(r,e),Kn(n)}),M()})});async function nn(e,t){let n;try{let r=await fetch(`/queue`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:e,action:t})});if(!r.ok)return I(await on(r));n=(await r.json()).queue}catch{return I(an)}sn(n),M()}var rn=`That could not be saved. The workspace server refused it.`,an=`The workspace server did not answer. It may have stopped.`;function I(e){he(Ne(),{kind:`failed`,text:e})}async function on(e){let t=await e.json().catch(()=>null);return typeof t?.error==`string`?t.error:rn}function sn(e){let t=new Map(e.map((e,t)=>[e,t]));for(let e of m()){let n=t.get(e.dataset.id??``);n===void 0?delete e.dataset.queue:e.dataset.queue=String(n),n!==void 0&&e.dataset.lifecycle!==`active`&&(e.dataset.lifecycle=`active`,delete e.dataset.lifecycleAt,Kn(e))}for(let e of document.querySelectorAll(`[data-queue-action][data-queue-id]`)){let n=t.has(e.dataset.queueId??``);e.dataset.queueAction=n?`remove`:`add`,e.textContent=Ae(n)}let n=document.querySelector(`[data-queue-option]`);n&&(n.textContent=ee(e.length))}document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-history-toggle]`);if(!t)return;e.preventDefault(),e.stopPropagation();let n=t.parentElement?.querySelector(`[data-history-list]`);n&&bt(t,n.hidden!==!1)});var cn=document.querySelector(`.prb-shell > main`);function ln(){wt(document,Tt.current().ui,{cards:m(),pane:cn,limits:S,reveal:(e,t)=>{S=e,C=t,M()}})}Tt.setCapturer(()=>xt(document,m(),S,cn,C)),M(),ln();var L=et(document,{onOpen:vn,onClose:e=>{vn(e),window.setTimeout($,0)}});function un(){return document.querySelector(`[data-menu-trigger][aria-expanded="true"]`)!==null}var dn=0;async function fn(e){dn+=1;try{await e()}finally{--dn,$()}}var R=new Set,pn=`A change to this review is still being saved.`,mn=`A change to one of these reviews is still being saved. Try again once it is.`;async function hn(e,t){if(e.some(e=>R.has(e)))return!1;for(let t of e)R.add(t);gn(e);try{await t()}finally{for(let t of e)R.delete(t);gn(e)}return!0}function gn(e){let t=new Set(e);for(let e of m()){let n=e.dataset.id??``;if(!t.has(n))continue;let r=R.has(n);for(let t of e.querySelectorAll(`.prb-card-controls button.prb-state-pill`))r?t.setAttribute(`aria-disabled`,`true`):t.removeAttribute(`aria-disabled`);for(let t of e.querySelectorAll(`.prb-card-controls :is([data-mark-status], [data-lifecycle-set], [data-queue-action])`))t.disabled=r}}async function _n(e,t){await hn([e],()=>fn(t))||I(pn)}function vn(e){let t=e.querySelector(`[data-menu-items]`),n=e.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!1),n&&(n.hidden=!0);let r=e.querySelector(`[data-collection-rename-form]`);r&&(r.hidden=!0,X(r,void 0)),e.querySelector(`[data-menu-error]`)?.remove(),e.querySelector(`[data-id-field]`)?.remove()}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-menu]`);if(!n||n.closest(`[data-bulk]`)||n.matches(`[data-collections-filter]`))return;if(n.matches(`.prb-collection-menu`))return ur(e,t,n);if(n.matches(`[data-lifecycle-control]`))return Wn(e,t,n);let r=t.closest(`[data-collections-for]`);if(r?.dataset.collectionsFor){e.preventDefault(),e.stopPropagation(),L.closeAll();let t=r.closest(`[data-card]`)?.querySelector(`[data-select]`)?.getAttribute(`aria-label`)?.replace(/^Select /,``);dr([r.dataset.collectionsFor],{card:t??`this review`});return}let i=t.closest(`[data-copy-id]`);if(i?.dataset.copyId){e.preventDefault(),e.stopPropagation(),He(i,i.dataset.copyId);return}let a=t.closest(`[data-fetch-review]`);if(a?.dataset.fetchReview){e.preventDefault(),e.stopPropagation(),L.closeAll();let t=a.closest(`[data-card]`);t&&xr([t]);return}let o=t.closest(`[data-mark-status]`);if(o?.dataset.markId){e.preventDefault(),e.stopPropagation(),L.closeAll();let t=o.dataset.markId;_n(t,()=>Rn(t,o.dataset.markStatus===`complete`));return}let s=t.closest(`[data-lifecycle-set]`);if(s?.dataset.lifecycleId){e.preventDefault(),e.stopPropagation(),L.closeAll();let t=s.dataset.lifecycleId;_n(t,Un(t,s.dataset.lifecycleSet));return}let c=t.closest(`[data-queue-action]`);if(c?.dataset.queueId){e.preventDefault(),e.stopPropagation(),L.closeAll();let t=c.dataset.queueId;_n(t,()=>nn(t,c.dataset.queueAction===`remove`?`remove`:`add`));return}if(t.closest(`[data-delete]`)){e.preventDefault(),e.stopPropagation();let t=n.querySelector(`[data-menu-items]`),r=n.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!0),r&&(r.hidden=!1),e.detail===0&&n.querySelector(`[data-cancel-delete]`)?.focus();return}if(t.closest(`[data-cancel-delete]`)){e.preventDefault(),e.stopPropagation(),vn(n),e.detail===0&&n.querySelector(`[data-delete]`)?.focus();return}if(t.closest(`[data-confirm-delete]`)){e.preventDefault(),e.stopPropagation(),yn(n);return}e.preventDefault(),e.stopPropagation()});async function yn(e){let t=e.querySelector(`[data-delete]`),n=t?.dataset.delete;if(!n)return;let r=e.querySelector(`[data-menu-confirm]`),i=e.querySelector(`[data-confirm-delete]`);i&&(i.disabled=!0,i.textContent=`Deleting`);try{let r=await fetch(`/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:n,scope:t?.dataset.scope??`review`})});if(r.ok)return void window.location.reload();bn(e,(await r.json().catch(()=>null))?.error??`That could not be deleted.`)}catch{bn(e,`The workspace server did not answer. It may have stopped.`)}i&&(i.disabled=!1,i.textContent=`Delete`),r&&(r.hidden=!0);let a=e.querySelector(`[data-menu-items]`);a&&(a.hidden=!1)}function bn(e,t){e.querySelector(`[data-menu-error]`)?.remove();let n=document.createElement(`p`);n.className=`prb-menu-error`,n.setAttribute(`data-menu-error`,``),n.textContent=t,e.querySelector(`[data-menu-panel]`)?.append(n)}function z(e){k=e,e||O.clear(),Mt&&(e?Mt.dataset.selecting=``:delete Mt.dataset.selecting),document.querySelector(`[data-select-mode]`)?.setAttribute(`aria-pressed`,String(e)),!e&&Jt&&L.close(Jt);for(let t of document.querySelectorAll(`.prb-card-link`))e?t.setAttribute(`aria-disabled`,`true`):t.removeAttribute(`aria-disabled`);B(),M()}function B(){T&&(T.hidden=!0),Xt&&(Xt.hidden=!1),E&&(E.hidden=!0,E.textContent=``)}function xn(t){for(let e of m()){let t=O.has(e.dataset.id??``),n=e.querySelector(`[data-select]`);n&&(n.checked=t),t?e.dataset.selected=``:delete e.dataset.selected}if(!w||(w.hidden=!k,!k))return;let n=new Set(m().filter(Sn).map(e=>e.dataset.id)),r=[...O].filter(e=>!n.has(e)).length,i=new Set(t.map(e=>e.dataset.id)),a=[...O].every(e=>i.has(e))?i.size:null;O.size===0?w.dataset.empty=``:delete w.dataset.empty,Ut&&(Ut.textContent=e(O.size)),Wt&&(Wt.textContent=oe(O.size,a,r)),Zt&&(Zt.textContent=pe(t.length,O.size>0&&a!==null),Zt.disabled=t.every(e=>O.has(e.dataset.id??``))),Kt&&(Kt.textContent=ne(Fn()));for(let e of w.querySelectorAll(`[data-bulk-mark], [data-bulk-lifecycle], [data-bulk-queue], [data-bulk-collections], [data-bulk-delete]`))e.disabled=O.size===0;A&&(A.hidden=!Ye(Qt,_r(U())))}function Sn(e){return!e.hidden&&e.closest(`details:not([open]), [hidden]`)===null}function Cn(e){let t=[...e.querySelectorAll(`details[data-section]`)];for(let e of t)e.addEventListener(`toggle`,()=>xn(j));rt(t,(e,t)=>fetch(`/sections`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({section:e,collapsed:t})}))}Cn(document),document.querySelector(`[data-select-mode]`)?.addEventListener(`click`,()=>{z(!k)}),Zt?.addEventListener(`click`,()=>{for(let e of j)e.dataset.id&&O.add(e.dataset.id);B(),M()});function wn(e){O.has(e)?O.delete(e):O.add(e),B(),M()}document.addEventListener(`change`,e=>{let t=e.target.closest(`[data-select]`);t?.dataset.select&&wn(t.dataset.select)}),document.addEventListener(`click`,e=>{if(!k)return;let t=e.target,n=t.closest(`[data-card]`);n?.dataset.id&&(t.closest(`[data-select], .prb-card-controls, [data-menu], [data-history-toggle]`)||(e.preventDefault(),wn(n.dataset.id)))}),document.addEventListener(`keydown`,e=>{if(!k||e.key!==`Enter`)return;let t=e.target.closest(`.prb-card-link`)?.closest(`[data-card]`);t?.dataset.id&&(e.preventDefault(),wn(t.dataset.id))});var V=nt({doc:document,item:`[data-card]`,link:`.prb-card-link`,walk:()=>[...document.querySelectorAll(`[data-card]`)].filter(Sn),enterAllowed:()=>!k,background:()=>cn,leadIn:e=>[...e.closest(`[data-cards]`)?.querySelectorAll(`[data-card]:not([hidden])`)??[]][0]===e?e.closest(`details[data-section]`)?.querySelector(`summary`)??null:null});function Tn(){return V.holdsKeys()?V.current()?.querySelector(zn)??null:null}var En=8;function Dn(e){let t=e.querySelector(`.prb-card-link`);t&&(t.focus({preventScroll:!0}),document.activeElement!==t&&document.activeElement?.blur(),N!==null&&P(),Tt.leaving(),On=!0,window.location.assign(t.href))}var On=!1,kn={title:`Search reviews`,mount(e,t){let n=document.createElement(`input`);n.type=`search`,n.className=`prb-palette-input`,n.placeholder=g?.placeholder??``,n.setAttribute(`aria-label`,`Search reviews`),n.spellcheck=!1,n.value=g?.value??``;let r=document.createElement(`p`);r.className=`prb-palette-summary`,r.setAttribute(`aria-live`,`polite`);let i=document.createElement(`div`);i.className=`prb-palette-results`,i.setAttribute(`role`,`group`),i.setAttribute(`aria-label`,`Matching reviews`);let a=()=>{let e=j.slice(0,En);i.replaceChildren(...e.map(e=>{let t=document.createElement(`button`);t.type=`button`,t.className=`prb-palette-result`,t.dataset.resultId=e.dataset.id??``;let n=document.createElement(`span`);n.className=`prb-palette-result-title`,n.textContent=e.querySelector(`.prb-card-head h2`)?.textContent??``;let r=document.createElement(`span`);return r.className=`prb-palette-result-where`,r.textContent=[e.querySelector(`.prb-card-repo`)?.textContent,e.querySelector(`.prb-card-branch`)?.textContent].filter(Boolean).join(` · `),t.append(n,r),t})),r.textContent=j.length===0?`No reviews match.`:j.length>e.length?`The first ${e.length} of ${b?.textContent??j.length}`:b?.textContent??``},o=()=>[...i.querySelectorAll(`.prb-palette-result`)],s=e=>{let n=f.find(t=>t.dataset.id===e?.dataset.resultId);n&&(t(),Dn(n))};n.addEventListener(`input`,()=>{g&&(g.value=n.value,g.dispatchEvent(new Event(`input`,{bubbles:!0})),a())}),i.addEventListener(`click`,e=>s(e.target.closest(`.prb-palette-result`)??void 0)),e.addEventListener(`keydown`,e=>{if(e.isComposing)return;let t=o(),r=t.indexOf(e.target);if(e.key===`Enter`&&e.target===n)return e.preventDefault(),s(t[0]);let i=e.key===`ArrowDown`?r<0?t[0]:t[r+1]:e.key===`ArrowUp`?r<=0?n:t[r-1]:null;i&&(e.preventDefault(),i.focus())}),e.append(n,r,i),a(),n.focus(),n.select()}},An={title:`Filters`,mount(e){let t=document.createElement(`p`);t.className=`prb-palette-summary`,t.setAttribute(`aria-live`,`polite`);let n=()=>{t.textContent=b?.textContent??``},r=[_,v,y].flatMap(e=>{if(!e)return[];let t=document.createElement(`label`);t.className=`prb-palette-field`;let r=document.createElement(`span`),i=(e.getAttribute(`aria-label`)??``).replace(/^Filter by /,``);r.textContent=i.charAt(0).toUpperCase()+i.slice(1);let a=document.createElement(`select`);for(let t of e.options)a.append(new Option(t.text,t.value));return a.value=e.value,a.addEventListener(`change`,()=>{e.value=a.value,e.dispatchEvent(new Event(`change`,{bubbles:!0})),n()}),t.append(r,a),[t]});e.append(...r,t),n(),r[0]?.querySelector(`select`)?.focus()}};function jn(e){let t=()=>document.querySelector(`details[data-section="${e}"]`);return{available:()=>!!(t()&&!t().hidden),state:()=>{let e=t();return e&&!e.hidden?e.open?`Expanded`:`Collapsed`:null},run:()=>{let e=t();e&&(e.open=!e.open)}}}var Mn=Object.fromEntries(r.map(e=>[`reviews.section.${e}`,jn(e)]));function Nn(){return[...document.querySelectorAll(`[data-collections-area]:not([hidden]) [data-collection]:not([hidden])`)].flatMap(e=>{let t=e.querySelector(`:scope > details[data-section]`);if(!t)return[];let n=t.querySelector(`[data-collection-name]`)?.textContent??``,r=t.querySelector(`:scope > summary [data-section-count]`)?.textContent??``;return[{id:e.dataset.collection??``,name:n,count:r,open:t.open}]})}var H=document.querySelector(`[data-collection-new]`),Pn=Te(`reviews`,{...Mn,"reviews.search":{available:()=>g!==null,panel:kn},"reviews.filters":{available:()=>_!==null,panel:An},"reviews.collection.new":{available:()=>H!==null&&!H.disabled,run:()=>H?.click()},"reviews.collection.fold":{available:()=>Nn().length>0,panel:vt({collections:Nn,toggle:e=>{let t=document.querySelector(`[data-collection="${CSS.escape(e)}"] > details[data-section]`);t&&(t.open=!t.open)}})},"reviews.next":{run:()=>V.move(1)},"reviews.previous":{run:()=>V.move(-1)},"reviews.open":{available:()=>V.enterOpens(),run:()=>V.open()},"reviews.openInNewTab":{available:()=>V.enterOpens(),run:()=>V.openInNewTab()},"reviews.selection.exit":{available:Qn,run:()=>T&&!T.hidden?Xn(w?.contains(document.activeElement)??!1):Zn()},"reviews.menu":{available:()=>Tn()!==null,run:()=>{let e=Tn();e&&L.open(e,{focusFirst:!0,returnFocus:()=>V.refocus()})}}},{onOpen:()=>L.closeAll(),onSettle:()=>$()});function U(){return Ht(f.filter(e=>O.has(e.dataset.id??``)))}function Fn(){return U().reduce((e,t)=>e+Number(t.dataset.reviews??1),0)}function W(e){E&&(E.textContent=e,E.hidden=!1)}function G(e){for(let t of w?.querySelectorAll(`button`)??[])t.disabled=e}async function In(e){let t=[...O];if(t.length===0)return;G(!0);let n=null,r=await hn(t,async()=>{try{(await fetch(`/status`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:t,complete:e})})).ok||(n=`That could not be saved. The workspace server refused it.`)}catch{n=`The workspace server did not answer. It may have stopped.`}});if(!r||n!==null)return G(!1),W(r?n??``:mn);Ln(U(),e),G(!1),z(!1)}function Ln(e,t){let n=t?`complete`:`in-progress`,r=t?`in-progress`:`complete`;for(let t of e.flatMap(e=>p.get(e.dataset.id??``)??[e])){t.dataset.status=n;for(let e of t.querySelectorAll(`.prb-card-status`))$e(e,n);let e=t.querySelector(`[data-mark-status]`);e&&(e.dataset.markStatus=r,e.textContent=le(r))}}async function Rn(e,t){try{let n=await fetch(`/status`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:[e],complete:t})});if(!n.ok)return I(await on(n))}catch{return I(an)}Ln(f.filter(t=>t.dataset.id===e),t),M()}var zn=`:scope > .prb-card-controls > [data-menu]:not([data-lifecycle-control])`;async function Bn(e,t){let n=e.closest(`[data-card]`),r=n?.dataset.id;if(!n||!r||R.has(r))return;let i=document.activeElement===e,a=Vn(n);Ge(e,!0);try{await _n(r,t)}finally{Ge(e,!1)}i&&Hn(e,a)}function Vn(e){let t=e=>e instanceof HTMLElement&&e.matches(`[data-card]`)&&e.checkVisibility();for(let n=e.nextElementSibling;n;n=n.nextElementSibling)if(t(n))return n;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)if(t(n))return n;return null}function Hn(e,t){if(document.activeElement===null||document.activeElement===document.body){if(e.isConnected&&e.checkVisibility())return e.focus({preventScroll:!0});t?.querySelector(`.prb-card-link`)?.focus({preventScroll:!0})}}function Un(e,t){return async()=>{await Gn([e],t)||I(`That could not be saved. The workspace server refused it or did not answer.`)}}document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-card] button.prb-card-status`),n=t?.closest(`[data-card]`)?.dataset.id;!t||!n||(e.preventDefault(),Bn(t,()=>Rn(n,t.dataset.status!==`complete`)))});function Wn(e,t,n){let r=n.querySelector(`[data-lifecycle-pill]`),i=n.closest(`[data-card]`)?.dataset.id;if(!r||!i)return;let a=t.closest(`[data-lifecycle-set]`);if(a){e.preventDefault(),e.stopPropagation(),L.close(n,{returnFocus:!0}),Bn(r,Un(i,a.dataset.lifecycleSet));return}let o=r.dataset.lifecyclePress;!t.closest(`[data-lifecycle-pill]`)||!o||o===`menu`||(e.preventDefault(),Bn(r,Un(i,o)))}async function Gn(e,t){let n;try{let r=await fetch(`/lifecycle`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:e,state:t})});n=r.ok?await r.json().catch(()=>null):null}catch{n=null}if(!n)return!1;let r=new Set(e);for(let e of m())r.has(e.dataset.id??``)&&(e.dataset.lifecycle=t,t===`active`?delete e.dataset.lifecycleAt:e.dataset.lifecycleAt=String(n.at),Kn(e));return sn(n.queue),M(),!0}function Kn(e){let{stored:t,activity:n}=Rt(e),r=e.querySelector(`[data-lifecycle-pill]`);r&&qe(r,t,n);let i=e.querySelector(`[data-lifecycle-chip]`);if(i){let e=Me(t,n);i.textContent=e??``,i.hidden=e===void 0}for(let r of e.querySelectorAll(`[data-menu-items] [data-lifecycle-set]`)){let e=r.dataset.lifecycleSet;r.hidden=!ge(e,t,n),r.textContent=Se(e,t,n)}}async function qn(e){let t=[...O];if(t.length===0)return;G(!0);let n=!1,r=await hn(t,async()=>{n=await Gn(t,e)});if(G(!1),!r)return W(mn);if(!n)return W(`That could not be saved. The workspace server refused it or did not answer.`);z(!1)}async function Jn(){let e=[...O];if(e.length===0)return;G(!0);let t=null;try{let n=await fetch(`/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:e})});if(t=n.ok?await n.json().catch(()=>null):null,!t)return G(!1),B(),W(`Nothing was deleted. The workspace server refused it.`)}catch{return G(!1),B(),W(`The workspace server did not answer. It may have stopped.`)}let n=t.blocked??[],r=new Set(n.map(e=>e.id));for(let e of U()){let t=e.dataset.id??``;r.has(t)||Dt(t,e=>e.remove())}f=f.filter(e=>e.isConnected),Et(),O.clear();for(let e of r)O.add(e);if(G(!1),B(),n.length===0)return z(!1);M(),W([...new Set(n.map(e=>e.error))].join(` `))}async function Yn(){let e=U().map(e=>e.dataset.id??``).filter(Boolean);if(e.length===0)return;G(!0);let t=null,n=!1,r=await hn(e,async()=>{try{let n=await fetch(`/queue`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:e,action:`add`})});t=n.ok?await n.json().catch(()=>null):null}catch{n=!0}});if(!r||n)return G(!1),B(),W(r?`The workspace server did not answer. It may have stopped.`:mn);if(!t?.queue)return G(!1),B(),W(`Nothing was added. The workspace server refused it.`);sn(t.queue);let i=t.refused??[];O.clear();for(let e of i)O.add(e.id);if(G(!1),B(),i.length===0)return z(!1);M(),W([...new Set(i.map(e=>e.error))].join(` `))}w?.addEventListener(`click`,e=>{let t=e.target;if(Jt&&t.closest(`[data-bulk-more] [data-menu-panel] button`)&&L.close(Jt),t.closest(`[data-bulk-queue]`))return void Yn();if(t.closest(`[data-bulk-collections]`))return dr(U().map(e=>e.dataset.id??``).filter(Boolean),{selection:!0});let n=t.closest(`[data-bulk-mark]`);if(n)return void In(n.dataset.bulkMark===`complete`);let r=t.closest(`[data-bulk-lifecycle]`);if(r)return void qn(r.dataset.bulkLifecycle);if(t.closest(`[data-bulk-delete]`)){Yt&&(Yt.textContent=re(Fn())),Xt&&(Xt.hidden=!0),T&&(T.hidden=!1),e.detail===0&&w.querySelector(`[data-bulk-cancel-delete]`)?.focus();return}if(t.closest(`[data-bulk-confirm-delete]`))return void Jn();if(t.closest(`[data-bulk-cancel-delete]`))return Xn(e.detail===0);if(t.closest(`[data-bulk-exit]`))return Zn()});function Xn(e){B(),e&&Gt?.focus()}function Zn(){let e=w?.contains(document.activeElement)??!1;z(!1),e&&document.querySelector(`[data-select-mode]`)?.focus()}function Qn(e){return!k||qt?.disabled?!1:e===void 0||Je(e,document,!0)}var K=document.querySelector(`[data-collections-dialog]`),$n=document.querySelector(`[data-collections-dialog-list]`),q=document.querySelector(`[data-collections-dialog-search]`),J=document.querySelector(`[data-collections-dialog-create]`),er=document.querySelector(`[data-collections-dialog-error]`),tr=document.querySelector(`[data-collections-dialog-for]`),Y=[],nr=!1,rr=!1,ir=document.body.dataset.cardsSnapshot??``;function ar(e,t){return ut(e,t,ir)}function or(e){if(e.stale||e.area===void 0){try{let e={ids:[...O],selecting:k};window.sessionStorage.setItem(dt,JSON.stringify(e))}catch{}K?.close(),window.location.reload();return}let t=e.area,n=document.querySelector(`[data-collections-area]`);if(n){let e=n.contains(document.activeElement)?ke(document):null,r=document.createElement(`template`);r.innerHTML=t.trim();let i=r.content.firstElementChild;if(i){if(n.replaceWith(i),Cn(i),k)for(let e of i.querySelectorAll(`.prb-card-link`))e.setAttribute(`aria-disabled`,`true`);e&&me(document,e.focus,e.focusVisible)}}h=e.collections;for(let t of f){let n=e.memberOf[t.dataset.id??``]??[];t.dataset.collections=n.join(` `);let r=t.querySelector(`[data-collections-line]`),i=we(n,h);r&&(r.textContent=i??``,r.hidden=i===void 0)}for(let t of Ot){let n=e.operations?.[t.dataset.key??``];n&&(t.dataset.collections=n.join(` `))}Et(),yr(),M()}function X(e,t){let n=e.querySelector(`[data-collection-error]`);n&&(n.textContent=t??``,n.hidden=t===void 0)}It?.addEventListener(`input`,()=>Lt()),x?.addEventListener(`change`,e=>{let t=e.target.closest(`[data-collections-filter-option]`);if(!t)return;let n=t.checked?[...D.collections,t.value]:D.collections.filter(e=>e!==t.value);F({collections:[...new Set(n)]},`now`),x.querySelector(`[data-collections-filter-option][value="${CSS.escape(t.value)}"]`)?.focus()});var Z=document.querySelector(`[data-collection-new-dialog]`),Q=Z?.querySelector(`[data-collection-name-input]`)??null,sr=Z?.querySelector(`[data-collection-create]`)??null,cr=!1;function lr(){H&&(H.disabled=cr),Q&&(Q.readOnly=cr),sr&&(sr.disabled=cr||(Q?.value.trim()??``)===``)}H?.addEventListener(`click`,()=>{Z&&(L.closeAll(),Q&&(Q.value=``),lr(),X(Z,void 0),Z.showModal(),Q?.focus())}),Q?.addEventListener(`input`,()=>{lr(),Z&&X(Z,void 0)}),Z?.querySelector(`[data-collection-cancel]`)?.addEventListener(`click`,()=>Z.close()),Z?.addEventListener(`close`,()=>$()),document.addEventListener(`submit`,e=>{let t=e.target;if(t.matches(`[data-collection-new-form]`)){e.preventDefault();let n=Q?.value??``;if(n.trim()===``)return;cr=!0,lr(),ar(`/collections`,{action:`create`,name:n}).then(e=>{cr=!1,lr();let n=Z?.open===!0;if(!e.ok)return X(t,e.error);Z?.close(),or(e.answer),n&&document.querySelector(`[data-collection="${CSS.escape(e.answer.id??``)}"] summary`)?.focus({focusVisible:!1})});return}let n=t.closest(`[data-collection-rename-form]`);if(n){e.preventDefault();let t=n.querySelector(`[data-collection-name-input]`)?.value??``,r=n.dataset.collectionRenameForm??``;ar(`/collections`,{action:`rename`,id:r,name:t}).then(e=>{if(!e.ok)return X(n,e.error);L.closeAll(),or(e.answer),document.querySelector(`[data-collection="${CSS.escape(r)}"] summary`)?.focus({focusVisible:!1})})}});function ur(e,t,n){let r=n.querySelector(`[data-menu-items]`),i=n.querySelector(`[data-collection-rename-form]`),a=n.querySelector(`[data-menu-confirm]`);if(t.closest(`[data-collection-rename]`)&&i){e.preventDefault(),r&&(r.hidden=!0),i.hidden=!1;let t=i.querySelector(`[data-collection-name-input]`);t?.focus(),t?.select();return}if(t.closest(`[data-collection-delete]`)&&a){e.preventDefault(),r&&(r.hidden=!0),a.hidden=!1,e.detail===0&&n.querySelector(`[data-cancel-delete]`)?.focus();return}if(t.closest(`[data-collection-cancel], [data-cancel-delete]`)){e.preventDefault(),vn(n);return}let o=t.closest(`[data-collection-confirm-delete]`);if(o?.dataset.collectionConfirmDelete){e.preventDefault(),o.disabled=!0;let t=o.dataset.collectionConfirmDelete;ar(`/collections`,{action:`delete`,id:t}).then(e=>{if(o.disabled=!1,!e.ok)return bn(n,e.error);L.closeAll(),or(e.answer),D.collections.includes(t)&&P(),document.querySelector(`[data-collection-new]`)?.focus()})}}function dr(e,t){!K||e.length===0||(L.closeAll(),Y=[...e],nr=!1,rr=`selection`in t,tr&&(tr.textContent=_t(e.length,`card`in t?t.card:void 0)),q&&(q.value=``),mr(void 0),pr(),K.showModal(),q?.focus())}function fr(){return Y.map(e=>lt(f.find(t=>t.dataset.id===e)??document.createElement(`div`)))}function pr(){let e=q?.value??``;$n&&gt($n,h,fr(),e);let t=mt(e,h);J&&(J.hidden=t===void 0,J.textContent=t===void 0?``:`Create “${t}” and add ${Y.length===1?`this review`:`these ${Y.length}`}`)}function mr(e){er&&(er.textContent=e??``,er.hidden=e===void 0)}async function hr(e){mr(void 0);let t=await ar(`/collections/members`,{ids:Y,...e});if(!t.ok)return mr(t.error),pr();nr=!0,or(t.answer);let n=t.answer.refused??[];n.length>0&&(Y=Y.filter(e=>!n.some(t=>t.id===e)),mr([...new Set(n.map(e=>e.error))].join(` `))),pr()}q?.addEventListener(`input`,()=>pr()),q?.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),J&&!J.hidden&&J.click())}),J?.addEventListener(`click`,()=>{let e=mt(q?.value??``,h);e!==void 0&&hr({action:`add`,create:e}).then(()=>{q&&(q.value=``),pr(),q?.focus()})}),$n?.addEventListener(`change`,e=>{let t=e.target.closest(`[data-collections-dialog-option]`);if(!t)return;let n=c(t.dataset.membership??`none`),r=t.value;hr({action:n,collection:r}).then(()=>{$n.querySelector(`[data-collections-dialog-option][value="${CSS.escape(r)}"]`)?.focus()})}),document.querySelector(`[data-collections-dialog-close]`)?.addEventListener(`click`,()=>K?.close());try{let e=window.sessionStorage.getItem(dt);if(e){window.sessionStorage.removeItem(dt);let t=JSON.parse(e),n=Array.isArray(t.ids)?t.ids.filter(e=>typeof e==`string`):[];if(t.selecting===!0||n.length>0){z(!0);for(let e of ft(n,f))O.add(e);M()}}}catch{}K?.addEventListener(`close`,()=>{nr&&k&&rr&&z(!1),Y=[],$()}),ze(window,()=>window.location.reload());var gr=`prb-fetch-summary`;function _r(e){return e.map(e=>({lineage:(e.dataset.lineage??e.dataset.id??``).split(` `).filter(Boolean)}))}function vr(e){return Xe(_r(e),Qt)}function yr(){for(let e of m()){let t=e.querySelector(`[data-fetch-review]`);t&&(t.hidden=!Ye(Qt,_r([e])))}}async function br(){try{let e=await fetch(`/fetch-updates`);if(!e.ok)return;Qt=(await e.json()).targets??{}}catch{return}yr(),M()}async function xr(e,t){let n=vr(e);if($t||n.repositories===0)return;$t=!0;let r=[A,...document.querySelectorAll(`[data-fetch-review]`)];for(let e of r)e&&(e.disabled=!0);t&&(t.textContent=Ue(n.repositories));let i=null;try{let e=await fetch(`/fetch-updates`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:n.ids})});e.ok&&(i=await e.json())}catch{}$t=!1;for(let e of r)e&&(e.disabled=!1);t&&(t.textContent=Qe),M();let a=i??{repositories:n.repositories,fetched:0,failed:[],moved:0},o={kind:a.fetched<a.repositories?`failed`:`ready`,text:Ke(a)};if(a.moved>0||wr){try{window.sessionStorage.setItem(gr,JSON.stringify(o))}catch{}if(!Tr())return void window.location.reload();wr=!0}he(Ne(),o)}try{let e=window.sessionStorage.getItem(gr);if(e){window.sessionStorage.removeItem(gr);let t=JSON.parse(e);typeof t.kind==`string`&&typeof t.text==`string`&&he(Ne(),{kind:t.kind,text:t.text})}}catch{}A?.addEventListener(`click`,()=>void xr(U(),A)),xe(),br();var Sr=document.body.dataset.indexRevision??``,Cr=document.body.dataset.live===`true`?Date.now():0,wr=!1;function Tr(){let e=K?.open===!0||Z?.open===!0||document.activeElement?.closest(`[data-collections-area], [data-collections-filter]`)!=null;return O.size>0||document.activeElement===g||$t||Pn.isOpen()||On||e||un()||dn>0}function $(){wr&&!Tr()&&je()}async function Er(){try{let e=await fetch(`/revision`);if(e.ok){Fe(document,!0);let t=await e.json();Ee(document,t),t.live&&Cr===0&&(Cr=Date.now()),t.live||(Cr=0);let n=fe(Sr,t.revision??``,Tr());if(n===`reload`)return je(),null;n===`hold`&&(wr=!0)}}catch{Fe(document,!1)}return tt(Cr===0?2**53-1:Date.now()-Cr)}var Dr=ve(window,Er);be(document,()=>Dr.now()),g?.addEventListener(`blur`,$),document.addEventListener(`click`,()=>window.setTimeout($,0)),Oe();
package/static/runs.js CHANGED
@@ -1 +1 @@
1
- import{X as e,a as t,b as n,g as r,h as i,i as a,lt as o,m as s,n as c,r as l,s as ee,t as te,u,vt as d,y as f}from"./chunk-CMC5F4_t.js";import{n as p,t as m}from"./chunk-DDm8oQLU.js";import{t as h}from"./chunk-Dv0Wowan.js";import{t as g}from"./chunk-C8kkSv38.js";import{r as ne,t as re}from"./chunk-BKBTVY9X.js";var _=[`all`,`in-progress`,`completed`,`failed`,`cancelled`,`not-responding`],v=[`all`,`review`,`update`,`re-run`,`kiss`,`ask`,`diagram`];function y(e,t){let n=0;return{visible:e.map(e=>e&&n++<t),matched:e.filter(Boolean).length}}function b(e,t){return e.status!==`all`&&t.status!==e.status||e.kind!==`all`&&t.kind!==e.kind?!1:e.query.toLowerCase().split(/\s+/).filter(Boolean).every(e=>t.searchText.includes(e))}function x(e){return e.status!==`all`||e.kind!==`all`||e.query.trim()!==``}function S(e){let t=new URLSearchParams(e.replace(/^#/,``)),n=t.get(`status`),r=t.get(`kind`);return{status:_.includes(n??``)?n:`all`,kind:v.includes(r??``)?r:`all`,query:t.get(`q`)??``}}function C(e){let t=new URLSearchParams;e.status!==`all`&&t.set(`status`,e.status),e.kind!==`all`&&t.set(`kind`,e.kind),e.query.trim()!==``&&t.set(`q`,e.query);let n=t.toString();return n===``?``:`#${n}`}var w=o();te(`/restart`);var T=document.querySelector(`[data-search]`),E=document.querySelector(`[data-run-status-filter]`),D=document.querySelector(`[data-run-kind-filter]`),O=document.querySelector(`[data-clear-filters]`),k=document.querySelector(`[data-no-matches]`),A=[...document.querySelectorAll(`[data-run]`)],j=S(window.location.hash);E&&![...E.options].some(e=>e.value===j.status)&&(j={...j,status:`all`});function M(){T&&(T.value=j.query),E&&(E.value=j.status),D&&(D.value=j.kind)}var N=50,P=document.querySelector(`[data-runs-more-row]`),F=document.querySelector(`[data-runs-more]`),I=document.querySelector(`[data-runs-more-note]`),L=e=>({status:e.dataset.runStatus??``,kind:e.dataset.runKind??``,searchText:e.dataset.searchText??``});function R(){let e=0;for(let t of document.querySelectorAll(`[data-runs-section]`)){let n=[...t.querySelectorAll(`[data-run]`)],r=n.map(e=>b(j,L(e))),i=t.dataset.runsSection===`recent`,{visible:a,matched:o}=i?y(r,N):{visible:r,matched:r.filter(Boolean).length};n.forEach((e,t)=>e.hidden=!a[t]),e+=o;let s=t.querySelector(`[data-section-count]`);if(s&&(s.textContent=String(o)),i&&P){let e=Math.min(o,N);P.hidden=o<=N,I&&(I.textContent=`Showing the newest ${e} of ${o}.`)}}let t=x(j);O&&(O.hidden=!t),k&&(k.hidden=!(t&&e===0&&A.length>0))}F?.addEventListener(`click`,()=>{N+=50,R()});function z(e){j={...j,...e},N=50,R(),w.replace(C(j),{})}T?.addEventListener(`input`,()=>z({query:T.value})),E?.addEventListener(`change`,()=>z({status:E.value})),D?.addEventListener(`change`,()=>z({kind:D.value})),ne(),re(document.querySelectorAll(`details[data-runs-section]`),e=>n(e.dataset.runsSection)?e.dataset.runsSection:void 0,(e,t)=>fetch(`/runs/sections`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({section:e,collapsed:t})}));for(let e of document.querySelectorAll(`[data-clear-filters], [data-clear-filters-inline]`))e.addEventListener(`click`,()=>{z({status:`all`,kind:`all`,query:``}),M()});M(),R();var B=3e4;function V(){for(let e of document.querySelectorAll(`time[data-since]`)){let t=Number(e.dataset.since);Number.isFinite(t)&&(e.textContent=`${e.dataset.sincePrefix??``} ${h(t)}`.trim())}}window.setInterval(V,B);var H=p(document,{onClose:()=>$()}),U=()=>document.querySelector(`[data-menu-trigger][aria-expanded="true"]`)!==null,W=!1;for(let e of document.querySelectorAll(`[data-run-remove]`))e.addEventListener(`click`,()=>{let n=e.dataset.runRemove,r=e.closest(`[data-run]`);if(!n||!r)return;H.closeAll(),e.disabled=!0,W=!0;let i=n=>{e.disabled=!1,t(ee(),{kind:`failed`,text:n})};fetch(`/runs/remove`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({key:n})}).then(async e=>{if(e.ok||e.status===404)r.remove(),A.splice(A.indexOf(r),1),R();else{let t=await e.json().catch(()=>null);i(typeof t?.error==`string`?t.error:`That run could not be removed. The workspace server refused it.`)}}).catch(()=>i(`The workspace server did not answer. It may have stopped.`)).finally(()=>{W=!1,$()})});var G=g({doc:document,item:`[data-run]`,link:`a.prb-card-link`,walk:()=>A.filter(e=>!e.hidden&&e.closest(`details`)?.open!==!1&&e.querySelector(`a.prb-card-link`)),background:()=>document.querySelector(`.prb-shell > main`)});function K(e){let t=()=>document.querySelector(`details[data-runs-section="${e}"]`);return{available:()=>t()!==null,state:()=>{let e=t();return e?e.open?`Expanded`:`Collapsed`:null},run:()=>{let e=t();e&&(e.open=!e.open)}}}function q(){return G.holdsKeys()?G.current()?.querySelector(`:scope > [data-menu]`)??null:null}var J=Object.fromEntries(f.map(e=>[`runs.section.${e}`,K(e)])),Y=s(`runs`,{"runs.search":{run:()=>T?.focus()},"runs.next":{run:()=>G.move(1)},"runs.previous":{run:()=>G.move(-1)},"runs.open":{available:()=>G.enterOpens(),run:()=>G.open()},"runs.openInNewTab":{available:()=>G.enterOpens(),run:()=>G.openInNewTab()},"runs.menu":{available:()=>q()!==null,run:()=>{let e=q();e&&H.open(e,{focusFirst:!0,returnFocus:()=>G.refocus()})}},...J},{onSettle:()=>$()}),ie=document.body.dataset.runsRevision??``,X=document.body.dataset.live===`true`?Date.now():0,Z=!1;function Q(){return document.activeElement===T||W||Y.isOpen()||U()}function $(){Z&&!Q()&&l()}T?.addEventListener(`blur`,()=>$());async function ae(){try{let t=await fetch(`/runs/revision`);if(t.ok){u(document,!0);let n=await t.json();c(document,n),n.live&&X===0&&(X=Date.now()),n.live||(X=0);let r=e(ie,n.revision??``,Q());if(r===`reload`)return l(),null;r===`hold`&&(Z=!0)}}catch{u(document,!1)}return m(X===0?2**53-1:Date.now()-X)}var oe=r(window,ae);i(document,()=>oe.now()),a(),d(window,()=>window.location.reload());
1
+ import{Y as e,a as t,b as n,ft as r,g as i,h as a,i as o,m as s,n as c,r as l,s as ee,t as te,u,xt as d,y as f}from"./chunk-DRtin0n-.js";import{n as p,t as m}from"./chunk-DMxtqzNj.js";import{t as h}from"./chunk-Dv0Wowan.js";import{t as g}from"./chunk-C8kkSv38.js";import{r as ne,t as re}from"./chunk-Ahis0VaG.js";var _=[`all`,`in-progress`,`completed`,`failed`,`cancelled`,`not-responding`],v=[`all`,`review`,`update`,`re-run`,`kiss`,`ask`,`diagram`];function y(e,t){let n=0;return{visible:e.map(e=>e&&n++<t),matched:e.filter(Boolean).length}}function b(e,t){return e.status!==`all`&&t.status!==e.status||e.kind!==`all`&&t.kind!==e.kind?!1:e.query.toLowerCase().split(/\s+/).filter(Boolean).every(e=>t.searchText.includes(e))}function x(e){return e.status!==`all`||e.kind!==`all`||e.query.trim()!==``}function S(e){let t=new URLSearchParams(e.replace(/^#/,``)),n=t.get(`status`),r=t.get(`kind`);return{status:_.includes(n??``)?n:`all`,kind:v.includes(r??``)?r:`all`,query:t.get(`q`)??``}}function C(e){let t=new URLSearchParams;e.status!==`all`&&t.set(`status`,e.status),e.kind!==`all`&&t.set(`kind`,e.kind),e.query.trim()!==``&&t.set(`q`,e.query);let n=t.toString();return n===``?``:`#${n}`}var w=r();te(`/restart`);var T=document.querySelector(`[data-search]`),E=document.querySelector(`[data-run-status-filter]`),D=document.querySelector(`[data-run-kind-filter]`),O=document.querySelector(`[data-clear-filters]`),k=document.querySelector(`[data-no-matches]`),A=[...document.querySelectorAll(`[data-run]`)],j=S(window.location.hash);E&&![...E.options].some(e=>e.value===j.status)&&(j={...j,status:`all`});function M(){T&&(T.value=j.query),E&&(E.value=j.status),D&&(D.value=j.kind)}var N=50,P=document.querySelector(`[data-runs-more-row]`),F=document.querySelector(`[data-runs-more]`),I=document.querySelector(`[data-runs-more-note]`),L=e=>({status:e.dataset.runStatus??``,kind:e.dataset.runKind??``,searchText:e.dataset.searchText??``});function R(){let e=0;for(let t of document.querySelectorAll(`[data-runs-section]`)){let n=[...t.querySelectorAll(`[data-run]`)],r=n.map(e=>b(j,L(e))),i=t.dataset.runsSection===`recent`,{visible:a,matched:o}=i?y(r,N):{visible:r,matched:r.filter(Boolean).length};n.forEach((e,t)=>e.hidden=!a[t]),e+=o;let s=t.querySelector(`[data-section-count]`);if(s&&(s.textContent=String(o)),i&&P){let e=Math.min(o,N);P.hidden=o<=N,I&&(I.textContent=`Showing the newest ${e} of ${o}.`)}}let t=x(j);O&&(O.hidden=!t),k&&(k.hidden=!(t&&e===0&&A.length>0))}F?.addEventListener(`click`,()=>{N+=50,R()});function z(e){j={...j,...e},N=50,R(),w.replace(C(j),{})}T?.addEventListener(`input`,()=>z({query:T.value})),E?.addEventListener(`change`,()=>z({status:E.value})),D?.addEventListener(`change`,()=>z({kind:D.value})),ne(),re(document.querySelectorAll(`details[data-runs-section]`),e=>n(e.dataset.runsSection)?e.dataset.runsSection:void 0,(e,t)=>fetch(`/runs/sections`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({section:e,collapsed:t})}));for(let e of document.querySelectorAll(`[data-clear-filters], [data-clear-filters-inline]`))e.addEventListener(`click`,()=>{z({status:`all`,kind:`all`,query:``}),M()});M(),R();var B=3e4;function V(){for(let e of document.querySelectorAll(`time[data-since]`)){let t=Number(e.dataset.since);Number.isFinite(t)&&(e.textContent=`${e.dataset.sincePrefix??``} ${h(t)}`.trim())}}window.setInterval(V,B);var H=p(document,{onClose:()=>$()}),U=()=>document.querySelector(`[data-menu-trigger][aria-expanded="true"]`)!==null,W=!1;for(let e of document.querySelectorAll(`[data-run-remove]`))e.addEventListener(`click`,()=>{let n=e.dataset.runRemove,r=e.closest(`[data-run]`);if(!n||!r)return;H.closeAll(),e.disabled=!0,W=!0;let i=n=>{e.disabled=!1,t(ee(),{kind:`failed`,text:n})};fetch(`/runs/remove`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({key:n})}).then(async e=>{if(e.ok||e.status===404)r.remove(),A.splice(A.indexOf(r),1),R();else{let t=await e.json().catch(()=>null);i(typeof t?.error==`string`?t.error:`That run could not be removed. The workspace server refused it.`)}}).catch(()=>i(`The workspace server did not answer. It may have stopped.`)).finally(()=>{W=!1,$()})});var G=g({doc:document,item:`[data-run]`,link:`a.prb-card-link`,walk:()=>A.filter(e=>!e.hidden&&e.closest(`details`)?.open!==!1&&e.querySelector(`a.prb-card-link`)),background:()=>document.querySelector(`.prb-shell > main`)});function K(e){let t=()=>document.querySelector(`details[data-runs-section="${e}"]`);return{available:()=>t()!==null,state:()=>{let e=t();return e?e.open?`Expanded`:`Collapsed`:null},run:()=>{let e=t();e&&(e.open=!e.open)}}}function q(){return G.holdsKeys()?G.current()?.querySelector(`:scope > [data-menu]`)??null:null}var J=Object.fromEntries(f.map(e=>[`runs.section.${e}`,K(e)])),Y=s(`runs`,{"runs.search":{run:()=>T?.focus()},"runs.next":{run:()=>G.move(1)},"runs.previous":{run:()=>G.move(-1)},"runs.open":{available:()=>G.enterOpens(),run:()=>G.open()},"runs.openInNewTab":{available:()=>G.enterOpens(),run:()=>G.openInNewTab()},"runs.menu":{available:()=>q()!==null,run:()=>{let e=q();e&&H.open(e,{focusFirst:!0,returnFocus:()=>G.refocus()})}},...J},{onSettle:()=>$()}),ie=document.body.dataset.runsRevision??``,X=document.body.dataset.live===`true`?Date.now():0,Z=!1;function Q(){return document.activeElement===T||W||Y.isOpen()||U()}function $(){Z&&!Q()&&l()}T?.addEventListener(`blur`,()=>$());async function ae(){try{let t=await fetch(`/runs/revision`);if(t.ok){u(document,!0);let n=await t.json();c(document,n),n.live&&X===0&&(X=Date.now()),n.live||(X=0);let r=e(ie,n.revision??``,Q());if(r===`reload`)return l(),null;r===`hold`&&(Z=!0)}}catch{u(document,!1)}return m(X===0?2**53-1:Date.now()-X)}var oe=i(window,ae);a(document,()=>oe.now()),o(),d(window,()=>window.location.reload());
@@ -1 +1 @@
1
- import{d as e,lt as t,m as n,o as r,t as i,vt as a}from"./chunk-CMC5F4_t.js";function o(e){let t=[...document.querySelectorAll(`[data-shutdown]`)],n=document.querySelector(`[data-shutdown-dialog]`),r=document.querySelector(`[data-shutdown-confirm]`);for(let e of t)e.addEventListener(`click`,()=>n?.showModal());document.querySelector(`[data-shutdown-cancel]`)?.addEventListener(`click`,()=>n?.close()),r?.addEventListener(`click`,()=>{r.disabled=!0,r.textContent=`Stopping…`,fetch(e,{method:`POST`}).then(e=>{if(!e.ok)throw Error(`Shutdown refused: ${e.status}`);n?.close(),s(t)}).catch(()=>{r.disabled=!1,r.textContent=`Stop server`})})}function s(t){document.body.dataset.serverStopped=`true`,e(document,`unreachable`);let n=document.createElement(`div`);n.className=`prb-stopped-notice`,n.setAttribute(`role`,`status`);let r=document.body.dataset.wayBack;n.textContent=r?`Workspace server stopped. This page is no longer being served. Run ${r} to bring it back.`:`Workspace server stopped. This page is no longer being served.`,document.body.prepend(n);for(let e of t)e.disabled=!0,e.classList.contains(`prb-strip-action`)||(e.textContent=`Server stopped`)}var c=[{id:`system`,label:`System`,help:`Follow your device setting`},{id:`light`,label:`Light`,help:`Always use light mode`},{id:`dark`,label:`Dark`,help:`Always use dark mode`}];function l(e){return c.some(t=>t.id===e)}function u(e){let t=e.querySelector(`[data-settings-theme]:checked`)?.value;return l(t)?t:void 0}function d(e,t){e.documentElement.dataset.theme=t}function f(e){for(let t of e.querySelectorAll(`[data-settings-theme]`))t.addEventListener(`change`,()=>{let t=u(e);t&&d(e,t)})}o(`/shutdown`),t(),n(`global`,{}),i(`/restart`),f(document);var p=document.querySelector(`[data-settings-save]`),m=document.querySelector(`[data-settings-status]`),h=document.querySelector(`[data-settings-port]`),g=document.querySelector(`[data-settings-port-error]`),_=document.querySelector(`[data-settings-agent]`);function v(){let e=document.querySelector(`[data-settings-usage]:checked`);return e?e.value===`on`:void 0}function y(e,t){m&&(m.textContent=e,m.dataset.kind=t)}function b(e){g&&(g.textContent=e??``),h&&(e?(h.setAttribute(`aria-invalid`,`true`),h.focus(),h.select()):h.removeAttribute(`aria-invalid`))}async function x(){if(!p)return;let e=v(),t=u(document),n={...h?{port:h.value.trim()}:{},..._?{agent:_.value}:{},...e===void 0?{}:{usageCounts:e},...t===void 0?{}:{theme:t}};p.disabled=!0,p.textContent=`Saving`;try{let e=await(await fetch(`/settings`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)})).json().catch(()=>null);if(!e){y(`Nothing was saved. The workspace server did not answer.`,`error`);return}if(e.error){b(e.error),y(`Nothing was saved.`,`error`);return}b(null),h&&(h.value=String(e.port.configured)),d(document,e.theme),y(e.restartRequired?`Saved. This page is served on port ${e.port.current}; the workspace moves to ${e.port.configured} the next time it starts.`:`Saved.`,`saved`)}catch{y(`Nothing was saved. The workspace server could not be reached.`,`error`)}finally{p.disabled=!1,p.textContent=`Save changes`}}p?.addEventListener(`click`,()=>void x()),r(document,window,{paintUnread:!0}),a(window,()=>window.location.reload());
1
+ import{d as e,ft as t,m as n,o as r,t as i,xt as a}from"./chunk-DRtin0n-.js";function o(e){let t=[...document.querySelectorAll(`[data-shutdown]`)],n=document.querySelector(`[data-shutdown-dialog]`),r=document.querySelector(`[data-shutdown-confirm]`);for(let e of t)e.addEventListener(`click`,()=>n?.showModal());document.querySelector(`[data-shutdown-cancel]`)?.addEventListener(`click`,()=>n?.close()),r?.addEventListener(`click`,()=>{r.disabled=!0,r.textContent=`Stopping…`,fetch(e,{method:`POST`}).then(e=>{if(!e.ok)throw Error(`Shutdown refused: ${e.status}`);n?.close(),s(t)}).catch(()=>{r.disabled=!1,r.textContent=`Stop server`})})}function s(t){document.body.dataset.serverStopped=`true`,e(document,`unreachable`);let n=document.createElement(`div`);n.className=`prb-stopped-notice`,n.setAttribute(`role`,`status`);let r=document.body.dataset.wayBack;n.textContent=r?`Workspace server stopped. This page is no longer being served. Run ${r} to bring it back.`:`Workspace server stopped. This page is no longer being served.`,document.body.prepend(n);for(let e of t)e.disabled=!0,e.classList.contains(`prb-strip-action`)||(e.textContent=`Server stopped`)}var c=[{id:`system`,label:`System`,help:`Follow your device setting`},{id:`light`,label:`Light`,help:`Always use light mode`},{id:`dark`,label:`Dark`,help:`Always use dark mode`}];function l(e){return c.some(t=>t.id===e)}function u(e){let t=e.querySelector(`[data-settings-theme]:checked`)?.value;return l(t)?t:void 0}function d(e,t){e.documentElement.dataset.theme=t}function f(e){for(let t of e.querySelectorAll(`[data-settings-theme]`))t.addEventListener(`change`,()=>{let t=u(e);t&&d(e,t)})}o(`/shutdown`),t(),n(`global`,{}),i(`/restart`),f(document);var p=document.querySelector(`[data-settings-save]`),m=document.querySelector(`[data-settings-status]`),h=document.querySelector(`[data-settings-port]`),g=document.querySelector(`[data-settings-port-error]`),_=document.querySelector(`[data-settings-agent]`);function v(){let e=document.querySelector(`[data-settings-usage]:checked`);return e?e.value===`on`:void 0}function y(e,t){m&&(m.textContent=e,m.dataset.kind=t)}function b(e){g&&(g.textContent=e??``),h&&(e?(h.setAttribute(`aria-invalid`,`true`),h.focus(),h.select()):h.removeAttribute(`aria-invalid`))}async function x(){if(!p)return;let e=v(),t=u(document),n={...h?{port:h.value.trim()}:{},..._?{agent:_.value}:{},...e===void 0?{}:{usageCounts:e},...t===void 0?{}:{theme:t}};p.disabled=!0,p.textContent=`Saving`;try{let e=await(await fetch(`/settings`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)})).json().catch(()=>null);if(!e){y(`Nothing was saved. The workspace server did not answer.`,`error`);return}if(e.error){b(e.error),y(`Nothing was saved.`,`error`);return}b(null),h&&(h.value=String(e.port.configured)),d(document,e.theme),y(e.restartRequired?`Saved. This page is served on port ${e.port.current}; the workspace moves to ${e.port.configured} the next time it starts.`:`Saved.`,`saved`)}catch{y(`Nothing was saved. The workspace server could not be reached.`,`error`)}finally{p.disabled=!1,p.textContent=`Save changes`}}p?.addEventListener(`click`,()=>void x()),r(document,window,{paintUnread:!0}),a(window,()=>window.location.reload());
package/static/shell.css CHANGED
@@ -90,6 +90,22 @@
90
90
  --neutral-subtle: light-dark(rgba(15, 23, 42, 0.06), rgba(139, 148, 158, 0.16));
91
91
  --merged-subtle: light-dark(#f3e8ff, rgba(163, 113, 247, 0.18));
92
92
  --merged-ink: light-dark(#6b21a8, #d2a8ff);
93
+ /* A review's own lifecycle, what happens next with it: Active, Waiting, Done. Named apart from
94
+ --lifecycle-*, which is a pull request's, so the two cannot be swapped by accident. Done is a
95
+ muted slate rather than purple, because purple already means the brand, Merged and branch news. */
96
+ --state-active-subtle: light-dark(#eaf2fd, rgba(56, 139, 253, 0.14));
97
+ --state-active-ink: light-dark(#0b4fae, #9cc4ff);
98
+ --state-active-border: light-dark(rgba(11, 79, 174, 0.3), rgba(56, 139, 253, 0.45));
99
+ --state-waiting-subtle: light-dark(#fff5d6, rgba(210, 153, 34, 0.16));
100
+ --state-waiting-ink: light-dark(#7a5200, #ffd18a);
101
+ --state-waiting-border: light-dark(rgba(138, 92, 0, 0.32), rgba(210, 153, 34, 0.5));
102
+ --state-done-subtle: light-dark(#e8ecf1, rgba(148, 163, 184, 0.16));
103
+ --state-done-ink: light-dark(#334155, #cbd5e1);
104
+ --state-done-border: light-dark(rgba(51, 65, 85, 0.32), rgba(148, 163, 184, 0.45));
105
+ /* The pills' widths, the widest of their words (NOT REVIEWED, WAITING): a press never moves what
106
+ is beside them, and a card can reserve exactly the room its controls take. */
107
+ --status-pill-width: 104px;
108
+ --lifecycle-pill-width: 70px;
93
109
  /* A pull request's lifecycle in Activity: merged, closed, reopened. Blue because purple there
94
110
  means unread, and a merged tile must never be read as a new one. */
95
111
  --lifecycle-subtle: light-dark(#e7f0fd, rgba(56, 139, 253, 0.16));
@@ -408,6 +424,8 @@ body > * { flex: 0 0 auto; }
408
424
  a fixed-width box hanging below the header, and its items have to wrap inside it. */
409
425
  .prb-header-stats > :not(.prb-menu) { white-space: nowrap; }
410
426
  .prb-header-stats .prb-add { color: var(--success); }
427
+ /* The two pills and the change chip read as one pair of facts, closer to each other than to the stats. */
428
+ .prb-state-pills { display: inline-flex; align-items: center; gap: 6px; }
411
429
  .prb-header-stats .prb-del { color: var(--danger); }
412
430
 
413
431
  /* The build, and where to complain about it. Quieter than the change stats — it is provenance,
@@ -3519,12 +3537,17 @@ a.prb-guide-pick { text-decoration: none; }
3519
3537
  .prb-index-more[hidden] { display: none; }
3520
3538
  .prb-index-more:hover { color: var(--text-primary); border-color: var(--border-strong); }
3521
3539
  .prb-card {
3540
+ /* What the controls over the top-right corner take: two pills, the menu and the star, and the
3541
+ gaps between them. The head reserves exactly this, so the title is cut only where they are. */
3542
+ --card-controls-width: calc(var(--status-pill-width) + var(--lifecycle-pill-width) + 26px + 26px + 3 * 6px);
3522
3543
  position: relative;
3544
+ container-type: inline-size;
3523
3545
  border: 1px solid var(--border);
3524
3546
  border-radius: 12px;
3525
3547
  background: var(--surface-raised);
3526
3548
  }
3527
- .prb-card:hover { border-color: var(--border-strong); }
3549
+ /* A stronger edge and the faintest change of ground, and nothing that moves. */
3550
+ .prb-card:hover { border-color: var(--border-strong); background: color-mix(in srgb, var(--surface-raised), var(--text-primary) 2%); }
3528
3551
  .prb-card[hidden] { display: none; }
3529
3552
 
3530
3553
  /* ── Selecting ──
@@ -3768,10 +3791,9 @@ a.prb-guide-pick { text-decoration: none; }
3768
3791
  align-items: baseline;
3769
3792
  justify-content: space-between;
3770
3793
  gap: 12px;
3771
- /* Room for the pin and the menu, both positioned over the card's top-right corner. Reserved
3772
- here rather than left to chance: the status badge is the last thing in this row, and without
3773
- the space it is what the controls sit on top of. */
3774
- padding-right: 56px;
3794
+ /* Room for the controls positioned over the card's top-right corner. Reserved here rather than
3795
+ left to chance: without it the PR state and the change chip are what the controls sit on. */
3796
+ padding-right: calc(var(--card-controls-width) + 6px);
3775
3797
  }
3776
3798
  .prb-card-head h2 {
3777
3799
  /* The auto margin takes the free space, so the status and the PR state sit together at the end
@@ -3847,12 +3869,26 @@ a.prb-guide-pick { text-decoration: none; }
3847
3869
 
3848
3870
  /* News about the change rather than a verdict on it: tinted like the brand, never like a risk.
3849
3871
  It sits in the meta line with the other facts, because that is what it is. */
3850
- .prb-card-moved {
3851
- color: var(--brand);
3872
+ .prb-card-moved,
3873
+ .prb-card-badge {
3874
+ padding: 1px 7px;
3875
+ border-radius: 999px;
3852
3876
  font-weight: 600;
3877
+ white-space: nowrap;
3853
3878
  }
3879
+ .prb-card-moved { background: var(--brand-muted); color: var(--brand-ink); }
3854
3880
  .prb-card-diffstat { font-variant-numeric: tabular-nums; }
3855
- .prb-card-left { color: var(--text-secondary); }
3881
+ /* What is left, as facts: a badge only where there is an outcome to see at a glance (resolved and
3882
+ answered, or still open), plain words for the rest, "Nothing flagged" among them. */
3883
+ .prb-card-left {
3884
+ display: inline-flex;
3885
+ flex-wrap: wrap;
3886
+ align-items: baseline;
3887
+ gap: 8px;
3888
+ color: var(--text-secondary);
3889
+ }
3890
+ .prb-card-badge[data-tone="success"] { background: var(--success-subtle); color: var(--success-ink); }
3891
+ .prb-card-badge[data-tone="attention"] { background: var(--warning-subtle); color: var(--warning-ink); }
3856
3892
 
3857
3893
  /* What is happening to this review right now.
3858
3894
  A dot that breathes, because the one thing this line has to communicate before it is read is
@@ -4045,6 +4081,51 @@ a.prb-guide-pick { text-decoration: none; }
4045
4081
  .prb-card-status { border: 1px solid var(--border); color: var(--text-tertiary, var(--text-secondary)); }
4046
4082
  .prb-card-status[data-status="new"] { border-color: var(--brand); color: var(--brand-ink); }
4047
4083
  .prb-card-status[data-status="complete"] { border-color: var(--success-border); color: var(--success-ink); }
4084
+
4085
+ /* ── Status and lifecycle pills ──
4086
+ Where a review stands, on a card and in the review's header, and the control that changes it
4087
+ (state_pills.ts). Outlined on a faint tint of their own colour, where the facts beside them
4088
+ (Merged, risk, branch news) are filled and borderless, so a control and a fact never look alike.
4089
+ Each kind has one width whatever its words, so pressing one never moves what is beside it. */
4090
+ .prb-state-pill {
4091
+ box-sizing: border-box;
4092
+ display: inline-flex;
4093
+ align-items: center;
4094
+ justify-content: center;
4095
+ gap: 4px;
4096
+ flex: none;
4097
+ padding: 2px 8px;
4098
+ border: 1px solid var(--border-strong);
4099
+ border-radius: 999px;
4100
+ background: var(--neutral-subtle);
4101
+ color: var(--text-secondary);
4102
+ font: inherit;
4103
+ font-size: var(--t-pill);
4104
+ font-weight: 700;
4105
+ line-height: 1.4;
4106
+ letter-spacing: 0.04em;
4107
+ text-transform: uppercase;
4108
+ white-space: nowrap;
4109
+ }
4110
+ .prb-state-pill.prb-card-status { min-width: var(--status-pill-width); }
4111
+ .prb-lifecycle-pill { min-width: var(--lifecycle-pill-width); }
4112
+ .prb-state-pill[data-status="new"] { border-color: var(--brand-border); background: var(--brand-muted); color: var(--brand-ink); }
4113
+ .prb-state-pill[data-status="complete"] { border-color: var(--success-border); background: var(--success-subtle); color: var(--success-ink); }
4114
+ /* A mark as well as a colour, so Reviewed is not told apart by colour alone. Silent to a screen
4115
+ reader, which hears the word. */
4116
+ .prb-state-pill[data-status="complete"]::before { content: '✓' / ''; }
4117
+ .prb-lifecycle-pill[data-lifecycle-pill="active"] { border-color: var(--state-active-border); background: var(--state-active-subtle); color: var(--state-active-ink); }
4118
+ .prb-lifecycle-pill[data-lifecycle-pill="waiting"] { border-color: var(--state-waiting-border); background: var(--state-waiting-subtle); color: var(--state-waiting-ink); }
4119
+ .prb-lifecycle-pill[data-lifecycle-pill="done"] { border-color: var(--state-done-border); background: var(--state-done-subtle); color: var(--state-done-ink); }
4120
+ button.prb-state-pill { cursor: pointer; }
4121
+ /* Pressable, said quietly: the outline takes the word's colour and the ground darkens a step. */
4122
+ button.prb-state-pill:not([aria-busy="true"]):hover {
4123
+ border-color: color-mix(in srgb, currentColor 55%, transparent);
4124
+ box-shadow: inset 0 0 0 999px var(--wash-strong);
4125
+ }
4126
+ button.prb-state-pill:focus-visible { outline: 2px solid var(--brand-hover); outline-offset: 2px; }
4127
+ button.prb-state-pill[aria-busy="true"] { opacity: 0.6; cursor: progress; }
4128
+ .prb-pill-menu .prb-menu-panel { top: 28px; width: 200px; }
4048
4129
  /* The upstream's state, beside the reviewer's. Filled where the status is outlined, so the two read
4049
4130
  as different kinds of fact. Merged takes the forge's own purple; closed is muted rather than red,
4050
4131
  because red on this card already means high risk. */
@@ -4061,19 +4142,42 @@ a.prb-guide-pick { text-decoration: none; }
4061
4142
  padding: 2px 7px;
4062
4143
  border-radius: 999px;
4063
4144
  font-size: var(--t-meta);
4064
- font-weight: 600;
4145
+ font-weight: 700;
4065
4146
  white-space: nowrap;
4066
4147
  background: var(--brand-muted);
4067
4148
  color: var(--brand-ink);
4149
+ /* A step louder than Branch updated, because a parked review that moved is the thing to find when
4150
+ scanning a long list. An inset edge, so it is no bigger than the pills beside it. */
4151
+ box-shadow: inset 0 0 0 1px var(--brand-border);
4068
4152
  }
4069
4153
  .prb-card-lifecycle[hidden] { display: none; }
4070
4154
 
4071
- /* Over the card rather than inside its link, so pinning cannot be a mis-click into the review. */
4072
- .prb-card-pin {
4155
+ /* The card's controls, over its top-right corner rather than inside its link, so no press on them
4156
+ can be a mis-click into the review. No z-index of its own: each control keeps the layer it had
4157
+ when the pin and the menu sat here alone, the pin and the pills under any open panel above them
4158
+ (a collection's menu, the card's above), the menu over them. Waiting's items rise while open. */
4159
+ .prb-card-controls {
4073
4160
  position: absolute;
4074
4161
  top: 10px;
4075
4162
  right: 10px;
4076
- z-index: 1;
4163
+ display: flex;
4164
+ align-items: center;
4165
+ gap: 6px;
4166
+ }
4167
+ .prb-card-controls > .prb-state-pill,
4168
+ .prb-card-controls > .prb-card-pin { position: relative; z-index: 1; }
4169
+ .prb-card-controls > .prb-menu { position: relative; top: auto; right: auto; }
4170
+ .prb-card-controls > .prb-pill-menu { z-index: 1; }
4171
+ .prb-card-controls > .prb-pill-menu:has(> [aria-expanded="true"]) { z-index: 3; }
4172
+ /* Where the title would be cut short, the controls take a line of their own under it instead, at
4173
+ the title's own left edge. The title is one line, so the line it leaves is a fixed height. */
4174
+ @container (max-width: 560px) {
4175
+ .prb-card[data-card] .prb-card-head { padding-right: 0; margin-bottom: 38px; }
4176
+ .prb-card-controls { top: 42px; right: auto; left: 16px; }
4177
+ .prb-index[data-selecting] .prb-card-controls { left: 42px; }
4178
+ }
4179
+
4180
+ .prb-card-pin {
4077
4181
  width: 26px;
4078
4182
  height: 26px;
4079
4183
  border: 0;
@@ -4222,18 +4326,6 @@ a.prb-guide-pick { text-decoration: none; }
4222
4326
  line-height: var(--lh-body);
4223
4327
  }
4224
4328
 
4225
- /* The review page's lifecycle pill is the status pill's shape. Changed since it was parked, it
4226
- reads as the card's chip does: a sentence, tinted like news. */
4227
- .prb-page-lifecycle[data-changed] {
4228
- border-color: transparent;
4229
- background: var(--brand-muted);
4230
- color: var(--brand-ink);
4231
- font-size: var(--t-meta);
4232
- font-weight: 600;
4233
- letter-spacing: 0;
4234
- text-transform: none;
4235
- }
4236
- .prb-page-lifecycle[hidden] { display: none; }
4237
4329
 
4238
4330
  /* ── Diagrams ──
4239
4331
  *